fix: all script resolution uses bundled-first resolveTool()
Replace remaining hardcoded MOSAIC_HOME/tools paths (mosaic-init, mosaic-ensure-sequential-thinking) and toolScript() with a shared resolveTool() that checks the npm package first. Every script the CLI delegates to now picks up the bundled version immediately after npm upgrade — no mosaic init needed. Bump @mosaic/mosaic and @mosaic/cli to 0.0.8. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mosaic/cli",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.8",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -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) ───────────────────────────────────────────
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mosaic/mosaic",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.8",
|
||||
"description": "Mosaic agent framework — installation wizard and meta package",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
|
||||
Reference in New Issue
Block a user