project-brain 0.18.2 → 0.19.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 CHANGED
@@ -6,36 +6,79 @@ 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:
9
+ Three commands, roughly two minutes:
10
10
 
11
11
  ```bash
12
- brew install jcsoftdev/tap/project-brain # Homebrew
12
+ brew install jcsoftdev/tap/project-brain # 1. install (see below for other channels)
13
+ project-brain setup # 2. register in your AI tools — once per machine
14
+ cd my-project && project-brain init # 3. index this project
15
+ ```
16
+
17
+ That is the whole setup. The rest of this section explains what each step did and how to confirm it worked.
18
+
19
+ ### 1. Install
20
+
21
+ Pick **one**. All three deliver the same self-contained binary — no Node, no Bun, nothing else at runtime:
22
+
23
+ ```bash
24
+ brew install jcsoftdev/tap/project-brain # Homebrew
13
25
  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
26
+ bun install -g project-brain # or npm / pnpm / yarn
27
+ ```
28
+
29
+ Confirm it landed:
30
+
31
+ ```bash
32
+ project-brain --version
15
33
  ```
16
34
 
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):
35
+ See [Install](#install) for platform coverage and how upgrades work per channel.
36
+
37
+ ### 2. Register in your AI tools
18
38
 
19
39
  ```bash
20
40
  project-brain setup
21
41
  ```
22
42
 
23
- **3. Initialize a project.** Detects the stack, indexes it, installs the git hook:
43
+ Detects and registers project-brain with Claude, Codex, Cursor, Gemini, Windsurf, Zed and VS Code, and installs the `brain-audit` and `brain-okf` host skills. Run it **once per machine**, not per project. Skip the skills with `--no-skills`.
44
+
45
+ ### 3. Index a project
24
46
 
25
47
  ```bash
26
48
  cd my-project
27
49
  project-brain init
28
50
  ```
29
51
 
30
- **4. Optional — start a knowledge bundle** for the *why*, not the *what*:
52
+ Detects the stack, writes a `CLAUDE.md` with MCP instructions, installs a `git commit` hook, scaffolds module stubs, and runs the first index.
53
+
54
+ No Ollama running? Use `project-brain init --no-embed`. Everything structural still works — see [What you get without Ollama](#what-you-get-without-ollama).
55
+
56
+ ### 4. Check it worked
31
57
 
32
58
  ```bash
33
- project-brain okf init
59
+ project-brain health
60
+ ```
61
+
62
+ Reports embedding service, index counts and staleness. If chunks are `0` or semantic results come back empty, this is the command that tells you why.
63
+
64
+ ### 5. Use it
65
+
66
+ From the terminal:
67
+
68
+ ```bash
69
+ project-brain map # what matters in this codebase, ranked
70
+ project-brain impact parseConfig # what breaks if I change this
71
+ project-brain callers runSync # who depends on this
34
72
  ```
35
73
 
36
- See [Install](#install) for every channel, the platforms each covers, and how upgrades work.
74
+ Or just ask your AI assistant in plain language — it picks the tool itself:
75
+
76
+ > "What breaks if I change `parseConfig`?"
77
+ > "How does authentication work here?"
37
78
 
38
- After `init`, the following run **automatically** without any extra steps:
79
+ See [Recipes](#recipes--get-the-most-out-of-it) for the prompts that steer it best.
80
+
81
+ ### What runs automatically after `init`
39
82
 
40
83
  | Trigger | What happens |
41
84
  |---|---|
@@ -43,11 +86,33 @@ After `init`, the following run **automatically** without any extra steps:
43
86
  | File save (while server is running) | File watcher detects the change and re-indexes it |
44
87
  | AI tool connects | MCP server starts on stdio, tools are ready |
45
88
 
89
+ ### What you get without Ollama
90
+
91
+ Ollama powers **semantic** search only. Everything else works offline with no model at all:
92
+
93
+ | Works with no Ollama | Needs Ollama |
94
+ |---|---|
95
+ | `find`, `callers`, `callees`, `impact`, `trace`, `map` (structural graph) | `search_context` at full quality |
96
+ | `code` (keyword/BM25 search) | |
97
+ | `search_context`, degraded to a keyword floor and flagged `mode: "lexical"` | |
98
+
99
+ ### Optional — capture the *why*
100
+
101
+ The index knows what the code does; it cannot know why it is that way. A knowledge bundle holds that half:
102
+
103
+ ```bash
104
+ project-brain okf init
105
+ ```
106
+
107
+ See [`okf`](#okf--knowledge-bundles-the-why-not-the-what).
108
+
46
109
  ## Prerequisites
47
110
 
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.
49
- - **Bun** ≥ 1.3.14 — only needed to build/run **from source** ([install](https://bun.sh)).
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.
111
+ | | Needed for | Notes |
112
+ |---|---|---|
113
+ | *nothing* | running project-brain | Every channel ships a self-contained prebuilt binary with the runtime, WASM grammars and templates bundled in. No Bun, no Node — the `curl` installer does not even need one to *install* it. |
114
+ | [Ollama](https://ollama.com) | semantic search only | `init` auto-pulls `qwen3-embedding:0.6b` (1024-dim, fast, code-capable), falling back to `nomic-embed-text` if it cannot. Pre-pull with `ollama pull qwen3-embedding:0.6b`. Everything structural works without it. |
115
+ | [Bun](https://bun.sh) ≥ 1.3.14 | building from source only | Not needed for any install channel. |
51
116
 
52
117
  ## Install
53
118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-brain",
3
- "version": "0.18.2",
3
+ "version": "0.19.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.18.2",
53
- "project-brain-linux-x64": "0.18.2",
54
- "project-brain-linux-arm64": "0.18.2",
55
- "project-brain-windows-x64": "0.18.2",
56
- "project-brain-windows-arm64": "0.18.2"
52
+ "project-brain-darwin-arm64": "0.19.0",
53
+ "project-brain-linux-x64": "0.19.0",
54
+ "project-brain-linux-arm64": "0.19.0",
55
+ "project-brain-windows-x64": "0.19.0",
56
+ "project-brain-windows-arm64": "0.19.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/bun": "latest",
@@ -0,0 +1,92 @@
1
+ ---
2
+ name: brain-commit
3
+ description: "Trigger: commit this, write the commit message, git commit, haz el commit, stage and commit, squash message, amend the message. Writes a commit message in the convention this repository already uses — conventional commits, gitmoji, or whatever the log actually shows — inferred from history rather than assumed."
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 commit message is about to be written: a normal commit, an amend, a squash summary, or a PR title that must match the repo's style.
21
+
22
+ Do not apply when: the user dictated the exact message (write theirs verbatim), or the request is to explain history rather than add to it.
23
+
24
+ **The rule this skill exists to enforce: read the log before writing the message.** A repository already voted on its convention, dozens of times. Guessing "conventional commits" because it is popular produces a message that is wrong in a repo using gitmoji, and unreviewable in a repo using neither.
25
+
26
+ ## Step 1 — Read the convention off the log
27
+
28
+ ```bash
29
+ git log --no-merges --format=%s -n 100
30
+ ```
31
+
32
+ Fewer than 100 commits is fine; a brand-new repo with zero is handled in Step 4. Also read a handful of full bodies, which is where the real house style lives:
33
+
34
+ ```bash
35
+ git log --no-merges --format='%s%n%b%n---' -n 15
36
+ ```
37
+
38
+ Classify the **subject lines** into one of four shapes:
39
+
40
+ | Shape | Looks like | Detection |
41
+ |---|---|---|
42
+ | Conventional | `feat(parser): add ESM support` | Matches `^(build\|chore\|ci\|docs\|feat\|fix\|perf\|refactor\|revert\|style\|test)(\(.+\))?!?: ` |
43
+ | Gitmoji | `✨ Add ESM support` or `:sparkles: Add ESM support` | Starts with an emoji or a `:shortcode:` |
44
+ | Gitmoji + conventional | `✨ feat(parser): add ESM support` | Both of the above, in that order |
45
+ | Freeform | `Add ESM support` | Neither |
46
+
47
+ **Decide by majority, and require a real majority.** If one shape covers ≥70% of the last 100 subjects, that is the convention — adopt it, including its details. Below 70%, treat the history as mixed and go to Step 4.
48
+
49
+ Count only what you can see. Do not weight by recency unless the split is clean — a repo whose last 30 commits are all gitmoji and whose first 70 are freeform has *changed* convention, and the recent one wins. Say so when you report the message.
50
+
51
+ ## Step 2 — Read the details, not just the shape
52
+
53
+ The shape is the easy half. These are what make a message look native:
54
+
55
+ - **Scope vocabulary.** Extract the set of scopes actually used: `git log --format=%s -n 100 | rg -o '^\w+\(([^)]+)\)' -r '$1' | sort | uniq -c | sort -rn`. **Never invent a scope that has never appeared.** If your change does not fit an existing scope, omit the scope — that is always valid — rather than minting one.
56
+ - **Which gitmoji for which intent.** A repo using ✨/🐛/♻️/📝 consistently has a working vocabulary; reuse the emoji it already uses for that kind of change. Only reach for the full list at <https://gitmoji.dev/> when the change has no precedent in the log. Match the form: raw emoji (`✨`) and shortcode (`:sparkles:`) are not interchangeable — copy whichever the log uses.
57
+ - **Case and mood.** Lowercase or capitalized subject? Imperative ("add") or past ("added")? Copy the dominant one.
58
+ - **Trailing period.** Copy the dominant choice. Most repos omit it.
59
+ - **Subject length.** Match the observed median rather than a textbook 50 characters.
60
+ - **Body presence.** If most non-trivial commits carry a body, write one. If the log is subjects-only, do not start a new tradition unprompted.
61
+ - **Trailers.** Reuse only trailers that already appear (`Refs:`, `Closes #`, `BREAKING CHANGE:`). **Never add AI or co-author attribution unless the history already shows it** — introducing `Co-Authored-By` into a repo that has never used it is a visible, unrequested change to the project's record.
62
+
63
+ ## Step 3 — Write the message about the change
64
+
65
+ Convention decides the *form*. These decide whether the message is worth reading:
66
+
67
+ - **The subject says what changed. The body says why.** The diff already shows what. A body that narrates the diff is noise; a body that explains the constraint, the bug's actual cause, or the rejected alternative is the reason anyone runs `git log` a year later.
68
+ - **Describe the change, not the process.** "fix flaky test" — not "address review feedback", "second attempt", or "as discussed".
69
+ - **One commit, one reason.** If an honest subject needs an "and", the work probably wants two commits. Say so; do not paper over it with a vague verb.
70
+ - **Breaking changes are marked**, in whatever way the repo marks them — `!` after the type, a `BREAKING CHANGE:` trailer, or both. Check the log for which.
71
+
72
+ ## Step 4 — Edge cases, decided in advance
73
+
74
+ - **Empty history (the first commit).** No convention exists to infer. Default to **conventional commits** — it is the most widely tooled and the easiest to migrate away from — and tell the user this is a default, not a detection, so they can redirect once instead of forever.
75
+ - **Mixed history below the 70% bar.** Do not silently pick. State the split ("58% conventional, 31% freeform") and ask which to follow. A repo mid-migration is exactly where an assumed convention causes an argument in review.
76
+ - **A commit template is configured.** `git config commit.template` beats inference — the maintainers wrote it down on purpose. Read the file and follow it.
77
+ - **A committed config declares the convention.** `commitlint.config.*`, `.czrc`, `.commitlintrc*`, `.gitmojirc.json`, or a `commitizen` key in `package.json` are stronger evidence than any log sample, because they are enforced. Check for them before trusting the count; if one contradicts your inference, it wins.
78
+ - **Hooks may reject your message.** If `.husky/commit-msg`, `.git/hooks/commit-msg`, or a `lefthook`/`pre-commit` config exists, expect validation. On rejection, read the hook's rule and fix the message — never retry with `--no-verify` to get around it.
79
+
80
+ ## Step 5 — Commit only what was meant
81
+
82
+ - **Commit what is staged.** If nothing is staged, say so and ask — do not `git add -A` on the user's behalf. An unrelated file swept into a commit is harder to undo than a missing one.
83
+ - **Check what you are about to commit** with `git diff --cached --stat` before writing the message. The message must describe *those* files. If secrets, build output, or a stray lockfile appear, stop and flag it.
84
+ - **Never amend or force-push a pushed commit** without the user explicitly asking. Rewriting shared history is not a message fix.
85
+
86
+ ## Reporting back
87
+
88
+ State the convention you detected and the evidence, in one line, before or with the message:
89
+
90
+ > Detected: gitmoji + conventional (81/100 subjects). Scopes in use: `parser`, `cli`, `db`.
91
+
92
+ That one line is what lets the user correct a bad inference immediately, instead of discovering it in review. When you fell back to a default or hit a mixed history, say that too — a stated assumption is cheap, a silent one is not.