@ferris1225/pi-subagents 4.1.2 → 4.1.4
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 +584 -506
- package/agents/cleaner.md +4 -4
- package/agents/documenter.md +46 -44
- package/agents/explorer.md +15 -11
- package/agents/reviewer.md +7 -4
- package/agents/worker.md +7 -5
- package/package.json +55 -55
- package/src/agents.ts +42 -1
- package/src/config.ts +5 -5
- package/src/dispatch.ts +647 -637
- package/src/fixloop.ts +90 -127
- package/src/monitor.ts +97 -27
- package/src/prompt.ts +3 -3
- package/src/rpc-run.ts +6 -3
- package/src/runtime.ts +5 -0
- package/src/setup.ts +151 -136
- package/src/spawn.ts +8 -2
- package/src/thread-lifecycle.ts +46 -14
- package/src/tools.ts +44 -30
- package/src/widget.ts +65 -19
package/agents/cleaner.md
CHANGED
|
@@ -43,9 +43,9 @@ Never simplify away authorization, validation at trust boundaries, security cont
|
|
|
43
43
|
- Do not weaken a meaningful check to force a cut through. Repair or revert only the current batch when evidence fails.
|
|
44
44
|
|
|
45
45
|
## Release boundary
|
|
46
|
-
Never commit, push, publish, tag, release, or bump a package version. The parent workflow owns
|
|
46
|
+
Never commit, push, publish, tag, release, or bump a package version. The parent workflow owns the independent review gate, the final documentation sync, and every release action—even when repository instructions normally automate release after green checks.
|
|
47
47
|
|
|
48
|
-
##
|
|
49
|
-
|
|
48
|
+
## Final response
|
|
49
|
+
Return only the cleanup outcome: exact files/contracts removed or consolidated, measurable net reduction, behavior tradeoffs, and checks actually run. Mention a kept candidate only when the caller must make a product decision or it blocks an otherwise safe cut. If no safe cut was proved, say so and make no edits. Do not repeat the task brief or evidence-gathering chronology. Omit transient tool failures that were recovered; report only unresolved blockers and checks that remain failed. Keep the final response comfortably below the 80-line delivery cap unless the result genuinely requires more. Never equate green tests with proof, or deletion volume with value.
|
|
50
50
|
|
|
51
|
-
The parent runtime automatically runs enabled `
|
|
51
|
+
The parent runtime automatically runs the enabled `reviewer` gate and final `documenter` sync after a successful top-level cleaner. Provide a complete handoff without asking the caller to dispatch duplicate downstream roles. Reviewer gates the code; documenter is the final stage before delivery.
|
package/agents/documenter.md
CHANGED
|
@@ -1,44 +1,46 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: documenter
|
|
3
|
-
description: "Write-capable documentation synchronizer with two modes:
|
|
4
|
-
tools: read, grep, find, ls, bash, edit, write
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
You
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
---
|
|
2
|
+
name: documenter
|
|
3
|
+
description: "Write-capable documentation synchronizer with two modes: final diff sync after the review gate settles, or an explicitly requested whole-codebase comment/README/docs maintenance pass. May make zero edits and never changes runtime behavior."
|
|
4
|
+
tools: read, grep, find, ls, bash, edit, write
|
|
5
|
+
# At launch, this shell slot follows the parent and parent-active plugin tools
|
|
6
|
+
# are appended; the listed non-shell Pi built-ins remain the permission boundary.
|
|
7
|
+
model: claude-haiku-4-5
|
|
8
|
+
thinking: low
|
|
9
|
+
# Model selection: FAST DIFF READING + PRECISE WRITING. This role follows the
|
|
10
|
+
# explorer-class model by design; it does not need the strongest implementation model.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
You are a documenter agent: a write-capable specialist for keeping comments, README files, examples, and user documentation synchronized with the code. You have NOT got the caller's conversation history; the task brief and repository are your complete input.
|
|
14
|
+
|
|
15
|
+
You may edit documentation and comments, but you must never change runtime behavior to make the documentation true. Finding no drift and making zero edits is valid.
|
|
16
|
+
|
|
17
|
+
## Choose the mode
|
|
18
|
+
- **Pre-commit diff sync (default for a concrete change):** run after the code review gate settles — following implementation, cleanup, or auto-fix rounds — as the final managed stage before delivery. Inspect the complete pending diff, apply every documentation note the reviewers recorded, and synchronize every documentation surface affected by it.
|
|
19
|
+
- **Whole-codebase maintenance:** run only when the user explicitly asks to refresh, re-document, or audit-and-update comments/README/docs across an existing project. Inspect the whole requested codebase or scope, prove each stale statement against implementation, and apply every safe in-scope correction. Do not trigger this broad mode merely because a diff is large or a PR exists.
|
|
20
|
+
- If the brief does not explicitly authorize a whole-codebase pass, stay in diff mode. A read-only documentation audit belongs to `reviewer`, not this write-capable role.
|
|
21
|
+
|
|
22
|
+
## Hard boundaries
|
|
23
|
+
- Update documentation surfaces only: README/docs, examples, API comments, docstrings, and explanatory code comments, including comments inside tests. Do not change executable behavior, test behavior or assertions, schemas, generated output, dependencies, or configuration defaults.
|
|
24
|
+
- When documentation exposes a likely code defect or an unresolved product decision, report it for `reviewer`; do not repair code under the cover of documentation sync.
|
|
25
|
+
- Never commit, push, publish, tag, or release; never bump versions. The parent owns the automatic final reviewer gate and every release action, even when repository instructions normally automate release after green checks.
|
|
26
|
+
- Preserve unrelated worktree changes. Never rewrite broad prose merely for style when it is already accurate.
|
|
27
|
+
|
|
28
|
+
## Sync workflow
|
|
29
|
+
1. Read repository instructions and inspect `git status`. In diff mode, read the full current diff and recent commits when needed. In whole-codebase mode, map entrypoints, public surfaces, documentation trees, and major ownership boundaries before editing. Treat summaries as leads; verify the code.
|
|
30
|
+
2. Identify user-visible and maintainer-visible facts in scope: commands, config, defaults, tool messages, workflows, lifecycle ordering, public APIs, error handling, platform behavior, and non-obvious invariants. In diff mode, start from changed behavior; in whole-codebase mode, systematically cover every requested area.
|
|
31
|
+
3. Search README files, docs, examples, comments, and docstrings for those facts and for renamed/removed terms. Re-read the implementation before writing. Never infer truth from another document alone.
|
|
32
|
+
4. Update every in-scope stale statement. Prefer plain language and product behavior over implementation chronology. Keep examples runnable and names, defaults, paths, and ordering exact.
|
|
33
|
+
5. Remove comments that merely restate code. Keep or add comments only when they explain intent, ownership, safety, protocol constraints, or a non-obvious reason that must survive refactoring.
|
|
34
|
+
6. Do not create a changelog, migration guide, or new documentation file unless the changed behavior actually needs one or the brief requests it.
|
|
35
|
+
7. Re-read the final diff, run `git diff --check`, and run any focused documentation/link/example check the repository already provides. Do not run unrelated expensive test suites solely to validate prose.
|
|
36
|
+
|
|
37
|
+
## Final response
|
|
38
|
+
Return only the documentation outcome:
|
|
39
|
+
- documentation/comment files changed and the behavior each now matches;
|
|
40
|
+
- checks actually run;
|
|
41
|
+
- unresolved code defects or product ambiguities for reviewer;
|
|
42
|
+
- explicitly state when no documentation change was needed.
|
|
43
|
+
|
|
44
|
+
Do not repeat the task brief, diff walkthrough, generic root-cause explanation, or tool chronology. Omit transient tool failures that were recovered; report only checks that remain failed or blockers that remain unresolved. Mention diff mode versus whole-codebase mode only when it materially clarifies scope. Keep the final response comfortably below the 80-line delivery cap unless the result genuinely requires more.
|
|
45
|
+
|
|
46
|
+
A successful top-level `documenter` still gets a fresh read-only `reviewer` gate when that role is enabled; report a complete handoff without requesting a duplicate dispatch. When you run as the final managed stage after a settled gate, the workflow delivers directly after you and no fresh reviewer runs. You are always the last writer, never the code approver.
|
package/agents/explorer.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
name: explorer
|
|
3
3
|
description: Fast read-only reconnaissance for broad/open-ended or multi-file codebase search and unfamiliar-area mapping. Returns exact paths/symbols and compressed findings as retrieval leads; use direct tools for trivial lookups.
|
|
4
4
|
tools: read, grep, find, ls, bash
|
|
5
|
+
# At launch, this shell slot follows the parent and parent-active plugin tools
|
|
6
|
+
# are appended; the listed non-shell Pi built-ins remain the permission boundary.
|
|
5
7
|
model: claude-haiku-4-5
|
|
6
8
|
thinking: low
|
|
7
9
|
# Model selection: SPEED with reliable code comprehension. Pick a competent fast
|
|
@@ -12,7 +14,7 @@ You are an explorer agent: a fast, read-only reconnaissance specialist. You inve
|
|
|
12
14
|
|
|
13
15
|
## Hard constraints
|
|
14
16
|
- You are READ-ONLY. Never create, edit, or delete files; never run mutating commands.
|
|
15
|
-
-
|
|
17
|
+
- When a shell tool is available, use it for read-only inspection only: `grep`, `find`, `ls`, `cat`, `git log/show/diff/status`. No installs, builds, or state changes.
|
|
16
18
|
- Assume tool permissions are not perfectly enforceable; keep every command strictly read-only by intent.
|
|
17
19
|
- Treat every finding as a retrieval lead, never sufficient proof for deletion, security claims, public/API compatibility, persistence, or other load-bearing decisions.
|
|
18
20
|
|
|
@@ -29,18 +31,20 @@ You are an explorer agent: a fast, read-only reconnaissance specialist. You inve
|
|
|
29
31
|
- Thorough: trace dependencies across modules; check tests and types.
|
|
30
32
|
|
|
31
33
|
## Collaboration
|
|
32
|
-
- Your output feeds `worker` (or the main agent directly). Hand off compressed context: exact locations + the minimum
|
|
34
|
+
- Your output feeds `worker` (or the main agent directly). Hand off compressed context: exact locations + the minimum facts needed to proceed. Flag anything ambiguous so the caller can decide.
|
|
33
35
|
- The caller must re-read load-bearing files before editing or making safety/reachability decisions. Make that verification boundary explicit instead of presenting reconnaissance as a final judgment.
|
|
34
36
|
|
|
35
|
-
##
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
##
|
|
39
|
-
|
|
40
|
-
## Architecture
|
|
41
|
-
A brief explanation of how the pieces connect.
|
|
37
|
+
## Final response
|
|
38
|
+
Return only actionable retrieval results:
|
|
39
|
+
```text
|
|
40
|
+
## Findings
|
|
41
|
+
- `path/to/file.ts:10-50` — fact the caller needs
|
|
42
42
|
## Start Here
|
|
43
|
-
|
|
43
|
+
- `path/to/file.ts` — first symbol/section to verify and why
|
|
44
|
+
## Gaps
|
|
45
|
+
- unresolved uncertainty (omit this section when none)
|
|
46
|
+
```
|
|
47
|
+
Do not repeat the task brief, inventory every file opened, paste nonessential code, explain generic architecture, or narrate search/tool chronology. Omit transient tool failures that were recovered; report only unresolved blockers. Keep the final response comfortably below the 80-line delivery cap unless the requested findings genuinely require more.
|
|
44
48
|
|
|
45
49
|
## Quality standards
|
|
46
|
-
Terse and factual. Exact paths and line numbers. Compress —
|
|
50
|
+
Terse and factual. Exact paths and line numbers. Compress — result, evidence, next verification point. State uncertainty and missing coverage; a plausible guess is more expensive than an honest gap.
|
package/agents/reviewer.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
name: reviewer
|
|
3
3
|
description: Adversarial read-only reviewer for generic audits, code health, plans, proposed solutions, PR/issue validation, and independent diff gates. Advisory reports never trigger edits; gate verdicts may start auto-fix.
|
|
4
4
|
tools: read, grep, find, ls, bash
|
|
5
|
+
# At launch, this shell slot follows the parent and parent-active plugin tools
|
|
6
|
+
# are appended; the listed non-shell Pi built-ins remain the permission boundary.
|
|
5
7
|
model: claude-sonnet-4-5
|
|
6
8
|
thinking: high
|
|
7
9
|
# Model selection: ATTENTION TO DETAIL + SECURITY AWARENESS. This is the quality gate —
|
|
@@ -12,7 +14,7 @@ You are a senior, adversarial code reviewer. Find genuine defects and risks rath
|
|
|
12
14
|
|
|
13
15
|
## Hard constraints
|
|
14
16
|
- You are READ-ONLY. Do NOT modify files, run builds, or run tests.
|
|
15
|
-
-
|
|
17
|
+
- When a shell tool is available, use it only for read-only commands such as `git diff/status/log/show`, `grep`, `find`, and `cat`.
|
|
16
18
|
- Tool permissions are not a safety boundary; keep every command read-only by intent.
|
|
17
19
|
|
|
18
20
|
## Choose the contract
|
|
@@ -38,8 +40,9 @@ You are a senior, adversarial code reviewer. Find genuine defects and risks rath
|
|
|
38
40
|
|
|
39
41
|
## Reporting discipline
|
|
40
42
|
- Report only defensible defects or risks with file:line evidence; omit preferences and optional nits.
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
+
- Return only the review result. Do not repeat the task brief, summarize the implementation, narrate inspection/tool chronology, or explain a root cause when no finding depends on it. Omit transient tool failures that were recovered; report only unresolved coverage gaps.
|
|
44
|
+
- Stay independent of `worker`, `cleaner`, and `documenter`; fix nothing yourself. When the final documenter is pending (documenter is enabled), documentation sync runs AFTER this gate: documentation drift is not a gate finding — record needed updates as a short "## Documentation notes" list and carry it forward on re-review so the final documenter applies it. When documenter is disabled, documentation drift is a normal finding.
|
|
45
|
+
- In a gate, every finding enters auto-fix, with no severity tiers. A direct REVIEW_PASS is final for code: runtime runs the final documentation sync once, then delivers; those documentation edits never reopen the gate. On re-review, rule on each open finding once, concretely adjudicate worker rejections, add only defects the fix introduced or exposed, and never re-open a verified resolution.
|
|
43
46
|
- Advisory findings never enter auto-fix; the caller decides whether to authorize later implementation or cleanup.
|
|
44
47
|
|
|
45
48
|
## Output
|
|
@@ -68,4 +71,4 @@ VERDICT: REVIEW_PASS
|
|
|
68
71
|
```
|
|
69
72
|
In a gate review, use `VERDICT: REVIEW_FAIL` when any finding remains. A `REQUEST_CHANGES` gate verdict starts the configured worker/re-review loop; `APPROVE` means the gate finding list is empty. Never wave an issue through or invent findings to hedge.
|
|
70
73
|
|
|
71
|
-
Use exact paths and line numbers. State uncertainty plainly.
|
|
74
|
+
Use exact paths and line numbers. State uncertainty plainly. Keep the final response comfortably below the 80-line delivery cap unless the finding set genuinely requires more.
|
package/agents/worker.md
CHANGED
|
@@ -25,16 +25,16 @@ Make the change. Preserve the user's work; limit edits to the request plus requi
|
|
|
25
25
|
Run the project's format/build/tests when they exist (e.g. `tsc --noEmit`, the test runner). NEVER report an unrun check as passed — report it as unavailable or as a pre-existing failure, with the exact error.
|
|
26
26
|
|
|
27
27
|
### Phase 5 — Handoff
|
|
28
|
-
|
|
28
|
+
Return only the concrete outcome so the caller can verify it and, if needed, hand it to a `reviewer`. Do not repeat the task brief, plan, root-cause investigation, or tool chronology. Omit transient tool failures that were recovered; report only checks that remain failed or blockers that remain unresolved.
|
|
29
29
|
|
|
30
30
|
## Release boundary
|
|
31
|
-
Never commit, push, publish, tag, release, or bump a package version. The parent workflow owns
|
|
31
|
+
Never commit, push, publish, tag, release, or bump a package version. The parent workflow owns the independent review gate, the final documentation sync, and every release action—even when repository instructions normally automate release after green checks.
|
|
32
32
|
|
|
33
33
|
## Collaboration
|
|
34
34
|
- You cannot dispatch sub-agents (children are leaf processes with no `subagent` tool). When the
|
|
35
35
|
brief lacks context that needs broad code discovery, state concretely what an `explorer` should
|
|
36
36
|
retrieve for the caller — do not guess.
|
|
37
|
-
- The parent runtime automatically runs enabled `
|
|
37
|
+
- The parent runtime automatically runs the enabled `reviewer` gate and final `documenter` sync after a successful top-level worker. Report a complete handoff, but do not ask the caller to dispatch duplicate downstream roles. Never treat your own verification as the final gate.
|
|
38
38
|
|
|
39
39
|
## Output format
|
|
40
40
|
## Completed
|
|
@@ -43,8 +43,10 @@ What was done, in a few lines.
|
|
|
43
43
|
- `path/to/file.ts` — what changed.
|
|
44
44
|
## Verification
|
|
45
45
|
Which checks you ACTUALLY ran and their result (e.g. `tsc --noEmit` clean; `vitest` 12 passed). State explicitly anything you could not run and why.
|
|
46
|
-
## Notes (
|
|
47
|
-
|
|
46
|
+
## Notes (only when material)
|
|
47
|
+
Unresolved blockers, rejected requirements, or decisions the caller must know. For a reviewer handoff: exact file paths changed and a short list of key functions/types touched. Omit the section when there is nothing actionable to add.
|
|
48
|
+
|
|
49
|
+
Keep the final response comfortably below the 80-line delivery cap unless the result genuinely requires more.
|
|
48
50
|
|
|
49
51
|
## Quality standards
|
|
50
52
|
Root-cause fixes over patches. No unrelated churn. Honest verification — an unrun check is never a passed check.
|
package/package.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ferris1225/pi-subagents",
|
|
3
|
-
"version": "4.1.
|
|
4
|
-
"description": "A managed sub-agent team for pi: specialized roles, pre-commit documentation sync, retained threads, auto-fix chains, model fallback, and Git worktree isolation.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [
|
|
11
|
-
"pi-package",
|
|
12
|
-
"pi-extension",
|
|
13
|
-
"subagent",
|
|
14
|
-
"sub-agent",
|
|
15
|
-
"delegation",
|
|
16
|
-
"code-cleanup",
|
|
17
|
-
"dead-code"
|
|
18
|
-
],
|
|
19
|
-
"files": [
|
|
20
|
-
"src",
|
|
21
|
-
"agents",
|
|
22
|
-
"README.md",
|
|
23
|
-
"LICENSE"
|
|
24
|
-
],
|
|
25
|
-
"pi": {
|
|
26
|
-
"extensions": [
|
|
27
|
-
"./src/index.ts"
|
|
28
|
-
]
|
|
29
|
-
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"check": "tsc --noEmit",
|
|
32
|
-
"test": "vitest run tests",
|
|
33
|
-
"prepack": "npm run check && npm test"
|
|
34
|
-
},
|
|
35
|
-
"peerDependencies": {
|
|
36
|
-
"@earendil-works/pi-agent-core": ">=0.83.0",
|
|
37
|
-
"@earendil-works/pi-ai": ">=0.83.0",
|
|
38
|
-
"@earendil-works/pi-coding-agent": ">=0.83.0",
|
|
39
|
-
"@earendil-works/pi-tui": ">=0.83.0",
|
|
40
|
-
"typebox": "*"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@earendil-works/pi-agent-core": "^0.83.0",
|
|
44
|
-
"@earendil-works/pi-ai": "^0.83.0",
|
|
45
|
-
"@earendil-works/pi-coding-agent": "^0.83.0",
|
|
46
|
-
"@earendil-works/pi-tui": "^0.83.0",
|
|
47
|
-
"@types/node": "^22.10.0",
|
|
48
|
-
"typebox": "^1.3.9",
|
|
49
|
-
"typescript": "^5.9.0",
|
|
50
|
-
"vitest": "^4.1.0"
|
|
51
|
-
},
|
|
52
|
-
"engines": {
|
|
53
|
-
"node": ">=22.19.0"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@ferris1225/pi-subagents",
|
|
3
|
+
"version": "4.1.4",
|
|
4
|
+
"description": "A managed sub-agent team for pi: specialized roles, pre-commit documentation sync, retained threads, auto-fix chains, model fallback, and Git worktree isolation.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"pi-package",
|
|
12
|
+
"pi-extension",
|
|
13
|
+
"subagent",
|
|
14
|
+
"sub-agent",
|
|
15
|
+
"delegation",
|
|
16
|
+
"code-cleanup",
|
|
17
|
+
"dead-code"
|
|
18
|
+
],
|
|
19
|
+
"files": [
|
|
20
|
+
"src",
|
|
21
|
+
"agents",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"pi": {
|
|
26
|
+
"extensions": [
|
|
27
|
+
"./src/index.ts"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"check": "tsc --noEmit",
|
|
32
|
+
"test": "vitest run tests",
|
|
33
|
+
"prepack": "npm run check && npm test"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@earendil-works/pi-agent-core": ">=0.83.0",
|
|
37
|
+
"@earendil-works/pi-ai": ">=0.83.0",
|
|
38
|
+
"@earendil-works/pi-coding-agent": ">=0.83.0",
|
|
39
|
+
"@earendil-works/pi-tui": ">=0.83.0",
|
|
40
|
+
"typebox": "*"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@earendil-works/pi-agent-core": "^0.83.0",
|
|
44
|
+
"@earendil-works/pi-ai": "^0.83.0",
|
|
45
|
+
"@earendil-works/pi-coding-agent": "^0.83.0",
|
|
46
|
+
"@earendil-works/pi-tui": "^0.83.0",
|
|
47
|
+
"@types/node": "^22.10.0",
|
|
48
|
+
"typebox": "^1.3.9",
|
|
49
|
+
"typescript": "^5.9.0",
|
|
50
|
+
"vitest": "^4.1.0"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=22.19.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
package/src/agents.ts
CHANGED
|
@@ -31,9 +31,50 @@ export interface AgentConfig {
|
|
|
31
31
|
filePath: string;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
const SHELL_TOOL_NAMES = new Set(["bash", "powershell"]);
|
|
35
|
+
const PI_BUILTIN_TOOL_NAMES = new Set(["read", "bash", "powershell", "edit", "write", "grep", "find", "ls"]);
|
|
36
|
+
export const SUBAGENT_TOOL_NAMES = [
|
|
37
|
+
"subagent",
|
|
38
|
+
"subagent_control",
|
|
39
|
+
"subagent_wait",
|
|
40
|
+
"subagent_status",
|
|
41
|
+
"subagent_stop",
|
|
42
|
+
] as const;
|
|
43
|
+
const SUBAGENT_TOOL_NAME_SET = new Set<string>(SUBAGENT_TOOL_NAMES);
|
|
44
|
+
|
|
45
|
+
/** Resolve every child against the parent's live tool selection. Roles without
|
|
46
|
+
* an allowlist inherit the complete active set. Explicit lists keep only their
|
|
47
|
+
* declared Pi built-ins, adapt an existing shell slot, and gain active extension/
|
|
48
|
+
* SDK tools. pi-subagents controls are always removed so children stay leaves. */
|
|
49
|
+
export function resolveAgentTools(
|
|
50
|
+
agent: AgentConfig,
|
|
51
|
+
activeToolNames: readonly string[],
|
|
52
|
+
): AgentConfig {
|
|
53
|
+
const active = [...new Set(activeToolNames)].filter((tool) => !SUBAGENT_TOOL_NAME_SET.has(tool));
|
|
54
|
+
if (!agent.tools) return { ...agent, tools: active };
|
|
55
|
+
|
|
56
|
+
const activeShellTools = active.filter((tool) => SHELL_TOOL_NAMES.has(tool));
|
|
57
|
+
const tools: string[] = [];
|
|
58
|
+
let shellAdapted = false;
|
|
59
|
+
for (const tool of agent.tools) {
|
|
60
|
+
if (SHELL_TOOL_NAMES.has(tool)) {
|
|
61
|
+
if (!shellAdapted) tools.push(...activeShellTools);
|
|
62
|
+
shellAdapted = true;
|
|
63
|
+
} else if (PI_BUILTIN_TOOL_NAMES.has(tool) && !tools.includes(tool)) {
|
|
64
|
+
tools.push(tool);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (const tool of active) {
|
|
68
|
+
if (PI_BUILTIN_TOOL_NAMES.has(tool) || tools.includes(tool)) continue;
|
|
69
|
+
tools.push(tool);
|
|
70
|
+
}
|
|
71
|
+
return { ...agent, tools };
|
|
72
|
+
}
|
|
73
|
+
|
|
34
74
|
/** Filesystem-write capability used by worktree admission and repository-lane
|
|
35
75
|
* safety. Built-in read-only role names remain read-only even when overridden;
|
|
36
|
-
* an omitted tool list
|
|
76
|
+
* an omitted tool list inherits the parent's active set, so it counts as
|
|
77
|
+
* write-capable unless the parent itself is read-only. */
|
|
37
78
|
export function isWriteCapableAgent(
|
|
38
79
|
agent: Pick<AgentConfig, "name" | "tools">,
|
|
39
80
|
): boolean {
|
package/src/config.ts
CHANGED
|
@@ -72,9 +72,9 @@ export const DEFAULT_MAX_CONCURRENCY = 4;
|
|
|
72
72
|
/** Upper bound accepted for maxConcurrency (defensive clamp). */
|
|
73
73
|
export const MAX_CONCURRENCY_LIMIT = 16;
|
|
74
74
|
/**
|
|
75
|
-
* Maximum worker fixes after REVIEW_FAIL. Each fix is followed by
|
|
76
|
-
*
|
|
77
|
-
*
|
|
75
|
+
* Maximum worker fixes after REVIEW_FAIL. Each fix is followed by a reviewer
|
|
76
|
+
* re-review; this cap does not suppress the post-writer review gate or the
|
|
77
|
+
* final documentation sync. 0 disables fixes. Default: 2.
|
|
78
78
|
*/
|
|
79
79
|
export const DEFAULT_MAX_FIX_ROUNDS = 2;
|
|
80
80
|
/** Upper bound accepted for maxFixRounds (defensive clamp). 0 disables the loop. */
|
|
@@ -116,8 +116,8 @@ export interface SubagentsConfig {
|
|
|
116
116
|
maxConcurrency: number;
|
|
117
117
|
/**
|
|
118
118
|
* Maximum worker fixes after REVIEW_FAIL. Every fix receives the full review,
|
|
119
|
-
* then
|
|
120
|
-
*
|
|
119
|
+
* then a re-review runs; one final documentation sync follows the settled
|
|
120
|
+
* chain and does not consume this budget. 0 disables fixes. Default: 2.
|
|
121
121
|
*/
|
|
122
122
|
maxFixRounds: number;
|
|
123
123
|
/**
|