capix-code 2.0.0 → 2.0.1
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/build.sh +0 -27
- package/scripts/postinstall.cjs +46 -124
- package/scripts/rebrand.sh +10 -24
package/package.json
CHANGED
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"
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -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-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
140
|
-
|
|
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`);
|
package/scripts/rebrand.sh
CHANGED
|
@@ -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
|
-
#
|
|
236
|
-
for
|
|
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
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
rm -f "$
|
|
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"
|