@astralyn/pi 1.0.4 → 1.1.0
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 +53 -0
- package/dist/bundle/chunks/{anthropic-messages-YIOJIMVL.js → anthropic-messages-3K3DWVY6.js} +1 -1
- package/dist/bundle/chunks/anthropic.js +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-LDW4FGAQ.js → azure-openai-responses-CH74HGP4.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +2 -2
- package/dist/bundle/chunks/{chunk-UCXU7KLO.js → chunk-3MMB5I7J.js} +1 -1
- package/dist/bundle/chunks/{chunk-GIG5IHES.js → chunk-5KJH3GGH.js} +1 -1
- package/dist/bundle/chunks/chunk-6VYRLG5F.js +2 -0
- package/dist/bundle/chunks/{chunk-73WG7F7N.js → chunk-C2ARIVS3.js} +1 -1
- package/dist/bundle/chunks/{chunk-23OTKHCH.js → chunk-D3XW5X3Z.js} +490 -260
- package/dist/bundle/chunks/{chunk-IFELM7MW.js → chunk-EJEOEBSJ.js} +1 -1
- package/dist/bundle/chunks/chunk-H35KWBT5.js +11 -0
- package/dist/bundle/chunks/chunk-KAC2YPTW.js +2 -0
- package/dist/bundle/chunks/chunk-MAC4N3BW.js +2 -0
- package/dist/bundle/chunks/chunk-QLU3LESZ.js +2 -0
- package/dist/bundle/chunks/{chunk-A6ALEEY5.js → chunk-TEAAYBTS.js} +1 -1
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-XO45ZT3V.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +101 -5
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/{google-generative-ai-S5A5IBU4.js → google-generative-ai-VVO64ZRQ.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-UBRQFDB4.js → google-vertex-LKS5NUHA.js} +1 -1
- package/dist/bundle/chunks/image-resize-worker.js +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-R7DQLTQN.js → llama-cpp-classify-H3IZDR5O.js} +2 -2
- package/dist/bundle/chunks/{mistral-conversations-A2N5FSOV.js → mistral-conversations-NJUOG4ET.js} +2 -2
- package/dist/bundle/chunks/openai-chatgpt.js +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-Q6JHCWLE.js → openai-codex-responses-TZWBTTYM.js} +2 -2
- package/dist/bundle/chunks/openai-codex.js +1 -1
- package/dist/bundle/chunks/{openai-completions-H4VMO7AU.js → openai-completions-7HTTU6FH.js} +1 -1
- package/dist/bundle/chunks/openai-decisions-776H4VDZ.js +5 -0
- package/dist/bundle/chunks/{openai-responses-G4PGNM2H.js → openai-responses-7A6BAQ5X.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-YP3YVB54.js → openrouter-images-TDLJV5N4.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-HZZ7GEEW.js → pi-messages-ZXNERWJG.js} +1 -1
- package/dist/bundle/chunks/typesafe-system-one-2DQLG4R2.js +2 -0
- package/dist/bundle/chunks/{virtual-modules-IJTAY26N.js → virtual-modules-2NHGQRS6.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts +2 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +24 -5
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session.d.ts +38 -10
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +190 -186
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +40 -45
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/context-snapshot.d.ts +4 -1
- package/dist/core/context-snapshot.d.ts.map +1 -1
- package/dist/core/context-snapshot.js +45 -0
- package/dist/core/context-snapshot.js.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +2 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/types.d.ts +13 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +8 -0
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +30 -7
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +2 -1
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +1 -0
- package/dist/core/nested-tool-calls.d.ts.map +1 -1
- package/dist/core/nested-tool-calls.js +1 -0
- package/dist/core/nested-tool-calls.js.map +1 -1
- package/dist/core/resource-loader.d.ts +3 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +3 -3
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +13 -4
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +19 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +13 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +37 -13
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +4 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +6 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +9 -4
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/session.d.ts +9 -0
- package/dist/core/tasks/session.d.ts.map +1 -1
- package/dist/core/tasks/session.js +21 -0
- package/dist/core/tasks/session.js.map +1 -1
- package/dist/core/tools/read.d.ts +13 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +18 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +8 -3
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/renderers/edit.js +1 -1
- package/dist/core/tools/renderers/edit.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +65 -8
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +1 -0
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +9 -2
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +14 -6
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/index.js +2 -2
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +34 -11
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/mcp/cli.js +17 -23
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +165 -64
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/oauth.d.ts +5 -3
- package/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/dist/extensions/mcp/oauth.js +36 -10
- package/dist/extensions/mcp/oauth.js.map +1 -1
- package/dist/extensions/mcp/resources.d.ts +3 -4
- package/dist/extensions/mcp/resources.d.ts.map +1 -1
- package/dist/extensions/mcp/resources.js +3 -4
- package/dist/extensions/mcp/resources.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +4 -1
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +22 -5
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts +2 -1
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +2 -1
- package/dist/extensions/mcp/tools.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts +3 -3
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +10 -2
- package/dist/extensions/mcp/ui.js.map +1 -1
- package/dist/extensions/search/code-search.d.ts +29 -0
- package/dist/extensions/search/code-search.d.ts.map +1 -0
- package/dist/extensions/search/code-search.js +120 -0
- package/dist/extensions/search/code-search.js.map +1 -0
- package/dist/extensions/search/command.d.ts +5 -0
- package/dist/extensions/search/command.d.ts.map +1 -0
- package/dist/extensions/search/command.js +69 -0
- package/dist/extensions/search/command.js.map +1 -0
- package/dist/extensions/search/credential.d.ts +25 -0
- package/dist/extensions/search/credential.d.ts.map +1 -0
- package/dist/extensions/search/credential.js +117 -0
- package/dist/extensions/search/credential.js.map +1 -0
- package/dist/extensions/search/devin.d.ts +34 -0
- package/dist/extensions/search/devin.d.ts.map +1 -0
- package/dist/extensions/search/devin.js +210 -0
- package/dist/extensions/search/devin.js.map +1 -0
- package/dist/extensions/search/index.d.ts +5 -0
- package/dist/extensions/search/index.d.ts.map +1 -0
- package/dist/extensions/search/index.js +110 -0
- package/dist/extensions/search/index.js.map +1 -0
- package/dist/extensions/search/panel.d.ts +53 -0
- package/dist/extensions/search/panel.d.ts.map +1 -0
- package/dist/extensions/search/panel.js +157 -0
- package/dist/extensions/search/panel.js.map +1 -0
- package/dist/extensions/search/prompt.d.ts +14 -0
- package/dist/extensions/search/prompt.d.ts.map +1 -0
- package/dist/extensions/search/prompt.js +221 -0
- package/dist/extensions/search/prompt.js.map +1 -0
- package/dist/extensions/search/render.d.ts +28 -0
- package/dist/extensions/search/render.d.ts.map +1 -0
- package/dist/extensions/search/render.js +86 -0
- package/dist/extensions/search/render.js.map +1 -0
- package/dist/extensions/search/workspace.d.ts +38 -0
- package/dist/extensions/search/workspace.d.ts.map +1 -0
- package/dist/extensions/search/workspace.js +245 -0
- package/dist/extensions/search/workspace.js.map +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +5 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +14 -14
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +5 -2
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +2 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +5 -2
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +3 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +7 -2
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +5 -2
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +52 -59
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/program-status-reporter.d.ts +34 -0
- package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -0
- package/dist/modes/interactive/program-status-reporter.js +107 -0
- package/dist/modes/interactive/program-status-reporter.js.map +1 -0
- package/dist/modes/interactive/tasks/host-hooks.d.ts +14 -0
- package/dist/modes/interactive/tasks/host-hooks.d.ts.map +1 -0
- package/dist/modes/interactive/tasks/host-hooks.js +31 -0
- package/dist/modes/interactive/tasks/host-hooks.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tool-view/tool-execution.d.ts +5 -0
- package/dist/modes/interactive/tool-view/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/tool-view/tool-execution.js +7 -0
- package/dist/modes/interactive/tool-view/tool-execution.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +24 -0
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/ansi.d.ts +8 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +30 -11
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +12 -11
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts +12 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +5 -0
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/image-resize-worker.js +3 -2
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +9 -10
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +6 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/docs/bundled/README.md +1 -1
- package/docs/bundled/extensions/provider.md +1 -1
- package/docs/bundled/extensions/question.md +1 -1
- package/docs/bundled/extensions/search.md +50 -0
- package/docs/bundled/extensions/statusline.md +15 -41
- package/docs/codemode.md +26 -5
- package/docs/docs.json +0 -4
- package/docs/environment-variables.md +1 -0
- package/docs/extensions.md +6 -2
- package/docs/json.md +2 -2
- package/docs/llama-cpp.md +8 -1
- package/docs/mcp.md +3 -1
- package/docs/models.md +4 -1
- package/docs/providers.md +17 -0
- package/docs/rpc.md +6 -3
- package/docs/session-format.md +1 -0
- package/docs/settings.md +4 -4
- package/docs/terminal-setup.md +14 -0
- package/docs/usage.md +19 -5
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +54 -54
- package/package.json +13 -11
- package/dist/bundle/chunks/chunk-57XI7YJH.js +0 -2
- package/dist/bundle/chunks/chunk-JI4WGISU.js +0 -2
- package/dist/bundle/chunks/chunk-TCQ4HHQD.js +0 -2
- package/dist/bundle/chunks/chunk-TXJO4AJ7.js +0 -11
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-OWU5SM6J.js +0 -2
- package/dist/bundle/chunks/typesafe-system-one-KYKKNU3E.js +0 -2
- package/dist/extensions/web-search/auth.d.ts +0 -12
- package/dist/extensions/web-search/auth.d.ts.map +0 -1
- package/dist/extensions/web-search/auth.js +0 -90
- package/dist/extensions/web-search/auth.js.map +0 -1
- package/dist/extensions/web-search/constants.d.ts +0 -13
- package/dist/extensions/web-search/constants.d.ts.map +0 -1
- package/dist/extensions/web-search/constants.js +0 -26
- package/dist/extensions/web-search/constants.js.map +0 -1
- package/dist/extensions/web-search/execute.d.ts +0 -9
- package/dist/extensions/web-search/execute.d.ts.map +0 -1
- package/dist/extensions/web-search/execute.js +0 -96
- package/dist/extensions/web-search/execute.js.map +0 -1
- package/dist/extensions/web-search/format.d.ts +0 -21
- package/dist/extensions/web-search/format.d.ts.map +0 -1
- package/dist/extensions/web-search/format.js +0 -117
- package/dist/extensions/web-search/format.js.map +0 -1
- package/dist/extensions/web-search/index.d.ts +0 -6
- package/dist/extensions/web-search/index.d.ts.map +0 -1
- package/dist/extensions/web-search/index.js +0 -50
- package/dist/extensions/web-search/index.js.map +0 -1
- package/dist/extensions/web-search/providers/deepseek.d.ts +0 -13
- package/dist/extensions/web-search/providers/deepseek.d.ts.map +0 -1
- package/dist/extensions/web-search/providers/deepseek.js +0 -110
- package/dist/extensions/web-search/providers/deepseek.js.map +0 -1
- package/dist/extensions/web-search/providers/http.d.ts +0 -4
- package/dist/extensions/web-search/providers/http.d.ts.map +0 -1
- package/dist/extensions/web-search/providers/http.js +0 -42
- package/dist/extensions/web-search/providers/http.js.map +0 -1
- package/dist/extensions/web-search/providers/minimax.d.ts +0 -12
- package/dist/extensions/web-search/providers/minimax.d.ts.map +0 -1
- package/dist/extensions/web-search/providers/minimax.js +0 -61
- package/dist/extensions/web-search/providers/minimax.js.map +0 -1
- package/dist/extensions/web-search/render.d.ts +0 -15
- package/dist/extensions/web-search/render.d.ts.map +0 -1
- package/dist/extensions/web-search/render.js +0 -142
- package/dist/extensions/web-search/render.js.map +0 -1
- package/dist/extensions/web-search/results.d.ts +0 -35
- package/dist/extensions/web-search/results.d.ts.map +0 -1
- package/dist/extensions/web-search/results.js +0 -167
- package/dist/extensions/web-search/results.js.map +0 -1
- package/dist/extensions/web-search/schema.d.ts +0 -10
- package/dist/extensions/web-search/schema.d.ts.map +0 -1
- package/dist/extensions/web-search/schema.js +0 -36
- package/dist/extensions/web-search/schema.js.map +0 -1
- package/dist/extensions/web-search/types.d.ts +0 -51
- package/dist/extensions/web-search/types.d.ts.map +0 -1
- package/dist/extensions/web-search/types.js +0 -5
- package/dist/extensions/web-search/types.js.map +0 -1
- package/docs/bundled/extensions/web-search.md +0 -46
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Planning rounds before the final answer is forced, commands per round, and files per answer. */
|
|
2
|
+
export declare const MAX_TURNS = 3;
|
|
3
|
+
export declare const MAX_COMMANDS = 8;
|
|
4
|
+
export declare const MAX_RESULTS = 10;
|
|
5
|
+
/**
|
|
6
|
+
* The SWE-grep planner prompt, kept close to the Windsurf original the backend model was tuned on.
|
|
7
|
+
* The budgets it states are the ones code-search.ts enforces.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SYSTEM_PROMPT = "You are an expert software engineer, responsible for providing context to another engineer to solve a code issue in the current codebase. The user will present you with a description of the issue, and it is your job to provide a series of file paths with associated line ranges that contain ALL the information relevant to understand and correctly address the issue.\n\n# IMPORTANT:\n- A relevant file does not mean only the files that must be modified to solve the task. It means any file that contains information relevant to planning and implementing the fix, such as the definitions of classes and functions that are relevant to the pieces of code that will have to be modified.\n- You should include enough context around the relevant lines to allow the engineer to understand the task correctly. You must include ENTIRE semantic blocks (functions, classes, definitions, etc). For example:\nIf addressing the issue requires modifying a method within a class, then you should include the entire class definition, not just the lines around the method we want to modify.\n- NEVER truncate these blocks unless they are very large (hundreds of lines or more, in which case providing only a relevant portion of the block is acceptable).\n- Your job is to essentially alleviate the job of the other engineer by giving them a clean starting context from which to start working. More precisely, you should minimize the number of files the engineer has to read to understand and solve the task correctly (while not providing irrelevant code snippets).\n\n# ENVIRONMENT\n- Working directory: /codebase. Make sure to run commands in this directory, not `.\n- Tool access: use the restricted_exec tool ONLY\n- Allowed sub-commands (schema-enforced):\n - rg: Search for patterns in files using ripgrep\n - Required: pattern (string), path (string)\n - Optional: include (array of globs), exclude (array of globs)\n - readfile: Read contents of a file with optional line range\n - Required: file (string)\n - Optional: start_line (int), end_line (int) \u2014 1-indexed, inclusive\n - tree: Display directory structure as a tree\n - Required: path (string)\n - Optional: levels (int)\n\n# THINKING RULES\n- Think step-by-step. Plan, reason, and reflect before each tool call.\n- Use tool calls liberally and purposefully to ground every conclusion in real code, not assumptions.\n- If a command fails, rethink and try something different; do not complain to the user.\n\n# FAST-SEARCH DEFAULTS (optimize rg/tree on large repos)\n- Start NARROW, then widen only if needed. Prefer searching likely code roots first (e.g., `src/`, `lib/`, `app/`, `packages/`, `services/`) instead of `/codebase`.\n- Prefer fixed-string search for literals: escape patterns or keep regex simple. Use smart case; avoid case-insensitive unless necessary.\n- Prefer file-type filters and globs (in include) over full-repo scans.\n- Default EXCLUDES for speed (apply via the exclude array): node_modules, .git, dist, build, coverage, .venv, venv, target, out, .cache, __pycache__, vendor, deps, third_party, logs, data, *.min.*\n- Skip huge files where possible; when opening files, prefer reading only relevant ranges with readfile.\n- Limit directory traversal with tree levels to quickly orient before deeper inspection.\n\n# SOME EXAMPLES OF WORKFLOWS\n- MAP \u2013 Use `tree` with small levels; `rg` on likely roots to grasp structure and hotspots.\n- ANCHOR \u2013 `rg` for problem keywords and anchor symbols; restrict by language globs via include.\n- TRACE \u2013 Follow imports with targeted `rg` in narrowed roots; open files with `readfile` scoped to entire semantic blocks.\n- VERIFY \u2013 Confirm each candidate path exists by reading or additional searches; drop false positives (tests, vendored, generated) unless they must change.\n\n# TOOL USE GUIDELINES\n- You must use a SINGLE restricted_exec call in your answer, that lets you execute at most 8 commands in a single turn. Each command must be an object with a `type` field of `rg`, `readfile`, or `tree` and the appropriate fields for that type.\n- Example restricted_exec usage:\n[TOOL_CALLS]restricted_exec[ARGS]{\n \"command1\": {\n \"type\": \"rg\",\n \"pattern\": \"Controller\",\n \"path\": \"/codebase/slime\",\n \"include\": [\"**/*.py\"],\n \"exclude\": [\"**/node_modules/**\", \"**/.git/**\", \"**/dist/**\", \"**/build/**\", \"**/.venv/**\", \"**/__pycache__/**\"]\n },\n \"command2\": {\n \"type\": \"readfile\",\n \"file\": \"/codebase/slime/train.py\",\n \"start_line\": 1,\n \"end_line\": 200\n },\n \"command3\": {\n \"type\": \"tree\",\n \"path\": \"/codebase/slime/\",\n \"levels\": 2\n }\n}\n- You have at most 3 turns to interact with the environment by calling tools, so issuing multiple commands at once is necessary and encouraged to speed up your research.\n- Each command result may be truncated to 40 lines; prefer multiple targeted reads/searches to build complete context.\n- DO NOT EVER USE MORE THAN 8 commands in a single turn, or you will be penalized.\n\n# ANSWER FORMAT (strict format, including tags)\n- You will output an XML structure with a root element \"ANSWER\" containing \"file\" elements. Each \"file\" element will have a \"path\" attribute and contain \"range\" elements.\n- You will output this as your final response.\n- The line ranges must be inclusive.\n\nOutput example inside the \"answer\" tool argument:\n<ANSWER>\n <file path=\"/codebase/info_theory/formulas/entropy.py\">\n <range>10-60</range>\n <range>150-210</range>\n </file>\n <file path=\"/codebase/info_theory/data_structures/bits.py\">\n <range>1-40</range>\n <range>110-170</range>\n </file>\n</ANSWER>\n\nRemember: Prefer narrow, fixed-string, and type-filtered searches with aggressive excludes and size/depth limits. Widen scope only as needed. Use the restricted tools available to you, and output your answer in exactly the specified format.\n\n# NO RESULTS POLICY\nIf after thorough searching you are confident that NO relevant files exist for the given query (e.g., the function/class/concept does not exist in the codebase), you MUST return an empty ANSWER:\n<ANSWER></ANSWER>\nDo NOT return irrelevant files (such as entry points or config files) just to provide some output. An empty answer is always better than a misleading one.\n\n# RESULT COUNT\nAim to return at most 10 files in your answer. Focus on the most relevant files first. If fewer files are relevant, return fewer.\n";
|
|
10
|
+
export declare const FORCE_ANSWER = "You have no turns left. Now you MUST provide your final ANSWER, even if it's not complete.";
|
|
11
|
+
export declare const RETRY_TOOL_CALL = "Your last reply did not contain a valid tool call. Reply with exactly one restricted_exec or answer call.";
|
|
12
|
+
/** The planner's two tools, in the OpenAI function format the backend expects. */
|
|
13
|
+
export declare const TOOL_DEFINITIONS: string;
|
|
14
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/extensions/search/prompt.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,WAAW,KAAK,CAAC;AAE9B;;;GAGG;AACH,eAAO,MAAM,aAAa,k4MAiJzB,CAAC;AAEF,eAAO,MAAM,YAAY,+FACoE,CAAC;AAE9F,eAAO,MAAM,eAAe,8GACgF,CAAC;AAwC7G,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,QA2B3B,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/** Planning rounds before the final answer is forced, commands per round, and files per answer. */
|
|
2
|
+
export const MAX_TURNS = 3;
|
|
3
|
+
export const MAX_COMMANDS = 8;
|
|
4
|
+
export const MAX_RESULTS = 10;
|
|
5
|
+
/**
|
|
6
|
+
* The SWE-grep planner prompt, kept close to the Windsurf original the backend model was tuned on.
|
|
7
|
+
* The budgets it states are the ones code-search.ts enforces.
|
|
8
|
+
*/
|
|
9
|
+
export const SYSTEM_PROMPT = `You are an expert software engineer, responsible for providing context \
|
|
10
|
+
to another engineer to solve a code issue in the current codebase. \
|
|
11
|
+
The user will present you with a description of the issue, and it is \
|
|
12
|
+
your job to provide a series of file paths with associated line ranges \
|
|
13
|
+
that contain ALL the information relevant to understand and correctly \
|
|
14
|
+
address the issue.
|
|
15
|
+
|
|
16
|
+
# IMPORTANT:
|
|
17
|
+
- A relevant file does not mean only the files that must be modified to \
|
|
18
|
+
solve the task. It means any file that contains information relevant to \
|
|
19
|
+
planning and implementing the fix, such as the definitions of classes \
|
|
20
|
+
and functions that are relevant to the pieces of code that will have to \
|
|
21
|
+
be modified.
|
|
22
|
+
- You should include enough context around the relevant lines to allow \
|
|
23
|
+
the engineer to understand the task correctly. You must include ENTIRE \
|
|
24
|
+
semantic blocks (functions, classes, definitions, etc). For example:
|
|
25
|
+
If addressing the issue requires modifying a method within a class, then \
|
|
26
|
+
you should include the entire class definition, not just the lines around \
|
|
27
|
+
the method we want to modify.
|
|
28
|
+
- NEVER truncate these blocks unless they are very large (hundreds of \
|
|
29
|
+
lines or more, in which case providing only a relevant portion of the \
|
|
30
|
+
block is acceptable).
|
|
31
|
+
- Your job is to essentially alleviate the job of the other engineer by \
|
|
32
|
+
giving them a clean starting context from which to start working. More \
|
|
33
|
+
precisely, you should minimize the number of files the engineer has to \
|
|
34
|
+
read to understand and solve the task correctly (while not providing \
|
|
35
|
+
irrelevant code snippets).
|
|
36
|
+
|
|
37
|
+
# ENVIRONMENT
|
|
38
|
+
- Working directory: /codebase. Make sure to run commands in this \
|
|
39
|
+
directory, not \`.
|
|
40
|
+
- Tool access: use the restricted_exec tool ONLY
|
|
41
|
+
- Allowed sub-commands (schema-enforced):
|
|
42
|
+
- rg: Search for patterns in files using ripgrep
|
|
43
|
+
- Required: pattern (string), path (string)
|
|
44
|
+
- Optional: include (array of globs), exclude (array of globs)
|
|
45
|
+
- readfile: Read contents of a file with optional line range
|
|
46
|
+
- Required: file (string)
|
|
47
|
+
- Optional: start_line (int), end_line (int) — 1-indexed, inclusive
|
|
48
|
+
- tree: Display directory structure as a tree
|
|
49
|
+
- Required: path (string)
|
|
50
|
+
- Optional: levels (int)
|
|
51
|
+
|
|
52
|
+
# THINKING RULES
|
|
53
|
+
- Think step-by-step. Plan, reason, and reflect before each tool call.
|
|
54
|
+
- Use tool calls liberally and purposefully to ground every conclusion \
|
|
55
|
+
in real code, not assumptions.
|
|
56
|
+
- If a command fails, rethink and try something different; do not \
|
|
57
|
+
complain to the user.
|
|
58
|
+
|
|
59
|
+
# FAST-SEARCH DEFAULTS (optimize rg/tree on large repos)
|
|
60
|
+
- Start NARROW, then widen only if needed. Prefer searching likely code \
|
|
61
|
+
roots first (e.g., \`src/\`, \`lib/\`, \`app/\`, \`packages/\`, \`services/\`) \
|
|
62
|
+
instead of \`/codebase\`.
|
|
63
|
+
- Prefer fixed-string search for literals: escape patterns or keep regex \
|
|
64
|
+
simple. Use smart case; avoid case-insensitive unless necessary.
|
|
65
|
+
- Prefer file-type filters and globs (in include) over full-repo scans.
|
|
66
|
+
- Default EXCLUDES for speed (apply via the exclude array): \
|
|
67
|
+
node_modules, .git, dist, build, coverage, .venv, venv, target, out, \
|
|
68
|
+
.cache, __pycache__, vendor, deps, third_party, logs, data, *.min.*
|
|
69
|
+
- Skip huge files where possible; when opening files, prefer reading \
|
|
70
|
+
only relevant ranges with readfile.
|
|
71
|
+
- Limit directory traversal with tree levels to quickly orient before \
|
|
72
|
+
deeper inspection.
|
|
73
|
+
|
|
74
|
+
# SOME EXAMPLES OF WORKFLOWS
|
|
75
|
+
- MAP – Use \`tree\` with small levels; \`rg\` on likely roots to grasp \
|
|
76
|
+
structure and hotspots.
|
|
77
|
+
- ANCHOR – \`rg\` for problem keywords and anchor symbols; restrict by \
|
|
78
|
+
language globs via include.
|
|
79
|
+
- TRACE – Follow imports with targeted \`rg\` in narrowed roots; open \
|
|
80
|
+
files with \`readfile\` scoped to entire semantic blocks.
|
|
81
|
+
- VERIFY – Confirm each candidate path exists by reading or additional \
|
|
82
|
+
searches; drop false positives (tests, vendored, generated) unless they \
|
|
83
|
+
must change.
|
|
84
|
+
|
|
85
|
+
# TOOL USE GUIDELINES
|
|
86
|
+
- You must use a SINGLE restricted_exec call in your answer, that lets \
|
|
87
|
+
you execute at most ${MAX_COMMANDS} commands in a single turn. Each command must be \
|
|
88
|
+
an object with a \`type\` field of \`rg\`, \`readfile\`, or \`tree\` and the appropriate fields for that type.
|
|
89
|
+
- Example restricted_exec usage:
|
|
90
|
+
[TOOL_CALLS]restricted_exec[ARGS]{
|
|
91
|
+
"command1": {
|
|
92
|
+
"type": "rg",
|
|
93
|
+
"pattern": "Controller",
|
|
94
|
+
"path": "/codebase/slime",
|
|
95
|
+
"include": ["**/*.py"],
|
|
96
|
+
"exclude": ["**/node_modules/**", "**/.git/**", "**/dist/**", \
|
|
97
|
+
"**/build/**", "**/.venv/**", "**/__pycache__/**"]
|
|
98
|
+
},
|
|
99
|
+
"command2": {
|
|
100
|
+
"type": "readfile",
|
|
101
|
+
"file": "/codebase/slime/train.py",
|
|
102
|
+
"start_line": 1,
|
|
103
|
+
"end_line": 200
|
|
104
|
+
},
|
|
105
|
+
"command3": {
|
|
106
|
+
"type": "tree",
|
|
107
|
+
"path": "/codebase/slime/",
|
|
108
|
+
"levels": 2
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
- You have at most ${MAX_TURNS} turns to interact with the environment by calling \
|
|
112
|
+
tools, so issuing multiple commands at once is necessary and encouraged \
|
|
113
|
+
to speed up your research.
|
|
114
|
+
- Each command result may be truncated to 40 lines; prefer multiple \
|
|
115
|
+
targeted reads/searches to build complete context.
|
|
116
|
+
- DO NOT EVER USE MORE THAN ${MAX_COMMANDS} commands in a single turn, or you will \
|
|
117
|
+
be penalized.
|
|
118
|
+
|
|
119
|
+
# ANSWER FORMAT (strict format, including tags)
|
|
120
|
+
- You will output an XML structure with a root element "ANSWER" \
|
|
121
|
+
containing "file" elements. Each "file" element will have a "path" \
|
|
122
|
+
attribute and contain "range" elements.
|
|
123
|
+
- You will output this as your final response.
|
|
124
|
+
- The line ranges must be inclusive.
|
|
125
|
+
|
|
126
|
+
Output example inside the "answer" tool argument:
|
|
127
|
+
<ANSWER>
|
|
128
|
+
<file path="/codebase/info_theory/formulas/entropy.py">
|
|
129
|
+
<range>10-60</range>
|
|
130
|
+
<range>150-210</range>
|
|
131
|
+
</file>
|
|
132
|
+
<file path="/codebase/info_theory/data_structures/bits.py">
|
|
133
|
+
<range>1-40</range>
|
|
134
|
+
<range>110-170</range>
|
|
135
|
+
</file>
|
|
136
|
+
</ANSWER>
|
|
137
|
+
|
|
138
|
+
Remember: Prefer narrow, fixed-string, and type-filtered searches with \
|
|
139
|
+
aggressive excludes and size/depth limits. Widen scope only as needed. \
|
|
140
|
+
Use the restricted tools available to you, and output your answer in \
|
|
141
|
+
exactly the specified format.
|
|
142
|
+
|
|
143
|
+
# NO RESULTS POLICY
|
|
144
|
+
If after thorough searching you are confident that NO relevant files exist \
|
|
145
|
+
for the given query (e.g., the function/class/concept does not exist in the \
|
|
146
|
+
codebase), you MUST return an empty ANSWER:
|
|
147
|
+
<ANSWER></ANSWER>
|
|
148
|
+
Do NOT return irrelevant files (such as entry points or config files) just \
|
|
149
|
+
to provide some output. An empty answer is always better than a misleading one.
|
|
150
|
+
|
|
151
|
+
# RESULT COUNT
|
|
152
|
+
Aim to return at most ${MAX_RESULTS} files in your answer. Focus on the most \
|
|
153
|
+
relevant files first. If fewer files are relevant, return fewer.
|
|
154
|
+
`;
|
|
155
|
+
export const FORCE_ANSWER = "You have no turns left. Now you MUST provide your final ANSWER, even if it's not complete.";
|
|
156
|
+
export const RETRY_TOOL_CALL = "Your last reply did not contain a valid tool call. Reply with exactly one restricted_exec or answer call.";
|
|
157
|
+
const COMMAND_SCHEMA = {
|
|
158
|
+
type: "object",
|
|
159
|
+
description: "One command. Must be one of: rg, readfile, or tree.",
|
|
160
|
+
oneOf: [
|
|
161
|
+
{
|
|
162
|
+
properties: {
|
|
163
|
+
type: { type: "string", const: "rg", description: "Search for patterns in files using ripgrep." },
|
|
164
|
+
pattern: { type: "string", description: "The regex pattern to search for." },
|
|
165
|
+
path: { type: "string", description: "The path to search in." },
|
|
166
|
+
include: { type: "array", items: { type: "string" }, description: "File patterns to include." },
|
|
167
|
+
exclude: { type: "array", items: { type: "string" }, description: "File patterns to exclude." },
|
|
168
|
+
},
|
|
169
|
+
required: ["type", "pattern", "path"],
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
properties: {
|
|
173
|
+
type: {
|
|
174
|
+
type: "string",
|
|
175
|
+
const: "readfile",
|
|
176
|
+
description: "Read contents of a file with optional line range.",
|
|
177
|
+
},
|
|
178
|
+
file: { type: "string", description: "Path to the file to read." },
|
|
179
|
+
start_line: { type: "integer", description: "Starting line number (1-indexed)." },
|
|
180
|
+
end_line: { type: "integer", description: "Ending line number (1-indexed)." },
|
|
181
|
+
},
|
|
182
|
+
required: ["type", "file"],
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
properties: {
|
|
186
|
+
type: { type: "string", const: "tree", description: "Display directory structure as a tree." },
|
|
187
|
+
path: { type: "string", description: "Path to the directory." },
|
|
188
|
+
levels: { type: "integer", description: "Number of directory levels." },
|
|
189
|
+
},
|
|
190
|
+
required: ["type", "path"],
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
};
|
|
194
|
+
/** The planner's two tools, in the OpenAI function format the backend expects. */
|
|
195
|
+
export const TOOL_DEFINITIONS = JSON.stringify([
|
|
196
|
+
{
|
|
197
|
+
type: "function",
|
|
198
|
+
function: {
|
|
199
|
+
name: "restricted_exec",
|
|
200
|
+
description: "Execute restricted commands (rg, readfile, tree) in parallel.",
|
|
201
|
+
parameters: {
|
|
202
|
+
type: "object",
|
|
203
|
+
properties: Object.fromEntries(Array.from({ length: MAX_COMMANDS }, (_, i) => [`command${i + 1}`, COMMAND_SCHEMA])),
|
|
204
|
+
required: ["command1"],
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
type: "function",
|
|
210
|
+
function: {
|
|
211
|
+
name: "answer",
|
|
212
|
+
description: "Final answer with relevant files and line ranges.",
|
|
213
|
+
parameters: {
|
|
214
|
+
type: "object",
|
|
215
|
+
properties: { answer: { type: "string", description: "The final answer in XML format." } },
|
|
216
|
+
required: ["answer"],
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
]);
|
|
221
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/extensions/search/prompt.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAC3B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAC9B,MAAM,CAAC,MAAM,WAAW,GAAG,E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AAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iCAAiC,EAAE,EAAE;gBAC1F,QAAQ,EAAE,CAAC,QAAQ,CAAC;aACpB;SACD;KACD;CACD,CAAC,CAAC","sourcesContent":["/** Planning rounds before the final answer is forced, commands per round, and files per answer. */\nexport const MAX_TURNS = 3;\nexport const MAX_COMMANDS = 8;\nexport const MAX_RESULTS = 10;\n\n/**\n * The SWE-grep planner prompt, kept close to the Windsurf original the backend model was tuned on.\n * The budgets it states are the ones code-search.ts enforces.\n */\nexport const SYSTEM_PROMPT = `You are an expert software engineer, responsible for providing context \\\nto another engineer to solve a code issue in the current codebase. \\\nThe user will present you with a description of the issue, and it is \\\nyour job to provide a series of file paths with associated line ranges \\\nthat contain ALL the information relevant to understand and correctly \\\naddress the issue.\n\n# IMPORTANT:\n- A relevant file does not mean only the files that must be modified to \\\nsolve the task. It means any file that contains information relevant to \\\nplanning and implementing the fix, such as the definitions of classes \\\nand functions that are relevant to the pieces of code that will have to \\\nbe modified.\n- You should include enough context around the relevant lines to allow \\\nthe engineer to understand the task correctly. You must include ENTIRE \\\nsemantic blocks (functions, classes, definitions, etc). For example:\nIf addressing the issue requires modifying a method within a class, then \\\nyou should include the entire class definition, not just the lines around \\\nthe method we want to modify.\n- NEVER truncate these blocks unless they are very large (hundreds of \\\nlines or more, in which case providing only a relevant portion of the \\\nblock is acceptable).\n- Your job is to essentially alleviate the job of the other engineer by \\\ngiving them a clean starting context from which to start working. More \\\nprecisely, you should minimize the number of files the engineer has to \\\nread to understand and solve the task correctly (while not providing \\\nirrelevant code snippets).\n\n# ENVIRONMENT\n- Working directory: /codebase. Make sure to run commands in this \\\ndirectory, not \\`.\n- Tool access: use the restricted_exec tool ONLY\n- Allowed sub-commands (schema-enforced):\n - rg: Search for patterns in files using ripgrep\n - Required: pattern (string), path (string)\n - Optional: include (array of globs), exclude (array of globs)\n - readfile: Read contents of a file with optional line range\n - Required: file (string)\n - Optional: start_line (int), end_line (int) — 1-indexed, inclusive\n - tree: Display directory structure as a tree\n - Required: path (string)\n - Optional: levels (int)\n\n# THINKING RULES\n- Think step-by-step. Plan, reason, and reflect before each tool call.\n- Use tool calls liberally and purposefully to ground every conclusion \\\nin real code, not assumptions.\n- If a command fails, rethink and try something different; do not \\\ncomplain to the user.\n\n# FAST-SEARCH DEFAULTS (optimize rg/tree on large repos)\n- Start NARROW, then widen only if needed. Prefer searching likely code \\\nroots first (e.g., \\`src/\\`, \\`lib/\\`, \\`app/\\`, \\`packages/\\`, \\`services/\\`) \\\ninstead of \\`/codebase\\`.\n- Prefer fixed-string search for literals: escape patterns or keep regex \\\nsimple. Use smart case; avoid case-insensitive unless necessary.\n- Prefer file-type filters and globs (in include) over full-repo scans.\n- Default EXCLUDES for speed (apply via the exclude array): \\\nnode_modules, .git, dist, build, coverage, .venv, venv, target, out, \\\n.cache, __pycache__, vendor, deps, third_party, logs, data, *.min.*\n- Skip huge files where possible; when opening files, prefer reading \\\nonly relevant ranges with readfile.\n- Limit directory traversal with tree levels to quickly orient before \\\ndeeper inspection.\n\n# SOME EXAMPLES OF WORKFLOWS\n- MAP – Use \\`tree\\` with small levels; \\`rg\\` on likely roots to grasp \\\nstructure and hotspots.\n- ANCHOR – \\`rg\\` for problem keywords and anchor symbols; restrict by \\\nlanguage globs via include.\n- TRACE – Follow imports with targeted \\`rg\\` in narrowed roots; open \\\nfiles with \\`readfile\\` scoped to entire semantic blocks.\n- VERIFY – Confirm each candidate path exists by reading or additional \\\nsearches; drop false positives (tests, vendored, generated) unless they \\\nmust change.\n\n# TOOL USE GUIDELINES\n- You must use a SINGLE restricted_exec call in your answer, that lets \\\nyou execute at most ${MAX_COMMANDS} commands in a single turn. Each command must be \\\nan object with a \\`type\\` field of \\`rg\\`, \\`readfile\\`, or \\`tree\\` and the appropriate fields for that type.\n- Example restricted_exec usage:\n[TOOL_CALLS]restricted_exec[ARGS]{\n \"command1\": {\n \"type\": \"rg\",\n \"pattern\": \"Controller\",\n \"path\": \"/codebase/slime\",\n \"include\": [\"**/*.py\"],\n \"exclude\": [\"**/node_modules/**\", \"**/.git/**\", \"**/dist/**\", \\\n\"**/build/**\", \"**/.venv/**\", \"**/__pycache__/**\"]\n },\n \"command2\": {\n \"type\": \"readfile\",\n \"file\": \"/codebase/slime/train.py\",\n \"start_line\": 1,\n \"end_line\": 200\n },\n \"command3\": {\n \"type\": \"tree\",\n \"path\": \"/codebase/slime/\",\n \"levels\": 2\n }\n}\n- You have at most ${MAX_TURNS} turns to interact with the environment by calling \\\ntools, so issuing multiple commands at once is necessary and encouraged \\\nto speed up your research.\n- Each command result may be truncated to 40 lines; prefer multiple \\\ntargeted reads/searches to build complete context.\n- DO NOT EVER USE MORE THAN ${MAX_COMMANDS} commands in a single turn, or you will \\\nbe penalized.\n\n# ANSWER FORMAT (strict format, including tags)\n- You will output an XML structure with a root element \"ANSWER\" \\\ncontaining \"file\" elements. Each \"file\" element will have a \"path\" \\\nattribute and contain \"range\" elements.\n- You will output this as your final response.\n- The line ranges must be inclusive.\n\nOutput example inside the \"answer\" tool argument:\n<ANSWER>\n <file path=\"/codebase/info_theory/formulas/entropy.py\">\n <range>10-60</range>\n <range>150-210</range>\n </file>\n <file path=\"/codebase/info_theory/data_structures/bits.py\">\n <range>1-40</range>\n <range>110-170</range>\n </file>\n</ANSWER>\n\nRemember: Prefer narrow, fixed-string, and type-filtered searches with \\\naggressive excludes and size/depth limits. Widen scope only as needed. \\\nUse the restricted tools available to you, and output your answer in \\\nexactly the specified format.\n\n# NO RESULTS POLICY\nIf after thorough searching you are confident that NO relevant files exist \\\nfor the given query (e.g., the function/class/concept does not exist in the \\\ncodebase), you MUST return an empty ANSWER:\n<ANSWER></ANSWER>\nDo NOT return irrelevant files (such as entry points or config files) just \\\nto provide some output. An empty answer is always better than a misleading one.\n\n# RESULT COUNT\nAim to return at most ${MAX_RESULTS} files in your answer. Focus on the most \\\nrelevant files first. If fewer files are relevant, return fewer.\n`;\n\nexport const FORCE_ANSWER =\n\t\"You have no turns left. Now you MUST provide your final ANSWER, even if it's not complete.\";\n\nexport const RETRY_TOOL_CALL =\n\t\"Your last reply did not contain a valid tool call. Reply with exactly one restricted_exec or answer call.\";\n\nconst COMMAND_SCHEMA = {\n\ttype: \"object\",\n\tdescription: \"One command. Must be one of: rg, readfile, or tree.\",\n\toneOf: [\n\t\t{\n\t\t\tproperties: {\n\t\t\t\ttype: { type: \"string\", const: \"rg\", description: \"Search for patterns in files using ripgrep.\" },\n\t\t\t\tpattern: { type: \"string\", description: \"The regex pattern to search for.\" },\n\t\t\t\tpath: { type: \"string\", description: \"The path to search in.\" },\n\t\t\t\tinclude: { type: \"array\", items: { type: \"string\" }, description: \"File patterns to include.\" },\n\t\t\t\texclude: { type: \"array\", items: { type: \"string\" }, description: \"File patterns to exclude.\" },\n\t\t\t},\n\t\t\trequired: [\"type\", \"pattern\", \"path\"],\n\t\t},\n\t\t{\n\t\t\tproperties: {\n\t\t\t\ttype: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tconst: \"readfile\",\n\t\t\t\t\tdescription: \"Read contents of a file with optional line range.\",\n\t\t\t\t},\n\t\t\t\tfile: { type: \"string\", description: \"Path to the file to read.\" },\n\t\t\t\tstart_line: { type: \"integer\", description: \"Starting line number (1-indexed).\" },\n\t\t\t\tend_line: { type: \"integer\", description: \"Ending line number (1-indexed).\" },\n\t\t\t},\n\t\t\trequired: [\"type\", \"file\"],\n\t\t},\n\t\t{\n\t\t\tproperties: {\n\t\t\t\ttype: { type: \"string\", const: \"tree\", description: \"Display directory structure as a tree.\" },\n\t\t\t\tpath: { type: \"string\", description: \"Path to the directory.\" },\n\t\t\t\tlevels: { type: \"integer\", description: \"Number of directory levels.\" },\n\t\t\t},\n\t\t\trequired: [\"type\", \"path\"],\n\t\t},\n\t],\n};\n\n/** The planner's two tools, in the OpenAI function format the backend expects. */\nexport const TOOL_DEFINITIONS = JSON.stringify([\n\t{\n\t\ttype: \"function\",\n\t\tfunction: {\n\t\t\tname: \"restricted_exec\",\n\t\t\tdescription: \"Execute restricted commands (rg, readfile, tree) in parallel.\",\n\t\t\tparameters: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: Object.fromEntries(\n\t\t\t\t\tArray.from({ length: MAX_COMMANDS }, (_, i) => [`command${i + 1}`, COMMAND_SCHEMA]),\n\t\t\t\t),\n\t\t\t\trequired: [\"command1\"],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\ttype: \"function\",\n\t\tfunction: {\n\t\t\tname: \"answer\",\n\t\t\tdescription: \"Final answer with relevant files and line ranges.\",\n\t\t\tparameters: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: { answer: { type: \"string\", description: \"The final answer in XML format.\" } },\n\t\t\t\trequired: [\"answer\"],\n\t\t\t},\n\t\t},\n\t},\n]);\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rows for code_search and web_search, in the shape of the built-in explore tools: a one-line
|
|
3
|
+
* header that carries progress and the result count, and a body only when expanded (or failed).
|
|
4
|
+
* The model-facing text is untouched; these read `details`.
|
|
5
|
+
*/
|
|
6
|
+
import { type Component } from "@earendil-works/pi-tui";
|
|
7
|
+
import type { AgentToolResult, ToolRenderContext, ToolRenderResultOptions } from "../../core/extensions/types.ts";
|
|
8
|
+
import type { Theme } from "../../modes/interactive/theme/theme.ts";
|
|
9
|
+
import type { CodeLocation } from "./code-search.ts";
|
|
10
|
+
import type { WebResult } from "./devin.ts";
|
|
11
|
+
export interface CodeSearchDetails {
|
|
12
|
+
locations: CodeLocation[];
|
|
13
|
+
}
|
|
14
|
+
export interface WebSearchDetails {
|
|
15
|
+
results: WebResult[];
|
|
16
|
+
}
|
|
17
|
+
export declare function renderCodeSearchCall(args: {
|
|
18
|
+
query?: string;
|
|
19
|
+
path?: string;
|
|
20
|
+
}, theme: Theme, context: ToolRenderContext<unknown, unknown, CodeSearchDetails>): Component;
|
|
21
|
+
export declare function renderCodeSearchResult(result: AgentToolResult<CodeSearchDetails>, options: ToolRenderResultOptions, theme: Theme, context: ToolRenderContext<unknown, {
|
|
22
|
+
path?: string;
|
|
23
|
+
}, CodeSearchDetails>): Component;
|
|
24
|
+
export declare function renderWebSearchCall(args: {
|
|
25
|
+
query?: string;
|
|
26
|
+
}, theme: Theme, context: ToolRenderContext<unknown, unknown, WebSearchDetails>): Component;
|
|
27
|
+
export declare function renderWebSearchResult(result: AgentToolResult<WebSearchDetails>, options: ToolRenderResultOptions, theme: Theme, context: ToolRenderContext<unknown, unknown, WebSearchDetails>): Component;
|
|
28
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/extensions/search/render.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,SAAS,EAA6D,MAAM,wBAAwB,CAAC;AACnH,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAClH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,iBAAiB;IACjC,SAAS,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,SAAS,EAAE,CAAC;CACrB;AAqDD,wBAAgB,oBAAoB,CACnC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EACvC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,CAAC,GAC7D,SAAS,CAMX;AAED,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,eAAe,CAAC,iBAAiB,CAAC,EAC1C,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,iBAAiB,CAAC,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,iBAAiB,CAAC,GACvE,SAAS,CAiBX;AAED,wBAAgB,mBAAmB,CAClC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACxB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,GAC5D,SAAS,CAKX;AAED,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,eAAe,CAAC,gBAAgB,CAAC,EACzC,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,GAC5D,SAAS,CAaX"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rows for code_search and web_search, in the shape of the built-in explore tools: a one-line
|
|
3
|
+
* header that carries progress and the result count, and a body only when expanded (or failed).
|
|
4
|
+
* The model-facing text is untouched; these read `details`.
|
|
5
|
+
*/
|
|
6
|
+
import { Container, hyperlink, Text, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
7
|
+
/** Columns beyond which a path or title stops pushing the second column right. */
|
|
8
|
+
const MAX_FIRST_COLUMN = 56;
|
|
9
|
+
function textOf(result) {
|
|
10
|
+
const block = result?.content.find((c) => c.type === "text");
|
|
11
|
+
return block && "text" in block ? block.text.trim() : "";
|
|
12
|
+
}
|
|
13
|
+
function plural(n, word) {
|
|
14
|
+
return `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
15
|
+
}
|
|
16
|
+
/** `● name "query"<scope> · <status>`, where status is live progress, then the result count. */
|
|
17
|
+
function header(theme, name, query, scope, context, summary) {
|
|
18
|
+
let line = `${theme.fg("toolTitle", theme.bold(name))} ${theme.fg("accent", `"${query ?? ""}"`)}`;
|
|
19
|
+
if (scope)
|
|
20
|
+
line += theme.fg("toolOutput", scope);
|
|
21
|
+
const status = !context.result || context.isError ? "" : context.isPartial ? textOf(context.result) : summary();
|
|
22
|
+
if (status)
|
|
23
|
+
line += theme.fg("muted", ` · ${status}`);
|
|
24
|
+
return new Text(line, 0, 0);
|
|
25
|
+
}
|
|
26
|
+
/** Two aligned columns; the first is padded to the widest entry, up to MAX_FIRST_COLUMN. */
|
|
27
|
+
function columns(rows) {
|
|
28
|
+
const width = Math.min(MAX_FIRST_COLUMN, Math.max(...rows.map((r) => visibleWidth(r.first))));
|
|
29
|
+
const lines = rows.map(({ first, second }) => {
|
|
30
|
+
const cell = visibleWidth(first) > width ? truncateToWidth(first, width, "…") : first;
|
|
31
|
+
return `${cell}${" ".repeat(Math.max(0, width - visibleWidth(cell)))} ${second}`;
|
|
32
|
+
});
|
|
33
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
34
|
+
}
|
|
35
|
+
/** Collapsed and still-running rows show nothing below the header; a failure always shows its message. */
|
|
36
|
+
function body(result, options, theme, context, expanded) {
|
|
37
|
+
if (context.isError)
|
|
38
|
+
return new Text(theme.fg("error", textOf(result).split("\n")[0] ?? ""), 0, 0);
|
|
39
|
+
if (!options.expanded || options.isPartial)
|
|
40
|
+
return new Container();
|
|
41
|
+
return expanded();
|
|
42
|
+
}
|
|
43
|
+
export function renderCodeSearchCall(args, theme, context) {
|
|
44
|
+
const scope = args.path && args.path !== "." ? ` in ${args.path.replace(/\\/g, "/")}` : "";
|
|
45
|
+
return header(theme, "code_search", args.query, scope, context, () => {
|
|
46
|
+
const n = context.result?.details?.locations.length ?? 0;
|
|
47
|
+
return n ? plural(n, "file") : "nothing found";
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export function renderCodeSearchResult(result, options, theme, context) {
|
|
51
|
+
return body(result, options, theme, context, () => {
|
|
52
|
+
const locations = result.details?.locations ?? [];
|
|
53
|
+
if (!locations.length)
|
|
54
|
+
return new Text(theme.fg("muted", "No relevant code found."), 0, 0);
|
|
55
|
+
// Paths are relative to the session directory; show them relative to the searched path.
|
|
56
|
+
const scope = context.args.path?.replace(/\\/g, "/").replace(/^\.\/?|\/+$/g, "");
|
|
57
|
+
return columns(locations.map(({ path, ranges }) => {
|
|
58
|
+
const shown = scope && path.startsWith(`${scope}/`) ? path.slice(scope.length + 1) : path;
|
|
59
|
+
const slash = shown.lastIndexOf("/");
|
|
60
|
+
return {
|
|
61
|
+
first: theme.fg("muted", shown.slice(0, slash + 1)) + theme.fg("toolOutput", shown.slice(slash + 1)),
|
|
62
|
+
second: theme.fg("accent", ranges.map(([s, e]) => (s === e ? `${s}` : `${s}-${e}`)).join(" · ")),
|
|
63
|
+
};
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export function renderWebSearchCall(args, theme, context) {
|
|
68
|
+
return header(theme, "web_search", args.query, "", context, () => {
|
|
69
|
+
const n = context.result?.details?.results.length ?? 0;
|
|
70
|
+
return n ? plural(n, "result") : "no results";
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export function renderWebSearchResult(result, options, theme, context) {
|
|
74
|
+
return body(result, options, theme, context, () => {
|
|
75
|
+
const results = result.details?.results ?? [];
|
|
76
|
+
if (!results.length)
|
|
77
|
+
return new Text(theme.fg("muted", "No results."), 0, 0);
|
|
78
|
+
return columns(results.map(({ url, title }) => {
|
|
79
|
+
const host = new URL(url).hostname.replace(/^www\./, "");
|
|
80
|
+
const label = title ?? url;
|
|
81
|
+
const cell = visibleWidth(label) > MAX_FIRST_COLUMN ? truncateToWidth(label, MAX_FIRST_COLUMN, "…") : label;
|
|
82
|
+
return { first: hyperlink(theme.fg("toolOutput", cell), url), second: theme.fg("muted", host) };
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/extensions/search/render.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAkB,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAcnH,kFAAkF;AAClF,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,SAAS,MAAM,CAAC,MAA4C;IAC3D,MAAM,KAAK,GAAG,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IAC7D,OAAO,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,CAAC;AAED,SAAS,MAAM,CAAC,CAAS,EAAE,IAAY;IACtC,OAAO,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAC5C,CAAC;AAED,gGAAgG;AAChG,SAAS,MAAM,CACd,KAAY,EACZ,IAAY,EACZ,KAAyB,EACzB,KAAa,EACb,OAA0B,EAC1B,OAAqB;IAErB,IAAI,IAAI,GAAG,GAAG,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;IAClG,IAAI,KAAK;QAAE,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,CAAC,O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,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YAC5G,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;QACjG,CAAC,CAAC,CACF,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Rows for code_search and web_search, in the shape of the built-in explore tools: a one-line\n * header that carries progress and the result count, and a body only when expanded (or failed).\n * The model-facing text is untouched; these read `details`.\n */\nimport { type Component, Container, hyperlink, Text, truncateToWidth, visibleWidth } from \"@earendil-works/pi-tui\";\nimport type { AgentToolResult, ToolRenderContext, ToolRenderResultOptions } from \"../../core/extensions/types.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { CodeLocation } from \"./code-search.ts\";\nimport type { WebResult } from \"./devin.ts\";\n\nexport interface CodeSearchDetails {\n\tlocations: CodeLocation[];\n}\n\nexport interface WebSearchDetails {\n\tresults: WebResult[];\n}\n\n/** Columns beyond which a path or title stops pushing the second column right. */\nconst MAX_FIRST_COLUMN = 56;\n\nfunction textOf(result: AgentToolResult<unknown> | undefined): string {\n\tconst block = result?.content.find((c) => c.type === \"text\");\n\treturn block && \"text\" in block ? block.text.trim() : \"\";\n}\n\nfunction plural(n: number, word: string): string {\n\treturn `${n} ${word}${n === 1 ? \"\" : \"s\"}`;\n}\n\n/** `● name \"query\"<scope> · <status>`, where status is live progress, then the result count. */\nfunction header(\n\ttheme: Theme,\n\tname: string,\n\tquery: string | undefined,\n\tscope: string,\n\tcontext: ToolRenderContext,\n\tsummary: () => string,\n): Component {\n\tlet line = `${theme.fg(\"toolTitle\", theme.bold(name))} ${theme.fg(\"accent\", `\"${query ?? \"\"}\"`)}`;\n\tif (scope) line += theme.fg(\"toolOutput\", scope);\n\tconst status = !context.result || context.isError ? \"\" : context.isPartial ? textOf(context.result) : summary();\n\tif (status) line += theme.fg(\"muted\", ` · ${status}`);\n\treturn new Text(line, 0, 0);\n}\n\n/** Two aligned columns; the first is padded to the widest entry, up to MAX_FIRST_COLUMN. */\nfunction columns(rows: Array<{ first: string; second: string }>): Component {\n\tconst width = Math.min(MAX_FIRST_COLUMN, Math.max(...rows.map((r) => visibleWidth(r.first))));\n\tconst lines = rows.map(({ first, second }) => {\n\t\tconst cell = visibleWidth(first) > width ? truncateToWidth(first, width, \"…\") : first;\n\t\treturn `${cell}${\" \".repeat(Math.max(0, width - visibleWidth(cell)))} ${second}`;\n\t});\n\treturn new Text(lines.join(\"\\n\"), 0, 0);\n}\n\n/** Collapsed and still-running rows show nothing below the header; a failure always shows its message. */\nfunction body(\n\tresult: AgentToolResult<unknown>,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcontext: ToolRenderContext,\n\texpanded: () => Component,\n): Component {\n\tif (context.isError) return new Text(theme.fg(\"error\", textOf(result).split(\"\\n\")[0] ?? \"\"), 0, 0);\n\tif (!options.expanded || options.isPartial) return new Container();\n\treturn expanded();\n}\n\nexport function renderCodeSearchCall(\n\targs: { query?: string; path?: string },\n\ttheme: Theme,\n\tcontext: ToolRenderContext<unknown, unknown, CodeSearchDetails>,\n): Component {\n\tconst scope = args.path && args.path !== \".\" ? ` in ${args.path.replace(/\\\\/g, \"/\")}` : \"\";\n\treturn header(theme, \"code_search\", args.query, scope, context, () => {\n\t\tconst n = context.result?.details?.locations.length ?? 0;\n\t\treturn n ? plural(n, \"file\") : \"nothing found\";\n\t});\n}\n\nexport function renderCodeSearchResult(\n\tresult: AgentToolResult<CodeSearchDetails>,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcontext: ToolRenderContext<unknown, { path?: string }, CodeSearchDetails>,\n): Component {\n\treturn body(result, options, theme, context, () => {\n\t\tconst locations = result.details?.locations ?? [];\n\t\tif (!locations.length) return new Text(theme.fg(\"muted\", \"No relevant code found.\"), 0, 0);\n\t\t// Paths are relative to the session directory; show them relative to the searched path.\n\t\tconst scope = context.args.path?.replace(/\\\\/g, \"/\").replace(/^\\.\\/?|\\/+$/g, \"\");\n\t\treturn columns(\n\t\t\tlocations.map(({ path, ranges }) => {\n\t\t\t\tconst shown = scope && path.startsWith(`${scope}/`) ? path.slice(scope.length + 1) : path;\n\t\t\t\tconst slash = shown.lastIndexOf(\"/\");\n\t\t\t\treturn {\n\t\t\t\t\tfirst: theme.fg(\"muted\", shown.slice(0, slash + 1)) + theme.fg(\"toolOutput\", shown.slice(slash + 1)),\n\t\t\t\t\tsecond: theme.fg(\"accent\", ranges.map(([s, e]) => (s === e ? `${s}` : `${s}-${e}`)).join(\" · \")),\n\t\t\t\t};\n\t\t\t}),\n\t\t);\n\t});\n}\n\nexport function renderWebSearchCall(\n\targs: { query?: string },\n\ttheme: Theme,\n\tcontext: ToolRenderContext<unknown, unknown, WebSearchDetails>,\n): Component {\n\treturn header(theme, \"web_search\", args.query, \"\", context, () => {\n\t\tconst n = context.result?.details?.results.length ?? 0;\n\t\treturn n ? plural(n, \"result\") : \"no results\";\n\t});\n}\n\nexport function renderWebSearchResult(\n\tresult: AgentToolResult<WebSearchDetails>,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcontext: ToolRenderContext<unknown, unknown, WebSearchDetails>,\n): Component {\n\treturn body(result, options, theme, context, () => {\n\t\tconst results = result.details?.results ?? [];\n\t\tif (!results.length) return new Text(theme.fg(\"muted\", \"No results.\"), 0, 0);\n\t\treturn columns(\n\t\t\tresults.map(({ url, title }) => {\n\t\t\t\tconst host = new URL(url).hostname.replace(/^www\\./, \"\");\n\t\t\t\tconst label = title ?? url;\n\t\t\t\tconst cell = visibleWidth(label) > MAX_FIRST_COLUMN ? truncateToWidth(label, MAX_FIRST_COLUMN, \"…\") : label;\n\t\t\t\treturn { first: hyperlink(theme.fg(\"toolOutput\", cell), url), second: theme.fg(\"muted\", host) };\n\t\t\t}),\n\t\t);\n\t});\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const VIRTUAL_ROOT = "/codebase";
|
|
2
|
+
/** `rg` backend: pattern, directory or file, optional glob → `path:line: text` lines. */
|
|
3
|
+
export type Grep = (pattern: string, path: string, glob: string | undefined, signal?: AbortSignal) => Promise<string>;
|
|
4
|
+
/** Pi's own grep tool: gitignore-aware, with its bundled ripgrep. It takes one glob, so only the first include applies. */
|
|
5
|
+
export declare function piGrep(root: string): Grep;
|
|
6
|
+
/** Whether `path` lies inside `root`, both as written and after following symlinks. */
|
|
7
|
+
export declare function isInside(root: string, path: string): boolean;
|
|
8
|
+
export interface Command {
|
|
9
|
+
type?: unknown;
|
|
10
|
+
pattern?: unknown;
|
|
11
|
+
path?: unknown;
|
|
12
|
+
include?: unknown;
|
|
13
|
+
file?: unknown;
|
|
14
|
+
start_line?: unknown;
|
|
15
|
+
end_line?: unknown;
|
|
16
|
+
levels?: unknown;
|
|
17
|
+
}
|
|
18
|
+
export declare class Workspace {
|
|
19
|
+
readonly root: string;
|
|
20
|
+
private readonly grep;
|
|
21
|
+
private readonly noise;
|
|
22
|
+
constructor(root: string, grep?: Grep);
|
|
23
|
+
contains(path: string): boolean;
|
|
24
|
+
/** `/codebase/src/a.ts` or `src/a.ts` → an absolute path inside the root, or null. */
|
|
25
|
+
toReal(virtual: unknown): string | null;
|
|
26
|
+
toVirtual(real: string): string;
|
|
27
|
+
/** The deepest tree of the root, up to three levels, that fits the map budget. */
|
|
28
|
+
repoMap(): {
|
|
29
|
+
depth: number;
|
|
30
|
+
tree: string;
|
|
31
|
+
};
|
|
32
|
+
run(command: Command, signal?: AbortSignal): Promise<string>;
|
|
33
|
+
private rg;
|
|
34
|
+
private readfile;
|
|
35
|
+
private tree;
|
|
36
|
+
private renderTree;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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