Skip to content

fix(setup): phase-ordered setup — skills/hooks land before network ops#1

Open
DavidMiserak wants to merge 2 commits into
mainfrom
fix/reduce-risk
Open

fix(setup): phase-ordered setup — skills/hooks land before network ops#1
DavidMiserak wants to merge 2 commits into
mainfrom
fix/reduce-risk

Conversation

@DavidMiserak

@DavidMiserak DavidMiserak commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Restructures setup into four phases ordered by failure probability, so a bad network day or missing sudo never leaves users with zero skills installed
  • Makes Playwright/Chromium failures non-fatal — was exit 1, now a named warning with $_PW_FAIL_REASON; skills, hooks, and migrations are already in place before Phase D runs
  • Fixes two bugs found in code review

Phase structure

Phase What runs Fail risk
A Filesystem ops: ~/.gstack/, welcome message, GBrain detection Always succeeds
B Local compute: binary build, skill linking, migrations, GBrain regen Low
C settings.json mutation: team/plan-tune hooks Medium, fully reversible
D Network/sudo/package managers: coreutils, emoji font, Playwright Highest — warn not exit

Previously, a Playwright install failure (network issue, bad mirror, missing sudo) would exit 1 mid-run, leaving skills unregistered. Now Phase D is best-effort; re-running ./setup retries only that phase.

Bug fixes

  • Windows non-ASCII bun path (lines 587, 792, 824): link_codex_skill_dirs, link_factory_skill_dirs, and link_opencode_skill_dirs were calling bun run directly instead of bun_cmd, bypassing the Windows non-ASCII path workaround. Silent failures masked by subsequent directory-existence checks.
  • GBrain regen exit code masked (line 1200): bun_cmd run gen:skill-docs:user ... | tail -3 caused tail's exit 0 to swallow bun's failure, so the || log "warning..." clause never fired. Removed the pipe.

Test plan

  • Run ./setup on a clean install — confirm skills link, hooks install, and Playwright failure (if any) prints a warning instead of aborting
  • Run ./setup --host codex on Windows with non-ASCII username — confirm Codex skill docs generate
  • Run ./setup with GBrain installed — confirm warning fires if gen:skill-docs:user fails

Restructures setup into four phases ordered by failure probability so a
bad network day or missing sudo never leaves users with zero skills:

  Phase A — trivial filesystem ops (always succeed)
  Phase B — local compute: binary build, skill linking, migrations
  Phase C — settings.json mutation (reversible)
  Phase D — network/sudo/package managers (best-effort, warn not exit)

Playwright/Chromium failures are now non-fatal warnings with a named
$_PW_FAIL_REASON. Skills, hooks, and migrations are already installed
before Phase D runs; re-running ./setup retries only the network step.

Also fixes two bugs found in code review:
- Use bun_cmd wrapper (not bare bun) in Codex/Factory/OpenCode skill
  generation helpers — fixes silent failures on Windows with non-ASCII
  bun paths
- Remove | tail -3 pipe in GBrain regen so bun exit code is preserved
  and the error warning actually fires on failure

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the setup script into four ordered phases (A–D) so that skill linking, hooks, and migrations complete before higher-risk network/sudo operations. It also changes Playwright/Chromium installation failures from fatal exits to warnings, and fixes Windows non-ASCII Bun path issues by routing skill-doc generation through bun_cmd.

Changes:

  • Reorders setup flow into Phase A (trivial), Phase B (local compute/filesystem), Phase C (settings mutation), and Phase D (network/package managers).
  • Makes Playwright/Chromium installation and launch checks best-effort, emitting a warning with a reason code instead of aborting.
  • Fixes skill-doc generation on Windows non-ASCII Bun paths by using bun_cmd for Codex/Factory/OpenCode doc generation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread setup
Comment thread setup Outdated
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.

3 participants