Skip to content

Commit 7051583

Browse files
committed
feat(application-starter): inject migration guide URLs into final prompt
When the user brief indicates a Next.js or Remix/React Router migration, append an instruction telling the downstream agent to fetch the relevant tanstack.com migration guide and follow it. Keeps the guide out of the analyze stage and out of the UI; only affects the final generation prompt.
1 parent c030f08 commit 7051583

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/components/application-builder/shared.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,15 @@ export type StarterPartnerButtonStyle = CSSProperties & {
5252

5353
const nextJsMigrationPattern =
5454
/migrat(?:e|ing|ion).*(next(?:\.js)?)|(next(?:\.js)?).*(migrat(?:e|ing|ion))/i
55+
const remixMigrationPattern =
56+
/migrat(?:e|ing|ion).*(remix|react[\s-]?router)|(remix|react[\s-]?router).*(migrat(?:e|ing|ion))/i
5557
const migrationRepositoryUrlPattern = /^(https?:\/\/\S+|git@\S+|ssh:\/\/\S+)$/i
5658

59+
export const STARTER_NEXTJS_MIGRATION_GUIDE_URL =
60+
'https://tanstack.com/start/latest/docs/framework/react/migrate-from-next-js'
61+
export const STARTER_REMIX_MIGRATION_GUIDE_URL =
62+
'https://tanstack.com/router/latest/docs/guide/how-to/migrate-from-react-router'
63+
5764
export const starterPinnedLibraryIds = [
5865
'start',
5966
'router',
@@ -142,6 +149,22 @@ export function isNextJsMigrationInput(input: string) {
142149
return nextJsMigrationPattern.test(input)
143150
}
144151

152+
export function isRemixMigrationInput(input: string) {
153+
return remixMigrationPattern.test(input)
154+
}
155+
156+
export function getStarterMigrationGuideUrl(input: string) {
157+
if (isNextJsMigrationInput(input)) {
158+
return STARTER_NEXTJS_MIGRATION_GUIDE_URL
159+
}
160+
161+
if (isRemixMigrationInput(input)) {
162+
return STARTER_REMIX_MIGRATION_GUIDE_URL
163+
}
164+
165+
return null
166+
}
167+
145168
export function normalizeMigrationRepositoryUrl(value: string) {
146169
return value.trim()
147170
}

src/utils/application-starter.server.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import {
1717
type ApplicationStarterResult,
1818
} from '~/utils/application-starter'
1919
import type { LibraryId } from '~/libraries'
20-
import { starterAddonLibraryIds } from '~/components/application-builder/shared'
20+
import {
21+
getStarterMigrationGuideUrl,
22+
starterAddonLibraryIds,
23+
} from '~/components/application-builder/shared'
2124
import {
2225
getApplicationStarterGuidanceLines,
2326
getApplicationStarterPartnerSuggestions,
@@ -400,6 +403,10 @@ function buildPromptGenerationRequest({
400403
].join('\n')
401404
const userBrief = getApplicationStarterUserBrief(request.input)
402405
const starterGuidanceLines = getApplicationStarterGuidanceLines(request.input)
406+
const migrationGuideUrl = getStarterMigrationGuideUrl(request.input)
407+
const migrationGuideInstruction = migrationGuideUrl
408+
? `The prompt must instruct the agent to fetch ${migrationGuideUrl} and use it as the primary reference for the migration, following its steps in order.`
409+
: null
403410

404411
return [
405412
'Write a short, natural final prompt for a stronger coding agent.',
@@ -417,6 +424,7 @@ function buildPromptGenerationRequest({
417424
'If the user says things like make it cool, keep it minimal, or do not include something, restate those instructions explicitly in the final prompt instead of compressing them away.',
418425
'Use the resolved starter plan as fixed input. Do not redesign the stack unless the original brief requires sequencing work after scaffolding.',
419426
'Keep the prompt concise and plain-English. Avoid internal process language like fixed input, resolved plan, objective, implementation notes, or deliverable.',
427+
...(migrationGuideInstruction ? [migrationGuideInstruction] : []),
420428
'',
421429
`Context: ${request.context}`,
422430
`User request: ${userBrief}`,

0 commit comments

Comments
 (0)