@jeffreyjyz/opencode-command-code 0.3.18 → 0.4.0

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 CHANGED
@@ -2414,7 +2414,7 @@ function superRefine(fn) {
2414
2414
  // package.json
2415
2415
  var package_default = {
2416
2416
  name: "@jeffreyjyz/opencode-command-code",
2417
- version: "0.3.18",
2417
+ version: "0.4.0",
2418
2418
  description: "Command Code provider + usage dashboard for opencode: two providers (Anthropic wire for Claude, OpenAI wire for everything else) against api.commandcode.ai, live model list, plan gating, /cmd-usage. Requires the cmduse CLI for usage rendering.",
2419
2419
  type: "module",
2420
2420
  main: "dist/index.js",
@@ -2438,7 +2438,7 @@ var package_default = {
2438
2438
  },
2439
2439
  devDependencies: {
2440
2440
  "@types/bun": "latest",
2441
- typescript: "^5",
2441
+ typescript: "^7",
2442
2442
  "@opencode-ai/plugin": "*",
2443
2443
  "@opencode/plugin": "^2.0.11",
2444
2444
  "@ai-sdk/provider": "3.0.8"
@@ -2461,8 +2461,12 @@ var package_default = {
2461
2461
  }
2462
2462
  };
2463
2463
 
2464
- // src/api.ts
2464
+ // src/constants/endpoints.ts
2465
2465
  var API_BASE = "https://api.commandcode.ai";
2466
+ var PROVIDER_BASE = `${API_BASE}/provider/v1`;
2467
+ var DEFAULT_BASE_URL = API_BASE;
2468
+
2469
+ // src/api.ts
2466
2470
  function authHeaders(key) {
2467
2471
  return { Authorization: `Bearer ${key}`, Accept: "application/json" };
2468
2472
  }
@@ -2579,10 +2583,18 @@ var MODEL_CATALOG = {
2579
2583
  modalities: ["text", "image"],
2580
2584
  minPlan: "Pro"
2581
2585
  },
2586
+ "claude-sonnet-5-5": {
2587
+ name: "Claude Sonnet 5.5",
2588
+ context: 1e6,
2589
+ efforts: ["low", "medium", "high", "xhigh", "max"],
2590
+ cost: { input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5 },
2591
+ modalities: ["text", "image"],
2592
+ minPlan: "GOAT"
2593
+ },
2582
2594
  "deepseek/deepseek-v4-flash": {
2583
2595
  name: "DeepSeek V4 Flash (latest)",
2584
2596
  context: 1e6,
2585
- efforts: ["high", "max"],
2597
+ efforts: ["off", "high", "max"],
2586
2598
  cost: { input: 0.15, output: 0.6, cacheRead: 0.003, cacheWrite: 0 },
2587
2599
  modalities: ["text"],
2588
2600
  minPlan: "Go"
@@ -2598,7 +2610,7 @@ var MODEL_CATALOG = {
2598
2610
  "deepseek/deepseek-v4-flash-vision-exp": {
2599
2611
  name: "DeepSeek V4 Flash Vision (exp)",
2600
2612
  context: 1e6,
2601
- efforts: ["high", "max"],
2613
+ efforts: ["off", "high", "max"],
2602
2614
  cost: { input: 0.15, output: 0.6, cacheRead: 0.003, cacheWrite: 0 },
2603
2615
  modalities: ["text", "image"],
2604
2616
  minPlan: "Go"
@@ -2606,7 +2618,7 @@ var MODEL_CATALOG = {
2606
2618
  "deepseek/deepseek-v4-pro": {
2607
2619
  name: "DeepSeek V4 Pro (latest)",
2608
2620
  context: 1e6,
2609
- efforts: ["high", "max"],
2621
+ efforts: ["off", "high", "max"],
2610
2622
  cost: { input: 0.66, output: 1.98, cacheRead: 0.022, cacheWrite: 0 },
2611
2623
  modalities: ["text"],
2612
2624
  minPlan: "Go"
@@ -2614,11 +2626,19 @@ var MODEL_CATALOG = {
2614
2626
  "deepseek/deepseek-v4.1-flash": {
2615
2627
  name: "DeepSeek V4.1 Flash",
2616
2628
  context: 1e6,
2617
- efforts: ["low", "high", "max"],
2629
+ efforts: ["off", "low", "high", "max"],
2618
2630
  cost: { input: 0.15, output: 0.6, cacheRead: 0.003, cacheWrite: 0 },
2619
2631
  modalities: ["text", "image"],
2620
2632
  minPlan: "Go"
2621
2633
  },
2634
+ "deepseek/deepseek-v4.1-flash-fast": {
2635
+ name: "DeepSeek V4.1 Flash Fast",
2636
+ context: 1e6,
2637
+ efforts: ["off", "low", "high", "max"],
2638
+ cost: { input: 0.16, output: 0.58, cacheRead: 0.016, cacheWrite: 0 },
2639
+ modalities: ["text", "image"],
2640
+ minPlan: "Go"
2641
+ },
2622
2642
  "google/gemini-3.1-flash-lite": {
2623
2643
  name: "Gemini 3.1 Flash Lite",
2624
2644
  context: 1e6,
@@ -2747,6 +2767,14 @@ var MODEL_CATALOG = {
2747
2767
  modalities: ["text", "image"],
2748
2768
  minPlan: "Pro"
2749
2769
  },
2770
+ "gpt-6.1-sol": {
2771
+ name: "GPT-6.1 Sol",
2772
+ context: 1050000,
2773
+ efforts: ["low", "medium", "high", "xhigh", "max"],
2774
+ cost: { input: 2, output: 10, cacheRead: 0.1, cacheWrite: 2.5 },
2775
+ modalities: ["text", "image"],
2776
+ minPlan: "Max"
2777
+ },
2750
2778
  "inclusionai/ling-3.0-flash-sante:free": {
2751
2779
  name: "Ling 3.0 Flash Sante",
2752
2780
  context: 262000,
@@ -2755,6 +2783,14 @@ var MODEL_CATALOG = {
2755
2783
  modalities: ["text"],
2756
2784
  minPlan: "Go"
2757
2785
  },
2786
+ "inclusionai/ling-3.1-flash:free": {
2787
+ name: "Ling 3.1 Flash",
2788
+ context: 262000,
2789
+ efforts: ["low", "medium", "high"],
2790
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
2791
+ modalities: ["text"],
2792
+ minPlan: "Go"
2793
+ },
2758
2794
  "meituan/LongCat-2.0": {
2759
2795
  name: "LongCat 2.0",
2760
2796
  context: 1050000,
@@ -2903,7 +2939,12 @@ var MODEL_CATALOG = {
2903
2939
  name: "Qwen 3.7 Flash",
2904
2940
  context: 1e6,
2905
2941
  efforts: null,
2906
- cost: { input: 0.03, output: 0.13, cacheRead: 0.006, cacheWrite: 0.038 },
2942
+ cost: {
2943
+ input: 0.03,
2944
+ output: 0.13,
2945
+ cacheRead: 0.006,
2946
+ cacheWrite: 0.038
2947
+ },
2907
2948
  modalities: ["text", "image"],
2908
2949
  minPlan: "Go"
2909
2950
  },
@@ -2974,7 +3015,7 @@ var MODEL_CATALOG = {
2974
3015
  "stealth/space-bunny-alpha": {
2975
3016
  name: "Space Bunny Alpha",
2976
3017
  context: 1e6,
2977
- efforts: ["low", "medium", "high"],
3018
+ efforts: ["low", "medium", "high", "max"],
2978
3019
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
2979
3020
  modalities: ["text", "image"],
2980
3021
  minPlan: "Go"
@@ -3055,7 +3096,7 @@ var MODEL_CATALOG = {
3055
3096
  name: "Grok 4.7",
3056
3097
  context: 500000,
3057
3098
  efforts: ["low", "medium", "high", "xhigh"],
3058
- cost: { input: 1.2, output: 3.6, cacheRead: 0.3, cacheWrite: 0 },
3099
+ cost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0 },
3059
3100
  modalities: ["text", "image"],
3060
3101
  minPlan: "GOAT"
3061
3102
  },
@@ -3175,16 +3216,22 @@ function reasoningVariants(id) {
3175
3216
 
3176
3217
  // src/cli.ts
3177
3218
  import { spawn } from "child_process";
3178
- function cmduseCandidates(env = process.env) {
3179
- const candidates = [
3180
- env.CMDUSE_BIN,
3181
- "cmduse",
3182
- "/opt/homebrew/bin/cmduse",
3183
- "/usr/local/bin/cmduse"
3184
- ];
3185
- return candidates.filter((bin) => Boolean(bin));
3186
- }
3187
- var CANDIDATES = cmduseCandidates();
3219
+
3220
+ // src/constants/binaries.ts
3221
+ import { homedir } from "os";
3222
+ import { join } from "path";
3223
+ var CMDUSE_BIN_CANDIDATES = [
3224
+ "cmduse",
3225
+ "/opt/homebrew/bin/cmduse",
3226
+ "/usr/local/bin/cmduse"
3227
+ ];
3228
+ var MPC_BIN_CANDIDATES = [
3229
+ "mpc",
3230
+ join(homedir(), ".bun/bin/mpc"),
3231
+ "/opt/homebrew/bin/mpc"
3232
+ ];
3233
+
3234
+ // src/constants/cli.ts
3188
3235
  var DEFAULT_ARGS = ["-1", "--plain"];
3189
3236
  var SUBCOMMANDS = new Set([
3190
3237
  "plans",
@@ -3196,6 +3243,13 @@ var SUBCOMMANDS = new Set([
3196
3243
  "statusline",
3197
3244
  "config"
3198
3245
  ]);
3246
+
3247
+ // src/cli.ts
3248
+ function cmduseCandidates(env = process.env) {
3249
+ const candidates = [env.CMDUSE_BIN, ...CMDUSE_BIN_CANDIDATES];
3250
+ return candidates.filter((bin) => Boolean(bin));
3251
+ }
3252
+ var CANDIDATES = cmduseCandidates();
3199
3253
  function splitCliArgs(input) {
3200
3254
  const out = [];
3201
3255
  let cur = "";
@@ -3237,7 +3291,7 @@ function splitCliArgs(input) {
3237
3291
  function buildCmduseArgs(arg) {
3238
3292
  const tokens = splitCliArgs(arg);
3239
3293
  if (!tokens.length)
3240
- return DEFAULT_ARGS;
3294
+ return [...DEFAULT_ARGS];
3241
3295
  if (tokens.some((t) => SUBCOMMANDS.has(t)))
3242
3296
  return tokens;
3243
3297
  return [...DEFAULT_ARGS, ...tokens];
@@ -3296,9 +3350,48 @@ async function runCmduse(arg, opts = {}) {
3296
3350
  throw new Error(`cmduse binary not found (install: brew install JeffreyJYZ/tap/cmduse)${last instanceof Error && last.message !== last.name ? ` \u2014 ${last.message}` : ""}`, { cause: last });
3297
3351
  }
3298
3352
 
3353
+ // src/constants/models.ts
3354
+ var MODEL_CAPABILITIES = {
3355
+ temperature: true,
3356
+ reasoning: true,
3357
+ attachment: false,
3358
+ toolcall: true,
3359
+ input: { text: true, audio: false, image: false, video: false, pdf: false },
3360
+ output: {
3361
+ text: true,
3362
+ audio: false,
3363
+ image: false,
3364
+ video: false,
3365
+ pdf: false
3366
+ }
3367
+ };
3368
+ var DEFAULT_CONTEXT_LENGTH = 128000;
3369
+ var DEFAULT_OUTPUT_TOKENS = 32000;
3370
+ var DEFAULT_MAX_TOKENS = 64000;
3371
+
3372
+ // src/constants/providers.ts
3373
+ var PROVIDER_ID_PREFIX = "command-code";
3374
+ var PLUGIN_ID = PROVIDER_ID_PREFIX;
3375
+ var INTEGRATION_ID = PROVIDER_ID_PREFIX;
3376
+ var INTEGRATION_NAME = "Command Code";
3377
+ var TOOL_DESCRIPTION = "Fetch live Command Code plan/usage: plan name, monthly credits, 5-hour & weekly windows, billing-period summary. Pass arg='plans' for the plan comparison table only, or extra cmduse flags (e.g. '--tz +05:30 daily').";
3378
+ var LANES = [
3379
+ {
3380
+ id: "command-code-anthropic",
3381
+ name: "Command Code (Anthropic)",
3382
+ pkg: "@opencode/ai/providers/anthropic"
3383
+ },
3384
+ {
3385
+ id: "command-code-openai",
3386
+ name: "Command Code (OpenAI)",
3387
+ pkg: "@opencode/ai/providers/openai-compatible",
3388
+ reasoningField: "reasoning_content"
3389
+ }
3390
+ ];
3391
+
3299
3392
  // src/key.ts
3300
3393
  import { readFile } from "fs/promises";
3301
- import { homedir } from "os";
3394
+ import { homedir as homedir2 } from "os";
3302
3395
  async function resolveKey(getAuth) {
3303
3396
  const env = process.env.CMD_API_KEY;
3304
3397
  if (env)
@@ -3309,7 +3402,7 @@ async function resolveKey(getAuth) {
3309
3402
  return auth.key;
3310
3403
  } catch {}
3311
3404
  try {
3312
- const text = await readFile(`${homedir()}/.commandcode/auth.json`, "utf8");
3405
+ const text = await readFile(`${homedir2()}/.commandcode/auth.json`, "utf8");
3313
3406
  const v = JSON.parse(text);
3314
3407
  if (typeof v.apiKey === "string" && v.apiKey)
3315
3408
  return v.apiKey;
@@ -3318,9 +3411,10 @@ async function resolveKey(getAuth) {
3318
3411
  }
3319
3412
  // ../core/gating.json
3320
3413
  var gating_default = {
3321
- extractedAt: "2026-09-27T06:27:06.878Z",
3322
- cliVersion: "1.66.0",
3414
+ extractedAt: "2026-10-03T05:21:43.847Z",
3415
+ cliVersion: "1.74.1",
3323
3416
  categories: {
3417
+ "claude-sonnet-5-5": "opensource",
3324
3418
  "claude-sonnet-5": "premium",
3325
3419
  "claude-sonnet-4-6": "premium",
3326
3420
  "claude-fable-5-1": "premium",
@@ -3334,6 +3428,7 @@ var gating_default = {
3334
3428
  "gpt-5.6-terra": "premium",
3335
3429
  "gpt-5.6-luna": "opensource",
3336
3430
  "gpt-6-astra": "premium",
3431
+ "gpt-6.1-sol": "premium",
3337
3432
  "gpt-6-sol": "premium",
3338
3433
  "gpt-6-luna": "opensource",
3339
3434
  "gpt-5.5": "premium",
@@ -3367,6 +3462,7 @@ var gating_default = {
3367
3462
  "deepseek/deepseek-v4-pro": "opensource",
3368
3463
  "deepseek/deepseek-v4-flash": "opensource",
3369
3464
  "deepseek/deepseek-v4.1-flash": "opensource",
3465
+ "deepseek/deepseek-v4.1-flash-fast": "opensource",
3370
3466
  "moonshotai/Kimi-K3": "opensource",
3371
3467
  "moonshotai/Kimi-K2.7-Code": "opensource",
3372
3468
  "moonshotai/Kimi-K2.7-Code-Highspeed": "opensource",
@@ -3395,6 +3491,7 @@ var gating_default = {
3395
3491
  "meituan/LongCat-2.0": "opensource",
3396
3492
  "meituan/LongCat-2.0:free": "opensource",
3397
3493
  "inclusionai/ling-3.0-flash-sante:free": "opensource",
3494
+ "inclusionai/ling-3.1-flash:free": "opensource",
3398
3495
  "stepfun/Step-5-Preview": "opensource",
3399
3496
  "stepfun/Step-3.7-Flash": "opensource",
3400
3497
  "stepfun/Step-3.5-Flash": "opensource",
@@ -3416,7 +3513,24 @@ var gating_default = {
3416
3513
  "vercel-ai-gateway:xiaomi/mimo-v2.6-pro-ultraspeed",
3417
3514
  "openrouter:google/gemini-3.7-flash",
3418
3515
  "vercel-ai-gateway:google/gemini-3.8-flash",
3419
- "vercel-ai-gateway:gpt-5.6-sol"
3516
+ "vercel-ai-gateway:gpt-5.6-sol",
3517
+ "anthropic:claude-sonnet-5-5"
3518
+ ]
3519
+ },
3520
+ "individual-go-v1": {
3521
+ allowedCategories: [
3522
+ "opensource"
3523
+ ],
3524
+ blockedModels: [
3525
+ "vercel-ai-gateway:meta/muse-spark-1.2",
3526
+ "vercel-ai-gateway:meta/muse-spark-1.3",
3527
+ "vercel-ai-gateway:xai/grok-4.6",
3528
+ "vercel-ai-gateway:xai/grok-4.7",
3529
+ "vercel-ai-gateway:xiaomi/mimo-v2.6-pro-ultraspeed",
3530
+ "openrouter:google/gemini-3.7-flash",
3531
+ "vercel-ai-gateway:google/gemini-3.8-flash",
3532
+ "vercel-ai-gateway:gpt-5.6-sol",
3533
+ "anthropic:claude-sonnet-5-5"
3420
3534
  ]
3421
3535
  },
3422
3536
  "individual-goat": {
@@ -3440,6 +3554,7 @@ var gating_default = {
3440
3554
  "anthropic:claude-opus-4-6",
3441
3555
  "anthropic:claude-opus-4-5-20251101",
3442
3556
  "openai:gpt-6-astra",
3557
+ "openai:gpt-6.1-sol",
3443
3558
  "vercel-ai-gateway:sakana/fugu-ultra"
3444
3559
  ]
3445
3560
  },
@@ -3458,6 +3573,7 @@ var gating_default = {
3458
3573
  "anthropic:claude-opus-4-6",
3459
3574
  "anthropic:claude-opus-4-5-20251101",
3460
3575
  "openai:gpt-6-astra",
3576
+ "openai:gpt-6.1-sol",
3461
3577
  "vercel-ai-gateway:sakana/fugu-ultra"
3462
3578
  ]
3463
3579
  },
@@ -3466,7 +3582,9 @@ var gating_default = {
3466
3582
  "premium",
3467
3583
  "opensource"
3468
3584
  ],
3469
- blockedModels: []
3585
+ blockedModels: [
3586
+ "openai:gpt-6.1-sol"
3587
+ ]
3470
3588
  },
3471
3589
  "individual-max": {
3472
3590
  allowedCategories: [
@@ -3491,6 +3609,7 @@ var gating_default = {
3491
3609
  }
3492
3610
  },
3493
3611
  knownModels: [
3612
+ "claude-sonnet-5",
3494
3613
  "claude-sonnet-4-6",
3495
3614
  "claude-fable-5-1",
3496
3615
  "claude-fable-5",
@@ -3500,6 +3619,7 @@ var gating_default = {
3500
3619
  "claude-opus-4-7",
3501
3620
  "claude-haiku-4-5-20251001",
3502
3621
  "gpt-6-astra",
3622
+ "gpt-6.1-sol",
3503
3623
  "gpt-6-sol",
3504
3624
  "gpt-6-luna",
3505
3625
  "gpt-5.6-sol",
@@ -3517,6 +3637,7 @@ var gating_default = {
3517
3637
  "deepseek/deepseek-v4-flash-vision-exp",
3518
3638
  "deepseek/deepseek-v4-flash-fast",
3519
3639
  "deepseek/deepseek-v4.1-flash",
3640
+ "deepseek/deepseek-v4.1-flash-fast",
3520
3641
  "moonshotai/Kimi-K2.7-Code",
3521
3642
  "moonshotai/Kimi-K2.7-Code-Highspeed",
3522
3643
  "moonshotai/Kimi-K2.6",
@@ -3562,9 +3683,10 @@ var gating_default = {
3562
3683
  "poolside/laguna-s-2.1-free",
3563
3684
  "inclusionai/ling-3.0-flash-free",
3564
3685
  "inclusionai/ling-3.0-flash-sante:free",
3686
+ "inclusionai/ling-3.1-flash:free",
3565
3687
  "stealth/space-bunny-alpha",
3566
3688
  "stealth/pixel-canary",
3567
- "claude-sonnet-5",
3689
+ "claude-sonnet-5-5",
3568
3690
  "MiniMaxAI/MiniMax-M3-Free",
3569
3691
  "MiniMaxAI/MiniMax-M3",
3570
3692
  "MiniMaxAI/MiniMax-M2.7",
@@ -3609,7 +3731,7 @@ var gating_default = {
3609
3731
  }
3610
3732
  };
3611
3733
 
3612
- // src/gating.ts
3734
+ // src/constants/gating.ts
3613
3735
  var MODEL_CATEGORIES = gating_default.categories;
3614
3736
  var PLAN_RULES = gating_default.plans;
3615
3737
  var HARD_BLOCKED = gating_default.hardBlocked;
@@ -3618,6 +3740,8 @@ var MODEL_ALIASES = gating_default.aliases;
3618
3740
  var GATE_EXTRACTED_AT = gating_default.extractedAt;
3619
3741
  var GATE_CLI_VERSION = gating_default.cliVersion;
3620
3742
  var GATE_STALE_DAYS = 30;
3743
+
3744
+ // src/gating.ts
3621
3745
  var staleWarned = false;
3622
3746
  function warnIfGatingStale() {
3623
3747
  if (staleWarned || !GATE_EXTRACTED_AT)
@@ -3684,8 +3808,11 @@ function siblingCategory(model) {
3684
3808
  return best ? MODEL_CATEGORIES[best] : undefined;
3685
3809
  }
3686
3810
 
3811
+ // src/constants/timing.ts
3812
+ var MODELS_CACHE_TTL_MS = 5 * 60 * 1000;
3813
+ var CATALOG_CACHE_TTL_MS = 60 * 60 * 1000;
3814
+
3687
3815
  // src/models.ts
3688
- var CACHE_TTL_MS = 5 * 60 * 1000;
3689
3816
  var cache = null;
3690
3817
  function isClaude(id) {
3691
3818
  const bare = id.includes("/") ? id.slice(id.lastIndexOf("/") + 1) : id;
@@ -3701,8 +3828,8 @@ function splitModels(models) {
3701
3828
  async function loadModels(key) {
3702
3829
  warnIfGatingStale();
3703
3830
  let models;
3704
- const fresh = cache && cache.key === key && Date.now() - cache.at < CACHE_TTL_MS;
3705
- if (fresh) {
3831
+ const fresh = cache && cache.key === key && Date.now() - cache.at < MODELS_CACHE_TTL_MS;
3832
+ if (fresh && cache) {
3706
3833
  models = cache.models;
3707
3834
  } else {
3708
3835
  try {
@@ -3740,11 +3867,18 @@ async function loadModels(key) {
3740
3867
 
3741
3868
  // src/modelsCache.ts
3742
3869
  import { mkdir, readFile as readFile2, writeFile } from "fs/promises";
3743
- import { homedir as homedir2 } from "os";
3744
- import { join } from "path";
3870
+ import { homedir as homedir3 } from "os";
3871
+ import { join as join2 } from "path";
3872
+
3873
+ // src/constants/paths.ts
3874
+ var CACHE_DIR = "command-code";
3875
+ var MODELS_CACHE_FILE = "models.json";
3876
+ var STARTUP_LOG_FILE = "startup.log";
3877
+
3878
+ // src/modelsCache.ts
3745
3879
  function cachePath() {
3746
- const base = process.env.XDG_CACHE_HOME ?? join(homedir2(), ".cache");
3747
- return join(base, "command-code", "models.json");
3880
+ const base = process.env.XDG_CACHE_HOME ?? join2(homedir3(), ".cache");
3881
+ return join2(base, CACHE_DIR, MODELS_CACHE_FILE);
3748
3882
  }
3749
3883
  async function readModelsCache() {
3750
3884
  try {
@@ -3759,7 +3893,7 @@ async function readModelsCache() {
3759
3893
  async function writeModelsCache(cache) {
3760
3894
  try {
3761
3895
  const path = cachePath();
3762
- await mkdir(join(path, ".."), { recursive: true });
3896
+ await mkdir(join2(path, ".."), { recursive: true });
3763
3897
  await writeFile(path, JSON.stringify(cache));
3764
3898
  } catch {}
3765
3899
  }
@@ -3853,7 +3987,9 @@ function anthropicReducer() {
3853
3987
  const open = (index, kind) => {
3854
3988
  const id = `${kind === "text" ? "text" : "reasoning"}-${index}`;
3855
3989
  blocks.set(index, { type: kind, id });
3856
- return [{ type: kind === "text" ? "text-start" : "reasoning-start", id }];
3990
+ return [
3991
+ { type: kind === "text" ? "text-start" : "reasoning-start", id }
3992
+ ];
3857
3993
  };
3858
3994
  return {
3859
3995
  feed(event) {
@@ -3875,7 +4011,13 @@ function anthropicReducer() {
3875
4011
  if (blockType === "tool_use") {
3876
4012
  const id = text(block.id) || `tool-${index}`;
3877
4013
  blocks.set(index, { type: "tool_use", id });
3878
- return [{ type: "tool-input-start", id, toolName: text(block.name) }];
4014
+ return [
4015
+ {
4016
+ type: "tool-input-start",
4017
+ id,
4018
+ toolName: text(block.name)
4019
+ }
4020
+ ];
3879
4021
  }
3880
4022
  blocks.set(index, { type: "other", id: `block-${index}` });
3881
4023
  return [];
@@ -3888,17 +4030,29 @@ function anthropicReducer() {
3888
4030
  if (textDelta) {
3889
4031
  const parts = block?.type === "text" ? [] : open(index, "text");
3890
4032
  const id = blocks.get(index)?.id ?? `text-${index}`;
3891
- return [...parts, { type: "text-delta", id, delta: textDelta }];
4033
+ return [
4034
+ ...parts,
4035
+ { type: "text-delta", id, delta: textDelta }
4036
+ ];
3892
4037
  }
3893
4038
  const thinking = text(delta.thinking);
3894
4039
  if (thinking) {
3895
4040
  const parts = block?.type === "thinking" ? [] : open(index, "thinking");
3896
4041
  const id = blocks.get(index)?.id ?? `reasoning-${index}`;
3897
- return [...parts, { type: "reasoning-delta", id, delta: thinking }];
4042
+ return [
4043
+ ...parts,
4044
+ { type: "reasoning-delta", id, delta: thinking }
4045
+ ];
3898
4046
  }
3899
4047
  const partial = text(delta.partial_json);
3900
4048
  if (partial && block?.type === "tool_use") {
3901
- return [{ type: "tool-input-delta", id: block.id, delta: partial }];
4049
+ return [
4050
+ {
4051
+ type: "tool-input-delta",
4052
+ id: block.id,
4053
+ delta: partial
4054
+ }
4055
+ ];
3902
4056
  }
3903
4057
  return [];
3904
4058
  }
@@ -4115,7 +4269,11 @@ function openaiReducer() {
4115
4269
  return parts;
4116
4270
  },
4117
4271
  close() {
4118
- const parts = [...closeReasoning(), ...closeText(), ...flushTools()];
4272
+ const parts = [
4273
+ ...closeReasoning(),
4274
+ ...closeText(),
4275
+ ...flushTools()
4276
+ ];
4119
4277
  if (pending && !finished) {
4120
4278
  finished = true;
4121
4279
  parts.push({
@@ -4130,7 +4288,6 @@ function openaiReducer() {
4130
4288
  }
4131
4289
 
4132
4290
  // src/provider/wire.ts
4133
- var DEFAULT_MAX_TOKENS = 64000;
4134
4291
  function capTokens(value) {
4135
4292
  const n = typeof value === "number" && Number.isFinite(value) ? value : DEFAULT_MAX_TOKENS;
4136
4293
  return Math.min(n, DEFAULT_MAX_TOKENS);
@@ -4284,7 +4441,11 @@ function anthropicBody(model, prompt, options) {
4284
4441
  };
4285
4442
  if (system)
4286
4443
  body.system = [
4287
- { type: "text", text: system, cache_control: { type: "ephemeral" } }
4444
+ {
4445
+ type: "text",
4446
+ text: system,
4447
+ cache_control: { type: "ephemeral" }
4448
+ }
4288
4449
  ];
4289
4450
  if (options.tools?.length) {
4290
4451
  body.tools = options.tools.map((t) => ({
@@ -4382,7 +4543,6 @@ function requestBody(lane, model, prompt, options) {
4382
4543
  }
4383
4544
 
4384
4545
  // src/provider/index.ts
4385
- var DEFAULT_BASE_URL = "https://api.commandcode.ai";
4386
4546
  function laneOf(modelId) {
4387
4547
  const bare = modelId.includes("/") ? modelId.slice(modelId.lastIndexOf("/") + 1) : modelId;
4388
4548
  return bare.toLowerCase().startsWith("claude") ? "anthropic" : "openai";
@@ -4446,10 +4606,11 @@ function createCommandCode(options = {}, images = () => false) {
4446
4606
  const detail = await response.text().catch(() => "");
4447
4607
  throw new Error(`command-code ${lane} ${response.status}: ${detail.slice(0, 300)}`);
4448
4608
  }
4609
+ const responseBody = response.body;
4449
4610
  const reducer = lane === "anthropic" ? anthropicReducer() : openaiReducer();
4450
4611
  const stream = new ReadableStream({
4451
4612
  async start(controller) {
4452
- const reader = response.body.getReader();
4613
+ const reader = responseBody.getReader();
4453
4614
  const decoder = new TextDecoder;
4454
4615
  const emit = (parts) => {
4455
4616
  for (const part of parts)
@@ -4485,7 +4646,12 @@ function createCommandCode(options = {}, images = () => false) {
4485
4646
  raw: "unknown"
4486
4647
  };
4487
4648
  let usage = {
4488
- inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
4649
+ inputTokens: {
4650
+ total: 0,
4651
+ noCache: 0,
4652
+ cacheRead: 0,
4653
+ cacheWrite: 0
4654
+ },
4489
4655
  outputTokens: { total: 0, text: 0, reasoning: 0 }
4490
4656
  };
4491
4657
  const textOf = {};
@@ -4498,7 +4664,10 @@ function createCommandCode(options = {}, images = () => false) {
4498
4664
  if (part.type === "text-delta")
4499
4665
  textOf[String(part.id)] = (textOf[String(part.id)] ?? "") + String(part.delta);
4500
4666
  else if (part.type === "reasoning-delta") {
4501
- content.push({ type: "reasoning", text: String(part.delta) });
4667
+ content.push({
4668
+ type: "reasoning",
4669
+ text: String(part.delta)
4670
+ });
4502
4671
  } else if (part.type === "tool-input-start") {
4503
4672
  toolsById.set(String(part.id), {
4504
4673
  name: String(part.toolName),
@@ -4536,43 +4705,25 @@ function createCommandCode(options = {}, images = () => false) {
4536
4705
 
4537
4706
  // src/startupLog.ts
4538
4707
  import { appendFile, mkdir as mkdir2 } from "fs/promises";
4539
- import { homedir as homedir3 } from "os";
4540
- import { join as join2 } from "path";
4708
+ import { homedir as homedir4 } from "os";
4709
+ import { join as join3 } from "path";
4541
4710
  function setupTimingLine(t) {
4542
4711
  return `setup: key=${t.key}ms register=${t.register}ms connection=${t.connection}ms refresh=${t.refresh}ms models=${t.models}`;
4543
4712
  }
4544
4713
  function startupLogPath() {
4545
- const base = process.env.XDG_CACHE_HOME ?? join2(homedir3(), ".cache");
4546
- return join2(base, "command-code", "startup.log");
4714
+ const base = process.env.XDG_CACHE_HOME ?? join3(homedir4(), ".cache");
4715
+ return join3(base, CACHE_DIR, STARTUP_LOG_FILE);
4547
4716
  }
4548
4717
  async function writeStartupLine(line) {
4549
4718
  try {
4550
4719
  const path = startupLogPath();
4551
- await mkdir2(join2(path, ".."), { recursive: true });
4720
+ await mkdir2(join3(path, ".."), { recursive: true });
4552
4721
  await appendFile(path, `[${new Date().toISOString()}] ${line}
4553
4722
  `);
4554
4723
  } catch {}
4555
4724
  }
4556
4725
 
4557
4726
  // src/v2.ts
4558
- var PLUGIN_ID = "command-code";
4559
- var PROVIDER_BASE = "https://api.commandcode.ai/provider/v1";
4560
- var INTEGRATION_ID = "command-code";
4561
- var INTEGRATION_NAME = "Command Code";
4562
- var LANES = [
4563
- {
4564
- id: "command-code-anthropic",
4565
- name: "Command Code (Anthropic)",
4566
- pkg: "@opencode/ai/providers/anthropic"
4567
- },
4568
- {
4569
- id: "command-code-openai",
4570
- name: "Command Code (OpenAI)",
4571
- pkg: "@opencode/ai/providers/openai-compatible",
4572
- reasoningField: "reasoning_content"
4573
- }
4574
- ];
4575
- var TOOL_DESCRIPTION = "Fetch live Command Code plan/usage: plan name, monthly credits, 5-hour & weekly windows, billing-period summary. Pass arg='plans' for the plan comparison table only, or extra cmduse flags (e.g. '--tz +05:30 daily').";
4576
4727
  function costEntry(id) {
4577
4728
  const cost = modelCost(id);
4578
4729
  return cost ? [
@@ -4601,7 +4752,10 @@ function toV2Model(m, lane) {
4601
4752
  cost: costEntry(m.id),
4602
4753
  status: "active",
4603
4754
  enabled: true,
4604
- limit: { context: m.contextLength || 128000, output: 32000 },
4755
+ limit: {
4756
+ context: m.contextLength || DEFAULT_CONTEXT_LENGTH,
4757
+ output: DEFAULT_OUTPUT_TOKENS
4758
+ },
4605
4759
  ...lane.reasoningField ? { compatibility: { reasoningField: lane.reasoningField } } : {}
4606
4760
  };
4607
4761
  return info;
@@ -4698,7 +4852,10 @@ var commandCodeV2 = {
4698
4852
  if (provider.package === "")
4699
4853
  provider.package = lane.pkg;
4700
4854
  provider.activation = localKey ? "enabled" : "auto";
4701
- provider.settings = { ...provider.settings, baseURL: PROVIDER_BASE };
4855
+ provider.settings = {
4856
+ ...provider.settings,
4857
+ baseURL: PROVIDER_BASE
4858
+ };
4702
4859
  if (localKey && provider.settings.apiKey === undefined) {
4703
4860
  provider.settings.apiKey = localKey;
4704
4861
  }
@@ -4819,14 +4976,6 @@ var PROVIDER_NPM = `${package_default.name}@${package_default.version}`;
4819
4976
  function tool(input) {
4820
4977
  return input;
4821
4978
  }
4822
- var MODEL_CAPABILITIES = {
4823
- temperature: true,
4824
- reasoning: true,
4825
- attachment: false,
4826
- toolcall: true,
4827
- input: { text: true, audio: false, image: false, video: false, pdf: false },
4828
- output: { text: true, audio: false, image: false, video: false, pdf: false }
4829
- };
4830
4979
  function costFor(id) {
4831
4980
  const cost = modelCost(id);
4832
4981
  return {
@@ -4848,11 +4997,17 @@ function toModelDefs(models, providerID, npm, interleaved = false) {
4848
4997
  interleaved,
4849
4998
  ...supportsImage(m.id) ? {
4850
4999
  attachment: true,
4851
- input: { ...MODEL_CAPABILITIES.input, image: true }
5000
+ input: {
5001
+ ...MODEL_CAPABILITIES.input,
5002
+ image: true
5003
+ }
4852
5004
  } : {}
4853
5005
  },
4854
5006
  cost: costFor(m.id),
4855
- limit: { context: m.contextLength || 128000, output: 32000 },
5007
+ limit: {
5008
+ context: m.contextLength || DEFAULT_CONTEXT_LENGTH,
5009
+ output: DEFAULT_OUTPUT_TOKENS
5010
+ },
4856
5011
  status: "active",
4857
5012
  options: {},
4858
5013
  headers: {},
@@ -4965,7 +5120,9 @@ var CommandCodePlugin = async (_input) => {
4965
5120
  },
4966
5121
  async execute(args) {
4967
5122
  const key = await resolveKey();
4968
- return runCmduse(args.arg ?? "", { env: { CMD_API_KEY: key } });
5123
+ return runCmduse(args.arg ?? "", {
5124
+ env: { CMD_API_KEY: key }
5125
+ });
4969
5126
  }
4970
5127
  })
4971
5128
  }