compact-adviser
Reviewed
at commit 37fa1a6
Sends data to TypeSafe Jev (api.typesafe.ai), only when you set a TypeSafe key
Suggests (or, opt-in, runs) /compact at a completed checkpoint, judged by TypeSafe Jev. Its hooks module activates only when CLAUDE_CODE_ENABLE_FUNCTION_HOOKS…
0 upvotes
Log in to upvote or save- Made by
- Kun Chen
- Pinned commit
-
37fa1a665b8933de68c90014312060e862cf121a - What we checked
-
After a finished answer in a long session, sends a trimmed, redacted excerpt of the conversation (your messages, Claude's latest replies, tool output snippets) to TypeSafe's Jev service, which judges whether it is a good moment to compact; if so a status-line hint appears. Automatic compaction is opt-in with a confirmation. Its TypeSafe key comes from the environment, settings or the project's .env.
Review details
Static review of the source at the pinned commit; not run. Every handler first checks that CLAUDE_CODE_ENABLE_FUNCTION_HOOKS is exactly 1 and COMPACT_ADVISER_DISABLE is not truthy, otherwise it passes through. Hooks: session.start (registers /compact-adviser, prunes its own session records older than 30 days), prompt.submit, command.run and turn.start (only track whether another prompt or command interrupts a pending before-compact turn), turn.complete (on a settled main-agent answer above the 40,000-token minimum and outside cooldowns, schedules a judgment), session.compact (resets cooldowns), command.run for /compact-adviser, config.describe (hides the saved key row from /config), ui.close and ui.render (the settings pane). The judgment reads $.session.messages() and builds a snapshot capped at 32,000 bytes: user messages (8,000 bytes), the last 64 assistant messages with tool excerpts of at most 512 bytes, the prior compaction summary and up to 8 written file paths; it redacts private keys, sk-/gh tokens, Bearer values, *_API_KEY/TOKEN/SECRET/PASSWORD assignments and the TypeSafe key, and skips excerpts of .env, auth.json, id_rsa/id_ed25519, .pem and .key files. It POSTs that with the key as a Bearer header through $.http.fetch to https://api.typesafe.ai/v1/systemone (or an https/loopback TYPESAFE_BASE from the launch environment; COMPACT_ADVISER_TEST_ENDPOINT accepts only http://127.0.0.1), with a 2 s timeout and exponential backoff; errors never count as a positive judgment. The key comes from TYPESAFE_API_KEY, else a hidden userConfig row saved through $.config.set (stored in the user's Claude Code settings), else a TYPESAFE_API_KEY line parsed from .env in the working directory via $.fs.read; only that variable is extracted. Hint mode only calls $.ui.status. Auto mode needs a $.ui.ask confirmation stored in $.store and then calls $.session.compact with fixed instructions between turns. An optional beforeCompactPrompt userConfig setting (empty by default, only used in confirmed auto mode) that the user writes themselves is submitted with $.prompt.submit, or run with $.command.run when it starts with /, and compaction follows only if that turn ends cleanly within 5 minutes. A TypeSafe HTTP 402 response is reported as a billing error. Optional logRequests (off by default, disclosed in the manifest) appends the redacted request bodies and verdicts to ~/.claude/compact-adviser-requests-<session-id>.jsonl through $.fs.read/$.fs.write; the key is not logged. Other runtime calls: $.store.get/set/delete/keys, $.config.list, $.session.id/cwd/usage, $.ui.toast/log/open/close/focus/panes/invalidate, $.clock.after/sleep/now, crypto.subtle for a checkpoint fingerprint. No npm runtime dependencies. hooks.json, register.ts and the lib files that do network, file access, environment and settings (judge, env, log, config, snapshot redaction) were read in full or checked line by line against the previous review; the remaining lib files (profile, state, disable) were checked by targeted search; the development scripts under scripts/ (plugin-types, validate, check-readme, plugin-test, live-e2e, common) and the repository-level generate-package-readme.mjs are not loaded by the plugin and were checked by targeted search only (they spawn the claude CLI and tmux in throwaway directories for testing).
- What it uses
-
- Reads your prompts: yes
- Sees tool calls: yes
- Blocks or changes tool calls: no
- Reads or writes files: yes
- Runs programs on your machine: no
- Calls the model (uses tokens): no
- Sends data over the network: yes
- Stores data: yes
- Shows something on screen: yes
Suggests (or, opt-in, runs) /compact at a completed checkpoint, judged by TypeSafe Jev. Its hooks module activates only when CLAUDE_CODE_ENABLE_FUNCTION_HOOKS is exactly 1 and is otherwise a complete no-op.
Made this mod? Add a badge to your README
Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.
[](https://modsforclaude.com/mods/compact-adviser/)