pi-crew 0.1.49 → 0.2.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 (249) hide show
  1. package/CHANGELOG.md +74 -1
  2. package/README.md +176 -781
  3. package/agents/analyst.md +11 -11
  4. package/agents/critic.md +11 -11
  5. package/agents/executor.md +11 -11
  6. package/agents/explorer.md +11 -11
  7. package/agents/planner.md +11 -11
  8. package/agents/reviewer.md +11 -11
  9. package/agents/security-reviewer.md +11 -11
  10. package/agents/test-engineer.md +11 -11
  11. package/agents/verifier.md +70 -11
  12. package/agents/writer.md +11 -11
  13. package/docs/actions-reference.md +595 -0
  14. package/docs/commands-reference.md +347 -0
  15. package/docs/runtime-flow.md +148 -148
  16. package/index.ts +6 -6
  17. package/package.json +99 -99
  18. package/skills/async-worker-recovery/SKILL.md +42 -42
  19. package/skills/context-artifact-hygiene/SKILL.md +52 -52
  20. package/skills/delegation-patterns/SKILL.md +54 -54
  21. package/skills/mailbox-interactive/SKILL.md +40 -40
  22. package/skills/model-routing-context/SKILL.md +39 -39
  23. package/skills/multi-perspective-review/SKILL.md +58 -58
  24. package/skills/observability-reliability/SKILL.md +41 -41
  25. package/skills/orchestration/SKILL.md +157 -157
  26. package/skills/ownership-session-security/SKILL.md +41 -41
  27. package/skills/pi-extension-lifecycle/SKILL.md +39 -39
  28. package/skills/requirements-to-task-packet/SKILL.md +63 -63
  29. package/skills/resource-discovery-config/SKILL.md +41 -41
  30. package/skills/runtime-state-reader/SKILL.md +44 -44
  31. package/skills/secure-agent-orchestration-review/SKILL.md +45 -45
  32. package/skills/state-mutation-locking/SKILL.md +42 -42
  33. package/skills/systematic-debugging/SKILL.md +67 -67
  34. package/skills/ui-render-performance/SKILL.md +39 -39
  35. package/skills/verification-before-done/SKILL.md +57 -57
  36. package/skills/worktree-isolation/SKILL.md +39 -39
  37. package/src/adapters/claude-adapter.ts +25 -0
  38. package/src/adapters/codex-adapter.ts +21 -0
  39. package/src/adapters/cursor-adapter.ts +17 -0
  40. package/src/adapters/export-util.ts +137 -0
  41. package/src/adapters/index.ts +15 -0
  42. package/src/adapters/registry.ts +18 -0
  43. package/src/adapters/types.ts +23 -0
  44. package/src/agents/agent-config.ts +2 -0
  45. package/src/agents/agent-search.ts +98 -98
  46. package/src/agents/discover-agents.ts +2 -1
  47. package/src/config/config.ts +14 -1
  48. package/src/config/defaults.ts +5 -5
  49. package/src/config/drift-detector.ts +211 -0
  50. package/src/config/markers.ts +327 -0
  51. package/src/config/resilient-parser.ts +108 -0
  52. package/src/config/suggestions.ts +74 -0
  53. package/src/extension/cross-extension-rpc.ts +103 -82
  54. package/src/extension/project-init.ts +36 -4
  55. package/src/extension/register.ts +67 -22
  56. package/src/extension/registration/commands.ts +77 -8
  57. package/src/extension/registration/subagent-tools.ts +10 -1
  58. package/src/extension/registration/team-tool.ts +10 -1
  59. package/src/extension/registration/viewers.ts +48 -34
  60. package/src/extension/run-bundle-schema.ts +89 -89
  61. package/src/extension/run-export.ts +26 -12
  62. package/src/extension/run-import.ts +25 -1
  63. package/src/extension/run-index.ts +5 -1
  64. package/src/extension/run-maintenance.ts +142 -68
  65. package/src/extension/team-manager-command.ts +10 -1
  66. package/src/extension/team-tool/context.ts +1 -1
  67. package/src/extension/team-tool/doctor.ts +28 -3
  68. package/src/extension/team-tool/handle-settings.ts +195 -188
  69. package/src/extension/team-tool/inspect.ts +41 -41
  70. package/src/extension/team-tool/intent-policy.ts +42 -42
  71. package/src/extension/team-tool/lifecycle-actions.ts +27 -8
  72. package/src/extension/team-tool/plan.ts +19 -19
  73. package/src/extension/team-tool/run.ts +12 -1
  74. package/src/extension/team-tool.ts +14 -3
  75. package/src/i18n.ts +184 -184
  76. package/src/observability/exporters/otlp-exporter.ts +92 -77
  77. package/src/prompt/prompt-runtime.ts +72 -72
  78. package/src/runtime/agent-memory.ts +72 -72
  79. package/src/runtime/agent-observability.ts +114 -114
  80. package/src/runtime/async-marker.ts +26 -26
  81. package/src/runtime/attention-events.ts +28 -28
  82. package/src/runtime/auto-resume.ts +100 -0
  83. package/src/runtime/background-runner.ts +11 -1
  84. package/src/runtime/cancellation-token.ts +89 -89
  85. package/src/runtime/cancellation.ts +61 -61
  86. package/src/runtime/capability-inventory.ts +116 -116
  87. package/src/runtime/child-pi.ts +7 -2
  88. package/src/runtime/compaction-summary.ts +271 -0
  89. package/src/runtime/completion-guard.ts +190 -190
  90. package/src/runtime/concurrency.ts +3 -1
  91. package/src/runtime/crash-recovery.ts +33 -0
  92. package/src/runtime/delta-conflict.ts +360 -0
  93. package/src/runtime/diagnostic-export.ts +3 -1
  94. package/src/runtime/direct-run.ts +35 -35
  95. package/src/runtime/event-stream-bridge.ts +3 -1
  96. package/src/runtime/foreground-control.ts +82 -82
  97. package/src/runtime/green-contract.ts +46 -46
  98. package/src/runtime/group-join.ts +106 -106
  99. package/src/runtime/heartbeat-gradient.ts +28 -28
  100. package/src/runtime/heartbeat-watcher.ts +124 -124
  101. package/src/runtime/iteration-hooks.ts +262 -0
  102. package/src/runtime/live-agent-control.ts +88 -88
  103. package/src/runtime/live-control-realtime.ts +36 -36
  104. package/src/runtime/live-extension-bridge.ts +150 -150
  105. package/src/runtime/live-irc.ts +92 -92
  106. package/src/runtime/live-session-health.ts +100 -100
  107. package/src/runtime/loop-gates.ts +129 -0
  108. package/src/runtime/metric-parser.ts +40 -0
  109. package/src/runtime/notebook-helpers.ts +90 -90
  110. package/src/runtime/orphan-sentinel.ts +7 -7
  111. package/src/runtime/parallel-research.ts +44 -44
  112. package/src/runtime/phase-progress.ts +217 -0
  113. package/src/runtime/pi-args.ts +38 -2
  114. package/src/runtime/pi-json-output.ts +111 -111
  115. package/src/runtime/pi-spawn.ts +74 -6
  116. package/src/runtime/policy-engine.ts +79 -79
  117. package/src/runtime/post-checks.ts +122 -0
  118. package/src/runtime/process-status.ts +14 -1
  119. package/src/runtime/progress-event-coalescer.ts +43 -43
  120. package/src/runtime/prose-compressor.ts +164 -164
  121. package/src/runtime/recovery-recipes.ts +74 -74
  122. package/src/runtime/result-extractor.ts +121 -121
  123. package/src/runtime/role-permission.ts +39 -39
  124. package/src/runtime/sensitive-paths.ts +3 -3
  125. package/src/runtime/session-resources.ts +25 -25
  126. package/src/runtime/session-snapshot.ts +59 -59
  127. package/src/runtime/session-usage.ts +79 -79
  128. package/src/runtime/sidechain-output.ts +29 -29
  129. package/src/runtime/stream-preview.ts +177 -177
  130. package/src/runtime/supervisor-contact.ts +59 -59
  131. package/src/runtime/task-display.ts +38 -38
  132. package/src/runtime/task-graph.ts +207 -0
  133. package/src/runtime/task-quality.ts +207 -0
  134. package/src/runtime/task-runner/capabilities.ts +78 -78
  135. package/src/runtime/task-runner/live-executor.ts +7 -1
  136. package/src/runtime/task-runner/progress.ts +119 -119
  137. package/src/runtime/task-runner/prompt-builder.ts +1 -1
  138. package/src/runtime/task-runner/prompt-pipeline.ts +64 -64
  139. package/src/runtime/task-runner/result-utils.ts +14 -14
  140. package/src/runtime/task-runner/run-projection.ts +103 -103
  141. package/src/runtime/task-runner/state-helpers.ts +22 -22
  142. package/src/runtime/team-runner.ts +126 -7
  143. package/src/runtime/worker-heartbeat.ts +21 -21
  144. package/src/runtime/worker-startup.ts +57 -57
  145. package/src/runtime/workflow-state.ts +187 -0
  146. package/src/runtime/workspace-tree.ts +298 -298
  147. package/src/schema/config-schema.ts +12 -0
  148. package/src/schema/validation-types.ts +148 -0
  149. package/src/skills/skill-templates.ts +374 -0
  150. package/src/state/active-run-registry.ts +35 -11
  151. package/src/state/atomic-write.ts +33 -26
  152. package/src/state/contracts.ts +1 -0
  153. package/src/state/event-reconstructor.ts +217 -0
  154. package/src/state/locks.ts +2 -11
  155. package/src/state/mailbox.ts +4 -3
  156. package/src/state/state-store.ts +32 -14
  157. package/src/state/task-claims.ts +44 -44
  158. package/src/state/types.ts +9 -0
  159. package/src/state/usage.ts +29 -29
  160. package/src/subagents/async-entry.ts +1 -1
  161. package/src/subagents/index.ts +3 -3
  162. package/src/subagents/live/control.ts +1 -1
  163. package/src/subagents/live/manager.ts +1 -1
  164. package/src/subagents/live/realtime.ts +1 -1
  165. package/src/subagents/live/session-runtime.ts +1 -1
  166. package/src/subagents/manager.ts +1 -1
  167. package/src/subagents/spawn.ts +1 -1
  168. package/src/teams/team-serializer.ts +38 -38
  169. package/src/types/diff.d.ts +18 -18
  170. package/src/ui/crew-footer.ts +101 -101
  171. package/src/ui/crew-select-list.ts +111 -111
  172. package/src/ui/crew-widget.ts +9 -4
  173. package/src/ui/dashboard-panes/cancellation-pane.ts +42 -42
  174. package/src/ui/dashboard-panes/capability-pane.ts +59 -59
  175. package/src/ui/dashboard-panes/mailbox-pane.ts +35 -35
  176. package/src/ui/dashboard-panes/metrics-pane.ts +34 -34
  177. package/src/ui/dashboard-panes/progress-pane.ts +11 -0
  178. package/src/ui/dynamic-border.ts +25 -25
  179. package/src/ui/layout-primitives.ts +106 -106
  180. package/src/ui/loaders.ts +158 -158
  181. package/src/ui/powerbar-publisher.ts +6 -0
  182. package/src/ui/render-coalescer.ts +51 -51
  183. package/src/ui/render-diff.ts +119 -119
  184. package/src/ui/render-scheduler.ts +143 -143
  185. package/src/ui/run-action-dispatcher.ts +10 -1
  186. package/src/ui/spinner.ts +17 -17
  187. package/src/ui/status-colors.ts +58 -58
  188. package/src/ui/syntax-highlight.ts +116 -116
  189. package/src/ui/transcript-entries.ts +258 -258
  190. package/src/utils/completion-dedupe.ts +63 -63
  191. package/src/utils/frontmatter.ts +68 -68
  192. package/src/utils/git.ts +262 -262
  193. package/src/utils/ids.ts +17 -17
  194. package/src/utils/incremental-reader.ts +104 -104
  195. package/src/utils/names.ts +27 -27
  196. package/src/utils/redaction.ts +44 -44
  197. package/src/utils/safe-paths.ts +47 -47
  198. package/src/utils/scan-cache.ts +136 -136
  199. package/src/utils/sleep.ts +40 -26
  200. package/src/utils/task-name-generator.ts +337 -337
  201. package/src/workflows/validate-workflow.ts +40 -40
  202. package/src/worktree/branch-freshness.ts +45 -45
  203. package/src/worktree/worktree-manager.ts +11 -3
  204. package/teams/default.team.md +12 -12
  205. package/teams/fast-fix.team.md +11 -11
  206. package/teams/implementation.team.md +18 -18
  207. package/teams/parallel-research.team.md +14 -14
  208. package/teams/research.team.md +11 -11
  209. package/teams/review.team.md +12 -12
  210. package/workflows/default.workflow.md +30 -29
  211. package/workflows/fast-fix.workflow.md +23 -22
  212. package/workflows/implementation.workflow.md +43 -38
  213. package/workflows/parallel-research.workflow.md +46 -46
  214. package/workflows/research.workflow.md +22 -22
  215. package/workflows/review.workflow.md +30 -30
  216. package/docs/refactor-tasks-phase3.md +0 -394
  217. package/docs/refactor-tasks-phase4.md +0 -564
  218. package/docs/refactor-tasks-phase5.md +0 -402
  219. package/docs/refactor-tasks-phase6.md +0 -662
  220. package/docs/refactor-tasks.md +0 -1484
  221. package/docs/research/AGENT-EXECUTION-ARCHITECTURE.md +0 -261
  222. package/docs/research/AGENT-LIFECYCLE-COMPARISON.md +0 -111
  223. package/docs/research/AUDIT_OH_MY_PI.md +0 -261
  224. package/docs/research/AUDIT_PI_CREW.md +0 -457
  225. package/docs/research/CAVEMAN-DEEP-RESEARCH.md +0 -281
  226. package/docs/research/COMPARISON_OH_MY_PI_VS_PI_CREW.md +0 -264
  227. package/docs/research/DEEP-RESEARCH-PI-POWERBAR.md +0 -343
  228. package/docs/research/DEEP_RESEARCH_SUBAGENT_ARCHITECTURE.md +0 -480
  229. package/docs/research/GAP_CLOSURE_IMPLEMENTATION_PLAN.md +0 -354
  230. package/docs/research/IMPLEMENTATION_PLAN.md +0 -385
  231. package/docs/research/LIVE-SESSION-PRODUCTION-READY-PLAN.md +0 -502
  232. package/docs/research/OH-MY-PI-DEEP-RESEARCH-v14.7.6.md +0 -266
  233. package/docs/research/REMAINING-GAPS-PLAN.md +0 -363
  234. package/docs/research/SESSION-SUMMARY-2026-05-08.md +0 -146
  235. package/docs/research/UI-RESPONSIVENESS-AUDIT.md +0 -173
  236. package/docs/research-awesome-agent-skills-distillation.md +0 -100
  237. package/docs/research-extension-examples.md +0 -297
  238. package/docs/research-extension-system.md +0 -324
  239. package/docs/research-oh-my-pi-distillation.md +0 -369
  240. package/docs/research-optimization-plan.md +0 -548
  241. package/docs/research-phase10-distillation.md +0 -199
  242. package/docs/research-phase11-distillation.md +0 -201
  243. package/docs/research-phase8-operator-experience-plan.md +0 -819
  244. package/docs/research-phase9-observability-reliability-plan.md +0 -1190
  245. package/docs/research-pi-coding-agent.md +0 -357
  246. package/docs/research-source-pi-crew-reference.md +0 -174
  247. package/docs/research-ui-optimization-plan.md +0 -480
  248. package/docs/source-runtime-refactor-map.md +0 -107
  249. package/src/utils/atomic-write.ts +0 -33
