@bastani/atomic 0.8.13-0 → 0.8.14-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/host-html-template.ts +1 -1
- package/dist/builtin/mcp/init.ts +15 -2
- package/dist/builtin/mcp/mcp-callback-server.ts +10 -9
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/mcp/ui-session.ts +9 -6
- package/dist/builtin/subagents/CHANGELOG.md +8 -1
- package/dist/builtin/subagents/README.md +39 -32
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
- package/dist/builtin/subagents/src/agents/agent-management.ts +6 -1
- package/dist/builtin/subagents/src/agents/agent-serializer.ts +2 -0
- package/dist/builtin/subagents/src/agents/agents.ts +44 -19
- package/dist/builtin/subagents/src/extension/config.ts +16 -0
- package/dist/builtin/subagents/src/extension/fanout-child.ts +246 -0
- package/dist/builtin/subagents/src/extension/index.ts +466 -603
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +6 -4
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +109 -1
- package/dist/builtin/subagents/src/runs/background/async-execution.ts +124 -19
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +41 -6
- package/dist/builtin/subagents/src/runs/background/async-resume.ts +28 -15
- package/dist/builtin/subagents/src/runs/background/async-status.ts +60 -30
- package/dist/builtin/subagents/src/runs/background/result-watcher.ts +111 -54
- package/dist/builtin/subagents/src/runs/background/run-id-resolver.ts +83 -0
- package/dist/builtin/subagents/src/runs/background/run-status.ts +79 -3
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +46 -1
- package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +66 -14
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +10 -3
- package/dist/builtin/subagents/src/runs/foreground/execution.ts +14 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +320 -23
- package/dist/builtin/subagents/src/runs/shared/completion-guard.ts +23 -1
- package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +369 -0
- package/dist/builtin/subagents/src/runs/shared/nested-events.ts +935 -0
- package/dist/builtin/subagents/src/runs/shared/nested-path.ts +52 -0
- package/dist/builtin/subagents/src/runs/shared/nested-render.ts +115 -0
- package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +1 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +82 -9
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/single-output.ts +12 -2
- package/dist/builtin/subagents/src/runs/shared/subagent-prompt-runtime.ts +32 -10
- package/dist/builtin/subagents/src/runs/shared/worktree.ts +3 -2
- package/dist/builtin/subagents/src/shared/artifacts.ts +0 -1
- package/dist/builtin/subagents/src/shared/types.ts +96 -1
- package/dist/builtin/subagents/src/shared/utils.ts +10 -2
- package/dist/builtin/subagents/src/slash/slash-commands.ts +468 -625
- package/dist/builtin/subagents/src/tui/render.ts +1227 -2093
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +24 -0
- package/dist/builtin/workflows/README.md +28 -11
- package/dist/builtin/workflows/builtin/deep-research-codebase.ts +323 -40
- package/dist/builtin/workflows/builtin/ralph.ts +362 -176
- package/dist/builtin/workflows/package.json +2 -5
- package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
- package/dist/builtin/workflows/skills/skill-creator/LICENSE.txt +202 -0
- package/dist/builtin/workflows/skills/skill-creator/SKILL.md +489 -0
- package/dist/builtin/workflows/skills/skill-creator/agents/analyzer.md +274 -0
- package/dist/builtin/workflows/skills/skill-creator/agents/comparator.md +202 -0
- package/dist/builtin/workflows/skills/skill-creator/agents/grader.md +223 -0
- package/dist/builtin/workflows/skills/skill-creator/assets/eval_review.html +146 -0
- package/dist/builtin/workflows/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/dist/builtin/workflows/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/dist/builtin/workflows/skills/skill-creator/references/schemas.md +430 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/__init__.py +0 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/generate_report.py +326 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/improve_description.py +247 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/package_skill.py +136 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/run_eval.py +310 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/run_loop.py +328 -0
- package/dist/builtin/workflows/skills/skill-creator/scripts/utils.py +47 -0
- package/dist/builtin/workflows/src/extension/index.ts +869 -93
- package/dist/builtin/workflows/src/extension/render-call.ts +34 -1
- package/dist/builtin/workflows/src/extension/render-result.ts +126 -21
- package/dist/builtin/workflows/src/extension/runtime.ts +91 -3
- package/dist/builtin/workflows/src/extension/wiring.ts +38 -12
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +62 -5
- package/dist/builtin/workflows/src/runs/background/runner.ts +3 -3
- package/dist/builtin/workflows/src/runs/background/status.ts +42 -8
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +410 -95
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +5 -2
- package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +8 -0
- package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +6 -4
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +3 -2
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +138 -5
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +30 -0
- package/dist/builtin/workflows/src/shared/render-inputs-schema.ts +78 -120
- package/dist/builtin/workflows/src/shared/stage-ui-broker.ts +193 -0
- package/dist/builtin/workflows/src/shared/store-types.ts +26 -1
- package/dist/builtin/workflows/src/shared/store.ts +145 -17
- package/dist/builtin/workflows/src/shared/timing.ts +6 -2
- package/dist/builtin/workflows/src/shared/workflow-failures.ts +375 -0
- package/dist/builtin/workflows/src/tui/chat-surface.ts +68 -17
- package/dist/builtin/workflows/src/tui/connectors.ts +2 -2
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +24 -26
- package/dist/builtin/workflows/src/tui/graph-canvas.ts +4 -8
- package/dist/builtin/workflows/src/tui/graph-view.ts +17 -14
- package/dist/builtin/workflows/src/tui/header.ts +38 -0
- package/dist/builtin/workflows/src/tui/inline-form-card.ts +161 -238
- package/dist/builtin/workflows/src/tui/inline-form-editor.ts +68 -73
- package/dist/builtin/workflows/src/tui/inline-form-overlay.ts +2 -3
- package/dist/builtin/workflows/src/tui/inline-form-store.ts +2 -1
- package/dist/builtin/workflows/src/tui/inputs-overlay.ts +1 -3
- package/dist/builtin/workflows/src/tui/inputs-picker.ts +286 -399
- package/dist/builtin/workflows/src/tui/keybindings-adapter.ts +11 -0
- package/dist/builtin/workflows/src/tui/node-card.ts +2 -1
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +9 -1
- package/dist/builtin/workflows/src/tui/prompt-card.ts +46 -19
- package/dist/builtin/workflows/src/tui/run-detail.ts +63 -80
- package/dist/builtin/workflows/src/tui/session-confirm.ts +9 -3
- package/dist/builtin/workflows/src/tui/session-picker.ts +19 -16
- package/dist/builtin/workflows/src/tui/stage-chat-layout.ts +88 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +368 -879
- package/dist/builtin/workflows/src/tui/status-helpers.ts +4 -0
- package/dist/builtin/workflows/src/tui/status-list.ts +67 -75
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +50 -12
- package/dist/builtin/workflows/src/tui/submit-pane.ts +164 -0
- package/dist/builtin/workflows/src/tui/switcher.ts +27 -4
- package/dist/builtin/workflows/src/tui/text-helpers.ts +98 -4
- package/dist/builtin/workflows/src/tui/widget.ts +90 -68
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +23 -2
- package/dist/builtin/workflows/src/tui/workflow-list.ts +44 -68
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -3
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -10
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +2 -1
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +3 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +16 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +8 -9
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -2
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +2 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +8 -6
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.js +6 -3
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +12 -29
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +5 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/package-manager.d.ts +8 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +145 -58
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +6 -20
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +38 -31
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +9 -4
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +32 -24
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +8 -15
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +8 -22
- package/dist/core/skills.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +5 -4
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js +34 -11
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/contract.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/projections.js +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/projections.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.d.ts +1 -2
- package/dist/core/tools/ask-user-question/state/state-reducer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.js +26 -9
- package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/state.d.ts +4 -0
- package/dist/core/tools/ask-user-question/state/state.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/state.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/option-list-view.d.ts +1 -0
- package/dist/core/tools/ask-user-question/view/components/option-list-view.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/option-list-view.js +1 -0
- package/dist/core/tools/ask-user-question/view/components/option-list-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts +9 -6
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +28 -7
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/props-adapter.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/props-adapter.js +4 -1
- package/dist/core/tools/ask-user-question/view/props-adapter.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +56 -53
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +3 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +8 -1
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +3 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +44 -81
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +27 -12
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +2 -3
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +3 -3
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +5 -5
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +2 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +11 -4
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts +2 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js +39 -21
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +9 -8
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +12 -2
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +20 -35
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +5 -6
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/chat-input-actions.d.ts +24 -0
- package/dist/modes/interactive/chat-input-actions.d.ts.map +1 -0
- package/dist/modes/interactive/chat-input-actions.js +179 -0
- package/dist/modes/interactive/chat-input-actions.js.map +1 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +14 -3
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +157 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host.js +1007 -0
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +14 -5
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +9 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +29 -4
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +18 -67
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/utils/child-process.d.ts +1 -0
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +8 -0
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +3 -1
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js +14 -8
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +124 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +7 -27
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +75 -115
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/paths.d.ts +16 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +49 -7
- package/dist/utils/paths.js.map +1 -1
- package/docs/changelog.mdx +29 -0
- package/docs/compaction.md +1 -1
- package/docs/custom-provider.md +2 -2
- package/docs/development.md +1 -1
- package/docs/docs.json +98 -143
- package/docs/extensions.md +29 -16
- package/docs/favicon.svg +29 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/images/workflow-command.png +0 -0
- package/docs/images/workflow-graph.png +0 -0
- package/docs/images/workflow-input-picker.png +0 -0
- package/docs/images/workflow-list.png +0 -0
- package/docs/index.md +10 -1
- package/docs/logo.svg +59 -0
- package/docs/packages.md +3 -3
- package/docs/providers.md +1 -1
- package/docs/quickstart.md +98 -2
- package/docs/rpc.md +8 -8
- package/docs/sdk.md +23 -12
- package/docs/sessions.md +1 -1
- package/docs/skills.md +15 -1
- package/docs/termux.md +11 -1
- package/docs/themes.md +6 -6
- package/docs/tui.md +18 -18
- package/docs/usage.md +1 -1
- package/docs/workflows.md +172 -2
- package/examples/extensions/subagent/index.ts +2 -1
- package/package.json +6 -6
- /package/dist/builtin/{workflows → subagents}/skills/playwright-cli/SKILL.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/playwright-cli/references/element-attributes.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/playwright-cli/references/playwright-tests.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/playwright-cli/references/request-mocking.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/playwright-cli/references/running-code.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/playwright-cli/references/session-management.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/playwright-cli/references/spec-driven-testing.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/playwright-cli/references/storage-state.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/playwright-cli/references/test-generation.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/playwright-cli/references/tracing.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/playwright-cli/references/video-recording.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/tdd/SKILL.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/tdd/deep-modules.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/tdd/interface-design.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/tdd/mocking.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/tdd/refactoring.md +0 -0
- /package/dist/builtin/{workflows → subagents}/skills/tdd/tests.md +0 -0
|
@@ -3,683 +3,526 @@ import * as fs from "node:fs";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import type { ExtensionAPI, ExtensionContext } from "@bastani/atomic";
|
|
5
5
|
import { Key, matchesKey } from "@earendil-works/pi-tui";
|
|
6
|
-
import {
|
|
7
|
-
discoverAgents,
|
|
8
|
-
discoverAgentsAll,
|
|
9
|
-
type ChainConfig,
|
|
10
|
-
} from "../agents/agents.ts";
|
|
6
|
+
import { discoverAgents, discoverAgentsAll, type ChainConfig } from "../agents/agents.ts";
|
|
11
7
|
import type { SubagentParamsLike } from "../runs/foreground/subagent-executor.ts";
|
|
12
8
|
import { isParallelStep, type ChainStep } from "../shared/settings.ts";
|
|
13
|
-
import type {
|
|
14
|
-
SlashSubagentResponse,
|
|
15
|
-
SlashSubagentUpdate,
|
|
16
|
-
} from "./slash-bridge.ts";
|
|
9
|
+
import type { SlashSubagentResponse, SlashSubagentUpdate } from "./slash-bridge.ts";
|
|
17
10
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
applySlashUpdate,
|
|
12
|
+
buildSlashInitialResult,
|
|
13
|
+
failSlashResult,
|
|
14
|
+
finalizeSlashResult,
|
|
22
15
|
} from "./slash-live-state.ts";
|
|
23
16
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
SLASH_RESULT_TYPE,
|
|
18
|
+
SLASH_SUBAGENT_CANCEL_EVENT,
|
|
19
|
+
SLASH_SUBAGENT_REQUEST_EVENT,
|
|
20
|
+
SLASH_SUBAGENT_RESPONSE_EVENT,
|
|
21
|
+
SLASH_SUBAGENT_STARTED_EVENT,
|
|
22
|
+
SLASH_SUBAGENT_UPDATE_EVENT,
|
|
23
|
+
type SingleResult,
|
|
24
|
+
type SubagentState,
|
|
32
25
|
} from "../shared/types.ts";
|
|
33
26
|
|
|
34
27
|
interface InlineConfig {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
output?: string | false;
|
|
29
|
+
outputMode?: "inline" | "file-only";
|
|
30
|
+
reads?: string[] | false;
|
|
31
|
+
model?: string;
|
|
32
|
+
skill?: string[] | false;
|
|
33
|
+
progress?: boolean;
|
|
41
34
|
}
|
|
42
35
|
|
|
43
36
|
const parseInlineConfig = (raw: string): InlineConfig => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
case "model":
|
|
66
|
-
config.model = val || undefined;
|
|
67
|
-
break;
|
|
68
|
-
case "skill":
|
|
69
|
-
case "skills":
|
|
70
|
-
config.skill = val === "false" ? false : val.split("+").filter(Boolean);
|
|
71
|
-
break;
|
|
72
|
-
case "progress":
|
|
73
|
-
config.progress = val !== "false";
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return config;
|
|
37
|
+
const config: InlineConfig = {};
|
|
38
|
+
for (const part of raw.split(",")) {
|
|
39
|
+
const trimmed = part.trim();
|
|
40
|
+
if (!trimmed) continue;
|
|
41
|
+
const eq = trimmed.indexOf("=");
|
|
42
|
+
if (eq === -1) {
|
|
43
|
+
if (trimmed === "progress") config.progress = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const key = trimmed.slice(0, eq).trim();
|
|
47
|
+
const val = trimmed.slice(eq + 1).trim();
|
|
48
|
+
switch (key) {
|
|
49
|
+
case "output": config.output = val === "false" ? false : val; break;
|
|
50
|
+
case "outputMode": if (val === "inline" || val === "file-only") config.outputMode = val; break;
|
|
51
|
+
case "reads": config.reads = val === "false" ? false : val.split("+").filter(Boolean); break;
|
|
52
|
+
case "model": config.model = val || undefined; break;
|
|
53
|
+
case "skill": case "skills": config.skill = val === "false" ? false : val.split("+").filter(Boolean); break;
|
|
54
|
+
case "progress": config.progress = val !== "false"; break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return config;
|
|
78
58
|
};
|
|
79
59
|
|
|
80
|
-
const parseAgentToken = (
|
|
81
|
-
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const end = token.lastIndexOf("]");
|
|
86
|
-
return {
|
|
87
|
-
name: token.slice(0, bracket),
|
|
88
|
-
config: parseInlineConfig(
|
|
89
|
-
token.slice(bracket + 1, end !== -1 ? end : undefined),
|
|
90
|
-
),
|
|
91
|
-
};
|
|
60
|
+
const parseAgentToken = (token: string): { name: string; config: InlineConfig } => {
|
|
61
|
+
const bracket = token.indexOf("[");
|
|
62
|
+
if (bracket === -1) return { name: token, config: {} };
|
|
63
|
+
const end = token.lastIndexOf("]");
|
|
64
|
+
return { name: token.slice(0, bracket), config: parseInlineConfig(token.slice(bracket + 1, end !== -1 ? end : undefined)) };
|
|
92
65
|
};
|
|
93
66
|
|
|
94
|
-
const extractExecutionFlags = (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return { args, bg, fork };
|
|
67
|
+
const extractExecutionFlags = (rawArgs: string): { args: string; bg: boolean; fork: boolean } => {
|
|
68
|
+
let args = rawArgs.trim();
|
|
69
|
+
let bg = false;
|
|
70
|
+
let fork = false;
|
|
71
|
+
|
|
72
|
+
while (true) {
|
|
73
|
+
if (args.endsWith(" --bg") || args === "--bg") {
|
|
74
|
+
bg = true;
|
|
75
|
+
args = args === "--bg" ? "" : args.slice(0, -5).trim();
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (args.endsWith(" --fork") || args === "--fork") {
|
|
79
|
+
fork = true;
|
|
80
|
+
args = args === "--fork" ? "" : args.slice(0, -7).trim();
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return { args, bg, fork };
|
|
116
87
|
};
|
|
117
88
|
|
|
118
|
-
const makeAgentCompletions =
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const beforeLastWord = prefix.slice(0, prefix.length - lastWord.length);
|
|
140
|
-
|
|
141
|
-
if (lastWord === "->") {
|
|
142
|
-
return agents.map((a) => ({
|
|
143
|
-
value: `${prefix} ${a.name}`,
|
|
144
|
-
label: a.name,
|
|
145
|
-
}));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return agents
|
|
149
|
-
.filter((a) => a.name.startsWith(lastWord))
|
|
150
|
-
.map((a) => ({ value: `${beforeLastWord}${a.name}`, label: a.name }));
|
|
151
|
-
};
|
|
89
|
+
const makeAgentCompletions = (state: SubagentState, multiAgent: boolean) => (prefix: string) => {
|
|
90
|
+
if (!state.baseCwd) return null;
|
|
91
|
+
const agents = discoverAgents(state.baseCwd, "both").agents;
|
|
92
|
+
if (!multiAgent) {
|
|
93
|
+
if (prefix.includes(" ")) return null;
|
|
94
|
+
return agents.filter((a) => a.name.startsWith(prefix)).map((a) => ({ value: a.name, label: a.name }));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const lastArrow = prefix.lastIndexOf(" -> ");
|
|
98
|
+
const segment = lastArrow !== -1 ? prefix.slice(lastArrow + 4) : prefix;
|
|
99
|
+
if (segment.includes(" -- ") || segment.includes('"') || segment.includes("'")) return null;
|
|
100
|
+
|
|
101
|
+
const lastWord = (prefix.match(/(\S*)$/) || ["", ""])[1];
|
|
102
|
+
const beforeLastWord = prefix.slice(0, prefix.length - lastWord.length);
|
|
103
|
+
|
|
104
|
+
if (lastWord === "->") {
|
|
105
|
+
return agents.map((a) => ({ value: `${prefix} ${a.name}`, label: a.name }));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return agents.filter((a) => a.name.startsWith(lastWord)).map((a) => ({ value: `${beforeLastWord}${a.name}`, label: a.name }));
|
|
109
|
+
};
|
|
152
110
|
|
|
153
111
|
const discoverSavedChains = (cwd: string): ChainConfig[] => {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
112
|
+
const chainsByName = new Map<string, ChainConfig>();
|
|
113
|
+
for (const chain of discoverAgentsAll(cwd).chains) {
|
|
114
|
+
chainsByName.set(chain.name, chain);
|
|
115
|
+
}
|
|
116
|
+
return Array.from(chainsByName.values());
|
|
159
117
|
};
|
|
160
118
|
|
|
161
119
|
const makeChainCompletions = (state: SubagentState) => (prefix: string) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
120
|
+
if (prefix.includes(" ") || !state.baseCwd) return null;
|
|
121
|
+
return discoverSavedChains(state.baseCwd)
|
|
122
|
+
.filter((chain) => chain.name.startsWith(prefix))
|
|
123
|
+
.map((chain) => ({ value: chain.name, label: chain.name }));
|
|
166
124
|
};
|
|
167
125
|
|
|
168
|
-
const mapSavedChainSteps = (
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
progress: step.progress,
|
|
183
|
-
skill: step.skill ?? step.skills,
|
|
184
|
-
model: step.model,
|
|
185
|
-
};
|
|
186
|
-
},
|
|
187
|
-
);
|
|
126
|
+
const mapSavedChainSteps = (chain: ChainConfig, worktree = false): ChainStep[] => {
|
|
127
|
+
return (chain.steps as Array<ChainStep & { skills?: string[] | false }>).map((step) => {
|
|
128
|
+
if (isParallelStep(step)) return worktree ? { ...step, worktree: true } : { ...step };
|
|
129
|
+
return {
|
|
130
|
+
agent: step.agent,
|
|
131
|
+
task: step.task || undefined,
|
|
132
|
+
output: step.output,
|
|
133
|
+
outputMode: step.outputMode,
|
|
134
|
+
reads: step.reads,
|
|
135
|
+
progress: step.progress,
|
|
136
|
+
skill: step.skill ?? step.skills,
|
|
137
|
+
model: step.model,
|
|
138
|
+
};
|
|
139
|
+
});
|
|
188
140
|
};
|
|
189
141
|
|
|
190
142
|
async function requestSlashRun(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
143
|
+
pi: ExtensionAPI,
|
|
144
|
+
ctx: ExtensionContext,
|
|
145
|
+
requestId: string,
|
|
146
|
+
params: SubagentParamsLike,
|
|
195
147
|
): Promise<SlashSubagentResponse> {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
// Bridge emits STARTED synchronously during REQUEST emit.
|
|
271
|
-
// If not started, no bridge received the request.
|
|
272
|
-
if (!started && done) return;
|
|
273
|
-
if (!started) {
|
|
274
|
-
finish(() =>
|
|
275
|
-
reject(
|
|
276
|
-
new Error(
|
|
277
|
-
"No slash subagent bridge responded. Ensure the subagent extension is loaded correctly.",
|
|
278
|
-
),
|
|
279
|
-
),
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
});
|
|
148
|
+
return new Promise((resolve, reject) => {
|
|
149
|
+
let done = false;
|
|
150
|
+
let started = false;
|
|
151
|
+
|
|
152
|
+
const startTimeoutMs = 15_000;
|
|
153
|
+
const startTimeout = setTimeout(() => {
|
|
154
|
+
finish(() => reject(new Error(
|
|
155
|
+
"Slash subagent bridge did not start within 15s. Ensure the extension is loaded correctly.",
|
|
156
|
+
)));
|
|
157
|
+
}, startTimeoutMs);
|
|
158
|
+
|
|
159
|
+
const onStarted = (data: unknown) => {
|
|
160
|
+
if (done || !data || typeof data !== "object") return;
|
|
161
|
+
if ((data as { requestId?: unknown }).requestId !== requestId) return;
|
|
162
|
+
started = true;
|
|
163
|
+
clearTimeout(startTimeout);
|
|
164
|
+
if (ctx.hasUI) ctx.ui.setStatus("subagent-slash", "running...");
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const onResponse = (data: unknown) => {
|
|
168
|
+
if (done || !data || typeof data !== "object") return;
|
|
169
|
+
const response = data as Partial<SlashSubagentResponse>;
|
|
170
|
+
if (response.requestId !== requestId) return;
|
|
171
|
+
clearTimeout(startTimeout);
|
|
172
|
+
finish(() => resolve(response as SlashSubagentResponse));
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const onUpdate = (data: unknown) => {
|
|
176
|
+
if (done || !data || typeof data !== "object") return;
|
|
177
|
+
const update = data as SlashSubagentUpdate;
|
|
178
|
+
if (update.requestId !== requestId) return;
|
|
179
|
+
applySlashUpdate(requestId, update);
|
|
180
|
+
if (!ctx.hasUI) return;
|
|
181
|
+
const tool = update.currentTool ? ` ${update.currentTool}` : "";
|
|
182
|
+
const count = update.toolCount ?? 0;
|
|
183
|
+
ctx.ui.setStatus("subagent-slash", `${count} tools${tool} | ctrl+o live detail`);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const onTerminalInput = ctx.hasUI
|
|
187
|
+
? ctx.ui.onTerminalInput((input) => {
|
|
188
|
+
if (!matchesKey(input, Key.escape)) return undefined;
|
|
189
|
+
pi.events.emit(SLASH_SUBAGENT_CANCEL_EVENT, { requestId });
|
|
190
|
+
finish(() => reject(new Error("Cancelled")));
|
|
191
|
+
return { consume: true };
|
|
192
|
+
})
|
|
193
|
+
: undefined;
|
|
194
|
+
|
|
195
|
+
const unsubStarted = pi.events.on(SLASH_SUBAGENT_STARTED_EVENT, onStarted);
|
|
196
|
+
const unsubResponse = pi.events.on(SLASH_SUBAGENT_RESPONSE_EVENT, onResponse);
|
|
197
|
+
const unsubUpdate = pi.events.on(SLASH_SUBAGENT_UPDATE_EVENT, onUpdate);
|
|
198
|
+
|
|
199
|
+
const finish = (next: () => void) => {
|
|
200
|
+
if (done) return;
|
|
201
|
+
done = true;
|
|
202
|
+
clearTimeout(startTimeout);
|
|
203
|
+
unsubStarted();
|
|
204
|
+
unsubResponse();
|
|
205
|
+
unsubUpdate();
|
|
206
|
+
onTerminalInput?.();
|
|
207
|
+
next();
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
pi.events.emit(SLASH_SUBAGENT_REQUEST_EVENT, { requestId, params });
|
|
211
|
+
|
|
212
|
+
// Bridge emits STARTED synchronously during REQUEST emit.
|
|
213
|
+
// If not started, no bridge received the request.
|
|
214
|
+
if (!started && done) return;
|
|
215
|
+
if (!started) {
|
|
216
|
+
finish(() => reject(new Error(
|
|
217
|
+
"No slash subagent bridge responded. Ensure the subagent extension is loaded correctly.",
|
|
218
|
+
)));
|
|
219
|
+
}
|
|
220
|
+
});
|
|
283
221
|
}
|
|
284
222
|
|
|
285
|
-
function extractSlashMessageText(
|
|
286
|
-
|
|
287
|
-
)
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
(part): part is { type: "text"; text: string } =>
|
|
293
|
-
part?.type === "text" && typeof part.text === "string",
|
|
294
|
-
)
|
|
295
|
-
.map((part) => part.text)
|
|
296
|
-
.join("\n");
|
|
223
|
+
function extractSlashMessageText(content: string | Array<{ type?: string; text?: string }>): string {
|
|
224
|
+
if (typeof content === "string") return content;
|
|
225
|
+
if (!Array.isArray(content)) return "";
|
|
226
|
+
return content
|
|
227
|
+
.filter((part): part is { type: "text"; text: string } => part?.type === "text" && typeof part.text === "string")
|
|
228
|
+
.map((part) => part.text)
|
|
229
|
+
.join("\n");
|
|
297
230
|
}
|
|
298
231
|
|
|
299
232
|
function formatExportPathList(paths: string[]): string {
|
|
300
|
-
|
|
233
|
+
return paths.map((file) => `- \`${file}\``).join("\n");
|
|
301
234
|
}
|
|
302
235
|
|
|
303
|
-
function collectResultPaths(
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
): string
|
|
307
|
-
return results
|
|
308
|
-
.map(getPath)
|
|
309
|
-
.filter(
|
|
310
|
-
(file): file is string => typeof file === "string" && file.length > 0,
|
|
311
|
-
);
|
|
236
|
+
function collectResultPaths(results: SingleResult[], getPath: (result: SingleResult) => string | undefined): string[] {
|
|
237
|
+
return results
|
|
238
|
+
.map(getPath)
|
|
239
|
+
.filter((file): file is string => typeof file === "string" && file.length > 0);
|
|
312
240
|
}
|
|
313
241
|
|
|
314
242
|
function buildSlashExportText(response: SlashSubagentResponse): string {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
results,
|
|
326
|
-
(result) => result.savedOutputPath,
|
|
327
|
-
);
|
|
328
|
-
const artifactOutputs = collectResultPaths(
|
|
329
|
-
results,
|
|
330
|
-
(result) => result.artifactPaths?.outputPath,
|
|
331
|
-
);
|
|
332
|
-
const sections = ["## Subagent result", output];
|
|
333
|
-
if (sessionFiles.length > 0)
|
|
334
|
-
sections.push(
|
|
335
|
-
"## Child session exports",
|
|
336
|
-
formatExportPathList(sessionFiles),
|
|
337
|
-
);
|
|
338
|
-
if (savedOutputs.length > 0)
|
|
339
|
-
sections.push("## Saved outputs", formatExportPathList(savedOutputs));
|
|
340
|
-
if (artifactOutputs.length > 0)
|
|
341
|
-
sections.push("## Artifact outputs", formatExportPathList(artifactOutputs));
|
|
342
|
-
return sections.join("\n\n");
|
|
243
|
+
const output = extractSlashMessageText(response.result.content) || response.errorText || "(no output)";
|
|
244
|
+
const results = response.result.details?.results ?? [];
|
|
245
|
+
const sessionFiles = collectResultPaths(results, (result) => result.sessionFile);
|
|
246
|
+
const savedOutputs = collectResultPaths(results, (result) => result.savedOutputPath);
|
|
247
|
+
const artifactOutputs = collectResultPaths(results, (result) => result.artifactPaths?.outputPath);
|
|
248
|
+
const sections = ["## Subagent result", output];
|
|
249
|
+
if (sessionFiles.length > 0) sections.push("## Child session exports", formatExportPathList(sessionFiles));
|
|
250
|
+
if (savedOutputs.length > 0) sections.push("## Saved outputs", formatExportPathList(savedOutputs));
|
|
251
|
+
if (artifactOutputs.length > 0) sections.push("## Artifact outputs", formatExportPathList(artifactOutputs));
|
|
252
|
+
return sections.join("\n\n");
|
|
343
253
|
}
|
|
344
254
|
|
|
345
255
|
function persistSlashSessionSnapshot(ctx: ExtensionContext): void {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
"Failed to persist slash session snapshot for export:",
|
|
361
|
-
error,
|
|
362
|
-
);
|
|
363
|
-
}
|
|
256
|
+
try {
|
|
257
|
+
if (!ctx.sessionManager) return;
|
|
258
|
+
const sessionManager = ctx.sessionManager as typeof ctx.sessionManager & {
|
|
259
|
+
_rewriteFile?: () => void;
|
|
260
|
+
flushed?: boolean;
|
|
261
|
+
};
|
|
262
|
+
const sessionFile = sessionManager.getSessionFile();
|
|
263
|
+
if (!sessionFile || typeof sessionManager._rewriteFile !== "function") return;
|
|
264
|
+
fs.mkdirSync(path.dirname(sessionFile), { recursive: true });
|
|
265
|
+
sessionManager._rewriteFile();
|
|
266
|
+
sessionManager.flushed = true;
|
|
267
|
+
} catch (error) {
|
|
268
|
+
console.error("Failed to persist slash session snapshot for export:", error);
|
|
269
|
+
}
|
|
364
270
|
}
|
|
365
271
|
|
|
366
272
|
async function runSlashSubagent(
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
273
|
+
pi: ExtensionAPI,
|
|
274
|
+
ctx: ExtensionContext,
|
|
275
|
+
params: SubagentParamsLike,
|
|
370
276
|
): Promise<void> {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
if (ctx.hasUI) ctx.ui.notify(message, "error");
|
|
419
|
-
}
|
|
277
|
+
if (ctx.hasUI) ctx.ui.setToolsExpanded(false);
|
|
278
|
+
const requestId = randomUUID();
|
|
279
|
+
const initialDetails = buildSlashInitialResult(requestId, params);
|
|
280
|
+
const initialText = extractSlashMessageText(initialDetails.result.content) || "Running subagent...";
|
|
281
|
+
pi.sendMessage({
|
|
282
|
+
customType: SLASH_RESULT_TYPE,
|
|
283
|
+
content: initialText,
|
|
284
|
+
display: true,
|
|
285
|
+
details: initialDetails,
|
|
286
|
+
});
|
|
287
|
+
persistSlashSessionSnapshot(ctx);
|
|
288
|
+
|
|
289
|
+
try {
|
|
290
|
+
const response = await requestSlashRun(pi, ctx, requestId, params);
|
|
291
|
+
const finalDetails = finalizeSlashResult(response);
|
|
292
|
+
pi.sendMessage({
|
|
293
|
+
customType: SLASH_RESULT_TYPE,
|
|
294
|
+
content: buildSlashExportText(response),
|
|
295
|
+
display: true,
|
|
296
|
+
details: finalDetails,
|
|
297
|
+
});
|
|
298
|
+
persistSlashSessionSnapshot(ctx);
|
|
299
|
+
if (ctx.hasUI) {
|
|
300
|
+
ctx.ui.setStatus("subagent-slash", undefined);
|
|
301
|
+
}
|
|
302
|
+
if (response.isError && ctx.hasUI) {
|
|
303
|
+
ctx.ui.notify(response.errorText || "Subagent failed", "error");
|
|
304
|
+
}
|
|
305
|
+
} catch (error) {
|
|
306
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
307
|
+
const failedDetails = failSlashResult(requestId, params, message);
|
|
308
|
+
pi.sendMessage({
|
|
309
|
+
customType: SLASH_RESULT_TYPE,
|
|
310
|
+
content: `## Subagent result\n\n${message}`,
|
|
311
|
+
display: true,
|
|
312
|
+
details: failedDetails,
|
|
313
|
+
});
|
|
314
|
+
persistSlashSessionSnapshot(ctx);
|
|
315
|
+
if (ctx.hasUI) {
|
|
316
|
+
ctx.ui.setStatus("subagent-slash", undefined);
|
|
317
|
+
}
|
|
318
|
+
if (message === "Cancelled") {
|
|
319
|
+
if (ctx.hasUI) ctx.ui.notify("Cancelled", "warning");
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (ctx.hasUI) ctx.ui.notify(message, "error");
|
|
323
|
+
}
|
|
420
324
|
}
|
|
421
325
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
config: InlineConfig;
|
|
425
|
-
task?: string;
|
|
426
|
-
}
|
|
326
|
+
|
|
327
|
+
interface ParsedStep { name: string; config: InlineConfig; task?: string }
|
|
427
328
|
|
|
428
329
|
const parseAgentArgs = (
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
330
|
+
state: SubagentState,
|
|
331
|
+
args: string,
|
|
332
|
+
command: string,
|
|
333
|
+
ctx: ExtensionContext,
|
|
433
334
|
): { steps: ParsedStep[]; task: string } | null => {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
);
|
|
506
|
-
return null;
|
|
507
|
-
}
|
|
508
|
-
if (command === "parallel" && !steps.some((s) => s.task) && !sharedTask) {
|
|
509
|
-
ctx.ui.notify("At least one step must have a task", "error");
|
|
510
|
-
return null;
|
|
511
|
-
}
|
|
512
|
-
return { steps, task: sharedTask };
|
|
335
|
+
const input = args.trim();
|
|
336
|
+
const usage = `Usage: /${command} agent1 "task1" -> agent2 "task2"`;
|
|
337
|
+
let steps: ParsedStep[];
|
|
338
|
+
let sharedTask: string;
|
|
339
|
+
let perStep = false;
|
|
340
|
+
|
|
341
|
+
if (input.includes(" -> ")) {
|
|
342
|
+
perStep = true;
|
|
343
|
+
const segments = input.split(" -> ");
|
|
344
|
+
steps = [];
|
|
345
|
+
for (const seg of segments) {
|
|
346
|
+
const trimmed = seg.trim();
|
|
347
|
+
if (!trimmed) continue;
|
|
348
|
+
let agentPart: string;
|
|
349
|
+
let task: string | undefined;
|
|
350
|
+
const qMatch = trimmed.match(/^(\S+(?:\[[^\]]*\])?)\s+(?:"([^"]*)"|'([^']*)')$/);
|
|
351
|
+
if (qMatch) {
|
|
352
|
+
agentPart = qMatch[1]!;
|
|
353
|
+
task = (qMatch[2] ?? qMatch[3]) || undefined;
|
|
354
|
+
} else {
|
|
355
|
+
const dashIdx = trimmed.indexOf(" -- ");
|
|
356
|
+
if (dashIdx !== -1) {
|
|
357
|
+
agentPart = trimmed.slice(0, dashIdx).trim();
|
|
358
|
+
task = trimmed.slice(dashIdx + 4).trim() || undefined;
|
|
359
|
+
} else {
|
|
360
|
+
agentPart = trimmed;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const parsed = parseAgentToken(agentPart);
|
|
364
|
+
steps.push({ ...parsed, task });
|
|
365
|
+
}
|
|
366
|
+
sharedTask = steps.find((s) => s.task)?.task ?? "";
|
|
367
|
+
} else {
|
|
368
|
+
const delimiterIndex = input.indexOf(" -- ");
|
|
369
|
+
if (delimiterIndex === -1) {
|
|
370
|
+
ctx.ui.notify(usage, "error");
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
const agentsPart = input.slice(0, delimiterIndex).trim();
|
|
374
|
+
sharedTask = input.slice(delimiterIndex + 4).trim();
|
|
375
|
+
if (!agentsPart || !sharedTask) {
|
|
376
|
+
ctx.ui.notify(usage, "error");
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
steps = agentsPart.split(/\s+/).filter(Boolean).map((t) => parseAgentToken(t));
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (steps.length === 0) {
|
|
383
|
+
ctx.ui.notify(usage, "error");
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
if (!state.baseCwd) {
|
|
387
|
+
ctx.ui.notify("Subagent session cwd is not initialized yet", "error");
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
const agents = discoverAgents(state.baseCwd, "both").agents;
|
|
391
|
+
for (const step of steps) {
|
|
392
|
+
if (!agents.find((a) => a.name === step.name)) {
|
|
393
|
+
ctx.ui.notify(`Unknown agent: ${step.name}`, "error");
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if (command === "chain" && !steps[0]?.task && (perStep || !sharedTask)) {
|
|
398
|
+
ctx.ui.notify(`First step must have a task: /chain agent "task" -> agent2`, "error");
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
if (command === "parallel" && !steps.some((s) => s.task) && !sharedTask) {
|
|
402
|
+
ctx.ui.notify("At least one step must have a task", "error");
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
return { steps, task: sharedTask };
|
|
513
406
|
};
|
|
514
407
|
|
|
515
408
|
export function registerSlashCommands(
|
|
516
|
-
|
|
517
|
-
|
|
409
|
+
pi: ExtensionAPI,
|
|
410
|
+
state: SubagentState,
|
|
518
411
|
): void {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
}
|
|
636
|
-
const params: SubagentParamsLike = {
|
|
637
|
-
chain: mapSavedChainSteps(chain),
|
|
638
|
-
task,
|
|
639
|
-
clarify: false,
|
|
640
|
-
agentScope: "both",
|
|
641
|
-
};
|
|
642
|
-
if (bg) params.async = true;
|
|
643
|
-
if (fork) params.context = "fork";
|
|
644
|
-
await runSlashSubagent(pi, ctx, params);
|
|
645
|
-
},
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
pi.registerCommand("parallel", {
|
|
649
|
-
description:
|
|
650
|
-
'Run agents in parallel: /parallel scout "task1" -> reviewer "task2" [--bg] [--fork]',
|
|
651
|
-
getArgumentCompletions: makeAgentCompletions(state, true),
|
|
652
|
-
handler: async (args, ctx) => {
|
|
653
|
-
const { args: cleanedArgs, bg, fork } = extractExecutionFlags(args);
|
|
654
|
-
const parsed = parseAgentArgs(state, cleanedArgs, "parallel", ctx);
|
|
655
|
-
if (!parsed) return;
|
|
656
|
-
const tasks = parsed.steps.map(({ name, config, task: stepTask }) => ({
|
|
657
|
-
agent: name,
|
|
658
|
-
task: stepTask ?? parsed.task,
|
|
659
|
-
...(config.output !== undefined ? { output: config.output } : {}),
|
|
660
|
-
...(config.outputMode !== undefined
|
|
661
|
-
? { outputMode: config.outputMode }
|
|
662
|
-
: {}),
|
|
663
|
-
...(config.reads !== undefined ? { reads: config.reads } : {}),
|
|
664
|
-
...(config.model ? { model: config.model } : {}),
|
|
665
|
-
...(config.skill !== undefined ? { skill: config.skill } : {}),
|
|
666
|
-
...(config.progress !== undefined ? { progress: config.progress } : {}),
|
|
667
|
-
}));
|
|
668
|
-
const params: SubagentParamsLike = {
|
|
669
|
-
tasks,
|
|
670
|
-
clarify: false,
|
|
671
|
-
agentScope: "both",
|
|
672
|
-
};
|
|
673
|
-
if (bg) params.async = true;
|
|
674
|
-
if (fork) params.context = "fork";
|
|
675
|
-
await runSlashSubagent(pi, ctx, params);
|
|
676
|
-
},
|
|
677
|
-
});
|
|
678
|
-
|
|
679
|
-
pi.registerCommand("subagents-doctor", {
|
|
680
|
-
description: "Show subagent diagnostics",
|
|
681
|
-
handler: async (_args, ctx) => {
|
|
682
|
-
await runSlashSubagent(pi, ctx, { action: "doctor" });
|
|
683
|
-
},
|
|
684
|
-
});
|
|
412
|
+
pi.registerCommand("run", {
|
|
413
|
+
description: "Run a subagent directly: /run agent[output=file] [task] [--bg] [--fork]",
|
|
414
|
+
getArgumentCompletions: makeAgentCompletions(state, false),
|
|
415
|
+
handler: async (args, ctx) => {
|
|
416
|
+
const { args: cleanedArgs, bg, fork } = extractExecutionFlags(args);
|
|
417
|
+
const input = cleanedArgs.trim();
|
|
418
|
+
const firstSpace = input.indexOf(" ");
|
|
419
|
+
if (!input) { ctx.ui.notify("Usage: /run <agent> [task] [--bg] [--fork]", "error"); return; }
|
|
420
|
+
const { name: agentName, config: inline } = parseAgentToken(firstSpace === -1 ? input : input.slice(0, firstSpace));
|
|
421
|
+
const task = firstSpace === -1 ? "" : input.slice(firstSpace + 1).trim();
|
|
422
|
+
|
|
423
|
+
if (!state.baseCwd) { ctx.ui.notify("Subagent session cwd is not initialized yet", "error"); return; }
|
|
424
|
+
const agents = discoverAgents(state.baseCwd, "both").agents;
|
|
425
|
+
if (!agents.find((a) => a.name === agentName)) { ctx.ui.notify(`Unknown agent: ${agentName}`, "error"); return; }
|
|
426
|
+
|
|
427
|
+
let finalTask = task;
|
|
428
|
+
if (inline.reads && Array.isArray(inline.reads) && inline.reads.length > 0) {
|
|
429
|
+
finalTask = `[Read from: ${inline.reads.join(", ")}]\n\n${finalTask}`;
|
|
430
|
+
}
|
|
431
|
+
const params: SubagentParamsLike = { agent: agentName, task: finalTask, clarify: false, agentScope: "both" };
|
|
432
|
+
if (inline.output !== undefined) params.output = inline.output;
|
|
433
|
+
if (inline.outputMode !== undefined) params.outputMode = inline.outputMode;
|
|
434
|
+
if (inline.skill !== undefined) params.skill = inline.skill;
|
|
435
|
+
if (inline.model) params.model = inline.model;
|
|
436
|
+
if (bg) params.async = true;
|
|
437
|
+
if (fork) params.context = "fork";
|
|
438
|
+
await runSlashSubagent(pi, ctx, params);
|
|
439
|
+
},
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
pi.registerCommand("chain", {
|
|
443
|
+
description: "Run agents in sequence: /chain scout \"task\" -> planner [--bg] [--fork]",
|
|
444
|
+
getArgumentCompletions: makeAgentCompletions(state, true),
|
|
445
|
+
handler: async (args, ctx) => {
|
|
446
|
+
const { args: cleanedArgs, bg, fork } = extractExecutionFlags(args);
|
|
447
|
+
const parsed = parseAgentArgs(state, cleanedArgs, "chain", ctx);
|
|
448
|
+
if (!parsed) return;
|
|
449
|
+
const chain = parsed.steps.map(({ name, config, task: stepTask }, i) => ({
|
|
450
|
+
agent: name,
|
|
451
|
+
...(stepTask ? { task: stepTask } : i === 0 && parsed.task ? { task: parsed.task } : {}),
|
|
452
|
+
...(config.output !== undefined ? { output: config.output } : {}),
|
|
453
|
+
...(config.outputMode !== undefined ? { outputMode: config.outputMode } : {}),
|
|
454
|
+
...(config.reads !== undefined ? { reads: config.reads } : {}),
|
|
455
|
+
...(config.model ? { model: config.model } : {}),
|
|
456
|
+
...(config.skill !== undefined ? { skill: config.skill } : {}),
|
|
457
|
+
...(config.progress !== undefined ? { progress: config.progress } : {}),
|
|
458
|
+
}));
|
|
459
|
+
const params: SubagentParamsLike = { chain, task: parsed.task, clarify: false, agentScope: "both" };
|
|
460
|
+
if (bg) params.async = true;
|
|
461
|
+
if (fork) params.context = "fork";
|
|
462
|
+
await runSlashSubagent(pi, ctx, params);
|
|
463
|
+
},
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
pi.registerCommand("run-chain", {
|
|
467
|
+
description: "Run a saved chain: /run-chain chainName -- task [--bg] [--fork]",
|
|
468
|
+
getArgumentCompletions: makeChainCompletions(state),
|
|
469
|
+
handler: async (args, ctx) => {
|
|
470
|
+
const { args: cleanedArgs, bg, fork } = extractExecutionFlags(args);
|
|
471
|
+
const delimiterIndex = cleanedArgs.indexOf(" -- ");
|
|
472
|
+
const usage = "Usage: /run-chain <chainName> -- <task> [--bg] [--fork]";
|
|
473
|
+
if (delimiterIndex === -1) {
|
|
474
|
+
ctx.ui.notify(usage, "error");
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const chainName = cleanedArgs.slice(0, delimiterIndex).trim();
|
|
478
|
+
const task = cleanedArgs.slice(delimiterIndex + 4).trim();
|
|
479
|
+
if (!chainName || !task) {
|
|
480
|
+
ctx.ui.notify(usage, "error");
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
if (!state.baseCwd) { ctx.ui.notify("Subagent session cwd is not initialized yet", "error"); return; }
|
|
484
|
+
const chain = discoverSavedChains(state.baseCwd).find((candidate) => candidate.name === chainName);
|
|
485
|
+
if (!chain) {
|
|
486
|
+
ctx.ui.notify(`Unknown chain: ${chainName}`, "error");
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
const params: SubagentParamsLike = { chain: mapSavedChainSteps(chain), task, clarify: false, agentScope: "both" };
|
|
490
|
+
if (bg) params.async = true;
|
|
491
|
+
if (fork) params.context = "fork";
|
|
492
|
+
await runSlashSubagent(pi, ctx, params);
|
|
493
|
+
},
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
pi.registerCommand("parallel", {
|
|
497
|
+
description: "Run agents in parallel: /parallel scout \"task1\" -> reviewer \"task2\" [--bg] [--fork]",
|
|
498
|
+
getArgumentCompletions: makeAgentCompletions(state, true),
|
|
499
|
+
handler: async (args, ctx) => {
|
|
500
|
+
const { args: cleanedArgs, bg, fork } = extractExecutionFlags(args);
|
|
501
|
+
const parsed = parseAgentArgs(state, cleanedArgs, "parallel", ctx);
|
|
502
|
+
if (!parsed) return;
|
|
503
|
+
const tasks = parsed.steps.map(({ name, config, task: stepTask }) => ({
|
|
504
|
+
agent: name,
|
|
505
|
+
task: stepTask ?? parsed.task,
|
|
506
|
+
...(config.output !== undefined ? { output: config.output } : {}),
|
|
507
|
+
...(config.outputMode !== undefined ? { outputMode: config.outputMode } : {}),
|
|
508
|
+
...(config.reads !== undefined ? { reads: config.reads } : {}),
|
|
509
|
+
...(config.model ? { model: config.model } : {}),
|
|
510
|
+
...(config.skill !== undefined ? { skill: config.skill } : {}),
|
|
511
|
+
...(config.progress !== undefined ? { progress: config.progress } : {}),
|
|
512
|
+
}));
|
|
513
|
+
const params: SubagentParamsLike = { tasks, clarify: false, agentScope: "both" };
|
|
514
|
+
if (bg) params.async = true;
|
|
515
|
+
if (fork) params.context = "fork";
|
|
516
|
+
await runSlashSubagent(pi, ctx, params);
|
|
517
|
+
},
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
pi.registerCommand("subagents-doctor", {
|
|
522
|
+
description: "Show subagent diagnostics",
|
|
523
|
+
handler: async (_args, ctx) => {
|
|
524
|
+
await runSlashSubagent(pi, ctx, { action: "doctor" });
|
|
525
|
+
},
|
|
526
|
+
});
|
|
527
|
+
|
|
685
528
|
}
|