@@ -3,7 +3,8 @@ import path from "node:path";
33
44const ROOT = process . cwd ( ) ;
55
6- const REQUIRED_DIRS = [ "agents" , "apps" , "automations" , "projects" ] ;
6+ const JSON_DIRS = [ "agents" , "automations" , "projects" ] ;
7+ const APP_DIR = "apps" ;
78
89const errors = [ ] ;
910
@@ -46,6 +47,25 @@ function listJsonFiles(dirName) {
4647 return files ;
4748}
4849
50+ function listAppDirs ( dirName ) {
51+ const dirPath = path . join ( ROOT , dirName ) ;
52+ if ( ! fs . existsSync ( dirPath ) ) {
53+ fail ( `Missing directory: ${ dirName } ` ) ;
54+ return [ ] ;
55+ }
56+
57+ const dirs = fs
58+ . readdirSync ( dirPath , { withFileTypes : true } )
59+ . filter ( ( entry ) => entry . isDirectory ( ) )
60+ . map ( ( entry ) => path . join ( dirPath , entry . name ) ) ;
61+
62+ if ( dirs . length === 0 ) {
63+ fail ( `Directory has no app subdirectories: ${ dirName } ` ) ;
64+ }
65+
66+ return dirs ;
67+ }
68+
4969function validateManifest ( ) {
5070 const filePath = path . join ( ROOT , "manifest.json" ) ;
5171 if ( ! fs . existsSync ( filePath ) ) {
@@ -87,17 +107,21 @@ function validateAgents() {
87107}
88108
89109function validateApps ( ) {
90- for ( const filePath of listJsonFiles ( "apps" ) ) {
91- const data = readJson ( filePath ) ;
110+ for ( const appDir of listAppDirs ( APP_DIR ) ) {
111+ const pkgPath = path . join ( appDir , "package.json" ) ;
112+ const rel = path . relative ( ROOT , appDir ) ;
113+
114+ if ( ! fs . existsSync ( pkgPath ) ) {
115+ fail ( `${ rel } : missing package.json` ) ;
116+ continue ;
117+ }
118+
119+ const data = readJson ( pkgPath ) ;
92120 if ( data == null ) {
93121 continue ;
94122 }
95123
96- const rel = path . relative ( ROOT , filePath ) ;
97- assert (
98- typeof data . src === "object" && data . src != null ,
99- `${ rel } : src object is required` ,
100- ) ;
124+ assert ( typeof data . name === "string" , `${ rel } /package.json: name must be a string` ) ;
101125 }
102126}
103127
@@ -138,9 +162,10 @@ function validateProjects() {
138162
139163validateManifest ( ) ;
140164
141- for ( const dirName of REQUIRED_DIRS ) {
165+ for ( const dirName of JSON_DIRS ) {
142166 listJsonFiles ( dirName ) ;
143167}
168+ listAppDirs ( APP_DIR ) ;
144169
145170validateAgents ( ) ;
146171validateApps ( ) ;
0 commit comments