@davesheffer/hunch 0.12.1 → 0.13.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.
@@ -15,87 +15,87 @@ import { shortHash } from "../core/ids.js";
15
15
  export function embedHash(title, body) {
16
16
  return shortHash(`${title}\x00${body ?? ""}`, 16);
17
17
  }
18
- export const SCHEMA_SQL = /* sql */ `
19
- PRAGMA journal_mode = WAL;
20
- PRAGMA foreign_keys = OFF;
21
-
22
- CREATE TABLE IF NOT EXISTS components (
23
- id TEXT PRIMARY KEY,
24
- kind TEXT, name TEXT, responsibility TEXT,
25
- paths TEXT, status TEXT, owners TEXT,
26
- fragility REAL,
27
- prov_source TEXT, prov_confidence REAL, prov_evidence TEXT,
28
- created_at TEXT, updated_at TEXT
29
- );
30
-
31
- CREATE TABLE IF NOT EXISTS edges (
32
- id TEXT PRIMARY KEY,
33
- "from" TEXT, "to" TEXT, type TEXT, reason TEXT, strength REAL,
34
- prov_source TEXT, prov_confidence REAL, prov_evidence TEXT
35
- );
36
- CREATE INDEX IF NOT EXISTS idx_edges_from ON edges("from");
37
- CREATE INDEX IF NOT EXISTS idx_edges_to ON edges("to");
38
- CREATE INDEX IF NOT EXISTS idx_edges_type ON edges(type);
39
-
40
- CREATE TABLE IF NOT EXISTS symbols (
41
- id TEXT PRIMARY KEY,
42
- file TEXT, name TEXT, kind TEXT, signature_hash TEXT,
43
- calls TEXT, called_by TEXT,
44
- loc INTEGER, churn_90d INTEGER, bug_count INTEGER, fan_in INTEGER, fan_out INTEGER,
45
- last_changed TEXT
46
- );
47
- CREATE INDEX IF NOT EXISTS idx_symbols_file ON symbols(file);
48
- CREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);
49
-
50
- CREATE TABLE IF NOT EXISTS decisions (
51
- id TEXT PRIMARY KEY,
52
- title TEXT, status TEXT, context TEXT, decision TEXT,
53
- consequences TEXT, alternatives_rejected TEXT,
54
- related_components TEXT, related_files TEXT,
55
- supersedes TEXT, caused_by_bug TEXT, "commit" TEXT,
56
- prov_source TEXT, prov_confidence REAL, prov_evidence TEXT,
57
- date TEXT
58
- );
59
-
60
- CREATE TABLE IF NOT EXISTS bugs (
61
- id TEXT PRIMARY KEY,
62
- title TEXT, symptom TEXT, root_cause TEXT, severity TEXT, status TEXT,
63
- affected_files TEXT, affected_symbols TEXT, lineage TEXT,
64
- prov_source TEXT, prov_confidence REAL, prov_evidence TEXT
65
- );
66
-
67
- CREATE TABLE IF NOT EXISTS constraints (
68
- id TEXT PRIMARY KEY,
69
- type TEXT, statement TEXT, scope TEXT, severity TEXT, enforcement TEXT,
70
- rationale TEXT, source_decision TEXT, violations TEXT,
71
- prov_source TEXT, prov_confidence REAL, prov_evidence TEXT
72
- );
73
-
74
- -- Unified full-text search across every entity. Rebuilt on index; bm25-ranked.
75
- CREATE VIRTUAL TABLE IF NOT EXISTS search USING fts5(
76
- ref UNINDEXED, -- entity id
77
- kind UNINDEXED, -- components | edges | symbols | decisions | bugs | constraints
78
- title,
79
- body,
80
- tokenize = 'porter unicode61'
81
- );
82
-
83
- -- Local semantic-search vectors (opt-in; written by \`hunch embed\`). One row per
84
- -- (ref, model); vec is a Float32 BLOB. DELIBERATELY NOT in RESET_SQL: reindex()
85
- -- runs RESET on nearly every path (MCP startup, every query/context), so resetting
86
- -- embeddings here would wipe them constantly and make the feature a no-op. Staleness
87
- -- is tracked by doc_hash and reconciled by pruneStaleEmbeddings() instead. Recall is
88
- -- exact brute-force cosine in JS (graphs are small); sqlite-vec only past ~100k rows.
89
- CREATE TABLE IF NOT EXISTS embeddings (
90
- ref TEXT, kind TEXT, model TEXT, dim INTEGER, doc_hash TEXT, vec BLOB,
91
- PRIMARY KEY (ref, model)
92
- );
18
+ export const SCHEMA_SQL = /* sql */ `
19
+ PRAGMA journal_mode = WAL;
20
+ PRAGMA foreign_keys = OFF;
21
+
22
+ CREATE TABLE IF NOT EXISTS components (
23
+ id TEXT PRIMARY KEY,
24
+ kind TEXT, name TEXT, responsibility TEXT,
25
+ paths TEXT, status TEXT, owners TEXT,
26
+ fragility REAL,
27
+ prov_source TEXT, prov_confidence REAL, prov_evidence TEXT,
28
+ created_at TEXT, updated_at TEXT
29
+ );
30
+
31
+ CREATE TABLE IF NOT EXISTS edges (
32
+ id TEXT PRIMARY KEY,
33
+ "from" TEXT, "to" TEXT, type TEXT, reason TEXT, strength REAL,
34
+ prov_source TEXT, prov_confidence REAL, prov_evidence TEXT
35
+ );
36
+ CREATE INDEX IF NOT EXISTS idx_edges_from ON edges("from");
37
+ CREATE INDEX IF NOT EXISTS idx_edges_to ON edges("to");
38
+ CREATE INDEX IF NOT EXISTS idx_edges_type ON edges(type);
39
+
40
+ CREATE TABLE IF NOT EXISTS symbols (
41
+ id TEXT PRIMARY KEY,
42
+ file TEXT, name TEXT, kind TEXT, signature_hash TEXT,
43
+ calls TEXT, called_by TEXT,
44
+ loc INTEGER, churn_90d INTEGER, bug_count INTEGER, fan_in INTEGER, fan_out INTEGER,
45
+ last_changed TEXT
46
+ );
47
+ CREATE INDEX IF NOT EXISTS idx_symbols_file ON symbols(file);
48
+ CREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);
49
+
50
+ CREATE TABLE IF NOT EXISTS decisions (
51
+ id TEXT PRIMARY KEY,
52
+ title TEXT, status TEXT, context TEXT, decision TEXT,
53
+ consequences TEXT, alternatives_rejected TEXT,
54
+ related_components TEXT, related_files TEXT,
55
+ supersedes TEXT, caused_by_bug TEXT, "commit" TEXT,
56
+ prov_source TEXT, prov_confidence REAL, prov_evidence TEXT,
57
+ date TEXT
58
+ );
59
+
60
+ CREATE TABLE IF NOT EXISTS bugs (
61
+ id TEXT PRIMARY KEY,
62
+ title TEXT, symptom TEXT, root_cause TEXT, severity TEXT, status TEXT,
63
+ affected_files TEXT, affected_symbols TEXT, lineage TEXT,
64
+ prov_source TEXT, prov_confidence REAL, prov_evidence TEXT
65
+ );
66
+
67
+ CREATE TABLE IF NOT EXISTS constraints (
68
+ id TEXT PRIMARY KEY,
69
+ type TEXT, statement TEXT, scope TEXT, severity TEXT, enforcement TEXT,
70
+ rationale TEXT, source_decision TEXT, violations TEXT,
71
+ prov_source TEXT, prov_confidence REAL, prov_evidence TEXT
72
+ );
73
+
74
+ -- Unified full-text search across every entity. Rebuilt on index; bm25-ranked.
75
+ CREATE VIRTUAL TABLE IF NOT EXISTS search USING fts5(
76
+ ref UNINDEXED, -- entity id
77
+ kind UNINDEXED, -- components | edges | symbols | decisions | bugs | constraints
78
+ title,
79
+ body,
80
+ tokenize = 'porter unicode61'
81
+ );
82
+
83
+ -- Local semantic-search vectors (opt-in; written by \`hunch embed\`). One row per
84
+ -- (ref, model); vec is a Float32 BLOB. DELIBERATELY NOT in RESET_SQL: reindex()
85
+ -- runs RESET on nearly every path (MCP startup, every query/context), so resetting
86
+ -- embeddings here would wipe them constantly and make the feature a no-op. Staleness
87
+ -- is tracked by doc_hash and reconciled by pruneStaleEmbeddings() instead. Recall is
88
+ -- exact brute-force cosine in JS (graphs are small); sqlite-vec only past ~100k rows.
89
+ CREATE TABLE IF NOT EXISTS embeddings (
90
+ ref TEXT, kind TEXT, model TEXT, dim INTEGER, doc_hash TEXT, vec BLOB,
91
+ PRIMARY KEY (ref, model)
92
+ );
93
93
  `;
94
94
  /** Drop derived data (used before a full reindex). NOTE: embeddings is omitted on
95
95
  * purpose — see the embeddings table comment above. */
96
- export const RESET_SQL = /* sql */ `
97
- DELETE FROM components; DELETE FROM edges; DELETE FROM symbols;
98
- DELETE FROM decisions; DELETE FROM bugs; DELETE FROM constraints;
99
- DELETE FROM search;
96
+ export const RESET_SQL = /* sql */ `
97
+ DELETE FROM components; DELETE FROM edges; DELETE FROM symbols;
98
+ DELETE FROM decisions; DELETE FROM bugs; DELETE FROM constraints;
99
+ DELETE FROM search;
100
100
  `;
101
101
  //# sourceMappingURL=schema.js.map
@@ -96,10 +96,10 @@ export function pexecIn(cmd, args, opts = {}) {
96
96
  child.stdin.end();
97
97
  });
98
98
  }
99
- const SYSTEM = `You are the synthesis engine of an Engineering Memory OS. You turn raw
100
- developer activity (a git commit diff, or a test failure) into a single structured
101
- "why" record. Be precise and evidence-grounded; never invent facts not supported by
102
- the input. Prefer short, concrete statements. If intent is unclear, say so plainly
99
+ const SYSTEM = `You are the synthesis engine of an Engineering Memory OS. You turn raw
100
+ developer activity (a git commit diff, or a test failure) into a single structured
101
+ "why" record. Be precise and evidence-grounded; never invent facts not supported by
102
+ the input. Prefer short, concrete statements. If intent is unclear, say so plainly
103
103
  rather than guessing.`;
104
104
  const DECISION_TOOL = {
105
105
  name: "emit_decision",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@davesheffer/hunch",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "license": "MIT",
5
5
  "author": "Dave Sheffer <dave.sheffer1@gmail.com>",
6
6
  "description": "Hunch — an Engineering Memory OS: a persistent, git-native reasoning graph over a codebase, exposed to Claude Code via MCP.",