token-goat 2.2.2 → 2.2.4

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 +39 -2
  2. package/dist/token-goat.mjs +8801 -4712
  3. package/package.json +3 -1
package/README.md CHANGED
@@ -61,7 +61,7 @@ The fastest way to reduce AI token costs is fixing these five, not writing short
61
61
  |--------------------|------------------|
62
62
  | 3.3 MB screenshot lands in model context | 84 KB compressed copy, 97.4% smaller |
63
63
  | Agent re-reads files from earlier in the session | "Already read this" reminder with narrow slice suggestion |
64
- | Agent re-reads a file edited mid-session | Unified diff injected as a hint — full Read avoided when the diff covers the change |
64
+ | Agent re-reads a file edited mid-session | Unified diff injected as a hint — full Read avoided when the diff covers the change. Docs (`.md`/`.rst`/`.txt`) by default; source/style/data files (`.ts`/`.css`/`.json`/…) when `serve_diff_on_reread` is enabled |
65
65
  | Compaction forgets which files were edited | Structured session manifest injected before compact |
66
66
  | Same files re-read from scratch after `/compact` | Recovery hint at SessionStart lists cached snapshot + bash + WebFetch IDs |
67
67
  | Loaded skill body summarised away by compaction | `### Active Skills` manifest section + `**Skills**:` recovery block list every loaded skill; full body recoverable via `token-goat skill-body <name>` without re-invoking |
@@ -75,7 +75,7 @@ The fastest way to reduce AI token costs is fixing these five, not writing short
75
75
  | `rg "^def" src/file.py` or `grep "class " module.ts` — structural search on a single source file | Pre-Bash hook redirects to `token-goat skeleton "file"` or `outline "file"` — all symbols with line numbers, no full-file read |
76
76
  | `rg` or `grep` run twice with the same pattern | Pre-Bash dedup hint fires on repeated `rg`/`grep`/`ag` calls the same way it fires on the native Grep tool; repeat searches return a cached match-count hint instead of re-running |
77
77
  | Read tool targets `tool-results/<id>.txt` or `tasks/<id>.output` | Pre-Read hook suggests `token-goat bash-output <id> --tail N` / `--grep PATTERN` / `--section H`; the filename stem is the output ID |
78
- | Repeated monitoring command run again (`gh run watch`, `next dev`, `vitest`, `docker logs`) | Pre-bash recall hint: when a prior run is cached and its output exceeds 2 KB, a pointer to `token-goat bash-output <id> --grep PATTERN` is injected instead of re-running the command |
78
+ | Repeated monitoring command run again (`gh run watch`, `next dev`, `vitest`, `docker logs`) | Pre-bash recall hint: when a prior run is cached and its output exceeds 2 KB, a pointer to `token-goat bash-output <id> --grep PATTERN` is injected instead of re-running the command. Cache is keyed on the *base command*, so re-running with a different trailing pipe (e.g., `| tail -40` then `| grep error`) still hits the same cache entry |
79
79
  | `pnpm`/`yarn`/`bun` install or build dumps full output | pnpm, yarn, and bun compress filters now strip install noise and build logs the same way npm does; `pnpm run`/`yarn run` route through their own filter |
80
80
  | Surgical-read command returns a 10k-line symbol or a full section dump | Capped at ~25k tokens; marker names the truncation ratio and narrowing command (`symbol` → `file::Class.method`; `section` → sub-heading; cached → `--grep`/`--tail`) |
81
81
  | Full file read for one function or section | `token-goat read file::symbol`, about 85% smaller |
@@ -336,6 +336,21 @@ Manual paths:
336
336
  | Reinstall from scratch (broken install, sharp failure) | `npm install -g token-goat@latest` |
337
337
  | Disable auto-updates | Delete the `token-goat-update` scheduled task (Windows) or the `# token-goat-autoupdate` crontab line (Linux/macOS) |
338
338
 
339
+ ### Upgrading from the Python version
340
+
341
+ The old Python package (`pip install token-goat`) wrote hook entries into `settings.json` with commands containing `token_goat` (underscore), invoking Python directly: something like `pythonw.exe -m token_goat.cli hook pre_tool_use`. The npm package uses `token-goat hook pre_tool_use` (hyphen) instead.
342
+
343
+ `token-goat uninstall` only strips entries matching `token-goat hook`. Python-style entries are invisible to it. Left in place alongside the new npm entries, both sets fire on every tool call.
344
+
345
+ To upgrade cleanly:
346
+
347
+ 1. Remove the Python package: `pip uninstall token-goat`
348
+ 2. Open `~/.claude/settings.json` (Windows: `%USERPROFILE%\.claude\settings.json`) and delete any hook entries whose `command` contains `token_goat` (underscore).
349
+ 3. Install and register the npm package: `npm install -g token-goat && token-goat install`
350
+ 4. Verify: re-run `token-goat install` (safe to repeat) or use the `jq` check under [Verify](#verify).
351
+
352
+ **AI agents handling an upgrade:** complete all four steps in sequence. After step 4, confirm no `token_goat` entries remain in `settings.json` before reporting the upgrade done.
353
+
339
354
  ## CLI
340
355
 
341
356
  | Command | What it does |
@@ -515,6 +530,28 @@ token-goat stats
515
530
 
516
531
  `doctor` confirms the install is healthy. `stats` shows cumulative savings.
517
532
 
533
+ ### Confirming hooks are wired
534
+
535
+ `doctor` checks the binary, worker, database, and disk. It does not inspect `settings.json` hook wiring. To confirm all three hooks are present, re-run `install`:
536
+
537
+ ```
538
+ token-goat install
539
+ ```
540
+
541
+ `install` is idempotent: it adds any missing entries and leaves existing hook entries alone. Re-running it is always safe. To inspect the wiring directly:
542
+
543
+ ```bash
544
+ # Linux / macOS / WSL
545
+ jq '[.hooks | to_entries[] | select(.value[].hooks[]?.command | contains("token-goat hook")) | .key]' ~/.claude/settings.json
546
+
547
+ # Windows (PowerShell with jq on your PATH)
548
+ jq '[.hooks | to_entries[] | select(.value[].hooks[]?.command | contains("token-goat hook")) | .key]' "$env:USERPROFILE\.claude\settings.json"
549
+ ```
550
+
551
+ A working install returns `["PreToolUse", "PostToolUse", "PreCompact"]`. Any missing event means a partial install; run `token-goat install` to fill it in.
552
+
553
+ **AI agents:** after `token-goat install`, run the `jq` check above or re-run `token-goat install` before marking the install complete. `doctor` does not verify hook wiring.
554
+
518
555
  ## Image support
519
556
 
520
557
  Token-goat shrinks large images before they reach the model, cutting vision token costs by 60–90%. The pipeline uses [`sharp`](https://sharp.pixelplumbing.com/), a Node.js image processing library that ships prebuilt native binaries for Windows, macOS, Linux, and Alpine.