mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-29 19:34:29 +01:00
`./setup` on Windows now installs when your home folder has an apostrophe in its name, such as `C:\Users\O'Brien`. Git Bash turns `/c/...` paths into `C:/...` before starting Bun, but skips any path holding an apostrophe, so setup stopped with `Module not found`. Nothing to do: re-run `./setup` after upgrading. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=testing
This commit is contained in:
1 parent
fd81a04ba7
commit
4ec576aaa5
5 files changed
+82
-9
No files matched your search
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* #4386: Git Bash converts a /c/... argument to C:/... before it starts a
|
||||
* native program such as Bun, but it skips any argument holding an apostrophe.
|
||||
* Under a home folder like C:\Users\O'Brien, setup handed Bun
|
||||
* /c/Users/O'Brien/.claude/skills/gstack/scripts/preflight-codex-overlap.ts
|
||||
* and Bun stopped with "Module not found". Setup now spells every path it
|
||||
* hands Bun through _bun_path, which uses cygpath -m on Windows. A one-off
|
||||
* windows-smoke run with an apostrophe in HOME proved the fix on a real
|
||||
* Windows runner; this test guards the source and the helper on any OS.
|
||||
*/
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import * as fs from 'node:fs';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
const SETUP = fs.readFileSync(path.join(ROOT, 'setup'), 'utf8');
|
||||
const BUN_START = 'bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" ';
|
||||
|
||||
function bunPathHelper(): string {
|
||||
const start = SETUP.indexOf('_bun_path() {');
|
||||
expect(start).toBeGreaterThan(-1);
|
||||
const end = SETUP.indexOf('\n}\n', start);
|
||||
return SETUP.slice(start, end + 2);
|
||||
}
|
||||
|
||||
function runHelper(ostype: string, arg: string, stubDir?: string) {
|
||||
const script = `OSTYPE=${ostype}\n${bunPathHelper()}\n_bun_path "$1"`;
|
||||
const PATH = stubDir ? `${stubDir}${path.delimiter}${process.env.PATH}` : process.env.PATH;
|
||||
return spawnSync('bash', ['-c', script, 'bash', arg], { encoding: 'utf8', timeout: 15_000, env: { ...process.env, PATH } });
|
||||
}
|
||||
|
||||
describe('#4386: setup hands Bun paths it can open under an apostrophe home', () => {
|
||||
test('every Bun start whose script is a variable path goes through _bun_path', () => {
|
||||
const unwrapped = SETUP.split('\n').filter((line) => line.includes(`${BUN_START}"$`) && !line.includes(`${BUN_START}"$(_bun_path `));
|
||||
expect(unwrapped.map((line) => line.trim())).toEqual([`def="$(${BUN_START}"$SKILL_ROUTE_BIN" --default "$key" 2>/dev/null || true)"`]);
|
||||
expect(SETUP).toContain('SKILL_ROUTE_BIN="$(_bun_path "$SOURCE_GSTACK_DIR/bin/gstack-skill-route")"');
|
||||
});
|
||||
|
||||
test('the Codex preflight gets converted --source, --namespace and --relocation paths', () => {
|
||||
expect(SETUP).toContain('--source "$(_bun_path "$SOURCE_GSTACK_DIR")" --namespace "$(_bun_path "$CODEX_SKILLS")"');
|
||||
expect(SETUP).toContain('--relocation "$(_bun_path "$HOME/.gstack/repos/gstack")"');
|
||||
});
|
||||
|
||||
test.skipIf(process.platform === 'win32')('_bun_path leaves a path unchanged off Windows, apostrophe included', () => {
|
||||
const r = runHelper('linux-gnu', "/home/o'brien/gstack/bin/gstack-harness");
|
||||
expect(r.status).toBe(0);
|
||||
expect(r.stdout).toBe("/home/o'brien/gstack/bin/gstack-harness\n");
|
||||
});
|
||||
|
||||
test.skipIf(process.platform === 'win32')('_bun_path asks cygpath -m for the Windows spelling under Git Bash', () => {
|
||||
const stubDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bun-path-'));
|
||||
try {
|
||||
fs.writeFileSync(path.join(stubDir, 'cygpath'), '#!/bin/sh\n[ "$1" = -m ] || exit 9\nprintf "C:%s\\n" "$2"\n', { mode: 0o755 });
|
||||
const r = runHelper('msys', "/c/Users/O'Brien/.claude/skills/gstack/setup", stubDir);
|
||||
expect(r.status).toBe(0);
|
||||
expect(r.stdout).toBe("C:/c/Users/O'Brien/.claude/skills/gstack/setup\n");
|
||||
} finally {
|
||||
fs.rmSync(stubDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -36,6 +36,7 @@ function slice(from: string, to: string | null): string {
|
||||
}
|
||||
|
||||
const HOOK_SECTIONS = [
|
||||
slice('_bun_path() {', '\n}\n') + '\n}\n',
|
||||
slice('_setup_ready_line() {', '\n}\n') + '\n}\n',
|
||||
slice('CANONICAL_GSTACK_ROOT="$(gstack_canonical_claude_root)"', '# ─── GBrain detection'),
|
||||
slice('# 11. Plan-tune cathedral hook install', '# ─── Redact pre-push guard consent'),
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
const setupSrc = fs.readFileSync(path.join(ROOT, 'setup'), 'utf8');
|
||||
const settingsHookSrc = fs.readFileSync(path.join(ROOT, 'bin', 'gstack-settings-hook'), 'utf8');
|
||||
const gateFn = setupSrc.slice(setupSrc.indexOf('_skill_hook_gate() {'), setupSrc.indexOf('\n}\n', setupSrc.indexOf('_skill_hook_gate() {')) + 3);
|
||||
const bunPathFn = setupSrc.slice(setupSrc.indexOf('_bun_path() {'), setupSrc.indexOf('\n}\n', setupSrc.indexOf('_bun_path() {')) + 3);
|
||||
const gateTimeoutLine = setupSrc.match(/^SKILL_GATE_HOOK_TIMEOUT=.*$/m)?.[0] ?? 'echo "setup has no SKILL_GATE_HOOK_TIMEOUT line" >&2; exit 9';
|
||||
|
||||
let state = '', home = '';
|
||||
@@ -51,6 +52,7 @@ function gate(mode: string, env: Record<string, string> = {}, noTeam = 0, root =
|
||||
'SKILL_ROUTE_BIN="$2/bin/gstack-skill-route"',
|
||||
`IS_WINDOWS=0; NO_TEAM_MODE=${noTeam}`,
|
||||
'SOURCE_GSTACK_DIR="$2"',
|
||||
bunPathFn,
|
||||
gateTimeoutLine,
|
||||
gateFn,
|
||||
`_skill_hook_gate ${key} "$1" ${GATES[key]}`,
|
||||
@@ -429,13 +431,13 @@ describe('setup: the autoplan_gate switch (GST-1666) registers Stop, and PreTool
|
||||
|
||||
describe('setup: both skill gates register the hook timeout lib/skill-gates.ts derives (GST-1615)', () => {
|
||||
test('source: one SKILL_GATE_HOOK_TIMEOUT from gstack-skill-gates hook-timeout, passed to both gates', () => {
|
||||
expect(gateTimeoutLine).toBe('SKILL_GATE_HOOK_TIMEOUT="$(bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$SOURCE_GSTACK_DIR/bin/gstack-skill-gates" hook-timeout 2>/dev/null || true)"');
|
||||
expect(gateTimeoutLine).toBe('SKILL_GATE_HOOK_TIMEOUT="$(bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$(_bun_path "$SOURCE_GSTACK_DIR/bin/gstack-skill-gates")" hook-timeout 2>/dev/null || true)"');
|
||||
expect(setupSrc).toContain('"$CEO_REVIEW_GATE_STOP" gstack-ceo-review-gate "$SKILL_GATE_HOOK_TIMEOUT" \\');
|
||||
expect(setupSrc).not.toMatch(/gstack-(ceo-review|autoplan)-gate \d/);
|
||||
});
|
||||
|
||||
test('the setup line evaluates to HOOK_TIMEOUT_S', () => {
|
||||
const r = spawnSync('bash', ['-c', `SOURCE_GSTACK_DIR="$1"\n${gateTimeoutLine}\nprintf %s "$SKILL_GATE_HOOK_TIMEOUT"`, 'gate', ROOT], { env: { PATH: process.env.PATH ?? '', HOME: home }, encoding: 'utf8', timeout: 30_000 });
|
||||
const r = spawnSync('bash', ['-c', `SOURCE_GSTACK_DIR="$1"\n${bunPathFn}${gateTimeoutLine}\nprintf %s "$SKILL_GATE_HOOK_TIMEOUT"`, 'gate', ROOT], { env: { PATH: process.env.PATH ?? '', HOME: home }, encoding: 'utf8', timeout: 30_000 });
|
||||
expect(r.stdout).toBe(String(HOOK_TIMEOUT_S));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user