@hoophq/fence 1.0.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/README.md +23 -0
- package/bin/fence.js +51 -0
- package/package.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @hoophq/fence
|
|
2
|
+
|
|
3
|
+
**Guardrails for AI coding agents.** Fence inspects every command your agent
|
|
4
|
+
tries to run and stops the catastrophic ones — recursive deletes of your home
|
|
5
|
+
directory, secret exfiltration, `curl | sh`, force-pushes — *before* they
|
|
6
|
+
execute.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install -g @hoophq/fence
|
|
10
|
+
|
|
11
|
+
fence check 'rm -rf ~' # DENY
|
|
12
|
+
fence init # wire it into Claude Code
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This package ships the native `fence` binary. It uses the esbuild/biome
|
|
16
|
+
distribution model: the correct `@hoophq/fence-<os>-<cpu>` build is pulled in as
|
|
17
|
+
an optional dependency via npm's `os`/`cpu` selection — **no postinstall script
|
|
18
|
+
and no download at runtime** (a tool that flags those shouldn't ship as one).
|
|
19
|
+
|
|
20
|
+
Supported platforms: macOS and Linux on x64/arm64. For anything else, install
|
|
21
|
+
from source: `go install github.com/hoophq/fence/cmd/fence@latest`.
|
|
22
|
+
|
|
23
|
+
Full docs: https://github.com/hoophq/fence
|
package/bin/fence.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// Resolve the prebuilt fence binary for this platform and exec it.
|
|
5
|
+
//
|
|
6
|
+
// The matching @hoophq/fence-<os>-<cpu> package is installed by npm as an
|
|
7
|
+
// optionalDependency, gated by its own `os`/`cpu` fields — so exactly one lands
|
|
8
|
+
// on any given machine. There is no postinstall and no download at runtime: a
|
|
9
|
+
// guardrail that flags `curl | sh` and postinstall hooks must not ship as one.
|
|
10
|
+
|
|
11
|
+
const { spawnSync } = require("node:child_process");
|
|
12
|
+
const fs = require("node:fs");
|
|
13
|
+
|
|
14
|
+
function binaryPath() {
|
|
15
|
+
const pkg = `@hoophq/fence-${process.platform}-${process.arch}`;
|
|
16
|
+
try {
|
|
17
|
+
return require.resolve(`${pkg}/bin/fence`);
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const bin = binaryPath();
|
|
24
|
+
if (!bin) {
|
|
25
|
+
const windows =
|
|
26
|
+
process.platform === "win32"
|
|
27
|
+
? `Native Windows isn't supported yet — run Fence inside WSL (works exactly as on Linux),\n` +
|
|
28
|
+
`or follow https://github.com/hoophq/fence/issues/26 for native support.\n`
|
|
29
|
+
: "";
|
|
30
|
+
console.error(
|
|
31
|
+
`fence: no prebuilt binary for ${process.platform}-${process.arch}.\n` +
|
|
32
|
+
`Supported: darwin/linux on x64/arm64.\n` +
|
|
33
|
+
windows +
|
|
34
|
+
`Install from source instead: go install github.com/hoophq/fence/cmd/fence@latest`
|
|
35
|
+
);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Be defensive about the executable bit surviving packaging/extraction.
|
|
40
|
+
try {
|
|
41
|
+
fs.chmodSync(bin, 0o755);
|
|
42
|
+
} catch {
|
|
43
|
+
// read-only store, etc. — spawn will surface any real problem
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const res = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
47
|
+
if (res.error) {
|
|
48
|
+
console.error(`fence: ${res.error.message}`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
process.exit(res.status === null ? 1 : res.status);
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hoophq/fence",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Guardrails for AI coding agents — blocks catastrophic tool calls before they run",
|
|
5
|
+
"repository": "github:hoophq/fence",
|
|
6
|
+
"homepage": "https://github.com/hoophq/fence",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"bin": {
|
|
9
|
+
"fence": "bin/fence.js"
|
|
10
|
+
},
|
|
11
|
+
"optionalDependencies": {
|
|
12
|
+
"@hoophq/fence-darwin-x64": "1.0.0",
|
|
13
|
+
"@hoophq/fence-darwin-arm64": "1.0.0",
|
|
14
|
+
"@hoophq/fence-linux-x64": "1.0.0",
|
|
15
|
+
"@hoophq/fence-linux-arm64": "1.0.0"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin"
|
|
19
|
+
]
|
|
20
|
+
}
|