Repository navigation
[WRONG BRANCH] Add ocx usage compare for previous-window usage totals #7211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,13 @@ Two honesty markers to respect: | |
| - Under `--provider` or `--model`, per-account rows are **withheld** rather than filtered, because | ||
| account totals cannot be honestly re-partitioned by provider. | ||
|
|
||
| ## `ocx usage compare --json` | ||
|
|
||
| CLI envelope `schemaVersion: 1` with `range`, `days`, `filter`, then `current` and `previous` | ||
| (`since`, `until`, `summary`, `usageIncomplete`), plus `delta`, `change` (percent, or `null` when | ||
| the previous value is zero and the current value is not), and `incomplete`. Totals are request, | ||
| token and estimated-cost fields only; use `ocx usage --json` for provider/model/account rows. | ||
|
|
||
|
Comment on lines
+89
to
+95
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Align the documented
📍 Affects 2 files
🤖 Prompt for AI AgentsSource: Path instructions |
||
| ## `ocx account list <provider> --json` | ||
|
|
||
| `accounts[]` with `id`, `email`, `plan`, `paused`, `selected`, `priority`, and `needsReauth`. Quota | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,8 +88,12 @@ actually served it, not only the one requested. | |
|
|
||
| ```bash | ||
| ocx usage --range 7d --json | ||
| ocx usage compare --range 7d --json | ||
| ``` | ||
|
|
||
| `ocx usage compare` reads the named range and the previous equal window. `--range all` is refused. | ||
| `--json` carries `delta` and `change` (percent). The two reads are sequential. | ||
|
|
||
|
Comment on lines
+91
to
+96
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win Move the compare example out of the per-account recipe. Recipe 4 is "Attribute spend per account", and the next line says "Read 🤖 Prompt for AI Agents |
||
| Read `accounts[]`. Two things to respect: | ||
|
|
||
| - A row with `ambiguous: true` (label `legacy-ambiguous`) aggregates several accounts from before | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -447,8 +447,11 @@ export const CLI_COMMANDS: CliCommandEntry[] = [ | |||||||||||||||||||||
| { name: "logs", usage: "ocx logs [filters] [--follow] [--json|--jsonl|--events]", summary: "Read or follow request logs." }, | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| name: "usage", | ||||||||||||||||||||||
| usage: "ocx usage [--range <today|1d|7d|30d|all>] [--surface <all|codex|claude|grok>] [--provider <name>] [--model <id>] [--api-key-id <id>] [--search <text>] [--json]", | ||||||||||||||||||||||
| usage: "ocx usage [--range <today|1d|7d|30d|all>] [--surface <all|codex|claude|grok>] [--provider <name>] [--model <id>] [--api-key-id <id>] [--search <text>] [--json]; ocx usage compare [--range <today|1d|7d|30d>] [--json]", | ||||||||||||||||||||||
| summary: "Report token usage and estimated cost (alias of ocx observe usage).", | ||||||||||||||||||||||
| details: [ | ||||||||||||||||||||||
| "`compare` reads the current named range and the previous equal window; `--range all` is refused.", | ||||||||||||||||||||||
| ], | ||||||||||||||||||||||
|
Comment on lines
+450
to
+454
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Align the registry The Add the missing flags so all three declarations agree. Proposed fix--- "a/src/cli/registry.ts"
+++ "b/src/cli/registry.ts"
@@ -447,7 +447,7 @@
{ name: "logs", usage: "ocx logs [filters] [--follow] [--json|--jsonl|--events]", summary: "Read or follow request logs." },
{
name: "usage",
- usage: "ocx usage [--range <today|1d|7d|30d|all>] [--surface <all|codex|claude|grok>] [--provider <name>] [--model <id>] [--api-key-id <id>] [--search <text>] [--json]; ocx usage compare [--range <today|1d|7d|30d>] [--json]",
+ usage: "ocx usage [--range <today|1d|7d|30d|all>] [--surface <all|codex|claude|grok>] [--provider <name>] [--model <id>] [--api-key-id <id>] [--search <text>] [--json]; ocx usage compare [--range <today|1d|7d|30d>] [--surface <all|codex|claude|grok>] [--provider <name>] [--model <id>] [--api-key-id <id>] [--json]",
summary: "Report token usage and estimated cost (alias of ocx observe usage).",
details: [
"`compare` reads the current named range and the previous equal window; `--range all` is refused.",📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| name: "storage", | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Fix the table row: unescaped pipes break the Markdown table.
The static analysis hint (MD056) reports 5 cells instead of 2. The
|characters inside the code span are parsed as column separators. The preceding row (Line 418) has the same pattern, but this row adds one more. Escape each pipe as\|, or use|.Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.23.3)
[warning] 419-419: Table column count
Expected: 2; Actual: 5; Too many cells, extra data will be missing
(MD056, table-column-count)
🤖 Prompt for AI Agents
Source: Linters/SAST tools