pi-crew 0.8.14 → 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 (80) hide show
  1. package/CHANGELOG.md +271 -0
  2. package/README.md +112 -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/package.json +2 -4
  35. package/skills/orchestration/SKILL.md +11 -11
  36. package/src/agents/agent-config.ts +4 -0
  37. package/src/config/config.ts +39 -0
  38. package/src/config/types.ts +11 -0
  39. package/src/extension/action-suggestions.ts +2 -1
  40. package/src/extension/async-notifier.ts +10 -0
  41. package/src/extension/help.ts +14 -0
  42. package/src/extension/registration/commands.ts +27 -0
  43. package/src/extension/team-tool/destructive-gate.ts +1 -1
  44. package/src/extension/team-tool/goal-wrap.ts +288 -0
  45. package/src/extension/team-tool/goal.ts +405 -0
  46. package/src/extension/team-tool/run.ts +103 -4
  47. package/src/extension/team-tool/workflow-manage.ts +194 -0
  48. package/src/extension/team-tool.ts +20 -0
  49. package/src/hooks/types.ts +3 -1
  50. package/src/runtime/async-runner.ts +24 -2
  51. package/src/runtime/background-runner.ts +68 -19
  52. package/src/runtime/child-pi.ts +6 -1
  53. package/src/runtime/completion-guard.ts +1 -1
  54. package/src/runtime/dynamic-workflow-context.ts +450 -0
  55. package/src/runtime/dynamic-workflow-runner.ts +180 -0
  56. package/src/runtime/global-worker-cap.ts +96 -0
  57. package/src/runtime/goal-evaluator.ts +294 -0
  58. package/src/runtime/goal-loop-runner.ts +612 -0
  59. package/src/runtime/goal-state-store.ts +209 -0
  60. package/src/runtime/pi-args.ts +10 -2
  61. package/src/runtime/result-extractor.ts +32 -0
  62. package/src/runtime/team-runner.ts +11 -1
  63. package/src/runtime/verification-gates.ts +85 -5
  64. package/src/runtime/verification-integrity.ts +110 -0
  65. package/src/runtime/verification-worktree.ts +136 -0
  66. package/src/runtime/workspace-lock.ts +448 -0
  67. package/src/schema/config-schema.ts +26 -0
  68. package/src/schema/team-tool-schema.ts +39 -4
  69. package/src/state/atomic-write.ts +9 -0
  70. package/src/state/contracts.ts +14 -0
  71. package/src/state/crew-init.ts +18 -5
  72. package/src/state/event-log.ts +7 -1
  73. package/src/state/state-store.ts +2 -0
  74. package/src/state/types.ts +82 -0
  75. package/src/state/worker-atomic-writer.ts +176 -0
  76. package/src/utils/redaction.ts +104 -24
  77. package/src/workflows/discover-workflows.ts +25 -1
  78. package/src/workflows/workflow-config.ts +13 -0
  79. package/teams/parallel-research.team.md +1 -1
  80. package/workflows/examples/hello.dwf.ts +24 -0
@@ -1,22 +1,22 @@
1
- # Research: oh-my-pi v15.0.0 — Tính năng thể áp dụng vào pi-crew
1
+ # Research: oh-my-pi v15.0.0 — Features Applicable to pi-crew
2
2
 
3
3
  > Date: 2026-05-13
4
4
  > Source: `D:/my/my_project/source/oh-my-pi` (v15.0.0)
5
- > Purpose: Tìm features thể port vào pi-crew
5
+ > Purpose: Find features that can be ported into pi-crew
6
6
 
7
7
  ---
8
8
 
9
9
  ## 1. Feature: Hashline Engine (`hashline/`)
10
10
 
11
- ### Mục đích
12
- Thay thế hoàn toàn hashline bằng engine mới hỗ trợ:
13
- - Line-level content addressing (hash mỗi dòng)
14
- - Semantic anchors (không chỉ line number hash content)
15
- - Recovery mode (phục hồi từ crash)
11
+ ### Purpose
12
+ Fully replace the old hashline with a new engine supporting:
13
+ - Line-level content addressing (hash each line)
14
+ - Semantic anchors (not just line numbers but content hashes)
15
+ - Recovery mode (recover from crash state)
16
16
  - Conflict resolution (3-way merge)
17
17
  - Streaming diff output
18
18
 
19
- ### Cách hoạt động
19
+ ### How it works
20
20
 
21
21
  **Core types** (`hashline/types.ts`):
22
22
  ```typescript
@@ -32,36 +32,36 @@ export type HashlineEdit =
32
32
  ```
33
33
 
34
34
  **Key modules:**
35
- - `hash.ts` (694→) — Line hashing với bigram index
35
+ - `hash.ts` (694→) — Line hashing with bigram index
36
36
  - `parser.ts` (192 lines) — Parse hashline input
