dal-code 1.0.50 → 1.0.52
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 +1050 -5
- package/NOTICE +17 -1
- package/dist/bundle/chunks/anthropic-messages-NK5NGKAI.js +5 -0
- package/dist/bundle/chunks/anthropic.js +74 -0
- package/dist/bundle/chunks/azure-openai-responses-VEASENYL.js +1 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +88 -0
- package/dist/bundle/chunks/chunk-3YGHTGYM.js +7 -0
- package/dist/bundle/chunks/chunk-4LDEEFCY.js +1 -0
- package/dist/bundle/chunks/chunk-4UTLMBZZ.js +13 -0
- package/dist/bundle/chunks/chunk-4VJJ6NXH.js +8 -0
- package/dist/bundle/chunks/chunk-567OJLS7.js +1 -0
- package/dist/bundle/chunks/chunk-5AGIVGSV.js +5 -0
- package/dist/bundle/chunks/chunk-6EEJ4MZH.js +1 -0
- package/dist/bundle/chunks/chunk-6QGV3IWD.js +5 -0
- package/dist/bundle/chunks/chunk-723ZGEZ2.js +1 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +1 -0
- package/dist/bundle/chunks/chunk-7ZC4UXSL.js +1 -0
- package/dist/bundle/chunks/chunk-A5CI3CVQ.js +1 -0
- package/dist/bundle/chunks/chunk-AAQZXQA7.js +1 -0
- package/dist/bundle/chunks/chunk-ANL2BCIQ.js +15 -0
- package/dist/bundle/chunks/chunk-CF5GWZHW.js +30 -0
- package/dist/bundle/chunks/chunk-CS4T4O5O.js +1 -0
- package/dist/bundle/chunks/chunk-D2WTLI2T.js +19 -0
- package/dist/bundle/chunks/chunk-DLKRCASW.js +17 -0
- package/dist/bundle/chunks/chunk-EH7SFF47.js +129 -0
- package/dist/bundle/chunks/chunk-FFMDRXC4.js +9 -0
- package/dist/bundle/chunks/chunk-HEFI7NO7.js +1 -0
- package/dist/bundle/chunks/chunk-IEBK4HQA.js +1 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +1 -0
- package/dist/bundle/chunks/chunk-K7VBBYTT.js +1 -0
- package/dist/bundle/chunks/chunk-KJW3E2CB.js +9 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +1 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +11 -0
- package/dist/bundle/chunks/chunk-ML5DIOWR.js +1 -0
- package/dist/bundle/chunks/chunk-ON7ZX67F.js +30 -0
- package/dist/bundle/chunks/chunk-OQWPBJCS.js +81 -0
- package/dist/bundle/chunks/chunk-P7FPUEYA.js +1 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +1 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +1 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +1 -0
- package/dist/bundle/chunks/chunk-R47JBGS3.js +1 -0
- package/dist/bundle/chunks/chunk-RDZVAGPR.js +1 -0
- package/dist/bundle/chunks/chunk-SE42OS3U.js +21 -0
- package/dist/bundle/chunks/chunk-TK2WJTRC.js +3 -0
- package/dist/bundle/chunks/chunk-TMTOQ7H7.js +1 -0
- package/dist/bundle/chunks/chunk-UTB4DTYQ.js +1 -0
- package/dist/bundle/chunks/chunk-UVKMBM5X.js +56 -0
- package/dist/bundle/chunks/chunk-WIZGOHKY.js +9 -0
- package/dist/bundle/chunks/chunk-XAS5HHBW.js +1180 -0
- package/dist/bundle/chunks/chunk-XDBGA662.js +43 -0
- package/dist/bundle/chunks/chunk-XJFQKN3N.js +2 -0
- package/dist/bundle/chunks/chunk-YWNDPXVM.js +25 -0
- package/dist/bundle/chunks/chunk-ZG74NES2.js +1 -0
- package/dist/bundle/chunks/cli-GXB5WYKG.js +52 -0
- package/dist/bundle/chunks/cli-YPE3BB5X.js +30 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-B7WOBGWO.js +1 -0
- package/dist/bundle/chunks/codemode-worker.js +480 -0
- package/dist/bundle/chunks/dist-D3WIBXB5.js +10 -0
- package/dist/bundle/chunks/easter-egg-3d-5TFBCTIS.js +1 -0
- package/dist/bundle/chunks/execute-27QCJECT.js +506 -0
- package/dist/bundle/chunks/github-copilot.js +1 -0
- package/dist/bundle/chunks/google-generative-ai-MBMRBHSZ.js +1 -0
- package/dist/bundle/chunks/google-vertex-S2ZFBDPP.js +1 -0
- package/dist/bundle/chunks/http-proxy-KF35JLJN.js +1 -0
- package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +12 -0
- package/dist/bundle/chunks/image-resize-worker.js +1 -0
- package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +20 -0
- package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +1 -0
- package/dist/bundle/chunks/kimi-coding.js +1 -0
- package/dist/bundle/chunks/lib-4AVRLBHM.js +8 -0
- package/dist/bundle/chunks/llama-cpp-classify-S4LVGNNY.js +21 -0
- package/dist/bundle/chunks/mcp-6LJKGKJQ.js +10 -0
- package/dist/bundle/chunks/meta.js +1 -0
- package/dist/bundle/chunks/mistral-conversations-C7LUXIEY.js +4 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +2 -0
- package/dist/bundle/chunks/node-AUOGOBCN.js +1 -0
- package/dist/bundle/chunks/node-ZTHARAQV.js +15 -0
- package/dist/bundle/chunks/office-5OWKTZOA.js +419 -0
- package/dist/bundle/chunks/openai-chatgpt.js +74 -0
- package/dist/bundle/chunks/openai-codex-responses-YQQXJ24E.js +9 -0
- package/dist/bundle/chunks/openai-codex.js +74 -0
- package/dist/bundle/chunks/openai-completions-7CMH2FKD.js +6 -0
- package/dist/bundle/chunks/openai-decisions-AOGZTREY.js +4 -0
- package/dist/bundle/chunks/openai-responses-ZSOGZ3MK.js +3 -0
- package/dist/bundle/chunks/openrouter-images-AHXST2TH.js +1 -0
- package/dist/bundle/chunks/openrouter.js +74 -0
- package/dist/bundle/chunks/pi-messages-QERJLMZ6.js +7 -0
- package/dist/bundle/chunks/radius.js +74 -0
- package/dist/bundle/chunks/review-5G56KIWY.js +80 -0
- package/dist/bundle/chunks/rewind-2OYLDDHH.js +8 -0
- package/dist/bundle/chunks/router-776Z7G7G.js +3 -0
- package/dist/bundle/chunks/runtime-NKPT25KD.js +1 -0
- package/dist/bundle/chunks/sdk-TVC4GDUX.js +1 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +3 -0
- package/dist/bundle/chunks/sync-JBDC3YBK.js +7 -0
- package/dist/bundle/chunks/typesafe-system-one-MMNGGQ46.js +1 -0
- package/dist/bundle/chunks/usage-BDCIALHO.js +1 -0
- package/dist/bundle/chunks/virtual-modules-25RQ6XTV.js +1 -0
- package/dist/bundle/chunks/xai.js +1 -0
- package/dist/bundle/cli-runtime.js +2 -0
- package/dist/bundle/cli.js +2 -0
- package/dist/bundle/index.js +1 -0
- package/dist/bundle/rpc-entry.js +2 -0
- package/dist/cli/args.js +1 -1
- package/dist/cli/auth-command.js +9 -6
- package/dist/cli/auth-login.js +2 -0
- package/dist/cli/auth-logout.js +1 -0
- package/dist/cli/auth-terminal.js +5 -0
- package/dist/cli/config-selector.js +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.js +1 -1
- package/dist/core/agent-session-runtime.js +1 -1
- package/dist/core/agent-session-services.js +1 -1
- package/dist/core/agent-session.d.ts +8 -1
- package/dist/core/agent-session.js +12 -9
- package/dist/core/auth-storage.js +1 -1
- package/dist/core/bash-executor.js +1 -1
- package/dist/core/bug-report.js +3 -3
- package/dist/core/cache-warmer.d.ts +3 -15
- package/dist/core/cache-warmer.js +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +3 -2
- package/dist/core/compaction/branch-summarization.js +5 -5
- package/dist/core/compaction/compaction.d.ts +1 -0
- package/dist/core/compaction/compaction.js +14 -14
- package/dist/core/compaction/tool-output-pruning.js +1 -1
- package/dist/core/compaction/utils.d.ts +0 -1
- package/dist/core/compaction/utils.js +8 -8
- package/dist/core/exec.d.ts +2 -0
- package/dist/core/exec.js +1 -1
- package/dist/core/export-html/template.css +9 -0
- package/dist/core/export-html/template.js +46 -39
- package/dist/core/export-html/tool-renderer.js +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/pi-ai-extension-view.js +1 -0
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/extensions/types.d.ts +25 -7
- package/dist/core/extensions/virtual-modules.js +1 -1
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/mcp-servers.d.ts +6 -17
- package/dist/core/mcp-servers.js +1 -1
- package/dist/core/model-config.d.ts +1912 -2211
- package/dist/core/model-config.js +4 -4
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.js +1 -1
- package/dist/core/package-manager.d.ts +10 -1
- package/dist/core/package-manager.js +2 -2
- package/dist/core/pi-ai-schemas.js +1 -0
- package/dist/core/pi-manifest.js +1 -1
- package/dist/core/preferred-providers.js +1 -0
- package/dist/core/project-trust.js +2 -2
- package/dist/core/prompt-templates.js +2 -2
- package/dist/core/provider-composer.js +1 -1
- package/dist/core/provider-matching.js +1 -0
- package/dist/core/radius-mcp.js +1 -0
- package/dist/core/remote-catalog-provider.js +1 -1
- package/dist/core/resource-loader.d.ts +3 -1
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/runtime-credentials.js +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/session-cwd.js +3 -7
- package/dist/core/session-manager.d.ts +1 -0
- package/dist/core/session-manager.js +12 -12
- package/dist/core/settings-defaults.js +1 -1
- package/dist/core/settings-manager.d.ts +4 -0
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-schema.d.ts +4 -2
- package/dist/core/settings-schema.js +1 -1
- package/dist/core/skills.js +3 -3
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/source-info.d.ts +8 -0
- package/dist/core/source-info.js +1 -1
- package/dist/core/system-prompt.js +3 -3
- package/dist/core/tools/bash.d.ts +2 -2
- package/dist/core/tools/bash.js +15 -15
- package/dist/core/tools/edit-diff.d.ts +9 -4
- package/dist/core/tools/edit-diff.js +22 -15
- package/dist/core/tools/edit.d.ts +3 -3
- package/dist/core/tools/edit.js +3 -3
- package/dist/core/tools/find.d.ts +2 -2
- package/dist/core/tools/find.js +10 -11
- package/dist/core/tools/grep.d.ts +3 -3
- package/dist/core/tools/grep.js +8 -12
- package/dist/core/tools/ls.d.ts +2 -2
- package/dist/core/tools/ls.js +4 -4
- package/dist/core/tools/powershell.js +6 -2
- package/dist/core/tools/read.d.ts +5 -2
- package/dist/core/tools/read.js +20 -19
- package/dist/core/tools/render-utils.js +5 -5
- package/dist/core/tools/renderers/write.js +10 -10
- package/dist/core/tools/tool-definition-wrapper.d.ts +11 -0
- package/dist/core/tools/truncate.d.ts +2 -8
- package/dist/core/tools/truncate.js +10 -10
- package/dist/core/tools/write.d.ts +2 -2
- package/dist/core/trust-manager.js +2 -2
- package/dist/core/usage-totals.js +1 -1
- package/dist/dal/builtins.js +2 -2
- package/dist/dal/manifest.d.ts +1 -0
- package/dist/dal/manifest.js +1 -1
- package/dist/dal/safety-net.js +11 -3
- package/dist/extensions/codemode/execute.js +12 -12
- package/dist/extensions/codemode/renderer.js +6 -6
- package/dist/extensions/codemode/tool.d.ts +2 -1
- package/dist/extensions/codemode/tool.js +11 -10
- package/dist/extensions/llama/client.js +5 -5
- package/dist/extensions/llama/ui.js +2 -2
- package/dist/extensions/mcp/cli.js +21 -19
- package/dist/extensions/mcp/config.js +2 -2
- package/dist/extensions/mcp/index.js +7 -7
- package/dist/extensions/mcp/oauth.d.ts +3 -22
- package/dist/extensions/mcp/oauth.js +2 -2
- package/dist/extensions/mcp/resources.d.ts +1 -1
- package/dist/extensions/mcp/resources.js +1 -1
- package/dist/extensions/mcp/runtime.d.ts +2 -2
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/extensions/mcp/tools.d.ts +1 -8
- package/dist/extensions/mcp/tools.js +4 -9
- package/dist/extensions/mcp/ui.js +1 -1
- package/dist/extensions/tool-search/tool.js +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/main.js +4 -4
- package/dist/modes/interactive/components/assistant-message.d.ts +4 -1
- package/dist/modes/interactive/components/assistant-message.js +2 -2
- package/dist/modes/interactive/components/branch-summary-message.d.ts +5 -1
- package/dist/modes/interactive/components/branch-summary-message.js +2 -2
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +5 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +2 -2
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/custom-editor.js +1 -1
- package/dist/modes/interactive/components/custom-entry.js +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +5 -2
- package/dist/modes/interactive/components/custom-message.js +3 -3
- package/dist/modes/interactive/components/diff.js +3 -3
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -0
- package/dist/modes/interactive/components/extension-editor.js +1 -1
- package/dist/modes/interactive/components/extension-selector.js +2 -2
- package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
- package/dist/modes/interactive/components/login-dialog.js +1 -1
- package/dist/modes/interactive/components/markdown-transform.js +1 -1
- package/dist/modes/interactive/components/mermaid.js +4 -4
- package/dist/modes/interactive/components/model-selector.d.ts +1 -0
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/oauth-selector.d.ts +2 -1
- package/dist/modes/interactive/components/oauth-selector.js +1 -1
- package/dist/modes/interactive/components/provider-brand.js +1 -0
- package/dist/modes/interactive/components/radius-login-selector.js +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +2 -1
- package/dist/modes/interactive/components/session-selector.js +2 -2
- package/dist/modes/interactive/components/settings-submenu.js +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +5 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +2 -2
- package/dist/modes/interactive/components/tool-execution.d.ts +1 -0
- package/dist/modes/interactive/components/tool-execution.js +3 -3
- package/dist/modes/interactive/components/tree-selector.d.ts +2 -0
- package/dist/modes/interactive/components/tree-selector.js +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +2 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/external-editor.js +3 -3
- package/dist/modes/interactive/interactive-mode.d.ts +10 -1
- package/dist/modes/interactive/interactive-mode.js +45 -40
- package/dist/modes/interactive/model-search.js +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +4 -0
- package/dist/modes/interactive/theme/theme.js +3 -6
- package/dist/modes/print-mode.js +7 -7
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-compat/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/package.json +5 -2
- package/dist/node_modules/@dalcode/dal-learn/src/engine.js +4 -4
- package/dist/node_modules/@dalcode/dal-learn/src/extract.js +31 -5
- package/dist/node_modules/@dalcode/dal-learn/src/index.js +16 -16
- package/dist/node_modules/@dalcode/dal-learn/src/learn-mode.js +1 -0
- package/dist/node_modules/@dalcode/dal-learn/src/lesson-events.js +1 -0
- package/dist/node_modules/@dalcode/dal-learn/src/lessons.js +4 -3
- package/dist/node_modules/@dalcode/dal-learn/src/project-map.js +2 -2
- package/dist/node_modules/@dalcode/dal-learn/src/safety.js +2 -2
- package/dist/node_modules/@dalcode/dal-learn/src/signals.js +6 -5
- package/dist/node_modules/@dalcode/dal-learn/src/store.js +3 -2
- package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +4 -3
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +4 -3
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-sync/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-sync/src/core.js +2 -2
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/todo-snapshot.js +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +3 -3
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/README.md +8 -6
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +2 -2
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +8 -5
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/README.md +58 -39
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +9 -9
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/strict-tool-limits.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/meta.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/trusted-url.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.d.ts +21 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-bedrock-provider.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-oauth.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/all.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts +485 -498
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual-cn.json +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts +65 -65
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/schema-builders.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/telemetry.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +4 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/openrouter-cost.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.d.ts +26 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.js +4 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/{typebox-helpers.d.ts → string-enum.d.ts} +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/string-enum.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.js +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/validation.js +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +12 -5
- package/dist/node_modules/@earendil-works/pi-codemode/README.md +2 -2
- package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.js +4 -4
- package/dist/node_modules/@earendil-works/pi-codemode/dist/index.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-codemode/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js +2 -0
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/CHANGELOG.md +32 -0
- package/dist/node_modules/@earendil-works/pi-mcp/README.md +60 -5
- package/dist/node_modules/@earendil-works/pi-mcp/dist/config.d.ts +45 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/config.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/index.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/callback.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.d.ts +42 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.d.ts +5 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.d.ts +22 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.d.ts +8 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.js +11 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/lines.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.d.ts +34 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.js +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.d.ts +1 -4
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.js +2 -2
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js +6 -4
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-schema/CHANGELOG.md +37 -0
- package/dist/node_modules/@earendil-works/pi-schema/LICENSE +21 -0
- package/dist/node_modules/@earendil-works/pi-schema/README.md +319 -0
- package/dist/node_modules/@earendil-works/pi-schema/THIRD_PARTY_NOTICES/typebox-LICENSE +23 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/annotations.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/builders.d.ts +89 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/builders.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/checks.d.ts +51 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/checks.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/coerce.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/compiler.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/explain.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date_time.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/duration.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/email.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_email.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/bidi.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/puny.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/idn-hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/ascii.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/puny.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/unicode.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/pattern/pattern.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv4.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv6.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri_reference.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer_uri_fragment.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/regex.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/relative_json_pointer.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/time.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_reference.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_template.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/url.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uuid.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/index.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/resolver.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/shared.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.d.ts +54 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.js +0 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/types.d.ts +25 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/types.js +0 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/validator.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/validator.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/package.json +43 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.js +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/render.js +2 -2
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +3 -1
- package/dist/node_modules/@earendil-works/pi-tui/README.md +2 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.js +3 -3
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +11 -10
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/text.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +2 -2
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/keys.js +5 -5
- package/dist/node_modules/@earendil-works/pi-tui/dist/layout.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/program-status.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +4 -4
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +13 -13
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -2
- package/dist/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/package-manager-cli.js +17 -16
- package/dist/utils/ansi.js +1 -1
- package/dist/utils/changelog.js +3 -3
- package/dist/utils/clipboard-command.js +1 -1
- package/dist/utils/image-resize-core.js +1 -1
- package/dist/utils/image-resize.js +1 -1
- package/dist/utils/open-browser.js +1 -1
- package/dist/utils/paths.js +1 -1
- package/dist/utils/shell.js +3 -3
- package/dist/utils/syntax-highlight.js +4 -4
- package/dist/utils/terminal-question.js +1 -0
- package/dist/utils/tools-manager.js +1 -1
- package/dist/utils/web-url.js +1 -0
- package/examples/extensions/README.md +2 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +14 -14
- package/examples/extensions/debug-provider.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +19 -29
- package/examples/extensions/gondolin/package.json +2 -2
- package/examples/extensions/plan-mode/index.ts +20 -9
- package/examples/extensions/plan-mode/utils.ts +42 -16
- package/examples/extensions/preset.ts +2 -0
- package/examples/extensions/reload-runtime.ts +17 -5
- package/examples/extensions/subagent/README.md +14 -11
- package/examples/extensions/subagent/index.ts +392 -171
- package/examples/extensions/todo.ts +7 -0
- package/examples/extensions/tools.ts +2 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +20 -20
- package/examples/tsconfig.json +208 -0
- package/npm-shrinkwrap.json +407 -383
- package/package.json +6 -7
- package/examples/extensions/sandbox/index.ts +0 -327
- package/examples/extensions/sandbox/package-lock.json +0 -92
- package/examples/extensions/sandbox/package.json +0 -19
- /package/dist/node_modules/@earendil-works/pi-mcp/{LICENSES → THIRD_PARTY_NOTICES}/modelcontextprotocol-typescript-sdk.txt +0 -0
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),o=e.indexOf(`
|
|
3
|
-
`);return o===-1||n===-1?`
|
|
4
|
-
`:n<o?`\r
|
|
5
|
-
`:`
|
|
6
|
-
`}u(Z,"detectLineEnding");function F(e){return e.replace(/\r\n/g,`
|
|
1
|
+
var k=Object.defineProperty;var f=(e,t)=>k(e,"name",{value:t,configurable:!0});import*as L from"diff";import{constants as v}from"fs";import{access as C,readFile as A}from"fs/promises";import{splitBom as P}from"../../utils/text.js";import{resolveToCwd as _}from"./path-utils.js";function z(e){return e.replace(/\r\n/g,`
|
|
7
2
|
`).replace(/\r/g,`
|
|
8
|
-
`)}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
`)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
`)}f(z,"normalizeToLF");function re(e,t){let o=0,n=e.indexOf(`\r
|
|
4
|
+
`);const c=f(a=>{for(;n!==-1&&n-o<a;)o++,n=e.indexOf(`\r
|
|
5
|
+
`,n+2);return a+o},"toOriginal"),s=[];let l=!1;const r=f(a=>{a.length!==0&&(l&&a[0]===`
|
|
6
|
+
`&&s.push(`
|
|
7
|
+
`),s.push(a),l=a[a.length-1]==="\r")},"push");let u=0;for(const a of t){const h=c(a.matchIndex);r(e.slice(u,h));const i=b(e,h);r(i===`
|
|
8
|
+
`?a.newText:a.newText.replaceAll(`
|
|
9
|
+
`,i)),u=c(a.matchIndex+a.matchLength)}return r(e.slice(u)),s.join("")}f(re,"applyReplacementsToOriginal");function b(e,t){let o=e.indexOf(`
|
|
10
|
+
`,t);return o===-1&&(o=e.lastIndexOf(`
|
|
11
|
+
`,t)),o===-1?e.includes("\r")?"\r":`
|
|
12
|
+
`:e[o-1]==="\r"?`\r
|
|
13
|
+
`:`
|
|
14
|
+
`}f(b,"getLineEndingAt");function T(e){return e.normalize("NFKC").split(`
|
|
15
|
+
`).map(t=>t.trimEnd()).join(`
|
|
16
|
+
`).replace(/[\u2018\u2019\u201A\u201B]/g,"'").replace(/[\u201C\u201D\u201E\u201F]/g,'"').replace(/[\u2010\u2011\u2012\u2013\u2014\u2015\u2212]/g,"-").replace(/[\u00A0\u2002-\u200A\u202F\u205F\u3000]/g," ")}f(T,"normalizeForFuzzyMatch");function j(e){return e.match(/[^\n]*\n|[^\n]+/g)??[]}f(j,"splitLinesWithEndings");function y(e){let t=0;return j(e).map(o=>{const n={start:t,end:t+o.length};return t=n.end,n})}f(y,"getLineSpans");function B(e,t){const o=t.matchIndex,n=t.matchIndex+t.matchLength;let c=-1;for(let l=0;l<e.length;l++){const r=e[l];if(o>=r.start&&o<r.end){c=l;break}}if(c===-1)throw new Error("Replacement range is outside the base content.");let s=c;for(;s<e.length&&e[s].end<n;)s++;if(s>=e.length)throw new Error("Replacement range is outside the base content.");return{startLine:c,endLine:s+1}}f(B,"getReplacementLineRange");function O(e,t,o=0){let n=e;for(let c=t.length-1;c>=0;c--){const s=t[c],l=s.matchIndex-o;n=n.substring(0,l)+s.newText+n.substring(l+s.matchLength)}return n}f(O,"applyReplacements");function q(e,t,o){const n=y(e),c=y(t);if(n.length!==c.length)throw new Error("Cannot preserve unchanged lines because the base content has a different line count.");const s=[],l=[...o].sort((r,u)=>r.matchIndex-u.matchIndex);for(const r of l){const u=B(c,r),a=s[s.length-1];if(a&&u.startLine<a.endLine){a.endLine=Math.max(a.endLine,u.endLine),a.replacements.push(r);continue}s.push({...u,replacements:[r]})}return s.map(r=>{const u=c[r.startLine].start,a=c[r.endLine-1].end,h=n[r.startLine].start;return{matchIndex:h,matchLength:n[r.endLine-1].end-h,newText:O(t.slice(u,a),r.replacements,u)}})}f(q,"widenReplacementsToLines");function D(e,t){const o=e.indexOf(t);if(o!==-1)return{found:!0,index:o,matchLength:t.length,usedFuzzyMatch:!1,contentForReplacement:e};const n=T(e),c=T(t),s=n.indexOf(c);return s===-1?{found:!1,index:-1,matchLength:0,usedFuzzyMatch:!1,contentForReplacement:e}:{found:!0,index:s,matchLength:c.length,usedFuzzyMatch:!0,contentForReplacement:n}}f(D,"fuzzyFindText");function H(e,t){const o=T(e),n=T(t);return o.split(n).length-1}f(H,"countOccurrences");function K(e,t,o){return o===1?new Error(`Could not find the exact text in ${e}. The old text must match exactly including all whitespace and newlines.`):new Error(`Could not find edits[${t}] in ${e}. The oldText must match exactly including all whitespace and newlines.`)}f(K,"getNotFoundError");function Y(e,t,o,n){return o===1?new Error(`Found ${n} occurrences of the text in ${e}. The text must be unique. Please provide more context to make it unique.`):new Error(`Found ${n} occurrences of edits[${t}] in ${e}. Each oldText must be unique. Please provide more context to make it unique.`)}f(Y,"getDuplicateError");function G(e,t,o){return o===1?new Error(`oldText must not be empty in ${e}.`):new Error(`edits[${t}].oldText must not be empty in ${e}.`)}f(G,"getEmptyOldTextError");function U(e,t){return t===1?new Error(`No changes made to ${e}. The replacement produced identical content. This might indicate an issue with special characters or the text not existing as expected.`):new Error(`No changes made to ${e}. The replacements produced identical content.`)}f(U,"getNoChangeError");function J(e,t,o){const n=t.map(i=>({oldText:z(i.oldText),newText:z(i.newText)}));for(let i=0;i<n.length;i++)if(n[i].oldText.length===0)throw G(o,i,n.length);const s=n.map(i=>D(e,i.oldText)).some(i=>i.usedFuzzyMatch),l=s?T(e):e,r=[];for(let i=0;i<n.length;i++){const d=n[i],g=D(l,d.oldText);if(!g.found)throw K(o,i,n.length);const m=H(l,d.oldText);if(m>1)throw Y(o,i,n.length,m);r.push({editIndex:i,matchIndex:g.index,matchLength:g.matchLength,newText:d.newText})}r.sort((i,d)=>i.matchIndex-d.matchIndex);for(let i=1;i<r.length;i++){const d=r[i-1],g=r[i];if(d.matchIndex+d.matchLength>g.matchIndex)throw new Error(`edits[${d.editIndex}] and edits[${g.editIndex}] overlap in ${o}. Merge them into one edit or target disjoint regions.`)}const u=e,a=s?q(e,l,r):r,h=O(u,a);if(u===h)throw U(o,n.length);return{baseContent:u,newContent:h,replacements:a}}f(J,"applyEditsToNormalizedContent");function oe(e,t,o,n=4){return L.createTwoFilesPatch(e,e,t,o,void 0,void 0,{context:n,headerOptions:L.FILE_HEADERS_ONLY})}f(oe,"generateUnifiedPatch");function ie(e,t,o=4){const n=String(Math.max($(e),$(t))).length,{output:c,firstChangedLine:s}=M(L.diffLines(e,t),1,1,n,o);return{diff:c.join(`
|
|
17
|
+
`),firstChangedLine:s}}f(ie,"generateDiffString");function $(e){return I(e,0,e.length)+1}f($,"countLines");function I(e,t,o){let n=0;for(let c=e.indexOf(`
|
|
18
|
+
`,t);c!==-1&&c<o;c=e.indexOf(`
|
|
19
|
+
`,c+1))n++;return n}f(I,"countLineFeeds");function M(e,t,o,n,c){const s=[];let l=t,r=o,u=!1,a;for(let h=0;h<e.length;h++){const i=e[h],d=i.value.split(`
|
|
20
|
+
`);if(d[d.length-1]===""&&d.pop(),i.added||i.removed){a===void 0&&(a=r);for(const g of d)if(i.added){const m=String(r).padStart(n," ");s.push(`+${m} ${g}`),r++}else{const m=String(l).padStart(n," ");s.push(`-${m} ${g}`),l++}u=!0}else{const g=h<e.length-1&&(e[h+1].added||e[h+1].removed),m=u,w=g;if(m&&w)if(d.length<=c*2)for(const p of d){const x=String(l).padStart(n," ");s.push(` ${x} ${p}`),l++,r++}else{const p=d.slice(0,c),x=d.slice(d.length-c),E=d.length-p.length-x.length;for(const S of p){const F=String(l).padStart(n," ");s.push(` ${F} ${S}`),l++,r++}s.push(` ${"".padStart(n," ")} ...`),l+=E,r+=E;for(const S of x){const F=String(l).padStart(n," ");s.push(` ${F} ${S}`),l++,r++}}else if(m){const p=d.slice(0,c),x=d.length-p.length;for(const E of p){const S=String(l).padStart(n," ");s.push(` ${S} ${E}`),l++,r++}x>0&&(s.push(` ${"".padStart(n," ")} ...`),l+=x,r+=x)}else if(w){const p=Math.max(0,d.length-c);p>0&&(s.push(` ${"".padStart(n," ")} ...`),l+=p,r+=p);for(const x of d.slice(p)){const E=String(l).padStart(n," ");s.push(` ${E} ${x}`),l++,r++}}else l+=d.length,r+=d.length;u=!1}}return{output:s,firstChangedLine:a}}f(M,"formatDisplayDiff");const R=32;function Q(e,t,o,n,c=4){const s=String(Math.max($(t),$(o))).length,l=` ${"".padStart(s," ")} ...`,r=[],u=[];let a;for(const i of V(t,n)){const d=t.slice(i.oldStart,i.oldEnd),g=o.slice(i.newStart,i.newEnd),m=M(L.diffLines(d,g),i.oldLine+1,i.newLine+1,s,c);a??=m.firstChangedLine,r.at(-1)===l&&m.output[0]===l&&m.output.shift();for(const p of m.output)r.push(p);const w=L.structuredPatch(e,e,d,g,void 0,void 0,{context:c});for(const p of w.hunks)u.push({...p,oldStart:p.oldStart+i.oldLine,newStart:p.newStart+i.newLine})}const h=L.formatPatch({oldFileName:e,newFileName:e,oldHeader:void 0,newHeader:void 0,hunks:u},L.FILE_HEADERS_ONLY);return{diff:r.join(`
|
|
21
|
+
`),patch:h,firstChangedLine:a}}f(Q,"generateEditDiff");function N(e,t){return t===0?0:e.lastIndexOf(`
|
|
22
|
+
`,t-1)+1}f(N,"lineStartBefore");function V(e,t){const o=[];let n=0,c=0,s=0,l=0;for(const r of t){const u=r.matchIndex+r.matchLength;let a=N(e,r.matchIndex);for(let m=0;m<R&&a>0;m++)a=N(e,a-1);let h=u;for(let m=0;m<=R&&h<e.length;m++){const w=e.indexOf(`
|
|
23
|
+
`,m===0?Math.max(u-1,r.matchIndex):h);h=w===-1?e.length:w+1}const i=r.newText.length-r.matchLength,d=I(r.newText,0,r.newText.length)-I(e,r.matchIndex,u),g=o.at(-1);g&&a<=g.oldEnd?(g.oldEnd=Math.max(g.oldEnd,h),g.newEnd=g.oldEnd+n+i):(l+=I(e,s,a),s=a,o.push({oldStart:a,oldEnd:h,oldLine:l,newStart:a+n,newEnd:h+n+i,newLine:l+c})),n+=i,c+=d}return o}f(V,"getDiffWindows");async function X(e,t,o){const n=_(e,o);try{try{await C(n,v.R_OK)}catch(d){const g=d instanceof Error&&"code"in d?`Error code: ${d.code}`:String(d);return{error:`Could not edit file: ${e}. ${g}.`}}const c=await A(n,"utf-8"),{text:s}=P(c),l=z(s),{baseContent:r,newContent:u,replacements:a}=J(l,t,e),{diff:h,firstChangedLine:i}=Q(e,r,u,a);return{diff:h,firstChangedLine:i}}catch(c){return{error:c instanceof Error?c.message:String(c)}}}f(X,"computeEditsDiff");async function se(e,t,o,n){return X(e,[{oldText:t,newText:o}],n)}f(se,"computeEditDiff");export{J as applyEditsToNormalizedContent,re as applyReplacementsToOriginal,se as computeEditDiff,X as computeEditsDiff,D as fuzzyFindText,ie as generateDiffString,Q as generateEditDiff,oe as generateUnifiedPatch,T as normalizeForFuzzyMatch,z as normalizeToLF};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
1
|
import { Box } from "@earendil-works/pi-tui";
|
|
3
2
|
import { type Static, Type } from "typebox";
|
|
4
3
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
5
4
|
import { type EditDiffError, type EditDiffResult } from "./edit-diff.ts";
|
|
5
|
+
import { type TypeBoxAgentTool } from "./tool-definition-wrapper.ts";
|
|
6
6
|
type EditPreview = EditDiffResult | EditDiffError;
|
|
7
7
|
type EditRenderState = {
|
|
8
8
|
callComponent?: EditCallRenderComponent;
|
|
@@ -16,7 +16,7 @@ declare const editSchema: Type.TObject<{
|
|
|
16
16
|
}>;
|
|
17
17
|
export declare const editToolSystemPromptContribution: {
|
|
18
18
|
readonly snippet: "Make precise file edits with exact text replacement, including multiple disjoint edits in one call";
|
|
19
|
-
readonly guidelines: readonly ["Use edit for
|
|
19
|
+
readonly guidelines: readonly ["Use edit for targeted changes. Batch changes to one file in a single call.", "Each edits[].oldText must exactly and uniquely match the original file. Keep matches short and non-overlapping; merge nearby changes without including large unchanged regions."];
|
|
20
20
|
};
|
|
21
21
|
export type EditToolInput = Static<typeof editSchema>;
|
|
22
22
|
export interface EditToolDetails {
|
|
@@ -39,5 +39,5 @@ type EditCallRenderComponent = Box & {
|
|
|
39
39
|
settledError?: boolean;
|
|
40
40
|
};
|
|
41
41
|
export declare function createEditToolDefinition(cwd: string, options?: EditToolOptions): ToolDefinition<typeof editSchema, EditToolDetails | undefined, EditRenderState>;
|
|
42
|
-
export declare function createEditTool(cwd: string, options?: EditToolOptions):
|
|
42
|
+
export declare function createEditTool(cwd: string, options?: EditToolOptions): TypeBoxAgentTool<typeof editSchema>;
|
|
43
43
|
export {};
|
package/dist/core/tools/edit.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`))r.startsWith("+")&&!r.startsWith("+++")&&t++,r.startsWith("-")&&!r.startsWith("---")&&i++;return{additions:t,removals:i}}d(
|
|
3
|
-
`);return!c||c===o?void 0:r.fg("error",c)}const s=i.details?.diff;if(s&&s!==n)return S(s,{filePath:a??void 0})}d(
|
|
1
|
+
var $=Object.defineProperty;var d=(e,t)=>$(e,"name",{value:t,configurable:!0});import{Box as b,Container as W,Spacer as x,Text as E}from"@earendil-works/pi-tui";import{constants as A}from"fs";import{access as L,readFile as k,writeFile as q}from"fs/promises";import{Type as g}from"typebox";import{renderDiff as S}from"../../modes/interactive/components/diff.js";import{splitBom as N}from"../../utils/text.js";import{applyEditsToNormalizedContent as z,applyReplacementsToOriginal as J,computeEditsDiff as M,generateEditDiff as U,normalizeToLF as G}from"./edit-diff.js";import{withFileMutationQueue as H}from"./file-mutation-queue.js";import{resolveToCwd as Q}from"./path-utils.js";import{renderToolPath as X,str as P}from"./render-utils.js";import{wrapToolDefinition as V}from"./tool-definition-wrapper.js";const Y=g.Object({oldText:g.String({description:"Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call."}),newText:g.String({description:"Replacement text for this targeted edit."})},{}),Z=g.Object({path:g.String({description:"Path to the file to edit (relative or absolute)"}),edits:g.Array(Y,{description:"One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead."})},{}),D={snippet:"Make precise file edits with exact text replacement, including multiple disjoint edits in one call",guidelines:["Use edit for targeted changes. Batch changes to one file in a single call.","Each edits[].oldText must exactly and uniquely match the original file. Keep matches short and non-overlapping; merge nearby changes without including large unchanged regions."]};function O(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.oldText=="string"&&typeof t.newText=="string"}d(O,"isSingleEditInput");const ee={readFile:d(e=>k(e),"readFile"),writeFile:d((e,t)=>q(e,t,"utf-8"),"writeFile"),access:d(e=>L(e,A.R_OK|A.W_OK),"access")};function te(e){if(!e||typeof e!="object")return e;const t=e;if(typeof t.edits=="string")try{const o=JSON.parse(t.edits);Array.isArray(o)?t.edits=o:O(o)&&(t.edits=[o])}catch{}else O(t.edits)&&(t.edits=[t.edits]);const i=t;if(typeof i.oldText!="string"||typeof i.newText!="string")return t;const r=Array.isArray(i.edits)?[...i.edits]:[];r.push({oldText:i.oldText,newText:i.newText});const{oldText:f,newText:a,...n}=i;return{...n,edits:r}}d(te,"prepareEditArguments");function re(e){if(!Array.isArray(e.edits)||e.edits.length===0)throw new Error("Edit tool input is invalid. edits must contain at least one replacement.");return{path:e.path,edits:e.edits}}d(re,"validateEditInput");function ie(){return Object.assign(new b(0,0),{preview:void 0,previewArgsKey:void 0,previewPending:!1,settledError:!1})}d(ie,"createEditCallRenderComponent");function ne(e,t){if(t instanceof b){const r=t;return e.callComponent=r,r}if(e.callComponent)return e.callComponent;const i=ie();return e.callComponent=i,i}d(ne,"getEditCallRenderComponent");function F(e){if(!e)return null;const t=typeof e.path=="string"?e.path:typeof e.file_path=="string"?e.file_path:null;return t?Array.isArray(e.edits)&&e.edits.length>0&&e.edits.every(i=>typeof i?.oldText=="string"&&typeof i?.newText=="string")?{path:t,edits:e.edits}:typeof e.oldText=="string"&&typeof e.newText=="string"?{path:t,edits:[{oldText:e.oldText,newText:e.newText}]}:null:null}d(F,"getRenderablePreviewInput");function oe(e){let t=0,i=0;for(const r of e.split(`
|
|
2
|
+
`))r.startsWith("+")&&!r.startsWith("+++")&&t++,r.startsWith("-")&&!r.startsWith("---")&&i++;return{additions:t,removals:i}}d(oe,"diffStats");function se(e,t,i){const r=X(P(e?.file_path??e?.path),t,i);return`${t.fg("toolTitle",t.bold("edit"))} ${r}`}d(se,"formatEditCall");function de(e,t,i,r,f){const a=P(e?.file_path??e?.path),n=t&&!("error"in t)?t.diff:void 0,o=t&&"error"in t?t.error:void 0;if(f){const c=i.content.filter(l=>l.type==="text").map(l=>l.text||"").join(`
|
|
3
|
+
`);return!c||c===o?void 0:r.fg("error",c)}const s=i.details?.diff;if(s&&s!==n)return S(s,{filePath:a??void 0})}d(de,"formatEditResult");function ae(e,t,i){return e?"error"in e?r=>i.bg("toolErrorBg",r):r=>i.bg("toolSuccessBg",r):t?r=>i.bg("toolErrorBg",r):r=>i.bg("toolPendingBg",r)}d(ae,"getEditHeaderBg");function K(e,t,i,r,f,a){e.setPaddingX(a),e.setBgFn("error"in(e.preview??{})||e.settledError?ae(e.preview,e.settledError,i):void 0),e.clear();let n=se(t,i,r);if(!f&&e.preview&&!("error"in e.preview)){const{additions:s,removals:c}=oe(e.preview.diff);n+=i.fg("muted",` +${s} / -${c}`)}if(e.addChild(new E(n,0,0)),!e.preview||!f&&!("error"in e.preview))return e;const o="error"in e.preview?i.fg("error",e.preview.error):S(e.preview.diff);return e.addChild(new x(1)),e.addChild(new E(o,0,0)),e}d(K,"buildEditCallComponent");function _(e,t,i){const r=e.preview,f=r===void 0||("error"in r&&"error"in t?r.error!==t.error:"error"in r!="error"in t)||!("error"in r)&&!("error"in t)&&(r.diff!==t.diff||r.firstChangedLine!==t.firstChangedLine);return e.preview=t,e.previewArgsKey=i,e.previewPending=!1,f}d(_,"setEditPreview");function le(e,t){const i=t?.operations??ee;return{name:"edit",label:"edit",description:"Edit a single file using exact text replacement. Every edits[].oldText must match a unique, non-overlapping region of the original file. If two changes affect the same block or nearby lines, merge them into one edit instead of emitting overlapping edits. Do not include large unchanged regions just to connect distant changes.",promptSnippet:D.snippet,promptGuidelines:[...D.guidelines],parameters:Z,constrainedSampling:{type:"json_schema",strict:"prefer"},renderShell:"self",prepareArguments:te,async execute(r,f,a,n,o){const{path:s,edits:c}=re(f),l=Q(s,o?.cwd||e);return H(l,async()=>{const p=d(()=>{if(a?.aborted)throw new Error("Operation aborted")},"throwIfAborted");p();try{await i.access(l)}catch(y){p();const B=y instanceof Error&&"code"in y?`Error code: ${y.code}`:String(y);throw new Error(`Could not edit file: ${s}. ${B}.`)}p();const w=(await i.readFile(l)).toString("utf-8");p();const{bom:u,text:m}=N(w),T=G(m),{baseContent:I,newContent:C,replacements:v}=z(T,c,s),R=U(s,I,C,v);p();const j=u+(m===T?C:J(m,v));return await i.writeFile(l,j),p(),{content:[{type:"text",text:`Successfully replaced ${c.length} block(s) in ${s}.`}],details:R}})},renderCall(r,f,a){const n=ne(a.state,a.lastComponent),o=F(r),s=o?JSON.stringify({path:o.path,edits:o.edits}):void 0;if(n.previewArgsKey!==s&&(n.preview=void 0,n.previewArgsKey=s,n.previewPending=!1,n.settledError=!1),a.argsComplete&&o&&!n.preview&&!n.previewPending){n.previewPending=!0;const c=s;M(o.path,o.edits,a.cwd).then(l=>{n.previewArgsKey===c&&(_(n,l,c),a.invalidate())})}return K(n,r,f,a.cwd,a.expanded,a.outputPad)},renderResult(r,f,a,n){const o=n.state.callComponent,s=F(n.args),c=s?JSON.stringify({path:s.path,edits:s.edits}):void 0,l=r,p=n.isError?void 0:l.details?.diff;let h=!1;o&&(typeof p=="string"&&(h=_(o,{diff:p,firstChangedLine:l.details?.firstChangedLine},c)||h),o.settledError!==n.isError&&(o.settledError=n.isError,h=!0),h&&K(o,n.args,a,n.cwd,f.expanded,n.outputPad));const w=de(n.args,o?.preview,l,a,n.isError),u=n.lastComponent??new W;return u.clear(),w&&(u.addChild(new x(1)),u.addChild(new E(w,1+n.outputPad,0))),u}}}d(le,"createEditToolDefinition");function ve(e,t){return V(le(e,t))}d(ve,"createEditTool");export{ve as createEditTool,le as createEditToolDefinition,D as editToolSystemPromptContribution};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import { type Static, Type } from "typebox";
|
|
4
3
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
4
|
+
import { type TypeBoxAgentTool } from "./tool-definition-wrapper.ts";
|
|
5
5
|
import { type TruncationResult } from "./truncate.ts";
|
|
6
6
|
export declare function relativizeFindResultPath(resultPath: string, searchPath: string, pathModule?: path.PlatformPath): string;
|
|
7
7
|
declare const findSchema: Type.TObject<{
|
|
@@ -29,5 +29,5 @@ export interface FindToolOptions {
|
|
|
29
29
|
operations?: FindOperations;
|
|
30
30
|
}
|
|
31
31
|
export declare function createFindToolDefinition(cwd: string, options?: FindToolOptions): ToolDefinition<typeof findSchema, FindToolDetails | undefined>;
|
|
32
|
-
export declare function createFindTool(cwd: string, options?: FindToolOptions):
|
|
32
|
+
export declare function createFindTool(cwd: string, options?: FindToolOptions): TypeBoxAgentTool<typeof findSchema>;
|
|
33
33
|
export {};
|
package/dist/core/tools/find.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),
|
|
3
|
-
${l.map(
|
|
4
|
-
`)}`,
|
|
5
|
-
${E(
|
|
6
|
-
${
|
|
7
|
-
`),
|
|
1
|
+
var rt=Object.defineProperty;var h=(t,r)=>rt(t,"name",{value:r,configurable:!0});import{createInterface as it}from"node:readline";import{Text as j}from"@earendil-works/pi-tui";import{spawn as ot}from"child_process";import{Minimatch as st}from"minimatch";import B from"path";import{Type as v}from"typebox";import{fill as E,t as w}from"../../dal/i18n.js";import{keyHint as at}from"../../modes/interactive/components/keybinding-hints.js";import{ensureTool as lt}from"../../utils/tools-manager.js";import{readAccessDenial as ut}from"../permissions/tool-policy.js";import{pathExists as J,resolveToCwd as ct}from"./path-utils.js";import{countOutputLines as dt,formatCollapsedSummary as ft,getTextOutput as Q,invalidArgText as pt,shortenPath as mt,str as V}from"./render-utils.js";import{wrapToolDefinition as ht}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as A,formatSize as D,truncateHead as Z}from"./truncate.js";function tt(t,r,n=B){const d=t.endsWith(n.sep)||n.sep==="\\"&&t.endsWith("/"),a=(n.isAbsolute(t)?n.relative(r,t):t).split(n.sep).join("/");return d&&!a.endsWith("/")?`${a}/`:a}h(tt,"relativizeFindResultPath");const bt=v.Object({pattern:v.String({description:"Glob pattern to match files, e.g. '*.ts', '**/*.json', or 'src/**/*.spec.ts'"}),path:v.Optional(v.String({description:"Directory to search in (default: current directory)"})),limit:v.Optional(v.Number({description:"Maximum number of results (default: 1000)"}))}),gt={snippet:"Find files by glob pattern (respects .gitignore)",guidelines:[]},et=1e3,wt={exists:J,glob:h(()=>[],"glob")};function xt(t,r){const n=V(t?.pattern),d=V(t?.path),c=d!==null?mt(d||"."):null,a=t?.limit,o=pt(r);let e=r.fg("toolTitle",r.bold("find"))+" "+(n===null?o:r.fg("accent",n||""))+r.fg("toolOutput",E(w(" \u4F4D\u4E8E {path}"),{path:c===null?o:c}));return a!==void 0&&(e+=r.fg("toolOutput",E(w(" (\u4E0A\u9650 {limit})"),{limit:a}))),e}h(xt,"formatFindCall");function Et(t,r,n,d,c){if(!r.expanded&&!c){const f=dt(Q(t,d));return ft(n,f>0?[E(w("{count} \u884C"),{count:f})]:[])}const a=Q(t,d).trim();let o="";if(a){const f=a.split(`
|
|
2
|
+
`),x=r.expanded?f.length:20,l=f.slice(0,x),S=f.length-x;o+=`
|
|
3
|
+
${l.map(y=>n.fg("toolOutput",y)).join(`
|
|
4
|
+
`)}`,S>0&&(o+=`${n.fg("muted",`
|
|
5
|
+
${E(w("... (\u8FD8\u6709 {count} \u884C\uFF0C"),{count:S})}`)} ${at("app.tools.expand",w("\u5373\u53EF\u5C55\u5F00"))}${n.fg("muted",")")}`)}const e=t.details?.resultLimitReached,F=t.details?.truncation;if(e||F?.truncated){const f=[];e&&f.push(E(w("\u4E0A\u9650 {count} \u4E2A\u7ED3\u679C"),{count:e})),F?.truncated&&f.push(E(w("\u4E0A\u9650 {size}"),{size:D(F.maxBytes??A)})),o+=`
|
|
6
|
+
${n.fg("warning",E(w("[\u5DF2\u622A\u65AD\uFF1A{reasons}]"),{reasons:f.join(", ")}))}`}return o}h(Et,"formatFindResult");function yt(t,r){const n=r?.operations;return{name:"find",label:"find",description:`Search for files by glob pattern. Returns matching file paths relative to the search directory. Respects .gitignore. Output is truncated to ${et} results or ${A/1024}KB (whichever is hit first).`,promptSnippet:gt.snippet,parameters:bt,async execute(d,{pattern:c,path:a,limit:o},e,F,f){return new Promise((x,l)=>{if(e?.aborted){l(new Error("Operation aborted"));return}let S=!1,y;const s=h(u=>{S||(S=!0,e?.removeEventListener("abort",I),y=void 0,u())},"settle"),I=h(()=>{y?.(),s(()=>l(new Error("Operation aborted")))},"onAbort");e?.addEventListener("abort",I,{once:!0}),(async()=>{try{const u=ct(a||".",f?.cwd||t),p=Math.max(1,Math.floor(o??et)),M=n??wt,W=n?void 0:ut(u);if(W){s(()=>l(new Error(W)));return}if(n?.glob){if(!await M.exists(u)){s(()=>l(new Error(`Path not found: ${u}`)));return}if(e?.aborted){s(()=>l(new Error("Operation aborted")));return}const i=await M.glob(c,u,{ignore:["**/node_modules/**","**/.git/**"],limit:p+1});if(e?.aborted){s(()=>l(new Error("Operation aborted")));return}if(i.length===0){s(()=>x({content:[{type:"text",text:"No files found matching pattern"}],details:void 0}));return}const m=i.length>p,T=i.slice(0,p).map(nt=>tt(nt,u)).join(`
|
|
7
|
+
`),g=Z(T,{maxLines:Number.MAX_SAFE_INTEGER});let P=g.content;const _={},k=[];m&&(k.push(`${p} results limit reached`),_.resultLimitReached=p),g.truncated&&(k.push(`${D(A)} limit reached`),_.truncation=g),k.length>0&&(P+=`
|
|
8
8
|
|
|
9
|
-
[${
|
|
10
|
-
`);
|
|
11
|
-
`),$=Q(R,{maxLines:Number.MAX_SAFE_INTEGER});let x=$.content;const h={},y=[];k&&(y.push(`${f} results limit reached. Use limit=${f*2} for more, or refine pattern`),h.resultLimitReached=f),$.truncated&&(y.push(`${D(C)} limit reached`),h.truncation=$),y.length>0&&(x+=`
|
|
9
|
+
[${k.join(". ")}]`),s(()=>x({content:[{type:"text",text:P}],details:Object.keys(_).length>0?_:void 0}));return}const G=await lt("fd");if(e?.aborted){s(()=>l(new Error("Operation aborted")));return}if(!G){s(()=>l(new Error("fd is not available and could not be downloaded")));return}const O=["--color=never","--hidden"];let U=!1;for(let i=u;;){if(await J(B.join(i,".git"))){U=!0;break}const m=B.dirname(i);if(m===i)break;i=m}U||O.push("--no-require-git");let b=process.platform==="win32"?c.replaceAll("\\","/"):c;const N=b.includes("/");N&&!b.startsWith("/")&&!b.startsWith("**/")&&b!=="**"&&(b=`**/${b}`);const C=process.platform==="win32"&&N?new st(b.replace(/\/\*\*$/,"/**/*"),{dot:!0,noext:!0,nocase:b===b.toLowerCase()}):void 0;if(C?O.push("--","",u):(O.push("--glob","--max-results",String(p+1)),N&&O.push("--full-path"),O.push("--",b,u)),e?.aborted)return;const $=ot(G,O,{stdio:["ignore","pipe","pipe"]}),X=it({input:$.stdout});let H="";const q=[];let R=0,z=0,K=!1;y=h(()=>{$.killed||$.kill()},"stopChild");const Y=h(()=>{X.close()},"cleanup");$.stderr?.on("data",i=>{H+=i.toString()}),X.on("line",i=>{const m=i.replace(/\r$/,"").trim();if(!m||C&&!C.match(m))return;if(R===p){K=!0,C&&y?.();return}const L=tt(m,u);R++,z-1<=A&&q.push(L),z+=Buffer.byteLength(L,"utf-8")+1}),$.on("error",i=>{Y(),s(()=>l(new Error(`Failed to run fd: ${i.message}`)))}),$.on("close",i=>{if(Y(),e?.aborted){s(()=>l(new Error("Operation aborted")));return}if(i!==0&&R===0){const P=H.trim()||`fd exited with code ${i}`;s(()=>l(new Error(P)));return}if(R===0){s(()=>x({content:[{type:"text",text:"No files found matching pattern"}],details:void 0}));return}const m={...Z(q.join(`
|
|
10
|
+
`),{maxLines:Number.MAX_SAFE_INTEGER}),totalLines:R,totalBytes:z-1};let L=m.content;const T={},g=[];K&&(g.push(`${p} results limit reached. Use limit=${p*2} for more, or refine pattern`),T.resultLimitReached=p),m.truncated&&(g.push(`${D(A)} limit reached`),T.truncation=m),g.length>0&&(L+=`
|
|
12
11
|
|
|
13
|
-
[${
|
|
12
|
+
[${g.join(". ")}]`),s(()=>x({content:[{type:"text",text:L}],details:Object.keys(T).length>0?T:void 0}))})}catch(u){if(e?.aborted){s(()=>l(new Error("Operation aborted")));return}const p=u instanceof Error?u:new Error(String(u));s(()=>l(p))}})()})},renderCall(d,c,a){const o=a.lastComponent??new j("",0,0);return o.setText(xt(d,c)),o},renderResult(d,c,a,o){const e=o.lastComponent??new j("",0,0);return e.setText(Et(d,c,a,o.showImages,o.isError)),e}}}h(yt,"createFindToolDefinition");function Bt(t,r){return ht(yt(t,r))}h(Bt,"createFindTool");export{Bt as createFindTool,yt as createFindToolDefinition,gt as findToolSystemPromptContribution,tt as relativizeFindResultPath};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
1
|
import { type Static, Type } from "typebox";
|
|
3
2
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
3
|
+
import { type TypeBoxAgentTool } from "./tool-definition-wrapper.ts";
|
|
4
4
|
import { type TruncationResult } from "./truncate.ts";
|
|
5
5
|
declare const grepSchema: Type.TObject<{
|
|
6
6
|
pattern: Type.TString;
|
|
@@ -23,11 +23,11 @@ export interface GrepToolDetails {
|
|
|
23
23
|
}
|
|
24
24
|
export interface GrepOperations {
|
|
25
25
|
isDirectory: (absolutePath: string) => Promise<boolean> | boolean;
|
|
26
|
-
readFile
|
|
26
|
+
readFile?: (absolutePath: string) => Promise<string> | string;
|
|
27
27
|
}
|
|
28
28
|
export interface GrepToolOptions {
|
|
29
29
|
operations?: GrepOperations;
|
|
30
30
|
}
|
|
31
31
|
export declare function createGrepToolDefinition(cwd: string, options?: GrepToolOptions): ToolDefinition<typeof grepSchema, GrepToolDetails | undefined>;
|
|
32
|
-
export declare function createGrepTool(cwd: string, options?: GrepToolOptions):
|
|
32
|
+
export declare function createGrepTool(cwd: string, options?: GrepToolOptions): TypeBoxAgentTool<typeof grepSchema>;
|
|
33
33
|
export {};
|
package/dist/core/tools/grep.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
var gt=Object.defineProperty;var
|
|
2
|
-
`),
|
|
3
|
-
${U.map(
|
|
4
|
-
`)}`,
|
|
5
|
-
${C(
|
|
6
|
-
${
|
|
7
|
-
`).
|
|
8
|
-
`).split(`
|
|
9
|
-
`)}catch{t=[]}W.set(e,t)}return t},"getFileLines"),_=["--no-config","--json","--line-number","--color=never","--hidden"];u&&_.push("--ignore-case"),x&&_.push("--fixed-strings"),r&&_.push("--glob",r),_.push("--",m,S);const v=$t(E,_,{stdio:["ignore","pipe","pipe"]}),Y=wt({input:v.stdout});let j="",A=0,q=!1,R=!1,Q=!1,Z=!1;const k=[],tt=i(()=>{Y.close(),O?.removeEventListener("abort",nt)},"cleanup"),et=i((e=!1)=>{v.killed||(Z=e,v.kill())},"stopChild"),nt=i(()=>{Q=!0,et()},"onAbort");O?.addEventListener("abort",nt,{once:!0}),v.stderr?.on("data",e=>{j+=e.toString()});const mt=i(async(e,t)=>{const c=V(e),w=await dt(e);if(!w.length)return[`${c}:${t}: (unable to read file)`];const f=[],y=D>0?Math.max(1,t-D):t,h=D>0?Math.min(w.length,t+D):t;for(let g=y;g<=h;g++){const G=(w[g-1]??"").replace(/\r/g,""),N=g===t,{text:it,wasTruncated:ht}=ut(G);ht&&(R=!0),N?f.push(`${c}:${g}: ${it}`):f.push(`${c}-${g}- ${it}`)}return f},"formatBlock"),rt=[];Y.on("line",e=>{if(!e.trim()||A>=M)return;let t;try{t=JSON.parse(e)}catch{return}if(t.type==="match"){A++;const c=t.data?.path?.text,w=t.data?.line_number,f=t.data?.lines?.text;if(c&&!l&&st(B.resolve(S,c))){A--;return}c&&typeof w=="number"&&rt.push({filePath:c,lineNumber:w,lineText:f}),A>=M&&(q=!0,et(!0))}}),v.on("error",e=>{tt(),T(()=>$(new Error(`Failed to run ripgrep: ${e.message}`)))}),v.on("close",async e=>{if(tt(),Q){T(()=>$(new Error("Operation aborted")));return}if(!Z&&e!==0&&e!==1){const h=j.trim()||`ripgrep exited with code ${e}`;T(()=>$(new Error(h)));return}if(A===0){T(()=>P({content:[{type:"text",text:"No matches found"}],details:void 0}));return}for(const h of rt)if(D===0&&h.lineText!==void 0){const g=V(h.filePath),ot=h.lineText.replace(/\r\n/g,`
|
|
10
|
-
`).replace(/\r/g,"").replace(/\n$/,""),{text:G,wasTruncated:N}=ut(ot);N&&(R=!0),k.push(`${g}:${h.lineNumber}: ${G}`)}else{const g=await mt(h.filePath,h.lineNumber);k.push(...g)}const t=k.join(`
|
|
11
|
-
`),c=Dt(t,{maxLines:Number.MAX_SAFE_INTEGER});let w=c.content;const f={},y=[];q&&(y.push(`${M} matches limit reached. Use limit=${M*2} for more, or refine pattern`),f.matchLimitReached=M),c.truncated&&(y.push(`${lt(z)} limit reached`),f.truncation=c),R&&(y.push(`Some lines truncated to ${pt} chars. Use read tool to see full lines`),f.linesTruncated=!0),y.length>0&&(w+=`
|
|
1
|
+
var gt=Object.defineProperty;var s=(t,r)=>gt(t,"name",{value:r,configurable:!0});import{stat as xt}from"node:fs/promises";import{createInterface as bt}from"node:readline";import{Text as it}from"@earendil-works/pi-tui";import{spawn as yt}from"child_process";import N from"path";import{Type as a}from"typebox";import{fill as C,t as T}from"../../dal/i18n.js";import{keyHint as wt}from"../../modes/interactive/components/keybinding-hints.js";import{ensureTool as Tt}from"../../utils/tools-manager.js";import{readAccessDenial as st}from"../permissions/tool-policy.js";import{resolveToCwd as $t}from"./path-utils.js";import{countOutputLines as Lt,formatCollapsedSummary as Et,getTextOutput as at,invalidArgText as Ot,shortenPath as St,str as k}from"./render-utils.js";import{wrapToolDefinition as vt}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as R,formatSize as lt,GREP_MAX_LINE_LENGTH as ct,truncateHead as Ct,truncateLine as At}from"./truncate.js";const _t=a.Object({pattern:a.String({description:"Search pattern (regex or literal string)"}),path:a.Optional(a.String({description:"Directory or file to search (default: current directory)"})),glob:a.Optional(a.String({description:"Filter files by glob pattern, relative to path, e.g. '*.ts', 'src/**/*.ts' or '**/*.spec.ts'. A pattern without '/' matches file names at any depth"})),ignoreCase:a.Optional(a.Boolean({description:"Case-insensitive search (default: false)"})),literal:a.Optional(a.Boolean({description:"Treat pattern as literal string instead of regex (default: false)"})),context:a.Optional(a.Number({description:"Number of lines to show before and after each match (default: 0)"})),limit:a.Optional(a.Number({description:"Maximum number of matches to return (default: 100)"}))}),Mt={snippet:"Search file contents for patterns (respects .gitignore)",guidelines:[]},ut=100,Dt={isDirectory:s(async t=>(await xt(t)).isDirectory(),"isDirectory")};function pt(t){return typeof t?.text=="string"?t.text:typeof t?.bytes=="string"?Buffer.from(t.bytes,"base64").toString("utf-8"):""}s(pt,"decodeRgText");function Nt(t,r){const u=k(t?.pattern),d=k(t?.path),m=d!==null?St(d||"."):null,p=k(t?.glob),n=t?.limit,f=Ot(r);let x=r.fg("toolTitle",r.bold("grep"))+" "+(u===null?f:r.fg("accent",`/${u||""}/`))+r.fg("toolOutput",C(T(" \u4F4D\u4E8E {path}"),{path:m===null?f:m}));return p&&(x+=r.fg("toolOutput",` (${p})`)),n!==void 0&&(x+=r.fg("toolOutput",` limit ${n}`)),x}s(Nt,"formatGrepCall");function Rt(t,r,u,d,m){if(!r.expanded&&!m){const l=Lt(at(t,d));return Et(u,l>0?[C(T("{count} \u884C"),{count:l})]:[])}const p=at(t,d).trim();let n="";if(p){const l=p.split(`
|
|
2
|
+
`),E=r.expanded?l.length:15,U=l.slice(0,E),A=l.length-E;n+=`
|
|
3
|
+
${U.map(_=>u.fg("toolOutput",_)).join(`
|
|
4
|
+
`)}`,A>0&&(n+=`${u.fg("muted",`
|
|
5
|
+
${C(T("... (\u8FD8\u6709 {count} \u884C\uFF0C"),{count:A})}`)} ${wt("app.tools.expand",T("\u5373\u53EF\u5C55\u5F00"))}${u.fg("muted",")")}`)}const f=t.details?.matchLimitReached,x=t.details?.truncation,L=t.details?.linesTruncated;if(f||x?.truncated||L){const l=[];f&&l.push(C(T("\u4E0A\u9650 {count} \u5904\u5339\u914D"),{count:f})),x?.truncated&&l.push(C(T("\u4E0A\u9650 {size}"),{size:lt(x.maxBytes??R)})),L&&l.push(T("\u90E8\u5206\u884C\u88AB\u622A\u65AD")),n+=`
|
|
6
|
+
${u.fg("warning",C(T("[\u5DF2\u622A\u65AD\uFF1A{reasons}]"),{reasons:l.join(", ")}))}`}return n}s(Rt,"formatGrepResult");function Bt(t,r){const u=r?.operations;return{name:"grep",label:"grep",description:`Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${ut} matches or ${R/1024}KB (whichever is hit first). Long lines are truncated to ${ct} chars.`,promptSnippet:Mt.snippet,parameters:_t,async execute(d,{pattern:m,path:p,glob:n,ignoreCase:f,literal:x,context:L,limit:l},E,U,A){return new Promise((_,y)=>{if(E?.aborted){y(new Error("Operation aborted"));return}let z=!1;const b=s(O=>{z||(z=!0,O())},"settle");(async()=>{try{const O=await Tt("rg");if(!O){b(()=>y(new Error("ripgrep (rg) is not available and could not be downloaded")));return}const w=$t(p||".",A?.cwd||t),ft=u??Dt,H=u?void 0:st(w);if(H){b(()=>y(new Error(H)));return}let M;try{M=await ft.isDirectory(w)}catch{b(()=>y(new Error(`Path not found: ${w}`)));return}const B=L&&L>0?Math.min(Math.floor(L),Number.MAX_SAFE_INTEGER):0,D=Math.max(1,Math.floor(l??ut)),dt=s(e=>{if(M){const o=N.relative(w,N.resolve(w,e));if(o&&!o.startsWith(".."))return o.replace(/\\/g,"/")}return N.basename(e)},"formatPath"),S=["--no-config","--json","--line-number","--color=never","--hidden"];f&&S.push("--ignore-case"),x&&S.push("--fixed-strings"),n&&S.push("--glob",n.replace(/^(!?)(?:\.\/)+/,"$1")),B>0&&S.push("--context",String(B)),S.push("--",m,M?".":w);const v=yt(O,S,{cwd:M?w:void 0,stdio:["ignore","pipe","pipe"]}),X=bt({input:v.stdout});let W="",G=0,P=!1,J=!1,K=!1,V=!1;const Y=[],j=s(()=>{X.close(),E?.removeEventListener("abort",Q)},"cleanup"),q=s((e=!1)=>{v.killed||(V=e,v.kill())},"stopChild"),Q=s(()=>{K=!0,q()},"onAbort");E?.addEventListener("abort",Q,{once:!0}),v.stderr?.on("data",e=>{W+=e.toString()});let F=0,Z=0,tt,et=!1,I=0,nt=!1;const mt=s(()=>{nt=!0,q(!0)},"finish"),rt=s((e,o,c,h)=>{tt=e;const i=dt(e),g=c.replace(/\r?\n?$/,""),{text:$,wasTruncated:ht}=At(g);ht&&(J=!0);const ot=h?`${i}:${o}: ${$}`:`${i}-${o}- ${$}`;F-1<=R&&Y.push(ot),F+=Buffer.byteLength(ot,"utf-8")+1,Z++},"pushLine");X.on("line",e=>{if(nt||!e.trim())return;let o;try{o=JSON.parse(e)}catch{return}const c=o.type==="match";if(!c&&o.type!=="context")return;const h=pt(o.data?.path),i=o.data?.line_number;if(!h||typeof i!="number")return;const g=pt(o.data?.lines);if(c&&!u&&st(N.resolve(w,h)))return;if(!et){if(rt(h,i,g,c),!c)return;G++,G>=D&&(et=!0,I=i+B);return}const $=h===tt&&i<=I;$&&rt(h,i,g,!1),c&&(P=!0),P&&!($&&i<I)&&mt()}),v.on("error",e=>{j(),b(()=>y(new Error(`Failed to run ripgrep: ${e.message}`)))}),v.on("close",e=>{if(j(),K){b(()=>y(new Error("Operation aborted")));return}if(!V&&e!==0&&e!==1){const $=W.trim()||`ripgrep exited with code ${e}`;b(()=>y(new Error($)));return}if(G===0){b(()=>_({content:[{type:"text",text:"No matches found"}],details:void 0}));return}const o=Y.join(`
|
|
7
|
+
`),c=Ct(o,{maxLines:Number.MAX_SAFE_INTEGER});c.totalLines=Z,c.totalBytes=F-1;let h=c.content;const i={},g=[];P&&(g.push(`${D} matches limit reached. Use limit=${D*2} for more, or refine pattern`),i.matchLimitReached=D),c.truncated&&(g.push(`${lt(R)} limit reached`),i.truncation=c),J&&(g.push(`Some lines truncated to ${ct} chars. Use read tool to see full lines`),i.linesTruncated=!0),g.length>0&&(h+=`
|
|
12
8
|
|
|
13
|
-
[${
|
|
9
|
+
[${g.join(". ")}]`),b(()=>_({content:[{type:"text",text:h}],details:Object.keys(i).length>0?i:void 0}))})}catch(O){b(()=>y(O))}})()})},renderCall(d,m,p){const n=p.lastComponent??new it("",0,0);return n.setText(Nt(d,m)),n},renderResult(d,m,p,n){const f=n.lastComponent??new it("",0,0);return f.setText(Rt(d,m,p,n.showImages,n.isError)),f}}}s(Bt,"createGrepToolDefinition");function qt(t,r){return vt(Bt(t,r))}s(qt,"createGrepTool");export{qt as createGrepTool,Bt as createGrepToolDefinition,Mt as grepToolSystemPromptContribution};
|
package/dist/core/tools/ls.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
1
|
import { type Static, Type } from "typebox";
|
|
3
2
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
3
|
+
import { type TypeBoxAgentTool } from "./tool-definition-wrapper.ts";
|
|
4
4
|
import { type TruncationResult } from "./truncate.ts";
|
|
5
5
|
declare const lsSchema: Type.TObject<{
|
|
6
6
|
path: Type.TOptional<Type.TString>;
|
|
@@ -28,5 +28,5 @@ export interface LsToolOptions {
|
|
|
28
28
|
operations?: LsOperations;
|
|
29
29
|
}
|
|
30
30
|
export declare function createLsToolDefinition(cwd: string, options?: LsToolOptions): ToolDefinition<typeof lsSchema, LsToolDetails | undefined>;
|
|
31
|
-
export declare function createLsTool(cwd: string, options?: LsToolOptions):
|
|
31
|
+
export declare function createLsTool(cwd: string, options?: LsToolOptions): TypeBoxAgentTool<typeof lsSchema>;
|
|
32
32
|
export {};
|
package/dist/core/tools/ls.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
1
|
+
var I=Object.defineProperty;var m=(n,e)=>I(n,"name",{value:e,configurable:!0});import{readdir as k,stat as F}from"node:fs/promises";import{Text as v}from"@earendil-works/pi-tui";import N from"path";import{Type as w}from"typebox";import{fill as y,t as d}from"../../dal/i18n.js";import{keyHint as U}from"../../modes/interactive/components/keybinding-hints.js";import{readAccessDenial as z}from"../permissions/tool-policy.js";import{pathExists as B,resolveToCwd as H}from"./path-utils.js";import{countOutputLines as X,formatCollapsedSummary as j,getTextOutput as A,renderToolPath as G,str as K}from"./render-utils.js";import{wrapToolDefinition as Y}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as O,formatSize as P,truncateHead as q}from"./truncate.js";const J=w.Object({path:w.Optional(w.String({description:"Directory to list (default: current directory)"})),limit:w.Optional(w.Number({description:"Maximum number of entries to return (default: 500)"}))}),Q={snippet:"List directory contents",guidelines:[]},_=500,V={exists:B,stat:F,readdir:k};function W(n,e,o){const a=n?.limit,u=G(K(n?.path),e,o,{emptyFallback:"."});let i=`${e.fg("toolTitle",e.bold("ls"))} ${u}`;return a!==void 0&&(i+=e.fg("toolOutput",y(d(" (\u4E0A\u9650 {limit})"),{limit:a}))),i}m(W,"formatLsCall");function Z(n,e,o,a,u){if(!e.expanded&&!u){const r=X(A(n,a));return j(o,r>0?[y(d("{count} \u884C"),{count:r})]:[])}const i=A(n,a).trim();let t="";if(i){const r=i.split(`
|
|
2
2
|
`),c=e.expanded?r.length:20,x=r.slice(0,c),s=r.length-c;t+=`
|
|
3
|
-
${x.map(
|
|
3
|
+
${x.map(f=>o.fg("toolOutput",f)).join(`
|
|
4
4
|
`)}`,s>0&&(t+=`${o.fg("muted",`
|
|
5
5
|
${y(d("... (\u8FD8\u6709 {count} \u884C\uFF0C"),{count:s})}`)} ${U("app.tools.expand",d("\u5373\u53EF\u5C55\u5F00"))}${o.fg("muted",")")}`)}const l=n.details?.entryLimitReached,h=n.details?.truncation;if(l||h?.truncated){const r=[];l&&r.push(y(d("\u4E0A\u9650 {count} \u4E2A\u6761\u76EE"),{count:l})),h?.truncated&&r.push(y(d("\u4E0A\u9650 {size}"),{size:P(h.maxBytes??O)})),t+=`
|
|
6
|
-
${o.fg("warning",y(d("[\u5DF2\u622A\u65AD\uFF1A{reasons}]"),{reasons:r.join(", ")}))}`}return t}m(Z,"formatLsResult");function tt(n,e){const o=e?.operations??V;return{name:"ls",label:"ls",description:`List directory contents. Returns entries sorted alphabetically, with '/' suffix for directories. Includes dotfiles. Output is truncated to ${_} entries or ${O/1024}KB (whichever is hit first).`,promptSnippet:Q.snippet,parameters:J,async execute(a,{path:u,limit:i},t,l,h){return new Promise((r,c)=>{if(t?.aborted){c(new Error("Operation aborted"));return}const x=m(()=>c(new Error("Operation aborted")),"onAbort");t?.addEventListener("abort",x,{once:!0}),(async()=>{try{const s=H(u||".",h?.cwd||n),
|
|
7
|
-
`),$=q(
|
|
6
|
+
${o.fg("warning",y(d("[\u5DF2\u622A\u65AD\uFF1A{reasons}]"),{reasons:r.join(", ")}))}`}return t}m(Z,"formatLsResult");function tt(n,e){const o=e?.operations??V;return{name:"ls",label:"ls",description:`List directory contents. Returns entries sorted alphabetically, with '/' suffix for directories. Includes dotfiles. Output is truncated to ${_} entries or ${O/1024}KB (whichever is hit first).`,promptSnippet:Q.snippet,parameters:J,async execute(a,{path:u,limit:i},t,l,h){return new Promise((r,c)=>{if(t?.aborted){c(new Error("Operation aborted"));return}const x=m(()=>c(new Error("Operation aborted")),"onAbort");t?.addEventListener("abort",x,{once:!0}),(async()=>{try{const s=H(u||".",h?.cwd||n),f=Math.max(1,Math.floor(i??_)),C=e?.operations?void 0:z(s);if(C){c(new Error(C));return}if(!await o.exists(s)){c(new Error(`Path not found: ${s}`));return}if(!(await o.stat(s)).isDirectory()){c(new Error(`Not a directory: ${s}`));return}let T;try{T=await o.readdir(s)}catch(p){c(new Error(`Cannot read directory: ${p.message}`));return}T.sort((p,g)=>p.toLowerCase().localeCompare(g.toLowerCase()));const L=[];let S=!1;for(const p of T){if(L.length>=f){S=!0;break}const g=N.join(s,p);let R="";try{(await o.stat(g)).isDirectory()&&(R="/")}catch{continue}L.push(p+R)}if(t?.removeEventListener("abort",x),L.length===0){r({content:[{type:"text",text:"(empty directory)"}],details:void 0});return}const M=L.join(`
|
|
7
|
+
`),$=q(M,{maxLines:Number.MAX_SAFE_INTEGER});let D=$.content;const b={},E=[];S&&(E.push(`${f} entries limit reached. Use limit=${f*2} for more`),b.entryLimitReached=f),$.truncated&&(E.push(`${P(O)} limit reached`),b.truncation=$),E.length>0&&(D+=`
|
|
8
8
|
|
|
9
9
|
[${E.join(". ")}]`),r({content:[{type:"text",text:D}],details:Object.keys(b).length>0?b:void 0})}catch(s){t?.removeEventListener("abort",x),c(s)}})()})},renderCall(a,u,i){const t=i.lastComponent??new v("",0,0);return t.setText(W(a,u,i.cwd)),t},renderResult(a,u,i,t){const l=t.lastComponent??new v("",0,0);return l.setText(Z(a,u,i,t.showImages,t.isError)),l}}}m(tt,"createLsToolDefinition");function yt(n,e){return Y(tt(n,e))}m(yt,"createLsTool");export{yt as createLsTool,tt as createLsToolDefinition,Q as lsToolSystemPromptContribution};
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
var p=Object.defineProperty;var
|
|
2
|
-
`,
|
|
1
|
+
var p=Object.defineProperty;var n=(e,o)=>p(e,"name",{value:o,configurable:!0});import{win32 as a}from"node:path";import{getPowerShellConfig as r}from"../../utils/shell.js";import{createLocalShellOperations as c,createShellToolDefinition as m}from"./bash.js";import{wrapToolDefinition as h}from"./tool-definition-wrapper.js";const f=`try { [Console]::OutputEncoding=[System.Text.Encoding]::UTF8 } catch {}
|
|
2
|
+
`,u=`
|
|
3
|
+
;
|
|
4
|
+
if ($?) { exit 0 }
|
|
5
|
+
if (($LASTEXITCODE -eq 0) -and ("$($Error[0].FullyQualifiedErrorId)" -like "NativeCommandError*")) { exit 0 }
|
|
6
|
+
exit 1`,i={snippet:"Execute PowerShell commands",guidelines:["You can inspect DAL_* environment variables for current model and session details."]};function d(){return{exec:n(async(e,o,t)=>{const l=r(),s=a.basename(l.shell).toLowerCase()==="powershell.exe"&&!e.endsWith("`")?u:"";return c("PowerShell",()=>l).exec(`${f}${e}${s}`,o,t)},"exec")}}n(d,"createLocalPowerShellOperations");const S={name:"powershell",label:"powershell",shellName:"PowerShell",prompt:"PS>",promptSnippet:i.snippet,promptGuidelines:i.guidelines,tempFilePrefix:"dal-powershell",defaultOperations:d,sandboxShell:n(()=>process.platform==="win32"?r().shell:"pwsh","sandboxShell"),sandboxShellKind:"powershell"};function w(e,o){return m(e,S,o)}n(w,"createPowerShellToolDefinition");function O(e,o){const t=w(e,o),l=h(t);return Object.assign(l,{promptSnippet:t.promptSnippet,promptGuidelines:t.promptGuidelines}),l}n(O,"createPowerShellTool");export{d as createLocalPowerShellOperations,O as createPowerShellTool,w as createPowerShellToolDefinition,i as powershellToolSystemPromptContribution};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
1
|
import type { ModelImageResizeOptions } from "@earendil-works/pi-ai";
|
|
3
2
|
import { type Static, Type } from "typebox";
|
|
4
3
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
4
|
+
import { type TypeBoxAgentTool } from "./tool-definition-wrapper.ts";
|
|
5
5
|
import { type TruncationResult } from "./truncate.ts";
|
|
6
6
|
declare const readSchema: Type.TObject<{
|
|
7
7
|
path: Type.TString;
|
|
@@ -27,6 +27,9 @@ export interface ReadOperations {
|
|
|
27
27
|
readFile: (absolutePath: string) => Promise<Buffer>;
|
|
28
28
|
access: (absolutePath: string) => Promise<void>;
|
|
29
29
|
detectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;
|
|
30
|
+
createReadStream?: (absolutePath: string, options: {
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}) => AsyncIterable<Uint8Array>;
|
|
30
33
|
}
|
|
31
34
|
export interface ReadToolOptions {
|
|
32
35
|
autoResizeImages?: boolean;
|
|
@@ -34,5 +37,5 @@ export interface ReadToolOptions {
|
|
|
34
37
|
operations?: ReadOperations;
|
|
35
38
|
}
|
|
36
39
|
export declare function createReadToolDefinition(cwd: string, options?: ReadToolOptions): ToolDefinition<typeof readSchema, ReadToolDetails | undefined>;
|
|
37
|
-
export declare function createReadTool(cwd: string, options?: ReadToolOptions):
|
|
40
|
+
export declare function createReadTool(cwd: string, options?: ReadToolOptions): TypeBoxAgentTool<typeof readSchema>;
|
|
38
41
|
export {};
|
package/dist/core/tools/read.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),w=
|
|
3
|
-
${
|
|
4
|
-
`)}`;
|
|
5
|
-
${
|
|
6
|
-
${i.fg("warning",
|
|
7
|
-
${i.fg("warning",
|
|
8
|
-
${i.fg("warning",
|
|
9
|
-
|
|
10
|
-
`)}
|
|
11
|
-
|
|
12
|
-
${x.
|
|
13
|
-
${
|
|
14
|
-
`)
|
|
15
|
-
`),
|
|
16
|
-
|
|
1
|
+
var X=Object.defineProperty;var s=(e,t)=>X(e,"name",{value:t,configurable:!0});import{basename as z,dirname as j,isAbsolute as Y,relative as q,resolve as W,sep as G}from"node:path";import{Text as H}from"@earendil-works/pi-tui";import{constants as J}from"fs";import{access as Q,open as Z,readFile as ee}from"fs/promises";import{Type as b}from"typebox";import{TextDecoder as te}from"util";import{getReadmePath as ne}from"../../config.js";import{fill as _,t as F}from"../../dal/i18n.js";import{keyHint as ie}from"../../modes/interactive/components/keybinding-hints.js";import{getLanguageFromPath as oe,highlightCode as se}from"../../modes/interactive/theme/theme.js";import{processImage as re}from"../../utils/image-process.js";import{detectSupportedImageMimeTypeFromFile as ae}from"../../utils/mime.js";import{formatPathRelativeToCwdOrAbsolute as fe}from"../../utils/paths.js";import{readAccessDenial as le}from"../permissions/tool-policy.js";import{resolveReadPathAsync as de,resolveToCwd as ce}from"./path-utils.js";import{formatReadLineRange as ue,getTextOutput as me,renderToolPath as pe,replaceTabs as k,str as v}from"./render-utils.js";import{wrapToolDefinition as ge}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as $,DEFAULT_MAX_LINES as D,formatSize as P,truncateHead as K}from"./truncate.js";const he=b.Object({path:b.String({description:"Path to the file to read (relative or absolute)"}),offset:b.Optional(b.Number({description:"Line number to start reading from (1-indexed)"})),limit:b.Optional(b.Number({description:"Maximum number of lines to read"}))}),V={snippet:"Read file contents",guidelines:["Use read to examine files instead of cat or sed."]},Le=b.Union([b.String(),b.Object({type:b.Literal("image"),data:b.String(),mimeType:b.String(),note:b.String()})]),ye=new Set(["AGENTS.override.md","AGENTS.md","AGENTS.MD","CLAUDE.md","CLAUDE.MD"]),be={readFile:s(e=>ee(e),"readFile"),createReadStream:we,access:s(e=>Q(e,J.R_OK),"access"),detectImageMimeType:ae};async function*we(e,{signal:t}){const n=await Z(e,"r");try{const i=await n.stat(),f=i.isFile()&&i.size>0?i.size-1:void 0;yield*n.createReadStream({end:f,signal:t,autoClose:!1})}finally{await n.close()}}s(we,"readLocalFileChunks");function U(e,t){const n=ue(e?.offset,e?.limit);return n?t.fg("warning",n):""}s(U,"formatReadLineRange");function Te(e,t,n){const i=pe(v(e?.file_path??e?.path),t,n);return`${t.fg("toolTitle",t.bold("read"))} ${i}${U(e,t)}`}s(Te,"formatReadCall");function xe(e){let t=e.length;for(;t>0&&e[t-1]==="";)t--;return e.slice(0,t)}s(xe,"trimTrailingEmptyLines");function $e(e){const t=e.find(i=>i.type==="text")?.text??"",n=e.find(i=>i.type==="image");return n?{type:"image",data:n.data,mimeType:n.mimeType,note:t}:t}s($e,"toReadOutput");function Re(e){if(!(!e||e.input.includes("image")))return"[Current model does not support images. The image will be omitted from this request.]"}s(Re,"getNonVisionImageNote");function Se(e){return e.split(G).join("/")}s(Se,"toPosixPath");function Ee(e){const t=j(ne()),n=q(W(t),W(e));if(n===""||n===".."||n.startsWith(`..${G}`)||Y(n))return;const i=Se(n);if(i==="README.md"||i.startsWith("docs/")||i.startsWith("dal-docs/")||i.startsWith("examples/"))return{kind:"docs",label:i}}s(Ee,"getPiDocsClassification");function Oe(e,t){const n=v(e?.file_path??e?.path);if(!n)return;const i=ce(n,t),f=z(i);if(f==="SKILL.md")return{kind:"skill",label:z(j(i))||f};const g=Ee(i);if(g)return g;if(ye.has(f))return{kind:"resource",label:fe(i,t)}}s(Oe,"getCompactReadClassification");function Ce(e,t,n){return e.kind==="skill"?n.fg("customMessageLabel","\x1B[1m[skill]\x1B[22m ")+n.fg("customMessageText",e.label)+U(t,n):n.fg("toolTitle",n.bold(`read ${e.kind}`))+" "+n.fg("accent",e.label)+U(t,n)}s(Ce,"formatCompactReadCall");function Ie(e,t,n,i,f,g,u){if(!n.expanded&&!u)return"";const m=v(e?.file_path??e?.path),d=me(t,f),o=!u&&m?oe(m):void 0,C=o?se(k(d),o):d.split(`
|
|
2
|
+
`),w=xe(C),T=n.expanded?w.length:10,x=w.slice(0,T),h=w.length-T;let y=`
|
|
3
|
+
${x.map(R=>o?k(R):i.fg("toolOutput",k(R))).join(`
|
|
4
|
+
`)}`;h>0&&(y+=`${i.fg("muted",`
|
|
5
|
+
${_(F("... (\u8FD8\u6709 {count} \u884C\uFF0C"),{count:h})}`)} ${ie("app.tools.expand",F("\u5373\u53EF\u5C55\u5F00"))}${i.fg("muted",")")}`);const r=t.details?.truncation;return r?.truncated&&(r.firstLineExceedsLimit?y+=`
|
|
6
|
+
${i.fg("warning",_(F("[\u9996\u884C\u8D85\u51FA {limit} \u4E0A\u9650]"),{limit:P(r.maxBytes??$)}))}`:r.truncatedBy==="lines"?y+=`
|
|
7
|
+
${i.fg("warning",_(F("[\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C\uFF08\u4E0A\u9650 {max} \u884C\uFF09]"),{shown:r.outputLines,total:r.totalLines,max:r.maxLines??D}))}`:y+=`
|
|
8
|
+
${i.fg("warning",_(F("[\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09]"),{shown:r.outputLines,limit:P(r.maxBytes??$)}))}`),y}s(Ie,"formatReadResult");function Be(e,t){return(e===void 0||Number.isInteger(e))&&(t===void 0||Number.isInteger(t)&&t>=0)}s(Be,"isStreamableRange");function Fe(e,t,n){const i=e.toString("utf-8").split(`
|
|
9
|
+
`),f=n===void 0?void 0:Math.min(t+n,i.length),g=K(i.slice(t,f).join(`
|
|
10
|
+
`)),u=g.firstLineExceedsLimit?Buffer.byteLength(i[t],"utf-8"):0;return{totalFileLines:i.length,truncation:g,firstLineBytes:u}}s(Fe,"selectLinesFromBuffer");async function Pe(e,t,n,i){const f=n===void 0?Number.POSITIVE_INFINITY:t+n,g=new te("utf-8",{ignoreBOM:!0}),u=[];let m=0,d=!1,o=0,C=0,w=0,T=0,x=!0,h=[],y=0,r=!1;const R=s((p,c,a)=>{if(r=!0,!h)return;const l=p.slice(c,a);y<=$&&h.push(l),y+=Buffer.byteLength(l,"utf-8")},"appendToLine"),I=s(()=>{if(h){C===0&&(T=y),(u.length>D||m>$)&&(d=!0);const p=h.join("");m+=Buffer.byteLength(p,"utf-8")+(u.length>0?1:0),u.push(p)}C++,x=!r,h=d?void 0:[],y=0,r=!1},"finishLine"),S=s(p=>{let c=0,a=-1;for(;;){const l=o>=t&&o<f;l&&a===-1&&(a=c);const L=p.indexOf(`
|
|
11
|
+
`,c),A=L===-1?p.length:L;if(l&&A>c&&R(p,c,A),L===-1)break;l&&(I(),o+1===f&&(w+=Buffer.byteLength(p.slice(a,L),"utf-8"),a=-1)),o++,c=L+1}a!==-1&&(w+=Buffer.byteLength(p.slice(a),"utf-8"))},"select");for await(const p of e){if(i?.aborted)throw new Error("Operation aborted");S(g.decode(p,{stream:!0}))}S(g.decode()),o>=t&&o<f&&I();const B={...K(u.join(`
|
|
12
|
+
`)),totalLines:w===0?0:C-(x?1:0),totalBytes:w};return{totalFileLines:o+1,truncation:B,firstLineBytes:T}}s(Pe,"selectLinesFromStream");function Ae(e,t){const n=t?.autoResizeImages??!0,i=t?.resizeOptions,f=t?.operations??be;return{name:"read",label:"read",description:`Read the contents of a file. Supports text files and images (jpg, png, gif, webp, bmp). Images are sent as attachments. For text files, output is truncated to ${D} lines or ${$/1024}KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.`,promptSnippet:V.snippet,promptGuidelines:[...V.guidelines],parameters:he,outputSchema:Le,constrainedSampling:{type:"json_schema",strict:"prefer"},async execute(g,{path:u,offset:m,limit:d},o,C,w){return new Promise((T,x)=>{if(o?.aborted){x(new Error("Operation aborted"));return}let h=!1;const y=s(()=>{h=!0,x(new Error("Operation aborted"))},"onAbort");o?.addEventListener("abort",y,{once:!0}),(async()=>{try{const r=await de(u,w?.cwd||e);if(h)return;const R=t?.operations?void 0:le(r);if(R)throw new Error(R);if(await f.access(r),h)return;const I=f.detectImageMimeType?await f.detectImageMimeType(r):void 0;let S,B;const p=Re(w?.model);if(I){const c=await f.readFile(r),a=await re(c,I,{autoResizeImages:n,resizeOptions:w?.model?.inputLimits?.images?.resize??i});if(a.ok){let l=`Read image file [${a.mimeType}]`;a.hints.length>0&&(l+=`
|
|
13
|
+
${a.hints.join(`
|
|
14
|
+
`)}`),p&&(l+=`
|
|
15
|
+
${p}`),S=[{type:"text",text:l},{type:"image",data:a.data,mimeType:a.mimeType}]}else{let l=`Read image file [${I}]
|
|
16
|
+
${a.message}`;p&&(l+=`
|
|
17
|
+
${p}`),S=[{type:"text",text:l}]}}else{const c=m?Math.max(0,m-1):0,a=c+1,{totalFileLines:l,truncation:L,firstLineBytes:A}=f.createReadStream&&Be(m,d)?await Pe(f.createReadStream(r,{signal:o}),c,d,o):Fe(await f.readFile(r),c,d);if(h)return;if(c>=l)throw new Error(`Offset ${m} is beyond end of file (${l} lines total)`);const M=d===void 0?void 0:Math.min(c+d,l)-c;let E;if(L.firstLineExceedsLimit){const O=P(A);E=`[Line ${a} is ${O}, exceeds ${P($)} limit. Use bash: sed -n '${a}p' ${u} | head -c ${$}]`,B={truncation:L}}else if(L.truncated){const O=a+L.outputLines-1,N=O+1;E=L.content,L.truncatedBy==="lines"?E+=`
|
|
17
18
|
|
|
18
|
-
[Showing lines ${
|
|
19
|
+
[Showing lines ${a}-${O} of ${l}. Use offset=${N} to continue.]`:E+=`
|
|
19
20
|
|
|
20
|
-
[Showing lines ${
|
|
21
|
+
[Showing lines ${a}-${O} of ${l} (${P($)} limit). Use offset=${N} to continue.]`,B={truncation:L}}else if(M!==void 0&&c+M<l){const O=l-(c+M),N=c+M+1;E=`${L.content}
|
|
21
22
|
|
|
22
|
-
[${
|
|
23
|
+
[${O} more lines in file. Use offset=${N} to continue.]`}else E=L.content;S=[{type:"text",text:E}]}if(h)return;o?.removeEventListener("abort",y),T({content:S,details:B})}catch(r){o?.removeEventListener("abort",y),h||x(r)}})()}).then(T=>({...T,structuredContent:$e(T.content)}))},renderCall(g,u,m){const d=m.lastComponent??new H("",0,0),o=m.expanded?void 0:Oe(g,m.cwd);return d.setText(o?Ce(o,g,u):Te(g,u,m.cwd)),d},renderResult(g,u,m,d){const o=d.lastComponent??new H("",0,0);return o.setText(Ie(d.args,g,u,m,d.showImages,d.cwd,d.isError)),o}}}s(Ae,"createReadToolDefinition");function Ze(e,t){return ge(Ae(e,t))}s(Ze,"createReadTool");export{Ze as createReadTool,Ae as createReadToolDefinition,V as readToolSystemPromptContribution};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var h=Object.defineProperty;var o=(t,n)=>h(t,"name",{value:n,configurable:!0});import
|
|
2
|
-
`);const c=d();if(i.length>0&&(!c.images||!n)){const u=i.map(f=>{const l=f.mimeType??"image/unknown",s=f.data&&f.mimeType?
|
|
1
|
+
var h=Object.defineProperty;var o=(t,n)=>h(t,"name",{value:n,configurable:!0});import{pathToFileURL as T}from"node:url";import{getCapabilities as d,getImageDimensions as A,hyperlink as x,imageFallback as b}from"@earendil-works/pi-tui";import{t as a}from"../../dal/i18n.js";import{stripAnsi as S}from"../../utils/ansi.js";import{resolvePath as _,shortenHomePath as j}from"../../utils/paths.js";import{sanitizeBinaryOutput as k}from"../../utils/shell.js";function O(t){return typeof t!="string"?"":j(t)}o(O,"shortenPath");function D(t,n,e){if(!d().hyperlinks)return t;const i=_(n,e);return x(t,T(i).href)}o(D,"linkPath");function H(t){return typeof t=="string"?t:t==null?"":null}o(H,"str");function m(t){return typeof t=="string"&&t.trim()!==""&&(t=Number(t)),typeof t=="number"&&Number.isFinite(t)?t:void 0}o(m,"parseLineNumber");function z(t,n){if(t==null&&n==null)return"";const e=t==null?1:m(t);if(e===void 0)return"";if(n==null)return`:${e}`;const i=m(n);if(i===void 0)return"";const r=e+i-1;return`:${e}${r?`-${r}`:""}`}o(z,"formatReadLineRange");function C(t){return t.replace(/\t/g," ")}o(C,"replaceTabs");function G(t){return t.replace(/\r/g,"")}o(G,"normalizeDisplayText");function J(t,n){if(!t)return"";const e=t.content.filter(u=>u.type==="text"),i=t.content.filter(u=>u.type==="image");let r=e.map(u=>k(S(u.text||"")).replace(/\r/g,"")).join(`
|
|
2
|
+
`);const c=d();if(i.length>0&&(!c.images||!n)){const u=i.map(f=>{const l=f.mimeType??"image/unknown",s=f.data&&f.mimeType?A(f.data,f.mimeType)??void 0:void 0;return b(l,s)}).join(`
|
|
3
3
|
`);r=r?`${r}
|
|
4
|
-
${u}`:u}return r}o(
|
|
4
|
+
${u}`:u}return r}o(J,"getTextOutput");const g=100;function N(t,n,e,i){const r=e.fg("toolTitle",e.bold(t));if(n==null)return r;const c=typeof n=="object"&&!Array.isArray(n)?Object.entries(n):[["args",n]];if(c.length===0)return r;if(i){const l=c.map(([s,p])=>{const y=typeof p=="string"?p:JSON.stringify(p,null,2)??String(p);return` ${s}: ${C(y).replace(/\r/g,"").split(`
|
|
5
5
|
`).join(`
|
|
6
6
|
`)}`});return`${r}
|
|
7
7
|
${e.fg("muted",l.join(`
|
|
8
|
-
`))}`}const u=c.map(([l,s])=>`${l}=${JSON.stringify(s)??String(s)}`).join(" "),f=u.length>g?`${u.slice(0,g-3)}...`:u;return`${r} ${e.fg("muted",f)}`}o(
|
|
8
|
+
`))}`}const u=c.map(([l,s])=>`${l}=${JSON.stringify(s)??String(s)}`).join(" "),f=u.length>g?`${u.slice(0,g-3)}...`:u;return`${r} ${e.fg("muted",f)}`}o(N,"formatToolCallWithArgs");function $(t){const n=t/1e3;if(n<60)return`${n.toFixed(1)}s`;const e=Math.floor(n),i=Math.floor(e/60),r=e%60;return i<60?`${i}m ${r}s`:`${Math.floor(i/60)}h ${i%60}m ${r}s`}o($,"formatToolDuration");function W(t){const n=t.state;t.executionStarted&&n.startedAt===void 0&&(n.startedAt=Date.now(),n.endedAt=void 0)}o(W,"startToolTimer");function q(t,n){const e=t.state;if(e.startedAt!==void 0&&n&&!e.interval&&(e.interval=setInterval(()=>t.invalidate(),1e3)),(!n||t.isError)&&(e.endedAt??=Date.now(),e.interval&&(clearInterval(e.interval),e.interval=void 0)),!n&&t.durationMs!==void 0)return`${a("\u8017\u65F6")} ${$(t.durationMs)}`;if(e.startedAt===void 0)return;const i=e.endedAt??Date.now();return`${n?a("\u5DF2\u8FD0\u884C"):a("\u8017\u65F6")} ${$(i-e.startedAt)}`}o(q,"toolTimerText");function M(t){return t.fg("error",a("[\u53C2\u6570\u65E0\u6548]"))}o(M,"invalidArgText");function v(t){const n=t.trim();return n?n.split(`
|
|
9
9
|
`).length:0}o(v,"countOutputLines");function K(t,n){const e=n.filter(i=>i.length>0);return e.length===0?"":`
|
|
10
|
-
${t.fg("muted",e.join(" \xB7 "))}`}o(K,"formatCollapsedSummary");const R=["path","file_path","filePath","command","query","pattern","description","uri","name","file","goal"];function U(t,n=48){if(!t||typeof t!="object")return"";const e=t;for(const i of R){const r=e[i];if(typeof r=="string"&&r.length>0)return r.length>n?`${r.slice(0,n-1)}\u2026`:r}return""}o(U,"compactToolArgHint");function Y(t){if(!t.startsWith("mcp__"))return t;const n=t.split("__");return n.length<3?t:`${n[1]}:${n.slice(2).join("__")}`}o(Y,"prettyToolLabel");function Q(t,n=72){return t.length<=n?t:`${t.slice(0,n-1)}\u2026`}o(Q,"truncateDisplay");function V(t,n,e,i){if(t===null)return M(n);const r=t||i?.emptyFallback;return r?D(n.fg("accent",O(r)),r,e):n.fg("toolOutput","...")}o(V,"renderToolPath");export{U as compactToolArgHint,v as countOutputLines,K as formatCollapsedSummary,z as formatReadLineRange,
|
|
10
|
+
${t.fg("muted",e.join(" \xB7 "))}`}o(K,"formatCollapsedSummary");const R=["path","file_path","filePath","command","query","pattern","description","uri","name","file","goal"];function U(t,n=48){if(!t||typeof t!="object")return"";const e=t;for(const i of R){const r=e[i];if(typeof r=="string"&&r.length>0)return r.length>n?`${r.slice(0,n-1)}\u2026`:r}return""}o(U,"compactToolArgHint");function Y(t){if(!t.startsWith("mcp__"))return t;const n=t.split("__");return n.length<3?t:`${n[1]}:${n.slice(2).join("__")}`}o(Y,"prettyToolLabel");function Q(t,n=72){return t.length<=n?t:`${t.slice(0,n-1)}\u2026`}o(Q,"truncateDisplay");function V(t,n,e,i){if(t===null)return M(n);const r=t||i?.emptyFallback;return r?D(n.fg("accent",O(r)),r,e):n.fg("toolOutput","...")}o(V,"renderToolPath");export{U as compactToolArgHint,v as countOutputLines,K as formatCollapsedSummary,z as formatReadLineRange,N as formatToolCallWithArgs,$ as formatToolDuration,J as getTextOutput,M as invalidArgText,D as linkPath,G as normalizeDisplayText,Y as prettyToolLabel,V as renderToolPath,C as replaceTabs,O as shortenPath,W as startToolTimer,H as str,q as toolTimerText,Q as truncateDisplay};
|