capix-code 1.6.10 → 1.6.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capix-code",
3
- "version": "1.6.10",
3
+ "version": "1.6.11",
4
4
  "description": "Capix Code — decentralized AI coding agent with GPU marketplace",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -4,118 +4,97 @@ const fs = require('fs');
4
4
  const path = require('path');
5
5
  const os = require('os');
6
6
 
7
- if (process.env.CI || process.env.GITHUB_ACTIONS) {
8
- console.log('Skipping binary download in CI environment.');
9
- process.exit(0);
10
- }
7
+ if (process.env.CI || process.env.GITHUB_ACTIONS) { process.exit(0); }
11
8
 
12
9
  const VERSION = '1.6.3';
13
- const PLATFORM_MAP = { darwin: 'darwin', linux: 'linux', win32: 'win32' };
14
- const ARCH_MAP = { arm64: 'arm64', x64: 'x64' };
15
- const platform = PLATFORM_MAP[process.platform] || 'linux';
16
- const arch = ARCH_MAP[process.arch] || 'x64';
10
+ const plat = process.platform === 'win32' ? 'win32' : process.platform;
11
+ const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
17
12
  const ext = process.platform === 'win32' ? 'zip' : 'tar.gz';
18
- const NAME = `capix-code-${VERSION}-${platform}-${arch}-unsigned`;
19
- const RELEASE = `https://github.com/CapIX-Protocol/Capix-Code/releases/download/v${VERSION}/${NAME}.${ext}`;
20
-
21
- const installDir = path.join(os.homedir(), '.capix-code');
22
- const tmpDir = path.join(os.tmpdir(), 'capix-code-install');
13
+ const NAME = `capix-code-${VERSION}-${plat}-${arch}-unsigned`;
14
+ const URL = `https://github.com/CapIX-Protocol/Capix-Code/releases/download/v${VERSION}/${NAME}.${ext}`;
15
+ const ROOT = path.join(os.homedir(), '.capix-code');
16
+ const TMP = path.join(os.tmpdir(), 'capix-code-install');
23
17
 
24
- fs.mkdirSync(installDir, { recursive: true });
25
- fs.mkdirSync(tmpDir, { recursive: true });
18
+ fs.mkdirSync(ROOT, { recursive: true });
19
+ fs.mkdirSync(TMP, { recursive: true });
26
20
 
