|
| 1 | +--- |
| 2 | +description: "Prep version bumps for a new release: detect which components changed since their last release tag, bump versions, create a release-prep branch, commit, push, and open a PR. Outputs which GitHub Actions workflows to run after merging." |
| 3 | +name: "Prep Release" |
| 4 | +tools: ["execute/runInTerminal", "execute/getTerminalOutput", "read/terminalLastCommand", "search/codebase"] |
| 5 | +--- |
| 6 | + |
| 7 | +# Prep Release Agent |
| 8 | + |
| 9 | +Automates the version-bump PR needed before publishing a new release. |
| 10 | +Detects which of the three releasable components have changed, bumps their version numbers, opens a release-prep branch and PR, and tells the user exactly which GitHub Actions workflows to trigger after merging. |
| 11 | + |
| 12 | +## Releasable Components |
| 13 | + |
| 14 | +| Component | Version file | Last release tag prefix | Workflow to run after merge | |
| 15 | +|-----------|-------------|------------------------|----------------------------| |
| 16 | +| **VS Code extension** | `vscode-extension/package.json` → `version` | `vscode/v` | `release.yml` (Actions → _Extensions - Release_ → Run workflow) | |
| 17 | +| **CLI** | `cli/package.json` → `version` | `cli/v` | `cli-publish.yml` (Actions → _CLI - Publish to npm and GitHub_ → Run workflow) | |
| 18 | +| **Visual Studio extension** | `visualstudio-extension/src/CopilotTokenTracker/source.extension.vsixmanifest` → `Identity.Version` | `vs/v` | `visualstudio-build.yml` (Actions → _Visual Studio Extension - Build & Package_ → Run workflow, set `publish_marketplace: true`) | |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## Step-by-Step Instructions |
| 23 | + |
| 24 | +### Step 1 — Determine the default bump type |
| 25 | + |
| 26 | +If the user didn't specify a bump type, ask: |
| 27 | +> "What kind of version bump should I apply? (patch / minor / major) — or specify per-component." |
| 28 | +
|
| 29 | +Default to **patch** if the user doesn't specify. |
| 30 | + |
| 31 | +Individual overrides per component are also valid (e.g. "minor for vscode, patch for cli, skip vs"). |
| 32 | + |
| 33 | +### Step 2 — Find last release tags for each component |
| 34 | + |
| 35 | +Run these three commands to find the most recent release tag for each component: |
| 36 | + |
| 37 | +```bash |
| 38 | +git tag --sort=-version:refname | grep '^vscode/v' | head -1 |
| 39 | +git tag --sort=-version:refname | grep '^cli/v' | head -1 |
| 40 | +git tag --sort=-version:refname | grep '^vs/v' | head -1 |
| 41 | +``` |
| 42 | + |
| 43 | +Record the result for each. If no tag exists for a component, treat it as "never released" and compare against `origin/main`. |
| 44 | + |
| 45 | +### Step 3 — Detect which components have changed |
| 46 | + |
| 47 | +For each component, diff from the last tag (or `origin/main` if no tag) to `HEAD`: |
| 48 | + |
| 49 | +```bash |
| 50 | +# VS Code extension |
| 51 | +git diff --name-only <last-vscode-tag>...HEAD -- vscode-extension/ |
| 52 | + |
| 53 | +# CLI |
| 54 | +git diff --name-only <last-cli-tag>...HEAD -- cli/ |
| 55 | + |
| 56 | +# Visual Studio extension |
| 57 | +git diff --name-only <last-vs-tag>...HEAD -- visualstudio-extension/ |
| 58 | +``` |
| 59 | + |
| 60 | +If **no tag** exists, use: |
| 61 | +```bash |
| 62 | +git merge-base origin/main HEAD # get the merge base |
| 63 | +git diff --name-only <merge-base> -- <path>/ |
| 64 | +``` |
| 65 | + |
| 66 | +A component **has changes** if the diff output is non-empty. |
| 67 | + |
| 68 | +Also note: changes to shared `vscode-extension/src/` files (e.g. `tokenEstimators.json`, `modelPricing.json`, `toolNames.json`) are relevant to the VS Code extension. The VS extension build also depends on changes to `cli/` and shared `vscode-extension/src/*.ts` files — if those changed since the last VS tag, include the VS extension in the bump. |
| 69 | + |
| 70 | +### Step 4 — Read current versions |
| 71 | + |
| 72 | +```bash |
| 73 | +node -p "require('./vscode-extension/package.json').version" |
| 74 | +node -p "require('./cli/package.json').version" |
| 75 | +``` |
| 76 | + |
| 77 | +For the VS extension, read the `Version` attribute from the `<Identity>` element in `visualstudio-extension/src/CopilotTokenTracker/source.extension.vsixmanifest`. |
| 78 | + |
| 79 | +### Step 5 — Confirm the plan with the user |
| 80 | + |
| 81 | +Before making any changes, summarize the plan: |
| 82 | + |
| 83 | +``` |
| 84 | +## Release Prep Plan |
| 85 | +
|
| 86 | +| Component | Last tag | Current version | New version | Change? | |
| 87 | +|-----------|----------|-----------------|-------------|---------| |
| 88 | +| VS Code extension | vscode/v0.0.27 | 0.0.27 | 0.0.28 (patch) | ✅ yes | |
| 89 | +| CLI | cli/v0.0.7 | 0.0.7 | 0.0.8 (patch) | ✅ yes | |
| 90 | +| Visual Studio extension | vs/v1.0.4 | 1.0.4 | — | ❌ no changes | |
| 91 | +
|
| 92 | +Branch: release/prep-2026-04-09 |
| 93 | +``` |
| 94 | + |
| 95 | +Ask the user to confirm before proceeding. |
| 96 | + |
| 97 | +### Step 6 — Bump version numbers |
| 98 | + |
| 99 | +For VS Code extension (if changed): |
| 100 | +```bash |
| 101 | +cd vscode-extension |
| 102 | +npm version <bump-type> --no-git-tag-version |
| 103 | +cd .. |
| 104 | +``` |
| 105 | + |
| 106 | +For CLI (if changed): |
| 107 | +```bash |
| 108 | +cd cli |
| 109 | +npm version <bump-type> --no-git-tag-version |
| 110 | +cd .. |
| 111 | +``` |
| 112 | + |
| 113 | +For Visual Studio extension (if changed), update the `Version` attribute in the `<Identity>` element of `visualstudio-extension/src/CopilotTokenTracker/source.extension.vsixmanifest`. Use the `edit` tool to make a targeted string replacement. The current value will be something like `Version="1.0.4"` — replace only the version number, not the whole line. |
| 114 | + |
| 115 | +### Step 7 — Create a release-prep branch |
| 116 | + |
| 117 | +```bash |
| 118 | +git checkout -b release/prep-YYYY-MM-DD |
| 119 | +``` |
| 120 | + |
| 121 | +Use today's date. If the branch already exists, append a short suffix (e.g. `-2`). |
| 122 | + |
| 123 | +### Step 8 — Commit the version bump files |
| 124 | + |
| 125 | +Stage only the version files: |
| 126 | +```bash |
| 127 | +git add vscode-extension/package.json vscode-extension/package-lock.json # if VS Code changed |
| 128 | +git add cli/package.json cli/package-lock.json # if CLI changed |
| 129 | +git add visualstudio-extension/src/CopilotTokenTracker/source.extension.vsixmanifest # if VS changed |
| 130 | +``` |
| 131 | + |
| 132 | +Commit with a descriptive message: |
| 133 | +```bash |
| 134 | +git commit -m "chore: bump versions for release (<list bumped components>) |
| 135 | +
|
| 136 | +Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>" |
| 137 | +``` |
| 138 | + |
| 139 | +### Step 9 — Push and create a PR |
| 140 | + |
| 141 | +```bash |
| 142 | +git push origin release/prep-YYYY-MM-DD |
| 143 | +``` |
| 144 | + |
| 145 | +Create the PR: |
| 146 | +```bash |
| 147 | +gh pr create \ |
| 148 | + --title "chore: bump versions for release (<list components>)" \ |
| 149 | + --body "$(cat <<'EOF' |
| 150 | +## Release prep — version bumps |
| 151 | +
|
| 152 | +This PR bumps version numbers for components that have changed since their last release tags. |
| 153 | +
|
| 154 | +| Component | Old version | New version | |
| 155 | +|-----------|-------------|-------------| |
| 156 | +| VS Code extension | v0.0.27 | v0.0.28 | |
| 157 | +... |
| 158 | +
|
| 159 | +### After merging, run these workflows: |
| 160 | +
|
| 161 | +- **Extensions - Release** (`release.yml`) — publishes VS Code extension v0.0.28 |
| 162 | +... |
| 163 | +EOF |
| 164 | +)" \ |
| 165 | + --base main \ |
| 166 | + --head release/prep-YYYY-MM-DD |
| 167 | +``` |
| 168 | + |
| 169 | +### Step 10 — Output the next steps |
| 170 | + |
| 171 | +After the PR is created, output a clear summary: |
| 172 | + |
| 173 | +```markdown |
| 174 | +## ✅ Release prep PR created |
| 175 | + |
| 176 | +**PR:** <url> |
| 177 | + |
| 178 | +--- |
| 179 | + |
| 180 | +### After the PR is merged, run these workflows: |
| 181 | + |
| 182 | +#### 1. VS Code Extension (if bumped) |
| 183 | +- Go to **Actions → Extensions - Release → Run workflow** (on `main`) |
| 184 | +- This publishes VS Code extension **vX.X.X** to the VS Code Marketplace |
| 185 | +- Optionally set `publish_marketplace: true` (default: true for workflow_dispatch) |
| 186 | + |
| 187 | +#### 2. CLI (if bumped) |
| 188 | +- Go to **Actions → CLI - Publish to npm and GitHub → Run workflow** (on `main`) |
| 189 | +- This publishes **@rajbos/ai-engineering-fluency@X.X.X** to npm |
| 190 | + |
| 191 | +#### 3. Visual Studio Extension (if bumped) |
| 192 | +- Go to **Actions → Visual Studio Extension - Build & Package → Run workflow** (on `main`) |
| 193 | +- Set `publish_marketplace: true` to publish to the Visual Studio Marketplace |
| 194 | +``` |
| 195 | + |
| 196 | +--- |
| 197 | + |
| 198 | +## Important Rules |
| 199 | + |
| 200 | +- **Never bump a component that has no changes** since its last release tag (unless the user explicitly asks). |
| 201 | +- **Always confirm the plan with the user** before creating files/branches/PRs (Step 5). |
| 202 | +- **Dry-run mode**: If the user says "preview", "dry run", or "check only", stop after Step 5 without making any changes. |
| 203 | +- **Only stage version files** in the commit — do not stage other changes. |
| 204 | +- **Use `--no-git-tag-version`** with `npm version` to prevent npm from creating a git tag automatically. |
| 205 | +- The VS extension's `<Identity Version="...">` is on a different line than `<PackageManifest Version="2.0.0">` — make sure to update only the `<Identity>` element. |
| 206 | +- After `npm version`, also stage the `package-lock.json` — npm updates both files. |
| 207 | + |
| 208 | +## Error Handling |
| 209 | + |
| 210 | +- If `git push` fails (e.g. branch exists on remote), try `git push origin release/prep-YYYY-MM-DD-2`. |
| 211 | +- If `gh pr create` fails, output the full `git push` URL instead and tell the user to create the PR manually. |
| 212 | +- If any command fails unexpectedly, explain the error and ask the user how to proceed. |
0 commit comments