pi-crew 0.5.2 → 0.5.6

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 (137) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/README.md +17 -1
  3. package/docs/architecture.md +2 -0
  4. package/docs/bugs/cross-session-notification-leakage.md +82 -0
  5. package/docs/coding-agent-optimization.md +268 -0
  6. package/docs/deep-review-report.md +384 -0
  7. package/docs/distillation/cybersecurity-patterns.md +294 -0
  8. package/docs/migration-v0.4-v0.5.md +208 -0
  9. package/docs/optimization-plan.md +642 -0
  10. package/docs/pi-crew-v0.5.5-audit-fix-plan.md +133 -0
  11. package/docs/pi-mono-opportunities.md +969 -0
  12. package/docs/pi-mono-review.md +291 -0
  13. package/docs/skills/REFERENCE.md +144 -0
  14. package/package.json +12 -9
  15. package/skills/artifact-analysis-loop/SKILL.md +302 -0
  16. package/skills/async-worker-recovery/SKILL.md +19 -1
  17. package/skills/child-pi-spawning/SKILL.md +19 -6
  18. package/skills/context-artifact-hygiene/SKILL.md +19 -2
  19. package/skills/delegation-patterns/SKILL.md +68 -3
  20. package/skills/detection-pipeline-design/SKILL.md +285 -0
  21. package/skills/event-log-tracing/SKILL.md +20 -6
  22. package/skills/git-master/SKILL.md +20 -6
  23. package/skills/hunting-investigation-loop/SKILL.md +401 -0
  24. package/skills/incident-playbook-construction/SKILL.md +383 -0
  25. package/skills/live-agent-lifecycle/SKILL.md +20 -6
  26. package/skills/mailbox-interactive/SKILL.md +19 -6
  27. package/skills/model-routing-context/SKILL.md +19 -1
  28. package/skills/multi-perspective-review/SKILL.md +19 -4
  29. package/skills/observability-reliability/SKILL.md +19 -2
  30. package/skills/orchestration/SKILL.md +20 -2
  31. package/skills/ownership-session-security/SKILL.md +20 -2
  32. package/skills/pi-extension-lifecycle/SKILL.md +20 -2
  33. package/skills/post-mortem/SKILL.md +7 -2
  34. package/skills/read-only-explorer/SKILL.md +20 -6
  35. package/skills/requirements-to-task-packet/SKILL.md +23 -3
  36. package/skills/resource-discovery-config/SKILL.md +20 -2
  37. package/skills/runtime-state-reader/SKILL.md +20 -2
  38. package/skills/safe-bash/SKILL.md +21 -6
  39. package/skills/scrutinize/SKILL.md +20 -2
  40. package/skills/secure-agent-orchestration-review/SKILL.md +29 -2
  41. package/skills/security-review/SKILL.md +560 -0
  42. package/skills/state-mutation-locking/SKILL.md +22 -2
  43. package/skills/systematic-debugging/SKILL.md +8 -6
  44. package/skills/threat-hypothesis-framework/SKILL.md +175 -0
  45. package/skills/ui-render-performance/SKILL.md +20 -2
  46. package/skills/verification-before-done/SKILL.md +17 -2
  47. package/skills/widget-rendering/SKILL.md +21 -6
  48. package/skills/workspace-isolation/SKILL.md +20 -6
  49. package/skills/worktree-isolation/SKILL.md +20 -6
  50. package/src/agents/agent-config.ts +40 -1
  51. package/src/benchmark/benchmark-runner.ts +45 -0
  52. package/src/benchmark/feedback-loop.ts +5 -0
  53. package/src/config/config.ts +32 -5
  54. package/src/config/role-tools.ts +82 -0
  55. package/src/config/suggestions.ts +8 -0
  56. package/src/config/types.ts +4 -0
  57. package/src/extension/async-notifier.ts +10 -1
  58. package/src/extension/crew-cleanup.ts +114 -0
  59. package/src/extension/cross-extension-rpc.ts +1 -1
  60. package/src/extension/notification-router.ts +18 -0
  61. package/src/extension/register.ts +27 -19
  62. package/src/extension/registration/subagent-tools.ts +1 -1
  63. package/src/extension/team-tool/anchor.ts +201 -0
  64. package/src/extension/team-tool/api.ts +2 -1
  65. package/src/extension/team-tool/auto-summarize.ts +154 -0
  66. package/src/extension/team-tool/run.ts +42 -7
  67. package/src/extension/team-tool.ts +44 -2
  68. package/src/hooks/registry.ts +1 -3
  69. package/src/observability/event-bus.ts +69 -0
  70. package/src/observability/event-to-metric.ts +0 -2
  71. package/src/runtime/anchor-manager.ts +473 -0
  72. package/src/runtime/async-runner.ts +8 -4
  73. package/src/runtime/auto-summarize.ts +350 -0
  74. package/src/runtime/background-runner.ts +10 -3
  75. package/src/runtime/budget-tracker.ts +354 -0
  76. package/src/runtime/chain-runner.ts +507 -0
  77. package/src/runtime/child-pi.ts +123 -35
  78. package/src/runtime/crash-recovery.ts +5 -4
  79. package/src/runtime/crew-agent-runtime.ts +1 -0
  80. package/src/runtime/custom-tools/irc-tool.ts +13 -0
  81. package/src/runtime/custom-tools/submit-result-tool.ts +3 -2
  82. package/src/runtime/delivery-coordinator.ts +10 -3
  83. package/src/runtime/dynamic-script-runner.ts +482 -0
  84. package/src/runtime/foreground-control.ts +87 -17
  85. package/src/runtime/handoff-manager.ts +589 -0
  86. package/src/runtime/hidden-handoff.ts +424 -0
  87. package/src/runtime/live-agent-manager.ts +20 -4
  88. package/src/runtime/live-session-runtime.ts +39 -4
  89. package/src/runtime/manifest-cache.ts +2 -1
  90. package/src/runtime/model-resolver.ts +16 -4
  91. package/src/runtime/phase-tracker.ts +373 -0
  92. package/src/runtime/pi-args.ts +11 -1
  93. package/src/runtime/pi-json-output.ts +31 -0
  94. package/src/runtime/pipeline-runner.ts +514 -0
  95. package/src/runtime/progress-tracker.ts +124 -0
  96. package/src/runtime/retry-runner.ts +354 -0
  97. package/src/runtime/sandbox.ts +252 -0
  98. package/src/runtime/scheduler.ts +7 -2
  99. package/src/runtime/skill-effectiveness.ts +473 -0
  100. package/src/runtime/skill-instructions.ts +37 -3
  101. package/src/runtime/subagent-manager.ts +1 -1
  102. package/src/runtime/task-graph.ts +11 -1
  103. package/src/runtime/task-runner.ts +92 -18
  104. package/src/runtime/team-runner.ts +13 -12
  105. package/src/runtime/tool-progress.ts +10 -3
  106. package/src/runtime/verification-gates.ts +367 -0
  107. package/src/schema/team-tool-schema.ts +37 -0
  108. package/src/skills/discover-skills.ts +5 -0
  109. package/src/state/active-run-registry.ts +9 -2
  110. package/src/state/contracts.ts +9 -0
  111. package/src/state/crew-init.ts +3 -3
  112. package/src/state/decision-ledger.ts +98 -55
  113. package/src/state/event-log-rotation.ts +2 -2
  114. package/src/state/event-log.ts +144 -10
  115. package/src/state/hook-instinct-bridge.ts +5 -5
  116. package/src/state/mailbox.ts +10 -0
  117. package/src/state/run-cache.ts +18 -8
  118. package/src/state/state-store.ts +3 -1
  119. package/src/state/types.ts +4 -0
  120. package/src/tools/safe-bash-extension.ts +1 -0
  121. package/src/tools/safe-bash.ts +152 -20
  122. package/src/types/new-api-types.ts +34 -0
  123. package/src/ui/agent-management-overlay.ts +5 -1
  124. package/src/ui/crew-widget.ts +29 -15
  125. package/src/ui/overlays/mailbox-detail-overlay.ts +13 -2
  126. package/src/ui/powerbar-publisher.ts +101 -7
  127. package/src/ui/tool-render.ts +15 -15
  128. package/src/ui/transcript-cache.ts +13 -0
  129. package/src/utils/bm25-search.ts +16 -8
  130. package/src/utils/env-filter.ts +8 -5
  131. package/src/utils/redaction.ts +169 -15
  132. package/src/utils/session-utils.ts +52 -0
  133. package/src/utils/sse-parser.ts +10 -1
  134. package/src/worktree/cleanup.ts +6 -1
  135. package/src/worktree/worktree-manager.ts +32 -13
  136. package/workflows/chain.workflow.md +252 -0
  137. package/workflows/pipeline.workflow.md +27 -0
