forge-pipeline 0.2.0 → 0.3.1

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 (2) hide show
  1. package/bin/forge.js +92 -22
  2. package/package.json +1 -1
package/bin/forge.js CHANGED
@@ -1,29 +1,99 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { execFileSync } = require("child_process");
3
+ const { execFileSync, execSync } = require("child_process");
4
4
  const path = require("path");
5
5
 
6
+ const forgePath = path.join(__dirname, "..", "forge");
7
+
6
8
  if (process.platform === "win32") {
7
- console.error(
8
- "Error: forge requires a Unix environment (macOS or Linux).\n" +
9
- "\n" +
10
- "On Windows, use one of:\n" +
11
- " 1. WSL (Windows Subsystem for Linux) — install from Microsoft Store\n" +
12
- " then run: wsl\n" +
13
- " and install forge inside WSL\n" +
14
- " 2. Git Bash — https://gitforwindows.org\n" +
15
- "\n" +
16
- "forge depends on bash, tmux, and git worktrees which are not\n" +
17
- "available natively on Windows."
18
- );
19
- process.exit(1);
20
- }
9
+ // Check if WSL has a working Linux distro (not just WSL installed)
10
+ let hasWslDistro = false;
11
+ try {
12
+ const result = execSync("wsl echo ok", {
13
+ stdio: ["ignore", "pipe", "ignore"],
14
+ timeout: 5000,
15
+ }).toString().trim();
16
+ hasWslDistro = result.includes("ok");
17
+ } catch {}
21
18
 
22
- const forgePath = path.join(__dirname, "..", "forge");
23
- try {
24
- execFileSync("bash", [forgePath, ...process.argv.slice(2)], {
25
- stdio: "inherit",
26
- });
27
- } catch (err) {
28
- process.exit(err.status || 1);
19
+ if (!hasWslDistro) {
20
+ console.error(
21
+ "forge requires WSL with a Linux distribution installed.\n" +
22
+ "\n" +
23
+ "Setup steps:\n" +
24
+ " 1. Open PowerShell as Administrator\n" +
25
+ " 2. Run: wsl --install\n" +
26
+ " 3. Restart your computer\n" +
27
+ " 4. Open 'Ubuntu' from the Start Menu and complete setup\n" +
28
+ " 5. Inside Ubuntu, install forge:\n" +
29
+ " curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -\n" +
30
+ " sudo apt install -y nodejs tmux git jq\n" +
31
+ " npm install -g forge-pipeline\n" +
32
+ " 6. Install Claude Code inside WSL:\n" +
33
+ " npm install -g @anthropic-ai/claude-code\n" +
34
+ "\n" +
35
+ "Then run forge from inside the Ubuntu terminal."
36
+ );
37
+ process.exit(1);
38
+ }
39
+
40
+ // WSL has a working distro — check for required tools
41
+ let missing = [];
42
+ for (const tool of ["bash", "tmux", "git", "claude", "jq"]) {
43
+ try {
44
+ execSync(`wsl which ${tool}`, { stdio: "ignore", timeout: 3000 });
45
+ } catch {
46
+ missing.push(tool);
47
+ }
48
+ }
49
+
50
+ if (missing.length > 0) {
51
+ const aptTools = missing.filter(t => !["claude"].includes(t));
52
+ console.error(
53
+ "WSL detected but missing required tools: " + missing.join(", ") + "\n" +
54
+ "\n" +
55
+ "Open WSL and install them:\n" +
56
+ " wsl\n" +
57
+ (aptTools.length > 0
58
+ ? " sudo apt update && sudo apt install -y " + aptTools.join(" ") + "\n"
59
+ : "") +
60
+ (missing.includes("claude")
61
+ ? " npm install -g @anthropic-ai/claude-code\n"
62
+ : "")
63
+ );
64
+ process.exit(1);
65
+ }
66
+
67
+ // Convert Windows path to WSL path and run
68
+ let wslForgePath;
69
+ try {
70
+ wslForgePath = execSync(`wsl wslpath -u "${forgePath.replace(/\\/g, "\\\\")}"`, {
71
+ stdio: ["ignore", "pipe", "ignore"],
72
+ }).toString().trim();
73
+ } catch {
74
+ console.error(
75
+ "Failed to convert path for WSL.\n" +
76
+ "Run forge directly from inside WSL instead:\n" +
77
+ " wsl\n" +
78
+ " forge --help"
79
+ );
80
+ process.exit(1);
81
+ }
82
+
83
+ try {
84
+ execFileSync("wsl", ["bash", wslForgePath, ...process.argv.slice(2)], {
85
+ stdio: "inherit",
86
+ });
87
+ } catch (err) {
88
+ process.exit(err.status || 1);
89
+ }
90
+ } else {
91
+ // macOS / Linux — run directly
92
+ try {
93
+ execFileSync("bash", [forgePath, ...process.argv.slice(2)], {
94
+ stdio: "inherit",
95
+ });
96
+ } catch (err) {
97
+ process.exit(err.status || 1);
98
+ }
29
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forge-pipeline",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Autonomous multi-agent coding pipeline",
5
5
  "bin": {
6
6
  "forge": "./bin/forge.js"