feat: full plugin integration + cross-agent rules
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env node
|
||||
// ponytail — UserPromptSubmit hook to track which ponytail mode is active
|
||||
// Inspects user input for /ponytail commands and writes mode to flag file
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const { getDefaultMode } = require('./ponytail-config');
|
||||
|
||||
const flagPath = path.join(os.homedir(), '.claude', '.ponytail-active');
|
||||
|
||||
let input = '';
|
||||
process.stdin.on('data', chunk => { input += chunk; });
|
||||
process.stdin.on('end', () => {
|
||||
try {
|
||||
// Strip UTF-8 BOM some shells prepend when piping (breaks JSON.parse)
|
||||
const data = JSON.parse(input.replace(/^\uFEFF/, ''));
|
||||
const prompt = (data.prompt || '').trim().toLowerCase();
|
||||
|
||||
// Match /ponytail commands
|
||||
if (prompt.startsWith('/ponytail')) {
|
||||
const parts = prompt.split(/\s+/);
|
||||
const cmd = parts[0]; // /ponytail, /ponytail-review, /ponytail:ponytail, etc.
|
||||
const arg = parts[1] || '';
|
||||
|
||||
let mode = null;
|
||||
|
||||
if (cmd === '/ponytail-review' || cmd === '/ponytail:ponytail-review') {
|
||||
mode = 'review';
|
||||
} else if (cmd === '/ponytail' || cmd === '/ponytail:ponytail') {
|
||||
if (arg === 'lite') mode = 'lite';
|
||||
else if (arg === 'full') mode = 'full';
|
||||
else if (arg === 'ultra') mode = 'ultra';
|
||||
else if (arg === 'off') mode = 'off';
|
||||
else mode = getDefaultMode();
|
||||
}
|
||||
|
||||
if (mode && mode !== 'off') {
|
||||
fs.mkdirSync(path.dirname(flagPath), { recursive: true });
|
||||
fs.writeFileSync(flagPath, mode);
|
||||
} else if (mode === 'off') {
|
||||
try { fs.unlinkSync(flagPath); } catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
// Detect deactivation
|
||||
if (/\b(stop ponytail|normal mode)\b/i.test(prompt)) {
|
||||
try { fs.unlinkSync(flagPath); } catch (e) {}
|
||||
}
|
||||
} catch (e) {
|
||||
// Silent fail
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user