declare-cc 0.4.0 → 0.4.5

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/bin/install.js CHANGED
@@ -1465,8 +1465,9 @@ function install(isGlobal, runtime = 'claude') {
1465
1465
  console.log(` ${green}✓${reset} Installed workflows/`);
1466
1466
  }
1467
1467
 
1468
- // Copy dashboard static files (src/server/public/) → .claude/server/public/
1469
- const publicSrc = path.join(src, 'src', 'server', 'public');
1468
+ // Copy dashboard static files (dist/public/) → .claude/server/public/
1469
+ // dist/public/ ships in the npm package (built by esbuild.config.js)
1470
+ const publicSrc = path.join(src, 'dist', 'public');
1470
1471
  if (fs.existsSync(publicSrc)) {
1471
1472
  const publicDest = path.join(targetDir, 'server', 'public');
1472
1473
  fs.mkdirSync(publicDest, { recursive: true });
@@ -95,11 +95,16 @@ After all milestones processed:
95
95
  node dist/declare-tools.cjs load-graph
96
96
  ```
97
97
 
98
- 2. Show summary: milestones processed, plans created, total actions derived.
99
- 3. Suggest the next step clearly:
98
+ 2. Start the dashboard if not already running:
99
+ ```bash
100
+ curl -sf http://localhost:3847/api/graph -o /dev/null || (node dist/declare-tools.cjs serve --port 3847 > /tmp/declare-dashboard.log 2>&1 & sleep 1 && open http://localhost:3847 2>/dev/null || true)
101
+ ```
102
+
103
+ 3. Show summary: milestones processed, plans created, total actions derived.
104
+ 4. Suggest the next step clearly:
100
105
 
101
106
  ```
102
- Actions defined. Next: create executable plans.
107
+ Actions and edges are live in the dashboard → http://localhost:3847
103
108
 
104
109
  /declare:plan M-XX — research + planner + checker loop → EXEC-PLAN files
105
110
  /declare:execute M-XX — once plans exist, execute with wave scheduling
@@ -44,9 +44,29 @@ node dist/declare-tools.cjs add-declaration --title "Short Title" --statement "F
44
44
 
45
45
  Parse the JSON output to confirm the declaration was created and note its assigned ID (e.g., D-01).
46
46
 
47
- **Step 5: Show summary and suggest next step.**
47
+ **Step 5: Launch dashboard and show summary.**
48
48
 
49
49
  After all declarations are captured:
50
50
 
51
- 1. List all declarations with their IDs and statements.
52
- 2. Suggest: "Run `/declare:milestones` to work backward from these declarations to milestones and actions."
51
+ 1. Start the dashboard server (if not already running):
52
+
53
+ ```bash
54
+ node dist/declare-tools.cjs serve --port 3847 > /tmp/declare-dashboard.log 2>&1 &
55
+ sleep 1 && curl -sf http://localhost:3847/api/graph -o /dev/null && echo "RUNNING" || echo "FAILED"
56
+ ```
57
+
58
+ If RUNNING, open it:
59
+ ```bash
60
+ open http://localhost:3847 2>/dev/null || true
61
+ ```
62
+
63
+ 2. List all declarations with their IDs and statements.
64
+
65
+ 3. Suggest next step:
66
+
67
+ ```
68
+ Your declarations are live in the dashboard → http://localhost:3847
69
+ The graph updates every 5 seconds as you add milestones and actions.
70
+
71
+ Run /declare:milestones to work backward from these declarations.
72
+ ```
@@ -77,5 +77,10 @@ After all declarations processed:
77
77
  node dist/declare-tools.cjs load-graph
78
78
  ```
79
79
 
80
- 2. Show summary: declarations processed, milestones derived.
81
- 3. Suggest: "Run `/declare:actions` to derive action plans for each milestone."
80
+ 2. Start the dashboard if not already running (dashboard updates live when files change):
81
+ ```bash
82
+ curl -sf http://localhost:3847/api/graph -o /dev/null || (node dist/declare-tools.cjs serve --port 3847 > /tmp/declare-dashboard.log 2>&1 & sleep 1 && open http://localhost:3847 2>/dev/null || true)
83
+ ```
84
+
85
+ 3. Show summary: declarations processed, milestones derived.
86
+ 4. Suggest: "Milestones are live in the dashboard → http://localhost:3847 — Run `/declare:actions` to derive action plans."
@@ -181,10 +181,14 @@ Repeat until VERIFICATION PASSED or revision count reaches 3.
181
181
 
182
182
  **Step 9: Commit EXEC-PLANs.**
183
183
 
184
+ Pass each file as a separate `--files` argument (not space-separated in one argument):
185
+
184
186
  ```bash
185
- node dist/declare-tools.cjs commit "docs(${MILESTONE}): create exec-plans for milestone actions" --files [space-separated list of EXEC-PLAN file paths]
187
+ node dist/declare-tools.cjs commit "docs(${MILESTONE}): create exec-plans for milestone actions" --files [path/to/A-01-EXEC-PLAN.md] --files [path/to/A-02-EXEC-PLAN.md]
186
188
  ```
187
189
 
190
+ If the commit reports `nothing_to_commit`, the planner already committed the files — that is fine, continue.
191
+
188
192
  **Step 10: Present results.**
189
193
 
190
194
  Display final summary:
@@ -211,11 +215,59 @@ Display final summary:
211
215
 
212
216
  ### Next Steps
213
217
 
214
- Execute: `/declare:execute M-XX`
215
-
216
- /clear first — fresh context window
217
218
  ```
218
219
 
220
+ After displaying the summary, reload the graph and check for milestones that still have no EXEC-PLANs (hasPlan is false OR actions array for that milestone has no EXEC-PLAN files):
221
+
222
+ - If **other milestones still need planning**, list them and suggest planning those next:
223
+ ```
224
+ Remaining milestones to plan:
225
+ /declare:plan M-02 — [title]
226
+ /declare:plan M-03 — [title]
227
+
228
+ Plan all milestones before executing. Run /declare:execute only when all are planned.
229
+ ```
230
+
231
+ - If **this was the last milestone to plan**, compute dependency waves before spawning anything — do not blindly parallelize all milestones.
232
+
233
+ **Step A: Compute milestone dependency waves.**
234
+
235
+ Load the graph, then read each milestone's PLAN.md. For each action, check its `dependsOn` field. If an action in M-02 lists `dependsOn: ["A-01"]` and A-01 belongs to M-01, then M-02 depends on M-01.
236
+
237
+ Build a milestone-level dependency graph from these cross-milestone action references. Run a topological sort (Kahn's algorithm) to group milestones into waves:
238
+ - Wave 1: milestones with no dependencies on other pending milestones
239
+ - Wave 2: milestones whose dependencies are all in wave 1
240
+ - …and so on
241
+
242
+ If no cross-milestone `dependsOn` edges exist, all milestones go into wave 1 (full parallelism). Show the wave plan before executing:
243
+
244
+ ```
245
+ ## Milestone Execution Waves
246
+
247
+ Wave 1 (parallel): M-01 [title], M-03 [title]
248
+ Wave 2 (after wave 1): M-02 [title]
249
+ ```
250
+
251
+ **Step B: Execute wave by wave using the Task tool.**
252
+
253
+ For each wave, spawn one Task agent per milestone **in the same response** so they execute in parallel:
254
+
255
+ Subagent type: `gsd-executor`
256
+ Prompt per milestone:
257
+ ```
258
+ Execute milestone [M-XX] "[title]" for the Declare project.
259
+ Working directory: [absolute path to cwd]
260
+ Run: /declare:execute [M-XX]
261
+ EXEC-PLANs are in: [absolute path to milestone folder]
262
+ ```
263
+
264
+ Wait for the entire wave to complete before spawning the next wave.
265
+
266
+ After all waves finish, propagate statuses:
267
+ ```bash
268
+ node dist/declare-tools.cjs sync-status
269
+ ```
270
+
219
271
  If max revisions reached with issues remaining, display blocker list prominently:
220
272
 
221
273
  ```
@@ -1329,7 +1329,7 @@ var require_help = __commonJS({
1329
1329
  usage: "/declare:help"
1330
1330
  }
1331
1331
  ],
1332
- version: "0.3.9"
1332
+ version: "0.4.4"
1333
1333
  };
1334
1334
  }
1335
1335
  module2.exports = { runHelp: runHelp2 };
@@ -1537,7 +1537,8 @@ var require_add_milestones_batch = __commonJS({
1537
1537
  dag.addNode(m.id, "milestone", m.title, m.status || "PENDING");
1538
1538
  }
1539
1539
  for (let i = 0; i < inputs.length; i++) {
1540
- const realizes = inputs[i].realizes.split(",").map((s) => s.trim()).filter(Boolean);
1540
+ const realizesRaw = inputs[i].realizes;
1541
+ const realizes = Array.isArray(realizesRaw) ? realizesRaw.map((s) => String(s).trim()).filter(Boolean) : String(realizesRaw).split(",").map((s) => s.trim()).filter(Boolean);
1541
1542
  for (const declId of realizes) {
1542
1543
  if (!dag.getNode(declId)) {
1543
1544
  return { error: `Item ${i}: declaration not found: ${declId}` };
@@ -3676,7 +3677,9 @@ var require_server = __commonJS({
3676
3677
  };
3677
3678
  function getPublicDir(cwd) {
3678
3679
  const installed = path.join(cwd, ".claude", "server", "public");
3679
- if (require("fs").existsSync(installed)) return installed;
3680
+ if (fs.existsSync(installed)) return installed;
3681
+ const bundled = path.join(__dirname, "public");
3682
+ if (fs.existsSync(bundled)) return bundled;
3680
3683
  return path.join(cwd, "src", "server", "public");
3681
3684
  }
3682
3685
  function sendJson(res, statusCode, data) {
@@ -3759,6 +3762,31 @@ var require_server = __commonJS({
3759
3762
  sendJson(res, 500, { error: String(err) });
3760
3763
  }
3761
3764
  }
3765
+ var sseClients = /* @__PURE__ */ new Set();
3766
+ function broadcastChange() {
3767
+ for (const client of sseClients) {
3768
+ try {
3769
+ client.write("event: change\ndata: {}\n\n");
3770
+ } catch (_) {
3771
+ sseClients.delete(client);
3772
+ }
3773
+ }
3774
+ }
3775
+ function watchPlanning(cwd) {
3776
+ const planningDir = path.join(cwd, ".planning");
3777
+ if (!fs.existsSync(planningDir)) return;
3778
+ let debounceTimer = null;
3779
+ try {
3780
+ fs.watch(planningDir, { recursive: true }, () => {
3781
+ if (debounceTimer) clearTimeout(debounceTimer);
3782
+ debounceTimer = setTimeout(() => {
3783
+ broadcastChange();
3784
+ debounceTimer = null;
3785
+ }, 200);
3786
+ });
3787
+ } catch (_) {
3788
+ }
3789
+ }
3762
3790
  function route(req, res, cwd) {
3763
3791
  const method = req.method || "GET";
3764
3792
  const url = req.url || "/";
@@ -3776,6 +3804,18 @@ var require_server = __commonJS({
3776
3804
  sendJson(res, 405, { error: "Method Not Allowed" });
3777
3805
  return;
3778
3806
  }
3807
+ if (urlPath === "/events") {
3808
+ res.writeHead(200, {
3809
+ "Content-Type": "text/event-stream",
3810
+ "Cache-Control": "no-cache",
3811
+ "Connection": "keep-alive",
3812
+ "Access-Control-Allow-Origin": "*"
3813
+ });
3814
+ res.write("retry: 3000\n\n");
3815
+ sseClients.add(res);
3816
+ req.on("close", () => sseClients.delete(res));
3817
+ return;
3818
+ }
3779
3819
  if (urlPath === "/api/graph") {
3780
3820
  handleGraph(res, cwd);
3781
3821
  return;
@@ -3817,6 +3857,7 @@ var require_server = __commonJS({
3817
3857
  const resolvedPort = port || parseInt(process.env.PORT || "", 10) || 3847;
3818
3858
  const server = createServer(cwd, resolvedPort);
3819
3859
  server.listen(resolvedPort, "127.0.0.1", () => {
3860
+ watchPlanning(cwd);
3820
3861
  });
3821
3862
  const url = `http://localhost:${resolvedPort}`;
3822
3863
  return { server, port: resolvedPort, url };