-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Inline completions in @vscode/chat-lib #2131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…mas for dependency extraction
…ectory cannot be found
…s of chat-lib and add missing completions dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR integrates inline completions functionality into the @vscode/chat-lib package, making it available for external consumption. The main purpose is to export a createInlineCompletionsProvider function that allows consumers to create inline completion providers with extensive customization options.
Key changes:
- Exports inline completions provider creation functionality through
chatLibMain.ts - Refactors service dependencies to support chat-lib usage (removes direct VS Code API dependencies)
- Enhances the build system to handle path aliases and improved dependency tracking
- Adds comprehensive test coverage for the new inline completions API
Reviewed Changes
Copilot reviewed 19 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/platform/telemetry/node/azureInsightsReporter.ts | Exports unwrapEventNameFromPrefix function for telemetry event name normalization in chat-lib |
| src/lib/node/chatLibMain.ts | Main integration point: exports inline completions provider creation with extensive service setup and bridging |
| src/extension/completions-core/vscode-node/prompt/src/fileLoader.ts | Improves path resolution to work correctly in both TypeScript source and transpiled JavaScript contexts |
| src/extension/completions-core/vscode-node/lib/src/telemetry/userConfig.ts | Ensures telemetry user config is initialized immediately when copilot token is already available |
| src/extension/completions-core/vscode-node/lib/src/notificationSender.ts | Removes direct VS Code API dependency, uses injected notification service instead |
| src/extension/completions-core/vscode-node/lib/src/error/userErrorNotifier.ts | Removes direct VS Code API dependency, uses injected env service instead |
| src/extension/completions-core/vscode-node/lib/src/config.ts | Exports EditorInfo and EditorPluginInfo types for chat-lib API surface |
| src/extension/completions-core/vscode-node/lib/src/completionsObservableWorkspace.ts | Removes implementation, keeps only interface definition to avoid circular dependencies |
| src/extension/completions-core/vscode-node/extension/src/completionsObservableWorkspace.ts | Moves CompletionsObservableWorkspace implementation to extension-specific location |
| src/extension/completions-core/vscode-node/completionsServiceBridges.ts | Updates import path for moved CompletionsObservableWorkspace class and fixes service descriptor |
| script/build/extractChatLib.ts | Significantly enhances build script to handle path aliases, JSX imports, and improved comment filtering |
| package.json | Adds explicit dependency on @sinclair/typebox (previously transitive) |
| eslint.config.mjs | Disables restricted import paths rule for chatLibMain.ts to allow cross-boundary imports |
| chat-lib/vitest.config.ts | Removes unused path import |
| chat-lib/tsconfig.json | Adds empty paths object (populated by build script) |
| chat-lib/test/getInlineCompletions.spec.ts | Comprehensive test for inline completions provider functionality |
| chat-lib/test/getInlineCompletions.reply.txt | Test fixture containing mock completion response data |
| chat-lib/script/postinstall.ts | New script to copy static assets (tiktoken files and tree-sitter grammars) after installation |
| chat-lib/package.json | Adds required dependencies and postinstall script |
Files not reviewed (1)
- chat-lib/package-lock.json: Language not supported
| if (this._telemetrySender.sendEnhancedTelemetryEvent) { | ||
| this._telemetrySender.sendEnhancedTelemetryEvent(eventName, eventPropertiesToSimpleObject(properties), measurements); | ||
| } |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation should avoid creating adhoc one-off mocks. Consider creating a reusable MockTelemetrySender class under a test/ folder that can be configured for different test scenarios, similar to existing patterns like MockFileSystemService.
| // Track block comments | ||
| if (line.trim().startsWith('/*')) { | ||
| // preserve pragmas in tsx files | ||
| if (!(filePath.endsWith('.tsx') && line.match(/\/\*\*\s+@jsxImportSource\s+\S+/))) { |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern for JSX import source appears twice (here and at line 233). Extract this into a named constant to avoid duplication and improve maintainability.
|
|
||
| } | ||
|
|
||
| main(); |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main function call should handle errors. If the async operation fails, the postinstall script will silently succeed. Add .catch(err => { console.error(err); process.exit(1); }) to properly propagate errors.
|
@microsoft-github-policy-service agree company="GitHub" |
chrmarti
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Include inline completions in @vscode/chat-lib
This exports a function for creating an
IInlineCompletionsProvider:The returned instance provides methods for updating treatment variables and getting inline completions:
The options object for creating a provider is fairly complex. It allows for customizing much of what was previously passed in to the completions function via a
Contextobject. This is probably a good area for simplifying in future iterations.I also discovered an undeclared dependency that I've added to the main
package.json. Some of the completions code depends on@sinclair/typebox. That's being indirectly supplied by@vitest/snapshotright now, but it we should have an explicit dependency. I'm using the same version as the completions extension here.