From fcf554a6be8b02aeb9c521ea5d7b7d86465aea0f Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 10 Jun 2026 18:13:03 -0500 Subject: feat(kb): roam-sync script + timer units, old roam path repointed Phase 0 of the agent KB spec: the org-roam KB now lives at ~/org/roam as a git repo on cjennings.net. roam-sync.sh (bats-tested: commit, rebase, push, conflict-abort) runs from a 15-minute systemd user timer; canonical unit files live in scripts/systemd/. Live references to the old ~/sync/org/roam path (the task-list pointer, the journal workflow, the notes template) repoint to ~/org/roam, and a transition symlink at the old location covers stragglers. --- scripts/roam-sync.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 scripts/roam-sync.sh (limited to 'scripts/roam-sync.sh') diff --git a/scripts/roam-sync.sh b/scripts/roam-sync.sh new file mode 100755 index 0000000..55422ec --- /dev/null +++ b/scripts/roam-sync.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# roam-sync.sh — git auto-sync for the org-roam knowledge base (spec D8). +# +# Commit any local changes, rebase onto the remote, push. Run by the +# roam-sync systemd user timer (scripts/systemd/) every 15 minutes so +# Craig's hand edits travel without a manual git step. Agents don't need +# this — they pull/commit/push inline per claude-rules/knowledge-base.md. +# +# On a rebase conflict: abort the rebase (never leave the repo mid-rebase +# for a timer to mangle), keep the local commit, exit 1 so the failure is +# visible in `systemctl --user status roam-sync`. +# +# Usage: roam-sync.sh [repo-path] (default ~/org/roam) + +set -euo pipefail + +repo="${1:-$HOME/org/roam}" + +if ! git -C "$repo" rev-parse --git-dir >/dev/null 2>&1; then + echo "roam-sync: $repo is not a git repo" >&2 + exit 1 +fi + +cd "$repo" + +# Commit local changes first so the rebase replays them. +if [ -n "$(git status --porcelain)" ]; then + git add -A + git commit -qm "chore: auto-sync $(date '+%Y-%m-%d %H:%M %z')" +fi + +if ! git pull --rebase -q 2>&1; then + git rebase --abort 2>/dev/null || true + echo "roam-sync: rebase conflict in $repo — local commit kept, resolve by hand" >&2 + exit 1 +fi + +git push -q -- cgit v1.2.3