costclaw 0.9.1 → 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 +48 -19
  2. package/dist/index.js +1079 -299
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -182,17 +182,21 @@ costclaw badge [--path <dir>] [--claude-md <file>] [--out <file>]
182
182
  npx costclaw optimize
183
183
  ```
184
184
 
185
- Turns the same audit into done-for-you artifacts: an optimized `CLAUDE.md`
186
- scaffold, a prioritized fix playbook, a conservative, project-derived
187
- `settings.suggested.json` permission allowlist, and a `HARNESS-UPGRADE.md` work
188
- order for your own Claude Code. It scans `--project <dir>`
189
- (default: the current directory) to auto-fill the scaffold from your real files.
190
- By default it dry-runs into `./costclaw-out` and touches none of your files.
191
-
192
- It also writes `DASHBOARD.html` and opens it: one page that browses every
193
- artifact, the ranked fixes, and a before and after of your CLAUDE.md (by section,
194
- as line changes, or side by side). Self-contained, no JavaScript, no network.
195
- 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.
196
200
 
197
201
  And it tells you what it actually did to the file that rides on every turn:
198
202
 
@@ -248,24 +252,49 @@ The rows plus that remainder line always add up to the headline figure above
248
252
  them, so the breakdown reconciles rather than approximating.
249
253
 
250
254
  ```
251
- 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]
252
256
  ```
253
257
 
254
- - `--write <file>` applies the optimized `CLAUDE.md` in place, after backing up
255
- the original to `<file>.bak` and printing a diff.
256
- - `--apply-settings [file]` merges the derived permission allowlist into your
257
- Claude Code settings. Opt-in and additive: it only touches
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]
269
+ ```
270
+
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
258
283
  `permissions.allow` and `permissions.deny` (a deduped union that keeps your
259
284
  existing entries and orders them first) and never removes or changes any other
260
- 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
261
286
  `[file]` to target another. It backs up the previous file to `<target>.bak`,
262
287
  prints a diff, then writes pretty JSON. A missing target is created; a file it
263
288
  cannot `JSON.parse` (for example JSONC with comments) is refused and left
264
289
  untouched.
265
- - `--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
266
294
  `--apply-settings`.
267
295
 
268
- `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.
269
298
 
270
299
  ## Privacy
271
300