burner-cc 0.1.0 → 0.1.2
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/README.md +12 -8
- package/package.json +1 -1
- package/src/cli.js +37 -0
- package/src/render.js +10 -4
- package/web/receipt.html +1 -0
- package/web/receipt.js +1 -1
package/README.md
CHANGED
|
@@ -7,14 +7,20 @@ Itemized dollar-and-token cost receipts for Claude Code sessions.
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
npx burner-cc # latest session -> opens a receipt
|
|
11
|
+
npx burner-cc <session-id> # specific session (accepts a title, slug, or id prefix)
|
|
12
|
+
npx burner-cc --all # every session found, sliding through one receipt each
|
|
13
|
+
npx burner-cc list # quick terminal table, no browser
|
|
14
|
+
npx burner-cc --json # machine-readable, no browser
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Or install it globally: `npm install -g burner-cc`, then run `burner-cc` directly.
|
|
18
|
+
|
|
19
|
+
### Local development
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
node bin/burner-cc.js <same args as above>
|
|
23
|
+
```
|
|
18
24
|
|
|
19
25
|
## How it works
|
|
20
26
|
|
|
@@ -24,8 +30,6 @@ Once published: `npx burner-cc`, `npx burner-cc --all`, etc.
|
|
|
24
30
|
- **Receipt** (`src/build-receipt.js`) groups tokens by model and computes cost per token-type line.
|
|
25
31
|
- **Rendering** (`src/render.js` + `web/`) injects the receipt JSON into `web/receipt.html` and opens it in the default browser. Theme buttons (paper / thermal / matrix / dark) switch CSS variables client-side.
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
|
|
29
33
|
## What this is not
|
|
30
34
|
|
|
31
35
|
Not official billing. Composition breakdown by *source* (system prompt vs. skills vs. MCP tool schemas) isn't available from local transcripts alone — that needs request interception, which this tool doesn't do. The receipt instead itemizes by token *type*: fresh input, cache write, cache read, output.
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -1,8 +1,35 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
1
4
|
import { discoverSessions, findSession, latestSession } from './discover.js';
|
|
2
5
|
import { buildReceipt, loadPricingTable } from './build-receipt.js';
|
|
3
6
|
import { renderReceipts, openInBrowser } from './render.js';
|
|
4
7
|
import { detectBillingMode } from './billing-mode.js';
|
|
5
8
|
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
const HELP_TEXT = `burner-cc — itemized cost receipts for Claude Code sessions
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
burner-cc latest session -> opens a receipt
|
|
15
|
+
burner-cc <session> specific session (title, slug, or id prefix)
|
|
16
|
+
burner-cc --all every session found, sliding carousel
|
|
17
|
+
burner-cc list quick terminal table, no browser
|
|
18
|
+
burner-cc --json machine-readable output, no browser
|
|
19
|
+
burner-cc -h, --help show this help
|
|
20
|
+
burner-cc -v, --version show version
|
|
21
|
+
|
|
22
|
+
Examples:
|
|
23
|
+
burner-cc
|
|
24
|
+
burner-cc my-renamed-session
|
|
25
|
+
burner-cc --all --json
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
function printVersion() {
|
|
29
|
+
const pkg = JSON.parse(readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
30
|
+
console.log(pkg.version);
|
|
31
|
+
}
|
|
32
|
+
|
|
6
33
|
function fmtUsd(n) {
|
|
7
34
|
return '$' + n.toFixed(3);
|
|
8
35
|
}
|
|
@@ -22,6 +49,16 @@ function printList(sessions, table) {
|
|
|
22
49
|
|
|
23
50
|
async function main() {
|
|
24
51
|
const args = process.argv.slice(2);
|
|
52
|
+
|
|
53
|
+
if (args.includes('-h') || args.includes('--help')) {
|
|
54
|
+
console.log(HELP_TEXT);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (args.includes('-v') || args.includes('--version')) {
|
|
58
|
+
printVersion();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
25
62
|
const asJson = args.includes('--json');
|
|
26
63
|
const filtered = args.filter((a) => a !== '--json');
|
|
27
64
|
|
package/src/render.js
CHANGED
|
@@ -12,10 +12,16 @@ export function renderReceipts(sessions) {
|
|
|
12
12
|
mkdirSync(outDir, { recursive: true });
|
|
13
13
|
|
|
14
14
|
const template = readFileSync(path.join(webDir, 'receipt.html'), 'utf-8');
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
// The logo has to be inlined as a data URI, not loaded as a separate
|
|
16
|
+
// file:// resource — html2canvas's Download button taints the canvas
|
|
17
|
+
// (SecurityError on toDataURL) if the receipt contains an <img> pulled
|
|
18
|
+
// in as its own file:// fetch, even from the same local directory.
|
|
19
|
+
const logoBase64 = readFileSync(path.join(webDir, 'logo-mark.png')).toString('base64');
|
|
20
|
+
const logoDataUri = `data:image/png;base64,${logoBase64}`;
|
|
21
|
+
|
|
22
|
+
const injected = template
|
|
23
|
+
.replace('/*__BURNER_DATA__*/[]', JSON.stringify(sessions))
|
|
24
|
+
.replace('/*__BURNER_LOGO_MARK__*/"logo-mark.png"', JSON.stringify(logoDataUri));
|
|
19
25
|
|
|
20
26
|
const outHtml = path.join(outDir, 'receipt.html');
|
|
21
27
|
writeFileSync(outHtml, injected, 'utf-8');
|
package/web/receipt.html
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
<div id="root"></div>
|
|
26
26
|
|
|
27
27
|
<script>window.__BURNER_DATA__ = /*__BURNER_DATA__*/[];</script>
|
|
28
|
+
<script>window.__BURNER_LOGO_MARK__ = /*__BURNER_LOGO_MARK__*/"logo-mark.png";</script>
|
|
28
29
|
<script src="vendor/html2canvas.min.js"></script>
|
|
29
30
|
<script src="receipt.js"></script>
|
|
30
31
|
</body>
|
package/web/receipt.js
CHANGED
|
@@ -129,7 +129,7 @@ function receiptHtml(session, index) {
|
|
|
129
129
|
</div>
|
|
130
130
|
<div class="barcode" title="${bc.title}">${bc.html}</div>
|
|
131
131
|
<div class="barcode-label">CC-SESSION-${session.sessionId.slice(0, 8).toUpperCase()}</div>
|
|
132
|
-
<img class="receipt-logo" src="logo-mark.png" alt="Burner" />
|
|
132
|
+
<img class="receipt-logo" src="${window.__BURNER_LOGO_MARK__ ?? 'logo-mark.png'}" alt="Burner" />
|
|
133
133
|
<div class="footer brand">~ B U R N E R ~</div>
|
|
134
134
|
</div>
|
|
135
135
|
`;
|