Skip to content

Commit 04a41a3

Browse files
committed
fixes for parsing
1 parent 775fa44 commit 04a41a3

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/commands/init/ai-rules.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@ const getRepoUrlFromProjectId = async (api: NetlifyAPI, projectId: string): Prom
317317
}
318318
}
319319

320-
const savePrompt = async (instructions: string, targetDir: string): Promise<void> => {
320+
const savePrompt = async (instructions: string, ntlContext: string | null, targetDir: string): Promise<void> => {
321321
try {
322322
const filePath = resolve(targetDir, 'AI-instructions.md')
323-
await fs.writeFile(filePath, instructions, 'utf-8')
323+
await fs.writeFile(filePath, `Context: ${ntlContext ?? ''}\n\n${instructions}`, 'utf-8')
324324
log(`${chalk.green('✅')} AI instructions saved to ${chalk.cyan('AI-instructions.md')}`)
325325
} catch (error) {
326326
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
@@ -376,8 +376,21 @@ export const initWithAiRules = async (hash: string, command: BaseCommand): Promi
376376

377377
// Step 4: Save AI instructions to file
378378
if (projectInfo.prompt) {
379+
const ntlContext = await fetch(
380+
'https://docs.netlify.com/ai-context/scoped-context?scopes=serverless,blobs,forms',
381+
{
382+
method: 'GET',
383+
headers: {
384+
'Content-Type': 'text/plain',
385+
},
386+
},
387+
)
388+
.then((res) => res.text())
389+
.catch(() => {
390+
return null
391+
})
379392
log('\n📝 Saving AI instructions...')
380-
await savePrompt(projectInfo.prompt, targetDir)
393+
await savePrompt(projectInfo.prompt, ntlContext, targetDir)
381394
}
382395

383396
// Step 5: Detect IDE and configure MCP server
@@ -405,28 +418,30 @@ export const initWithAiRules = async (hash: string, command: BaseCommand): Promi
405418
log()
406419
log(chalk.yellowBright(`📁 Step 1: Enter your project directory`))
407420
log(` ${chalk.cyanBright(`cd ${targetDir}`)}`)
408-
421+
409422
if (detectedIDE) {
410423
if (mcpConfigured) {
411424
log(chalk.yellowBright(`🔧 Step 2: MCP Server Configured`))
412-
log(` ${chalk.green('✅')} ${chalk.cyan(detectedIDE.presentedName)} is ready with Netlify MCP server`)
425+
log(` ${chalk.green('✅')} ${chalk.cyan(detectedIDE.key)} is ready with Netlify MCP server`)
413426
log(` ${chalk.gray('💡 MCP will activate when you reload/restart your IDE window')}`)
414427
} else {
415428
log(chalk.yellowBright(`🔧 Step 2: Manual MCP Configuration`))
416-
log(` ${chalk.cyan(detectedIDE.presentedName)} detected - MCP setup was skipped`)
429+
log(` ${chalk.cyan(detectedIDE.key)} detected - MCP setup was skipped`)
417430
log(` ${chalk.gray('You can configure MCP manually later for enhanced AI capabilities')}`)
418431
}
419432
log()
420433
}
421-
434+
422435
if (projectInfo.prompt) {
423436
const stepNumber = detectedIDE ? '3' : '2'
424437
log(chalk.yellowBright(`🤖 Step ${stepNumber}: Ask your AI assistant to process the instructions`))
425438
log()
426-
log(chalk.bgGreen.black.bold(` follow instructions in ${targetDir}/AI-instructions.md `))
439+
log(chalk.gray('*'.repeat(60)))
440+
log(chalk.cyan(`Follow ${targetDir}/AI-instructions.md and create a new site`))
441+
log(chalk.gray('*'.repeat(60)))
427442
log()
428443
}
429444
} catch (error) {
430445
return logAndThrowError(error)
431446
}
432-
}
447+
}

0 commit comments

Comments
 (0)