capix-code 2.0.0 → 2.1.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": "2.0.0",
3
+ "version": "2.1.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,33 +145,6 @@ 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
-
175
148
  "$DIR/scripts/assert-artifact.sh" "$ARTIFACT"
176
149
  "$DIR/scripts/assert-customer-brand.sh" "$ARTIFACT"
177
150
  echo "✓ Customer artifact staged: $ARTIFACT"
@@ -4,139 +4,61 @@ const fs = require('fs');
4
4
  const path = require('path');
5
5
  const os = require('os');
6
6
  const crypto = require('crypto');
7
-
8
7
  if (process.env.CI || process.env.GITHUB_ACTIONS) { process.exit(0); }
9
-
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
-
8
+ const VERSION = require('../package.json').version;
15
9
  const plat = process.platform === 'win32' ? 'win32' : process.platform;
16
10
  const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
17
11
  const ext = process.platform === 'win32' ? 'zip' : 'tar.gz';
18
12
  const NAME = `capix-code-${VERSION}-${plat}-${arch}-unsigned`;
19
13
  const URL = `https://github.com/CapIX-Protocol/Capix-Code/releases/download/v${VERSION}/${NAME}.${ext}`;
20
14
  const CHECKSUM_URL = `${URL}.sha256`;
21
-
22
15
  const ROOT = path.join(os.homedir(), '.capix-code');
23
- const TMP = path.join(os.tmpdir(), `capix-code-install-${VERSION}`);
16
+ const TMP = path.join(os.tmpdir(), `capix-install-${VERSION}`);
24
17
  const archivePath = path.join(TMP, `${NAME}.${ext}`);
25
-
26
18
  fs.mkdirSync(ROOT, { recursive: true });
27
19
  fs.mkdirSync(TMP, { recursive: true });
