@@ -52,10 +52,10 @@ program
5252// Additional commands must be registered before final parse.
5353program
5454 . command ( 'add' )
55- . description ( 'Add a new service or plugin ' )
56- . argument ( '<entity>' , 'service | plugin' )
57- . argument ( '<name>' , 'Name of the service or plugin ' )
58- . option ( '--type <type>' , 'Service type (node|python|go|java|frontend|remix|astro|sveltekit)' )
55+ . description ( 'Add a new service, plugin, or shared library ' )
56+ . argument ( '<entity>' , 'service | plugin | lib ' )
57+ . argument ( '<name>' , 'Name of the service, plugin, or library ' )
58+ . option ( '--type <type>' , 'Service type (node|python|go|java|frontend|remix|astro|sveltekit) or Library type (python|go) ' )
5959 . option ( '--lang <type>' , '(Deprecated) Alias of --type' )
6060 . option ( '--port <port>' , 'Service port' )
6161 . option ( '--yes' , 'Non-interactive defaults' )
@@ -92,8 +92,24 @@ program
9292 await addService ( projectDir , { type, name, port } , opts ) ;
9393 } else if ( entity === 'plugin' ) {
9494 await scaffoldPlugin ( projectDir , name ) ;
95+ } else if ( entity === 'lib' ) {
96+ let type = opts . type || opts . lang ;
97+ if ( ! opts . yes ) {
98+ const promptsMod = await import ( 'prompts' ) ;
99+ const p = promptsMod . default ;
100+ if ( ! type ) {
101+ const ans = await p ( { type : 'select' , name : 'type' , message : 'Library type:' , choices : [
102+ { title : 'Python Package' , value : 'python' } ,
103+ { title : 'Go Module' , value : 'go' }
104+ ] } ) ;
105+ type = ans . type ;
106+ }
107+ }
108+ if ( ! type ) throw new Error ( 'Library type required' ) ;
109+ const { scaffoldSharedLibrary } = await import ( './lib/scaffold.js' ) ;
110+ await scaffoldSharedLibrary ( projectDir , { type, name } , opts ) ;
95111 } else {
96- console . error ( chalk . red ( `Unknown entity '${ entity } '. Use service or plugin .` ) ) ;
112+ console . error ( chalk . red ( `Unknown entity '${ entity } '. Use service, plugin, or lib .` ) ) ;
97113 process . exit ( 1 ) ;
98114 }
99115 } catch ( e ) {
@@ -104,10 +120,10 @@ program
104120
105121program
106122 . command ( 'remove' )
107- . description ( 'Remove a service or plugin ' )
108- . argument ( '<entity>' , 'service | plugin' )
109- . argument ( '<name>' , 'Name of the service or plugin ' )
110- . option ( '--keep-files' , 'Keep service files, only remove from configuration' )
123+ . description ( 'Remove a service, plugin, or shared library ' )
124+ . argument ( '<entity>' , 'service | plugin | lib ' )
125+ . argument ( '<name>' , 'Name of the service, plugin, or library ' )
126+ . option ( '--keep-files' , 'Keep service/library files, only remove from configuration' )
111127 . option ( '--yes' , 'Skip confirmation prompt' )
112128 . action ( async ( entity , name , opts ) => {
113129 const projectDir = process . cwd ( ) ;
@@ -116,8 +132,11 @@ program
116132 await removeService ( projectDir , name , opts ) ;
117133 } else if ( entity === 'plugin' ) {
118134 await removePlugin ( projectDir , name , opts ) ;
135+ } else if ( entity === 'lib' ) {
136+ const { removeSharedLibrary } = await import ( './lib/scaffold.js' ) ;
137+ await removeSharedLibrary ( projectDir , name , opts ) ;
119138 } else {
120- console . error ( chalk . red ( `Unknown entity '${ entity } '. Use service or plugin .` ) ) ;
139+ console . error ( chalk . red ( `Unknown entity '${ entity } '. Use service, plugin, or lib .` ) ) ;
121140 process . exit ( 1 ) ;
122141 }
123142 } catch ( e ) {
@@ -158,6 +177,37 @@ program
158177 }
159178 } ) ;
160179
180+ program
181+ . command ( 'libraries' )
182+ . alias ( 'libs' )
183+ . description ( 'List shared libraries in the current workspace (table)' )
184+ . option ( '--json' , 'Output raw JSON instead of table' )
185+ . action ( async ( opts ) => {
186+ try {
187+ const cwd = process . cwd ( ) ;
188+ const cfgPath = path . join ( cwd , 'polyglot.json' ) ;
189+ if ( ! fs . existsSync ( cfgPath ) ) {
190+ console . log ( chalk . red ( 'polyglot.json not found. Run inside a generated workspace.' ) ) ;
191+ process . exit ( 1 ) ;
192+ }
193+ const cfg = JSON . parse ( fs . readFileSync ( cfgPath , 'utf-8' ) ) ;
194+ const libs = cfg . sharedLibs || [ ] ;
195+ if ( opts . json ) {
196+ console . log ( JSON . stringify ( libs , null , 2 ) ) ;
197+ } else {
198+ if ( libs . length === 0 ) {
199+ console . log ( chalk . yellow ( 'No shared libraries found.' ) ) ;
200+ } else {
201+ const { renderLibrariesTable } = await import ( './lib/ui.js' ) ;
202+ renderLibrariesTable ( libs , { title : 'Shared Libraries' } ) ;
203+ }
204+ }
205+ } catch ( e ) {
206+ console . error ( chalk . red ( 'Failed to list libraries:' ) , e . message ) ;
207+ process . exit ( 1 ) ;
208+ }
209+ } ) ;
210+
161211program
162212 . command ( 'admin' )
163213 . description ( 'Launch admin dashboard to monitor service status' )
0 commit comments