Fix: stop the design hook from creating .impeccable/ in unrelated projects (#346)

The PostToolUse hook was writing hook.cache.json after every edit, even
when nothing was scanned or recorded. Gate the persist to earned writes
only, and key the cache to the edited file's project root when the
session starts from an umbrella directory.

Fixes #344, #305

Co-authored-by: Abdul Wahab <abdulwahab@Abduls-MacBook-Pro-2.local>
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Abdul Wahab
2026-07-05 17:11:39 -07:00
committed by GitHub
co-authored by Abdul Wahab Cursor
parent 582f23eae3
commit 751ec31dd6
3 changed files with 184 additions and 7 deletions
+6 -2
View File
@@ -27,6 +27,7 @@ import {
readCache,
readConfig,
renderTemplate,
resolveCacheCwd,
resolveProjectCwd,
truthy,
writeAuditLog,
@@ -379,9 +380,12 @@ async function main() {
return allow({ skipped: 'stdin-empty' });
}
const cwd = resolveProjectCwd(event);
const sessionCwd = resolveProjectCwd(event);
const started = Date.now();
const filePath = proposedFilePath(event, cwd);
const filePath = proposedFilePath(event, sessionCwd);
// Re-key config/cache to the edited file's project root when the session
// was launched from a non-project umbrella directory (issue #305).
const cwd = resolveCacheCwd(filePath, sessionCwd);
const audit = {
harness: 'cursor',
cwd,