| 1 | import { |
| 2 | ContextItem, |
| 3 | ContextProviderDescription, |
| 4 | ContextProviderExtras, |
| 5 | } from "../../index.js"; |
| 6 | import { BaseContextProvider } from "../index.js"; |
| 7 | |
| 8 | class TerminalContextProvider extends BaseContextProvider { |
| 9 | static description: ContextProviderDescription = { |
| 10 | title: "terminal", |
| 11 | displayTitle: "Terminal", |
| 12 | description: "Reference the last terminal command", |
| 13 | type: "normal", |
| 14 | }; |
| 15 | |
| 16 | async getContextItems( |
| 17 | query: string, |
| 18 | extras: ContextProviderExtras, |
| 19 | ): Promise<ContextItem[]> { |
| 20 | const content = await extras.ide.getTerminalContents(); |
| 21 | return [ |
| 22 | { |
| 23 | description: "The contents of the terminal", |
| 24 | content: `Current terminal contents:\n\n${ |
| 25 | content || "The terminal is empty." |
| 26 | }`, |
| 27 | name: "Terminal", |
| 28 | }, |
| 29 | ]; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | export default TerminalContextProvider; |