tokengolf 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.
package/README.md CHANGED
@@ -1,25 +1,24 @@
1
1
  # ⛳ TokenGolf
2
2
 
3
- > Gamify your Claude Code sessions. Flow mode tracks you. Roguelike mode trains you.
3
+ > Flow mode tracks you. Roguelike mode trains you.
4
4
 
5
5
  Turn Claude Code token efficiency into a game. Declare a quest, commit to a budget, pick a character class. Work normally. At the end, get a score based on how efficiently you used your budget.
6
6
 
7
7
  **Better prompting → fewer tokens → higher score.**
8
8
 
9
+ **[tokengolf.dev](https://josheche.github.io/tokengolf/)** · [npm](https://www.npmjs.com/package/tokengolf) · [GitHub](https://github.com/josheche/tokengolf)
10
+
9
11
  ---
10
12
 
11
13
  <!-- SCREENSHOT: tokengolf start wizard — quest/class/effort/budget selection -->
12
14
 
13
15
  ---
14
16
 
15
- ## Install
17
+ ## Why "TokenGolf"?
16
18
 
17
- ```bash
18
- git clone <repo>
19
- cd tokengolf
20
- npm install && npm link
21
- tokengolf install
22
- ```
19
+ [Code golf](https://en.wikipedia.org/wiki/Code_golf) is the engineering practice of solving a problem in as few characters (or lines, or bytes) as possible. The constraint isn't the point — the *discipline the constraint creates* is the point. Writing the shortest possible solution forces you to understand the problem deeply and use your tools precisely.
20
+
21
+ Token golf is the same idea applied to AI sessions. Your budget is par. Every unnecessary prompt, every redundant context dump, every "can you also..." tacked onto a request is a stroke over par. The game doesn't literally resemble golf — it borrows the concept: **optimize under constraint, measure your score, improve your game.**
23
22
 
24
23
  ---
25
24
 
@@ -31,7 +30,16 @@ Just work. TokenGolf auto-creates a tracking session when you open Claude Code.
31
30
  ### ☠️ Roguelike Mode
32
31
  Pre-commit before you start. Declare a quest, pick a class and effort level, set a budget. Go over budget = permadeath — the run is logged as a death. The deliberate pressure trains better prompting habits, which makes your Flow sessions cheaper over time.
33
32
 
34
- **The meta loop:** Roguelike practice makes Flow sessions better. Better Flow = lower daily spend = better scores without even trying.
33
+ ---
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ npm install -g tokengolf
39
+ tokengolf install
40
+ ```
41
+
42
+ `tokengolf install` patches `~/.claude/settings.json` with the hooks that power live tracking, the HUD, and the auto scorecard.
35
43
 
36
44
  ---
37
45
 
@@ -45,6 +53,7 @@ tokengolf bust # manual permadeath override
45
53
  tokengolf scorecard # last run scorecard
46
54
  tokengolf stats # career dashboard
47
55
  tokengolf install # patch ~/.claude/settings.json with hooks
56
+ tokengolf demo # show all HUD states (for screenshots)
48
57
  ```
49
58
 
50
59
  ---
@@ -56,6 +65,7 @@ tokengolf install # patch ~/.claude/settings.json with hooks
56
65
  | 🏹 Rogue | Haiku | — *(skips effort step)* | Glass cannon. Prompt precisely or die. |
57
66
  | ⚔️ Fighter | Sonnet | Low / **Medium** / High | Balanced. The default run. |
58
67
  | 🧙 Warlock | Opus | Low / **Medium** / High / Max | Powerful but costly. |
68
+ | ⚜️ Paladin | Opus (plan mode) | Low / **Medium** / High / Max | Strategic planner. Thinks before acting. |
59
69
  | ⚡ Warlock·Fast | Opus + fast mode | any | 2× cost. Maximum danger mode. |
60
70
 
61
71
  `max` effort is Opus-only — the API returns an error if used on other models. Fast mode is toggled mid-session with `/fast` in Claude Code and is auto-detected by TokenGolf.
@@ -107,6 +117,22 @@ Extended thinking tokens are billed at full output rate. A single ultrathink on
107
117
 
108
118
  ---
109
119
 
120
+ ## The Meta Loop
121
+
122
+ The dungeon crawl framing maps directly to real session behaviors:
123
+
124
+ - **Overencumbered** = context bloat slowing you down
125
+ - **Made Camp** = hit usage limits, came back next session
126
+ - **Ghost Run** = surgical context management before the boss
127
+ - **Hubris** = reached for ultrathink on a tight budget and paid for it
128
+ - **Silent Run** = solved it with pure prompting discipline, no extended thinking needed
129
+ - **Lone Wolf** = didn't spawn a single subagent; held the whole problem in one context
130
+ - **Agentic** = gave Claude the wheel and it ran with it — 3+ turns per prompt
131
+
132
+ Roguelike mode surfaces these patterns explicitly. Flow mode lets them compound over time. The meta loop: **roguelike practice makes Flow sessions better. Better Flow = lower daily spend = better scores without even trying.**
133
+
134
+ ---
135
+
110
136
  ## Achievements
111
137
 
112
138
  **Class**
@@ -119,6 +145,23 @@ Extended thinking tokens are billed at full output rate. A single ultrathink on
119
145
  - 🎯 Sniper — Under 25% of budget used
120
146
  - ⚡ Efficient — Under 50% of budget used
121
147
  - 🪙 Penny Pincher — Total spend under $0.10
148
+ - 🪙 Cheap Shots — Under $0.01 per prompt (≥3 prompts)
149
+ - 🍷 Expensive Taste — Over $0.50 per prompt (≥3 prompts)
150
+
151
+ **Prompting skill**
152
+ - 🎯 One Shot — Completed in a single prompt
153
+ - 💬 Conversationalist — 20+ prompts in one run
154
+ - 🤐 Terse — ≤3 prompts, ≥10 tool calls
155
+ - 🪑 Backseat Driver — 15+ prompts but <1 tool call per prompt
156
+ - 🏗️ High Leverage — 5+ tool calls per prompt (≥2 prompts)
157
+
158
+ **Tool mastery**
159
+ - 👁️ Read Only — Won with no Edit or Write calls
160
+ - ✏️ Editor — 10+ Edit calls
161
+ - 🐚 Bash Warrior — 10+ Bash calls comprising ≥50% of tools
162
+ - 🔍 Scout — ≥60% of tool calls were Reads (≥5 total)
163
+ - 🔪 Surgeon — 1–3 Edit calls, completed under budget
164
+ - 🧰 Toolbox — 5+ distinct tools used
122
165
 
123
166
  **Effort**
124
167
  - 🎯 Speedrunner — Low effort, completed under budget
@@ -129,6 +172,11 @@ Extended thinking tokens are billed at full output rate. A single ultrathink on
129
172
  - ⚡ Lightning Run — Opus fast mode, completed under budget
130
173
  - 🎰 Daredevil — Opus fast mode, LEGENDARY efficiency
131
174
 
175
+ **Time**
176
+ - ⏱️ Speedrun — Completed in under 5 minutes
177
+ - 🏃 Marathon — Session over 60 minutes
178
+ - 🫠 Endurance — Session over 3 hours
179
+
132
180
  **Ultrathink**
133
181
  - 🔮 Spell Cast — Used extended thinking during the run
134
182
  - 🧠 Calculated Risk — Ultrathink + LEGENDARY efficiency
@@ -151,18 +199,32 @@ Extended thinking tokens are billed at full output rate. A single ultrathink on
151
199
  - 🪶 Ultralight — Manual compact at ≤40% context
152
200
  - 🥷 Ghost Run — Manual compact at ≤30% context
153
201
 
202
+ **Tool reliability** *(requires PostToolUseFailure hook)*
203
+ - ✅ Clean Run — Zero failed tool calls (≥5 total)
204
+ - 🐂 Stubborn — 10+ failed tool calls, still won
205
+
206
+ **Subagents** *(requires SubagentStart hook)*
207
+ - 🐺 Lone Wolf — Completed with no subagents spawned
208
+ - 📡 Summoner — 5+ subagents spawned
209
+ - 🪖 Army of One — 10+ subagents, under 50% budget used
210
+
211
+ **Turn discipline** *(requires Stop hook)*
212
+ - 🤖 Agentic — 3+ Claude turns per user prompt
213
+ - 🐕 Obedient — Exactly one turn per prompt (≥3 prompts)
214
+
215
+ **Death marks** *(fire on bust, not win)*
216
+ - 💥 Blowout — Spent 2× your budget
217
+ - 😭 So Close — Died within 10% of budget
218
+ - 🔨 Tool Happy — Died with 30+ tool calls
219
+ - 🪦 Silent Death — Died with ≤2 prompts
220
+ - 🤡 Fumble — Died with 5+ failed tool calls
221
+
154
222
  ---
155
223
 
156
224
  ## Live HUD
157
225
 
158
226
  After `tokengolf install`, a status line appears in every Claude Code session:
159
227
 
160
- ```
161
- ───────────────
162
- ⛳ implement pagination | 💎 $0.1203/$0.50 24% | LEGENDARY | 🪶 38% | ⚔️ Sonnet·High | Floor 1/5
163
- ───────────────
164
- ```
165
-
166
228
  - **tier emoji** (💎🥇🥈🥉💸) updates live as cost accumulates
167
229
  - **🪶 green** at 50–74% context — traveling light
168
230
  - **🎒 yellow** at 75–89% context — getting heavy
@@ -170,62 +232,42 @@ After `tokengolf install`, a status line appears in every Claude Code session:
170
232
  - **💤** instead of ⛳ if the previous session fainted (hit usage limits)
171
233
  - Roguelike runs show floor progress; Flow runs omit budget/efficiency
172
234
 
173
- <!-- SCREENSHOT: Claude Code split-screen showing the TokenGolf HUD in the status bar -->
235
+ Run `tokengolf demo` to see all HUD states rendered in your terminal:
236
+
237
+ ![TokenGolf HUD demo — all game states](assets/demo-hud.png)
174
238
 
175
239
  ---
176
240
 
177
241
  ## Auto Scorecard
178
242
 
179
- When you `/exit` a Claude Code session, the scorecard appears automatically:
243
+ When you `/exit` a Claude Code session, the scorecard appears automatically — cost, model breakdown, achievements, ultrathink stats, tool usage.
180
244
 
181
- ```
182
- ╔════════════════════════════════════════════════════════════════════╗
183
- ║ 🏆 SESSION COMPLETE ║
184
- ║ implement pagination for /users ║
185
- ╠════════════════════════════════════════════════════════════════════╣
186
- ║ $0.18/$0.50 36% ⚡ EFFICIENT ⚔️ Sonnet·High 🥇 Gold ║
187
- ╠════════════════════════════════════════════════════════════════════╣
188
- ║ 🔮 1 ultrathink invocation ~8.4K thinking tokens ║
189
- ╠════════════════════════════════════════════════════════════════════╣
190
- ║ 🥈 silver_sonnet 🎯 sniper 🔮 spell_cast 🧠 calculated_risk ║
191
- ╠════════════════════════════════════════════════════════════════════╣
192
- ║ tokengolf scorecard · tokengolf start · tokengolf stats ║
193
- ╚════════════════════════════════════════════════════════════════════╝
194
- ```
245
+ <p align="center">
246
+ <img src="assets/scorecard.png" alt="TokenGolf scorecard — session complete" width="620" />
247
+ </p>
195
248
 
196
- <!-- SCREENSHOT: Auto-displayed scorecard after /exit in Claude Code terminal -->
249
+ *Real scorecard from building TokenGolf itself. $40 flow session, 27 ultrathink invocations, Class Defection for declaring Sonnet but spending 89% on Opus. The game plays you back.*
197
250
 
198
251
  ---
199
252
 
200
253
  ## Hooks
201
254
 
202
- Six hooks installed via `tokengolf install`:
255
+ Nine hooks installed via `tokengolf install`:
203
256
 
204
257
  | Hook | When | What it does |
205
258
  |------|------|-------------|
206
259
  | `SessionStart` | Session opens | Injects quest/budget/floor into Claude's context. Auto-creates Flow run if none active. Increments session count for multi-session runs. |
207
260
  | `PostToolUse` | After every tool | Tracks tool usage by type. Fires budget warning at 80%. |
261
+ | `PostToolUseFailure` | After a tool error | Increments `failedToolCalls` — powers Clean Run, Stubborn, Fumble. |
208
262
  | `UserPromptSubmit` | Each prompt | Counts prompts. Injects halfway nudge at 50% budget. |
209
263
  | `PreCompact` | Before compaction | Records manual vs auto compact + context % — powers gear achievements. |
210
264
  | `SessionEnd` | Session closes | Scans transcripts for cost + ultrathink blocks, saves run, displays ANSI scorecard. Detects Fainted if session ended unexpectedly (usage limit hit). |
265
+ | `SubagentStart` | Subagent spawned | Increments `subagentSpawns` — powers Lone Wolf, Summoner, Army of One. |
266
+ | `Stop` | Claude finishes a turn | Increments `turnCount` — powers Agentic, Obedient. |
211
267
  | `StatusLine` | Continuously | Live HUD with cost, tier, efficiency, context %, model class. |
212
268
 
213
269
  ---
214
270
 
215
- ## The Meta Loop
216
-
217
- The dungeon crawl framing maps directly to real mechanics:
218
-
219
- - **Overencumbered** = context bloat slowing you down
220
- - **Made Camp** = hit usage limits, came back next session
221
- - **Ghost Run** = surgical context management before the boss
222
- - **Hubris** = reached for ultrathink on a tight budget and paid for it
223
- - **Silent Run** = solved it with pure prompting discipline, no extended thinking needed
224
-
225
- Roguelike mode surfaces these patterns explicitly. Flow mode lets them compound over time.
226
-
227
- ---
228
-
229
271
  ## State
230
272
 
231
273
  All data lives in `~/.tokengolf/`:
Binary file
Binary file