@jeffreyjyz/opencode-command-code 0.1.0 → 0.1.1

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/dist/index.js +26 -28
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -496,12 +496,12 @@ function plansTable(current) {
496
496
  ["max-20", "Max 20x", "$200", "$300", "$90", "$180"],
497
497
  ["team-pro", "Team Pro", "$40", "$40", "$12", "$24"]
498
498
  ];
499
- const cur = current.toLowerCase();
499
+ const mine = planName(current);
500
500
  let out = `| Plan | Price | Credits/mo | 5-hour | Weekly |
501
501
  |---|---|---|---|---|
502
502
  `;
503
- for (const [id, name, price, monthly, h5, wk] of plans) {
504
- const mark = cur.includes(id) ? "**" : "";
503
+ for (const [_id, name, price, monthly, h5, wk] of plans) {
504
+ const mark = name === mine ? "**" : "";
505
505
  out += `| ${mark}${name}${mark} | ${price}/mo | ${monthly} | ${h5} | ${wk} |
506
506
  `;
507
507
  }
@@ -592,18 +592,18 @@ function toModelDefs(models, providerID, npm) {
592
592
  var CommandCodePlugin = async (_input) => {
593
593
  return {
594
594
  auth: {
595
- provider: "command-code",
595
+ provider: "command-code-anthropic",
596
596
  loader: async (getAuth) => {
597
597
  const auth = await getAuth();
598
598
  if (auth?.type !== "api") {
599
- throw new Error("No API key available. Please run '/connect' and choose Command Code.");
599
+ throw new Error("No API key available. Please run '/connect' and choose Command Code (Anthropic).");
600
600
  }
601
601
  return { apiKey: auth.key, baseURL: PROVIDER_BASE };
602
602
  },
603
603
  methods: [
604
604
  {
605
605
  type: "api",
606
- label: "Command Code API key",
606
+ label: "Command Code API key (Claude / Anthropic)",
607
607
  prompts: [
608
608
  {
609
609
  type: "text",
@@ -619,7 +619,7 @@ var CommandCodePlugin = async (_input) => {
619
619
  const me = await whoami(key);
620
620
  if (!me.success)
621
621
  return { type: "failed" };
622
- return { type: "success", key, provider: "command-code" };
622
+ return { type: "success", key, provider: "command-code-anthropic" };
623
623
  } catch {
624
624
  return { type: "failed" };
625
625
  }
@@ -631,48 +631,46 @@ var CommandCodePlugin = async (_input) => {
631
631
  cfg.provider ??= {};
632
632
  const existing = (id) => cfg.provider?.[id] ?? {};
633
633
  let split;
634
- try {
635
- split = await loadModels(await resolveKey());
636
- } catch {}
637
- const claudeDefs = split ? toModelDefs(split.claude, "command-code", "@ai-sdk/anthropic") : {};
638
- const openDefs = split ? toModelDefs(split.open, "command-code-open", "@ai-sdk/openai-compatible") : {};
639
- const userCc = existing("command-code");
640
- cfg.provider["command-code"] = {
641
- npm: userCc.options ? undefined : "@ai-sdk/anthropic",
642
- name: "Command Code",
643
- options: { baseURL: PROVIDER_BASE, ...userCc.options },
644
- models: { ...claudeDefs, ...userCc.models }
645
- };
646
- const userOpen = existing("command-code-open");
647
634
  let openKey;
648
635
  try {
649
636
  openKey = await resolveKey();
637
+ split = await loadModels(openKey);
650
638
  } catch {}
651
- cfg.provider["command-code-open"] = {
652
- npm: "@ai-sdk/openai-compatible",
653
- name: userOpen.options ? undefined : "Command Code (Open)",
639
+ const claudeDefs = split ? toModelDefs(split.claude, "command-code-anthropic", "@ai-sdk/anthropic") : {};
640
+ const openDefs = split ? toModelDefs(split.open, "command-code-openai", "@ai-sdk/openai-compatible") : {};
641
+ const userAnthropic = existing("command-code-anthropic");
642
+ cfg.provider["command-code-anthropic"] = {
643
+ npm: userAnthropic.options ? undefined : "@ai-sdk/anthropic",
644
+ name: "Command Code (Anthropic)",
645
+ options: { baseURL: PROVIDER_BASE, ...userAnthropic.options },
646
+ models: { ...claudeDefs, ...userAnthropic.models }
647
+ };
648
+ const userOpenai = existing("command-code-openai");
649
+ cfg.provider["command-code-openai"] = {
650
+ npm: userOpenai.options ? undefined : "@ai-sdk/openai-compatible",
651
+ name: userOpenai.options ? undefined : "Command Code (OpenAI)",
654
652
  options: {
655
653
  baseURL: PROVIDER_BASE,
656
654
  ...openKey ? { apiKey: openKey } : {},
657
- ...userOpen.options
655
+ ...userOpenai.options
658
656
  },
659
- models: { ...openDefs, ...userOpen.models }
657
+ models: { ...openDefs, ...userOpenai.models }
660
658
  };
661
659
  cfg.command ??= {};
662
660
  cfg.command["cmd-usage"] = {
663
661
  description: "Show Command Code plan, credits, and usage windows",
664
- template: "Call the cmd_usage tool and present its markdown output verbatim to the user. If the tool errors, tell the user to run /connect (Command Code) and retry. $ARGUMENTS"
662
+ template: "Call the cmd_usage tool and present its markdown output verbatim to the user. If the tool errors, tell the user to run /connect (Command Code (Anthropic)) and retry. $ARGUMENTS"
665
663
  };
666
664
  },
667
665
  provider: {
668
- id: "command-code",
666
+ id: "command-code-anthropic",
669
667
  models: async (_provider, ctx) => {
670
668
  const key = await resolveKey(async () => {
671
669
  const a = ctx.auth;
672
670
  return a?.type === "api" && a.key ? { key: a.key } : undefined;
673
671
  });
674
672
  const split = await loadModels(key);
675
- return toModelDefs(split.claude, "command-code", "@ai-sdk/anthropic");
673
+ return toModelDefs(split.claude, "command-code-anthropic", "@ai-sdk/anthropic");
676
674
  }
677
675
  },
678
676
  tool: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffreyjyz/opencode-command-code",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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",