pi-crew 0.8.13 → 0.9.0

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 (82) hide show
  1. package/CHANGELOG.md +296 -0
  2. package/README.md +118 -2
  3. package/docs/FEATURE_INTAKE.md +1 -1
  4. package/docs/HARNESS.md +20 -19
  5. package/docs/PROJECT_REVIEW.md +132 -133
  6. package/docs/PROJECT_REVIEW_FIXES.md +130 -131
  7. package/docs/actions-reference.md +127 -121
  8. package/docs/architecture.md +1 -1
  9. package/docs/code-review-2026-05-11.md +134 -134
  10. package/docs/commands-reference.md +108 -106
  11. package/docs/comparison-pi-subagents-vs-pi-crew.md +105 -105
  12. package/docs/deep-review-report.md +1 -1
  13. package/docs/dynamic-workflows.md +90 -0
  14. package/docs/fixes/BATCH_A_H1_H2.md +17 -17
  15. package/docs/fixes/bug-007-async-notifier-stale-ctx.md +23 -23
  16. package/docs/followup-plan-2026-05-12.md +135 -135
  17. package/docs/followup-review-2026-05-12.md +86 -86
  18. package/docs/followup-review-round3-2026-05-12.md +123 -123
  19. package/docs/goals.md +59 -0
  20. package/docs/implementation-plan-top3.md +4 -4
  21. package/docs/issue-29-analysis.md +2 -2
  22. package/docs/oh-my-pi-research.md +154 -154
  23. package/docs/optimization-plan.md +2 -0
  24. package/docs/perf/baseline-2026-05.md +9 -9
  25. package/docs/perf/final-report-2026-05.md +2 -2
  26. package/docs/perf/sprint-1-report.md +2 -2
  27. package/docs/perf/sprint-2-report.md +1 -1
  28. package/docs/perf/upgrade-plan-2026-05.md +72 -72
  29. package/docs/pi-crew-bugs.md +230 -230
  30. package/docs/pi-crew-investigation-report.md +102 -102
  31. package/docs/pi-crew-test-round5.md +4 -4
  32. package/docs/runtime-analysis-child-vs-live.md +57 -57
  33. package/docs/runtime-migration-in-process-analysis.md +97 -97
  34. package/install.mjs +3 -2
  35. package/package.json +2 -4
  36. package/skills/orchestration/SKILL.md +11 -11
  37. package/src/agents/agent-config.ts +4 -0
  38. package/src/config/config.ts +39 -0
  39. package/src/config/types.ts +11 -0
  40. package/src/extension/action-suggestions.ts +2 -1
  41. package/src/extension/async-notifier.ts +10 -0
  42. package/src/extension/help.ts +14 -0
  43. package/src/extension/project-init.ts +7 -20
  44. package/src/extension/registration/commands.ts +27 -0
  45. package/src/extension/team-tool/destructive-gate.ts +1 -1
  46. package/src/extension/team-tool/goal-wrap.ts +288 -0
  47. package/src/extension/team-tool/goal.ts +405 -0
  48. package/src/extension/team-tool/run.ts +103 -4
  49. package/src/extension/team-tool/workflow-manage.ts +194 -0
  50. package/src/extension/team-tool.ts +20 -0
  51. package/src/hooks/types.ts +3 -1
  52. package/src/runtime/async-runner.ts +24 -2
  53. package/src/runtime/background-runner.ts +68 -19
  54. package/src/runtime/child-pi.ts +6 -1
  55. package/src/runtime/completion-guard.ts +1 -1
  56. package/src/runtime/dynamic-workflow-context.ts +450 -0
  57. package/src/runtime/dynamic-workflow-runner.ts +180 -0
  58. package/src/runtime/global-worker-cap.ts +96 -0
  59. package/src/runtime/goal-evaluator.ts +294 -0
  60. package/src/runtime/goal-loop-runner.ts +612 -0
  61. package/src/runtime/goal-state-store.ts +209 -0
  62. package/src/runtime/pi-args.ts +10 -2
  63. package/src/runtime/result-extractor.ts +32 -0
  64. package/src/runtime/team-runner.ts +11 -1
  65. package/src/runtime/verification-gates.ts +85 -5
  66. package/src/runtime/verification-integrity.ts +110 -0
  67. package/src/runtime/verification-worktree.ts +136 -0
  68. package/src/runtime/workspace-lock.ts +448 -0
  69. package/src/schema/config-schema.ts +26 -0
  70. package/src/schema/team-tool-schema.ts +39 -4
  71. package/src/state/atomic-write.ts +9 -0
  72. package/src/state/contracts.ts +14 -0
  73. package/src/state/crew-init.ts +18 -5
  74. package/src/state/event-log.ts +7 -1
  75. package/src/state/state-store.ts +2 -0
  76. package/src/state/types.ts +82 -0
  77. package/src/state/worker-atomic-writer.ts +176 -0
  78. package/src/utils/redaction.ts +104 -24
  79. package/src/workflows/discover-workflows.ts +25 -1
  80. package/src/workflows/workflow-config.ts +13 -0
  81. package/teams/parallel-research.team.md +1 -1
  82. package/workflows/examples/hello.dwf.ts +24 -0
