From ef12f9811daeff08364d4d27a5db5b14c33854fb Mon Sep 17 00:00:00 2001 From: mrwogu Date: Mon, 9 Mar 2026 09:25:08 +0100 Subject: [PATCH] fix: correct regex anchors and align npx timeout in hook scripts - Change \brg$ and \bgrep$ to \brg\b and \bgrep\b so full paths like /usr/bin/rg are matched correctly (all 3 hook variants) - Reduce npx fallback timeout from 15s to 8s to fit within the 10s hook runner timeout (Factory plugin) --- gitnexus-claude-plugin/hooks/gitnexus-hook.js | 2 +- gitnexus-factory-plugin/hooks/gitnexus-hook.js | 4 ++-- gitnexus/hooks/claude/gitnexus-hook.cjs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gitnexus-claude-plugin/hooks/gitnexus-hook.js b/gitnexus-claude-plugin/hooks/gitnexus-hook.js index 4cc79c100..3ec29b265 100644 --- a/gitnexus-claude-plugin/hooks/gitnexus-hook.js +++ b/gitnexus-claude-plugin/hooks/gitnexus-hook.js @@ -69,7 +69,7 @@ function extractPattern(toolName, toolInput) { for (const token of tokens) { if (skipNext) { skipNext = false; continue; } if (!foundCmd) { - if (/\brg$|\bgrep$/.test(token)) foundCmd = true; + if (/\brg\b|\bgrep\b/.test(token)) foundCmd = true; continue; } if (token.startsWith('-')) { diff --git a/gitnexus-factory-plugin/hooks/gitnexus-hook.js b/gitnexus-factory-plugin/hooks/gitnexus-hook.js index 73062d51b..fcea7dbc1 100644 --- a/gitnexus-factory-plugin/hooks/gitnexus-hook.js +++ b/gitnexus-factory-plugin/hooks/gitnexus-hook.js @@ -64,7 +64,7 @@ function extractPattern(toolName, toolInput) { for (const token of tokens) { if (skipNext) { skipNext = false; continue; } if (!foundCmd) { - if (/\brg$|\bgrep$/.test(token)) foundCmd = true; + if (/\brg\b|\bgrep\b/.test(token)) foundCmd = true; continue; } if (token.startsWith('-')) { @@ -122,7 +122,7 @@ function main() { const child = spawnSync( 'npx', ['-y', 'gitnexus', 'augment', pattern], - { encoding: 'utf-8', timeout: 15000, cwd, stdio: ['pipe', 'pipe', 'pipe'], shell: isWin } + { encoding: 'utf-8', timeout: 8000, cwd, stdio: ['pipe', 'pipe', 'pipe'], shell: isWin } ); if (child.status === 0 && child.stderr && child.stderr.trim()) { result = child.stderr; diff --git a/gitnexus/hooks/claude/gitnexus-hook.cjs b/gitnexus/hooks/claude/gitnexus-hook.cjs index 55e694fa2..a9181f85e 100755 --- a/gitnexus/hooks/claude/gitnexus-hook.cjs +++ b/gitnexus/hooks/claude/gitnexus-hook.cjs @@ -69,7 +69,7 @@ function extractPattern(toolName, toolInput) { for (const token of tokens) { if (skipNext) { skipNext = false; continue; } if (!foundCmd) { - if (/\brg$|\bgrep$/.test(token)) foundCmd = true; + if (/\brg\b|\bgrep\b/.test(token)) foundCmd = true; continue; } if (token.startsWith('-')) {