@@ -159,7 +159,7 @@ await node('06 models listed', async () => {
159159await node ( '07 create project' , async ( ) => {
160160 const r = await gql (
161161 'mutation($i:CreateProjectInput!){createProject(createProjectInput:$i){id}}' ,
162- { i : { description : '帮我做一个网站' , public : false , model : state . model } } ,
162+ { i : { description : '帮我做一个网站' , public : false , model : state . model , template : 'next' } } ,
163163 state . token
164164 ) ;
165165 state . chatId = r . data ?. createProject ?. id ;
@@ -425,6 +425,66 @@ await node('23 admin overview answers', async () => {
425425 return `${ r . data . adminOverview . counts . users } users, ${ r . data . adminOverview . counts . projects } projects` ;
426426} ) ;
427427
428+ await node ( '24 html project scaffolds instantly' , async ( ) => {
429+ const r = await gqlOrThrow (
430+ 'mutation($i:CreateProjectInput!){createProject(createProjectInput:$i){id}}' ,
431+ { i : { description : '一个双语打招呼页面' , public : false , model : state . model , template : 'html' } } ,
432+ state . token ,
433+ ) ;
434+ state . htmlChatId = r . data . createProject . id ;
435+ for ( let i = 0 ; i < 12 ; i ++ ) {
436+ const d = await gql (
437+ 'query($c:String!){getChatDetails(chatId:$c){project{projectPath template}}}' ,
438+ { c : state . htmlChatId } ,
439+ state . token ,
440+ ) ;
441+ const project = d . data ?. getChatDetails ?. project ;
442+ if ( project ?. projectPath ) {
443+ if ( project . template !== 'html' ) throw new Error ( `kind ${ project . template } ` ) ;
444+ state . htmlPath = project . projectPath ;
445+ const f = await rest (
446+ `/api/file?path=${ encodeURIComponent ( `${ state . htmlPath } /index.html` ) } ` ,
447+ { } ,
448+ state . token ,
449+ ) ;
450+ const { content } = await f . json ( ) ;
451+ if ( ! content ?. includes ( 'tailwind' ) ) throw new Error ( 'no starter html' ) ;
452+ return state . htmlPath ;
453+ }
454+ await new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) ) ;
455+ }
456+ throw new Error ( 'html project never bound' ) ;
457+ } ) ;
458+
459+ await node ( '25 html turn edits the page, nothing else' , async ( ) => {
460+ const { tools } = await turn (
461+ state . htmlChatId ,
462+ '把页面做成中英双语的打招呼页,深色背景' ,
463+ state . token ,
464+ ) ;
465+ if ( tools < 1 ) throw new Error ( 'no tools ran' ) ;
466+ const f = await rest (
467+ `/api/file?path=${ encodeURIComponent ( `${ state . htmlPath } /index.html` ) } ` ,
468+ { } ,
469+ state . token ,
470+ ) ;
471+ const { content } = await f . json ( ) ;
472+ if ( ! content || content . length < 600 ) throw new Error ( 'page unchanged' ) ;
473+ if ( content . includes ( 'package.json' ) ) throw new Error ( 'toolchain leaked in' ) ;
474+ return `${ content . length } bytes` ;
475+ } ) ;
476+
477+ await node ( '26 html changes are exactly the page' , async ( ) => {
478+ const r = await rest ( `/api/project/changes?path=${ state . htmlPath } ` , { } , state . token ) ;
479+ const { changes } = await r . json ( ) ;
480+ if ( ! changes ?. some ( ( c ) => c . path === 'index.html' ) ) throw new Error ( 'index.html not listed' ) ;
481+ await gqlOrThrow (
482+ 'mutation($c:String!){deleteChat(chatId:$c)}' ,
483+ { c : state . htmlChatId } ,
484+ state . token ,
485+ ) ;
486+ } ) ;
487+
428488const failed = results . filter ( ( r ) => ! r . ok ) ;
429489console . log (
430490 `\n${ results . length - failed . length } /${ results . length } nodes green`
0 commit comments