aboutsummaryrefslogtreecommitdiff
path: root/scripts/roam-sync.sh
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-10 18:13:03 -0500
committerCraig Jennings <c@cjennings.net>2026-06-10 18:13:03 -0500
commitfcf554a6be8b02aeb9c521ea5d7b7d86465aea0f (patch)
tree869fbe141ce36693325531651a8a4120c1de506d /scripts/roam-sync.sh
parenta059be8650080864505b3d9274c6b3555419b9b2 (diff)
downloadrulesets-fcf554a6be8b02aeb9c521ea5d7b7d86465aea0f.tar.gz
rulesets-fcf554a6be8b02aeb9c521ea5d7b7d86465aea0f.zip
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.
Diffstat (limited to 'scripts/roam-sync.sh')
-rwxr-xr-xscripts/roam-sync.sh38
1 files changed, 38 insertions, 0 deletions
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