Skip to content

A self-organizing Obsidian vault that gives AI coding agents persistent memory.

fix: extend isMarkdownFilename across remaining session-start call sites (#92)

Brenno Ferrarie9f7edd9ea61
diff --git a/.claude/scripts/lib/session-start.ts b/.claude/scripts/lib/session-start.ts
index f891d62..8987969 100644
--- a/.claude/scripts/lib/session-start.ts
+++ b/.claude/scripts/lib/session-start.ts
@@ -31,8 +31,8 @@ export function formatActiveWork(
limit: number,
): string {
const names = filenames
- .filter((f) => f.endsWith(".md"))
- .map((f) => f.replace(/\.md$/, ""))
+ .filter((f) => isMarkdownFilename(f))
+ .map((f) => f.replace(/\.md$/i, ""))
.slice(0, limit);
return names.length > 0 ? names.join("\n") : "(none)";
}
diff --git a/.claude/scripts/session-start.ts b/.claude/scripts/session-start.ts
index 3a75a98..d1ca3f0 100644
--- a/.claude/scripts/session-start.ts
+++ b/.claude/scripts/session-start.ts
@@ -205,11 +205,11 @@ function brainIndex(): string {
return "(none)";
}
const files = entries
- .filter((e) => e.isFile() && e.name.endsWith(".md"))
+ .filter((e) => e.isFile() && isMarkdownFilename(e.name))
.map((e) => e.name)
.sort();
const parsed = files.map((f) => {
- const name = f.replace(/\.md$/, "");
+ const name = f.replace(/\.md$/i, "");
let description: string | null = null;
let hasContent = false;
try {
@@ -255,7 +255,7 @@ function listMd(): string[] {
const full = dir === "." ? e.name : join(dir, e.name);
if (isSkippedPath(full, SKIP_PREFIXES)) continue;
if (e.isDirectory()) walk(full);
- else if (e.isFile() && e.name.endsWith(".md")) results.push(`./${full}`);
+ else if (e.isFile() && isMarkdownFilename(e.name)) results.push(`./${full}`);
}
}
walk(".");
diff --git a/.claude/scripts/tests/session-start.integration.test.ts b/.claude/scripts/tests/session-start.integration.test.ts
index a06fe04..1f1e17b 100644
--- a/.claude/scripts/tests/session-start.integration.test.ts
+++ b/.claude/scripts/tests/session-start.integration.test.ts
@@ -48,6 +48,17 @@ before(() => {
join(TMP_DIR, "brain", "North Star.md"),
"---\ndescription: test\n---\n\n# North Star\n\n- placeholder\n",
);
+ // Uppercase-extension fixture: locks the case-insensitive filter wiring
+ // of `brainIndex()` (lists the topic without extension) and `listMd()`
+ // (preserves the original `.MD` in the vault file listing). On
+ // case-sensitive filesystems this is a distinct file; on Windows/macOS
+ // case-insensitive filesystems it's the same dirent — either way the
+ // listMd path must accept it and the brainIndex strip must drop the
+ // extension regardless of case.
+ writeFileSync(
+ join(TMP_DIR, "brain", "Uppercase.MD"),
+ "---\ndescription: locks case-insensitive .md detection\n---\n",
+ );
});
after(() => {
@@ -110,6 +121,29 @@ describe("session-start — silence contract and structure", () => {
assert.ok(open !== undefined, "Open Tasks section should be present");
assert.match(open ?? "", /\(no open tasks\)/);
});
+
+ test("`.MD` files (uppercase extension) appear in brain index and vault listing", () => {
+ // Locks the case-insensitive wiring of `brainIndex()` and `listMd()`
+ // at the hook level — the helper-level tests prove the predicate, this
+ // proves the predicate is what each call site actually uses.
+ const { stdout } = runHook();
+ const brain =
+ stdout.split("### Brain Topics (read on demand)\n")[1]?.split("\n### ")[0] ?? "";
+ const listing =
+ stdout.split("### Vault File Listing\n")[1] ?? "";
+ // Brain index strips the extension (case-insensitive) — bare topic name.
+ assert.match(
+ brain,
+ /Uppercase/,
+ "brainIndex must list `.MD` topics with the extension stripped",
+ );
+ // Vault file listing preserves the original casing including extension.
+ assert.match(
+ listing,
+ /Uppercase\.MD/,
+ "listMd must include `.MD` files in the vault file listing",
+ );
+ });
});
describe("session-start — openTasks aggregation", () => {
diff --git a/.claude/scripts/tests/session-start.test.ts b/.claude/scripts/tests/session-start.test.ts
index 1e7bbec..ccfa9a3 100644
--- a/.claude/scripts/tests/session-start.test.ts
+++ b/.claude/scripts/tests/session-start.test.ts
@@ -70,6 +70,13 @@ describe("formatActiveWork", () => {
test("all-filtered-out → '(none)'", () => {
assert.equal(formatActiveWork(["not-markdown.txt"], 10), "(none)");
});
+ test("preserves `.MD` and `.Md` files (case-insensitive matching)", () => {
+ const out = formatActiveWork(
+ ["Note.md", "Note.MD", "Note.Md", "notes.txt"],
+ 10,
+ );
+ assert.equal(out, "Note\nNote\nNote");
+ });
});
describe("formatRecentChanges", () => {