@jacklika/dsh-tool-memory-filesystem 0.1.3-alpha.8 → 0.1.3-alpha.9

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 (2) hide show
  1. package/lib/index.js +20 -5
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -486,10 +486,13 @@ export async function buildIndex(root, extensions, indexHiddenDirs = false) {
486
486
  }
487
487
  const index = new Map();
488
488
  for (const note of notes) {
489
+ const explicitTitle = typeof note.frontmatter.title === 'string' ? note.frontmatter.title.trim() : '';
489
490
  const headingMatch = /^#\s+(.+)$/m.exec(note.body);
490
- const title = headingMatch !== null && headingMatch[1] !== undefined
491
- ? headingMatch[1].trim()
492
- : note.id.replace(/\.[^.]+$/, '');
491
+ const title = explicitTitle !== ''
492
+ ? explicitTitle
493
+ : (headingMatch !== null && headingMatch[1] !== undefined
494
+ ? headingMatch[1].trim()
495
+ : note.id.replace(/\.[^.]+$/, ''));
493
496
  index.set(note.id, { id: note.id, title, backlinks: [], body: note.body });
494
497
  }
495
498
  const linkResolver = createLinkResolver([...index.keys()]);
@@ -683,6 +686,9 @@ export function apply(ctx, config) {
683
686
  mode: { type: 'string' },
684
687
  bytes: { type: 'integer' },
685
688
  version: { type: 'string' },
689
+ created: { type: 'string' },
690
+ updated: { type: 'string' },
691
+ committed: { type: 'boolean' },
686
692
  },
687
693
  },
688
694
  render: (_args, value) => [{ type: 'text', text: JSON.stringify(value, null, 2) }],
@@ -710,11 +716,15 @@ export function apply(ctx, config) {
710
716
  throw new Error(`tool-memory-filesystem: note ${args.id} changed since it was read; re-read it before writing`);
711
717
  }
712
718
  let finalBody;
719
+ let frontmatter = {};
713
720
  if (mode === 'overwrite') {
714
721
  finalBody = normalizeTextTimestamps(args.content);
722
+ frontmatter = splitFrontmatter(finalBody).frontmatter;
715
723
  }
716
724
  else {
717
- const { frontmatter, body } = splitFrontmatter(existing ?? '');
725
+ const split = splitFrontmatter(existing ?? '');
726
+ frontmatter = split.frontmatter;
727
+ const body = split.body;
718
728
  normalizeNoteTimestamps(frontmatter);
719
729
  const timestamp = formatBeijingTime(new Date());
720
730
  // Track note lifetime the way memory_capture does: `created` on the
@@ -738,7 +748,7 @@ export function apply(ctx, config) {
738
748
  await writeAtomic(absolutePath, finalBody);
739
749
  const info = await stat(absolutePath);
740
750
  recordMtime(absolutePath, info.mtimeMs);
741
- return {
751
+ const result = {
742
752
  id: vaultRelativeId(vaultRoot, absolutePath),
743
753
  mode,
744
754
  bytes: Buffer.byteLength(finalBody, 'utf8'),
@@ -746,6 +756,11 @@ export function apply(ctx, config) {
746
756
  // fingerprint `wiki_read` would report — without a second read.
747
757
  version: noteVersion(finalBody),
748
758
  };
759
+ if (typeof frontmatter.created === 'string' && frontmatter.created !== '')
760
+ result.created = frontmatter.created;
761
+ if (typeof frontmatter.updated === 'string' && frontmatter.updated !== '')
762
+ result.updated = frontmatter.updated;
763
+ return result;
749
764
  },
750
765
  })));
751
766
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jacklika/dsh-tool-memory-filesystem",
3
3
  "description": "Model-facing wiki/memory tools over a local Markdown vault: read, search, and write notes with Obsidian-style links and YAML frontmatter.",
4
- "version": "0.1.3-alpha.8",
4
+ "version": "0.1.3-alpha.9",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },