token-harness 0.1.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/LICENSE +202 -0
- package/README.md +289 -0
- package/package.json +36 -0
- package/sbom.json +89 -0
- package/token-harness.mjs +8483 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Giulio Ardoino
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# Token Harness
|
|
2
|
+
|
|
3
|
+
> One control plane for token-efficient coding agents.
|
|
4
|
+
|
|
5
|
+
Token Harness is an open-source orchestrator for token-saving tools used by coding
|
|
6
|
+
agents. It detects the active coding harness, installs compatible optimization
|
|
7
|
+
providers, prevents conflicting integrations, verifies that the resulting pipeline
|
|
8
|
+
works, and reports savings through one normalized metrics model.
|
|
9
|
+
|
|
10
|
+
Token Harness is not another compressor. It coordinates specialized projects at
|
|
11
|
+
different layers of the agent pipeline. This is the current integration landscape;
|
|
12
|
+
"candidate" means researched, not supported or installed by this release.
|
|
13
|
+
|
|
14
|
+
| System | Layer and added value | Token Harness state |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| [RTK](https://github.com/rtk-ai/rtk) | Command rewriting and shell-output reduction | **Integrated today** for Claude Code |
|
|
17
|
+
| [HarnessTrim](https://github.com/giuliastro/HarnessTrim) | Deterministic reducers, harness adapters, skills, pipes, and MCP integration | **MVP provider in progress**: detection, adoption, conflict reconciliation, and metrics |
|
|
18
|
+
| [Dejavu](https://github.com/Salnika/dejavu) | Emits only the delta when a command produces repeated output | Priority candidate; requires an RTK ordering fixture and native-Windows work |
|
|
19
|
+
| [Lazy MCP](https://github.com/voicetreelab/lazy-mcp) | Loads MCP tool schemas only when the agent needs them | Priority, largely orthogonal candidate |
|
|
20
|
+
| [repowise](https://github.com/repowise-dev/repowise) | Retrieves task-shaped repository context instead of repeated grep/read loops | Priority candidate; response bounds and attribution must be verified |
|
|
21
|
+
| [LiteLLM](https://github.com/BerriAI/litellm) | Self-hosted model gateway, fallbacks, load balancing, budgets, and usage telemetry | Routing foundation candidate; it does not by itself prove token savings |
|
|
22
|
+
| [RouteLLM](https://github.com/lm-sys/RouteLLM) | Routes easier requests to a cheaper model through an OpenAI-compatible endpoint | Learned-routing candidate; needs coding-agent quality benchmarks |
|
|
23
|
+
| [vLLM Semantic Router](https://github.com/vllm-project/semantic-router) | Routes by task, complexity, tools, and deployment locality for self-hosted inference | Alternative routing candidate for local inference fleets |
|
|
24
|
+
| [Headroom](https://github.com/headroomlabs-ai/headroom) | Compresses tool, MCP, file, and RAG payloads and can lower effort on routine turns | Broad-context candidate; alternative to Context Mode, with overlap tests required |
|
|
25
|
+
| [Context Mode](https://github.com/mksglu/context-mode) | Keeps raw tool/MCP results outside context and restores compact session memory | Broad-context candidate; alternative to Headroom, source-available under ELv2 |
|
|
26
|
+
| [LLMLingua](https://github.com/microsoft/LLMLingua) | Model-based prompt compression engine for long context | Engine candidate, not yet a direct harness adapter |
|
|
27
|
+
| [Caveman](https://github.com/JuliusBrussee/caveman) | Steers shorter visible model replies | Opt-in candidate; output savings only, with quality and prompt-overhead checks |
|
|
28
|
+
|
|
29
|
+
The evidence, licenses, conflicts, and recommended admission order are recorded in the
|
|
30
|
+
[provider landscape](docs/provider-landscape.md). Routing savings are reported as cost or
|
|
31
|
+
quality trade-offs, never silently added to exact token savings.
|
|
32
|
+
|
|
33
|
+
Upstream tools remain independent. Token Harness installs supported releases through
|
|
34
|
+
their official distribution channels and never silently vendors or forks them.
|
|
35
|
+
|
|
36
|
+
## Product identity
|
|
37
|
+
|
|
38
|
+
| Surface | Value |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| Product name | Token Harness |
|
|
41
|
+
| Repository/package slug | `token-harness` |
|
|
42
|
+
| CLI command | `token-harness` |
|
|
43
|
+
| License | Apache-2.0 |
|
|
44
|
+
| Runtime | Node.js 22.13.0+ |
|
|
45
|
+
| Language | TypeScript |
|
|
46
|
+
| Package manager | pnpm |
|
|
47
|
+
|
|
48
|
+
## Core principles
|
|
49
|
+
|
|
50
|
+
1. **Plan before apply.** Every mutation is represented as a reviewable plan. Dry-run
|
|
51
|
+
is the default, and no flag skips planning.
|
|
52
|
+
2. **One owner per interception surface.** The planner prevents two providers from
|
|
53
|
+
rewriting or compressing the same payload unless that exact chain is validated — and
|
|
54
|
+
it keeps checking after installation, because config files keep changing.
|
|
55
|
+
3. **Upstreams stay upstream.** Providers wrap official installers and APIs instead
|
|
56
|
+
of copying their implementations.
|
|
57
|
+
4. **Measured, not marketed.** Exact, estimated, and counterfactual savings are
|
|
58
|
+
reported separately and never summed into one headline number.
|
|
59
|
+
5. **Proven, not assumed.** Verification states its tier: presence, config-only, or an
|
|
60
|
+
observed canary. A configuration that looks correct is never presented as proof that
|
|
61
|
+
the harness reaches the provider.
|
|
62
|
+
6. **Reversible by construction.** Configuration edits are marker-owned, backed up,
|
|
63
|
+
journaled, and removable.
|
|
64
|
+
7. **Local-first.** No account or telemetry is required. Usage data stays local unless
|
|
65
|
+
the user explicitly enables an upstream service.
|
|
66
|
+
8. **Cross-platform.** Windows, macOS, Linux, and WSL are first-class targets, with
|
|
67
|
+
unsupported combinations surfaced before installation.
|
|
68
|
+
|
|
69
|
+
## Initial user experience
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
token-harness doctor
|
|
73
|
+
token-harness plan
|
|
74
|
+
token-harness apply --yes
|
|
75
|
+
token-harness verify
|
|
76
|
+
token-harness metrics --since 7d
|
|
77
|
+
token-harness status
|
|
78
|
+
token-harness rollback --yes
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Existing installations are adopted, not replaced. If RTK or HarnessTrim is already
|
|
82
|
+
configured by hand, Token Harness detects it, plans around it, and leaves it in place on
|
|
83
|
+
uninstall.
|
|
84
|
+
|
|
85
|
+
`0.1.0` supports Codex, Claude Code, and OpenCode. RTK is managed end to end: detected,
|
|
86
|
+
configured, verified, measured. HarnessTrim is detected, adopted, reconciled against RTK's
|
|
87
|
+
ownership, and measured — but not installed, because at its current release no configuration
|
|
88
|
+
exists that would let both tools reduce output without contesting the same surface. Token
|
|
89
|
+
Harness reports that contest instead of hiding it.
|
|
90
|
+
|
|
91
|
+
Additional tools, and joint reduction by two providers, are introduced only after
|
|
92
|
+
compatibility and attribution tests prove they compose safely.
|
|
93
|
+
|
|
94
|
+
## Status
|
|
95
|
+
|
|
96
|
+
**Version `0.1.0`.** PLAN §16 defines that number as: RTK and HarnessTrim, three harnesses,
|
|
97
|
+
transactional install, verification with declared tiers, metrics, and brownfield adoption. All
|
|
98
|
+
of it is here, and a test refuses the version string unless the registries and the command
|
|
99
|
+
surface actually back it.
|
|
100
|
+
|
|
101
|
+
### The nine criteria
|
|
102
|
+
|
|
103
|
+
PLAN §2 lists what makes `0.1.0` useful. Measured, not estimated:
|
|
104
|
+
|
|
105
|
+
| # | Criterion | State |
|
|
106
|
+
| --- | --- | --- |
|
|
107
|
+
| 1 | `doctor` detects Codex, Claude Code, or OpenCode | **done** — all three |
|
|
108
|
+
| 2 | RTK and HarnessTrim: available, installed, configured, broken | **done** |
|
|
109
|
+
| 3 | Dry-run plan for a compatible setup | **done** |
|
|
110
|
+
| 4 | Apply that plan transactionally | **done** |
|
|
111
|
+
| 5 | Verify the integration, with the tier stated | **done** |
|
|
112
|
+
| 6 | Inspect normalized savings | **done** — both providers |
|
|
113
|
+
| 7 | Uninstall or roll back without damage | **done** |
|
|
114
|
+
| 8 | Adopt an existing hand-configured installation | **done** — both providers |
|
|
115
|
+
| 9 | Windows, macOS, Linux | **done** — CI on all three, every commit |
|
|
116
|
+
|
|
117
|
+
### What it looks like on a real machine
|
|
118
|
+
|
|
119
|
+
```text
|
|
120
|
+
$ token-harness doctor
|
|
121
|
+
Harnesses
|
|
122
|
+
claude configured ~/.claude/settings.json
|
|
123
|
+
codex configured ~/.codex/config.toml
|
|
124
|
+
opencode detected ~/.config/opencode/opencode.jsonc
|
|
125
|
+
|
|
126
|
+
Providers
|
|
127
|
+
rtk configured 0.42.0 configured for claude (adopted, not managed)
|
|
128
|
+
harnesstrim configured configured for codex (adopted, not managed)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```text
|
|
132
|
+
$ token-harness verify
|
|
133
|
+
rtk — claude — adopted, not managed — declared tier: canary
|
|
134
|
+
pass canary-intercepted 494 commands intercepted on 2026-07-31
|
|
135
|
+
harnesstrim — codex — adopted, not managed — declared tier: config-only
|
|
136
|
+
not-exercised canary-intercepted no telemetry file exists, so no interception has been recorded
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
That second line is the point of the whole verification model: the hook is correctly
|
|
140
|
+
configured, and it has never run. RFC 0007 exists because "configured" and "working" are
|
|
141
|
+
different claims, and `not-exercised` is neither a pass nor a failure.
|
|
142
|
+
|
|
143
|
+
`metrics` on the same machine reports **91,600 tokens saved over 2,847 intercepted
|
|
144
|
+
commands** — exactly what `rtk gain` reports independently.
|
|
145
|
+
|
|
146
|
+
### The full command surface
|
|
147
|
+
|
|
148
|
+
```text
|
|
149
|
+
token-harness doctor what is here, and what is broken
|
|
150
|
+
token-harness plan what would change; nothing is written
|
|
151
|
+
token-harness apply --yes write it, inside a reversible transaction
|
|
152
|
+
token-harness verify is it actually intercepting, at which tier
|
|
153
|
+
token-harness metrics --since 7d what it saved, by measurement class
|
|
154
|
+
token-harness status drift, and competing hooks on owned surfaces
|
|
155
|
+
token-harness uninstall --yes remove only what Token Harness owns
|
|
156
|
+
token-harness rollback --yes restore the files a transaction changed
|
|
157
|
+
token-harness update what a newer version would be, per channel
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
That is all nine commands RFC 0001 declares. `update` was the last one missing.
|
|
161
|
+
|
|
162
|
+
It asks each provider's own installation channel what version it offers and compares that with
|
|
163
|
+
what is installed — the installed side comes from the provider, the available side from the
|
|
164
|
+
channel, because `winget` knows what exists for `rtk-ai.rtk` and RTK's adapter does not. Reaching
|
|
165
|
+
the channel is a network read and it happens on a dry run too, since a target version cannot be
|
|
166
|
+
named without asking, so the destinations are reported.
|
|
167
|
+
|
|
168
|
+
It updates and nothing else. A provider that is not installed is left alone, a channel offering
|
|
169
|
+
something older is not acted on, and a channel that cannot be read produces *unknown* rather than
|
|
170
|
+
the far more comfortable *up to date*. A pinned provider is skipped and its pin is named; a pin
|
|
171
|
+
written inside a repository is reported and not honored, because a repository may not choose which
|
|
172
|
+
version of a tool you run.
|
|
173
|
+
|
|
174
|
+
And the honest limit, printed rather than implied: an updated package is not restored by a
|
|
175
|
+
rollback. Rollback restores files, and a package is not a file.
|
|
176
|
+
|
|
177
|
+
### Guarantees worth knowing before you run `apply`
|
|
178
|
+
|
|
179
|
+
- **Dry-run by default.** Without `--yes`, mutating commands display the plan and exit 8.
|
|
180
|
+
- **One appended entry, not a rewritten list.** Your other hooks keep their content and their
|
|
181
|
+
order; a test asserts your entry is still first afterwards.
|
|
182
|
+
- **Every file is snapshotted first**, including files that did not exist, so a rollback can
|
|
183
|
+
restore their absence. The restoration is verified by reading the files back — which is what
|
|
184
|
+
separates exit 6 (rolled back) from exit 7 (did not fully restore).
|
|
185
|
+
- **Token Harness removes only what a committed journal records as its own.** Not what merely
|
|
186
|
+
looks like its own: an entry whose bytes match what it would have written is still yours if
|
|
187
|
+
it did not write it, and `uninstall` says so and declines.
|
|
188
|
+
- **A change you did not ask for is reported.** Editing a hand-formatted JSON file reformats
|
|
189
|
+
it, and that warning reaches you rather than only the journal.
|
|
190
|
+
- **A competing hook on an owned surface is reported, never removed.** `status` names the file,
|
|
191
|
+
the surface, and the competing command, and exits 3.
|
|
192
|
+
|
|
193
|
+
### What is honest about the limits
|
|
194
|
+
|
|
195
|
+
- **HarnessTrim is never installed**, by design rather than omission. RFC 0003 §Resolution at
|
|
196
|
+
0.1.0 checked its installer at `0.0.5` and found no configuration that lets it and RTK reduce
|
|
197
|
+
output without contesting the same surface. So it is detected, adopted, reconciled, and
|
|
198
|
+
measured — and left alone. Under `profile: custom` you may hand it the scope instead of RTK.
|
|
199
|
+
- **An installed package cannot be rolled back.** `apply` can now run a package manager, but a
|
|
200
|
+
package is not a file and there is no snapshot of one, so a later failure restores your files and
|
|
201
|
+
leaves the package installed. The report says so rather than letting "rolled back" imply the
|
|
202
|
+
machine is as it was. Elevation is refused outright, with the exact command to run yourself.
|
|
203
|
+
- **A provider that cannot report its version is still adopted.** Older HarnessTrim builds reject
|
|
204
|
+
`--version`; Token Harness asks, falls back, and reports the tool as installed with no version
|
|
205
|
+
rather than as missing. It never reads the reachable `package.json`, which names the monorepo
|
|
206
|
+
rather than the CLI.
|
|
207
|
+
- **Codex hooks cannot be proven to run.** Enablement and trust are persisted separately from
|
|
208
|
+
`hooks.json`, in state no adapter can read, so Codex tops out at `config-only` and says why.
|
|
209
|
+
- **Two measurement findings that change how a number reads.** 75% of RTK's interceptions save
|
|
210
|
+
nothing, and RTK sometimes makes output *larger* while flooring its own counter at zero — so
|
|
211
|
+
its total is a sum of clamped values. Token Harness reports the net effect and names the
|
|
212
|
+
inflation separately.
|
|
213
|
+
|
|
214
|
+
### Installing 0.1.0
|
|
215
|
+
|
|
216
|
+
A single self-contained ESM artifact with **no dependencies at all**. Not on npm — publishing
|
|
217
|
+
is PLAN §8.3, with provenance, SBOM, and signing — but it installs from a tarball you build
|
|
218
|
+
yourself, and CI proves that on Windows, macOS, and Linux on every commit:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
pnpm install && pnpm build && pnpm package
|
|
222
|
+
npm install -g ./dist/package
|
|
223
|
+
token-harness doctor
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
To run it without installing:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
node dist/bundle/token-harness.mjs doctor
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Every read-only command is safe to run first. `doctor`, `plan`, `status`, `verify` and
|
|
233
|
+
`metrics` never touch a harness configuration, and `--project <dir>` retargets the
|
|
234
|
+
project-scoped half if you want to watch it work against a scratch directory.
|
|
235
|
+
|
|
236
|
+
## Development
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
pnpm install
|
|
240
|
+
pnpm typecheck
|
|
241
|
+
pnpm lint
|
|
242
|
+
pnpm test
|
|
243
|
+
pnpm build
|
|
244
|
+
pnpm smoke
|
|
245
|
+
pnpm package
|
|
246
|
+
pnpm smoke:install
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
`pnpm build` produces the self-contained artifact at `dist/bundle/token-harness.mjs`;
|
|
250
|
+
`pnpm smoke` runs it from a temporary directory outside the repository, so anything
|
|
251
|
+
that failed to inline shows up as a resolution failure rather than as a passing test.
|
|
252
|
+
CI runs all of it on `windows-latest`, `macos-latest`, and `ubuntu-latest`, in that
|
|
253
|
+
order and without fail-fast, because the failures this project exists to prevent are
|
|
254
|
+
mostly Windows-specific and finding them after two green jobs is how they become
|
|
255
|
+
workarounds instead of design.
|
|
256
|
+
|
|
257
|
+
## Release gates
|
|
258
|
+
|
|
259
|
+
| Version | Gate |
|
|
260
|
+
| --- | --- |
|
|
261
|
+
| `0.0.x` | Internal architecture and fixtures. No stability promise. |
|
|
262
|
+
| `0.1.0` | RTK and HarnessTrim, three harnesses, transactional install, verification with declared tiers, metrics, brownfield adoption **← here** |
|
|
263
|
+
| `0.2.0` | A third provider, goal-based profiles, the A/B benchmark matrix |
|
|
264
|
+
| `1.0.0` | Stable provider and harness contracts, two release cycles with no configuration-loss defects, published benchmark results |
|
|
265
|
+
|
|
266
|
+
`PLAN.md` §16 is the authority; this table is a summary of it.
|
|
267
|
+
|
|
268
|
+
`pnpm golden` regenerates the derived halves of the golden fixtures. It never
|
|
269
|
+
touches the five human transcripts transcribed from RFC 0006 — see
|
|
270
|
+
[tests/fixtures/README.md](tests/fixtures/README.md).
|
|
271
|
+
|
|
272
|
+
CI runs Windows, macOS, and Linux, with Windows first in the matrix and the
|
|
273
|
+
matrix set not to fail fast.
|
|
274
|
+
|
|
275
|
+
Releases publish on a `v*` tag through npm trusted publishing: OIDC, no token in the repository
|
|
276
|
+
secrets or anywhere else, and provenance signed by npm. A tag that does not match the staged version
|
|
277
|
+
is refused before the publish rather than discovered by whoever installs it.
|
|
278
|
+
|
|
279
|
+
- [Compatibility, verification tiers, and known limitations](docs/matrices.md) — the tables are
|
|
280
|
+
generated from the manifests and a test fails if they drift; the limitations below them are prose,
|
|
281
|
+
and a test checks that every limitation the code declares appears there
|
|
282
|
+
- [Development plan](PLAN.md)
|
|
283
|
+
- [Foundation decisions](docs/rfcs/0001-foundation.md)
|
|
284
|
+
- [Provider contract](docs/rfcs/0002-provider-contract.md)
|
|
285
|
+
- [Capability and conflict model](docs/rfcs/0003-capabilities-and-conflicts.md)
|
|
286
|
+
- [Safety and installation model](docs/rfcs/0004-safety-and-installation.md)
|
|
287
|
+
- [Metrics and attribution](docs/rfcs/0005-metrics-and-attribution.md)
|
|
288
|
+
- [CLI contract](docs/rfcs/0006-cli-contract.md)
|
|
289
|
+
- [Live verification](docs/rfcs/0007-live-verification.md)
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "token-harness",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "One control plane for token-efficient coding agents.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22.13.0"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"token-harness": "./token-harness.mjs"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"token-harness.mjs",
|
|
15
|
+
"sbom.json",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/giuliastro/token-harness.git"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/giuliastro/token-harness#readme",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/giuliastro/token-harness/issues"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"tokens",
|
|
29
|
+
"llm",
|
|
30
|
+
"coding-agent",
|
|
31
|
+
"claude-code",
|
|
32
|
+
"codex",
|
|
33
|
+
"opencode",
|
|
34
|
+
"cli"
|
|
35
|
+
]
|
|
36
|
+
}
|
package/sbom.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bomFormat": "CycloneDX",
|
|
3
|
+
"specVersion": "1.5",
|
|
4
|
+
"version": 1,
|
|
5
|
+
"metadata": {
|
|
6
|
+
"component": {
|
|
7
|
+
"type": "application",
|
|
8
|
+
"bom-ref": "token-harness",
|
|
9
|
+
"name": "token-harness",
|
|
10
|
+
"version": "0.1.0",
|
|
11
|
+
"description": "One control plane for token-efficient coding agents.",
|
|
12
|
+
"licenses": [
|
|
13
|
+
{
|
|
14
|
+
"license": {
|
|
15
|
+
"id": "Apache-2.0"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"hashes": [
|
|
20
|
+
{
|
|
21
|
+
"alg": "SHA-256",
|
|
22
|
+
"content": "5189fd514cc13d0d291588962f83608f249ebed06d118524bc3bbda8e54092db"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"tools": [
|
|
27
|
+
{
|
|
28
|
+
"name": "scripts/package.mjs"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"components": [
|
|
33
|
+
{
|
|
34
|
+
"type": "library",
|
|
35
|
+
"bom-ref": "@token-harness/core",
|
|
36
|
+
"name": "@token-harness/core",
|
|
37
|
+
"version": "0.1.0",
|
|
38
|
+
"scope": "required",
|
|
39
|
+
"licenses": [
|
|
40
|
+
{
|
|
41
|
+
"license": {
|
|
42
|
+
"id": "Apache-2.0"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"description": "first-party workspace package, inlined into the published bundle"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"type": "library",
|
|
50
|
+
"bom-ref": "@token-harness/platform",
|
|
51
|
+
"name": "@token-harness/platform",
|
|
52
|
+
"version": "0.1.0",
|
|
53
|
+
"scope": "required",
|
|
54
|
+
"licenses": [
|
|
55
|
+
{
|
|
56
|
+
"license": {
|
|
57
|
+
"id": "Apache-2.0"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"description": "first-party workspace package, inlined into the published bundle"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "library",
|
|
65
|
+
"bom-ref": "@token-harness/adapters",
|
|
66
|
+
"name": "@token-harness/adapters",
|
|
67
|
+
"version": "0.1.0",
|
|
68
|
+
"scope": "required",
|
|
69
|
+
"licenses": [
|
|
70
|
+
{
|
|
71
|
+
"license": {
|
|
72
|
+
"id": "Apache-2.0"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"description": "first-party workspace package, inlined into the published bundle"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"dependencies": [
|
|
80
|
+
{
|
|
81
|
+
"ref": "token-harness",
|
|
82
|
+
"dependsOn": [
|
|
83
|
+
"@token-harness/core",
|
|
84
|
+
"@token-harness/platform",
|
|
85
|
+
"@token-harness/adapters"
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|