@@ -203,8 +203,8 @@ program
203203 ) ;
204204
205205program
206- . command ( "init [conn]" )
207- . description ( "Create a monitoring user, required view(s), and grant required permissions (idempotent)" )
206+ . command ( "prepare-db [conn]" )
207+ . description ( "Prepare database for monitoring: create monitoring user, required view(s), and grant permissions (idempotent)" )
208208 . option ( "--db-url <url>" , "PostgreSQL connection URL (admin) to run the setup against (deprecated; pass it as positional arg)" )
209209 . option ( "-h, --host <host>" , "PostgreSQL host (psql-like)" )
210210 . option ( "-p, --port <port>" , "PostgreSQL port (psql-like)" )
@@ -223,9 +223,9 @@ program
223223 [
224224 "" ,
225225 "Examples:" ,
226- " postgresai init postgresql://admin@host:5432/dbname" ,
227- " postgresai init \"dbname=dbname host=host user=admin\"" ,
228- " postgresai init -h host -p 5432 -U admin -d dbname" ,
226+ " postgresai prepare-db postgresql://admin@host:5432/dbname" ,
227+ " postgresai prepare-db \"dbname=dbname host=host user=admin\"" ,
228+ " postgresai prepare-db -h host -p 5432 -U admin -d dbname" ,
229229 "" ,
230230 "Admin password:" ,
231231 " --admin-password <password> or PGPASSWORD=... (libpq standard)" ,
@@ -247,16 +247,16 @@ program
247247 " PGAI_MON_PASSWORD — monitoring password" ,
248248 "" ,
249249 "Inspect SQL without applying changes:" ,
250- " postgresai init <conn> --print-sql" ,
250+ " postgresai prepare-db <conn> --print-sql" ,
251251 "" ,
252252 "Verify setup (no changes):" ,
253- " postgresai init <conn> --verify" ,
253+ " postgresai prepare-db <conn> --verify" ,
254254 "" ,
255255 "Reset monitoring password only:" ,
256- " postgresai init <conn> --reset-password --password '...'" ,
256+ " postgresai prepare-db <conn> --reset-password --password '...'" ,
257257 "" ,
258258 "Offline SQL plan (no DB connection):" ,
259- " postgresai init --print-sql" ,
259+ " postgresai prepare-db --print-sql" ,
260260 ] . join ( "\n" )
261261 )
262262 . action ( async ( conn : string | undefined , opts : {
@@ -336,7 +336,7 @@ program
336336 } ) ;
337337 } catch ( e ) {
338338 const msg = e instanceof Error ? e . message : String ( e ) ;
339- console . error ( `Error: init : ${ msg } ` ) ;
339+ console . error ( `Error: prepare-db : ${ msg } ` ) ;
340340 // When connection details are missing, show full init help (options + examples).
341341 if ( typeof msg === "string" && msg . startsWith ( "Connection is required." ) ) {
342342 console . error ( "" ) ;
@@ -372,14 +372,14 @@ program
372372 includeOptionalPermissions,
373373 } ) ;
374374 if ( v . ok ) {
375- console . log ( "✓ init verify: OK" ) ;
375+ console . log ( "✓ prepare-db verify: OK" ) ;
376376 if ( v . missingOptional . length > 0 ) {
377377 console . log ( "⚠ Optional items missing:" ) ;
378378 for ( const m of v . missingOptional ) console . log ( `- ${ m } ` ) ;
379379 }
380380 return ;
381381 }
382- console . error ( "✗ init verify failed: missing required items" ) ;
382+ console . error ( "✗ prepare-db verify failed: missing required items" ) ;
383383 for ( const m of v . missingRequired ) console . error ( `- ${ m } ` ) ;
384384 if ( v . missingOptional . length > 0 ) {
385385 console . error ( "Optional items missing:" ) ;
@@ -455,7 +455,7 @@ program
455455
456456 const { applied, skippedOptional } = await applyInitPlan ( { client, plan : effectivePlan } ) ;
457457
458- console . log ( opts . resetPassword ? "✓ init password reset completed" : "✓ init completed" ) ;
458+ console . log ( opts . resetPassword ? "✓ prepare-db password reset completed" : "✓ prepare-db completed" ) ;
459459 if ( skippedOptional . length > 0 ) {
460460 console . log ( "⚠ Some optional steps were skipped (not supported or insufficient privileges):" ) ;
461461 for ( const s of skippedOptional ) console . log ( `- ${ s } ` ) ;
@@ -477,7 +477,7 @@ program
477477 if ( ! message || message === "[object Object]" ) {
478478 message = "Unknown error" ;
479479 }
480- console . error ( `Error: init : ${ message } ` ) ;
480+ console . error ( `Error: prepare-db : ${ message } ` ) ;
481481 // If this was a plan step failure, surface the step name explicitly to help users diagnose quickly.
482482 const stepMatch =
483483 typeof message === "string" ? message . match ( / F a i l e d a t s t e p " ( [ ^ " ] + ) " : / i) : null ;
@@ -679,16 +679,16 @@ program.command("help", { isDefault: true }).description("show help").action(()
679679const mon = program . command ( "mon" ) . description ( "monitoring services management" ) ;
680680
681681mon
682- . command ( "quickstart " )
683- . description ( "complete setup (generate config, start monitoring services)" )
682+ . command ( "local-install " )
683+ . description ( "install local monitoring stack (generate config, start services)" )
684684 . option ( "--demo" , "demo mode with sample database" , false )
685685 . option ( "--api-key <key>" , "Postgres AI API key for automated report uploads" )
686686 . option ( "--db-url <url>" , "PostgreSQL connection URL to monitor" )
687687 . option ( "--tag <tag>" , "Docker image tag to use (e.g., 0.14.0, 0.14.0-dev.33)" )
688688 . option ( "-y, --yes" , "accept all defaults and skip interactive prompts" , false )
689689 . action ( async ( opts : { demo : boolean ; apiKey ?: string ; dbUrl ?: string ; tag ?: string ; yes : boolean } ) => {
690690 console . log ( "\n=================================" ) ;
691- console . log ( " PostgresAI Monitoring Quickstart " ) ;
691+ console . log ( " PostgresAI monitoring local install " ) ;
692692 console . log ( "=================================\n" ) ;
693693 console . log ( "This will install, configure, and start the monitoring system\n" ) ;
694694
726726 if ( opts . demo && opts . apiKey ) {
727727 console . error ( "✗ Cannot use --api-key with --demo mode" ) ;
728728 console . error ( "✗ Demo mode is for testing only and does not support API key integration" ) ;
729- console . error ( "\nUse demo mode without API key: postgres-ai mon quickstart --demo" ) ;
730- console . error ( "Or use production mode with API key: postgres-ai mon quickstart --api-key=your_key" ) ;
729+ console . error ( "\nUse demo mode without API key: postgres-ai mon local-install --demo" ) ;
730+ console . error ( "Or use production mode with API key: postgres-ai mon local-install --api-key=your_key" ) ;
731731 process . exitCode = 1 ;
732732 return ;
733733 }
989989
990990 // Final summary
991991 console . log ( "=================================" ) ;
992- console . log ( " 🎉 Quickstart setup completed!" ) ;
992+ console . log ( " Local install completed!" ) ;
993993 console . log ( "=================================\n" ) ;
994994
995995 console . log ( "What's running:" ) ;
@@ -1536,10 +1536,26 @@ targets
15361536// Authentication and API key management
15371537program
15381538 . command ( "auth" )
1539- . description ( "authenticate via browser and obtain API key" )
1539+ . description ( "authenticate via browser (OAuth) or store API key directly" )
1540+ . option ( "--set-key <key>" , "store API key directly without OAuth flow" )
15401541 . option ( "--port <port>" , "local callback server port (default: random)" , parseInt )
15411542 . option ( "--debug" , "enable debug output" )
1542- . action ( async ( opts : { port ?: number ; debug ?: boolean } ) => {
1543+ . action ( async ( opts : { setKey ?: string ; port ?: number ; debug ?: boolean } ) => {
1544+ // If --set-key is provided, store it directly without OAuth
1545+ if ( opts . setKey ) {
1546+ const trimmedKey = opts . setKey . trim ( ) ;
1547+ if ( ! trimmedKey ) {
1548+ console . error ( "Error: API key cannot be empty" ) ;
1549+ process . exitCode = 1 ;
1550+ return ;
1551+ }
1552+
1553+ config . writeConfig ( { apiKey : trimmedKey } ) ;
1554+ console . log ( `API key saved to ${ config . getConfigPath ( ) } ` ) ;
1555+ return ;
1556+ }
1557+
1558+ // Otherwise, proceed with OAuth flow
15431559 const pkce = require ( "../lib/pkce" ) ;
15441560 const authServer = require ( "../lib/auth-server" ) ;
15451561
@@ -1765,8 +1781,9 @@ program
17651781
17661782program
17671783 . command ( "add-key <apiKey>" )
1768- . description ( "store API key" )
1784+ . description ( "store API key (deprecated: use 'auth --set-key' instead) " )
17691785 . action ( async ( apiKey : string ) => {
1786+ console . warn ( "Warning: 'add-key' is deprecated. Use 'auth --set-key <key>' instead.\n" ) ;
17701787 config . writeConfig ( { apiKey } ) ;
17711788 console . log ( `API key saved to ${ config . getConfigPath ( ) } ` ) ;
17721789 } ) ;
@@ -1893,7 +1910,7 @@ mon
18931910 const { projectDir } = await resolveOrInitPaths ( ) ;
18941911 const cfgPath = path . resolve ( projectDir , ".pgwatch-config" ) ;
18951912 if ( ! fs . existsSync ( cfgPath ) ) {
1896- console . error ( "Configuration file not found. Run 'postgres-ai mon quickstart ' first." ) ;
1913+ console . error ( "Configuration file not found. Run 'postgres-ai mon local-install ' first." ) ;
18971914 process . exitCode = 1 ;
18981915 return ;
18991916 }
0 commit comments