pi-squad 0.6.5 → 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 +21 -3
- 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 +375 -212
- 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 +11 -20
- package/src/scheduler.ts +172 -95
- package/src/skills/squad-architecture/SKILL.md +53 -0
- package/src/skills/squad-backend-dev/SKILL.md +45 -0
- package/src/skills/squad-code-review/SKILL.md +89 -0
- package/src/skills/{collaboration → squad-collaboration}/SKILL.md +6 -2
- package/src/skills/squad-debugging/SKILL.md +61 -0
- package/src/skills/squad-frontend-dev/SKILL.md +51 -0
- package/src/skills/squad-protocol/SKILL.md +19 -0
- package/src/skills/squad-qa-testing/SKILL.md +72 -0
- package/src/skills/squad-security-audit/SKILL.md +43 -0
- package/src/skills/squad-supervisor/SKILL.md +85 -11
- package/src/skills/{verification → squad-verification}/SKILL.md +1 -1
- package/src/store.ts +24 -26
- package/src/types.ts +48 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: squad-frontend-dev
|
|
3
|
+
description: >
|
|
4
|
+
Frontend engineering practices — React patterns, CSS/Tailwind, accessibility,
|
|
5
|
+
state management, API integration, and responsive design. Use when building
|
|
6
|
+
UIs, web apps, or frontend components.
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Frontend Development
|
|
11
|
+
|
|
12
|
+
## React Patterns
|
|
13
|
+
- Use functional components with hooks (no class components)
|
|
14
|
+
- Extract reusable logic into custom hooks (useAuth, useFetch, useDebounce)
|
|
15
|
+
- Handle all UI states explicitly: loading, error, empty, success
|
|
16
|
+
- Use React.memo only for measured performance bottlenecks
|
|
17
|
+
- Prefer composition over prop drilling — use context for cross-cutting concerns
|
|
18
|
+
- Use controlled components for forms, validate before submit
|
|
19
|
+
|
|
20
|
+
## State Management
|
|
21
|
+
- Server state: use React Query / TanStack Query (caching, refetching, optimistic updates)
|
|
22
|
+
- Client state: use useState for local, useContext for shared, useReducer for complex
|
|
23
|
+
- URL state: use router params/search params for bookmarkable state
|
|
24
|
+
- Never duplicate server state in client state — let the query cache be the source of truth
|
|
25
|
+
|
|
26
|
+
## API Integration
|
|
27
|
+
- Create a typed API client module (don't scatter fetch calls across components)
|
|
28
|
+
- Handle 401 responses globally (refresh token, redirect to login)
|
|
29
|
+
- Show loading indicators for any request > 200ms
|
|
30
|
+
- Handle network errors gracefully (offline banner, retry button)
|
|
31
|
+
- Use optimistic updates for snappy UX (revert on error)
|
|
32
|
+
|
|
33
|
+
## CSS / Tailwind
|
|
34
|
+
- Use utility classes, avoid custom CSS when possible
|
|
35
|
+
- Follow the project's design tokens (colors, spacing, typography)
|
|
36
|
+
- Use responsive prefixes: sm:, md:, lg:, xl:
|
|
37
|
+
- Implement dark mode with dark: prefix when required
|
|
38
|
+
- Ensure consistent spacing scale (don't mix arbitrary values)
|
|
39
|
+
|
|
40
|
+
## Accessibility
|
|
41
|
+
- All interactive elements must be keyboard-navigable (tab, enter, escape)
|
|
42
|
+
- Use semantic HTML elements (button, nav, main, section, header, footer)
|
|
43
|
+
- Add aria-labels to icon-only buttons and non-text interactive elements
|
|
44
|
+
- Ensure color contrast meets WCAG AA (4.5:1 for normal text, 3:1 for large)
|
|
45
|
+
- Support screen readers: announce dynamic content changes with aria-live
|
|
46
|
+
|
|
47
|
+
## Build & Performance
|
|
48
|
+
- Verify the build completes without errors before claiming done
|
|
49
|
+
- Code-split routes (React.lazy + Suspense)
|
|
50
|
+
- Optimize images (lazy loading, proper sizing)
|
|
51
|
+
- Minimize bundle size (check for unnecessary dependencies)
|
|
@@ -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
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: squad-qa-testing
|
|
3
|
+
description: >
|
|
4
|
+
QA and testing practices — test strategy, checklist, evidence requirements,
|
|
5
|
+
verdict format, and rework flow. Use when verifying, testing, or reviewing
|
|
6
|
+
implementations.
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# QA & Testing
|
|
11
|
+
|
|
12
|
+
## Test Strategy
|
|
13
|
+
1. **Build verification**: Does the code compile/build without errors?
|
|
14
|
+
2. **Smoke test**: Does the app start and respond to basic requests?
|
|
15
|
+
3. **Functional tests**: Do all features work as specified?
|
|
16
|
+
4. **Edge cases**: Invalid inputs, empty states, boundary values
|
|
17
|
+
5. **Integration**: Do components work together (API ↔ frontend, auth flow)?
|
|
18
|
+
|
|
19
|
+
## Before You Start
|
|
20
|
+
- Read the task description and dependency outputs carefully
|
|
21
|
+
- Understand what was built before testing it
|
|
22
|
+
- Start the server/app and verify it's actually running
|
|
23
|
+
- Don't assume anything works — verify everything
|
|
24
|
+
|
|
25
|
+
## Testing Checklist
|
|
26
|
+
- [ ] App builds without errors (tsc, vite build, etc.)
|
|
27
|
+
- [ ] Server starts and responds to health check
|
|
28
|
+
- [ ] All CRUD operations work (create, read, update, delete)
|
|
29
|
+
- [ ] Authentication flow works (register, login, protected routes)
|
|
30
|
+
- [ ] Input validation rejects bad data (missing fields, wrong types)
|
|
31
|
+
- [ ] Error responses have correct HTTP status codes
|
|
32
|
+
- [ ] Frontend renders without console errors
|
|
33
|
+
- [ ] Navigation between pages works
|
|
34
|
+
- [ ] Forms submit correctly and show feedback
|
|
35
|
+
|
|
36
|
+
## Evidence Requirements
|
|
37
|
+
Every claim must have evidence. Don't just say "it works" — show it:
|
|
38
|
+
- **API tests**: Show curl commands and their responses
|
|
39
|
+
- **Build tests**: Show the build command output (exit code 0)
|
|
40
|
+
- **UI tests**: Describe what you see, or use screenshots
|
|
41
|
+
- **Error tests**: Show the error response for invalid input
|
|
42
|
+
|
|
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
|
+
|
|
49
|
+
```
|
|
50
|
+
## Verdict: PASS | FAIL | PASS WITH ISSUES
|
|
51
|
+
|
|
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
|
|
57
|
+
|
|
58
|
+
## Evidence
|
|
59
|
+
[test output, curl commands and responses, build output]
|
|
60
|
+
```
|
|
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
|
+
|
|
67
|
+
## Rework Flow
|
|
68
|
+
If issues are found:
|
|
69
|
+
1. Document each issue with severity, location, and reproduction steps
|
|
70
|
+
2. The squad system will create fix tasks automatically
|
|
71
|
+
3. You will re-test after fixes are applied
|
|
72
|
+
4. On re-test: verify ALL previous issues are fixed, not just the latest
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: squad-security-audit
|
|
3
|
+
description: >
|
|
4
|
+
Security audit checklist, vulnerability patterns, and remediation guidance.
|
|
5
|
+
Use when reviewing code for security issues, hardening an application,
|
|
6
|
+
or performing security verification.
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Security Audit
|
|
11
|
+
|
|
12
|
+
## Checklist
|
|
13
|
+
- [ ] No secrets in source code (API keys, passwords, tokens, connection strings)
|
|
14
|
+
- [ ] All user inputs validated and sanitized
|
|
15
|
+
- [ ] SQL injection prevention (parameterized queries, no string interpolation)
|
|
16
|
+
- [ ] XSS prevention (output encoding, CSP headers, no innerHTML with user data)
|
|
17
|
+
- [ ] Authentication on all protected endpoints
|
|
18
|
+
- [ ] Authorization checks (can THIS user perform THIS action on THIS resource?)
|
|
19
|
+
- [ ] Rate limiting on public endpoints (login, register, password reset)
|
|
20
|
+
- [ ] Secure headers configured (CORS, HSTS, X-Frame-Options, X-Content-Type-Options)
|
|
21
|
+
- [ ] File upload validation (type whitelist, size limits)
|
|
22
|
+
- [ ] Error messages don't leak internal details (stack traces, SQL errors, file paths)
|
|
23
|
+
- [ ] Passwords hashed with bcrypt (not MD5, SHA1, or plain text)
|
|
24
|
+
- [ ] JWT tokens validated on every request (signature, expiry, issuer)
|
|
25
|
+
- [ ] Sensitive data not logged (passwords, tokens, credit cards)
|
|
26
|
+
- [ ] Dependencies checked for known vulnerabilities (npm audit)
|
|
27
|
+
|
|
28
|
+
## Common Vulnerabilities
|
|
29
|
+
- **Broken Access Control**: Missing auth checks, IDOR (accessing other users' data by changing IDs)
|
|
30
|
+
- **Injection**: SQL, NoSQL, command injection via unsanitized inputs
|
|
31
|
+
- **Broken Auth**: Weak passwords allowed, no rate limiting on login, tokens never expire
|
|
32
|
+
- **Security Misconfiguration**: Default credentials, verbose error pages, unnecessary features enabled
|
|
33
|
+
- **Sensitive Data Exposure**: Secrets in client-side code, PII in logs, HTTP instead of HTTPS
|
|
34
|
+
|
|
35
|
+
## Reporting Format
|
|
36
|
+
```
|
|
37
|
+
## Security Finding: [Title]
|
|
38
|
+
**Severity**: Critical | High | Medium | Low
|
|
39
|
+
**Location**: [file:line or endpoint]
|
|
40
|
+
**Description**: What's wrong
|
|
41
|
+
**Impact**: What could happen if exploited
|
|
42
|
+
**Remediation**: How to fix it (specific code change)
|
|
43
|
+
```
|
|
@@ -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");
|
|
@@ -405,32 +429,6 @@ export function loadAllKnowledge(squadId: string): KnowledgeEntry[] {
|
|
|
405
429
|
].sort((a, b) => a.ts.localeCompare(b.ts));
|
|
406
430
|
}
|
|
407
431
|
|
|
408
|
-
// ============================================================================
|
|
409
|
-
// Overview Document (shared squad summary)
|
|
410
|
-
// ============================================================================
|
|
411
|
-
|
|
412
|
-
export function getOverviewPath(squadId: string): string {
|
|
413
|
-
return path.join(getSquadDir(squadId), "OVERVIEW.md");
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
export function loadOverview(squadId: string): string {
|
|
417
|
-
try {
|
|
418
|
-
return fs.readFileSync(getOverviewPath(squadId), "utf-8");
|
|
419
|
-
} catch {
|
|
420
|
-
return "";
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
export function appendOverview(squadId: string, section: string): void {
|
|
425
|
-
const filePath = getOverviewPath(squadId);
|
|
426
|
-
ensureDir(path.dirname(filePath));
|
|
427
|
-
const existing = loadOverview(squadId);
|
|
428
|
-
const content = existing
|
|
429
|
-
? existing.trimEnd() + "\n\n---\n\n" + section.trim() + "\n"
|
|
430
|
-
: section.trim() + "\n";
|
|
431
|
-
fs.writeFileSync(filePath, content, "utf-8");
|
|
432
|
-
}
|
|
433
|
-
|
|
434
432
|
// ============================================================================
|
|
435
433
|
// Rework Helpers
|
|
436
434
|
// ============================================================================
|
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
|
|