@x-all-in-one/coding-helper 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,9 +13,6 @@ export declare class OhMyOpenCodePlugin implements IPlugin {
13
13
  * 通过检查配置文件或 plugin 数组来判断
14
14
  */
15
15
  isInstalled(): boolean;
16
- /**
17
- * 安装 Oh My OpenCode
18
- */
19
16
  install(): Promise<void>;
20
17
  /**
21
18
  * 装载 Oh My OpenCode(添加到 OpenCode 配置)
@@ -27,34 +27,26 @@ export class OhMyOpenCodePlugin {
27
27
  // 或者检查是否已在 opencode.json 的 plugin 数组中
28
28
  return this.isLoaded();
29
29
  }
30
- /**
31
- * 安装 Oh My OpenCode
32
- */
33
30
  async install() {
34
- // 使用 bunInstaller 确保 Bun 已安装
35
31
  const hasBun = await bunInstaller.ensureBun();
36
32
  if (!hasBun) {
37
33
  throw new Error('Bun is required for Oh My OpenCode. Please install bun first.');
38
34
  }
39
35
  const isWindows = process.platform === 'win32';
40
- const command = isWindows ? 'bunx.cmd' : 'bunx';
41
- const args = ['oh-my-opencode', 'install', '--no-tui', '--claude=no', '--chatgpt=no', '--gemini=no'];
36
+ const bunxCommand = isWindows ? 'bunx.cmd' : 'bunx';
42
37
  return new Promise((resolve, reject) => {
43
- const child = spawn(command, args, {
38
+ const args = ['oh-my-opencode@latest', 'install', '--no-tui', '--claude=no', '--openai=no', '--gemini=no', '--copilot=no'];
39
+ const child = spawn(bunxCommand, args, {
44
40
  stdio: 'inherit',
45
41
  shell: true,
46
42
  });
47
43
  child.on('close', (code) => {
48
- if (code === 0) {
44
+ if (code === 0)
49
45
  resolve();
50
- }
51
- else {
46
+ else
52
47
  reject(new Error(`Oh My OpenCode install failed with code ${code}`));
53
- }
54
- });
55
- child.on('error', (error) => {
56
- reject(error);
57
48
  });
49
+ child.on('error', reject);
58
50
  });
59
51
  }
60
52
  /**
@@ -7,6 +7,10 @@ export interface OhMyOpenCodeConfig {
7
7
  model?: string;
8
8
  [key: string]: any;
9
9
  }>;
10
+ categories?: Record<string, {
11
+ model?: string;
12
+ [key: string]: any;
13
+ }>;
10
14
  [key: string]: any;
11
15
  }
12
16
  export declare const OPENCODE_DEFAULT_CONFIG: {
@@ -123,9 +127,11 @@ export declare class OpenCodeTool extends BaseTool {
123
127
  * Save oh-my-opencode config
124
128
  */
125
129
  saveOhMyOpenCodeConfig(config: OhMyOpenCodeConfig): void;
130
+ private updateOhMyOpenCodeAgents;
131
+ private updateOhMyOpenCodeCategories;
126
132
  /**
127
- * Update oh-my-opencode agent models
128
- * Only updates the model field, preserves other agent configurations
133
+ * Update oh-my-opencode agent and category models
134
+ * Only updates the model field, preserves other configurations
129
135
  */
130
136
  updateOhMyOpenCodeModels(model: string): void;
131
137
  /**
@@ -7,17 +7,28 @@ import { modelService } from '../model-service.js';
7
7
  import { BaseTool } from './base-tool.js';
8
8
  // X-AIO Provider ID
9
9
  const XAIO_PROVIDER_ID = 'xaio';
10
- // oh-my-opencode agent names
10
+ // oh-my-opencode agent names (latest version)
11
11
  const OH_MY_OPENCODE_AGENTS = [
12
- 'Sisyphus',
12
+ 'sisyphus',
13
+ 'oracle',
13
14
  'librarian',
14
15
  'explore',
15
- 'oracle',
16
- 'frontend-ui-ux-engineer',
17
- 'document-writer',
18
16
  'multimodal-looker',
17
+ 'prometheus',
18
+ 'metis',
19
+ 'momus',
19
20
  'atlas',
20
21
  ];
22
+ // oh-my-opencode category names
23
+ const OH_MY_OPENCODE_CATEGORIES = [
24
+ 'visual-engineering',
25
+ 'ultrabrain',
26
+ 'artistry',
27
+ 'quick',
28
+ 'unspecified-low',
29
+ 'unspecified-high',
30
+ 'writing',
31
+ ];
21
32
  // Unified output token limit for all models
22
33
  const OUTPUT_TOKEN_LIMIT = 32000;
23
34
  // Model tag constants
@@ -322,30 +333,41 @@ export class OpenCodeTool extends BaseTool {
322
333
  throw new Error(`Failed to save oh-my-opencode config: ${error}`);
323
334
  }
324
335
  }
325
- /**
326
- * Update oh-my-opencode agent models
327
- * Only updates the model field, preserves other agent configurations
328
- */
329
- updateOhMyOpenCodeModels(model) {
330
- const prefixedModel = `${XAIO_PROVIDER_ID}/${model}`;
331
- // Read existing config or create new one
332
- const currentConfig = this.getOhMyOpenCodeConfig();
333
- // Initialize agents if not exists
334
- if (!currentConfig.agents) {
335
- currentConfig.agents = {};
336
+ updateOhMyOpenCodeAgents(config, model) {
337
+ if (!config.agents) {
338
+ config.agents = {};
336
339
  }
337
- // Update each agent's model, preserving other settings
338
340
  for (const agentName of OH_MY_OPENCODE_AGENTS) {
339
- if (currentConfig.agents[agentName]) {
340
- // Agent exists, only update model
341
- currentConfig.agents[agentName].model = prefixedModel;
341
+ if (config.agents[agentName]) {
342
+ config.agents[agentName].model = model;
343
+ }
344
+ else {
345
+ config.agents[agentName] = { model };
346
+ }
347
+ }
348
+ }
349
+ updateOhMyOpenCodeCategories(config, model) {
350
+ if (!config.categories) {
351
+ config.categories = {};
352
+ }
353
+ for (const categoryName of OH_MY_OPENCODE_CATEGORIES) {
354
+ if (config.categories[categoryName]) {
355
+ config.categories[categoryName].model = model;
342
356
  }
343
357
  else {
344
- // Agent doesn't exist, create with only model
345
- currentConfig.agents[agentName] = { model: prefixedModel };
358
+ config.categories[categoryName] = { model };
346
359
  }
347
360
  }
348
- // Ensure schema is set
361
+ }
362
+ /**
363
+ * Update oh-my-opencode agent and category models
364
+ * Only updates the model field, preserves other configurations
365
+ */
366
+ updateOhMyOpenCodeModels(model) {
367
+ const prefixedModel = `${XAIO_PROVIDER_ID}/${model}`;
368
+ const currentConfig = this.getOhMyOpenCodeConfig();
369
+ this.updateOhMyOpenCodeAgents(currentConfig, prefixedModel);
370
+ this.updateOhMyOpenCodeCategories(currentConfig, prefixedModel);
349
371
  if (!currentConfig.$schema) {
350
372
  currentConfig.$schema = 'https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json';
351
373
  }
@@ -3,6 +3,7 @@ import inquirer from 'inquirer';
3
3
  import ora from 'ora';
4
4
  import { i18n } from '../../i18n.js';
5
5
  import { modelService } from '../../model-service.js';
6
+ import { openCodeTool } from '../../tools/opencode-tool.js';
6
7
  import { promptHelper } from '../ui/prompt-helper.js';
7
8
  import { uiRenderer } from '../ui/ui-renderer.js';
8
9
  /**
@@ -115,6 +116,10 @@ export class PluginMenu {
115
116
  }).start();
116
117
  const result = await modelService.refreshAndSyncToOpenCode();
117
118
  if (result.success) {
119
+ const modelConfig = openCodeTool.getModelConfig();
120
+ if (modelConfig?.model) {
121
+ openCodeTool.updateOhMyOpenCodeModels(modelConfig.model);
122
+ }
118
123
  spinner.succeed(chalk.green(i18n.t('wizard.models_refreshed', { count: String(result.count) })));
119
124
  }
120
125
  else {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@x-all-in-one/coding-helper",
3
3
  "type": "module",
4
- "version": "0.4.5",
4
+ "version": "0.4.6",
5
5
  "description": "X All In One Coding Helper",
6
6
  "author": "X.AIO",
7
7
  "homepage": "https://docs.x-aio.com/zh/docs",