pi-crew 0.1.45 → 0.1.46

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 (198) hide show
  1. package/README.md +5 -5
  2. package/agents/analyst.md +1 -1
  3. package/agents/critic.md +1 -1
  4. package/agents/executor.md +1 -1
  5. package/agents/explorer.md +1 -1
  6. package/agents/planner.md +1 -1
  7. package/agents/reviewer.md +1 -1
  8. package/agents/security-reviewer.md +1 -1
  9. package/agents/test-engineer.md +1 -1
  10. package/agents/verifier.md +1 -1
  11. package/agents/writer.md +1 -1
  12. package/docs/next-upgrade-roadmap.md +733 -0
  13. package/docs/refactor-tasks-phase3.md +394 -394
  14. package/docs/refactor-tasks-phase4.md +564 -564
  15. package/docs/refactor-tasks-phase5.md +402 -402
  16. package/docs/refactor-tasks-phase6.md +662 -662
  17. package/docs/research-awesome-agent-skills-distillation.md +100 -0
  18. package/docs/research-extension-examples.md +297 -297
  19. package/docs/research-extension-system.md +324 -324
  20. package/docs/research-oh-my-pi-distillation.md +322 -0
  21. package/docs/research-optimization-plan.md +548 -548
  22. package/docs/research-phase10-distillation.md +198 -198
  23. package/docs/research-phase11-distillation.md +201 -201
  24. package/docs/research-pi-coding-agent.md +357 -357
  25. package/docs/research-source-pi-crew-reference.md +174 -174
  26. package/docs/runtime-flow.md +148 -148
  27. package/docs/source-runtime-refactor-map.md +107 -83
  28. package/docs/usage.md +3 -3
  29. package/index.ts +6 -6
  30. package/install.mjs +52 -8
  31. package/package.json +1 -1
  32. package/schema.json +2 -1
  33. package/skills/async-worker-recovery/SKILL.md +42 -0
  34. package/skills/context-artifact-hygiene/SKILL.md +52 -0
  35. package/skills/delegation-patterns/SKILL.md +54 -0
  36. package/skills/mailbox-interactive/SKILL.md +40 -0
  37. package/skills/model-routing-context/SKILL.md +39 -0
  38. package/skills/multi-perspective-review/SKILL.md +58 -0
  39. package/skills/observability-reliability/SKILL.md +41 -0
  40. package/skills/ownership-session-security/SKILL.md +41 -0
  41. package/skills/pi-extension-lifecycle/SKILL.md +39 -0
  42. package/skills/requirements-to-task-packet/SKILL.md +63 -0
  43. package/skills/resource-discovery-config/SKILL.md +41 -0
  44. package/skills/runtime-state-reader/SKILL.md +44 -0
  45. package/skills/secure-agent-orchestration-review/SKILL.md +45 -0
  46. package/skills/state-mutation-locking/SKILL.md +42 -0
  47. package/skills/systematic-debugging/SKILL.md +67 -0
  48. package/skills/ui-render-performance/SKILL.md +39 -0
  49. package/skills/verification-before-done/SKILL.md +57 -0
  50. package/skills/worktree-isolation/SKILL.md +39 -0
  51. package/src/agents/agent-serializer.ts +34 -34
  52. package/src/agents/discover-agents.ts +12 -11
  53. package/src/config/config.ts +48 -24
  54. package/src/config/defaults.ts +14 -0
  55. package/src/extension/cross-extension-rpc.ts +82 -82
  56. package/src/extension/project-init.ts +62 -2
  57. package/src/extension/register.ts +11 -9
  58. package/src/extension/registration/commands.ts +32 -25
  59. package/src/extension/registration/compaction-guard.ts +125 -125
  60. package/src/extension/registration/subagent-helpers.ts +8 -0
  61. package/src/extension/registration/subagent-tools.ts +149 -148
  62. package/src/extension/registration/team-tool.ts +8 -6
  63. package/src/extension/run-bundle-schema.ts +89 -89
  64. package/src/extension/run-index.ts +13 -5
  65. package/src/extension/run-maintenance.ts +62 -43
  66. package/src/extension/team-tool/api.ts +25 -8
  67. package/src/extension/team-tool/cancel.ts +33 -4
  68. package/src/extension/team-tool/context.ts +5 -0
  69. package/src/extension/team-tool/handle-settings.ts +188 -188
  70. package/src/extension/team-tool/inspect.ts +41 -41
  71. package/src/extension/team-tool/lifecycle-actions.ts +91 -79
  72. package/src/extension/team-tool/plan.ts +19 -19
  73. package/src/extension/team-tool/respond.ts +37 -17
  74. package/src/extension/team-tool/run.ts +52 -10
  75. package/src/extension/team-tool/status.ts +12 -1
  76. package/src/extension/team-tool-types.ts +2 -0
  77. package/src/extension/team-tool.ts +32 -11
  78. package/src/i18n.ts +184 -184
  79. package/src/observability/event-to-metric.ts +8 -1
  80. package/src/observability/exporters/otlp-exporter.ts +77 -77
  81. package/src/prompt/prompt-runtime.ts +72 -72
  82. package/src/runtime/agent-control.ts +63 -63
  83. package/src/runtime/agent-memory.ts +72 -72
  84. package/src/runtime/agent-observability.ts +114 -114
  85. package/src/runtime/async-marker.ts +26 -26
  86. package/src/runtime/attention-events.ts +28 -28
  87. package/src/runtime/background-runner.ts +59 -53
  88. package/src/runtime/cancellation.ts +51 -0
  89. package/src/runtime/child-pi.ts +457 -444
  90. package/src/runtime/completion-guard.ts +190 -190
  91. package/src/runtime/crash-recovery.ts +1 -0
  92. package/src/runtime/crew-agent-records.ts +38 -6
  93. package/src/runtime/deadletter.ts +1 -0
  94. package/src/runtime/delivery-coordinator.ts +46 -25
  95. package/src/runtime/direct-run.ts +35 -35
  96. package/src/runtime/effectiveness.ts +76 -0
  97. package/src/runtime/foreground-control.ts +82 -82
  98. package/src/runtime/green-contract.ts +46 -46
  99. package/src/runtime/group-join.ts +106 -106
  100. package/src/runtime/heartbeat-gradient.ts +28 -28
  101. package/src/runtime/heartbeat-watcher.ts +124 -124
  102. package/src/runtime/live-agent-control.ts +88 -87
  103. package/src/runtime/live-agent-manager.ts +103 -85
  104. package/src/runtime/live-control-realtime.ts +36 -36
  105. package/src/runtime/live-session-runtime.ts +309 -305
  106. package/src/runtime/manifest-cache.ts +17 -2
  107. package/src/runtime/model-fallback.ts +6 -4
  108. package/src/runtime/parallel-research.ts +44 -44
  109. package/src/runtime/pi-args.ts +18 -3
  110. package/src/runtime/pi-json-output.ts +111 -111
  111. package/src/runtime/policy-engine.ts +79 -79
  112. package/src/runtime/process-status.ts +5 -1
  113. package/src/runtime/progress-event-coalescer.ts +43 -43
  114. package/src/runtime/recovery-recipes.ts +74 -74
  115. package/src/runtime/retry-executor.ts +81 -64
  116. package/src/runtime/role-permission.ts +39 -39
  117. package/src/runtime/runtime-resolver.ts +22 -6
  118. package/src/runtime/session-resources.ts +25 -25
  119. package/src/runtime/session-snapshot.ts +59 -59
  120. package/src/runtime/session-usage.ts +79 -79
  121. package/src/runtime/sidechain-output.ts +29 -29
  122. package/src/runtime/skill-instructions.ts +222 -0
  123. package/src/runtime/stale-reconciler.ts +4 -14
  124. package/src/runtime/subagent-manager.ts +3 -0
  125. package/src/runtime/supervisor-contact.ts +59 -59
  126. package/src/runtime/task-display.ts +38 -38
  127. package/src/runtime/task-output-context.ts +127 -127
  128. package/src/runtime/task-runner/capabilities.ts +78 -0
  129. package/src/runtime/task-runner/live-executor.ts +105 -101
  130. package/src/runtime/task-runner/progress.ts +119 -119
  131. package/src/runtime/task-runner/prompt-builder.ts +3 -1
  132. package/src/runtime/task-runner/prompt-pipeline.ts +64 -0
  133. package/src/runtime/task-runner/result-utils.ts +14 -14
  134. package/src/runtime/task-runner/state-helpers.ts +22 -22
  135. package/src/runtime/task-runner.ts +44 -5
  136. package/src/runtime/team-runner.ts +78 -15
  137. package/src/runtime/worker-heartbeat.ts +21 -21
  138. package/src/runtime/worker-startup.ts +57 -57
  139. package/src/schema/config-schema.ts +1 -0
  140. package/src/schema/team-tool-schema.ts +3 -3
  141. package/src/state/active-run-registry.ts +165 -0
  142. package/src/state/contracts.ts +1 -1
  143. package/src/state/mailbox.ts +44 -4
  144. package/src/state/state-store.ts +8 -1
  145. package/src/state/task-claims.ts +44 -44
  146. package/src/state/types.ts +44 -2
  147. package/src/state/usage.ts +29 -29
  148. package/src/subagents/async-entry.ts +1 -1
  149. package/src/subagents/index.ts +3 -3
  150. package/src/subagents/live/control.ts +1 -1
  151. package/src/subagents/live/manager.ts +1 -1
  152. package/src/subagents/live/realtime.ts +1 -1
  153. package/src/subagents/live/session-runtime.ts +1 -1
  154. package/src/subagents/manager.ts +1 -1
  155. package/src/subagents/spawn.ts +1 -1
  156. package/src/teams/team-config.ts +1 -0
  157. package/src/teams/team-serializer.ts +38 -38
  158. package/src/types/diff.d.ts +18 -18
  159. package/src/ui/crew-footer.ts +101 -101
  160. package/src/ui/crew-select-list.ts +111 -111
  161. package/src/ui/crew-widget.ts +4 -3
  162. package/src/ui/dashboard-panes/metrics-pane.ts +34 -34
  163. package/src/ui/dashboard-panes/progress-pane.ts +2 -0
  164. package/src/ui/dynamic-border.ts +25 -25
  165. package/src/ui/layout-primitives.ts +106 -106
  166. package/src/ui/loaders.ts +158 -158
  167. package/src/ui/render-diff.ts +119 -119
  168. package/src/ui/render-scheduler.ts +143 -143
  169. package/src/ui/run-snapshot-cache.ts +10 -2
  170. package/src/ui/snapshot-types.ts +2 -0
  171. package/src/ui/spinner.ts +17 -17
  172. package/src/ui/status-colors.ts +58 -58
  173. package/src/ui/syntax-highlight.ts +116 -116
  174. package/src/utils/atomic-write.ts +33 -33
  175. package/src/utils/completion-dedupe.ts +63 -63
  176. package/src/utils/frontmatter.ts +68 -68
  177. package/src/utils/git.ts +262 -262
  178. package/src/utils/ids.ts +12 -12
  179. package/src/utils/names.ts +27 -27
  180. package/src/utils/paths.ts +4 -2
  181. package/src/utils/redaction.ts +44 -44
  182. package/src/utils/safe-paths.ts +47 -47
  183. package/src/utils/sleep.ts +32 -32
  184. package/src/workflows/validate-workflow.ts +40 -40
  185. package/src/workflows/workflow-config.ts +1 -0
  186. package/src/worktree/branch-freshness.ts +45 -45
  187. package/teams/default.team.md +12 -12
  188. package/teams/fast-fix.team.md +11 -11
  189. package/teams/implementation.team.md +18 -18
  190. package/teams/parallel-research.team.md +14 -14
  191. package/teams/research.team.md +11 -11
  192. package/teams/review.team.md +12 -12
  193. package/workflows/default.workflow.md +29 -29
  194. package/workflows/fast-fix.workflow.md +22 -22
  195. package/workflows/implementation.workflow.md +38 -38
  196. package/workflows/parallel-research.workflow.md +46 -46
  197. package/workflows/research.workflow.md +22 -22
  198. package/workflows/review.workflow.md +30 -30
