pi-crew 0.9.66 → 0.9.68

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 (52) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/README.md +2 -3
  3. package/agents/executor.md +1 -1
  4. package/agents/test-engineer.md +1 -1
  5. package/agents/verifier.md +1 -1
  6. package/dist/index.mjs +4451 -4092
  7. package/package.json +12 -8
  8. package/scripts/analyze-run.mjs +1333 -0
  9. package/scripts/resource-sampler.mjs +482 -0
  10. package/skills/real-test-pi-crew/SKILL.md +10 -9
  11. package/src/agents/agent-config.ts +35 -14
  12. package/src/config/role-tools.ts +2 -2
  13. package/src/extension/knowledge-injection.ts +17 -0
  14. package/src/extension/pi-api.ts +0 -16
  15. package/src/extension/team-tool/api/agent-control.ts +358 -0
  16. package/src/extension/team-tool/api/handler-context.ts +57 -0
  17. package/src/extension/team-tool/api/heartbeat.ts +75 -0
  18. package/src/extension/team-tool/api/mailbox.ts +242 -0
  19. package/src/extension/team-tool/api/plan-approval.ts +190 -0
  20. package/src/extension/team-tool/api/read.ts +443 -0
  21. package/src/extension/team-tool/api/task-claims.ts +207 -0
  22. package/src/extension/team-tool/api.ts +56 -1301
  23. package/src/extension/team-tool/cancel.ts +15 -4
  24. package/src/extension/team-tool/goal-wrap.ts +2 -2
  25. package/src/extension/team-tool/goal.ts +4 -4
  26. package/src/extension/team-tool/lifecycle-actions.ts +5 -5
  27. package/src/extension/team-tool/parallel-dispatch.ts +2 -2
  28. package/src/extension/team-tool/respond.ts +11 -3
  29. package/src/extension/team-tool/run-intent.ts +357 -0
  30. package/src/extension/team-tool/run.ts +8 -285
  31. package/src/extension/team-tool/status.ts +56 -21
  32. package/src/extension/team-tool.ts +10 -8
  33. package/src/prompt/scratchpad-lifecycle.ts +80 -5
  34. package/src/runtime/child-pi/child-pi-spawn.ts +13 -7
  35. package/src/runtime/child-pi/child-pi.ts +22 -144
  36. package/src/runtime/child-pi/mock-fixtures.ts +171 -0
  37. package/src/runtime/crew-agent-records.ts +18 -1
  38. package/src/runtime/scratchpad/README.md +11 -0
  39. package/src/runtime/scratchpad/guest.ts +157 -7
  40. package/src/runtime/scratchpad/protocol.ts +13 -1
  41. package/src/runtime/scratchpad/transform.ts +206 -12
  42. package/src/runtime/supervisor-contact.ts +0 -16
  43. package/src/runtime/task-runner/child-executor.ts +1 -0
  44. package/src/runtime/task-runner/state-helpers.ts +9 -1
  45. package/src/runtime/team-runner.ts +39 -2
  46. package/src/state/contracts.ts +3 -0
  47. package/src/state/event-log/event-log.ts +19 -27
  48. package/src/state/gitignore-manager.ts +61 -7
  49. package/src/utils/glob-match.ts +29 -0
  50. package/types/dwf.d.ts +1 -1
  51. package/src/runtime/scratchpad/snapshot-hmac.ts +0 -161
  52. package/src/types/new-api-types.ts +0 -35
package/CHANGELOG.md CHANGED
@@ -2,6 +2,115 @@
2
2
 
3
3
  > **Note:** `atomic-write-v2.ts` / `AtomicWriter` mentioned in historical entries below was consolidated into `atomic-write.ts` as of v0.9.42. This changelog is preserved as historical record — the migration was completed (the v2 class was never adopted; v1 won on simplicity + symlink-safety + link+unlink atomicity). See `docs/migration/atomic-write-v2-migration.md` for the decision rationale.
4
4
 
