feat: integrate framework files into monorepo under packages/mosaic/framework/
Moves all Mosaic framework runtime files from the separate bootstrap repo into the monorepo as canonical source. The @mosaic/mosaic npm package now ships the complete framework — bin scripts, runtime configs, tools, and templates — enabling standalone installation via npm install. Structure: packages/mosaic/framework/ ├── bin/ 28 CLI scripts (mosaic, mosaic-doctor, mosaic-sync-skills, etc.) ├── runtime/ Runtime adapters (claude, codex, opencode, pi, mcp) ├── tools/ Shell tooling (git, prdy, orchestrator, quality, etc.) ├── templates/ Agent and repo templates ├── defaults/ Default identity files (AGENTS.md, STANDARDS.md, SOUL.md, etc.) ├── install.sh Legacy bash installer └── remote-install.sh One-liner remote installer Key files with Pi support and recent fixes: - bin/mosaic: launch_pi() with skills-local loop - bin/mosaic-doctor: --fix auto-wiring for all 4 harnesses - bin/mosaic-sync-skills: Pi as 4th link target, symlink-aware find - bin/mosaic-link-runtime-assets: Pi settings.json patching - bin/mosaic-migrate-local-skills: Pi skill roots, symlink find - runtime/pi/RUNTIME.md + mosaic-extension.ts Package ships 251 framework files in the npm tarball (278KB compressed).
This commit is contained in:
76
packages/mosaic/framework/tools/excalidraw/loader.mjs
Normal file
76
packages/mosaic/framework/tools/excalidraw/loader.mjs
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* Custom ESM loader to fix missing .js extensions in @excalidraw/excalidraw deps.
|
||||
*
|
||||
* Problems patched:
|
||||
* 1. excalidraw imports 'roughjs/bin/rough' (and other roughjs/* paths) without .js
|
||||
* 2. roughjs/* files import sibling modules as './canvas' (relative, no .js)
|
||||
* 3. JSON files need { type: 'json' } import attribute in Node.js v22+
|
||||
*
|
||||
* Usage: node --loader ./loader.mjs server.mjs [args...]
|
||||
*/
|
||||
|
||||
import { fileURLToPath, pathToFileURL } from 'url';
|
||||
import { dirname, resolve as pathResolve } from 'path';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
// Modules that have incompatible ESM format — redirect to local stubs
|
||||
const STUBS = {
|
||||
'@excalidraw/laser-pointer': pathToFileURL(pathResolve(__dirname, 'stubs/laser-pointer.mjs')).href,
|
||||
};
|
||||
|
||||
export async function resolve(specifier, context, nextResolve) {
|
||||
// 0. Module stubs (incompatible ESM format packages)
|
||||
if (STUBS[specifier]) {
|
||||
return { url: STUBS[specifier], shortCircuit: true };
|
||||
}
|
||||
|
||||
// 1. Bare roughjs/* specifiers without .js extension
|
||||
if (/^roughjs\/bin\/[a-z-]+$/.test(specifier)) {
|
||||
return nextResolve(`${specifier}.js`, context);
|
||||
}
|
||||
|
||||
// 2. Relative imports without extension (e.g. './canvas' from roughjs/bin/rough.js)
|
||||
// These come in as relative paths that resolve to extensionless file URLs.
|
||||
if (specifier.startsWith('./') || specifier.startsWith('../')) {
|
||||
// Try resolving first; if it fails with a missing-extension error, add .js
|
||||
try {
|
||||
return await nextResolve(specifier, context);
|
||||
} catch (err) {
|
||||
if (err.code === 'ERR_MODULE_NOT_FOUND') {
|
||||
// Try appending .js
|
||||
try {
|
||||
return await nextResolve(`${specifier}.js`, context);
|
||||
} catch {
|
||||
// Fall through to original error
|
||||
}
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. JSON imports need type: 'json' attribute
|
||||
if (specifier.endsWith('.json')) {
|
||||
const resolved = await nextResolve(specifier, context);
|
||||
if (!resolved.importAttributes?.type) {
|
||||
return {
|
||||
...resolved,
|
||||
importAttributes: { ...resolved.importAttributes, type: 'json' },
|
||||
};
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
|
||||
return nextResolve(specifier, context);
|
||||
}
|
||||
|
||||
export async function load(url, context, nextLoad) {
|
||||
// Ensure JSON files are loaded with json format
|
||||
if (url.endsWith('.json')) {
|
||||
return nextLoad(url, {
|
||||
...context,
|
||||
importAttributes: { ...context.importAttributes, type: 'json' },
|
||||
});
|
||||
}
|
||||
return nextLoad(url, context);
|
||||
}
|
||||
Reference in New Issue
Block a user