@davesheffer/hunch 1.1.0 → 1.1.1

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
@@ -105,35 +105,21 @@ is its complement — it keeps your *docs* honest to the graph (**doc ≠ graph*
105
105
  says one thing; the decision that actually governs the file says another. Both are "memory that stays
106
106
  true"; you want both.
107
107
 
108
- The anchor is one optional field. A decision can carry a **`topic`** the thing it's the current answer
109
- for (e.g. `"auth.session"`) and topic gives you a query contract: **current** (the one live answer),
110
- **history** (the supersede trail), and **rejected** (what was ruled out and why). It's fully
111
- backward-compatible: `topic` defaults to `null`, there's **no schema bump**, and existing graphs load
112
- unchanged.
113
-
114
- - **Read-time grounding.** The pre-edit (PreToolUse) hook now surfaces a file's topic-anchored decisions
115
- *before* the AI writes with doc-precedence framing ("follow the graph, not a stale doc") and what each
116
- decision **rejected**, so the model doesn't happily re-add the approach you already ruled out.
117
- - **`anchor-stale` drift deterministic, no guessing.** A new drift kind fires when a file is still
118
- anchored to a **superseded** decision while a **current** one exists for its topic. It shows up in
119
- `hunch doctor` and in a CI-gateable `hunch drift`:
120
-
121
- ```bash
122
- hunch drift # exits non-zero on anchor-stale drift or a topic collision (>1 live decision)
123
- ```
124
-
125
- It only fires on **explicit** topic anchors — no semantic guessing, no false positives on prose it can't
126
- read.
127
- - **Capture, gated.** `hunch_record_decision` now enforces a store-scoped **uniqueness guard**: it refuses
128
- a *second* live decision for a topic (you're never silently governed by two). The richer path is the new
129
- **`hunch_capture_decision`** tool — it returns a one-question-at-a-time grilling protocol plus a
130
- capture-session token; `record_decision` accepts an optional `capture_token`. Un-token'd writes still
131
- work, they just get a nudge toward `/capture`. **`hunch_current_decision(topic)`** returns the one answer
132
- that currently governs a topic.
133
- - **`hunch reconcile-topics`.** A git merge is the one thing that can create two live decisions for a
134
- topic. This scans for it and exits non-zero — wire it into a post-merge hook or CI.
135
- - **`hunch heal`** + the **`/capture`** and **`/heal`** slash commands (scaffolded by `hunch init`) do
136
- **read-only** doc↔graph reconciliation — they surface the mismatch and never rewrite your prose silently.
108
+ A decision can be anchored to a **topic** (e.g. `"auth.session"`), and a topic always has one live
109
+ answer: the **current** decision, its **history**, and what was **rejected** along the way. Existing
110
+ graphs are unaffected until you opt in.
111
+
112
+ - **Read-time grounding.** Before the AI edits a file — or a markdown doc like `AGENTS.md` — it's told
113
+ which decision is *current* (follow the graph, not a stale doc) and what was **rejected**, so it
114
+ doesn't re-add the approach you already ruled out.
115
+ - **Drift, caught deterministically.** Prose or a file still describing a **superseded** decision is
116
+ flagged in `hunch doctor`, and `hunch drift` exits non-zero so CI can gate on it. It only fires on
117
+ explicit anchorsnever a semantic guess.
118
+ - **Capture, interviewed.** `/capture` walks a decision to a resolved state topic, rationale, and
119
+ rejected alternatives — before it's written, and the graph refuses to hold **two live decisions on
120
+ one topic**. `hunch reconcile-topics` catches the one case a git merge can create, for human resolution.
121
+ - **`hunch heal`** + the **`/heal`** slash command do **read-only** doc↔graph reconciliation — they show
122
+ exactly what disagrees and never rewrite your prose silently.
137
123
 
138
124
  → [docs](https://hunch-pi.vercel.app/docs#grounding)
139
125
 
@@ -147,6 +133,15 @@ hunch backfill --since 90d # cold start: seed decisions from recent git
147
133
  hunch why src/auth/session.ts # …then ask your assistant: "why is X built this way?"
148
134
  ```
149
135
 
136
+ **Claude Code users — one-step plugin install** (MCP tools + `/hunch:capture`, `/hunch:heal`, `/hunch:why`, `/hunch:fix`, `/hunch:fragile`):
137
+
138
+ ```text
139
+ /plugin marketplace add davesheffer/hunch
140
+ /plugin install hunch@hunch
141
+ ```
142
+
143
+ Then `hunch init` in each repo you want remembered (the plugin brings the tools; init builds the graph + hooks).
144
+
150
145
  `hunch init` scaffolds `.hunch/`, indexes the repo, installs the git hooks,
151
146
  writes `.mcp.json` + slash commands + an auto-maintained `CLAUDE.md`, and wires up **every
152
147
  detected assistant** (Claude Code, Cursor, VS Code/Copilot, Windsurf, Codex, Google Antigravity) to the same
@@ -230,12 +225,10 @@ Plus the **Regression Guard** (re-adding deliberately-retired code) and the
230
225
  comments the affected `con_`/`dec_` ids and fails on a blocking one).
231
226
 
232
227
  Name the actual violation — `record-constraint "…" --scope "src/**" --severity blocking
233
- --forbid-dep "lodash"` — and it blocks the *real* change across the file's whole life instead
234
- of relaxing to advisory after the file is edited again. The dep matcher reads the **parsed
235
- import**, so a comment or string naming the module can't false-positive and a submodule
236
- (`lodash/groupBy`) is still caught; a correction your assistant records gets the same matcher
237
- automatically. (`--match <regex>` remains a lint-grade textual fallback.) None of these are a
238
- bypass-proof boundary — deliberate indirection can still route around any rule.
228
+ --forbid-dep "lodash"` — and it blocks the *real* change for the file's whole life, while staying
229
+ quiet on edits that don't break the rule. A comment or string that merely mentions the module can't
230
+ false-positive. None of these are a bypass-proof boundary deliberate indirection can still route
231
+ around any rule.
239
232
 
240
233
  ## Working as a team
241
234
 
@@ -263,24 +256,15 @@ the same way via the MCP server) — everyone, on every branch, resolves the sam
263
256
  ## Private memory (public repo, private context)
264
257
 
265
258
  Open-source your code without open-sourcing your *reasoning*. **`hunch private`** sets up a
266
- separate private store in one command Hunch unions it into every query and guard **locally**
267
- (MCP and the pre-edit hook see your sensitive decisions/bugs/constraints) while your public
268
- `.hunch/` stays clean. It writes a gitignored `.hunch/local.json` so it's auto-detected **no
269
- env var, no shell-profile edit** (and `HUNCH_PRIVATE_DIR` still overrides per-shell). **Opt-in,
270
- default-off** (no config → fully inert), and **leak-safe by construction**: committed files and
271
- the CI PR comment render *public-only*, so a private record can't reach a public surface. Record
272
- sensitive items with `private: true` (`hunch_record_decision` / `hunch_record_correction`);
273
- post-commit synthesis can route there too. Every capture is **auto-committed by default** to the
274
- store it lands in — the private repo is committed + pushed; a public capture is committed to
275
- `.hunch/` only and rides your next push (Hunch never pushes or merges your code branch) —
276
- recursion-safe, staging only `.hunch/`. Opt out with `--no-auto-commit`.
259
+ separate private store in one command: your local queries, guards, and assistants see the
260
+ sensitive decisions but they're never committed to the public repo, and public outputs (like
261
+ the CI PR comment) **can never contain them, by construction**. Opt-in, default-off; captures are
262
+ auto-committed to the store they land in (opt out with `--no-auto-commit`), and Hunch never
263
+ touches your code branch.
277
264
 
278
265
  Already published a repo *with* its `.hunch/` memory and want it private after the fact?
279
- `hunch private --repo <url> --migrate` does it in one shot: it **moves** your existing public
280
- records into the overlay (union by id nothing is lost), empties the public store, untracks +
281
- gitignores the `.hunch/` memory tree, and regenerates the assistant grounding (CLAUDE.md, AGENTS.md,
282
- …) so the repo becomes **code-only**. It commits the private overlay for you and prints the one
283
- `git` command to commit the now-clean public repo.
266
+ **`hunch private --repo <url> --migrate`** moves the existing memory into the private store
267
+ nothing lost and leaves the public repo code-only, telling you the one `git` command left to run.
284
268
  → [docs](https://hunch-pi.vercel.app/docs#private)
285
269
 
286
270
  ## Continuous learning (CI)
package/dist/cli/index.js CHANGED
@@ -708,6 +708,7 @@ program
708
708
  const { store, root } = storeFor();
709
709
  // Lookup mode: scoped runbook retrieval (search within runbooks, not the whole graph).
710
710
  if (opts.find) {
711
+ store.reindex(); // reflect out-of-band JSON edits before searching (mirrors `hunch query`)
711
712
  const emb = opts.semantic ? await selectEmbedder() : undefined;
712
713
  const hits = await store.searchRunbooks(opts.find, 5, { embedder: emb });
713
714
  if (!hits.length)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@davesheffer/hunch",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Dave Sheffer <dave.sheffer1@gmail.com>",
6
6
  "description": "Architectural Conformance for AI-generated code: a git-native graph that deterministically blocks AI changes which break your architecture — the semantic invariants (layering, must-reach, dependency direction) pattern-SAST can't express — grounded in the decisions and bugs behind each rule, across any MCP assistant (Claude Code, Cursor, Copilot, Windsurf, Codex).",