#!/usr/bin/env bash # linux/install.sh, run for real into a sandbox home: every file lands, the # ~/.local/bin symlink runs (which exercises the CLI finding its lib/ beside # itself through a symlink), re-running is a safe upgrade. . "$(dirname "$0")/../lib.sh" export HOME="$SB/ihome" export CM_ROOT="$HOME/.claude-mode" mkdir -p "$HOME" : > "$HOME/.bashrc" install_() { OUT="$(bash "$REPO/linux/install.sh" --skip-key-prompt 2>&1)"; RC=$?; OUT="$(printf '%s' "$OUT" | sed "s/${ESC}\[[0-9;]*m//g")"; } install_ expect_rc 0 'the installer succeeds' for f in bin/claude-mode bin/cm-json.py bin/cm-vault.sh bin/claude-key-helper.sh \ bin/lib/core.sh bin/lib/repair.sh providers.json VERSION presets/ollama.json health.json; do expect_file "$CM_ROOT/$f" "installs $f" done expect_eq "$(readlink "$HOME/.local/bin/claude-mode")" "$CM_ROOT/bin/claude-mode" 'links the entry point' expect_eq "$(grep -c '>>> claude-mode >>>' "$HOME/.bashrc")" 1 'adds the shell block' OUT="$("$HOME/.local/bin/claude-mode" presets 2>&1)" expect_out 'ollama' 'runs through the symlink, loading its lib/' python3 "$CM_ROOT/bin/cm-json.py" set-tier "$CM_ROOT/presets/default.json" opus my/model : > "$CM_ROOT/bin/lib/stale.sh" install_ expect_rc 0 're-running the installer succeeds' expect_eq "$(jget "$CM_ROOT/presets/default.json" models.opus)" my/model 'and keeps an edited preset' expect_no_file "$CM_ROOT/bin/lib/stale.sh" 'and drops a module the source no longer has' expect_eq "$(grep -c '>>> claude-mode >>>' "$HOME/.bashrc")" 1 'and does not add the block twice' finish