@bastani/atomic 0.8.11 → 0.8.12-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 +21 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +3 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/agents/agent-serializer.ts +3 -2
- package/dist/builtin/subagents/src/agents/agents.ts +1 -1
- package/dist/builtin/subagents/src/extension/index.ts +597 -471
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +16 -8
- package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +9 -13
- package/dist/builtin/subagents/src/runs/foreground/execution.ts +7 -3
- package/dist/builtin/subagents/src/shared/formatters.ts +8 -3
- package/dist/builtin/subagents/src/slash/slash-commands.ts +625 -468
- package/dist/builtin/subagents/src/tui/render.ts +342 -158
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +15 -4
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +75 -33
- package/dist/builtin/workflows/src/shared/store-types.ts +3 -4
- package/dist/builtin/workflows/src/shared/store.ts +2 -3
- package/dist/builtin/workflows/src/tui/graph-view.ts +12 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +1 -2
- package/dist/builtin/workflows/src/tui/status-helpers.ts +1 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js.map +1 -1
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts +2 -2
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/initial-message.d.ts +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/list-models.d.ts +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -6
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +45 -22
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +9 -9
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +2 -3
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +7 -7
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +10 -10
- package/dist/core/agent-session.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/auth-storage.d.ts +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +1 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/builtin-packages.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +3 -3
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/index.d.ts +3 -3
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/index.d.ts +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts +2 -2
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/index.d.ts +8 -8
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +3 -3
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +6 -6
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +20 -20
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts +2 -2
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts +32 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +43 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/index.d.ts +8 -8
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +4 -4
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-manager.d.ts +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +10 -11
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader.d.ts +9 -9
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +13 -13
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +3 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +21 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +2 -2
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/source-info.d.ts +1 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +7 -8
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/telemetry.d.ts +1 -1
- package/dist/core/telemetry.d.ts.map +1 -1
- package/dist/core/telemetry.js.map +1 -1
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts +4 -4
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
- package/dist/core/tools/ask-user-question/index.d.ts +1 -1
- package/dist/core/tools/ask-user-question/index.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/index.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts +5 -5
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/key-router.d.ts +2 -2
- package/dist/core/tools/ask-user-question/state/key-router.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/key-router.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +3 -3
- 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.map +1 -1
- package/dist/core/tools/ask-user-question/state/row-intent.d.ts +2 -2
- package/dist/core/tools/ask-user-question/state/row-intent.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/row-intent.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts +6 -6
- 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/derivations.d.ts +2 -2
- package/dist/core/tools/ask-user-question/state/selectors/derivations.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/derivations.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/focus.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/focus.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/focus.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts +8 -8
- 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.map +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.d.ts +4 -4
- 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.map +1 -1
- package/dist/core/tools/ask-user-question/state/state.d.ts +2 -2
- 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/tool/format-answer.d.ts +1 -1
- package/dist/core/tools/ask-user-question/tool/format-answer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/tool/format-answer.js.map +1 -1
- package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts +1 -1
- package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/tool/response-envelope.js.map +1 -1
- package/dist/core/tools/ask-user-question/tool/types.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/tool/types.js.map +1 -1
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.d.ts +1 -1
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/body-residual-spacer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/body-residual-spacer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/component-binding.d.ts +4 -4
- package/dist/core/tools/ask-user-question/view/component-binding.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/component-binding.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/chat-row-view.d.ts +2 -2
- package/dist/core/tools/ask-user-question/view/components/chat-row-view.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/chat-row-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts +4 -4
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/option-list-view.d.ts +2 -2
- 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.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts +2 -2
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +3 -3
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.d.ts +2 -2
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +8 -8
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts +3 -3
- package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts +3 -3
- package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/tab-bar.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts +8 -8
- package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/props-adapter.d.ts +5 -5
- 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.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-components.d.ts +4 -4
- package/dist/core/tools/ask-user-question/view/tab-components.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-components.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts +9 -9
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +2 -2
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +9 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +2 -2
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +2 -2
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +2 -2
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +19 -19
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +2 -2
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/read.d.ts +2 -2
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/todos.d.ts +1 -1
- package/dist/core/tools/todos.d.ts.map +1 -1
- package/dist/core/tools/todos.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.d.ts +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +30 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts +5 -5
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +3 -3
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +2 -2
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts +2 -2
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +2 -2
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +3 -3
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +34 -34
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +1 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +3 -3
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +13 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/working-status.d.ts.map +1 -1
- package/dist/modes/interactive/components/working-status.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +7 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +5 -5
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +1 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +2 -2
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +4 -4
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +22 -6
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/changelog.d.ts +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts +5 -2
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +9 -7
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/utils/windows-self-update.d.ts.map +1 -0
- package/dist/utils/windows-self-update.js +78 -0
- package/dist/utils/windows-self-update.js.map +1 -0
- package/docs/compaction.md +5 -5
- package/docs/custom-provider.md +2 -2
- package/docs/development.md +22 -16
- package/docs/docs.json +6 -2
- package/docs/extensions.md +25 -25
- package/docs/index.md +11 -14
- package/docs/keybindings.md +5 -5
- package/docs/models.md +6 -6
- package/docs/packages.md +55 -48
- package/docs/prompt-templates.md +5 -5
- package/docs/providers.md +10 -10
- package/docs/quickstart.md +32 -30
- package/docs/rpc.md +9 -9
- package/docs/sdk.md +1 -1
- package/docs/session-format.md +3 -3
- package/docs/sessions.md +11 -11
- package/docs/settings.md +18 -15
- package/docs/shell-aliases.md +2 -2
- package/docs/skills.md +11 -11
- package/docs/terminal-setup.md +8 -8
- package/docs/termux.md +6 -6
- package/docs/themes.md +10 -10
- package/docs/tui.md +5 -4
- package/docs/usage.md +50 -50
- package/docs/windows.md +2 -2
- package/docs/workflows.md +695 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
- package/examples/extensions/doom-overlay/doom-component.ts +2 -2
- package/examples/extensions/doom-overlay/index.ts +3 -3
- package/examples/extensions/overlay-qa-tests.ts +116 -33
- package/examples/extensions/overlay-test.ts +9 -3
- package/examples/extensions/plan-mode/index.ts +1 -1
- package/examples/extensions/subagent/index.ts +1159 -903
- package/package.json +6 -4
- package/dist/builtin/workflows/skills/workflow/SKILL.md +0 -322
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/advanced-evaluation.md +0 -404
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/bdi-mental-states.md +0 -313
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/context-compression.md +0 -274
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/context-degradation.md +0 -208
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/context-fundamentals.md +0 -203
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/context-optimization.md +0 -197
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/evaluation.md +0 -253
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/filesystem-context.md +0 -289
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/hosted-agents.md +0 -262
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/memory-systems.md +0 -221
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/multi-agent-patterns.md +0 -259
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/project-development.md +0 -293
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/tool-design.md +0 -273
- package/dist/builtin/workflows/skills/workflow/references/context-engineering.md +0 -23
- package/dist/builtin/workflows/skills/workflow/references/design-checklist.md +0 -83
- package/dist/builtin/workflows/skills/workflow/references/running-workflows.md +0 -159
- package/dist/builtin/workflows/skills/workflow/references/sdk-authoring.md +0 -260
|
@@ -3,526 +3,683 @@ 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 {
|
|
6
|
+
import {
|
|
7
|
+
discoverAgents,
|
|
8
|
+
discoverAgentsAll,
|
|
9
|
+
type ChainConfig,
|
|
10
|
+
} from "../agents/agents.ts";
|
|
7
11
|
import type { SubagentParamsLike } from "../runs/foreground/subagent-executor.ts";
|
|
8
12
|
import { isParallelStep, type ChainStep } from "../shared/settings.ts";
|
|
9
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
SlashSubagentResponse,
|
|
15
|
+
SlashSubagentUpdate,
|
|
16
|
+
} from "./slash-bridge.ts";
|
|
10
17
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
applySlashUpdate,
|
|
19
|
+
buildSlashInitialResult,
|
|
20
|
+
failSlashResult,
|
|
21
|
+
finalizeSlashResult,
|
|
15
22
|
} from "./slash-live-state.ts";
|
|
16
23
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
SLASH_RESULT_TYPE,
|
|
25
|
+
SLASH_SUBAGENT_CANCEL_EVENT,
|
|
26
|
+
SLASH_SUBAGENT_REQUEST_EVENT,
|
|
27
|
+
SLASH_SUBAGENT_RESPONSE_EVENT,
|
|
28
|
+
SLASH_SUBAGENT_STARTED_EVENT,
|
|
29
|
+
SLASH_SUBAGENT_UPDATE_EVENT,
|
|
30
|
+
type SingleResult,
|
|
31
|
+
type SubagentState,
|
|
25
32
|
} from "../shared/types.ts";
|
|
26
33
|
|
|
27
34
|
interface InlineConfig {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
output?: string | false;
|
|
36
|
+
outputMode?: "inline" | "file-only";
|
|
37
|
+
reads?: string[] | false;
|
|
38
|
+
model?: string;
|
|
39
|
+
skill?: string[] | false;
|
|
40
|
+
progress?: boolean;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
const parseInlineConfig = (raw: string): InlineConfig => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
const config: InlineConfig = {};
|
|
45
|
+
for (const part of raw.split(",")) {
|
|
46
|
+
const trimmed = part.trim();
|
|
47
|
+
if (!trimmed) continue;
|
|
48
|
+
const eq = trimmed.indexOf("=");
|
|
49
|
+
if (eq === -1) {
|
|
50
|
+
if (trimmed === "progress") config.progress = true;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const key = trimmed.slice(0, eq).trim();
|
|
54
|
+
const val = trimmed.slice(eq + 1).trim();
|
|
55
|
+
switch (key) {
|
|
56
|
+
case "output":
|
|
57
|
+
config.output = val === "false" ? false : val;
|
|
58
|
+
break;
|
|
59
|
+
case "outputMode":
|
|
60
|
+
if (val === "inline" || val === "file-only") config.outputMode = val;
|
|
61
|
+
break;
|
|
62
|
+
case "reads":
|
|
63
|
+
config.reads = val === "false" ? false : val.split("+").filter(Boolean);
|
|
64
|
+
break;
|
|
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;
|
|
58
78
|
};
|
|
59
79
|
|
|
60
|
-
const parseAgentToken = (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
const parseAgentToken = (
|
|
81
|
+
token: string,
|
|
82
|
+
): { name: string; config: InlineConfig } => {
|
|
83
|
+
const bracket = token.indexOf("[");
|
|
84
|
+
if (bracket === -1) return { name: token, config: {} };
|
|
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
|
+
};
|
|
65
92
|
};
|
|
66
93
|
|
|
67
|
-
const extractExecutionFlags = (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
const extractExecutionFlags = (
|
|
95
|
+
rawArgs: string,
|
|
96
|
+
): { args: string; bg: boolean; fork: boolean } => {
|
|
97
|
+
let args = rawArgs.trim();
|
|
98
|
+
let bg = false;
|
|
99
|
+
let fork = false;
|
|
100
|
+
|
|
101
|
+
while (true) {
|
|
102
|
+
if (args.endsWith(" --bg") || args === "--bg") {
|
|
103
|
+
bg = true;
|
|
104
|
+
args = args === "--bg" ? "" : args.slice(0, -5).trim();
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (args.endsWith(" --fork") || args === "--fork") {
|
|
108
|
+
fork = true;
|
|
109
|
+
args = args === "--fork" ? "" : args.slice(0, -7).trim();
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return { args, bg, fork };
|
|
87
116
|
};
|
|
88
117
|
|
|
89
|
-
const makeAgentCompletions =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
const makeAgentCompletions =
|
|
119
|
+
(state: SubagentState, multiAgent: boolean) => (prefix: string) => {
|
|
120
|
+
if (!state.baseCwd) return null;
|
|
121
|
+
const agents = discoverAgents(state.baseCwd, "both").agents;
|
|
122
|
+
if (!multiAgent) {
|
|
123
|
+
if (prefix.includes(" ")) return null;
|
|
124
|
+
return agents
|
|
125
|
+
.filter((a) => a.name.startsWith(prefix))
|
|
126
|
+
.map((a) => ({ value: a.name, label: a.name }));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const lastArrow = prefix.lastIndexOf(" -> ");
|
|
130
|
+
const segment = lastArrow !== -1 ? prefix.slice(lastArrow + 4) : prefix;
|
|
131
|
+
if (
|
|
132
|
+
segment.includes(" -- ") ||
|
|
133
|
+
segment.includes('"') ||
|
|
134
|
+
segment.includes("'")
|
|
135
|
+
)
|
|
136
|
+
return null;
|
|
137
|
+
|
|
138
|
+
const lastWord = (prefix.match(/(\S*)$/) || ["", ""])[1];
|
|
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
|
+
};
|
|
110
152
|
|
|
111
153
|
const discoverSavedChains = (cwd: string): ChainConfig[] => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
154
|
+
const chainsByName = new Map<string, ChainConfig>();
|
|
155
|
+
for (const chain of discoverAgentsAll(cwd).chains) {
|
|
156
|
+
chainsByName.set(chain.name, chain);
|
|
157
|
+
}
|
|
158
|
+
return Array.from(chainsByName.values());
|
|
117
159
|
};
|
|
118
160
|
|
|
119
161
|
const makeChainCompletions = (state: SubagentState) => (prefix: string) => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
162
|
+
if (prefix.includes(" ") || !state.baseCwd) return null;
|
|
163
|
+
return discoverSavedChains(state.baseCwd)
|
|
164
|
+
.filter((chain) => chain.name.startsWith(prefix))
|
|
165
|
+
.map((chain) => ({ value: chain.name, label: chain.name }));
|
|
124
166
|
};
|
|
125
167
|
|
|
126
|
-
const mapSavedChainSteps = (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
168
|
+
const mapSavedChainSteps = (
|
|
169
|
+
chain: ChainConfig,
|
|
170
|
+
worktree = false,
|
|
171
|
+
): ChainStep[] => {
|
|
172
|
+
return (chain.steps as Array<ChainStep & { skills?: string[] | false }>).map(
|
|
173
|
+
(step) => {
|
|
174
|
+
if (isParallelStep(step))
|
|
175
|
+
return worktree ? { ...step, worktree: true } : { ...step };
|
|
176
|
+
return {
|
|
177
|
+
agent: step.agent,
|
|
178
|
+
task: step.task || undefined,
|
|
179
|
+
output: step.output,
|
|
180
|
+
outputMode: step.outputMode,
|
|
181
|
+
reads: step.reads,
|
|
182
|
+
progress: step.progress,
|
|
183
|
+
skill: step.skill ?? step.skills,
|
|
184
|
+
model: step.model,
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
);
|
|
140
188
|
};
|
|
141
189
|
|
|
142
190
|
async function requestSlashRun(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
191
|
+
pi: ExtensionAPI,
|
|
192
|
+
ctx: ExtensionContext,
|
|
193
|
+
requestId: string,
|
|
194
|
+
params: SubagentParamsLike,
|
|
147
195
|
): Promise<SlashSubagentResponse> {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
196
|
+
return new Promise((resolve, reject) => {
|
|
197
|
+
let done = false;
|
|
198
|
+
let started = false;
|
|
199
|
+
|
|
200
|
+
const startTimeoutMs = 15_000;
|
|
201
|
+
const startTimeout = setTimeout(() => {
|
|
202
|
+
finish(() =>
|
|
203
|
+
reject(
|
|
204
|
+
new Error(
|
|
205
|
+
"Slash subagent bridge did not start within 15s. Ensure the extension is loaded correctly.",
|
|
206
|
+
),
|
|
207
|
+
),
|
|
208
|
+
);
|
|
209
|
+
}, startTimeoutMs);
|
|
210
|
+
|
|
211
|
+
const onStarted = (data: unknown) => {
|
|
212
|
+
if (done || !data || typeof data !== "object") return;
|
|
213
|
+
if ((data as { requestId?: unknown }).requestId !== requestId) return;
|
|
214
|
+
started = true;
|
|
215
|
+
clearTimeout(startTimeout);
|
|
216
|
+
if (ctx.hasUI) ctx.ui.setStatus("subagent-slash", "running...");
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const onResponse = (data: unknown) => {
|
|
220
|
+
if (done || !data || typeof data !== "object") return;
|
|
221
|
+
const response = data as Partial<SlashSubagentResponse>;
|
|
222
|
+
if (response.requestId !== requestId) return;
|
|
223
|
+
clearTimeout(startTimeout);
|
|
224
|
+
finish(() => resolve(response as SlashSubagentResponse));
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const onUpdate = (data: unknown) => {
|
|
228
|
+
if (done || !data || typeof data !== "object") return;
|
|
229
|
+
const update = data as SlashSubagentUpdate;
|
|
230
|
+
if (update.requestId !== requestId) return;
|
|
231
|
+
applySlashUpdate(requestId, update);
|
|
232
|
+
if (!ctx.hasUI) return;
|
|
233
|
+
const tool = update.currentTool ? ` ${update.currentTool}` : "";
|
|
234
|
+
const count = update.toolCount ?? 0;
|
|
235
|
+
ctx.ui.setStatus(
|
|
236
|
+
"subagent-slash",
|
|
237
|
+
`${count} tools${tool} | ctrl+o live detail`,
|
|
238
|
+
);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const onTerminalInput = ctx.hasUI
|
|
242
|
+
? ctx.ui.onTerminalInput((input) => {
|
|
243
|
+
if (!matchesKey(input, Key.escape)) return undefined;
|
|
244
|
+
pi.events.emit(SLASH_SUBAGENT_CANCEL_EVENT, { requestId });
|
|
245
|
+
finish(() => reject(new Error("Cancelled")));
|
|
246
|
+
return { consume: true };
|
|
247
|
+
})
|
|
248
|
+
: undefined;
|
|
249
|
+
|
|
250
|
+
const unsubStarted = pi.events.on(SLASH_SUBAGENT_STARTED_EVENT, onStarted);
|
|
251
|
+
const unsubResponse = pi.events.on(
|
|
252
|
+
SLASH_SUBAGENT_RESPONSE_EVENT,
|
|
253
|
+
onResponse,
|
|
254
|
+
);
|
|
255
|
+
const unsubUpdate = pi.events.on(SLASH_SUBAGENT_UPDATE_EVENT, onUpdate);
|
|
256
|
+
|
|
257
|
+
const finish = (next: () => void) => {
|
|
258
|
+
if (done) return;
|
|
259
|
+
done = true;
|
|
260
|
+
clearTimeout(startTimeout);
|
|
261
|
+
unsubStarted();
|
|
262
|
+
unsubResponse();
|
|
263
|
+
unsubUpdate();
|
|
264
|
+
onTerminalInput?.();
|
|
265
|
+
next();
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
pi.events.emit(SLASH_SUBAGENT_REQUEST_EVENT, { requestId, params });
|
|
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
|
+
});
|
|
221
283
|
}
|
|
222
284
|
|
|
223
|
-
function extractSlashMessageText(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
285
|
+
function extractSlashMessageText(
|
|
286
|
+
content: string | Array<{ type?: string; text?: string }>,
|
|
287
|
+
): string {
|
|
288
|
+
if (typeof content === "string") return content;
|
|
289
|
+
if (!Array.isArray(content)) return "";
|
|
290
|
+
return content
|
|
291
|
+
.filter(
|
|
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");
|
|
230
297
|
}
|
|
231
298
|
|
|
232
299
|
function formatExportPathList(paths: string[]): string {
|
|
233
|
-
|
|
300
|
+
return paths.map((file) => `- \`${file}\``).join("\n");
|
|
234
301
|
}
|
|
235
302
|
|
|
236
|
-
function collectResultPaths(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
303
|
+
function collectResultPaths(
|
|
304
|
+
results: SingleResult[],
|
|
305
|
+
getPath: (result: SingleResult) => string | undefined,
|
|
306
|
+
): string[] {
|
|
307
|
+
return results
|
|
308
|
+
.map(getPath)
|
|
309
|
+
.filter(
|
|
310
|
+
(file): file is string => typeof file === "string" && file.length > 0,
|
|
311
|
+
);
|
|
240
312
|
}
|
|
241
313
|
|
|
242
314
|
function buildSlashExportText(response: SlashSubagentResponse): string {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
315
|
+
const output =
|
|
316
|
+
extractSlashMessageText(response.result.content) ||
|
|
317
|
+
response.errorText ||
|
|
318
|
+
"(no output)";
|
|
319
|
+
const results = response.result.details?.results ?? [];
|
|
320
|
+
const sessionFiles = collectResultPaths(
|
|
321
|
+
results,
|
|
322
|
+
(result) => result.sessionFile,
|
|
323
|
+
);
|
|
324
|
+
const savedOutputs = collectResultPaths(
|
|
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");
|
|
253
343
|
}
|
|
254
344
|
|
|
255
345
|
function persistSlashSessionSnapshot(ctx: ExtensionContext): void {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
346
|
+
try {
|
|
347
|
+
if (!ctx.sessionManager) return;
|
|
348
|
+
const sessionManager = ctx.sessionManager as typeof ctx.sessionManager & {
|
|
349
|
+
_rewriteFile?: () => void;
|
|
350
|
+
flushed?: boolean;
|
|
351
|
+
};
|
|
352
|
+
const sessionFile = sessionManager.getSessionFile();
|
|
353
|
+
if (!sessionFile || typeof sessionManager._rewriteFile !== "function")
|
|
354
|
+
return;
|
|
355
|
+
fs.mkdirSync(path.dirname(sessionFile), { recursive: true });
|
|
356
|
+
sessionManager._rewriteFile();
|
|
357
|
+
sessionManager.flushed = true;
|
|
358
|
+
} catch (error) {
|
|
359
|
+
console.error(
|
|
360
|
+
"Failed to persist slash session snapshot for export:",
|
|
361
|
+
error,
|
|
362
|
+
);
|
|
363
|
+
}
|
|
270
364
|
}
|
|
271
365
|
|
|
272
366
|
async function runSlashSubagent(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
367
|
+
pi: ExtensionAPI,
|
|
368
|
+
ctx: ExtensionContext,
|
|
369
|
+
params: SubagentParamsLike,
|
|
276
370
|
): Promise<void> {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
371
|
+
if (ctx.hasUI) ctx.ui.setToolsExpanded(false);
|
|
372
|
+
const requestId = randomUUID();
|
|
373
|
+
const initialDetails = buildSlashInitialResult(requestId, params);
|
|
374
|
+
const initialText =
|
|
375
|
+
extractSlashMessageText(initialDetails.result.content) ||
|
|
376
|
+
"Running subagent...";
|
|
377
|
+
pi.sendMessage({
|
|
378
|
+
customType: SLASH_RESULT_TYPE,
|
|
379
|
+
content: initialText,
|
|
380
|
+
display: true,
|
|
381
|
+
details: initialDetails,
|
|
382
|
+
});
|
|
383
|
+
persistSlashSessionSnapshot(ctx);
|
|
384
|
+
|
|
385
|
+
try {
|
|
386
|
+
const response = await requestSlashRun(pi, ctx, requestId, params);
|
|
387
|
+
const finalDetails = finalizeSlashResult(response);
|
|
388
|
+
pi.sendMessage({
|
|
389
|
+
customType: SLASH_RESULT_TYPE,
|
|
390
|
+
content: buildSlashExportText(response),
|
|
391
|
+
display: true,
|
|
392
|
+
details: finalDetails,
|
|
393
|
+
});
|
|
394
|
+
persistSlashSessionSnapshot(ctx);
|
|
395
|
+
if (ctx.hasUI) {
|
|
396
|
+
ctx.ui.setStatus("subagent-slash", undefined);
|
|
397
|
+
}
|
|
398
|
+
if (response.isError && ctx.hasUI) {
|
|
399
|
+
ctx.ui.notify(response.errorText || "Subagent failed", "error");
|
|
400
|
+
}
|
|
401
|
+
} catch (error) {
|
|
402
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
403
|
+
const failedDetails = failSlashResult(requestId, params, message);
|
|
404
|
+
pi.sendMessage({
|
|
405
|
+
customType: SLASH_RESULT_TYPE,
|
|
406
|
+
content: `## Subagent result\n\n${message}`,
|
|
407
|
+
display: true,
|
|
408
|
+
details: failedDetails,
|
|
409
|
+
});
|
|
410
|
+
persistSlashSessionSnapshot(ctx);
|
|
411
|
+
if (ctx.hasUI) {
|
|
412
|
+
ctx.ui.setStatus("subagent-slash", undefined);
|
|
413
|
+
}
|
|
414
|
+
if (message === "Cancelled") {
|
|
415
|
+
if (ctx.hasUI) ctx.ui.notify("Cancelled", "warning");
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (ctx.hasUI) ctx.ui.notify(message, "error");
|
|
419
|
+
}
|
|
324
420
|
}
|
|
325
421
|
|
|
326
|
-
|
|
327
|
-
|
|
422
|
+
interface ParsedStep {
|
|
423
|
+
name: string;
|
|
424
|
+
config: InlineConfig;
|
|
425
|
+
task?: string;
|
|
426
|
+
}
|
|
328
427
|
|
|
329
428
|
const parseAgentArgs = (
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
429
|
+
state: SubagentState,
|
|
430
|
+
args: string,
|
|
431
|
+
command: string,
|
|
432
|
+
ctx: ExtensionContext,
|
|
334
433
|
): { steps: ParsedStep[]; task: string } | null => {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
-
|
|
434
|
+
const input = args.trim();
|
|
435
|
+
const usage = `Usage: /${command} agent1 "task1" -> agent2 "task2"`;
|
|
436
|
+
let steps: ParsedStep[];
|
|
437
|
+
let sharedTask: string;
|
|
438
|
+
let perStep = false;
|
|
439
|
+
|
|
440
|
+
if (input.includes(" -> ")) {
|
|
441
|
+
perStep = true;
|
|
442
|
+
const segments = input.split(" -> ");
|
|
443
|
+
steps = [];
|
|
444
|
+
for (const seg of segments) {
|
|
445
|
+
const trimmed = seg.trim();
|
|
446
|
+
if (!trimmed) continue;
|
|
447
|
+
let agentPart: string;
|
|
448
|
+
let task: string | undefined;
|
|
449
|
+
const qMatch = trimmed.match(
|
|
450
|
+
/^(\S+(?:\[[^\]]*\])?)\s+(?:"([^"]*)"|'([^']*)')$/,
|
|
451
|
+
);
|
|
452
|
+
if (qMatch) {
|
|
453
|
+
agentPart = qMatch[1]!;
|
|
454
|
+
task = (qMatch[2] ?? qMatch[3]) || undefined;
|
|
455
|
+
} else {
|
|
456
|
+
const dashIdx = trimmed.indexOf(" -- ");
|
|
457
|
+
if (dashIdx !== -1) {
|
|
458
|
+
agentPart = trimmed.slice(0, dashIdx).trim();
|
|
459
|
+
task = trimmed.slice(dashIdx + 4).trim() || undefined;
|
|
460
|
+
} else {
|
|
461
|
+
agentPart = trimmed;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const parsed = parseAgentToken(agentPart);
|
|
465
|
+
steps.push({ ...parsed, task });
|
|
466
|
+
}
|
|
467
|
+
sharedTask = steps.find((s) => s.task)?.task ?? "";
|
|
468
|
+
} else {
|
|
469
|
+
const delimiterIndex = input.indexOf(" -- ");
|
|
470
|
+
if (delimiterIndex === -1) {
|
|
471
|
+
ctx.ui.notify(usage, "error");
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
const agentsPart = input.slice(0, delimiterIndex).trim();
|
|
475
|
+
sharedTask = input.slice(delimiterIndex + 4).trim();
|
|
476
|
+
if (!agentsPart || !sharedTask) {
|
|
477
|
+
ctx.ui.notify(usage, "error");
|
|
478
|
+
return null;
|
|
479
|
+
}
|
|
480
|
+
steps = agentsPart
|
|
481
|
+
.split(/\s+/)
|
|
482
|
+
.filter(Boolean)
|
|
483
|
+
.map((t) => parseAgentToken(t));
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (steps.length === 0) {
|
|
487
|
+
ctx.ui.notify(usage, "error");
|
|
488
|
+
return null;
|
|
489
|
+
}
|
|
490
|
+
if (!state.baseCwd) {
|
|
491
|
+
ctx.ui.notify("Subagent session cwd is not initialized yet", "error");
|
|
492
|
+
return null;
|
|
493
|
+
}
|
|
494
|
+
const agents = discoverAgents(state.baseCwd, "both").agents;
|
|
495
|
+
for (const step of steps) {
|
|
496
|
+
if (!agents.find((a) => a.name === step.name)) {
|
|
497
|
+
ctx.ui.notify(`Unknown agent: ${step.name}`, "error");
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (command === "chain" && !steps[0]?.task && (perStep || !sharedTask)) {
|
|
502
|
+
ctx.ui.notify(
|
|
503
|
+
`First step must have a task: /chain agent "task" -> agent2`,
|
|
504
|
+
"error",
|
|
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 };
|
|
406
513
|
};
|
|
407
514
|
|
|
408
515
|
export function registerSlashCommands(
|
|
409
|
-
|
|
410
|
-
|
|
516
|
+
pi: ExtensionAPI,
|
|
517
|
+
state: SubagentState,
|
|
411
518
|
): void {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
519
|
+
pi.registerCommand("run", {
|
|
520
|
+
description:
|
|
521
|
+
"Run a subagent directly: /run agent[output=file] [task] [--bg] [--fork]",
|
|
522
|
+
getArgumentCompletions: makeAgentCompletions(state, false),
|
|
523
|
+
handler: async (args, ctx) => {
|
|
524
|
+
const { args: cleanedArgs, bg, fork } = extractExecutionFlags(args);
|
|
525
|
+
const input = cleanedArgs.trim();
|
|
526
|
+
const firstSpace = input.indexOf(" ");
|
|
527
|
+
if (!input) {
|
|
528
|
+
ctx.ui.notify("Usage: /run <agent> [task] [--bg] [--fork]", "error");
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
const { name: agentName, config: inline } = parseAgentToken(
|
|
532
|
+
firstSpace === -1 ? input : input.slice(0, firstSpace),
|
|
533
|
+
);
|
|
534
|
+
const task = firstSpace === -1 ? "" : input.slice(firstSpace + 1).trim();
|
|
535
|
+
|
|
536
|
+
if (!state.baseCwd) {
|
|
537
|
+
ctx.ui.notify("Subagent session cwd is not initialized yet", "error");
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
const agents = discoverAgents(state.baseCwd, "both").agents;
|
|
541
|
+
if (!agents.find((a) => a.name === agentName)) {
|
|
542
|
+
ctx.ui.notify(`Unknown agent: ${agentName}`, "error");
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
let finalTask = task;
|
|
547
|
+
if (
|
|
548
|
+
inline.reads &&
|
|
549
|
+
Array.isArray(inline.reads) &&
|
|
550
|
+
inline.reads.length > 0
|
|
551
|
+
) {
|
|
552
|
+
finalTask = `[Read from: ${inline.reads.join(", ")}]\n\n${finalTask}`;
|
|
553
|
+
}
|
|
554
|
+
const params: SubagentParamsLike = {
|
|
555
|
+
agent: agentName,
|
|
556
|
+
task: finalTask,
|
|
557
|
+
clarify: false,
|
|
558
|
+
agentScope: "both",
|
|
559
|
+
};
|
|
560
|
+
if (inline.output !== undefined) params.output = inline.output;
|
|
561
|
+
if (inline.outputMode !== undefined)
|
|
562
|
+
params.outputMode = inline.outputMode;
|
|
563
|
+
if (inline.skill !== undefined) params.skill = inline.skill;
|
|
564
|
+
if (inline.model) params.model = inline.model;
|
|
565
|
+
if (bg) params.async = true;
|
|
566
|
+
if (fork) params.context = "fork";
|
|
567
|
+
await runSlashSubagent(pi, ctx, params);
|
|
568
|
+
},
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
pi.registerCommand("chain", {
|
|
572
|
+
description:
|
|
573
|
+
'Run agents in sequence: /chain scout "task" -> planner [--bg] [--fork]',
|
|
574
|
+
getArgumentCompletions: makeAgentCompletions(state, true),
|
|
575
|
+
handler: async (args, ctx) => {
|
|
576
|
+
const { args: cleanedArgs, bg, fork } = extractExecutionFlags(args);
|
|
577
|
+
const parsed = parseAgentArgs(state, cleanedArgs, "chain", ctx);
|
|
578
|
+
if (!parsed) return;
|
|
579
|
+
const chain = parsed.steps.map(({ name, config, task: stepTask }, i) => ({
|
|
580
|
+
agent: name,
|
|
581
|
+
...(stepTask
|
|
582
|
+
? { task: stepTask }
|
|
583
|
+
: i === 0 && parsed.task
|
|
584
|
+
? { task: parsed.task }
|
|
585
|
+
: {}),
|
|
586
|
+
...(config.output !== undefined ? { output: config.output } : {}),
|
|
587
|
+
...(config.outputMode !== undefined
|
|
588
|
+
? { outputMode: config.outputMode }
|
|
589
|
+
: {}),
|
|
590
|
+
...(config.reads !== undefined ? { reads: config.reads } : {}),
|
|
591
|
+
...(config.model ? { model: config.model } : {}),
|
|
592
|
+
...(config.skill !== undefined ? { skill: config.skill } : {}),
|
|
593
|
+
...(config.progress !== undefined ? { progress: config.progress } : {}),
|
|
594
|
+
}));
|
|
595
|
+
const params: SubagentParamsLike = {
|
|
596
|
+
chain,
|
|
597
|
+
task: parsed.task,
|
|
598
|
+
clarify: false,
|
|
599
|
+
agentScope: "both",
|
|
600
|
+
};
|
|
601
|
+
if (bg) params.async = true;
|
|
602
|
+
if (fork) params.context = "fork";
|
|
603
|
+
await runSlashSubagent(pi, ctx, params);
|
|
604
|
+
},
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
pi.registerCommand("run-chain", {
|
|
608
|
+
description:
|
|
609
|
+
"Run a saved chain: /run-chain chainName -- task [--bg] [--fork]",
|
|
610
|
+
getArgumentCompletions: makeChainCompletions(state),
|
|
611
|
+
handler: async (args, ctx) => {
|
|
612
|
+
const { args: cleanedArgs, bg, fork } = extractExecutionFlags(args);
|
|
613
|
+
const delimiterIndex = cleanedArgs.indexOf(" -- ");
|
|
614
|
+
const usage = "Usage: /run-chain <chainName> -- <task> [--bg] [--fork]";
|
|
615
|
+
if (delimiterIndex === -1) {
|
|
616
|
+
ctx.ui.notify(usage, "error");
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
const chainName = cleanedArgs.slice(0, delimiterIndex).trim();
|
|
620
|
+
const task = cleanedArgs.slice(delimiterIndex + 4).trim();
|
|
621
|
+
if (!chainName || !task) {
|
|
622
|
+
ctx.ui.notify(usage, "error");
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
if (!state.baseCwd) {
|
|
626
|
+
ctx.ui.notify("Subagent session cwd is not initialized yet", "error");
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
const chain = discoverSavedChains(state.baseCwd).find(
|
|
630
|
+
(candidate) => candidate.name === chainName,
|
|
631
|
+
);
|
|
632
|
+
if (!chain) {
|
|
633
|
+
ctx.ui.notify(`Unknown chain: ${chainName}`, "error");
|
|
634
|
+
return;
|
|
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
|
+
});
|
|
528
685
|
}
|