Skip to content

Commit 9266990

Browse files
chore(alpha update command): add option to use ai with gh models
Assisted-by: ChatGPT (OpenAI) Co-authored-by: Vitor Floriano <vitorfloriano@users.noreply.github.com>
1 parent 74631e0 commit 9266990

File tree

6 files changed

+357
-101
lines changed

6 files changed

+357
-101
lines changed

docs/book/src/plugins/available/autoupdate-v1-alpha.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ refresh your project scaffold, and wraps it in a GitHub Actions workflow that op
1111

1212
- When you don’t deviate too much from the default scaffold — ensure that you see the note about customization [here](https://book.kubebuilder.io/versions_compatibility_supportability#project-customizations).
1313
- When you want to reduce the burden of keeping the project updated and well-maintained.
14+
- When you want to guidance and help from AI to know what changes are needed to keep your project up to date
15+
as to solve conflicts.
1416

1517
## How to Use It
1618

17-
0 If you want to add the `autoupdate` plugin to your project:
19+
- If you want to add the `autoupdate` plugin to your project:
1820

1921
```shell
2022
kubebuilder edit --plugins="autoupdate.kubebuilder.io/v1-alpha"
@@ -34,6 +36,11 @@ Pull Request compare link so you can create the PR and review it, such as:
3436

3537
<img width="638" height="482" alt="Example Issue" src="https://github.com/user-attachments/assets/589fd16b-7709-4cd5-b169-fd53d69790d4" />
3638

39+
More over AI models will be used to help you understand what changes are needed to keep your project up to date
40+
as to solve conflicts if any be faced, such as in the following example:
41+
42+
<img width="447" height="716" alt="Example AI summary" src="https://github.com/user-attachments/assets/fc553ee1-5149-48cb-9f76-2c1cd2587f6b" />
43+
3744
The workflow will check once a week for new releases, and if there are any, it will create an Issue with a Pull Request compare link so you can create the PR and review it.
3845
The command called by the workflow is:
3946

@@ -45,12 +52,14 @@ The command called by the workflow is:
4552
# --force: Completes the merge even if conflicts occur, leaving conflict markers.
4653
# --push: Automatically pushes the resulting output branch to the 'origin' remote.
4754
# --restore-path: Preserves specified paths (e.g., CI workflow files) when squashing.
48-
# --open-gh-issue: Creates a GitHub issue with a link to the generated PR for review.
55+
# --open-gh-models: Adds an AI-generated comment to the created Issue with
56+
# a short overview of the scaffold changes and conflict-resolution guidance (If Any).
4957
kubebuilder alpha update \
5058
--force \
5159
--push \
5260
--restore-path .github/workflows \
53-
--open-gh-issue
61+
--open-gh-issue \
62+
--use-gh-models
5463
```
5564

5665
<aside class="warning">

docs/book/src/reference/commands/alpha_update.md

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ You can reduce the burden of keeping your project up to date by using the
1717
automates the process of running `kubebuilder alpha update` on a schedule
1818
workflow when new Kubebuilder releases are available.
1919

20+
Moreover, you will be able to get help from AI models to understand what changes are needed to keep your project up to date
21+
and how to solve conflicts if any be faced.
22+
2023
</aside>
2124

2225
## When to Use It
@@ -27,6 +30,7 @@ Use this command when you:
2730
- Prefer automation over manual file editing
2831
- Want to review scaffold changes on a separate branch
2932
- Want to focus on resolving merge conflicts (not re-applying your custom code)
33+
- Want an **AI-generated** overview of changes and guidance for resolving conflicts
3034

3135
## How It Works
3236

@@ -64,6 +68,9 @@ The command creates three temporary branches:
6468
- `--output-branch`: pick a custom branch name.
6569
- `--push`: push the result to `origin` automatically.
6670
- `--git-config`: sets git configurations.
71+
- `--open-gh-issue`: create a GitHub issue with a checklist and compare link (requires `gh`).
72+
- `--use-gh-models[=<model>]`: add an AI overview **comment** to that issue using `gh models`
73+
(requires the `gh-models` extension). If used without a value, default
6774

6875
### Step 5: Cleanup
6976
- Once the output branch is ready, all the temporary working branches are deleted.
@@ -143,7 +150,32 @@ make manifests generate fmt vet lint-fix
143150
make all
144151
```
145152

146-
### Changing Extra Git configs only during the run (does not change your ~/.gitconfig)_
153+
## Using with GitHub Issues (`--open-gh-issue`) and AI (`--use-gh-models`) assistance
154+
155+
If you pass `--open-gh-issue`, the command creates an issue in your repository with a pre-filled checklist and a compare link so you can open a PR and review the update.
156+
157+
If you also pass `--use-gh-models[=<model>]`, the tool posts a follow-up comment on that issue with an AI-generated overview of the most important changes and brief conflict-resolution guidance. When the flag is provided without a value, the default model is `openai/gpt-4o`. The AI comment uses simple, Kubebuilder-style wording and, when relevant, adds a short **Conflicts** section with commands to regenerate files. *(If the `gh models` command isn’t available, the issue is still created; only the AI comment is skipped.)*
158+
159+
This integrates cleanly with automation. The [`autoupdate.kubebuilder.io/v1-alpha`][autoupdate-plugin] plugin can scaffold a GitHub Actions workflow that runs the command on a schedule (e.g., weekly). When a new Kubebuilder release is available, it opens an issue with a compare link so you can create the PR and review it, for example:
160+
161+
<img width="638" height="482" alt="Example Issue" src="https://github.com/user-attachments/assets/589fd16b-7709-4cd5-b169-fd53d69790d4" />
162+
163+
With `--use-gh-models`, an AI comment helps you understand key changes and how to resolve conflicts (e.g., which files to regenerate and which commands to run), for example:
164+
165+
<img width="447" height="716" alt="Example AI summary" src="https://github.com/user-attachments/assets/fc553ee1-5149-48cb-9f76-2c1cd2587f6b" />
166+
167+
```
168+
# Create an issue after the update
169+
kubebuilder alpha update --open-gh-issue
170+
171+
# Create an issue and add an AI overview comment (default model)
172+
kubebuilder alpha update --open-gh-issue --use-gh-models
173+
174+
# Create an issue and add an AI overview comment with a specific model
175+
kubebuilder alpha update --open-gh-issue --use-gh-models openai/gpt-4o-mini
176+
```
177+
178+
## Changing Extra Git configs only during the run (does not change your ~/.gitconfig)_
147179

148180
By default, `kubebuilder alpha update` applies safe Git configs:
149181
`merge.renameLimit=999999`, `diff.renameLimit=999999`.
@@ -171,18 +203,20 @@ kubebuilder alpha update \
171203

172204
## Flags
173205

174-
| Flag | Description |
175-
|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
176-
| `--from-version` | Kubebuilder release to update **from** (e.g., `v4.6.0`). If unset, read from the `PROJECT` file when possible. |
177-
| `--to-version` | Kubebuilder release to update **to** (e.g., `v4.7.0`). If unset, defaults to the latest available release. |
178-
| `--from-branch` | Git branch that holds your current project code. Defaults to `main`. |
179-
| `--force` | Continue even if merge conflicts happen. Conflicted files are committed with conflict markers (CI/cron friendly). |
180-
| `--show-commits` | Keep full history (do not squash). **Not compatible** with `--preserve-path`. |
181-
| `--restore-path` | Repeatable. Paths to preserve from the base branch (repeatable). Not supported with --show-commits. (e.g., `.github/workflows`). |
182-
| `--output-branch` | Name of the output branch. Default: `kubebuilder-update-from-<from-version>-to-<to-version>`. |
183-
| `--push` | Push the output branch to the `origin` remote after the update completes. |
184-
| `--git-config` | Repeatable. Pass per-invocation Git config as `-c key=value`. **Default** (if omitted): `-c merge.renameLimit=999999 -c diff.renameLimit=999999`. Your configs are applied on top. To disable defaults, include `--git-config disable` |
185-
| `-h, --help` | Show help for this command. |
206+
| Flag | Description |
207+
|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
208+
| `--force` | Continue even if merge conflicts happen. Conflicted files are committed with conflict markers (CI/cron friendly). |
209+
| `--from-branch` | Git branch that holds your current project code. Defaults to `main`. |
210+
| `--from-version` | Kubebuilder release to update **from** (e.g., `v4.6.0`). If unset, read from the `PROJECT` file when possible. |
211+
| `--git-config` | Repeatable. Pass per-invocation Git config as `-c key=value`. **Default** (if omitted): `-c merge.renameLimit=999999 -c diff.renameLimit=999999`. Your configs are applied on top. To disable defaults, include `--git-config disable`. |
212+
| `--open-gh-issue` | Create a GitHub issue with a pre-filled checklist and compare link after the update completes (requires `gh`). |
213+
| `--output-branch` | Name of the output branch. Default: `kubebuilder-update-from-<from-version>-to-<to-version>`. |
214+
| `--push` | Push the output branch to the `origin` remote after the update completes. |
215+
| `--restore-path` | Repeatable. Paths to preserve from the base branch when squashing (e.g., `.github/workflows`). **Not supported** with `--show-commits`. |
216+
| `--show-commits` | Keep full history (do not squash). **Not compatible** with `--restore-path`. |
217+
| `--to-version` | Kubebuilder release to update **to** (e.g., `v4.7.0`). If unset, defaults to the latest available release. |
218+
| `--use-gh-models` | Post an AI overview as an issue comment using `gh models`. Provide a model name; if the flag is used without a value it defaults to `openai/gpt-4o`. Requires `gh` + `gh-models` extension. Effective only when `--open-gh-issue` is also set. |
219+
| `-h, --help` | Show help for this command. |
186220

187221
<aside class="note warning">
188222
<h1>You might need to upgrade your project first</h1>

0 commit comments

Comments
 (0)