openmagic 0.28.5 → 0.29.0

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.
package/dist/cli.js CHANGED
@@ -1448,7 +1448,7 @@ async function handleLlmChat(params, onChunk, onDone, onError) {
1448
1448
  }
1449
1449
 
1450
1450
  // src/server.ts
1451
- var VERSION = "0.28.5";
1451
+ var VERSION = "0.29.0";
1452
1452
  var __dirname = dirname2(fileURLToPath(import.meta.url));
1453
1453
  function attachOpenMagic(httpServer, roots) {
1454
1454
  function handleRequest(req, res) {
@@ -1862,7 +1862,7 @@ async function detectDevServer() {
1862
1862
  if (scriptPorts.length > 0) {
1863
1863
  for (const port of scriptPorts) {
1864
1864
  if (await checkPort(port)) {
1865
- return { port, host: "localhost" };
1865
+ return { port, host: "localhost", fromScripts: true };
1866
1866
  }
1867
1867
  }
1868
1868
  return null;
@@ -1874,7 +1874,7 @@ async function detectDevServer() {
1874
1874
  const results = await Promise.all(checks);
1875
1875
  const foundPort = results.find((p) => p !== null);
1876
1876
  if (foundPort) {
1877
- return { port: foundPort, host: "127.0.0.1" };
1877
+ return { port: foundPort, host: "localhost", fromScripts: false };
1878
1878
  }
1879
1879
  return null;
1880
1880
  }
@@ -1902,7 +1902,7 @@ var FRAMEWORK_PATTERNS = [
1902
1902
  { match: /\brails\b/, framework: "Rails", defaultPort: 3e3 },
1903
1903
  { match: /\bphp\s+.*serve\b|artisan\s+serve/, framework: "PHP/Laravel", defaultPort: 8e3 }
1904
1904
  ];
1905
- var DEV_SCRIPT_NAMES = ["dev", "start", "serve", "develop", "dev:start", "start:dev"];
1905
+ var DEV_SCRIPT_NAMES = ["dev", "start", "serve", "develop", "dev:start", "start:dev", "server", "dev:server", "web", "frontend"];
1906
1906
  function detectDevScripts(cwd = process.cwd()) {
1907
1907
  const pkgPath = join4(cwd, "package.json");
1908
1908
  if (!existsSync4(pkgPath)) return [];
@@ -1990,7 +1990,7 @@ process.on("uncaughtException", (err) => {
1990
1990
  });
1991
1991
  var childProcesses = [];
1992
1992
  var lastDetectedPort = null;
1993
- var VERSION2 = "0.28.5";
1993
+ var VERSION2 = "0.29.0";
1994
1994
  function ask(question) {
1995
1995
  const rl = createInterface({ input: process.stdin, output: process.stdout });
1996
1996
  return new Promise((resolve3) => {
@@ -2128,9 +2128,23 @@ program.name("openmagic").description("AI-powered coding toolbar for any web app
2128
2128
  } else {
2129
2129
  console.log(chalk.dim(" Scanning for dev server..."));
2130
2130
  const detected = await detectDevServer();
2131
- if (detected) {
2131
+ if (detected && detected.fromScripts) {
2132
2132
  targetPort = detected.port;
2133
2133
  targetHost = detected.host;
2134
+ } else if (detected && !detected.fromScripts) {
2135
+ const answer = await ask(
2136
+ chalk.yellow(` Found a server on port ${detected.port}. Is this your project's dev server? `) + chalk.dim("(y/n) ")
2137
+ );
2138
+ if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes" || answer === "") {
2139
+ targetPort = detected.port;
2140
+ targetHost = detected.host;
2141
+ } else {
2142
+ console.log("");
2143
+ console.log(chalk.dim(" Start your dev server, then run:"));
2144
+ console.log(chalk.cyan(" npx openmagic --port <your-port>"));
2145
+ console.log("");
2146
+ process.exit(0);
2147
+ }
2134
2148
  } else {
2135
2149
  const started = await offerToStartDevServer();
2136
2150
  if (!started) {