@compaction/cli 0.3.0 → 0.3.1

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,19 +1,53 @@
1
1
  # @compaction/cli
2
2
 
3
- **The free, local-first CLI for capturing and measuring AI agent traces.** It captures
4
- supported agent sessions on your own machine, shows input/output tokens and estimated spend
5
- with honest labels, and writes local reports and redacted share bundles. Everything runs
6
- locally and writes local files only **no account, no telemetry, no upload by default.**
3
+ **The free, local-first CLI for the Compaction Gateway a local, OpenAI-compatible proxy that
4
+ measures your AI traffic without changing it.** Point your OpenAI-compatible client's base URL at
5
+ the local gateway (or launch your workflow through it) and it forwards traffic to your provider and
6
+ records **content-free** token/cache receiptscounts and labels only, never prompt/response
7
+ content. Your provider key stays on the client. The CLI also captures and measures agent traces
8
+ locally. Everything runs on your machine — **no account, no telemetry, no upload to Compaction.**
9
+
10
+ > The free CLI runs the **local Gateway** (byte-safe **record** mode + content-free receipts, plus
11
+ > an **explicit, experimental deterministic apply/recovery**), captures and measures agent traces,
12
+ > and performs deterministic local compaction with the basic policies (`compact`) — writing honest
13
+ > before/after artifacts. The **learned context model (LCM), learned optimization engine, hosted /
14
+ > team control plane, verified-savings logic, and advanced proprietary evals are NOT in the npm /
15
+ > free CLI** — they are the **opt-in Compaction API**, which is **not a live hosted service yet**.
16
+
17
+ ## The Gateway (local, byte-safe)
18
+
19
+ The Compaction **Gateway** is a **local, OpenAI-compatible reverse proxy for OpenAI-compatible
20
+ clients**. Point your client's base URL at it, or launch your workflow through it, and it forwards
21
+ traffic to your provider and records **content-free** token/cache receipts (counts / structure /
22
+ labels only — never prompt/response content). Your provider key rides straight through to the
23
+ provider and is **never read, stored, or logged**. Set it up from onboarding (`compaction` →
24
+ **Gateway setup**), or directly:
7
25
 
8
- > **The free CLI captures, measures, inspects, reports, redacts — and performs deterministic
9
- > local compaction with the basic policies (`compact`), writing honest before/after artifacts.**
10
- > Advanced verification, recommendation and apply guidance, advanced policies, and team
11
- > reporting are **not** in the free CLI — they are the **opt-in Compaction API**, which is
12
- > **not a live hosted service yet**.
13
-
14
- ## What the CLI does
26
+ ```bash
27
+ compaction gateway start # start the local gateway (RECORD mode: byte-safe, no mutation)
28
+ compaction gateway run -- npm run dev # run a command through the gateway (no baseURL copy-paste)
29
+ compaction gateway status # requests observed + a content-free receipts rollup
30
+ compaction gateway activate # print env exports: eval "$(compaction gateway activate)"
31
+ ```
15
32
 
16
- Everything below runs on your machine and writes local files only:
33
+ - **Record mode is byte-safe** — it forwards your request and the provider's response
34
+ **byte-for-byte** and never changes either. Receipts are content-free and local-only (gitignored).
35
+ - **Explicit, experimental deterministic apply** (`--mode apply --policy deterministic-dedupe`) can
36
+ remove **exact-duplicate large blocks** from known-safe requests. It is **off by default**,
37
+ opt-in, and **retains the original locally** (`compaction gateway recover <id>`). Unknown/complex
38
+ shapes **fail closed** (forwarded unchanged); system/developer instructions and tool schemas are
39
+ never touched; the **response is never changed**.
40
+ - **No hosted/managed proxy or model routing.** The local Gateway is an OpenAI-compatible reverse
41
+ proxy for compatible clients — it runs on your machine.
42
+ - **Claim boundary.** The gateway reports **provider-reported** token/cache counts (or
43
+ `unavailable`) — it makes **no cost-savings, no output-token-savings, and no billing-confirmed
44
+ claim**. A model-visible **input** reduction is stated only when apply actually changed the
45
+ request (a **local-estimate** before/after; the original is retained) — never a cost or
46
+ output-token figure, and never a "no context lost" claim.
47
+
48
+ ## Trace / capture utilities (other local tools)
49
+
50
+ Beyond the Gateway, the free CLI captures and measures agent traces locally — local files only:
17
51
 
