ux: create parent directories before moving config files (#1127)

Fixes #1125 and #1114

The upload_config_file() function now creates parent directories
before moving config files to paths like ~/.claude/settings.json
and ~/.openclaw/openclaw.json.

Previously, if these directories didn't exist, the mv command would
fail with "No such file or directory" errors. This affected all
agents using setup_claude_code_config() and setup_openclaw_config().

Changes:
- Extract directory path using dirname
- Create parent directories with mkdir -p
- Execute chmod and mv in same command chain

Agent: ux-engineer

Co-authored-by: spawn-refactor-bot <refactor@openrouter.ai>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
A 2026-02-14 13:10:17 -08:00 committed by GitHub
parent b0843f6144
commit f871996a82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2327,7 +2327,12 @@ upload_config_file() {
rand_suffix=$(basename "${temp_file}")
local temp_remote="/tmp/spawn_config_${rand_suffix}"
${upload_callback} "${temp_file}" "${temp_remote}"
${run_callback} "chmod 600 '${temp_remote}' && mv '${temp_remote}' '${remote_path}'"
# Extract directory path and create parent directories if needed
# This handles paths like ~/.claude/settings.json or ~/.openclaw/openclaw.json
local dir_cmd
dir_cmd="parent_dir=\$(dirname '${remote_path}') && mkdir -p \"\${parent_dir}\" && chmod 600 '${temp_remote}' && mv '${temp_remote}' '${remote_path}'"
${run_callback} "${dir_cmd}"
}
# ============================================================