tokenops 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 (23) hide show
  1. {tokenops-0.2.0 → tokenops-0.2.2}/PKG-INFO +8 -6
  2. {tokenops-0.2.0 → tokenops-0.2.2}/README.md +7 -5
  3. {tokenops-0.2.0 → tokenops-0.2.2}/pyproject.toml +36 -36
  4. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops.egg-info/PKG-INFO +8 -6
  5. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/doctor.py +23 -6
  6. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops.egg-info/SOURCES.txt +0 -0
  7. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops.egg-info/dependency_links.txt +0 -0
  8. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops.egg-info/entry_points.txt +0 -0
  9. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops.egg-info/top_level.txt +0 -0
  10. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/__init__.py +0 -0
  11. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/ab.py +0 -0
  12. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/caveman.py +0 -0
  13. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/cost.py +0 -0
  14. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/guard.py +0 -0
  15. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/prices.json +0 -0
  16. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/prices.py +0 -0
  17. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/prompts.py +0 -0
  18. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/rtk.py +0 -0
  19. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/savers.py +0 -0
  20. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/settings.py +0 -0
  21. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cc/transcript.py +0 -0
  22. {tokenops-0.2.0 → tokenops-0.2.2}/scripts/tokenops_cli.py +0 -0
  23. {tokenops-0.2.0 → tokenops-0.2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tokenops
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Which prompts ate your Claude Code limit, and why? Read from your own session logs.
5
5
  Author: Susheem Koul, Tisha Chawla
6
6
  License-Expression: MIT
@@ -23,8 +23,8 @@ and what to change. Read from your own session logs, on your machine.
23
23
 
24
24
  Why am I hitting my limit? (last 7 days, 12 sessions, 304 prompts, $235 at API list prices)
25
25
 
26
- 37% of your Claude usage went to coming back after a break.
27
- 39 times the cache had expired, so Claude re-paid for the whole conversation.
26
+ 37% of your Claude usage went to the first message after a break.
27
+ 39 times the cache had expired, so Claude reloaded the whole conversation.
28
28
  /compact before you step away would have saved ~31%.
29
29
 
30
30
  Your 3 most expensive prompts (9% of usage)
@@ -37,7 +37,7 @@ and what to change. Read from your own session logs, on your machine.
37
37
  ...
38
38
  Where your usage goes
39
39
  41% Re-reading context every call
40
- 37% Coming back after breaks (cache re-written)
40
+ 37% First message after a break (cache reloaded)
41
41
  12% Claude's output
42
42
  11% Caching new context
43
43
 
@@ -76,10 +76,12 @@ uvx tokenops doctor
76
76
  Models with a 1M-token context can carry a conversation that long.
77
77
  - **CACHE EXPIRED** means the call came more than the cache lifetime (1 hour on a Claude plan,
78
78
  5 minutes with an API key) after the previous one, and wrote most of the conversation to the
79
- cache again at the cache-write price. The headline and the "Coming back after breaks" row are
79
+ cache again at the cache-write price. The headline and the "First message after a break" row are
80
80
  the same number: the cache writes of those calls.
81
81
  - **5-hour windows** are estimated from your first prompt in each, not read from Anthropic's
82
82
  meter. The cheaper costs are estimates: only the calls a break made expensive are re-priced.
83
+ - **Share yours.** The report ends with one line you can paste as is: your headline share and the
84
+ command, with no prompts, project names or dollars.
83
85
  - **Sharing a screenshot?** From a terminal, `uvx tokenops doctor --redact` hides your prompts and
84
86
  project names ("project A", "project B").
85
87
 
@@ -133,7 +135,7 @@ transcripts, counts a response once even when a forked session copies it, and pr
133
135
  and cache writes (1.25x input for the 5-minute cache, 2x for the 1-hour cache). Prices come from
134
136
  TokenOps' price book (`src/tokenops/framework/pricing.py`).
135
137
 
136
- - **Coming back after breaks:** a cache write of 20,000+ tokens, at least half the conversation,
138
+ - **First message after a break:** a cache write of 20,000+ tokens, at least half the conversation,
137
139
  more than the cache lifetime after the previous call. The cache had expired, so the whole
138
140
  conversation was written again.
139
141
  - **Re-reading context:** cache reads. Every call reads the conversation again.
@@ -8,8 +8,8 @@ and what to change. Read from your own session logs, on your machine.
8
8
 
9
9
  Why am I hitting my limit? (last 7 days, 12 sessions, 304 prompts, $235 at API list prices)
10
10
 
11
- 37% of your Claude usage went to coming back after a break.
12
- 39 times the cache had expired, so Claude re-paid for the whole conversation.
11
+ 37% of your Claude usage went to the first message after a break.
12
+ 39 times the cache had expired, so Claude reloaded the whole conversation.
13
13
  /compact before you step away would have saved ~31%.
14
14
 
15
15
  Your 3 most expensive prompts (9% of usage)
@@ -22,7 +22,7 @@ and what to change. Read from your own session logs, on your machine.
22
22
  ...
23
23
  Where your usage goes
24
24
  41% Re-reading context every call
25
- 37% Coming back after breaks (cache re-written)
25
+ 37% First message after a break (cache reloaded)
26
26
  12% Claude's output
27
27
  11% Caching new context
28
28
 
@@ -61,10 +61,12 @@ uvx tokenops doctor
61
61
  Models with a 1M-token context can carry a conversation that long.
62
62
  - **CACHE EXPIRED** means the call came more than the cache lifetime (1 hour on a Claude plan,
63
63
  5 minutes with an API key) after the previous one, and wrote most of the conversation to the
64
- cache again at the cache-write price. The headline and the "Coming back after breaks" row are
64
+ cache again at the cache-write price. The headline and the "First message after a break" row are
65
65
  the same number: the cache writes of those calls.
66
66
  - **5-hour windows** are estimated from your first prompt in each, not read from Anthropic's
67
67
  meter. The cheaper costs are estimates: only the calls a break made expensive are re-priced.
68
+ - **Share yours.** The report ends with one line you can paste as is: your headline share and the
69
+ command, with no prompts, project names or dollars.
68
70
  - **Sharing a screenshot?** From a terminal, `uvx tokenops doctor --redact` hides your prompts and
69
71
  project names ("project A", "project B").
70
72
 
@@ -118,7 +120,7 @@ transcripts, counts a response once even when a forked session copies it, and pr
118
120
  and cache writes (1.25x input for the 5-minute cache, 2x for the 1-hour cache). Prices come from
119
121
  TokenOps' price book (`src/tokenops/framework/pricing.py`).
120
122
 
121
- - **Coming back after breaks:** a cache write of 20,000+ tokens, at least half the conversation,
123
+ - **First message after a break:** a cache write of 20,000+ tokens, at least half the conversation,
122
124
  more than the cache lifetime after the previous call. The cache had expired, so the whole
123
125
  conversation was written again.
124
126
  - **Re-reading context:** cache reads. Every call reads the conversation again.
@@ -1,36 +1,36 @@
1
- # The Claude Code plugin's CLI as a small PyPI package, so `uvx tokenops why` runs without
2
- # installing the plugin (ADR 0012). Standard library only; the plugin itself does not use this file.
3
- [build-system]
4
- requires = ["setuptools>=77"]
5
- build-backend = "setuptools.build_meta"
6
-
7
- [project]
8
- name = "tokenops"
9
- version = "0.2.0"
10
- description = "Which prompts ate your Claude Code limit, and why? Read from your own session logs."
11
- readme = "README.md"
12
- requires-python = ">=3.9"
13
- license = "MIT"
14
- authors = [{ name = "Susheem Koul" }, { name = "Tisha Chawla" }]
15
- keywords = ["claude", "claude-code", "tokens", "usage", "rate-limit", "prompt-cache"]
16
- classifiers = [
17
- "Environment :: Console",
18
- "Intended Audience :: Developers",
19
- "Programming Language :: Python :: 3",
20
- ]
21
- dependencies = []
22
-
23
- [project.urls]
24
- Homepage = "https://github.com/theagentplane/tokenops/tree/main/integrations/claude-code"
25
- Repository = "https://github.com/theagentplane/tokenops"
26
-
27
- [project.scripts]
28
- tokenops = "tokenops_cli:main"
29
-
30
- [tool.setuptools]
31
- package-dir = { "" = "scripts" }
32
- packages = ["tokenops_cc"]
33
- py-modules = ["tokenops_cli"]
34
-
35
- [tool.setuptools.package-data]
36
- tokenops_cc = ["prices.json"]
1
+ # The Claude Code plugin's CLI as a small PyPI package, so `uvx tokenops why` runs without
2
+ # installing the plugin (ADR 0012). Standard library only; the plugin itself does not use this file.
3
+ [build-system]
4
+ requires = ["setuptools>=77"]
5
+ build-backend = "setuptools.build_meta"
6
+
7
+ [project]
8
+ name = "tokenops"
9
+ version = "0.2.2"
10
+ description = "Which prompts ate your Claude Code limit, and why? Read from your own session logs."
11
+ readme = "README.md"
12
+ requires-python = ">=3.9"
13
+ license = "MIT"
14
+ authors = [{ name = "Susheem Koul" }, { name = "Tisha Chawla" }]
15
+ keywords = ["claude", "claude-code", "tokens", "usage", "rate-limit", "prompt-cache"]
16
+ classifiers = [
17
+ "Environment :: Console",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ ]
21
+ dependencies = []
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/theagentplane/tokenops/tree/main/integrations/claude-code"
25
+ Repository = "https://github.com/theagentplane/tokenops"
26
+
27
+ [project.scripts]
28
+ tokenops = "tokenops_cli:main"
29
+
30
+ [tool.setuptools]
31
+ package-dir = { "" = "scripts" }
32
+ packages = ["tokenops_cc"]
33
+ py-modules = ["tokenops_cli"]
34
+
35
+ [tool.setuptools.package-data]
36
+ tokenops_cc = ["prices.json"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tokenops
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Which prompts ate your Claude Code limit, and why? Read from your own session logs.
5
5
  Author: Susheem Koul, Tisha Chawla
6
6
  License-Expression: MIT
@@ -23,8 +23,8 @@ and what to change. Read from your own session logs, on your machine.
23
23
 
24
24
  Why am I hitting my limit? (last 7 days, 12 sessions, 304 prompts, $235 at API list prices)
25
25
 
26
- 37% of your Claude usage went to coming back after a break.
27
- 39 times the cache had expired, so Claude re-paid for the whole conversation.
26
+ 37% of your Claude usage went to the first message after a break.
27
+ 39 times the cache had expired, so Claude reloaded the whole conversation.
28
28
  /compact before you step away would have saved ~31%.
29
29
 
30
30
  Your 3 most expensive prompts (9% of usage)
@@ -37,7 +37,7 @@ and what to change. Read from your own session logs, on your machine.
37
37
  ...
38
38
  Where your usage goes
39
39
  41% Re-reading context every call
40
- 37% Coming back after breaks (cache re-written)
40
+ 37% First message after a break (cache reloaded)
41
41
  12% Claude's output
42
42
  11% Caching new context
43
43
 
@@ -76,10 +76,12 @@ uvx tokenops doctor
76
76
  Models with a 1M-token context can carry a conversation that long.
77
77
  - **CACHE EXPIRED** means the call came more than the cache lifetime (1 hour on a Claude plan,
78
78
  5 minutes with an API key) after the previous one, and wrote most of the conversation to the
79
- cache again at the cache-write price. The headline and the "Coming back after breaks" row are
79
+ cache again at the cache-write price. The headline and the "First message after a break" row are
80
80
  the same number: the cache writes of those calls.
81
81
  - **5-hour windows** are estimated from your first prompt in each, not read from Anthropic's
82
82
  meter. The cheaper costs are estimates: only the calls a break made expensive are re-priced.
83
+ - **Share yours.** The report ends with one line you can paste as is: your headline share and the
84
+ command, with no prompts, project names or dollars.
83
85
  - **Sharing a screenshot?** From a terminal, `uvx tokenops doctor --redact` hides your prompts and
84
86
  project names ("project A", "project B").
85
87
 
@@ -133,7 +135,7 @@ transcripts, counts a response once even when a forked session copies it, and pr
133
135
  and cache writes (1.25x input for the 5-minute cache, 2x for the 1-hour cache). Prices come from
134
136
  TokenOps' price book (`src/tokenops/framework/pricing.py`).
135
137
 
136
- - **Coming back after breaks:** a cache write of 20,000+ tokens, at least half the conversation,
138
+ - **First message after a break:** a cache write of 20,000+ tokens, at least half the conversation,
137
139
  more than the cache lifetime after the previous call. The cache had expired, so the whole
138
140
  conversation was written again.
139
141
  - **Re-reading context:** cache reads. Every call reads the conversation again.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Read from your own transcripts, nothing estimated from benchmarks:
4
4
 
5
- * **Coming back after a break.** Claude Code caches the conversation. Once the cache expires
5
+ * **The first message after a break.** Claude Code caches the conversation. Once the cache expires
6
6
  (1 hour on Claude plans, 5 minutes on an API key by default), the next call writes the whole
7
7
  conversation again, at 1.25x (5 min) or 2x (1 hour) the input price.
8
8
  * **The most expensive prompts,** with every model call each one led to (``prompts``).
@@ -146,6 +146,23 @@ def diagnose(projects_dir: str, days: int = 7, cwd: str | None = None, top: int
146
146
  )
147
147
 
148
148
 
149
+ def share_line(d: Diagnosis) -> str:
150
+ """One line a user can paste as is: their headline finding, no prompts, projects or dollars."""
151
+ total = d.cost["cost_usd"] or 1e-9
152
+ ask = "What's yours? uvx tokenops doctor"
153
+ if d.rebuy_usd / total >= LEAD_SHARE:
154
+ breaks = f"{100 * d.rebuy_usd / total:.0f}%"
155
+ return f"{breaks} of my Claude Code usage went to the first message after a break. {ask}"
156
+ if d.top:
157
+ p = d.top[0]
158
+ return (
159
+ f"My most expensive Claude Code prompt cost {p.times_median:,.0f}x my typical one "
160
+ f"({p.cause.lower()}). {ask}"
161
+ )
162
+ reads = f"{100 * d.cost['cost_cache_read'] / total:.0f}%"
163
+ return f"{reads} of my Claude Code usage was re-reading the conversation. {ask}"
164
+
165
+
149
166
  def render(
150
167
  d: Diagnosis,
151
168
  redact: bool = False,
@@ -185,9 +202,8 @@ def render(
185
202
  out += [
186
203
  " "
187
204
  + paint("1;31", pct(d.rebuy_usd))
188
- + paint("1", " of your Claude usage went to coming back after a break."),
189
- f" {d.rebuys} times the cache had expired, so Claude re-paid for the whole"
190
- " conversation.",
205
+ + paint("1", " of your Claude usage went to the first message after a break."),
206
+ f" {d.rebuys} times the cache had expired, so Claude reloaded the whole conversation.",
191
207
  " " + paint("1;32", break_fix),
192
208
  "",
193
209
  ]
@@ -207,7 +223,7 @@ def render(
207
223
 
208
224
  growth = max(0.0, c["cost_cache_write"] - d.rebuy_usd)
209
225
  rows = [
210
- ("Coming back after breaks (cache re-written)", d.rebuy_usd),
226
+ ("First message after a break (cache reloaded)", d.rebuy_usd),
211
227
  ("Re-reading context every call", c["cost_cache_read"]),
212
228
  ("Caching new context", growth),
213
229
  ("Claude's output", c["cost_output"]),
@@ -224,7 +240,7 @@ def render(
224
240
  fixes = []
225
241
  if not lead and d.rebuy_usd / total >= 0.05: # when breaks lead, the headline says this
226
242
  fixes.append(
227
- f"Breaks cost you {pct(d.rebuy_usd)}: {d.rebuys} times you came back to an expired "
243
+ f"Breaks cost you {pct(d.rebuy_usd)}: {d.rebuys} times the first message after a break found an expired "
228
244
  f"cache (worst: ${d.worst_rebuy_usd:.2f} for one call). {break_fix}"
229
245
  )
230
246
  if c["cost_cache_read"] / total >= 0.3:
@@ -276,6 +292,7 @@ def render(
276
292
  " /plugin marketplace add theagentplane/tokenops, then /tokenops:saver on",
277
293
  ]
278
294
  )
295
+ out += ["", paint("1", " Share yours"), " " + share_line(d)]
279
296
  out += [
280
297
  "",
281
298
  paint(
File without changes