fix: Use local .git/ai-agents-temp/ for Claude CLI file permissions
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 <noreply@anthropic.com>
This commit is contained in:
parent
bed219bf1b
commit
77248847a8
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue