@polka-codes/core 0.8.19 → 0.8.21
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/dist/_tsup-dts-rollup.d.ts +489 -687
- package/dist/index.d.ts +0 -2
- package/dist/index.js +113 -236
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { replaceInFileHelper } from './_tsup-dts-rollup.js';
|
|
2
|
-
export { editFileHelper } from './_tsup-dts-rollup.js';
|
|
3
2
|
export { AiServiceProvider } from './_tsup-dts-rollup.js';
|
|
4
3
|
export { defaultModels } from './_tsup-dts-rollup.js';
|
|
5
4
|
export { createService } from './_tsup-dts-rollup.js';
|
|
@@ -62,7 +61,6 @@ export { ToolUse } from './_tsup-dts-rollup.js';
|
|
|
62
61
|
export { AssistantMessageContent } from './_tsup-dts-rollup.js';
|
|
63
62
|
export { KnowledgeManagementPolicy } from './_tsup-dts-rollup.js';
|
|
64
63
|
export { TruncateContextPolicy } from './_tsup-dts-rollup.js';
|
|
65
|
-
export { editFile } from './_tsup-dts-rollup.js';
|
|
66
64
|
export { allTools } from './_tsup-dts-rollup.js';
|
|
67
65
|
export { FilesystemProvider } from './_tsup-dts-rollup.js';
|
|
68
66
|
export { CommandProvider } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -914,40 +914,6 @@ var ToolResponseType = /* @__PURE__ */ ((ToolResponseType2) => {
|
|
|
914
914
|
return ToolResponseType2;
|
|
915
915
|
})(ToolResponseType || {});
|
|
916
916
|
|
|
917
|
-
// src/tools/utils/editFile.ts
|
|
918
|
-
var START_OF_FILE = "<<<START_OF_FILE>>>";
|
|
919
|
-
var END_OF_FILE = "<<<END_OF_FILE>>>";
|
|
920
|
-
var editFile = async (fileContent, operations) => {
|
|
921
|
-
if (!operations || operations.length === 0) {
|
|
922
|
-
throw new Error("At least one edit operation is required");
|
|
923
|
-
}
|
|
924
|
-
let updatedContent = fileContent;
|
|
925
|
-
for (const operation of operations) {
|
|
926
|
-
updatedContent = await applyEditOperation(updatedContent, operation);
|
|
927
|
-
}
|
|
928
|
-
return updatedContent;
|
|
929
|
-
};
|
|
930
|
-
async function applyEditOperation(fileContent, operation) {
|
|
931
|
-
const { search, replace } = operation;
|
|
932
|
-
if (search === START_OF_FILE && replace === END_OF_FILE) {
|
|
933
|
-
throw new Error("Cannot search for START_OF_FILE and replace with END_OF_FILE");
|
|
934
|
-
}
|
|
935
|
-
if (search === END_OF_FILE && replace === START_OF_FILE) {
|
|
936
|
-
throw new Error("Cannot search for END_OF_FILE and replace with START_OF_FILE");
|
|
937
|
-
}
|
|
938
|
-
if (search === START_OF_FILE) {
|
|
939
|
-
return replace + fileContent;
|
|
940
|
-
}
|
|
941
|
-
if (search === END_OF_FILE) {
|
|
942
|
-
return fileContent + replace;
|
|
943
|
-
}
|
|
944
|
-
const index = fileContent.indexOf(search);
|
|
945
|
-
if (index === -1) {
|
|
946
|
-
throw new Error(`Could not find text: ${search}`);
|
|
947
|
-
}
|
|
948
|
-
return fileContent.slice(0, index) + replace + fileContent.slice(index + search.length);
|
|
949
|
-
}
|
|
950
|
-
|
|
951
917
|
// src/tools/utils/getArg.ts
|
|
952
918
|
var getString = (args, name, defaultValue) => {
|
|
953
919
|
if (typeof args !== "object" || Array.isArray(args)) {
|
|
@@ -1042,7 +1008,7 @@ var getArray = (args, name, defaultValue) => {
|
|
|
1042
1008
|
|
|
1043
1009
|
// src/tools/utils/replaceInFile.ts
|
|
1044
1010
|
var replaceInFile = async (fileContent, diff) => {
|
|
1045
|
-
const blockPattern = /<<<<<+ SEARCH
|
|
1011
|
+
const blockPattern = /<<<<<+ SEARCH>?\s*\r?\n([\s\S]*?)\r?\n=======[ \t]*\r?\n([\s\S]*?)\r?\n?>>>>>+ REPLACE/g;
|
|
1046
1012
|
const blocks = [];
|
|
1047
1013
|
for (let match = blockPattern.exec(diff); match !== null; match = blockPattern.exec(diff)) {
|
|
1048
1014
|
blocks.push({ search: match[1], replace: match[2] });
|
|
@@ -1559,29 +1525,29 @@ var toolInfo7 = {
|
|
|
1559
1525
|
{
|
|
1560
1526
|
name: "diff",
|
|
1561
1527
|
description: `One or more SEARCH/REPLACE blocks following this exact format:
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1528
|
+
\`\`\`
|
|
1529
|
+
<<<<<<< SEARCH
|
|
1530
|
+
[exact content to find]
|
|
1531
|
+
=======
|
|
1532
|
+
[new content to replace with]
|
|
1533
|
+
>>>>>>> REPLACE
|
|
1534
|
+
\`\`\`
|
|
1535
|
+
Critical rules:
|
|
1536
|
+
1. SEARCH content must match the associated file section to find EXACTLY:
|
|
1537
|
+
* Match character-for-character including whitespace, indentation, line endings
|
|
1538
|
+
* Include all comments, docstrings, etc.
|
|
1539
|
+
2. SEARCH/REPLACE blocks will ONLY replace the first match occurrence.
|
|
1540
|
+
* Including multiple unique SEARCH/REPLACE blocks if you need to make multiple changes.
|
|
1541
|
+
* Include *just* enough lines in each SEARCH section to uniquely match each set of lines that need to change.
|
|
1542
|
+
* When using multiple SEARCH/REPLACE blocks, list them in the order they appear in the file.
|
|
1543
|
+
3. Keep SEARCH/REPLACE blocks concise:
|
|
1544
|
+
* Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
|
|
1545
|
+
* Include just the changing lines, and a few surrounding lines if needed for uniqueness.
|
|
1546
|
+
* Do not include long runs of unchanging lines in SEARCH/REPLACE blocks.
|
|
1547
|
+
* Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
|
|
1548
|
+
4. Special operations:
|
|
1549
|
+
* To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
|
|
1550
|
+
* To delete code: Use empty REPLACE section`,
|
|
1585
1551
|
required: true,
|
|
1586
1552
|
usageValue: "Search and replace blocks here"
|
|
1587
1553
|
}
|
|
@@ -1624,6 +1590,73 @@ function handleSubmit() {
|
|
|
1624
1590
|
return (
|
|
1625
1591
|
<div>
|
|
1626
1592
|
>>>>>>> REPLACE
|
|
1593
|
+
`
|
|
1594
|
+
}
|
|
1595
|
+
]
|
|
1596
|
+
},
|
|
1597
|
+
{
|
|
1598
|
+
description: "Request to perform a simple, single-line replacement",
|
|
1599
|
+
parameters: [
|
|
1600
|
+
{
|
|
1601
|
+
name: "path",
|
|
1602
|
+
value: "src/config.js"
|
|
1603
|
+
},
|
|
1604
|
+
{
|
|
1605
|
+
name: "diff",
|
|
1606
|
+
value: `
|
|
1607
|
+
<<<<<<< SEARCH
|
|
1608
|
+
const API_URL = 'https://api.example.com';
|
|
1609
|
+
=======
|
|
1610
|
+
const API_URL = 'https://api.staging.example.com';
|
|
1611
|
+
>>>>>>> REPLACE
|
|
1612
|
+
`
|
|
1613
|
+
}
|
|
1614
|
+
]
|
|
1615
|
+
},
|
|
1616
|
+
{
|
|
1617
|
+
description: "Request to add a new function to a file",
|
|
1618
|
+
parameters: [
|
|
1619
|
+
{
|
|
1620
|
+
name: "path",
|
|
1621
|
+
value: "src/utils.js"
|
|
1622
|
+
},
|
|
1623
|
+
{
|
|
1624
|
+
name: "diff",
|
|
1625
|
+
value: `
|
|
1626
|
+
<<<<<<< SEARCH
|
|
1627
|
+
function helperA() {
|
|
1628
|
+
// ...
|
|
1629
|
+
}
|
|
1630
|
+
=======
|
|
1631
|
+
function helperA() {
|
|
1632
|
+
// ...
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
function newHelper() {
|
|
1636
|
+
// implementation
|
|
1637
|
+
}
|
|
1638
|
+
>>>>>>> REPLACE
|
|
1639
|
+
`
|
|
1640
|
+
}
|
|
1641
|
+
]
|
|
1642
|
+
},
|
|
1643
|
+
{
|
|
1644
|
+
description: "Request to delete a block of code from a file",
|
|
1645
|
+
parameters: [
|
|
1646
|
+
{
|
|
1647
|
+
name: "path",
|
|
1648
|
+
value: "src/app.js"
|
|
1649
|
+
},
|
|
1650
|
+
{
|
|
1651
|
+
name: "diff",
|
|
1652
|
+
value: `
|
|
1653
|
+
<<<<<<< SEARCH
|
|
1654
|
+
function oldFeature() {
|
|
1655
|
+
// This is no longer needed
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
=======
|
|
1659
|
+
>>>>>>> REPLACE
|
|
1627
1660
|
`
|
|
1628
1661
|
}
|
|
1629
1662
|
]
|
|
@@ -2251,158 +2284,6 @@ var renameFile_default = {
|
|
|
2251
2284
|
isAvailable: isAvailable13
|
|
2252
2285
|
};
|
|
2253
2286
|
|
|
2254
|
-
// src/tools/editFile.ts
|
|
2255
|
-
var toolInfo14 = {
|
|
2256
|
-
name: "edit_file",
|
|
2257
|
-
description: "Request to edit file contents using search/replace operations. Supports multiple edit operations in a single call.",
|
|
2258
|
-
parameters: [
|
|
2259
|
-
{
|
|
2260
|
-
name: "path",
|
|
2261
|
-
description: "The path of the file to edit",
|
|
2262
|
-
required: true,
|
|
2263
|
-
usageValue: "File path here"
|
|
2264
|
-
},
|
|
2265
|
-
{
|
|
2266
|
-
name: "operations",
|
|
2267
|
-
description: "Edit operation with search and replace parameters",
|
|
2268
|
-
required: true,
|
|
2269
|
-
allowMultiple: true,
|
|
2270
|
-
children: [
|
|
2271
|
-
{
|
|
2272
|
-
name: "search",
|
|
2273
|
-
description: `Text to search for and replace (use ${START_OF_FILE} to insert at file start, ${END_OF_FILE} to insert at file end)`,
|
|
2274
|
-
required: true,
|
|
2275
|
-
usageValue: "Text to find and replace"
|
|
2276
|
-
},
|
|
2277
|
-
{
|
|
2278
|
-
name: "replace",
|
|
2279
|
-
description: "Text to replace the search text with",
|
|
2280
|
-
required: true,
|
|
2281
|
-
usageValue: "Replacement text"
|
|
2282
|
-
}
|
|
2283
|
-
],
|
|
2284
|
-
usageValue: "operations here"
|
|
2285
|
-
}
|
|
2286
|
-
],
|
|
2287
|
-
examples: [
|
|
2288
|
-
{
|
|
2289
|
-
description: "Replace specific text",
|
|
2290
|
-
parameters: [
|
|
2291
|
-
{
|
|
2292
|
-
name: "path",
|
|
2293
|
-
value: "src/main.ts"
|
|
2294
|
-
},
|
|
2295
|
-
{
|
|
2296
|
-
name: "operations",
|
|
2297
|
-
value: {
|
|
2298
|
-
search: "function oldFunction() {\n return 42;\n}",
|
|
2299
|
-
replace: 'function newFunction() {\n return "new implementation";\n}'
|
|
2300
|
-
}
|
|
2301
|
-
}
|
|
2302
|
-
]
|
|
2303
|
-
},
|
|
2304
|
-
{
|
|
2305
|
-
description: "Insert at start of file",
|
|
2306
|
-
parameters: [
|
|
2307
|
-
{
|
|
2308
|
-
name: "path",
|
|
2309
|
-
value: "src/header.ts"
|
|
2310
|
-
},
|
|
2311
|
-
{
|
|
2312
|
-
name: "operations",
|
|
2313
|
-
value: {
|
|
2314
|
-
search: START_OF_FILE,
|
|
2315
|
-
replace: "// File header comment\n"
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
]
|
|
2319
|
-
},
|
|
2320
|
-
{
|
|
2321
|
-
description: "Multiple operations in one call",
|
|
2322
|
-
parameters: [
|
|
2323
|
-
{
|
|
2324
|
-
name: "path",
|
|
2325
|
-
value: "src/utils.ts"
|
|
2326
|
-
},
|
|
2327
|
-
{
|
|
2328
|
-
name: "operations",
|
|
2329
|
-
value: [
|
|
2330
|
-
{
|
|
2331
|
-
search: 'import React from "react"',
|
|
2332
|
-
replace: 'import React, { useState } from "react"'
|
|
2333
|
-
},
|
|
2334
|
-
{
|
|
2335
|
-
search: "function Component() {\n return (",
|
|
2336
|
-
replace: "function Component() {\n const [state, setState] = useState(false);\n return ("
|
|
2337
|
-
}
|
|
2338
|
-
]
|
|
2339
|
-
}
|
|
2340
|
-
]
|
|
2341
|
-
},
|
|
2342
|
-
{
|
|
2343
|
-
description: "Append content at end of file",
|
|
2344
|
-
parameters: [
|
|
2345
|
-
{
|
|
2346
|
-
name: "path",
|
|
2347
|
-
value: "src/footer.ts"
|
|
2348
|
-
},
|
|
2349
|
-
{
|
|
2350
|
-
name: "operations",
|
|
2351
|
-
value: {
|
|
2352
|
-
search: END_OF_FILE,
|
|
2353
|
-
replace: "\n// End of file appended comment\n"
|
|
2354
|
-
}
|
|
2355
|
-
}
|
|
2356
|
-
]
|
|
2357
|
-
}
|
|
2358
|
-
],
|
|
2359
|
-
permissionLevel: 2 /* Write */
|
|
2360
|
-
};
|
|
2361
|
-
var handler14 = async (provider, args) => {
|
|
2362
|
-
if (!provider.readFile || !provider.writeFile) {
|
|
2363
|
-
return {
|
|
2364
|
-
type: "Error" /* Error */,
|
|
2365
|
-
message: "Not possible to edit file. Abort."
|
|
2366
|
-
};
|
|
2367
|
-
}
|
|
2368
|
-
const path = getString(args, "path");
|
|
2369
|
-
const operations = getArray(args, "operations");
|
|
2370
|
-
if (!operations || operations.length === 0) {
|
|
2371
|
-
return {
|
|
2372
|
-
type: "Error" /* Error */,
|
|
2373
|
-
message: `<error><edit_file_path>${path}</edit_file_path><error_message>At least one edit operation is required</error_message></error>`
|
|
2374
|
-
};
|
|
2375
|
-
}
|
|
2376
|
-
const fileContent = await provider.readFile(path);
|
|
2377
|
-
if (fileContent == null) {
|
|
2378
|
-
return {
|
|
2379
|
-
type: "Error" /* Error */,
|
|
2380
|
-
message: `<error><edit_file_path>${path}</edit_file_path><error_message>File not found</error_message></error>`
|
|
2381
|
-
};
|
|
2382
|
-
}
|
|
2383
|
-
try {
|
|
2384
|
-
const result = await editFile(fileContent, operations);
|
|
2385
|
-
await provider.writeFile(path, result);
|
|
2386
|
-
return {
|
|
2387
|
-
type: "Reply" /* Reply */,
|
|
2388
|
-
message: `<edit_file_path>${path}</edit_file_path>`
|
|
2389
|
-
};
|
|
2390
|
-
} catch (error) {
|
|
2391
|
-
return {
|
|
2392
|
-
type: "Error" /* Error */,
|
|
2393
|
-
message: `<error><edit_file_path>${path}</edit_file_path><error_message>${error instanceof Error ? error.message : String(error)}</error_message></error>`
|
|
2394
|
-
};
|
|
2395
|
-
}
|
|
2396
|
-
};
|
|
2397
|
-
var isAvailable14 = (provider) => {
|
|
2398
|
-
return !!provider.readFile && !!provider.writeFile;
|
|
2399
|
-
};
|
|
2400
|
-
var editFile_default = {
|
|
2401
|
-
...toolInfo14,
|
|
2402
|
-
handler: handler14,
|
|
2403
|
-
isAvailable: isAvailable14
|
|
2404
|
-
};
|
|
2405
|
-
|
|
2406
2287
|
// src/getAvailableTools.ts
|
|
2407
2288
|
var getAvailableTools = ({
|
|
2408
2289
|
provider,
|
|
@@ -2623,6 +2504,8 @@ Tool use is formatted using XML-style tags. The tool name is enclosed in opening
|
|
|
2623
2504
|
...
|
|
2624
2505
|
</${toolNamePrefix}tool_name>
|
|
2625
2506
|
|
|
2507
|
+
**It is crucial that all tags are correctly nested and closed.**
|
|
2508
|
+
|
|
2626
2509
|
## Array Parameters
|
|
2627
2510
|
|
|
2628
2511
|
To create an array of values for a parameter, repeat the parameter tag multiple times:
|
|
@@ -2657,7 +2540,7 @@ You can also combine array parameters with nested objects:
|
|
|
2657
2540
|
</${parameterPrefix}key>
|
|
2658
2541
|
</${toolNamePrefix}example_tool>
|
|
2659
2542
|
|
|
2660
|
-
Always adhere to this format
|
|
2543
|
+
Always adhere to this format, ensuring every opening tag has a matching closing tag, to ensure proper parsing and execution.
|
|
2661
2544
|
|
|
2662
2545
|
NEVER surround tool use with triple backticks (\`\`\`).
|
|
2663
2546
|
|
|
@@ -2674,18 +2557,14 @@ ${tools.map((tool) => {
|
|
|
2674
2557
|
}).join("")}
|
|
2675
2558
|
# Tool Use Guidelines
|
|
2676
2559
|
|
|
2677
|
-
1. **
|
|
2678
|
-
- Before using a tool, wrap your reasoning inside \`<thinking>\` tags. Be concise\u2014just enough to clarify your plan and the rationale behind selecting a specific tool.
|
|
2679
|
-
2. **Wait for Feedback**
|
|
2560
|
+
1. **Wait for Feedback**
|
|
2680
2561
|
- After using a tool, wait for the user's response indicating success/failure or any output logs. Do not assume the result of a tool without explicit confirmation.
|
|
2681
|
-
|
|
2562
|
+
2. **Error Handling**
|
|
2682
2563
|
- If a tool fails or produces an unexpected result, analyze the error, decide on an alternative approach or tool, and proceed carefully.
|
|
2683
|
-
|
|
2564
|
+
3. **Avoid Repetition**
|
|
2684
2565
|
- Do not quote or repeat previous commands or prompts verbatim. Move the conversation forward by focusing on the latest required action.
|
|
2685
|
-
|
|
2686
|
-
-
|
|
2687
|
-
6. **Tool Call Limit**
|
|
2688
|
-
- Do not make more than 5 tool calls in a single message.`;
|
|
2566
|
+
4. **Tool Call Limit**
|
|
2567
|
+
- It is **STRIGHTLY FORBIDDEN** to make more than 5 tool calls in a single message.`;
|
|
2689
2568
|
};
|
|
2690
2569
|
var agentsPrompt = (agents, name) => `
|
|
2691
2570
|
====
|
|
@@ -3013,8 +2892,8 @@ ${instance.prompt}`;
|
|
|
3013
2892
|
}
|
|
3014
2893
|
async #invokeTool(name, args) {
|
|
3015
2894
|
try {
|
|
3016
|
-
const
|
|
3017
|
-
if (!
|
|
2895
|
+
const handler14 = this.handlers[name]?.handler;
|
|
2896
|
+
if (!handler14) {
|
|
3018
2897
|
return {
|
|
3019
2898
|
type: "Error" /* Error */,
|
|
3020
2899
|
message: responsePrompts.errorInvokeTool(name, "Tool not found"),
|
|
@@ -3033,7 +2912,7 @@ ${instance.prompt}`;
|
|
|
3033
2912
|
if (resp) {
|
|
3034
2913
|
return resp;
|
|
3035
2914
|
}
|
|
3036
|
-
return await
|
|
2915
|
+
return await handler14(this.config.provider, args);
|
|
3037
2916
|
} catch (error) {
|
|
3038
2917
|
return {
|
|
3039
2918
|
type: "Error" /* Error */,
|
|
@@ -3391,7 +3270,7 @@ var editingFilesPrompt = (toolNamePrefix) => `
|
|
|
3391
3270
|
|
|
3392
3271
|
EDITING FILES
|
|
3393
3272
|
|
|
3394
|
-
You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full overwrite) and **${toolNamePrefix}
|
|
3273
|
+
You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full overwrite) and **${toolNamePrefix}replace_in_file** (targeted anchor-based edits). Choose the smallest safe operation for every change.
|
|
3395
3274
|
|
|
3396
3275
|
# ${toolNamePrefix}write_to_file
|
|
3397
3276
|
|
|
@@ -3403,16 +3282,16 @@ You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full o
|
|
|
3403
3282
|
|
|
3404
3283
|
- Initial file creation, such as when scaffolding a new project.
|
|
3405
3284
|
- Overwriting large boilerplate files where you want to replace the entire content at once.
|
|
3406
|
-
- When the complexity or number of changes would make ${toolNamePrefix}
|
|
3285
|
+
- When the complexity or number of changes would make ${toolNamePrefix}replace_in_file unwieldy or error-prone.
|
|
3407
3286
|
- When you need to completely restructure a file's content or change its fundamental organization.
|
|
3408
3287
|
|
|
3409
3288
|
## Important Considerations
|
|
3410
3289
|
|
|
3411
3290
|
- Using ${toolNamePrefix}write_to_file requires providing the file's complete final content.
|
|
3412
|
-
- If you only need to make small changes to an existing file, consider using ${toolNamePrefix}
|
|
3291
|
+
- If you only need to make small changes to an existing file, consider using ${toolNamePrefix}replace_in_file instead to avoid unnecessarily rewriting the entire file.
|
|
3413
3292
|
- While ${toolNamePrefix}write_to_file should not be your default choice, don't hesitate to use it when the situation truly calls for it.
|
|
3414
3293
|
|
|
3415
|
-
# ${toolNamePrefix}
|
|
3294
|
+
# ${toolNamePrefix}replace_in_file
|
|
3416
3295
|
|
|
3417
3296
|
## Purpose
|
|
3418
3297
|
|
|
@@ -3431,10 +3310,10 @@ You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full o
|
|
|
3431
3310
|
|
|
3432
3311
|
# Choosing the Appropriate Tool
|
|
3433
3312
|
|
|
3434
|
-
- **Default to ${toolNamePrefix}
|
|
3313
|
+
- **Default to ${toolNamePrefix}replace_in_file** for most changes. It keeps diffs small and reduces risk.
|
|
3435
3314
|
- **Use ${toolNamePrefix}write_to_file** when:
|
|
3436
3315
|
- Creating new files
|
|
3437
|
-
- The changes are so extensive that using ${toolNamePrefix}
|
|
3316
|
+
- The changes are so extensive that using ${toolNamePrefix}replace_in_file would be more complex or risky
|
|
3438
3317
|
- You need to completely reorganize or restructure a file
|
|
3439
3318
|
- The file is relatively small and the changes affect most of its content
|
|
3440
3319
|
- You're generating boilerplate or template files
|
|
@@ -3442,9 +3321,9 @@ You have two file-manipulation tools: **${toolNamePrefix}write_to_file** (full o
|
|
|
3442
3321
|
# Workflow Tips
|
|
3443
3322
|
|
|
3444
3323
|
1. Before editing, assess the scope of your changes and decide which tool to use.
|
|
3445
|
-
2. For targeted edits, apply ${toolNamePrefix}
|
|
3324
|
+
2. For targeted edits, apply ${toolNamePrefix}replace_in_file with carefully crafted before/after text anchors. If you need multiple changes, you can stack multiple operations within a single ${toolNamePrefix}replace_in_file call.
|
|
3446
3325
|
3. For major overhauls or initial file creation, rely on ${toolNamePrefix}write_to_file.
|
|
3447
|
-
4. Once the file has been edited with either ${toolNamePrefix}write_to_file or ${toolNamePrefix}
|
|
3326
|
+
4. Once the file has been edited with either ${toolNamePrefix}write_to_file or ${toolNamePrefix}replace_in_file, the system will provide you with the final state of the modified file. Use this updated content as the reference point for any subsequent operations, since it reflects any auto-formatting or user-applied changes.
|
|
3448
3327
|
|
|
3449
3328
|
Picking the right tool keeps edits minimal, safe, and easy to review.
|
|
3450
3329
|
`;
|
|
@@ -3458,10 +3337,10 @@ RULES
|
|
|
3458
3337
|
For text files (e.g. README.md), append a footer with the same notice.
|
|
3459
3338
|
- Never describe what changed inside code comments; comments must focus on purpose or usage only.
|
|
3460
3339
|
- Before using ${toolNamePrefix}execute_command, consider SYSTEM INFORMATION to ensure commands suit the user's OS. If a command must run in a subdirectory, prepend a single \`cd childDir &&\` segment.
|
|
3461
|
-
- Use ${toolNamePrefix}search_files for broad analysis, then ${toolNamePrefix}read_file to inspect context, and finally ${toolNamePrefix}
|
|
3462
|
-
- Prefer ${toolNamePrefix}
|
|
3340
|
+
- Use ${toolNamePrefix}search_files for broad analysis, then ${toolNamePrefix}read_file to inspect context, and finally ${toolNamePrefix}replace_in_file or ${toolNamePrefix}write_to_file to modify.
|
|
3341
|
+
- Prefer ${toolNamePrefix}replace_in_file for focused edits; choose ${toolNamePrefix}write_to_file for new files or complete rewrites.
|
|
3463
3342
|
- When creating a new file, look for existing files with similar content or patterns; if found, read them and use their structure or conventions as a reference.
|
|
3464
|
-
- Use before/after text anchors in ${toolNamePrefix}
|
|
3343
|
+
- Use before/after text anchors in ${toolNamePrefix}replace_in_file to target changes. If multiple operations are needed, list them in file order.
|
|
3465
3344
|
- Do not guess unseen content. Read existing files first unless creating new ones.
|
|
3466
3345
|
- Follow existing style, lint, and naming conventions. Ensure all changes compile and pass tests where applicable.
|
|
3467
3346
|
- ALWAYS wait for the user's confirmation after each tool call before starting the next step.
|
|
@@ -4360,8 +4239,6 @@ export {
|
|
|
4360
4239
|
deepSeekModels,
|
|
4361
4240
|
defaultModels,
|
|
4362
4241
|
delegate_default as delegate,
|
|
4363
|
-
editFile_default as editFile,
|
|
4364
|
-
editFile as editFileHelper,
|
|
4365
4242
|
executeAgentTool,
|
|
4366
4243
|
executeCommand_default as executeCommand,
|
|
4367
4244
|
executeTool,
|