capix-code 1.4.1 → 1.4.3

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.
@@ -2,27 +2,38 @@
2
2
 
3
3
  const { spawnSync } = require('node:child_process');
4
4
  const { chmodSync, cpSync, existsSync, mkdirSync } = require('node:fs');
5
- const { dirname, join } = require('node:path');
5
+ const { join } = require('node:path');
6
6
 
7
- const platform = process.platform === 'win32' ? 'windows' : process.platform;
8
- const packageName = `@capix-code/${platform}-${process.arch}`;
9
- let root;
7
+ const suffix = process.platform === 'win32' ? '.exe' : '';
10
8
 
11
- try {
12
- root = join(dirname(require.resolve(`${packageName}/package.json`)), 'customer');
13
- } catch {
14
- const developmentRoot = join(__dirname, '..', 'dist', 'customer');
15
- if (existsSync(developmentRoot)) root = developmentRoot;
9
+ // Look for the customer runtime in these locations:
10
+ // 1. npm global install: node_modules/capix-code/dist/customer
11
+ // 2. Local dev: dist/customer
12
+ // 3. Home directory: ~/.capix-code (from postinstall binary download)
13
+ const { homedir } = require('node:os');
14
+ const candidates = [
15
+ join(__dirname, '..', 'dist', 'customer'),
16
+ join(homedir(), '.capix-code'),
17
+ ];
18
+
19
+ let root = null;
20
+ for (const candidate of candidates) {
21
+ const launcher = join(candidate, 'bin', `capix-code${suffix}`);
22
+ if (existsSync(launcher)) {
23
+ root = candidate;
24
+ break;
25
+ }
16
26
  }
17
27
 
18
28
  if (!root) {
19
- console.error(`Capix Code does not have a runtime for ${process.platform}-${process.arch}.`);
20
- console.error(`Reinstall capix-code and ensure ${packageName} is available.`);
29
+ console.error('Capix Code installation is incomplete. Reinstall the package and try again.');
30
+ console.error('If this persists, download the full binary from:');
31
+ console.error(' https://github.com/CapIX-Protocol/Capix-Code/releases');
21
32
  process.exit(1);
22
33
  }
23
34
 
24
- const suffix = process.platform === 'win32' ? '.exe' : '';
25
35
  const launcher = join(root, 'bin', `capix-code${suffix}`);
36
+ const engine = join(root, 'engine', `capix-engine${suffix}`);
26
37
 
27
38
  if (!existsSync(launcher)) {
28
39
  console.error('Capix Code installation is incomplete. Reinstall the package and try again.');
@@ -31,14 +42,14 @@ if (!existsSync(launcher)) {
31
42
 
32
43
  try {
33
44
  const runtimeProvider = join(root, 'runtime', 'node_modules', '@capix', 'runtime-provider');
34
- if (!existsSync(runtimeProvider)) {
45
+ if (!existsSync(runtimeProvider) && existsSync(join(root, 'runtime', 'packages', 'runtime-provider'))) {
35
46
  mkdirSync(join(root, 'runtime', 'node_modules', '@capix'), { recursive: true });
36
47
  cpSync(join(root, 'runtime', 'packages', 'runtime-provider'), runtimeProvider, {
37
48
  recursive: true,
38
49
  });
39
50
  }
40
51
  chmodSync(launcher, 0o755);
41
- chmodSync(join(root, 'engine', `capix-engine${suffix}`), 0o755);
52
+ if (existsSync(engine)) chmodSync(engine, 0o755);
42
53
  } catch (error) {
43
54
  console.error(`Capix Code could not prepare its native runtime: ${error.message}`);
44
55
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capix-code",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Capix Code — decentralized AI coding agent with GPU marketplace",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -43,7 +43,12 @@
43
43
  "prettier": "^3.0.0",
44
44
  "typescript": "^5.7.0",
45
45
  "typescript-eslint": "^8.0.0",
46
- "vitest": "^2.1.0"
46
+ "vitest": "^2.1.0",
47
+ "@capix/runtime-provider": "file:packages/runtime-provider",
48
+ "@opencode-ai/plugin": "1.17.18",
49
+ "@opencode-ai/sdk": "1.17.18",
50
+ "bun": "^1.3.14",
51
+ "opencode-ai": "1.17.18"
47
52
  },
48
53
  "lint-staged": {
49
54
  "*.{ts,js}": [
@@ -10,27 +10,56 @@ if (process.env.CI || process.env.GITHUB_ACTIONS) {
10
10
  process.exit(0);
11
11
  }
12
12
 
13
- const PLATFORM = process.platform === 'darwin' ? 'darwin' : 'linux';
14
- const ARCH = process.arch === 'arm64' ? 'arm64' : 'x64';
15
- const VERSION = '1.3.0';
16
- const RELEASE = 'https://github.com/CapIX-Protocol/CapIX-Code/releases/download/v' + VERSION;
13
+ const VERSION = '1.4.2';
14
+ const PLATFORM_MAP = { darwin: 'darwin', linux: 'linux', win32: 'win32' };
15
+ const ARCH_MAP = { arm64: 'arm64', x64: 'x64' };
16
+ const platform = PLATFORM_MAP[process.platform] || 'linux';
17
+ const arch = ARCH_MAP[process.arch] || 'x64';
18
+ const ext = process.platform === 'win32' ? 'zip' : 'tar.gz';
19
+ const NAME = `capix-code-${VERSION}-${platform}-${arch}-unsigned`;
20
+ const RELEASE = `https://github.com/CapIX-Protocol/Capix-Code/releases/download/v${VERSION}/${NAME}.${ext}`;
17
21
 
18
22
  const installDir = path.join(os.homedir(), '.capix-code');
19
- const binDir = path.join(installDir, 'bin');
20
- const engineDir = path.join(installDir, 'engine');
23
+ const tmpDir = path.join(os.tmpdir(), 'capix-code-install');
21
24
 
22
- fs.mkdirSync(binDir, { recursive: true });
23
- fs.mkdirSync(engineDir, { recursive: true });
25
+ fs.mkdirSync(installDir, { recursive: true });
26
+ fs.mkdirSync(tmpDir, { recursive: true });
24
27
 
25
28
  try {
26
- console.log('Downloading capix-code binary...');
27
- execSync('curl -fsSL ' + RELEASE + '/capix-code -o ' + binDir + '/capix-code', { stdio: 'inherit' });
28
- fs.chmodSync(path.join(binDir, 'capix-code'), 0o755);
29
- console.log('✓ Capix Code installed to ' + installDir);
29
+ console.log(`Downloading capix-code v${VERSION} (${platform}-${arch})...`);
30
+ const archivePath = path.join(tmpDir, `${NAME}.${ext}`);
31
+ execSync(`curl -fsSL -o "${archivePath}" "${RELEASE}"`, { stdio: 'inherit' });
32
+
33
+ if (process.platform === 'win32') {
34
+ execSync(`tar -xf "${archivePath}" -C "${tmpDir}"`, { stdio: 'inherit' });
35
+ } else {
36
+ execSync(`tar -xzf "${archivePath}" -C "${tmpDir}"`, { stdio: 'inherit' });
37
+ }
38
+
39
+ const customerSrc = path.join(tmpDir, 'customer');
40
+ if (fs.existsSync(customerSrc)) {
41
+ // Copy bin/ and engine/ and runtime/ to ~/.capix-code
42
+ for (const dir of ['bin', 'engine', 'runtime']) {
43
+ const src = path.join(customerSrc, dir);
44
+ const dst = path.join(installDir, dir);
45
+ if (fs.existsSync(src)) {
46
+ execSync(`cp -a "${src}" "${dst}"`, { stdio: 'inherit' });
47
+ }
48
+ }
49
+ // Ensure bin is executable
50
+ const binPath = path.join(installDir, 'bin', 'capix-code');
51
+ if (fs.existsSync(binPath)) {
52
+ fs.chmodSync(binPath, 0o755);
53
+ }
54
+ }
55
+
56
+ // Cleanup
57
+ fs.rmSync(tmpDir, { recursive: true, force: true });
58
+
59
+ console.log(`✓ Capix Code v${VERSION} installed to ${installDir}`);
30
60
  console.log('Run: capix-code --version');
31
61
  } catch (err) {
32
62
  console.warn('⚠ Binary download failed. Download manually from:');
33
- console.warn(' https://github.com/CapIX-Protocol/CapIX-Code/releases');
34
- // Don't fail the install
63
+ console.warn(' https://github.com/CapIX-Protocol/Capix-Code/releases');
35
64
  process.exit(0);
36
65
  }