token-harness 0.1.8 → 0.1.9

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 (4) hide show
  1. package/README.md +165 -101
  2. package/package.json +1 -1
  3. package/sbom.json +3 -3
  4. package/token-harness.mjs +3420 -391
package/README.md CHANGED
@@ -6,119 +6,120 @@ Token Harness checks your coding agents, shows subscription allowance when it ca
6
6
  observed reliably, reduces avoidable context overhead, and recommends useful actions.
7
7
  It runs locally and never presents local token estimates as subscription quota.
8
8
 
9
- ## The easy path
9
+ ## Open it. Approve setup. Keep coding.
10
10
 
11
- You need [Node.js 22.13 or newer](https://nodejs.org/) and at least one signed-in coding
12
- agent such as Claude Code or Codex.
13
-
14
- Open a terminal and paste:
11
+ You need [Node.js 22.13 or newer](https://nodejs.org/) and an installed, signed-in
12
+ Claude Code or Codex. Install Token Harness, then open it:
15
13
 
16
14
  ```sh
17
15
  npm install --global token-harness@latest
18
- token-harness setup
16
+ token-harness
19
17
  ```
20
18
 
21
- That is the whole first-time check. `setup` tells you:
22
-
23
- - which coding agents it found;
24
- - which optimizers are already active;
25
- - whether the current setup works;
26
- - what it changed, if anything;
27
- - exactly one next step.
19
+ The browser is now the primary interface. **Set up automatically** checks both agents and
20
+ prepares the supported integration changes. It describes each change in plain language.
21
+ Choose **Approve and apply** to apply the reviewed configuration with backups and verification.
22
+ There are no plan IDs to copy and no daily command sequence to remember.
28
23
 
29
- The first run does not change Claude Code, Codex, or project configuration. If Token
30
- Harness finds a supported improvement, it shows the safe plan and may suggest:
24
+ Already configured? The app shows your existing integrations without replacing them.
25
+ An absent provider or an unreviewed version combination is explained rather than installed
26
+ or forced silently. Automatic setup covers the reviewed integration paths, not every possible
27
+ provider/version. Token Harness does not install Claude Code or Codex or log you in.
31
28
 
32
- ```sh
33
- token-harness setup --yes
34
- ```
29
+ ### Daily use
35
30
 
36
- `--yes` is always explicit. The change is backed up, applied transactionally, and
37
- verified. Unsupported combinations are left untouched.
31
+ Continue launching `claude` or `codex` as usual. Supported output integrations operate in the
32
+ agent, not in the dashboard. You can close the page and its terminal without disabling those
33
+ integrations. Open `token-harness` whenever you want to see results; the visible dashboard
34
+ imports available provider records and refreshes its readings automatically.
38
35
 
39
- ## Open the dashboard
36
+ **Recorded savings** shows retained history across locally recorded projects, with date bounds,
37
+ provider, measurement class, units, changed-output counts, and before/after values. It does not
38
+ add incompatible provider figures together. Negative results remain visible. No telemetry is
39
+ shown as **not measured**, never a reassuring zero or an invented subscription saving.
40
+ Some provider records may predate Token Harness; locally stored records are not guaranteed
41
+ complete lifetime history. RTK history is imported directly. HarnessTrim project-local records
42
+ must have been imported from their project, or exposed through a configured known metrics path;
43
+ the app does not crawl your disk looking for private projects.
40
44
 
41
- After setup, run:
45
+ For a terminal-only summary, the one command is:
42
46
 
43
47
  ```sh
44
- token-harness ui
48
+ token-harness savings
45
49
  ```
46
50
 
47
- The dashboard opens in your browser and answers three questions in this order:
51
+ Optional windows are `--since 7d` and `--since 30d`. The advanced `metrics` command remains
52
+ project-scoped; opening the app from its installation folder does not change the savings scope.
48
53
 
49
- 1. **Can I work normally right now?**
50
- 2. **What is actually active and useful?**
51
- 3. **Is there one action worth taking?**
54
+ ### Find what you need
52
55
 
53
- It shows active/relevant coding agents first, their optimization providers, observable
54
- allowance windows, and task guidance. Tools that are absent do not get large cards;
55
- secondary detected tools are kept out of the main path.
56
+ The app has three tabs: **Overview** for agents and recorded savings, **Rules & settings**
57
+ for one agent's rules at a time, and **Activity** for checks and guarded undo. Theme follows
58
+ your system; the header also offers light and dark modes.
56
59
 
57
- The page is served only on `127.0.0.1`: no Electron app, account, or cloud service.
60
+ Each rule shows what was actually **observed**, separately from how it works. Actions sit
61
+ next to the relevant state: **Adjust reasoning** opens the supported review/apply flow;
62
+ **Change in Claude/Codex** explains native steps when an automatic write is not available.
63
+ Missing allowance data and measurement records have their own setup/help actions.
58
64
 
59
- ### What happens after the dashboard?
65
+ A saved Claude effort can be displayed even on an unreviewed CLI version. That does not
66
+ admit automatic writes on that version. **No saved preference** means the user field is
67
+ absent, not that reasoning is disabled. A failed read is a separate state with a cause.
68
+ The displayed preference is not a live reading of an already-running session.
60
69
 
61
- Usually: **nothing else. You are done.**
70
+ ### The rules are visible
62
71
 
63
- Token Harness is not a launcher and it does not need to stay between you and your coding
64
- agent. Continue exactly as you normally would:
72
+ **Rules & settings** explains each configured rule: what it does, why it is used,
73
+ its mode, and the evidence available. Automatic integrations, persistent preferences,
74
+ observations and features that are not enabled are explicitly distinguished.
65
75
 
66
- ```sh
67
- claude
68
- codex
69
- opencode
70
- ```
76
+ RTK's supported command integration can reduce output automatically. HarnessTrim can use
77
+ adapters or skills/instructions, depending on the installation; skills-only is not a transparent
78
+ hook, and the agent must actually use the reducer. Configured never means every command was
79
+ intercepted. Provider telemetry and its exact/estimated classification remain separate evidence.
80
+
81
+ **Optional: match reasoning to your work** lets you choose the agent and the type of work
82
+ without learning CLI flags. It previews the actual supported effort/verbosity change, then
83
+ applies only after approval. **This is a persistent preference for future sessions, not an
84
+ automatic per-task switch.** It does not switch models, billing, login, or hook trust. The
85
+ baseline automatic setup never guesses a task or quietly lowers reasoning.
71
86
 
72
- Use whichever of those you already use. RTK, HarnessTrim, or another configured provider
73
- runs automatically through that coding agent's integration. You do **not** need a special
74
- `token-harness run` command.
87
+ **Check integrations** performs the existing integration checks from the UI.
88
+ **Undo last change**, available after an application in that dashboard session, previews a
89
+ whole-file backup restoration. It refuses to undo a newer unrelated transaction. It restores
90
+ only the last successful agent transaction; manual edits to those same files after that
91
+ transaction would also be restored, as the confirmation explains.
75
92
 
76
- You can close the dashboard whenever you want. Use `Ctrl+C` in the terminal to stop its
77
- local web server. Closing it does not disable configured optimizers.
93
+ ### Run the current source
78
94
 
79
- Open it again later with `token-harness ui` when you want a status check. If you do not
80
- want it to open a browser:
95
+ From an existing clone, after installing its dependencies, one command builds and opens the app:
81
96
 
82
97
  ```sh
83
- token-harness ui --no-open
98
+ npm start
84
99
  ```
85
100
 
86
- ## Daily use
87
-
88
- There is no mandatory command loop. These are tools you use when they answer a question:
101
+ For a fresh clone:
89
102
 
90
- | When you want to know... | Run |
91
- | --- | --- |
92
- | Is everything still connected? | `token-harness ui` |
93
- | What should I do before a demanding task? | `token-harness optimize --task hard --profile quality` |
94
- | Is an integration actually working? | `token-harness verify` |
95
- | How much reducer saving has been measured? | `token-harness metrics --since 7d` |
96
- | Are safer provider updates available? | `token-harness update` |
97
-
98
- If a command finishes with **no action required**, stop there and use your coding agent
99
- normally. Token Harness should not send you around a `ui → optimize → ui` loop.
103
+ ```sh
104
+ git clone https://github.com/giuliastro/token-harness.git
105
+ cd token-harness
106
+ npx --yes pnpm@10.33.4 install --frozen-lockfile
107
+ npm start
108
+ ```
100
109
 
101
- ## Ask your AI to install Token Harness
110
+ This uses the clone, not an older global installation. An unmerged branch or unpublished main
111
+ change is not automatically available through `token-harness@latest`.
102
112
 
103
- You can give this prompt to Claude Code or Codex:
113
+ ### Advanced and AI-assisted use
104
114
 
105
- ```text
106
- Install the latest stable Token Harness from npm on this computer, then run
107
- `token-harness setup`. Do not install or replace Claude Code, Codex, or any
108
- optimization provider unless Token Harness's supported plan explicitly requires it.
109
-
110
- Explain the setup result in plain language: what was detected, what already works,
111
- what would change, and the single next step. Do not expose credentials, cookies,
112
- tokens, raw home paths, or private project contents. If setup proposes a supported
113
- configuration change, show me the short plan and ask before running
114
- `token-harness setup --yes`. After an approved change, verify it and open
115
- `token-harness ui` once. Then tell me clearly that setup is complete and that I should
116
- continue using my normal coding-agent command. Do not invent additional Token Harness
117
- steps when no action is required.
118
- ```
115
+ An AI may use the existing JSON CLI to inspect, plan and apply an explicitly approved change.
116
+ That is optional: another AI subscription is not required to operate the app. No persistent
117
+ agent, background model calls or task classifier runs behind your back.
119
118
 
120
- The AI should ask before the `--yes` step because that is the point where coding-agent
121
- configuration may change.
119
+ The older automation contracts remain available: `setup`, `optimize`, `plan`, `apply`,
120
+ `verify`, `metrics`, `rollback`, and their JSON reports. `ui --json` preserves its existing
121
+ schema-1 report; `ui --read-only` opens the legacy read-only dashboard. `ui --no-open` starts
122
+ the guided app without launching a browser. Stop either local server with Ctrl+C.
122
123
 
123
124
  ## What normal output looks like
124
125
 
@@ -167,26 +168,10 @@ token-harness ui --json
167
168
 
168
169
  `--json` keeps the complete schema-1 result and diagnostics; it is not shortened.
169
170
 
170
- ## Three commands to remember
171
+ ## Two entry points to remember
171
172
 
172
- ```sh
173
- token-harness setup
174
- token-harness ui
175
- token-harness optimize
176
- ```
177
-
178
- | Command | Answer |
179
- | --- | --- |
180
- | `setup` | Is Token Harness ready, and what is my one next step? |
181
- | `ui` | What is active, how much allowance is visible, and do I need to do anything? |
182
- | `optimize` | What is the best evidence-based action for the task I am starting? |
183
-
184
- For example:
185
-
186
- ```sh
187
- token-harness optimize --task hard --profile quality
188
- token-harness optimize --task mechanical --profile economy
189
- ```
173
+ `token-harness` opens the application. `token-harness savings` prints recorded results.
174
+ The advanced commands below are implementation tools, not a required user workflow.
190
175
 
191
176
  ## Safety and privacy
192
177
 
@@ -194,19 +179,23 @@ Token Harness is conservative by design:
194
179
 
195
180
  - normal read-only commands do not change coding-agent or project configuration;
196
181
  - `setup --yes`, `apply --yes`, `update --yes`, `rollback --yes`, and
197
- `uninstall --yes` are the explicit configuration-changing forms;
182
+ `uninstall --yes` are the explicit CLI configuration-changing forms; the guided UI uses
183
+ a reviewed preview and explicit **Approve and apply** instead;
198
184
  - plans are checked again immediately before they are applied;
199
185
  - existing files are backed up before a managed write;
200
186
  - only exact Token Harness-owned entries are removed by `uninstall`;
201
187
  - newer or untested combinations are reported, not guessed;
202
188
  - an available provider update outside reviewed compatibility is kept out rather than
203
189
  forced, and the installed working version stays in place;
204
- - the dashboard binds only to the local loopback address and provides no mutation API;
190
+ - the guided app binds only to 127.0.0.1 and protects its fixed local controls with exact
191
+ Host/Origin checks, a per-process anti-forgery token and single-use approval tickets;
192
+ - the legacy read-only dashboard and external status seam remain read-only;
205
193
  - source code, prompts, command contents, credentials, and cookies are not sent to a
206
194
  Token Harness service.
207
195
 
208
196
  Plans, receipts, metrics, and backups stay in the local Token Harness state directory.
209
- See [RFC 0004](docs/rfcs/0004-safety-and-installation.md) for the execution model and
197
+ See [RFC 0013](docs/rfcs/0013-guided-local-experience.md) for the local browser trust boundary,
198
+ [RFC 0004](docs/rfcs/0004-safety-and-installation.md) for the execution model and
210
199
  [RFC 0006](docs/rfcs/0006-cli-contract.md) for CLI/JSON guarantees.
211
200
 
212
201
  ## Supported optimizations
@@ -250,8 +239,64 @@ Most people do not need this section. Run `token-harness <command> --help` for d
250
239
  | `handoff` | Build a bounded cross-harness handoff | No |
251
240
  | `benchmark*`, `transfer*` | Capture and compare empirical evidence | Local state only |
252
241
 
242
+ ## Applying native recommendations
243
+
244
+ `optimize` remains read-only. Review a plan before applying a supported native change:
245
+
246
+ ```sh
247
+ token-harness plan --harness claude --native-policy --task mechanical --profile economy
248
+ token-harness apply --plan <printed-plan-id> --yes
249
+ ```
250
+
251
+ `apply --plan <id>` restores the reviewed harness/provider selection automatically; you
252
+ should not have to repeat `--harness`, `--provider`, `--native-policy`, `--task` or `--profile`.
253
+ Run it from the same project as `plan`. Conflicting explicit selectors are rejected, and
254
+ actual version, ownership and configuration changes still invalidate the plan. Existing
255
+ schema-1 plans remain usable; only their approved actions can execute.
256
+
257
+ The first Claude path supports the **persisted user effort preference** on the reviewed
258
+ Claude Code 2.1.261 build. It does not change model, authentication, hooks, endpoint or billing.
259
+ `max` is never persisted. Project/local/ancestor settings, custom configuration roots and
260
+ known environment/thinking overrides block the change rather than being overwritten. The
261
+ preference affects future sessions unless overridden: reopen Claude and check `/effort`.
262
+ This is not evidence of a running session's effective effort or a guaranteed quota saving.
263
+
264
+ For Codex, the same plan/apply flow manages the existing reviewed reasoning-effort and
265
+ verbosity fields through native `config/batchWrite`; project/profile overrides remain yours.
266
+ `rollback --yes` restores the complete pre-change files. `uninstall --yes` removes only owned
267
+ changes and restores a prior Claude effort preference without undoing unrelated later edits.
268
+
253
269
  ## Troubleshooting
254
270
 
271
+ ### Claude allowance is unavailable
272
+
273
+ The dashboard now explains whether the optional companion is missing, lacks the safe CLI
274
+ flags, cannot find Python, has no usable Claude session, reports an expired session, or returns
275
+ an unsupported source. It does not expose credentials, raw companion errors or private paths.
276
+
277
+ As observed on **September 5, 2026**, npm `cclimits@1.7.0` includes the merged Claude
278
+ zero-configuration support and the read-only flags. The latest GitHub Release listing is older
279
+ and is not evidence of what npm ships. To check the same path Token Harness uses:
280
+
281
+ ```sh
282
+ npm list --global cclimits
283
+ cclimits --claude --json --no-cache-write --no-stale-fallback
284
+ token-harness budget --harness claude --verbose
285
+ ```
286
+
287
+ An explicit optional installation/update is `npm install --global cclimits@1.7.0`.
288
+ Token Harness does not install it automatically or retry without its read-only flags.
289
+ A fresh local Claude cache is shown as **cached**, never promoted to live quota pacing.
290
+ A missing observation is not zero remaining allowance. Never paste credentials to debug it.
291
+
292
+ ### Codex is configured but its hook does not run
293
+
294
+ `token-harness verify --harness codex --verbose` now reads native `hooks/list` where the
295
+ installed app-server exposes it. Disabled, untrusted and modified hooks are distinguished from
296
+ an unavailable observation. Trust must still be granted explicitly in Codex. Enabled/trusted
297
+ metadata does not prove interception, reduction, or task quality; the integration remains
298
+ `config-only` until attributable runtime evidence exists.
299
+
255
300
  ### `token-harness` is not found
256
301
 
257
302
  Check that Node is new enough and the package is installed:
@@ -339,3 +384,22 @@ behavior or architecture.
339
384
 
340
385
  [Apache License 2.0](LICENSE). Referenced provider tools are independent projects with
341
386
  their own licenses.
387
+
388
+ ### Loading, impact and sharing
389
+
390
+ The dashboard shows animated, named checks while it reads your setup. Agent cards and saved
391
+ reduction records appear as they are ready; a slow allowance check does not hide the results.
392
+ Refreshing keeps previous readings visible until newer ones arrive. Errors and waiting are
393
+ explicit, and reduced-motion preferences disable animation without removing status text.
394
+
395
+ A result can now say **"65% less tool output"**, with its source, before/after values and count
396
+ of recorded changed outputs immediately beside it. An estimate says **"Estimated"**. This
397
+ percentage describes only those recorded outputs, not your whole coding session, subscription
398
+ allowance or money. Provider rows remain separate; negative results and errors remain visible.
399
+
400
+ Choose **Share result** to preview the exact summary and a locally generated image. **Open X
401
+ draft** prepares a short post. **Open Reddit** prepares a title/link; copy the summary into a
402
+ text post and choose a community yourself. **Copy for Discord** prepares a message to paste
403
+ in your chosen channel. **Save image** creates a PNG you can attach yourself. Nothing is
404
+ posted or uploaded automatically, and sharing excludes private paths, code, prompts and
405
+ account/allowance information. An open share preview stays fixed even if readings update.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "token-harness",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Quota-aware efficiency layer for Claude Code and Codex subscription limits.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/sbom.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "bomFormat": "CycloneDX",
3
3
  "specVersion": "1.5",
4
- "serialNumber": "urn:uuid:dfdf5e8b-aba7-10dd-1c9d-dd9a38f31fb3",
4
+ "serialNumber": "urn:uuid:98b38470-d012-6450-a4aa-0abf63b8e925",
5
5
  "version": 1,
6
6
  "metadata": {
7
7
  "component": {
8
8
  "type": "application",
9
9
  "bom-ref": "token-harness",
10
10
  "name": "token-harness",
11
- "version": "0.1.8",
11
+ "version": "0.1.9",
12
12
  "description": "Quota-aware efficiency layer for Claude Code and Codex subscription limits.",
13
13
  "licenses": [
14
14
  {
@@ -20,7 +20,7 @@
20
20
  "hashes": [
21
21
  {
22
22
  "alg": "SHA-256",
23
- "content": "dfdf5e8baba710dd1c9ddd9a38f31fb3aded525ea28f8b15a0fc5cff743444c6"
23
+ "content": "98b38470d0126450a4aa0abf63b8e925b297a1f1a2110d4a1074d7e3c0b10a21"
24
24
  }
25
25
  ]
26
26
  },