pi-crew 0.5.14 → 0.5.17

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 (90) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/README.md +1 -1
  3. package/docs/pi-crew-v0.5.16-audit-fix-plan.md +35 -0
  4. package/docs/pi-crew-v0.5.17-audit-fix-plan.md +80 -0
  5. package/docs/skills/REFERENCE.md +11 -0
  6. package/package.json +1 -1
  7. package/skills/artifact-analysis-loop/SKILL.md +1 -0
  8. package/skills/async-worker-recovery/SKILL.md +1 -0
  9. package/skills/child-pi-spawning/SKILL.md +1 -0
  10. package/skills/context-artifact-hygiene/SKILL.md +1 -0
  11. package/skills/delegation-patterns/SKILL.md +1 -0
  12. package/skills/detection-pipeline-design/SKILL.md +2 -1
  13. package/skills/event-log-tracing/SKILL.md +1 -0
  14. package/skills/git-master/SKILL.md +1 -0
  15. package/skills/hunting-investigation-loop/SKILL.md +1 -0
  16. package/skills/incident-playbook-construction/SKILL.md +1 -0
  17. package/skills/iterative-audit/SKILL.md +331 -0
  18. package/skills/live-agent-lifecycle/SKILL.md +1 -0
  19. package/skills/mailbox-interactive/SKILL.md +1 -0
  20. package/skills/model-routing-context/SKILL.md +2 -1
  21. package/skills/multi-perspective-review/SKILL.md +1 -0
  22. package/skills/observability-reliability/SKILL.md +1 -0
  23. package/skills/orchestration/SKILL.md +2 -1
  24. package/skills/ownership-session-security/SKILL.md +1 -0
  25. package/skills/pi-extension-lifecycle/SKILL.md +3 -2
  26. package/skills/post-mortem/SKILL.md +1 -0
  27. package/skills/read-only-explorer/SKILL.md +1 -0
  28. package/skills/requirements-to-task-packet/SKILL.md +1 -0
  29. package/skills/resource-discovery-config/SKILL.md +2 -1
  30. package/skills/runtime-state-reader/SKILL.md +1 -0
  31. package/skills/safe-bash/SKILL.md +1 -0
  32. package/skills/scrutinize/SKILL.md +1 -0
  33. package/skills/secure-agent-orchestration-review/SKILL.md +1 -0
  34. package/skills/security-review/SKILL.md +1 -0
  35. package/skills/state-mutation-locking/SKILL.md +1 -0
  36. package/skills/systematic-debugging/SKILL.md +1 -0
  37. package/skills/threat-hypothesis-framework/SKILL.md +1 -0
  38. package/skills/ui-render-performance/SKILL.md +2 -1
  39. package/skills/verification-before-done/SKILL.md +1 -0
  40. package/skills/widget-rendering/SKILL.md +2 -1
  41. package/skills/workspace-isolation/SKILL.md +1 -0
  42. package/skills/worktree-isolation/SKILL.md +1 -0
  43. package/src/config/types.ts +1 -0
  44. package/src/extension/management.ts +1 -1
  45. package/src/extension/plan-orchestrate.ts +0 -1
  46. package/src/extension/register.ts +16 -7
  47. package/src/extension/registration/viewers.ts +1 -1
  48. package/src/extension/run-index.ts +1 -1
  49. package/src/extension/team-tool/explain.ts +0 -1
  50. package/src/extension/team-tool/handle-schedule.ts +0 -1
  51. package/src/extension/team-tool/health-monitor.ts +0 -1
  52. package/src/extension/team-tool/orchestrate.ts +12 -4
  53. package/src/extension/team-tool/run.ts +2 -2
  54. package/src/extension/team-tool/status.ts +1 -1
  55. package/src/extension/team-tool.ts +2 -30
  56. package/src/observability/exporters/otlp-exporter.ts +11 -1
  57. package/src/runtime/adaptive-plan.ts +18 -2
  58. package/src/runtime/child-pi.ts +18 -6
  59. package/src/runtime/crash-recovery.ts +1 -1
  60. package/src/runtime/crew-agent-records.ts +23 -3
  61. package/src/runtime/crew-hooks.ts +1 -1
  62. package/src/runtime/dynamic-script-runner.ts +14 -1
  63. package/src/runtime/handoff-manager.ts +0 -1
  64. package/src/runtime/heartbeat-watcher.ts +1 -1
  65. package/src/runtime/live-session-runtime.ts +0 -1
  66. package/src/runtime/loop-gates.ts +0 -1
  67. package/src/runtime/mcp-proxy.ts +2 -2
  68. package/src/runtime/pipeline-runner.ts +1 -2
  69. package/src/runtime/sandbox.ts +8 -0
  70. package/src/runtime/task-packet.ts +124 -0
  71. package/src/runtime/task-runner/live-executor.ts +1 -2
  72. package/src/runtime/task-runner/prompt-builder.ts +4 -1
  73. package/src/runtime/task-runner.ts +2 -2
  74. package/src/schema/config-schema.ts +1 -0
  75. package/src/state/event-log.ts +7 -0
  76. package/src/state/jsonl-writer.ts +24 -0
  77. package/src/state/locks.ts +66 -35
  78. package/src/state/run-metrics.ts +1 -2
  79. package/src/state/schedule.ts +13 -5
  80. package/src/state/state-store.ts +1 -1
  81. package/src/tools/safe-bash-extension.ts +1 -1
  82. package/src/tools/safe-bash.ts +10 -1
  83. package/src/ui/crew-widget.ts +2 -2
  84. package/src/ui/render-diff.ts +1 -1
  85. package/src/ui/run-dashboard.ts +1 -2
  86. package/src/ui/tool-render.ts +20 -3
  87. package/src/utils/conflict-detect.ts +0 -1
  88. package/src/utils/gh-protocol.ts +0 -2
  89. package/src/workflows/workflow-config.ts +3 -0
  90. package/src/worktree/worktree-manager.ts +75 -1
