feat: 添加对 OpenCode 的支持,更新 CLI 工具配置和会话发现逻辑

This commit is contained in:
catlog22
2026-01-08 10:47:07 +08:00
parent d2d6cce5f4
commit 55fa170b4e
7 changed files with 223 additions and 104 deletions

View File

@@ -96,7 +96,7 @@ import {
// Define Zod schema for validation
const ParamsSchema = z.object({
tool: z.enum(['gemini', 'qwen', 'codex']),
tool: z.enum(['gemini', 'qwen', 'codex', 'opencode']),
prompt: z.string().min(1, 'Prompt is required'),
mode: z.enum(['analysis', 'write', 'auto']).default('analysis'),
format: z.enum(['plain', 'yaml', 'json']).default('plain'), // Multi-turn prompt concatenation format
@@ -808,7 +808,7 @@ export {
* Get status of all CLI tools
*/
export async function getCliToolsStatus(): Promise<Record<string, ToolAvailability>> {
const tools = ['gemini', 'qwen', 'codex', 'claude'];
const tools = ['gemini', 'qwen', 'codex', 'claude', 'opencode'];
const results: Record<string, ToolAvailability> = {};
await Promise.all(tools.map(async (tool) => {
@@ -823,7 +823,8 @@ const CLI_TOOL_PACKAGES: Record<string, string> = {
gemini: '@google/gemini-cli',
qwen: '@qwen-code/qwen-code',
codex: '@openai/codex',
claude: '@anthropic-ai/claude-code'
claude: '@anthropic-ai/claude-code',
opencode: 'opencode' // https://opencode.ai - installed via npm/pnpm/bun/brew
};
// Disabled tools storage (in-memory fallback, main storage is in cli-config.json)