@jeffreyjyz/opencode-command-code 0.5.21 → 0.5.22

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.5.21",
2417
+ version: "0.5.22",
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",
@@ -2446,7 +2446,6 @@ var package_default = {
2446
2446
  },
2447
2447
  files: [
2448
2448
  "dist",
2449
- "tui.js",
2450
2449
  "LICENSE"
2451
2450
  ],
2452
2451
  keywords: [
@@ -3362,7 +3361,13 @@ function runOnce(bin, args, opts, name = "cmduse") {
3362
3361
  if (settled)
3363
3362
  return;
3364
3363
  settled = true;
3365
- child.kill();
3364
+ child.stdout.removeAllListeners("data");
3365
+ child.stderr.removeAllListeners("data");
3366
+ child.removeAllListeners("error");
3367
+ child.removeAllListeners("close");
3368
+ child.kill("SIGTERM");
3369
+ const killTimer = setTimeout(() => child.kill("SIGKILL"), 3000);
3370
+ killTimer.unref();
3366
3371
  reject(new Error(`${name} ${args.join(" ")}: timed out after ${opts.timeoutMs}ms`));
3367
3372
  }, opts.timeoutMs);
3368
3373
  const onAbort = () => child.kill("SIGTERM");
@@ -3374,6 +3379,10 @@ function runOnce(bin, args, opts, name = "cmduse") {
3374
3379
  if (timer)
3375
3380
  clearTimeout(timer);
3376
3381
  opts.signal?.removeEventListener("abort", onAbort);
3382
+ child.stdout.removeAllListeners("data");
3383
+ child.stderr.removeAllListeners("data");
3384
+ child.removeAllListeners("error");
3385
+ child.removeAllListeners("close");
3377
3386
  fn();
3378
3387
  };
3379
3388
  child.stdout.on("data", (d) => out.push(d));
@@ -3616,9 +3625,7 @@ var gating_default = {
3616
3625
  },
