mirror of
https://github.com/gnekt/My-Brain-Is-Full-Crew.git
synced 2026-09-09 15:26:19 +00:00
Co-Authored-By: win0na <winnie@winneon.moe> feat(lib.sh): add install_plugins helper for opencode JS plugins build(adapters): opencode adapter skeleton with capability/event tables build(opencode): adapter_translate_dispatcher (DISPATCHER.md → AGENTS.md) build(opencode): adapter_translate_references and adapter_translate_skills Implements Task 4 and Task 5: - adapter_translate_references: Copies reference markdown files to .opencode/references/ - adapter_translate_skills: Copies skill SKILL.md files to .opencode/skills/<name>/ with exclude filtering Both functions respect framework filtering via should_include(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(opencode): adapter_translate_agents with capability→permission mapping Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(opencode): bash-executor template for spawning hook scripts build(opencode): plugin-stub template for mbifc-hooks.js build(opencode): adapter_translate_hooks with JS plugin generation Implements _oc_hook_registry_json and adapter_translate_hooks in the opencode adapter. Copies hook scripts to .opencode/hooks/, generates a single .opencode/plugins/mbifc-hooks.js by inlining bash-executor.js and synthesising a hook registry from *.hook.yaml files. Uses python3 for template substitution to safely handle multi-line JS content. Adds 3 unit tests (copies scripts, registry entries, noop when no hooks dir). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> build(opencode): adapter_translate_mcp with local/remote handling build(opencode): adapter_finalize and complete adapter_build wiring Add adapter_finalize placeholder and wire adapter_translate_mcp into adapter_build; add end-to-end integration test (14/14 pass). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> feat(launchme): branch on --framework for opencode install layout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> feat(updateme): branch on --framework for opencode install layout Mirror the same case "$FRAMEWORK" block from launchme.sh: framework-specific DIST_COMPONENTS_DIR, VAULT_COMPONENTS_DIR, DISPATCHER_SRC/DST, MCP_SRC/DST, HAS_PLUGINS; conditional install_plugins; conditional install_settings; framework-aware vault-setup check; framework-neutral summary messages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
146 lines
7.0 KiB
Bash
Executable File
146 lines
7.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# =============================================================================
|
|
# My Brain Is Full - Crew :: Updater
|
|
# =============================================================================
|
|
# After pulling new changes from the repo, run this to update the crew:
|
|
#
|
|
# cd /path/to/your-vault/My-Brain-Is-Full-Crew
|
|
# git pull
|
|
# bash scripts/updateme.sh
|
|
#
|
|
# Options:
|
|
# --framework <name> Framework to build for (default: claude-code)
|
|
# --target <path> Override the vault destination path
|
|
# =============================================================================
|
|
|
|
set -eo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck source=scripts/lib.sh
|
|
source "$SCRIPT_DIR/lib.sh"
|
|
|
|
resolve_paths "${BASH_SOURCE[0]}"
|
|
|
|
# ── Parse args ─────────────────────────────────────────────────────────────
|
|
FRAMEWORK="claude-code"
|
|
TARGET_OVERRIDE=""
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--framework) FRAMEWORK="$2"; shift 2 ;;
|
|
--target) TARGET_OVERRIDE="$2"; shift 2 ;;
|
|
*) die "Unknown argument: $1" ;;
|
|
esac
|
|
done
|
|
[[ -n "$TARGET_OVERRIDE" ]] && VAULT_DIR="$TARGET_OVERRIDE"
|
|
|
|
# ── Banner ────────────────────────────────────────────────────────────────────
|
|
print_banner "Update "
|
|
|
|
# ── Check vault has been set up ───────────────────────────────────────────────
|
|
case "$FRAMEWORK" in
|
|
claude-code) _SETUP_CHECK="$VAULT_DIR/.claude/agents" ;;
|
|
opencode) _SETUP_CHECK="$VAULT_DIR/.opencode/agents" ;;
|
|
*) _SETUP_CHECK="$VAULT_DIR/.claude/agents" ;;
|
|
esac
|
|
[[ -d "$_SETUP_CHECK" ]] \
|
|
|| die "No agents/ found in $VAULT_DIR for framework '$FRAMEWORK' — run launchme.sh first"
|
|
|
|
# ── Confirm ───────────────────────────────────────────────────────────────────
|
|
echo -e "${BOLD}This will update core agents, skills, references, hooks, and CLAUDE.md.${NC}"
|
|
echo -e " ${DIM}Custom agents in .claude/agents/ are never overwritten or deleted.${NC}"
|
|
echo -e " ${DIM}Custom content between MBIFC markers in references is preserved.${NC}"
|
|
echo -e " ${DIM}Your vault notes are never touched.${NC}"
|
|
echo ""
|
|
echo -e " ${BOLD}c)${NC} Continue"
|
|
echo -e " ${BOLD}q)${NC} Quit"
|
|
if ! read -r -p " > " ANSWER 2>/dev/null; then ANSWER=""; fi
|
|
if [[ ! "$ANSWER" =~ ^[Cc]$ ]]; then
|
|
echo ""; info "Update cancelled."; echo ""; exit 0
|
|
fi
|
|
echo ""
|
|
|
|
# ── Build the framework dist ───────────────────────────────────────────────
|
|
info "Building $FRAMEWORK adapter..."
|
|
bash "$SCRIPT_DIR/build.sh" --framework "$FRAMEWORK"
|
|
DIST_DIR="$REPO_DIR/dist/$FRAMEWORK"
|
|
[[ -d "$DIST_DIR" ]] || die "Build did not produce $DIST_DIR"
|
|
|
|
# ── Framework-specific install layout ────────────────────────────────────────
|
|
case "$FRAMEWORK" in
|
|
claude-code)
|
|
DIST_COMPONENTS_DIR="$DIST_DIR/.claude"
|
|
VAULT_COMPONENTS_DIR="$VAULT_DIR/.claude"
|
|
DISPATCHER_SRC="$DIST_DIR/CLAUDE.md"
|
|
DISPATCHER_DST="$VAULT_DIR/CLAUDE.md"
|
|
MCP_SRC="$DIST_DIR/.mcp.json"
|
|
MCP_DST="$VAULT_DIR/.mcp.json"
|
|
HAS_PLUGINS=0
|
|
;;
|
|
opencode)
|
|
DIST_COMPONENTS_DIR="$DIST_DIR/.opencode"
|
|
VAULT_COMPONENTS_DIR="$VAULT_DIR/.opencode"
|
|
DISPATCHER_SRC="$DIST_DIR/AGENTS.md"
|
|
DISPATCHER_DST="$VAULT_DIR/AGENTS.md"
|
|
MCP_SRC="$DIST_DIR/opencode.json"
|
|
MCP_DST="$VAULT_DIR/opencode.json"
|
|
HAS_PLUGINS=1
|
|
;;
|
|
*)
|
|
die "Unknown framework: $FRAMEWORK (install layout not defined)"
|
|
;;
|
|
esac
|
|
|
|
# ── Migrate legacy manifests (if any) ────────────────────────────────────────
|
|
manifest_migrate
|
|
|
|
# ── Deprecate agents/refs removed from repo ──────────────────────────────────
|
|
DEP_COUNT=$(deprecate_removed "agents" "$DIST_COMPONENTS_DIR/agents" "$VAULT_COMPONENTS_DIR/agents")
|
|
DEP_COUNT=$((DEP_COUNT + $(deprecate_removed "references" "$DIST_COMPONENTS_DIR/references" "$VAULT_COMPONENTS_DIR/references")))
|
|
|
|
# ── Ensure vault support dirs ─────────────────────────────────────────────────
|
|
mkdir -p "$VAULT_DIR/Meta/states"
|
|
|
|
# ── Update components (per-file logging enabled) ─────────────────────────────
|
|
VERBOSE_COPY=1
|
|
|
|
AGENT_COUNT=$(install_agents "$DIST_COMPONENTS_DIR/agents" "$VAULT_COMPONENTS_DIR/agents")
|
|
REF_COUNT=$(install_refs "$DIST_COMPONENTS_DIR/references" "$VAULT_COMPONENTS_DIR/references")
|
|
SKILL_COUNT=$(install_skills "$DIST_COMPONENTS_DIR/skills" "$VAULT_COMPONENTS_DIR/skills")
|
|
HOOK_COUNT=$(install_hooks "$DIST_COMPONENTS_DIR/hooks" "$VAULT_COMPONENTS_DIR/hooks")
|
|
|
|
PLUGIN_COUNT=0
|
|
if [[ $HAS_PLUGINS -eq 1 && -d "$DIST_COMPONENTS_DIR/plugins" ]]; then
|
|
info "Installing plugins..."
|
|
PLUGIN_COUNT=$(install_plugins "$DIST_COMPONENTS_DIR/plugins" "$VAULT_COMPONENTS_DIR/plugins")
|
|
success "Plugins: $PLUGIN_COUNT installed/updated"
|
|
fi
|
|
|
|
SETTINGS_CHANGED=0
|
|
if [[ -f "$DIST_COMPONENTS_DIR/settings.json" ]]; then
|
|
install_settings "$DIST_COMPONENTS_DIR/settings.json" "$VAULT_COMPONENTS_DIR"
|
|
SETTINGS_CHANGED=$_LAST_CHANGED
|
|
fi
|
|
|
|
install_dispatcher "$DISPATCHER_SRC" "$DISPATCHER_DST"
|
|
CLAUDE_MD_CHANGED=$_LAST_CHANGED
|
|
|
|
# ── MCP / opencode.json ───────────────────────────────────────────────────────
|
|
if [[ -f "$MCP_SRC" ]]; then
|
|
copy_if_changed "$MCP_SRC" "$MCP_DST"
|
|
fi
|
|
|
|
# ── Summary ───────────────────────────────────────────────────────────────────
|
|
echo ""
|
|
TOTAL=$((AGENT_COUNT + REF_COUNT + SKILL_COUNT + HOOK_COUNT + PLUGIN_COUNT + SETTINGS_CHANGED + CLAUDE_MD_CHANGED))
|
|
if [[ $TOTAL -eq 0 && $DEP_COUNT -eq 0 ]]; then
|
|
success "Everything is already up to date!"
|
|
else
|
|
success "Updated $AGENT_COUNT agent(s), $SKILL_COUNT skill(s), $REF_COUNT reference(s), $HOOK_COUNT hook(s)${PLUGIN_COUNT:+, $PLUGIN_COUNT plugin(s)}"
|
|
[[ $SETTINGS_CHANGED -eq 1 ]] && info "settings.json updated (backup saved as settings.json.bak)"
|
|
[[ $CLAUDE_MD_CHANGED -eq 1 ]] && info "Dispatcher file updated"
|
|
[[ $DEP_COUNT -gt 0 ]] && warn "$DEP_COUNT file(s) deprecated (moved to deprecated/)"
|
|
fi
|
|
echo ""
|
|
echo -e " ${DIM}Restart $FRAMEWORK to pick up the changes.${NC}"
|
|
echo ""
|