@caveman-ai/cli 1.3.3 → 2.0.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/LICENSE +202 -21
- package/NOTICE +66 -0
- package/README.md +30 -1
- package/dist/agent-skills.generated.js +2 -2
- package/dist/agents.generated.js +24 -24
- package/dist/binaries.generated.js +1 -1
- package/dist/caveman-delegate-mcp.mjs +0 -0
- package/dist/caveman-pi-extension.mjs +291 -104
- package/dist/index.js +1638 -383
- package/dist/learn-autopilot.js +447 -0
- package/dist/learn-trends.js +132 -0
- package/dist/learn-tui.js +31 -31
- package/dist/native-hook-fast.js +19 -6
- package/dist/native-pack.generated.js +1 -1
- package/dist/openclaw-provider-compat.js +111 -0
- package/dist/provider-routing.js +147 -0
- package/dist/stats-cli.js +105 -0
- package/package.json +12 -12
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// The proxy owns accounting and HTML. This module only parses the public
|
|
2
|
+
// command and renders its already-calculated report; it never recomputes money.
|
|
3
|
+
export const STATS_USAGE = "stats [--json] [--days N | --all-time] [--provider ID] [--model ID] [--agent ID] [--auth MODE] [--plain | --open] [--out PATH]";
|
|
4
|
+
export const STATS_HELP = `caveman stats — your local token and cost report
|
|
5
|
+
|
|
6
|
+
caveman stats summary and visual dashboard
|
|
7
|
+
caveman stats --days 7 last 7 UTC calendar days
|
|
8
|
+
caveman stats --all-time all recorded history
|
|
9
|
+
caveman stats --provider openai one provider
|
|
10
|
+
caveman stats --model gpt-5.6 one recorded model
|
|
11
|
+
caveman stats --auth subscription
|
|
12
|
+
caveman stats --json complete machine-readable report
|
|
13
|
+
caveman stats --plain terminal summary, no browser
|
|
14
|
+
caveman stats --out savings.html --open
|
|
15
|
+
|
|
16
|
+
Filters: --provider, --model, --agent and --auth use exact recorded values.
|
|
17
|
+
Days: 30 by default; 1–3660, or --all-time. All dates use UTC.
|
|
18
|
+
The dashboard is a private, offline HTML snapshot. Run stats again to refresh.
|
|
19
|
+
API cost estimates and subscription API equivalents are separate. Neither
|
|
20
|
+
proves an invoice reduction. Unknown models and billing modes stay unpriced.
|
|
21
|
+
`;
|
|
22
|
+
export function parseStatsOptions(argv) {
|
|
23
|
+
const result = { json: false, plain: false, open: false, filters: [] };
|
|
24
|
+
const seen = new Set();
|
|
25
|
+
const valueFlags = new Set(["--days", "--provider", "--model", "--agent", "--auth", "--out"]);
|
|
26
|
+
for (let i = 0; i < argv.length; i++) {
|
|
27
|
+
const arg = argv[i];
|
|
28
|
+
if (seen.has(arg))
|
|
29
|
+
throw new Error(`duplicate ${arg}`);
|
|
30
|
+
seen.add(arg);
|
|
31
|
+
if (valueFlags.has(arg)) {
|
|
32
|
+
const value = argv[++i];
|
|
33
|
+
if (!value || value.startsWith("--") || /[\u0000-\u001f\u007f]/u.test(value))
|
|
34
|
+
throw new Error(`${arg} requires a value`);
|
|
35
|
+
if (arg === "--days" && (!/^\d+$/u.test(value) || Number(value) < 1 || Number(value) > 3660)) {
|
|
36
|
+
throw new Error("--days must be an integer from 1 to 3660");
|
|
37
|
+
}
|
|
38
|
+
if (arg === "--out")
|
|
39
|
+
result.out = value;
|
|
40
|
+
else
|
|
41
|
+
result.filters.push(arg, value);
|
|
42
|
+
}
|
|
43
|
+
else if (arg === "--json")
|
|
44
|
+
result.json = true;
|
|
45
|
+
else if (arg === "--plain" || arg === "--no-open")
|
|
46
|
+
result.plain = true;
|
|
47
|
+
else if (arg === "--open")
|
|
48
|
+
result.open = true;
|
|
49
|
+
else if (arg === "--all-time")
|
|
50
|
+
result.filters.push("--days", "0");
|
|
51
|
+
else
|
|
52
|
+
throw new Error(`unknown option ${arg}`);
|
|
53
|
+
}
|
|
54
|
+
if (seen.has("--days") && seen.has("--all-time"))
|
|
55
|
+
throw new Error("choose --days or --all-time");
|
|
56
|
+
if (result.plain && result.open)
|
|
57
|
+
throw new Error("choose --plain or --open");
|
|
58
|
+
if (result.json && result.open)
|
|
59
|
+
throw new Error("--json cannot open a browser");
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
const count = (n) => Number.isFinite(n) ? n.toLocaleString("en-US") : "unknown";
|
|
63
|
+
const money = (n) => typeof n === "number" && Number.isFinite(n)
|
|
64
|
+
? `${n < 0 ? "−" : ""}$${Math.abs(n).toFixed(Math.abs(n) > 0 && Math.abs(n) < 0.01 ? 6 : 4)}`
|
|
65
|
+
: "unavailable";
|
|
66
|
+
const label = (value) => value.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/gu, "").replace(/[\u0000-\u001f\u007f-\u009f]/gu, "");
|
|
67
|
+
export function renderStatsSummary(report) {
|
|
68
|
+
const m = report.totals;
|
|
69
|
+
const usageCount = (n) => {
|
|
70
|
+
if (m.complete_usage_requests === 0 && n === 0)
|
|
71
|
+
return "unknown";
|
|
72
|
+
return `${count(n)}${m.partial_usage_requests > 0 ? " observed" : ""}`;
|
|
73
|
+
};
|
|
74
|
+
const lines = [
|
|
75
|
+
"Caveman Stats",
|
|
76
|
+
`${report.window.lifetime ? "All recorded history" : `Last ${report.window.days} days`} · UTC · local estimates`,
|
|
77
|
+
"",
|
|
78
|
+
];
|
|
79
|
+
if (m.requests === 0) {
|
|
80
|
+
lines.push("No routed requests in this window.", "Run an agent through Caveman, then run caveman stats again.");
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const reduction = m.measured_requests > 0
|
|
84
|
+
? `${count(m.saved_tokens)} tokens${m.before_tokens > 0 ? ` (${(100 * m.saved_tokens / m.before_tokens).toFixed(1)}%)` : ""}`
|
|
85
|
+
: "unavailable — no request comparisons recorded yet";
|
|
86
|
+
lines.push(`Input reduction estimate ${reduction}`, `Compared request tokens ${m.measured_requests > 0 ? `${count(m.before_tokens)} original / ${count(m.after_tokens)} delivered` : "unavailable"}`, `API input cost estimate ${money(m.api_savings_usd)} reduction · ${count(m.api_savings_requests)} priced requests`, `Subscription equivalent ${money(m.api_equivalent_savings_usd)} at API rates · ${count(m.equivalent_savings_requests)} priced requests`, `API spend estimate ${money(m.api_spend_usd)} · ${count(m.api_spend_requests)} priced requests`, "", `Requests ${count(m.requests)} total / ${count(m.successful_requests)} successful / ${count(m.failed_requests)} failed`, `Provider usage ${usageCount(m.input_tokens)} input / ${usageCount(m.output_tokens)} output`, `Cache usage ${usageCount(m.cache_read_tokens)} read / ${usageCount(m.cache_write_tokens)} written`, `Usage coverage ${count(m.complete_usage_requests)} complete / ${count(m.partial_usage_requests)} partial or unavailable`, `Comparison coverage ${count(m.measured_requests)} measured / ${count(m.unmeasured_requests)} unavailable`);
|
|
87
|
+
if (m.expanded_requests > 0)
|
|
88
|
+
lines.push(`Overhead regressions ${count(m.expanded_requests)} requests (included in net delta)`);
|
|
89
|
+
if (m.legacy_requests > 0)
|
|
90
|
+
lines.push(`Legacy segment reductions ${count(m.legacy_saved_tokens)} tokens / ${count(m.legacy_requests)} requests (separate)`);
|
|
91
|
+
if (m.unknown_auth_requests > 0)
|
|
92
|
+
lines.push(`Unknown billing ${count(m.unknown_auth_requests)} requests (excluded from money totals)`);
|
|
93
|
+
if (report.providers?.length) {
|
|
94
|
+
lines.push("", "By provider");
|
|
95
|
+
for (const p of report.providers) {
|
|
96
|
+
lines.push(` ${label(p.provider)}: ${count(p.requests)} requests · ${p.measured_requests > 0 ? count(p.saved_tokens) : "unknown"} tokens · API ${money(p.api_savings_usd)} · subscription equivalent ${money(p.api_equivalent_savings_usd)}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
lines.push("", "API estimates assume the observed cache mix. Subscription equivalents do not reduce your bill.");
|
|
100
|
+
}
|
|
101
|
+
if (report.report_path)
|
|
102
|
+
lines.push("", `Dashboard: ${report.report_path}`);
|
|
103
|
+
lines.push("Full breakdown: caveman stats --json");
|
|
104
|
+
return `${lines.join("\n")}\n`;
|
|
105
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caveman-ai/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Caveman CLI — wrap coding agents with recoverable local context compression and truthful metering (`caveman claude`), then drive Caveman Cloud from terminal. Compression and metering run in companion Go binaries: run `caveman setup` to see install state. Local savings stay inferred until verified.",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -23,21 +23,21 @@
|
|
|
23
23
|
"files": [
|
|
24
24
|
"dist",
|
|
25
25
|
"README.md",
|
|
26
|
-
"LICENSE"
|
|
26
|
+
"LICENSE",
|
|
27
|
+
"NOTICE"
|
|
27
28
|
],
|
|
28
|
-
"scripts": {
|
|
29
|
-
"build": "node scripts/gen-binaries.mjs && node scripts/gen-wedge-installer.mjs && node scripts/compile-registries.mjs && tsc && node scripts/bundle-delegate.mjs && node scripts/bundle-tui.mjs && node scripts/bundle-pi-extension.mjs && node scripts/shebang.mjs",
|
|
30
|
-
"prepack": "npm run build",
|
|
31
|
-
"lint": "tsc --noEmit",
|
|
32
|
-
"test": "node scripts/gen-binaries.mjs && node scripts/gen-wedge-installer.mjs && node scripts/compile-registries.mjs && tsc && node scripts/bundle-delegate.mjs && node scripts/bundle-tui.mjs && node scripts/bundle-pi-extension.mjs && node scripts/shebang.mjs && node --test --test-force-exit --test-concurrency=4 tests/*.runtime.mjs",
|
|
33
|
-
"bench:native": "node scripts/benchmark-native-hooks.mjs",
|
|
34
|
-
"test:fast": "node scripts/gen-binaries.mjs && node scripts/gen-wedge-installer.mjs && node scripts/compile-registries.mjs && tsc && node scripts/bundle-delegate.mjs && node scripts/bundle-tui.mjs && node scripts/bundle-pi-extension.mjs && node --test --test-force-exit --test-concurrency=4 --test-reporter=dot tests/agent-native.runtime.mjs tests/billing.runtime.mjs tests/capability-config.runtime.mjs tests/login.runtime.mjs tests/mcp-surface.runtime.mjs tests/porcelain.runtime.mjs tests/practice-registry.runtime.mjs tests/skills.runtime.mjs tests/status.runtime.mjs tests/subscription-recovery.runtime.mjs tests/wrap-gate.runtime.mjs"
|
|
35
|
-
},
|
|
36
29
|
"dependencies": {},
|
|
37
30
|
"devDependencies": {
|
|
38
31
|
"@clack/prompts": "1.7.0",
|
|
39
32
|
"@types/node": "24.10.1",
|
|
40
33
|
"esbuild": "0.28.1",
|
|
41
34
|
"typescript": "5.9.3"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "node scripts/gen-binaries.mjs && node scripts/gen-wedge-installer.mjs && node scripts/compile-registries.mjs && tsc && node scripts/bundle-delegate.mjs && node scripts/bundle-tui.mjs && node scripts/bundle-pi-extension.mjs && node scripts/shebang.mjs",
|
|
38
|
+
"lint": "tsc --noEmit",
|
|
39
|
+
"test": "node scripts/gen-binaries.mjs && node scripts/gen-wedge-installer.mjs && node scripts/compile-registries.mjs && tsc && node scripts/bundle-delegate.mjs && node scripts/bundle-tui.mjs && node scripts/bundle-pi-extension.mjs && node scripts/shebang.mjs && node --test --test-force-exit --test-concurrency=4 tests/*.runtime.mjs",
|
|
40
|
+
"bench:native": "node scripts/benchmark-native-hooks.mjs",
|
|
41
|
+
"test:fast": "node scripts/gen-binaries.mjs && node scripts/gen-wedge-installer.mjs && node scripts/compile-registries.mjs && tsc && node scripts/bundle-delegate.mjs && node scripts/bundle-tui.mjs && node scripts/bundle-pi-extension.mjs && node --test --test-force-exit --test-concurrency=4 --test-reporter=dot tests/agent-native.runtime.mjs tests/billing.runtime.mjs tests/capability-config.runtime.mjs tests/login.runtime.mjs tests/mcp-surface.runtime.mjs tests/porcelain.runtime.mjs tests/practice-registry.runtime.mjs tests/skills.runtime.mjs tests/status.runtime.mjs tests/subscription-recovery.runtime.mjs tests/wrap-gate.runtime.mjs"
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|