pi-crew 0.1.29 → 0.1.30
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.
- package/CHANGELOG.md +38 -0
- package/NOTICE.md +1 -0
- package/docs/architecture.md +164 -92
- package/docs/refactor-tasks-phase6.md +662 -0
- package/docs/runtime-flow.md +148 -0
- package/package.json +1 -1
- package/schema.json +1 -0
- package/skills/git-master/SKILL.md +19 -0
- package/skills/read-only-explorer/SKILL.md +21 -0
- package/skills/safe-bash/SKILL.md +16 -0
- package/skills/task-packet/SKILL.md +23 -0
- package/skills/verify-evidence/SKILL.md +22 -0
- package/src/config/config.ts +2 -0
- package/src/config/defaults.ts +1 -0
- package/src/extension/async-notifier.ts +33 -4
- package/src/extension/register.ts +15 -522
- package/src/extension/registration/artifact-cleanup.ts +14 -0
- package/src/extension/registration/commands.ts +208 -0
- package/src/extension/registration/subagent-helpers.ts +1 -1
- package/src/extension/registration/subagent-tools.ts +110 -0
- package/src/extension/registration/team-tool.ts +44 -0
- package/src/extension/team-tool/api.ts +4 -4
- package/src/extension/team-tool/cancel.ts +31 -0
- package/src/extension/team-tool/inspect.ts +41 -0
- package/src/extension/team-tool/lifecycle-actions.ts +79 -0
- package/src/extension/team-tool/plan.ts +19 -0
- package/src/extension/team-tool/run.ts +41 -3
- package/src/extension/team-tool/status.ts +73 -0
- package/src/extension/team-tool.ts +57 -224
- package/src/runtime/async-marker.ts +26 -0
- package/src/runtime/async-runner.ts +44 -9
- package/src/runtime/background-runner.ts +2 -0
- package/src/runtime/child-pi.ts +5 -1
- package/src/runtime/concurrency.ts +9 -3
- package/src/runtime/crew-agent-records.ts +1 -0
- package/src/runtime/crew-agent-runtime.ts +2 -1
- package/src/runtime/model-fallback.ts +21 -4
- package/src/runtime/pi-args.ts +2 -0
- package/src/runtime/process-status.ts +1 -0
- package/src/runtime/role-permission.ts +11 -0
- package/src/runtime/task-runner/live-executor.ts +98 -0
- package/src/runtime/task-runner/progress.ts +111 -0
- package/src/runtime/task-runner/prompt-builder.ts +72 -0
- package/src/runtime/task-runner/result-utils.ts +14 -0
- package/src/runtime/task-runner/state-helpers.ts +22 -0
- package/src/runtime/task-runner.ts +38 -283
- package/src/runtime/team-runner.ts +116 -7
- package/src/schema/config-schema.ts +1 -0
- package/src/state/mailbox.ts +28 -0
- package/src/state/types.ts +16 -0
- package/src/subagents/async-entry.ts +1 -0
- package/src/subagents/index.ts +3 -0
- package/src/subagents/live/control.ts +1 -0
- package/src/subagents/live/manager.ts +1 -0
- package/src/subagents/live/realtime.ts +1 -0
- package/src/subagents/live/session-runtime.ts +1 -0
- package/src/subagents/manager.ts +1 -0
- package/src/subagents/spawn.ts +1 -0
- package/src/ui/live-run-sidebar.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added Phase 6 async hardening: jiti loader resolution/fail-fast, async startup marker files, and early background-runner exit detection.
|
|
8
|
+
- Added worker concurrency hard cap with explicit `limits.allowUnboundedConcurrency` opt-out and observability event.
|
|
9
|
+
- Added persisted model routing metadata on tasks and agent records: requested model, resolved model, fallback chain, reason, and used attempt.
|
|
10
|
+
- Added self-contained architecture/runtime-flow docs and five built-in coding skills.
|
|
11
|
+
- Added mailbox replay on resume for pending inbox messages, including task-scoped messages.
|
|
12
|
+
- Added task resume checkpoints and recovery for crash-after-final-stdout and crash-after-artifact-write child-process tasks.
|
|
13
|
+
- Added async notifier detection for quiet dead background runners with durable `async.died` events.
|
|
14
|
+
- Added adaptive planner repair for malformed JSON, oversized task plans, and common role aliases before blocking implementation runs.
|
|
15
|
+
- Added package snapshot coverage for Phase 6 docs, skills, Pi manifest entries, and the runtime `jiti` dependency.
|
|
16
|
+
- Added `src/subagents/*` consolidation entrypoints for child spawning, background runner commands, and subagent manager APIs.
|
|
17
|
+
- Split `team-tool.ts` actions into focused status, inspect, lifecycle, cancel, and plan modules while preserving public action names.
|
|
18
|
+
- Split `register.ts` lifecycle wiring into command, team-tool, subagent-tool, and artifact-cleanup registration modules.
|
|
19
|
+
- Added async restart recovery integration smoke coverage for stale background pids.
|
|
20
|
+
- Added explicit recursive subagent depth and read-only role spawn-denial tests.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Async background runs now use an explicit jiti loader path and expose startup markers for recovery/health checks.
|
|
25
|
+
- Active batch selection now caps excessive user concurrency by default to protect local machines.
|
|
26
|
+
- Resume now emits mailbox replay metadata before restarting queued work.
|
|
27
|
+
- Child-process tasks now persist checkpoint phases (`started`, `child-spawned`, `child-stdout-final`, `artifact-written`) during execution.
|
|
28
|
+
- Split `task-runner.ts` prompt/progress/state/live helpers into focused modules while keeping `runTeamTask` as the public entrypoint.
|
|
29
|
+
- Moved live-session access behind `src/subagents/live/*` and dynamic task-runner imports so default child-process flow does not eagerly load live runtime code.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- Background runner startup failures are reported earlier instead of silently leaving queued/running manifests stale.
|
|
34
|
+
|
|
35
|
+
### Release prep notes
|
|
36
|
+
|
|
37
|
+
- Suggested next release grouping: `0.1.30` for Phase 6 runtime hardening, resume recovery, model observability, docs/skills, and internal refactors.
|
|
38
|
+
- Gate run locally: `npm run typecheck`, `npm test`, and `npm pack --dry-run`.
|
|
39
|
+
- No breaking public API changes: tool actions, slash commands, config schema, and package name remain stable.
|
|
40
|
+
|
|
3
41
|
## 0.1.29
|
|
4
42
|
|
|
5
43
|
- Republished the child worker response timeout fix as a fresh npm version.
|
package/NOTICE.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
- Primary design and Pi-extension implementation inspiration: `pi-subagents` by Nico Bailon, MIT license.
|
|
8
8
|
- Team orchestration, state, and worktree contract inspiration: `oh-my-claudecode` by Yeachan Heo, MIT license.
|
|
9
9
|
- Conceptual inspiration only: `oh-my-openagent` / `oh-my-opencode`, SUL-1.0. No source code from this project should be copied into `pi-crew` unless explicitly reviewed for license compatibility and documented here.
|
|
10
|
+
- Built-in skill topics are original pi-crew guidance informed by common agent-skill patterns in `Source/awesome-agent-skills`, `Source/oh-my-claudecode`, and related local references; no verbatim skill text was copied.
|
|
10
11
|
|
|
11
12
|
## Copied code policy
|
|
12
13
|
|
package/docs/architecture.md
CHANGED
|
@@ -1,92 +1,164 @@
|
|
|
1
|
-
# pi-crew Architecture
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
1
|
+
# pi-crew Architecture
|
|
2
|
+
|
|
3
|
+
`pi-crew` is a Pi package for coordinated multi-agent work. It is intentionally durable-first: every run is represented on disk, every task has a state record, and child workers stream progress into JSONL/status files so foreground sessions, background jobs, dashboards, and later restarts all read the same source of truth.
|
|
4
|
+
|
|
5
|
+
## Layers
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
Pi extension layer
|
|
9
|
+
register tools, slash commands, widget/dashboard, notifier, lifecycle cleanup
|
|
10
|
+
|
|
11
|
+
Runtime layer
|
|
12
|
+
team runner, task graph scheduler, child Pi process runner, async runner,
|
|
13
|
+
model fallback, policy engine, worktree manager, live-session experimental path
|
|
14
|
+
|
|
15
|
+
State layer
|
|
16
|
+
.pi/teams/state/runs/{runId}/manifest.json
|
|
17
|
+
.pi/teams/state/runs/{runId}/tasks.json
|
|
18
|
+
.pi/teams/state/runs/{runId}/events.jsonl
|
|
19
|
+
.pi/teams/state/runs/{runId}/agents/{taskId}/status.json
|
|
20
|
+
.pi/teams/artifacts/{runId}/...
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Run flow
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
user/team tool
|
|
27
|
+
│
|
|
28
|
+
▼
|
|
29
|
+
handleTeamTool(action=run)
|
|
30
|
+
├─ discover agents/teams/workflows
|
|
31
|
+
├─ validate team/workflow refs
|
|
32
|
+
├─ create run manifest + task graph
|
|
33
|
+
├─ write goal artifact
|
|
34
|
+
└─ choose foreground/session-bound or async/background mode
|
|
35
|
+
│
|
|
36
|
+
├─ foreground: startForegroundRun() schedules executeTeamRun()
|
|
37
|
+
│
|
|
38
|
+
└─ async: spawnBackgroundTeamRun()
|
|
39
|
+
├─ node --import jiti-register.mjs background-runner.ts
|
|
40
|
+
├─ background-runner writes async.started + async.pid marker
|
|
41
|
+
└─ executeTeamRun()
|
|
42
|
+
├─ resolve ready task batch
|
|
43
|
+
├─ resolveBatchConcurrency() with hard cap
|
|
44
|
+
├─ runTeamTask() per task
|
|
45
|
+
│ ├─ build prompt + dependency context
|
|
46
|
+
│ ├─ choose configured Pi model candidates
|
|
47
|
+
│ ├─ spawn child `pi` worker
|
|
48
|
+
│ ├─ observe JSONL/stdout progress
|
|
49
|
+
│ ├─ persist agent status/events/output
|
|
50
|
+
│ └─ write result/log/transcript artifacts
|
|
51
|
+
├─ merge task updates monotonically
|
|
52
|
+
├─ write progress artifacts
|
|
53
|
+
└─ synthesize policy closeout
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Extension layer
|
|
57
|
+
|
|
58
|
+
`src/extension/register.ts` wires the package into Pi:
|
|
59
|
+
|
|
60
|
+
- `team` tool and management actions.
|
|
61
|
+
- Conflict-safe subagent tools: `crew_agent`, `crew_agent_result`, `crew_agent_steer`.
|
|
62
|
+
- Claude-style aliases: `Agent`, `get_subagent_result`, `steer_subagent` when available.
|
|
63
|
+
- Slash commands including `/team-run`, `/team-status`, `/team-dashboard`, `/team-doctor`, `/team-config`, `/team-summary`.
|
|
64
|
+
- Active-only widget and optional dashboard/sidebar UI.
|
|
65
|
+
- Foreground run scheduling and shutdown cleanup.
|
|
66
|
+
- Async completion notifier and session-start active-run summary.
|
|
67
|
+
|
|
68
|
+
The extension layer should remain thin: user input is normalized into tool parameters, then delegated to runtime/state modules.
|
|
69
|
+
|
|
70
|
+
## Runtime layer
|
|
71
|
+
|
|
72
|
+
### Team runner
|
|
73
|
+
|
|
74
|
+
`src/runtime/team-runner.ts` drives workflow execution. It reads queued tasks, computes the ready set from the task graph, applies concurrency limits, runs a batch, then merges results back into the latest task state. Terminal task states are monotonic: stale parallel snapshots must not regress completed/failed/cancelled/skipped tasks back to queued/running.
|
|
75
|
+
|
|
76
|
+
### Task runner
|
|
77
|
+
|
|
78
|
+
`src/runtime/task-runner.ts` executes one task. It prepares workspace/worktree context, renders a task prompt, chooses model candidates from Pi configuration, launches a child Pi process by default, and writes result artifacts. Scaffold mode is explicit dry-run only.
|
|
79
|
+
|
|
80
|
+
### Child Pi runtime
|
|
81
|
+
|
|
82
|
+
`src/runtime/child-pi.ts` is the default worker runtime. It:
|
|
83
|
+
|
|
84
|
+
- launches real `pi` child processes,
|
|
85
|
+
- hides Windows console windows with `windowsHide: true`,
|
|
86
|
+
- streams JSONL output into transcripts,
|
|
87
|
+
- compacts noisy message updates,
|
|
88
|
+
- isolates observer callback failures so progress persistence cannot kill orchestration,
|
|
89
|
+
- applies post-exit stdio guards for late output.
|
|
90
|
+
|
|
91
|
+
### Async background runner
|
|
92
|
+
|
|
93
|
+
`src/runtime/async-runner.ts` spawns detached background runs. Installed packages use an absolute `jiti-register.mjs` loader path because Node strip-types refuses TypeScript under `node_modules`. The runner fail-fasts if jiti is missing, and writes `async.pid` once startup begins so the parent can distinguish a healthy start from an early import crash.
|
|
94
|
+
|
|
95
|
+
### Concurrency and policy
|
|
96
|
+
|
|
97
|
+
`src/runtime/concurrency.ts` picks batch size from explicit limits, team settings, workflow settings, or built-in defaults. User-provided `limits.maxConcurrentWorkers` is hard-capped by default to prevent local DoS; `limits.allowUnboundedConcurrency=true` is an explicit opt-out and emits an observability event.
|
|
98
|
+
|
|
99
|
+
`src/runtime/policy-engine.ts` applies closeout and safety policy decisions such as limit exceeded, failed task blocking, stale workers, and green-contract failures.
|
|
100
|
+
|
|
101
|
+
### Model routing
|
|
102
|
+
|
|
103
|
+
Model choice is based on Pi's current configuration/model registry, not hardcoded providers. Task and agent records persist model attempts and routing metadata so dashboards/status can show requested model, selected model, fallback chain, and fallback reason.
|
|
104
|
+
|
|
105
|
+
## State layer
|
|
106
|
+
|
|
107
|
+
Run state is under:
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
.pi/teams/state/runs/{runId}/
|
|
111
|
+
manifest.json run metadata/status/artifacts/async pid
|
|
112
|
+
tasks.json task graph and per-task status
|
|
113
|
+
events.jsonl append-only run events
|
|
114
|
+
events.jsonl.seq event sequence cache
|
|
115
|
+
agents.json aggregate agent cache
|
|
116
|
+
async.pid background startup marker
|
|
117
|
+
agents/{taskId}/
|
|
118
|
+
status.json per-agent status source
|
|
119
|
+
events.jsonl per-agent event stream
|
|
120
|
+
output.log compact worker output
|
|
121
|
+
sidechain.output.jsonl
|
|
122
|
+
live-control.jsonl
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Artifacts are under:
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
.pi/teams/artifacts/{runId}/
|
|
129
|
+
goal.md
|
|
130
|
+
prompts/{taskId}.md
|
|
131
|
+
results/{taskId}.txt
|
|
132
|
+
logs/{taskId}.log
|
|
133
|
+
transcripts/{taskId}.jsonl
|
|
134
|
+
metadata/*.json
|
|
135
|
+
progress.md
|
|
136
|
+
summary.md
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Atomic writes use temp-file replace with retry for transient Windows `EPERM`/`EBUSY`/`EACCES`. JSONL append paths are best-effort where used for observers/progress; write failures must not crash child output parsing.
|
|
140
|
+
|
|
141
|
+
## UI and observability
|
|
142
|
+
|
|
143
|
+
- The persistent widget shows active runs only.
|
|
144
|
+
- Stale async runs with dead background pids are hidden from the active widget.
|
|
145
|
+
- `/team-status` is the canonical detailed state view and can mark stale active async runs failed.
|
|
146
|
+
- `/team-dashboard` provides history and details.
|
|
147
|
+
- Powerbar publishing is optional and event-compatible.
|
|
148
|
+
- Transcript viewer is file-backed so it works for foreground and async runs.
|
|
149
|
+
|
|
150
|
+
## Lifecycle and cleanup
|
|
151
|
+
|
|
152
|
+
Foreground runs are session-bound and should be interrupted on session shutdown or session switch. Only explicit `async: true` runs are allowed to survive the Pi session. Runtime cleanup is registered through Pi lifecycle hooks and a global reload cleanup guard.
|
|
153
|
+
|
|
154
|
+
## Configuration
|
|
155
|
+
|
|
156
|
+
Key config sections:
|
|
157
|
+
|
|
158
|
+
- `runtime`: `auto`, `child-process`, `scaffold`, experimental `live-session`.
|
|
159
|
+
- `limits`: concurrency/task/depth safety controls.
|
|
160
|
+
- `ui`: widget/dashboard/powerbar/model-token display settings.
|
|
161
|
+
- `agents`: builtin overrides for models/fallbacks/tools.
|
|
162
|
+
- `autonomous`: policy injection/profile for proactive team delegation.
|
|
163
|
+
|
|
164
|
+
See `usage.md`, `resource-formats.md`, `runtime-flow.md`, and `live-mailbox-runtime.md` for operational details.
|