From e9224712292aabd598e163398556045879806412 Mon Sep 17 00:00:00 2001 From: Mathias Bergqvist Date: Sat, 2 May 2026 22:55:43 +0200 Subject: [PATCH] fix(context-sync): short-circuit when root AGENT.md is unreachable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In CI's clean checkout the tree-walk for ~/dev/.context/AGENT.md finds nothing, leaving ROOT_CONTEXT empty. The script previously proceeded to regenerate AGENTS.md, .cursorrules, .aider.conventions.md, and .context/system-prompt.txt as project-only — but the committed versions are root+project, so the drift gate added in cc401d9 fails CI on every push. When no root context is reachable, only regenerate CLAUDE.md (which is project-only by design — Claude Code walks up the tree itself to find the root). The root-bearing adapters are left untouched, eliminating the false-positive drift. Local runs (with root context reachable) are unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) --- scripts/context-sync.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/context-sync.sh b/scripts/context-sync.sh index a3f9468..bdf38ee 100755 --- a/scripts/context-sync.sh +++ b/scripts/context-sync.sh @@ -39,7 +39,17 @@ fi if [ -n "$ROOT_CONTEXT" ] && [ -f "$ROOT_CONTEXT" ]; then echo " Root context: $ROOT_CONTEXT" else - echo " No root AGENT.md found (project context only)" + # No reachable root AGENT.md — common in CI's clean checkout. The root+project + # adapters (AGENTS.md, .cursorrules, .aider.conventions.md, system-prompt.txt) + # require the root context to regenerate correctly, so we skip them entirely + # and only regenerate CLAUDE.md (which is project-only and inherits root via + # tree walk in Claude Code itself). + echo " No root AGENT.md found — regenerating CLAUDE.md only" + echo "Syncing project context from $PROJECT_FILE..." + cat "$PROJECT_FILE" > CLAUDE.md + echo " → CLAUDE.md (project-only)" + echo "Done." + exit 0 fi # Emit root context + separator