Windows hooks start under unconverted paths, and six more setup and install fixes from outside reports (#4682)

Seven install and setup bugs reported by outside contributors are fixed,
each with a test that fails on main: Windows hooks under an apostrophe
home or with path conversion off, two misleading `./setup --status`
rows, owner-only files in Bun's shared cache, a leftover
`/connect-chrome` alias, a doctor false alarm, and harness installs
ignoring `disabled_skills`.

Nothing to do after merge; the next `./setup` or upgrade picks it up.

Co-authored-by: Arnuv <69417158+abyss-node@users.noreply.github.com>
Co-authored-by: Mahmoud ElNeMR <83190847+ElNeMeR70@users.noreply.github.com>
Co-authored-by: Yuan S. <3579304+szsunyuan@users.noreply.github.com>
Co-authored-by: Alexander William Haire <141470777+alexanderhaire@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1v/outside-voice#1 reader=outside-voice
Review-Finding: p1v/outside-voice#3 reader=outside-voice
This commit is contained in:
authored and GitHub committed 2026-11-22 10:31:18 +00:00
1 parent 9d9ba2f057
commit 24b15c6823
31 files changed
+370 -23

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ _autoplan_backstop() {
}
trap _autoplan_backstop EXIT
_AUTOPLAN_HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then _AUTOPLAN_HOOK_DIR="$(cygpath -m "$_AUTOPLAN_HOOK_DIR")"; fi ;; esac
_AUTOPLAN_RESULT="$(bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$_AUTOPLAN_HOOK_DIR/phase-publication-hook.ts")"
test -n "$_AUTOPLAN_RESULT"
printf '%s\n' "$_AUTOPLAN_RESULT"
+10 -3
View File
@@ -583,16 +583,23 @@ check_windows_bash() {
# skills itself, and a pasted list goes stale with each release. A section is
# a heading whose title starts with "gstack", up to the next heading of its
# level or higher; it enumerates when it has an "Available skills" line or
# names 8 or more distinct /skill tokens (paths are not tokens).
# names 8 or more distinct /skill tokens (paths are not tokens). gstack's own
# CLAUDE.md, at the root of a gstack tree (setup + VERSION + bin/gstack-relink),
# is its development guide, not a pasted list, so it is skipped and named (#4324).
check_claude_md() {
local user project file f n checked="" listed="" seen=""
local user project file dir f n checked="" listed="" seen=""
user="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/CLAUDE.md"
project="$(git rev-parse --show-toplevel 2>/dev/null || pwd -P)/CLAUDE.md"
for file in "$user" "$project"; do
[ -f "$file" ] || continue
f=$(cd "$(dirname "$file")" 2>/dev/null && pwd -P)/CLAUDE.md
dir=$(cd "$(dirname "$file")" 2>/dev/null && pwd -P)
f=$dir/CLAUDE.md
case "|$seen|" in *"|$f|"*) continue ;; esac
seen="$seen|$f"
if [ -f "$dir/VERSION" ] && [ -f "$dir/setup" ] && [ -f "$dir/bin/gstack-relink" ]; then
checked="${checked:+$checked, }skipped gstack's own $file"
continue
fi
checked="${checked:+$checked, }$file"
n=$(awk '
/^#+[ \t]/ {
+11 -5
View File
@@ -181,11 +181,17 @@ if [ -n "$ENTRIES" ] && ! command -v "$BUN" >/dev/null 2>&1; then
fi
BUILD_RC=0
if [ -n "$ENTRIES" ]; then
# Bun reports native spellings; shellPath maps them back to the keys looked
# up below (lib/path-spelling.ts shellPath; test/path-spelling.test.ts keeps
# the two equal).
# Bun gets the entries in cygpath -m spelling under the test that picks
# GSTACK_BUN_CONFIG: Git Bash leaves a /c/x argument holding ' ` [ ] (or
# every one, under MSYS_NO_PATHCONV=1) unconverted, and bun.exe cannot open
# /c/x (#4386). Bun reports native spellings; shellPath maps them back to the
# keys looked up below (lib/path-spelling.ts shellPath;
# test/path-spelling.test.ts keeps the two equal).
BUN_ENTRIES=$ENTRIES
# shellcheck disable=SC2086 # newline-split list (IFS is a newline)
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then BUN_ENTRIES=$(set -f; cygpath -m $ENTRIES); fi ;; esac
# shellcheck disable=SC2086 # newline-split list (IFS is set to a newline below)
(cd "$ROOT" && IFS=$NL && "$BUN" --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" -e '
(cd "$ROOT" && IFS=$NL && set -f && "$BUN" --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" -e '
const shellPath = (value) => process.platform === "win32"
? String(value).replace(/\\/g, "/").replace(/^([A-Za-z]):(?=\/|$)/, (_, drive) => `/${drive.toLowerCase()}`)
: String(value);
@@ -198,7 +204,7 @@ if [ -n "$ENTRIES" ]; then
const at = log.position ? `${shellPath(log.position.file)}:${log.position.line}` : key;
console.log(`${key}\tfail\t${at}\t${String(log.message ?? log).split("\n")[0]}`);
}
}' $ENTRIES) > "$BUILT" 2>/dev/null || BUILD_RC=$?
}' $BUN_ENTRIES) > "$BUILT" 2>/dev/null || BUILD_RC=$?
fi
TS_UNCHECKED=0
if [ "$BUILD_RC" -gt 128 ]; then
+4 -1
View File
@@ -277,7 +277,7 @@ _gstack_status_rows() {
cur="$(cat "$src/VERSION" 2>/dev/null || true)"
note=""
if [ ! -e "$root" ] && [ ! -L "$root" ]; then
result=missing; note="install root $root is gone; the next setup or upgrade drops this row"
result=missing; note="install root $root is gone; ./setup --refresh-registered (which /gstack-upgrade runs) drops this row"
elif [ -z "$cur" ]; then
result=missing; cur="-"; note="source checkout $src is gone; reinstall from a fresh clone with ./setup --host $host"
elif [ "$cur" = "$ver" ]; then
@@ -299,6 +299,9 @@ ROWS
seen="$seen$root|"
src="$(_gstack_install_source "$root")"
[ -n "$src" ] || continue
case "$root" in */.agents/skills/gstack)
[ "$(cd "${root%/.agents/skills/gstack}" 2>/dev/null && pwd -P)" = "$src" ] && continue ;;
esac
cur="$(cat "$src/VERSION" 2>/dev/null || echo '-')"
note="installed before the registry; register it: cd $src && ./setup --host $host"
if [ "$scope" = global ] && [ "$host" != claude ] && _gstack_vendored_source "$src"; then
+13 -3
View File
@@ -246,7 +246,7 @@ _backup_skill_md() {
# Helper: remove an OLD skill entry from the opposite prefix mode. Only entries
# we can prove are ours are removed; anything else is reported and kept.
_cleanup_skill_entry() {
local entry="$1" skill="${2:-}" e dest src
local entry="$1" skill="${2:-}" whole="${3:-whole}" e dest src
[ -e "$entry" ] || [ -L "$entry" ] || return 0
# Unclaimed dir (no SKILL.md, no marker): nothing of ours to clean.
if [ -d "$entry" ] && [ ! -L "$entry" ] && [ ! -e "$entry/SKILL.md" ] && [ ! -L "$entry/SKILL.md" ] && [ ! -f "$entry/.gstack-owned" ]; then
@@ -266,8 +266,9 @@ _cleanup_skill_entry() {
# the marker (we created the dir) while the skill's source still exists, or
# a directory holding nothing but links. A retired skill's marked entry
# takes the path below, so a real SKILL.md is backed up and the user's
# files stay.
if { [ -f "$entry/.gstack-owned" ] && { [ -z "$skill" ] || [ -f "$src" ]; }; } || { [ -L "$entry/SKILL.md" ] && _dir_only_links "$entry"; }; then
# files stay. A third argument other than "whole" (an alias entry, whose
# marked directory may still hold the user's files) always takes that path.
if { [ "$whole" = whole ] && [ -f "$entry/.gstack-owned" ] && { [ -z "$skill" ] || [ -f "$src" ]; }; } || { [ -L "$entry/SKILL.md" ] && _dir_only_links "$entry"; }; then
rm -rf "$entry"
else
# Otherwise only what is ours goes: the SKILL.md, the marker, and our
@@ -400,6 +401,15 @@ for skill_dir in "$INSTALL_DIR"/*/; do
*" ${skill#gstack-} "*)
_cleanup_skill_entry "$SKILLS_DIR/$skill" "$skill"
case "$skill" in gstack-*) ;; *) _cleanup_skill_entry "$SKILLS_DIR/gstack-$skill" "$skill" ;; esac
# setup's rewritten-copy alias of this skill goes with it (#4308); the loop
# above skips the alias's symlinked source dir, and a checkout made without
# symlinks has none. The next ./setup writes it back once the skill is on.
# Only the generated SKILL.md goes: an edited one is backed up, and the
# user's other files stay.
if [ "$skill" = open-gstack-browser ]; then
_cleanup_skill_entry "$SKILLS_DIR/connect-chrome" "$skill" files
_cleanup_skill_entry "$SKILLS_DIR/gstack-connect-chrome" "$skill" files
fi
case "$DISABLED" in *" ${skill#gstack-} "*) DISABLED_COUNT=$((DISABLED_COUNT + 1)) ;; esac
continue ;;
esac
+7
View File
@@ -0,0 +1,7 @@
- **TypeScript hooks start on Windows when Git Bash leaves a path unconverted.** Under a home folder holding an apostrophe (such as `C:\Users\O'Brien`), or with `MSYS_NO_PATHCONV=1` or `MSYS2_ARG_CONV_EXCL=*` set, every TypeScript hook died with "Module not found" and `gstack-hook-check` reported all of them broken. Each hook now hands Bun its own folder in `C:/…` form, the checker does the same, and `./setup` turns Git Bash's path conversion back on for the programs it starts. (#4386)
- **`./setup --status` passes on a `--prefix` install.** It no longer reports `gstack-review/SKILL.md names ../qa/sections/exploratory.md` as broken when the prefixed `../gstack-qa/…` path the same file names exists. (#4164)
- **`./setup --status` names commands that clear what it reports.** A row whose install root is gone now says `./setup --refresh-registered` drops it, and the gstack checkout's own Codex render is no longer listed as an unregistered project install. (#4420)
- **`./setup` no longer leaves owner-only files in Bun's shared package cache.** Its `bun install` and Playwright install run under umask 022, so another project that later reuses the same cached packages can be read by other users; gstack's own state and logs stay owner-only. (#4288)
- **Disabling `/open-gstack-browser` also removes its `/connect-chrome` alias.** (#4308)
- **`gstack-doctor` no longer flags gstack's own CLAUDE.md as a pasted skill list** when run inside a gstack checkout. (#4324)
- **OpenClaw, Hermes and Dots registrations leave out skills turned off with `disabled_skills`.** (#4548)
+3 -1
View File
@@ -6111,7 +6111,9 @@ or in this project's `CLAUDE.md` that enumerates skills: an `Available
skills:` line, or eight or more `/skill` names. Older install prompts asked
for that list (#3169). Claude Code already lists every installed skill with
its description, and a pasted list goes stale with each release, so the agent
can take a partial list as the complete set.
can take a partial list as the complete set. Inside a gstack checkout the
doctor skips gstack's own `CLAUDE.md`, which is its development guide, and
names it as skipped in the `ok` line (#4324).
**Fix.** Replace the section with the short block the doctor prints (no skill
list; keep any other gstack rules you wrote yourself):
@@ -5,4 +5,5 @@
set -e
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)"
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
exec bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/auq-error-fallback-hook.ts"
@@ -8,6 +8,7 @@
# FAIL-OPEN: every failure path (bun missing, script crash) still exits 0.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
PAYLOAD="$(cat)" || exit 0
case "$PAYLOAD" in *autoplan-published*) ;; *) exit 0 ;; esac
printf '%s' "$PAYLOAD" | bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/autoplan-stop-gate.ts" || true
@@ -7,5 +7,6 @@
# FAIL-OPEN: every failure path (bun missing, script crash) still exits 0.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/autoplan-stop-gate.ts" || true
exit 0
+1
View File
@@ -8,5 +8,6 @@
# FAIL-OPEN: every failure path (bun missing, script crash) still exits 0.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/ceo-review-gate.ts" || true
exit 0
@@ -8,5 +8,6 @@
# FAIL-OPEN: every failure path (bun missing, script crash) still exits 0.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/ceo-review-gate.ts" || true
exit 0
@@ -6,5 +6,6 @@
# FAIL-OPEN: every failure path — bun missing, script crash — still exits 0.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/destructive-guard-hook.ts" || true
exit 0
@@ -14,6 +14,7 @@
# `<&0` keeps stdin: bash hands background jobs /dev/null otherwise.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/memorable-user-prompt-hook.ts" <&0 &
_child=$!
trap 'kill -TERM "$_child" 2>/dev/null' TERM INT HUP
+1
View File
@@ -5,4 +5,5 @@
set -e
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)"
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
exec bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/question-log-hook.ts"
@@ -5,4 +5,5 @@
set -e
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)"
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
exec bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/question-preference-hook.ts"
@@ -6,5 +6,6 @@
# FAIL-OPEN: every failure path — bun missing, script crash — still exits 0.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/skill-contract-stop-hook.ts" || true
exit 0
+1
View File
@@ -6,5 +6,6 @@
# FAIL-OPEN: every failure path — bun missing, script crash — still exits 0.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/skill-route-hook.ts" || true
exit 0
+1
View File
@@ -7,5 +7,6 @@
# Every failure path — bun missing, script crash — still exits 0.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/timeline-stop-hook.ts" || true
exit 0
@@ -7,5 +7,6 @@
# FAIL-OPEN: every failure path — bun missing, script crash — still exits 0.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd -P)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
GSTACK_HOOK_HOST=codex bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/codex-destructive-guard-hook.ts" || true
exit 0
@@ -7,5 +7,6 @@
# FAIL-OPEN: every failure path — bun missing, script crash — still exits 0.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd -P)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
GSTACK_HOOK_HOST=codex bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/codex-skill-contract-stop-hook.ts" || true
exit 0
+1
View File
@@ -7,5 +7,6 @@
# FAIL-OPEN: every failure path — bun missing, script crash — still exits 0.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd -P)" || exit 0
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
GSTACK_HOOK_HOST=codex bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/codex-skill-route-hook.ts" || true
exit 0
+6 -3
View File
@@ -22,6 +22,7 @@ import { spawnSync } from 'node:child_process';
import { unregisteredSkills } from '../scripts/discover-skills';
import { bunIsolationArgs } from './bun-isolation';
import { runBashSync } from './script-invocation';
import { readConfigKey } from './state-root';
import { frontmatterList, routerLine } from './skill-triggers';
import { activateHook, assertHookRoot, foreignOpenclawConfig, hookChoice, hookConfig, hookFiles, hookProfile, hookRoot, inspectHook, isHookTarget, profileSkills, type HookResult } from './harness-start-hook';
@@ -233,8 +234,10 @@ function skillDirs(root: string, triggersByName = new Map<string, string[]>()):
}
/** The skills a target's payload carries: the host render (made for this checkout as the install root) or the checkout's committed Claude render. */
export function sourceSkills(target: Target, checkout: string, scratch: string): SkillEntry[] {
const off = unregisteredSkills();
export function sourceSkills(target: Target, checkout: string, scratch: string, env: Env = process.env): SkillEntry[] {
const disabled = (readConfigKey('disabled_skills', env) ?? '').replace(/["']/g, '').split(/[\s,]+/)
.map(n => n.replace(/^\//, '')).filter(n => n && n !== 'gstack' && n !== 'gstack-upgrade').map(n => n.replace(/^gstack-/, ''));
const off = [...unregisteredSkills(), ...disabled];
const registered = (s: SkillEntry) => !off.includes(s.name.replace(/^gstack-/, ''));
if (target.render === 'claude') return skillDirs(checkout).filter(s => s.name !== 'gstack' && registered(s));
const out = path.join(scratch, 'render');
@@ -394,7 +397,7 @@ function resolveDest(opts: RegisterOptions, id?: string): string | null {
/** Desired files (absolute path -> bytes), the router path, the skill names the harness lists, the skills listed directly beside a router, and the skill count. */
export function planPayload(opts: RegisterOptions, dest: string, mode: SkillsMode, scratch: string): { files: Map<string, Buffer>; router: string | null; visible: string[]; direct: string[]; skills: number } {
const t = opts.target;
const skills = sourceSkills(t, opts.checkout, scratch);
const skills = sourceSkills(t, opts.checkout, scratch, { ...process.env, ...opts.env, GSTACK_STATE_ROOT: opts.stateRoot });
const files = new Map<string, Buffer>();
const copyDir = (from: string, to: string) => { for (const f of walkFiles(from)) files.set(path.join(to, path.relative(from, f)), fs.readFileSync(f)); };
const claudeFiles = (s: SkillEntry, to: string) => {
+1
View File
@@ -3,4 +3,5 @@
# TypeScript hook with bun.
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
HERE="$(cd "$(dirname "$0")" && pwd)"
case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then HERE="$(cygpath -m "$HERE")"; fi ;; esac
exec bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" "$HERE/mode-handoff-hook.ts"
+10 -4
View File
@@ -2,6 +2,9 @@
# gstack setup — build browser binary + register skills with Claude Code / Codex
set -e
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
# Native Bun and Git cannot open a /c/x path: keep Git Bash's argument
# conversion on for everything setup starts, even where a user turned it off (#4386).
case "${OSTYPE:-}" in msys*|cygwin*) unset MSYS_NO_PATHCONV MSYS2_ARG_CONV_EXCL ;; esac
umask 077 # Restrict new files to owner-only (0o600 files, 0o700 dirs)
# Heredoc delivery guard. bash 5.2+ writes a heredoc body <=64KiB through a
@@ -146,7 +149,7 @@ _status_install_checks() {
'$GSTACK_ROOT/'*) path="$root/${tok#\$GSTACK_ROOT/}" ;;
'~/'*) path="$HOME/${tok#\~/}" ;;
/*) path="$tok" ;;
../*) path="$dir/$tok" ;;
../*) path="$dir/$tok"; case "${dir##*/}" in gstack-*) [ -r "$path" ] || path="$dir/../gstack-${tok#../}" ;; esac ;;
*) continue ;;
esac
checked=$((checked + 1))
@@ -1936,18 +1939,20 @@ _deps_migration_finish() {
# install, which keeps its dev packages at bun.lock's versions.
# Bun's --production implies a frozen lockfile, so when bun.lock is out of date
# (a fork or a local edit) refresh it first, then install production-only again.
# Installs run under umask 022, not setup's 077: Bun extracts into a package cache
# that every Bun project of this user hardlinks from (#4288).
install_runtime_deps() {
local role out rc=0
role="$(_deps_role)"
if [ "$role" = "user" ] && _deps_migration_start; then
out="$( { bun_cmd install --production --frozen-lockfile || { bun_cmd install --lockfile-only && bun_cmd install --production --frozen-lockfile; }; } 2>&1 )" && _deps_verified || rc=$?
out="$( { umask 022; bun_cmd install --production --frozen-lockfile || { bun_cmd install --lockfile-only && bun_cmd install --production --frozen-lockfile; }; } 2>&1 )" && _deps_verified || rc=$?
_deps_migration_finish "$rc" "$out" && return 0
fi
if [ "$role" = "contributor" ] || _deps_has_dev; then
bun_cmd install --frozen-lockfile 2>/dev/null || bun_cmd install
( umask 022; bun_cmd install --frozen-lockfile 2>/dev/null || bun_cmd install )
return
fi
bun_cmd install --production --frozen-lockfile 2>/dev/null || { bun_cmd install --lockfile-only && bun_cmd install --production --frozen-lockfile; }
( umask 022; bun_cmd install --production --frozen-lockfile 2>/dev/null || { bun_cmd install --lockfile-only && bun_cmd install --production --frozen-lockfile; } )
}
cleanup_copied_bun() {
@@ -2506,6 +2511,7 @@ elif ! ensure_playwright_browser; then
# `bun x`, not `bunx`: a winget Bun ships no bunx (#3131).
_PW_BUN="$(command -v "$BUN_CMD" 2>/dev/null || printf '%s' "$BUN_CMD")"
(
umask 022
cd "$SOURCE_GSTACK_DIR"
if [ -n "$_PLAYWRIGHT_PLATFORM_OVERRIDE" ]; then
PLAYWRIGHT_HOST_PLATFORM_OVERRIDE="$_PLAYWRIGHT_PLATFORM_OVERRIDE" bun_cmd x playwright install chromium
+25
View File
@@ -367,6 +367,31 @@ describe('gstack-doctor: rescue refs, CLAUDE.md skill lists, Windows bash', () =
expect(replacement(r.out)).toEqual([]);
});
test('CLAUDE.md: gstack\'s own guide at the root of a gstack checkout is skipped and named in the row; the same text in another project and a list in ~/.claude/CLAUDE.md still warn', () => {
const f = makeFixture();
// gstack's CLAUDE.md opens with this title, so the whole guide reads as one gstack section.
const guide = '# gstack development\n\n## Commands\nRun /review, /ship, /qa, /browse, /retro, /investigate, /office-hours, /autoplan and /canary here.\n';
write(path.join(f.work, 'CLAUDE.md'), guide);
const elsewhere = doctor(f).row('CLAUDE.md');
expect(elsewhere.state).toBe('warn');
expect(elsewhere.detail).toContain(`${bashPath(f.work)}/CLAUDE.md lists 9 skills`);
// The install root as a git checkout: the fixture has setup and VERSION, bin/gstack-relink completes the tree.
write(path.join(f.root, 'CLAUDE.md'), guide);
fs.copyFileSync(path.join(REPO, 'bin/gstack-relink'), path.join(f.root, 'bin/gstack-relink'));
git(f, ['init', '-q']);
const inRoot = { ...f, work: f.root };
write(path.join(f.home, '.claude/CLAUDE.md'), SHORT);
const r = doctor(inRoot);
expect(r.row('CLAUDE.md').state, r.out).toBe('ok');
expect(r.row('CLAUDE.md').detail).toMatch(/^no gstack section lists skills \(.*\/\.claude\/CLAUDE\.md, skipped gstack's own .*\/CLAUDE\.md\)$/);
expect(replacement(r.out)).toEqual([]);
write(path.join(f.home, '.claude/CLAUDE.md'), LISTING);
const listed = doctor(inRoot).row('CLAUDE.md');
expect(listed.state).toBe('warn');
expect(listed.detail).toContain(`${bashPath(f.home)}/.claude/CLAUDE.md lists 13 skills`);
expect(listed.detail.match(/ lists \d+ skills/g)).toHaveLength(1);
});
/** A JSON probe file: the discovery inputs resolveWindowsBash takes, in test/fixtures/windows-bash-resolution.json's shape. */
const probe = (f: Fixture, inputs: Record<string, unknown>) => { const file = path.join(f.base, 'bash-probe.json'); write(file, JSON.stringify(inputs)); return file; };
const GIT_BASH = 'C:/Program Files/Git/bin/bash.exe';
+13
View File
@@ -140,6 +140,19 @@ describe('gstack-harness register and unregister (skill folders)', () => {
}
}, 60_000);
// #4548: the harness payload (OpenClaw, Hermes, Dots) honors gstack-config disabled_skills like every other install.
test('a skill turned off with disabled_skills is left out of the harness payload (#4548)', () => {
const d = tmp();
fs.mkdirSync(path.join(d, 'state'), { recursive: true });
fs.writeFileSync(path.join(d, 'state', 'config.yaml'), 'disabled_skills: ship,/cso,gstack-qa\n');
const r = register(opts(d, 'dots', { mode: 'all', skillsDir: path.join(d, 'all') }));
for (const off of ['ship', 'cso', 'qa']) expect(fs.existsSync(path.join(r.dest, off))).toBe(false);
expect(fs.existsSync(path.join(r.dest, 'review', 'SKILL.md'))).toBe(true);
const names = sourceSkills(TARGETS.dots, ROOT, d, { GSTACK_STATE_ROOT: path.join(d, 'state') }).map(s => s.name);
expect(names).toContain('review');
for (const off of ['ship', 'cso', 'qa']) expect(names).not.toContain(off);
}, 60_000);
test('Claude-render targets (dots, generic) never register a retired skill; /autoplan still carries its methodology', () => {
const d = tmp();
const names = sourceSkills(TARGETS.dots, ROOT, d).map(s => s.name);
+26 -1
View File
@@ -112,7 +112,7 @@ function brokenSectionPointers(dest: string, runtimeRoot: string, home: string):
} else if (tok.startsWith('$GSTACK_ROOT/')) targets = [join(runtimeRoot, tok.slice('$GSTACK_ROOT/'.length))];
else if (tok.startsWith('~/')) targets = [join(home, tok.slice(2))];
else if (tok.startsWith('/')) targets = [tok];
else if (tok.startsWith('../')) targets = [join(dir, tok)];
else if (tok.startsWith('../')) targets = skill.startsWith('gstack-') ? [join(dir, tok), join(dir, '..', `gstack-${tok.slice(3)}`)] : [join(dir, tok)];
else continue;
if (!targets.some(readable)) broken.push(`${skill}: ${tok}`);
}
@@ -266,6 +266,31 @@ describe.skipIf(process.platform === 'win32')('host conformance kit', () => {
expect(status.stdout).toMatch(/claude global: [^\n]*section links: [1-9]\d* of \d+ broken \(first: autoplan\/SKILL\.md names sections\/unattended\.md\)/);
}, 60_000);
test('--status resolves relative sibling section pointers in a --prefix Claude install (#4164)', () => {
const f = makeFixture();
const src = makeSource(f, join(f.dir, 'gstack'));
expect(runSetup(f, join(src, 'setup'), ['--host', 'claude', '--prefix']).status).toBe(0);
const status = runSetup(f, join(src, 'setup'), ['--status']);
expect(status.status, status.stdout + status.stderr).toBe(0);
expect(status.stdout).toMatch(/claude global: router is a real file; section links: \d+ checked, all resolve/);
}, 60_000);
test('--status names the command that drops a gone row, and skips the checkout\'s own Codex render (#4420)', () => {
const f = makeFixture();
const src = makeSource(f, join(f.home, '.claude/skills/gstack'));
expect(runSetup(f, join(src, 'setup'), ['--host', 'codex']).status).toBe(0);
if (!existsSync(join(src, '.git'))) Bun.spawnSync(['git', 'init', '-q', src], { timeout: 10_000 });
const fromCheckout = runSetup(f, join(src, 'setup'), ['--status'], { cwd: src });
expect(fromCheckout.stdout, fromCheckout.stdout + fromCheckout.stderr).not.toMatch(/codex\s+\S+\s+project\s+unregistered/);
const gone = join(f.dir, 'gone-home/.claude/skills');
const file = join(f.home, '.gstack/installs.tsv');
const row = registryRows(f).find(r => r[0] === 'codex')!;
writeFileSync(file, readFileSync(file, 'utf8') + ['claude', 'global', row[2], gone, join(gone, 'gstack'), ...row.slice(5)].join('\t') + '\n');
const status = runSetup(f, join(src, 'setup'), ['--status']);
expect(status.stdout).toContain(`install root ${join(gone, 'gstack')} is gone; ./setup --refresh-registered (which /gstack-upgrade runs) drops this row`);
}, 60_000);
test('upgrade from the previous release layout refreshes every installed host (#1925)', () => {
const f = makeFixture();
const src = makeSource(f, join(f.home, '.claude/skills/gstack'), '1.91.12.0');
+80
View File
@@ -1262,3 +1262,83 @@ describe('gstack-relink cycle-3 hardening: foreign dir links, failed backups, fl
expect(fs.readFileSync(path.join(skillsDir, '_gstack-command', 'notes.md'), 'utf-8')).toBe('mine\n');
});
});
// ============================================================
// #4308: connect-chrome is setup's rewritten-copy alias of open-gstack-browser.
// The discovery loop skips the symlinked source dir (#2201), and a checkout
// without symlinks has no such dir at all, so disabling the skill used to
// leave /connect-chrome registered.
// ============================================================
describe('gstack-relink: a disabled skill takes its alias with it (#4308)', () => {
const OGB = '---\nname: open-gstack-browser\ndescription: test\n---\n<!-- AUTO-GENERATED from SKILL.md.tmpl — do not edit directly -->\n<!-- Regenerate: bun run gen:skill-docs -->\n# open-gstack-browser\n';
const env = () => ({
GSTACK_INSTALL_DIR: installDir, GSTACK_SKILLS_DIR: skillsDir, GSTACK_HOME: path.join(tmpDir, 'home'), GSTACK_USER_RENDER_DIR: path.join(tmpDir, 'no-render'),
});
const relink = () => run(`${path.join(installDir, 'bin', 'gstack-relink')} 2>&1`, env());
const disable = (skills: string) => run(`${path.join(installDir, 'bin', 'gstack-config')} set disabled_skills '${skills}' 2>&1`, env());
// The alias exactly as setup's _install_alias_skill_md writes it: the source
// with name: rewritten, plus the marker when setup created the directory.
function aliasCopy(name: string, marked: boolean) {
fs.mkdirSync(path.join(skillsDir, name));
fs.writeFileSync(path.join(skillsDir, name, 'SKILL.md'), OGB.replace('name: open-gstack-browser', `name: ${name}`));
if (marked) fs.writeFileSync(path.join(skillsDir, name, '.gstack-owned'), `${installDir}\n`);
}
beforeEach(() => {
// No connect-chrome dir in the install: the shape of a checkout made
// without symlink support, where the alias has no source dir to discover.
setupMockInstall(['open-gstack-browser', 'qa']);
fs.writeFileSync(path.join(installDir, 'open-gstack-browser', 'SKILL.md'), OGB);
// disabled_skills is read through the registry library.
fs.copyFileSync(path.join(BIN, 'gstack-install-registry.sh'), path.join(installDir, 'bin', 'gstack-install-registry.sh'));
});
// Value: protects=disabling open-gstack-browser unregisters /connect-chrome too, under the flat and the prefixed alias name; fails_when=relink cleans only the entries named after the skill, or drops the alias while the skill is enabled; why_new=no test disabled a skill that has an alias; seam=none
test('disabling open-gstack-browser removes its connect-chrome alias under both names, and an enabled skill keeps it', () => {
aliasCopy('connect-chrome', true);
// An alias an older install left as a symlink, replaced in place: no marker.
aliasCopy('gstack-connect-chrome', false);
relink();
expect(fs.existsSync(path.join(skillsDir, 'open-gstack-browser', 'SKILL.md'))).toBe(true);
expect(fs.existsSync(path.join(skillsDir, 'connect-chrome', 'SKILL.md'))).toBe(true);
expect(fs.existsSync(path.join(skillsDir, 'gstack-connect-chrome', 'SKILL.md'))).toBe(true);
const out = disable('open-gstack-browser');
expect(fs.existsSync(path.join(skillsDir, 'open-gstack-browser'))).toBe(false);
expect(fs.existsSync(path.join(skillsDir, 'connect-chrome'))).toBe(false);
expect(fs.existsSync(path.join(skillsDir, 'gstack-connect-chrome'))).toBe(false);
expect(fs.existsSync(path.join(skillsDir, 'qa', 'SKILL.md'))).toBe(true);
expect(out).not.toContain('skipped');
});
// Value: protects=a user's own skill named connect-chrome survives disabling open-gstack-browser; fails_when=the alias cleanup deletes by name instead of going through the ownership gate; why_new=the alias name is a new cleanup target; seam=none
test("a user's own connect-chrome skill is reported and left byte-identical", () => {
const mine = '---\nname: connect-chrome\ndescription: my own chrome helper\n---\n# mine\n';
fs.mkdirSync(path.join(skillsDir, 'connect-chrome'));
fs.writeFileSync(path.join(skillsDir, 'connect-chrome', 'SKILL.md'), mine);
fs.writeFileSync(path.join(skillsDir, 'connect-chrome', 'notes.md'), 'mine\n');
const out = disable('open-gstack-browser');
expect(fs.existsSync(path.join(skillsDir, 'open-gstack-browser'))).toBe(false);
expect(fs.readFileSync(path.join(skillsDir, 'connect-chrome', 'SKILL.md'), 'utf-8')).toBe(mine);
expect(fs.readFileSync(path.join(skillsDir, 'connect-chrome', 'notes.md'), 'utf-8')).toBe('mine\n');
expect(out).toContain('skipped connect-chrome');
});
// Value: protects=a setup-made alias dir loses only its generated SKILL.md; fails_when=the alias cleanup takes the marker's whole-directory removal; why_new=the marked alias dir held only generated files in the tests above; seam=none
test("a setup-made alias keeps the user's files and backs up an edited SKILL.md", () => {
aliasCopy('connect-chrome', true);
fs.writeFileSync(path.join(skillsDir, 'connect-chrome', 'notes.md'), 'mine\n');
aliasCopy('gstack-connect-chrome', true);
fs.appendFileSync(path.join(skillsDir, 'gstack-connect-chrome', 'SKILL.md'), 'my edit\n');
disable('open-gstack-browser');
expect(fs.existsSync(path.join(skillsDir, 'connect-chrome', 'SKILL.md'))).toBe(false);
expect(fs.readFileSync(path.join(skillsDir, 'connect-chrome', 'notes.md'), 'utf-8')).toBe('mine\n');
expect(fs.existsSync(path.join(skillsDir, 'gstack-connect-chrome'))).toBe(false);
const root = path.join(tmpDir, 'home', 'backups', 'skills');
const saved = fs.readdirSync(root).map((ts) => path.join(root, ts, 'gstack-connect-chrome', 'SKILL.md')).filter((f) => fs.existsSync(f));
expect(saved.map((f) => fs.readFileSync(f, 'utf-8'))).toEqual([expect.stringContaining('my edit')]);
});
});
+119 -2
View File
@@ -86,11 +86,52 @@ function tmpBase(): string {
return base;
}
function check(root: string) {
const r = spawnSync('bash', [CHECK, root], { encoding: 'utf8', timeout: 30_000 });
function check(root: string, env: NodeJS.ProcessEnv = {}) {
const r = spawnSync('bash', [CHECK, root], { encoding: 'utf8', timeout: 30_000, env: { ...process.env, ...env } });
return { code: r.status, out: `${r.stdout}${r.stderr}` };
}
/**
* A root Git Bash leaves unconverted: MSYS rewrites a /c/x argument to C:/x as
* a native program starts, but never one holding ' ` [ ] (msys2-runtime
* winsup/cygwin/msys2_path_conv.cc), and native Bun cannot open /c/x. The
* space keeps the path whole on its way into bash from this test: Bun quotes
* an argument with a space, and the MSYS runtime reads an unquoted ' in its
* command line as a quote.
*/
const UNCONVERTED_ROOT = "hook root o'brien";
/** A fresh such root, spelled as pwd -P spells it (macOS's /var is /private/var). */
const unconvertedRoot = () => path.join(fs.realpathSync(tmpBase()), UNCONVERTED_ROOT);
/**
* A Windows bash on a POSIX host for a root Git Bash does not convert:
* OSTYPE=msys, a cygpath that spells <root> as another directory, and a bun
* that fails, as bun.exe does, on an argument naming <root> in its shell
* spelling. The bun maps the cygpath spelling back before it runs the real Bun.
*/
function simulatedWindowsBash(root: string): NodeJS.ProcessEnv {
const dir = tmpBase();
const vars = `APOS=${JSON.stringify(root)} LINK=${JSON.stringify(path.join(dir, 'native-spelling'))}`;
const write = (name: string, body: string[]) => fs.writeFileSync(path.join(dir, name), ['#!/usr/bin/env bash', vars, ...body, ''].join('\n'), { mode: 0o755 });
write('cygpath', [
'[ "$1" = -m ] && shift',
'for p in "$@"; do case "$p" in "$APOS"*) p="$LINK${p#"$APOS"}" ;; esac; printf \'%s\\n\' "$p"; done',
]);
write('bun', [
'a=()',
'for x in "$@"; do',
' case "$x" in',
' --config=NUL) a+=(--config=/dev/null) ;;',
' "$LINK"*) a+=("$APOS${x#"$LINK"}") ;;',
' *"$APOS"*) echo "error: Module not found \\"$x\\"" >&2; exit 1 ;;',
' *) a+=("$x") ;;',
' esac',
'done',
`exec ${JSON.stringify(process.execPath)} "\${a[@]}"`,
]);
return { OSTYPE: 'msys', PATH: `${dir}${path.delimiter}${process.env.PATH ?? ''}` };
}
describe('gstack-hook-check: the hook list is the registration code', () => {
test('equals every hook setup resolves for registration plus every gstack path a skill frontmatter command runs', () => {
const registered = [...SETUP.matchAll(/_hook_command_path (\S+)/g)].map(m => m[1]!.replace(/\W+$/, ''));
@@ -135,6 +176,34 @@ describe('gstack-hook-check: what fails', () => {
expect(broken.out).not.toContain('bun could not bundle the TypeScript entry');
}, 90_000); // Git Bash process startup makes two checks slow on Windows.
// Under a home such as C:\Users\O'Brien, or with MSYS_NO_PATHCONV=1, Bun got
// each entry as /c/x and every TypeScript hook was reported as "bun could
// not bundle the TypeScript entry". POSIX hosts run the simulated Windows bash.
test('entries bundle in a root Git Bash does not convert', () => {
const root = unconvertedRoot();
fixtureTree(root);
const envs = process.platform === 'win32' ? [{}, { MSYS_NO_PATHCONV: '1' }] : [simulatedWindowsBash(root)];
for (const env of envs) {
const r = check(root, env);
expect(r.out).not.toContain('fail ');
expect(r.code).toBe(0);
expect(r.out.trim().split('\n')).toEqual(HOOKS.map(h => `ok ${h}`));
}
}, 90_000);
test('a root named like a glob pattern is read literally, not as the sibling it matches', () => {
const base = fs.realpathSync(tmpBase());
const root = path.join(base, 'hooks[1]');
fixtureTree(root);
fixtureTree(path.join(base, 'hooks1'));
const envs = process.platform === 'win32' ? [{}] : [{}, simulatedWindowsBash(root)];
for (const env of envs) {
const r = check(root, env);
expect(r.out).not.toContain('fail ');
expect(r.code).toBe(0);
}
}, 90_000);
test('healthy fixture passes', () => {
const root = tmpBase();
fixtureTree(root);
@@ -296,6 +365,41 @@ describe('gstack-hook-check: what fails', () => {
});
});
/** The TypeScript files a shim runs, as gstack-hook-check's ts_entries reads them. */
const tsEntries = (shim: string) => [...new Set(fs.readFileSync(shim, 'utf8').split('\n')
.filter(line => !/^\s*#/.test(line)).flatMap(line => [...line.matchAll(/[\w.-]+\.ts\b/g)].map(m => m[0])))];
/** Every shim that starts Bun on a TypeScript entry: the hooks setup and skills register, plus the opt-in shims beside them (gstack-memorable registers its own). */
const BUN_SHIMS = [...new Set([...HOOKS, ...fs.readdirSync(path.join(ROOT, 'hosts/claude/hooks'))
.filter(f => !path.extname(f)).map(f => `hosts/claude/hooks/${f}`)])]
.filter(h => fs.statSync(path.join(ROOT, h), { throwIfNoEntry: false })?.isFile() && tsEntries(path.join(ROOT, h)).length > 0);
describe('hook shims: Bun gets an entry path it can open', () => {
// Each shim spells its own directory with pwd (/c/x on Git Bash), so under a
// root Git Bash does not convert every TypeScript hook died in bun.exe with
// "Module not found" before it ran: the /autoplan Read barrier denied every
// Read, and the record and gate hooks did nothing. POSIX hosts run the
// simulated Windows bash.
test('every shim that runs TypeScript starts its entry in a root Git Bash does not convert', () => {
expect(BUN_SHIMS.length).toBeGreaterThanOrEqual(13);
const root = unconvertedRoot();
for (const shim of BUN_SHIMS) {
fs.mkdirSync(path.dirname(path.join(root, shim)), { recursive: true });
fs.copyFileSync(path.join(ROOT, shim), path.join(root, shim));
fs.chmodSync(path.join(root, shim), 0o755);
for (const entry of tsEntries(path.join(ROOT, shim))) fs.writeFileSync(path.join(root, path.dirname(shim), entry), "console.log('entry ran');\n");
}
const env = { ...process.env, ...(process.platform === 'win32' ? {} : simulatedWindowsBash(root)) };
// autoplan-stop-gate-publish starts Bun only for a publish no-op.
const input = JSON.stringify({ tool_input: { command: 'true autoplan-published ceo' } });
const runs = BUN_SHIMS.map((shim) => {
const r = spawnSync('bash', [posix(path.join(root, shim))], { input, env, encoding: 'utf8', timeout: 30_000 });
return `${shim}: ${r.status} ${r.stdout.trim()}`;
});
expect(runs).toEqual(BUN_SHIMS.map(shim => `${shim}: 0 entry ran`));
}, 120_000); // Thirteen Git Bash and Bun starts on Windows.
});
describe('setup: registers the hooks that parse, refuses the rest, exits non-zero', () => {
test('the gate runs before any hook registration is healed or written', () => {
const gate = SETUP.indexOf('# Hook parse gate');
@@ -412,3 +516,16 @@ describe('setup: registers the hooks that parse, refuses the rest, exits non-zer
expect(registeredCommands(fx)).toEqual(before);
}, 30_000); // Two setup hook passes, each resolving every gate switch.
});
describe('setup: Git Bash argument conversion stays on for what setup starts', () => {
// MSYS_NO_PATHCONV=1 or MSYS2_ARG_CONV_EXCL=* (common for Docker users) left
// every /c/x argument unconverted, so setup's first Bun step failed (#4386).
test('a Windows bash unsets MSYS_NO_PATHCONV and MSYS2_ARG_CONV_EXCL; other shells keep them', () => {
const script = SETUP.slice(0, SETUP.indexOf('\numask 077')) + '\necho "nopathconv=' + '$' + '{MSYS_NO_PATHCONV-unset} excl=' + '$' + '{MSYS2_ARG_CONV_EXCL-unset}"\n';
const run = (ostype: string) => spawnSync('bash', ['-c', script], { encoding: 'utf8', timeout: 30_000, env: { ...process.env, OSTYPE: ostype, MSYS_NO_PATHCONV: '1', MSYS2_ARG_CONV_EXCL: '*' } }).stdout.trim();
expect(run('msys')).toBe('nopathconv=unset excl=unset');
expect(run('cygwin')).toBe('nopathconv=unset excl=unset');
if (process.platform !== 'win32') expect(run('linux-gnu')).toBe('nopathconv=1 excl=*');
});
});
+26
View File
@@ -132,6 +132,32 @@ describe.skipIf(process.platform === 'win32')('setup installs production depende
expect(stub3.calls()).toEqual(['install --frozen-lockfile', 'install']);
});
// #4288: setup runs under umask 077 for its own state and logs. Bun extracts
// packages into its shared cache with the caller's umask, and later installs of
// unrelated projects hardlink those files, so the installs run under 022.
test('install_runtime_deps installs under umask 022 on every branch while setup keeps 077 (#4288)', () => {
const umaskBun = (base: string) => {
const log = path.join(base, 'umasks');
const bun = path.join(base, 'umask-bun');
fs.writeFileSync(bun, `#!/usr/bin/env bash\numask >> ${JSON.stringify(log)}\nexec ${JSON.stringify(stubBun(base).bun)} "$@"\n`, { mode: 0o755 });
return { bun, umasks: () => fs.readFileSync(log, 'utf-8').trim().split('\n') };
};
const run = (base: string, env: Record<string, string>) => {
const stub = umaskBun(base);
const r = runBashScript(`umask 077\n${script(stub.bun, 'install_runtime_deps')}\necho "after=$(umask)"\n`, { cwd: base, env: { ...process.env, ...env } });
expect(r.status, r.stderr).toBe(0);
expect(r.stdout).toContain('after=0077');
return stub.umasks();
};
expect(run(tempBase(), { FROZEN_RC: '0' })).toEqual(['0022']);
expect(run(tempBase(), { FROZEN_RC: '1' })).toEqual(['0022', '0022', '0022']);
const contributor = tempBase();
markContributor(contributor);
fs.mkdirSync(path.join(contributor, 'node_modules', 'typescript'), { recursive: true });
expect(run(contributor, { FROZEN_RC: '1' })).toEqual(['0022', '0022']);
expect(setup).toMatch(/\(\n\s+umask 022\n\s+cd "\$SOURCE_GSTACK_DIR"\n\s+if \[ -n "\$_PLAYWRIGHT_PLATFORM_OVERRIDE" \]/);
});
test('every bun install in setup goes through install_runtime_deps', () => {
const body = setup.replace(sliceFunction(setup, 'install_runtime_deps'), '');
const directInstall = /(?:^|[\s;&|(])(?:bun_cmd|"?\$\{?BUN_CMD\}?"?|bun)\s+install\b/;