ccost 0.3.0 → 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 +28 -12
  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`. 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.
@@ -268,6 +268,18 @@ ccost --per month --output csv --filename usage.csv
268
268
  # Two-level: project > model
269
269
  ccost --per project --per model --table full
270
270
 
271
+ # Subagent cost breakdown
272
+ ccost --per subagent --cost decimal
273
+
274
+ # Session > subagent: see subagent cost within each session
275
+ ccost --per session --per subagent
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
+
271
283
  # Copy JSON to clipboard
272
284
  ccost --copy json
273
285
 
@@ -342,7 +354,7 @@ struct LoadOptions {
342
354
  session: Option<String>,
343
355
  }
344
356
 
345
- enum GroupDimension { Day, Hour, Month, Session, Project, Model }
357
+ enum GroupDimension { Day, Hour, Month, Session, Project, Model, Subagent }
346
358
 
347
359
  struct GroupedData {
348
360
  label: String,
@@ -380,7 +392,11 @@ Reads JSONL conversation logs from Claude Code's local storage:
380
392
  - `~/.claude/projects/*/` (session files and `subagents/`)
381
393
  - `~/.config/claude/projects/*/` (alternate location)
382
394
 
383
- 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.
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.
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`).
384
400
 
385
401
  ### Deduplication
386
402
 
@@ -406,7 +422,7 @@ Below we'll compare `ccost` (data from `~/.claude/projects/`) and `ccost sl` (da
406
422
 
407
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.
408
424
 
409
- 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`.
410
426
 
411
427
  ### Project Path Decoding
412
428
 
@@ -416,15 +432,15 @@ Directory names like `-home-user-workspace-test` decode to `/home/user/workspace
416
432
 
417
433
  ### Terminal
418
434
 
419
- ![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)
420
436
 
421
437
  ### Statusline Analysis (`ccost sl`)
422
438
 
423
- ![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)
424
440
 
425
441
  ### HTML Report
426
442
 
427
- ![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)
428
444
 
429
445
  ## Development
430
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.0",
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",