@@ -1,66 +1,66 @@
1
1
  # pi-crew Runtime Analysis: child-process vs live-session
2
2
 
3
- > Ngày: 2026-05-12
4
- > Trạng thái: Phân tích hiệu năng đề xuất chuyển default runtime
3
+ > Date: 2026-05-12
4
+ > Status: Performance analysisproposing a default runtime change
5
5
 
6
6
  ---
7
7
 
8
- ## 1. Vấn đề hiện tại
8
+ ## 1. Current problem
9
9
 
10
- pi-crew default runtime **child-process** — mỗi worker spawn một `pi` CLI child process riêng. Điều này gây:
10
+ pi-crew's default runtime is **child-process** — each worker spawns its own `pi` CLI child process. This causes:
11
11
 
12
12
  ### 1.1 Memory
13
13
 
14
- | Scenario | child-process | live-session | Tiết kiệm |
14
+ | Scenario | child-process | live-session | Savings |
15
15
  |---|---|---|---|
16
- | 1 worker | ~150 MB thêm | ~15 MB thêm | **135 MB** |
17
- | 4 workers (parallel) | ~600 MB thêm | ~60 MB thêm | **540 MB** |
18
- | 8 workers (max cap) | ~1.2 GB thêm | ~120 MB thêm | **~1.1 GB** |
16
+ | 1 worker | ~150 MB added | ~15 MB added | **135 MB** |
17
+ | 4 workers (parallel) | ~600 MB added | ~60 MB added | **540 MB** |
18
+ | 8 workers (max cap) | ~1.2 GB added | ~120 MB added | **~1.1 GB** |
19
19
 
20
- **Parent Pi process đã chiếm ~308 MB.** Thêm 4 child-process workers = **910 MB tổng**, gần 1 GB chỉ để chạy một team. Máy 8 GB RAM sẽ bắt đầu swap.
20
+ **The parent Pi process already consumes ~308 MB.** Adding 4 child-process workers brings the total to **910 MB**, nearly 1 GB just to run a single team. A machine with 8 GB of RAM will start swapping.
21
21
 
22
22
  ### 1.2 Startup latency
23
23
 
24
- | Giai đoạn | child-process | live-session |
24
+ | Stage | child-process | live-session |
25
25
  |---|---|---|
26
26
  | Process spawn | ~300ms | 0 |
27
27
  | Node.js bootstrap | ~500ms | 0 |
28
28
  | Pi CLI init + load extensions | ~1-2s | 0 |
29
- | pi-crew register() (chạy lại trong child) | ~200ms | 0 |
29
+ | pi-crew register() (runs again in child) | ~200ms | 0 |
30
30
  | createAgentSession() | ~100ms | ~100ms |
31
31
  | First LLM token | **2-4s total** | **200-500ms total** |
32
32
 
33
- **Mỗi worker mất 2-4s startup.** Team implementation 3 phases sequential × 2-4s = **6-12s chỉ để spawn processes**, trước khi bất kỳ công việc nào bắt đầu.
33
+ **Each worker takes 2-4s to start.** A team implementation with 3 sequential phases × 2-4s = **6-12s just to spawn processes**, before any work even begins.
34
34
 
35
35
  ### 1.3 CPU overhead
36
36
 
37
- - Mỗi child process chạy riêng V8 isolate → riêng JIT compiler, riêng GC
38
- - `pi-crew register()` chạy **lặp lại** trong mỗi child (load config, register tools, bind extensions)
39
- - JSON parsing/redaction trên child stdout → CPU cost cho mỗi event
37
+ - Each child process runs a separate V8 isolate → separate JIT compiler, separate GC
38
+ - `pi-crew register()` runs **repeatedly** in each child (load config, register tools, bind extensions)
39
+ - JSON parsing/redaction on child stdout → CPU cost per event
40
40
 
41
41
  ### 1.4 Complexity
42
42
 
43
- - `child-pi.ts` = 461 dòng chỉ để quản subprocess lifecycle
43
+ - `child-pi.ts` = 461 lines just to manage the subprocess lifecycle
44
44
  - Hard kill timer (3s), post-exit stdio guard (3s), final drain (5s), response timeout (5 min)
45
- - Process tree kill (`taskkill /t /f` trên Windows, `kill -pgid` trên Unix)
46
- - Mock system cho testing (`PI_TEAMS_MOCK_CHILD_PI`)
45
+ - Process tree kill (`taskkill /t /f` on Windows, `kill -pgid` on Unix)
46
+ - Mock system for testing (`PI_TEAMS_MOCK_CHILD_PI`)
47
47
 
48
48
  ---
49
49
 
50
- ## 2. live-session đã sẵn sàng
50
+ ## 2. live-session is ready
51
51
 
52
- pi-crew **đã implement** live-session runtime hoàn chỉnh:
52
+ pi-crew **has already implemented** a complete live-session runtime:
53
53
 