37
- - `apply.ts` (716 lines) — Apply edits với validation
38
- - `recovery.ts` (72 lines) — Recovery từ crash state
37
+ - `apply.ts` (716 lines) — Apply edits with validation
38
+ - `recovery.ts` (72 lines) — Recovery from crash state
39
39
  - `execute.ts` (267 lines) — Execute hashline commands
40
40
  - `diff.ts` / `diff-preview.ts` — Streaming diff
41
41
 
42
- ### Potential apply cho pi-crew
42
+ ### Potential application to pi-crew
43
43
 
44
- **Option A — Dùng trực tiếp (nếu oh-my-pi tách hashline thành package riêng):**
45
- - Pi-crew cần edit files trong worktree
46
- - Hashline engine thể giúp detect conflicts khi nhiều agents edit cùng file
44
+ **Option A — Use directly (if oh-my-pi splits hashline into a separate package):**
45
+ - pi-crew needs to edit files in worktrees
46
+ - The hashline engine could help detect conflicts when multiple agents edit the same file
47
47
 
48
- **Option B — Conflict detection (đã `conflict-detect.ts` rồi):**
49
- - Xem feature tiếp theo
48
+ **Option B — Conflict detection (already have `conflict-detect.ts`):**
49
+ - See the next feature
50
50
 
51
- **Effort: HIGH** — hashline strongly coupled với oh-my-pi internals (ToolSession, LSP batch request, etc.)
51
+ **Effort: HIGH** — hashline is strongly coupled to oh-my-pi internals (ToolSession, LSP batch request, etc.)
52
52
 
53
53
  ### Risk/Dependency
54
- - Requires oh-my-pi package hoặc fork lại
55
- - Strong dependency on oh-my-pi tool execution model
54
+ - Requires the oh-my-pi package or a fork
55
+ - Strong dependency on oh-my-pi's tool execution model
56
56
 
57
57
  ---
58
58
 
59
59
  ## 2. Feature: Conflict Detection & Resolution (`conflict-detect.ts`)
60
60
 
61
- ### Mục đích
62
- Detect git merge conflicts (<<<<<<, =======, >>>>>>>) trong file content không cần extra I/O. Mỗi conflict block được assign stable id, agent thể resolve bằng cách write vào `conflict://<id>`.
61
+ ### Purpose
62
+ Detect git merge conflicts (<<<<<<, =======, >>>>>>>) in file content without extra I/O. Each conflict block is assigned a stable id; the agent can resolve it by writing to `conflict://<id>`.
63
63
 
64
- ### Cách hoạt động
64
+ ### How it works
65
65
 
66
66
  ```typescript
67
67
  export interface ConflictBlock {
@@ -83,41 +83,41 @@ export interface ConflictBlock {
83
83
  ```
84
84
 
85
85
  **Workflow:**
86
- 1. `read` collects lines từ disk
87
- 2. `scanConflictLines` inspects cho `<<<<<<<` / `=======` / `>>>>>>>` markers
86
+ 1. `read` collects lines from disk
87
+ 2. `scanConflictLines` inspects for `<<<<<<<` / `=======` / `>>>>>>>` markers
88
88
  3. Each completed block → `ConflictHistory` (stable id)
89
- 4. Read output trả về kèm footer với conflict ids
90
- 5. Agent gọi `write({ path: "conflict://<id>", content })` để resolve
89
+ 4. Read output returns with a footer containing conflict ids
90
+ 5. Agent calls `write({ path: "conflict://<id>", content })` to resolve
91
91
 
92
- **Key insight:** Marker shape phải strict — column-0, exact prefix length, followed by EOL or single space + label.
92
+ **Key insight:** Marker shape must be strict — column-0, exact prefix length, followed by EOL or a single space + label.
93
93
 
94
- ### Potential apply cho pi-crew
94
+ ### Potential application to pi-crew
95
95
 
96
- **HIGH VALUE cho pi-crew:**
97
- - Khi nhiều agents edit cùng file trong worktree, thể xảy ra conflicts
98
- - Conflict detection giúp agent nhận biết resolve tự động
96
+ **HIGH VALUE for pi-crew:**
97
+ - When multiple agents edit the same file in a worktree, conflicts can occur
98
+ - Conflict detection lets the agent recognize and resolve them automatically
99
99
 
100
100
  **Implementation approach:**
101
101
  1. Fork `conflict-detect.ts` (license OK — MIT)
102
- 2. Integrate vào pi-crew's file read path
103
- 3. Register conflicts vào `LiveAgentHandle.activity` hoặc artifact store
104
- 4. Provide `conflict://` protocol trong write tool
105
- 5. Add `detect-conflicts` tool cho agents
102
+ 2. Integrate into pi-crew's file read path
103
+ 3. Register conflicts into `LiveAgentHandle.activity` or the artifact store
104
+ 4. Provide a `conflict://` protocol in the write tool
105
+ 5. Add a `detect-conflicts` tool for agents
106
106
 
107
- **Effort: MEDIUM** — standalone module, thể copy + adapt
107
+ **Effort: MEDIUM** — standalone module, can be copied + adapted
108
108
 
