fix(config): resolve wrapper env from repo root and warn on deprecated .env

This commit is contained in:
2026-08-04 21:42:49 +09:00
parent 2458995e75
commit 62dcbb1361
@@ -16,11 +16,26 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Load local .env if it exists in current dir or workspace root # Load local env file (.mam.env preferred, .env fallback) from workspace root or explicit MAM_ENV_FILE
if [[ -f .env ]]; then REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
set -a; source .env; set +a TARGET_ENV="${MAM_ENV_FILE:-}"
elif [[ -f "$SCRIPT_DIR/../../.env" ]]; then if [[ -z "$TARGET_ENV" ]]; then
set -a; source "$SCRIPT_DIR/../../.env"; set +a if [[ -f "$REPO_ROOT/.mam.env" ]]; then
TARGET_ENV="$REPO_ROOT/.mam.env"
elif [[ -f "$REPO_ROOT/.env" ]]; then
TARGET_ENV="$REPO_ROOT/.env"
echo "WARNING: Loading deprecated config file '$TARGET_ENV'. Please migrate to '.mam.env'." >&2
elif [[ -f .mam.env ]]; then
TARGET_ENV=".mam.env"
echo "WARNING: Loading config from cwd relative path '$TARGET_ENV'." >&2
elif [[ -f .env ]]; then
TARGET_ENV=".env"
echo "WARNING: Loading deprecated config from cwd relative path '$TARGET_ENV'. Please migrate to '.mam.env'." >&2
fi
fi
if [[ -n "$TARGET_ENV" && -f "$TARGET_ENV" ]]; then
set -a; source "$TARGET_ENV"; set +a
fi fi
# Source EARLY (before any herdr usage in run_agent) — this is what turns # Source EARLY (before any herdr usage in run_agent) — this is what turns