goatcode-sh 0.0.1 → 0.1.2
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/.github/workflows/ci.yml +85 -0
- package/.github/workflows/release.yml +107 -0
- package/.opencode/plugins/goatcode.js +1 -0
- package/AGENTS.md +59 -0
- package/CONTRIBUTING.md +110 -0
- package/LICENSE +21 -0
- package/README.md +106 -12
- package/bun.lock +2081 -0
- package/bunfig.toml +3 -0
- package/dist/agents/advisor/config.d.ts +4 -0
- package/dist/agents/advisor/index.d.ts +2 -0
- package/dist/agents/advisor/plugin.d.ts +1 -0
- package/dist/agents/advisor/prompt-meta.d.ts +2 -0
- package/dist/agents/advisor/prompt.d.ts +1 -0
- package/dist/agents/agent-builder.d.ts +10 -0
- package/dist/agents/agent-registry.d.ts +8 -0
- package/dist/agents/builtin-agents.d.ts +2 -0
- package/dist/agents/deep-worker/config.d.ts +4 -0
- package/dist/agents/deep-worker/index.d.ts +2 -0
- package/dist/agents/deep-worker/plugin.d.ts +1 -0
- package/dist/agents/deep-worker/prompt-meta.d.ts +2 -0
- package/dist/agents/deep-worker/prompt.d.ts +1 -0
- package/dist/agents/explorer/config.d.ts +4 -0
- package/dist/agents/explorer/index.d.ts +2 -0
- package/dist/agents/explorer/plugin.d.ts +1 -0
- package/dist/agents/explorer/prompt-meta.d.ts +2 -0
- package/dist/agents/explorer/prompt.d.ts +1 -0
- package/dist/agents/fallback-chains.d.ts +2 -0
- package/dist/agents/index.d.ts +14 -0
- package/dist/agents/orchestrator/config.d.ts +4 -0
- package/dist/agents/orchestrator/index.d.ts +2 -0
- package/dist/agents/orchestrator/plugin.d.ts +1 -0
- package/dist/agents/orchestrator/prompt-meta.d.ts +2 -0
- package/dist/agents/orchestrator/prompt.d.ts +1 -0
- package/dist/agents/planner/config.d.ts +4 -0
- package/dist/agents/planner/index.d.ts +2 -0
- package/dist/agents/planner/plugin.d.ts +1 -0
- package/dist/agents/planner/prompt-meta.d.ts +2 -0
- package/dist/agents/planner/prompt.d.ts +1 -0
- package/dist/agents/prompt-meta.d.ts +11 -0
- package/dist/agents/prompt-registry.d.ts +4 -0
- package/dist/agents/researcher/config.d.ts +4 -0
- package/dist/agents/researcher/index.d.ts +2 -0
- package/dist/agents/researcher/plugin.d.ts +1 -0
- package/dist/agents/researcher/prompt-meta.d.ts +2 -0
- package/dist/agents/researcher/prompt.d.ts +1 -0
- package/dist/agents/tool-restrictions.d.ts +7 -0
- package/dist/agents/worker/config.d.ts +4 -0
- package/dist/agents/worker/index.d.ts +2 -0
- package/dist/agents/worker/plugin.d.ts +1 -0
- package/dist/agents/worker/prompt-meta.d.ts +2 -0
- package/dist/agents/worker/prompt.d.ts +1 -0
- package/dist/bootstrap.d.ts +3 -0
- package/dist/cli/cli.d.ts +3 -0
- package/dist/cli/commands/install.d.ts +12 -0
- package/dist/cli/commands/update.d.ts +1 -0
- package/dist/cli/config-generator.d.ts +26 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/define-config.d.ts +27 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/loader.d.ts +3 -0
- package/dist/config/paths.d.ts +4 -0
- package/dist/config/schema.d.ts +273 -0
- package/dist/config/validator.d.ts +9 -0
- package/dist/features/auto-update/index.d.ts +3 -0
- package/dist/features/auto-update/plugin.d.ts +2 -0
- package/dist/features/auto-update/update-checker.d.ts +7 -0
- package/dist/features/background-agent/concurrency.d.ts +10 -0
- package/dist/features/background-agent/index.d.ts +6 -0
- package/dist/features/background-agent/manager.d.ts +18 -0
- package/dist/features/background-agent/poller.d.ts +17 -0
- package/dist/features/background-agent/singleton.d.ts +7 -0
- package/dist/features/background-agent/spawner.d.ts +6 -0
- package/dist/features/background-agent/types.d.ts +18 -0
- package/dist/features/builtin-features.d.ts +2 -0
- package/dist/features/categories/category-config.d.ts +9 -0
- package/dist/features/categories/category-resolver.d.ts +6 -0
- package/dist/features/categories/index.d.ts +3 -0
- package/dist/features/categories/prompt-appends.d.ts +10 -0
- package/dist/features/loops/file-store.d.ts +22 -0
- package/dist/features/loops/handler.d.ts +9 -0
- package/dist/features/loops/index.d.ts +5 -0
- package/dist/features/loops/memory-store.d.ts +11 -0
- package/dist/features/loops/plugin.d.ts +34 -0
- package/dist/features/loops/shared/event-utils.d.ts +7 -0
- package/dist/features/loops/state.d.ts +22 -0
- package/dist/features/prompt-builder/agent-table-builder.d.ts +6 -0
- package/dist/features/prompt-builder/category-section-builder.d.ts +2 -0
- package/dist/features/prompt-builder/dynamic-prompt-builder.d.ts +9 -0
- package/dist/features/prompt-builder/index.d.ts +7 -0
- package/dist/features/prompt-builder/skill-section-builder.d.ts +5 -0
- package/dist/features/session-state/index.d.ts +5 -0
- package/dist/features/session-state/session-cursor.d.ts +13 -0
- package/dist/features/session-state/session-store.d.ts +12 -0
- package/dist/features/session-state/session-tools-store.d.ts +4 -0
- package/dist/features/skills/builtin/git-master.d.ts +2 -0
- package/dist/features/skills/index.d.ts +10 -0
- package/dist/features/skills/skill-loader.d.ts +22 -0
- package/dist/features/skills/skill-merger.d.ts +2 -0
- package/dist/features/slash-commands/command-registry.d.ts +3 -0
- package/dist/features/slash-commands/commands/cancel-loop.d.ts +2 -0
- package/dist/features/slash-commands/commands/handoff.d.ts +2 -0
- package/dist/features/slash-commands/commands/init-deep.d.ts +2 -0
- package/dist/features/slash-commands/commands/loop.d.ts +2 -0
- package/dist/features/slash-commands/commands/start-work.d.ts +2 -0
- package/dist/features/slash-commands/commands/stop-continuation.d.ts +2 -0
- package/dist/features/slash-commands/index.d.ts +2 -0
- package/dist/features/slash-commands/types.d.ts +5 -0
- package/dist/hooks/anthropic-effort/handler.d.ts +5 -0
- package/dist/hooks/anthropic-effort/index.d.ts +3 -0
- package/dist/hooks/anthropic-effort/plugin.d.ts +1 -0
- package/dist/hooks/builtin-hooks.d.ts +2 -0
- package/dist/hooks/comment-checker/handler.d.ts +5 -0
- package/dist/hooks/comment-checker/index.d.ts +2 -0
- package/dist/hooks/comment-checker/plugin.d.ts +1 -0
- package/dist/hooks/compaction-context/handler.d.ts +2 -0
- package/dist/hooks/compaction-context/index.d.ts +2 -0
- package/dist/hooks/compaction-context/plugin.d.ts +1 -0
- package/dist/hooks/compaction-todo-preserver/handler.d.ts +4 -0
- package/dist/hooks/compaction-todo-preserver/index.d.ts +2 -0
- package/dist/hooks/compaction-todo-preserver/plugin.d.ts +1 -0
- package/dist/hooks/context-injector/handlers/agents.d.ts +1 -0
- package/dist/hooks/context-injector/handlers/readme.d.ts +1 -0
- package/dist/hooks/context-injector/handlers/rules.d.ts +1 -0
- package/dist/hooks/context-injector/index.d.ts +4 -0
- package/dist/hooks/context-injector/plugin.d.ts +1 -0
- package/dist/hooks/context-window-limit/handler.d.ts +6 -0
- package/dist/hooks/context-window-limit/index.d.ts +2 -0
- package/dist/hooks/context-window-limit/plugin.d.ts +1 -0
- package/dist/hooks/delegate-retry/handler.d.ts +16 -0
- package/dist/hooks/delegate-retry/index.d.ts +3 -0
- package/dist/hooks/delegate-retry/plugin.d.ts +1 -0
- package/dist/hooks/edit-error/handler.d.ts +6 -0
- package/dist/hooks/edit-error/index.d.ts +2 -0
- package/dist/hooks/edit-error/plugin.d.ts +1 -0
- package/dist/hooks/empty-response-detector/handler.d.ts +5 -0
- package/dist/hooks/empty-response-detector/index.d.ts +2 -0
- package/dist/hooks/empty-response-detector/plugin.d.ts +1 -0
- package/dist/hooks/error-diagnostics/handler.d.ts +6 -0
- package/dist/hooks/error-diagnostics/patterns.d.ts +3 -0
- package/dist/hooks/error-diagnostics/plugin.d.ts +1 -0
- package/dist/hooks/error-diagnostics/types.d.ts +14 -0
- package/dist/hooks/foreground-fallback/handler.d.ts +22 -0
- package/dist/hooks/foreground-fallback/index.d.ts +2 -0
- package/dist/hooks/foreground-fallback/plugin.d.ts +1 -0
- package/dist/hooks/hashline-diff-enhancer/handler.d.ts +28 -0
- package/dist/hooks/hashline-diff-enhancer/index.d.ts +2 -0
- package/dist/hooks/hashline-diff-enhancer/plugin.d.ts +1 -0
- package/dist/hooks/hashline-read-enhancer/handler.d.ts +4 -0
- package/dist/hooks/hashline-read-enhancer/index.d.ts +2 -0
- package/dist/hooks/hashline-read-enhancer/plugin.d.ts +1 -0
- package/dist/hooks/hook-composer.d.ts +4 -0
- package/dist/hooks/hook-ordering.d.ts +9 -0
- package/dist/hooks/hook-types.d.ts +3 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/json-error/handler.d.ts +6 -0
- package/dist/hooks/json-error/index.d.ts +2 -0
- package/dist/hooks/json-error/plugin.d.ts +1 -0
- package/dist/hooks/keyword-detector/handler.d.ts +8 -0
- package/dist/hooks/keyword-detector/index.d.ts +3 -0
- package/dist/hooks/keyword-detector/plugin.d.ts +1 -0
- package/dist/hooks/model-fallback/handler.d.ts +21 -0
- package/dist/hooks/model-fallback/index.d.ts +2 -0
- package/dist/hooks/model-fallback/plugin.d.ts +1 -0
- package/dist/hooks/phase-reminder/handler.d.ts +5 -0
- package/dist/hooks/phase-reminder/index.d.ts +2 -0
- package/dist/hooks/phase-reminder/plugin.d.ts +1 -0
- package/dist/hooks/post-read-nudge/handler.d.ts +5 -0
- package/dist/hooks/post-read-nudge/index.d.ts +2 -0
- package/dist/hooks/post-read-nudge/plugin.d.ts +1 -0
- package/dist/hooks/preemptive-compaction/handler.d.ts +31 -0
- package/dist/hooks/preemptive-compaction/index.d.ts +2 -0
- package/dist/hooks/preemptive-compaction/plugin.d.ts +1 -0
- package/dist/hooks/runtime-fallback/handler.d.ts +21 -0
- package/dist/hooks/runtime-fallback/index.d.ts +2 -0
- package/dist/hooks/runtime-fallback/plugin.d.ts +1 -0
- package/dist/hooks/safe-hook-wrapper.d.ts +2 -0
- package/dist/hooks/session-recovery/handler.d.ts +6 -0
- package/dist/hooks/session-recovery/index.d.ts +2 -0
- package/dist/hooks/session-recovery/plugin.d.ts +1 -0
- package/dist/hooks/skill-discovery/plugin.d.ts +1 -0
- package/dist/hooks/stop-guard/handler.d.ts +4 -0
- package/dist/hooks/stop-guard/index.d.ts +2 -0
- package/dist/hooks/stop-guard/plugin.d.ts +1 -0
- package/dist/hooks/task-resume-info/handler.d.ts +4 -0
- package/dist/hooks/task-resume-info/index.d.ts +2 -0
- package/dist/hooks/task-resume-info/plugin.d.ts +1 -0
- package/dist/hooks/think-mode/handler.d.ts +4 -0
- package/dist/hooks/think-mode/index.d.ts +2 -0
- package/dist/hooks/think-mode/plugin.d.ts +1 -0
- package/dist/hooks/thinking-block-validator/handler.d.ts +4 -0
- package/dist/hooks/thinking-block-validator/index.d.ts +2 -0
- package/dist/hooks/thinking-block-validator/plugin.d.ts +1 -0
- package/dist/hooks/todo-enforcer/handler.d.ts +4 -0
- package/dist/hooks/todo-enforcer/index.d.ts +2 -0
- package/dist/hooks/todo-enforcer/plugin.d.ts +1 -0
- package/dist/hooks/todowrite-disabler/handler.d.ts +6 -0
- package/dist/hooks/todowrite-disabler/index.d.ts +2 -0
- package/dist/hooks/todowrite-disabler/plugin.d.ts +1 -0
- package/dist/hooks/tool-output-truncator/handler.d.ts +4 -0
- package/dist/hooks/tool-output-truncator/index.d.ts +2 -0
- package/dist/hooks/tool-output-truncator/plugin.d.ts +1 -0
- package/dist/hooks/write-file-guard/handler.d.ts +7 -0
- package/dist/hooks/write-file-guard/index.d.ts +2 -0
- package/dist/hooks/write-file-guard/plugin.d.ts +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8547 -0
- package/dist/plugin/compositor.d.ts +9 -0
- package/dist/plugin/index.d.ts +1 -0
- package/dist/plugin-api/define-plugin.d.ts +33 -0
- package/dist/plugin-api/index.d.ts +3 -0
- package/dist/plugin-api/types.d.ts +10 -0
- package/dist/registry/agent-aggregator.d.ts +3 -0
- package/dist/registry/contribution-aggregator.d.ts +10 -0
- package/dist/registry/dependency-resolver.d.ts +3 -0
- package/dist/registry/hook-aggregator.d.ts +2 -0
- package/dist/registry/index.d.ts +6 -0
- package/dist/registry/plugin-registry.d.ts +16 -0
- package/dist/registry/tool-aggregator.d.ts +3 -0
- package/dist/registry/types.d.ts +9 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/shared/data-path.d.ts +4 -0
- package/dist/shared/deep-merge.d.ts +13 -0
- package/dist/shared/fallback-chain.d.ts +1 -0
- package/dist/shared/index.d.ts +19 -0
- package/dist/shared/logger.d.ts +4 -0
- package/dist/shared/model-availability.d.ts +1 -0
- package/dist/shared/model-normalization.d.ts +6 -0
- package/dist/shared/model-prefix-map.d.ts +11 -0
- package/dist/shared/model-resolution-pipeline.d.ts +14 -0
- package/dist/shared/models-dev.d.ts +29 -0
- package/dist/shared/provider-discovery.d.ts +28 -0
- package/dist/shared/provider-registry.d.ts +16 -0
- package/dist/shared/safe-create-hook.d.ts +3 -0
- package/dist/shared/snake-case.d.ts +1 -0
- package/dist/shared/truncate-description.d.ts +1 -0
- package/dist/test-utils/index.d.ts +6 -0
- package/dist/test-utils/mock-agent-config.d.ts +5 -0
- package/dist/test-utils/mock-hook-inputs.d.ts +20 -0
- package/dist/test-utils/mock-hook-outputs.d.ts +20 -0
- package/dist/test-utils/mock-plugin-context.d.ts +6 -0
- package/dist/test-utils/mock-sdk-client.d.ts +41 -0
- package/dist/test-utils/mock-tool-context.d.ts +6 -0
- package/dist/tools/ast-grep/index.d.ts +4 -0
- package/dist/tools/ast-grep/replace/handler.d.ts +7 -0
- package/dist/tools/ast-grep/replace/plugin.d.ts +1 -0
- package/dist/tools/ast-grep/replace/types.d.ts +37 -0
- package/dist/tools/ast-grep/search/handler.d.ts +14 -0
- package/dist/tools/ast-grep/search/plugin.d.ts +1 -0
- package/dist/tools/ast-grep/search/types.d.ts +37 -0
- package/dist/tools/background-task/cancel/handler.d.ts +4 -0
- package/dist/tools/background-task/cancel/plugin.d.ts +2 -0
- package/dist/tools/background-task/cancel/types.d.ts +4 -0
- package/dist/tools/background-task/index.d.ts +2 -0
- package/dist/tools/background-task/output/handler.d.ts +3 -0
- package/dist/tools/background-task/output/plugin.d.ts +2 -0
- package/dist/tools/background-task/output/types.d.ts +11 -0
- package/dist/tools/bridge.d.ts +7 -0
- package/dist/tools/builtin-tools.d.ts +2 -0
- package/dist/tools/delegate-task/category-resolver.d.ts +4 -0
- package/dist/tools/delegate-task/constants.d.ts +3 -0
- package/dist/tools/delegate-task/executor.d.ts +10 -0
- package/dist/tools/delegate-task/handler.d.ts +3 -0
- package/dist/tools/delegate-task/index.d.ts +7 -0
- package/dist/tools/delegate-task/plugin.d.ts +2 -0
- package/dist/tools/delegate-task/types.d.ts +17 -0
- package/dist/tools/glob/handler.d.ts +7 -0
- package/dist/tools/glob/index.d.ts +2 -0
- package/dist/tools/glob/plugin.d.ts +1 -0
- package/dist/tools/glob/types.d.ts +7 -0
- package/dist/tools/grep/handler.d.ts +13 -0
- package/dist/tools/grep/index.d.ts +2 -0
- package/dist/tools/grep/plugin.d.ts +1 -0
- package/dist/tools/grep/types.d.ts +15 -0
- package/dist/tools/hashline-edit/constants.d.ts +4 -0
- package/dist/tools/hashline-edit/edit-operations.d.ts +4 -0
- package/dist/tools/hashline-edit/handler.d.ts +5 -0
- package/dist/tools/hashline-edit/hash-computation.d.ts +2 -0
- package/dist/tools/hashline-edit/index.d.ts +5 -0
- package/dist/tools/hashline-edit/plugin.d.ts +3 -0
- package/dist/tools/hashline-edit/types.d.ts +21 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/look-at/handler.d.ts +6 -0
- package/dist/tools/look-at/index.d.ts +3 -0
- package/dist/tools/look-at/plugin.d.ts +1 -0
- package/dist/tools/look-at/types.d.ts +9 -0
- package/dist/tools/lsp/client.d.ts +7 -0
- package/dist/tools/lsp/diagnostics/handler.d.ts +2 -0
- package/dist/tools/lsp/diagnostics/plugin.d.ts +1 -0
- package/dist/tools/lsp/diagnostics/types.d.ts +13 -0
- package/dist/tools/lsp/find-references/handler.d.ts +2 -0
- package/dist/tools/lsp/find-references/plugin.d.ts +1 -0
- package/dist/tools/lsp/find-references/types.d.ts +8 -0
- package/dist/tools/lsp/goto-definition/handler.d.ts +2 -0
- package/dist/tools/lsp/goto-definition/plugin.d.ts +1 -0
- package/dist/tools/lsp/goto-definition/types.d.ts +7 -0
- package/dist/tools/lsp/index.d.ts +6 -0
- package/dist/tools/lsp/prepare-rename/handler.d.ts +2 -0
- package/dist/tools/lsp/prepare-rename/plugin.d.ts +1 -0
- package/dist/tools/lsp/prepare-rename/types.d.ts +7 -0
- package/dist/tools/lsp/rename/handler.d.ts +2 -0
- package/dist/tools/lsp/rename/plugin.d.ts +1 -0
- package/dist/tools/lsp/rename/types.d.ts +8 -0
- package/dist/tools/lsp/symbols/handler.d.ts +2 -0
- package/dist/tools/lsp/symbols/plugin.d.ts +1 -0
- package/dist/tools/lsp/symbols/types.d.ts +11 -0
- package/dist/tools/session-manager/client-context.d.ts +3 -0
- package/dist/tools/session-manager/index.d.ts +5 -0
- package/dist/tools/session-manager/info/handler.d.ts +3 -0
- package/dist/tools/session-manager/info/plugin.d.ts +1 -0
- package/dist/tools/session-manager/info/types.d.ts +3 -0
- package/dist/tools/session-manager/list/handler.d.ts +3 -0
- package/dist/tools/session-manager/list/plugin.d.ts +1 -0
- package/dist/tools/session-manager/list/types.d.ts +6 -0
- package/dist/tools/session-manager/read/handler.d.ts +3 -0
- package/dist/tools/session-manager/read/plugin.d.ts +1 -0
- package/dist/tools/session-manager/read/types.d.ts +6 -0
- package/dist/tools/session-manager/search/handler.d.ts +3 -0
- package/dist/tools/session-manager/search/plugin.d.ts +1 -0
- package/dist/tools/session-manager/search/types.d.ts +6 -0
- package/dist/tools/session-manager/session-formatter.d.ts +29 -0
- package/dist/tools/session-manager/types.d.ts +36 -0
- package/dist/tools/shared/constants.d.ts +3 -0
- package/dist/tools/skill/handler.d.ts +4 -0
- package/dist/tools/skill/index.d.ts +3 -0
- package/dist/tools/skill/plugin.d.ts +1 -0
- package/dist/tools/skill/types.d.ts +12 -0
- package/dist/tools/skill-mcp/handler.d.ts +5 -0
- package/dist/tools/skill-mcp/index.d.ts +3 -0
- package/dist/tools/skill-mcp/plugin.d.ts +1 -0
- package/dist/tools/skill-mcp/types.d.ts +13 -0
- package/dist/tools/task/create/handler.d.ts +2 -0
- package/dist/tools/task/create/plugin.d.ts +1 -0
- package/dist/tools/task/format-task.d.ts +2 -0
- package/dist/tools/task/get/handler.d.ts +2 -0
- package/dist/tools/task/get/plugin.d.ts +1 -0
- package/dist/tools/task/index.d.ts +4 -0
- package/dist/tools/task/list/handler.d.ts +2 -0
- package/dist/tools/task/list/plugin.d.ts +1 -0
- package/dist/tools/task/storage.d.ts +7 -0
- package/dist/tools/task/types.d.ts +84 -0
- package/dist/tools/task/update/handler.d.ts +2 -0
- package/dist/tools/task/update/plugin.d.ts +1 -0
- package/dist/tools/tool-builder.d.ts +7 -0
- package/dist/tools/tool-registry-adapter.d.ts +3 -0
- package/dist/types/agent.d.ts +40 -0
- package/dist/types/category.d.ts +22 -0
- package/dist/types/config.d.ts +23 -0
- package/dist/types/hook.d.ts +18 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/plugin.d.ts +41 -0
- package/dist/types/tool.d.ts +7 -0
- package/eval/README.md +160 -0
- package/eval/ablation-config.yaml +43 -0
- package/eval/assertions/ablation-scorer.ts +81 -0
- package/eval/assertions/hook-impact.ts +152 -0
- package/eval/assertions/task-completion.ts +65 -0
- package/eval/assertions/tool-accuracy.ts +56 -0
- package/eval/promptfooconfig.yaml +42 -0
- package/eval/providers/opencode-baseline.ts +63 -0
- package/eval/providers/opencode-client.ts +112 -0
- package/eval/providers/opencode-provider.ts +66 -0
- package/eval/spike/config.yaml +13 -0
- package/eval/spike/provider.ts +15 -0
- package/npm-reserve/README.md +19 -0
- package/npm-reserve/package.json +24 -0
- package/opencode.json +6 -0
- package/package.json +47 -8
- package/src/agents/advisor/config.ts +6 -0
- package/src/agents/advisor/index.ts +2 -0
- package/src/agents/advisor/plugin.test.ts +48 -0
- package/src/agents/advisor/plugin.ts +17 -0
- package/src/agents/advisor/prompt-meta.ts +14 -0
- package/src/agents/advisor/prompt.ts +93 -0
- package/src/agents/agent-builder.test.ts +66 -0
- package/src/agents/agent-builder.ts +97 -0
- package/src/agents/agent-plugins.test.ts +98 -0
- package/src/agents/agent-registry.ts +25 -0
- package/src/agents/builtin-agents.ts +18 -0
- package/src/agents/deep-worker/config.ts +6 -0
- package/src/agents/deep-worker/index.ts +2 -0
- package/src/agents/deep-worker/plugin.test.ts +31 -0
- package/src/agents/deep-worker/plugin.ts +16 -0
- package/src/agents/deep-worker/prompt-meta.ts +14 -0
- package/src/agents/deep-worker/prompt.ts +121 -0
- package/src/agents/disabled/analyst/config.ts +6 -0
- package/src/agents/disabled/analyst/index.ts +2 -0
- package/src/agents/disabled/analyst/plugin.ts +16 -0
- package/src/agents/disabled/analyst/prompt.ts +1 -0
- package/src/agents/disabled/executor/config.ts +9 -0
- package/src/agents/disabled/executor/index.ts +2 -0
- package/src/agents/disabled/executor/plugin.ts +16 -0
- package/src/agents/disabled/executor/prompt.ts +1 -0
- package/src/agents/disabled/inspector/config.ts +6 -0
- package/src/agents/disabled/inspector/index.ts +2 -0
- package/src/agents/disabled/inspector/plugin.ts +18 -0
- package/src/agents/disabled/inspector/prompt.ts +1 -0
- package/src/agents/disabled/reviewer/config.ts +6 -0
- package/src/agents/disabled/reviewer/index.ts +2 -0
- package/src/agents/disabled/reviewer/plugin.ts +18 -0
- package/src/agents/disabled/reviewer/prompt.ts +1 -0
- package/src/agents/explorer/config.ts +6 -0
- package/src/agents/explorer/index.ts +2 -0
- package/src/agents/explorer/plugin.test.ts +36 -0
- package/src/agents/explorer/plugin.ts +15 -0
- package/src/agents/explorer/prompt-meta.ts +14 -0
- package/src/agents/explorer/prompt.ts +96 -0
- package/src/agents/fallback-chains.ts +13 -0
- package/src/agents/index.ts +18 -0
- package/src/agents/model-resolution.test.ts +79 -0
- package/src/agents/orchestrator/config.ts +10 -0
- package/src/agents/orchestrator/index.ts +2 -0
- package/src/agents/orchestrator/plugin.test.ts +31 -0
- package/src/agents/orchestrator/plugin.ts +16 -0
- package/src/agents/orchestrator/prompt-meta.ts +14 -0
- package/src/agents/orchestrator/prompt.ts +143 -0
- package/src/agents/planner/config.ts +6 -0
- package/src/agents/planner/index.ts +2 -0
- package/src/agents/planner/plugin.test.ts +31 -0
- package/src/agents/planner/plugin.ts +16 -0
- package/src/agents/planner/prompt-meta.ts +14 -0
- package/src/agents/planner/prompt.ts +138 -0
- package/src/agents/prompt-meta.ts +12 -0
- package/src/agents/prompt-registry.test.ts +98 -0
- package/src/agents/prompt-registry.ts +22 -0
- package/src/agents/researcher/config.ts +6 -0
- package/src/agents/researcher/index.ts +2 -0
- package/src/agents/researcher/plugin.test.ts +31 -0
- package/src/agents/researcher/plugin.ts +16 -0
- package/src/agents/researcher/prompt-meta.ts +14 -0
- package/src/agents/researcher/prompt.ts +116 -0
- package/src/agents/tool-restrictions.ts +87 -0
- package/src/agents/worker/config.ts +6 -0
- package/src/agents/worker/index.ts +2 -0
- package/src/agents/worker/plugin.test.ts +31 -0
- package/src/agents/worker/plugin.ts +15 -0
- package/src/agents/worker/prompt-meta.ts +14 -0
- package/src/agents/worker/prompt.ts +83 -0
- package/src/bootstrap.integration.test.ts +168 -0
- package/src/bootstrap.ts +171 -0
- package/src/cli/cli.ts +42 -0
- package/src/cli/commands/install.test.ts +40 -0
- package/src/cli/commands/install.ts +125 -0
- package/src/cli/commands/update.test.ts +84 -0
- package/src/cli/commands/update.ts +45 -0
- package/src/cli/config-generator.test.ts +178 -0
- package/src/cli/config-generator.ts +119 -0
- package/src/cli/index.test.ts +34 -0
- package/src/cli/index.ts +4 -0
- package/src/config/defaults.ts +24 -0
- package/src/config/define-config.ts +38 -0
- package/src/config/index.ts +6 -0
- package/src/config/loader.test.ts +218 -0
- package/src/config/loader.ts +89 -0
- package/src/config/paths.ts +30 -0
- package/src/config/schema.test.ts +69 -0
- package/src/config/schema.ts +57 -0
- package/src/config/validator.ts +24 -0
- package/src/features/auto-update/auto-update.test.ts +105 -0
- package/src/features/auto-update/index.ts +4 -0
- package/src/features/auto-update/plugin.ts +45 -0
- package/src/features/auto-update/update-checker.ts +66 -0
- package/src/features/background-agent/concurrency.test.ts +65 -0
- package/src/features/background-agent/concurrency.ts +44 -0
- package/src/features/background-agent/index.ts +12 -0
- package/src/features/background-agent/manager.ts +214 -0
- package/src/features/background-agent/poller.test.ts +33 -0
- package/src/features/background-agent/poller.ts +75 -0
- package/src/features/background-agent/singleton.ts +26 -0
- package/src/features/background-agent/spawner.ts +51 -0
- package/src/features/background-agent/types.ts +20 -0
- package/src/features/builtin-features.ts +5 -0
- package/src/features/categories/categories.test.ts +68 -0
- package/src/features/categories/category-config.ts +70 -0
- package/src/features/categories/category-resolver.ts +36 -0
- package/src/features/categories/index.ts +8 -0
- package/src/features/categories/prompt-appends.ts +38 -0
- package/src/features/loops/file-store.ts +151 -0
- package/src/features/loops/handler.ts +89 -0
- package/src/features/loops/index.ts +28 -0
- package/src/features/loops/loops.test.ts +175 -0
- package/src/features/loops/memory-store.ts +53 -0
- package/src/features/loops/plugin.ts +107 -0
- package/src/features/loops/shared/event-utils.ts +50 -0
- package/src/features/loops/state.ts +44 -0
- package/src/features/prompt-builder/agent-table-builder.ts +23 -0
- package/src/features/prompt-builder/category-section-builder.ts +21 -0
- package/src/features/prompt-builder/dynamic-prompt-builder.ts +42 -0
- package/src/features/prompt-builder/index.ts +7 -0
- package/src/features/prompt-builder/prompt-builder.test.ts +244 -0
- package/src/features/prompt-builder/skill-section-builder.ts +25 -0
- package/src/features/session-state/index.ts +17 -0
- package/src/features/session-state/session-cursor.test.ts +137 -0
- package/src/features/session-state/session-cursor.ts +80 -0
- package/src/features/session-state/session-store.test.ts +82 -0
- package/src/features/session-state/session-store.ts +37 -0
- package/src/features/session-state/session-tools-store.ts +18 -0
- package/src/features/skills/builtin/git-master.ts +109 -0
- package/src/features/skills/index.ts +97 -0
- package/src/features/skills/skill-loader.ts +133 -0
- package/src/features/skills/skill-merger.ts +15 -0
- package/src/features/skills/skills.test.ts +120 -0
- package/src/features/slash-commands/command-registry.ts +36 -0
- package/src/features/slash-commands/commands/cancel-loop.ts +17 -0
- package/src/features/slash-commands/commands/handoff.ts +59 -0
- package/src/features/slash-commands/commands/init-deep.ts +40 -0
- package/src/features/slash-commands/commands/loop.ts +39 -0
- package/src/features/slash-commands/commands/start-work.ts +39 -0
- package/src/features/slash-commands/commands/stop-continuation.ts +21 -0
- package/src/features/slash-commands/index.ts +2 -0
- package/src/features/slash-commands/slash-commands.test.ts +68 -0
- package/src/features/slash-commands/types.ts +5 -0
- package/src/hooks/anthropic-effort/handler.test.ts +156 -0
- package/src/hooks/anthropic-effort/handler.ts +64 -0
- package/src/hooks/anthropic-effort/index.ts +3 -0
- package/src/hooks/anthropic-effort/plugin.ts +17 -0
- package/src/hooks/builtin-hooks.ts +64 -0
- package/src/hooks/comment-checker/handler.test.ts +65 -0
- package/src/hooks/comment-checker/handler.ts +60 -0
- package/src/hooks/comment-checker/index.ts +2 -0
- package/src/hooks/comment-checker/plugin.ts +15 -0
- package/src/hooks/compaction-context/handler.test.ts +160 -0
- package/src/hooks/compaction-context/handler.ts +179 -0
- package/src/hooks/compaction-context/index.ts +5 -0
- package/src/hooks/compaction-context/plugin.ts +40 -0
- package/src/hooks/compaction-todo-preserver/handler.test.ts +155 -0
- package/src/hooks/compaction-todo-preserver/handler.ts +129 -0
- package/src/hooks/compaction-todo-preserver/index.ts +2 -0
- package/src/hooks/compaction-todo-preserver/plugin.ts +18 -0
- package/src/hooks/context-injection.test.ts +124 -0
- package/src/hooks/context-injector/handlers/agents.test.ts +90 -0
- package/src/hooks/context-injector/handlers/agents.ts +81 -0
- package/src/hooks/context-injector/handlers/readme.ts +55 -0
- package/src/hooks/context-injector/handlers/rules.ts +62 -0
- package/src/hooks/context-injector/index.ts +4 -0
- package/src/hooks/context-injector/plugin.ts +56 -0
- package/src/hooks/context-window-limit/handler.test.ts +103 -0
- package/src/hooks/context-window-limit/handler.ts +128 -0
- package/src/hooks/context-window-limit/index.ts +6 -0
- package/src/hooks/context-window-limit/plugin.ts +15 -0
- package/src/hooks/continuation.test.ts +103 -0
- package/src/hooks/delegate-retry/handler.test.ts +212 -0
- package/src/hooks/delegate-retry/handler.ts +137 -0
- package/src/hooks/delegate-retry/index.ts +8 -0
- package/src/hooks/delegate-retry/plugin.ts +15 -0
- package/src/hooks/edit-error/handler.test.ts +82 -0
- package/src/hooks/edit-error/handler.ts +50 -0
- package/src/hooks/edit-error/index.ts +6 -0
- package/src/hooks/edit-error/plugin.ts +15 -0
- package/src/hooks/empty-response-detector/handler.test.ts +133 -0
- package/src/hooks/empty-response-detector/handler.ts +62 -0
- package/src/hooks/empty-response-detector/index.ts +2 -0
- package/src/hooks/empty-response-detector/plugin.ts +18 -0
- package/src/hooks/error-diagnostics/error-diagnostics.test.ts +116 -0
- package/src/hooks/error-diagnostics/handler.test.ts +147 -0
- package/src/hooks/error-diagnostics/handler.ts +135 -0
- package/src/hooks/error-diagnostics/patterns.ts +93 -0
- package/src/hooks/error-diagnostics/plugin.ts +11 -0
- package/src/hooks/error-diagnostics/types.ts +26 -0
- package/src/hooks/error-recovery.test.ts +85 -0
- package/src/hooks/foreground-fallback/handler.test.ts +229 -0
- package/src/hooks/foreground-fallback/handler.ts +294 -0
- package/src/hooks/foreground-fallback/index.ts +2 -0
- package/src/hooks/foreground-fallback/plugin.ts +18 -0
- package/src/hooks/hashline-diff-enhancer/handler.test.ts +166 -0
- package/src/hooks/hashline-diff-enhancer/handler.ts +186 -0
- package/src/hooks/hashline-diff-enhancer/index.ts +6 -0
- package/src/hooks/hashline-diff-enhancer/plugin.ts +24 -0
- package/src/hooks/hashline-read-enhancer/handler.test.ts +121 -0
- package/src/hooks/hashline-read-enhancer/handler.ts +165 -0
- package/src/hooks/hashline-read-enhancer/index.ts +2 -0
- package/src/hooks/hashline-read-enhancer/plugin.ts +18 -0
- package/src/hooks/hook-composer.test.ts +52 -0
- package/src/hooks/hook-composer.ts +17 -0
- package/src/hooks/hook-composition.integration.test.ts +274 -0
- package/src/hooks/hook-ordering.ts +41 -0
- package/src/hooks/hook-types.ts +22 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/json-error/handler.test.ts +95 -0
- package/src/hooks/json-error/handler.ts +82 -0
- package/src/hooks/json-error/index.ts +6 -0
- package/src/hooks/json-error/plugin.ts +15 -0
- package/src/hooks/keyword-detector/handler.test.ts +113 -0
- package/src/hooks/keyword-detector/handler.ts +73 -0
- package/src/hooks/keyword-detector/index.ts +8 -0
- package/src/hooks/keyword-detector/plugin.ts +24 -0
- package/src/hooks/model-fallback/handler.test.ts +163 -0
- package/src/hooks/model-fallback/handler.ts +178 -0
- package/src/hooks/model-fallback/index.ts +2 -0
- package/src/hooks/model-fallback/plugin.ts +11 -0
- package/src/hooks/model-management.test.ts +121 -0
- package/src/hooks/phase-reminder/handler.test.ts +105 -0
- package/src/hooks/phase-reminder/handler.ts +54 -0
- package/src/hooks/phase-reminder/index.ts +2 -0
- package/src/hooks/phase-reminder/plugin.ts +18 -0
- package/src/hooks/post-read-nudge/handler.test.ts +106 -0
- package/src/hooks/post-read-nudge/handler.ts +28 -0
- package/src/hooks/post-read-nudge/index.ts +2 -0
- package/src/hooks/post-read-nudge/plugin.ts +18 -0
- package/src/hooks/preemptive-compaction/handler.test.ts +130 -0
- package/src/hooks/preemptive-compaction/handler.ts +84 -0
- package/src/hooks/preemptive-compaction/index.ts +2 -0
- package/src/hooks/preemptive-compaction/plugin.ts +15 -0
- package/src/hooks/productivity.test.ts +332 -0
- package/src/hooks/quality.test.ts +330 -0
- package/src/hooks/runtime-fallback/handler.test.ts +142 -0
- package/src/hooks/runtime-fallback/handler.ts +171 -0
- package/src/hooks/runtime-fallback/index.ts +2 -0
- package/src/hooks/runtime-fallback/plugin.ts +13 -0
- package/src/hooks/safe-hook-wrapper.test.ts +35 -0
- package/src/hooks/safe-hook-wrapper.ts +12 -0
- package/src/hooks/session-recovery/handler.test.ts +88 -0
- package/src/hooks/session-recovery/handler.ts +87 -0
- package/src/hooks/session-recovery/index.ts +6 -0
- package/src/hooks/session-recovery/plugin.ts +15 -0
- package/src/hooks/skill-discovery/plugin.ts +45 -0
- package/src/hooks/stop-guard/handler.test.ts +147 -0
- package/src/hooks/stop-guard/handler.ts +127 -0
- package/src/hooks/stop-guard/index.ts +2 -0
- package/src/hooks/stop-guard/plugin.ts +15 -0
- package/src/hooks/task-hooks.test.ts +324 -0
- package/src/hooks/task-resume-info/handler.test.ts +180 -0
- package/src/hooks/task-resume-info/handler.ts +61 -0
- package/src/hooks/task-resume-info/index.ts +2 -0
- package/src/hooks/task-resume-info/plugin.ts +15 -0
- package/src/hooks/think-mode/handler.test.ts +139 -0
- package/src/hooks/think-mode/handler.ts +50 -0
- package/src/hooks/think-mode/index.ts +2 -0
- package/src/hooks/think-mode/plugin.ts +15 -0
- package/src/hooks/thinking-block-validator/handler.test.ts +79 -0
- package/src/hooks/thinking-block-validator/handler.ts +93 -0
- package/src/hooks/thinking-block-validator/index.ts +2 -0
- package/src/hooks/thinking-block-validator/plugin.ts +18 -0
- package/src/hooks/todo-enforcer/handler.test.ts +153 -0
- package/src/hooks/todo-enforcer/handler.ts +100 -0
- package/src/hooks/todo-enforcer/index.ts +2 -0
- package/src/hooks/todo-enforcer/plugin.ts +15 -0
- package/src/hooks/todowrite-disabler/handler.test.ts +119 -0
- package/src/hooks/todowrite-disabler/handler.ts +50 -0
- package/src/hooks/todowrite-disabler/index.ts +6 -0
- package/src/hooks/todowrite-disabler/plugin.ts +46 -0
- package/src/hooks/tool-output-truncator/handler.test.ts +113 -0
- package/src/hooks/tool-output-truncator/handler.ts +83 -0
- package/src/hooks/tool-output-truncator/index.ts +2 -0
- package/src/hooks/tool-output-truncator/plugin.ts +18 -0
- package/src/hooks/tool-output.test.ts +238 -0
- package/src/hooks/workflow-reminders.test.ts +187 -0
- package/src/hooks/write-file-guard/handler.test.ts +107 -0
- package/src/hooks/write-file-guard/handler.ts +166 -0
- package/src/hooks/write-file-guard/index.ts +2 -0
- package/src/hooks/write-file-guard/plugin.ts +23 -0
- package/src/index.ts +8 -0
- package/src/plugin/compositor.ts +99 -0
- package/src/plugin/index.ts +1 -0
- package/src/plugin-api/define-plugin.test.ts +66 -0
- package/src/plugin-api/define-plugin.ts +36 -0
- package/src/plugin-api/index.ts +26 -0
- package/src/plugin-api/types.ts +28 -0
- package/src/registry/agent-aggregator.ts +13 -0
- package/src/registry/contribution-aggregator.test.ts +62 -0
- package/src/registry/contribution-aggregator.ts +114 -0
- package/src/registry/contribution-conflicts.integration.test.ts +186 -0
- package/src/registry/dependency-resolver.test.ts +35 -0
- package/src/registry/dependency-resolver.ts +64 -0
- package/src/registry/hook-aggregator.test.ts +78 -0
- package/src/registry/hook-aggregator.ts +63 -0
- package/src/registry/index.ts +6 -0
- package/src/registry/plugin-lifecycle.integration.test.ts +94 -0
- package/src/registry/plugin-overrides.integration.test.ts +140 -0
- package/src/registry/plugin-registry.test.ts +56 -0
- package/src/registry/plugin-registry.ts +82 -0
- package/src/registry/tool-aggregator.ts +13 -0
- package/src/registry/types.ts +11 -0
- package/src/runtime/index.ts +43 -0
- package/src/shared/data-path.ts +18 -0
- package/src/shared/deep-merge.test.ts +36 -0
- package/src/shared/deep-merge.ts +61 -0
- package/src/shared/fallback-chain.ts +8 -0
- package/src/shared/index.ts +59 -0
- package/src/shared/logger.ts +54 -0
- package/src/shared/model-availability.ts +18 -0
- package/src/shared/model-normalization.test.ts +75 -0
- package/src/shared/model-normalization.ts +28 -0
- package/src/shared/model-prefix-map.test.ts +75 -0
- package/src/shared/model-prefix-map.ts +58 -0
- package/src/shared/model-resolution-pipeline.test.ts +111 -0
- package/src/shared/model-resolution-pipeline.ts +55 -0
- package/src/shared/models-dev.test.ts +277 -0
- package/src/shared/models-dev.ts +176 -0
- package/src/shared/provider-discovery.test.ts +97 -0
- package/src/shared/provider-discovery.ts +73 -0
- package/src/shared/provider-registry.test.ts +212 -0
- package/src/shared/provider-registry.ts +157 -0
- package/src/shared/safe-create-hook.ts +15 -0
- package/src/shared/snake-case.ts +7 -0
- package/src/shared/truncate-description.ts +6 -0
- package/src/test-utils/index.ts +6 -0
- package/src/test-utils/mock-agent-config.ts +13 -0
- package/src/test-utils/mock-hook-inputs.ts +148 -0
- package/src/test-utils/mock-hook-outputs.ts +153 -0
- package/src/test-utils/mock-plugin-context.test.ts +32 -0
- package/src/test-utils/mock-plugin-context.ts +21 -0
- package/src/test-utils/mock-sdk-client.ts +52 -0
- package/src/test-utils/mock-tool-context.ts +24 -0
- package/src/tools/ast-grep/index.ts +4 -0
- package/src/tools/ast-grep/replace/handler.test.ts +93 -0
- package/src/tools/ast-grep/replace/handler.ts +89 -0
- package/src/tools/ast-grep/replace/plugin.ts +10 -0
- package/src/tools/ast-grep/replace/types.ts +14 -0
- package/src/tools/ast-grep/search/handler.test.ts +94 -0
- package/src/tools/ast-grep/search/handler.ts +93 -0
- package/src/tools/ast-grep/search/plugin.ts +10 -0
- package/src/tools/ast-grep/search/types.ts +42 -0
- package/src/tools/background-task/background-task.test.ts +185 -0
- package/src/tools/background-task/cancel/handler.test.ts +141 -0
- package/src/tools/background-task/cancel/handler.ts +52 -0
- package/src/tools/background-task/cancel/plugin.ts +30 -0
- package/src/tools/background-task/cancel/types.ts +4 -0
- package/src/tools/background-task/index.ts +2 -0
- package/src/tools/background-task/output/handler.test.ts +142 -0
- package/src/tools/background-task/output/handler.ts +93 -0
- package/src/tools/background-task/output/plugin.ts +60 -0
- package/src/tools/background-task/output/types.ts +11 -0
- package/src/tools/bridge.test.ts +55 -0
- package/src/tools/bridge.ts +13 -0
- package/src/tools/builtin-tools.ts +54 -0
- package/src/tools/code-search.test.ts +203 -0
- package/src/tools/delegate-task/category-resolver.ts +18 -0
- package/src/tools/delegate-task/constants.ts +43 -0
- package/src/tools/delegate-task/delegate-task.test.ts +245 -0
- package/src/tools/delegate-task/executor.ts +157 -0
- package/src/tools/delegate-task/handler.ts +74 -0
- package/src/tools/delegate-task/index.ts +7 -0
- package/src/tools/delegate-task/plugin.ts +21 -0
- package/src/tools/delegate-task/types.ts +19 -0
- package/src/tools/glob/handler.test.ts +80 -0
- package/src/tools/glob/handler.ts +74 -0
- package/src/tools/glob/index.ts +2 -0
- package/src/tools/glob/plugin.ts +10 -0
- package/src/tools/glob/types.ts +14 -0
- package/src/tools/grep/handler.test.ts +79 -0
- package/src/tools/grep/handler.ts +104 -0
- package/src/tools/grep/index.ts +2 -0
- package/src/tools/grep/plugin.ts +10 -0
- package/src/tools/grep/types.ts +28 -0
- package/src/tools/hashline-edit/constants.ts +10 -0
- package/src/tools/hashline-edit/edit-operations.ts +115 -0
- package/src/tools/hashline-edit/handler.test.ts +105 -0
- package/src/tools/hashline-edit/handler.ts +33 -0
- package/src/tools/hashline-edit/hash-computation.ts +20 -0
- package/src/tools/hashline-edit/hashline-edit.test.ts +62 -0
- package/src/tools/hashline-edit/index.ts +5 -0
- package/src/tools/hashline-edit/plugin.ts +28 -0
- package/src/tools/hashline-edit/types.ts +42 -0
- package/src/tools/index.ts +4 -0
- package/src/tools/look-at/handler.test.ts +189 -0
- package/src/tools/look-at/handler.ts +232 -0
- package/src/tools/look-at/index.ts +3 -0
- package/src/tools/look-at/look-at.test.ts +200 -0
- package/src/tools/look-at/plugin.ts +10 -0
- package/src/tools/look-at/types.ts +17 -0
- package/src/tools/lsp/client.ts +145 -0
- package/src/tools/lsp/diagnostics/handler.test.ts +94 -0
- package/src/tools/lsp/diagnostics/handler.ts +39 -0
- package/src/tools/lsp/diagnostics/plugin.ts +10 -0
- package/src/tools/lsp/diagnostics/types.ts +15 -0
- package/src/tools/lsp/find-references/handler.test.ts +79 -0
- package/src/tools/lsp/find-references/handler.ts +38 -0
- package/src/tools/lsp/find-references/plugin.ts +10 -0
- package/src/tools/lsp/find-references/types.ts +10 -0
- package/src/tools/lsp/goto-definition/handler.test.ts +80 -0
- package/src/tools/lsp/goto-definition/handler.ts +38 -0
- package/src/tools/lsp/goto-definition/plugin.ts +10 -0
- package/src/tools/lsp/goto-definition/types.ts +9 -0
- package/src/tools/lsp/index.ts +6 -0
- package/src/tools/lsp/lsp-tools.test.ts +150 -0
- package/src/tools/lsp/prepare-rename/handler.test.ts +81 -0
- package/src/tools/lsp/prepare-rename/handler.ts +34 -0
- package/src/tools/lsp/prepare-rename/plugin.ts +10 -0
- package/src/tools/lsp/prepare-rename/types.ts +9 -0
- package/src/tools/lsp/rename/handler.test.ts +87 -0
- package/src/tools/lsp/rename/handler.ts +34 -0
- package/src/tools/lsp/rename/plugin.ts +10 -0
- package/src/tools/lsp/rename/types.ts +10 -0
- package/src/tools/lsp/symbols/handler.test.ts +108 -0
- package/src/tools/lsp/symbols/handler.ts +43 -0
- package/src/tools/lsp/symbols/plugin.ts +10 -0
- package/src/tools/lsp/symbols/types.ts +13 -0
- package/src/tools/session-manager/client-context.ts +16 -0
- package/src/tools/session-manager/index.ts +5 -0
- package/src/tools/session-manager/info/handler.test.ts +100 -0
- package/src/tools/session-manager/info/handler.ts +27 -0
- package/src/tools/session-manager/info/plugin.ts +40 -0
- package/src/tools/session-manager/info/types.ts +3 -0
- package/src/tools/session-manager/list/handler.test.ts +122 -0
- package/src/tools/session-manager/list/handler.ts +56 -0
- package/src/tools/session-manager/list/plugin.ts +52 -0
- package/src/tools/session-manager/list/types.ts +6 -0
- package/src/tools/session-manager/read/handler.test.ts +114 -0
- package/src/tools/session-manager/read/handler.ts +36 -0
- package/src/tools/session-manager/read/plugin.ts +57 -0
- package/src/tools/session-manager/read/types.ts +6 -0
- package/src/tools/session-manager/search/handler.test.ts +115 -0
- package/src/tools/session-manager/search/handler.ts +72 -0
- package/src/tools/session-manager/search/plugin.ts +57 -0
- package/src/tools/session-manager/search/types.ts +6 -0
- package/src/tools/session-manager/session-formatter.ts +315 -0
- package/src/tools/session-manager/session-manager.test.ts +254 -0
- package/src/tools/session-manager/types.ts +41 -0
- package/src/tools/shared/constants.ts +3 -0
- package/src/tools/skill/handler.test.ts +57 -0
- package/src/tools/skill/handler.ts +27 -0
- package/src/tools/skill/index.ts +3 -0
- package/src/tools/skill/plugin.ts +41 -0
- package/src/tools/skill/types.ts +14 -0
- package/src/tools/skill-mcp/handler.test.ts +68 -0
- package/src/tools/skill-mcp/handler.ts +84 -0
- package/src/tools/skill-mcp/index.ts +3 -0
- package/src/tools/skill-mcp/plugin.ts +37 -0
- package/src/tools/skill-mcp/types.ts +15 -0
- package/src/tools/skill-tools.test.ts +172 -0
- package/src/tools/task/create/handler.test.ts +64 -0
- package/src/tools/task/create/handler.ts +43 -0
- package/src/tools/task/create/plugin.ts +10 -0
- package/src/tools/task/format-task.test.ts +37 -0
- package/src/tools/task/format-task.ts +19 -0
- package/src/tools/task/get/handler.test.ts +76 -0
- package/src/tools/task/get/handler.ts +35 -0
- package/src/tools/task/get/plugin.ts +10 -0
- package/src/tools/task/index.ts +4 -0
- package/src/tools/task/list/handler.test.ts +70 -0
- package/src/tools/task/list/handler.ts +48 -0
- package/src/tools/task/list/plugin.ts +10 -0
- package/src/tools/task/storage.ts +14 -0
- package/src/tools/task/task.test.ts +165 -0
- package/src/tools/task/types.ts +51 -0
- package/src/tools/task/update/handler.test.ts +86 -0
- package/src/tools/task/update/handler.ts +54 -0
- package/src/tools/task/update/plugin.ts +10 -0
- package/src/tools/tool-builder.test.ts +32 -0
- package/src/tools/tool-builder.ts +24 -0
- package/src/tools/tool-registry-adapter.test.ts +51 -0
- package/src/tools/tool-registry-adapter.ts +19 -0
- package/src/types/agent.ts +53 -0
- package/src/types/category.ts +32 -0
- package/src/types/config.ts +26 -0
- package/src/types/hook.ts +44 -0
- package/src/types/index.ts +12 -0
- package/src/types/plugin.ts +47 -0
- package/src/types/tool.ts +10 -0
- package/test-setup.ts +8 -0
- package/tsconfig.json +20 -0
- /package/{index.js → npm-reserve/index.js} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CategoryConfig } from "./types";
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_CATEGORIES: Record<string, CategoryConfig> = {
|
|
4
|
+
"visual-engineering": {
|
|
5
|
+
model: "gemini-3.1-pro",
|
|
6
|
+
variant: "high",
|
|
7
|
+
description: "Frontend, UI/UX, design, styling, animation",
|
|
8
|
+
},
|
|
9
|
+
ultrabrain: {
|
|
10
|
+
model: "gpt-5.4",
|
|
11
|
+
variant: "xhigh",
|
|
12
|
+
description: "Hard logic, architecture decisions, complex reasoning",
|
|
13
|
+
},
|
|
14
|
+
deep: {
|
|
15
|
+
model: "gpt-5.3-codex",
|
|
16
|
+
variant: "medium",
|
|
17
|
+
description: "Goal-oriented autonomous problem-solving, deep research",
|
|
18
|
+
},
|
|
19
|
+
artistry: {
|
|
20
|
+
model: "gemini-3.1-pro",
|
|
21
|
+
variant: "high",
|
|
22
|
+
description: "Creative approaches, unconventional solutions",
|
|
23
|
+
},
|
|
24
|
+
quick: {
|
|
25
|
+
model: "gpt-5.4-mini",
|
|
26
|
+
description: "Trivial tasks, single file changes, typo fixes",
|
|
27
|
+
},
|
|
28
|
+
"unspecified-low": {
|
|
29
|
+
model: "claude-sonnet-4-6",
|
|
30
|
+
description: "Moderate effort tasks that don't fit other categories",
|
|
31
|
+
},
|
|
32
|
+
"unspecified-high": {
|
|
33
|
+
model: "claude-opus-4-6",
|
|
34
|
+
variant: "max",
|
|
35
|
+
description: "High effort tasks that don't fit other categories",
|
|
36
|
+
},
|
|
37
|
+
writing: {
|
|
38
|
+
model: "gemini-3.1-flash-lite",
|
|
39
|
+
description: "Documentation, prose, technical writing",
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const CATEGORY_NAMES = Object.keys(DEFAULT_CATEGORIES);
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { describe, it, expect, mock } from "bun:test";
|
|
2
|
+
import { resolveCategory } from "./category-resolver";
|
|
3
|
+
import { DEFAULT_CATEGORIES, CATEGORY_NAMES } from "./constants";
|
|
4
|
+
import type { BackgroundTask, BackgroundAgentManager } from "../../runtime";
|
|
5
|
+
import { createTaskTool } from "./handler";
|
|
6
|
+
import type { ToolDefinition } from "@opencode-ai/plugin";
|
|
7
|
+
|
|
8
|
+
function makeMockManager() {
|
|
9
|
+
const launched: Array<{ id: string; prompt: string; model: string }> = [];
|
|
10
|
+
return {
|
|
11
|
+
launched,
|
|
12
|
+
launch: mock(async (_ctx: unknown, input: { id: string; prompt: string; model: string }) => {
|
|
13
|
+
launched.push(input);
|
|
14
|
+
return {
|
|
15
|
+
id: input.id,
|
|
16
|
+
status: "queued" as BackgroundTask["status"],
|
|
17
|
+
prompt: input.prompt,
|
|
18
|
+
model: input.model,
|
|
19
|
+
createdAt: Date.now(),
|
|
20
|
+
};
|
|
21
|
+
}),
|
|
22
|
+
get: mock(() => undefined),
|
|
23
|
+
getAll: mock(() => []),
|
|
24
|
+
complete: mock(() => {}),
|
|
25
|
+
fail: mock(() => {}),
|
|
26
|
+
cancel: mock(async () => {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function makeMockToolContext(overrides: Partial<Parameters<ToolDefinition["execute"]>[1]> = {}) {
|
|
31
|
+
return {
|
|
32
|
+
sessionID: "test-session",
|
|
33
|
+
messageID: "test-message",
|
|
34
|
+
agent: "test-agent",
|
|
35
|
+
directory: "/tmp/test",
|
|
36
|
+
worktree: "/tmp/test",
|
|
37
|
+
abort: new AbortController().signal,
|
|
38
|
+
metadata: () => {},
|
|
39
|
+
ask: async () => {},
|
|
40
|
+
client: makeMockClient(),
|
|
41
|
+
...overrides,
|
|
42
|
+
} as unknown as Parameters<ToolDefinition["execute"]>[1];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function makeMockClient() {
|
|
46
|
+
return {
|
|
47
|
+
session: {
|
|
48
|
+
create: mock(async () => ({
|
|
49
|
+
data: { id: "sync-session-123" },
|
|
50
|
+
error: undefined,
|
|
51
|
+
})),
|
|
52
|
+
promptAsync: mock(async () => ({
|
|
53
|
+
data: {},
|
|
54
|
+
error: undefined,
|
|
55
|
+
})),
|
|
56
|
+
status: mock(async () => ({
|
|
57
|
+
data: {
|
|
58
|
+
"sync-session-123": { type: "idle" },
|
|
59
|
+
},
|
|
60
|
+
})),
|
|
61
|
+
messages: mock(async () => ({
|
|
62
|
+
data: [
|
|
63
|
+
{ role: "user", content: "test prompt" },
|
|
64
|
+
{ role: "assistant", content: "task result here" },
|
|
65
|
+
],
|
|
66
|
+
})),
|
|
67
|
+
delete: mock(async () => ({})),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
describe("resolveCategory", () => {
|
|
73
|
+
describe("#given the resolveCategory function", () => {
|
|
74
|
+
describe("#when resolving all 8 default categories", () => {
|
|
75
|
+
it("#then each resolves to a valid config", () => {
|
|
76
|
+
const expected = [
|
|
77
|
+
"visual-engineering",
|
|
78
|
+
"ultrabrain",
|
|
79
|
+
"deep",
|
|
80
|
+
"artistry",
|
|
81
|
+
"quick",
|
|
82
|
+
"unspecified-low",
|
|
83
|
+
"unspecified-high",
|
|
84
|
+
"writing",
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
for (const name of expected) {
|
|
88
|
+
const config = resolveCategory(name);
|
|
89
|
+
expect(config).toBeDefined();
|
|
90
|
+
expect(config?.model).toBeTypeOf("string");
|
|
91
|
+
expect((config?.model ?? "").length).toBeGreaterThan(0);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe("#when resolving visual-engineering", () => {
|
|
97
|
+
it("#then returns gemini-3.1-pro with high variant", () => {
|
|
98
|
+
const config = resolveCategory("visual-engineering");
|
|
99
|
+
expect(config?.model).toBe("gemini-3.1-pro");
|
|
100
|
+
expect(config?.variant).toBe("high");
|
|
101
|
+
expect(config?.description).toBe("Frontend, UI/UX, design, styling, animation");
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe("#when resolving ultrabrain", () => {
|
|
106
|
+
it("#then returns gpt-5.4 with xhigh variant", () => {
|
|
107
|
+
const config = resolveCategory("ultrabrain");
|
|
108
|
+
expect(config?.model).toBe("gpt-5.4");
|
|
109
|
+
expect(config?.variant).toBe("xhigh");
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe("#when resolving an unknown category", () => {
|
|
114
|
+
it("#then returns undefined", () => {
|
|
115
|
+
const config = resolveCategory("nonexistent-category");
|
|
116
|
+
expect(config).toBeUndefined();
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe("#when listing categories", () => {
|
|
121
|
+
it("#then returns all 8 category names", () => {
|
|
122
|
+
expect(CATEGORY_NAMES).toHaveLength(8);
|
|
123
|
+
expect(CATEGORY_NAMES).toContain("visual-engineering");
|
|
124
|
+
expect(CATEGORY_NAMES).toContain("ultrabrain");
|
|
125
|
+
expect(CATEGORY_NAMES).toContain("deep");
|
|
126
|
+
expect(CATEGORY_NAMES).toContain("artistry");
|
|
127
|
+
expect(CATEGORY_NAMES).toContain("quick");
|
|
128
|
+
expect(CATEGORY_NAMES).toContain("unspecified-low");
|
|
129
|
+
expect(CATEGORY_NAMES).toContain("unspecified-high");
|
|
130
|
+
expect(CATEGORY_NAMES).toContain("writing");
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe("DEFAULT_CATEGORIES", () => {
|
|
137
|
+
describe("#given the constant map", () => {
|
|
138
|
+
describe("#when checking category count", () => {
|
|
139
|
+
it("#then has exactly 8 entries", () => {
|
|
140
|
+
expect(Object.keys(DEFAULT_CATEGORIES)).toHaveLength(8);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe("#when checking each category has a model", () => {
|
|
145
|
+
it("#then every entry has a non-empty model string", () => {
|
|
146
|
+
for (const [, config] of Object.entries(DEFAULT_CATEGORIES)) {
|
|
147
|
+
expect(config.model.length).toBeGreaterThan(0);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe("CATEGORY_NAMES", () => {
|
|
155
|
+
describe("#given the names array", () => {
|
|
156
|
+
it("#then matches the keys of DEFAULT_CATEGORIES", () => {
|
|
157
|
+
expect(CATEGORY_NAMES).toEqual(Object.keys(DEFAULT_CATEGORIES));
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
describe("createTaskTool", () => {
|
|
163
|
+
describe("#given a task tool with mock manager", () => {
|
|
164
|
+
const manager = makeMockManager();
|
|
165
|
+
const tool = createTaskTool(() => manager as unknown as BackgroundAgentManager);
|
|
166
|
+
|
|
167
|
+
describe("#when executing with an unknown category", () => {
|
|
168
|
+
it("#then returns an error listing available categories", async () => {
|
|
169
|
+
const ctx = makeMockToolContext();
|
|
170
|
+
const result = await tool.execute(
|
|
171
|
+
{
|
|
172
|
+
category: "bogus",
|
|
173
|
+
description: "test task",
|
|
174
|
+
prompt: "do something",
|
|
175
|
+
run_in_background: false,
|
|
176
|
+
},
|
|
177
|
+
ctx,
|
|
178
|
+
);
|
|
179
|
+
expect(result).toContain("Unknown category");
|
|
180
|
+
expect(result).toContain("bogus");
|
|
181
|
+
expect(result).toContain("visual-engineering");
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
describe("#when executing background task with valid category", () => {
|
|
186
|
+
it("#then launches via manager and returns task id", async () => {
|
|
187
|
+
const bgManager = makeMockManager();
|
|
188
|
+
const bgTool = createTaskTool(() => bgManager as unknown as BackgroundAgentManager);
|
|
189
|
+
const ctx = makeMockToolContext();
|
|
190
|
+
|
|
191
|
+
const result = await bgTool.execute(
|
|
192
|
+
{
|
|
193
|
+
category: "quick",
|
|
194
|
+
description: "fix typo",
|
|
195
|
+
prompt: "fix the typo in readme",
|
|
196
|
+
run_in_background: true,
|
|
197
|
+
},
|
|
198
|
+
ctx,
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
expect(result).toContain("Background task launched");
|
|
202
|
+
expect(result).toContain("quick");
|
|
203
|
+
expect(result).toContain("gpt-5.4-mini");
|
|
204
|
+
expect(bgManager.launch).toHaveBeenCalledTimes(1);
|
|
205
|
+
expect(bgManager.launched[0].model).toBe("gpt-5.4-mini");
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
describe("#when executing sync task with valid category", () => {
|
|
210
|
+
it("#then creates session and returns result", async () => {
|
|
211
|
+
const syncManager = makeMockManager();
|
|
212
|
+
const syncTool = createTaskTool(() => syncManager as unknown as BackgroundAgentManager);
|
|
213
|
+
const ctx = makeMockToolContext();
|
|
214
|
+
|
|
215
|
+
const result = await syncTool.execute(
|
|
216
|
+
{
|
|
217
|
+
category: "unspecified-low",
|
|
218
|
+
description: "moderate task",
|
|
219
|
+
prompt: "implement the feature",
|
|
220
|
+
run_in_background: false,
|
|
221
|
+
},
|
|
222
|
+
ctx,
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
expect(result).toBe("task result here");
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe("#given the tool definition", () => {
|
|
231
|
+
const manager = makeMockManager();
|
|
232
|
+
const tool = createTaskTool(() => manager as unknown as BackgroundAgentManager);
|
|
233
|
+
|
|
234
|
+
describe("#when checking tool metadata", () => {
|
|
235
|
+
it("#then has a description mentioning categories", () => {
|
|
236
|
+
expect(tool.description).toContain("category-based agent");
|
|
237
|
+
expect(tool.description).toContain("visual-engineering");
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("#then has args defined", () => {
|
|
241
|
+
expect(tool.args).toBeDefined();
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { OpenCodeContext } from "../../types/plugin";
|
|
2
|
+
import type { BackgroundAgentManager } from "../../runtime";
|
|
3
|
+
import type { TaskInput, CategoryConfig } from "./types";
|
|
4
|
+
import { log } from "../../shared/logger";
|
|
5
|
+
import { parseModelId } from "../../shared/model-normalization";
|
|
6
|
+
import { qualifyModel } from "../../shared/provider-registry";
|
|
7
|
+
|
|
8
|
+
export interface ExecutorDeps {
|
|
9
|
+
manager: BackgroundAgentManager;
|
|
10
|
+
client: OpenCodeContext["client"];
|
|
11
|
+
directory: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function executeBackground(
|
|
15
|
+
input: TaskInput,
|
|
16
|
+
config: CategoryConfig,
|
|
17
|
+
deps: ExecutorDeps,
|
|
18
|
+
): Promise<string> {
|
|
19
|
+
if (input.session_id) {
|
|
20
|
+
return "Error: 'session_id' is not supported for background tasks. Use run_in_background=false to resume a session.";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { manager, client, directory } = deps;
|
|
24
|
+
const taskId = `task_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
25
|
+
|
|
26
|
+
log("[delegate-task] Launching background task", {
|
|
27
|
+
taskId,
|
|
28
|
+
category: input.category,
|
|
29
|
+
model: config.model,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const ctx: OpenCodeContext = { client, directory } as OpenCodeContext;
|
|
33
|
+
const task = await manager.launch(ctx, {
|
|
34
|
+
id: taskId,
|
|
35
|
+
prompt: input.prompt,
|
|
36
|
+
model: config.model,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return formatBackgroundResult(task.id, input, config);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function formatBackgroundResult(taskId: string, input: TaskInput, config: CategoryConfig): string {
|
|
43
|
+
return [
|
|
44
|
+
"Background task launched.",
|
|
45
|
+
"",
|
|
46
|
+
`Task ID: ${taskId}`,
|
|
47
|
+
`Category: ${input.category}`,
|
|
48
|
+
`Model: ${config.model}${config.variant ? ` (variant: ${config.variant})` : ""}`,
|
|
49
|
+
`Description: ${input.description}`,
|
|
50
|
+
"",
|
|
51
|
+
`Use \`background_output\` with task_id="${taskId}" to check status.`,
|
|
52
|
+
].join("\n");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function executeSync(
|
|
56
|
+
input: TaskInput,
|
|
57
|
+
config: CategoryConfig,
|
|
58
|
+
deps: ExecutorDeps,
|
|
59
|
+
): Promise<string> {
|
|
60
|
+
const { client, directory } = deps;
|
|
61
|
+
|
|
62
|
+
log("[delegate-task] Executing sync task", {
|
|
63
|
+
category: input.category,
|
|
64
|
+
model: config.model,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
let sessionId: string;
|
|
68
|
+
|
|
69
|
+
if (input.session_id) {
|
|
70
|
+
sessionId = input.session_id;
|
|
71
|
+
log("[delegate-task] Resuming existing session", { sessionId });
|
|
72
|
+
} else {
|
|
73
|
+
const createResult = await client.session.create({
|
|
74
|
+
body: { title: `task:${input.category}:${input.description.slice(0, 50)}` },
|
|
75
|
+
query: { directory },
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (createResult.error) {
|
|
79
|
+
const errorMsg = `Failed to create session: ${String(createResult.error)}`;
|
|
80
|
+
log("[delegate-task] Session creation failed", { error: errorMsg });
|
|
81
|
+
return errorMsg;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
sessionId = createResult.data.id;
|
|
85
|
+
}
|
|
86
|
+
const parsed = parseModelId(qualifyModel(config.model));
|
|
87
|
+
|
|
88
|
+
const promptResult = await client.session.promptAsync({
|
|
89
|
+
path: { id: sessionId },
|
|
90
|
+
body: {
|
|
91
|
+
parts: [{ type: "text", text: input.prompt }],
|
|
92
|
+
...(parsed && { model: { providerID: parsed.provider, modelID: parsed.modelId } }),
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (promptResult.error) {
|
|
97
|
+
const errorMsg = `Failed to send prompt: ${String(promptResult.error)}`;
|
|
98
|
+
log("[delegate-task] Prompt send failed", { error: errorMsg, sessionId });
|
|
99
|
+
return errorMsg;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return await pollForResult(client, directory, sessionId);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const POLL_INTERVAL_MS = 2_000;
|
|
106
|
+
const MAX_POLL_DURATION_MS = 5 * 60 * 1_000;
|
|
107
|
+
|
|
108
|
+
async function pollForResult(
|
|
109
|
+
client: OpenCodeContext["client"],
|
|
110
|
+
directory: string,
|
|
111
|
+
sessionId: string,
|
|
112
|
+
): Promise<string> {
|
|
113
|
+
const start = Date.now();
|
|
114
|
+
|
|
115
|
+
while (Date.now() - start < MAX_POLL_DURATION_MS) {
|
|
116
|
+
const statusResult = await client.session.status({
|
|
117
|
+
query: { directory },
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const sessionStatus = statusResult.data?.[sessionId]?.type;
|
|
121
|
+
// undefined means session not yet visible in status map — keep polling
|
|
122
|
+
if (sessionStatus === undefined) {
|
|
123
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (sessionStatus === "idle") {
|
|
127
|
+
return await fetchLastAssistantMessage(client, sessionId);
|
|
128
|
+
}
|
|
129
|
+
// any status other than active running states is terminal
|
|
130
|
+
if (sessionStatus !== "busy" && sessionStatus !== "retry") {
|
|
131
|
+
return await fetchLastAssistantMessage(client, sessionId);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return `Task timed out after ${MAX_POLL_DURATION_MS / 1_000}s. Session: ${sessionId}`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
type SessionMessage = {
|
|
141
|
+
role?: string;
|
|
142
|
+
content?: string;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
async function fetchLastAssistantMessage(
|
|
146
|
+
client: OpenCodeContext["client"],
|
|
147
|
+
sessionId: string,
|
|
148
|
+
): Promise<string> {
|
|
149
|
+
const messagesResult = await client.session.messages({
|
|
150
|
+
path: { id: sessionId },
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const messages = (messagesResult.data ?? []) as SessionMessage[];
|
|
154
|
+
const lastAssistant = [...messages].reverse().find((m) => m.role === "assistant");
|
|
155
|
+
|
|
156
|
+
return lastAssistant?.content ?? "Task completed but no response was returned.";
|
|
157
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ToolDefinition } from "@opencode-ai/plugin";
|
|
2
|
+
import type { BackgroundAgentManager } from "../../runtime";
|
|
3
|
+
import type { TaskInput, CategoryConfig } from "./types";
|
|
4
|
+
import type { ExecutorDeps } from "./executor";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
import { buildTool } from "../tool-builder";
|
|
8
|
+
import { getClientFromToolContext } from "../lsp/client";
|
|
9
|
+
import { resolveCategory } from "./category-resolver";
|
|
10
|
+
import { executeBackground, executeSync } from "./executor";
|
|
11
|
+
import { CATEGORY_NAMES } from "./constants";
|
|
12
|
+
import { log } from "../../shared/logger";
|
|
13
|
+
|
|
14
|
+
const categoryListForDescription = CATEGORY_NAMES.map((name) => `"${name}"`).join(", ");
|
|
15
|
+
|
|
16
|
+
const taskArgsSchema = z.object({
|
|
17
|
+
category: z.string().describe(`Category to route to. One of: ${categoryListForDescription}`),
|
|
18
|
+
description: z.string().describe("Short 3-5 word task description"),
|
|
19
|
+
prompt: z.string().describe("Full prompt/instructions for the delegated agent"),
|
|
20
|
+
load_skills: z.array(z.string()).optional().describe("Skill names to inject"),
|
|
21
|
+
run_in_background: z
|
|
22
|
+
.boolean()
|
|
23
|
+
.describe("true: async (returns task_id), false: sync (waits for result)"),
|
|
24
|
+
session_id: z.string().optional().describe("Resume an existing session"),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export function createTaskTool(getManager: () => BackgroundAgentManager): ToolDefinition {
|
|
28
|
+
return buildTool({
|
|
29
|
+
description: [
|
|
30
|
+
"Delegate a task to a category-based agent.",
|
|
31
|
+
`Available categories: ${categoryListForDescription}.`,
|
|
32
|
+
"Set run_in_background=true for async execution (returns task_id), false for sync.",
|
|
33
|
+
].join(" "),
|
|
34
|
+
args: taskArgsSchema.shape as unknown as ToolDefinition["args"],
|
|
35
|
+
execute: async (rawArgs, toolContext) => {
|
|
36
|
+
const args = taskArgsSchema.parse(rawArgs);
|
|
37
|
+
const input: TaskInput = {
|
|
38
|
+
category: args.category,
|
|
39
|
+
description: args.description,
|
|
40
|
+
prompt: args.prompt,
|
|
41
|
+
load_skills: args.load_skills,
|
|
42
|
+
run_in_background: args.run_in_background,
|
|
43
|
+
session_id: args.session_id,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const config = resolveCategory(input.category) as CategoryConfig | undefined;
|
|
47
|
+
if (!config) {
|
|
48
|
+
const available = CATEGORY_NAMES.join(", ");
|
|
49
|
+
log("[delegate-task] Unknown category", { category: input.category });
|
|
50
|
+
return `Unknown category: "${input.category}". Available: ${available}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const client = getClientFromToolContext(toolContext);
|
|
54
|
+
const manager = getManager();
|
|
55
|
+
const deps: ExecutorDeps = {
|
|
56
|
+
manager,
|
|
57
|
+
client,
|
|
58
|
+
directory: toolContext.directory,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
log("[delegate-task] Routing task", {
|
|
62
|
+
category: input.category,
|
|
63
|
+
model: config.model,
|
|
64
|
+
background: input.run_in_background,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (input.run_in_background) {
|
|
68
|
+
return executeBackground(input, config, deps);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return executeSync(input, config, deps);
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { TaskInput, CategoryConfig } from "./types";
|
|
2
|
+
export type { ExecutorDeps } from "./executor";
|
|
3
|
+
export { DEFAULT_CATEGORIES, CATEGORY_NAMES } from "./constants";
|
|
4
|
+
export { resolveCategory, resolveCategoryWithDefaults } from "./category-resolver";
|
|
5
|
+
export { createTaskTool } from "./handler";
|
|
6
|
+
export { executeBackground, executeSync } from "./executor";
|
|
7
|
+
export { default as delegateTaskPlugin } from "./plugin";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { definePlugin } from "../../plugin-api/define-plugin";
|
|
2
|
+
import { getBackgroundAgent, initBackgroundAgent, resetBackgroundAgent } from "../../runtime";
|
|
3
|
+
import { createTaskTool } from "./handler";
|
|
4
|
+
|
|
5
|
+
function getManagerOrThrow() {
|
|
6
|
+
return getBackgroundAgent().manager;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default definePlugin({
|
|
10
|
+
name: "delegate-task",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
setup() {
|
|
13
|
+
initBackgroundAgent();
|
|
14
|
+
},
|
|
15
|
+
teardown() {
|
|
16
|
+
resetBackgroundAgent();
|
|
17
|
+
},
|
|
18
|
+
tools: {
|
|
19
|
+
task: createTaskTool(getManagerOrThrow),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface TaskInput {
|
|
2
|
+
category: string;
|
|
3
|
+
description: string;
|
|
4
|
+
prompt: string;
|
|
5
|
+
load_skills?: string[];
|
|
6
|
+
run_in_background: boolean;
|
|
7
|
+
session_id?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CategoryConfig {
|
|
11
|
+
model: string;
|
|
12
|
+
variant?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CategoryResolver {
|
|
17
|
+
resolve(categoryName: string): CategoryConfig | undefined;
|
|
18
|
+
list(): string[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, it, expect, mock } from "bun:test";
|
|
2
|
+
import { mkdtemp, rm, utimes, writeFile } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { createGlobTool } from "./handler";
|
|
6
|
+
import { createMockToolContext } from "../../test-utils";
|
|
7
|
+
|
|
8
|
+
describe("globTool", () => {
|
|
9
|
+
let tempDir: string;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
tempDir = await mkdtemp(join(tmpdir(), "goatcode-glob-handler-test-"));
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
afterEach(async () => {
|
|
16
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe("#given files matching a pattern", () => {
|
|
20
|
+
describe("#when scanner returns matches", () => {
|
|
21
|
+
it("#then returns files sorted by modification time (newest first)", async () => {
|
|
22
|
+
await writeFile(join(tempDir, "old.ts"), "export const old = true");
|
|
23
|
+
await writeFile(join(tempDir, "new.ts"), "export const newer = true");
|
|
24
|
+
const now = Date.now() / 1000;
|
|
25
|
+
await utimes(join(tempDir, "old.ts"), now - 10, now - 10);
|
|
26
|
+
await utimes(join(tempDir, "new.ts"), now, now);
|
|
27
|
+
|
|
28
|
+
const scanner = mock(async () => ["old.ts", "new.ts"]);
|
|
29
|
+
const tool = createGlobTool(scanner);
|
|
30
|
+
const ctx = createMockToolContext({ directory: tempDir });
|
|
31
|
+
|
|
32
|
+
const result = await tool.execute({ pattern: "*.ts" }, ctx);
|
|
33
|
+
|
|
34
|
+
expect(scanner).toHaveBeenCalledTimes(1);
|
|
35
|
+
const lines = String(result).split("\n");
|
|
36
|
+
expect(lines[0]).toBe(join(tempDir, "new.ts"));
|
|
37
|
+
expect(lines[1]).toBe(join(tempDir, "old.ts"));
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("#given more files than the maximum limit", () => {
|
|
43
|
+
describe("#when scanner returns over 100 files", () => {
|
|
44
|
+
it("#then returns at most 100 files", async () => {
|
|
45
|
+
const totalFiles = 105;
|
|
46
|
+
const fileNames: string[] = [];
|
|
47
|
+
for (let i = 0; i < totalFiles; i++) {
|
|
48
|
+
const name = `file-${i.toString().padStart(3, "0")}.ts`;
|
|
49
|
+
fileNames.push(name);
|
|
50
|
+
await writeFile(join(tempDir, name), "");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const scanner = mock(async () => fileNames);
|
|
54
|
+
const tool = createGlobTool(scanner);
|
|
55
|
+
const ctx = createMockToolContext({ directory: tempDir });
|
|
56
|
+
|
|
57
|
+
const result = await tool.execute({ pattern: "*.ts" }, ctx);
|
|
58
|
+
|
|
59
|
+
const lines = String(result)
|
|
60
|
+
.split("\n")
|
|
61
|
+
.filter((l) => l.length > 0);
|
|
62
|
+
expect(lines.length).toBe(100);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("#given a pattern matching no files", () => {
|
|
68
|
+
describe("#when scanner returns empty array", () => {
|
|
69
|
+
it("#then returns no files found message", async () => {
|
|
70
|
+
const scanner = mock(async () => []);
|
|
71
|
+
const tool = createGlobTool(scanner);
|
|
72
|
+
const ctx = createMockToolContext({ directory: tempDir });
|
|
73
|
+
|
|
74
|
+
const result = await tool.execute({ pattern: "*.xyz" }, ctx);
|
|
75
|
+
|
|
76
|
+
expect(result).toBe("No files found");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|