Skip to content

Commit 0e83773

Browse files
mdesmetclaude
andcommitted
fix: embed altimate-core in standalone binary and rename to altimate (match npm primary)
The curl install at the repo root produced a binary that crashed on first run with `Cannot find module '@altimateai/altimate-core'`. Root cause: script/build.ts marked altimate-core as `external` (NAPI native modules can't live inside Bun's single-file bunfs), and the release archive shipped only the raw Bun binary — no companion node_modules, no NODE_PATH-aware wrapper. The CI smoke tests hid the bug by pre-setting NODE_PATH against the developer checkout before invoking the binary. The fix has two halves: 1. Self-contained binary (build-level fix) - Drop `@altimateai/altimate-core` from requiredExternals. - In the per-target build loop, stage a copy of the loader package and replace its NAPI-RS dispatcher with a one-line shim: module.exports = require('./altimate-core.<platform>.node') Co-locate the target's `.node` file. Add a Bun.build onResolve plugin that redirects `@altimateai/altimate-core` to the staged shim. Bun statically sees a single require() and embeds that one .node into bunfs. Result: ~192 MB self-contained binary, no companion files. - Ensure every altimate-core NAPI prebuild is installed before the target loop via `bun install --os=* --cpu=*`. - Drop targets without an altimate-core prebuild from allTargets: linux-*-musl and win32-arm64. release.yml's build matrix updated to match. Re-add if/when altimate-core publishes those prebuilds. - CI smoke tests now run the binary with NODE_PATH explicitly cleared (`env -u NODE_PATH ...`). This turns the smoke test into a real regression guard for the curl-install class of bug. 2. Rename the curl-install binary altimate-code → altimate The npm package already exposes `altimate` as the primary bin and `altimate-code` as the alias (see packages/opencode/package.json bin block, and the postinstall banner). The curl install was the odd one out, installing only `altimate-code`. Align it with the npm contract: the standalone install puts `altimate` on $PATH. Drop the alias from the curl-install path — users who want `altimate-code` get it from npm or Homebrew. - `install`: APP=altimate (was altimate-code). Cascades to archive filename `altimate-<target>.{zip,tar.gz}`, INSTALL_DIR `~/.altimate/bin`, `mv $tmp_dir/altimate $INSTALL_DIR`, and every log line / tmp-basename / check_version reference. Final getting-started block matches upstream opencode's shape (cd <project> / altimate). Branding-only diff against anomalyco/opencode's install is now 6 non-branding lines: the file-marker line, 4 ASCII banner lines (removed), and one cosmetic getting-started line. - `script/build.ts`: archive step renames `@altimateai/altimate-code-<target>` → `altimate-<target>` and packs exactly one file (the renamed `altimate` binary), not the sourcemaps and not the `altimate-code` alias. The `altimate-code` copy stays inside the platform package dir because the npm wrapper (`packages/opencode/bin/altimate`) looks for `bin/altimate-code` to locate the platform binary — that flow is unchanged. - `script/publish.ts`: Homebrew + AUR formula URLs and the sha256sum paths swap to the new `altimate-<target>` archive names. The brew formula still installs the binary as `altimate` and creates the `altimate-code` alias inside the Cellar — Homebrew users keep both names. - Tests (`branding.test.ts`, `brew-formula.test.ts`, `smoke-test-binary.test.ts`) updated to match the new binary name and archive prefix. Things that intentionally did NOT change: GitHub repo URL `AltimateAI/altimate-code`, npm package name `altimate-code`, the npm wrapper package's `bin` block. Verification on darwin-arm64: $ ls packages/opencode/dist/*.zip altimate-darwin-arm64.zip # was altimate-code-darwin-arm64.zip $ unzip -l packages/opencode/dist/altimate-darwin-arm64.zip 192306704 altimate # single file, no altimate-code # Regression test: NODE_PATH unset, from /tmp $ cd /tmp && env -u NODE_PATH .../bin/altimate --version 0.0.0-test # E2E install via --binary $ HOME=$SCRATCH bash ./install --binary .../bin/altimate $ ls $SCRATCH/.altimate/bin altimate $ env -u NODE_PATH $SCRATCH/.altimate/bin/altimate --version 0.0.0-test # Install diff vs upstream opencode — non-branding lines $ diff -u <(curl -s https://raw.githubusercontent.com/anomalyco/opencode/dev/install) install \ | grep -E '^[-+]' | grep -vE 'opencode|altimate|anomalyco|AltimateAI|OpenCode|Altimate' --- /tmp/upstream-install ... -echo -e "${MUTED} ${NC} ▄ " -echo -e "${MUTED}█▀▀█ █▀▀█ █▀▀█ █▀▀▄ ${NC}█▀▀▀ █▀▀█ █▀▀█ █▀▀█" -echo -e "${MUTED}█░░█ █░░█ █▀▀▀ █░░█ ${NC}█░░░ █░░█ █░░█ █▀▀▀" -echo -e "${MUTED}▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀ ▀ ${NC}▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀" +echo -e "${MUTED}To start:${NC}" # → file marker + ASCII banner removal + cosmetic "To start:" line. $ bun test --timeout 60000 test/branding/ test/install/ 400 pass / 0 fail Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent c859b57 commit 0e83773

