mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-01-30 06:12:06 +00:00
feat: add configurable CLI command and UI improvements
Add support for alternative CLI commands via CLI_COMMAND environment variable, allowing users to use CLIs other than 'claude' (e.g., 'glm'). This change affects all server services and the main CLI launcher. Key changes: - Configurable CLI command via CLI_COMMAND env var (defaults to 'claude') - Configurable Playwright headless mode via PLAYWRIGHT_HEADLESS env var - Pin claude-agent-sdk version to <0.2.0 for stability - Use tail -500 for progress notes to avoid context overflow - Add project delete functionality with confirmation dialog - Replace single-line input with resizable textarea in spec chat - Add coder agent configuration for code implementation tasks - Ignore issues/ directory in git Files modified: - client.py: CLI command and Playwright headless configuration - server/main.py, server/services/*: CLI command configuration - start.py: CLI command configuration and error messages - .env.example: Document new environment variables - .gitignore: Ignore issues/ directory - requirements.txt: Pin SDK version - .claude/templates/*: Use tail -500 for progress notes - ui/src/components/ProjectSelector.tsx: Add delete button - ui/src/components/SpecCreationChat.tsx: Auto-resizing textarea - ui/src/components/ConfirmDialog.tsx: New reusable dialog - .claude/agents/coder.md: New coder agent configuration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
50
client.py
50
client.py
@@ -13,9 +13,45 @@ from pathlib import Path
|
||||
|
||||
from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient
|
||||
from claude_agent_sdk.types import HookMatcher
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from security import bash_security_hook
|
||||
|
||||
# Load environment variables from .env file if present
|
||||
load_dotenv()
|
||||
|
||||
# Default CLI command - can be overridden via CLI_COMMAND environment variable
|
||||
# Common values: "claude" (default), "glm"
|
||||
DEFAULT_CLI_COMMAND = "claude"
|
||||
|
||||
# Default Playwright headless mode - can be overridden via PLAYWRIGHT_HEADLESS env var
|
||||
# When True, browser runs invisibly in background
|
||||
# When False, browser window is visible (default - useful for monitoring agent progress)
|
||||
DEFAULT_PLAYWRIGHT_HEADLESS = False
|
||||
|
||||
|
||||
def get_cli_command() -> str:
|
||||
"""
|
||||
Get the CLI command to use for the agent.
|
||||
|
||||
Reads from CLI_COMMAND environment variable, defaults to 'claude'.
|
||||
This allows users to use alternative CLIs like 'glm'.
|
||||
"""
|
||||
return os.getenv("CLI_COMMAND", DEFAULT_CLI_COMMAND)
|
||||
|
||||
|
||||
def get_playwright_headless() -> bool:
|
||||
"""
|
||||
Get the Playwright headless mode setting.
|
||||
|
||||
Reads from PLAYWRIGHT_HEADLESS environment variable, defaults to False.
|
||||
Returns True for headless mode (invisible browser), False for visible browser.
|
||||
"""
|
||||
value = os.getenv("PLAYWRIGHT_HEADLESS", "false").lower()
|
||||
# Accept various truthy/falsy values
|
||||
return value in ("true", "1", "yes", "on")
|
||||
|
||||
|
||||
# Feature MCP tools for feature/test management
|
||||
FEATURE_MCP_TOOLS = [
|
||||
"mcp__features__feature_get_stats",
|
||||
@@ -151,12 +187,14 @@ def create_client(project_dir: Path, model: str, yolo_mode: bool = False):
|
||||
print(" - Project settings enabled (skills, commands, CLAUDE.md)")
|
||||
print()
|
||||
|
||||
# Use system Claude CLI instead of bundled one (avoids Bun runtime crash on Windows)
|
||||
system_cli = shutil.which("claude")
|
||||
# Use system CLI instead of bundled one (avoids Bun runtime crash on Windows)
|
||||
# CLI command is configurable via CLI_COMMAND environment variable
|
||||
cli_command = get_cli_command()
|
||||
system_cli = shutil.which(cli_command)
|
||||
if system_cli:
|
||||
print(f" - Using system CLI: {system_cli}")
|
||||
else:
|
||||
print(" - Warning: System Claude CLI not found, using bundled CLI")
|
||||
print(f" - Warning: System CLI '{cli_command}' not found, using bundled CLI")
|
||||
|
||||
# Build MCP servers config - features is always included, playwright only in standard mode
|
||||
mcp_servers = {
|
||||
@@ -174,9 +212,13 @@ def create_client(project_dir: Path, model: str, yolo_mode: bool = False):
|
||||
}
|
||||
if not yolo_mode:
|
||||
# Include Playwright MCP server for browser automation (standard mode only)
|
||||
# Headless mode is configurable via PLAYWRIGHT_HEADLESS environment variable
|
||||
playwright_args = ["@playwright/mcp@latest", "--viewport-size", "1280x720"]
|
||||
if get_playwright_headless():
|
||||
playwright_args.append("--headless")
|
||||
mcp_servers["playwright"] = {
|
||||
"command": "npx",
|
||||
"args": ["@playwright/mcp@latest", "--viewport-size", "1280x720"],
|
||||
"args": playwright_args,
|
||||
}
|
||||
|
||||
return ClaudeSDKClient(
|
||||
|
||||
Reference in New Issue
Block a user