opencode-aicodewith-auth 0.1.27 → 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 +59 -77
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1545,48 +1545,26 @@ Restart OpenCode to apply.`,
1545
1545
  import { readFile as readFile2, writeFile as writeFile2, access } from "fs/promises";
1546
1546
  import path4 from "path";
1547
1547
  import os3 from "os";
1548
-
1549
- // lib/hooks/omo-config-sync/constants.ts
1550
- var AGENT_MODEL_MAP = {
1551
- sisyphus: `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1552
- prometheus: `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1553
- metis: `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1554
- "OpenCode-Builder": `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1555
- build: `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1556
- plan: `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1557
- oracle: `${PROVIDER_ID}/gpt-5.2`,
1558
- momus: `${PROVIDER_ID}/gpt-5.2`,
1559
- librarian: `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1560
- atlas: `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1561
- "sisyphus-junior": `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1562
- general: `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1563
- explore: `${PROVIDER_ID}/gemini-3-pro`,
1564
- "multimodal-looker": `${PROVIDER_ID}/gemini-3-pro`,
1565
- "frontend-ui-ux-engineer": `${PROVIDER_ID}/gemini-3-pro`,
1566
- "document-writer": `${PROVIDER_ID}/gemini-3-pro`
1567
- };
1568
- var CATEGORY_MODEL_MAP = {
1569
- "visual-engineering": `${PROVIDER_ID}/gemini-3-pro`,
1570
- visual: `${PROVIDER_ID}/gemini-3-pro`,
1571
- ultrabrain: `${PROVIDER_ID}/gpt-5.2`,
1572
- artistry: `${PROVIDER_ID}/gemini-3-pro`,
1573
- quick: `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1574
- "unspecified-low": `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1575
- "unspecified-high": `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1576
- writing: `${PROVIDER_ID}/gemini-3-pro`,
1577
- "business-logic": `${PROVIDER_ID}/gpt-5.2`,
1578
- "data-analysis": `${PROVIDER_ID}/claude-sonnet-4-5-20250929`
1579
- };
1580
- var DEFAULT_MODEL = `${PROVIDER_ID}/claude-sonnet-4-5-20250929`;
1581
- var DEFAULT_CONFIG = {
1582
- $schema: "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json",
1583
- agents: Object.fromEntries(Object.entries(AGENT_MODEL_MAP).map(([name, model]) => [name, { model }])),
1584
- categories: Object.fromEntries(Object.entries(CATEGORY_MODEL_MAP).map(([name, model]) => [name, { model }]))
1585
- };
1586
- var OMO_CONFIG_FILENAME = "oh-my-opencode.json";
1587
-
1588
- // lib/hooks/omo-config-sync/index.ts
1589
1548
  var PACKAGE_NAME2 = "opencode-aicodewith-auth";
1549
+ var OMO_CONFIG_FILENAME = "oh-my-opencode.json";
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;
1566
+ }
1567
+ };
1590
1568
  var fileExists = async (filePath) => {
1591
1569
  try {
1592
1570
  await access(filePath);
@@ -1600,56 +1578,60 @@ var getOmoConfigPath = () => {
1600
1578
  const configRoot = process.env.XDG_CONFIG_HOME || path4.join(homeDir, ".config");
1601
1579
  return path4.join(configRoot, "opencode", OMO_CONFIG_FILENAME);
1602
1580
  };
1603
- var getDefaultModelForAgent = (agentName) => {
1604
- return AGENT_MODEL_MAP[agentName] || DEFAULT_MODEL;
1605
- };
1606
- var getDefaultModelForCategory = (categoryName) => {
1607
- return CATEGORY_MODEL_MAP[categoryName] || DEFAULT_MODEL;
1608
- };
1609
- var syncOmoConfig = async () => {
1610
- const configPath = getOmoConfigPath();
1611
- let config;
1612
- if (!await fileExists(configPath)) {
1613
- config = DEFAULT_CONFIG;
1614
- try {
1615
- await writeFile2(configPath, `${JSON.stringify(config, null, 2)}
1616
- `, "utf-8");
1617
- } catch (error) {
1618
- console.warn(`[${PACKAGE_NAME2}] Failed to create OMO config: ${error instanceof Error ? error.message : error}`);
1619
- }
1620
- return;
1621
- }
1622
- try {
1623
- const content = await readFile2(configPath, "utf-8");
1624
- config = JSON.parse(content);
1625
- } catch {
1626
- return;
1581
+ var syncAgentsAndCategories = (userConfig, defaultConfig) => {
1582
+ let changed = false;
1583
+ if (!userConfig.agents) {
1584
+ userConfig.agents = {};
1627
1585
  }
1628
- if (!config || typeof config !== "object") {
1629
- return;
1586
+ if (!userConfig.categories) {
1587
+ userConfig.categories = {};
1630
1588
  }
1631
- let changed = false;
1632
- if (config.agents && typeof config.agents === "object") {
1633
- for (const [agentName, agentConfig] of Object.entries(config.agents)) {
1634
- if (!agentConfig.model) {
1635
- agentConfig.model = getDefaultModelForAgent(agentName);
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 };
1636
1593
  changed = true;
1637
1594
  }
1638
1595
  }
1639
1596
  }
1640
- if (config.categories && typeof config.categories === "object") {
1641
- for (const [categoryName, categoryConfig] of Object.entries(config.categories)) {
1642
- if (!categoryConfig.model) {
1643
- categoryConfig.model = getDefaultModelForCategory(categoryName);
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 };
1644
1601
  changed = true;
1645
1602
  }
1646
1603
  }
1647
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);
1648
1630
  if (!changed) {
1649
1631
  return;
1650
1632
  }
1651
1633
  try {
1652
- await writeFile2(configPath, `${JSON.stringify(config, null, 2)}
1634
+ await writeFile2(configPath, `${JSON.stringify(userConfig, null, 2)}
1653
1635
  `, "utf-8");
1654
1636
  } catch (error) {
1655
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.27",
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",