sessioncost 0.2.0__tar.gz → 0.2.2__tar.gz

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 (29) hide show
  1. {sessioncost-0.2.0/sessioncost.egg-info → sessioncost-0.2.2}/PKG-INFO +32 -17
  2. {sessioncost-0.2.0 → sessioncost-0.2.2}/README.md +167 -152
  3. {sessioncost-0.2.0 → sessioncost-0.2.2}/pyproject.toml +27 -27
  4. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/__init__.py +2 -2
  5. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/cli.py +22 -3
  6. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/skill/SKILL.md +5 -5
  7. {sessioncost-0.2.0 → sessioncost-0.2.2/sessioncost.egg-info}/PKG-INFO +32 -17
  8. {sessioncost-0.2.0 → sessioncost-0.2.2}/LICENSE +0 -0
  9. {sessioncost-0.2.0 → sessioncost-0.2.2}/MANIFEST.in +0 -0
  10. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/__main__.py +0 -0
  11. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/analyse.py +0 -0
  12. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/fixes.py +0 -0
  13. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/locate.py +0 -0
  14. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/model.py +0 -0
  15. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/prices.json +0 -0
  16. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/prices.py +0 -0
  17. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/readers/__init__.py +0 -0
  18. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/readers/_pb.py +0 -0
  19. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/readers/antigravity.py +0 -0
  20. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/readers/claude.py +0 -0
  21. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/readers/codex.py +0 -0
  22. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/readers/cursor.py +0 -0
  23. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/report.py +0 -0
  24. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost/report_template.html +0 -0
  25. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost.egg-info/SOURCES.txt +0 -0
  26. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost.egg-info/dependency_links.txt +0 -0
  27. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost.egg-info/entry_points.txt +0 -0
  28. {sessioncost-0.2.0 → sessioncost-0.2.2}/sessioncost.egg-info/top_level.txt +0 -0
  29. {sessioncost-0.2.0 → sessioncost-0.2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sessioncost
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: See how many tokens each turn of your coding-agent chat sends, why, and what to cut. Cost goes down with it.
5
5
  Author: kish21
6
6
  License-Expression: MIT
@@ -25,28 +25,41 @@ runs on your computer, and sends nothing anywhere.
25
25
 
26
26
  ## Get it
27
27
 
28
- **Using Claude Code?** Type these two lines in a Claude Code chat:
28
+ Works with **Claude Code, Codex, Cursor and Antigravity**. You don't need Python or Git: the installer brings what
29
+ it needs.
29
30
 
30
- ```
31
- /plugin marketplace add kish21/sessioncost
32
- /plugin install sessioncost@sessioncost
33
- ```
31
+ **1. Open a terminal**
34
32
 
35
- (Or in the editor: **Manage Plugins → Marketplaces**, add `kish21/sessioncost`, then install **sessioncost** from
36
- the **Plugins** tab.) This needs Python 3.10 or newer on your computer. If you have none, `/sessioncost` says so and
37
- gives you the line below.
33
+ - **Windows:** press the Windows key, type `powershell`, press Enter.
34
+ - **Mac:** press Cmd + Space, type `terminal`, press Enter.
38
35
 
39
- **Using Codex, Cursor or Antigravity (or Claude Code without Python)?** Paste one line in a terminal:
36
+ **2. Paste this line and press Enter**
40
37
 
41
38
  | Your computer | Paste this |
42
39
  |---|---|
43
- | Windows (PowerShell) | `irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 \| iex` |
44
- | macOS or Linux | `curl -fsSL https://raw.githubusercontent.com/kish21/sessioncost/main/install.sh \| sh` |
40
+ | Windows | `irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 \| iex` |
41
+ | Mac or Linux | `curl -fsSL https://raw.githubusercontent.com/kish21/sessioncost/main/install.sh \| sh` |
42
+
43
+ Wait about a minute. It ends with a line like `Claude Code /sessioncost added` for each agent it found.
44
+
45
+ **3. Restart your agent, and type `/sessioncost` in any chat**
46
+
47
+ To update later, paste the same line again.
45
48
 
46
- It installs SessionCost (bringing its own Python if your computer has none, via [uv](https://docs.astral.sh/uv/)),
47
- then adds `/sessioncost` to every agent you have. Run the same line again to update.
49
+ <details>
50
+ <summary>Already have Git and Python? Install it as a Claude Code plugin instead</summary>
51
+
52
+ In a Claude Code chat:
53
+
54
+ ```
55
+ /plugin marketplace add kish21/sessioncost
56
+ /plugin install sessioncost@sessioncost
57
+ ```
48
58
 
49
- **Then:** restart your agent and type `/sessioncost` in any chat.
59
+ (Or **Manage Plugins → Marketplaces**, add `kish21/sessioncost`, then install **sessioncost** from the **Plugins**
60
+ tab.) Claude Code downloads plugins with Git, so this needs [Git](https://git-scm.com/downloads), and SessionCost
61
+ needs Python 3.10 or newer. If the plugin says "git not found", use the line above instead.
62
+ </details>
50
63
 
51
64
  ## What you get
52
65
 
@@ -78,11 +91,13 @@ into the chat.
78
91
  ## If something goes wrong
79
92
 
80
93
  - **`/sessioncost` does nothing:** restart the agent after installing.
94
+ - **Two `/sessioncost` in Claude Code** (the plugin and the one-line install): run `sessioncost setup` again; with the
95
+ plugin installed it removes the extra copy.
96
+ - **"git not found" when adding the plugin:** use the one-line install instead; it needs neither Git nor Python.
81
97
  - **"Python is not found" with the Claude Code plugin:** paste the one line for your computer from above.
82
98
  - **Windows says running scripts is disabled:** run the line as
83
99
  `powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 | iex"`.
84
- - **Already have Python and prefer pip:** `pip install https://github.com/kish21/sessioncost/archive/refs/heads/main.zip`,
85
- then `python -m sessioncost setup`.
100
+ - **Already have Python and prefer pip:** `pip install sessioncost`, then `python -m sessioncost setup`.
86
101
 
87
102
  ## Which agents, and how exact
88
103
 
@@ -1,152 +1,167 @@
1
- # SessionCost
2
-
3
- See how many tokens each turn of your coding-agent chat sends, why, and what to cut.
4
-
5
- Every message you send makes the agent send the whole conversation again, plus its setup, plus whatever it read.
6
- Type `/sessioncost` in a chat and see, for each of your messages, how many tokens went out and what they were, the
7
- heaviest turn, and the fixes that would have sent fewer, measured from that chat. Fewer tokens is what makes an agent
8
- cheaper and faster, so the cost is shown too, as the result. It works in **Claude Code, Codex, Cursor and Antigravity**,
9
- runs on your computer, and sends nothing anywhere.
10
-
11
- ## Get it
12
-
13
- **Using Claude Code?** Type these two lines in a Claude Code chat:
14
-
15
- ```
16
- /plugin marketplace add kish21/sessioncost
17
- /plugin install sessioncost@sessioncost
18
- ```
19
-
20
- (Or in the editor: **Manage Plugins → Marketplaces**, add `kish21/sessioncost`, then install **sessioncost** from
21
- the **Plugins** tab.) This needs Python 3.10 or newer on your computer. If you have none, `/sessioncost` says so and
22
- gives you the line below.
23
-
24
- **Using Codex, Cursor or Antigravity (or Claude Code without Python)?** Paste one line in a terminal:
25
-
26
- | Your computer | Paste this |
27
- |---|---|
28
- | Windows (PowerShell) | `irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 \| iex` |
29
- | macOS or Linux | `curl -fsSL https://raw.githubusercontent.com/kish21/sessioncost/main/install.sh \| sh` |
30
-
31
- It installs SessionCost (bringing its own Python if your computer has none, via [uv](https://docs.astral.sh/uv/)),
32
- then adds `/sessioncost` to every agent you have. Run the same line again to update.
33
-
34
- **Then:** restart your agent and type `/sessioncost` in any chat.
35
-
36
- ## What you get
37
-
38
- A short summary in the chat:
39
-
40
- ```
41
- SessionCost: Add a CSV export to the reports page
42
- 1.9M tokens sent, 24k written · 5 turns · 31 calls · 22 min working, 6.0 min waiting for you
43
- Heaviest turn: #3 “now add tests” · 910k tokens sent (48%) · $1.12
44
- Top fix: Turn off tools this session never used · 420k fewer tokens sent · saves $0.214 (measured from this session)
45
- Cost: $2.31 exact (API prices 2026-10-08)
46
- Report: ~/.sessioncost/reports/<session-id>.html
47
- ```
48
-
49
- (The numbers above are an example.) Say yes when it offers to open the report: a page in your browser with
50
-
51
- - **Turn by turn**: one row per thing you asked, with the tokens it sent and wrote, its calls and minutes, and its
52
- cost. Click a turn to see its calls, and a call to see what it sent (fixed setup, carried history, new input) and
53
- what it wrote. Every set of parts adds up to the number above it.
54
- - **Replay**: step or play through the chat call by call and watch the context grow.
55
- - **Where the tokens went**: by kind of step (reading, running commands, writing files, helpers...) and by kind of
56
- token.
57
- - **What to fix**: the fixes that apply to this chat, each with the tokens it would cut and the money that saves.
58
- - **Sent with every call**: the agent's fixed setup, and which tools were never used.
59
-
60
- Asking costs almost nothing: the agent runs the tool and shows its summary, and never reads the log or the report
61
- into the chat.
62
-
63
- ## If something goes wrong
64
-
65
- - **`/sessioncost` does nothing:** restart the agent after installing.
66
- - **"Python is not found" with the Claude Code plugin:** paste the one line for your computer from above.
67
- - **Windows says running scripts is disabled:** run the line as
68
- `powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 | iex"`.
69
- - **Already have Python and prefer pip:** `pip install https://github.com/kish21/sessioncost/archive/refs/heads/main.zip`,
70
- then `python -m sessioncost setup`.
71
-
72
- ## Which agents, and how exact
73
-
74
- | Agent | Where its log is | Tokens |
75
- |---|---|---|
76
- | Claude Code | `~/.claude/projects/<project>/<session>.jsonl` | exact, from the log |
77
- | Codex (CLI, IDE, app) | `~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl` | exact, from the log |
78
- | Antigravity | `~/.gemini/antigravity-ide/conversations/<id>.db` | exact, from the log |
79
- | Cursor | Cursor's `User/globalStorage/state.vscdb` | **estimated** from text size; exact with your usage export |
80
-
81
- Cursor keeps no token counts on your computer. SessionCost rebuilds each call from the chat's messages, estimates
82
- its size from the text (characters / 4), and scales it so the last call matches the context size Cursor itself
83
- recorded. For exact numbers, download your usage export from the Cursor dashboard and pass it with
84
- `--cursor-usage file.csv`.
85
-
86
- ## From a terminal
87
-
88
- After the one-line install, `sessioncost` also works in a terminal, from your project folder, and costs zero tokens:
89
-
90
- ```
91
- sessioncost # the newest chat of this folder's project (same as: sessioncost last)
92
- sessioncost list # recent chats: date, id, cost, turns, calls, first message
93
- sessioncost 3f2a9c1e # one chat, by the first characters of its id
94
- sessioncost path/to/session.jsonl # or an Antigravity .db
95
- sessioncost 3f2a9c1e --cursor-usage usage-events.csv # a Cursor chat, with exact tokens from your export
96
- sessioncost setup # add /sessioncost to your agents again
97
- ```
98
-
99
- Options: `--project <dir>` (another project folder), `--no-open` (write the report, do not open it), `--json`
100
- (print the full model as JSON), `--prices <file>`, `--subscription` (see below), `--cursor-usage <file.csv>`.
101
-
102
- `last` and `list` look at every agent above for the project folder. `last` picks the chat whose **last logged
103
- message** is newest, not the newest file: reopening an old chat touches its file but does not make it the latest.
104
-
105
- ## Privacy
106
-
107
- Local only. SessionCost reads log files on your disk and writes one HTML file to `~/.sessioncost/reports/`. It
108
- sends nothing anywhere, calls no AI model and needs no network. The report page loads a web font from Google Fonts
109
- when you are online and falls back to system fonts when you are not.
110
-
111
- ## How money is labelled
112
-
113
- Every token class is priced on its own: new input, input written to the cache (5-minute and 1-hour rates differ),
114
- input re-read from the cache, and output (the model's writing, hidden thinking included). Each model call is
115
- counted once, even though the log writes one reply as several rows.
116
-
117
- - **exact (API prices as of <date>)**: every model in the session has a checked rate in the price table. The
118
- figure is what the same tokens cost on the public API on that date.
119
- - **estimate**: at least one model has no checked rate (the OpenAI and Gemini rates are from third-party price
120
- lists, not yet checked against the providers' own pages), or the tokens themselves are estimated (Cursor without
121
- its usage export).
122
- - **API-equivalent**: with `--subscription`, and always for Antigravity. On a plan that is not billed per token
123
- (Claude Pro or Max, a ChatGPT plan, Antigravity) the figure is what the same work would cost at API prices.
124
-
125
- When the log carries the agent's own running total (Claude Code), or you give Cursor's usage export with its cost
126
- column, the report shows it as a cross-check.
127
-
128
- Prices live in `sessioncost/prices.json` (USD per million tokens). Override any model in
129
- `~/.sessioncost/prices.json` (merged over the built-in table) or pass `--prices <file>`.
130
-
131
- Sizes the log does not give directly (how much of a call's input was the fixed setup, how much of its output was a
132
- file rather than a message) are estimated from the text (characters / 4) and scaled so the parts add up exactly to
133
- the token counts in the log. They are marked "~ estimated" on the page.
134
-
135
- ## The built-in fixes
136
-
137
- Three simple checks. Each one shows the tokens it would cut and what they cost, in this session.
138
-
139
- 1. **Tools never used, sent with every call.** Tool definitions travel with every model call. The saving is what
140
- the unused ones cost across the session's calls.
141
- 2. **The same unchanged file read again.** A read that returned exactly the same text as an earlier read in the
142
- same chat. The saving is what that copy cost when it came in, plus on every later call that carried it.
143
- 3. **A confirm-only stop.** You typed only "yes", "ok", "save" or "go" (or picked such an answer on a question
144
- card), and the agent had stopped just to ask. The saving is the cost of re-sending the conversation to receive
145
- that answer.
146
-
147
- ## Roadmap
148
-
149
- - Compare two sessions of the same task side by side.
150
- - An optional fix engine with more checks.
151
-
152
- _Status: early. MIT license._
1
+ # SessionCost
2
+
3
+ See how many tokens each turn of your coding-agent chat sends, why, and what to cut.
4
+
5
+ Every message you send makes the agent send the whole conversation again, plus its setup, plus whatever it read.
6
+ Type `/sessioncost` in a chat and see, for each of your messages, how many tokens went out and what they were, the
7
+ heaviest turn, and the fixes that would have sent fewer, measured from that chat. Fewer tokens is what makes an agent
8
+ cheaper and faster, so the cost is shown too, as the result. It works in **Claude Code, Codex, Cursor and Antigravity**,
9
+ runs on your computer, and sends nothing anywhere.
10
+
11
+ ## Get it
12
+
13
+ Works with **Claude Code, Codex, Cursor and Antigravity**. You don't need Python or Git: the installer brings what
14
+ it needs.
15
+
16
+ **1. Open a terminal**
17
+
18
+ - **Windows:** press the Windows key, type `powershell`, press Enter.
19
+ - **Mac:** press Cmd + Space, type `terminal`, press Enter.
20
+
21
+ **2. Paste this line and press Enter**
22
+
23
+ | Your computer | Paste this |
24
+ |---|---|
25
+ | Windows | `irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 \| iex` |
26
+ | Mac or Linux | `curl -fsSL https://raw.githubusercontent.com/kish21/sessioncost/main/install.sh \| sh` |
27
+
28
+ Wait about a minute. It ends with a line like `Claude Code /sessioncost added` for each agent it found.
29
+
30
+ **3. Restart your agent, and type `/sessioncost` in any chat**
31
+
32
+ To update later, paste the same line again.
33
+
34
+ <details>
35
+ <summary>Already have Git and Python? Install it as a Claude Code plugin instead</summary>
36
+
37
+ In a Claude Code chat:
38
+
39
+ ```
40
+ /plugin marketplace add kish21/sessioncost
41
+ /plugin install sessioncost@sessioncost
42
+ ```
43
+
44
+ (Or **Manage Plugins → Marketplaces**, add `kish21/sessioncost`, then install **sessioncost** from the **Plugins**
45
+ tab.) Claude Code downloads plugins with Git, so this needs [Git](https://git-scm.com/downloads), and SessionCost
46
+ needs Python 3.10 or newer. If the plugin says "git not found", use the line above instead.
47
+ </details>
48
+
49
+ ## What you get
50
+
51
+ A short summary in the chat:
52
+
53
+ ```
54
+ SessionCost: Add a CSV export to the reports page
55
+ 1.9M tokens sent, 24k written · 5 turns · 31 calls · 22 min working, 6.0 min waiting for you
56
+ Heaviest turn: #3 “now add tests” · 910k tokens sent (48%) · $1.12
57
+ Top fix: Turn off tools this session never used · 420k fewer tokens sent · saves $0.214 (measured from this session)
58
+ Cost: $2.31 exact (API prices 2026-10-08)
59
+ Report: ~/.sessioncost/reports/<session-id>.html
60
+ ```
61
+
62
+ (The numbers above are an example.) Say yes when it offers to open the report: a page in your browser with
63
+
64
+ - **Turn by turn**: one row per thing you asked, with the tokens it sent and wrote, its calls and minutes, and its
65
+ cost. Click a turn to see its calls, and a call to see what it sent (fixed setup, carried history, new input) and
66
+ what it wrote. Every set of parts adds up to the number above it.
67
+ - **Replay**: step or play through the chat call by call and watch the context grow.
68
+ - **Where the tokens went**: by kind of step (reading, running commands, writing files, helpers...) and by kind of
69
+ token.
70
+ - **What to fix**: the fixes that apply to this chat, each with the tokens it would cut and the money that saves.
71
+ - **Sent with every call**: the agent's fixed setup, and which tools were never used.
72
+
73
+ Asking costs almost nothing: the agent runs the tool and shows its summary, and never reads the log or the report
74
+ into the chat.
75
+
76
+ ## If something goes wrong
77
+
78
+ - **`/sessioncost` does nothing:** restart the agent after installing.
79
+ - **Two `/sessioncost` in Claude Code** (the plugin and the one-line install): run `sessioncost setup` again; with the
80
+ plugin installed it removes the extra copy.
81
+ - **"git not found" when adding the plugin:** use the one-line install instead; it needs neither Git nor Python.
82
+ - **"Python is not found" with the Claude Code plugin:** paste the one line for your computer from above.
83
+ - **Windows says running scripts is disabled:** run the line as
84
+ `powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 | iex"`.
85
+ - **Already have Python and prefer pip:** `pip install sessioncost`, then `python -m sessioncost setup`.
86
+
87
+ ## Which agents, and how exact
88
+
89
+ | Agent | Where its log is | Tokens |
90
+ |---|---|---|
91
+ | Claude Code | `~/.claude/projects/<project>/<session>.jsonl` | exact, from the log |
92
+ | Codex (CLI, IDE, app) | `~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl` | exact, from the log |
93
+ | Antigravity | `~/.gemini/antigravity-ide/conversations/<id>.db` | exact, from the log |
94
+ | Cursor | Cursor's `User/globalStorage/state.vscdb` | **estimated** from text size; exact with your usage export |
95
+
96
+ Cursor keeps no token counts on your computer. SessionCost rebuilds each call from the chat's messages, estimates
97
+ its size from the text (characters / 4), and scales it so the last call matches the context size Cursor itself
98
+ recorded. For exact numbers, download your usage export from the Cursor dashboard and pass it with
99
+ `--cursor-usage file.csv`.
100
+
101
+ ## From a terminal
102
+
103
+ After the one-line install, `sessioncost` also works in a terminal, from your project folder, and costs zero tokens:
104
+
105
+ ```
106
+ sessioncost # the newest chat of this folder's project (same as: sessioncost last)
107
+ sessioncost list # recent chats: date, id, cost, turns, calls, first message
108
+ sessioncost 3f2a9c1e # one chat, by the first characters of its id
109
+ sessioncost path/to/session.jsonl # or an Antigravity .db
110
+ sessioncost 3f2a9c1e --cursor-usage usage-events.csv # a Cursor chat, with exact tokens from your export
111
+ sessioncost setup # add /sessioncost to your agents again
112
+ ```
113
+
114
+ Options: `--project <dir>` (another project folder), `--no-open` (write the report, do not open it), `--json`
115
+ (print the full model as JSON), `--prices <file>`, `--subscription` (see below), `--cursor-usage <file.csv>`.
116
+
117
+ `last` and `list` look at every agent above for the project folder. `last` picks the chat whose **last logged
118
+ message** is newest, not the newest file: reopening an old chat touches its file but does not make it the latest.
119
+
120
+ ## Privacy
121
+
122
+ Local only. SessionCost reads log files on your disk and writes one HTML file to `~/.sessioncost/reports/`. It
123
+ sends nothing anywhere, calls no AI model and needs no network. The report page loads a web font from Google Fonts
124
+ when you are online and falls back to system fonts when you are not.
125
+
126
+ ## How money is labelled
127
+
128
+ Every token class is priced on its own: new input, input written to the cache (5-minute and 1-hour rates differ),
129
+ input re-read from the cache, and output (the model's writing, hidden thinking included). Each model call is
130
+ counted once, even though the log writes one reply as several rows.
131
+
132
+ - **exact (API prices as of <date>)**: every model in the session has a checked rate in the price table. The
133
+ figure is what the same tokens cost on the public API on that date.
134
+ - **estimate**: at least one model has no checked rate (the OpenAI and Gemini rates are from third-party price
135
+ lists, not yet checked against the providers' own pages), or the tokens themselves are estimated (Cursor without
136
+ its usage export).
137
+ - **API-equivalent**: with `--subscription`, and always for Antigravity. On a plan that is not billed per token
138
+ (Claude Pro or Max, a ChatGPT plan, Antigravity) the figure is what the same work would cost at API prices.
139
+
140
+ When the log carries the agent's own running total (Claude Code), or you give Cursor's usage export with its cost
141
+ column, the report shows it as a cross-check.
142
+
143
+ Prices live in `sessioncost/prices.json` (USD per million tokens). Override any model in
144
+ `~/.sessioncost/prices.json` (merged over the built-in table) or pass `--prices <file>`.
145
+
146
+ Sizes the log does not give directly (how much of a call's input was the fixed setup, how much of its output was a
147
+ file rather than a message) are estimated from the text (characters / 4) and scaled so the parts add up exactly to
148
+ the token counts in the log. They are marked "~ estimated" on the page.
149
+
150
+ ## The built-in fixes
151
+
152
+ Three simple checks. Each one shows the tokens it would cut and what they cost, in this session.
153
+
154
+ 1. **Tools never used, sent with every call.** Tool definitions travel with every model call. The saving is what
155
+ the unused ones cost across the session's calls.
156
+ 2. **The same unchanged file read again.** A read that returned exactly the same text as an earlier read in the
157
+ same chat. The saving is what that copy cost when it came in, plus on every later call that carried it.
158
+ 3. **A confirm-only stop.** You typed only "yes", "ok", "save" or "go" (or picked such an answer on a question
159
+ card), and the agent had stopped just to ask. The saving is the cost of re-sending the conversation to receive
160
+ that answer.
161
+
162
+ ## Roadmap
163
+
164
+ - Compare two sessions of the same task side by side.
165
+ - An optional fix engine with more checks.
166
+
167
+ _Status: early. MIT license._
@@ -1,27 +1,27 @@
1
- [build-system]
2
- requires = ["setuptools>=61"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "sessioncost"
7
- version = "0.2.0"
8
- description = "See how many tokens each turn of your coding-agent chat sends, why, and what to cut. Cost goes down with it."
9
- readme = "README.md"
10
- license = "MIT"
11
- requires-python = ">=3.10"
12
- dependencies = []
13
- authors = [{ name = "kish21" }]
14
- keywords = ["claude-code", "codex", "cursor", "antigravity", "tokens", "cost"]
15
- classifiers = ["Programming Language :: Python :: 3", "Environment :: Console"]
16
-
17
- [project.urls]
18
- Homepage = "https://github.com/kish21/sessioncost"
19
-
20
- [project.scripts]
21
- sessioncost = "sessioncost.cli:main"
22
-
23
- [tool.setuptools]
24
- packages = ["sessioncost", "sessioncost.readers"]
25
-
26
- [tool.setuptools.package-data]
27
- sessioncost = ["prices.json", "report_template.html", "skill/SKILL.md"]
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sessioncost"
7
+ version = "0.2.2"
8
+ description = "See how many tokens each turn of your coding-agent chat sends, why, and what to cut. Cost goes down with it."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ dependencies = []
13
+ authors = [{ name = "kish21" }]
14
+ keywords = ["claude-code", "codex", "cursor", "antigravity", "tokens", "cost"]
15
+ classifiers = ["Programming Language :: Python :: 3", "Environment :: Console"]
16
+
17
+ [project.urls]
18
+ Homepage = "https://github.com/kish21/sessioncost"
19
+
20
+ [project.scripts]
21
+ sessioncost = "sessioncost.cli:main"
22
+
23
+ [tool.setuptools]
24
+ packages = ["sessioncost", "sessioncost.readers"]
25
+
26
+ [tool.setuptools.package-data]
27
+ sessioncost = ["prices.json", "report_template.html", "skill/SKILL.md"]
@@ -1,2 +1,2 @@
1
- """SessionCost: see where every token of your agent session went, turn by turn, and what to fix."""
2
- __version__ = "0.2.0"
1
+ """SessionCost: see where every token of your agent session went, turn by turn, and what to fix."""
2
+ __version__ = "0.2.2"
@@ -91,8 +91,18 @@ SKILL_HOMES = [ # (agent, its folder, where its personal skills live inside it
91
91
  ]
92
92
 
93
93
 
94
- def setup(home: Path | None = None) -> list[tuple[str, Path]]:
95
- """Add the /sessioncost skill to every agent installed for this user. Returns (agent, skill file) written."""
94
+ def claude_plugin_installed(home: Path) -> bool:
95
+ """True when Claude Code has the SessionCost plugin, which brings its own /sessioncost."""
96
+ try:
97
+ plugins = json.loads((home / ".claude" / "plugins" / "installed_plugins.json").read_text(encoding="utf-8"))
98
+ except (OSError, ValueError):
99
+ return False
100
+ return any(k.startswith("sessioncost@") for k in (plugins.get("plugins") or {}))
101
+
102
+
103
+ def setup(home: Path | None = None) -> list[tuple[str, Path | None]]:
104
+ """Add the /sessioncost skill to every agent installed for this user. Returns (agent, skill file written), with
105
+ None for Claude Code when the plugin already provides /sessioncost."""
96
106
  home = home or Path.home()
97
107
  # The skill names this exact Python, so it runs even when no 'python' or 'sessioncost' is on the PATH.
98
108
  exe = Path(sys.executable).as_posix()
@@ -105,6 +115,14 @@ def setup(home: Path | None = None) -> list[tuple[str, Path]]:
105
115
  if not (home / folder).is_dir():
106
116
  continue
107
117
  dest = home / folder / sub / "sessioncost" / "SKILL.md"
118
+ if folder == ".claude" and claude_plugin_installed(home):
119
+ # Two /sessioncost in one agent confuse people: remove a copy an earlier setup wrote, add none.
120
+ if dest.is_file() and "name: sessioncost" in dest.read_text(encoding="utf-8", errors="replace"):
121
+ dest.unlink()
122
+ if not any(dest.parent.iterdir()):
123
+ dest.parent.rmdir()
124
+ done.append((agent, None))
125
+ continue
108
126
  dest.parent.mkdir(parents=True, exist_ok=True)
109
127
  dest.write_text(text, encoding="utf-8")
110
128
  done.append((agent, dest))
@@ -117,7 +135,8 @@ def cmd_setup() -> int:
117
135
  print("No Claude Code, Codex, Antigravity or Cursor folder found for this user; nothing to set up.")
118
136
  return 1
119
137
  for agent, dest in done:
120
- print(f"{agent:12} /sessioncost added ({dest})")
138
+ print(f"{agent:12} /sessioncost added ({dest})" if dest else
139
+ f"{agent:12} /sessioncost comes from the SessionCost plugin; nothing added")
121
140
  print("\nRestart the agent if it is open, then type /sessioncost in a chat.")
122
141
  return 0
123
142
 
@@ -14,10 +14,10 @@ no AI model.
14
14
  1. Run this from the project folder of the current session (one command, nothing else):
15
15
 
16
16
  ```
17
- {{RUN}} last --no-open
17
+ {{RUN}} last
18
18
  ```
19
19
 
20
- If that fails because the program is missing, try `sessioncost last --no-open`. If that fails too, tell the user
20
+ If that fails because the program is missing, try `sessioncost last`. If that fails too, tell the user
21
21
  SessionCost is not installed and give them the one line for their system, then stop:
22
22
 
23
23
  - Windows (PowerShell): `irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 | iex`
@@ -25,9 +25,9 @@ no AI model.
25
25
 
26
26
  2. Show the user the printed summary exactly as printed, in a code block. Do not reword or recompute it.
27
27
 
28
- 3. Add one line: the report path from the summary, and offer to open it ("Want me to open the report?").
29
- If they say yes, open the file with the system's default opener (`start "" <path>` on Windows, `open <path>`
30
- on macOS, `xdg-open <path>` on Linux).
28
+ 3. The tool opens the report in the browser by itself. Add one line: "The full report is open in your browser"
29
+ and its path from the summary. Do not offer to open it. Only if the user says it did not open, open the file with
30
+ the system's default opener (`start "" <path>` on Windows, `open <path>` on macOS, `xdg-open <path>` on Linux).
31
31
 
32
32
  ## Never
33
33
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sessioncost
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: See how many tokens each turn of your coding-agent chat sends, why, and what to cut. Cost goes down with it.
5
5
  Author: kish21
6
6
  License-Expression: MIT
@@ -25,28 +25,41 @@ runs on your computer, and sends nothing anywhere.
25
25
 
26
26
  ## Get it
27
27
 
28
- **Using Claude Code?** Type these two lines in a Claude Code chat:
28
+ Works with **Claude Code, Codex, Cursor and Antigravity**. You don't need Python or Git: the installer brings what
29
+ it needs.
29
30
 
30
- ```
31
- /plugin marketplace add kish21/sessioncost
32
- /plugin install sessioncost@sessioncost
33
- ```
31
+ **1. Open a terminal**
34
32
 
35
- (Or in the editor: **Manage Plugins → Marketplaces**, add `kish21/sessioncost`, then install **sessioncost** from
36
- the **Plugins** tab.) This needs Python 3.10 or newer on your computer. If you have none, `/sessioncost` says so and
37
- gives you the line below.
33
+ - **Windows:** press the Windows key, type `powershell`, press Enter.
34
+ - **Mac:** press Cmd + Space, type `terminal`, press Enter.
38
35
 
39
- **Using Codex, Cursor or Antigravity (or Claude Code without Python)?** Paste one line in a terminal:
36
+ **2. Paste this line and press Enter**
40
37
 
41
38
  | Your computer | Paste this |
42
39
  |---|---|
43
- | Windows (PowerShell) | `irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 \| iex` |
44
- | macOS or Linux | `curl -fsSL https://raw.githubusercontent.com/kish21/sessioncost/main/install.sh \| sh` |
40
+ | Windows | `irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 \| iex` |
41
+ | Mac or Linux | `curl -fsSL https://raw.githubusercontent.com/kish21/sessioncost/main/install.sh \| sh` |
42
+
43
+ Wait about a minute. It ends with a line like `Claude Code /sessioncost added` for each agent it found.
44
+
45
+ **3. Restart your agent, and type `/sessioncost` in any chat**
46
+
47
+ To update later, paste the same line again.
45
48
 
46
- It installs SessionCost (bringing its own Python if your computer has none, via [uv](https://docs.astral.sh/uv/)),
47
- then adds `/sessioncost` to every agent you have. Run the same line again to update.
49
+ <details>
50
+ <summary>Already have Git and Python? Install it as a Claude Code plugin instead</summary>
51
+
52
+ In a Claude Code chat:
53
+
54
+ ```
55
+ /plugin marketplace add kish21/sessioncost
56
+ /plugin install sessioncost@sessioncost
57
+ ```
48
58
 
49
- **Then:** restart your agent and type `/sessioncost` in any chat.
59
+ (Or **Manage Plugins → Marketplaces**, add `kish21/sessioncost`, then install **sessioncost** from the **Plugins**
60
+ tab.) Claude Code downloads plugins with Git, so this needs [Git](https://git-scm.com/downloads), and SessionCost
61
+ needs Python 3.10 or newer. If the plugin says "git not found", use the line above instead.
62
+ </details>
50
63
 
51
64
  ## What you get
52
65
 
@@ -78,11 +91,13 @@ into the chat.
78
91
  ## If something goes wrong
79
92
 
80
93
  - **`/sessioncost` does nothing:** restart the agent after installing.
94
+ - **Two `/sessioncost` in Claude Code** (the plugin and the one-line install): run `sessioncost setup` again; with the
95
+ plugin installed it removes the extra copy.
96
+ - **"git not found" when adding the plugin:** use the one-line install instead; it needs neither Git nor Python.
81
97
  - **"Python is not found" with the Claude Code plugin:** paste the one line for your computer from above.
82
98
  - **Windows says running scripts is disabled:** run the line as
83
99
  `powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/kish21/sessioncost/main/install.ps1 | iex"`.
84
- - **Already have Python and prefer pip:** `pip install https://github.com/kish21/sessioncost/archive/refs/heads/main.zip`,
85
- then `python -m sessioncost setup`.
100
+ - **Already have Python and prefer pip:** `pip install sessioncost`, then `python -m sessioncost setup`.
86
101
 
87
102
  ## Which agents, and how exact
88
103
 
File without changes
File without changes
File without changes