fix: all CLI script resolution uses bundled-first resolveTool() (#362)
This commit was merged in pull request #362.
This commit is contained in:
@@ -68,7 +68,7 @@ function checkSoul(): void {
|
||||
}
|
||||
|
||||
// Fallback: legacy bash mosaic-init
|
||||
const initBin = join(MOSAIC_HOME, 'tools', '_scripts', 'mosaic-init');
|
||||
const initBin = fwScript('mosaic-init');
|
||||
if (existsSync(initBin)) {
|
||||
spawnSync(initBin, [], { stdio: 'inherit' });
|
||||
} else {
|
||||
@@ -79,7 +79,7 @@ function checkSoul(): void {
|
||||
}
|
||||
|
||||
function checkSequentialThinking(runtime: string): void {
|
||||
const checker = join(MOSAIC_HOME, 'tools', '_scripts', 'mosaic-ensure-sequential-thinking');
|
||||
const checker = fwScript('mosaic-ensure-sequential-thinking');
|
||||
if (!existsSync(checker)) return; // Skip if checker doesn't exist
|
||||
const result = spawnSync(checker, ['--check', '--runtime', runtime], { stdio: 'ignore' });
|
||||
if (result.status !== 0) {
|
||||
@@ -493,24 +493,28 @@ function delegateToScript(scriptPath: string, args: string[], env?: Record<strin
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a framework script path. Prefers the version bundled in the
|
||||
* @mosaic/mosaic npm package (always matches the installed CLI version)
|
||||
* over the deployed copy in ~/.config/mosaic/ (may be stale).
|
||||
* Resolve a path under the framework tools directory. Prefers the version
|
||||
* bundled in the @mosaic/mosaic npm package (always matches the installed
|
||||
* CLI version) over the deployed copy in ~/.config/mosaic/ (may be stale).
|
||||
*/
|
||||
function fwScript(name: string): string {
|
||||
function resolveTool(...segments: string[]): string {
|
||||
try {
|
||||
const require = createRequire(import.meta.url);
|
||||
const mosaicPkg = dirname(require.resolve('@mosaic/mosaic/package.json'));
|
||||
const bundled = join(mosaicPkg, 'framework', 'tools', '_scripts', name);
|
||||
const req = createRequire(import.meta.url);
|
||||
const mosaicPkg = dirname(req.resolve('@mosaic/mosaic/package.json'));
|
||||
const bundled = join(mosaicPkg, 'framework', 'tools', ...segments);
|
||||
if (existsSync(bundled)) return bundled;
|
||||
} catch {
|
||||
// Fall through to deployed copy
|
||||
}
|
||||
return join(MOSAIC_HOME, 'tools', '_scripts', name);
|
||||
return join(MOSAIC_HOME, 'tools', ...segments);
|
||||
}
|
||||
|
||||
function fwScript(name: string): string {
|
||||
return resolveTool('_scripts', name);
|
||||
}
|
||||
|
||||
function toolScript(toolDir: string, name: string): string {
|
||||
return join(MOSAIC_HOME, 'tools', toolDir, name);
|
||||
return resolveTool(toolDir, name);
|
||||
}
|
||||
|
||||
// ─── Coord (mission orchestrator) ───────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user