token-furnace 0.1.3 → 0.1.5

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,22 +1,46 @@
1
1
  # token-furnace
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/token-furnace)](https://www.npmjs.com/package/token-furnace)
4
+ [![Node.js](https://img.shields.io/node/v/token-furnace)](https://www.npmjs.com/package/token-furnace)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
+ [![npm downloads](https://img.shields.io/npm/dm/token-furnace)](https://www.npmjs.com/package/token-furnace)
7
+
3
8
  Where the token budget actually went. `token-furnace` reads your local Claude Code and Codex
4
9
  transcripts, finds token leaks, and shows the result in your terminal, as JSON for agents, and in a
5
10
  local dashboard. Transcript data never leaves your machine.
6
11
 
7
- ## Requirements
12
+ ## Quick start
8
13
 
9
- - Node.js 22.13 or newer.
14
+ Requires **Node.js 22.13 or newer** and local Claude Code or Codex transcripts.
10
15
 
11
16
  Run it without installing:
12
17
 
18
+ ```sh
19
+ npx token-furnace@latest
13
20
  ```
14
- npx token-furnace
21
+
22
+ Open the live dashboard:
23
+
24
+ ```sh
25
+ npx token-furnace@latest serve
15
26
  ```
16
27
 
17
- Or install it globally:
28
+ Visit **http://127.0.0.1:8765**. The first scan measures local usage; later scans reuse a metadata cache.
29
+ Choose Claude Code or Codex independently for each chart, and pin a selection to remember it on reload.
18
30
 
31
+ Export a report for scripts or sharing:
32
+
33
+ ```sh
34
+ npx token-furnace@latest --json --no-plan-usage
35
+ npx token-furnace@latest --html report.html
19
36
  ```
37
+
38
+ Reports include session titles and file paths. Review an exported report before sharing it.
39
+ With no transcripts, the CLI exits 1; run `npx token-furnace@latest --list-sources` to see where it looks.
40
+
41
+ Or install it globally:
42
+
43
+ ```sh
20
44
  npm install -g token-furnace
21
45
  ```
22
46
 
@@ -31,6 +55,7 @@ npm install -g token-furnace
31
55
  | `token-furnace --list-sources` | Each agent, its path, and its transcript count. |
32
56
  | `token-furnace serve [--port 8765]` | Live dashboard on `http://127.0.0.1:<port>`. It serves the last scan and refreshes it in the background. |
33
57
  | `token-furnace setup [--apply] [--verify] [--rollback] [--aggressive]` | Installer. Dry run unless `--apply`. |
58
+ | `token-furnace fix-config` | Repairs context and worker settings; backs up changed files first. Optional `--include-depth`. |
34
59
  | `token-furnace hook churn` | Claude Code PostToolUse churn hook. Reads the payload on stdin. Never blocks. |
35
60
 
36
61
  Options:
@@ -41,6 +66,39 @@ Options:
41
66
  - `--no-plan-usage` — never call `api.anthropic.com`. A saved reading is still used.
42
67
  - `-h`, `--help` — usage text.
43
68
 
69
+ ## Context targets
70
+
71
+ The analysis targets context sizes of **Claude Code 400k** and
72
+ **Codex 300k**. Checkup, session flags, dashboard KPIs, hourly spend charts, benchmark estimates,
73
+ and configuration repair all use these values. A turn exactly at its provider target is within
74
+ target. Mixed-provider charts compare each turn against its own provider target.
75
+
76
+ ## Auto Fixes
77
+
78
+ In the live dashboard, click **Auto Fixes** in the page header, review the changes, and select
79
+ **Back up and apply**. Cancel closes the modal without changing files.
80
+
81
+ The **Auto Fixes** button opens a checklist with every repair checked by default. Uncheck any
82
+ setting to leave it unchanged; only selected repairs are applied. Backups are always made first.
83
+ The CLI defaults still exclude depth limits unless `--include-depth` is supplied.
84
+ Both providers get a concurrent worker cap of 3; Claude gets tool concurrency capped at 4
85
+ and Sonnet workers if no worker model is pinned. Codex worker reasoning is set to medium
86
+ unless already medium or lower. Existing lower caps and pinned models are preserved.
87
+ Use `token-furnace fix-config --include-depth` or keep the modal depth checkboxes selected to also cap
88
+ nesting at 1. This is optional because some agent versions may reject it or block spawning.
89
+ Session age, caller reads, wakeups and unbounded loops require workflow changes; configuration
90
+ repairs cannot rewrite those historical measurements.
91
+
92
+ Run `token-furnace fix-config` to set Claude Code's `autoCompactWindow` to `400000` and
93
+ Codex's `model_auto_compact_token_limit` to `300000`. Checks warn when these settings differ.
94
+ The command respects `CLAUDE_CONFIG_DIR` and `CODEX_HOME`, preserves unrelated settings,
95
+ and saves each existing changed file beside the original as `.token-furnace-backup`
96
+ (with a numbered suffix when needed). No backup is needed for a newly created file.
97
+ Invalid or unsupported configuration exits 1 before editing either file. Repeated runs make
98
+ no changes once targets match. Restore by copying the printed backup path over its original.
99
+ Restart agents after repair. A shell `CLAUDE_CODE_AUTO_COMPACT_WINDOW` override must be unset
100
+ in the shell; the command reports it when present.
101
+
44
102
  ## Setup and hook
45
103
 
46
104
  `token-furnace setup` prints the planned changes and changes no file. Add `--apply` to write them.
@@ -92,18 +150,29 @@ main thread, or a positive number to set the worker count.
92
150
  An unknown option does not exit 2. `node:util` `parseArgs` throws, so that run exits 1 with a stack
93
151
  trace.
94
152
 
95
- ## Release status
153
+ ## Development and contributing
154
+
155
+ Bug reports and focused pull requests are welcome. For a bug, include your Node.js version,
156
+ the command you ran, and a redacted error or minimal transcript example. Keep credentials and
157
+ private transcript content out of issues.
158
+
159
+ ```sh
160
+ git clone https://github.com/jonit-dev/token-furnace.git
161
+ cd token-furnace
162
+ npm ci
163
+ npm run typecheck
164
+ npm test
165
+ npm run smoke
166
+ ```
167
+
168
+ `npm test` builds the CLI and dashboard before running the suite. `npm run smoke` packs and installs
169
+ the package into a temporary project, then checks the installed CLI, HTML export and live server
170
+ against synthetic transcripts. `npm pack` and `npm publish` rebuild the distributable automatically.
171
+ The dashboard is self-contained: no CDN scripts, fonts or styles are needed.
96
172
 
97
- Version 0.1.0. The `setup` and `hook` commands are integrated and tested (PRD-006). The dashboard
98
- is a React + Vite + TypeScript single-file build (PRD-005). `--html` writes one file and `serve`
99
- serves the same page. Both load no external URL: no CDN `<script>` or `<link>`.
173
+ [Report a bug](https://github.com/jonit-dev/token-furnace/issues) ·
174
+ [Browse the source](https://github.com/jonit-dev/token-furnace)
100
175
 
101
- The package smoke test passes on both Node.js 22.13 and Node.js 24.16: `npm pack`, a temporary
102
- install, and `npx --no-install` runs of the CLI (`--json`), `--html`, and `serve` all match the
103
- expected totals and routes. The tarball includes `dist/scan-worker.js` and `dist/dashboard.html`. The package file allowlist
104
- contains `dist/`, `SKILL.md`, `references/`, and `README.md`, plus npm metadata and the license.
105
- It contains no `.py`, `.sh`, test, or fixture files.
176
+ ## License
106
177
 
107
- The full Vitest suite (86 tests) plus the root and web typechecks and the build pass. The four CLI
108
- paths (cold workers, warm cache, inline main-thread, and `--no-cache` workers) return identical
109
- `Report` JSON. Publishing to npm is pending the package owner.
178
+ [MIT](LICENSE) © Joao Paulo Furtado
package/SKILL.md CHANGED
@@ -210,7 +210,8 @@ Applied by default — none of these reduce reasoning quality:
210
210
  | Claude | `CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS` | `3` | Default is 20. Caps simultaneous fan-out; does not cap total work. |
211
211
  | Claude | `ENABLE_TOOL_SEARCH` | `true` | Defers MCP tool schemas instead of loading every definition up front. Pure win with several MCP servers. |
212
212
  | Claude | `MAX_MCP_OUTPUT_TOKENS` | `12000` | Default 25K. Bounds a pathological MCP dump. |
213
- | Claude | `autoCompactWindow` | `200000` | Manual for now: `token-furnace setup` does not set it. On a 1M model the default compacts near 1M, so every turn carries up to 1M of context. |
213
+ | Claude | `autoCompactWindow` | `400000` | Set with `token-furnace fix-config` (backup first). On a 1M model the default compacts near 1M, so every turn carries up to 1M of context. |
214
+ | Codex | `model_auto_compact_token_limit` | `300000` | Set with `token-furnace fix-config` (backup first). |
214
215
  | Codex | `model_verbosity` | `low` | Shortens visible prose only. Reasoning is a separate setting and is untouched. |
215
216
  | Codex | `tool_output_token_limit` | `10000` | Bounds giant build and test logs. |
216
217
  | Codex | `agents.max_concurrent_threads_per_session` | `3` | Same reasoning as the Claude cap. |
@@ -255,7 +256,7 @@ npx token-furnace serve # live report on http://127.0.0.1:8765
255
256
  Read the output in this order:
256
257
 
257
258
  1. **Spend by context size.** Cost per turn scales with the context carried into it, so a
258
- few very long turns can dominate a week. A large share above 300k means sessions are
259
+ few very long turns can dominate a week. A large share above the provider target means sessions are
259
260
  never compacting: use a smaller context window, or start fresh sessions between
260
261
  unrelated tasks. Compression cannot fix this.
261
262
  2. **Always-resident preamble.** Instructions, memory, skill catalog and tool schemas are
@@ -266,14 +267,14 @@ Read the output in this order:
266
267
  4. **Tool calls.** If duplicate reads or repeated identical commands are rare, output
267
268
  compression has nothing to eat and is not your lever.
268
269
  5. **Leak checks.** Each top session gets one line per leak it shows, with the fix:
269
- - *late compaction*: peak context above 300k. Set `autoCompactWindow` to about 200000.
270
+ - *late compaction*: peak context above the provider target (Claude 400k, Codex 300k). Values come from `src/core/context.ts`.
270
271
  - *caller reads*: 100+ file or log reads (`Read`, `sed -n`, `grep`, `rg`, `cat`, `python3 -`)
271
272
  run in the caller's own context. Send them to a cheap read-only agent.
272
273
  - *wakeups*: 50+ teammate, task-notification or cross-session messages. Each one is a
273
274
  full-context turn. Ask for one report at the end.
274
275
  - *loop*: 200+ turns per human prompt. Give the autonomous loop a stop condition and a budget.
275
276
  - *long-lived*: open 12+ hours. Start one fresh session per task.
276
- 6. **Config checks.** `autoCompactWindow` unset or above 300k (the env var
277
+ 6. **Config checks.** `autoCompactWindow` unset or different from 400k; Codex `model_auto_compact_token_limit` unset or different from 300k (the env var
277
278
  `CLAUDE_CODE_AUTO_COMPACT_WINDOW` overrides the setting), and any `MEMORY.md` index over
278
279
  200 lines (Claude Code does not load the rest).
279
280