From d12d31f8dea9f9a930423f252308c969b816871a Mon Sep 17 00:00:00 2001 From: Tibsfox Date: Tue, 7 Apr 2026 14:25:21 -0700 Subject: [PATCH] perf(hooks): add .planning/ sentinel check before config read in context monitor (#1930) The context monitor hook read and parsed config.json on every PostToolUse event. For non-GSD projects (no .planning/ directory), this was unnecessary I/O. Add a quick existsSync check for the .planning/ directory before attempting to read config.json. Co-authored-by: Claude Opus 4.6 (1M context) --- hooks/gsd-context-monitor.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hooks/gsd-context-monitor.js b/hooks/gsd-context-monitor.js index c1064f919..150646d8b 100644 --- a/hooks/gsd-context-monitor.js +++ b/hooks/gsd-context-monitor.js @@ -52,17 +52,19 @@ process.stdin.on('end', () => { process.exit(0); } - // Check if context warnings are disabled via config + // Check if context warnings are disabled via config. + // Quick sentinel check: skip config read entirely for non-GSD projects (#P2.5). const cwd = data.cwd || process.cwd(); - const configPath = path.join(cwd, '.planning', 'config.json'); - if (fs.existsSync(configPath)) { + const planningDir = path.join(cwd, '.planning'); + if (fs.existsSync(planningDir)) { try { + const configPath = path.join(planningDir, 'config.json'); const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); if (config.hooks?.context_warnings === false) { process.exit(0); } } catch (e) { - // Ignore config parse errors + // Ignore config read/parse errors (config may not exist in .planning/) } }