@delt/claude-jev-advisor 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 delt96
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # claude-jev-advisor
2
+
3
+ Unofficial helpers for [Claude Code](https://claude.com/claude-code), installed as command hooks in `~/.claude/settings.json`. They use [TypeSafe](https://typesafe.ai) Jev for judgments that need to understand the conversation.
4
+
5
+ The `context` helper sends parts of your conversation to TypeSafe's Jev API (`api.typesafe.ai`): your last three requests, each cut to its first 1,000 characters, and Claude's last reply, cut to its first and last 1,500 characters. The `rm` helper sends nothing.
6
+
7
+ Not affiliated with Anthropic or TypeSafe.
8
+
9
+ | Helper | What it does | Systems |
10
+ |---|---|---|
11
+ | `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 |
12
+ | `rm` | Asks before a Bash `rm` deletes real files. Lets temp files through and refuses an `rm` whose targets it cannot work out. | Windows |
13
+
14
+ ## Requirements
15
+
16
+ - Node.js 18 or later
17
+ - Claude Code (the bottom-row display uses Claude Code mods, an early-access feature that may change between releases)
18
+ - A TypeSafe API key for the `context` helper, in `TYPESAFE_API_KEY` or in a key file (`--key-file`)
19
+ - Windows for the `rm` helper. On other systems `install` skips it and says why.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ npm i -g @delt/claude-jev-advisor
25
+ ```
26
+
27
+ Then register the hooks:
28
+
29
+ ```bash
30
+ claude-jev-advisor install --key-file C:/path/to/jev-key.env
31
+ ```
32
+
33
+ The key file holds a line `TYPESAFE_API_KEY=...`. Only its path is saved, never the key.
34
+
35
+ 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.
36
+
37
+ 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.
38
+
39
+ ## Commands
40
+
41
+ | Command | What it does |
42
+ |---|---|
43
+ | `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 |
44
+ | `claude-jev-advisor uninstall [rm] [context]` | Removes this package's hooks and display from `settings.json` |
45
+ | `claude-jev-advisor on [rm] [context]` / `off [rm] [context]` | Switches helpers on or off without touching `settings.json` |
46
+ | `claude-jev-advisor status` | Shows what is registered and on, the display, whether a key is set, the thresholds and the last judgment |
47
+ | `claude-jev-advisor help` | Prints the usage |
48
+
49
+ If you leave out the helper names, the command applies to all helpers. The display is set up when `context` is installed; run `claude-jev-advisor install context --display <mode>` to switch it.
50
+
51
+ ## The context helper
52
+
53
+ When a turn ends, a `Stop` hook reads the size of the conversation from the session transcript. From 100k tokens it asks Jev two questions about the last three requests and the last reply:
54
+
55
+ - has the work asked for reached a natural stopping point?
56
+ - is the goal behind it finished, with nothing left to do next?
57
+
58
+ 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.
59
+
60
+ | Situation | Shown |
61
+ |---|---|
62
+ | Under 100k, or no judgment (no key, Jev unreachable) | `52k` |
63
+ | Work in progress | `🟒 312k` |
64
+ | Goal finished (from 100k) | `🟑 312k μƒˆλ‘­κ²Œ μ‹œμž‘ν•˜λŠ” 건 μ–΄λ– μ„Έμš”? /clear` |
65
+ | Work unit finished (from 200k) | `🟑 312k μ§€κΈˆκΉŒμ§€ μ •λ¦¬ν•˜κ³  μ΄μ–΄κ°€λŠ” 건 μ–΄λ– μ„Έμš”? /compact` |
66
+ | Work unit finished, under 200k | `🟒 150k` |
67
+ | Within 20% of auto-compact | `πŸ”΄ 790k 18%`, then ` Β· ` and the `/clear` or `/compact` advice above, or `μž‘μ—…μ΄ λλ‚˜λ©΄ μ •λ¦¬ν•˜κ³  μ΄μ–΄κ°€λŠ” 건 μ–΄λ– μ„Έμš”? /compact` while the work is still going |
68
+
69
+ 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`.
70
+
71
+ `/clear` is suggested only when Jev is confident the goal is finished; when in doubt it suggests `/compact`. `/compact` waits until 200k because compacting a smaller conversation costs more than it saves. The suggestion is hidden while a new request runs, and a judgment made before a `/compact` is dropped.
72
+
73
+ | `--display` | Where |
74
+ |---|---|
75
+ | `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`. |
76
+ | `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 is run through `cmd.exe`, so a status line that needs bash may not show. No red zone, because the auto-compact threshold is not known there. |
77
+ | `message` | A `Stop says: …` line in the transcript when there is advice. Claude does not see it. No red zone. |
78
+
79
+ ## The rm helper
80
+
81
+ It runs before every Bash tool call (`PreToolUse`, matcher `Bash`, 15-second timeout) and looks only at `rm`, `rmdir` and `xargs`.
82
+
83
+ | Target | Result |
84
+ |---|---|
85
+ | Inside `%TEMP%`/`%TMP%` or `/tmp` | No decision. Claude Code's normal permission handling applies. |
86
+ | A path with a `.superpowers` folder in it | No decision |
87
+ | A path that does not exist | No decision |
88
+ | 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 |
89
+ | Any other existing file or folder | `ask`, with the reason `μ‹€μ œ 파일 μ‚­μ œ: <paths>` ("deleting real files") |
90
+ | A target it cannot work out | `deny`, with a hint to rewrite the command using literal paths |
91
+
92
+ A target cannot be worked out when it uses:
93
+
94
+ - shell variables, other than literal assignments in the same command and `TEMP`, `TMP`, `TMPDIR`, `HOME`, `USERPROFILE` and `PWD`
95
+ - command substitution
96
+ - `xargs` feeding `rm`
97
+ - brace expansion
98
+ - a wildcard in a folder name
99
+ - a `cd` to such a path earlier in the command
100
+
101
+ `install rm` also replaces an older personal hook at `~/.claude/hooks/rm-guard/rm-guard.mjs` if one is registered. Its files are left in place.
102
+
103
+ If a hook of this package fails in any way, it prints nothing and exits 0, so it never blocks Claude Code.
104
+
105
+ ## Uninstall
106
+
107
+ npm does not run uninstall scripts, so remove the hooks before removing the package:
108
+
109
+ ```bash
110
+ claude-jev-advisor uninstall
111
+ npm rm -g @delt/claude-jev-advisor
112
+ ```
113
+
114
+ If the package is removed first, the hook entries point to a missing file. Claude Code keeps running, but the helpers are off. To clean up, reinstall the package and run `claude-jev-advisor uninstall`, or delete the entries from `settings.json` by hand.
115
+
116
+ ## Files
117
+
118
+ | Path | Contents |
119
+ |---|---|
120
+ | `~/.claude/claude-jev-advisor/config.json` | Switches and settings. 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. |
121
+ | `~/.claude/claude-jev-advisor/state/<session>.json` | The last judgment of each open session, read by the display. Removed when the session ends. |
122
+ | `~/.claude/claude-jev-advisor/log/YYYY-MM.jsonl` | One line per judgment: the size, what was sent to Jev (parts of your conversation), the answers and the result. Never the key. |
123
+ | `~/.claude/claude-jev-advisor/statusline-before.json` | Your own status line while `--display statusline` is in use |
124
+ | `~/.claude/backups/settings.json.*-before-claude-jev-advisor` | Copies of `settings.json` from before each change |
125
+
126
+ Default config:
127
+
128
+ ```json
129
+ {
130
+ "lang": "ko",
131
+ "keyFile": null,
132
+ "display": "mod",
133
+ "context": { "enabled": true, "minTokens": 100000, "compactMinTokens": 200000, "redRemainingPct": 20, "unitDoneYes": 0.7, "goalDoneYes": 0.8 },
134
+ "rm": { "enabled": true, "jev": true, "throwawayYes": 0.8, "maxDirFiles": 50 }
135
+ }
136
+ ```
137
+
138
+ `minTokens` is where judging starts, `compactMinTokens` where `/compact` is suggested, `redRemainingPct` where the red zone starts, and `unitDoneYes` / `goalDoneYes` are the Jev probabilities needed for "unit finished" and "goal finished". The `rm` settings other than `enabled` are reserved for a later version.
139
+
140
+ ## Development
141
+
142
+ ```bash
143
+ git clone https://github.com/delt96/claude-jev-advisor.git
144
+ cd claude-jev-advisor
145
+ npm ci
146
+ npm test # node:test via tsx; tests use temporary home folders and never call Jev
147
+ npm run typecheck
148
+ npm run build # dist/*.js and mod/hooks/register.js
149
+ ```
150
+
151
+ ## License
152
+
153
+ MIT