reasonix 0.4.22 → 0.4.24

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
@@ -148,6 +148,29 @@ reasonix code › /commit "fix: findByEmail case-insensitive"
148
148
  writable).
149
149
  - `npx reasonix code --no-session` — ephemeral; nothing saved.
150
150
 
151
+ ### `reasonix stats` — how much did you actually save?
152
+
153
+ Every turn `reasonix chat|code|run` runs appends a compact record
154
+ (tokens + cost + what Claude Sonnet 4.6 would have charged) to
155
+ `~/.reasonix/usage.jsonl`. `reasonix stats` with no args rolls that
156
+ log into today / week / month / all-time windows:
157
+
158
+ ```
159
+ Reasonix usage — /Users/you/.reasonix/usage.jsonl
160
+
161
+ turns cache hit cost (USD) vs Claude saved
162
+ ----------------------------------------------------------------------
163
+ today 8 95.1% $0.004821 $0.1348 96.4%
164
+ week 34 93.8% $0.023104 $0.6081 96.2%
165
+ month 127 94.2% $0.081530 $2.1452 96.2%
166
+ all-time 342 94.0% $0.210881 $5.8934 96.4%
167
+ ```
168
+
169
+ Privacy: only tokens, costs, and the session name you chose land
170
+ in the file. No prompts, no completions, no tool arguments.
171
+ `reasonix stats <transcript>` keeps the old per-file summary
172
+ (assistant turns + tool calls) for scripts that already use it.
173
+
151
174
  ### Staying current
152
175
 
153
176
  The panel header shows the running version next to `Reasonix` (e.g.
@@ -271,6 +294,60 @@ prose, so skills authored for other tools usually port over unchanged
271
294
  (Reasonix's tool names differ — `filesystem` / `shell` / `web` — but
272
295
  the model reads the instructions and picks our equivalents).
273
296
 
297
+ ### Hooks — automate around tool calls and turns
298
+
299
+ Drop a `settings.json` under `.reasonix/` (project or `~/`) and
300
+ Reasonix will fire shell commands at four well-known points in
301
+ the loop: before a tool runs, after a tool returns, before your
302
+ prompt reaches the model, and after the turn ends.
303
+
304
+ ```json
305
+ // <project>/.reasonix/settings.json ← committable
306
+ // ~/.reasonix/settings.json ← per-user
307
+ {
308
+ "hooks": {
309
+ "PreToolUse": [{ "match": "edit_file|write_file", "command": "bun scripts/guard.ts" }],
310
+ "PostToolUse": [{ "match": "edit_file", "command": "biome format --write" }],
311
+ "UserPromptSubmit": [{ "command": "echo $(date +%s) >> ~/.reasonix/prompts.log" }],
312
+ "Stop": [{ "command": "bun test --run", "timeout": 60000 }]
313
+ }
314
+ }
315
+ ```
316
+
317
+ Each hook is a shell command. Reasonix invokes it with stdin = a
318
+ JSON envelope describing the event:
319
+
320
+ ```json
321
+ { "event": "PreToolUse", "cwd": "/path/to/project",
322
+ "toolName": "edit_file", "toolArgs": { "path": "src/x.ts", "..." } }
323
+ ```
324
+
325
+ Exit code drives the decision:
326
+
327
+ - **0** — pass; loop continues normally
328
+ - **2** — block (only on `PreToolUse` / `UserPromptSubmit`); the
329
+ hook's stderr becomes the synthetic tool result the model sees,
330
+ or the prompt is dropped entirely
331
+ - **anything else** — warn; loop continues, stderr renders as a
332
+ yellow row inline
333
+
334
+ `match` is anchored regex on the tool name; `*` or omitted matches
335
+ every tool. Project hooks fire before global hooks. Default
336
+ timeouts: 5s for blocking events, 30s for logging events; per-hook
337
+ `timeout` overrides.
338
+
339
+ **Slash**: `/hooks` (list active hooks) · `/hooks reload` (re-read
340
+ `settings.json` from disk without losing your session).
341
+
342
+ ### Staying current from inside the TUI
343
+
344
+ `/update` inside a running session shows your current version, the
345
+ last-resolved latest version (from the quiet 24h background check),
346
+ and the shell command to run. The slash does *not* spawn
347
+ `npm install` — stdio:inherit into a running Ink renderer corrupts
348
+ the display. Exit the session and run `reasonix update` in a
349
+ fresh shell when you actually want to install.
350
+
274
351
  ---
275
352
 
276
353
  ## `reasonix` — also works as general chat