Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(hooks): recognize env assignments before calls [L3,A6]
Corey Olsonc7728b681ad2
diff --git a/src/hooks.js b/src/hooks.jsindex b6a6ff9f..9bc71468 100644--- a/src/hooks.js+++ b/src/hooks.js@@ -369,7 +369,10 @@ function delegatesHook(source, hook) {const program = String.raw`(?:"(?:[^"]*/)?pullboard(?:\.js)?"|'(?:[^']*/)?pullboard(?:\.js)?'|(?:[^\s"';&|()]+/)?pullboard(?:\.js)?)`;const binBinding = new RegExp(`^(?:bin=|for\\s+bin\\s+in\\s+)${program}(?=\\s|$)`);const boundBin = commands.some(command => binBinding.test(command));- const call = new RegExp(`^(?:(?:then|do|else|exec|command|npx|node|env)\\s+)*(?:${program}${boundBin ? '|"?\\$bin"?' : ''})\\s+hook\\s+${hook}(?=\\s|$)`);+ // env consumes NAME=value arguments before its executable, including quoted and empty values.+ const assignment = String.raw`[A-Za-z_][A-Za-z0-9_]*=(?:"[^"]*"|'[^']*'|[^\s"';&|()])*`;+ const prefix = String.raw`(?:(?:then|do|else|exec|command|npx|node)\s+|env\s+(?:${assignment}\s+)*)*`;+ const call = new RegExp(`^${prefix}(?:${program}${boundBin ? '|"?\\$bin"?' : ''})\\s+hook\\s+${hook}(?=\\s|$)`);return commands.some(command => call.test(command));}diff --git a/test/doctor.test.js b/test/doctor.test.jsindex 099f6dea..a47de13b 100644--- a/test/doctor.test.js+++ b/test/doctor.test.js@@ -165,6 +165,32 @@ test('doctor and resume accept env delegation that real Git executes [L3]', () =}});+test('doctor and resume accept env assignments that real Git executes [L3]', () => {+ const box = executedHookBox();+ for (const source of [+ '#!/bin/sh\nenv REVIEWER_HOOK_CONTROL=1 pullboard hook pre-commit "$@"\n',+ '#!/bin/sh\nexec env FIRST=one SECOND="two words" EMPTY= pullboard hook pre-commit "$@"\n',+ "#!/bin/sh\nenv FIRST='two words' SECOND=three pullboard hook pre-commit \"$@\"\n",+ ]) {+ writeFileSync(box.hook, source); chmodSync(box.hook, 0o755);+ writeFileSync(box.marker, '');+ box.git('commit', '--allow-empty', '-q', '-m', 'chore: actual hook control');+ assert.match(readFileSync(box.marker, 'utf8'), /^hook pre-commit\n$/u,+ 'the real Git pre-commit hook invoked the actual submitted CLI once');+ writeFileSync(box.marker, '');+ const doctor = box.run('doctor');+ assert.equal(doctor.status, 0, 'an executed env delegation is wired');+ assert.equal(doctor.stdout, 'board is clean\n');+ const resume = box.run('resume');+ assert.equal(resume.status, 0);+ assert.doesNotMatch(resume.stdout, /active Git hook|HOOK_UNWIRED/u);+ assert.deepEqual(JSON.parse(box.run('doctor', '--json').stdout).problems, []);+ assert.deepEqual(JSON.parse(box.run('resume', '--json').stdout).hookProblems, []);+ assert.equal(readFileSync(box.marker, 'utf8'), '', 'diagnosis never executes the hook');+ assert.equal(readFileSync(box.hook, 'utf8'), source, 'diagnosis never edits the hook');+ }+});+test('doctor and resume reject printed heredocs that real Git never executes [L3]', () => {const box = executedHookBox();const message = 'active Git hook .husky/pre-commit does not call pullboard hook pre-commit';