@selesai/code 0.2.1 → 0.3.1
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/dist/config.d.ts +4 -15
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -45
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +8 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/diagnostics.d.ts +1 -0
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/diagnostics.js.map +1 -1
- package/dist/core/model-registry.d.ts +4 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +101 -51
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/package-manager.d.ts +10 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +93 -8
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/package-manager.test.d.ts +2 -0
- package/dist/core/package-manager.test.d.ts.map +1 -0
- package/dist/core/package-manager.test.js +20 -0
- package/dist/core/package-manager.test.js.map +1 -0
- package/dist/core/resource-loader.d.ts +3 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +10 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/defaults/models.json +64 -113
- package/dist/extensions/caveman/caveman-instructions.cjs +39 -0
- package/dist/extensions/caveman/index.js +116 -0
- package/dist/extensions/caveman/package.json +8 -0
- package/dist/extensions/caveman/test/extension.test.js +185 -0
- package/dist/extensions/caveman/test/helpers.test.js +67 -0
- package/dist/extensions/copy-turn.ts +2 -2
- package/dist/extensions/pi-intercom/broker/broker.ts +2 -3
- package/dist/extensions/pi-intercom/broker/paths.ts +10 -5
- package/dist/extensions/pi-intercom/broker/spawn.ts +2 -3
- package/dist/extensions/pi-intercom/config.ts +2 -2
- package/dist/extensions/pi-intercom/index.ts +2 -2
- package/dist/extensions/pi-intercom/package.json +2 -2
- package/dist/extensions/pi-intercom/ui/compose.ts +3 -3
- package/dist/extensions/pi-intercom/ui/inline-message.ts +3 -3
- package/dist/extensions/pi-intercom/ui/session-list.ts +3 -3
- package/dist/extensions/pi-powerline-footer/bash-mode/editor.ts +2 -2
- package/dist/extensions/pi-powerline-footer/bash-mode/history.ts +2 -1
- package/dist/extensions/pi-powerline-footer/index.ts +40 -47
- package/dist/extensions/pi-powerline-footer/package.json +2 -2
- package/dist/extensions/pi-powerline-footer/tests/bash-mode.test.ts +10 -10
- package/dist/extensions/pi-powerline-footer/tests/jump-shortcuts.test.ts +1 -1
- package/dist/extensions/pi-powerline-footer/tests/working-vibes.test.ts +2 -2
- package/dist/extensions/pi-powerline-footer/theme.ts +6 -6
- package/dist/extensions/pi-powerline-footer/tps.ts +1 -1
- package/dist/extensions/pi-powerline-footer/types.ts +7 -7
- package/dist/extensions/pi-powerline-footer/welcome.ts +23 -16
- package/dist/extensions/pi-powerline-footer/working-vibes.ts +52 -59
- package/dist/extensions/pi-rewind-hook/index.ts +1 -1
- package/dist/extensions/pi-rewind-hook/package.json +1 -1
- package/dist/extensions/pi-subagents/README.md +224 -52
- package/dist/extensions/pi-subagents/agents/architect.md +188 -0
- package/dist/extensions/pi-subagents/agents/builder.md +120 -0
- package/dist/extensions/pi-subagents/agents/commentator.md +131 -0
- package/dist/extensions/pi-subagents/agents/explorer.md +51 -0
- package/dist/extensions/pi-subagents/agents/recapper.md +21 -0
- package/dist/extensions/pi-subagents/install.mjs +93 -0
- package/dist/extensions/pi-subagents/package.json +4 -5
- package/dist/extensions/pi-subagents/prompts/parallel-context-build.md +1 -1
- package/dist/extensions/pi-subagents/prompts/parallel-handoff-plan.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +76 -13
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +179 -2
- package/dist/extensions/pi-subagents/src/agents/agent-memory.ts +254 -0
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +11 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +193 -19
- package/dist/extensions/pi-subagents/src/agents/chain-serializer.ts +27 -2
- package/dist/extensions/pi-subagents/src/extension/config.ts +27 -4
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +1 -7
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +3 -2
- package/dist/extensions/pi-subagents/src/extension/index.ts +73 -71
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +369 -0
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +54 -10
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +200 -0
- package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +21 -253
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +519 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +195 -105
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +88 -2
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +67 -10
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +34 -4
- package/dist/extensions/pi-subagents/src/runs/background/completion-batcher.ts +166 -0
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +156 -1
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +515 -0
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +161 -44
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +1 -2
- package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +3 -2
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +167 -6
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +514 -0
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +28 -1
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +873 -204
- package/dist/extensions/pi-subagents/src/runs/background/wait.ts +353 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +123 -27
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +174 -70
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +569 -81
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +45 -22
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +2 -2
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +172 -21
- package/dist/extensions/pi-subagents/src/runs/shared/model-scope.ts +128 -0
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +89 -0
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +50 -1
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +35 -4
- package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +63 -45
- package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +125 -5
- package/dist/extensions/pi-subagents/src/runs/shared/tool-budget.ts +74 -0
- package/dist/extensions/pi-subagents/src/runs/shared/turn-budget.ts +52 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +28 -5
- package/dist/extensions/pi-subagents/src/shared/artifacts.ts +16 -1
- package/dist/extensions/pi-subagents/src/shared/atomic-json.ts +15 -2
- package/dist/extensions/pi-subagents/src/shared/child-transcript.ts +212 -0
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +133 -22
- package/dist/extensions/pi-subagents/src/shared/settings.ts +3 -1
- package/dist/extensions/pi-subagents/src/shared/types.ts +197 -4
- package/dist/extensions/pi-subagents/src/shared/utils.ts +108 -17
- package/dist/extensions/pi-subagents/src/slash/prompt-workflows.ts +330 -0
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +135 -4
- package/dist/extensions/pi-subagents/src/tui/render.ts +32 -12
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +94 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +2772 -0
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +1107 -0
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +463 -0
- package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +274 -0
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +1535 -0
- package/dist/extensions/pi-subagents/test/integration/detect-error.test.ts +242 -0
- package/dist/extensions/pi-subagents/test/integration/doctor-executor.test.ts +128 -0
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +252 -0
- package/dist/extensions/pi-subagents/test/integration/foreground-result-size.test.ts +188 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +1306 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +1033 -0
- package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +397 -0
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +583 -0
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +691 -0
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +892 -0
- package/dist/extensions/pi-subagents/test/integration/session-tokens.test.ts +62 -0
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +1824 -0
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +1284 -0
- package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +127 -0
- package/dist/extensions/pi-subagents/test/integration/template-resolution.test.ts +299 -0
- package/dist/extensions/pi-subagents/test/integration/top-level-async.test.ts +37 -0
- package/dist/extensions/pi-subagents/test/support/helpers.ts +189 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +335 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +129 -0
- package/dist/extensions/pi-subagents/test/support/real-session-child-cli.mjs +184 -0
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +285 -0
- package/dist/extensions/pi-subagents/test/support/register-loader.mjs +15 -0
- package/dist/extensions/pi-subagents/test/support/ts-loader.mjs +108 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +421 -0
- package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +213 -0
- package/dist/extensions/pi-subagents/test/unit/agent-eject-disable.test.ts +343 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +1199 -0
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +556 -0
- package/dist/extensions/pi-subagents/test/unit/agent-memory.test.ts +420 -0
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +579 -0
- package/dist/extensions/pi-subagents/test/unit/agent-scope.test.ts +20 -0
- package/dist/extensions/pi-subagents/test/unit/agent-selection.test.ts +88 -0
- package/dist/extensions/pi-subagents/test/unit/artifacts.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +86 -0
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +221 -0
- package/dist/extensions/pi-subagents/test/unit/async-permission-session.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +285 -0
- package/dist/extensions/pi-subagents/test/unit/atomic-json.test.ts +112 -0
- package/dist/extensions/pi-subagents/test/unit/chain-append.test.ts +206 -0
- package/dist/extensions/pi-subagents/test/unit/chain-root-attachment.test.ts +159 -0
- package/dist/extensions/pi-subagents/test/unit/chain-serializer.test.ts +229 -0
- package/dist/extensions/pi-subagents/test/unit/child-transcript.test.ts +225 -0
- package/dist/extensions/pi-subagents/test/unit/close-grace-timer.test.ts +101 -0
- package/dist/extensions/pi-subagents/test/unit/completion-batcher.test.ts +228 -0
- package/dist/extensions/pi-subagents/test/unit/completion-dedupe.test.ts +36 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +152 -0
- package/dist/extensions/pi-subagents/test/unit/config-dir-runtime.test.ts +72 -0
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +327 -0
- package/dist/extensions/pi-subagents/test/unit/control-notices.test.ts +161 -0
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +159 -0
- package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +217 -0
- package/dist/extensions/pi-subagents/test/unit/extra-agent-dirs.test.ts +88 -0
- package/dist/extensions/pi-subagents/test/unit/file-coalescer.test.ts +68 -0
- package/dist/extensions/pi-subagents/test/unit/foreground-tool-call-compaction.test.ts +78 -0
- package/dist/extensions/pi-subagents/test/unit/fork-context.test.ts +415 -0
- package/dist/extensions/pi-subagents/test/unit/get-final-output.test.ts +126 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +271 -0
- package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +173 -0
- package/dist/extensions/pi-subagents/test/unit/jsonl-writer.test.ts +119 -0
- package/dist/extensions/pi-subagents/test/unit/live-async-resume.test.ts +170 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +346 -0
- package/dist/extensions/pi-subagents/test/unit/model-info.test.ts +62 -0
- package/dist/extensions/pi-subagents/test/unit/model-scope-settings.test.ts +87 -0
- package/dist/extensions/pi-subagents/test/unit/model-scope.test.ts +145 -0
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +162 -0
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +470 -0
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +329 -0
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +319 -0
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +70 -0
- package/dist/extensions/pi-subagents/test/unit/parallel-utils.test.ts +247 -0
- package/dist/extensions/pi-subagents/test/unit/path-handling.test.ts +113 -0
- package/dist/extensions/pi-subagents/test/unit/path-resolution.test.ts +94 -0
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +803 -0
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +209 -0
- package/dist/extensions/pi-subagents/test/unit/pi-spawn.test.ts +238 -0
- package/dist/extensions/pi-subagents/test/unit/proactive-skills.test.ts +118 -0
- package/dist/extensions/pi-subagents/test/unit/profiles.test.ts +299 -0
- package/dist/extensions/pi-subagents/test/unit/prompt-template-bridge.test.ts +408 -0
- package/dist/extensions/pi-subagents/test/unit/prompt-workflows.test.ts +134 -0
- package/dist/extensions/pi-subagents/test/unit/recursion-guard.test.ts +257 -0
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +209 -0
- package/dist/extensions/pi-subagents/test/unit/result-intercom.test.ts +226 -0
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +294 -0
- package/dist/extensions/pi-subagents/test/unit/run-id-resolver.test.ts +147 -0
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +997 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +478 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +562 -0
- package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +213 -0
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +438 -0
- package/dist/extensions/pi-subagents/test/unit/slash-bridge.test.ts +54 -0
- package/dist/extensions/pi-subagents/test/unit/slash-chain-groups.test.ts +464 -0
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +255 -0
- package/dist/extensions/pi-subagents/test/unit/status-format.test.ts +19 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +245 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +517 -0
- package/dist/extensions/pi-subagents/test/unit/temp-paths.test.ts +72 -0
- package/dist/extensions/pi-subagents/test/unit/tool-budget.test.ts +52 -0
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +237 -0
- package/dist/extensions/pi-subagents/test/unit/total-cost.test.ts +60 -0
- package/dist/extensions/pi-subagents/test/unit/ts-loader.test.ts +33 -0
- package/dist/extensions/pi-subagents/test/unit/turn-budget.test.ts +202 -0
- package/dist/extensions/pi-subagents/test/unit/types-fork-preamble.test.ts +23 -0
- package/dist/extensions/pi-subagents/test/unit/wait.test.ts +398 -0
- package/dist/extensions/pi-subagents/test/unit/widget-nested-render.test.ts +88 -0
- package/dist/extensions/pi-subagents/test/unit/windows-hide-spawn.test.ts +26 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-graph.test.ts +134 -0
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +479 -0
- package/dist/extensions/pi-web-agent/package.json +2 -2
- package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +2 -2
- package/dist/extensions/pi-web-agent/src/changelog-notice.ts +5 -2
- package/dist/extensions/pi-web-agent/src/commands/web-agent-config.ts +1 -1
- package/dist/extensions/pi-web-agent/src/extension.ts +1 -1
- package/dist/extensions/pi-web-agent/src/presentation/config-store.ts +6 -4
- package/dist/extensions/question/helpers.ts +3 -3
- package/dist/extensions/question/index.ts +2 -2
- package/dist/extensions/question/navigation.ts +2 -2
- package/dist/extensions/question/package.json +2 -2
- package/dist/extensions/question/question-list.ts +2 -2
- package/dist/extensions/question/tests/question-list.test.ts +2 -2
- package/dist/extensions/question/tui-adapter.ts +2 -2
- package/dist/extensions/question/types.ts +2 -2
- package/dist/extensions/question/ui-protocol.ts +2 -2
- package/dist/extensions/rtk.ts +2 -2
- package/dist/extensions/tokenin-onboarding.ts +2 -2
- package/dist/extensions/undo.ts +1 -1
- package/dist/extensions/web-agent-onboarding.ts +3 -3
- package/dist/extensions/workflow/adapter.ts +16 -8
- package/dist/extensions/workflow/extension.ts +1 -1
- package/dist/extensions/workflow/package.json +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +4 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +2 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +19 -5
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/skills/caveman/SKILL.md +49 -0
- package/dist/skills/handoff-text/SKILL.md +13 -0
- package/dist/utils/thinking-tags.d.ts +7 -0
- package/dist/utils/thinking-tags.d.ts.map +1 -0
- package/dist/utils/thinking-tags.js +63 -0
- package/dist/utils/thinking-tags.js.map +1 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +2 -0
- package/docs/settings.md +15 -0
- package/docs/shared-host-extensions.md +109 -0
- package/package.json +2 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { registerSlashSubagentBridge } from "../../src/slash/slash-bridge.ts";
|
|
4
|
+
|
|
5
|
+
const REQUEST = "subagent:slash:request";
|
|
6
|
+
const RESPONSE = "subagent:slash:response";
|
|
7
|
+
|
|
8
|
+
function eventBus() {
|
|
9
|
+
const handlers = new Map<string, Array<(data: unknown) => void>>();
|
|
10
|
+
return {
|
|
11
|
+
on(event: string, handler: (data: unknown) => void) {
|
|
12
|
+
const list = handlers.get(event) ?? [];
|
|
13
|
+
list.push(handler);
|
|
14
|
+
handlers.set(event, list);
|
|
15
|
+
return () => handlers.set(event, (handlers.get(event) ?? []).filter((h) => h !== handler));
|
|
16
|
+
},
|
|
17
|
+
emit(event: string, data: unknown) {
|
|
18
|
+
for (const handler of handlers.get(event) ?? []) handler(data);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe("slash subagent bridge requester context", () => {
|
|
24
|
+
it("uses request ctx instead of stale fallback context when provided", async () => {
|
|
25
|
+
const events = eventBus();
|
|
26
|
+
const fallbackCtx = { cwd: "/fallback" } as any;
|
|
27
|
+
const requestCtx = { cwd: "/request" } as any;
|
|
28
|
+
let executedCtx: any;
|
|
29
|
+
|
|
30
|
+
registerSlashSubagentBridge({
|
|
31
|
+
events,
|
|
32
|
+
getContext: () => fallbackCtx,
|
|
33
|
+
execute: async (_id, _params, _signal, _onUpdate, ctx) => {
|
|
34
|
+
executedCtx = ctx;
|
|
35
|
+
return { content: [{ type: "text", text: "ok" }], details: { mode: "single", results: [] } } as any;
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const done = new Promise<void>((resolve, reject) => {
|
|
40
|
+
events.on(RESPONSE, (data: any) => {
|
|
41
|
+
try {
|
|
42
|
+
assert.equal(data.isError, false);
|
|
43
|
+
assert.equal(executedCtx, requestCtx);
|
|
44
|
+
resolve();
|
|
45
|
+
} catch (error) {
|
|
46
|
+
reject(error);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
events.emit(REQUEST, { requestId: "ctx-test", params: { action: "list" }, ctx: requestCtx });
|
|
52
|
+
await done;
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { after, before, describe, it } from "node:test";
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import * as os from "node:os";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import {
|
|
7
|
+
buildChainExpressionSteps,
|
|
8
|
+
hasGroupSyntax,
|
|
9
|
+
PARALLEL_GROUP_USAGE,
|
|
10
|
+
parseChainExpression,
|
|
11
|
+
parseGroupSegment,
|
|
12
|
+
parseSingleTaskToken,
|
|
13
|
+
SlashParseError,
|
|
14
|
+
} from "../../src/slash/slash-commands.ts";
|
|
15
|
+
|
|
16
|
+
function makeCtx(notifications: string[]): {
|
|
17
|
+
ui: { notify: (message: string, level?: string) => void };
|
|
18
|
+
} {
|
|
19
|
+
return {
|
|
20
|
+
ui: {
|
|
21
|
+
notify: (message: string) => {
|
|
22
|
+
notifications.push(message);
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function makeState(cwd: string) {
|
|
29
|
+
return {
|
|
30
|
+
baseCwd: cwd,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let tempRoot: string;
|
|
35
|
+
|
|
36
|
+
before(() => {
|
|
37
|
+
tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "pi-slash-chain-test-"));
|
|
38
|
+
fs.mkdirSync(path.join(tempRoot, ".selesai", "agents"), { recursive: true });
|
|
39
|
+
const agentsDir = path.join(tempRoot, ".selesai", "agents");
|
|
40
|
+
const writeAgent = (name: string) => {
|
|
41
|
+
fs.writeFileSync(
|
|
42
|
+
path.join(agentsDir, `${name}.md`),
|
|
43
|
+
`---\nname: ${name}\ndescription: ${name}\n---\nBody\n`,
|
|
44
|
+
"utf-8",
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
for (const name of ["scout", "reviewer", "writer", "unknown"]) {
|
|
48
|
+
writeAgent(name);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
after(() => {
|
|
53
|
+
fs.rmSync(tempRoot, { recursive: true, force: true });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe("parseSingleTaskToken", () => {
|
|
57
|
+
it("parses a quoted task", () => {
|
|
58
|
+
const parsed = parseSingleTaskToken('reviewer "review auth module"');
|
|
59
|
+
assert.equal(parsed.kind, "step");
|
|
60
|
+
assert.equal(parsed.name, "reviewer");
|
|
61
|
+
assert.equal(parsed.task, "review auth module");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("parses an agent with inline config and no task", () => {
|
|
65
|
+
const parsed = parseSingleTaskToken(
|
|
66
|
+
"scout[output=ctx.md,outputMode=file-only]",
|
|
67
|
+
);
|
|
68
|
+
assert.equal(parsed.kind, "step");
|
|
69
|
+
assert.equal(parsed.name, "scout");
|
|
70
|
+
assert.equal(parsed.config.output, "ctx.md");
|
|
71
|
+
assert.equal(parsed.config.outputMode, "file-only");
|
|
72
|
+
assert.equal(parsed.task, undefined);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("parses a task via -- delimiter", () => {
|
|
76
|
+
const parsed = parseSingleTaskToken("reviewer -- Review {previous}");
|
|
77
|
+
assert.equal(parsed.kind, "step");
|
|
78
|
+
assert.equal(parsed.name, "reviewer");
|
|
79
|
+
assert.equal(parsed.task, "Review {previous}");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("parses extended metadata in inline config", () => {
|
|
83
|
+
const parsed = parseSingleTaskToken(
|
|
84
|
+
'reviewer[as=rev,label=Review,phase=p1,cwd=sub,count=3,acceptance=checked] "task"',
|
|
85
|
+
);
|
|
86
|
+
assert.equal(parsed.config.as, "rev");
|
|
87
|
+
assert.equal(parsed.config.label, "Review");
|
|
88
|
+
assert.equal(parsed.config.phase, "p1");
|
|
89
|
+
assert.equal(parsed.config.cwd, "sub");
|
|
90
|
+
assert.equal(parsed.config.count, 3);
|
|
91
|
+
assert.equal(parsed.config.acceptance, "checked");
|
|
92
|
+
assert.equal(parsed.task, "task");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("ignores a non-positive count", () => {
|
|
96
|
+
assert.equal(parseSingleTaskToken("scout[count=0]").config.count, undefined);
|
|
97
|
+
assert.equal(parseSingleTaskToken("scout[count=x]").config.count, undefined);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe("parseGroupSegment", () => {
|
|
102
|
+
it("parses a static parallel group with two quoted tasks", () => {
|
|
103
|
+
const parsed = parseGroupSegment('(reviewer "A" | reviewer "B")');
|
|
104
|
+
assert.equal(parsed.kind, "group");
|
|
105
|
+
assert.equal(parsed.tasks.length, 2);
|
|
106
|
+
assert.equal(parsed.tasks[0]?.name, "reviewer");
|
|
107
|
+
assert.equal(parsed.tasks[0]?.task, "A");
|
|
108
|
+
assert.equal(parsed.tasks[1]?.task, "B");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("rejects groups with a single task", () => {
|
|
112
|
+
assert.throws(
|
|
113
|
+
() => parseGroupSegment('(reviewer "A")'),
|
|
114
|
+
(error: unknown) => error instanceof SlashParseError,
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("rejects groups with unbalanced parentheses", () => {
|
|
119
|
+
assert.throws(
|
|
120
|
+
() => parseGroupSegment('(reviewer "A"'),
|
|
121
|
+
(error: unknown) => error instanceof SlashParseError,
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("parses a trailing group-options suffix", () => {
|
|
126
|
+
const parsed = parseGroupSegment('(reviewer "A" | reviewer "B")[concurrency=2,failFast,worktree]');
|
|
127
|
+
assert.equal(parsed.tasks.length, 2);
|
|
128
|
+
assert.equal(parsed.config.concurrency, 2);
|
|
129
|
+
assert.equal(parsed.config.failFast, true);
|
|
130
|
+
assert.equal(parsed.config.worktree, true);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("defaults to an empty group config without a suffix", () => {
|
|
134
|
+
assert.deepEqual(parseGroupSegment('(a "x" | b "y")').config, {});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("rejects a non-bracketed group suffix", () => {
|
|
138
|
+
assert.throws(
|
|
139
|
+
() => parseGroupSegment('(a "x" | b "y") concurrency=2'),
|
|
140
|
+
(error: unknown) => error instanceof SlashParseError,
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe("hasGroupSyntax", () => {
|
|
146
|
+
it("detects parentheses", () => {
|
|
147
|
+
assert.equal(hasGroupSyntax("a -> (b | c)"), true);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("does not treat a bare pipe as group syntax", () => {
|
|
151
|
+
assert.equal(hasGroupSyntax("a -> b | c"), false);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("ignores parens inside quotes", () => {
|
|
155
|
+
assert.equal(hasGroupSyntax('a -> b "with (paren) inside"'), false);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("returns false for plain chain input", () => {
|
|
159
|
+
assert.equal(hasGroupSyntax("scout -> reviewer"), false);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("does not treat unquoted parens inside a -- task as group syntax", () => {
|
|
163
|
+
// Regression: a shared-task command must stay on the legacy path even when the
|
|
164
|
+
// task text contains bare parentheses. A group is a *step* that opens with `(`.
|
|
165
|
+
assert.equal(hasGroupSyntax("scout -- inspect auth (backend)"), false);
|
|
166
|
+
assert.equal(hasGroupSyntax("scout -- inspect (auth) -> writer"), false);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("still detects a group that opens a step", () => {
|
|
170
|
+
assert.equal(hasGroupSyntax('scout "x" -> (a "y" | b "z")'), true);
|
|
171
|
+
assert.equal(hasGroupSyntax('(a "y" | b "z") -> writer'), true);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
describe("parseChainExpression", () => {
|
|
176
|
+
it("parses sequential + group + sequential", () => {
|
|
177
|
+
const expression = parseChainExpression(
|
|
178
|
+
'scout "scan" -> (reviewer "A" | reviewer "B") -> writer "fix"',
|
|
179
|
+
);
|
|
180
|
+
assert.equal(expression.steps.length, 3);
|
|
181
|
+
const group = expression.steps[1];
|
|
182
|
+
assert.ok(group);
|
|
183
|
+
assert.equal(group.kind, "group");
|
|
184
|
+
if (group.kind === "group") {
|
|
185
|
+
assert.equal(group.tasks.length, 2);
|
|
186
|
+
}
|
|
187
|
+
assert.equal(expression.steps[0]?.kind, "step");
|
|
188
|
+
assert.equal((expression.steps[0] as { name: string }).name, "scout");
|
|
189
|
+
assert.equal((expression.steps[2] as { name: string }).name, "writer");
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it("rejects expression without arrows", () => {
|
|
193
|
+
assert.throws(
|
|
194
|
+
() => parseChainExpression('(reviewer "A" | reviewer "B")'),
|
|
195
|
+
(error: unknown) =>
|
|
196
|
+
error instanceof SlashParseError && error.message.includes("->"),
|
|
197
|
+
);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("rejects groups with one task", () => {
|
|
201
|
+
assert.throws(
|
|
202
|
+
() => parseChainExpression('scout "scan" -> (reviewer "A")'),
|
|
203
|
+
(error: unknown) => error instanceof SlashParseError,
|
|
204
|
+
);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("respects quotes when splitting on arrows", () => {
|
|
208
|
+
const expression = parseChainExpression(
|
|
209
|
+
'scout "scan -> quick" -> reviewer "Review"',
|
|
210
|
+
);
|
|
211
|
+
assert.equal(expression.steps.length, 2);
|
|
212
|
+
assert.equal(
|
|
213
|
+
(expression.steps[0] as { task: string }).task,
|
|
214
|
+
"scan -> quick",
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("allows balanced parens in a -- task after a group", () => {
|
|
219
|
+
const expression = parseChainExpression(
|
|
220
|
+
'scout "scan" -> (reviewer "A" | reviewer "B") -> writer -- fix (backend)',
|
|
221
|
+
);
|
|
222
|
+
assert.equal(expression.steps.length, 3);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it("still rejects truly unmatched parens in a non-group segment", () => {
|
|
226
|
+
assert.throws(
|
|
227
|
+
() => parseChainExpression('scout "scan" -> (reviewer "A" | reviewer "B") -> writer -- fix (backend'),
|
|
228
|
+
(error: unknown) =>
|
|
229
|
+
error instanceof SlashParseError && error.message.includes("Unmatched parentheses"),
|
|
230
|
+
);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
describe("buildChainExpressionSteps", () => {
|
|
235
|
+
it("emits a chain with a { parallel: [...] } step for groups", () => {
|
|
236
|
+
const notifications: string[] = [];
|
|
237
|
+
const built = buildChainExpressionSteps(
|
|
238
|
+
makeState(tempRoot) as never,
|
|
239
|
+
'scout "scan" -> (reviewer "A" | reviewer "B") -> writer "fix"',
|
|
240
|
+
makeCtx(notifications) as never,
|
|
241
|
+
);
|
|
242
|
+
assert.ok(built, "should build a chain");
|
|
243
|
+
if (!built) return;
|
|
244
|
+
assert.deepEqual(notifications, []);
|
|
245
|
+
assert.equal(built.chain.length, 3);
|
|
246
|
+
assert.equal(
|
|
247
|
+
built.chain[0] && "agent" in built.chain[0]
|
|
248
|
+
? built.chain[0].agent
|
|
249
|
+
: undefined,
|
|
250
|
+
"scout",
|
|
251
|
+
);
|
|
252
|
+
assert.equal(
|
|
253
|
+
built.chain[1] && "parallel" in built.chain[1]
|
|
254
|
+
? built.chain[1].parallel.length
|
|
255
|
+
: undefined,
|
|
256
|
+
2,
|
|
257
|
+
);
|
|
258
|
+
assert.equal(
|
|
259
|
+
built.chain[2] && "agent" in built.chain[2]
|
|
260
|
+
? built.chain[2].agent
|
|
261
|
+
: undefined,
|
|
262
|
+
"writer",
|
|
263
|
+
);
|
|
264
|
+
assert.equal(built.task, "scan");
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it("preserves backward-compatible linear chain behavior", () => {
|
|
268
|
+
const notifications: string[] = [];
|
|
269
|
+
const built = buildChainExpressionSteps(
|
|
270
|
+
makeState(tempRoot) as never,
|
|
271
|
+
'scout "scan" -> reviewer "review"',
|
|
272
|
+
makeCtx(notifications) as never,
|
|
273
|
+
);
|
|
274
|
+
assert.ok(built);
|
|
275
|
+
if (!built) return;
|
|
276
|
+
assert.equal(built.chain.length, 2);
|
|
277
|
+
assert.equal(built.task, "scan");
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it("falls back to shared task when first step has no task", () => {
|
|
281
|
+
const notifications: string[] = [];
|
|
282
|
+
const built = buildChainExpressionSteps(
|
|
283
|
+
makeState(tempRoot) as never,
|
|
284
|
+
"scout -> reviewer",
|
|
285
|
+
makeCtx(notifications) as never,
|
|
286
|
+
);
|
|
287
|
+
assert.equal(built, null);
|
|
288
|
+
assert.ok(
|
|
289
|
+
notifications.some((message) => /task/i.test(message)),
|
|
290
|
+
`notifications: ${notifications.join(" | ")}`,
|
|
291
|
+
);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it("reports parallel group errors as notifications", () => {
|
|
295
|
+
const notifications: string[] = [];
|
|
296
|
+
const built = buildChainExpressionSteps(
|
|
297
|
+
makeState(tempRoot) as never,
|
|
298
|
+
'scout "scan" -> (reviewer "A")',
|
|
299
|
+
makeCtx(notifications) as never,
|
|
300
|
+
);
|
|
301
|
+
assert.equal(built, null);
|
|
302
|
+
assert.equal(notifications.length, 1);
|
|
303
|
+
assert.match(notifications[0] ?? "", /at least two/i);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it("propagates inline metadata onto chain steps", () => {
|
|
307
|
+
const notifications: string[] = [];
|
|
308
|
+
const built = buildChainExpressionSteps(
|
|
309
|
+
makeState(tempRoot) as never,
|
|
310
|
+
'scout[as=ctx,label=Scan,phase=recon] "scan" -> reviewer "review"',
|
|
311
|
+
makeCtx(notifications) as never,
|
|
312
|
+
);
|
|
313
|
+
assert.ok(built);
|
|
314
|
+
if (!built) return;
|
|
315
|
+
assert.deepEqual(notifications, []);
|
|
316
|
+
const first = built.chain[0] as Record<string, unknown>;
|
|
317
|
+
assert.equal(first.as, "ctx");
|
|
318
|
+
assert.equal(first.label, "Scan");
|
|
319
|
+
assert.equal(first.phase, "recon");
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it("applies count only inside a parallel group", () => {
|
|
323
|
+
const notifications: string[] = [];
|
|
324
|
+
const built = buildChainExpressionSteps(
|
|
325
|
+
makeState(tempRoot) as never,
|
|
326
|
+
'scout[count=2] "scan" -> (reviewer[count=3] "A" | writer "B")',
|
|
327
|
+
makeCtx(notifications) as never,
|
|
328
|
+
);
|
|
329
|
+
assert.ok(built);
|
|
330
|
+
if (!built) return;
|
|
331
|
+
assert.deepEqual(notifications, []);
|
|
332
|
+
// sequential first step: count ignored
|
|
333
|
+
assert.equal((built.chain[0] as Record<string, unknown>).count, undefined);
|
|
334
|
+
const parallel = (built.chain[1] as { parallel: Array<Record<string, unknown>> }).parallel;
|
|
335
|
+
assert.equal(parallel[0]?.count, 3);
|
|
336
|
+
assert.equal(parallel[1]?.count, undefined);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it("propagates group-level options onto the parallel step", () => {
|
|
340
|
+
const notifications: string[] = [];
|
|
341
|
+
const built = buildChainExpressionSteps(
|
|
342
|
+
makeState(tempRoot) as never,
|
|
343
|
+
'scout "scan" -> (reviewer "A" | writer "B")[concurrency=2,failFast]',
|
|
344
|
+
makeCtx(notifications) as never,
|
|
345
|
+
);
|
|
346
|
+
assert.ok(built);
|
|
347
|
+
if (!built) return;
|
|
348
|
+
assert.deepEqual(notifications, []);
|
|
349
|
+
const group = built.chain[1] as Record<string, unknown>;
|
|
350
|
+
assert.equal(group.concurrency, 2);
|
|
351
|
+
assert.equal(group.failFast, true);
|
|
352
|
+
assert.equal(group.worktree, undefined);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it("rejects an invalid acceptance level", () => {
|
|
356
|
+
const notifications: string[] = [];
|
|
357
|
+
const built = buildChainExpressionSteps(
|
|
358
|
+
makeState(tempRoot) as never,
|
|
359
|
+
'scout[acceptance=bogus] "scan" -> reviewer "review"',
|
|
360
|
+
makeCtx(notifications) as never,
|
|
361
|
+
);
|
|
362
|
+
assert.equal(built, null);
|
|
363
|
+
assert.equal(notifications.length, 1);
|
|
364
|
+
assert.match(notifications[0] ?? "", /acceptance/i);
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it("rejects inline acceptance levels that require object contracts", () => {
|
|
368
|
+
const notifications: string[] = [];
|
|
369
|
+
const built = buildChainExpressionSteps(
|
|
370
|
+
makeState(tempRoot) as never,
|
|
371
|
+
'scout[acceptance=verified] "scan" -> reviewer "review"',
|
|
372
|
+
makeCtx(notifications) as never,
|
|
373
|
+
);
|
|
374
|
+
assert.equal(built, null);
|
|
375
|
+
assert.equal(notifications.length, 1);
|
|
376
|
+
assert.match(notifications[0] ?? "", /supports auto, attested, or checked/);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it("loads an inline outputSchema path and rejects a missing one", () => {
|
|
380
|
+
fs.writeFileSync(
|
|
381
|
+
path.join(tempRoot, "schema.json"),
|
|
382
|
+
JSON.stringify({ type: "object" }),
|
|
383
|
+
"utf-8",
|
|
384
|
+
);
|
|
385
|
+
const ok: string[] = [];
|
|
386
|
+
const built = buildChainExpressionSteps(
|
|
387
|
+
makeState(tempRoot) as never,
|
|
388
|
+
'scout[outputSchema=schema.json] "scan" -> reviewer "review"',
|
|
389
|
+
makeCtx(ok) as never,
|
|
390
|
+
);
|
|
391
|
+
assert.ok(built);
|
|
392
|
+
if (built) {
|
|
393
|
+
assert.deepEqual((built.chain[0] as Record<string, unknown>).outputSchema, { type: "object" });
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const missing: string[] = [];
|
|
397
|
+
const bad = buildChainExpressionSteps(
|
|
398
|
+
makeState(tempRoot) as never,
|
|
399
|
+
'scout[outputSchema=nope.json] "scan" -> reviewer "review"',
|
|
400
|
+
makeCtx(missing) as never,
|
|
401
|
+
);
|
|
402
|
+
assert.equal(bad, null);
|
|
403
|
+
assert.equal(missing.length, 1);
|
|
404
|
+
assert.match(missing[0] ?? "", /outputSchema/i);
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
it("keeps a bare pipe in a -- task on the legacy single-agent path", () => {
|
|
408
|
+
const notifications: string[] = [];
|
|
409
|
+
const built = buildChainExpressionSteps(
|
|
410
|
+
makeState(tempRoot) as never,
|
|
411
|
+
"scout -- do x | y",
|
|
412
|
+
makeCtx(notifications) as never,
|
|
413
|
+
);
|
|
414
|
+
assert.ok(built);
|
|
415
|
+
if (!built) return;
|
|
416
|
+
assert.deepEqual(notifications, []);
|
|
417
|
+
assert.equal(built.chain.length, 1);
|
|
418
|
+
assert.equal(built.task, "do x | y");
|
|
419
|
+
assert.equal(
|
|
420
|
+
built.chain[0] && "task" in built.chain[0] ? built.chain[0].task : undefined,
|
|
421
|
+
"do x | y",
|
|
422
|
+
);
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
it("keeps unquoted parens in a -- task on the legacy single-agent path", () => {
|
|
426
|
+
// Regression: `/chain scout -- inspect auth (backend)` was wrongly rejected as a
|
|
427
|
+
// malformed group. Bare parens in the shared task must parse as plain task text.
|
|
428
|
+
const notifications: string[] = [];
|
|
429
|
+
const built = buildChainExpressionSteps(
|
|
430
|
+
makeState(tempRoot) as never,
|
|
431
|
+
"scout -- inspect auth (backend)",
|
|
432
|
+
makeCtx(notifications) as never,
|
|
433
|
+
);
|
|
434
|
+
assert.ok(built);
|
|
435
|
+
if (!built) return;
|
|
436
|
+
assert.deepEqual(notifications, []);
|
|
437
|
+
assert.equal(built.chain.length, 1);
|
|
438
|
+
assert.equal(built.task, "inspect auth (backend)");
|
|
439
|
+
assert.equal(
|
|
440
|
+
built.chain[0] && "task" in built.chain[0] ? built.chain[0].task : undefined,
|
|
441
|
+
"inspect auth (backend)",
|
|
442
|
+
);
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
it("allows balanced parens in a -- task after a group step", () => {
|
|
446
|
+
const notifications: string[] = [];
|
|
447
|
+
const built = buildChainExpressionSteps(
|
|
448
|
+
makeState(tempRoot) as never,
|
|
449
|
+
'scout "scan" -> (reviewer "A" | reviewer "B") -> writer -- fix (backend)',
|
|
450
|
+
makeCtx(notifications) as never,
|
|
451
|
+
);
|
|
452
|
+
assert.ok(built);
|
|
453
|
+
if (!built) return;
|
|
454
|
+
assert.deepEqual(notifications, []);
|
|
455
|
+
assert.equal(built.chain.length, 3);
|
|
456
|
+
assert.equal(built.task, "scan");
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
it("exports a stable parallel group usage hint", () => {
|
|
460
|
+
assert.match(PARALLEL_GROUP_USAGE, /Usage: \/chain/);
|
|
461
|
+
assert.match(PARALLEL_GROUP_USAGE, /\(/);
|
|
462
|
+
assert.match(PARALLEL_GROUP_USAGE, /\|/);
|
|
463
|
+
});
|
|
464
|
+
});
|