@@ -70,6 +70,7 @@ interface CopyOptions {
7070 theme : boolean ;
7171 coreVersion : string ;
7272 cliVersion : string ;
73+ mcpVersion : string ;
7374}
7475
7576function shouldSkipFile ( relativePath : string , options : CopyOptions ) : boolean {
@@ -129,6 +130,7 @@ async function copyDir(
129130 content = content . replace ( / \{ \{ P R O J E C T _ N A M E \} \} / g, options . projectName ) ;
130131 content = content . replace ( / \{ \{ C O R E _ V E R S I O N \} \} / g, options . coreVersion ) ;
131132 content = content . replace ( / \{ \{ C L I _ V E R S I O N \} \} / g, options . cliVersion ) ;
133+ content = content . replace ( / \{ \{ M C P _ V E R S I O N \} \} / g, options . mcpVersion ) ;
132134
133135 // Add dark mode CSS variables if theme is enabled
134136 if ( options . theme && currentRelativePath === "app/globals.css" ) {
@@ -182,31 +184,42 @@ function getTemplatesDir(): string {
182184 * Reads CLI/Core package versions at runtime and returns them as ^major.minor.0
183185 * Used to replace {{CORE_VERSION}}, {{CLI_VERSION}} in template package.json
184186 */
185- async function resolvePackageVersions ( ) : Promise < { coreVersion : string ; cliVersion : string } > {
187+ async function resolvePackageVersions ( ) : Promise < {
188+ coreVersion : string ;
189+ cliVersion : string ;
190+ mcpVersion : string ;
191+ } > {
186192 const cliPkgPath = path . resolve ( import . meta. dir , "../../package.json" ) ;
187193 const cliPkg = JSON . parse ( await fs . readFile ( cliPkgPath , "utf-8" ) ) ;
188194 const cliVersion = cliPkg . version ?? "0.0.0" ;
189195
190- // Read core from CLI's node_modules or workspace
191- let coreVersion = cliVersion ; // fallback: same as CLI version
192- try {
193- const corePkgPath = require . resolve ( "@mandujs/core/package.json" , { paths : [ path . resolve ( import . meta. dir , "../.." ) ] } ) ;
194- const corePkg = JSON . parse ( await fs . readFile ( corePkgPath , "utf-8" ) ) ;
195- coreVersion = corePkg . version ?? coreVersion ;
196- } catch {
197- // workspace environment: try direct path
196+ const resolveSibling = async ( pkgName : string , workspaceDir : string ) : Promise < string > => {
198197 try {
199- const workspacePath = path . resolve ( import . meta. dir , "../../../core/package.json" ) ;
200- const corePkg = JSON . parse ( await fs . readFile ( workspacePath , "utf-8" ) ) ;
201- coreVersion = corePkg . version ?? coreVersion ;
198+ const pkgPath = require . resolve ( `${ pkgName } /package.json` , {
199+ paths : [ path . resolve ( import . meta. dir , "../.." ) ] ,
200+ } ) ;
201+ const pkg = JSON . parse ( await fs . readFile ( pkgPath , "utf-8" ) ) ;
202+ if ( pkg . version ) return pkg . version ;
203+ } catch {
204+ // fall through to workspace lookup
205+ }
206+ try {
207+ const workspacePath = path . resolve ( import . meta. dir , "../../../" , workspaceDir , "package.json" ) ;
208+ const pkg = JSON . parse ( await fs . readFile ( workspacePath , "utf-8" ) ) ;
209+ if ( pkg . version ) return pkg . version ;
202210 } catch {
203211 // keep fallback
204212 }
205- }
213+ return cliVersion ;
214+ } ;
215+
216+ const coreVersion = await resolveSibling ( "@mandujs/core" , "core" ) ;
217+ const mcpVersion = await resolveSibling ( "@mandujs/mcp" , "mcp" ) ;
206218
207219 return {
208220 coreVersion : `^${ coreVersion } ` ,
209221 cliVersion : `^${ cliVersion } ` ,
222+ mcpVersion : `^${ mcpVersion } ` ,
210223 } ;
211224}
212225
@@ -331,7 +344,7 @@ export async function init(options: InitOptions = {}): Promise<boolean> {
331344 return false ;
332345 }
333346
334- const { coreVersion, cliVersion } = await resolvePackageVersions ( ) ;
347+ const { coreVersion, cliVersion, mcpVersion } = await resolvePackageVersions ( ) ;
335348
336349 const copyOptions : CopyOptions = {
337350 projectName,
@@ -340,6 +353,7 @@ export async function init(options: InitOptions = {}): Promise<boolean> {
340353 theme : themeEnabled ,
341354 coreVersion,
342355 cliVersion,
356+ mcpVersion,
343357 } ;
344358
345359 // Run structured steps with progress
0 commit comments