pi-legion 0.16.0 → 2.0.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 (89) hide show
  1. package/CONTRIBUTING.md +58 -0
  2. package/README.md +313 -640
  3. package/agents/advisor.md +7 -5
  4. package/agents/centurion.md +53 -0
  5. package/agents/designer.md +33 -33
  6. package/agents/planner.md +1 -2
  7. package/agents/prototype.md +2 -2
  8. package/agents/reviewer.md +67 -31
  9. package/agents/scout.md +6 -2
  10. package/agents/worker.md +12 -3
  11. package/docs/contracts/esc-abort-v1.md +131 -0
  12. package/docs/contracts/esc-cascade-v2.md +100 -0
  13. package/docs/design.md +44 -25
  14. package/docs/legion-v2-contract.md +461 -0
  15. package/docs/legion-v2-delivery.md +62 -0
  16. package/docs/retire-hardening-contract.md +125 -0
  17. package/docs/subagents-teams.md +76 -0
  18. package/docs/tui-viewer-contract.md +276 -0
  19. package/docs/vexillatio-contract.md +162 -0
  20. package/index.ts +1462 -286
  21. package/package.json +12 -9
  22. package/skills/pi-legion/SKILL.md +74 -96
  23. package/src/agents/agents.ts +6 -11
  24. package/src/agents/overrides.ts +2 -1
  25. package/src/agents/paths.ts +1 -1
  26. package/src/agents/settings.ts +268 -20
  27. package/src/api.ts +47 -48
  28. package/src/{herdr → backends/legacy}/client.ts +14 -69
  29. package/src/{shared → backends/legacy}/cursor-chat.ts +2 -2
  30. package/src/{herdr → backends/legacy}/runner.ts +22 -9
  31. package/src/backends/legacy/types.ts +138 -0
  32. package/src/extension/auto-doctor.ts +144 -0
  33. package/src/extension/budget.ts +2 -2
  34. package/src/extension/child-guard.ts +214 -201
  35. package/src/extension/event-bus.ts +263 -0
  36. package/src/extension/legion-commands.ts +719 -0
  37. package/src/extension/legion-doctor.ts +888 -0
  38. package/src/extension/legion-stop.ts +150 -0
  39. package/src/extension/legion-tools.ts +816 -0
  40. package/src/extension/notify.ts +24 -19
  41. package/src/extension/playbook.ts +20 -89
  42. package/src/extension/recycle.ts +2 -7
  43. package/src/extension/runtime.ts +655 -105
  44. package/src/extension/scout-guard.ts +483 -0
  45. package/src/extension/slash.ts +89 -438
  46. package/src/extension/spawn-hints.ts +79 -0
  47. package/src/extension/summary.ts +17 -58
  48. package/src/legion/budget.ts +165 -0
  49. package/src/legion/db.ts +242 -0
  50. package/src/legion/events.ts +150 -0
  51. package/src/legion/mail.ts +412 -0
  52. package/src/legion/nodes.ts +461 -0
  53. package/src/legion/rebuild.ts +533 -0
  54. package/src/legion/state-machine.ts +313 -0
  55. package/src/legion/usage.ts +101 -0
  56. package/src/runs/acceptance.ts +82 -25
  57. package/src/runs/args.ts +51 -5
  58. package/src/runs/hygiene.ts +335 -0
  59. package/src/runs/orchestrator.ts +790 -1683
  60. package/src/runs/owner.ts +61 -0
  61. package/src/runs/provision.ts +135 -0
  62. package/src/runs/store.ts +44 -17
  63. package/src/runs/verify-queue.ts +195 -0
  64. package/src/shared/name.ts +29 -0
  65. package/src/shared/output-cap.ts +57 -0
  66. package/src/shared/progress.ts +57 -135
  67. package/src/shared/session.ts +243 -171
  68. package/src/shared/types.ts +107 -208
  69. package/src/supervisor/child-memory.ts +140 -0
  70. package/src/supervisor/proc-tree.ts +103 -0
  71. package/src/supervisor/rpc-supervisor.ts +1033 -0
  72. package/src/supervisor/types.ts +153 -0
  73. package/src/supervisor/ui-proxy.ts +226 -0
  74. package/src/tui/chat-items.ts +330 -0
  75. package/src/tui/live-overlay.ts +874 -0
  76. package/src/tui/status.ts +553 -27
  77. package/src/tui/tree-view.ts +808 -0
  78. package/src/tui/viz/canvas.ts +119 -0
  79. package/src/tui/viz/layout.ts +111 -0
  80. package/src/tui/viz/model.ts +123 -0
  81. package/src/tui/viz/palette.ts +188 -0
  82. package/src/tui/viz/panels.ts +530 -0
  83. package/src/tui/viz/railway.ts +313 -0
  84. package/src/tui/viz/rate.ts +211 -0
  85. package/src/tui/viz/view.ts +228 -0
  86. package/src/extension/parent-label.ts +0 -115
  87. package/src/profiles/classify.ts +0 -375
  88. package/src/profiles/profiles.ts +0 -730
  89. package/src/runs/layout.ts +0 -258
