@davesheffer/hunch 1.4.2 → 1.6.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
@@ -1,44 +1,138 @@
1
- # 🧠 Hunch — Architectural Conformance for AI code
1
+ # Hunch
2
+
3
+ ## Your AI can write code. Hunch makes it remember the consequences.
2
4
 
3
5
  [![npm version](https://img.shields.io/npm/v/@davesheffer/hunch?color=2742ff&label=npm)](https://www.npmjs.com/package/@davesheffer/hunch)
4
6
  [![GitHub stars](https://img.shields.io/github/stars/davesheffer/hunch?color=2742ff&label=%E2%98%85%20star)](https://github.com/davesheffer/hunch)
5
7
  [![license](https://img.shields.io/npm/l/@davesheffer/hunch?color=2742ff)](LICENSE)
6
8
 
7
- > **Your repo remembers *what* changed. Hunch makes it remember *why*** and keeps every
8
- > AI coding session consistent with the decisions, trade-offs, and bugs you already paid for.
9
- > Local-first, git-native, works with Claude Code, Cursor, Copilot, Windsurf & Codex.
9
+ **Hunch is engineering memory and a deterministic Change Gate for AI-assisted codebases.**
10
+ It captures the decisions, rejected approaches, and bug history behind your code—then gives every
11
+ assistant the same evidence before it changes anything.
10
12
 
11
- ## Install
13
+ Not another chat history. Not a wiki your team must remember to update. A git-native reasoning
14
+ graph that turns “we already learned this the hard way” into something your tools can actually use.
12
15
 
13
16
  ```bash
14
17
  npm i -g @davesheffer/hunch
15
- cd your-repo && hunch init # 2 minutes; advisory by default — nothing blocks until you say so
16
- hunch backfill --since 90d # optional: seed memory from recent git history
18
+ cd your-repo
19
+ hunch init
17
20
  ```
18
21
 
19
- Reload your assistant and ask: *"why is X built this way?"* — it answers from the graph, with receipts.
22
+ Then ask any connected assistant: **“Why is this built this way?”**
23
+
24
+ ## The problem Hunch solves
25
+
26
+ AI can read your current code. It does not know the decision you made six months ago, the incident
27
+ that made it necessary, or the approach you deliberately rejected yesterday.
28
+
29
+ That gap is where architectural drift starts:
30
+
31
+ | Without Hunch | With Hunch |
32
+ | --- | --- |
33
+ | A refactor passes tests but bypasses a hard-won service boundary. | The change is checked against the decision, its constraint, and the incident behind it. |
34
+ | A new coding session starts from scratch. | Claude Code, Cursor, Copilot, Windsurf, Antigravity, and Codex retrieve the same project memory over MCP. |
35
+ | A correction disappears into a chat transcript. | “Never do that again” becomes a scoped, auditable guard. |
36
+ | Code review sees a diff, not the reason behind it. | Change Gate produces a PASS / WARN / BLOCK receipt with causal evidence. |
37
+
38
+ ## What you get in five minutes
39
+
40
+ ```bash
41
+ hunch init # index code + wire supported assistants
42
+ hunch backfill --since 90d # optional: seed memory from recent history
43
+ hunch check --working --strict # review the whole working tree before a commit
44
+ ```
45
+
46
+ Hunch creates a local graph of:
47
+
48
+ - **Decisions** — what was chosen, why, and what alternatives were rejected.
49
+ - **Constraints** — the invariants a change must not violate.
50
+ - **Bug lineage** — the root cause behind fixes, recurrences, and regression guards.
51
+ - **Architecture** — symbols, components, dependencies, blast radius, and fragility.
52
+
53
+ It then puts that context where work happens: MCP tools, the CLI, a VS Code Change Gate, git hooks,
54
+ and an optional pull-request guard.
55
+
56
+ ## One graph. Every assistant. No lock-in.
57
+
58
+ Hunch is agent-agnostic by design. It scaffolds MCP and grounding for Claude Code, Cursor, VS Code / Copilot,
59
+ Windsurf, Google Antigravity, Codex, and any agent that can read `AGENTS.md`; where a client exposes hooks,
60
+ it adds a native lifecycle adapter too.
61
+
62
+ Your memory is plain JSON that you own. Hunch adds a SQLite index only as a rebuildable derived
63
+ layer—your decisions never disappear into a proprietary hosted memory system.
64
+
65
+ ```text
66
+ Claude Code ─┐
67
+ Cursor ├── MCP ──> .hunch/ reasoning graph ──> deterministic checks
68
+ Copilot ┤
69
+ Codex ┤
70
+ Windsurf ┤
71
+ Antigravity ┘
72
+ ```
73
+
74
+ ## The Change Gate: review intent, not just code
75
+
76
+ Before you commit, ask Hunch to review staged files, your working tree, or a branch against its
77
+ base. It returns a receipt your human reviewer or any coding agent can understand:
78
+
79
+ ```text
80
+ BLOCK src/payments/charge.ts
81
+
82
+ [blocking] Controllers must not reach the database directly
83
+ why: dec_service_boundary → bug_n_plus_one_2025
84
+ evidence: charge() now imports dbQuery
85
+ ```
86
+
87
+ The gate is deterministic: no prompt-quality lottery and no model call in the enforcement path.
88
+ Start advisory. Turn on strictness only when the rules have earned it.
89
+
90
+ ```bash
91
+ hunch firmness strict
92
+ hunch check --staged --strict
93
+ hunch conform --strict
94
+ ```
95
+
96
+ ## Private when the reasoning is sensitive
97
+
98
+ Open-source the code without open-sourcing the reasoning.
99
+
100
+ ```bash
101
+ hunch private ~/work/hunch-private/.hunch
102
+ hunch record-bug --private --test "billing regression" --message "…"
103
+ hunch review --private
104
+ ```
105
+
106
+ Private decisions, bugs, constraints, and wiki pages live in a separate overlay you control.
107
+ Local checks enforce them; public CI reports use `--public-only`, so private memory never appears in
108
+ a pull-request comment or committed grounding file. Private captures default to deterministic local
109
+ synthesis, keeping sensitive diffs and failure messages out of subscription-model drafting.
110
+
111
+ ## A workflow your team can trust
20
112
 
21
- ## The moment it earns its keep
113
+ Hunch is deliberately conservative:
22
114
 
23
- An AI "optimizes" your controller to query the DB directly. Linters stay green — no bad
24
- pattern to match. Hunch flags it: *"listOrders now reaches dbQuery · why: the Mar-2025 N+1
25
- incident · protects against bug_0317."* You decide what happens next advisory shows the
26
- note; **strict** (opt-in) holds the change.
115
+ - **Human-confirmed rules get the teeth.** Drafted memory advises; confirmed, precise invariants can block.
116
+ - **Every result carries receipts.** Decisions, constraints, bugs, confidence, and evidence are connected.
117
+ - **Drift is visible.** `hunch doctor` catches stale references, stale generated docs, and broken overlay pointers.
118
+ - **Public surfaces are public-only.** Private overlay data stays local unless you explicitly choose to share it.
119
+ - **No magic rewrite bot.** Hunch proposes and checks; you decide what becomes truth.
27
120
 
28
- Measured ([`bench/`](bench/architectural-conformance.md), n=90, three models): recorded rules
29
- in context cut architectural drift **58% → 16%**. The deterministic check catches the rest —
30
- no model in the loop.
121
+ ## Try the moment it earns its keep
31
122
 
32
- ## What you get
123
+ Imagine an assistant “simplifies” a controller by querying the database directly. Linters are green.
124
+ Unit tests pass. The architecture is still wrong.
33
125
 
34
- - **Memory as a byproduct of work** every commit becomes a decision, failing tests become bug lineage; no documentation chore
35
- - **Every answer with receipts** decisions cite the why, the rejected alternatives, and the bug they protect against
36
- - **Guards that hold the line** corrections become permanent rules; drift and re-opened bugs get caught deterministically
37
- - **Verification pipeline** (v1.4) — the agent can't end a turn claiming success on unverified edits
38
- - **One graph, every assistant** — plain git-tracked JSON in `.hunch/`, served over MCP; no SaaS, $0, works offline
126
+ Hunch can answer with the actual context: this boundary exists because of the N+1 incident, the
127
+ service layer was the chosen repair, and the direct import violates a confirmed constraint. That is
128
+ the missing layer between fast code generation and durable engineering judgment.
39
129
 
40
130
  ## Learn more
41
131
 
42
- **[Documentation](https://hunch-pi.vercel.app/docs)** · **[Cookbook](https://hunch-pi.vercel.app/cookbook)** · **[Changelog](https://hunch-pi.vercel.app/changelog)** · **[15-second demo](demo/architectural-conformance.sh)**
132
+ - [Full documentation](https://hunch-pi.vercel.app/docs)
133
+ - [Interactive product site](https://hunch-pi.vercel.app)
134
+ - [VS Code extension](vscode-extension/README.md)
135
+ - [Architecture benchmark](bench/architectural-conformance.md)
136
+ - [15-second demo](demo/architectural-conformance.sh)
43
137
 
44
138
  Apache-2.0