@@ -96,7 +96,44 @@ export const serveCommand = new Command('serve')
9696 logger : loggerConfig
9797 } ) ;
9898
99- // Auto-register AppPlugin if config contains app definitions
99+ // Load plugins from configuration
100+ let plugins = config . plugins || [ ] ;
101+
102+ // Merge devPlugins if in dev mode
103+ if ( options . dev && config . devPlugins ) {
104+ console . log ( chalk . blue ( `📦 Loading development plugins...` ) ) ;
105+ plugins = [ ...plugins , ...config . devPlugins ] ;
106+ }
107+
108+ // 1. Auto-register ObjectQL Plugin if objects define but plugins missing
109+ const hasObjectQL = plugins . some ( ( p : any ) => p . name ?. includes ( 'objectql' ) || p . constructor ?. name ?. includes ( 'ObjectQL' ) ) ;
110+ if ( config . objects && ! hasObjectQL ) {
111+ try {
112+ console . log ( chalk . dim ( ` Auto-injecting ObjectQL Engine...` ) ) ;
113+ const { ObjectQLPlugin } = await import ( '@objectstack/objectql' ) ;
114+ kernel . use ( new ObjectQLPlugin ( ) ) ;
115+ console . log ( chalk . green ( ` ✓ Registered ObjectQL Plugin (auto-detected)` ) ) ;
116+ } catch ( e : any ) {
117+ console . warn ( chalk . yellow ( ` ⚠ Could not auto-load ObjectQL: ${ e . message } ` ) ) ;
118+ }
119+ }
120+
121+ // 2. Auto-register Memory Driver if in Dev and no driver configured
122+ const hasDriver = plugins . some ( ( p : any ) => p . name ?. includes ( 'driver' ) || p . constructor ?. name ?. includes ( 'Driver' ) ) ;
123+ if ( isDev && ! hasDriver && config . objects ) {
124+ try {
125+ console . log ( chalk . dim ( ` Auto-injecting Memory Driver (Dev Mode)...` ) ) ;
126+ const { DriverPlugin } = await import ( '@objectstack/runtime' ) ;
127+ const { InMemoryDriver } = await import ( '@objectstack/driver-memory' ) ;
128+ kernel . use ( new DriverPlugin ( new InMemoryDriver ( ) ) ) ;
129+ console . log ( chalk . green ( ` ✓ Registered Memory Driver (auto-detected)` ) ) ;
130+ } catch ( e : any ) {
131+ // Silent fail - maybe they don't want a driver or don't have the package
132+ console . log ( chalk . dim ( ` ℹ No default driver loaded: ${ e . message } ` ) ) ;
133+ }
134+ }
135+
136+ // 3. Auto-register AppPlugin if config contains app definitions
100137 if ( config . objects || config . manifest || config . apps ) {
101138 try {
102139 const { AppPlugin } = await import ( '@objectstack/runtime' ) ;
@@ -107,14 +144,6 @@ export const serveCommand = new Command('serve')
107144 }
108145 }
109146
110- // Load plugins from configuration
111- let plugins = config . plugins || [ ] ;
112-
113- // Merge devPlugins if in dev mode
114- if ( options . dev && config . devPlugins ) {
115- console . log ( chalk . blue ( `📦 Loading development plugins...` ) ) ;
116- plugins = [ ...plugins , ...config . devPlugins ] ;
117- }
118147
119148 if ( plugins . length > 0 ) {
120149 console . log ( chalk . yellow ( `📦 Loading ${ plugins . length } plugin(s)...` ) ) ;
0 commit comments