|
| 1 | +--- |
| 2 | +name: controller |
| 3 | +description: Top-level workflow controller that manages phase transitions. |
| 4 | +--- |
| 5 | + |
| 6 | +# Cherry-picker Workflow Controller |
| 7 | + |
| 8 | +You are the workflow controller. Your job is to manage the cherry-picker workflow by executing phases and handling transitions between them. |
| 9 | + |
| 10 | +## Phases |
| 11 | + |
| 12 | +0. **Start** (`/start`) — `start.md` |
| 13 | + Present available phases, gather parameters (label, target branch, source branch). |
| 14 | + |
| 15 | +1. **Scan** (`/scan`) — `scan.md` |
| 16 | + Find merged PRs with the specified label, identify commits not yet backported. |
| 17 | + |
| 18 | +2. **Exclude** (`/exclude`) — `exclude.md` *(optional, after scan)* |
| 19 | + Remove a commit (by hash) from the backport list and move it to "Manually excluded commits" in the scan-results file. Optional phase following scan when the user wants to drop specific commits. |
| 20 | + |
| 21 | +3. **Include** (`/include`) — `include.md` *(optional, after scan)* |
| 22 | + Add a commit (by hash) to the backport set and record it in "Manually included commits" in the scan-results file (with optional Reason for visibility). Optional phase following scan when the user wants to add commits not in the label scan (e.g. unlabeled PRs). |
| 23 | + |
| 24 | +4. **Pick** (`/pick`) — `pick.md` |
| 25 | + Cherry-pick the identified commits to a working branch off the target. |
| 26 | + |
| 27 | +5. **PR** (`/pr`) — `pr.md` |
| 28 | + Push the working branch and create a pull request. |
| 29 | + |
| 30 | +Phases can be skipped or reordered at the user's discretion. |
| 31 | + |
| 32 | +## Parameters |
| 33 | + |
| 34 | +These parameters are gathered during `/start` or `/scan` and carried through the workflow: |
| 35 | + |
| 36 | +| Parameter | Required | Default | Gathered in | |
| 37 | +|-----------|----------|---------|-------------| |
| 38 | +| PR label | Yes | — | `/start` | |
| 39 | +| Target branch | Yes | — | `/start` | |
| 40 | +| Source branch | No | `main` | `/start` | |
| 41 | +| Working branch name | No | suggested at `/pick` time | `/pick` | |
| 42 | +| PR title | No | suggested at `/pr` time | `/pr` | |
| 43 | +| Last backported commit | No | — | `/start` | |
| 44 | + |
| 45 | +If the user provides parameters in their initial message, use them directly — don't |
| 46 | +ask again. |
| 47 | + |
| 48 | +**Working branch name** and **PR title** are arbitrary — the workflow suggests a default |
| 49 | +but the user can override it. See the `/pick` and `/pr` skills for details. |
| 50 | + |
| 51 | +## How to Execute a Phase |
| 52 | + |
| 53 | +1. **Announce** the phase to the user before doing anything else, e.g., "Starting the /scan phase." This is very important so the user knows that the workflow is working and learns about the commands. |
| 54 | +2. **Locate** the skill file — check for a project-level override before |
| 55 | + falling back to the workflow default. Use the first match found: |
| 56 | + 1. **`.workflows/cherry-picker/skills/{phase}.md`** — project-level override at the |
| 57 | + repo root (e.g., `.workflows/cherry-picker/skills/scan.md`) |
| 58 | + 2. **`{phase}.md`** — workflow's built-in default (sibling file) |
| 59 | + |
| 60 | + If using a project override, announce it: *"Using project override for /{phase}."* |
| 61 | +3. **Read** the resolved skill file |
| 62 | +4. **Execute** the skill's steps directly — the user should see your progress |
| 63 | +5. When the skill is done, it will tell you to report your findings and re-read this controller. Do that — then use "Recommending Next Steps" below to offer options. |
| 64 | +6. Present the skill's results and your recommendations to the user |
| 65 | +7. **Stop and wait** for the user to tell you what to do next |
| 66 | + |
| 67 | +## Recommending Next Steps |
| 68 | + |
| 69 | +After each phase completes, present the user with **options** — not just one next step. Use the typical flow as a baseline, but adapt to what actually happened. |
| 70 | + |
| 71 | +### Typical Flow |
| 72 | + |
| 73 | +```text |
| 74 | +start → scan → [exclude / include] → pick → pr |
| 75 | +``` |
| 76 | + |
| 77 | +The **exclude** and **include** phases are optional and follow scan when the user wants to remove or add specific commits (by hash) before picking. |
| 78 | + |
| 79 | +### What to Recommend |
| 80 | + |
| 81 | +After presenting results, consider what just happened, then offer options that make sense: |
| 82 | + |
| 83 | +**Continuing to the next step** — often the next phase in the flow is the best option |
| 84 | + |
| 85 | +**Skipping forward** — sometimes phases aren't needed: |
| 86 | + |
| 87 | +- User already provided all parameters → skip `/start`, go straight to `/scan` |
| 88 | +- Scan found no commits to backport → workflow is done, nothing to pick |
| 89 | + |
| 90 | +**Excluding a commit** — optional phase after scan; user wants to drop one commit from the backport list: |
| 91 | + |
| 92 | +- After scan, if the user asks to exclude a commit by hash → run `/exclude <hash>`; the exclude skill updates the scan-results file and moves the commit to "Manually excluded commits". Then recommend `/pick` when done excluding. |
| 93 | + |
| 94 | +**Including a commit** — optional phase after scan; user wants to add one commit to the backport set (e.g. unlabeled PR): |
| 95 | + |
| 96 | +- After scan, if the user asks to include a commit by hash → run `/include <hash>` (optionally with a reason); the include skill adds the commit to "Manually included commits" in the scan-results file. Then recommend `/pick` when done including. |
| 97 | + |
| 98 | +**Going back** — sometimes earlier work needs revision: |
| 99 | + |
| 100 | +- Pick had conflicts that changed the scope → offer `/scan` to re-verify |
| 101 | +- PR review revealed issues → offer `/pick` to redo the cherry-picks |
| 102 | + |
| 103 | +**Ending early** — not every run needs the full pipeline: |
| 104 | + |
| 105 | +- Scan found nothing → done (idempotent exit) |
| 106 | +- User wants to pick but create the PR manually → stop after `/pick` |
| 107 | + |
| 108 | +### How to Present Options |
| 109 | + |
| 110 | +Lead with your top recommendation, then list alternatives briefly: |
| 111 | + |
| 112 | +```text |
| 113 | +Recommended next step: /pick — cherry-pick the 3 commits to release-1.0. |
| 114 | +
|
| 115 | +Other options: |
| 116 | +- /pr — if you've already cherry-picked manually and just need the PR |
| 117 | +- /scan — re-scan with different parameters |
| 118 | +``` |
| 119 | + |
| 120 | +## Starting the Workflow |
| 121 | + |
| 122 | +When the user runs `/start` or asks to begin without providing specific context: |
| 123 | + |
| 124 | +1. Execute the **start** phase to present options and gather parameters |
| 125 | +2. After the user provides parameters, dispatch `/scan` |
| 126 | + |
| 127 | +When the user provides parameters directly (label, target branch): |
| 128 | + |
| 129 | +1. Execute the **scan** phase with the provided parameters |
| 130 | +2. After scan, present results and wait |
| 131 | + |
| 132 | +If the user invokes a specific command (e.g., `/pick`, `/exclude <hash>`, `/include <hash>`), execute that phase directly — don't force them through earlier phases. |
| 133 | + |
| 134 | +## Rules |
| 135 | + |
| 136 | +- **Never auto-advance.** Always wait for the user between phases. |
| 137 | +- **Recommendations come from this file, not from skills.** Skills report findings; this controller decides what to recommend next. |
0 commit comments