@nikelyh/metamorph 2.0.7 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +41 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1837,25 +1837,34 @@ var managePackagesProcessor = {
1837
1837
  }
1838
1838
  const packageJsonPath = path4.join(shadowDir, "package.json");
1839
1839
  if (fs5.existsSync(packageJsonPath)) {
1840
- const { execSync: execSync2 } = await import("child_process");
1841
- const execOpts = { cwd: shadowDir, stdio: "inherit" };
1840
+ const { spawn } = await import("child_process");
1841
+ const runCommandAsync = (cmd, args) => {
1842
+ return new Promise((resolve3, reject) => {
1843
+ const proc = spawn(cmd, args, { cwd: shadowDir, stdio: "inherit", shell: true });
1844
+ proc.on("close", (code) => {
1845
+ if (code === 0) resolve3();
1846
+ else reject(new Error(`Command ${cmd} ${args.join(" ")} failed with code ${code}`));
1847
+ });
1848
+ proc.on("error", reject);
1849
+ });
1850
+ };
1842
1851
  try {
1843
1852
  let toRemove = [];
1844
1853
  if (catalogEntry.dependenciesToRemove) toRemove.push(...catalogEntry.dependenciesToRemove);
1845
1854
  if (catalogEntry.devDependenciesToRemove) toRemove.push(...catalogEntry.devDependenciesToRemove);
1846
1855
  if (toRemove.length > 0) {
1847
1856
  console.log(`[PackageManagerAgent] Uninstalling: ${toRemove.join(" ")}`);
1848
- execSync2(`npm uninstall ${toRemove.join(" ")}`, execOpts);
1857
+ await runCommandAsync("npm", ["uninstall", ...toRemove]);
1849
1858
  }
1850
1859
  if (catalogEntry.dependenciesToAdd && Object.keys(catalogEntry.dependenciesToAdd).length > 0) {
1851
1860
  const deps = Object.entries(catalogEntry.dependenciesToAdd).map(([pkg, ver]) => `${pkg}@${ver}`);
1852
1861
  console.log(`[PackageManagerAgent] Installing dependencies: ${deps.join(" ")}`);
1853
- execSync2(`npm install ${deps.join(" ")}`, execOpts);
1862
+ await runCommandAsync("npm", ["install", ...deps]);
1854
1863
  }
1855
1864
  if (catalogEntry.devDependenciesToAdd && Object.keys(catalogEntry.devDependenciesToAdd).length > 0) {
1856
1865
  const devDeps = Object.entries(catalogEntry.devDependenciesToAdd).map(([pkg, ver]) => `${pkg}@${ver}`);
1857
1866
  console.log(`[PackageManagerAgent] Installing devDependencies: ${devDeps.join(" ")}`);
1858
- execSync2(`npm install -D ${devDeps.join(" ")}`, execOpts);
1867
+ await runCommandAsync("npm", ["install", "-D", ...devDeps]);
1859
1868
  }
1860
1869
  console.log(`[PackageManagerAgent] Successfully updated dependencies via npm.`);
1861
1870
  } catch (err) {
@@ -2200,8 +2209,19 @@ program.command("run [path]").description("Run a migration on the specified dire
2200
2209
  console.log(chalk.gray(`Target: ${targetPath} | ${from} -> ${to}
2201
2210
  `));
2202
2211
  if (!process.env.OPENAI_API_KEY && !process.env.ANTHROPIC_API_KEY) {
2203
- console.log(chalk.yellow(`\u26A0\uFE0F WARNING: No LLM API key detected.
2212
+ console.log(chalk.red(`
2213
+ \u274C ERROR: No LLM API key detected.`));
2214
+ console.log(chalk.yellow(`Metamorph requires an API key (OPENAI_API_KEY or ANTHROPIC_API_KEY) to power the AI Worker agents.`));
2215
+ console.log(chalk.yellow(`Execution has been blocked to prevent agents from crashing during the migration.
2204
2216
  `));
2217
+ console.log(chalk.white(`To fix this, you can either:`));
2218
+ console.log(chalk.gray(` 1. Create a `) + chalk.cyan(`.env`) + chalk.gray(` file in your current directory with:`));
2219
+ console.log(chalk.green(` OPENAI_API_KEY=sk-...`));
2220
+ console.log(chalk.gray(` 2. Or set it directly in your terminal:`));
2221
+ console.log(chalk.gray(` Linux/macOS: `) + chalk.cyan(`export OPENAI_API_KEY="sk-..."`));
2222
+ console.log(chalk.gray(` Windows: `) + chalk.cyan(`$env:OPENAI_API_KEY="sk-..."
2223
+ `));
2224
+ process.exit(1);
2205
2225
  }
2206
2226
  const spinner = ora("Initializing...").start();
2207
2227
  try {
@@ -2305,6 +2325,21 @@ program.command("ui").description("Start the Metamorph Dashboard API server").op
2305
2325
  const getPort = (await import("get-port")).default;
2306
2326
  const open = (await import("open")).default;
2307
2327
  const port = await getPort({ port: desiredPort });
2328
+ if (!process.env.OPENAI_API_KEY && !process.env.ANTHROPIC_API_KEY) {
2329
+ console.log(chalk.red(`
2330
+ \u274C ERROR: No LLM API key detected.`));
2331
+ console.log(chalk.yellow(`Metamorph requires an API key (OPENAI_API_KEY or ANTHROPIC_API_KEY) to power the AI Worker agents.`));
2332
+ console.log(chalk.yellow(`Execution has been blocked to prevent agents from crashing during the migration.
2333
+ `));
2334
+ console.log(chalk.white(`To fix this, you can either:`));
2335
+ console.log(chalk.gray(` 1. Create a `) + chalk.cyan(`.env`) + chalk.gray(` file in your current directory with:`));
2336
+ console.log(chalk.green(` OPENAI_API_KEY=sk-...`));
2337
+ console.log(chalk.gray(` 2. Or set it directly in your terminal:`));
2338
+ console.log(chalk.gray(` Linux/macOS: `) + chalk.cyan(`export OPENAI_API_KEY="sk-..."`));
2339
+ console.log(chalk.gray(` Windows: `) + chalk.cyan(`$env:OPENAI_API_KEY="sk-..."
2340
+ `));
2341
+ process.exit(1);
2342
+ }
2308
2343
  const store = new SQLiteStateStore(".metamorph");
2309
2344
  const tools = [
2310
2345
  createReadFileTool(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nikelyh/metamorph",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "metamorph": "./bin/metamorph.js"