diff --git a/automation/agents.py b/automation/agents.py index 9e070a2..ae891ea 100644 --- a/automation/agents.py +++ b/automation/agents.py @@ -80,17 +80,22 @@ def call_ai_cli(prompt: str, content: str) -> dict[str, Any] | None: Call AI via CLI command (claude, gemini, codex, etc.). The command template can use {prompt} and {content} placeholders. - Content is passed via a temporary file to avoid shell escaping issues. + Content is passed via a temporary file in .git/ai-agents-temp/ to avoid + shell escaping issues while remaining accessible to Claude CLI. Returns parsed JSON response or None on failure. """ config = get_ai_config() command_template = config["command"] - # Create temporary file with content - with tempfile.NamedTemporaryFile(mode='w', suffix='.md', delete=False) as f: - content_file = Path(f.name) - f.write(content) + # Create temporary file in .git/ai-agents-temp/ (accessible to Claude CLI) + # Using .git/ ensures it's gitignored and Claude has permission + temp_dir = Path.cwd() / ".git" / "ai-agents-temp" + temp_dir.mkdir(parents=True, exist_ok=True) + + # Use PID for unique filename to avoid conflicts + content_file = temp_dir / f"discussion-{os.getpid()}.md" + content_file.write_text(content, encoding='utf-8') try: # Build full prompt