Unverified Commit ccbd0cb5 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

Default agentic upgrades to a separate worktree (#99111)

### Why?

The agent nudge offers a background upgrade without specifying a
separate checkout, so upgrade edits can land alongside the current
task’s changes.

### How?

Make both the nudge and upgrade handoff instruct the agent to use a
separate Git worktree unless the user explicitly requests otherwise. The
handoff directs upgrade commands to the app’s corresponding directory in
that worktree. Update the existing prompt assertions and snapshots to
match.

<!-- NEXT_JS_LLM -->
parent ae91b476
...@@ -380,6 +380,8 @@ Complete each adoption. Temporary opt-outs and TODO markers are intermediate wor ...@@ -380,6 +380,8 @@ Complete each adoption. Temporary opt-outs and TODO markers are intermediate wor
${taskSummary} ${taskSummary}
Unless the user explicitly requests otherwise, perform the upgrade in a separate Git worktree. Run upgrade commands from this app's corresponding directory in that worktree.
Set \`experimental.agenticAutoUpgrade\` to ${JSON.stringify(upgradeType)} in the app's Next.js config as part of this upgrade. Preserve unrelated configuration. If the target Next.js version does not support this option, skip the setting and report why. Set \`experimental.agenticAutoUpgrade\` to ${JSON.stringify(upgradeType)} in the app's Next.js config as part of this upgrade. Preserve unrelated configuration. If the target Next.js version does not support this option, skip the setting and report why.
${futureDefaultsPrompt ? `${futureDefaultsPrompt.trimStart()}\n\n` : ''}References: ${futureDefaultsPrompt ? `${futureDefaultsPrompt.trimStart()}\n\n` : ''}References:
......
...@@ -282,7 +282,7 @@ This command stopped so the reminder you configured is not missed. Retry the sam ...@@ -282,7 +282,7 @@ This command stopped so the reminder you configured is not missed. Retry the sam
${ ${
command command
? `At the end of the task, ask the user whether they want you to run the upgrade using the configured '${reminder.policy}' policy in the background from this app's directory: ? `At the end of the task, ask the user whether they want you to run the upgrade using the configured '${reminder.policy}' policy in the background in a separate Git worktree unless they request otherwise. Run this command from this app's directory:
\`\`\` \`\`\`
${command} ${command}
......
...@@ -453,6 +453,8 @@ describe('agentic upgrade prompts', () => { ...@@ -453,6 +453,8 @@ describe('agentic upgrade prompts', () => {
We're upgrading the app in "/workspace/app" from Next.js 14.1.1 to 16.3.5 because the installed version is affected by a published security advisory. We're upgrading the app in "/workspace/app" from Next.js 14.1.1 to 16.3.5 because the installed version is affected by a published security advisory.
Unless the user explicitly requests otherwise, perform the upgrade in a separate Git worktree. Run upgrade commands from this app's corresponding directory in that worktree.
Set \`experimental.agenticAutoUpgrade\` to "security" in the app's Next.js config as part of this upgrade. Preserve unrelated configuration. If the target Next.js version does not support this option, skip the setting and report why. Set \`experimental.agenticAutoUpgrade\` to "security" in the app's Next.js config as part of this upgrade. Preserve unrelated configuration. If the target Next.js version does not support this option, skip the setting and report why.
References: References:
...@@ -538,6 +540,8 @@ describe('agentic upgrade prompts', () => { ...@@ -538,6 +540,8 @@ describe('agentic upgrade prompts', () => {
We're upgrading the app in "/workspace/app" from Next.js 16.2.12 to 16.3.5 because a newer stable Next.js release is available. We're upgrading the app in "/workspace/app" from Next.js 16.2.12 to 16.3.5 because a newer stable Next.js release is available.
Unless the user explicitly requests otherwise, perform the upgrade in a separate Git worktree. Run upgrade commands from this app's corresponding directory in that worktree.
Set \`experimental.agenticAutoUpgrade\` to "latest" in the app's Next.js config as part of this upgrade. Preserve unrelated configuration. If the target Next.js version does not support this option, skip the setting and report why. Set \`experimental.agenticAutoUpgrade\` to "latest" in the app's Next.js config as part of this upgrade. Preserve unrelated configuration. If the target Next.js version does not support this option, skip the setting and report why.
References: References:
...@@ -645,6 +649,8 @@ describe('agentic upgrade prompts', () => { ...@@ -645,6 +649,8 @@ describe('agentic upgrade prompts', () => {
We're upgrading the app in "/workspace/app" from Next.js 16.2.0 to 16.4.0 because the Future policy applies the latest stable release and adopts its Future Defaults. We're upgrading the app in "/workspace/app" from Next.js 16.2.0 to 16.4.0 because the Future policy applies the latest stable release and adopts its Future Defaults.
Unless the user explicitly requests otherwise, perform the upgrade in a separate Git worktree. Run upgrade commands from this app's corresponding directory in that worktree.
Set \`experimental.agenticAutoUpgrade\` to "future" in the app's Next.js config as part of this upgrade. Preserve unrelated configuration. If the target Next.js version does not support this option, skip the setting and report why. Set \`experimental.agenticAutoUpgrade\` to "future" in the app's Next.js config as part of this upgrade. Preserve unrelated configuration. If the target Next.js version does not support this option, skip the setting and report why.
After completing and verifying the version migration, adopt these Future Defaults in order: After completing and verifying the version migration, adopt these Future Defaults in order:
...@@ -741,6 +747,8 @@ describe('agentic upgrade prompts', () => { ...@@ -741,6 +747,8 @@ describe('agentic upgrade prompts', () => {
We're adopting the Future Defaults available to the app in "/workspace/app", which already uses Next.js 16.4.0. We're adopting the Future Defaults available to the app in "/workspace/app", which already uses Next.js 16.4.0.
Unless the user explicitly requests otherwise, perform the upgrade in a separate Git worktree. Run upgrade commands from this app's corresponding directory in that worktree.
Set \`experimental.agenticAutoUpgrade\` to "future" in the app's Next.js config as part of this upgrade. Preserve unrelated configuration. If the target Next.js version does not support this option, skip the setting and report why. Set \`experimental.agenticAutoUpgrade\` to "future" in the app's Next.js config as part of this upgrade. Preserve unrelated configuration. If the target Next.js version does not support this option, skip the setting and report why.
Adopt these Future Defaults in order: Adopt these Future Defaults in order:
......
...@@ -159,7 +159,7 @@ describe('security upgrade nudge', () => { ...@@ -159,7 +159,7 @@ describe('security upgrade nudge', () => {
name: 'SecurityFatalError', name: 'SecurityFatalError',
exitCode: 1, exitCode: 1,
message: expect.stringMatching( message: expect.stringMatching(
/affected by a published security advisory[\s\S]*\*\*We strongly recommend you upgrade Next\.js\.\*\*[\s\S]*reminder you configured is not missed\. Retry the same command to continue the original task\.[\s\S]*At the end of the task, ask the user whether they want you to run the upgrade using the configured 'security' policy in the background from this app's directory:[\s\S]*```\nnext upgrade --ai=(?:security|latest|future)\n```/ /affected by a published security advisory[\s\S]*\*\*We strongly recommend you upgrade Next\.js\.\*\*[\s\S]*reminder you configured is not missed\. Retry the same command to continue the original task\.[\s\S]*At the end of the task, ask the user whether they want you to run the upgrade using the configured 'security' policy in the background in a separate Git worktree unless they request otherwise\. Run this command from this app's directory:[\s\S]*```\nnext upgrade --ai=(?:security|latest|future)\n```/
), ),
}) })
expect(warn).not.toHaveBeenCalled() expect(warn).not.toHaveBeenCalled()
...@@ -397,7 +397,7 @@ describe('latest upgrade nudge', () => { ...@@ -397,7 +397,7 @@ describe('latest upgrade nudge', () => {
name: 'UpgradeNudgeError', name: 'UpgradeNudgeError',
exitCode: 1, exitCode: 1,
message: expect.stringMatching( message: expect.stringMatching(
/Next\.js 17\.0\.0 is available\.[\s\S]*\*\*We recommend you upgrade Next\.js\.\*\*[\s\S]*reminder you configured is not missed\. Retry the same command to continue the original task\.[\s\S]*At the end of the task, ask the user whether they want you to run the upgrade using the configured 'latest' policy in the background from this app's directory:[\s\S]*```\nnext upgrade --ai=(?:security|latest|future)\n```[\s\S]*registry\.npmjs\.org[\s\S]*agenticAutoUpgrade: 'latest'/ /Next\.js 17\.0\.0 is available\.[\s\S]*\*\*We recommend you upgrade Next\.js\.\*\*[\s\S]*reminder you configured is not missed\. Retry the same command to continue the original task\.[\s\S]*At the end of the task, ask the user whether they want you to run the upgrade using the configured 'latest' policy in the background in a separate Git worktree unless they request otherwise\. Run this command from this app's directory:[\s\S]*```\nnext upgrade --ai=(?:security|latest|future)\n```[\s\S]*registry\.npmjs\.org[\s\S]*agenticAutoUpgrade: 'latest'/
), ),
}) })
await expect( await expect(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment