Add SystemContextProvider to context providers so that users can use … (#988)

* Add SystemContextProvider to context providers so that users can use their own system cpu and os for a resource

* change to OSContextProvider

* update descriptor
This commit is contained in:
Jason Jacobs 2024-03-18 21:26:11 -07:00 • committed by GitHub
parent 9ab5d295ec
commit 60d2cb4450
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 57 additions and 10 deletions

View file

@ -0,0 +1,36 @@
//os.platform()
//os.arch()
import { BaseContextProvider } from "..";
import {
ContextItem,
ContextProviderDescription,
ContextProviderExtras,
} from "../..";
import os from "os";
class OSContextProvider extends BaseContextProvider {
static description: ContextProviderDescription = {
title: "OS",
displayTitle: "OS",
description: "OS and CPU Information.",
type: "normal",
};
async getContextItems(
query: string,
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
const cpu = os.arch();
const platform = os.platform();
return [
{
description: "Your OS and CPU",
content: `I am running ${platform} on ${cpu}.`,
name: "OS",
},
];
}
}
export default OSContextProvider;

View file

@ -15,6 +15,7 @@ import OpenFilesContextProvider from "./OpenFilesContextProvider";
import PostgresContextProvider from "./PostgresContextProvider";
import ProblemsContextProvider from "./ProblemsContextProvider";
import SearchContextProvider from "./SearchContextProvider";
import OSContextProvider from "./OSContextProvider";
import TerminalContextProvider from "./TerminalContextProvider";
import LocalsProvider from "./LocalsProvider";
import URLContextProvider from "./URLContextProvider";
@ -31,6 +32,7 @@ const Providers: (typeof BaseContextProvider)[] = [
OpenFilesContextProvider,
HttpContextProvider,
SearchContextProvider,
OSContextProvider,
CodebaseContextProvider,
ProblemsContextProvider,
FolderContextProvider,

3
core/index.d.ts vendored
View file

@ -441,7 +441,8 @@ type ContextProviderName =
| "database"
| "code"
| "docs"
| "gitlab-mr";
| "gitlab-mr"
| "os";
type TemplateType =
| "llama2"

View file

@ -1062,7 +1062,8 @@
"highlights",
"outline",
"postgres",
"code"
"code",
"system"
],
"markdownEnumDescriptions": [
"Reference the contents of the current changes as given by `git diff`",
@ -1082,7 +1083,8 @@
"Displays important snippets of code from the currently open files",
"Displays definition lines from the currently open files",
"References Postgres table schema and sample rows",
"Reference specific functions and classes from throughout your codebase"
"Reference specific functions and classes from throughout your codebase",
"Reference your operating system and cpu"
],
"type": "string"
},

View file

@ -1,4 +1,4 @@
{
git st{
"title": "config.json",
"$ref": "#/definitions/SerializedContinueConfig",
"definitions": {
@ -1062,7 +1062,8 @@
"highlights",
"outline",
"postgres",
"code"
"code",
"OS"
],
"markdownEnumDescriptions": [
"Reference the contents of the current changes as given by `git diff`",
@ -1082,7 +1083,8 @@
"Displays important snippets of code from the currently open files",
"Displays definition lines from the currently open files",
"References Postgres table schema and sample rows",
"Reference specific functions and classes from throughout your codebase"
"Reference specific functions and classes from throughout your codebase",
"Reference your operating system with cpu"
],
"type": "string"
},

View file

@ -1062,7 +1062,8 @@
"highlights",
"outline",
"postgres",
"code"
"code",
"system"
],
"markdownEnumDescriptions": [
"Reference the contents of the current changes as given by `git diff`",
@ -1082,7 +1083,8 @@
"Displays important snippets of code from the currently open files",
"Displays definition lines from the currently open files",
"References Postgres table schema and sample rows",
"Reference specific functions and classes from throughout your codebase"
"Reference specific functions and classes from throughout your codebase",
"Reference your operating system and cpu"
],
"type": "string"
},

View file

@ -1178,7 +1178,8 @@
"highlights",
"outline",
"postgres",
"code"
"code",
"system"
],
"markdownEnumDescriptions": [
"Reference the contents of the current changes as given by `git diff`",
@ -1198,7 +1199,8 @@
"Displays important snippets of code from the currently open files",
"Displays definition lines from the currently open files",
"References Postgres table schema and sample rows",
"Reference specific functions and classes from throughout your codebase"
"Reference specific functions and classes from throughout your codebase",
"Reference your operating system and cpu"
],
"type": "string"
},