diff --git a/src/__tests__/main/agents/definitions.test.ts b/src/__tests__/main/agents/definitions.test.ts index 04f4e1a4..bfb0d935 100644 --- a/src/__tests__/main/agents/definitions.test.ts +++ b/src/__tests__/main/agents/definitions.test.ts @@ -70,10 +70,24 @@ describe('agent-definitions', () => { expect(opencode?.noPromptSeparator).toBe(true); }); - it('should have opencode with default env vars for YOLO mode', () => { + it('should have opencode with default env vars for YOLO mode and disabled question tool', () => { const opencode = AGENT_DEFINITIONS.find((def) => def.id === 'opencode'); expect(opencode?.defaultEnvVars).toBeDefined(); - expect(opencode?.defaultEnvVars?.OPENCODE_CONFIG_CONTENT).toContain('external_directory'); + const configContent = opencode?.defaultEnvVars?.OPENCODE_CONFIG_CONTENT; + expect(configContent).toBeDefined(); + + // Verify it's valid JSON + const config = JSON.parse(configContent!); + + // Should have permission settings for YOLO mode + expect(config.permission).toBeDefined(); + expect(config.permission['*']).toBe('allow'); + expect(config.permission.external_directory).toBe('allow'); + + // Should disable the question tool to prevent batch mode hangs + // The question tool waits for stdin input which causes hangs in batch mode + expect(config.tools).toBeDefined(); + expect(config.tools.question).toBe(false); }); }); diff --git a/src/main/agents/definitions.ts b/src/main/agents/definitions.ts index b0653551..6b893ab5 100644 --- a/src/main/agents/definitions.ts +++ b/src/main/agents/definitions.ts @@ -200,9 +200,11 @@ export const AGENT_DEFINITIONS: AgentDefinition[] = [ imageArgs: (imagePath: string) => ['-f', imagePath], // Image/file attachment: opencode run -f /path/to/image.png -- "prompt" noPromptSeparator: true, // OpenCode doesn't need '--' before prompt - yargs handles positional args // Default env vars: enable YOLO mode (allow all permissions including external_directory) + // Also disable the question tool - it waits for stdin input which hangs batch mode // Users can override by setting customEnvVars in agent config defaultEnvVars: { - OPENCODE_CONFIG_CONTENT: '{"permission":{"*":"allow","external_directory":"allow"}}', + OPENCODE_CONFIG_CONTENT: + '{"permission":{"*":"allow","external_directory":"allow"},"tools":{"question":false}}', }, // Agent-specific configuration options shown in UI configOptions: [