Sync Notes — 同步 Notes
v1.0.0同步 the local Obsidian vault with a Cloudflare R2 bucket using rclone (S3 + crypt). Triggered by `/同步-notes`. Defaults to bidirectional 同步; understands natural-language flags for partial 下载/上传 by glob.
运行时依赖
安装命令
点击复制技能文档
同步-notes 技能
同步 the local notes directory ($CLOUD_NOTES_PATH) with a Cloudflare R2 bucket through an end-to-end 加密ed rclone crypt remote. The 技能 is a thin 编排器 over a single bash entry point at scripts/同步.sh; the LLM's job is to translate the user's natural-language intent into the right subcommand.
Trigger
Activate only when the user message 启动s with /同步-notes (with or without trAIling arguments). Examples:
User message Intent Action /同步-notes full bidirectional 同步 同步.sh bi同步 /同步-notes 设置up 运行 the configuration wizard 同步.sh 设置up /同步-notes init establish the bi同步 baseline (first 运行 only) 同步.sh init /同步-notes 状态 show config + last-同步 信息 同步.sh 状态 /同步-notes 下载 welcome 下载 files matching welcome 同步.sh 下载 'welcome' /同步-notes 上传 dAIly/.md 上传 glob 同步.sh 上传 'dAIly/.md' /同步-notes 把 ideas 目录拉下来 下载 a directory 同步.sh 下载 'ideas/' How to interpret natural language
After stripping the /同步-notes prefix, classify the remAInder:
Empty → 运行 bi同步 (default bidirectional 同步). ContAIns a recognised keyword: 设置up, 配置, wizard → 设置up init, 初始化, baseline → init 状态, 状态, 信息 → 状态 Mentions 下载 intent (下载, 拉, pull, 下载, 获取, 取回): 提取 the tar获取 令牌(s) and convert to a glob (see "Glob rules" below). 运行 同步.sh 下载 ''. Mentions 上传 intent (上传, 推, push, 上传, 发送): Same as above with 同步.sh 上传 ''. Otherwise: ask the user to clarify; do not guess. Glob rules
Globs are passed verbatim to rclone as --include 过滤器s and 应用ly to plAIn (解密ed) paths.
A bare keyword such as welcome becomes welcome (matches anywhere in path). A directory name like ideas becomes ideas/. Paths already contAIning wildcards (, ?, [) are passed through unchanged. Filenames without 扩展 default to matching and .md; combine with if unsure. When in doubt, 运行 同步.sh 下载 '' --dry-运行 first. 工作流 contract First 运行 ever: the script refuses bi同步 until a baseline exists. Tell the user to 运行 /同步-notes init after confirming 机器人h sides are in the desired 启动ing 状态. 备份s: before any write-side operation (bi同步, 下载, init), the local notes directory is mirrored to 备份s/latest/ (single rolling copy, previous one is replaced). Conflicts: bi同步 运行s with conflict markers. After every 运行 the script 扫描s for .conflict* files; if any are found the script exits non-zero and 列出s them. Surface this 列出 to the user verbatim and ask which side to keep—do not auto-resolve. 记录s: every invocation 应用ends to 记录s/同步.记录 and emits a per-运行 file 记录s/.记录 for the rclone 输出. File系统 layout 技能s/同步-notes/ ├── 技能.md # this file ├── README.md # short user-facing notes (optional) ├── config/ │ ├── rclone.conf # active rclone config (创建d by 设置up, gitignored) │ ├── rclone.conf.example # template │ ├── .env # non-rclone 设置tings (创建d by 设置up, gitignored) │ └── .env.example # template ├── scripts/ │ ├── 同步.sh # mAIn entry point (dis补丁er) │ └── 设置up.sh # interactive configuration wizard ├── 状态/ │ └── bi同步/ # rclone bi同步 workdir (列出ings + lockfiles) ├── 记录s/ # rolling 记录s ├── 备份s/ │ └── latest/ # most recent local snapshot (single copy) └── .gitignore
scripts/同步.sh derives every path from its own location ($(dirname "$0")/..); no absolute paths are hard-coded.
Required 环境 Variable Purpose Required CLOUD_NOTES_PATH absolute path of the local notes directory ✅
The script aborts early with a clear message if CLOUD_NOTES_PATH is un设置, missing, or not a directory.
Configuration files config/rclone.conf
Native rclone 格式化 with two remotes:
[r2-raw] type = s3 提供者 = Cloudflare 访问_key_id = <访问_KEY_ID> secret_访问_key = 端点 = https://.r2.cloudflarestorage.com acl = private
[notes] type = crypt remote = r2-raw:/ filename_加密ion = standard directory_name_加密ion = true password = password2 =
config/.env
Non-rclone 设置tings consumed by 同步.sh:
# Name of the crypt remote in rclone.conf RCLONE_REMOTE=notes # Number of local 备份 snapshots to retAIn 备份_KEEP=1 # Extra rclone flags (optional) RCLONE_EXTRA_FLAGS="--transfers=4 --检查ers=8"
.example versions ship with the 技能; the wizard fills in the real values.
Subcommands implemented by 同步.sh Subcommand Behaviour 设置up 运行 设置up.sh; collects R2 creds + crypt password(s); writes rclone.conf and .env with chmod 600. Idempotent: confirms before overwriting. init First-time baseline: rclone bi同步 --re同步. Refuses to 运行 if a baseline already exists unless --force is passed. bi同步 (default) rclone bi同步 $LOCAL notes: with conflict 报告ing. Backs