mirror of
https://github.com/JuliusBrussee/caveman.git
synced 2026-08-11 13:21:09 +02:00
fix: detect natural language activation/deactivation in mode tracker
README tells users they can say "talk like caveman" to activate, but the UserPromptSubmit hook only matched /caveman commands. This meant the flag file and statusline badge stayed out of sync when users activated via natural language — the model would speak caveman (it reads the prompt) but the hook never wrote the flag file. Now matches: "activate caveman", "turn on caveman mode", "talk like caveman", "disable caveman", "turn off caveman", etc. Uses a negative guard so "stop caveman" doesn't trigger activation first. Uses getDefaultMode() for natural language activation to respect CAVEMAN_DEFAULT_MODE and config.json, same as /caveman command. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
600e8efcd6
commit
56f4047ab3
@@ -16,6 +16,17 @@ process.stdin.on('end', () => {
|
||||
const data = JSON.parse(input);
|
||||
const prompt = (data.prompt || '').trim().toLowerCase();
|
||||
|
||||
// Natural language activation (e.g. "activate caveman", "turn on caveman mode",
|
||||
// "talk like caveman"). README tells users they can say these, but the hook
|
||||
// only matched /caveman commands — flag file and statusline stayed out of sync.
|
||||
if (/\b(activate|enable|turn on|start|talk like)\b.*\bcaveman\b/i.test(prompt) ||
|
||||
/\bcaveman\b.*\b(mode|activate|enable|turn on|start)\b/i.test(prompt)) {
|
||||
if (!/\b(stop|disable|turn off|deactivate)\b/i.test(prompt)) {
|
||||
fs.mkdirSync(path.dirname(flagPath), { recursive: true });
|
||||
fs.writeFileSync(flagPath, getDefaultMode());
|
||||
}
|
||||
}
|
||||
|
||||
// Match /caveman commands
|
||||
if (prompt.startsWith('/caveman')) {
|
||||
const parts = prompt.split(/\s+/);
|
||||
@@ -47,8 +58,10 @@ process.stdin.on('end', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// Detect deactivation
|
||||
if (/\b(stop caveman|normal mode)\b/i.test(prompt)) {
|
||||
// Detect deactivation — natural language and slash commands
|
||||
if (/\b(stop|disable|deactivate|turn off)\b.*\bcaveman\b/i.test(prompt) ||
|
||||
/\bcaveman\b.*\b(stop|disable|deactivate|turn off)\b/i.test(prompt) ||
|
||||
/\bnormal mode\b/i.test(prompt)) {
|
||||
try { fs.unlinkSync(flagPath); } catch (e) {}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user