costclaw 0.9.0 → 0.10.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.
Files changed (3) hide show
  1. package/README.md +51 -20
  2. package/dist/index.js +1354 -474
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -113,7 +113,9 @@ costclaw audit [--path <dir>] [--claude-md <file>] [--plan <plan>] [--json] [--h
113
113
  disable). `--html <file>` picks the path; `--no-html` skips the file;
114
114
  `--json` runs stay file-free unless `--html` is passed explicitly. Set
115
115
  `COSTCLAW_NO_OPEN=1` to write reports without launching a browser (CI and
116
- test runners are detected and never open one).
116
+ test runners are detected and never open one). The report ends with a
117
+ "What to do next" ramp: the commands to run next, how the optimize license
118
+ works, and a command reference.
117
119
  - `--card [file]` also write a shareable score card SVG (default
118
120
  `costclaw-card.svg`): your score, band, recoverable spend, cache hit rate, and
119
121
  strongest pillar. A static file, no fonts or network calls.
@@ -180,17 +182,21 @@ costclaw badge [--path <dir>] [--claude-md <file>] [--out <file>]
180
182
  npx costclaw optimize
181
183
  ```
182
184
 
183
- Turns the same audit into done-for-you artifacts: an optimized `CLAUDE.md`
184
- scaffold, a prioritized fix playbook, a conservative, project-derived
185
- `settings.suggested.json` permission allowlist, and a `HARNESS-UPGRADE.md` work
186
- order for your own Claude Code. It scans `--project <dir>`
187
- (default: the current directory) to auto-fill the scaffold from your real files.
188
- By default it dry-runs into `./costclaw-out` and touches none of your files.
189
-
190
- It also writes `DASHBOARD.html` and opens it: one page that browses every
191
- artifact, the ranked fixes, and a before and after of your CLAUDE.md (by section,
192
- as line changes, or side by side). Self-contained, no JavaScript, no network.
193
- Pass `--no-dashboard` to skip it.
185
+ Generates, for every project your audit saw, five artifacts: an optimized
186
+ `CLAUDE.md` scaffold, a prioritized fix playbook, a conservative,
187
+ project-derived `settings.suggested.json` permission allowlist, a
188
+ `HARNESS-UPGRADE.md` work order for your own Claude Code, and `costclaw.md`
189
+ (the generated sections as a standalone include). It never writes inside a
190
+ project; only `costclaw apply` does that, and only on an explicit command.
191
+
192
+ By default it runs globally: it ranks your audited projects by spend,
193
+ generates for the top ones (cap 10; override with `--limit N`) into
194
+ `~/.costclaw/optimize/<project>/`, and writes one `DASHBOARD.html` index
195
+ listing every project with its receipt and apply line, plus a local
196
+ click-to-apply page you can use instead of the command line (Ctrl+C, the
197
+ page's Done button, or `--no-serve` to skip it). `--project <dir>` keeps the
198
+ single-project behavior, writing into `./costclaw-out` (or `--out <dir>`)
199
+ instead. `--no-dashboard` skips the HTML.
194
200
 
195
201
  And it tells you what it actually did to the file that rides on every turn:
196
202
 
@@ -246,24 +252,49 @@ The rows plus that remainder line always add up to the headline figure above
246
252
  them, so the breakdown reconciles rather than approximating.
247
253
 
248
254
  ```
249
- costclaw optimize [--path <dir>] [--claude-md <file>] [--project <dir>] [--out <dir>] [--write <file>] [--apply-settings [file]] [--no-dashboard] [--force]
255
+ costclaw optimize [--path <dir>] [--claude-md <file>] [--project <dir>] [--out <dir>] [--limit <n>] [--no-dashboard] [--no-serve] [--force]
256
+ ```
257
+
258
+ ## Apply
259
+
260
+ ```bash
261
+ npx costclaw apply
262
+ ```
263
+
264
+ The only command that writes inside a project, and only additively. Run it
265
+ from inside the project, or pass a directory:
266
+
267
+ ```
268
+ costclaw apply [<dir>] [--remove] [--replace] [--apply-settings [file]] [--from <dir>] [--force]
250
269
  ```
251
270
 
252
- - `--write <file>` applies the optimized `CLAUDE.md` in place, after backing up
253
- the original to `<file>.bak` and printing a diff.
254
- - `--apply-settings [file]` merges the derived permission allowlist into your
255
- Claude Code settings. Opt-in and additive: it only touches
271
+ - Default mode writes the generated sections to `.claude/costclaw.md` and adds
272
+ one `@.claude/costclaw.md` import line (Claude Code's memory import syntax)
273
+ to your `CLAUDE.md`. Every line you wrote stays exactly as it was. Idempotent:
274
+ running it again rewrites the include and leaves the import line alone.
275
+ - `--remove` undoes it: deletes `.claude/costclaw.md` and `.claude/costclaw/`,
276
+ and strips the import line (only that exact generated line).
277
+ - `--replace` is the old wholesale rewrite. It requires a git repository (a
278
+ `.git` directory in the project), so the undo is `git checkout -- CLAUDE.md`;
279
+ outside git it refuses. It still keeps a `.bak` as a second net, refusing to
280
+ overwrite an existing one without `--force`.
281
+ - `--apply-settings [file]` additively merges the derived permission allowlist
282
+ into your Claude Code settings. Opt-in: it only touches
256
283
  `permissions.allow` and `permissions.deny` (a deduped union that keeps your
257
284
  existing entries and orders them first) and never removes or changes any other
258
- key. The default target is the scanned project's `.claude/settings.json`; pass
285
+ key. The default target is the project's `.claude/settings.json`; pass
259
286
  `[file]` to target another. It backs up the previous file to `<target>.bak`,
260
287
  prints a diff, then writes pretty JSON. A missing target is created; a file it
261
288
  cannot `JSON.parse` (for example JSONC with comments) is refused and left
262
289
  untouched.
263
- - `--force` allows overwriting an existing `.bak` backup for `--write` and
290
+ - `--from <dir>` points at a specific artifacts folder instead of looking one
291
+ up by project. Without it, `apply` finds artifacts from the last `optimize`
292
+ run, or generates them cold (into `./costclaw-out`) if none exist yet.
293
+ - `--force` allows overwriting an existing `.bak` backup for `--replace` and
264
294
  `--apply-settings`.
265
295
 
266
- `optimize` needs a one-time license (`costclaw activate <key>`); `audit` is free.
296
+ `optimize` and `apply` need a one-time license (`costclaw activate <key>`);
297
+ `audit` is free.
267
298
 
268
299
  ## Privacy
269
300