@rubytech/create-maxy-code 0.1.138 → 0.1.140

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 (38) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/config/brand.json +1 -1
  3. package/payload/platform/lib/obsidian-parser/dist/index.d.ts +98 -0
  4. package/payload/platform/lib/obsidian-parser/dist/index.d.ts.map +1 -0
  5. package/payload/platform/lib/obsidian-parser/dist/index.js +480 -0
  6. package/payload/platform/lib/obsidian-parser/dist/index.js.map +1 -0
  7. package/payload/platform/lib/obsidian-parser/src/index.ts +572 -0
  8. package/payload/platform/lib/obsidian-parser/tsconfig.json +8 -0
  9. package/payload/platform/neo4j/schema.cypher +6 -0
  10. package/payload/platform/package.json +2 -2
  11. package/payload/platform/plugins/.claude-plugin/marketplace.json +10 -0
  12. package/payload/platform/plugins/docs/references/plugins-guide.md +2 -0
  13. package/payload/platform/plugins/memory/PLUGIN.md +3 -0
  14. package/payload/platform/plugins/memory/mcp/dist/index.js +89 -2
  15. package/payload/platform/plugins/memory/mcp/dist/index.js.map +1 -1
  16. package/payload/platform/plugins/memory/mcp/dist/tools/memory-archive-write.d.ts +64 -1
  17. package/payload/platform/plugins/memory/mcp/dist/tools/memory-archive-write.d.ts.map +1 -1
  18. package/payload/platform/plugins/memory/mcp/dist/tools/memory-archive-write.js +258 -0
  19. package/payload/platform/plugins/memory/mcp/dist/tools/memory-archive-write.js.map +1 -1
  20. package/payload/platform/plugins/memory/mcp/dist/tools/obsidian-vault-import.d.ts +127 -0
  21. package/payload/platform/plugins/memory/mcp/dist/tools/obsidian-vault-import.d.ts.map +1 -0
  22. package/payload/platform/plugins/memory/mcp/dist/tools/obsidian-vault-import.js +477 -0
  23. package/payload/platform/plugins/memory/mcp/dist/tools/obsidian-vault-import.js.map +1 -0
  24. package/payload/platform/plugins/notion-import/.claude-plugin/plugin.json +8 -0
  25. package/payload/platform/plugins/notion-import/PLUGIN.md +27 -0
  26. package/payload/platform/plugins/notion-import/skills/notion-import/SKILL.md +110 -0
  27. package/payload/platform/plugins/notion-import/skills/notion-import/references/attachments.md +55 -0
  28. package/payload/platform/plugins/notion-import/skills/notion-import/references/databases.md +81 -0
  29. package/payload/platform/plugins/notion-import/skills/notion-import/references/page-tree.md +61 -0
  30. package/payload/platform/plugins/notion-import/skills/notion-import/references/workspace-export.md +41 -0
  31. package/payload/platform/plugins/obsidian-import/.claude-plugin/plugin.json +8 -0
  32. package/payload/platform/plugins/obsidian-import/PLUGIN.md +39 -0
  33. package/payload/platform/plugins/obsidian-import/skills/obsidian-import/SKILL.md +92 -0
  34. package/payload/platform/plugins/obsidian-import/skills/obsidian-import/references/attachments.md +80 -0
  35. package/payload/platform/plugins/obsidian-import/skills/obsidian-import/references/daily-notes.md +31 -0
  36. package/payload/platform/plugins/obsidian-import/skills/obsidian-import/references/vault-structure.md +46 -0
  37. package/payload/platform/plugins/obsidian-import/skills/obsidian-import/references/wikilinks.md +70 -0
  38. package/payload/platform/templates/specialists/agents/database-operator.md +13 -1
