claude-code-cost 1.6.1 → 1.7.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/hub-app.json CHANGED
@@ -4,6 +4,35 @@
4
4
  "name": "Cost",
5
5
  "icon": "dollar-sign",
6
6
  "run": { "entry": "server.js", "defaultPort": 3543 },
7
+ "plugin": { "marketplace": "plugin", "name": "cost-dashboard" },
8
+ "listing": {
9
+ "tagline": "Ask Claude what your Claude Code sessions cost",
10
+ "description": "A skill that lets Claude read your Claude Code costs in a session. Run /cost-dashboard:cost with a question, such as \"what did this week cost?\" or \"which session cost the most?\". Claude answers with totals by day, model and project, the costliest sessions and subagents, and your plan usage limits.",
11
+ "tags": ["skill", "cost", "cli"],
12
+ "homepage": "https://nikiforovall.blog/claude-code-cost/",
13
+ "screenshots": [
14
+ {
15
+ "url": "https://nikiforovall.blog/claude-code-cost/shots/themes/ember-h2-hub-cost-light.webp",
16
+ "alt": "The Cost dashboard in the hub: the total cost, the cost by day and by model, and the top projects",
17
+ "title": "Overview",
18
+ "caption": "The numbers the skill reads: the total, by day, by model and by project."
19
+ },
20
+ {
21
+ "url": "https://nikiforovall.blog/claude-code-cost/shots/themes/ember-h2d-hub-cost-sessions-light.webp",
22
+ "alt": "The Cost dashboard's session list, sorted by cost",
23
+ "title": "Sessions",
24
+ "caption": "Sessions by cost. Ask Claude which one cost the most."
25
+ },
26
+ {
27
+ "url": "https://nikiforovall.blog/claude-code-cost/shots/themes/ember-cost-insights-light.webp",
28
+ "alt": "The Cost insights view: run rate, 5-hour blocks, subagent share and top tools",
29
+ "title": "Insights",
30
+ "caption": "Run rate, 5-hour blocks, the subagent share and the top tools."
31
+ }
32
+ ],
33
+ "author": "NikiforovAll",
34
+ "license": "MIT"
35
+ },
7
36
  "loading": {
8
37
  "verbs": [
9
38
  "Counting tokens…",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-cost",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "Cost dashboard for Claude Code usage",
5
5
  "main": "server.js",
6
6
  "type": "commonjs",
@@ -48,6 +48,7 @@
48
48
  "server.js",
49
49
  "hub-app.json",
50
50
  "lib/",
51
+ "plugin/",
51
52
  "public/",
52
53
  "README.md",
53
54
  "LICENSE"
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "cost-dashboard",
3
+ "owner": {
4
+ "name": "NikiforovAll"
5
+ },
6
+ "description": "The plugin that ships with Claude Code Cost",
7
+ "plugins": [
8
+ {
9
+ "name": "cost-dashboard",
10
+ "source": "./plugins/cost-dashboard",
11
+ "description": "A skill to read Claude Code costs from a session"
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "cost-dashboard",
3
+ "version": "1.0.1",
4
+ "author": { "name": "NikiforovAll" },
5
+ "description": "A skill to read Claude Code costs from a session"
6
+ }
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: cost
3
+ description: Answer a question about Claude Code costs — totals by day, model and project, the costliest sessions and subagents, plan usage limits.
4
+ argument-hint: '[question]'
5
+ disable-model-invocation: true
6
+ ---
7
+
8
+ # Cost
9
+
10
+ Answer the user's cost question with the `claude-code-cost` CLI. With no question, run `overview`.
11
+
12
+ ## Find the CLI
13
+
14
+ Use the first that exists:
15
+
16
+ 1. The command your system prompt names for the cost CLI.
17
+ 2. When the Cost dashboard runs (for example in Claude Code Hub), it writes `<config dir>/.cost/server.json`. Read its `script` field, the path of the CLI, and run `node "<that path>"`. The config dir is `$CLAUDE_CONFIG_DIR`, else `~/.claude`. Quote the path: on Windows it has backslashes.
18
+ 3. `claude-code-cost` on PATH.
19
+ 4. `npx claude-code-cost`.
20
+
21
+ ## Commands
22
+
23
+ | Command | What it prints |
24
+ |---|---|
25
+ | `overview` | Total cost, by model, by day and the top projects; `--compare` adds the window before |
26
+ | `insights` | Run rate, 5-hour blocks, subagent share, compactions, top tools |
27
+ | `projects` | Projects by cost |
28
+ | `sessions [<project>]` | Sessions by cost, with their ids; `--match <title>` |
29
+ | `agents` | Subagents by skill or agent type: runs, total, average |
30
+ | `session <id>` | One session: totals, subagents, costliest turns |
31
+ | `agent <session id> <agent id>` | One subagent of a session |
32
+ | `limits` | Plan usage limits: the 5-hour and weekly windows |
33
+
34
+ Most commands take `--range` (`today`, `24h`, `<n>d`) and `--json`. `help <command>` prints the flags of the installed binary: read it before you use a flag.
35
+
36
+ ## Answer
37
+
38
+ - State the window with every number. The default is 7 days. `session` and `agent` cover the whole session: state its first and last date.
39
+ - A list shows the top rows. `--top <n>` shows more.
40
+ - Call the costs estimates: they come from the transcripts at list prices.
@@ -1,4 +1,4 @@
1
- // claude-hub-sdk 1.9.0 (sha256 537745aa3415). Copied by npm run sdk:sync in claude-code-hub. Do not edit.
1
+ // claude-hub-sdk 1.12.0 (sha256 6fb679e4d801). Copied by npm run sdk:sync in claude-code-hub. Do not edit.
2
2
  // Claude Code Hub SDK: the one rule that names a key press, shared by the hub page, client.js and
3
3
  // stub.js. The hub serves it to its page as /sdk/keys.js; mount() and sdk:sync put it in front of
4
4
  // client.js and stub.js, so an app still loads one file.
@@ -10,19 +10,62 @@ var ClaudeHubKeys = (() => {
10
10
  // Modifiers in ctrl, alt, shift, meta order, joined by '+' to the key. macOS composes
11
11
  // Option+<key> into a character (Option+1 is '¡', Option+P is 'π') and holding Control does not
12
12
  // undo it, so e.key alone cannot name these presses there. e.code is the physical key, which is
13
- // wrong for non-US layouts, hence only as a fallback. No fallback under AltGraph: Chromium sets it
14
- // when AltGr types a character, and that press is text. Takes a real KeyboardEvent or a forwarded
15
- // {key, code} payload; a payload without code degrades to key. A payload needs no AltGraph: the
16
- // SDK forwards only a press whose key already names a bound combo.
17
- // Self-contained on purpose: cck puts its source text into a sandboxed frame.
13
+ // wrong for non-US layouts, hence only as a fallback. A letter or punctuation key falls back to its
14
+ // US character only when e.key is not ASCII (a non-Latin layout, or Option on macOS), so AZERTY's
15
+ // ',' on the M key stays ','. The digit row always falls back, so AZERTY's '&' key is 1, as Windows
16
+ // and VS Code treat it. No fallback under AltGraph: Chromium sets it when AltGr types a character, and that
17
+ // press is text. Takes a real KeyboardEvent or a forwarded {key, code} payload; a payload without
18
+ // code degrades to key. A payload needs no AltGraph: the SDK forwards only a press whose key
19
+ // already names a bound combo.
20
+ // Self-contained on purpose, the table too: cck puts its source text into a sandboxed frame.
21
+ // codeOf() lists the same keys the other way round.
18
22
  function comboOf(e) {
19
- const lower = typeof e.key === 'string' ? e.key.toLowerCase() : '';
20
- const m = !e.getModifierState?.('AltGraph') && /^(?:Key|Digit)([A-Z1-9])$/.exec(e.code || '');
21
- const key = /^[a-z1-9]$/.test(lower) ? lower : m ? m[1].toLowerCase() : e.key === ' ' ? 'Space' : e.key;
23
+ const raw = typeof e.key === 'string' ? e.key : '';
24
+ const lower = raw.toLowerCase();
25
+ const code = e.getModifierState?.('AltGraph') ? '' : e.code || '';
26
+ const latin = !/[^\x20-\x7e]/.test(raw);
27
+ const digit = /^Digit([0-9])$/.exec(code)?.[1];
28
+ const us =
29
+ !latin &&
30
+ (/^Key([A-Z])$/.exec(code)?.[1].toLowerCase() ||
31
+ {
32
+ Minus: '-',
33
+ Equal: '=',
34
+ BracketLeft: '[',
35
+ BracketRight: ']',
36
+ Backslash: '\\',
37
+ Semicolon: ';',
38
+ Quote: "'",
39
+ Backquote: '`',
40
+ Comma: ',',
41
+ Period: '.',
42
+ Slash: '/',
43
+ }[code]);
44
+ const key = /^[a-z0-9]$/.test(lower) ? lower : digit || us || (e.key === ' ' ? 'Space' : e.key);
22
45
  const mods = [e.ctrlKey && 'ctrl', e.altKey && 'alt', e.shiftKey && 'shift', e.metaKey && 'meta'];
23
46
  return [...mods, key].filter(Boolean).join('+');
24
47
  }
25
48
 
49
+ // The physical key (e.code) that types a combo's key on a US layout, or null for a named key.
50
+ function codeOf(key) {
51
+ if (/^[a-z]$/.test(key)) return `Key${key.toUpperCase()}`;
52
+ if (/^[0-9]$/.test(key)) return `Digit${key}`;
53
+ const codes = {
54
+ '-': 'Minus',
55
+ '=': 'Equal',
56
+ '[': 'BracketLeft',
57
+ ']': 'BracketRight',
58
+ '\\': 'Backslash',
59
+ ';': 'Semicolon',
60
+ "'": 'Quote',
61
+ '`': 'Backquote',
62
+ ',': 'Comma',
63
+ '.': 'Period',
64
+ '/': 'Slash',
65
+ };
66
+ return codes[key] ?? null;
67
+ }
68
+
26
69
  // The keys of a combo as a help row shows them: ['Ctrl', 'Alt', 'P'], or ['⌃', '⌥', 'P'] on macOS.
27
70
  // The {n} of a numbered combo reads 1…9.
28
71
  function keyParts(combo, mac) {
@@ -47,7 +90,7 @@ var ClaudeHubKeys = (() => {
47
90
  ].filter(Boolean);
48
91
  }
49
92
 
50
- return { comboOf, keyParts, keySigs };
93
+ return { comboOf, codeOf, keyParts, keySigs };
51
94
  })();
52
95
 
53
96
  if (typeof module === 'object' && module.exports) module.exports = ClaudeHubKeys;
@@ -93,7 +136,9 @@ if (typeof module === 'object' && module.exports) module.exports = ClaudeHubKeys
93
136
  can: (action) => !!standaloneFn(action),
94
137
  forwards: () => false,
95
138
  forwardCombos: () => [],
139
+ onKeys: () => off,
96
140
  keyLabel: () => null,
141
+ voiceCommands: () => [],
97
142
  closeGuard() {},
98
143
  openExternal(url) {
99
144
  win.open(url, '_blank', 'noopener');
@@ -103,7 +148,8 @@ if (typeof module === 'object' && module.exports) module.exports = ClaudeHubKeys
103
148
  return hub;
104
149
  }
105
150
 
106
- return { connect, comboOf };
151
+ const mod = { list: [], wrap: () => false, on: () => off, emit() {}, send: () => false };
152
+ return { connect, comboOf, mod };
107
153
  }
108
154
 
109
155
  if (typeof module === 'object' && module.exports) module.exports = { createClaudeHub, comboOf };