fix: bug: entrypoint clones project at /home/agent/repos/${COMPOSE_PROJECT_NAME} but TOML parse later rewrites PROJECT_REPO_ROOT — dev-agent cd fails silently (#861)
This commit is contained in:
parent
342928bb32
commit
820ffafd0f
2 changed files with 23 additions and 1 deletions
|
|
@ -254,7 +254,11 @@ agent_recover_session
|
||||||
# WORKTREE SETUP
|
# WORKTREE SETUP
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
status "setting up worktree"
|
status "setting up worktree"
|
||||||
cd "$REPO_ROOT"
|
if ! cd "$REPO_ROOT"; then
|
||||||
|
log "ERROR: REPO_ROOT=${REPO_ROOT} does not exist — cannot cd"
|
||||||
|
log "Check PROJECT_REPO_ROOT vs compose PROJECT_NAME vs TOML name mismatch"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Determine forge remote by matching FORGE_URL host against git remotes
|
# Determine forge remote by matching FORGE_URL host against git remotes
|
||||||
_forge_host=$(printf '%s' "$FORGE_URL" | sed 's|https\?://||; s|/.*||')
|
_forge_host=$(printf '%s' "$FORGE_URL" | sed 's|https\?://||; s|/.*||')
|
||||||
|
|
|
||||||
|
|
@ -315,6 +315,24 @@ _setup_git_creds
|
||||||
configure_git_identity
|
configure_git_identity
|
||||||
configure_tea_login
|
configure_tea_login
|
||||||
|
|
||||||
|
# Parse first available project TOML to get the project name for cloning.
|
||||||
|
# This ensures PROJECT_NAME matches the TOML 'name' field, not the compose
|
||||||
|
# default of 'project'. The clone will land at /home/agent/repos/<toml_name>
|
||||||
|
# and subsequent env exports in the main loop will be consistent.
|
||||||
|
if compgen -G "${DISINTO_DIR}/projects/*.toml" >/dev/null 2>&1; then
|
||||||
|
_first_toml=$(compgen -G "${DISINTO_DIR}/projects/*.toml" | head -1)
|
||||||
|
_pname=$(python3 -c "
|
||||||
|
import sys, tomllib
|
||||||
|
with open(sys.argv[1], 'rb') as f:
|
||||||
|
print(tomllib.load(f).get('name', ''))
|
||||||
|
" "$_first_toml" 2>/dev/null) || _pname=""
|
||||||
|
if [ -n "$_pname" ]; then
|
||||||
|
export PROJECT_NAME="$_pname"
|
||||||
|
export PROJECT_REPO_ROOT="/home/agent/repos/${_pname}"
|
||||||
|
log "Parsed PROJECT_NAME=${PROJECT_NAME} from ${_first_toml}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Clone project repo on first run (makes agents self-healing, #589)
|
# Clone project repo on first run (makes agents self-healing, #589)
|
||||||
ensure_project_clone
|
ensure_project_clone
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue