pybao-cli 1.5.46 → 1.5.49
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/REPL-QOH5GRZO.js +53 -0
- package/dist/{acp-JLRZ5E3I.js → acp-6X7A2AET.js} +30 -30
- package/dist/{agentsValidate-3OYN7SNK.js → agentsValidate-GRUUS3WU.js} +7 -7
- package/dist/{ask-BHVMWER5.js → ask-HZDW4LTP.js} +30 -30
- package/dist/{autoUpdater-27NDSNED.js → autoUpdater-SPEKG26M.js} +3 -3
- package/dist/{chunk-ASMQWQTY.js → chunk-3OA76CSA.js} +1 -1
- package/dist/{chunk-6WVP4NLC.js → chunk-4DMR3345.js} +366 -717
- package/dist/chunk-4DMR3345.js.map +7 -0
- package/dist/{chunk-5VQQJFA3.js → chunk-7NJKFUVQ.js} +3 -3
- package/dist/{chunk-R6A5OQPH.js → chunk-7OKEXFNZ.js} +3 -3
- package/dist/{chunk-PZBMEC3T.js → chunk-AIKGRPJR.js} +2 -2
- package/dist/{chunk-4K3MGWZ7.js → chunk-AKDLTQJZ.js} +1 -1
- package/dist/{chunk-DS6COGYF.js → chunk-ALMRZ6TK.js} +4 -1
- package/dist/chunk-ALMRZ6TK.js.map +7 -0
- package/dist/{chunk-EUYHO7FU.js → chunk-C2BMJGBF.js} +1 -1
- package/dist/{chunk-QIWBL65U.js → chunk-E5CC5UGF.js} +4 -4
- package/dist/{chunk-KDPYN5HT.js → chunk-EPTONOB3.js} +1 -1
- package/dist/{chunk-LA6C74RB.js → chunk-F4IOWWDV.js} +3 -3
- package/dist/{chunk-HHGV6WKI.js → chunk-I33HG6MZ.js} +1 -1
- package/dist/{chunk-J2NQVO6G.js → chunk-JJNZ7WEP.js} +1 -1
- package/dist/{chunk-ATYJA674.js → chunk-KH3BWQJI.js} +2 -2
- package/dist/{chunk-Q3ND7MXY.js → chunk-KSDMNPM3.js} +3 -3
- package/dist/{chunk-WEXG5Q5B.js → chunk-NRGFDG57.js} +2 -2
- package/dist/{chunk-D7QIKN3F.js → chunk-NSPAFJYF.js} +3 -3
- package/dist/{chunk-C2NMYFPN.js → chunk-NYRCQC7E.js} +3 -3
- package/dist/{chunk-KUKOMPLF.js → chunk-OT7EHZKB.js} +1 -1
- package/dist/{chunk-VP62JPGI.js → chunk-SCZBEZ4L.js} +2 -2
- package/dist/{chunk-AVQJBO3X.js → chunk-SQL5Q5UT.js} +638 -129
- package/dist/chunk-SQL5Q5UT.js.map +7 -0
- package/dist/{chunk-2GQH5CH7.js → chunk-TBPXZUAE.js} +2 -2
- package/dist/{chunk-LSDHJWLA.js → chunk-UEF22EAA.js} +578 -28
- package/dist/chunk-UEF22EAA.js.map +7 -0
- package/dist/{chunk-BSCFLD7U.js → chunk-V633SD3K.js} +3 -3
- package/dist/{chunk-U5OB3CDM.js → chunk-V6B67TTT.js} +3 -3
- package/dist/{chunk-5BASSS5Y.js → chunk-VII5ABW7.js} +1 -1
- package/dist/{chunk-KPDYWSAZ.js → chunk-X7L2ZXEQ.js} +2 -2
- package/dist/{chunk-IOSFLDRK.js → chunk-XGSD7RT6.js} +1 -1
- package/dist/{chunk-DIOS332Y.js → chunk-XRHL3B3W.js} +1 -1
- package/dist/{chunk-J2UQWSDT.js → chunk-ZBUV2OFZ.js} +1 -1
- package/dist/{chunk-KYMBYUI7.js → chunk-ZYI3GZHI.js} +4 -4
- package/dist/{cli-TCRA6ARC.js → cli-E24TVQWL.js} +90 -90
- package/dist/commands-M75WK3OK.js +57 -0
- package/dist/{config-5KMP3FRP.js → config-U5HHXO56.js} +4 -4
- package/dist/{context-VPRXOV4W.js → context-5XAWTXIF.js} +6 -6
- package/dist/{conversationPersistence-66W5Z6AO.js → conversationPersistence-COKR4DJM.js} +3 -3
- package/dist/{conversationTracker-FTAS67VE.js → conversationTracker-CFWPAQJQ.js} +4 -4
- package/dist/{customCommands-YQ2A3R6L.js → customCommands-KV4SPPEJ.js} +4 -4
- package/dist/{env-BDTFUU2H.js → env-6Z2X4SGO.js} +2 -2
- package/dist/{file-N4UK3JJK.js → file-EYJLYMU7.js} +4 -4
- package/dist/index.js +3 -3
- package/dist/{llm-QTECZGRE.js → llm-JRNCNUVN.js} +31 -31
- package/dist/{llmLazy-5OLIOZK2.js → llmLazy-ULKOVGTW.js} +1 -1
- package/dist/{loader-ITDKGIKQ.js → loader-YC2J4JQD.js} +4 -4
- package/dist/{lsp-DNNS2MO4.js → lsp-YOU3CXAU.js} +7 -6
- package/dist/{lspAnchor-HU2YPGDN.js → lspAnchor-XLKJXJ4F.js} +8 -8
- package/dist/{mcp-5R4HG2LZ.js → mcp-ZBXWPPEQ.js} +7 -7
- package/dist/{mentionProcessor-5DPHU4OP.js → mentionProcessor-D7A5SR2F.js} +5 -5
- package/dist/{messages-ZVVMQ3Q6.js → messages-N4BMW6FO.js} +1 -1
- package/dist/{model-Q3NJN5MQ.js → model-3R63GBXV.js} +5 -5
- package/dist/{openai-HSEUQEKK.js → openai-OE2BXCWW.js} +5 -5
- package/dist/{outputStyles-YGD3BAAK.js → outputStyles-7NXCPWAM.js} +4 -4
- package/dist/{pluginRuntime-ODOQDPAK.js → pluginRuntime-DUFKGBKI.js} +6 -6
- package/dist/{pluginValidation-P52JWV6C.js → pluginValidation-TUI4RWTL.js} +6 -6
- package/dist/prompts-VLIUTRIV.js +59 -0
- package/dist/{pybAgentSessionLoad-B735OKRY.js → pybAgentSessionLoad-OHCESID3.js} +4 -4
- package/dist/{pybAgentSessionResume-YKCKQOJO.js → pybAgentSessionResume-X7TO6VQ7.js} +4 -4
- package/dist/{pybAgentStreamJsonSession-7KQJH3YL.js → pybAgentStreamJsonSession-3XCK4MLN.js} +1 -1
- package/dist/{pybHooks-27O2F24J.js → pybHooks-WGTXY2KQ.js} +4 -4
- package/dist/query-Y332XP4J.js +57 -0
- package/dist/{registry-CJLUFMEQ.js → registry-V4XMLWYT.js} +5 -5
- package/dist/{ripgrep-TD77KYER.js → ripgrep-ITNB4VGR.js} +3 -3
- package/dist/{skillMarketplace-R475NBXV.js → skillMarketplace-YYMKIEEM.js} +3 -3
- package/dist/{state-KQVHDJY3.js → state-ZQW77MQC.js} +2 -2
- package/dist/{theme-GDAAXHZV.js → theme-L3I3PP7H.js} +5 -5
- package/dist/{toolPermissionSettings-ZTEGC7CB.js → toolPermissionSettings-ZHMSXSXS.js} +6 -6
- package/dist/tools-CM5X3TT5.js +57 -0
- package/dist/{userInput-7HR7YK3T.js → userInput-VSYAOPNU.js} +32 -32
- package/package.json +4 -1
- package/dist/REPL-OP6NG7VB.js +0 -53
- package/dist/chunk-6WVP4NLC.js.map +0 -7
- package/dist/chunk-AVQJBO3X.js.map +0 -7
- package/dist/chunk-DS6COGYF.js.map +0 -7
- package/dist/chunk-LSDHJWLA.js.map +0 -7
- package/dist/commands-7FEOAWKL.js +0 -57
- package/dist/prompts-VWZICAZT.js +0 -59
- package/dist/query-YW4M2CLS.js +0 -57
- package/dist/tools-4WVDBE5W.js +0 -57
- /package/dist/{REPL-OP6NG7VB.js.map → REPL-QOH5GRZO.js.map} +0 -0
- /package/dist/{acp-JLRZ5E3I.js.map → acp-6X7A2AET.js.map} +0 -0
- /package/dist/{agentsValidate-3OYN7SNK.js.map → agentsValidate-GRUUS3WU.js.map} +0 -0
- /package/dist/{ask-BHVMWER5.js.map → ask-HZDW4LTP.js.map} +0 -0
- /package/dist/{autoUpdater-27NDSNED.js.map → autoUpdater-SPEKG26M.js.map} +0 -0
- /package/dist/{chunk-ASMQWQTY.js.map → chunk-3OA76CSA.js.map} +0 -0
- /package/dist/{chunk-5VQQJFA3.js.map → chunk-7NJKFUVQ.js.map} +0 -0
- /package/dist/{chunk-R6A5OQPH.js.map → chunk-7OKEXFNZ.js.map} +0 -0
- /package/dist/{chunk-PZBMEC3T.js.map → chunk-AIKGRPJR.js.map} +0 -0
- /package/dist/{chunk-4K3MGWZ7.js.map → chunk-AKDLTQJZ.js.map} +0 -0
- /package/dist/{chunk-EUYHO7FU.js.map → chunk-C2BMJGBF.js.map} +0 -0
- /package/dist/{chunk-QIWBL65U.js.map → chunk-E5CC5UGF.js.map} +0 -0
- /package/dist/{chunk-KDPYN5HT.js.map → chunk-EPTONOB3.js.map} +0 -0
- /package/dist/{chunk-LA6C74RB.js.map → chunk-F4IOWWDV.js.map} +0 -0
- /package/dist/{chunk-HHGV6WKI.js.map → chunk-I33HG6MZ.js.map} +0 -0
- /package/dist/{chunk-J2NQVO6G.js.map → chunk-JJNZ7WEP.js.map} +0 -0
- /package/dist/{chunk-ATYJA674.js.map → chunk-KH3BWQJI.js.map} +0 -0
- /package/dist/{chunk-Q3ND7MXY.js.map → chunk-KSDMNPM3.js.map} +0 -0
- /package/dist/{chunk-WEXG5Q5B.js.map → chunk-NRGFDG57.js.map} +0 -0
- /package/dist/{chunk-D7QIKN3F.js.map → chunk-NSPAFJYF.js.map} +0 -0
- /package/dist/{chunk-C2NMYFPN.js.map → chunk-NYRCQC7E.js.map} +0 -0
- /package/dist/{chunk-KUKOMPLF.js.map → chunk-OT7EHZKB.js.map} +0 -0
- /package/dist/{chunk-VP62JPGI.js.map → chunk-SCZBEZ4L.js.map} +0 -0
- /package/dist/{chunk-2GQH5CH7.js.map → chunk-TBPXZUAE.js.map} +0 -0
- /package/dist/{chunk-BSCFLD7U.js.map → chunk-V633SD3K.js.map} +0 -0
- /package/dist/{chunk-U5OB3CDM.js.map → chunk-V6B67TTT.js.map} +0 -0
- /package/dist/{chunk-5BASSS5Y.js.map → chunk-VII5ABW7.js.map} +0 -0
- /package/dist/{chunk-KPDYWSAZ.js.map → chunk-X7L2ZXEQ.js.map} +0 -0
- /package/dist/{chunk-IOSFLDRK.js.map → chunk-XGSD7RT6.js.map} +0 -0
- /package/dist/{chunk-DIOS332Y.js.map → chunk-XRHL3B3W.js.map} +0 -0
- /package/dist/{chunk-J2UQWSDT.js.map → chunk-ZBUV2OFZ.js.map} +0 -0
- /package/dist/{chunk-KYMBYUI7.js.map → chunk-ZYI3GZHI.js.map} +0 -0
- /package/dist/{cli-TCRA6ARC.js.map → cli-E24TVQWL.js.map} +0 -0
- /package/dist/{commands-7FEOAWKL.js.map → commands-M75WK3OK.js.map} +0 -0
- /package/dist/{config-5KMP3FRP.js.map → config-U5HHXO56.js.map} +0 -0
- /package/dist/{context-VPRXOV4W.js.map → context-5XAWTXIF.js.map} +0 -0
- /package/dist/{conversationPersistence-66W5Z6AO.js.map → conversationPersistence-COKR4DJM.js.map} +0 -0
- /package/dist/{conversationTracker-FTAS67VE.js.map → conversationTracker-CFWPAQJQ.js.map} +0 -0
- /package/dist/{customCommands-YQ2A3R6L.js.map → customCommands-KV4SPPEJ.js.map} +0 -0
- /package/dist/{env-BDTFUU2H.js.map → env-6Z2X4SGO.js.map} +0 -0
- /package/dist/{file-N4UK3JJK.js.map → file-EYJLYMU7.js.map} +0 -0
- /package/dist/{llm-QTECZGRE.js.map → llm-JRNCNUVN.js.map} +0 -0
- /package/dist/{llmLazy-5OLIOZK2.js.map → llmLazy-ULKOVGTW.js.map} +0 -0
- /package/dist/{loader-ITDKGIKQ.js.map → loader-YC2J4JQD.js.map} +0 -0
- /package/dist/{lsp-DNNS2MO4.js.map → lsp-YOU3CXAU.js.map} +0 -0
- /package/dist/{lspAnchor-HU2YPGDN.js.map → lspAnchor-XLKJXJ4F.js.map} +0 -0
- /package/dist/{mcp-5R4HG2LZ.js.map → mcp-ZBXWPPEQ.js.map} +0 -0
- /package/dist/{mentionProcessor-5DPHU4OP.js.map → mentionProcessor-D7A5SR2F.js.map} +0 -0
- /package/dist/{messages-ZVVMQ3Q6.js.map → messages-N4BMW6FO.js.map} +0 -0
- /package/dist/{model-Q3NJN5MQ.js.map → model-3R63GBXV.js.map} +0 -0
- /package/dist/{openai-HSEUQEKK.js.map → openai-OE2BXCWW.js.map} +0 -0
- /package/dist/{outputStyles-YGD3BAAK.js.map → outputStyles-7NXCPWAM.js.map} +0 -0
- /package/dist/{pluginRuntime-ODOQDPAK.js.map → pluginRuntime-DUFKGBKI.js.map} +0 -0
- /package/dist/{pluginValidation-P52JWV6C.js.map → pluginValidation-TUI4RWTL.js.map} +0 -0
- /package/dist/{prompts-VWZICAZT.js.map → prompts-VLIUTRIV.js.map} +0 -0
- /package/dist/{pybAgentSessionLoad-B735OKRY.js.map → pybAgentSessionLoad-OHCESID3.js.map} +0 -0
- /package/dist/{pybAgentSessionResume-YKCKQOJO.js.map → pybAgentSessionResume-X7TO6VQ7.js.map} +0 -0
- /package/dist/{pybAgentStreamJsonSession-7KQJH3YL.js.map → pybAgentStreamJsonSession-3XCK4MLN.js.map} +0 -0
- /package/dist/{pybHooks-27O2F24J.js.map → pybHooks-WGTXY2KQ.js.map} +0 -0
- /package/dist/{query-YW4M2CLS.js.map → query-Y332XP4J.js.map} +0 -0
- /package/dist/{registry-CJLUFMEQ.js.map → registry-V4XMLWYT.js.map} +0 -0
- /package/dist/{ripgrep-TD77KYER.js.map → ripgrep-ITNB4VGR.js.map} +0 -0
- /package/dist/{skillMarketplace-R475NBXV.js.map → skillMarketplace-YYMKIEEM.js.map} +0 -0
- /package/dist/{state-KQVHDJY3.js.map → state-ZQW77MQC.js.map} +0 -0
- /package/dist/{theme-GDAAXHZV.js.map → theme-L3I3PP7H.js.map} +0 -0
- /package/dist/{toolPermissionSettings-ZTEGC7CB.js.map → toolPermissionSettings-ZHMSXSXS.js.map} +0 -0
- /package/dist/{tools-4WVDBE5W.js.map → tools-CM5X3TT5.js.map} +0 -0
- /package/dist/{userInput-7HR7YK3T.js.map → userInput-VSYAOPNU.js.map} +0 -0
|
@@ -3,13 +3,13 @@ const require = __pybCreateRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
getSettingsFileCandidates,
|
|
5
5
|
loadSettingsWithLegacyFallback
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JJNZ7WEP.js";
|
|
7
7
|
import {
|
|
8
8
|
getSessionPlugins
|
|
9
9
|
} from "./chunk-BJSWTHRM.js";
|
|
10
10
|
import {
|
|
11
11
|
getTheme
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-AKDLTQJZ.js";
|
|
13
13
|
import {
|
|
14
14
|
addMcprcServerForTesting,
|
|
15
15
|
getCurrentProjectConfig,
|
|
@@ -19,13 +19,13 @@ import {
|
|
|
19
19
|
safeParseJSON,
|
|
20
20
|
saveCurrentProjectConfig,
|
|
21
21
|
saveGlobalConfig
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-NYRCQC7E.js";
|
|
23
23
|
import {
|
|
24
24
|
PRODUCT_COMMAND,
|
|
25
25
|
PRODUCT_NAME,
|
|
26
26
|
getCwd,
|
|
27
27
|
logMCPError
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-ZBUV2OFZ.js";
|
|
29
29
|
|
|
30
30
|
// src/services/mcp/client.ts
|
|
31
31
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
@@ -695,6 +695,7 @@ function FallbackToolUseRejectedMessage() {
|
|
|
695
695
|
}
|
|
696
696
|
|
|
697
697
|
// src/tools/mcp/MCPTool/prompt.ts
|
|
698
|
+
var TOOL_NAME = "mcp";
|
|
698
699
|
var PROMPT = "";
|
|
699
700
|
var DESCRIPTION = "";
|
|
700
701
|
|
|
@@ -906,6 +907,545 @@ function normalizeSandboxRuntimeConfigFromSettings(settings, options) {
|
|
|
906
907
|
};
|
|
907
908
|
}
|
|
908
909
|
|
|
910
|
+
// src/tools/filesystem/FileReadTool/prompt.ts
|
|
911
|
+
var MAX_LINES_TO_READ = 2e3;
|
|
912
|
+
var MAX_LINE_LENGTH = 2e3;
|
|
913
|
+
var TOOL_NAME2 = "Read";
|
|
914
|
+
var DESCRIPTION2 = "Read a file or directory from the local filesystem.";
|
|
915
|
+
var PROMPT2 = `Reads a file or directory from the local filesystem. You can access any file or directory directly by using this tool.Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid; otherwise, Ensure the path is confirmed by Glob/Grep before reading.
|
|
916
|
+
|
|
917
|
+
## Best Practice
|
|
918
|
+
- **Read vs Analyze**: Use this tool when you need to inspect full implementation details.
|
|
919
|
+
- **Workflow**: Locate file (Glob/Grep) -> Read file (FileRead) -> Edit file.
|
|
920
|
+
- **Avoid**: Do not use this to 'search' for code strings; use 'Grep' or 'Glob' for that.
|
|
921
|
+
|
|
922
|
+
## When NOT to Use Read Tool
|
|
923
|
+
- **Unverified Paths**: Do NOT read a file if the path was inferred or guessed from context. Always verify the path exists using Glob/Grep first.
|
|
924
|
+
- **Exploration Phase**: When exploring unfamiliar code, do NOT assume file locations. Use Glob/Grep to discover actual paths before reading.
|
|
925
|
+
- It is okay to read a file that does not exist; an error will be returned.
|
|
926
|
+
|
|
927
|
+
## Usage Details
|
|
928
|
+
- The file_path parameter must be an absolute path, not a relative path
|
|
929
|
+
- This tool supports both file mode and directory mode
|
|
930
|
+
- In directory mode, offset/limit are 1-based entry pagination and offset>=1 is required
|
|
931
|
+
- In file mode, offset/limit are 1-based line pagination; offset=1 starts from the first line shown in cat -n output
|
|
932
|
+
- By default, file mode reads up to ${MAX_LINES_TO_READ} lines starting from the beginning of the file
|
|
933
|
+
- You can optionally specify a line offset and limit (especially handy for long files). **Smart Truncation is active** only in file mode when \`limit\` is provided and \`symbol_name\` is not provided: if your limit cuts a function or class in the middle, the tool will automatically extend the read range to include the full semantic block (up to 500 extra lines).
|
|
934
|
+
- Smart Truncation is a best-effort semantic boundary repair (Tree-sitter). If semantic parsing fails, Read falls back to the original offset/limit window.
|
|
935
|
+
- symbol_name enables LSP-assisted symbol read: provide an exact symbol name to resolve the symbol range and read that block directly
|
|
936
|
+
- When \`symbol_name\` is provided, Read resolves symbol range via LSP and reads that block directly (offset/limit are ignored for range selection).
|
|
937
|
+
- Use symbol_name only after file path is confirmed and when you need a specific class/function definition; if symbol is missing, unresolved, or LSP is unavailable, fallback to offset/limit or use LspTool for semantic discovery first.
|
|
938
|
+
- Directory mode returns a one-level tree structure using \u251C\u2500\u2500/\u2514\u2500\u2500 and supports pagination continuation hints
|
|
939
|
+
- For large files, iterate in chunks: offset=1 limit=200, then offset=201 limit=200, and so on until the needed region is covered
|
|
940
|
+
- File text truncation is capped at 50KB per result and 2000 lines; 50KB is file text truncation and not a directory access gate
|
|
941
|
+
- Any lines longer than ${MAX_LINE_LENGTH} characters will be truncated
|
|
942
|
+
- Results are returned using cat -n format, with line numbers starting at 1
|
|
943
|
+
- This tool allows reading images (eg PNG, JPG, etc). When reading an image file the contents are presented visually.
|
|
944
|
+
- This tool can read PDF files and return them as document blocks for analysis.
|
|
945
|
+
- This tool can read Jupyter notebooks (.ipynb files) and returns all cells with their outputs, combining code, text, and visualizations.
|
|
946
|
+
- For wide repository exploration, still prefer Glob first, then use Read for focused file/directory inspection.
|
|
947
|
+
- You can call multiple tools in a single response. It is always better to speculatively read multiple potentially useful files in parallel.
|
|
948
|
+
- You will regularly be asked to read screenshots. If the user provides a path to a screenshot, ALWAYS use this tool to view the file at the path. This tool will work with all temporary file paths.
|
|
949
|
+
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.
|
|
950
|
+
|
|
951
|
+
## Typical Usage Examples
|
|
952
|
+
### Example 1: Exploring Unfamiliar Codebase
|
|
953
|
+
<example>
|
|
954
|
+
user: How does authentication work in this project?
|
|
955
|
+
assistant: [uses Grep tool with pattern="auth|login" to find relevant files]
|
|
956
|
+
[uses Glob tool with pattern="**/auth*.{ts,js}" to locate auth modules]
|
|
957
|
+
[reads the matched files after confirming their paths]
|
|
958
|
+
</example>
|
|
959
|
+
|
|
960
|
+
### Example 2: User Mentions a Concept Without Path
|
|
961
|
+
<example>
|
|
962
|
+
user: Check the database configuration
|
|
963
|
+
assistant: [uses Glob tool with pattern="**/config*.{ts,js,json}"]
|
|
964
|
+
[uses Grep tool with pattern="database|db_" to find config files with db settings]
|
|
965
|
+
[reads the confirmed config file]
|
|
966
|
+
</example>
|
|
967
|
+
|
|
968
|
+
### Example 3: Read Directory Structure Then Read File
|
|
969
|
+
<example>
|
|
970
|
+
user: Check the API module layout and read router implementation
|
|
971
|
+
assistant: [uses Glob tool with pattern="**/api*"]
|
|
972
|
+
[reads the confirmed api directory path to get one-level tree structure with Read]
|
|
973
|
+
[reads the router file path found in that directory tree]
|
|
974
|
+
</example>
|
|
975
|
+
|
|
976
|
+
### Example 4: LSP-Assisted Symbol Read
|
|
977
|
+
<example>
|
|
978
|
+
user: I only need the function that actually executes file reading, not the whole file
|
|
979
|
+
assistant: [uses Glob/Grep to confirm FileReadTool file path]
|
|
980
|
+
[uses Read with file_path="<absolute path>/FileReadTool.tsx" symbol_name="call"]
|
|
981
|
+
[if symbol is missing or unresolved, uses LspTool documentSymbol to discover exact symbol names, then retries]
|
|
982
|
+
[if LSP is unavailable, falls back to offset/limit chunked reads around likely implementation area]
|
|
983
|
+
<reasoning>
|
|
984
|
+
The assistant used symbol_name-based Read because:
|
|
985
|
+
1. User intent is a specific implementation block, not whole-file browsing
|
|
986
|
+
2. symbol_name gives precise semantic range selection and avoids noisy context
|
|
987
|
+
3. LspTool is used only for symbol discovery fallback, while Read remains the code retrieval tool
|
|
988
|
+
</reasoning>
|
|
989
|
+
</example>
|
|
990
|
+
|
|
991
|
+
### Example 5: Smart Truncation on Partial Window
|
|
992
|
+
<example>
|
|
993
|
+
user: Please read this file section for me; I do not know where the function ends
|
|
994
|
+
assistant: [uses Read with file_path="<absolute path>/service.ts" offset=120 limit=30]
|
|
995
|
+
[relies on Smart Truncation to auto-extend when the requested window cuts a function/class boundary]
|
|
996
|
+
[checks returned startLine/numLines and continues with adjacent chunks if more context is needed]
|
|
997
|
+
[if semantic parsing fails, falls back to original offset/limit and continues chunked reading]
|
|
998
|
+
<reasoning>
|
|
999
|
+
The assistant used offset/limit Read with Smart Truncation because:
|
|
1000
|
+
1. User asked for a local section without symbol-level knowledge
|
|
1001
|
+
2. Pagination windows can split semantic containers, causing misleading partial code
|
|
1002
|
+
3. Smart Truncation repairs semantic boundaries while preserving pagination workflow
|
|
1003
|
+
</reasoning>
|
|
1004
|
+
</example>
|
|
1005
|
+
`.trim();
|
|
1006
|
+
|
|
1007
|
+
// src/tools/filesystem/FileEditTool/prompt.ts
|
|
1008
|
+
var TOOL_NAME3 = "Edit";
|
|
1009
|
+
var DESCRIPTION3 = `Performs smart string replacements in files using SEARCH/REPLACE blocks.
|
|
1010
|
+
|
|
1011
|
+
Usage:
|
|
1012
|
+
1. **Read First**: You must use your \`Read\` tool at least once before editing.
|
|
1013
|
+
2. **Block Format**: Provide changes as one or more SEARCH/REPLACE blocks.
|
|
1014
|
+
\`\`\`
|
|
1015
|
+
<<<<<<< SEARCH
|
|
1016
|
+
[original code to replace]
|
|
1017
|
+
=======
|
|
1018
|
+
[new code to insert]
|
|
1019
|
+
>>>>>>> REPLACE
|
|
1020
|
+
\`\`\`
|
|
1021
|
+
3. **Multiple Edits**: You can provide multiple blocks in a single turn to perform batch edits.
|
|
1022
|
+
4. **Context**: Include enough surrounding lines in the SEARCH block to ensure uniqueness.
|
|
1023
|
+
5. **Indentation**: Preserve the exact indentation (tabs/spaces) of the original file in your SEARCH block.
|
|
1024
|
+
6. **Smart Matching**: The tool uses a fuzzy matching engine. It can locate code even if there are minor differences in whitespace or indentation.
|
|
1025
|
+
7. **Conditional Edit**: Use \`if_not_contains\` to skip the edit if the file already contains a specific string.
|
|
1026
|
+
8. **Thinking**: You can include "thinking" text between blocks; the tool will ignore it.
|
|
1027
|
+
|
|
1028
|
+
## LSP-Integrated Behavior
|
|
1029
|
+
- **Semantic Anchor Assist**: Before fuzzy replacement, Edit tries LSP anchor matching to narrow replacement to the most relevant symbol range.
|
|
1030
|
+
- **When It Helps**: Especially useful when the same snippet appears multiple times and plain text matching may hit the wrong block.
|
|
1031
|
+
- **Fallback**: If LSP anchor is unavailable, Edit falls back to normal SEARCH/REPLACE matching.
|
|
1032
|
+
- **Post-Edit Verification**: Set \`verify: true\` to run LSP diagnostics after applying edits.
|
|
1033
|
+
- **Verification Guardrail**: If syntax/type diagnostics contain errors after edit, Edit reverts changes and returns a verification failure.
|
|
1034
|
+
- **When LSP Is Unavailable**: You may receive verification unavailable; retry with \`verify: false\` only when you have high confidence in edit safety.
|
|
1035
|
+
|
|
1036
|
+
Notes:
|
|
1037
|
+
- The edit will FAIL if the SEARCH block matches multiple locations(ambiguous). Provide more context.
|
|
1038
|
+
- To delete code, leave the REPLACE section empty.
|
|
1039
|
+
- To create a new file, use an empty SEARCH block with the desired content in REPLACE.
|
|
1040
|
+
- ALWAYS prefer editing existing files. NEVER write new files unless explicitly required.
|
|
1041
|
+
- For Jupyter Notebooks (.ipynb), use the NotebookEditTool instead.
|
|
1042
|
+
|
|
1043
|
+
## Typical Usage Examples
|
|
1044
|
+
### Example 1: Ambiguous Duplicate Snippet with LSP Anchor
|
|
1045
|
+
<example>
|
|
1046
|
+
user: Update the constructor guard in UserService, not the test helper copy
|
|
1047
|
+
assistant: [uses Read on UserService file to confirm target block]
|
|
1048
|
+
[uses Edit with SEARCH/REPLACE block and verify=true]
|
|
1049
|
+
[relies on LSP anchor assist to prefer semantic symbol region when duplicate text exists]
|
|
1050
|
+
<reasoning>
|
|
1051
|
+
The assistant enabled semantic-safe editing because:
|
|
1052
|
+
1. Duplicate snippets can cause ambiguous fuzzy matches
|
|
1053
|
+
2. LSP anchor narrows replacement to the intended symbol scope
|
|
1054
|
+
3. verify=true adds post-edit diagnostics guardrail and auto-revert on syntax errors
|
|
1055
|
+
</reasoning>
|
|
1056
|
+
</example>
|
|
1057
|
+
|
|
1058
|
+
### Example 2: Verification-Unavailable Recovery
|
|
1059
|
+
<example>
|
|
1060
|
+
user: Apply this quick rename in a generated file
|
|
1061
|
+
assistant: [uses Read to confirm exact path and block]
|
|
1062
|
+
[uses Edit with verify=true]
|
|
1063
|
+
[if response says verification unavailable, retries with verify=false and tighter SEARCH context]
|
|
1064
|
+
<reasoning>
|
|
1065
|
+
The assistant keeps verification first, then degrades safely because:
|
|
1066
|
+
1. LSP verification is preferred for correctness
|
|
1067
|
+
2. Generated or unsupported files may not have active LSP diagnostics
|
|
1068
|
+
3. Retrying with verify=false is acceptable only after narrowing context
|
|
1069
|
+
</reasoning>
|
|
1070
|
+
</example>
|
|
1071
|
+
`.trim();
|
|
1072
|
+
|
|
1073
|
+
// src/tools/filesystem/FileWriteTool/prompt.ts
|
|
1074
|
+
var TOOL_NAME4 = "Write";
|
|
1075
|
+
var DESCRIPTION4 = "Write a file to the local filesystem.";
|
|
1076
|
+
var PROMPT3 = `Writes a file to the local filesystem.
|
|
1077
|
+
|
|
1078
|
+
Usage:
|
|
1079
|
+
- This tool will overwrite the existing file if there is one at the provided path.
|
|
1080
|
+
- If this is an existing file, you MUST use the ${TOOL_NAME2} tool first to read the file's contents. This tool will fail if you did not read the file first.
|
|
1081
|
+
- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
|
|
1082
|
+
- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.
|
|
1083
|
+
- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.
|
|
1084
|
+
`.trim();
|
|
1085
|
+
|
|
1086
|
+
// src/tools/filesystem/GlobTool/prompt.ts
|
|
1087
|
+
var TOOL_NAME5 = "Glob";
|
|
1088
|
+
var DESCRIPTION5 = `Fast file pattern matching tool that works with any codebase size
|
|
1089
|
+
|
|
1090
|
+
## WhenToUse & Best Practice
|
|
1091
|
+
- If you have keywords or fuzzy paths, use Glob first to narrow candidates.
|
|
1092
|
+
- When you are doing an open ended search that may require multiple rounds of globbing and grepping, use the Agent tool instead
|
|
1093
|
+
- You can call multiple tools in a single response. It is always better to speculatively perform multiple searches in parallel if they are potentially useful.
|
|
1094
|
+
- This tool is for FINDING files.
|
|
1095
|
+
|
|
1096
|
+
## Directory Structure Guidance
|
|
1097
|
+
- For one-level directory structure, use Read directly on the directory path (offset>=1, optional limit)
|
|
1098
|
+
- Use Glob for file-path discovery and candidate narrowing, not as the primary one-level directory listing workflow
|
|
1099
|
+
|
|
1100
|
+
## Search Strategy
|
|
1101
|
+
- **Broad-to-Narrow Pattern**: Start with a broad pattern, then narrow based on results.
|
|
1102
|
+
- Step 1: Use broad patterns like \`**/*.ts\` or \`src/**/*\` to get an overview
|
|
1103
|
+
- Step 2: Analyze results and refine with more specific patterns
|
|
1104
|
+
- Example: "\`**/*.test.ts\`" \u2192 too many results \u2192 "src/**/auth*.test.ts"
|
|
1105
|
+
- **Pattern Selection Guide**:
|
|
1106
|
+
- Unknown structure? Start with \`**/*.{ext}\` to discover layout, then use Read on specific directory paths for one-level structure
|
|
1107
|
+
- Looking for specific type? Use descriptive names: \`**/test*\`, \`**/config*\`
|
|
1108
|
+
- In a specific area? Combine path + pattern: \`src/auth/**/*.ts\`
|
|
1109
|
+
- **Discovery Workflow**: For unfamiliar codebases, run these in parallel:
|
|
1110
|
+
- \`**/package.json\`, \`**/*.{ts,js,tsx,jsx}\`, \`**/README*\`, \`**/*config*.{ts,js,json}\`
|
|
1111
|
+
- Analyze structure \u2192 refine search \u2192 read key files
|
|
1112
|
+
- **Tool Collaboration**:
|
|
1113
|
+
- Read \`directory_path\` \u2192 Get one-level directory tree structure
|
|
1114
|
+
- Grep \u2192 After Glob finds files, use Grep to search content
|
|
1115
|
+
- Read \u2192 Read the found file contents
|
|
1116
|
+
|
|
1117
|
+
## Usage Details
|
|
1118
|
+
- Supports glob patterns like "**/*.js" or "src/**/*.ts"
|
|
1119
|
+
- Returns absolute file paths sorted by modification time (most recent first)
|
|
1120
|
+
- Use this tool when you need to find files by name patterns
|
|
1121
|
+
- Powered by ripgrep with \`--files\` mode for fast pattern matching
|
|
1122
|
+
- \`path\` parameter: Specify the directory to search in. If omitted, uses the current working directory. IMPORTANT: Omit this field to use the default directory. DO NOT enter "undefined" or "null" - simply omit it for the default behavior. Supports both relative and absolute paths.
|
|
1123
|
+
- Results are limited to 100 files by default. If truncated, use a more specific path or pattern to narrow results.
|
|
1124
|
+
- Search ignores .gitignore rules and includes hidden files by default.
|
|
1125
|
+
- **Empty Results**: When no files are found, try broader patterns (e.g., src/**/*) or verify path exists.
|
|
1126
|
+
- **Error Handling**: Returns error if \`path\` does not exist or is not a valid directory.
|
|
1127
|
+
- **LSP Semantic Mode**: \`semantic: true\` enables workspace symbol fallback when file globbing returns empty.
|
|
1128
|
+
- **Semantic search is opt-in**: Only set \`semantic: true\` when you intentionally want LSP-assisted fallback.
|
|
1129
|
+
- Semantic output may include:
|
|
1130
|
+
- \`semanticNotice\`: human-readable semantic fallback note
|
|
1131
|
+
- \`semanticReason\`: structured reason code (e.g., \`SYMBOLS_ADDED\`, \`NO_SYMBOL_MATCH\`, \`LSP_UNAVAILABLE\`)
|
|
1132
|
+
- \`semanticSuggestion\`: suggested next action aligned to reason code
|
|
1133
|
+
- **Truncated Results**: When results are truncated (limited to 100 files), narrow down using:
|
|
1134
|
+
1. Add a more specific path: \`src/core/**/*.ts\` instead of \`**/*.ts\`
|
|
1135
|
+
2. Use file extension filter: \`src/**/*.test.ts\` instead of \`src/**/*.ts\`
|
|
1136
|
+
3. Use Read on a specific directory path to confirm one-level structure, then target specific directories with Glob
|
|
1137
|
+
|
|
1138
|
+
## Typical Usage Examples
|
|
1139
|
+
|
|
1140
|
+
### Example 1: Project Structure Discovery (Unknown Codebase)
|
|
1141
|
+
<example>
|
|
1142
|
+
user: I'm new to this project, what's the structure?
|
|
1143
|
+
assistant: [uses Glob tool with pattern="**/package.json" to find project roots]
|
|
1144
|
+
[reads the confirmed source directory path to inspect one-level tree structure]
|
|
1145
|
+
[uses Glob tool with pattern="**/*.{ts,tsx,js,jsx}" to locate major source areas]
|
|
1146
|
+
</example>
|
|
1147
|
+
|
|
1148
|
+
### Example 2: Find Files by Type in Specific Area
|
|
1149
|
+
<example>
|
|
1150
|
+
user: Find all test files in the auth module
|
|
1151
|
+
assistant: [uses Glob tool with pattern="src/auth/**/*.test.ts"]
|
|
1152
|
+
[uses Read tool to examine specific test files]
|
|
1153
|
+
</example>
|
|
1154
|
+
|
|
1155
|
+
### Example 3: Config File Location (Deterministic)
|
|
1156
|
+
<example>
|
|
1157
|
+
user: Where is the webpack configuration?
|
|
1158
|
+
assistant: [uses Glob tool with pattern="**/webpack*.{js,ts,json}"]
|
|
1159
|
+
[uses Read tool on the matched config file]
|
|
1160
|
+
</example>
|
|
1161
|
+
|
|
1162
|
+
### Example 4: Parallel Discovery for Entry Points
|
|
1163
|
+
<example>
|
|
1164
|
+
user: What are the main entry points of this application?
|
|
1165
|
+
assistant: [uses Glob tool with pattern="**/index.{ts,js}"]
|
|
1166
|
+
[uses Glob tool with pattern="**/main.{ts,js}"]
|
|
1167
|
+
[uses Glob tool with pattern="**/app.{ts,js}"]
|
|
1168
|
+
[uses Read tool to examine the entry point files]
|
|
1169
|
+
</example>
|
|
1170
|
+
|
|
1171
|
+
### Example 5: Narrow Down After Broad Results
|
|
1172
|
+
<example>
|
|
1173
|
+
user: Find all TypeScript files in the project
|
|
1174
|
+
assistant: [uses Glob tool with pattern="**/*.ts" - returns 500+ files, truncated]
|
|
1175
|
+
[uses Glob tool with pattern="src/**/*.ts" to focus on source code]
|
|
1176
|
+
[uses Glob tool with pattern="src/core/**/*.ts" to narrow further if needed]
|
|
1177
|
+
</example>
|
|
1178
|
+
|
|
1179
|
+
### Example 6: Semantic Fallback for Unknown File Path
|
|
1180
|
+
<example>
|
|
1181
|
+
user: Find where AuthService is implemented, I do not know the file name
|
|
1182
|
+
assistant: [uses Glob tool with pattern="**/*AuthService*" semantic=false first]
|
|
1183
|
+
[if no files found, retries with semantic=true]
|
|
1184
|
+
[reads semanticReason and semanticSuggestion to decide next step]
|
|
1185
|
+
<reasoning>
|
|
1186
|
+
The assistant switches to semantic mode because:
|
|
1187
|
+
1. Filename-based glob failed and user intent is symbol-oriented
|
|
1188
|
+
2. semantic=true allows LSP workspace symbols to recover likely file paths
|
|
1189
|
+
3. semanticReason + semanticSuggestion provide explicit fallback diagnostics
|
|
1190
|
+
</reasoning>
|
|
1191
|
+
</example>
|
|
1192
|
+
`.trim();
|
|
1193
|
+
|
|
1194
|
+
// src/tools/search/GrepTool/prompt.ts
|
|
1195
|
+
var TOOL_NAME6 = "Grep";
|
|
1196
|
+
var DESCRIPTION6 = `A powerful fast content search tool that works with any codebase size
|
|
1197
|
+
|
|
1198
|
+
## Best Practice
|
|
1199
|
+
- Use Grep as a "Scout" to *find* entry points based on text patterns.
|
|
1200
|
+
- STEP 1: Search for a unique string (e.g., error message, URL route, specific variable name).
|
|
1201
|
+
- STEP 2: Once you get a match (File + Line Number), STOP grepping.
|
|
1202
|
+
- STEP 3: Use Read to get the exact line + character, then call LspTool for definition or references.
|
|
1203
|
+
- AVOID: Do not use Grep to trace execution flow (e.g., searching for "functionName" manually). Use LSP for that.
|
|
1204
|
+
- Hotspot strategy: narrow the path scope first, then paginate or refine the search; after truncation, focus on high-signal directories to avoid full-repo scans.
|
|
1205
|
+
|
|
1206
|
+
## Search Strategy
|
|
1207
|
+
- **Pattern Refinement Workflow**:
|
|
1208
|
+
- Start broad: simple keyword first, observe results
|
|
1209
|
+
- Narrow down: add constraints (type, glob, path) if too many matches
|
|
1210
|
+
- Switch mode: \`files_with_matches\` for discovery, \`content\` for details
|
|
1211
|
+
- **From Vague Intent to Precise Pattern**:
|
|
1212
|
+
- "How does auth work?" \u2192 Start with Grep("auth", type="ts") \u2192 Analyze results \u2192 Refine pattern
|
|
1213
|
+
- "Find the API endpoints" \u2192 Grep("router|route|endpoint", type="ts") \u2192 Read key files
|
|
1214
|
+
- "Where is this error from?" \u2192 Grep(exact error message) \u2192 Trace back to source
|
|
1215
|
+
- **Iterative Narrowing**:
|
|
1216
|
+
- Too many results? Add \`glob\`, \`type\`, or narrower \`path\`
|
|
1217
|
+
- No results? Broaden pattern, try case-insensitive (\`-i\`), or try alternative keywords
|
|
1218
|
+
- Wrong results? Adjust pattern, check regex syntax, try alternative keywords
|
|
1219
|
+
- **Tool Collaboration**:
|
|
1220
|
+
- Read "directory_path" \u2192 Confirm one-level directory structure for search scope
|
|
1221
|
+
- Glob "file_path" \u2192 Confirm file path existence
|
|
1222
|
+
- Read \u2192 Read specific content of matched files
|
|
1223
|
+
- LspTool \u2192 Trace definitions and references (replace manual Grep tracing)
|
|
1224
|
+
|
|
1225
|
+
## Usage Details
|
|
1226
|
+
- ALWAYS use Grep for search tasks. NEVER invoke \`grep\` or \`rg\` as a Bash command. The Grep tool has been optimized for correct permissions and access.
|
|
1227
|
+
- Powered by ripgrep for fast text search with full regex support (e.g., "log.*Error", "function\\s+\\w+")
|
|
1228
|
+
- Pattern syntax: Uses ripgrep - literal braces need escaping (use \`interface\\{\\}\` to find \`interface{}\` in Go code)
|
|
1229
|
+
- Excludes version control directories (.git, .svn, .hg, .bzr) automatically
|
|
1230
|
+
- Includes hidden files by default
|
|
1231
|
+
|
|
1232
|
+
**Path & Scope**:
|
|
1233
|
+
- \`path\` parameter: File or directory to search in. Defaults to current working directory.
|
|
1234
|
+
- \`glob\` parameter: Filter files by glob pattern (e.g., "*.js", "*.{ts,tsx}") - maps to rg --glob
|
|
1235
|
+
- \`type\` parameter: Filter by file type (e.g., "js", "py", "rust", "go", "java") - more efficient than glob for standard types
|
|
1236
|
+
- Path guidance: If user provides a path, use it directly. If uncertain, confirm with Glob first.
|
|
1237
|
+
|
|
1238
|
+
**Output Modes**:
|
|
1239
|
+
- \`files_with_matches\` (default): Returns file paths sorted by modification time
|
|
1240
|
+
- \`content\`: Shows matching lines with line numbers (supports -A/-B/-C context)
|
|
1241
|
+
- \`count\`: Shows match counts per file
|
|
1242
|
+
|
|
1243
|
+
**Context & Pagination**:
|
|
1244
|
+
- \`-B\`, \`-A\`, \`-C\`: Context lines before/after/around matches (requires output_mode: "content")
|
|
1245
|
+
- \`-n\`: Show line numbers (default: true, requires output_mode: "content")
|
|
1246
|
+
- \`head_limit\`: Limit output to first N entries (works across all modes)
|
|
1247
|
+
- \`offset\`: Skip first N entries before applying head_limit
|
|
1248
|
+
- \`multiline\`: Enable multiline mode where . matches newlines (default: false)
|
|
1249
|
+
|
|
1250
|
+
**Case Sensitivity**:
|
|
1251
|
+
- \`-i\`: Enable case-insensitive search
|
|
1252
|
+
|
|
1253
|
+
**Result Handling**:
|
|
1254
|
+
- Results are truncated at 20,000 characters if too large
|
|
1255
|
+
- Use Task tool for open-ended searches requiring multiple rounds
|
|
1256
|
+
- **Semantic Fallback** (\`semantic: true\`): when text grep has no hit (or \`symbol_type\` is provided), Grep can query LSP workspace symbols.
|
|
1257
|
+
- Semantic-enhanced outputs may include:
|
|
1258
|
+
- \`semanticNotice\`: fallback summary
|
|
1259
|
+
- \`semanticReason\`: structured reason code (e.g., \`SYMBOLS_ADDED\`, \`NO_SYMBOL_MATCH\`, \`LSP_UNAVAILABLE\`)
|
|
1260
|
+
- \`semanticSuggestion\`: suggested next action by reason code
|
|
1261
|
+
- Keep deterministic workflow: text search first, semantic fallback second.
|
|
1262
|
+
|
|
1263
|
+
**Typical Usage Examples**:
|
|
1264
|
+
|
|
1265
|
+
Example 1: Exact Error Message Tracing (Deterministic)
|
|
1266
|
+
<example>
|
|
1267
|
+
user: Where does the error "Connection timeout after 30s" come from?
|
|
1268
|
+
assistant: [uses Grep tool with pattern="Connection timeout after 30s"output_mode="content"]
|
|
1269
|
+
[uses Read tool to examine the error source and surrounding context]
|
|
1270
|
+
</example>
|
|
1271
|
+
|
|
1272
|
+
Example 2: Precise Function Definition Lookup (Deterministic)
|
|
1273
|
+
<example>
|
|
1274
|
+
user: Find the implementation of \`calculateCompoundInterest\` function
|
|
1275
|
+
assistant: [uses Grep tool with pattern="calculateCompoundInterest" type="ts"output_mode="content"]
|
|
1276
|
+
[uses Read tool on the matched file to read the full implementation]
|
|
1277
|
+
</example>
|
|
1278
|
+
|
|
1279
|
+
Example 3: Iterative Narrowing for Broad Patterns
|
|
1280
|
+
<example>
|
|
1281
|
+
user: Find all API route definitions
|
|
1282
|
+
assistant: [uses Grep tool with pattern="router\\.(get|post|put|delete)" type="ts"]
|
|
1283
|
+
[if too many results: adds path="src/routes" to narrow scope]
|
|
1284
|
+
[uses Read tool to inspect specific route handlers]
|
|
1285
|
+
</example>
|
|
1286
|
+
|
|
1287
|
+
Example 4: Handoff to LSP After Entry Point Found
|
|
1288
|
+
<example>
|
|
1289
|
+
user: Find all usages of the \`PaymentService\` class
|
|
1290
|
+
assistant: [uses Grep tool with pattern="class PaymentService" type="ts"output_mode="content"]
|
|
1291
|
+
[uses LSP findReferences at the class definition location to get all references]
|
|
1292
|
+
</example>
|
|
1293
|
+
|
|
1294
|
+
Example 5: Case-Insensitive Search for Config Values
|
|
1295
|
+
<example>
|
|
1296
|
+
user: Where is the database host configured?
|
|
1297
|
+
assistant: [uses Grep tool with pattern="database.*host|db_host|DB_HOST" -i: true]
|
|
1298
|
+
[uses Read tool to examine configuration files]
|
|
1299
|
+
</example>
|
|
1300
|
+
|
|
1301
|
+
Example 6: Semantic Fallback with Structured Reason
|
|
1302
|
+
<example>
|
|
1303
|
+
user: Find usages of PaymentSrvce (name might be misspelled)
|
|
1304
|
+
assistant: [uses Grep tool with pattern="PaymentSrvce" output_mode="files_with_matches"]
|
|
1305
|
+
[if no hit, retries with semantic=true]
|
|
1306
|
+
[uses semanticReason and semanticSuggestion to decide whether to broaden query or switch to LspTool]
|
|
1307
|
+
<reasoning>
|
|
1308
|
+
The assistant uses semantic fallback because:
|
|
1309
|
+
1. Text grep may miss typo-tolerant symbol matches
|
|
1310
|
+
2. LSP workspace symbols can recover intended semantic targets
|
|
1311
|
+
3. Structured reason fields make fallback outcomes explicit and actionable
|
|
1312
|
+
</reasoning>
|
|
1313
|
+
</example>
|
|
1314
|
+
`.trim();
|
|
1315
|
+
|
|
1316
|
+
// src/tools/search/LspTool/prompt.ts
|
|
1317
|
+
var TOOL_NAME7 = "LSP";
|
|
1318
|
+
var PROMPT4 = `Interact with Language Server Protocol (LSP) servers to get code intelligence features.Supports all languages.
|
|
1319
|
+
|
|
1320
|
+
## Capabilities & Scenarios
|
|
1321
|
+
This tool acts as your "Code Analyst". Use it to understand the codebase semantically, rather than just matching text.
|
|
1322
|
+
|
|
1323
|
+
### 1. Tracing Logic (Where does this go?)
|
|
1324
|
+
- **Scenario**: You see a function call \`calculateTax(amount)\` and need to know its formula.
|
|
1325
|
+
- **Action**: Use \`goToDefinition\` on the function name.
|
|
1326
|
+
- **Why**: It jumps directly to the implementation, even if it's imported from another file.
|
|
1327
|
+
|
|
1328
|
+
### 2. Impact Analysis (What uses this?)
|
|
1329
|
+
- **Scenario**: You are planning to rename or modify the \`User\` class.
|
|
1330
|
+
- **Action**: Use \`findReferences\` at the symbol position (line + character) in the file where \`User\` is declared or used.
|
|
1331
|
+
- **Why**: It lists every file and line where \`User\` is referenced, ensuring you don't break dependents.
|
|
1332
|
+
|
|
1333
|
+
### 3. Exploring New Files (What's in here?)
|
|
1334
|
+
- **Scenario**: You just opened a large file \`utils.ts\` and want a quick overview.
|
|
1335
|
+
- **Action**: Use \`documentSymbol\`.
|
|
1336
|
+
- **Why**: It returns a structured outline (Classes, Functions, Variables) using LspFacade policy: LSP-first for accuracy, Tree-Sitter fallback for speed when needed.
|
|
1337
|
+
|
|
1338
|
+
### 4. Interface Implementation (Who implements this?)
|
|
1339
|
+
- **Scenario**: You see an interface \`IStorage\` and want to find the concrete class (e.g., \`S3Storage\`).
|
|
1340
|
+
- **Action**: Use \`goToImplementation\`.
|
|
1341
|
+
- **Why**: Grep might just find the import; LSP finds the actual code that implements the interface.
|
|
1342
|
+
|
|
1343
|
+
### 5. Scope Analysis (What is visible here?)
|
|
1344
|
+
- **Scenario**: You are debugging a closure or nested function and want to know which variables are captured or locally defined.
|
|
1345
|
+
- **Action**: Use \`getScope\`.
|
|
1346
|
+
- **Why**: It returns the local variables and closure captures at the current position. Essential for debugging Python closures or JavaScript lexical scopes.
|
|
1347
|
+
|
|
1348
|
+
### 6. Real-time Diagnostics (Is this correct?)
|
|
1349
|
+
- **Scenario**: You just edited a file and want to verify if you introduced any syntax errors.
|
|
1350
|
+
- **Action**: Use \`diagnostics\` with \`waitForDiagnostics: true\`.
|
|
1351
|
+
- **Why**: It waits for the language server to re-analyze the file and returns fresh errors/warnings. This is your "Self-Correction" mechanism.
|
|
1352
|
+
|
|
1353
|
+
### 7. Workspace Symbol Search (Where is this symbol?)
|
|
1354
|
+
- **Scenario**: You need to find a class or function across the entire project.
|
|
1355
|
+
- **Action**: Use \`workspaceSymbol\` with a query string and a scoped filePath (module or directory).
|
|
1356
|
+
- **Why**: It searches across all files in the scope. **Important**: Must provide a scoped path to avoid unbounded full-repo queries.
|
|
1357
|
+
|
|
1358
|
+
## Supported Operations
|
|
1359
|
+
|
|
1360
|
+
### Location-Based Operations (require line + character)
|
|
1361
|
+
These 8 operations require precise symbol position:
|
|
1362
|
+
- \`goToDefinition\`: Find where a symbol is defined
|
|
1363
|
+
- \`findReferences\`: Find all references to a symbol
|
|
1364
|
+
- \`hover\`: Get hover information (documentation, type info) for a symbol
|
|
1365
|
+
- \`goToImplementation\`: Find implementations of an interface or abstract method
|
|
1366
|
+
- \`prepareCallHierarchy\`: Get call hierarchy item at a position (functions/methods)
|
|
1367
|
+
- \`incomingCalls\`: Find all functions/methods that call the function at a position
|
|
1368
|
+
- \`outgoingCalls\`: Find all functions/methods called by the function at a position
|
|
1369
|
+
- \`getScope\`: Get local variables and closure captures at a position
|
|
1370
|
+
|
|
1371
|
+
### Document-Level Operations (no position required)
|
|
1372
|
+
- \`documentSymbol\`: Get all symbols (functions, classes, variables) in a document
|
|
1373
|
+
- \`diagnostics\`: Get validation errors and warnings for a file (supports waiting for fresh results)
|
|
1374
|
+
|
|
1375
|
+
### Workspace-Level Operations
|
|
1376
|
+
- \`workspaceSymbol\`: Search for symbols across the entire workspace (requires query + scoped filePath)
|
|
1377
|
+
|
|
1378
|
+
## Parameters
|
|
1379
|
+
|
|
1380
|
+
All operations require:
|
|
1381
|
+
- \`filePath\`: The file or directory to operate on
|
|
1382
|
+
|
|
1383
|
+
Location-based operations require:
|
|
1384
|
+
- \`line\`: The line number (1-based, as shown in editors)
|
|
1385
|
+
- \`character\`: The character offset (1-based, as shown in editors)
|
|
1386
|
+
|
|
1387
|
+
\`workspaceSymbol\` requires:
|
|
1388
|
+
- \`query\`: The symbol name or keyword to search for
|
|
1389
|
+
|
|
1390
|
+
Optional:
|
|
1391
|
+
- \`waitForDiagnostics\`: If true, wait for fresh diagnostics (used with "diagnostics" operation)
|
|
1392
|
+
- \`timeout\`: Timeout in milliseconds for waiting operations (default: 5000)
|
|
1393
|
+
|
|
1394
|
+
## Intelligent Position Handling
|
|
1395
|
+
|
|
1396
|
+
**Do not pass a symbol name.** LSPTool works on positions, not names. Use Read to locate the symbol and derive line + character first.
|
|
1397
|
+
|
|
1398
|
+
### Auto-Adjustment Mechanism
|
|
1399
|
+
If the specified position is not on a valid symbol, the tool automatically searches for the nearest valid token:
|
|
1400
|
+
- **Search scope**: Current line, then previous line, then next line
|
|
1401
|
+
- **Priority**: Current line tokens are preferred (lower score)
|
|
1402
|
+
- **Skipped tokens**: Keywords (function, class, if, for, return, etc.) and operators (=, =>, +, -, &&, ||, etc.) are automatically skipped
|
|
1403
|
+
- **If no valid token found**: Returns an error message
|
|
1404
|
+
|
|
1405
|
+
### Best Practice for Position
|
|
1406
|
+
1. Use Read to open the file and locate the symbol
|
|
1407
|
+
2. Provide accurate 1-based line and character offset
|
|
1408
|
+
3. Position should be on the symbol name itself, not on keywords/operators
|
|
1409
|
+
4. If unsure, position at the start of the symbol name
|
|
1410
|
+
|
|
1411
|
+
## Workflow & Scope Guidelines
|
|
1412
|
+
- **Priority order**: documentSymbol \u2192 hotspot detection \u2192 Read \u2192 LSP (ensure line + character)
|
|
1413
|
+
- **workspaceSymbol**: Must provide scoped filePath (module or directory), avoid unbounded full-repo queries
|
|
1414
|
+
- **documentSymbol**: Uses LspFacade policy (LSP-first for accuracy, Tree-Sitter fallback for speed)
|
|
1415
|
+
|
|
1416
|
+
## Typical Usage Examples
|
|
1417
|
+
### Example 1: Find Symbol Then Read Precise Block
|
|
1418
|
+
<example>
|
|
1419
|
+
user: Locate JWT validation implementation quickly
|
|
1420
|
+
assistant: [uses LSP workspaceSymbol with query="jwt validate" and scoped filePath]
|
|
1421
|
+
[uses Read on the discovered file and then LSP documentSymbol/definition as needed]
|
|
1422
|
+
<reasoning>
|
|
1423
|
+
The assistant starts semantically because:
|
|
1424
|
+
1. User asks for implementation location, not broad text grep
|
|
1425
|
+
2. workspaceSymbol narrows candidate files efficiently
|
|
1426
|
+
3. Read is then used for exact code extraction once target is known
|
|
1427
|
+
</reasoning>
|
|
1428
|
+
</example>
|
|
1429
|
+
|
|
1430
|
+
### Example 2: Diagnostics-First Debugging
|
|
1431
|
+
<example>
|
|
1432
|
+
user: Build failed in api package, tell me real code errors
|
|
1433
|
+
assistant: [uses LSP diagnostics with waitForDiagnostics=true on scoped filePath]
|
|
1434
|
+
[uses goToDefinition/findReferences for follow-up impact tracing]
|
|
1435
|
+
<reasoning>
|
|
1436
|
+
The assistant prioritizes diagnostics because:
|
|
1437
|
+
1. Diagnostics provide direct semantic errors from language tooling
|
|
1438
|
+
2. Scoped path avoids unbounded workspace queries
|
|
1439
|
+
3. Follow-up LSP ops can trace root-cause dependencies
|
|
1440
|
+
</reasoning>
|
|
1441
|
+
</example>
|
|
1442
|
+
|
|
1443
|
+
Note: LSP servers are automatically managed and installed for most languages. For system-level languages (like C++, Java), ensure the corresponding tools (clangd, jdtls) are in your PATH.`;
|
|
1444
|
+
var DESCRIPTION7 = PROMPT4;
|
|
1445
|
+
|
|
1446
|
+
// src/tools/agent/TaskTool/constants.ts
|
|
1447
|
+
var TOOL_NAME8 = "Task";
|
|
1448
|
+
|
|
909
1449
|
// src/tools/system/BashTool/prompt.ts
|
|
910
1450
|
var DEFAULT_TIMEOUT_MS = 12e4;
|
|
911
1451
|
var MAX_TIMEOUT_MS = 6e5;
|
|
@@ -913,14 +1453,7 @@ var MAX_OUTPUT_LENGTH = 3e4;
|
|
|
913
1453
|
var MAX_RENDERED_LINES = 5;
|
|
914
1454
|
var PROJECT_URL = "https://github.com/pyb-xc/pyb-ts";
|
|
915
1455
|
var DEFAULT_CO_AUTHOR = "PYB-XC";
|
|
916
|
-
var
|
|
917
|
-
var TOOL_NAME_GLOB = "Glob";
|
|
918
|
-
var TOOL_NAME_GREP = "Grep";
|
|
919
|
-
var TOOL_NAME_LSP = "Lsp";
|
|
920
|
-
var TOOL_NAME_READ = "Read";
|
|
921
|
-
var TOOL_NAME_EDIT = "Edit";
|
|
922
|
-
var TOOL_NAME_WRITE = "Write";
|
|
923
|
-
var TOOL_NAME_TASK = "Task";
|
|
1456
|
+
var TOOL_NAME9 = "Bash";
|
|
924
1457
|
function isExperimentalMcpCliEnabled() {
|
|
925
1458
|
const value = process.env.ENABLE_EXPERIMENTAL_MCP_CLI;
|
|
926
1459
|
if (!value) return false;
|
|
@@ -1012,7 +1545,7 @@ Git Safety Protocol:
|
|
|
1012
1545
|
- Before amending: ALWAYS check authorship (git log -1 --format='%an %ae')
|
|
1013
1546
|
- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
|
|
1014
1547
|
|
|
1015
|
-
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel, each using the ${
|
|
1548
|
+
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel, each using the ${TOOL_NAME9} tool:
|
|
1016
1549
|
- Run a git status command to see all untracked files.
|
|
1017
1550
|
- Run a git diff command to see both staged and unstaged changes that will be committed.
|
|
1018
1551
|
- Run a git log command to see recent commit messages, so that you can follow this repository's commit message style.
|
|
@@ -1034,7 +1567,7 @@ Git Safety Protocol:
|
|
|
1034
1567
|
|
|
1035
1568
|
Important notes:
|
|
1036
1569
|
- NEVER run additional commands to read or explore code, besides git bash commands
|
|
1037
|
-
- NEVER use the ${
|
|
1570
|
+
- NEVER use the ${TOOL_NAME4} or ${TOOL_NAME8} tools
|
|
1038
1571
|
- DO NOT push to the remote repository unless the user explicitly asks you to do so
|
|
1039
1572
|
- IMPORTANT: Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported.
|
|
1040
1573
|
- If there are no changes to commit (i.e., no untracked files and no modifications), do not create an empty commit
|
|
@@ -1053,7 +1586,7 @@ Use the gh command via the Bash tool for ALL GitHub-related tasks including work
|
|
|
1053
1586
|
|
|
1054
1587
|
IMPORTANT: When the user asks you to create a pull request, follow these steps carefully:
|
|
1055
1588
|
|
|
1056
|
-
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel
|
|
1589
|
+
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel using the ${TOOL_NAME9} tool, in order to understand the current state of the branch since it diverged from the main branch:
|
|
1057
1590
|
- Run a git status command to see all untracked files
|
|
1058
1591
|
- Run a git diff command to see both staged and unstaged changes that will be committed
|
|
1059
1592
|
- Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote
|
|
@@ -1077,7 +1610,7 @@ EOF
|
|
|
1077
1610
|
</example>
|
|
1078
1611
|
|
|
1079
1612
|
Important:
|
|
1080
|
-
- DO NOT use the ${
|
|
1613
|
+
- DO NOT use the ${TOOL_NAME4} or ${TOOL_NAME8} tools
|
|
1081
1614
|
- Return the PR URL when you're done, so the user can see it
|
|
1082
1615
|
|
|
1083
1616
|
# Other common operations
|
|
@@ -1092,7 +1625,7 @@ IMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO N
|
|
|
1092
1625
|
Before executing the command, please follow these steps:
|
|
1093
1626
|
|
|
1094
1627
|
1. Directory Verification:
|
|
1095
|
-
- If the command will create new directories or files, first use the ${
|
|
1628
|
+
- If the command will create new directories or files, first use the ${TOOL_NAME5} tool to verify the parent directory exists and is the correct location
|
|
1096
1629
|
- For example, before running "mkdir foo/bar", first check if "foo" exists
|
|
1097
1630
|
|
|
1098
1631
|
2. Command Execution:
|
|
@@ -1110,21 +1643,21 @@ Usage notes:
|
|
|
1110
1643
|
- You can specify an optional timeout in milliseconds (up to ${MAX_TIMEOUT_MS}ms / ${MAX_TIMEOUT_MS / 6e4} minutes). If not specified, commands will timeout after ${DEFAULT_TIMEOUT_MS}ms (${DEFAULT_TIMEOUT_MS / 6e4} minutes).
|
|
1111
1644
|
- It is very helpful if you write a clear, concise description of what this command does in 5-10 words.
|
|
1112
1645
|
- If the output exceeds ${MAX_OUTPUT_LENGTH} characters, output will be truncated before being returned to you.
|
|
1113
|
-
- You can use the \`run_in_background\` parameter to run the command in the background, which allows you to continue working while the command runs. You can monitor the output using the ${
|
|
1646
|
+
- You can use the \`run_in_background\` parameter to run the command in the background, which allows you to continue working while the command runs. You can monitor the output using the ${TOOL_NAME9} tool as it becomes available. You do not need to use '&' at the end of the command when using this parameter.
|
|
1114
1647
|
${sandboxPrompt}
|
|
1115
1648
|
- Avoid using Bash with the \`find\`, \`grep\`, \`cat\`, \`head\`, \`tail\`, \`sed\`, \`awk\`, \`echo\`, \`ls\`, \`dir\`, or \`tree\` commands, unless explicitly instructed or when these commands are truly necessary for the task. Instead, always prefer using the dedicated tools for these commands:
|
|
1116
|
-
- File search: Use ${
|
|
1117
|
-
- Directory structure and information: use ${
|
|
1118
|
-
- Content search: Use ${
|
|
1119
|
-
- Symbol navigation: Use ${
|
|
1120
|
-
- Read files: Use ${
|
|
1121
|
-
- Edit files: Use ${
|
|
1122
|
-
- Write files: Use ${
|
|
1649
|
+
- File search: Use ${TOOL_NAME5} (NOT find or ls)
|
|
1650
|
+
- Directory structure and information: use ${TOOL_NAME2} (NOT ls/dir/tree)
|
|
1651
|
+
- Content search: Use ${TOOL_NAME6} (NOT grep or rg)
|
|
1652
|
+
- Symbol navigation: Use ${TOOL_NAME7} (NOT ctags/gtags)
|
|
1653
|
+
- Read files: Use ${TOOL_NAME2} (NOT cat/head/tail)
|
|
1654
|
+
- Edit files: Use ${TOOL_NAME3} (NOT sed/awk)
|
|
1655
|
+
- Write files: Use ${TOOL_NAME4} (NOT echo >/cat <<EOF)
|
|
1123
1656
|
- Delete files: Use Delete (NOT rm/rmdir/del). Example: Delete({ file_paths: ["/path/to/file"] })
|
|
1124
1657
|
- Communication: Output text directly (NOT echo/printf)
|
|
1125
1658
|
- When issuing multiple commands:
|
|
1126
|
-
- If the commands are independent and can run in parallel, make multiple ${
|
|
1127
|
-
- If the commands depend on each other and must run sequentially, use a single ${
|
|
1659
|
+
- If the commands are independent and can run in parallel, make multiple ${TOOL_NAME9} tool calls in a single message. For example, if you need to run "git status" and "git diff", send a single message with two ${TOOL_NAME9} tool calls in parallel.
|
|
1660
|
+
- If the commands depend on each other and must run sequentially, use a single ${TOOL_NAME9} call with '&&' to chain them together (e.g., \`git add . && git commit -m "message" && git push\`). For instance, if one operation must complete before another starts (like mkdir before cp, Write before Bash for git operations, or git add before git commit), run these operations sequentially instead.
|
|
1128
1661
|
- Use ';' only when you need to run commands sequentially but don't care if earlier commands fail
|
|
1129
1662
|
- DO NOT use newlines to separate commands (newlines are ok in quoted strings)
|
|
1130
1663
|
- Try to maintain your current working directory throughout the session by using absolute paths and avoiding usage of \`cd\`. You may use \`cd\` if the User explicitly requests it.
|
|
@@ -1174,7 +1707,7 @@ var MCPTool = {
|
|
|
1174
1707
|
isConcurrencySafe() {
|
|
1175
1708
|
return false;
|
|
1176
1709
|
},
|
|
1177
|
-
name:
|
|
1710
|
+
name: TOOL_NAME,
|
|
1178
1711
|
async description() {
|
|
1179
1712
|
return DESCRIPTION;
|
|
1180
1713
|
},
|
|
@@ -1588,8 +2121,25 @@ export {
|
|
|
1588
2121
|
FallbackToolUseRejectedMessage,
|
|
1589
2122
|
loadMergedSettings,
|
|
1590
2123
|
normalizeSandboxRuntimeConfigFromSettings,
|
|
2124
|
+
TOOL_NAME2 as TOOL_NAME,
|
|
2125
|
+
DESCRIPTION2 as DESCRIPTION,
|
|
2126
|
+
PROMPT2 as PROMPT,
|
|
2127
|
+
TOOL_NAME3 as TOOL_NAME2,
|
|
2128
|
+
DESCRIPTION3 as DESCRIPTION2,
|
|
2129
|
+
TOOL_NAME4 as TOOL_NAME3,
|
|
2130
|
+
DESCRIPTION4 as DESCRIPTION3,
|
|
2131
|
+
PROMPT3 as PROMPT2,
|
|
2132
|
+
TOOL_NAME5 as TOOL_NAME4,
|
|
2133
|
+
DESCRIPTION5 as DESCRIPTION4,
|
|
2134
|
+
TOOL_NAME6 as TOOL_NAME5,
|
|
2135
|
+
DESCRIPTION6 as DESCRIPTION5,
|
|
2136
|
+
TOOL_NAME7 as TOOL_NAME6,
|
|
2137
|
+
PROMPT4 as PROMPT3,
|
|
2138
|
+
DESCRIPTION7 as DESCRIPTION6,
|
|
2139
|
+
TOOL_NAME8 as TOOL_NAME7,
|
|
1591
2140
|
DEFAULT_TIMEOUT_MS,
|
|
1592
2141
|
MAX_OUTPUT_LENGTH,
|
|
2142
|
+
TOOL_NAME9 as TOOL_NAME8,
|
|
1593
2143
|
getBashToolPrompt,
|
|
1594
2144
|
OutputLine,
|
|
1595
2145
|
listPluginMCPServers,
|