18
52
  - **Capture supported agent sessions.** Claude Code is the primary supported workflow
19
53
  (`capture claude-code`); OpenAI Agents SDK (`capture openai-agents`) and Codex / local-file
@@ -34,55 +68,54 @@ Everything below runs on your machine and writes local files only:
34
68
  - **Build a local context store and retrieve from it.** `context add` accumulates source-pointed
35
69
  items from a captured/imported trace into a local, size-capped store; `context get`
36
70
  deterministically retrieves and assembles the active context for a query under a token budget,
37
- printing it **with source pointers** plus local retrieval **diagnostics** (what was
38
- considered / included / dropped, the recoverable fraction, latency). Local-only and
39
- deterministic **no model, no embeddings, no network**. It reports **diagnostics only** (no
40
- quality or sufficiency verdict on your data) and makes **no savings claim** (see `spend` /
41
- `summary` for cost).
42
- - **Write local reports.** `analyze` writes local JSON + Markdown reports under an
43
- operator-chosen output directory. Local files only.
71
+ printing it **with source pointers** plus local retrieval **diagnostics**. Local-only and
72
+ deterministic **no model, no embeddings, no network**. It reports **diagnostics only** and
73
+ makes **no savings claim**.
74
+ - **Write local reports.** `analyze` writes local JSON + Markdown reports under an operator-chosen
75
+ output directory. Local files only.
44
76
  - **Create redacted, content-free share bundles.** `feedback --redact` writes a redacted,
45
77
  privacy-safe bundle as a **local file only — never uploaded**, and only with an explicit write
46
78
  gesture (`--yes`).
47
- - **No upload by default.** There is **no telemetry**. The **only** network call in the free CLI
48
- is the explicitly operator-invoked, read-only `capture provider-usage` (credential supplied via
49
- an environment variable only; aggregate usage/cost figures only, no prompt/completion content).
50
79
 
51
- The free CLI deliberately answers the first-value question — *"where is my context being wasted,
52
- and roughly what does it cost?"* — entirely locally, with honest labels.
80
+ ## Free (npm) vs. private (opt-in API)
53
81
 
54
- ## What requires the Compaction API (opt-in — not in the free CLI)
82
+ **In the free / local CLI (npm):**
55
83
 
56
- These are **not** part of the free local CLI:
84
+ - the **local Gateway** record mode, `status`, content-free receipts, `gateway run`,
85
+ - **explicit deterministic apply / dry-run / recover** (experimental, opt-in),
86
+ - **capture / import / analyze / spend / compact / context / feedback** (local trace utilities).
57
87
 
58
- - **Recommendation** a recommended-policy verdict (`recommend`) for a captured trace.
59
- - **Advanced verification** — stronger checks on what a compacted context retains (incl. `compact --eval`).
60
- - **Apply guidance** — a readiness verdict and a review/approval path before any context is applied.
61
- - **Advanced policies & team reporting** — configurable behavior controls beyond the basic
62
- deterministic policies, and cross-run / team reporting.
88
+ **NOT in the npm / free CLI** (these are the opt-in Compaction API **not a live hosted service
89
+ yet**):
63
90
 
