@jeffreyjyz/opencode-command-code 0.1.2 → 0.1.3

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/gating.d.ts CHANGED
@@ -11,3 +11,7 @@ export declare const PLAN_RULES: Record<string, {
11
11
  * tracks category via serving lane, not per-model plan entitlements. */
12
12
  export declare const HARD_BLOCKED: Record<string, string[]>;
13
13
  export declare function canonicalizeModelId(model: string): string;
14
+ /** Bare model id with any provider qualifier stripped: everything after the
15
+ * FIRST colon ("anthropic:claude-opus-5" → "claude-opus-5"). Matches
16
+ * cmduse-core's `bare_model`; a model id that itself contains ':' keeps it. */
17
+ export declare function bareModel(blocked: string): string;
package/dist/index.js CHANGED
@@ -325,6 +325,10 @@ function canonicalizeModelId(model) {
325
325
  return findKnown(aliased) ?? model;
326
326
  return findKnown(stripDate(model)) ?? model;
327
327
  }
328
+ function bareModel(blocked) {
329
+ const i = blocked.indexOf(":");
330
+ return i >= 0 ? blocked.slice(i + 1) : blocked;
331
+ }
328
332
 
329
333
  // src/access.ts
330
334
  function evaluateModelAccess(model, plan) {
@@ -342,10 +346,7 @@ function evaluateModelAccess(model, plan) {
342
346
  const category = MODEL_CATEGORIES[canonical] ?? siblingCategory(canonical);
343
347
  if (!category)
344
348
  return { allowed: true };
345
- const blocked = rules.blockedModels.some((b) => {
346
- const bare = b.includes(":") ? b.slice(b.indexOf(":") + 1) : b;
347
- return bare.toLowerCase() === canonical.toLowerCase();
348
- });
349
+ const blocked = rules.blockedModels.some((b) => bareModel(b).toLowerCase() === canonical.toLowerCase());
349
350
  if (blocked)
350
351
  return { allowed: false };
351
352
  if (!rules.allowedCategories.includes(category))
@@ -393,11 +394,11 @@ async function loadModels(key) {
393
394
  contextLength: m.context_length ?? 0
394
395
  }));
395
396
  cache = { at: Date.now(), models };
396
- } catch {
397
+ } catch (e) {
397
398
  if (cache) {
398
399
  models = cache.models;
399
400
  } else {
400
- throw new Error("Could not fetch Command Code model list (https://api.commandcode.ai/provider/v1/models). Check network/API key.");
401
+ throw new Error("Could not fetch Command Code model list (https://api.commandcode.ai/provider/v1/models). Check network/API key.", { cause: e });
401
402
  }
402
403
  }
403
404
  }
@@ -662,8 +663,14 @@ var CommandCodePlugin = async (_input) => {
662
663
  let openKey;
663
664
  try {
664
665
  openKey = await resolveKey();
665
- split = await loadModels(openKey);
666
666
  } catch {}
667
+ if (openKey) {
668
+ try {
669
+ split = await loadModels(openKey);
670
+ } catch (e) {
671
+ console.warn("[command-code] model list unavailable:", e);
672
+ }
673
+ }
667
674
  const claudeDefs = split ? toModelDefs(split.claude, "command-code-anthropic", "@ai-sdk/anthropic") : {};
668
675
  const openDefs = split ? toModelDefs(split.open, "command-code-openai", "@ai-sdk/openai-compatible", { field: "reasoning_content" }) : {};
669
676
  const userAnthropic = existing("command-code-anthropic");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffreyjyz/opencode-command-code",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",