@jeffreyjyz/opencode-command-code 0.2.7 → 0.2.8

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.
@@ -1,4 +1,11 @@
1
+ import { spawn } from "node:child_process";
1
2
  import { type ModelMeta, type Usage } from "./rows";
3
+ /** `detached` is load-bearing, not tidiness: it starts the child in its own
4
+ * session, so it has no controlling terminal. cmduse's snapshot() paints a
5
+ * "fetching usage…" spinner straight to /dev/tty — piping stdout/stderr does
6
+ * not stop it — which would corrupt the opencode TUI this process inherits its
7
+ * tty from. Detaching makes that open fail; stdout/stderr stay piped. */
8
+ export declare const SPAWN_OPTIONS: Parameters<typeof spawn>[2];
2
9
  /** Parse `cmduse -1 --json` into the usage snapshot. */
3
10
  export declare function parseUsageJson(text: string): Usage;
4
11
  /** Parse `mpc --json` into per-model meta, CommandCode side only. */
package/dist/tui.js CHANGED
@@ -9,7 +9,7 @@ import { createTextNode as _$createTextNode } from "@opentui/solid";
9
9
  import { insertNode as _$insertNode } from "@opentui/solid";
10
10
  import { createElement as _$createElement } from "@opentui/solid";
11
11
  import { Plugin } from "@opencode/plugin/tui";
12
- import { For, Show, createMemo, createSignal, onCleanup } from "solid-js";
12
+ import { For, Show, createEffect, createMemo, createSignal, onCleanup } from "solid-js";
13
13
 
14
14
  // src/cli.ts
15
15
  import { spawn } from "child_process";
@@ -493,15 +493,17 @@ function tierFor(modelId) {
493
493
  var CMDUSE = ["cmduse", "/opt/homebrew/bin/cmduse", "/usr/local/bin/cmduse"];
494
494
  var MPC = ["mpc", join(homedir(), ".bun/bin/mpc"), "/opt/homebrew/bin/mpc"];
495
495
  var CACHE_TTL_MS = 6 * 60 * 60 * 1000;
496
+ var SPAWN_OPTIONS = {
497
+ stdio: ["ignore", "pipe", "pipe"],
498
+ detached: true
499
+ };
496
500
  function run(bin, args) {
497
501
  return new Promise((resolve, reject) => {
498
- const child = spawn2(bin, args, {
499
- stdio: ["ignore", "pipe", "pipe"]
500
- });
502
+ const child = spawn2(bin, args, SPAWN_OPTIONS);
501
503
  const out = [];
502
504
  const err = [];
503
- child.stdout.on("data", (d) => out.push(d));
504
- child.stderr.on("data", (d) => err.push(d));
505
+ child.stdout?.on("data", (d) => out.push(d));
506
+ child.stderr?.on("data", (d) => err.push(d));
505
507
  child.on("error", reject);
506
508
  child.on("close", (code) => code === 0 ? resolve(Buffer.concat(out).toString("utf8")) : reject(new Error(`${bin} ${args.join(" ")}: exit ${code} ${Buffer.concat(err).toString("utf8").slice(-200)}`)));
507
509
  });
@@ -632,9 +634,13 @@ function useRows(activeModelId, active) {
632
634
  setUsage(usageRows(await loadUsage()));
633
635
  } catch {}
634
636
  };
635
- refresh();
636
- const timer = setInterval(() => void refresh(), POLL_MS);
637
- onCleanup(() => clearInterval(timer));
637
+ createEffect(() => {
638
+ if (!active())
639
+ return;
640
+ refresh();
641
+ const timer = setInterval(() => void refresh(), POLL_MS);
642
+ onCleanup(() => clearInterval(timer));
643
+ });
638
644
  return createMemo(() => {
639
645
  if (!active())
640
646
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffreyjyz/opencode-command-code",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
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",