MCPcopy
hub / github.com/vercel/next.js / promptForOptions

Function promptForOptions

packages/next-codemod/bin/agents-md.ts:134–207  ·  view source on GitHub ↗
(
  cwd: string
)

Source from the content-addressed store, hash-verified

132}
133
134async function promptForOptions(
135 cwd: string
136): Promise<{ nextVersion: string; targetFile: string }> {
137 // Detect Next.js version for default
138 const versionResult = getNextjsVersion(cwd)
139 const detectedVersion = versionResult.version
140
141 console.log(
142 pc.cyan('\n@next/codemod agents-md - Next.js Documentation for AI Agents\n')
143 )
144
145 if (detectedVersion) {
146 console.log(pc.gray(` Detected Next.js version: ${detectedVersion}\n`))
147 }
148
149 const response = await prompts(
150 [
151 {
152 type: 'text',
153 name: 'nextVersion',
154 message: 'Next.js version',
155 initial: detectedVersion || '',
156 validate: (value: string) =>
157 value.trim() ? true : 'Please enter a Next.js version',
158 },
159 {
160 type: 'select',
161 name: 'targetFile',
162 message: 'Target markdown file',
163 choices: [
164 { title: 'CLAUDE.md', value: 'CLAUDE.md' },
165 { title: 'AGENTS.md', value: 'AGENTS.md' },
166 { title: 'Custom...', value: '__custom__' },
167 ],
168 initial: 0,
169 },
170 ],
171 { onCancel }
172 )
173
174 // Handle cancelled prompts
175 if (response.nextVersion === undefined || response.targetFile === undefined) {
176 console.log(pc.yellow('\nCancelled.'))
177 process.exit(0)
178 }
179
180 let targetFile = response.targetFile
181
182 if (targetFile === '__custom__') {
183 const customResponse = await prompts(
184 {
185 type: 'text',
186 name: 'customFile',
187 message: 'Enter custom file path',
188 initial: 'CLAUDE.md',
189 validate: (value: string) =>
190 value.trim() ? true : 'Please enter a file path',
191 },

Callers 1

runAgentsMdFunction · 0.85

Calls 4

getNextjsVersionFunction · 0.90
trimMethod · 0.80
logMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected