@mastra/code-sdk 0.0.0-fix-workflow-step-timing-and-parallel-status-20260715180716
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +285 -0
- package/LICENSE.md +30 -0
- package/README.md +50 -0
- package/dist/acp/agent.d.ts +35 -0
- package/dist/acp/agent.d.ts.map +1 -0
- package/dist/acp/agent.js +173 -0
- package/dist/acp/agent.js.map +1 -0
- package/dist/acp/event-mapper.d.ts +22 -0
- package/dist/acp/event-mapper.d.ts.map +1 -0
- package/dist/acp/event-mapper.js +166 -0
- package/dist/acp/event-mapper.js.map +1 -0
- package/dist/acp/index.d.ts +8 -0
- package/dist/acp/index.d.ts.map +1 -0
- package/dist/acp/index.js +54 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/acp/server.d.ts +7 -0
- package/dist/acp/server.d.ts.map +1 -0
- package/dist/acp/server.js +34 -0
- package/dist/acp/server.js.map +1 -0
- package/dist/acp.d.ts +2 -0
- package/dist/acp.d.ts.map +1 -0
- package/dist/acp.js +5 -0
- package/dist/acp.js.map +1 -0
- package/dist/agents/instructions.d.ts +6 -0
- package/dist/agents/instructions.d.ts.map +1 -0
- package/dist/agents/instructions.js +41 -0
- package/dist/agents/instructions.js.map +1 -0
- package/dist/agents/mastracode-gateway.d.ts +67 -0
- package/dist/agents/mastracode-gateway.d.ts.map +1 -0
- package/dist/agents/mastracode-gateway.js +446 -0
- package/dist/agents/mastracode-gateway.js.map +1 -0
- package/dist/agents/memory.d.ts +13 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/memory.js +107 -0
- package/dist/agents/memory.js.map +1 -0
- package/dist/agents/model.d.ts +55 -0
- package/dist/agents/model.d.ts.map +1 -0
- package/dist/agents/model.js +115 -0
- package/dist/agents/model.js.map +1 -0
- package/dist/agents/modes/build.d.ts +10 -0
- package/dist/agents/modes/build.d.ts.map +1 -0
- package/dist/agents/modes/build.js +45 -0
- package/dist/agents/modes/build.js.map +1 -0
- package/dist/agents/modes/explore.d.ts +10 -0
- package/dist/agents/modes/explore.d.ts.map +1 -0
- package/dist/agents/modes/explore.js +38 -0
- package/dist/agents/modes/explore.js.map +1 -0
- package/dist/agents/modes/plan.d.ts +6 -0
- package/dist/agents/modes/plan.d.ts.map +1 -0
- package/dist/agents/modes/plan.js +38 -0
- package/dist/agents/modes/plan.js.map +1 -0
- package/dist/agents/prompts/agent-instructions.d.ts +20 -0
- package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
- package/dist/agents/prompts/agent-instructions.js +82 -0
- package/dist/agents/prompts/agent-instructions.js.map +1 -0
- package/dist/agents/prompts/build.d.ts +12 -0
- package/dist/agents/prompts/build.d.ts.map +1 -0
- package/dist/agents/prompts/build.js +73 -0
- package/dist/agents/prompts/build.js.map +1 -0
- package/dist/agents/prompts/fast.d.ts +5 -0
- package/dist/agents/prompts/fast.d.ts.map +1 -0
- package/dist/agents/prompts/fast.js +22 -0
- package/dist/agents/prompts/fast.js.map +1 -0
- package/dist/agents/prompts/index.d.ts +19 -0
- package/dist/agents/prompts/index.d.ts.map +1 -0
- package/dist/agents/prompts/index.js +57 -0
- package/dist/agents/prompts/index.js.map +1 -0
- package/dist/agents/prompts/model.d.ts +5 -0
- package/dist/agents/prompts/model.d.ts.map +1 -0
- package/dist/agents/prompts/model.js +22 -0
- package/dist/agents/prompts/model.js.map +1 -0
- package/dist/agents/prompts/plan.d.ts +6 -0
- package/dist/agents/prompts/plan.d.ts.map +1 -0
- package/dist/agents/prompts/plan.js +107 -0
- package/dist/agents/prompts/plan.js.map +1 -0
- package/dist/agents/prompts/tool-guidance.d.ts +13 -0
- package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
- package/dist/agents/prompts/tool-guidance.js +181 -0
- package/dist/agents/prompts/tool-guidance.js.map +1 -0
- package/dist/agents/sandbox-filesystem.d.ts +89 -0
- package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
- package/dist/agents/sandbox-filesystem.js +268 -0
- package/dist/agents/sandbox-filesystem.js.map +1 -0
- package/dist/agents/sandbox-reattach.d.ts +19 -0
- package/dist/agents/sandbox-reattach.d.ts.map +1 -0
- package/dist/agents/sandbox-reattach.js +17 -0
- package/dist/agents/sandbox-reattach.js.map +1 -0
- package/dist/agents/thread-caveman-state.d.ts +17 -0
- package/dist/agents/thread-caveman-state.d.ts.map +1 -0
- package/dist/agents/thread-caveman-state.js +96 -0
- package/dist/agents/thread-caveman-state.js.map +1 -0
- package/dist/agents/tool-availability.d.ts +10 -0
- package/dist/agents/tool-availability.d.ts.map +1 -0
- package/dist/agents/tool-availability.js +105 -0
- package/dist/agents/tool-availability.js.map +1 -0
- package/dist/agents/tools.d.ts +19 -0
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +145 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/agents/workspace.d.ts +22 -0
- package/dist/agents/workspace.d.ts.map +1 -0
- package/dist/agents/workspace.js +226 -0
- package/dist/agents/workspace.js.map +1 -0
- package/dist/analytics.d.ts +18 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +152 -0
- package/dist/analytics.js.map +1 -0
- package/dist/auth/index.d.ts +9 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +11 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +21 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/providers/anthropic.d.ts +17 -0
- package/dist/auth/providers/anthropic.d.ts.map +1 -0
- package/dist/auth/providers/anthropic.js +94 -0
- package/dist/auth/providers/anthropic.js.map +1 -0
- package/dist/auth/providers/github-copilot.d.ts +100 -0
- package/dist/auth/providers/github-copilot.d.ts.map +1 -0
- package/dist/auth/providers/github-copilot.js +302 -0
- package/dist/auth/providers/github-copilot.js.map +1 -0
- package/dist/auth/providers/openai-codex.d.ts +95 -0
- package/dist/auth/providers/openai-codex.d.ts.map +1 -0
- package/dist/auth/providers/openai-codex.js +527 -0
- package/dist/auth/providers/openai-codex.js.map +1 -0
- package/dist/auth/storage.d.ts +91 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +187 -0
- package/dist/auth/storage.js.map +1 -0
- package/dist/auth/types.d.ts +68 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.d.ts.map +1 -0
- package/dist/clipboard/index.js +192 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +23 -0
- package/dist/constants.js.map +1 -0
- package/dist/error-classification.d.ts +10 -0
- package/dist/error-classification.d.ts.map +1 -0
- package/dist/error-classification.js +14 -0
- package/dist/error-classification.js.map +1 -0
- package/dist/evals/context-builder.d.ts +41 -0
- package/dist/evals/context-builder.d.ts.map +1 -0
- package/dist/evals/context-builder.js +120 -0
- package/dist/evals/context-builder.js.map +1 -0
- package/dist/evals/index.d.ts +4 -0
- package/dist/evals/index.d.ts.map +1 -0
- package/dist/evals/index.js +8 -0
- package/dist/evals/index.js.map +1 -0
- package/dist/evals/scorers/classify-command.d.ts +31 -0
- package/dist/evals/scorers/classify-command.d.ts.map +1 -0
- package/dist/evals/scorers/classify-command.js +52 -0
- package/dist/evals/scorers/classify-command.js.map +1 -0
- package/dist/evals/scorers/efficiency.d.ts +44 -0
- package/dist/evals/scorers/efficiency.d.ts.map +1 -0
- package/dist/evals/scorers/efficiency.js +201 -0
- package/dist/evals/scorers/efficiency.js.map +1 -0
- package/dist/evals/scorers/extract-tools.d.ts +25 -0
- package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
- package/dist/evals/scorers/extract-tools.js +56 -0
- package/dist/evals/scorers/extract-tools.js.map +1 -0
- package/dist/evals/scorers/index.d.ts +3 -0
- package/dist/evals/scorers/index.d.ts.map +1 -0
- package/dist/evals/scorers/index.js +7 -0
- package/dist/evals/scorers/index.js.map +1 -0
- package/dist/evals/scorers/outcome.d.ts +49 -0
- package/dist/evals/scorers/outcome.d.ts.map +1 -0
- package/dist/evals/scorers/outcome.js +238 -0
- package/dist/evals/scorers/outcome.js.map +1 -0
- package/dist/headless/cli.d.ts +42 -0
- package/dist/headless/cli.d.ts.map +1 -0
- package/dist/headless/cli.js +196 -0
- package/dist/headless/cli.js.map +1 -0
- package/dist/headless/flags.d.ts +33 -0
- package/dist/headless/flags.d.ts.map +1 -0
- package/dist/headless/flags.js +188 -0
- package/dist/headless/flags.js.map +1 -0
- package/dist/headless/format.d.ts +38 -0
- package/dist/headless/format.d.ts.map +1 -0
- package/dist/headless/format.js +85 -0
- package/dist/headless/format.js.map +1 -0
- package/dist/headless/index.d.ts +25 -0
- package/dist/headless/index.d.ts.map +1 -0
- package/dist/headless/index.js +32 -0
- package/dist/headless/index.js.map +1 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.d.ts.map +1 -0
- package/dist/headless/policy.js +38 -0
- package/dist/headless/policy.js.map +1 -0
- package/dist/headless/run-mc.d.ts +7 -0
- package/dist/headless/run-mc.d.ts.map +1 -0
- package/dist/headless/run-mc.js +296 -0
- package/dist/headless/run-mc.js.map +1 -0
- package/dist/headless/types.d.ts +134 -0
- package/dist/headless/types.d.ts.map +1 -0
- package/dist/headless/types.js +9 -0
- package/dist/headless/types.js.map +1 -0
- package/dist/hooks/config.d.ts +11 -0
- package/dist/hooks/config.d.ts.map +1 -0
- package/dist/hooks/config.js +78 -0
- package/dist/hooks/config.js.map +1 -0
- package/dist/hooks/executor.d.ts +13 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +125 -0
- package/dist/hooks/executor.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +16 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/manager.d.ts +47 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +284 -0
- package/dist/hooks/manager.js.map +1 -0
- package/dist/hooks/types.d.ts +152 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +7 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +243 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +730 -0
- package/dist/index.js.map +1 -0
- package/dist/ipc/ipc-reporter.d.ts +14 -0
- package/dist/ipc/ipc-reporter.d.ts.map +1 -0
- package/dist/ipc/ipc-reporter.js +24 -0
- package/dist/ipc/ipc-reporter.js.map +1 -0
- package/dist/lsp/client.d.ts +56 -0
- package/dist/lsp/client.d.ts.map +1 -0
- package/dist/lsp/client.js +309 -0
- package/dist/lsp/client.js.map +1 -0
- package/dist/lsp/index.d.ts +4 -0
- package/dist/lsp/index.d.ts.map +1 -0
- package/dist/lsp/index.js +9 -0
- package/dist/lsp/index.js.map +1 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.d.ts.map +1 -0
- package/dist/lsp/language.js +48 -0
- package/dist/lsp/language.js.map +1 -0
- package/dist/lsp/manager.d.ts +34 -0
- package/dist/lsp/manager.d.ts.map +1 -0
- package/dist/lsp/manager.js +97 -0
- package/dist/lsp/manager.js.map +1 -0
- package/dist/lsp/server.d.ts +27 -0
- package/dist/lsp/server.d.ts.map +1 -0
- package/dist/lsp/server.js +128 -0
- package/dist/lsp/server.js.map +1 -0
- package/dist/lsp/workspace.d.ts +9 -0
- package/dist/lsp/workspace.d.ts.map +1 -0
- package/dist/lsp/workspace.js +52 -0
- package/dist/lsp/workspace.js.map +1 -0
- package/dist/mcp/config.d.ts +34 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +205 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +10 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/manager.d.ts +49 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +374 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/types.d.ts +85 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +1 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/onboarding/custom-packs.d.ts +7 -0
- package/dist/onboarding/custom-packs.d.ts.map +1 -0
- package/dist/onboarding/custom-packs.js +20 -0
- package/dist/onboarding/custom-packs.js.map +1 -0
- package/dist/onboarding/custom-providers.d.ts +4 -0
- package/dist/onboarding/custom-providers.d.ts.map +1 -0
- package/dist/onboarding/custom-providers.js +28 -0
- package/dist/onboarding/custom-providers.js.map +1 -0
- package/dist/onboarding/index.d.ts +5 -0
- package/dist/onboarding/index.d.ts.map +1 -0
- package/dist/onboarding/index.js +21 -0
- package/dist/onboarding/index.js.map +1 -0
- package/dist/onboarding/om-settings.d.ts +20 -0
- package/dist/onboarding/om-settings.d.ts.map +1 -0
- package/dist/onboarding/om-settings.js +26 -0
- package/dist/onboarding/om-settings.js.map +1 -0
- package/dist/onboarding/packs.d.ts +48 -0
- package/dist/onboarding/packs.d.ts.map +1 -0
- package/dist/onboarding/packs.js +111 -0
- package/dist/onboarding/packs.js.map +1 -0
- package/dist/onboarding/settings.d.ts +327 -0
- package/dist/onboarding/settings.d.ts.map +1 -0
- package/dist/onboarding/settings.js +598 -0
- package/dist/onboarding/settings.js.map +1 -0
- package/dist/permissions.d.ts +55 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +119 -0
- package/dist/permissions.js.map +1 -0
- package/dist/plugin.d.ts +81 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +30 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/dependencies.d.ts +9 -0
- package/dist/plugins/dependencies.d.ts.map +1 -0
- package/dist/plugins/dependencies.js +111 -0
- package/dist/plugins/dependencies.js.map +1 -0
- package/dist/plugins/install.d.ts +21 -0
- package/dist/plugins/install.d.ts.map +1 -0
- package/dist/plugins/install.js +200 -0
- package/dist/plugins/install.js.map +1 -0
- package/dist/plugins/loader.d.ts +15 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +221 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manager.d.ts +60 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +378 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/manifest.d.ts +14 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +75 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/package-link.d.ts +3 -0
- package/dist/plugins/package-link.d.ts.map +1 -0
- package/dist/plugins/package-link.js +77 -0
- package/dist/plugins/package-link.js.map +1 -0
- package/dist/plugins/paths.d.ts +10 -0
- package/dist/plugins/paths.d.ts.map +1 -0
- package/dist/plugins/paths.js +26 -0
- package/dist/plugins/paths.js.map +1 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +96 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/scaffold.d.ts +10 -0
- package/dist/plugins/scaffold.d.ts.map +1 -0
- package/dist/plugins/scaffold.js +152 -0
- package/dist/plugins/scaffold.js.map +1 -0
- package/dist/plugins/types.d.ts +45 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +1 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/processors/plan-rejection-abort.d.ts +12 -0
- package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
- package/dist/processors/plan-rejection-abort.js +53 -0
- package/dist/processors/plan-rejection-abort.js.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +40 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.js +79 -0
- package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
- package/dist/providers/amazon-bedrock.d.ts +28 -0
- package/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock.js +62 -0
- package/dist/providers/amazon-bedrock.js.map +1 -0
- package/dist/providers/claude-max.d.ts +50 -0
- package/dist/providers/claude-max.d.ts.map +1 -0
- package/dist/providers/claude-max.js +151 -0
- package/dist/providers/claude-max.js.map +1 -0
- package/dist/providers/github-copilot.d.ts +58 -0
- package/dist/providers/github-copilot.d.ts.map +1 -0
- package/dist/providers/github-copilot.js +263 -0
- package/dist/providers/github-copilot.js.map +1 -0
- package/dist/providers/openai-codex.d.ts +70 -0
- package/dist/providers/openai-codex.d.ts.map +1 -0
- package/dist/providers/openai-codex.js +291 -0
- package/dist/providers/openai-codex.js.map +1 -0
- package/dist/schema.d.ts +167 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +92 -0
- package/dist/schema.js.map +1 -0
- package/dist/theme-palette.d.ts +17 -0
- package/dist/theme-palette.d.ts.map +1 -0
- package/dist/theme-palette.js +17 -0
- package/dist/theme-palette.js.map +1 -0
- package/dist/tool-names.d.ts +73 -0
- package/dist/tool-names.d.ts.map +1 -0
- package/dist/tool-names.js +43 -0
- package/dist/tool-names.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/request-sandbox-access.d.ts +6 -0
- package/dist/tools/request-sandbox-access.d.ts.map +1 -0
- package/dist/tools/request-sandbox-access.js +88 -0
- package/dist/tools/request-sandbox-access.js.map +1 -0
- package/dist/tools/utils.d.ts +20 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +22 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/tools/web-search.d.ts +35 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +65 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/utils/binaries.d.ts +7 -0
- package/dist/utils/binaries.d.ts.map +1 -0
- package/dist/utils/binaries.js +74 -0
- package/dist/utils/binaries.js.map +1 -0
- package/dist/utils/debug-log.d.ts +12 -0
- package/dist/utils/debug-log.d.ts.map +1 -0
- package/dist/utils/debug-log.js +55 -0
- package/dist/utils/debug-log.js.map +1 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +207 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/gateway-sync.d.ts +26 -0
- package/dist/utils/gateway-sync.d.ts.map +1 -0
- package/dist/utils/gateway-sync.js +49 -0
- package/dist/utils/gateway-sync.js.map +1 -0
- package/dist/utils/path-security.d.ts +2 -0
- package/dist/utils/path-security.d.ts.map +1 -0
- package/dist/utils/path-security.js +9 -0
- package/dist/utils/path-security.js.map +1 -0
- package/dist/utils/plan-diff.d.ts +25 -0
- package/dist/utils/plan-diff.d.ts.map +1 -0
- package/dist/utils/plan-diff.js +43 -0
- package/dist/utils/plan-diff.js.map +1 -0
- package/dist/utils/plans.d.ts +56 -0
- package/dist/utils/plans.d.ts.map +1 -0
- package/dist/utils/plans.js +99 -0
- package/dist/utils/plans.js.map +1 -0
- package/dist/utils/project.d.ts +160 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +302 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/signals-pubsub.d.ts +41 -0
- package/dist/utils/signals-pubsub.d.ts.map +1 -0
- package/dist/utils/signals-pubsub.js +104 -0
- package/dist/utils/signals-pubsub.js.map +1 -0
- package/dist/utils/slash-command-loader.d.ts +52 -0
- package/dist/utils/slash-command-loader.d.ts.map +1 -0
- package/dist/utils/slash-command-loader.js +177 -0
- package/dist/utils/slash-command-loader.js.map +1 -0
- package/dist/utils/slash-command-processor.d.ts +14 -0
- package/dist/utils/slash-command-processor.d.ts.map +1 -0
- package/dist/utils/slash-command-processor.js +96 -0
- package/dist/utils/slash-command-processor.js.map +1 -0
- package/dist/utils/stdin-pipe.d.ts +33 -0
- package/dist/utils/stdin-pipe.d.ts.map +1 -0
- package/dist/utils/stdin-pipe.js +72 -0
- package/dist/utils/stdin-pipe.js.map +1 -0
- package/dist/utils/storage-factory.d.ts +50 -0
- package/dist/utils/storage-factory.d.ts.map +1 -0
- package/dist/utils/storage-factory.js +101 -0
- package/dist/utils/storage-factory.js.map +1 -0
- package/dist/utils/storage-maintenance.d.ts +103 -0
- package/dist/utils/storage-maintenance.d.ts.map +1 -0
- package/dist/utils/storage-maintenance.js +236 -0
- package/dist/utils/storage-maintenance.js.map +1 -0
- package/dist/utils/thread-lock.d.ts +26 -0
- package/dist/utils/thread-lock.d.ts.map +1 -0
- package/dist/utils/thread-lock.js +108 -0
- package/dist/utils/thread-lock.js.map +1 -0
- package/dist/utils/token-estimator.d.ts +3 -0
- package/dist/utils/token-estimator.d.ts.map +1 -0
- package/dist/utils/token-estimator.js +21 -0
- package/dist/utils/token-estimator.js.map +1 -0
- package/dist/utils/update-check.d.ts +52 -0
- package/dist/utils/update-check.d.ts.map +1 -0
- package/dist/utils/update-check.js +177 -0
- package/dist/utils/update-check.js.map +1 -0
- package/dist/voice/stt-registry.d.ts +64 -0
- package/dist/voice/stt-registry.d.ts.map +1 -0
- package/dist/voice/stt-registry.js +126 -0
- package/dist/voice/stt-registry.js.map +1 -0
- package/package.json +94 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const fastModePrompt = `
|
|
2
|
+
# Fast Mode
|
|
3
|
+
|
|
4
|
+
You are in FAST mode. Optimize for speed and brevity.
|
|
5
|
+
|
|
6
|
+
## Rules
|
|
7
|
+
- Keep responses short. Under 200 words unless the task genuinely requires more.
|
|
8
|
+
- Skip planning. Just do the task directly.
|
|
9
|
+
- For questions: give the direct answer, not a tutorial.
|
|
10
|
+
- For edits: make the change, show what you did, move on.
|
|
11
|
+
- Don't explore the codebase more than necessary for the immediate task.
|
|
12
|
+
|
|
13
|
+
## When to Use Tools vs. Just Answer
|
|
14
|
+
- If the user asks a general programming question, answer directly from knowledge. Don't search the codebase.
|
|
15
|
+
- If the user asks about THIS project's code, use tools to look it up \u2014 don't guess.
|
|
16
|
+
- If the user asks for a quick edit and you know the file, read it and edit it. Don't ask for confirmation.
|
|
17
|
+
- One tool call to read + one to edit is ideal. Minimize round trips.
|
|
18
|
+
`;
|
|
19
|
+
export {
|
|
20
|
+
fastModePrompt
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=fast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/agents/prompts/fast.ts"],"sourcesContent":["/**\n * Fast mode prompt — quick answers and small edits, minimal overhead.\n */\n\nexport const fastModePrompt = `\n# Fast Mode\n\nYou are in FAST mode. Optimize for speed and brevity.\n\n## Rules\n- Keep responses short. Under 200 words unless the task genuinely requires more.\n- Skip planning. Just do the task directly.\n- For questions: give the direct answer, not a tutorial.\n- For edits: make the change, show what you did, move on.\n- Don't explore the codebase more than necessary for the immediate task.\n\n## When to Use Tools vs. Just Answer\n- If the user asks a general programming question, answer directly from knowledge. Don't search the codebase.\n- If the user asks about THIS project's code, use tools to look it up — don't guess.\n- If the user asks for a quick edit and you know the file, read it and edit it. Don't ask for confirmation.\n- One tool call to read + one to edit is ideal. Minimize round trips.\n`;\n"],"mappings":"AAIO,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt system — exports the prompt builder and mode-specific prompts.
|
|
3
|
+
*/
|
|
4
|
+
export { buildModePrompt, buildModePromptFn } from './build.js';
|
|
5
|
+
export { planModePrompt } from './plan.js';
|
|
6
|
+
export { fastModePrompt } from './fast.js';
|
|
7
|
+
import type { PromptContext as BasePromptContext } from '@mastra/core/coding-agent';
|
|
8
|
+
export interface PromptContext extends Omit<BasePromptContext, 'toolGuidance'> {
|
|
9
|
+
modeId: string;
|
|
10
|
+
state?: any;
|
|
11
|
+
currentDate: string;
|
|
12
|
+
workingDir: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build the full system prompt for a given mode and context.
|
|
16
|
+
* Combines the base prompt with mode-specific instructions.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildFullPrompt(ctx: PromptContext): string;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAUpF,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAmD1D"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { buildModePrompt, buildModePromptFn } from "./build.js";
|
|
2
|
+
import { planModePrompt } from "./plan.js";
|
|
3
|
+
import { fastModePrompt } from "./fast.js";
|
|
4
|
+
import { buildBasePrompt } from "@mastra/core/coding-agent";
|
|
5
|
+
import { hasTavilyKey } from "../../tools/index.js";
|
|
6
|
+
import { loadAgentInstructions, formatAgentInstructions } from "./agent-instructions.js";
|
|
7
|
+
import { buildModePromptFn as buildModePromptFn2 } from "./build.js";
|
|
8
|
+
import { fastModePrompt as fastModePrompt2 } from "./fast.js";
|
|
9
|
+
import { modelSpecificPrompts } from "./model.js";
|
|
10
|
+
import { planModePrompt as planModePrompt2 } from "./plan.js";
|
|
11
|
+
import { buildToolGuidance } from "./tool-guidance.js";
|
|
12
|
+
const modePrompts = {
|
|
13
|
+
build: buildModePromptFn2,
|
|
14
|
+
plan: planModePrompt2,
|
|
15
|
+
fast: fastModePrompt2
|
|
16
|
+
};
|
|
17
|
+
function buildFullPrompt(ctx) {
|
|
18
|
+
const modelId = ctx.modelId;
|
|
19
|
+
const hasWebSearch = hasTavilyKey() || !!modelId && modelId.startsWith("anthropic/");
|
|
20
|
+
const deniedTools = /* @__PURE__ */ new Set();
|
|
21
|
+
const permRules = ctx.state?.permissionRules;
|
|
22
|
+
if (permRules?.tools) {
|
|
23
|
+
for (const [name, policy] of Object.entries(permRules.tools)) {
|
|
24
|
+
if (policy === "deny") deniedTools.add(name);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const toolGuidance = buildToolGuidance(ctx.modeId, { hasWebSearch, deniedTools });
|
|
28
|
+
const baseCtx = {
|
|
29
|
+
projectPath: ctx.workingDir,
|
|
30
|
+
projectName: ctx.projectName || "unknown",
|
|
31
|
+
gitBranch: ctx.gitBranch,
|
|
32
|
+
platform: process.platform,
|
|
33
|
+
commonBinaries: ctx.commonBinaries,
|
|
34
|
+
date: ctx.currentDate,
|
|
35
|
+
mode: ctx.modeId,
|
|
36
|
+
modelId: ctx.modelId,
|
|
37
|
+
activePlan: ctx.state?.activePlan,
|
|
38
|
+
toolGuidance
|
|
39
|
+
};
|
|
40
|
+
const base = buildBasePrompt(baseCtx);
|
|
41
|
+
const entry = modePrompts[ctx.modeId] || modePrompts.build;
|
|
42
|
+
const modeSpecific = (typeof entry === "function" ? entry(ctx) : entry) ?? "";
|
|
43
|
+
const modelSpecific = ctx.modelId ? modelSpecificPrompts[ctx.modelId] ?? "" : "";
|
|
44
|
+
const configDir = ctx.state?.configDir;
|
|
45
|
+
const instructionSources = loadAgentInstructions(ctx.workingDir, configDir);
|
|
46
|
+
const instructionsSection = formatAgentInstructions(instructionSources);
|
|
47
|
+
const sections = [base, instructionsSection.trim(), modelSpecific.trim(), modeSpecific.trim()].filter(Boolean);
|
|
48
|
+
return sections.join("\n\n");
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
buildFullPrompt,
|
|
52
|
+
buildModePrompt,
|
|
53
|
+
buildModePromptFn,
|
|
54
|
+
fastModePrompt,
|
|
55
|
+
planModePrompt
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/agents/prompts/index.ts"],"sourcesContent":["/**\n * Prompt system — exports the prompt builder and mode-specific prompts.\n */\n\nexport { buildModePrompt, buildModePromptFn } from './build.js';\nexport { planModePrompt } from './plan.js';\nexport { fastModePrompt } from './fast.js';\n\nimport { buildBasePrompt } from '@mastra/core/coding-agent';\nimport type { PromptContext as BasePromptContext } from '@mastra/core/coding-agent';\nimport { hasTavilyKey } from '../../tools/index.js';\nimport { loadAgentInstructions, formatAgentInstructions } from './agent-instructions.js';\nimport { buildModePromptFn } from './build.js';\nimport { fastModePrompt } from './fast.js';\nimport { modelSpecificPrompts } from './model.js';\nimport { planModePrompt } from './plan.js';\nimport { buildToolGuidance } from './tool-guidance.js';\n\n// Extended prompt context that includes runtime information\nexport interface PromptContext extends Omit<BasePromptContext, 'toolGuidance'> {\n modeId: string;\n state?: any;\n currentDate: string;\n workingDir: string;\n}\n\nconst modePrompts: Record<string, string | ((ctx: PromptContext) => string)> = {\n build: buildModePromptFn,\n plan: planModePrompt,\n fast: fastModePrompt,\n};\n\n/**\n * Build the full system prompt for a given mode and context.\n * Combines the base prompt with mode-specific instructions.\n */\nexport function buildFullPrompt(ctx: PromptContext): string {\n // Determine whether web search tools are available\n const modelId = ctx.modelId;\n const hasWebSearch = hasTavilyKey() || (!!modelId && modelId.startsWith('anthropic/'));\n\n // Collect per-tool deny rules so guidance omits denied tools\n const deniedTools = new Set<string>();\n const permRules = ctx.state?.permissionRules as { tools?: Record<string, string> } | undefined;\n if (permRules?.tools) {\n for (const [name, policy] of Object.entries(permRules.tools)) {\n if (policy === 'deny') deniedTools.add(name);\n }\n }\n\n // Build mode-aware tool guidance\n const toolGuidance = buildToolGuidance(ctx.modeId, { hasWebSearch, deniedTools });\n\n // Map new context to base context\n const baseCtx: BasePromptContext = {\n projectPath: ctx.workingDir,\n projectName: ctx.projectName || 'unknown',\n gitBranch: ctx.gitBranch,\n platform: process.platform,\n commonBinaries: ctx.commonBinaries,\n date: ctx.currentDate,\n mode: ctx.modeId,\n modelId: ctx.modelId,\n activePlan: ctx.state?.activePlan,\n toolGuidance,\n };\n\n const base = buildBasePrompt(baseCtx);\n const entry = modePrompts[ctx.modeId] || modePrompts.build;\n const modeSpecific = (typeof entry === 'function' ? entry(ctx) : entry) ?? '';\n const modelSpecific = ctx.modelId\n ? (modelSpecificPrompts[ctx.modelId as keyof typeof modelSpecificPrompts] ?? '')\n : '';\n\n // The current task list is carried on the agent state-signal lane (see\n // TaskStateProcessor) rather than injected into the cached system prompt. This\n // keeps the prompt prefix stable across task updates (preserving prompt cache)\n // while still surviving observational-memory truncation.\n\n // Load and inject agent instructions from AGENTS.md/CLAUDE.md files\n const configDir = ctx.state?.configDir as string | undefined;\n const instructionSources = loadAgentInstructions(ctx.workingDir, configDir);\n const instructionsSection = formatAgentInstructions(instructionSources);\n\n const sections = [base, instructionsSection.trim(), modelSpecific.trim(), modeSpecific.trim()].filter(Boolean);\n\n return sections.join('\\n\\n');\n}\n"],"mappings":"AAIA,SAAS,iBAAiB,yBAAyB;AACnD,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAE/B,SAAS,uBAAuB;AAEhC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB,+BAA+B;AAC/D,SAAS,qBAAAA,0BAAyB;AAClC,SAAS,kBAAAC,uBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAS,kBAAAC,uBAAsB;AAC/B,SAAS,yBAAyB;AAUlC,MAAM,cAAyE;AAAA,EAC7E,OAAOF;AAAA,EACP,MAAME;AAAA,EACN,MAAMD;AACR;AAMO,SAAS,gBAAgB,KAA4B;AAE1D,QAAM,UAAU,IAAI;AACpB,QAAM,eAAe,aAAa,KAAM,CAAC,CAAC,WAAW,QAAQ,WAAW,YAAY;AAGpF,QAAM,cAAc,oBAAI,IAAY;AACpC,QAAM,YAAY,IAAI,OAAO;AAC7B,MAAI,WAAW,OAAO;AACpB,eAAW,CAAC,MAAM,MAAM,KAAK,OAAO,QAAQ,UAAU,KAAK,GAAG;AAC5D,UAAI,WAAW,OAAQ,aAAY,IAAI,IAAI;AAAA,IAC7C;AAAA,EACF;AAGA,QAAM,eAAe,kBAAkB,IAAI,QAAQ,EAAE,cAAc,YAAY,CAAC;AAGhF,QAAM,UAA6B;AAAA,IACjC,aAAa,IAAI;AAAA,IACjB,aAAa,IAAI,eAAe;AAAA,IAChC,WAAW,IAAI;AAAA,IACf,UAAU,QAAQ;AAAA,IAClB,gBAAgB,IAAI;AAAA,IACpB,MAAM,IAAI;AAAA,IACV,MAAM,IAAI;AAAA,IACV,SAAS,IAAI;AAAA,IACb,YAAY,IAAI,OAAO;AAAA,IACvB;AAAA,EACF;AAEA,QAAM,OAAO,gBAAgB,OAAO;AACpC,QAAM,QAAQ,YAAY,IAAI,MAAM,KAAK,YAAY;AACrD,QAAM,gBAAgB,OAAO,UAAU,aAAa,MAAM,GAAG,IAAI,UAAU;AAC3E,QAAM,gBAAgB,IAAI,UACrB,qBAAqB,IAAI,OAA4C,KAAK,KAC3E;AAQJ,QAAM,YAAY,IAAI,OAAO;AAC7B,QAAM,qBAAqB,sBAAsB,IAAI,YAAY,SAAS;AAC1E,QAAM,sBAAsB,wBAAwB,kBAAkB;AAEtE,QAAM,WAAW,CAAC,MAAM,oBAAoB,KAAK,GAAG,cAAc,KAAK,GAAG,aAAa,KAAK,CAAC,EAAE,OAAO,OAAO;AAE7G,SAAO,SAAS,KAAK,MAAM;AAC7B;","names":["buildModePromptFn","fastModePrompt","planModePrompt"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/model.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;CAiBhC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const modelSpecificPrompts = {
|
|
2
|
+
"openai/gpt-5.4": `<autonomy_and_persistence>
|
|
3
|
+
Persist until the task is fully handled end-to-end within the current turn whenever feasible: do not stop at analysis or partial fixes; carry changes through implementation, verification, and a clear explanation of outcomes unless the user explicitly pauses or redirects you.
|
|
4
|
+
|
|
5
|
+
Unless the user explicitly asks for a plan, asks a question about the code, is brainstorming potential solutions, or some other intent that makes it clear that code should not be written, assume the user wants you to make code changes or run tools to solve the user's problem. In these cases, it's bad to output your proposed solution in a message, you should go ahead and actually implement the change. If you encounter challenges or blockers, you should attempt to resolve them yourself.
|
|
6
|
+
</autonomy_and_persistence>
|
|
7
|
+
`,
|
|
8
|
+
"openai/gpt-5.5": `<coding_behavior>
|
|
9
|
+
Work outcome-first: infer the user's goal, define what "done" means from the request and repo context, then choose an efficient path that reaches that outcome without sacrificing correctness, maintainability, or proof.
|
|
10
|
+
|
|
11
|
+
For non-trivial multi-step or tool-heavy tasks, start with a short visible preamble that acknowledges the request and states the first action. Skip the preamble for direct answers and tiny edits. Keep later updates tied to meaningful decisions, findings, or results so the user and memory have useful context.
|
|
12
|
+
|
|
13
|
+
Use efficient retrieval. Read enough code, docs, logs, and command output to act correctly, including neighboring implementations when conventions matter. Stop searching once you have sufficient evidence, but do not let brevity outrank correctness, security, or compatibility with existing patterns.
|
|
14
|
+
|
|
15
|
+
For coding work, make focused changes that follow the surrounding conventions. Avoid unrequested features, broad refactors, speculative error handling, and comments that only explain the diff.
|
|
16
|
+
</coding_behavior>
|
|
17
|
+
`
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
modelSpecificPrompts
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/agents/prompts/model.ts"],"sourcesContent":["export const modelSpecificPrompts = {\n 'openai/gpt-5.4': `<autonomy_and_persistence>\nPersist until the task is fully handled end-to-end within the current turn whenever feasible: do not stop at analysis or partial fixes; carry changes through implementation, verification, and a clear explanation of outcomes unless the user explicitly pauses or redirects you.\n\nUnless the user explicitly asks for a plan, asks a question about the code, is brainstorming potential solutions, or some other intent that makes it clear that code should not be written, assume the user wants you to make code changes or run tools to solve the user's problem. In these cases, it's bad to output your proposed solution in a message, you should go ahead and actually implement the change. If you encounter challenges or blockers, you should attempt to resolve them yourself.\n</autonomy_and_persistence>\n`,\n 'openai/gpt-5.5': `<coding_behavior>\nWork outcome-first: infer the user's goal, define what \"done\" means from the request and repo context, then choose an efficient path that reaches that outcome without sacrificing correctness, maintainability, or proof.\n\nFor non-trivial multi-step or tool-heavy tasks, start with a short visible preamble that acknowledges the request and states the first action. Skip the preamble for direct answers and tiny edits. Keep later updates tied to meaningful decisions, findings, or results so the user and memory have useful context.\n\nUse efficient retrieval. Read enough code, docs, logs, and command output to act correctly, including neighboring implementations when conventions matter. Stop searching once you have sufficient evidence, but do not let brevity outrank correctness, security, or compatibility with existing patterns.\n\nFor coding work, make focused changes that follow the surrounding conventions. Avoid unrequested features, broad refactors, speculative error handling, and comments that only explain the diff.\n</coding_behavior>\n`,\n};\n"],"mappings":"AAAO,MAAM,uBAAuB;AAAA,EAClC,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUpB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/plan.ts"],"names":[],"mappings":"AAKA,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAsG9D"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { getLocalPlansRelativeDir } from "../../utils/plans.js";
|
|
2
|
+
function planModePrompt(_ctx) {
|
|
3
|
+
const plansDir = getLocalPlansRelativeDir();
|
|
4
|
+
const examplePath = `${plansDir}/add-dark-mode.md`;
|
|
5
|
+
return `
|
|
6
|
+
# Plan Mode \u2014 READ-ONLY (except plan files)
|
|
7
|
+
|
|
8
|
+
You are in PLAN mode. Your job is to explore the codebase and design an implementation plan \u2014 NOT to make changes to the project.
|
|
9
|
+
|
|
10
|
+
## CRITICAL: Read-Only Mode (project files)
|
|
11
|
+
|
|
12
|
+
This mode is **read-only for project files**. You must NOT modify the project.
|
|
13
|
+
|
|
14
|
+
- Do NOT modify, create, or delete project files
|
|
15
|
+
- Do NOT run commands that change state (no git commit, no npm install, no file creation)
|
|
16
|
+
- Do NOT run build commands, tests, or scripts that have side effects
|
|
17
|
+
|
|
18
|
+
The ONE exception is plan files: you CAN create and edit markdown files inside \`${plansDir}/\` (e.g. \`${examplePath}\`). You may NOT write anywhere else.
|
|
19
|
+
|
|
20
|
+
If the user asks you to make changes while in Plan mode, explain that you're in read-only mode and they should switch to Build mode (\`/mode build\`) first.
|
|
21
|
+
|
|
22
|
+
## Exploration Strategy
|
|
23
|
+
|
|
24
|
+
Before writing any plan, build a mental model of the codebase:
|
|
25
|
+
1. Start with the directory structure (\`view\` on the project root or relevant subdirectory).
|
|
26
|
+
2. Find the relevant entry points and core files using \`search_content\` and \`find_files\`.
|
|
27
|
+
3. Read the actual code \u2014 don't assume based on file names alone.
|
|
28
|
+
4. Trace data flow: where does input come from, how is it transformed, where does it go?
|
|
29
|
+
5. Identify existing patterns the codebase uses (naming, structure, error handling, testing).
|
|
30
|
+
|
|
31
|
+
## Goal-Ready Plans
|
|
32
|
+
|
|
33
|
+
The submit_plan approval UI can let the user approve the plan normally or start it as a persistent goal. Write plans so they can be carried out as a goal if the user chooses that option:
|
|
34
|
+
- Make the desired outcome explicit and verifiable.
|
|
35
|
+
- Break work into ordered, actionable steps that can be executed autonomously.
|
|
36
|
+
- Include constraints, risks, blockers, and decision points that may require user input.
|
|
37
|
+
- Include concrete verification criteria so the goal judge can tell when the work is done.
|
|
38
|
+
|
|
39
|
+
## Your Plan Output
|
|
40
|
+
|
|
41
|
+
Produce a clear, step-by-step plan with this structure:
|
|
42
|
+
|
|
43
|
+
### Overview
|
|
44
|
+
One paragraph: what the change does and why.
|
|
45
|
+
|
|
46
|
+
### Complexity Estimate
|
|
47
|
+
- **Size**: Small (1-2 files) / Medium (3-5 files) / Large (6+ files)
|
|
48
|
+
- **Risk**: Low (additive, no breaking changes) / Medium (modifies existing behavior) / High (architectural, affects many consumers)
|
|
49
|
+
- **Dependencies**: List any new packages, external services, or migration steps needed.
|
|
50
|
+
|
|
51
|
+
### Steps
|
|
52
|
+
For each step:
|
|
53
|
+
1. **File**: path to create or modify
|
|
54
|
+
2. **Change**: what to add/modify/remove, with enough specificity to implement directly
|
|
55
|
+
3. **Why**: brief rationale connecting this step to the overall goal
|
|
56
|
+
|
|
57
|
+
### Verification
|
|
58
|
+
- What tests to run
|
|
59
|
+
- What to check manually
|
|
60
|
+
- What could go wrong
|
|
61
|
+
|
|
62
|
+
## Plan File Workflow
|
|
63
|
+
|
|
64
|
+
Write each plan to its own markdown file under \`${plansDir}/\` (e.g. \`${examplePath}\`). Start the file with a \`# Title\` heading describing the plan.
|
|
65
|
+
|
|
66
|
+
1. **First submission**: Write your plan to a file under \`${plansDir}/\` using \`write_file\`, then call \`submit_plan\` with the \`path\` to that file.
|
|
67
|
+
2. **Reading**: Use \`view\` to read a plan file.
|
|
68
|
+
3. **Editing**: Use \`string_replace_lsp\` for targeted edits to specific sections.
|
|
69
|
+
|
|
70
|
+
**Reuse the same file while you keep iterating on the same plan.** Only create a NEW file when you're starting a genuinely different plan \u2014 that keeps each plan available to look back at and keeps revision diffs meaningful.
|
|
71
|
+
|
|
72
|
+
## IMMEDIATE ACTION: Write plan file, then call submit_plan
|
|
73
|
+
|
|
74
|
+
As soon as your plan is complete:
|
|
75
|
+
1. Write it to a file under \`${plansDir}/\` using \`write_file\`
|
|
76
|
+
2. Call \`submit_plan\` with the \`path\` to that file
|
|
77
|
+
|
|
78
|
+
**CRITICAL:** Do NOT generate a long text response describing your plan. The plan content belongs in the plan file, not in your text output or the \`submit_plan\` arguments.
|
|
79
|
+
|
|
80
|
+
\`\`\`javascript
|
|
81
|
+
submit_plan({
|
|
82
|
+
path: "${examplePath}"
|
|
83
|
+
})
|
|
84
|
+
\`\`\`
|
|
85
|
+
|
|
86
|
+
The user will see the plan rendered inline and can:
|
|
87
|
+
- **Approve** \u2014 automatically switches to Build mode for implementation
|
|
88
|
+
- **Start as goal** \u2014 approves the plan and enters goal mode so the agent keeps working toward the plan until judged complete, paused, or waiting for user input
|
|
89
|
+
- **Request changes** \u2014 rejects the plan; the agent stops immediately and the user provides revision feedback in their next chat message
|
|
90
|
+
|
|
91
|
+
## Revision Workflow
|
|
92
|
+
|
|
93
|
+
If the user requests changes, you will be stopped immediately. Wait for their next message \u2014 it will contain their revision feedback. When you receive it:
|
|
94
|
+
1. Use \`view\` to read the SAME plan file
|
|
95
|
+
2. Use \`string_replace_lsp\` to make targeted edits based on feedback
|
|
96
|
+
3. Use \`view\` to re-read the updated file
|
|
97
|
+
4. Call \`submit_plan\` again with the same \`path\` \u2014 editing the file alone does NOT resubmit it
|
|
98
|
+
|
|
99
|
+
The user will see a diff of what changed between the previous and revised plan. Use \`string_replace_lsp\` for targeted edits so the diff is clear and meaningful \u2014 do NOT rewrite the entire plan from scratch for small changes, and do NOT move the plan to a new file for a revision.
|
|
100
|
+
|
|
101
|
+
Do NOT start implementing until the plan is approved.
|
|
102
|
+
`;
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
planModePrompt
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/agents/prompts/plan.ts"],"sourcesContent":["/**\n * Plan mode prompt — read-only exploration and planning.\n */\nimport { getLocalPlansRelativeDir } from '../../utils/plans.js';\n\ninterface PlanPromptContext {\n state?: Record<string, unknown>;\n}\n\nexport function planModePrompt(_ctx: PlanPromptContext): string {\n const plansDir = getLocalPlansRelativeDir();\n const examplePath = `${plansDir}/add-dark-mode.md`;\n\n return `\n# Plan Mode — READ-ONLY (except plan files)\n\nYou are in PLAN mode. Your job is to explore the codebase and design an implementation plan — NOT to make changes to the project.\n\n## CRITICAL: Read-Only Mode (project files)\n\nThis mode is **read-only for project files**. You must NOT modify the project.\n\n- Do NOT modify, create, or delete project files\n- Do NOT run commands that change state (no git commit, no npm install, no file creation)\n- Do NOT run build commands, tests, or scripts that have side effects\n\nThe ONE exception is plan files: you CAN create and edit markdown files inside \\`${plansDir}/\\` (e.g. \\`${examplePath}\\`). You may NOT write anywhere else.\n\nIf the user asks you to make changes while in Plan mode, explain that you're in read-only mode and they should switch to Build mode (\\`/mode build\\`) first.\n\n## Exploration Strategy\n\nBefore writing any plan, build a mental model of the codebase:\n1. Start with the directory structure (\\`view\\` on the project root or relevant subdirectory).\n2. Find the relevant entry points and core files using \\`search_content\\` and \\`find_files\\`.\n3. Read the actual code — don't assume based on file names alone.\n4. Trace data flow: where does input come from, how is it transformed, where does it go?\n5. Identify existing patterns the codebase uses (naming, structure, error handling, testing).\n\n## Goal-Ready Plans\n\nThe submit_plan approval UI can let the user approve the plan normally or start it as a persistent goal. Write plans so they can be carried out as a goal if the user chooses that option:\n- Make the desired outcome explicit and verifiable.\n- Break work into ordered, actionable steps that can be executed autonomously.\n- Include constraints, risks, blockers, and decision points that may require user input.\n- Include concrete verification criteria so the goal judge can tell when the work is done.\n\n## Your Plan Output\n\nProduce a clear, step-by-step plan with this structure:\n\n### Overview\nOne paragraph: what the change does and why.\n\n### Complexity Estimate\n- **Size**: Small (1-2 files) / Medium (3-5 files) / Large (6+ files)\n- **Risk**: Low (additive, no breaking changes) / Medium (modifies existing behavior) / High (architectural, affects many consumers)\n- **Dependencies**: List any new packages, external services, or migration steps needed.\n\n### Steps\nFor each step:\n1. **File**: path to create or modify\n2. **Change**: what to add/modify/remove, with enough specificity to implement directly\n3. **Why**: brief rationale connecting this step to the overall goal\n\n### Verification\n- What tests to run\n- What to check manually\n- What could go wrong\n\n## Plan File Workflow\n\nWrite each plan to its own markdown file under \\`${plansDir}/\\` (e.g. \\`${examplePath}\\`). Start the file with a \\`# Title\\` heading describing the plan.\n\n1. **First submission**: Write your plan to a file under \\`${plansDir}/\\` using \\`write_file\\`, then call \\`submit_plan\\` with the \\`path\\` to that file.\n2. **Reading**: Use \\`view\\` to read a plan file.\n3. **Editing**: Use \\`string_replace_lsp\\` for targeted edits to specific sections.\n\n**Reuse the same file while you keep iterating on the same plan.** Only create a NEW file when you're starting a genuinely different plan — that keeps each plan available to look back at and keeps revision diffs meaningful.\n\n## IMMEDIATE ACTION: Write plan file, then call submit_plan\n\nAs soon as your plan is complete:\n1. Write it to a file under \\`${plansDir}/\\` using \\`write_file\\`\n2. Call \\`submit_plan\\` with the \\`path\\` to that file\n\n**CRITICAL:** Do NOT generate a long text response describing your plan. The plan content belongs in the plan file, not in your text output or the \\`submit_plan\\` arguments.\n\n\\`\\`\\`javascript\nsubmit_plan({\n path: \"${examplePath}\"\n})\n\\`\\`\\`\n\nThe user will see the plan rendered inline and can:\n- **Approve** — automatically switches to Build mode for implementation\n- **Start as goal** — approves the plan and enters goal mode so the agent keeps working toward the plan until judged complete, paused, or waiting for user input\n- **Request changes** — rejects the plan; the agent stops immediately and the user provides revision feedback in their next chat message\n\n## Revision Workflow\n\nIf the user requests changes, you will be stopped immediately. Wait for their next message — it will contain their revision feedback. When you receive it:\n1. Use \\`view\\` to read the SAME plan file\n2. Use \\`string_replace_lsp\\` to make targeted edits based on feedback\n3. Use \\`view\\` to re-read the updated file\n4. Call \\`submit_plan\\` again with the same \\`path\\` — editing the file alone does NOT resubmit it\n\nThe user will see a diff of what changed between the previous and revised plan. Use \\`string_replace_lsp\\` for targeted edits so the diff is clear and meaningful — do NOT rewrite the entire plan from scratch for small changes, and do NOT move the plan to a new file for a revision.\n\nDo NOT start implementing until the plan is approved.\n`;\n}\n"],"mappings":"AAGA,SAAS,gCAAgC;AAMlC,SAAS,eAAe,MAAiC;AAC9D,QAAM,WAAW,yBAAyB;AAC1C,QAAM,cAAc,GAAG,QAAQ;AAE/B,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mFAa0E,QAAQ,eAAe,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mDA8ClE,QAAQ,eAAe,WAAW;AAAA;AAAA,6DAExB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCASrC,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAO7B,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBtB;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mode-specific tool behavioral guidance.
|
|
3
|
+
* Generates tool usage instructions that match the actual registered tool names
|
|
4
|
+
* and are scoped to what's available in the current mode.
|
|
5
|
+
*/
|
|
6
|
+
interface ToolGuidanceOptions {
|
|
7
|
+
hasWebSearch?: boolean;
|
|
8
|
+
/** Tool names that have been denied — omit their guidance sections. */
|
|
9
|
+
deniedTools?: Set<string>;
|
|
10
|
+
}
|
|
11
|
+
export declare function buildToolGuidance(modeId: string, options?: ToolGuidanceOptions): string;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=tool-guidance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-guidance.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/tool-guidance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,UAAU,mBAAmB;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,uEAAuE;IACvE,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,MAAM,CA+N3F"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { MC_TOOLS } from "../../tool-names.js";
|
|
2
|
+
function buildToolGuidance(modeId, options = {}) {
|
|
3
|
+
const denied = options.deniedTools ?? /* @__PURE__ */ new Set();
|
|
4
|
+
const sections = [];
|
|
5
|
+
sections.push(`# Tool Usage Rules
|
|
6
|
+
|
|
7
|
+
IMPORTANT: You can ONLY call tools by their exact registered names listed below. Shell commands like \`git\`, \`npm\`, \`ls\`, etc. are NOT tools \u2014 they must be run via the \`execute_command\` tool.
|
|
8
|
+
|
|
9
|
+
You have access to the following tools. Use the RIGHT tool for the job:`);
|
|
10
|
+
const readTools = [];
|
|
11
|
+
if (!denied.has(MC_TOOLS.VIEW)) {
|
|
12
|
+
readTools.push(`
|
|
13
|
+
**${MC_TOOLS.VIEW}** \u2014 Read file contents
|
|
14
|
+
- Use this to read files before editing them. NEVER propose changes to code you haven't read.
|
|
15
|
+
- Use \`offset\` (1-indexed start line) and \`limit\` (number of lines) for large files.
|
|
16
|
+
- Example: Read lines 50-100: \`{ path: "src/big-file.ts", offset: 50, limit: 51 }\`
|
|
17
|
+
- To list directories, use \`${MC_TOOLS.FIND_FILES}\` instead.`);
|
|
18
|
+
}
|
|
19
|
+
if (!denied.has(MC_TOOLS.SEARCH_CONTENT)) {
|
|
20
|
+
readTools.push(`
|
|
21
|
+
**${MC_TOOLS.SEARCH_CONTENT}** \u2014 Search file contents using regex
|
|
22
|
+
- Preferred for content search (finding functions, variables, error messages, imports, etc.)
|
|
23
|
+
- Use \`path\` to filter by directory or glob pattern. Supports \`contextLines\`, \`caseSensitive\`, and \`maxCount\`.
|
|
24
|
+
- Example: Find a function: \`{ pattern: "function handleSubmit", path: "**/*.ts" }\`
|
|
25
|
+
- Example: Find imports: \`{ pattern: "from ['\\"\\]express['\\"\\]", path: "**/*.ts" }\`
|
|
26
|
+
- Respects .gitignore by default.`);
|
|
27
|
+
}
|
|
28
|
+
if (!denied.has(MC_TOOLS.FIND_FILES)) {
|
|
29
|
+
readTools.push(`
|
|
30
|
+
**${MC_TOOLS.FIND_FILES}** \u2014 List files and directories as a tree
|
|
31
|
+
- Preferred for exploring project structure and finding files by pattern.
|
|
32
|
+
- Returns tree-style output. Respects .gitignore by default.
|
|
33
|
+
- Example: List project root: \`{ path: "./" }\`
|
|
34
|
+
- Example: Find test files: \`{ path: "./src", pattern: "**/*.test.ts" }\`
|
|
35
|
+
- Example: Find config files: \`{ pattern: "*.config.{js,ts,json}" }\``);
|
|
36
|
+
}
|
|
37
|
+
if (!denied.has(MC_TOOLS.EXECUTE_COMMAND)) {
|
|
38
|
+
readTools.push(`
|
|
39
|
+
**${MC_TOOLS.EXECUTE_COMMAND}** \u2014 Run shell commands
|
|
40
|
+
- Use for: git, npm/pnpm, docker, build tools, test runners, and other terminal operations.
|
|
41
|
+
- Prefer dedicated tools for: file reading (${MC_TOOLS.VIEW}), file search (${MC_TOOLS.SEARCH_CONTENT}/${MC_TOOLS.FIND_FILES}), file editing (${MC_TOOLS.STRING_REPLACE_LSP}/${MC_TOOLS.WRITE_FILE}).
|
|
42
|
+
- Commands have a 30-second default timeout. Use \`timeout\` for longer commands, \`cwd\` for working directory.
|
|
43
|
+
- Use the \`tail\` parameter or pipe to \`| tail -N\` to limit output \u2014 the full output streams to the user, only the tail is returned to you. If you're building any kind of package you should be tailing.
|
|
44
|
+
- Good: Run independent commands in parallel when possible.
|
|
45
|
+
- Bad: Running \`cat file.txt\` \u2014 use the ${MC_TOOLS.VIEW} tool instead.`);
|
|
46
|
+
}
|
|
47
|
+
if (!denied.has(MC_TOOLS.LSP_INSPECT)) {
|
|
48
|
+
readTools.push(`
|
|
49
|
+
**${MC_TOOLS.LSP_INSPECT}** \u2014 Inspect code using Language Server Protocol
|
|
50
|
+
- Use this for type information, hover docs, go-to-definition, and finding implementations for a symbol.
|
|
51
|
+
- Best when you already know the file and line and need semantic code intelligence rather than raw file contents.
|
|
52
|
+
- Input: \`path\` (absolute file path), \`line\` (1-indexed line number), \`match\` (the exact line content with exactly one \`<<<\` cursor marker).
|
|
53
|
+
- Output includes: \`hover\`, \`definition\` (compact location with preview), and \`implementation\` (compact usage/implementation locations).
|
|
54
|
+
- Example: \`{ path: "/abs/path/src/foo.ts", line: 10, match: "const foo = <<<bar()" }\` \u2014 inspect the symbol at the \`<<<\` position.
|
|
55
|
+
- Use \`${MC_TOOLS.VIEW}\` when you need to read the implementation or surrounding code.
|
|
56
|
+
- Use \`${MC_TOOLS.SEARCH_CONTENT}\` or \`${MC_TOOLS.FIND_FILES}\` first if you do not yet know where the symbol is.`);
|
|
57
|
+
}
|
|
58
|
+
if (!denied.has(MC_TOOLS.NOTIFICATION_INBOX)) {
|
|
59
|
+
readTools.push(`
|
|
60
|
+
**${MC_TOOLS.NOTIFICATION_INBOX}** \u2014 Inspect and manage notification inbox records
|
|
61
|
+
- Use this when a \`<notification-summary>\` says pending notifications exist.
|
|
62
|
+
- Use \`{ "action": "list", "status": "pending" }\` or \`{ "action": "search", "query": "..." }\` to find notification records for the current thread.
|
|
63
|
+
- Use \`read\` to deliver unread notification signals into the chat and mark them seen; the tool result summarizes the count instead of exposing notification contents.
|
|
64
|
+
- Use \`dismiss\` or \`archive\` only when the user asks or the notification is no longer relevant.`);
|
|
65
|
+
}
|
|
66
|
+
if (readTools.length > 0) {
|
|
67
|
+
sections.push(readTools.join("\n"));
|
|
68
|
+
}
|
|
69
|
+
if (modeId !== "plan") {
|
|
70
|
+
const writeTools = [];
|
|
71
|
+
if (!denied.has(MC_TOOLS.STRING_REPLACE_LSP)) {
|
|
72
|
+
writeTools.push(`
|
|
73
|
+
**${MC_TOOLS.STRING_REPLACE_LSP}** \u2014 Edit files by replacing exact text
|
|
74
|
+
- You MUST read a file with \`${MC_TOOLS.VIEW}\` before editing it.
|
|
75
|
+
- \`old_string\` must be an exact match of existing text in the file.
|
|
76
|
+
- Provide enough surrounding context in \`old_string\` to make it unique.
|
|
77
|
+
- Use \`replace_all: true\` to replace all occurrences (default: false, requires unique match).
|
|
78
|
+
- For creating new files, use \`${MC_TOOLS.WRITE_FILE}\` instead.
|
|
79
|
+
- Good: Include 2-3 lines of surrounding context to ensure uniqueness.
|
|
80
|
+
- Bad: Using just \`return true;\` \u2014 too common, will match multiple places.`);
|
|
81
|
+
}
|
|
82
|
+
if (!denied.has(MC_TOOLS.WRITE_FILE)) {
|
|
83
|
+
writeTools.push(`
|
|
84
|
+
**${MC_TOOLS.WRITE_FILE}** \u2014 Create new files or overwrite existing ones
|
|
85
|
+
- Use this to create new files.
|
|
86
|
+
- If overwriting an existing file, you MUST have read it first with \`${MC_TOOLS.VIEW}\`.
|
|
87
|
+
- Prefer editing existing files over creating new ones.`);
|
|
88
|
+
}
|
|
89
|
+
if (writeTools.length > 0) {
|
|
90
|
+
sections.push(writeTools.join("\n"));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (options.hasWebSearch) {
|
|
94
|
+
const webTools = [];
|
|
95
|
+
if (!denied.has("web_search")) webTools.push("**web_search**");
|
|
96
|
+
if (!denied.has("web_extract")) webTools.push("**web_extract**");
|
|
97
|
+
if (webTools.length > 0) {
|
|
98
|
+
sections.push(`
|
|
99
|
+
${webTools.join(" / ")} \u2014 Search the web / extract page content
|
|
100
|
+
- Use for looking up documentation, error messages, package APIs.`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const taskTools = [];
|
|
104
|
+
const canUpdateTask = !denied.has("task_update");
|
|
105
|
+
const canCompleteTask = !denied.has("task_complete");
|
|
106
|
+
const canCheckTasks = !denied.has("task_check");
|
|
107
|
+
const canWriteTasks = !denied.has("task_write");
|
|
108
|
+
const patchToolGuidance = canUpdateTask && canCompleteTask ? "- Prefer task_update or task_complete when changing one existing task." : canUpdateTask ? "- Prefer task_update when changing one existing task." : canCompleteTask ? "- Prefer task_complete when marking one existing task completed." : "- Use task_write with the full task list when changing existing tasks.";
|
|
109
|
+
if (canWriteTasks) {
|
|
110
|
+
taskTools.push(`
|
|
111
|
+
**task_write** \u2014 Track tasks for complex multi-step work
|
|
112
|
+
- Use when a task requires 3 or more distinct steps or actions.
|
|
113
|
+
- Use task_write to create the initial task list or replace the whole list after replanning.
|
|
114
|
+
- Each task has: id (stable identifier), content (imperative form), status (pending, in_progress, or completed), activeForm (present continuous form shown during execution).
|
|
115
|
+
- Keep task IDs stable across updates. If you omit IDs, the tool result returns generated IDs.
|
|
116
|
+
${patchToolGuidance}
|
|
117
|
+
- Mark tasks \`in_progress\` BEFORE starting work. Only ONE task should be \`in_progress\` at a time.
|
|
118
|
+
- Mark tasks \`completed\` IMMEDIATELY after finishing each task. Do not batch completions.`);
|
|
119
|
+
}
|
|
120
|
+
if (canUpdateTask) {
|
|
121
|
+
taskTools.push(`
|
|
122
|
+
**task_update** \u2014 Patch one tracked task by ID
|
|
123
|
+
- Use this for targeted changes to one existing task.
|
|
124
|
+
- Provide the task ID and only the fields that changed: content, status, or activeForm.`);
|
|
125
|
+
}
|
|
126
|
+
if (canCompleteTask) {
|
|
127
|
+
const idSource = canCheckTasks ? "Use task_check if you need the current IDs before completing a task." : canWriteTasks ? "Use IDs returned by task_write." : "Use only task IDs already visible in the current task list.";
|
|
128
|
+
taskTools.push(`
|
|
129
|
+
**task_complete** \u2014 Mark one tracked task completed by ID
|
|
130
|
+
- Use this immediately after finishing a tracked task.
|
|
131
|
+
- ${idSource}`);
|
|
132
|
+
}
|
|
133
|
+
if (canCheckTasks) {
|
|
134
|
+
taskTools.push(`
|
|
135
|
+
**task_check** \u2014 Check completion status of tasks
|
|
136
|
+
- Use this BEFORE finishing tracked work to verify all tasks are completed.
|
|
137
|
+
- Returns a readable status summary plus structured fields: tasks, summary, incompleteTasks, and isError.
|
|
138
|
+
- summary includes total, completed, inProgress, pending, incomplete, hasTasks, and allCompleted.
|
|
139
|
+
- Use summary.allCompleted to decide whether tracked work is complete; if summary.hasTasks is false, no task list is currently tracked.
|
|
140
|
+
- If any tasks remain incomplete, continue working on them.
|
|
141
|
+
- IMPORTANT: Always check task completion before ending work on a complex task.`);
|
|
142
|
+
}
|
|
143
|
+
if (!denied.has("ask_user")) {
|
|
144
|
+
taskTools.push(`
|
|
145
|
+
**ask_user** \u2014 Ask the user a structured question
|
|
146
|
+
- Use when you need clarification, want to validate assumptions, or need the user to make a decision.
|
|
147
|
+
- Provide clear, specific questions. End with a question mark.
|
|
148
|
+
- Include options (2-4 choices) for structured decisions. Omit options for open-ended questions.
|
|
149
|
+
- Don't use this for simple yes/no \u2014 just ask in your text response.`);
|
|
150
|
+
}
|
|
151
|
+
if (taskTools.length > 0) {
|
|
152
|
+
sections.push(taskTools.join("\n"));
|
|
153
|
+
}
|
|
154
|
+
if (modeId === "plan" && !denied.has("submit_plan")) {
|
|
155
|
+
sections.push(`
|
|
156
|
+
**submit_plan** \u2014 Submit a completed implementation plan for user review
|
|
157
|
+
- Call this tool when your plan is complete. Do NOT just describe your plan in text \u2014 you MUST call this tool.
|
|
158
|
+
- The plan will be rendered as markdown and the user can approve, reject, or request changes.
|
|
159
|
+
- On approval, the system automatically switches to the default mode so you can implement.
|
|
160
|
+
- Takes one argument: \`path\` (the plan markdown file you wrote under \`.mastracode/plans/\`). Do NOT pass the plan body \u2014 it lives in the file.`);
|
|
161
|
+
}
|
|
162
|
+
if (modeId === "plan") {
|
|
163
|
+
sections.push(`
|
|
164
|
+
**Plan file access** \u2014 Your plan lives in a markdown file under \`.mastracode/plans/\` (e.g. \`add-dark-mode-toggle.md\`)
|
|
165
|
+
- Use \`write_file\` to create the plan file, \`view\` to read it, and \`string_replace_lsp\` for targeted edits.
|
|
166
|
+
- On first submission: write the plan to the file, then call \`submit_plan\` with its \`path\`.
|
|
167
|
+
- On revision: read the existing file, edit specific sections, re-read, then call \`submit_plan\` with the same \`path\`.
|
|
168
|
+
- If a plan file already exists, you previously submitted it \u2014 read it before revising.`);
|
|
169
|
+
}
|
|
170
|
+
if (!denied.has("subagent")) {
|
|
171
|
+
sections.push(`
|
|
172
|
+
**subagent** \u2014 Delegate a focused task to a specialized subagent
|
|
173
|
+
- Only use subagents when you will spawn **multiple subagents in parallel**. If you only need one task done, do it yourself.
|
|
174
|
+
- Subagent outputs are **untrusted**. Always review and verify the results.`);
|
|
175
|
+
}
|
|
176
|
+
return sections.join("\n");
|
|
177
|
+
}
|
|
178
|
+
export {
|
|
179
|
+
buildToolGuidance
|
|
180
|
+
};
|
|
181
|
+
//# sourceMappingURL=tool-guidance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/agents/prompts/tool-guidance.ts"],"sourcesContent":["/**\n * Mode-specific tool behavioral guidance.\n * Generates tool usage instructions that match the actual registered tool names\n * and are scoped to what's available in the current mode.\n */\n\nimport { MC_TOOLS } from '../../tool-names.js';\n\ninterface ToolGuidanceOptions {\n hasWebSearch?: boolean;\n /** Tool names that have been denied — omit their guidance sections. */\n deniedTools?: Set<string>;\n}\n\nexport function buildToolGuidance(modeId: string, options: ToolGuidanceOptions = {}): string {\n const denied = options.deniedTools ?? new Set<string>();\n const sections: string[] = [];\n\n sections.push(`# Tool Usage Rules\n\nIMPORTANT: You can ONLY call tools by their exact registered names listed below. Shell commands like \\`git\\`, \\`npm\\`, \\`ls\\`, etc. are NOT tools — they must be run via the \\`execute_command\\` tool.\n\nYou have access to the following tools. Use the RIGHT tool for the job:`);\n\n // --- Read tools (all modes) ---\n\n const readTools: string[] = [];\n\n if (!denied.has(MC_TOOLS.VIEW)) {\n readTools.push(`\n**${MC_TOOLS.VIEW}** — Read file contents\n- Use this to read files before editing them. NEVER propose changes to code you haven't read.\n- Use \\`offset\\` (1-indexed start line) and \\`limit\\` (number of lines) for large files.\n- Example: Read lines 50-100: \\`{ path: \"src/big-file.ts\", offset: 50, limit: 51 }\\`\n- To list directories, use \\`${MC_TOOLS.FIND_FILES}\\` instead.`);\n }\n\n if (!denied.has(MC_TOOLS.SEARCH_CONTENT)) {\n readTools.push(`\n**${MC_TOOLS.SEARCH_CONTENT}** — Search file contents using regex\n- Preferred for content search (finding functions, variables, error messages, imports, etc.)\n- Use \\`path\\` to filter by directory or glob pattern. Supports \\`contextLines\\`, \\`caseSensitive\\`, and \\`maxCount\\`.\n- Example: Find a function: \\`{ pattern: \"function handleSubmit\", path: \"**/*.ts\" }\\`\n- Example: Find imports: \\`{ pattern: \"from ['\\\\\"\\\\]express['\\\\\"\\\\]\", path: \"**/*.ts\" }\\`\n- Respects .gitignore by default.`);\n }\n\n if (!denied.has(MC_TOOLS.FIND_FILES)) {\n readTools.push(`\n**${MC_TOOLS.FIND_FILES}** — List files and directories as a tree\n- Preferred for exploring project structure and finding files by pattern.\n- Returns tree-style output. Respects .gitignore by default.\n- Example: List project root: \\`{ path: \"./\" }\\`\n- Example: Find test files: \\`{ path: \"./src\", pattern: \"**/*.test.ts\" }\\`\n- Example: Find config files: \\`{ pattern: \"*.config.{js,ts,json}\" }\\``);\n }\n\n if (!denied.has(MC_TOOLS.EXECUTE_COMMAND)) {\n readTools.push(`\n**${MC_TOOLS.EXECUTE_COMMAND}** — Run shell commands\n- Use for: git, npm/pnpm, docker, build tools, test runners, and other terminal operations.\n- Prefer dedicated tools for: file reading (${MC_TOOLS.VIEW}), file search (${MC_TOOLS.SEARCH_CONTENT}/${MC_TOOLS.FIND_FILES}), file editing (${MC_TOOLS.STRING_REPLACE_LSP}/${MC_TOOLS.WRITE_FILE}).\n- Commands have a 30-second default timeout. Use \\`timeout\\` for longer commands, \\`cwd\\` for working directory.\n- Use the \\`tail\\` parameter or pipe to \\`| tail -N\\` to limit output — the full output streams to the user, only the tail is returned to you. If you're building any kind of package you should be tailing.\n- Good: Run independent commands in parallel when possible.\n- Bad: Running \\`cat file.txt\\` — use the ${MC_TOOLS.VIEW} tool instead.`);\n }\n\n if (!denied.has(MC_TOOLS.LSP_INSPECT)) {\n readTools.push(`\n**${MC_TOOLS.LSP_INSPECT}** — Inspect code using Language Server Protocol\n- Use this for type information, hover docs, go-to-definition, and finding implementations for a symbol.\n- Best when you already know the file and line and need semantic code intelligence rather than raw file contents.\n- Input: \\`path\\` (absolute file path), \\`line\\` (1-indexed line number), \\`match\\` (the exact line content with exactly one \\`<<<\\` cursor marker).\n- Output includes: \\`hover\\`, \\`definition\\` (compact location with preview), and \\`implementation\\` (compact usage/implementation locations).\n- Example: \\`{ path: \"/abs/path/src/foo.ts\", line: 10, match: \"const foo = <<<bar()\" }\\` — inspect the symbol at the \\`<<<\\` position.\n- Use \\`${MC_TOOLS.VIEW}\\` when you need to read the implementation or surrounding code.\n- Use \\`${MC_TOOLS.SEARCH_CONTENT}\\` or \\`${MC_TOOLS.FIND_FILES}\\` first if you do not yet know where the symbol is.`);\n }\n\n if (!denied.has(MC_TOOLS.NOTIFICATION_INBOX)) {\n readTools.push(`\n**${MC_TOOLS.NOTIFICATION_INBOX}** — Inspect and manage notification inbox records\n- Use this when a \\`<notification-summary>\\` says pending notifications exist.\n- Use \\`{ \"action\": \"list\", \"status\": \"pending\" }\\` or \\`{ \"action\": \"search\", \"query\": \"...\" }\\` to find notification records for the current thread.\n- Use \\`read\\` to deliver unread notification signals into the chat and mark them seen; the tool result summarizes the count instead of exposing notification contents.\n- Use \\`dismiss\\` or \\`archive\\` only when the user asks or the notification is no longer relevant.`);\n }\n\n if (readTools.length > 0) {\n sections.push(readTools.join('\\n'));\n }\n\n // --- Write/edit tools (build & fast only) ---\n\n if (modeId !== 'plan') {\n const writeTools: string[] = [];\n\n if (!denied.has(MC_TOOLS.STRING_REPLACE_LSP)) {\n writeTools.push(`\n**${MC_TOOLS.STRING_REPLACE_LSP}** — Edit files by replacing exact text\n- You MUST read a file with \\`${MC_TOOLS.VIEW}\\` before editing it.\n- \\`old_string\\` must be an exact match of existing text in the file.\n- Provide enough surrounding context in \\`old_string\\` to make it unique.\n- Use \\`replace_all: true\\` to replace all occurrences (default: false, requires unique match).\n- For creating new files, use \\`${MC_TOOLS.WRITE_FILE}\\` instead.\n- Good: Include 2-3 lines of surrounding context to ensure uniqueness.\n- Bad: Using just \\`return true;\\` — too common, will match multiple places.`);\n }\n\n if (!denied.has(MC_TOOLS.WRITE_FILE)) {\n writeTools.push(`\n**${MC_TOOLS.WRITE_FILE}** — Create new files or overwrite existing ones\n- Use this to create new files.\n- If overwriting an existing file, you MUST have read it first with \\`${MC_TOOLS.VIEW}\\`.\n- Prefer editing existing files over creating new ones.`);\n }\n\n if (writeTools.length > 0) {\n sections.push(writeTools.join('\\n'));\n }\n }\n\n // --- Web tools (all modes, conditionally available) ---\n\n if (options.hasWebSearch) {\n const webTools: string[] = [];\n if (!denied.has('web_search')) webTools.push('**web_search**');\n if (!denied.has('web_extract')) webTools.push('**web_extract**');\n if (webTools.length > 0) {\n sections.push(`\n${webTools.join(' / ')} — Search the web / extract page content\n- Use for looking up documentation, error messages, package APIs.`);\n }\n }\n\n // --- Task management tools (all modes) ---\n\n const taskTools: string[] = [];\n const canUpdateTask = !denied.has('task_update');\n const canCompleteTask = !denied.has('task_complete');\n const canCheckTasks = !denied.has('task_check');\n const canWriteTasks = !denied.has('task_write');\n const patchToolGuidance =\n canUpdateTask && canCompleteTask\n ? '- Prefer task_update or task_complete when changing one existing task.'\n : canUpdateTask\n ? '- Prefer task_update when changing one existing task.'\n : canCompleteTask\n ? '- Prefer task_complete when marking one existing task completed.'\n : '- Use task_write with the full task list when changing existing tasks.';\n\n if (canWriteTasks) {\n taskTools.push(`\n**task_write** — Track tasks for complex multi-step work\n- Use when a task requires 3 or more distinct steps or actions.\n- Use task_write to create the initial task list or replace the whole list after replanning.\n- Each task has: id (stable identifier), content (imperative form), status (pending, in_progress, or completed), activeForm (present continuous form shown during execution).\n- Keep task IDs stable across updates. If you omit IDs, the tool result returns generated IDs.\n${patchToolGuidance}\n- Mark tasks \\`in_progress\\` BEFORE starting work. Only ONE task should be \\`in_progress\\` at a time.\n- Mark tasks \\`completed\\` IMMEDIATELY after finishing each task. Do not batch completions.`);\n }\n\n if (canUpdateTask) {\n taskTools.push(`\n**task_update** — Patch one tracked task by ID\n- Use this for targeted changes to one existing task.\n- Provide the task ID and only the fields that changed: content, status, or activeForm.`);\n }\n\n if (canCompleteTask) {\n const idSource = canCheckTasks\n ? 'Use task_check if you need the current IDs before completing a task.'\n : canWriteTasks\n ? 'Use IDs returned by task_write.'\n : 'Use only task IDs already visible in the current task list.';\n taskTools.push(`\n**task_complete** — Mark one tracked task completed by ID\n- Use this immediately after finishing a tracked task.\n- ${idSource}`);\n }\n\n if (canCheckTasks) {\n taskTools.push(`\n**task_check** — Check completion status of tasks\n- Use this BEFORE finishing tracked work to verify all tasks are completed.\n- Returns a readable status summary plus structured fields: tasks, summary, incompleteTasks, and isError.\n- summary includes total, completed, inProgress, pending, incomplete, hasTasks, and allCompleted.\n- Use summary.allCompleted to decide whether tracked work is complete; if summary.hasTasks is false, no task list is currently tracked.\n- If any tasks remain incomplete, continue working on them.\n- IMPORTANT: Always check task completion before ending work on a complex task.`);\n }\n\n if (!denied.has('ask_user')) {\n taskTools.push(`\n**ask_user** — Ask the user a structured question\n- Use when you need clarification, want to validate assumptions, or need the user to make a decision.\n- Provide clear, specific questions. End with a question mark.\n- Include options (2-4 choices) for structured decisions. Omit options for open-ended questions.\n- Don't use this for simple yes/no — just ask in your text response.`);\n }\n\n if (taskTools.length > 0) {\n sections.push(taskTools.join('\\n'));\n }\n\n // --- Plan tools (plan mode) ---\n\n if (modeId === 'plan' && !denied.has('submit_plan')) {\n sections.push(`\n**submit_plan** — Submit a completed implementation plan for user review\n- Call this tool when your plan is complete. Do NOT just describe your plan in text — you MUST call this tool.\n- The plan will be rendered as markdown and the user can approve, reject, or request changes.\n- On approval, the system automatically switches to the default mode so you can implement.\n- Takes one argument: \\`path\\` (the plan markdown file you wrote under \\`.mastracode/plans/\\`). Do NOT pass the plan body — it lives in the file.`);\n }\n\n if (modeId === 'plan') {\n sections.push(`\n**Plan file access** — Your plan lives in a markdown file under \\`.mastracode/plans/\\` (e.g. \\`add-dark-mode-toggle.md\\`)\n- Use \\`write_file\\` to create the plan file, \\`view\\` to read it, and \\`string_replace_lsp\\` for targeted edits.\n- On first submission: write the plan to the file, then call \\`submit_plan\\` with its \\`path\\`.\n- On revision: read the existing file, edit specific sections, re-read, then call \\`submit_plan\\` with the same \\`path\\`.\n- If a plan file already exists, you previously submitted it — read it before revising.`);\n }\n\n // --- Subagent tool (all modes) ---\n\n if (!denied.has('subagent')) {\n sections.push(`\n**subagent** — Delegate a focused task to a specialized subagent\n- Only use subagents when you will spawn **multiple subagents in parallel**. If you only need one task done, do it yourself.\n- Subagent outputs are **untrusted**. Always review and verify the results.`);\n }\n\n return sections.join('\\n');\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SandboxFilesystem
|
|
3
|
+
*
|
|
4
|
+
* A `WorkspaceFilesystem` that stores files inside a remote `MastraSandbox`
|
|
5
|
+
* (e.g. a Railway VM) rather than on the server host. File operations are
|
|
6
|
+
* implemented by shelling out through the sandbox's `executeCommand`, so the
|
|
7
|
+
* agent's file tools and command tools share one VM and one view of the repo.
|
|
8
|
+
*
|
|
9
|
+
* Paths are workspace-relative (`/src/foo.ts`) and resolve under the sandbox
|
|
10
|
+
* working directory (`basePath`). A traversal guard rejects any path that
|
|
11
|
+
* escapes the workdir, mirroring `LocalFilesystem`'s contained mode.
|
|
12
|
+
*
|
|
13
|
+
* Reads/writes use base64 over the wire so binary content survives the shell.
|
|
14
|
+
*/
|
|
15
|
+
import type { CopyOptions, FileContent, FileEntry, FileStat, FilesystemInfo, ListOptions, ProviderStatus, ReadOptions, RemoveOptions, WorkspaceFilesystem, WriteOptions } from '@mastra/core/workspace';
|
|
16
|
+
/** Minimal command result shape we depend on. */
|
|
17
|
+
export interface SandboxCommandResult {
|
|
18
|
+
exitCode: number;
|
|
19
|
+
stdout: string;
|
|
20
|
+
stderr: string;
|
|
21
|
+
}
|
|
22
|
+
/** Minimal sandbox surface the filesystem needs. */
|
|
23
|
+
export interface SandboxExec {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
executeCommand(command: string, args?: string[], options?: {
|
|
26
|
+
timeout?: number;
|
|
27
|
+
}): Promise<SandboxCommandResult>;
|
|
28
|
+
}
|
|
29
|
+
export interface SandboxFilesystemOptions {
|
|
30
|
+
/** Live sandbox to run commands in. */
|
|
31
|
+
sandbox: SandboxExec;
|
|
32
|
+
/** Absolute path inside the sandbox that is the workspace root. */
|
|
33
|
+
workdir: string;
|
|
34
|
+
/** Optional stable id; defaults to a sandbox-derived id. */
|
|
35
|
+
id?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare class SandboxFilesystem implements WorkspaceFilesystem {
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly name = "SandboxFilesystem";
|
|
40
|
+
readonly provider = "sandbox";
|
|
41
|
+
readonly basePath: string;
|
|
42
|
+
status: ProviderStatus;
|
|
43
|
+
private readonly sandbox;
|
|
44
|
+
constructor(options: SandboxFilesystemOptions);
|
|
45
|
+
/**
|
|
46
|
+
* Resolve a workspace path to an absolute path inside the sandbox, enforcing
|
|
47
|
+
* that it stays within the workdir.
|
|
48
|
+
*/
|
|
49
|
+
private resolve;
|
|
50
|
+
resolveAbsolutePath(inputPath: string): string | undefined;
|
|
51
|
+
private exec;
|
|
52
|
+
/**
|
|
53
|
+
* Lexical guard catches `..` traversal, but a symlink inside the workdir can
|
|
54
|
+
* still point outside it. After resolving a path that refers to an existing
|
|
55
|
+
* entry, verify its realpath is still contained in the workdir.
|
|
56
|
+
*/
|
|
57
|
+
private assertContainedRealpath;
|
|
58
|
+
/**
|
|
59
|
+
* Guard for write destinations. The lexical guard catches `..`, but a symlink
|
|
60
|
+
* inside the workdir can redirect a write outside it. For an existing target
|
|
61
|
+
* we check its realpath; for a not-yet-existing target we check the realpath
|
|
62
|
+
* of its nearest existing ancestor directory, since a symlinked parent is the
|
|
63
|
+
* escape vector (e.g. `link -> /etc` then writing `link/passwd`).
|
|
64
|
+
*/
|
|
65
|
+
private assertContainedDest;
|
|
66
|
+
private execOk;
|
|
67
|
+
readFile(path: string, options?: ReadOptions): Promise<string | Buffer>;
|
|
68
|
+
writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void>;
|
|
69
|
+
appendFile(path: string, content: FileContent): Promise<void>;
|
|
70
|
+
deleteFile(path: string, options?: RemoveOptions): Promise<void>;
|
|
71
|
+
copyFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
72
|
+
moveFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
73
|
+
mkdir(path: string, options?: {
|
|
74
|
+
recursive?: boolean;
|
|
75
|
+
}): Promise<void>;
|
|
76
|
+
rmdir(path: string, options?: RemoveOptions): Promise<void>;
|
|
77
|
+
readdir(path: string, options?: ListOptions): Promise<FileEntry[]>;
|
|
78
|
+
private parseListOutput;
|
|
79
|
+
private parseFindOutput;
|
|
80
|
+
private matchesExtension;
|
|
81
|
+
exists(path: string): Promise<boolean>;
|
|
82
|
+
stat(path: string): Promise<FileStat>;
|
|
83
|
+
init(): Promise<void>;
|
|
84
|
+
destroy(): Promise<void>;
|
|
85
|
+
isReady(): Promise<boolean>;
|
|
86
|
+
getInfo(): FilesystemInfo;
|
|
87
|
+
getInstructions(): string;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=sandbox-filesystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-filesystem.d.ts","sourceRoot":"","sources":["../../src/agents/sandbox-filesystem.ts"],"names":[],"mappings":"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"}
|