@@ -0,0 +1,572 @@
1
+ /**
2
+ * obsidian-parser — pure functions for parsing an Obsidian vault on disk.
3
+ *
4
+ * No DB access, no MCP, no I/O side effects other than fs reads. Composed by
5
+ * the `obsidian-vault-import` MCP tool in the memory plugin.
6
+ *
7
+ * Doctrine: every regex is linear-time (no catastrophic backtracking), every
8
+ * function is deterministic. The agent never calls this code; the server does.
9
+ */
10
+
11
+ import { createHash } from "node:crypto";
12
+ import { promises as fs } from "node:fs";
13
+ import * as path from "node:path";
14
+
15
+ // ---------------------------------------------------------------------------
16
+ // Types
17
+ // ---------------------------------------------------------------------------
18
+
19
+ export interface ParsedPage {
20
+ /** Path relative to the vault root, with forward slashes. The MERGE natural key. */
21
+ obsidianPath: string;
22
+ /** Filename without `.md` — the default wikilink target form. */
23
+ title: string;
24
+ /** Aliases declared in frontmatter (`aliases:` array). */
25
+ aliases: string[];
26
+ /** Tag tokens (without `#`), unioned from frontmatter `tags:` and inline `#tag` body matches. */
27
+ tags: string[];
28
+ /** Body text (frontmatter stripped). Stored verbatim. */
29
+ body: string;
30
+ /** SHA-256 of the on-disk file bytes — idempotency key. */
31
+ contentHash: string;
32
+ /** Detected daily-note date (YYYY-MM-DD) or null. */
33
+ noteDate: string | null;
34
+ /** Wikilinks emitted by this page. */
35
+ wikilinks: WikilinkOccurrence[];
36
+ /** Embedded attachments declared via `![[file.png]]` or `![alt](file.png)`. */
37
+ attachments: AttachmentOccurrence[];
38
+ /** Last-modified timestamp from fs stat — used for modified-since filtering. */
39
+ mtimeMs: number;
40
+ }
41
+
42
+ export interface WikilinkOccurrence {
43
+ /** The exact text inside `[[…]]` before any alias `|`. May contain `#anchor`. */
44
+ rawTarget: string;
45
+ /** Target after stripping `#anchor`. */
46
+ target: string;
47
+ /** Anchor portion (after `#`) or null. */
48
+ anchor: string | null;
49
+ /** Alias text after `|`, or null when absent. The display text. */
50
+ alias: string | null;
51
+ }
52
+
53
+ export interface AttachmentOccurrence {
54
+ /** Path as written in the markdown. May be relative to the page or to the vault root. */
55
+ rawPath: string;
56
+ /** Resolved path relative to vault root, normalised. May not exist on disk yet. */
57
+ resolvedPath: string;
58
+ /** Display alt text (from `![alt](path)` form) or null for embed-syntax `![[file]]`. */
59
+ alt: string | null;
60
+ }
61
+
62
+ export interface VaultWalkOptions {
63
+ /** Filter: only pages whose path starts with one of these folder prefixes. */
64
+ folderPrefixes?: string[];
65
+ /** Filter: only pages whose tags intersect with this set. */
66
+ tagFilter?: string[];
67
+ /** Filter: only pages modified at or after this epoch-ms. */
68
+ modifiedSinceMs?: number;
69
+ }
70
+
71
+ // ---------------------------------------------------------------------------
72
+ // Vault walk
73
+ // ---------------------------------------------------------------------------
74
+
75
+ /**
76
+ * Walk the vault directory and return one ParsedPage per `.md` file that
77
+ * survives the optional filter set.
78
+ *
79
+ * Path-traversal defence: paths containing `..` segments are rejected at
80
+ * entry. The `vaultRoot` passed in is assumed to have already been verified
81
+ * by the caller as living under the account's archive directory.
82
+ */
83
+ export async function walkVault(
84
+ vaultRoot: string,
85
+ opts: VaultWalkOptions = {},
86
+ ): Promise<ParsedPage[]> {
87
+ const pages: ParsedPage[] = [];
88
+ const queue: string[] = [vaultRoot];
89
+
90
+ while (queue.length > 0) {
91
+ const dir = queue.shift()!;
92
+ let entries;
93
+ try {
94
+ entries = await fs.readdir(dir, { withFileTypes: true });
95
+ } catch (err) {
96
+ throw new Error(
97
+ `obsidian-parser: cannot read directory ${dir}: ${
98
+ err instanceof Error ? err.message : String(err)
99
+ }`,
100
+ );
101
+ }
102
+ for (const entry of entries) {
103
+ if (entry.name.startsWith(".")) continue;
104
+ const abs = path.join(dir, entry.name);
105
+ if (entry.isDirectory()) {
106
+ queue.push(abs);
107
+ continue;
108
+ }
109
+ if (!entry.isFile()) continue;
110
+ if (!entry.name.toLowerCase().endsWith(".md")) continue;
111
+
112
+ const rel = toPosixRelative(vaultRoot, abs);
113
+ if (rel.split("/").includes("..")) continue;
114
+
115
+ if (opts.folderPrefixes && opts.folderPrefixes.length > 0) {
116
+ const matchesPrefix = opts.folderPrefixes.some((p) =>
117
+ rel === p || rel.startsWith(p.replace(/\/?$/, "/")),
118
+ );
119
+ if (!matchesPrefix) continue;
120
+ }
121
+
122
+ let stat;
123
+ let bytes;
124
+ try {
125
+ stat = await fs.stat(abs);
126
+ bytes = await fs.readFile(abs);
127
+ } catch (err) {
128
+ // Per-file isolation — log and skip, don't abort the walk.
129
+ process.stderr.write(
130
+ `[obsidian-parser] event=read-failed file=${rel} reason=${
131
+ err instanceof Error ? err.message : String(err)
132
+ }\n`,
133
+ );
134
+ continue;
135
+ }
136
+
137
+ if (opts.modifiedSinceMs && stat.mtimeMs < opts.modifiedSinceMs) continue;
138
+
139
+ let parsed: ParsedPage;
140
+ try {
141
+ parsed = parsePage(rel, bytes, stat.mtimeMs);
142
+ } catch (err) {
143
+ process.stderr.write(
144
+ `[obsidian-parser] event=parse-failed file=${rel} reason=${
145
+ err instanceof Error ? err.message : String(err)
146
+ }\n`,
147
+ );
148
+ continue;
149
+ }
150
+
151
+ if (opts.tagFilter && opts.tagFilter.length > 0) {
152
+ const wanted = new Set(opts.tagFilter.map(normalizeTag));
153
+ const hit = parsed.tags.some((t) => wanted.has(normalizeTag(t)));
154
+ if (!hit) continue;
155
+ }
156
+
157
+ pages.push(parsed);
158
+ }
159
+ }
160
+
161
+ pages.sort((a, b) => a.obsidianPath.localeCompare(b.obsidianPath));
162
+ return pages;
163
+ }
164
+
165
+ function toPosixRelative(root: string, abs: string): string {
166
+ const rel = path.relative(root, abs);
167
+ return rel.split(path.sep).join("/");
168
+ }
169
+
170
+ // ---------------------------------------------------------------------------
171
+ // Page parser
172
+ // ---------------------------------------------------------------------------
173
+
174
+ const DAILY_NOTE_FILENAME_RE = /^(\d{4})-(\d{2})-(\d{2})(?:\.md)?$/;
175
+ const DAILY_NOTE_FOLDER_NAMES = new Set([
176
+ "daily",
177
+ "daily-notes",
178
+ "daily notes",
179
+ "journal",
180
+ "journals",
181
+ ]);
182
+
183
+ export function parsePage(
184
+ obsidianPath: string,
185
+ bytes: Buffer,
186
+ mtimeMs: number,
187
+ ): ParsedPage {
188
+ const contentHash = createHash("sha256").update(bytes).digest("hex");
189
+ const text = bytes.toString("utf8");
190
+
191
+ const { frontmatter, body } = splitFrontmatter(text);
192
+
193
+ const title = path
194
+ .basename(obsidianPath)
195
+ .replace(/\.md$/i, "")
196
+ .normalize("NFC");
197
+
198
+ const aliases = extractAliases(frontmatter);
199
+ const frontmatterTags = extractFrontmatterTags(frontmatter);
200
+ const { bodyTags, wikilinks, attachments } = scanBody(body, obsidianPath);
201
+ const tags = dedupeNormalized([...frontmatterTags, ...bodyTags]);
202
+ const noteDate = detectDailyNote(obsidianPath, frontmatter);
203
+
204
+ return {
205
+ obsidianPath,
206
+ title,
207
+ aliases: aliases.map((a) => a.normalize("NFC")),
208
+ tags,
209
+ body,
210
+ contentHash,
211
+ noteDate,
212
+ wikilinks,
213
+ attachments,
214
+ mtimeMs,
215
+ };
216
+ }
217
+
218
+ // ---------------------------------------------------------------------------
219
+ // Frontmatter
220
+ // ---------------------------------------------------------------------------
221
+
222
+ interface ParsedFrontmatter {
223
+ raw: string;
224
+ /** Map of top-level key → raw value string. Arrays are returned as the
225
+ * block following the key (caller parses per-key). */
226
+ fields: Map<string, string>;
227
+ }
228
+
229
+ const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
230
+
231
+ export function splitFrontmatter(
232
+ text: string,
233
+ ): { frontmatter: ParsedFrontmatter; body: string } {
234
+ const match = text.match(FRONTMATTER_RE);
235
+ if (!match) {
236
+ return { frontmatter: { raw: "", fields: new Map() }, body: text };
237
+ }
238
+ const raw = match[1];
239
+ const body = text.slice(match[0].length);
240
+
241
+ // Minimal YAML-subset parser: top-level `key: value` and `key:` followed by
242
+ // ` - item` lines. Not a full YAML — we explicitly limit the surface so a
243
+ // malformed frontmatter degrades to "no fields found" rather than throwing.
244
+ const fields = new Map<string, string>();
245
+ const lines = raw.split(/\r?\n/);
246
+ let currentKey: string | null = null;
247
+ let currentBlock: string[] = [];
248
+
249
+ for (const line of lines) {
250
+ if (/^[#]/.test(line.trim())) continue; // comment
251
+ const flush = () => {
252
+ if (currentKey !== null) {
253
+ const existing = fields.get(currentKey);
254
+ const next = currentBlock.join("\n");
255
+ fields.set(currentKey, existing ? existing + "\n" + next : next);
256
+ }
257
+ currentKey = null;
258
+ currentBlock = [];
259
+ };
260
+
261
+ const topMatch = line.match(/^([A-Za-z_][\w-]*)\s*:\s*(.*)$/);
262
+ if (topMatch && !line.startsWith(" ") && !line.startsWith("\t")) {
263
+ flush();
264
+ currentKey = topMatch[1];
265
+ const value = topMatch[2];
266
+ if (value.trim() === "") {
267
+ currentBlock = [];
268
+ } else {
269
+ currentBlock = [value];
270
+ flush();
271
+ }
272
+ continue;
273
+ }
274
+ if (currentKey !== null) {
275
+ currentBlock.push(line);
276
+ }
277
+ }
278
+ if (currentKey !== null) {
279
+ const existing = fields.get(currentKey);
280
+ const next = currentBlock.join("\n");
281
+ fields.set(currentKey, existing ? existing + "\n" + next : next);
282
+ }
283
+
284
+ return { frontmatter: { raw, fields }, body };
285
+ }
286
+
287
+ function extractAliases(fm: ParsedFrontmatter): string[] {
288
+ return parseYamlList(fm.fields.get("aliases"));
289
+ }
290
+
291
+ function extractFrontmatterTags(fm: ParsedFrontmatter): string[] {
292
+ return parseYamlList(fm.fields.get("tags")).map(normalizeTag);
293
+ }
294
+
295
+ function parseYamlList(value: string | undefined): string[] {
296
+ if (!value) return [];
297
+ const trimmed = value.trim();
298
+ if (!trimmed) return [];
299
+ // Flow-style: [a, b, c]
300
+ if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
301
+ return trimmed
302
+ .slice(1, -1)
303
+ .split(",")
304
+ .map((s) => s.trim().replace(/^["']|["']$/g, ""))
305
+ .filter(Boolean);
306
+ }
307
+ // Block-style: - item per line, or single scalar
308
+ const lines = trimmed.split(/\r?\n/);
309
+ if (lines.length === 1 && !lines[0].startsWith("-")) {
310
+ return [lines[0].replace(/^["']|["']$/g, "").trim()].filter(Boolean);
311
+ }
312
+ const out: string[] = [];
313
+ for (const line of lines) {
314
+ const m = line.match(/^\s*-\s*(.*?)\s*$/);
315
+ if (m) {
316
+ const v = m[1].replace(/^["']|["']$/g, "").trim();
317
+ if (v) out.push(v);
318
+ }
319
+ }
320
+ return out;
321
+ }
322
+
323
+ // ---------------------------------------------------------------------------
324
+ // Body scan: wikilinks, tags, attachments — all code-fence-aware
325
+ // ---------------------------------------------------------------------------
326
+
327
+ const WIKILINK_RE = /\[\[([^\]\r\n]+)\]\]/g;
328
+ const EMBED_RE = /!\[\[([^\]\r\n]+)\]\]/g;
329
+ const IMAGE_RE = /!\[([^\]\r\n]*)\]\(([^)\r\n]+)\)/g;
330
+ const INLINE_TAG_RE = /(^|[\s(])#([A-Za-z][\w/-]*)/g;
331
+ const ATTACHMENT_EXT_RE = /\.(png|jpe?g|gif|webp|svg|pdf|mp3|mp4|mov|wav|m4a|webm)$/i;
332
+
333
+ interface BodyScan {
334
+ bodyTags: string[];
335
+ wikilinks: WikilinkOccurrence[];
336
+ attachments: AttachmentOccurrence[];
337
+ }
338
+
339
+ function scanBody(body: string, obsidianPath: string): BodyScan {
340
+ const bodyTags: string[] = [];
341
+ const wikilinks: WikilinkOccurrence[] = [];
342
+ const attachments: AttachmentOccurrence[] = [];
343
+
344
+ for (const segment of splitOnCodeFences(body)) {
345
+ if (segment.isCode) continue;
346
+ const text = segment.text;
347
+
348
+ // Embeds first — they share `[[…]]` with wikilinks but the `!` prefix
349
+ // routes them to attachments.
350
+ const embedSpans: Array<[number, number]> = [];
351
+ for (const m of text.matchAll(EMBED_RE)) {
352
+ const inner = m[1].trim();
353
+ const resolved = resolveAttachmentPath(inner, obsidianPath);
354
+ if (resolved && ATTACHMENT_EXT_RE.test(resolved)) {
355
+ attachments.push({ rawPath: inner, resolvedPath: resolved, alt: null });
356
+ } else {
357
+ // Non-attachment embed (e.g. another note transclusion). Treat as a
358
+ // wikilink so the cross-reference is preserved.
359
+ wikilinks.push(parseWikilinkInner(inner));
360
+ }
361
+ embedSpans.push([m.index ?? 0, (m.index ?? 0) + m[0].length]);
362
+ }
363
+
364
+ for (const m of text.matchAll(WIKILINK_RE)) {
365
+ const start = m.index ?? 0;
366
+ if (embedSpans.some(([s, e]) => start >= s - 1 && start < e)) continue;
367
+ wikilinks.push(parseWikilinkInner(m[1]));
368
+ }
369
+
370
+ for (const m of text.matchAll(IMAGE_RE)) {
371
+ const rawPath = m[2].trim();
372
+ const alt = m[1].trim() || null;
373
+ if (/^https?:\/\//i.test(rawPath)) continue; // remote
374
+ const resolved = resolveAttachmentPath(rawPath, obsidianPath);
375
+ if (resolved && ATTACHMENT_EXT_RE.test(resolved)) {
376
+ attachments.push({ rawPath, resolvedPath: resolved, alt });
377
+ }
378
+ }
379
+
380
+ for (const m of text.matchAll(INLINE_TAG_RE)) {
381
+ bodyTags.push(normalizeTag(m[2]));
382
+ }
383
+ }
384
+
385
+ return {
386
+ bodyTags: dedupeNormalized(bodyTags),
387
+ wikilinks,
388
+ attachments,
389
+ };
390
+ }
391
+
392
+ function parseWikilinkInner(inner: string): WikilinkOccurrence {
393
+ const trimmed = inner.trim();
394
+ const aliasIdx = trimmed.indexOf("|");
395
+ let raw = trimmed;
396
+ let alias: string | null = null;
397
+ if (aliasIdx >= 0) {
398
+ raw = trimmed.slice(0, aliasIdx).trim();
399
+ alias = trimmed.slice(aliasIdx + 1).trim() || null;
400
+ }
401
+ const anchorIdx = raw.indexOf("#");
402
+ let target = raw;
403
+ let anchor: string | null = null;
404
+ if (anchorIdx >= 0) {
405
+ target = raw.slice(0, anchorIdx).trim();
406
+ anchor = raw.slice(anchorIdx + 1).trim() || null;
407
+ }
408
+ return { rawTarget: raw, target: target.normalize("NFC"), anchor, alias };
409
+ }
410
+
411
+ function resolveAttachmentPath(
412
+ rawPath: string,
413
+ obsidianPath: string,
414
+ ): string | null {
415
+ if (!rawPath) return null;
416
+ if (rawPath.startsWith("/") || /^[A-Za-z]:[\\/]/.test(rawPath)) return null;
417
+ if (rawPath.split("/").includes("..")) return null;
418
+ // Obsidian's default: vault-root relative. We also accept page-relative.
419
+ // For the resolved form we prefer vault-root-relative (more deterministic
420
+ // for MERGE), normalising path separators.
421
+ const norm = rawPath.replace(/\\/g, "/");
422
+ if (norm.includes("/")) return norm;
423
+ // Bare filename — could be in any attachments folder. Caller's index does
424
+ // the lookup; we record the bare form.
425
+ return norm;
426
+ }
427
+
428
+ function splitOnCodeFences(text: string): Array<{ text: string; isCode: boolean }> {
429
+ const out: Array<{ text: string; isCode: boolean }> = [];
430
+ const fenceRe = /(^|\n)(```|~~~)[^\n]*\n([\s\S]*?)\n(```|~~~)/g;
431
+ let lastIdx = 0;
432
+ for (const m of text.matchAll(fenceRe)) {
433
+ const start = (m.index ?? 0) + (m[1] ? m[1].length : 0);
434
+ out.push({ text: text.slice(lastIdx, start), isCode: false });
435
+ out.push({ text: m[0], isCode: true });
436
+ lastIdx = start + m[0].length - (m[1] ? m[1].length : 0);
437
+ }
438
+ out.push({ text: text.slice(lastIdx), isCode: false });
439
+ return out;
440
+ }
441
+
442
+ // ---------------------------------------------------------------------------
443
+ // Tag normalization
444
+ // ---------------------------------------------------------------------------
445
+
446
+ export function normalizeTag(tag: string): string {
447
+ return tag
448
+ .replace(/^#/, "")
449
+ .normalize("NFC")
450
+ .trim()
451
+ .toLowerCase();
452
+ }
453
+
454
+ function dedupeNormalized(values: string[]): string[] {
455
+ const seen = new Set<string>();
456
+ const out: string[] = [];
457
+ for (const v of values) {
458
+ const k = v.normalize("NFC").trim().toLowerCase();
459
+ if (!k) continue;
460
+ if (seen.has(k)) continue;
461
+ seen.add(k);
462
+ out.push(v);
463
+ }
464
+ return out;
465
+ }
466
+
467
+ // ---------------------------------------------------------------------------
468
+ // Daily-notes detection
469
+ // ---------------------------------------------------------------------------
470
+
471
+ export function detectDailyNote(
472
+ obsidianPath: string,
473
+ fm: ParsedFrontmatter,
474
+ ): string | null {
475
+ // 1. Frontmatter `date:` or `created:` wins if it's an ISO date.
476
+ for (const key of ["date", "created"]) {
477
+ const v = fm.fields.get(key);
478
+ if (v) {
479
+ const m = v.trim().match(/^(\d{4}-\d{2}-\d{2})/);
480
+ if (m) return m[1];
481
+ }
482
+ }
483
+ // 2. Filename matches YYYY-MM-DD.md.
484
+ const basename = path.basename(obsidianPath);
485
+ const fileMatch = basename.match(DAILY_NOTE_FILENAME_RE);
486
+ if (fileMatch) return `${fileMatch[1]}-${fileMatch[2]}-${fileMatch[3]}`;
487
+
488
+ // 3. Filename is YYYY-MM-DD inside a known daily-notes folder.
489
+ const parts = obsidianPath.split("/");
490
+ const inDailyFolder = parts
491
+ .slice(0, -1)
492
+ .some((p) => DAILY_NOTE_FOLDER_NAMES.has(p.toLowerCase()));
493
+ if (inDailyFolder) {
494
+ const stem = basename.replace(/\.md$/i, "");
495
+ const m = stem.match(/^(\d{4})-(\d{2})-(\d{2})$/);
496
+ if (m) return `${m[1]}-${m[2]}-${m[3]}`;
497
+ }
498
+ return null;
499
+ }
500
+
501
+ // ---------------------------------------------------------------------------
502
+ // Wikilink resolution helpers
503
+ // ---------------------------------------------------------------------------
504
+
505
+ export interface VaultIndex {
506
+ /** Lowercased title (without `.md`) → set of `obsidianPath` candidates. */
507
+ byTitle: Map<string, string[]>;
508
+ /** Lowercased alias → set of `obsidianPath` candidates. */
509
+ byAlias: Map<string, string[]>;
510
+ }
511
+
512
+ export function buildVaultIndex(pages: ParsedPage[]): VaultIndex {
513
+ const byTitle = new Map<string, string[]>();
514
+ const byAlias = new Map<string, string[]>();
515
+ for (const p of pages) {
516
+ pushKey(byTitle, p.title.toLowerCase(), p.obsidianPath);
517
+ for (const a of p.aliases) {
518
+ pushKey(byAlias, a.toLowerCase(), p.obsidianPath);
519
+ }
520
+ }
521
+ return { byTitle, byAlias };
522
+ }
523
+
524
+ function pushKey(m: Map<string, string[]>, k: string, v: string): void {
525
+ const arr = m.get(k);
526
+ if (arr) {
527
+ if (!arr.includes(v)) arr.push(v);
528
+ } else {
529
+ m.set(k, [v]);
530
+ }
531
+ }
532
+
533
+ /**
534
+ * Look up a wikilink target inside the vault, returning candidate page paths.
535
+ *
536
+ * The target is matched against (a) page titles and (b) declared aliases.
537
+ * Path-form targets (`Folder/Page`) match directly. Returns an empty array
538
+ * when no intra-vault candidate exists — the caller falls through to entity
539
+ * resolution.
540
+ */
541
+ export function resolveWikilinkInVault(
542
+ target: string,
543
+ index: VaultIndex,
544
+ knownPaths: Set<string>,
545
+ ): string[] {
546
+ const t = target.normalize("NFC").trim();
547
+ if (!t) return [];
548
+ // Path-form: contains a slash or ends with `.md`.
549
+ if (t.includes("/") || t.toLowerCase().endsWith(".md")) {
550
+ const norm = t.replace(/\\/g, "/").replace(/\.md$/i, "") + ".md";
551
+ if (knownPaths.has(norm)) return [norm];
552
+ return [];
553
+ }
554
+ const titleHits = index.byTitle.get(t.toLowerCase()) ?? [];
555
+ const aliasHits = index.byAlias.get(t.toLowerCase()) ?? [];
556
+ const seen = new Set<string>();
557
+ const out: string[] = [];
558
+ for (const p of [...titleHits, ...aliasHits]) {
559
+ if (seen.has(p)) continue;
560
+ seen.add(p);
561
+ out.push(p);
562
+ }
563
+ return out;
564
+ }
565
+
566
+ // ---------------------------------------------------------------------------
567
+ // Import-id helper
568
+ // ---------------------------------------------------------------------------
569
+
570
+ export function makeImportId(): string {
571
+ return `obs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
572
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src"
6
+ },
7
+ "include": ["src"]
8
+ }
@@ -236,6 +236,12 @@ FOR (k:KnowledgeDocument) ON (k.accountId);
236
236
  CREATE INDEX knowledge_doc_source_url IF NOT EXISTS
237
237
  FOR (k:KnowledgeDocument) ON (k.sourceUrl);
238
238
 
239
+ // obsidianPath — natural key for vault pages MERGEd by the obsidian-import
240
+ // plugin. Per-account by composing accountId in the MERGE pattern; the index
241
+ // here speeds up the lookup on re-imports for the idempotency check.
242
+ CREATE INDEX knowledge_doc_obsidian_path IF NOT EXISTS
243
+ FOR (k:KnowledgeDocument) ON (k.obsidianPath);
244
+
239
245
  CREATE VECTOR INDEX knowledge_doc_embedding IF NOT EXISTS
240
246
  FOR (k:KnowledgeDocument) ON (k.embedding)
241
247
  OPTIONS {
@@ -6,8 +6,8 @@
6
6
  "services/*"
7
7
  ],
8
8
  "scripts": {
9
- "build": "tsc -p lib/models/tsconfig.json && tsc -p lib/oauth-llm/tsconfig.json && tsc -p lib/mcp-stderr-tee/tsconfig.json && tsc -p lib/mcp-spawn-tee/tsconfig.json && tsc -p lib/mcp-eager/tsconfig.json && tsc -p lib/account-enumeration/tsconfig.json && tsc -p lib/graph-write/tsconfig.json && tsc -p lib/graph-mcp/tsconfig.json && tsc -p lib/graph-trash/tsconfig.json && tsc -p lib/admin-conversation-purge/tsconfig.json && tsc -p lib/graph-search/tsconfig.json && tsc -p lib/graph-style/tsconfig.json && tsc -p lib/screening-patterns/tsconfig.json && tsc -p lib/device-url/tsconfig.json && tsc -p lib/brand-templating/tsconfig.json && tsc -p lib/entitlement/tsconfig.json && tsc -p lib/task-secrets/tsconfig.json && tsc -p lib/admins-write/tsconfig.json && tsc -p lib/persistent-components/tsconfig.json && tsc -p lib/require-port-env/tsconfig.json && tsc -p lib/aeo-llms-txt-writer/tsconfig.json && tsc -p services/claude-session-manager/tsconfig.json && NODE_OPTIONS='--max-old-space-size=8192' tsc -b plugins/*/mcp/tsconfig.json",
10
- "build:lib": "tsc -p lib/models/tsconfig.json && tsc -p lib/oauth-llm/tsconfig.json && tsc -p lib/mcp-stderr-tee/tsconfig.json && tsc -p lib/mcp-spawn-tee/tsconfig.json && tsc -p lib/mcp-eager/tsconfig.json && tsc -p lib/account-enumeration/tsconfig.json && tsc -p lib/graph-write/tsconfig.json && tsc -p lib/graph-mcp/tsconfig.json && tsc -p lib/graph-trash/tsconfig.json && tsc -p lib/admin-conversation-purge/tsconfig.json && tsc -p lib/graph-search/tsconfig.json && tsc -p lib/graph-style/tsconfig.json && tsc -p lib/screening-patterns/tsconfig.json && tsc -p lib/device-url/tsconfig.json && tsc -p lib/brand-templating/tsconfig.json && tsc -p lib/entitlement/tsconfig.json && tsc -p lib/task-secrets/tsconfig.json && tsc -p lib/admins-write/tsconfig.json && tsc -p lib/persistent-components/tsconfig.json && tsc -p lib/require-port-env/tsconfig.json && tsc -p lib/aeo-llms-txt-writer/tsconfig.json",
9
+ "build": "tsc -p lib/models/tsconfig.json && tsc -p lib/oauth-llm/tsconfig.json && tsc -p lib/mcp-stderr-tee/tsconfig.json && tsc -p lib/mcp-spawn-tee/tsconfig.json && tsc -p lib/mcp-eager/tsconfig.json && tsc -p lib/account-enumeration/tsconfig.json && tsc -p lib/graph-write/tsconfig.json && tsc -p lib/graph-mcp/tsconfig.json && tsc -p lib/graph-trash/tsconfig.json && tsc -p lib/admin-conversation-purge/tsconfig.json && tsc -p lib/graph-search/tsconfig.json && tsc -p lib/graph-style/tsconfig.json && tsc -p lib/screening-patterns/tsconfig.json && tsc -p lib/device-url/tsconfig.json && tsc -p lib/brand-templating/tsconfig.json && tsc -p lib/entitlement/tsconfig.json && tsc -p lib/task-secrets/tsconfig.json && tsc -p lib/admins-write/tsconfig.json && tsc -p lib/persistent-components/tsconfig.json && tsc -p lib/require-port-env/tsconfig.json && tsc -p lib/aeo-llms-txt-writer/tsconfig.json && tsc -p lib/obsidian-parser/tsconfig.json && tsc -p services/claude-session-manager/tsconfig.json && NODE_OPTIONS='--max-old-space-size=8192' tsc -b plugins/*/mcp/tsconfig.json",
10
+ "build:lib": "tsc -p lib/models/tsconfig.json && tsc -p lib/oauth-llm/tsconfig.json && tsc -p lib/mcp-stderr-tee/tsconfig.json && tsc -p lib/mcp-spawn-tee/tsconfig.json && tsc -p lib/mcp-eager/tsconfig.json && tsc -p lib/account-enumeration/tsconfig.json && tsc -p lib/graph-write/tsconfig.json && tsc -p lib/graph-mcp/tsconfig.json && tsc -p lib/graph-trash/tsconfig.json && tsc -p lib/admin-conversation-purge/tsconfig.json && tsc -p lib/graph-search/tsconfig.json && tsc -p lib/graph-style/tsconfig.json && tsc -p lib/screening-patterns/tsconfig.json && tsc -p lib/device-url/tsconfig.json && tsc -p lib/brand-templating/tsconfig.json && tsc -p lib/entitlement/tsconfig.json && tsc -p lib/task-secrets/tsconfig.json && tsc -p lib/admins-write/tsconfig.json && tsc -p lib/persistent-components/tsconfig.json && tsc -p lib/require-port-env/tsconfig.json && tsc -p lib/aeo-llms-txt-writer/tsconfig.json && tsc -p lib/obsidian-parser/tsconfig.json",
11
11
  "build:memory": "tsc -p plugins/memory/mcp/tsconfig.json",
12
12
  "build:contacts": "tsc -p plugins/contacts/mcp/tsconfig.json",
13
13
  "build:telegram": "tsc -p plugins/telegram/mcp/tsconfig.json",
@@ -64,6 +64,16 @@
64
64
  "source": "./memory",
65
65
  "version": "0.1.0"
66
66
  },
67
+ {
68
+ "name": "notion-import",
69
+ "source": "./notion-import",
70
+ "version": "0.1.0"
71
+ },
72
+ {
73
+ "name": "obsidian-import",
74
+ "source": "./obsidian-import",
75
+ "version": "0.1.0"
76
+ },
67
77
  {
68
78
  "name": "outlook",
69
79
  "source": "./outlook",
@@ -38,6 +38,8 @@ These are enabled during onboarding and can be added or removed at any time. Som
38
38
  | `whatsapp` | WhatsApp messaging, pairing, and conversation browsing | Personal assistant |
39
39
  | `replicate` | Image generation — three models for photorealistic, design, and fast draft images | Content producer, Research assistant |
40
40
  | `linkedin-import` | Import a LinkedIn Basic Data Export — Profile and Connections today, more CSVs as references land | Database operator |
41
+ | `notion-import` | Import a Notion workspace export (markdown + CSV) — pages, databases, hierarchy, attachments, schema-bounded relations, `@person` mentions account-filtered | Database operator |
42
+ | `obsidian-import` | Import an extracted Obsidian vault — pages map to `:KnowledgeDocument`, wikilinks resolve to intra-vault pages or existing entities, tags become `:DefinedTerm`, embedded images become `:DigitalDocument`. Two-phase tool (dry-run → operator disambiguation → commit). | Database operator |
41
43
  | `memory/skills/conversation-archive` | Source-agnostic conversation transcript ingest. One skill for WhatsApp `_chat.txt`, Telegram, Signal, LinkedIn DMs, Zoom transcript, meeting minutes, iMessage, Slack — `--source <enum>` selects the per-source normaliser. Single Bash entry — `bash platform/plugins/memory/bin/conversation-archive-ingest.sh <archive> --source <enum> --owner-element-id <id> --participant-person-ids <csv> --scope <admin\|public>` — runs normalise → operator-confirms owner + every distinct sender → sessionize at gap-hours boundaries (default 12h) → classify each session via Haiku (`memory-classify` with `mode='chat'`) into topic-bounded `:Section:Conversation` chunks → memory-ingest with `parentLabel='ConversationArchive'`, `source=<enum>`. Re-imports are delta-append. Auto-creating participants is forbidden — any sender outside the operator-confirmed closed set LOUD-FAILs with `parser-miss`. Phase 0 ships only `whatsapp`; other normalisers land per-source. Distinct from the live `whatsapp` plugin (Baileys). | Database operator |
42
44
  | `memory/skills/conversation-archive-enrich` | Phase 2 for any named `:ConversationArchive` — source-agnostic per-row insight derivation. Operator-triggered (never auto-fires on Phase 1 completion). Walks `:Section:Conversation` chunks in pages via the read-only MCP tool `mcp__memory__conversation-archive-derive-insights`; surfaces high-confidence claims for per-row operator gate (`wire / skip / reject`) over four kinds — `mention`, `task`, `preference`, `observed-relationship`. Idempotent on `(elementId(chunk), kind, contentHash)` — re-runs collapse identical claims. Haiku runs on OAuth (admin-side LLM never the API key); confidence floor is a hedging-avoidance instruction in the system prompt, not a numeric post-filter. | Database operator |
43
45
 
@@ -56,6 +56,9 @@ tools:
56
56
  - name: memory-archive-write
57
57
  publicAllowlist: false
58
58
  adminAllowlist: false
59
+ - name: obsidian-vault-import
60
+ publicAllowlist: false
61
+ adminAllowlist: false
59
62
  - name: conversation-archive-derive-insights
60
63
  publicAllowlist: false
61
64
  adminAllowlist: false