package/CONTRIBUTING.md CHANGED
@@ -4,6 +4,48 @@ This package is a Pi extension. The public surface is `index.ts` (the
4
4
  `subagent` tool) plus `src/api.ts` (programmatic imports). Please keep those
5
5
  two as the only things a downstream should need.
6
6
 
7
+ ## Project workflow
8
+
9
+ **Issues first.** A bug or feature found while dogfooding starts as a GitHub
10
+ issue. Include a repro, the expected behaviour, the actual behaviour, and the
11
+ environment (Node version, OS, and the Pi / pi-legion version).
12
+
13
+ **One concern per pull request.** Link the issue. Open the PR as a draft.
14
+ Mark it **Ready for review** when the change is ready and you expect the
15
+ required check `ci` to pass.
16
+
17
+ **Merge gate.** Alice (the maintainer bot) merges only after code review has
18
+ passed and the required GitHub Actions check `ci` is green. Do not push
19
+ directly to `master`. Implementers do not merge their own pull requests.
20
+
21
+ **Before you push.** Run:
22
+
23
+ ```bash
24
+ npm run typecheck
25
+ npm test
26
+ ```
27
+
28
+ Add the unit tests the change needs. Prefer **TDD** (see [Checks](#checks)):
29
+ a failing test in `test/unit` or `test/integration` first, then the production
30
+ code.
31
+
32
+ **Regression tests.** When you fix a bug, add a unit or integration test in
33
+ the same PR when that is feasible: failing first, then passing. Do not
34
+ `unref()` a timer that must keep the Node test runner alive. `unref()` drops
35
+ the timer from the event-loop refcount, so `node --test` can exit before the
36
+ callback runs. That is the rpc-supervisor retire-timer lesson (`waitForExit`
37
+ and the descendant-sweep delay in `src/supervisor/rpc-supervisor.ts`): a
38
+ timeout the caller is awaiting stays referenced, as with the wait timer in
39
+ `src/extension/runtime.ts`.
40
+
41
+ **npm release.** A `v*.*.*` tag runs the release workflow
42
+ (`.github/workflows/release.yml`). Publish from that workflow with
43
+ `npm stage publish` and a stage-only token. A maintainer promotes the staged
44
+ version on npm with 2FA. Do not use plain `npm publish` in GitHub Actions.
45
+
46
+ **Communication.** Coordinate in the team channel, or with Alice. Do not ping
47
+ the maintainer user for a routine review or merge ask.
48
+
7
49
  ## Setup
8
50
 
9
51
  ```bash
@@ -32,6 +74,21 @@ Prefer **TDD** for behaviour changes: a failing test in `test/unit` or
32
74
  go through `createHerdrClient(createFakeRunner(fake))` so argv construction
33
75
  and JSON parsing stay covered.
34
76
 
77
+ ## Mock LLM
78
+
79
+ For offline Pi / legion smoke without provider quota, start the scriptable
80
+ OpenAI-compatible mock (see [`test/mock-llm/README.md`](test/mock-llm/README.md)):
81
+
82
+ ```bash
83
+ npm run mock-llm # default scenario=echo on :8765
84
+ npm run test:mock-llm # engine + HTTP + optional pi --print smoke
85
+ ```
86
+
87
+ `test/docker/mock-llm.mjs` launches the same CLI (default scenario `tool-once`
88
+ for legacy inside-*.sh). Point Pi at it with `writeMockPiHome({ baseUrl })` or
89
+ the `providers.mock` block in that README. Never commit real API keys; the
90
+ dummy key is always the literal `mock`.
91
+
35
92
  ## Docker verification
36
93
 
37
94
  `test/docker/` runs the package inside `pi-herdr-sandbox:latest` with a copy
@@ -86,6 +143,7 @@ them by hand.
86
143
  | `src/extension/runtime.ts` | status widget, watch, auto-recycle |
87
144
  | `src/extension/blocked.ts` | `onBlocked` confirm / auto-approve / notify |
88
145
  | `src/runs/acceptance.ts` | `verification-output` command |
146
+ | `test/mock-llm/` | Scriptable OpenAI mock for offline pi / legion |
89
147
  | `agents/*.md` | bundled roles |
90
148
  | `docs/design.md` | measured herdr findings (F1–F46) |
91
149
  | `README.md` | what is actually wired today |