qlogicagent 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/dist/agent/agent.d.ts +44 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.js +114 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/tool-loop.d.ts +65 -0
- package/dist/agent/tool-loop.d.ts.map +1 -0
- package/dist/agent/tool-loop.js +576 -0
- package/dist/agent/tool-loop.js.map +1 -0
- package/dist/agent/types.d.ts +176 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +15 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/cli/main.d.ts +12 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +24 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/stdio-server.d.ts +46 -0
- package/dist/cli/stdio-server.d.ts.map +1 -0
- package/dist/cli/stdio-server.js +464 -0
- package/dist/cli/stdio-server.js.map +1 -0
- package/dist/config/config.d.ts +18 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +22 -0
- package/dist/config/config.js.map +1 -0
- package/dist/contracts/hooks.d.ts +121 -0
- package/dist/contracts/hooks.d.ts.map +1 -0
- package/dist/contracts/hooks.js +8 -0
- package/dist/contracts/hooks.js.map +1 -0
- package/dist/contracts/index.d.ts +11 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +11 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/planner.d.ts +36 -0
- package/dist/contracts/planner.d.ts.map +1 -0
- package/dist/contracts/planner.js +3 -0
- package/dist/contracts/planner.js.map +1 -0
- package/dist/contracts/skill-candidate.d.ts +64 -0
- package/dist/contracts/skill-candidate.d.ts.map +1 -0
- package/dist/contracts/skill-candidate.js +196 -0
- package/dist/contracts/skill-candidate.js.map +1 -0
- package/dist/contracts/todo.d.ts +15 -0
- package/dist/contracts/todo.d.ts.map +1 -0
- package/dist/contracts/todo.js +10 -0
- package/dist/contracts/todo.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/builtin-providers.d.ts +11 -0
- package/dist/llm/builtin-providers.d.ts.map +1 -0
- package/dist/llm/builtin-providers.js +532 -0
- package/dist/llm/builtin-providers.js.map +1 -0
- package/dist/llm/index.d.ts +16 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +15 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/llm-client.d.ts +44 -0
- package/dist/llm/llm-client.d.ts.map +1 -0
- package/dist/llm/llm-client.js +68 -0
- package/dist/llm/llm-client.js.map +1 -0
- package/dist/llm/model-catalog.d.ts +54 -0
- package/dist/llm/model-catalog.d.ts.map +1 -0
- package/dist/llm/model-catalog.js +192 -0
- package/dist/llm/model-catalog.js.map +1 -0
- package/dist/llm/provider-def.d.ts +60 -0
- package/dist/llm/provider-def.d.ts.map +1 -0
- package/dist/llm/provider-def.js +13 -0
- package/dist/llm/provider-def.js.map +1 -0
- package/dist/llm/provider-registry.d.ts +55 -0
- package/dist/llm/provider-registry.d.ts.map +1 -0
- package/dist/llm/provider-registry.js +148 -0
- package/dist/llm/provider-registry.js.map +1 -0
- package/dist/llm/transport.d.ts +63 -0
- package/dist/llm/transport.d.ts.map +1 -0
- package/dist/llm/transport.js +28 -0
- package/dist/llm/transport.js.map +1 -0
- package/dist/llm/transports/anthropic-messages.d.ts +32 -0
- package/dist/llm/transports/anthropic-messages.d.ts.map +1 -0
- package/dist/llm/transports/anthropic-messages.js +294 -0
- package/dist/llm/transports/anthropic-messages.js.map +1 -0
- package/dist/llm/transports/openai-chat.d.ts +37 -0
- package/dist/llm/transports/openai-chat.d.ts.map +1 -0
- package/dist/llm/transports/openai-chat.js +166 -0
- package/dist/llm/transports/openai-chat.js.map +1 -0
- package/dist/orchestration/agent-registry.d.ts +42 -0
- package/dist/orchestration/agent-registry.d.ts.map +1 -0
- package/dist/orchestration/agent-registry.js +117 -0
- package/dist/orchestration/agent-registry.js.map +1 -0
- package/dist/orchestration/approval-aware-tool-plan.d.ts +33 -0
- package/dist/orchestration/approval-aware-tool-plan.d.ts.map +1 -0
- package/dist/orchestration/approval-aware-tool-plan.js +88 -0
- package/dist/orchestration/approval-aware-tool-plan.js.map +1 -0
- package/dist/orchestration/context-compression.d.ts +221 -0
- package/dist/orchestration/context-compression.d.ts.map +1 -0
- package/dist/orchestration/context-compression.js +584 -0
- package/dist/orchestration/context-compression.js.map +1 -0
- package/dist/orchestration/conversation-repair.d.ts +62 -0
- package/dist/orchestration/conversation-repair.d.ts.map +1 -0
- package/dist/orchestration/conversation-repair.js +430 -0
- package/dist/orchestration/conversation-repair.js.map +1 -0
- package/dist/orchestration/curator-scheduler.d.ts +120 -0
- package/dist/orchestration/curator-scheduler.d.ts.map +1 -0
- package/dist/orchestration/curator-scheduler.js +136 -0
- package/dist/orchestration/curator-scheduler.js.map +1 -0
- package/dist/orchestration/embedded-failover-policy.d.ts +111 -0
- package/dist/orchestration/embedded-failover-policy.d.ts.map +1 -0
- package/dist/orchestration/embedded-failover-policy.js +169 -0
- package/dist/orchestration/embedded-failover-policy.js.map +1 -0
- package/dist/orchestration/error-classification.d.ts +13 -0
- package/dist/orchestration/error-classification.d.ts.map +1 -0
- package/dist/orchestration/error-classification.js +78 -0
- package/dist/orchestration/error-classification.js.map +1 -0
- package/dist/orchestration/failover-classification.d.ts +9 -0
- package/dist/orchestration/failover-classification.d.ts.map +1 -0
- package/dist/orchestration/failover-classification.js +382 -0
- package/dist/orchestration/failover-classification.js.map +1 -0
- package/dist/orchestration/failover-error.d.ts +34 -0
- package/dist/orchestration/failover-error.d.ts.map +1 -0
- package/dist/orchestration/failover-error.js +199 -0
- package/dist/orchestration/failover-error.js.map +1 -0
- package/dist/orchestration/fork-subagent.d.ts +101 -0
- package/dist/orchestration/fork-subagent.d.ts.map +1 -0
- package/dist/orchestration/fork-subagent.js +99 -0
- package/dist/orchestration/fork-subagent.js.map +1 -0
- package/dist/orchestration/index.d.ts +121 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +268 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/memory-flush-policy.d.ts +58 -0
- package/dist/orchestration/memory-flush-policy.d.ts.map +1 -0
- package/dist/orchestration/memory-flush-policy.js +86 -0
- package/dist/orchestration/memory-flush-policy.js.map +1 -0
- package/dist/orchestration/memory-provider.d.ts +15 -0
- package/dist/orchestration/memory-provider.d.ts.map +1 -0
- package/dist/orchestration/memory-provider.js +3 -0
- package/dist/orchestration/memory-provider.js.map +1 -0
- package/dist/orchestration/parallel-tool-calls.d.ts +42 -0
- package/dist/orchestration/parallel-tool-calls.d.ts.map +1 -0
- package/dist/orchestration/parallel-tool-calls.js +60 -0
- package/dist/orchestration/parallel-tool-calls.js.map +1 -0
- package/dist/orchestration/prompt-cache-strategy.d.ts +127 -0
- package/dist/orchestration/prompt-cache-strategy.d.ts.map +1 -0
- package/dist/orchestration/prompt-cache-strategy.js +229 -0
- package/dist/orchestration/prompt-cache-strategy.js.map +1 -0
- package/dist/orchestration/reactive-compact.d.ts +74 -0
- package/dist/orchestration/reactive-compact.d.ts.map +1 -0
- package/dist/orchestration/reactive-compact.js +79 -0
- package/dist/orchestration/reactive-compact.js.map +1 -0
- package/dist/orchestration/retry-loop.d.ts +23 -0
- package/dist/orchestration/retry-loop.d.ts.map +1 -0
- package/dist/orchestration/retry-loop.js +25 -0
- package/dist/orchestration/retry-loop.js.map +1 -0
- package/dist/orchestration/skill-candidate.d.ts +53 -0
- package/dist/orchestration/skill-candidate.d.ts.map +1 -0
- package/dist/orchestration/skill-candidate.js +142 -0
- package/dist/orchestration/skill-candidate.js.map +1 -0
- package/dist/orchestration/skill-consolidation.d.ts +124 -0
- package/dist/orchestration/skill-consolidation.d.ts.map +1 -0
- package/dist/orchestration/skill-consolidation.js +221 -0
- package/dist/orchestration/skill-consolidation.js.map +1 -0
- package/dist/orchestration/skill-improvement.d.ts +60 -0
- package/dist/orchestration/skill-improvement.d.ts.map +1 -0
- package/dist/orchestration/skill-improvement.js +67 -0
- package/dist/orchestration/skill-improvement.js.map +1 -0
- package/dist/orchestration/skill-similarity.d.ts +99 -0
- package/dist/orchestration/skill-similarity.d.ts.map +1 -0
- package/dist/orchestration/skill-similarity.js +132 -0
- package/dist/orchestration/skill-similarity.js.map +1 -0
- package/dist/orchestration/streaming-tool-executor.d.ts +74 -0
- package/dist/orchestration/streaming-tool-executor.d.ts.map +1 -0
- package/dist/orchestration/streaming-tool-executor.js +97 -0
- package/dist/orchestration/streaming-tool-executor.js.map +1 -0
- package/dist/orchestration/team-orchestration.d.ts +196 -0
- package/dist/orchestration/team-orchestration.d.ts.map +1 -0
- package/dist/orchestration/team-orchestration.js +370 -0
- package/dist/orchestration/team-orchestration.js.map +1 -0
- package/dist/orchestration/team-tool-loop-wiring.d.ts +93 -0
- package/dist/orchestration/team-tool-loop-wiring.d.ts.map +1 -0
- package/dist/orchestration/team-tool-loop-wiring.js +148 -0
- package/dist/orchestration/team-tool-loop-wiring.js.map +1 -0
- package/dist/orchestration/tool-choice-policy.d.ts +55 -0
- package/dist/orchestration/tool-choice-policy.d.ts.map +1 -0
- package/dist/orchestration/tool-choice-policy.js +165 -0
- package/dist/orchestration/tool-choice-policy.js.map +1 -0
- package/dist/orchestration/tool-loop-state.d.ts +51 -0
- package/dist/orchestration/tool-loop-state.d.ts.map +1 -0
- package/dist/orchestration/tool-loop-state.js +134 -0
- package/dist/orchestration/tool-loop-state.js.map +1 -0
- package/dist/orchestration/tool-schema.d.ts +40 -0
- package/dist/orchestration/tool-schema.d.ts.map +1 -0
- package/dist/orchestration/tool-schema.js +298 -0
- package/dist/orchestration/tool-schema.js.map +1 -0
- package/dist/orchestration/transcript-repair.d.ts +43 -0
- package/dist/orchestration/transcript-repair.d.ts.map +1 -0
- package/dist/orchestration/transcript-repair.js +427 -0
- package/dist/orchestration/transcript-repair.js.map +1 -0
- package/dist/orchestration/turn-loop-guard.d.ts +87 -0
- package/dist/orchestration/turn-loop-guard.d.ts.map +1 -0
- package/dist/orchestration/turn-loop-guard.js +93 -0
- package/dist/orchestration/turn-loop-guard.js.map +1 -0
- package/dist/orchestration/web-browser-policy.d.ts +18 -0
- package/dist/orchestration/web-browser-policy.d.ts.map +1 -0
- package/dist/orchestration/web-browser-policy.js +40 -0
- package/dist/orchestration/web-browser-policy.js.map +1 -0
- package/dist/runtime/context-compression.d.ts +62 -0
- package/dist/runtime/context-compression.d.ts.map +1 -0
- package/dist/runtime/context-compression.js +275 -0
- package/dist/runtime/context-compression.js.map +1 -0
- package/dist/runtime/hook-registry.d.ts +13 -0
- package/dist/runtime/hook-registry.d.ts.map +1 -0
- package/dist/runtime/hook-registry.js +54 -0
- package/dist/runtime/hook-registry.js.map +1 -0
- package/dist/runtime/memory-hooks.d.ts +24 -0
- package/dist/runtime/memory-hooks.d.ts.map +1 -0
- package/dist/runtime/memory-hooks.js +66 -0
- package/dist/runtime/memory-hooks.js.map +1 -0
- package/dist/runtime/tool-eligibility.d.ts +60 -0
- package/dist/runtime/tool-eligibility.d.ts.map +1 -0
- package/dist/runtime/tool-eligibility.js +112 -0
- package/dist/runtime/tool-eligibility.js.map +1 -0
- package/dist/skills/index.d.ts +109 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +83 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/memory-extractor.d.ts +65 -0
- package/dist/skills/memory-extractor.d.ts.map +1 -0
- package/dist/skills/memory-extractor.js +174 -0
- package/dist/skills/memory-extractor.js.map +1 -0
- package/dist/skills/memory-query-tool.d.ts +44 -0
- package/dist/skills/memory-query-tool.d.ts.map +1 -0
- package/dist/skills/memory-query-tool.js +128 -0
- package/dist/skills/memory-query-tool.js.map +1 -0
- package/dist/skills/memory-store.d.ts +67 -0
- package/dist/skills/memory-store.d.ts.map +1 -0
- package/dist/skills/memory-store.js +229 -0
- package/dist/skills/memory-store.js.map +1 -0
- package/dist/skills/memory-tool.d.ts +68 -0
- package/dist/skills/memory-tool.d.ts.map +1 -0
- package/dist/skills/memory-tool.js +193 -0
- package/dist/skills/memory-tool.js.map +1 -0
- package/dist/skills/portable-tool.d.ts +72 -0
- package/dist/skills/portable-tool.d.ts.map +1 -0
- package/dist/skills/portable-tool.js +15 -0
- package/dist/skills/portable-tool.js.map +1 -0
- package/dist/skills/qmemory-adapter.d.ts +53 -0
- package/dist/skills/qmemory-adapter.d.ts.map +1 -0
- package/dist/skills/qmemory-adapter.js +166 -0
- package/dist/skills/qmemory-adapter.js.map +1 -0
- package/dist/skills/skill-frontmatter.d.ts +20 -0
- package/dist/skills/skill-frontmatter.d.ts.map +1 -0
- package/dist/skills/skill-frontmatter.js +345 -0
- package/dist/skills/skill-frontmatter.js.map +1 -0
- package/dist/skills/skill-guard.d.ts +24 -0
- package/dist/skills/skill-guard.d.ts.map +1 -0
- package/dist/skills/skill-guard.js +230 -0
- package/dist/skills/skill-guard.js.map +1 -0
- package/dist/skills/skill-loader.d.ts +17 -0
- package/dist/skills/skill-loader.d.ts.map +1 -0
- package/dist/skills/skill-loader.js +304 -0
- package/dist/skills/skill-loader.js.map +1 -0
- package/dist/skills/skill-source.d.ts +120 -0
- package/dist/skills/skill-source.d.ts.map +1 -0
- package/dist/skills/skill-source.js +127 -0
- package/dist/skills/skill-source.js.map +1 -0
- package/dist/skills/skill-types.d.ts +200 -0
- package/dist/skills/skill-types.d.ts.map +1 -0
- package/dist/skills/skill-types.js +7 -0
- package/dist/skills/skill-types.js.map +1 -0
- package/dist/skills/think-tool.d.ts +17 -0
- package/dist/skills/think-tool.d.ts.map +1 -0
- package/dist/skills/think-tool.js +60 -0
- package/dist/skills/think-tool.js.map +1 -0
- package/dist/skills/todo-tool.d.ts +64 -0
- package/dist/skills/todo-tool.d.ts.map +1 -0
- package/dist/skills/todo-tool.js +115 -0
- package/dist/skills/todo-tool.js.map +1 -0
- package/dist/skills/tools/agent-tool.d.ts +92 -0
- package/dist/skills/tools/agent-tool.d.ts.map +1 -0
- package/dist/skills/tools/agent-tool.js +143 -0
- package/dist/skills/tools/agent-tool.js.map +1 -0
- package/dist/skills/tools/apply-patch-tool.d.ts +30 -0
- package/dist/skills/tools/apply-patch-tool.d.ts.map +1 -0
- package/dist/skills/tools/apply-patch-tool.js +185 -0
- package/dist/skills/tools/apply-patch-tool.js.map +1 -0
- package/dist/skills/tools/ask-user-tool.d.ts +81 -0
- package/dist/skills/tools/ask-user-tool.d.ts.map +1 -0
- package/dist/skills/tools/ask-user-tool.js +122 -0
- package/dist/skills/tools/ask-user-tool.js.map +1 -0
- package/dist/skills/tools/brief-tool.d.ts +75 -0
- package/dist/skills/tools/brief-tool.d.ts.map +1 -0
- package/dist/skills/tools/brief-tool.js +96 -0
- package/dist/skills/tools/brief-tool.js.map +1 -0
- package/dist/skills/tools/browser-tool.d.ts +115 -0
- package/dist/skills/tools/browser-tool.d.ts.map +1 -0
- package/dist/skills/tools/browser-tool.js +156 -0
- package/dist/skills/tools/browser-tool.js.map +1 -0
- package/dist/skills/tools/checkpoint-tool.d.ts +67 -0
- package/dist/skills/tools/checkpoint-tool.d.ts.map +1 -0
- package/dist/skills/tools/checkpoint-tool.js +103 -0
- package/dist/skills/tools/checkpoint-tool.js.map +1 -0
- package/dist/skills/tools/config-tool.d.ts +64 -0
- package/dist/skills/tools/config-tool.d.ts.map +1 -0
- package/dist/skills/tools/config-tool.js +144 -0
- package/dist/skills/tools/config-tool.js.map +1 -0
- package/dist/skills/tools/cron-tool.d.ts +117 -0
- package/dist/skills/tools/cron-tool.d.ts.map +1 -0
- package/dist/skills/tools/cron-tool.js +176 -0
- package/dist/skills/tools/cron-tool.js.map +1 -0
- package/dist/skills/tools/edit-tool.d.ts +44 -0
- package/dist/skills/tools/edit-tool.d.ts.map +1 -0
- package/dist/skills/tools/edit-tool.js +71 -0
- package/dist/skills/tools/edit-tool.js.map +1 -0
- package/dist/skills/tools/exec-tool.d.ts +103 -0
- package/dist/skills/tools/exec-tool.d.ts.map +1 -0
- package/dist/skills/tools/exec-tool.js +134 -0
- package/dist/skills/tools/exec-tool.js.map +1 -0
- package/dist/skills/tools/image-generate-tool.d.ts +63 -0
- package/dist/skills/tools/image-generate-tool.d.ts.map +1 -0
- package/dist/skills/tools/image-generate-tool.js +68 -0
- package/dist/skills/tools/image-generate-tool.js.map +1 -0
- package/dist/skills/tools/instructions-tool.d.ts +104 -0
- package/dist/skills/tools/instructions-tool.d.ts.map +1 -0
- package/dist/skills/tools/instructions-tool.js +188 -0
- package/dist/skills/tools/instructions-tool.js.map +1 -0
- package/dist/skills/tools/lsp-tool.d.ts +154 -0
- package/dist/skills/tools/lsp-tool.d.ts.map +1 -0
- package/dist/skills/tools/lsp-tool.js +228 -0
- package/dist/skills/tools/lsp-tool.js.map +1 -0
- package/dist/skills/tools/mcp-client-types.d.ts +270 -0
- package/dist/skills/tools/mcp-client-types.d.ts.map +1 -0
- package/dist/skills/tools/mcp-client-types.js +54 -0
- package/dist/skills/tools/mcp-client-types.js.map +1 -0
- package/dist/skills/tools/mcp-tool.d.ts +250 -0
- package/dist/skills/tools/mcp-tool.d.ts.map +1 -0
- package/dist/skills/tools/mcp-tool.js +504 -0
- package/dist/skills/tools/mcp-tool.js.map +1 -0
- package/dist/skills/tools/memory-tool.d.ts +75 -0
- package/dist/skills/tools/memory-tool.d.ts.map +1 -0
- package/dist/skills/tools/memory-tool.js +89 -0
- package/dist/skills/tools/memory-tool.js.map +1 -0
- package/dist/skills/tools/monitor-tool.d.ts +114 -0
- package/dist/skills/tools/monitor-tool.d.ts.map +1 -0
- package/dist/skills/tools/monitor-tool.js +132 -0
- package/dist/skills/tools/monitor-tool.js.map +1 -0
- package/dist/skills/tools/music-generate-tool.d.ts +56 -0
- package/dist/skills/tools/music-generate-tool.d.ts.map +1 -0
- package/dist/skills/tools/music-generate-tool.js +63 -0
- package/dist/skills/tools/music-generate-tool.js.map +1 -0
- package/dist/skills/tools/notify-tool.d.ts +54 -0
- package/dist/skills/tools/notify-tool.d.ts.map +1 -0
- package/dist/skills/tools/notify-tool.js +63 -0
- package/dist/skills/tools/notify-tool.js.map +1 -0
- package/dist/skills/tools/patch-tool.d.ts +46 -0
- package/dist/skills/tools/patch-tool.d.ts.map +1 -0
- package/dist/skills/tools/patch-tool.js +506 -0
- package/dist/skills/tools/patch-tool.js.map +1 -0
- package/dist/skills/tools/pdf-tool.d.ts +67 -0
- package/dist/skills/tools/pdf-tool.d.ts.map +1 -0
- package/dist/skills/tools/pdf-tool.js +89 -0
- package/dist/skills/tools/pdf-tool.js.map +1 -0
- package/dist/skills/tools/plan-mode-tool.d.ts +60 -0
- package/dist/skills/tools/plan-mode-tool.d.ts.map +1 -0
- package/dist/skills/tools/plan-mode-tool.js +123 -0
- package/dist/skills/tools/plan-mode-tool.js.map +1 -0
- package/dist/skills/tools/read-tool.d.ts +52 -0
- package/dist/skills/tools/read-tool.d.ts.map +1 -0
- package/dist/skills/tools/read-tool.js +85 -0
- package/dist/skills/tools/read-tool.js.map +1 -0
- package/dist/skills/tools/repl-tool.d.ts +71 -0
- package/dist/skills/tools/repl-tool.d.ts.map +1 -0
- package/dist/skills/tools/repl-tool.js +70 -0
- package/dist/skills/tools/repl-tool.js.map +1 -0
- package/dist/skills/tools/search-tool.d.ts +113 -0
- package/dist/skills/tools/search-tool.d.ts.map +1 -0
- package/dist/skills/tools/search-tool.js +226 -0
- package/dist/skills/tools/search-tool.js.map +1 -0
- package/dist/skills/tools/send-message-tool.d.ts +52 -0
- package/dist/skills/tools/send-message-tool.d.ts.map +1 -0
- package/dist/skills/tools/send-message-tool.js +77 -0
- package/dist/skills/tools/send-message-tool.js.map +1 -0
- package/dist/skills/tools/skill-list-tool.d.ts +34 -0
- package/dist/skills/tools/skill-list-tool.d.ts.map +1 -0
- package/dist/skills/tools/skill-list-tool.js +55 -0
- package/dist/skills/tools/skill-list-tool.js.map +1 -0
- package/dist/skills/tools/skill-manage-tool.d.ts +74 -0
- package/dist/skills/tools/skill-manage-tool.d.ts.map +1 -0
- package/dist/skills/tools/skill-manage-tool.js +154 -0
- package/dist/skills/tools/skill-manage-tool.js.map +1 -0
- package/dist/skills/tools/skill-view-tool.d.ts +38 -0
- package/dist/skills/tools/skill-view-tool.d.ts.map +1 -0
- package/dist/skills/tools/skill-view-tool.js +73 -0
- package/dist/skills/tools/skill-view-tool.js.map +1 -0
- package/dist/skills/tools/sleep-tool.d.ts +50 -0
- package/dist/skills/tools/sleep-tool.d.ts.map +1 -0
- package/dist/skills/tools/sleep-tool.js +82 -0
- package/dist/skills/tools/sleep-tool.js.map +1 -0
- package/dist/skills/tools/structured-output-tool.d.ts +117 -0
- package/dist/skills/tools/structured-output-tool.d.ts.map +1 -0
- package/dist/skills/tools/structured-output-tool.js +177 -0
- package/dist/skills/tools/structured-output-tool.js.map +1 -0
- package/dist/skills/tools/task-tool.d.ts +105 -0
- package/dist/skills/tools/task-tool.d.ts.map +1 -0
- package/dist/skills/tools/task-tool.js +162 -0
- package/dist/skills/tools/task-tool.js.map +1 -0
- package/dist/skills/tools/team-tool.d.ts +90 -0
- package/dist/skills/tools/team-tool.d.ts.map +1 -0
- package/dist/skills/tools/team-tool.js +106 -0
- package/dist/skills/tools/team-tool.js.map +1 -0
- package/dist/skills/tools/tool-search-tool.d.ts +52 -0
- package/dist/skills/tools/tool-search-tool.d.ts.map +1 -0
- package/dist/skills/tools/tool-search-tool.js +111 -0
- package/dist/skills/tools/tool-search-tool.js.map +1 -0
- package/dist/skills/tools/tts-tool.d.ts +39 -0
- package/dist/skills/tools/tts-tool.d.ts.map +1 -0
- package/dist/skills/tools/tts-tool.js +46 -0
- package/dist/skills/tools/tts-tool.js.map +1 -0
- package/dist/skills/tools/video-edit-tool.d.ts +70 -0
- package/dist/skills/tools/video-edit-tool.d.ts.map +1 -0
- package/dist/skills/tools/video-edit-tool.js +75 -0
- package/dist/skills/tools/video-edit-tool.js.map +1 -0
- package/dist/skills/tools/video-generate-tool.d.ts +63 -0
- package/dist/skills/tools/video-generate-tool.d.ts.map +1 -0
- package/dist/skills/tools/video-generate-tool.js +67 -0
- package/dist/skills/tools/video-generate-tool.js.map +1 -0
- package/dist/skills/tools/video-merge-tool.d.ts +106 -0
- package/dist/skills/tools/video-merge-tool.d.ts.map +1 -0
- package/dist/skills/tools/video-merge-tool.js +93 -0
- package/dist/skills/tools/video-merge-tool.js.map +1 -0
- package/dist/skills/tools/video-upscale-tool.d.ts +46 -0
- package/dist/skills/tools/video-upscale-tool.d.ts.map +1 -0
- package/dist/skills/tools/video-upscale-tool.js +53 -0
- package/dist/skills/tools/video-upscale-tool.js.map +1 -0
- package/dist/skills/tools/web-fetch-tool.d.ts +79 -0
- package/dist/skills/tools/web-fetch-tool.d.ts.map +1 -0
- package/dist/skills/tools/web-fetch-tool.js +93 -0
- package/dist/skills/tools/web-fetch-tool.js.map +1 -0
- package/dist/skills/tools/web-search-tool.d.ts +58 -0
- package/dist/skills/tools/web-search-tool.d.ts.map +1 -0
- package/dist/skills/tools/web-search-tool.js +87 -0
- package/dist/skills/tools/web-search-tool.js.map +1 -0
- package/dist/skills/tools/worktree-tool.d.ts +70 -0
- package/dist/skills/tools/worktree-tool.d.ts.map +1 -0
- package/dist/skills/tools/worktree-tool.js +148 -0
- package/dist/skills/tools/worktree-tool.js.map +1 -0
- package/dist/skills/tools/write-tool.d.ts +46 -0
- package/dist/skills/tools/write-tool.d.ts.map +1 -0
- package/dist/skills/tools/write-tool.js +82 -0
- package/dist/skills/tools/write-tool.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Agent Tool — CC-aligned fork sub-agent with built-in registry.
|
|
3
|
+
// Reference: claude-code-haha/src/tools/AgentTool/AgentTool.tsx
|
|
4
|
+
// claude-code-haha/src/tools/AgentTool/runAgent.ts
|
|
5
|
+
// claude-code-haha/src/tools/AgentTool/forkSubagent.ts
|
|
6
|
+
// claude-code-haha/src/tools/AgentTool/builtInAgents.ts
|
|
7
|
+
// Category: system
|
|
8
|
+
// ============================================================
|
|
9
|
+
export const AGENT_TOOL_NAME = "agent";
|
|
10
|
+
export const BUILT_IN_AGENT_TYPES = [
|
|
11
|
+
"general", "explore", "plan", "code", "research", "verify",
|
|
12
|
+
];
|
|
13
|
+
export const AGENT_TOOL_SCHEMA = {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
agent: {
|
|
17
|
+
type: "string",
|
|
18
|
+
enum: ["general", "explore", "plan", "code", "research", "verify"],
|
|
19
|
+
description: "Sub-agent type to fork:\n" +
|
|
20
|
+
"- general: Full tool access, any task\n" +
|
|
21
|
+
"- explore: Read-only codebase exploration (search, read, analyze)\n" +
|
|
22
|
+
"- plan: Planning mode (explore + produce plan, no writes)\n" +
|
|
23
|
+
"- code: Coding agent with full tool access\n" +
|
|
24
|
+
"- research: Web research and information gathering\n" +
|
|
25
|
+
"- verify: Run tests, check builds, validate changes",
|
|
26
|
+
},
|
|
27
|
+
prompt: {
|
|
28
|
+
type: "string",
|
|
29
|
+
description: "Detailed task for the sub-agent. The sub-agent shares your conversation " +
|
|
30
|
+
"history as context (prompt cache shared). Be specific about what " +
|
|
31
|
+
"information to return in the final response.",
|
|
32
|
+
},
|
|
33
|
+
description: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "Short description (3-7 words) for status tracking.",
|
|
36
|
+
},
|
|
37
|
+
maxTurns: {
|
|
38
|
+
type: "number",
|
|
39
|
+
description: "Max turns for the sub-agent. Defaults: general=200, explore=50, plan=80, code=200, research=30, verify=40.",
|
|
40
|
+
},
|
|
41
|
+
background: {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
description: "If true, runs in background and returns a task_id. Poll with task tool. Default: false.",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
required: ["agent", "prompt"],
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
};
|
|
49
|
+
/** Maximum fork depth for in-memory agents. */
|
|
50
|
+
export const MAX_FORK_DEPTH = 4;
|
|
51
|
+
export function createAgentTool(deps) {
|
|
52
|
+
return {
|
|
53
|
+
name: AGENT_TOOL_NAME,
|
|
54
|
+
label: "Sub-Agent",
|
|
55
|
+
description: "Fork a sub-agent to handle complex tasks autonomously. " +
|
|
56
|
+
"Sub-agents share your conversation context (prompt cache) and " +
|
|
57
|
+
"have isolated tool state. Use for: parallel research, code exploration, " +
|
|
58
|
+
"testing, delegating large tasks to specialized agents.",
|
|
59
|
+
parameters: AGENT_TOOL_SCHEMA,
|
|
60
|
+
searchHint: "fork subagent delegate spawn child parallel worker",
|
|
61
|
+
isConcurrencySafe: true,
|
|
62
|
+
execute: async (_toolCallId, params) => {
|
|
63
|
+
// Validate prompt
|
|
64
|
+
if (!params.prompt || params.prompt.trim().length < 10) {
|
|
65
|
+
return {
|
|
66
|
+
content: [{ type: "text", text: "Error: prompt must be at least 10 characters." }],
|
|
67
|
+
details: { type: "agent", error: "prompt_too_short" },
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// Validate agent type
|
|
71
|
+
if (!BUILT_IN_AGENT_TYPES.includes(params.agent)) {
|
|
72
|
+
return {
|
|
73
|
+
content: [{
|
|
74
|
+
type: "text",
|
|
75
|
+
text: `Error: unknown agent "${params.agent}". Available: ${BUILT_IN_AGENT_TYPES.join(", ")}`,
|
|
76
|
+
}],
|
|
77
|
+
details: { type: "agent", error: "invalid_agent_type" },
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// Fork depth guard
|
|
81
|
+
const depth = deps.currentForkDepth ?? 0;
|
|
82
|
+
if (depth >= MAX_FORK_DEPTH) {
|
|
83
|
+
return {
|
|
84
|
+
content: [{
|
|
85
|
+
type: "text",
|
|
86
|
+
text: `Error: maximum fork depth (${MAX_FORK_DEPTH}) reached. Cannot spawn more sub-agents. Complete current work instead.`,
|
|
87
|
+
}],
|
|
88
|
+
details: { type: "agent", error: "max_depth_reached", depth },
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const result = await deps.forkAgent({
|
|
93
|
+
agent: params.agent,
|
|
94
|
+
prompt: params.prompt.trim(),
|
|
95
|
+
description: params.description,
|
|
96
|
+
maxTurns: params.maxTurns,
|
|
97
|
+
background: params.background,
|
|
98
|
+
abortSignal: deps.abortSignal,
|
|
99
|
+
});
|
|
100
|
+
// Background mode — return task reference
|
|
101
|
+
if (params.background && result.status === "running") {
|
|
102
|
+
return {
|
|
103
|
+
content: [{
|
|
104
|
+
type: "text",
|
|
105
|
+
text: `Sub-agent "${params.agent}" started in background.\nAgent ID: ${result.agentId}\nUse task tool with this ID to check status and get output.`,
|
|
106
|
+
}],
|
|
107
|
+
details: { type: "agent", agentId: result.agentId, status: "running", background: true },
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// Failed
|
|
111
|
+
if (result.status === "failed") {
|
|
112
|
+
return {
|
|
113
|
+
content: [{ type: "text", text: `Sub-agent failed: ${result.error || "unknown error"}` }],
|
|
114
|
+
details: { type: "agent", agentId: result.agentId, status: "failed", error: result.error },
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
// Completed — return output with metadata
|
|
118
|
+
const output = result.output || "(sub-agent returned no output)";
|
|
119
|
+
const suffix = result.maxTurnsReached
|
|
120
|
+
? "\n\n[Note: Sub-agent reached turn limit. Output may be incomplete.]"
|
|
121
|
+
: "";
|
|
122
|
+
return {
|
|
123
|
+
content: [{ type: "text", text: output + suffix }],
|
|
124
|
+
details: {
|
|
125
|
+
type: "agent",
|
|
126
|
+
agentId: result.agentId,
|
|
127
|
+
status: "completed",
|
|
128
|
+
tokensUsed: result.tokensUsed,
|
|
129
|
+
maxTurnsReached: result.maxTurnsReached,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
135
|
+
return {
|
|
136
|
+
content: [{ type: "text", text: `Sub-agent execution failed: ${msg}` }],
|
|
137
|
+
details: { type: "agent", error: "execution_error", message: msg },
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=agent-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tool.js","sourceRoot":"","sources":["../../../src/skills/tools/agent-tool.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,iEAAiE;AACjE,gEAAgE;AAChE,8DAA8D;AAC9D,kEAAkE;AAClE,mEAAmE;AACnE,mBAAmB;AACnB,+DAA+D;AAI/D,MAAM,CAAC,MAAM,eAAe,GAAG,OAAgB,CAAC;AAQhD,MAAM,CAAC,MAAM,oBAAoB,GAAuB;IACtD,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ;CAC3D,CAAC;AAeF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,QAAiB;IACvB,UAAU,EAAE;QACV,KAAK,EAAE;YACL,IAAI,EAAE,QAAiB;YACvB,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAU;YAC3E,WAAW,EACT,2BAA2B;gBAC3B,yCAAyC;gBACzC,qEAAqE;gBACrE,6DAA6D;gBAC7D,8CAA8C;gBAC9C,sDAAsD;gBACtD,qDAAqD;SACxD;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAiB;YACvB,WAAW,EACT,0EAA0E;gBAC1E,mEAAmE;gBACnE,8CAA8C;SACjD;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAiB;YACvB,WAAW,EAAE,oDAAoD;SAClE;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAiB;YACvB,WAAW,EAAE,4GAA4G;SAC1H;QACD,UAA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ool } from "../portable-tool.js";
|
|
2
|
+
export declare const APPLY_PATCH_TOOL_NAME: "apply_patch";
|
|
3
|
+
export interface ApplyPatchToolParams {
|
|
4
|
+
input: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const APPLY_PATCH_TOOL_SCHEMA: {
|
|
7
|
+
readonly type: "object";
|
|
8
|
+
readonly properties: {
|
|
9
|
+
readonly input: {
|
|
10
|
+
readonly type: "string";
|
|
11
|
+
readonly description: "Patch content using the *** Begin Patch / *** End Patch format.";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
readonly required: readonly ["input"];
|
|
15
|
+
};
|
|
16
|
+
export interface ApplyPatchSummary {
|
|
17
|
+
added: string[];
|
|
18
|
+
modified: string[];
|
|
19
|
+
deleted: string[];
|
|
20
|
+
}
|
|
21
|
+
/** Deps injected by the host runtime for file patching. */
|
|
22
|
+
export interface ApplyPatchToolDeps {
|
|
23
|
+
readFile(path: string): Promise<string>;
|
|
24
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
25
|
+
deleteFile(path: string): Promise<void>;
|
|
26
|
+
fileExists(path: string): Promise<boolean>;
|
|
27
|
+
resolvePath(input: string): string;
|
|
28
|
+
}
|
|
29
|
+
export declare function createApplyPatchTool(deps: ApplyPatchToolDeps): PortableTool<ApplyPatchToolParams>;
|
|
30
|
+
//# sourceMappingURL=apply-patch-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-patch-tool.d.ts","sourceRoot":"","sources":["../../../src/skills/tools/apply-patch-tool.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,qBAAqB,CAAC;AAE5E,eAAO,MAAM,qBAAqB,EAAG,aAAsB,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;CAS1B,CAAC;AAEX,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,2DAA2D;AAC3D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACpC;AA+GD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAmEjG"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Apply Patch Tool — apply unified diff patches to files.
|
|
3
|
+
// Category: coding
|
|
4
|
+
// ============================================================
|
|
5
|
+
export const APPLY_PATCH_TOOL_NAME = "apply_patch";
|
|
6
|
+
export const APPLY_PATCH_TOOL_SCHEMA = {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
input: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "Patch content using the *** Begin Patch / *** End Patch format.",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
required: ["input"],
|
|
15
|
+
};
|
|
16
|
+
function parsePatch(input) {
|
|
17
|
+
const lines = input.split("\n");
|
|
18
|
+
const ops = [];
|
|
19
|
+
let current = null;
|
|
20
|
+
let currentHunk = null;
|
|
21
|
+
let inPatch = false;
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
if (line.startsWith("*** Begin Patch")) {
|
|
24
|
+
inPatch = true;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (line.startsWith("*** End Patch")) {
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
if (!inPatch)
|
|
31
|
+
continue;
|
|
32
|
+
if (line.startsWith("*** Add File: ")) {
|
|
33
|
+
if (current)
|
|
34
|
+
ops.push(current);
|
|
35
|
+
current = { type: "add", path: line.slice("*** Add File: ".length).trim(), hunks: [] };
|
|
36
|
+
currentHunk = { contextBefore: [], removals: [], additions: [], contextAfter: [] };
|
|
37
|
+
current.hunks.push(currentHunk);
|
|
38
|
+
}
|
|
39
|
+
else if (line.startsWith("*** Update File: ")) {
|
|
40
|
+
if (current)
|
|
41
|
+
ops.push(current);
|
|
42
|
+
current = { type: "update", path: line.slice("*** Update File: ".length).trim(), hunks: [] };
|
|
43
|
+
currentHunk = null;
|
|
44
|
+
}
|
|
45
|
+
else if (line.startsWith("*** Delete File: ")) {
|
|
46
|
+
if (current)
|
|
47
|
+
ops.push(current);
|
|
48
|
+
current = { type: "delete", path: line.slice("*** Delete File: ".length).trim(), hunks: [] };
|
|
49
|
+
currentHunk = null;
|
|
50
|
+
}
|
|
51
|
+
else if (line.startsWith("*** Move to: ") && current) {
|
|
52
|
+
current.moveTo = line.slice("*** Move to: ".length).trim();
|
|
53
|
+
}
|
|
54
|
+
else if (line.startsWith("@@ ") && current) {
|
|
55
|
+
currentHunk = { contextBefore: [], removals: [], additions: [], contextAfter: [] };
|
|
56
|
+
current.hunks.push(currentHunk);
|
|
57
|
+
}
|
|
58
|
+
else if (currentHunk) {
|
|
59
|
+
if (line.startsWith("+")) {
|
|
60
|
+
currentHunk.additions.push(line.slice(1));
|
|
61
|
+
}
|
|
62
|
+
else if (line.startsWith("-")) {
|
|
63
|
+
currentHunk.removals.push(line.slice(1));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// context line (space prefix or bare)
|
|
67
|
+
const ctx = line.startsWith(" ") ? line.slice(1) : line;
|
|
68
|
+
if (currentHunk.additions.length === 0 && currentHunk.removals.length === 0) {
|
|
69
|
+
currentHunk.contextBefore.push(ctx);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
currentHunk.contextAfter.push(ctx);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (current)
|
|
78
|
+
ops.push(current);
|
|
79
|
+
return ops;
|
|
80
|
+
}
|
|
81
|
+
function applyHunksToContent(content, hunks) {
|
|
82
|
+
const lines = content.split("\n");
|
|
83
|
+
let result = [...lines];
|
|
84
|
+
for (const hunk of hunks) {
|
|
85
|
+
// Find context match position
|
|
86
|
+
let matchStart = -1;
|
|
87
|
+
if (hunk.contextBefore.length > 0) {
|
|
88
|
+
for (let i = 0; i <= result.length - hunk.contextBefore.length; i++) {
|
|
89
|
+
let matches = true;
|
|
90
|
+
for (let j = 0; j < hunk.contextBefore.length; j++) {
|
|
91
|
+
if (result[i + j] !== hunk.contextBefore[j]) {
|
|
92
|
+
matches = false;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (matches) {
|
|
97
|
+
matchStart = i + hunk.contextBefore.length;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
matchStart = 0;
|
|
104
|
+
}
|
|
105
|
+
if (matchStart === -1)
|
|
106
|
+
continue;
|
|
107
|
+
// Remove old lines
|
|
108
|
+
if (hunk.removals.length > 0) {
|
|
109
|
+
result.splice(matchStart, hunk.removals.length, ...hunk.additions);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
result.splice(matchStart, 0, ...hunk.additions);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return result.join("\n");
|
|
116
|
+
}
|
|
117
|
+
export function createApplyPatchTool(deps) {
|
|
118
|
+
return {
|
|
119
|
+
name: APPLY_PATCH_TOOL_NAME,
|
|
120
|
+
label: "Apply Patch",
|
|
121
|
+
description: "Apply a patch to one or more files using the *** Begin Patch / *** End Patch format. " +
|
|
122
|
+
"Supports Add File, Update File, Delete File, and Move To operations.",
|
|
123
|
+
parameters: APPLY_PATCH_TOOL_SCHEMA,
|
|
124
|
+
execute: async (_toolCallId, params) => {
|
|
125
|
+
const ops = parsePatch(params.input);
|
|
126
|
+
if (ops.length === 0) {
|
|
127
|
+
return {
|
|
128
|
+
content: [{ type: "text", text: "Error: No valid patch operations found. Ensure *** Begin Patch / *** End Patch markers are present." }],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const summary = { added: [], modified: [], deleted: [] };
|
|
132
|
+
const errors = [];
|
|
133
|
+
for (const op of ops) {
|
|
134
|
+
const resolved = deps.resolvePath(op.path);
|
|
135
|
+
try {
|
|
136
|
+
switch (op.type) {
|
|
137
|
+
case "add": {
|
|
138
|
+
const newContent = op.hunks.flatMap((h) => [...h.additions]).join("\n");
|
|
139
|
+
await deps.writeFile(resolved, newContent);
|
|
140
|
+
summary.added.push(op.path);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case "update": {
|
|
144
|
+
const existing = await deps.readFile(resolved);
|
|
145
|
+
const patched = applyHunksToContent(existing, op.hunks);
|
|
146
|
+
if (op.moveTo) {
|
|
147
|
+
const dest = deps.resolvePath(op.moveTo);
|
|
148
|
+
await deps.writeFile(dest, patched);
|
|
149
|
+
await deps.deleteFile(resolved);
|
|
150
|
+
summary.modified.push(`${op.path} → ${op.moveTo}`);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
await deps.writeFile(resolved, patched);
|
|
154
|
+
summary.modified.push(op.path);
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case "delete": {
|
|
159
|
+
await deps.deleteFile(resolved);
|
|
160
|
+
summary.deleted.push(op.path);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
errors.push(`${op.type} ${op.path}: ${err instanceof Error ? err.message : String(err)}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const parts = [];
|
|
170
|
+
if (summary.added.length)
|
|
171
|
+
parts.push(`Added: ${summary.added.join(", ")}`);
|
|
172
|
+
if (summary.modified.length)
|
|
173
|
+
parts.push(`Modified: ${summary.modified.join(", ")}`);
|
|
174
|
+
if (summary.deleted.length)
|
|
175
|
+
parts.push(`Deleted: ${summary.deleted.join(", ")}`);
|
|
176
|
+
if (errors.length)
|
|
177
|
+
parts.push(`Errors: ${errors.join("; ")}`);
|
|
178
|
+
return {
|
|
179
|
+
content: [{ type: "text", text: parts.join("\n") || "No changes applied." }],
|
|
180
|
+
details: { type: "apply_patch", summary, errors },
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=apply-patch-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-patch-tool.js","sourceRoot":"","sources":["../../../src/skills/tools/apply-patch-tool.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,0DAA0D;AAC1D,mBAAmB;AACnB,+DAA+D;AAI/D,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAsB,CAAC;AAM5D,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,QAAiB;IACvB,UAAU,EAAE;QACV,KAAK,EAAE;YACL,IAAI,EAAE,QAAiB;YACvB,WAAW,EAAE,iEAAiE;SAC/E;KACF;IACD,QAAQ,EAAE,CAAC,OAAO,CAAU;CACpB,CAAC;AAiCX,SAAS,UAAU,CAAC,KAAa;IAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,IAAI,OAAO,GAAuB,IAAI,CAAC;IACvC,IAAI,WAAW,GAAqB,IAAI,CAA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gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,qBAAqB,EAAE,CAAC;gBAC5E,OAAO,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE;aAClD,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const ASK_USER_TOOL_NAME: "ask_user";
|
|
3
|
+
export interface AskUserOption {
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AskUserQuestion {
|
|
8
|
+
question: string;
|
|
9
|
+
header: string;
|
|
10
|
+
options?: AskUserOption[];
|
|
11
|
+
multiSelect?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface AskUserToolParams {
|
|
14
|
+
questions: AskUserQuestion[];
|
|
15
|
+
}
|
|
16
|
+
export declare const ASK_USER_TOOL_SCHEMA: {
|
|
17
|
+
readonly type: "object";
|
|
18
|
+
readonly properties: {
|
|
19
|
+
readonly questions: {
|
|
20
|
+
readonly type: "array";
|
|
21
|
+
readonly minItems: 1;
|
|
22
|
+
readonly maxItems: 4;
|
|
23
|
+
readonly description: "1-4 clarifying questions to ask the user.";
|
|
24
|
+
readonly items: {
|
|
25
|
+
readonly type: "object";
|
|
26
|
+
readonly properties: {
|
|
27
|
+
readonly question: {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly description: "The question text. Should end with '?'.";
|
|
30
|
+
};
|
|
31
|
+
readonly header: {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
readonly description: "Short identifier/tag for this question (max 50 chars).";
|
|
34
|
+
};
|
|
35
|
+
readonly options: {
|
|
36
|
+
readonly type: "array";
|
|
37
|
+
readonly description: "2-4 options for the user to choose from. Omit for free text.";
|
|
38
|
+
readonly items: {
|
|
39
|
+
readonly type: "object";
|
|
40
|
+
readonly properties: {
|
|
41
|
+
readonly label: {
|
|
42
|
+
readonly type: "string";
|
|
43
|
+
readonly description: "Display label (1-5 words).";
|
|
44
|
+
};
|
|
45
|
+
readonly description: {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
readonly description: "Brief explanation of this option.";
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
readonly required: readonly ["label"];
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
readonly multiSelect: {
|
|
54
|
+
readonly type: "boolean";
|
|
55
|
+
readonly description: "Allow selecting multiple options (default: false).";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
readonly required: readonly ["question", "header"];
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
readonly required: readonly ["questions"];
|
|
63
|
+
};
|
|
64
|
+
export interface AskUserAnswer {
|
|
65
|
+
question: string;
|
|
66
|
+
answer: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Host-provided user interaction backend.
|
|
70
|
+
* The host renders the questions in the UI and collects answers.
|
|
71
|
+
*/
|
|
72
|
+
export interface AskUserToolDeps {
|
|
73
|
+
/**
|
|
74
|
+
* Present questions to the user and collect answers.
|
|
75
|
+
* Returns a map of question text → answer text.
|
|
76
|
+
* If the user declines, returns null.
|
|
77
|
+
*/
|
|
78
|
+
askUser(questions: AskUserQuestion[]): Promise<Record<string, string> | null>;
|
|
79
|
+
}
|
|
80
|
+
export declare function createAskUserTool(deps: AskUserToolDeps): PortableTool<AskUserToolParams>;
|
|
81
|
+
//# sourceMappingURL=ask-user-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-tool.d.ts","sourceRoot":"","sources":["../../../src/skills/tools/ask-user-tool.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,qBAAqB,CAAC;AAE5E,eAAO,MAAM,kBAAkB,EAAG,UAAmB,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CvB,CAAC;AAEX,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;CAC/E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,YAAY,CAAC,iBAAiB,CAAC,CA0ExF"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Ask User Tool — ask the user clarifying questions.
|
|
3
|
+
// Reference: claude-code-haha/src/tools/AskUserQuestionTool/AskUserQuestionTool.tsx
|
|
4
|
+
// Category: interaction
|
|
5
|
+
// ============================================================
|
|
6
|
+
export const ASK_USER_TOOL_NAME = "ask_user";
|
|
7
|
+
export const ASK_USER_TOOL_SCHEMA = {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
questions: {
|
|
11
|
+
type: "array",
|
|
12
|
+
minItems: 1,
|
|
13
|
+
maxItems: 4,
|
|
14
|
+
description: "1-4 clarifying questions to ask the user.",
|
|
15
|
+
items: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
question: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "The question text. Should end with '?'.",
|
|
21
|
+
},
|
|
22
|
+
header: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Short identifier/tag for this question (max 50 chars).",
|
|
25
|
+
},
|
|
26
|
+
options: {
|
|
27
|
+
type: "array",
|
|
28
|
+
description: "2-4 options for the user to choose from. Omit for free text.",
|
|
29
|
+
items: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
label: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Display label (1-5 words).",
|
|
35
|
+
},
|
|
36
|
+
description: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "Brief explanation of this option.",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
required: ["label"],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
multiSelect: {
|
|
45
|
+
type: "boolean",
|
|
46
|
+
description: "Allow selecting multiple options (default: false).",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
required: ["question", "header"],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
required: ["questions"],
|
|
54
|
+
};
|
|
55
|
+
export function createAskUserTool(deps) {
|
|
56
|
+
return {
|
|
57
|
+
name: ASK_USER_TOOL_NAME,
|
|
58
|
+
label: "Ask User",
|
|
59
|
+
description: "Ask the user clarifying questions when you need more information to proceed. " +
|
|
60
|
+
"Supports free text questions and multiple-choice options. " +
|
|
61
|
+
"Use this when the user's intent is ambiguous or you need confirmation.",
|
|
62
|
+
parameters: ASK_USER_TOOL_SCHEMA,
|
|
63
|
+
execute: async (_toolCallId, params) => {
|
|
64
|
+
// Validate questions count
|
|
65
|
+
if (!params.questions || params.questions.length === 0) {
|
|
66
|
+
return {
|
|
67
|
+
content: [{ type: "text", text: "Error: at least one question is required." }],
|
|
68
|
+
details: { type: "ask_user", error: "no_questions" },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (params.questions.length > 4) {
|
|
72
|
+
return {
|
|
73
|
+
content: [{ type: "text", text: "Error: maximum 4 questions allowed." }],
|
|
74
|
+
details: { type: "ask_user", error: "too_many_questions" },
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Validate unique question texts
|
|
78
|
+
const questionTexts = params.questions.map((q) => q.question);
|
|
79
|
+
if (new Set(questionTexts).size !== questionTexts.length) {
|
|
80
|
+
return {
|
|
81
|
+
content: [{ type: "text", text: "Error: all questions must have unique text." }],
|
|
82
|
+
details: { type: "ask_user", error: "duplicate_questions" },
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Validate options count and label uniqueness per question
|
|
86
|
+
for (const q of params.questions) {
|
|
87
|
+
if (q.options && (q.options.length < 2 || q.options.length > 4)) {
|
|
88
|
+
return {
|
|
89
|
+
content: [{ type: "text", text: `Error: question "${q.header}" must have 2-4 options (got ${q.options.length}).` }],
|
|
90
|
+
details: { type: "ask_user", error: "invalid_option_count" },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (q.options) {
|
|
94
|
+
const labels = q.options.map((o) => o.label);
|
|
95
|
+
if (new Set(labels).size !== labels.length) {
|
|
96
|
+
return {
|
|
97
|
+
content: [{ type: "text", text: `Error: question "${q.header}" has duplicate option labels.` }],
|
|
98
|
+
details: { type: "ask_user", error: "duplicate_option_labels" },
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const answers = await deps.askUser(params.questions);
|
|
104
|
+
if (answers === null) {
|
|
105
|
+
return {
|
|
106
|
+
content: [{ type: "text", text: "User declined to answer questions." }],
|
|
107
|
+
details: { type: "ask_user", declined: true },
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const lines = ["User answered:"];
|
|
111
|
+
for (const q of params.questions) {
|
|
112
|
+
const answer = answers[q.question] ?? "(no answer)";
|
|
113
|
+
lines.push(`- ${q.header}: ${answer}`);
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
117
|
+
details: { type: "ask_user", answers, questionCount: params.questions.length },
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=ask-user-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-tool.js","sourceRoot":"","sources":["../../../src/skills/tools/ask-user-tool.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,qDAAqD;AACrD,oFAAoF;AACpF,wBAAwB;AACxB,+DAA+D;AAI/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAmB,CAAC;AAkBtD,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,QAAiB;IACvB,UAAU,EAAE;QACV,SAAS,EAAE;YACT,IAAI,EAAE,OAAgB;YACtB,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,CAAC;YACX,WAAW,EAAE,2CAA2C;YACxD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAiB;gBACvB,UAAU,EAAE;oBACV,QAAQ,EAAE;wBACR,IAAI,EAAE,QAAiB;wBACvB,WAAW,EAAE,yCAAyC;qBACvD;oBACD,MAAM,EAAE;wBACN,IAAI,EAAE,QAAiB;wBACvB,WAAW,EAAE,wDAAwD;qBACtE;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,OAAgB;wBACtB,WAAW,EAAE,8DAA8D;wBAC3E,KAAK,EAAE;4BACL,IAAI,EAAE,QAAiB;4BACvB,UAAU,EAAE;gCACV,KAAK,EAAE;oCACL,IAAI,EAAE,QAAiB;oCACvB,WAAW,EAAE,4BAA4B;iCAC1C;gCACD,WAAW,EAAE;oCACX,IAAI,EAAE,QAAiB;oCACvB,WAAW,EAAE,mCAAmC;iCACj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