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
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import type { Message, Part, Todo } from "@opencode-ai/sdk";
|
|
2
|
+
import type { SessionSummary, SearchMatch, SessionDetail } from "./types";
|
|
3
|
+
|
|
4
|
+
type TextPart = Part & { type: "text"; text: string };
|
|
5
|
+
type ReasoningPart = Part & { type: "reasoning"; text: string };
|
|
6
|
+
type ThinkingPart = Part & { type: "thinking"; thinking?: string; text?: string };
|
|
7
|
+
type ToolPart = Part & {
|
|
8
|
+
type: "tool";
|
|
9
|
+
tool: string;
|
|
10
|
+
state: { status: string; input?: Record<string, unknown> };
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function isTextPart(part: Part): part is TextPart {
|
|
14
|
+
return part.type === "text" && typeof (part as { text?: unknown }).text === "string";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function isReasoningPart(part: Part): part is ReasoningPart {
|
|
18
|
+
return part.type === "reasoning" && typeof (part as { text?: unknown }).text === "string";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isThinkingPart(part: Part): part is ThinkingPart {
|
|
22
|
+
const type = (part as { type?: unknown }).type;
|
|
23
|
+
if (type !== "thinking") return false;
|
|
24
|
+
const thinking = (part as { thinking?: unknown }).thinking;
|
|
25
|
+
const text = (part as { text?: unknown }).text;
|
|
26
|
+
return typeof thinking === "string" || typeof text === "string";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function isToolPart(part: Part): part is ToolPart {
|
|
30
|
+
if (part.type !== "tool") {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const tool = (part as { tool?: unknown }).tool;
|
|
34
|
+
const state = (part as { state?: unknown }).state;
|
|
35
|
+
if (typeof tool !== "string") {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (typeof state !== "object" || state === null || Array.isArray(state)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const status = (state as { status?: unknown }).status;
|
|
42
|
+
if (typeof status !== "string") {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const input = (state as { input?: unknown }).input;
|
|
46
|
+
return (
|
|
47
|
+
input === undefined || (typeof input === "object" && input !== null && !Array.isArray(input))
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function formatDate(timestamp: number): string {
|
|
52
|
+
return new Date(timestamp).toISOString().split("T")[0];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function formatTimestamp(timestamp: number): string {
|
|
56
|
+
return new Date(timestamp).toISOString();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function safeTruncateJson(value: Record<string, unknown>, max = 100): string {
|
|
60
|
+
try {
|
|
61
|
+
return JSON.stringify(value).substring(0, max);
|
|
62
|
+
} catch {
|
|
63
|
+
return "[unserializable tool input]";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function computeDurationLabel(firstMs: number, lastMs: number): string | null {
|
|
68
|
+
const diff = lastMs - firstMs;
|
|
69
|
+
if (diff <= 0) return null;
|
|
70
|
+
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
|
|
71
|
+
const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
72
|
+
const parts: string[] = [];
|
|
73
|
+
if (days > 0) parts.push(`${days} day${days !== 1 ? "s" : ""}`);
|
|
74
|
+
if (hours > 0) parts.push(`${hours} hour${hours !== 1 ? "s" : ""}`);
|
|
75
|
+
return parts.length > 0 ? parts.join(", ") : null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function extractTextFromParts(parts: Part[]): string {
|
|
79
|
+
return parts
|
|
80
|
+
.filter(isTextPart)
|
|
81
|
+
.map((p) => p.text)
|
|
82
|
+
.join(" ")
|
|
83
|
+
.trim();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function extractAgentsFromMessages(
|
|
87
|
+
messages: Array<{ info: Message; parts: Part[] }>,
|
|
88
|
+
): string[] {
|
|
89
|
+
const agents = new Set<string>();
|
|
90
|
+
for (const { info } of messages) {
|
|
91
|
+
if (info.role === "user" && "agent" in info && info.agent) {
|
|
92
|
+
agents.add(info.agent);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return Array.from(agents);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function buildSessionSummary(
|
|
99
|
+
id: string,
|
|
100
|
+
messages: Array<{ info: Message; parts: Part[] }>,
|
|
101
|
+
): SessionSummary {
|
|
102
|
+
const timestamps = messages
|
|
103
|
+
.map((m) => m.info.time.created)
|
|
104
|
+
.filter((t): t is number => typeof t === "number");
|
|
105
|
+
|
|
106
|
+
const firstDate = timestamps.length > 0 ? formatDate(Math.min(...timestamps)) : null;
|
|
107
|
+
const lastDate = timestamps.length > 0 ? formatDate(Math.max(...timestamps)) : null;
|
|
108
|
+
const agentsUsed = extractAgentsFromMessages(messages);
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
id,
|
|
112
|
+
messageCount: messages.length,
|
|
113
|
+
firstDate,
|
|
114
|
+
lastDate,
|
|
115
|
+
agentsUsed,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function formatSessionList(summaries: SessionSummary[]): string {
|
|
120
|
+
if (summaries.length === 0) {
|
|
121
|
+
return "No sessions found.";
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const headers = ["Session ID", "Messages", "First", "Last", "Agents"];
|
|
125
|
+
const rows = summaries.map((s) => [
|
|
126
|
+
s.id,
|
|
127
|
+
s.messageCount.toString(),
|
|
128
|
+
s.firstDate ?? "N/A",
|
|
129
|
+
s.lastDate ?? "N/A",
|
|
130
|
+
s.agentsUsed.join(", ") || "none",
|
|
131
|
+
]);
|
|
132
|
+
|
|
133
|
+
const colWidths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => r[i].length)));
|
|
134
|
+
|
|
135
|
+
const formatRow = (cells: string[]): string =>
|
|
136
|
+
"| " + cells.map((cell, i) => cell.padEnd(colWidths[i])).join(" | ") + " |";
|
|
137
|
+
|
|
138
|
+
const separator = "|" + colWidths.map((w) => "-".repeat(w + 2)).join("|") + "|";
|
|
139
|
+
|
|
140
|
+
return [formatRow(headers), separator, ...rows.map(formatRow)].join("\n");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function formatMessages(
|
|
144
|
+
sessionId: string,
|
|
145
|
+
messages: Array<{ info: Message; parts: Part[] }>,
|
|
146
|
+
options: { includeTodos?: boolean; todos?: Todo[] } = {},
|
|
147
|
+
): string {
|
|
148
|
+
if (messages.length === 0) {
|
|
149
|
+
return "No messages found in this session.";
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const lines: string[] = [`Session: ${sessionId}`, `Messages: ${messages.length}`];
|
|
153
|
+
|
|
154
|
+
for (const { info, parts } of messages) {
|
|
155
|
+
const ts = formatTimestamp(info.time.created);
|
|
156
|
+
const agent = info.role === "user" && "agent" in info && info.agent ? ` (${info.agent})` : "";
|
|
157
|
+
lines.push(`\n[Message ${info.id}] ${info.role}${agent} (${ts})`);
|
|
158
|
+
|
|
159
|
+
for (const part of parts) {
|
|
160
|
+
if (isTextPart(part)) {
|
|
161
|
+
const text = part.text.trim();
|
|
162
|
+
if (text) lines.push(text);
|
|
163
|
+
} else if (isReasoningPart(part) || isThinkingPart(part)) {
|
|
164
|
+
const text =
|
|
165
|
+
(part as { thinking?: string; text?: string }).thinking ??
|
|
166
|
+
(part as { text?: string }).text ??
|
|
167
|
+
"";
|
|
168
|
+
lines.push(`[thinking] ${text.substring(0, 200)}...`);
|
|
169
|
+
} else if (isToolPart(part)) {
|
|
170
|
+
const tp = part;
|
|
171
|
+
const inputStr = tp.state.input ? safeTruncateJson(tp.state.input, 100) : "";
|
|
172
|
+
lines.push(`[tool: ${tp.tool}] ${inputStr}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (options.includeTodos && options.todos && options.todos.length > 0) {
|
|
178
|
+
lines.push("\n\n=== Todos ===");
|
|
179
|
+
for (const todo of options.todos) {
|
|
180
|
+
const mark =
|
|
181
|
+
todo.status === "completed" ? "[x]" : todo.status === "in_progress" ? "[-]" : "[ ]";
|
|
182
|
+
lines.push(`${mark} [${todo.status}] ${todo.content}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return lines.join("\n");
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function formatSearchResults(matches: SearchMatch[]): string {
|
|
190
|
+
if (matches.length === 0) {
|
|
191
|
+
return "No matches found.";
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const lines: string[] = [
|
|
195
|
+
`Found ${matches.length} match${matches.length !== 1 ? "es" : ""} across sessions:\n`,
|
|
196
|
+
];
|
|
197
|
+
|
|
198
|
+
for (const match of matches) {
|
|
199
|
+
const ts = match.timestamp ? ` ${match.timestamp}` : "";
|
|
200
|
+
lines.push(`[${match.sessionId}] Message ${match.messageId} (${match.role})${ts}`);
|
|
201
|
+
lines.push(` ...${match.excerpt}...`);
|
|
202
|
+
lines.push(` Matches: ${match.matchCount}\n`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return lines.join("\n");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function formatSessionDetail(detail: SessionDetail): string {
|
|
209
|
+
const lines: string[] = [
|
|
210
|
+
`Session ID: ${detail.id}`,
|
|
211
|
+
`Messages: ${detail.messageCount}`,
|
|
212
|
+
`Date Range: ${detail.firstDate ?? "N/A"} to ${detail.lastDate ?? "N/A"}`,
|
|
213
|
+
];
|
|
214
|
+
|
|
215
|
+
if (detail.durationLabel) {
|
|
216
|
+
lines.push(`Duration: ${detail.durationLabel}`);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
lines.push(`Agents Used: ${detail.agentsUsed.join(", ") || "none"}`);
|
|
220
|
+
|
|
221
|
+
if (detail.hasTodos) {
|
|
222
|
+
lines.push(
|
|
223
|
+
`Has Todos: Yes (${detail.todoCount} items, ${detail.completedTodoCount} completed)`,
|
|
224
|
+
);
|
|
225
|
+
} else {
|
|
226
|
+
lines.push("Has Todos: No");
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
lines.push(`Has Transcript: ${detail.hasTranscript ? "Yes" : "No"}`);
|
|
230
|
+
|
|
231
|
+
return lines.join("\n");
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export function buildSessionDetail(
|
|
235
|
+
id: string,
|
|
236
|
+
messages: Array<{ info: Message; parts: Part[] }>,
|
|
237
|
+
todos: Todo[],
|
|
238
|
+
hasTranscript: boolean,
|
|
239
|
+
): SessionDetail {
|
|
240
|
+
const timestamps = messages
|
|
241
|
+
.map((m) => m.info.time.created)
|
|
242
|
+
.filter((t): t is number => typeof t === "number");
|
|
243
|
+
|
|
244
|
+
const firstMs = timestamps.length > 0 ? Math.min(...timestamps) : null;
|
|
245
|
+
const lastMs = timestamps.length > 0 ? Math.max(...timestamps) : null;
|
|
246
|
+
|
|
247
|
+
const firstDate = firstMs !== null ? formatDate(firstMs) : null;
|
|
248
|
+
const lastDate = lastMs !== null ? formatDate(lastMs) : null;
|
|
249
|
+
const durationLabel =
|
|
250
|
+
firstMs !== null && lastMs !== null ? computeDurationLabel(firstMs, lastMs) : null;
|
|
251
|
+
const agentsUsed = extractAgentsFromMessages(messages);
|
|
252
|
+
const completedTodoCount = todos.filter((t) => t.status === "completed").length;
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
id,
|
|
256
|
+
messageCount: messages.length,
|
|
257
|
+
firstDate,
|
|
258
|
+
lastDate,
|
|
259
|
+
durationLabel,
|
|
260
|
+
agentsUsed,
|
|
261
|
+
hasTodos: todos.length > 0,
|
|
262
|
+
todoCount: todos.length,
|
|
263
|
+
completedTodoCount,
|
|
264
|
+
hasTranscript,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export function searchMessages(
|
|
269
|
+
sessionId: string,
|
|
270
|
+
messages: Array<{ info: Message; parts: Part[] }>,
|
|
271
|
+
query: string,
|
|
272
|
+
caseSensitive: boolean,
|
|
273
|
+
maxResults: number,
|
|
274
|
+
): SearchMatch[] {
|
|
275
|
+
const results: SearchMatch[] = [];
|
|
276
|
+
if (query.trim() === "" || maxResults <= 0) return results;
|
|
277
|
+
const searchQuery = caseSensitive ? query : query.toLowerCase();
|
|
278
|
+
|
|
279
|
+
for (const { info, parts } of messages) {
|
|
280
|
+
if (results.length >= maxResults) break;
|
|
281
|
+
|
|
282
|
+
let matchCount = 0;
|
|
283
|
+
let firstExcerpt = "";
|
|
284
|
+
|
|
285
|
+
for (const part of parts) {
|
|
286
|
+
if (!isTextPart(part)) continue;
|
|
287
|
+
const rawText = part.text;
|
|
288
|
+
const text = caseSensitive ? rawText : rawText.toLowerCase();
|
|
289
|
+
const occurrences = text.split(searchQuery).length - 1;
|
|
290
|
+
if (occurrences === 0) continue;
|
|
291
|
+
|
|
292
|
+
matchCount += occurrences;
|
|
293
|
+
|
|
294
|
+
if (!firstExcerpt) {
|
|
295
|
+
const idx = text.indexOf(searchQuery);
|
|
296
|
+
const start = Math.max(0, idx - 50);
|
|
297
|
+
const end = Math.min(rawText.length, idx + searchQuery.length + 50);
|
|
298
|
+
firstExcerpt = rawText.substring(start, end);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (matchCount > 0) {
|
|
303
|
+
results.push({
|
|
304
|
+
sessionId,
|
|
305
|
+
messageId: info.id,
|
|
306
|
+
role: info.role,
|
|
307
|
+
excerpt: firstExcerpt,
|
|
308
|
+
matchCount,
|
|
309
|
+
timestamp: formatTimestamp(info.time.created),
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return results;
|
|
315
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { describe, it, expect } from "bun:test";
|
|
2
|
+
import type { OpenCodeContext } from "../../types/plugin";
|
|
3
|
+
import { handleSessionList } from "./list/handler";
|
|
4
|
+
import { handleSessionRead } from "./read/handler";
|
|
5
|
+
import { handleSessionSearch } from "./search/handler";
|
|
6
|
+
import { handleSessionInfo } from "./info/handler";
|
|
7
|
+
|
|
8
|
+
const SESSION_A_ID = "ses_aaa111";
|
|
9
|
+
const SESSION_B_ID = "ses_bbb222";
|
|
10
|
+
|
|
11
|
+
const NOW = 1735000000000;
|
|
12
|
+
const EARLIER = NOW - 86400000;
|
|
13
|
+
|
|
14
|
+
const mockMessages = {
|
|
15
|
+
[SESSION_A_ID]: [
|
|
16
|
+
{
|
|
17
|
+
info: {
|
|
18
|
+
id: "msg_001",
|
|
19
|
+
sessionID: SESSION_A_ID,
|
|
20
|
+
role: "user" as const,
|
|
21
|
+
time: { created: EARLIER },
|
|
22
|
+
agent: "orchestrator",
|
|
23
|
+
model: { providerID: "anthropic", modelID: "claude-opus" },
|
|
24
|
+
},
|
|
25
|
+
parts: [
|
|
26
|
+
{
|
|
27
|
+
id: "part_001",
|
|
28
|
+
sessionID: SESSION_A_ID,
|
|
29
|
+
messageID: "msg_001",
|
|
30
|
+
type: "text" as const,
|
|
31
|
+
text: "Hello, can you help me implement the session manager tool?",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
info: {
|
|
37
|
+
id: "msg_002",
|
|
38
|
+
sessionID: SESSION_A_ID,
|
|
39
|
+
role: "assistant" as const,
|
|
40
|
+
time: { created: NOW },
|
|
41
|
+
parentID: "msg_001",
|
|
42
|
+
modelID: "claude-opus",
|
|
43
|
+
providerID: "anthropic",
|
|
44
|
+
mode: "auto",
|
|
45
|
+
path: { cwd: "/tmp", root: "/tmp" },
|
|
46
|
+
cost: 0,
|
|
47
|
+
tokens: { input: 100, output: 200, reasoning: 0, cache: { read: 0, write: 0 } },
|
|
48
|
+
},
|
|
49
|
+
parts: [
|
|
50
|
+
{
|
|
51
|
+
id: "part_002",
|
|
52
|
+
sessionID: SESSION_A_ID,
|
|
53
|
+
messageID: "msg_002",
|
|
54
|
+
type: "text" as const,
|
|
55
|
+
text: "Of course! Let me help you implement the session manager.",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
[SESSION_B_ID]: [
|
|
61
|
+
{
|
|
62
|
+
info: {
|
|
63
|
+
id: "msg_003",
|
|
64
|
+
sessionID: SESSION_B_ID,
|
|
65
|
+
role: "user" as const,
|
|
66
|
+
time: { created: NOW },
|
|
67
|
+
agent: "worker",
|
|
68
|
+
model: { providerID: "openai", modelID: "gpt-4" },
|
|
69
|
+
},
|
|
70
|
+
parts: [
|
|
71
|
+
{
|
|
72
|
+
id: "part_003",
|
|
73
|
+
sessionID: SESSION_B_ID,
|
|
74
|
+
messageID: "msg_003",
|
|
75
|
+
type: "text" as const,
|
|
76
|
+
text: "Search for the session manager implementation.",
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const mockSessions = [
|
|
84
|
+
{
|
|
85
|
+
id: SESSION_A_ID,
|
|
86
|
+
projectID: "proj_001",
|
|
87
|
+
directory: "/tmp/test-project",
|
|
88
|
+
title: "Session A",
|
|
89
|
+
version: "1.0",
|
|
90
|
+
time: { created: EARLIER, updated: NOW },
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: SESSION_B_ID,
|
|
94
|
+
projectID: "proj_001",
|
|
95
|
+
directory: "/tmp/test-project",
|
|
96
|
+
title: "Session B",
|
|
97
|
+
version: "1.0",
|
|
98
|
+
time: { created: NOW, updated: NOW },
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
const mockTodos = [
|
|
103
|
+
{ id: "todo_001", content: "Implement session list", status: "completed", priority: "high" },
|
|
104
|
+
{ id: "todo_002", content: "Write tests", status: "in_progress", priority: "medium" },
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
function createMockCtx(overrides: Record<string, unknown> = {}): OpenCodeContext {
|
|
108
|
+
return {
|
|
109
|
+
directory: "/tmp/test-project",
|
|
110
|
+
client: {
|
|
111
|
+
session: {
|
|
112
|
+
list: async () => ({ data: mockSessions }),
|
|
113
|
+
messages: async (opts: { path: { id: string } }) => {
|
|
114
|
+
const data = mockMessages[opts.path.id as keyof typeof mockMessages];
|
|
115
|
+
if (!data) return { data: undefined, error: "session not found" };
|
|
116
|
+
return { data };
|
|
117
|
+
},
|
|
118
|
+
todo: async () => ({ data: mockTodos }),
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
...overrides,
|
|
122
|
+
} as unknown as OpenCodeContext;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
describe("session_list", () => {
|
|
126
|
+
describe("#given two sessions exist", () => {
|
|
127
|
+
describe("#when called with no filters", () => {
|
|
128
|
+
it("#then returns a formatted table with both sessions", async () => {
|
|
129
|
+
const ctx = createMockCtx();
|
|
130
|
+
const result = await handleSessionList({}, ctx);
|
|
131
|
+
|
|
132
|
+
expect(result).toContain("Session ID");
|
|
133
|
+
expect(result).toContain("Messages");
|
|
134
|
+
expect(result).toContain(SESSION_A_ID);
|
|
135
|
+
expect(result).toContain(SESSION_B_ID);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe("#when called with limit=1", () => {
|
|
140
|
+
it("#then returns only one session", async () => {
|
|
141
|
+
const ctx = createMockCtx();
|
|
142
|
+
const result = await handleSessionList({ limit: 1 }, ctx);
|
|
143
|
+
|
|
144
|
+
expect(result).toContain("Session ID");
|
|
145
|
+
const lines = result
|
|
146
|
+
.split("\n")
|
|
147
|
+
.filter((l) => l.startsWith("|") && !l.startsWith("| Session"));
|
|
148
|
+
expect(lines.length).toBe(2);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe("session_read", () => {
|
|
155
|
+
describe("#given session A exists with 2 messages", () => {
|
|
156
|
+
describe("#when called with session_id=SESSION_A_ID", () => {
|
|
157
|
+
it("#then returns formatted messages with role and timestamp", async () => {
|
|
158
|
+
const ctx = createMockCtx();
|
|
159
|
+
const result = await handleSessionRead({ session_id: SESSION_A_ID }, ctx);
|
|
160
|
+
|
|
161
|
+
expect(result).toContain(SESSION_A_ID);
|
|
162
|
+
expect(result).toContain("Messages: 2");
|
|
163
|
+
expect(result).toContain("user");
|
|
164
|
+
expect(result).toContain("assistant");
|
|
165
|
+
expect(result).toContain("Hello, can you help me implement the session manager tool?");
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe("#when called with include_todos=true", () => {
|
|
170
|
+
it("#then includes the todo list in output", async () => {
|
|
171
|
+
const ctx = createMockCtx();
|
|
172
|
+
const result = await handleSessionRead(
|
|
173
|
+
{ session_id: SESSION_A_ID, include_todos: true },
|
|
174
|
+
ctx,
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
expect(result).toContain("=== Todos ===");
|
|
178
|
+
expect(result).toContain("Implement session list");
|
|
179
|
+
expect(result).toContain("Write tests");
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
describe("#when called with a non-existent session_id", () => {
|
|
184
|
+
it("#then returns a not found message", async () => {
|
|
185
|
+
const ctx = createMockCtx();
|
|
186
|
+
const result = await handleSessionRead({ session_id: "ses_nonexistent" }, ctx);
|
|
187
|
+
|
|
188
|
+
expect(result).toContain("Session not found");
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe("session_search", () => {
|
|
195
|
+
describe("#given two sessions with text content", () => {
|
|
196
|
+
describe("#when searching for a term that exists in session A", () => {
|
|
197
|
+
it("#then returns matching excerpts", async () => {
|
|
198
|
+
const ctx = createMockCtx();
|
|
199
|
+
const result = await handleSessionSearch({ query: "session manager" }, ctx);
|
|
200
|
+
|
|
201
|
+
expect(result).toContain("Found");
|
|
202
|
+
expect(result).toContain(SESSION_A_ID);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe("#when searching within a specific session", () => {
|
|
207
|
+
it("#then only searches that session", async () => {
|
|
208
|
+
const ctx = createMockCtx();
|
|
209
|
+
const result = await handleSessionSearch(
|
|
210
|
+
{ query: "session manager", session_id: SESSION_A_ID },
|
|
211
|
+
ctx,
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
expect(result).toContain(SESSION_A_ID);
|
|
215
|
+
expect(result).not.toContain(SESSION_B_ID);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
describe("#when searching for a term that does not exist", () => {
|
|
220
|
+
it("#then returns no matches found", async () => {
|
|
221
|
+
const ctx = createMockCtx();
|
|
222
|
+
const result = await handleSessionSearch({ query: "xyzzy_nonexistent_term_12345" }, ctx);
|
|
223
|
+
|
|
224
|
+
expect(result).toBe("No matches found.");
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe("session_info", () => {
|
|
231
|
+
describe("#given session A exists", () => {
|
|
232
|
+
describe("#when called with session_id=SESSION_A_ID", () => {
|
|
233
|
+
it("#then returns detailed session metadata", async () => {
|
|
234
|
+
const ctx = createMockCtx();
|
|
235
|
+
const result = await handleSessionInfo({ session_id: SESSION_A_ID }, ctx);
|
|
236
|
+
|
|
237
|
+
expect(result).toContain(`Session ID: ${SESSION_A_ID}`);
|
|
238
|
+
expect(result).toContain("Messages: 2");
|
|
239
|
+
expect(result).toContain("Agents Used:");
|
|
240
|
+
expect(result).toContain("orchestrator");
|
|
241
|
+
expect(result).toContain("Has Todos: Yes");
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
describe("#when called with a non-existent session_id", () => {
|
|
246
|
+
it("#then returns a not found message", async () => {
|
|
247
|
+
const ctx = createMockCtx();
|
|
248
|
+
const result = await handleSessionInfo({ session_id: "ses_nonexistent" }, ctx);
|
|
249
|
+
|
|
250
|
+
expect(result).toContain("Session not found");
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Session, Message, Part, Todo } from "@opencode-ai/sdk";
|
|
2
|
+
|
|
3
|
+
export type { Session, Message, Part, Todo };
|
|
4
|
+
|
|
5
|
+
export interface SessionSummary {
|
|
6
|
+
id: string;
|
|
7
|
+
messageCount: number;
|
|
8
|
+
firstDate: string | null;
|
|
9
|
+
lastDate: string | null;
|
|
10
|
+
agentsUsed: string[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface MessageSummary {
|
|
14
|
+
id: string;
|
|
15
|
+
role: string;
|
|
16
|
+
agent: string | undefined;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
textContent: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SearchMatch {
|
|
22
|
+
sessionId: string;
|
|
23
|
+
messageId: string;
|
|
24
|
+
role: string;
|
|
25
|
+
excerpt: string;
|
|
26
|
+
matchCount: number;
|
|
27
|
+
timestamp: string | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SessionDetail {
|
|
31
|
+
id: string;
|
|
32
|
+
messageCount: number;
|
|
33
|
+
firstDate: string | null;
|
|
34
|
+
lastDate: string | null;
|
|
35
|
+
durationLabel: string | null;
|
|
36
|
+
agentsUsed: string[];
|
|
37
|
+
hasTodos: boolean;
|
|
38
|
+
todoCount: number;
|
|
39
|
+
completedTodoCount: number;
|
|
40
|
+
hasTranscript: boolean;
|
|
41
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from "bun:test";
|
|
2
|
+
import { executeSkill, registerSkillLoader } from "./handler";
|
|
3
|
+
|
|
4
|
+
describe("executeSkill", () => {
|
|
5
|
+
describe("#given a skill loader that returns content for known skills", () => {
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
registerSkillLoader({
|
|
8
|
+
load: (name: string, userMessage?: string) => {
|
|
9
|
+
if (name === "git-master") return "Git workflow instructions";
|
|
10
|
+
if (name === "with-msg" && userMessage) return `Context: ${userMessage}`;
|
|
11
|
+
return undefined;
|
|
12
|
+
},
|
|
13
|
+
list: () => [
|
|
14
|
+
{ name: "git-master", description: "Git workflow" },
|
|
15
|
+
{ name: "with-msg", description: "Uses the forwarded user message" },
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("#when called with a known skill name", () => {
|
|
21
|
+
it("#then returns the skill content from the loader", () => {
|
|
22
|
+
const result = executeSkill({ name: "git-master" });
|
|
23
|
+
expect(result).toBe("Git workflow instructions");
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe("#when called with an unknown skill name", () => {
|
|
28
|
+
it("#then returns a not-found message containing the skill name", () => {
|
|
29
|
+
const result = executeSkill({ name: "nonexistent-skill" });
|
|
30
|
+
expect(result).toContain("nonexistent-skill");
|
|
31
|
+
expect(result).toContain("not found");
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("#when called with a user_message argument", () => {
|
|
36
|
+
it("#then forwards user_message to the loader", () => {
|
|
37
|
+
const result = executeSkill({ name: "with-msg", user_message: "patch release" });
|
|
38
|
+
expect(result).toBe("Context: patch release");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe("#given a loader that always returns undefined", () => {
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
registerSkillLoader({ load: () => undefined, list: () => [] });
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("#when executeSkill is called", () => {
|
|
49
|
+
it("#then returns the not-found message with available sources", () => {
|
|
50
|
+
const result = executeSkill({ name: "missing" });
|
|
51
|
+
expect(result).toContain("missing");
|
|
52
|
+
expect(result).toContain("not found");
|
|
53
|
+
expect(result).toContain(".opencode/skills");
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { log } from "../../shared/logger";
|
|
2
|
+
import type { SkillArgs, SkillInfo, SkillLoader } from "./types";
|
|
3
|
+
|
|
4
|
+
let registeredLoader: SkillLoader | null = null;
|
|
5
|
+
|
|
6
|
+
export function registerSkillLoader(loader: SkillLoader): void {
|
|
7
|
+
registeredLoader = loader;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getAvailableSkills(): SkillInfo[] {
|
|
11
|
+
return typeof registeredLoader?.list === "function" ? registeredLoader.list() : [];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function executeSkill(args: SkillArgs): string {
|
|
15
|
+
log("skill.execute", { name: args.name });
|
|
16
|
+
|
|
17
|
+
if (registeredLoader) {
|
|
18
|
+
const content = registeredLoader.load(args.name, args.user_message);
|
|
19
|
+
if (content !== undefined) {
|
|
20
|
+
return content;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const available = getAvailableSkills();
|
|
25
|
+
const names = available.map((s) => s.name).join(", ");
|
|
26
|
+
return `Skill '${args.name}' not found. Available: ${names || "none"}. Add project skills in .opencode/skills/.`;
|
|
27
|
+
}
|