capix-code 2.2.3 → 2.2.5

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/scripts/build.sh DELETED
@@ -1,154 +0,0 @@
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 CAPIX_CODE_VERSION="$CAPIX_RELEASE_VERSION"
27
- export CAPIX_CODE_CHANNEL="latest"
28
- export OPENCODE_VERSION="$CAPIX_RELEASE_VERSION"
29
-
30
- # Write default config if the init script exists.
31
- if [ -f "packages/capix-code/scripts/init-capix-config.ts" ]; then
32
- "$BUN" run packages/capix-code/scripts/init-capix-config.ts 2>/dev/null || true
33
- fi
34
-
35
- # Build using the upstream build script.
36
- if [ -f "packages/capix-code/script/build.ts" ]; then
37
- "$BUN" run --cwd packages/capix-code script/build.ts --single
38
- fi
39
-
40
- # Find the output — handle both renamed and original patterns.
41
- EXE_SUFFIX=""
42
- case "$(uname -s)" in MINGW*|MSYS*|CYGWIN*) EXE_SUFFIX=".exe";; esac
43
- OUTPUT=$(find packages/capix-code/dist -name "capix-code$EXE_SUFFIX" -type f 2>/dev/null | head -1)
44
- if [ -z "$OUTPUT" ]; then
45
- OUTPUT=$(find packages/capix-code/dist -name "opencode$EXE_SUFFIX" -type f 2>/dev/null | head -1)
46
- if [ -n "$OUTPUT" ]; then
47
- NEW_OUTPUT="$(dirname "$OUTPUT")/capix-code$EXE_SUFFIX"
48
- mv "$OUTPUT" "$NEW_OUTPUT"
49
- OUTPUT="$NEW_OUTPUT"
50
- fi
51
- fi
52
-
53
- if [ -n "$OUTPUT" ]; then
54
- ARTIFACT="$DIR/dist/customer"
55
- rm -rf "$ARTIFACT"
56
- mkdir -p "$ARTIFACT/bin" "$ARTIFACT/engine" "$ARTIFACT/runtime/packages" "$ARTIFACT/config" "$ARTIFACT/mcp"
57
- cp "$OUTPUT" "$ARTIFACT/engine/capix-engine$EXE_SUFFIX"
58
- cp -R "$DIR/src" "$ARTIFACT/runtime/src"
59
- # Create tsconfig.json so path aliases (@/*) resolve when the engine imports providers
60
- cat > "$ARTIFACT/runtime/tsconfig.json" << 'TCSONFIG'
61
- {
62
- "compilerOptions": {
63
- "target": "ES2022",
64
- "module": "esnext",
65
- "moduleResolution": "bundler",
66
- "strict": true,
67
- "esModuleInterop": true,
68
- "skipLibCheck": true,
69
- "baseUrl": ".",
70
- "paths": {
71
- "@/*": ["./src/*"]
72
- }
73
- }
74
- }
75
- TCSONFIG
76
- cp -R "$DIR/packages/runtime-provider" "$ARTIFACT/runtime/packages/runtime-provider"
77
- cp "$DIR/config/runtime-package.json" "$ARTIFACT/runtime/package.json"
78
- cp "$DIR/config/capix-defaults.json" "$DIR/config/defaults.json" "$ARTIFACT/config/"
79
- cp -R "$DIR/commands" "$ARTIFACT/commands"
80
- # Build and bundle the MCP server from the capix-mcp npm package
81
- mkdir -p "$ARTIFACT/mcp" "$ARTIFACT/mcp/node_modules"
82
- npm install capix-mcp@2.1.0 --prefix "$DIR/dist/mcp-tmp" 2>/dev/null
83
- cp -R "$DIR/dist/mcp-tmp/node_modules/capix-mcp/dist/"* "$ARTIFACT/mcp/" 2>/dev/null
84
- cp "$DIR/dist/mcp-tmp/node_modules/capix-mcp/package.json" "$ARTIFACT/mcp/" 2>/dev/null
85
- # Copy ALL dependencies needed by capix-mcp
86
- for dep in @modelcontextprotocol zod; do
87
- if [ -d "$DIR/dist/mcp-tmp/node_modules/$dep" ]; then
88
- cp -R "$DIR/dist/mcp-tmp/node_modules/$dep" "$ARTIFACT/mcp/node_modules/" 2>/dev/null
89
- fi
90
- done
91
- if [ -d "$DIR/dist/mcp-tmp/node_modules/capix-mcp/node_modules" ]; then
92
- cp -R "$DIR/dist/mcp-tmp/node_modules/capix-mcp/node_modules/"* "$ARTIFACT/mcp/node_modules/" 2>/dev/null
93
- fi
94
- # Copy capix-mcp's dependencies (SDK, zod, etc.)
95
- mkdir -p "$ARTIFACT/mcp/node_modules"
96
- if [ -d "$DIR/dist/mcp-tmp/node_modules/capix-mcp/node_modules" ]; then
97
- cp -R "$DIR/dist/mcp-tmp/node_modules/capix-mcp/node_modules/"* "$ARTIFACT/mcp/node_modules/" 2>/dev/null
98
- fi
99
- for dep in @modelcontextprotocol zod; do
100
- if [ -d "$DIR/dist/mcp-tmp/node_modules/$dep" ]; then
101
- cp -R "$DIR/dist/mcp-tmp/node_modules/$dep" "$ARTIFACT/mcp/node_modules/" 2>/dev/null
102
- fi
103
- done
104
- # Create entry point wrapper that shares credentials with capix-code
105
- cat > "$ARTIFACT/mcp/capix-mcp.js" << 'MCPWRAPPER'
106
- #!/usr/bin/env node
107
- const { readFileSync, writeFileSync, chmodSync, existsSync } = require("node:fs");
108
- const { join } = require("node:path");
109
- const { homedir } = require("node:os");
110
- const credPath = join(homedir(), ".capix-code", "credentials.json");
111
- async function loadMcp() {
112
- require(join(__dirname, "index.js"));
113
- }
114
- (async () => {
115
- try {
116
- if (existsSync(credPath)) {
117
- const creds = JSON.parse(readFileSync(credPath, "utf8"));
118
- const rt = creds["capix-code:oauth-refresh-token"];
119
- if (rt) {
120
- const res = await fetch("https://www.capix.network/oauth/token", {
121
- method: "POST",
122
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
123
- body: new URLSearchParams({ grant_type: "refresh_token", refresh_token: rt, client_id: "capix-code" }).toString(),
124
- });
125
- const body = await res.json();
126
- if (body.access_token) {
127
- process.env.CAPIX_API_KEY = body.access_token;
128
- creds["capix-code:oauth-refresh-token"] = body.refresh_token;
129
- writeFileSync(credPath, JSON.stringify(creds, null, 2), { mode: 0o600 });
130
- chmodSync(credPath, 0o600);
131
- }
132
- }
133
- }
134
- } catch {}
135
- loadMcp();
136
- })();
137
- MCPWRAPPER
138
- chmod 0755 "$ARTIFACT/mcp/capix-mcp.js"
139
- rm -rf "$DIR/dist/mcp-tmp"
140
- chmod 0755 "$ARTIFACT/engine/capix-engine$EXE_SUFFIX"
141
- # Install from the dedicated runtime manifest. The outer npm package has
142
- # platform selectors which do not belong inside the embedded runtime.
143
- (cd "$ARTIFACT/runtime" && npm install --omit=dev --ignore-scripts)
144
- (cd "$DIR/launcher" && cargo build --release)
145
- cp "$DIR/launcher/target/release/capix-code$EXE_SUFFIX" "$ARTIFACT/bin/capix-code$EXE_SUFFIX"
146
- chmod 0755 "$ARTIFACT/bin/capix-code$EXE_SUFFIX"
147
-
148
- "$DIR/scripts/assert-artifact.sh" "$ARTIFACT"
149
- "$DIR/scripts/assert-customer-brand.sh" "$ARTIFACT"
150
- echo "✓ Customer artifact staged: $ARTIFACT"
151
- else
152
- echo "✗ No binary found in dist/ — build may have failed."
153
- exit 1
154
- fi
@@ -1,8 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- DIST_DIR="${1:-dist}"
4
- for f in "$DIST_DIR"/*.tar.gz "$DIST_DIR"/*.zip; do
5
- [ -f "$f" ] || continue
6
- shasum -a 256 "$f" > "$f.sha256"
7
- echo " $(basename $f): $(cat "$f.sha256" | awk '{print $1}')"
8
- done
@@ -1,30 +0,0 @@
1
- #!/bin/bash
2
- # Local development installation of Capix Code
3
- # This is NOT a production installer — for development only
4
- set -euo pipefail
5
-
6
- SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7
- SOURCE_DIR="$(dirname "$SCRIPT_DIR")"
8
-
9
- echo "=== Capix Code Development Install ==="
10
- echo "Path: $SOURCE_DIR"
11
- echo ""
12
-
13
- # Install dependencies
14
- cd "$SOURCE_DIR"
15
- if [ ! -d "node_modules" ]; then
16
- echo "Installing dependencies..."
17
- npm install
18
- fi
19
-
20
- # Type check
21
- echo "Running type check..."
22
- npx tsc --noEmit
23
-
24
- # Run tests
25
- echo "Running tests..."
26
- npx vitest run
27
-
28
- echo ""
29
- echo "✅ Development environment ready."
30
- echo "Run: npx tsx src/plugin.ts # to start the Capix Code agent"
package/scripts/dev.sh DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # dev.sh — launch capix-code in dev mode.
4
- #
5
- # Requires the repository-pinned Bun 1.3.14 runtime.
6
- set -euo pipefail
7
-
8
- DIR="$(cd "$(dirname "$0")/.." && pwd)"
9
- CAPIX_CODE_DIR="${CAPIX_CODE_DIR:-$DIR/upstream}"
10
- BUN="${BUN_BIN:-$(command -v bun || true)}"
11
- if [ -z "$BUN" ] && [ -x "$DIR/node_modules/.bin/bun" ]; then BUN="$DIR/node_modules/.bin/bun"; fi
12
- [ -n "$BUN" ] || { echo "✗ Bun 1.3.14 is required; install the pinned runtime first"; exit 1; }
13
- [ "$($BUN --version)" = "1.3.14" ] || { echo "✗ Expected Bun 1.3.14"; exit 1; }
14
-
15
- if [ ! -d "$CAPIX_CODE_DIR" ]; then
16
- echo "✗ No $CAPIX_CODE_DIR. Run ./scripts/bootstrap.sh first."
17
- exit 1
18
- fi
19
-
20
- cd "$CAPIX_CODE_DIR"
21
-
22
- echo "▸ Installing dependencies (Bun)…"
23
- "$BUN" install
24
-
25
- echo "▸ Writing default Capix config (if missing)…"
26
- "$BUN" run packages/capix-code/scripts/init-capix-config.ts 2>/dev/null || true
27
-
28
- echo "▸ Launching capix-code (dev mode)…"
29
- echo ""
30
- echo " Set your Capix env vars before starting:"
31
- echo " export CAPIX_BASE_URL=https://capix.network/api/v1"
32
- echo " export CAPIX_API_KEY=cpk_... (or your deployed cpxllm_... key)"
33
- echo " export CAPIX_MODEL=capix/auto (optional — defaults to auto)"
34
- echo ""
35
- "$BUN" run --cwd packages/capix-code --conditions=browser src/index.ts "$@"
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env bash
2
- # install-config.sh — drop the Capix provider config as the default.
3
- set -uo pipefail
4
-
5
- DIR="$(cd "$(dirname "$0")/.." && pwd)"
6
- CAPIX_CODE_DIR="${CAPIX_CODE_DIR:-$DIR/upstream}"
7
- CONFIG_SRC="$DIR/config/defaults.json"
8
-
9
- if [ ! -f "$CONFIG_SRC" ]; then
10
- echo "✗ Missing $CONFIG_SRC"
11
- exit 1
12
- fi
13
-
14
- # 1. Bundle the config into the capix-code package as a default.
15
- DEST_DIR="$CAPIX_CODE_DIR/packages/capix-code/config"
16
- mkdir -p "$DEST_DIR"
17
- cp "$CONFIG_SRC" "$DEST_DIR/capix-defaults.json"
18
- echo " ✓ bundled capix-defaults.json"
19
-
20
- # 2. Create the init script that writes the default config on first run.
21
- WRAPPER="$CAPIX_CODE_DIR/packages/capix-code/scripts/init-capix-config.ts"
22
- mkdir -p "$(dirname "$WRAPPER")"
23
- cat > "$WRAPPER" << 'WRAPPER_EOF'
24
- import { existsSync, mkdirSync, writeFileSync, readFileSync } from "node:fs";
25
- import { homedir } from "node:os";
26
- import { join } from "node:path";
27
-
28
- function getConfigDir(): string {
29
- switch (process.platform) {
30
- case "darwin": return join(homedir(), "Library", "Application Support", "capix-code");
31
- case "win32": return join(homedir(), "AppData", "Roaming", "capix-code");
32
- default: return join(homedir(), ".config", "capix-code");
33
- }
34
- }
35
-
36
- const configDir = getConfigDir();
37
- const configFile = join(configDir, "capix-code.json");
38
-
39
- if (!existsSync(configFile)) {
40
- let defaults = "{}";
41
- try {
42
- defaults = readFileSync(join(import.meta.dir, "..", "config", "capix-defaults.json"), "utf-8");
43
- } catch {}
44
- mkdirSync(configDir, { recursive: true });
45
- writeFileSync(configFile, defaults, "utf-8");
46
- }
47
- WRAPPER_EOF
48
- echo " ✓ created init-capix-config.ts wrapper"
49
-
50
- # 3. Install the TUI theme + brand assets.
51
- if [ -d "$DIR/themes" ]; then
52
- THEME_DEST="$CAPIX_CODE_DIR/packages/capix-code/config/themes"
53
- mkdir -p "$THEME_DEST"
54
- cp "$DIR/themes/capix.toml" "$THEME_DEST/capix.toml" 2>/dev/null || true
55
- cp "$DIR/tui-capix.json" "$CAPIX_CODE_DIR/packages/capix-code/config/tui-capix.json" 2>/dev/null || true
56
- echo " ✓ TUI theme installed"
57
- fi
58
-
59
- if [ -d "$DIR/brand" ]; then
60
- BRAND_DEST="$CAPIX_CODE_DIR/packages/capix-code/config/brand"
61
- mkdir -p "$BRAND_DEST"
62
- cp -R "$DIR/brand/"* "$BRAND_DEST/" 2>/dev/null || true
63
- echo " ✓ brand assets installed"
64
- fi
65
-
66
- echo "✓ Capix config + branding installed."
@@ -1,115 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
-
4
- VERSION="${CAPIX_CODE_VERSION:-${1:-}}"
5
- RELEASE_BASE_URL="${CAPIX_RELEASE_BASE_URL:-https://github.com/CapIX-Protocol/Capix-Code/releases/download}"
6
- INSTALL_DIR="${CAPIX_INSTALL_DIR:-${CAPIX_CODE_INSTALL_DIR:-${HOME}/.local/bin}}"
7
- RUNTIME_DIR="${CAPIX_CODE_RUNTIME_DIR:-${HOME}/.local/share/capix-code}"
8
-
9
- # "latest" is permitted only by resolving it to an immutable version BEFORE any
10
- # download — never by trusting mutable content. The release pipeline pins the
11
- # current stable version in CAPIX_STABLE_VERSION (the single source of truth
12
- # that also populates manifest/release-manifest.json#stableVersion). Without a
13
- # pin, "latest" fails closed so the installer never proceeds unbounded.
14
- if [ -z "$VERSION" ] || [ "$VERSION" = "latest" ]; then
15
- if [ -n "${CAPIX_STABLE_VERSION:-}" ]; then
16
- VERSION="$CAPIX_STABLE_VERSION"
17
- echo "Resolved latest -> ${VERSION} (CAPIX_STABLE_VERSION)" >&2
18
- else
19
- echo "ERROR: 'latest' requires CAPIX_STABLE_VERSION to be set to an immutable release (e.g. v1.2.3)." >&2
20
- echo "The release pipeline pins the current stable version there; do not pin to mutable content." >&2
21
- exit 2
22
- fi
23
- fi
24
-
25
- if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
26
- echo "ERROR: invalid version '$VERSION' (expected vMAJOR.MINOR.PATCH)" >&2
27
- exit 2
28
- fi
29
-
30
- OS="${CAPIX_INSTALL_OS:-$(uname -s | tr '[:upper:]' '[:lower:]')}"
31
- ARCH="${CAPIX_INSTALL_ARCH:-$(uname -m)}"
32
- case "$OS" in
33
- darwin|linux) ;;
34
- mingw*|msys*|cygwin*|win32*|windows*)
35
- echo "ERROR: Windows is not supported by this shell installer." >&2
36
- echo "Download the Windows binary from:" >&2
37
- echo " https://github.com/CapIX-Protocol/Capix-Code/releases" >&2
38
- echo "Or use PowerShell:" >&2
39
- echo " iwr -UseBasicParsing https://github.com/CapIX-Protocol/Capix-Code/releases/download/${VERSION}/capix-code-windows-x64.exe -OutFile capix-code.exe" >&2
40
- exit 2
41
- ;;
42
- *)
43
- echo "ERROR: unsupported operating system '$OS'" >&2
44
- echo "Download a binary from: https://github.com/CapIX-Protocol/Capix-Code/releases" >&2
45
- exit 2
46
- ;;
47
- esac
48
- case "$ARCH" in
49
- x86_64) ARCH="x64" ;;
50
- arm64|aarch64) ARCH="arm64" ;;
51
- *) echo "ERROR: unsupported architecture '$ARCH'" >&2; exit 2 ;;
52
- esac
53
-
54
- RELEASE_VERSION="${VERSION#v}"
55
- ARTIFACT="capix-code-${RELEASE_VERSION}-${OS}-${ARCH}-unsigned.tar.gz"
56
- BASE_URL="${RELEASE_BASE_URL}/${VERSION}"
57
- WORK_DIR=$(mktemp -d "${TMPDIR:-/tmp}/capix-code-install.XXXXXX")
58
- trap 'rm -rf "$WORK_DIR"' EXIT INT TERM
59
-
60
- if [[ "$BASE_URL" == https://* ]]; then
61
- curl --proto '=https' --tlsv1.2 -fsSL "${BASE_URL}/${ARTIFACT}.sha256" -o "${WORK_DIR}/${ARTIFACT}.sha256"
62
- curl --proto '=https' --tlsv1.2 -fsSL "${BASE_URL}/${ARTIFACT}" -o "${WORK_DIR}/${ARTIFACT}"
63
- else
64
- curl -fsSL "${BASE_URL}/${ARTIFACT}.sha256" -o "${WORK_DIR}/${ARTIFACT}.sha256"
65
- curl -fsSL "${BASE_URL}/${ARTIFACT}" -o "${WORK_DIR}/${ARTIFACT}"
66
- fi
67
-
68
- CHECKSUM_LINES=$(awk 'NF { count++ } END { print count + 0 }' "${WORK_DIR}/${ARTIFACT}.sha256")
69
- EXPECTED=$(awk 'NF { print $1 }' "${WORK_DIR}/${ARTIFACT}.sha256")
70
- RECORDED_ARTIFACT=$(awk 'NF { print $2 }' "${WORK_DIR}/${ARTIFACT}.sha256")
71
- RECORDED_ARTIFACT="${RECORDED_ARTIFACT#\*}"
72
- RECORDED_ARTIFACT="${RECORDED_ARTIFACT##*/}"
73
- if [ "$CHECKSUM_LINES" -ne 1 ] || [ "$RECORDED_ARTIFACT" != "$ARTIFACT" ] || [[ ! "$EXPECTED" =~ ^[0-9a-fA-F]{64}$ ]]; then
74
- echo "ERROR: adjacent checksum must contain exactly one valid SHA-256 entry for ${ARTIFACT}" >&2
75
- exit 1
76
- fi
77
-
78
- if command -v shasum >/dev/null 2>&1; then
79
- ACTUAL=$(shasum -a 256 "${WORK_DIR}/${ARTIFACT}" | awk '{print $1}')
80
- elif command -v sha256sum >/dev/null 2>&1; then
81
- ACTUAL=$(sha256sum "${WORK_DIR}/${ARTIFACT}" | awk '{print $1}')
82
- else
83
- echo "ERROR: neither shasum nor sha256sum is available" >&2
84
- exit 1
85
- fi
86
-
87
- if [ "$EXPECTED" != "$ACTUAL" ]; then
88
- echo "ERROR: checksum verification failed for ${ARTIFACT}" >&2
89
- exit 1
90
- fi
91
-
92
- mkdir -p "$INSTALL_DIR" "$(dirname "$RUNTIME_DIR")"
93
-
94
- if [ ! -w "$INSTALL_DIR" ]; then
95
- echo "ERROR: ${INSTALL_DIR} is not writable. Re-run with a user-owned CAPIX_CODE_INSTALL_DIR; this installer does not invoke sudo." >&2
96
- exit 1
97
- fi
98
-
99
- tar -xzf "${WORK_DIR}/${ARTIFACT}" -C "$WORK_DIR"
100
- test -x "${WORK_DIR}/customer/bin/capix-code" || {
101
- echo "ERROR: verified archive does not contain customer/bin/capix-code" >&2
102
- exit 1
103
- }
104
-
105
- STAGED_RUNTIME="${RUNTIME_DIR}.${VERSION}.new"
106
- rm -rf "$STAGED_RUNTIME"
107
- mkdir -p "$STAGED_RUNTIME"
108
- cp -a "${WORK_DIR}/customer/." "$STAGED_RUNTIME/"
109
- rm -rf "$RUNTIME_DIR"
110
- mv "$STAGED_RUNTIME" "$RUNTIME_DIR"
111
- ln -sfn "${RUNTIME_DIR}/bin/capix-code" "${INSTALL_DIR}/capix-code"
112
- TARGET="${INSTALL_DIR}/capix-code"
113
-
114
- echo "Installed verified Capix Code ${VERSION} at ${TARGET}"
115
- echo "This artifact is unsigned. Verification used the release's exact SHA-256 manifest entry."
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- VERSION="${1:?version required}"
4
- PLATFORM="${2:?platform required}"
5
- ARCH="${3:?architecture required}"
6
- ROOT="$(cd "$(dirname "$0")/.." && pwd)"
7
- CUSTOMER="$ROOT/dist/customer"
8
- OUT="$ROOT/release-artifacts"
9
- NAME="capix-code-$VERSION-$PLATFORM-$ARCH-unsigned"
10
-
11
- "$ROOT/scripts/assert-artifact.sh" "$CUSTOMER"
12
- "$ROOT/scripts/assert-customer-brand.sh" "$CUSTOMER"
13
- mkdir -p "$OUT"
14
- if [ "$PLATFORM" = win32 ]; then
15
- ARCHIVE="$OUT/$NAME.zip"
16
- (cd "$ROOT/dist" && 7z a -tzip "$ARCHIVE" customer)
17
- else
18
- ARCHIVE="$OUT/$NAME.tar.gz"
19
- tar -C "$ROOT/dist" -czf "$ARCHIVE" customer
20
- fi
21
- if command -v sha256sum >/dev/null 2>&1; then
22
- sha256sum "$ARCHIVE" > "$ARCHIVE.sha256"
23
- else
24
- shasum -a 256 "$ARCHIVE" > "$ARCHIVE.sha256"
25
- fi
26
- printf '%s\n' "$(git -C "$ROOT" rev-parse HEAD)" > "$OUT/$NAME.source-commit.txt"
27
- node "$ROOT/scripts/write-release-entry.mjs" "$VERSION" "$PLATFORM" "$ARCH" "$ARCHIVE"
28
- echo "Verified release artifact: $ARCHIVE"
@@ -1,84 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
-
4
- VERSION="${1:-0.1.0-dev}"
5
- ARCH="$(uname -m)"
6
- OUTPUT_DIR="dist"
7
- ARTIFACT_NAME="capix-code-$VERSION-darwin-$ARCH"
8
-
9
- echo "=== Packaging Capix Code $VERSION ($ARCH) ==="
10
-
11
- mkdir -p "$OUTPUT_DIR"
12
-
13
- # 1. Build the TypeScript
14
- npm run compile || true # tsc --noEmit for now — no separate build step yet
15
-
16
- # 2. Create tarball with src/, config/, manifest/
17
- echo "Creating tarball..."
18
- tar -czf "$OUTPUT_DIR/$ARTIFACT_NAME.tar.gz" \
19
- src/ \
20
- config/ \
21
- manifest/ \
22
- package.json \
23
- package-lock.json \
24
- tui-capix.json \
25
- tsconfig.json \
26
- LICENSE \
27
- NOTICE \
28
- README.md
29
-
30
- # 3. Generate SHA-256
31
- echo "Generating SHA-256..."
32
- shasum -a 256 "$OUTPUT_DIR/$ARTIFACT_NAME.tar.gz" > "$OUTPUT_DIR/$ARTIFACT_NAME.tar.gz.sha256"
33
-
34
- # 4. Provenance
35
- cat > "$OUTPUT_DIR/$ARTIFACT_NAME.provenance.json" << EOF
36
- {
37
- "artifact": "$ARTIFACT_NAME.tar.gz",
38
- "version": "$VERSION",
39
- "platform": "darwin-$ARCH",
40
- "signed": false,
41
- "sourceCommit": "$(git rev-parse HEAD)",
42
- "builtAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
43
- "builder": "$(whoami)@$(hostname)",
44
- "checksum": "$(cat "$OUTPUT_DIR/$ARTIFACT_NAME.tar.gz.sha256" | awk '{print $1}')"
45
- }
46
- EOF
47
-
48
- # 5. Minimal SBOM
49
- cat > "$OUTPUT_DIR/$ARTIFACT_NAME.sbom.json" << EOF
50
- {
51
- "sbomFormat": "CapIX-minimal",
52
- "version": "0.1.0",
53
- "generatedAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
54
- "dependencies": "See package-lock.json",
55
- "sourceCommit": "$(git rev-parse HEAD)",
56
- "unsigned": true
57
- }
58
- EOF
59
-
60
- # 6. Installation instructions
61
- cat << INST
62
-
63
- === Capix Code $VERSION (UNSIGNED) ===
64
-
65
- Artifact: $OUTPUT_DIR/$ARTIFACT_NAME.tar.gz
66
- SHA-256: $(cat "$OUTPUT_DIR/$ARTIFACT_NAME.tar.gz.sha256" | awk '{print $1}')
67
-
68
- ## Installation (UNSIGNED)
69
-
70
- 1. Verify checksum:
71
- shasum -a 256 $OUTPUT_DIR/$ARTIFACT_NAME.tar.gz
72
-
73
- 2. Extract:
74
- tar -xzf $OUTPUT_DIR/$ARTIFACT_NAME.tar.gz -C ~/capix-code
75
-
76
- 3. Install dependencies:
77
- cd ~/capix-code && npm install --production
78
-
79
- 4. Run:
80
- node ~/capix-code/src/index.ts # or after tsc: node dist/index.js
81
-
82
- Source commit: $(git rev-parse HEAD)
83
-
84
- INST
@@ -1,12 +0,0 @@
1
- import { chmodSync, existsSync } from 'node:fs';
2
- import { join } from 'node:path';
3
-
4
- const root = new URL('..', import.meta.url).pathname;
5
- const launcher = join(root, 'bin', 'capix-code.cjs');
6
-
7
- if (!existsSync(launcher)) {
8
- console.error('Capix Code npm launcher is missing.');
9
- process.exit(1);
10
- }
11
-
12
- chmodSync(launcher, 0o755);
@@ -1,59 +0,0 @@
1
- import { execFileSync } from 'node:child_process';
2
- import { cpSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
3
- import { join, resolve } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
-
6
- const [platform, arch, source = 'dist/customer', destination = 'npm-platform'] =
7
- process.argv.slice(2);
8
- const supported = new Set([
9
- 'darwin-arm64',
10
- 'darwin-x64',
11
- 'linux-arm64',
12
- 'linux-x64',
13
- 'windows-x64',
14
- ]);
15
- const id = `${platform}-${arch}`;
16
-
17
- if (!supported.has(id)) {
18
- console.error(`Unsupported Capix Code npm platform: ${id}`);
19
- process.exit(2);
20
- }
21
-
22
- const root = resolve(fileURLToPath(new URL('..', import.meta.url)));
23
- const artifact = resolve(root, source);
24
- const output = resolve(root, destination, id);
25
- const isWindows = process.platform === 'win32';
26
- const assertScript = join(root, 'scripts', 'assert-artifact.sh');
27
- const brandScript = join(root, 'scripts', 'assert-customer-brand.sh');
28
- if (!isWindows) {
29
- execFileSync(assertScript, [artifact], { stdio: 'inherit' });
30
- execFileSync(brandScript, [artifact], { stdio: 'inherit' });
31
- } else {
32
- // On Windows, run via bash if available; otherwise skip shell-script assertions
33
- try {
34
- execFileSync('bash', [assertScript, artifact], { stdio: 'inherit' });
35
- execFileSync('bash', [brandScript, artifact], { stdio: 'inherit' });
36
- } catch {
37
- console.warn('Skipping shell-script assertions on Windows (bash not available)');
38
- }
39
- }
40
- rmSync(output, { recursive: true, force: true });
41
- mkdirSync(output, { recursive: true });
42
- cpSync(artifact, join(output, 'customer'), { recursive: true });
43
- writeFileSync(
44
- join(output, 'package.json'),
45
- `${JSON.stringify(
46
- {
47
- name: `@capix-code/${id}`,
48
- version: '1.2.7',
49
- description: `Capix Code native runtime for ${id}`,
50
- license: 'Apache-2.0',
51
- os: [platform === 'windows' ? 'win32' : platform],
52
- cpu: [arch],
53
- files: ['customer/'],
54
- },
55
- null,
56
- 2
57
- )}\n`
58
- );
59
- console.log(output);