@delt/claude-jev-advisor 0.2.0 β†’ 0.4.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.
package/README.md CHANGED
@@ -5,21 +5,21 @@ Unofficial helpers for [Claude Code](https://claude.com/claude-code), installed
5
5
  What is sent to TypeSafe's Jev API (`api.typesafe.ai`):
6
6
 
7
7
  - `context`: your last three requests (typed by you, or sent through a channel or from another Claude Code session), each cut to its first 1,000 characters, and Claude's last reply, cut to its first and last 1,500 characters.
8
- - `rm`: only for a delete it would otherwise ask about, and only when the target is a file this session made or a folder git ignores. It sends the path, the `rm` command and its description, up to three tool calls of this session that name the target (each cut to 600 characters), and for a folder up to ten of its file names.
8
+ - `rm`: only for a delete it would otherwise ask about, and only when the target is a file this session made or a folder git ignores. It sends the path, the delete command and its description, up to three tool calls of this session that name the target (each cut to 600 characters), and for a folder up to ten of its file names.
9
9
 
10
10
  Not affiliated with Anthropic or TypeSafe.
11
11
 
12
12
  | Helper | What it does | Systems |
13
13
  |---|---|---|
14
14
  | `context` | At the end of each turn, suggests `/compact` or `/clear` when the conversation is large and the work has reached a stopping point. Shown at the end of Claude Code's bottom row. | Any |
15
- | `rm` | Asks before a Bash `rm` deletes real files. Lets temp files through and refuses an `rm` whose targets it cannot work out. Jev can lift the ask for a test file this session made or a folder git ignores. | Windows |
15
+ | `rm` | Asks before a Bash or PowerShell command deletes real files (`rm`, `Remove-Item`, `del`, `rd`, also inside `sh -c`, `powershell -Command` or `cmd /c`). Lets temp files through and refuses a delete whose targets it cannot work out. Jev can lift the ask for a test file this session made or a folder git ignores. | Windows |
16
16
 
17
17
  ## Requirements
18
18
 
19
19
  - Node.js 18 or later
20
- - Claude Code (the bottom-row display uses Claude Code mods, an early-access feature that may change between releases)
20
+ - Claude Code (the bottom-row display and the advice button use Claude Code mods, an early-access feature that may change between releases)
21
21
  - A TypeSafe API key for the `context` helper and for the Jev check of the `rm` helper, in `TYPESAFE_API_KEY` or in a key file (`--key-file`). Without a key, `rm` asks about every real file.
22
- - Windows for the `rm` helper. On other systems `install` skips it and says why.
22
+ - Windows for the `rm` helper. On other systems `install` skips it and says why. It reads PowerShell commands with Windows PowerShell, which comes with Windows, or with PowerShell 7 when `pwsh` is on `PATH`, the same one Claude Code uses. It was checked with Windows PowerShell 5.1; PowerShell 7 was not tested.
23
23
 
24
24
  ## Install
25
25
 
@@ -35,9 +35,13 @@ claude-jev-advisor install
35
35
 
36
36
  When the context helper is installed and no key is found, `install` asks for your TypeSafe API key. What you type is hidden. It checks the key with one small Jev call and saves it to `~/.claude/claude-jev-advisor/jev-key.env`. Press Enter to skip; `claude-jev-advisor key` asks again later. Instead of typing it, you can set `TYPESAFE_API_KEY`, or pass `--key-file <path>` to a file holding a line `TYPESAFE_API_KEY=...` (then only that path is saved). The key is never printed or logged. On Windows that file is protected by your user folder's permissions only.
37
37
 
38
- Before it changes `~/.claude/settings.json`, `install` copies it to `~/.claude/backups/settings.json.<YYYY-MM-DD-HHmmss>-before-claude-jev-advisor`. If a backup from the same second already exists, it adds `-2`, `-3` and so on instead of overwriting it. It then adds or replaces only this package's entries. Running it again changes nothing.
38
+ Before it changes `~/.claude/settings.json`, `install` copies it to `~/.claude/backups/settings.json.<YYYY-MM-DD-HHmmss>-before-claude-jev-advisor`. If a backup from the same second already exists, it adds `-2`, `-3` and so on instead of overwriting it. It then adds or replaces only this package's entries. Running it again with the same version changes nothing. With the mod display it also binds `ctrl+x ctrl+f` in `~/.claude/keybindings.json` (see the context helper below), backing that file up the same way first.
39
39
 
40
- The hooks also reach Claude Code sessions that are already open; the bottom-row display starts with the next new session. Turning a helper on or off applies at once, even to open sessions.
40
+ After upgrading from 0.2 or earlier, run `claude-jev-advisor install rm` again so that the rm hook also covers the PowerShell tool. Until you do, `status` shows `Bash only`.
41
+
42
+ After upgrading from 0.3 or earlier, run `claude-jev-advisor install context` again so that it binds `ctrl+x ctrl+f` for the advice button. Until you do, `status` shows `shortcut: none - run "claude-jev-advisor install context" ...`.
43
+
44
+ The hooks also reach Claude Code sessions that are already open. The bottom-row display and the advice button start with the next new session; sessions that already show the bottom-row display pick up an upgrade by themselves. Turning a helper on or off applies at once, even to open sessions.
41
45
 
42
46
  ## Commands
43
47
 
@@ -46,7 +50,7 @@ The hooks also reach Claude Code sessions that are already open; the bottom-row
46
50
  | `claude-jev-advisor install [rm] [context] [--lang ko\|en] [--key-file <path>] [--display mod\|statusline\|message]` | Registers the hooks (backs up `settings.json` first) and switches the helpers on |
47
51
  | `claude-jev-advisor uninstall [rm] [context]` | Removes this package's hooks and display from `settings.json` |
48
52
  | `claude-jev-advisor on [rm] [context]` / `off [rm] [context]` | Switches helpers on or off without touching `settings.json` |
49
- | `claude-jev-advisor status` | Shows what is registered and on, the display, whether a key is set, the thresholds and the last judgment |
53
+ | `claude-jev-advisor status` | Shows what is registered and on, the display, the shortcut, whether a key is set, the thresholds and the last judgment |
50
54
  | `claude-jev-advisor report [--days 7]` | Lists the `/compact` and `/clear` advice shown and what followed it, and the deletions Jev let through |
51
55
  | `claude-jev-advisor key` | Asks for the TypeSafe API key, checks it and saves it (needs an interactive terminal) |
52
56
  | `claude-jev-advisor help` | Prints the usage |
@@ -62,13 +66,22 @@ When a turn ends, a `Stop` hook reads the size of the conversation from the sess
62
66
 
63
67
  The answer is saved for the display. Nothing is added to what Claude sees, so it costs no Claude tokens. If Jev does not answer within 8 seconds, only the size is shown. While a subagent or a workflow runs in the background, the turn counts as work in progress and Jev is not asked; background shells and monitors do not count.
64
68
 
65
- | Situation | Shown |
66
- |---|---|
67
- | Under 250k, or no judgment (no key, Jev unreachable) | `52k` |
68
- | Work in progress | `🟒 312k` |
69
- | A whole stage closed (from 250k) | `🟑 312k μƒˆλ‘­κ²Œ μ‹œμž‘ν•˜λŠ” 건 μ–΄λ– μ„Έμš”? /clear` |
70
- | Work finished, stage goes on (from 250k) | `🟑 312k μ§€κΈˆκΉŒμ§€ μ •λ¦¬ν•˜κ³  μ΄μ–΄κ°€λŠ” 건 μ–΄λ– μ„Έμš”? /compact` |
71
- | Within 20% of auto-compact | `πŸ”΄ 790k 18%`, then ` Β· ` and the `/clear` or `/compact` advice above, or `μž‘μ—…μ΄ λλ‚˜λ©΄ μ •λ¦¬ν•˜κ³  μ΄μ–΄κ°€λŠ” 건 μ–΄λ– μ„Έμš”? /compact` while the work is still going |
69
+ With the mod display (the default):
70
+
71
+ | Situation | Bottom row | Above the prompt |
72
+ |---|---|---|
73
+ | Under 250k, or no judgment (no key, Jev unreachable) | `52k +12k` | |
74
+ | Work in progress | `🟒 312k +38k` | |
75
+ | A whole stage closed (from 250k) | `312k +38k` | `🟑 μƒˆλ‘­κ²Œ μ‹œμž‘ν•˜λŠ” 건 μ–΄λ– μ„Έμš”?` and a `/clear` button |
76
+ | Work finished, stage goes on (from 250k) | `312k +38k` | `🟑 μ§€κΈˆκΉŒμ§€ μ •λ¦¬ν•˜κ³  μ΄μ–΄κ°€λŠ” 건 μ–΄λ– μ„Έμš”?` and a `/compact` button |
77
+ | Within 20% of auto-compact, with one of the two above | `790k +38k` | `πŸ”΄ 18%`, the advice and its button |
78
+ | Within 20% of auto-compact otherwise | `πŸ”΄ 790k +38k 18%`, then ` Β· μž‘μ—…μ΄ λλ‚˜λ©΄ μ •λ¦¬ν•˜κ³  μ΄μ–΄κ°€λŠ” 건 μ–΄λ– μ„Έμš”? /compact` while the work is still going | |
79
+
80
+ `+38k` is how much the conversation grew in the last request, counted from when it was sent. It is left out when the conversation did not grow, for example after a `/compact`. The `statusline` and `message` displays show the whole advice on one line instead, without the increase: `🟑 312k μƒˆλ‘­κ²Œ μ‹œμž‘ν•˜λŠ” 건 μ–΄λ– μ„Έμš”? /clear` and so on.
81
+
82
+ The button runs `/compact` or `/clear` at once; a `/clear` can be undone with `/resume`. Click it, press `ctrl+x ctrl+f`, or press `ctrl+x tab` and then Enter. It is not drawn while a request runs or while Claude Code waits for your answer to a question, and once pressed it stays away until Jev judges a newer reply. A refused `/compact` (too few messages, for example) shows the reason in a toast.
83
+
84
+ `install` writes the shortcut to `~/.claude/keybindings.json` as `"ctrl+x ctrl+f": "diff:back"` in the `DiffDialog` block. Claude Code lets a mod's button take the key of one of its own actions while that action is not in use; `diff:back` has no key of its own and works only inside the diff dialog, where `ctrl+x ctrl+f` keeps doing that. If `ctrl+x ctrl+f` is already bound in your file, or the file cannot be read, `install` leaves the file alone and says so, and the button is pressed with a click or `ctrl+x tab`. Both keys are pressed with `ctrl` on purpose: with a Korean or other input method on, a plain letter after `ctrl+x` arrives as another character and the chord would not match. `uninstall context` and switching to another display take the line out again if it is still ours. To keep `install` from binding it, set `"ctrl+x ctrl+f": null` in any block of that file.
72
85
 
73
86
  With `--lang en` the advice reads `Start fresh? /clear`, `Wrap up what you have and continue? /compact` and `When this work is done, wrap up and continue? /compact`.
74
87
 
@@ -76,7 +89,7 @@ Judging starts at 250k because a conversation passes 100k after a request or two
76
89
 
77
90
  | `--display` | Where |
78
91
  |---|---|
79
- | `mod` (default) | At the end of the bottom row, after `⏡⏡ … mode on`. A small Claude Code mod in the package's `mod/` folder draws it. The mod is listed in `env.CLAUDE_CODE_PLUGIN_DIRS` and told the data folder through `pluginConfigs`. |
92
+ | `mod` (default) | At the end of the bottom row, after `⏡⏡ … mode on`, and advice that can be acted on in a band above the prompt with a button. A small Claude Code mod in the package's `mod/` folder draws both. The mod is listed in `env.CLAUDE_CODE_PLUGIN_DIRS` and told the data folder through `pluginConfigs`. |
80
93
  | `statusline` | Claude Code's status line, the row above the bottom row. An existing status line of yours keeps running first, with our text after it, and is put back when you switch away or uninstall. On Windows that command runs in Git Bash when it is installed and in PowerShell otherwise, as Claude Code runs it; it gets 2 seconds. No red zone, because the auto-compact threshold is not known there. |
81
94
  | `message` | A `Stop says: …` line in the transcript when there is advice. Claude does not see it. No red zone. |
82
95
 
@@ -84,7 +97,11 @@ Judging starts at 250k because a conversation passes 100k after a request or two
84
97
 
85
98
  ## The rm helper
86
99
 
87
- It runs before every Bash tool call (`PreToolUse`, matcher `Bash`, 15-second timeout) and looks only at `rm`, `rmdir` and `xargs`.
100
+ It runs before every Bash and PowerShell tool call (`PreToolUse`, matcher `Bash|PowerShell`, 15-second timeout) and looks at:
101
+
102
+ - Bash: `rm`, `rmdir` and `xargs`
103
+ - PowerShell: `Remove-Item` and its aliases `ri`, `rm`, `del`, `erase`, `rd` and `rmdir`, and `[System.IO.File]::Delete` and `[System.IO.Directory]::Delete`. PowerShell's own parser and parameter binder read the command, so aliases, shortened parameter names, positional paths and nested blocks count as PowerShell reads them. PowerShell is started only when the command holds one of these words or a shell name, and takes about 0.3 seconds.
104
+ - shells started inside a command, up to three levels deep: `sh -c` and `bash -c`, `powershell -Command`, `pwsh -c` and `-EncodedCommand`, and `del`, `erase`, `rd` and `rmdir` in `cmd /c`
88
105
 
89
106
  | Target | Result |
90
107
  |---|---|
@@ -92,23 +109,30 @@ It runs before every Bash tool call (`PreToolUse`, matcher `Bash`, 15-second tim
92
109
  | A path with a `.superpowers` folder in it | No decision |
93
110
  | A path that does not exist | No decision |
94
111
  | A git-ignored path inside a build folder (`target`, `build`, `dist`, `out`, `node_modules`, `coverage`, `__pycache__`, `.pytest_cache`, `.gradle`, `.next`, `.nuxt`, `.turbo`, `.cache`, `bin`, `obj`) | No decision |
112
+ | A PowerShell path on a drive that is not a file system (`Env:`, `Alias:`, `Function:`, `Variable:`, `HKCU:`, `HKLM:`, `Cert:`, `WSMan:`, `Registry::`) | No decision |
113
+ | `Remove-Item … -WhatIf` | No decision |
114
+ | A network path (`\\server\share\…`) | `ask`, without looking the path up |
95
115
  | Any other existing file or folder | `ask`, with the reason `μ‹€μ œ 파일 μ‚­μ œ: <paths>` ("deleting real files"), unless Jev lifts it (below) |
116
+ | A PowerShell command its parser cannot read (a syntax error, PowerShell not answering within 3 seconds, a nested PowerShell command left when the hook has spent 9 seconds reading, an answer it does not expect), or one that deletes and runs code it cannot follow (`& $name`, `Invoke-Expression`, `Start-Process` or `Set-Alias` with an argument it cannot work out, `[scriptblock]::Create`, `.Invoke()`, a `Delete()` method in a command that gets file objects from `Get-Item`, `Get-ChildItem`, `New-Item` or `-PassThru`), or makes a drive with `New-PSDrive` | `ask`, with the reason `μ‚­μ œ λͺ…령을 λΆ„μ„ν•˜μ§€ λͺ»ν•¨: <start of the command>` ("could not read the delete command"). Jev is not asked. |
96
117
  | A target it cannot work out | `deny`, with a hint to rewrite the command using literal paths |
97
118
 
98
119
  A target cannot be worked out when it uses:
99
120
 
100
- - shell variables, other than literal assignments in the same command and `TEMP`, `TMP`, `TMPDIR`, `HOME`, `USERPROFILE` and `PWD`
101
- - command substitution
102
- - `xargs` feeding `rm`
121
+ - in Bash, shell variables other than literal assignments in the same command and `TEMP`, `TMP`, `TMPDIR`, `HOME`, `USERPROFILE` and `PWD`; in PowerShell, variables other than one plain top-level assignment in the same command (a variable written any other way, such as `+=`, a loop, a function parameter, `Set-Variable`, `$script:`, `-OutVariable`, or its name handed to a command as text, is unknown), `$env:TEMP`, `$env:TMP`, `$env:TMPDIR`, `$env:HOME`, `$env:USERPROFILE`, `$HOME` and `$PWD` (unless the command assigns it); in `cmd`, variables other than `%TEMP%`, `%TMP%`, `%USERPROFILE%` and `%CD%`
122
+ - command substitution, or in PowerShell any expression such as `(Join-Path …)`, `$(…)` or `@splat`
123
+ - `xargs` feeding `rm` or a shell that deletes, PowerShell pipeline input feeding `Remove-Item` (`Get-ChildItem … | Remove-Item`), or a shell given no script of its own, which reads one from a pipe, a heredoc or a here-string (`… | bash`, `bash <<EOF`, `powershell -`), in a command that holds a delete word
103
124
  - brace expansion
104
125
  - a wildcard in a folder name
105
- - a `cd` to such a path earlier in the command
126
+ - a `cd`, `pushd`, `Set-Location` or `Push-Location` to such a path earlier in the command, a `popd` or `Pop-Location`, or a location change inside a PowerShell block; in PowerShell also a relative path inside a loop, a function or a script block when the command changes location anywhere
127
+ - a PowerShell drive other than a drive letter and the non-file drives above, such as one made with `New-PSDrive`
128
+ - a nested shell whose script is not fixed text and holds a delete word, or shells nested more than three deep that delete
129
+ - in `cmd`, a delete on a line that uses `if`, `else`, `for`, `call`, `start` or unquoted parentheses, or starts a command with a name it cannot read: write plain `del` or `rd` lines instead, with names that hold parentheses in double quotes
106
130
 
107
131
  It does not see deletions made any other way:
108
132
 
109
- - through the PowerShell tool (`Remove-Item` and its aliases). On Windows with Git Bash installed, Claude Code turns this tool on by default for claude.ai and Console accounts and uses PowerShell as its main shell, so many deletions go through it.
110
- - through a nested shell: `sh -c`, `bash -c`, `powershell -Command`, `pwsh -c`, `cmd /c del`
111
- - with other commands or programs, such as `find -delete`, `git clean` or a script that deletes files
133
+ - in PowerShell, `Remove-ItemProperty`, `Clear-RecycleBin`, an object's `Delete()` in a command that gets no file objects, COM file objects (`Scripting.FileSystemObject`'s `DeleteFile` and `DeleteFolder`), provider methods such as `$ExecutionContext.InvokeProvider.Item.Remove`, and code that builds a command's name or text from pieces while it runs (`[char]` codes, joined strings); the reader is not a sandbox
134
+ - script files: `powershell -File`, `pwsh script.ps1`, `bash script.sh`, a `.bat` file
135
+ - other commands or programs, such as `find -delete`, `git clean`, or Node or Python code that deletes files
112
136
 
113
137
  What its decisions do depends on Claude Code's permission mode:
114
138
 
@@ -124,7 +148,7 @@ The facts are checked by code; Jev only judges what the target is for. Jev is as
124
148
 
125
149
  | Target | Checked first | Jev is asked |
126
150
  |---|---|---|
127
- | A file or folder this session made | Not tracked by git; the first call of this session that names it created it: a Write that made a new file, or a shell command whose `>` redirect, `touch`, `mkdir` or `curl -o` makes it (deletes do not count, and a Read, an Edit or any other shell command first means it was already there); made after the session started; for a folder, every file inside too, and at most 50 files | Is it a throwaway made only to try something out? |
151
+ | A file or folder this session made | Not tracked by git; the first call of this session that names it created it: a Write that made a new file, or a shell command whose `>` redirect, `touch`, `mkdir` or `curl -o` makes it (deletes do not count, and a Read, an Edit or any other shell command first means it was already there; PowerShell's `New-Item`, `Set-Content` and `Out-File` are not recognized yet, so a file made with them keeps the ask); a folder holding a git repository never counts; made after the session started; for a folder, every file inside too, and at most 50 files | Is it a throwaway made only to try something out? |
128
152
  | A folder git ignores, outside the build folders above | It is a folder (a single ignored file such as `.env` still asks) | Is it generated output or a cache that is made again? |
129
153
 
130
154
  When Jev answers 0.8 or more for every target, the hook makes no decision (the last column of the table above), and a line like `[jev-advisor] Jevκ°€ 이 μ„Έμ…˜μ˜ μ‹œν—˜ 파일둜 νŒλ‹¨ν•΄ 묻지 μ•Šκ³  μ§€μ›λ‹ˆλ‹€: out.json (0.93)` is shown. Otherwise the ask stays, with Jev's answer added: `μ‹€μ œ 파일 μ‚­μ œ: …\out.json Β· Jev: μ‹œν—˜μš© 파일일 ν™•λ₯  0.42`. Without a key, when Jev fails, or with `"jev": false`, every real file asks as before. A `deny` is never sent to Jev.
@@ -152,10 +176,12 @@ A key saved by `install` or `key` stays in `~/.claude/claude-jev-advisor/jev-key
152
176
  |---|---|
153
177
  | `~/.claude/claude-jev-advisor/config.json` | Switches and settings that differ from the defaults. A missing or broken file reads as the defaults. A value of the wrong type falls back to its default, so only `"enabled": false` turns a helper off. |
154
178
  | `~/.claude/claude-jev-advisor/state/<session>.json` | The last judgment of each open session, read by the display. Removed when the session ends. |
155
- | `~/.claude/claude-jev-advisor/log/YYYY-MM.jsonl` | One line per context judgment and per `rm` Jev check: the size or the command, what was sent to Jev (parts of your conversation), the answers and the result. Never the key. |
179
+ | `~/.claude/claude-jev-advisor/log/YYYY-MM.jsonl` | One line per context judgment and per `rm` Jev check: the size, or the tool (`Bash` or `PowerShell`) and the command, what was sent to Jev (parts of your conversation), the answers and the result. Never the key. |
156
180
  | `~/.claude/claude-jev-advisor/statusline-before.json` | Your own status line while `--display statusline` is in use |
157
181
  | `~/.claude/claude-jev-advisor/jev-key.env` | Your TypeSafe API key, when you typed it in `install` or `key` |
158
182
  | `~/.claude/backups/settings.json.*-before-claude-jev-advisor` | Copies of `settings.json` from before each change |
183
+ | `~/.claude/keybindings.json` | The `ctrl+x ctrl+f` line, with the `mod` display |
184
+ | `~/.claude/backups/keybindings.json.*-before-claude-jev-advisor` | Copies of `keybindings.json` from before each change |
159
185
 
160
186
  Defaults:
161
187
 
@@ -164,12 +190,13 @@ Defaults:
164
190
  "lang": "ko",
165
191
  "keyFile": null,
166
192
  "display": "mod",
193
+ "shortcut": null,
167
194
  "context": { "enabled": true, "minTokens": 250000, "compactMinTokens": 250000, "redRemainingPct": 20, "unitDoneYes": 0.6, "phaseDoneYes": 0.6 },
168
195
  "rm": { "enabled": true, "jev": true, "throwawayYes": 0.8, "maxDirFiles": 50 }
169
196
  }
170
197
  ```
171
198
 
172
- `minTokens` is where judging starts, `compactMinTokens` where `/compact` is suggested, `redRemainingPct` where the red zone starts, and `unitDoneYes` / `phaseDoneYes` are the Jev probabilities needed for "work finished" (`/compact`) and "stage closed" (`/clear`). For `rm`, `jev` switches the Jev check, `throwawayYes` is the probability needed to lift an ask, and `maxDirFiles` the most files a folder of this session may hold.
199
+ `minTokens` is where judging starts, `compactMinTokens` where `/compact` is suggested, `redRemainingPct` where the red zone starts, and `unitDoneYes` / `phaseDoneYes` are the Jev probabilities needed for "work finished" (`/compact`) and "stage closed" (`/clear`). For `rm`, `jev` switches the Jev check, `throwawayYes` is the probability needed to lift an ask, and `maxDirFiles` the most files a folder of this session may hold. `shortcut` is set by `install`: the key it bound, or `null` when it bound none.
173
200
 
174
201
  `config.json` keeps only the values you changed, with `"version": 2`. A config written by 0.1.x, which saved every value, has its old default thresholds (`minTokens` 100000, `compactMinTokens` 200000, `unitDoneYes` 0.7) read as unset, so the new defaults apply.
175
202