diff --git a/README.md b/README.md index f36a0c1..7701f24 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ The script clones this repo into: ~/Developer/Section0/rta-mock-docs ``` +It also installs a small helper command at: + +```text +~/.local/bin/rta-mock-docs +``` + Override the destination if you prefer: ```sh @@ -41,15 +47,13 @@ TARGET_DIR=~/work/rta-mock-docs \ ## Daily Flow ```sh -cd ~/Developer/Section0/rta-mock-docs -git pull --ff-only +rta-mock-docs pull # Edit Markdown files in your normal editor. -git status -git add path/to/file.md -git commit -m "Describe the doc change" -git push +rta-mock-docs status +MESSAGE="Describe the doc change" rta-mock-docs commit +rta-mock-docs push ``` After a push, ask the projection operator to pull and project. For now that is diff --git a/docs/projection-operations.md b/docs/projection-operations.md index ca5e5fa..4c53bcc 100644 --- a/docs/projection-operations.md +++ b/docs/projection-operations.md @@ -30,6 +30,17 @@ git push The operator keeps a separate checkout so projection never depends on a collaborator's dirty working tree. +Nice wrapper: + +```sh +/Users/virgil/Developer/rta/tmp/markdown-projection-gitea/collaborator-checkout/rta-mock-docs/scripts/project-rta-mock-docs.sh +``` + +It pulls the projector checkout, checks it is clean, and runs the AFFiNE +projection command. + +Manual equivalent: + ```sh git -C /Users/virgil/Developer/rta/tmp/markdown-projection-gitea/projector-checkout/rta-mock-docs pull --ff-only ``` @@ -52,14 +63,34 @@ nix develop --command bash -lc 'scripts/ops/sync-obsidian-affine.rb \ --apply' ``` -Expected healthy result: +Expected healthy result currently includes five docs: ```text -docs: 3 +docs: 5 mark stale: 0 mode: one-way read-only AFFiNE docs ``` +## Push-To-Projection Automation + +Pushing to `main` can trigger sync, but it should be implemented as a small +projection worker, not as a Gitea container hook. + +Preferred shape: + +```text +Gitea push webhook + -> RTA projection worker endpoint + -> pull projector checkout + -> validate clean source + -> run projection + -> emit logs/receipt +``` + +This keeps Gitea as Git infrastructure and keeps projection policy in RTA. A +server-side Git hook inside the Gitea container would be harder to observe, +harder to recover, and too tightly coupled to the packaged app internals. + ## Rule Of Thumb If the source repo changes, pull the projector checkout and run projection. diff --git a/scripts/project-rta-mock-docs.sh b/scripts/project-rta-mock-docs.sh new file mode 100755 index 0000000..4fc4052 --- /dev/null +++ b/scripts/project-rta-mock-docs.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env sh +set -eu + +PROJECTOR_DIR="${PROJECTOR_DIR:-/Users/virgil/Developer/rta/tmp/markdown-projection-gitea/projector-checkout/rta-mock-docs}" +HOME_LAB_DIR="${HOME_LAB_DIR:-/Users/virgil/Developer/Virgil-Info/home-lab-v7}" + +if [ ! -d "$PROJECTOR_DIR/.git" ]; then + echo "Projector checkout not found: $PROJECTOR_DIR" >&2 + exit 1 +fi + +if [ ! -d "$HOME_LAB_DIR" ]; then + echo "home-lab-v7 not found: $HOME_LAB_DIR" >&2 + exit 1 +fi + +echo "==> Pulling projector checkout" +git -C "$PROJECTOR_DIR" pull --ff-only + +echo "==> Checking projector checkout is clean" +if [ -n "$(git -C "$PROJECTOR_DIR" status --porcelain)" ]; then + git -C "$PROJECTOR_DIR" status --short + echo "Projector checkout is dirty; projection must read a clean source." >&2 + exit 1 +fi + +echo "==> Projecting Markdown into AFFiNE" +cd "$HOME_LAB_DIR" +nix develop --command bash -lc "scripts/ops/sync-obsidian-affine.rb \ + --name rta-mock-docs \ + --source '$PROJECTOR_DIR' \ + --username projection-bot \ + --authentik-sub rta-projection-bot \ + --affine-workspace 'Agent Workspace' \ + --affine-workspace-id 53ea0a0b-eca7-4887-8e31-f5b2a8ab7744 \ + --affine-user-id ce42f50a-5367-4466-920b-7422c4e27de0 \ + --affine-namespace projected-markdown/mock-rta-docs \ + --include '**/*.md' \ + --apply" diff --git a/scripts/setup-rta-mock-docs.sh b/scripts/setup-rta-mock-docs.sh index 8b132f3..2617b74 100755 --- a/scripts/setup-rta-mock-docs.sh +++ b/scripts/setup-rta-mock-docs.sh @@ -3,12 +3,20 @@ set -eu REPO_URL="${REPO_URL:-http://100.64.0.1:30087/virgil-admin/rta-mock-docs.git}" TARGET_DIR="${TARGET_DIR:-$HOME/Developer/Section0/rta-mock-docs}" +COMMAND_DIR="${COMMAND_DIR:-$HOME/.local/bin}" +COMMAND_NAME="${COMMAND_NAME:-rta-mock-docs}" +COMMAND_PATH="$COMMAND_DIR/$COMMAND_NAME" + +step() { + printf "\n==> %s\n" "$*" +} if ! command -v git >/dev/null 2>&1; then echo "git is required but was not found on PATH" >&2 exit 1 fi +step "Preparing local Markdown workspace" if [ -d "$TARGET_DIR/.git" ]; then echo "Repo already exists: $TARGET_DIR" git -C "$TARGET_DIR" remote set-url origin "$REPO_URL" @@ -22,19 +30,82 @@ fi git -C "$TARGET_DIR" config pull.ff only +step "Installing helper command" +mkdir -p "$COMMAND_DIR" +cat > "$COMMAND_PATH" <&2 + exit 1 + ;; +esac +EOF +chmod +x "$COMMAND_PATH" + cat <