@tuan_son.dinh/gsd 2.6.2 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cli.js +24 -10
- package/dist/loader.js +21 -3
- package/dist/logo.d.ts +3 -3
- package/dist/logo.js +2 -2
- package/dist/onboarding.d.ts +3 -3
- package/dist/onboarding.js +3 -4
- package/dist/pi-migration.d.ts +5 -1
- package/dist/pi-migration.js +19 -2
- package/dist/resource-loader.d.ts +2 -1
- package/dist/resource-loader.js +60 -4
- package/dist/wizard.d.ts +1 -1
- package/package.json +12 -6
- package/packages/pi-agent-core/dist/agent-loop.d.ts +21 -0
- package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/agent-loop.js +308 -0
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -0
- package/packages/pi-agent-core/dist/agent.d.ts +162 -0
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/agent.js +399 -0
- package/packages/pi-agent-core/dist/agent.js.map +1 -0
- package/packages/pi-agent-core/dist/index.d.ts +5 -0
- package/packages/pi-agent-core/dist/index.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/index.js +9 -0
- package/packages/pi-agent-core/dist/index.js.map +1 -0
- package/packages/pi-agent-core/dist/proxy.d.ts +85 -0
- package/packages/pi-agent-core/dist/proxy.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/proxy.js +268 -0
- package/packages/pi-agent-core/dist/proxy.js.map +1 -0
- package/packages/pi-agent-core/dist/types.d.ts +178 -0
- package/packages/pi-agent-core/dist/types.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/types.js +2 -0
- package/packages/pi-agent-core/dist/types.js.map +1 -0
- package/packages/pi-agent-core/package.json +14 -0
- package/packages/pi-agent-core/src/agent-loop.ts +417 -0
- package/packages/pi-agent-core/src/agent.ts +568 -0
- package/packages/pi-agent-core/src/index.ts +8 -0
- package/packages/pi-agent-core/src/proxy.ts +340 -0
- package/packages/pi-agent-core/src/types.ts +194 -0
- package/packages/pi-agent-core/tsconfig.json +27 -0
- package/packages/pi-ai/bedrock-provider.d.ts +1 -0
- package/packages/pi-ai/bedrock-provider.js +1 -0
- package/packages/pi-ai/dist/api-registry.d.ts +20 -0
- package/packages/pi-ai/dist/api-registry.d.ts.map +1 -0
- package/packages/pi-ai/dist/api-registry.js +44 -0
- package/packages/pi-ai/dist/api-registry.js.map +1 -0
- package/packages/pi-ai/dist/bedrock-provider.d.ts +5 -0
- package/packages/pi-ai/dist/bedrock-provider.d.ts.map +1 -0
- package/packages/pi-ai/dist/bedrock-provider.js +6 -0
- package/packages/pi-ai/dist/bedrock-provider.js.map +1 -0
- package/packages/pi-ai/dist/cli.d.ts +3 -0
- package/packages/pi-ai/dist/cli.d.ts.map +1 -0
- package/packages/pi-ai/dist/cli.js +116 -0
- package/packages/pi-ai/dist/cli.js.map +1 -0
- package/packages/pi-ai/dist/env-api-keys.d.ts +9 -0
- package/packages/pi-ai/dist/env-api-keys.d.ts.map +1 -0
- package/packages/pi-ai/dist/env-api-keys.js +104 -0
- package/packages/pi-ai/dist/env-api-keys.js.map +1 -0
- package/packages/pi-ai/dist/index.d.ts +23 -0
- package/packages/pi-ai/dist/index.d.ts.map +1 -0
- package/packages/pi-ai/dist/index.js +21 -0
- package/packages/pi-ai/dist/index.js.map +1 -0
- package/packages/pi-ai/dist/models.d.ts +24 -0
- package/packages/pi-ai/dist/models.d.ts.map +1 -0
- package/packages/pi-ai/dist/models.generated.d.ts +13572 -0
- package/packages/pi-ai/dist/models.generated.d.ts.map +1 -0
- package/packages/pi-ai/dist/models.generated.js +13368 -0
- package/packages/pi-ai/dist/models.generated.js.map +1 -0
- package/packages/pi-ai/dist/models.js +55 -0
- package/packages/pi-ai/dist/models.js.map +1 -0
- package/packages/pi-ai/dist/oauth.d.ts +2 -0
- package/packages/pi-ai/dist/oauth.d.ts.map +1 -0
- package/packages/pi-ai/dist/oauth.js +2 -0
- package/packages/pi-ai/dist/oauth.js.map +1 -0
- package/packages/pi-ai/dist/providers/amazon-bedrock.d.ts +15 -0
- package/packages/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/amazon-bedrock.js +600 -0
- package/packages/pi-ai/dist/providers/amazon-bedrock.js.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic.d.ts +33 -0
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic.js +732 -0
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -0
- package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts +15 -0
- package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/azure-openai-responses.js +187 -0
- package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -0
- package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts +8 -0
- package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/github-copilot-headers.js +29 -0
- package/packages/pi-ai/dist/providers/github-copilot-headers.js.map +1 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts +74 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.js +757 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -0
- package/packages/pi-ai/dist/providers/google-shared.d.ts +65 -0
- package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/google-shared.js +300 -0
- package/packages/pi-ai/dist/providers/google-shared.js.map +1 -0
- package/packages/pi-ai/dist/providers/google-vertex.d.ts +15 -0
- package/packages/pi-ai/dist/providers/google-vertex.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/google-vertex.js +374 -0
- package/packages/pi-ai/dist/providers/google-vertex.js.map +1 -0
- package/packages/pi-ai/dist/providers/google.d.ts +13 -0
- package/packages/pi-ai/dist/providers/google.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/google.js +355 -0
- package/packages/pi-ai/dist/providers/google.js.map +1 -0
- package/packages/pi-ai/dist/providers/mistral.d.ts +22 -0
- package/packages/pi-ai/dist/providers/mistral.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/mistral.js +498 -0
- package/packages/pi-ai/dist/providers/mistral.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts +9 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.js +704 -0
- package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-completions.d.ts +15 -0
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-completions.js +705 -0
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses-shared.d.ts +17 -0
- package/packages/pi-ai/dist/providers/openai-responses-shared.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses-shared.js +442 -0
- package/packages/pi-ai/dist/providers/openai-responses-shared.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses.d.ts +13 -0
- package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses.js +201 -0
- package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -0
- package/packages/pi-ai/dist/providers/register-builtins.d.ts +11 -0
- package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/register-builtins.js +138 -0
- package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -0
- package/packages/pi-ai/dist/providers/simple-options.d.ts +8 -0
- package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/simple-options.js +35 -0
- package/packages/pi-ai/dist/providers/simple-options.js.map +1 -0
- package/packages/pi-ai/dist/providers/transform-messages.d.ts +8 -0
- package/packages/pi-ai/dist/providers/transform-messages.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/transform-messages.js +155 -0
- package/packages/pi-ai/dist/providers/transform-messages.js.map +1 -0
- package/packages/pi-ai/dist/stream.d.ts +8 -0
- package/packages/pi-ai/dist/stream.d.ts.map +1 -0
- package/packages/pi-ai/dist/stream.js +27 -0
- package/packages/pi-ai/dist/stream.js.map +1 -0
- package/packages/pi-ai/dist/types.d.ts +285 -0
- package/packages/pi-ai/dist/types.d.ts.map +1 -0
- package/packages/pi-ai/dist/types.js +2 -0
- package/packages/pi-ai/dist/types.js.map +1 -0
- package/packages/pi-ai/dist/utils/event-stream.d.ts +21 -0
- package/packages/pi-ai/dist/utils/event-stream.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/event-stream.js +77 -0
- package/packages/pi-ai/dist/utils/event-stream.js.map +1 -0
- package/packages/pi-ai/dist/utils/hash.d.ts +3 -0
- package/packages/pi-ai/dist/utils/hash.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/hash.js +14 -0
- package/packages/pi-ai/dist/utils/hash.js.map +1 -0
- package/packages/pi-ai/dist/utils/json-parse.d.ts +9 -0
- package/packages/pi-ai/dist/utils/json-parse.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/json-parse.js +29 -0
- package/packages/pi-ai/dist/utils/json-parse.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/anthropic.d.ts +17 -0
- package/packages/pi-ai/dist/utils/oauth/anthropic.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/anthropic.js +104 -0
- package/packages/pi-ai/dist/utils/oauth/anthropic.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts +30 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js +281 -0
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts +26 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js +373 -0
- package/packages/pi-ai/dist/utils/oauth/google-antigravity.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts +26 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js +478 -0
- package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/index.d.ts +61 -0
- package/packages/pi-ai/dist/utils/oauth/index.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/index.js +131 -0
- package/packages/pi-ai/dist/utils/oauth/index.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/openai-codex.d.ts +34 -0
- package/packages/pi-ai/dist/utils/oauth/openai-codex.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/openai-codex.js +380 -0
- package/packages/pi-ai/dist/utils/oauth/openai-codex.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/pkce.d.ts +13 -0
- package/packages/pi-ai/dist/utils/oauth/pkce.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/pkce.js +31 -0
- package/packages/pi-ai/dist/utils/oauth/pkce.js.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/types.d.ts +47 -0
- package/packages/pi-ai/dist/utils/oauth/types.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/oauth/types.js +2 -0
- package/packages/pi-ai/dist/utils/oauth/types.js.map +1 -0
- package/packages/pi-ai/dist/utils/overflow.d.ts +52 -0
- package/packages/pi-ai/dist/utils/overflow.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/overflow.js +117 -0
- package/packages/pi-ai/dist/utils/overflow.js.map +1 -0
- package/packages/pi-ai/dist/utils/sanitize-unicode.d.ts +22 -0
- package/packages/pi-ai/dist/utils/sanitize-unicode.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/sanitize-unicode.js +26 -0
- package/packages/pi-ai/dist/utils/sanitize-unicode.js.map +1 -0
- package/packages/pi-ai/dist/utils/typebox-helpers.d.ts +17 -0
- package/packages/pi-ai/dist/utils/typebox-helpers.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/typebox-helpers.js +21 -0
- package/packages/pi-ai/dist/utils/typebox-helpers.js.map +1 -0
- package/packages/pi-ai/dist/utils/validation.d.ts +18 -0
- package/packages/pi-ai/dist/utils/validation.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/validation.js +72 -0
- package/packages/pi-ai/dist/utils/validation.js.map +1 -0
- package/packages/pi-ai/package.json +40 -0
- package/packages/pi-ai/src/api-registry.ts +98 -0
- package/packages/pi-ai/src/bedrock-provider.ts +6 -0
- package/packages/pi-ai/src/cli.ts +133 -0
- package/packages/pi-ai/src/env-api-keys.ts +129 -0
- package/packages/pi-ai/src/index.ts +32 -0
- package/packages/pi-ai/src/models.generated.ts +13370 -0
- package/packages/pi-ai/src/models.ts +77 -0
- package/packages/pi-ai/src/oauth.ts +1 -0
- package/packages/pi-ai/src/providers/amazon-bedrock.ts +751 -0
- package/packages/pi-ai/src/providers/anthropic.ts +883 -0
- package/packages/pi-ai/src/providers/azure-openai-responses.ts +259 -0
- package/packages/pi-ai/src/providers/github-copilot-headers.ts +37 -0
- package/packages/pi-ai/src/providers/google-gemini-cli.ts +967 -0
- package/packages/pi-ai/src/providers/google-shared.ts +313 -0
- package/packages/pi-ai/src/providers/google-vertex.ts +485 -0
- package/packages/pi-ai/src/providers/google.ts +455 -0
- package/packages/pi-ai/src/providers/mistral.ts +582 -0
- package/packages/pi-ai/src/providers/openai-codex-responses.ts +875 -0
- package/packages/pi-ai/src/providers/openai-completions.ts +820 -0
- package/packages/pi-ai/src/providers/openai-responses-shared.ts +496 -0
- package/packages/pi-ai/src/providers/openai-responses.ts +262 -0
- package/packages/pi-ai/src/providers/register-builtins.ts +186 -0
- package/packages/pi-ai/src/providers/simple-options.ts +46 -0
- package/packages/pi-ai/src/providers/transform-messages.ts +172 -0
- package/packages/pi-ai/src/stream.ts +59 -0
- package/packages/pi-ai/src/types.ts +321 -0
- package/packages/pi-ai/src/utils/event-stream.ts +87 -0
- package/packages/pi-ai/src/utils/hash.ts +13 -0
- package/packages/pi-ai/src/utils/json-parse.ts +28 -0
- package/packages/pi-ai/src/utils/oauth/anthropic.ts +138 -0
- package/packages/pi-ai/src/utils/oauth/github-copilot.ts +381 -0
- package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +457 -0
- package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +599 -0
- package/packages/pi-ai/src/utils/oauth/index.ts +162 -0
- package/packages/pi-ai/src/utils/oauth/openai-codex.ts +455 -0
- package/packages/pi-ai/src/utils/oauth/pkce.ts +34 -0
- package/packages/pi-ai/src/utils/oauth/types.ts +59 -0
- package/packages/pi-ai/src/utils/overflow.ts +123 -0
- package/packages/pi-ai/src/utils/sanitize-unicode.ts +25 -0
- package/packages/pi-ai/src/utils/typebox-helpers.ts +24 -0
- package/packages/pi-ai/src/utils/validation.ts +84 -0
- package/packages/pi-ai/tsconfig.json +27 -0
- package/packages/pi-coding-agent/dist/cli/args.d.ts +48 -0
- package/packages/pi-coding-agent/dist/cli/args.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli/args.js +299 -0
- package/packages/pi-coding-agent/dist/cli/args.js.map +1 -0
- package/packages/pi-coding-agent/dist/cli/config-selector.d.ts +14 -0
- package/packages/pi-coding-agent/dist/cli/config-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli/config-selector.js +31 -0
- package/packages/pi-coding-agent/dist/cli/config-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/cli/file-processor.d.ts +15 -0
- package/packages/pi-coding-agent/dist/cli/file-processor.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli/file-processor.js +79 -0
- package/packages/pi-coding-agent/dist/cli/file-processor.js.map +1 -0
- package/packages/pi-coding-agent/dist/cli/list-models.d.ts +9 -0
- package/packages/pi-coding-agent/dist/cli/list-models.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli/list-models.js +92 -0
- package/packages/pi-coding-agent/dist/cli/list-models.js.map +1 -0
- package/packages/pi-coding-agent/dist/cli/session-picker.d.ts +9 -0
- package/packages/pi-coding-agent/dist/cli/session-picker.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli/session-picker.js +34 -0
- package/packages/pi-coding-agent/dist/cli/session-picker.js.map +1 -0
- package/packages/pi-coding-agent/dist/cli.d.ts +3 -0
- package/packages/pi-coding-agent/dist/cli.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/cli.js +16 -0
- package/packages/pi-coding-agent/dist/cli.js.map +1 -0
- package/packages/pi-coding-agent/dist/config.d.ts +68 -0
- package/packages/pi-coding-agent/dist/config.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/config.js +203 -0
- package/packages/pi-coding-agent/dist/config.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +618 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/agent-session.js +2481 -0
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +134 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.js +415 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/bash-executor.d.ts +47 -0
- package/packages/pi-coding-agent/dist/core/bash-executor.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/bash-executor.js +212 -0
- package/packages/pi-coding-agent/dist/core/bash-executor.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts +86 -0
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js +242 -0
- package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts +121 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js +610 -0
- package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/index.d.ts +7 -0
- package/packages/pi-coding-agent/dist/core/compaction/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/index.js +7 -0
- package/packages/pi-coding-agent/dist/core/compaction/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts +38 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.js +153 -0
- package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/defaults.d.ts +3 -0
- package/packages/pi-coding-agent/dist/core/defaults.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/defaults.js +2 -0
- package/packages/pi-coding-agent/dist/core/defaults.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/diagnostics.d.ts +15 -0
- package/packages/pi-coding-agent/dist/core/diagnostics.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/diagnostics.js +2 -0
- package/packages/pi-coding-agent/dist/core/diagnostics.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/event-bus.d.ts +9 -0
- package/packages/pi-coding-agent/dist/core/event-bus.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/event-bus.js +25 -0
- package/packages/pi-coding-agent/dist/core/event-bus.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/exec.d.ts +29 -0
- package/packages/pi-coding-agent/dist/core/exec.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/exec.js +71 -0
- package/packages/pi-coding-agent/dist/core/exec.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js +249 -0
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/index.d.ts +37 -0
- package/packages/pi-coding-agent/dist/core/export-html/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/index.js +223 -0
- package/packages/pi-coding-agent/dist/core/export-html/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/template.css +971 -0
- package/packages/pi-coding-agent/dist/core/export-html/template.html +54 -0
- package/packages/pi-coding-agent/dist/core/export-html/template.js +1583 -0
- package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts +38 -0
- package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.js +70 -0
- package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/export-html/vendor/.gitkeep +0 -0
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +11 -0
- package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/index.js +9 -0
- package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts +25 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +426 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +147 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +672 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +1040 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.js +35 -0
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/wrapper.d.ts +27 -0
- package/packages/pi-coding-agent/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/extensions/wrapper.js +102 -0
- package/packages/pi-coding-agent/dist/core/extensions/wrapper.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/footer-data-provider.d.ts +32 -0
- package/packages/pi-coding-agent/dist/core/footer-data-provider.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/footer-data-provider.js +134 -0
- package/packages/pi-coding-agent/dist/core/footer-data-provider.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts +9 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/index.js +9 -0
- package/packages/pi-coding-agent/dist/core/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts +55 -0
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/keybindings.js +151 -0
- package/packages/pi-coding-agent/dist/core/keybindings.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/messages.d.ts +77 -0
- package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/messages.js +123 -0
- package/packages/pi-coding-agent/dist/core/messages.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts +113 -0
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry.js +537 -0
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts +104 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.js +462 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/package-manager.d.ts +156 -0
- package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/package-manager.js +1442 -0
- package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts +50 -0
- package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/prompt-templates.js +251 -0
- package/packages/pi-coding-agent/dist/core/prompt-templates.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/resolve-config-value.d.ts +17 -0
- package/packages/pi-coding-agent/dist/core/resolve-config-value.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/resolve-config-value.js +59 -0
- package/packages/pi-coding-agent/dist/core/resolve-config-value.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/resource-loader.d.ts +184 -0
- package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/resource-loader.js +633 -0
- package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk.d.ts +90 -0
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk.js +242 -0
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts +323 -0
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.js +1094 -0
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +232 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js +682 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/skills.d.ts +58 -0
- package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/skills.js +364 -0
- package/packages/pi-coding-agent/dist/core/skills.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.d.ts +15 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.js +22 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +28 -0
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/system-prompt.js +159 -0
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/timings.d.ts +7 -0
- package/packages/pi-coding-agent/dist/core/timings.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/timings.js +25 -0
- package/packages/pi-coding-agent/dist/core/timings.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts +55 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.js +269 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts +63 -0
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.js +243 -0
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/edit.d.ts +39 -0
- package/packages/pi-coding-agent/dist/core/tools/edit.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/edit.js +146 -0
- package/packages/pi-coding-agent/dist/core/tools/edit.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/find.d.ts +39 -0
- package/packages/pi-coding-agent/dist/core/tools/find.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/find.js +206 -0
- package/packages/pi-coding-agent/dist/core/tools/find.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/grep.d.ts +45 -0
- package/packages/pi-coding-agent/dist/core/tools/grep.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/grep.js +239 -0
- package/packages/pi-coding-agent/dist/core/tools/grep.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts +73 -0
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/index.js +61 -0
- package/packages/pi-coding-agent/dist/core/tools/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/ls.d.ts +40 -0
- package/packages/pi-coding-agent/dist/core/tools/ls.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/ls.js +118 -0
- package/packages/pi-coding-agent/dist/core/tools/ls.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/path-utils.d.ts +8 -0
- package/packages/pi-coding-agent/dist/core/tools/path-utils.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/path-utils.js +81 -0
- package/packages/pi-coding-agent/dist/core/tools/path-utils.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/read.d.ts +39 -0
- package/packages/pi-coding-agent/dist/core/tools/read.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/read.js +166 -0
- package/packages/pi-coding-agent/dist/core/tools/read.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/truncate.d.ts +70 -0
- package/packages/pi-coding-agent/dist/core/tools/truncate.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/truncate.js +205 -0
- package/packages/pi-coding-agent/dist/core/tools/truncate.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/write.d.ts +29 -0
- package/packages/pi-coding-agent/dist/core/tools/write.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/write.js +78 -0
- package/packages/pi-coding-agent/dist/core/tools/write.js.map +1 -0
- package/packages/pi-coding-agent/dist/index.d.ts +27 -0
- package/packages/pi-coding-agent/dist/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/index.js +42 -0
- package/packages/pi-coding-agent/dist/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/main.d.ts +8 -0
- package/packages/pi-coding-agent/dist/main.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/main.js +691 -0
- package/packages/pi-coding-agent/dist/main.js.map +1 -0
- package/packages/pi-coding-agent/dist/migrations.d.ts +33 -0
- package/packages/pi-coding-agent/dist/migrations.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/migrations.js +261 -0
- package/packages/pi-coding-agent/dist/migrations.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/index.d.ts +9 -0
- package/packages/pi-coding-agent/dist/modes/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/index.js +8 -0
- package/packages/pi-coding-agent/dist/modes/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/armin.d.ts +34 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/armin.js +329 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/armin.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts +16 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +92 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts +35 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js +156 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.js +48 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js +42 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js +43 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.js +470 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js +28 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.js +63 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.js +74 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.js +138 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts +12 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js +133 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js +20 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js +106 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js +55 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.d.ts +24 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.js +71 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts +26 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +196 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/index.d.ts +32 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/index.js +33 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/index.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js +61 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts +42 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +139 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts +47 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js +259 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.js +92 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.js +271 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js +825 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +58 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +295 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.js +34 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js +45 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.js +44 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js +46 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +77 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +773 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts +87 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +1026 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.js +110 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js +27 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +330 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +3755 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/dark.json +86 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/light.json +85 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +78 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +944 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/print-mode.d.ts +28 -0
- package/packages/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/print-mode.js +101 -0
- package/packages/pi-coding-agent/dist/modes/print-mode.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/jsonl.d.ts +17 -0
- package/packages/pi-coding-agent/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/jsonl.js +49 -0
- package/packages/pi-coding-agent/dist/modes/rpc/jsonl.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.d.ts +217 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.js +400 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +509 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts +409 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.js +8 -0
- package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/changelog.d.ts +21 -0
- package/packages/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/changelog.js +87 -0
- package/packages/pi-coding-agent/dist/utils/changelog.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts +11 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-image.js +162 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-image.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-native.d.ts +7 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-native.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-native.js +14 -0
- package/packages/pi-coding-agent/dist/utils/clipboard-native.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard.d.ts +2 -0
- package/packages/pi-coding-agent/dist/utils/clipboard.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/clipboard.js +67 -0
- package/packages/pi-coding-agent/dist/utils/clipboard.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/frontmatter.d.ts +8 -0
- package/packages/pi-coding-agent/dist/utils/frontmatter.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/frontmatter.js +26 -0
- package/packages/pi-coding-agent/dist/utils/frontmatter.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/git.d.ts +26 -0
- package/packages/pi-coding-agent/dist/utils/git.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/git.js +163 -0
- package/packages/pi-coding-agent/dist/utils/git.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/image-convert.d.ts +9 -0
- package/packages/pi-coding-agent/dist/utils/image-convert.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/image-convert.js +35 -0
- package/packages/pi-coding-agent/dist/utils/image-convert.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/image-resize.d.ts +36 -0
- package/packages/pi-coding-agent/dist/utils/image-resize.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/image-resize.js +181 -0
- package/packages/pi-coding-agent/dist/utils/image-resize.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/mime.d.ts +2 -0
- package/packages/pi-coding-agent/dist/utils/mime.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/mime.js +26 -0
- package/packages/pi-coding-agent/dist/utils/mime.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/photon.d.ts +21 -0
- package/packages/pi-coding-agent/dist/utils/photon.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/photon.js +121 -0
- package/packages/pi-coding-agent/dist/utils/photon.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/shell.d.ts +26 -0
- package/packages/pi-coding-agent/dist/utils/shell.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/shell.js +186 -0
- package/packages/pi-coding-agent/dist/utils/shell.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/sleep.d.ts +5 -0
- package/packages/pi-coding-agent/dist/utils/sleep.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/sleep.js +17 -0
- package/packages/pi-coding-agent/dist/utils/sleep.js.map +1 -0
- package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts +3 -0
- package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/utils/tools-manager.js +251 -0
- package/packages/pi-coding-agent/dist/utils/tools-manager.js.map +1 -0
- package/packages/pi-coding-agent/package.json +55 -0
- package/packages/pi-coding-agent/src/cli/args.ts +316 -0
- package/packages/pi-coding-agent/src/cli/config-selector.ts +52 -0
- package/packages/pi-coding-agent/src/cli/file-processor.ts +96 -0
- package/packages/pi-coding-agent/src/cli/list-models.ts +104 -0
- package/packages/pi-coding-agent/src/cli/session-picker.ts +51 -0
- package/packages/pi-coding-agent/src/cli.ts +18 -0
- package/packages/pi-coding-agent/src/config.ts +241 -0
- package/packages/pi-coding-agent/src/core/agent-session.ts +3050 -0
- package/packages/pi-coding-agent/src/core/auth-storage.ts +489 -0
- package/packages/pi-coding-agent/src/core/bash-executor.ts +278 -0
- package/packages/pi-coding-agent/src/core/compaction/branch-summarization.ts +352 -0
- package/packages/pi-coding-agent/src/core/compaction/compaction.ts +813 -0
- package/packages/pi-coding-agent/src/core/compaction/index.ts +7 -0
- package/packages/pi-coding-agent/src/core/compaction/utils.ts +170 -0
- package/packages/pi-coding-agent/src/core/defaults.ts +3 -0
- package/packages/pi-coding-agent/src/core/diagnostics.ts +15 -0
- package/packages/pi-coding-agent/src/core/event-bus.ts +33 -0
- package/packages/pi-coding-agent/src/core/exec.ts +104 -0
- package/packages/pi-coding-agent/src/core/export-html/ansi-to-html.ts +258 -0
- package/packages/pi-coding-agent/src/core/export-html/index.ts +306 -0
- package/packages/pi-coding-agent/src/core/export-html/template.css +971 -0
- package/packages/pi-coding-agent/src/core/export-html/template.html +54 -0
- package/packages/pi-coding-agent/src/core/export-html/template.js +1583 -0
- package/packages/pi-coding-agent/src/core/export-html/tool-renderer.ts +114 -0
- package/packages/pi-coding-agent/src/core/export-html/vendor/.gitkeep +0 -0
- package/packages/pi-coding-agent/src/core/extensions/index.ts +171 -0
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +545 -0
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +884 -0
- package/packages/pi-coding-agent/src/core/extensions/types.ts +1411 -0
- package/packages/pi-coding-agent/src/core/extensions/wrapper.ts +118 -0
- package/packages/pi-coding-agent/src/core/footer-data-provider.ts +144 -0
- package/packages/pi-coding-agent/src/core/index.ts +61 -0
- package/packages/pi-coding-agent/src/core/keybindings.ts +211 -0
- package/packages/pi-coding-agent/src/core/messages.ts +195 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +694 -0
- package/packages/pi-coding-agent/src/core/model-resolver.ts +594 -0
- package/packages/pi-coding-agent/src/core/package-manager.ts +1794 -0
- package/packages/pi-coding-agent/src/core/prompt-templates.ts +299 -0
- package/packages/pi-coding-agent/src/core/resolve-config-value.ts +64 -0
- package/packages/pi-coding-agent/src/core/resource-loader.ts +868 -0
- package/packages/pi-coding-agent/src/core/sdk.ts +373 -0
- package/packages/pi-coding-agent/src/core/session-manager.ts +1410 -0
- package/packages/pi-coding-agent/src/core/settings-manager.ts +942 -0
- package/packages/pi-coding-agent/src/core/skills.ts +459 -0
- package/packages/pi-coding-agent/src/core/slash-commands.ts +38 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +218 -0
- package/packages/pi-coding-agent/src/core/timings.ts +25 -0
- package/packages/pi-coding-agent/src/core/tools/bash.ts +347 -0
- package/packages/pi-coding-agent/src/core/tools/edit-diff.ts +308 -0
- package/packages/pi-coding-agent/src/core/tools/edit.ts +227 -0
- package/packages/pi-coding-agent/src/core/tools/find.ts +273 -0
- package/packages/pi-coding-agent/src/core/tools/grep.ts +346 -0
- package/packages/pi-coding-agent/src/core/tools/index.ts +139 -0
- package/packages/pi-coding-agent/src/core/tools/ls.ts +170 -0
- package/packages/pi-coding-agent/src/core/tools/path-utils.ts +94 -0
- package/packages/pi-coding-agent/src/core/tools/read.ts +222 -0
- package/packages/pi-coding-agent/src/core/tools/truncate.ts +265 -0
- package/packages/pi-coding-agent/src/core/tools/write.ts +118 -0
- package/packages/pi-coding-agent/src/index.ts +333 -0
- package/packages/pi-coding-agent/src/main.ts +821 -0
- package/packages/pi-coding-agent/src/migrations.ts +295 -0
- package/packages/pi-coding-agent/src/modes/index.ts +9 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/armin.ts +382 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +115 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/bash-execution.ts +210 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/bordered-loader.ts +66 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/branch-summary-message.ts +58 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/compaction-summary-message.ts +59 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/config-selector.ts +592 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/countdown-timer.ts +38 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/custom-editor.ts +80 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/custom-message.ts +99 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/daxnuts.ts +164 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/diff.ts +147 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/dynamic-border.ts +25 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/extension-editor.ts +147 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/extension-input.ts +85 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/extension-selector.ts +107 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +216 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/index.ts +32 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/keybinding-hints.ts +66 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +174 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/model-selector.ts +329 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/oauth-selector.ts +121 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/scoped-models-selector.ts +346 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/session-selector-search.ts +194 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/session-selector.ts +1019 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/settings-selector.ts +421 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/show-images-selector.ts +45 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/skill-invocation-message.ts +55 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/theme-selector.ts +62 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/thinking-selector.ts +64 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +916 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/tree-selector.ts +1184 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/user-message-selector.ts +143 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/user-message.ts +32 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/visual-truncate.ts +50 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +4464 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/dark.json +86 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/light.json +85 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.json +335 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +1105 -0
- package/packages/pi-coding-agent/src/modes/print-mode.ts +124 -0
- package/packages/pi-coding-agent/src/modes/rpc/jsonl.ts +58 -0
- package/packages/pi-coding-agent/src/modes/rpc/rpc-client.ts +505 -0
- package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +638 -0
- package/packages/pi-coding-agent/src/modes/rpc/rpc-types.ts +263 -0
- package/packages/pi-coding-agent/src/utils/changelog.ts +99 -0
- package/packages/pi-coding-agent/src/utils/clipboard-image.ts +207 -0
- package/packages/pi-coding-agent/src/utils/clipboard-native.ts +21 -0
- package/packages/pi-coding-agent/src/utils/clipboard.ts +62 -0
- package/packages/pi-coding-agent/src/utils/frontmatter.ts +39 -0
- package/packages/pi-coding-agent/src/utils/git.ts +192 -0
- package/packages/pi-coding-agent/src/utils/image-convert.ts +38 -0
- package/packages/pi-coding-agent/src/utils/image-resize.ts +231 -0
- package/packages/pi-coding-agent/src/utils/mime.ts +30 -0
- package/packages/pi-coding-agent/src/utils/photon.ts +139 -0
- package/packages/pi-coding-agent/src/utils/shell.ts +202 -0
- package/packages/pi-coding-agent/src/utils/sleep.ts +18 -0
- package/packages/pi-coding-agent/src/utils/tools-manager.ts +286 -0
- package/packages/pi-coding-agent/tsconfig.json +27 -0
- package/packages/pi-tui/dist/autocomplete.d.ts +50 -0
- package/packages/pi-tui/dist/autocomplete.d.ts.map +1 -0
- package/packages/pi-tui/dist/autocomplete.js +593 -0
- package/packages/pi-tui/dist/autocomplete.js.map +1 -0
- package/packages/pi-tui/dist/components/box.d.ts +22 -0
- package/packages/pi-tui/dist/components/box.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/box.js +99 -0
- package/packages/pi-tui/dist/components/box.js.map +1 -0
- package/packages/pi-tui/dist/components/cancellable-loader.d.ts +22 -0
- package/packages/pi-tui/dist/components/cancellable-loader.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/cancellable-loader.js +36 -0
- package/packages/pi-tui/dist/components/cancellable-loader.js.map +1 -0
- package/packages/pi-tui/dist/components/editor.d.ts +219 -0
- package/packages/pi-tui/dist/components/editor.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/editor.js +1693 -0
- package/packages/pi-tui/dist/components/editor.js.map +1 -0
- package/packages/pi-tui/dist/components/image.d.ts +28 -0
- package/packages/pi-tui/dist/components/image.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/image.js +61 -0
- package/packages/pi-tui/dist/components/image.js.map +1 -0
- package/packages/pi-tui/dist/components/input.d.ts +37 -0
- package/packages/pi-tui/dist/components/input.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/input.js +443 -0
- package/packages/pi-tui/dist/components/input.js.map +1 -0
- package/packages/pi-tui/dist/components/loader.d.ts +21 -0
- package/packages/pi-tui/dist/components/loader.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/loader.js +46 -0
- package/packages/pi-tui/dist/components/loader.js.map +1 -0
- package/packages/pi-tui/dist/components/markdown.d.ts +95 -0
- package/packages/pi-tui/dist/components/markdown.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/markdown.js +641 -0
- package/packages/pi-tui/dist/components/markdown.js.map +1 -0
- package/packages/pi-tui/dist/components/select-list.d.ts +32 -0
- package/packages/pi-tui/dist/components/select-list.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/select-list.js +148 -0
- package/packages/pi-tui/dist/components/select-list.js.map +1 -0
- package/packages/pi-tui/dist/components/settings-list.d.ts +50 -0
- package/packages/pi-tui/dist/components/settings-list.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/settings-list.js +177 -0
- package/packages/pi-tui/dist/components/settings-list.js.map +1 -0
- package/packages/pi-tui/dist/components/spacer.d.ts +12 -0
- package/packages/pi-tui/dist/components/spacer.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/spacer.js +22 -0
- package/packages/pi-tui/dist/components/spacer.js.map +1 -0
- package/packages/pi-tui/dist/components/text.d.ts +19 -0
- package/packages/pi-tui/dist/components/text.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/text.js +81 -0
- package/packages/pi-tui/dist/components/text.js.map +1 -0
- package/packages/pi-tui/dist/components/truncated-text.d.ts +13 -0
- package/packages/pi-tui/dist/components/truncated-text.d.ts.map +1 -0
- package/packages/pi-tui/dist/components/truncated-text.js +48 -0
- package/packages/pi-tui/dist/components/truncated-text.js.map +1 -0
- package/packages/pi-tui/dist/editor-component.d.ts +39 -0
- package/packages/pi-tui/dist/editor-component.d.ts.map +1 -0
- package/packages/pi-tui/dist/editor-component.js +2 -0
- package/packages/pi-tui/dist/editor-component.js.map +1 -0
- package/packages/pi-tui/dist/fuzzy.d.ts +16 -0
- package/packages/pi-tui/dist/fuzzy.d.ts.map +1 -0
- package/packages/pi-tui/dist/fuzzy.js +107 -0
- package/packages/pi-tui/dist/fuzzy.js.map +1 -0
- package/packages/pi-tui/dist/index.d.ts +23 -0
- package/packages/pi-tui/dist/index.d.ts.map +1 -0
- package/packages/pi-tui/dist/index.js +32 -0
- package/packages/pi-tui/dist/index.js.map +1 -0
- package/packages/pi-tui/dist/keybindings.d.ts +39 -0
- package/packages/pi-tui/dist/keybindings.d.ts.map +1 -0
- package/packages/pi-tui/dist/keybindings.js +116 -0
- package/packages/pi-tui/dist/keybindings.js.map +1 -0
- package/packages/pi-tui/dist/keys.d.ts +170 -0
- package/packages/pi-tui/dist/keys.d.ts.map +1 -0
- package/packages/pi-tui/dist/keys.js +1046 -0
- package/packages/pi-tui/dist/keys.js.map +1 -0
- package/packages/pi-tui/dist/kill-ring.d.ts +28 -0
- package/packages/pi-tui/dist/kill-ring.d.ts.map +1 -0
- package/packages/pi-tui/dist/kill-ring.js +46 -0
- package/packages/pi-tui/dist/kill-ring.js.map +1 -0
- package/packages/pi-tui/dist/stdin-buffer.d.ts +48 -0
- package/packages/pi-tui/dist/stdin-buffer.d.ts.map +1 -0
- package/packages/pi-tui/dist/stdin-buffer.js +316 -0
- package/packages/pi-tui/dist/stdin-buffer.js.map +1 -0
- package/packages/pi-tui/dist/terminal-image.d.ts +68 -0
- package/packages/pi-tui/dist/terminal-image.d.ts.map +1 -0
- package/packages/pi-tui/dist/terminal-image.js +288 -0
- package/packages/pi-tui/dist/terminal-image.js.map +1 -0
- package/packages/pi-tui/dist/terminal.d.ts +85 -0
- package/packages/pi-tui/dist/terminal.d.ts.map +1 -0
- package/packages/pi-tui/dist/terminal.js +271 -0
- package/packages/pi-tui/dist/terminal.js.map +1 -0
- package/packages/pi-tui/dist/tui.d.ts +220 -0
- package/packages/pi-tui/dist/tui.d.ts.map +1 -0
- package/packages/pi-tui/dist/tui.js +976 -0
- package/packages/pi-tui/dist/tui.js.map +1 -0
- package/packages/pi-tui/dist/undo-stack.d.ts +17 -0
- package/packages/pi-tui/dist/undo-stack.d.ts.map +1 -0
- package/packages/pi-tui/dist/undo-stack.js +27 -0
- package/packages/pi-tui/dist/undo-stack.js.map +1 -0
- package/packages/pi-tui/dist/utils.d.ts +78 -0
- package/packages/pi-tui/dist/utils.d.ts.map +1 -0
- package/packages/pi-tui/dist/utils.js +817 -0
- package/packages/pi-tui/dist/utils.js.map +1 -0
- package/packages/pi-tui/package.json +21 -0
- package/packages/pi-tui/src/autocomplete.ts +736 -0
- package/packages/pi-tui/src/components/box.ts +137 -0
- package/packages/pi-tui/src/components/cancellable-loader.ts +40 -0
- package/packages/pi-tui/src/components/editor.ts +2035 -0
- package/packages/pi-tui/src/components/image.ts +104 -0
- package/packages/pi-tui/src/components/input.ts +521 -0
- package/packages/pi-tui/src/components/loader.ts +55 -0
- package/packages/pi-tui/src/components/markdown.ts +806 -0
- package/packages/pi-tui/src/components/select-list.ts +188 -0
- package/packages/pi-tui/src/components/settings-list.ts +250 -0
- package/packages/pi-tui/src/components/spacer.ts +28 -0
- package/packages/pi-tui/src/components/text.ts +106 -0
- package/packages/pi-tui/src/components/truncated-text.ts +65 -0
- package/packages/pi-tui/src/editor-component.ts +74 -0
- package/packages/pi-tui/src/fuzzy.ts +133 -0
- package/packages/pi-tui/src/index.ts +93 -0
- package/packages/pi-tui/src/keybindings.ts +189 -0
- package/packages/pi-tui/src/keys.ts +1255 -0
- package/packages/pi-tui/src/kill-ring.ts +46 -0
- package/packages/pi-tui/src/stdin-buffer.ts +386 -0
- package/packages/pi-tui/src/terminal-image.ts +381 -0
- package/packages/pi-tui/src/terminal.ts +349 -0
- package/packages/pi-tui/src/tui.ts +1212 -0
- package/packages/pi-tui/src/undo-stack.ts +28 -0
- package/packages/pi-tui/src/utils.ts +905 -0
- package/packages/pi-tui/tsconfig.json +27 -0
- package/pkg/dist/modes/interactive/theme/dark.json +6 -6
- package/pkg/dist/modes/interactive/theme/light.json +6 -5
- package/pkg/dist/modes/interactive/theme/theme.d.ts +2 -2
- package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.js +1 -6
- package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
- package/scripts/postinstall.js +2 -17
- package/src/resources/extensions/ask-user-questions.ts +2 -2
- package/src/resources/extensions/bg-shell/index.ts +4 -4
- package/src/resources/extensions/browser-tools/index.ts +3 -3
- package/src/resources/extensions/context7/index.ts +3 -3
- package/src/resources/extensions/get-secrets-from-user.ts +331 -59
- package/src/resources/extensions/google-search/index.ts +20 -7
- package/src/resources/extensions/gsd/activity-log.ts +1 -1
- package/src/resources/extensions/gsd/auto.ts +106 -21
- package/src/resources/extensions/gsd/commands.ts +2 -2
- package/src/resources/extensions/gsd/dashboard-overlay.ts +2 -2
- package/src/resources/extensions/gsd/docs/preferences-reference.md +45 -1
- package/src/resources/extensions/gsd/doctor.ts +23 -4
- package/src/resources/extensions/gsd/files.ts +115 -1
- package/src/resources/extensions/gsd/git-service.ts +64 -111
- package/src/resources/extensions/gsd/guided-flow.ts +3 -2
- package/src/resources/extensions/gsd/index.ts +18 -7
- package/src/resources/extensions/gsd/metrics.ts +1 -1
- package/src/resources/extensions/gsd/migrate/command.ts +1 -1
- package/src/resources/extensions/gsd/preferences.ts +72 -10
- package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +4 -0
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +17 -0
- package/src/resources/extensions/gsd/session-forensics.ts +19 -6
- package/src/resources/extensions/gsd/skill-discovery.ts +1 -1
- package/src/resources/extensions/gsd/templates/secrets-manifest.md +22 -0
- package/src/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +196 -0
- package/src/resources/extensions/gsd/tests/collect-from-manifest.test.ts +469 -0
- package/src/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +170 -0
- package/src/resources/extensions/gsd/tests/git-service.test.ts +43 -0
- package/src/resources/extensions/gsd/tests/manifest-status.test.ts +283 -0
- package/src/resources/extensions/gsd/tests/parsers.test.ts +401 -65
- package/src/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +2 -1
- package/src/resources/extensions/gsd/tests/secure-env-collect.test.ts +185 -0
- package/src/resources/extensions/gsd/types.ts +27 -0
- package/src/resources/extensions/gsd/worktree-command.ts +2 -2
- package/src/resources/extensions/mac-tools/index.ts +2 -2
- package/src/resources/extensions/mcporter/index.ts +3 -3
- package/src/resources/extensions/remote-questions/remote-command.ts +3 -3
- package/src/resources/extensions/search-the-web/command-search-provider.ts +2 -2
- package/src/resources/extensions/search-the-web/index.ts +1 -1
- package/src/resources/extensions/search-the-web/provider.ts +1 -1
- package/src/resources/extensions/search-the-web/tool-fetch-page.ts +3 -3
- package/src/resources/extensions/search-the-web/tool-llm-context.ts +4 -4
- package/src/resources/extensions/search-the-web/tool-search.ts +4 -4
- package/src/resources/extensions/shared/confirm-ui.ts +3 -3
- package/src/resources/extensions/shared/interview-ui.ts +3 -3
- package/src/resources/extensions/shared/next-action-ui.ts +3 -3
- package/src/resources/extensions/shared/progress-widget.ts +2 -2
- package/src/resources/extensions/shared/thinking-widget.ts +3 -3
- package/src/resources/extensions/shared/ui.ts +4 -4
- package/src/resources/extensions/shared/wizard-ui.ts +4 -4
- package/src/resources/extensions/slash-commands/audit.ts +1 -1
- package/src/resources/extensions/slash-commands/clear.ts +1 -1
- package/src/resources/extensions/slash-commands/create-extension.ts +2 -2
- package/src/resources/extensions/slash-commands/create-slash-command.ts +2 -2
- package/src/resources/extensions/slash-commands/index.ts +1 -1
- package/src/resources/extensions/subagent/agents.ts +1 -1
- package/src/resources/extensions/subagent/index.ts +5 -5
- package/src/resources/extensions/voice/index.ts +3 -3
- package/patches/@mariozechner+pi-coding-agent+0.57.1.patch +0 -78
- package/patches/@mariozechner+pi-tui+0.57.1.patch +0 -47
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AgentTool } from "@gsd/pi-agent-core";
|
|
2
|
+
import { type Static } from "@sinclair/typebox";
|
|
3
|
+
import { type TruncationResult } from "./truncate.js";
|
|
4
|
+
declare const findSchema: import("@sinclair/typebox").TObject<{
|
|
5
|
+
pattern: import("@sinclair/typebox").TString;
|
|
6
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
7
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
8
|
+
}>;
|
|
9
|
+
export type FindToolInput = Static<typeof findSchema>;
|
|
10
|
+
export interface FindToolDetails {
|
|
11
|
+
truncation?: TruncationResult;
|
|
12
|
+
resultLimitReached?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pluggable operations for the find tool.
|
|
16
|
+
* Override these to delegate file search to remote systems (e.g., SSH).
|
|
17
|
+
*/
|
|
18
|
+
export interface FindOperations {
|
|
19
|
+
/** Check if path exists */
|
|
20
|
+
exists: (absolutePath: string) => Promise<boolean> | boolean;
|
|
21
|
+
/** Find files matching glob pattern. Returns relative paths. */
|
|
22
|
+
glob: (pattern: string, cwd: string, options: {
|
|
23
|
+
ignore: string[];
|
|
24
|
+
limit: number;
|
|
25
|
+
}) => Promise<string[]> | string[];
|
|
26
|
+
}
|
|
27
|
+
export interface FindToolOptions {
|
|
28
|
+
/** Custom operations for find. Default: local filesystem + fd */
|
|
29
|
+
operations?: FindOperations;
|
|
30
|
+
}
|
|
31
|
+
export declare function createFindTool(cwd: string, options?: FindToolOptions): AgentTool<typeof findSchema>;
|
|
32
|
+
/** Default find tool using process.cwd() - for backwards compatibility */
|
|
33
|
+
export declare const findTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
34
|
+
pattern: import("@sinclair/typebox").TString;
|
|
35
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
36
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
37
|
+
}>, any>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=find.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/core/tools/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAOtD,OAAO,EAAiC,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAEnG,QAAA,MAAM,UAAU;;;;EAMd,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAItD,MAAM,WAAW,eAAe;IAC/B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,2BAA2B;IAC3B,MAAM,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC7D,gEAAgE;IAChE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;CACnH;AAUD,MAAM,WAAW,eAAe;IAC/B,iEAAiE;IACjE,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CA0NnG;AAED,0EAA0E;AAC1E,eAAO,MAAM,QAAQ;;;;QAAgC,CAAC"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { spawnSync } from "child_process";
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import { globSync } from "glob";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { ensureTool } from "../../utils/tools-manager.js";
|
|
7
|
+
import { resolveToCwd } from "./path-utils.js";
|
|
8
|
+
import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
|
|
9
|
+
const findSchema = Type.Object({
|
|
10
|
+
pattern: Type.String({
|
|
11
|
+
description: "Glob pattern to match files, e.g. '*.ts', '**/*.json', or 'src/**/*.spec.ts'",
|
|
12
|
+
}),
|
|
13
|
+
path: Type.Optional(Type.String({ description: "Directory to search in (default: current directory)" })),
|
|
14
|
+
limit: Type.Optional(Type.Number({ description: "Maximum number of results (default: 1000)" })),
|
|
15
|
+
});
|
|
16
|
+
const DEFAULT_LIMIT = 1000;
|
|
17
|
+
const defaultFindOperations = {
|
|
18
|
+
exists: existsSync,
|
|
19
|
+
glob: (_pattern, _searchCwd, _options) => {
|
|
20
|
+
// This is a placeholder - actual fd execution happens in execute
|
|
21
|
+
return [];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export function createFindTool(cwd, options) {
|
|
25
|
+
const customOps = options?.operations;
|
|
26
|
+
return {
|
|
27
|
+
name: "find",
|
|
28
|
+
label: "find",
|
|
29
|
+
description: `Search for files by glob pattern. Returns matching file paths relative to the search directory. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} results or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first).`,
|
|
30
|
+
parameters: findSchema,
|
|
31
|
+
execute: async (_toolCallId, { pattern, path: searchDir, limit }, signal) => {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
if (signal?.aborted) {
|
|
34
|
+
reject(new Error("Operation aborted"));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const onAbort = () => reject(new Error("Operation aborted"));
|
|
38
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
39
|
+
(async () => {
|
|
40
|
+
try {
|
|
41
|
+
const searchPath = resolveToCwd(searchDir || ".", cwd);
|
|
42
|
+
const effectiveLimit = limit ?? DEFAULT_LIMIT;
|
|
43
|
+
const ops = customOps ?? defaultFindOperations;
|
|
44
|
+
// If custom operations provided with glob, use that
|
|
45
|
+
if (customOps?.glob) {
|
|
46
|
+
if (!(await ops.exists(searchPath))) {
|
|
47
|
+
reject(new Error(`Path not found: ${searchPath}`));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const results = await ops.glob(pattern, searchPath, {
|
|
51
|
+
ignore: ["**/node_modules/**", "**/.git/**"],
|
|
52
|
+
limit: effectiveLimit,
|
|
53
|
+
});
|
|
54
|
+
signal?.removeEventListener("abort", onAbort);
|
|
55
|
+
if (results.length === 0) {
|
|
56
|
+
resolve({
|
|
57
|
+
content: [{ type: "text", text: "No files found matching pattern" }],
|
|
58
|
+
details: undefined,
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
// Relativize paths
|
|
63
|
+
const relativized = results.map((p) => {
|
|
64
|
+
if (p.startsWith(searchPath)) {
|
|
65
|
+
return p.slice(searchPath.length + 1);
|
|
66
|
+
}
|
|
67
|
+
return path.relative(searchPath, p);
|
|
68
|
+
});
|
|
69
|
+
const resultLimitReached = relativized.length >= effectiveLimit;
|
|
70
|
+
const rawOutput = relativized.join("\n");
|
|
71
|
+
const truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });
|
|
72
|
+
let resultOutput = truncation.content;
|
|
73
|
+
const details = {};
|
|
74
|
+
const notices = [];
|
|
75
|
+
if (resultLimitReached) {
|
|
76
|
+
notices.push(`${effectiveLimit} results limit reached`);
|
|
77
|
+
details.resultLimitReached = effectiveLimit;
|
|
78
|
+
}
|
|
79
|
+
if (truncation.truncated) {
|
|
80
|
+
notices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);
|
|
81
|
+
details.truncation = truncation;
|
|
82
|
+
}
|
|
83
|
+
if (notices.length > 0) {
|
|
84
|
+
resultOutput += `\n\n[${notices.join(". ")}]`;
|
|
85
|
+
}
|
|
86
|
+
resolve({
|
|
87
|
+
content: [{ type: "text", text: resultOutput }],
|
|
88
|
+
details: Object.keys(details).length > 0 ? details : undefined,
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Default: use fd
|
|
93
|
+
const fdPath = await ensureTool("fd", true);
|
|
94
|
+
if (!fdPath) {
|
|
95
|
+
reject(new Error("fd is not available and could not be downloaded"));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// Build fd arguments
|
|
99
|
+
const args = [
|
|
100
|
+
"--glob",
|
|
101
|
+
"--color=never",
|
|
102
|
+
"--hidden",
|
|
103
|
+
"--max-results",
|
|
104
|
+
String(effectiveLimit),
|
|
105
|
+
];
|
|
106
|
+
// Include .gitignore files
|
|
107
|
+
const gitignoreFiles = new Set();
|
|
108
|
+
const rootGitignore = path.join(searchPath, ".gitignore");
|
|
109
|
+
if (existsSync(rootGitignore)) {
|
|
110
|
+
gitignoreFiles.add(rootGitignore);
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const nestedGitignores = globSync("**/.gitignore", {
|
|
114
|
+
cwd: searchPath,
|
|
115
|
+
dot: true,
|
|
116
|
+
absolute: true,
|
|
117
|
+
ignore: ["**/node_modules/**", "**/.git/**"],
|
|
118
|
+
});
|
|
119
|
+
for (const file of nestedGitignores) {
|
|
120
|
+
gitignoreFiles.add(file);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Ignore glob errors
|
|
125
|
+
}
|
|
126
|
+
for (const gitignorePath of gitignoreFiles) {
|
|
127
|
+
args.push("--ignore-file", gitignorePath);
|
|
128
|
+
}
|
|
129
|
+
args.push(pattern, searchPath);
|
|
130
|
+
const result = spawnSync(fdPath, args, {
|
|
131
|
+
encoding: "utf-8",
|
|
132
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
133
|
+
});
|
|
134
|
+
signal?.removeEventListener("abort", onAbort);
|
|
135
|
+
if (result.error) {
|
|
136
|
+
reject(new Error(`Failed to run fd: ${result.error.message}`));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const output = result.stdout?.trim() || "";
|
|
140
|
+
if (result.status !== 0) {
|
|
141
|
+
const errorMsg = result.stderr?.trim() || `fd exited with code ${result.status}`;
|
|
142
|
+
if (!output) {
|
|
143
|
+
reject(new Error(errorMsg));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (!output) {
|
|
148
|
+
resolve({
|
|
149
|
+
content: [{ type: "text", text: "No files found matching pattern" }],
|
|
150
|
+
details: undefined,
|
|
151
|
+
});
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const lines = output.split("\n");
|
|
155
|
+
const relativized = [];
|
|
156
|
+
for (const rawLine of lines) {
|
|
157
|
+
const line = rawLine.replace(/\r$/, "").trim();
|
|
158
|
+
if (!line)
|
|
159
|
+
continue;
|
|
160
|
+
const hadTrailingSlash = line.endsWith("/") || line.endsWith("\\");
|
|
161
|
+
let relativePath = line;
|
|
162
|
+
if (line.startsWith(searchPath)) {
|
|
163
|
+
relativePath = line.slice(searchPath.length + 1);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
relativePath = path.relative(searchPath, line);
|
|
167
|
+
}
|
|
168
|
+
if (hadTrailingSlash && !relativePath.endsWith("/")) {
|
|
169
|
+
relativePath += "/";
|
|
170
|
+
}
|
|
171
|
+
relativized.push(relativePath);
|
|
172
|
+
}
|
|
173
|
+
const resultLimitReached = relativized.length >= effectiveLimit;
|
|
174
|
+
const rawOutput = relativized.join("\n");
|
|
175
|
+
const truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });
|
|
176
|
+
let resultOutput = truncation.content;
|
|
177
|
+
const details = {};
|
|
178
|
+
const notices = [];
|
|
179
|
+
if (resultLimitReached) {
|
|
180
|
+
notices.push(`${effectiveLimit} results limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`);
|
|
181
|
+
details.resultLimitReached = effectiveLimit;
|
|
182
|
+
}
|
|
183
|
+
if (truncation.truncated) {
|
|
184
|
+
notices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);
|
|
185
|
+
details.truncation = truncation;
|
|
186
|
+
}
|
|
187
|
+
if (notices.length > 0) {
|
|
188
|
+
resultOutput += `\n\n[${notices.join(". ")}]`;
|
|
189
|
+
}
|
|
190
|
+
resolve({
|
|
191
|
+
content: [{ type: "text", text: resultOutput }],
|
|
192
|
+
details: Object.keys(details).length > 0 ? details : undefined,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
signal?.removeEventListener("abort", onAbort);
|
|
197
|
+
reject(e);
|
|
198
|
+
}
|
|
199
|
+
})();
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/** Default find tool using process.cwd() - for backwards compatibility */
|
|
205
|
+
export const findTool = createFindTool(process.cwd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AM,CAAC,CAAC,CAAC,CAAC;oBACX,CAAC;gBACF,CAAC,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC","sourcesContent":["import type { AgentTool } from \"@gsd/pi-agent-core\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport { spawnSync } from \"child_process\";\nimport { existsSync } from \"fs\";\nimport { globSync } from \"glob\";\nimport path from \"path\";\nimport { ensureTool } from \"../../utils/tools-manager.js\";\nimport { resolveToCwd } from \"./path-utils.js\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult, truncateHead } from \"./truncate.js\";\n\nconst findSchema = Type.Object({\n\tpattern: Type.String({\n\t\tdescription: \"Glob pattern to match files, e.g. '*.ts', '**/*.json', or 'src/**/*.spec.ts'\",\n\t}),\n\tpath: Type.Optional(Type.String({ description: \"Directory to search in (default: current directory)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of results (default: 1000)\" })),\n});\n\nexport type FindToolInput = Static<typeof findSchema>;\n\nconst DEFAULT_LIMIT = 1000;\n\nexport interface FindToolDetails {\n\ttruncation?: TruncationResult;\n\tresultLimitReached?: number;\n}\n\n/**\n * Pluggable operations for the find tool.\n * Override these to delegate file search to remote systems (e.g., SSH).\n */\nexport interface FindOperations {\n\t/** Check if path exists */\n\texists: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Find files matching glob pattern. Returns relative paths. */\n\tglob: (pattern: string, cwd: string, options: { ignore: string[]; limit: number }) => Promise<string[]> | string[];\n}\n\nconst defaultFindOperations: FindOperations = {\n\texists: existsSync,\n\tglob: (_pattern, _searchCwd, _options) => {\n\t\t// This is a placeholder - actual fd execution happens in execute\n\t\treturn [];\n\t},\n};\n\nexport interface FindToolOptions {\n\t/** Custom operations for find. Default: local filesystem + fd */\n\toperations?: FindOperations;\n}\n\nexport function createFindTool(cwd: string, options?: FindToolOptions): AgentTool<typeof findSchema> {\n\tconst customOps = options?.operations;\n\n\treturn {\n\t\tname: \"find\",\n\t\tlabel: \"find\",\n\t\tdescription: `Search for files by glob pattern. Returns matching file paths relative to the search directory. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} results or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first).`,\n\t\tparameters: findSchema,\n\t\texecute: async (\n\t\t\t_toolCallId: string,\n\t\t\t{ pattern, path: searchDir, limit }: { pattern: string; path?: string; limit?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t) => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst onAbort = () => reject(new Error(\"Operation aborted\"));\n\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst searchPath = resolveToCwd(searchDir || \".\", cwd);\n\t\t\t\t\t\tconst effectiveLimit = limit ?? DEFAULT_LIMIT;\n\t\t\t\t\t\tconst ops = customOps ?? defaultFindOperations;\n\n\t\t\t\t\t\t// If custom operations provided with glob, use that\n\t\t\t\t\t\tif (customOps?.glob) {\n\t\t\t\t\t\t\tif (!(await ops.exists(searchPath))) {\n\t\t\t\t\t\t\t\treject(new Error(`Path not found: ${searchPath}`));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst results = await ops.glob(pattern, searchPath, {\n\t\t\t\t\t\t\t\tignore: [\"**/node_modules/**\", \"**/.git/**\"],\n\t\t\t\t\t\t\t\tlimit: effectiveLimit,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\n\t\t\t\t\t\t\tif (results.length === 0) {\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No files found matching pattern\" }],\n\t\t\t\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Relativize paths\n\t\t\t\t\t\t\tconst relativized = results.map((p) => {\n\t\t\t\t\t\t\t\tif (p.startsWith(searchPath)) {\n\t\t\t\t\t\t\t\t\treturn p.slice(searchPath.length + 1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn path.relative(searchPath, p);\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst resultLimitReached = relativized.length >= effectiveLimit;\n\t\t\t\t\t\t\tconst rawOutput = relativized.join(\"\\n\");\n\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\n\t\t\t\t\t\t\tlet resultOutput = truncation.content;\n\t\t\t\t\t\t\tconst details: FindToolDetails = {};\n\t\t\t\t\t\t\tconst notices: string[] = [];\n\n\t\t\t\t\t\t\tif (resultLimitReached) {\n\t\t\t\t\t\t\t\tnotices.push(`${effectiveLimit} results limit reached`);\n\t\t\t\t\t\t\t\tdetails.resultLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (notices.length > 0) {\n\t\t\t\t\t\t\t\tresultOutput += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: resultOutput }],\n\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Default: use fd\n\t\t\t\t\t\tconst fdPath = await ensureTool(\"fd\", true);\n\t\t\t\t\t\tif (!fdPath) {\n\t\t\t\t\t\t\treject(new Error(\"fd is not available and could not be downloaded\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Build fd arguments\n\t\t\t\t\t\tconst args: string[] = [\n\t\t\t\t\t\t\t\"--glob\",\n\t\t\t\t\t\t\t\"--color=never\",\n\t\t\t\t\t\t\t\"--hidden\",\n\t\t\t\t\t\t\t\"--max-results\",\n\t\t\t\t\t\t\tString(effectiveLimit),\n\t\t\t\t\t\t];\n\n\t\t\t\t\t\t// Include .gitignore files\n\t\t\t\t\t\tconst gitignoreFiles = new Set<string>();\n\t\t\t\t\t\tconst rootGitignore = path.join(searchPath, \".gitignore\");\n\t\t\t\t\t\tif (existsSync(rootGitignore)) {\n\t\t\t\t\t\t\tgitignoreFiles.add(rootGitignore);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst nestedGitignores = globSync(\"**/.gitignore\", {\n\t\t\t\t\t\t\t\tcwd: searchPath,\n\t\t\t\t\t\t\t\tdot: true,\n\t\t\t\t\t\t\t\tabsolute: true,\n\t\t\t\t\t\t\t\tignore: [\"**/node_modules/**\", \"**/.git/**\"],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tfor (const file of nestedGitignores) {\n\t\t\t\t\t\t\t\tgitignoreFiles.add(file);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// Ignore glob errors\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const gitignorePath of gitignoreFiles) {\n\t\t\t\t\t\t\targs.push(\"--ignore-file\", gitignorePath);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\targs.push(pattern, searchPath);\n\n\t\t\t\t\t\tconst result = spawnSync(fdPath, args, {\n\t\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t\t\tmaxBuffer: 10 * 1024 * 1024,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\n\t\t\t\t\t\tif (result.error) {\n\t\t\t\t\t\t\treject(new Error(`Failed to run fd: ${result.error.message}`));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst output = result.stdout?.trim() || \"\";\n\n\t\t\t\t\t\tif (result.status !== 0) {\n\t\t\t\t\t\t\tconst errorMsg = result.stderr?.trim() || `fd exited with code ${result.status}`;\n\t\t\t\t\t\t\tif (!output) {\n\t\t\t\t\t\t\t\treject(new Error(errorMsg));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!output) {\n\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No files found matching pattern\" }],\n\t\t\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst lines = output.split(\"\\n\");\n\t\t\t\t\t\tconst relativized: string[] = [];\n\n\t\t\t\t\t\tfor (const rawLine of lines) {\n\t\t\t\t\t\t\tconst line = rawLine.replace(/\\r$/, \"\").trim();\n\t\t\t\t\t\t\tif (!line) continue;\n\n\t\t\t\t\t\t\tconst hadTrailingSlash = line.endsWith(\"/\") || line.endsWith(\"\\\\\");\n\t\t\t\t\t\t\tlet relativePath = line;\n\t\t\t\t\t\t\tif (line.startsWith(searchPath)) {\n\t\t\t\t\t\t\t\trelativePath = line.slice(searchPath.length + 1);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\trelativePath = path.relative(searchPath, line);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (hadTrailingSlash && !relativePath.endsWith(\"/\")) {\n\t\t\t\t\t\t\t\trelativePath += \"/\";\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\trelativized.push(relativePath);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst resultLimitReached = relativized.length >= effectiveLimit;\n\t\t\t\t\t\tconst rawOutput = relativized.join(\"\\n\");\n\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\n\t\t\t\t\t\tlet resultOutput = truncation.content;\n\t\t\t\t\t\tconst details: FindToolDetails = {};\n\t\t\t\t\t\tconst notices: string[] = [];\n\n\t\t\t\t\t\tif (resultLimitReached) {\n\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t`${effectiveLimit} results limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tdetails.resultLimitReached = effectiveLimit;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (notices.length > 0) {\n\t\t\t\t\t\t\tresultOutput += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: resultOutput }],\n\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (e: any) {\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\treject(e);\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t},\n\t};\n}\n\n/** Default find tool using process.cwd() - for backwards compatibility */\nexport const findTool = createFindTool(process.cwd());\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AgentTool } from "@gsd/pi-agent-core";
|
|
2
|
+
import { type Static } from "@sinclair/typebox";
|
|
3
|
+
import { type TruncationResult } from "./truncate.js";
|
|
4
|
+
declare const grepSchema: import("@sinclair/typebox").TObject<{
|
|
5
|
+
pattern: import("@sinclair/typebox").TString;
|
|
6
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
7
|
+
glob: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
8
|
+
ignoreCase: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
9
|
+
literal: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
10
|
+
context: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
11
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
12
|
+
}>;
|
|
13
|
+
export type GrepToolInput = Static<typeof grepSchema>;
|
|
14
|
+
export interface GrepToolDetails {
|
|
15
|
+
truncation?: TruncationResult;
|
|
16
|
+
matchLimitReached?: number;
|
|
17
|
+
linesTruncated?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Pluggable operations for the grep tool.
|
|
21
|
+
* Override these to delegate search to remote systems (e.g., SSH).
|
|
22
|
+
*/
|
|
23
|
+
export interface GrepOperations {
|
|
24
|
+
/** Check if path is a directory. Throws if path doesn't exist. */
|
|
25
|
+
isDirectory: (absolutePath: string) => Promise<boolean> | boolean;
|
|
26
|
+
/** Read file contents for context lines */
|
|
27
|
+
readFile: (absolutePath: string) => Promise<string> | string;
|
|
28
|
+
}
|
|
29
|
+
export interface GrepToolOptions {
|
|
30
|
+
/** Custom operations for grep. Default: local filesystem + ripgrep */
|
|
31
|
+
operations?: GrepOperations;
|
|
32
|
+
}
|
|
33
|
+
export declare function createGrepTool(cwd: string, options?: GrepToolOptions): AgentTool<typeof grepSchema>;
|
|
34
|
+
/** Default grep tool using process.cwd() - for backwards compatibility */
|
|
35
|
+
export declare const grepTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
36
|
+
pattern: import("@sinclair/typebox").TString;
|
|
37
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
38
|
+
glob: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
39
|
+
ignoreCase: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
40
|
+
literal: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
41
|
+
context: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
42
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
43
|
+
}>, any>;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=grep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAMtD,OAAO,EAIN,KAAK,gBAAgB,EAGrB,MAAM,eAAe,CAAC;AAEvB,QAAA,MAAM,UAAU;;;;;;;;EAYd,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAItD,MAAM,WAAW,eAAe;IAC/B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,kEAAkE;IAClE,WAAW,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAClE,2CAA2C;IAC3C,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;CAC7D;AAOD,MAAM,WAAW,eAAe;IAC/B,sEAAsE;IACtE,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAwRnG;AAED,0EAA0E;AAC1E,eAAO,MAAM,QAAQ;;;;;;;;QAAgC,CAAC"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { createInterface } from "node:readline";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { spawn } from "child_process";
|
|
4
|
+
import { readFileSync, statSync } from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { ensureTool } from "../../utils/tools-manager.js";
|
|
7
|
+
import { resolveToCwd } from "./path-utils.js";
|
|
8
|
+
import { DEFAULT_MAX_BYTES, formatSize, GREP_MAX_LINE_LENGTH, truncateHead, truncateLine, } from "./truncate.js";
|
|
9
|
+
const grepSchema = Type.Object({
|
|
10
|
+
pattern: Type.String({ description: "Search pattern (regex or literal string)" }),
|
|
11
|
+
path: Type.Optional(Type.String({ description: "Directory or file to search (default: current directory)" })),
|
|
12
|
+
glob: Type.Optional(Type.String({ description: "Filter files by glob pattern, e.g. '*.ts' or '**/*.spec.ts'" })),
|
|
13
|
+
ignoreCase: Type.Optional(Type.Boolean({ description: "Case-insensitive search (default: false)" })),
|
|
14
|
+
literal: Type.Optional(Type.Boolean({ description: "Treat pattern as literal string instead of regex (default: false)" })),
|
|
15
|
+
context: Type.Optional(Type.Number({ description: "Number of lines to show before and after each match (default: 0)" })),
|
|
16
|
+
limit: Type.Optional(Type.Number({ description: "Maximum number of matches to return (default: 100)" })),
|
|
17
|
+
});
|
|
18
|
+
const DEFAULT_LIMIT = 100;
|
|
19
|
+
const defaultGrepOperations = {
|
|
20
|
+
isDirectory: (p) => statSync(p).isDirectory(),
|
|
21
|
+
readFile: (p) => readFileSync(p, "utf-8"),
|
|
22
|
+
};
|
|
23
|
+
export function createGrepTool(cwd, options) {
|
|
24
|
+
const customOps = options?.operations;
|
|
25
|
+
return {
|
|
26
|
+
name: "grep",
|
|
27
|
+
label: "grep",
|
|
28
|
+
description: `Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} matches or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Long lines are truncated to ${GREP_MAX_LINE_LENGTH} chars.`,
|
|
29
|
+
parameters: grepSchema,
|
|
30
|
+
execute: async (_toolCallId, { pattern, path: searchDir, glob, ignoreCase, literal, context, limit, }, signal) => {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
if (signal?.aborted) {
|
|
33
|
+
reject(new Error("Operation aborted"));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
let settled = false;
|
|
37
|
+
const settle = (fn) => {
|
|
38
|
+
if (!settled) {
|
|
39
|
+
settled = true;
|
|
40
|
+
fn();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
(async () => {
|
|
44
|
+
try {
|
|
45
|
+
const rgPath = await ensureTool("rg", true);
|
|
46
|
+
if (!rgPath) {
|
|
47
|
+
settle(() => reject(new Error("ripgrep (rg) is not available and could not be downloaded")));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const searchPath = resolveToCwd(searchDir || ".", cwd);
|
|
51
|
+
const ops = customOps ?? defaultGrepOperations;
|
|
52
|
+
let isDirectory;
|
|
53
|
+
try {
|
|
54
|
+
isDirectory = await ops.isDirectory(searchPath);
|
|
55
|
+
}
|
|
56
|
+
catch (_err) {
|
|
57
|
+
settle(() => reject(new Error(`Path not found: ${searchPath}`)));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const contextValue = context && context > 0 ? context : 0;
|
|
61
|
+
const effectiveLimit = Math.max(1, limit ?? DEFAULT_LIMIT);
|
|
62
|
+
const formatPath = (filePath) => {
|
|
63
|
+
if (isDirectory) {
|
|
64
|
+
const relative = path.relative(searchPath, filePath);
|
|
65
|
+
if (relative && !relative.startsWith("..")) {
|
|
66
|
+
return relative.replace(/\\/g, "/");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return path.basename(filePath);
|
|
70
|
+
};
|
|
71
|
+
const fileCache = new Map();
|
|
72
|
+
const getFileLines = async (filePath) => {
|
|
73
|
+
let lines = fileCache.get(filePath);
|
|
74
|
+
if (!lines) {
|
|
75
|
+
try {
|
|
76
|
+
const content = await ops.readFile(filePath);
|
|
77
|
+
lines = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
lines = [];
|
|
81
|
+
}
|
|
82
|
+
fileCache.set(filePath, lines);
|
|
83
|
+
}
|
|
84
|
+
return lines;
|
|
85
|
+
};
|
|
86
|
+
const args = ["--json", "--line-number", "--color=never", "--hidden"];
|
|
87
|
+
if (ignoreCase) {
|
|
88
|
+
args.push("--ignore-case");
|
|
89
|
+
}
|
|
90
|
+
if (literal) {
|
|
91
|
+
args.push("--fixed-strings");
|
|
92
|
+
}
|
|
93
|
+
if (glob) {
|
|
94
|
+
args.push("--glob", glob);
|
|
95
|
+
}
|
|
96
|
+
args.push(pattern, searchPath);
|
|
97
|
+
const child = spawn(rgPath, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
98
|
+
const rl = createInterface({ input: child.stdout });
|
|
99
|
+
let stderr = "";
|
|
100
|
+
let matchCount = 0;
|
|
101
|
+
let matchLimitReached = false;
|
|
102
|
+
let linesTruncated = false;
|
|
103
|
+
let aborted = false;
|
|
104
|
+
let killedDueToLimit = false;
|
|
105
|
+
const outputLines = [];
|
|
106
|
+
const cleanup = () => {
|
|
107
|
+
rl.close();
|
|
108
|
+
signal?.removeEventListener("abort", onAbort);
|
|
109
|
+
};
|
|
110
|
+
const stopChild = (dueToLimit = false) => {
|
|
111
|
+
if (!child.killed) {
|
|
112
|
+
killedDueToLimit = dueToLimit;
|
|
113
|
+
child.kill();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const onAbort = () => {
|
|
117
|
+
aborted = true;
|
|
118
|
+
stopChild();
|
|
119
|
+
};
|
|
120
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
121
|
+
child.stderr?.on("data", (chunk) => {
|
|
122
|
+
stderr += chunk.toString();
|
|
123
|
+
});
|
|
124
|
+
const formatBlock = async (filePath, lineNumber) => {
|
|
125
|
+
const relativePath = formatPath(filePath);
|
|
126
|
+
const lines = await getFileLines(filePath);
|
|
127
|
+
if (!lines.length) {
|
|
128
|
+
return [`${relativePath}:${lineNumber}: (unable to read file)`];
|
|
129
|
+
}
|
|
130
|
+
const block = [];
|
|
131
|
+
const start = contextValue > 0 ? Math.max(1, lineNumber - contextValue) : lineNumber;
|
|
132
|
+
const end = contextValue > 0 ? Math.min(lines.length, lineNumber + contextValue) : lineNumber;
|
|
133
|
+
for (let current = start; current <= end; current++) {
|
|
134
|
+
const lineText = lines[current - 1] ?? "";
|
|
135
|
+
const sanitized = lineText.replace(/\r/g, "");
|
|
136
|
+
const isMatchLine = current === lineNumber;
|
|
137
|
+
// Truncate long lines
|
|
138
|
+
const { text: truncatedText, wasTruncated } = truncateLine(sanitized);
|
|
139
|
+
if (wasTruncated) {
|
|
140
|
+
linesTruncated = true;
|
|
141
|
+
}
|
|
142
|
+
if (isMatchLine) {
|
|
143
|
+
block.push(`${relativePath}:${current}: ${truncatedText}`);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
block.push(`${relativePath}-${current}- ${truncatedText}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return block;
|
|
150
|
+
};
|
|
151
|
+
// Collect matches during streaming, format after
|
|
152
|
+
const matches = [];
|
|
153
|
+
rl.on("line", (line) => {
|
|
154
|
+
if (!line.trim() || matchCount >= effectiveLimit) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
let event;
|
|
158
|
+
try {
|
|
159
|
+
event = JSON.parse(line);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (event.type === "match") {
|
|
165
|
+
matchCount++;
|
|
166
|
+
const filePath = event.data?.path?.text;
|
|
167
|
+
const lineNumber = event.data?.line_number;
|
|
168
|
+
if (filePath && typeof lineNumber === "number") {
|
|
169
|
+
matches.push({ filePath, lineNumber });
|
|
170
|
+
}
|
|
171
|
+
if (matchCount >= effectiveLimit) {
|
|
172
|
+
matchLimitReached = true;
|
|
173
|
+
stopChild(true);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
child.on("error", (error) => {
|
|
178
|
+
cleanup();
|
|
179
|
+
settle(() => reject(new Error(`Failed to run ripgrep: ${error.message}`)));
|
|
180
|
+
});
|
|
181
|
+
child.on("close", async (code) => {
|
|
182
|
+
cleanup();
|
|
183
|
+
if (aborted) {
|
|
184
|
+
settle(() => reject(new Error("Operation aborted")));
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (!killedDueToLimit && code !== 0 && code !== 1) {
|
|
188
|
+
const errorMsg = stderr.trim() || `ripgrep exited with code ${code}`;
|
|
189
|
+
settle(() => reject(new Error(errorMsg)));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (matchCount === 0) {
|
|
193
|
+
settle(() => resolve({ content: [{ type: "text", text: "No matches found" }], details: undefined }));
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
// Format matches (async to support remote file reading)
|
|
197
|
+
for (const match of matches) {
|
|
198
|
+
const block = await formatBlock(match.filePath, match.lineNumber);
|
|
199
|
+
outputLines.push(...block);
|
|
200
|
+
}
|
|
201
|
+
// Apply byte truncation (no line limit since we already have match limit)
|
|
202
|
+
const rawOutput = outputLines.join("\n");
|
|
203
|
+
const truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });
|
|
204
|
+
let output = truncation.content;
|
|
205
|
+
const details = {};
|
|
206
|
+
// Build notices
|
|
207
|
+
const notices = [];
|
|
208
|
+
if (matchLimitReached) {
|
|
209
|
+
notices.push(`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`);
|
|
210
|
+
details.matchLimitReached = effectiveLimit;
|
|
211
|
+
}
|
|
212
|
+
if (truncation.truncated) {
|
|
213
|
+
notices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);
|
|
214
|
+
details.truncation = truncation;
|
|
215
|
+
}
|
|
216
|
+
if (linesTruncated) {
|
|
217
|
+
notices.push(`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`);
|
|
218
|
+
details.linesTruncated = true;
|
|
219
|
+
}
|
|
220
|
+
if (notices.length > 0) {
|
|
221
|
+
output += `\n\n[${notices.join(". ")}]`;
|
|
222
|
+
}
|
|
223
|
+
settle(() => resolve({
|
|
224
|
+
content: [{ type: "text", text: output }],
|
|
225
|
+
details: Object.keys(details).length > 0 ? details : undefined,
|
|
226
|
+
}));
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
settle(() => reject(err));
|
|
231
|
+
}
|
|
232
|
+
})();
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** Default grep tool using process.cwd() - for backwards compatibility */
|
|
238
|
+
export const grepTool = createGrepTool(process.cwd());
|
|
239
|
+
//# sourceMappingURL=grep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grep.js","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,O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AC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC","sourcesContent":["import { createInterface } from \"node:readline\";\nimport type { AgentTool } from \"@gsd/pi-agent-core\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport { spawn } from \"child_process\";\nimport { readFileSync, statSync } from \"fs\";\nimport path from \"path\";\nimport { ensureTool } from \"../../utils/tools-manager.js\";\nimport { resolveToCwd } from \"./path-utils.js\";\nimport {\n\tDEFAULT_MAX_BYTES,\n\tformatSize,\n\tGREP_MAX_LINE_LENGTH,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n} from \"./truncate.js\";\n\nconst grepSchema = Type.Object({\n\tpattern: Type.String({ description: \"Search pattern (regex or literal string)\" }),\n\tpath: Type.Optional(Type.String({ description: \"Directory or file to search (default: current directory)\" })),\n\tglob: Type.Optional(Type.String({ description: \"Filter files by glob pattern, e.g. '*.ts' or '**/*.spec.ts'\" })),\n\tignoreCase: Type.Optional(Type.Boolean({ description: \"Case-insensitive search (default: false)\" })),\n\tliteral: Type.Optional(\n\t\tType.Boolean({ description: \"Treat pattern as literal string instead of regex (default: false)\" }),\n\t),\n\tcontext: Type.Optional(\n\t\tType.Number({ description: \"Number of lines to show before and after each match (default: 0)\" }),\n\t),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of matches to return (default: 100)\" })),\n});\n\nexport type GrepToolInput = Static<typeof grepSchema>;\n\nconst DEFAULT_LIMIT = 100;\n\nexport interface GrepToolDetails {\n\ttruncation?: TruncationResult;\n\tmatchLimitReached?: number;\n\tlinesTruncated?: boolean;\n}\n\n/**\n * Pluggable operations for the grep tool.\n * Override these to delegate search to remote systems (e.g., SSH).\n */\nexport interface GrepOperations {\n\t/** Check if path is a directory. Throws if path doesn't exist. */\n\tisDirectory: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Read file contents for context lines */\n\treadFile: (absolutePath: string) => Promise<string> | string;\n}\n\nconst defaultGrepOperations: GrepOperations = {\n\tisDirectory: (p) => statSync(p).isDirectory(),\n\treadFile: (p) => readFileSync(p, \"utf-8\"),\n};\n\nexport interface GrepToolOptions {\n\t/** Custom operations for grep. Default: local filesystem + ripgrep */\n\toperations?: GrepOperations;\n}\n\nexport function createGrepTool(cwd: string, options?: GrepToolOptions): AgentTool<typeof grepSchema> {\n\tconst customOps = options?.operations;\n\n\treturn {\n\t\tname: \"grep\",\n\t\tlabel: \"grep\",\n\t\tdescription: `Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} matches or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Long lines are truncated to ${GREP_MAX_LINE_LENGTH} chars.`,\n\t\tparameters: grepSchema,\n\t\texecute: async (\n\t\t\t_toolCallId: string,\n\t\t\t{\n\t\t\t\tpattern,\n\t\t\t\tpath: searchDir,\n\t\t\t\tglob,\n\t\t\t\tignoreCase,\n\t\t\t\tliteral,\n\t\t\t\tcontext,\n\t\t\t\tlimit,\n\t\t\t}: {\n\t\t\t\tpattern: string;\n\t\t\t\tpath?: string;\n\t\t\t\tglob?: string;\n\t\t\t\tignoreCase?: boolean;\n\t\t\t\tliteral?: boolean;\n\t\t\t\tcontext?: number;\n\t\t\t\tlimit?: number;\n\t\t\t},\n\t\t\tsignal?: AbortSignal,\n\t\t) => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet settled = false;\n\t\t\t\tconst settle = (fn: () => void) => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tfn();\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst rgPath = await ensureTool(\"rg\", true);\n\t\t\t\t\t\tif (!rgPath) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"ripgrep (rg) is not available and could not be downloaded\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst searchPath = resolveToCwd(searchDir || \".\", cwd);\n\t\t\t\t\t\tconst ops = customOps ?? defaultGrepOperations;\n\n\t\t\t\t\t\tlet isDirectory: boolean;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tisDirectory = await ops.isDirectory(searchPath);\n\t\t\t\t\t\t} catch (_err) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Path not found: ${searchPath}`)));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst contextValue = context && context > 0 ? context : 0;\n\t\t\t\t\t\tconst effectiveLimit = Math.max(1, limit ?? DEFAULT_LIMIT);\n\n\t\t\t\t\t\tconst formatPath = (filePath: string): string => {\n\t\t\t\t\t\t\tif (isDirectory) {\n\t\t\t\t\t\t\t\tconst relative = path.relative(searchPath, filePath);\n\t\t\t\t\t\t\t\tif (relative && !relative.startsWith(\"..\")) {\n\t\t\t\t\t\t\t\t\treturn relative.replace(/\\\\/g, \"/\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn path.basename(filePath);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst fileCache = new Map<string, string[]>();\n\t\t\t\t\t\tconst getFileLines = async (filePath: string): Promise<string[]> => {\n\t\t\t\t\t\t\tlet lines = fileCache.get(filePath);\n\t\t\t\t\t\t\tif (!lines) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst content = await ops.readFile(filePath);\n\t\t\t\t\t\t\t\t\tlines = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\").split(\"\\n\");\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tlines = [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfileCache.set(filePath, lines);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn lines;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst args: string[] = [\"--json\", \"--line-number\", \"--color=never\", \"--hidden\"];\n\n\t\t\t\t\t\tif (ignoreCase) {\n\t\t\t\t\t\t\targs.push(\"--ignore-case\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (literal) {\n\t\t\t\t\t\t\targs.push(\"--fixed-strings\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (glob) {\n\t\t\t\t\t\t\targs.push(\"--glob\", glob);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\targs.push(pattern, searchPath);\n\n\t\t\t\t\t\tconst child = spawn(rgPath, args, { stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n\t\t\t\t\t\tconst rl = createInterface({ input: child.stdout });\n\t\t\t\t\t\tlet stderr = \"\";\n\t\t\t\t\t\tlet matchCount = 0;\n\t\t\t\t\t\tlet matchLimitReached = false;\n\t\t\t\t\t\tlet linesTruncated = false;\n\t\t\t\t\t\tlet aborted = false;\n\t\t\t\t\t\tlet killedDueToLimit = false;\n\t\t\t\t\t\tconst outputLines: string[] = [];\n\n\t\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\t\trl.close();\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst stopChild = (dueToLimit: boolean = false) => {\n\t\t\t\t\t\t\tif (!child.killed) {\n\t\t\t\t\t\t\t\tkilledDueToLimit = dueToLimit;\n\t\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\t\tstopChild();\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\t\t\t\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\t\t\t\t\tstderr += chunk.toString();\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst formatBlock = async (filePath: string, lineNumber: number): Promise<string[]> => {\n\t\t\t\t\t\t\tconst relativePath = formatPath(filePath);\n\t\t\t\t\t\t\tconst lines = await getFileLines(filePath);\n\t\t\t\t\t\t\tif (!lines.length) {\n\t\t\t\t\t\t\t\treturn [`${relativePath}:${lineNumber}: (unable to read file)`];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst block: string[] = [];\n\t\t\t\t\t\t\tconst start = contextValue > 0 ? Math.max(1, lineNumber - contextValue) : lineNumber;\n\t\t\t\t\t\t\tconst end = contextValue > 0 ? Math.min(lines.length, lineNumber + contextValue) : lineNumber;\n\n\t\t\t\t\t\t\tfor (let current = start; current <= end; current++) {\n\t\t\t\t\t\t\t\tconst lineText = lines[current - 1] ?? \"\";\n\t\t\t\t\t\t\t\tconst sanitized = lineText.replace(/\\r/g, \"\");\n\t\t\t\t\t\t\t\tconst isMatchLine = current === lineNumber;\n\n\t\t\t\t\t\t\t\t// Truncate long lines\n\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\tif (wasTruncated) {\n\t\t\t\t\t\t\t\t\tlinesTruncated = true;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (isMatchLine) {\n\t\t\t\t\t\t\t\t\tblock.push(`${relativePath}:${current}: ${truncatedText}`);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tblock.push(`${relativePath}-${current}- ${truncatedText}`);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn block;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// Collect matches during streaming, format after\n\t\t\t\t\t\tconst matches: Array<{ filePath: string; lineNumber: number }> = [];\n\n\t\t\t\t\t\trl.on(\"line\", (line) => {\n\t\t\t\t\t\t\tif (!line.trim() || matchCount >= effectiveLimit) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tlet event: any;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tevent = JSON.parse(line);\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (event.type === \"match\") {\n\t\t\t\t\t\t\t\tmatchCount++;\n\t\t\t\t\t\t\t\tconst filePath = event.data?.path?.text;\n\t\t\t\t\t\t\t\tconst lineNumber = event.data?.line_number;\n\n\t\t\t\t\t\t\t\tif (filePath && typeof lineNumber === \"number\") {\n\t\t\t\t\t\t\t\t\tmatches.push({ filePath, lineNumber });\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (matchCount >= effectiveLimit) {\n\t\t\t\t\t\t\t\t\tmatchLimitReached = true;\n\t\t\t\t\t\t\t\t\tstopChild(true);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Failed to run ripgrep: ${error.message}`)));\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchild.on(\"close\", async (code) => {\n\t\t\t\t\t\t\tcleanup();\n\n\t\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!killedDueToLimit && code !== 0 && code !== 1) {\n\t\t\t\t\t\t\t\tconst errorMsg = stderr.trim() || `ripgrep exited with code ${code}`;\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(errorMsg)));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (matchCount === 0) {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: \"No matches found\" }], details: undefined }),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Format matches (async to support remote file reading)\n\t\t\t\t\t\t\tfor (const match of matches) {\n\t\t\t\t\t\t\t\tconst block = await formatBlock(match.filePath, match.lineNumber);\n\t\t\t\t\t\t\t\toutputLines.push(...block);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Apply byte truncation (no line limit since we already have match limit)\n\t\t\t\t\t\t\tconst rawOutput = outputLines.join(\"\\n\");\n\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\n\t\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\t\tconst details: GrepToolDetails = {};\n\n\t\t\t\t\t\t\t// Build notices\n\t\t\t\t\t\t\tconst notices: string[] = [];\n\n\t\t\t\t\t\t\tif (matchLimitReached) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.matchLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (linesTruncated) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.linesTruncated = true;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (notices.length > 0) {\n\t\t\t\t\t\t\t\toutput += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tsettle(() => reject(err as Error));\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t},\n\t};\n}\n\n/** Default grep tool using process.cwd() - for backwards compatibility */\nexport const grepTool = createGrepTool(process.cwd());\n"]}
|