@@ -0,0 +1,208 @@
1
+ # pi-crew Migration Guide: v0.4 → v0.5
2
+
3
+ **Author:** pi-crew team
4
+ **Date:** 2026-06-01
5
+ **Version:** 0.5.5
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ This guide covers breaking changes and new features introduced in v0.5.x.
12
+
13
+ ---
14
+
15
+ ## v0.5.5 Highlights (June 2026)
16
+
17
+ v0.5.5 closes 13 rounds of code review. The user-facing changes are:
18
+
19
+ - **Linear-time secret redaction** at all event/mailbox/artifact boundaries.
20
+ - **v8.deserialize hardened** with `BINARY_MAGIC` headers — old binaries are auto-discarded.
21
+ - **Adaptive implementation workflow** now has a single `assess` step; the planner picks the smallest effective crew.
22
+ - **Async-notifier debounce** of 30 s — completion notifications can be delayed by up to 30 s.
23
+ - **Mailbox delivery state capped at 10000 messages** — older entries are pruned FIFO.
24
+ - **Anchors cap at 50 with 100 handoffs each** — older handoffs are pruned FIFO.
25
+
26
+ No new public API is required for any of these changes. If you pinned a `BINARY_MAGIC`-guarded binary from a previous session, delete `~/.pi/agent/pi-crew/.cache/active-run-index.bin` once.
27
+
28
+ ## v0.5.4 → v0.5.5 Migration
29
+
30
+ No breaking changes. Drop-in replacement.
31
+
32
+ ## Breaking Changes
33
+
34
+ ### 1. Environment Variable Allowlist (Security)
35
+
36
+ **Before (v0.4):**
37
+ ```typescript
38
+ // Child Pi workers received ALL matching secrets
39
+ "*_API_KEY",
40
+ "*_TOKEN",
41
+ "*_SECRET",
42
+ ```
43
+
44
+ **After (v0.5):**
45
+ ```typescript
46
+ // Only explicit provider keys
47
+ "ANTHROPIC_API_KEY",
48
+ "OPENAI_API_KEY",
49
+ "GOOGLE_API_KEY",
50
+ // ...
51
+ ```
52
+
53
+ **Action Required:** If your workflows rely on custom environment variables with `*_API_KEY` patterns, you must now explicitly list them:
54
+ ```json
55
+ {
56
+ "piCrew": {
57
+ "runtime": {
58
+ "envAllowlist": ["MY_CUSTOM_API_KEY", "MY_OTHER_KEY"]
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ ---
65
+
66
+ ### 2. Mock Mode Requires Dual Environment Variables
67
+
68
+ **Before (v0.4):**
69
+ ```bash
70
+ PI_TEAMS_MOCK_CHILD_PI=success # Works silently
71
+ ```
72
+
73
+ **After (v0.5):**
74
+ ```bash
75
+ PI_TEAMS_MOCK_CHILD_PI=success
76
+ PI_CREW_ALLOW_MOCK=1 # Required for security
77
+ ```
78
+
79
+ **Action Required:** Update CI/CD and test scripts that use mock mode.
80
+
81
+ ---
82
+
83
+ ### 3. Skill Frontmatter Format
84
+
85
+ **Before (v0.4):**
86
+ ```yaml
87
+ ---
88
+ name: my-skill
89
+ description: "My skill description"
90
+ ---
91
+ ```
92
+
93
+ **After (v0.5):**
94
+ ```yaml
95
+ ---
96
+ name: my-skill
97
+ description: "My skill description"
98
+ triggers:
99
+ - "trigger phrase 1"
100
+ - "trigger phrase 2"
101
+ ---
102
+ ```
103
+
104
+ **Action Required:** Run `node scripts/check-all-skills.ts` to identify skills needing `triggers` field.
105
+
106
+ ---
107
+
108
+ ## New Features in v0.5
109
+
110
+ ### 1. Enhanced Security
111
+
112
+ - **Secure env allowlist**: Only explicit API keys passed to child processes
113
+ - **Mock mode protection**: Requires `PI_CREW_ALLOW_MOCK=1` alongside `PI_TEAMS_MOCK_CHILD_PI`
114
+ - **Worktree hook hardening**: Safer execution on Windows
115
+
116
+ ### 2. Improved Reliability
117
+
118
+ - **Terminal event durability**: Critical events (task.completed, task.failed) now bypass event buffering
119
+ - **Race condition fixes**: Foreground interrupt requests are now properly serialized
120
+ - **File descriptor cleanup**: Background runner properly closes log file descriptors
121
+
122
+ ### 3. Better Observability
123
+
124
+ - **Reduced cache TTL**: Manifest cache now expires in 30s instead of 5min for faster state updates
125
+ - **Decision ledger integrity**: Ledger entries are preserved during promote/decay operations
126
+
127
+ ### 4. Skill System
128
+
129
+ - **Standardized triggers**: All 35 built-in skills now have explicit trigger phrases
130
+ - **Enforcement gates**: Skills include checklist-based enforcement sections
131
+ - **Anti-patterns**: Most skills include anti-pattern documentation
132
+
133
+ ---
134
+
135
+ ## Configuration Changes
136
+
137
+ ### New Config Keys
138
+
139
+ | Key | Type | Default | Description |
140
+ |-----|------|---------|-------------|
141
+ | `limits.heartbeatStaleMs` | number | 30000 | Stale heartbeat threshold |
142
+ | `runtime.effectivenessGuard` | string | "off" | Effectiveness guard level |
143
+ | `runtime.completionMutationGuard` | string | "off" | Mutation guard level |
144
+
145
+ ### Deprecated Config Keys
146
+
147
+ None in v0.5.
148
+
149
+ ---
150
+
151
+ ## Workflow Migration
152
+
153
+ ### Updating Custom Agents
154
+
155
+ 1. Ensure agent files have `triggers` in frontmatter:
156
+ ```yaml
157
+ ---
158
+ name: my-agent
159
+ triggers:
160
+ - "my trigger"
161
+ ---
162
+ ```
163
+
164
+ 2. Verify agent is discovered:
165
+ ```bash
166
+ team action=list agent=my-agent
167
+ ```
168
+
169
+ ### Updating Custom Teams
170
+
171
+ 1. Validate team config:
172
+ ```bash
173
+ team action=validate resource=team name=my-team
174
+ ```
175
+
176
+ 2. Check for breaking changes in role/task definitions.
177
+
178
+ ---
179
+
180
+ ## Testing Checklist
181
+
182
+ After upgrading to v0.5:
183
+
184
+ - [ ] Run `team action=doctor` to verify configuration
185
+ - [ ] Run `node scripts/check-all-skills.ts` to verify skills
186
+ - [ ] Test mock mode with both env vars set
187
+ - [ ] Verify environment variables are properly filtered in child processes
188
+ - [ ] Test foreground interrupt (cancel) behavior
189
+ - [ ] Verify terminal events are properly logged
190
+
191
+ ---
192
+
193
+ ## Rollback
194
+
195
+ If issues occur after upgrade:
196
+
197
+ ```bash
198
+ # Revert to v0.4.x
199
+ pi install npm:pi-crew@0.4.x
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Support
205
+
206
+ - **Issues**: https://github.com/baphuongna/pi-crew/issues
207
+ - **Documentation**: [docs/](docs/)
208
+ - **Changelog**: [CHANGELOG.md](CHANGELOG.md)