@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 +117 -23
- package/dist/cli/index.js +269 -57
- package/dist/core/agenthook.js +197 -0
- package/dist/core/autoreview.js +52 -0
- package/dist/core/config.js +1 -1
- package/dist/core/drift.js +25 -3
- package/dist/core/hookcache.js +1 -1
- package/dist/core/refrepair.js +33 -0
- package/dist/extractors/git.js +31 -1
- package/dist/integrations/hooks.js +4 -0
- package/dist/integrations/providers.js +177 -23
- package/dist/mcp/server.js +23 -22
- package/dist/store/hunchStore.js +26 -5
- package/dist/synthesis/provider.js +58 -0
- package/dist/synthesis/synthesize.js +32 -17
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,44 +1,138 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Hunch
|
|
2
|
+
|
|
3
|
+
## Your AI can write code. Hunch makes it remember the consequences.
|
|
2
4
|
|
|
3
5
|
[](https://www.npmjs.com/package/@davesheffer/hunch)
|
|
4
6
|
[](https://github.com/davesheffer/hunch)
|
|
5
7
|
[](LICENSE)
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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
|
|
16
|
-
hunch
|
|
18
|
+
cd your-repo
|
|
19
|
+
hunch init
|
|
17
20
|
```
|
|
18
21
|
|
|
19
|
-
|
|
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
|
-
|
|
113
|
+
Hunch is deliberately conservative:
|
|
22
114
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|