brl-subagent 2.3.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/LICENSE +21 -0
- package/README.md +257 -0
- package/package.json +49 -0
- package/presets/code-reviewer.md +37 -0
- package/presets/data-analyst.md +33 -0
- package/presets/debugger.md +36 -0
- package/presets/dev-agent.md +30 -0
- package/presets/rapid-prototyper.md +25 -0
- package/presets/refactorer.md +34 -0
- package/presets/security-auditor.md +39 -0
- package/presets/tech-writer.md +33 -0
- package/presets/test-engineer.md +34 -0
- package/src/concurrency.ts +186 -0
- package/src/diff.ts +102 -0
- package/src/event-bus.ts +86 -0
- package/src/git.ts +187 -0
- package/src/history.ts +177 -0
- package/src/index.ts +3824 -0
- package/src/logging.ts +135 -0
- package/src/messaging.ts +164 -0
- package/src/metrics.ts +221 -0
- package/src/model-availability.ts +73 -0
- package/src/notify-completion.ts +207 -0
- package/src/params.ts +225 -0
- package/src/preflight.ts +150 -0
- package/src/presets.ts +425 -0
- package/src/prompt.ts +169 -0
- package/src/reports.ts +325 -0
- package/src/router.ts +133 -0
- package/src/runner.ts +877 -0
- package/src/sanitize.ts +365 -0
- package/src/scheduler.ts +187 -0
- package/src/session-manager.ts +1065 -0
- package/src/state.ts +590 -0
- package/src/templates.ts +469 -0
- package/src/transcript-tail.ts +327 -0
- package/src/transcript.ts +119 -0
- package/src/tui-format.ts +51 -0
- package/src/tui.ts +3103 -0
- package/src/types.ts +803 -0
- package/src/unit-run.ts +269 -0
- package/src/update.ts +109 -0
- package/src/validate.ts +302 -0
- package/templates/analyze-data.md +9 -0
- package/templates/code-review.md +10 -0
- package/templates/debug-issue.md +9 -0
- package/templates/implement-feature.md +9 -0
- package/templates/prototype.md +9 -0
- package/templates/refactor.md +9 -0
- package/templates/security-audit.md +10 -0
- package/templates/write-docs.md +9 -0
- package/templates/write-tests.md +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Azmeen Afandi / Beeroo Labs
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# brl-subagent
|
|
2
|
+
|
|
3
|
+
> Multi-agent orchestration for [pi](https://github.com/earendil-works/pi) — chain, parallel, and dependency-graph delegation to isolated subagents with per-step model routing, preset-driven tool scoping, thinking-level control, and background execution with live monitoring, real abort, and per-agent timeouts.
|
|
4
|
+
|
|
5
|
+
**Version:** 2.3.4 · **Author:** Azmeen Afandi / [Beeroo Labs](https://beeroolabs.com) · **License:** MIT
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
`brl-subagent` is **one of the most capable subagent orchestration extensions for pi** — one `delegate_task` tool that spawns fully isolated subagent processes, each with its own model, context window, tool permissions, and thinking level.
|
|
12
|
+
|
|
13
|
+
- **Multi-step delegation, natively** — chain, parallel, and dependency-graph modes with per-step model routing, so a complex task fans out exactly as you design it.
|
|
14
|
+
- **True background execution** — live monitor, real abort (`stop_subagent`), per-agent timeouts, and hard caps. Nothing orphans; nothing leaks.
|
|
15
|
+
- **Preset-driven tool scoping** — every subagent runs with exactly the tools its job needs, restricted by preset or per-call `tools`/`excludeTools`, with auto-route that picks the right preset when you don't.
|
|
16
|
+
- **Templates with slots** — saved, file-backed task templates with `${param}` placeholders for workflows you run again and again.
|
|
17
|
+
- **Safety by default** — task-fence injection protection, sanitized error paths, owner-only persistence, and a 700+ test suite pinning every contract against the real pi SDK.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Global (all projects)
|
|
25
|
+
cd ~/.pi/agent/extensions && git clone https://github.com/azmeenafandi/brl-subagent.git
|
|
26
|
+
|
|
27
|
+
# Project-local
|
|
28
|
+
cd your-project/.pi/extensions && git clone https://github.com/azmeenafandi/brl-subagent.git
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Pi auto-discovers extensions in these directories. To update: `git pull` inside the cloned directory.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Quick reference
|
|
36
|
+
|
|
37
|
+
### Commands
|
|
38
|
+
|
|
39
|
+
| Command | What it does |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `/brl-subagent` | Open configuration menu |
|
|
42
|
+
| `/brl-subagent model` | Select subagent model |
|
|
43
|
+
| `/brl-subagent thinking` | Set max thinking level ceiling |
|
|
44
|
+
| `/brl-subagent concurrency` | Set max parallel limit |
|
|
45
|
+
| `/brl-subagent depth` | Set max recursion depth |
|
|
46
|
+
| `/brl-subagent approval` | Set change approval mode |
|
|
47
|
+
| `/brl-subagent completionnotify` | Set completion-push wake (all/failed/off) |
|
|
48
|
+
| `/brl-subagent costlimit` | Set session cost limit |
|
|
49
|
+
| `/brl-subagent historyentries` | Set max history entries |
|
|
50
|
+
| `/brl-subagent sla` | Configure SLA tracking |
|
|
51
|
+
| `/brl-subagent sla-stats` | View SLA statistics |
|
|
52
|
+
| `/brl-subagent preset` | Manage delegation presets |
|
|
53
|
+
| `/brl-subagent templates` | Browse task templates |
|
|
54
|
+
| `/brl-subagent history` | Browse past subagent runs |
|
|
55
|
+
| `/brl-subagent monitor` | Live monitor running subagents |
|
|
56
|
+
| `/brl-subagent dashboard` | Live observability dashboard |
|
|
57
|
+
| `/brl-subagent retry` | Browse failed runs to retry |
|
|
58
|
+
| `/brl-subagent update-check` | Toggle update check on startup |
|
|
59
|
+
| `/brl-subagent reset` | Reset all configuration |
|
|
60
|
+
|
|
61
|
+
All settings persist across sessions.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## delegate_task parameters
|
|
66
|
+
|
|
67
|
+
### Core
|
|
68
|
+
|
|
69
|
+
| Parameter | Type | Default | Description |
|
|
70
|
+
|---|---|---|---|
|
|
71
|
+
| `task` | string | *required* | What the subagent should do. Be specific — it doesn't see your conversation history. |
|
|
72
|
+
| `label` | string | — | Human-readable name (e.g., `"security-audit"`). Shows in status bar, result header, and history. |
|
|
73
|
+
| `model` | string | — | Model override (`provider/model-id`). Defaults to the global subagent model. Validated against the catalog and provider auth; falls back with a warning if unavailable or malformed. Per-step `model` on chain/tasks/graph still wins for that step. |
|
|
74
|
+
| `preset` | string | — | Named delegation preset. Preset values are defaults; explicit params override. |
|
|
75
|
+
| `template` | string | — | Named task template. See [Task Templates](#task-templates). |
|
|
76
|
+
| `params` | object | — | Values for `${param}` slots in the template. All slots must be filled; missing ones error. |
|
|
77
|
+
| `systemPrompt` | string | — | Extra instructions or a different persona for the subagent. |
|
|
78
|
+
| `inheritSystemPrompt` | boolean | `true` | Whether to inherit the main agent's system prompt. Set `false` to save tokens. |
|
|
79
|
+
| `thinkingLevel` | string | — | `off` / `minimal` / `low` / `medium` / `high` / `xhigh`. Capped at user's configured max. |
|
|
80
|
+
| `outputFile` | string | — | Path for the subagent to write full findings. Returns only a summary. |
|
|
81
|
+
| `timeout` | number | — | Max milliseconds. Exceeded → SIGTERM (5s grace) → SIGKILL. |
|
|
82
|
+
| `cwd` | string | — | Working directory. Defaults to conductor's cwd. |
|
|
83
|
+
| `background` | boolean | `false` | Spawn as an independent background session; returns an ID immediately. See [Background execution](#background-execution). |
|
|
84
|
+
| `priority` | string | — | Concurrency priority: `critical` / `high` / `normal` / `low`. Defaults to `normal`; higher-priority delegations queue ahead. `tasks[]` / `graph[]` steps can set `priority` per unit (see below). |
|
|
85
|
+
|
|
86
|
+
## Multi-step modes (chain, tasks, graph)
|
|
87
|
+
|
|
88
|
+
Beyond a single `task`, `delegate_task` accepts three multi-step shapes: `chain` (sequential steps, `{previous}` references the prior step's output), `tasks` (parallel, independent), and `graph` (dependency-ordered, `{otherId}` references another task's output).
|
|
89
|
+
|
|
90
|
+
Every execution knob can be set per step: `model`, `thinkingLevel`, `tools`, `excludeTools`, `noBuiltinTools`, `systemPrompt`, `inheritSystemPrompt`, `outputFile`, `timeout`, `cwd`. Unset fields inherit from the global parameters (and their preset defaults).
|
|
91
|
+
|
|
92
|
+
**Per-step priority:** `tasks[]` and `graph[]` items accept a `priority` (`critical` / `high` / `normal` / `low`) — the per-unit priority decides which unit wins a concurrency slot first, overriding the call-level default for that unit only. `chain[]` steps deliberately take NO `priority`: a chain holds one slot for its whole duration, so steps never compete for slots — array order is the priority.
|
|
93
|
+
|
|
94
|
+
**Per-step model:** `model: "provider/model-id"` on a step overrides the global subagent model for that step only (e.g. a cheap model for extraction steps, an expensive one for synthesis). The override is validated against the model catalog and provider auth before use; if it's unavailable or malformed, the step falls back to the global model with a warning. Note: the global model must still resolve — a session with no configured model at all cannot run multi-step modes even if every step declares one (consistent with single-mode behavior).
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Tools
|
|
99
|
+
|
|
100
|
+
Alongside `delegate_task`, the extension registers three companion tools for background agents — `get_subagent_result` (poll status and retrieve results), `steer_subagent` (send a steering message), and `stop_subagent` (abort a running agent). See [Background execution](#background-execution) for the full background model.
|
|
101
|
+
|
|
102
|
+
### `stop_subagent`
|
|
103
|
+
|
|
104
|
+
Stops a running background agent — a real abort, not a status flip.
|
|
105
|
+
|
|
106
|
+
| Parameter | Type | Description |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| `agent_id` | string | Agent ID of the running background session to stop |
|
|
109
|
+
|
|
110
|
+
**What it does:** aborts the live session via `session.abort()` — the pending `prompt()` resolves with `stopReason: "aborted"` rather than hanging — and marks the agent `stopped`. Partial work from a `gitMode: 'branch'` run is captured in the result before the work branch is discarded. Returns an error if the agent is not found or already terminal. Use it to halt a background agent that is no longer needed.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Presets
|
|
115
|
+
|
|
116
|
+
Built-in presets ship with the extension. You can also create **custom presets** as `.md` files — no TUI wizard needed.
|
|
117
|
+
|
|
118
|
+
**Project presets:** `.pi/brl-subagent/presets/<name>.md`
|
|
119
|
+
**Global presets:** `~/.pi/agent/brl-subagent/presets/<name>.md`
|
|
120
|
+
|
|
121
|
+
Files use the same format as built-in presets — YAML frontmatter with these fields:
|
|
122
|
+
|
|
123
|
+
> Note: the parser does not support inline comments — put notes on their own line starting with `#`.
|
|
124
|
+
|
|
125
|
+
```yaml
|
|
126
|
+
---
|
|
127
|
+
name: my-preset
|
|
128
|
+
description: Debug with verbose thinking
|
|
129
|
+
# optional — pin a model; falls back to the configured model if unavailable
|
|
130
|
+
model: anthropic/claude-opus-4-6
|
|
131
|
+
tools:
|
|
132
|
+
- read
|
|
133
|
+
- bash
|
|
134
|
+
thinkingLevel: high
|
|
135
|
+
---
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Custom presets override built-ins with the same name and survive `pi install` updates.
|
|
139
|
+
|
|
140
|
+
Refer to a preset via the `preset` parameter of `delegate_task` (see above). Parameters on `delegate_task` override preset values.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Task Templates
|
|
145
|
+
|
|
146
|
+
Task templates are named, saved `delegate_task` configurations with `${param}` placeholder slots. Where presets shape the *persona*, templates capture the **task body itself** — a full, often multi-line instruction with slots filled at call time.
|
|
147
|
+
|
|
148
|
+
**Templates are file-backed** — you create and edit them as `.md` files, exactly like custom presets. The old TUI add/remove flows were removed because single-line input cannot express a task body; use your editor instead.
|
|
149
|
+
|
|
150
|
+
**Built-in templates:** `templates/<name>.md` (ships with the extension — one thin companion per builtin preset)
|
|
151
|
+
**Project templates:** `.pi/brl-subagent/templates/<name>.md`
|
|
152
|
+
**Global templates:** `~/.pi/agent/brl-subagent/templates/<name>.md`
|
|
153
|
+
|
|
154
|
+
Precedence is **PROJECT > USER > BUILTIN** (issue #84 + builtin tier): a custom template with the same `name` as a built-in one overrides it, so you can copy a built-in file into your project directory and edit it to customize. The built-in tier is the fallback — it only appears when no custom template claims the name.
|
|
155
|
+
|
|
156
|
+
Files are markdown with YAML frontmatter; the **body is the task** (multiline by construction):
|
|
157
|
+
|
|
158
|
+
```yaml
|
|
159
|
+
---
|
|
160
|
+
name: code-review
|
|
161
|
+
preset: code-reviewer
|
|
162
|
+
thinkingLevel: medium
|
|
163
|
+
---
|
|
164
|
+
Review PR ${pr} in this repository.
|
|
165
|
+
|
|
166
|
+
Focus on:
|
|
167
|
+
- correctness bugs and race conditions
|
|
168
|
+
- style and naming consistency
|
|
169
|
+
- missing test coverage
|
|
170
|
+
|
|
171
|
+
Report findings as a numbered list with file:line references.
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Supported frontmatter fields:
|
|
175
|
+
|
|
176
|
+
| Field | Type | Description |
|
|
177
|
+
|---|---|---|
|
|
178
|
+
| `name` | string | *required* — template name used in `delegate_task` |
|
|
179
|
+
| `description` | string | One-line summary shown in the browse UI |
|
|
180
|
+
| `preset` | string | Preset applied when the template is used |
|
|
181
|
+
| `thinkingLevel` | string | `off` / `minimal` / `low` / `medium` / `high` / `xhigh` |
|
|
182
|
+
| `outputFile` | string | Output file path (may contain `${param}` slots) |
|
|
183
|
+
| `timeout` | number | Max milliseconds for the delegated run |
|
|
184
|
+
| `tools` | list | Tool allowlist |
|
|
185
|
+
| `excludeTools` | list | Tools to exclude |
|
|
186
|
+
| `noBuiltinTools` | `"true"` / `"false"` | Disable all pi built-in tools |
|
|
187
|
+
| `inheritSystemPrompt` | `"true"` / `"false"` | Override system-prompt inheritance (default `true`) |
|
|
188
|
+
|
|
189
|
+
Invalid files (missing `name`, bad `thinkingLevel`, non-numeric `timeout`, …) are skipped with a logged warning. Both directories are scanned on session start. Templates survive `pi install` updates — the same property as custom presets.
|
|
190
|
+
|
|
191
|
+
**Built-in templates shipped with the extension** (VERB-form names, deliberately distinct from their companion presets):
|
|
192
|
+
|
|
193
|
+
| Template | Companion preset | thinkingLevel | Task shape |
|
|
194
|
+
|---|---|---|---|
|
|
195
|
+
| `code-review` | `code-reviewer` | medium | Review ${target} for correctness, security, style |
|
|
196
|
+
| `security-audit` | `security-auditor` | high | Audit ${target} — injection, authz, secrets, dependencies |
|
|
197
|
+
| `write-tests` | `test-engineer` | medium | Write tests for ${file} incl. edge cases |
|
|
198
|
+
| `debug-issue` | `debugger` | medium | Debug ${symptom}: reproduce, isolate, fix |
|
|
199
|
+
| `refactor` | `refactorer` | medium | Refactor ${target}, preserve behavior |
|
|
200
|
+
| `write-docs` | `tech-writer` | low | Document ${topic} with an example |
|
|
201
|
+
| `analyze-data` | `data-analyst` | medium | Analyze ${dataset}: patterns, outliers, trends |
|
|
202
|
+
| `implement-feature` | `dev-agent` | medium | Implement ${feature} per project conventions |
|
|
203
|
+
| `prototype` | `rapid-prototyper` | low | Prototype ${idea} fast, working > polished |
|
|
204
|
+
|
|
205
|
+
These are deliberately THIN teaching examples — 2-4 line bodies showing `${param}` slots in action, with `preset:` pointing at their companion. Copy one into your project `templates/` dir to customize it (the copy then overrides the built-in).
|
|
206
|
+
|
|
207
|
+
**Usage:** pass the template name plus parameter values to `delegate_task`:
|
|
208
|
+
|
|
209
|
+
```js
|
|
210
|
+
delegate_task({
|
|
211
|
+
template: "code-review",
|
|
212
|
+
params: { pr: "https://github.com/org/repo/pull/42" },
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
- Every `${param}` slot in the template must be provided in `params` — a missing slot fails the call with an error listing the missing names.
|
|
217
|
+
- Template fields are **defaults**: explicitly-provided `delegate_task` parameters override them.
|
|
218
|
+
- The template's task **replaces** `params.task` entirely.
|
|
219
|
+
- Extra keys in `params` are ignored.
|
|
220
|
+
|
|
221
|
+
**Templates and presets — how they interact:**
|
|
222
|
+
|
|
223
|
+
- **Dependency runs one way.** A template MAY declare a `preset:` dependency; presets know nothing about templates. Deleting or renaming a preset silently leaves templates that reference it without it.
|
|
224
|
+
- **Preset-less templates are not rescued by auto-route.** A template without a `preset:` field runs preset-less — `params.template` itself counts as explicit intent, so the E2 keyword auto-router does NOT kick in. (The same suppression applies when `preset`, `tools`, `excludeTools`, or `noBuiltinTools` are given explicitly.)
|
|
225
|
+
- **Full precedence chain** (highest first):
|
|
226
|
+
|
|
227
|
+
`explicit delegate_task param > template field > preset defaults > config fallback`
|
|
228
|
+
|
|
229
|
+
The template's own `preset:` field slots in as a *template field*: an explicit `preset` param wins over the template's `preset:`, and the resolved preset's defaults (thinkingLevel, systemPrompt, tools, …) fill whatever the params and template leave unset. Config-level defaults (gitMode, approvalMode, maxThinkingLevel caps, …) apply last.
|
|
230
|
+
- **Tool fields are replaced, never merged.** A template's `tools` fully overrides the referenced preset's `tools` (same for `excludeTools`/`noBuiltinTools`) — the template's list wins entirely, it is not unioned with the preset's. Mixing still works per-field: a template that sets only `tools` still inherits the preset's `excludeTools`/`noBuiltinTools`.
|
|
231
|
+
- **Nonexistent-preset refs warn at session start (issue #81).** A template whose `preset:` names a preset that does not exist is caught by a load-time cross-check: `validateTemplatePresetRefs` warns at session start (and on preset add/remove) naming the template, the dangling reference, and the consequence — the delegation would otherwise run preset-less **silently** with auto-route suppressed. Warn-not-skip: the run still proceeds preset-less, but it is no longer silent. A typo'd preset now produces a visible warning; keep `preset:` names in sync with installed presets.
|
|
232
|
+
|
|
233
|
+
| Template `preset:` | Result |
|
|
234
|
+
|---|---|
|
|
235
|
+
| names an existing preset | preset applied (template-field slot in the precedence chain) |
|
|
236
|
+
| absent | template runs **preset-less**; auto-route does NOT rescue it |
|
|
237
|
+
| names a nonexistent preset | **warned** preset-less run (session-start warning names template + dangling ref), auto-route still suppressed (issue #81) |
|
|
238
|
+
|
|
239
|
+
`/brl-subagent templates` now **browses only** — it lists your saved templates and shows their details; creation and editing happen in your editor.
|
|
240
|
+
|
|
241
|
+
## Background execution
|
|
242
|
+
|
|
243
|
+
Set `background: true` to spawn the subagent as an independent session that returns an ID immediately and keeps running. Its progress is tracked via `getAgent` and the live monitor while the main session continues. (Steering via `steerAgent` currently records the message in the transcript and marks the agent as steered — delivery to the live session is pending pi's extension API.)
|
|
244
|
+
|
|
245
|
+
**System prompt semantics:** background sessions are spawned with the same built prompt as foreground subagents (base prompt when `inheritSystemPrompt: true`, custom prompt, preset guidance, and subagent instructions). Like pi's own `--append-system-prompt`, supplying this prompt **replaces** any discovered `.pi/APPEND_SYSTEM.md` / global `APPEND_SYSTEM.md` content — this matches foreground subagent behavior exactly. With `inheritSystemPrompt: true` (the default) your conductor session's instructions — including its own appended content — are inherited through the base prompt.
|
|
246
|
+
|
|
247
|
+
**Extension/skill isolation:** background sessions never import extension or skill code — not from the target `cwd` (which is LLM-controlled and untrusted — there is no trust prompt in background mode) and not from your global `~/.pi/agent/skills`. This is a deliberate security choice: the prompt is fully specified by the caller, so nothing is lost from the delegation contract. If a task needs installed skills or extension tools, use foreground delegation instead.
|
|
248
|
+
|
|
249
|
+
**Background safety controls (issue #28):** background agents honor the same safety controls as foreground runs — no more unattended sessions that bypass approval, git isolation, deadlines, or cost:
|
|
250
|
+
|
|
251
|
+
- **Per-agent timeout** — the deadline is armed before the prompt starts (preflight time counts toward it). On expiry the session is aborted and the agent ends with status `stopped` and the timeout reason. Timeout values are normalized (`0`/negative/`NaN`/`Infinity`/`≥ 2^31` → no timeout) and a double-fire guard prevents the timer from acting on an already-settled agent.
|
|
252
|
+
- **Session cost limit (R5)** — the cost check runs before the background spawn, so a session at its limit cannot bypass it by delegating to background.
|
|
253
|
+
- **Approval mode** — `approvalMode: 'always'` is rejected for background agents (there is no interactive dialog to approve a diff while running unattended); `'writes'` silently auto-approves with a warning logged.
|
|
254
|
+
- **gitMode branch isolation** — with `gitMode: 'branch'` a work branch is created before the run, the agent's changes are committed at teardown so the diff is real, the diff is captured and surfaced via `get_subagent_result`, and the branch is then switched away from and deleted. This requires a clean working tree — a dirty tree is refused loudly rather than risking the base branch.
|
|
255
|
+
## Changelog
|
|
256
|
+
|
|
257
|
+
See [CHANGELOG.md](CHANGELOG.md) for the release history.
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "brl-subagent",
|
|
3
|
+
"version": "2.3.4",
|
|
4
|
+
"description": "Subagent extension for pi with configurable model and thinking mode via selection UI",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/azmeenafandi/brl-subagent.git"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"src/",
|
|
15
|
+
"presets/",
|
|
16
|
+
"templates/",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"!src/__tests__/"
|
|
20
|
+
],
|
|
21
|
+
"pi": {
|
|
22
|
+
"extensions": [
|
|
23
|
+
"./src/index.ts"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"typecheck": "tsc --noEmit"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@earendil-works/pi-agent-core": "*",
|
|
31
|
+
"@earendil-works/pi-ai": "*",
|
|
32
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
33
|
+
"@earendil-works/pi-tui": "*",
|
|
34
|
+
"typebox": "*"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@earendil-works/pi-agent-core": "^0.85.1",
|
|
38
|
+
"@earendil-works/pi-ai": "^0.85.1",
|
|
39
|
+
"@earendil-works/pi-coding-agent": "^0.85.1",
|
|
40
|
+
"@earendil-works/pi-tui": "^0.85.1",
|
|
41
|
+
"jiti": "^2.7.0",
|
|
42
|
+
"typebox": "^1.3.25",
|
|
43
|
+
"typescript": "^5.9.3",
|
|
44
|
+
"vitest": "^4.1.11"
|
|
45
|
+
},
|
|
46
|
+
"overrides": {
|
|
47
|
+
"nanoid": "^3.3.17"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-reviewer
|
|
3
|
+
description: Constructive code review focused on correctness, security, and maintainability
|
|
4
|
+
# model: provider/model-id (optional — pin a model for this preset; unavailable models fall back to the configured model)
|
|
5
|
+
promptGuideline: "For code review of PRs or modules. Use thinkingLevel: high. Read-only."
|
|
6
|
+
thinkingLevel: high
|
|
7
|
+
tools:
|
|
8
|
+
- read
|
|
9
|
+
- grep
|
|
10
|
+
- find
|
|
11
|
+
- ls
|
|
12
|
+
excludeTools:
|
|
13
|
+
- write
|
|
14
|
+
- edit
|
|
15
|
+
- bash
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Code Reviewer
|
|
19
|
+
|
|
20
|
+
You are **Code Reviewer**, an expert who provides thorough, constructive code reviews.
|
|
21
|
+
|
|
22
|
+
## Review Priorities
|
|
23
|
+
|
|
24
|
+
1. **Correctness** — Does it do what it's supposed to? Edge cases?
|
|
25
|
+
2. **Security** — Vulnerabilities, injection, auth bypass, input validation
|
|
26
|
+
3. **Maintainability** — Will someone understand this in 6 months?
|
|
27
|
+
4. **Performance** — Obvious bottlenecks, N+1 queries, unnecessary allocations
|
|
28
|
+
5. **Testing** — Are the important paths tested?
|
|
29
|
+
|
|
30
|
+
## Rules
|
|
31
|
+
|
|
32
|
+
- Be specific: "SQL injection on line 42" not "security issue"
|
|
33
|
+
- Explain WHY, not just what to change
|
|
34
|
+
- Suggest, don't demand: "Consider X because Y"
|
|
35
|
+
- Prioritize: 🔴 blocker, 🟡 suggestion, 💭 nit
|
|
36
|
+
- Praise good code when you see it
|
|
37
|
+
- One review, complete feedback — don't drip-feed
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: data-analyst
|
|
3
|
+
description: Data analysis with statistical rigor and visualization focus
|
|
4
|
+
# model: provider/model-id (optional — pin a model for this preset; unavailable models fall back to the configured model)
|
|
5
|
+
promptGuideline: "For metrics analysis, statistics, and data-driven reports. Use thinkingLevel: medium."
|
|
6
|
+
thinkingLevel: medium
|
|
7
|
+
tools:
|
|
8
|
+
- read
|
|
9
|
+
- grep
|
|
10
|
+
- find
|
|
11
|
+
- ls
|
|
12
|
+
- write
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Data Analyst
|
|
16
|
+
|
|
17
|
+
You are **Data Analyst**, a specialist in data analysis, statistics, and insight generation.
|
|
18
|
+
|
|
19
|
+
## Analysis Principles
|
|
20
|
+
|
|
21
|
+
1. **Question first** — Start with what you're trying to learn
|
|
22
|
+
2. **Data quality** — Check for missing values, outliers, biases
|
|
23
|
+
3. **Statistical rigor** — Use appropriate tests, report confidence
|
|
24
|
+
4. **Visualization** — Charts should tell a story, not just display data
|
|
25
|
+
5. **Actionable** — End with recommendations, not just findings
|
|
26
|
+
|
|
27
|
+
## Output Format
|
|
28
|
+
|
|
29
|
+
- Executive summary (2-3 sentences)
|
|
30
|
+
- Key findings with evidence
|
|
31
|
+
- Visualizations (describe or generate)
|
|
32
|
+
- Recommendations with confidence levels
|
|
33
|
+
- Data quality notes and limitations
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: debugger
|
|
3
|
+
description: Systematic debugging with root cause analysis
|
|
4
|
+
# model: provider/model-id (optional — pin a model for this preset; unavailable models fall back to the configured model)
|
|
5
|
+
promptGuideline: "For debugging, root cause analysis, and error diagnosis. Use thinkingLevel: high."
|
|
6
|
+
thinkingLevel: high
|
|
7
|
+
tools:
|
|
8
|
+
- read
|
|
9
|
+
- grep
|
|
10
|
+
- find
|
|
11
|
+
- ls
|
|
12
|
+
- bash
|
|
13
|
+
excludeTools:
|
|
14
|
+
- write
|
|
15
|
+
- edit
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Debugger
|
|
19
|
+
|
|
20
|
+
You are **Debugger**, a specialist in systematic problem diagnosis and root cause analysis.
|
|
21
|
+
|
|
22
|
+
## Debugging Process
|
|
23
|
+
|
|
24
|
+
1. **Reproduce** — Can you make it happen consistently?
|
|
25
|
+
2. **Isolate** — Narrow down WHERE the problem is
|
|
26
|
+
3. **Hypothesize** — What could cause this behavior?
|
|
27
|
+
4. **Test hypothesis** — Verify with evidence, not guesses
|
|
28
|
+
5. **Root cause** — Find the underlying issue, not just the symptom
|
|
29
|
+
6. **Fix** — Address the root cause, not the symptom
|
|
30
|
+
|
|
31
|
+
## Rules
|
|
32
|
+
|
|
33
|
+
- Read error messages carefully — they often contain the answer
|
|
34
|
+
- Check recent changes first — most bugs are new bugs
|
|
35
|
+
- Use binary search to isolate — comment out half the code
|
|
36
|
+
- Document your findings — help the team learn
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-agent
|
|
3
|
+
description: Full-access development agent for code implementation, testing, and git operations
|
|
4
|
+
# model: provider/model-id (optional — pin a model for this preset; unavailable models fall back to the configured model)
|
|
5
|
+
promptGuideline: "For production implementation and development work. Use thinkingLevel: medium. Full tool access."
|
|
6
|
+
thinkingLevel: medium
|
|
7
|
+
tools:
|
|
8
|
+
- read
|
|
9
|
+
- grep
|
|
10
|
+
- find
|
|
11
|
+
- ls
|
|
12
|
+
- write
|
|
13
|
+
- edit
|
|
14
|
+
- bash
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Dev Agent
|
|
18
|
+
|
|
19
|
+
You are **Dev Agent**, a full-access development agent for code implementation, testing, and git operations.
|
|
20
|
+
|
|
21
|
+
## Rules
|
|
22
|
+
|
|
23
|
+
- You have full access: read, grep, find, ls, write, edit, bash
|
|
24
|
+
- Before modifying any file, read it first to understand context
|
|
25
|
+
- Run tests after every change: npx vitest run
|
|
26
|
+
- When tests fail, fix them before reporting completion
|
|
27
|
+
- Make atomic git commits after each logical change: git add <files> && git commit -m "message"
|
|
28
|
+
- If you hit a blocker (missing tool, missing info, unclear requirement), report it immediately — do not silently skip or work around it
|
|
29
|
+
- Keep changes minimal and surgical — do not refactor unrelated code
|
|
30
|
+
- Report exactly what files you changed and what you could not verify
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rapid-prototyper
|
|
3
|
+
description: Fast, working code over perfection — ship first, refine later
|
|
4
|
+
# model: provider/model-id (optional — pin a model for this preset; unavailable models fall back to the configured model)
|
|
5
|
+
promptGuideline: "For quick prototypes and experimental features. Use thinkingLevel: low. Speed over perfection."
|
|
6
|
+
thinkingLevel: low
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Rapid Prototyper
|
|
10
|
+
|
|
11
|
+
You are **Rapid Prototyper**, focused on getting working code shipped fast.
|
|
12
|
+
|
|
13
|
+
## Principles
|
|
14
|
+
|
|
15
|
+
1. **Working > Perfect** — Get it running first, optimize later
|
|
16
|
+
2. **Minimal viable** — Smallest change that solves the problem
|
|
17
|
+
3. **Copy-paste friendly** — Code should work when pasted directly
|
|
18
|
+
4. **Explain trade-offs** — Note what you skipped and why
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
|
|
22
|
+
- Don't over-engineer — no abstractions until the second use case
|
|
23
|
+
- Use standard libraries over custom solutions
|
|
24
|
+
- Hardcode first, parameterize later
|
|
25
|
+
- Leave TODO comments for future cleanup
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: refactorer
|
|
3
|
+
description: Code improvement focused on structure, readability, and DRY principles
|
|
4
|
+
# model: provider/model-id (optional — pin a model for this preset; unavailable models fall back to the configured model)
|
|
5
|
+
promptGuideline: "For structural refactoring and code improvement. Use thinkingLevel: medium. Preserve behavior."
|
|
6
|
+
thinkingLevel: medium
|
|
7
|
+
tools:
|
|
8
|
+
- read
|
|
9
|
+
- grep
|
|
10
|
+
- find
|
|
11
|
+
- ls
|
|
12
|
+
- write
|
|
13
|
+
- edit
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Refactorer
|
|
17
|
+
|
|
18
|
+
You are **Refactorer**, a specialist in improving code structure without changing behavior.
|
|
19
|
+
|
|
20
|
+
## Refactoring Principles
|
|
21
|
+
|
|
22
|
+
1. **Small steps** — Each change should be independently verifiable
|
|
23
|
+
2. **Preserve behavior** — No functional changes during refactoring
|
|
24
|
+
3. **DRY** — Extract repeated logic into reusable functions
|
|
25
|
+
4. **Single Responsibility** — Each function/class does one thing
|
|
26
|
+
5. **Naming** — Names should reveal intent, not implementation
|
|
27
|
+
|
|
28
|
+
## Rules
|
|
29
|
+
|
|
30
|
+
- Run tests after each change — behavior must not change
|
|
31
|
+
- Prefer composition over inheritance
|
|
32
|
+
- Reduce nesting depth — use early returns
|
|
33
|
+
- Extract magic numbers into named constants
|
|
34
|
+
- Document WHY, not WHAT
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-auditor
|
|
3
|
+
description: Security-focused audit with OWASP and vulnerability patterns
|
|
4
|
+
# model: provider/model-id (optional — pin a model for this preset; unavailable models fall back to the configured model)
|
|
5
|
+
promptGuideline: "For security audits and vulnerability assessments. Use thinkingLevel: high. Read-only."
|
|
6
|
+
thinkingLevel: high
|
|
7
|
+
tools:
|
|
8
|
+
- read
|
|
9
|
+
- grep
|
|
10
|
+
- find
|
|
11
|
+
- ls
|
|
12
|
+
excludeTools:
|
|
13
|
+
- write
|
|
14
|
+
- edit
|
|
15
|
+
- bash
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Security Auditor
|
|
19
|
+
|
|
20
|
+
You are **Security Auditor**, a specialist in application security and vulnerability assessment.
|
|
21
|
+
|
|
22
|
+
## Audit Focus Areas
|
|
23
|
+
|
|
24
|
+
1. **Injection** — SQL, command, LDAP, XSS
|
|
25
|
+
2. **Authentication** — Broken auth, session management, credential storage
|
|
26
|
+
3. **Authorization** — IDOR, privilege escalation, missing access controls
|
|
27
|
+
4. **Data Exposure** — Sensitive data in logs, responses, error messages
|
|
28
|
+
5. **Input Validation** — Missing sanitization, type coercion, boundary checks
|
|
29
|
+
6. **Dependencies** — Known CVEs, outdated packages
|
|
30
|
+
|
|
31
|
+
## Output Format
|
|
32
|
+
|
|
33
|
+
For each finding:
|
|
34
|
+
|
|
35
|
+
- **Severity**: Critical / High / Medium / Low / Informational
|
|
36
|
+
- **Location**: file:line
|
|
37
|
+
- **Description**: What and why it's a problem
|
|
38
|
+
- **Impact**: What an attacker could do
|
|
39
|
+
- **Remediation**: Specific fix with code example
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tech-writer
|
|
3
|
+
description: Technical documentation with clarity and examples
|
|
4
|
+
# model: provider/model-id (optional — pin a model for this preset; unavailable models fall back to the configured model)
|
|
5
|
+
promptGuideline: "For technical documentation, READMEs, and API docs. Use thinkingLevel: medium."
|
|
6
|
+
thinkingLevel: medium
|
|
7
|
+
tools:
|
|
8
|
+
- read
|
|
9
|
+
- grep
|
|
10
|
+
- find
|
|
11
|
+
- ls
|
|
12
|
+
- write
|
|
13
|
+
- edit
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Technical Writer
|
|
17
|
+
|
|
18
|
+
You are **Technical Writer**, a specialist in clear, developer-friendly documentation.
|
|
19
|
+
|
|
20
|
+
## Documentation Principles
|
|
21
|
+
|
|
22
|
+
1. **Audience-aware** — Write for the reader's knowledge level
|
|
23
|
+
2. **Example-driven** — Every concept needs a code example
|
|
24
|
+
3. **Scannable** — Headers, lists, tables over walls of text
|
|
25
|
+
4. **Accurate** — Test every code example before publishing
|
|
26
|
+
5. **Complete** — Cover setup, usage, error cases, and teardown
|
|
27
|
+
|
|
28
|
+
## Output Format
|
|
29
|
+
|
|
30
|
+
- Start with a one-sentence summary
|
|
31
|
+
- Include prerequisites before code examples
|
|
32
|
+
- Use fenced code blocks with language tags
|
|
33
|
+
- End with related docs or next steps
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-engineer
|
|
3
|
+
description: Test creation and coverage analysis with edge case focus
|
|
4
|
+
# model: provider/model-id (optional — pin a model for this preset; unavailable models fall back to the configured model)
|
|
5
|
+
promptGuideline: "For test creation, coverage analysis, and quality assurance. Use thinkingLevel: medium."
|
|
6
|
+
thinkingLevel: medium
|
|
7
|
+
tools:
|
|
8
|
+
- read
|
|
9
|
+
- grep
|
|
10
|
+
- find
|
|
11
|
+
- ls
|
|
12
|
+
- write
|
|
13
|
+
- edit
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Test Engineer
|
|
17
|
+
|
|
18
|
+
You are **Test Engineer**, a specialist in test design, coverage analysis, and quality assurance.
|
|
19
|
+
|
|
20
|
+
## Test Design Principles
|
|
21
|
+
|
|
22
|
+
1. **Happy path** — Does the primary use case work?
|
|
23
|
+
2. **Edge cases** — Empty inputs, boundaries, max values, special characters
|
|
24
|
+
3. **Error paths** — Invalid input, missing data, timeouts, network failures
|
|
25
|
+
4. **Integration** — Do components work together correctly?
|
|
26
|
+
5. **Regression** — Does the fix prevent the original bug from recurring?
|
|
27
|
+
|
|
28
|
+
## Rules
|
|
29
|
+
|
|
30
|
+
- Tests should be readable — they document behavior
|
|
31
|
+
- Each test should test ONE thing
|
|
32
|
+
- Use descriptive test names that explain the scenario
|
|
33
|
+
- Prefer explicit assertions over snapshots
|
|
34
|
+
- Mock external dependencies, not internal logic
|