109
109
  ### Risk/Dependency
110
- - Cần xử `conflict://` protocol trong write tool
111
- - Cần update read tool để detect report conflicts
110
+ - Need to handle the `conflict://` protocol in the write tool
111
+ - Need to update the read tool to detect and report conflicts
112
112
 
113
113
  ---
114
114
 
115
115
  ## 3. Feature: ACP Client Bridge (`acp-client-bridge.ts`)
116
116
 
117
- ### Mục đích
118
- Bridge giữa oh-my-pi internal ClientBridge interface ACP (Agent Client Protocol) SDK. Cho phép tools (read/write/bash/edit) route qua client khi client capabilities.
117
+ ### Purpose
118
+ A bridge between oh-my-pi's internal ClientBridge interface and the ACP (Agent Client Protocol) SDK. Allows tools (read/write/bash/edit) to route through the client when the client has the capabilities.
119
119
 
120
- ### Cách hoạt động
120
+ ### How it works
121
121
 
122
122
  ```typescript
123
123
  export interface ClientBridgeCapabilities {
@@ -136,31 +136,31 @@ export interface ClientBridge {
136
136
  }
137
137
  ```
138
138
 
139
- **Pattern:** Feature detection → conditional implementation. Nếu client không capability thì fallback sang default implementation.
139
+ **Pattern:** Feature detection → conditional implementation. If the client lacks a capability, fall back to the default implementation.
140
140
 
141
- ### Potential apply cho pi-crew
141
+ ### Potential application to pi-crew
142
142
 
143
143
  **LOW-MEDIUM VALUE:**
144
144
 
145
- pi-crew đã `LiveExtensionBridge` `LiveAgentControl` — không cần ACP bridge. Tuy nhiên, pattern này hữu ích cho:
145
+ pi-crew already has `LiveExtensionBridge` and `LiveAgentControl` — doesn't need an ACP bridge. However, this pattern is useful for:
146
146
 
147
- 1. **pi-crew tool permission system** — thể dùng pattern này để check permission trước khi cho phép tool execution
148
- 2. **Cross-extension communication** — `ClientBridge` pattern thể adapt cho `CrossExtensionRPC`
147
+ 1. **pi-crew tool permission system** — Could use this pattern to check permission before allowing tool execution
148
+ 2. **Cross-extension communication** — The `ClientBridge` pattern could be adapted for `CrossExtensionRPC`
149
149
 
150
- **Effort: LOW** — chỉ cần học pattern, không cần port code
150
+ **Effort: LOW** — just learn the pattern, no need to port code
151
151
 
152
152
  ### Risk/Dependency
153
- - ACP SDK proprietary (`@agentclientprotocol/sdk`)
154
- - Pattern thể apply không cần SDK
153
+ - ACP SDK is proprietary (`@agentclientprotocol/sdk`)
154
+ - The pattern can be applied without the SDK
155
155
 
156
156
  ---
157
157
 
158
158
  ## 4. Feature: Todo Helper (`todo.ts`)
159
159
 
160
- ### Mục đích
161
- Slash command helper cho phép agents quản todo list trong project. Hỗ trợ subcommands: `done`, `drop`, `rm`, parsing markdown todo format.
160
+ ### Purpose
161
+ A slash command helper that lets agents manage a todo list within a project. Supports subcommands: `done`, `drop`, `rm`, and parses markdown todo format.
162
162
 
163
- ### Cách hoạt động
163
+ ### How it works
164
164
 
165
165
  **Tokenize approach:**
166
166
  ```typescript
@@ -187,36 +187,36 @@ function tokenize(input: string): string[] {
187
187
  - Escape sequences: `\<char>`
188
188
  - Whitespace splitting
189
189
 
190
- ### Potential apply cho pi-crew
190
+ ### Potential application to pi-crew
191
191
 
192
- **HIGH VALUE cho pi-crew:**
192
+ **HIGH VALUE for pi-crew:**
193
193
 
194
- pi-crew `YieldReminder` `TaskRunner` — thể tích hợp todo management:
194
+ pi-crew has `YieldReminder` and `TaskRunner` — can integrate todo management:
195
195
 
196
- 1. **Team task tracking** — Workflow tasks thể represented as todos
197
- 2. **Yield + Todo integration** — Khi agent yields với todo request, thể parse update todo list
198
- 3. **Slash command `/crew todo`** — Management interface cho team tasks
196
+ 1. **Team task tracking** — Workflow tasks can be represented as todos
197
+ 2. **Yield + Todo integration** — When an agent yields with a todo request, can parse and update the todo list
198
+ 3. **Slash command `/crew todo`** — Management interface for team tasks
199
199
 
200
200
  **Implementation approach:**
201
- 1. Fork `todo.ts` helper (279 lines)
202
- 2. Integrate vào `CrewTaskRunner` hoặc `YieldHandler`
203
- 3. Add `/crew todo` slash command
204
- 4. Wire vào `TaskDisplay` component
201
+ 1. Fork the `todo.ts` helper (279 lines)
202
+ 2. Integrate into `CrewTaskRunner` or `YieldHandler`
203
+ 3. Add a `/crew todo` slash command
204
+ 4. Wire into the `TaskDisplay` component
205
205
 
206
- **Effort: MEDIUM** — thể copy module, cần integrate với existing task system
206
+ **Effort: MEDIUM** — can copy the module, needs integration with the existing task system
207
207
 
208
208
  ### Risk/Dependency
209
209
  - Dependency on `todo-write.ts` tool
210
- - Cần sync với actual task state trong manifest
210
+ - Needs to sync with actual task state in the manifest
211
211
 
212
212
  ---
213
213
 
214
214
  ## 5. Feature: Compaction Error Types (`compaction/errors.ts`)
215
215
 
216
- ### Mục đích
217
- Typed error sentinels cho compaction operations. Dùng `instanceof` discrimination thay string matching.
216
+ ### Purpose
217
+ Typed error sentinels for compaction operations. Uses `instanceof` discrimination instead of string matching.
218
218
 
219
- ### Cách hoạt động
219
+ ### How it works
220
220
 
221
221
  ```typescript