@@ -0,0 +1,331 @@
1
+ ---
2
+ name: iterative-audit
3
+ description: "Iterative multi-round codebase audit with diminishing-returns detection. Run 5-20+ rounds, each focusing on one specific area. Built from 19 rounds of dogfooding pi-crew on itself."
4
+ origin: pi-crew
5
+ triggers:
6
+ - "audit this codebase"
7
+ - "review everything"
8
+ - "find all bugs"
9
+ - "deep audit"
10
+ - "harden this"
11
+ - "iterate audit rounds"
12
+ - "multi-round review"
13
+ ---
14
+
15
+ # Iterative Audit
16
+
17
+ > Distilled from 19 rounds of auditing pi-crew on itself (v0.5.5 → v0.5.14):
18
+ > ~70 issues fixed, 286 tests added, 9 security improvements, 2 performance improvements.
19
+
20
+ The core insight: **a single round of audit finds the easy 30% of bugs**. The remaining 70% only surfaces through 5-20+ targeted rounds, each with a specific focus. After round 5+ you find HIGH severity bugs that round 1 missed. After round 10+ you find issues that no human reviewer would catch in a single pass.
21
+
22
+ ## Operating Stance
23
+
24
+ - **One focus per round.** Each round targets one of the 7 patterns below. Don't try to fix everything in one pass.
25
+ - **Source verification is mandatory.** Never trust audit docs or previous round reports — always read the actual code. ~30% of issues from prior rounds are false positives or already fixed.
26
+ - **Document every finding with file:line.** "Sandbox env allow-list" is useless. "src/runtime/sandbox.ts:70 — process.env full leak" is actionable.
27
+ - **Verify the team actually applied changes.** After any team run, run `git diff` and inspect. ~20% of team runs silently fail to apply changes.
28
+ - **Don't publish without explicit user confirmation.** Audit work compounds; releasing in the middle of a round leaves the codebase in a half-hardened state.
29
+
30
+ ## The 7 Patterns (rotate through these)
31
+
32
+ After 19 rounds, every issue found falls into one of these 7 categories. Use this to plan each round's focus.
33
+
34
+ ### 1. L1 Cleanup (decoration, low value, easy)
35
+ **What**: Replace `console.error` / `console.warn` / `process.stderr.write` with `logInternalError()` from `utils/internal-error.ts`.
36
+
37
+ **Why**: `console.error` may not be visible in JSON-RPC mode or when stderr is redirected. `logInternalError` is the project-wide pattern; missing it means errors are silently dropped.
38
+
39
+ **How to find them**:
40
+ ```bash
41
+ rg -n 'console\.(error|warn|log)' src/
42
+ rg -n 'process\.stderr\.write' src/
43
+ ```
44
+
45
+ **Rule**: Skip `internal-error.ts:5` itself (it's the implementation). Skip `background-runner.ts:146` (overrides `console.error` for testing). Skip `parent-guard.ts:37` (exit-time log must fire synchronously).
46
+
47
+ **Time per round**: 30 min for 5-10 callsites. Diminishing returns after round 1.
48
+
49
+ ### 2. Defensive Caps (memory safety, medium value, medium effort)
50
+ **What**: Find Maps, Sets, Arrays, and Queues that grow unboundedly. Add `MAX_*` constants and eviction logic.
51
+
52
+ **Why**: Long-running processes (background runners, extension reloads) accumulate state. Without caps, a busy period causes OOM.
53
+
54
+ **How to find them**:
55
+ ```bash
56
+ rg -n 'new Map\(' src/ # look for ones that are .set() repeatedly
57
+ rg -n 'new Set\(' src/
58
+ rg -n 'this\.\w+\.push\(' src/ # look for unbounded arrays
59
+ ```
60
+
61
+ **Common patterns**:
62
+ - `Semaphore.#queue` → add `MAX_QUEUE` cap (pi-crew: 10,000)
63
+ - `liveAgentManager.liveAgents` Map → add `MAX_LIVE_AGENTS` cap (pi-crew: 5,000)
64
+ - `OverflowRecoveryTracker.states` Map → add `MAX_TRACKED_STATES` cap (pi-crew: 5,000)
65
+ - `NotificationRouter.seen` Map → add `SEEN_MAP_MAX_SIZE` cap (pi-crew: 10,000)
66
+
67
+ **Eviction strategies** (in order of preference):
68
+ 1. **LRU by access time** — track `lastAccessAt` per entry
69
+ 2. **Oldest insertion** — Map's natural insertion order works (delete first key)
70
+ 3. **Terminal-state priority** — protect live entries, evict completed/failed/cancelled first
71
+
72
+ **Test pattern**: Verify cap by inserting 1.5× the max, confirm old entries are gone.
73
+
74
+ ### 3. Test Coverage Gaps (good value, low effort)
75
+ **What**: Find source files with zero direct unit tests.
76
+
77
+ **How to find them**:
78
+ ```bash
79
+ # For each src file, check if any test file imports it
80
+ for f in src/runtime/*.ts src/extension/*.ts; do
81
+ basename=$(basename "$f" .ts)
82
+ count=$(ls test/unit/${basename}*.test.ts 2>/dev/null | wc -l)
83
+ [ "$count" = "0" ] && echo "NO TEST: $f"
84
+ done
85
+ ```
86
+
87
+ **Prioritize**:
88
+ - Security-critical: `sandbox.ts`, `child-pi.ts`, `pi-spawn.ts`, `crew-cleanup.ts`
89
+ - Resource-management: `live-agent-manager.ts`, `semaphore.ts`, `overflow-recovery.ts`
90
+ - Public APIs: anything with `export class` or `export function`
91
+
92
+ **Don't test**: internal helpers, generated code, pure re-exports.
93
+
94
+ **Test categories** (in order of importance):
95
+ 1. **Path validation** (security) — `assertSafePathId`, path traversal rejection
96
+ 2. **Resource cleanup** — `dispose()` clears everything, listeners don't stack
97
+ 3. **Boundary conditions** — empty input, max-size, overflow
98
+ 4. **Callback lifecycle** — sync/async error handling, `resultConsumed` flag
99
+
100
+ ### 4. Security Hardening (high value, high effort)
101
+ **What**: Find places where untrusted input reaches dangerous sinks.
102
+
103
+ **Common sinks to audit**:
104
+ - `execSync(command)` → switch to `execFileSync(program, args[])`
105
+ - `eval()` / `Function()` / `vm.runInNewContext()` → avoid entirely
106
+ - `path.join(base, userInput)` → use `assertSafePathId(userInput)` first
107
+ - `process.env` access → use sanitized env with allow-list
108
+ - File writes to user-controlled paths → validate path is within allowed roots
109
+ - Child process spawn → use `cwd: knownDir`, sanitize env
110
+
111
+ **How to find them**:
112
+ ```bash
113
+ rg -n 'execSync\(' src/
114
+ rg -n 'exec\(' src/
115
+ rg -n 'eval\(|Function\(' src/
116
+ rg -n 'spawn\(' src/
117
+ rg -n 'path\.join\(' src/ | rg 'record\.|task\.|runId|agent\.'
118
+ ```
119
+
120
+ **Round 1**: Find all `execSync` and `exec`. Switch to `execFileSync(program, args)` (no shell).
121
+ **Round 2**: Audit env handling. Look for `process.env` access in hot paths. Add allow-list.
122
+ **Round 3**: Path traversal. For every `path.join(base, userInput)`, add `assertSafePathId()`.
123
+ **Round 4**: Subprocess safety. Verify all `spawn()` calls have: validated args, sanitized env, `cwd` set, signal handling, timeout.
124
+
125
+ ### 5. Performance (medium value, medium effort)
126
+ **What**: Find O(N²) or worse algorithms, especially in hot paths.
127
+
128
+ **Common patterns**:
129
+ - Recomputing document frequency in search loops → precompute at construction
130
+ - `array.filter().map().filter()` in a loop → fuse into one pass
131
+ - `JSON.parse` of the same file repeatedly → cache
132
+ - `fs.statSync` per file in a directory scan → batch with `Dirent.isDirectory()`
133
+ - `setTimeout` busy-polling for state changes → use `fs.watch` or events
134
+
135
+ **How to find them**:
136
+ ```bash
137
+ # Look for nested loops over the same data
138
+ rg -nB 1 -A 5 'for.*of.*for' src/
139
+ # Look for polls
140
+ rg -n 'setTimeout.*poll' src/
141
+ rg -n 'pollIntervalMs' src/
142
+ ```
143
+
144
+ **Test pattern**: For precomputation fixes, write a perf test that creates 1000 docs, runs search, and asserts completion under 100ms.
145
+
146
+ ### 6. Code Quality (low value, easy)
147
+ **What**: Remove dead code, fix type misuse, add missing JSDoc.
148
+
149
+ **Common patterns**:
150
+ - Fields declared but never used (e.g., `seenCleanupCounter`)
151
+ - Unused imports
152
+ - Type assertions (`as any`, `as unknown as T`) that hide real issues
153
+ - Functions that always return the same value
154
+ - Catch blocks that swallow errors silently
155
+
156
+ **How to find them**:
157
+ ```bash
158
+ # Find fields/methods declared but never used
159
+ rg -n 'private \w+\s*=\s*' src/ | while read line; do
160
+ field=$(echo "$line" | grep -oP 'private \K\w+')
161
+ count=$(rg -c "\b$field\b" src/ 2>/dev/null | head -1)
162
+ [ "$count" = "1" ] && echo "DEAD: $line"
163
+ done
164
+ ```
165
+
166
+ ### 7. Resource Cleanup (medium value, medium effort)
167
+ **What**: Find places where listeners, timers, file handles, or other resources can leak.
168
+
169
+ **Common patterns**:
170
+ - `process.on('SIGTERM', ...)` registered multiple times → use module-level flag
171
+ - `setInterval` / `setTimeout` not cleared on shutdown → `dispose()` method
172
+ - `AbortController` not aborted in cleanup
173
+ - File watchers (`fs.watch`) not closed
174
+ - Event listeners (`emitter.on`) not removed
175
+
176
+ **How to find them**:
177
+ ```bash
178
+ rg -n 'process\.on\(' src/
179
+ rg -n 'setInterval\(' src/
180
+ rg -n 'setTimeout\(' src/ | rg -v 'setTimeout.*resolve' # filter out poll sleeps
181
+ rg -n 'fs\.watch\(' src/
182
+ ```
183
+
184
+ **Test pattern**: Call the registration function N times, verify listener count is 1.
185
+
186
+ ## Round Workflow (use this for EVERY round)
187
+
188
+ ### Step 1: Pick a focus
189
+ Choose ONE of the 7 patterns above. Don't try to do multiple patterns in one round.
190
+
191
+ ### Step 2: Explore (read 3-5 files)
192
+ Read the actual source for the focus area. Don't trust prior audit docs.
193
+
194
+ ### Step 3: Verify from source
195
+ For each candidate issue:
196
+ - Read the file at the cited line
197
+ - Check if the issue is real (not a false positive)
198
+ - Check if it's already fixed
199
+ - Note the exact file:line and code snippet
200
+
201
+ ### Step 4: Create a plan doc
202
+ ```markdown
203
+ # Round N Audit Fix Plan
204
+ ## Findings
205
+ ### Issue 1: <file>:<line> — <title> (severity)
206
+ <File path and line numbers>
207
+ <Code snippet showing the issue>
208
+ <Rationale>
209
+
210
+ ## Plan (5 phases)
211
+ ### Phase 1: <action>
212
+ ### Phase 2: <action>
213
+ ...
214
+ ```
215
+
216
+ ### Step 5: Implement
217
+ - Make the fix
218
+ - Add tests (if applicable)
219
+ - Run typecheck: `npx tsc --noEmit`
220
+ - Run tests: `npm test`
221
+
222
+ ### Step 6: Commit + Release
223
+ - Commit with conventional message: `fix: round N - <summary>`
224
+ - Update CHANGELOG.md
225
+ - Bump version (patch)
226
+ - Push + npm publish
227
+ - Create GitHub release
228
+
229
+ ### Step 7: Decide: continue or stop?
230
+ After 5-10 rounds, evaluate:
231
+
232
+ **Continue if**:
233
+ - Last 2 rounds found HIGH or MEDIUM severity issues
234
+ - Test coverage is < 80% of modules
235
+ - User explicitly wants more
236
+
237
+ **Stop if**:
238
+ - Last 2 rounds found only LOW severity or L1 cleanup
239
+ - All patterns exhausted (you've done each at least once)
240
+ - Diminishing returns: more time spent planning than implementing
241
+
242
+ ## When to Use Teams vs. Do It Yourself
243
+
244
+ **Use teams** (via `team action='run', team='review'`) for:
245
+ - Initial broad audit (round 1)
246
+ - Security reviews (specialized `security-reviewer` agent)
247
+ - When you need 3+ perspectives (multi-explorer)
248
+
249
+ **Do it yourself** for:
250
+ - Round 2+ (you have context from prior rounds)
251
+ - Focused single-pattern work (L1 cleanup, test coverage)
252
+ - Small fixes (< 5 file edits)
253
+
254
+ **Teams often fail because**:
255
+ - 5-min heartbeat timeout for long-running runs (add `startTeamRunHeartbeat` if needed)
256
+ - Agent cancellations
257
+ - Hallucinated file:line references (always verify from source)
258
+
259
+ ## Common False Positives (audit findings to reject)
260
+
261
+ After 19 rounds, ~30% of audit findings are false positives. Common patterns:
262
+
263
+ 1. **"Double-merge in config"** — looks like a bug, but project config + user config merge is intentional
264
+ 2. **"as unknown as T in error handling"** — necessary for TypeScript's strict mode
265
+ 3. **"Auto-repair timer race"** — there's a guard like `cleanedUp || !currentCtx` you missed
266
+ 4. **"Already-validated input"** — validation is in the caller, not the callee
267
+ 5. **"Redundant null check"** — TypeScript narrowing doesn't always work for closures
268
+
269
+ **Always verify against source** before acting. If you're not sure, write a test that exercises the alleged bug path. If the test passes, it's a false positive.
270
+
271
+ ## Success Metrics
272
+
273
+ After each round, record:
274
+ - Issues found (real vs. false positive)
275
+ - Tests added
276
+ - Typecheck clean?
277
+ - Total test count delta
278
+
279
+ **Healthy round**: 3-8 real issues found, +20 to +50 tests added, all pass.
280
+
281
+ **Exhausted round**: 0-1 real issues found, 0 tests added, mostly L1 cleanup.
282
+
283
+ When you hit 2+ exhausted rounds in a row, **stop**.
284
+
285
+ ## Real Examples from 19 Rounds
286
+
287
+ | Round | Focus | Issues Found | Severity Range |
288
+ |-------|-------|--------------|----------------|
289
+ | 1-3 | Broad security audit | 11 | CRITICAL, HIGH |
290
+ | 4-6 | Race conditions, locks | 5 | HIGH |
291
+ | 7-9 | L1 cleanup, dead code | 12 | LOW |
292
+ | 10-12 | Defensive caps | 3 | MEDIUM |
293
+ | 13-15 | Security: execSync, sandbox | 9 | CRITICAL, HIGH |
294
+ | 16-18 | Test coverage, L1 | 30+ | LOW |
295
+ | 19 | Path validation, tests | 5 | MEDIUM |
296
+
297
+ **Pattern**: First 3 rounds find the most impactful issues. Rounds 4-15 find the rest. Rounds 16+ are diminishing returns (mostly test coverage and L1 cleanup).
298
+
299
+ ## Anti-Patterns to Avoid
300
+
301
+ - **Mega-rounds** (10+ files, 5+ categories) — too broad, low quality findings
302
+ - **Trusting audit docs** — always verify from source
303
+ - **Skipping typecheck** — type errors compound and become hard to debug later
304
+ - **Releasing mid-round** — leaves the codebase in a half-hardened state
305
+ - **No test for the fix** — every fix needs a test that would have caught the bug
306
+ - **Committing too late** — commit after each phase, not at the end of the round
307
+
308
+ ## Enforcement — Iterative Audit Gate
309
+
310
+ **Before reporting round findings, verify:**
311
+
312
+ - [ ] Round focus is ONE of the 7 patterns (not multiple)
313
+ - [ ] Each finding has a verified `file:line` reference (read the actual source)
314
+ - [ ] False positives filtered out (consult "Common False Positives" section)
315
+ - [ ] Severity assigned using the standard scale (CRITICAL / HIGH / MEDIUM / LOW)
316
+ - [ ] Plan doc created with phases and file:line evidence
317
+ - [ ] Typecheck clean: `npx tsc --noEmit` returns 0 errors
318
+ - [ ] All tests pass: `npm test` shows 0 failures
319
+ - [ ] Tests added for the fix (if applicable)
320
+ - [ ] Round results recorded: issues found, tests added, delta
321
+ - [ ] Decision logged: continue to next round or stop (with reason)
322
+
323
+ **If ANY answer is NO → Stop. Complete audit requirements before reporting round results.**
324
+
325
+ ## Related Skills
326
+
327
+ - `scrutinize` — Quick outsider-perspective review of a single change
328
+ - `multi-perspective-review` — 8-pass deep review for a single change
329
+ - `security-review` — Security-focused audit with detection authoring
330
+ - `verification-before-done` — Evidence before claim (use per round)
331
+ - `systematic-debugging` — When a finding reveals a real bug that needs deeper investigation
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: live-agent-lifecycle
3
3
  description: "Live agent registration, workspace isolation, termination, and eviction workflow."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "register agent"
6
7
  - "terminate agent"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: mailbox-interactive
3
3
  description: "Interactive waiting-task and mailbox workflow."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "respond to worker"
6
7
  - "nudge agent"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: model-routing-context
3
3
  description: Model routing, parent context, thinking level, and prompt construction workflow. Use when changing model fallback, child Pi args, inherited context, task prompts, or compact-read behavior.
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "change model"
6
7
  - "parent context"
@@ -15,7 +16,7 @@ Use this skill when working on model/context propagation.
15
16
 
16
17
  ## Source patterns distilled
17
18
 
18
- - Pi session context/model state: `source/pi-mono/packages/coding-agent/src/core/session-manager.ts`, `agent-session.ts`, compaction modules
19
+ - Pi session context/model state: `source/pi/packages/coding-agent/src/core/session-manager.ts`, `agent-session.ts`, compaction modules
19
20
  - pi-crew model and prompt code: `src/runtime/model-fallback.ts`, `src/runtime/pi-args.ts`, `src/runtime/task-runner/prompt-builder.ts`, `src/runtime/task-output-context.ts`, `src/extension/team-tool/context.ts`
20
21
 
21
22
  ## Rules
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: multi-perspective-review
3
3
  description: "Multi-perspective code review with simpler-alternative pass."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "review this"
6
7
  - "look at this"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: observability-reliability
3
3
  description: "Metrics, diagnostics, correlation, retry, deadletter, and recovery evidence workflow."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "add metrics"
6
7
  - "diagnose failure"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: orchestration
3
3
  description: "Multi-phase orchestration for planners and executors."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "orchestrate this"
6
7
  - "coordinate tasks"
@@ -73,7 +74,7 @@ Maintain the original scope exactly. Không mở rộng scope vì "thấy thêm
73
74
  ### Step 3 — Dispatch phase
74
75
 
75
76
  - Launch all parallel subagents in one `team` call.
76
- - Each subagent receives a complete task packet (see `task-packet` skill).
77
+ - Each subagent receives a complete task packet (see `requirements-to-task-packet` skill).
77
78
  - Set explicit file ownership per worker — no two workers touch the same file.
78
79
  - Use `workspaceMode: 'worktree'` when parallel edits risk conflict.
79
80
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: ownership-session-security
3
3
  description: "Session ownership and authorization workflow."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "cancel run"
6
7
  - "respond to task"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: pi-extension-lifecycle
3
3
  description: Pi extension lifecycle and registration patterns.
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "add extension"
6
7
  - "register tools"
@@ -15,8 +16,8 @@ Use this skill when working on Pi extension registration or lifecycle behavior.
15
16
 
16
17
  ## Source patterns distilled
17
18
 
18
- - Pi core: `source/pi-mono/packages/coding-agent/src/core/extensions/types.ts`, `loader.ts`, `runner.ts`
19
- - Pi examples: `source/pi-mono/packages/coding-agent/examples/extensions/`
19
+ - Pi core: `source/pi/packages/coding-agent/src/core/extensions/types.ts`, `loader.ts`, `runner.ts`
20
+ - Pi examples: `source/pi/packages/coding-agent/examples/extensions/`
20
21
  - pi-crew extension entry: `src/extension/register.ts`, `src/extension/registration/*.ts`
21
22
 
22
23
  ## Rules
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: post-mortem
3
3
  description: "Write engineering RCA record after bug is fixed."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "post-mortem"
6
7
  - "root cause"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: read-only-explorer
3
3
  description: "Read-only exploration and audit workflow."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "explore code"
6
7
  - "audit source"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: requirements-to-task-packet
3
3
  description: "Use when a goal, issue, roadmap item, review finding, or user request must become actionable worker tasks."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "convert requirements"
6
7
  - "create task packet"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: resource-discovery-config
3
3
  description: "pi-crew resource and configuration discovery workflow."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "discover agents"
6
7
  - "find teams"
@@ -15,7 +16,7 @@ Use this skill for pi-crew resource/config work.
15
16
 
16
17
  ## Source patterns distilled
17
18
 
18
- - Pi resource loader: `source/pi-mono/packages/coding-agent/src/core/resource-loader.ts`, extension `resources_discover` hook
19
+ - Pi resource loader: `source/pi/packages/coding-agent/src/core/resource-loader.ts`, extension `resources_discover` hook
19
20
  - pi-crew discovery: `src/agents/discover-agents.ts`, `src/teams/discover-teams.ts`, `src/workflows/discover-workflows.ts`
20
21
  - Config: `src/config/config.ts`, `src/schema/config-schema.ts`, `schema.json`, `docs/resource-formats.md`
21
22
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: runtime-state-reader
3
3
  description: Safe read-only navigation of pi-crew run state.
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "inspect manifest"
6
7
  - "read tasks"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: safe-bash
3
3
  description: "Safe shell-command workflow."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "run this command"
6
7
  - "execute bash"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: scrutinize
3
3
  description: "Outsider-perspective review questioning intent before tracing code."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "scrutinize this"
6
7
  - "question this"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: secure-agent-orchestration-review
3
3
  description: "Use when reviewing delegation, skill loading, tool access, worker prompts, artifacts, runtime config, state, ownership, or subprocess execution."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "review delegation"
6
7
  - "check skill security"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: security-review
3
3
  description: "Security review patterns with audit and detection authoring."
4
+ origin: distilled:anthropic-cybersecurity-skills
4
5
  triggers:
5
6
  - "security review"
6
7
  - "vulnerability scan"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: state-mutation-locking
3
3
  description: "Durable state mutation and locking workflow."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "modify manifest"
6
7
  - "update tasks"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: systematic-debugging
3
3
  description: "Four-phase debugging discipline with refuse gates."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "debug this"
6
7
  - "investigate"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: threat-hypothesis-framework
3
3
  description: "Structured investigation using testable hypotheses."
4
+ origin: distilled:anthropic-cybersecurity-skills
4
5
  triggers:
5
6
  - "hunt for"
6
7
  - "investigate"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: ui-render-performance
3
3
  description: "Non-blocking Pi TUI render workflow."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "widget render"
6
7
  - "dashboard pane"
@@ -14,7 +15,7 @@ Use this skill for Pi/pi-crew TUI work.
14
15
 
15
16
  ## Source patterns distilled
16
17
 
17
- - Pi TUI is synchronous immediate-mode/string rendering: `source/pi-mono/packages/coding-agent/src/modes/interactive/interactive-mode.ts`
18
+ - Pi TUI is synchronous immediate-mode/string rendering: `source/pi/packages/coding-agent/src/modes/interactive/interactive-mode.ts`
18
19
  - Pi extension examples use event-driven state updates, not render-time loading.
19
20
  - pi-crew UI: `src/extension/register.ts`, `src/ui/run-dashboard.ts`, `src/ui/run-snapshot-cache.ts`, `src/ui/crew-widget.ts`, `src/ui/powerbar-publisher.ts`, `src/ui/render-scheduler.ts`
20
21
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: verification-before-done
3
3
  description: "Evidence before claims."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "done"
6
7
  - "verify this"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: widget-rendering
3
3
  description: "Pi TUI crew widget data sources, display priority, and rendering performance."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "empty agent"
6
7
  - "ghost run"
@@ -259,7 +260,7 @@ If ANY answer is NO → Stop. Fix widget rendering issues before proceeding.
259
260
  - `src/runtime/crew-agent-records.ts` — readCrewAgents, agents.json
260
261
  - `src/runtime/process-status.ts` — hasStaleAsyncProcess, isDisplayActiveRun
261
262
  - `src/runtime/background-runner.ts` — active run filtering with async PID check
262
- - `src/runtime/active-run-registry.ts` — purgeStaleActiveRunIndex
263
+ - `src/state/active-run-registry.ts` — purgeStaleActiveRunIndex
263
264
 
264
265
  ---
265
266
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: workspace-isolation
3
3
  description: "Workspace isolation boundaries."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "workspace isolation"
6
7
  - "cross-workspace access"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: worktree-isolation
3
3
  description: "Conflict-safe git worktree workflow."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "create worktree"
6
7
  - "parallel workers"
@@ -81,6 +81,7 @@ export interface CrewWorktreeConfig {
81
81
  setupHook?: string;
82
82
  setupHookTimeoutMs?: number;
83
83
  linkNodeModules?: boolean;
84
+ seedPaths?: string[];
84
85
  }
85
86
 
86
87
  export interface CrewUiConfig {
@@ -3,7 +3,7 @@ import * as fs from "node:fs";
3
3
  import * as path from "node:path";
4
4
  import type { AgentConfig, ResourceSource, RoutingMetadata } from "../agents/agent-config.ts";
5
5
  import { serializeAgent } from "../agents/agent-serializer.ts";
6
- import { allAgents, discoverAgents } from "../agents/discover-agents.ts";
6
+ import { discoverAgents } from "../agents/discover-agents.ts";
7
7
  import type { TeamToolDetails } from "./team-tool-types.ts";
8
8
  import { toolResult, type PiTeamsToolResult } from "./tool-result.ts";
9
9
  import type { TeamToolParamsValue } from "../schema/team-tool-schema.ts";
@@ -6,7 +6,6 @@
6
6
  */
7
7
 
8
8
  import * as fs from "node:fs";
9
- import * as path from "node:path";
10
9
 
11
10
  /**
12
11
  * Tag → Agent chain mapping from ECC recommendations.