@bitmilldev/warden 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/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@bitmilldev/warden",
3
+ "version": "1.0.0",
4
+ "description": "AI Coding Session Guardian — runtime intelligence layer for Claude Code, Gemini CLI, and more",
5
+ "keywords": [
6
+ "ai",
7
+ "coding",
8
+ "hooks",
9
+ "claude",
10
+ "gemini",
11
+ "guardian",
12
+ "session"
13
+ ],
14
+ "author": "Liel Kaysari (ekud12)",
15
+ "license": "MIT",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/ekud12/warden"
19
+ },
20
+ "bin": {
21
+ "warden": "bin/warden"
22
+ },
23
+ "scripts": {
24
+ "postinstall": "node scripts/postinstall.js"
25
+ },
26
+ "os": [
27
+ "win32",
28
+ "darwin",
29
+ "linux"
30
+ ],
31
+ "cpu": [
32
+ "x64",
33
+ "arm64"
34
+ ],
35
+ "engines": {
36
+ "node": ">=16"
37
+ }
38
+ }
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+ // Warden npm/bun postinstall — downloads the platform-specific binary
3
+ // to ~/.warden/bin/ and registers PATH.
4
+
5
+ const { execSync, spawnSync } = require("child_process");
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const os = require("os");
9
+ const https = require("https");
10
+
11
+ const VERSION = require("../package.json").version;
12
+ const REPO = "ekud12/warden";
13
+
14
+ const PLATFORM_MAP = {
15
+ "win32-x64": "warden-x86_64-pc-windows-msvc.exe",
16
+ "win32-arm64": "warden-aarch64-pc-windows-msvc.exe",
17
+ "darwin-x64": "warden-x86_64-apple-darwin",
18
+ "darwin-arm64": "warden-aarch64-apple-darwin",
19
+ "linux-x64": "warden-x86_64-unknown-linux-gnu",
20
+ "linux-arm64": "warden-aarch64-unknown-linux-gnu",
21
+ };
22
+
23
+ async function main() {
24
+ const platform = `${os.platform()}-${os.arch()}`;
25
+ const binary = PLATFORM_MAP[platform];
26
+
27
+ if (!binary) {
28
+ console.error(`Unsupported platform: ${platform}`);
29
+ console.error("Install from source: cargo install warden-ai");
30
+ process.exit(0); // Don't fail npm install
31
+ }
32
+
33
+ const wardenHome = path.join(os.homedir(), ".warden");
34
+ const binDir = path.join(wardenHome, "bin");
35
+ const destName = os.platform() === "win32" ? "warden.exe" : "warden";
36
+ const dest = path.join(binDir, destName);
37
+
38
+ // Create directories
39
+ fs.mkdirSync(binDir, { recursive: true });
40
+ fs.mkdirSync(path.join(wardenHome, "rules"), { recursive: true });
41
+ fs.mkdirSync(path.join(wardenHome, "projects"), { recursive: true });
42
+
43
+ // Download binary from GitHub Releases
44
+ const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${binary}`;
45
+ console.log(`Downloading warden v${VERSION} for ${platform}...`);
46
+
47
+ try {
48
+ await download(url, dest);
49
+ if (os.platform() !== "win32") {
50
+ fs.chmodSync(dest, 0o755);
51
+ }
52
+ console.log(`Installed to ${dest}`);
53
+
54
+ // Run warden init (non-interactive: just PATH + config)
55
+ try {
56
+ spawnSync(dest, ["version"], { stdio: "inherit" });
57
+ } catch (e) {
58
+ // Ignore — binary might need different setup
59
+ }
60
+
61
+ console.log("");
62
+ console.log("Run 'warden init' to complete setup (install CLI tools, configure hooks).");
63
+ console.log(`Or: 'warden install claude-code' / 'warden install gemini-cli'`);
64
+ } catch (err) {
65
+ console.error(`Download failed: ${err.message}`);
66
+ console.error("Install from source: cargo install warden-ai");
67
+ process.exit(0); // Don't fail npm install
68
+ }
69
+ }
70
+
71
+ function download(url, dest) {
72
+ return new Promise((resolve, reject) => {
73
+ const file = fs.createWriteStream(dest);
74
+ const request = (urlStr) => {
75
+ https.get(urlStr, (response) => {
76
+ if (response.statusCode === 302 || response.statusCode === 301) {
77
+ request(response.headers.location);
78
+ return;
79
+ }
80
+ if (response.statusCode !== 200) {
81
+ reject(new Error(`HTTP ${response.statusCode}`));
82
+ return;
83
+ }
84
+ response.pipe(file);
85
+ file.on("finish", () => { file.close(); resolve(); });
86
+ }).on("error", reject);
87
+ };
88
+ request(url);
89
+ });
90
+ }
91
+
92
+ main().catch((e) => {
93
+ console.error(e.message);
94
+ process.exit(0);
95
+ });