64
- > **The Compaction API is not broadly hosted yet.** There is **no live hosted service today**.
65
- > Until the API is available, these capabilities are **on the roadmap / opt-in**, not present in
66
- > the free CLI. The honesty rails carry over unchanged: cost stays an **estimate** unless
67
- > billing-confirmed (no figure carries that label today); verification is **deterministic
68
- > recoverability, NOT semantic/meaning preservation**; and there is **no auto-apply** every
69
- > application is an explicit operator gesture.
91
+ - the **LCM / learned context model**,
92
+ - the **learned optimization engine**,
93
+ - the **hosted / team control plane**,
94
+ - **verified-savings** logic,
95
+ - **advanced proprietary evals** (and recommendation / advanced verification / apply-guidance / advanced policies).
96
+
97
+ > **The Compaction API is not broadly hosted yet.** There is **no live hosted service today**. The
98
+ > honesty rails carry over unchanged: cost stays an **estimate** unless billing-confirmed (no figure
99
+ > carries that label today); verification is **deterministic recoverability, NOT semantic/meaning
100
+ > preservation**; and there is **no auto-apply** — every application is an explicit operator gesture.
70
101
 
71
102
  ## Install
72
103
 
73
- A local-first CLI. It makes no network calls by default; the only command that reaches the
74
- network is the explicitly operator-invoked `capture provider-usage`. There is no telemetry.
104
+ A local-first CLI. **No telemetry and no upload to Compaction.** Network happens only when you
105
+ explicitly call provider-usage (`capture provider-usage`) or route your own provider traffic through
106
+ the local gateway (which forwards it to your provider). Nothing else reaches the network.
75
107
 
76
108
  ### npm / npx
77
109
 
78
110
  ```bash
79
- npm install -g @compaction/cli # then: compaction init
111
+ npm install -g @compaction/cli # then: compaction
80
112
  npx @compaction/cli init # no global install
81
113
  npx @compaction/cli --help # no install at all
82
114
  ```
83
115
 
84
116
  The installed binary is `compaction`. After a global install, sanity-check with
85
- `compaction --version` (→ `0.3.0`) and `compaction --help`.
117
+ `compaction --version` (→ `0.3.1`) and `compaction --help`. Run `compaction` (no args) to open
118
+ onboarding, including **Gateway setup**.
86
119
 
87
120
  ### curl one-liner
88
121
 
@@ -102,42 +135,29 @@ curl -fsSL https://cli.compaction.dev/install | sh -s -- --dry-run
102
135
 
103
136
  ## Quick start
104
137
 
105
- Run on **your own** captured/imported workflow — not a demo. The recommended free local loop is
106
- **capture → analyze → (local report) → redact / share**:
138
+ Two local loops, both on **your own** workflow — not a demo.
139
+
140
+ **Route your traffic through the local Gateway** (byte-safe; content-free receipts):
107
141
 
108
142
  ```bash
109
- compaction init # one-time local scaffold (writes nothing until you capture)
110
- # 1. Capture a real workflow (Claude Code shown; --discover lists local sessions):
111
- compaction capture claude-code --discover
112
- compaction capture claude-code --session <session.jsonl> --out ./my-trace
113
- # 2. Measure tokens + estimated spend, and see where it came from:
114
- compaction analyze ./my-trace/captured-trace.json
115
- compaction spend ./my-trace/captured-trace.json
116
- # 3. Share a redacted, content-free bundle (local file only, never uploaded):
117
- compaction feedback --redact --yes
143
+ compaction gateway start # start the local gateway (RECORD mode)
144
+ compaction gateway run -- npm run dev # or point your OpenAI client's baseURL at the listen address + /v1
145
+ compaction gateway status # see requests observed + the content-free receipts rollup
118
146
  ```
119
147
 
120
- Deterministic basic compaction (`compaction compact <trace> --out <dir>`) also runs locally in
121
- the free CLI. Advanced verification, recommendation, and apply guidance are the opt-in
122
- Compaction API — not steps of the free local CLI.
123
-
124
- ## Gateway (local, byte-safe)
125
-
126
- The Compaction **Gateway** is a local, OpenAI-compatible reverse proxy. Point your OpenAI client at it
127
- (or launch your workflow through it) and it forwards traffic to the provider and records **content-free**
128
- token/cache receipts — no prompt/response content, and your provider key stays on the client. Set it up
129
- from onboarding (`compaction` → **Gateway setup**), or directly:
148
+ **Capture + measure an agent trace** (local files only):
130
149
 
