opencode-aicodewith-auth 0.1.29 → 0.1.31

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.
Files changed (2) hide show
  1. package/dist/index.js +58 -58
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1547,34 +1547,23 @@ import path4 from "path";
1547
1547
  import os3 from "os";
1548
1548
  var PACKAGE_NAME2 = "opencode-aicodewith-auth";
1549
1549
  var OMO_CONFIG_FILENAME = "oh-my-opencode.json";
1550
- var DEFAULT_MODEL = `${PROVIDER_ID}/claude-sonnet-4-5-20250929`;
1551
- var mapModelToAicodewith = (model) => {
1552
- if (model.startsWith(`${PROVIDER_ID}/`)) {
1553
- return model;
1554
- }
1555
- const lowerModel = model.toLowerCase();
1556
- if (lowerModel.includes("codex")) {
1557
- return `${PROVIDER_ID}/gpt-5.2-codex`;
1558
- }
1559
- if (lowerModel.includes("claude-opus") || lowerModel.includes("claude_opus")) {
1560
- return `${PROVIDER_ID}/claude-opus-4-5-20251101`;
1561
- }
1562
- if (lowerModel.includes("claude-sonnet") || lowerModel.includes("claude_sonnet")) {
1563
- return `${PROVIDER_ID}/claude-sonnet-4-5-20250929`;
1564
- }
1565
- if (lowerModel.includes("claude-haiku") || lowerModel.includes("claude_haiku")) {
1566
- return `${PROVIDER_ID}/claude-sonnet-4-5-20250929`;
1567
- }
1568
- if (lowerModel.includes("claude")) {
1569
- return `${PROVIDER_ID}/claude-sonnet-4-5-20250929`;
1570
- }
1571
- if (lowerModel.includes("gpt-") || lowerModel.includes("gpt_") || lowerModel.startsWith("openai/")) {
1572
- return `${PROVIDER_ID}/gpt-5.2`;
1573
- }
1574
- if (lowerModel.includes("gemini") || lowerModel.startsWith("google/")) {
1575
- return `${PROVIDER_ID}/gemini-3-pro`;
1550
+ var DEFAULT_CONFIG_URL = "https://raw.githubusercontent.com/DaneelOlivaw1/opencode-aicodewith-auth/main/assets/default-omo-config.json";
1551
+ var FETCH_TIMEOUT_MS = 5000;
1552
+ var fetchDefaultConfig = async () => {
1553
+ try {
1554
+ const controller = new AbortController;
1555
+ const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
1556
+ const response = await fetch(DEFAULT_CONFIG_URL, {
1557
+ signal: controller.signal
1558
+ });
1559
+ clearTimeout(timeoutId);
1560
+ if (!response.ok) {
1561
+ return null;
1562
+ }
1563
+ return await response.json();
1564
+ } catch {
1565
+ return null;
1576
1566
  }
1577
- return DEFAULT_MODEL;
1578
1567
  };
1579
1568
  var fileExists = async (filePath) => {
1580
1569
  try {
@@ -1589,49 +1578,60 @@ var getOmoConfigPath = () => {
1589
1578
  const configRoot = process.env.XDG_CONFIG_HOME || path4.join(homeDir, ".config");
1590
1579
  return path4.join(configRoot, "opencode", OMO_CONFIG_FILENAME);
1591
1580
  };
1592
- var syncOmoConfig = async () => {
1593
- const configPath = getOmoConfigPath();
1594
- if (!await fileExists(configPath)) {
1595
- return;
1596
- }
1597
- let config;
1598
- try {
1599
- const content = await readFile2(configPath, "utf-8");
1600
- config = JSON.parse(content);
1601
- } catch {
1602
- return;
1581
+ var syncAgentsAndCategories = (userConfig, defaultConfig) => {
1582
+ let changed = false;
1583
+ if (!userConfig.agents) {
1584
+ userConfig.agents = {};
1603
1585
  }
1604
- if (!config || typeof config !== "object") {
1605
- return;
1586
+ if (!userConfig.categories) {
1587
+ userConfig.categories = {};
1606
1588
  }
1607
- let changed = false;
1608
- if (config.agents && typeof config.agents === "object") {
1609
- for (const [_agentName, agentConfig] of Object.entries(config.agents)) {
1610
- if (agentConfig.model && !agentConfig.model.startsWith(`${PROVIDER_ID}/`)) {
1611
- const mappedModel = mapModelToAicodewith(agentConfig.model);
1612
- if (mappedModel !== agentConfig.model) {
1613
- agentConfig.model = mappedModel;
1614
- changed = true;
1615
- }
1589
+ if (defaultConfig.agents) {
1590
+ for (const [name, defaultAgent] of Object.entries(defaultConfig.agents)) {
1591
+ if (!userConfig.agents[name] && defaultAgent.model) {
1592
+ userConfig.agents[name] = { model: defaultAgent.model };
1593
+ changed = true;
1616
1594
  }
1617
1595
  }
1618
1596
  }
1619
- if (config.categories && typeof config.categories === "object") {
1620
- for (const [_categoryName, categoryConfig] of Object.entries(config.categories)) {
1621
- if (categoryConfig.model && !categoryConfig.model.startsWith(`${PROVIDER_ID}/`)) {
1622
- const mappedModel = mapModelToAicodewith(categoryConfig.model);
1623
- if (mappedModel !== categoryConfig.model) {
1624
- categoryConfig.model = mappedModel;
1625
- changed = true;
1626
- }
1597
+ if (defaultConfig.categories) {
1598
+ for (const [name, defaultCategory] of Object.entries(defaultConfig.categories)) {
1599
+ if (!userConfig.categories[name] && defaultCategory.model) {
1600
+ userConfig.categories[name] = { model: defaultCategory.model };
1601
+ changed = true;
1627
1602
  }
1628
1603
  }
1629
1604
  }
1605
+ return changed;
1606
+ };
1607
+ var syncOmoConfig = async () => {
1608
+ const defaultConfig = await fetchDefaultConfig();
1609
+ if (!defaultConfig) {
1610
+ return;
1611
+ }
1612
+ const configPath = getOmoConfigPath();
1613
+ let userConfig;
1614
+ if (!await fileExists(configPath)) {
1615
+ userConfig = {
1616
+ $schema: "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json"
1617
+ };
1618
+ } else {
1619
+ try {
1620
+ const content = await readFile2(configPath, "utf-8");
1621
+ userConfig = JSON.parse(content);
1622
+ } catch {
1623
+ return;
1624
+ }
1625
+ }
1626
+ if (!userConfig || typeof userConfig !== "object") {
1627
+ return;
1628
+ }
1629
+ const changed = syncAgentsAndCategories(userConfig, defaultConfig);
1630
1630
  if (!changed) {
1631
1631
  return;
1632
1632
  }
1633
1633
  try {
1634
- await writeFile2(configPath, `${JSON.stringify(config, null, 2)}
1634
+ await writeFile2(configPath, `${JSON.stringify(userConfig, null, 2)}
1635
1635
  `, "utf-8");
1636
1636
  } catch (error) {
1637
1637
  console.warn(`[${PACKAGE_NAME2}] Failed to sync OMO config: ${error instanceof Error ? error.message : error}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-aicodewith-auth",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "OpenCode plugin for AICodewith authentication - Access GPT-5.2, Claude, and Gemini models through AICodewith API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",