@jeffreyjyz/opencode-command-code 0.3.19 → 0.5.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/access.d.ts +2 -1
- package/dist/api.d.ts +0 -1
- package/dist/cli.d.ts +14 -0
- package/dist/constants/binaries.d.ts +6 -0
- package/dist/constants/cli.d.ts +17 -0
- package/dist/constants/endpoints.d.ts +6 -0
- package/dist/constants/gating.d.ts +22 -0
- package/dist/constants/models.d.ts +29 -0
- package/dist/constants/paths.d.ts +18 -0
- package/dist/constants/providers.d.ts +32 -0
- package/dist/constants/sidebar.d.ts +33 -0
- package/dist/constants/timing.d.ts +13 -0
- package/dist/gating.d.ts +1 -19
- package/dist/index.d.ts +2 -2
- package/dist/index.js +237 -77
- package/dist/provider/index.d.ts +0 -1
- package/dist/sidebar/data.d.ts +13 -10
- package/dist/sidebar/prefs.d.ts +5 -3
- package/dist/sidebar/rows.d.ts +17 -4
- package/dist/sidebar/windows.d.ts +0 -4
- package/dist/sidebar/zen.d.ts +0 -6
- package/dist/tui.d.ts +1 -1
- package/dist/tui.js +141 -71
- package/dist/v2.d.ts +2 -16
- package/package.json +2 -2
package/dist/access.d.ts
CHANGED
package/dist/api.d.ts
CHANGED
package/dist/cli.d.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* the homebrew prefix, so the bare name alone is not enough. `CMDUSE_BIN` wins
|
|
3
3
|
* when set — the dev-build hook the sibling cmduse consumers (mpc) honour too. */
|
|
4
4
|
export declare function cmduseCandidates(env?: Record<string, string | undefined>): string[];
|
|
5
|
+
/** Same lookup for mpc, the per-model price comparison: `MPC_BIN`
|
|
6
|
+
* wins when set (the `bun link` dev hook oc-cmd-compare installs),
|
|
7
|
+
* then the bun/homebrew fallbacks. */
|
|
8
|
+
export declare function mpcCandidates(env?: Record<string, string | undefined>): string[];
|
|
5
9
|
/** Shell-words split: whitespace-separated, with single/double quoting and
|
|
6
10
|
* backslash escapes ("--tz +05:30", arg='a b'). Unterminated quotes close at
|
|
7
11
|
* end of input. */
|
|
@@ -10,6 +14,10 @@ export declare function splitCliArgs(input: string): string[];
|
|
|
10
14
|
* pass-through flags, or a subcommand invocation ("plans",
|
|
11
15
|
* "--tz +05:30 daily") passed through untouched. */
|
|
12
16
|
export declare function buildCmduseArgs(arg: string): string[];
|
|
17
|
+
/** argv for an mpc invocation: mpc has no subcommands, so the arg
|
|
18
|
+
* string is split and passed straight through; an empty arg means
|
|
19
|
+
* the fewest-columns view (see MPC_DEFAULT_ARGS). */
|
|
20
|
+
export declare function buildMpcArgs(arg: string): string[];
|
|
13
21
|
export type RunOptions = {
|
|
14
22
|
signal?: AbortSignal;
|
|
15
23
|
/** Extra env for the child (CMD_API_KEY when the plugin resolved one). */
|
|
@@ -21,3 +29,9 @@ export type RunOptions = {
|
|
|
21
29
|
* homebrew locations; every candidate failing with ENOENT yields a single
|
|
22
30
|
* install-hint error. */
|
|
23
31
|
export declare function runCmduse(arg: string, opts?: RunOptions): Promise<string>;
|
|
32
|
+
/** Run mpc and return its plain-text stdout (the per-model price
|
|
33
|
+
* comparison). Same contract as runCmduse: `MPC_BIN` wins, then the
|
|
34
|
+
* fallback paths; every candidate failing with ENOENT yields a
|
|
35
|
+
* single install-hint error, and any other failure (a non-zero exit
|
|
36
|
+
* included) surfaces immediately with mpc's last stderr lines. */
|
|
37
|
+
export declare function runMpc(arg: string, opts?: RunOptions): Promise<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Fallback lookup paths for the cmduse CLI (CMDUSE_BIN wins when set). */
|
|
2
|
+
export declare const CMDUSE_BIN_CANDIDATES: readonly string[];
|
|
3
|
+
/** Fallback lookup paths for mpc, the per-model catalog scraper. */
|
|
4
|
+
export declare const MPC_BIN_CANDIDATES: readonly string[];
|
|
5
|
+
/** Fallback lookup paths for ocuse (OCUSE_BIN wins when set). */
|
|
6
|
+
export declare const OCUSE_BIN_CANDIDATES: readonly string[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { spawn } from "node:child_process";
|
|
2
|
+
/** Default invocation: one-shot dashboard, no colors / no live redraw. */
|
|
3
|
+
export declare const DEFAULT_ARGS: readonly string[];
|
|
4
|
+
/** Default mpc invocation: the fewest-columns view. mpc has no
|
|
5
|
+
* subcommands to fall back on, so an empty arg must mean the
|
|
6
|
+
* narrowest table — a bare tool call cannot dump a wide comparison
|
|
7
|
+
* into the model's context. */
|
|
8
|
+
export declare const MPC_DEFAULT_ARGS: readonly string[];
|
|
9
|
+
/** cmduse subcommands — when the arg starts with one, pass it through
|
|
10
|
+
* untouched; otherwise it is extra flags for the one-shot dashboard. */
|
|
11
|
+
export declare const SUBCOMMANDS: ReadonlySet<string>;
|
|
12
|
+
/** `detached` is load-bearing, not tidiness: it starts the child in its own
|
|
13
|
+
* session, so it has no controlling terminal. cmduse's snapshot() paints a
|
|
14
|
+
* "fetching usage…" spinner straight to /dev/tty — piping stdout/stderr does
|
|
15
|
+
* not stop it — which would corrupt the opencode TUI this process inherits its
|
|
16
|
+
* tty from. Detaching makes that open fail; stdout/stderr stay piped. */
|
|
17
|
+
export declare const SPAWN_OPTIONS: Parameters<typeof spawn>[2];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Command Code account/billing API. */
|
|
2
|
+
export declare const API_BASE = "https://api.commandcode.ai";
|
|
3
|
+
/** Provider (inference) API root; the lanes append their wire path. */
|
|
4
|
+
export declare const PROVIDER_BASE = "https://api.commandcode.ai/provider/v1";
|
|
5
|
+
/** Default provider base URL used when the host passes none. */
|
|
6
|
+
export declare const DEFAULT_BASE_URL = "https://api.commandcode.ai";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Category } from "../gating";
|
|
2
|
+
/** model id -> category (models absent from this table have unknown category) */
|
|
3
|
+
export declare const MODEL_CATEGORIES: Record<string, Category>;
|
|
4
|
+
/** planId -> access rules; plan ids absent from this table get everything */
|
|
5
|
+
export declare const PLAN_RULES: Record<string, {
|
|
6
|
+
allowedCategories: Category[];
|
|
7
|
+
blockedModels: string[];
|
|
8
|
+
}>;
|
|
9
|
+
/** Models the API hard-blocks (403 MODEL_NOT_IN_PLAN) per plan, beyond the
|
|
10
|
+
* category rules. Empirically probed — the CLI bundle misses these because it
|
|
11
|
+
* tracks category via serving lane, not per-model plan entitlements. */
|
|
12
|
+
export declare const HARD_BLOCKED: Record<string, string[]>;
|
|
13
|
+
/** canonical known model ids (lowercase compare) */
|
|
14
|
+
export declare const KNOWN_MODELS: string[];
|
|
15
|
+
/** deprecated/aliased model id -> canonical id */
|
|
16
|
+
export declare const MODEL_ALIASES: Record<string, string>;
|
|
17
|
+
/** ISO timestamp the snapshot was extracted (absent on pre-metadata files). */
|
|
18
|
+
export declare const GATE_EXTRACTED_AT: string | undefined;
|
|
19
|
+
/** Command Code CLI version the snapshot was scraped from. */
|
|
20
|
+
export declare const GATE_CLI_VERSION: string | undefined;
|
|
21
|
+
/** Warn once a process when gating.json is older than this many days. */
|
|
22
|
+
export declare const GATE_STALE_DAYS = 30;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Every Command Code model shares these capabilities; hoisted so each record
|
|
2
|
+
* does not rebuild them. Vision (`attachment` + `input.image`) is applied per
|
|
3
|
+
* model from the generated catalog in the two model builders. */
|
|
4
|
+
export declare const MODEL_CAPABILITIES: {
|
|
5
|
+
temperature: boolean;
|
|
6
|
+
reasoning: boolean;
|
|
7
|
+
attachment: boolean;
|
|
8
|
+
toolcall: boolean;
|
|
9
|
+
input: {
|
|
10
|
+
text: boolean;
|
|
11
|
+
audio: boolean;
|
|
12
|
+
image: boolean;
|
|
13
|
+
video: boolean;
|
|
14
|
+
pdf: boolean;
|
|
15
|
+
};
|
|
16
|
+
output: {
|
|
17
|
+
text: boolean;
|
|
18
|
+
audio: boolean;
|
|
19
|
+
image: boolean;
|
|
20
|
+
video: boolean;
|
|
21
|
+
pdf: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/** Context window advertised when the listing API gives no length. */
|
|
25
|
+
export declare const DEFAULT_CONTEXT_LENGTH = 128000;
|
|
26
|
+
/** Max output tokens advertised per model. */
|
|
27
|
+
export declare const DEFAULT_OUTPUT_TOKENS = 32000;
|
|
28
|
+
/** Provider wire ceiling for a request's max tokens. */
|
|
29
|
+
export declare const DEFAULT_MAX_TOKENS = 64000;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Dir segment under an XDG base that holds our caches/diagnostics. */
|
|
2
|
+
export declare const CACHE_DIR = "command-code";
|
|
3
|
+
/** Live model list disk cache file (under CACHE_DIR). */
|
|
4
|
+
export declare const MODELS_CACHE_FILE = "models.json";
|
|
5
|
+
/** Startup timing log file (under CACHE_DIR). */
|
|
6
|
+
export declare const STARTUP_LOG_FILE = "startup.log";
|
|
7
|
+
/**
|
|
8
|
+
* mpc per-model catalog disk cache file (under CACHE_DIR), one per OpenCode Go
|
|
9
|
+
* plan: mpc bakes the selected plan's per-model allowance into the rows, so a
|
|
10
|
+
* cached catalog is only valid for the plan it was fetched under.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ccCatalogFile(plan: string): string;
|
|
13
|
+
/** opencode's own config/data dir segment. */
|
|
14
|
+
export declare const OPENCODE_DIR = "opencode";
|
|
15
|
+
/** opencode's message store file (under OPENCODE_DIR in the data root). */
|
|
16
|
+
export declare const OPENCODE_DB_FILE = "opencode.db";
|
|
17
|
+
/** Sidebar prefs file (under OPENCODE_DIR in the config root). */
|
|
18
|
+
export declare const PREFS_FILE = "command-code.json";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Provider-id prefix shared by both Command Code lanes and the plugin id. */
|
|
2
|
+
export declare const PROVIDER_ID_PREFIX = "command-code";
|
|
3
|
+
/** Plugin id (stable contract; the v2 `setup` definition and the TUI share it). */
|
|
4
|
+
export declare const PLUGIN_ID = "command-code";
|
|
5
|
+
/** Integration id backing both lanes' credentials (/connect + env). */
|
|
6
|
+
export declare const INTEGRATION_ID = "command-code";
|
|
7
|
+
/** Display name for the integration and the no-key warning. */
|
|
8
|
+
export declare const INTEGRATION_NAME = "Command Code";
|
|
9
|
+
/** OpenCode Go provider id (ocuse reads its store). */
|
|
10
|
+
export declare const GO_PROVIDER_ID = "opencode-go";
|
|
11
|
+
/** OpenCode Zen provider id and its `opencode-zen` alias prefix. */
|
|
12
|
+
export declare const ZEN_PROVIDER_ID = "opencode";
|
|
13
|
+
export declare const ZEN_PROVIDER_PREFIX = "opencode-zen";
|
|
14
|
+
/** TUI plugin id (stable contract; test/tui.test.ts pins it). */
|
|
15
|
+
export declare const TUI_ID = "command-code.tui";
|
|
16
|
+
/** The cmd_usage tool description, shared by the v1 and v2 halves. */
|
|
17
|
+
export declare const 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').";
|
|
18
|
+
/** The mpc_prices tool description, shared by the v1 and v2 halves. */
|
|
19
|
+
export declare const MPC_TOOL_DESCRIPTION = "Per-model price comparison: what a model costs per request ($/1M input, output and cache rates) and per month (request allowance) on each Command Code (cc) and OpenCode Go (oc) plan side, plus ability, Tok/s, the cheaper-side verdict and running deals. Pass '--model <regex>' to filter rows, '--minimal' | '--medium' | '--detail' for table width, '--json' for the full structured rows, '--cc-plan' / '--oc-plan' to pick a plan, or '--usage' to project real usage.";
|
|
20
|
+
/** The mpc_prices `arg` description, shared by the v1 and v2 halves. */
|
|
21
|
+
export declare const MPC_TOOL_ARG_DESCRIPTION = "Optional mpc flags: '--model <regex>' filters rows, '--minimal' | '--medium' | '--detail' set table width, '--json' for full structured rows, '--cc-plan'/'--oc-plan' pick a plan, '--usage' projects real usage";
|
|
22
|
+
export type Lane = {
|
|
23
|
+
id: "command-code-anthropic" | "command-code-openai";
|
|
24
|
+
name: string;
|
|
25
|
+
/** v2 runtime package (first-party, distinct from the v1 `npm` value). */
|
|
26
|
+
pkg: string;
|
|
27
|
+
/** Wire field reasoning must round-trip through on the openai-compatible
|
|
28
|
+
* lane; v2 spells the old `interleaved: {field}` as `compatibility`. */
|
|
29
|
+
reasoningField?: string;
|
|
30
|
+
};
|
|
31
|
+
/** The Anthropic and OpenAI-compatible provider lanes this plugin owns. */
|
|
32
|
+
export declare const LANES: [Lane, Lane];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Category } from "../gating";
|
|
2
|
+
import type { Prefs } from "../sidebar/prefs";
|
|
3
|
+
/**
|
|
4
|
+
* The sidebar is 42 columns wide with 2+2 padding, and our panel keeps one more
|
|
5
|
+
* column clear on the right, so a rendered row must stay within this. Rows that
|
|
6
|
+
* cannot fit are split across an indented continuation rather than wrapping in
|
|
7
|
+
* the host's renderer, which is what made the panel look broken.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ROW_WIDTH = 37;
|
|
10
|
+
/** Tier label per gating category. */
|
|
11
|
+
export declare const TIER_DISPLAY: Readonly<Record<Category, string>>;
|
|
12
|
+
/**
|
|
13
|
+
* OpenCode Go plans the panel can render: the same token rates, different
|
|
14
|
+
* per-model monthly limits. Which one a user is on is not discoverable (Go has
|
|
15
|
+
* no usage API and the store records no subscription), so it is a setting.
|
|
16
|
+
*/
|
|
17
|
+
export declare const OC_PLANS: readonly ["go", "go-plus"];
|
|
18
|
+
export type OcPlan = (typeof OC_PLANS)[number];
|
|
19
|
+
/** Plan used when the user has not set one: behaviour is unchanged for them. */
|
|
20
|
+
export declare const OC_PLAN_DEFAULT: OcPlan;
|
|
21
|
+
/** Go's documented per-model window shares of the monthly allowance. */
|
|
22
|
+
export declare const GO_WINDOW_SHARE: {
|
|
23
|
+
readonly fiveHour: 0.2;
|
|
24
|
+
readonly weekly: 0.5;
|
|
25
|
+
readonly month: 1;
|
|
26
|
+
};
|
|
27
|
+
/** 5-hour window length in seconds. Mirrors cmduse_core::FIVE_HOUR_SECS. */
|
|
28
|
+
export declare const FIVE_HOUR_SECS: number;
|
|
29
|
+
/** Weekly window length in seconds. Mirrors cmduse_core::WEEKLY_SECS. */
|
|
30
|
+
export declare const WEEKLY_SECS: number;
|
|
31
|
+
/** Colour is OFF unless asked for; the OpenCode Go plan defaults to `go` (see
|
|
32
|
+
* sidebar/prefs.ts). */
|
|
33
|
+
export declare const PREF_DEFAULTS: Prefs;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Sidebar poll cadence: one cmduse/ocuse spawn plus the local store reads. */
|
|
2
|
+
export declare const POLL_MS = 5000;
|
|
3
|
+
/** How long one sidebar CLI spawn may run before it is killed. An outage can
|
|
4
|
+
* leave a fetch hanging through cmduse's retry ladder, and the poll interval
|
|
5
|
+
* would otherwise stack spawns on top of each other. */
|
|
6
|
+
export declare const CHILD_TIMEOUT_MS = 30000;
|
|
7
|
+
/** Process-lifetime cache for the live model list (src/models.ts). */
|
|
8
|
+
export declare const MODELS_CACHE_TTL_MS: number;
|
|
9
|
+
/** Disk cache for mpc's per-model catalog (src/sidebar/data.ts). An hour, not
|
|
10
|
+
* six: a running panel then picks up new models and promotions. */
|
|
11
|
+
export declare const CATALOG_CACHE_TTL_MS: number;
|
|
12
|
+
/** Re-read window for the sidebar colour prefs file (src/sidebar/prefs.ts). */
|
|
13
|
+
export declare const PREFS_CACHE_MS = 5000;
|
package/dist/gating.d.ts
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
export type Category = "opensource" | "premium";
|
|
2
|
-
/**
|
|
3
|
-
export declare const MODEL_CATEGORIES: Record<string, Category>;
|
|
4
|
-
/** planId -> access rules; plan ids absent from this table get everything */
|
|
5
|
-
export declare const PLAN_RULES: Record<string, {
|
|
6
|
-
allowedCategories: Category[];
|
|
7
|
-
blockedModels: string[];
|
|
8
|
-
}>;
|
|
9
|
-
/** Models the API hard-blocks (403 MODEL_NOT_IN_PLAN) per plan, beyond the
|
|
10
|
-
* category rules. Empirically probed — the CLI bundle misses these because it
|
|
11
|
-
* tracks category via serving lane, not per-model plan entitlements. */
|
|
12
|
-
export declare const HARD_BLOCKED: Record<string, string[]>;
|
|
13
|
-
/** canonical known model ids (lowercase compare) */
|
|
14
|
-
declare const KNOWN_MODELS: string[];
|
|
15
|
-
export { KNOWN_MODELS };
|
|
16
|
-
/** ISO timestamp the snapshot was extracted (absent on pre-metadata files). */
|
|
17
|
-
export declare const GATE_EXTRACTED_AT: string | undefined;
|
|
18
|
-
/** Command Code CLI version the snapshot was scraped from. */
|
|
19
|
-
export declare const GATE_CLI_VERSION: string | undefined;
|
|
20
|
-
/** Warn once per process when gating.json is older than 30 days. */
|
|
2
|
+
/** Warn once per process when gating.json is older than GATE_STALE_DAYS. */
|
|
21
3
|
export declare function warnIfGatingStale(): void;
|
|
22
4
|
export declare function canonicalizeModelId(model: string): string;
|
|
23
5
|
/** Bare model id with any provider qualifier stripped: everything after the
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { Plugin as PluginV1 } from "@opencode-ai/plugin";
|
|
|
2
2
|
export declare const CommandCodePlugin: PluginV1;
|
|
3
3
|
export { createCommandCode } from "./provider";
|
|
4
4
|
declare const _default: {
|
|
5
|
-
/** v1 entrypoint (opencode >=1.18.29 object entrypoints). */
|
|
6
|
-
server: PluginV1;
|
|
7
5
|
id: string;
|
|
8
6
|
setup: (context: import("@opencode/plugin/promise/plugin").Context) => Promise<import("@opencode/plugin/promise/plugin").Cleanup | void> | import("@opencode/plugin/promise/plugin").Cleanup | void;
|
|
7
|
+
/** v1 entrypoint (opencode >=1.18.29 object entrypoints). */
|
|
8
|
+
server: PluginV1;
|
|
9
9
|
};
|
|
10
10
|
export default _default;
|