fix(install): honor CLAUDE_CONFIG_DIR as config root, not agents dir (#834)

resolve_dest() for claude-code now appends /agents to CLAUDE_CONFIG_DIR (the config root that replaces ~/.claude); a value already ending in /agents is used verbatim and a trailing slash is stripped. detect_claude_code() honors CLAUDE_CONFIG_DIR so relocated configs are detected. Three regression cases in scripts/test-install.sh.

Fixes #578. The diagnosis and the same fix were first proposed by @halindrome in #579 (June); this lands the current-main version with tests.

Co-Authored-By: Shane McCarron <520688+halindrome@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
emindagg
2026-09-04 13:06:36 -05:00
committed by GitHub
co-authored by Shane McCarron Claude Fable 5.1
parent 882d4cda89
commit af128a9288
2 changed files with 46 additions and 2 deletions
+31
View File
@@ -186,6 +186,37 @@ RUN_OUT="$(HOME="$home" COPILOT_AGENT_DIR="$home/from-env" "$INSTALL" --no-inter
assert_eq "$TOTAL_AGENTS" "$(count_md "$home/from-flag")" "--path wins over the env var"
assert_eq 0 "$(count_md "$home/from-env")" "env var destination is unused when --path is given"
# ---------------------------------------------------------------------------
# 3b. CLAUDE_CONFIG_DIR is the config root, not the agents dir (issue #578)
#
# Claude Code replaces ~/.claude with $CLAUDE_CONFIG_DIR, so agents belong in
# $CLAUDE_CONFIG_DIR/agents — matching the default ${HOME}/.claude/agents.
# Before the fix, resolve_dest returned the variable verbatim and agents
# landed in the config root where Claude Code never loads them; detection
# also missed relocated configs entirely.
# ---------------------------------------------------------------------------
home="$(sandbox claude-config-dir)"
cfg="$home/.config/claude-code"
RUN_OUT="$(HOME="$home" CLAUDE_CONFIG_DIR="$cfg" "$INSTALL" --no-interactive --tool claude-code 2>&1)"; RUN_STATUS=$?
assert_eq 0 "$RUN_STATUS" "CLAUDE_CONFIG_DIR install exits 0"
assert_eq "$TOTAL_AGENTS" "$(count_md "$cfg/agents")" "CLAUDE_CONFIG_DIR installs agents into \$CLAUDE_CONFIG_DIR/agents"
assert_eq 0 "$(count_md "$cfg")" "CLAUDE_CONFIG_DIR leaves the config root itself empty"
# Trailing slash and a pre-existing /agents suffix both resolve cleanly.
home="$(sandbox claude-config-dir-slash)"
cfg="$home/.config/claude-code/"
RUN_OUT="$(HOME="$home" CLAUDE_CONFIG_DIR="$cfg" "$INSTALL" --no-interactive --tool claude-code 2>&1)"; RUN_STATUS=$?
assert_eq 0 "$RUN_STATUS" "trailing-slash CLAUDE_CONFIG_DIR install exits 0"
assert_eq "$TOTAL_AGENTS" "$(count_md "$home/.config/claude-code/agents")" \
"a trailing slash on CLAUDE_CONFIG_DIR still resolves to .../agents"
home="$(sandbox claude-config-dir-agents)"
cfg="$home/.config/claude-code/agents"
RUN_OUT="$(HOME="$home" CLAUDE_CONFIG_DIR="$cfg" "$INSTALL" --no-interactive --tool claude-code 2>&1)"; RUN_STATUS=$?
assert_eq 0 "$RUN_STATUS" "pre-suffixed CLAUDE_CONFIG_DIR install exits 0"
assert_eq "$TOTAL_AGENTS" "$(count_md "$cfg")" \
"a CLAUDE_CONFIG_DIR already ending in /agents is used verbatim (no double-nesting)"
# ---------------------------------------------------------------------------
# 4. Paths with spaces (regression: word-splitting in the install loop)
# ---------------------------------------------------------------------------