mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
refactor: rename Tool.alpha to Tool.experimental
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
const fs = require("node:fs");
|
||||
const input = JSON.parse(fs.readFileSync("/dev/stdin", "utf8"));
|
||||
const cmd = input.tool_input?.command || "";
|
||||
|
||||
const devPattern = /\b(pnpm|npm|yarn|bun)\s+(run\s+)?dev\b/;
|
||||
|
||||
if (devPattern.test(cmd) && !/tmux/.test(cmd) && !/&\s*$/.test(cmd)) {
|
||||
console.log(
|
||||
"TIP: Dev servers block the session. Consider running in tmux instead:\n" +
|
||||
` tmux new-session -d -s stirling-dev '${cmd}'\n` +
|
||||
"Or append & to background the process.",
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
const fs = require("node:fs");
|
||||
const input = JSON.parse(fs.readFileSync("/dev/stdin", "utf8"));
|
||||
const cmd = input.tool_input?.command || "";
|
||||
|
||||
if (/--no-verify/.test(cmd)) {
|
||||
console.log(
|
||||
"BLOCKED: --no-verify bypasses git hooks. Fix the underlying issue instead of skipping checks.",
|
||||
);
|
||||
process.exit(2);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
const fs = require("node:fs");
|
||||
const input = JSON.parse(fs.readFileSync("/dev/stdin", "utf8"));
|
||||
const filePath = input.tool_input?.file_path || "";
|
||||
|
||||
const protectedPatterns = [
|
||||
/biome\.json$/,
|
||||
/\.eslintrc/,
|
||||
/eslint\.config/,
|
||||
/\.prettierrc/,
|
||||
/prettier\.config/,
|
||||
/tsconfig.*\.json$/,
|
||||
/\.editorconfig$/,
|
||||
];
|
||||
|
||||
if (protectedPatterns.some((p) => p.test(filePath))) {
|
||||
console.log(
|
||||
`BLOCKED: Cannot modify config file "${filePath}". Fix the code to match the config, not the other way around.`,
|
||||
);
|
||||
process.exit(2);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
const fs = require("node:fs");
|
||||
const { execFileSync } = require("node:child_process");
|
||||
const path = require("node:path");
|
||||
|
||||
const input = JSON.parse(fs.readFileSync("/dev/stdin", "utf8"));
|
||||
const filePath = input.tool_input?.file_path || "";
|
||||
const formattable = /\.(ts|tsx|js|jsx|json)$/;
|
||||
|
||||
if (filePath && formattable.test(filePath) && fs.existsSync(filePath)) {
|
||||
const projectRoot = path.resolve(__dirname, "..", "..");
|
||||
const biomeBin = path.join(projectRoot, "node_modules", ".bin", "biome");
|
||||
|
||||
try {
|
||||
execFileSync(biomeBin, ["check", "--write", filePath], {
|
||||
stdio: "pipe",
|
||||
cwd: projectRoot,
|
||||
});
|
||||
} catch {
|
||||
// Format failures are non-blocking
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
const fs = require("node:fs");
|
||||
const os = require("node:os");
|
||||
const path = require("node:path");
|
||||
|
||||
const _input = JSON.parse(fs.readFileSync("/dev/stdin", "utf8"));
|
||||
const counterFile = path.join(os.tmpdir(), "stirling-claude-tool-count.json");
|
||||
|
||||
let count = 0;
|
||||
try {
|
||||
const data = JSON.parse(fs.readFileSync(counterFile, "utf8"));
|
||||
count = data.count || 0;
|
||||
} catch {
|
||||
// First call or file missing
|
||||
}
|
||||
|
||||
count++;
|
||||
fs.writeFileSync(counterFile, JSON.stringify({ count }));
|
||||
|
||||
if (count === 50 || (count > 50 && (count - 50) % 25 === 0)) {
|
||||
console.log(
|
||||
`${count} tool calls this session. Consider /compact at a logical boundary to free up context.`,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user