7 files changed

Lines changed: 252 additions & 110 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,17 @@ jobs:
5959
matrix:
6060
include:
6161
# Each target builds ONE binary in parallel (~5 min each)
62-
# Index matches allTargets array in build.ts
62+
# Index matches allTargets array in build.ts. Targets without a
63+
# @altimateai/altimate-core NAPI prebuild (linux-*-musl, win32-arm64)
64+
# are intentionally excluded — see allTargets in build.ts.
6365
- { index: 0, name: "linux-arm64" }
6466
- { index: 1, name: "linux-x64" }
6567
- { index: 2, name: "linux-x64-baseline" }
66-
- { index: 3, name: "linux-arm64-musl" }
67-
- { index: 4, name: "linux-x64-musl" }
68-
- { index: 5, name: "linux-x64-baseline-musl" }
69-
- { index: 6, name: "darwin-arm64" }
70-
- { index: 7, name: "darwin-x64" }
71-
- { index: 8, name: "darwin-x64-baseline" }
72-
- { index: 9, name: "win32-arm64" }
73-
- { index: 10, name: "win32-x64" }
74-
- { index: 11, name: "win32-x64-baseline" }
68+
- { index: 3, name: "darwin-arm64" }
69+
- { index: 4, name: "darwin-x64" }
70+
- { index: 5, name: "darwin-x64-baseline" }
71+
- { index: 6, name: "win32-x64" }
72+
- { index: 7, name: "win32-x64-baseline" }
7573
steps:
7674
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
7775

@@ -113,10 +111,12 @@ jobs:
113111
fi
114112
chmod +x "$BINARY"
115113
116-
# Set NODE_PATH so the binary can resolve external NAPI modules
117-
# (mirrors what the npm bin wrapper does at runtime)
118-
NODE_PATH="$(pwd)/packages/opencode/node_modules:$(pwd)/node_modules" "$BINARY" --version
119-
echo "Smoke test passed: binary starts and prints version"
114+
# Run the binary with NO pre-set NODE_PATH. The Bun-compiled binary
115+
# now embeds @altimateai/altimate-core's NAPI .node into bunfs, so
116+
# it must start standalone. This is the regression gate for the
117+
# v0.7.x curl-install crash (Cannot find module '@altimateai/altimate-core').
118+
env -u NODE_PATH "$BINARY" --version
119+
echo "Smoke test passed: standalone binary starts without external NODE_PATH"
120120
121121
- name: Upload build artifact
122122
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
@@ -262,7 +262,9 @@ jobs:
262262
exit 1
263263
else
264264
chmod +x "$BINARY"
265-
NODE_PATH="$(pwd)/packages/opencode/node_modules:$(pwd)/node_modules" "$BINARY" --version
265+
# No NODE_PATH — the binary embeds altimate-core itself.
266+
# This is the gate that would have caught the v0.7.x missing-module bug.
267+
env -u NODE_PATH "$BINARY" --version
266268
echo "Pre-publish smoke test passed"
267269
fi
268270

‎install‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
3-
APP=altimate-code
3+
APP=altimate
44

55
MUTED='\033[0;2m'
66
RED='\033[0;31m'
@@ -22,7 +22,7 @@ Options:
2222
Examples:
2323
curl -fsSL https://altimate.ai/install | bash
2424
curl -fsSL https://altimate.ai/install | bash -s -- --version 1.0.180
25-
./install --binary /path/to/altimate-code
25+
./install --binary /path/to/altimate
2626
EOF
2727
}
2828

