@golproductions/check 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +83 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@golproductions/check",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Pre-execution firewall hook for AI agents. Validates every command before it reaches the shell. 152 failed commands without Check. 1 with it. Supports Claude Code, Gemini CLI, Antigravity, Cursor, and VS Code.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"check": "src/index.js"
|
package/src/index.js
CHANGED
|
@@ -3,11 +3,94 @@
|
|
|
3
3
|
|
|
4
4
|
import { execFileSync } from "node:child_process";
|
|
5
5
|
|
|
6
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { homedir } from "node:os";
|
|
9
|
+
|
|
6
10
|
const API = "https://triage.golproductions.com/preflight";
|
|
7
11
|
const CLIENT_ID = process.env.GOL_CLIENT_ID || "";
|
|
8
12
|
const TIMEOUT_MS = 5000;
|
|
9
13
|
const IS_WIN = process.platform === "win32";
|
|
10
14
|
|
|
15
|
+
function install() {
|
|
16
|
+
const key = process.argv[3] || process.env.GOL_CLIENT_ID || "your_key";
|
|
17
|
+
const home = homedir();
|
|
18
|
+
let installed = 0;
|
|
19
|
+
|
|
20
|
+
const targets = [
|
|
21
|
+
{
|
|
22
|
+
name: "Claude Code",
|
|
23
|
+
dir: join(home, ".claude"),
|
|
24
|
+
file: "settings.json",
|
|
25
|
+
config: (existing) => {
|
|
26
|
+
existing.hooks = existing.hooks || {};
|
|
27
|
+
existing.hooks.PreToolUse = [{
|
|
28
|
+
matcher: "Bash|PowerShell",
|
|
29
|
+
hooks: [{ type: "command", command: "npx", args: ["@golproductions/check"] }]
|
|
30
|
+
}];
|
|
31
|
+
existing.env = existing.env || {};
|
|
32
|
+
existing.env.GOL_CLIENT_ID = key;
|
|
33
|
+
return existing;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "Gemini CLI / Antigravity",
|
|
38
|
+
dir: join(home, ".gemini"),
|
|
39
|
+
file: "settings.json",
|
|
40
|
+
config: (existing) => {
|
|
41
|
+
existing.hooks = existing.hooks || {};
|
|
42
|
+
existing.hooks.BeforeTool = [{
|
|
43
|
+
type: "command",
|
|
44
|
+
command: "npx @golproductions/check",
|
|
45
|
+
matcher: ".*",
|
|
46
|
+
timeout: 5000
|
|
47
|
+
}];
|
|
48
|
+
return existing;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "Cursor",
|
|
53
|
+
dir: join(home, ".cursor"),
|
|
54
|
+
file: "hooks.json",
|
|
55
|
+
config: (existing) => {
|
|
56
|
+
existing.version = existing.version || 1;
|
|
57
|
+
existing.hooks = existing.hooks || {};
|
|
58
|
+
existing.hooks.beforeShellExecution = [{
|
|
59
|
+
command: "npx @golproductions/check"
|
|
60
|
+
}];
|
|
61
|
+
return existing;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
for (const t of targets) {
|
|
67
|
+
if (!existsSync(t.dir)) continue;
|
|
68
|
+
const filepath = join(t.dir, t.file);
|
|
69
|
+
let existing = {};
|
|
70
|
+
try { existing = JSON.parse(readFileSync(filepath, "utf8")); } catch {}
|
|
71
|
+
const updated = t.config(existing);
|
|
72
|
+
mkdirSync(t.dir, { recursive: true });
|
|
73
|
+
writeFileSync(filepath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
74
|
+
console.log(`✓ ${t.name} — ${filepath}`);
|
|
75
|
+
installed++;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (installed === 0) {
|
|
79
|
+
console.log("No IDE config directories found (~/.claude, ~/.gemini, ~/.cursor).");
|
|
80
|
+
console.log("Start your IDE first, then run: npx @golproductions/check --install");
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log(`\n${installed} IDE(s) configured. Restart your IDE to activate Check.`);
|
|
85
|
+
if (key === "your_key") {
|
|
86
|
+
console.log("Set your key: export GOL_CLIENT_ID=your_key");
|
|
87
|
+
console.log("Get a free key at https://www.golproductions.com/check.html");
|
|
88
|
+
}
|
|
89
|
+
process.exit(0);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (process.argv.includes("--install")) { install(); }
|
|
93
|
+
|
|
11
94
|
const SKIP = new Set(["cd", "ls", "dir", "pwd", "echo", "cat", "head", "tail", "wc", "mkdir", "test", "true", "false", "exit"]);
|
|
12
95
|
const PREFIXES = new Set(["sudo", "nohup", "nice", "time", "timeout", "env"]);
|
|
13
96
|
|