Elffuss BraidHub

kikocis/continue public

refactor: :art: format snippets so that it's more model prefix-friendly
Changesetdb9477902ab48976058995086ba61a7ce8330afefdabd152d0438248560f341c
AuthorJacob Kim <jacob@continue.dev> · 2025-07-07 19:20 -07:00
CommitterJacob Kim <jacob@continue.dev> · 2025-07-07 19:20 -07:00
Parents84415195a78d

Browse the files at this changeset

2 files changed

modified core/autocomplete/context/static-context/StaticContextService.ts +26 −6
@@ -1,5 +1,6 @@
11 import * as fs from "fs/promises";
22 import path from "path";
3+import { pathToFileURL } from "url";
34 import Parser from "web-tree-sitter";
45 import { IDE, Position } from "../../..";
56 import { localPathOrUriToPath } from "../../../util/pathToUri";
@@ -153,14 +154,33 @@
153154
154155 this.logAutocompleteStaticSnippet(ctx);
155156
156- console.log(end - start);
157+ // console.log(end - start);
157158
158- return [
159- {
159+ const snippets: AutocompleteStaticSnippet[] = [];
160+
161+ snippets.push({
162+ type: AutocompleteSnippetType.Static,
163+ filepath: pathToFileURL(path.resolve(holeContext.source)).toString(),
164+ content: holeContext.fullHoverResult,
165+ });
166+
167+ for (const [filepath, typs] of ctx.relevantTypes.entries()) {
168+ snippets.push({
169+ type: AutocompleteSnippetType.Static,
170+ filepath: pathToFileURL(path.resolve(filepath)).toString(),
171+ content: typs.join("\n"),
172+ });
173+ }
174+
175+ for (const [filepath, headers] of ctx.relevantHeaders.entries()) {
176+ snippets.push({
160177 type: AutocompleteSnippetType.Static,
161- content: StaticContextService.formatAutocompleteStaticSnippet(ctx),
162- },
163- ];
178+ filepath: pathToFileURL(path.resolve(filepath)).toString(),
179+ content: headers.join("\n"),
180+ });
181+ }
182+
183+ return snippets;
164184 }
165185
166186 private async getHoleContext(
modified core/autocomplete/snippets/types.ts +1 −0
@@ -26,6 +26,7 @@
2626
2727 export interface AutocompleteStaticSnippet extends BaseAutocompleteSnippet {
2828 type: AutocompleteSnippetType.Static;
29+ filepath: string;
2930 }
3031
3132 export type AutocompleteSnippet =