pi-crew 0.9.55 → 0.9.57

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.
Files changed (309) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +58 -0
  3. package/README.md +53 -5
  4. package/dist/index.mjs +5666 -4370
  5. package/docs/README.md +54 -0
  6. package/package.json +12 -13
  7. package/skills/real-test-pi-crew/SKILL.md +93 -3
  8. package/src/agents/discover-agents.ts +68 -10
  9. package/src/benchmark/feedback-loop.ts +1 -1
  10. package/src/config/config.ts +2 -1
  11. package/src/config/types.ts +12 -0
  12. package/src/extension/action-suggestions.ts +16 -63
  13. package/src/extension/async-notifier.ts +3 -3
  14. package/src/extension/command-completions.ts +2 -2
  15. package/src/extension/crew-cleanup.ts +3 -3
  16. package/src/extension/crew-vibes/footer.ts +4 -2
  17. package/src/extension/cross-extension-rpc.ts +10 -5
  18. package/src/extension/knowledge-injection.ts +57 -10
  19. package/src/extension/register.ts +2 -2
  20. package/src/extension/registration/artifact-cleanup.ts +41 -3
  21. package/src/extension/registration/commands.ts +4 -4
  22. package/src/extension/registration/context-builder.ts +10 -10
  23. package/src/extension/registration/crash-recovery-cache.ts +3 -3
  24. package/src/extension/registration/foreground-run-controller.ts +1 -1
  25. package/src/extension/registration/lazy-configurers.ts +2 -2
  26. package/src/extension/registration/lifecycle-handlers.ts +12 -12
  27. package/src/extension/registration/lifecycle.ts +2 -2
  28. package/src/extension/registration/observability.ts +2 -2
  29. package/src/extension/registration/registration-types.ts +3 -3
  30. package/src/extension/registration/runtime-cleanup.ts +1 -1
  31. package/src/extension/registration/subagent-helpers.ts +2 -2
  32. package/src/extension/registration/subagent-manager-setup.ts +2 -2
  33. package/src/extension/registration/subagent-tools.ts +21 -16
  34. package/src/extension/registration/team-tool.ts +109 -17
  35. package/src/extension/registration/viewers.ts +3 -4
  36. package/src/extension/registration/wire-cross-extension.ts +7 -7
  37. package/src/extension/rpc-hmac.ts +3 -2
  38. package/src/extension/run-bundle-schema.ts +13 -4
  39. package/src/extension/run-export.ts +2 -2
  40. package/src/extension/run-index.ts +2 -3
  41. package/src/extension/run-maintenance.ts +57 -1
  42. package/src/extension/team-manager-command.ts +3 -1
  43. package/src/extension/team-tool/anchor.ts +8 -2
  44. package/src/extension/team-tool/api.ts +117 -39
  45. package/src/extension/team-tool/cancel.ts +23 -8
  46. package/src/extension/team-tool/chain-executor.ts +1 -1
  47. package/src/extension/team-tool/dispatch/automate.ts +17 -2
  48. package/src/extension/team-tool/dispatch/control.ts +17 -2
  49. package/src/extension/team-tool/dispatch/manage.ts +34 -2
  50. package/src/extension/team-tool/dispatch/run.ts +17 -2
  51. package/src/extension/team-tool/dispatch/status.ts +37 -5
  52. package/src/extension/team-tool/doctor.ts +2 -2
  53. package/src/extension/team-tool/explain.ts +1 -1
  54. package/src/extension/team-tool/goal-wrap.ts +5 -5
  55. package/src/extension/team-tool/goal.ts +30 -9
  56. package/src/extension/team-tool/handle-schedule.ts +37 -19
  57. package/src/extension/team-tool/inspect.ts +21 -5
  58. package/src/extension/team-tool/lifecycle-actions.ts +53 -10
  59. package/src/extension/team-tool/parallel-dispatch.ts +14 -5
  60. package/src/extension/team-tool/param-error.ts +138 -0
  61. package/src/extension/team-tool/respond.ts +20 -6
  62. package/src/extension/team-tool/run.ts +27 -17
  63. package/src/extension/team-tool/status.ts +17 -6
  64. package/src/extension/team-tool.ts +26 -19
  65. package/src/hooks/registry.ts +1 -1
  66. package/src/i18n.ts +22 -0
  67. package/src/observability/event-bus.ts +1 -1
  68. package/src/prompt/prompt-runtime.ts +2 -2
  69. package/src/runtime/README.md +35 -0
  70. package/src/runtime/agent-control.ts +1 -1
  71. package/src/runtime/anchor-manager.ts +0 -2
  72. package/src/runtime/async-runner.ts +1 -1
  73. package/src/runtime/attention-events.ts +3 -2
  74. package/src/runtime/auto-summarize.ts +0 -2
  75. package/src/runtime/background-runner.ts +103 -30
  76. package/src/runtime/{crew-broker-child.ts → broker/crew-broker-child.ts} +2 -2
  77. package/src/runtime/{crew-broker-client.ts → broker/crew-broker-client.ts} +4 -7
  78. package/src/runtime/{crew-broker.ts → broker/crew-broker.ts} +13 -21
  79. package/src/runtime/chain-runner.ts +50 -5
  80. package/src/runtime/{child-pi-constants.ts → child-pi/child-pi-constants.ts} +1 -1
  81. package/src/runtime/{child-pi-kill.ts → child-pi/child-pi-kill.ts} +3 -3
  82. package/src/runtime/{child-pi-spawn.ts → child-pi/child-pi-spawn.ts} +28 -12
  83. package/src/runtime/{child-pi-steering.ts → child-pi/child-pi-steering.ts} +1 -1
  84. package/src/runtime/{child-pi-streams.ts → child-pi/child-pi-streams.ts} +23 -4
  85. package/src/runtime/{child-pi-transcript.ts → child-pi/child-pi-transcript.ts} +6 -6
  86. package/src/runtime/{child-pi.ts → child-pi/child-pi.ts} +47 -78
  87. package/src/runtime/compaction/compact-stages/bounded-tail.ts +84 -0
  88. package/src/runtime/{compact-stages → compaction/compact-stages}/index.ts +2 -2
  89. package/src/runtime/{compaction-summary.ts → compaction/compaction-summary.ts} +3 -3
  90. package/src/runtime/{tool-output-pruner.ts → compaction/tool-output-pruner.ts} +1 -1
  91. package/src/runtime/crew-agent-records.ts +48 -2
  92. package/src/runtime/custom-tools/irc-tool.ts +2 -2
  93. package/src/runtime/delivery-coordinator.ts +0 -3
  94. package/src/runtime/diagnostic-export.ts +5 -4
  95. package/src/runtime/foreground-control.ts +1 -1
  96. package/src/runtime/foreground-watchdog.ts +1 -1
  97. package/src/runtime/{adaptive-plan.ts → goal-workflow/adaptive-plan.ts} +8 -8
  98. package/src/runtime/{dynamic-workflow-context.ts → goal-workflow/dynamic-workflow-context.ts} +16 -16
  99. package/src/runtime/{dynamic-workflow-runner.ts → goal-workflow/dynamic-workflow-runner.ts} +10 -10
  100. package/src/runtime/{goal-achievement.ts → goal-workflow/goal-achievement.ts} +3 -3
  101. package/src/runtime/{goal-evaluator.ts → goal-workflow/goal-evaluator.ts} +8 -8
  102. package/src/runtime/{goal-loop-runner.ts → goal-workflow/goal-loop-runner.ts} +27 -25
  103. package/src/runtime/{goal-state-store.ts → goal-workflow/goal-state-store.ts} +8 -8
  104. package/src/runtime/{plan-templates.ts → goal-workflow/plan-templates.ts} +1 -1
  105. package/src/runtime/group-join.ts +3 -3
  106. package/src/runtime/handoff-manager.ts +0 -2
  107. package/src/runtime/{heartbeat-watcher.ts → heartbeat/heartbeat-watcher.ts} +7 -7
  108. package/src/runtime/iteration-hooks.ts +1 -1
  109. package/src/runtime/{live-agent-control.ts → live-session/live-agent-control.ts} +2 -2
  110. package/src/runtime/{live-agent-manager.ts → live-session/live-agent-manager.ts} +4 -4
  111. package/src/runtime/{live-session-runtime.ts → live-session/live-session-runtime.ts} +39 -41
  112. package/src/runtime/manifest-cache.ts +6 -2
  113. package/src/runtime/{model-fallback.ts → model/model-fallback.ts} +1 -1
  114. package/src/runtime/{pi-args.ts → model/pi-args.ts} +20 -5
  115. package/src/runtime/model/provider-extensions.ts +116 -0
  116. package/src/runtime/{runtime-policy.ts → model/runtime-policy.ts} +2 -2
  117. package/src/runtime/{runtime-resolver.ts → model/runtime-resolver.ts} +3 -3
  118. package/src/runtime/{runtime-warmup.ts → model/runtime-warmup.ts} +8 -8
  119. package/src/runtime/orphan-worker-registry.ts +1 -1
  120. package/src/runtime/{progress-tracker.ts → output/progress-tracker.ts} +1 -1
  121. package/src/runtime/{result-extractor.ts → output/result-extractor.ts} +4 -4
  122. package/src/runtime/{sidechain-output.ts → output/sidechain-output.ts} +2 -2
  123. package/src/runtime/{stream-preview.ts → output/stream-preview.ts} +1 -1
  124. package/src/runtime/{streaming-output.ts → output/streaming-output.ts} +2 -2
  125. package/src/runtime/{tool-progress.ts → output/tool-progress.ts} +1 -1
  126. package/src/runtime/parent-guard.ts +30 -10
  127. package/src/runtime/pipeline-runner.ts +2 -2
  128. package/src/runtime/policy-engine.ts +2 -2
  129. package/src/runtime/{cancellation.ts → process/cancellation.ts} +1 -1
  130. package/src/runtime/{post-exit-stdio-guard.ts → process/post-exit-stdio-guard.ts} +1 -1
  131. package/src/runtime/{process-lifecycle.ts → process/process-lifecycle.ts} +3 -3
  132. package/src/runtime/{checkpoint.ts → recovery/checkpoint.ts} +4 -4
  133. package/src/runtime/{crash-recovery.ts → recovery/crash-recovery.ts} +93 -21
  134. package/src/runtime/{overflow-recovery.ts → recovery/overflow-recovery.ts} +1 -1
  135. package/src/runtime/{recovery-recipes.ts → recovery/recovery-recipes.ts} +1 -1
  136. package/src/runtime/{retry-executor.ts → recovery/retry-executor.ts} +2 -2
  137. package/src/runtime/{retry-runner.ts → recovery/retry-runner.ts} +2 -8
  138. package/src/runtime/run-tracker.ts +1 -1
  139. package/src/runtime/run-worker.ts +3 -3
  140. package/src/runtime/{coalesce-tasks.ts → scheduling/coalesce-tasks.ts} +3 -3
  141. package/src/runtime/{concurrency.ts → scheduling/concurrency.ts} +9 -3
  142. package/src/runtime/{parallel-research.ts → scheduling/parallel-research.ts} +4 -2
  143. package/src/runtime/{run-coalesced-task-group.ts → scheduling/run-coalesced-task-group.ts} +95 -36
  144. package/src/runtime/{semaphore.ts → scheduling/semaphore.ts} +4 -1
  145. package/src/runtime/{task-graph-scheduler.ts → scheduling/task-graph-scheduler.ts} +1 -1
  146. package/src/runtime/session-resources.ts +1 -1
  147. package/src/runtime/settings-store.ts +1 -1
  148. package/src/runtime/single-agent-compose.ts +1 -0
  149. package/src/runtime/stale-reconciler.ts +1 -1
  150. package/src/runtime/subagent-manager.ts +1 -1
  151. package/src/runtime/supervisor-contact.ts +28 -13
  152. package/src/runtime/task-output-context.ts +7 -5
  153. package/src/runtime/task-runner/child-executor.ts +67 -31
  154. package/src/runtime/task-runner/live-executor.ts +8 -8
  155. package/src/runtime/task-runner/post-execution.ts +12 -12
  156. package/src/runtime/task-runner/pre-execution.ts +6 -6
  157. package/src/runtime/task-runner/progress.ts +1 -1
  158. package/src/runtime/task-runner/run-projection.ts +1 -1
  159. package/src/runtime/task-runner/scaffold-executor.ts +1 -1
  160. package/src/runtime/task-runner/state-helpers.ts +2 -2
  161. package/src/runtime/task-runner.ts +4 -4
  162. package/src/runtime/team-runner.ts +441 -175
  163. package/src/runtime/{completion-guard.ts → verification/completion-guard.ts} +1 -1
  164. package/src/runtime/{green-contract.ts → verification/green-contract.ts} +1 -1
  165. package/src/runtime/{post-checks.ts → verification/post-checks.ts} +4 -4
  166. package/src/runtime/{verification-gates.ts → verification/verification-gates.ts} +5 -5
  167. package/src/runtime/{verification-integrity.ts → verification/verification-integrity.ts} +1 -1
  168. package/src/schema/config-schema.ts +1 -0
  169. package/src/schema/team-tool-schema.ts +149 -185
  170. package/src/state/README.md +44 -0
  171. package/src/state/atomic-write.ts +24 -3
  172. package/src/state/{locks.ts → coordination/locks.ts} +118 -38
  173. package/src/state/{mailbox.ts → coordination/mailbox.ts} +14 -8
  174. package/src/state/{schedule.ts → coordination/schedule.ts} +3 -3
  175. package/src/state/{task-claims.ts → coordination/task-claims.ts} +1 -1
  176. package/src/state/decision-ledger.ts +1 -1
  177. package/src/state/{event-log-rotation.ts → event-log/event-log-rotation.ts} +189 -31
  178. package/src/state/{event-log.ts → event-log/event-log.ts} +77 -39
  179. package/src/state/{jsonl-writer.ts → event-log/jsonl-writer.ts} +14 -6
  180. package/src/state/hook-instinct-bridge.ts +2 -2
  181. package/src/state/{active-run-registry.ts → stores/active-run-registry.ts} +7 -7
  182. package/src/state/{artifact-store.ts → stores/artifact-store.ts} +62 -4
  183. package/src/state/{blob-store.ts → stores/blob-store.ts} +3 -3
  184. package/src/state/{health-store.ts → stores/health-store.ts} +3 -3
  185. package/src/state/{instinct-store.ts → stores/instinct-store.ts} +3 -3
  186. package/src/state/{observation-store.ts → stores/observation-store.ts} +2 -2
  187. package/src/state/{run-cache.ts → stores/run-cache.ts} +4 -4
  188. package/src/state/{run-graph.ts → stores/run-graph.ts} +4 -4
  189. package/src/state/{run-metrics.ts → stores/run-metrics.ts} +3 -3
  190. package/src/state/{state-store.ts → stores/state-store.ts} +254 -21
  191. package/src/state/types.ts +27 -3
  192. package/src/ui/component.ts +55 -0
  193. package/src/ui/crew-select-list.ts +3 -1
  194. package/src/ui/dashboard-panes/agents-pane.ts +1 -1
  195. package/src/ui/dwf-phase-display.ts +1 -1
  196. package/src/ui/heartbeat-aggregator.ts +1 -1
  197. package/src/ui/keybinding-map.ts +179 -6
  198. package/src/ui/layout-primitives.ts +9 -5
  199. package/src/ui/live-conversation-overlay.ts +1 -1
  200. package/src/ui/live-run-sidebar.ts +1 -1
  201. package/src/ui/overlay-stack.ts +148 -0
  202. package/src/ui/overlays/agent-picker-overlay.ts +1 -1
  203. package/src/ui/overlays/mailbox-compose-overlay.ts +1 -1
  204. package/src/ui/overlays/mailbox-detail-overlay.ts +2 -2
  205. package/src/ui/powerbar-publisher.ts +1 -1
  206. package/src/ui/render-scheduler.ts +1 -1
  207. package/src/ui/run-action-dispatcher.ts +3 -3
  208. package/src/ui/run-dashboard.ts +5 -33
  209. package/src/ui/run-event-bus.ts +3 -3
  210. package/src/ui/run-snapshot-cache.ts +37 -18
  211. package/src/ui/settings-overlay.ts +13 -21
  212. package/src/ui/snapshot-types.ts +1 -1
  213. package/src/ui/status-colors.ts +0 -2
  214. package/src/ui/terminal-status.ts +1 -1
  215. package/src/ui/theme-adapter.ts +33 -13
  216. package/src/ui/tool-renderers/index.ts +8 -0
  217. package/src/ui/transcript-viewer.ts +37 -13
  218. package/src/ui/widget/index.ts +32 -9
  219. package/src/ui/widget/widget-formatters.ts +62 -4
  220. package/src/ui/widget/widget-model.ts +2 -2
  221. package/src/ui/widget/widget-renderer.ts +1 -1
  222. package/src/utils/conflict-detect.ts +58 -5
  223. package/src/utils/ndjson.ts +2 -2
  224. package/src/utils/redaction.ts +39 -0
  225. package/src/utils/socket-path.ts +1 -1
  226. package/src/workflows/workflow-config.ts +1 -1
  227. package/src/worktree/cleanup.ts +1 -1
  228. package/src/worktree/worktree-manager.ts +111 -47
  229. package/workflows/chain.workflow.md +2 -2
  230. package/dist/build-meta.json +0 -16807
  231. package/index.bundle.ts +0 -25
  232. package/scripts/bench-check.mjs +0 -96
  233. package/scripts/bench-cold-start.mjs +0 -216
  234. package/scripts/build-bundle.mjs +0 -92
  235. package/scripts/check-all-skills.ts +0 -294
  236. package/scripts/check-bundle-size.mjs +0 -38
  237. package/scripts/check-bundle-staleness.mjs +0 -97
  238. package/scripts/check-conflict-markers.mjs +0 -91
  239. package/scripts/check-lazy-imports.mjs +0 -28
  240. package/scripts/dev-runner.mjs +0 -106
  241. package/scripts/profile-startup.mjs +0 -125
  242. package/scripts/release-smoke.mjs +0 -74
  243. package/scripts/run-bench.mjs +0 -47
  244. package/scripts/run-real-chain.ts +0 -41
  245. package/scripts/test-issue-29-crash.ts +0 -111
  246. package/scripts/test-issue-29-e2e.ts +0 -183
  247. package/scripts/test-issue-29-real-runtime.ts +0 -330
  248. package/scripts/test-issue-29-real-tasks.ts +0 -387
  249. package/scripts/test-issue-29-team-tool.ts +0 -105
  250. package/scripts/test-runner.mjs +0 -84
  251. package/scripts/verify-flicker-fix.ts +0 -109
  252. package/scripts/verify-skill.ts +0 -550
  253. package/scripts/watch-bundle.mjs +0 -259
  254. package/scripts/watchdog-harness.ts +0 -119
  255. package/src/adapters/claude-adapter.ts +0 -23
  256. package/src/adapters/codex-adapter.ts +0 -21
  257. package/src/adapters/cursor-adapter.ts +0 -17
  258. package/src/adapters/export-util.ts +0 -143
  259. package/src/adapters/index.ts +0 -15
  260. package/src/adapters/registry.ts +0 -18
  261. package/src/adapters/types.ts +0 -23
  262. package/src/runtime/code-summary.ts +0 -292
  263. package/src/runtime/cross-extension-rpc.ts +0 -143
  264. package/src/runtime/hidden-handoff.ts +0 -407
  265. package/src/runtime/prose-compressor.ts +0 -162
  266. package/src/subagents/async-entry.ts +0 -1
  267. package/src/subagents/index.ts +0 -3
  268. package/src/subagents/live/control.ts +0 -1
  269. package/src/subagents/live/manager.ts +0 -1
  270. package/src/subagents/live/realtime.ts +0 -1
  271. package/src/subagents/live/session-runtime.ts +0 -1
  272. package/src/subagents/manager.ts +0 -1
  273. package/src/subagents/spawn.ts +0 -1
  274. package/test-integration-check.ts +0 -118
  275. /package/src/runtime/{broker-issuer.ts → broker/broker-issuer.ts} +0 -0
  276. /package/src/runtime/{crew-broker-tokens.ts → broker/crew-broker-tokens.ts} +0 -0
  277. /package/src/runtime/{child-pi-pool.ts → child-pi/child-pi-pool.ts} +0 -0
  278. /package/src/runtime/{compact-pipeline.ts → compaction/compact-pipeline.ts} +0 -0
  279. /package/src/runtime/{compact-stages → compaction/compact-stages}/ansi-strip-stage.ts +0 -0
  280. /package/src/runtime/{compact-stages → compaction/compact-stages}/blank-collapse-stage.ts +0 -0
  281. /package/src/runtime/{compact-stages → compaction/compact-stages}/deduplicate-stage.ts +0 -0
  282. /package/src/runtime/{compact-stages → compaction/compact-stages}/head-snap-stage.ts +0 -0
  283. /package/src/runtime/{compact-stages → compaction/compact-stages}/tail-capture-stage.ts +0 -0
  284. /package/src/runtime/{compact-stages → compaction/compact-stages}/truncation-stage.ts +0 -0
  285. /package/src/runtime/{important-line-classifier.ts → compaction/important-line-classifier.ts} +0 -0
  286. /package/src/runtime/{heartbeat-gradient.ts → heartbeat/heartbeat-gradient.ts} +0 -0
  287. /package/src/runtime/{worker-heartbeat.ts → heartbeat/worker-heartbeat.ts} +0 -0
  288. /package/src/runtime/{worker-startup.ts → heartbeat/worker-startup.ts} +0 -0
  289. /package/src/runtime/{intercom-bridge.ts → live-session/intercom-bridge.ts} +0 -0
  290. /package/src/runtime/{live-control-realtime.ts → live-session/live-control-realtime.ts} +0 -0
  291. /package/src/runtime/{live-extension-bridge.ts → live-session/live-extension-bridge.ts} +0 -0
  292. /package/src/runtime/{live-irc.ts → live-session/live-irc.ts} +0 -0
  293. /package/src/runtime/{live-session-health.ts → live-session/live-session-health.ts} +0 -0
  294. /package/src/runtime/{model-resolver.ts → model/model-resolver.ts} +0 -0
  295. /package/src/runtime/{model-scope.ts → model/model-scope.ts} +0 -0
  296. /package/src/runtime/{output-validator.ts → output/output-validator.ts} +0 -0
  297. /package/src/runtime/{pi-json-output.ts → output/pi-json-output.ts} +0 -0
  298. /package/src/runtime/{progress-event-coalescer.ts → output/progress-event-coalescer.ts} +0 -0
  299. /package/src/runtime/{cancellation-token.ts → process/cancellation-token.ts} +0 -0
  300. /package/src/runtime/{zombie-scanner.ts → process/zombie-scanner.ts} +0 -0
  301. /package/src/runtime/{crash-classification.ts → recovery/crash-classification.ts} +0 -0
  302. /package/src/runtime/{batch-barrier.ts → scheduling/batch-barrier.ts} +0 -0
  303. /package/src/runtime/{global-worker-cap.ts → scheduling/global-worker-cap.ts} +0 -0
  304. /package/src/runtime/{parallel-utils.ts → scheduling/parallel-utils.ts} +0 -0
  305. /package/src/runtime/{scheduler.ts → scheduling/scheduler.ts} +0 -0
  306. /package/src/runtime/{task-graph.ts → scheduling/task-graph.ts} +0 -0
  307. /package/src/runtime/{verification-worktree.ts → verification/verification-worktree.ts} +0 -0
  308. /package/src/state/{event-reconstructor.ts → event-log/event-reconstructor.ts} +0 -0
  309. /package/src/state/{worker-atomic-writer.ts → event-log/worker-atomic-writer.ts} +0 -0
