mirror of
https://github.com/JuliusBrussee/caveman.git
synced 2026-08-11 13:21:09 +02:00
Use UserPromptSubmit for caveman mode tracking
Switch caveman mode tracking from PostToolUse to UserPromptSubmit: update README to document the new hook, adjust caveman-mode-tracker.js to read the incoming `prompt` field (removing `user_prompt`), and modify install.sh to register the UserPromptSubmit hook with timeouts and status messages (and add a timeout/status for the activate hook). This ensures mode detection runs on every user prompt and prevents hook stalls by setting command timeouts and status text. Files changed: hooks/README.md, hooks/caveman-mode-tracker.js, hooks/install.sh.
This commit is contained in:
+4
-4
@@ -18,10 +18,10 @@ Or from a cloned repo: `bash hooks/install.sh`
|
||||
- Writes `full` to `~/.claude/.caveman-active` (flag file)
|
||||
- Emits caveman rules as hidden SessionStart context
|
||||
|
||||
### `caveman-mode-tracker.js` — PostToolUse hook
|
||||
### `caveman-mode-tracker.js` — UserPromptSubmit hook
|
||||
|
||||
- Fires after any Skill tool invocation
|
||||
- Detects caveman-related skills and writes the active mode to the flag file
|
||||
- Fires on every user prompt, checks for `/caveman` commands
|
||||
- Writes the active mode to the flag file when a caveman command is detected
|
||||
- Supports: `full`, `lite`, `ultra`, `wenyan`, `wenyan-lite`, `wenyan-ultra`, `commit`, `review`, `compress`
|
||||
|
||||
## Statusline Badge
|
||||
@@ -52,7 +52,7 @@ Badge examples:
|
||||
## How It Works
|
||||
|
||||
```
|
||||
SessionStart hook ──writes "full"──▶ ~/.claude/.caveman-active ◀──writes mode── PostToolUse hook
|
||||
SessionStart hook ──writes "full"──▶ ~/.claude/.caveman-active ◀──writes mode── UserPromptSubmit hook
|
||||
│
|
||||
reads
|
||||
▼
|
||||
|
||||
@@ -13,7 +13,7 @@ process.stdin.on('data', chunk => { input += chunk; });
|
||||
process.stdin.on('end', () => {
|
||||
try {
|
||||
const data = JSON.parse(input);
|
||||
const prompt = (data.user_prompt || data.prompt || '').trim().toLowerCase();
|
||||
const prompt = (data.prompt || '').trim().toLowerCase();
|
||||
|
||||
// Match /caveman commands
|
||||
if (prompt.startsWith('/caveman')) {
|
||||
|
||||
+5
-2
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
# caveman — one-command hook installer for Claude Code
|
||||
# Installs: SessionStart hook (auto-load rules) + PostToolUse hook (mode tracking)
|
||||
# Installs: SessionStart hook (auto-load rules) + UserPromptSubmit hook (mode tracking)
|
||||
# Usage: bash hooks/install.sh
|
||||
# or: bash <(curl -s https://raw.githubusercontent.com/JuliusBrussee/caveman/main/hooks/install.sh)
|
||||
set -e
|
||||
@@ -50,6 +50,7 @@ node -e "
|
||||
hooks: [{
|
||||
type: 'command',
|
||||
command: 'node $HOOKS_DIR/caveman-activate.js',
|
||||
timeout: 5,
|
||||
statusMessage: 'Loading caveman mode...'
|
||||
}]
|
||||
});
|
||||
@@ -64,7 +65,9 @@ node -e "
|
||||
settings.hooks.UserPromptSubmit.push({
|
||||
hooks: [{
|
||||
type: 'command',
|
||||
command: 'node $HOOKS_DIR/caveman-mode-tracker.js'
|
||||
command: 'node $HOOKS_DIR/caveman-mode-tracker.js',
|
||||
timeout: 5,
|
||||
statusMessage: 'Tracking caveman mode...'
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user