mirror of https://github.com/garrytan/gstack.git
Merge 6393079468 into a3259400a3
This commit is contained in:
commit
67087bf27e
|
|
@ -127,7 +127,7 @@ Install it:
|
|||
|
||||
Then restart your AI coding tool.
|
||||
MSG
|
||||
echo '{"permissionDecision":"deny","message":"gstack is required but not installed. See stderr for install instructions."}'
|
||||
echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"gstack is required but not installed. See stderr for install instructions."}}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -240,6 +240,29 @@ describe('gstack-team-init', () => {
|
|||
expect(stat.mode & 0o111).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('required: hook emits PreToolUse deny in hookSpecificOutput shape when gstack is missing', () => {
|
||||
run(`${TEAM_INIT} required`, { cwd: tmpDir });
|
||||
const hookPath = path.join(tmpDir, '.claude', 'hooks', 'check-gstack.sh');
|
||||
|
||||
// HOME without gstack → must deny via hookSpecificOutput (top-level
|
||||
// permissionDecision is ignored by Claude Code's PreToolUse schema)
|
||||
const fakeHome = path.join(tmpDir, 'fake-home');
|
||||
fs.mkdirSync(fakeHome, { recursive: true });
|
||||
const denied = run(`bash ${hookPath}`, { env: { HOME: fakeHome } });
|
||||
expect(denied.exitCode).toBe(0);
|
||||
const deniedJson = JSON.parse(denied.stdout.trim());
|
||||
expect(deniedJson.hookSpecificOutput.hookEventName).toBe('PreToolUse');
|
||||
expect(deniedJson.hookSpecificOutput.permissionDecision).toBe('deny');
|
||||
expect(deniedJson.hookSpecificOutput.permissionDecisionReason).toContain('gstack is required');
|
||||
|
||||
// HOME with gstack installed → no-op {}
|
||||
const homeWithGstack = path.join(tmpDir, 'home-with-gstack');
|
||||
fs.mkdirSync(path.join(homeWithGstack, '.claude', 'skills', 'gstack', 'bin'), { recursive: true });
|
||||
const allowed = run(`bash ${hookPath}`, { env: { HOME: homeWithGstack } });
|
||||
expect(allowed.exitCode).toBe(0);
|
||||
expect(JSON.parse(allowed.stdout.trim())).toEqual({});
|
||||
});
|
||||
|
||||
test('required: creates project settings.json with PreToolUse hook', () => {
|
||||
run(`${TEAM_INIT} required`, { cwd: tmpDir });
|
||||
const settingsPath = path.join(tmpDir, '.claude', 'settings.json');
|
||||
|
|
|
|||
Loading…
Reference in New Issue