Files
stack/packages/mosaic/framework/tools/_scripts/mosaic-release-upgrade
Jarvis 15830e2f2a
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/push/ci Pipeline was successful
feat!: unify mosaic CLI — native launcher, no bin/ directory
BREAKING CHANGE: ~/.config/mosaic/bin/ is removed entirely.
The mosaic npm CLI is now the only executable.

## What changed

- **bin/ → deleted**: All scripts moved to tools/_scripts/ (internal)
- **mosaic-launch → deleted**: Launcher logic is native TypeScript
  in packages/cli/src/commands/launch.ts
- **mosaic.ps1 → deleted**: PowerShell launcher removed
- **Framework install.sh**: Complete rewrite with migration system
- **Version tracking**: .framework-version file (schema v2)
- **Migration v1→v2**: Auto-removes bin/, cleans old PATH entries
  from shell profiles

## Native TypeScript launcher (commands/launch.ts)

All runtime launch logic ported from bash:
- Runtime prompt builder (AGENTS.md + RUNTIME.md + USER.md + TOOLS.md)
- Mission context injection (reads .mosaic/orchestrator/mission.json)
- PRD status injection (scans docs/PRD.md)
- Pre-flight checks (MOSAIC_HOME, AGENTS.md, SOUL.md, runtime binary)
- Session lock management with signal cleanup
- Per-runtime launch: Claude, Codex, OpenCode, Pi
- Yolo mode flags per runtime
- Pi skill discovery + extension loading
- Framework management (init, doctor, sync, bootstrap) delegates
  to tools/_scripts/ bash implementations

## Installer

- tools/install.sh: detects framework by .framework-version or AGENTS.md
- Framework install.sh: migration system with schema versioning
- Forward-compatible: add migrations as numbered blocks
- No PATH manipulation for framework (npm bin is the only PATH entry)
2026-04-02 19:37:13 -05:00

125 lines
3.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# mosaic-release-upgrade — Upgrade installed Mosaic framework release.
#
# This re-runs the remote installer with explicit install mode controls.
# Default behavior is safe/idempotent (keep SOUL.md + memory).
#
# Usage:
# mosaic-release-upgrade
# mosaic-release-upgrade --ref main --keep
# mosaic-release-upgrade --ref v0.2.0 --overwrite --yes
MOSAIC_HOME="${MOSAIC_HOME:-$HOME/.config/mosaic}"
REMOTE_SCRIPT_URL="${MOSAIC_REMOTE_INSTALL_URL:-https://git.mosaicstack.dev/mosaic/mosaic-stack/raw/branch/main/tools/install.sh}"
BOOTSTRAP_REF="${MOSAIC_BOOTSTRAP_REF:-main}"
INSTALL_MODE="${MOSAIC_INSTALL_MODE:-keep}" # keep|overwrite
YES=false
DRY_RUN=false
usage() {
cat <<USAGE
Usage: $(basename "$0") [options]
Upgrade the installed Mosaic framework release.
Options:
--ref <name> Bootstrap archive ref (branch/tag/commit). Default: main
--keep Keep local files (SOUL.md, memory/) during upgrade (default)
--overwrite Overwrite target install directory contents
-y, --yes Skip confirmation prompt
--dry-run Show actions without executing
-h, --help Show this help
USAGE
}
while [[ $# -gt 0 ]]; do
case "$1" in
--ref)
[[ $# -lt 2 ]] && { echo "Missing value for --ref" >&2; exit 1; }
BOOTSTRAP_REF="$2"
shift 2
;;
--keep)
INSTALL_MODE="keep"
shift
;;
--overwrite)
INSTALL_MODE="overwrite"
shift
;;
-y|--yes)
YES=true
shift
;;
--dry-run)
DRY_RUN=true
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
done
case "$INSTALL_MODE" in
keep|overwrite) ;;
*)
echo "[mosaic-release-upgrade] Invalid install mode: $INSTALL_MODE" >&2
exit 1
;;
esac
current_version="unknown"
if [[ -x "$MOSAIC_HOME/bin/mosaic" ]]; then
current_version="$("$MOSAIC_HOME/bin/mosaic" --version 2>/dev/null | awk '{print $2}' || true)"
[[ -n "$current_version" ]] || current_version="unknown"
fi
echo "[mosaic-release-upgrade] Current version: $current_version"
echo "[mosaic-release-upgrade] Target ref: $BOOTSTRAP_REF"
echo "[mosaic-release-upgrade] Install mode: $INSTALL_MODE"
echo "[mosaic-release-upgrade] Installer URL: $REMOTE_SCRIPT_URL"
if [[ "$DRY_RUN" == "true" ]]; then
echo "[mosaic-release-upgrade] Dry run: no changes applied."
exit 0
fi
if [[ "$YES" != "true" && -t 0 ]]; then
printf "Proceed with Mosaic release upgrade? [y/N]: "
read -r confirm
case "${confirm:-n}" in
y|Y|yes|YES) ;;
*)
echo "[mosaic-release-upgrade] Aborted."
exit 1
;;
esac
fi
if command -v curl >/dev/null 2>&1; then
curl -sL "$REMOTE_SCRIPT_URL" | \
MOSAIC_BOOTSTRAP_REF="$BOOTSTRAP_REF" \
MOSAIC_INSTALL_MODE="$INSTALL_MODE" \
MOSAIC_HOME="$MOSAIC_HOME" \
sh
elif command -v wget >/dev/null 2>&1; then
wget -qO- "$REMOTE_SCRIPT_URL" | \
MOSAIC_BOOTSTRAP_REF="$BOOTSTRAP_REF" \
MOSAIC_INSTALL_MODE="$INSTALL_MODE" \
MOSAIC_HOME="$MOSAIC_HOME" \
sh
else
echo "[mosaic-release-upgrade] ERROR: curl or wget required." >&2
exit 1
fi