Extract copilot library service into standalone copilot module#851
Extract copilot library service into standalone copilot module#851RNViththagan wants to merge 4 commits intoballerina-platform:1.7.xfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughRefactors Copilot components into a new module Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/response/GetAllLibrariesResponse.java (1)
49-60: Minor: Inconsistent blank lines inside methods.The
getLibraries()andsetLibraries()methods have unnecessary blank lines after the opening brace, unlike the error handling methods above. Consider removing for consistency.♻️ Proposed formatting fix
public GetAllLibrariesResponse() { } public JsonArray getLibraries() { - return libraries; } public void setLibraries(JsonArray libraries) { - this.libraries = libraries; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/response/GetAllLibrariesResponse.java` around lines 49 - 60, Remove the unnecessary blank lines inside the accessor methods of GetAllLibrariesResponse: collapse the extra empty lines immediately after the opening brace in getLibraries() and setLibraries() so the methods read consistently like the other methods (returning/assigning the field libraries directly inside the method body).copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/database/LibraryDatabaseAccessor.java (2)
127-128: Consider documenting the MAX_SEARCH_RESULTS value choice.The constant
MAX_SEARCH_RESULTS = 9appears arbitrary. A brief comment explaining why 9 results was chosen (e.g., UI constraints, UX considerations) would help future maintainers understand the rationale.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/database/LibraryDatabaseAccessor.java` around lines 127 - 128, The constant MAX_SEARCH_RESULTS in LibraryDatabaseAccessor is undocumented and its value (9) seems arbitrary; add a brief comment next to the declaration explaining the rationale (e.g., UI row/column constraints, UX reasons, pagination behavior, or alignment with frontend components) so future maintainers know why 9 was chosen and when it may be changed. Reference the MAX_SEARCH_RESULTS constant in LibraryDatabaseAccessor and ensure the comment mentions the specific UI or UX constraint that drove the choice.
212-214: Clarify the ConnectorFTS source multiplier rationale.The comment describes ConnectorFTS as "primary library entry points," yet it has the lowest source multiplier (0.8) compared to Package (1.0), Type (0.9), and Function (1.0). This seems counterintuitive. Consider updating the comment to explain why primary entry points are de-prioritized, or adjust the multiplier if this is unintended.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/database/LibraryDatabaseAccessor.java` around lines 212 - 214, The ConnectorFTS source multiplier (0.8) is inconsistent with the comment that labels ConnectorFTS as "primary library entry points"; either update the SQL/comment or the multiplier to remove the contradiction: locate the SQL fragment using ConnectorFTS in LibraryDatabaseAccessor (the SELECT p.id, bm25(ConnectorFTS, 10.0, 2.0, 5.0) * 0.8 AS weighted_score expression), then either change the multiplier to match other primary sources (e.g., 1.0) or revise the inline comment to explain why ConnectorFTS is intentionally de-prioritized (e.g., lower relevance due to noise or broader matches), ensuring the comment and multiplier reflect the same rationale.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/InstructionAugmentationTest.java`:
- Line 38: The TestNG suite still references the old fully-qualified class name
for the renamed test class; update the testng.xml TestNG suite entry to point to
the new FQCN for InstructionAugmentationTest (the class declared as
InstructionAugmentationTest in package io.ballerina.copilot.library.extension)
so TestNG can discover and run the test; locate the old FQCN reference in the
testng.xml suite configuration and replace it with
io.ballerina.copilot.library.extension.InstructionAugmentationTest.
In
`@copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryListTest.java`:
- Line 38: Update the TestNG suite entries that reference the old migrated test
class FQCNs: replace
io.ballerina.flowmodelgenerator.extension.CopilotLibraryListTest with
io.ballerina.copilot.library.extension.LibraryListTest and replace
io.ballerina.flowmodelgenerator.extension.CopilotLibraryFilterTest with
io.ballerina.copilot.library.extension.LibraryFilterTest in the testng.xml so
TestNG can discover the renamed classes (verify the class names match the actual
test classes LibraryListTest and LibraryFilterTest).
---
Nitpick comments:
In
`@copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/database/LibraryDatabaseAccessor.java`:
- Around line 127-128: The constant MAX_SEARCH_RESULTS in
LibraryDatabaseAccessor is undocumented and its value (9) seems arbitrary; add a
brief comment next to the declaration explaining the rationale (e.g., UI
row/column constraints, UX reasons, pagination behavior, or alignment with
frontend components) so future maintainers know why 9 was chosen and when it may
be changed. Reference the MAX_SEARCH_RESULTS constant in LibraryDatabaseAccessor
and ensure the comment mentions the specific UI or UX constraint that drove the
choice.
- Around line 212-214: The ConnectorFTS source multiplier (0.8) is inconsistent
with the comment that labels ConnectorFTS as "primary library entry points";
either update the SQL/comment or the multiplier to remove the contradiction:
locate the SQL fragment using ConnectorFTS in LibraryDatabaseAccessor (the
SELECT p.id, bm25(ConnectorFTS, 10.0, 2.0, 5.0) * 0.8 AS weighted_score
expression), then either change the multiplier to match other primary sources
(e.g., 1.0) or revise the inline comment to explain why ConnectorFTS is
intentionally de-prioritized (e.g., lower relevance due to noise or broader
matches), ensuring the comment and multiplier reflect the same rationale.
In
`@copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/response/GetAllLibrariesResponse.java`:
- Around line 49-60: Remove the unnecessary blank lines inside the accessor
methods of GetAllLibrariesResponse: collapse the extra empty lines immediately
after the opening brace in getLibraries() and setLibraries() so the methods read
consistently like the other methods (returning/assigning the field libraries
directly inside the method body).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e6a3c13c-d48c-4730-aa8b-b2a2e48bf74e
📒 Files selected for processing (71)
copilot/modules/copilot-library-core/build.gradlecopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/CopilotLibraryManager.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/InstructionLoader.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/adapters/StringPathAdapter.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/builder/TypeDefDataBuilder.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/builder/TypeLinkBuilder.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/database/LibraryDatabaseAccessor.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Client.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/EnumValue.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Field.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Library.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/LibraryFunction.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Listener.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/ModelToJsonConverter.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Parameter.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/PathElement.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/PathSegment.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Return.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Service.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/ServiceRemoteFunction.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/StringPath.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Type.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeDef.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeDefMember.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeLink.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/UnionValue.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/service/ServiceLoader.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/LibraryModelConverter.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/SymbolProcessor.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/TypeSymbolExtractor.javacopilot/modules/copilot-library-core/src/main/java/module-info.javacopilot/modules/copilot-library-core/src/main/resources/central-index.sqlitecopilot/modules/copilot-library-core/src/main/resources/copilot/exclusion.jsoncopilot/modules/copilot-library-core/src/main/resources/copilot/generic-services.jsoncopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/README.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/ai/library.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/ai/service.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/graphql/service.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/http/service.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/http/test.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/test/library.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerinax/client.config/library.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerinax/mailchimp.transactional/library.mdcopilot/modules/copilot-library-core/src/main/resources/search-index.sqlitecopilot/modules/copilot-library-ls-extension/build.gradlecopilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/CopilotLibraryService.javacopilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetAllLibrariesRequest.javacopilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetLibrariesBySearchRequest.javacopilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetSelectedLibrariesRequest.javacopilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/response/GetAllLibrariesResponse.javacopilot/modules/copilot-library-ls-extension/src/main/java/module-info.javacopilot/modules/copilot-library-ls-extension/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerServicecopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/GetFilteredLibrariesFromSemanticModel.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/GetLibrariesListFromSearchIndex.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/InstructionAugmentationTest.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/InstructionLoaderTest.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryExclusionTest.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryFilterTest.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryListTest.javacopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries_from_semantic_api.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries_salesforce.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries_trigger_github.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries_trigger_salesforce.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_libraries_list.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_libraries_list_from_database.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_libraries_list_healthcare.jsonflow-model-generator/modules/flow-model-generator-core/build.gradleflow-model-generator/modules/flow-model-generator-core/src/main/java/module-info.javaflow-model-generator/modules/flow-model-generator-ls-extension/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerServicesettings.gradle
💤 Files with no reviewable changes (3)
- flow-model-generator/modules/flow-model-generator-core/build.gradle
- flow-model-generator/modules/flow-model-generator-ls-extension/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService
- flow-model-generator/modules/flow-model-generator-core/src/main/java/module-info.java
...ension/src/test/java/io/ballerina/copilot/library/extension/InstructionAugmentationTest.java
Show resolved
Hide resolved
...brary-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryListTest.java
Show resolved
Hide resolved
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
copilot/modules/copilot-library-ls-extension/build.gradle (1)
99-103: Use append operator for compiler args to align with codebase patterns and defend against future upstream configurations.The current assignment
options.compilerArgs = [...]can drop args if added upstream, though gradle/javaProject.gradle doesn't currently configure them. Several modules in the codebase use the safer append operator (<<) instead. Prefer the refactored approach for consistency and defensiveness:Proposed refactor
compileJava { doFirst { - options.compilerArgs = [ - '--module-path', classpath.asPath, - ] + def existingArgs = options.compilerArgs ?: [] + options.compilerArgs = existingArgs + [ + '--module-path', classpath.asPath, + ] classpath = files() } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@copilot/modules/copilot-library-ls-extension/build.gradle` around lines 99 - 103, Replace the assignment to options.compilerArgs inside the compileJava.doFirst block with append operations so existing upstream args aren’t overwritten; specifically, in the compileJava closure change options.compilerArgs = ['--module-path', classpath.asPath] to append the two elements (e.g., options.compilerArgs << '--module-path' << classpath.asPath) so compileJava and options.compilerArgs keep prior entries while adding these flags.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/database/LibraryDatabaseAccessor.java`:
- Around line 154-166: The primary subquery branches (primaryPackageQuery and
primaryNameDescQuery produced by formatForPackageFTS and
formatForNameDescriptionFTS) must be omitted when they are identical to their
fallbacks (allPackageQuery / allNameDescQuery) to avoid duplicating hits and
inflating score; update the query construction logic that builds the
UNION/priority-boosting clauses so it only appends/emits the primary subquery
pieces if primaryPackageQuery != allPackageQuery and primaryNameDescQuery !=
allNameDescQuery (respectively), keeping the existing fallback assignments but
preventing duplicate MATCH terms from being added to the final SQL when they
collapse to the same value.
- Around line 168-256: The query in LibraryDatabaseAccessor.java (the sql String
building the weighted union that creates the combined subquery and uses COUNT(*)
to compute the multi-match bonus) lets large packages gain bonus by counting
many symbol rows; fix by collapsing each source to one row per package before
final aggregation and counting distinct sources instead of raw rows: in each
SELECT inside the UNION ALL (PackageFTS/TypeFTS/ConnectorFTS/FunctionFTS) group
by p.id and emit a source label (e.g., 'pkg','type','connector','func') and a
single per-package score (MIN(weighted_score) or AVG as appropriate), then in
the outer query join that aggregated combined result and replace COUNT(*) with
COUNT(DISTINCT source_label) and subtract (COUNT(DISTINCT source_label) - 1) *
0.2 when computing combined_score; locate the sql variable and the combined
subquery/alias to implement these changes.
In `@copilot/modules/copilot-library-ls-extension/build.gradle`:
- Around line 86-87: The build script hardcodes
"build/extracted-distribution/..." when defining ballerinaDist; change it to use
the existing project.buildDir (or the balDistribution variable if present) so
the path respects overridden buildDir. Locate the declaration for def
ballerinaDist and replace the hardcoded "build/..." string with a path
constructed from project.buildDir (or reuse balDistribution) so tests copy
stdlibs into the correct distribution directory when buildDir is customized.
---
Nitpick comments:
In `@copilot/modules/copilot-library-ls-extension/build.gradle`:
- Around line 99-103: Replace the assignment to options.compilerArgs inside the
compileJava.doFirst block with append operations so existing upstream args
aren’t overwritten; specifically, in the compileJava closure change
options.compilerArgs = ['--module-path', classpath.asPath] to append the two
elements (e.g., options.compilerArgs << '--module-path' << classpath.asPath) so
compileJava and options.compilerArgs keep prior entries while adding these
flags.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6d0eebe9-24fe-47ec-8b04-293832c460aa
📒 Files selected for processing (72)
copilot/modules/copilot-library-core/build.gradlecopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/CopilotLibraryManager.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/InstructionLoader.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/adapters/StringPathAdapter.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/builder/TypeDefDataBuilder.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/builder/TypeLinkBuilder.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/database/LibraryDatabaseAccessor.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Client.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/EnumValue.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Field.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Library.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/LibraryFunction.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Listener.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/ModelToJsonConverter.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Parameter.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/PathElement.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/PathSegment.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Return.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Service.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/ServiceRemoteFunction.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/StringPath.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Type.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeDef.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeDefMember.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeLink.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/UnionValue.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/service/ServiceLoader.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/LibraryModelConverter.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/SymbolProcessor.javacopilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/TypeSymbolExtractor.javacopilot/modules/copilot-library-core/src/main/java/module-info.javacopilot/modules/copilot-library-core/src/main/resources/central-index.sqlitecopilot/modules/copilot-library-core/src/main/resources/copilot/exclusion.jsoncopilot/modules/copilot-library-core/src/main/resources/copilot/generic-services.jsoncopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/README.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/ai/library.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/ai/service.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/graphql/service.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/http/service.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/http/test.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/test/library.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerinax/client.config/library.mdcopilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerinax/mailchimp.transactional/library.mdcopilot/modules/copilot-library-core/src/main/resources/search-index.sqlitecopilot/modules/copilot-library-ls-extension/build.gradlecopilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/CopilotLibraryService.javacopilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetAllLibrariesRequest.javacopilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetLibrariesBySearchRequest.javacopilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetSelectedLibrariesRequest.javacopilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/response/GetAllLibrariesResponse.javacopilot/modules/copilot-library-ls-extension/src/main/java/module-info.javacopilot/modules/copilot-library-ls-extension/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerServicecopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/GetFilteredLibrariesFromSemanticModel.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/GetLibrariesListFromSearchIndex.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/InstructionAugmentationTest.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/InstructionLoaderTest.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryExclusionTest.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryFilterTest.javacopilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryListTest.javacopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries_from_semantic_api.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries_salesforce.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries_trigger_github.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries_trigger_salesforce.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_libraries_list.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_libraries_list_from_database.jsoncopilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_libraries_list_healthcare.jsonflow-model-generator/modules/flow-model-generator-core/build.gradleflow-model-generator/modules/flow-model-generator-core/src/main/java/module-info.javaflow-model-generator/modules/flow-model-generator-ls-extension/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerServiceflow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/testng.xmlsettings.gradle
💤 Files with no reviewable changes (4)
- flow-model-generator/modules/flow-model-generator-core/build.gradle
- flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/testng.xml
- flow-model-generator/modules/flow-model-generator-ls-extension/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService
- flow-model-generator/modules/flow-model-generator-core/src/main/java/module-info.java
✅ Files skipped from review due to trivial changes (24)
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/LibraryFunction.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Field.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/EnumValue.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Parameter.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Library.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Return.java
- copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/InstructionLoaderTest.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/InstructionLoader.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeDefMember.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/PathElement.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Service.java
- copilot/modules/copilot-library-ls-extension/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/ServiceRemoteFunction.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/adapters/StringPathAdapter.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/CopilotLibraryManager.java
- copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetLibrariesBySearchRequest.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/service/ServiceLoader.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/TypeSymbolExtractor.java
- copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryListTest.java
- copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/GetLibrariesListFromSearchIndex.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/SymbolProcessor.java
- copilot/modules/copilot-library-ls-extension/src/main/java/module-info.java
- copilot/modules/copilot-library-core/build.gradle
- copilot/modules/copilot-library-core/src/main/java/module-info.java
🚧 Files skipped from review as they are similar to previous changes (21)
- copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetSelectedLibrariesRequest.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/PathSegment.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeLink.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeDef.java
- copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/GetFilteredLibrariesFromSemanticModel.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/StringPath.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/builder/TypeDefDataBuilder.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/ModelToJsonConverter.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/UnionValue.java
- copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetAllLibrariesRequest.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Type.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Client.java
- copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryFilterTest.java
- copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/InstructionAugmentationTest.java
- settings.gradle
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/LibraryModelConverter.java
- copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryExclusionTest.java
- copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/response/GetAllLibrariesResponse.java
- copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/CopilotLibraryService.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Listener.java
- copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/builder/TypeLinkBuilder.java
...ibrary-core/src/main/java/io/ballerina/copilot/library/database/LibraryDatabaseAccessor.java
Outdated
Show resolved
Hide resolved
...ibrary-core/src/main/java/io/ballerina/copilot/library/database/LibraryDatabaseAccessor.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR extracts the Copilot library search/retrieval feature set from flow-model-generator into a new standalone copilot module, split into a reusable core library and a dedicated LS-extension module, while also carrying forward the weighted BM25 search improvements.
Changes:
- Added new Gradle subprojects
copilot-library-coreandcopilot-library-ls-extension, and wired them into the build. - Moved/repackaged Copilot library core + resources (SQLite index usage, instruction resources, exclusions, generic services) into
io.ballerina.copilot.library. - Moved the JSON-RPC LS service + request/response types and associated tests into the new LS-extension module.
Reviewed changes
Copilot reviewed 51 out of 72 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| settings.gradle | Registers the new copilot subprojects in the multi-project build. |
| flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/testng.xml | Removes Copilot-related test classes from the old LS-extension test suite. |
| flow-model-generator/modules/flow-model-generator-ls-extension/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService | Unregisters the Copilot library service from the old LS extension. |
| flow-model-generator/modules/flow-model-generator-core/src/main/java/module-info.java | Removes sqlite-jdbc requirement and Copilot package exports from the old core module descriptor. |
| flow-model-generator/modules/flow-model-generator-core/build.gradle | Drops sqlite-jdbc dependency from the old core module. |
| copilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_libraries_list.json | Adds LS test fixture for listing libraries (empty expectation). |
| copilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_libraries_list_healthcare.json | Adds LS test fixture for listing libraries in HEALTHCARE mode. |
| copilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries_trigger_salesforce.json | Adds LS test fixture for exclusion behavior (trigger.salesforce). |
| copilot/modules/copilot-library-ls-extension/src/test/resources/copilot_library/get_filtered_libraries_salesforce.json | Adds large LS test fixture validating filtered library details for Salesforce. |
| copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryListTest.java | Migrates/renames list test into the new Copilot LS-extension package. |
| copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryFilterTest.java | Migrates/renames filter test into the new Copilot LS-extension package. |
| copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/LibraryExclusionTest.java | Migrates/renames exclusion test to use the new Copilot core package. |
| copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/InstructionLoaderTest.java | Migrates instruction loader test to the new Copilot core API. |
| copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/InstructionAugmentationTest.java | Migrates/renames instruction augmentation test to the new Copilot LS-extension package. |
| copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/GetLibrariesListFromSearchIndex.java | Migrates list-from-index LS test to the new Copilot LS-extension package. |
| copilot/modules/copilot-library-ls-extension/src/test/java/io/ballerina/copilot/library/extension/GetFilteredLibrariesFromSemanticModel.java | Migrates semantic-model filtering LS test to the new Copilot LS-extension package. |
| copilot/modules/copilot-library-ls-extension/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService | Registers the new CopilotLibraryService via SPI in the new LS-extension module. |
| copilot/modules/copilot-library-ls-extension/src/main/java/module-info.java | Introduces the JPMS descriptor for the new Copilot LS-extension module. |
| copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/response/GetAllLibrariesResponse.java | Introduces/migrates response type for the LS endpoints in the new module namespace. |
| copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetSelectedLibrariesRequest.java | Migrates request type to the new module namespace. |
| copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetLibrariesBySearchRequest.java | Migrates request type to the new module namespace. |
| copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/request/GetAllLibrariesRequest.java | Migrates request type to the new module namespace. |
| copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/CopilotLibraryService.java | Migrates LS JSON-RPC service implementation to the new module namespace. |
| copilot/modules/copilot-library-ls-extension/build.gradle | Adds Gradle build for the new Copilot LS-extension module (including stdlib unpacking for tests). |
| copilot/modules/copilot-library-core/src/main/resources/copilot/instructions/README.md | Adds contribution guide for custom library instruction resources. |
| copilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerinax/mailchimp.transactional/library.md | Adds library-specific instruction override for reserved keyword import. |
| copilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerinax/client.config/library.md | Adds library-specific instruction override for reserved keyword import. |
| copilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/test/library.md | Adds testing guidance instruction bundle for Copilot augmentation. |
| copilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/http/test.md | Adds HTTP test-generation instructions for Copilot augmentation. |
| copilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/http/service.md | Adds HTTP service/client authoring instructions for Copilot augmentation. |
| copilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/graphql/service.md | Adds GraphQL service authoring instructions for Copilot augmentation. |
| copilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/ai/service.md | Adds AI service/agent/RAG authoring instructions for Copilot augmentation. |
| copilot/modules/copilot-library-core/src/main/resources/copilot/instructions/ballerina/ai/library.md | Adds AI library overview instructions for Copilot augmentation. |
| copilot/modules/copilot-library-core/src/main/resources/copilot/generic-services.json | Adds generic service templates metadata for selected standard libraries. |
| copilot/modules/copilot-library-core/src/main/resources/copilot/exclusion.json | Adds exclusion rules for libraries/functions not to surface. |
| copilot/modules/copilot-library-core/src/main/java/module-info.java | Introduces the JPMS descriptor for the new Copilot core module and its exported packages. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/TypeSymbolExtractor.java | Migrates type link extraction utility to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/SymbolProcessor.java | Migrates symbol processing logic to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/util/LibraryModelConverter.java | Migrates model conversion utilities to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/service/ServiceLoader.java | Migrates service definition loader to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/UnionValue.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeLink.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeDefMember.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/TypeDef.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Type.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/StringPath.java | Migrates model type and adapter reference to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/ServiceRemoteFunction.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Service.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Return.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/PathSegment.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/PathElement.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Parameter.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/ModelToJsonConverter.java | Migrates model JSON conversion helper to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Listener.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/LibraryFunction.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Library.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Field.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/EnumValue.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/model/Client.java | Migrates model type to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/InstructionLoader.java | Migrates instruction loader to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/database/LibraryDatabaseAccessor.java | Migrates DB accessor and includes the weighted BM25 query updates. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/CopilotLibraryManager.java | Migrates the manager façade to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/builder/TypeLinkBuilder.java | Migrates builder utility to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/builder/TypeDefDataBuilder.java | Migrates builder utility to the new module namespace. |
| copilot/modules/copilot-library-core/src/main/java/io/ballerina/copilot/library/adapters/StringPathAdapter.java | Migrates Gson adapter to the new module namespace. |
| copilot/modules/copilot-library-core/build.gradle | Adds Gradle build for the new Copilot core module (incl. sqlite-jdbc). |
Comments suppressed due to low confidence (1)
copilot/modules/copilot-library-ls-extension/src/main/java/io/ballerina/copilot/library/extension/response/GetAllLibrariesResponse.java:39
- This response class now defines errorMsg/stacktrace and a setError(Throwable) helper, but there are currently no call sites in this module that populate these fields (the service methods construct a response and only set libraries). As a result, clients will never receive structured error details through this type. Consider either wiring setError(...) into the service implementation or removing these unused fields/method to avoid a misleading API surface.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5fe3020 to
3a5c718
Compare
Move the copilot library search and retrieval code out of flow-model-generator
into a new first-class copilot module with the standard -core/-ls-extension split:
- copilot/modules/copilot-library-core: pure Java, no LS dependency
- copilot/modules/copilot-library-ls-extension: LSP endpoint + tests
Repackages all classes from io.ballerina.flowmodelgenerator.core.copilot
to io.ballerina.copilot.library. The JSON-RPC API surface is unchanged
(@JsonSegment("copilotLibraryManager") and all three @JsonRequest endpoints).
- Remove stale copilot test class entries from flow-model-generator-ls-extension testng.xml - Remove unnecessary blank lines in GetAllLibrariesResponse accessor methods
Description
Extracts the copilot library search and retrieval functionality from
flow-model-generatorinto a new dedicated
copilotmodule following the standard-core/-ls-extensionsplit.New module structure
copilot/
modules/
copilot-library-core/
copilot-library-ls-extension/
Changes
io.ballerina.flowmodelgenerator.core.copilotto
io.ballerina.copilot.librarycopilot/instruction resources tocopilot-library-coreCopilotLibraryServiceand request/response types tocopilot-library-ls-extensionsqlite-jdbcdependency and copilot exports fromflow-model-generator-coreAPI compatibility
The following endpoints remain unchanged:
copilotLibraryManager/getLibrariesListcopilotLibraryManager/getFilteredLibrariescopilotLibraryManager/getLibrariesBySearchThis PR extracts the Copilot library search and retrieval functionality from the flow-model-generator module into a dedicated copilot module, splitting it into a core library and a language-server extension, and applies related refactors and build updates.
Key changes
New modules
Packaging and API surface
Search ranking and behavior
Build and dependency updates
Tests and service registration
Minor API change
Intent