pi-crew 0.9.65 → 0.9.67

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 (54) hide show
  1. package/CHANGELOG.md +79 -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 +4526 -4100
  7. package/package.json +7 -4
  8. package/skills/real-test-pi-crew/SKILL.md +10 -9
  9. package/src/config/config.ts +19 -3
  10. package/src/config/role-tools.ts +2 -2
  11. package/src/config/types.ts +2 -0
  12. package/src/extension/knowledge-injection.ts +17 -0
  13. package/src/extension/pi-api.ts +0 -16
  14. package/src/extension/team-tool/api/agent-control.ts +358 -0
  15. package/src/extension/team-tool/api/handler-context.ts +57 -0
  16. package/src/extension/team-tool/api/heartbeat.ts +75 -0
  17. package/src/extension/team-tool/api/mailbox.ts +242 -0
  18. package/src/extension/team-tool/api/plan-approval.ts +190 -0
  19. package/src/extension/team-tool/api/read.ts +443 -0
  20. package/src/extension/team-tool/api/task-claims.ts +207 -0
  21. package/src/extension/team-tool/api.ts +56 -1301
  22. package/src/extension/team-tool/cancel.ts +49 -4
  23. package/src/extension/team-tool/dispatch/manage.ts +7 -4
  24. package/src/extension/team-tool/explain.ts +3 -1
  25. package/src/extension/team-tool/goal-wrap.ts +2 -2
  26. package/src/extension/team-tool/goal.ts +4 -4
  27. package/src/extension/team-tool/lifecycle-actions.ts +9 -6
  28. package/src/extension/team-tool/parallel-dispatch.ts +2 -2
  29. package/src/extension/team-tool/respond.ts +11 -3
  30. package/src/extension/team-tool/run-intent.ts +357 -0
  31. package/src/extension/team-tool/run.ts +8 -285
  32. package/src/extension/team-tool/status.ts +56 -21
  33. package/src/extension/team-tool-types.ts +2 -0
  34. package/src/extension/team-tool.ts +10 -8
  35. package/src/prompt/scratchpad-lifecycle.ts +80 -5
  36. package/src/runtime/child-pi/child-pi-spawn.ts +13 -7
  37. package/src/runtime/child-pi/child-pi.ts +22 -144
  38. package/src/runtime/child-pi/mock-fixtures.ts +171 -0
  39. package/src/runtime/crew-agent-records.ts +18 -1
  40. package/src/runtime/output/output-validator.ts +34 -6
  41. package/src/runtime/scheduling/scheduler.ts +67 -19
  42. package/src/runtime/scratchpad/README.md +6 -0
  43. package/src/runtime/scratchpad/guest.ts +54 -5
  44. package/src/runtime/scratchpad/snapshot-hmac.ts +7 -1
  45. package/src/runtime/supervisor-contact.ts +0 -16
  46. package/src/runtime/task-runner/child-executor.ts +1 -0
  47. package/src/runtime/task-runner/state-helpers.ts +9 -1
  48. package/src/runtime/team-runner.ts +39 -2
  49. package/src/state/contracts.ts +3 -0
  50. package/src/state/event-log/event-log.ts +19 -27
  51. package/src/state/gitignore-manager.ts +61 -7
  52. package/src/utils/glob-match.ts +29 -0
  53. package/types/dwf.d.ts +1 -1
  54. package/src/types/new-api-types.ts +0 -35
package/CHANGELOG.md CHANGED
@@ -2,6 +2,85 @@
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.67] — RLM/scratchpad adoption batch (I1–I7) (2026-08-11)
6
+
7
+ First shippable slice of `improvement-plan-2026-08-11.md` — the scratchpad was
8
+ armed-but-unused (0 cells in 14 runs); this batch fixes the doctrine, adds an
9
+ adoption/value metric, and ports the pattern-12 shell guard. Each item was
10
+ loop-reviewed (iterative-audit) before commit; `test:critical` 101/0, 129
11
+ scratchpad tests, `tsc`/biome clean.
12
+
13
+ ### Fixes
14
+ - **Doctrine truthfulness (I1–I2)** (`src/prompt/scratchpad-lifecycle.ts`):
15
+ removed the "await expressions" bullet that advertised a tools bridge that
16
+ does not exist (pattern-22 "silence is cheaper"); replaced the foreign
17
+ `<rlm_engine_reset>` marker with the real `[scratchpad]` restore-notice prefix,
18
+ keeping the I6-pairing "especially inside shell commands" clause. New pins in
19
+ `test/unit/scratchpad-lifecycle.test.ts` (no absent-binding ads, no foreign
20
+ marker, real prefix taught).
21
+ - **English model-facing surface (I3)**: `description` + `promptSnippet`
22
+ translated from Vietnamese to English (model-facing channel only; human docs
23
+ stay Vietnamese). Pin asserts no non-ASCII prose.
24
+ - **Worked example + when-to-prefer rule (I4)**: 7th doctrine bullet shows a
25
+ two-cell `await import('node:fs')` example with `const failures` persisting
26
+ across cells, a prefer-scratchpad-over-bash rule, the "bash is cheaper for
27
+ one-shot" negative rule, and a "keep namespace values small" caveat. Perf
28
+ metric re-recorded: doctrine=299, delta=310 est-tokens (under the ~350
29
+ budget).
30
+ - **Adoption/value metric (I5)**: fire-and-forget `scratchpad.cell` (per cell:
31
+ status/durationMs/codeLength/resultBytes) and `scratchpad.restored`
32
+ (attempt/restoredCount/failedCount/status, incl. restore-throw) events, threaded
33
+ via new `PI_CREW_EVENTS_PATH` env + runId (now set unconditionally, uncoupled
34
+ from the broker gate). Both literals registered in `TEAM_EVENT_TYPES`; a
35
+ non-zero `## Scratchpad` section is reported in `summary.md` (silent when
36
+ unused). DI-seam failing-writer test added.
37
+ - **Pattern-12 shell guard (I6)** (`src/runtime/scratchpad/guest.ts`): guest-local
38
+ `sh(cmd, args[])` refuses null/empty args before spawn (the `rm -rf undefined`
39
+ class bug), runs `execFile(shell:false, args array)`, returns
40
+ `{ exitCode, stdout, stderr }` (non-zero does not throw). Registered in
41
+ `INTERNAL_BINDINGS` + namespace (identity skip excludes it from snapshots);
42
+ re-installed after restore. Advisory guard only — cells run at full worker
43
+ trust (no VM sandbox). 5 new guest tests.
44
+ - **NOT WIRED banners (I7)**: `snapshot-hmac.ts` marked unmissably NOT WIRED
45
+ (module + test header + README threat-model cross-ref) pending the J1
46
+ wire-or-delete decision.
47
+
48
+ ### Verified
49
+ - `npm run test:critical`: 101/0; 19 scratchpad test files 129/129; `test:spike`
50
+ 12 pass/1 pre-existing skip.
51
+ - `npx tsc --noEmit`, biome lint + format clean; `check:event-types` 67
52
+ registered (2 new), drift unchanged at 72; `check:lazy-imports`
53
+ (LAZY marker on the doctrine example string), bundle-staleness/size OK.
54
+ - Bundle rebuilt (2.81 MB < 3.5 MB budget).
55
+ - Observation window for the §5 decision gate starts after this release
56
+ (scratchpad.cell counts now visible in run state + summary.md).
57
+
58
+ ### CI regression fixes (same release)
59
+ - **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.
60
+ - **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.
61
+ - **removeCrewAgent test fixed** for H2 coalesced non-terminal status writes (use a terminal record).
62
+
63
+ ### Verified (CI)
64
+ - GitHub Actions: ubuntu + windows + macOS all green (run `31556762231`).
65
+
66
+ ## [0.9.66] — real-test findings: cross-project run lookup, output validation, config no-op-write, retry clarity, cron grammar (2026-08-10)
67
+
68
+ 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.
69
+
70
+ ### Fixes
71
+ - **Cross-project run lookup** (`src/extension/team-tool/explain.ts`, `lifecycle-actions.ts`): `explain` and `worktrees` now resolve runs via `locateRunCwd` (the same cross-project resolver `status`/`cancel`/`inspect` use) instead of raw `ctx.cwd`. A run created with a nested `cwd` override is now reachable from the parent session root (previously "Run not found"). Finding #1.
72
+ - **Output validation accepts markdown** (`src/runtime/output/output-validator.ts`): `ROLE_PATTERN_DEFS` only matched the strict caveman format, so every task tripped `output_validation valid:false`. Each role pattern now also accepts markdown-structured handoffs (`## Handoff`, bullets, bold); structural-preservation checks and empty-output rejection are unchanged. Finding #2.
73
+ - **Config skip-write guard** (`src/config/config.ts`, `types.ts`): `action='config'` with an empty patch went through the write path (`parseConfig({})` yields a full default config → `shouldUpdate=true`) and rewrote `~/.pi/agent/pi-crew.json` on every read. Added a skip-if-unchanged guard (and a `written` flag) so a no-op patch leaves the file untouched. Finding #3.
74
+ - **Retry clarity for completed runs** (`src/extension/team-tool/cancel.ts`): `action='retry'` on a completed run acquired the run lock and surfaced a stale-lock error ("run.lock is locked by another operation"). A pre-lock terminal-status check now short-circuits to "already completed; retry only applies to failed/cancelled runs" before touching the lock. Finding #4.
75
+ - **Cron grammar** (`src/runtime/scheduling/scheduler.ts`): `nextCronDate`'s matcher rejected standard cron step values (`*/30`, `9-17/2`) and named tokens (`MON`, `JAN`), so `action='schedule cron='0 9 * * MON'` errored with "No next cron occurrence found". Rewritten as `cronFieldMatches` handling wildcard, single, range, list, step, and named DOW/month tokens. Cosmetic finding.
76
+ - **"Config unchanged" message** (`src/extension/team-tool-types.ts`, `dispatch/manage.ts`): the config action always said "Updated" even when the skip-write guard left the file untouched; now shows "Config unchanged (no effective changes)." when no write occurred. Cosmetic finding.
77
+
78
+ ### Verified
79
+ - `npm run test:critical`: 101/101 pass (default, `PI_CREW_BROKER=0`, `PI_CREW_BROKER=1`).
80
+ - `npx tsc --noEmit` exit 0; biome lint + format clean.
81
+ - Bundle md5 `a32223b037f35d8605fa3013e1d8a095` (~2857 KB).
82
+ - Full 9-tier `real-test-pi-crew` re-run (2026-08-10): all tiers green, all 6 fixes live-verified. Reports under `docs/real-test/reports/real-test-2026-08-10-full-9-tier*.md`.
83
+
5
84
  ## [0.9.65] — team-tool schema empty-string guard (budgetTotal) + effectiveness empty-result guard + skill drift fix (2026-08-10)
6
85
 
7
86
  ### Fixes
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