5
+ ## [0.9.68] — RLM fixes after deep-review verification (2026-08-12)
6
+
7
+ Fixes from `docs/rlm-deep-review-2026-08-12.md` (verified) +
8
+ `docs/rlm-fixes-implementation-plan.md`. Each code part loop-reviewed (3
9
+ parallel reviewers: security/correctness/tests, read-only) before merge here.
10
+
11
+ ### Fixes
12
+ - **P1 — global shadow poisoning** (`src/runtime/scratchpad/guest.ts`):
13
+ `PROTECTED_GLOBALS` + `resetProtectedGlobals()` register live Node globals
14
+ into the namespace/`INTERNAL_BINDINGS`. Closes both poisoning paths: restore
15
+ (re-install overwrites revived shadow) and in-session (reset at cell start —
16
+ shadow stays local to the cell that created it). Silent corruption (e.g.
17
+ `const process='x'` making `process.env` undefined) is gone. 8 regression
18
+ tests in `test/unit/runtime/scratchpad/guest-global-shadow.test.ts`.
19
+ - **P2 — scratchpad adoption lever** (`src/agents/agent-config.ts`): new
20
+ `PI_CREW_SCRATCHPAD_DEMOTE_BASH=1` flag. When on + a role has scratchpad
21
+ enabled, `resolveToolPolicy` removes `bash` (allowlist filter + denylist add)
22
+ so the model reaches for the `sh()` binding instead — the documented root
23
+ cause of 0 adoption. Default off (zero behavior change); scoped to
24
+ scratchpad-armed roles (executor/verifier/test-engineer) via
25
+ `isScratchpadEnabledForRole` (S-6 read-only gate + F6 kill-switch honored).
26
+ 10 tests in `test/unit/scratchpad-demote-bash.test.ts`.
27
+ - **P4 — host_request protocol doc** (`src/runtime/scratchpad/protocol.ts`):
28
+ the `host_request` type is now documented as reserved for the future host
29
+ bridge (§5.2F), not yet wired (no handler).
30
+ - **P5 — version drift** (`package.json`): 4 pi devDeps `^0.83.0` → `^0.84.0`
31
+ (installed runtime is 0.84.1).
32
+ - **P6 — scratchpad stack-trace sourcemap** (`src/runtime/scratchpad/transform.ts`
33
+ + `guest.ts`): `transformCell` now returns a `lineMap` (body line → source
34
+ line) built from esbuild `sourcemap:'inline'` + a hand-rolled VLQ decoder
35
+ (no dependency) + import pre-rewrite tracking + splice line counting. Guest
36
+ `remapStackLines` remaps the V8 `<anonymous>:N` frame back to the cell's
37
+ original source line. Only real ` at ` frames are remapped (a crafted
38
+ error message containing `<anonymous>:N:C)` is left byte-identical). Known
39
+ cosmetic limitation: multi-line type annotations map to the esbuild collapse
40
+ point. 10 tests in `test/unit/runtime/scratchpad/scratchpad-sourcemap.test.ts`.
41
+
42
+ ### Removed
43
+ - **P3 — dead HMAC crypto deleted.** `src/runtime/scratchpad/snapshot-hmac.ts`
44
+ (167 lines, 11 tests) + its test file removed. The threat it mitigated
45
+ (v8.deserialize tamper) is double-conditional (0 scratchpad adoption +
46
+ same-uid store both hold today); wiring (ROADMAP R1-4) was premature and
47
+ blocked on 3 unresolved design questions. ADR Superseded; design retained
48
+ for clean re-add if conditions ever hold. ROADMAP R1-4 / R2-2 marked removed.
49
+
50
+ ### Deferred (needs design)
51
+ - *None remaining.* (P6 was the last deferred item; it shipped — see Fixes.)
52
+
53
+ ## [0.9.67] — RLM/scratchpad adoption batch (I1–I7) (2026-08-11)
54
+
55
+ First shippable slice of `improvement-plan-2026-08-11.md` — the scratchpad was
56
+ armed-but-unused (0 cells in 14 runs); this batch fixes the doctrine, adds an
57
+ adoption/value metric, and ports the pattern-12 shell guard. Each item was
58
+ loop-reviewed (iterative-audit) before commit; `test:critical` 101/0, 129
59
+ scratchpad tests, `tsc`/biome clean.
60
+
61
+ ### Fixes
62
+ - **Doctrine truthfulness (I1–I2)** (`src/prompt/scratchpad-lifecycle.ts`):
63
+ removed the "await expressions" bullet that advertised a tools bridge that
64
+ does not exist (pattern-22 "silence is cheaper"); replaced the foreign
65
+ `<rlm_engine_reset>` marker with the real `[scratchpad]` restore-notice prefix,
66
+ keeping the I6-pairing "especially inside shell commands" clause. New pins in
67
+ `test/unit/scratchpad-lifecycle.test.ts` (no absent-binding ads, no foreign
68
+ marker, real prefix taught).
69
+ - **English model-facing surface (I3)**: `description` + `promptSnippet`
70
+ translated from Vietnamese to English (model-facing channel only; human docs
71
+ stay Vietnamese). Pin asserts no non-ASCII prose.
72
+ - **Worked example + when-to-prefer rule (I4)**: 7th doctrine bullet shows a
73
+ two-cell `await import('node:fs')` example with `const failures` persisting
74
+ across cells, a prefer-scratchpad-over-bash rule, the "bash is cheaper for
75
+ one-shot" negative rule, and a "keep namespace values small" caveat. Perf
76
+ metric re-recorded: doctrine=299, delta=310 est-tokens (under the ~350
77
+ budget).
78
+ - **Adoption/value metric (I5)**: fire-and-forget `scratchpad.cell` (per cell:
79
+ status/durationMs/codeLength/resultBytes) and `scratchpad.restored`
80
+ (attempt/restoredCount/failedCount/status, incl. restore-throw) events, threaded
81
+ via new `PI_CREW_EVENTS_PATH` env + runId (now set unconditionally, uncoupled
82
+ from the broker gate). Both literals registered in `TEAM_EVENT_TYPES`; a
83
+ non-zero `## Scratchpad` section is reported in `summary.md` (silent when
84
+ unused). DI-seam failing-writer test added.
85
+ - **Pattern-12 shell guard (I6)** (`src/runtime/scratchpad/guest.ts`): guest-local
86
+ `sh(cmd, args[])` refuses null/empty args before spawn (the `rm -rf undefined`
87
+ class bug), runs `execFile(shell:false, args array)`, returns
88
+ `{ exitCode, stdout, stderr }` (non-zero does not throw). Registered in
89
+ `INTERNAL_BINDINGS` + namespace (identity skip excludes it from snapshots);
90
+ re-installed after restore. Advisory guard only — cells run at full worker
91
+ trust (no VM sandbox). 5 new guest tests.
92
+ - **NOT WIRED banners (I7)**: `snapshot-hmac.ts` marked unmissably NOT WIRED
93
+ (module + test header + README threat-model cross-ref) pending the J1
94
+ wire-or-delete decision.
95
+
96
+ ### Verified
97
+ - `npm run test:critical`: 101/0; 19 scratchpad test files 129/129; `test:spike`
98
+ 12 pass/1 pre-existing skip.
99
+ - `npx tsc --noEmit`, biome lint + format clean; `check:event-types` 67
100
+ registered (2 new), drift unchanged at 72; `check:lazy-imports`
101
+ (LAZY marker on the doctrine example string), bundle-staleness/size OK.
102
+ - Bundle rebuilt (2.81 MB < 3.5 MB budget).
103
+ - Observation window for the §5 decision gate starts after this release
104
+ (scratchpad.cell counts now visible in run state + summary.md).
105
+
106
+ ### CI regression fixes (same release)
107
+ - **Untracked api/ modules committed** (`src/extension/team-tool/api/*`, `run-intent.ts`, `src/utils/glob-match.ts`, `src/runtime/child-pi/mock-fixtures.ts`): the 08-10 batch staged only tracked files; CI typecheck failed `Cannot find module './api/*.ts'`. Fixed by committing the 10 missing source files.
108
+ - **Sync appendEvent restored in extracted api/ handlers** (`team-tool/api/{agent-control,mailbox,heartbeat,plan-approval}.ts` + `team-tool/status.ts`): the H3 extract silently changed 11 sync `appendEvent` → fire-and-forget `appendEventAsync`, breaking byte-identical behavior and racing integration tests (status/ack/nudge events missed when read immediately after the call). Reverted to sync `appendEvent`; integration 188/0 (was 3 fails), unit 7121/0.
109
+ - **removeCrewAgent test fixed** for H2 coalesced non-terminal status writes (use a terminal record).
110
+
111
+ ### Verified (CI)
112
+ - GitHub Actions: ubuntu + windows + macOS all green (run `31556762231`).
113
+
5
114
  ## [0.9.66] — real-test findings: cross-project run lookup, output validation, config no-op-write, retry clarity, cron grammar (2026-08-10)
