fix: all CLI script resolution uses bundled-first resolveTool() (#362)
Some checks failed
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/push/publish Pipeline failed

This commit was merged in pull request #362.
This commit is contained in:
2026-04-03 02:28:07 +00:00
parent db8023bdbb
commit 70a51ba711
3 changed files with 17 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mosaic/cli", "name": "@mosaic/cli",
"version": "0.0.7", "version": "0.0.8",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@@ -68,7 +68,7 @@ function checkSoul(): void {
} }
// Fallback: legacy bash mosaic-init // Fallback: legacy bash mosaic-init
const initBin = join(MOSAIC_HOME, 'tools', '_scripts', 'mosaic-init'); const initBin = fwScript('mosaic-init');
if (existsSync(initBin)) { if (existsSync(initBin)) {
spawnSync(initBin, [], { stdio: 'inherit' }); spawnSync(initBin, [], { stdio: 'inherit' });
} else { } else {
@@ -79,7 +79,7 @@ function checkSoul(): void {
} }
function checkSequentialThinking(runtime: string): 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 if (!existsSync(checker)) return; // Skip if checker doesn't exist
const result = spawnSync(checker, ['--check', '--runtime', runtime], { stdio: 'ignore' }); const result = spawnSync(checker, ['--check', '--runtime', runtime], { stdio: 'ignore' });
if (result.status !== 0) { 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 * Resolve a path under the framework tools directory. Prefers the version
* @mosaic/mosaic npm package (always matches the installed CLI version) * bundled in the @mosaic/mosaic npm package (always matches the installed
* over the deployed copy in ~/.config/mosaic/ (may be stale). * CLI version) over the deployed copy in ~/.config/mosaic/ (may be stale).
*/ */
function fwScript(name: string): string { function resolveTool(...segments: string[]): string {
try { try {
const require = createRequire(import.meta.url); const req = createRequire(import.meta.url);
const mosaicPkg = dirname(require.resolve('@mosaic/mosaic/package.json')); const mosaicPkg = dirname(req.resolve('@mosaic/mosaic/package.json'));
const bundled = join(mosaicPkg, 'framework', 'tools', '_scripts', name); const bundled = join(mosaicPkg, 'framework', 'tools', ...segments);
if (existsSync(bundled)) return bundled; if (existsSync(bundled)) return bundled;
} catch { } catch {
// Fall through to deployed copy // 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 { function toolScript(toolDir: string, name: string): string {
return join(MOSAIC_HOME, 'tools', toolDir, name); return resolveTool(toolDir, name);
} }
// ─── Coord (mission orchestrator) ─────────────────────────────────────────── // ─── Coord (mission orchestrator) ───────────────────────────────────────────

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mosaic/mosaic", "name": "@mosaic/mosaic",
"version": "0.0.7", "version": "0.0.8",
"description": "Mosaic agent framework — installation wizard and meta package", "description": "Mosaic agent framework — installation wizard and meta package",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",