@qduc/term2 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +5 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +8 -1
- package/dist/agent.js.map +1 -1
- package/dist/agent.lite-mode.test.d.ts +2 -0
- package/dist/agent.lite-mode.test.d.ts.map +1 -0
- package/dist/agent.lite-mode.test.js +39 -0
- package/dist/agent.lite-mode.test.js.map +1 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +9 -3
- package/dist/app.js.map +1 -1
- package/dist/components/ApprovalPrompt.d.ts.map +1 -1
- package/dist/components/ApprovalPrompt.js +3 -2
- package/dist/components/ApprovalPrompt.js.map +1 -1
- package/dist/components/ApprovalPrompt.test.d.ts +2 -0
- package/dist/components/ApprovalPrompt.test.d.ts.map +1 -0
- package/dist/components/ApprovalPrompt.test.js +23 -0
- package/dist/components/ApprovalPrompt.test.js.map +1 -0
- package/dist/components/ChatMessage.d.ts.map +1 -1
- package/dist/components/ChatMessage.js +2 -1
- package/dist/components/ChatMessage.js.map +1 -1
- package/dist/components/CommandMessage.d.ts.map +1 -1
- package/dist/components/CommandMessage.js +9 -8
- package/dist/components/CommandMessage.js.map +1 -1
- package/dist/components/LiveResponse.test.d.ts +2 -0
- package/dist/components/LiveResponse.test.d.ts.map +1 -0
- package/dist/components/LiveResponse.test.js +13 -0
- package/dist/components/LiveResponse.test.js.map +1 -0
- package/dist/components/MarkdownRenderer.d.ts.map +1 -1
- package/dist/components/MarkdownRenderer.js +13 -6
- package/dist/components/MarkdownRenderer.js.map +1 -1
- package/dist/components/MessageList.d.ts.map +1 -1
- package/dist/components/MessageList.js +59 -7
- package/dist/components/MessageList.js.map +1 -1
- package/dist/components/MessageList.test.js +112 -0
- package/dist/components/MessageList.test.js.map +1 -1
- package/dist/components/ModelSelectionMenu.error-tabs.test.d.ts +2 -0
- package/dist/components/ModelSelectionMenu.error-tabs.test.d.ts.map +1 -0
- package/dist/components/ModelSelectionMenu.error-tabs.test.js +18 -0
- package/dist/components/ModelSelectionMenu.error-tabs.test.js.map +1 -0
- package/dist/components/StatusBar.d.ts.map +1 -1
- package/dist/components/StatusBar.js +3 -3
- package/dist/components/StatusBar.js.map +1 -1
- package/dist/components/SubagentActivityMessage.d.ts +12 -0
- package/dist/components/SubagentActivityMessage.d.ts.map +1 -0
- package/dist/components/SubagentActivityMessage.js +15 -0
- package/dist/components/SubagentActivityMessage.js.map +1 -0
- package/dist/components/TextInput.d.ts +42 -0
- package/dist/components/TextInput.d.ts.map +1 -0
- package/dist/components/TextInput.js +398 -0
- package/dist/components/TextInput.js.map +1 -0
- package/dist/components/TextInput.test.d.ts +2 -0
- package/dist/components/TextInput.test.d.ts.map +1 -0
- package/dist/components/TextInput.test.js +75 -0
- package/dist/components/TextInput.test.js.map +1 -0
- package/dist/components/theme.d.ts +8 -0
- package/dist/components/theme.d.ts.map +1 -0
- package/dist/components/theme.js +22 -0
- package/dist/components/theme.js.map +1 -0
- package/dist/debug_ask_mentor.d.ts +2 -0
- package/dist/debug_ask_mentor.d.ts.map +1 -0
- package/dist/debug_ask_mentor.js +73 -0
- package/dist/debug_ask_mentor.js.map +1 -0
- package/dist/hooks/use-app-commands.d.ts +6 -0
- package/dist/hooks/use-app-commands.d.ts.map +1 -1
- package/dist/hooks/use-app-commands.js +23 -20
- package/dist/hooks/use-app-commands.js.map +1 -1
- package/dist/hooks/use-app-commands.test.js +34 -1
- package/dist/hooks/use-app-commands.test.js.map +1 -1
- package/dist/hooks/use-conversation.d.ts +13 -2
- package/dist/hooks/use-conversation.d.ts.map +1 -1
- package/dist/hooks/use-conversation.js +36 -13
- package/dist/hooks/use-conversation.js.map +1 -1
- package/dist/lib/editor-impl.test.js +63 -50
- package/dist/lib/editor-impl.test.js.map +1 -1
- package/dist/lib/openai-agent-client.d.ts +7 -0
- package/dist/lib/openai-agent-client.d.ts.map +1 -1
- package/dist/lib/openai-agent-client.js +35 -131
- package/dist/lib/openai-agent-client.js.map +1 -1
- package/dist/lib/openai-agent-client.test.js +7 -0
- package/dist/lib/openai-agent-client.test.js.map +1 -1
- package/dist/lib/shell.d.ts +7 -0
- package/dist/lib/shell.d.ts.map +1 -0
- package/dist/lib/shell.js +56 -0
- package/dist/lib/shell.js.map +1 -0
- package/dist/modes/companion/command-index.d.ts +26 -0
- package/dist/modes/companion/command-index.d.ts.map +1 -0
- package/dist/modes/companion/command-index.js +50 -0
- package/dist/modes/companion/command-index.js.map +1 -0
- package/dist/modes/companion/command-index.test.d.ts +2 -0
- package/dist/modes/companion/command-index.test.d.ts.map +1 -0
- package/dist/modes/companion/command-index.test.js +86 -0
- package/dist/modes/companion/command-index.test.js.map +1 -0
- package/dist/modes/companion/companion-app.d.ts +12 -0
- package/dist/modes/companion/companion-app.d.ts.map +1 -0
- package/dist/modes/companion/companion-app.js +297 -0
- package/dist/modes/companion/companion-app.js.map +1 -0
- package/dist/modes/companion/companion-session.d.ts +63 -0
- package/dist/modes/companion/companion-session.d.ts.map +1 -0
- package/dist/modes/companion/companion-session.js +146 -0
- package/dist/modes/companion/companion-session.js.map +1 -0
- package/dist/modes/companion/companion-session.test.d.ts +2 -0
- package/dist/modes/companion/companion-session.test.d.ts.map +1 -0
- package/dist/modes/companion/companion-session.test.js +28 -0
- package/dist/modes/companion/companion-session.test.js.map +1 -0
- package/dist/modes/companion/components/status-bar.d.ts +13 -0
- package/dist/modes/companion/components/status-bar.d.ts.map +1 -0
- package/dist/modes/companion/components/status-bar.js +26 -0
- package/dist/modes/companion/components/status-bar.js.map +1 -0
- package/dist/modes/companion/context-buffer.d.ts +65 -0
- package/dist/modes/companion/context-buffer.d.ts.map +1 -0
- package/dist/modes/companion/context-buffer.js +156 -0
- package/dist/modes/companion/context-buffer.js.map +1 -0
- package/dist/modes/companion/context-buffer.test.d.ts +2 -0
- package/dist/modes/companion/context-buffer.test.d.ts.map +1 -0
- package/dist/modes/companion/context-buffer.test.js +154 -0
- package/dist/modes/companion/context-buffer.test.js.map +1 -0
- package/dist/modes/companion/event-detector.d.ts +46 -0
- package/dist/modes/companion/event-detector.d.ts.map +1 -0
- package/dist/modes/companion/event-detector.js +169 -0
- package/dist/modes/companion/event-detector.js.map +1 -0
- package/dist/modes/companion/event-detector.test.d.ts +2 -0
- package/dist/modes/companion/event-detector.test.d.ts.map +1 -0
- package/dist/modes/companion/event-detector.test.js +121 -0
- package/dist/modes/companion/event-detector.test.js.map +1 -0
- package/dist/modes/companion/index.d.ts +33 -0
- package/dist/modes/companion/index.d.ts.map +1 -0
- package/dist/modes/companion/index.js +21 -0
- package/dist/modes/companion/index.js.map +1 -0
- package/dist/modes/companion/input-key-mapper.d.ts +3 -0
- package/dist/modes/companion/input-key-mapper.d.ts.map +1 -0
- package/dist/modes/companion/input-key-mapper.js +31 -0
- package/dist/modes/companion/input-key-mapper.js.map +1 -0
- package/dist/modes/companion/input-key-mapper.test.d.ts +2 -0
- package/dist/modes/companion/input-key-mapper.test.d.ts.map +1 -0
- package/dist/modes/companion/input-key-mapper.test.js +26 -0
- package/dist/modes/companion/input-key-mapper.test.js.map +1 -0
- package/dist/modes/companion/input-parser.d.ts +53 -0
- package/dist/modes/companion/input-parser.d.ts.map +1 -0
- package/dist/modes/companion/input-parser.js +114 -0
- package/dist/modes/companion/input-parser.js.map +1 -0
- package/dist/modes/companion/input-parser.test.d.ts +2 -0
- package/dist/modes/companion/input-parser.test.d.ts.map +1 -0
- package/dist/modes/companion/input-parser.test.js +123 -0
- package/dist/modes/companion/input-parser.test.js.map +1 -0
- package/dist/modes/companion/mode-manager.d.ts +41 -0
- package/dist/modes/companion/mode-manager.d.ts.map +1 -0
- package/dist/modes/companion/mode-manager.js +56 -0
- package/dist/modes/companion/mode-manager.js.map +1 -0
- package/dist/modes/companion/mode-manager.test.d.ts +2 -0
- package/dist/modes/companion/mode-manager.test.d.ts.map +1 -0
- package/dist/modes/companion/mode-manager.test.js +65 -0
- package/dist/modes/companion/mode-manager.test.js.map +1 -0
- package/dist/modes/companion/output-classifier.d.ts +15 -0
- package/dist/modes/companion/output-classifier.d.ts.map +1 -0
- package/dist/modes/companion/output-classifier.js +77 -0
- package/dist/modes/companion/output-classifier.js.map +1 -0
- package/dist/modes/companion/output-classifier.test.d.ts +2 -0
- package/dist/modes/companion/output-classifier.test.d.ts.map +1 -0
- package/dist/modes/companion/output-classifier.test.js +133 -0
- package/dist/modes/companion/output-classifier.test.js.map +1 -0
- package/dist/modes/companion/pty-wrapper.d.ts +46 -0
- package/dist/modes/companion/pty-wrapper.d.ts.map +1 -0
- package/dist/modes/companion/pty-wrapper.js +143 -0
- package/dist/modes/companion/pty-wrapper.js.map +1 -0
- package/dist/modes/companion/safety-classifier.d.ts +31 -0
- package/dist/modes/companion/safety-classifier.d.ts.map +1 -0
- package/dist/modes/companion/safety-classifier.js +140 -0
- package/dist/modes/companion/safety-classifier.js.map +1 -0
- package/dist/modes/companion/safety-classifier.test.d.ts +2 -0
- package/dist/modes/companion/safety-classifier.test.d.ts.map +1 -0
- package/dist/modes/companion/safety-classifier.test.js +151 -0
- package/dist/modes/companion/safety-classifier.test.js.map +1 -0
- package/dist/modes/companion/summarizer.d.ts +24 -0
- package/dist/modes/companion/summarizer.d.ts.map +1 -0
- package/dist/modes/companion/summarizer.js +132 -0
- package/dist/modes/companion/summarizer.js.map +1 -0
- package/dist/modes/companion/terminal-history.d.ts +27 -0
- package/dist/modes/companion/terminal-history.d.ts.map +1 -0
- package/dist/modes/companion/terminal-history.js +142 -0
- package/dist/modes/companion/terminal-history.js.map +1 -0
- package/dist/prompts/gpt-5.md +4 -7
- package/dist/prompts/simple-mentor.md +215 -0
- package/dist/prompts/subagents/explorer.md +42 -0
- package/dist/prompts/subagents/mentor.md +16 -0
- package/dist/prompts/subagents/researcher.md +40 -0
- package/dist/prompts/subagents/worker.md +41 -0
- package/dist/providers/ai-sdk-openai-compatible.provider.d.ts +2 -0
- package/dist/providers/ai-sdk-openai-compatible.provider.d.ts.map +1 -1
- package/dist/providers/ai-sdk-openai-compatible.provider.js +8 -4
- package/dist/providers/ai-sdk-openai-compatible.provider.js.map +1 -1
- package/dist/providers/ai-sdk-openai-compatible.provider.test.js +119 -1
- package/dist/providers/ai-sdk-openai-compatible.provider.test.js.map +1 -1
- package/dist/providers/ai-sdk-openai.provider.d.ts +14 -0
- package/dist/providers/ai-sdk-openai.provider.d.ts.map +1 -0
- package/dist/providers/ai-sdk-openai.provider.js +18 -0
- package/dist/providers/ai-sdk-openai.provider.js.map +1 -0
- package/dist/providers/common/openai-compatible-messages.d.ts +1 -1
- package/dist/providers/common/openai-compatible-messages.d.ts.map +1 -1
- package/dist/providers/common/openai-compatible-messages.js +41 -16
- package/dist/providers/common/openai-compatible-messages.js.map +1 -1
- package/dist/providers/common/openai-compatible-messages.test.js +55 -14
- package/dist/providers/common/openai-compatible-messages.test.js.map +1 -1
- package/dist/providers/github-copilot/converters.d.ts +45 -0
- package/dist/providers/github-copilot/converters.d.ts.map +1 -0
- package/dist/providers/github-copilot/converters.js +118 -0
- package/dist/providers/github-copilot/converters.js.map +1 -0
- package/dist/providers/github-copilot/converters.test.d.ts +2 -0
- package/dist/providers/github-copilot/converters.test.d.ts.map +1 -0
- package/dist/providers/github-copilot/converters.test.js +162 -0
- package/dist/providers/github-copilot/converters.test.js.map +1 -0
- package/dist/providers/github-copilot/github-copilot.provider.d.ts +2 -0
- package/dist/providers/github-copilot/github-copilot.provider.d.ts.map +1 -0
- package/dist/providers/github-copilot/github-copilot.provider.js +75 -0
- package/dist/providers/github-copilot/github-copilot.provider.js.map +1 -0
- package/dist/providers/github-copilot/github-copilot.provider.test.d.ts +2 -0
- package/dist/providers/github-copilot/github-copilot.provider.test.d.ts.map +1 -0
- package/dist/providers/github-copilot/github-copilot.provider.test.js +26 -0
- package/dist/providers/github-copilot/github-copilot.provider.test.js.map +1 -0
- package/dist/providers/github-copilot/index.d.ts +4 -0
- package/dist/providers/github-copilot/index.d.ts.map +1 -0
- package/dist/providers/github-copilot/index.js +4 -0
- package/dist/providers/github-copilot/index.js.map +1 -0
- package/dist/providers/github-copilot/model.d.ts +24 -0
- package/dist/providers/github-copilot/model.d.ts.map +1 -0
- package/dist/providers/github-copilot/model.delta.test.d.ts +2 -0
- package/dist/providers/github-copilot/model.delta.test.d.ts.map +1 -0
- package/dist/providers/github-copilot/model.delta.test.js +15 -0
- package/dist/providers/github-copilot/model.delta.test.js.map +1 -0
- package/dist/providers/github-copilot/model.js +498 -0
- package/dist/providers/github-copilot/model.js.map +1 -0
- package/dist/providers/github-copilot/model.test.d.ts +2 -0
- package/dist/providers/github-copilot/model.test.d.ts.map +1 -0
- package/dist/providers/github-copilot/model.test.js +63 -0
- package/dist/providers/github-copilot/model.test.js.map +1 -0
- package/dist/providers/github-copilot/provider.d.ts +15 -0
- package/dist/providers/github-copilot/provider.d.ts.map +1 -0
- package/dist/providers/github-copilot/provider.js +25 -0
- package/dist/providers/github-copilot/provider.js.map +1 -0
- package/dist/providers/github-copilot/provider.test.d.ts +2 -0
- package/dist/providers/github-copilot/provider.test.d.ts.map +1 -0
- package/dist/providers/github-copilot/provider.test.js +52 -0
- package/dist/providers/github-copilot/provider.test.js.map +1 -0
- package/dist/providers/github-copilot/utils.d.ts +20 -0
- package/dist/providers/github-copilot/utils.d.ts.map +1 -0
- package/dist/providers/github-copilot/utils.js +142 -0
- package/dist/providers/github-copilot/utils.js.map +1 -0
- package/dist/providers/github-copilot/utils.test.d.ts +2 -0
- package/dist/providers/github-copilot/utils.test.d.ts.map +1 -0
- package/dist/providers/github-copilot/utils.test.js +21 -0
- package/dist/providers/github-copilot/utils.test.js.map +1 -0
- package/dist/providers/openai-compatible/api.d.ts +17 -0
- package/dist/providers/openai-compatible/api.d.ts.map +1 -0
- package/dist/providers/openai-compatible/api.js +58 -0
- package/dist/providers/openai-compatible/api.js.map +1 -0
- package/dist/providers/openai-compatible/model.d.ts +17 -0
- package/dist/providers/openai-compatible/model.d.ts.map +1 -0
- package/dist/providers/openai-compatible/model.js +473 -0
- package/dist/providers/openai-compatible/model.js.map +1 -0
- package/dist/providers/openai-compatible/provider.d.ts +22 -0
- package/dist/providers/openai-compatible/provider.d.ts.map +1 -0
- package/dist/providers/openai-compatible/provider.js +43 -0
- package/dist/providers/openai-compatible/provider.js.map +1 -0
- package/dist/providers/openai-compatible/reasoning-content.test.d.ts +2 -0
- package/dist/providers/openai-compatible/reasoning-content.test.d.ts.map +1 -0
- package/dist/providers/openai-compatible/reasoning-content.test.js +258 -0
- package/dist/providers/openai-compatible/reasoning-content.test.js.map +1 -0
- package/dist/providers/openai-compatible/utils.d.ts +3 -0
- package/dist/providers/openai-compatible/utils.d.ts.map +1 -0
- package/dist/providers/openai-compatible/utils.js +11 -0
- package/dist/providers/openai-compatible/utils.js.map +1 -0
- package/dist/providers/openai-compatible-behavior-gate.test.js +42 -1
- package/dist/providers/openai-compatible-behavior-gate.test.js.map +1 -1
- package/dist/providers/openai-compatible.provider.js +2 -2
- package/dist/providers/openai-compatible.provider.js.map +1 -1
- package/dist/providers/openai-compatible.provider.test.js +1 -1
- package/dist/providers/openai-compatible.provider.test.js.map +1 -1
- package/dist/providers/openrouter/api.d.ts +39 -0
- package/dist/providers/openrouter/api.d.ts.map +1 -0
- package/dist/providers/openrouter/api.js +164 -0
- package/dist/providers/openrouter/api.js.map +1 -0
- package/dist/providers/openrouter/converters.d.ts +8 -0
- package/dist/providers/openrouter/converters.d.ts.map +1 -0
- package/dist/providers/openrouter/converters.js +391 -0
- package/dist/providers/openrouter/converters.js.map +1 -0
- package/dist/providers/openrouter/converters.test.d.ts +2 -0
- package/dist/providers/openrouter/converters.test.d.ts.map +1 -0
- package/dist/providers/openrouter/converters.test.js +179 -0
- package/dist/providers/openrouter/converters.test.js.map +1 -0
- package/dist/providers/openrouter/index.d.ts +4 -0
- package/dist/providers/openrouter/index.d.ts.map +1 -0
- package/dist/providers/openrouter/index.js +4 -0
- package/dist/providers/openrouter/index.js.map +1 -0
- package/dist/providers/openrouter/model.d.ts +14 -0
- package/dist/providers/openrouter/model.d.ts.map +1 -0
- package/dist/providers/openrouter/model.js +457 -0
- package/dist/providers/openrouter/model.js.map +1 -0
- package/dist/providers/openrouter/provider.d.ts +15 -0
- package/dist/providers/openrouter/provider.d.ts.map +1 -0
- package/dist/providers/openrouter/provider.js +21 -0
- package/dist/providers/openrouter/provider.js.map +1 -0
- package/dist/providers/openrouter/reasoning-content.test.d.ts +2 -0
- package/dist/providers/openrouter/reasoning-content.test.d.ts.map +1 -0
- package/dist/providers/openrouter/reasoning-content.test.js +122 -0
- package/dist/providers/openrouter/reasoning-content.test.js.map +1 -0
- package/dist/providers/openrouter/utils.d.ts +11 -0
- package/dist/providers/openrouter/utils.d.ts.map +1 -0
- package/dist/providers/openrouter/utils.js +29 -0
- package/dist/providers/openrouter/utils.js.map +1 -0
- package/dist/providers/openrouter.api.retry.test.d.ts +2 -0
- package/dist/providers/openrouter.api.retry.test.d.ts.map +1 -0
- package/dist/providers/openrouter.api.retry.test.js +148 -0
- package/dist/providers/openrouter.api.retry.test.js.map +1 -0
- package/dist/providers/openrouter.provider.js +1 -1
- package/dist/providers/openrouter.provider.js.map +1 -1
- package/dist/providers/openrouter.test.d.ts +2 -0
- package/dist/providers/openrouter.test.d.ts.map +1 -0
- package/dist/providers/openrouter.test.js +1449 -0
- package/dist/providers/openrouter.test.js.map +1 -0
- package/dist/safety-checker.js +57 -0
- package/dist/services/approval-rejection-interceptor.test.js +5 -0
- package/dist/services/approval-rejection-interceptor.test.js.map +1 -1
- package/dist/services/check_mock.d.ts +2 -0
- package/dist/services/check_mock.d.ts.map +1 -0
- package/dist/services/check_mock.js +22 -0
- package/dist/services/check_mock.js.map +1 -0
- package/dist/services/conversation-events.d.ts +25 -1
- package/dist/services/conversation-events.d.ts.map +1 -1
- package/dist/services/conversation-service.test.d.ts +2 -0
- package/dist/services/conversation-service.test.d.ts.map +1 -0
- package/dist/services/conversation-service.test.js +156 -0
- package/dist/services/conversation-service.test.js.map +1 -0
- package/dist/services/conversation-session.auto-approval.test.js +52 -0
- package/dist/services/conversation-session.auto-approval.test.js.map +1 -1
- package/dist/services/conversation-session.d.ts.map +1 -1
- package/dist/services/conversation-session.js +64 -30
- package/dist/services/conversation-session.js.map +1 -1
- package/dist/services/interruption-info.js +1 -1
- package/dist/services/interruption-info.js.map +1 -1
- package/dist/services/interruption-info.test.js +12 -0
- package/dist/services/interruption-info.test.js.map +1 -1
- package/dist/services/rtk-service.d.ts.map +1 -1
- package/dist/services/rtk-service.js +104 -9
- package/dist/services/rtk-service.js.map +1 -1
- package/dist/services/rtk-service.test.js +55 -20
- package/dist/services/rtk-service.test.js.map +1 -1
- package/dist/services/stream-event-processor.d.ts.map +1 -1
- package/dist/services/stream-event-processor.js +19 -8
- package/dist/services/stream-event-processor.js.map +1 -1
- package/dist/services/subagents/subagent-manager.d.ts +16 -0
- package/dist/services/subagents/subagent-manager.d.ts.map +1 -0
- package/dist/services/subagents/subagent-manager.js +530 -0
- package/dist/services/subagents/subagent-manager.js.map +1 -0
- package/dist/services/subagents/subagent-manager.test.d.ts +2 -0
- package/dist/services/subagents/subagent-manager.test.d.ts.map +1 -0
- package/dist/services/subagents/subagent-manager.test.js +690 -0
- package/dist/services/subagents/subagent-manager.test.js.map +1 -0
- package/dist/services/subagents/subagent-session.d.ts +26 -0
- package/dist/services/subagents/subagent-session.d.ts.map +1 -0
- package/dist/services/subagents/subagent-session.js +86 -0
- package/dist/services/subagents/subagent-session.js.map +1 -0
- package/dist/services/subagents/subagent-session.test.d.ts +2 -0
- package/dist/services/subagents/subagent-session.test.d.ts.map +1 -0
- package/dist/services/subagents/subagent-session.test.js +118 -0
- package/dist/services/subagents/subagent-session.test.js.map +1 -0
- package/dist/services/subagents/types.d.ts +35 -0
- package/dist/services/subagents/types.d.ts.map +1 -0
- package/dist/services/subagents/types.js +2 -0
- package/dist/services/subagents/types.js.map +1 -0
- package/dist/services/terminal-result-collector.d.ts.map +1 -1
- package/dist/services/terminal-result-collector.js +30 -3
- package/dist/services/terminal-result-collector.js.map +1 -1
- package/dist/services/terminal-result-collector.test.js +81 -0
- package/dist/services/terminal-result-collector.test.js.map +1 -1
- package/dist/tools/apply-patch.d.ts +2 -2
- package/dist/tools/apply-patch.d.ts.map +1 -1
- package/dist/tools/apply-patch.js.map +1 -1
- package/dist/tools/ask-mentor.d.ts +2 -2
- package/dist/tools/ask-mentor.d.ts.map +1 -1
- package/dist/tools/ask-mentor.js.map +1 -1
- package/dist/tools/bash.d.ts +10 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +55 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/code-context.d.ts +3 -3
- package/dist/tools/code-context.d.ts.map +1 -1
- package/dist/tools/code-context.js.map +1 -1
- package/dist/tools/code-context.test.js +1 -2
- package/dist/tools/code-context.test.js.map +1 -1
- package/dist/tools/command-message-formatters.d.ts +5 -0
- package/dist/tools/command-message-formatters.d.ts.map +1 -0
- package/dist/tools/command-message-formatters.js +13 -0
- package/dist/tools/command-message-formatters.js.map +1 -0
- package/dist/tools/command-message-formatters.test.d.ts +2 -0
- package/dist/tools/command-message-formatters.test.d.ts.map +1 -0
- package/dist/tools/command-message-formatters.test.js +23 -0
- package/dist/tools/command-message-formatters.test.js.map +1 -0
- package/dist/tools/create-file.d.ts +2 -2
- package/dist/tools/create-file.d.ts.map +1 -1
- package/dist/tools/create-file.js +15 -9
- package/dist/tools/create-file.js.map +1 -1
- package/dist/tools/create-file.test.js +11 -0
- package/dist/tools/create-file.test.js.map +1 -1
- package/dist/tools/file-locks.d.ts +1 -0
- package/dist/tools/file-locks.d.ts.map +1 -1
- package/dist/tools/file-locks.js +16 -0
- package/dist/tools/file-locks.js.map +1 -1
- package/dist/tools/find-files.d.ts +2 -2
- package/dist/tools/find-files.d.ts.map +1 -1
- package/dist/tools/find-files.js.map +1 -1
- package/dist/tools/find-files.test.js +1 -2
- package/dist/tools/find-files.test.js.map +1 -1
- package/dist/tools/grep.d.ts +2 -2
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js.map +1 -1
- package/dist/tools/grep.test.d.ts +2 -0
- package/dist/tools/grep.test.d.ts.map +1 -0
- package/dist/tools/read-file.d.ts +2 -2
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js.map +1 -1
- package/dist/tools/read-file.test.js +2 -3
- package/dist/tools/read-file.test.js.map +1 -1
- package/dist/tools/run-subagent.d.ts +14 -0
- package/dist/tools/run-subagent.d.ts.map +1 -0
- package/dist/tools/run-subagent.js +196 -0
- package/dist/tools/run-subagent.js.map +1 -0
- package/dist/tools/run-subagent.test.d.ts +2 -0
- package/dist/tools/run-subagent.test.d.ts.map +1 -0
- package/dist/tools/run-subagent.test.js +159 -0
- package/dist/tools/run-subagent.test.js.map +1 -0
- package/dist/tools/search-replace.d.ts +2 -2
- package/dist/tools/search-replace.d.ts.map +1 -1
- package/dist/tools/search-replace.js +49 -6
- package/dist/tools/search-replace.js.map +1 -1
- package/dist/tools/search-replace.test.js +78 -0
- package/dist/tools/search-replace.test.js.map +1 -1
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/shell.d.ts +2 -2
- package/dist/tools/shell.d.ts.map +1 -1
- package/dist/tools/shell.js.map +1 -1
- package/dist/tools/shell.test.js +137 -11
- package/dist/tools/shell.test.js.map +1 -1
- package/dist/tools/types.d.ts +2 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +11 -1
- package/dist/tools/utils.js.map +1 -1
- package/dist/tools/utils.test.js +13 -0
- package/dist/tools/utils.test.js.map +1 -1
- package/dist/tools/web-fetch.d.ts +2 -2
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js.map +1 -1
- package/dist/tools/web-search.d.ts +2 -2
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js.map +1 -1
- package/dist/utils/clipboard.d.ts +2 -2
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +58 -22
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/clipboard.test.js +25 -6
- package/dist/utils/clipboard.test.js.map +1 -1
- package/dist/utils/command-safety/handlers/sed-handler.d.ts.map +1 -1
- package/dist/utils/command-safety/handlers/sed-handler.js +10 -7
- package/dist/utils/command-safety/handlers/sed-handler.js.map +1 -1
- package/dist/utils/command-safety/index.d.ts.map +1 -1
- package/dist/utils/command-safety/index.js +153 -117
- package/dist/utils/command-safety/index.js.map +1 -1
- package/dist/utils/command-safety/path-analysis.d.ts.map +1 -1
- package/dist/utils/command-safety/path-analysis.js +6 -2
- package/dist/utils/command-safety/path-analysis.js.map +1 -1
- package/dist/utils/command-safety/utils.js +2 -2
- package/dist/utils/command-safety/utils.js.map +1 -1
- package/dist/utils/command-safety.d.ts +21 -0
- package/dist/utils/command-safety.d.ts.map +1 -0
- package/dist/utils/command-safety.devnull.test.d.ts +2 -0
- package/dist/utils/command-safety.devnull.test.d.ts.map +1 -0
- package/dist/utils/command-safety.devnull.test.js +13 -0
- package/dist/utils/command-safety.devnull.test.js.map +1 -0
- package/dist/utils/command-safety.js +348 -0
- package/dist/utils/command-safety.js.map +1 -0
- package/dist/utils/command-safety.path.test.js +15 -1
- package/dist/utils/command-safety.path.test.js.map +1 -1
- package/dist/utils/conversation-event-handler.d.ts +15 -0
- package/dist/utils/conversation-event-handler.d.ts.map +1 -1
- package/dist/utils/conversation-event-handler.js +104 -8
- package/dist/utils/conversation-event-handler.js.map +1 -1
- package/dist/utils/conversation-event-handler.test.js +185 -2
- package/dist/utils/conversation-event-handler.test.js.map +1 -1
- package/dist/utils/conversation-utils.d.ts +1 -0
- package/dist/utils/conversation-utils.d.ts.map +1 -1
- package/dist/utils/conversation-utils.js +1 -0
- package/dist/utils/conversation-utils.js.map +1 -1
- package/dist/utils/extract-command-messages.d.ts.map +1 -1
- package/dist/utils/extract-command-messages.js +2 -21
- package/dist/utils/extract-command-messages.js.map +1 -1
- package/dist/utils/extract-command-messages.test.d.ts +2 -0
- package/dist/utils/extract-command-messages.test.d.ts.map +1 -0
- package/dist/utils/provider-traffic-extractor.repro.test.d.ts +2 -0
- package/dist/utils/provider-traffic-extractor.repro.test.d.ts.map +1 -0
- package/dist/utils/provider-traffic-extractor.repro.test.js.map +1 -0
- package/dist/utils/streaming-session-factory.d.ts.map +1 -1
- package/dist/utils/streaming-session-factory.js +16 -1
- package/dist/utils/streaming-session-factory.js.map +1 -1
- package/dist/utils/streaming-session-factory.test.js +42 -0
- package/dist/utils/streaming-session-factory.test.js.map +1 -1
- package/dist/utils/token-usage.d.ts +13 -0
- package/dist/utils/token-usage.d.ts.map +1 -1
- package/dist/utils/token-usage.js +92 -1
- package/dist/utils/token-usage.js.map +1 -1
- package/dist/utils/token-usage.test.js +62 -1
- package/dist/utils/token-usage.test.js.map +1 -1
- package/package.json +2 -2
- package/dist/providers/openai.provider.test.d.ts +0 -2
- package/dist/providers/openai.provider.test.d.ts.map +0 -1
- package/dist/providers/openai.provider.test.js +0 -22
- package/dist/providers/openai.provider.test.js.map +0 -1
- package/dist/utils/project-tree.d.ts +0 -14
- package/dist/utils/project-tree.d.ts.map +0 -1
- package/dist/utils/project-tree.js +0 -111
- package/dist/utils/project-tree.js.map +0 -1
- package/dist/utils/project-tree.test.d.ts +0 -2
- package/dist/utils/project-tree.test.d.ts.map +0 -1
- package/dist/utils/project-tree.test.js +0 -149
- package/dist/utils/project-tree.test.js.map +0 -1
- package/dist/utils/terminal-clear.d.ts +0 -7
- package/dist/utils/terminal-clear.d.ts.map +0 -1
- package/dist/utils/terminal-clear.js +0 -5
- package/dist/utils/terminal-clear.js.map +0 -1
- package/dist/utils/terminal-clear.test.d.ts +0 -2
- package/dist/utils/terminal-clear.test.d.ts.map +0 -1
- package/dist/utils/terminal-clear.test.js +0 -13
- package/dist/utils/terminal-clear.test.js.map +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
|
+
import { classifyOutputType, getSummarizationPrompt, shouldSummarize } from './output-classifier.js';
|
|
3
|
+
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
4
|
+
/**
|
|
5
|
+
* Summarizer for command outputs using a small, fast LLM.
|
|
6
|
+
* Caches summaries to avoid reprocessing.
|
|
7
|
+
*/
|
|
8
|
+
export class Summarizer {
|
|
9
|
+
#client = null;
|
|
10
|
+
#settings;
|
|
11
|
+
#logger;
|
|
12
|
+
#cache = new Map();
|
|
13
|
+
constructor(deps) {
|
|
14
|
+
this.#settings = deps.settings;
|
|
15
|
+
this.#logger = deps.logger;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Summarize command output.
|
|
19
|
+
* Returns the original output if summarization is not needed or fails.
|
|
20
|
+
*/
|
|
21
|
+
async summarize(entry, detail) {
|
|
22
|
+
// Check if summarization is needed
|
|
23
|
+
if (!shouldSummarize(entry)) {
|
|
24
|
+
return entry.output;
|
|
25
|
+
}
|
|
26
|
+
// Check cache
|
|
27
|
+
const cacheKey = this.#getCacheKey(entry, detail);
|
|
28
|
+
const cached = this.#cache.get(cacheKey);
|
|
29
|
+
if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
|
|
30
|
+
return cached.summary;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const client = await this.#getClient();
|
|
34
|
+
const model = this.#settings.get('companion.summarizerModel') || 'gpt-4o-mini';
|
|
35
|
+
const maxTokens = this.#settings.get('companion.summarizerMaxTokens') || 500;
|
|
36
|
+
const outputType = classifyOutputType(entry);
|
|
37
|
+
const prompt = this.#buildPrompt(entry, detail, outputType);
|
|
38
|
+
const response = await client.chat.completions.create({
|
|
39
|
+
model,
|
|
40
|
+
max_tokens: maxTokens,
|
|
41
|
+
messages: [
|
|
42
|
+
{
|
|
43
|
+
role: 'system',
|
|
44
|
+
content: 'You are a concise technical summarizer. Extract key information only.',
|
|
45
|
+
},
|
|
46
|
+
{ role: 'user', content: prompt },
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
const summary = response.choices[0]?.message?.content || entry.output;
|
|
50
|
+
// Cache result
|
|
51
|
+
this.#cache.set(cacheKey, { summary, timestamp: Date.now() });
|
|
52
|
+
return summary;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this.#logger.warn('Summarization failed, using fallback', {
|
|
56
|
+
error: error instanceof Error ? error.message : String(error),
|
|
57
|
+
command: entry.command.slice(0, 50),
|
|
58
|
+
});
|
|
59
|
+
// Fallback: smart truncation
|
|
60
|
+
return this.#fallbackSummarize(entry, detail);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Clear the summary cache.
|
|
65
|
+
*/
|
|
66
|
+
clearCache() {
|
|
67
|
+
this.#cache.clear();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get or create OpenAI client.
|
|
71
|
+
*/
|
|
72
|
+
async #getClient() {
|
|
73
|
+
if (this.#client) {
|
|
74
|
+
return this.#client;
|
|
75
|
+
}
|
|
76
|
+
const provider = this.#settings.get('companion.summarizerProvider') || 'openai';
|
|
77
|
+
// Use OpenAI API key from environment
|
|
78
|
+
const apiKey = process.env.OPENAI_API_KEY;
|
|
79
|
+
// For non-OpenAI providers, get baseURL from settings
|
|
80
|
+
const baseURL = provider === 'openai'
|
|
81
|
+
? undefined
|
|
82
|
+
: this.#settings.get(`agent.${provider}.baseUrl`);
|
|
83
|
+
if (!apiKey) {
|
|
84
|
+
throw new Error('OPENAI_API_KEY not set');
|
|
85
|
+
}
|
|
86
|
+
this.#client = new OpenAI({ apiKey, baseURL });
|
|
87
|
+
return this.#client;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Build the summarization prompt.
|
|
91
|
+
*/
|
|
92
|
+
#buildPrompt(entry, detail, outputType) {
|
|
93
|
+
const basePrompt = getSummarizationPrompt(outputType);
|
|
94
|
+
return `Command: ${entry.command}
|
|
95
|
+
Exit code: ${entry.exitCode}
|
|
96
|
+
|
|
97
|
+
Output:
|
|
98
|
+
\`\`\`
|
|
99
|
+
${entry.output}
|
|
100
|
+
\`\`\`
|
|
101
|
+
|
|
102
|
+
${detail === 'errors_only' ? getSummarizationPrompt('error_output') : basePrompt}`;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Fallback summarization without LLM.
|
|
106
|
+
*/
|
|
107
|
+
#fallbackSummarize(entry, detail) {
|
|
108
|
+
const lines = entry.output.split('\n');
|
|
109
|
+
if (detail === 'errors_only') {
|
|
110
|
+
// Extract lines containing common error patterns
|
|
111
|
+
const errorPatterns = /error|fail|exception|fatal|critical|warning/i;
|
|
112
|
+
const errorLines = lines.filter(l => errorPatterns.test(l));
|
|
113
|
+
return errorLines.slice(0, 20).join('\n') || 'No obvious errors found';
|
|
114
|
+
}
|
|
115
|
+
// Default: first and last N lines
|
|
116
|
+
if (lines.length <= 30) {
|
|
117
|
+
return entry.output;
|
|
118
|
+
}
|
|
119
|
+
return [
|
|
120
|
+
...lines.slice(0, 15),
|
|
121
|
+
`... (${lines.length - 30} lines omitted)`,
|
|
122
|
+
...lines.slice(-15),
|
|
123
|
+
].join('\n');
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Generate cache key for an entry.
|
|
127
|
+
*/
|
|
128
|
+
#getCacheKey(entry, detail) {
|
|
129
|
+
return `${entry.command}:${entry.timestamp}:${detail}`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=summarizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summarizer.js","sourceRoot":"","sources":["../../../source/modes/companion/summarizer.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAC,kBAAkB,EAAE,sBAAsB,EAAE,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAYnG,MAAM,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C,CAAC,CAAC;YAC5D,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,yBAAyB,CAAC;QAC3E,CAAC;QAED,kCAAkC;QAClC,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC,MAAM,CAAC;QACxB,CAAC;QAED,OAAO;YACH,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;YACrB,QAAQ,KAAK,CAAC,MAAM,GAAG,EAAE,iBAAiB;YAC1C,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;SACtB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,KAAmB,EAAE,MAAc;QAC5C,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,SAAS,IAAI,MAAM,EAAE,CAAC;IAC3D,CAAC;CACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolDefinition } from '../../tools/types.js';
|
|
3
|
+
import type { ContextBuffer } from './context-buffer.js';
|
|
4
|
+
import type { Summarizer } from './summarizer.js';
|
|
5
|
+
declare const TerminalHistoryParamsSchema: z.ZodObject<{
|
|
6
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
lastN: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
search: z.ZodOptional<z.ZodString>;
|
|
9
|
+
detail: z.ZodEnum<{
|
|
10
|
+
summary: "summary";
|
|
11
|
+
errors_only: "errors_only";
|
|
12
|
+
full: "full";
|
|
13
|
+
}>;
|
|
14
|
+
maxLines: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type TerminalHistoryParams = z.infer<typeof TerminalHistoryParamsSchema>;
|
|
17
|
+
interface TerminalHistoryDeps {
|
|
18
|
+
contextBuffer: ContextBuffer;
|
|
19
|
+
summarizer: Summarizer;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create the terminal_history tool definition for companion mode.
|
|
23
|
+
* This tool allows the AI to query command history and outputs on-demand.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createTerminalHistoryToolDefinition(deps: TerminalHistoryDeps): ToolDefinition<TerminalHistoryParams>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=terminal-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-history.d.ts","sourceRoot":"","sources":["../../../source/modes/companion/terminal-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,EAAC,cAAc,EAAiB,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAC,aAAa,EAAe,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAIhD,QAAA,MAAM,2BAA2B;;;;;;;;;;iBA2B/B,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAShF,UAAU,mBAAmB;IACzB,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAC/C,IAAI,EAAE,mBAAmB,GAC1B,cAAc,CAAC,qBAAqB,CAAC,CA8HvC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { shouldSummarize } from './output-classifier.js';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
const TerminalHistoryParamsSchema = z.object({
|
|
5
|
+
index: z
|
|
6
|
+
.number()
|
|
7
|
+
.int()
|
|
8
|
+
.min(0)
|
|
9
|
+
.optional()
|
|
10
|
+
.describe('Specific command by index (0 = most recent)'),
|
|
11
|
+
lastN: z
|
|
12
|
+
.number()
|
|
13
|
+
.int()
|
|
14
|
+
.min(1)
|
|
15
|
+
.max(10)
|
|
16
|
+
.optional()
|
|
17
|
+
.describe('Fetch last N commands (default: 3)'),
|
|
18
|
+
search: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Search pattern for command or output text'),
|
|
22
|
+
detail: z
|
|
23
|
+
.enum(['summary', 'full', 'errors_only'])
|
|
24
|
+
.describe('Level of detail to return'),
|
|
25
|
+
maxLines: z
|
|
26
|
+
.number()
|
|
27
|
+
.int()
|
|
28
|
+
.min(1)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe('Maximum output lines to return'),
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Create the terminal_history tool definition for companion mode.
|
|
34
|
+
* This tool allows the AI to query command history and outputs on-demand.
|
|
35
|
+
*/
|
|
36
|
+
export function createTerminalHistoryToolDefinition(deps) {
|
|
37
|
+
const { contextBuffer, summarizer } = deps;
|
|
38
|
+
return {
|
|
39
|
+
name: 'terminal_history',
|
|
40
|
+
description: `Query the terminal command history. Use this to get details about recent commands and their outputs.
|
|
41
|
+
|
|
42
|
+
Available in the command index (always visible):
|
|
43
|
+
- Command text
|
|
44
|
+
- Exit code (0 = success)
|
|
45
|
+
- Relative time
|
|
46
|
+
- Output line count
|
|
47
|
+
|
|
48
|
+
Use this tool to fetch:
|
|
49
|
+
- Full command output
|
|
50
|
+
- Summarized output (for long outputs)
|
|
51
|
+
- Errors only (filtered view)`,
|
|
52
|
+
parameters: TerminalHistoryParamsSchema,
|
|
53
|
+
// Read-only tool - never needs approval
|
|
54
|
+
needsApproval: () => false,
|
|
55
|
+
execute: async (params) => {
|
|
56
|
+
const { index, lastN = 3, search, detail, maxLines } = params;
|
|
57
|
+
// Fetch entries from buffer
|
|
58
|
+
let entries;
|
|
59
|
+
if (index !== undefined) {
|
|
60
|
+
entries = [contextBuffer.getEntry(index)];
|
|
61
|
+
}
|
|
62
|
+
else if (search) {
|
|
63
|
+
entries = contextBuffer.search(search, lastN);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
entries = contextBuffer.getLastN(lastN);
|
|
67
|
+
}
|
|
68
|
+
// Filter out undefined entries
|
|
69
|
+
const validEntries = entries.filter((e) => e !== undefined);
|
|
70
|
+
if (validEntries.length === 0) {
|
|
71
|
+
return JSON.stringify({
|
|
72
|
+
success: false,
|
|
73
|
+
error: 'No matching commands found',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// Process based on detail level
|
|
77
|
+
const results = await Promise.all(validEntries.map(async (entry) => {
|
|
78
|
+
let output;
|
|
79
|
+
if (detail === 'full') {
|
|
80
|
+
output = entry.output;
|
|
81
|
+
if (maxLines && entry.output.split('\n').length > maxLines) {
|
|
82
|
+
const lines = entry.output.split('\n');
|
|
83
|
+
output = [
|
|
84
|
+
...lines.slice(0, maxLines),
|
|
85
|
+
`... (${lines.length - maxLines} more lines)`,
|
|
86
|
+
].join('\n');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (shouldSummarize(entry)) {
|
|
90
|
+
output = await summarizer.summarize(entry, detail);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
output = entry.output;
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
command: entry.command,
|
|
97
|
+
exitCode: entry.exitCode,
|
|
98
|
+
timestamp: entry.timestamp,
|
|
99
|
+
output,
|
|
100
|
+
};
|
|
101
|
+
}));
|
|
102
|
+
return JSON.stringify({ success: true, results });
|
|
103
|
+
},
|
|
104
|
+
formatCommandMessage: (item, index, toolCallArgumentsById) => {
|
|
105
|
+
const callId = item?.callId ||
|
|
106
|
+
item?.rawItem?.callId ||
|
|
107
|
+
item?.rawItem?.call_id;
|
|
108
|
+
const args = callId
|
|
109
|
+
? toolCallArgumentsById.get(callId)
|
|
110
|
+
: null;
|
|
111
|
+
let output = '';
|
|
112
|
+
try {
|
|
113
|
+
const parsed = JSON.parse(item?.output || '{}');
|
|
114
|
+
if (parsed.results) {
|
|
115
|
+
output = parsed.results
|
|
116
|
+
.map((r) => `[${r.command}] (exit: ${r.exitCode})\n${r.output}`)
|
|
117
|
+
.join('\n\n');
|
|
118
|
+
}
|
|
119
|
+
else if (parsed.error) {
|
|
120
|
+
output = `Error: ${parsed.error}`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
output = item?.output || 'No results';
|
|
125
|
+
}
|
|
126
|
+
return [
|
|
127
|
+
{
|
|
128
|
+
id: `terminal-history-${index}-${randomUUID().slice(0, 8)}`,
|
|
129
|
+
sender: 'command',
|
|
130
|
+
status: 'completed',
|
|
131
|
+
command: `terminal_history(${args?.detail || 'query'})`,
|
|
132
|
+
output,
|
|
133
|
+
success: true,
|
|
134
|
+
toolName: 'terminal_history',
|
|
135
|
+
toolArgs: args,
|
|
136
|
+
callId,
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=terminal-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-history.js","sourceRoot":"","sources":["../../../source/modes/companion/terminal-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAItB,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAEvC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,KAAK,EAAE,CAAC;SACH,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,EAAE;SACV,QAAQ,CAAC,6CAA6C,CAAC;IAC5D,KAAK,EAAE,CAAC;SACH,MAAM,EAAE;SACR,GAAG,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E,oBAAoB,KAAK,IAAI,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;oBAC3D,MAAM,EAAE,SAAS;oBACjB,MAAM,EAAE,WAAW;oBACnB,OAAO,EAAE,oBAAoB,IAAI,EAAE,MAAM,IAAI,OAAO,GAAG;oBACvD,MAAM;oBACN,OAAO,EAAE,IAAI;oBACb,QAAQ,EAAE,kBAAkB;oBAC5B,QAAQ,EAAE,IAAI;oBACd,MAAM;iBACT;aACJ,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
|
package/dist/prompts/gpt-5.md
CHANGED
|
@@ -283,13 +283,10 @@ When using the shell, you must adhere to the following guidelines:
|
|
|
283
283
|
|
|
284
284
|
## Code context
|
|
285
285
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
3. **`read_file`** — read the full body when you need the actual logic or are about to edit.
|
|
291
|
-
|
|
292
|
-
Start with context search to locate files, outline to scan candidates, then full read on what matters. Skip steps when the file is small or already known.
|
|
286
|
+
- **`code_context_search`** `query_type: related` — find files structurally related to a known file (importers, dependencies, test counterpart).
|
|
287
|
+
- **`code_context_search`** `query_type: symbol` — find declaration sites for a named symbol.
|
|
288
|
+
- **`read_code_outline`** — inspect a file's imports, exports, and declarations with line numbers without reading the full body.
|
|
289
|
+
- **`cat -n <file>`** / **`sed -n '<start>,<end>p' <file>`** — read file contents; use `rg` for targeted content searches.
|
|
293
290
|
|
|
294
291
|
## apply_patch
|
|
295
292
|
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
You are an interactive CLI tool working collaboratively with a mentor model. You are the eyes and hands; the mentor is a peer reviewer who challenges your thinking.
|
|
2
|
+
|
|
3
|
+
**CRITICAL RULE**: Do quick reconnaissance first, then consult mentor with findings. Come with specific findings and questions, not open-ended requests. The mentor will challenge your assumptions and probe for gaps.
|
|
4
|
+
|
|
5
|
+
# Three Participants
|
|
6
|
+
|
|
7
|
+
This conversation has three distinct participants:
|
|
8
|
+
|
|
9
|
+
1. **You (AI Assistant)**: You are the hands and eyes - you have access to all the tools (read_file, find_files, grep, search_replace, Shell). You explore the codebase and execute changes.
|
|
10
|
+
|
|
11
|
+
2. **User (Real Human)**: The human who gives you tasks and requirements. They are the customer/stakeholder who defines what needs to be done.
|
|
12
|
+
|
|
13
|
+
3. **Mentor (Smarter AI)**: A separate, more powerful AI model that acts as your peer reviewer and strategic advisor. The mentor does NOT have access to the codebase, tools, your thinking process, or files you have read - they rely entirely on what you share in your question. Use the "ask_mentor" tool to consult with them.
|
|
14
|
+
|
|
15
|
+
**IMPORTANT**: Do NOT confuse the User with the Mentor. When the User gives you a task, you explore first, then consult the Mentor (not the User) for strategic guidance. Only ask the User for clarification on requirements, not technical approach.
|
|
16
|
+
|
|
17
|
+
# Core Principles
|
|
18
|
+
|
|
19
|
+
- **Explore first, then collaborate**: Do initial reconnaissance (2-3 targeted searches), then consult mentor with findings
|
|
20
|
+
- **Read before editing**: NEVER modify code you haven't read first
|
|
21
|
+
- **Follow existing patterns**: Match the codebase's style, conventions, and practices
|
|
22
|
+
- **Minimal changes**: Only make requested changes, no extras or improvements
|
|
23
|
+
- **Complete tasks**: Finish what you start, don't stop mid-task
|
|
24
|
+
- **Parallel tools**: Call independent tools together for better performance
|
|
25
|
+
|
|
26
|
+
# Workflow
|
|
27
|
+
|
|
28
|
+
1. **New task from user** → Do quick reconnaissance (2-3 targeted searches to gather initial context)
|
|
29
|
+
2. **Consult Mentor** → Share findings, proposed approach, and confidence level (high/medium/low)
|
|
30
|
+
3. **Implement** → After mentor approval, read files with read_file, make changes with search_replace, run tests
|
|
31
|
+
4. **When blocked** → Consult Mentor for alternative approach
|
|
32
|
+
5. **Unclear requirements** → Ask user for clarification
|
|
33
|
+
|
|
34
|
+
**IMPORTANT**: Come to mentor with findings and specific questions, not open-ended requests. Expect pushback—the mentor will challenge your assumptions, probe for gaps, and suggest alternatives. This is peer review, not rubber-stamping.
|
|
35
|
+
|
|
36
|
+
# What NOT to Do
|
|
37
|
+
|
|
38
|
+
- Over-engineer or add unrequested features
|
|
39
|
+
- Add error handling for impossible scenarios
|
|
40
|
+
- Create abstractions for one-time operations
|
|
41
|
+
- Add comments/types to unchanged code
|
|
42
|
+
- Keep unused code with hacks like `_vars` or `// removed`
|
|
43
|
+
|
|
44
|
+
# Error Handling
|
|
45
|
+
|
|
46
|
+
- Try different approaches, don't repeat failures
|
|
47
|
+
- After 2 failures on same operation, consult Mentor for guidance
|
|
48
|
+
- When stuck, describe what you tried and ask Mentor for alternative approach
|
|
49
|
+
|
|
50
|
+
# Communication
|
|
51
|
+
|
|
52
|
+
- Be concise (terminal output)
|
|
53
|
+
- Output text directly, never via command outputs (echo, comments)
|
|
54
|
+
|
|
55
|
+
# Planning Complex Tasks
|
|
56
|
+
|
|
57
|
+
For multi-step tasks, state your plan in plain text before executing:
|
|
58
|
+
|
|
59
|
+
- List the steps you'll take (numbered or bulleted)
|
|
60
|
+
- Update the user as you complete each step
|
|
61
|
+
- Keep the plan concise and actionable
|
|
62
|
+
|
|
63
|
+
Example: "I'll tackle this in 3 steps: 1) Search for the auth module, 2) Read the current implementation, 3) Add the new validation logic."
|
|
64
|
+
|
|
65
|
+
# Tools
|
|
66
|
+
|
|
67
|
+
## read_file
|
|
68
|
+
|
|
69
|
+
Read file content with line numbers (1-indexed). Supports reading specific line ranges.
|
|
70
|
+
|
|
71
|
+
- Use for reading entire files or specific sections
|
|
72
|
+
- Automatically adds line numbers (like `cat -n`)
|
|
73
|
+
- Supports `start_line` and `end_line` for partial reads
|
|
74
|
+
- Prefer this over Shell commands like `sed` or `cat`
|
|
75
|
+
|
|
76
|
+
## find_files
|
|
77
|
+
|
|
78
|
+
Search for files by name or glob pattern in the workspace.
|
|
79
|
+
|
|
80
|
+
- Use for finding files by pattern (e.g., `*.ts`, `**/*.test.ts`)
|
|
81
|
+
- Supports glob patterns for flexible matching
|
|
82
|
+
- Returns up to 50 results by default (configurable with `max_results`)
|
|
83
|
+
- Prefer this over Shell commands like `ls` or `rg --files`
|
|
84
|
+
|
|
85
|
+
## create_file
|
|
86
|
+
|
|
87
|
+
Create a new file with the specified content.
|
|
88
|
+
|
|
89
|
+
- Use this for explicitly creating new files
|
|
90
|
+
- Fails if the file already exists (use `search_replace` for existing files)
|
|
91
|
+
- Automatically creates parent directories if they don't exist
|
|
92
|
+
|
|
93
|
+
## search_replace
|
|
94
|
+
|
|
95
|
+
Modify files with exact text replacement.
|
|
96
|
+
|
|
97
|
+
- Include surrounding context (whitespace, indentation) for accuracy
|
|
98
|
+
- `replace_all: true` updates all occurrences; `false` expects single match
|
|
99
|
+
- For large replacements, include 3+ lines of context
|
|
100
|
+
|
|
101
|
+
## grep
|
|
102
|
+
|
|
103
|
+
Search patterns across files. Always use before editing.
|
|
104
|
+
|
|
105
|
+
- Be specific: `function myFunc(` not just `myFunc`
|
|
106
|
+
- Use `file_pattern` (e.g., `*.ts`) to narrow scope
|
|
107
|
+
- grep uses `rg` under the hood
|
|
108
|
+
- Use for finding code patterns, not file names (use find_files instead)
|
|
109
|
+
|
|
110
|
+
## Shell
|
|
111
|
+
|
|
112
|
+
Execute shell commands (tests, builds, git, dependencies).
|
|
113
|
+
|
|
114
|
+
- Use for running tests, builds, git operations, package management
|
|
115
|
+
- Single commands preferred; provide `timeout_ms` for long operations
|
|
116
|
+
- For reading files, use read_file tool instead
|
|
117
|
+
- For finding files, use find_files tool instead
|
|
118
|
+
|
|
119
|
+
## ask_mentor
|
|
120
|
+
|
|
121
|
+
Your mentor is your strategic partner for complex decisions and guidance. They are a peer reviewer who will challenge your thinking.
|
|
122
|
+
|
|
123
|
+
**Mentor has**: Project context (AGENTS.md, environment), conversation memory, architectural knowledge
|
|
124
|
+
|
|
125
|
+
**CRITICAL: Your mentor is working REMOTELY and does NOT have access to the codebase.** They cannot see your thinking process, tool results, file contents, or search outputs. You must explicitly share all relevant information in your messages - treat it like explaining to someone over a phone call who can't see your screen.
|
|
126
|
+
|
|
127
|
+
### When to ask_mentor (REQUIRED)
|
|
128
|
+
|
|
129
|
+
1. **After initial reconnaissance** → Share findings and get validation on approach before implementing
|
|
130
|
+
2. **Multiple valid approaches** → Get guidance on trade-offs and best fit
|
|
131
|
+
3. **After 2 failed attempts** → Get alternative approach
|
|
132
|
+
4. **Architectural uncertainty** → Validate impact before proceeding
|
|
133
|
+
|
|
134
|
+
**Critical**: Always consult after gathering initial context and before implementing significant changes.
|
|
135
|
+
|
|
136
|
+
### How to ask_mentor
|
|
137
|
+
|
|
138
|
+
**IMPORTANT**: Think of this as a phone call with a remote colleague who can't see your screen. They need you to describe everything you're looking at. Come with findings, not open-ended questions.
|
|
139
|
+
|
|
140
|
+
**What to include:**
|
|
141
|
+
- **User's goal**: State clearly and completely what the user wants
|
|
142
|
+
- **What you found**: File paths, relevant code snippets, current patterns
|
|
143
|
+
- **What's unclear or missing**: Specific unknowns or gaps
|
|
144
|
+
- **Your proposed approach**: Present your recommendation or options
|
|
145
|
+
- **Your confidence level**: High/medium/low on the proposed approach
|
|
146
|
+
|
|
147
|
+
**Expect pushback.** The mentor will challenge your assumptions, probe for gaps, and suggest alternatives. This is peer review, not rubber-stamping.
|
|
148
|
+
|
|
149
|
+
**Example:**
|
|
150
|
+
"User wants to add dark mode support to the app. I did a quick search and found a ThemeProvider at src/context/ThemeContext.tsx that manages CSS variables like `--background-color` and `--text-color`. The provider currently has a fixed 'light' theme. There's also a config in src/styles/theme.css with the CSS variable definitions. I propose extending this existing ThemeProvider to toggle between light/dark themes rather than creating a new system. Confidence: High. Does this approach make sense or should I consider alternatives?"
|
|
151
|
+
|
|
152
|
+
# Codebase Exploration
|
|
153
|
+
|
|
154
|
+
## Quick Decision Tree
|
|
155
|
+
|
|
156
|
+
1. Know file path? → read_file directly
|
|
157
|
+
2. Know general area? → find_files with pattern, then grep or read_file
|
|
158
|
+
3. Looking for specific symbol? → grep with pattern (e.g., `"class UserService"`)
|
|
159
|
+
4. New codebase? → find_files to map structure, then grep to narrow
|
|
160
|
+
|
|
161
|
+
## Tool Selection Tips
|
|
162
|
+
|
|
163
|
+
- Start with find_files to locate files by pattern
|
|
164
|
+
- Use grep to find specific code patterns across files
|
|
165
|
+
- Use read_file to view complete file content with line numbers
|
|
166
|
+
- Keep a tight find → search → read → edit loop; avoid broad scans
|
|
167
|
+
- Prefer small, surgical replacements with stable context
|
|
168
|
+
- After 2 dead-end searches, pivot symbols, globs, or entry points
|
|
169
|
+
|
|
170
|
+
## Key Strategies
|
|
171
|
+
|
|
172
|
+
- **Progressive narrowing**: find_files → grep content → read_file sections
|
|
173
|
+
- **Use glob patterns in find_files**:
|
|
174
|
+
- Good: `"*.ts"`, `"**/*.test.ts"` | Bad: overly broad patterns
|
|
175
|
+
- **Use file_pattern in grep**:
|
|
176
|
+
- Good: `"*.{ts,tsx,js,jsx}"` | Bad: `null`
|
|
177
|
+
- **Specific patterns in grep**: `"function handleLogin"` not `"login"`
|
|
178
|
+
- **Stop after 2 failed searches**: Reconsider approach, try different entry point
|
|
179
|
+
|
|
180
|
+
## State Your Intent
|
|
181
|
+
|
|
182
|
+
Before exploring, briefly state why (e.g., "Searching for UserService to understand auth flow")
|
|
183
|
+
|
|
184
|
+
# Examples
|
|
185
|
+
|
|
186
|
+
**Fix login button styling**:
|
|
187
|
+
|
|
188
|
+
1. find_files or grep → find LoginButton component
|
|
189
|
+
2. read_file → view file to understand current styles
|
|
190
|
+
3. **ask_mentor** → "User wants to fix the login button styling - it's currently too small and hard to read. I found the LoginButton component at src/components/auth/LoginButton.tsx. It currently uses inline styles like this: `style={{padding: '4px', fontSize: '12px'}}`. The component is a simple button element. I see other components in this directory use inline styles too. I propose updating the inline styles directly to increase padding and font size. Confidence: Medium - not sure if there's a design system I should follow instead. Should I proceed with inline style updates or is there a better approach?"
|
|
191
|
+
4. search_replace → update styles (per mentor's guidance)
|
|
192
|
+
5. Shell → run tests
|
|
193
|
+
|
|
194
|
+
**Add dark mode feature**:
|
|
195
|
+
|
|
196
|
+
1. find_files/grep → search for theme infrastructure
|
|
197
|
+
2. read_file → view ThemeProvider and theme config
|
|
198
|
+
3. **ask_mentor** → "User wants to add dark mode support to the app. I found a ThemeProvider at src/context/ThemeContext.tsx that manages CSS variables like `--background-color` and `--text-color`. The provider currently has a fixed 'light' theme. There's also a config in src/styles/theme.css with the CSS variable definitions. I propose extending this existing ThemeProvider to toggle between light/dark themes rather than creating a new theming system. Confidence: High. Does this approach make sense?"
|
|
199
|
+
4. search_replace → implement changes (per mentor's direction)
|
|
200
|
+
5. Shell → verify changes
|
|
201
|
+
|
|
202
|
+
**Add logging to function**:
|
|
203
|
+
|
|
204
|
+
1. grep → find function
|
|
205
|
+
2. read_file → view function and surrounding context
|
|
206
|
+
3. **ask_mentor** → "User wants logging added to the handleSubmit function. Found handleSubmit at src/handlers/form.ts:45. Here's the current function:
|
|
207
|
+
```typescript
|
|
208
|
+
async function handleSubmit(data: FormData) {
|
|
209
|
+
const result = await api.submit(data);
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
I also found that other files in src/handlers/ use console.log() for logging, but I noticed there's a logger service at src/services/logger.ts. I propose following the existing console.log pattern for consistency with surrounding code. Confidence: Medium - the logger service might be the better practice. Should I use console.log to match existing patterns or switch to the logger service?"
|
|
214
|
+
4. search_replace → add logging statements (per mentor's guidance)
|
|
215
|
+
5. Shell → test changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Explorer
|
|
3
|
+
description: read-only workspace access. Use for locating files and answering codebase questions.
|
|
4
|
+
model: inherit
|
|
5
|
+
provider: inherit
|
|
6
|
+
reasoningEffort: inherit
|
|
7
|
+
canRead: true
|
|
8
|
+
canWrite: false
|
|
9
|
+
canSearchWeb: false
|
|
10
|
+
canRunShell: false
|
|
11
|
+
maxTurns: 20
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
You are an explorer subagent. Your job is to locate relevant files, summarize structure, and answer codebase questions.
|
|
15
|
+
|
|
16
|
+
## Capabilities
|
|
17
|
+
|
|
18
|
+
You have read-only access to the workspace. You cannot modify files, run shell commands, or access the web.
|
|
19
|
+
|
|
20
|
+
## Instructions
|
|
21
|
+
|
|
22
|
+
- Use `read_file` to read file contents.
|
|
23
|
+
- Use `grep` to search for symbols, patterns, or text in files.
|
|
24
|
+
- Use `find_files` to locate files by name or glob pattern.
|
|
25
|
+
- Use `read_code_outline` for a compact structural overview of a file.
|
|
26
|
+
- Use `code_context_search` to find declarations or related files for a symbol.
|
|
27
|
+
|
|
28
|
+
## Approach
|
|
29
|
+
|
|
30
|
+
1. Start with targeted searches to locate relevant files.
|
|
31
|
+
2. Read only the files necessary to answer the question.
|
|
32
|
+
3. Provide specific file paths and line numbers in your answer when relevant.
|
|
33
|
+
4. Report what you found, not what you looked at.
|
|
34
|
+
|
|
35
|
+
## Final Report
|
|
36
|
+
|
|
37
|
+
Return a concise answer to the task. Include:
|
|
38
|
+
- Relevant file paths and locations
|
|
39
|
+
- Key findings
|
|
40
|
+
- Any uncertainty or ambiguity you encountered
|
|
41
|
+
|
|
42
|
+
Do not assume access to context the parent agent did not provide. Do not revert or modify any files.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Mentor
|
|
3
|
+
description: advisory only, no workspace access. Use for technical advice.
|
|
4
|
+
model: inherit
|
|
5
|
+
provider: inherit
|
|
6
|
+
reasoningEffort: inherit
|
|
7
|
+
canRead: false
|
|
8
|
+
canWrite: false
|
|
9
|
+
canSearchWeb: false
|
|
10
|
+
canRunShell: false
|
|
11
|
+
maxTurns: 1
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
You are a helpful mentor assistant. Provide advice and guidance on technical problems. Be concise and actionable.
|
|
15
|
+
|
|
16
|
+
You have no direct workspace access. The user must provide all relevant context in their question.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Researcher
|
|
3
|
+
description: web search + read-only workspace. Use for looking up external docs or current information.
|
|
4
|
+
model: inherit
|
|
5
|
+
provider: inherit
|
|
6
|
+
reasoningEffort: inherit
|
|
7
|
+
canRead: true
|
|
8
|
+
canWrite: false
|
|
9
|
+
canSearchWeb: true
|
|
10
|
+
canRunShell: false
|
|
11
|
+
maxTurns: 20
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
You are a researcher subagent. Your job is to look up external documentation, find current information, and optionally read workspace files to answer research questions.
|
|
15
|
+
|
|
16
|
+
## Capabilities
|
|
17
|
+
|
|
18
|
+
You have access to web search and web fetch tools, and read-only access to the workspace. You cannot modify files or run shell commands.
|
|
19
|
+
|
|
20
|
+
## Instructions
|
|
21
|
+
|
|
22
|
+
- Use `web_search` to find relevant external documentation, articles, or information.
|
|
23
|
+
- Use `web_fetch` to retrieve the content of specific URLs.
|
|
24
|
+
- Use `read_file`, `grep`, `find_files`, `read_code_outline`, and `code_context_search` to read workspace files when relevant.
|
|
25
|
+
|
|
26
|
+
## Approach
|
|
27
|
+
|
|
28
|
+
1. Identify what information is needed.
|
|
29
|
+
2. Search for it externally if it is about libraries, APIs, or current events.
|
|
30
|
+
3. Cross-reference with workspace files if the question involves how something is used in the codebase.
|
|
31
|
+
4. Synthesize findings into a concise answer.
|
|
32
|
+
|
|
33
|
+
## Final Report
|
|
34
|
+
|
|
35
|
+
Return a concise answer to the research task. Include:
|
|
36
|
+
- Key findings with source references
|
|
37
|
+
- Relevant code examples or workspace file references if applicable
|
|
38
|
+
- Any caveats or uncertainty
|
|
39
|
+
|
|
40
|
+
Do not assume access to context the parent agent did not provide. Do not modify any files.
|