222
222
  export class CompactionCancelledError extends Error {
@@ -228,18 +228,18 @@ export type CompactionOutcome = "ok" | "cancelled" | "failed";
228
228
  ```
229
229
 
230
230
  **Pattern:**
231
- - Sentinel class với `name` property readonly
232
- - Downstream callers dùng `instanceof CompactionCancelledError`
233
- - Source-agnostic: Esc, extension hook, programmatic abort đều cùng type
231
+ - Sentinel class with a readonly `name` property
232
+ - Downstream callers use `instanceof CompactionCancelledError`
233
+ - Source-agnostic: Esc, extension hook, programmatic abort all share the same type
234
234
 
235
- ### Potential apply cho pi-crew
235
+ ### Potential application to pi-crew
236
236
 
237
- **MEDIUM VALUE cho pi-crew:**
237
+ **MEDIUM VALUE for pi-crew:**
238
238
 
239
- pi-crew `YieldResult` compaction tracking — thể dùng pattern này:
239
+ pi-crew has `YieldResult` and compaction tracking — can use this pattern:
240
240
 
241
241
  1. **Typed cancellation errors** — `CrewCancelledError`, `CrewTimeoutError`, `CrewDeadletterError`
242
- 2. **Better error discrimination** — Thay string matching, dùng `instanceof`
242
+ 2. **Better error discrimination** — Instead of string matching, use `instanceof`
243
243
  3. **Error outcome tracking** — `CrewRunOutcome = "ok" | "cancelled" | "failed" | "deadletter"`
244
244
 
245
245
  **Implementation approach:**
@@ -261,24 +261,24 @@ export class CrewDeadletterError extends Error {
261
261
  }
262
262
  ```
263
263
 
264
- **Effort: LOW** — chỉ cần create error classes replace `instanceof Error` checks
264
+ **Effort: LOW** — just create the error classes and replace `instanceof Error` checks
265
265
 
266
266
  ### Risk/Dependency
267
- - None — pure TypeScript, thể copy pattern
268
- - Cần audit existing error handling để update
267
+ - None — pure TypeScript, can copy the pattern
268
+ - Need to audit existing error handling to update
269
269
 
270
270
  ---
271
271
 
272
272
  ## 6. Feature: ACP Agent Session (`acp-agent.ts`)
273
273
 
274
- ### Mục đích
275
- ACP protocol handler trong oh-my-pi. Mở rộng từ `agent-session.ts` với:
274
+ ### Purpose
275
+ ACP protocol handler in oh-my-pi. Extends from `agent-session.ts` with:
276
276
  - Fork sessions (clone session state)
277
277
  - Session list/load/resume
278
278
  - Model state management
279
279
  - MCP server discovery
280
280
 
281
- ### Cách hoạt động
281
+ ### How it works
282
282
 
283
283
  **ACP Protocol types:**
284
284
  ```typescript
@@ -289,42 +289,42 @@ type ClientCapabilities (fs, terminal, permission)
289
289
  ```
290
290
 
291
291
  **Key capabilities:**
292
- - `forkSession` — Clone session với same conversation history
292
+ - `forkSession` — Clone a session with the same conversation history
293
293
  - `listSessions` — Enumerate active sessions
294
- - `loadSession` / `resumeSession` — Restore previous session
294
+ - `loadSession` / `resumeSession` — Restore a previous session
295
295
  - `setSessionModel` — Change model mid-session
296
296
 
297
- ### Potential apply cho pi-crew
297
+ ### Potential application to pi-crew
298
298
 
299
- **HIGH VALUE cho pi-crew:**
299
+ **HIGH VALUE for pi-crew:**
300
300
 
301
- 1. **Fork session** — Trong workflow orchestration, thể fork một agent session để chạy parallel experiments
302
- 2. **Session resume** — Resume a previous run từ manifest/events
303
- 3. **Model switching** — Change model for specific tasks (e.g., cheap model for exploration, expensive model for final generation)
301
+ 1. **Fork session** — In workflow orchestration, could fork an agent session to run parallel experiments
302
+ 2. **Session resume** — Resume a previous run from manifest/events
303
+ 3. **Model switching** — Change model for specific tasks (e.g. cheap model for exploration, expensive model for final generation)
304
304
 
305
305
  **Current pi-crew state:**
306
- - pi-crew đã `ResumeSession` cho team runs (re-spawn child Pi)
307
- - Nhưng không in-process session fork
306
+ - pi-crew already has `ResumeSession` for team runs (re-spawn child Pi)
307
+ - But no in-process session fork
308
308
 
309
309
  **Implementation approach:**
310
- - `forkLiveAgentSession()` — Clone `LiveAgentHandle` với same conversation
311
- - Store forked sessions trong `live-agent-manager.ts`
312
- - Add `fork-session` operation vào `team-tool api`
310
+ - `forkLiveAgentSession()` — Clone `LiveAgentHandle` with the same conversation
311
+ - Store forked sessions in `live-agent-manager.ts`
312
+ - Add a `fork-session` operation to the `team-tool api`
313
313
 
314
- **Effort: HIGH** — cần deep understanding của `LiveSessionHandle` session state
314
+ **Effort: HIGH** — needs deep understanding of `LiveSessionHandle` and session state
315
315
 
316
316
  ### Risk/Dependency
317
317
  - Requires oh-my-pi internals (AgentSession, ToolSession)
318
- - pi-crew dùng child Pi process — fork thể không tương thích
318
+ - pi-crew uses a child Pi process — fork may not be compatible
319
319
 
320
320
  ---
321
321
 
322
322
  ## 7. Feature: User Metrics (`stats/src/user-metrics.ts`)
323
323
 
324
- ### Mục đích
325
- Tracking aggregation của user behavior metrics: edits, tools usage, model selection, cost, session quality.
324
+ ### Purpose
325
+ Tracking and aggregation of user behavior metrics: edits, tool usage, model selection, cost, session quality.
326
326
 
327
- ### Cách hoạt động
327
+ ### How it works
328
328
 
329
329
  **Database schema:**
330
330
  - Sessions table: session_id, start_time, end_time, model, cost
@@ -337,30 +337,30 @@ Tracking và aggregation của user behavior metrics: edits, tools usage, model
337
337
  - Model comparison: cost vs quality per model
338
338
  - Session summary: duration, token usage, task completion rate
339
339
 
340
- ### Potential apply cho pi-crew
340
+ ### Potential application to pi-crew
341
341
 
342
342
  **MEDIUM VALUE:**
343
343
 
344
- pi-crew đã `UsageTracker` `MetricsRegistry` — thể học:
344
+ pi-crew already has `UsageTracker` and `MetricsRegistry` — can learn from:
345
345
 
346
346
  1. **Team metrics** — Track team run performance (workflow duration, agent utilization, cost)
347
347
  2. **Agent quality scoring** — Rate agent output quality
348
348
  3. **Cost tracking** — Per-agent, per-task, per-team cost
349
349
 
350
- **Effort: MEDIUM** — Cần design database schema API
350
+ **Effort: MEDIUM** — Need to design a database schema and API
351
351
 
352
352
  ### Risk/Dependency
353
- - SQLite hoặc separate database
353
+ - SQLite or a separate database
354
354
  - Privacy implications (storing user behavior data)
355
355
 
356
356
  ---
357
357
 
358
358
  ## 8. Feature: Shell Minimizer (`crates/pi-shell/src/minimizer/`)
359
359
 
360
- ### Mục đích
361
- Tự động minimize command output (loại bỏ noise như progress bars, ANSI codes) để LLM đọc được kết quả clean hơn.
360
+ ### Purpose
361
+ Automatically minimize command output (remove noise like progress bars, ANSI codes) so the LLM can read cleaner results.
362
362
 
363
- ### Cách hoạt động
363
+ ### How it works
364
364
 
365
365
  **100+ TOML config files:**
366
366
  - `cargo.toml` — Filter cargo progress output
@@ -378,63 +378,63 @@ pub struct Minimizer {
378
378
  // Filter types: line removal, replacement, truncation
379
379
  ```
380
380
 
381
- ### Potential apply cho pi-crew
381
+ ### Potential application to pi-crew
382
382
 
383
- **HIGH VALUE cho pi-crew:**
383
+ **HIGH VALUE for pi-crew:**
384
384
 
385
- pi-crew agents chạy bash commands — output thể rất noisy. Minimizer giúp:
386
- - Agent đọc được clean output
387
- - Giảm context usage
388
- - Tập trung vào important information
385
+ pi-crew agents run bash commands — the output can be very noisy. The minimizer helps:
386
+ - Agents read clean output
387
+ - Reduces context usage
388
+ - Focuses on important information
389
389
 
390
390
  **Implementation approach:**
391
- 1. Fork minimizer engine (Rust) hoặc port sang TypeScript
392
- 2. Integrate vào `TaskRunner` bash execution
393
- 3. Auto-detect command type apply appropriate filter
391
+ 1. Fork the minimizer engine (Rust) or port to TypeScript
392
+ 2. Integrate into `TaskRunner` bash execution
393
+ 3. Auto-detect command type and apply the appropriate filter
394
394
 
395
- **Effort: HIGH** — Rust code cần rewrite hoặc integration via FFI
395
+ **Effort: HIGH** — Rust code needs rewriting or integration via FFI
396
396
 
397
397
  ### Risk/Dependency
398
398
  - Rust dependency
399
- - May not be necessary nếu oh-my-pi tách thành standalone tool
399
+ - May not be necessary if oh-my-pi splits it into a standalone tool
400
400
 
401
401
  ---
402
402
 
403
403
  ## 9. Feature: MCP Helper (`slash-commands/helpers/mcp.ts`)
404
404
 
405
- ### Mục đích
406
- Helper cho MCP (Model Context Protocol) slash commands. Quản MCP server configuration tool invocation.
405
+ ### Purpose
406
+ Helper for MCP (Model Context Protocol) slash commands. Manages MCP server configuration and tool invocation.
407
407
 
408
- ### Cách hoạt động
408
+ ### How it works
409
409
 
410
- 532 lines TypeScript. **Key functions:**
410
+ 532 lines of TypeScript. **Key functions:**
411
411
  - `resolveMcpServer` — Resolve MCP server config
412
- - `invokeMcpTool` — Call MCP tool
412
+ - `invokeMcpTool` — Call an MCP tool
413
413
  - `listMcpResources` — List available resources
414
414
  - `mcpServerStatus` — Check server health
415
415
 
416
- ### Potential apply cho pi-crew
416
+ ### Potential application to pi-crew
417
417
 
418
418
  **MEDIUM VALUE:**
419
419
 
420
- pi-crew đã `McpProxy` trong `live-extension-bridge.ts` — thể học thêm:
420
+ pi-crew already has `McpProxy` in `live-extension-bridge.ts` — can learn more:
421
421
  1. **MCP server lifecycle** — Start/stop MCP servers per team
422
- 2. **MCP tool routing** — Route MCP calls qua team session
422
+ 2. **MCP tool routing** — Route MCP calls through the team session
423
423
 
424
- **Effort: LOW** — chỉ cần học pattern, không cần port code
424
+ **Effort: LOW** — just learn the pattern, no need to port code
425
425
 
426
426
  ### Risk/Dependency
427
427
  - MCP protocol knowledge required
428
- - thể reuse existing `buildMcpProxyFromSession`
428
+ - Can reuse the existing `buildMcpProxyFromSession`
429
429
 
430
430
  ---
431
431
 
432
432
  ## 10. Feature: Issue-PR Protocol (`internal-urls/issue-pr-protocol.ts`)
433
433
 
434
- ### Mục đích
435
- Protocol handler cho `issue://` `pr://` internal URLs. Cho phép agents interact với GitHub/GitLab issues PRs qua unified interface.
434
+ ### Purpose
435
+ Protocol handler for `issue://` and `pr://` internal URLs. Lets agents interact with GitHub/GitLab issues and PRs through a unified interface.
436
436
 
437
- ### Cách hoạt động
437
+ ### How it works
438
438
 
439
439
  ```typescript
440
440
  // Handle URLs like:
@@ -449,16 +449,16 @@ Protocol handler cho `issue://` và `pr://` internal URLs. Cho phép agents inte
449
449
  - `comment` — Add comment
450
450
  - `close` / `reopen` — State transitions
451
451
 
452
- ### Potential apply cho pi-crew
452
+ ### Potential application to pi-crew
453
453
 
454
- **HIGH VALUE cho pi-crew:**
454
+ **HIGH VALUE for pi-crew:**
455
455
 
456
- pi-crew workflow agents thể benefit từ issue/PR integration:
457
- 1. **Task creation** — Create issue từ failed task
458
- 2. **PR review** — Use `pr://` protocol trong review workflow
456
+ pi-crew workflow agents can benefit from issue/PR integration:
457
+ 1. **Task creation** — Create an issue from a failed task
458
+ 2. **PR review** — Use the `pr://` protocol in the review workflow
459
459
  3. **Task linking** — Link workflow tasks to issues
460
460
 
461
- **Effort: MEDIUM** — Cần port `issue-pr-protocol.ts` (577 lines)
461
+ **Effort: MEDIUM** — Need to port `issue-pr-protocol.ts` (577 lines)
462
462
 
463
463
  ### Risk/Dependency
464
464
  - GitHub API authentication
@@ -468,42 +468,42 @@ pi-crew workflow agents có thể benefit từ issue/PR integration:
468
468
 
469
469
  ## Summary: Recommendations
470
470
 
471
- ### Tier 1 — High Value, Medium Effort (Ưu tiên cao)
471
+ ### Tier 1 — High Value, Medium Effort (High priority)
472
472
 
473
473
  | Feature | Why | Effort | Notes |
474
474
  |---|---|---|---|
475
- | **Conflict Detection** | Prevents data loss khi multiple agents edit same file | MEDIUM | Fork `conflict-detect.ts`, add `conflict://` protocol |
475
+ | **Conflict Detection** | Prevents data loss when multiple agents edit the same file | MEDIUM | Fork `conflict-detect.ts`, add `conflict://` protocol |
476
476
  | **Typed Crew Errors** | Better error handling, cleaner code | LOW | Create `CrewCancelledError`, `CrewTimeoutError`, `CrewDeadletterError` |
477
- | **Todo Integration** | Task tracking cho team workflows | MEDIUM | Fork `todo.ts`, integrate với `TaskRunner` |
478
- | **Issue-PR Protocol** | Link team tasks với GitHub issues | MEDIUM | Port `issue-pr-protocol.ts` |
477
+ | **Todo Integration** | Task tracking for team workflows | MEDIUM | Fork `todo.ts`, integrate with `TaskRunner` |
478
+ | **Issue-PR Protocol** | Link team tasks to GitHub issues | MEDIUM | Port `issue-pr-protocol.ts` |
479
479
 
480
- ### Tier 2 — High Value, High Effort (Ưu tiên thấp hơn)
480
+ ### Tier 2 — High Value, High Effort (Lower priority)
481
481
 
482
482
  | Feature | Why | Effort | Notes |
483
483
  |---|---|---|---|
484
- | **Shell Minimizer** | Clean command output cho agents | HIGH | Rust → TypeScript port hoặc FFI |
485
- | **ACP Fork Session** | Parallel agent experiments | HIGH | Cần deep `LiveSessionHandle` understanding |
484
+ | **Shell Minimizer** | Clean command output for agents | HIGH | Rust → TypeScript port or FFI |
485
+ | **ACP Fork Session** | Parallel agent experiments | HIGH | Needs deep `LiveSessionHandle` understanding |
486
486
  | **User Metrics** | Team performance analytics | MEDIUM | Design DB schema, build API |
487
487
 
488
- ### Tier 3 — Low Value (Không ưu tiên)
488
+ ### Tier 3 — Low Value (Not prioritized)
489
489
 
490
490
  | Feature | Why | Effort |
491
491
  |---|---|---|
492
- | Hashline Engine | Strongly coupled với oh-my-pi | HIGH |
493
- | ACP Client Bridge | pi-crew đã `LiveExtensionBridge` | LOW |
494
- | MCP Helper | pi-crew đã `McpProxy` | LOW |
492
+ | Hashline Engine | Strongly coupled to oh-my-pi | HIGH |
493
+ | ACP Client Bridge | pi-crew already has `LiveExtensionBridge` | LOW |
494
+ | MCP Helper | pi-crew already has `McpProxy` | LOW |
495
495
 
496
496
  ---
497
497
 
498
498
  ## Next Steps
499
499
 
500
- 1. **Conflict Detection** — Start với porting `conflict-detect.ts` standalone high-value
501
- 2. **Typed Errors** — Quick win, chỉ cần create error classes
502
- 3. **Todo Integration** — Long-term, cần integrate với workflow engine
500
+ 1. **Conflict Detection** — Start with porting `conflict-detect.ts` because it's standalone and high-value
501
+ 2. **Typed Errors** — Quick win, just create the error classes
502
+ 3. **Todo Integration** — Long-term, needs integration with the workflow engine
503
503
 
504
- ## Files cần đọc thêm
504
+ ## Files to read further
505
505
 
506
- - `packages/coding-agent/src/tools/conflict-detect.ts` (toàn bộ)
507
- - `packages/coding-agent/src/tools/todo-write.ts` (dependency của todo.ts)
508
- - `packages/coding-agent/src/session/agent-session.ts` (phần fork/resume session)
509
- - `crates/pi-shell/src/minimizer/engine.rs` (nếu muốn port shell minimizer)
506
+ - `packages/coding-agent/src/tools/conflict-detect.ts` (entire file)
507
+ - `packages/coding-agent/src/tools/todo-write.ts` (dependency of todo.ts)
508
+ - `packages/coding-agent/src/session/agent-session.ts` (the fork/resume session part)
509
+ - `crates/pi-shell/src/minimizer/engine.rs` (if you want to port the shell minimizer)
@@ -1,5 +1,7 @@
1
1
  # pi-crew Optimization Plan: coding-agent Integration
2
2
 
3
+ > **Status note (2026-06-22):** Dated 2026-05-28 — verify against current code before acting. Some items may already be implemented.
4
+
3
5
  **Date:** 2026-05-28
4
6
  **Based on:** 133 coding-agent commits (May 2026), direct source analysis
5
7
  **Goal:** Implement 4 optimization opportunities for pi-crew
@@ -79,18 +79,18 @@ $env:BASELINE = "test/bench/baseline-2026-05.json"
79
79
 
80
80
  CPU profile: `.profile/startup-2026-05-14T14-38-20-180Z.cpuprofile` (open in Chrome DevTools → Performance → Load profile).
81
81
 
82
- > `registerMs` thấp hơn bench register-startup profile chạy 5 iter trong cùng một process (module cache nóng sau iter 1). Bench `register-startup` mới phản ánh cold-start thực.
82
+ > `registerMs` is lower than the register-startup bench because the profile runs 5 iters in the same process (the module cache is warm after iter 1). The `register-startup` bench is what reflects the actual cold start.
83
83
 
84
- ## Sprint targets (so với baseline trên)
84
+ ## Sprint targets (vs. the baseline above)
85
85
 
86
- | Metric | Baseline | Target sau khi xong toàn bộ kế hoạch | Sprint kỳ vọng |
86
+ | Metric | Baseline | Target after completing the full plan | Expected sprint |
87
87
  |---|---|---|---|
88
88
  | register-startup.import.p95 | 655 ms | ≤ 400 ms (lazy) / ≤ 200 ms (bundled) | 2 / 5 |
89
- | register-startup.register.p95 | 27.5 ms | ≤ 25 ms (giữ nguyên) | — |
90
- | render-flush.p95 | 0.36 ms | ≤ 0.5 ms (giữ nguyên) | — |
89
+ | register-startup.register.p95 | 27.5 ms | ≤ 25 ms (keep as-is) | — |
90
+ | render-flush.p95 | 0.36 ms | ≤ 0.5 ms (keep as-is) | — |
91
91
  | snapshot-cache.cold.p95 | 3.06 ms | ≤ 2.1 ms (-30%) | 1, 2 |
92
92
  | snapshot-cache.warm.p95 | 3.06 ms | ≤ 1.5 ms (-50%) | 1, 2 |
93
- | dashboard FPS khi run đang chạy | n/a | +50% | 3 |
93
+ | dashboard FPS while a run is active | n/a | +50% | 3 |
94
94
  | events.jsonl tail 32 KB parse p95 | n/a | < 5 ms | 2 |
95
95
  | cancel round-trip | n/a | < 200 ms | 4 |
96
96
 
@@ -108,6 +108,6 @@ CPU profile: `.profile/startup-2026-05-14T14-38-20-180Z.cpuprofile` (open in Chr
108
108
 
109
109
  ## Caveats
110
110
 
111
- - Baseline được ghi trên 1 máy Windows duy nhất. Các máy khác CPU/disk khác nhau sẽ ra số khác. Khi cần re-baseline (Node major bump, OS upgrade, máy CI khác), copy `results.json → baseline.json` viết file mới `baseline-<date>.md`.
112
- - `register-startup` bench tốn ~13 s (20 iter × 600 ms); CI nên giữ. Local thể `BENCH_ITERS=5` để debug nhanh.
113
- - Bench không chạy trong `npm test` để giữ test suite nhanh; trigger riêng qua `npm run bench` hoặc CI step riêng.
111
+ - The baseline was recorded on a single Windows machine. Other machines with different CPU/disk will produce different numbers. When you need to re-baseline (Node major bump, OS upgrade, different CI machine), copy `results.json → baseline.json` and write a new file `baseline-<date>.md`.
112
+ - The `register-startup` bench takes ~13 s (20 iters × 600 ms); keep it in CI. Locally you can set `BENCH_ITERS=5` for fast debugging.
113
+ - The bench does not run as part of `npm test` to keep the test suite fast; trigger it separately via `npm run bench` or a dedicated CI step.
@@ -37,7 +37,7 @@ projected to bring `register-startup.import.p95` to ≤ 250 ms after a
37
37
  - Bonus fix: pre-existing `// LAZY:` marker missing in
38
38
  `src/runtime/background-runner.ts`
39
39
 
40
- ### Sprint 1 — UI mượt rủi ro thấp (6 items)
40
+ ### Sprint 1 — Smooth UI, low risk (6 items)
41
41
 
42
42
  - 1.4 events stamp via `.seq` sequence file
43
43
  - 1.5 drop per-agent outputStamp from SnapshotStamps
@@ -47,7 +47,7 @@ projected to bring `register-startup.import.p95` to ≤ 250 ms after a
47
47
  - 1.2 drop sync `refreshIfStale` fallback on hot render path
48
48
  - 1.10 mascot pause idle — skipped (mascot is splash, not always-on)
49
49
 
50
- ### Sprint 2 — Cắt I/O sync hot path (4 items)
50
+ ### Sprint 2 — Cut I/O sync hot path (4 items)
51
51
 
52
52
  - 2.10 cache findRepoRoot lookups (TTL-LRU 30 s)
53
53
  - 2.7 lazy-load OTLPExporter, LiveRunSidebar, crash-recovery