ccost 0.3.1 → 0.4.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.
Files changed (3) hide show
  1. package/README.md +20 -10
  2. package/install.js +1 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ccost <img src="https://raw.githubusercontent.com/toolsu/ccost/main/logo.svg" alt="ccost" width="35" />
1
+ # ccost <img src="https://raw.githubusercontent.com/cc-friend/ccost/main/logo.svg" alt="ccost" width="35" />
2
2
 
3
3
  Analyze Claude Code token usage and costs from local conversation logs and statusline data.
4
4
 
@@ -6,11 +6,11 @@ Reads JSONL files from `~/.claude/projects/`, deduplicates streaming entries, ca
6
6
 
7
7
  The [`ccost sl` subcommand](#statusline-analysis) ([setup statusline.jsonl first](#setup-for-statuslinejsonl)) analyzes `~/.claude/statusline.jsonl` for rate limit tracking, session summaries, budget estimation, and cost comparison (see [`ccost` vs `ccost sl`](#ccost-vs-ccost-sl)).
8
8
 
9
- Blazing fast CLI and library written in Rust with thorough tests. Also powers [CC Dashboard for Claude Code](https://github.com/toolsu/ccdashboard), a Tauri desktop app for visualizing your Claude Code usage and more.
9
+ Blazing fast CLI and library written in Rust with thorough tests. Also powers [CC Friend (Claude Code Friend)](https://github.com/cc-friend/ccfriend), a Tauri desktop app for visualizing your Claude Code usage and more.
10
10
 
11
- [![crates.io](https://img.shields.io/crates/v/ccost)](https://crates.io/crates/ccost) [![npm](https://img.shields.io/npm/v/ccost)](https://www.npmjs.com/package/ccost) [![CI](https://github.com/toolsu/ccost/actions/workflows/ci.yml/badge.svg)](https://github.com/toolsu/ccost/actions/workflows/ci.yml) [![License](https://img.shields.io/badge/license-MIT-brightgreen)](https://github.com/toolsu/ccost/blob/main/LICENSE)
11
+ [![crates.io](https://img.shields.io/crates/v/ccost)](https://crates.io/crates/ccost) [![npm](https://img.shields.io/npm/v/ccost)](https://www.npmjs.com/package/ccost) [![CI](https://github.com/cc-friend/ccost/actions/workflows/ci.yml/badge.svg)](https://github.com/cc-friend/ccost/actions/workflows/ci.yml) [![License](https://img.shields.io/badge/license-MIT-brightgreen)](https://github.com/cc-friend/ccost/blob/main/LICENSE)
12
12
 
13
- [中文文档](https://github.com/toolsu/ccost/blob/main/README.zh.md)
13
+ [中文文档](https://github.com/cc-friend/ccost/blob/main/README.zh.md)
14
14
 
15
15
  ## Install
16
16
 
@@ -18,7 +18,7 @@ Blazing fast CLI and library written in Rust with thorough tests. Also powers [C
18
18
  npm i -g ccost
19
19
  ```
20
20
 
21
- Or download prebuilt binaries from [GitHub Releases](https://github.com/toolsu/ccost/releases).
21
+ Or download prebuilt binaries from [GitHub Releases](https://github.com/cc-friend/ccost/releases).
22
22
 
23
23
  Or via Cargo (compiles from source):
24
24
 
@@ -46,7 +46,7 @@ ccost sl --chart 5h # rate limit chart
46
46
 
47
47
  | Flag | Description |
48
48
  |------|-------------|
49
- | `--per <dim>` | Group by: `day`, `hour`, `month`, `session`, `project`, `model`, `subagent`. Up to 2 for nested grouping. Default: `--per day --per model`. |
49
+ | `--per <dim>` | Group by: `day`, `hour`, `month`, `session`, `project`, `model`, `subagent`, `tool`, `line`. Up to 2 for nested grouping. Default: `--per day --per model`. |
50
50
  | `--order <order>` | Sort: `asc` (default) or `desc`. |
51
51
 
52
52
  Two-level grouping creates parent-child rows, e.g. `--per day --per model` shows each day with per-model breakdowns.
@@ -274,6 +274,12 @@ ccost --per subagent --cost decimal
274
274
  # Session > subagent: see subagent cost within each session
275
275
  ccost --per session --per subagent
276
276
 
277
+ # Tool cost breakdown: which tools consume the most tokens
278
+ ccost --per tool --cost decimal
279
+
280
+ # Per-line cost: cost of each JSONL line (user prompt / assistant response)
281
+ ccost --per session --per line
282
+
277
283
  # Copy JSON to clipboard
278
284
  ccost --copy json
279
285
 
@@ -388,6 +394,10 @@ Reads JSONL conversation logs from Claude Code's local storage:
388
394
 
389
395
  Both are scanned and deduplicated via symlink detection. Subagent transcripts are found in both the old (`<project>/subagents/`) and new (`<project>/<session-uuid>/subagents/`) directory structures. Each record carries an `agent_id` (the subagent file stem, or empty for the main session), enabling `--per subagent` grouping.
390
396
 
397
+ ### Tool & Line Extraction
398
+
399
+ Each record's `message.content` is parsed with lightweight deserialization (only `type` and `name` fields from content blocks; `input`, `text`, etc. are skipped for performance). Tool names are extracted from `tool_use` blocks in assistant messages, enabling `--per tool` grouping. Each record also carries its JSONL line number (1-based), enabling `--per line` grouping. Line numbers are consistent with ccfriend's transcript line anchors (`#N`).
400
+
391
401
  ### Deduplication
392
402
 
393
403
  Streaming entries share the same `messageId:requestId` key with increasing `output_tokens`. Only the highest-output record per key is kept. This dedup is global across all files, preventing double-counting between parent sessions and subagent files.
@@ -412,7 +422,7 @@ Below we'll compare `ccost` (data from `~/.claude/projects/`) and `ccost sl` (da
412
422
 
413
423
  As shown by `ccost sl --per session --cost-diff`, when LiteLLM pricing is accurate, the cost computed from `~/.claude/projects/` closely matches the server-reported cost in `statusline.jsonl`. The statusline cost may occasionally undercount because it does not always include subagent costs. Since `~/.claude/projects/` has full per-request token breakdowns, it may be the more reliable source for cost.
414
424
 
415
- The primary value of `statusline.jsonl` is the rate-limit percentages, not cost. This is why [CC Dashboard for Claude Code](https://github.com/toolsu/ccdashboard) uses cost data computed from `~/.claude/projects/` combined with the 5-hour and 1-week rate-limit percentages from `statusline.jsonl`.
425
+ The primary value of `statusline.jsonl` is the rate-limit percentages, not cost. This is why [CC Friend (Claude Code Friend)](https://github.com/cc-friend/ccfriend) uses cost data computed from `~/.claude/projects/` combined with the 5-hour and 1-week rate-limit percentages from `statusline.jsonl`.
416
426
 
417
427
  ### Project Path Decoding
418
428
 
@@ -422,15 +432,15 @@ Directory names like `-home-user-workspace-test` decode to `/home/user/workspace
422
432
 
423
433
  ### Terminal
424
434
 
425
- ![Terminal output](https://raw.githubusercontent.com/toolsu/ccost/main/screenshot_terminal.png)
435
+ ![Terminal output](https://raw.githubusercontent.com/cc-friend/ccost/main/screenshot_terminal.png)
426
436
 
427
437
  ### Statusline Analysis (`ccost sl`)
428
438
 
429
- ![Statusline output](https://raw.githubusercontent.com/toolsu/ccost/main/screenshot_terminal_sl.png)
439
+ ![Statusline output](https://raw.githubusercontent.com/cc-friend/ccost/main/screenshot_terminal_sl.png)
430
440
 
431
441
  ### HTML Report
432
442
 
433
- ![HTML report](https://raw.githubusercontent.com/toolsu/ccost/main/screenshot_html.png)
443
+ ![HTML report](https://raw.githubusercontent.com/cc-friend/ccost/main/screenshot_html.png)
434
444
 
435
445
  ## Development
436
446
 
package/install.js CHANGED
@@ -13,7 +13,7 @@ if (process.env.CCOST_SKIP_INSTALL) {
13
13
  }
14
14
 
15
15
  const VERSION = require("./package.json").version;
16
- const REPO = "toolsu/ccost";
16
+ const REPO = "cc-friend/ccost";
17
17
 
18
18
  function getPlatformName() {
19
19
  const platform = process.platform;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "ccost",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Analyze Claude Code token usage and costs from local conversation logs and statusline data (Rust CLI & lib)",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/toolsu/ccost"
7
+ "url": "https://github.com/cc-friend/ccost"
8
8
  },
9
9
  "author": "Tom Chen",
10
10
  "license": "MIT",