opencode-aicodewith-auth 0.1.29 → 0.1.32
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/README.md +23 -0
- package/dist/index.js +62 -58
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,6 +108,29 @@ opencode --model aicodewith/gpt-5.2-codex
|
|
|
108
108
|
|
|
109
109
|
---
|
|
110
110
|
|
|
111
|
+
## 环境变量
|
|
112
|
+
|
|
113
|
+
| 变量名 | 默认值 | 说明 |
|
|
114
|
+
|--------|--------|------|
|
|
115
|
+
| `AICODEWITH_DISABLE_OMO_SYNC` | - | 设为 `1` 或 `true` 禁用 oh-my-opencode 配置自动同步 |
|
|
116
|
+
|
|
117
|
+
### 禁用 OMO 配置同步
|
|
118
|
+
|
|
119
|
+
插件默认会自动同步 oh-my-opencode 的 agent/category 配置。如果你想完全自定义 OMO 配置,可以禁用此功能:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# 在 shell 配置文件中添加(如 ~/.zshrc 或 ~/.bashrc)
|
|
123
|
+
export AICODEWITH_DISABLE_OMO_SYNC=1
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
或启动时指定:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
AICODEWITH_DISABLE_OMO_SYNC=1 opencode
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
111
134
|
## 开发
|
|
112
135
|
|
|
113
136
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -1547,34 +1547,24 @@ 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
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
return
|
|
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 DISABLE_OMO_SYNC_ENV = "AICODEWITH_DISABLE_OMO_SYNC";
|
|
1553
|
+
var fetchDefaultConfig = async () => {
|
|
1554
|
+
try {
|
|
1555
|
+
const controller = new AbortController;
|
|
1556
|
+
const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
1557
|
+
const response = await fetch(DEFAULT_CONFIG_URL, {
|
|
1558
|
+
signal: controller.signal
|
|
1559
|
+
});
|
|
1560
|
+
clearTimeout(timeoutId);
|
|
1561
|
+
if (!response.ok) {
|
|
1562
|
+
return null;
|
|
1563
|
+
}
|
|
1564
|
+
return await response.json();
|
|
1565
|
+
} catch {
|
|
1566
|
+
return null;
|
|
1576
1567
|
}
|
|
1577
|
-
return DEFAULT_MODEL;
|
|
1578
1568
|
};
|
|
1579
1569
|
var fileExists = async (filePath) => {
|
|
1580
1570
|
try {
|
|
@@ -1589,49 +1579,63 @@ var getOmoConfigPath = () => {
|
|
|
1589
1579
|
const configRoot = process.env.XDG_CONFIG_HOME || path4.join(homeDir, ".config");
|
|
1590
1580
|
return path4.join(configRoot, "opencode", OMO_CONFIG_FILENAME);
|
|
1591
1581
|
};
|
|
1592
|
-
var
|
|
1593
|
-
|
|
1594
|
-
if (!
|
|
1595
|
-
|
|
1582
|
+
var syncAgentsAndCategories = (userConfig, defaultConfig) => {
|
|
1583
|
+
let changed = false;
|
|
1584
|
+
if (!userConfig.agents) {
|
|
1585
|
+
userConfig.agents = {};
|
|
1596
1586
|
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
const content = await readFile2(configPath, "utf-8");
|
|
1600
|
-
config = JSON.parse(content);
|
|
1601
|
-
} catch {
|
|
1602
|
-
return;
|
|
1587
|
+
if (!userConfig.categories) {
|
|
1588
|
+
userConfig.categories = {};
|
|
1603
1589
|
}
|
|
1604
|
-
if (
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
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
|
-
}
|
|
1590
|
+
if (defaultConfig.agents) {
|
|
1591
|
+
for (const [name, defaultAgent] of Object.entries(defaultConfig.agents)) {
|
|
1592
|
+
if (!userConfig.agents[name] && defaultAgent.model) {
|
|
1593
|
+
userConfig.agents[name] = { model: defaultAgent.model };
|
|
1594
|
+
changed = true;
|
|
1616
1595
|
}
|
|
1617
1596
|
}
|
|
1618
1597
|
}
|
|
1619
|
-
if (
|
|
1620
|
-
for (const [
|
|
1621
|
-
if (
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
categoryConfig.model = mappedModel;
|
|
1625
|
-
changed = true;
|
|
1626
|
-
}
|
|
1598
|
+
if (defaultConfig.categories) {
|
|
1599
|
+
for (const [name, defaultCategory] of Object.entries(defaultConfig.categories)) {
|
|
1600
|
+
if (!userConfig.categories[name] && defaultCategory.model) {
|
|
1601
|
+
userConfig.categories[name] = { model: defaultCategory.model };
|
|
1602
|
+
changed = true;
|
|
1627
1603
|
}
|
|
1628
1604
|
}
|
|
1629
1605
|
}
|
|
1606
|
+
return changed;
|
|
1607
|
+
};
|
|
1608
|
+
var syncOmoConfig = async () => {
|
|
1609
|
+
if (process.env[DISABLE_OMO_SYNC_ENV] === "1" || process.env[DISABLE_OMO_SYNC_ENV] === "true") {
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1612
|
+
const defaultConfig = await fetchDefaultConfig();
|
|
1613
|
+
if (!defaultConfig) {
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
const configPath = getOmoConfigPath();
|
|
1617
|
+
let userConfig;
|
|
1618
|
+
if (!await fileExists(configPath)) {
|
|
1619
|
+
userConfig = {
|
|
1620
|
+
$schema: "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json"
|
|
1621
|
+
};
|
|
1622
|
+
} else {
|
|
1623
|
+
try {
|
|
1624
|
+
const content = await readFile2(configPath, "utf-8");
|
|
1625
|
+
userConfig = JSON.parse(content);
|
|
1626
|
+
} catch {
|
|
1627
|
+
return;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
if (!userConfig || typeof userConfig !== "object") {
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
const changed = syncAgentsAndCategories(userConfig, defaultConfig);
|
|
1630
1634
|
if (!changed) {
|
|
1631
1635
|
return;
|
|
1632
1636
|
}
|
|
1633
1637
|
try {
|
|
1634
|
-
await writeFile2(configPath, `${JSON.stringify(
|
|
1638
|
+
await writeFile2(configPath, `${JSON.stringify(userConfig, null, 2)}
|
|
1635
1639
|
`, "utf-8");
|
|
1636
1640
|
} catch (error) {
|
|
1637
1641
|
console.warn(`[${PACKAGE_NAME2}] Failed to sync OMO config: ${error instanceof Error ? error.message : error}`);
|
package/package.json
CHANGED