131
150
  ```bash
132
- compaction gateway start # start the local gateway (RECORD mode; byte-safe, no mutation)
133
- compaction gateway run -- npm run dev # run a command through the gateway (no baseURL copy-paste)
134
- compaction gateway status # requests observed + a content-free receipts rollup
151
+ compaction init # one-time local scaffold (writes nothing until you capture)
152
+ compaction capture claude-code --discover # list local Claude Code sessions
153
+ compaction capture claude-code --session <session.jsonl> --out ./my-trace
154
+ compaction analyze ./my-trace/captured-trace.json # tokens + estimated spend, honestly labeled
155
+ compaction feedback --redact --yes # redacted, content-free bundle (local file only, never uploaded)
135
156
  ```
136
157
 
137
- Record mode never changes your request or response. An **experimental**, explicit-opt-in deterministic
138
- `apply` mode (`--mode apply --policy deterministic-dedupe`) can remove exact-duplicate large blocks from
139
- known-safe requests, retaining the original locally (`compaction gateway recover <id>`). Nothing is called
140
- a saving — the gateway reports provider-reported token/cache counts (or "unavailable"), never a cost figure.
158
+ Deterministic basic compaction (`compaction compact <trace> --out <dir>`) also runs locally.
159
+ Advanced verification, recommendation, and apply guidance are the opt-in Compaction API not steps
160
+ of the free local CLI.
141
161
 
142
162
  ## Supported local workflows
143
163
 
@@ -153,14 +173,29 @@ a saving — the gateway reports provider-reported token/cache counts (or "unava
153
173
  `codex exec --json` export) and normalizes it. **Level 1.** Codex token counts on this path are
154
174
  **locally estimated (chars/4)**, not provider-reported. `compaction import --list-sources` lists
155
175
  supported sources.
176
+ - **OpenAI-compatible clients via the local Gateway** — any OpenAI-compatible client can route
177
+ through `compaction gateway` for content-free receipts (and, opt-in, explicit deterministic apply).
156
178
 
157
- There is **no** native/Level 3 SDK instrumentation, no production proxy, no model routing, and no
179
+ There is **no** native/Level 3 SDK instrumentation, **no hosted/managed proxy or model routing**
180
+ (the local Gateway is an OpenAI-compatible reverse proxy for compatible clients), and no
158
181
  consumer-app (ChatGPT/Claude desktop) support.
159
182
 
160
183
  ## Commands
161
184
 
162
185
  ```bash
186
+ compaction # onboarding (workflow chooser + Gateway setup)
163
187
  compaction init # one-time local scaffold
188
+
189
+ # Gateway (local, byte-safe):
190
+ compaction gateway start # start the local gateway (RECORD mode)
191
+ compaction gateway run -- <command> # run a command through the gateway
192
+ compaction gateway status # requests observed + content-free receipts rollup
193
+ compaction gateway activate # print env exports (eval-able); prints only, no mutation
194
+ compaction gateway configure # approval-gated: propose a project baseURL (diff, no write without --apply)
195
+ compaction gateway recover <recovery_id> # recover the original request retained by apply mode
196
+ compaction gateway stop # stop a running local gateway
197
+
198
+ # Trace / capture utilities:
164
199
  compaction capture claude-code --session <session.jsonl> [--include-subagents] --out <dir>
165
200
  compaction capture claude-code --discover [--projects-dir <path>]
166
201
  compaction capture openai-agents --out <dir> -- <command> [args...]
@@ -177,15 +212,20 @@ compaction aggregate # per-session / cross-session l
177
212
  compaction feedback --redact [--yes] # redacted, local-only share bundle
178
213
  ```
179
214
 
180
- `compaction --help` lists the free local commands.
215
+ `compaction --help` lists the free local commands; `compaction gateway --help` lists the gateway commands.
181
216
 
182
217
  ## Privacy and security
183
218
 
184
- - **No telemetry; no upload by default.** The free CLI is local-first and file-based.
185
- - **One network call only.** `capture provider-usage` is explicitly operator-invoked and read-only;
186
- its credential comes from an **environment variable only** (never a flag value, never logged,
187
- never written into artifacts), and it captures **aggregate** usage/cost figures only — no
188
- prompt/completion content. Its absence is a clean refusal.
219
+ - **No telemetry; no upload to Compaction.** The free CLI is local-first and file-based.
220
+ - **Network only on explicit action.** Network happens only when you explicitly call
221
+ `capture provider-usage` (read-only; credential via an **environment variable only**, never a flag
222
+ value, never logged, never written into artifacts; **aggregate** usage/cost figures only — no
223
+ prompt/completion content) **or** route your own provider traffic through the local gateway (which
224
+ forwards it to your provider; your provider key stays on the client and is never read or stored).
225
+ - **Content-free gateway receipts.** Gateway receipts record token/cache counts and labels only —
226
+ never prompt/response content; they are local-only (gitignored). Apply mode retains the original
227
+ request **locally** (restrictive permissions) so it is recoverable; that original is referenced
228
+ from receipts by id only.
189
229
  - **Captured traces can contain local content.** Capturing a session may include local file
190
230
  content — review a trace before sharing it.
191
231
  - **Redacted sharing.** `feedback --redact` produces a redacted, content-free bundle as a local
@@ -199,33 +239,42 @@ Every figure this tool produces carries one of these labels — and nothing stro
199
239
  | Label | Meaning |
200
240
  |---|---|
201
241
  | **local estimate** | chars/4 token heuristics and price-table cost approximations computed locally |
202
- | **provider-reported token delta** | token counts read from the provider's own API response/usage metadata (operator-entered or captured); input tokens are deterministic for a fixed context+prompt |
242
+ | **provider-reported token delta** | token counts read from the provider's own API response/usage metadata (operator-entered, captured, or via the gateway); input tokens are deterministic for a fixed context+prompt |
203
243
  | **token-estimated cost** | a price-table estimate applied to provider-reported token counts (`price_table_estimate`) — an estimate, never a billed figure |
204
244
  | **operator-entered billing record** | billed costs the operator read from their own provider console; recorded, not provider-verified by this tool |
205
245
  | **billing-confirmed** | only with real provider billing/invoice evidence **AND** the accepted measurement criterion met on those billed runs (N ≥ 3 runs per arm AND the delta-of-means ±2·SE interval excludes zero) — the statistical criterion alone is a bar on operator-entered figures, not proof of billing, so it is never sufficient by itself — **no figure in this repository currently carries this label** |
206
246
 
207
- **What is NOT claimed:** no billing-confirmed savings claim; no invoice savings claim; no general savings claim (all results are workflow-scoped and caveated); no auto-apply (every application is an explicit operator gesture); no hosted service or control plane (the free CLI is local-first, file-based); no universal "no context is lost" claim; no semantic/meaning preservation claim (it stays `not_evaluated`); no native/production/Level 3 integration claim.
247
+ **What is NOT claimed:** no billing-confirmed savings claim; no invoice savings claim; no
248
+ output-token savings claim unless measured before/after **and** eval-confirmed; no general savings
249
+ claim (all results are workflow-scoped and caveated); no auto-apply (every application is an explicit
250
+ operator gesture); no hosted service or control plane, and **no hosted-live claim** (the free CLI +
251
+ Gateway are local-first, file-based); no universal "no context is lost" claim; no semantic/meaning
252
+ preservation claim (it stays `not_evaluated`); no native/production/Level 3 integration claim.
208
253
 
209
254
  ## Known limitations
210
255
 
