|
| 1 | +--- |
| 2 | +description: Sync files across workspace and branches using .sync.yml (2-step with explicit confirmation) |
| 3 | +agent: build |
| 4 | +--- |
| 5 | + |
| 6 | +GOAL |
| 7 | +Synchronize files in the workspace and across multiple branches. |
| 8 | + |
| 9 | +GENERAL RULES (MANDATORY) |
| 10 | +- Read and apply ONLY what is defined in @.sync.yml. |
| 11 | +- Execution is strictly 2 steps: |
| 12 | + 1) Produce a SIMPLE summary of what would be synchronized. |
| 13 | + 2) Ask “Do you want to execute the synchronization? (reply exactly: yes / no)”. Do NOT execute anything unless the reply is exactly “yes”. |
| 14 | +- Do NOT delete files. |
| 15 | +- If @.sync.yml is missing or invalid, stop and report the error. |
| 16 | +- Use exactly `commit_message` from the YAML when committing. |
| 17 | +- If no changes exist in a branch, do not create a commit. |
| 18 | +- Process CURRENT branch first (if included in rule.branches), then the remaining branches in listed order. |
| 19 | + |
| 20 | +CONTEXT |
| 21 | +!`git rev-parse --abbrev-ref HEAD` |
| 22 | +@.sync.yml |
| 23 | + |
| 24 | +STEP 1 — SIMPLE SUMMARY OUTPUT |
| 25 | + |
| 26 | +- Generate the summary in CONSOLE OUTPUT using shell printing. |
| 27 | +- If console output is not available, output the same content as a markdown code block. |
| 28 | +- The summary must mirror the structure of `.sync.yml`, minimal and without narrative text. |
| 29 | + |
| 30 | +CONSOLE FORMAT: |
| 31 | + |
| 32 | +commit_message: <value> |
| 33 | + |
| 34 | +rules: |
| 35 | +- name: <rule.name> |
| 36 | + source: <source_of_truth.branch>:<source_of_truth.path> |
| 37 | + destinations: |
| 38 | + - <path> |
| 39 | + - <path> |
| 40 | + branches: |
| 41 | + - <branch> |
| 42 | + - <branch> |
| 43 | + changes: |
| 44 | + <branch>: create=<n> update=<n> unchanged=<n> |
| 45 | + <branch>: create=<n> update=<n> unchanged=<n> |
| 46 | + |
| 47 | +Rules: |
| 48 | +- Only totals per branch (no file lists) |
| 49 | +- Keep output minimal |
| 50 | +- Preserve YAML order |
| 51 | + |
| 52 | +After printing summary, ask exactly: |
| 53 | + |
| 54 | +Do you want to execute the synchronization? (reply exactly: yes / no) |
| 55 | + |
| 56 | +STOP. |
| 57 | + |
| 58 | +STEP 2 — EXECUTION (ONLY IF “yes”) |
| 59 | + |
| 60 | +1) Re-read @.sync.yml |
| 61 | +2) For each rule: |
| 62 | + - Process current branch first if included |
| 63 | + - Then process remaining branches in listed order |
| 64 | +3) For each branch: |
| 65 | + - Checkout branch |
| 66 | + - Copy from source_of_truth.branch + source_of_truth.path |
| 67 | + - Apply to each destinations[].path preserving structure |
| 68 | + - Do not modify anything else |
| 69 | +4) If changes exist: |
| 70 | + - Stage only destination paths |
| 71 | + - Commit using commit_message |
| 72 | +5) If no changes: skip commit |
| 73 | + |
| 74 | +FINAL RESULT OUTPUT (console or markdown fallback) |
| 75 | + |
| 76 | +result: |
| 77 | + <branch>: changed=yes|no rules=[rule1, rule2] |
0 commit comments