@aws/lsp-codewhisperer 0.0.53 → 0.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/out/language-server/agenticChat/agenticChatController.js +29 -14
- package/out/language-server/agenticChat/agenticChatController.js.map +1 -1
- package/out/language-server/agenticChat/context/agenticChatTriggerContext.d.ts +31 -2
- package/out/language-server/agenticChat/context/agenticChatTriggerContext.js +88 -4
- package/out/language-server/agenticChat/context/agenticChatTriggerContext.js.map +1 -1
- package/out/language-server/agenticChat/tools/fsReplace.d.ts +60 -0
- package/out/language-server/agenticChat/tools/fsReplace.js +131 -0
- package/out/language-server/agenticChat/tools/fsReplace.js.map +1 -0
- package/out/language-server/agenticChat/tools/fsWrite.d.ts +5 -29
- package/out/language-server/agenticChat/tools/fsWrite.js +18 -105
- package/out/language-server/agenticChat/tools/fsWrite.js.map +1 -1
- package/out/language-server/agenticChat/tools/grepSearch.d.ts +2 -2
- package/out/language-server/agenticChat/tools/grepSearch.js +2 -2
- package/out/language-server/agenticChat/tools/grepSearch.js.map +1 -1
- package/out/language-server/agenticChat/tools/mcp/mcpManager.js +12 -2
- package/out/language-server/agenticChat/tools/mcp/mcpManager.js.map +1 -1
- package/out/language-server/agenticChat/tools/toolServer.js +6 -0
- package/out/language-server/agenticChat/tools/toolServer.js.map +1 -1
- package/out/language-server/workspaceContext/artifactManager.js +1 -1
- package/out/language-server/workspaceContext/artifactManager.js.map +1 -1
- package/out/language-server/workspaceContext/workspaceContextServer.js +1 -1
- package/out/language-server/workspaceContext/workspaceContextServer.js.map +1 -1
- package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js +8 -3
- package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js.map +1 -1
- package/out/shared/codeWhispererService.d.ts +8 -2
- package/out/shared/codeWhispererService.js +41 -5
- package/out/shared/codeWhispererService.js.map +1 -1
- package/package.json +1 -1
|
@@ -40,12 +40,41 @@ export declare class AgenticChatTriggerContext {
|
|
|
40
40
|
getChatParamsFromTrigger(params: ChatParams | InlineChatParams, triggerContext: TriggerContext, chatTriggerType: ChatTriggerType, customizationArn?: string, chatResultStream?: AgenticChatResultStream, profileArn?: string, history?: ChatMessage[], tools?: BedrockTools, additionalContent?: AdditionalContentEntryAddition[], modelId?: string): Promise<GenerateAssistantResponseCommandInput>;
|
|
41
41
|
extractDocumentContext(input: Pick<ChatParams | InlineChatParams, 'cursorState' | 'textDocument'>): Promise<DocumentContext | undefined>;
|
|
42
42
|
/**
|
|
43
|
-
* Fetch the current textDocument such that:
|
|
43
|
+
* Fetch the current textDocument using a URI, such that:
|
|
44
44
|
* 1. If the document is synced with LSP, return the synced textDocument
|
|
45
45
|
* 2. If the document is not synced with LSP, read the file from the file system
|
|
46
46
|
* 3. If the file cannot be read, return undefined
|
|
47
47
|
* @param uri
|
|
48
48
|
* @returns
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
getTextDocumentFromUri(uri: string): Promise<TextDocument | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Fetch the current textDocument using a filesystem path, such that:
|
|
53
|
+
* 1. If the document is synced with LSP, return the synced textDocument
|
|
54
|
+
* 2. If the document is not synced with LSP, read the file from the file system
|
|
55
|
+
* 3. If the file cannot be read, return undefined
|
|
56
|
+
* @param path - path of file to load, not in URI format
|
|
57
|
+
* @param useWorkspace - attempt to load from the LSP workspace
|
|
58
|
+
* @param useFs - attempt to load directly from the filesystem, prioritizing workspace first
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
getTextDocumentFromPath(path: string, useWorkspace: boolean, useFs: boolean): Promise<TextDocument | undefined>;
|
|
62
|
+
/**
|
|
63
|
+
* Given a path, return a set of the possible uri strings that could be used
|
|
64
|
+
* to represent the file in the workspace.
|
|
65
|
+
*
|
|
66
|
+
* This solves a problem where URI-parsing a windows path
|
|
67
|
+
* like C:\Foo\bar.txt creates a uri string of
|
|
68
|
+
* file:///c%3A/Foo/bar.txt, but the workspace stores the file as
|
|
69
|
+
* file:///C:/Foo/bar.txt or file:///c:/Foo/bar.txt
|
|
70
|
+
*
|
|
71
|
+
* The reason for this is the vscode-languageserver implementation used
|
|
72
|
+
* an implementation of URI that preserved colons, however the vscode-uri
|
|
73
|
+
* implementation of URI uses a "more correct" version that encodes the colons.
|
|
74
|
+
*
|
|
75
|
+
* Some of this function's implementation was inspired by the vscode-uri
|
|
76
|
+
* implementation of uriToFsPath
|
|
77
|
+
* https://github.com/microsoft/vscode-uri/blob/edfdccd976efaf4bb8fdeca87e97c47257721729/src/uri.ts#L564
|
|
78
|
+
*/
|
|
79
|
+
getPossiblePathUris(path: string): string[];
|
|
51
80
|
}
|
|
@@ -168,7 +168,7 @@ class AgenticChatTriggerContext {
|
|
|
168
168
|
if (textDocumentIdentifier?.uri === undefined) {
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
|
-
const textDocument = await this.
|
|
171
|
+
const textDocument = await this.getTextDocumentFromUri(textDocumentIdentifier.uri);
|
|
172
172
|
return textDocument
|
|
173
173
|
? this.#documentContextExtractor.extractDocumentContext(textDocument,
|
|
174
174
|
// we want to include a default position if a text document is found so users can still ask questions about the opened file
|
|
@@ -177,14 +177,14 @@ class AgenticChatTriggerContext {
|
|
|
177
177
|
: undefined;
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
|
-
* Fetch the current textDocument such that:
|
|
180
|
+
* Fetch the current textDocument using a URI, such that:
|
|
181
181
|
* 1. If the document is synced with LSP, return the synced textDocument
|
|
182
182
|
* 2. If the document is not synced with LSP, read the file from the file system
|
|
183
183
|
* 3. If the file cannot be read, return undefined
|
|
184
184
|
* @param uri
|
|
185
185
|
* @returns
|
|
186
186
|
*/
|
|
187
|
-
async
|
|
187
|
+
async getTextDocumentFromUri(uri) {
|
|
188
188
|
// Note: version is unused, and languageId can be determined from file extension.
|
|
189
189
|
const syncedTextDocument = await this.#workspace.getTextDocument(uri);
|
|
190
190
|
if (syncedTextDocument) {
|
|
@@ -194,10 +194,94 @@ class AgenticChatTriggerContext {
|
|
|
194
194
|
const content = await this.#workspace.fs.readFile(vscode_uri_1.URI.parse(uri).fsPath);
|
|
195
195
|
return server_interface_1.TextDocument.create(uri, '', 0, content);
|
|
196
196
|
}
|
|
197
|
-
catch {
|
|
197
|
+
catch (err) {
|
|
198
|
+
this.#logging.error(`Unable to load from ${path}: ${err}`);
|
|
198
199
|
return;
|
|
199
200
|
}
|
|
200
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Fetch the current textDocument using a filesystem path, such that:
|
|
204
|
+
* 1. If the document is synced with LSP, return the synced textDocument
|
|
205
|
+
* 2. If the document is not synced with LSP, read the file from the file system
|
|
206
|
+
* 3. If the file cannot be read, return undefined
|
|
207
|
+
* @param path - path of file to load, not in URI format
|
|
208
|
+
* @param useWorkspace - attempt to load from the LSP workspace
|
|
209
|
+
* @param useFs - attempt to load directly from the filesystem, prioritizing workspace first
|
|
210
|
+
* @returns
|
|
211
|
+
*/
|
|
212
|
+
async getTextDocumentFromPath(path, useWorkspace, useFs) {
|
|
213
|
+
try {
|
|
214
|
+
if (useWorkspace) {
|
|
215
|
+
// fetching documents from the workspace requires a URI formatted string
|
|
216
|
+
// eg: "file:///foo/bar.txt" or "file:///C:/foo/bar.txt"
|
|
217
|
+
var uris = this.getPossiblePathUris(path);
|
|
218
|
+
for (const uriStr of uris) {
|
|
219
|
+
// Note: version is unused, and languageId can be determined from file extension.
|
|
220
|
+
const wsTextDocument = await this.#workspace.getTextDocument(uriStr);
|
|
221
|
+
if (wsTextDocument) {
|
|
222
|
+
return wsTextDocument;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// If we get here, one of the following is possible:
|
|
226
|
+
// - the document exists, but we did not have the right lookup key
|
|
227
|
+
// - the document exists, but is not open in the editor
|
|
228
|
+
// - the document does not exist
|
|
229
|
+
}
|
|
230
|
+
if (useFs) {
|
|
231
|
+
const content = await this.#workspace.fs.readFile(path);
|
|
232
|
+
return server_interface_1.TextDocument.create(path, '', 0, content);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
236
|
+
this.#logging.error(`Unable to load from ${path}: ${err}`);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Given a path, return a set of the possible uri strings that could be used
|
|
242
|
+
* to represent the file in the workspace.
|
|
243
|
+
*
|
|
244
|
+
* This solves a problem where URI-parsing a windows path
|
|
245
|
+
* like C:\Foo\bar.txt creates a uri string of
|
|
246
|
+
* file:///c%3A/Foo/bar.txt, but the workspace stores the file as
|
|
247
|
+
* file:///C:/Foo/bar.txt or file:///c:/Foo/bar.txt
|
|
248
|
+
*
|
|
249
|
+
* The reason for this is the vscode-languageserver implementation used
|
|
250
|
+
* an implementation of URI that preserved colons, however the vscode-uri
|
|
251
|
+
* implementation of URI uses a "more correct" version that encodes the colons.
|
|
252
|
+
*
|
|
253
|
+
* Some of this function's implementation was inspired by the vscode-uri
|
|
254
|
+
* implementation of uriToFsPath
|
|
255
|
+
* https://github.com/microsoft/vscode-uri/blob/edfdccd976efaf4bb8fdeca87e97c47257721729/src/uri.ts#L564
|
|
256
|
+
*/
|
|
257
|
+
getPossiblePathUris(path) {
|
|
258
|
+
const uris = new Set();
|
|
259
|
+
const uriStr = vscode_uri_1.URI.file(path).toString();
|
|
260
|
+
uris.add(uriStr);
|
|
261
|
+
// On Windows the tool-generated path can have a different drive letter case
|
|
262
|
+
// from the URI stored in the lsp workspace. So we need to try
|
|
263
|
+
// lowercase and uppercase drive letters.
|
|
264
|
+
if (process.platform === 'win32' &&
|
|
265
|
+
uriStr.startsWith('file:///') &&
|
|
266
|
+
uriStr.substring(9, 12).toLowerCase() == '%3a') {
|
|
267
|
+
const driveLower = uriStr[8].toLowerCase();
|
|
268
|
+
const driveUpper = uriStr[8].toUpperCase();
|
|
269
|
+
const leadingPath = uriStr.substring(0, 8); // "file:///"
|
|
270
|
+
const encodedColonTrailingPath = uriStr.substring(9); // "%3A/Foo/bar.txt"
|
|
271
|
+
const colonTrailingPath = ':' + uriStr.substring(12); // ":/Foo/bar.txt"
|
|
272
|
+
// Some IDEs (eg: VS Code) index the workspace files using encoded paths.
|
|
273
|
+
// file:///c%3A/Foo/bar.txt
|
|
274
|
+
uris.add(leadingPath + driveLower + encodedColonTrailingPath);
|
|
275
|
+
// file:///C%3A/Foo/bar.txt
|
|
276
|
+
uris.add(leadingPath + driveUpper + encodedColonTrailingPath);
|
|
277
|
+
// Some IDEs (eg: VS) index the workspace files using paths containing colons.
|
|
278
|
+
// file:///c:/Foo/bar.txt
|
|
279
|
+
uris.add(leadingPath + driveLower + colonTrailingPath);
|
|
280
|
+
// file:///C:/Foo/bar.txt
|
|
281
|
+
uris.add(leadingPath + driveUpper + colonTrailingPath);
|
|
282
|
+
}
|
|
283
|
+
return [...uris];
|
|
284
|
+
}
|
|
201
285
|
async #getRelevantDocuments(prompt, chatResultStream) {
|
|
202
286
|
const localProjectContextController = await localProjectContextController_1.LocalProjectContextController.getInstance();
|
|
203
287
|
if (!localProjectContextController.isIndexingEnabled() && chatResultStream) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agenticChatTriggerContext.js","sourceRoot":"","sources":["../../../../src/language-server/agenticChat/context/agenticChatTriggerContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,wFAS4C;AAC5C,qFAQuD;AAEvD,yEAA+F;AAC/F,4CAA8C;AAC9C,2CAAgC;AAChC,iGAA6F;AAC7F,6BAA4B;AAE5B,yEAAuE;AAEvE,iDAAwF;AACxF,0FAAsF;AAmBtF,qCAAqC;AACxB,QAAA,qBAAqB,GAAG,MAAM,CAAA;AAE3C,4CAA4C;AAC/B,QAAA,0BAA0B,GAAG,GAAG,CAAA;AAE7C,yDAAyD;AAC5C,QAAA,mBAAmB,GAAG,GAAG,CAAA;AAEtC,MAAa,yBAAyB;IAC1B,MAAM,CAAU,oBAAo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J;gBACD,gBAAgB;gBAChB,OAAO;aACV;YACD,UAAU;SACb,CAAA;QAED,OAAO,IAAI,CAAA;IACf,CAAC;IAED,qBAAqB;IACrB,KAAK,CAAC,sBAAsB,CACxB,KAA0E;QAE1E,MAAM,EAAE,YAAY,EAAE,sBAAsB,EAAE,WAAW,EAAE,GAAG,KAAK,CAAA;QAEnE,IAAI,sBAAsB,EAAE,GAAG,KAAK,SAAS,EAAE,CAAC;YAC5C,OAAM;QACV,CAAC;QACD,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"agenticChatTriggerContext.js","sourceRoot":"","sources":["../../../../src/language-server/agenticChat/context/agenticChatTriggerContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,wFAS4C;AAC5C,qFAQuD;AAEvD,yEAA+F;AAC/F,4CAA8C;AAC9C,2CAAgC;AAChC,iGAA6F;AAC7F,6BAA4B;AAE5B,yEAAuE;AAEvE,iDAAwF;AACxF,0FAAsF;AAmBtF,qCAAqC;AACxB,QAAA,qBAAqB,GAAG,MAAM,CAAA;AAE3C,4CAA4C;AAC/B,QAAA,0BAA0B,GAAG,GAAG,CAAA;AAE7C,yDAAyD;AAC5C,QAAA,mBAAmB,GAAG,GAAG,CAAA;AAEtC,MAAa,yBAAyB;IAC1B,MAAM,CAAU,oBAAoB,GAAgB,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,CAAA;IAEnG,UAAU,CAAuB;IACjC,IAAI,CAAiB;IACrB,QAAQ,CAAqB;IAC7B,yBAAyB,CAA0B;IAEnD,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAuE;QACxG,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;QACf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,yBAAyB,GAAG,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,OAAO,IAAI,CAAC,CAAC;iBAC/B,CAAA;gBAED,IAAI,KAAK,CAAC,mBAAmB,IAAI,KAAK,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;oBACvE,qBAAqB,CAAC,IAAI,CAAC;wBACvB,GAAG,YAAY;wBACf,mBAAmB,EAAE;4BACjB,YAAY,EAAE,KAAK,CAAC,mBAAmB;yBAC1C;wBACD,IAAI,EAAE,4CAAW,CAAC,SAAS;qBAC9B,CAAC,CAAA;gBACN,CAAC;qBAAM,CAAC;oBACJ,qBAAqB,CAAC,IAAI,CAAC;wBACvB,GAAG,YAAY;wBACf,IAAI,EAAE,4CAAW,CAAC,SAAS;qBAC9B,CAAC,CAAA;gBACN,CAAC;YACL,CAAC;YAED,OAAO,qBAAqB,CAAA;QAChC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,gEAAgE,CAAC,EAAE,CAAC,CAAA;YACxF,OAAO,EAAE,CAAA;QACb,CAAC;IACL,CAAC;;AAlYL,8DAmYC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { CommandValidation, ExplanatoryParams, InvokeOutput } from './toolShared';
|
|
2
|
+
import { Features } from '@aws/language-server-runtimes/server-interface/server';
|
|
3
|
+
interface BaseParams extends ExplanatoryParams {
|
|
4
|
+
path: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Diff {
|
|
7
|
+
oldStr: string;
|
|
8
|
+
newStr: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ReplaceParams extends BaseParams {
|
|
11
|
+
diffs: Diff[];
|
|
12
|
+
}
|
|
13
|
+
export type FsReplaceParams = ReplaceParams;
|
|
14
|
+
export declare class FsReplace {
|
|
15
|
+
private readonly logging;
|
|
16
|
+
private readonly workspace;
|
|
17
|
+
private readonly lsp;
|
|
18
|
+
constructor(features: Pick<Features, 'workspace' | 'logging' | 'lsp'> & Partial<Features>);
|
|
19
|
+
validate(params: FsReplaceParams): Promise<void>;
|
|
20
|
+
invoke(params: FsReplaceParams): Promise<InvokeOutput>;
|
|
21
|
+
requiresAcceptance(params: FsReplaceParams, approvedPaths?: Set<string>): Promise<CommandValidation>;
|
|
22
|
+
private handleReplace;
|
|
23
|
+
getSpec(): {
|
|
24
|
+
readonly name: "fsReplace";
|
|
25
|
+
readonly description: string;
|
|
26
|
+
readonly inputSchema: {
|
|
27
|
+
readonly type: "object";
|
|
28
|
+
readonly properties: {
|
|
29
|
+
readonly explanation: {
|
|
30
|
+
readonly description: "One sentence explanation as to why this tool is being used, and how it contributes to the goal.";
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
};
|
|
33
|
+
readonly diffs: {
|
|
34
|
+
readonly description: "List of `oldStr`/`newStr` pairs to replace contents in an existing file. IMPORTANT: Must be provided as an array of objects, NOT as a string. For example, `[{\"oldStr\": \"existingContent\", \"newStr\": \"newContent\"}]`";
|
|
35
|
+
readonly type: "array";
|
|
36
|
+
readonly items: {
|
|
37
|
+
readonly type: "object";
|
|
38
|
+
readonly properties: {
|
|
39
|
+
readonly oldStr: {
|
|
40
|
+
readonly description: "The exact string content to be replaced in the file. Must match EXACTLY including whitespaces (indentations, tabs, spaces) and line breaks.";
|
|
41
|
+
readonly type: "string";
|
|
42
|
+
};
|
|
43
|
+
readonly newStr: {
|
|
44
|
+
readonly description: "The new string content that will replace the oldStr. Use empty string to delete content.";
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
readonly required: readonly ["oldStr"];
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
readonly path: {
|
|
52
|
+
readonly description: "Absolute path to a file, e.g. `/repo/file.py` for Unix-like system including Unix/Linux/macOS or `d:\\repo\\file.py` for Windows.";
|
|
53
|
+
readonly type: "string";
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
readonly required: readonly ["diffs", "path"];
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FsReplace = void 0;
|
|
4
|
+
const toolShared_1 = require("./toolShared");
|
|
5
|
+
const path_1 = require("@aws/lsp-core/out/util/path");
|
|
6
|
+
const os = require("os");
|
|
7
|
+
class FsReplace {
|
|
8
|
+
logging;
|
|
9
|
+
workspace;
|
|
10
|
+
lsp;
|
|
11
|
+
constructor(features) {
|
|
12
|
+
this.logging = features.logging;
|
|
13
|
+
this.workspace = features.workspace;
|
|
14
|
+
this.lsp = features.lsp;
|
|
15
|
+
}
|
|
16
|
+
async validate(params) {
|
|
17
|
+
if (!params.path) {
|
|
18
|
+
throw new Error('Path must not be empty');
|
|
19
|
+
}
|
|
20
|
+
if (!params.diffs || params.diffs.length === 0) {
|
|
21
|
+
throw new Error('Diffs must not be empty');
|
|
22
|
+
}
|
|
23
|
+
const sanitizedPath = (0, path_1.sanitize)(params.path);
|
|
24
|
+
const fileExists = await this.workspace.fs.exists(sanitizedPath);
|
|
25
|
+
if (!fileExists) {
|
|
26
|
+
throw new Error('The provided path must exist in order to replace contents into it');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async invoke(params) {
|
|
30
|
+
const sanitizedPath = (0, path_1.sanitize)(params.path);
|
|
31
|
+
await this.handleReplace(params, sanitizedPath);
|
|
32
|
+
return {
|
|
33
|
+
output: {
|
|
34
|
+
kind: 'text',
|
|
35
|
+
content: 'File updated successfully',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async requiresAcceptance(params, approvedPaths) {
|
|
40
|
+
return (0, toolShared_1.requiresPathAcceptance)(params.path, this.workspace, this.logging, approvedPaths);
|
|
41
|
+
}
|
|
42
|
+
async handleReplace(params, sanitizedPath) {
|
|
43
|
+
const fileContent = await this.workspace.fs.readFile(sanitizedPath);
|
|
44
|
+
const newContent = getReplaceContent(params, fileContent);
|
|
45
|
+
await this.workspace.fs.writeFile(sanitizedPath, newContent);
|
|
46
|
+
}
|
|
47
|
+
getSpec() {
|
|
48
|
+
return {
|
|
49
|
+
name: 'fsReplace',
|
|
50
|
+
description: 'A tool for search and replace contents of an existing file.\n\n' +
|
|
51
|
+
'## Overview\n' +
|
|
52
|
+
'This tool replaces sections of content in an existing file using `oldStr`/`newStr` blocks that define exact changes to specific parts of the file. You MUST ALWAYS group as many changes as you can by populating the diffs array with multiple `oldStr`/`newStr` pairs, DO NOT be overly cautious and methodical by making one change at a time on the same file.\n\n' +
|
|
53
|
+
'## When to use\n' +
|
|
54
|
+
'- When you need to make targeted changes to specific parts of a file\n' +
|
|
55
|
+
'- When you need to update multiple sections of the same file\n' +
|
|
56
|
+
'## When not to use\n' +
|
|
57
|
+
'- When you need to create a new file\n' +
|
|
58
|
+
'- When you need to rename or move a file\n\n' +
|
|
59
|
+
'## IMPORTANT Notes\n' +
|
|
60
|
+
'- Use this tool to delete code by using empty `newStr` parameter\n' +
|
|
61
|
+
'- The `oldStr` parameter should match EXACTLY one or more consecutive lines from the target file. Be mindful of whitespaces including the tabs and spaces! Include just the changing lines, and a few surrounding lines if needed for uniqueness. Do not include long runs of unchanging lines in `oldStr`\n' +
|
|
62
|
+
'- When multiple edits to the same file are needed, ALWAYS populate the diffs array with MULTIPLE `oldStr` and `newStr` pairs. This improves efficiency by reducing the number of tool calls and ensures the file remains in a consistent state',
|
|
63
|
+
inputSchema: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
properties: {
|
|
66
|
+
explanation: {
|
|
67
|
+
description: 'One sentence explanation as to why this tool is being used, and how it contributes to the goal.',
|
|
68
|
+
type: 'string',
|
|
69
|
+
},
|
|
70
|
+
diffs: {
|
|
71
|
+
description: 'List of `oldStr`/`newStr` pairs to replace contents in an existing file. IMPORTANT: Must be provided as an array of objects, NOT as a string. For example, `[{"oldStr": "existingContent", "newStr": "newContent"}]`',
|
|
72
|
+
type: 'array',
|
|
73
|
+
items: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
properties: {
|
|
76
|
+
oldStr: {
|
|
77
|
+
description: 'The exact string content to be replaced in the file. Must match EXACTLY including whitespaces (indentations, tabs, spaces) and line breaks.',
|
|
78
|
+
type: 'string',
|
|
79
|
+
},
|
|
80
|
+
newStr: {
|
|
81
|
+
description: 'The new string content that will replace the oldStr. Use empty string to delete content.',
|
|
82
|
+
type: 'string',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
required: ['oldStr'],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
path: {
|
|
89
|
+
description: 'Absolute path to a file, e.g. `/repo/file.py` for Unix-like system including Unix/Linux/macOS or `d:\\repo\\file.py` for Windows.',
|
|
90
|
+
type: 'string',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
required: ['diffs', 'path'],
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.FsReplace = FsReplace;
|
|
99
|
+
const getReplaceContent = (params, fileContent) => {
|
|
100
|
+
// Detect line ending from oldContent (CRLF, LF, or CR)
|
|
101
|
+
const match = fileContent.match(/\r\n|\r|\n/);
|
|
102
|
+
const lineEnding = match ? match[0] : os.EOL;
|
|
103
|
+
for (const diff of params.diffs) {
|
|
104
|
+
if (diff.newStr == undefined) {
|
|
105
|
+
diff.newStr = '';
|
|
106
|
+
}
|
|
107
|
+
if (diff.oldStr === diff.newStr) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
// Normalize oldStr and newStr to match fileContent's line ending style
|
|
111
|
+
const normalizedOldStr = diff.oldStr.split(/\r\n|\r|\n/).join(lineEnding);
|
|
112
|
+
const normalizedNewStr = diff.newStr.split(/\r\n|\r|\n/).join(lineEnding);
|
|
113
|
+
// Use string indexOf and substring for safer replacement with special characters
|
|
114
|
+
const startIndex = fileContent.indexOf(normalizedOldStr);
|
|
115
|
+
if (startIndex === -1) {
|
|
116
|
+
throw new Error(`No occurrences of "${diff.oldStr}" were found`);
|
|
117
|
+
}
|
|
118
|
+
// Check for multiple occurrences
|
|
119
|
+
const secondIndex = fileContent.indexOf(normalizedOldStr, startIndex + 1);
|
|
120
|
+
if (secondIndex !== -1) {
|
|
121
|
+
throw new Error(`Multiple occurrences of "${diff.oldStr}" were found when only 1 is expected`);
|
|
122
|
+
}
|
|
123
|
+
// Perform the replacement using string operations instead of regex
|
|
124
|
+
fileContent =
|
|
125
|
+
fileContent.substring(0, startIndex) +
|
|
126
|
+
normalizedNewStr +
|
|
127
|
+
fileContent.substring(startIndex + normalizedOldStr.length);
|
|
128
|
+
}
|
|
129
|
+
return fileContent;
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=fsReplace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsReplace.js","sourceRoot":"","sources":["../../../../src/language-server/agenticChat/tools/fsReplace.ts"],"names":[],"mappings":";;;AAAA,6CAAyG;AAEzG,sDAAsD;AACtD,yBAAwB;AAiBxB,MAAa,SAAS;IACD,OAAO,CAAqB;IAC5B,SAAS,CAAuB;IAChC,GAAG,CAAiB;IAErC,YAAY,QAA6E;QACrF,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;QAC/B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;QACnC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAA;IAC3B,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,MAAuB;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;QAC7C,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAC9C,CAAC;QACD,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AK,IAAI,CAAC,MAAM,EAAE,CAAC;YAC9B,SAAQ;QACZ,CAAC;QAED,uEAAuE;QACvE,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACzE,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAEzE,iFAAiF;QACjF,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;QAExD,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,MAAM,cAAc,CAAC,CAAA;QACpE,CAAC;QAED,iCAAiC;QACjC,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,gBAAgB,EAAE,UAAU,GAAG,CAAC,CAAC,CAAA;QACzE,IAAI,WAAW,KAAK,CAAC,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,MAAM,sCAAsC,CAAC,CAAA;QAClG,CAAC;QAED,mEAAmE;QACnE,WAAW;YACP,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC;gBACpC,gBAAgB;gBAChB,WAAW,CAAC,SAAS,CAAC,UAAU,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACnE,CAAC;IACD,OAAO,WAAW,CAAA;AACtB,CAAC,CAAA"}
|
|
@@ -7,21 +7,11 @@ export interface CreateParams extends BaseParams {
|
|
|
7
7
|
command: 'create';
|
|
8
8
|
fileText: string;
|
|
9
9
|
}
|
|
10
|
-
export interface StrReplaceParams extends BaseParams {
|
|
11
|
-
command: 'strReplace';
|
|
12
|
-
oldStr: string;
|
|
13
|
-
newStr: string;
|
|
14
|
-
}
|
|
15
|
-
export interface InsertParams extends BaseParams {
|
|
16
|
-
command: 'insert';
|
|
17
|
-
insertLine: number;
|
|
18
|
-
newStr: string;
|
|
19
|
-
}
|
|
20
10
|
export interface AppendParams extends BaseParams {
|
|
21
11
|
command: 'append';
|
|
22
|
-
|
|
12
|
+
fileText: string;
|
|
23
13
|
}
|
|
24
|
-
export type FsWriteParams = CreateParams |
|
|
14
|
+
export type FsWriteParams = CreateParams | AppendParams;
|
|
25
15
|
export interface FsWriteBackup {
|
|
26
16
|
content: string;
|
|
27
17
|
isNew: boolean;
|
|
@@ -36,8 +26,6 @@ export declare class FsWrite {
|
|
|
36
26
|
queueDescription(updates: WritableStream): Promise<void>;
|
|
37
27
|
requiresAcceptance(params: FsWriteParams, approvedPaths?: Set<string>): Promise<CommandValidation>;
|
|
38
28
|
private handleCreate;
|
|
39
|
-
private handleStrReplace;
|
|
40
|
-
private handleInsert;
|
|
41
29
|
private handleAppend;
|
|
42
30
|
getSpec(): {
|
|
43
31
|
readonly name: "fsWrite";
|
|
@@ -48,26 +36,14 @@ export declare class FsWrite {
|
|
|
48
36
|
readonly command: {
|
|
49
37
|
readonly type: "string";
|
|
50
38
|
readonly enum: string[];
|
|
51
|
-
readonly description: "The
|
|
39
|
+
readonly description: "The command to run. Allowed options are: `create`, `append`.";
|
|
52
40
|
};
|
|
53
41
|
readonly explanation: {
|
|
54
42
|
readonly description: "One sentence explanation as to why this tool is being used, and how it contributes to the goal.";
|
|
55
43
|
readonly type: "string";
|
|
56
44
|
};
|
|
57
45
|
readonly fileText: {
|
|
58
|
-
readonly description: "
|
|
59
|
-
readonly type: "string";
|
|
60
|
-
};
|
|
61
|
-
readonly insertLine: {
|
|
62
|
-
readonly description: "Required parameter of `insert` command. The `newStr` will be inserted AFTER the line `insertLine` of `path`.";
|
|
63
|
-
readonly type: "number";
|
|
64
|
-
};
|
|
65
|
-
readonly newStr: {
|
|
66
|
-
readonly description: "Required parameter of `strReplace` command containing the new string. Required parameter of `insert` command containing the string to insert. Required parameter of `append` command containing the content to append to the file.";
|
|
67
|
-
readonly type: "string";
|
|
68
|
-
};
|
|
69
|
-
readonly oldStr: {
|
|
70
|
-
readonly description: "Required parameter of `strReplace` command containing the string in `path` to replace.";
|
|
46
|
+
readonly description: "The content to write to the file. For `create`, this is the entire file content. For `append`, this is the content to add to the end of the file.";
|
|
71
47
|
readonly type: "string";
|
|
72
48
|
};
|
|
73
49
|
readonly path: {
|
|
@@ -75,7 +51,7 @@ export declare class FsWrite {
|
|
|
75
51
|
readonly type: "string";
|
|
76
52
|
};
|
|
77
53
|
};
|
|
78
|
-
readonly required: readonly ["command", "path"];
|
|
54
|
+
readonly required: readonly ["command", "path", "fileText"];
|
|
79
55
|
};
|
|
80
56
|
};
|
|
81
57
|
}
|