@selesai/code 0.5.19 → 0.5.21
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/extensions/handoff-new.test.ts +8 -9
- package/dist/extensions/handoff-new.ts +6 -8
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +31 -0
- package/dist/extensions/pi-intercom/broker/spawn.ts +5 -3
- package/dist/extensions/pi-subagents/CHANGELOG.md +1367 -0
- package/dist/extensions/pi-subagents/README.md +602 -220
- package/dist/extensions/pi-subagents/banner.png +0 -0
- package/dist/extensions/pi-subagents/index.ts +1 -0
- package/dist/extensions/pi-subagents/install.mjs +3 -3
- package/dist/extensions/pi-subagents/package-lock.json +3405 -0
- package/dist/extensions/pi-subagents/package.json +26 -14
- package/dist/extensions/pi-subagents/prompts/gather-context-and-clarify.md +1 -1
- package/dist/extensions/pi-subagents/prompts/parallel-cleanup.md +9 -9
- package/dist/extensions/pi-subagents/prompts/parallel-context-build.md +3 -3
- package/dist/extensions/pi-subagents/prompts/parallel-handoff-plan.md +7 -7
- package/dist/extensions/pi-subagents/prompts/parallel-research.md +6 -6
- package/dist/extensions/pi-subagents/prompts/parallel-review.md +8 -8
- package/dist/extensions/pi-subagents/prompts/review-loop.md +13 -11
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +267 -176
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +89 -16
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +19 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +218 -120
- package/dist/extensions/pi-subagents/src/agents/frontmatter.ts +67 -13
- package/dist/extensions/pi-subagents/src/agents/proactive-skills.ts +2 -2
- package/dist/extensions/pi-subagents/src/agents/skills.ts +25 -12
- package/dist/extensions/pi-subagents/src/api/background-work.ts +197 -0
- package/dist/extensions/pi-subagents/src/api/capability-ceiling.ts +17 -0
- package/dist/extensions/pi-subagents/src/api/delegation.ts +285 -0
- package/dist/extensions/pi-subagents/src/api/preflight.ts +399 -0
- package/dist/extensions/pi-subagents/src/extension/chain-validation.ts +165 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +7 -1
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +15 -0
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +3 -1
- package/dist/extensions/pi-subagents/src/extension/index.ts +113 -157
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +41 -4
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +45 -15
- package/dist/extensions/pi-subagents/src/extension/steering-notices.ts +35 -0
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +28 -15
- package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +4 -3
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +225 -29
- package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +11 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +8 -10
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +452 -62
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +60 -9
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +198 -52
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +119 -21
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +67 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +16 -8
- package/dist/extensions/pi-subagents/src/runs/background/completion-batcher.ts +6 -4
- package/dist/extensions/pi-subagents/src/runs/background/completion-dedupe.ts +2 -11
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +260 -13
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +32 -6
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +171 -90
- package/dist/extensions/pi-subagents/src/runs/background/process-terminal.ts +280 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +149 -88
- package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +14 -2
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +33 -17
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +9 -1
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +38 -10
- package/dist/extensions/pi-subagents/src/runs/background/steering.ts +237 -0
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +1297 -307
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +610 -0
- package/dist/extensions/pi-subagents/src/runs/background/top-level-async.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/background/wait-config.ts +36 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +26 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +230 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +22 -6
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +228 -140
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +452 -138
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +90 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +1001 -416
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +443 -132
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +38 -0
- package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +178 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +121 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +41 -93
- package/dist/extensions/pi-subagents/src/runs/shared/context-mode.ts +44 -0
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +11 -9
- package/dist/extensions/pi-subagents/src/runs/shared/long-running-guard.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +12 -6
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +36 -0
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +44 -7
- package/dist/extensions/pi-subagents/src/runs/shared/nested-render.ts +4 -1
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +154 -0
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +18 -0
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +174 -54
- package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +38 -31
- package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +90 -5
- package/dist/extensions/pi-subagents/src/runs/shared/session-lease.ts +299 -0
- package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +61 -6
- package/dist/extensions/pi-subagents/src/runs/shared/spawn-budget.ts +128 -0
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +112 -7
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +14 -6
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +149 -36
- package/dist/extensions/pi-subagents/src/runs/shared/task-intent.ts +181 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +83 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-budget.ts +11 -5
- package/dist/extensions/pi-subagents/src/runs/shared/turn-budget.ts +50 -4
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +63 -14
- package/dist/extensions/pi-subagents/src/shared/accessible-dir.ts +25 -0
- package/dist/extensions/pi-subagents/src/shared/artifacts.ts +37 -7
- package/dist/extensions/pi-subagents/src/shared/atomic-json.ts +18 -43
- package/dist/extensions/pi-subagents/src/shared/child-transcript.ts +52 -0
- package/dist/extensions/pi-subagents/src/shared/env.ts +16 -0
- package/dist/extensions/pi-subagents/src/shared/file-system-retry.ts +47 -0
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +28 -3
- package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +123 -0
- package/dist/extensions/pi-subagents/src/shared/model-info.ts +8 -5
- package/dist/extensions/pi-subagents/src/shared/settings.ts +9 -1
- package/dist/extensions/pi-subagents/src/shared/status-format.ts +7 -1
- package/dist/extensions/pi-subagents/src/shared/types.ts +522 -51
- package/dist/extensions/pi-subagents/src/shared/utils.ts +59 -53
- package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +604 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-json.ts +108 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-request.ts +249 -0
- package/dist/extensions/pi-subagents/src/slash/prompt-template-bridge.ts +353 -345
- package/dist/extensions/pi-subagents/src/slash/prompt-workflows.ts +2 -2
- package/dist/extensions/pi-subagents/src/slash/selector.ts +147 -0
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +265 -23
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +2 -2
- package/dist/extensions/pi-subagents/src/slash/subagents-admin.ts +428 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +362 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-transcript.ts +472 -0
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +664 -0
- package/dist/extensions/pi-subagents/src/tui/render.ts +115 -31
- package/dist/extensions/pi-subagents/src/watchdog/change-signature.ts +220 -0
- package/dist/extensions/pi-subagents/src/watchdog/child-status.ts +205 -0
- package/dist/extensions/pi-subagents/src/watchdog/emission-guard.ts +123 -0
- package/dist/extensions/pi-subagents/src/watchdog/lsp-diagnostics.ts +532 -0
- package/dist/extensions/pi-subagents/src/watchdog/model-selection.ts +167 -0
- package/dist/extensions/pi-subagents/src/watchdog/register-child.ts +117 -0
- package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +433 -0
- package/dist/extensions/pi-subagents/src/watchdog/render.ts +54 -0
- package/dist/extensions/pi-subagents/src/watchdog/review.ts +298 -0
- package/dist/extensions/pi-subagents/src/watchdog/runtime.ts +714 -0
- package/dist/extensions/pi-subagents/src/watchdog/settings.ts +528 -0
- package/dist/extensions/pi-subagents/src/watchdog/tool-actions.ts +155 -0
- package/dist/extensions/pi-subagents/src/watchdog/turn-delta.ts +161 -0
- package/dist/extensions/pi-subagents/src/watchdog/types.ts +188 -0
- package/dist/extensions/pi-subagents/src/watchdog/warning-format.ts +73 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +130 -2
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +439 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +1632 -61
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +54 -1
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +112 -0
- package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +98 -1
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +179 -9
- package/dist/extensions/pi-subagents/test/integration/detect-error.test.ts +16 -9
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +6 -5
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +589 -9
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +528 -21
- package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +227 -3
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +235 -7
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +172 -2
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +1502 -18
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +993 -4
- package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/integration/top-level-async.test.ts +7 -1
- package/dist/extensions/pi-subagents/test/support/helpers.ts +32 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +59 -2
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +32 -6
- package/dist/extensions/pi-subagents/test/support/real-session-child-cli.mjs +25 -24
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +59 -35
- package/dist/extensions/pi-subagents/test/support/session-lease-child.mjs +42 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +703 -69
- package/dist/extensions/pi-subagents/test/unit/accessible-dir.test.ts +82 -0
- package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +15 -15
- package/dist/extensions/pi-subagents/test/unit/agent-eject-disable.test.ts +66 -66
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +478 -19
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +228 -7
- package/dist/extensions/pi-subagents/test/unit/agent-memory.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +198 -78
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +15 -1
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +102 -7
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +439 -6
- package/dist/extensions/pi-subagents/test/unit/atomic-json.test.ts +41 -1
- package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +79 -0
- package/dist/extensions/pi-subagents/test/unit/background-work.test.ts +285 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-pi-args.test.ts +84 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +68 -0
- package/dist/extensions/pi-subagents/test/unit/chain-validation.test.ts +326 -0
- package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +82 -0
- package/dist/extensions/pi-subagents/test/unit/child-transcript.test.ts +46 -4
- package/dist/extensions/pi-subagents/test/unit/completion-batcher.test.ts +3 -1
- package/dist/extensions/pi-subagents/test/unit/completion-dedupe.test.ts +9 -17
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +175 -3
- package/dist/extensions/pi-subagents/test/unit/config-dir-runtime.test.ts +10 -5
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +126 -6
- package/dist/extensions/pi-subagents/test/unit/default-extensions.test.ts +219 -0
- package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +913 -0
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +13 -2
- package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +351 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-transcript.test.ts +280 -0
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +575 -0
- package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +65 -0
- package/dist/extensions/pi-subagents/test/unit/fork-context.test.ts +94 -1
- package/dist/extensions/pi-subagents/test/unit/get-final-output.test.ts +23 -0
- package/dist/extensions/pi-subagents/test/unit/host-peer-runtime-imports.test.ts +157 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +367 -5
- package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +11 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +36 -0
- package/dist/extensions/pi-subagents/test/unit/model-info.test.ts +25 -3
- package/dist/extensions/pi-subagents/test/unit/model-scope.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +341 -10
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +16 -0
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +52 -0
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +168 -7
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +85 -7
- package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +175 -0
- package/dist/extensions/pi-subagents/test/unit/path-resolution.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +243 -16
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +79 -36
- package/dist/extensions/pi-subagents/test/unit/pi-spawn.test.ts +174 -56
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +322 -0
- package/dist/extensions/pi-subagents/test/unit/process-terminal.test.ts +204 -0
- package/dist/extensions/pi-subagents/test/unit/recursion-guard.test.ts +20 -12
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +117 -4
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +40 -7
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +48 -1
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +21 -3
- package/dist/extensions/pi-subagents/test/unit/selector.test.ts +57 -0
- package/dist/extensions/pi-subagents/test/unit/session-lease.test.ts +326 -0
- package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +101 -2
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +111 -1
- package/dist/extensions/pi-subagents/test/unit/spawn-budget.test.ts +124 -0
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +6 -4
- package/dist/extensions/pi-subagents/test/unit/status-format.test.ts +7 -0
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +397 -0
- package/dist/extensions/pi-subagents/test/unit/steering-notices.test.ts +58 -0
- package/dist/extensions/pi-subagents/test/unit/steering.test.ts +173 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +25 -4
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +390 -25
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +837 -0
- package/dist/extensions/pi-subagents/test/unit/task-intent.test.ts +86 -0
- package/dist/extensions/pi-subagents/test/unit/tool-budget.test.ts +15 -0
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +47 -1
- package/dist/extensions/pi-subagents/test/unit/turn-budget.test.ts +56 -10
- package/dist/extensions/pi-subagents/test/unit/watchdog-change-signature.test.ts +387 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-child-status.test.ts +110 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-emission-guard.test.ts +62 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-lsp-diagnostics.test.ts +144 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-model-selection.test.ts +121 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-render.test.ts +76 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-review.test.ts +327 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-runtime.test.ts +863 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-settings.test.ts +290 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-tool-actions.test.ts +91 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-turn-delta.test.ts +130 -0
- package/dist/extensions/pi-subagents/test/unit/widget-nested-render.test.ts +32 -4
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +5 -1
- package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +30 -0
- package/dist/extensions/question/batch.ts +39 -0
- package/dist/extensions/question/dialog-adapter.ts +23 -1
- package/dist/extensions/question/index.ts +237 -7
- package/dist/extensions/question/schemas.ts +28 -15
- package/dist/extensions/question/tests/batch.test.ts +26 -0
- package/dist/extensions/question/tests/ui-protocol.test.ts +23 -3
- package/dist/extensions/question/tui-adapter.ts +2 -3
- package/dist/extensions/question/types.ts +37 -0
- package/dist/extensions/question/ui-protocol.ts +3 -3
- package/dist/skills/batch-grill-me/SKILL.md +3 -1
- package/package.json +2 -1
|
@@ -51,6 +51,14 @@ describe("buildDoctorReport", () => {
|
|
|
51
51
|
it("formats a bounded successful environment summary", () => {
|
|
52
52
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), "pi-doctor-success-"));
|
|
53
53
|
try {
|
|
54
|
+
const state = makeState(root);
|
|
55
|
+
state.subagentSpawns = {
|
|
56
|
+
sessionId: "session-abc123",
|
|
57
|
+
count: 3,
|
|
58
|
+
configuredLimit: 4,
|
|
59
|
+
granted: 1,
|
|
60
|
+
grantHistory: [{ sessionId: "session-abc123", amount: 1, grantedAt: 0, previousLimit: 4, limit: 5 }],
|
|
61
|
+
};
|
|
54
62
|
const paths = {
|
|
55
63
|
tempRootDir: path.join(root, "temp-root"),
|
|
56
64
|
asyncDir: path.join(root, "async"),
|
|
@@ -61,8 +69,8 @@ describe("buildDoctorReport", () => {
|
|
|
61
69
|
|
|
62
70
|
const report = buildDoctorReport({
|
|
63
71
|
cwd: root,
|
|
64
|
-
config: { defaultSessionDir: "~/subagent-sessions", intercomBridge: { mode: "always" } },
|
|
65
|
-
state
|
|
72
|
+
config: { defaultSessionDir: "~/subagent-sessions", intercomBridge: { mode: "always" }, maxSubagentSpawnsPerSession: 4 },
|
|
73
|
+
state,
|
|
66
74
|
currentSessionFile: path.join(root, "sessions", "parent.jsonl"),
|
|
67
75
|
currentSessionId: "session-abc123",
|
|
68
76
|
orchestratorTarget: "subagent-chat-abc123",
|
|
@@ -105,6 +113,9 @@ describe("buildDoctorReport", () => {
|
|
|
105
113
|
assert.match(report, /- temp root: ok /);
|
|
106
114
|
assert.match(report, /- agents: total 4 \(builtin 1, package 0, user 1, project 2\)/);
|
|
107
115
|
assert.match(report, /- chains: total 2 \(builtin 0, package 0, user 1, project 1\)/);
|
|
116
|
+
assert.match(report, /Spawn budget\n- usage: 3\/5 used, 2 remaining \(configured 4; granted 1; grant allowance 3\)/);
|
|
117
|
+
assert.match(report, /- recent grants: \+1 at 1970-01-01T00:00:00\.000Z \(4 → 5\)/);
|
|
118
|
+
assert.match(report, /new parent session resets usage and grants; compaction does not/);
|
|
108
119
|
assert.match(report, /- skills: total 2 \(project 1, user-package 1\)/);
|
|
109
120
|
assert.match(report, /- bridge: active/);
|
|
110
121
|
assert.match(report, /- supervisor channel: available \(native:pi-subagents-supervisor-channel\)/);
|
|
@@ -190,7 +190,7 @@ describe("dynamic fanout helpers", () => {
|
|
|
190
190
|
], {}, { priorOutputNames: ["targets"], startStepIndex: 2 }));
|
|
191
191
|
});
|
|
192
192
|
|
|
193
|
-
it("collects ordered child result records and validates aggregate schema", () => {
|
|
193
|
+
it("collects ordered child result records and validates aggregate schema", async () => {
|
|
194
194
|
const step: ChainStep = {
|
|
195
195
|
expand: { from: { output: "targets", path: "/items" }, key: "/path", maxItems: 4 },
|
|
196
196
|
parallel: { agent: "reviewer", task: "Review {item.path}" },
|
|
@@ -211,7 +211,7 @@ describe("dynamic fanout helpers", () => {
|
|
|
211
211
|
assert.deepEqual(collected.map((item) => item.key), ["src/a.ts", "src/b.ts"]);
|
|
212
212
|
assert.deepEqual(collected.map((item) => item.structured), [{ ok: "a" }, { ok: "b" }]);
|
|
213
213
|
assert.equal(collected[1]?.timedOut, true);
|
|
214
|
-
assert.
|
|
215
|
-
assert.
|
|
214
|
+
await assert.doesNotReject(validateDynamicCollection({ type: "array", minItems: 2 }, collected));
|
|
215
|
+
await assert.rejects(validateDynamicCollection({ type: "object" }, collected), DynamicFanoutError);
|
|
216
216
|
});
|
|
217
217
|
});
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { Editor, visibleWidth } from "@earendil-works/pi-tui";
|
|
4
|
+
import type { ExtensionContext } from "@selesai/code";
|
|
5
|
+
import type { SubagentState } from "../../src/shared/types.ts";
|
|
6
|
+
import { collectFleetSnapshot } from "../../src/tui/fleet.ts";
|
|
7
|
+
import {
|
|
8
|
+
FLEET_STATUS_WIDGET_KEY,
|
|
9
|
+
SubagentFleetStatus,
|
|
10
|
+
collectFleetStatusEntries,
|
|
11
|
+
formatFleetElapsed,
|
|
12
|
+
formatFleetTokens,
|
|
13
|
+
} from "../../src/tui/fleet-status.ts";
|
|
14
|
+
|
|
15
|
+
function stateForTest(): SubagentState {
|
|
16
|
+
return {
|
|
17
|
+
baseCwd: process.cwd(),
|
|
18
|
+
currentSessionId: "session-current",
|
|
19
|
+
asyncJobs: new Map(),
|
|
20
|
+
fleetJobs: new Map(),
|
|
21
|
+
foregroundRuns: new Map(),
|
|
22
|
+
foregroundControls: new Map(),
|
|
23
|
+
lastForegroundControlId: null,
|
|
24
|
+
cleanupTimers: new Map(),
|
|
25
|
+
lastUiContext: null,
|
|
26
|
+
poller: null,
|
|
27
|
+
completionSeen: new Map(),
|
|
28
|
+
watcher: null,
|
|
29
|
+
watcherRestartTimer: null,
|
|
30
|
+
resultFileCoalescer: { schedule: () => false, clear: () => {} },
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const theme = {
|
|
35
|
+
fg: (_name: string, text: string) => text,
|
|
36
|
+
bg: (_name: string, text: string) => text,
|
|
37
|
+
bold: (text: string) => text,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
describe("below-editor subagent FleetView", () => {
|
|
41
|
+
it("formats elapsed time and token counts like the Claude Code fleet", () => {
|
|
42
|
+
assert.equal(formatFleetElapsed(10_600), "11s");
|
|
43
|
+
assert.equal(formatFleetTokens(999), "↓ 999 tokens");
|
|
44
|
+
assert.equal(formatFleetTokens(13_100), "↓ 13.1k tokens");
|
|
45
|
+
assert.equal(formatFleetTokens(1_250_000), "↓ 1.3M tokens");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("renders main plus active children below the editor and bounds every line", () => {
|
|
49
|
+
const state = stateForTest();
|
|
50
|
+
const now = Date.now();
|
|
51
|
+
for (let index = 0; index < 7; index++) {
|
|
52
|
+
state.foregroundControls.set(`run-${index}`, {
|
|
53
|
+
runId: `run-${index}`,
|
|
54
|
+
mode: "single",
|
|
55
|
+
startedAt: now - 11_000 + index,
|
|
56
|
+
updatedAt: now,
|
|
57
|
+
currentAgent: `worker-${index}`,
|
|
58
|
+
description: index === 0 ? "Inspect\nmodule 0" : `Inspect module ${index}`,
|
|
59
|
+
tokens: index === 0 ? 13_100 : index,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let widgetFactory: ((tui: unknown, theme: typeof theme) => { render(width: number): string[] }) | undefined;
|
|
64
|
+
const ctx = {
|
|
65
|
+
hasUI: true,
|
|
66
|
+
ui: {
|
|
67
|
+
setWidget(key: string, content: typeof widgetFactory | undefined, options?: { placement?: string }) {
|
|
68
|
+
assert.equal(key, FLEET_STATUS_WIDGET_KEY);
|
|
69
|
+
if (content) {
|
|
70
|
+
assert.equal(options?.placement, "belowEditor");
|
|
71
|
+
widgetFactory = content;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
onTerminalInput() { return () => {}; },
|
|
75
|
+
getEditorText() { return ""; },
|
|
76
|
+
requestRender() {},
|
|
77
|
+
notify() {},
|
|
78
|
+
theme,
|
|
79
|
+
},
|
|
80
|
+
} as unknown as ExtensionContext;
|
|
81
|
+
const fleet = new SubagentFleetStatus(state, () => {}, { refreshMs: 60_000 });
|
|
82
|
+
try {
|
|
83
|
+
fleet.setContext(ctx);
|
|
84
|
+
assert.ok(widgetFactory);
|
|
85
|
+
const component = widgetFactory!({ requestRender() {} }, theme);
|
|
86
|
+
const lines = component.render(80);
|
|
87
|
+
assert.ok(lines.some((line) => line.includes("⏺ main")));
|
|
88
|
+
assert.ok(lines.some((line) => line.includes("worker-0") && line.includes("Inspect module 0")));
|
|
89
|
+
assert.ok(lines.some((line) => line.includes("11s · ↓ 13.1k tokens")));
|
|
90
|
+
assert.ok(lines.some((line) => line.includes("↓ 2 more")));
|
|
91
|
+
for (const line of lines) assert.ok(visibleWidth(line) <= 80, `line exceeded width: ${line}`);
|
|
92
|
+
} finally {
|
|
93
|
+
fleet.dispose();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("keeps widget ownership through invalidation so an empty refresh removes it", () => {
|
|
98
|
+
const state = stateForTest();
|
|
99
|
+
state.foregroundControls.set("run-worker", {
|
|
100
|
+
runId: "run-worker",
|
|
101
|
+
mode: "single",
|
|
102
|
+
startedAt: 10,
|
|
103
|
+
updatedAt: 20,
|
|
104
|
+
currentAgent: "worker",
|
|
105
|
+
});
|
|
106
|
+
let widgetFactory: ((tui: unknown, theme: typeof theme) => { render(width: number): string[]; invalidate(): void }) | undefined;
|
|
107
|
+
let removals = 0;
|
|
108
|
+
const ctx = {
|
|
109
|
+
hasUI: true,
|
|
110
|
+
ui: {
|
|
111
|
+
setWidget(_key: string, content: typeof widgetFactory | undefined) {
|
|
112
|
+
if (content) widgetFactory = content;
|
|
113
|
+
else removals++;
|
|
114
|
+
},
|
|
115
|
+
onTerminalInput() { return () => {}; },
|
|
116
|
+
getEditorText() { return ""; },
|
|
117
|
+
requestRender() {},
|
|
118
|
+
notify() {},
|
|
119
|
+
theme,
|
|
120
|
+
},
|
|
121
|
+
} as unknown as ExtensionContext;
|
|
122
|
+
const fleet = new SubagentFleetStatus(state, () => {}, { refreshMs: 60_000 });
|
|
123
|
+
try {
|
|
124
|
+
fleet.setContext(ctx);
|
|
125
|
+
const component = widgetFactory!({ requestRender() {} }, theme);
|
|
126
|
+
component.invalidate();
|
|
127
|
+
state.foregroundControls.clear();
|
|
128
|
+
fleet.refresh();
|
|
129
|
+
assert.equal(removals, 1);
|
|
130
|
+
} finally {
|
|
131
|
+
fleet.dispose();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("removes the dynamic widget while the fleet inspector owns the viewport", () => {
|
|
136
|
+
const state = stateForTest();
|
|
137
|
+
state.foregroundControls.set("run-worker", {
|
|
138
|
+
runId: "run-worker",
|
|
139
|
+
mode: "single",
|
|
140
|
+
startedAt: 10,
|
|
141
|
+
updatedAt: 20,
|
|
142
|
+
currentAgent: "worker",
|
|
143
|
+
});
|
|
144
|
+
const registrations: string[] = [];
|
|
145
|
+
const ctx = {
|
|
146
|
+
hasUI: true,
|
|
147
|
+
ui: {
|
|
148
|
+
setWidget(_key: string, content: unknown) {
|
|
149
|
+
registrations.push(content ? "shown" : "hidden");
|
|
150
|
+
},
|
|
151
|
+
onTerminalInput() { return () => {}; },
|
|
152
|
+
getEditorText() { return ""; },
|
|
153
|
+
requestRender() {},
|
|
154
|
+
notify() {},
|
|
155
|
+
theme,
|
|
156
|
+
},
|
|
157
|
+
} as unknown as ExtensionContext;
|
|
158
|
+
const fleet = new SubagentFleetStatus(state, () => {}, { refreshMs: 60_000 });
|
|
159
|
+
try {
|
|
160
|
+
fleet.setContext(ctx);
|
|
161
|
+
state.fleetInspectorOpen = true;
|
|
162
|
+
fleet.refresh();
|
|
163
|
+
state.fleetInspectorOpen = false;
|
|
164
|
+
fleet.refresh();
|
|
165
|
+
assert.deepEqual(registrations, ["shown", "hidden", "shown"]);
|
|
166
|
+
} finally {
|
|
167
|
+
fleet.dispose();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("shows only the current sequential chain step while retaining active parallel siblings", () => {
|
|
172
|
+
const state = stateForTest();
|
|
173
|
+
state.asyncJobs.set("sequential", {
|
|
174
|
+
asyncId: "sequential",
|
|
175
|
+
asyncDir: "/tmp/sequential",
|
|
176
|
+
status: "running",
|
|
177
|
+
mode: "chain",
|
|
178
|
+
currentStep: 1,
|
|
179
|
+
startedAt: 50,
|
|
180
|
+
updatedAt: 200,
|
|
181
|
+
steps: [
|
|
182
|
+
{ agent: "scout", index: 0, status: "complete" },
|
|
183
|
+
{ agent: "worker", index: 1, status: "running" },
|
|
184
|
+
{ agent: "reviewer", index: 2, status: "pending" },
|
|
185
|
+
],
|
|
186
|
+
});
|
|
187
|
+
state.asyncJobs.set("parallel-group", {
|
|
188
|
+
asyncId: "parallel-group",
|
|
189
|
+
asyncDir: "/tmp/parallel-group",
|
|
190
|
+
status: "running",
|
|
191
|
+
mode: "chain",
|
|
192
|
+
currentStep: 3,
|
|
193
|
+
activeParallelGroup: true,
|
|
194
|
+
startedAt: 100,
|
|
195
|
+
updatedAt: 200,
|
|
196
|
+
steps: [
|
|
197
|
+
{ agent: "reviewer", index: 3, status: "running" },
|
|
198
|
+
{ agent: "tester", index: 4, status: "pending" },
|
|
199
|
+
],
|
|
200
|
+
});
|
|
201
|
+
assert.deepEqual(collectFleetStatusEntries(state).map((entry) => entry.key), [
|
|
202
|
+
"async:sequential:1",
|
|
203
|
+
"async:parallel-group:3",
|
|
204
|
+
"async:parallel-group:4",
|
|
205
|
+
]);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("shows every active foreground parallel child", () => {
|
|
209
|
+
const state = stateForTest();
|
|
210
|
+
state.foregroundControls.set("parallel", {
|
|
211
|
+
runId: "parallel",
|
|
212
|
+
mode: "parallel",
|
|
213
|
+
startedAt: 10,
|
|
214
|
+
updatedAt: 30,
|
|
215
|
+
activeChildren: new Map([
|
|
216
|
+
[0, { index: 0, agent: "reviewer", description: "Review correctness", startedAt: 11, updatedAt: 21, tokens: 100 }],
|
|
217
|
+
[1, { index: 1, agent: "reviewer", description: "Review quality", startedAt: 12, updatedAt: 22, tokens: 200 }],
|
|
218
|
+
[2, { index: 2, agent: "reviewer", description: "Review tests", startedAt: 13, updatedAt: 23, tokens: 300 }],
|
|
219
|
+
]),
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
const entries = collectFleetStatusEntries(state);
|
|
223
|
+
assert.deepEqual(entries.map((entry) => entry.key), [
|
|
224
|
+
"foreground-active:parallel:0",
|
|
225
|
+
"foreground-active:parallel:1",
|
|
226
|
+
"foreground-active:parallel:2",
|
|
227
|
+
]);
|
|
228
|
+
assert.deepEqual(entries.map((entry) => entry.description), ["Review correctness", "Review quality", "Review tests"]);
|
|
229
|
+
assert.deepEqual(collectFleetSnapshot(state).items.map((item) => item.key), entries.map((entry) => entry.key));
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("uses the same item keys as the full inspector", () => {
|
|
233
|
+
const state = stateForTest();
|
|
234
|
+
state.foregroundControls.set("foreground", {
|
|
235
|
+
runId: "foreground",
|
|
236
|
+
mode: "single",
|
|
237
|
+
startedAt: 10,
|
|
238
|
+
updatedAt: 20,
|
|
239
|
+
currentAgent: "worker",
|
|
240
|
+
currentIndex: 2,
|
|
241
|
+
});
|
|
242
|
+
const asyncJob = {
|
|
243
|
+
asyncId: "background",
|
|
244
|
+
asyncDir: "/tmp/background",
|
|
245
|
+
sessionId: "session-current",
|
|
246
|
+
status: "running" as const,
|
|
247
|
+
mode: "single" as const,
|
|
248
|
+
startedAt: 10,
|
|
249
|
+
updatedAt: 20,
|
|
250
|
+
steps: [{ agent: "reviewer", index: 0, status: "running" as const }],
|
|
251
|
+
};
|
|
252
|
+
state.asyncJobs.set(asyncJob.asyncId, asyncJob);
|
|
253
|
+
state.fleetJobs!.set(asyncJob.asyncId, asyncJob);
|
|
254
|
+
|
|
255
|
+
const statusKeys = collectFleetStatusEntries(state).map((entry) => entry.key).sort();
|
|
256
|
+
const inspectorKeys = collectFleetSnapshot(state).items.map((item) => item.key).sort();
|
|
257
|
+
assert.deepEqual(statusKeys, inspectorKeys);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("uses tracked async task descriptions and per-child token totals", () => {
|
|
261
|
+
const state = stateForTest();
|
|
262
|
+
state.asyncJobs.set("async-run", {
|
|
263
|
+
asyncId: "async-run",
|
|
264
|
+
asyncDir: "/tmp/async-run",
|
|
265
|
+
status: "running",
|
|
266
|
+
mode: "parallel",
|
|
267
|
+
description: "Review the authentication changes",
|
|
268
|
+
startedAt: 100,
|
|
269
|
+
updatedAt: 200,
|
|
270
|
+
steps: [
|
|
271
|
+
{ agent: "reviewer", index: 0, status: "running", startedAt: 120, tokens: { input: 4_000, output: 200, total: 4_200 } },
|
|
272
|
+
{ agent: "worker", index: 1, status: "complete", tokens: { input: 100, output: 20, total: 120 } },
|
|
273
|
+
],
|
|
274
|
+
});
|
|
275
|
+
const fleet = new SubagentFleetStatus(state, () => {}, { refreshMs: 60_000 });
|
|
276
|
+
let widgetFactory: ((tui: unknown, theme: typeof theme) => { render(width: number): string[] }) | undefined;
|
|
277
|
+
const ctx = {
|
|
278
|
+
hasUI: true,
|
|
279
|
+
ui: {
|
|
280
|
+
setWidget(_key: string, content: typeof widgetFactory | undefined) { if (content) widgetFactory = content; },
|
|
281
|
+
onTerminalInput() { return () => {}; },
|
|
282
|
+
getEditorText() { return ""; },
|
|
283
|
+
requestRender() {},
|
|
284
|
+
notify() {},
|
|
285
|
+
theme,
|
|
286
|
+
},
|
|
287
|
+
} as unknown as ExtensionContext;
|
|
288
|
+
try {
|
|
289
|
+
fleet.setContext(ctx);
|
|
290
|
+
const lines = widgetFactory!({ requestRender() {} }, theme).render(100);
|
|
291
|
+
assert.ok(lines.some((line) => line.includes("reviewer") && line.includes("Review the authentication changes")));
|
|
292
|
+
assert.ok(lines.some((line) => line.includes("↓ 4.2k tokens")));
|
|
293
|
+
assert.ok(!lines.some((line) => line.includes("worker")), "completed async children should leave the status fleet");
|
|
294
|
+
} finally {
|
|
295
|
+
fleet.dispose();
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it("only captures navigation at an empty editor and opens the selected child", async () => {
|
|
300
|
+
const state = stateForTest();
|
|
301
|
+
state.foregroundControls.set("run-worker", {
|
|
302
|
+
runId: "run-worker",
|
|
303
|
+
mode: "single",
|
|
304
|
+
startedAt: Date.now() - 1_000,
|
|
305
|
+
updatedAt: Date.now(),
|
|
306
|
+
currentAgent: "worker",
|
|
307
|
+
description: "Implement FleetView",
|
|
308
|
+
});
|
|
309
|
+
let editorText = "draft";
|
|
310
|
+
let inputHandler: ((data: string) => { consume?: boolean } | undefined) | undefined;
|
|
311
|
+
let widgetFactory: ((tui: unknown, theme: typeof theme) => { render(width: number): string[] }) | undefined;
|
|
312
|
+
const opened: string[] = [];
|
|
313
|
+
const ctx = {
|
|
314
|
+
hasUI: true,
|
|
315
|
+
ui: {
|
|
316
|
+
setWidget(_key: string, content: typeof widgetFactory | undefined) { if (content) widgetFactory = content; },
|
|
317
|
+
onTerminalInput(handler: typeof inputHandler) { inputHandler = handler; return () => { inputHandler = undefined; }; },
|
|
318
|
+
getEditorText() { return editorText; },
|
|
319
|
+
requestRender() {},
|
|
320
|
+
notify() {},
|
|
321
|
+
theme,
|
|
322
|
+
},
|
|
323
|
+
} as unknown as ExtensionContext;
|
|
324
|
+
const fleet = new SubagentFleetStatus(state, async (key) => { opened.push(key); }, { refreshMs: 60_000 });
|
|
325
|
+
try {
|
|
326
|
+
fleet.setContext(ctx);
|
|
327
|
+
assert.ok(inputHandler);
|
|
328
|
+
assert.ok(widgetFactory);
|
|
329
|
+
const tui = { requestRender() {}, focusedComponent: Object.create(Editor.prototype) as Editor };
|
|
330
|
+
const component = widgetFactory!(tui, theme);
|
|
331
|
+
|
|
332
|
+
assert.equal(inputHandler!("\x1b[B"), undefined, "non-empty editor should retain Down");
|
|
333
|
+
editorText = "";
|
|
334
|
+
tui.focusedComponent = {} as Editor;
|
|
335
|
+
assert.equal(inputHandler!("\x1b[B"), undefined, "non-editor focus should retain Down");
|
|
336
|
+
tui.focusedComponent = Object.create(Editor.prototype) as Editor;
|
|
337
|
+
assert.deepEqual(inputHandler!("\x1b[B"), { consume: true });
|
|
338
|
+
assert.deepEqual(inputHandler!("\x1b[B"), { consume: true });
|
|
339
|
+
assert.ok(component.render(100).some((line) => line.includes("⏺ worker")));
|
|
340
|
+
assert.deepEqual(inputHandler!("\r"), { consume: true });
|
|
341
|
+
await Promise.resolve();
|
|
342
|
+
assert.deepEqual(opened, ["foreground-active:run-worker:0"]);
|
|
343
|
+
await new Promise<void>((resolve) => setImmediate(resolve));
|
|
344
|
+
widgetFactory!(tui, theme);
|
|
345
|
+
assert.deepEqual(inputHandler!("\x1b"), { consume: true });
|
|
346
|
+
assert.ok(component.render(100).some((line) => line.includes("⏺ main")));
|
|
347
|
+
} finally {
|
|
348
|
+
fleet.dispose();
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
});
|