@bubstack/moe-memory 0.1.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.
Files changed (157) hide show
  1. package/.mcp.json +18 -0
  2. package/README.md +47 -0
  3. package/agents/search-conversations.md +171 -0
  4. package/dist/LICENSE +25 -0
  5. package/dist/cli.d.ts +25 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +125 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/codex-hook-trust.d.ts +4 -0
  10. package/dist/codex-hook-trust.d.ts.map +1 -0
  11. package/dist/codex-hook-trust.js +114 -0
  12. package/dist/codex-hook-trust.js.map +1 -0
  13. package/dist/codex-support.d.ts +6 -0
  14. package/dist/codex-support.d.ts.map +1 -0
  15. package/dist/codex-support.js +29 -0
  16. package/dist/codex-support.js.map +1 -0
  17. package/dist/constants.d.ts +14 -0
  18. package/dist/constants.d.ts.map +1 -0
  19. package/dist/constants.js +14 -0
  20. package/dist/constants.js.map +1 -0
  21. package/dist/db.d.ts +103 -0
  22. package/dist/db.d.ts.map +1 -0
  23. package/dist/db.js +430 -0
  24. package/dist/db.js.map +1 -0
  25. package/dist/doctor-cli.d.ts +3 -0
  26. package/dist/doctor-cli.d.ts.map +1 -0
  27. package/dist/doctor-cli.js +43 -0
  28. package/dist/doctor-cli.js.map +1 -0
  29. package/dist/doctor.d.ts +17 -0
  30. package/dist/doctor.d.ts.map +1 -0
  31. package/dist/doctor.js +98 -0
  32. package/dist/doctor.js.map +1 -0
  33. package/dist/embedding-migration.d.ts +73 -0
  34. package/dist/embedding-migration.d.ts.map +1 -0
  35. package/dist/embedding-migration.js +120 -0
  36. package/dist/embedding-migration.js.map +1 -0
  37. package/dist/embeddings.d.ts +78 -0
  38. package/dist/embeddings.d.ts.map +1 -0
  39. package/dist/embeddings.js +180 -0
  40. package/dist/embeddings.js.map +1 -0
  41. package/dist/file-lock.d.ts +39 -0
  42. package/dist/file-lock.d.ts.map +1 -0
  43. package/dist/file-lock.js +91 -0
  44. package/dist/file-lock.js.map +1 -0
  45. package/dist/index-cli.d.ts +10 -0
  46. package/dist/index-cli.d.ts.map +1 -0
  47. package/dist/index-cli.js +195 -0
  48. package/dist/index-cli.js.map +1 -0
  49. package/dist/index.d.ts +12 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +19 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/indexer.d.ts +4 -0
  54. package/dist/indexer.d.ts.map +1 -0
  55. package/dist/indexer.js +318 -0
  56. package/dist/indexer.js.map +1 -0
  57. package/dist/install-check.d.ts +48 -0
  58. package/dist/install-check.d.ts.map +1 -0
  59. package/dist/install-check.js +82 -0
  60. package/dist/install-check.js.map +1 -0
  61. package/dist/journal/index.d.ts +5 -0
  62. package/dist/journal/index.d.ts.map +1 -0
  63. package/dist/journal/index.js +5 -0
  64. package/dist/journal/index.js.map +1 -0
  65. package/dist/journal/legacy-sidecars.d.ts +74 -0
  66. package/dist/journal/legacy-sidecars.d.ts.map +1 -0
  67. package/dist/journal/legacy-sidecars.js +151 -0
  68. package/dist/journal/legacy-sidecars.js.map +1 -0
  69. package/dist/journal/markdown.d.ts +91 -0
  70. package/dist/journal/markdown.d.ts.map +1 -0
  71. package/dist/journal/markdown.js +234 -0
  72. package/dist/journal/markdown.js.map +1 -0
  73. package/dist/journal/search.d.ts +91 -0
  74. package/dist/journal/search.d.ts.map +1 -0
  75. package/dist/journal/search.js +203 -0
  76. package/dist/journal/search.js.map +1 -0
  77. package/dist/journal/store.d.ts +96 -0
  78. package/dist/journal/store.d.ts.map +1 -0
  79. package/dist/journal/store.js +270 -0
  80. package/dist/journal/store.js.map +1 -0
  81. package/dist/journal-cli.d.ts +19 -0
  82. package/dist/journal-cli.d.ts.map +1 -0
  83. package/dist/journal-cli.js +153 -0
  84. package/dist/journal-cli.js.map +1 -0
  85. package/dist/logging.d.ts +6 -0
  86. package/dist/logging.d.ts.map +1 -0
  87. package/dist/logging.js +20 -0
  88. package/dist/logging.js.map +1 -0
  89. package/dist/mcp-server.d.ts +34 -0
  90. package/dist/mcp-server.d.ts.map +1 -0
  91. package/dist/mcp-server.js +607 -0
  92. package/dist/mcp-server.js.map +1 -0
  93. package/dist/parser.d.ts +11 -0
  94. package/dist/parser.d.ts.map +1 -0
  95. package/dist/parser.js +445 -0
  96. package/dist/parser.js.map +1 -0
  97. package/dist/paths.d.ts +103 -0
  98. package/dist/paths.d.ts.map +1 -0
  99. package/dist/paths.js +258 -0
  100. package/dist/paths.js.map +1 -0
  101. package/dist/search-cli.d.ts +3 -0
  102. package/dist/search-cli.d.ts.map +1 -0
  103. package/dist/search-cli.js +138 -0
  104. package/dist/search-cli.js.map +1 -0
  105. package/dist/search.d.ts +36 -0
  106. package/dist/search.d.ts.map +1 -0
  107. package/dist/search.js +371 -0
  108. package/dist/search.js.map +1 -0
  109. package/dist/show-cli.d.ts +3 -0
  110. package/dist/show-cli.d.ts.map +1 -0
  111. package/dist/show-cli.js +60 -0
  112. package/dist/show-cli.js.map +1 -0
  113. package/dist/show.d.ts +3 -0
  114. package/dist/show.d.ts.map +1 -0
  115. package/dist/show.js +984 -0
  116. package/dist/show.js.map +1 -0
  117. package/dist/stats-cli.d.ts +3 -0
  118. package/dist/stats-cli.d.ts.map +1 -0
  119. package/dist/stats-cli.js +51 -0
  120. package/dist/stats-cli.js.map +1 -0
  121. package/dist/stats.d.ts +19 -0
  122. package/dist/stats.d.ts.map +1 -0
  123. package/dist/stats.js +116 -0
  124. package/dist/stats.js.map +1 -0
  125. package/dist/summarizer.d.ts +83 -0
  126. package/dist/summarizer.d.ts.map +1 -0
  127. package/dist/summarizer.js +526 -0
  128. package/dist/summarizer.js.map +1 -0
  129. package/dist/summary-sentinel.d.ts +31 -0
  130. package/dist/summary-sentinel.d.ts.map +1 -0
  131. package/dist/summary-sentinel.js +80 -0
  132. package/dist/summary-sentinel.js.map +1 -0
  133. package/dist/sync-cli.d.ts +15 -0
  134. package/dist/sync-cli.d.ts.map +1 -0
  135. package/dist/sync-cli.js +202 -0
  136. package/dist/sync-cli.js.map +1 -0
  137. package/dist/sync.d.ts +35 -0
  138. package/dist/sync.d.ts.map +1 -0
  139. package/dist/sync.js +204 -0
  140. package/dist/sync.js.map +1 -0
  141. package/dist/types.d.ts +125 -0
  142. package/dist/types.d.ts.map +1 -0
  143. package/dist/types.js +32 -0
  144. package/dist/types.js.map +1 -0
  145. package/dist/verify.d.ts +30 -0
  146. package/dist/verify.d.ts.map +1 -0
  147. package/dist/verify.js +174 -0
  148. package/dist/verify.js.map +1 -0
  149. package/dist/version.d.ts +13 -0
  150. package/dist/version.d.ts.map +1 -0
  151. package/dist/version.js +13 -0
  152. package/dist/version.js.map +1 -0
  153. package/hooks/hooks.json +15 -0
  154. package/package.json +71 -0
  155. package/prompts/search-agent.md +160 -0
  156. package/skills/remembering-conversations/MCP-TOOLS.md +147 -0
  157. package/skills/remembering-conversations/SKILL.md +97 -0
