1
1
import { getPlatformFromFolder } from "../../../dataconnect/appFinder" ;
2
2
import { Platform } from "../../../dataconnect/types" ;
3
3
import { prompt } from "../../prompt" ;
4
+ import { init_ai } from "../../resources/guides/init_ai" ;
5
+ import { init_backend } from "../../resources/guides/init_backend" ;
6
+ import { ServerResource } from "../../resource" ;
7
+
8
+ const GUIDE_PARAMS : Record < string , ServerResource > = {
9
+ "ai-logic" : init_ai ,
10
+ backend : init_backend ,
11
+ } ;
4
12
5
13
export const init = prompt (
6
14
{
@@ -17,7 +25,25 @@ export const init = prompt(
17
25
title : "Initialize Firebase" ,
18
26
} ,
19
27
} ,
20
- async ( { prompt } , { config, projectId, accountEmail } ) => {
28
+ async ( { prompt } , mcp ) => {
29
+ const { config, projectId, accountEmail } = mcp ;
30
+
31
+ // This allows a "short circuit" feature where you can pass a specific
32
+ // name, like "ai-logic" into the prompt and get a specific guide
33
+ const resourceDefinition = prompt ? GUIDE_PARAMS [ prompt ] : undefined ;
34
+ if ( resourceDefinition ) {
35
+ const resource = await resourceDefinition . fn ( resourceDefinition . mcp . uri , mcp ) ;
36
+ return resource . contents
37
+ . filter ( ( resContents ) => ! ! resContents . text )
38
+ . map ( ( resContents ) => ( {
39
+ role : "user" as const ,
40
+ content : {
41
+ type : "text" ,
42
+ text : String ( resContents . text ) ,
43
+ } ,
44
+ } ) ) ;
45
+ }
46
+
21
47
const platform = await getPlatformFromFolder ( config . projectDir ) ;
22
48
23
49
return [
0 commit comments