Skip to content

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

fix: find the vault root in hook commands after /cd (#270)

Brenno Ferrarif7086d85d66b
diff --git a/.claude/scripts/generate-memory-index.ts b/.claude/scripts/generate-memory-index.ts
index d4adfe0..6f1f691 100644
--- a/.claude/scripts/generate-memory-index.ts
+++ b/.claude/scripts/generate-memory-index.ts
@@ -8,7 +8,8 @@
* node --experimental-strip-types .claude/scripts/generate-memory-index.ts \
* > ~/.claude/projects/<slug>/memory/MEMORY.md
*
- * Run from the vault root (or with CLAUDE_PROJECT_DIR set).
+ * Run from anywhere inside the vault: the root is found by walking up to
+ * vault-manifest.json (lib/project-dir.ts), from CLAUDE_PROJECT_DIR when set.
*/
import { readdirSync, readFileSync } from "node:fs";
diff --git a/.claude/scripts/lib/project-dir.ts b/.claude/scripts/lib/project-dir.ts
index 96e1be3..beab478 100644
--- a/.claude/scripts/lib/project-dir.ts
+++ b/.claude/scripts/lib/project-dir.ts
@@ -7,28 +7,56 @@
* An empty value counts as unset (`||`, not `??`): an empty string is never
* a usable root, and treating it as one resolved paths against "".
*
- * The fallback is the caller's. Every hook passes the working directory:
- * the hook commands themselves resolve their script through
- * `${*_PROJECT_DIR:-.}`, so when the variable is unset the hook only runs at
- * all if cwd is the vault. Not to be confused with qmd-refresh.ts's
- * resolveVaultRoot, which ignores these variables on purpose (a detached
- * worker anchors to its own location), or with mcp-context.ts's, which
- * reads the MCP server's own vault-path override.
+ * The fallback is the caller's. Every hook passes the working directory.
+ * The Codex and Gemini hook commands resolve their script through
+ * `${*_PROJECT_DIR:-.}`, so there a hook only runs at all when the variable
+ * or cwd names the vault root. The Claude commands walk up from
+ * `${CLAUDE_PROJECT_DIR:-.}` instead (below). Not to be confused with
+ * qmd-refresh.ts's resolveVaultRoot, which ignores these variables on purpose
+ * (a detached worker anchors to its own location), or with mcp-context.ts's,
+ * which reads the MCP server's own vault-path override.
+ *
+ * The directory named is not always the vault root (#263). Claude Code sets
+ * CLAUDE_PROJECT_DIR to the folder the session was launched in and does not
+ * update it on `/cd`, so a session started in a vault subfolder and moved to
+ * the root with `/cd` loads the root's hooks while the variable still names
+ * the subfolder. So the result walks up from the named directory to the
+ * nearest one holding `vault-manifest.json`, and falls back to the named
+ * directory itself when there is none above it (a script run outside a
+ * vault keeps today's behaviour). The Claude hook commands do the same walk
+ * in the shell, to find the script at all.
*/
+import { statSync } from "node:fs";
+import { dirname, join } from "node:path";
+
const PROJECT_DIR_VARS = [
"CLAUDE_PROJECT_DIR",
"CODEX_PROJECT_DIR",
"GEMINI_PROJECT_DIR",
] as const;
-export function resolveProjectDir(
- fallback: string,
- env: NodeJS.ProcessEnv = process.env,
-): string {
- for (const name of PROJECT_DIR_VARS) {
- const value = env[name];
- if (value) return value;
+/** The file whose presence marks a vault root. */
+export const VAULT_MARKER = "vault-manifest.json";
+
+/** A regular file, as the hook commands' `[ -f ]` tests: a directory of that name is not a vault. */
+const holdsMarker = (dir: string): boolean => {
+ try {
+ return statSync(join(dir, VAULT_MARKER), { throwIfNoEntry: false })?.isFile() ?? false;
+ } catch {
+ return false;
+ }
+};
+
+export function resolveProjectDir(fallback: string, env: NodeJS.ProcessEnv = process.env): string {
+ const named = PROJECT_DIR_VARS.map((name) => env[name]).find(Boolean) ?? fallback;
+ return nearestVaultRoot(named) ?? named;
+}
+
+/** `dir` or the nearest ancestor that is a vault root, or null when none is. */
+export function nearestVaultRoot(dir: string): string | null {
+ for (let current = dir; ; current = dirname(current)) {
+ if (holdsMarker(current)) return current;
+ if (dirname(current) === current) return null;
}
- return fallback;
}
diff --git a/.claude/scripts/pre-compact.ts b/.claude/scripts/pre-compact.ts
index d69dffc..4558db0 100644
--- a/.claude/scripts/pre-compact.ts
+++ b/.claude/scripts/pre-compact.ts
@@ -4,7 +4,8 @@
* compacts its context so lost history can be rehydrated from disk if
* needed. Keeps the most recent 30 backups; older ones are pruned.
*
- * Backups land in `${CLAUDE_PROJECT_DIR}/thinking/session-logs/` named
+ * Backups land in the vault root's `thinking/session-logs/` (the root found
+ * by lib/project-dir.ts) named
* `session_<trigger>_<YYYYMMDD_HHMMSS>.jsonl`.
*/
diff --git a/.claude/scripts/qmd-mcp.mjs b/.claude/scripts/qmd-mcp.mjs
index 25af538..a68397e 100644
--- a/.claude/scripts/qmd-mcp.mjs
+++ b/.claude/scripts/qmd-mcp.mjs
@@ -27,7 +27,7 @@
*/
import { spawn, spawnSync } from "node:child_process";
-import { existsSync, readFileSync } from "node:fs";
+import { existsSync, readFileSync, statSync } from "node:fs";
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
import { createRequire } from "node:module";
import { fileURLToPath, pathToFileURL } from "node:url";
@@ -41,10 +41,28 @@ const require = createRequire(import.meta.url);
* the path math without depending on the current process's working directory
* or CLAUDE_PROJECT_DIR. Layout assumption: the wrapper lives at
* `<vault>/.claude/scripts/qmd-mcp.mjs`, so the vault root is two levels up.
+ *
+ * CLAUDE_PROJECT_DIR names the folder the session was launched in, which can
+ * be a vault subfolder (#263), so the root is the nearest folder at or above
+ * it that holds vault-manifest.json, as lib/project-dir.ts resolves it for the
+ * hooks. With no manifest above, the named folder itself.
*/
export function resolveVaultRoot(metaUrl, env = process.env) {
+ // A regular file, as the hook commands' `[ -f ]` tests: a directory of that name is not a vault.
+ const isFile = (path) => {
+ try {
+ return statSync(path, { throwIfNoEntry: false })?.isFile() ?? false;
+ } catch {
+ return false;
+ }
+ };
const envRoot = env["CLAUDE_PROJECT_DIR"];
- if (envRoot && isAbsolute(envRoot)) return envRoot;
+ if (envRoot && isAbsolute(envRoot)) {
+ for (let dir = envRoot; ; dir = dirname(dir)) {
+ if (isFile(join(dir, "vault-manifest.json"))) return dir;
+ if (dirname(dir) === dir) return envRoot;
+ }
+ }
return resolve(dirname(fileURLToPath(metaUrl)), "..", "..");
}
diff --git a/.claude/scripts/tests/hook-config.test.ts b/.claude/scripts/tests/hook-config.test.ts
index db4c6d6..1ddcb41 100644
--- a/.claude/scripts/tests/hook-config.test.ts
+++ b/.claude/scripts/tests/hook-config.test.ts
@@ -13,13 +13,22 @@
* was reverted (89bb963) without a recorded rationale; the replacement
* fix re-applies the same pattern. This test exists so the revert
* doesn't silently happen a third time.
+ *
+ * Claude Code's commands go one step further (#263): CLAUDE_PROJECT_DIR is
+ * the folder the session was launched in and does not follow `/cd`, so it can
+ * name a vault subfolder. They start from `${CLAUDE_PROJECT_DIR:-.}` and
+ * walk up to the nearest folder holding vault-manifest.json. The last block
+ * runs each real command to prove it.
*/
-import { test, describe } from "node:test";
+import { test, describe, before, after } from "node:test";
import assert from "node:assert/strict";
-import { readFileSync } from "node:fs";
-import { dirname, resolve } from "node:path";
+import { spawnSync } from "node:child_process";
+import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
+import { nearestVaultRoot } from "../lib/project-dir.ts";
type HookConfig = {
readonly hooks?: Record<
@@ -99,12 +108,24 @@ describe("hook config — CWD-independent script resolution (issue #45)", () =>
});
for (const { event, command } of commands) {
- test(`${event} uses \${${envVar}:-.}/ prefix`, () => {
- assert.ok(
- command.includes(`\${${envVar}:-.}/.claude/scripts/`),
- `${path} ${event} command must resolve scripts via \${${envVar}:-.}/ to survive CWD drift — got:\n ${command}`,
- );
- });
+ if (envVar === "CLAUDE_PROJECT_DIR") {
+ // Claude Code does not update CLAUDE_PROJECT_DIR on `/cd`, so it can
+ // name a vault subfolder (#263). Its commands start from the variable
+ // and walk up to the vault root; the run test below proves they work.
+ test(`${event} walks up from \${${envVar}:-.} to the vault root (#263)`, () => {
+ assert.ok(
+ command.includes(`r="\${${envVar}:-.}"`) && command.includes("vault-manifest.json") && command.includes(")/.claude/scripts/"),
+ `${path} ${event} command must find the vault root from \${${envVar}:-.} — got:\n ${command}`,
+ );
+ });
+ } else {
+ test(`${event} uses \${${envVar}:-.}/ prefix`, () => {
+ assert.ok(
+ command.includes(`\${${envVar}:-.}/.claude/scripts/`),
+ `${path} ${event} command must resolve scripts via \${${envVar}:-.}/ to survive CWD drift — got:\n ${command}`,
+ );
+ });
+ }
test(`${event} does not use a bare relative .claude/scripts/ path`, () => {
// A bare relative path only survives if the invoking shell's
@@ -172,3 +193,102 @@ describe("hook config — the checklist runs where its message is shown", () =>
});
}
});
+
+/**
+ * #263: run every Claude hook command for real, with `node` replaced by a
+ * shell function that prints its arguments, and check which script it would
+ * run. Claude Code runs hook commands through a POSIX shell (Git Bash on
+ * Windows), so this is the same shell, quoting and path handling, minus the
+ * script itself. On macOS and Linux each command also runs under `sh`.
+ */
+describe("hook config — Claude commands find the vault root from a subfolder (#263)", () => {
+ const commands = eachNodeHookCommand(loadConfig(".claude/settings.json"));
+ const scriptOf = (command: string) => /\/\.claude\/scripts\/([a-z-]+\.ts)"$/.exec(command)?.[1] ?? "";
+
+ test("every command walks up with the same text: one rule, five copies that cannot drift", () => {
+ // JSON cannot share a snippet, so each command carries the walk-up. Each
+ // copy is also run below, but only this keeps one copy from quietly
+ // losing a branch (the fallback, say) that the run cases happen not to reach.
+ const walkOf = (command: string) => command.slice(0, command.indexOf("/.claude/scripts/"));
+ const walks = new Set(commands.map(({ command }) => walkOf(command)));
+ assert.equal(commands.length, 5);
+ assert.equal(walks.size, 1, `the walk-up differs between commands:\n${[...walks].join("\n")}`);
+ assert.match([...walks][0]!, /vault-manifest\.json/);
+ });
+
+ /**
+ * The POSIX shells to run the commands under. On Windows that is Git Bash,
+ * the shell Claude Code itself uses there: never a bare `bash`, which can
+ * resolve to WSL's. None found means the run tests are skipped, with the
+ * reason in the skip, rather than failing on a missing binary.
+ */
+ function posixShells(): string[] {
+ if (process.platform !== "win32") return ["bash", "sh"].filter((sh) => spawnSync(sh, ["-c", "true"]).status === 0);
+ const candidates = [
+ process.env["CLAUDE_CODE_GIT_BASH_PATH"],
+ process.env["ProgramFiles"] && join(process.env["ProgramFiles"], "Git", "bin", "bash.exe"),
+ process.env["ProgramFiles(x86)"] && join(process.env["ProgramFiles(x86)"], "Git", "bin", "bash.exe"),
+ process.env["LOCALAPPDATA"] && join(process.env["LOCALAPPDATA"], "Programs", "Git", "bin", "bash.exe"),
+ ];
+ const found = candidates.find((path): path is string => typeof path === "string" && existsSync(path));
+ return found ? [found] : [];
+ }
+ const shells = posixShells();
+ // Locally a missing shell skips with the reason. On CI it must fail instead:
+ // a run that skips every command proves nothing and would still pass.
+ const noShell = shells.length === 0 && !process.env["CI"] ? "no POSIX shell found (on Windows: Git Bash)" : false;
+
+ /** The script path the command hands to node under `shell`, run from `cwd` with `env`. */
+ function resolvedScript(shell: string, command: string, cwd: string, env: NodeJS.ProcessEnv): string {
+ const run = spawnSync(shell, ["-c", `node() { printf '%s\\n' "$@"; }; ${command}`], { encoding: "utf-8", cwd, env });
+ assert.equal(run.status, 0, `${shell} failed: ${run.error?.message ?? run.stderr}`);
+ return run.stdout.trim().split("\n").pop() ?? "";
+ }
+ const withProjectDir = (dir: string): NodeJS.ProcessEnv => ({ ...process.env, CLAUDE_PROJECT_DIR: dir });
+ const withoutProjectDir = (): NodeJS.ProcessEnv => {
+ const env = { ...process.env };
+ delete env["CLAUDE_PROJECT_DIR"];
+ return env;
+ };
+
+ let vault = "";
+ before(() => {
+ vault = mkdtempSync(join(tmpdir(), "hook-config-vault-"));
+ mkdirSync(join(vault, "work", "deep"), { recursive: true });
+ writeFileSync(join(vault, "vault-manifest.json"), "{}");
+ });
+ after(() => rmSync(vault, { recursive: true, force: true }));
+
+ // The "no vault above" case needs a temp folder that is not itself inside a vault.
+ const tmpInVault = nearestVaultRoot(tmpdir()) !== null ? "the temp folder is inside a vault on this machine" : false;
+
+ for (const shell of shells.length ? shells : ["(none)"]) {
+ for (const { event, command } of commands) {
+ const script = scriptOf(command);
+ const label = `${event} under ${shell.split(/[\\/]/).pop()}`;
+
+ test(`${label}: launched in a subfolder, the command runs the vault root's script`, { skip: noShell }, () => {
+ assert.ok(script, `could not read the script name from: ${command}`);
+ const got = resolvedScript(shell, command, vault, withProjectDir(join(vault, "work", "deep")));
+ assert.equal(resolve(got), resolve(vault, ".claude", "scripts", script));
+ });
+
+ test(`${label}: with the variable unset, run from the vault root, the command still runs the root's script`, { skip: noShell }, () => {
+ // Claude Code always sets the variable for hooks; unset is the
+ // outside-Claude case, which keeps the pre-#263 `.` behaviour.
+ const got = resolvedScript(shell, command, vault, withoutProjectDir());
+ assert.equal(resolve(vault, got), resolve(vault, ".claude", "scripts", script));
+ });
+
+ test(`${label}: with no vault above, the command keeps the named folder`, { skip: noShell || tmpInVault }, () => {
+ const elsewhere = mkdtempSync(join(tmpdir(), "hook-config-novault-"));
+ try {
+ const got = resolvedScript(shell, command, elsewhere, withProjectDir(elsewhere));
+ assert.equal(resolve(got), resolve(elsewhere, ".claude", "scripts", script));
+ } finally {
+ rmSync(elsewhere, { recursive: true, force: true });
+ }
+ });
+ }
+ }
+});
diff --git a/.claude/scripts/tests/project-dir.test.ts b/.claude/scripts/tests/project-dir.test.ts
index e7d6223..56fbc64 100644
--- a/.claude/scripts/tests/project-dir.test.ts
+++ b/.claude/scripts/tests/project-dir.test.ts
@@ -3,9 +3,12 @@
* against, whichever of the three agents called it.
*/
-import { test, describe } from "node:test";
+import { after, before, describe, test } from "node:test";
import assert from "node:assert/strict";
-import { resolveProjectDir } from "../lib/project-dir.ts";
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { nearestVaultRoot, resolveProjectDir, VAULT_MARKER } from "../lib/project-dir.ts";
describe("resolveProjectDir", () => {
test("each agent's variable is honoured", () => {
@@ -29,3 +32,71 @@ describe("resolveProjectDir", () => {
assert.equal(resolveProjectDir("/fb", {}), "/fb");
});
});
+
+/**
+ * #263: Claude Code's CLAUDE_PROJECT_DIR names the folder the session was
+ * launched in and does not follow `/cd`, so it can name a vault subfolder.
+ * The result walks up to the nearest folder holding vault-manifest.json.
+ */
+describe("resolveProjectDir — finds the vault root above the named folder", () => {
+ // A real vault on disk, with a second vault nested inside it.
+ let root = "";
+ let inner = "";
+ before(() => {
+ root = mkdtempSync(join(tmpdir(), "pd-root-"));
+ inner = join(root, "nested-vault");
+ mkdirSync(join(root, "work", "deep"), { recursive: true });
+ mkdirSync(join(inner, "work"), { recursive: true });
+ writeFileSync(join(root, VAULT_MARKER), "{}");
+ writeFileSync(join(inner, VAULT_MARKER), "{}");
+ });
+ after(() => rmSync(root, { recursive: true, force: true }));
+
+ test("a subfolder resolves to the vault root above it", () => {
+ assert.equal(resolveProjectDir("/fb", { CLAUDE_PROJECT_DIR: join(root, "work", "deep") }), root);
+ });
+
+ test("the root itself resolves to itself", () => {
+ assert.equal(resolveProjectDir("/fb", { CLAUDE_PROJECT_DIR: root }), root);
+ });
+
+ test("the nearest root wins: a vault inside another vault resolves to the inner one", () => {
+ // Starting the search above the named folder would skip the inner root
+ // and land on the outer one; the fallback could not hide that here.
+ assert.equal(resolveProjectDir("/fb", { CLAUDE_PROJECT_DIR: inner }), inner);
+ assert.equal(resolveProjectDir("/fb", { CLAUDE_PROJECT_DIR: join(inner, "work") }), inner);
+ });
+
+ test("no vault root above the named folder keeps the named folder", { skip: nearestVaultRoot(tmpdir()) !== null ? "the temp folder is inside a vault on this machine" : false }, () => {
+ const elsewhere = join(tmpdir(), "pd-elsewhere", "x");
+ assert.equal(resolveProjectDir("/fb", { CLAUDE_PROJECT_DIR: elsewhere }), elsewhere);
+ });
+
+ test("a directory named like the marker is not a vault: the walk passes it, as the hook commands' [ -f ] does", () => {
+ // The launcher found the script at the real root; the scripts must agree.
+ const between = join(root, "work", "deep", VAULT_MARKER);
+ mkdirSync(between, { recursive: true });
+ try {
+ assert.equal(resolveProjectDir("/fb", { CLAUDE_PROJECT_DIR: join(root, "work", "deep") }), root);
+ } finally {
+ rmSync(between, { recursive: true, force: true });
+ }
+ });
+
+ test("the fallback is walked up too", () => {
+ assert.equal(resolveProjectDir(join(root, "work"), {}), root);
+ });
+
+ test("on a real filesystem the marker is vault-manifest.json", () => {
+ const vault = mkdtempSync(join(tmpdir(), "pd-vault-"));
+ try {
+ mkdirSync(join(vault, "work", "deep"), { recursive: true });
+ writeFileSync(join(vault, VAULT_MARKER), "{}");
+ assert.equal(VAULT_MARKER, "vault-manifest.json", "the hook commands in settings.json look for this same literal");
+ assert.equal(resolveProjectDir("/fb", { CLAUDE_PROJECT_DIR: join(vault, "work", "deep") }), vault);
+ assert.equal(nearestVaultRoot(join(vault, "work")), vault);
+ } finally {
+ rmSync(vault, { recursive: true, force: true });
+ }
+ });
+});
diff --git a/.claude/scripts/tests/qmd-mcp.test.ts b/.claude/scripts/tests/qmd-mcp.test.ts
index d46c669..7fb13c9 100644
--- a/.claude/scripts/tests/qmd-mcp.test.ts
+++ b/.claude/scripts/tests/qmd-mcp.test.ts
@@ -17,8 +17,9 @@
import { test, describe } from "node:test";
import assert from "node:assert/strict";
-import { existsSync } from "node:fs";
-import { isAbsolute } from "node:path";
+import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
+import { isAbsolute, join } from "node:path";
+import { tmpdir } from "node:os";
import {
resolveQmdEntry,
@@ -199,6 +200,30 @@ describe("resolveVaultRoot", () => {
assert.equal(out, "/override/root");
});
+ test("walks up from a vault subfolder in CLAUDE_PROJECT_DIR to the vault root (#263)", () => {
+ const vault = mkdtempSync(join(tmpdir(), "qmd-mcp-root-"));
+ try {
+ mkdirSync(join(vault, "work", "deep"), { recursive: true });
+ writeFileSync(join(vault, "vault-manifest.json"), "{}");
+ const out = resolveVaultRoot("file:///elsewhere/.claude/scripts/qmd-mcp.mjs", { CLAUDE_PROJECT_DIR: join(vault, "work", "deep") });
+ assert.equal(out, vault);
+ } finally {
+ rmSync(vault, { recursive: true, force: true });
+ }
+ });
+
+ test("passes a directory named vault-manifest.json, as the hook commands' [ -f ] does", () => {
+ const vault = mkdtempSync(join(tmpdir(), "qmd-mcp-dirmarker-"));
+ try {
+ mkdirSync(join(vault, "work", "vault-manifest.json"), { recursive: true });
+ writeFileSync(join(vault, "vault-manifest.json"), "{}");
+ const out = resolveVaultRoot("file:///elsewhere/.claude/scripts/qmd-mcp.mjs", { CLAUDE_PROJECT_DIR: join(vault, "work") });
+ assert.equal(out, vault);
+ } finally {
+ rmSync(vault, { recursive: true, force: true });
+ }
+ });
+
test("ignores CLAUDE_PROJECT_DIR when value is empty", () => {
const out = resolveVaultRoot(
"file:///C:/vault/.claude/scripts/qmd-mcp.mjs",
diff --git a/.claude/settings.json b/.claude/settings.json
index f76bc7e..0fda9f1 100644
--- a/.claude/settings.json
+++ b/.claude/settings.json
@@ -6,7 +6,7 @@
"hooks": [
{
"type": "command",
- "command": "node --disable-warning=ExperimentalWarning --experimental-strip-types \"${CLAUDE_PROJECT_DIR:-.}/.claude/scripts/session-start.ts\"",
+ "command": "node --disable-warning=ExperimentalWarning --experimental-strip-types \"$(r=\"${CLAUDE_PROJECT_DIR:-.}\"; d=\"$r\"; while [ ! -f \"$d/vault-manifest.json\" ] && p=\"$(dirname \"$d\")\" && [ \"$d\" != \"$p\" ]; do d=\"$p\"; done; [ -f \"$d/vault-manifest.json\" ] || d=\"$r\"; printf %s \"$d\")/.claude/scripts/session-start.ts\"",
"timeout": 30
}
]
@@ -17,7 +17,7 @@
"hooks": [
{
"type": "command",
- "command": "node --disable-warning=ExperimentalWarning --experimental-strip-types \"${CLAUDE_PROJECT_DIR:-.}/.claude/scripts/classify-message.ts\"",
+ "command": "node --disable-warning=ExperimentalWarning --experimental-strip-types \"$(r=\"${CLAUDE_PROJECT_DIR:-.}\"; d=\"$r\"; while [ ! -f \"$d/vault-manifest.json\" ] && p=\"$(dirname \"$d\")\" && [ \"$d\" != \"$p\" ]; do d=\"$p\"; done; [ -f \"$d/vault-manifest.json\" ] || d=\"$r\"; printf %s \"$d\")/.claude/scripts/classify-message.ts\"",
"timeout": 15
}
]
@@ -29,7 +29,7 @@
"hooks": [
{
"type": "command",
- "command": "node --disable-warning=ExperimentalWarning --experimental-strip-types \"${CLAUDE_PROJECT_DIR:-.}/.claude/scripts/validate-write.ts\"",
+ "command": "node --disable-warning=ExperimentalWarning --experimental-strip-types \"$(r=\"${CLAUDE_PROJECT_DIR:-.}\"; d=\"$r\"; while [ ! -f \"$d/vault-manifest.json\" ] && p=\"$(dirname \"$d\")\" && [ \"$d\" != \"$p\" ]; do d=\"$p\"; done; [ -f \"$d/vault-manifest.json\" ] || d=\"$r\"; printf %s \"$d\")/.claude/scripts/validate-write.ts\"",
"timeout": 15
}
]
@@ -40,7 +40,7 @@
"hooks": [
{
"type": "command",
- "command": "node --disable-warning=ExperimentalWarning --experimental-strip-types \"${CLAUDE_PROJECT_DIR:-.}/.claude/scripts/pre-compact.ts\"",
+ "command": "node --disable-warning=ExperimentalWarning --experimental-strip-types \"$(r=\"${CLAUDE_PROJECT_DIR:-.}\"; d=\"$r\"; while [ ! -f \"$d/vault-manifest.json\" ] && p=\"$(dirname \"$d\")\" && [ \"$d\" != \"$p\" ]; do d=\"$p\"; done; [ -f \"$d/vault-manifest.json\" ] || d=\"$r\"; printf %s \"$d\")/.claude/scripts/pre-compact.ts\"",
"timeout": 30
}
]
@@ -51,7 +51,7 @@
"hooks": [
{
"type": "command",
- "command": "node --disable-warning=ExperimentalWarning --experimental-strip-types \"${CLAUDE_PROJECT_DIR:-.}/.claude/scripts/stop-checklist.ts\"",
+ "command": "node --disable-warning=ExperimentalWarning --experimental-strip-types \"$(r=\"${CLAUDE_PROJECT_DIR:-.}\"; d=\"$r\"; while [ ! -f \"$d/vault-manifest.json\" ] && p=\"$(dirname \"$d\")\" && [ \"$d\" != \"$p\" ]; do d=\"$p\"; done; [ -f \"$d/vault-manifest.json\" ] || d=\"$r\"; printf %s \"$d\")/.claude/scripts/stop-checklist.ts\"",
"timeout": 5
}
]