@@ -27,7 +27,7 @@ const LEGACY_COMMANDS = ['docgen-discover','docgen-analyze','docgen-fix','docgen
2727const LEGACY_MANAGED = [ ...LEGACY_ENGINE , ...LEGACY_AGENTS , ...LEGACY_COMMANDS ] ;
2828
2929function sha256 ( data ) { return crypto . createHash ( 'sha256' ) . update ( data ) . digest ( 'hex' ) ; }
30- function walk ( dir ) { const out = [ ] ; for ( const entry of fs . readdirSync ( dir , { withFileTypes : true } ) ) { const file = path . join ( dir , entry . name ) ; entry . isDirectory ( ) ? out . push ( ...walk ( file ) ) : out . push ( file ) ; } return out ; }
30+ function walk ( dir ) { if ( ! fs . existsSync ( dir ) ) return [ ] ; const out = [ ] ; for ( const entry of fs . readdirSync ( dir , { withFileTypes : true } ) ) { const file = path . join ( dir , entry . name ) ; entry . isDirectory ( ) ? out . push ( ...walk ( file ) ) : out . push ( file ) ; } return out ; }
3131function ensureDir ( dir ) { if ( ! dryRun ) fs . mkdirSync ( dir , { recursive : true } ) ; }
3232function copyWithPolicy ( src , dest , backupRoot , installed , skipped ) {
3333 const data = fs . readFileSync ( src ) ; const rel = path . relative ( commandCodeHome , dest ) . replaceAll ( '\\' , '/' ) ;
@@ -74,8 +74,8 @@ function mergeGlobalSettings(backupRoot, installed) {
7474function installGlobal ( ) {
7575 const template = path . join ( here , 'global-template' ) ; const backupRoot = path . join ( commandCodeHome , 'docgen-backup' , timestamp ) ; const installed = [ ] ; const skipped = [ ] ;
7676 ensureDir ( commandCodeHome ) ;
77- for ( const area of [ 'agents' , 'skills' , 'commands' ] ) for ( const src of walk ( path . join ( template , area ) ) ) copyWithPolicy ( src , path . join ( commandCodeHome , area , path . relative ( path . join ( template , area ) , src ) ) , backupRoot , installed , skipped ) ;
78- for ( const src of walk ( path . join ( template , 'docgen' ) ) ) copyWithPolicy ( src , path . join ( commandCodeHome , 'docgen' , path . relative ( path . join ( template , 'docgen' ) , src ) ) , backupRoot , installed , skipped ) ;
77+ for ( const area of [ 'agents' , 'skills' , 'commands' ] ) { const areaRoot = path . join ( template , area ) ; for ( const src of walk ( areaRoot ) ) copyWithPolicy ( src , path . join ( commandCodeHome , area , path . relative ( areaRoot , src ) ) , backupRoot , installed , skipped ) ; }
78+ const engineRoot = path . join ( template , 'docgen' ) ; for ( const src of walk ( engineRoot ) ) copyWithPolicy ( src , path . join ( commandCodeHome , 'docgen' , path . relative ( engineRoot , src ) ) , backupRoot , installed , skipped ) ;
7979 removeLegacy ( commandCodeHome , LEGACY_MANAGED , backupRoot , installed ) ;
8080 mergeGlobalSettings ( backupRoot , installed ) ;
8181 if ( ! dryRun ) {
0 commit comments