project-brain 0.19.0 → 0.20.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 +31 -1
- package/package.json +6 -6
- package/templates/model-routing.md +68 -0
- package/templates/model-routing.claude.md +0 -9
package/README.md
CHANGED
|
@@ -283,7 +283,37 @@ One-time global setup. Detects your environment and registers project-brain with
|
|
|
283
283
|
project-brain setup
|
|
284
284
|
```
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
#### Model routing for sub-agents
|
|
287
|
+
|
|
288
|
+
Setup also writes model-routing guidance into each detected host's rules file: which **tier** — `fast`, `balanced`, or `deep` — a delegated sub-agent should run at for a given kind of task, and how to set that tier *on that host*.
|
|
289
|
+
|
|
290
|
+
Tiers rather than model names, because four of the six supported hosts default sub-agents to inheriting the parent's model and set the model in an agent-definition file rather than at the call — so "pass the `model` param" is true on Claude Code and false almost everywhere else. Each host gets its own text:
|
|
291
|
+
|
|
292
|
+
| Host | Where the model is chosen |
|
|
293
|
+
| --- | --- |
|
|
294
|
+
| Claude Code | per spawn — `model` on the Agent/Task call |
|
|
295
|
+
| Codex | `~/.codex/agents/*.toml`; per-spawn needs `[features.multi_agent_v2]` |
|
|
296
|
+
| Gemini CLI | `~/.gemini/agents/*.md` frontmatter `model:` |
|
|
297
|
+
| Cursor | sub-agent definition: `fast`, `inherit`, or a pinned id |
|
|
298
|
+
| opencode | `opencode.json` → `agent.<name>.model` (`provider/model-id`) |
|
|
299
|
+
| Windsurf | Devin Local routes tiers on its own |
|
|
300
|
+
|
|
301
|
+
It is opt-**out**: a non-interactive run installs it, and `--no-model-routing` is the way out. `--model-routing` forces it without prompting. The section carries a content version, so a later release updates it in place instead of leaving you on the text you first accepted.
|
|
302
|
+
|
|
303
|
+
Override the table in `~/.project-brain/model-routing.json`:
|
|
304
|
+
|
|
305
|
+
```json
|
|
306
|
+
{
|
|
307
|
+
"models": { "claude": { "deep": "opus" } },
|
|
308
|
+
"rules": [{ "task": "Write a migration", "tier": "deep", "why": "irreversible" }]
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
`models` remaps tiers per host, one tier at a time. `rules` adds a task, or retiers a built-in one by matching its `task` exactly. A malformed file warns and falls back to the defaults — it never fails setup.
|
|
313
|
+
|
|
314
|
+
**Hooks (Claude Code only).** Accepting the guidance also installs a `SessionStart` hook that injects the tier table once per session. Claude Code is the only host verified to fire `PreToolUse` on a sub-agent spawn and to accept `additionalContext` on `SessionStart`; a hook that silently never fires is worse than none.
|
|
315
|
+
|
|
316
|
+
Add `--routing-hook-strict` for enforcement: a `PreToolUse` hook that blocks a spawn naming no model and tells the model to re-issue it with one. Off by default — inheriting the session model is sometimes the right call, and the guard fails open on any payload it cannot parse. `--no-routing-hook` skips both.
|
|
287
317
|
|
|
288
318
|
### `init`
|
|
289
319
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "project-brain",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Local-first MCP server that gives AI tools semantic memory of your codebase.",
|
|
6
6
|
"author": "jcsoftdev",
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"zod": "^4.4.3"
|
|
50
50
|
},
|
|
51
51
|
"optionalDependencies": {
|
|
52
|
-
"project-brain-darwin-arm64": "0.
|
|
53
|
-
"project-brain-linux-x64": "0.
|
|
54
|
-
"project-brain-linux-arm64": "0.
|
|
55
|
-
"project-brain-windows-x64": "0.
|
|
56
|
-
"project-brain-windows-arm64": "0.
|
|
52
|
+
"project-brain-darwin-arm64": "0.20.0",
|
|
53
|
+
"project-brain-linux-x64": "0.20.0",
|
|
54
|
+
"project-brain-linux-arm64": "0.20.0",
|
|
55
|
+
"project-brain-windows-x64": "0.20.0",
|
|
56
|
+
"project-brain-windows-arm64": "0.20.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/bun": "latest",
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
## Model routing for delegated agents
|
|
2
|
+
|
|
3
|
+
<!-- model-routing-version: {{contentVersion}} -->
|
|
4
|
+
|
|
5
|
+
When spawning a sub-agent, pick its tier deliberately. Leaving every delegation
|
|
6
|
+
on the session's default model means paying deep-tier prices for lookups, or
|
|
7
|
+
getting fast-tier answers to questions that need judgment.
|
|
8
|
+
|
|
9
|
+
A tier is a claim about the work, not about a vendor's lineup:
|
|
10
|
+
|
|
11
|
+
{{tierMeanings}}
|
|
12
|
+
|
|
13
|
+
{{modelRoutingTable}}
|
|
14
|
+
|
|
15
|
+
Shortcut: sub-agent output is yes/no or a list → fast. Output is code or
|
|
16
|
+
synthesis → balanced. Output is "which approach is better" → deep.
|
|
17
|
+
|
|
18
|
+
**On {{hostName}}:** {{howToApply}}
|
|
19
|
+
{{labelRule}}
|
|
20
|
+
### When NOT to delegate
|
|
21
|
+
|
|
22
|
+
Delegation is not free — it pays a full context bootstrap before the sub-agent
|
|
23
|
+
reads its first line. Reading 1–3 files to decide or verify something is
|
|
24
|
+
cheaper inline. Delegate when the work is 4+ files of exploration, or any
|
|
25
|
+
read-then-write pair where the reading would otherwise land in your context and
|
|
26
|
+
stay there.
|
|
27
|
+
|
|
28
|
+
### Escalate, don't start deep
|
|
29
|
+
|
|
30
|
+
Run the fast tier first. On a failed or empty result, retry one tier up. Two
|
|
31
|
+
fast attempts plus one balanced still costs less than one deep attempt, and
|
|
32
|
+
most delegations never need the escalation.
|
|
33
|
+
|
|
34
|
+
### Verification must be asymmetric
|
|
35
|
+
|
|
36
|
+
Never verify with the model that produced the work — same blind spots, and it
|
|
37
|
+
rubber-stamps its own output. This is why adversarial review sits at `deep`
|
|
38
|
+
even when the code under review was written at `balanced`. The point is not a
|
|
39
|
+
better reader; it is a different one.
|
|
40
|
+
|
|
41
|
+
### Effort is a second axis
|
|
42
|
+
|
|
43
|
+
Where the host exposes a reasoning-effort setting, raise it before raising the
|
|
44
|
+
tier: balanced at high effort often beats deep at low effort, and costs less.
|
|
45
|
+
Tier and effort are independent knobs, and only one of them is usually the
|
|
46
|
+
answer.
|
|
47
|
+
|
|
48
|
+
### Run independent delegations in parallel
|
|
49
|
+
|
|
50
|
+
Delegations that do not depend on each other go out in one message. This is
|
|
51
|
+
orthogonal to tier and multiplies the saving — three fast lookups in parallel
|
|
52
|
+
cost the same tokens as three in sequence, and a third of the wall-clock.
|
|
53
|
+
|
|
54
|
+
### Relative cost
|
|
55
|
+
|
|
56
|
+
Order of magnitude, not a price list: fast ≈ 1×, balanced ≈ 5×, deep ≈ 25×.
|
|
57
|
+
Enough to calibrate a decision, coarse enough to stay true after a price
|
|
58
|
+
change.
|
|
59
|
+
|
|
60
|
+
### project-brain's own routing
|
|
61
|
+
|
|
62
|
+
`search_context` and explore-class questions return large results; run them
|
|
63
|
+
inside a sub-agent so your own context keeps the conclusion and not the
|
|
64
|
+
transcript. Structural lookups — `find_symbol`, `find_callers`, `find_callees`,
|
|
65
|
+
`impact` — return a handful of lines and belong inline.
|
|
66
|
+
|
|
67
|
+
Override any of this in `{{configPath}}`: `models` remaps tiers per host,
|
|
68
|
+
`rules` adds or retiers a task.
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
## Model routing for delegated agents
|
|
2
|
-
|
|
3
|
-
When spawning a sub-agent (Agent tool, Task tool, or workflow step), pick its model explicitly — don't leave it on the default for every call.
|
|
4
|
-
|
|
5
|
-
{{modelRoutingTable}}
|
|
6
|
-
|
|
7
|
-
Shortcut: sub-agent output is yes/no or a list → haiku. Output is code or synthesis → sonnet. Output is "which approach is better" → opus.
|
|
8
|
-
|
|
9
|
-
Pass the choice via the `model` param on the delegation call. Omit it only to inherit the current session's model.
|