@mastra/code-sdk 0.0.0-agent-tags-alpha-20261125185303
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/LICENSE.md +32 -0
- package/README.md +284 -0
- package/dist/acp/agent.d.ts +48 -0
- package/dist/acp/agent.js +414 -0
- package/dist/acp/errors.d.ts +3 -0
- package/dist/acp/errors.js +11 -0
- package/dist/acp/event-mapper.d.ts +28 -0
- package/dist/acp/event-mapper.js +274 -0
- package/dist/acp/index.d.ts +9 -0
- package/dist/acp/index.js +21 -0
- package/dist/acp/runtime.d.ts +5 -0
- package/dist/acp/runtime.js +91 -0
- package/dist/acp/server.d.ts +4 -0
- package/dist/acp/server.js +35 -0
- package/dist/acp/skills.d.ts +6 -0
- package/dist/acp/skills.js +30 -0
- package/dist/acp.d.ts +2 -0
- package/dist/acp.js +1 -0
- package/dist/agent-connections/messaging-processor.d.ts +17 -0
- package/dist/agent-connections/messaging-processor.js +131 -0
- package/dist/agent-connections/ownership.d.ts +24 -0
- package/dist/agent-connections/ownership.js +96 -0
- package/dist/agent-connections/registry.d.ts +20 -0
- package/dist/agent-connections/registry.js +167 -0
- package/dist/agent-connections/session-advertisement.d.ts +27 -0
- package/dist/agent-connections/session-advertisement.js +86 -0
- package/dist/agent-connections/signal-provider.d.ts +141 -0
- package/dist/agent-connections/signal-provider.js +35 -0
- package/dist/agent-connections/state-processor.d.ts +23 -0
- package/dist/agent-connections/state-processor.js +270 -0
- package/dist/agent-connections/thread-state.d.ts +41 -0
- package/dist/agent-connections/thread-state.js +157 -0
- package/dist/agent-connections/tools.d.ts +133 -0
- package/dist/agent-connections/tools.js +616 -0
- package/dist/agent-connections/types.d.ts +99 -0
- package/dist/agent-connections/types.js +4 -0
- package/dist/agent-connections/untrusted-text.d.ts +5 -0
- package/dist/agent-connections/untrusted-text.js +19 -0
- package/dist/agents/background-completion-events.d.ts +16 -0
- package/dist/agents/background-completion-events.js +16 -0
- package/dist/agents/background-completion.d.ts +22 -0
- package/dist/agents/background-completion.js +73 -0
- package/dist/agents/context-audit.d.ts +84 -0
- package/dist/agents/context-audit.js +115 -0
- package/dist/agents/credential-resolver.d.ts +74 -0
- package/dist/agents/credential-resolver.js +142 -0
- package/dist/agents/custom-provider-source.d.ts +35 -0
- package/dist/agents/custom-provider-source.js +22 -0
- package/dist/agents/fastembed-subprocess.d.ts +52 -0
- package/dist/agents/fastembed-subprocess.js +282 -0
- package/dist/agents/instructions.d.ts +42 -0
- package/dist/agents/instructions.js +69 -0
- package/dist/agents/mastracode-gateway.d.ts +85 -0
- package/dist/agents/mastracode-gateway.js +500 -0
- package/dist/agents/memory.d.ts +36 -0
- package/dist/agents/memory.js +248 -0
- package/dist/agents/model.d.ts +158 -0
- package/dist/agents/model.js +382 -0
- package/dist/agents/modes/build.d.ts +12 -0
- package/dist/agents/modes/build.js +33 -0
- package/dist/agents/modes/explore.d.ts +10 -0
- package/dist/agents/modes/explore.js +25 -0
- package/dist/agents/modes/plan.d.ts +8 -0
- package/dist/agents/modes/plan.js +43 -0
- package/dist/agents/prompts/agent-instructions.d.ts +122 -0
- package/dist/agents/prompts/agent-instructions.js +617 -0
- package/dist/agents/prompts/build.d.ts +12 -0
- package/dist/agents/prompts/build.js +73 -0
- package/dist/agents/prompts/fast.d.ts +5 -0
- package/dist/agents/prompts/fast.js +23 -0
- package/dist/agents/prompts/index.d.ts +61 -0
- package/dist/agents/prompts/index.js +141 -0
- package/dist/agents/prompts/model.d.ts +5 -0
- package/dist/agents/prompts/model.js +20 -0
- package/dist/agents/prompts/plan.d.ts +11 -0
- package/dist/agents/prompts/plan.js +132 -0
- package/dist/agents/prompts/tool-guidance.d.ts +18 -0
- package/dist/agents/prompts/tool-guidance.js +158 -0
- package/dist/agents/sandbox-filesystem.d.ts +232 -0
- package/dist/agents/sandbox-filesystem.js +851 -0
- package/dist/agents/subagents/execute.d.ts +3 -0
- package/dist/agents/subagents/execute.js +24 -0
- package/dist/agents/subagents/explore.d.ts +3 -0
- package/dist/agents/subagents/explore.js +15 -0
- package/dist/agents/subagents/index.d.ts +6 -0
- package/dist/agents/subagents/index.js +15 -0
- package/dist/agents/subagents/plan.d.ts +3 -0
- package/dist/agents/subagents/plan.js +15 -0
- package/dist/agents/thread-caveman-state.d.ts +17 -0
- package/dist/agents/thread-caveman-state.js +104 -0
- package/dist/agents/tool-availability.d.ts +17 -0
- package/dist/agents/tool-availability.js +134 -0
- package/dist/agents/tools.d.ts +37 -0
- package/dist/agents/tools.js +154 -0
- package/dist/agents/workflow-builder-agent.d.ts +2 -0
- package/dist/agents/workflow-builder-agent.js +79 -0
- package/dist/agents/workspace.d.ts +35 -0
- package/dist/agents/workspace.js +207 -0
- package/dist/analytics.d.ts +18 -0
- package/dist/analytics.js +159 -0
- package/dist/auth/account-rotation-processor.d.ts +210 -0
- package/dist/auth/account-rotation-processor.js +662 -0
- package/dist/auth/account-routing-context.d.ts +17 -0
- package/dist/auth/account-routing-context.js +38 -0
- package/dist/auth/authorization-input.d.ts +16 -0
- package/dist/auth/authorization-input.js +39 -0
- package/dist/auth/device-code.d.ts +93 -0
- package/dist/auth/device-code.js +126 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.js +9 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.js +29 -0
- package/dist/auth/provider-auth-error.d.ts +24 -0
- package/dist/auth/provider-auth-error.js +44 -0
- package/dist/auth/providers/anthropic.d.ts +40 -0
- package/dist/auth/providers/anthropic.js +117 -0
- package/dist/auth/providers/github-copilot.d.ts +154 -0
- package/dist/auth/providers/github-copilot.js +359 -0
- package/dist/auth/providers/kimi-coding.d.ts +38 -0
- package/dist/auth/providers/kimi-coding.js +225 -0
- package/dist/auth/providers/openai-codex.d.ts +141 -0
- package/dist/auth/providers/openai-codex.js +531 -0
- package/dist/auth/providers/xai.d.ts +64 -0
- package/dist/auth/providers/xai.js +223 -0
- package/dist/auth/storage.d.ts +222 -0
- package/dist/auth/storage.js +805 -0
- package/dist/auth/types.d.ts +164 -0
- package/dist/auth/types.js +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.js +224 -0
- package/dist/constants.d.ts +29 -0
- package/dist/constants.js +34 -0
- package/dist/error-classification.d.ts +10 -0
- package/dist/error-classification.js +19 -0
- package/dist/evals/context-builder.d.ts +41 -0
- package/dist/evals/context-builder.js +156 -0
- package/dist/evals/index.d.ts +4 -0
- package/dist/evals/index.js +5 -0
- package/dist/evals/scorers/classify-command.d.ts +30 -0
- package/dist/evals/scorers/classify-command.js +61 -0
- package/dist/evals/scorers/efficiency.d.ts +44 -0
- package/dist/evals/scorers/efficiency.js +256 -0
- package/dist/evals/scorers/extract-tools.d.ts +25 -0
- package/dist/evals/scorers/extract-tools.js +57 -0
- package/dist/evals/scorers/index.d.ts +3 -0
- package/dist/evals/scorers/index.js +3 -0
- package/dist/evals/scorers/outcome.d.ts +49 -0
- package/dist/evals/scorers/outcome.js +360 -0
- package/dist/experimental-agent.d.ts +19 -0
- package/dist/experimental-agent.js +45 -0
- package/dist/factory/client.d.ts +44 -0
- package/dist/factory/client.js +110 -0
- package/dist/factory/remote-controller.d.ts +34 -0
- package/dist/factory/remote-controller.js +40 -0
- package/dist/factory/remote-session.d.ts +210 -0
- package/dist/factory/remote-session.js +415 -0
- package/dist/goal-manager.d.ts +114 -0
- package/dist/goal-manager.js +351 -0
- package/dist/goal-signal.d.ts +14 -0
- package/dist/goal-signal.js +14 -0
- package/dist/headless/cli.d.ts +55 -0
- package/dist/headless/cli.js +261 -0
- package/dist/headless/flags.d.ts +33 -0
- package/dist/headless/flags.js +207 -0
- package/dist/headless/format.d.ts +41 -0
- package/dist/headless/format.js +94 -0
- package/dist/headless/index.d.ts +25 -0
- package/dist/headless/index.js +6 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.js +39 -0
- package/dist/headless/run-mc.d.ts +7 -0
- package/dist/headless/run-mc.js +438 -0
- package/dist/headless/types.d.ts +175 -0
- package/dist/headless/types.js +16 -0
- package/dist/hooks/config.d.ts +11 -0
- package/dist/hooks/config.js +77 -0
- package/dist/hooks/executor.d.ts +13 -0
- package/dist/hooks/executor.js +128 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/manager.d.ts +75 -0
- package/dist/hooks/manager.js +289 -0
- package/dist/hooks/types.d.ts +180 -0
- package/dist/hooks/types.js +5 -0
- package/dist/index.d.ts +537 -0
- package/dist/index.js +1399 -0
- package/dist/ipc/ipc-reporter.d.ts +14 -0
- package/dist/ipc/ipc-reporter.js +18 -0
- package/dist/knowledge-inspector.d.ts +139 -0
- package/dist/knowledge-inspector.js +533 -0
- package/dist/knowledge-scope-id.d.ts +7 -0
- package/dist/knowledge-scope-id.js +10 -0
- package/dist/knowledge-scope.d.ts +41 -0
- package/dist/knowledge-scope.js +85 -0
- package/dist/lsp/client.d.ts +56 -0
- package/dist/lsp/client.js +248 -0
- package/dist/lsp/index.d.ts +4 -0
- package/dist/lsp/index.js +4 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.js +41 -0
- package/dist/lsp/manager.d.ts +34 -0
- package/dist/lsp/manager.js +79 -0
- package/dist/lsp/server.d.ts +27 -0
- package/dist/lsp/server.js +158 -0
- package/dist/lsp/workspace.d.ts +9 -0
- package/dist/lsp/workspace.js +52 -0
- package/dist/mcp/config.d.ts +77 -0
- package/dist/mcp/config.js +313 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/manager.d.ts +104 -0
- package/dist/mcp/manager.js +693 -0
- package/dist/mcp/state.d.ts +35 -0
- package/dist/mcp/state.js +94 -0
- package/dist/mcp/types.d.ts +139 -0
- package/dist/mcp/types.js +1 -0
- package/dist/onboarding/custom-packs.d.ts +7 -0
- package/dist/onboarding/custom-packs.js +17 -0
- package/dist/onboarding/custom-providers.d.ts +4 -0
- package/dist/onboarding/custom-providers.js +27 -0
- package/dist/onboarding/index.d.ts +5 -0
- package/dist/onboarding/index.js +3 -0
- package/dist/onboarding/om-settings.d.ts +47 -0
- package/dist/onboarding/om-settings.js +80 -0
- package/dist/onboarding/pack-activation.d.ts +43 -0
- package/dist/onboarding/pack-activation.js +105 -0
- package/dist/onboarding/packs.d.ts +106 -0
- package/dist/onboarding/packs.js +283 -0
- package/dist/onboarding/settings.d.ts +563 -0
- package/dist/onboarding/settings.js +1110 -0
- package/dist/permissions.d.ts +55 -0
- package/dist/permissions.js +139 -0
- package/dist/platform/index.d.ts +74 -0
- package/dist/platform/index.js +199 -0
- package/dist/plugin.d.ts +156 -0
- package/dist/plugin.js +27 -0
- package/dist/plugins/dependencies.d.ts +9 -0
- package/dist/plugins/dependencies.js +84 -0
- package/dist/plugins/install.d.ts +21 -0
- package/dist/plugins/install.js +187 -0
- package/dist/plugins/loader.d.ts +25 -0
- package/dist/plugins/loader.js +264 -0
- package/dist/plugins/manager.d.ts +115 -0
- package/dist/plugins/manager.js +507 -0
- package/dist/plugins/manifest.d.ts +14 -0
- package/dist/plugins/manifest.js +47 -0
- package/dist/plugins/package-link.d.ts +3 -0
- package/dist/plugins/package-link.js +58 -0
- package/dist/plugins/paths.d.ts +10 -0
- package/dist/plugins/paths.js +22 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.js +109 -0
- package/dist/plugins/scaffold.d.ts +10 -0
- package/dist/plugins/scaffold.js +115 -0
- package/dist/plugins/signal-lane.d.ts +59 -0
- package/dist/plugins/signal-lane.js +163 -0
- package/dist/plugins/types.d.ts +95 -0
- package/dist/plugins/types.js +1 -0
- package/dist/process-memory-diagnostics.d.ts +136 -0
- package/dist/process-memory-diagnostics.js +497 -0
- package/dist/processors/plan-rejection-abort.d.ts +16 -0
- package/dist/processors/plan-rejection-abort.js +62 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
- package/dist/providers/amazon-bedrock-gateway.js +142 -0
- package/dist/providers/amazon-bedrock.d.ts +28 -0
- package/dist/providers/amazon-bedrock.js +99 -0
- package/dist/providers/anthropic-prompt-cache.d.ts +19 -0
- package/dist/providers/anthropic-prompt-cache.js +8 -0
- package/dist/providers/anthropic-thinking.d.ts +5 -0
- package/dist/providers/anthropic-thinking.js +22 -0
- package/dist/providers/claude-max.d.ts +67 -0
- package/dist/providers/claude-max.js +232 -0
- package/dist/providers/github-copilot-gateway.d.ts +35 -0
- package/dist/providers/github-copilot-gateway.js +58 -0
- package/dist/providers/github-copilot.d.ts +60 -0
- package/dist/providers/github-copilot.js +320 -0
- package/dist/providers/google-thinking.d.ts +31 -0
- package/dist/providers/google-thinking.js +64 -0
- package/dist/providers/google-vertex-gateway.d.ts +23 -0
- package/dist/providers/google-vertex-gateway.js +49 -0
- package/dist/providers/google-vertex.d.ts +6 -0
- package/dist/providers/google-vertex.js +51 -0
- package/dist/providers/kimi-coding.d.ts +14 -0
- package/dist/providers/kimi-coding.js +80 -0
- package/dist/providers/model-ids.d.ts +53 -0
- package/dist/providers/model-ids.js +132 -0
- package/dist/providers/openai-codex.d.ts +114 -0
- package/dist/providers/openai-codex.js +427 -0
- package/dist/providers/provider-thinking.d.ts +23 -0
- package/dist/providers/provider-thinking.js +61 -0
- package/dist/providers/thinking-request.d.ts +14 -0
- package/dist/providers/thinking-request.js +87 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.js +72 -0
- package/dist/schedules/index.d.ts +10 -0
- package/dist/schedules/index.js +6 -0
- package/dist/schedules/interval.d.ts +49 -0
- package/dist/schedules/interval.js +212 -0
- package/dist/schedules/prompt.d.ts +36 -0
- package/dist/schedules/prompt.js +36 -0
- package/dist/schedules/run-script.d.ts +8 -0
- package/dist/schedules/run-script.js +80 -0
- package/dist/schedules/scheduler.d.ts +101 -0
- package/dist/schedules/scheduler.js +167 -0
- package/dist/schedules/tools.d.ts +57 -0
- package/dist/schedules/tools.js +217 -0
- package/dist/schema.d.ts +499 -0
- package/dist/schema.js +131 -0
- package/dist/theme-palette.d.ts +17 -0
- package/dist/theme-palette.js +18 -0
- package/dist/thinking-catalog.d.ts +4 -0
- package/dist/thinking-catalog.js +13 -0
- package/dist/thinking.d.ts +37 -0
- package/dist/thinking.js +134 -0
- package/dist/tool-names.d.ts +77 -0
- package/dist/tool-names.js +53 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/request-sandbox-access.d.ts +6 -0
- package/dist/tools/request-sandbox-access.js +80 -0
- package/dist/tools/utils.d.ts +20 -0
- package/dist/tools/utils.js +31 -0
- package/dist/tools/web-search.d.ts +116 -0
- package/dist/tools/web-search.js +158 -0
- package/dist/tools/workflows/create-workflow.d.ts +7 -0
- package/dist/tools/workflows/create-workflow.js +82 -0
- package/dist/tools/workflows/delete-workflow.d.ts +7 -0
- package/dist/tools/workflows/delete-workflow.js +18 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts +28 -0
- package/dist/tools/workflows/ephemeral-memory.js +41 -0
- package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
- package/dist/tools/workflows/extract-json-schema.js +19 -0
- package/dist/tools/workflows/get-workflow.d.ts +11 -0
- package/dist/tools/workflows/get-workflow.js +31 -0
- package/dist/tools/workflows/list-available-agents.d.ts +8 -0
- package/dist/tools/workflows/list-available-agents.js +29 -0
- package/dist/tools/workflows/list-available-classifiers.d.ts +19 -0
- package/dist/tools/workflows/list-available-classifiers.js +53 -0
- package/dist/tools/workflows/list-available-tools.d.ts +9 -0
- package/dist/tools/workflows/list-available-tools.js +37 -0
- package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-available-workflows.js +29 -0
- package/dist/tools/workflows/list-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-workflows.js +30 -0
- package/dist/tools/workflows/run-workflow.d.ts +9 -0
- package/dist/tools/workflows/run-workflow.js +49 -0
- package/dist/tools/workflows/save-workflow.d.ts +1125 -0
- package/dist/tools/workflows/save-workflow.js +25 -0
- package/dist/tools/workflows/tool-ids.d.ts +16 -0
- package/dist/tools/workflows/tool-ids.js +17 -0
- package/dist/utils/binaries.d.ts +7 -0
- package/dist/utils/binaries.js +97 -0
- package/dist/utils/debug-log.d.ts +12 -0
- package/dist/utils/debug-log.js +56 -0
- package/dist/utils/discarding-scores-storage.d.ts +33 -0
- package/dist/utils/discarding-scores-storage.js +51 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.js +215 -0
- package/dist/utils/gateway-sync.d.ts +26 -0
- package/dist/utils/gateway-sync.js +58 -0
- package/dist/utils/local-observability.d.ts +19 -0
- package/dist/utils/local-observability.js +54 -0
- package/dist/utils/maintenance-lock.d.ts +42 -0
- package/dist/utils/maintenance-lock.js +196 -0
- package/dist/utils/notification-dispatch.d.ts +74 -0
- package/dist/utils/notification-dispatch.js +128 -0
- package/dist/utils/open-url.d.ts +10 -0
- package/dist/utils/open-url.js +27 -0
- package/dist/utils/path-security.d.ts +2 -0
- package/dist/utils/path-security.js +7 -0
- package/dist/utils/plan-diff.d.ts +25 -0
- package/dist/utils/plan-diff.js +59 -0
- package/dist/utils/plans.d.ts +61 -0
- package/dist/utils/plans.js +120 -0
- package/dist/utils/project.d.ts +160 -0
- package/dist/utils/project.js +361 -0
- package/dist/utils/prune-cli.d.ts +24 -0
- package/dist/utils/prune-cli.js +124 -0
- package/dist/utils/signals-pubsub.d.ts +103 -0
- package/dist/utils/signals-pubsub.js +409 -0
- package/dist/utils/slash-command-loader.d.ts +52 -0
- package/dist/utils/slash-command-loader.js +139 -0
- package/dist/utils/slash-command-processor.d.ts +14 -0
- package/dist/utils/slash-command-processor.js +106 -0
- package/dist/utils/stdin-pipe.d.ts +33 -0
- package/dist/utils/stdin-pipe.js +93 -0
- package/dist/utils/storage-factory.d.ts +50 -0
- package/dist/utils/storage-factory.js +118 -0
- package/dist/utils/storage-maintenance.d.ts +121 -0
- package/dist/utils/storage-maintenance.js +352 -0
- package/dist/utils/thread-lock.d.ts +26 -0
- package/dist/utils/thread-lock.js +109 -0
- package/dist/utils/token-estimator.d.ts +3 -0
- package/dist/utils/token-estimator.js +19 -0
- package/dist/utils/update-check.d.ts +151 -0
- package/dist/utils/update-check.js +430 -0
- package/dist/utils/wake-session.d.ts +44 -0
- package/dist/utils/wake-session.js +83 -0
- package/dist/voice/stt-registry.d.ts +67 -0
- package/dist/voice/stt-registry.js +144 -0
- package/dist/voice/transcribe.d.ts +10 -0
- package/dist/voice/transcribe.js +75 -0
- package/dist/workflows/register-primitives.d.ts +52 -0
- package/dist/workflows/register-primitives.js +40 -0
- package/dist/workflows/service.d.ts +64 -0
- package/dist/workflows/service.js +50 -0
- package/package.json +117 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fast mode prompt — quick answers and small edits, minimal overhead.
|
|
3
|
+
*/
|
|
4
|
+
export declare 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 \u2014 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";
|
|
5
|
+
//# sourceMappingURL=fast.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/agents/prompts/fast.ts
|
|
2
|
+
/**
|
|
3
|
+
* Fast mode prompt — quick answers and small edits, minimal overhead.
|
|
4
|
+
*/
|
|
5
|
+
const fastModePrompt = `
|
|
6
|
+
# Fast Mode
|
|
7
|
+
|
|
8
|
+
You are in FAST mode. Optimize for speed and brevity.
|
|
9
|
+
|
|
10
|
+
## Rules
|
|
11
|
+
- Keep responses short. Under 200 words unless the task genuinely requires more.
|
|
12
|
+
- Skip planning. Just do the task directly.
|
|
13
|
+
- For questions: give the direct answer, not a tutorial.
|
|
14
|
+
- For edits: make the change, show what you did, move on.
|
|
15
|
+
- Don't explore the codebase more than necessary for the immediate task.
|
|
16
|
+
|
|
17
|
+
## When to Use Tools vs. Just Answer
|
|
18
|
+
- If the user asks a general programming question, answer directly from knowledge. Don't search the codebase.
|
|
19
|
+
- If the user asks about THIS project's code, use tools to look it up — don't guess.
|
|
20
|
+
- If the user asks for a quick edit and you know the file, read it and edit it. Don't ask for confirmation.
|
|
21
|
+
- One tool call to read + one to edit is ideal. Minimize round trips.
|
|
22
|
+
`;
|
|
23
|
+
export { fastModePrompt };
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
import type { RequestContextReader } from '../../auth/account-routing-context.js';
|
|
9
|
+
import type { InstructionSource } from './agent-instructions.js';
|
|
10
|
+
export interface PromptContext extends Omit<BasePromptContext, 'toolGuidance'> {
|
|
11
|
+
modeId: string;
|
|
12
|
+
state?: any;
|
|
13
|
+
hostInstructions?: string;
|
|
14
|
+
/** Request whose credentials decide the model's transport, and so its web search tool. */
|
|
15
|
+
requestContext?: RequestContextReader;
|
|
16
|
+
/** Controller built-in tools removed via `disableBuiltinTools`; treated as denied. */
|
|
17
|
+
disabledBuiltinTools?: readonly string[];
|
|
18
|
+
/** Host-configured workspace-relative plans directory (see `MastraCodeConfig.plansDir`). */
|
|
19
|
+
plansDir?: string;
|
|
20
|
+
/** Agent tools removed via `disabledTools` (e.g. `web_search`); treated as denied. */
|
|
21
|
+
disabledTools?: readonly string[];
|
|
22
|
+
/** Resolved in `buildFullPromptSections`; false when `submit_plan` is denied or disabled. */
|
|
23
|
+
submitPlanAvailable?: boolean;
|
|
24
|
+
currentDate: string;
|
|
25
|
+
workingDir: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* One labeled piece of the assembled system prompt.
|
|
29
|
+
*
|
|
30
|
+
* The system prompt is a single string by the time it reaches the model, which
|
|
31
|
+
* makes it impossible to say which configuration source is responsible for
|
|
32
|
+
* which share of the context window. Building it as labeled sections and
|
|
33
|
+
* joining them at the end keeps that attribution available to the `/context`
|
|
34
|
+
* audit while guaranteeing the audit measures the exact text that is sent —
|
|
35
|
+
* a parallel "describe the prompt" path would drift and report numbers for a
|
|
36
|
+
* prompt that is no longer assembled this way.
|
|
37
|
+
*/
|
|
38
|
+
export interface PromptSection {
|
|
39
|
+
/** Stable identifier, unique within a single build. */
|
|
40
|
+
id: string;
|
|
41
|
+
/** Human-readable label for display. */
|
|
42
|
+
label: string;
|
|
43
|
+
/** Optional provenance (e.g. the instruction file path). */
|
|
44
|
+
detail?: string;
|
|
45
|
+
/** The exact text contributed to the prompt. */
|
|
46
|
+
content: string;
|
|
47
|
+
}
|
|
48
|
+
/** Join prompt sections into the final system prompt string. */
|
|
49
|
+
export declare function joinPromptSections(sections: PromptSection[]): string;
|
|
50
|
+
/**
|
|
51
|
+
* Build the full system prompt for a given mode and context.
|
|
52
|
+
* Combines the base prompt with mode-specific instructions.
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildFullPrompt(ctx: PromptContext): string;
|
|
55
|
+
export declare function buildFullPromptSectionsAsync(ctx: PromptContext): Promise<PromptSection[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Build the system prompt as labeled sections. `buildFullPrompt` is the join of
|
|
58
|
+
* these, so the two can never disagree about what the model receives.
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildFullPromptSections(ctx: PromptContext, loadedInstructions?: InstructionSource[]): PromptSection[];
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { buildModePrompt, buildModePromptFn } from "./build.js";
|
|
2
|
+
import { planModePrompt } from "./plan.js";
|
|
3
|
+
import { fastModePrompt } from "./fast.js";
|
|
4
|
+
import { loadSettings, resolveLspSetting } from "../../onboarding/settings.js";
|
|
5
|
+
import { MC_TOOLS } from "../../tool-names.js";
|
|
6
|
+
import "../../tools/index.js";
|
|
7
|
+
import { getLocalPlansRelativeDir } from "../../utils/plans.js";
|
|
8
|
+
import { hasParallelKey, hasTavilyKey } from "../../tools/web-search.js";
|
|
9
|
+
import { resolveProviderWebSearchRoute } from "../model.js";
|
|
10
|
+
import { AGENT_INSTRUCTIONS_HEADING, formatInstructionSource, loadSessionInstructions, loadSessionInstructionsAsync } from "./agent-instructions.js";
|
|
11
|
+
import { modelSpecificPrompts } from "./model.js";
|
|
12
|
+
import { buildToolGuidance } from "./tool-guidance.js";
|
|
13
|
+
import { buildBasePrompt } from "@mastra/core/coding-agent";
|
|
14
|
+
// src/agents/prompts/index.ts
|
|
15
|
+
const modePrompts = {
|
|
16
|
+
build: buildModePromptFn,
|
|
17
|
+
plan: planModePrompt,
|
|
18
|
+
fast: fastModePrompt
|
|
19
|
+
};
|
|
20
|
+
/** Join prompt sections into the final system prompt string. */
|
|
21
|
+
function joinPromptSections(sections) {
|
|
22
|
+
return sections.map((section) => section.content).filter(Boolean).join("\n\n");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build the full system prompt for a given mode and context.
|
|
26
|
+
* Combines the base prompt with mode-specific instructions.
|
|
27
|
+
*/
|
|
28
|
+
function buildFullPrompt(ctx) {
|
|
29
|
+
return joinPromptSections(buildFullPromptSections(ctx));
|
|
30
|
+
}
|
|
31
|
+
async function buildFullPromptSectionsAsync(ctx) {
|
|
32
|
+
return buildFullPromptSections(ctx, ctx.workingDir ? await loadSessionInstructionsAsync({
|
|
33
|
+
workingDir: ctx.workingDir,
|
|
34
|
+
instructionRoots: Array.isArray(ctx.state?.instructionRoots) ? ctx.state.instructionRoots : void 0,
|
|
35
|
+
configDir: ctx.state?.configDir,
|
|
36
|
+
untrustedCheckout: ctx.state?.untrustedCheckout === true,
|
|
37
|
+
baseRef: typeof ctx.state?.baseRef === "string" ? ctx.state.baseRef : void 0,
|
|
38
|
+
skipGlobal: ctx.state?.skipGlobalInstructions === true
|
|
39
|
+
}) : []);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Build the system prompt as labeled sections. `buildFullPrompt` is the join of
|
|
43
|
+
* these, so the two can never disagree about what the model receives.
|
|
44
|
+
*/
|
|
45
|
+
function buildFullPromptSections(ctx, loadedInstructions) {
|
|
46
|
+
const hasWebExtract = hasParallelKey() || hasTavilyKey();
|
|
47
|
+
const hasWebSearch = hasWebExtract || resolveProviderWebSearchRoute(ctx.modelId, { requestContext: ctx.requestContext }) !== void 0;
|
|
48
|
+
const deniedTools = /* @__PURE__ */ new Set();
|
|
49
|
+
const permRules = ctx.state?.permissionRules;
|
|
50
|
+
if (permRules?.tools) {
|
|
51
|
+
for (const [name, policy] of Object.entries(permRules.tools)) if (policy === "deny") deniedTools.add(name);
|
|
52
|
+
}
|
|
53
|
+
for (const name of ctx.disabledBuiltinTools ?? []) deniedTools.add(name);
|
|
54
|
+
for (const name of ctx.disabledTools ?? []) deniedTools.add(name);
|
|
55
|
+
if (resolveLspSetting(loadSettings().lsp) === false) deniedTools.add(MC_TOOLS.LSP_INSPECT);
|
|
56
|
+
const factoryProjectId = typeof ctx.state?.factoryProjectId === "string" ? ctx.state.factoryProjectId : void 0;
|
|
57
|
+
const toolGuidance = buildToolGuidance(ctx.modeId, {
|
|
58
|
+
hasWebSearch,
|
|
59
|
+
hasWebExtract,
|
|
60
|
+
hasSubagents: ctx.hasSubagents,
|
|
61
|
+
deniedTools,
|
|
62
|
+
plansDir: getLocalPlansRelativeDir({
|
|
63
|
+
factoryProjectId,
|
|
64
|
+
plansDir: ctx.plansDir
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
const baseCtx = {
|
|
68
|
+
projectPath: ctx.workingDir || "(no workspace attached)",
|
|
69
|
+
projectName: ctx.projectName || "unknown",
|
|
70
|
+
gitBranch: ctx.gitBranch,
|
|
71
|
+
platform: process.platform,
|
|
72
|
+
commonBinaries: ctx.commonBinaries,
|
|
73
|
+
date: ctx.currentDate,
|
|
74
|
+
mode: ctx.modeId,
|
|
75
|
+
modelId: ctx.modelId,
|
|
76
|
+
coAuthorName: ctx.coAuthorName,
|
|
77
|
+
coAuthorEmail: ctx.coAuthorEmail,
|
|
78
|
+
activePlan: ctx.state?.activePlan,
|
|
79
|
+
hasSubagents: ctx.hasSubagents !== false && !deniedTools.has("subagent"),
|
|
80
|
+
planApprovalStartsGoal: ctx.planApprovalStartsGoal,
|
|
81
|
+
toolGuidance
|
|
82
|
+
};
|
|
83
|
+
const base = buildBasePrompt(baseCtx);
|
|
84
|
+
const entry = modePrompts[ctx.modeId] || modePrompts.build;
|
|
85
|
+
const modeSpecific = (typeof entry === "function" ? entry({
|
|
86
|
+
...ctx,
|
|
87
|
+
submitPlanAvailable: !deniedTools.has("submit_plan")
|
|
88
|
+
}) : entry) ?? "";
|
|
89
|
+
const modelSpecific = ctx.modelId ? modelSpecificPrompts[ctx.modelId] ?? "" : "";
|
|
90
|
+
const configDir = ctx.state?.configDir;
|
|
91
|
+
const baseRef = typeof ctx.state?.baseRef === "string" ? ctx.state.baseRef : void 0;
|
|
92
|
+
const instructionRoots = Array.isArray(ctx.state?.instructionRoots) ? ctx.state.instructionRoots : void 0;
|
|
93
|
+
const instructionSources = loadedInstructions ?? (ctx.workingDir ? loadSessionInstructions({
|
|
94
|
+
workingDir: ctx.workingDir,
|
|
95
|
+
instructionRoots,
|
|
96
|
+
configDir,
|
|
97
|
+
untrustedCheckout: ctx.state?.untrustedCheckout === true,
|
|
98
|
+
baseRef,
|
|
99
|
+
skipGlobal: ctx.state?.skipGlobalInstructions === true
|
|
100
|
+
}) : []);
|
|
101
|
+
const instructionSections = instructionSources.map((source, index) => {
|
|
102
|
+
const isFirst = index === 0;
|
|
103
|
+
const isLast = index === instructionSources.length - 1;
|
|
104
|
+
let content = formatInstructionSource(source);
|
|
105
|
+
if (isFirst) content = `${AGENT_INSTRUCTIONS_HEADING}\n\n${content}`;
|
|
106
|
+
if (isLast) content = content.trimEnd();
|
|
107
|
+
return {
|
|
108
|
+
id: `agent-instructions:${source.path}:${index}`,
|
|
109
|
+
label: `${source.scope === "global" ? "Global" : "Project"} instructions`,
|
|
110
|
+
detail: source.ref ? `${source.path} (at ref ${source.ref})` : source.path,
|
|
111
|
+
content
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
const hostInstructions = ctx.hostInstructions?.trim() ?? "";
|
|
115
|
+
return [
|
|
116
|
+
{
|
|
117
|
+
id: "base-prompt",
|
|
118
|
+
label: "Base system prompt",
|
|
119
|
+
content: base
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: "host-instructions",
|
|
123
|
+
label: "Host instructions",
|
|
124
|
+
content: hostInstructions
|
|
125
|
+
},
|
|
126
|
+
...instructionSections,
|
|
127
|
+
{
|
|
128
|
+
id: "model-prompt",
|
|
129
|
+
label: "Model-specific prompt",
|
|
130
|
+
detail: ctx.modelId,
|
|
131
|
+
content: modelSpecific.trim()
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: "mode-prompt",
|
|
135
|
+
label: "Mode prompt",
|
|
136
|
+
detail: ctx.modeId,
|
|
137
|
+
content: modeSpecific.trim()
|
|
138
|
+
}
|
|
139
|
+
].filter((section) => Boolean(section.content));
|
|
140
|
+
}
|
|
141
|
+
export { buildFullPrompt, buildFullPromptSections, buildFullPromptSectionsAsync, buildModePrompt, buildModePromptFn, fastModePrompt, joinPromptSections, planModePrompt };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/agents/prompts/model.ts
|
|
2
|
+
const modelSpecificPrompts = {
|
|
3
|
+
"openai/gpt-5.4": `<autonomy_and_persistence>
|
|
4
|
+
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.
|
|
5
|
+
|
|
6
|
+
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.
|
|
7
|
+
</autonomy_and_persistence>
|
|
8
|
+
`,
|
|
9
|
+
"openai/gpt-5.5": `<coding_behavior>
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
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.
|
|
13
|
+
|
|
14
|
+
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.
|
|
15
|
+
|
|
16
|
+
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.
|
|
17
|
+
</coding_behavior>
|
|
18
|
+
`
|
|
19
|
+
};
|
|
20
|
+
export { modelSpecificPrompts };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface PlanPromptContext {
|
|
2
|
+
state?: Record<string, unknown>;
|
|
3
|
+
plansDir?: string;
|
|
4
|
+
/** False when the host disabled or denied `submit_plan`; defaults to available. */
|
|
5
|
+
submitPlanAvailable?: boolean;
|
|
6
|
+
/** False when the host does not start a goal on plan approval (Factory); defaults to true. */
|
|
7
|
+
planApprovalStartsGoal?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function planModePrompt(ctx: PlanPromptContext): string;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { getLocalPlansRelativeDir } from "../../utils/plans.js";
|
|
2
|
+
// src/agents/prompts/plan.ts
|
|
3
|
+
/**
|
|
4
|
+
* Plan mode prompt — read-only exploration and planning.
|
|
5
|
+
*/
|
|
6
|
+
function planModePrompt(ctx) {
|
|
7
|
+
const factoryProjectId = typeof ctx.state?.factoryProjectId === "string" ? ctx.state.factoryProjectId : void 0;
|
|
8
|
+
const plansDir = getLocalPlansRelativeDir({
|
|
9
|
+
factoryProjectId,
|
|
10
|
+
plansDir: ctx.plansDir
|
|
11
|
+
});
|
|
12
|
+
const examplePath = `${plansDir}/add-dark-mode.md`;
|
|
13
|
+
const submitPlanAvailable = ctx.submitPlanAvailable !== false;
|
|
14
|
+
const planApprovalStartsGoal = ctx.planApprovalStartsGoal !== false;
|
|
15
|
+
return `
|
|
16
|
+
# Plan Mode — READ-ONLY (except plan files)
|
|
17
|
+
|
|
18
|
+
You are in PLAN mode. Your job is to explore the codebase and design an implementation plan — NOT to make changes to the project.
|
|
19
|
+
|
|
20
|
+
## CRITICAL: Read-Only Mode (project files)
|
|
21
|
+
|
|
22
|
+
This mode is **read-only for project files**. You must NOT modify the project.
|
|
23
|
+
|
|
24
|
+
- Do NOT modify, create, or delete project files
|
|
25
|
+
- Do NOT run commands that change state (no git commit, no npm install, no file creation)
|
|
26
|
+
- Do NOT run build commands, tests, or scripts that have side effects
|
|
27
|
+
|
|
28
|
+
The ONE exception is plan files: you CAN create and edit markdown files inside \`${plansDir}/\` (e.g. \`${examplePath}\`). You may NOT write anywhere else.
|
|
29
|
+
|
|
30
|
+
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.
|
|
31
|
+
|
|
32
|
+
## Exploration Strategy
|
|
33
|
+
|
|
34
|
+
Before writing any plan, build a mental model of the codebase:
|
|
35
|
+
1. Start with the directory structure (\`view\` on the project root or relevant subdirectory).
|
|
36
|
+
2. Find the relevant entry points and core files using \`search_content\` and \`find_files\`.
|
|
37
|
+
3. Read the actual code — don't assume based on file names alone.
|
|
38
|
+
4. Trace data flow: where does input come from, how is it transformed, where does it go?
|
|
39
|
+
5. Identify existing patterns the codebase uses (naming, structure, error handling, testing).
|
|
40
|
+
|
|
41
|
+
${submitPlanAvailable ? goalReadySection(planApprovalStartsGoal) : ""}## Your Plan Output
|
|
42
|
+
|
|
43
|
+
Produce a clear, step-by-step plan with this structure:
|
|
44
|
+
|
|
45
|
+
### Overview
|
|
46
|
+
One paragraph: what the change does and why.
|
|
47
|
+
|
|
48
|
+
### Complexity Estimate
|
|
49
|
+
- **Size**: Small (1-2 files) / Medium (3-5 files) / Large (6+ files)
|
|
50
|
+
- **Risk**: Low (additive, no breaking changes) / Medium (modifies existing behavior) / High (architectural, affects many consumers)
|
|
51
|
+
- **Dependencies**: List any new packages, external services, or migration steps needed.
|
|
52
|
+
|
|
53
|
+
### Steps
|
|
54
|
+
For each step:
|
|
55
|
+
1. **File**: path to create or modify
|
|
56
|
+
2. **Change**: what to add/modify/remove, with enough specificity to implement directly
|
|
57
|
+
3. **Why**: brief rationale connecting this step to the overall goal
|
|
58
|
+
|
|
59
|
+
### Verification
|
|
60
|
+
- What tests to run
|
|
61
|
+
- What to check manually
|
|
62
|
+
- What could go wrong
|
|
63
|
+
|
|
64
|
+
## Plan File Workflow
|
|
65
|
+
|
|
66
|
+
Write each plan to its own markdown file under \`${plansDir}/\` (e.g. \`${examplePath}\`). Start the file with a \`# Title\` heading describing the plan.
|
|
67
|
+
|
|
68
|
+
1. **${submitPlanAvailable ? "First submission" : "Writing"}**: Write your plan to a file under \`${plansDir}/\` using \`write_file\`${submitPlanAvailable ? ", then call `submit_plan` with the `path` to that file" : ""}.
|
|
69
|
+
2. **Reading**: Use \`view\` to read a plan file.
|
|
70
|
+
3. **Editing**: Use \`string_replace_lsp\` for targeted edits to specific sections.
|
|
71
|
+
|
|
72
|
+
**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.
|
|
73
|
+
|
|
74
|
+
${submitPlanAvailable ? submitPlanSection(plansDir, examplePath, planApprovalStartsGoal) : planFileOnlySection(plansDir)}Do NOT start implementing until the plan is approved.
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
function goalReadySection(planApprovalStartsGoal) {
|
|
78
|
+
return `## ${planApprovalStartsGoal ? "Goal-Ready Plans" : "Executable Plans"}
|
|
79
|
+
|
|
80
|
+
${planApprovalStartsGoal ? "Approving a plan in the submit_plan approval UI starts it as a persistent goal. Write plans so they can be carried out as a goal:" : "Write plans so they can be carried out autonomously after approval:"}
|
|
81
|
+
- Make the desired outcome explicit and verifiable.
|
|
82
|
+
- Break work into ordered, actionable steps that can be executed autonomously.
|
|
83
|
+
- Include constraints, risks, blockers, and decision points that may require user input.
|
|
84
|
+
- Include concrete verification criteria so ${planApprovalStartsGoal ? "the goal judge" : "you"} can tell when the work is done.
|
|
85
|
+
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
function submitPlanSection(plansDir, examplePath, planApprovalStartsGoal) {
|
|
89
|
+
return `## IMMEDIATE ACTION: Write plan file, then call submit_plan
|
|
90
|
+
|
|
91
|
+
As soon as your plan is complete:
|
|
92
|
+
1. Write it to a file under \`${plansDir}/\` using \`write_file\`
|
|
93
|
+
2. Call \`submit_plan\` with the \`path\` to that file
|
|
94
|
+
|
|
95
|
+
**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.
|
|
96
|
+
|
|
97
|
+
\`\`\`javascript
|
|
98
|
+
submit_plan({
|
|
99
|
+
path: "${examplePath}"
|
|
100
|
+
})
|
|
101
|
+
\`\`\`
|
|
102
|
+
|
|
103
|
+
The user will see the plan rendered inline and can:
|
|
104
|
+
- **Approve** — ${planApprovalStartsGoal ? "switches to Build mode and starts the plan as a goal, so the agent keeps working toward the plan until judged complete, paused, or waiting for user input" : "switches to Build mode for implementation"}
|
|
105
|
+
- **Request changes** — rejects the plan; the agent stops immediately and the user provides revision feedback in their next chat message
|
|
106
|
+
|
|
107
|
+
## Revision Workflow
|
|
108
|
+
|
|
109
|
+
If the user requests changes, you will be stopped immediately. Wait for their next message — it will contain their revision feedback. When you receive it:
|
|
110
|
+
1. Use \`view\` to read the SAME plan file
|
|
111
|
+
2. Use \`string_replace_lsp\` to make targeted edits based on feedback
|
|
112
|
+
3. Use \`view\` to re-read the updated file
|
|
113
|
+
4. Call \`submit_plan\` again with the same \`path\` — editing the file alone does NOT resubmit it
|
|
114
|
+
|
|
115
|
+
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 — do NOT rewrite the entire plan from scratch for small changes, and do NOT move the plan to a new file for a revision.
|
|
116
|
+
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
function planFileOnlySection(plansDir) {
|
|
120
|
+
return `## When the plan is complete
|
|
121
|
+
|
|
122
|
+
Plan approval is not available in this session — there is no \`submit_plan\` tool. As soon as your plan is complete:
|
|
123
|
+
1. Write it to a file under \`${plansDir}/\` using \`write_file\`
|
|
124
|
+
2. Follow any host or session instructions for handing the plan off; otherwise reply with a brief summary and the plan file path
|
|
125
|
+
|
|
126
|
+
**CRITICAL:** Do NOT generate a long text response describing your plan. The plan content belongs in the plan file.
|
|
127
|
+
|
|
128
|
+
When you receive revision feedback, edit the SAME plan file with \`string_replace_lsp\` rather than rewriting it or moving it to a new file.
|
|
129
|
+
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
export { planModePrompt };
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
/** `web_extract` is registered (Parallel/Tavily); provider-executed search has no extract tool. */
|
|
9
|
+
hasWebExtract?: boolean;
|
|
10
|
+
hasSubagents?: boolean;
|
|
11
|
+
/** Tool names that have been denied — omit their guidance sections. */
|
|
12
|
+
deniedTools?: Set<string>;
|
|
13
|
+
/** Workspace-relative directory where plan mode can write plans. */
|
|
14
|
+
plansDir?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function buildToolGuidance(modeId: string, options?: ToolGuidanceOptions): string;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=tool-guidance.d.ts.map
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { MC_TOOLS } from "../../tool-names.js";
|
|
2
|
+
// src/agents/prompts/tool-guidance.ts
|
|
3
|
+
/**
|
|
4
|
+
* Mode-specific tool behavioral guidance.
|
|
5
|
+
* Generates tool usage instructions that match the actual registered tool names
|
|
6
|
+
* and are scoped to what's available in the current mode.
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_PLANS_DIR = ".mastracode/plans";
|
|
9
|
+
function buildToolGuidance(modeId, options = {}) {
|
|
10
|
+
const denied = options.deniedTools ?? /* @__PURE__ */ new Set();
|
|
11
|
+
const plansDir = (options.plansDir ?? DEFAULT_PLANS_DIR).replaceAll("\\", "/");
|
|
12
|
+
const sections = [];
|
|
13
|
+
sections.push(`# Tool Usage Rules
|
|
14
|
+
|
|
15
|
+
IMPORTANT: 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.
|
|
16
|
+
|
|
17
|
+
You have access to the following tools. Use the RIGHT tool for the job:`);
|
|
18
|
+
const readTools = [];
|
|
19
|
+
if (!denied.has(MC_TOOLS.VIEW)) readTools.push(`
|
|
20
|
+
**${MC_TOOLS.VIEW}** — Read file contents
|
|
21
|
+
- Use this to read file contents. Don't propose changes to code you haven't seen; reading with shell commands (cat, sed, rg) also works.
|
|
22
|
+
- Use \`offset\` (1-indexed start line) and \`limit\` (number of lines) for large files.
|
|
23
|
+
- Example: Read lines 50-100: \`{ path: "src/big-file.ts", offset: 50, limit: 51 }\`
|
|
24
|
+
- To list directories, use \`${MC_TOOLS.FIND_FILES}\` instead.`);
|
|
25
|
+
if (!denied.has(MC_TOOLS.SEARCH_CONTENT)) readTools.push(`
|
|
26
|
+
**${MC_TOOLS.SEARCH_CONTENT}** — Search file contents using regex
|
|
27
|
+
- Preferred for content search (finding functions, variables, error messages, imports, etc.)
|
|
28
|
+
- Use \`path\` to filter by directory or glob pattern. Supports \`contextLines\`, \`caseSensitive\`, and \`maxCount\`.
|
|
29
|
+
- Example: Find a function: \`{ pattern: "function handleSubmit", path: "**/*.ts" }\`
|
|
30
|
+
- Example: Find imports: \`{ pattern: "from ['\\"\\]express['\\"\\]", path: "**/*.ts" }\`
|
|
31
|
+
- Respects .gitignore by default.`);
|
|
32
|
+
if (!denied.has(MC_TOOLS.FIND_FILES)) readTools.push(`
|
|
33
|
+
**${MC_TOOLS.FIND_FILES}** — List files and directories as a tree
|
|
34
|
+
- Preferred for exploring project structure and finding files by pattern.
|
|
35
|
+
- Returns tree-style output. Respects .gitignore by default.
|
|
36
|
+
- Example: List project root: \`{ path: "./" }\`
|
|
37
|
+
- Example: Find test files: \`{ path: "./src", pattern: "**/*.test.ts" }\`
|
|
38
|
+
- Example: Find config files: \`{ pattern: "*.config.{js,ts,json}" }\``);
|
|
39
|
+
if (!denied.has(MC_TOOLS.EXECUTE_COMMAND)) readTools.push(`
|
|
40
|
+
**${MC_TOOLS.EXECUTE_COMMAND}** — Run shell commands
|
|
41
|
+
- Use for: git, npm/pnpm, docker, build tools, test runners, and other terminal operations.
|
|
42
|
+
- 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}).
|
|
43
|
+
- Commands have a 30-second default timeout. Use \`timeout\` for longer commands, \`cwd\` for working directory.
|
|
44
|
+
- 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.
|
|
45
|
+
- Always set \`description\` to a 5-10 word summary of what the command does; the user sees it instead of the raw command. Put it first in the arguments, before \`command\`, so the user sees it while the rest of the call streams in. Write each one as the next step in a running narrative that can lean on earlier commands (e.g. "Searching open PRs for failing CI", then "Drilling into the first of 15 failures").
|
|
46
|
+
- Good: Run independent commands in parallel when possible.
|
|
47
|
+
- Bad: Running \`cat file.txt\` — use the ${MC_TOOLS.VIEW} tool instead.`);
|
|
48
|
+
if (!denied.has(MC_TOOLS.LSP_INSPECT)) readTools.push(`
|
|
49
|
+
**${MC_TOOLS.LSP_INSPECT}** — 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()" }\` — 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
|
+
if (!denied.has(MC_TOOLS.NOTIFICATION_INBOX)) readTools.push(`
|
|
58
|
+
**${MC_TOOLS.NOTIFICATION_INBOX}** — Inspect and manage notification inbox records
|
|
59
|
+
- Use this when a \`<notification-summary>\` says pending notifications exist.
|
|
60
|
+
- Use \`{ "action": "list", "status": "pending" }\` or \`{ "action": "search", "query": "..." }\` to find notification records for the current thread.
|
|
61
|
+
- 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.
|
|
62
|
+
- Use \`dismiss\` or \`archive\` only when the user asks or the notification is no longer relevant.`);
|
|
63
|
+
if (readTools.length > 0) sections.push(readTools.join("\n"));
|
|
64
|
+
if (modeId !== "plan") {
|
|
65
|
+
const writeTools = [];
|
|
66
|
+
if (!denied.has(MC_TOOLS.STRING_REPLACE_LSP)) writeTools.push(`
|
|
67
|
+
**${MC_TOOLS.STRING_REPLACE_LSP}** — Edit files by replacing exact text
|
|
68
|
+
- \`old_string\` must be an exact match of existing text in the file.
|
|
69
|
+
- Provide enough surrounding context in \`old_string\` to make it unique.
|
|
70
|
+
- Use \`replace_all: true\` to replace all occurrences (default: false, requires unique match).
|
|
71
|
+
- For creating new files, use \`${MC_TOOLS.WRITE_FILE}\` instead.
|
|
72
|
+
- Good: Include 2-3 lines of surrounding context to ensure uniqueness.
|
|
73
|
+
- Bad: Using just \`return true;\` — too common, will match multiple places.`);
|
|
74
|
+
if (!denied.has(MC_TOOLS.WRITE_FILE)) writeTools.push(`
|
|
75
|
+
**${MC_TOOLS.WRITE_FILE}** — Create new files or overwrite existing ones
|
|
76
|
+
- Use this to create new files.
|
|
77
|
+
- Overwriting replaces the whole file, so make sure you know its current contents first.
|
|
78
|
+
- Prefer editing existing files over creating new ones.`);
|
|
79
|
+
if (writeTools.length > 0) sections.push(writeTools.join("\n"));
|
|
80
|
+
}
|
|
81
|
+
if (options.hasWebSearch) {
|
|
82
|
+
const webTools = [];
|
|
83
|
+
if (!denied.has("web_search")) webTools.push("**web_search**");
|
|
84
|
+
if (options.hasWebExtract && !denied.has("web_extract")) webTools.push("**web_extract**");
|
|
85
|
+
if (webTools.length > 0) {
|
|
86
|
+
const purpose = webTools.length === 2 ? "Search the web / extract page content" : webTools[0] === "**web_search**" ? "Search the web" : "Extract page content";
|
|
87
|
+
sections.push(`
|
|
88
|
+
${webTools.join(" / ")} — ${purpose}
|
|
89
|
+
- Use for looking up documentation, error messages, package APIs.`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const taskTools = [];
|
|
93
|
+
const canUpdateTask = !denied.has("task_update");
|
|
94
|
+
const canCompleteTask = !denied.has("task_complete");
|
|
95
|
+
const canCheckTasks = !denied.has("task_check");
|
|
96
|
+
const canWriteTasks = !denied.has("task_write");
|
|
97
|
+
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.";
|
|
98
|
+
if (canWriteTasks) taskTools.push(`
|
|
99
|
+
**task_write** — Track tasks for complex multi-step work
|
|
100
|
+
- Use when a task requires 3 or more distinct steps or actions.
|
|
101
|
+
- Use task_write to create the initial task list or replace the whole list after replanning.
|
|
102
|
+
- Each task has: id (stable identifier), content (imperative form), status (pending, in_progress, or completed), activeForm (present continuous form shown during execution).
|
|
103
|
+
- Keep task IDs stable across updates. If you omit IDs, the tool result returns generated IDs.
|
|
104
|
+
${patchToolGuidance}
|
|
105
|
+
- Mark tasks \`in_progress\` BEFORE starting work. Only ONE task should be \`in_progress\` at a time.
|
|
106
|
+
- Mark tasks \`completed\` IMMEDIATELY after finishing each task. Do not batch completions.`);
|
|
107
|
+
if (canUpdateTask) taskTools.push(`
|
|
108
|
+
**task_update** — Patch one tracked task by ID
|
|
109
|
+
- Use this for targeted changes to one existing task.
|
|
110
|
+
- Provide the task ID and only the fields that changed: content, status, or activeForm.`);
|
|
111
|
+
if (canCompleteTask) {
|
|
112
|
+
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.";
|
|
113
|
+
taskTools.push(`
|
|
114
|
+
**task_complete** — Mark one tracked task completed by ID
|
|
115
|
+
- Use this immediately after finishing a tracked task.
|
|
116
|
+
- ${idSource}`);
|
|
117
|
+
}
|
|
118
|
+
if (canCheckTasks) taskTools.push(`
|
|
119
|
+
**task_check** — Check completion status of tasks
|
|
120
|
+
- Use this BEFORE finishing tracked work to verify all tasks are completed.
|
|
121
|
+
- Returns a readable status summary plus structured fields: tasks, summary, incompleteTasks, and isError.
|
|
122
|
+
- summary includes total, completed, inProgress, pending, incomplete, hasTasks, and allCompleted.
|
|
123
|
+
- Use summary.allCompleted to decide whether tracked work is complete; if summary.hasTasks is false, no task list is currently tracked.
|
|
124
|
+
- If any tasks remain incomplete, continue working on them.
|
|
125
|
+
- IMPORTANT: Always check task completion before ending work on a complex task.`);
|
|
126
|
+
if (!denied.has("ask_user")) taskTools.push(`
|
|
127
|
+
**ask_user** — Ask the user a structured question
|
|
128
|
+
- Use when you need clarification, want to validate assumptions, or need the user to make a decision.
|
|
129
|
+
- Provide clear, specific questions. End with a question mark.
|
|
130
|
+
- Include options (2-4 choices) for structured decisions. Omit options for open-ended questions.
|
|
131
|
+
- Don't use this for simple yes/no — just ask in your text response.`);
|
|
132
|
+
if (taskTools.length > 0) sections.push(taskTools.join("\n"));
|
|
133
|
+
if (modeId === "plan" && !denied.has("submit_plan")) sections.push(`
|
|
134
|
+
**submit_plan** — Submit a completed implementation plan for user review
|
|
135
|
+
- Call this tool when your plan is complete. Do NOT just describe your plan in text — you MUST call this tool.
|
|
136
|
+
- The plan will be rendered as markdown and the user can approve, reject, or request changes.
|
|
137
|
+
- On approval, the system automatically switches to the default mode so you can implement.
|
|
138
|
+
- Takes one argument: \`path\` (the plan markdown file you wrote under \`${plansDir}/\`). Do NOT pass the plan body — it lives in the file.`);
|
|
139
|
+
if (modeId !== "plan" && modeId !== "fast" && !denied.has("submit_plan")) {
|
|
140
|
+
const elsewhere = plansDir === DEFAULT_PLANS_DIR ? "" : `, never under \`${DEFAULT_PLANS_DIR}/\`. Plans anywhere else cannot be shown to the user`;
|
|
141
|
+
sections.push(`
|
|
142
|
+
**submit_plan** — Submit a plan for user review
|
|
143
|
+
- Write plan files under \`${plansDir}/\` (e.g. \`${plansDir}/add-dark-mode.md\`)${elsewhere}.
|
|
144
|
+
- Pass that file's \`path\` to \`submit_plan\`. Do NOT pass the plan body — it lives in the file.`);
|
|
145
|
+
}
|
|
146
|
+
if (modeId === "plan") sections.push(`
|
|
147
|
+
**Plan file access** — Your plan lives in a markdown file under \`${plansDir}/\` (e.g. \`add-dark-mode-toggle.md\`)
|
|
148
|
+
- Use \`write_file\` to create the plan file, \`view\` to read it, and \`string_replace_lsp\` for targeted edits.
|
|
149
|
+
- On first submission: write the plan to the file, then call \`submit_plan\` with its \`path\`.
|
|
150
|
+
- On revision: read the existing file, edit specific sections, re-read, then call \`submit_plan\` with the same \`path\`.
|
|
151
|
+
- If a plan file already exists, you previously submitted it — read it before revising.`);
|
|
152
|
+
if (options.hasSubagents !== false && !denied.has("subagent")) sections.push(`
|
|
153
|
+
**subagent** — Delegate a focused task to a specialized subagent
|
|
154
|
+
- Only use subagents when you will spawn **multiple subagents in parallel**. If you only need one task done, do it yourself.
|
|
155
|
+
- Subagent outputs are **untrusted**. Always review and verify the results.`);
|
|
156
|
+
return sections.join("\n");
|
|
157
|
+
}
|
|
158
|
+
export { buildToolGuidance };
|