package/AGENTS.md CHANGED
@@ -10,7 +10,7 @@ Read in this order:
10
10
  2. `docs/HARNESS.md` for the human-agent collaboration model.
11
11
  3. `docs/FEATURE_INTAKE.md` before turning any request into work.
12
12
  4. `docs/product/` for current product contracts.
13
- 5. `docs/ARCHITECTURE.md` for implementation shape.
13
+ 5. `docs/architecture.md` for implementation shape.
14
14
  6. `docs/stories/` for story packets and backlog.
15
15
  7. `docs/TEST_MATRIX.md` for proof status.
16
16
  8. `docs/decisions/` for why important choices were made.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,64 @@
3
3
  > **Note:** `atomic-write-v2.ts` / `AtomicWriter` mentioned in historical entries below was consolidated into `atomic-write.ts` as of v0.9.42. This changelog is preserved as historical record — the migration was completed (the v2 class was never adopted; v1 won on simplicity + symlink-safety + link+unlink atomicity). See `docs/migration/atomic-write-v2-migration.md` for the decision rationale.
4
4
 
5
5
 
6
+ ## [0.9.57] — provider-extension auto-discovery + team-tool schema repair + whole-project reorganization (2026-08-03)
7
+
8
+ ### New: provider extensions work in subagents (no hardcoding)
9
+ - pi-crew spawns child-pi workers with `--no-extensions` (security posture from SEC-1), which made extension-registered providers (e.g. `pi-commandcode-provider`) unresolvable in subagents → their models fell back to a secondary provider (429 rate-limit deaths, 0 tool uses).
10
+ - **Auto-discovery**: pi-crew now reads `~/.pi/agent/settings.json` `packages` (npm: specs only), resolves each to its extension entry point (`pi.extensions` → `index.ts` → `index.mjs` → `index.js` → `src/index.ts`), and merges the discovered paths into every builtin/user agent (`src/runtime/model/provider-extensions.ts` + `src/agents/discover-agents.ts`).
11
+ - Result: **any provider package installed via `pi install npm:<pkg>` works automatically in subagents** — no manual per-extension config.
12
+ - Optional explicit allowlist `runtime.agentExtensions: string[]` config added on top of auto-discovery.
13
+ - SEC-1 preserved: project/project-pi agents never receive these extensions.
14
+ - Verified end-to-end: `deepseek/deepseek-v4-flash` resolves to `commandcode/deepseek/deepseek-v4-flash` in a real subagent spawn and completes.
15
+
16
+ ### Bug fixes (team tool was broken live while tests stayed green)
17
+ - **"Validation failed for tool team"**: pi-ai `validateToolArguments` validates tool args BEFORE the pi-crew handler runs, and rejected model-emitted empty-string defaults (`runId:""`, `workspaceMode:""`, `context:""`, `scope:""`, `budgetTotal:0`, `once:false`, `keep:false`) against Literal unions / patterns / minimums. Schema now accepts the unset markers (`Literal("")`, runId pattern `^$|^...`, `Literal(0)`, `Boolean` in unions); `allActionLiterals` filters the `""`.
18
+ - **"Unknown type"**: `SkillOverride`/`FreeformConfig` used `Type.Unsafe({...})` WITHOUT a `[TypeBox.Kind]` symbol, so `Value.Check` threw "Unknown type" the first time a model sent `skill`/`config`. Switched to TypeBox-native `Type.Union`/`Type.Record`. Handler-side `normalizeTeamParams` drops empty strings before validation (defense-in-depth).
19
+ - **chain-runner mis-split on arrows inside inline goals**: `parseChain` used `split("->")`, incorrectly splitting `"Change A -> B" -> "Analyze"` into 3 steps. New quote-aware `splitChainSteps()` splits only on top-level arrows (backward compatible).
20
+ - These were caught by a new Tier 9 feature battery in the `real-test-pi-crew` skill (live team-tool action coverage), which is now documented there alongside the agent-unauthorized-edit anti-pattern surfaced during testing.
21
+
22
+ ### Whole-project reorganization (~92 commits)
23
+ - `src/` clustered: `src/runtime/` → 15 subdirs (child-pi/, broker/, live-session/, recovery/, scheduling/, verification/, model/, output/, heartbeat/, process/, goal-workflow/, compaction/, task-runner/, custom-tools/, errors/), `src/state/` → 3 subdirs (event-log/, stores/, coordination/), plus ui/, config/, utils/, agents/, extension/ clusters. Cluster maps in `src/runtime/README.md`, `src/state/README.md`.
24
+ - `test/unit/` mirrored: 561 of 712 flat `.test.ts` files moved into 35 subdirs matching `src/` (243 runtime/, 53 state/, 110 extension/, plus ui/, config/, utils/, etc.). 151 cross-cutting tests (round*, v0*, package-*, errors, i18n, bundle-*) stay at root by design. Map in `test/unit/README.md`.
25
+ - **REAL bug fixed**: test runner now expands `**` globs — `test/unit/security/` (3 files, 36 tests) were invisible before. All 715 files now discovered (6732 tests, 0 fail).
26
+ - `docs/` consolidated: 27 historical docs → `docs/archive/`; 20 living docs stay at root; new `docs/README.md` index; 5 categories of broken refs fixed (dead links in src/agents/discover-agents.ts, src/runtime/{chain-runner,anchor-manager,handoff-manager,auto-summarize}.ts, recovery/retry-runner.ts, SECURITY-ISSUES.md, ARCHITECTURE.md refs).
27
+ - Root cleanup: 11 stray `.md` files at repo root → `docs/archive/` + `docs/bugs/`.
28
+ - README updated: Repository layout section, provider-extension feature, `runtime.agentExtensions` config row, v0.9.57 Recent-changes entry, 3 broken doc links fixed.
29
+ - Stale worktrees + 4 merged local branches cleaned; `git worktree list` main-only.
30
+
31
+ ### Verification
32
+ - Full final gate: typecheck 0 · lint 0 err/warn · format:check clean · unit 6763/6760/0 · integration 200/199/0 · `test:critical` 98/0 · bundle-load + smoke(real-binary) green · bundle 2.70 MB (budget 3.5 MB) · conflict-markers/lazy-imports/bundle-staleness all OK.
33
+ - Live feature battery (Tier 9): `team` action=list/run(sync)/run(async)/chain + `Agent`/`crew_agent`/`get_subagent_result` all green with `deepseek/deepseek-v4-flash` over commandcode; read-only actions (recommend/health/doctor/status/events/summary/get/explain/worktrees) all return clean.
34
+
35
+ ## [0.9.56] — performance remediation + team-tool schema fix (2026-07-30)
36
+
37
+ Follows the verified `performance-audit-2026-07-29.md` (16 findings addressed). Independently deep-reviewed by a 4-agent review team (explore/code-review/security-review/verify — no P0/P1), full unit 6486/0 + integration 190/0, CI green on ubuntu/macos/windows.
38
+
39
+ ### Performance
40
+ - **P0-1**: new `BoundedTail` segment ring replaces the O(n²) `appendBoundedTail` rebuild-per-line on stdout/stderr (5000 CJK lines: 112s → 26ms).
41
+ - **P0-2**: per-eventsPath rotation counter — the async append path's `% 100` gate was always true (counter never incremented there) so `needsRotation` ran every event; now ticked on all three append paths.
42
+ - **P0-3**: the per-batch hot-loop `saveCrewAgents` switched to `saveCrewAgentsCoalesced` (removes the `Atomics.wait`/`sleepSync` main-thread block); terminal writes flush coalesced first.
43
+ - **P0-4**: async event append drops from 5 fsyncs to ~0 (non-terminal) / 1 (terminal) — best-effort pid/`.seq` + F3a-style terminal-only data fsync.
44
+ - **P1-5**: memoize validated agent paths per task (~60 syscalls/event → ~0 after first).
45
+ - **P1-6**: redaction pre-filter `mayContainSecret` skips the ~14 redaction passes on clean strings (no bypass — every secret type still redacted).
46
+ - **P1-7**: scheduler consults the global worker cap (no more over-dispatch on low-core machines).
47
+ - **P1-8**: tail readers use `readJsonlTail`; `status.ts` O(events×messages) → O(events+messages).
48
+ - **P1-9**: manifest cache-hit skips the redundant path re-validation.
49
+ - **P1-10**: `before_task_start` hooks run via `Promise.all`.
50
+ - **P1-11**: `git worktree prune` memoized per-repo (coalesces concurrent calls + once per process).
51
+ - **P1-12**: `resolveRunStateRoot` memoized (containment check was ~8-12 syscalls/call).
52
+ - **P2-21**: drop `dist/build-meta.json` from the npm tarball (−470KB).
53
+ - **P2-25**: `supervisor_contact` events now reach `recordSupervisorContact` (was fully dead — the compact pipeline stripped the payload and `onStdoutLine` received display prose).
54
+ - **H2**: archive retention sweep (`.archive.jsonl` no longer accumulate forever).
55
+ - **H5**: `tasks.find` O(N²) → `Map` at all scheduler sites.
56
+
57
+ ### Platform fix
58
+ - **team-tool schema flatten**: `TeamToolParams` was `Type.Union([5 domain objects])`, emitting a giant `anyOf` that LLM tool-callers could not reliably satisfy → empty/malformed calls → the tool silently defaulted to `list`. Flattened to a single `Type.Object` (all 54 actions + shared fields optional); the handler still validates per-action fields at runtime (defense-in-depth, unchanged).
59
+
60
+ ### Review follow-ups
61
+ - Tighten the `"gh"` redaction marker to `gh[pousr]_` (reduces false-positives like "though"/"highlight").
62
+ - Test guard: `allActionLiterals.length === 54` (schema-derivation regression guard).
63
+
6
64
  ## [0.9.55] — HOTFIX: ship src/ (child workers load src/prompt/prompt-runtime.ts by path) (2026-07-29)
