project-brain 0.18.3 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-brain",
3
- "version": "0.18.3",
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.3",
53
- "project-brain-linux-x64": "0.18.3",
54
- "project-brain-linux-arm64": "0.18.3",
55
- "project-brain-windows-x64": "0.18.3",
56
- "project-brain-windows-arm64": "0.18.3"
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.