A self-organizing Obsidian vault that gives AI coding agents persistent memory.
TypeScript ai-agentsclaude-codecodex-cligemini-cliknowledge-managementobsidianobsidian-vaultpersistent-memorysecond-braintemplate
fix: find frontmatter by its delimiter lines, not every --- (#320)
Brenno Ferrarid02e3ccfdff2
diff --git a/.claude/scripts/lib/frontmatter.ts b/.claude/scripts/lib/frontmatter.tsindex a654694..ecf9bb9 100644--- a/.claude/scripts/lib/frontmatter.ts+++ b/.claude/scripts/lib/frontmatter.ts@@ -200,9 +200,14 @@ export function validateContent(if (!content.startsWith("---")) {warnings.push("Missing YAML frontmatter");} else {- const parts = content.split("---");- if (parts.length >= 3) {- const { keys, tags } = readFrontmatterKeys(parts[1] ?? "");+ // The block ends at the next line that is exactly `---`, not at the next+ // `---` anywhere: a value holding one (`before --- after`) used to end the+ // block there and report every later key missing. The same rule as+ // prose-width.ts, so both readers agree on where frontmatter ends.+ const lines = content.split(/\r?\n/);+ const close = lines.indexOf("---", 1);+ if (close > 0) {+ const { keys, tags } = readFrontmatterKeys(lines.slice(1, close).join("\n"));for (const field of requiredFieldsFor(opts.required ?? {}, opts.relPath ?? null, tags)) {if (keys.has(field)) continue;warnings.push(diff --git a/.claude/scripts/tests/frontmatter.test.ts b/.claude/scripts/tests/frontmatter.test.tsindex 490d2f5..3299636 100644--- a/.claude/scripts/tests/frontmatter.test.ts+++ b/.claude/scripts/tests/frontmatter.test.ts@@ -257,6 +257,32 @@ describe("validateContent — frontmatter + wikilinks", () => {assert.match(w[0]!, /^1 hard-wrapped paragraph line\(s\), first at line 9 /);});+ /**+ * #319: the block was found with `content.split("---")`, so a value holding+ * `---` ended it there and every later key was reported missing.+ */+ test("a value containing --- does not end the frontmatter", () => {+ const c = "---\ndate: 2026-01-01\ndescription: before --- after\ntags: [x]\n---\nShort.";+ assert.deepEqual(validateContent(c), []);+ });++ test("the same with CRLF line endings", () => {+ const c = "---\r\ndate: 2026-01-01\r\ndescription: before --- after\r\ntags: [x]\r\n---\r\nShort.";+ assert.deepEqual(validateContent(c), []);+ });++ test("a CRLF block is really read, not skipped: a missing key is still reported", () => {+ // "No warnings" alone would also pass if the CRLF block were never found+ // and no field was checked; a key that IS missing proves it was read.+ const c = "---\r\ndate: 2026-01-01\r\ndescription: before --- after\r\n---\r\nShort.";+ assert.deepEqual(validateContent(c), ["Missing `tags` in frontmatter"]);+ });++ test("an unclosed frontmatter still gets no field checks", () => {+ const w = validateContent("---\ndate: 2026-01-01\nShort, and no closing line.");+ assert.ok(!w.some((x) => x.startsWith("Missing `")), w.join("\n"));+ });+test("tolerates 'tags :' with space (alternate YAML style)", () => {const c ="---\ndate : 2026-04-05\ndescription : test\ntags :\n - test\n---\n# Note\n" +