fix: register gsd-workflow-guard.js in settings.json during install (#1772)
The hook was built, copied to hooks/dist/, and installed to disk — but never registered as a PreToolUse entry in settings.json, making the hooks.workflow_guard config flag permanently inert. Adds the registration block following the same pattern as the other community hooks (prompt-guard, read-guard, validate-commit, etc.). Includes regression test that verifies every JS hook in gsdHooks has a corresponding command construction and registration block. Fixes #1767 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5635,6 +5635,30 @@ function install(isGlobal, runtime = 'claude') {
|
||||
// and exits silently (no-op) if not enabled. This lets users enable
|
||||
// them per-project by adding: "hooks": { "community": true }
|
||||
|
||||
// Configure workflow guard hook (opt-in via hooks.workflow_guard: true)
|
||||
// Detects file edits outside GSD workflow context and advises using
|
||||
// /gsd-quick or /gsd-fast for state-tracked changes. Advisory only.
|
||||
const workflowGuardCommand = isGlobal
|
||||
? buildHookCommand(targetDir, 'gsd-workflow-guard.js')
|
||||
: 'node ' + dirName + '/hooks/gsd-workflow-guard.js';
|
||||
const hasWorkflowGuardHook = settings.hooks[preToolEvent].some(entry =>
|
||||
entry.hooks && entry.hooks.some(h => h.command && h.command.includes('gsd-workflow-guard'))
|
||||
);
|
||||
|
||||
if (!hasWorkflowGuardHook) {
|
||||
settings.hooks[preToolEvent].push({
|
||||
matcher: 'Write|Edit',
|
||||
hooks: [
|
||||
{
|
||||
type: 'command',
|
||||
command: workflowGuardCommand,
|
||||
timeout: 5
|
||||
}
|
||||
]
|
||||
});
|
||||
console.log(` ${green}✓${reset} Configured workflow guard hook (opt-in via hooks.workflow_guard)`);
|
||||
}
|
||||
|
||||
// Configure commit validation hook (Conventional Commits enforcement, opt-in)
|
||||
const validateCommitCommand = isGlobal
|
||||
? 'bash ' + targetDir.replace(/\\/g, '/') + '/hooks/gsd-validate-commit.sh'
|
||||
|
||||
Reference in New Issue
Block a user