package/README.md CHANGED
@@ -1,631 +1,238 @@
1
1
  # pi-crew
2
2
 
3
- `pi-crew` is a Pi extension/package for coordinated AI teams: autonomous routing, manual slash-command controls, durable run state, artifacts, async/background execution, optional worktree isolation, resource management, validation, import/export, dashboard helpers, and safe API interop.
3
+ **Coordinate AI agent teams inside [Pi](https://github.com/nicekate/pi-coding-agent).**
4
4
 
5
- NPM package:
5
+ pi-crew is a Pi extension that orchestrates autonomous multi-agent workflows — research, implementation, review, testing, and more — with durable state, parallel execution, worktree isolation, and safe defaults.
6
6
 
7
7
  ```text
8
- pi-crew
8
+ npm: pi-crew
9
+ repo: https://github.com/baphuongna/pi-crew
9
10
  ```
10
11
 
11
- GitHub repository:
12
+ **v0.2.0**: Security hardening + 76% faster startup. See [CHANGELOG.md](CHANGELOG.md).
12
13
 
13
- ```text
14
- https://github.com/baphuongna/pi-crew
15
- ```
14
+ ---
16
15
 
17
- ## Status
18
-
19
- `pi-crew` is published on npm and implemented with safe execution defaults and product-oriented foundations.
20
-
21
- Current highlights:
22
-
23
- - one main Pi tool: `team`
24
- - autonomous delegation policy injection before agent start
25
- - metadata-aware `recommend` action for routing, decomposition, fanout hints, async/worktree suggestions
26
- - configurable autonomy profiles: `manual`, `suggested`, `assisted`, `aggressive`
27
- - builtin agents, teams, and workflows
28
- - user/project/builtin resource discovery where user resources override builtin resources, and project resources cannot shadow trusted user/builtin names
29
- - resource format support for routing metadata: `triggers`, `useWhen`, `avoidWhen`, `cost`, `category`
30
- - durable run state: manifest, tasks, events, artifacts, imports/exports
31
- - foreground workflow scheduler
32
- - detached async/background runner
33
- - stale async PID detection
34
- - active run summary and async completion notifications in Pi sessions
35
- - owner-session delivery guards so stale sessions do not receive background subagent/result/live-session completions
36
- - real child Pi worker execution by default, with explicit scaffold/dry-run opt-out
37
- - child Pi JSON output parsing for final text, usage, and event counts
38
- - retryable model fallback attempts per task
39
- - aggregate usage totals in status/summary
40
- - progress, summary, prompt, result, log, diff, patch, export artifacts
41
- - task packets, verification/green-contract evidence, policy decision artifacts, and task graph metadata
42
- - opt-in git worktree isolation per task
43
- - worktree branch mismatch detection
44
- - dirty worktree preservation unless `force` is explicitly set
45
- - cancel/resume lifecycle operations
46
- - forget/prune cleanup operations with explicit confirmation
47
- - export/import portable run bundles
48
- - resource create/update/delete with backups, dry-run, reference checks, and optional reference updates
49
- - resource validation and doctor checks
50
- - project initialization for `.pi` layout and `.gitignore`
51
- - config show/update with user/project scope and nested unset support
52
- - safe API interop for manifest/task/event/heartbeat/claim/mailbox operations
53
- - realpath containment for run/import/artifact/transcript/mailbox/agent state reads and writes, including symlink escape protection
54
- - read-only state APIs avoid creating mailbox files when only inspecting delivery or mailbox state
55
- - run-level and task-level mailbox files with validation/repair support
56
- - `/team-manager` interactive helper
57
- - `/team-dashboard` custom TUI overlay with progress preview, action shortcuts, and reload
58
- - `parallel-research` team/workflow for dynamic `Source/pi-*` fanout and parallel shard exploration
59
- - observability metrics: per-session Counter/Gauge/Histogram registry, JSONL sink, `/team-metrics`, dashboard metrics pane, Prometheus/OTLP exporters (OTLP opt-in)
60
- - reliability hardening: heartbeat gradient watcher, opt-in retry executor with attempt trace, crash-recovery detection, deadletter queue
61
- - background `Agent`/`crew_agent` completion wake-up so parent sessions can automatically join completed subagent results
62
- - optional `runtime.requirePlanApproval` gate for planner-first approval before mutating adaptive implementation workers run
63
- - optional `runtime.completionMutationGuard` to warn or fail implementation-style workers that complete without observed mutation tool calls
64
- - grouped result delivery is correlated through mailbox metadata, deduped by request id, and acknowledged via existing `ack-message`
65
- - shared redaction for common secrets before durable event/log/mailbox/artifact/metric/diagnostic persistence
66
- - package polish: `schema.json`, TypeScript semantic check, strip-types import smoke, cross-platform CI workflow, dry-run package verification
16
+ ## Features
17
+
18
+ - **One Pi tool** `team` handles routing, planning, execution, review, and cleanup
19
+ - **Autonomous delegation** — policy injection decides when/how to delegate based on task complexity
20
+ - **Real child Pi workers** — each task spawns a separate Pi process by default; scaffold/dry-run opt-out
21
+ - **Adaptive planning** — implementation workflow lets a planner agent decide subagent fanout
22
+ - **Parallel execution** tasks in the same phase run concurrently with configurable concurrency
23
+ - **Durable state** manifest, tasks, events, artifacts all persisted to disk
24
+ - **Async/background runs** detached runs survive session switches with completion notifications
25
+ - **Worktree isolation** opt-in git worktrees per task for safe parallel edits
26
+ - **Rich UI** — live widget, dashboard, progress tracking, model/token display
27
+ - **Observability** metrics registry, Prometheus/OTLP exporters, heartbeat watching, deadletter queue
28
+ - **Resource management** create/update/delete agents, teams, workflows with validation
29
+ - **Import/export** — portable run bundles for sharing and archiving
67
30
 
68
- ## Install
31
+ ---
69
32
 
70
- From npm:
33
+ ## Install
71
34
 
72
35
  ```bash
73
36
  pi install npm:pi-crew
74
37
  ```
75
38
 
76
- From the workspace root for local development:
39
+ Local development:
77
40
 
78
41
  ```bash
79
42
  pi install ./pi-crew
80
43
  ```
81
44
 
82
- Optional config bootstrap after npm install:
45
+ Post-install config bootstrap:
83
46
 
84
47
  ```bash
85
- pi-crew
48
+ pi-crew # after npm install
49
+ node ./pi-crew/install.mjs # from local clone
86
50
  ```
87
51
 
88
- Optional config bootstrap from a local clone:
89
-
90
- ```bash
91
- node ./pi-crew/install.mjs
92
- ```
93
-
94
- Local verification from this package:
95
-
96
- ```bash
97
- cd pi-crew
98
- npm run ci
99
- ```
100
-
101
- ## Runtime safety model
52
+ ---
102
53
 
103
- By default, `run` launches each crew task as a separate child Pi process. This matches the subagent model from `pi-subagents`: the parent session orchestrates while worker sessions execute independently and stream durable output back to run state.
54
+ ## Quick Start
104
55
 
105
- Use scaffold/dry-run mode only when you explicitly want prompts/artifacts without launching workers:
56
+ ### 1. Initialize project
106
57
 
107
- ```json
108
- {
109
- "runtime": { "mode": "scaffold" }
110
- }
58
+ ```text
59
+ /team-init
111
60
  ```
112
61
 
113
- or disable workers globally:
62
+ ### 2. Run a team
114
63
 
115
- ```json
116
- {
117
- "executeWorkers": false
118
- }
64
+ ```text
65
+ /team-run Investigate failing tests and propose a fix
119
66
  ```
120
67
 
121
- Worktree mode is opt-in:
68
+ Or via tool call:
122
69
 
123
70
  ```json
124
71
  {
125
72
  "action": "run",
126
- "team": "implementation",
127
- "goal": "Implement feature X",
128
- "workspaceMode": "worktree"
73
+ "team": "default",
74
+ "goal": "Investigate failing tests and propose a fix"
129
75
  }
130
76
  ```
131
77
 
132
- By default, worktree mode requires a clean leader repository. Dirty task worktrees are preserved unless cleanup is called with `force: true`.
133
-
134
- ## Config
135
-
136
- User config path:
78
+ ### 3. Check status
137
79
 
138
80
  ```text
139
- ~/.pi/agent/extensions/pi-crew/config.json
140
- ```
141
-
142
- Project config path:
143
-
144
- ```text
145
- .crew/config.json # default (new projects)
146
- .pi/teams/config.json # legacy (when the repo already has .pi/)
147
- ```
148
-
149
- The project root is auto-detected by walking up from the current directory and stopping at any of: `.git`, `.pi`, `.crew`, `.hg`, `.svn`, `.factory`, `.omc`, or any common manifest file (`package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`, `pom.xml`, `composer.json`, `build.gradle[.kts]`). If the project already has a `.pi/` directory, pi-crew reuses it under `.pi/teams/` to avoid creating a parallel layout; otherwise it uses `.crew/`.
150
-
151
- Config merge priority:
152
-
153
- ```text
154
- user < project for ordinary presentation/UX settings
81
+ /team-status <runId>
82
+ /team-dashboard
155
83
  ```
156
84
 
157
- Trust-boundary exception: project config is intentionally not trusted for sensitive execution controls. Project-level values such as `executeWorkers`, `asyncByDefault`, runtime mode/live-session inheritance, autonomy mode, `agents.disableBuiltins`, `agents.overrides`, `worktree.setupHook`, and `otlp.headers` are ignored with warnings. Set those in user config when you want to trust them explicitly.
158
-
159
- Resource discovery trust boundary: project-local agents, teams, and workflows may add new names, but cannot shadow builtin or user resources with the same name.
85
+ ### 4. Get a recommendation
160
86
 
161
- Supported config:
87
+ When unsure which team/workflow fits:
162
88
 
163
89
  ```json
164
90
  {
165
- "asyncByDefault": false,
166
- "executeWorkers": true,
167
- "notifierIntervalMs": 5000,
168
- "requireCleanWorktreeLeader": true,
169
- "autonomous": {
170
- "profile": "suggested",
171
- "enabled": true,
172
- "injectPolicy": true,
173
- "preferAsyncForLongTasks": false,
174
- "allowWorktreeSuggestion": true,
175
- "magicKeywords": {
176
- "review": ["review", "audit", "inspect"]
177
- }
178
- },
179
- "runtime": {
180
- "mode": "auto",
181
- "groupJoin": "smart",
182
- "groupJoinAckTimeoutMs": 300000,
183
- "requirePlanApproval": false,
184
- "completionMutationGuard": "warn"
185
- },
186
- "limits": {
187
- "maxConcurrentWorkers": 3,
188
- "maxTaskDepth": 2,
189
- "maxChildrenPerTask": 5,
190
- "maxRunMinutes": 60,
191
- "maxRetriesPerTask": 1,
192
- "heartbeatStaleMs": 60000
193
- },
194
- "ui": {
195
- "widgetPlacement": "aboveEditor",
196
- "widgetMaxLines": 8,
197
- "powerbar": true,
198
- "dashboardPlacement": "center",
199
- "dashboardWidth": 72,
200
- "dashboardLiveRefreshMs": 1000,
201
- "autoOpenDashboard": false,
202
- "autoOpenDashboardForForegroundRuns": false,
203
- "showModel": true,
204
- "showTokens": true,
205
- "showTools": true
206
- },
207
- "tools": {
208
- "enableClaudeStyleAliases": true,
209
- "enableSteer": true,
210
- "terminateOnForeground": false
211
- },
212
- "telemetry": {
213
- "enabled": true
214
- },
215
- "observability": {
216
- "enabled": true,
217
- "pollIntervalMs": 5000,
218
- "metricRetentionDays": 7
219
- },
220
- "reliability": {
221
- "autoRetry": false,
222
- "autoRecover": false,
223
- "deadletterThreshold": 3,
224
- "retryPolicy": {
225
- "maxAttempts": 3,
226
- "backoffMs": 1000,
227
- "jitterRatio": 0.3,
228
- "exponentialFactor": 2
229
- }
230
- },
231
- "otlp": {
232
- "enabled": false,
233
- "endpoint": "http://localhost:4318/v1/metrics"
234
- }
91
+ "action": "recommend",
92
+ "goal": "Refactor auth flow and add tests"
235
93
  }
236
94
  ```
237
95
 
238
- Safety notes:
239
-
240
- - Foreground child-process runs continue in the Pi extension process and return control to chat immediately, so large workflows do not block the interactive session. They are interrupted on session shutdown. Use `async: true` only for intentionally detached runs that may survive the current session.
241
- - Async completion notifications survive extension reload/auto-compaction: active runs are not marked consumed just because the notifier restarts, while stale owner-session callbacks are suppressed after session switches.
242
- - Background `Agent`/`crew_agent` runs notify the parent session when they reach a terminal state; the parent can then call `get_subagent_result`/`crew_agent_result` and continue the original task.
243
- - `tools.terminateOnForeground` is an opt-in power-user setting. When true, foreground `Agent`/`crew_agent` calls return with `terminate: true` after the child result is available, saving one follow-up LLM turn. Default is false so the assistant can still summarize raw worker output.
244
- - Runtime state paths are treated as untrusted data: run ids, import bundles, artifact/transcript paths, mailbox files, and agent control/log files are validated with containment checks before reads or writes.
245
- - `runtime.completionMutationGuard` defaults to `warn`; set `off` to disable or `fail` to fail implementation-style tasks that report success without observed mutation tool calls.
246
- - Group-join result messages use normal mailbox delivery and normal `ack-message`; missing acknowledgements never block run completion, and duplicate delivery attempts reuse the same request id/message instead of appending spam.
247
- - Common secret patterns (`token=`, `apiKey=`, `Authorization: Bearer ...`, private keys, etc.) are redacted before durable logs/events/mailbox/artifacts/metrics/diagnostics are written.
248
- - `observability.enabled` defaults to true for in-memory metrics and heartbeat watching. Metric JSONL snapshots are gated by `telemetry.enabled`; set `telemetry.enabled=false` to opt out of local telemetry files.
249
- - `reliability.autoRetry` and `reliability.autoRecover` default to false. Enabling retry may execute an idempotent task more than once; each attempt is recorded in `task.attempts`, and exhausted retries append a deadletter entry.
250
- - `otlp.enabled` defaults to false. Configure `otlp.endpoint` only when you want to push metrics to an OTLP HTTP collector.
251
-
252
- UI notes:
253
-
254
- - `widgetPlacement`/`widgetMaxLines` keep the persistent active-run widget compact.
255
- - `dashboardPlacement: "center"` is the default for `/team-dashboard`; set it to `"right"` only when you want a right-sidebar dashboard.
256
- - `autoOpenDashboard`/`autoOpenDashboardForForegroundRuns` control whether the live sidebar opens automatically. Both default to false so the compact widget above the input remains the primary live UI.
257
- - `dashboardLiveRefreshMs` controls the live sidebar refresh cadence.
258
- - `showModel`, `showTokens`, and `showTools` show worker model attempts, token usage, and tool activity in dashboard agent rows.
259
-
260
- Show config:
261
-
262
- ```text
263
- /team-config
264
- ```
265
-
266
- Update user config:
267
-
268
- ```text
269
- /team-config asyncByDefault=true notifierIntervalMs=5000
270
- ```
271
-
272
- Update project config:
273
-
274
- ```text
275
- /team-config autonomous.profile=assisted autonomous.preferAsyncForLongTasks=true --project
276
- ```
96
+ ---
277
97
 
278
- Unset/delete nested config keys:
98
+ ## Builtin Teams
279
99
 
280
- ```text
281
- /team-config --unset=autonomous.preferAsyncForLongTasks --project
282
- /team-config autonomous.preferAsyncForLongTasks=unset --project
283
- /team-config autonomous.preferAsyncForLongTasks=null --project
284
- ```
100
+ | Team | Workflow | Mục đích |
101
+ |------|----------|----------|
102
+ | `default` | explore → plan → execute → verify | Cân bằng, đa năng |
103
+ | `fast-fix` | explore → execute → verify | Sửa bug nhỏ nhanh |
104
+ | `implementation` | Adaptive planner quyết fanout | Multi-file implementation |
105
+ | `review` | explore → code-review → security-review → verify | Code review + security audit |
106
+ | `research` | explore → analyze → write | Nghiên cứu và viết tài liệu |
285
107
 
286
- Config schema is exported as:
108
+ ## Builtin Agents
287
109
 
288
- ```text
289
- ./schema.json
290
110
  ```
291
-
292
- ## Main tool
293
-
294
- The extension registers one main tool:
295
-
296
- ```text
297
- team
111
+ analyst · critic · executor · explorer · planner · reviewer
112
+ security-reviewer · test-engineer · verifier · writer
298
113
  ```
299
114
 
300
- Use it for complex multi-file work, planning, implementation, tests, reviews, security audits, research, async/background runs, and worktree-isolated execution.
115
+ ---
301
116
 
302
- When unsure which team/workflow to choose, call:
117
+ ## Runtime Safety
303
118
 
304
- ```json
305
- {
306
- "action": "recommend",
307
- "goal": "Refactor auth flow and add tests"
308
- }
309
- ```
119
+ By default, `run` launches each task as a **separate child Pi process**. Workers execute independently and stream output to durable state.
310
120
 
311
- ## Tool actions
312
-
313
- Supported actions:
314
-
315
- | Action | Purpose |
316
- |---|---|
317
- | `list` | List discovered teams, agents, workflows, and recent runs |
318
- | `get` | Inspect a named agent/team/workflow |
319
- | `recommend` | Suggest team/workflow/action plus decomposition and fanout hints |
320
- | `run` | Create a run and execute the workflow scheduler |
321
- | `plan` | Validate and preview workflow execution without running tasks |
322
- | `status` | Read durable run status |
323
- | `summary` | Read/write run summary artifact |
324
- | `events` | Read run event log |
325
- | `artifacts` | List run artifacts |
326
- | `worktrees` | List run worktree metadata |
327
- | `cancel` | Cancel queued/running work |
328
- | `resume` | Re-queue failed/cancelled/skipped/running tasks |
329
- | `cleanup` | Clean run worktrees; dirty worktrees are preserved unless forced |
330
- | `forget` | Delete run state/artifacts after `confirm: true` |
331
- | `prune` | Delete old finished runs after `confirm: true` |
332
- | `export` | Export a portable run bundle |
333
- | `import` | Import a run bundle into local imports |
334
- | `imports` | List imported run bundles |
335
- | `create` | Create agent/team/workflow in user/project scope |
336
- | `update` | Update agent/team/workflow with backup |
337
- | `delete` | Delete agent/team/workflow with `confirm: true` and backup |
338
- | `validate` | Validate agents, teams, workflows, references, and model hints |
339
- | `doctor` | Check local readiness and optionally run child Pi smoke check |
340
- | `config` | Show/update config |
341
- | `init` | Create project `.pi` layout and update `.gitignore` |
342
- | `autonomy` | Show/update autonomous delegation settings |
343
- | `api` | Safe interop for run/task/event/heartbeat/claim/mailbox state, including plan approval/cancel operations |
344
- | `help` | Show help text |
345
-
346
- ## Example tool calls
347
-
348
- Run a default team safely:
121
+ Scaffold/dry-run mode (no real workers):
349
122
 
350
123
  ```json
351
- {
352
- "action": "run",
353
- "team": "default",
354
- "goal": "Investigate failing tests and propose a fix"
355
- }
124
+ { "runtime": { "mode": "scaffold" } }
356
125
  ```
357
126
 
358
- Run async:
127
+ Disable workers globally:
359
128
 
360
129
  ```json
361
- {
362
- "action": "run",
363
- "team": "implementation",
364
- "goal": "Implement the user settings screen",
365
- "async": true
366
- }
130
+ { "executeWorkers": false }
367
131
  ```
368
132
 
369
- Run with worktrees:
133
+ Worktree mode is **opt-in** and requires a clean repo:
370
134
 
371
135
  ```json
372
136
  {
373
137
  "action": "run",
374
138
  "team": "implementation",
375
- "workflow": "implementation",
376
- "goal": "Add API endpoint and tests",
139
+ "goal": "Refactor auth",
377
140
  "workspaceMode": "worktree"
378
141
  }
379
142
  ```
380
143
 
381
- Require explicit approval after the adaptive planner writes a plan artifact and before mutating workers run:
382
-
383
- ```json
384
- {
385
- "action": "run",
386
- "team": "implementation",
387
- "workflow": "implementation",
388
- "goal": "Refactor auth and update tests",
389
- "config": {
390
- "runtime": { "requirePlanApproval": true }
391
- }
392
- }
393
- ```
394
-
395
- Approve or cancel the pending plan:
396
-
397
- ```json
398
- {
399
- "action": "api",
400
- "runId": "team_...",
401
- "config": { "operation": "approve-plan" }
402
- }
403
- ```
404
-
405
- Inspect a run:
406
-
407
- ```json
408
- {
409
- "action": "status",
410
- "runId": "team_..."
411
- }
412
- ```
144
+ ---
413
145
 
414
- Create a routed agent:
146
+ ## Configuration
415
147
 
416
- ```json
417
- {
418
- "action": "create",
419
- "resource": "agent",
420
- "config": {
421
- "scope": "project",
422
- "name": "api-reviewer",
423
- "description": "Reviews backend API changes",
424
- "systemPrompt": "You review backend API changes for correctness and compatibility.",
425
- "triggers": ["api", "endpoint", "contract"],
426
- "useWhen": ["backend API change", "OpenAPI contract update"],
427
- "avoidWhen": ["documentation-only edits"],
428
- "cost": "cheap",
429
- "category": "backend"
430
- }
431
- }
432
- ```
148
+ ### Config Paths
433
149
 
434
- ## Slash commands
150
+ | Scope | Path |
151
+ |-------|------|
152
+ | User | `~/.pi/agent/extensions/pi-crew/config.json` |
153
+ | Project (new) | `.crew/config.json` |
154
+ | Project (legacy) | `.pi/teams/config.json` |
435
155
 
436
- Manual slash commands are ops/debug controls. Autonomous tool use via policy/recommendation is the primary agent-driven path.
156
+ ### Quick Config
437
157
 
438
158
  ```text
439
- /teams
440
- /team-run [--team=name] [--workflow=name] [--async] [--worktree] <goal>
441
- /team-cancel <runId>
442
- /team-status <runId>
443
- /team-summary <runId>
444
- /team-resume <runId>
445
- /team-events <runId>
446
- /team-artifacts <runId>
447
- /team-worktrees <runId>
448
- /team-cleanup <runId> [--force]
449
- /team-forget <runId> --confirm [--force]
450
- /team-prune --keep=20 --confirm
451
- /team-export <runId>
452
- /team-import <path-to-run-export.json> [--user]
453
- /team-imports
454
- /team-api <runId> <operation> [key=value]
455
- /team-metrics [filter]
456
- /team-manager
457
- /team-dashboard
458
- /team-init [--copy-builtins] [--overwrite]
459
- /team-config [key=value] [--unset=key.path] [--project]
460
- /team-settings [list|get <key>|set <key> <value>|unset <key>|path|scope]
461
- /team-autonomy [status|on|off|manual|suggested|assisted|aggressive] [--prefer-async] [--no-worktree-suggest]
462
- /team-validate
463
- /team-help
464
- /team-doctor
465
- ```
466
-
467
- ### `/team-api` examples
468
-
469
- ```text
470
- /team-api team_... read-manifest
471
- /team-api team_... list-tasks
472
- /team-api team_... read-task taskId=task_...
473
- /team-api team_... read-events
474
- /team-api team_... read-heartbeat taskId=task_...
475
- /team-api team_... write-heartbeat taskId=task_... alive=true
476
- /team-api team_... claim-task taskId=task_... owner=worker-1
477
- /team-api team_... release-task-claim taskId=task_... owner=worker-1 token=...
478
- /team-api team_... transition-task-status taskId=task_... owner=worker-1 token=... status=running
479
- /team-api team_... send-message direction=outbox to=worker body="please check this"
480
- /team-api team_... send-message taskId=task_... direction=inbox to=worker body="task scoped message"
481
- /team-api team_... read-mailbox direction=outbox
482
- /team-api team_... read-mailbox taskId=task_... direction=inbox
483
- /team-api team_... ack-message messageId=msg_... # also acknowledges group-join result messages
484
- /team-api team_... read-delivery
485
- /team-api team_... validate-mailbox repair=true
486
- /team-api team_... approve-plan
487
- /team-api team_... cancel-plan
159
+ /team-config # view
160
+ /team-config asyncByDefault=true # update
161
+ /team-config runtime.mode=scaffold # scaffold mode
162
+ /team-config --unset=asyncByDefault # reset
163
+ /team-config autonomous.profile=assisted --project # project scope
488
164
  ```
489
165
 
490
- Use `/team-metrics` for a current metrics snapshot. The optional argument is a glob-style metric filter:
166
+ ### Key Settings
491
167
 
492
- ```text
493
- /team-metrics
494
- /team-metrics crew.task.*
495
- ```
168
+ | Section | Key Settings | Default |
169
+ |---------|-------------|---------|
170
+ | **Runtime** | `mode`: `auto` \| `scaffold` \| `child-process` \| `live-session` | `auto` |
171
+ | **Concurrency** | `limits.maxConcurrentWorkers` | workflow-dependent (2–4) |
172
+ | **Async** | `asyncByDefault`, `runtime.groupJoin` | `false`, `smart` |
173
+ | **Autonomy** | `profile`: `manual` \| `suggested` \| `assisted` \| `aggressive` | `suggested` |
174
+ | **UI** | `widgetPlacement`, `dashboardPlacement`, `showModel`, `showTokens` | compact widget |
175
+ | **Reliability** | `autoRetry`, `autoRecover`, `deadletterThreshold` | all opt-in |
176
+ | **Observability** | `prometheus.enabled`, `otlp.enabled` | opt-in |
496
177
 
497
- ### `/team-settings` view & manage config
178
+ > ⚠️ **Trust boundary**: project config cannot override sensitive execution controls (workers, runtime mode, autonomy, agent overrides). Set those in **user config** only.
498
179
 
499
- List all settings, get/set individual keys, or unset (reset to default).
180
+ 📖 Full config reference: [docs/configuration.md](docs/configuration.md) *(coming soon see [docs/usage.md](docs/usage.md) for now)*
500
181
 
501
- ```text
502
- /team-settings # list all known config keys
503
- /team-settings get limits.maxTurns # read one key
504
- /team-settings set limits.maxTurns 20 # update a key
505
- /team-settings unset runtime.maxTurns # reset to default
506
- /team-settings path # show config file path
507
- /team-settings scope # show current scope (user/project)
508
- ```
182
+ ---
509
183
 
510
- **Supported config keys:**
511
-
512
- | Key | Type | Description |
513
- |-----|------|-------------|
514
- | `asyncByDefault` | boolean | Run workflows async by default |
515
- | `executeWorkers` | boolean | Enable real child Pi workers |
516
- | `notifierIntervalMs` | number | Polling interval for async notifications |
517
- | `runtime.mode` | `"auto"\|"scaffold"\|"child-process"\|"live-session"` | Crew runtime selection |
518
- | `runtime.maxTurns` | number | Max turns per worker |
519
- | `runtime.graceTurns` | number | Grace turns after max |
520
- | `runtime.inheritContext` | boolean | Workers inherit parent context |
521
- | `runtime.promptMode` | `"replace"\|"append"` | Prompt merge strategy |
522
- | `runtime.groupJoin` | `"off"\|"group"\|"smart"` | Group join strategy |
523
- | `runtime.groupJoinAckTimeoutMs` | number | Group join ack timeout (ms) |
524
- | `runtime.requirePlanApproval` | boolean | Require plan approval before execution |
525
- | `runtime.completionMutationGuard` | `"off"\|"warn"\|"fail"` | Mutation guard on completion |
526
- | `limits.maxConcurrentWorkers` | number | Max concurrent workers |
527
- | `limits.maxTaskDepth` | number | Max task tree depth |
528
- | `limits.maxChildrenPerTask` | number | Max children per task |
529
- | `limits.maxRunMinutes` | number | Max run duration (minutes) |
530
- | `limits.maxRetriesPerTask` | number | Max retries per task |
531
- | `limits.maxTasksPerRun` | number | Max tasks per run |
532
- | `limits.heartbeatStaleMs` | number | Heartbeat stale threshold (ms) |
533
- | `control.enabled` | boolean | Enable agent control-plane |
534
- | `control.needsAttentionAfterMs` | number | Attention trigger after inactivity (ms) |
535
- | `autonomous.profile` | `"manual"\|"suggested"\|"assisted"\|"aggressive"` | Autonomy profile |
536
- | `autonomous.injectPolicy` | boolean | Inject autonomy policy into prompt |
537
- | `autonomous.preferAsyncForLongTasks` | boolean | Auto-async for long tasks |
538
- | `autonomous.allowWorktreeSuggestion` | boolean | Suggest worktree mode |
539
- | `tools.enableClaudeStyleAliases` | boolean | Enable Claude-style tool aliases |
540
- | `tools.enableSteer` | boolean | Enable steer tool |
541
- | `tools.terminateOnForeground` | boolean | Return terminate:true from foreground Agent |
542
- | `agents.disableBuiltins` | boolean | Disable all builtin agents |
543
- | `observability.prometheus.enabled` | boolean | Enable Prometheus exporter |
544
- | `observability.otlp.enabled` | boolean | Enable OTLP exporter |
545
- | `worktree.enabled` | boolean | Enable worktree isolation |
546
-
547
- ## Dashboard
548
-
549
- Open:
184
+ ## Tool Actions
550
185
 
551
- ```text
552
- /team-dashboard
186
+ ```json
187
+ { "action": "run", "team": "default", "goal": "..." } // execute
188
+ { "action": "status", "runId": "team_..." } // monitor
189
+ { "action": "cancel", "runId": "team_..." } // stop
190
+ { "action": "resume", "runId": "team_..." } // continue
191
+ { "action": "recommend", "goal": "..." } // get advice
192
+ { "action": "list" } // discover
193
+ { "action": "create", "resource": "agent", ... } // extend
194
+ { "action": "doctor" } // diagnose
553
195
  ```
554
196
 
555
- Shortcuts:
556
-
557
- ```text
558
- ↑/↓ or j/k select run
559
- r reload run list
560
- p toggle short/long progress preview
561
- Enter or s show status
562
- a list artifacts
563
- u show summary
564
- i API read-manifest
565
- q or Esc close
566
- ```
197
+ 📖 Full actions reference: [docs/actions-reference.md](docs/actions-reference.md)
567
198
 
568
- ## Manager
199
+ ---
569
200
 
570
- Open:
201
+ ## Slash Commands
571
202
 
572
203
  ```text
573
- /team-manager
204
+ /team-run [--team=X] [--async] [--worktree] <goal>
205
+ /team-status <runId>
206
+ /team-dashboard
207
+ /team-doctor
208
+ /team-init [--copy-builtins]
209
+ /team-config [key=value]
210
+ /team-autonomy [status|on|off|suggested|assisted]
574
211
  ```
575
212
 
576
- Current flows:
213
+ 📖 Full commands reference: [docs/commands-reference.md](docs/commands-reference.md)
577
214
 
578
- - list resources/runs
579
- - run a team
580
- - show run status
581
- - cleanup run worktrees
582
- - create routed agent/team resources
583
- - update routed agent/team resources
584
- - doctor
585
-
586
- ## Resource paths
587
-
588
- Builtin package resources:
589
-
590
- ```text
591
- agents/*.md
592
- teams/*.team.md
593
- workflows/*.workflow.md
594
- ```
595
-
596
- User resources:
215
+ ---
597
216
 
598
- ```text
599
- ~/.pi/agent/agents/*.md
600
- ~/.pi/agent/teams/*.team.md
601
- ~/.pi/agent/workflows/*.workflow.md
602
- ```
217
+ ## Resource Discovery
603
218
 
604
- Project resources (new default layout):
219
+ Agents, teams, and workflows are discovered from three layers:
605
220
 
606
- ```text
607
- .crew/agents/*.md
608
- .crew/teams/*.team.md
609
- .crew/workflows/*.workflow.md
610
221
  ```
611
-
612
- Legacy layout (when `.pi/` already exists in the repo):
613
-
614
- ```text
615
- .pi/teams/agents/*.md
616
- .pi/teams/teams/*.team.md
617
- .pi/teams/workflows/*.workflow.md
222
+ builtin (package) < user (~/.pi/agent/) < project (.crew/ or .pi/teams/)
618
223
  ```
619
224
 
620
- Discovery priority:
225
+ Project resources can add new names but **cannot shadow** builtin/user resources.
621
226
 
622
- ```text
623
- builtin < user < project
624
- ```
227
+ ### Resource Paths
625
228
 
626
- ## Resource metadata
229
+ | Type | Builtin | User | Project |
230
+ |------|---------|------|---------|
231
+ | Agent | `agents/*.md` | `~/.pi/agent/agents/*.md` | `.crew/agents/*.md` |
232
+ | Team | `teams/*.team.md` | `~/.pi/agent/teams/*.team.md` | `.crew/teams/*.team.md` |
233
+ | Workflow | `workflows/*.workflow.md` | `~/.pi/agent/workflows/*.workflow.md` | `.crew/workflows/*.workflow.md` |
627
234
 
628
- Agents and teams may include optional routing metadata in frontmatter:
235
+ ### Custom Resources with Routing Metadata
629
236
 
630
237
  ```yaml
631
238
  ---
@@ -637,292 +244,80 @@ avoidWhen: docs-only edits
637
244
  cost: cheap
638
245
  category: backend
639
246
  ---
247
+ Your system prompt here.
640
248
  ```
641
249
 
642
- These fields guide autonomous policy injection and `recommend` routing.
643
-
644
- ## Builtin resources
645
-
646
- Builtin agents include roles such as:
647
-
648
- ```text
649
- analyst
650
- critic
651
- executor
652
- explorer
653
- planner
654
- reviewer
655
- security-reviewer
656
- test-engineer
657
- verifier
658
- writer
659
- ```
660
-
661
- Builtin teams include:
662
-
663
- ```text
664
- default
665
- fast-fix
666
- implementation
667
- research
668
- review
669
- ```
670
-
671
- Builtin workflows include:
672
-
673
- ```text
674
- default
675
- fast-fix
676
- implementation
677
- research
678
- review
679
- ```
680
-
681
- ## State layout
682
-
683
- Project-local state is preferred when the cwd is inside a recognised project (any of the markers listed in the Config section above). Otherwise pi-crew falls back to user-global state.
684
-
685
- The project state root (`<crewRoot>` below) resolves to:
686
-
687
- ```text
688
- <repoRoot>/.crew/ # default, used for new projects
689
- <repoRoot>/.pi/teams/ # legacy reuse when .pi/ already exists
690
- ```
691
-
692
- Typical project-local state (`<crewRoot>` is one of the two paths above):
693
-
694
- ```text
695
- <crewRoot>/state/runs/{runId}/manifest.json
696
- <crewRoot>/state/runs/{runId}/tasks.json
697
- <crewRoot>/state/runs/{runId}/events.jsonl
698
- <crewRoot>/artifacts/{runId}/...
699
- <crewRoot>/worktrees/{runId}/{taskId}
700
- <crewRoot>/imports/{runId}/run-export.json
701
- ```
250
+ 📖 Full resource formats: [docs/resource-formats.md](docs/resource-formats.md)
702
251
 
703
- Mailbox state:
704
-
705
- ```text
706
- <crewRoot>/state/runs/{runId}/mailbox/inbox.jsonl
707
- <crewRoot>/state/runs/{runId}/mailbox/outbox.jsonl
708
- <crewRoot>/state/runs/{runId}/mailbox/delivery.json
709
- <crewRoot>/state/runs/{runId}/mailbox/tasks/{taskId}/inbox.jsonl
710
- <crewRoot>/state/runs/{runId}/mailbox/tasks/{taskId}/outbox.jsonl
711
- ```
712
-
713
- User-global fallback (shared with other Pi tools):
714
-
715
- ```text
716
- ~/.pi/agent/extensions/pi-crew/state/runs/...
717
- ~/.pi/agent/extensions/pi-crew/artifacts/...
718
- ~/.pi/agent/extensions/pi-crew/imports/...
719
- ```
720
-
721
- ## Project initialization
722
-
723
- Initialize project-local layout:
724
-
725
- ```text
726
- /team-init
727
- ```
728
-
729
- Optionally copy builtin resources:
730
-
731
- ```text
732
- /team-init --copy-builtins
733
- /team-init --copy-builtins --overwrite
734
- ```
735
-
736
- Created directories (new projects):
737
-
738
- ```text
739
- .crew/agents/
740
- .crew/teams/
741
- .crew/workflows/
742
- .crew/imports/
743
- ```
744
-
745
- If the project already has `.pi/`, the legacy layout is initialised instead:
746
-
747
- ```text
748
- .pi/teams/agents/
749
- .pi/teams/teams/
750
- .pi/teams/workflows/
751
- .pi/teams/imports/
752
- ```
753
-
754
- `.gitignore` entries are written for whichever layout is active, e.g.:
755
-
756
- ```text
757
- # new layout
758
- .crew/state/
759
- .crew/artifacts/
760
- .crew/worktrees/
761
- .crew/imports/
762
-
763
- # legacy layout
764
- .pi/teams/state/
765
- .pi/teams/artifacts/
766
- .pi/teams/worktrees/
767
- .pi/teams/imports/
768
- ```
769
-
770
- ## Import/export
771
-
772
- Export writes:
773
-
774
- ```text
775
- {artifactsRoot}/export/run-export.json
776
- {artifactsRoot}/export/run-export.md
777
- ```
778
-
779
- Import stores bundles under (new layout):
780
-
781
- ```text
782
- .crew/imports/{runId}/run-export.json
783
- .crew/imports/{runId}/README.md
784
- ```
785
-
786
- or under the legacy layout when `.pi/` already exists:
787
-
788
- ```text
789
- .pi/teams/imports/{runId}/run-export.json
790
- .pi/teams/imports/{runId}/README.md
791
- ```
252
+ ---
792
253
 
793
- or user-global imports with `--user`:
254
+ ## State Layout
794
255
 
795
- ```text
796
- ~/.pi/agent/extensions/pi-crew/imports/{runId}/run-export.json
797
- ~/.pi/agent/extensions/pi-crew/imports/{runId}/README.md
798
256
  ```
799
-
800
- ## Doctor and validation
801
-
802
- Validate resources:
803
-
804
- ```text
805
- /team-validate
257
+ <crewRoot>/ # .crew/ (new) or .pi/teams/ (legacy)
258
+ ├── state/runs/{runId}/
259
+ │ ├── manifest.json # run metadata
260
+ │ ├── tasks.json # task graph + status
261
+ │ ├── events.jsonl # append-only events
262
+ │ └── agents/{taskId}/status.json # per-agent state
263
+ ├── artifacts/{runId}/
264
+ │ ├── goal.md
265
+ │ ├── prompts/{taskId}.md
266
+ │ ├── results/{taskId}.txt
267
+ │ ├── logs/{taskId}.log
268
+ │ └── summary.md
269
+ ├── worktrees/{runId}/{taskId}/
270
+ └── imports/{runId}/run-export.json
806
271
  ```
807
272
 
808
- Doctor:
809
-
810
- ```text
811
- /team-doctor
812
- ```
813
-
814
- Doctor checks include:
815
-
816
- - cwd
817
- - platform/architecture/Node.js version
818
- - `pi --version`
819
- - `git --version`
820
- - writable state paths
821
- - config parse
822
- - discovery counts
823
- - resource validation
824
- - current model/provider when available
825
- - model/fallback hints
826
-
827
- Optional child Pi smoke check is explicit only:
273
+ ---
828
274
 
829
- ```json
830
- {
831
- "action": "doctor",
832
- "config": {
833
- "smokeChildPi": true
834
- }
835
- }
836
- ```
275
+ ## Environment Variables
837
276
 
838
- ## Environment variables
277
+ | Variable | Purpose |
278
+ |----------|---------|
279
+ | `PI_CREW_EXECUTE_WORKERS=0` | Disable child workers (scaffold mode) |
280
+ | `PI_TEAMS_EXECUTE_WORKERS=0` | Legacy disable flag |
281
+ | `PI_TEAMS_MOCK_CHILD_PI=success` | Mock child worker for testing |
282
+ | `PI_TEAMS_PI_BIN=<path>` | Explicit Pi CLI path |
283
+ | `PI_TEAMS_HOME=<path>` | Override home for tests |
839
284
 
840
- ```text
841
- PI_CREW_EXECUTE_WORKERS=0 disable child workers and use scaffold/dry-run mode
842
- PI_TEAMS_EXECUTE_WORKERS=0 legacy disable flag
843
- PI_TEAMS_MOCK_CHILD_PI=success test/mock child worker success
844
- PI_TEAMS_MOCK_CHILD_PI=json-success
845
- PI_TEAMS_MOCK_CHILD_PI=retryable-failure
846
- PI_TEAMS_INHERIT_PROJECT_CONTEXT control child prompt context inheritance
847
- PI_TEAMS_INHERIT_SKILLS control skill inheritance
848
- PI_TEAMS_HOME override home path for tests/config/state
849
- PI_TEAMS_PI_BIN optional explicit Pi CLI script/shim path for doctor/child workers
850
- ```
285
+ ---
851
286
 
852
287
  ## Development
853
288
 
854
- Install dependencies:
855
-
856
289
  ```bash
857
290
  cd pi-crew
858
- npm install
859
- ```
860
-
861
- Run tests:
862
-
863
- ```bash
864
- npm test
291
+ npm install # dependencies
292
+ npm test # unit + integration tests
293
+ npm run typecheck # tsc --noEmit
294
+ npm run ci # full CI-equivalent check
295
+ npm pack --dry-run # package verification
865
296
  ```
866
297
 
867
- Typecheck and smoke import:
868
-
869
- ```bash
870
- npm run typecheck
871
- ```
872
-
873
- Full local CI-equivalent check:
874
-
875
- ```bash
876
- npm run ci
877
- ```
298
+ CI runs on: `ubuntu-latest` · `windows-latest` · `macos-latest`
878
299
 
879
- GitHub CI runs the same typecheck/test/pack checks on:
880
-
881
- ```text
882
- ubuntu-latest
883
- windows-latest
884
- macos-latest
885
- ```
886
-
887
- Package dry-run only:
888
-
889
- ```bash
890
- npm pack --dry-run
891
- ```
300
+ ---
892
301
 
893
302
  ## Documentation
894
303
 
895
- Package docs:
304
+ | Doc | Contents |
305
+ |-----|----------|
306
+ | [docs/actions-reference.md](docs/actions-reference.md) | Full tool actions + examples |
307
+ | [docs/commands-reference.md](docs/commands-reference.md) | Slash commands + `/team-api` |
308
+ | [docs/resource-formats.md](docs/resource-formats.md) | Agent/team/workflow file formats |
309
+ | [docs/usage.md](docs/usage.md) | Usage patterns + config examples |
310
+ | [docs/architecture.md](docs/architecture.md) | Internal architecture + run flow |
311
+ | [docs/runtime-flow.md](docs/runtime-flow.md) | Runtime execution details |
312
+ | [docs/live-mailbox-runtime.md](docs/live-mailbox-runtime.md) | Mailbox + live-session runtime |
313
+ | [docs/publishing.md](docs/publishing.md) | Release & publish process |
314
+ | [docs/next-upgrade-roadmap.md](docs/next-upgrade-roadmap.md) | Future upgrade roadmap |
315
+ | [schema.json](schema.json) | Config JSON schema |
316
+
317
+ Research docs (not in package): [`docs/pi-crew-research/`](https://github.com/baphuongna/pi-crew/tree/main/docs) — audits, deep research, distillation notes.
896
318
 
897
- ```text
898
- pi-crew/docs/architecture.md
899
- pi-crew/docs/usage.md
900
- pi-crew/docs/resource-formats.md
901
- pi-crew/docs/live-mailbox-runtime.md
902
- pi-crew/docs/publishing.md
903
- ```
904
-
905
- Historical workspace-level design/progress docs may exist in the original development workspace under `docs/pi-crew-*`, but package-maintained docs live under `pi-crew/docs/`.
906
-
907
- ## Local Pi smoke
908
-
909
- A local Pi smoke test requires an installed Pi CLI and a real Pi environment:
910
-
911
- ```bash
912
- cd pi-crew
913
- npm run smoke:pi
914
- ```
915
-
916
- Then in Pi:
917
-
918
- ```text
919
- /team-doctor
920
- /team-validate
921
- /team-autonomy status
922
- ```
319
+ ---
923
320
 
924
321
  ## Acknowledgements
925
322
 
926
- `pi-crew` builds on ideas and selected MIT-licensed implementation patterns from `pi-subagents` and `oh-my-claudecode`.
927
-
928
- It also draws conceptual inspiration from `oh-my-openagent`; no `oh-my-openagent` source code is copied unless separately documented and license-compatible.
323
+ `pi-crew` builds on ideas and selected MIT-licensed implementation patterns from `pi-subagents` and `oh-my-claudecode`, with conceptual inspiration from `oh-my-openagent`.