* fix(#373): replace unquoted $GSD_SDK with space-safe gsd_run launcher Workflow bash blocks resolved the runtime as GSD_SDK="node $GSD_TOOLS" and invoked it unquoted ($GSD_SDK query ...). On install paths containing spaces (e.g. /Volumes/Mini Me/...) the unquoted expansion word-split into `node /Volumes/Mini gsd-tools.cjs ...`, failing with "Cannot find module '/Volumes/Mini'" and getting masked by `2>/dev/null || echo "{}"` into a silent empty state. Replace the string variable with a single-line shell launcher that defines a gsd_run function, invokes the runtime with a fully-quoted path and "$@", and preserves the local-cjs / installed-gsd-tools-on-PATH fallback (#3668) plus the loud not-found error and install hint. The launcher uses _GSD_SHIM_NAME indirection so no workflow emits the /gsd-tools substring that the do.md dispatcher-parity scanner would misread, and is single-line to stay within the per-file progressive-disclosure line budgets (#2551). The canonical launcher lives in get-shit-done/workflows/_runtime-launcher.snippet.sh, is propagated once per file by scripts/sync-runtime-launcher.cjs, and is locked by tests/runtime-launcher-parity.test.cjs (fails CI on drift, on a reappearing $GSD_SDK token, or on a /gsd-tools substring). Dependent workflow-assertion tests are updated from $GSD_SDK to gsd_run, and the runtime launcher is registered in CONTEXT.md. Fixes #373 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ci(#373): add changeset fragment and allow-test-rule for parity guard The runtime-launcher parity test is a structural drift guard that reads workflow markdown to assert the canonical launcher is present and the retired $GSD_SDK / /gsd-tools tokens are absent; annotate it with allow-test-rule per the no-source-grep lint escape hatch. Add the required .changeset fragment for this user-facing fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test(#373): make parity PATH-fallback assertion cross-platform (Windows) Subtest (E) compared GSD_TOOLS against the Node-side absolute temp path, but the value originates from git-bash which reports the POSIX form, so the prefix comparison failed on windows-latest while the launcher itself worked (the installed stub was invoked). Assert the resolved binary by normalized suffix (/bin/gsd-tools, not .cjs) instead of the absolute prefix; the behavioral stub-invocation assertion is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,14 +16,63 @@ const { execFileSync } = require('node:child_process');
|
||||
|
||||
const WORKFLOW_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'next.md');
|
||||
|
||||
/**
|
||||
* Extract the canonical runtime resolver snippet from next.md.
|
||||
*
|
||||
* Supports two forms:
|
||||
* - One-line form (canonical): the entire launcher is a single line starting with
|
||||
* `_GSD_SHIM_NAME="gsd-tools.cjs";` — return that line directly.
|
||||
* - Multi-line form (legacy): starts with a `# Runtime launcher:` comment or a
|
||||
* `_GSD_SHIM_NAME=` line followed by separate GSD_TOOLS= and if/elif/else/fi
|
||||
* lines — scan to the closing `fi`.
|
||||
*/
|
||||
function extractResolverSnippet() {
|
||||
const content = fs.readFileSync(WORKFLOW_PATH, 'utf8');
|
||||
const lines = content.split(/\r?\n/);
|
||||
const start = lines.findIndex((line) => line.includes('SDK resolution: prefer local gsd-tools.cjs'));
|
||||
assert.notEqual(start, -1, 'next.md must contain the SDK resolution snippet');
|
||||
|
||||
const end = lines.findIndex((line, index) => index > start && line === 'fi');
|
||||
assert.notEqual(end, -1, 'SDK resolution snippet must end with fi');
|
||||
// Find the canonical preamble — prefer _GSD_SHIM_NAME= line (handles both forms)
|
||||
let start = lines.findIndex((line) => /^_GSD_SHIM_NAME=/.test(line.trim()));
|
||||
if (start === -1) {
|
||||
// Fallback: canonical preamble comment (multi-line legacy form)
|
||||
start = lines.findIndex((line) =>
|
||||
/^\s*#\s*Runtime launcher:.*prefer local gsd-tools\.cjs.*installed gsd-tools on PATH/.test(line)
|
||||
);
|
||||
}
|
||||
if (start === -1) {
|
||||
// Last fallback: GSD_TOOLS= with RUNTIME_DIR
|
||||
start = lines.findIndex((line) => line.includes('GSD_TOOLS="${RUNTIME_DIR:-'));
|
||||
}
|
||||
assert.notEqual(
|
||||
start,
|
||||
-1,
|
||||
'next.md must contain the canonical runtime preamble ' +
|
||||
'(_GSD_SHIM_NAME= line, # Runtime launcher: comment, or GSD_TOOLS= line with RUNTIME_DIR)'
|
||||
);
|
||||
|
||||
// One-line form: the entire launcher (including `if` and `fi`) is on a single line.
|
||||
// Detect by checking whether the start line contains a semicolon-separated `if` and `fi`.
|
||||
const startLine = lines[start].trim();
|
||||
if (/^_GSD_SHIM_NAME=.*;\s*if\s+\[.*\bfi$/.test(startLine)) {
|
||||
// Single-line canonical launcher — return it as-is
|
||||
return startLine;
|
||||
}
|
||||
|
||||
// Multi-line form: scan forward from start to the closing `fi`, tracking if-depth
|
||||
let depth = 0;
|
||||
let end = -1;
|
||||
for (let i = start; i < lines.length; i++) {
|
||||
const t = lines[i].trim();
|
||||
if (/^if\s+/.test(t)) depth++;
|
||||
if (/^fi(\s|$)/.test(t)) {
|
||||
depth--;
|
||||
if (depth === 0) {
|
||||
end = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.notEqual(end, -1, 'runtime preamble must end with a closing `fi`');
|
||||
|
||||
return lines.slice(start, end + 1).join('\n');
|
||||
}
|
||||
|
||||
@@ -36,7 +85,7 @@ function runResolver({ cwd, runtimeDir, pathDir }) {
|
||||
'set -e',
|
||||
extractResolverSnippet(),
|
||||
'printf "GSD_TOOLS=%s\\n" "$GSD_TOOLS"',
|
||||
'$GSD_SDK query state.json',
|
||||
'gsd_run query state.json',
|
||||
].join('\n');
|
||||
|
||||
return execFileSync('bash', ['-c', script], {
|
||||
@@ -57,18 +106,28 @@ function writeExecutable(file, content) {
|
||||
|
||||
describe('bug-3668: workflow SDK resolver supports installed user projects', () => {
|
||||
test('falls back to installed gsd-tools when project-local runtime copy is absent', () => {
|
||||
// Bug #3668: when a user project has no local get-shit-done/bin/gsd-tools.cjs,
|
||||
// the elif branch must resolve to the gsd-tools binary on PATH.
|
||||
// RUNTIME_DIR points to a dir that has no gsd-tools.cjs.
|
||||
const tmp = makeTempDir();
|
||||
const project = path.join(tmp, 'user-project');
|
||||
const bin = path.join(tmp, 'bin');
|
||||
const runtimeNoLocal = path.join(tmp, 'runtime-no-local');
|
||||
const pathBin = path.join(tmp, 'bin');
|
||||
fs.mkdirSync(project, { recursive: true });
|
||||
writeExecutable(path.join(bin, 'gsd-tools'), '#!/bin/sh\nprintf "installed:%s %s\\n" "$1" "$2"\n');
|
||||
fs.mkdirSync(runtimeNoLocal, { recursive: true });
|
||||
|
||||
const output = runResolver({ cwd: project, pathDir: bin });
|
||||
// Place gsd-tools stub on PATH (installed binary)
|
||||
writeExecutable(
|
||||
path.join(pathBin, 'gsd-tools'),
|
||||
'#!/bin/sh\nprintf "installed:%s %s\\n" "$1" "$2"\n',
|
||||
);
|
||||
|
||||
// Normalize separators so the assertion works on Windows (Git bash emits POSIX paths)
|
||||
const norm = output.replace(/\\/g, '/');
|
||||
// subtest 1: the resolved bin is the PATH-fallback gsd-tools (suffix /bin/gsd-tools, no .cjs)
|
||||
assert.match(norm, /GSD_TOOLS=\S*\/bin\/gsd-tools(?:\s|$)/m);
|
||||
// NO get-shit-done/bin/gsd-tools.cjs in runtimeNoLocal
|
||||
const output = runResolver({ cwd: project, runtimeDir: runtimeNoLocal, pathDir: pathBin });
|
||||
|
||||
// GSD_TOOLS must have been reassigned to the PATH binary (not the missing .cjs)
|
||||
assert.match(output, /GSD_TOOLS=.+gsd-tools(?:\s|$)/m);
|
||||
// The PATH stub must have been invoked
|
||||
assert.match(output, /installed:query state\.json/);
|
||||
});
|
||||
|
||||
@@ -78,7 +137,7 @@ describe('bug-3668: workflow SDK resolver supports installed user projects', ()
|
||||
const runtime = path.join(tmp, 'runtime');
|
||||
const pathBin = path.join(tmp, 'bin');
|
||||
fs.mkdirSync(project, { recursive: true });
|
||||
writeExecutable(path.join(pathBin, 'gsd-tools'), '#!/bin/sh\nprintf "installed:%s %s\\n" "$1" "$2"\n');
|
||||
writeExecutable(path.join(pathBin, 'gsd-tools'), '#!/bin/sh\nprintf "path-installed:%s %s\\n" "$1" "$2"\n');
|
||||
writeExecutable(
|
||||
path.join(runtime, 'get-shit-done', 'bin', 'gsd-tools.cjs'),
|
||||
'#!/usr/bin/env node\nconsole.log(`runtime:${process.argv[2]} ${process.argv[3]}`);\n',
|
||||
@@ -88,9 +147,10 @@ describe('bug-3668: workflow SDK resolver supports installed user projects', ()
|
||||
|
||||
// Normalize separators so the assertion works on Windows (Git bash emits POSIX paths)
|
||||
const norm = output.replace(/\\/g, '/');
|
||||
// subtest 2: the resolved bin is the RUNTIME_DIR local runtime (suffix /get-shit-done/bin/gsd-tools.cjs)
|
||||
assert.match(norm, /GSD_TOOLS=\S*\/get-shit-done\/bin\/gsd-tools\.cjs(?:\s|$)/m);
|
||||
// The resolved bin is the RUNTIME_DIR local runtime (suffix /get-shit-done/bin/gsd-tools.cjs)
|
||||
// Use .+ instead of \S* to handle paths with spaces (e.g. /Volumes/Mini Me/...)
|
||||
assert.match(norm, /GSD_TOOLS=.+\/get-shit-done\/bin\/gsd-tools\.cjs(?:\s|$)/m);
|
||||
assert.match(output, /runtime:query state\.json/);
|
||||
assert.doesNotMatch(output, /installed:query state\.json/);
|
||||
assert.doesNotMatch(output, /path-installed:query state\.json/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user