snow-flow 9.0.4 → 9.0.6
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/bin/snow-code.cjs +10 -40
- package/package.json +1 -8
- package/postinstall.cjs +101 -30
- package/bin/snow-flow.cmd +0 -58
- package/bin/snowcode.cmd +0 -58
package/bin/snow-code.cjs
CHANGED
|
@@ -1,53 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const {
|
|
2
|
+
const { spawn } = require('child_process');
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const os = require('os');
|
|
6
6
|
|
|
7
7
|
const platform = os.platform() === 'win32' ? 'windows' : os.platform();
|
|
8
|
-
const arch = os.arch();
|
|
8
|
+
const arch = os.arch() === 'arm64' ? 'arm64' : 'x64';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
'x64': 'x64',
|
|
14
|
-
'x86_64': 'x64'
|
|
15
|
-
};
|
|
10
|
+
const binaryName = platform === 'windows' ? 'snow-code.exe' : 'snow-code';
|
|
11
|
+
const packageDir = path.dirname(__dirname);
|
|
12
|
+
const binaryPath = path.join(packageDir, 'bin', binaryName);
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// Search for binary in node_modules
|
|
21
|
-
function findBinary() {
|
|
22
|
-
let dir = __dirname;
|
|
23
|
-
|
|
24
|
-
// Walk up looking for node_modules
|
|
25
|
-
while (dir !== path.dirname(dir)) {
|
|
26
|
-
// Check in sibling node_modules (for global install)
|
|
27
|
-
const globalPath = path.join(path.dirname(dir), 'node_modules', packageName, 'bin', platform === 'windows' ? 'snow-code.exe' : 'snow-code');
|
|
28
|
-
if (fs.existsSync(globalPath)) {
|
|
29
|
-
return globalPath;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Check in parent's node_modules
|
|
33
|
-
const localPath = path.join(dir, 'node_modules', packageName, 'bin', platform === 'windows' ? 'snow-code.exe' : 'snow-code');
|
|
34
|
-
if (fs.existsSync(localPath)) {
|
|
35
|
-
return localPath;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
dir = path.dirname(dir);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const binaryPath = findBinary();
|
|
45
|
-
|
|
46
|
-
if (!binaryPath) {
|
|
47
|
-
console.error(`Error: Could not find snow-flow binary for ${platform}-${mappedArch}`);
|
|
48
|
-
console.error(`Expected package: ${packageName}`);
|
|
14
|
+
if (!fs.existsSync(binaryPath)) {
|
|
15
|
+
console.error('Error: snow-flow binary not found.');
|
|
49
16
|
console.error('');
|
|
17
|
+
console.error('The binary should have been downloaded during installation.');
|
|
50
18
|
console.error('Try reinstalling: npm install -g snow-flow');
|
|
19
|
+
console.error('');
|
|
20
|
+
console.error(`Expected binary at: ${binaryPath}`);
|
|
51
21
|
process.exit(1);
|
|
52
22
|
}
|
|
53
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.6",
|
|
4
4
|
"name": "snow-flow",
|
|
5
5
|
"description": "Snow-Flow - AI-powered ServiceNow development CLI with 410+ MCP tools",
|
|
6
6
|
"type": "module",
|
|
@@ -101,12 +101,5 @@
|
|
|
101
101
|
"zod": "3.25.76",
|
|
102
102
|
"zod-to-json-schema": "3.24.5",
|
|
103
103
|
"tsx": "4.20.6"
|
|
104
|
-
},
|
|
105
|
-
"optionalDependencies": {
|
|
106
|
-
"snow-flow-darwin-arm64": "*",
|
|
107
|
-
"snow-flow-darwin-x64": "*",
|
|
108
|
-
"snow-flow-linux-arm64": "*",
|
|
109
|
-
"snow-flow-linux-x64": "*",
|
|
110
|
-
"snow-flow-windows-x64": "*"
|
|
111
104
|
}
|
|
112
105
|
}
|
package/postinstall.cjs
CHANGED
|
@@ -2,38 +2,109 @@
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const os = require('os');
|
|
5
|
+
const https = require('https');
|
|
6
|
+
const { execSync } = require('child_process');
|
|
7
|
+
const zlib = require('zlib');
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const platform = os.platform() === 'win32' ? 'windows' : os.platform();
|
|
10
|
+
const arch = os.arch() === 'arm64' ? 'arm64' : 'x64';
|
|
11
|
+
|
|
12
|
+
const binaryName = platform === 'windows' ? 'snow-code.exe' : 'snow-code';
|
|
13
|
+
const packageDir = __dirname;
|
|
14
|
+
const binDir = path.join(packageDir, 'bin');
|
|
15
|
+
const binaryPath = path.join(binDir, binaryName);
|
|
16
|
+
|
|
17
|
+
// Get version from package.json
|
|
18
|
+
function getVersion() {
|
|
19
|
+
try {
|
|
20
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8'));
|
|
21
|
+
return pkg.version;
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
14
24
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Follow redirects and download file
|
|
28
|
+
function download(url) {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
const request = https.get(url, { headers: { 'User-Agent': 'snow-flow-installer' } }, (response) => {
|
|
31
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
32
|
+
download(response.headers.location).then(resolve).catch(reject);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (response.statusCode !== 200) {
|
|
36
|
+
reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const chunks = [];
|
|
41
|
+
response.on('data', chunk => chunks.push(chunk));
|
|
42
|
+
response.on('end', () => resolve(Buffer.concat(chunks)));
|
|
43
|
+
response.on('error', reject);
|
|
44
|
+
});
|
|
45
|
+
request.on('error', reject);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function downloadBinary() {
|
|
50
|
+
const version = getVersion();
|
|
51
|
+
if (!version) {
|
|
52
|
+
console.log('Could not determine version, skipping binary download');
|
|
53
|
+
return false;
|
|
26
54
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
55
|
+
|
|
56
|
+
const assetName = `snow-flow-${platform}-${arch}`;
|
|
57
|
+
const tarballName = `${assetName}.tar.gz`;
|
|
58
|
+
const releaseUrl = `https://github.com/groeimetai/snow-flow/releases/download/v${version}/${tarballName}`;
|
|
59
|
+
|
|
60
|
+
console.log(`Downloading snow-flow binary for ${platform}-${arch}...`);
|
|
61
|
+
console.log(`URL: ${releaseUrl}`);
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
// Download the tarball
|
|
65
|
+
const tarballData = await download(releaseUrl);
|
|
66
|
+
|
|
67
|
+
// Create temp file
|
|
68
|
+
const tmpDir = os.tmpdir();
|
|
69
|
+
const tarballPath = path.join(tmpDir, tarballName);
|
|
70
|
+
fs.writeFileSync(tarballPath, tarballData);
|
|
71
|
+
|
|
72
|
+
// Ensure bin directory exists
|
|
73
|
+
if (!fs.existsSync(binDir)) {
|
|
74
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Extract using tar command
|
|
78
|
+
console.log('Extracting binary...');
|
|
79
|
+
execSync(`tar -xzf "${tarballPath}" -C "${binDir}" --strip-components=1`, { stdio: 'pipe' });
|
|
80
|
+
|
|
81
|
+
// Clean up
|
|
82
|
+
fs.unlinkSync(tarballPath);
|
|
83
|
+
|
|
84
|
+
// Make executable on non-Windows
|
|
85
|
+
if (platform !== 'windows' && fs.existsSync(binaryPath)) {
|
|
86
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
console.log('✅ Binary installed successfully!');
|
|
90
|
+
return true;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.log(`Note: Could not download pre-built binary (${error.message})`);
|
|
93
|
+
console.log('You may need to build from source or check your network connection.');
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Only run if binary doesn't exist
|
|
99
|
+
if (!fs.existsSync(binaryPath)) {
|
|
100
|
+
downloadBinary().catch(err => {
|
|
101
|
+
console.log(`Download failed: ${err.message}`);
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
// Make sure it's executable
|
|
105
|
+
if (platform !== 'windows') {
|
|
106
|
+
try {
|
|
107
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
108
|
+
} catch {}
|
|
35
109
|
}
|
|
36
|
-
} catch (error) {
|
|
37
|
-
// Silently fail - not critical
|
|
38
|
-
console.log('Note: Could not set binary permissions (non-critical)');
|
|
39
110
|
}
|
package/bin/snow-flow.cmd
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
setlocal enabledelayedexpansion
|
|
3
|
-
|
|
4
|
-
if defined OPENCODE_BIN_PATH (
|
|
5
|
-
set "resolved=%OPENCODE_BIN_PATH%"
|
|
6
|
-
goto :execute
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
rem Get the directory of this script
|
|
10
|
-
set "script_dir=%~dp0"
|
|
11
|
-
set "script_dir=%script_dir:~0,-1%"
|
|
12
|
-
|
|
13
|
-
rem Detect platform and architecture
|
|
14
|
-
set "platform=windows"
|
|
15
|
-
|
|
16
|
-
rem Detect architecture
|
|
17
|
-
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
|
|
18
|
-
set "arch=x64"
|
|
19
|
-
) else if "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
|
|
20
|
-
set "arch=arm64"
|
|
21
|
-
) else if "%PROCESSOR_ARCHITECTURE%"=="x86" (
|
|
22
|
-
set "arch=x86"
|
|
23
|
-
) else (
|
|
24
|
-
set "arch=x64"
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
set "name=opencode-!platform!-!arch!"
|
|
28
|
-
set "binary=opencode.exe"
|
|
29
|
-
|
|
30
|
-
rem Search for the binary starting from script location
|
|
31
|
-
set "resolved="
|
|
32
|
-
set "current_dir=%script_dir%"
|
|
33
|
-
|
|
34
|
-
:search_loop
|
|
35
|
-
set "candidate=%current_dir%\node_modules\%name%\bin\%binary%"
|
|
36
|
-
if exist "%candidate%" (
|
|
37
|
-
set "resolved=%candidate%"
|
|
38
|
-
goto :execute
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
rem Move up one directory
|
|
42
|
-
for %%i in ("%current_dir%") do set "parent_dir=%%~dpi"
|
|
43
|
-
set "parent_dir=%parent_dir:~0,-1%"
|
|
44
|
-
|
|
45
|
-
rem Check if we've reached the root
|
|
46
|
-
if "%current_dir%"=="%parent_dir%" goto :not_found
|
|
47
|
-
set "current_dir=%parent_dir%"
|
|
48
|
-
goto :search_loop
|
|
49
|
-
|
|
50
|
-
:not_found
|
|
51
|
-
echo It seems that your package manager failed to install the right version of the opencode CLI for your platform. You can try manually installing the "%name%" package >&2
|
|
52
|
-
exit /b 1
|
|
53
|
-
|
|
54
|
-
:execute
|
|
55
|
-
rem Execute the binary with all arguments in the same console window
|
|
56
|
-
rem Use start /b /wait to ensure it runs in the current shell context for all shells
|
|
57
|
-
start /b /wait "" "%resolved%" %*
|
|
58
|
-
exit /b %ERRORLEVEL%
|
package/bin/snowcode.cmd
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
setlocal enabledelayedexpansion
|
|
3
|
-
|
|
4
|
-
if defined OPENCODE_BIN_PATH (
|
|
5
|
-
set "resolved=%OPENCODE_BIN_PATH%"
|
|
6
|
-
goto :execute
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
rem Get the directory of this script
|
|
10
|
-
set "script_dir=%~dp0"
|
|
11
|
-
set "script_dir=%script_dir:~0,-1%"
|
|
12
|
-
|
|
13
|
-
rem Detect platform and architecture
|
|
14
|
-
set "platform=windows"
|
|
15
|
-
|
|
16
|
-
rem Detect architecture
|
|
17
|
-
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
|
|
18
|
-
set "arch=x64"
|
|
19
|
-
) else if "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
|
|
20
|
-
set "arch=arm64"
|
|
21
|
-
) else if "%PROCESSOR_ARCHITECTURE%"=="x86" (
|
|
22
|
-
set "arch=x86"
|
|
23
|
-
) else (
|
|
24
|
-
set "arch=x64"
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
set "name=opencode-!platform!-!arch!"
|
|
28
|
-
set "binary=opencode.exe"
|
|
29
|
-
|
|
30
|
-
rem Search for the binary starting from script location
|
|
31
|
-
set "resolved="
|
|
32
|
-
set "current_dir=%script_dir%"
|
|
33
|
-
|
|
34
|
-
:search_loop
|
|
35
|
-
set "candidate=%current_dir%\node_modules\%name%\bin\%binary%"
|
|
36
|
-
if exist "%candidate%" (
|
|
37
|
-
set "resolved=%candidate%"
|
|
38
|
-
goto :execute
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
rem Move up one directory
|
|
42
|
-
for %%i in ("%current_dir%") do set "parent_dir=%%~dpi"
|
|
43
|
-
set "parent_dir=%parent_dir:~0,-1%"
|
|
44
|
-
|
|
45
|
-
rem Check if we've reached the root
|
|
46
|
-
if "%current_dir%"=="%parent_dir%" goto :not_found
|
|
47
|
-
set "current_dir=%parent_dir%"
|
|
48
|
-
goto :search_loop
|
|
49
|
-
|
|
50
|
-
:not_found
|
|
51
|
-
echo It seems that your package manager failed to install the right version of the opencode CLI for your platform. You can try manually installing the "%name%" package >&2
|
|
52
|
-
exit /b 1
|
|
53
|
-
|
|
54
|
-
:execute
|
|
55
|
-
rem Execute the binary with all arguments in the same console window
|
|
56
|
-
rem Use start /b /wait to ensure it runs in the current shell context for all shells
|
|
57
|
-
start /b /wait "" "%resolved%" %*
|
|
58
|
-
exit /b %ERRORLEVEL%
|