| 1 | import { |
| 2 | ContextItem, |
| 3 | ContextProviderDescription, |
| 4 | ContextProviderExtras, |
| 5 | } from "../../index.js"; |
| 6 | import { BaseContextProvider } from "../index.js"; |
| 7 | |
| 8 | const HIGHLIGHTS_TOKEN_BUDGET = 2000; |
| 9 | |
| 10 | class CodeHighlightsContextProvider extends BaseContextProvider { |
| 11 | static description: ContextProviderDescription = { |
| 12 | title: "highlights", |
| 13 | displayTitle: "Highlights", |
| 14 | description: "Code highlights from open files", |
| 15 | type: "normal", |
| 16 | renderInlineAs: "", |
| 17 | }; |
| 18 | |
| 19 | async getContextItems( |
| 20 | query: string, |
| 21 | extras: ContextProviderExtras, |
| 22 | ): Promise<ContextItem[]> { |
| 23 | // const { getHighlightsThatFit } = await import( |
| 24 | // "llm-code-highlighter/src/index.continue.js" |
| 25 | // ); |
| 26 | const ide = extras.ide; |
| 27 | const openFiles = await ide.getOpenFiles(); |
| 28 | // const allFiles: { name: string; absPath: string; content: string }[] = |
| 29 | // await Promise.all( |
| 30 | // openFiles.map(async (filepath: string) => { |
| 31 | // return { |
| 32 | // name: getBasename(filepath), |
| 33 | // absPath: filepath, |
| 34 | // content: `${await ide.readFile(filepath)}`, |
| 35 | // }; |
| 36 | // }), |
| 37 | // ); |
| 38 | // const contextSizer = { |
| 39 | // fits(content: string): boolean { |
| 40 | // return countTokens(content, "") < HIGHLIGHTS_TOKEN_BUDGET; |
| 41 | // }, |
| 42 | // }; |
| 43 | // const repoMap = await getHighlightsThatFit( |
| 44 | // contextSizer, |
| 45 | // [], |
| 46 | // allFiles |
| 47 | // .filter((file) => file.content.length > 0) |
| 48 | // .map((file) => { |
| 49 | // return { |
| 50 | // relPath: file.name, |
| 51 | // code: file.content, |
| 52 | // }; |
| 53 | // }), |
| 54 | // ); |
| 55 | // return [ |
| 56 | // { |
| 57 | // content: repoMap ? repoMap : "", |
| 58 | // name: "Code Highlights", |
| 59 | // description: "Code highlights from open files", |
| 60 | // }, |
| 61 | // ]; |
| 62 | return []; |
| 63 | } |
| 64 | |
| 65 | async load(): Promise<void> {} |
| 66 | } |
| 67 | |
| 68 | export default CodeHighlightsContextProvider; |