From 77248847a8da5e6d5a2316802d4956c5d1257463 Mon Sep 17 00:00:00 2001 From: rob Date: Sat, 1 Nov 2025 03:41:14 -0300 Subject: [PATCH] fix: Use local .git/ai-agents-temp/ for Claude CLI file permissions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed temp file location from /tmp to .git/ai-agents-temp/ to resolve Claude CLI permission errors when reading discussion content. Problem: - agents.py created temp files in /tmp/tmp*.md - Asked Claude CLI to read these files - Claude CLI couldn't access /tmp without explicit permission grant - Error: "I don't have permission to read that file" - Fell back to basic pattern matching (degraded functionality) Solution: - Create temp files in .git/ai-agents-temp/ directory - Claude CLI has permission to read files in the project directory - Use PID for unique filenames to avoid conflicts - Cleanup still handled by finally block Benefits: - No user configuration needed - Claude CLI can now read discussion files - AI agents work properly for structured extraction - Temp files automatically gitignored (.git/ directory) - Easy debugging (files visible in project) The finally block at line 154-158 still cleans up temp files after use. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- automation/agents.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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