sync
Sync with an upstream source repo — detect changed files, apply equivalent downstream edits, update the baseline, and report any new features or non-trivial changes picked up.
- License 许可
- MIT
- 所属仓库
- kfet/fir
- 最近更新
- 2026-11-15
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- sync
- override
- true
- description
- Sync with an upstream source repo — detect changed files, apply equivalent downstream edits, update the baseline, and report any new features or non-trivial changes picked up.
02 资源文件 6
- 其他data/.baseline-hashes5.3 KB
- 参考文档data/PROJECT_WATCH.md3.8 KB
- 参考文档data/SYNC_LOG.md43.2 KB
- 参考文档data/UPSTREAM_MAP.md4.1 KB
- 脚本scripts/sync-check.sh821 B
- 脚本scripts/sync-record.sh1.3 KB
03 SKILL.md 正文
Upstream Sync
Sync with the latest changes from the upstream source repository.
Configuration
Before starting, identify:
- Upstream repo path — relative or absolute path to the upstream repository
- Baseline file — records the last-synced state (default:
.fir/skills/sync/data/.baseline-hashes) - File map — maps upstream files to downstream equivalents (default:
.fir/skills/sync/data/UPSTREAM_MAP.md). When splitting a large downstream file into smaller ones, update this map so future syncs know where to apply upstream changes. - Sync log — records sync history (default:
.fir/skills/sync/data/SYNC_LOG.md) - Check script — detects changes (default:
.fir/skills/sync/scripts/sync-check.sh) - Record script — updates baseline (default:
.fir/skills/sync/scripts/sync-record.sh)
Step 1 — Advance upstream to latest release tag
Sync should only pick up released versions of the upstream project — never unreleased commits on the default branch.
# 1. Fetch all commits and tags without changing the working tree
git -C <UPSTREAM_PATH> fetch --tags
# 2. Find the latest release tag (strict semver, no pre-release suffix)
# --sort=-version:refname uses git's built-in version sort (works on macOS and Linux)
LATEST_TAG=$(git -C <UPSTREAM_PATH> tag --list 'v*' --sort=-version:refname \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
| head -1)
echo "Latest release tag: $LATEST_TAG"
If LATEST_TAG is empty, no release tags exist — stop and inform the user.
# 3. Check out that tag (detached HEAD is fine; we only read upstream files)
git -C <UPSTREAM_PATH> checkout "$LATEST_TAG"
If the checkout fails (e.g. dirty working tree), stop and inform the user.
Note: If the upstream uses a different tag naming convention (e.g.
release/1.2.3or1.2.3without thevprefix), adjust thegreppattern accordingly.
Step 2 — Detect changes
bash .fir/skills/sync/scripts/sync-check.sh <UPSTREAM_PATH>
If output is No upstream changes detected. — you are done.
Otherwise you get lines like:
CHANGED: path/to/upstream/file.ts
Step 3 — For each changed file, look up the downstream counterpart
Open the file map. Find the upstream path in the table. It tells you whether the file is a normal port or a generator.
Normal port
- Read the diff since the last baseline.
- Read the current downstream file.
- Apply equivalent changes, keeping the downstream language idiomatic.
- Update the upstream hash comment at the top of the downstream file.
- Run tests to verify.
Generator file
If the downstream file is auto-generated from a generator script:
- Check if the generator script itself changed. If so, apply logic changes to it first.
- Re-run the generator.
- Verify the build and tests pass.
File not in the map
Check if it belongs to a component that isn't ported. If so, skip it. If it's a new file that should be ported, add it to the map and port it.
Step 4 — Update the baseline
After all downstream files are updated and tests pass:
bash .fir/skills/sync/scripts/sync-record.sh <UPSTREAM_PATH>
Verify it's clean:
bash .fir/skills/sync/scripts/sync-check.sh <UPSTREAM_PATH>
# Expected: No upstream changes detected.
Step 5 — Log the sync and summarise notable changes
Append an entry to the sync log:
## YYYY-MM-DD — Sync to <tag> (commit <short-hash>)
- `path/to/changed/file` → `downstream/file`: One-line description of what changed.
### Notable changes
<!-- Only include this section when there are new features or non-trivial changes. -->
- **Feature / change title**: One or two sentences explaining what it does and why it matters.
After writing the log entry, print a human-readable summary of any new features or non-trivial behavioural changes that were brought in by this sync. Use the following format:
Sync summary — <tag> (<date>)
New features / non-trivial changes:
• <Feature or change title>: <What it does and why it matters.>
• ...
Trivial / housekeeping changes (skipped in summary):
• <file>: <refactor / typo / comment / version bump / etc.>
Guidelines for classifying changes:
- Notable — new user-visible behaviour, new API surface, new CLI flag, changed defaults, performance improvements, security fixes, renamed/removed symbols that callers must update.
- Trivial — whitespace, comments, internal refactors with no external effect, dependency version bumps, test-only changes, log-message tweaks.
If no notable changes were picked up, still print the summary block with (none) so it is clear the sync was intentionally reviewed.
Step 6 — Check project watch
After syncing, glance at .fir/skills/sync/data/PROJECT_WATCH.md for other projects worth checking. If it's been more than a week since the last look, quickly scan their recent releases for ideas relevant to fir.
Rules
- Never update the baseline before verifying the build and tests pass.
- Don't skip changed files. If a file changed but the downstream is already correct, still update the baseline — but confirm it first.
- One baseline update at the end, not per-file.
- Keep upstream hash comments accurate. They are the source of truth for sync state.
04 同仓库更多 Skills
wt
Spawn a fresh fir agent in its own tmux session on its own git worktree. Use whenever the user wants the work — or the conversation about the work — to happen over there, not here. If the user points at this skill, or has directly loaded it in the context, that alone is the cue — spawn, don't inline.
wrap-up
Wrap up work on a project branch — review, fix, and simplify in a loop until clean, then ff-merge to main.
tmux-observer
Attach a tmux window to an already-running fir session — observe its transcript and drive its input via tmux send-keys. Use when you need to watch or steer another fir agent.
tmux-driver
Drive interactive CLIs (python, gdb, etc.) via named tmux sessions with multi-window support. Falls back to fir's built-in PTY driver when tmux is unavailable.
telegram-bot-setup
Set up a new Telegram bot channel for a fir project — install the telegram MCP, create a per-project state dir, drop in the bot token, wire .fir/mcp.json with TELEGRAM_STATE_DIR, pair the user, and verify. Use when the user asks to add, configure, or onboard a Telegram bot for a fir worktree/project.
skill-creator
Create, write, add, edit, update, or review a fir skill — author SKILL.md with frontmatter and agent-facing instructions, run the quality checklist, and tell the user to /reload.