feat: add hooks and rules

This commit is contained in:
duthaho
2026-04-19 12:11:56 +07:00
parent 5d87f8c1f3
commit 3103a8da1b
9 changed files with 233 additions and 8 deletions
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env node
/**
* Notification hook: cross-platform desktop notification.
* Supports macOS (osascript), Linux (notify-send), and Windows (PowerShell).
* Fails open — notification errors are silently ignored.
*/
"use strict";
const { execSync } = require("child_process");
const os = require("os");
function notify(title, message) {
const platform = os.platform();
const commands = {
darwin: `osascript -e 'display notification "${message}" with title "${title}"'`,
linux: `notify-send "${title}" "${message}"`,
win32: `powershell.exe -Command "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('${message}', '${title}', 'OK', 'Information')"`,
};
const cmd = commands[platform];
if (cmd) {
execSync(cmd, { stdio: "ignore", timeout: 5000 });
}
}
async function main() {
try {
let data = "";
for await (const chunk of process.stdin) data += chunk;
const input = JSON.parse(data);
const message = input?.message ?? "Needs your attention";
notify("Claude Code", message);
} catch {
// Fail open — notification errors should never block work
}
}
main();