snow-flow 9.0.4 → 9.0.9
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 +2 -8
- package/postinstall.cjs +155 -30
- package/bin/snow-flow.cmd +0 -58
- package/bin/snowcode.cmd +0 -58
- package/bunfig.toml +0 -2
- package/script/postinstall.mjs +0 -135
- package/script/preinstall.mjs +0 -45
- package/snow-code-config.example.json +0 -39
- package/src/acp/README.md +0 -164
- package/src/agent/generate.txt +0 -75
- package/src/dag/README.md +0 -473
- package/src/session/prompt/anthropic-20250930.txt +0 -166
- package/src/session/prompt/anthropic.txt +0 -235
- package/src/session/prompt/anthropic_spoof.txt +0 -1
- package/src/session/prompt/beast.txt +0 -200
- package/src/session/prompt/build-switch.txt +0 -5
- package/src/session/prompt/codex.txt +0 -353
- package/src/session/prompt/copilot-gpt-5.txt +0 -143
- package/src/session/prompt/gemini.txt +0 -217
- package/src/session/prompt/initialize.txt +0 -8
- package/src/session/prompt/plan.txt +0 -8
- package/src/session/prompt/qwen.txt +0 -141
- package/src/session/prompt/summarize-turn.txt +0 -5
- package/src/session/prompt/summarize.txt +0 -10
- package/src/session/prompt/title.txt +0 -24
- package/src/tool/bash.txt +0 -121
- package/src/tool/edit.txt +0 -10
- package/src/tool/glob.txt +0 -6
- package/src/tool/grep.txt +0 -8
- package/src/tool/ls.txt +0 -1
- package/src/tool/lsp-diagnostics.txt +0 -1
- package/src/tool/lsp-hover.txt +0 -1
- package/src/tool/multiedit.txt +0 -41
- package/src/tool/patch.txt +0 -1
- package/src/tool/read.txt +0 -12
- package/src/tool/task.txt +0 -76
- package/src/tool/todoread.txt +0 -14
- package/src/tool/todowrite.txt +0 -167
- package/src/tool/webfetch.txt +0 -14
- package/src/tool/websearch.txt +0 -11
- package/src/tool/write.txt +0 -8
- package/test-codespace-detection.js +0 -51
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.9",
|
|
4
4
|
"name": "snow-flow",
|
|
5
5
|
"description": "Snow-Flow - AI-powered ServiceNow development CLI with 410+ MCP tools",
|
|
6
6
|
"type": "module",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"@standard-schema/spec": "1.0.0",
|
|
80
80
|
"@zip.js/zip.js": "2.7.62",
|
|
81
81
|
"ai": "5.0.8",
|
|
82
|
+
"axios": "1.7.9",
|
|
82
83
|
"chokidar": "4.0.3",
|
|
83
84
|
"decimal.js": "10.5.0",
|
|
84
85
|
"diff": "8.0.2",
|
|
@@ -101,12 +102,5 @@
|
|
|
101
102
|
"zod": "3.25.76",
|
|
102
103
|
"zod-to-json-schema": "3.24.5",
|
|
103
104
|
"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
105
|
}
|
|
112
106
|
}
|
package/postinstall.cjs
CHANGED
|
@@ -2,38 +2,163 @@
|
|
|
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
|
+
const distDir = path.join(packageDir, 'dist');
|
|
17
|
+
const mcpDir = path.join(distDir, 'mcp');
|
|
18
|
+
const mcpIndexPath = path.join(mcpDir, 'enterprise-proxy', 'index.js');
|
|
19
|
+
|
|
20
|
+
// Get version from package.json
|
|
21
|
+
function getVersion() {
|
|
22
|
+
try {
|
|
23
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8'));
|
|
24
|
+
return pkg.version;
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Follow redirects and download file
|
|
31
|
+
function download(url) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const request = https.get(url, { headers: { 'User-Agent': 'snow-flow-installer' } }, (response) => {
|
|
34
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
35
|
+
download(response.headers.location).then(resolve).catch(reject);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (response.statusCode !== 200) {
|
|
39
|
+
reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const chunks = [];
|
|
44
|
+
response.on('data', chunk => chunks.push(chunk));
|
|
45
|
+
response.on('end', () => resolve(Buffer.concat(chunks)));
|
|
46
|
+
response.on('error', reject);
|
|
47
|
+
});
|
|
48
|
+
request.on('error', reject);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function downloadBinary() {
|
|
53
|
+
const version = getVersion();
|
|
54
|
+
if (!version) {
|
|
55
|
+
console.log('Could not determine version, skipping binary download');
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const assetName = `snow-flow-${platform}-${arch}`;
|
|
60
|
+
const tarballName = `${assetName}.tar.gz`;
|
|
61
|
+
const releaseUrl = `https://github.com/groeimetai/snow-flow/releases/download/v${version}/${tarballName}`;
|
|
62
|
+
|
|
63
|
+
console.log(`Downloading snow-flow binary for ${platform}-${arch}...`);
|
|
64
|
+
console.log(`URL: ${releaseUrl}`);
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
// Download the tarball
|
|
68
|
+
const tarballData = await download(releaseUrl);
|
|
69
|
+
|
|
70
|
+
// Create temp file
|
|
71
|
+
const tmpDir = os.tmpdir();
|
|
72
|
+
const tarballPath = path.join(tmpDir, tarballName);
|
|
73
|
+
fs.writeFileSync(tarballPath, tarballData);
|
|
74
|
+
|
|
75
|
+
// Ensure bin directory exists
|
|
76
|
+
if (!fs.existsSync(binDir)) {
|
|
77
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Extract using tar command
|
|
81
|
+
console.log('Extracting binary...');
|
|
82
|
+
execSync(`tar -xzf "${tarballPath}" -C "${binDir}" --strip-components=1`, { stdio: 'pipe' });
|
|
83
|
+
|
|
84
|
+
// Clean up
|
|
85
|
+
fs.unlinkSync(tarballPath);
|
|
86
|
+
|
|
87
|
+
// Make executable on non-Windows
|
|
88
|
+
if (platform !== 'windows' && fs.existsSync(binaryPath)) {
|
|
89
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
console.log('✅ Binary installed successfully!');
|
|
93
|
+
return true;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.log(`Note: Could not download pre-built binary (${error.message})`);
|
|
96
|
+
console.log('You may need to build from source or check your network connection.');
|
|
97
|
+
return false;
|
|
14
98
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const mappedArch = archMap[arch];
|
|
23
|
-
if (!mappedArch) {
|
|
24
|
-
console.log(`Unknown architecture: ${arch}`);
|
|
25
|
-
process.exit(0);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function downloadMcpServers() {
|
|
102
|
+
const version = getVersion();
|
|
103
|
+
if (!version) {
|
|
104
|
+
console.log('Could not determine version, skipping MCP download');
|
|
105
|
+
return false;
|
|
26
106
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
107
|
+
|
|
108
|
+
const tarballName = 'snow-flow-mcp.tar.gz';
|
|
109
|
+
const releaseUrl = `https://github.com/groeimetai/snow-flow/releases/download/v${version}/${tarballName}`;
|
|
110
|
+
|
|
111
|
+
console.log('Downloading MCP servers...');
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
// Download the tarball
|
|
115
|
+
const tarballData = await download(releaseUrl);
|
|
116
|
+
|
|
117
|
+
// Create temp file
|
|
118
|
+
const tmpDir = os.tmpdir();
|
|
119
|
+
const tarballPath = path.join(tmpDir, tarballName);
|
|
120
|
+
fs.writeFileSync(tarballPath, tarballData);
|
|
121
|
+
|
|
122
|
+
// Ensure dist directory exists
|
|
123
|
+
if (!fs.existsSync(distDir)) {
|
|
124
|
+
fs.mkdirSync(distDir, { recursive: true });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Extract MCP servers
|
|
128
|
+
console.log('Extracting MCP servers...');
|
|
129
|
+
execSync(`tar -xzf "${tarballPath}" -C "${distDir}"`, { stdio: 'pipe' });
|
|
130
|
+
|
|
131
|
+
// Clean up
|
|
132
|
+
fs.unlinkSync(tarballPath);
|
|
133
|
+
|
|
134
|
+
console.log('✅ MCP servers installed successfully!');
|
|
135
|
+
return true;
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.log(`Note: Could not download MCP servers (${error.message})`);
|
|
138
|
+
console.log('Enterprise features may not be available.');
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function main() {
|
|
144
|
+
// Download binary if needed
|
|
145
|
+
if (!fs.existsSync(binaryPath)) {
|
|
146
|
+
await downloadBinary();
|
|
147
|
+
} else {
|
|
148
|
+
// Make sure it's executable
|
|
149
|
+
if (platform !== 'windows') {
|
|
150
|
+
try {
|
|
151
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
152
|
+
} catch {}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Download MCP servers if needed
|
|
157
|
+
if (!fs.existsSync(mcpIndexPath)) {
|
|
158
|
+
await downloadMcpServers();
|
|
35
159
|
}
|
|
36
|
-
} catch (error) {
|
|
37
|
-
// Silently fail - not critical
|
|
38
|
-
console.log('Note: Could not set binary permissions (non-critical)');
|
|
39
160
|
}
|
|
161
|
+
|
|
162
|
+
main().catch(err => {
|
|
163
|
+
console.log(`Postinstall failed: ${err.message}`);
|
|
164
|
+
});
|
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%
|
package/bunfig.toml
DELETED
package/script/postinstall.mjs
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from "fs"
|
|
4
|
-
import path from "path"
|
|
5
|
-
import os from "os"
|
|
6
|
-
import { fileURLToPath } from "url"
|
|
7
|
-
import { createRequire } from "module"
|
|
8
|
-
|
|
9
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
10
|
-
const require = createRequire(import.meta.url)
|
|
11
|
-
|
|
12
|
-
function detectPlatformAndArch() {
|
|
13
|
-
// Map platform names
|
|
14
|
-
let platform
|
|
15
|
-
switch (os.platform()) {
|
|
16
|
-
case "darwin":
|
|
17
|
-
platform = "darwin"
|
|
18
|
-
break
|
|
19
|
-
case "linux":
|
|
20
|
-
platform = "linux"
|
|
21
|
-
break
|
|
22
|
-
case "win32":
|
|
23
|
-
platform = "windows"
|
|
24
|
-
break
|
|
25
|
-
default:
|
|
26
|
-
platform = os.platform()
|
|
27
|
-
break
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Map architecture names
|
|
31
|
-
let arch
|
|
32
|
-
switch (os.arch()) {
|
|
33
|
-
case "x64":
|
|
34
|
-
arch = "x64"
|
|
35
|
-
break
|
|
36
|
-
case "arm64":
|
|
37
|
-
arch = "arm64"
|
|
38
|
-
break
|
|
39
|
-
case "arm":
|
|
40
|
-
arch = "arm"
|
|
41
|
-
break
|
|
42
|
-
default:
|
|
43
|
-
arch = os.arch()
|
|
44
|
-
break
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return { platform, arch }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function findBinary() {
|
|
51
|
-
const { platform, arch } = detectPlatformAndArch()
|
|
52
|
-
const packageName = `@groeimetai/snow-flow-${platform}-${arch}`
|
|
53
|
-
const binary = platform === "windows" ? "snow-code.exe" : "snow-code"
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
// Use require.resolve to find the package
|
|
57
|
-
const packageJsonPath = require.resolve(`${packageName}/package.json`)
|
|
58
|
-
const packageDir = path.dirname(packageJsonPath)
|
|
59
|
-
const binaryPath = path.join(packageDir, "bin", binary)
|
|
60
|
-
|
|
61
|
-
if (!fs.existsSync(binaryPath)) {
|
|
62
|
-
throw new Error(`Binary not found at ${binaryPath}`)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return binaryPath
|
|
66
|
-
} catch (error) {
|
|
67
|
-
throw new Error(`Could not find package ${packageName}: ${error.message}`)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async function regenerateWindowsCmdWrappers() {
|
|
72
|
-
console.log("Windows + npm detected: Forcing npm to rebuild bin links")
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
const { execSync } = require("child_process")
|
|
76
|
-
const pkgPath = path.join(__dirname, "..")
|
|
77
|
-
|
|
78
|
-
// npm_config_global is string | undefined
|
|
79
|
-
// if it exists, the value is true
|
|
80
|
-
const isGlobal = process.env.npm_config_global === "true" || pkgPath.includes(path.join("npm", "node_modules"))
|
|
81
|
-
|
|
82
|
-
// The npm rebuild command does 2 things - Execute lifecycle scripts and rebuild bin links
|
|
83
|
-
// We want to skip lifecycle scripts to avoid infinite loops, so we use --ignore-scripts
|
|
84
|
-
const cmd = `npm rebuild @groeimetai/snow-flow-snowcode --ignore-scripts${isGlobal ? " -g" : ""}`
|
|
85
|
-
const opts = {
|
|
86
|
-
stdio: "inherit",
|
|
87
|
-
shell: true,
|
|
88
|
-
...(isGlobal ? {} : { cwd: path.join(pkgPath, "..", "..") }), // For local, run from project root
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
console.log(`Running: ${cmd}`)
|
|
92
|
-
execSync(cmd, opts)
|
|
93
|
-
console.log("Successfully rebuilt npm bin links")
|
|
94
|
-
} catch (error) {
|
|
95
|
-
console.error("Error rebuilding npm links:", error.message)
|
|
96
|
-
console.error("npm rebuild failed. You may need to manually run: npm rebuild @groeimetai/snow-flow-snowcode --ignore-scripts")
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async function main() {
|
|
101
|
-
try {
|
|
102
|
-
if (os.platform() === "win32") {
|
|
103
|
-
// NPM eg format - npm/11.4.2 node/v24.4.1 win32 x64
|
|
104
|
-
// Bun eg format - bun/1.2.19 npm/? node/v24.3.0 win32 x64
|
|
105
|
-
if (process.env.npm_config_user_agent.startsWith("npm")) {
|
|
106
|
-
await regenerateWindowsCmdWrappers()
|
|
107
|
-
} else {
|
|
108
|
-
console.log("Windows detected but not npm, skipping postinstall")
|
|
109
|
-
}
|
|
110
|
-
return
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const binaryPath = findBinary()
|
|
114
|
-
const binScript = path.join(__dirname, "bin", "snow-code")
|
|
115
|
-
|
|
116
|
-
// Remove existing bin script if it exists
|
|
117
|
-
if (fs.existsSync(binScript)) {
|
|
118
|
-
fs.unlinkSync(binScript)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Create symlink to the actual binary
|
|
122
|
-
fs.symlinkSync(binaryPath, binScript)
|
|
123
|
-
console.log(`snow-code binary symlinked: ${binScript} -> ${binaryPath}`)
|
|
124
|
-
} catch (error) {
|
|
125
|
-
console.error("Failed to create snow-code binary symlink:", error.message)
|
|
126
|
-
process.exit(1)
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
try {
|
|
131
|
-
main()
|
|
132
|
-
} catch (error) {
|
|
133
|
-
console.error("Postinstall script error:", error.message)
|
|
134
|
-
process.exit(0)
|
|
135
|
-
}
|
package/script/preinstall.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from "fs"
|
|
4
|
-
import path from "path"
|
|
5
|
-
import os from "os"
|
|
6
|
-
import { fileURLToPath } from "url"
|
|
7
|
-
|
|
8
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
9
|
-
|
|
10
|
-
function main() {
|
|
11
|
-
if (os.platform() !== "win32") {
|
|
12
|
-
console.log("Non-Windows platform detected, skipping preinstall")
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
console.log("Windows detected: Modifying package.json bin entry")
|
|
17
|
-
|
|
18
|
-
// Read package.json
|
|
19
|
-
const packageJsonPath = path.join(__dirname, "package.json")
|
|
20
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"))
|
|
21
|
-
|
|
22
|
-
// Modify bin to point to .cmd file on Windows
|
|
23
|
-
packageJson.bin = {
|
|
24
|
-
"snow-code": "./bin/snowcode.cmd",
|
|
25
|
-
"snowcode": "./bin/snowcode.cmd",
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Write it back
|
|
29
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
|
|
30
|
-
console.log("Updated package.json bin to use snowcode.cmd")
|
|
31
|
-
|
|
32
|
-
// Now you can also remove the Unix script if you want
|
|
33
|
-
const unixScript = path.join(__dirname, "bin", "snow-code")
|
|
34
|
-
if (fs.existsSync(unixScript)) {
|
|
35
|
-
console.log("Removing Unix shell script")
|
|
36
|
-
fs.unlinkSync(unixScript)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
main()
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.error("Preinstall script error:", error.message)
|
|
44
|
-
process.exit(0)
|
|
45
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://opencode.ai/config.json",
|
|
3
|
-
"tui": {
|
|
4
|
-
"scroll_speed": 5
|
|
5
|
-
},
|
|
6
|
-
"mcp": {
|
|
7
|
-
"servicenow-unified": {
|
|
8
|
-
"type": "local",
|
|
9
|
-
"command": ["node", "dist/mcp/servicenow-mcp-unified/index.js"],
|
|
10
|
-
"environment": {
|
|
11
|
-
"SERVICENOW_INSTANCE_URL": "https://dev12345.service-now.com",
|
|
12
|
-
"SERVICENOW_CLIENT_ID": "your-client-id-here",
|
|
13
|
-
"SERVICENOW_CLIENT_SECRET": "your-client-secret-here",
|
|
14
|
-
"SERVICENOW_USERNAME": "your-username-here",
|
|
15
|
-
"SERVICENOW_PASSWORD": "your-password-here"
|
|
16
|
-
},
|
|
17
|
-
"enabled": true
|
|
18
|
-
},
|
|
19
|
-
"snow-flow-orchestration": {
|
|
20
|
-
"type": "local",
|
|
21
|
-
"command": ["node", "dist/mcp/snow-flow-mcp.js"],
|
|
22
|
-
"environment": {
|
|
23
|
-
"SNOW_FLOW_ENV": "production"
|
|
24
|
-
},
|
|
25
|
-
"enabled": true
|
|
26
|
-
},
|
|
27
|
-
"snow-flow-enterprise": {
|
|
28
|
-
"type": "local",
|
|
29
|
-
"command": ["node", "../snow-flow-enterprise/mcp-proxy/dist/enterprise-proxy.js"],
|
|
30
|
-
"description": "Enterprise integrations - Jira, Azure DevOps, Confluence (local proxy to remote server)",
|
|
31
|
-
"environment": {
|
|
32
|
-
"SNOW_ENTERPRISE_URL": "https://enterprise.snow-flow.dev",
|
|
33
|
-
"SNOW_LICENSE_KEY": ""
|
|
34
|
-
},
|
|
35
|
-
"enabled": false,
|
|
36
|
-
"_comment": "Run 'snow-flow auth login' to configure and enable this server"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|