Skip to content

Commit 436ff2d

Browse files
committed
Update VSCode extension to use agent API
1 parent 7e9969f commit 436ff2d

8 files changed

Lines changed: 459 additions & 326 deletions

File tree

‎package-lock.json‎

Lines changed: 7 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/deep-agent/src/deep-agent-provider.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Observable, Subject } from 'rxjs';
66

77
import { DeepAgentConfig } from './deep-agent-config';
88
import { DeepAgentToolDefinition } from './deep-agent-tool';
9-
import { createWorkspaceTools } from './deep-agent-workspace-tools';
9+
import { createWorkspaceTools } from './deep-agent-tools';
1010

1111
type DeepAgent = ReturnType<typeof createDeepAgent>;
1212

packages/deep-agent/src/deep-agent-workspace-tools.ts renamed to packages/deep-agent/src/deep-agent-tools.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { WorkspaceAccessor } from '@sillsdev/lynx';
1+
import { Document, DocumentAccessor, WorkspaceAccessor } from '@sillsdev/lynx';
22
import { tool } from 'langchain';
33
import { z } from 'zod';
44

5+
import { DeepAgentToolDefinition } from './deep-agent-tool';
6+
57
const diagnosticSchema = z.object({
68
code: z.union([z.string(), z.number()]),
79
source: z.string(),
@@ -38,7 +40,8 @@ export function createWorkspaceTools<T>(workspace: WorkspaceAccessor<T>) {
3840
},
3941
{
4042
name: 'get_diagnostic_actions',
41-
description: 'Get available fix actions for a specific diagnostic issue in a document',
43+
description:
44+
'Get available fix actions for a specific diagnostic issue in a document. An action will either contain a `command` to execute by calling `execute_diagnostic_command` or `edits` to apply directly to the document.',
4245
schema: z.object({
4346
uri: z.string().describe('The document URI'),
4447
diagnostic: diagnosticSchema.describe('The diagnostic to get actions for'),
@@ -76,3 +79,31 @@ export function createWorkspaceTools<T>(workspace: WorkspaceAccessor<T>) {
7679
),
7780
];
7881
}
82+
83+
export function createDocumentAccessorTools<T extends Document = Document>(
84+
documents: DocumentAccessor<T>,
85+
): DeepAgentToolDefinition[] {
86+
return [
87+
{
88+
name: 'get_active_documents',
89+
description: 'Returns a list of all documents currently open in the workspace with their URIs and formats.',
90+
schema: z.object({}),
91+
async execute(_args: unknown) {
92+
const docs = await documents.active();
93+
return JSON.stringify(docs.map((doc) => ({ uri: doc.uri, format: doc.format })));
94+
},
95+
},
96+
{
97+
name: 'get_document',
98+
description: 'Returns the URI, format, version, and full text content of a workspace document by URI.',
99+
schema: z.object({ uri: z.string().describe('The URI of the document to retrieve.') }),
100+
async execute({ uri }: { uri: string }) {
101+
const doc = await documents.get(uri);
102+
if (doc == null) {
103+
return JSON.stringify({ error: `Document not found: ${uri}` });
104+
}
105+
return JSON.stringify({ uri: doc.uri, format: doc.format, version: doc.version, content: doc.getText() });
106+
},
107+
},
108+
];
109+
}

‎packages/deep-agent/src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ export type { DeepAgentConfig } from './deep-agent-config';
22
export { DeepAgentProvider } from './deep-agent-provider';
33
export type { DeepAgentSubAgentDefinition } from './deep-agent-sub-agent';
44
export type { DeepAgentToolDefinition } from './deep-agent-tool';
5-
export { createWorkspaceTools } from './deep-agent-workspace-tools';
5+
export { createDocumentAccessorTools, createWorkspaceTools } from './deep-agent-tools';

‎packages/vscode/package.json‎

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,21 @@
1414
"license": "MIT",
1515
"description": "",
1616
"engines": {
17-
"vscode": "^1.75.0"
17+
"vscode": "^1.93.0"
1818
},
1919
"activationEvents": [
2020
"onLanguage:usfm"
2121
],
2222
"contributes": {
23+
"chatParticipants": [
24+
{
25+
"id": "lynx.chatParticipant",
26+
"fullName": "Lynx",
27+
"name": "lynx",
28+
"description": "Bible translation assistant that helps with translation quality checks, formatting, and diagnostics.",
29+
"isSticky": true
30+
}
31+
],
2332
"languages": [
2433
{
2534
"id": "usfm",
@@ -41,17 +50,40 @@
4150
"type": "string",
4251
"default": "",
4352
"description": "Path to a JSON file for persisting dismissed diagnostics. If empty, dismissals are stored in memory only."
53+
},
54+
"lynx.agent.enabled": {
55+
"type": "boolean",
56+
"default": false,
57+
"description": "Enable the Lynx agent and chat participant."
58+
},
59+
"lynx.agent.provider": {
60+
"type": "string",
61+
"enum": ["anthropic", "openai", "google-genai"],
62+
"default": "anthropic",
63+
"description": "LLM provider for the Lynx agent."
64+
},
65+
"lynx.agent.model": {
66+
"type": "string",
67+
"default": "",
68+
"description": "Model identifier for the Lynx agent. If empty, a sensible default is used based on the provider."
69+
},
70+
"lynx.agent.apiKey": {
71+
"type": "string",
72+
"default": "",
73+
"description": "API key for the Lynx agent. If empty, falls back to the provider's environment variable (ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY)."
4474
}
4575
}
4676
}
4777
},
4878
"dependencies": {
79+
"langchain": "^1.3.1",
4980
"@sillsdev/lynx": "*",
81+
"@sillsdev/lynx-deep-agent": "*",
5082
"@sillsdev/lynx-examples": "*",
5183
"@sillsdev/lynx-punctuation-checker": "*",
5284
"@sillsdev/lynx-usfm": "*",
53-
"vscode-languageclient": "^9.0.1",
54-
"vscode-languageserver": "^9.0.1"
85+
"rxjs": "^7.8.2",
86+
"zod": "^3.23.0"
5587
},
5688
"devDependencies": {
5789
"@repo/eslint-config": "*",

0 commit comments

Comments
 (0)