oh-my-opencode-cohub 1.10.3 → 1.11.0

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.
package/dist/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // package.json
3
- var version = "1.10.3";
3
+ var version = "1.11.0";
4
4
 
5
5
  // src/cli/config-io.ts
6
6
  import * as fs from "node:fs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAyIlD,QAAA,MAAM,WAAW,EAAE,MAmclB,CAAC;AAEF,eAAO,MAAM,MAAM,QAAc,CAAC;AAClC,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAiMlD,QAAA,MAAM,WAAW,EAAE,MAsclB,CAAC;AAEF,eAAO,MAAM,MAAM,QAAc,CAAC;AAClC,eAAe,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1561,6 +1561,50 @@ function createCouncilTool(ctx, councilManager) {
1561
1561
  import * as fs3 from "node:fs";
1562
1562
  import * as path3 from "node:path";
1563
1563
  import * as os3 from "node:os";
1564
+ function syncAgentConfigToOpencode(userConfig) {
1565
+ const agents = userConfig.agents;
1566
+ if (!agents)
1567
+ return;
1568
+ const opencodePath = path3.join(os3.homedir(), ".config", "opencode", "opencode.json");
1569
+ let opencodeConfig;
1570
+ try {
1571
+ if (!fs3.existsSync(opencodePath))
1572
+ return;
1573
+ const raw = fs3.readFileSync(opencodePath, "utf-8");
1574
+ opencodeConfig = JSON.parse(raw);
1575
+ } catch (err) {
1576
+ appendLog("sync", "opencode.json 读取或解析失败,跳过同步", err);
1577
+ return;
1578
+ }
1579
+ const agentSection = opencodeConfig.agent;
1580
+ if (!agentSection)
1581
+ return;
1582
+ let changed = false;
1583
+ for (const [agentName, override] of Object.entries(agents)) {
1584
+ const agentEntry = agentSection[agentName];
1585
+ if (!agentEntry || typeof agentEntry !== "object" || Array.isArray(agentEntry))
1586
+ continue;
1587
+ if (override.model && agentEntry.model !== override.model) {
1588
+ agentEntry.model = override.model;
1589
+ changed = true;
1590
+ }
1591
+ if (override.variant && agentEntry.variant !== override.variant) {
1592
+ agentEntry.variant = override.variant;
1593
+ changed = true;
1594
+ }
1595
+ }
1596
+ if (changed) {
1597
+ try {
1598
+ const tmpPath = opencodePath + ".tmp";
1599
+ fs3.writeFileSync(tmpPath, JSON.stringify(opencodeConfig, null, 2) + `
1600
+ `);
1601
+ fs3.renameSync(tmpPath, opencodePath);
1602
+ appendLog("sync", "已将 oh-my-opencode-cohub.json 的 agent model/variant 同步到 opencode.json", null);
1603
+ } catch (err) {
1604
+ appendLog("sync", "同步 opencode.json 失败", err);
1605
+ }
1606
+ }
1607
+ }
1564
1608
  function loadFileOverrides(projectDir) {
1565
1609
  const overrides = {};
1566
1610
  const agentNames = [
@@ -1741,6 +1785,7 @@ var CoHubPlugin = async (input, options) => {
1741
1785
  }
1742
1786
  }
1743
1787
  }
1788
+ syncAgentConfigToOpencode(userConfig);
1744
1789
  for (const agent of agents) {
1745
1790
  const override = fileOverrides[agent.name];
1746
1791
  if (override) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-opencode-cohub",
3
- "version": "1.10.3",
3
+ "version": "1.11.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Mr-cjf/oh-my-opencode-cohub.git"