@bli-cockpit/cli 0.2.103 → 0.2.104
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/commands/local-args-tower-usage.js +2 -2
- package/dist/commands/local-help-commands-tower.js +2 -1
- package/dist/commands/local-help.js +1 -1
- package/dist/commands/public-root.js +1 -1
- package/dist/commands/usage-format.js +2 -0
- package/dist/commands/usage.js +30 -1
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { optionalNonEmpty, optionalUrl, parseNamedArgs } from "./local-arg-values.js";
|
|
2
2
|
export function parseUsageArgs(args) {
|
|
3
|
-
const values = parseNamedArgs(args, { allowedFlags: ["--since", "--until", "--include-automated", "--detail", "--home", "--dashboard-url", "--json"], valueFlags: ["--since", "--until", "--home", "--dashboard-url"] });
|
|
3
|
+
const values = parseNamedArgs(args, { allowedFlags: ["--by-repo", "--person", "--all", "--since", "--until", "--include-automated", "--detail", "--home", "--dashboard-url", "--json"], valueFlags: ["--person", "--since", "--until", "--home", "--dashboard-url"] });
|
|
4
4
|
const action = values.positionals[0] ?? "people";
|
|
5
5
|
if (action !== "people" || values.positionals.length > 1)
|
|
6
6
|
throw new Error("usage takes one verb: people.");
|
|
7
|
-
return { kind: "usage", action: "people", since: optionalNonEmpty(values.flags.get("--since")) ?? "30d", until: optionalNonEmpty(values.flags.get("--until")), detail: values.booleans.has("--detail"), includeAutomated: values.booleans.has("--include-automated"), homeDir: optionalNonEmpty(values.flags.get("--home")), dashboardUrl: optionalUrl(values.flags.get("--dashboard-url")), json: values.booleans.has("--json") };
|
|
7
|
+
return { kind: "usage", byRepo: values.booleans.has("--by-repo"), person: optionalNonEmpty(values.flags.get("--person")), all: values.booleans.has("--all"), action: "people", since: optionalNonEmpty(values.flags.get("--since")) ?? "30d", until: optionalNonEmpty(values.flags.get("--until")), detail: values.booleans.has("--detail"), includeAutomated: values.booleans.has("--include-automated"), homeDir: optionalNonEmpty(values.flags.get("--home")), dashboardUrl: optionalUrl(values.flags.get("--dashboard-url")), json: values.booleans.has("--json") };
|
|
8
8
|
}
|
|
@@ -143,8 +143,9 @@ export const TOWER_COMMAND_HELP = [
|
|
|
143
143
|
[
|
|
144
144
|
"usage",
|
|
145
145
|
[
|
|
146
|
-
"Usage: cockpit usage people [--since <n>d|<n>h|<iso>] [--detail] [--until <iso>] [--include-automated] [--json]",
|
|
146
|
+
"Usage: cockpit usage people [--by-repo] [--person <email|me>] [--all] [--since <n>d|<n>h|<iso>] [--detail] [--until <iso>] [--include-automated] [--json]",
|
|
147
147
|
"",
|
|
148
|
+
"--by-repo adds project rows under each person (top 10; --all shows every repo). --person me uses your signed-in email.",
|
|
148
149
|
"Claude Code and Codex usage per person: sessions observed and extracted, tokens (total, output,",
|
|
149
150
|
"and the input / cache split when the row carries it), and an API list-price equivalent that is",
|
|
150
151
|
"labelled as such and is never actual spend. A super_admin sees everyone; a member sees their own row.",
|
|
@@ -102,7 +102,7 @@ export function localCommandHelp(command) {
|
|
|
102
102
|
` cockpit search "<words>" [--kind ${SEARCH_KINDS.join(",")}] [--limit <n>] [--dashboard-url <url>] [--json]`,
|
|
103
103
|
" cockpit release [--dry-run] [--skip-checks] [--no-floor] [--tag <tag>] [--access <public|restricted>] [--otp <code>]",
|
|
104
104
|
" cockpit careers [list|show <id>|rescreen <id>] [--role <slug>] [--min-score <n>] [--since <date>] [--json]",
|
|
105
|
-
" cockpit usage people [--since
|
|
105
|
+
" cockpit usage people [--by-repo] [--person <email|me>] [--all] [--detail] [--since <n>d|<n>h|<iso>] [--until <iso>] [--include-automated] [--dashboard-url <url>] [--json]",
|
|
106
106
|
"",
|
|
107
107
|
`Default dashboard: ${DEFAULT_DASHBOARD_URL}. Omit --dashboard-url for normal production use; pass it only for staging/custom dashboards or to force a different pairing.`,
|
|
108
108
|
].join("\n");
|
|
@@ -15,7 +15,7 @@ export async function runCockpitCli(argv, io) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
if (command === "--version" || command === "-V" || command === "version") {
|
|
18
|
-
writeLine(io?.stdout ?? process.stdout, "0.2.
|
|
18
|
+
writeLine(io?.stdout ?? process.stdout, "0.2.104");
|
|
19
19
|
return 0;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -12,6 +12,8 @@ export function formatCount(value) {
|
|
|
12
12
|
return String(value);
|
|
13
13
|
}
|
|
14
14
|
export function formatUsageDollars(value) {
|
|
15
|
+
if (value === null)
|
|
16
|
+
return "Unavailable";
|
|
15
17
|
return new Intl.NumberFormat("en-US", {
|
|
16
18
|
style: "currency", currency: "USD", maximumFractionDigits: 0,
|
|
17
19
|
}).format(value);
|
package/dist/commands/usage.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { loadPairedSession } from "../tower-client.js";
|
|
1
2
|
import { formatCount, formatUsageDollars } from "./usage-format.js";
|
|
2
3
|
import { askAgentDoor, emitAgentDoor, failAgentDoor, openAgentDoor } from "./agent-door.js";
|
|
3
4
|
import { writeLine } from "./cli-io.js";
|
|
4
5
|
export async function runUsage(command, io) {
|
|
5
6
|
const door = await openAgentDoor("usage", command, io);
|
|
6
7
|
const query = new URLSearchParams({ since: command.since });
|
|
8
|
+
if (command.byRepo)
|
|
9
|
+
query.set("groupBy", "repo");
|
|
7
10
|
if (command.until)
|
|
8
11
|
query.set("until", command.until);
|
|
9
12
|
if (command.includeAutomated)
|
|
@@ -12,9 +15,27 @@ export async function runUsage(command, io) {
|
|
|
12
15
|
if (!answer.ok)
|
|
13
16
|
return failAgentDoor(door, "[usage]", answer.reason, answer.detail);
|
|
14
17
|
const body = answer.body;
|
|
18
|
+
if (command.person) {
|
|
19
|
+
const email = command.person === "me" ? (await loadPairedSession("usage", command.homeDir)).email : command.person;
|
|
20
|
+
if (!email)
|
|
21
|
+
return failAgentDoor(door, "[usage]", "caller_email_unavailable", "The paired session has no email. Sign in again or pass --person <email>.");
|
|
22
|
+
body.people = (body.people ?? []).filter((person) => person.email?.toLowerCase() === email.toLowerCase());
|
|
23
|
+
body.coverage = { sessions_extracted: body.people.reduce((total, person) => total + person.sessions_extracted, 0), sessions_observed: body.people.reduce((total, person) => total + person.sessions_observed, 0) };
|
|
24
|
+
}
|
|
25
|
+
if (command.byRepo && body.people?.some((person) => !Array.isArray(person.repos))) {
|
|
26
|
+
return failAgentDoor(door, "[usage]", "repo_grouping_unavailable", "The dashboard returned person totals without project rows. Deploy the dashboard project split before using --by-repo.");
|
|
27
|
+
}
|
|
15
28
|
if (door.json)
|
|
16
29
|
return emitAgentDoor(door, body);
|
|
17
|
-
|
|
30
|
+
let nameWidth = 20;
|
|
31
|
+
if (command.byRepo) {
|
|
32
|
+
for (const person of body.people ?? []) {
|
|
33
|
+
const repos = person.repos ?? [];
|
|
34
|
+
for (const repo of command.all ? repos : repos.slice(0, 10))
|
|
35
|
+
nameWidth = Math.max(nameWidth, repo.repo_label.length + 2);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const widths = [nameWidth, 8, 15, 12, 10, 10, 12, 14];
|
|
18
39
|
const printRow = (cells) => writeLine(io.stdout, cells.map((cell, index) => index === 0 ? cell.padEnd(widths[index]) : cell.padStart(widths[index])).join(" ").trimEnd());
|
|
19
40
|
printRow(["Person", "Tokens", "List equivalent", "Coverage", ...(command.detail ? ["Output", "Input", "Cache read", "Cache creation"] : [])]);
|
|
20
41
|
for (const row of body.people ?? []) {
|
|
@@ -25,6 +46,14 @@ export async function runUsage(command, io) {
|
|
|
25
46
|
`${row.sessions_extracted}/${row.sessions_observed}`,
|
|
26
47
|
...(command.detail ? [row.output_tokens, row.input_tokens, row.cache_read_input_tokens, row.cache_creation_input_tokens].map(formatCount) : []),
|
|
27
48
|
]);
|
|
49
|
+
if (command.byRepo) {
|
|
50
|
+
const repos = row.repos ?? [];
|
|
51
|
+
for (const repo of command.all ? repos : repos.slice(0, 10)) {
|
|
52
|
+
printRow([` ${repo.repo_label}`, formatCount(repo.tokens), formatUsageDollars(repo.api_list_price_equivalent_usd), `${repo.extracted_sessions}/${repo.sessions}`, ...(command.detail ? [repo.output, repo.input, repo.cache_read, repo.cache_creation].map(formatCount) : [])]);
|
|
53
|
+
}
|
|
54
|
+
if (!command.all && repos.length > 10)
|
|
55
|
+
writeLine(io.stdout, ` and ${repos.length - 10} more repos`);
|
|
56
|
+
}
|
|
28
57
|
}
|
|
29
58
|
writeLine(io.stdout, "");
|
|
30
59
|
writeLine(io.stdout, body.api_list_price_equivalent_label ?? "API list-price equivalent (not actual spend)");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bli-cockpit/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.104",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@bli-cockpit/memory-mcp": "0.1.27",
|
|
31
|
-
"@bli-cockpit/mcp": "0.1.
|
|
31
|
+
"@bli-cockpit/mcp": "0.1.34",
|
|
32
32
|
"@bli-cockpit/telemetry-core": "0.1.43"
|
|
33
33
|
}
|
|
34
34
|
}
|