cortad 0.3.0-rc.5 → 0.3.0-rc.6

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/local.mjs +15 -1
  2. package/package.json +1 -1
package/local.mjs CHANGED
@@ -682,8 +682,22 @@ async function installOnce(said) {
682
682
  return true;
683
683
  }
684
684
 
685
+ // The port their start command names, moved when something else already holds it: two apps on one
686
+ // laptop both said --port 8000, and the second attached to the first's server as its own.
687
+ async function freed(cmd) {
688
+ const m = /(--port[= ]|-p |\bPORT=)(\d{4,5})\b/.exec(cmd);
689
+ if (!m || !(await listenerOn(Number(m[2])))) return cmd;
690
+ for (let port = Number(m[2]) + 1; port < Number(m[2]) + 30; port++) {
691
+ if (await listenerOn(port)) continue;
692
+ say(`port ${m[2]} is taken on this machine, so your app starts on ${port}`);
693
+ return cmd.replace(m[0], `${m[1]}${port}`);
694
+ }
695
+ return cmd;
696
+ }
697
+
685
698
  async function start(waitMs) {
686
- const { cmd, lifted } = launched;
699
+ const { lifted } = launched;
700
+ const cmd = await freed(launched.cmd);
687
701
  child = spawn("/bin/sh", ["-c", cmd], { cwd: appDir, env: { ...process.env, ...lifted, ...(capture ? capture.env(process.env) : {}), FORCE_COLOR: "0", ...(pinned.bin ? { PATH: `${pinned.bin}:${process.env.PATH ?? ""}` } : {}) }, stdio: ["ignore", "pipe", "pipe"], detached: true });
688
702
  const mine = child;
689
703
  let seen = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortad",
3
- "version": "0.3.0-rc.5",
3
+ "version": "0.3.0-rc.6",
4
4
  "description": "Connects the AI app on your machine to Cortad for test conversations, and gives your coding agent the MCP and skill to run them. No dependencies.",
5
5
  "bin": {
6
6
  "cortad": "local.mjs"