-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed-example.mjs
More file actions
86 lines (77 loc) · 2.92 KB
/
Copy pathseed-example.mjs
File metadata and controls
86 lines (77 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// seed-example.mjs — build a synthetic observation store for the demo.
//
// Creates example.db with the same `observations` shape this tool reads, filled
// with FAKE data for two made-up projects. Lets anyone run the full pipeline
// (cluster → build → read) with no real memory store and no private data.
//
// bun seed-example.mjs
// CLAUDE_MEM_DB=./example.db MERGE_MODEL=mock bun build-digests.mjs
// CLAUDE_MEM_DB=./example.db bun read-digests.mjs widgets-api
//
// CONFIG (env)
// EXAMPLE_DB output path (default: ./example.db)
import { Database } from "bun:sqlite";
import { join } from "path";
const OUT = process.env.EXAMPLE_DB || join(process.cwd(), "example.db");
const db = new Database(OUT);
db.run(`DROP TABLE IF EXISTS observations`);
db.run(`
CREATE TABLE observations (
id INTEGER PRIMARY KEY,
project TEXT NOT NULL,
concepts TEXT NOT NULL, -- JSON array of type tags
title TEXT NOT NULL,
narrative TEXT NOT NULL,
facts TEXT NOT NULL, -- JSON array of strings
created_at_epoch INTEGER NOT NULL,
relevance_count INTEGER DEFAULT 0
)
`);
const TYPES = [
"how-it-works",
"gotcha",
"decision",
"pattern",
"problem-solution",
"what-changed",
"trade-off",
"why-it-exists",
];
// Two synthetic projects, deliberately lopsided so the economics are visible:
// "widgets-api" has deep history (compresses hard), "tiny-cli" is shallow
// (near the floor where consolidation barely helps).
const PLAN = {
"widgets-api": 220,
"tiny-cli": 12,
};
const insert = db.query(`
INSERT INTO observations
(project, concepts, title, narrative, facts, created_at_epoch, relevance_count)
VALUES (?, ?, ?, ?, ?, ?, 0)
`);
let epoch = Date.UTC(2026, 0, 1); // Jan 1 2026, marches forward per row
let total = 0;
for (const [project, n] of Object.entries(PLAN)) {
for (let i = 0; i < n; i++) {
const type = TYPES[i % TYPES.length];
const title = `${project}: ${type} note #${i + 1}`;
const narrative =
`During session ${i + 1} on ${project}, work touching the ${type} ` +
`area produced a distilled memory. Several of these overlap on purpose, ` +
`so consolidation has duplicates to collapse and stale points to drop.`;
const facts = JSON.stringify([
`${type} fact A for ${project} #${i + 1}`,
`${type} fact B for ${project} #${i + 1}`,
]);
const concepts = JSON.stringify([type]);
epoch += 60_000; // +1 minute per observation, strictly increasing
insert.run(project, concepts, title, narrative, facts, epoch);
total++;
}
}
db.close();
console.log(`Seeded ${total} synthetic observations → ${OUT}`);
console.log(`Projects: ${Object.entries(PLAN).map(([p, n]) => `${p}(${n})`).join(", ")}`);
console.log(`\nNext:`);
console.log(` CLAUDE_MEM_DB=./example.db MERGE_MODEL=mock bun build-digests.mjs`);
console.log(` CLAUDE_MEM_DB=./example.db bun read-digests.mjs widgets-api`);