@skyforgeai/skyforge 2.0.5 → 2.0.7

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/sky-code +58 -6
  2. package/package.json +6 -6
package/bin/sky-code CHANGED
@@ -13,8 +13,8 @@ const arch = archMap[os.arch()] || os.arch()
13
13
  const pkgName = `@skyforgeai/skyforge-${platform}-${arch}`
14
14
  const binaryName = platform === "windows" ? "sky-code.exe" : "sky-code"
15
15
 
16
- // Search for the platform binary in node_modules
17
- function findBinary(startDir) {
16
+ // Walk up from startDir looking for node_modules/<pkgName>/bin/<binaryName>
17
+ function findBinaryFrom(startDir) {
18
18
  let current = startDir
19
19
  while (true) {
20
20
  const candidate = path.join(current, "node_modules", pkgName, "bin", binaryName)
@@ -26,13 +26,65 @@ function findBinary(startDir) {
26
26
  return null
27
27
  }
28
28
 
29
- const scriptDir = path.dirname(fs.realpathSync(__filename))
30
- const binary = findBinary(scriptDir)
29
+ function findBinary() {
30
+ // 1. Walk up from realpath of launcher (handles local/project installs)
31
+ try {
32
+ const r = findBinaryFrom(path.dirname(fs.realpathSync(__filename)))
33
+ if (r) return r
34
+ } catch (_) {}
35
+
36
+ // 2. Walk up from __filename without resolving symlinks
37
+ try {
38
+ const r = findBinaryFrom(path.dirname(__filename))
39
+ if (r) return r
40
+ } catch (_) {}
41
+
42
+ // 3. Sibling resolution — on global npm the layout is:
43
+ // node_modules/@skyforgeai/skyforge/bin/sky-code (this file)
44
+ // node_modules/@skyforgeai/skyforge-windows-x64/bin/sky-code.exe
45
+ // Go 4 dirs up from __filename to reach node_modules root, then into sibling pkg
46
+ try {
47
+ const r = path.join(
48
+ path.dirname(path.dirname(path.dirname(path.dirname(__filename)))),
49
+ pkgName, "bin", binaryName
50
+ )
51
+ if (fs.existsSync(r)) return r
52
+ } catch (_) {}
53
+
54
+ // 4. Windows global npm fallback: %APPDATA%\npm\node_modules\<pkgName>\bin\<binaryName>
55
+ if (platform === "windows") {
56
+ try {
57
+ const appdata = process.env.APPDATA || process.env.appdata
58
+ if (appdata) {
59
+ const r = path.join(appdata, "npm", "node_modules", pkgName, "bin", binaryName)
60
+ if (fs.existsSync(r)) return r
61
+ }
62
+ } catch (_) {}
63
+ }
64
+
65
+ return null
66
+ }
67
+
68
+ let binary = findBinary()
69
+
70
+ if (!binary) {
71
+ // Optional dependency was not installed automatically (common with nvm on Windows)
72
+ // Try to install it now
73
+ console.error(`sky-code: Platform binary not found, attempting to install ${pkgName}...`)
74
+ try {
75
+ const { execSync } = require("child_process")
76
+ const pkg = require("../package.json")
77
+ const version = pkg.version || "latest"
78
+ execSync(`npm install -g ${pkgName}@${version}`, { stdio: "inherit" })
79
+ binary = findBinary()
80
+ } catch (e) {
81
+ // install failed
82
+ }
83
+ }
31
84
 
32
85
  if (!binary) {
33
86
  console.error(`sky-code: Binary not found for ${platform}-${arch}`)
34
- console.error(`Expected package: ${pkgName}`)
35
- console.error(`Try: npm install -g @skyforgeai/skyforge`)
87
+ console.error(`Run: npm install -g ${pkgName}`)
36
88
  process.exit(1)
37
89
  }
38
90
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "name": "@skyforgeai/skyforge",
5
5
  "description": "SkyForge - ServiceNow Multi-Agent Development Framework powered by AI",
6
6
  "license": "Elastic-2.0",
@@ -137,10 +137,10 @@
137
137
  "development"
138
138
  ],
139
139
  "optionalDependencies": {
140
- "@skyforgeai/skyforge-darwin-arm64": "2.0.5",
141
- "@skyforgeai/skyforge-darwin-x64": "2.0.5",
142
- "@skyforgeai/skyforge-linux-arm64": "2.0.5",
143
- "@skyforgeai/skyforge-linux-x64": "2.0.5",
144
- "@skyforgeai/skyforge-windows-x64": "2.0.5"
140
+ "@skyforgeai/skyforge-darwin-arm64": "2.0.7",
141
+ "@skyforgeai/skyforge-darwin-x64": "2.0.7",
142
+ "@skyforgeai/skyforge-linux-arm64": "2.0.7",
143
+ "@skyforgeai/skyforge-linux-x64": "2.0.7",
144
+ "@skyforgeai/skyforge-windows-x64": "2.0.7"
145
145
  }
146
146
  }