6
115
 
7
116
  Six fixes distilled from the `real-test-pi-crew` 9-tier battery (run 2026-08-10). All verified live end-to-end; `npm run test:critical` 101/101, `npx tsc --noEmit` exit 0, biome lint+format clean.
package/README.md CHANGED
@@ -271,7 +271,7 @@ The guidance is available in three places agents see:
271
271
 
272
272
  ### How to silence the advisory
273
273
 
274
- The advisory is **informational only** — there is no `force:true` flag needed (the run proceeds regardless). If you want to silence the `console.warn` output for cleaner logs, set `PI_CREW_QUIET_PREFLIGHT=1` in your environment.
274
+ The advisory is **informational only** — there is no `force:true` flag needed (the run proceeds regardless).
275
275
 
276
276
  ### Implementation
277
277
 
@@ -827,7 +827,7 @@ This is pi-crew's cliff-resilient mode: the workflow definitions, phase structur
827
827
  { "action": "auto-summarize" }
828
828
  ```
829
829
 
830
- 📖 Full actions reference (40+ actions): [docs/actions-reference.md](docs/actions-reference.md)
830
+ 📖 Full actions reference (54 schema actions across 5 domain dispatchers: run/status/control/manage/automate): [docs/actions-reference.md](docs/actions-reference.md)
831
831
 
832
832
  ---
833
833
 
@@ -911,7 +911,6 @@ Your system prompt here.
911
911
  |----------|---------|
912
912
  | `PI_CREW_BROKER=0` | **Disable the inter-pi broker entirely** (always wins over config). Use to opt out of cross-session messaging. |
913
913
  | `PI_CREW_BROKER=1` | Explicitly enable the broker (redundant under the v0.9.47 default-on; useful for overriding a config `broker.enabled: false`). |
914
- | `PI_CREW_BROKER_DIAG_UI=1` | Make the run-dashboard `handleInput` emit a `[PI-CREW-DIAG]` line to stderr per keystroke — for TUI keybinding probes. |
915
914
  | `PI_CREW_USE_BUNDLE=1` | Force-load via bundled `dist/index.mjs` (~19% faster cold-start than strip-types). Default: bundle (since v0.9.17). Set `PI_CREW_USE_BUNDLE=0` to force strip-types fallback. Requires `npm run build:bundle` to have produced `dist/`. |
916
915
  | `PI_CREW_EXECUTE_WORKERS=0` | Disable child workers (scaffold mode) |
917
916
  | `PI_TEAMS_EXECUTE_WORKERS=0` | Legacy disable flag |
@@ -5,7 +5,7 @@ model: false
5
5
  systemPromptMode: replace
6
6
  inheritProjectContext: true
7
7
  inheritSkills: false
8
- tools: read, grep, find, ls, bash, edit, write
8
+ tools: read, grep, find, ls, bash, edit, write, scratchpad
9
9
  ---
10
10
 
11
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.
@@ -5,7 +5,7 @@ model: false
5
5
  systemPromptMode: replace
6
6
  inheritProjectContext: true
7
7
  inheritSkills: false
8
- tools: read, edit, write, bash, ls
8
+ tools: read, edit, write, bash, ls, scratchpad
9
9
  ---
10
10
 
11
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.
@@ -5,7 +5,7 @@ model: false
5
5
  systemPromptMode: replace
6
6
  inheritProjectContext: true
7
7
  inheritSkills: false
8
- tools: read, grep, find, ls, bash
8
+ tools: read, grep, find, ls, bash, scratchpad
9
9
  maxTurns: 15
10
10
  ---
11
11