A self-organizing Obsidian vault that gives AI coding agents persistent memory.
TypeScript ai-agentsclaude-codecodex-cligemini-cliknowledge-managementobsidianobsidian-vaultpersistent-memorysecond-braintemplate
fix: manifest-check compared platform paths to posix globs (#221)
Brenno Ferrari81a5a026edc5
diff --git a/.claude/scripts/tests/manifest-check.test.ts b/.claude/scripts/tests/manifest-check.test.tsindex 44a48da..e9c142d 100644--- a/.claude/scripts/tests/manifest-check.test.ts+++ b/.claude/scripts/tests/manifest-check.test.ts@@ -6,11 +6,19 @@import { test, describe } from "node:test";import assert from "node:assert/strict";+import { mkdtempSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";import {globToRegex,isCovered,+ toPosix,+ listTopLevelFiles,} from "../../../.github/scripts/manifest-check.ts";+/** The real manifest's shape, in miniature. */+const GLOBS = ["CLAUDE.md", ".claude/**", "templates/**", "brain/Skills.md"];+describe("globToRegex", () => {test("exact string (no wildcards)", () => {const r = globToRegex("CLAUDE.md");@@ -65,13 +73,6 @@ describe("globToRegex", () => {});describe("isCovered", () => {- const GLOBS = [- "CLAUDE.md",- ".claude/**",- "templates/**",- "brain/Skills.md",- ];-test("exact-string glob matches the same string", () => {assert.equal(isCovered("CLAUDE.md", GLOBS), true);assert.equal(isCovered("brain/Skills.md", GLOBS), true);@@ -95,4 +96,66 @@ describe("isCovered", () => {assert.equal(isCovered("CLAUDE.md.bak", GLOBS), false);assert.equal(isCovered("x/CLAUDE.md", GLOBS), false);});++ // The manifest globs are POSIX, but the directory walk built its paths with+ // `join`, which emits the PLATFORM separator. On Windows that made every+ // infrastructure file look uncovered, so the check failed against a clean+ // tree for every Windows contributor, while CI runs Linux and saw nothing.+ //+ // Asserted with a literal backslash rather than by running the walk, so the+ // guard can fail on ANY platform. A test that only goes red on Windows is a+ // test no CI machine will ever run.+ test("a windows-separated path is covered by a posix glob", () => {+ assert.equal(isCovered(".claude\\commands\\om-tidy.md", GLOBS), true);+ assert.equal(isCovered("templates\\Work Note.md", GLOBS), true);+ });++ test("normalizing separators does not make an uncovered path covered", () => {+ assert.equal(isCovered("work\\active\\project.md", GLOBS), false);+ });+});++describe("toPosix", () => {+ test("converts backslashes and leaves posix paths alone", () => {+ assert.equal(toPosix(".claude\\agents\\x.md"), ".claude/agents/x.md");+ assert.equal(toPosix(".claude/agents/x.md"), ".claude/agents/x.md");+ });++ test("a nullish path does not throw its way into the walk", () => {+ assert.equal(toPosix(undefined as unknown as string), "");+ });+});++// The seam the bug lived in. The walk is the one place a platform separator+// enters, and this file's header used to say it was "exercised live by the+// workflow" — which only ever runs Linux.+describe("listTopLevelFiles", () => {+ // Driven against a real directory rather than the repo's own, so the test+ // does not depend on the cwd the runner happens to use.+ test("emits posix-separated paths its own globs can match", () => {+ const dir = mkdtempSync(join(tmpdir(), "mc-"));+ try {+ writeFileSync(join(dir, "alpha.md"), "x", "utf8");+ writeFileSync(join(dir, "beta.md"), "x", "utf8");+ writeFileSync(join(dir, "ignored.txt"), "x", "utf8");++ const found = listTopLevelFiles(dir, [".md"]);+ assert.equal(found.length, 2, "extension filter still applies");+ for (const p of found) {+ assert.ok(!p.includes("\\"), `walk emitted a platform separator: ${p}`);+ }+ // The property that actually matters: what the walk emits is a shape+ // the manifest globs can match. On Windows the old walk failed this.+ const globs = [`${toPosix(dir)}/**`];+ for (const p of found) {+ assert.ok(isCovered(p, globs), `walk emitted a path its own glob cannot match: ${p}`);+ }+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+ });++ test("a missing directory is empty, not a throw", () => {+ assert.deepEqual(listTopLevelFiles("does/not/exist", [".md"]), []);+ });});diff --git a/.github/scripts/manifest-check.ts b/.github/scripts/manifest-check.tsindex 3223b10..56d3654 100644--- a/.github/scripts/manifest-check.ts+++ b/.github/scripts/manifest-check.ts@@ -41,18 +41,37 @@ export function globToRegex(glob: string): RegExp {return new RegExp(`^${pattern}$`);}+/**+ * Normalize a filesystem path to the POSIX separator the manifest globs use.+ *+ * `node:path`'s `join` emits the PLATFORM separator, so the directory walk+ * below produced Windows-separated paths while every glob in+ * vault-manifest.json is written POSIX-style (`.claude/**`). `globToRegex`+ * matches the forward slash literally, so nothing matched at all: the check+ * reported every infrastructure file as uncovered and exited 1 against a clean+ * tree, for every Windows contributor. The workflow runs on Linux, so CI never+ * saw it.+ */+export function toPosix(path: string): string {+ return String(path ?? "").split("\\").join("/");+}+/*** Return true if `path` is covered by any entry in `globs`. Exact-string* globs (no wildcards) are matched literally; wildcard globs go through* globToRegex.+ *+ * The path is normalized first, so this answers the same question whatever+ * separator the caller happens to hand it.*/export function isCovered(path: string,globs: readonly string[],): boolean {+ const p = toPosix(path);for (const g of globs) {- if (g === path) return true;- if (g.includes("*") && globToRegex(g).test(path)) return true;+ if (g === p) return true;+ if (g.includes("*") && globToRegex(g).test(p)) return true;}return false;}@@ -99,7 +118,7 @@ const WATCHED_ROOT_FILES: readonly string[] = ["obsidian-mind-logo.png",];-function listTopLevelFiles(dir: string, exts: readonly string[]): string[] {+export function listTopLevelFiles(dir: string, exts: readonly string[]): string[] {let entries: Dirent[];try {entries = readdirSync(dir, { withFileTypes: true });@@ -108,7 +127,10 @@ function listTopLevelFiles(dir: string, exts: readonly string[]): string[] {}return entries.filter((e) => e.isFile() && exts.some((x) => e.name.endsWith(x)))- .map((e) => join(dir, e.name));+ // Normalized here as well as inside `isCovered`, so the paths printed in+ // the failure message are the same shape as the globs the reader is being+ // asked to compare them against.+ .map((e) => toPosix(join(dir, e.name)));}function listRootFiles(allowlist: readonly string[]): string[] {