Unverified Commit 4e0e573a authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

Use Agent terminology throughout upgrades (#99545)

### Why?

Use consistent Agent terminology for the upgrade command and lifecycle
reporting.

### How?

Replace `--ai` and `--experimental-ai` with `--agent`, and update
upgrade recommendations, DevTools prompts, tests, and eval fixtures.
Rename the telemetry module, types and event names, hidden completion
reporter, run-ID environment variable, and preference namespace to
match. Telemetry events now use `NEXT_AGENT_UPGRADE_*`, and preferences
use `agent-upgrade.*`.

Formatting, TypeScript syntax, and telemetry producer smoke checks pass.
Full local build and unit tests remain blocked by missing workspace
dependencies.
parent 936fda6a
......@@ -39,7 +39,7 @@ fixtures fail before execution, and infrastructure failures are retained in the
Feature PRs add ordinary npm app fixtures with exact dependency versions,
`PROMPT.md`, and `EVAL.ts`. Explicit upgrade scenarios invoke
`npx next@canary upgrade --ai`. Reminder scenarios keep the original task prompt
`npx next@canary upgrade --agent`. Reminder scenarios keep the original task prompt
unchanged so the eval can attribute acknowledgment to the runtime notice. Feature
PRs own browser setup, repository remotes, advisory responses, codemod routing,
grading, and reference or negative controls. Keep graders and reference solutions
......
Run `next upgrade --ai experimental-future` for this app and complete the upgrade.
Run `next upgrade --agent experimental-future` for this app and complete the upgrade.
Run `next upgrade --ai experimental-future` for this app and complete the upgrade.
Run `next upgrade --agent experimental-future` for this app and complete the upgrade.
Run `npx next@canary upgrade --ai latest` for this app.
Run `npx next@canary upgrade --agent latest` for this app.
Run `npx next@canary upgrade --ai latest` for this app.
Run `npx next@canary upgrade --agent latest` for this app.
Run `npx next@canary upgrade --ai` for this app and follow the instructions.
Run `npx next@canary upgrade --agent` for this app and follow the instructions.
Run `npx next@canary upgrade --ai` for this app and follow the instructions.
Run `npx next@canary upgrade --agent` for this app and follow the instructions.
Run `npx next@canary upgrade --ai` for this app and follow the instructions.
Run `npx next@canary upgrade --agent` for this app and follow the instructions.
......@@ -153,7 +153,7 @@ export function duplicateSecurityChecks(source: string, target: string) {
test('recognizes the existing security upgrade', async () => {
expect(records('invocations.jsonl')).toContainEqual(
expect.objectContaining({
args: ['upgrade', '--ai'],
args: ['upgrade', '--agent'],
packageRunner: 'npx',
requestedPackage: 'next@canary',
})
......
......@@ -112,10 +112,7 @@ class NextRootCommand extends Command {
// The upgrade harness may run both dev and production checks. Preserve
// its caller's environment instead of forcing all child commands into
// production mode merely because they were launched through this CLI.
if (
commandName !== 'upgrade' ||
!event.getOptionValue('experimentalAi')
) {
if (commandName !== 'upgrade' || !event.getOptionValue('agent')) {
;(process.env as any).NODE_ENV = process.env.NODE_ENV || defaultEnv
;(process.env as any).NEXT_RUNTIME = 'nodejs'
}
......@@ -586,8 +583,8 @@ program
.option('--verbose', 'Verbose output', false)
.addOption(
new Option(
'--ai, --experimental-ai [type]',
'Upgrade with AI to security, latest, or experimental-future. Defaults to security.'
'--agent [type]',
'Upgrade with an agent to security, latest, or experimental-future. Defaults to security.'
).conflicts('revision')
)
// Keep nudge attribution available to agents without exposing it in public help.
......@@ -596,10 +593,7 @@ program
const mod = await import('../cli/next-upgrade.js')
await mod.spawnNextUpgrade(
directory,
{
...options,
ai: options.experimentalAi,
},
options,
options.internalNudgeId !== undefined
? { id: options.internalNudgeId, recipient: 'agent' }
: null
......@@ -676,12 +670,12 @@ const internal = program
// Agents use the pinned CLI to report completion after the upgrade has changed dependencies.
internal
.command('report-ai-upgrade', { hidden: true })
.command('report-agent-upgrade', { hidden: true })
.argument('<run-id>', 'The upgrade run UUID.')
.argument('<result>', 'The agent-reported success or failure result.')
.action((runId: string, result: string) =>
import('../cli/next-upgrade.js').then((mod) =>
mod.reportAIUpgradeAgentResult(runId, result)
mod.reportAgentUpgradeAgentResult(runId, result)
)
)
......
......@@ -15,13 +15,13 @@ import type { UpgradeDocument } from '../lib/upgrade/future-defaults'
import { runChildProcess } from '../lib/upgrade/run-child-process'
import { getAgentName } from '../telemetry/agent-name'
import {
eventAIUpgradeAgentResult,
eventAIUpgradeCLIResult,
eventAIUpgradeRunStarted,
type AIUpgradeCLIResult,
type AIUpgradeHandoffMethod,
type AIUpgradePolicy,
} from '../telemetry/events/ai-upgrade'
eventAgentUpgradeAgentResult,
eventAgentUpgradeCLIResult,
eventAgentUpgradeRunStarted,
type AgentUpgradeCLIResult,
type AgentUpgradeHandoffMethod,
type AgentUpgradePolicy,
} from '../telemetry/events/agent-upgrade'
import { Telemetry } from '../telemetry/storage'
import loadConfig from '../server/config'
import { normalizeConfig } from '../server/config-shared'
......@@ -30,7 +30,7 @@ import { PHASE_PRODUCTION_BUILD } from '../shared/lib/constants'
type NextUpgradeOptions = {
revision: string
verbose: boolean
ai: boolean | string | undefined
agent: boolean | string | undefined
}
const UUID_PATTERN =
......@@ -134,7 +134,7 @@ async function prepareUpgradeSkill(
}
}
async function loadAIUpgradeConfig(directory: string) {
async function loadAgentUpgradeConfig(directory: string) {
// Read and normalize the app's config without validating legacy options
// against the current Next.js schema.
const rawConfig = await loadConfig(PHASE_PRODUCTION_BUILD, directory, {
......@@ -175,7 +175,7 @@ export async function spawnNextUpgrade(
) {
let baseDir = resolvePath(directory || '.')
if (options.ai) {
if (options.agent) {
// Match dev/build's telemetry storage, including custom output directories in CI.
// Retain config errors until after recording the invocation so failed runs still count.
let distDir = '.next'
......@@ -183,14 +183,14 @@ export async function spawnNextUpgrade(
let configError: unknown = null
try {
baseDir = getProjectDir(directory, false)
const config = await loadAIUpgradeConfig(baseDir)
const config = await loadAgentUpgradeConfig(baseDir)
distDir = config.distDir || '.next'
configuredPolicy = config.experimental?.agentUpgrade
} catch (error) {
configError = error
}
// Count AI invocations even when resolving the directory or config fails.
// Count agent invocations even when resolving the directory or config fails.
const telemetry = new Telemetry({
distDir: join(baseDir, distDir),
skipNotify: true,
......@@ -198,8 +198,8 @@ export async function spawnNextUpgrade(
// The parent records attribution; canary only needs its run ID to report results.
// Remove it before launching an agent so later upgrades start their own runs.
const inheritedRunId = process.env.__NEXT_AI_UPGRADE_RUN_ID
delete process.env.__NEXT_AI_UPGRADE_RUN_ID
const inheritedRunId = process.env.__NEXT_AGENT_UPGRADE_RUN_ID
delete process.env.__NEXT_AGENT_UPGRADE_RUN_ID
const invalidRunId =
inheritedRunId !== undefined && !UUID_PATTERN.test(inheritedRunId)
const invalidNudgeId =
......@@ -208,14 +208,14 @@ export async function spawnNextUpgrade(
const runId =
inheritedRunId && !invalidRunId ? inheritedRunId : randomUUID()
let resolvedPolicy: AIUpgradePolicy | null = null
let resolvedPolicy: AgentUpgradePolicy | null = null
let failureStage: 'cli' | 'metadata' | 'guide' | 'handoff' = 'cli'
let cliResultRecorded = false
// Preparation and handoff can both fail; record only the first terminal result.
const recordCLIResult = (
result: AIUpgradeCLIResult,
handoffMethod: AIUpgradeHandoffMethod | null,
result: AgentUpgradeCLIResult,
handoffMethod: AgentUpgradeHandoffMethod | null,
selectedAgentProduct: string | null
) => {
if (cliResultRecorded) {
......@@ -223,7 +223,7 @@ export async function spawnNextUpgrade(
}
cliResultRecorded = true
telemetry.record(
eventAIUpgradeCLIResult({
eventAgentUpgradeCLIResult({
runId,
result,
resolvedPolicy,
......@@ -247,16 +247,16 @@ export async function spawnNextUpgrade(
? 'agent_manual'
: 'human_manual'
telemetry.record(
eventAIUpgradeRunStarted({
eventAgentUpgradeRunStarted({
runId,
nudgeId: nudge?.id ?? null,
origin,
agentProduct,
requestedPolicy:
options.ai === 'security' ||
options.ai === 'latest' ||
options.ai === 'experimental-future'
? options.ai
options.agent === 'security' ||
options.agent === 'latest' ||
options.agent === 'experimental-future'
? options.agent
: null,
})
)
......@@ -290,14 +290,16 @@ export async function spawnNextUpgrade(
failureStage = 'cli'
if (process.env.__NEXT_VERSION !== canaryVersion) {
const [command, ...runnerArgs] = getNpxCommand(baseDir).split(' ')
const aiArgument =
typeof options.ai === 'string' ? `--ai=${options.ai}` : '--ai'
const agentArgument =
typeof options.agent === 'string'
? `--agent=${options.agent}`
: '--agent'
const args = [
...runnerArgs,
`next@${canaryVersion}`,
'upgrade',
baseDir,
aiArgument,
agentArgument,
]
if (options.verbose) {
......@@ -313,7 +315,7 @@ export async function spawnNextUpgrade(
env: {
...process.env,
// The delegated CLI emits the CLI result for this invocation's run ID.
__NEXT_AI_UPGRADE_RUN_ID: runId,
__NEXT_AGENT_UPGRADE_RUN_ID: runId,
__NEXT_UPGRADE_EXPECTED_CLI_VERSION: canaryVersion,
// Older canaries recognize only this recursion guard.
__NEXT_UPGRADE_USE_CURRENT_CLI: '1',
......@@ -329,13 +331,13 @@ export async function spawnNextUpgrade(
if (!findDir(baseDir, 'app') && !findDir(baseDir, 'pages')) {
throw new Error(
'No Next.js app found in this directory. Run the command from an app directory or pass its path:\n\n' +
`next upgrade [directory] --ai${typeof options.ai === 'string' ? `=${options.ai}` : ''}`
`next upgrade [directory] --agent${typeof options.agent === 'string' ? `=${options.agent}` : ''}`
)
}
const upgradeType =
typeof options.ai === 'string'
? options.ai
typeof options.agent === 'string'
? options.agent
: configuredPolicy === 'security' ||
configuredPolicy === 'latest' ||
configuredPolicy === 'experimental-future'
......@@ -348,7 +350,7 @@ export async function spawnNextUpgrade(
upgradeType !== 'experimental-future'
) {
throw new Error(
`Unsupported AI upgrade type ${JSON.stringify(upgradeType)}. Expected "security", "latest", or "experimental-future".`
`Unsupported agent upgrade type ${JSON.stringify(upgradeType)}. Expected "security", "latest", or "experimental-future".`
)
}
resolvedPolicy = upgradeType
......@@ -576,7 +578,7 @@ export async function spawnNextUpgrade(
: `We're adopting the Future Defaults available to the app in ${JSON.stringify(baseDir)}, which already uses Next.js ${result.installedVersion}.`
// Use the invoking CLI's reporter even after the app's Next.js package changes.
const reportCommand = `${getNpxCommand(baseDir)} next@${process.env.__NEXT_VERSION} internal report-ai-upgrade ${runId}`
const reportCommand = `${getNpxCommand(baseDir)} next@${process.env.__NEXT_VERSION} internal report-agent-upgrade ${runId}`
const prompt = (
useWorktree: boolean | null
) => `Read and follow ${JSON.stringify(sharedGuidePath)} first. Attempt its applicable duplicate checks before changing files. If a check is unavailable, report it and continue. Stop only if you find equivalent work. Then read and follow every applicable instruction in ${JSON.stringify(guidePath)}.
......@@ -670,7 +672,7 @@ When this task ends, report its result once. After completing the requested upgr
})
}
export async function reportAIUpgradeAgentResult(
export async function reportAgentUpgradeAgentResult(
runId: string,
result: string
) {
......@@ -685,11 +687,11 @@ export async function reportAIUpgradeAgentResult(
}
// Reuse normal telemetry consent and delivery without starting another upgrade.
const config = await loadAIUpgradeConfig(process.cwd())
const config = await loadAgentUpgradeConfig(process.cwd())
const telemetry = new Telemetry({
distDir: join(process.cwd(), config.distDir || '.next'),
skipNotify: true,
})
await telemetry.record(eventAIUpgradeAgentResult({ runId, result }))
await telemetry.record(eventAgentUpgradeAgentResult({ runId, result }))
await telemetry.flush()
}
......@@ -8,7 +8,7 @@ import spawn from 'next/dist/compiled/cross-spawn'
import * as Log from '../../build/output/log'
import { getAgentName } from '../../telemetry/agent-name'
import type { AIUpgradeHandoffMethod } from '../../telemetry/events/ai-upgrade'
import type { AgentUpgradeHandoffMethod } from '../../telemetry/events/agent-upgrade'
import { bold, cyan, dim } from '../picocolors'
import { runChildProcess } from './run-child-process'
......@@ -273,7 +273,7 @@ async function chooseHarness(
function copyUpgradePrompt(
prompt: string,
noHarness: boolean
): AIUpgradeHandoffMethod {
): AgentUpgradeHandoffMethod {
const commands =
process.platform === 'darwin'
? [['pbcopy']]
......@@ -353,7 +353,7 @@ export async function handoffUpgrade(
directory: string,
onHandoff:
| ((
method: AIUpgradeHandoffMethod,
method: AgentUpgradeHandoffMethod,
selectedAgentProduct: string | null
) => void)
| null
......
......@@ -9,10 +9,10 @@ import * as Log from '../../build/output/log'
import type { NextConfigComplete } from '../../server/config-shared'
import type { Telemetry } from '../../telemetry/storage'
import {
eventAIUpgradeNudgeDecision,
eventAIUpgradeNudgeShown,
eventAIUpgradePolicyDetected,
} from '../../telemetry/events/ai-upgrade'
eventAgentUpgradeNudgeDecision,
eventAgentUpgradeNudgeShown,
eventAgentUpgradePolicyDetected,
} from '../../telemetry/events/agent-upgrade'
import semver from 'next/dist/compiled/semver'
import type { UpgradeAction } from './prompt'
import { getAgentName } from '../../telemetry/agent-name'
......@@ -283,7 +283,7 @@ async function nudgeUpgradeForAgent(
nudgeId: string,
agentProduct: string,
telemetry: Telemetry | null,
policyEvent: ReturnType<typeof eventAIUpgradePolicyDetected>
policyEvent: ReturnType<typeof eventAgentUpgradePolicyDetected>
): Promise<void> {
let summary: string
let recommendation: string
......@@ -306,7 +306,7 @@ async function nudgeUpgradeForAgent(
break
}
// Pass attribution on the invocation using the same command syntax on every platform.
const command = `next upgrade --ai=${reminder.policy} --internal-nudge-id=${nudgeId}`
const command = `next upgrade --agent=${reminder.policy} --internal-nudge-id=${nudgeId}`
const message = `${summary}
**${recommendation}**
......@@ -351,7 +351,7 @@ ${reference ? `Reference: ${reference}` : ''}`
distDir: resolve(options.directory, options.distDir),
events: [
policyEvent,
eventAIUpgradeNudgeShown({
eventAgentUpgradeNudgeShown({
nudgeId,
recipient: 'agent',
agentProduct,
......@@ -402,7 +402,7 @@ async function getUpgradePreferences(directory: string) {
const hash = createHash('sha256').update(identity).digest('hex')
// Conf treats dots as separators, including dots in directory names.
const name = encodeURIComponent(projectName).replace(/\./g, '%2E')
const key = `ai-upgrade.${name}.${hash}`
const key = `agent-upgrade.${name}.${hash}`
// Upgrade preferences share Next.js' global config location, not telemetry consent.
return { key, preferences: new Conf({ projectName: 'nextjs' }) }
}
......@@ -503,7 +503,7 @@ export async function runUpgrade(
// Human Update actions invoke the CLI directly, so their ID does not need an env var.
await spawnNextUpgrade(
directory,
{ revision: 'latest', verbose: false, ai: policy },
{ revision: 'latest', verbose: false, agent: policy },
nudgeId ? { id: nudgeId, recipient: 'human' } : null
)
return process.exitCode ?? 0
......@@ -535,7 +535,7 @@ export async function nudgeUpgrade(
}
// Observe the effective policy even when assessment finds no upgrade to offer.
const telemetry = telemetryOptions?.telemetry ?? null
const policyEvent = eventAIUpgradePolicyDetected({
const policyEvent = eventAgentUpgradePolicyDetected({
configuredPolicy: config.configuredPolicy ?? null,
effectivePolicy: policy,
policySource: requested ? 'environment' : 'config',
......@@ -613,7 +613,7 @@ export async function nudgeUpgrade(
shown = true
telemetryOptions.onNudgeId?.(nudgeId)
telemetryOptions.telemetry.record(
eventAIUpgradeNudgeShown({
eventAgentUpgradeNudgeShown({
nudgeId,
recipient: 'human',
agentProduct: null,
......@@ -634,7 +634,7 @@ export async function nudgeUpgrade(
if (shown && telemetry) {
if (!signal.aborted) {
telemetry.record(eventAIUpgradeNudgeDecision({ nudgeId, action }))
telemetry.record(eventAgentUpgradeNudgeDecision({ nudgeId, action }))
}
await telemetry.flush()
}
......
......@@ -30,7 +30,7 @@ export async function prepareUpgrade(
targetRequest !== 'experimental-future'
) {
throw new Error(
`Unsupported AI upgrade type ${JSON.stringify(targetRequest)}. Expected "security", "latest", or "experimental-future".`
`Unsupported agent upgrade type ${JSON.stringify(targetRequest)}. Expected "security", "latest", or "experimental-future".`
)
}
......@@ -98,7 +98,7 @@ export async function getUpgradeAssessment(
const channel = getPrereleaseChannel(installedVersion)
if (semver.prerelease(installedVersion) && !channel) {
throw new Error(
'AI upgrades are not available for this prerelease version of Next.js.'
'Agent upgrades are not available for this prerelease version of Next.js.'
)
}
if (channel && (policy === 'security' || onlyIfAffected)) {
......@@ -107,7 +107,7 @@ export async function getUpgradeAssessment(
reference: null,
upgrade: {
status: 'blocked',
reason: `The installed Next.js version (${installedVersion}) is a ${channel} prerelease. Security advisories target stable versions, and prereleases do not reliably follow stable version ordering, so an advisory could be a false positive. To upgrade to the latest ${channel === 'canary' ? 'canary' : 'stable'} release, run this command from the app's directory:\n\nnpx next@canary upgrade --ai=latest`,
reason: `The installed Next.js version (${installedVersion}) is a ${channel} prerelease. Security advisories target stable versions, and prereleases do not reliably follow stable version ordering, so an advisory could be a false positive. To upgrade to the latest ${channel === 'canary' ? 'canary' : 'stable'} release, run this command from the app's directory:\n\nnpx next@canary upgrade --agent=latest`,
},
}
}
......@@ -117,7 +117,7 @@ export async function getUpgradeAssessment(
reference: null,
upgrade: {
status: 'blocked',
reason: `Future Defaults upgrades are not supported for Next.js ${installedVersion}. To upgrade to the latest stable release, run this command from the app's directory:\n\nnpx next@canary upgrade --ai=latest`,
reason: `Future Defaults upgrades are not supported for Next.js ${installedVersion}. To upgrade to the latest stable release, run this command from the app's directory:\n\nnpx next@canary upgrade --agent=latest`,
},
}
}
......
......@@ -33,7 +33,8 @@ export function VulnerabilityInsight({
onNext: (() => void) | undefined
onClose: (() => void) | undefined
}) {
const prompt = 'Run `next upgrade --ai=security` and follow its instructions.'
const prompt =
'Run `next upgrade --agent=security` and follow its instructions.'
const animationProps = {
'data-rendered': rendered,
style: {
......
// Shared values keep event payloads consistent across the CLI, nudges, and handoffs.
export type AIUpgradePolicy = 'security' | 'latest' | 'experimental-future'
export type AgentUpgradePolicy = 'security' | 'latest' | 'experimental-future'
export type AIUpgradeOrigin =
export type AgentUpgradeOrigin =
| 'human_manual'
| 'human_nudge'
| 'agent_manual'
| 'agent_nudge'
export type AIUpgradeHandoffMethod =
export type AgentUpgradeHandoffMethod =
| 'existing_agent'
| 'launched_agent'
| 'copied_prompt'
| 'printed_prompt'
export type AIUpgradeCLIResult =
export type AgentUpgradeCLIResult =
| 'no_update_needed'
| 'no_safe_target'
| 'metadata_failure'
......@@ -29,61 +29,61 @@ function event<T extends object>(eventName: string, fields: T) {
}
// Measure configured reach separately from whether an upgrade reminder is needed.
export function eventAIUpgradePolicyDetected(fields: {
configuredPolicy: AIUpgradePolicy | false | null
effectivePolicy: AIUpgradePolicy
export function eventAgentUpgradePolicyDetected(fields: {
configuredPolicy: AgentUpgradePolicy | false | null
effectivePolicy: AgentUpgradePolicy
policySource: 'config' | 'environment'
sourceCommand: 'dev' | 'build'
}) {
return event('NEXT_AI_UPGRADE_POLICY_DETECTED', fields)
return event('NEXT_AGENT_UPGRADE_POLICY_DETECTED', fields)
}
// Correlate a displayed reminder with a later upgrade invocation.
export function eventAIUpgradeNudgeShown(fields: {
export function eventAgentUpgradeNudgeShown(fields: {
nudgeId: string
recipient: 'human' | 'agent'
agentProduct: string | null
sourceCommand: 'dev' | 'build'
policy: AIUpgradePolicy
nudgeKind: AIUpgradePolicy
policy: AgentUpgradePolicy
nudgeKind: AgentUpgradePolicy
}) {
return event('NEXT_AI_UPGRADE_NUDGE_SHOWN', fields)
return event('NEXT_AGENT_UPGRADE_NUDGE_SHOWN', fields)
}
// Human menus expose a decision directly; agent decisions are inferred from runs.
export function eventAIUpgradeNudgeDecision(fields: {
export function eventAgentUpgradeNudgeDecision(fields: {
nudgeId: string
action: 'update' | 'skip' | 'dismiss' | 'interrupt'
}) {
return event('NEXT_AI_UPGRADE_NUDGE_DECISION', fields)
return event('NEXT_AGENT_UPGRADE_NUDGE_DECISION', fields)
}
// Count invocations independently of whether preparation or handoff finishes.
export function eventAIUpgradeRunStarted(fields: {
export function eventAgentUpgradeRunStarted(fields: {
runId: string
nudgeId: string | null
origin: AIUpgradeOrigin
origin: AgentUpgradeOrigin
agentProduct: string | null
requestedPolicy: AIUpgradePolicy | null
requestedPolicy: AgentUpgradePolicy | null
}) {
return event('NEXT_AI_UPGRADE_RUN_STARTED', fields)
return event('NEXT_AGENT_UPGRADE_RUN_STARTED', fields)
}
// Report the CLI's preparation and prompt delivery, not completion of the agent's work.
export function eventAIUpgradeCLIResult(fields: {
export function eventAgentUpgradeCLIResult(fields: {
runId: string
result: AIUpgradeCLIResult
resolvedPolicy: AIUpgradePolicy | null
handoffMethod: AIUpgradeHandoffMethod | null
result: AgentUpgradeCLIResult
resolvedPolicy: AgentUpgradePolicy | null
handoffMethod: AgentUpgradeHandoffMethod | null
selectedAgentProduct: string | null
}) {
return event('NEXT_AI_UPGRADE_CLI_RESULT', fields)
return event('NEXT_AGENT_UPGRADE_CLI_RESULT', fields)
}
// The agent reports its verified result separately from the CLI's prompt delivery.
export function eventAIUpgradeAgentResult(fields: {
export function eventAgentUpgradeAgentResult(fields: {
runId: string
result: 'success' | 'failure'
}) {
return event('NEXT_AI_UPGRADE_AGENT_RESULT', fields)
return event('NEXT_AGENT_UPGRADE_AGENT_RESULT', fields)
}
......@@ -45,7 +45,7 @@ describe('vulnerability insight', () => {
'[data-nextjs-vulnerability-prompt]'
)
expect(displayedPrompt).toBe(
'Run `next upgrade --ai=security` and follow its instructions.'
'Run `next upgrade --agent=security` and follow its instructions.'
)
await clickInPortal(browser, '[aria-label="Copy prompt"]')
......@@ -53,12 +53,12 @@ describe('vulnerability insight', () => {
await retry(async () => {
copiedPrompt = await browser.eval(() => navigator.clipboard.readText())
expect(copiedPrompt).toBe(
'Run `next upgrade --ai=security` and follow its instructions.'
'Run `next upgrade --agent=security` and follow its instructions.'
)
})
expect(copiedPrompt).toMatchInlineSnapshot(
`"Run \`next upgrade --ai=security\` and follow its instructions."`
`"Run \`next upgrade --agent=security\` and follow its instructions."`
)
})
})
This diff is collapsed.
......@@ -139,7 +139,7 @@ describe('prepare latest upgrade', () => {
upgrade: {
status: 'blocked',
reason:
"The installed Next.js version (17.2.0-canary.4) is a canary prerelease. Security advisories target stable versions, and prereleases do not reliably follow stable version ordering, so an advisory could be a false positive. To upgrade to the latest canary release, run this command from the app's directory:\n\nnpx next@canary upgrade --ai=latest",
"The installed Next.js version (17.2.0-canary.4) is a canary prerelease. Security advisories target stable versions, and prereleases do not reliably follow stable version ordering, so an advisory could be a false positive. To upgrade to the latest canary release, run this command from the app's directory:\n\nnpx next@canary upgrade --agent=latest",
},
})
await expect(prepareUpgrade(directory, 'security')).resolves.toMatchObject({
......@@ -453,7 +453,7 @@ describe('prepare latest upgrade', () => {
upgrade: expect.objectContaining({
status: 'blocked',
reason: expect.stringContaining(
'npx next@canary upgrade --ai=latest'
'npx next@canary upgrade --agent=latest'
),
}),
})
......@@ -483,7 +483,7 @@ describe('prepare latest upgrade', () => {
upgrade: expect.objectContaining({
status: 'blocked',
reason: expect.stringContaining(
'npx next@canary upgrade --ai=latest'
'npx next@canary upgrade --agent=latest'
),
}),
})
......@@ -497,10 +497,10 @@ describe('prepare latest upgrade', () => {
const directory = await createApp(version)
global.fetch = jest.fn()
await expect(prepareUpgrade(directory, 'latest')).rejects.toThrow(
'AI upgrades are not available for this prerelease version of Next.js.'
'Agent upgrades are not available for this prerelease version of Next.js.'
)
await expect(getUpgradeAssessment(version, 'latest')).rejects.toThrow(
'AI upgrades are not available for this prerelease version of Next.js.'
'Agent upgrades are not available for this prerelease version of Next.js.'
)
expect(global.fetch).toHaveBeenCalledTimes(0)
})
......
......@@ -169,7 +169,7 @@ describe('security upgrade nudge', () => {
name: 'SecurityFatalError',
exitCode: 1,
message: expect.stringMatching(
/affected by a known security vulnerability[\s\S]*\*\*We strongly recommend you upgrade Next\.js\.\*\*[\s\S]*upgrade recommendation\. Retry the same command to continue the original task\.[\s\S]*include this upgrade recommendation even if the retry succeeds\.[\s\S]*ask the user once:[\s\S]*in a separate Git worktree\?[\s\S]*Use their worktree choice and continue in this agent session[\s\S]*Run this command from this app's directory:[\s\S]*next upgrade --ai=(?:security|latest|experimental-future)/
/affected by a known security vulnerability[\s\S]*\*\*We strongly recommend you upgrade Next\.js\.\*\*[\s\S]*upgrade recommendation\. Retry the same command to continue the original task\.[\s\S]*include this upgrade recommendation even if the retry succeeds\.[\s\S]*ask the user once:[\s\S]*in a separate Git worktree\?[\s\S]*Use their worktree choice and continue in this agent session[\s\S]*Run this command from this app's directory:[\s\S]*next upgrade --agent=(?:security|latest|experimental-future)/
),
})
expect(warn).not.toHaveBeenCalled()
......@@ -529,7 +529,7 @@ describe('latest upgrade nudge', () => {
name: 'UpgradeNudgeError',
exitCode: 1,
message: expect.stringMatching(
/Next\.js 17\.0\.0 is available\.[\s\S]*\*\*We recommend you upgrade Next\.js\.\*\*[\s\S]*upgrade recommendation\. Retry the same command to continue the original task\.[\s\S]*include this upgrade recommendation even if the retry succeeds\.[\s\S]*ask the user once:[\s\S]*in a separate Git worktree\?[\s\S]*Use their worktree choice and continue in this agent session[\s\S]*Run this command from this app's directory:[\s\S]*next upgrade --ai=(?:security|latest|experimental-future)[\s\S]*registry\.npmjs\.org/
/Next\.js 17\.0\.0 is available\.[\s\S]*\*\*We recommend you upgrade Next\.js\.\*\*[\s\S]*upgrade recommendation\. Retry the same command to continue the original task\.[\s\S]*include this upgrade recommendation even if the retry succeeds\.[\s\S]*ask the user once:[\s\S]*in a separate Git worktree\?[\s\S]*Use their worktree choice and continue in this agent session[\s\S]*Run this command from this app's directory:[\s\S]*next upgrade --agent=(?:security|latest|experimental-future)[\s\S]*registry\.npmjs\.org/
),
})
await expect(
......@@ -631,7 +631,7 @@ describe('composed latest nudge', () => {
await expect(nudge).rejects.toMatchObject({
name: 'SecurityFatalError',
exitCode: 1,
message: expect.stringContaining(`next upgrade --ai=${policy}`),
message: expect.stringContaining(`next upgrade --agent=${policy}`),
})
await expect(nudge).rejects.toMatchObject({
message: expect.stringContaining(
......@@ -768,7 +768,7 @@ describe('composed future nudge', () => {
).rejects.toMatchObject({
name: 'UpgradeNudgeError',
message: expect.stringMatching(
/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|experimental-future)/
/Next\.js 17\.0\.0 is available[\s\S]*include this upgrade recommendation even if the retry succeeds\.[\s\S]*next upgrade --agent=(?:security|latest|experimental-future)/
),
})
})
......@@ -891,7 +891,7 @@ describe('human upgrade nudge', () => {
})
jest.mocked(getAgentName).mockResolvedValue('codex')
await expect(run(policy)).rejects.toMatchObject({
message: expect.stringContaining(`next upgrade --ai=${policy}`),
message: expect.stringContaining(`next upgrade --agent=${policy}`),
})
}
)
......@@ -983,7 +983,7 @@ describe('human upgrade nudge', () => {
{
revision: 'latest',
verbose: false,
ai: policy,
agent: policy,
},
null
)
......@@ -1044,7 +1044,7 @@ describe('human upgrade nudge', () => {
await expect(
nudgeUpgrade(directory, config(false), 'dev', null, null, null)
).rejects.toMatchObject({
message: expect.stringContaining('next upgrade --ai=latest'),
message: expect.stringContaining('next upgrade --agent=latest'),
})
})
......@@ -1154,7 +1154,7 @@ describe('human upgrade nudge', () => {
const preferences = new Conf({ projectName: 'nextjs' })
const name = appPath === '.' ? 'project%2Ename' : 'web'
const saved = preferences.get(`ai-upgrade.${name}`) as Record<
const saved = preferences.get(`agent-upgrade.${name}`) as Record<
string,
unknown
>
......
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