capix-code 1.4.8 → 1.4.9
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 +36 -2
- package/scripts/build.sh.bak +81 -0
package/package.json
CHANGED
package/scripts/build.sh
CHANGED
|
@@ -58,12 +58,46 @@ if [ -n "$OUTPUT" ]; then
|
|
|
58
58
|
cp "$DIR/config/runtime-package.json" "$ARTIFACT/runtime/package.json"
|
|
59
59
|
cp "$DIR/config/capix-defaults.json" "$DIR/config/defaults.json" "$ARTIFACT/config/"
|
|
60
60
|
cp -R "$DIR/commands" "$ARTIFACT/commands"
|
|
61
|
-
# Build and bundle the MCP server from the capix-mcp package
|
|
61
|
+
# Build and bundle the MCP server from the capix-mcp npm package
|
|
62
62
|
mkdir -p "$ARTIFACT/mcp"
|
|
63
63
|
npm install capix-mcp@2.1.0 --prefix "$DIR/dist/mcp-tmp" 2>/dev/null
|
|
64
64
|
cp -R "$DIR/dist/mcp-tmp/node_modules/capix-mcp/dist/"* "$ARTIFACT/mcp/" 2>/dev/null
|
|
65
65
|
cp "$DIR/dist/mcp-tmp/node_modules/capix-mcp/package.json" "$ARTIFACT/mcp/" 2>/dev/null
|
|
66
|
-
|
|
66
|
+
# Create entry point wrapper that shares credentials with capix-code
|
|
67
|
+
cat > "$ARTIFACT/mcp/capix-mcp.js" << 'MCPWRAPPER'
|
|
68
|
+
#!/usr/bin/env node
|
|
69
|
+
const { readFileSync, writeFileSync, chmodSync, existsSync } = require("node:fs");
|
|
70
|
+
const { join } = require("node:path");
|
|
71
|
+
const { homedir } = require("node:os");
|
|
72
|
+
const credPath = join(homedir(), ".capix-code", "credentials.json");
|
|
73
|
+
async function loadMcp() {
|
|
74
|
+
require(join(__dirname, "index.js"));
|
|
75
|
+
}
|
|
76
|
+
(async () => {
|
|
77
|
+
try {
|
|
78
|
+
if (existsSync(credPath)) {
|
|
79
|
+
const creds = JSON.parse(readFileSync(credPath, "utf8"));
|
|
80
|
+
const rt = creds["capix-code:oauth-refresh-token"];
|
|
81
|
+
if (rt) {
|
|
82
|
+
const res = await fetch("https://www.capix.network/oauth/token", {
|
|
83
|
+
method: "POST",
|
|
84
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
85
|
+
body: new URLSearchParams({ grant_type: "refresh_token", refresh_token: rt, client_id: "capix-code" }).toString(),
|
|
86
|
+
});
|
|
87
|
+
const body = await res.json();
|
|
88
|
+
if (body.access_token) {
|
|
89
|
+
process.env.CAPIX_API_KEY = body.access_token;
|
|
90
|
+
creds["capix-code:oauth-refresh-token"] = body.refresh_token;
|
|
91
|
+
writeFileSync(credPath, JSON.stringify(creds, null, 2), { mode: 0o600 });
|
|
92
|
+
chmodSync(credPath, 0o600);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
} catch {}
|
|
97
|
+
loadMcp();
|
|
98
|
+
})();
|
|
99
|
+
MCPWRAPPER
|
|
100
|
+
chmod 0755 "$ARTIFACT/mcp/capix-mcp.js"
|
|
67
101
|
rm -rf "$DIR/dist/mcp-tmp"
|
|
68
102
|
chmod 0755 "$ARTIFACT/engine/capix-engine$EXE_SUFFIX"
|
|
69
103
|
# Install from the dedicated runtime manifest. The outer npm package has
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# build.sh — produce packaged capix-code binaries.
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
6
|
+
CAPIX_CODE_DIR="${CAPIX_CODE_DIR:-$DIR/upstream}"
|
|
7
|
+
BUN="${BUN_BIN:-$(command -v bun || true)}"
|
|
8
|
+
if [ -z "$BUN" ] && [ -x "$DIR/node_modules/.bin/bun" ]; then BUN="$DIR/node_modules/.bin/bun"; fi
|
|
9
|
+
[ -n "$BUN" ] || { echo "✗ Bun 1.3.14 is required"; exit 1; }
|
|
10
|
+
[ "$($BUN --version)" = "1.3.14" ] || { echo "✗ Expected Bun 1.3.14"; exit 1; }
|
|
11
|
+
|
|
12
|
+
if [ ! -d "$CAPIX_CODE_DIR" ]; then
|
|
13
|
+
echo "✗ No $CAPIX_CODE_DIR. Run ./scripts/bootstrap.sh first."
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
cd "$CAPIX_CODE_DIR"
|
|
18
|
+
|
|
19
|
+
echo "▸ Building capix-code standalone binary…"
|
|
20
|
+
"$BUN" install
|
|
21
|
+
|
|
22
|
+
# The embedded engine otherwise falls back to a timestamped 0.0.0 development
|
|
23
|
+
# identifier. Stamp it with the immutable Capix Code package version so the TUI,
|
|
24
|
+
# API metadata and diagnostics all report the customer release.
|
|
25
|
+
CAPIX_RELEASE_VERSION="${CAPIX_CODE_VERSION:-$(node -p 'require(process.argv[1]).version' "$DIR/package.json")}"
|
|
26
|
+
export OPENCODE_VERSION="$CAPIX_RELEASE_VERSION"
|
|
27
|
+
|
|
28
|
+
# Write default config if the init script exists.
|
|
29
|
+
if [ -f "packages/capix-code/scripts/init-capix-config.ts" ]; then
|
|
30
|
+
"$BUN" run packages/capix-code/scripts/init-capix-config.ts 2>/dev/null || true
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Build using the upstream build script.
|
|
34
|
+
if [ -f "packages/capix-code/script/build.ts" ]; then
|
|
35
|
+
"$BUN" run --cwd packages/capix-code script/build.ts --single
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# Find the output — handle both renamed and original patterns.
|
|
39
|
+
EXE_SUFFIX=""
|
|
40
|
+
case "$(uname -s)" in MINGW*|MSYS*|CYGWIN*) EXE_SUFFIX=".exe";; esac
|
|
41
|
+
OUTPUT=$(find packages/capix-code/dist -name "capix-code$EXE_SUFFIX" -type f 2>/dev/null | head -1)
|
|
42
|
+
if [ -z "$OUTPUT" ]; then
|
|
43
|
+
OUTPUT=$(find packages/capix-code/dist -name "opencode$EXE_SUFFIX" -type f 2>/dev/null | head -1)
|
|
44
|
+
if [ -n "$OUTPUT" ]; then
|
|
45
|
+
NEW_OUTPUT="$(dirname "$OUTPUT")/capix-code$EXE_SUFFIX"
|
|
46
|
+
mv "$OUTPUT" "$NEW_OUTPUT"
|
|
47
|
+
OUTPUT="$NEW_OUTPUT"
|
|
48
|
+
fi
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
if [ -n "$OUTPUT" ]; then
|
|
52
|
+
ARTIFACT="$DIR/dist/customer"
|
|
53
|
+
rm -rf "$ARTIFACT"
|
|
54
|
+
mkdir -p "$ARTIFACT/bin" "$ARTIFACT/engine" "$ARTIFACT/runtime/packages" "$ARTIFACT/config" "$ARTIFACT/mcp"
|
|
55
|
+
cp "$OUTPUT" "$ARTIFACT/engine/capix-engine$EXE_SUFFIX"
|
|
56
|
+
cp -R "$DIR/src" "$ARTIFACT/runtime/src"
|
|
57
|
+
cp -R "$DIR/packages/runtime-provider" "$ARTIFACT/runtime/packages/runtime-provider"
|
|
58
|
+
cp "$DIR/config/runtime-package.json" "$ARTIFACT/runtime/package.json"
|
|
59
|
+
cp "$DIR/config/capix-defaults.json" "$DIR/config/defaults.json" "$ARTIFACT/config/"
|
|
60
|
+
cp -R "$DIR/commands" "$ARTIFACT/commands"
|
|
61
|
+
# Build and bundle the MCP server from the capix-mcp package
|
|
62
|
+
mkdir -p "$ARTIFACT/mcp"
|
|
63
|
+
npm install capix-mcp@2.1.0 --prefix "$DIR/dist/mcp-tmp" 2>/dev/null
|
|
64
|
+
cp -R "$DIR/dist/mcp-tmp/node_modules/capix-mcp/dist/"* "$ARTIFACT/mcp/" 2>/dev/null
|
|
65
|
+
cp "$DIR/dist/mcp-tmp/node_modules/capix-mcp/package.json" "$ARTIFACT/mcp/" 2>/dev/null
|
|
66
|
+
cp -R "$DIR/dist/mcp-tmp/node_modules/capix-mcp/node_modules/" "$ARTIFACT/mcp/node_modules/" 2>/dev/null
|
|
67
|
+
rm -rf "$DIR/dist/mcp-tmp"
|
|
68
|
+
chmod 0755 "$ARTIFACT/engine/capix-engine$EXE_SUFFIX"
|
|
69
|
+
# Install from the dedicated runtime manifest. The outer npm package has
|
|
70
|
+
# platform selectors which do not belong inside the embedded runtime.
|
|
71
|
+
(cd "$ARTIFACT/runtime" && npm install --omit=dev --ignore-scripts)
|
|
72
|
+
(cd "$DIR/launcher" && cargo build --locked --release)
|
|
73
|
+
cp "$DIR/launcher/target/release/capix-code$EXE_SUFFIX" "$ARTIFACT/bin/capix-code$EXE_SUFFIX"
|
|
74
|
+
chmod 0755 "$ARTIFACT/bin/capix-code$EXE_SUFFIX"
|
|
75
|
+
"$DIR/scripts/assert-artifact.sh" "$ARTIFACT"
|
|
76
|
+
"$DIR/scripts/assert-customer-brand.sh" "$ARTIFACT"
|
|
77
|
+
echo "✓ Customer artifact staged: $ARTIFACT"
|
|
78
|
+
else
|
|
79
|
+
echo "✗ No binary found in dist/ — build may have failed."
|
|
80
|
+
exit 1
|
|
81
|
+
fi
|