@@ -0,0 +1,322 @@
1
+ # oh-my-pi Distillation for pi-crew
2
+
3
+ Date: 2026-05-05
4
+ Source repo: `Source/oh-my-pi` at `1d898a7fe chore: bump version to 14.5.3`.
5
+
6
+ ## Scope Read
7
+
8
+ Read-only exploration covered four source areas:
9
+
10
+ - Agent/provider runtime: `packages/agent`, `packages/ai`.
11
+ - Main CLI/session/task implementation: `packages/coding-agent`.
12
+ - TUI, extensions, hooks, skills, marketplace, rulebook docs and implementation.
13
+ - Native/Rust reliability/performance/release docs and implementation.
14
+
15
+ Representative files and docs inspected:
16
+
17
+ - `packages/agent/src/agent-loop.ts`, `packages/agent/src/agent.ts`, `packages/agent/src/types.ts`.
18
+ - `packages/ai/src/stream.ts`, `packages/ai/src/model-manager.ts`, `packages/ai/src/utils/{abort,retry,event-stream,overflow}.ts`, provider adapters.
19
+ - `packages/coding-agent/src/session/*`, `src/extensibility/{hooks,slash-commands,skills,plugins}/*`, `src/task/*`, `src/edit/*`, prompts.
20
+ - `packages/tui/src/tui.ts`, `docs/tui*.md`, `docs/extensions.md`, `docs/hooks.md`, `docs/skills.md`, `docs/marketplace.md`, `docs/rulebook-matching-pipeline.md`.
21
+ - `crates/pi-natives/src/{task,shell,pty,fs_cache,glob,fd,grep}.rs`, natives docs, install/release scripts.
22
+
23
+ This document rewrites the useful ideas as pi-crew-native patterns. It does not vendor or copy source code.
24
+
25
+ ## High-Value Patterns to Adopt
26
+
27
+ ### 1. Separate durable run history from provider/model context
28
+
29
+ oh-my-pi keeps rich internal session messages separate from LLM-compatible provider messages. Custom events, UI messages, hook entries, and branch/compaction entries can live in durable history, while a conversion layer decides what reaches the model.
30
+
31
+ pi-crew application:
32
+
33
+ - Keep `TeamRunManifest`, task records, mailbox messages, artifacts, worker events, and review/verification notes as durable run history.
34
+ - Add a projection/conversion step before worker prompt/model invocation:
35
+ - `transformRunContextBeforeWorkerStart(...)` for pruning/context injection.
36
+ - `convertRunHistoryToWorkerPrompt(...)` for provider/child-Pi compatible text.
37
+ - Avoid treating UI/runtime events as prompt text by default.
38
+
39
+ Benefit: safer compaction, mailbox summarization, and artifact hygiene without losing durable audit history.
40
+
41
+ ### 2. Distinguish steering from follow-up
42
+
43
+ oh-my-pi's agent runtime distinguishes interrupting current work (`steer`) from continuing after the agent would otherwise stop (`followUp`).
44
+
45
+ pi-crew application:
46
+
47
+ - Model leader/operator messages as two queues:
48
+ - `steeringQueue`: urgent cancellation, nudge, priority change, user answer while worker is active.
49
+ - `followUpQueue`: review/verification/documentation after a task reaches a natural stop.
50
+ - Default to one-at-a-time delivery to reduce context shock.
51
+ - Persist queue entries and delivery status in task mailbox/state.
52
+
53
+ Benefit: clearer interactive semantics than a single generic respond/resume path.
54
+
55
+ ### 3. Preserve invariants on cancellation and abort
56
+
57
+ oh-my-pi propagates `AbortSignal` through model streaming and tool execution, distinguishes caller abort from provider-local watchdog abort, and emits synthetic tool results when abort happens after tool calls were started.
58
+
59
+ pi-crew application:
60
+
61
+ - Use structured cancel reasons:
62
+ - `caller_cancelled`
63
+ - `leader_interrupted`
64
+ - `provider_timeout`
65
+ - `worker_timeout`
66
+ - `tool_timeout`
67
+ - `shutdown`
68
+ - If a worker/tool/action has started but is cancelled, emit a terminal synthetic event/result so task history has no dangling operation.
69
+ - Add non-abortable cleanup/finalize phases for artifact preservation and state unlock.
70
+
71
+ Benefit: fewer stuck `running` tasks and clearer recovery after cancellation.
72
+
73
+ ### 4. Batch-aware execution with shared vs exclusive operations
74
+
75
+ oh-my-pi marks tools with concurrency semantics: shared tools can run concurrently, exclusive tools serialize around shared/exclusive peers, and queued tools can be skipped when steering arrives.
76
+
77
+ pi-crew application:
78
+
79
+ - Classify worker subtasks or internal operations:
80
+ - shared: read-only exploration, status, grep, artifact reads.
81
+ - exclusive: edits, package manifests, lockfiles, migration/schema updates, worktree merge.
82
+ - Attach `batchId`, `index`, `total`, and `conflictKey` metadata to task execution.
83
+ - On new steering, skip not-yet-started low-priority operations with explicit skip reason.
84
+
85
+ Benefit: safer parallelism and more auditable conflict handling.
86
+
87
+ ### 5. Intent tracing for destructive/tool actions
88
+
89
+ oh-my-pi optionally injects an intent field into tool schemas, strips it before execution, and keeps it for auditability.
90
+
91
+ pi-crew application:
92
+
93
+ - Add optional `_intent`/`intent` metadata to worker tool/action events.
94
+ - Require intent for destructive actions: cancel, delete, prune, force cleanup, edits, package publish, worktree removal.
95
+ - Store intent in events/artifacts but never pass it to low-level execution APIs if not needed.
96
+
97
+ Benefit: reviewable why/what for high-risk actions without changing execution payloads.
98
+
99
+ ### 6. Event-first UI with tiny component contract and coalesced rendering
100
+
101
+ oh-my-pi TUI uses small components (`render(width)`, `handleInput`, `invalidate`) and event-driven, coalesced rendering. Components must be width-safe and lifecycle-clean.
102
+
103
+ pi-crew application:
104
+
105
+ - Keep dashboards/widgets as projections from snapshot/event state, not direct filesystem scanners.
106
+ - Continue using render scheduler/coalescing; add width-safety tests for all dashboard panes/widgets.
107
+ - Components should expose `dispose()` for timers/theme subscriptions.
108
+ - UI event stream should be semantic (`task_started`, `worker_status`, `mailbox_updated`) rather than raw file polling.
109
+
110
+ Benefit: avoids UI freezes and makes live views predictable.
111
+
112
+ ### 7. Two-phase extension lifecycle
113
+
114
+ oh-my-pi extensions have a registration phase where side-effecting runtime methods are unavailable, followed by an initialized phase with real context/actions.
115
+
116
+ pi-crew application:
117
+
118
+ - If pi-crew grows plugin/extension support, split APIs into:
119
+ - `registerCrewExtension(api)`: declare teams, workflows, hooks, commands, renderers.
120
+ - `initializeCrewExtension(context)`: subscribe to events, perform side effects.
121
+ - In headless mode, UI APIs should be explicit no-ops or unavailable via `hasUI`.
122
+ - Loader should collect extension errors without breaking builtin teams.
123
+
124
+ Benefit: fewer load-time side effects and safer third-party extensibility.
125
+
126
+ ### 8. Unified capability inventory/control center
127
+
128
+ oh-my-pi normalizes extensions, skills, rules, tools, hooks, MCPs, prompts, and slash commands into a shared dashboard model with active/disabled/shadowed states.
129
+
130
+ pi-crew application:
131
+
132
+ - Extend `/team-settings` or add `/team-control` to show a unified inventory:
133
+ - teams, workflows, agents, skills, hooks/policies, tools, runtime providers.
134
+ - Normalize each item to:
135
+ - `id`, `kind`, `name`, `description`, `source`, `path`, `state`, `disabledReason`, `shadowedBy`, `raw`.
136
+ - Persist disables by stable capability ID, not file path.
137
+
138
+ Benefit: better operator experience for complex multi-resource setups.
139
+
140
+ ### 9. Hooks as typed lifecycle gates, not ad-hoc shell glue
141
+
142
+ oh-my-pi hooks cover session lifecycle, before-agent-start, tool-call gates, tool-result transforms, and compaction events. Blocking hooks are scoped; non-blocking hook errors are captured but do not crash streaming.
143
+
144
+ pi-crew application:
145
+
146
+ - Define typed crew hooks:
147
+ - `before_run_start`
148
+ - `before_task_start`
149
+ - `task_result`
150
+ - `before_cancel`
151
+ - `before_publish`
152
+ - `session_before_switch`
153
+ - `run_recovery`
154
+ - Mark hooks as blocking or non-blocking.
155
+ - Capture hook errors into diagnostics/status, not uncontrolled exceptions.
156
+
157
+ Benefit: safer customization for policy/security/release gates.
158
+
159
+ ### 10. Prompt pipeline should be explicit
160
+
161
+ oh-my-pi applies slash/custom commands, templates, compaction, file mentions, hook injection, and model validation in a clear order before calling the agent.
162
+
163
+ pi-crew application:
164
+
165
+ Define a worker prompt pipeline:
166
+
167
+ 1. Parse orchestration command/control intent.
168
+ 2. Expand prompt templates/task packet.
169
+ 3. Attach selected context/artifact/mailbox summaries.
170
+ 4. Run `before_worker_start` hooks.
171
+ 5. Persist exact task packet/artifacts.
172
+ 6. Launch worker.
173
+
174
+ Benefit: reproducible worker prompts and easier debugging of context injection.
175
+
176
+ ### 11. Session/run history as append-only tree
177
+
178
+ oh-my-pi persists session entries with parent relationships. Branching/forking moves the current leaf rather than rewriting past history.
179
+
180
+ pi-crew application:
181
+
182
+ - Keep `events.jsonl` append-only and add optional `parentEventId` / `attemptId` / `branchId` fields for retries/forks.
183
+ - Represent retry attempts as child branches from the original task prompt/result.
184
+ - Preserve old failed attempts instead of overwriting task state only.
185
+
186
+ Benefit: better auditability and replay/debug of retries.
187
+
188
+ ### 12. Cooperative cancellation token for long loops
189
+
190
+ oh-my-pi native code uses cancel tokens with deadlines, abort signals, `heartbeat()`, and async wait. Long loops over external-size input must heartbeat at bounded cadence.
191
+
192
+ pi-crew application:
193
+
194
+ - Add a TS `CancellationToken` utility for internal long-running loops:
195
+ - `heartbeat(stage?: string)`
196
+ - `throwIfCancelled()`
197
+ - `wait()`
198
+ - `abort(reason)`
199
+ - Require it in scanners over runs, artifacts, mailboxes, worktrees, and event logs.
200
+
201
+ Benefit: bounded shutdown/cancel latency and easier stuck-loop diagnostics.
202
+
203
+ ### 13. Process lifecycle: graceful cancel, forced kill, then non-reuse
204
+
205
+ oh-my-pi shell/PTY runtime cancels gracefully, waits a grace window, forces abort/kill, drains output for bounded windows, and discards persistent sessions after cancellation/errors.
206
+
207
+ pi-crew application:
208
+
209
+ - For child Pi workers:
210
+ - send graceful abort/TERM;
211
+ - wait `graceMs`;
212
+ - force-kill process tree;
213
+ - drain stdout/stderr for bounded time;
214
+ - mark session non-reusable after timeout/protocol error/cancel.
215
+ - Return typed status `{ exitCode, cancelled, timedOut, killed, cleanupErrors }`.
216
+
217
+ Benefit: more deterministic worker cleanup and fewer zombie/stale runs.
218
+
219
+ ### 14. Reserve control channel before async worker start
220
+
221
+ oh-my-pi PTY reserves its control channel before async process start, rejects duplicate starts, and always clears state in completion.
222
+
223
+ pi-crew application:
224
+
225
+ - Install a `WorkerRunCore`/controller synchronously before spawn returns.
226
+ - Expose cancel/steer immediately, even while startup is still in progress.
227
+ - Clear controller in `finally` and persist terminal state.
228
+
229
+ Benefit: closes race windows where operator cannot cancel a starting worker.
230
+
231
+ ### 15. Cache scan entries, not final query results
232
+
233
+ oh-my-pi native search caches directory entries and applies query-specific filters/scoring later. Empty stale caches trigger rescan; ordering is deterministic.
234
+
235
+ pi-crew application:
236
+
237
+ - For run/artifact/mailbox discovery, cache raw entries/stats rather than final UI results.
238
+ - Apply active-status/mailbox/health filters after cache retrieval.
239
+ - Invalidate cache after state mutation.
240
+ - Use deterministic sort keys for dashboards and summaries.
241
+
242
+ Benefit: faster UI/status with fewer stale semantic bugs.
243
+
244
+ ### 16. Blob artifacts and bounded file access
245
+
246
+ oh-my-pi blob-artifact design uses content addressing, metadata sidecars, streaming writes, size budgets, manifest GC, and path whitelisting.
247
+
248
+ pi-crew application:
249
+
250
+ - Introduce content-addressed large artifacts for worker transcripts/screenshots/log chunks.
251
+ - Persist metadata sidecars with MIME, source, redaction, run/task IDs, size, hash.
252
+ - Keep task prompts/results small by referencing artifact IDs.
253
+ - Add GC tied to run retention.
254
+
255
+ Benefit: avoids bloating task JSON/events and improves artifact security.
256
+
257
+ ### 17. Native/release verification checklist mindset
258
+
259
+ oh-my-pi release scripts emphasize multi-platform build artifacts, install smoke tests, spoofed-version checks, and runtime loader fallback diagnostics.
260
+
261
+ pi-crew application:
262
+
263
+ - For npm releases, keep a release checklist with:
264
+ - typecheck;
265
+ - unit/integration tests;
266
+ - `npm pack --dry-run`;
267
+ - install from packed tarball in temp project;
268
+ - Pi extension load smoke;
269
+ - version/tag/npm consistency check.
270
+
271
+ Benefit: fewer broken published packages.
272
+
273
+ ## Skill/Rulebook Ideas to Port
274
+
275
+ oh-my-pi's skills/rulebook ecosystem suggests additional pi-crew resources:
276
+
277
+ 1. `worker-prompt-pipeline` skill: prompt assembly, context projection, before-worker hooks, artifact references.
278
+ 2. `typed-hook-design` skill: lifecycle gates, blocking vs non-blocking hooks, diagnostics.
279
+ 3. `process-cancellation-contract` skill: graceful/force kill, synthetic terminal results, non-reuse.
280
+ 4. `capability-inventory-ux` skill: normalized resource inventory and disable/shadow semantics.
281
+ 5. `append-only-run-history` skill: event tree, branch/retry provenance.
282
+
283
+ ## Prioritized Backlog for pi-crew
284
+
285
+ ### P0 / High confidence
286
+
287
+ - Fix current runtime review findings first: waiting final status, respond semantics, no-registry model routing.
288
+ - Add structured cancellation reason and terminal synthetic result/event for cancelled workers.
289
+ - Centralize worker prompt pipeline and persist exact prompt packets.
290
+ - Add width-safety tests for dashboard/widget lines.
291
+
292
+ ### P1 / Medium-term architecture
293
+
294
+ - Add steering vs follow-up mailbox queues.
295
+ - Add typed hook lifecycle for `before_task_start`, `task_result`, `before_cancel`, `session_before_switch`.
296
+ - Add capability inventory model for teams/workflows/agents/skills/hooks/tools.
297
+ - Add `CancellationToken` for long internal loops and scans.
298
+
299
+ ### P2 / Larger subsystem work
300
+
301
+ - Append-only run-history tree with attempt/branch parentage.
302
+ - Content-addressed blob artifact store with metadata sidecars and GC.
303
+ - Worker process controller installed before spawn; process non-reuse after cancel/protocol error.
304
+ - Raw scan-entry cache shared by dashboard/status/artifact lookup.
305
+
306
+ ## Anti-Patterns to Avoid
307
+
308
+ - Building prompts from scattered inline string concatenation without a traceable pipeline.
309
+ - Treating UI render as a place to perform heavy filesystem scans.
310
+ - Auto-opening modal/right-sidebar UI by default when a compact widget/status line would suffice.
311
+ - Dropping queued user-facing results just because session generation changed.
312
+ - Cancelling a task without writing a terminal event/result.
313
+ - Caching semantic query results that should be recomputed from raw state.
314
+ - Letting one bad extension/resource prevent builtin operation.
315
+
316
+ ## Immediate Review Questions for Future Implementation
317
+
318
+ - Should pi-crew project-local skills be allowed to shadow builtin safety skills by default, or require explicit `project:` namespace?
319
+ - Should `respond` enqueue durable work or only deliver to live workers? Current semantics need to become explicit.
320
+ - What is the stable capability ID scheme for teams/workflows/agents/skills/hooks?
321
+ - Which hook events should be blocking by default and which should be diagnostic-only?
322
+ - What artifact size threshold should trigger blob storage instead of embedding content in task/events JSON?