Files
stack/packages/mosaic/framework/bin/mosaic-ensure-excalidraw
Jason Woltje b38cfac760
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
feat: integrate framework files into monorepo under packages/mosaic/framework/
Moves all Mosaic framework runtime files from the separate bootstrap repo
into the monorepo as canonical source. The @mosaic/mosaic npm package now
ships the complete framework — bin scripts, runtime configs, tools, and
templates — enabling standalone installation via npm install.

Structure:
  packages/mosaic/framework/
  ├── bin/          28 CLI scripts (mosaic, mosaic-doctor, mosaic-sync-skills, etc.)
  ├── runtime/      Runtime adapters (claude, codex, opencode, pi, mcp)
  ├── tools/        Shell tooling (git, prdy, orchestrator, quality, etc.)
  ├── templates/    Agent and repo templates
  ├── defaults/     Default identity files (AGENTS.md, STANDARDS.md, SOUL.md, etc.)
  ├── install.sh    Legacy bash installer
  └── remote-install.sh  One-liner remote installer

Key files with Pi support and recent fixes:
- bin/mosaic: launch_pi() with skills-local loop
- bin/mosaic-doctor: --fix auto-wiring for all 4 harnesses
- bin/mosaic-sync-skills: Pi as 4th link target, symlink-aware find
- bin/mosaic-link-runtime-assets: Pi settings.json patching
- bin/mosaic-migrate-local-skills: Pi skill roots, symlink find
- runtime/pi/RUNTIME.md + mosaic-extension.ts

Package ships 251 framework files in the npm tarball (278KB compressed).
2026-04-01 21:19:21 -05:00

120 lines
3.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
MOSAIC_HOME="${MOSAIC_HOME:-$HOME/.config/mosaic}"
TOOLS_DIR="$MOSAIC_HOME/tools/excalidraw"
MODE="apply"
SCOPE="user"
err() { echo "[mosaic-excalidraw] ERROR: $*" >&2; }
log() { echo "[mosaic-excalidraw] $*"; }
while [[ $# -gt 0 ]]; do
case "$1" in
--check) MODE="check"; shift ;;
--scope)
if [[ $# -lt 2 ]]; then
err "--scope requires a value: user|local"
exit 2
fi
SCOPE="$2"
shift 2
;;
*)
err "Unknown argument: $1"
exit 2
;;
esac
done
require_binary() {
local name="$1"
if ! command -v "$name" >/dev/null 2>&1; then
err "Required binary missing: $name"
return 1
fi
}
check_software() {
require_binary node
require_binary npm
}
check_tool_dir() {
[[ -d "$TOOLS_DIR" ]] || { err "Tool dir not found: $TOOLS_DIR"; return 1; }
[[ -f "$TOOLS_DIR/package.json" ]] || { err "package.json not found in $TOOLS_DIR"; return 1; }
[[ -f "$TOOLS_DIR/launch.sh" ]] || { err "launch.sh not found in $TOOLS_DIR"; return 1; }
}
check_npm_deps() {
[[ -d "$TOOLS_DIR/node_modules/@modelcontextprotocol" ]] || return 1
[[ -d "$TOOLS_DIR/node_modules/@excalidraw" ]] || return 1
[[ -d "$TOOLS_DIR/node_modules/jsdom" ]] || return 1
}
install_npm_deps() {
if check_npm_deps; then
return 0
fi
log "Installing npm deps in $TOOLS_DIR..."
(cd "$TOOLS_DIR" && npm install --silent) || {
err "npm install failed in $TOOLS_DIR"
return 1
}
}
check_claude_config() {
python3 - <<'PY'
import json
from pathlib import Path
p = Path.home() / ".claude.json"
if not p.exists():
raise SystemExit(1)
try:
data = json.loads(p.read_text(encoding="utf-8"))
except Exception:
raise SystemExit(1)
mcp = data.get("mcpServers")
if not isinstance(mcp, dict):
raise SystemExit(1)
entry = mcp.get("excalidraw")
if not isinstance(entry, dict):
raise SystemExit(1)
cmd = entry.get("command", "")
if not cmd.endswith("launch.sh"):
raise SystemExit(1)
PY
}
apply_claude_config() {
require_binary claude
local launch_sh="$TOOLS_DIR/launch.sh"
claude mcp add --scope user excalidraw -- "$launch_sh"
}
# ── Check mode ────────────────────────────────────────────────────────────────
if [[ "$MODE" == "check" ]]; then
check_software
check_tool_dir
if ! check_npm_deps; then
err "npm deps not installed in $TOOLS_DIR (run without --check to install)"
exit 1
fi
if ! check_claude_config; then
err "excalidraw not registered in ~/.claude.json"
exit 1
fi
log "excalidraw MCP is configured and available"
exit 0
fi
# ── Apply mode ────────────────────────────────────────────────────────────────
check_software
check_tool_dir
install_npm_deps
apply_claude_config
log "excalidraw MCP configured (scope: $SCOPE)"