fix: installer copies default framework files (AGENTS.md) to mosaicHome #363
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/cli",
|
"name": "@mosaic/cli",
|
||||||
"version": "0.0.8",
|
"version": "0.0.9",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mosaic/mosaic",
|
"name": "@mosaic/mosaic",
|
||||||
"version": "0.0.8",
|
"version": "0.0.9",
|
||||||
"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",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { readFileSync, existsSync } from 'node:fs';
|
import { readFileSync, existsSync, readdirSync, statSync, copyFileSync } from 'node:fs';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
import type { ConfigService } from './config-service.js';
|
import type { ConfigService } from './config-service.js';
|
||||||
import type { SoulConfig, UserConfig, ToolsConfig, InstallAction } from '../types.js';
|
import type { SoulConfig, UserConfig, ToolsConfig, InstallAction } from '../types.js';
|
||||||
@@ -140,6 +140,23 @@ export class FileConfigAdapter implements ConfigService {
|
|||||||
preserve: preservePaths,
|
preserve: preservePaths,
|
||||||
excludeGit: true,
|
excludeGit: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Copy default root-level .md files (AGENTS.md, STANDARDS.md, etc.)
|
||||||
|
// from framework/defaults/ into mosaicHome root if they don't exist yet.
|
||||||
|
// These are framework contracts — only written on first install, never
|
||||||
|
// overwritten (user may have customized them).
|
||||||
|
const defaultsDir = join(this.sourceDir, 'defaults');
|
||||||
|
if (existsSync(defaultsDir)) {
|
||||||
|
for (const entry of readdirSync(defaultsDir)) {
|
||||||
|
const dest = join(this.mosaicHome, entry);
|
||||||
|
if (!existsSync(dest)) {
|
||||||
|
const src = join(defaultsDir, entry);
|
||||||
|
if (statSync(src).isFile()) {
|
||||||
|
copyFileSync(src, dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { resolve } from 'node:path';
|
import { existsSync } from 'node:fs';
|
||||||
|
import { dirname, resolve } from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
@@ -49,7 +50,14 @@ program
|
|||||||
.action(async (opts: Record<string, string | boolean | undefined>) => {
|
.action(async (opts: Record<string, string | boolean | undefined>) => {
|
||||||
try {
|
try {
|
||||||
const mosaicHome = (opts['mosaicHome'] as string) ?? DEFAULT_MOSAIC_HOME;
|
const mosaicHome = (opts['mosaicHome'] as string) ?? DEFAULT_MOSAIC_HOME;
|
||||||
const sourceDir = (opts['sourceDir'] as string | undefined) ?? mosaicHome;
|
// Default source to the framework/ dir bundled in this npm package.
|
||||||
|
// This ensures syncFramework copies AGENTS.md, STANDARDS.md, guides/, etc.
|
||||||
|
// Falls back to mosaicHome if the bundled dir doesn't exist (shouldn't happen).
|
||||||
|
const pkgRoot = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const bundledFramework = resolve(pkgRoot, '..', 'framework');
|
||||||
|
const sourceDir =
|
||||||
|
(opts['sourceDir'] as string | undefined) ??
|
||||||
|
(existsSync(bundledFramework) ? bundledFramework : mosaicHome);
|
||||||
|
|
||||||
const prompter = opts['nonInteractive'] ? new HeadlessPrompter() : new ClackPrompter();
|
const prompter = opts['nonInteractive'] ? new HeadlessPrompter() : new ClackPrompter();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user