@mastra/code-sdk 0.0.0-client-tool-results-20260912062135
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 +37 -0
- package/dist/acp/agent.d.ts +35 -0
- package/dist/acp/agent.d.ts.map +1 -0
- package/dist/acp/agent.js +161 -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 +214 -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 +65 -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 +35 -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 +2 -0
- package/dist/agents/context-audit.d.ts +84 -0
- package/dist/agents/context-audit.d.ts.map +1 -0
- package/dist/agents/context-audit.js +118 -0
- package/dist/agents/context-audit.js.map +1 -0
- package/dist/agents/credential-resolver.d.ts +63 -0
- package/dist/agents/credential-resolver.d.ts.map +1 -0
- package/dist/agents/credential-resolver.js +97 -0
- package/dist/agents/credential-resolver.js.map +1 -0
- package/dist/agents/custom-provider-source.d.ts +35 -0
- package/dist/agents/custom-provider-source.d.ts.map +1 -0
- package/dist/agents/custom-provider-source.js +25 -0
- package/dist/agents/custom-provider-source.js.map +1 -0
- package/dist/agents/instructions.d.ts +29 -0
- package/dist/agents/instructions.d.ts.map +1 -0
- package/dist/agents/instructions.js +58 -0
- package/dist/agents/instructions.js.map +1 -0
- package/dist/agents/mastracode-gateway.d.ts +74 -0
- package/dist/agents/mastracode-gateway.d.ts.map +1 -0
- package/dist/agents/mastracode-gateway.js +431 -0
- package/dist/agents/mastracode-gateway.js.map +1 -0
- package/dist/agents/memory.d.ts +30 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/memory.js +171 -0
- package/dist/agents/memory.js.map +1 -0
- package/dist/agents/model.d.ts +81 -0
- package/dist/agents/model.d.ts.map +1 -0
- package/dist/agents/model.js +155 -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 +49 -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 +42 -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 +42 -0
- package/dist/agents/modes/plan.js.map +1 -0
- package/dist/agents/prompts/agent-instructions.d.ts +70 -0
- package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
- package/dist/agents/prompts/agent-instructions.js +211 -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 +76 -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 +26 -0
- package/dist/agents/prompts/fast.js.map +1 -0
- package/dist/agents/prompts/index.d.ts +50 -0
- package/dist/agents/prompts/index.d.ts.map +1 -0
- package/dist/agents/prompts/index.js +119 -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 +23 -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 +111 -0
- package/dist/agents/prompts/plan.js.map +1 -0
- package/dist/agents/prompts/tool-guidance.d.ts +18 -0
- package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
- package/dist/agents/prompts/tool-guidance.js +180 -0
- package/dist/agents/prompts/tool-guidance.js.map +1 -0
- package/dist/agents/sandbox-filesystem.d.ts +117 -0
- package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
- package/dist/agents/sandbox-filesystem.js +356 -0
- package/dist/agents/sandbox-filesystem.js.map +1 -0
- package/dist/agents/subagents/execute.d.ts +3 -0
- package/dist/agents/subagents/execute.d.ts.map +1 -0
- package/dist/agents/subagents/execute.js +27 -0
- package/dist/agents/subagents/execute.js.map +1 -0
- package/dist/agents/subagents/explore.d.ts +3 -0
- package/dist/agents/subagents/explore.d.ts.map +1 -0
- package/dist/agents/subagents/explore.js +18 -0
- package/dist/agents/subagents/explore.js.map +1 -0
- package/dist/agents/subagents/plan.d.ts +3 -0
- package/dist/agents/subagents/plan.d.ts.map +1 -0
- package/dist/agents/subagents/plan.js +18 -0
- package/dist/agents/subagents/plan.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 +107 -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 +96 -0
- package/dist/agents/tool-availability.js.map +1 -0
- package/dist/agents/tools.d.ts +36 -0
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +117 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/agents/workflow-builder-agent.d.ts +2 -0
- package/dist/agents/workflow-builder-agent.d.ts.map +1 -0
- package/dist/agents/workflow-builder-agent.js +80 -0
- package/dist/agents/workflow-builder-agent.js.map +1 -0
- package/dist/agents/workspace.d.ts +32 -0
- package/dist/agents/workspace.d.ts.map +1 -0
- package/dist/agents/workspace.js +208 -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 +163 -0
- package/dist/analytics.js.map +1 -0
- package/dist/auth/authorization-input.d.ts +16 -0
- package/dist/auth/authorization-input.d.ts.map +1 -0
- package/dist/auth/authorization-input.js +42 -0
- package/dist/auth/authorization-input.js.map +1 -0
- package/dist/auth/device-code.d.ts +93 -0
- package/dist/auth/device-code.d.ts.map +1 -0
- package/dist/auth/device-code.js +129 -0
- package/dist/auth/device-code.js.map +1 -0
- package/dist/auth/index.d.ts +12 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +8 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +32 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/provider-auth-error.d.ts +12 -0
- package/dist/auth/provider-auth-error.d.ts.map +1 -0
- package/dist/auth/provider-auth-error.js +16 -0
- package/dist/auth/provider-auth-error.js.map +1 -0
- package/dist/auth/providers/anthropic.d.ts +40 -0
- package/dist/auth/providers/anthropic.d.ts.map +1 -0
- package/dist/auth/providers/anthropic.js +126 -0
- package/dist/auth/providers/anthropic.js.map +1 -0
- package/dist/auth/providers/github-copilot.d.ts +154 -0
- package/dist/auth/providers/github-copilot.d.ts.map +1 -0
- package/dist/auth/providers/github-copilot.js +340 -0
- package/dist/auth/providers/github-copilot.js.map +1 -0
- package/dist/auth/providers/kimi-coding.d.ts +38 -0
- package/dist/auth/providers/kimi-coding.d.ts.map +1 -0
- package/dist/auth/providers/kimi-coding.js +232 -0
- package/dist/auth/providers/kimi-coding.js.map +1 -0
- package/dist/auth/providers/openai-codex.d.ts +139 -0
- package/dist/auth/providers/openai-codex.d.ts.map +1 -0
- package/dist/auth/providers/openai-codex.js +519 -0
- package/dist/auth/providers/openai-codex.js.map +1 -0
- package/dist/auth/providers/xai.d.ts +64 -0
- package/dist/auth/providers/xai.d.ts.map +1 -0
- package/dist/auth/providers/xai.js +205 -0
- package/dist/auth/providers/xai.js.map +1 -0
- package/dist/auth/storage.d.ts +92 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +211 -0
- package/dist/auth/storage.js.map +1 -0
- package/dist/auth/types.d.ts +89 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.d.ts.map +1 -0
- package/dist/clipboard/index.js +226 -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 +18 -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 +22 -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 +161 -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 +5 -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 +73 -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 +259 -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 +60 -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 +3 -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 +347 -0
- package/dist/evals/scorers/outcome.js.map +1 -0
- package/dist/goal-manager.d.ts +78 -0
- package/dist/goal-manager.d.ts.map +1 -0
- package/dist/goal-manager.js +273 -0
- package/dist/goal-manager.js.map +1 -0
- package/dist/goal-signal.d.ts +14 -0
- package/dist/goal-signal.d.ts.map +1 -0
- package/dist/goal-signal.js +17 -0
- package/dist/goal-signal.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 +209 -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 +190 -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 +89 -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 +6 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.d.ts.map +1 -0
- package/dist/headless/policy.js +42 -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 +346 -0
- package/dist/headless/run-mc.js.map +1 -0
- package/dist/headless/types.d.ts +158 -0
- package/dist/headless/types.d.ts.map +1 -0
- package/dist/headless/types.js +19 -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 +73 -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 +129 -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 +5 -0
- package/dist/hooks/manager.d.ts +54 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +241 -0
- package/dist/hooks/manager.js.map +1 -0
- package/dist/hooks/types.d.ts +172 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +8 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +341 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +919 -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 +21 -0
- package/dist/ipc/ipc-reporter.js.map +1 -0
- package/dist/knowledge-inspector.d.ts +119 -0
- package/dist/knowledge-inspector.d.ts.map +1 -0
- package/dist/knowledge-inspector.js +508 -0
- package/dist/knowledge-inspector.js.map +1 -0
- package/dist/knowledge-scope.d.ts +35 -0
- package/dist/knowledge-scope.d.ts.map +1 -0
- package/dist/knowledge-scope.js +47 -0
- package/dist/knowledge-scope.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 +251 -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 +4 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.d.ts.map +1 -0
- package/dist/lsp/language.js +44 -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 +82 -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 +159 -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 +55 -0
- package/dist/lsp/workspace.js.map +1 -0
- package/dist/mcp/config.d.ts +62 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +301 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/manager.d.ts +101 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +644 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/state.d.ts +35 -0
- package/dist/mcp/state.d.ts.map +1 -0
- package/dist/mcp/state.js +97 -0
- package/dist/mcp/state.js.map +1 -0
- package/dist/mcp/types.d.ts +125 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +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 +17 -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 +30 -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 +3 -0
- package/dist/onboarding/om-settings.d.ts +25 -0
- package/dist/onboarding/om-settings.d.ts.map +1 -0
- package/dist/onboarding/om-settings.js +47 -0
- package/dist/onboarding/om-settings.js.map +1 -0
- package/dist/onboarding/packs.d.ts +49 -0
- package/dist/onboarding/packs.d.ts.map +1 -0
- package/dist/onboarding/packs.js +182 -0
- package/dist/onboarding/packs.js.map +1 -0
- package/dist/onboarding/settings.d.ts +438 -0
- package/dist/onboarding/settings.d.ts.map +1 -0
- package/dist/onboarding/settings.js +847 -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 +137 -0
- package/dist/permissions.js.map +1 -0
- package/dist/plugin.d.ts +144 -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 +88 -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 +190 -0
- package/dist/plugins/install.js.map +1 -0
- package/dist/plugins/loader.d.ts +19 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +258 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manager.d.ts +98 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +456 -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 +50 -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 +61 -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 +25 -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 +112 -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 +116 -0
- package/dist/plugins/scaffold.js.map +1 -0
- package/dist/plugins/signal-lane.d.ts +58 -0
- package/dist/plugins/signal-lane.d.ts.map +1 -0
- package/dist/plugins/signal-lane.js +166 -0
- package/dist/plugins/signal-lane.js.map +1 -0
- package/dist/plugins/types.d.ts +81 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +1 -0
- package/dist/process-memory-diagnostics.d.ts +135 -0
- package/dist/process-memory-diagnostics.d.ts.map +1 -0
- package/dist/process-memory-diagnostics.js +500 -0
- package/dist/process-memory-diagnostics.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 +54 -0
- package/dist/processors/plan-rejection-abort.js.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.js +153 -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 +102 -0
- package/dist/providers/amazon-bedrock.js.map +1 -0
- package/dist/providers/claude-max.d.ts +65 -0
- package/dist/providers/claude-max.d.ts.map +1 -0
- package/dist/providers/claude-max.js +252 -0
- package/dist/providers/claude-max.js.map +1 -0
- package/dist/providers/github-copilot.d.ts +60 -0
- package/dist/providers/github-copilot.d.ts.map +1 -0
- package/dist/providers/github-copilot.js +266 -0
- package/dist/providers/github-copilot.js.map +1 -0
- package/dist/providers/kimi-coding.d.ts +15 -0
- package/dist/providers/kimi-coding.d.ts.map +1 -0
- package/dist/providers/kimi-coding.js +69 -0
- package/dist/providers/kimi-coding.js.map +1 -0
- package/dist/providers/openai-codex.d.ts +73 -0
- package/dist/providers/openai-codex.d.ts.map +1 -0
- package/dist/providers/openai-codex.js +306 -0
- package/dist/providers/openai-codex.js.map +1 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.d.ts.map +1 -0
- package/dist/providers/xai.js +71 -0
- package/dist/providers/xai.js.map +1 -0
- package/dist/schema.d.ts +200 -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 +21 -0
- package/dist/theme-palette.js.map +1 -0
- package/dist/thinking.d.ts +33 -0
- package/dist/thinking.d.ts.map +1 -0
- package/dist/thinking.js +58 -0
- package/dist/thinking.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 +52 -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 +3 -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 +79 -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 +32 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/tools/web-search.d.ts +114 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +155 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/workflows/create-workflow.d.ts +7 -0
- package/dist/tools/workflows/create-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/create-workflow.js +81 -0
- package/dist/tools/workflows/create-workflow.js.map +1 -0
- package/dist/tools/workflows/delete-workflow.d.ts +7 -0
- package/dist/tools/workflows/delete-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/delete-workflow.js +21 -0
- package/dist/tools/workflows/delete-workflow.js.map +1 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts +7 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts.map +1 -0
- package/dist/tools/workflows/ephemeral-memory.js +45 -0
- package/dist/tools/workflows/ephemeral-memory.js.map +1 -0
- package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
- package/dist/tools/workflows/extract-json-schema.d.ts.map +1 -0
- package/dist/tools/workflows/extract-json-schema.js +22 -0
- package/dist/tools/workflows/extract-json-schema.js.map +1 -0
- package/dist/tools/workflows/get-workflow.d.ts +11 -0
- package/dist/tools/workflows/get-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/get-workflow.js +34 -0
- package/dist/tools/workflows/get-workflow.js.map +1 -0
- package/dist/tools/workflows/list-available-agents.d.ts +8 -0
- package/dist/tools/workflows/list-available-agents.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-agents.js +32 -0
- package/dist/tools/workflows/list-available-agents.js.map +1 -0
- package/dist/tools/workflows/list-available-tools.d.ts +9 -0
- package/dist/tools/workflows/list-available-tools.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-tools.js +40 -0
- package/dist/tools/workflows/list-available-tools.js.map +1 -0
- package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-available-workflows.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-workflows.js +32 -0
- package/dist/tools/workflows/list-available-workflows.js.map +1 -0
- package/dist/tools/workflows/list-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-workflows.d.ts.map +1 -0
- package/dist/tools/workflows/list-workflows.js +33 -0
- package/dist/tools/workflows/list-workflows.js.map +1 -0
- package/dist/tools/workflows/run-workflow.d.ts +9 -0
- package/dist/tools/workflows/run-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/run-workflow.js +52 -0
- package/dist/tools/workflows/run-workflow.js.map +1 -0
- package/dist/tools/workflows/save-workflow.d.ts +1015 -0
- package/dist/tools/workflows/save-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/save-workflow.js +28 -0
- package/dist/tools/workflows/save-workflow.js.map +1 -0
- package/dist/tools/workflows/tool-ids.d.ts +15 -0
- package/dist/tools/workflows/tool-ids.d.ts.map +1 -0
- package/dist/tools/workflows/tool-ids.js +19 -0
- package/dist/tools/workflows/tool-ids.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 +78 -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 +59 -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 +196 -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 +61 -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 +10 -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 +62 -0
- package/dist/utils/plan-diff.js.map +1 -0
- package/dist/utils/plans.d.ts +59 -0
- package/dist/utils/plans.d.ts.map +1 -0
- package/dist/utils/plans.js +117 -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 +364 -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 +122 -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 +142 -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 +109 -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 +96 -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 +121 -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 +274 -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 +112 -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 +101 -0
- package/dist/utils/update-check.d.ts.map +1 -0
- package/dist/utils/update-check.js +383 -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 +144 -0
- package/dist/voice/stt-registry.js.map +1 -0
- package/dist/workflows/register-primitives.d.ts +52 -0
- package/dist/workflows/register-primitives.d.ts.map +1 -0
- package/dist/workflows/register-primitives.js +40 -0
- package/dist/workflows/register-primitives.js.map +1 -0
- package/dist/workflows/service.d.ts +64 -0
- package/dist/workflows/service.d.ts.map +1 -0
- package/dist/workflows/service.js +53 -0
- package/dist/workflows/service.js.map +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { EXPLORE_MODE_AVAILABLE_TOOLS } from "../tool-availability.js";
|
|
2
|
+
//#region src/agents/modes/explore.ts
|
|
3
|
+
const fastMode = {
|
|
4
|
+
id: "fast",
|
|
5
|
+
name: "Explore",
|
|
6
|
+
description: "Read-only codebase exploration. Use for questions like 'find all usages of X', 'how does module Y work'.",
|
|
7
|
+
defaultModelId: "openai/gpt-5.4-mini",
|
|
8
|
+
instructions: `You are an expert code explorer. Your job is to investigate a codebase and answer a specific question or gather specific information.
|
|
9
|
+
|
|
10
|
+
## Rules
|
|
11
|
+
- You have READ-ONLY access. You cannot modify files or run commands.
|
|
12
|
+
- Be thorough — search broadly first, then drill into relevant files.
|
|
13
|
+
- After gathering enough information, produce a clear, concise summary of your findings.
|
|
14
|
+
|
|
15
|
+
## Tool Strategy
|
|
16
|
+
- **Start broad**: Use find_files (glob) to understand project structure
|
|
17
|
+
- **Search smart**: Use search_content (grep) with specific patterns — avoid overly broad searches
|
|
18
|
+
- **Read efficiently**: Use view with view_range for large files — don't read entire files if you only need a section
|
|
19
|
+
- **Parallelize**: Make multiple independent tool calls in one round when exploring different areas
|
|
20
|
+
|
|
21
|
+
## Efficiency
|
|
22
|
+
Your output returns to the parent agent. Be concise:
|
|
23
|
+
- Don't include raw file contents in your response — summarize what you found
|
|
24
|
+
- Reference files by path and line number, not by copying code
|
|
25
|
+
- If a search returns many results, report the count and key examples, not every match
|
|
26
|
+
|
|
27
|
+
## Output Format
|
|
28
|
+
End with a structured summary:
|
|
29
|
+
. **Answer**: Direct answer to the question (1-2 sentences)
|
|
30
|
+
. **Key Files**: Most relevant files with line numbers
|
|
31
|
+
. **Details**: Additional context if needed
|
|
32
|
+
|
|
33
|
+
Keep your summary under 300 words.
|
|
34
|
+
|
|
35
|
+
## Workflows
|
|
36
|
+
- You can use \`list-workflows\` and \`get-workflow\` to inspect saved workflows. You cannot create, run, or delete in this mode.`,
|
|
37
|
+
availableTools: [...EXPLORE_MODE_AVAILABLE_TOOLS]
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { fastMode };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=explore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explore.js","names":[],"sources":["../../../src/agents/modes/explore.ts"],"sourcesContent":["/**\n * Explore subagent — read-only codebase exploration.\n *\n * This subagent is given a focused task (e.g., \"find all usages of X\",\n * \"understand how module Y works\") and uses read-only tools to explore\n * the codebase, then returns a concise summary of its findings.\n */\nimport type { AgentControllerMode } from '@mastra/core/agent-controller';\nimport { EXPLORE_MODE_AVAILABLE_TOOLS } from '../tool-availability.js';\n\nexport const fastMode: AgentControllerMode = {\n id: 'fast',\n name: 'Explore',\n description:\n \"Read-only codebase exploration. Use for questions like 'find all usages of X', 'how does module Y work'.\",\n defaultModelId: 'openai/gpt-5.4-mini',\n instructions: `You are an expert code explorer. Your job is to investigate a codebase and answer a specific question or gather specific information.\n\n## Rules\n- You have READ-ONLY access. You cannot modify files or run commands.\n- Be thorough — search broadly first, then drill into relevant files.\n- After gathering enough information, produce a clear, concise summary of your findings.\n\n## Tool Strategy\n- **Start broad**: Use find_files (glob) to understand project structure\n- **Search smart**: Use search_content (grep) with specific patterns — avoid overly broad searches\n- **Read efficiently**: Use view with view_range for large files — don't read entire files if you only need a section\n- **Parallelize**: Make multiple independent tool calls in one round when exploring different areas\n\n## Efficiency\nYour output returns to the parent agent. Be concise:\n- Don't include raw file contents in your response — summarize what you found\n- Reference files by path and line number, not by copying code\n- If a search returns many results, report the count and key examples, not every match\n\n## Output Format\nEnd with a structured summary:\n. **Answer**: Direct answer to the question (1-2 sentences)\n. **Key Files**: Most relevant files with line numbers\n. **Details**: Additional context if needed\n\nKeep your summary under 300 words.\n\n## Workflows\n- You can use \\`list-workflows\\` and \\`get-workflow\\` to inspect saved workflows. You cannot create, run, or delete in this mode.`,\n\n availableTools: [...EXPLORE_MODE_AVAILABLE_TOOLS],\n};\n"],"mappings":";;AAUA,MAAa,WAAgC;CAC3C,IAAI;CACJ,MAAM;CACN,aACE;CACF,gBAAgB;CAChB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Bd,gBAAgB,CAAC,GAAG,4BAA4B;AAClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/modes/plan.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,eAAO,MAAM,QAAQ,EAAE,mBAwCtB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PLAN_MODE_AVAILABLE_TOOLS } from "../tool-availability.js";
|
|
2
|
+
//#region src/agents/modes/plan.ts
|
|
3
|
+
const planMode = {
|
|
4
|
+
id: "plan",
|
|
5
|
+
name: "Plan",
|
|
6
|
+
transitionsTo: "build",
|
|
7
|
+
defaultModelId: "openai/gpt-5.5",
|
|
8
|
+
description: "Read-only analysis and planning. Use for 'create an implementation plan for X', 'analyze the architecture of Y'.",
|
|
9
|
+
instructions: `You are an expert software architect and planner. Your job is to analyze a codebase and produce a detailed implementation plan for a given task.
|
|
10
|
+
|
|
11
|
+
## Rules
|
|
12
|
+
- You have READ-ONLY access to the project. You cannot modify project files or run commands.
|
|
13
|
+
- The one exception is plan files: you can create and edit markdown files inside the session-specific plan directory identified in your system prompt using \`write_file\`, \`view\`, and \`string_replace_lsp\`. You may not write anywhere else.
|
|
14
|
+
- First, explore the codebase to understand existing patterns, architecture, and conventions.
|
|
15
|
+
- Produce a concrete, actionable plan — not vague suggestions.
|
|
16
|
+
|
|
17
|
+
## Tool Strategy
|
|
18
|
+
- **Discover structure**: Use find_files (glob) to understand project layout and find relevant files
|
|
19
|
+
- **Find patterns**: Use search_content (grep) to locate existing implementations, imports, and conventions
|
|
20
|
+
- **Understand deeply**: Use view with view_range to read specific sections of key files
|
|
21
|
+
- **Parallelize**: Make multiple independent tool calls when exploring different areas
|
|
22
|
+
|
|
23
|
+
## Plan Delivery
|
|
24
|
+
- Write your plan to a markdown file in the session-specific plan directory identified in your system prompt using \`write_file\`, then call \`submit_plan({ path })\` with the path to that file (never the plan body).
|
|
25
|
+
- Start the file with a \`# Title\` heading describing the plan.
|
|
26
|
+
- Reuse the same file while iterating on the same plan; only create a new file for a genuinely different plan so each plan stays available to review.
|
|
27
|
+
- Do NOT output the plan as text — it MUST live in the plan file.
|
|
28
|
+
- Be concise: reference files by path and line number, don't include raw contents.
|
|
29
|
+
- Focus on actionable details, not general observations.
|
|
30
|
+
- To revise after "Request changes", edit the same file in place with \`string_replace_lsp\`, and call \`submit_plan\` again with the same path.
|
|
31
|
+
|
|
32
|
+
## Workflows
|
|
33
|
+
- You can INSPECT saved workflows via \`list-workflows\` and \`get-workflow\`.
|
|
34
|
+
- You CANNOT build, run, or delete workflows in this mode.
|
|
35
|
+
- If the user asks for a workflow design, include it in the implementation plan stored at the session-specific plan path, then call \`submit_plan({ path })\` as required above. After approval, build mode can save and run it.`,
|
|
36
|
+
metadata: { default: false },
|
|
37
|
+
availableTools: [...PLAN_MODE_AVAILABLE_TOOLS]
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { planMode };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","names":[],"sources":["../../../src/agents/modes/plan.ts"],"sourcesContent":["/**\n * Plan mode — read-only analysis and planning.\n */\nimport type { AgentControllerMode } from '@mastra/core/agent-controller';\nimport { PLAN_MODE_AVAILABLE_TOOLS } from '../tool-availability.js';\n\nexport const planMode: AgentControllerMode = {\n id: 'plan',\n name: 'Plan',\n transitionsTo: 'build',\n defaultModelId: 'openai/gpt-5.5',\n description:\n \"Read-only analysis and planning. Use for 'create an implementation plan for X', 'analyze the architecture of Y'.\",\n instructions: `You are an expert software architect and planner. Your job is to analyze a codebase and produce a detailed implementation plan for a given task.\n\n## Rules\n- You have READ-ONLY access to the project. You cannot modify project files or run commands.\n- The one exception is plan files: you can create and edit markdown files inside the session-specific plan directory identified in your system prompt using \\`write_file\\`, \\`view\\`, and \\`string_replace_lsp\\`. You may not write anywhere else.\n- First, explore the codebase to understand existing patterns, architecture, and conventions.\n- Produce a concrete, actionable plan — not vague suggestions.\n\n## Tool Strategy\n- **Discover structure**: Use find_files (glob) to understand project layout and find relevant files\n- **Find patterns**: Use search_content (grep) to locate existing implementations, imports, and conventions\n- **Understand deeply**: Use view with view_range to read specific sections of key files\n- **Parallelize**: Make multiple independent tool calls when exploring different areas\n\n## Plan Delivery\n- Write your plan to a markdown file in the session-specific plan directory identified in your system prompt using \\`write_file\\`, then call \\`submit_plan({ path })\\` with the path to that file (never the plan body).\n- Start the file with a \\`# Title\\` heading describing the plan.\n- Reuse the same file while iterating on the same plan; only create a new file for a genuinely different plan so each plan stays available to review.\n- Do NOT output the plan as text — it MUST live in the plan file.\n- Be concise: reference files by path and line number, don't include raw contents.\n- Focus on actionable details, not general observations.\n- To revise after \"Request changes\", edit the same file in place with \\`string_replace_lsp\\`, and call \\`submit_plan\\` again with the same path.\n\n## Workflows\n- You can INSPECT saved workflows via \\`list-workflows\\` and \\`get-workflow\\`.\n- You CANNOT build, run, or delete workflows in this mode.\n- If the user asks for a workflow design, include it in the implementation plan stored at the session-specific plan path, then call \\`submit_plan({ path })\\` as required above. After approval, build mode can save and run it.`,\n\n metadata: {\n default: false,\n },\n\n availableTools: [...PLAN_MODE_AVAILABLE_TOOLS],\n};\n"],"mappings":";;AAMA,MAAa,WAAgC;CAC3C,IAAI;CACJ,MAAM;CACN,eAAe;CACf,gBAAgB;CAChB,aACE;CACF,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Bd,UAAU,EACR,SAAS,MACX;CAEA,gBAAgB,CAAC,GAAG,yBAAyB;AAC/C"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load project and global agent instruction files (AGENTS.md, CLAUDE.md).
|
|
3
|
+
* Prefers AGENTS.md over CLAUDE.md when multiple exist at the same location.
|
|
4
|
+
*/
|
|
5
|
+
export interface InstructionSource {
|
|
6
|
+
path: string;
|
|
7
|
+
content: string;
|
|
8
|
+
scope: 'global' | 'project';
|
|
9
|
+
/** Git ref the content was read from, when not read off the working tree. */
|
|
10
|
+
ref?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reads project-scope instruction files. The default implementation reads the
|
|
14
|
+
* working tree via `fs`; alternative readers can serve content from another
|
|
15
|
+
* source (e.g. a trusted git ref) while keeping working-tree paths as the
|
|
16
|
+
* addressing scheme.
|
|
17
|
+
*/
|
|
18
|
+
export interface InstructionFileReader {
|
|
19
|
+
exists(path: string): boolean;
|
|
20
|
+
read(path: string): string;
|
|
21
|
+
/** Git ref backing this reader, recorded on the loaded sources. */
|
|
22
|
+
ref?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a reader that serves instruction files from a git ref instead of the
|
|
26
|
+
* working tree. Paths are still addressed as working-tree paths under
|
|
27
|
+
* `projectPath`; content comes from `git show <ref>:<relpath>` so an untrusted
|
|
28
|
+
* checkout (e.g. a PR branch under review) cannot influence what is loaded.
|
|
29
|
+
* Tries `origin/<ref>` first (remote truth), then the local ref. Any git
|
|
30
|
+
* failure (missing ref, missing file, no repo) reports the file as absent.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createGitRefInstructionReader(projectPath: string, ref: string): InstructionFileReader;
|
|
33
|
+
/**
|
|
34
|
+
* Reader for the reactive reminder channel (AgentsMDInjector) that serves
|
|
35
|
+
* paths under `projectPath` from a trusted git ref. Paths outside the project
|
|
36
|
+
* fall back to the operator machine's filesystem (those are trusted); paths
|
|
37
|
+
* inside the project are only ever resolved against the ref, never the
|
|
38
|
+
* working tree, so an untrusted checkout cannot feed content in.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createGitRefReminderReader(projectPath: string, ref: string): {
|
|
41
|
+
pathExists: (path: string) => boolean;
|
|
42
|
+
isDirectory: (path: string) => boolean;
|
|
43
|
+
readFile: (path: string) => string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Load all agent instruction files from global and project locations.
|
|
47
|
+
* Returns an array of instruction sources, with global ones first.
|
|
48
|
+
*
|
|
49
|
+
* `projectReader` controls where project-scope content comes from (defaults to
|
|
50
|
+
* the working tree). Global instructions read the operator machine's
|
|
51
|
+
* filesystem, unless `skipGlobal` keeps them out entirely.
|
|
52
|
+
*/
|
|
53
|
+
export declare function loadAgentInstructions(projectPath: string, configDirName?: string, projectReader?: InstructionFileReader, { skipGlobal }?: {
|
|
54
|
+
skipGlobal?: boolean;
|
|
55
|
+
}): InstructionSource[];
|
|
56
|
+
export declare function getStaticallyLoadedInstructionPaths(projectPath: string, configDirName?: string, projectReader?: InstructionFileReader): string[];
|
|
57
|
+
/** Heading the agent-instructions block is introduced by in the system prompt. */
|
|
58
|
+
export declare const AGENT_INSTRUCTIONS_HEADING = "# Agent Instructions";
|
|
59
|
+
/**
|
|
60
|
+
* Format a single instruction source as it appears in the system prompt.
|
|
61
|
+
*
|
|
62
|
+
* Exported so callers that attribute prompt cost per source (the `/context`
|
|
63
|
+
* audit) measure the exact block that is sent rather than reconstructing it.
|
|
64
|
+
*/
|
|
65
|
+
export declare function formatInstructionSource(source: InstructionSource): string;
|
|
66
|
+
/**
|
|
67
|
+
* Format loaded instructions into a string for the system prompt.
|
|
68
|
+
*/
|
|
69
|
+
export declare function formatAgentInstructions(sources: InstructionSource[]): string;
|
|
70
|
+
//# sourceMappingURL=agent-instructions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-instructions.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/agent-instructions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoBH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,6EAA6E;IAC7E,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,mEAAmE;IACnE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAOD;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,qBAAqB,CA+BrG;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,GACV;IACD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC,CA4CA;AAgBD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,aAAa,SAAqB,EAClC,aAAa,GAAE,qBAA2C,EAC1D,EAAE,UAAkB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACpD,iBAAiB,EAAE,CAwDrB;AAED,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,MAAM,EACnB,aAAa,SAAqB,EAClC,aAAa,CAAC,EAAE,qBAAqB,GACpC,MAAM,EAAE,CAEV;AAED,kFAAkF;AAClF,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AAEjE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAIzE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAM5E"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { DEFAULT_CONFIG_DIR } from "../../constants.js";
|
|
2
|
+
import { existsSync, readFileSync, statSync } from "fs";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { isAbsolute, join, normalize, relative, sep } from "path";
|
|
5
|
+
import { execFileSync } from "child_process";
|
|
6
|
+
//#region src/agents/prompts/agent-instructions.ts
|
|
7
|
+
/**
|
|
8
|
+
* Load project and global agent instruction files (AGENTS.md, CLAUDE.md).
|
|
9
|
+
* Prefers AGENTS.md over CLAUDE.md when multiple exist at the same location.
|
|
10
|
+
*/
|
|
11
|
+
const INSTRUCTION_FILES = ["AGENTS.md", "CLAUDE.md"];
|
|
12
|
+
const PROJECT_LOCATIONS = [
|
|
13
|
+
"",
|
|
14
|
+
".claude",
|
|
15
|
+
".mastracode"
|
|
16
|
+
];
|
|
17
|
+
const GLOBAL_LOCATIONS = [
|
|
18
|
+
".claude",
|
|
19
|
+
".mastracode",
|
|
20
|
+
".config/claude",
|
|
21
|
+
".config/mastracode"
|
|
22
|
+
];
|
|
23
|
+
const fsInstructionReader = {
|
|
24
|
+
exists: (path) => existsSync(path),
|
|
25
|
+
read: (path) => readFileSync(path, "utf-8")
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Create a reader that serves instruction files from a git ref instead of the
|
|
29
|
+
* working tree. Paths are still addressed as working-tree paths under
|
|
30
|
+
* `projectPath`; content comes from `git show <ref>:<relpath>` so an untrusted
|
|
31
|
+
* checkout (e.g. a PR branch under review) cannot influence what is loaded.
|
|
32
|
+
* Tries `origin/<ref>` first (remote truth), then the local ref. Any git
|
|
33
|
+
* failure (missing ref, missing file, no repo) reports the file as absent.
|
|
34
|
+
*/
|
|
35
|
+
function createGitRefInstructionReader(projectPath, ref) {
|
|
36
|
+
const toRelative = (path) => {
|
|
37
|
+
const rel = relative(projectPath, path);
|
|
38
|
+
if (!rel || rel.startsWith("..") || isAbsolute(rel)) return null;
|
|
39
|
+
return rel.split(sep).join("/");
|
|
40
|
+
};
|
|
41
|
+
const show = (path) => {
|
|
42
|
+
const rel = toRelative(path);
|
|
43
|
+
if (rel === null) return null;
|
|
44
|
+
for (const candidate of [`origin/${ref}`, ref]) try {
|
|
45
|
+
return execFileSync("git", [
|
|
46
|
+
"-C",
|
|
47
|
+
projectPath,
|
|
48
|
+
"show",
|
|
49
|
+
`${candidate}:${rel}`
|
|
50
|
+
], {
|
|
51
|
+
encoding: "utf-8",
|
|
52
|
+
stdio: [
|
|
53
|
+
"ignore",
|
|
54
|
+
"pipe",
|
|
55
|
+
"ignore"
|
|
56
|
+
],
|
|
57
|
+
maxBuffer: 1024 * 1024
|
|
58
|
+
});
|
|
59
|
+
} catch {}
|
|
60
|
+
return null;
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
ref,
|
|
64
|
+
exists: (path) => show(path) !== null,
|
|
65
|
+
read: (path) => {
|
|
66
|
+
const content = show(path);
|
|
67
|
+
if (content === null) throw new Error(`Not found at ref ${ref}: ${path}`);
|
|
68
|
+
return content;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Reader for the reactive reminder channel (AgentsMDInjector) that serves
|
|
74
|
+
* paths under `projectPath` from a trusted git ref. Paths outside the project
|
|
75
|
+
* fall back to the operator machine's filesystem (those are trusted); paths
|
|
76
|
+
* inside the project are only ever resolved against the ref, never the
|
|
77
|
+
* working tree, so an untrusted checkout cannot feed content in.
|
|
78
|
+
*/
|
|
79
|
+
function createGitRefReminderReader(projectPath, ref) {
|
|
80
|
+
const gitReader = createGitRefInstructionReader(projectPath, ref);
|
|
81
|
+
const toRelative = (path) => {
|
|
82
|
+
const rel = relative(projectPath, normalize(path));
|
|
83
|
+
if (rel.startsWith("..") || isAbsolute(rel)) return null;
|
|
84
|
+
return rel.split(sep).join("/");
|
|
85
|
+
};
|
|
86
|
+
const objectType = (rel) => {
|
|
87
|
+
if (rel === "") return "tree";
|
|
88
|
+
for (const candidate of [`origin/${ref}`, ref]) try {
|
|
89
|
+
return execFileSync("git", [
|
|
90
|
+
"-C",
|
|
91
|
+
projectPath,
|
|
92
|
+
"cat-file",
|
|
93
|
+
"-t",
|
|
94
|
+
`${candidate}:${rel}`
|
|
95
|
+
], {
|
|
96
|
+
encoding: "utf-8",
|
|
97
|
+
stdio: [
|
|
98
|
+
"ignore",
|
|
99
|
+
"pipe",
|
|
100
|
+
"ignore"
|
|
101
|
+
]
|
|
102
|
+
}).trim();
|
|
103
|
+
} catch {}
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
pathExists: (path) => {
|
|
108
|
+
const rel = toRelative(path);
|
|
109
|
+
if (rel === null) return existsSync(path);
|
|
110
|
+
return objectType(rel) !== null;
|
|
111
|
+
},
|
|
112
|
+
isDirectory: (path) => {
|
|
113
|
+
const rel = toRelative(path);
|
|
114
|
+
if (rel === null) try {
|
|
115
|
+
return statSync(path).isDirectory();
|
|
116
|
+
} catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return objectType(rel) === "tree";
|
|
120
|
+
},
|
|
121
|
+
readFile: (path) => {
|
|
122
|
+
if (toRelative(path) === null) return readFileSync(path, "utf-8");
|
|
123
|
+
return gitReader.read(path);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Find the first existing instruction file at a given base path.
|
|
129
|
+
* Prefers AGENTS.md over CLAUDE.md.
|
|
130
|
+
*/
|
|
131
|
+
function findInstructionFile(basePath, reader = fsInstructionReader) {
|
|
132
|
+
for (const filename of INSTRUCTION_FILES) {
|
|
133
|
+
const fullPath = join(basePath, filename);
|
|
134
|
+
if (reader.exists(fullPath)) return fullPath;
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Load all agent instruction files from global and project locations.
|
|
140
|
+
* Returns an array of instruction sources, with global ones first.
|
|
141
|
+
*
|
|
142
|
+
* `projectReader` controls where project-scope content comes from (defaults to
|
|
143
|
+
* the working tree). Global instructions read the operator machine's
|
|
144
|
+
* filesystem, unless `skipGlobal` keeps them out entirely.
|
|
145
|
+
*/
|
|
146
|
+
function loadAgentInstructions(projectPath, configDirName = DEFAULT_CONFIG_DIR, projectReader = fsInstructionReader, { skipGlobal = false } = {}) {
|
|
147
|
+
const sources = [];
|
|
148
|
+
const home = homedir();
|
|
149
|
+
const projectLocations = PROJECT_LOCATIONS.map((loc) => loc === ".mastracode" ? configDirName : loc);
|
|
150
|
+
const globalLocations = skipGlobal ? [] : GLOBAL_LOCATIONS.map((loc) => {
|
|
151
|
+
if (loc === ".mastracode") return configDirName;
|
|
152
|
+
if (loc === ".config/mastracode") return ".config/" + configDirName.replace(/^\./, "");
|
|
153
|
+
return loc;
|
|
154
|
+
});
|
|
155
|
+
for (const location of globalLocations) {
|
|
156
|
+
const filePath = findInstructionFile(join(home, location));
|
|
157
|
+
if (filePath) try {
|
|
158
|
+
const content = readFileSync(filePath, "utf-8").trim();
|
|
159
|
+
if (content) {
|
|
160
|
+
sources.push({
|
|
161
|
+
path: filePath,
|
|
162
|
+
content,
|
|
163
|
+
scope: "global"
|
|
164
|
+
});
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
} catch {}
|
|
168
|
+
}
|
|
169
|
+
for (const location of projectLocations) {
|
|
170
|
+
const filePath = findInstructionFile(location ? join(projectPath, location) : projectPath, projectReader);
|
|
171
|
+
if (filePath) try {
|
|
172
|
+
const content = projectReader.read(filePath).trim();
|
|
173
|
+
if (content) {
|
|
174
|
+
sources.push({
|
|
175
|
+
path: filePath,
|
|
176
|
+
content,
|
|
177
|
+
scope: "project",
|
|
178
|
+
...projectReader.ref ? { ref: projectReader.ref } : {}
|
|
179
|
+
});
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
} catch {}
|
|
183
|
+
}
|
|
184
|
+
return sources;
|
|
185
|
+
}
|
|
186
|
+
function getStaticallyLoadedInstructionPaths(projectPath, configDirName = DEFAULT_CONFIG_DIR, projectReader) {
|
|
187
|
+
return loadAgentInstructions(projectPath, configDirName, projectReader).map((source) => normalize(source.path));
|
|
188
|
+
}
|
|
189
|
+
/** Heading the agent-instructions block is introduced by in the system prompt. */
|
|
190
|
+
const AGENT_INSTRUCTIONS_HEADING = "# Agent Instructions";
|
|
191
|
+
/**
|
|
192
|
+
* Format a single instruction source as it appears in the system prompt.
|
|
193
|
+
*
|
|
194
|
+
* Exported so callers that attribute prompt cost per source (the `/context`
|
|
195
|
+
* audit) measure the exact block that is sent rather than reconstructing it.
|
|
196
|
+
*/
|
|
197
|
+
function formatInstructionSource(source) {
|
|
198
|
+
return `<!-- ${source.scope === "global" ? "Global" : "Project"} instructions from ${source.ref ? `${source.path} (at ref ${source.ref})` : source.path} -->\n${source.content}`;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Format loaded instructions into a string for the system prompt.
|
|
202
|
+
*/
|
|
203
|
+
function formatAgentInstructions(sources) {
|
|
204
|
+
if (sources.length === 0) return "";
|
|
205
|
+
const sections = sources.map(formatInstructionSource);
|
|
206
|
+
return `\n${AGENT_INSTRUCTIONS_HEADING}\n\n${sections.join("\n\n")}\n`;
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
export { AGENT_INSTRUCTIONS_HEADING, createGitRefInstructionReader, createGitRefReminderReader, formatAgentInstructions, formatInstructionSource, getStaticallyLoadedInstructionPaths, loadAgentInstructions };
|
|
210
|
+
|
|
211
|
+
//# sourceMappingURL=agent-instructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-instructions.js","names":[],"sources":["../../../src/agents/prompts/agent-instructions.ts"],"sourcesContent":["/**\n * Load project and global agent instruction files (AGENTS.md, CLAUDE.md).\n * Prefers AGENTS.md over CLAUDE.md when multiple exist at the same location.\n */\n\nimport { execFileSync } from 'node:child_process';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { isAbsolute, join, normalize, relative, sep } from 'node:path';\nimport { DEFAULT_CONFIG_DIR } from '../../constants.js';\n\n// Filenames to check, in order of preference\nconst INSTRUCTION_FILES = ['AGENTS.md', 'CLAUDE.md'];\n\n// Locations to scan (relative to project root or home)\nconst PROJECT_LOCATIONS = [\n '', // project root\n '.claude',\n '.mastracode',\n];\n\nconst GLOBAL_LOCATIONS = ['.claude', '.mastracode', '.config/claude', '.config/mastracode'];\n\nexport interface InstructionSource {\n path: string;\n content: string;\n scope: 'global' | 'project';\n /** Git ref the content was read from, when not read off the working tree. */\n ref?: string;\n}\n\n/**\n * Reads project-scope instruction files. The default implementation reads the\n * working tree via `fs`; alternative readers can serve content from another\n * source (e.g. a trusted git ref) while keeping working-tree paths as the\n * addressing scheme.\n */\nexport interface InstructionFileReader {\n exists(path: string): boolean;\n read(path: string): string;\n /** Git ref backing this reader, recorded on the loaded sources. */\n ref?: string;\n}\n\nconst fsInstructionReader: InstructionFileReader = {\n exists: path => existsSync(path),\n read: path => readFileSync(path, 'utf-8'),\n};\n\n/**\n * Create a reader that serves instruction files from a git ref instead of the\n * working tree. Paths are still addressed as working-tree paths under\n * `projectPath`; content comes from `git show <ref>:<relpath>` so an untrusted\n * checkout (e.g. a PR branch under review) cannot influence what is loaded.\n * Tries `origin/<ref>` first (remote truth), then the local ref. Any git\n * failure (missing ref, missing file, no repo) reports the file as absent.\n */\nexport function createGitRefInstructionReader(projectPath: string, ref: string): InstructionFileReader {\n const toRelative = (path: string): string | null => {\n const rel = relative(projectPath, path);\n if (!rel || rel.startsWith('..') || isAbsolute(rel)) return null;\n return rel.split(sep).join('/');\n };\n const show = (path: string): string | null => {\n const rel = toRelative(path);\n if (rel === null) return null;\n for (const candidate of [`origin/${ref}`, ref]) {\n try {\n return execFileSync('git', ['-C', projectPath, 'show', `${candidate}:${rel}`], {\n encoding: 'utf-8',\n stdio: ['ignore', 'pipe', 'ignore'],\n maxBuffer: 1024 * 1024,\n });\n } catch {\n // Ref or file missing at this candidate — try the next one.\n }\n }\n return null;\n };\n return {\n ref,\n exists: path => show(path) !== null,\n read: path => {\n const content = show(path);\n if (content === null) throw new Error(`Not found at ref ${ref}: ${path}`);\n return content;\n },\n };\n}\n\n/**\n * Reader for the reactive reminder channel (AgentsMDInjector) that serves\n * paths under `projectPath` from a trusted git ref. Paths outside the project\n * fall back to the operator machine's filesystem (those are trusted); paths\n * inside the project are only ever resolved against the ref, never the\n * working tree, so an untrusted checkout cannot feed content in.\n */\nexport function createGitRefReminderReader(\n projectPath: string,\n ref: string,\n): {\n pathExists: (path: string) => boolean;\n isDirectory: (path: string) => boolean;\n readFile: (path: string) => string;\n} {\n const gitReader = createGitRefInstructionReader(projectPath, ref);\n const toRelative = (path: string): string | null => {\n const rel = relative(projectPath, normalize(path));\n if (rel.startsWith('..') || isAbsolute(rel)) return null;\n return rel.split(sep).join('/');\n };\n const objectType = (rel: string): string | null => {\n if (rel === '') return 'tree'; // project root\n for (const candidate of [`origin/${ref}`, ref]) {\n try {\n return execFileSync('git', ['-C', projectPath, 'cat-file', '-t', `${candidate}:${rel}`], {\n encoding: 'utf-8',\n stdio: ['ignore', 'pipe', 'ignore'],\n }).trim();\n } catch {\n // Ref or object missing at this candidate — try the next one.\n }\n }\n return null;\n };\n return {\n pathExists: path => {\n const rel = toRelative(path);\n if (rel === null) return existsSync(path);\n return objectType(rel) !== null;\n },\n isDirectory: path => {\n const rel = toRelative(path);\n if (rel === null) {\n try {\n return statSync(path).isDirectory();\n } catch {\n return false;\n }\n }\n return objectType(rel) === 'tree';\n },\n readFile: path => {\n const rel = toRelative(path);\n if (rel === null) return readFileSync(path, 'utf-8');\n return gitReader.read(path);\n },\n };\n}\n\n/**\n * Find the first existing instruction file at a given base path.\n * Prefers AGENTS.md over CLAUDE.md.\n */\nfunction findInstructionFile(basePath: string, reader: InstructionFileReader = fsInstructionReader): string | null {\n for (const filename of INSTRUCTION_FILES) {\n const fullPath = join(basePath, filename);\n if (reader.exists(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\n/**\n * Load all agent instruction files from global and project locations.\n * Returns an array of instruction sources, with global ones first.\n *\n * `projectReader` controls where project-scope content comes from (defaults to\n * the working tree). Global instructions read the operator machine's\n * filesystem, unless `skipGlobal` keeps them out entirely.\n */\nexport function loadAgentInstructions(\n projectPath: string,\n configDirName = DEFAULT_CONFIG_DIR,\n projectReader: InstructionFileReader = fsInstructionReader,\n { skipGlobal = false }: { skipGlobal?: boolean } = {},\n): InstructionSource[] {\n const sources: InstructionSource[] = [];\n const home = homedir();\n\n // Derive location arrays from the base constants, substituting the config dir name\n const projectLocations = PROJECT_LOCATIONS.map(loc => (loc === '.mastracode' ? configDirName : loc));\n const globalLocations = skipGlobal\n ? []\n : GLOBAL_LOCATIONS.map(loc => {\n if (loc === '.mastracode') return configDirName;\n // XDG-style path (~/.config/<name>): strip the leading dot since the\n // .config/ prefix already signals a hidden/config directory.\n if (loc === '.config/mastracode') return '.config/' + configDirName.replace(/^\\./, '');\n return loc;\n });\n\n // Load global instructions first\n for (const location of globalLocations) {\n const basePath = join(home, location);\n const filePath = findInstructionFile(basePath);\n if (filePath) {\n try {\n const content = readFileSync(filePath, 'utf-8').trim();\n if (content) {\n sources.push({ path: filePath, content, scope: 'global' });\n break; // Only use first found global instruction file\n }\n } catch {\n // Skip unreadable files\n }\n }\n }\n\n // Load project instructions\n for (const location of projectLocations) {\n const basePath = location ? join(projectPath, location) : projectPath;\n const filePath = findInstructionFile(basePath, projectReader);\n if (filePath) {\n try {\n const content = projectReader.read(filePath).trim();\n if (content) {\n sources.push({\n path: filePath,\n content,\n scope: 'project',\n ...(projectReader.ref ? { ref: projectReader.ref } : {}),\n });\n break; // Only use first found project instruction file\n }\n } catch {\n // Skip unreadable files\n }\n }\n }\n\n return sources;\n}\n\nexport function getStaticallyLoadedInstructionPaths(\n projectPath: string,\n configDirName = DEFAULT_CONFIG_DIR,\n projectReader?: InstructionFileReader,\n): string[] {\n return loadAgentInstructions(projectPath, configDirName, projectReader).map(source => normalize(source.path));\n}\n\n/** Heading the agent-instructions block is introduced by in the system prompt. */\nexport const AGENT_INSTRUCTIONS_HEADING = '# Agent Instructions';\n\n/**\n * Format a single instruction source as it appears in the system prompt.\n *\n * Exported so callers that attribute prompt cost per source (the `/context`\n * audit) measure the exact block that is sent rather than reconstructing it.\n */\nexport function formatInstructionSource(source: InstructionSource): string {\n const label = source.scope === 'global' ? 'Global' : 'Project';\n const origin = source.ref ? `${source.path} (at ref ${source.ref})` : source.path;\n return `<!-- ${label} instructions from ${origin} -->\\n${source.content}`;\n}\n\n/**\n * Format loaded instructions into a string for the system prompt.\n */\nexport function formatAgentInstructions(sources: InstructionSource[]): string {\n if (sources.length === 0) return '';\n\n const sections = sources.map(formatInstructionSource);\n\n return `\\n${AGENT_INSTRUCTIONS_HEADING}\\n\\n${sections.join('\\n\\n')}\\n`;\n}\n"],"mappings":";;;;;;;;;;AAYA,MAAM,oBAAoB,CAAC,aAAa,WAAW;AAGnD,MAAM,oBAAoB;CACxB;CACA;CACA;AACF;AAEA,MAAM,mBAAmB;CAAC;CAAW;CAAe;CAAkB;AAAoB;AAuB1F,MAAM,sBAA6C;CACjD,SAAQ,SAAQ,WAAW,IAAI;CAC/B,OAAM,SAAQ,aAAa,MAAM,OAAO;AAC1C;;;;;;;;;AAUA,SAAgB,8BAA8B,aAAqB,KAAoC;CACrG,MAAM,cAAc,SAAgC;EAClD,MAAM,MAAM,SAAS,aAAa,IAAI;EACtC,IAAI,CAAC,OAAO,IAAI,WAAW,IAAI,KAAK,WAAW,GAAG,GAAG,OAAO;EAC5D,OAAO,IAAI,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;CAChC;CACA,MAAM,QAAQ,SAAgC;EAC5C,MAAM,MAAM,WAAW,IAAI;EAC3B,IAAI,QAAQ,MAAM,OAAO;EACzB,KAAK,MAAM,aAAa,CAAC,UAAU,OAAO,GAAG,GAC3C,IAAI;GACF,OAAO,aAAa,OAAO;IAAC;IAAM;IAAa;IAAQ,GAAG,UAAU,GAAG;GAAK,GAAG;IAC7E,UAAU;IACV,OAAO;KAAC;KAAU;KAAQ;IAAQ;IAClC,WAAW,OAAO;GACpB,CAAC;EACH,QAAQ,CAER;EAEF,OAAO;CACT;CACA,OAAO;EACL;EACA,SAAQ,SAAQ,KAAK,IAAI,MAAM;EAC/B,OAAM,SAAQ;GACZ,MAAM,UAAU,KAAK,IAAI;GACzB,IAAI,YAAY,MAAM,MAAM,IAAI,MAAM,oBAAoB,IAAI,IAAI,MAAM;GACxE,OAAO;EACT;CACF;AACF;;;;;;;;AASA,SAAgB,2BACd,aACA,KAKA;CACA,MAAM,YAAY,8BAA8B,aAAa,GAAG;CAChE,MAAM,cAAc,SAAgC;EAClD,MAAM,MAAM,SAAS,aAAa,UAAU,IAAI,CAAC;EACjD,IAAI,IAAI,WAAW,IAAI,KAAK,WAAW,GAAG,GAAG,OAAO;EACpD,OAAO,IAAI,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;CAChC;CACA,MAAM,cAAc,QAA+B;EACjD,IAAI,QAAQ,IAAI,OAAO;EACvB,KAAK,MAAM,aAAa,CAAC,UAAU,OAAO,GAAG,GAC3C,IAAI;GACF,OAAO,aAAa,OAAO;IAAC;IAAM;IAAa;IAAY;IAAM,GAAG,UAAU,GAAG;GAAK,GAAG;IACvF,UAAU;IACV,OAAO;KAAC;KAAU;KAAQ;IAAQ;GACpC,CAAC,CAAC,CAAC,KAAK;EACV,QAAQ,CAER;EAEF,OAAO;CACT;CACA,OAAO;EACL,aAAY,SAAQ;GAClB,MAAM,MAAM,WAAW,IAAI;GAC3B,IAAI,QAAQ,MAAM,OAAO,WAAW,IAAI;GACxC,OAAO,WAAW,GAAG,MAAM;EAC7B;EACA,cAAa,SAAQ;GACnB,MAAM,MAAM,WAAW,IAAI;GAC3B,IAAI,QAAQ,MACV,IAAI;IACF,OAAO,SAAS,IAAI,CAAC,CAAC,YAAY;GACpC,QAAQ;IACN,OAAO;GACT;GAEF,OAAO,WAAW,GAAG,MAAM;EAC7B;EACA,WAAU,SAAQ;GAEhB,IADY,WAAW,IACjB,MAAM,MAAM,OAAO,aAAa,MAAM,OAAO;GACnD,OAAO,UAAU,KAAK,IAAI;EAC5B;CACF;AACF;;;;;AAMA,SAAS,oBAAoB,UAAkB,SAAgC,qBAAoC;CACjH,KAAK,MAAM,YAAY,mBAAmB;EACxC,MAAM,WAAW,KAAK,UAAU,QAAQ;EACxC,IAAI,OAAO,OAAO,QAAQ,GACxB,OAAO;CAEX;CACA,OAAO;AACT;;;;;;;;;AAUA,SAAgB,sBACd,aACA,gBAAgB,oBAChB,gBAAuC,qBACvC,EAAE,aAAa,UAAoC,CAAC,GAC/B;CACrB,MAAM,UAA+B,CAAC;CACtC,MAAM,OAAO,QAAQ;CAGrB,MAAM,mBAAmB,kBAAkB,KAAI,QAAQ,QAAQ,gBAAgB,gBAAgB,GAAI;CACnG,MAAM,kBAAkB,aACpB,CAAC,IACD,iBAAiB,KAAI,QAAO;EAC1B,IAAI,QAAQ,eAAe,OAAO;EAGlC,IAAI,QAAQ,sBAAsB,OAAO,aAAa,cAAc,QAAQ,OAAO,EAAE;EACrF,OAAO;CACT,CAAC;CAGL,KAAK,MAAM,YAAY,iBAAiB;EAEtC,MAAM,WAAW,oBADA,KAAK,MAAM,QACgB,CAAC;EAC7C,IAAI,UACF,IAAI;GACF,MAAM,UAAU,aAAa,UAAU,OAAO,CAAC,CAAC,KAAK;GACrD,IAAI,SAAS;IACX,QAAQ,KAAK;KAAE,MAAM;KAAU;KAAS,OAAO;IAAS,CAAC;IACzD;GACF;EACF,QAAQ,CAER;CAEJ;CAGA,KAAK,MAAM,YAAY,kBAAkB;EAEvC,MAAM,WAAW,oBADA,WAAW,KAAK,aAAa,QAAQ,IAAI,aACX,aAAa;EAC5D,IAAI,UACF,IAAI;GACF,MAAM,UAAU,cAAc,KAAK,QAAQ,CAAC,CAAC,KAAK;GAClD,IAAI,SAAS;IACX,QAAQ,KAAK;KACX,MAAM;KACN;KACA,OAAO;KACP,GAAI,cAAc,MAAM,EAAE,KAAK,cAAc,IAAI,IAAI,CAAC;IACxD,CAAC;IACD;GACF;EACF,QAAQ,CAER;CAEJ;CAEA,OAAO;AACT;AAEA,SAAgB,oCACd,aACA,gBAAgB,oBAChB,eACU;CACV,OAAO,sBAAsB,aAAa,eAAe,aAAa,CAAC,CAAC,KAAI,WAAU,UAAU,OAAO,IAAI,CAAC;AAC9G;;AAGA,MAAa,6BAA6B;;;;;;;AAQ1C,SAAgB,wBAAwB,QAAmC;CAGzE,OAAO,QAFO,OAAO,UAAU,WAAW,WAAW,UAEhC,qBADN,OAAO,MAAM,GAAG,OAAO,KAAK,WAAW,OAAO,IAAI,KAAK,OAAO,KAC5B,QAAQ,OAAO;AAClE;;;;AAKA,SAAgB,wBAAwB,SAAsC;CAC5E,IAAI,QAAQ,WAAW,GAAG,OAAO;CAEjC,MAAM,WAAW,QAAQ,IAAI,uBAAuB;CAEpD,OAAO,KAAK,2BAA2B,MAAM,SAAS,KAAK,MAAM,EAAE;AACrE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build mode prompt — full tool access, make changes and verify.
|
|
3
|
+
*/
|
|
4
|
+
import type { PromptContext } from './index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Dynamic build mode prompt function.
|
|
7
|
+
* When an approved plan exists in state, prepends it so the agent
|
|
8
|
+
* knows exactly what to implement.
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildModePromptFn(ctx: PromptContext): string;
|
|
11
|
+
export declare const buildModePrompt = "\n# Build Mode\n\nYou are in BUILD mode. You have full access to all tools and can read, write, edit, and execute commands.\n\n## Working Style\n\n**For simple tasks** (typo fixes, small edits, single-file changes):\n- Just do it. No need to explain your plan first.\n\n**For non-trivial tasks** (3+ files, architectural decisions, unclear requirements):\n- Use the available task-management tools to create and update your task list\n- Work on ONE step at a time \u2014 complete it and verify it works before moving on\n- If multiple approaches are plausible and the choice would materially affect scope, behavior, or risk, stop and ask the user\n\n## The Implementation Loop\n\nFor each change you make:\n\n1. **Understand** \u2014 Read the relevant code. Check how similar things are done elsewhere.\n2. **Implement** \u2014 Make the change. Follow existing patterns and conventions.\n3. **Verify** \u2014 Test that it works. Don't assume \u2014 actually run it.\n4. **Prove** \u2014 Proactively prove that the change is good, makes sense in context, is a positive contribution, and works fully. The burden of proof is on YOU.\n5. **Clean up** \u2014 Ensure no broken code, no debug statements, no half-done features.\n\nOnly move to the next change after the current one is verified and proved to be working.\n\n## Verification is Required\n\nBefore considering any task complete:\n- Run relevant tests (check package.json for test scripts)\n- For TypeScript, run `tsc --noEmit` to catch type errors\n- If there are no automated tests, manually verify the behavior works as expected\n- Confirm the result makes sense in the codebase and improves the requested behavior\n- Use available task-checking tools to ensure all tracked tasks are done\n\n**Don't mark something as done until you've verified and proved it actually works.**\n\n## Error Recovery\n\nWhen something breaks:\n1. Read the full error output carefully \u2014 don't guess\n2. Find the root cause, not just the symptom\n3. Fix it properly \u2014 no casts or suppressions to hide errors\n4. Re-run to confirm the fix\n5. If progress is blocked after reasonable attempts, briefly explain the blocker, what you've tried, and the next best option\n\n## Git in Build Mode\n\n- Before committing, verify the code compiles and passes lint\n- Use descriptive branch names: `feat/...`, `fix/...`, `refactor/...`\n";
|
|
12
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/build.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAiB5D;AAED,eAAO,MAAM,eAAe,00EAmD3B,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//#region src/agents/prompts/build.ts
|
|
2
|
+
/**
|
|
3
|
+
* Dynamic build mode prompt function.
|
|
4
|
+
* When an approved plan exists in state, prepends it so the agent
|
|
5
|
+
* knows exactly what to implement.
|
|
6
|
+
*/
|
|
7
|
+
function buildModePromptFn(ctx) {
|
|
8
|
+
if (ctx.activePlan) return `# Approved Plan
|
|
9
|
+
|
|
10
|
+
**${ctx.activePlan.title}**
|
|
11
|
+
|
|
12
|
+
${ctx.activePlan.plan}
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
Implement the approved plan above. Follow the steps in order and verify each step works before moving on.
|
|
17
|
+
|
|
18
|
+
` + buildModePrompt;
|
|
19
|
+
return buildModePrompt;
|
|
20
|
+
}
|
|
21
|
+
const buildModePrompt = `
|
|
22
|
+
# Build Mode
|
|
23
|
+
|
|
24
|
+
You are in BUILD mode. You have full access to all tools and can read, write, edit, and execute commands.
|
|
25
|
+
|
|
26
|
+
## Working Style
|
|
27
|
+
|
|
28
|
+
**For simple tasks** (typo fixes, small edits, single-file changes):
|
|
29
|
+
- Just do it. No need to explain your plan first.
|
|
30
|
+
|
|
31
|
+
**For non-trivial tasks** (3+ files, architectural decisions, unclear requirements):
|
|
32
|
+
- Use the available task-management tools to create and update your task list
|
|
33
|
+
- Work on ONE step at a time — complete it and verify it works before moving on
|
|
34
|
+
- If multiple approaches are plausible and the choice would materially affect scope, behavior, or risk, stop and ask the user
|
|
35
|
+
|
|
36
|
+
## The Implementation Loop
|
|
37
|
+
|
|
38
|
+
For each change you make:
|
|
39
|
+
|
|
40
|
+
1. **Understand** — Read the relevant code. Check how similar things are done elsewhere.
|
|
41
|
+
2. **Implement** — Make the change. Follow existing patterns and conventions.
|
|
42
|
+
3. **Verify** — Test that it works. Don't assume — actually run it.
|
|
43
|
+
4. **Prove** — Proactively prove that the change is good, makes sense in context, is a positive contribution, and works fully. The burden of proof is on YOU.
|
|
44
|
+
5. **Clean up** — Ensure no broken code, no debug statements, no half-done features.
|
|
45
|
+
|
|
46
|
+
Only move to the next change after the current one is verified and proved to be working.
|
|
47
|
+
|
|
48
|
+
## Verification is Required
|
|
49
|
+
|
|
50
|
+
Before considering any task complete:
|
|
51
|
+
- Run relevant tests (check package.json for test scripts)
|
|
52
|
+
- For TypeScript, run \`tsc --noEmit\` to catch type errors
|
|
53
|
+
- If there are no automated tests, manually verify the behavior works as expected
|
|
54
|
+
- Confirm the result makes sense in the codebase and improves the requested behavior
|
|
55
|
+
- Use available task-checking tools to ensure all tracked tasks are done
|
|
56
|
+
|
|
57
|
+
**Don't mark something as done until you've verified and proved it actually works.**
|
|
58
|
+
|
|
59
|
+
## Error Recovery
|
|
60
|
+
|
|
61
|
+
When something breaks:
|
|
62
|
+
1. Read the full error output carefully — don't guess
|
|
63
|
+
2. Find the root cause, not just the symptom
|
|
64
|
+
3. Fix it properly — no casts or suppressions to hide errors
|
|
65
|
+
4. Re-run to confirm the fix
|
|
66
|
+
5. If progress is blocked after reasonable attempts, briefly explain the blocker, what you've tried, and the next best option
|
|
67
|
+
|
|
68
|
+
## Git in Build Mode
|
|
69
|
+
|
|
70
|
+
- Before committing, verify the code compiles and passes lint
|
|
71
|
+
- Use descriptive branch names: \`feat/...\`, \`fix/...\`, \`refactor/...\`
|
|
72
|
+
`;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { buildModePrompt, buildModePromptFn };
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","names":[],"sources":["../../../src/agents/prompts/build.ts"],"sourcesContent":["/**\n * Build mode prompt — full tool access, make changes and verify.\n */\n\nimport type { PromptContext } from './index.js';\n\n/**\n * Dynamic build mode prompt function.\n * When an approved plan exists in state, prepends it so the agent\n * knows exactly what to implement.\n */\nexport function buildModePromptFn(ctx: PromptContext): string {\n if (ctx.activePlan) {\n return (\n `# Approved Plan\n\n**${ctx.activePlan.title}**\n\n${ctx.activePlan.plan}\n\n---\n\nImplement the approved plan above. Follow the steps in order and verify each step works before moving on.\n\n` + buildModePrompt\n );\n }\n return buildModePrompt;\n}\n\nexport const buildModePrompt = `\n# Build Mode\n\nYou are in BUILD mode. You have full access to all tools and can read, write, edit, and execute commands.\n\n## Working Style\n\n**For simple tasks** (typo fixes, small edits, single-file changes):\n- Just do it. No need to explain your plan first.\n\n**For non-trivial tasks** (3+ files, architectural decisions, unclear requirements):\n- Use the available task-management tools to create and update your task list\n- Work on ONE step at a time — complete it and verify it works before moving on\n- If multiple approaches are plausible and the choice would materially affect scope, behavior, or risk, stop and ask the user\n\n## The Implementation Loop\n\nFor each change you make:\n\n1. **Understand** — Read the relevant code. Check how similar things are done elsewhere.\n2. **Implement** — Make the change. Follow existing patterns and conventions.\n3. **Verify** — Test that it works. Don't assume — actually run it.\n4. **Prove** — Proactively prove that the change is good, makes sense in context, is a positive contribution, and works fully. The burden of proof is on YOU.\n5. **Clean up** — Ensure no broken code, no debug statements, no half-done features.\n\nOnly move to the next change after the current one is verified and proved to be working.\n\n## Verification is Required\n\nBefore considering any task complete:\n- Run relevant tests (check package.json for test scripts)\n- For TypeScript, run \\`tsc --noEmit\\` to catch type errors\n- If there are no automated tests, manually verify the behavior works as expected\n- Confirm the result makes sense in the codebase and improves the requested behavior\n- Use available task-checking tools to ensure all tracked tasks are done\n\n**Don't mark something as done until you've verified and proved it actually works.**\n\n## Error Recovery\n\nWhen something breaks:\n1. Read the full error output carefully — don't guess\n2. Find the root cause, not just the symptom\n3. Fix it properly — no casts or suppressions to hide errors\n4. Re-run to confirm the fix\n5. If progress is blocked after reasonable attempts, briefly explain the blocker, what you've tried, and the next best option\n\n## Git in Build Mode\n\n- Before committing, verify the code compiles and passes lint\n- Use descriptive branch names: \\`feat/...\\`, \\`fix/...\\`, \\`refactor/...\\`\n`;\n"],"mappings":";;;;;;AAWA,SAAgB,kBAAkB,KAA4B;CAC5D,IAAI,IAAI,YACN,OACE;;IAEF,IAAI,WAAW,MAAM;;EAEvB,IAAI,WAAW,KAAK;;;;;;IAMlB;CAGF,OAAO;AACT;AAEA,MAAa,kBAAkB"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"fast.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/fast.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,cAAc,6zBAiB1B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region 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
|
+
//#endregion
|
|
24
|
+
export { fastModePrompt };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=fast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast.js","names":[],"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":";;;;AAIA,MAAa,iBAAiB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
/** The subconscious knowledge tools are registered on the agent. */
|
|
12
|
+
hasSubconscious?: boolean;
|
|
13
|
+
hostInstructions?: string;
|
|
14
|
+
currentDate: string;
|
|
15
|
+
workingDir: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* One labeled piece of the assembled system prompt.
|
|
19
|
+
*
|
|
20
|
+
* The system prompt is a single string by the time it reaches the model, which
|
|
21
|
+
* makes it impossible to say which configuration source is responsible for
|
|
22
|
+
* which share of the context window. Building it as labeled sections and
|
|
23
|
+
* joining them at the end keeps that attribution available to the `/context`
|
|
24
|
+
* audit while guaranteeing the audit measures the exact text that is sent —
|
|
25
|
+
* a parallel "describe the prompt" path would drift and report numbers for a
|
|
26
|
+
* prompt that is no longer assembled this way.
|
|
27
|
+
*/
|
|
28
|
+
export interface PromptSection {
|
|
29
|
+
/** Stable identifier, unique within a single build. */
|
|
30
|
+
id: string;
|
|
31
|
+
/** Human-readable label for display. */
|
|
32
|
+
label: string;
|
|
33
|
+
/** Optional provenance (e.g. the instruction file path). */
|
|
34
|
+
detail?: string;
|
|
35
|
+
/** The exact text contributed to the prompt. */
|
|
36
|
+
content: string;
|
|
37
|
+
}
|
|
38
|
+
/** Join prompt sections into the final system prompt string. */
|
|
39
|
+
export declare function joinPromptSections(sections: PromptSection[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* Build the full system prompt for a given mode and context.
|
|
42
|
+
* Combines the base prompt with mode-specific instructions.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildFullPrompt(ctx: PromptContext): string;
|
|
45
|
+
/**
|
|
46
|
+
* Build the system prompt as labeled sections. `buildFullPrompt` is the join of
|
|
47
|
+
* these, so the two can never disagree about what the model receives.
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildFullPromptSections(ctx: PromptContext): PromptSection[];
|
|
50
|
+
//# 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;AAkBpF,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,oEAAoE;IACpE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAQD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAKpE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,aAAa,GAAG,aAAa,EAAE,CAkH3E"}
|