@herouucn/opencode-commandcode 0.1.0 → 0.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herouucn/opencode-commandcode",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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",
@@ -23,10 +23,10 @@
23
23
  "url": "https://github.com/herouu/opencode-commandcode/issues"
24
24
  },
25
25
  "license": "MIT",
26
- "author": "Brent Weatherall",
26
+ "author": "herouu",
27
27
  "repository": {
28
28
  "type": "git",
29
- "url": "git+https://github.com/herouu/opencode-commandcode.git"
29
+ "url": "https://github.com/herouu/opencode-commandcode"
30
30
  },
31
31
  "files": [
32
32
  "index.ts",
package/src/auth.ts CHANGED
@@ -1,43 +1,43 @@
1
- import { readFileSync, existsSync } from "fs";
2
- import { homedir } from "os";
3
- import { join } from "path";
4
-
5
- export function resolveApiKey(options: {
6
- apiKey?: string;
7
- env?: Record<string, string | undefined>;
8
- authPaths?: string[];
9
- }): string | undefined {
10
- if (options.apiKey) return options.apiKey;
11
-
12
- const envKey = options.env?.COMMANDCODE_API_KEY ?? process.env.COMMANDCODE_API_KEY;
13
- if (envKey) return envKey;
14
-
15
- const authPaths = options.authPaths ?? [
16
- join(homedir(), ".commandcode", "auth.json"),
17
- join(homedir(), ".pi", "agent", "auth.json"),
18
- ];
19
-
20
- for (const p of authPaths) {
21
- if (!existsSync(p)) continue;
22
- try {
23
- const parsed = JSON.parse(readFileSync(p, "utf-8"));
24
- if (typeof parsed === "object" && parsed !== null) {
25
- if (typeof parsed.apiKey === "string") return parsed.apiKey;
26
- if (typeof parsed.commandcode === "string") return parsed.commandcode;
27
- if (
28
- typeof parsed.commandcode === "object" &&
29
- parsed.commandcode !== null &&
30
- parsed.commandcode.type === "oauth" &&
31
- typeof parsed.commandcode.access === "string"
32
- ) {
33
- return parsed.commandcode.access;
34
- }
35
- }
36
- } catch {
37
- // intentionally silent: skip unreadable or malformed auth files
38
- continue;
39
- }
40
- }
41
-
42
- return undefined;
43
- }
1
+ import { readFileSync, existsSync } from "fs";
2
+ import { homedir } from "os";
3
+ import { join } from "path";
4
+
5
+ export function resolveApiKey(options: {
6
+ apiKey?: string;
7
+ env?: Record<string, string | undefined>;
8
+ authPaths?: string[];
9
+ }): string | undefined {
10
+ if (options.apiKey) return options.apiKey;
11
+
12
+ const envKey = options.env?.COMMANDCODE_API_KEY ?? process.env.COMMANDCODE_API_KEY;
13
+ if (envKey) return envKey;
14
+
15
+ const authPaths = options.authPaths ?? [
16
+ join(homedir(), ".commandcode", "auth.json"),
17
+ join(homedir(), ".pi", "agent", "auth.json"),
18
+ ];
19
+
20
+ for (const p of authPaths) {
21
+ if (!existsSync(p)) continue;
22
+ try {
23
+ const parsed = JSON.parse(readFileSync(p, "utf-8"));
24
+ if (typeof parsed === "object" && parsed !== null) {
25
+ if (typeof parsed.apiKey === "string") return parsed.apiKey;
26
+ if (typeof parsed.commandcode === "string") return parsed.commandcode;
27
+ if (
28
+ typeof parsed.commandcode === "object" &&
29
+ parsed.commandcode !== null &&
30
+ parsed.commandcode.type === "oauth" &&
31
+ typeof parsed.commandcode.access === "string"
32
+ ) {
33
+ return parsed.commandcode.access;
34
+ }
35
+ }
36
+ } catch {
37
+ // intentionally silent: skip unreadable or malformed auth files
38
+ continue;
39
+ }
40
+ }
41
+
42
+ return undefined;
43
+ }
@@ -1,41 +1,41 @@
1
- export function catalogBreakTitle(commandCodeVersion: string): string {
2
- const version = commandCodeVersion.trim().replace(/^v/, "");
3
- return `[catalog-break] command-code@${version} — model extraction failed`;
4
- }
5
-
6
- export function renderCatalogBreakBody(input: {
7
- commandCodeVersion: string;
8
- error: string;
9
- workflowUrl: string;
10
- bundledCommandCodeVersion: string | null;
11
- }): string {
12
- const bundled = input.bundledCommandCodeVersion ?? "(none)";
13
- return `Model catalog extraction failed for \`command-code@${input.commandCodeVersion}\`.
14
-
15
- ## Error
16
-
17
- \`\`\`
18
- ${input.error}
19
- \`\`\`
20
-
21
- ## Workflow
22
-
23
- ${input.workflowUrl}
24
-
25
- ## Still serving
26
-
27
- Bundled catalog is still \`command-code@${bundled}\`. No npm release was published.
28
-
29
- ## Manual fix
30
-
31
- - [ ] Check extraction anchors in \`src/catalog.ts\`
32
- - [ ] Add/adjust unit fixtures under \`tests/fixtures/command-code/\`
33
- - [ ] Re-run **Catalog sync** with \`force=true\`
34
- `;
35
- }
36
-
37
- export function catalogBreakResolvedComment(input: { commit: string; tag: string }): string {
38
- return `Catalog sync recovered. Fix commit: \`${input.commit}\`. Release: \`${input.tag}\`.`;
39
- }
40
-
41
- export const CATALOG_BREAK_LABEL = "catalog-break";
1
+ export function catalogBreakTitle(commandCodeVersion: string): string {
2
+ const version = commandCodeVersion.trim().replace(/^v/, "");
3
+ return `[catalog-break] command-code@${version} — model extraction failed`;
4
+ }
5
+
6
+ export function renderCatalogBreakBody(input: {
7
+ commandCodeVersion: string;
8
+ error: string;
9
+ workflowUrl: string;
10
+ bundledCommandCodeVersion: string | null;
11
+ }): string {
12
+ const bundled = input.bundledCommandCodeVersion ?? "(none)";
13
+ return `Model catalog extraction failed for \`command-code@${input.commandCodeVersion}\`.
14
+
15
+ ## Error
16
+
17
+ \`\`\`
18
+ ${input.error}
19
+ \`\`\`
20
+
21
+ ## Workflow
22
+
23
+ ${input.workflowUrl}
24
+
25
+ ## Still serving
26
+
27
+ Bundled catalog is still \`command-code@${bundled}\`. No npm release was published.
28
+
29
+ ## Manual fix
30
+
31
+ - [ ] Check extraction anchors in \`src/catalog.ts\`
32
+ - [ ] Add/adjust unit fixtures under \`tests/fixtures/command-code/\`
33
+ - [ ] Re-run **Catalog sync** with \`force=true\`
34
+ `;
35
+ }
36
+
37
+ export function catalogBreakResolvedComment(input: { commit: string; tag: string }): string {
38
+ return `Catalog sync recovered. Fix commit: \`${input.commit}\`. Release: \`${input.tag}\`.`;
39
+ }
40
+
41
+ export const CATALOG_BREAK_LABEL = "catalog-break";