-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ghost context provider #3506
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
Merged
Merged
Ghost context provider #3506
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
1c0e0c1
WiP ghost context provider
beatlevic 0d5a465
Use pure function for formatContextForPrompt
beatlevic c067c1d
Added more context snippets like clipboard, static, recentlyVisited a…
beatlevic dc1f5f6
Improved categorizeSnippets
beatlevic 3ade747
Used comment wrapped formatSnippets directly
beatlevic 5810ccb
Removed RECENT_EDITS
beatlevic 3e3060c
Cleanup auto trigger strategy test
beatlevic a90e41a
Removed Ghost recent operations spec
beatlevic d10b8bc
Merge branch 'main' into beatlevic/ghost-context-provider
beatlevic 2334465
Cleanup ghost context provider
beatlevic 4c28d9b
Cleanup GhostContextProvider.test.ts
beatlevic b935be2
Plumb through GhostContextProvider
jrf0110 44f5165
Added GhostRecentlyVisitedRangesService to keep track of recent files
beatlevic ead100a
Added GhostRecentlyEditedTracker
beatlevic f9378a9
Use recentlyEditedRanges and recentlyVisitedRanges services directly
beatlevic 1432705
Added continuedev dispose methods
beatlevic dd4f395
Merge branch 'main' into beatlevic/ghost-context-provider
beatlevic adcac93
Merge branch 'main' into beatlevic/ghost-context-provider
beatlevic aad27a6
Fixed GhostInlineCompletionProvider.test.ts
beatlevic 7bf414b
Merge branch 'beatlevic/ghost-context-provider' of github.com:Kilo-Or…
beatlevic a3c1aad
Merge branch 'main' into beatlevic/ghost-context-provider
beatlevic 48450b3
Merge branch 'main' into beatlevic/ghost-context-provider
beatlevic 787ec84
Fixed HoleFiller.test.ts
beatlevic bdfceaa
Removed addCursorMarker from HoleFiller
beatlevic 3eed116
Merge branch 'main' into beatlevic/ghost-context-provider
beatlevic f171370
Removed useless comments
beatlevic e835e40
Removed try/catch wrapper for formattedContext
beatlevic 48c1124
Use AutocompleteCodeSnippet from continue
beatlevic e11c18e
Moved recentlyVisitedRanges and recentlyEditedRanges into context
beatlevic 06c623b
Fixed GhostContextProvider.test to propagate error
beatlevic d442b5b
Merge branch 'main' into beatlevic/ghost-context-provider
beatlevic 7a15c57
Update src/services/ghost/classic-auto-complete/GhostContextProvider.ts
EamonNerbonne b279001
Pass model to ghost context provider
beatlevic 36ab69e
Small prompt change to improve sporadic comment duplication. Tested o…
beatlevic 83824de
Merge branch 'main' into beatlevic/ghost-context-provider
beatlevic d338310
Merge branch 'main' into beatlevic/ghost-context-provider
beatlevic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 0 additions & 153 deletions
153
src/services/ghost/__tests__/GhostRecentOperations.spec.ts
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
src/services/ghost/classic-auto-complete/GhostContextProvider.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import * as vscode from "vscode" | ||
| import { ContextRetrievalService } from "../../continuedev/core/autocomplete/context/ContextRetrievalService" | ||
| import { VsCodeIde } from "../../continuedev/core/vscode-test-harness/src/VSCodeIde" | ||
| import { AutocompleteInput } from "../types" | ||
| import { HelperVars } from "../../continuedev/core/autocomplete/util/HelperVars" | ||
| import { getAllSnippetsWithoutRace } from "../../continuedev/core/autocomplete/snippets/getAllSnippets" | ||
| import { getDefinitionsFromLsp } from "../../continuedev/core/vscode-test-harness/src/autocomplete/lsp" | ||
| import { DEFAULT_AUTOCOMPLETE_OPTS } from "../../continuedev/core/util/parameters" | ||
| import { getSnippets } from "../../continuedev/core/autocomplete/templating/filtering" | ||
| import { formatSnippets } from "../../continuedev/core/autocomplete/templating/formatting" | ||
| import { GhostModel } from "../GhostModel" | ||
|
|
||
| export class GhostContextProvider { | ||
| private contextService: ContextRetrievalService | ||
| private ide: VsCodeIde | ||
| private model: GhostModel | ||
|
|
||
| constructor(context: vscode.ExtensionContext, model: GhostModel) { | ||
| this.ide = new VsCodeIde(context) | ||
| this.contextService = new ContextRetrievalService(this.ide) | ||
| this.model = model | ||
| } | ||
|
|
||
| /** | ||
| * Get the IDE instance for use by tracking services | ||
| */ | ||
| public getIde(): VsCodeIde { | ||
| return this.ide | ||
| } | ||
|
|
||
| /** | ||
| * Get context snippets for the current autocomplete request | ||
| * Returns comment-based formatted context that can be added to prompts | ||
| */ | ||
| async getFormattedContext(autocompleteInput: AutocompleteInput, filepath: string): Promise<string> { | ||
| // Convert filepath to URI if it's not already one | ||
| const filepathUri = filepath.startsWith("file://") ? filepath : vscode.Uri.file(filepath).toString() | ||
|
|
||
| // Initialize import definitions cache | ||
| // this looks like a race, but the contextService only prefetches data here; it's not a mode switch. | ||
| // This odd-looking API seems to be an optimization that's used in continue but not (currently) in our codebase, | ||
| // continue preloads the tree-sitter parse on text editor tab switch to reduce autocomplete latency. | ||
| await this.contextService.initializeForFile(filepathUri) | ||
|
|
||
| // Create helper with URI filepath | ||
| const helperInput = { | ||
| ...autocompleteInput, | ||
| filepath: filepathUri, | ||
| } | ||
|
|
||
| const modelName = this.model.getModelName() ?? "codestral" | ||
| const helper = await HelperVars.create(helperInput as any, DEFAULT_AUTOCOMPLETE_OPTS, modelName, this.ide) | ||
|
|
||
| const snippetPayload = await getAllSnippetsWithoutRace({ | ||
| helper, | ||
| ide: this.ide, | ||
| getDefinitionsFromLsp, | ||
| contextRetrievalService: this.contextService, | ||
| }) | ||
|
|
||
| const filteredSnippets = getSnippets(helper, snippetPayload) | ||
|
|
||
| // Convert all snippet filepaths to URIs | ||
| const snippetsWithUris = filteredSnippets.map((snippet: any) => ({ | ||
| ...snippet, | ||
| filepath: snippet.filepath?.startsWith("file://") | ||
| ? snippet.filepath | ||
| : vscode.Uri.file(snippet.filepath).toString(), | ||
| })) | ||
|
|
||
| const workspaceDirs = await this.ide.getWorkspaceDirs() | ||
| const formattedContext = formatSnippets(helper, snippetsWithUris, workspaceDirs) | ||
|
|
||
| console.log("[GhostContextProvider] - formattedContext:", formattedContext) | ||
|
|
||
| return formattedContext | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.