pi-crew 0.1.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 (95) hide show
  1. package/AGENTS.md +32 -0
  2. package/CHANGELOG.md +6 -0
  3. package/LICENSE +21 -0
  4. package/NOTICE.md +15 -0
  5. package/README.md +703 -0
  6. package/agents/analyst.md +11 -0
  7. package/agents/critic.md +11 -0
  8. package/agents/executor.md +11 -0
  9. package/agents/explorer.md +11 -0
  10. package/agents/planner.md +11 -0
  11. package/agents/reviewer.md +11 -0
  12. package/agents/security-reviewer.md +11 -0
  13. package/agents/test-engineer.md +11 -0
  14. package/agents/verifier.md +11 -0
  15. package/agents/writer.md +11 -0
  16. package/docs/architecture.md +92 -0
  17. package/docs/live-mailbox-runtime.md +36 -0
  18. package/docs/publishing.md +65 -0
  19. package/docs/resource-formats.md +131 -0
  20. package/docs/usage.md +203 -0
  21. package/index.ts +6 -0
  22. package/install.mjs +19 -0
  23. package/package.json +79 -0
  24. package/schema.json +45 -0
  25. package/skills/.gitkeep +0 -0
  26. package/src/agents/agent-config.ts +27 -0
  27. package/src/agents/agent-serializer.ts +34 -0
  28. package/src/agents/discover-agents.ts +73 -0
  29. package/src/config/config.ts +193 -0
  30. package/src/extension/async-notifier.ts +36 -0
  31. package/src/extension/autonomous-policy.ts +122 -0
  32. package/src/extension/help.ts +43 -0
  33. package/src/extension/import-index.ts +52 -0
  34. package/src/extension/management.ts +335 -0
  35. package/src/extension/project-init.ts +74 -0
  36. package/src/extension/register.ts +349 -0
  37. package/src/extension/run-bundle-schema.ts +85 -0
  38. package/src/extension/run-export.ts +59 -0
  39. package/src/extension/run-import.ts +46 -0
  40. package/src/extension/run-index.ts +28 -0
  41. package/src/extension/run-maintenance.ts +24 -0
  42. package/src/extension/session-summary.ts +8 -0
  43. package/src/extension/team-manager-command.ts +86 -0
  44. package/src/extension/team-recommendation.ts +174 -0
  45. package/src/extension/team-tool.ts +783 -0
  46. package/src/extension/tool-result.ts +16 -0
  47. package/src/extension/validate-resources.ts +77 -0
  48. package/src/prompt/prompt-runtime.ts +58 -0
  49. package/src/runtime/async-runner.ts +26 -0
  50. package/src/runtime/background-runner.ts +43 -0
  51. package/src/runtime/child-pi.ts +75 -0
  52. package/src/runtime/model-fallback.ts +101 -0
  53. package/src/runtime/pi-args.ts +81 -0
  54. package/src/runtime/pi-json-output.ts +110 -0
  55. package/src/runtime/pi-spawn.ts +96 -0
  56. package/src/runtime/process-status.ts +25 -0
  57. package/src/runtime/task-runner.ts +164 -0
  58. package/src/runtime/team-runner.ts +135 -0
  59. package/src/runtime/worker-heartbeat.ts +21 -0
  60. package/src/schema/team-tool-schema.ts +100 -0
  61. package/src/state/artifact-store.ts +36 -0
  62. package/src/state/atomic-write.ts +18 -0
  63. package/src/state/contracts.ts +88 -0
  64. package/src/state/event-log.ts +27 -0
  65. package/src/state/locks.ts +40 -0
  66. package/src/state/mailbox.ts +188 -0
  67. package/src/state/state-store.ts +119 -0
  68. package/src/state/task-claims.ts +42 -0
  69. package/src/state/types.ts +88 -0
  70. package/src/state/usage.ts +29 -0
  71. package/src/teams/discover-teams.ts +84 -0
  72. package/src/teams/team-config.ts +22 -0
  73. package/src/teams/team-serializer.ts +36 -0
  74. package/src/ui/run-dashboard.ts +138 -0
  75. package/src/utils/frontmatter.ts +36 -0
  76. package/src/utils/ids.ts +12 -0
  77. package/src/utils/names.ts +26 -0
  78. package/src/utils/paths.ts +15 -0
  79. package/src/workflows/discover-workflows.ts +101 -0
  80. package/src/workflows/validate-workflow.ts +40 -0
  81. package/src/workflows/workflow-config.ts +24 -0
  82. package/src/workflows/workflow-serializer.ts +31 -0
  83. package/src/worktree/cleanup.ts +69 -0
  84. package/src/worktree/worktree-manager.ts +60 -0
  85. package/teams/default.team.md +12 -0
  86. package/teams/fast-fix.team.md +11 -0
  87. package/teams/implementation.team.md +15 -0
  88. package/teams/research.team.md +11 -0
  89. package/teams/review.team.md +12 -0
  90. package/tsconfig.json +19 -0
  91. package/workflows/default.workflow.md +29 -0
  92. package/workflows/fast-fix.workflow.md +22 -0
  93. package/workflows/implementation.workflow.md +47 -0
  94. package/workflows/research.workflow.md +22 -0
  95. package/workflows/review.workflow.md +30 -0
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: executor
3
+ description: Implement planned code changes
4
+ model: claude-sonnet-4-5
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls, bash, edit, write
9
+ ---
10
+
11
+ You are an implementation specialist. Follow the provided plan, make targeted changes, keep edits minimal, and report changed files plus validation status. Do not broaden scope without explaining why.
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: explorer
3
+ description: Fast codebase discovery and file/symbol mapping
4
+ model: claude-haiku-4-5
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls
9
+ ---
10
+
11
+ You are a fast codebase explorer. Map relevant files, symbols, data flow, and constraints. Do not modify files. Return concise findings with paths and evidence.
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: planner
3
+ description: Create an execution plan with clear sequencing and risk notes
4
+ model: claude-sonnet-4-5
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls
9
+ ---
10
+
11
+ You are a planning specialist. Convert the goal and discovery notes into a concrete, ordered plan. Identify dependencies, risks, validation steps, and handoff instructions for implementers.
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: reviewer
3
+ description: Review code changes for correctness, maintainability, and regressions
4
+ model: claude-sonnet-4-5
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls, bash
9
+ ---
10
+
11
+ You are a code reviewer. Review the implementation for bugs, regressions, maintainability issues, missing tests, and project-rule violations. Return prioritized findings with evidence.
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: security-reviewer
3
+ description: Review changes for security vulnerabilities and trust-boundary issues
4
+ model: claude-sonnet-4-5
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls, bash
9
+ ---
10
+
11
+ You are a security reviewer. Look for injection, authn/authz flaws, insecure defaults, secret exposure, unsafe filesystem/network behavior, and dependency risks. Return severity and remediation.
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: test-engineer
3
+ description: Design and implement test strategy for a change
4
+ model: claude-sonnet-4-5
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls, bash, edit, write
9
+ ---
10
+
11
+ You are a test engineer. Identify the right test level, add or adjust tests when asked, detect flaky assumptions, and report exact validation commands and results.
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: verifier
3
+ description: Verify that implementation satisfies the requested goal
4
+ model: claude-sonnet-4-5
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls, bash
9
+ ---
10
+
11
+ You are a verification specialist. Check whether the work is complete, correct, tested, and aligned with project constraints. Prefer evidence over assumptions. Return PASS or FAIL with reasons.
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: writer
3
+ description: Write concise documentation, migration notes, and summaries
4
+ model: claude-haiku-4-5
5
+ systemPromptMode: replace
6
+ inheritProjectContext: true
7
+ inheritSkills: false
8
+ tools: read, grep, find, ls, edit, write
9
+ ---
10
+
11
+ You are a documentation specialist. Produce clear, concise, maintainable docs and summaries. Preserve technical accuracy and avoid marketing fluff.
@@ -0,0 +1,92 @@
1
+ # pi-crew Architecture
2
+
3
+ Canonical architecture documentation currently lives at workspace level:
4
+
5
+ - `../docs/pi-crew-source-review-and-lessons.md`
6
+ - `../docs/pi-crew-architecture.md`
7
+ - `../docs/pi-crew-mvp-plan.md`
8
+
9
+ This project-local document exists so the package contains an obvious documentation entry point. Keep it in sync as implementation progresses.
10
+
11
+ ## Current scaffold
12
+
13
+ Implemented now:
14
+
15
+ - Pi package manifest
16
+ - autonomous delegation policy injection so the agent can decide when to use the `team` tool
17
+ - dynamic autonomous resource guidance generated from discovered agents/teams/workflows
18
+ - `recommend` action for agent-side team/workflow routing, decomposition, and fanout hints before plan/run
19
+ - `autonomy` action and `/team-autonomy` command for toggling autonomous delegation and profiles
20
+ - centralized state contracts plus task-claim, worker-heartbeat, run-lock, progress-artifact, mailbox files, dashboard progress/action helpers, and safe API interop contracts for runtime hardening
21
+ - extension entrypoint
22
+ - main `team` tool
23
+ - slash commands: `/teams`, `/team-run`, `/team-status`, `/team-doctor`
24
+ - builtin agent/team/workflow markdown resources
25
+ - resource discovery for builtin/user/project paths
26
+ - TypeBox tool schema
27
+ - model fallback helper
28
+ - state type definitions
29
+ - atomic state writes
30
+ - JSONL event log
31
+ - artifact store with content hashes
32
+ - durable run manifests and task files
33
+ - workflow validation
34
+ - foreground workflow scheduler
35
+ - safe scaffold task execution
36
+ - optional real child Pi execution via `PI_TEAMS_EXECUTE_WORKERS=1`
37
+ - safety-first create/update/delete for agents, teams, and workflows
38
+ - backups for update/delete mutations
39
+ - dry-run support for management mutations
40
+ - detached async background runner
41
+ - opt-in git worktree task workspace creation
42
+ - worktree diff artifacts
43
+ - child prompt runtime for inherited project-context/skills stripping
44
+ - retryable model fallback attempts per worker task
45
+ - rich status output with recent artifacts and event tail
46
+ - recent run listing
47
+ - `/team-cleanup` worktree cleanup command
48
+ - improved `/team-run` parser for `--async`, `--worktree`, `--team=`, `--workflow=`, `--role=`, `--agent=`
49
+ - async completion polling notifications during Pi sessions
50
+ - active run summary on session start
51
+ - reference checks before deleting referenced agents/workflows
52
+ - optional reference updates when renaming agents/workflows
53
+ - expanded doctor checks for `pi`, `git`, writable state paths, and resource discovery
54
+ - durable run integration-style test coverage
55
+ - user config loader for async defaults, worker execution, notifier interval, and worktree cleanliness policy
56
+ - `pi-crew` install helper that creates default config
57
+ - worktree branch mismatch detection before reuse
58
+ - simple interactive `/team-manager` built with Pi UI dialogs
59
+ - dedicated `events` and `artifacts` actions plus slash commands
60
+ - persisted worktree metadata on task state/status
61
+ - mocked child Pi execution path for integration-style tests
62
+ - package polish: `.gitignore`, `tsconfig.json`, `npm run check`
63
+ - project-local `AGENTS.md` development rules
64
+ - run resume action/command that re-queues failed/cancelled/skipped/running tasks
65
+ - dedicated worktrees inspection action and `/team-worktrees`
66
+ - real temp-git worktree integration test
67
+ - async run metadata persisted in manifest/status
68
+ - stale async PID detection that marks active orphaned runs failed on status inspection
69
+ - child Pi JSON output parsing for final text, usage, and JSON event counts
70
+ - aggregate usage totals in status/summary
71
+ - summary artifact and `summary` action/`/team-summary` command
72
+ - custom overlay `/team-dashboard` run browser built with `ctx.ui.custom`
73
+ - dashboard details pane with status counts and selected run metadata
74
+ - prune action and `/team-prune` to remove old finished runs after confirmation
75
+ - export action and `/team-export` to write portable JSON/Markdown run bundles
76
+ - import action and `/team-import` to store exported bundles under local imports
77
+ - imports action and `/team-imports` to browse imported bundles
78
+ - help action and `/team-help` command
79
+ - validate action and `/team-validate` command for agents/teams/workflows
80
+ - doctor auto-runs resource validation and reports validation errors/warnings
81
+ - project init action and `/team-init` command for `.pi` directories, `.gitignore`, and optional builtin resource copying
82
+ - config action and `/team-config` command
83
+ - published `schema.json` for config validation
84
+ - publishing checklist docs
85
+ - `/team-cancel` command alias
86
+ - forget action and `/team-forget` to delete run state/artifacts after confirmation
87
+ - resource format documentation
88
+ - unit tests for async stale detection, autonomous config toggling, autonomous policy, autonomous recommendation/decomposition, config, project config merge, config action, dashboard rendering/navigation, discovery, doctor/model validation, events/artifacts/worktrees inspection, export/import run bundles and schema validation, help output, imported bundle listing, forget run cleanup, management, management reference checks, mocked child execution, child JSON output parsing and fixtures, model fallback, project init, prompt runtime, prune run cleanup, resource validation, resume/cancel, routing metadata, runtime hardening/progress/API interop, state contracts, state store, summary artifact/action, task claims, team run persistence, worker heartbeat, worktree mode, and workflow validation
89
+
90
+ Not implemented yet:
91
+
92
+ - richer multi-pane custom TUI manager
@@ -0,0 +1,36 @@
1
+ # Live Mailbox Runtime Direction
2
+
3
+ `pi-crew` currently uses workflow child-process orchestration: a run materializes tasks, executes them through the scheduler, writes artifacts/events, and optionally launches child Pi workers.
4
+
5
+ A full live mailbox runtime is intentionally out of scope for the current stable surface. Current foundational mailbox files are intentionally simple and local:
6
+
7
+ ```text
8
+ {stateRoot}/mailbox/inbox.jsonl
9
+ {stateRoot}/mailbox/outbox.jsonl
10
+ {stateRoot}/mailbox/delivery.json
11
+ {stateRoot}/mailbox/tasks/{taskId}/inbox.jsonl
12
+ {stateRoot}/mailbox/tasks/{taskId}/outbox.jsonl
13
+ ```
14
+
15
+ They are exposed through safe API operations (`read-mailbox`, `send-message`, `ack-message`, `read-delivery`, `validate-mailbox`) but do not yet imply always-on long-lived workers. If a full runtime is added later, it should build on the foundations already present:
16
+
17
+ - `src/state/contracts.ts` for status/event contracts
18
+ - `src/state/task-claims.ts` for claim/lease safety
19
+ - `src/runtime/worker-heartbeat.ts` for liveness
20
+ - `src/state/locks.ts` for run-level mutation safety
21
+ - `action: "api"` for safe interop boundaries
22
+
23
+ ## Proposed phases
24
+
25
+ 1. **Read-only interop** — already started with `api` operations.
26
+ 2. **Heartbeat writers** — allow workers to update heartbeat/progress safely.
27
+ 3. **Claim-safe task lifecycle** — expose claim/release/transition operations with tokens.
28
+ 4. **Mailbox** — add worker inbox/leader inbox files and delivery state.
29
+ 5. **Live workers** — only after the above contracts are stable.
30
+
31
+ ## Non-goals for now
32
+
33
+ - No always-on background worker pool.
34
+ - No automatic destructive cleanup of dirty worktrees.
35
+ - No recursive team spawning by workers.
36
+ - No mailbox mutation without locks and schema validation.
@@ -0,0 +1,65 @@
1
+ # Publishing pi-crew
2
+
3
+ This package is published as the scoped public npm package:
4
+
5
+ ```text
6
+ pi-crew
7
+ ```
8
+
9
+ Before publishing to npm:
10
+
11
+ 1. Confirm package metadata in `package.json`:
12
+ - `author`
13
+ - `repository`
14
+ - `homepage`
15
+ - `bugs`
16
+ - `publishConfig.access = public`
17
+ 2. Confirm license and notices:
18
+ - keep `LICENSE`
19
+ - keep `NOTICE.md`
20
+ - document copied/adapted MIT source if any substantial code is ported
21
+ 3. Run checks:
22
+
23
+ ```bash
24
+ npm run check
25
+ ```
26
+
27
+ 4. Verify package contents:
28
+
29
+ ```bash
30
+ npm pack --dry-run
31
+ ```
32
+
33
+ 5. Verify local install in Pi:
34
+
35
+ ```bash
36
+ pi install ./pi-crew
37
+ /team-doctor
38
+ /team-validate
39
+ ```
40
+
41
+ 6. Publish when ready:
42
+
43
+ ```bash
44
+ npm publish --access public
45
+ ```
46
+
47
+ Users can install the published package with:
48
+
49
+ ```bash
50
+ pi install npm:pi-crew
51
+ ```
52
+
53
+ ## Config schema
54
+
55
+ The package exports:
56
+
57
+ ```text
58
+ ./schema.json
59
+ ```
60
+
61
+ Use this for editor validation of:
62
+
63
+ ```text
64
+ ~/.pi/agent/extensions/pi-crew/config.json
65
+ ```
@@ -0,0 +1,131 @@
1
+ # pi-crew Resource Formats
2
+
3
+ ## Agent files
4
+
5
+ Location:
6
+
7
+ ```text
8
+ agents/{name}.md
9
+ ~/.pi/agent/agents/{name}.md
10
+ .pi/agents/{name}.md
11
+ ```
12
+
13
+ Format:
14
+
15
+ ```md
16
+ ---
17
+ name: executor
18
+ description: Implement planned code changes
19
+ model: claude-sonnet-4-5
20
+ fallbackModels: openai/gpt-5-mini, anthropic/claude-sonnet-4
21
+ thinking: high
22
+ tools: read, grep, find, ls, bash, edit, write
23
+ extensions: /path/to/extension.ts
24
+ skills: safe-bash
25
+ systemPromptMode: replace
26
+ inheritProjectContext: true
27
+ inheritSkills: false
28
+ triggers: auth, tests
29
+ useWhen: multi-file implementation with tests
30
+ avoidWhen: one-line typo
31
+ cost: cheap
32
+ category: implementation
33
+ ---
34
+
35
+ System prompt body.
36
+ ```
37
+
38
+ Optional routing metadata fields:
39
+
40
+ | Field | Meaning |
41
+ | --- | --- |
42
+ | `triggers` | Comma-separated terms that should route work to this agent/team |
43
+ | `useWhen` | Comma-separated natural-language use cases |
44
+ | `avoidWhen` | Comma-separated cases where the agent/team should not be used |
45
+ | `cost` | `free`, `cheap`, or `expensive` hint for autonomous routing |
46
+ | `category` | Free-form grouping such as `frontend`, `security`, `docs` |
47
+
48
+ ## Team files
49
+
50
+ Location:
51
+
52
+ ```text
53
+ teams/{name}.team.md
54
+ ~/.pi/agent/teams/{name}.team.md
55
+ .pi/teams/{name}.team.md
56
+ ```
57
+
58
+ Format:
59
+
60
+ ```md
61
+ ---
62
+ name: implementation
63
+ description: Full implementation team
64
+ defaultWorkflow: implementation
65
+ workspaceMode: single
66
+ maxConcurrency: 3
67
+ triggers: implementation, refactor
68
+ useWhen: multi-file implementation
69
+ cost: cheap
70
+ category: implementation
71
+ ---
72
+
73
+ - explorer: agent=explorer map the codebase
74
+ - planner: agent=planner create plan
75
+ - executor: agent=executor implement
76
+ - verifier: agent=verifier verify
77
+ ```
78
+
79
+ Role line:
80
+
81
+ ```text
82
+ - {role-name}: agent={agent-name} optional description
83
+ ```
84
+
85
+ ## Workflow files
86
+
87
+ Location:
88
+
89
+ ```text
90
+ workflows/{name}.workflow.md
91
+ ~/.pi/agent/workflows/{name}.workflow.md
92
+ .pi/workflows/{name}.workflow.md
93
+ ```
94
+
95
+ Format:
96
+
97
+ ```md
98
+ ---
99
+ name: default
100
+ description: Explore, plan, execute, verify
101
+ ---
102
+
103
+ ## explore
104
+ role: explorer
105
+
106
+ Explore for: {goal}
107
+
108
+ ## plan
109
+ role: planner
110
+ dependsOn: explore
111
+ output: plan.md
112
+
113
+ Create a plan for: {goal}
114
+ ```
115
+
116
+ Step fields:
117
+
118
+ | Field | Meaning |
119
+ | --- | --- |
120
+ | `role` | Team role to run |
121
+ | `dependsOn` | Comma-separated step IDs |
122
+ | `parallelGroup` | Optional grouping metadata |
123
+ | `output` | Output file name or `false` |
124
+ | `reads` | Comma-separated read files or `false` |
125
+ | `model` | Step model override |
126
+ | `skills` | Comma-separated skills or `false` |
127
+ | `progress` | `true`/`false` |
128
+ | `worktree` | `true`/`false` metadata |
129
+ | `verify` | `true`/`false` verification marker |
130
+
131
+ Avoid using level-2 headings (`##`) inside task bodies because they delimit workflow steps.
package/docs/usage.md ADDED
@@ -0,0 +1,203 @@
1
+ # pi-crew Usage
2
+
3
+ ## Config
4
+
5
+ Optional config path:
6
+
7
+ ```text
8
+ ~/.pi/agent/extensions/pi-crew/config.json
9
+ ```
10
+
11
+ Create a default config:
12
+
13
+ ```bash
14
+ node ./pi-crew/install.mjs
15
+ ```
16
+
17
+ Supported fields:
18
+
19
+ ```json
20
+ {
21
+ "asyncByDefault": false,
22
+ "executeWorkers": false,
23
+ "notifierIntervalMs": 5000,
24
+ "requireCleanWorktreeLeader": true,
25
+ "autonomous": {
26
+ "profile": "suggested",
27
+ "enabled": true,
28
+ "injectPolicy": true,
29
+ "preferAsyncForLongTasks": false,
30
+ "allowWorktreeSuggestion": true
31
+ }
32
+ }
33
+ ```
34
+
35
+ ## Local Pi smoke test
36
+
37
+ ```bash
38
+ cd pi-crew
39
+ npm run smoke:pi
40
+ ```
41
+
42
+ Then open Pi and run:
43
+
44
+ ```text
45
+ /team-doctor
46
+ /team-validate
47
+ /team-autonomy status
48
+ ```
49
+
50
+ ## Safe run
51
+
52
+ By default, `pi-crew` does not launch child workers. It creates a durable run, prompts, placeholder results, events, and artifacts.
53
+
54
+ ```json
55
+ {
56
+ "action": "run",
57
+ "team": "default",
58
+ "goal": "Implement login with tests"
59
+ }
60
+ ```
61
+
62
+ ## Real worker execution
63
+
64
+ Start Pi with:
65
+
66
+ ```bash
67
+ PI_TEAMS_EXECUTE_WORKERS=1 pi
68
+ ```
69
+
70
+ Then run normally. Each task can spawn a child Pi worker.
71
+
72
+ ## Async run
73
+
74
+ ```json
75
+ {
76
+ "action": "run",
77
+ "team": "implementation",
78
+ "goal": "Refactor auth module",
79
+ "async": true
80
+ }
81
+ ```
82
+
83
+ Check status:
84
+
85
+ ```json
86
+ {
87
+ "action": "status",
88
+ "runId": "team_..."
89
+ }
90
+ ```
91
+
92
+ ## Worktree mode
93
+
94
+ ```json
95
+ {
96
+ "action": "run",
97
+ "team": "implementation",
98
+ "goal": "Refactor API layer",
99
+ "workspaceMode": "worktree"
100
+ }
101
+ ```
102
+
103
+ The leader repository must be clean. Per-task worktrees are created under:
104
+
105
+ ```text
106
+ .pi/teams/worktrees/{runId}/{taskId}
107
+ ```
108
+
109
+ Cleanup:
110
+
111
+ ```json
112
+ {
113
+ "action": "cleanup",
114
+ "runId": "team_..."
115
+ }
116
+ ```
117
+
118
+ Dirty worktrees are preserved unless `force: true` is provided.
119
+
120
+ ## Slash commands
121
+
122
+ ```text
123
+ /teams
124
+ /team-run default "Implement login with tests"
125
+ /team-run --team=implementation --workflow=implementation --async "Refactor auth"
126
+ /team-cancel team_...
127
+ /team-run --worktree default "Change API safely"
128
+ /team-status team_...
129
+ /team-summary team_...
130
+ /team-resume team_...
131
+ /team-events team_...
132
+ /team-artifacts team_...
133
+ /team-worktrees team_...
134
+ /team-cleanup team_...
135
+ /team-forget team_... --confirm
136
+ /team-export team_...
137
+ /team-import .pi/teams/artifacts/team_.../export/run-export.json
138
+ /team-imports
139
+ /team-prune --keep=20 --confirm
140
+ /team-manager
141
+ /team-dashboard
142
+ /team-api team_... read-mailbox direction=outbox
143
+ /team-api team_... send-message direction=outbox taskId=task_... to=worker body="hello"
144
+ /team-api team_... validate-mailbox repair=true
145
+ /team-init
146
+ /team-init --copy-builtins
147
+ /team-config
148
+ /team-config autonomous.profile=assisted autonomous.preferAsyncForLongTasks=true --project
149
+ /team-config --unset=autonomous.preferAsyncForLongTasks --project
150
+ /team-autonomy status
151
+ /team-autonomy on
152
+ /team-autonomy off
153
+ /team-autonomy manual
154
+ /team-autonomy suggested
155
+ /team-autonomy assisted
156
+ /team-autonomy aggressive
157
+ /team-validate
158
+ /team-help
159
+ /team-doctor
160
+ ```
161
+
162
+ ## Management
163
+
164
+ Create resources:
165
+
166
+ ```json
167
+ {
168
+ "action": "create",
169
+ "resource": "team",
170
+ "config": {
171
+ "name": "Backend Team",
172
+ "description": "Backend work",
173
+ "scope": "project",
174
+ "defaultWorkflow": "default",
175
+ "roles": [{ "name": "executor", "agent": "executor" }]
176
+ }
177
+ }
178
+ ```
179
+
180
+ Rename an agent and update team references:
181
+
182
+ ```json
183
+ {
184
+ "action": "update",
185
+ "resource": "agent",
186
+ "agent": "worker",
187
+ "scope": "project",
188
+ "updateReferences": true,
189
+ "config": { "name": "better-worker" }
190
+ }
191
+ ```
192
+
193
+ Delete requires confirmation:
194
+
195
+ ```json
196
+ {
197
+ "action": "delete",
198
+ "resource": "team",
199
+ "team": "backend-team",
200
+ "scope": "project",
201
+ "confirm": true
202
+ }
203
+ ```
package/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
+ import { registerPiTeams } from "./src/extension/register.ts";
3
+
4
+ export default function (pi: ExtensionAPI): void {
5
+ registerPiTeams(pi);
6
+ }
package/install.mjs ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import * as fs from "node:fs";
3
+ import * as os from "node:os";
4
+ import * as path from "node:path";
5
+
6
+ const configDir = path.join(os.homedir(), ".pi", "agent", "extensions", "pi-crew");
7
+ const configPath = path.join(configDir, "config.json");
8
+ fs.mkdirSync(configDir, { recursive: true });
9
+ if (!fs.existsSync(configPath)) {
10
+ fs.writeFileSync(configPath, `${JSON.stringify({ asyncByDefault: false, executeWorkers: false, notifierIntervalMs: 5000, requireCleanWorktreeLeader: true, autonomous: { enabled: true, injectPolicy: true, preferAsyncForLongTasks: false, allowWorktreeSuggestion: true } }, null, 2)}\n`, "utf-8");
11
+ console.log(`Created default pi-crew config: ${configPath}`);
12
+ } else {
13
+ console.log(`pi-crew config already exists: ${configPath}`);
14
+ }
15
+
16
+ console.log("\nInstall this package in Pi with:");
17
+ console.log(" pi install ./pi-crew");
18
+ console.log("\nEnable real child workers by setting either config executeWorkers=true or environment:");
19
+ console.log(" PI_TEAMS_EXECUTE_WORKERS=1 pi");