Vision-based auto-approval system for Claude Code CLI using MiniCPM-V vision model. Features: - Automatic detection and response to approval prompts - Screenshot capture and vision analysis via Ollama - Support for multiple screenshot tools (scrot, gnome-screenshot, etc.) - Configurable timing and behavior - Debug mode for troubleshooting - Comprehensive documentation Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Jean-Philippe Brule <jp@svrnty.io>
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
"""
|
|
Configuration for Claude Vision Auto
|
|
"""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Ollama configuration
|
|
OLLAMA_URL = os.getenv("OLLAMA_URL", "http://localhost:11434/api/generate")
|
|
VISION_MODEL = os.getenv("VISION_MODEL", "minicpm-v:latest")
|
|
|
|
# Timing configuration
|
|
IDLE_THRESHOLD = float(os.getenv("IDLE_THRESHOLD", "3.0")) # seconds of no output before screenshot
|
|
RESPONSE_DELAY = float(os.getenv("RESPONSE_DELAY", "1.0")) # seconds to wait before sending response
|
|
|
|
# Buffer configuration
|
|
OUTPUT_BUFFER_SIZE = int(os.getenv("OUTPUT_BUFFER_SIZE", "4096")) # bytes
|
|
|
|
# Keywords that suggest we're waiting for approval
|
|
APPROVAL_KEYWORDS = [
|
|
"Yes",
|
|
"No",
|
|
"(y/n)",
|
|
"[y/n]",
|
|
"Approve",
|
|
"Do you want to",
|
|
"create",
|
|
"edit",
|
|
"delete"
|
|
]
|
|
|
|
# Screenshot configuration
|
|
SCREENSHOT_TIMEOUT = int(os.getenv("SCREENSHOT_TIMEOUT", "5")) # seconds
|
|
SCREENSHOT_TOOLS = ["scrot", "gnome-screenshot", "import", "maim"]
|
|
|
|
# Vision analysis timeout
|
|
VISION_TIMEOUT = int(os.getenv("VISION_TIMEOUT", "30")) # seconds
|
|
|
|
# Debug mode
|
|
DEBUG = os.getenv("DEBUG", "false").lower() in ("true", "1", "yes")
|
|
|
|
def get_cache_dir() -> Path:
|
|
"""Get cache directory for screenshots"""
|
|
cache_dir = Path.home() / ".cache" / "claude-vision-auto"
|
|
cache_dir.mkdir(parents=True, exist_ok=True)
|
|
return cache_dir
|