Skip to content

v1.57.4.0 fix(setup): route gen:skill-docs through bun_cmd; drop tail -3 pipe that masks bun failures#1898

Open
DavidMiserak wants to merge 1 commit into
garrytan:mainfrom
DavidMiserak:fix/setup-bun-cmd-and-pipe-bugs
Open

v1.57.4.0 fix(setup): route gen:skill-docs through bun_cmd; drop tail -3 pipe that masks bun failures#1898
DavidMiserak wants to merge 1 commit into
garrytan:mainfrom
DavidMiserak:fix/setup-bun-cmd-and-pipe-bugs

Conversation

@DavidMiserak
Copy link
Copy Markdown

@DavidMiserak DavidMiserak commented Jun 7, 2026

Summary

Fix two bugs in setup that silently broke skill doc generation on certain installations.

bun_cmd routing fix — Three helpers (link_codex_skill_dirs, link_factory_skill_dirs, link_opencode_skill_dirs) called literal bun run gen:skill-docs instead of the bun_cmd wrapper. The bun_cmd wrapper exists to handle Windows non-ASCII usernames: prepare_bun_for_windows_compile copies bun to an ASCII path and points BUN_CMD at it when needed. Bypassing it caused silent failures on affected installs. (setup:714, 919, 951)

Pipe-masking exit-code fix — The gbrain-detected SKILL.md regen ran bun_cmd run gen:skill-docs:user ... 2>&1 | tail -3. The pipe makes the subshell's exit status tail's, which is always 0, so the trailing || log "warning..." guard never fired when bun failed. Dropping the pipe restores correct failure detection. (setup:1297)

Both fixes were identified by @jbetala7 during review on #1883, carved out as a focused fast-merge PR per their request.

Test Coverage

CODE PATHS
[+] setup (shell script)
  ├── link_codex_skill_dirs()
  │   ├── [★★★ TESTED] bun_cmd invoked via $BUN_CMD — test:4
  │   └── [★★★ TESTED] uses bun_cmd, not bare bun — test:5
  ├── link_factory_skill_dirs()
  │   └── [★★★ TESTED] uses bun_cmd, not bare bun — test:5
  ├── link_opencode_skill_dirs()
  │   └── [★★★ TESTED] uses bun_cmd, not bare bun — test:5
  └── gbrain regen block (setup:1295-1298)
      ├── [★★★ TESTED] without pipe → || warning fires — test:1
      ├── [★★★ TESTED] with pipe (bug shape) → warning silent — test:2
      └── [★★★ TESTED] live block has no pipe — test:3

COVERAGE: 6/6 paths tested (100%)

Tests: 0 → 5 (+5 new)

Pre-Landing Review

Review: CLEAR (DIFF, 2026-06-08, same commit). Quality score: 9.0/10.

0 critical. 4 informational (all skipped — minor test quality suggestions, no blocking issues).

Adversarial: Pre-existing set -e dead-code in warning blocks (not introduced by this PR). Recommendation: ship as-is.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related files changed — evals skipped.

Greptile Review

No Greptile comments.

Scope Drift

Scope Check: CLEAN — 4 setup lines + 5 tests + CHANGELOG/VERSION, no creep.

Plan Completion

No plan file detected.

TODOS

No TODO items completed in this PR.

Test plan

  • bun test test/setup-bun-cmd-and-pipe-bugs.test.ts — 5 pass / 0 fail
  • bun test — exit code 0 (pre-existing failures in E2E/browse suites unrelated to this branch)
  • bash -n setup — syntax OK

🤖 Generated with Claude Code

@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Jun 7, 2026

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@jbetala7
Copy link
Copy Markdown
Contributor

jbetala7 commented Jun 8, 2026

Verified on main — both fixes are real and this is exactly the carve-out we discussed on #1883:

  • link_codex/factory/opencode_skill_dirs call literal bun run gen:skill-docs at setup:714/919/951, while the sibling install paths (setup:454/464/474) correctly use bun_cmd. On a non-ASCII Windows username the literal bun can't resolve the unicode path, the call exits nonzero, and the [ ! -d "$…_dir" ] guard immediately after silently proceeds as if generation succeeded. Switching those three to bun_cmd matches the rest of the function.
  • the | tail -3 on the gbrain gen:skill-docs:user regen (setup:1297) masks the pipeline exit status, so a failed regen still reports success and the || log "warning…" branch never fires. Dropping it restores real failure detection.

