Files
hyperframes/packages/cli/src/commands/usage.ts
Miguel Ángel 7348933111 feat(cli): expose harness subscription usage to agents (#4919)
* feat(cli): plan video creation around remaining harness usage

* feat(cli): read Codex and Grok subscription allowances

* test(cli): load usage fixtures through portable file URLs

* test(cli): keep fixture writes on filesystem paths

* refactor(cli): separate usage window and login decisions

* fix(cli): guard parsed credential array entries

* refactor(cli): report harness usage without workflow policy

* fix(cli): preserve usage when subscription tier is null

* test(cli): separate usage fixture code from inputs

* style(cli): format usage transport fixture

* refactor(cli): isolate usage fixture credential checks
2026-10-03 00:25:43 +00:00

32 lines
1.0 KiB
TypeScript

import { defineCommand } from "citty";
import { readHarnessUsage } from "../utils/harnessUsage.js";
export default defineCommand({
meta: {
name: "usage",
description: "Read remaining harness subscription usage without telemetry",
},
args: {
harness: {
type: "string",
description:
"Harness to read (claude-code, codex, grok); otherwise detect the current harness",
},
json: { type: "boolean", description: "Print subscription usage as JSON", default: false },
},
async run({ args }) {
const harness = args.harness ?? detectHarness();
const usage = await readHarnessUsage(harness);
if (args.json) console.log(JSON.stringify(usage));
else if (usage.status === "unknown") console.log(`Usage unknown (${usage.reason}).`);
else console.log(JSON.stringify(usage, null, 2));
},
});
function detectHarness(): string {
if (process.env.CODEX_THREAD_ID) return "codex";
if (process.env.GROK_AGENT === "1") return "grok";
if (process.env.CLAUDECODE) return "claude-code";
return "unknown";
}