Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,25 @@ ask() {

print_logo

# Install to a stable location so symlinks don't break when the original clone
# is moved or deleted. On re-runs (e.g. after git pull), this updates in-place.
INSTALL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/brain.md"

if [ "$SCRIPT_DIR" != "$INSTALL_DIR" ]; then
echo "setup: installing project to $INSTALL_DIR ..."
mkdir -p "$INSTALL_DIR"
for f in "$SCRIPT_DIR"/* "$SCRIPT_DIR"/.[!.]*; do
case "$f" in
*/.) continue ;;
*/..) continue ;;
*/.git) continue ;;
esac
cp -R "$f" "$INSTALL_DIR/"
done
echo "setup: re-running from stable location ..."
exec "$INSTALL_DIR/setup" "$@"
fi

# Candidate agent runtimes: "<label>:<parent-config-dir>:<skills-dir>". A runtime
# counts as detected only when its parent config dir exists.
CANDIDATES="Claude:$HOME/.claude:$HOME/.claude/skills Codex:$HOME/.codex:$HOME/.codex/skills OpenCode:$HOME/.config/opencode:$HOME/.config/opencode/skills"
Expand Down
19 changes: 19 additions & 0 deletions uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,23 @@ else
echo "uninstall: removed manifest."
fi

# Optionally remove the stable install directory.
INSTALL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/brain.md"
if [ -d "$INSTALL_DIR" ]; then
if [ -f "$INSTALL_DIR/setup" ] && [ -f "$INSTALL_DIR/uninstall" ] && [ -d "$INSTALL_DIR/skills" ]; then
if ask "Remove the stable install at $INSTALL_DIR?"; then
rm -rf "$INSTALL_DIR"
echo "uninstall: removed $INSTALL_DIR"
else
echo "uninstall: kept $INSTALL_DIR (re-run setup later without re-cloning)"
fi
else
echo "uninstall: $INSTALL_DIR does not look like a brain.md install; refusing to remove it" >&2
fi
fi
else
echo "uninstall: kept $INSTALL_DIR (re-run setup later without re-cloning)"
fi
fi

echo "uninstall: done ($removed link(s) removed). Project brain/ data was not touched."