Unverified Commit 41efc183 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

[ai-upgrade] Remind the agent to report the nudge (#99127)

### Why?

Coding agents can retry startup successfully and omit the upgrade
reminder from their final response. That leaves users unaware of a
security, latest-version, or Future Defaults recommendation.

### How?

Tell agents to include the applicable upgrade recommendation when they
report back, even if the retry succeeds. Assert this wording for all
three reminder paths.

Local focused Jest verification could not initialize because this
worktree lacks the dependency setup required by the main checkout's
compiled Next.js output.

<!-- NEXT_JS_LLM -->
parent c9a2a711
...@@ -280,6 +280,8 @@ async function nudgeUpgradeForAgent( ...@@ -280,6 +280,8 @@ async function nudgeUpgradeForAgent(
This command stopped so the reminder you configured is not missed. Retry the same command to continue the original task. This command stopped so the reminder you configured is not missed. Retry the same command to continue the original task.
When you report back to the user, include this upgrade recommendation even if the retry succeeds.
${ ${
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 in a separate Git worktree unless they request otherwise. Run this command 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:
......
...@@ -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 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```/ /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]*include this upgrade recommendation even if the retry succeeds\.[\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 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'/ /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]*include this upgrade recommendation even if the retry succeeds\.[\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(
...@@ -567,8 +567,8 @@ describe('composed future nudge', () => { ...@@ -567,8 +567,8 @@ describe('composed future nudge', () => {
) )
).rejects.toMatchObject({ ).rejects.toMatchObject({
name: 'UpgradeNudgeError', name: 'UpgradeNudgeError',
message: expect.stringContaining( message: expect.stringMatching(
'We recommend you adopt these Future Defaults.' /We recommend you adopt these Future Defaults\.[\s\S]*include this upgrade recommendation even if the retry succeeds\./
), ),
}) })
expect(getUpgradeAssessment).toHaveBeenCalledTimes(1) expect(getUpgradeAssessment).toHaveBeenCalledTimes(1)
...@@ -624,7 +624,7 @@ describe('composed future nudge', () => { ...@@ -624,7 +624,7 @@ describe('composed future nudge', () => {
).rejects.toMatchObject({ ).rejects.toMatchObject({
name: 'UpgradeNudgeError', name: 'UpgradeNudgeError',
message: expect.stringMatching( message: expect.stringMatching(
/Next\.js 17\.0\.0 is available[\s\S]*next upgrade --ai=(?:security|latest|future)\n```[\s\S]*agenticAutoUpgrade: 'future'/ /Next\.js 17\.0\.0 is available[\s\S]*include this upgrade recommendation even if the retry succeeds\.[\s\S]*next upgrade --ai=(?:security|latest|future)\n```[\s\S]*agenticAutoUpgrade: 'future'/
), ),
}) })
}) })
......
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