54
- - `src/runtime/live-session-runtime.ts` — 600 LOC, feature parity với child-process cho hầu hết use cases
55
- - `src/runtime/runtime-resolver.ts` — `resolveCrewRuntime()` đã handle auto/live-session/child-process
56
- - Soft turn limit + grace period (default 5) — **đã có**, y hệt pi-subagents3
57
- - Tool filtering — `filterActiveTools()` loại recursive tools
54
+ - `src/runtime/live-session-runtime.ts` — 600 LOC, feature parity with child-process for most use cases
55
+ - `src/runtime/runtime-resolver.ts` — `resolveCrewRuntime()` already handles auto/live-session/child-process
56
+ - Soft turn limit + grace period (default 5) — **already present**, identical to pi-subagents3
57
+ - Tool filtering — `filterActiveTools()` removes recursive tools
58
58
  - Yield/submit_result — custom tool + JSON event detection
59
59
  - Live agent control — steer, resume, real-time tool activity
60
- - Extension bridge — `buildExtensionBridge()` cho extension-based APIs
60
+ - Extension bridge — `buildExtensionBridge()` for extension-based APIs
61
61
  - Health diagnostics — `collectLiveSessionHealth()`, `formatLiveSessionDiagnostics()`
62
62
 
63
- ### Cấu hình hiện tại cần set thủ công:
63
+ ### Current configuration must be set manually:
64
64
 
65
65
  ```json
66
66
  // .pi/crew-config.json
@@ -71,7 +71,7 @@ pi-crew **đã implement** live-session runtime hoàn chỉnh:
71
71
  }
72
72
  ```
73
73
 
74
- Hoặc:
74
+ Or:
75
75
  ```json
76
76
  {
77
77
  "runtime": {
@@ -81,15 +81,15 @@ Hoặc:
81
81
  }
82
82
  ```
83
83
 
84
- **Default hiện tại `"auto"` KHÔNG `preferLiveSession`** → luôn fallback về child-process.
84
+ **The current default is `"auto"` WITHOUT `preferLiveSession`** → it always falls back to child-process.
85
85
 
86
86
  ---
87
87
 
88
- ## 3. Đề xuất
88
+ ## 3. Proposal
89
89
 
90
- ### 3.1 Đổi default: `preferLiveSession: true` khi mode = "auto"
90
+ ### 3.1 Change the default: `preferLiveSession: true` when mode = "auto"
91
91
 
92
- `resolveCrewRuntime()` hiện tại:
92
+ Current `resolveCrewRuntime()`:
93
93
 
94
94
  ```typescript
95
95
  // src/runtime/runtime-resolver.ts
@@ -98,10 +98,10 @@ if (requestedMode === "live-session" || (requestedMode === "auto" && config.runt
98
98
  if (live.available) return liveCaps(requestedMode);
99
99
  // fallback to child-process
100
100
  }
101
- return childCaps(requestedMode); // ← default: luôn child-process
101
+ return childCaps(requestedMode); // ← default: always child-process
102
102
  ```
103
103
 
104
- **Đề xuất đổi:**
104
+ **Proposed change:**
105
105
 
106
106
  ```typescript
107
107
  if (requestedMode === "live-session" || requestedMode === "auto") {
@@ -113,11 +113,11 @@ if (requestedMode === "live-session" || requestedMode === "auto") {
113
113
  }
114
114
  ```
115
115
 
116
- **Tức là:** `"auto"` → thử live-session trước, fallback child-process nếu SDK không available. User vẫn thể force `child-process` nếu muốn.
116
+ **In other words:** `"auto"` → try live-session first, fall back to child-process if the SDK is unavailable. Users can still force `child-process` if they want.
117
117
 
118
- ### 3.2 Thêm opt-out cho risky tasks
118
+ ### 3.2 Add an opt-out for risky tasks
119
119
 
120
- Task-level flag để force child-process cho tasks cụ thể:
120
+ A task-level flag to force child-process for specific tasks:
121
121
 
122
122
  ```json
123
123
  {
@@ -129,43 +129,43 @@ Task-level flag để force child-process cho tasks cụ thể:
129
129
  }
130
130
  ```
131
131
 
132
- Tasks role `executor` hoặc tasks trong worktree → tự dùng child-process.
132
+ Tasks with the `executor` role, or tasks running in a worktree → automatically use child-process.
133
133
 
134
- ### 3.3 Lợi ích dự kiến
134
+ ### 3.3 Expected benefits
135
135
 
136
- | Metric | Trước (child-process default) | Sau (live-session default) |
136
+ | Metric | Before (child-process default) | After (live-session default) |
137
137
  |---|---|---|
138
138
  | **4-worker memory** | ~910 MB | ~370 MB |
139
139
  | **First token latency** | 2-4s/worker | 200-500ms/worker |
140
- | **Startup total (3 phases)** | 6-12s | 0.6-1.5s |
140
+ | **Total startup (3 phases)** | 6-12s | 0.6-1.5s |
141
141
  | **Steering** | ❌ | ✅ |
142
142
  | **Resume** | ❌ | ✅ |
143
143
  | **Crash isolation** | ✅ | ❌ (fallback available) |
144
144
  | **Parent crash risk** | None | Low (session.abort handles most) |
145
145
 
146
- ### 3.4 Rủi ro và cách giảm thiểu
146
+ ### 3.4 Risks and mitigations
147
147
 
148
- | Rủi ro | Mức độ | Cách giảm thiểu |
148
+ | Risk | Severity | Mitigation |
149
149
  |---|---|---|
150
- | Agent crash → parent crash | Medium | `try/catch` quanh `session.prompt()`, `AbortController` per-agent, cleanup trên unhandled rejection |
151
- | Memory pressure (nhiều sessions) | Low | Giữ `maxConcurrent` cap (default 4), limit đủ |
152
- | Recursive team calls | Low | `filterActiveTools()` đã loại recursive tools |
153
- | SDK không available (Pi version) | Low | Auto-fallback về child-process |
154
- | Unhandled errors trong session | Medium | Global `unhandledRejection` handler per-session |
150
+ | Agent crash → parent crash | Medium | `try/catch` around `session.prompt()`, `AbortController` per-agent, cleanup on unhandled rejection |
151
+ | Memory pressure (many sessions) | Low | Keep the `maxConcurrent` cap (default 4); the limit is sufficient |
152
+ | Recursive team calls | Low | `filterActiveTools()` already removes recursive tools |
153
+ | SDK unavailable (old Pi version) | Low | Auto-fallback to child-process |
154
+ | Unhandled errors in session | Medium | Global `unhandledRejection` handler per-session |
155
155
 
156
156
  ---
157
157
 
158
- ## 4. Kết luận
158
+ ## 4. Conclusion
159
159
 
160
- **pi-crew đang dùng runtime quá nặng cho hầu hết use cases.** child-process crash isolation tuyệt vời nhưng:
160
+ **pi-crew is using an overly heavy runtime for most use cases.** child-process provides excellent crash isolation, but:
161
161
 
162
- - **9x memory** so với live-session
163
- - **8x startup latency**
164
- - **Không steer/resume** — mất khả năng interactive
162
+ - ** the memory** compared to live-session
163
+ - ** the startup latency**
164
+ - **No steer/resume** — loses interactive capability
165
165
 
166
- live-session **đã implement sẵn**, chỉ cần đổi default. Crash isolation trade-off chấp nhận được vì:
167
- 1. Pi SDK `createAgentSession()` đã handle大部分 errors
168
- 2. Fallback child-process vẫn available khi cần
169
- 3. Lợi ích (540 MB tiết kiệm, 3s faster startup, steer/resume) vượt trội hơn rủi ro
166
+ live-session **is already implemented**; only the default needs to change. The crash isolation trade-off is acceptable because:
167
+ 1. The Pi SDK `createAgentSession()` already handles most errors
168
+ 2. A child-process fallback is still available when needed
169
+ 3. The benefits (540 MB saved, 3s faster startup, steer/resume) outweigh the risks
170
170
 
171
- **Action:** Đổi `resolveCrewRuntime()` default để `"auto"` prefer live-session, giữ child-process làm fallback.
171
+ **Action:** Change the `resolveCrewRuntime()` default so `"auto"` prefers live-session, keeping child-process as a fallback.
@@ -1,130 +1,130 @@
1
- # Phân tích: Chuyển pi-crew hoàn toàn sang in-process execution
1
+ # Analysis: Migrating pi-crew fully to in-process execution
2
2
 
3
- > Ngày: 2026-05-12
4
- > Câu hỏi: Nếu chuyển hẳn sang in-process giống pi-subagents3 thì sao?
3
+ > Date: 2026-05-12
4
+ > Question: What if we move entirely to in-process like pi-subagents3?
5
5
 
6
6
  ---
7
7
 
8
- ## 1. Hiện trạng
8
+ ## 1. Current state
9
9
 
10
- pi-crew **3 runtime modes**, child-process default:
10
+ pi-crew has **3 runtime modes**, with child-process as the default:
11
11
 
12
12
  ```
13
- scaffold → không chạy workers (dry-run)
14
- child-process → spawn `pi` CLI subprocess per worker (DEFAULT)
13
+ scaffold → no workers run (dry-run)
14
+ child-process → spawn a `pi` CLI subprocess per worker (DEFAULT)
15
15
  live-session → createAgentSession() in-process per worker
16
16
  ```
17
17
 
18
- ### Code liên quan child-process
18
+ ### Code related to child-process
19
19
 
20
- | File | LOC | Vai trò |
20
+ | File | LOC | Role |
21
21
  |---|---|---|
22
22
  | `child-pi.ts` | 461 | Subprocess lifecycle, stdout parsing, kill process tree |
23
- | `pi-args.ts` | 165 | Build CLI args cho child `pi` process |
24
- | `pi-spawn.ts` | 167 | Detect `pi` binary path (local/global) |
25
- | `post-exit-stdio-guard.ts` | 86 | Drain child stdout sau exit, hard kill timer |
26
- | `async-runner.ts` | 153 | Spawn background team runs ( detached process) |
27
- | **Tổng** | **1.032** | **Code chỉ dùng cho child-process** |
23
+ | `pi-args.ts` | 165 | Build CLI args for the child `pi` process |
24
+ | `pi-spawn.ts` | 167 | Detect the `pi` binary path (local/global) |
25
+ | `post-exit-stdio-guard.ts` | 86 | Drain child stdout after exit, hard kill timer |
26
+ | `async-runner.ts` | 153 | Spawn background team runs (detached process) |
27
+ | **Total** | **1,032** | **Code only used by child-process** |
28
28
 
29
- ### Code liên quan live-session (đã có sẵn)
29
+ ### Code related to live-session (already present)
30
30
 
31
- | File | LOC | Vai trò |
31
+ | File | LOC | Role |
32
32
  |---|---|---|
33
33
  | `live-session-runtime.ts` | 600 | In-process execution, soft turn limit, yield, custom tools |
34
34
  | `runtime-resolver.ts` | 92 | Auto-detect available runtime |
35
35
  | `task-runner/live-executor.ts` | 95 | Adapter: live-session → task-runner interface |
36
36
 
37
- ### Files sử dụng child-process path
37
+ ### Files that use the child-process path
38
38
 
39
- - `task-runner.ts` — 8 references, ~120 dòng logic riêng child-process (heartbeat, progress, model retry)
39
+ - `task-runner.ts` — 8 references, ~120 lines of child-process-specific logic (heartbeat, progress, model retry)
40
40
  - `register.ts` — `terminateActiveChildPiProcesses()` cleanup
41
41
  - `doctor.ts` — diagnose child-process issues
42
42
  - `async-runner.ts` — spawn background team runs
43
43
 
44
- ### Tests liên quan
44
+ ### Related tests
45
45
 
46
46
  - ~37 test files reference child-process / mock child
47
- - ~3 test files reference live-session mock
48
- - Tất cả integration tests dùng `PI_TEAMS_MOCK_CHILD_PI` — **cần rewrite** nếu bỏ child-process
47
+ - ~3 test files reference the live-session mock
48
+ - All integration tests use `PI_TEAMS_MOCK_CHILD_PI` — **would need rewriting** if child-process is dropped
49
49
 
50
50
  ---
51
51
 
52
- ## 2. Nếu chuyển hẳn sang in-process
52
+ ## 2. If we move fully to in-process
53
53
 
54
- ### 2.1 Những ĐƯỢC
54
+ ### 2.1 What we GAIN
55
55
 
56
- #### Lợi tức tức thì
56
+ #### Immediate benefits
57
57
 
58
- | Metric | child-process | in-process | Cải thiện |
58
+ | Metric | child-process | in-process | Improvement |
59
59
  |---|---|---|---|
60
- | Memory / worker | ~150 MB | ~15 MB | **10× nhẹ hơn** |
61
- | 4 workers peak | ~600 MB thêm | ~60 MB thêm | **540 MB tiết kiệm** |
62
- | Startup / worker | 2-4s | 200-500ms | **8× nhanh hơn** |
63
- | Team startup (3 phases) | 6-12s overhead | ~1s overhead | **6-12× nhanh hơn** |
64
- | Steering | ❌ | ✅ | **Tính năng mới** |
65
- | Resume | ❌ | ✅ | **Tính năng mới** |
66
- | Context inheritance | ❌ | ✅ (parentContext) | **Tính năng mới** |
67
- | Live tool activity | ❌ | ✅ | **Tính năng mới** |
60
+ | Memory / worker | ~150 MB | ~15 MB | **10× lighter** |
61
+ | 4 workers peak | ~600 MB added | ~60 MB added | **540 MB saved** |
62
+ | Startup / worker | 2-4s | 200-500ms | **8× faster** |
63
+ | Team startup (3 phases) | 6-12s overhead | ~1s overhead | **6-12× faster** |
64
+ | Steering | ❌ | ✅ | **New feature** |
65
+ | Resume | ❌ | ✅ | **New feature** |
66
+ | Context inheritance | ❌ | ✅ (parentContext) | **New feature** |
67
+ | Live tool activity | ❌ | ✅ | **New feature** |
68
68
  | Yield/submit_result | ✅ (JSON event) | ✅ (custom tool) | Parity |
69
69
  | Worktree isolation | ✅ | ✅ | Parity |
70
70
 
71
- #### Lợi tức kiến trúc
71
+ #### Architectural benefits
72
72
 
73
- - **Xóa ~1.000 LOC** subprocess management code
74
- - Đơn giản hóa `task-runner.ts` (bỏ 120 dòng child-process logic)
75
- - Bỏ `post-exit-stdio-guard.ts`, `pi-spawn.ts`, `pi-args.ts` subprocess overhead
76
- - Bỏ `responseTimeoutMs`, `hardKillMs`, `postExitStdioGuardMs` — không cần kill process tree
77
- - **Zero npm dependencies cho execution** (hiện cần `jiti` cho async-runner TypeScript loading)
73
+ - **Delete ~1,000 LOC** of subprocess management code
74
+ - Simplify `task-runner.ts` (remove 120 lines of child-process logic)
75
+ - Remove `post-exit-stdio-guard.ts`, `pi-spawn.ts`, `pi-args.ts` subprocess overhead
76
+ - Remove `responseTimeoutMs`, `hardKillMs`, `postExitStdioGuardMs` — no need to kill a process tree
77
+ - **Zero npm dependencies for execution** (currently requires `jiti` for async-runner TypeScript loading)
78
78
 
79
- ### 2.2 Những MẤT
79
+ ### 2.2 What we LOSE
80
80
 
81
81
  #### ❌ Process isolation — biggest loss
82
82
 
83
83
  ```
84
84
  child-process: worker crash → worker dies → parent continues
85
- in-process: worker crash → thể crash parent → toàn bộ team mất
85
+ in-process: worker crash → can crash parent → entire team lost
86
86
  ```
87
87
 
88
- Pi SDK `createAgentSession()` đã handle phần lớn errors, nhưng:
89
- - **Unhandled promise rejection** trong session
90
- - **Infinite loop** trong custom tool
91
- - **OOM** — một session ăn hết memory ảnh hưởng tất cả
92
- - **Node.js segfault** — rare nhưng khi xảy ra = chết hết
88
+ The Pi SDK `createAgentSession()` handles most errors, but:
89
+ - **Unhandled promise rejection** within a session
90
+ - **Infinite loop** inside a custom tool
91
+ - **OOM** — one session consuming all memory affects everything
92
+ - **Node.js segfault** — rare, but when it happens = total death
93
93
 
94
94
  #### ❌ Async background team runs
95
95
 
96
- `async-runner.ts` spawn một **detached process** chạy team khi user close terminal. In-process không thể — process chết khi terminal close.
96
+ `async-runner.ts` spawns a **detached process** to run a team when the user closes the terminal. In-process cannot do this the process dies when the terminal closes.
97
97
 
98
- **Giải pháp:** Giữ `async-runner.ts` riêng cho background runs — spawn cả team runner, không phải individual workers.
98
+ **Solution:** Keep `async-runner.ts` specifically for background runs — it spawns the entire team runner, not individual workers.
99
99
 
100
- #### ❌ Depth guard đơn giản
100
+ #### ❌ Simple depth guard
101
101
 
102
- `checkCrewDepth()` đếm `PI_CREW_PARENT_PID` env var. In-process không process boundary → đếm depth khó hơn. Cần dùng global counter hoặc thread-local.
102
+ `checkCrewDepth()` counts the `PI_CREW_PARENT_PID` env var. In-process has no process boundary → counting depth is harder. A global counter or thread-local equivalent is needed.
103
103
 
104
- #### ❌ 37+ test files cần update
104
+ #### ❌ 37+ test files need updating
105
105
 
106
- Tất cả integration tests dùng `PI_TEAMS_MOCK_CHILD_PI`. Cần chuyển sang `PI_CREW_MOCK_LIVE_SESSION` hoặc viết mock mới.
106
+ All integration tests use `PI_TEAMS_MOCK_CHILD_PI`. They would need to switch to `PI_CREW_MOCK_LIVE_SESSION` or have new mocks written.
107
107
 
108
108
  #### ❌ `_CrewRuntimeKind` type union
109
109
 
110
- `"scaffold" | "child-process" | "live-session"` → nếu bỏ child-process thì chỉ còn `"scaffold" | "in-process"`. Breaking change cho config.
110
+ `"scaffold" | "child-process" | "live-session"` → if child-process is dropped, only `"scaffold" | "in-process"` remains. Breaking change for config.
111
111
 
112
- ### 2.3 Rủi ro cụ thể
112
+ ### 2.3 Specific risks
113
113
 
114
- | Rủi ro | Mức độ | Chi tiết |
114
+ | Risk | Severity | Details |
115
115
  |---|---|---|
116
- | Parent crash | **Medium** | Unhandled error in agent session → parent dies. Pi SDK wraps大部分 nhưng không phải 100%. |
117
- | Memory pressure | **Medium** | 4 in-process sessions + context windows thể chiếm >500MB trong cùng heap. V8 GC pause. |
118
- | Extension conflicts | **Low** | In-process extensions thể conflict (global state, tool registry). Đã filter nhưng edge cases. |
119
- | Recursive team calls | **Low** | `team` tool trong agent session → infinite recursion. Đã filter nhưng cần guarantee. |
120
- | Background runs | **Solved** | Giữ `async-runner.ts` riêng, chỉ spawn 1 detached process cho full team. |
121
- | Breaking config | **Low** | User đang set `mode: "child-process"` → cần migration path. |
116
+ | Parent crash | **Medium** | Unhandled error in agent session → parent dies. The Pi SDK wraps most of them but not 100%. |
117
+ | Memory pressure | **Medium** | 4 in-process sessions + context windows can consume >500MB within the same heap. V8 GC pauses. |
118
+ | Extension conflicts | **Low** | In-process extensions can conflict (global state, tool registry). Filtering exists but there are edge cases. |
119
+ | Recursive team calls | **Low** | The `team` tool inside an agent session → infinite recursion. Already filtered but a guarantee is needed. |
120
+ | Background runs | **Solved** | Keep `async-runner.ts` separate; it only spawns 1 detached process for the full team. |
121
+ | Breaking config | **Low** | Users currently setting `mode: "child-process"` → need a migration path. |
122
122
 
123
123
  ---
124
124
 
125
- ## 3. Hai hướng đi
125
+ ## 3. Two directions
126
126
 
127
- ### Hướng A: Bỏ hoàn toàn child-process (giống pi-subagents3)
127
+ ### Direction A: Drop child-process entirely (like pi-subagents3)
128
128
 
129
129
  ```
130
130
  ┌─────────────────────────┐
@@ -140,15 +140,15 @@ Tất cả integration tests dùng `PI_TEAMS_MOCK_CHILD_PI`. Cần chuyển sang
140
140
  └─────────────────────────┘
141
141
  ```
142
142
 
143
- **Xóa:** `child-pi.ts`, `pi-args.ts`, `pi-spawn.ts`, `post-exit-stdio-guard.ts` (~879 LOC)
144
- **Giữ:** `async-runner.ts` (cho background team runs — spawn 1 process cho cả team, không phải per-worker)
145
- **Đổi:** `task-runner.ts` → bỏ child-process branch, chỉ dùng live-session
146
- **Đổi:** Tất cả 37+ test files
143
+ **Delete:** `child-pi.ts`, `pi-args.ts`, `pi-spawn.ts`, `post-exit-stdio-guard.ts` (~879 LOC)
144
+ **Keep:** `async-runner.ts` (for background team runs — spawns 1 process for the whole team, not per-worker)
145
+ **Change:** `task-runner.ts` → drop the child-process branch, use only live-session
146
+ **Change:** All 37+ test files
147
147
 
148
- **Pros:** Clean architecture, đơn giản nhất, maintenance thấp nhất
149
- **Cons:** Mất crash isolation cho per-worker, nhiều test cần rewrite
148
+ **Pros:** Clean architecture, simplest, lowest maintenance
149
+ **Cons:** Loses per-worker crash isolation; many tests need rewriting
150
150
 
151
- ### Hướng B: Live-session default + child-process opt-in (khuyến nghị)
151
+ ### Direction B: Live-session default + child-process opt-in (recommended)
152
152
 
153
153
  ```
154
154
  ┌─────────────────────────────────┐
@@ -162,26 +162,26 @@ Tất cả integration tests dùng `PI_TEAMS_MOCK_CHILD_PI`. Cần chuyển sang
162
162
  └──────────┴───────────────────────┘
163
163
  ```
164
164
 
165
- **Đổi:** `runtime-resolver.ts` → `"auto"` prefer live-session
166
- **Giữ:** Tất cả child-process code (fallback)
167
- **Giữ:** Tất cả tests
168
- **Thêm:** Config `"riskyIsolation": true"` cho executor role auto-use child-process
165
+ **Change:** `runtime-resolver.ts` → `"auto"` prefers live-session
166
+ **Keep:** All child-process code (as fallback)
167
+ **Keep:** All tests
168
+ **Add:** Config `"riskyIsolation": true` so the executor role auto-uses child-process
169
169
 
170
- **Pros:** Best of both worlds, zero breaking change
171
- **Cons:** Vẫn maintain 2 code paths
170
+ **Pros:** Best of both worlds, zero breaking changes
171
+ **Cons:** Still maintaining 2 code paths
172
172
 
173
173
  ---
174
174
 
175
- ## 4. Khuyến nghị: Hướng B
175
+ ## 4. Recommendation: Direction B
176
176
 
177
- **Không nên bỏ child-process hoàn toàn** — quá rủi ro cho production. Thay vào đó:
177
+ **Do not drop child-process entirely** — too risky for production. Instead:
178
178
 
179
- ### Bước 1: Đổi default runtime (nhanh, ít rủi ro)
179
+ ### Step 1: Change the default runtime (fast, low risk)
180
180
 
181
181
  ```typescript
182
182
  // runtime-resolver.ts
183
- // Trước: "auto" → luôn child-process
184
- // Sau: "auto" → thử live-session, fallback child-process
183
+ // Before: "auto" → always child-process
184
+ // After: "auto" → try live-session, fall back to child-process
185
185
 
186
186
  export async function resolveCrewRuntime(config, env) {
187
187
  const requestedMode = config.runtime?.mode ?? "auto";
@@ -197,7 +197,7 @@ export async function resolveCrewRuntime(config, env) {
197
197
  }
198
198
  ```
199
199
 
200
- ### Bước 2: Thêm per-role isolation policy
200
+ ### Step 2: Add a per-role isolation policy
201
201
 
202
202
  ```json
203
203
  // crew-config.json
@@ -213,38 +213,38 @@ export async function resolveCrewRuntime(config, env) {
213
213
  }
214
214
  ```
215
215
 
216
- ### Bước 3: Observability cho in-process errors
216
+ ### Step 3: Observability for in-process errors
217
217
 
218
218
  ```typescript
219
- // Wrap session.prompt() với global error handler
219
+ // Wrap session.prompt() with a global error handler
220
220
  process.on('unhandledRejection', (err) => {
221
221
  logInternalError('live-session.unhandled', err);
222
222
  // Don't crash — attempt recovery
223
223
  });
224
224
  ```