27
21
  try {
28
- console.log(`Downloading capix-code v${VERSION} (${platform}-${arch})...`);
29
- const archivePath = path.join(tmpDir, `${NAME}.${ext}`);
30
- execSync(`curl -fsSL -o "${archivePath}" "${RELEASE}"`, { stdio: 'inherit' });
22
+ console.log(`Downloading capix-code v${VERSION} (${plat}-${arch})...`);
23
+ execSync(`curl -fsSL -o "${TMP}/${NAME}.${ext}" "${URL}"`, { stdio: 'inherit' });
24
+ execSync(`tar -xzf "${TMP}/${NAME}.${ext}" -C "${TMP}"`, { stdio: 'inherit' });
31
25
 
32
- if (process.platform === 'win32') {
33
- execSync(`tar -xf "${archivePath}" -C "${tmpDir}"`, { stdio: 'inherit' });
34
- } else {
35
- execSync(`tar -xzf "${archivePath}" -C "${tmpDir}"`, { stdio: 'inherit' });
36
- }
37
-
38
- const customerSrc = path.join(tmpDir, 'customer');
39
- if (fs.existsSync(customerSrc)) {
26
+ const src = path.join(TMP, 'customer');
27
+ if (fs.existsSync(src)) {
40
28
  for (const dir of ['bin', 'engine', 'runtime', 'config', 'mcp']) {
41
- const src = path.join(customerSrc, dir);
42
- const dst = path.join(installDir, dir);
43
- if (fs.existsSync(src)) {
44
- execSync(`rm -rf "${dst}" && cp -a "${src}" "${dst}"`, { stdio: 'inherit' });
45
- }
46
- }
47
- const binPath = path.join(installDir, 'bin', 'capix-code');
48
- if (fs.existsSync(binPath)) {
49
- fs.chmodSync(binPath, 0o755);
29
+ const s = path.join(src, dir);
30
+ const d = path.join(ROOT, dir);
31
+ if (fs.existsSync(s)) execSync(`rm -rf "${d}" && cp -a "${s}" "${d}"`, { stdio: 'inherit' });
50
32
  }
33
+ fs.chmodSync(path.join(ROOT, 'bin', 'capix-code'), 0o755);
51
34
  }
52
35
 
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
- }
36
+ // Install runtime deps (typescript required by plugin.ts)
37
+ console.log('Installing runtime dependencies...');
38
+ execSync('npm install --omit=dev --ignore-scripts', { cwd: path.join(ROOT, 'runtime'), stdio: 'inherit' });
59
39
 
60
- // Install MCP dependencies if not already bundled
61
- const mcpDir = path.join(installDir, 'mcp');
62
- const mcpEntry = path.join(mcpDir, 'capix-mcp.js');
63
- if (!fs.existsSync(path.join(mcpDir, 'node_modules', '@modelcontextprotocol', 'sdk'))) {
40
+ // Install MCP deps if not bundled
41
+ const mcpDir = path.join(ROOT, 'mcp');
42
+ if (!fs.existsSync(path.join(mcpDir, 'node_modules', '@modelcontextprotocol'))) {
64
43
  console.log('Installing MCP dependencies...');
65
- execSync(`npm install capix-mcp@2.1.0`, { cwd: mcpDir, stdio: 'inherit' });
66
- // Create wrapper that shares credentials
67
- const mcpPkgPath = path.join(mcpDir, 'node_modules', 'capix-mcp', 'dist', 'index.js');
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
- }
44
+ execSync('npm install capix-mcp@2.1.0', { cwd: mcpDir, stdio: 'inherit' });
45
+ // Write MCP wrapper that does NOT refresh token (uses CAPIX_API_KEY from env)
46
+ fs.writeFileSync(path.join(mcpDir, 'capix-mcp.js'),
47
+ '#!/usr/bin/env node\n' +
48
+ 'const { join } = require("node:path");\n' +
49
+ 'const { homedir } = require("node:os");\n' +
50
+ 'require(join(homedir(), ".capix-code", "mcp", "node_modules", "capix-mcp", "dist", "index.js"));\n'
51
+ );
52
+ fs.chmodSync(path.join(mcpDir, 'capix-mcp.js'), 0o755);
104
53
  }
105
54
 
106
- // Sign binaries on macOS to prevent Gatekeeper kills
55
+ // Create config at the path the engine ACTUALLY reads
56
+ // The core package uses ~/.config/opencode/ (not capix-code)
57
+ const cfgDir = path.join(os.homedir(), '.config', 'opencode');
58
+ fs.mkdirSync(cfgDir, { recursive: true });
59
+ const rtDir = path.join(ROOT, 'runtime');
60
+ const providerUrl = `file://${rtDir}/packages/runtime-provider/src/index.ts`;
61
+ const apiBase = 'https://www.capix.network/api/v1';
62
+
63
+ const config = {
64
+ model: 'capix/auto',
65
+ enabled_providers: ['capix'],
66
+ plugin: [
67
+ path.join(rtDir, 'src', 'native-bridge.ts'),
68
+ path.join(rtDir, 'src', 'plugin.ts')
69
+ ],
70
+ provider: {
71
+ capix: {
72
+ npm: providerUrl,
73
+ name: 'Capix',
74
+ models: {
75
+ auto: {
76
+ name: 'Capix Auto (smart route)',
77
+ limit: { context: 128000, output: 64000 },
78
+ api: { url: apiBase, npm: providerUrl }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ };
84
+ fs.writeFileSync(path.join(cfgDir, 'capix-code.json'), JSON.stringify(config, null, 2));
85
+
86
+ // Sign on macOS
107
87
  if (process.platform === 'darwin') {
108
88
  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' });
89
+ execSync(`codesign --force --sign - "${path.join(ROOT, 'bin', 'capix-code')}"`, { stdio: 'ignore' });
90
+ execSync(`codesign --force --sign - "${path.join(ROOT, 'engine', 'capix-engine')}"`, { stdio: 'ignore' });
111
91
  } catch {}
112
92
  }
113
93
 
114
- fs.rmSync(tmpDir, { recursive: true, force: true });
115
- console.log(`✓ Capix Code v${VERSION} installed to ${installDir}`);
94
+ fs.rmSync(TMP, { recursive: true, force: true });
95
+ console.log(`✓ Capix Code v${VERSION} installed`);
116
96
  console.log('Run: capix-code login && capix-code');
117
97
  } catch (err) {
118
- console.warn(' Binary download failed. Download manually from:');
119
- console.warn(' https://github.com/CapIX-Protocol/Capix-Code/releases');
98
+ console.warn('Install failed. Download manually from https://github.com/CapIX-Protocol/Capix-Code/releases');
120
99
  process.exit(0);
121
100
  }