7
65
 
8
66
  **Fixes the delegation / team-run regression** that affected 0.9.52–0.9.54. The extension loaded fine (0.9.54), but delegation/team-run failed with "pi-crew run failed" — the child worker `pi` process could not find its extension.
package/README.md CHANGED
@@ -26,7 +26,7 @@
26
26
  > a footgun, or a sharp edge, please open an issue or send a note — your
27
27
  > feedback is genuinely appreciated. Thanks. ✌️
28
28
  >
29
- > See also: [SECURITY-ISSUES.md](SECURITY-ISSUES.md),
29
+ > See also: [SECURITY-ISSUES.md](docs/bugs/SECURITY-ISSUES.md),
30
30
  > [docs/dynamic-workflows.md](docs/dynamic-workflows.md#security-model-important)
31
31
  > (trust model), and the [Known limitations](#known-limitations) section below.
32
32
 
@@ -70,6 +70,7 @@ repo: https://github.com/baphuongna/pi-crew
70
70
  - **Lossless-by-default output handling** (L4, v0.9.8) — worker output thresholds sized from measured data (100% of real outputs fit without compaction); when compaction is unavoidable it keeps head+tail (preserves closing code fences/headings) instead of head-only truncation. No more `[pi-crew compacted N chars]` markers eating the end of a worker's result.
71
71
  - **Inter-pi broker** (v0.9.47, default-on) — a Unix-domain-socket message bus that lets concurrently-running Pi sessions pass messages, steering notes, and task-status events to each other. **On by default** on Linux + macOS; auto-disabled on native Windows (no unix socket). Three independent kill switches: `broker.enabled: false` (config), `PI_CREW_BROKER=0` (env, always wins), Windows auto-disable. See [docs/decisions/2026-07-22-broker-phase4-gated-on.md](docs/decisions/2026-07-22-broker-phase4-gated-on.md).
72
72
  - **`test:critical` + `real-test-pi-crew` skill** (v0.9.47) — a curated 14-file / 97-test subset (`npm run test:critical`, ~20s) for fast in-loop verification, plus a bundled skill distilling the full 8-tier end-to-end verification discipline (unit → 3-path kill-switch proof → typecheck/bundle → live TUI probing → smoke team run). Prevents the verifier-worker hang that full `npm test` (>4 min) caused against the 300s worker timeout.
73
+ - **Provider extensions in subagents** (v0.9.57) — pi-crew spawns child-pi workers with `--no-extensions` (security posture), which made extension-registered providers (e.g. `pi-commandcode-provider`) unresolvable inside subagents. pi-crew now **auto-discovers provider packages** from `~/.pi/agent/settings.json` `packages` (npm: specs) and loads them via `--extension` in every builtin/user subagent — so **all provider models work in subagents**. An explicit `runtime.agentExtensions: string[]` config is an optional extra allowlist on top of auto-discovery. **SEC-1 preserved:** project/project-pi agents never receive these (env-gate unchanged).
73
74
 
74
75
  ---
75
76
 
@@ -286,6 +287,16 @@ The advisory is **informational only** — there is no `force:true` flag needed
286
287
 
287
288
  ## Recent changes
288
289
 
290
+ ### v0.9.57: team-tool schema repair + provider-extension auto-discovery + post-reorg repo-layout consolidation
291
+
292
+ - **Team tool repaired (was broken live while tests stayed green)**: calling models emit empty-string/boolean defaults for every schema key, which pi-ai's pre-handler `validateToolArguments` rejected (`Validation failed for tool team`) and `Type.Unsafe` schema fields without `[TypeBox.Kind]` made `Value.Check` throw (`Unknown type`). Schema now accepts unset markers natively; `SkillOverride`/`FreeformConfig` switched to TypeBox-native constructors; `normalizeTeamParams` drops empties in the handler. Chain-runner also fixed (quote-aware step splitting). Caught by a new **Tier 9 feature battery** in the [`real-test-pi-crew`](skills/real-test-pi-crew/SKILL.md) skill (live team-tool action coverage).
293
+ - **Source reorg finalised (~90 commits)**: `src/` is now cluster-organised — `src/runtime/` (15 subdirs + ~77 flat files) and `src/state/` (3 subdirs + 12 root files), with the other top-level dirs (`extension/`, `ui/`, `config/`, `utils/`, `agents/`, …) cluster-honed too. See [Repository layout](#repository-layout) and the cluster maps [`src/runtime/README.md`](src/runtime/README.md) / [`src/state/README.md`](src/state/README.md).
294
+ - **Tests mirrored into subdirs**: 566 flat `.test.ts` files now live in 35 leaf subdirectories mirroring `src/` (`test/unit/runtime/`, `test/unit/state/`, `test/unit/extension/`, …). 151 cross-cutting tests (`round*`, `v0*`, `package-*`, errors, i18n, bundle-*) stay at `test/unit/` root by design. See [`test/unit/README.md`](test/unit/README.md).
295
+ - **Recursive-glob test-runner fix**: `scripts/test-runner.mjs` now expands `**` globs itself — Node v22's `--test` only expands single-level `*`, so subdir tests (e.g. `test/unit/security/`) were **invisible** to `npm test` before.
296
+ - **Docs consolidated**: 47 flat docs at `docs/` root → 20 living docs kept at root, 27 historical moved to `docs/archive/` (flat); 11 stray root `.md` files moved to `docs/archive/` + `docs/bugs/`. New [`docs/README.md`](docs/README.md) indexes the living docs + subdirs.
297
+ - **Provider extensions in subagents** (see [Features](#features)): auto-discovery of provider packages from `~/.pi/agent/settings.json` `packages` (npm: specs) + explicit `runtime.agentExtensions` allowlist. Implementation: `src/runtime/model/provider-extensions.ts` + merge in `src/agents/discover-agents.ts`. SEC-1 preserved (project/project-pi agents never receive these).
298
+ - See [CHANGELOG.md](CHANGELOG.md) for the full reorg + feature log.
299
+
289
300
  ### v0.9.47 (2026-07-22): Inter-pi broker Phase 4 (default-on) + verifier-hang fix + verification skill
290
301
 
291
302
  - **Broker default-on**: `broker.enabled` flipped `false` → `true` on Linux + macOS. The inter-pi broker lets concurrent Pi sessions exchange messages, steering notes, and task-status events over a Unix-domain socket. Three kill switches remain: config `broker.enabled: false`, env `PI_CREW_BROKER=0` (always wins), Windows auto-disable.
@@ -315,7 +326,7 @@ The advisory is **informational only** — there is no `force:true` flag needed
315
326
 
316
327
  ### v0.9.42 – v0.9.44: 4-wave audit + flaky-CI fixes
317
328
 
318
- A 4-wave audit + fix pass was completed (see `UPGRADE_REVIEW.md` for the full 647-line report and `CHANGELOG.md` for the diff):
329
+ A 4-wave audit + fix pass was completed (see `docs/archive/UPGRADE_REVIEW.md` for the full 647-line report and `CHANGELOG.md` for the diff):
319
330
 
320
331
  - **−481 KB** bundle size (externalized `acorn` + fixed `@sinclair/typebox` name).
321
332
  - **−31.1%** in `child-pi.ts` (1842 → 1270 lines via 6 decomposition steps).
@@ -481,6 +492,7 @@ For machine-readable validation, see [schema.json](schema.json).
481
492
  | `runtime.effectivenessGuard` | `off \| warn \| block \| fail` | `off` | Pre-flight topology validator enforcement mode. |
482
493
  | `runtime.isolationPolicy` 🔒 | `{ isolatedRoles?, defaultRuntime? }` | _(unset)_ | Per-role runtime selection for crash isolation. |
483
494
  | `runtime.excludeContextBash` | `boolean` | `false` | Exclude certain bash results from worker context. |
495
+ | `runtime.agentExtensions` | `string[]` | _(unset)_ | Extra extension paths (file paths or npm entry points) loaded in **every** child-pi worker on top of auto-discovered provider packages (see [Features](#features)). Optional allowlist — auto-discovery already loads provider packages from `~/.pi/agent/settings.json` `packages`. Project/project-pi agents never receive these (SEC-1). |
484
496
 
485
497
  ² `requirePlanApproval` is sensitive only when set to `false` in project config
486
498
  (the sanitizer blocks *disabling* the gate from untrusted project config).
@@ -893,7 +905,39 @@ npm run ci # full CI-equivalent check
893
905
  npm pack --dry-run # package verification
894
906
  ```
895
907
 
896
- Stats: **477 source files** (108K lines) · **682 test files** (~6,500 tests) · **CI: Ubuntu ✅ macOS ✅ Windows ✅**
908
+ Stats: **476 source files** (112K lines) · **762 test files** (717 unit + 34 integration + 5 smoke + 3 functional + 2 platform + 1 manual) · **CI: Ubuntu ✅ macOS ✅ Windows ✅**
909
+
910
+ ---
911
+
912
+ ## Repository layout
913
+
914
+ After the v0.9.x reorg (~90 commits) the repo is cluster-organised so related
915
+ files live together — source, tests, and docs mirror each other.
916
+
917
+ ```
918
+ src/ # ~476 TS files
919
+ ├── runtime/ # team-run execution machinery — 15 subdirs + ~77 flat files
920
+ ├── state/ # persistent state layer — 3 subdirs + 12 root files
921
+ ├── extension/ # Pi extension surface (register, team-tool, ui glue)
922
+ ├── ui/ # TUI, dashboard, overlays
923
+ ├── config/ · utils/ · agents/ · workflows/ · … # supporting clusters
924
+ test/
925
+ └── unit/ # mirrors src/ — 35 leaf subdirs + 151 cross-cutting tests at root
926
+ ├── runtime/ · state/ · extension/ · ui/ · config/ · …
927
+ docs/ # living docs at root; history in docs/archive/
928
+ ```
929
+
930
+ - **`src/`** — each top-level dir has a cluster map; the two largest are
931
+ [`src/runtime/README.md`](src/runtime/README.md) (15 subdirs: child-pi,
932
+ broker, live-session, recovery, scheduling, verification, model, output,
933
+ heartbeat, process, goal-workflow, compaction, task-runner, custom-tools,
934
+ errors) and [`src/state/README.md`](src/state/README.md) (event-log,
935
+ stores, coordination).
936
+ - **`test/unit/`** — mirrors `src/` 1:1; cross-cutting tests (`round*`,
937
+ `v0*`, `package-*`, errors, i18n, bundle-*) stay at the root by design.
938
+ See [`test/unit/README.md`](test/unit/README.md).
939
+ - **`docs/`** — 20 living docs at the root; 27 historical docs moved to
940
+ `docs/archive/`. See [`docs/README.md`](docs/README.md).
897
941
 
898
942
  ---
899
943
 
@@ -912,7 +956,11 @@ Stats: **477 source files** (108K lines) · **682 test files** (~6,500 tests) ·
912
956
  | [docs/dynamic-workflows.md](docs/dynamic-workflows.md) | **v0.9.0** `.dwf.ts` script runtime + trust model |
913
957
  | [docs/live-mailbox-runtime.md](docs/live-mailbox-runtime.md) | Mailbox + live-session runtime |
914
958
  | [docs/publishing.md](docs/publishing.md) | Release & publish process |
915
- | [docs/next-upgrade-roadmap.md](docs/next-upgrade-roadmap.md) | Future upgrade roadmap |
959
+ | [docs/README.md](docs/README.md) | Index of all docs/ (living + subdirs) |
960
+ | [src/runtime/README.md](src/runtime/README.md) | Runtime source cluster map (15 subdirs) |
961
+ | [src/state/README.md](src/state/README.md) | State source cluster map (3 subdirs) |
962
+ | [test/unit/README.md](test/unit/README.md) | Unit-test cluster map (mirrors src/) |
963
+ | [docs/archive/next-upgrade-roadmap.md](docs/archive/next-upgrade-roadmap.md) | Future upgrade roadmap |
916
964
  | [schema.json](schema.json) | Config JSON schema |
917
965
 
918
966
  Research docs (not in package): [`docs/pi-crew-research/`](https://github.com/baphuongna/pi-crew/tree/main/docs) — audits, deep research, distillation notes.
@@ -929,7 +977,7 @@ sharp edges I'm aware of — there are almost certainly others I'm not.
929
977
  event-loop race that kills the background process with no signal, no core,
930
978
  and no V8 diagnostic report (8 investigation attempts: gdb, strace, perf,
931
979
  `--report-on-fatalerror`, sync-fs workarounds, worker-thread atomic writer —
932
- see `research-findings/goal-workflow/17-PHASE1.5-CRASH-INVESTIGATION-RFC.md`).
980
+ see [CHANGELOG.md](CHANGELOG.md) § v0.9.0 "Phase 1.5 #3").
933
981
  **Mitigation:** multi-step workflows silently auto-downgrade to a normal
934
982
  team-run (no goal-wrap layer); single-step workflows (`implementation`)
935
983
  goal-wrap end-to-end.