diff --git a/next-env.d.ts b/next-env.d.ts
index ce4e94a..a419cbe 100644
--- a/next-env.d.ts
+++ b/next-env.d.ts
@@ -1,7 +1,7 @@
///
///
-import "./.next/types/routes.d.ts";
-import "./.next/types/root-params.d.ts";
+import "./.next/dev/types/routes.d.ts";
+import "./.next/dev/types/root-params.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
diff --git a/scripts/backfill-graph.ts b/scripts/backfill-graph.ts
new file mode 100644
index 0000000..194addc
--- /dev/null
+++ b/scripts/backfill-graph.ts
@@ -0,0 +1,36 @@
+/**
+ * One-time backfill: wipe the legacy ledgers and re-extract every chat with
+ * the redesigned pipeline (vision §1, commit b07c907). Run from the master
+ * tree only — data never crosses trees:
+ *
+ * npx tsx --env-file=.env.local scripts/backfill-graph.ts
+ */
+import { chatStore } from "../src/store/chats.ts";
+import { graphStore } from "../src/store/graph.ts";
+import { createExtractionPipeline } from "../src/agent/subagents/extraction.ts";
+import { getGraph } from "../src/core/graph.ts";
+
+async function main() {
+ const only = process.argv[2]; // optional: extract just one chat id
+ const chats = only ? chatStore.listChats().filter((c) => c.id === only) : chatStore.listChats();
+ console.log(`[backfill] ${chats.length} chats to extract`);
+ const pipeline = createExtractionPipeline({ chatStore, graphStore });
+ for (const chat of chats) {
+ const t0 = Date.now();
+ try {
+ const stats = await pipeline.runExtraction(chat.id);
+ console.log(
+ `[backfill] ${chat.id} (${chat.title.slice(0, 40)}): ` +
+ `${stats.nodes} nodes, ${stats.edges} edges, ${stats.events} events in ${((Date.now() - t0) / 1000).toFixed(1)}s`,
+ );
+ } catch (err) {
+ console.error(`[backfill] ${chat.id} FAILED:`, err);
+ }
+ }
+ const graph = getGraph(graphStore);
+ console.log(
+ `[backfill] done: ${graph.nodes.length} nodes, ${graph.edges.length} edges, ${graph.events.length} events`,
+ );
+}
+
+main();