capix-code 1.6.11 → 2.0.0

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.11",
3
+ "version": "2.0.0",
4
4
  "description": "Capix Code — decentralized AI coding agent with GPU marketplace",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/scripts/build.sh CHANGED
@@ -145,6 +145,33 @@ MCPWRAPPER
145
145
  cp "$DIR/launcher/target/release/capix-code$EXE_SUFFIX" "$ARTIFACT/bin/capix-code$EXE_SUFFIX"
146
146
  chmod 0755 "$ARTIFACT/bin/capix-code$EXE_SUFFIX"
147
147
 
148
+ # Write a startup config to the path the engine binary actually reads.
149
+ # The engine's core package uses ~/.config/opencode/ (not capix-code)
150
+ # because the core was not rebranded. The launcher overwrites this at
151
+ # runtime from the defaults.json, but having it pre-populated helps
152
+ # when running the engine directly for testing.
153
+ mkdir -p "$ARTIFACT/config/opencode"
154
+ cat > "$ARTIFACT/config/opencode/capix-code.json" << 'OCJSON'
155
+ {
156
+ "model": "capix/auto",
157
+ "enabled_providers": ["capix"],
158
+ "plugin": ["__RUNTIME_DIR__/src/native-bridge.ts", "__RUNTIME_DIR__/src/plugin.ts"],
159
+ "provider": {
160
+ "capix": {
161
+ "npm": "__PROVIDER_URL__",
162
+ "name": "Capix",
163
+ "models": {
164
+ "auto": {
165
+ "name": "Capix Auto (smart route)",
166
+ "limit": {"context": 128000, "output": 64000},
167
+ "api": {"url": "https://www.capix.network/api/v1", "npm": "__PROVIDER_URL__"}
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
173
+ OCJSON
174
+
148
175
  "$DIR/scripts/assert-artifact.sh" "$ARTIFACT"
149
176
  "$DIR/scripts/assert-customer-brand.sh" "$ARTIFACT"
150
177
  echo "✓ Customer artifact staged: $ARTIFACT"
@@ -3,46 +3,85 @@ const { execSync } = require('child_process');
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
5
  const os = require('os');
6
+ const crypto = require('crypto');
6
7
 
7
8
  if (process.env.CI || process.env.GITHUB_ACTIONS) { process.exit(0); }
8
9
 
9
- const VERSION = '1.6.3';
10
+ // Derive version from our own package metadata — never hardcode
11
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
12
+ const VERSION = pkg.version;
13
+ if (!VERSION) { console.error('Cannot determine version from package.json'); process.exit(1); }
14
+
10
15
  const plat = process.platform === 'win32' ? 'win32' : process.platform;
11
16
  const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
12
17
  const ext = process.platform === 'win32' ? 'zip' : 'tar.gz';
13
18
  const NAME = `capix-code-${VERSION}-${plat}-${arch}-unsigned`;
14
19
  const URL = `https://github.com/CapIX-Protocol/Capix-Code/releases/download/v${VERSION}/${NAME}.${ext}`;
20
+ const CHECKSUM_URL = `${URL}.sha256`;
21
+
15
22
  const ROOT = path.join(os.homedir(), '.capix-code');
16
- const TMP = path.join(os.tmpdir(), 'capix-code-install');
23
+ const TMP = path.join(os.tmpdir(), `capix-code-install-${VERSION}`);
24
+ const archivePath = path.join(TMP, `${NAME}.${ext}`);
17
25
 
18
26
  fs.mkdirSync(ROOT, { recursive: true });
19
27
  fs.mkdirSync(TMP, { recursive: true });
20
28
 
21
- try {
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' });
29
+ async function main() {
30
+ console.log(`Capix Code v${VERSION} (${plat}-${arch})`);
31
+
32
+ // Download artifact
33
+ console.log('Downloading...');
34
+ execSync(`curl -fsSL -o "${archivePath}" "${URL}"`, { stdio: 'inherit' });
35
+
36
+ // Download and verify checksum
37
+ console.log('Verifying checksum...');
38
+ const checksumPath = path.join(TMP, `${NAME}.${ext}.sha256`);
39
+ execSync(`curl -fsSL -o "${checksumPath}" "${CHECKSUM_URL}"`, { stdio: 'inherit' });
40
+
41
+ const expected = fs.readFileSync(checksumPath, 'utf8').trim().split(/\s+/)[0];
42
+ const actual = crypto.createHash('sha256').update(fs.readFileSync(archivePath)).digest('hex');
43
+
44
+ if (expected !== actual) {
45
+ console.error(`Checksum mismatch: expected ${expected}, got ${actual}`);
46
+ process.exit(1);
47
+ }
48
+ console.log('Checksum OK');
49
+
50
+ // Extract
51
+ console.log('Extracting...');
52
+ if (process.platform === 'win32') {
53
+ execSync(`tar -xf "${archivePath}" -C "${TMP}"`, { stdio: 'inherit' });
54
+ } else {
55
+ execSync(`tar -xzf "${archivePath}" -C "${TMP}"`, { stdio: 'inherit' });
56
+ }
25
57
 
26
58
  const src = path.join(TMP, 'customer');
27
- if (fs.existsSync(src)) {
28
- for (const dir of ['bin', 'engine', 'runtime', 'config', 'mcp']) {
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' });
32
- }
33
- fs.chmodSync(path.join(ROOT, 'bin', 'capix-code'), 0o755);
59
+ if (!fs.existsSync(src)) { console.error('Artifact missing customer/'); process.exit(1); }
60
+
61
+ // Atomic replace
62
+ const backup = ROOT + '.bak';
63
+ if (fs.existsSync(backup)) fs.rmSync(backup, { recursive: true });
64
+ if (fs.existsSync(ROOT)) fs.renameSync(ROOT, backup);
65
+ fs.mkdirSync(ROOT, { recursive: true });
66
+
67
+ for (const dir of ['bin', 'engine', 'runtime', 'config', 'mcp']) {
68
+ const s = path.join(src, dir);
69
+ const d = path.join(ROOT, dir);
70
+ if (fs.existsSync(s)) execSync(`cp -a "${s}" "${d}"`, { stdio: 'inherit' });
34
71
  }
72
+ fs.chmodSync(path.join(ROOT, 'bin', 'capix-code'), 0o755);
35
73
 
36
74
  // Install runtime deps (typescript required by plugin.ts)
37
75
  console.log('Installing runtime dependencies...');
38
- execSync('npm install --omit=dev --ignore-scripts', { cwd: path.join(ROOT, 'runtime'), stdio: 'inherit' });
76
+ execSync('npm install --omit=dev --ignore-scripts', {
77
+ cwd: path.join(ROOT, 'runtime'), stdio: 'inherit'
78
+ });
39
79
 
40
- // Install MCP deps if not bundled
80
+ // Install MCP deps
41
81
  const mcpDir = path.join(ROOT, 'mcp');
42
82
  if (!fs.existsSync(path.join(mcpDir, 'node_modules', '@modelcontextprotocol'))) {
43
83
  console.log('Installing MCP dependencies...');
44
84
  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
85
  fs.writeFileSync(path.join(mcpDir, 'capix-mcp.js'),
47
86
  '#!/usr/bin/env node\n' +
48
87
  'const { join } = require("node:path");\n' +
@@ -52,14 +91,12 @@ try {
52
91
  fs.chmodSync(path.join(mcpDir, 'capix-mcp.js'), 0o755);
53
92
  }
54
93
 
55
- // Create config at the path the engine ACTUALLY reads
56
- // The core package uses ~/.config/opencode/ (not capix-code)
94
+ // Write config to ~/.config/opencode/ (engine binary reads this path)
57
95
  const cfgDir = path.join(os.homedir(), '.config', 'opencode');
58
96
  fs.mkdirSync(cfgDir, { recursive: true });
59
97
  const rtDir = path.join(ROOT, 'runtime');
60
98
  const providerUrl = `file://${rtDir}/packages/runtime-provider/src/index.ts`;
61
99
  const apiBase = 'https://www.capix.network/api/v1';
62
-
63
100
  const config = {
64
101
  model: 'capix/auto',
65
102
  enabled_providers: ['capix'],
@@ -91,10 +128,15 @@ try {
91
128
  } catch {}
92
129
  }
93
130
 
131
+ // Cleanup
94
132
  fs.rmSync(TMP, { recursive: true, force: true });
133
+ if (fs.existsSync(backup)) fs.rmSync(backup, { recursive: true });
134
+
95
135
  console.log(`✓ Capix Code v${VERSION} installed`);
96
136
  console.log('Run: capix-code login && capix-code');
97
- } catch (err) {
98
- console.warn('Install failed. Download manually from https://github.com/CapIX-Protocol/Capix-Code/releases');
99
- process.exit(0);
100
137
  }
138
+
139
+ main().catch(err => {
140
+ console.error('Installation failed:', err.message);
141
+ process.exit(1);
142
+ });
@@ -215,6 +215,34 @@ for relative in "${PRESENTATION_FILES[@]}"; do
215
215
  rm -f "$file.bak"
216
216
  done
217
217
  echo " ✓ terminal title, splash, logo and customer command copy replaced"
218
+ # 6c. Fix split-span rendering: <b>Open</b>\n<b>Code</b> → Capix Code
219
+ echo "▸ Fixing split-span branding in sidebar/footer…"
220
+ SIDEBAR_FILES=(
221
+ "$CAPIX_CODE_DIR/packages/tui/src/routes/session/sidebar.tsx"
222
+ "$CAPIX_CODE_DIR/packages/tui/src/feature-plugins/sidebar/footer.tsx"
223
+ )
224
+ for file in "${SIDEBAR_FILES[@]}"; do
225
+ if [ -f "$file" ]; then
226
+ perl -0pi.bak -e 's|<b>Open</b>\s*\n\s*\s*<b>Code</b>|<b>Capix Code</b>|gs' "$file"
227
+ perl -0pi.bak -e 's|<b>Open</b>\s*\n\s*<b>Code</b>|<b>Capix Code</b>|gs' "$file"
228
+ perl -0pi.bak -e 's|<b>Open</b>|<b>Capix Code</b>|g' "$file"
229
+ perl -0pi.bak -e 's|<b>Code</b>||g' "$file"
230
+ rm -f "$file.bak"
231
+ echo " ✓ Fixed split-span in $(basename $file)"
232
+ fi
233
+ done
234
+
235
+ # 6d. Fix home/footer.tsx and tips-view.tsx
236
+ for fixfile in \
237
+ "$CAPIX_CODE_DIR/packages/tui/src/feature-plugins/home/footer.tsx" \
238
+ "$CAPIX_CODE_DIR/packages/tui/src/feature-plugins/home/tips-view.tsx"
239
+ do
240
+ if [ -f "$fixfile" ]; then
241
+ sed -i.bak 's/OpenCode/Capix Code/g' "$fixfile"
242
+ rm -f "$fixfile.bak"
243
+ echo " ✓ Fixed $(basename $fixfile)"
244
+ fi
245
+ done
218
246
 
219
247
  # 7. Install script references.
220
248
  INSTALL="$CAPIX_CODE_DIR/install"