From c80631fc1d6ef5c2507f8b9495243e7e21b9df79 Mon Sep 17 00:00:00 2001 From: Lidang-Jiang Date: Sat, 28 Mar 2026 09:54:35 +0800 Subject: [PATCH] fix(observer): improve Windows compatibility for temp files and Haiku prompt Address remaining issues from #842 after PR #903 moved temp files to PROJECT_DIR/.observer-tmp: Bug A (path resolution): Use relative paths (.observer-tmp/filename) in the prompt instead of absolute paths from mktemp. On Windows Git Bash/MSYS2, absolute paths use MSYS-style prefixes (/c/Users/...) that the spawned Claude subprocess may fail to resolve. Bug B (asks for permission): Add explicit IMPORTANT instruction block at the prompt start telling the Haiku agent it is in non-interactive --print mode and must use the Write tool directly without asking for confirmation. Additional improvements: - Pass prompt via -p flag instead of stdin redirect for Windows compat - Add .observer-tmp/ to .gitignore to prevent accidental commits Fixes #842 Co-Authored-By: Claude Opus 4.6 Signed-off-by: Lidang-Jiang --- .gitignore | 3 +++ .../continuous-learning-v2/agents/observer-loop.sh | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 68de41d1..88c7755a 100644 --- a/.gitignore +++ b/.gitignore @@ -83,6 +83,9 @@ temp/ *.bak *.backup +# Observer temp files (continuous-learning-v2) +.observer-tmp/ + # Rust build artifacts ecc2/target/ diff --git a/skills/continuous-learning-v2/agents/observer-loop.sh b/skills/continuous-learning-v2/agents/observer-loop.sh index c8d02470..e4eb0972 100755 --- a/skills/continuous-learning-v2/agents/observer-loop.sh +++ b/skills/continuous-learning-v2/agents/observer-loop.sh @@ -62,9 +62,16 @@ analyze_observations() { analysis_count=$(wc -l < "$analysis_file" 2>/dev/null || echo 0) echo "[$(date)] Using last $analysis_count of $obs_count observations for analysis" >> "$LOG_FILE" + # Use relative path from PROJECT_DIR for cross-platform compatibility (#842). + # On Windows (Git Bash/MSYS2), absolute paths from mktemp may use MSYS-style + # prefixes (e.g. /c/Users/...) that the Claude subprocess cannot resolve. + analysis_relpath=".observer-tmp/$(basename "$analysis_file")" + prompt_file="$(mktemp "${observer_tmp_dir}/ecc-observer-prompt.XXXXXX")" cat > "$prompt_file" <.md using the Write tool. Do NOT ask for permission to write files, do NOT describe what you would write, and do NOT stop at analysis when a qualifying pattern exists. @@ -117,10 +124,11 @@ PROMPT max_turns=10 fi - # Prevent observe.sh from recording this automated Haiku session as observations + # Prevent observe.sh from recording this automated Haiku session as observations. + # Pass prompt via -p flag instead of stdin redirect for Windows compatibility (#842). ECC_SKIP_OBSERVE=1 ECC_HOOK_PROFILE=minimal claude --model haiku --max-turns "$max_turns" --print \ --allowedTools "Read,Write" \ - < "$prompt_file" >> "$LOG_FILE" 2>&1 & + -p "$(cat "$prompt_file")" >> "$LOG_FILE" 2>&1 & claude_pid=$! (