@@ -65,7 +65,7 @@ while [[ $# -gt 0 ]]; do
6565
esac
6666
done
6767

68-
INSTALL_DIR=$HOME/.altimate-code/bin
68+
INSTALL_DIR=$HOME/.altimate/bin
6969
mkdir -p "$INSTALL_DIR"
7070

7171
# If --binary is provided, skip all download/detection logic
@@ -219,11 +219,11 @@ print_message() {
219219
}
220220

221221
check_version() {
222-
if command -v altimate-code >/dev/null 2>&1; then
223-
altimate_code_path=$(which altimate-code)
222+
if command -v altimate >/dev/null 2>&1; then
223+
altimate_path=$(which altimate)
224224

225225
## Check the installed version
226-
installed_version=$(altimate-code --version 2>/dev/null || echo "")
226+
installed_version=$(altimate --version 2>/dev/null || echo "")
227227

228228
if [[ "$installed_version" != "$specific_version" ]]; then
229229
print_message info "${MUTED}Installed version: ${NC}$installed_version."
@@ -275,7 +275,7 @@ download_with_progress() {
275275
fi
276276

277277
local tmp_dir=${TMPDIR:-/tmp}
278-
local basename="${tmp_dir}/altimate_code_install_$$"
278+
local basename="${tmp_dir}/altimate_install_$$"
279279
local tracefile="${basename}.trace"
280280

281281
rm -f "$tracefile"
@@ -325,8 +325,8 @@ download_with_progress() {
325325
}
326326

327327
download_and_install() {
328-
print_message info "\n${MUTED}Installing ${NC}altimate-code ${MUTED}version: ${NC}$specific_version"
329-
local tmp_dir="${TMPDIR:-/tmp}/altimate_code_install_$$"
328+
print_message info "\n${MUTED}Installing ${NC}altimate ${MUTED}version: ${NC}$specific_version"
329+
local tmp_dir="${TMPDIR:-/tmp}/altimate_install_$$"
330330
mkdir -p "$tmp_dir"
331331

332332
if [[ "$os" == "windows" ]] || ! [ -t 2 ] || ! download_with_progress "$url" "$tmp_dir/$filename"; then
@@ -340,15 +340,15 @@ download_and_install() {
340340
unzip -q "$tmp_dir/$filename" -d "$tmp_dir"
341341
fi
342342

343-
mv "$tmp_dir/altimate-code" "$INSTALL_DIR"
344-
chmod 755 "${INSTALL_DIR}/altimate-code"
343+
mv "$tmp_dir/altimate" "$INSTALL_DIR"
344+
chmod 755 "${INSTALL_DIR}/altimate"
345345
rm -rf "$tmp_dir"
346346
}
347347

348348
install_from_binary() {
349-
print_message info "\n${MUTED}Installing ${NC}altimate-code ${MUTED}from: ${NC}$binary_path"
350-
cp "$binary_path" "${INSTALL_DIR}/altimate-code"
351-
chmod 755 "${INSTALL_DIR}/altimate-code"
349+
print_message info "\n${MUTED}Installing ${NC}altimate ${MUTED}from: ${NC}$binary_path"
350+
cp "$binary_path" "${INSTALL_DIR}/altimate"
351+
chmod 755 "${INSTALL_DIR}/altimate"
352352
}
353353

354354
if [ -n "$binary_path" ]; then
@@ -366,9 +366,9 @@ add_to_path() {
366366
if grep -Fxq "$command" "$config_file"; then
367367
print_message info "Command already exists in $config_file, skipping write."
368368
elif [[ -w $config_file ]]; then
369-
echo -e "\n# altimate-code" >> "$config_file"
369+
echo -e "\n# altimate" >> "$config_file"
370370
echo "$command" >> "$config_file"
371-
print_message info "${MUTED}Successfully added ${NC}altimate-code ${MUTED}to \$PATH in ${NC}$config_file"
371+
print_message info "${MUTED}Successfully added ${NC}altimate ${MUTED}to \$PATH in ${NC}$config_file"
372372
else
373373
print_message warning "Manually add the directory to $config_file (or similar):"
374374
print_message info " $command"
@@ -448,8 +448,8 @@ echo -e ""
448448
echo -e ""
449449
echo -e "${MUTED}To start:${NC}"
450450
echo -e ""
451-
echo -e "cd <project> ${MUTED}# Open your project directory${NC}"
452-
echo -e "altimate-code ${MUTED}# Launch the interactive TUI${NC}"
451+
echo -e "cd <project> ${MUTED}# Open directory${NC}"
452+
echo -e "altimate ${MUTED}# Run command${NC}"
453453
echo -e ""
454454
echo -e "${MUTED}For more information visit ${NC}https://altimate.ai"
455455
echo -e ""

0 commit comments

Comments
 (0)