gstack/lib
fongwc 1c9da7620c fix: resolveSlug returns "unknown" on Windows, sending decisions to projects/unknown
lib/bin-context.ts spawns the `gstack-slug` bash script directly. Windows has
no shebang support, so spawnSync fails with ENOENT, stdout is null, and the
slug silently falls back to "unknown".

Every bun-based bin that resolves a slug this way then reads and writes
~/.gstack/projects/unknown/ instead of the real project. In practice that means
gstack-decision-log writes decisions somewhere gstack-decision-search on another
project can also see, and the Context Recovery block in every skill preamble
never surfaces them, because it checks for decisions.active.json under the
correct slug. The failure is silent: exit 0, empty results, nothing in any log.

Same root cause as the spawn half of #2356, and the same class the #1731 fix
addressed for gbrain. That fix used `shell: true`, which is right for gbrain
because gbrain ships a .cmd shim on Windows. gstack's own bins are extensionless
bash scripts, so cmd.exe answers "is not recognized as an internal or external
command" and only `spawnSync("bash", [script])` starts them:

  spawnSync(bin)                  -> ENOENT
  spawnSync(bin, {shell: true})   -> not recognized as an internal or external command
  spawnSync("bash", [bin])        -> status 0

Adds spawnBashBin() and routes resolveSlug through it. The direct spawn is still
attempted first, so POSIX behaviour is byte-for-byte unchanged and the bash
fallback only runs on the path that is currently broken.

Verified on Windows 11, bun 1.3.13, Git Bash, global git install at
~/.claude/skills/gstack:

  before: gstack-decision-search --json -> []   (2 decisions on disk)
  after:  gstack-decision-search --json -> 2 decisions, from both the repo root
          and a subdirectory with a different git remote

Test suite unchanged: test/gbrain-spawn-windows-shell.test.ts,
gstack-decision.test.ts, gstack-decision-bins.test.ts,
bin-windows-bun-import-paths.test.ts and gstack-slug-sanitize.test.ts report
39 pass / 18 fail both before and after this commit on Windows at a3259400,
so this introduces no regressions. Those 18 pre-existing failures look like
separate Windows path bugs in the tests themselves and are not touched here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-29 12:39:54 +08:00
..
diagram-render v1.58.0.0 feat: diagram + multi-format document engine (mermaid, excalidraw, single-file HTML, DOCX) (#1990) 2026-06-12 15:38:53 -07:00
bin-context.ts fix: resolveSlug returns "unknown" on Windows, sending decisions to projects/unknown 2026-07-29 12:39:54 +08:00
conductor-env-shim.ts v1.58.1.0 feat: hermetic local E2E + Conductor prose AskUserQuestion (#2004) 2026-06-14 11:40:57 -07:00
gbrain-exec.ts v1.58.4.0 fix: high-priority community bug wave + PTY plan-mode smoke gate (#2077) 2026-06-21 07:15:19 -07:00
gbrain-guards.ts v1.57.5.0 feat: cross-session decision memory + gbrain dream-stage call graph (#1910) 2026-06-08 06:20:58 -07:00
gbrain-local-status.ts fix(gbrain): classify PGLite connect locks 2026-07-10 16:51:16 -07:00
gbrain-sources.ts v1.57.5.0 feat: cross-session decision memory + gbrain dream-stage call graph (#1910) 2026-06-08 06:20:58 -07:00
gstack-decision-semantic.ts v1.57.5.0 feat: cross-session decision memory + gbrain dream-stage call graph (#1910) 2026-06-08 06:20:58 -07:00
gstack-decision.ts v1.57.5.0 feat: cross-session decision memory + gbrain dream-stage call graph (#1910) 2026-06-08 06:20:58 -07:00
gstack-memory-helpers.ts fix(gbrain): canonicalize remotes with trailing slashes 2026-07-14 12:56:09 -07:00
is-conductor.ts v1.58.1.0 feat: hermetic local E2E + Conductor prose AskUserQuestion (#2004) 2026-06-14 11:40:57 -07:00
jsonl-store.ts v1.57.5.0 feat: cross-session decision memory + gbrain dream-stage call graph (#1910) 2026-06-08 06:20:58 -07:00
redact-audit-log.ts v1.53.0.0 feat: smarter redaction — PII/secrets/legal guard across /spec, /ship, /cso, /document-* (#1797) 2026-05-30 08:54:46 -07:00
redact-engine.ts v1.58.4.0 fix: high-priority community bug wave + PTY plan-mode smoke gate (#2077) 2026-06-21 07:15:19 -07:00
redact-patterns.ts v1.58.4.0 fix: high-priority community bug wave + PTY plan-mode smoke gate (#2077) 2026-06-21 07:15:19 -07:00
staging-guard.ts v1.56.1.0 fix(sync): staging-dir ownership guard + resume-correctness fixes (#1802) (#1856) 2026-06-07 06:51:10 -07:00
worktree.ts feat: content security — 4-layer prompt injection defense for pair-agent (#815) 2026-04-06 14:41:06 -07:00