* fix(#448): resolve UI safety gate helper against the GSD install dir The §5.6 UI Design Contract Gate (and autonomous §3a.5) resolved ui-safety-gate.cjs via `git rev-parse --show-toplevel`, i.e. the consuming project's git root — which has no bin/lib. The node call failed, its exit code was conflated with "no UI", and the gate silently no-opped so frontend phases skipped the UI-SPEC prompt. Resolve the helper against the GSD install dir via RUNTIME_DIR (the same idiom §1 uses for gsd-tools), with git-toplevel and $HOME/.claude fallbacks. When the helper genuinely can't be found, fail OPEN with a stderr warning (assume UI present) rather than silently skipping. Tests: bug-3706 structural guard now requires RUNTIME_DIR resolution and forbids the consuming-project GSD_REPO_ROOT anchor; a new behavioral test resolves and runs the helper from a temp consuming project (no bin/lib) with RUNTIME_DIR set. autonomous-ui-steps updated to match. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * docs(#448): add changeset fragment for PR #539 * fix(#448): add get-shit-done/bin/lib/ to UI gate probe and deploy helper there The installer copies get-shit-done/ to the target but not root bin/lib/, so the helper was never found for installed users. Placing ui-safety-gate.cjs in get-shit-done/bin/lib/ ensures the installer deploys it, and probing that path first makes the gate work correctly in installed runtimes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: update changeset to cover get-shit-done/bin/lib/ deployment Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: update inventory for ui-safety-gate.cjs in get-shit-done/bin/lib/ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -30,16 +30,17 @@ describe('autonomous workflow ui-phase and ui-review integration (#1375)', () =>
|
||||
});
|
||||
|
||||
test('UI design contract step detects frontend indicators via shell-free Node gate (#3718)', () => {
|
||||
// After #3718 fix: the gate is implemented in bin/lib/ui-safety-gate.cjs (Node.js)
|
||||
// piped from stdin, path anchored via git rev-parse. This avoids silent failure
|
||||
// on Windows PowerShell and ARG_MAX limits for large phase text.
|
||||
// After #3718: the gate is implemented in bin/lib/ui-safety-gate.cjs (Node.js)
|
||||
// piped from stdin, avoiding silent failure on Windows PowerShell and ARG_MAX.
|
||||
// After #448: the helper is resolved against the GSD install dir (RUNTIME_DIR),
|
||||
// not the consuming project's git root, so it is actually found at runtime.
|
||||
assert.ok(
|
||||
content.includes('ui-safety-gate.cjs'),
|
||||
'should invoke shell-free Node gate for cross-platform portability (#3718)'
|
||||
);
|
||||
assert.ok(
|
||||
content.includes('GSD_REPO_ROOT'),
|
||||
'should anchor gate path to GSD_REPO_ROOT to avoid CWD-sensitive failure'
|
||||
content.includes('RUNTIME_DIR'),
|
||||
'should resolve the gate helper against the GSD install dir (RUNTIME_DIR), not the consuming project root (#448)'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ const assert = require('node:assert/strict');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('node:child_process');
|
||||
const os = require('node:os');
|
||||
|
||||
const HELPER_PATH = path.join(__dirname, '..', 'bin', 'lib', 'ui-safety-gate.cjs');
|
||||
const PLAN_PHASE_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'plan-phase.md');
|
||||
@@ -68,19 +69,33 @@ describe('Workflow .md structural guard (#3718)', () => {
|
||||
['plan-phase.md', PLAN_PHASE_PATH],
|
||||
['autonomous.md', AUTONOMOUS_PATH],
|
||||
]) {
|
||||
test(`${label} must invoke ui-safety-gate.cjs via stdin, anchored to GSD_REPO_ROOT`, () => {
|
||||
test(`${label} must invoke ui-safety-gate.cjs via stdin, anchored to the GSD install dir`, () => {
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
assert.ok(
|
||||
content.includes('ui-safety-gate.cjs'),
|
||||
`${label}: must reference ui-safety-gate.cjs for cross-shell portability (#3718)`
|
||||
);
|
||||
|
||||
// Scope structural assertions to the gate invocation region so we test the
|
||||
// gate's OWN resolution, not §1's unrelated RUNTIME_DIR usage for gsd-tools.
|
||||
const gi = content.indexOf('ui-safety-gate.cjs');
|
||||
const region = content.slice(Math.max(0, gi - 800), gi + 200);
|
||||
|
||||
// #448: the helper ships inside the GSD package, so it must be resolved
|
||||
// against the GSD install dir (RUNTIME_DIR), NOT the consuming project's
|
||||
// git root — otherwise the node call fails and the gate silently no-ops.
|
||||
assert.ok(
|
||||
content.includes('GSD_REPO_ROOT'),
|
||||
`${label}: must anchor path to GSD_REPO_ROOT to avoid CWD-sensitive failure (#3718)`
|
||||
region.includes('RUNTIME_DIR'),
|
||||
`${label}: UI gate must resolve ui-safety-gate.cjs against RUNTIME_DIR (the GSD install dir), not the consuming project's git root (#448)`
|
||||
);
|
||||
assert.ok(
|
||||
content.includes('git rev-parse --show-toplevel'),
|
||||
`${label}: must derive GSD_REPO_ROOT from git rev-parse --show-toplevel`
|
||||
!region.includes('GSD_REPO_ROOT'),
|
||||
`${label}: UI gate must NOT anchor the helper to GSD_REPO_ROOT (the consuming project's git root) — that silently no-ops in installed repos (#448)`
|
||||
);
|
||||
// Retain a git rev-parse --show-toplevel fallback when RUNTIME_DIR is unset (#3718).
|
||||
assert.ok(
|
||||
region.includes('git rev-parse --show-toplevel'),
|
||||
`${label}: must retain a git rev-parse --show-toplevel fallback for the install-dir resolution`
|
||||
);
|
||||
// Confirm stdin pipe usage (printf or echo piped to node)
|
||||
assert.ok(
|
||||
@@ -251,6 +266,80 @@ function runBehavioralTests(label) {
|
||||
|
||||
runBehavioralTests('ui-safety-gate.cjs');
|
||||
|
||||
// ── Install-dir resolution from a consuming project (#448) ────────────────────
|
||||
|
||||
describe('UI gate resolves the helper against RUNTIME_DIR, not the consuming repo (#448)', () => {
|
||||
const REPO_ROOT = path.join(__dirname, '..');
|
||||
|
||||
// Mirrors the §5.6 / §3a.5 resolution. The structural guard above forces the
|
||||
// workflows to keep using this RUNTIME_DIR-anchored form; this proves the
|
||||
// candidate path is correct and the helper is actually found + executed when
|
||||
// the CWD is a consuming project that has no bin/lib of its own.
|
||||
const GATE_SNIPPET = [
|
||||
'_GSD_RT="${RUNTIME_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"',
|
||||
'UI_GATE_JS=$(for _c in "$_GSD_RT/get-shit-done/bin/lib/ui-safety-gate.cjs" "$_GSD_RT/bin/lib/ui-safety-gate.cjs" "$_GSD_RT/.claude/bin/lib/ui-safety-gate.cjs" "$HOME/.claude/get-shit-done/bin/lib/ui-safety-gate.cjs" "$HOME/.claude/bin/lib/ui-safety-gate.cjs"; do [ -f "$_c" ] && { echo "$_c"; break; }; done)',
|
||||
'if [ -n "$UI_GATE_JS" ]; then printf \'%s\' "$PHASE_SECTION" | node "$UI_GATE_JS" >/dev/null 2>&1; HAS_UI=$?; else HAS_UI=0; fi',
|
||||
'echo "$HAS_UI"',
|
||||
].join('\n');
|
||||
|
||||
function runGateFrom(consumingDir, phaseSection) {
|
||||
return spawnSync('bash', ['-c', GATE_SNIPPET], {
|
||||
cwd: consumingDir,
|
||||
encoding: 'utf-8',
|
||||
env: { ...process.env, RUNTIME_DIR: REPO_ROOT, PHASE_SECTION: phaseSection },
|
||||
});
|
||||
}
|
||||
|
||||
test('UI text is detected (HAS_UI=0) from a project without bin/lib', () => {
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-consuming-'));
|
||||
try {
|
||||
const res = runGateFrom(tmp, 'UI Refactor: migrate all screens');
|
||||
assert.strictEqual(res.status, 0, `bash failed: ${res.stderr}`);
|
||||
assert.strictEqual(res.stdout.trim(), '0',
|
||||
'helper must be found via RUNTIME_DIR and report UI present — not silently no-op');
|
||||
} finally {
|
||||
fs.rmSync(tmp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('non-UI text returns HAS_UI=1 via the RUNTIME_DIR-resolved helper', () => {
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-consuming-'));
|
||||
try {
|
||||
const res = runGateFrom(tmp, 'Requirements: backend REST API only');
|
||||
assert.strictEqual(res.stdout.trim(), '1');
|
||||
} finally {
|
||||
fs.rmSync(tmp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('UI gate found via get-shit-done/bin/lib/ in installed layout (no root bin/lib/)', () => {
|
||||
// Regression for #448: installed RUNTIME_DIR has get-shit-done/bin/lib/ but NOT root bin/lib/.
|
||||
// The probe must find the helper at the installed path, not silently no-op to HAS_UI=0.
|
||||
const fakeRuntime = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-installed-rt-'));
|
||||
const consumingProject = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-consuming-'));
|
||||
try {
|
||||
const installedLibDir = path.join(fakeRuntime, 'get-shit-done', 'bin', 'lib');
|
||||
fs.mkdirSync(installedLibDir, { recursive: true });
|
||||
fs.copyFileSync(
|
||||
path.join(REPO_ROOT, 'get-shit-done', 'bin', 'lib', 'ui-safety-gate.cjs'),
|
||||
path.join(installedLibDir, 'ui-safety-gate.cjs')
|
||||
);
|
||||
|
||||
const res = spawnSync('bash', ['-c', GATE_SNIPPET], {
|
||||
cwd: consumingProject,
|
||||
encoding: 'utf-8',
|
||||
env: { ...process.env, RUNTIME_DIR: fakeRuntime, PHASE_SECTION: 'Build the analytics dashboard' },
|
||||
});
|
||||
assert.strictEqual(res.status, 0, `bash failed: ${res.stderr}`);
|
||||
assert.strictEqual(res.stdout.trim(), '0',
|
||||
'helper must be found via get-shit-done/bin/lib/ in installed layout and report UI present');
|
||||
} finally {
|
||||
fs.rmSync(fakeRuntime, { recursive: true, force: true });
|
||||
fs.rmSync(consumingProject, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ── checkUiPresence() return value API ───────────────────────────────────────
|
||||
|
||||
describe('checkUiPresence() return value API', () => {
|
||||
|
||||
Reference in New Issue
Block a user