refactor: rename Tool.alpha to Tool.experimental

This commit is contained in:
Siddharth Kumar Sah
2026-03-26 01:10:51 +08:00
parent ab370a74fe
commit 585d66f0c9
178 changed files with 5637 additions and 4082 deletions
+13
View File
@@ -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.",
);
}
+10
View File
@@ -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);
}
+20
View File
@@ -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);
}
+21
View File
@@ -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
}
}
+23
View File
@@ -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.`,
);
}