goatcode-sh 0.0.1 → 0.1.3
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 +6 -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 +8623 -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 +4 -0
- package/dist/tools/delegate-task/index.d.ts +7 -0
- package/dist/tools/delegate-task/plugin.d.ts +4 -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 +166 -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 +140 -0
- package/src/hooks/context-injector/handlers/agents.ts +101 -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 +159 -0
- package/src/hooks/post-read-nudge/handler.ts +64 -0
- package/src/hooks/post-read-nudge/index.ts +6 -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 +107 -0
- package/src/tools/delegate-task/index.ts +7 -0
- package/src/tools/delegate-task/plugin.ts +30 -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
package/src/bootstrap.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { Hooks } from "@opencode-ai/plugin";
|
|
2
|
+
import { loadConfig } from "./config/loader";
|
|
3
|
+
import { validateConfig } from "./config/validator";
|
|
4
|
+
import { PluginRegistry } from "./registry/plugin-registry";
|
|
5
|
+
import { compose } from "./plugin/compositor";
|
|
6
|
+
import { log } from "./shared/logger";
|
|
7
|
+
import type { OpenCodeContext } from "./types/plugin";
|
|
8
|
+
import type { GoatCodeConfig } from "./types/config";
|
|
9
|
+
import type { PluginDefinition } from "./types/plugin";
|
|
10
|
+
import { BUILTIN_AGENT_PLUGINS } from "./agents/builtin-agents";
|
|
11
|
+
import { BUILTIN_HOOK_PLUGINS } from "./hooks/builtin-hooks";
|
|
12
|
+
import { BUILTIN_TOOL_PLUGINS } from "./tools/builtin-tools";
|
|
13
|
+
import { BUILTIN_FEATURE_PLUGINS } from "./features/builtin-features";
|
|
14
|
+
import { registerProjectSkillLoader } from "./features/skills";
|
|
15
|
+
import {
|
|
16
|
+
buildDiscoveryIndex,
|
|
17
|
+
initializeDiscovery,
|
|
18
|
+
resetDiscovery,
|
|
19
|
+
type ProviderListResponse,
|
|
20
|
+
} from "./shared/provider-discovery";
|
|
21
|
+
import {
|
|
22
|
+
resetProviderRegistry,
|
|
23
|
+
setDefaultPreferredProvider,
|
|
24
|
+
setProviderPriority,
|
|
25
|
+
} from "./shared/provider-registry";
|
|
26
|
+
|
|
27
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
28
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isStringArray(value: unknown): value is string[] {
|
|
32
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isValidPluginDefinition(value: unknown): value is PluginDefinition {
|
|
36
|
+
if (!isRecord(value)) return false;
|
|
37
|
+
const obj = value;
|
|
38
|
+
|
|
39
|
+
// Required: non-empty name string
|
|
40
|
+
if (typeof obj["name"] !== "string" || obj["name"] === "") return false;
|
|
41
|
+
|
|
42
|
+
// Optional: dependencies must be array of strings if present
|
|
43
|
+
if (obj["dependencies"] !== undefined) {
|
|
44
|
+
if (!isStringArray(obj["dependencies"])) return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Optional: hooks/tools/agents must be plain objects if present
|
|
48
|
+
for (const key of ["hooks", "tools", "agents"] as const) {
|
|
49
|
+
if (obj[key] !== undefined) {
|
|
50
|
+
if (typeof obj[key] !== "object" || obj[key] === null || Array.isArray(obj[key]))
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (obj["hooks"] !== undefined) {
|
|
56
|
+
for (const handler of Object.values(obj["hooks"] as Record<string, unknown>)) {
|
|
57
|
+
if (handler !== undefined && typeof handler !== "function") return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Optional: setup/teardown must be functions if present
|
|
62
|
+
if (obj["setup"] !== undefined && typeof obj["setup"] !== "function") return false;
|
|
63
|
+
if (obj["teardown"] !== undefined && typeof obj["teardown"] !== "function") return false;
|
|
64
|
+
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function bootstrap(ctx: OpenCodeContext): Promise<Hooks> {
|
|
69
|
+
const rawConfig = await loadConfig(ctx.directory);
|
|
70
|
+
|
|
71
|
+
const validation = validateConfig(rawConfig ?? {});
|
|
72
|
+
let config: GoatCodeConfig;
|
|
73
|
+
if (validation.success) {
|
|
74
|
+
config = validation.config;
|
|
75
|
+
} else {
|
|
76
|
+
log("[bootstrap] Config validation failed, using defaults", {
|
|
77
|
+
errors: validation.errors,
|
|
78
|
+
});
|
|
79
|
+
process.stderr.write(
|
|
80
|
+
`[goatcode] WARNING: goatcode.config.ts has validation errors — using defaults.\n` +
|
|
81
|
+
validation.errors.map((e) => ` - ${e}`).join("\n") +
|
|
82
|
+
"\n",
|
|
83
|
+
);
|
|
84
|
+
const fallback = validateConfig({});
|
|
85
|
+
if (!fallback.success) {
|
|
86
|
+
throw new Error("[bootstrap] Default config validation failed");
|
|
87
|
+
}
|
|
88
|
+
config = fallback.config;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
resetProviderRegistry();
|
|
92
|
+
resetDiscovery();
|
|
93
|
+
setProviderPriority(config.provider_priority ?? []);
|
|
94
|
+
setDefaultPreferredProvider(config.default_provider);
|
|
95
|
+
try {
|
|
96
|
+
const DISCOVERY_TIMEOUT_MS = 5_000;
|
|
97
|
+
const providerResponse = (await Promise.race([
|
|
98
|
+
ctx.client.provider.list(),
|
|
99
|
+
new Promise<never>((_, reject) =>
|
|
100
|
+
setTimeout(
|
|
101
|
+
() => reject(new Error(`provider.list timeout after ${DISCOVERY_TIMEOUT_MS}ms`)),
|
|
102
|
+
DISCOVERY_TIMEOUT_MS,
|
|
103
|
+
),
|
|
104
|
+
),
|
|
105
|
+
])) as Awaited<ReturnType<typeof ctx.client.provider.list>>;
|
|
106
|
+
const providerData = providerResponse?.data as ProviderListResponse | undefined;
|
|
107
|
+
if (providerData?.all && providerData?.connected) {
|
|
108
|
+
const discovery = buildDiscoveryIndex(providerData);
|
|
109
|
+
initializeDiscovery(discovery);
|
|
110
|
+
} else {
|
|
111
|
+
log("[bootstrap] Provider discovery response missing required fields");
|
|
112
|
+
}
|
|
113
|
+
} catch (error) {
|
|
114
|
+
log("[bootstrap] Provider discovery failed; using pass-through model resolution", { error });
|
|
115
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
116
|
+
process.stderr.write(
|
|
117
|
+
`[goatcode] WARNING: Provider discovery failed (${msg}) — model provider resolution will use pass-through fallback.\n`,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const registry = new PluginRegistry();
|
|
122
|
+
|
|
123
|
+
for (const plugin of BUILTIN_AGENT_PLUGINS) {
|
|
124
|
+
registry.register(plugin);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
for (const plugin of BUILTIN_HOOK_PLUGINS) {
|
|
128
|
+
registry.register(plugin);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
for (const plugin of BUILTIN_TOOL_PLUGINS) {
|
|
132
|
+
registry.register(plugin);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
for (const plugin of BUILTIN_FEATURE_PLUGINS) {
|
|
136
|
+
registry.register(plugin);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
for (const packageName of config.plugins ?? []) {
|
|
140
|
+
try {
|
|
141
|
+
const mod = await import(packageName);
|
|
142
|
+
const pluginDef = mod.default ?? mod;
|
|
143
|
+
if (!isValidPluginDefinition(pluginDef)) {
|
|
144
|
+
log(
|
|
145
|
+
`[bootstrap] External plugin "${packageName}" does not export a valid PluginDefinition, skipping`,
|
|
146
|
+
);
|
|
147
|
+
process.stderr.write(
|
|
148
|
+
`[goatcode] WARNING: Plugin "${packageName}" is not a valid PluginDefinition and was skipped.\n`,
|
|
149
|
+
);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
registry.register(pluginDef);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
log(`[bootstrap] Failed to load external plugin: ${packageName}`, { error });
|
|
155
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
156
|
+
process.stderr.write(`[goatcode] WARNING: Failed to load plugin "${packageName}": ${msg}\n`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
registerProjectSkillLoader(ctx.directory);
|
|
161
|
+
|
|
162
|
+
const resolved = registry.resolve();
|
|
163
|
+
const initializedPlugins = await registry.setup(resolved, ctx);
|
|
164
|
+
|
|
165
|
+
const aggregated = registry.aggregate(initializedPlugins, {
|
|
166
|
+
disabledAgents: config.disabled_agents,
|
|
167
|
+
disabledHooks: config.disabled_hooks,
|
|
168
|
+
disabledTools: config.disabled_tools,
|
|
169
|
+
});
|
|
170
|
+
return compose(aggregated);
|
|
171
|
+
}
|
package/src/cli/cli.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { log } from "../shared/logger";
|
|
3
|
+
import { handleUpdateCommand } from "./commands/update";
|
|
4
|
+
import packageJson from "../../package.json" with { type: "json" };
|
|
5
|
+
|
|
6
|
+
const VERSION = packageJson.version;
|
|
7
|
+
|
|
8
|
+
export function createProgram(): Command {
|
|
9
|
+
const program = new Command();
|
|
10
|
+
|
|
11
|
+
program
|
|
12
|
+
.name("goatcode-sh")
|
|
13
|
+
.description(
|
|
14
|
+
"Enterprise-grade OpenCode plugin with micro-plugin architecture and multi-agent orchestration",
|
|
15
|
+
)
|
|
16
|
+
.version(VERSION, "-v, --version", "Show version number");
|
|
17
|
+
|
|
18
|
+
program
|
|
19
|
+
.command("install")
|
|
20
|
+
.description("Install and configure goatcode")
|
|
21
|
+
.option("--non-interactive", "Skip interactive prompts and use defaults")
|
|
22
|
+
.option("--force", "Overwrite existing config file")
|
|
23
|
+
.action(async (options) => {
|
|
24
|
+
log("cli: install command invoked");
|
|
25
|
+
const { installCommand } = await import("./commands/install");
|
|
26
|
+
await installCommand({ nonInteractive: options.nonInteractive, force: options.force });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
program
|
|
30
|
+
.command("update")
|
|
31
|
+
.description("Update goatcode to the latest version")
|
|
32
|
+
.action(async () => {
|
|
33
|
+
await handleUpdateCommand();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return program;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function runCli(): void {
|
|
40
|
+
const program = createProgram();
|
|
41
|
+
program.parse();
|
|
42
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, it, expect } from "bun:test";
|
|
2
|
+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { BUILTIN_AGENT_PLUGINS } from "../../agents/builtin-agents";
|
|
6
|
+
import { installCommand } from "./install";
|
|
7
|
+
|
|
8
|
+
describe("#given the install command", () => {
|
|
9
|
+
describe("#when run with --non-interactive", () => {
|
|
10
|
+
it("#then it generates goatcode.config.ts with defineConfig", async () => {
|
|
11
|
+
const tempDir = mkdtempSync(join(tmpdir(), "goatcode-install-test-"));
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const configPath = await installCommand({ nonInteractive: true, cwd: tempDir });
|
|
15
|
+
const content = readFileSync(configPath, "utf8");
|
|
16
|
+
|
|
17
|
+
expect(configPath).toBe(join(tempDir, "goatcode.config.ts"));
|
|
18
|
+
expect(content).toContain('import { defineConfig } from "goatcode-sh"');
|
|
19
|
+
expect(content).toContain("export default defineConfig({");
|
|
20
|
+
} finally {
|
|
21
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("#then generated config lists all built-in plugins", async () => {
|
|
26
|
+
const tempDir = mkdtempSync(join(tmpdir(), "goatcode-install-test-"));
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const configPath = await installCommand({ nonInteractive: true, cwd: tempDir });
|
|
30
|
+
const content = readFileSync(configPath, "utf8");
|
|
31
|
+
|
|
32
|
+
for (const plugin of BUILTIN_AGENT_PLUGINS) {
|
|
33
|
+
expect(content).toContain(`"${plugin.name}"`);
|
|
34
|
+
}
|
|
35
|
+
} finally {
|
|
36
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { createInterface } from "node:readline/promises";
|
|
2
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
3
|
+
import { writeFile } from "node:fs/promises";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import { BUILTIN_AGENT_PLUGINS } from "../../agents/builtin-agents";
|
|
6
|
+
import { log } from "../../shared/logger";
|
|
7
|
+
|
|
8
|
+
interface InstallDefaults {
|
|
9
|
+
autoUpdate: boolean;
|
|
10
|
+
plugins: string[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface InstallCommandOptions {
|
|
14
|
+
nonInteractive?: boolean;
|
|
15
|
+
force?: boolean;
|
|
16
|
+
cwd?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const CONFIG_FILE_NAME = "goatcode.config.ts";
|
|
20
|
+
|
|
21
|
+
function getDefaultInstallConfig(): InstallDefaults {
|
|
22
|
+
return {
|
|
23
|
+
autoUpdate: true,
|
|
24
|
+
plugins: BUILTIN_AGENT_PLUGINS.map((plugin) => plugin.name),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function parseBooleanInput(inputValue: string, fallback: boolean): boolean {
|
|
29
|
+
const normalized = inputValue.trim().toLowerCase();
|
|
30
|
+
if (normalized === "") return fallback;
|
|
31
|
+
if (normalized === "y" || normalized === "yes" || normalized === "true") return true;
|
|
32
|
+
if (normalized === "n" || normalized === "no" || normalized === "false") return false;
|
|
33
|
+
return fallback;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function parsePluginInput(inputValue: string, fallback: string[]): string[] {
|
|
37
|
+
const normalized = inputValue.trim();
|
|
38
|
+
if (normalized === "") return fallback;
|
|
39
|
+
return normalized
|
|
40
|
+
.split(",")
|
|
41
|
+
.map((part) => part.trim())
|
|
42
|
+
.filter((value, index, array) => value !== "" && array.indexOf(value) === index);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getConfigTemplate(config: InstallDefaults): string {
|
|
46
|
+
const pluginLines = config.plugins.map((plugin) => ` ${JSON.stringify(plugin)},`).join("\n");
|
|
47
|
+
return `import { defineConfig } from "goatcode-sh"
|
|
48
|
+
|
|
49
|
+
export default defineConfig({
|
|
50
|
+
// Agent-level model and behavior overrides.
|
|
51
|
+
agents: {},
|
|
52
|
+
|
|
53
|
+
// Category-level defaults for delegated tasks.
|
|
54
|
+
categories: {},
|
|
55
|
+
|
|
56
|
+
// Disable built-in runtime components by name.
|
|
57
|
+
disabled_agents: [],
|
|
58
|
+
disabled_hooks: [],
|
|
59
|
+
disabled_tools: [],
|
|
60
|
+
disabled_skills: [],
|
|
61
|
+
|
|
62
|
+
// Keep goatcode updated automatically.
|
|
63
|
+
auto_update: ${String(config.autoUpdate)},
|
|
64
|
+
|
|
65
|
+
// External and internal micro-plugins to load.
|
|
66
|
+
plugins: [
|
|
67
|
+
${pluginLines}
|
|
68
|
+
],
|
|
69
|
+
})
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function promptInstallConfig(defaults: InstallDefaults): Promise<InstallDefaults> {
|
|
74
|
+
const rl = createInterface({ input, output });
|
|
75
|
+
try {
|
|
76
|
+
output.write("goatcode install: interactive setup\n");
|
|
77
|
+
const autoUpdateAnswer = await rl.question(
|
|
78
|
+
`Enable auto-update checks? (Y/n) [${defaults.autoUpdate ? "Y" : "N"}]: `,
|
|
79
|
+
);
|
|
80
|
+
const pluginsAnswer = await rl.question(
|
|
81
|
+
`Plugins (comma-separated) [${defaults.plugins.join(", ")}]: `,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
autoUpdate: parseBooleanInput(autoUpdateAnswer, defaults.autoUpdate),
|
|
86
|
+
plugins: parsePluginInput(pluginsAnswer, defaults.plugins),
|
|
87
|
+
};
|
|
88
|
+
} finally {
|
|
89
|
+
rl.close();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function installCommand(options: InstallCommandOptions = {}): Promise<string> {
|
|
94
|
+
const defaults = getDefaultInstallConfig();
|
|
95
|
+
const config = options.nonInteractive ? defaults : await promptInstallConfig(defaults);
|
|
96
|
+
const configContent = getConfigTemplate(config);
|
|
97
|
+
const targetDirectory = options.cwd ?? process.cwd();
|
|
98
|
+
const configPath = resolve(targetDirectory, CONFIG_FILE_NAME);
|
|
99
|
+
|
|
100
|
+
if (!options.force) {
|
|
101
|
+
try {
|
|
102
|
+
await writeFile(configPath, configContent, { encoding: "utf8", flag: "wx" });
|
|
103
|
+
} catch (err) {
|
|
104
|
+
if ((err as NodeJS.ErrnoException).code === "EEXIST") {
|
|
105
|
+
output.write(
|
|
106
|
+
`${CONFIG_FILE_NAME} already exists at ${configPath}. Use --force to overwrite.\n`,
|
|
107
|
+
);
|
|
108
|
+
return configPath;
|
|
109
|
+
}
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
await writeFile(configPath, configContent, "utf8");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
log("cli: install config generated", {
|
|
117
|
+
nonInteractive: options.nonInteractive ?? false,
|
|
118
|
+
configPath,
|
|
119
|
+
});
|
|
120
|
+
output.write(`Created ${CONFIG_FILE_NAME} at ${configPath}\n`);
|
|
121
|
+
|
|
122
|
+
return configPath;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { getConfigTemplate };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
|
|
2
|
+
import { handleUpdateCommand } from "./update";
|
|
3
|
+
|
|
4
|
+
describe("#given update command", () => {
|
|
5
|
+
let stdoutWrites: string[] = [];
|
|
6
|
+
let originalWrite: any;
|
|
7
|
+
let originalFetch: any;
|
|
8
|
+
let originalSpawn: any;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
stdoutWrites = [];
|
|
12
|
+
originalWrite = process.stdout.write;
|
|
13
|
+
originalFetch = globalThis.fetch;
|
|
14
|
+
originalSpawn = Bun.spawn;
|
|
15
|
+
|
|
16
|
+
process.stdout.write = ((text: string) => {
|
|
17
|
+
stdoutWrites.push(text);
|
|
18
|
+
return true;
|
|
19
|
+
}) as any;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
process.stdout.write = originalWrite;
|
|
24
|
+
globalThis.fetch = originalFetch;
|
|
25
|
+
Bun.spawn = originalSpawn;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("#when update is available", () => {
|
|
29
|
+
it("#then runs bun update goatcode-sh", async () => {
|
|
30
|
+
globalThis.fetch = (() => {
|
|
31
|
+
return Promise.resolve(new Response(JSON.stringify({ version: "0.2.0" })));
|
|
32
|
+
}) as any;
|
|
33
|
+
|
|
34
|
+
Bun.spawn = (() => {
|
|
35
|
+
return {
|
|
36
|
+
exited: Promise.resolve(0),
|
|
37
|
+
};
|
|
38
|
+
}) as any;
|
|
39
|
+
|
|
40
|
+
await handleUpdateCommand();
|
|
41
|
+
expect(stdoutWrites.some((w) => w.includes("Update available"))).toBe(true);
|
|
42
|
+
expect(stdoutWrites.some((w) => w.includes("bun update goatcode-sh"))).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("#when already up to date", () => {
|
|
47
|
+
it("#then prints already up to date message", async () => {
|
|
48
|
+
globalThis.fetch = (() => {
|
|
49
|
+
return Promise.resolve(new Response(JSON.stringify({ version: "0.1.0" })));
|
|
50
|
+
}) as any;
|
|
51
|
+
|
|
52
|
+
await handleUpdateCommand();
|
|
53
|
+
expect(stdoutWrites.some((w) => w.includes("Already up to date"))).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe("#when npm check fails", () => {
|
|
58
|
+
it("#then reports failure gracefully", async () => {
|
|
59
|
+
globalThis.fetch = (() => {
|
|
60
|
+
return Promise.reject(new Error("Network error"));
|
|
61
|
+
}) as any;
|
|
62
|
+
|
|
63
|
+
await handleUpdateCommand();
|
|
64
|
+
expect(stdoutWrites.some((w) => w.includes("Failed to check for updates"))).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe("#when bun update fails", () => {
|
|
69
|
+
it("#then reports exit code", async () => {
|
|
70
|
+
globalThis.fetch = (() => {
|
|
71
|
+
return Promise.resolve(new Response(JSON.stringify({ version: "0.2.0" })));
|
|
72
|
+
}) as any;
|
|
73
|
+
|
|
74
|
+
Bun.spawn = (() => {
|
|
75
|
+
return {
|
|
76
|
+
exited: Promise.resolve(1),
|
|
77
|
+
};
|
|
78
|
+
}) as any;
|
|
79
|
+
|
|
80
|
+
await handleUpdateCommand();
|
|
81
|
+
expect(stdoutWrites.some((w) => w.includes("exit code 1"))).toBe(true);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { log } from "../../shared/logger";
|
|
2
|
+
import { checkForUpdate } from "../../features/auto-update/update-checker";
|
|
3
|
+
import packageJson from "../../../package.json" with { type: "json" };
|
|
4
|
+
|
|
5
|
+
const VERSION = packageJson.version;
|
|
6
|
+
const PACKAGE_NAME = packageJson.name;
|
|
7
|
+
|
|
8
|
+
export async function handleUpdateCommand(): Promise<void> {
|
|
9
|
+
try {
|
|
10
|
+
log("cli: update command invoked");
|
|
11
|
+
|
|
12
|
+
const result = await checkForUpdate(VERSION);
|
|
13
|
+
|
|
14
|
+
if (result.error) {
|
|
15
|
+
process.stdout.write("Failed to check for updates. Please try again later.\n");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!result.updateAvailable) {
|
|
20
|
+
process.stdout.write(`Already up to date (v${result.current})\n`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
process.stdout.write(`Update available: v${result.current} -> v${result.latest}\n`);
|
|
25
|
+
process.stdout.write(`Running: bun update ${PACKAGE_NAME}\n`);
|
|
26
|
+
|
|
27
|
+
const proc = Bun.spawn(["bun", "update", PACKAGE_NAME], {
|
|
28
|
+
stdio: ["inherit", "inherit", "inherit"],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const exitCode = await proc.exited;
|
|
32
|
+
|
|
33
|
+
if (exitCode === 0) {
|
|
34
|
+
process.stdout.write("Update completed successfully!\n");
|
|
35
|
+
log("cli: update command completed successfully");
|
|
36
|
+
} else {
|
|
37
|
+
process.stdout.write(`Update failed with exit code ${exitCode}\n`);
|
|
38
|
+
log("cli: update command failed", { exitCode });
|
|
39
|
+
}
|
|
40
|
+
} catch (error) {
|
|
41
|
+
log("cli: update command error", error);
|
|
42
|
+
process.stdout.write("Error during update: " + String(error) + "\n");
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll, afterAll } from "bun:test";
|
|
2
|
+
import { writeFileSync, mkdtempSync, rmSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { generateConfig } from "./config-generator";
|
|
7
|
+
|
|
8
|
+
describe("#given generateConfig with default options", () => {
|
|
9
|
+
describe("#when called with no arguments", () => {
|
|
10
|
+
it("#then the output contains the defineConfig import", () => {
|
|
11
|
+
const result = generateConfig();
|
|
12
|
+
expect(result).toContain('import { defineConfig } from "goatcode-sh"');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("#then the output contains the defineConfig call", () => {
|
|
16
|
+
const result = generateConfig();
|
|
17
|
+
expect(result).toContain("export default defineConfig({");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("#then the output contains agent override comments", () => {
|
|
21
|
+
const result = generateConfig();
|
|
22
|
+
expect(result).toContain("// agents: {");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("#then the output contains all active agent names in comments", () => {
|
|
26
|
+
const result = generateConfig();
|
|
27
|
+
expect(result).toContain('"orchestrator"');
|
|
28
|
+
expect(result).toContain('"deep-worker"');
|
|
29
|
+
expect(result).toContain('"planner"');
|
|
30
|
+
expect(result).toContain('"advisor"');
|
|
31
|
+
expect(result).toContain('"researcher"');
|
|
32
|
+
expect(result).toContain('"explorer"');
|
|
33
|
+
expect(result).toContain('"worker"');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("#then the output does not contain disabled agent names", () => {
|
|
37
|
+
const result = generateConfig();
|
|
38
|
+
expect(result).not.toContain('"executor"');
|
|
39
|
+
expect(result).not.toContain('"analyst"');
|
|
40
|
+
expect(result).not.toContain('"reviewer"');
|
|
41
|
+
expect(result).not.toContain('"inspector"');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("#then the output contains category override comments", () => {
|
|
45
|
+
const result = generateConfig();
|
|
46
|
+
expect(result).toContain("// categories: {");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("#then the output contains all built-in category names in comments", () => {
|
|
50
|
+
const result = generateConfig();
|
|
51
|
+
expect(result).toContain('// "visual-engineering":');
|
|
52
|
+
expect(result).toContain('// "ultrabrain":');
|
|
53
|
+
expect(result).toContain('// "deep":');
|
|
54
|
+
expect(result).toContain('// "artistry":');
|
|
55
|
+
expect(result).toContain('// "quick":');
|
|
56
|
+
expect(result).toContain('// "unspecified-low":');
|
|
57
|
+
expect(result).toContain('// "unspecified-high":');
|
|
58
|
+
expect(result).toContain('// "writing":');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("#then the output contains the plugins array", () => {
|
|
62
|
+
const result = generateConfig();
|
|
63
|
+
expect(result).toContain("plugins: [");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("#then the output lists all active micro-plugins", () => {
|
|
67
|
+
const result = generateConfig();
|
|
68
|
+
expect(result).toContain('"goatcode-sh/orchestrator"');
|
|
69
|
+
expect(result).toContain('"goatcode-sh/deep-worker"');
|
|
70
|
+
expect(result).toContain('"goatcode-sh/planner"');
|
|
71
|
+
expect(result).toContain('"goatcode-sh/advisor"');
|
|
72
|
+
expect(result).toContain('"goatcode-sh/researcher"');
|
|
73
|
+
expect(result).toContain('"goatcode-sh/explorer"');
|
|
74
|
+
expect(result).toContain('"goatcode-sh/worker"');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("#then the output does not list disabled micro-plugins", () => {
|
|
78
|
+
const result = generateConfig();
|
|
79
|
+
expect(result).not.toContain('"goatcode-sh/executor"');
|
|
80
|
+
expect(result).not.toContain('"goatcode-sh/analyst"');
|
|
81
|
+
expect(result).not.toContain('"goatcode-sh/reviewer"');
|
|
82
|
+
expect(result).not.toContain('"goatcode-sh/inspector"');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("#then the output ends with a newline", () => {
|
|
86
|
+
const result = generateConfig();
|
|
87
|
+
expect(result.endsWith("\n")).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("#given generateConfig with includePlugins: false", () => {
|
|
93
|
+
describe("#when called with includePlugins disabled", () => {
|
|
94
|
+
it("#then the output does not contain the plugins array", () => {
|
|
95
|
+
const result = generateConfig({ includePlugins: false });
|
|
96
|
+
expect(result).not.toContain("plugins: [");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("#then the output still contains the defineConfig import", () => {
|
|
100
|
+
const result = generateConfig({ includePlugins: false });
|
|
101
|
+
expect(result).toContain('import { defineConfig } from "goatcode-sh"');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe("#given generateConfig with includeAgents: false", () => {
|
|
107
|
+
describe("#when called with includeAgents disabled", () => {
|
|
108
|
+
it("#then the output does not contain agent override comments", () => {
|
|
109
|
+
const result = generateConfig({ includeAgents: false });
|
|
110
|
+
expect(result).not.toContain("// agents: {");
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("#then the output still contains category override comments", () => {
|
|
114
|
+
const result = generateConfig({ includeAgents: false });
|
|
115
|
+
expect(result).toContain("// categories: {");
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe("#given generateConfig with includeCategories: false", () => {
|
|
121
|
+
describe("#when called with includeCategories disabled", () => {
|
|
122
|
+
it("#then the output does not contain category override comments", () => {
|
|
123
|
+
const result = generateConfig({ includeCategories: false });
|
|
124
|
+
expect(result).not.toContain("// categories: {");
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("#then the output still contains agent override comments", () => {
|
|
128
|
+
const result = generateConfig({ includeCategories: false });
|
|
129
|
+
expect(result).toContain("// agents: {");
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe("#given the generated config written to a temp file", () => {
|
|
135
|
+
let tempDir: string;
|
|
136
|
+
let tempFile: string;
|
|
137
|
+
|
|
138
|
+
beforeAll(() => {
|
|
139
|
+
tempDir = mkdtempSync(join(tmpdir(), "goatcode-config-test-"));
|
|
140
|
+
tempFile = join(tempDir, "goatcode.config.ts");
|
|
141
|
+
const content = generateConfig();
|
|
142
|
+
writeFileSync(tempFile, content, "utf8");
|
|
143
|
+
|
|
144
|
+
writeFileSync(
|
|
145
|
+
join(tempDir, "goatcode-sh.d.ts"),
|
|
146
|
+
"export function defineConfig(config: any): any\n",
|
|
147
|
+
"utf8",
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
afterAll(() => {
|
|
152
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe("#when typechecked with tsc", () => {
|
|
156
|
+
it("#then the generated config is valid TypeScript", () => {
|
|
157
|
+
const result = spawnSync(
|
|
158
|
+
"bunx",
|
|
159
|
+
[
|
|
160
|
+
"tsc",
|
|
161
|
+
"--noEmit",
|
|
162
|
+
"--skipLibCheck",
|
|
163
|
+
"--isolatedModules",
|
|
164
|
+
"--module",
|
|
165
|
+
"esnext",
|
|
166
|
+
"--target",
|
|
167
|
+
"esnext",
|
|
168
|
+
tempFile,
|
|
169
|
+
],
|
|
170
|
+
{ encoding: "utf8", timeout: 30000 },
|
|
171
|
+
);
|
|
172
|
+
if (result.error) {
|
|
173
|
+
throw new Error(`tsc failed to launch: ${result.error.message}`);
|
|
174
|
+
}
|
|
175
|
+
expect(result.status).toBe(0);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|