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.
- package/dist/index.js +58 -58
- 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
|
|
1551
|
-
var
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
return
|
|
1564
|
-
}
|
|
1565
|
-
|
|
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
|
|
1593
|
-
|
|
1594
|
-
if (!
|
|
1595
|
-
|
|
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 (!
|
|
1605
|
-
|
|
1586
|
+
if (!userConfig.categories) {
|
|
1587
|
+
userConfig.categories = {};
|
|
1606
1588
|
}
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
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 (
|
|
1620
|
-
for (const [
|
|
1621
|
-
if (
|
|
1622
|
-
|
|
1623
|
-
|
|
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(
|
|
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