Files
bootstrap/bin/mosaic-link-runtime-assets
Jason Woltje 7c2eba4e15 feat: centralized SOUL.md, mosaic-init generator, and unified launcher
- Add SOUL.md.template with {{PLACEHOLDERS}} for interactive generation
- Add mosaic-init (bash + PS1) for interactive SOUL.md creation with flag overrides
- Add mosaic launcher (bash + PS1) — unified CLI for claude/opencode/codex with SOUL.md injection
- Add codex runtime adapter (runtime/codex/instructions.md)
- Update runtime adapters (claude, opencode) with SOUL.md read directive
- Update mosaic-link-runtime-assets to push codex adapter to ~/.codex/
- Update installers to prompt for mosaic init when SOUL.md is missing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 12:38:22 -06:00

98 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
MOSAIC_HOME="${MOSAIC_HOME:-$HOME/.config/mosaic}"
backup_stamp="$(date +%Y%m%d%H%M%S)"
copy_file_managed() {
local src="$1"
local dst="$2"
mkdir -p "$(dirname "$dst")"
if [[ -L "$dst" ]]; then
rm -f "$dst"
fi
if [[ -f "$dst" ]]; then
if cmp -s "$src" "$dst"; then
return
fi
mv "$dst" "${dst}.mosaic-bak-${backup_stamp}"
fi
cp "$src" "$dst"
}
remove_legacy_path() {
local p="$1"
if [[ -L "$p" ]]; then
rm -f "$p"
return
fi
if [[ -d "$p" ]]; then
find "$p" -depth -type l -delete 2>/dev/null || true
find "$p" -depth -type d -empty -delete 2>/dev/null || true
return
fi
# Remove stale symlinked files if present.
if [[ -e "$p" && -L "$p" ]]; then
rm -f "$p"
fi
}
# Remove compatibility symlink surfaces for migrated content.
legacy_paths=(
"$HOME/.claude/agent-guides"
"$HOME/.claude/scripts/git"
"$HOME/.claude/scripts/codex"
"$HOME/.claude/scripts/bootstrap"
"$HOME/.claude/scripts/cicd"
"$HOME/.claude/scripts/portainer"
"$HOME/.claude/scripts/debug-hook.sh"
"$HOME/.claude/scripts/qa-hook-handler.sh"
"$HOME/.claude/scripts/qa-hook-stdin.sh"
"$HOME/.claude/scripts/qa-hook-wrapper.sh"
"$HOME/.claude/scripts/qa-queue-monitor.sh"
"$HOME/.claude/scripts/remediation-hook-handler.sh"
"$HOME/.claude/templates"
"$HOME/.claude/presets/domains"
"$HOME/.claude/presets/tech-stacks"
"$HOME/.claude/presets/workflows"
"$HOME/.claude/presets/jarvis-ralph.json"
)
for p in "${legacy_paths[@]}"; do
remove_legacy_path "$p"
done
# Runtime files are synced as regular files (not symlinks) to reduce path confusion.
for runtime_file in \
CLAUDE.md \
settings.json \
hooks-config.json \
context7-integration.md; do
src="$MOSAIC_HOME/runtime/claude/$runtime_file"
[[ -f "$src" ]] || continue
copy_file_managed "$src" "$HOME/.claude/$runtime_file"
done
# OpenCode runtime adapter (optional, copied when present).
opencode_adapter="$MOSAIC_HOME/runtime/opencode/AGENTS.md"
if [[ -f "$opencode_adapter" ]]; then
copy_file_managed "$opencode_adapter" "$HOME/.config/opencode/AGENTS.md"
fi
# Codex runtime adapter (optional, copied when present).
codex_adapter="$MOSAIC_HOME/runtime/codex/instructions.md"
if [[ -f "$codex_adapter" ]]; then
mkdir -p "$HOME/.codex"
copy_file_managed "$codex_adapter" "$HOME/.codex/instructions.md"
fi
echo "[mosaic-link] Runtime assets synced (non-symlink mode)"
echo "[mosaic-link] Canonical source: $MOSAIC_HOME"