project-brain 0.35.0 → 0.36.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 +27 -1
- package/package.json +6 -6
- package/templates/model-routing.md +14 -9
package/README.md
CHANGED
|
@@ -405,6 +405,31 @@ Override the table in `~/.project-brain/model-routing.json`:
|
|
|
405
405
|
|
|
406
406
|
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.
|
|
407
407
|
|
|
408
|
+
#### Architecture guard (opt-in)
|
|
409
|
+
|
|
410
|
+
A `PreToolUse` hook on `Edit`, `Write` and `MultiEdit` that blocks an edit which breaks your architecture boundaries. Not installed by default, because it stops a real tool call:
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
project-brain setup --with=hooks:arch-guard
|
|
414
|
+
project-brain arch init # writes .project-brain/architecture.json (hexagonal preset, mode "warn")
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
**Layer rules (deterministic, offline).** `.project-brain/architecture.json` names the layers and what may not depend on what:
|
|
418
|
+
|
|
419
|
+
```json
|
|
420
|
+
{
|
|
421
|
+
"layers": { "domain": "src/domain/**", "application": "src/application/**", "infrastructure": ["src/infra/**", "pkg:pg"] },
|
|
422
|
+
"forbid": [{ "from": "domain", "to": ["application", "infrastructure"] }],
|
|
423
|
+
"mode": "block"
|
|
424
|
+
}
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
A layer is a glob or an array of globs; `pkg:<name>` claims a third-party package, which is otherwise in no layer. Only the imports the edit **adds** are judged, so a violation already in the file never blocks an unrelated change. TS/JS (`import`, `export … from`, `require`, literal `import()`), Go (through the `go.mod` module path) and Python are understood; relative specifiers resolve against the edited file, trying extensions and `/index`. `tsconfig` `paths` aliases are not resolved yet. Import syntax is matched in code only, so an import written inside a string, template or docstring is not a dependency. Only an explicit `"mode": "block"` blocks; a missing or unrecognised mode, and a file that is not valid JSON, mean `"warn"`. A warning is delivered to Claude as `additionalContext` next to the tool result, and a malformed file means no check, never a crash.
|
|
428
|
+
|
|
429
|
+
**Constraints (fuzzy, needs a TypeSafe token).** Any `type: Constraint` concept in `okf/` whose `resource:` anchor covers the edited file is put to Jev as a yes/no question; the edit is blocked when P(violates) is above 0.8. A directory anchor with a trailing slash (`resource: ../src/domain/`) covers every file under it. This layer sends the edit and the constraint text to `api.typesafe.ai`, and only runs when a token resolves (the same one the reranker uses). With no token it is skipped, and a timeout or error lets the edit through. It blocks only when `architecture.json` exists and says `"mode": "block"` (the file may hold nothing else); with no file it only warns, so a token you keep for reranking never stops an edit. At most 10 constraints are asked per edit, the most specific anchors first.
|
|
430
|
+
|
|
431
|
+
The hook reads stdin and fails open on anything it cannot parse. A block exits `2` with the reason on stderr, which Claude Code hands to the model as the retry prompt.
|
|
432
|
+
|
|
408
433
|
### `init`
|
|
409
434
|
|
|
410
435
|
Initialize a project. Detects the stack, writes a `CLAUDE.md` with MCP instructions, installs a git hook, scaffolds module stubs in `docs/modules/`, and indexes the project.
|
|
@@ -497,7 +522,7 @@ project-brain okf audit --json # one JSON object instead of prose, f
|
|
|
497
522
|
project-brain okf audit --judge # ask Claude whether a stale finding's reasoning still holds
|
|
498
523
|
```
|
|
499
524
|
|
|
500
|
-
`--judge` is opt-in and costs money: it sends `claude-opus-5` the concept's prose plus the actual code diff, for every `stale` finding where the code moved but the reasoning might not have (never for `uncommitted`, `expired`, or a broken anchor). Needs Anthropic credentials (`ANTHROPIC_API_KEY` or `ant auth login`) — without them the run aborts judging and falls back to the plain, unjudged audit. A "still holds" verdict never auto-attests; it only moves the finding into a non-failing `judged` backlog for a human to confirm with a `verified` entry.
|
|
525
|
+
`--judge` is opt-in and costs money: it sends `claude-opus-5-5` the concept's prose plus the actual code diff, for every `stale` finding where the code moved but the reasoning might not have (never for `uncommitted`, `expired`, or a broken anchor). Needs Anthropic credentials (`ANTHROPIC_API_KEY` or `ant auth login`) — without them the run aborts judging and falls back to the plain, unjudged audit. A "still holds" verdict never auto-attests; it only moves the finding into a non-failing `judged` backlog for a human to confirm with a `verified` entry.
|
|
501
526
|
|
|
502
527
|
`init` writes `index.md` and `log.md` and stops — **no seeded concepts**, because a bundle shipped with examples makes the first `audit` report coverage gaps across the whole repo. Type directories appear when the first concept needs them.
|
|
503
528
|
|
|
@@ -563,6 +588,7 @@ BRAIN_HTTP_TOKEN=your-secret project-brain serve --http [--port 3000]
|
|
|
563
588
|
| `BRAIN_EMBED_MODEL` | `qwen3-embedding:0.6b` | Ollama embedding model (registry keys: `qwen3-embedding`, `nomic-text`; or any raw Ollama model name; `none` disables embeddings — lexical/keyword search only, no Ollama needed) |
|
|
564
589
|
| `OLLAMA_HOST` | `http://127.0.0.1:11434` | Ollama server URL |
|
|
565
590
|
| `BRAIN_NO_UPDATE_CHECK` | — | Set to `1` to disable the update-available notice |
|
|
591
|
+
| `BRAIN_CONCEPT_MODEL` | `claude-haiku-5-5` | Anthropic model id `conceptualize` uses to write module concepts. Read on each call. Same credentials as `--judge` (`ANTHROPIC_API_KEY` or `ant auth login`). |
|
|
566
592
|
| `TYPESAFE_API_KEY` | — | Opt-in Jev reranker token — see [Reranking (optional)](#reranking-optional). Checked before `~/.project-brain/reranker.json`. |
|
|
567
593
|
|
|
568
594
|
## Tuning (environment variables)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "project-brain",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.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.36.0",
|
|
53
|
+
"project-brain-linux-x64": "0.36.0",
|
|
54
|
+
"project-brain-linux-arm64": "0.36.0",
|
|
55
|
+
"project-brain-windows-x64": "0.36.0",
|
|
56
|
+
"project-brain-windows-arm64": "0.36.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/bun": "latest",
|
|
@@ -16,7 +16,7 @@ Shortcut: sub-agent output is yes/no or a list → fast. Output is code or
|
|
|
16
16
|
synthesis → balanced. Output is "which approach is better" → deep.
|
|
17
17
|
|
|
18
18
|
**On {{hostName}}:** {{howToApply}}
|
|
19
|
-
{{labelRule}}
|
|
19
|
+
{{labelRule}}{{advisorRule}}
|
|
20
20
|
### When NOT to delegate
|
|
21
21
|
|
|
22
22
|
Delegation is not free — it pays a full context bootstrap before the sub-agent
|
|
@@ -29,9 +29,9 @@ stay there.
|
|
|
29
29
|
|
|
30
30
|
Run the cheapest tier the task table allows. On a failed or empty result,
|
|
31
31
|
retry one tier up. The escalation pays because most delegations never need it,
|
|
32
|
-
|
|
33
|
-
table already puts at `deep` goes there first: a wrong answer from a
|
|
34
|
-
tier costs a retry plus the parent's turns spent acting on it.
|
|
32
|
+
and because the fast tier is far cheaper than the rest — see Relative cost.
|
|
33
|
+
A task the table already puts at `deep` goes there first: a wrong answer from a
|
|
34
|
+
cheaper tier costs a retry plus the parent's turns spent acting on it.
|
|
35
35
|
|
|
36
36
|
### Verification must be asymmetric
|
|
37
37
|
|
|
@@ -57,11 +57,16 @@ cost the same tokens as three in sequence, and a third of the wall-clock.
|
|
|
57
57
|
|
|
58
58
|
### Relative cost
|
|
59
59
|
|
|
60
|
-
Per token, at list price
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
Per token, at list price, the gaps are uneven. On the Claude lineup, fast to
|
|
61
|
+
balanced (Haiku 5.5 to Sonnet 5.5) is about 20×, balanced to deep (Sonnet 5.5
|
|
62
|
+
to Opus 5.5) is 2×, and Fable 5.1 is 2.5× Opus. So moving a lookup down to fast
|
|
63
|
+
saves far more than moving a judgment call down from deep, and a failed fast
|
|
64
|
+
attempt retried one tier up still costs a fraction of starting at balanced.
|
|
65
|
+
Between balanced and deep the price rarely settles the choice: what does is the
|
|
66
|
+
tokens spent. A deeper tier at high effort thinks longer, and a cheap tier that
|
|
67
|
+
gets it wrong costs a retry and the parent's turns acting on it. Judge by the
|
|
68
|
+
cost of the finished task, not of one call.
|
|
69
|
+
(https://platform.claude.com/docs/en/models/overview.md)
|
|
65
70
|
|
|
66
71
|
### project-brain's own routing
|
|
67
72
|
|