211
- - **The free CLI captures, measures, and compacts deterministically; it does not perform
212
- advanced verification.** Recommendation, advanced verification (incl. `compact --eval`), apply
213
- guidance, advanced policies, and team reporting are the **opt-in Compaction API** — not the
214
- free local CLI. The API is **not broadly hosted yet**.
256
+ - **The free CLI runs the local Gateway, captures/measures traces, and compacts deterministically;
257
+ it does not perform advanced verification.** The LCM / learned optimization engine, hosted/team
258
+ control plane, verified savings, advanced proprietary evals, recommendation, advanced verification
259
+ (incl. `compact --eval`), apply guidance, and advanced policies are the **opt-in Compaction API**
260
+ not the free local CLI. The API is **not broadly hosted yet**.
215
261
  - **Cost figures are estimates or operator-entered records, not billing-confirmed.** Locally
216
262
  computed cost figures are price-table estimates; provider-usage records carry operator-entered/
217
263
  captured console figures (not provider-verified by this tool). **No figure is billing-confirmed.**
218
264
  - **Token counts are local estimates unless provider-reported usage is captured.** The default is a
219
265
  chars/4 estimate, labeled as such. Unknown stays unknown — output tokens, provider, or cost the
220
266
  data does not carry are never inferred.
267
+ - **Gateway apply is experimental, deterministic, and opt-in.** It removes only exact-duplicate large
268
+ blocks from known-safe request shapes, retains the original locally, and fails closed on anything
269
+ else; it makes no output-token or cost claim, and never claims meaning preservation or "no context
270
+ lost". Record mode is the byte-safe default.
221
271
  - **Integrations are Level 1/2, not native/production.** Claude Code and OpenAI Agents capture are
222
272
  Level 2 local command-wrappers; Codex/local-file import is Level 1. There is **no** native/Level 3
223
- SDK instrumentation, no production proxy, no model routing, and no consumer-app support.
273
+ SDK instrumentation, **no hosted/managed proxy or model routing**, and no consumer-app support.
224
274
  - **Verification (opt-in API) is deterministic recoverability, not semantic preservation.** Where
225
275
  the opt-in API verifies a compacted context, it checks deterministic recoverability for a
226
276
  supported workflow; it does **not** evaluate meaning or task equivalence and does **not** re-run
227
- your agent through a model. Semantic / meaning preservation remains **not evaluated**; true model
228
- replay is future work.
277
+ your agent through a model. Semantic / meaning preservation remains **not evaluated**.
229
278
  - **No universal "no context is lost" guarantee.** Any apply-guidance verdict from the opt-in API
230
279
  is **fail-closed and scoped** to supported developer-agent workflows — never a universal
231
280
  guarantee, and never a semantic/meaning claim.
@@ -97,7 +97,7 @@ export async function runUpgrade(opts) {
97
97
  */
98
98
  export async function runStatus(opts = {}) {
99
99
  const env = opts.env ?? process.env;
100
- const version = opts.version ?? "0.3.0";
100
+ const version = opts.version ?? "0.3.1";
101
101
  const target = resolveTarget({ env });
102
102
  const configured = target.apiKey !== undefined && !isLocalDefaultUrl(target.url);
103
103
  console.log(chalk.cyan("compaction status"));
@@ -146,7 +146,7 @@ export function registerStatusCommand(program) {
146
146
  .command("status")
147
147
  .description("Show local core status and whether a hosted endpoint is configured + reachable.")
148
148
  .action(async () => {
149
- await runStatus({ version: program.version() ?? "0.3.0" });
149
+ await runStatus({ version: program.version() ?? "0.3.1" });
150
150
  });
151
151
  }
152
152
  //# sourceMappingURL=upgrade-status.js.map
package/dist/cli/index.js CHANGED
@@ -39,7 +39,7 @@ const program = new Command();
39
39
  program
40
40
  .name("compaction")
41
41
  .description("CLI-first trace compaction tools for AI agent workflows.")
42
- .version("0.3.0");
42
+ .version("0.3.1");
43
43
  // Brand mark above the TOP-LEVEL help only (compaction --help / bare `compaction`).
44
44
  // Derived rendering of apps/web/src/assets/compaction-mark.svg — see
45
45
  // docs/brand/terminal-logo.md. Colored only on a TTY with NO_COLOR unset; plain
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compaction/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },