capix-code 1.6.8 → 1.6.10
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/package.json +1 -1
- package/scripts/postinstall.cjs +57 -50
package/package.json
CHANGED
package/scripts/postinstall.cjs
CHANGED
|
@@ -9,7 +9,7 @@ if (process.env.CI || process.env.GITHUB_ACTIONS) {
|
|
|
9
9
|
process.exit(0);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const VERSION = '1.6.
|
|
12
|
+
const VERSION = '1.6.3';
|
|
13
13
|
const PLATFORM_MAP = { darwin: 'darwin', linux: 'linux', win32: 'win32' };
|
|
14
14
|
const ARCH_MAP = { arm64: 'arm64', x64: 'x64' };
|
|
15
15
|
const platform = PLATFORM_MAP[process.platform] || 'linux';
|
|
@@ -37,11 +37,11 @@ try {
|
|
|
37
37
|
|
|
38
38
|
const customerSrc = path.join(tmpDir, 'customer');
|
|
39
39
|
if (fs.existsSync(customerSrc)) {
|
|
40
|
-
for (const dir of ['bin', 'engine', 'runtime', 'config']) {
|
|
40
|
+
for (const dir of ['bin', 'engine', 'runtime', 'config', 'mcp']) {
|
|
41
41
|
const src = path.join(customerSrc, dir);
|
|
42
42
|
const dst = path.join(installDir, dir);
|
|
43
43
|
if (fs.existsSync(src)) {
|
|
44
|
-
execSync(`cp -a "${src}" "${dst}"`, { stdio: 'inherit' });
|
|
44
|
+
execSync(`rm -rf "${dst}" && cp -a "${src}" "${dst}"`, { stdio: 'inherit' });
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
const binPath = path.join(installDir, 'bin', 'capix-code');
|
|
@@ -50,63 +50,70 @@ try {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
// Install
|
|
53
|
+
// Install runtime dependencies (typescript is required by plugin.ts)
|
|
54
|
+
const runtimeDir = path.join(installDir, 'runtime');
|
|
55
|
+
if (fs.existsSync(path.join(runtimeDir, 'package.json'))) {
|
|
56
|
+
console.log('Installing runtime dependencies...');
|
|
57
|
+
execSync(`npm install --omit=dev --ignore-scripts`, { cwd: runtimeDir, stdio: 'inherit' });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Install MCP dependencies if not already bundled
|
|
54
61
|
const mcpDir = path.join(installDir, 'mcp');
|
|
55
62
|
const mcpEntry = path.join(mcpDir, 'capix-mcp.js');
|
|
56
|
-
if (!fs.existsSync(
|
|
57
|
-
console.log('Installing
|
|
58
|
-
fs.mkdirSync(mcpDir, { recursive: true });
|
|
63
|
+
if (!fs.existsSync(path.join(mcpDir, 'node_modules', '@modelcontextprotocol', 'sdk'))) {
|
|
64
|
+
console.log('Installing MCP dependencies...');
|
|
59
65
|
execSync(`npm install capix-mcp@2.1.0`, { cwd: mcpDir, stdio: 'inherit' });
|
|
60
|
-
// Create
|
|
66
|
+
// Create wrapper that shares credentials
|
|
61
67
|
const mcpPkgPath = path.join(mcpDir, 'node_modules', 'capix-mcp', 'dist', 'index.js');
|
|
62
|
-
fs.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
68
|
+
if (!fs.existsSync(mcpEntry)) {
|
|
69
|
+
fs.writeFileSync(mcpEntry,
|
|
70
|
+
'#!/usr/bin/env node\n' +
|
|
71
|
+
'const { readFileSync, writeFileSync, chmodSync, existsSync } = require("node:fs");\n' +
|
|
72
|
+
'const { join } = require("node:path");\n' +
|
|
73
|
+
'const { homedir } = require("node:os");\n' +
|
|
74
|
+
'const credPath = join(homedir(), ".capix-code", "credentials.json");\n' +
|
|
75
|
+
'async function loadMcp() {\n' +
|
|
76
|
+
' require(join(homedir(), ".capix-code", "mcp", "node_modules", "capix-mcp", "dist", "index.js"));\n' +
|
|
77
|
+
'}\n' +
|
|
78
|
+
'(async () => {\n' +
|
|
79
|
+
' try {\n' +
|
|
80
|
+
' if (existsSync(credPath)) {\n' +
|
|
81
|
+
' const creds = JSON.parse(readFileSync(credPath, "utf8"));\n' +
|
|
82
|
+
' const rt = creds["capix-code:oauth-refresh-token"];\n' +
|
|
83
|
+
' if (rt) {\n' +
|
|
84
|
+
' const res = await fetch("https://www.capix.network/oauth/token", {\n' +
|
|
85
|
+
' method: "POST",\n' +
|
|
86
|
+
' headers: { "Content-Type": "application/x-www-form-urlencoded" },\n' +
|
|
87
|
+
' body: new URLSearchParams({ grant_type: "refresh_token", refresh_token: rt, client_id: "capix-code" }).toString(),\n' +
|
|
88
|
+
' });\n' +
|
|
89
|
+
' const body = await res.json();\n' +
|
|
90
|
+
' if (body.access_token) {\n' +
|
|
91
|
+
' process.env.CAPIX_API_KEY = body.access_token;\n' +
|
|
92
|
+
' creds["capix-code:oauth-refresh-token"] = body.refresh_token;\n' +
|
|
93
|
+
' writeFileSync(credPath, JSON.stringify(creds, null, 2), { mode: 0o600 });\n' +
|
|
94
|
+
' chmodSync(credPath, 0o600);\n' +
|
|
95
|
+
' }\n' +
|
|
96
|
+
' }\n' +
|
|
97
|
+
' }\n' +
|
|
98
|
+
' } catch {}\n' +
|
|
99
|
+
' loadMcp();\n' +
|
|
100
|
+
'})();\n'
|
|
101
|
+
);
|
|
102
|
+
fs.chmodSync(mcpEntry, 0o755);
|
|
103
|
+
}
|
|
98
104
|
}
|
|
99
105
|
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
// Sign binaries on macOS to prevent Gatekeeper kills
|
|
107
|
+
if (process.platform === 'darwin') {
|
|
108
|
+
try {
|
|
109
|
+
execSync(`codesign --force --sign - "${path.join(installDir, 'bin', 'capix-code')}"`, { stdio: 'ignore' });
|
|
110
|
+
execSync(`codesign --force --sign - "${path.join(installDir, 'engine', 'capix-engine')}"`, { stdio: 'ignore' });
|
|
111
|
+
} catch {}
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
108
115
|
console.log(`✓ Capix Code v${VERSION} installed to ${installDir}`);
|
|
109
|
-
console.log('Run: capix-code
|
|
116
|
+
console.log('Run: capix-code login && capix-code');
|
|
110
117
|
} catch (err) {
|
|
111
118
|
console.warn('⚠ Binary download failed. Download manually from:');
|
|
112
119
|
console.warn(' https://github.com/CapIX-Protocol/Capix-Code/releases');
|