project-brain 0.16.1 → 0.18.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 +73 -18
- package/bin/project-brain +13 -1
- package/package.json +6 -6
- package/templates/project.claude.md +1 -1
- package/templates/skills/brain-okf/SKILL.md +157 -0
package/README.md
CHANGED
|
@@ -6,18 +6,35 @@ project-brain indexes your project files into a local LanceDB vector store using
|
|
|
6
6
|
|
|
7
7
|
## Quick Start
|
|
8
8
|
|
|
9
|
+
**1. Install globally.** Pick *one* line — they all deliver the same self-contained binary:
|
|
10
|
+
|
|
9
11
|
```bash
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
brew install jcsoftdev/tap/project-brain # Homebrew
|
|
13
|
+
curl -fsSL https://raw.githubusercontent.com/jcsoftdev/project-brain/main/scripts/install.sh | sh # no package manager
|
|
14
|
+
bun install -g project-brain # or npm / pnpm / yarn
|
|
15
|
+
```
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
**2. Register in your AI tools.** Once per machine — Claude, Codex, Cursor, Gemini, Windsurf, Zed, VS Code. Also installs the `brain-audit` and `brain-okf` host skills (`--no-skills` to opt out):
|
|
18
|
+
|
|
19
|
+
```bash
|
|
14
20
|
project-brain setup
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**3. Initialize a project.** Detects the stack, indexes it, installs the git hook:
|
|
15
24
|
|
|
16
|
-
|
|
25
|
+
```bash
|
|
17
26
|
cd my-project
|
|
18
27
|
project-brain init
|
|
19
28
|
```
|
|
20
29
|
|
|
30
|
+
**4. Optional — start a knowledge bundle** for the *why*, not the *what*:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
project-brain okf init
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
See [Install](#install) for every channel, the platforms each covers, and how upgrades work.
|
|
37
|
+
|
|
21
38
|
After `init`, the following run **automatically** without any extra steps:
|
|
22
39
|
|
|
23
40
|
| Trigger | What happens |
|
|
@@ -28,29 +45,60 @@ After `init`, the following run **automatically** without any extra steps:
|
|
|
28
45
|
|
|
29
46
|
## Prerequisites
|
|
30
47
|
|
|
31
|
-
- **Nothing extra to run it.**
|
|
48
|
+
- **Nothing extra to run it.** Every channel ships the same self-contained, prebuilt binary per platform, with the runtime, WASM grammars and templates bundled in — you do **not** need Bun or Node installed to use project-brain. The `curl` installer does not even need one to *install* it.
|
|
32
49
|
- **Bun** ≥ 1.3.14 — only needed to build/run **from source** ([install](https://bun.sh)).
|
|
33
50
|
- **Ollama** (optional, only for semantic search) — download from [ollama.com](https://ollama.com). `project-brain init` **auto-pulls** the default embedding model `qwen3-embedding:0.6b` (1024-dim, fast, code-capable). To pre-pull it: `ollama pull qwen3-embedding:0.6b`. If it can't be pulled, project-brain falls back to `nomic-embed-text`. The structural tools work with **no** Ollama at all.
|
|
34
51
|
|
|
35
52
|
## Install
|
|
36
53
|
|
|
37
|
-
|
|
54
|
+
Every channel ships the same artifact: a `bun build --compile` binary with the
|
|
55
|
+
runtime, WASM grammars and templates embedded. Nothing else is needed at runtime.
|
|
56
|
+
|
|
57
|
+
| Channel | Command | Platforms | Upgrade with |
|
|
58
|
+
|---|---|---|---|
|
|
59
|
+
| **Homebrew** | `brew install jcsoftdev/tap/project-brain` | macOS (Apple Silicon), Linux | `brew upgrade project-brain` |
|
|
60
|
+
| **curl** | see [below](#curl-no-package-manager) | macOS (Apple Silicon), Linux x64/arm64 | re-run the installer |
|
|
61
|
+
| **Registry** | `bun install -g project-brain` (or npm / pnpm / yarn) | all, including Intel macOS and Windows | `project-brain update` |
|
|
62
|
+
| **Scoop** | `scoop install project-brain` — *bucket not published yet* | Windows | `scoop update project-brain` |
|
|
63
|
+
|
|
64
|
+
**Intel macOS**: no prebuilt binary. Homebrew and curl both refuse rather than
|
|
65
|
+
hand you an arm64 binary — use a registry install there.
|
|
66
|
+
|
|
67
|
+
`project-brain update` reads the binary's own path to work out which channel
|
|
68
|
+
installed it and prints the matching command. For a channel it cannot drive it
|
|
69
|
+
says so rather than guessing: a guessed `npm install -g` would leave a second
|
|
70
|
+
copy shadowing the first.
|
|
71
|
+
|
|
72
|
+
### curl (no package manager)
|
|
38
73
|
|
|
39
74
|
```bash
|
|
40
|
-
|
|
41
|
-
# or
|
|
42
|
-
npm install -g project-brain
|
|
75
|
+
curl -fsSL https://raw.githubusercontent.com/jcsoftdev/project-brain/main/scripts/install.sh | sh
|
|
43
76
|
```
|
|
44
77
|
|
|
45
|
-
|
|
78
|
+
| Variable | Default | Purpose |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `BRAIN_INSTALL_DIR` | `~/.local/bin` | Where the binary lands |
|
|
81
|
+
| `BRAIN_VERSION` | latest release | Pin a tag, e.g. `v0.17.0` |
|
|
82
|
+
|
|
83
|
+
The script verifies the downloaded binary actually runs on your machine before
|
|
84
|
+
moving it onto your PATH, so a wrong-arch or truncated download fails at install
|
|
85
|
+
time instead of at first use.
|
|
86
|
+
|
|
87
|
+
### Build it yourself
|
|
46
88
|
|
|
47
89
|
```bash
|
|
48
|
-
git clone https://github.com/jcsoftdev/project-brain
|
|
90
|
+
git clone git@github.com:jcsoftdev/project-brain.git # or https://github.com/jcsoftdev/project-brain.git
|
|
49
91
|
cd project-brain
|
|
50
|
-
bun build ./src/cli.ts --compile --outfile project-brain
|
|
51
|
-
./project-brain --
|
|
92
|
+
bun build ./src/cli.ts ./src/parser/worker.ts --compile --outfile project-brain
|
|
93
|
+
./project-brain --version
|
|
52
94
|
```
|
|
53
95
|
|
|
96
|
+
`worker.ts` is a required second entrypoint — without it the parser's worker pool cannot resolve its own imports inside the compiled binary and silently extracts zero symbols.
|
|
97
|
+
|
|
98
|
+
### Keeping the host skills current
|
|
99
|
+
|
|
100
|
+
Skills live in your assistant's global skills directory, not in the package, so upgrading the binary does not move them. project-brain compares the installed skill content against what the running binary carries and refreshes any directory it originally created — whichever way you upgraded. It never creates one (that is `setup`'s job) and never touches a directory it cannot prove it wrote. Opt out with `BRAIN_NO_SKILL_REFRESH=1`.
|
|
101
|
+
|
|
54
102
|
## Usage modes
|
|
55
103
|
|
|
56
104
|
project-brain runs in two modes — CLI and inside AI tools. Both call the same underlying commands.
|
|
@@ -73,19 +121,20 @@ Once `project-brain setup` has registered the MCP server in your AI tool, you ca
|
|
|
73
121
|
|
|
74
122
|
These five are thin wrappers over the CLI. **project-brain does not install them** — write them yourself as skills in your assistant's global skills directory if you want the shortcuts, or just run the CLI.
|
|
75
123
|
|
|
76
|
-
###
|
|
124
|
+
### Host skills setup installs
|
|
77
125
|
|
|
78
126
|
| Skill | Equivalent CLI | What it does |
|
|
79
127
|
|---|---|---|
|
|
80
128
|
| `/brain-audit` | *(none — host skill)* | Whole-project audit: dead code, orphan UI, broken flows, coverage gaps, plus findings by severity across security, performance and architecture |
|
|
129
|
+
| `/brain-okf` | *(none — host skill)* | Write an OKF concept: the reasoning behind code, anchored to a verified symbol and checkable by `okf audit` |
|
|
81
130
|
|
|
82
|
-
Unlike the `/brain-*` commands above,
|
|
131
|
+
Unlike the `/brain-*` commands above, these have no CLI equivalent. They are **host skills**: the logic lives in `SKILL.md` and runs inside the assistant, which calls project-brain's MCP tools to do the work. That is what lets `brain-audit` answer "is this export dead?" with `find_callers` instead of guessing from a grep, and what lets `brain-okf` verify an anchor with `find_symbol` before writing it.
|
|
83
132
|
|
|
84
|
-
`project-brain setup` installs
|
|
133
|
+
`project-brain setup` installs them into each registered tool's global skills directory (`~/.claude/skills/`, `~/.codex/skills/`, or the shared `~/.agents/skills/`). Opt out with `project-brain setup --no-skills` (`--no-brain-audit` still works as an alias).
|
|
85
134
|
|
|
86
|
-
|
|
135
|
+
**Both are offered, not scheduled.** Nothing invokes them for you and nothing fires on commit — you decide when. `brain-audit` runs discovery, proposes an audit module set, and waits for you to confirm before loading anything: 34 modules exist, and loading all of them every time is what makes an audit expensive. `brain-okf` proposes the type, title, and anchor and waits before creating a file, because whether an insight deserves a permanent home is your call, not the assistant's.
|
|
87
136
|
|
|
88
|
-
Setup never overwrites a
|
|
137
|
+
Setup never overwrites a skill directory it did not create. Ownership is proven per directory, so your own hand-written `brain-okf/` is left untouched — and reported — while `brain-audit/` upgrades beside it.
|
|
89
138
|
|
|
90
139
|
## MCP Tools
|
|
91
140
|
|
|
@@ -239,12 +288,17 @@ project-brain code "chargeCard" --limit 5
|
|
|
239
288
|
The index answers "what does this code do". It cannot answer "why is it like this", because that never existed in the AST. An **[Open Knowledge Format](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md) v0.2 bundle** — a committed directory of Markdown files with YAML frontmatter — holds that half, and `okf` keeps the two halves honest about each other.
|
|
240
289
|
|
|
241
290
|
```bash
|
|
291
|
+
project-brain okf init [dir] # scaffold an empty bundle. Never overwrites.
|
|
242
292
|
project-brain okf validate [dir] # conformance (SPEC §11). Offline.
|
|
243
293
|
project-brain okf sync [dir] # index the concepts so search returns them
|
|
244
294
|
project-brain okf audit [dir] # cross-check the bundle against the code graph
|
|
245
295
|
project-brain okf audit --symbol <name> # which concepts to re-read after <name> changes
|
|
246
296
|
```
|
|
247
297
|
|
|
298
|
+
`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.
|
|
299
|
+
|
|
300
|
+
It also re-renders `CLAUDE.md`. `project-brain init` runs before any bundle exists, so the knowledge-bundle section is omitted then; `okf init` adds it once there is something to point at. That section asks the assistant to **decide, at the end of a task, whether anything belongs in the bundle** — and says plainly that most tasks produce nothing. A checkpoint that feels obliged to produce a file is a concept mill, and noise in a knowledge bundle is worse than gaps. Projects with no bundle never see the instruction.
|
|
301
|
+
|
|
248
302
|
`dir` defaults to `./okf`. Because the bundle is tracked in git, a plain `project-brain sync` also keeps it fresh — bundle files are routed through the curated projection instead of being chunked as raw markdown, so `search_context` returns the reasoning next to the code it explains.
|
|
249
303
|
|
|
250
304
|
A concept anchors code through `resource` (and `sources[]`), resolved from the bundle root:
|
|
@@ -316,6 +370,7 @@ BRAIN_HTTP_TOKEN=your-secret project-brain serve --http [--port 3000]
|
|
|
316
370
|
| `BRAIN_EMBED_CONCURRENCY` | `1` | `1`–`16` | Concurrent embed requests. Defaults to `1` — a single local Ollama instance is GPU-compute-bound, so concurrency>1 adds no throughput, only false-timeout risk. Raise it only against a genuine multi-host pool (`BRAIN_OLLAMA_HOSTS`) or remote inference API where separate hardware actually runs requests in parallel. |
|
|
317
371
|
| `BRAIN_OLLAMA_HOSTS` | — | comma-separated URLs | Pool of Ollama hosts for round-robin embedding (e.g. `http://127.0.0.1:11434,http://127.0.0.1:11435`). Falls through to the next host on failure; only `null`s when every host fails. |
|
|
318
372
|
| `BRAIN_EMBED_MODEL` | `qwen3-embedding:0.6b` | model name | Override the embedding model (see table above). |
|
|
373
|
+
| `BRAIN_SYNC_WINDOW_FILES` | `200` | `1`+ | Files held in memory at once during a sync. Their content, chunks and vectors are live together and released when the window is stored, so peak memory tracks this number rather than repository size. Lower it on a memory-constrained host; raising it buys nothing once a window already fills an embed batch. |
|
|
319
374
|
|
|
320
375
|
A partial or total embed failure makes `sync`/`reindex` exit non-zero (`1`) — check the exit code in automation (CI, git hooks), not just stderr text.
|
|
321
376
|
|
package/bin/project-brain
CHANGED
|
@@ -42,7 +42,19 @@ try {
|
|
|
42
42
|
// Setting process.env mid-process (in this parent, or inside cli.ts)
|
|
43
43
|
// is too late and the "vector index statistics include centroids" WARN
|
|
44
44
|
// still fires.
|
|
45
|
-
env: {
|
|
45
|
+
env: {
|
|
46
|
+
...process.env,
|
|
47
|
+
LANCE_INCLUDE_VECTOR_CENTROIDS: process.env.LANCE_INCLUDE_VECTOR_CENTROIDS ?? "false",
|
|
48
|
+
// Which pid the long-running `serve` should treat as its client.
|
|
49
|
+
//
|
|
50
|
+
// execFileSync blocks this shim for the child's whole life, so the child's
|
|
51
|
+
// parent is THIS process, not the AI tool that launched it. A server that
|
|
52
|
+
// watched its parent would see the shim alive forever and never notice the
|
|
53
|
+
// tool crashing — the leak that left servers running for days. Hand down
|
|
54
|
+
// our own parent so it watches the tool. Already-set wins, so a caller can
|
|
55
|
+
// point it somewhere deliberately.
|
|
56
|
+
BRAIN_CLIENT_PID: process.env.BRAIN_CLIENT_PID ?? String(process.ppid),
|
|
57
|
+
},
|
|
46
58
|
});
|
|
47
59
|
} catch (err) {
|
|
48
60
|
if (err && typeof err.status === "number") process.exit(err.status);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "project-brain",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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.18.0",
|
|
53
|
+
"project-brain-linux-x64": "0.18.0",
|
|
54
|
+
"project-brain-linux-arm64": "0.18.0",
|
|
55
|
+
"project-brain-windows-x64": "0.18.0",
|
|
56
|
+
"project-brain-windows-arm64": "0.18.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/bun": "latest",
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brain-okf
|
|
3
|
+
description: "Trigger: write this down, capture why, record this decision, document this gotcha, add an OKF concept, knowledge bundle, why is it like this, save this for next time. Writes an Open Knowledge Format v0.2 concept — the reasoning behind code that no AST can hold — anchored to real symbols and validated against the code graph."
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
metadata:
|
|
6
|
+
author: jcsoftdev
|
|
7
|
+
version: "1.0"
|
|
8
|
+
generator: project-brain
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<!--
|
|
12
|
+
`generator: project-brain` is an ownership marker, not decoration.
|
|
13
|
+
`project-brain setup` overwrites this directory only when it finds that line;
|
|
14
|
+
without it, setup treats the directory as hand-written and leaves it alone.
|
|
15
|
+
Strip it and you pin this copy forever — no upgrade will ever reach it.
|
|
16
|
+
-->
|
|
17
|
+
|
|
18
|
+
## Activation Contract
|
|
19
|
+
|
|
20
|
+
Apply when a **specific piece of reasoning** is worth keeping: a fix that surprised someone, a decision with a real rejected alternative, a constraint that must not be violated, a gotcha that cost time. The knowledge already exists in the conversation — this skill turns it into an anchored, auditable file.
|
|
21
|
+
|
|
22
|
+
**You are never required to invoke this.** It is offered, not scheduled. There is no hook, no per-commit trigger, and there should not be — see "Why this is not automated" below.
|
|
23
|
+
|
|
24
|
+
Do not apply when: the ask is "document this module" or "explain what this code does" (that is `conceptualize`, below); the project has no `okf/` bundle and the user has not asked to start one; or the insight is a restatement of the diff.
|
|
25
|
+
|
|
26
|
+
### End of a task is a checkpoint, not a quota
|
|
27
|
+
|
|
28
|
+
A project whose CLAUDE.md carries the knowledge-bundle section is asking for one thing at the end of a piece of work: **decide whether anything belongs in the bundle.** Deciding is the whole obligation. Three things qualify:
|
|
29
|
+
|
|
30
|
+
- A fix whose **cause was surprising** — the symptom pointed somewhere else.
|
|
31
|
+
- A decision where a **real alternative was rejected**, and the reason is not obvious from the result.
|
|
32
|
+
- A **constraint** that must keep holding, where violating it breaks something non-locally.
|
|
33
|
+
|
|
34
|
+
**Most tasks produce nothing, and that is the expected answer.** Say so in one line and move on. A checkpoint that feels obliged to produce a file is a concept mill, and noise in a knowledge bundle is worse than gaps — it destroys the signal that made the bundle worth reading.
|
|
35
|
+
|
|
36
|
+
If a project has no bundle, `project-brain okf init` scaffolds an empty one and re-renders the project rules so the host learns it exists. Propose that; do not create it unasked.
|
|
37
|
+
|
|
38
|
+
## Two knowledge layers — do not conflate them
|
|
39
|
+
|
|
40
|
+
| | `conceptualize` (already automatic) | OKF concept (this skill) |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| Runs | every commit, via the post-commit git hook | only when a human decides |
|
|
43
|
+
| Scope | a whole module | one specific insight |
|
|
44
|
+
| Answers | what this module does and how | **why it is like this** |
|
|
45
|
+
| Written by | an LLM from the commit diff | a human, or you with the human's confirmation |
|
|
46
|
+
| Anchored | no | yes — to a file, symbol, or line range |
|
|
47
|
+
| Audited | no | yes — broken anchors and staleness are CI-gateable |
|
|
48
|
+
|
|
49
|
+
If the answer lives in the diff, it is not a concept. `conceptualize` already has it.
|
|
50
|
+
|
|
51
|
+
## Hard Rules
|
|
52
|
+
|
|
53
|
+
- **Propose before writing.** State the `type`, `title`, and the `resource` anchor you intend, and wait. The user decides whether the insight is worth a permanent file. Never create concepts unprompted or in bulk.
|
|
54
|
+
- **One insight per file.** A concept that needs two titles is two concepts.
|
|
55
|
+
- **The anchor must be verified, not guessed.** Run `find_symbol` on the symbol you plan to cite before writing it. An anchor that does not resolve is a `Broken anchor` finding the moment anyone runs `audit`.
|
|
56
|
+
- **Never invent the "how it was found".** If you did not observe the debugging, say the concept needs that section filled in by whoever did.
|
|
57
|
+
- Write for the reader who hits this in eight months with no context. Assume they know the language and nothing about this incident.
|
|
58
|
+
- Prose carries the value. The frontmatter is plumbing — do not spend the user's attention on YAML.
|
|
59
|
+
|
|
60
|
+
## Why this is not automated
|
|
61
|
+
|
|
62
|
+
Three reasons, each worth knowing before someone proposes a hook again:
|
|
63
|
+
|
|
64
|
+
1. **The input is not in the diff.** A concept comes from "this surprised me", which no diff contains. `conceptualize` works as a hook precisely because a diff *determines* module docs; nothing determines a concept.
|
|
65
|
+
2. **The frequency does not match.** Concepts are rare — a mature bundle holds tens, not thousands. A per-commit trigger fires a hundred times per concept actually written, and an alert nobody acts on trains everyone to ignore alerts.
|
|
66
|
+
3. **`audit`'s coverage gaps are NOT a work queue.** They rank by PageRank, which measures structural centrality, not explanatory need. On a real run the top of that list was `get`, `set`, `key`, `close`, `jsonResult`, `normalize` — cache accessors and formatters, every one of which has zero interesting *why*. Treat coverage gaps as a hint about *areas*, never as a list of files to generate.
|
|
67
|
+
|
|
68
|
+
## File shape
|
|
69
|
+
|
|
70
|
+
Path: `okf/<type-pluralised>/<kebab-slug>.md`. Existing convention: `decisions/`, `gotchas/`, `constraints/`.
|
|
71
|
+
|
|
72
|
+
```markdown
|
|
73
|
+
---
|
|
74
|
+
type: Gotcha
|
|
75
|
+
title: Language.load ignores Bun's /$bunfs virtual filesystem
|
|
76
|
+
description: One line — the cost of not knowing this.
|
|
77
|
+
tags: [parser, bun, wasm]
|
|
78
|
+
resource: ../src/parser/wasm.ts
|
|
79
|
+
sources:
|
|
80
|
+
- resource: ../src/okf/audit.ts#findStale
|
|
81
|
+
title: Why this other file also matters
|
|
82
|
+
status: stable
|
|
83
|
+
generated: { by: "human:<handle>", at: 2026-07-30T00:00:00Z }
|
|
84
|
+
---
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`validate` enforces exactly two things: a parseable frontmatter block, and a non-empty `type` (SPEC §11.1–11.2). The spec **forbids** rejecting a document for missing optional fields, and the `type` value is not constrained — the vocabulary is the bundle's convention, not a schema.
|
|
88
|
+
|
|
89
|
+
That means everything else is optional, and every optional field still earns its place:
|
|
90
|
+
|
|
91
|
+
| Field | What it buys |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `resource` | The anchor. **Without it the concept is invisible to `audit`** — no broken-anchor check, no staleness check. This is what separates knowledge from a note. |
|
|
94
|
+
| `sources[]` | Additional anchors. Each one is watched independently. |
|
|
95
|
+
| `generated.at` | The staleness baseline. Absent, `audit` falls back to the concept file's own commit date. |
|
|
96
|
+
| `title` / `description` | How it reads in a list and in search results. |
|
|
97
|
+
| `tags` | Retrieval. |
|
|
98
|
+
| `status` | `stable`, or say it is provisional. |
|
|
99
|
+
|
|
100
|
+
## Anchors
|
|
101
|
+
|
|
102
|
+
Three forms, least to most precise. Resolved **from the bundle root**, which is why they start with `../`:
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
resource: ../src/parser/wasm.ts # whole file
|
|
106
|
+
resource: ../src/hooks/git.ts#installGitHook # symbol — prefer this
|
|
107
|
+
resource: ../src/commands/sync.ts#L478-L499 # line range
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Choosing:
|
|
111
|
+
|
|
112
|
+
- **Symbol** is the default. It survives the file moving within itself, and `find_symbol` proves it exists.
|
|
113
|
+
- **Whole file** when the reasoning is about the file's role, not one function.
|
|
114
|
+
- **Line range** only when the point is a specific few lines with no symbol boundary. It is the most fragile form: a range claims only what fits inside it, and if the file shrinks past that range the anchor breaks — which is correct behaviour, not a bug. `audit` surfaces it rather than silently downgrading to "unknown".
|
|
115
|
+
|
|
116
|
+
Verify before writing. `find_symbol <name>` gives the path and line range; if it returns nothing, the anchor is wrong.
|
|
117
|
+
|
|
118
|
+
## Body conventions
|
|
119
|
+
|
|
120
|
+
Free markdown — but these shapes are what makes the bundle readable as a set:
|
|
121
|
+
|
|
122
|
+
**Gotcha** — `# Symptom` (what a person actually sees, including the exact error text) → `# Why` (the mechanism) → `# Fix` (the code) → `# How it was found` (the procedure that isolated it — often the most reusable part).
|
|
123
|
+
|
|
124
|
+
**Decision** — `# Why <chosen>` → **the rejected alternative and what it cost**. A decision with no stated alternative is a description, and it cannot be revisited later because nobody knows what it traded against.
|
|
125
|
+
|
|
126
|
+
**Constraint** — what must hold, and **what breaks if it does not**. State the failure, not the rule.
|
|
127
|
+
|
|
128
|
+
Cross-link with bundle-root paths: `[title](/constraints/guards-must-be-seen-failing.md)`.
|
|
129
|
+
|
|
130
|
+
## Flow
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
project-brain okf validate # conformance, offline, no embeddings
|
|
134
|
+
project-brain okf sync # index the concepts so search returns them
|
|
135
|
+
project-brain okf audit # cross-check against the code graph
|
|
136
|
+
project-brain okf audit --symbol <name> # which concepts to re-read after <name> changes
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Run `validate` before finishing. A plain `project-brain sync` also keeps the bundle fresh, since it is tracked in git.
|
|
140
|
+
|
|
141
|
+
`audit` exits 1 on **broken anchors** and **stale concepts**, so it works as a CI gate. Coverage gaps and link suggestions are backlog and never fail the run.
|
|
142
|
+
|
|
143
|
+
## Clearing a stale finding
|
|
144
|
+
|
|
145
|
+
A concept is stale when the cited code changed after the knowledge was last confirmed. The fix is not to edit the date — it is to **re-read the concept and confirm it still holds**, then record that:
|
|
146
|
+
|
|
147
|
+
```yaml
|
|
148
|
+
verified:
|
|
149
|
+
- by: "human:<handle>"
|
|
150
|
+
at: 2026-07-30T00:00:00Z
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`verified[]` is a list, and the staleness baseline is the newest `at` across `generated` and every `verified` entry. Appending an entry also changes the file, so its own commit date moves — the finding clears either way. If the concept no longer holds, rewrite the prose instead; a `verified` stamp on wrong knowledge is worse than a stale flag.
|
|
154
|
+
|
|
155
|
+
## Output Contract
|
|
156
|
+
|
|
157
|
+
When you write a concept, report: the path created, the `type` and `title`, every anchor and the symbol it resolved to, and the `validate` result. If any section was left for the user to fill in, say which and why.
|