From 176d3964c93a52257be0f465c8e1f508cc7754a0 Mon Sep 17 00:00:00 2001 From: Pedram Amini Date: Tue, 16 Dec 2025 22:36:52 -0600 Subject: [PATCH] MAESTRO: Implement Phase 4 - Add OpenCode agent definition with argument builders Extended AgentConfig interface with new fields for dynamic CLI construction: - batchModePrefix: Args added before base args for batch mode (e.g., ['run']) - jsonOutputArgs: Args for JSON output format (e.g., ['--format', 'json']) - resumeArgs: Function to build resume args (e.g., ['--session', sessionId]) - readOnlyArgs: Args for read-only/plan mode (e.g., ['--agent', 'plan']) Updated OpenCode entry in AGENT_DEFINITIONS with all argument builders. Updated OpenCode capabilities based on verified investigation: - supportsImageInput: true (documented -f, --file flag) - supportsSessionStorage: true (~/.local/share/opencode/storage/) - supportsCostTracking: true (part.cost in events) --- src/main/agent-capabilities.ts | 28 ++++++++++++++-------------- src/main/agent-detector.ts | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/main/agent-capabilities.ts b/src/main/agent-capabilities.ts index fdcccbcb..2ff6e22c 100644 --- a/src/main/agent-capabilities.ts +++ b/src/main/agent-capabilities.ts @@ -186,22 +186,22 @@ export const AGENT_CAPABILITIES: Record = { * OpenCode - Open source coding assistant * https://github.com/opencode-ai/opencode * - * NOTE: Some capabilities marked as false may be supported but are unverified. - * Update this configuration after testing with the actual OpenCode CLI. + * Verified capabilities based on CLI testing and documentation review. + * See Auto Run Docs/OpenCode-Support.md for investigation details. */ 'opencode': { - supportsResume: true, // --session flag (sessionID in output) - supportsReadOnlyMode: true, // --agent plan (plan mode) - supportsJsonOutput: true, // --format json - supportsSessionId: true, // sessionID in JSON output - supportsImageInput: false, // Unverified - may be supported - supportsSlashCommands: false, // Unverified - may be supported - supportsSessionStorage: false, // Server-managed sessions - supportsCostTracking: false, // May not apply to local/self-hosted - supportsUsageStats: true, // part.tokens in output - supportsBatchMode: true, // run subcommand - supportsStreaming: true, // Streams JSON events - supportsResultMessages: true, // step_finish event type + supportsResume: true, // --session flag (sessionID in output) - Verified + supportsReadOnlyMode: true, // --agent plan (plan mode) - Verified + supportsJsonOutput: true, // --format json - Verified + supportsSessionId: true, // sessionID in JSON output (camelCase) - Verified + supportsImageInput: true, // -f, --file flag documented - Documented + supportsSlashCommands: false, // Not investigated + supportsSessionStorage: true, // ~/.local/share/opencode/storage/ (JSON files) - Verified + supportsCostTracking: true, // part.cost in step_finish events - Verified + supportsUsageStats: true, // part.tokens in step_finish events - Verified + supportsBatchMode: true, // run subcommand (auto-approves all permissions) - Verified + supportsStreaming: true, // Streams JSONL events - Verified + supportsResultMessages: true, // step_finish with part.reason:"stop" - Verified }, }; diff --git a/src/main/agent-detector.ts b/src/main/agent-detector.ts index 40264e19..081aa404 100644 --- a/src/main/agent-detector.ts +++ b/src/main/agent-detector.ts @@ -23,7 +23,7 @@ export interface AgentConfig { name: string; binaryName: string; command: string; - args: string[]; // Base args always included + args: string[]; // Base args always included (excludes batch mode prefix) available: boolean; path?: string; customPath?: string; // User-specified custom path (shown in UI even if not available) @@ -31,6 +31,13 @@ export interface AgentConfig { configOptions?: AgentConfigOption[]; // Agent-specific configuration hidden?: boolean; // If true, agent is hidden from UI (internal use only) capabilities: AgentCapabilities; // Agent feature capabilities + + // Argument builders for dynamic CLI construction + // These are optional - agents that don't have them use hardcoded behavior + batchModePrefix?: string[]; // Args added before base args for batch mode (e.g., ['run'] for OpenCode) + jsonOutputArgs?: string[]; // Args for JSON output format (e.g., ['--format', 'json']) + resumeArgs?: (sessionId: string) => string[]; // Function to build resume args + readOnlyArgs?: string[]; // Args for read-only/plan mode (e.g., ['--agent', 'plan']) } const AGENT_DEFINITIONS: Omit[] = [ @@ -77,7 +84,13 @@ const AGENT_DEFINITIONS: Omit] [--agent plan] "prompt" + batchModePrefix: ['run'], // OpenCode uses 'run' subcommand for batch mode + jsonOutputArgs: ['--format', 'json'], // JSON output format + resumeArgs: (sessionId: string) => ['--session', sessionId], // Resume with session ID + readOnlyArgs: ['--agent', 'plan'], // Read-only/plan mode }, ];