feat(source): enable running gsd directly from source checkout
Adds bin/gsd-from-source shell wrapper that bun-runs src/loader.ts, so local commits are live without reinstalling gsd-pi. Patches loader.ts to respect a pre-set GSD_BIN_PATH (previously it clobbered the env var with process.argv[1], forcing subagent spawns to point at the .ts loader path which child_process.spawn can't execute). Why: working on fixes like #4251 required full `bun install -g --trust gsd-pi` cycles plus longcat shim re-patching for every iteration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1f1c029c74
commit
80ce0f4855
2 changed files with 28 additions and 2 deletions
24
bin/gsd-from-source
Executable file
24
bin/gsd-from-source
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# gsd-from-source — run GSD directly from this source checkout via bun.
|
||||
#
|
||||
# Purpose: every local commit in this repo (e.g. the #4251 fix) is live
|
||||
# immediately without reinstalling the bun-packaged gsd-pi. Subagents can
|
||||
# spawn gsd by pointing GSD_BIN_PATH at this script instead of dist/loader.js.
|
||||
#
|
||||
# Contract:
|
||||
# - Executable shim spawn() / exec() can launch directly.
|
||||
# - Exports GSD_BIN_PATH before handing off to loader.ts so loader.ts's
|
||||
# `GSD_BIN_PATH ||= process.argv[1]` branch preserves the shim path
|
||||
# instead of clobbering it with the .ts loader path (which is not
|
||||
# directly executable by child_process.spawn).
|
||||
#
|
||||
# Requirements: bun on PATH, node_modules populated (`bun install` once).
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
GSD_SOURCE_ROOT=$(cd -- "$SCRIPT_DIR/.." &>/dev/null && pwd)
|
||||
|
||||
export GSD_BIN_PATH="$SCRIPT_DIR/gsd-from-source"
|
||||
|
||||
exec bun run "$GSD_SOURCE_ROOT/src/loader.ts" "$@"
|
||||
|
|
@ -137,8 +137,10 @@ const { Module } = await import('module');
|
|||
process.env.GSD_VERSION = gsdVersion
|
||||
|
||||
// GSD_BIN_PATH — absolute path to this loader (dist/loader.js), used by patched subagent
|
||||
// to spawn gsd instead of pi when dispatching workflow tasks
|
||||
process.env.GSD_BIN_PATH = process.argv[1]
|
||||
// to spawn gsd instead of pi when dispatching workflow tasks.
|
||||
// Respect a pre-set value so a source-mode wrapper (e.g. bin/gsd-from-source) can
|
||||
// advertise the executable shim instead of the .ts loader path (which spawn() can't exec).
|
||||
process.env.GSD_BIN_PATH = process.env.GSD_BIN_PATH || process.argv[1]
|
||||
|
||||
// GSD_WORKFLOW_PATH — absolute path to bundled GSD-WORKFLOW.md, used by patched gsd extension
|
||||
// when dispatching workflow prompts. Prefers dist/resources/ (stable, set at build time)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue