opencode-aicodewith-auth 0.1.27 → 0.1.29
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 +44 -62
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1545,48 +1545,37 @@ 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
|
-
|
|
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
|
-
};
|
|
1548
|
+
var PACKAGE_NAME2 = "opencode-aicodewith-auth";
|
|
1549
|
+
var OMO_CONFIG_FILENAME = "oh-my-opencode.json";
|
|
1580
1550
|
var DEFAULT_MODEL = `${PROVIDER_ID}/claude-sonnet-4-5-20250929`;
|
|
1581
|
-
var
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
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`;
|
|
1576
|
+
}
|
|
1577
|
+
return DEFAULT_MODEL;
|
|
1585
1578
|
};
|
|
1586
|
-
var OMO_CONFIG_FILENAME = "oh-my-opencode.json";
|
|
1587
|
-
|
|
1588
|
-
// lib/hooks/omo-config-sync/index.ts
|
|
1589
|
-
var PACKAGE_NAME2 = "opencode-aicodewith-auth";
|
|
1590
1579
|
var fileExists = async (filePath) => {
|
|
1591
1580
|
try {
|
|
1592
1581
|
await access(filePath);
|
|
@@ -1600,25 +1589,12 @@ var getOmoConfigPath = () => {
|
|
|
1600
1589
|
const configRoot = process.env.XDG_CONFIG_HOME || path4.join(homeDir, ".config");
|
|
1601
1590
|
return path4.join(configRoot, "opencode", OMO_CONFIG_FILENAME);
|
|
1602
1591
|
};
|
|
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
1592
|
var syncOmoConfig = async () => {
|
|
1610
1593
|
const configPath = getOmoConfigPath();
|
|
1611
|
-
let config;
|
|
1612
1594
|
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
1595
|
return;
|
|
1621
1596
|
}
|
|
1597
|
+
let config;
|
|
1622
1598
|
try {
|
|
1623
1599
|
const content = await readFile2(configPath, "utf-8");
|
|
1624
1600
|
config = JSON.parse(content);
|
|
@@ -1630,18 +1606,24 @@ var syncOmoConfig = async () => {
|
|
|
1630
1606
|
}
|
|
1631
1607
|
let changed = false;
|
|
1632
1608
|
if (config.agents && typeof config.agents === "object") {
|
|
1633
|
-
for (const [
|
|
1634
|
-
if (!agentConfig.model) {
|
|
1635
|
-
|
|
1636
|
-
|
|
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
|
+
}
|
|
1637
1616
|
}
|
|
1638
1617
|
}
|
|
1639
1618
|
}
|
|
1640
1619
|
if (config.categories && typeof config.categories === "object") {
|
|
1641
|
-
for (const [
|
|
1642
|
-
if (!categoryConfig.model) {
|
|
1643
|
-
|
|
1644
|
-
|
|
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
|
+
}
|
|
1645
1627
|
}
|
|
1646
1628
|
}
|
|
1647
1629
|
}
|
package/package.json
CHANGED