@agentfare/forge 0.1.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.
Files changed (3) hide show
  1. package/install.js +91 -0
  2. package/package.json +35 -0
  3. package/run.js +24 -0
package/install.js ADDED
@@ -0,0 +1,91 @@
1
+ const { execSync } = require("child_process");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const https = require("https");
5
+ const { createWriteStream } = require("fs");
6
+ const { pipeline } = require("stream/promises");
7
+
8
+ const VERSION = require("./package.json").version;
9
+
10
+ function getPlatform() {
11
+ const platform = process.platform;
12
+ const arch = process.arch;
13
+ const osMap = { darwin: "darwin", linux: "linux", win32: "windows" };
14
+ const archMap = { x64: "x86_64", arm64: "aarch64" };
15
+
16
+ const goos = osMap[platform];
17
+ const goarch = archMap[arch];
18
+
19
+ if (!goos || !goarch) {
20
+ throw new Error(`Unsupported platform: ${platform}/${arch}`);
21
+ }
22
+
23
+ return { goos, goarch };
24
+ }
25
+
26
+ function getBinaryName() {
27
+ return process.platform === "win32" ? "forge.exe" : "forge";
28
+ }
29
+
30
+ async function download(url, dest) {
31
+ const res = await new Promise((resolve, reject) => {
32
+ https
33
+ .get(url, { timeout: 30000 }, (res) => {
34
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
35
+ return download(res.headers.location, dest).then(resolve).catch(reject);
36
+ }
37
+ if (res.statusCode !== 200) {
38
+ return reject(new Error(`Download failed: HTTP ${res.statusCode}`));
39
+ }
40
+ resolve(res);
41
+ })
42
+ .on("error", reject);
43
+ });
44
+
45
+ await pipeline(res, createWriteStream(dest));
46
+ }
47
+
48
+ async function main() {
49
+ const binDir = path.join(__dirname, "bin");
50
+ fs.mkdirSync(binDir, { recursive: true });
51
+
52
+ const { goos, goarch } = getPlatform();
53
+ const ext = goos === "windows" ? "zip" : "tar.gz";
54
+ const archiveName = `forge_${VERSION}_${goos}_${goarch}.${ext}`;
55
+ const url = `https://github.com/MjxUpUp/forge/releases/download/v${VERSION}/${archiveName}`;
56
+
57
+ const archivePath = path.join(binDir, archiveName);
58
+ console.log(`Downloading forge v${VERSION} for ${goos}/${goarch}...`);
59
+
60
+ await download(url, archivePath);
61
+ console.log(`Downloaded to ${archivePath}`);
62
+
63
+ // Extract
64
+ if (ext === "zip") {
65
+ if (process.platform === "win32") {
66
+ execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${binDir}' -Force"`, { stdio: "inherit" });
67
+ } else {
68
+ execSync(`unzip -o "${archivePath}" -d "${binDir}"`, { stdio: "inherit" });
69
+ }
70
+ } else {
71
+ execSync(`tar xzf "${archivePath}" -C "${binDir}"`, { stdio: "inherit" });
72
+ }
73
+
74
+ // Make executable
75
+ const binaryName = getBinaryName();
76
+ const binaryPath = path.join(binDir, binaryName);
77
+ if (process.platform !== "win32") {
78
+ fs.chmodSync(binaryPath, 0o755);
79
+ }
80
+
81
+ // Cleanup archive
82
+ fs.unlinkSync(archivePath);
83
+
84
+ console.log(`forge v${VERSION} installed successfully.`);
85
+ }
86
+
87
+ main().catch((err) => {
88
+ console.error("Installation failed:", err.message);
89
+ console.error("You can download forge manually from https://github.com/MjxUpUp/forge/releases");
90
+ process.exit(1);
91
+ });
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@agentfare/forge",
3
+ "version": "0.1.0",
4
+ "description": "AI development gate engine — structured quality gates for AI-generated code",
5
+ "bin": {
6
+ "forge": "run.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "files": [
12
+ "install.js",
13
+ "run.js"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/MjxUpUp/forge"
18
+ },
19
+ "keywords": [
20
+ "ai",
21
+ "gate",
22
+ "pipeline",
23
+ "quality",
24
+ "claude-code"
25
+ ],
26
+ "license": "MIT",
27
+ "engines": {
28
+ "node": ">=16"
29
+ },
30
+ "optionalDependencies": {},
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/",
33
+ "access": "public"
34
+ }
35
+ }
package/run.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require("child_process");
4
+ const path = require("path");
5
+ const fs = require("fs");
6
+
7
+ const binaryName = process.platform === "win32" ? "forge.exe" : "forge";
8
+ const binaryPath = path.join(__dirname, "bin", binaryName);
9
+
10
+ if (!fs.existsSync(binaryPath)) {
11
+ console.error(
12
+ "forge binary not found. Run `npm install` to download it, or install from https://github.com/MjxUpUp/forge/releases"
13
+ );
14
+ process.exit(1);
15
+ }
16
+
17
+ const child = spawn(binaryPath, process.argv.slice(2), {
18
+ stdio: "inherit",
19
+ env: process.env,
20
+ });
21
+
22
+ child.on("exit", (code) => {
23
+ process.exit(code || 0);
24
+ });