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

Remove `true` from `agentUpgrade` option (#99461)

Set `'security'` to be the default.
parent a1de339f
......@@ -1165,7 +1165,6 @@ export default async function build(
// Reuse the loaded config; ordinary builds do not load upgrade tooling.
if (
config.experimental.agentUpgrade === true ||
config.experimental.agentUpgrade === 'security' ||
config.experimental.agentUpgrade === 'latest' ||
config.experimental.agentUpgrade === 'experimental-future' ||
......
......@@ -157,10 +157,7 @@ export function getUpgradeContext(config: NextConfigComplete): UpgradeContext {
cacheComponents: config.cacheComponents,
experimental: {
agentUpgrade:
getRequestedUpgrade() ??
(config.experimental.agentUpgrade === true
? 'security'
: (config.experimental.agentUpgrade ?? false)),
getRequestedUpgrade() ?? config.experimental.agentUpgrade ?? false,
},
}
}
......
......@@ -198,7 +198,10 @@ const zTurbopackConfig: zod.ZodType<TurbopackOptions> = z.strictObject({
export const experimentalSchema = {
agentUpgrade: z
.union([z.enum(['security', 'latest', 'experimental-future']), z.boolean()])
.union([
z.enum(['security', 'latest', 'experimental-future']),
z.literal(false),
])
.optional(),
agentFeedback: z.boolean().optional(),
turbopackAdditionalRoots: z
......
......@@ -499,8 +499,8 @@ export interface DeprecatedConfig {
}
export interface ExperimentalConfig {
/** Nudge coding agents about security upgrades, stable releases, or Future Defaults. `true` uses the security policy. */
agentUpgrade?: 'security' | 'latest' | 'experimental-future' | boolean
/** Nudge coding agents about security upgrades, stable releases, or Future Defaults. */
agentUpgrade?: 'security' | 'latest' | 'experimental-future' | false
/**
* Adds managed instructions to AGENTS.md that let AI coding agents prepare
* anonymized Next.js feedback for user review.
......@@ -2363,7 +2363,7 @@ export const defaultConfig = Object.freeze({
adapterPath: process.env.NEXT_ADAPTER_PATH || undefined,
deprecated: {} as DeprecatedConfig,
experimental: {
agentUpgrade: true,
agentUpgrade: 'security',
agentFeedback: false,
coldCacheBadge: false,
collapseAdapterRoutes: true,
......
......@@ -222,7 +222,6 @@ export async function initialize(opts: {
// Check only development; production startup does not query advisories.
if (
developmentConfig.experimental.agentUpgrade === true ||
developmentConfig.experimental.agentUpgrade === 'security' ||
developmentConfig.experimental.agentUpgrade === 'latest' ||
developmentConfig.experimental.agentUpgrade === 'experimental-future' ||
......
......@@ -17,6 +17,7 @@ import { getAgentName } from 'next/dist/telemetry/agent-name'
import { getUpgradeAssessment } from 'next/dist/lib/upgrade/prepare-upgrade'
import { warn } from 'next/dist/build/output/log'
import { spawnNextUpgrade } from 'next/dist/cli/next-upgrade'
import { defaultConfig } from 'next/dist/server/config-shared'
jest.mock('next/dist/cli/next-upgrade', () => ({
spawnNextUpgrade: jest.fn(),
......@@ -94,7 +95,7 @@ const initialNextVersion = process.env.__NEXT_VERSION
const initialRequestedUpgrade = process.env.__NEXT_AGENT_UPGRADE
const config = (
policy: 'security' | 'latest' | 'experimental-future' | boolean,
policy: 'security' | 'latest' | 'experimental-future' | false,
values: Record<string, unknown> = {}
) =>
({
......@@ -103,8 +104,9 @@ const config = (
experimental: { agentUpgrade: policy },
}) as never
it('uses the security policy when agentUpgrade is true', () => {
const context = getUpgradeContext(config(true))
it('defaults agentUpgrade to the security policy', () => {
expect(defaultConfig.experimental.agentUpgrade).toBe('security')
const context = getUpgradeContext(config('security'))
expect(context.experimental.agentUpgrade).toBe('security')
})
......
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