declare-cc 1.0.7 → 1.0.8

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.
@@ -319,12 +319,14 @@ var require_milestones = __commonJS({
319
319
  function parseMarkdownTable(text) {
320
320
  const lines = text.trim().split("\n").filter((l) => l.trim().startsWith("|"));
321
321
  if (lines.length < 2) return [];
322
- const headers = lines[0].split("|").map((h) => h.trim()).filter(Boolean);
322
+ const raw = lines[0].split("|").map((h) => h.trim());
323
+ const headers = raw.slice(1, raw.length - 1);
323
324
  return lines.slice(2).map((line) => {
324
- const cells = line.split("|").map((c) => c.trim()).filter(Boolean);
325
+ const raw2 = line.split("|").map((c) => c.trim());
326
+ const cells = raw2.slice(1, raw2.length - 1);
325
327
  const row = {};
326
328
  headers.forEach((h, i) => {
327
- row[h] = cells[i] || "";
329
+ row[h] = (cells[i] || "").trim();
328
330
  });
329
331
  return row;
330
332
  });
@@ -1552,7 +1554,7 @@ var require_help = __commonJS({
1552
1554
  usage: "/declare:help"
1553
1555
  }
1554
1556
  ],
1555
- version: "1.0.7"
1557
+ version: "1.0.8"
1556
1558
  };
1557
1559
  }
1558
1560
  module2.exports = { runHelp: runHelp2 };
@@ -8267,6 +8269,33 @@ data: ${JSON.stringify({ reason: "archive", nodeId: id })}
8267
8269
  const projectNameMatch = content.match(/^# Future:\s*(.+)/m);
8268
8270
  const projectName = projectNameMatch ? projectNameMatch[1].trim() : "Project";
8269
8271
  fs.writeFileSync(futurePath, writeFutureFile(filtered, projectName), "utf-8");
8272
+ const msPath = path.join(planningDir, "MILESTONES.md");
8273
+ if (fs.existsSync(msPath)) {
8274
+ const msContent = fs.readFileSync(msPath, "utf-8");
8275
+ const { milestones } = parseMilestonesFile(msContent);
8276
+ const orphaned = [];
8277
+ const surviving = [];
8278
+ for (const m of milestones) {
8279
+ if (!m.realizes.includes(id)) {
8280
+ surviving.push(m);
8281
+ } else if (m.realizes.length === 1) {
8282
+ orphaned.push(m);
8283
+ } else {
8284
+ surviving.push({ ...m, realizes: m.realizes.filter((r) => r !== id) });
8285
+ }
8286
+ }
8287
+ for (const m of orphaned) {
8288
+ const folder = findMilestoneFolder(planningDir, m.id);
8289
+ if (folder) {
8290
+ fs.rmSync(folder, { recursive: true, force: true });
8291
+ }
8292
+ }
8293
+ if (orphaned.length > 0 || surviving.length !== milestones.length) {
8294
+ const msProjectMatch = msContent.match(/^# Milestones:\s*(.+)/m);
8295
+ const msProjectName = msProjectMatch ? msProjectMatch[1].trim() : "Project";
8296
+ fs.writeFileSync(msPath, writeMilestonesFile(surviving, msProjectName), "utf-8");
8297
+ }
8298
+ }
8270
8299
  } else if (prefix === "M") {
8271
8300
  const msPath = path.join(planningDir, "MILESTONES.md");
8272
8301
  const content = fs.readFileSync(msPath, "utf-8");
@@ -8724,7 +8753,7 @@ data: ${JSON.stringify({ reason: "delete", nodeId: id })}
8724
8753
  return;
8725
8754
  }
8726
8755
  if (urlPath === "/api/version") {
8727
- sendJson(res, 200, { version: true ? "1.0.7" : "dev" });
8756
+ sendJson(res, 200, { version: true ? "1.0.8" : "dev" });
8728
8757
  return;
8729
8758
  }
8730
8759
  if (urlPath === "/api/graph") {
@@ -8978,8 +9007,8 @@ var require_open = __commonJS({
8978
9007
  var fs = require("fs");
8979
9008
  var path = require("path");
8980
9009
  var http = require("http");
8981
- var { spawn } = require("child_process");
8982
9010
  var { runInit: runInit2 } = require_init();
9011
+ var { startServer } = require_server();
8983
9012
  function checkServer(port) {
8984
9013
  return new Promise((resolve) => {
8985
9014
  const req = http.get(`http://localhost:${port}/api/graph`, (res) => {
@@ -8993,18 +9022,6 @@ var require_open = __commonJS({
8993
9022
  });
8994
9023
  });
8995
9024
  }
8996
- async function waitForPortFile(portFile, maxAttempts = 30, intervalMs = 200) {
8997
- for (let i = 0; i < maxAttempts; i++) {
8998
- try {
8999
- const content = fs.readFileSync(portFile, "utf8").trim();
9000
- const port = parseInt(content, 10);
9001
- if (!isNaN(port) && port > 0) return port;
9002
- } catch (_) {
9003
- }
9004
- await new Promise((r) => setTimeout(r, intervalMs));
9005
- }
9006
- return null;
9007
- }
9008
9025
  async function runOpen2(cwd, args) {
9009
9026
  const planningDir = path.join(cwd, ".planning");
9010
9027
  if (!fs.existsSync(planningDir)) {
@@ -9029,19 +9046,13 @@ var require_open = __commonJS({
9029
9046
  }
9030
9047
  }
9031
9048
  }
9032
- const bundlePath = path.resolve(__dirname, "declare-tools.cjs");
9033
- const child = spawn(process.execPath, [bundlePath, "serve"], {
9034
- cwd,
9035
- detached: true,
9036
- stdio: "ignore"
9049
+ const { server, url } = await startServer(cwd);
9050
+ console.log(`Dashboard: ${url}`);
9051
+ const shutdown = () => server.close(() => process.exit(0));
9052
+ process.on("SIGINT", shutdown);
9053
+ process.on("SIGTERM", shutdown);
9054
+ await new Promise(() => {
9037
9055
  });
9038
- child.unref();
9039
- const port = await waitForPortFile(portFile);
9040
- if (!port) {
9041
- console.error("[declare] Server failed to start (no port file after 6s)");
9042
- process.exit(1);
9043
- }
9044
- console.log(`Dashboard: http://localhost:${port}`);
9045
9056
  }
9046
9057
  module2.exports = { runOpen: runOpen2 };
9047
9058
  }