pi-legion 0.0.0-stage → 0.16.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.
- package/CONTRIBUTING.md +110 -0
- package/LICENSE +21 -0
- package/README.md +714 -2
- package/agents/advisor.md +108 -0
- package/agents/designer.md +87 -0
- package/agents/planner.md +54 -0
- package/agents/prototype.md +72 -0
- package/agents/reviewer.md +78 -0
- package/agents/scout.md +52 -0
- package/agents/worker.md +59 -0
- package/docs/design.md +1267 -0
- package/index.ts +1660 -0
- package/package.json +86 -4
- package/skills/pi-legion/SKILL.md +120 -0
- package/src/agents/agents.ts +747 -0
- package/src/agents/context.ts +118 -0
- package/src/agents/frontmatter.ts +237 -0
- package/src/agents/model-resolution.ts +161 -0
- package/src/agents/model-scope.ts +176 -0
- package/src/agents/overrides.ts +147 -0
- package/src/agents/paths.ts +21 -0
- package/src/agents/presets.ts +237 -0
- package/src/agents/settings.ts +545 -0
- package/src/agents/step-model.ts +153 -0
- package/src/agents/teams.ts +101 -0
- package/src/api.ts +312 -0
- package/src/extension/blocked.ts +52 -0
- package/src/extension/budget.ts +63 -0
- package/src/extension/child-guard.ts +323 -0
- package/src/extension/join.ts +230 -0
- package/src/extension/notice-renderer.ts +72 -0
- package/src/extension/notify.ts +408 -0
- package/src/extension/parent-label.ts +115 -0
- package/src/extension/playbook.ts +113 -0
- package/src/extension/recycle.ts +28 -0
- package/src/extension/runtime.ts +640 -0
- package/src/extension/slash.ts +1030 -0
- package/src/extension/summary.ts +813 -0
- package/src/herdr/client.ts +693 -0
- package/src/herdr/runner.ts +88 -0
- package/src/profiles/classify.ts +375 -0
- package/src/profiles/profiles.ts +730 -0
- package/src/runs/acceptance.ts +164 -0
- package/src/runs/args.ts +224 -0
- package/src/runs/kind.ts +260 -0
- package/src/runs/layout.ts +258 -0
- package/src/runs/orchestrator.ts +2038 -0
- package/src/runs/store.ts +544 -0
- package/src/runs/worktree.ts +125 -0
- package/src/shared/cursor-chat.ts +348 -0
- package/src/shared/name.ts +49 -0
- package/src/shared/nested-path.ts +80 -0
- package/src/shared/progress.ts +175 -0
- package/src/shared/session.ts +697 -0
- package/src/shared/types.ts +811 -0
- package/src/tui/status.ts +319 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
This package is a Pi extension. The public surface is `index.ts` (the
|
|
4
|
+
`subagent` tool) plus `src/api.ts` (programmatic imports). Please keep those
|
|
5
|
+
two as the only things a downstream should need.
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/zzjcool/pi-legion.git
|
|
11
|
+
cd pi-legion
|
|
12
|
+
npm install
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires Node.js 22+ (`node --experimental-strip-types` is how tests run;
|
|
16
|
+
there is no compile step to ship).
|
|
17
|
+
|
|
18
|
+
## Checks
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm run typecheck
|
|
22
|
+
npm test # test/unit/*.test.ts
|
|
23
|
+
npm run test:integration # fake herdr, no live binary
|
|
24
|
+
npm run test:all # typecheck + unit + integration
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`npm run test:live` talks to a real herdr. It skips itself unless `HERDR_ENV=1`
|
|
28
|
+
and `herdr` is on `PATH`. Do not fail CI on it.
|
|
29
|
+
|
|
30
|
+
Prefer **TDD** for behaviour changes: a failing test in `test/unit` or
|
|
31
|
+
`test/integration` first, then the production code. Integration tests should
|
|
32
|
+
go through `createHerdrClient(createFakeRunner(fake))` so argv construction
|
|
33
|
+
and JSON parsing stay covered.
|
|
34
|
+
|
|
35
|
+
## Docker verification
|
|
36
|
+
|
|
37
|
+
`test/docker/` runs the package inside `pi-herdr-sandbox:latest` with a copy
|
|
38
|
+
of the **host** Pi config (`~/.pi/agent/settings.json`, `models.json`,
|
|
39
|
+
`auth.json` if present). The copy is disposable (`/tmp/pi-herdr-docker-home`
|
|
40
|
+
by default); the container cannot write back to your real `~/.pi`.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# image must already exist
|
|
44
|
+
docker image inspect pi-herdr-sandbox:latest >/dev/null
|
|
45
|
+
|
|
46
|
+
bash test/docker/verify-1-child-guard.sh # child herdr interceptor
|
|
47
|
+
bash test/docker/verify-2-task-appendix.sh # frozen task appendix
|
|
48
|
+
bash test/docker/verify-3-readonly.sh # read-only bash denylist
|
|
49
|
+
bash test/docker/verify-4-acceptance.sh # collect → verified
|
|
50
|
+
bash test/docker/verify-5-blocked.sh # onBlocked forward
|
|
51
|
+
bash test/docker/verify-6-cache.sh # collect cache / retire no-op
|
|
52
|
+
bash test/docker/verify-7-budget.sh # tool/turn budget + bash timeout
|
|
53
|
+
bash test/docker/verify-8-verify-command.sh # criterion.command + timeout
|
|
54
|
+
bash test/docker/verify-9-worktree.sh # git worktree cwd
|
|
55
|
+
bash test/docker/verify-10-fallback.sh # fallbackModels
|
|
56
|
+
bash test/docker/verify-11-nested-alias.sh # nested + alias + completionGuard
|
|
57
|
+
bash test/docker/verify-12-workspace.sh # pi install + child pinned to parent Space
|
|
58
|
+
bash test/docker/verify-13-kinds.sh # kind/model matrix; live CodeBuddy when mounted
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or all at once:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm run test:docker
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`verify-13-kinds.sh` is **not** in `npm run test:docker`: it bind-mounts host
|
|
68
|
+
`codebuddy` / `cursor-agent` and (unless `LIVE_KIND_PROBES=0`) calls live
|
|
69
|
+
CodeBuddy. The numbered 1–12 scripts stay offline/mock.
|
|
70
|
+
|
|
71
|
+
Override paths with `HOST_PI_AGENT`, `DOCKER_PI_HOME`, `PI_DOCKER_IMAGE`.
|
|
72
|
+
|
|
73
|
+
Each `inside-N-*.sh` is what actually runs **in** the container. Keep those
|
|
74
|
+
scripts self-contained: they should still make sense if you `docker exec`
|
|
75
|
+
them by hand.
|
|
76
|
+
|
|
77
|
+
## Layout
|
|
78
|
+
|
|
79
|
+
| Path | Role |
|
|
80
|
+
| --- | --- |
|
|
81
|
+
| `index.ts` | Pi extension entry: parent tool + child-guard branch |
|
|
82
|
+
| `src/runs/orchestrator.ts` | launch / collect / retire |
|
|
83
|
+
| `src/extension/child-guard.ts` | child process interceptor + task appendix |
|
|
84
|
+
| `src/extension/budget.ts` | tool/turn/timeout env + bash wrap |
|
|
85
|
+
| `src/runs/worktree.ts` | `git worktree` isolation for `worktree: true` |
|
|
86
|
+
| `src/extension/runtime.ts` | status widget, watch, auto-recycle |
|
|
87
|
+
| `src/extension/blocked.ts` | `onBlocked` confirm / auto-approve / notify |
|
|
88
|
+
| `src/runs/acceptance.ts` | `verification-output` command |
|
|
89
|
+
| `agents/*.md` | bundled roles |
|
|
90
|
+
| `docs/design.md` | measured herdr findings (F1–F46) |
|
|
91
|
+
| `README.md` | what is actually wired today |
|
|
92
|
+
|
|
93
|
+
Do not import from `src/` in downstream packages — use
|
|
94
|
+
`pi-legion/api`. If a helper needs to be public, re-export
|
|
95
|
+
it there and add a test that imports from the API path.
|
|
96
|
+
|
|
97
|
+
## Agent definitions
|
|
98
|
+
|
|
99
|
+
A frontmatter key that is parsed but ignored is listed on
|
|
100
|
+
`subagent({ action: "list" })` as `⚠ not enforced yet`. If you start honouring
|
|
101
|
+
a field, **remove it from `UNENFORCED_FIELDS`** in `src/agents/agents.ts` in
|
|
102
|
+
the same change, and add a test that it is no longer reported.
|
|
103
|
+
|
|
104
|
+
## Style
|
|
105
|
+
|
|
106
|
+
- TypeScript strict, `noUncheckedIndexedAccess`
|
|
107
|
+
- Imports use the `.ts` extension
|
|
108
|
+
- Node stdlib only at runtime (plus `typebox` for the tool schema)
|
|
109
|
+
- No `git commit` / `git push` unless the maintainer asked for it in that
|
|
110
|
+
conversation
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zhijiezheng
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|