Scope is tight (4 setup lines + a focused regression test), no phase restructure, no Playwright behavior change. Looks correct to me.

@DavidMiserak DavidMiserak force-pushed the fix/setup-bun-cmd-and-pipe-bugs branch from 74febfc to 696ee59 Compare June 8, 2026 08:41
@github-actions github-actions Bot changed the title fix(setup): route gen:skill-docs through bun_cmd; drop tail -3 pipe that masks bun failures v1.57.4.0 fix(setup): route gen:skill-docs through bun_cmd; drop tail -3 pipe that masks bun failures Jun 8, 2026
DavidMiserak added a commit to DavidMiserak/gstack that referenced this pull request Jun 8, 2026
…ability

setup used to interleave trivial filesystem ops, expensive compute,
settings.json mutations, and network/sudo steps in whatever order the
script grew. A Playwright Chromium download failing at step 2 would
abort before skills got registered at step 4, hooks landed at step 10,
or migrations ran at step 8.

This commit groups work by where failures actually come from:

  Phase A — filesystem (always succeeds): ~/.gstack/, welcome, GBrain detection
  Phase B — local compute (low fail): bun build, skill linking, migrations, regen
  Phase C — settings.json mutation (medium fail, reversible): team-mode + plan-tune hooks
  Phase D — external network/sudo/package managers (highest fail): coreutils, font, Playwright

Each phase is bracketed with a header comment; steps within are
renumbered (A1, A2, B1, B2a...).

The biggest behavior shift is the GBrain detect/regen split that the
new order requires: detection moves to A3 (filesystem scan only, no
dependencies), regen moves to B6 (runs after the binary is built and
skill docs are generated). Detection persists to
~/.gstack/gbrain-detection.json so B6 can read it.

A safety guard for that split: when gstack-gbrain-detect exits non-zero,
A3 removes both the temp file AND any pre-existing detection file from a
prior successful run. Without the guard, a stale "ok" detection file
would survive a failed detect and silently apply ~250 tokens of overhead
per planning skill to a user whose gbrain may no longer be installed.

Behavior preservation:
- bun_cmd routing in link_{codex,factory,opencode}_skill_dirs is
  unchanged (still buggy here). The fix is in garrytan#1898.
- gen:skill-docs:user still pipes through `tail -3` in B6 (still buggy
  here). The fix is in garrytan#1898.
- Playwright Chromium install/verify in D3 still exits 1 on failure
  (unchanged). The warn-don't-exit conversion is in garrytan#1900 and
  coordinates with garrytan#1838.

Splitting those keeps this PR reviewable as "a move plus the gbrain
split that the move requires," per @jbetala7's request on garrytan#1883.
…hat masks bun failures

Two surgical fixes called out by @jbetala7 on garrytan#1883, carved out as the
focused fast-merge PR they asked for.

1. link_codex_skill_dirs, link_factory_skill_dirs, and
   link_opencode_skill_dirs called literal `bun run gen:skill-docs ...`
   instead of routing through `bun_cmd`, the wrapper installed by
   prepare_bun_for_windows_compile. On a non-ASCII Windows username the
   literal call would exit non-zero; the next line checks if the output
   directory exists and prints a soft warning, masking the failure.

2. The gbrain-detected SKILL.md regen ran
   `bun_cmd run gen:skill-docs:user --host claude 2>&1 | tail -3`. The
   pipe makes the subshell's exit status `tail`'s (always 0), swallowing
   bun's failure so the `|| log "warning..."` clause right after never
   fires regardless of whether bun succeeded.

Tests exercise the exit-code path, not source-grep: stub bun_cmd to fail,
run the actual shell pattern, assert the `|| log` clause fires only on
the fixed shape and does NOT fire on the buggy shape with the pipe.
@DavidMiserak DavidMiserak force-pushed the fix/setup-bun-cmd-and-pipe-bugs branch from e091eaa to 76957bd Compare June 8, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants