diff --git a/tests/hooks/context-gate-ownership.test.js b/tests/hooks/context-gate-ownership.test.js index e77abd943..5e978fea8 100644 --- a/tests/hooks/context-gate-ownership.test.js +++ b/tests/hooks/context-gate-ownership.test.js @@ -54,6 +54,12 @@ function createSandbox() { return { root, resumeDir, transcript, env }; } +// The proposed checkpoint is the indented line that is an absolute .md path: +// "/..." on POSIX, "C:\\..." (or a UNC path) on Windows. +function isProposedPathLine(line) { + return /^\s+\S/.test(line) && line.endsWith('.md') && path.isAbsolute(line.trim()); +} + function fire(sandbox, extra = {}) { const input = { cwd: '/tmp/owner-a/project', session_id: 'mysess', transcript_path: sandbox.transcript, ...extra }; const result = spawnSync(process.execPath, [RUNNER, 'user-prompt:context-gate', 'scripts/hooks/context-gate.js', 'standard,strict'], { @@ -66,7 +72,7 @@ function fire(sandbox, extra = {}) { if (result.error) return { timeout: result.error.code }; const text = JSON.parse(result.stdout).hookSpecificOutput.additionalContext; const lines = text.split('\n'); - const target = lines.find(line => /^\s+[/\\].*\.md$/.test(line)); + const target = lines.find(isProposedPathLine); const marker = lines.find(line => line.includes('