3617
3626
  plans: {
3618
3627
  "individual-go": {
3619
- allowedCategories: [
3620
- "opensource"
3621
- ],
3628
+ allowedCategories: ["opensource"],
3622
3629
  blockedModels: [
3623
3630
  "vercel-ai-gateway:meta/muse-spark-1.2",
3624
3631
  "vercel-ai-gateway:meta/muse-spark-1.3",
@@ -3632,9 +3639,7 @@ var gating_default = {
3632
3639
  ]
3633
3640
  },
3634
3641
  "individual-go-v1": {
3635
- allowedCategories: [
3636
- "opensource"
3637
- ],
3642
+ allowedCategories: ["opensource"],
3638
3643
  blockedModels: [
3639
3644
  "vercel-ai-gateway:meta/muse-spark-1.2",
3640
3645
  "vercel-ai-gateway:meta/muse-spark-1.3",
@@ -3648,16 +3653,11 @@ var gating_default = {
3648
3653
  ]
3649
3654
  },
3650
3655
  "individual-goat": {
3651
- allowedCategories: [
3652
- "opensource"
3653
- ],
3656
+ allowedCategories: ["opensource"],
3654
3657
  blockedModels: []
3655
3658
  },
3656
3659
  "individual-pro": {
3657
- allowedCategories: [
3658
- "premium",
3659
- "opensource"
3660
- ],
3660
+ allowedCategories: ["premium", "opensource"],
3661
3661
  blockedModels: [
3662
3662
  "anthropic:claude-fable-5-1",
3663
3663
  "anthropic:claude-fable-5",
@@ -3673,10 +3673,7 @@ var gating_default = {
3673
3673
  ]
3674
3674
  },
3675
3675
  "individual-pro-v1": {
3676
- allowedCategories: [
3677
- "premium",
3678
- "opensource"
3679
- ],
3676
+ allowedCategories: ["premium", "opensource"],
3680
3677
  blockedModels: [
3681
3678
  "anthropic:claude-fable-5-1",
3682
3679
  "anthropic:claude-fable-5",
@@ -3692,33 +3689,19 @@ var gating_default = {
3692
3689
  ]
3693
3690
  },
3694
3691
  "individual-provider": {
3695
- allowedCategories: [
3696
- "premium",
3697
- "opensource"
3698
- ],
3699
- blockedModels: [
3700
- "openai:gpt-6.1-sol"
3701
- ]
3692
+ allowedCategories: ["premium", "opensource"],
3693
+ blockedModels: ["openai:gpt-6.1-sol"]
3702
3694
  },
3703
3695
  "individual-max": {
3704
- allowedCategories: [
3705
- "premium",
3706
- "opensource"
3707
- ],
3696
+ allowedCategories: ["premium", "opensource"],
3708
3697
  blockedModels: []
3709
3698
  },
3710
3699
  "individual-ultra": {
3711
- allowedCategories: [
3712
- "premium",
3713
- "opensource"
3714
- ],
3700
+ allowedCategories: ["premium", "opensource"],
3715
3701
  blockedModels: []
3716
3702
  },
3717
3703
  "teams-pro": {
3718
- allowedCategories: [
3719
- "premium",
3720
- "opensource"
3721
- ],
3704
+ allowedCategories: ["premium", "opensource"],
3722
3705
  blockedModels: []
3723
3706
  }
3724
3707
  },
@@ -4898,6 +4881,9 @@ async function credentialKey(ctx) {
4898
4881
  return;
4899
4882
  }
4900
4883
  }
4884
+ var v2Controller;
4885
+ var v2FirstRefresh;
4886
+ var v2Timer;
4901
4887
  var commandCodeV2 = {
4902
4888
  id: PLUGIN_ID,
4903
4889
  async setup(ctx) {
@@ -4937,7 +4923,7 @@ var commandCodeV2 = {
4937
4923
  }
4938
4924
  const seed = staticSeedModels();
4939
4925
  const cached = await readModelsCache();
4940
- if (cached) {
4926
+ if (cached && typeof cached.fetchedAt === "number" && Date.now() - cached.fetchedAt < MODELS_CACHE_TTL_MS) {
4941
4927
  seed["command-code-anthropic"] = mergeModels(seed["command-code-anthropic"], cached.claude.map((m) => toV2Model(m, LANES[0])));
4942
4928
  seed["command-code-openai"] = mergeModels(seed["command-code-openai"], cached.open.map((m) => toV2Model(m, LANES[1])));
4943
4929
  }
@@ -5069,7 +5055,14 @@ var commandCodeV2 = {
5069
5055
  if (!localKey && !hasConnection) {
5070
5056
  console.warn(`[command-code] no API key found. Run /connect and choose "${INTEGRATION_NAME}", or \`cmd login\` (~/.commandcode/auth.json), or set CMD_API_KEY.`);
5071
5057
  }
5058
+ if (v2Controller)
5059
+ v2Controller.abort();
5060
+ if (v2FirstRefresh)
5061
+ clearTimeout(v2FirstRefresh);
5062
+ if (v2Timer)
5063
+ clearInterval(v2Timer);
5072
5064
  const controller = new AbortController;
5065
+ v2Controller = controller;
5073
5066
  let refreshing = false;
5074
5067
  let appliedClaude = cached?.claude ?? [];
5075
5068
  let appliedOpen = cached?.open ?? [];
@@ -5121,12 +5114,18 @@ var commandCodeV2 = {
5121
5114
  canTransform = true;
5122
5115
  }
5123
5116
  };
5124
- const firstRefresh = setTimeout(() => void refresh(), 3000);
5125
- const timer = setInterval(() => void refresh(), 30 * 60 * 1000);
5117
+ v2FirstRefresh = setTimeout(() => void refresh(), 3000);
5118
+ v2Timer = setInterval(() => void refresh(), 30 * 60 * 1000);
5126
5119
  return () => {
5127
5120
  controller.abort();
5128
- clearTimeout(firstRefresh);
5129
- clearInterval(timer);
5121
+ if (v2FirstRefresh)
5122
+ clearTimeout(v2FirstRefresh);
5123
+ if (v2Timer)
5124
+ clearInterval(v2Timer);
5125
+ if (v2Controller === controller)
5126
+ v2Controller = undefined;
5127
+ v2FirstRefresh = undefined;
5128
+ v2Timer = undefined;
5130
5129
  };
5131
5130
  }
5132
5131
  };
package/dist/tui.js CHANGED
@@ -124,7 +124,13 @@ function runOnce(bin, args, opts, name = "cmduse") {
124
124
  if (settled)
125
125
  return;
126
126
  settled = true;
127
- child.kill();
127
+ child.stdout.removeAllListeners("data");
128
+ child.stderr.removeAllListeners("data");
129
+ child.removeAllListeners("error");
130
+ child.removeAllListeners("close");
131
+ child.kill("SIGTERM");
132
+ const killTimer = setTimeout(() => child.kill("SIGKILL"), 3000);
133
+ killTimer.unref();
128
134
  reject(new Error(`${name} ${args.join(" ")}: timed out after ${opts.timeoutMs}ms`));
129
135
  }, opts.timeoutMs);
130
136
  const onAbort = () => child.kill("SIGTERM");
@@ -138,6 +144,10 @@ function runOnce(bin, args, opts, name = "cmduse") {
138
144
  if (timer)
139
145
  clearTimeout(timer);
140
146
  opts.signal?.removeEventListener("abort", onAbort);
147
+ child.stdout.removeAllListeners("data");
148
+ child.stderr.removeAllListeners("data");
149
+ child.removeAllListeners("error");
150
+ child.removeAllListeners("close");
141
151
  fn();
142
152
  };
143
153
  child.stdout.on("data", (d) => out.push(d));
@@ -345,9 +355,7 @@ var gating_default = {
345
355
  },
346
356
  plans: {
347
357
  "individual-go": {
348
- allowedCategories: [
349
- "opensource"
350
- ],
358
+ allowedCategories: ["opensource"],
351
359
  blockedModels: [
352
360
  "vercel-ai-gateway:meta/muse-spark-1.2",
353
361
  "vercel-ai-gateway:meta/muse-spark-1.3",
@@ -361,9 +369,7 @@ var gating_default = {
361
369
  ]
362
370
  },
363
371
  "individual-go-v1": {
364
- allowedCategories: [
365
- "opensource"
366
- ],
372
+ allowedCategories: ["opensource"],
367
373
  blockedModels: [
368
374
  "vercel-ai-gateway:meta/muse-spark-1.2",
369
375
  "vercel-ai-gateway:meta/muse-spark-1.3",
@@ -377,16 +383,11 @@ var gating_default = {
377
383
  ]
378
384
  },
379
385
  "individual-goat": {
380
- allowedCategories: [
381
- "opensource"
382
- ],
386
+ allowedCategories: ["opensource"],
383
387
  blockedModels: []
384
388
  },
385
389
  "individual-pro": {
386
- allowedCategories: [
387
- "premium",
388
- "opensource"
389
- ],
390
+ allowedCategories: ["premium", "opensource"],
390
391
  blockedModels: [
391
392
  "anthropic:claude-fable-5-1",
392
393
  "anthropic:claude-fable-5",
@@ -402,10 +403,7 @@ var gating_default = {
402
403
  ]
403
404
  },
404
405
  "individual-pro-v1": {
405
- allowedCategories: [
406
- "premium",
407
- "opensource"
408
- ],
406
+ allowedCategories: ["premium", "opensource"],
409
407
  blockedModels: [
410
408
  "anthropic:claude-fable-5-1",
411
409
  "anthropic:claude-fable-5",
@@ -421,33 +419,19 @@ var gating_default = {
421
419
  ]
422
420
  },
423
421
  "individual-provider": {
424
- allowedCategories: [
425
- "premium",
426
- "opensource"
427
- ],
428
- blockedModels: [
429
- "openai:gpt-6.1-sol"
430
- ]
422
+ allowedCategories: ["premium", "opensource"],
423
+ blockedModels: ["openai:gpt-6.1-sol"]
431
424
  },
432
425
  "individual-max": {
433
- allowedCategories: [
434
- "premium",
435
- "opensource"
436
- ],
426
+ allowedCategories: ["premium", "opensource"],
437
427
  blockedModels: []
438
428
  },
439
429
  "individual-ultra": {
440
- allowedCategories: [
441
- "premium",
442
- "opensource"
443
- ],
430
+ allowedCategories: ["premium", "opensource"],
444
431
  blockedModels: []
445
432
  },
446
433
  "teams-pro": {
447
- allowedCategories: [
448
- "premium",
449
- "opensource"
450
- ],
434
+ allowedCategories: ["premium", "opensource"],
451
435
  blockedModels: []
452
436
  }
453
437
  },
@@ -2589,12 +2573,14 @@ async function loadZen(plan = OC_PLAN_DEFAULT) {
2589
2573
  }
2590
2574
  var arkCache;
2591
2575
  async function loadArk() {
2576
+ const key = "default";
2592
2577
  const now = Date.now();
2593
- if (arkCache && now - arkCache.at < ARK_SNAPSHOT_TTL_MS) {
2578
+ if (arkCache && arkCache.key === key && now - arkCache.at < ARK_SNAPSHOT_TTL_MS) {
2594
2579
  return arkCache.usage;
2595
2580
  }
2596
2581
  const usage = parseArkJson(await runArkuse("-1 --json", SIDEBAR_OPTS));
2597
2582
  arkCache = {
2583
+ key,
2598
2584
  at: now,
2599
2585
  usage
2600
2586
  };
@@ -3022,9 +3008,13 @@ function PanelV2(props) {
3022
3008
  colors: () => themed(hostColors(ctx.theme))
3023
3009
  });
3024
3010
  }
3011
+ var tuiSetupSeen = new WeakSet;
3025
3012
  var commandCodeTui = {
3026
3013
  id: TUI_ID,
3027
3014
  setup(ctx) {
3015
+ if (tuiSetupSeen.has(ctx))
3016
+ return;
3017
+ tuiSetupSeen.add(ctx);
3028
3018
  ctx.ui.slot({
3029
3019
  append: "sidebar.content",
3030
3020
  render: (input) => _$createComponent2(PanelV2, {
package/dist/v2.d.ts CHANGED
@@ -29,11 +29,5 @@ type CredentialContext = {
29
29
  * back to CMD_API_KEY / ~/.commandcode/auth.json. Resolved per call — a
30
30
  * /connect mid-session must be picked up. */
31
31
  export declare function credentialKey(ctx: CredentialContext): Promise<string | undefined>;
32
- /**
33
- * opencode validates the plugin *by decoding* the default export against its
34
- * own `Plugin` interface (identity `define` on both sides), so the package is
35
- * only needed for types. Keeps the runtime dependency surface to opencode's
36
- * own rewrite list (@opentui/*, solid-js).
37
- */
38
32
  export declare const commandCodeV2: PluginNs.Plugin;
39
33
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffreyjyz/opencode-command-code",
3
- "version": "0.5.21",
3
+ "version": "0.5.22",
4
4
  "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.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -32,7 +32,6 @@
32
32
  },
33
33
  "files": [
34
34
  "dist",
35
- "tui.js",
36
35
  "LICENSE"
37
36
  ],
38
37
  "keywords": [
package/tui.js DELETED
@@ -1,5 +0,0 @@
1
- // Entry shim for local/directory plugin loading: opencode resolves the TUI
2
- // half as a literal `tui.js` beside the package root (package `exports`
3
- // are only consulted for npm-installed plugins). Keep this file in sync with
4
- // the built ./tui output.
5
- export { default } from "./dist/tui.js";