fix: fwScript prefers npm-bundled scripts over stale deployed copies (#361)
Some checks failed
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/push/publish Pipeline failed

This commit was merged in pull request #361.
This commit is contained in:
2026-04-03 02:21:58 +00:00
parent 9e597ecf87
commit db8023bdbb
3 changed files with 16 additions and 2 deletions

View File

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

View File

@@ -7,6 +7,7 @@
import { execFileSync, execSync, spawnSync } from 'node:child_process';
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, rmSync } from 'node:fs';
import { createRequire } from 'node:module';
import { homedir } from 'node:os';
import { join, dirname } from 'node:path';
import type { Command } from 'commander';
@@ -491,7 +492,20 @@ 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).
*/
function fwScript(name: 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);
if (existsSync(bundled)) return bundled;
} catch {
// Fall through to deployed copy
}
return join(MOSAIC_HOME, 'tools', '_scripts', name);
}

View File

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