225
225
 
226
- ### Lợi tức dự kiến Hướng B
226
+ ### Expected benefits of Direction B
227
227
 
228
- | | Hiện tại | Sau Bước 1 | Sau Bước 2 |
228
+ | | Current | After Step 1 | After Step 2 |
229
229
  |---|---|---|---|
230
230
  | **Default runtime** | child-process | live-session (auto) | live-session + per-role |
231
- | **Memory (4 workers)** | ~910 MB | ~370 MB | ~450 MB (mix) |
232
- | **Startup** | 2-4s/worker | 200-500ms/worker | Mix |
231
+ | **Memory (4 workers)** | ~910 MB | ~370 MB | ~450 MB (mixed) |
232
+ | **Startup** | 2-4s/worker | 200-500ms/worker | Mixed |
233
233
  | **Crash isolation** | ✅ all | ✅ fallback | ✅ risky roles |
234
234
  | **Steering** | ❌ | ✅ | ✅ |
235
235
  | **Breaking changes** | — | None | None |
236
- | **Code xóa** | — | 0 | 0 (giữ fallback) |
237
- | **Tests cần đổi** | — | 0 | 0 |
236
+ | **Code deleted** | — | 0 | 0 (keep fallback) |
237
+ | **Tests to change** | — | 0 | 0 |
238
238
 
239
239
  ---
240
240
 
241
- ## 5. Kết luận
241
+ ## 5. Conclusion
242
242
 
243
- **Không nên chuyển hẳn 100% in-process.** Lý do:
243
+ **Do not move 100% to in-process.** Reasons:
244
244
 
245
- 1. **Crash isolation quá quan trọng** cho executor/test-engineer roles — những agent này chạy code, write files, thể infinite loop
246
- 2. **Background runs cần detached process** — không thể in-process
247
- 3. **37+ test files cần rewrite** — chi phí migration cao
248
- 4. **Breaking change** cho users đang dùng `mode: "child-process"`
245
+ 1. **Crash isolation is too important** for executor/test-engineer roles — these agents run code, write files, and can infinite-loop
246
+ 2. **Background runs need a detached process** — impossible in-process
247
+ 3. **37+ test files need rewriting** — high migration cost
248
+ 4. **Breaking change** for users currently using `mode: "child-process"`
249
249
 
250
- **Thay vào đó: Đổi default sang live-session + giữ child-process làm fallback/opt-in.** Đây chính thiết kế sẵn của `resolveCrewRuntime()` — chỉ cần flip default trong `"auto"` mode. Zero code xóa, zero breaking change, users tự chọn khi cần isolation.
250
+ **Instead: Change the default to live-session + keep child-process as a fallback/opt-in.** This is precisely the design already built into `resolveCrewRuntime()` — just flip the default in `"auto"` mode. Zero code deleted, zero breaking changes, and users choose isolation when they need it.
package/install.mjs CHANGED
@@ -70,11 +70,12 @@ console.log("To force-disable or force-enable workers in a shell, use PI_TEAMS_E
70
70
  console.log("\n--- What pi-crew writes (and how to undo it) ---");
71
71
  console.log("pi-crew itself writes nothing on install. The following only happens when you");
72
72
  console.log("explicitly run `team action=init` in a project:");
73
- console.log(" - A marker-delimited block is injected into the project's AGENTS.md.");
74
- console.log(" (Wrapped in <!-- PI-CREW:GUIDANCE:START/END --> — your content is never touched.)");
75
73
  console.log(" - A `.crew/` runtime state dir is created in the project (run history + artifacts).");
76
74
  console.log(" - With --copy-builtins: bundled agents/teams/workflows are copied into the project.");
77
75
  console.log("This install also created the global config above (`~/.pi/agent/pi-crew.json`).");
76
+ console.log("Note: pi-crew v0.8.14+ no longer injects a guidance block into AGENTS.md on init");
77
+ console.log(" (it was redundant — the `team` tool self-describes via tool registration).");
78
+ console.log(" Versions <0.8.14 did inject one; `team action=cleanup` removes it.");
78
79
  console.log("\nFull uninstall (in order):");
79
80
  console.log(" team action=cleanup dryRun=true # preview what would be removed (project)");
80
81
  console.log(" team action=cleanup # remove the AGENTS.md guidance block");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-crew",
3
- "version": "0.8.13",
3
+ "version": "0.9.0",
4
4
  "description": "Pi extension for coordinated AI teams, workflows, worktrees, and async task orchestration",
5
5
  "author": "baphuongna",
6
6
  "license": "MIT",
@@ -81,12 +81,10 @@
81
81
  },
82
82
  "dependencies": {
83
83
  "@sinclair/typebox": "^0.34.49",
84
- "acorn": "^8.16.0",
85
84
  "ajv": "^8.20.0",
86
85
  "cli-highlight": "^2.1.11",
87
86
  "diff": "^5.2.0",
88
- "jiti": "^2.7.0",
89
- "typebox": "^1.1.38"
87
+ "jiti": "^2.7.0"
90
88
  },
91
89
  "devDependencies": {
92
90
  "@biomejs/biome": "^2.4.15",