From 820ffafd0f9abc39b18c4875dba22ef91a46894c Mon Sep 17 00:00:00 2001 From: Agent Date: Thu, 16 Apr 2026 11:42:48 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20bug:=20entrypoint=20clones=20project=20a?= =?UTF-8?q?t=20/home/agent/repos/${COMPOSE=5FPROJECT=5FNAME}=20but=20TOML?= =?UTF-8?q?=20parse=20later=20rewrites=20PROJECT=5FREPO=5FROOT=20=E2=80=94?= =?UTF-8?q?=20dev-agent=20`cd`=20fails=20silently=20(#861)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev/dev-agent.sh | 6 +++++- docker/agents/entrypoint.sh | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/dev/dev-agent.sh b/dev/dev-agent.sh index cd8d390..913a2a7 100755 --- a/dev/dev-agent.sh +++ b/dev/dev-agent.sh @@ -254,7 +254,11 @@ agent_recover_session # WORKTREE SETUP # ============================================================================= 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 _forge_host=$(printf '%s' "$FORGE_URL" | sed 's|https\?://||; s|/.*||') diff --git a/docker/agents/entrypoint.sh b/docker/agents/entrypoint.sh index b7593a2..a664a09 100644 --- a/docker/agents/entrypoint.sh +++ b/docker/agents/entrypoint.sh @@ -315,6 +315,24 @@ _setup_git_creds configure_git_identity 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/ +# 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) ensure_project_clone -- 2.49.1