@@ -175,56 +175,21 @@ export default class Serve extends Command {
175175 throw new Error ( `No default export found in ${ args . config } ` ) ;
176176 }
177177
178- // If the user's config is a bare defineStack() and OBJECTSTACK_MODE is
179- // set (or config.bootMode is set), build the full project/ cloud/
180- // standalone stack via @objectstack /service- cloud. The package is
181- // resolved by walking up node_modules from the user's cwd, so it
182- // picks up the consumer's installation regardless of where the CLI
183- // itself lives .
178+ // Project mode is the canonical OS dev workflow. Every bare
179+ // `defineStack()` is booted via `@objectstack/service- cloud`'s
180+ // `createBootStack()` (project / cloud / standalone are selected
181+ // by `OBJECTSTACK_MODE`, default `project`). Set
182+ // `OBJECTSTACK_MODE=off` to fall back to the legacy lightweight
183+ // assembler .
184184 if ( shouldBootWithLibrary ( config ) ) {
185- try {
186- const { pathToFileURL } = await import ( 'node:url' ) ;
187- let dir = process . cwd ( ) ;
188- let cloudPkgDir : string | null = null ;
189- // Walk upward from cwd looking for node_modules/@objectstack /service-cloud
190- while ( true ) {
191- const candidate = path . join ( dir , 'node_modules' , '@objectstack' , 'service-cloud' ) ;
192- if ( fs . existsSync ( path . join ( candidate , 'package.json' ) ) ) {
193- cloudPkgDir = candidate ;
194- break ;
195- }
196- const parent = path . dirname ( dir ) ;
197- if ( parent === dir ) break ;
198- dir = parent ;
199- }
200- if ( ! cloudPkgDir ) {
201- throw new Error ( '@objectstack/service-cloud not found in any node_modules from cwd upward' ) ;
202- }
203- const pkg = JSON . parse (
204- fs . readFileSync ( path . join ( cloudPkgDir , 'package.json' ) , 'utf8' ) ,
205- ) ;
206- const entry =
207- pkg . exports ?. [ '.' ] ?. import ??
208- pkg . exports ?. [ '.' ] ?. default ??
209- pkg . module ??
210- pkg . main ??
211- 'dist/index.js' ;
212- const cloudEntry = path . join ( cloudPkgDir , entry ) ;
213- const cloudMod : any = await import ( pathToFileURL ( cloudEntry ) . href ) ;
214- const bootResult = await cloudMod . createBootStack ( {
215- mode : config . bootMode ,
216- project : config . project ,
217- cloud : config . cloud ,
218- standalone : config . standalone ,
219- } ) ;
220- config = bootResult as any ;
221- } catch ( err ) {
222- console . error (
223- 'OBJECTSTACK_MODE is set but @objectstack/service-cloud cannot be loaded.' ,
224- 'Install it with: pnpm add @objectstack/service-cloud' ,
225- ) ;
226- throw err ;
227- }
185+ const { createBootStack } = await import ( '@objectstack/service-cloud' ) ;
186+ const bootResult = await createBootStack ( {
187+ mode : config . bootMode ,
188+ project : config . project ,
189+ cloud : config . cloud ,
190+ standalone : config . standalone ,
191+ } ) ;
192+ config = bootResult as any ;
228193 }
229194
230195 // ── Resolve plugin tiers ──────────────────────────────────────
0 commit comments