@herouucn/opencode-commandcode 0.1.4 → 0.1.6

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/package.json +1 -1
  2. package/plugin.ts +9 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herouucn/opencode-commandcode",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Inject Command Code API provider into opencode — access Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, MiniMax & Step via unified Command Code API. / 将 Command Code API provider 注入 opencode —— 通过统一的 Command Code API 使用 Claude、GPT、Gemini、DeepSeek、Qwen、Kimi、GLM、MiniMax 和 Step 模型。",
5
5
  "keywords": [
6
6
  "ai",
package/plugin.ts CHANGED
@@ -34,13 +34,13 @@ interface PluginFileConfig {
34
34
  const DEFAULT_REMOTE_CATALOG_URL =
35
35
  "https://raw.githubusercontent.com/herouu/opencode-commandcode/main/models.json";
36
36
 
37
+ // 默认 OpenAI 兼容端点:与 @ai-sdk/openai-compatible 搭配,等价于 README 手动配置推荐值。
38
+ const DEFAULT_BASE_URL = "https://api.commandcode.ai/provider/v1/";
39
+
37
40
  function loadPluginConfig(): PluginFileConfig {
38
41
  const dir = join(homedir(), ".config", "opencode");
39
- const configPath = [
40
- join(dir, "opencode-commandcode.json"),
41
- join(dir, "commandcode-go-opencode-provider.json"),
42
- ].find((p) => existsSync(p));
43
- if (!configPath) return {};
42
+ const configPath = join(dir, "opencode-commandcode.json");
43
+ if (!existsSync(configPath)) return {};
44
44
  try {
45
45
  return JSON.parse(readFileSync(configPath, "utf-8"));
46
46
  } catch {
@@ -123,9 +123,12 @@ export default async function commandcodePlugin() {
123
123
  process.env.COMMANDCODE_PACKAGE_PATH?.trim() ||
124
124
  "";
125
125
 
126
- if (!cc.npm) cc.npm = "commandcode-go-opencode-provider";
126
+ if (!cc.npm) cc.npm = "@ai-sdk/openai-compatible";
127
127
  if (!cc.name) cc.name = "Command Code";
128
128
  if (!cc.env) cc.env = ["COMMANDCODE_API_KEY"];
129
+ const options = (cc.options as Record<string, unknown> | undefined) ?? {};
130
+ cc.options = options;
131
+ if (typeof options.baseURL !== "string") options.baseURL = DEFAULT_BASE_URL;
129
132
 
130
133
  if (cc.models) return;
131
134
 
@@ -225,13 +228,6 @@ export default async function commandcodePlugin() {
225
228
  {
226
229
  type: "api",
227
230
  label: "API Key",
228
- authorize: async (inputs: Record<string, unknown> | undefined) => {
229
- const rawKey = inputs?.key;
230
- if (typeof rawKey !== "string") return { type: "failed" as const };
231
- const key = rawKey.trim();
232
- if (!key) return { type: "failed" as const };
233
- return { type: "api" as const, key };
234
- },
235
231
  },
236
232
  ],
237
233
  loader: async (getAuth: () => Promise<{ type: string; key?: string } | null>) => {