Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/opencode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"typecheck": "tsgo --noEmit",
"test": "bun test --timeout 30000",
"build": "bun run script/build.ts",
"build:local": "bun run script/build.ts --single --skip-install",
"local": "./script/local.sh",
"dev": "bun run --conditions=browser ./src/index.ts",
"db": "bun drizzle-kit"
},
Expand Down
56 changes: 56 additions & 0 deletions packages/opencode/script/local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Build and run altimate-code locally from a compiled binary.
#
# Usage:
# ./script/local.sh # build + run
# ./script/local.sh --skip-build # run without rebuilding
# ./script/local.sh -- --help # pass flags to altimate-code
#
# The script:
# 1. Builds a single-platform binary (current OS/arch) via `bun run script/build.ts --single --skip-install`
# 2. Sets NODE_PATH so the compiled Bun binary can find @altimateai/altimate-core
# 3. Launches the binary with any trailing arguments

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PKG_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"

# Parse script flags (everything before --)
SKIP_BUILD=false
ARGS=()
while [[ $# -gt 0 ]]; do
case "$1" in
--skip-build) SKIP_BUILD=true; shift ;;
--) shift; ARGS=("$@"); break ;;
*) ARGS+=("$1"); shift ;;
esac
done

# --- Build ---
if [ "$SKIP_BUILD" = false ]; then
echo "Building for current platform..."
# Run in subshell to avoid changing the working directory
(cd "$PKG_DIR" && bun run script/build.ts --single --skip-install)
fi

# --- Resolve binary ---
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
case "$ARCH" in
aarch64|arm64) ARCH="arm64" ;;
x86_64) ARCH="x64" ;;
esac

Comment on lines +39 to +53

This comment was marked as outdated.

BINARY="$PKG_DIR/dist/@altimateai/altimate-code-${OS}-${ARCH}/bin/altimate"
if [ ! -f "$BINARY" ]; then
echo "error: binary not found at $BINARY" >&2
echo "Available builds:" >&2
ls "$PKG_DIR/dist/@altimateai/" 2>/dev/null || echo " (none)" >&2
exit 1
fi

# --- Run ---
export NODE_PATH="$PKG_DIR/node_modules${NODE_PATH:+:$NODE_PATH}"
# Use ${ARGS[@]+"${ARGS[@]}"} to avoid "unbound variable" on bash 3.2 (macOS default)
exec "$BINARY" ${ARGS[@]+"${ARGS[@]}"}
Loading