diff --git a/bin/gs b/bin/gs index 11a4b08..daed4f2 100755 --- a/bin/gs +++ b/bin/gs @@ -472,6 +472,10 @@ cmd_sync() { fi ln -sfn "$ai_bin" "$HOME/.local/bin/gentle-ai" ln -sfn "$bin/engram" "$HOME/.local/bin/engram" + # gentle-ai sync and gentle-shell setup must use the Engram built above: without + # it, gentle-ai's beta channel runs its own go install of the pre-v3 module path, + # which fails. Set here so the sync never depends on the calling shell's env. + export GENTLE_AI_ENGRAM_BIN="${GENTLE_AI_ENGRAM_BIN:-$bin/engram}" # New binaries are not enough: gentle-ai sync materializes the managed configs # (agents, skills, plugins, engram instructions) every runtime reads. diff --git a/docs/gs-sync.md b/docs/gs-sync.md index c8402cd..17ee3c9 100644 --- a/docs/gs-sync.md +++ b/docs/gs-sync.md @@ -100,10 +100,15 @@ Check: `scripts/test-engram-auto-setup.sh`. On the beta channel, `gentle-ai sync` and installs run `go install github.com/Gentleman-Programming/engram/cmd/engram@main`. That is the -pre-v3 module path, so it installs Engram v1 over the v3 binary. -`zsh/cortex-dotfiles.zsh` exports `GENTLE_AI_ENGRAM_BIN=$HOME/.local/bin/engram`, -which makes gentle-ai use that binary instead of installing one. `gs sync` -installs v3 at that path. +pre-v3 module path: it fails (`missing .../cmd/engram/go.mod`) or installs +Engram v1 over the v3 binary. `GENTLE_AI_ENGRAM_BIN` makes gentle-ai use a given +binary instead of installing one. + +`gs sync` sets `GENTLE_AI_ENGRAM_BIN` to the Engram it just built before it runs +`gentle-ai sync` and `gentle-shell --isolated setup`, so the sync does not depend +on the calling shell (a shell opened before a dotfiles update, or a host that +does not load them). A value already set in the environment wins. +`zsh/cortex-dotfiles.zsh` also exports it for `gentle-ai` runs outside `gs sync`. Check: `engram version` reports 3.x after `gs sync` and after starting Pi. diff --git a/tests/gs_test.sh b/tests/gs_test.sh index 93eecf6..558b71e 100755 --- a/tests/gs_test.sh +++ b/tests/gs_test.sh @@ -218,6 +218,20 @@ SHELL_CLONE="$HOME/dev/gentle/gentle-shell" : > "$CALLS"; OUT=$(env -u GS_SKIP_AI_SYNC "$GS" sync 2>&1); rc=$? check "workshop sync: gentle-ai sync targets claude-code only, then gentle-shell setup on the isolated home" \ '[ $rc -eq 0 ] && [ "$(grep -E "^gentle-ai sync|--isolated setup" "$CALLS")" = "$(printf "gentle-ai sync --agents claude-code\nlaunch %s --isolated setup" "$SHELL_CLONE")" ] && [[ "$OUT" == *"gentle-shell setup (isolated home)"*ok* ]]' +# gentle-ai and gentle-shell setup must use the Engram gs just built, even when the +# calling shell never exported GENTLE_AI_ENGRAM_BIN (else beta installs the pre-v3 path). +printf '#!/bin/sh\n[ "$1" = --version ] && { echo "gentle-ai 1.0.0"; exit 0; }\necho "gentle-ai engram=${GENTLE_AI_ENGRAM_BIN:-unset}" >> "$CALLS"\n' > "$AI" +cp "$S/node" "$T/node.real" +printf '#!/bin/sh\necho "setup engram=${GENTLE_AI_ENGRAM_BIN:-unset}" >> "$CALLS"\nexec %s "$@"\n' "$T/node.real" > "$S/node" +: > "$CALLS"; OUT=$(env -u GS_SKIP_AI_SYNC -u GENTLE_AI_ENGRAM_BIN "$GS" sync 2>&1) +EB="$HOME/.local/share/gentle-ai/main/engram" +check "workshop sync: gentle-ai sync and gentle-shell setup get GENTLE_AI_ENGRAM_BIN on the built engram" \ + 'grep -qx "gentle-ai engram=$EB" "$CALLS" && grep -qx "setup engram=$EB" "$CALLS"' +: > "$CALLS"; OUT=$(env -u GS_SKIP_AI_SYNC GENTLE_AI_ENGRAM_BIN=/opt/e "$GS" sync 2>&1) +check "workshop sync: an explicit GENTLE_AI_ENGRAM_BIN wins" \ + 'grep -qx "gentle-ai engram=/opt/e" "$CALLS" && grep -qx "setup engram=/opt/e" "$CALLS"' +cp "$T/node.real" "$S/node" +printf '#!/bin/sh\n[ "$1" = --version ] && { echo "gentle-ai 1.0.0"; exit 0; }\necho "gentle-ai $*" >> "$CALLS"\n' > "$AI" : > "$CALLS"; OUT=$(env -u GS_SKIP_AI_SYNC GS_SYNC_AGENTS=x "$GS" sync 2>&1) check "workshop sync: GS_SYNC_AGENTS overrides the claude-code default" \ 'grep -qx "gentle-ai sync --agents x" "$CALLS"'