28
-
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
- }
57
-
58
- const src = path.join(TMP, 'customer');
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' });
71
- }
72
- fs.chmodSync(path.join(ROOT, 'bin', 'capix-code'), 0o755);
73
-
74
- // Install runtime deps (typescript required by plugin.ts)
75
- console.log('Installing runtime dependencies...');
76
- execSync('npm install --omit=dev --ignore-scripts', {
77
- cwd: path.join(ROOT, 'runtime'), stdio: 'inherit'
78
- });
79
-
80
- // Install MCP deps
81
- const mcpDir = path.join(ROOT, 'mcp');
82
- if (!fs.existsSync(path.join(mcpDir, 'node_modules', '@modelcontextprotocol'))) {
83
- console.log('Installing MCP dependencies...');
84
- execSync('npm install capix-mcp@2.1.0', { cwd: mcpDir, stdio: 'inherit' });
85
- fs.writeFileSync(path.join(mcpDir, 'capix-mcp.js'),
86
- '#!/usr/bin/env node\n' +
87
- 'const { join } = require("node:path");\n' +
88
- 'const { homedir } = require("node:os");\n' +
89
- 'require(join(homedir(), ".capix-code", "mcp", "node_modules", "capix-mcp", "dist", "index.js"));\n'
90
- );
91
- fs.chmodSync(path.join(mcpDir, 'capix-mcp.js'), 0o755);
92
- }
93
-
94
- // Write config to ~/.config/opencode/ (engine binary reads this path)
95
- const cfgDir = path.join(os.homedir(), '.config', 'opencode');
96
- fs.mkdirSync(cfgDir, { recursive: true });
97
- const rtDir = path.join(ROOT, 'runtime');
98
- const providerUrl = `file://${rtDir}/packages/runtime-provider/src/index.ts`;
99
- const apiBase = 'https://www.capix.network/api/v1';
100
- const config = {
101
- model: 'capix/auto',
102
- enabled_providers: ['capix'],
103
- plugin: [
104
- path.join(rtDir, 'src', 'native-bridge.ts'),
105
- path.join(rtDir, 'src', 'plugin.ts')
106
- ],
107
- provider: {
108
- capix: {
109
- npm: providerUrl,
110
- name: 'Capix',
111
- models: {
112
- auto: {
113
- name: 'Capix Auto (smart route)',
114
- limit: { context: 128000, output: 64000 },
115
- api: { url: apiBase, npm: providerUrl }
116
- }
117
- }
118
- }
119
- }
120
- };
121
- fs.writeFileSync(path.join(cfgDir, 'capix-code.json'), JSON.stringify(config, null, 2));
122
-
123
- // Sign on macOS
124
- if (process.platform === 'darwin') {
125
- try {
126
- execSync(`codesign --force --sign - "${path.join(ROOT, 'bin', 'capix-code')}"`, { stdio: 'ignore' });
127
- execSync(`codesign --force --sign - "${path.join(ROOT, 'engine', 'capix-engine')}"`, { stdio: 'ignore' });
128
- } catch {}
129
- }
130
-
131
- // Cleanup
132
- fs.rmSync(TMP, { recursive: true, force: true });
133
- if (fs.existsSync(backup)) fs.rmSync(backup, { recursive: true });
134
-
135
- console.log(`✓ Capix Code v${VERSION} installed`);
136
- console.log('Run: capix-code login && capix-code');
20
+ console.log(`Capix Code v${VERSION} (${plat}-${arch})`);
21
+ execSync(`curl -fsSL -o "${archivePath}" "${URL}"`, { stdio: 'inherit' });
22
+ const checksumPath = path.join(TMP, 'checksum.sha256');
23
+ execSync(`curl -fsSL -o "${checksumPath}" "${CHECKSUM_URL}"`, { stdio: 'inherit' });
24
+ const expected = fs.readFileSync(checksumPath, 'utf8').trim().split(/\s+/)[0];
25
+ const actual = crypto.createHash('sha256').update(fs.readFileSync(archivePath)).digest('hex');
26
+ if (expected !== actual) { console.error(`Checksum mismatch!`); process.exit(1); }
27
+ if (process.platform === 'win32') { execSync(`tar -xf "${archivePath}" -C "${TMP}"`, { stdio: 'inherit' }); }
28
+ else { execSync(`tar -xzf "${archivePath}" -C "${TMP}"`, { stdio: 'inherit' }); }
29
+ const src = path.join(TMP, 'customer');
30
+ if (!fs.existsSync(src)) { console.error('Missing customer/'); process.exit(1); }
31
+ const backup = ROOT + '.bak';
32
+ if (fs.existsSync(backup)) fs.rmSync(backup, { recursive: true });
33
+ if (fs.existsSync(ROOT)) fs.renameSync(ROOT, backup);
34
+ fs.mkdirSync(ROOT, { recursive: true });
35
+ for (const dir of ['bin', 'engine', 'runtime', 'config', 'mcp']) {
36
+ const s = path.join(src, dir);
37
+ if (fs.existsSync(s)) execSync(`cp -a "${s}" "${path.join(ROOT, dir)}"`, { stdio: 'inherit' });
38
+ }
39
+ fs.chmodSync(path.join(ROOT, 'bin', 'capix-code'), 0o755);
40
+ console.log('Installing runtime deps...');
41
+ execSync('npm install --omit=dev --ignore-scripts', { cwd: path.join(ROOT, 'runtime'), stdio: 'inherit' });
42
+ const mcpDir = path.join(ROOT, 'mcp');
43
+ if (!fs.existsSync(path.join(mcpDir, 'node_modules', '@modelcontextprotocol'))) {
44
+ console.log('Installing MCP deps...');
45
+ execSync('npm install capix-mcp@2.1.0', { cwd: mcpDir, stdio: 'inherit' });
46
+ fs.writeFileSync(path.join(mcpDir, 'capix-mcp.js'), '#!/usr/bin/env node\nconst{join}=require("node:path");const{homedir}=require("node:os");require(join(homedir(),".capix-code","mcp","node_modules","capix-mcp","dist","index.js"));\n');
47
+ fs.chmodSync(path.join(mcpDir, 'capix-mcp.js'), 0o755);
48
+ }
49
+ const cfgDir = path.join(os.homedir(), '.config', 'opencode');
50
+ fs.mkdirSync(cfgDir, { recursive: true });
51
+ const rt = path.join(ROOT, 'runtime');
52
+ const pu = `file://${rt}/packages/runtime-provider/src/index.ts`;
53
+ fs.writeFileSync(path.join(cfgDir, 'capix-code.json'), JSON.stringify({
54
+ model: 'capix/auto', enabled_providers: ['capix'],
55
+ plugin: [path.join(rt, 'src', 'native-bridge.ts'), path.join(rt, 'src', 'plugin.ts')],
56
+ provider: { capix: { npm: pu, name: 'Capix', models: { auto: { name: 'Capix Auto', limit: { context: 128000, output: 64000 }, api: { url: 'https://www.capix.network/api/v1', npm: pu } } } } }
57
+ }, null, 2));
58
+ if (process.platform === 'darwin') {
59
+ try { execSync(`codesign --force --sign - "${path.join(ROOT, 'bin', 'capix-code')}"`, { stdio: 'ignore' }); } catch {}
60
+ try { execSync(`codesign --force --sign - "${path.join(ROOT, 'engine', 'capix-engine')}"`, { stdio: 'ignore' }); } catch {}
137
61
  }
138
-
139
- main().catch(err => {
140
- console.error('Installation failed:', err.message);
141
- process.exit(1);
142
- });
62
+ fs.rmSync(TMP, { recursive: true, force: true });
63
+ if (fs.existsSync(backup)) fs.rmSync(backup, { recursive: true });
64
+ console.log(`Capix Code v${VERSION} installed. Run: capix-code login && capix-code`);
@@ -215,34 +215,20 @@ 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
218
 
235
- # 6d. Fix home/footer.tsx and tips-view.tsx
236
- for fixfile in \
219
+ # 6c. Fix split-span: <b>Open</b><b>Code</b> → <b>Capix Code</b>
220
+ for file in \
221
+ "$CAPIX_CODE_DIR/packages/tui/src/routes/session/sidebar.tsx" \
222
+ "$CAPIX_CODE_DIR/packages/tui/src/feature-plugins/sidebar/footer.tsx" \
237
223
  "$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)"
224
+ "$CAPIX_CODE_DIR/packages/tui/src/feature-plugins/home/tips-view.tsx"; do
225
+ if [ -f "$file" ]; then
226
+ perl -0pi.bak -e 's/<b>Open<\/b>\s*\n\s*<b>Code<\/b>/<b>Capix Code<\/b>/gs' "$file"
227
+ perl -0pi.bak -e 's/OpenCode/Capix Code/g' "$file"
228
+ rm -f "$file.bak"
244
229
  fi
245
230
  done
231
+ echo " ✓ split-span branding fixed"
246
232
 
247
233
  # 7. Install script references.
248
234
  INSTALL="$CAPIX_CODE_DIR/install"
@@ -257,4 +243,72 @@ fi
257
243
 
258
244
  echo "✓ Rebrand complete. Only the binary name, config dirs, and env vars are rebranded."
259
245
  echo " Runtime plugin/provider are staged by scripts/build.sh and verified fail-closed."