@@ -0,0 +1,91 @@
1
+ /**
2
+ * File-based exclusive locks. Thin wrapper around the `proper-lockfile`
3
+ * package, which uses an atomic mkdir + mtime-heartbeat protocol that is
4
+ * race-free under concurrent stale-stealers — the failure mode that pure
5
+ * "openSync(wx) + PID file" implementations cannot fully close without
6
+ * advisory locking (flock/fcntl).
7
+ *
8
+ * Used by long-running background work that must not run more than once at a
9
+ * time on a given machine: the embedding migration (#73) and
10
+ * `sync --background` (#97).
11
+ *
12
+ * On disk for a held lock at `<lockPath>`:
13
+ * <lockPath> — diagnostic file containing the holder's PID
14
+ * <lockPath>.lock/ — proper-lockfile's mutex directory (mkdir-atomic)
15
+ *
16
+ * Stale recovery is mtime-based with a 10-minute threshold: if the holder
17
+ * crashed without releasing, the .lock/ directory's mtime stops advancing,
18
+ * and a contender past the threshold steals it atomically. The protocol's
19
+ * atomicity guarantee is the package's contract — see proper-lockfile's
20
+ * README for the underlying analysis (the same approach used by npm itself).
21
+ *
22
+ * Error policy:
23
+ * - `null` means lock contention.
24
+ * - Unexpected I/O errors (EACCES, ENOSPC, EMFILE, etc.) are thrown so
25
+ * callers can surface disk problems rather than mask them as "locked".
26
+ */
27
+ import fs from "node:fs";
28
+ import path from "node:path";
29
+ import * as lockfile from "proper-lockfile";
30
+ /**
31
+ * Default stale threshold for the underlying proper-lockfile mtime heartbeat.
32
+ * 10 minutes is well above the longest expected sync (a few minutes for a
33
+ * cold start with hundreds of pending summaries) and the longest expected
34
+ * embedding migration batch (seconds).
35
+ */
36
+ const DEFAULT_STALE_MS = 10 * 60 * 1000;
37
+ export function acquireFileLock(lockPath) {
38
+ fs.mkdirSync(path.dirname(lockPath), { recursive: true });
39
+ // proper-lockfile expects the target path to exist. Touch it if missing —
40
+ // 'a' (append, create if missing) leaves any existing PID intact. An I/O
41
+ // failure here (EACCES, ENOSPC) is a disk problem and must not be masked as
42
+ // contention, so it propagates. Upstream wrapped this in a
43
+ // `catch (err: any) { throw err }` that did nothing at all.
44
+ fs.closeSync(fs.openSync(lockPath, "a"));
45
+ let release;
46
+ try {
47
+ release = lockfile.lockSync(lockPath, {
48
+ realpath: false,
49
+ retries: 0,
50
+ stale: DEFAULT_STALE_MS,
51
+ });
52
+ }
53
+ catch (err) {
54
+ if (err?.code === "ELOCKED")
55
+ return null;
56
+ throw err;
57
+ }
58
+ // Hold acquired. Record our PID for diagnostics ("which process holds the
59
+ // lock right now?"). Best-effort — the mutex itself lives in .lock/.
60
+ try {
61
+ fs.writeFileSync(lockPath, String(process.pid), "utf-8");
62
+ }
63
+ catch { }
64
+ return { path: lockPath, release };
65
+ }
66
+ export function releaseFileLock(handle) {
67
+ try {
68
+ handle.release();
69
+ }
70
+ catch { }
71
+ // Clean up the diagnostic file. A subsequent acquirer will recreate it.
72
+ try {
73
+ fs.unlinkSync(handle.path);
74
+ }
75
+ catch { }
76
+ }
77
+ /**
78
+ * Read the recorded holder PID from a lock file's diagnostic content.
79
+ * Returns null if the file doesn't exist or doesn't contain a valid PID.
80
+ * The PID is informational only — the real mutex lives in `<lockPath>.lock/`.
81
+ */
82
+ export function readLockHolder(lockPath) {
83
+ try {
84
+ const pid = parseInt(fs.readFileSync(lockPath, "utf-8").trim(), 10);
85
+ return Number.isFinite(pid) && pid > 0 ? pid : null;
86
+ }
87
+ catch {
88
+ return null;
89
+ }
90
+ }
91
+ //# sourceMappingURL=file-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-lock.js","sourceRoot":"","sources":["../src/file-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAO5C;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAExC,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE1D,0EAA0E;IAC1E,yEAAyE;IACzE,4EAA4E;IAC5E,2DAA2D;IAC3D,4DAA4D;IAC5D,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;IAEzC,IAAI,OAAmB,CAAC;IACxB,IAAI,CAAC;QACH,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE;YACpC,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,CAAC;YACV,KAAK,EAAE,gBAAgB;SACxB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,IAAK,GAAyC,EAAE,IAAI,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QAChF,MAAM,GAAG,CAAC;IACZ,CAAC;IAED,0EAA0E;IAC1E,qEAAqE;IACrE,IAAI,CAAC;QACH,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IAEV,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAsB;IACpD,IAAI,CAAC;QACH,MAAM,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,wEAAwE;IACxE,IAAI,CAAC;QACH,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACpE,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `moe-memory index` — index, verify, repair or rebuild the conversation index.
3
+ *
4
+ * Collapses two upstream layers: `cli/index-conversations.js` (flag parsing,
5
+ * the `--rebuild` confirmation prompt, help text) and `dist/index-cli.js`
6
+ * (subcommand dispatch). They were separate only because one was a shim that
7
+ * spawned the other.
8
+ */
9
+ export declare function runIndex(args: string[]): Promise<number>;
10
+ //# sourceMappingURL=index-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-cli.d.ts","sourceRoot":"","sources":["../src/index-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA4EH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAiI9D"}
@@ -0,0 +1,195 @@
1
+ /**
2
+ * `moe-memory index` — index, verify, repair or rebuild the conversation index.
3
+ *
4
+ * Collapses two upstream layers: `cli/index-conversations.js` (flag parsing,
5
+ * the `--rebuild` confirmation prompt, help text) and `dist/index-cli.js`
6
+ * (subcommand dispatch). They were separate only because one was a shim that
7
+ * spawned the other.
8
+ */
9
+ import fs from "node:fs";
10
+ import path from "node:path";
11
+ import { createInterface } from "node:readline";
12
+ import { initDatabase } from "./db.js";
13
+ import { indexConversations, indexSession, indexUnprocessed } from "./indexer.js";
14
+ import { JournalStore } from "./journal/store.js";
15
+ import { getArchiveDir, getDbPath } from "./paths.js";
16
+ import { repairIndex, verifyIndex } from "./verify.js";
17
+ const HELP = `
18
+ Usage: moe-memory index [COMMAND] [OPTIONS]
19
+
20
+ COMMANDS:
21
+ (default) Index all conversations
22
+ --cleanup Process only unindexed conversations (fast, cheap)
23
+ --session ID Index specific session (used by the SessionStart hook)
24
+ --verify Check index health
25
+ --repair Fix detected issues
26
+ --rebuild Delete DB and re-index everything (requires confirmation)
27
+
28
+ OPTIONS:
29
+ --concurrency N Parallel summarization (1-16, default: 1)
30
+ -c N Short form of --concurrency
31
+ --no-summaries Skip AI summary generation (free, but no summaries in results)
32
+ --help, -h Show this help
33
+
34
+ EXAMPLES:
35
+ # Index all unprocessed (recommended for backfill)
36
+ moe-memory index --cleanup
37
+
38
+ # Index with 8 parallel summarizations (8x faster)
39
+ moe-memory index --cleanup --concurrency 8
40
+
41
+ # Index without AI summaries (free, fast)
42
+ moe-memory index --cleanup --no-summaries
43
+
44
+ # Check index health
45
+ moe-memory index --verify
46
+
47
+ # Fix any issues found
48
+ moe-memory index --repair
49
+
50
+ # Nuclear option (deletes everything, re-indexes)
51
+ moe-memory index --rebuild
52
+
53
+ WORKFLOW:
54
+ 1. Initial setup: moe-memory index --cleanup
55
+ 2. Ongoing: auto-indexed by the SessionStart hook (moe-memory sync)
56
+ 3. Health check: moe-memory index --verify (weekly)
57
+ 4. Recovery: moe-memory index --repair (if issues found)
58
+ `;
59
+ function getConcurrency(args) {
60
+ const idx = args.findIndex((arg) => arg === "--concurrency" || arg === "-c");
61
+ if (idx !== -1) {
62
+ const raw = args[idx + 1];
63
+ if (raw) {
64
+ const value = Number.parseInt(raw, 10);
65
+ if (value >= 1 && value <= 16)
66
+ return value;
67
+ }
68
+ }
69
+ return 1; // default
70
+ }
71
+ function askConfirmation(question) {
72
+ return new Promise((resolve) => {
73
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
74
+ rl.question(question, (answer) => {
75
+ rl.close();
76
+ resolve(answer.toLowerCase() === "yes");
77
+ });
78
+ });
79
+ }
80
+ export async function runIndex(args) {
81
+ if (args.includes("--help") || args.includes("-h")) {
82
+ console.log(HELP);
83
+ return 0;
84
+ }
85
+ const concurrency = getConcurrency(args);
86
+ const noSummaries = args.includes("--no-summaries");
87
+ const command = args[0];
88
+ if (command === "--session") {
89
+ const sessionId = args[1];
90
+ if (!sessionId) {
91
+ console.error("Usage: moe-memory index --session <session-id>");
92
+ return 1;
93
+ }
94
+ await indexSession(sessionId, concurrency, noSummaries);
95
+ return 0;
96
+ }
97
+ if (command === "--cleanup") {
98
+ await indexUnprocessed(concurrency, noSummaries);
99
+ return 0;
100
+ }
101
+ if (command === "--verify") {
102
+ console.log("Verifying conversation index...");
103
+ const issues = await verifyIndex();
104
+ console.log("\n=== Verification Results ===");
105
+ console.log(`Missing summaries: ${issues.missing.length}`);
106
+ console.log(`Orphaned entries: ${issues.orphaned.length}`);
107
+ console.log(`Outdated files: ${issues.outdated.length}`);
108
+ console.log(`Corrupted files: ${issues.corrupted.length}`);
109
+ if (issues.missing.length > 0) {
110
+ console.log("\nMissing summaries:");
111
+ for (const m of issues.missing)
112
+ console.log(` ${m.path}`);
113
+ }
114
+ const total = issues.missing.length +
115
+ issues.orphaned.length +
116
+ issues.outdated.length +
117
+ issues.corrupted.length;
118
+ if (total > 0) {
119
+ console.log("\nRun with --repair to fix these issues.");
120
+ return 1;
121
+ }
122
+ console.log("\n✅ Index is healthy!");
123
+ return 0;
124
+ }
125
+ if (command === "--repair") {
126
+ console.log("Verifying conversation index...");
127
+ const issues = await verifyIndex();
128
+ if (issues.missing.length + issues.orphaned.length + issues.outdated.length > 0) {
129
+ await repairIndex(issues, { noSummaries });
130
+ }
131
+ else {
132
+ console.log("✅ No issues to repair!");
133
+ }
134
+ return 0;
135
+ }
136
+ if (command === "--rebuild") {
137
+ console.log("⚠️ This will DELETE the entire database and re-index everything.");
138
+ if (!args.includes("--yes") && !(await askConfirmation("Are you sure? [yes/NO]: "))) {
139
+ console.log("Cancelled");
140
+ return 0;
141
+ }
142
+ console.log("Rebuilding entire index...");
143
+ const dbPath = getDbPath();
144
+ if (fs.existsSync(dbPath)) {
145
+ fs.unlinkSync(dbPath);
146
+ console.log("Deleted existing database");
147
+ }
148
+ const archiveDir = getArchiveDir();
149
+ if (fs.existsSync(archiveDir)) {
150
+ for (const project of fs.readdirSync(archiveDir)) {
151
+ const projectPath = path.join(archiveDir, project);
152
+ if (!fs.statSync(projectPath).isDirectory())
153
+ continue;
154
+ const summaries = fs.readdirSync(projectPath).filter((f) => f.endsWith("-summary.txt"));
155
+ for (const summary of summaries) {
156
+ fs.unlinkSync(path.join(projectPath, summary));
157
+ }
158
+ }
159
+ console.log("Deleted all summary files");
160
+ }
161
+ console.log("Re-indexing all conversations...");
162
+ await indexConversations(undefined, undefined, concurrency, noSummaries);
163
+ // Re-index the journal too.
164
+ //
165
+ // `getDbPath()` is ONE database holding both record types — conversation
166
+ // turns and journal entries (src/db.ts). So `--rebuild` deletes the journal
167
+ // index as well, and re-indexing conversations does not bring it back: the
168
+ // command used to return 0 having silently emptied half the store. Journal
169
+ // markdown is the source of truth and always survives, so nothing was
170
+ // unrecoverable, but the user was never told they now had to run
171
+ // `moe-memory journal index` by hand, and a search would just quietly
172
+ // return nothing.
173
+ //
174
+ // Failure here is reported and does not fail the rebuild: the conversation
175
+ // re-index above may have taken hours and cost money in summarisation, and
176
+ // throwing that away over a journal walk would be the worse outcome.
177
+ console.log("Re-indexing the journal...");
178
+ const journalDb = initDatabase();
179
+ try {
180
+ const journal = await new JournalStore().indexJournal(journalDb);
181
+ console.log(`✅ Journal re-indexed: ${journal.indexed} indexed, ${journal.failed} failed, ${journal.total} entries on disk`);
182
+ }
183
+ catch (error) {
184
+ console.error(`⚠️ Journal re-index failed: ${error instanceof Error ? error.message : String(error)}`);
185
+ console.error(" Run `moe-memory journal index` to retry. Your entries are safe on disk.");
186
+ }
187
+ finally {
188
+ journalDb.close();
189
+ }
190
+ return 0;
191
+ }
192
+ await indexConversations(undefined, undefined, concurrency, noSummaries);
193
+ return 0;
194
+ }
195
+ //# sourceMappingURL=index-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-cli.js","sourceRoot":"","sources":["../src/index-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCZ,CAAC;AAEF,SAAS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4B;QAC5B,EAAE;QACF,yEAAyE;QACzE,4EAA4E;QAC5E,2EAA2E;QAC3E,2EAA2E;QAC3E,sEAAsE;QACtE,iEAAiE;QACjE,sEAAsE;QACtE,kBAAkB;QAClB,EAAE;QACF,2EAA2E;QAC3E,2EAA2E;QAC3E,qEAAqE;QACrE,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YACjE,OAAO,CAAC,GAAG,CACT,yBAAyB,OAAO,CAAC,OAAO,aAAa,OAAO,CAAC,MAAM,YAAY,OAAO,CAAC,KAAK,kBAAkB,CAC/G,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CACX,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACzF,CAAC;YACF,OAAO,CAAC,KAAK,CAAC,6EAA6E,CAAC,CAAC;QAC/F,CAAC;gBAAS,CAAC;YACT,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IACzE,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,12 @@
1
+ export * from "./constants.js";
2
+ export * from "./db.js";
3
+ export * from "./embedding-migration.js";
4
+ export * from "./embeddings.js";
5
+ export * from "./indexer.js";
6
+ export * from "./journal/index.js";
7
+ export * from "./parser.js";
8
+ export * from "./paths.js";
9
+ export * from "./search.js";
10
+ export * from "./summarizer.js";
11
+ export * from "./types.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ // Public API for the @bubstack/moe-memory package.
2
+ //
3
+ // This file is a pure re-export barrel with no side effects. private-journal-mcp
4
+ // also had a `src/index.ts` — but theirs was the executable entry point, with a
5
+ // shebang, argv parsing and a server boot. Both names could not survive in place;
6
+ // the barrel keeps the filename and the executable became src/cli.ts, which is
7
+ // what the package's single `bin` points at.
8
+ export * from "./constants.js";
9
+ export * from "./db.js";
10
+ export * from "./embedding-migration.js";
11
+ export * from "./embeddings.js";
12
+ export * from "./indexer.js";
13
+ export * from "./journal/index.js";
14
+ export * from "./parser.js";
15
+ export * from "./paths.js";
16
+ export * from "./search.js";
17
+ export * from "./summarizer.js";
18
+ export * from "./types.js";
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,kFAAkF;AAClF,+EAA+E;AAC/E,6CAA6C;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function indexConversations(limitToProject?: string, maxConversations?: number, concurrency?: number, noSummaries?: boolean): Promise<void>;
2
+ export declare function indexSession(sessionId: string, _concurrency?: number, noSummaries?: boolean): Promise<void>;
3
+ export declare function indexUnprocessed(concurrency?: number, noSummaries?: boolean): Promise<void>;
4
+ //# sourceMappingURL=indexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../src/indexer.ts"],"names":[],"mappings":"AA4CA,wBAAsB,kBAAkB,CACtC,cAAc,CAAC,EAAE,MAAM,EACvB,gBAAgB,CAAC,EAAE,MAAM,EACzB,WAAW,GAAE,MAAU,EACvB,WAAW,GAAE,OAAe,GAC3B,OAAO,CAAC,IAAI,CAAC,CA8Jf;AAED,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EAGjB,YAAY,GAAE,MAAU,EACxB,WAAW,GAAE,OAAe,GAC3B,OAAO,CAAC,IAAI,CAAC,CA6Ff;AAED,wBAAsB,gBAAgB,CACpC,WAAW,GAAE,MAAU,EACvB,WAAW,GAAE,OAAe,GAC3B,OAAO,CAAC,IAAI,CAAC,CAyIf"}