mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-13 00:19:03 +02:00
The investigate skill's PreToolUse hooks and Scope Lock probe resolved
check-freeze.sh via ${CLAUDE_SKILL_DIR}, which does not exist when
frontmatter hooks run — the || exit 0 tail then failed open, so the debug
scope boundary silently never engaged (#1871 follow-up). Anchor all four
sites on $HOME/.claude/skills/gstack/ like careful/freeze, and add a static
test asserting no frontmatter command: line in the guard-family skills ever
references CLAUDE_SKILL_DIR again.
Fixes #2469; closes the last live half of #1459 together with the
freeze/careful hookSpecificOutput fix. The broader portable-install-root
rewrite stays #1882 (its own focused PR per the TODOS.md decision).
Reported with a fix by @maxpetrusenkoagent (PR #1873; absorbed narrowly —
the cwd-walk rewrite belongs to #1882).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
35 lines
1.7 KiB
TypeScript
35 lines
1.7 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
const ROOT = path.resolve(import.meta.dir, '..');
|
|
const FILES = ['investigate/SKILL.md.tmpl', 'investigate/SKILL.md'];
|
|
|
|
// #2469: frontmatter hooks (and early skill bash) run before any runtime
|
|
// variable exists, so a ${CLAUDE_SKILL_DIR}-relative path silently never
|
|
// resolved and the scope-lock guard failed open via `|| exit 0`. Both the
|
|
// hook commands and the Scope Lock probe must anchor on $HOME like the
|
|
// careful/freeze skills (#1871). The old standalone `gstack-freeze` sibling
|
|
// fallback was part of the never-resolving path — prefix installs keep the
|
|
// payload at ~/.claude/skills/gstack/, so the $HOME anchor covers them.
|
|
describe('investigate freeze path resolution', () => {
|
|
for (const rel of FILES) {
|
|
const content = fs.readFileSync(path.join(ROOT, rel), 'utf-8');
|
|
|
|
test(`${rel} hook resolves check-freeze via the $HOME anchor`, () => {
|
|
expect(content).toContain('S="$HOME/.claude/skills/gstack/freeze/bin/check-freeze.sh"');
|
|
expect(content).toContain('[ -x "$S" ] && exec bash "$S"; exit 0');
|
|
const commandLines = content.split('\n').filter((l) => l.trim().startsWith('command:'));
|
|
expect(commandLines.length).toBeGreaterThan(0);
|
|
for (const line of commandLines) {
|
|
expect(line).not.toContain('CLAUDE_SKILL_DIR');
|
|
}
|
|
});
|
|
|
|
test(`${rel} scope lock availability probe uses the $HOME anchor`, () => {
|
|
expect(content).toContain('_FREEZE_SCRIPT="$HOME/.claude/skills/gstack/freeze/bin/check-freeze.sh"');
|
|
expect(content).toContain('[ -x "$_FREEZE_SCRIPT" ] && echo "FREEZE_AVAILABLE" || echo "FREEZE_UNAVAILABLE"');
|
|
});
|
|
}
|
|
});
|