246
+ # ── Standalone binary integration ──────────────────────────────────────
247
+ # Copy our source files into the upstream's capix-code package so they
248
+ # are compiled INTO the binary by Bun. This makes the binary truly
249
+ # standalone — no external .ts files, tsconfig, or typescript needed
250
+ # for the core provider.
251
+
252
+ echo "▸ Integrating Capix provider into upstream source tree…"
253
+
254
+ # Copy our src/*.ts files into the upstream's capix-code/src/
255
+ for file in \
256
+ ai-sdk-provider.ts broker.ts capix-provider.ts credential-constants.ts \
257
+ intelligence-client.ts logger.ts mcp-supervisor.ts native-bridge.ts \
258
+ plugin.ts sandbox.ts url-builder.ts; do
259
+ if [ -f "$DIR/src/$file" ]; then
260
+ cp "$DIR/src/$file" "$CAPIX_CODE_DIR/packages/capix-code/src/$file"
261
+ fi
262
+ done
263
+
264
+ # Copy planner subdir
265
+ if [ -d "$DIR/src/planner" ]; then
266
+ mkdir -p "$CAPIX_CODE_DIR/packages/capix-code/src/planner"
267
+ cp -R "$DIR/src/planner/"* "$CAPIX_CODE_DIR/packages/capix-code/src/planner/"
268
+ fi
269
+
270
+ # Copy our runtime-provider package
271
+ mkdir -p "$CAPIX_CODE_DIR/packages/runtime-provider/src"
272
+ cp "$DIR/packages/runtime-provider/package.json" "$CAPIX_CODE_DIR/packages/runtime-provider/package.json"
273
+ cp "$DIR/packages/runtime-provider/src/index.ts" "$CAPIX_CODE_DIR/packages/runtime-provider/src/index.ts"
274
+
275
+ # Add @capix/runtime-provider to the upstream's workspace
276
+ UPSTREAM_PKG="$CAPIX_CODE_DIR/package.json"
277
+ if [ -f "$UPSTREAM_PKG" ]; then
278
+ if ! grep -q "runtime-provider" "$UPSTREAM_PKG"; then
279
+ sed -i.bak 's|"packages/capix-code"|"packages/capix-code",\n "packages/runtime-provider"|' "$UPSTREAM_PKG"
280
+ rm -f "$UPSTREAM_PKG.bak"
281
+ fi
282
+ fi
283
+
284
+ # Add @capix/runtime-provider to BUNDLED_PROVIDERS in provider.ts
285
+ PROVIDER_TS="$CAPIX_CODE_DIR/packages/capix-code/src/provider/provider.ts"
286
+ if [ -f "$PROVIDER_TS" ] && ! grep -q "capix/runtime-provider" "$PROVIDER_TS"; then
287
+ sed -i.bak 's|const BUNDLED_PROVIDERS: Record<string, () => Promise<(opts: any) => BundledSDK>> = {|const BUNDLED_PROVIDERS: Record<string, () => Promise<(opts: any) => BundledSDK>> = {\n "@capix/runtime-provider": () => import("@capix/runtime-provider").then((m) => m.createCapix),|' "$PROVIDER_TS"
288
+ rm -f "$PROVIDER_TS.bak"
289
+ fi
290
+
291
+ # The @ai-sdk/provider import in runtime-provider needs to resolve
292
+ # from the upstream's node_modules. Add it to the workspace deps.
293
+ RT_PKG="$CAPIX_CODE_DIR/packages/runtime-provider/package.json"
294
+ if [ -f "$RT_PKG" ]; then
295
+ # Change export path to work from upstream context
296
+ cat > "$RT_PKG" << 'RTPKG'
297
+ {
298
+ "name": "@capix/runtime-provider",
299
+ "version": "0.1.0",
300
+ "private": true,
301
+ "type": "module",
302
+ "exports": "./src/index.ts",
303
+ "dependencies": {
304
+ "@ai-sdk/provider": "3.0.8"
305
+ }
306
+ }
307
+ RTPKG
308
+ fi
309
+
310
+ echo " ✓ Capix provider integrated into source tree"
311
+
312
+ # ── End standalone integration ────────────────────────────────────────
313
+
260
314
  "$DIR/scripts/assert-upstream-brand.sh" "$CAPIX_CODE_DIR"