Skip to content

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

fix: close manifest coverage gaps and prepare v5.0 release metadata (#50)

Brenno Ferrari9e1f0ab96897
diff --git a/.claude/scripts/tests/generate-changelog.test.ts b/.claude/scripts/tests/generate-changelog.test.ts
index c1b8dae..827193e 100644
--- a/.claude/scripts/tests/generate-changelog.test.ts
+++ b/.claude/scripts/tests/generate-changelog.test.ts
@@ -11,6 +11,9 @@ import {
classifyCommit,
generateSection,
normalizeVersion,
+ toFingerprintKey,
+ pickMarkers,
+ findLatestOpenFingerprint,
} from "../../../.github/scripts/generate-changelog.ts";
describe("classifyCommit", () => {
@@ -118,3 +121,167 @@ describe("normalizeVersion", () => {
assert.equal(normalizeVersion("5.2.3"), "5.2.3");
});
});
+
+describe("toFingerprintKey", () => {
+ test("drops .0 patch for minor releases", () => {
+ assert.equal(toFingerprintKey("5.0.0"), "v5.0");
+ assert.equal(toFingerprintKey("v5.0"), "v5.0");
+ assert.equal(toFingerprintKey("5.0"), "v5.0");
+ });
+ test("preserves non-zero patch", () => {
+ assert.equal(toFingerprintKey("5.1.2"), "v5.1.2");
+ assert.equal(toFingerprintKey("v3.4.1"), "v3.4.1");
+ });
+ test("double-digit components survive", () => {
+ assert.equal(toFingerprintKey("10.12.0"), "v10.12");
+ });
+});
+
+describe("pickMarkers", () => {
+ const GLOBS = [
+ "CLAUDE.md",
+ "AGENTS.md",
+ ".mcp.json",
+ ".claude/**",
+ ".codex/**",
+ ".github/scripts/generate-changelog.ts",
+ "templates/**",
+ ];
+
+ test("returns at most `limit` entries (default 3)", () => {
+ const added = [
+ "AGENTS.md",
+ ".codex/hooks.json",
+ ".mcp.json",
+ "templates/New.md",
+ ".claude/commands/new.md",
+ ];
+ const picked = pickMarkers(added, GLOBS);
+ assert.equal(picked.length, 3);
+ });
+
+ test("filters out files not covered by infrastructure globs", () => {
+ const added = ["work/active/project.md", "brain/MyGotchas.md", ".mcp.json"];
+ assert.deepEqual(pickMarkers(added, GLOBS), [".mcp.json"]);
+ });
+
+ test("skips tests/, lib/, node_modules/, and .github/", () => {
+ const added = [
+ ".claude/scripts/tests/new.test.ts",
+ ".claude/scripts/lib/internal.ts",
+ ".claude/scripts/node_modules/whatever.js",
+ ".github/workflows/new.yml",
+ ".mcp.json",
+ ];
+ assert.deepEqual(pickMarkers(added, GLOBS), [".mcp.json"]);
+ });
+
+ test("skips package.json and tsconfig.json (excluded from release zip)", () => {
+ // release.yml explicitly excludes .claude/scripts/{package,tsconfig}.json
+ // from the published zip. Using them as fingerprint markers would break
+ // version detection for zip-install users.
+ const added = [
+ ".claude/scripts/package.json",
+ ".claude/scripts/tsconfig.json",
+ ".mcp.json",
+ ];
+ assert.deepEqual(pickMarkers(added, GLOBS), [".mcp.json"]);
+ });
+
+ test("skips .test.ts files even outside a tests/ dir", () => {
+ const added = [".claude/scripts/manifest-check.test.ts", ".mcp.json"];
+ assert.deepEqual(pickMarkers(added, GLOBS), [".mcp.json"]);
+ });
+
+ test("custom limit is respected", () => {
+ const added = ["AGENTS.md", ".mcp.json", ".codex/hooks.json"];
+ assert.equal(pickMarkers(added, GLOBS, 2).length, 2);
+ });
+
+ test("returns empty when nothing qualifies", () => {
+ assert.deepEqual(pickMarkers(["work/foo.md", "README.ja.md"], GLOBS), []);
+ });
+
+ test("prefers shallow (root-level) paths over deep subdirectory paths", () => {
+ // Regression test for the original heuristic, which walked alphabetically
+ // and picked .claude/scripts/* over .mcp.json. Root-level files are
+ // more meaningful markers; they should rank first.
+ const added = [
+ ".claude/scripts/charcount.ts",
+ ".claude/scripts/classify-message.ts",
+ ".claude/scripts/package.json",
+ ".mcp.json",
+ ];
+ const picked = pickMarkers(added, GLOBS);
+ assert.equal(picked[0], ".mcp.json", "root-level .mcp.json should rank first");
+ });
+
+ test("prefers singletons in their parent dir over bulk-added siblings", () => {
+ // At the same depth, a file with fewer siblings-in-this-diff is a
+ // more distinctive marker. `a/rare.md` is alone under `a/`; `b/` has
+ // three files, so b's entries rank after a's.
+ const globs = ["**"];
+ const added = [
+ "b/mass1.md",
+ "b/mass2.md",
+ "b/mass3.md",
+ "a/rare.md",
+ ];
+ const picked = pickMarkers(added, globs, 1);
+ assert.deepEqual(picked, ["a/rare.md"]);
+ });
+
+ test("falls back to alphabetical order when depth and sibling count tie", () => {
+ const globs = ["*.md"];
+ const added = ["zebra.md", "alpha.md", "mango.md"];
+ assert.deepEqual(pickMarkers(added, globs), [
+ "alpha.md",
+ "mango.md",
+ "zebra.md",
+ ]);
+ });
+});
+
+describe("findLatestOpenFingerprint", () => {
+ test("returns the highest version without a missing field", () => {
+ const fp = {
+ "v3.7": { exists: ["x"], missing: ["y"] },
+ "v4.0": { exists: ["a"] },
+ };
+ assert.equal(findLatestOpenFingerprint(fp), "v4.0");
+ });
+
+ test("uses numeric component sort (v3.10 > v3.7)", () => {
+ const fp = {
+ "v3.7": { exists: ["a"] },
+ "v3.10": { exists: ["b"] },
+ };
+ assert.equal(findLatestOpenFingerprint(fp), "v3.10");
+ });
+
+ test("returns null when every entry is closed", () => {
+ const fp = {
+ "v3.7": { exists: ["a"], missing: ["b"] },
+ "v4.0": { exists: ["c"], missing: ["d"] },
+ };
+ assert.equal(findLatestOpenFingerprint(fp), null);
+ });
+
+ test("returns null when empty", () => {
+ assert.equal(findLatestOpenFingerprint({}), null);
+ });
+
+ test("single open entry is returned regardless of version", () => {
+ const fp = { v1: { exists: ["a"] } };
+ assert.equal(findLatestOpenFingerprint(fp), "v1");
+ });
+
+ test("mixed three-part + two-part versions sort correctly", () => {
+ const fp = {
+ "v3.6.0": { exists: ["a"] },
+ "v3.6": { exists: ["b"] }, // equivalent to v3.6.0 numerically
+ "v3.7": { exists: ["c"] },
+ };
+ assert.equal(findLatestOpenFingerprint(fp), "v3.7");
+ });
+});
diff --git a/.github/scripts/generate-changelog.ts b/.github/scripts/generate-changelog.ts
index 530137b..8276478 100644
--- a/.github/scripts/generate-changelog.ts
+++ b/.github/scripts/generate-changelog.ts
@@ -14,6 +14,7 @@
import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
import { readFileSync, writeFileSync } from "node:fs";
+import { isCovered } from "./manifest-check.ts";
const PREFIX_MAP: Readonly<Record<string, string>> = {
feat: "Added",
@@ -174,11 +175,220 @@ export function normalizeVersion(version: string): string {
return `${major}.${minor}.${patch ?? "0"}`;
}
-function updateManifest(version: string): void {
+/**
+ * Derive the fingerprint key from a release version. A `.0` patch is dropped
+ * to match the existing manifest convention (e.g. "5.0.0" → "v5.0", while
+ * "5.1.2" stays "v5.1.2"). Keys are prefixed with `v` for parity with git tags.
+ */
+export function toFingerprintKey(version: string): string {
+ const normalized = normalizeVersion(version);
+ const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(normalized);
+ if (!match) return `v${normalized}`;
+ const [, major, minor, patch] = match;
+ return patch === "0" ? `v${major}.${minor}` : `v${major}.${minor}.${patch}`;
+}
+
+/**
+ * Files added between the previous tag and HEAD, via `git diff --diff-filter=A`.
+ * Returns paths relative to the repo root. An empty list signals "nothing
+ * structurally new was added in this release" — callers treat it as "skip
+ * fingerprint generation."
+ */
+function getAddedFiles(prevTag: string): string[] {
+ const proc = spawnSync(
+ "git",
+ [
+ "diff",
+ `${prevTag}..HEAD`,
+ "--name-only",
+ "--diff-filter=A",
+ ],
+ { encoding: "utf-8" },
+ );
+ if (proc.status !== 0) return [];
+ return (proc.stdout ?? "")
+ .split("\n")
+ .map((l) => l.trim())
+ .filter((l) => l.length > 0);
+}
+
+/**
+ * Paths to skip when picking fingerprint markers, even if they're covered by
+ * the manifest's infrastructure globs. These are volatile implementation
+ * details — tests, internal libs, CI plumbing, vendored deps — that shouldn't
+ * serve as stable version markers because they may be renamed or removed.
+ */
+/**
+ * Paths to skip when picking fingerprint markers. Two rules they all serve:
+ * (1) skip volatile implementation details (tests, internal libs, vendored
+ * deps) because they may be renamed or removed; (2) skip paths that are
+ * **excluded from the release zip** (`.github/**`, `.claude/scripts/tests/**`,
+ * `.claude/scripts/{package,tsconfig}.json`, `.claude/scripts/node_modules/**`
+ * — see `.github/workflows/release.yml` zip -x entries). Zip-excluded paths
+ * would produce fingerprints that don't work for users who install from the
+ * published zip instead of a git clone.
+ */
+const MARKER_SKIP_PATTERNS: readonly RegExp[] = [
+ /(^|\/)tests?\//,
+ /(^|\/)lib\//,
+ /(^|\/)node_modules\//,
+ /\.github\//,
+ /\.test\.ts$/,
+ /(^|\/)(package|tsconfig)\.json$/,
+];
+
+/**
+ * Return the immediate parent directory of a path, or "" for root-level files.
+ * Used to reason about how "alone" a file is among its siblings in the diff.
+ */
+function parentOf(path: string): string {
+ const idx = path.lastIndexOf("/");
+ return idx === -1 ? "" : path.slice(0, idx);
+}
+
+/**
+ * Choose up to `limit` stable version markers from the newly-added files.
+ * A marker must be (a) covered by the manifest's infrastructure globs — so
+ * it's template content, not user content — and (b) not in a skip pattern.
+ *
+ * Among qualifying candidates we prefer more *distinctive* files: shallower
+ * paths (root files and top-level directory additions tend to be feature
+ * declarations rather than plumbing) and singletons in their parent
+ * directory (a file added alone in its folder is a stronger signal than
+ * one of 15 files added to a bulk-migrated directory). Alphabetical order
+ * is the final tiebreak so the output is deterministic.
+ */
+export function pickMarkers(
+ addedFiles: readonly string[],
+ infrastructureGlobs: readonly string[],
+ limit = 3,
+): string[] {
+ const qualified = addedFiles.filter(
+ (p) =>
+ isCovered(p, infrastructureGlobs) &&
+ !MARKER_SKIP_PATTERNS.some((re) => re.test(p)),
+ );
+
+ // Count siblings-added-in-this-diff per parent directory. Only other
+ // qualified files count — skipped/uncovered additions don't dilute the
+ // signal because they wouldn't be candidates anyway.
+ const siblingCount = new Map<string, number>();
+ for (const p of qualified) {
+ const parent = parentOf(p);
+ siblingCount.set(parent, (siblingCount.get(parent) ?? 0) + 1);
+ }
+
+ const ranked = [...qualified].sort((a, b) => {
+ const depthA = a.split("/").length;
+ const depthB = b.split("/").length;
+ if (depthA !== depthB) return depthA - depthB;
+ const sibA = siblingCount.get(parentOf(a)) ?? 0;
+ const sibB = siblingCount.get(parentOf(b)) ?? 0;
+ if (sibA !== sibB) return sibA - sibB;
+ return a.localeCompare(b);
+ });
+
+ return ranked.slice(0, limit);
+}
+
+type Fingerprint = {
+ exists: string[];
+ missing?: string[];
+};
+
+/**
+ * Find the latest fingerprint key that has no `missing` field — conceptually
+ * "the currently-open-ended release." Returns null if the map is empty or
+ * every entry already has a `missing`. Keys are sorted by numeric version
+ * components (v3.7 < v3.10, unlike string sort) so the "latest" is the one
+ * with the highest major/minor/patch.
+ */
+export function findLatestOpenFingerprint(
+ fingerprints: Readonly<Record<string, Fingerprint>>,
+): string | null {
+ const sorted = Object.keys(fingerprints).sort((a, b) => {
+ const pa = a.replace(/^v/, "").split(".").map(Number);
+ const pb = b.replace(/^v/, "").split(".").map(Number);
+ const len = Math.max(pa.length, pb.length);
+ for (let i = 0; i < len; i++) {
+ const da = pa[i] ?? 0;
+ const db = pb[i] ?? 0;
+ if (da !== db) return da - db;
+ }
+ return 0;
+ });
+ for (let i = sorted.length - 1; i >= 0; i--) {
+ const key = sorted[i]!;
+ if (!fingerprints[key]!.missing) return key;
+ }
+ return null;
+}
+
+type ManifestShape = {
+ infrastructure?: string[];
+ version_fingerprints?: Record<string, Fingerprint>;
+ [key: string]: unknown;
+};
+
+/**
+ * Auto-generate the fingerprint entry for `version` from git history, and
+ * close out the previous open-ended fingerprint so version detection stays
+ * unambiguous. No-op when there's no previous tag (first release) or when
+ * the release added no stable markers.
+ */
+function updateFingerprints(
+ version: string,
+ prevTag: string | null,
+ manifest: ManifestShape,
+): void {
+ if (!prevTag) return;
+
+ const fingerprints = manifest.version_fingerprints ?? {};
+ const key = toFingerprintKey(version);
+
+ // Re-running the release workflow for an existing version (e.g. after a
+ // hotfix rebuild) would re-derive markers from the current HEAD, which
+ // may differ from the HEAD at original-release time. That would silently
+ // invalidate version detection for vaults legitimately at the original
+ // release. Keep the original fingerprint untouched on re-runs.
+ if (key in fingerprints) {
+ process.stderr.write(
+ `Fingerprint for ${key} already exists; leaving untouched (re-run safe).\n`,
+ );
+ return;
+ }
+
+ const addedFiles = getAddedFiles(prevTag);
+ const globs = manifest.infrastructure ?? [];
+ const markers = pickMarkers(addedFiles, globs);
+
+ if (markers.length === 0) {
+ process.stderr.write(
+ `No stable infrastructure markers added since ${prevTag}; skipping fingerprint for ${version}.\n`,
+ );
+ return;
+ }
+
+ // Close out the previous open-ended fingerprint BEFORE adding the new
+ // one, so we don't look up the new entry as its own predecessor.
+ const prevKey = findLatestOpenFingerprint(fingerprints);
+ if (prevKey && prevKey !== key) {
+ fingerprints[prevKey] = {
+ ...fingerprints[prevKey]!,
+ missing: [markers[0]!],
+ };
+ }
+
+ fingerprints[key] = { exists: [...markers] };
+ manifest.version_fingerprints = fingerprints;
+}
+
+function updateManifest(version: string, prevTag: string | null): void {
const content = readFileSync("vault-manifest.json", { encoding: "utf-8" });
- const manifest = JSON.parse(content) as Record<string, unknown>;
- manifest["version"] = normalizeVersion(version);
- manifest["released"] = todayUTC();
+ const manifest = JSON.parse(content) as ManifestShape;
+ (manifest as Record<string, unknown>)["version"] = normalizeVersion(version);
+ (manifest as Record<string, unknown>)["released"] = todayUTC();
+ updateFingerprints(version, prevTag, manifest);
writeFileSync(
"vault-manifest.json",
JSON.stringify(manifest, null, 2) + "\n",
@@ -213,7 +423,7 @@ function main(): void {
}
prependToChangelog(section, version);
- updateManifest(version);
+ updateManifest(version, prevTag);
// Print section for GitHub Release body
process.stdout.write(section);
diff --git a/.github/scripts/manifest-check.ts b/.github/scripts/manifest-check.ts
index a50924d..451459b 100644
--- a/.github/scripts/manifest-check.ts
+++ b/.github/scripts/manifest-check.ts
@@ -61,18 +61,42 @@ export function isCovered(
// ---------------------------------------------------------------------------
// Top-level files in these directories are the "template infrastructure"
-// surface. Matches the hardcoded glob list in the bash predecessor.
+// surface. Each entry contributes every matching file in the directory.
const WATCHED: ReadonlyArray<{
readonly dir: string;
readonly exts: readonly string[];
}> = [
{ dir: ".claude/commands", exts: [".md"] },
{ dir: ".claude/agents", exts: [".md"] },
- { dir: ".claude/scripts", exts: [".ts"] },
+ { dir: ".claude/scripts", exts: [".ts", ".json"] },
+ { dir: ".claude-plugin", exts: [".json"] },
+ { dir: ".codex", exts: [".json", ".md"] },
+ { dir: ".gemini", exts: [".json", ".md"] },
{ dir: "templates", exts: [".md"] },
{ dir: "bases", exts: [".base"] },
];
+// Specific root-level files that are template infrastructure. Unlike the
+// dir-walks above, the root has mixed concerns (infrastructure files live
+// alongside user-content directories like work/ and brain/), so we allowlist
+// the known infrastructure files by name. This list must stay in sync with
+// the corresponding entries in vault-manifest.json's `infrastructure` array.
+const WATCHED_ROOT_FILES: readonly string[] = [
+ "AGENTS.md",
+ "CLAUDE.md",
+ "CHANGELOG.md",
+ "CONTRIBUTING.md",
+ "GEMINI.md",
+ "Home.md",
+ "LICENSE",
+ "README.md",
+ ".gitignore",
+ ".mcp.json",
+ "vault-manifest.json",
+ "obsidian-mind-demo.gif",
+ "obsidian-mind-logo.png",
+];
+
function listTopLevelFiles(dir: string, exts: readonly string[]): string[] {
let entries: Dirent[];
try {
@@ -85,6 +109,32 @@ function listTopLevelFiles(dir: string, exts: readonly string[]): string[] {
.map((e) => join(dir, e.name));
}
+function listRootFiles(allowlist: readonly string[]): string[] {
+ let entries: Dirent[];
+ try {
+ entries = readdirSync(".", { withFileTypes: true });
+ } catch {
+ return [];
+ }
+ const present = new Set(
+ entries.filter((e) => e.isFile()).map((e) => e.name),
+ );
+ const out: string[] = [];
+ for (const name of allowlist) {
+ if (present.has(name)) out.push(name);
+ }
+ // Additionally include translated READMEs (README.<lang>.md). These are
+ // managed as a glob in the manifest (`README.*.md`) rather than an
+ // enumerated list, so discover them dynamically.
+ for (const e of entries) {
+ if (!e.isFile()) continue;
+ if (/^README\.[^/]+\.md$/.test(e.name) && e.name !== "README.md") {
+ out.push(e.name);
+ }
+ }
+ return out;
+}
+
function main(): void {
const manifest = JSON.parse(
readFileSync("vault-manifest.json", "utf-8"),
@@ -97,6 +147,9 @@ function main(): void {
if (!isCovered(path, globs)) missing.push(path);
}
}
+ for (const path of listRootFiles(WATCHED_ROOT_FILES)) {
+ if (!isCovered(path, globs)) missing.push(path);
+ }
if (missing.length === 0) return;
diff --git a/.github/workflows/manifest-check.yml b/.github/workflows/manifest-check.yml
index 5884b06..020ed0e 100644
--- a/.github/workflows/manifest-check.yml
+++ b/.github/workflows/manifest-check.yml
@@ -3,11 +3,26 @@ name: Manifest Check
on:
pull_request:
paths:
+ # Template infrastructure surfaces the script walks — if these change
+ # we need to verify every file is still covered by a manifest glob.
- '.claude/commands/**'
- '.claude/agents/**'
- '.claude/scripts/**'
+ - '.claude-plugin/**'
+ - '.codex/**'
+ - '.gemini/**'
- 'templates/**'
- 'bases/**'
+ # Root-level template files (allowlisted in manifest-check.ts). A PR
+ # that adds any of these without a matching manifest entry should
+ # trigger a warning — the .mcp.json addition in #48 slipped through
+ # precisely because root files weren't watched.
+ - '*.md'
+ - '.mcp.json'
+ - '.gitignore'
+ - 'LICENSE'
+ - 'obsidian-mind-logo.png'
+ - 'obsidian-mind-demo.gif'
- 'vault-manifest.json'
- '.github/scripts/manifest-check.ts'
diff --git a/vault-manifest.json b/vault-manifest.json
index 4f4eaac..91de9e6 100644
--- a/vault-manifest.json
+++ b/vault-manifest.json
@@ -4,17 +4,25 @@
"released": "2026-04-09",
"infrastructure": [
"CLAUDE.md",
+ "AGENTS.md",
+ "GEMINI.md",
"Home.md",
"README.md",
+ "README.*.md",
"CHANGELOG.md",
"CONTRIBUTING.md",
"LICENSE",
".gitignore",
+ ".mcp.json",
".claude/**",
".claude-plugin/**",
+ ".codex/**",
+ ".gemini/**",
"templates/**",
"bases/**",
"vault-manifest.json",
+ "obsidian-mind-logo.png",
+ "obsidian-mind-demo.gif",
"brain/Skills.md",
"perf/competencies/README.md",
"thinking/README.md"
@@ -109,6 +117,17 @@
"exists": [
".claude/commands/om-standup.md",
".claude/commands/om-intake.md"
+ ],
+ "missing": [
+ "AGENTS.md"
+ ]
+ },
+ "v4.0": {
+ "exists": [
+ "AGENTS.md",
+ "GEMINI.md",
+ ".codex/hooks.json",
+ ".gemini/settings.json"
]
}
},