pi-squad 0.7.2 → 0.14.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/README.md +200 -318
- package/package.json +15 -2
- package/src/advisor.ts +145 -0
- package/src/agent-pool.ts +39 -15
- package/src/agents/_defaults/architect.json +8 -1
- package/src/agents/_defaults/backend.json +9 -1
- package/src/agents/_defaults/debugger.json +8 -1
- package/src/agents/_defaults/devops.json +9 -1
- package/src/agents/_defaults/docs.json +8 -1
- package/src/agents/_defaults/frontend.json +10 -1
- package/src/agents/_defaults/fullstack.json +8 -1
- package/src/agents/_defaults/planner.json +7 -1
- package/src/agents/_defaults/qa.json +8 -1
- package/src/agents/_defaults/researcher.json +8 -1
- package/src/agents/_defaults/reviewer.json +10 -0
- package/src/agents/_defaults/security.json +8 -1
- package/src/index.ts +365 -76
- package/src/monitor.ts +20 -7
- package/src/panel/message-view.ts +2 -2
- package/src/panel/squad-panel.ts +3 -3
- package/src/panel/squad-widget.ts +3 -3
- package/src/panel/task-list.ts +2 -2
- package/src/plan-rules.ts +134 -0
- package/src/planner.ts +18 -14
- package/src/protocol.ts +10 -2
- package/src/scheduler.ts +172 -9
- package/src/skills/squad-code-review/SKILL.md +89 -0
- package/src/skills/squad-collaboration/SKILL.md +5 -1
- package/src/skills/squad-debugging/SKILL.md +61 -0
- package/src/skills/squad-protocol/SKILL.md +19 -0
- package/src/skills/squad-qa-testing/SKILL.md +19 -8
- package/src/skills/squad-supervisor/SKILL.md +85 -11
- package/src/store.ts +24 -0
- package/src/types.ts +48 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: squad-code-review
|
|
3
|
+
description: >
|
|
4
|
+
Code review methodology — two-pass review (correctness/scope, then
|
|
5
|
+
over-engineering), surgical-change discipline, complexity findings with
|
|
6
|
+
delete/stdlib/native/yagni/shrink tags, machine-parsed verdicts. Use when
|
|
7
|
+
reviewing diffs, implementations, or pull requests.
|
|
8
|
+
version: 1.0.0
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Code Review
|
|
12
|
+
|
|
13
|
+
Two passes, in order. Findings from pass 1 gate the verdict; pass 2 findings
|
|
14
|
+
are usually non-blocking. Derived from the karpathy-guidelines and ponytail
|
|
15
|
+
review disciplines.
|
|
16
|
+
|
|
17
|
+
## Pass 1 — Correctness & Scope
|
|
18
|
+
|
|
19
|
+
**Every changed line must trace to the task.**
|
|
20
|
+
- Flag unrequested refactors, drive-by "improvements", formatting churn in
|
|
21
|
+
untouched code, and deleted code the task didn't ask to remove
|
|
22
|
+
- Orphan check: did the change leave now-unused imports/variables/functions
|
|
23
|
+
it created? (Pre-existing dead code is a mention, not a finding)
|
|
24
|
+
|
|
25
|
+
**Verify with evidence, not by reading.**
|
|
26
|
+
- Run the task's Verify criterion yourself (tests, build, curl). Your review
|
|
27
|
+
is only as strong as the commands you ran
|
|
28
|
+
- Reproduce at least one happy path and one failure path where practical
|
|
29
|
+
- If you can't run something, say so explicitly — don't imply you did
|
|
30
|
+
|
|
31
|
+
**Assumptions and interpretations.**
|
|
32
|
+
- If the implementation silently picked one of several readings of the task,
|
|
33
|
+
name the choice and whether it matches the task's Goal/Boundaries
|
|
34
|
+
- Check the task's Boundaries were respected (unchanged APIs, schemas, configs)
|
|
35
|
+
|
|
36
|
+
**Error handling in the right places.**
|
|
37
|
+
- Trust boundaries (user input, network, file I/O) must handle failure
|
|
38
|
+
- Impossible-scenario handling is noise — flag it in pass 2 as yagni
|
|
39
|
+
|
|
40
|
+
## Pass 2 — Complexity Hunt
|
|
41
|
+
|
|
42
|
+
Climb the ladder for each addition; stop at the first rung that holds:
|
|
43
|
+
need to exist? → already in codebase? → stdlib? → native platform? →
|
|
44
|
+
installed dep? → one line? → minimum that works.
|
|
45
|
+
|
|
46
|
+
One line per finding — location, what to cut, what replaces it:
|
|
47
|
+
|
|
48
|
+
- `delete:` dead code, unused flexibility, speculative feature → nothing
|
|
49
|
+
- `stdlib:` hand-rolled thing the standard library ships → name the function
|
|
50
|
+
- `native:` dep/code doing what the platform does → name the feature
|
|
51
|
+
- `yagni:` abstraction with one implementation, config nobody sets, layer with one caller
|
|
52
|
+
- `shrink:` same logic, fewer lines → show the shorter form
|
|
53
|
+
|
|
54
|
+
Example: `api.ts:L88: yagni: RepositoryFactory with one product. Inline it until a second exists.`
|
|
55
|
+
|
|
56
|
+
**Never flag as bloat**: trust-boundary validation, data-loss handling,
|
|
57
|
+
security, accessibility, or a minimal test. Lean is not careless.
|
|
58
|
+
|
|
59
|
+
If nothing to cut: `Lean already.` — don't invent findings to look thorough.
|
|
60
|
+
|
|
61
|
+
## Verdict (machine-parsed — REQUIRED)
|
|
62
|
+
|
|
63
|
+
End your final message with exactly:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
## Verdict: PASS | FAIL | PASS WITH ISSUES
|
|
67
|
+
|
|
68
|
+
## Issues
|
|
69
|
+
1. **[file:line]** (Critical/High/Medium/Low) description
|
|
70
|
+
- Expected: X
|
|
71
|
+
- Got: Y
|
|
72
|
+
- Fix: specific change
|
|
73
|
+
|
|
74
|
+
## Evidence
|
|
75
|
+
[commands run + output]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- **FAIL**: pass-1 problems (correctness, scope violations, broken Verify).
|
|
79
|
+
Creates a rework task — the fixer only sees your Issues section
|
|
80
|
+
- **PASS WITH ISSUES**: works and in-scope, but pass-2 cuts are worth making
|
|
81
|
+
- **PASS**: correct, in scope, lean. Say what you verified
|
|
82
|
+
- Severity: correctness/security → Critical/High; complexity → Medium/Low
|
|
83
|
+
- Do not rename the sections — `## Issues` is extracted verbatim as fix feedback
|
|
84
|
+
|
|
85
|
+
## You Don't Fix
|
|
86
|
+
|
|
87
|
+
You report; the squad routes fixes to the original agent. Applying fixes
|
|
88
|
+
yourself would bypass the rework loop and confuse file ownership. If a fix
|
|
89
|
+
is truly one character, still report it — with the exact edit in the Fix line.
|
|
@@ -22,10 +22,14 @@ Bad: "@backend FYI I'm working on the frontend" (no question, wastes their time)
|
|
|
22
22
|
Don't just post conclusions. Explain why you made a choice, so others can course-correct early.
|
|
23
23
|
"I chose RS256 over HS256 because the frontend needs to verify tokens without the signing secret"
|
|
24
24
|
|
|
25
|
-
## Admit uncertainty
|
|
25
|
+
## Admit uncertainty — flag gaps, never guess
|
|
26
26
|
If you're not sure about something, say so and ask.
|
|
27
27
|
"I'm not sure if this migration is backwards-compatible — @backend can you verify?"
|
|
28
28
|
|
|
29
|
+
When required information is missing from your task or dependency outputs, flag the gap
|
|
30
|
+
and ask — don't invent values, endpoints, or formats to fill it. A wrong guess propagates
|
|
31
|
+
to every dependent task; a question costs one message.
|
|
32
|
+
|
|
29
33
|
Better to ask than to silently introduce a breaking change.
|
|
30
34
|
|
|
31
35
|
## Respond when asked
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: squad-debugging
|
|
3
|
+
description: >
|
|
4
|
+
Debugging and rework discipline — reproduce-first workflow, hypothesis testing,
|
|
5
|
+
minimal fixes, regression tests. Use when fixing bugs, handling QA feedback,
|
|
6
|
+
working on rework/fix tasks, or investigating failures.
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Debugging & Rework
|
|
11
|
+
|
|
12
|
+
## The Iron Rule: Reproduce First
|
|
13
|
+
|
|
14
|
+
Never change code before you've seen the failure with your own eyes.
|
|
15
|
+
|
|
16
|
+
1. **REPRODUCE**: Run the failing test, repro steps, or command from the QA
|
|
17
|
+
feedback. Confirm you see the same failure. If you can't reproduce it,
|
|
18
|
+
say so explicitly — don't "fix" what you can't observe.
|
|
19
|
+
2. **LOCALIZE**: Read the error, stack trace, or diff. Form ONE hypothesis
|
|
20
|
+
about the cause. State it before changing anything.
|
|
21
|
+
3. **FIX**: Make the smallest change that addresses the hypothesized cause.
|
|
22
|
+
4. **VERIFY**: Re-run the exact reproduction from step 1 — it must now pass.
|
|
23
|
+
Then run the surrounding test suite to catch regressions.
|
|
24
|
+
5. **PROTECT**: Add a regression test if none exists for this failure mode.
|
|
25
|
+
|
|
26
|
+
## Hypothesis Discipline
|
|
27
|
+
|
|
28
|
+
- One hypothesis at a time. If the fix doesn't work, REVERT it before trying
|
|
29
|
+
the next hypothesis — never stack speculative changes
|
|
30
|
+
- If two hypotheses fail, stop and gather more evidence (add logging, isolate
|
|
31
|
+
with a minimal test case) instead of guessing a third time
|
|
32
|
+
- Distinguish "the symptom moved" from "the cause is fixed" — re-run the
|
|
33
|
+
ORIGINAL repro, not just your new test
|
|
34
|
+
|
|
35
|
+
## Rework Tasks (QA sent your work back)
|
|
36
|
+
|
|
37
|
+
- Fix ONLY the issues listed in the QA feedback — no rewrites, no opportunistic
|
|
38
|
+
refactoring, no unrelated improvements
|
|
39
|
+
- Reproduce each reported issue before touching code (the feedback includes
|
|
40
|
+
Expected/Got/Repro for each — use them)
|
|
41
|
+
- If a reported issue looks wrong or is not reproducible, say so explicitly
|
|
42
|
+
with evidence instead of silently skipping it
|
|
43
|
+
- Your completion message must show each issue → what changed → re-run evidence
|
|
44
|
+
|
|
45
|
+
## Common Traps
|
|
46
|
+
|
|
47
|
+
- **Fixing the test instead of the code** — only adjust a test when you can
|
|
48
|
+
argue the test itself was wrong, and say so
|
|
49
|
+
- **Shotgun debugging** — many small changes at once; you won't know which
|
|
50
|
+
one mattered and you'll introduce new breakage
|
|
51
|
+
- **Environment blame** — "works on my machine" requires evidence: show the
|
|
52
|
+
environment difference, don't assume it
|
|
53
|
+
- **Silent scope creep** — noticing other bugs is good; fixing them inside a
|
|
54
|
+
rework task is not. Mention them so the squad can create tasks
|
|
55
|
+
|
|
56
|
+
## Output Checklist
|
|
57
|
+
|
|
58
|
+
Your completion message must include:
|
|
59
|
+
1. Each issue: root cause (one sentence) + the fix (file:line)
|
|
60
|
+
2. Evidence: the original failing command now passing (actual output)
|
|
61
|
+
3. Regression scope: which suites you ran and their results
|
|
@@ -23,6 +23,17 @@ Messages from other agents and the human arrive as interruptions in your convers
|
|
|
23
23
|
They are prefixed with `[squad]`. Read them carefully, incorporate the information,
|
|
24
24
|
and continue your work. Don't ignore incoming messages.
|
|
25
25
|
|
|
26
|
+
### Advisor messages
|
|
27
|
+
If you appear stuck, a senior advisor model may review your situation. Its guidance
|
|
28
|
+
arrives as `[squad advisor]` with a verdict and numbered action items.
|
|
29
|
+
Execute the action items unless your evidence contradicts them — in that case,
|
|
30
|
+
state the conflict explicitly instead of silently ignoring the advice.
|
|
31
|
+
|
|
32
|
+
### Reading your task
|
|
33
|
+
Task descriptions are structured as: Goal (the outcome), Context (where to look),
|
|
34
|
+
Output (deliverable), Boundaries (what must NOT change), Verify (the command that
|
|
35
|
+
proves you're done). Honor the Boundaries; run the Verify command before claiming done.
|
|
36
|
+
|
|
26
37
|
### Completion
|
|
27
38
|
When you finish your task, clearly state your output in your last message.
|
|
28
39
|
Be specific about what you built, what files you changed, and how to verify it works.
|
|
@@ -63,3 +74,11 @@ The squad system monitors your activity and will intervene, but being explicit i
|
|
|
63
74
|
### Read before writing
|
|
64
75
|
Before modifying any file, read it first. Another agent may have changed it
|
|
65
76
|
since the last time you saw it.
|
|
77
|
+
|
|
78
|
+
### Boundaries
|
|
79
|
+
- If required information is missing or ambiguous, ask (@mention or escalate) —
|
|
80
|
+
flag gaps instead of guessing or inventing
|
|
81
|
+
- Keep changes minimal and within your task's scope — no unrequested refactors or polish
|
|
82
|
+
- Keep public APIs, schemas, and configs unchanged unless your task says otherwise
|
|
83
|
+
- Never take externally visible actions (git push, deploy, publish, send messages)
|
|
84
|
+
unless your task explicitly instructs it — prepare, don't ship
|
|
@@ -40,19 +40,30 @@ Every claim must have evidence. Don't just say "it works" — show it:
|
|
|
40
40
|
- **UI tests**: Describe what you see, or use screenshots
|
|
41
41
|
- **Error tests**: Show the error response for invalid input
|
|
42
42
|
|
|
43
|
-
## Verdict Format
|
|
43
|
+
## Verdict Format (machine-parsed — use EXACTLY this structure)
|
|
44
|
+
|
|
45
|
+
Your final message MUST end with this structure. The squad system parses the
|
|
46
|
+
`## Verdict:` line to decide pass/fail, and extracts the `## Issues` section
|
|
47
|
+
(exactly `## Issues`, two hashes) as feedback for the fixing agent:
|
|
48
|
+
|
|
44
49
|
```
|
|
45
|
-
## Verdict: PASS | FAIL
|
|
50
|
+
## Verdict: PASS | FAIL | PASS WITH ISSUES
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
## Issues
|
|
53
|
+
1. **[file:line or endpoint]** (Critical/High/Medium/Low) Description
|
|
54
|
+
- Expected: X
|
|
55
|
+
- Got: Y
|
|
56
|
+
- Repro: exact command or steps
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
[test output, curl commands,
|
|
58
|
+
## Evidence
|
|
59
|
+
[test output, curl commands and responses, build output]
|
|
54
60
|
```
|
|
55
61
|
|
|
62
|
+
- `FAIL` automatically creates a rework task for the original agent — it only
|
|
63
|
+
sees your `## Issues` section, so make every issue specific and reproducible
|
|
64
|
+
- `PASS WITH ISSUES` = working but with non-blocking concerns (listed under `## Issues`)
|
|
65
|
+
- Do NOT rename the sections (`### Issues Found` etc. breaks feedback extraction)
|
|
66
|
+
|
|
56
67
|
## Rework Flow
|
|
57
68
|
If issues are found:
|
|
58
69
|
1. Document each issue with severity, location, and reproduction steps
|
|
@@ -9,12 +9,52 @@ You are the supervisor of multi-agent squads. Agents work on decomposed tasks in
|
|
|
9
9
|
|
|
10
10
|
## Your Role
|
|
11
11
|
|
|
12
|
-
You are the bridge between the human and the squad
|
|
12
|
+
You are the bridge between the human and the squad, and you wear three hats:
|
|
13
|
+
- **Planner** — when you pass pre-defined `tasks` to the `squad` tool, you replace the planner agent. Follow the same rules it does (see "Acting as the Planner" below)
|
|
14
|
+
- **Supervisor** — monitor progress, handle escalations, relay instructions, steer agents
|
|
15
|
+
- **Reviewer** — when the squad completes, verify the work like a QA agent before reporting success to the user (see "Reviewing Completed Work" below)
|
|
16
|
+
|
|
17
|
+
You:
|
|
13
18
|
- Start squads for complex tasks (use the `squad` tool)
|
|
14
19
|
- Monitor progress and relay status to the user
|
|
15
20
|
- Handle escalations when agents get stuck
|
|
16
21
|
- Send instructions to agents on behalf of the user
|
|
17
|
-
-
|
|
22
|
+
- Review and verify results when the squad completes
|
|
23
|
+
|
|
24
|
+
## Acting as the Planner
|
|
25
|
+
|
|
26
|
+
Providing `tasks` yourself skips the planner agent — so you must apply its rules:
|
|
27
|
+
- 3-7 tasks is usually right — don't over-decompose
|
|
28
|
+
- Task IDs short kebab-case; dependencies reference IDs from the same plan; first task(s) have empty `depends`
|
|
29
|
+
- When tasks share an interface (API endpoints, schema, data formats), create a design/contract task FIRST and make consumers depend on it
|
|
30
|
+
- Include a final QA/verification task if there are user-facing changes
|
|
31
|
+
- Required work only — no optional polish
|
|
32
|
+
|
|
33
|
+
Plans are validated on submission: structural errors (unknown deps, cycles, duplicate IDs, no entry task) are rejected; rule violations come back as ⚠️ warnings in the tool response. **Act on the warnings** — fix them with `squad_modify` `add_task`, or note them for review time. Don't silently ignore them.
|
|
34
|
+
|
|
35
|
+
## Writing Good Task Descriptions
|
|
36
|
+
|
|
37
|
+
When you pass pre-defined `tasks` to the `squad` tool, structure each description with the parts that help (Goal / Context / Output / Boundaries / Verify):
|
|
38
|
+
- **Goal**: the outcome, stated first — not a step-by-step process
|
|
39
|
+
- **Context**: which files, contracts, or dependency outputs to read
|
|
40
|
+
- **Output**: the expected deliverable and format
|
|
41
|
+
- **Boundaries**: what must stay unchanged; what needs escalation instead of guessing
|
|
42
|
+
- **Verify**: the command or check that proves the task is done
|
|
43
|
+
|
|
44
|
+
Scope tasks to required work only. Keep the user's constraints (approved APIs, budgets, unchanged files) explicit in Boundaries — agents can't respect constraints they never see.
|
|
45
|
+
|
|
46
|
+
### Context inheritance (`inheritContext: true`)
|
|
47
|
+
|
|
48
|
+
Agents normally start fresh with only their task description + dependency outputs. Setting `inheritContext: true` on a task forks the current pi session, so the agent inherits this conversation's full context.
|
|
49
|
+
|
|
50
|
+
**Use it when** the task genuinely depends on the discussion — e.g. "implement the design we agreed on above", long requirement threads, or decisions scattered across the conversation that can't be restated briefly.
|
|
51
|
+
|
|
52
|
+
**Avoid it by default**:
|
|
53
|
+
- It's expensive — the agent pays the entire conversation history as input tokens on every turn
|
|
54
|
+
- It's auto-skipped when the estimated session size exceeds 50% of the agent model's context window (a smaller-context model gets NO inherited context, silently degrading to standard behavior — the skip is noted in the task's message log)
|
|
55
|
+
- A well-written task description (Goal/Context/Output/Boundaries/Verify) is usually better than raw history
|
|
56
|
+
|
|
57
|
+
**Rule of thumb**: restate the 3-5 key decisions in the task description first; reach for `inheritContext` only when that's impractical.
|
|
18
58
|
|
|
19
59
|
## When to Use Squad
|
|
20
60
|
|
|
@@ -29,17 +69,42 @@ You are the bridge between the human and the squad. You:
|
|
|
29
69
|
- Simple questions or explanations
|
|
30
70
|
- Tasks a single agent can finish in a few minutes
|
|
31
71
|
|
|
72
|
+
### Squad vs Fleet (when pi-fleet tools are available)
|
|
73
|
+
|
|
74
|
+
If `remote_spawn` / `remote_prompt` / `fleet_status` tools exist in your session, you also have **pi-fleet** (cross-device workers). Division of labor:
|
|
75
|
+
|
|
76
|
+
| Situation | Use |
|
|
77
|
+
|---|---|
|
|
78
|
+
| Parallel work inside THIS repo (agents share the working tree, coordinate on files) | **squad** |
|
|
79
|
+
| Work on another machine, OS, dev-env VM, or different repo; cost/blast-radius isolation | **fleet** (`remote_spawn` + `remote_prompt`) |
|
|
80
|
+
| Big feature locally + validation/deployment on a remote box | **both side by side** — each reports back to you push-based; review each with evidence |
|
|
81
|
+
| Repeated tasks on a remote repo | fleet with `fromBaseline` (warm context) |
|
|
82
|
+
|
|
83
|
+
Rules when combining:
|
|
84
|
+
- Both systems wake you automatically (squad events and `fleet-task-done`) — never poll either
|
|
85
|
+
- Remote work cannot share this repo's working tree: have fleet workers deliver branches/patches, and never assume squad agents can see remote files
|
|
86
|
+
- Review fleet results with `remote_diff`/`remote_read` (costs zero worker tokens) before `remote_accept`
|
|
87
|
+
- If pi-fleet is NOT installed, none of this applies — squad works fully standalone
|
|
88
|
+
|
|
32
89
|
## Monitoring a Running Squad
|
|
33
90
|
|
|
91
|
+
### Never poll — the squad reports to you
|
|
92
|
+
|
|
93
|
+
The `squad` tool is non-blocking and the squad system is **push-based**:
|
|
94
|
+
- **Completion, failure, and escalations wake you automatically** (as `[squad]` messages that trigger your turn)
|
|
95
|
+
- After starting a squad: report the plan to the user and **end your turn**
|
|
96
|
+
- While a squad runs: keep helping the user with other work, or stay idle
|
|
97
|
+
- **NEVER** call `squad_status` in a loop, sleep-wait between checks, or burn turns "monitoring" — that wastes tokens and blocks the user
|
|
98
|
+
|
|
34
99
|
### Passive monitoring (automatic)
|
|
35
100
|
The squad status is injected into your context via `<squad_status>` before each response.
|
|
36
101
|
Read it to stay aware of progress without needing to call tools.
|
|
37
102
|
|
|
38
103
|
### Active monitoring (on-demand)
|
|
39
|
-
Use `squad_status` when:
|
|
104
|
+
Use `squad_status` ONLY when:
|
|
40
105
|
- The user asks "how's the squad doing?"
|
|
41
|
-
- You
|
|
42
|
-
- You want to check a specific squad by ID
|
|
106
|
+
- You were just woken by a squad event and need detail beyond the message
|
|
107
|
+
- You want to check a specific squad by ID at the user's request
|
|
43
108
|
|
|
44
109
|
### What to tell the user
|
|
45
110
|
- Summarize in plain language: "2 of 4 tasks done, tests are running, docs waiting on API"
|
|
@@ -71,6 +136,13 @@ Keep messages **specific and actionable**:
|
|
|
71
136
|
- Good: "Use RS256 for JWT signing. The secret is in env var JWT_SECRET."
|
|
72
137
|
- Bad: "Figure out the auth approach."
|
|
73
138
|
|
|
139
|
+
### Steering a working agent
|
|
140
|
+
Send small, scoped corrections instead of restarting the task:
|
|
141
|
+
- Name exactly what to change and what to keep: "Change only the header component — keep the layout and routes as they are."
|
|
142
|
+
- Add missing information the moment you learn it — don't wait for the agent to get stuck
|
|
143
|
+
- If the user manually edited or reverted files the agent touched, tell the agent immediately so it doesn't overwrite the human's changes
|
|
144
|
+
- If an agent starts doing work that's no longer needed, narrow its scope via `squad_message` or stop it with `squad_modify` `cancel_task` — don't let it burn tokens on obsolete work
|
|
145
|
+
|
|
74
146
|
## Modifying a Running Squad
|
|
75
147
|
|
|
76
148
|
Use `squad_modify` when:
|
|
@@ -80,13 +152,14 @@ Use `squad_modify` when:
|
|
|
80
152
|
- **`pause`** / **`resume`**: Stop/restart the entire squad
|
|
81
153
|
- **`cancel`**: Abort everything (user changed their mind)
|
|
82
154
|
|
|
83
|
-
## After Squad Completes
|
|
155
|
+
## After Squad Completes — Reviewing Completed Work
|
|
84
156
|
|
|
85
|
-
When you receive `[squad] Squad completed
|
|
86
|
-
1.
|
|
87
|
-
2.
|
|
88
|
-
3.
|
|
89
|
-
4.
|
|
157
|
+
When you receive `[squad] Squad completed`, you are the last line of review. Do NOT just relay the summary:
|
|
158
|
+
1. **Check verdicts**: scan task outputs for QA verdicts (`## Verdict: PASS/FAIL/PASS WITH ISSUES`) and note any `PASS WITH ISSUES` minor issues
|
|
159
|
+
2. **Check evidence**: each task's output should include verification evidence (commands + results). If a task claimed done without evidence, run its Verify command yourself (build, test, curl — whatever the task description specified)
|
|
160
|
+
3. **Spot-check integration**: individual tasks passing doesn't guarantee the integrated result works — run the end-to-end check when one exists (app builds, server starts, main flow works)
|
|
161
|
+
4. **Report with evidence**: tell the user what was verified (with the commands/results), and explicitly flag anything unverified or concerning
|
|
162
|
+
5. Suggest next steps if applicable
|
|
90
163
|
|
|
91
164
|
Example:
|
|
92
165
|
> Squad finished all 4 tasks:
|
|
@@ -103,6 +176,7 @@ Example:
|
|
|
103
176
|
|---|---|
|
|
104
177
|
| User asks complex task | Start squad with `squad` tool |
|
|
105
178
|
| User asks "what's happening?" | Read `<squad_status>`, summarize |
|
|
179
|
+
| Squad is running, nothing to do | End your turn — squad events wake you; do NOT poll |
|
|
106
180
|
| Agent escalates | Triage → answer or ask user |
|
|
107
181
|
| User says "tell the backend agent to..." | `squad_message` to that agent |
|
|
108
182
|
| User says "add a task for..." | `squad_modify` with `add_task` |
|
package/src/store.ts
CHANGED
|
@@ -49,6 +49,30 @@ export function getGlobalAgentsDir(): string {
|
|
|
49
49
|
return path.join(SQUAD_HOME, "agents");
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Squad Settings (~/.pi/squad/settings.json)
|
|
54
|
+
// ============================================================================
|
|
55
|
+
|
|
56
|
+
import { DEFAULT_SQUAD_SETTINGS, type SquadSettings } from "./types.js";
|
|
57
|
+
|
|
58
|
+
export function getSquadSettingsPath(): string {
|
|
59
|
+
return path.join(SQUAD_HOME, "settings.json");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Load global squad settings, merged over defaults (advisor merged deep) */
|
|
63
|
+
export function loadSquadSettings(): SquadSettings {
|
|
64
|
+
const loaded = readJson<Partial<SquadSettings>>(getSquadSettingsPath());
|
|
65
|
+
return {
|
|
66
|
+
...DEFAULT_SQUAD_SETTINGS,
|
|
67
|
+
...(loaded || {}),
|
|
68
|
+
advisor: { ...DEFAULT_SQUAD_SETTINGS.advisor, ...(loaded?.advisor || {}) },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function saveSquadSettings(settings: SquadSettings): void {
|
|
73
|
+
writeJsonAtomic(getSquadSettingsPath(), settings);
|
|
74
|
+
}
|
|
75
|
+
|
|
52
76
|
/** Project-local agent directory (overrides global) */
|
|
53
77
|
export function getLocalAgentsDir(projectCwd: string): string {
|
|
54
78
|
return path.join(projectCwd, ".pi", "squad", "agents");
|
package/src/types.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface AgentDef {
|
|
|
11
11
|
description: string;
|
|
12
12
|
/** Override model (null = squad default or pi default) */
|
|
13
13
|
model: string | null;
|
|
14
|
+
/** Thinking level: off, minimal, low, medium, high, xhigh, max (null = pi default) */
|
|
15
|
+
thinking?: string | null;
|
|
14
16
|
/** Override tool list (null = all standard tools) */
|
|
15
17
|
tools: string[] | null;
|
|
16
18
|
/** Tags for planner's automatic agent matching */
|
|
@@ -24,8 +26,47 @@ export interface AgentDef {
|
|
|
24
26
|
/** Agent entry in squad.json — just overrides, references an AgentDef by key */
|
|
25
27
|
export interface SquadAgentEntry {
|
|
26
28
|
model?: string | null;
|
|
29
|
+
thinking?: string | null;
|
|
27
30
|
}
|
|
28
31
|
|
|
32
|
+
/** Valid thinking levels accepted by pi's --thinking flag */
|
|
33
|
+
export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const;
|
|
34
|
+
export type ThinkingLevel = (typeof THINKING_LEVELS)[number];
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Squad Settings (global, ~/.pi/squad/settings.json)
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Default model/thinking policy for agents whose def doesn't set one.
|
|
42
|
+
* - "main": follow the main pi session's current model / thinking level (default)
|
|
43
|
+
* - "pi-default": let the child pi process resolve its own configured default
|
|
44
|
+
* - any other string: an explicit model id (defaultModel) or thinking level (defaultThinking)
|
|
45
|
+
*/
|
|
46
|
+
export interface SquadSettings {
|
|
47
|
+
defaultModel: string;
|
|
48
|
+
defaultThinking: string;
|
|
49
|
+
advisor: {
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
model: string;
|
|
52
|
+
maxCallsPerTask: number;
|
|
53
|
+
maxTokens: number;
|
|
54
|
+
reasoning: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const DEFAULT_SQUAD_SETTINGS: SquadSettings = {
|
|
59
|
+
defaultModel: "main",
|
|
60
|
+
defaultThinking: "main",
|
|
61
|
+
advisor: {
|
|
62
|
+
enabled: true,
|
|
63
|
+
model: "main",
|
|
64
|
+
maxCallsPerTask: 2,
|
|
65
|
+
maxTokens: 8192,
|
|
66
|
+
reasoning: "medium",
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
29
70
|
// ============================================================================
|
|
30
71
|
// Squad
|
|
31
72
|
// ============================================================================
|
|
@@ -53,6 +94,8 @@ export interface Squad {
|
|
|
53
94
|
status: SquadStatus;
|
|
54
95
|
created: string;
|
|
55
96
|
cwd: string;
|
|
97
|
+
/** Session file of the pi session that created this squad (for inheritContext forks) */
|
|
98
|
+
sessionFile?: string | null;
|
|
56
99
|
/** Agent name → overrides. Keys must exist in .pi/squad/agents/ */
|
|
57
100
|
agents: Record<string, SquadAgentEntry>;
|
|
58
101
|
config: SquadConfig;
|
|
@@ -78,6 +121,9 @@ export interface Task {
|
|
|
78
121
|
agent: string;
|
|
79
122
|
status: TaskStatus;
|
|
80
123
|
depends: string[];
|
|
124
|
+
/** Fork the main pi session so this agent inherits the full conversation context.
|
|
125
|
+
* Skipped automatically if the estimated context exceeds 50% of the agent model's window. */
|
|
126
|
+
inheritContext?: boolean;
|
|
81
127
|
created: string;
|
|
82
128
|
started: string | null;
|
|
83
129
|
completed: string | null;
|
|
@@ -196,13 +242,14 @@ export interface SupervisorResult {
|
|
|
196
242
|
// ============================================================================
|
|
197
243
|
|
|
198
244
|
export interface PlannerOutput {
|
|
199
|
-
agents: Record<string, { model?: string }>;
|
|
245
|
+
agents: Record<string, { model?: string; thinking?: string }>;
|
|
200
246
|
tasks: Array<{
|
|
201
247
|
id: string;
|
|
202
248
|
title: string;
|
|
203
249
|
description: string;
|
|
204
250
|
agent: string;
|
|
205
251
|
depends: string[];
|
|
252
|
+
inheritContext?: boolean;
|
|
206
253
|
}>;
|
|
207
254
|
}
|
|
208
255
|
|