diff --git a/DreamcoderShell/.config/fish/conf.d/27-dreamcoder-gga-pin.fish b/DreamcoderShell/.config/fish/conf.d/27-dreamcoder-gga-pin.fish index 40f541ec..631878ad 100644 --- a/DreamcoderShell/.config/fish/conf.d/27-dreamcoder-gga-pin.fish +++ b/DreamcoderShell/.config/fish/conf.d/27-dreamcoder-gga-pin.fish @@ -1,9 +1,7 @@ -# gga reviews: Codex provider with the pinned model shim first on PATH. -# The shim only changes `codex exec` calls made by gga (docs/configuration/gga.md). +# gga reviews use the Codex provider. The model itself is pinned by the shim in +# ~/.config/gga/bin (docs/configuration/gga.md); putting that directory on PATH happens in +# config.fish, because conf.d runs before it and config.fish prepends ~/.local/bin, which +# would leave the real codex ahead of the shim. set -l _dc_config_home $HOME/.config set -q XDG_CONFIG_HOME[1]; and test -n "$XDG_CONFIG_HOME"; and set _dc_config_home $XDG_CONFIG_HOME -set -l _dc_gga_bin $_dc_config_home/gga/bin -if test -d $_dc_gga_bin - set -gx GGA_PROVIDER codex - fish_add_path --global --move --path $_dc_gga_bin -end +test -d $_dc_config_home/gga/bin; and set -gx GGA_PROVIDER codex diff --git a/DreamcoderShell/.config/fish/config.fish b/DreamcoderShell/.config/fish/config.fish index 35951116..fcda5d6e 100644 --- a/DreamcoderShell/.config/fish/config.fish +++ b/DreamcoderShell/.config/fish/config.fish @@ -20,6 +20,13 @@ if test -d "$HOME/.bun/bin" fish_add_path -g "$BUN_INSTALL/bin" end +# gga model pin: the shim must come before ~/.local/bin (the real codex). fish keeps +# fish_user_paths ahead of the rest of PATH, so the shim has to join that list (no --path) and +# move to its front. Keep this after the block above: each fish_add_path puts its entries first. +set -l _dc_gga_config_home $HOME/.config +set -q XDG_CONFIG_HOME[1]; and test -n "$XDG_CONFIG_HOME"; and set _dc_gga_config_home $XDG_CONFIG_HOME +test -d $_dc_gga_config_home/gga/bin; and fish_add_path --global --move $_dc_gga_config_home/gga/bin + if status is-interactive command -q zoxide; and zoxide init fish | source end diff --git a/tests/shell/test_gga_pin.bats b/tests/shell/test_gga_pin.bats index e4d22a39..0d173aec 100644 --- a/tests/shell/test_gga_pin.bats +++ b/tests/shell/test_gga_pin.bats @@ -189,3 +189,33 @@ shim() { PATH="${SHIM_DIR}:${REAL_BIN}:${PATH}" "$@"; } run -127 env PATH="${SHIM_DIR}:/usr/bin:/bin" codex exec x [[ "$output" == *"real codex CLI was not found"* ]] } + +# ── fish PATH order ────────────────────────────────────────────────── + +# fish keeps fish_user_paths ahead of the rest of PATH, and config.fish adds ~/.local/bin (where +# the real codex lives) to it. A shim directory added with --path, or only from conf.d, ends up +# behind the real codex, so a config rewrite by gentle-ai would silently drop the model pin. +@test "fish: the gga shim directory precedes ~/.local/bin in fish_user_paths after config.fish" { + command -v fish >/dev/null || skip "fish not installed" + gga_setup + mkdir -p "${HOME}/.local/bin" "${SHIM_DIR}" + run env -u XDG_CONFIG_HOME HOME="${HOME}" fish --no-config -c ' + source '"${DREAMCODER_DOTS_DIR}"'/DreamcoderShell/.config/fish/conf.d/27-dreamcoder-gga-pin.fish + source '"${DREAMCODER_DOTS_DIR}"'/DreamcoderShell/.config/fish/config.fish + set -l shim (contains -i -- $HOME/.config/gga/bin $fish_user_paths) + set -l real (contains -i -- $HOME/.local/bin $fish_user_paths) + test -n "$shim" -a -n "$real" -a "$shim" -lt "$real"; and echo ordered + ' 2>/dev/null + [[ "$output" == *ordered* ]] +} + +@test "fish: GGA_PROVIDER is exported when the shim directory exists" { + command -v fish >/dev/null || skip "fish not installed" + gga_setup + mkdir -p "${SHIM_DIR}" + run env -u XDG_CONFIG_HOME -u GGA_PROVIDER HOME="${HOME}" fish --no-config -c ' + source '"${DREAMCODER_DOTS_DIR}"'/DreamcoderShell/.config/fish/conf.d/27-dreamcoder-gga-pin.fish + echo "provider=$GGA_PROVIDER" + ' 2>/dev/null + [[ "$output" == *"provider=codex"* ]] +}