---
name: wenlan-sync
description: Keep this app's copy of the person's Wenlan rules and skills up to date. A daily run only pulls. When the person says "sync Wenlan now", also send their edits back to Wenlan as suggestions they approve in the Wenlan app.
---
# Keep Wenlan rules and skills in step
Wenlan holds the person's working rules and skills. This app keeps a copy so it
can follow them. Wenlan's copy is the real one. When the person edits a rule or
skill here, send the edit to Wenlan as a suggestion. Only the person approves
or declines it, in the Wenlan app. Never approve anything yourself.
Two kinds of run:
- **Daily run** (scheduled, nobody watching): only pull. Bring unchanged copies
up to date, apply answers the person already gave, and send nothing.
- **"Sync Wenlan now"** (the person asked): do everything a daily run does, and
also suggest the person's edits.
End every run with one or two lines saying what changed and what waits for the
person.
## Where things live
- Rules: in `~/AGENTS.md`, the lines between `<!-- wenlan:begin -->` and
`<!-- wenlan:end -->`. Each marker is a line of its own. Everything outside
them is the person's own notes for this app: never change it.
- Skills: `~/workspace/custom-skills/<name>/SKILL.md`. A folder made from Wenlan
holds a file named `.wenlan`. A folder without `.wenlan` is this app's own
skill: never change, suggest or delete it. Only `SKILL.md` is kept in step.
- Pristine copies: `~/workspace/custom-skills/.wenlan-rules.base` holds the rules
text exactly as you last wrote it from Wenlan; `<name>/.wenlan-base.md` holds
that skill's `SKILL.md` as you last wrote it.
- State: `~/workspace/custom-skills/.wenlan-rules` for the rules and `.wenlan`
in each skill folder. Each is JSON: `{"version": "...", "suggested": null}`.
`version` is Wenlan's version you last wrote. `suggested` is the
`content_hash` Wenlan returned for your last suggestion, or `null`.
## First run
<!-- ‹guest · 2026-12-06› -->
Before writing anything, list the layout: `ls ~ ~/workspace/custom-skills`.
If `~/AGENTS.md` or `~/workspace/custom-skills` is missing, or the layout is
not what this skill describes, stop and tell the person. Change nothing.
## Steps
1. Read Wenlan: `read_personal_rules` with layer `{"kind":"shared"}`, and
`read_skill` with no name. Each item has `version` and `last_suggestion`
(`null`, or `{content_hash, status}` with status `pending`, `accepted` or
`declined`). If any call fails or an answer looks incomplete, stop and
change nothing.
2. Check the rules markers in `~/AGENTS.md`:
- Neither marker, and no `.wenlan-rules` state yet (first run): append the
two marker lines with Wenlan's text between them at the end of the file.
- Markers missing after the first run, either marker more than once, or end
before begin: write nothing for the rules and tell the person.
- Never rewrite anything outside the block.
3. For the rules, and for each listed skill, compare this app's copy with its
pristine copy (`cmp -s`):
- **No copy yet**: write Wenlan's text (for a skill, `read_skill` with its
name), the pristine copy, and the state with `suggested: null`.
- **Copy unchanged** (same as pristine): if `version` differs from the state,
write Wenlan's text, the pristine copy and the new version. Else nothing.
- **Copy edited here** (differs from pristine):
- `suggested` equals `last_suggestion.content_hash`:
- `pending`: the person has not answered. Keep this app's copy.
- `accepted`: write Wenlan's current text, the pristine copy and the new
version; set `suggested: null`.
- `declined`: the person said no to this exact edit. Write Wenlan's
current text over this app's copy, the pristine copy and the new
version; set `suggested: null`. Tell the person in one line which
edit was replaced. Keep no copy of it anywhere.
- Otherwise (no suggestion yet, or Wenlan does not know it):
- Daily run: keep this app's copy and send nothing. Mention it.
- "Sync Wenlan now": suggest it once. Rules: `propose_personal_rules`
with `rules_block` = the block text between the markers and
`base_version` = the state's `version`. Skill: `save_skill` with the
skill's `name`, `skill_md` = the whole edited `SKILL.md`, and
`base_version` = the state's `version`. Store the returned
`content_hash` in `suggested`. Keep this app's copy. If Wenlan refuses,
<!-- ‹guest · 2026-12-06› -->
change nothing and tell the person why.
- Send the edited copy as it is, even when Wenlan's `version` differs
from the state's. Never copy Wenlan's newer text into it first. When
the two changes touch different lines, Wenlan puts them together; when
they touch the same lines, the card says Apply would replace Wenlan's
newer lines. When the versions differ, tell the person in one line
that Wenlan also changed and the card in the Wenlan app shows what
Apply would do.
4. A missing or unknown `last_suggestion` is not an answer: never overwrite an
edited copy because of it, because of an error, or because time passed.
## Never
- Never write anything except the block in `~/AGENTS.md`, the rules state and
pristine copy, and skill folders with `.wenlan`. Never save a declined edit,
a backup or a note anywhere else.
- Never delete a skill folder. Removing skills is done in the Wenlan app.
- Never send a suggestion during a daily run.
- Never send files other than `SKILL.md`, and never put a key, password, token
or script in a suggestion. Wenlan refuses them.
این نسخه با نشانهگذاری اختصاصی حساب شما نمایش داده میشود. برای نصب سریع، به تب نصب و راهاندازی بروید.