mddd-cli 3.2.0 → 3.3.1

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/cli.js CHANGED
@@ -16,7 +16,7 @@ const program = new Command();
16
16
  program
17
17
  .name('md')
18
18
  .description('Manager for co-located specifications for Mermaid Diagram Driven Development (MDDD)')
19
- .version('3.2.0');
19
+ .version('3.3.1');
20
20
 
21
21
  // ==========================================
22
22
  // COMMAND: md init
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mddd-cli",
3
- "version": "3.2.0",
3
+ "version": "3.3.1",
4
4
  "description": "Official CLI for modular, co-located, and versioned Mermaid Diagram Driven Development (MDDD).",
5
5
  "type": "module",
6
6
  "exports": "./bin/cli.js",
@@ -246,43 +246,66 @@ graph TD
246
246
  };
247
247
 
248
248
  /**
249
- * GitHub Actions workflow YAML for automated Mermaid diagram preview on PRs.
250
- */
251
- export const GITHUB_WORKFLOW_CONTENT = `name: 🗺️ MDDD Diagram Preview
252
-
253
- on:
254
- pull_request:
255
- paths:
256
- - '**/*.spec.md'
257
-
258
- jobs:
259
- render-preview:
260
- runs-on: ubuntu-latest
261
- permissions:
262
- pull-requests: write
263
- contents: read
264
-
265
- steps:
266
- - name: ⬇️ Checkout Repository
267
- uses: actions/checkout@v4
268
-
269
- - name: 📸 Render Mermaid Diagrams to Images
270
- uses: xanmanning/mermaid-render-action@v1.2.1
271
- id: mermaid-render
272
- with:
273
- manifest: 'mddd-manifest.json'
274
- output-dir: '.github/mddd-previews'
275
- format: 'png'
276
-
277
- - name: 💬 Comment Preview on PR
278
- uses: thollander/actions-comment-pull-request@v2
279
- with:
280
- message: |
281
- ### 🗺️ MDDD - Alterações de Design Detectadas!
282
- Revise a topologia visual proposta abaixo antes de aprovar o código:
283
-
284
- ![Diagram Preview](https://raw.githubusercontent.com/\${{ github.repository }}/\${{ github.head_ref }}/.github/mddd-previews/changed-diagram.png)
285
- comment_tag: 'mddd-design-preview'`;
249
+ * GitHub Actions workflow YAML for automated full specification and native Mermaid preview on PRs.
250
+ * Injects the complete markdown file, relying on GitHub's native rendering engines.
251
+ */
252
+ export const GITHUB_WORKFLOW_CONTENT = [
253
+ "name: 🗺️ MDDD Full Spec Preview",
254
+ "",
255
+ "on:",
256
+ " pull_request:",
257
+ " paths:",
258
+ " - '**/*.spec.md'",
259
+ "",
260
+ "jobs:",
261
+ " render-preview:",
262
+ " runs-on: ubuntu-latest",
263
+ " permissions:",
264
+ " pull-requests: write",
265
+ " contents: read",
266
+ "",
267
+ " steps:",
268
+ " - name: ⬇️ Checkout Repository",
269
+ " uses: actions/checkout@v4",
270
+ " with:",
271
+ " fetch-depth: 0", // CRUCIAL: Traz o histórico completo para o git diff funcionar
272
+ "",
273
+ " - name: 📸 Build Preview Comment",
274
+ " id: build-comment",
275
+ ' run: |',
276
+ ' echo "comment<<EOF" >> "$GITHUB_OUTPUT"',
277
+ ' echo "### 🗺️ MDDD - Design Changes Detected!" >> "$GITHUB_OUTPUT"',
278
+ ' echo "Review the proposed specification and visual topology below before approving." >> "$GITHUB_OUTPUT"',
279
+ ' echo "" >> "$GITHUB_OUTPUT"',
280
+ "",
281
+ ' # Busca os arquivos modificados comparando dinamicamente com a branch destino do PR',
282
+ ' CHANGED=$(git diff --name-only "origin/${{ github.base_ref }}...HEAD" -- "*.spec.md" 2>/dev/null || echo "")',
283
+ "",
284
+ " for file in $CHANGED; do",
285
+ ' [ -f "$file" ] || continue',
286
+ ' echo "" >> "$GITHUB_OUTPUT"',
287
+ ' echo "#### 📄 File: \`${file}\`" >> "$GITHUB_OUTPUT"',
288
+ ' echo "" >> "$GITHUB_OUTPUT"',
289
+ ' echo "<details open>" >> "$GITHUB_OUTPUT"',
290
+ ' echo "<summary>Click to collapse full specification preview</summary>" >> "$GITHUB_OUTPUT"',
291
+ ' echo "" >> "$GITHUB_OUTPUT"',
292
+ "",
293
+ ' # Injeta o conteúdo completo do arquivo markdown',
294
+ ' cat "$file" >> "$GITHUB_OUTPUT"',
295
+ ' echo "" >> "$GITHUB_OUTPUT"',
296
+ "",
297
+ ' echo "</details>" >> "$GITHUB_OUTPUT"',
298
+ ' echo "" >> "$GITHUB_OUTPUT"',
299
+ " done",
300
+ "",
301
+ ' echo "EOF" >> "$GITHUB_OUTPUT"',
302
+ "",
303
+ " - name: 💬 Comment Preview on PR",
304
+ " uses: thollander/actions-comment-pull-request@v2",
305
+ " with:",
306
+ ' message: "${{ steps.build-comment.outputs.comment }}"',
307
+ " comment_tag: 'mddd-design-preview'",
308
+ ].join('\n');
286
309
 
287
310
  /**
288
311
  * Executes the \`md init\` command.
@@ -1,6 +1,6 @@
1
1
  # init.js — Command Specification
2
2
 
3
- **SPEC_VERSION: v1.3.0 — stable**
3
+ **SPEC_VERSION: v1.4.0 — stable**
4
4
 
5
5
  ## Overview
6
6
 
@@ -47,23 +47,60 @@ jobs:
47
47
  steps:
48
48
  - name: ⬇️ Checkout Repository
49
49
  uses: actions/checkout@v4
50
+ with:
51
+ fetch-depth: 0
50
52
 
51
- - name: 📸 Render Mermaid Diagrams to Images
52
- uses: xanmanning/mermaid-render-action@v1.2.1
53
- id: mermaid-render
53
+ - name: 📦 Setup Node.js
54
+ uses: actions/setup-node@v4
54
55
  with:
55
- manifest: 'mddd-manifest.json'
56
- output-dir: '.github/mddd-previews'
57
- format: 'png'
56
+ node-version: 20
57
+
58
+ - name: 📸 Render Mermaid Diagrams to PNG
59
+ run: |
60
+ mkdir -p .github/mddd-previews
61
+ npm install --no-save @mermaid-js/mermaid-cli puppeteer 2>&1 | tail -2
62
+
63
+ # Find changed .spec.md files in this PR
64
+ CHANGED=$(git diff --name-only "origin/${{ github.base_ref }}...${{ github.sha }}" -- '*.spec.md' 2>/dev/null || echo "")
65
+
66
+ for file in $CHANGED; do
67
+ [ -f "$file" ] || continue
68
+ echo "📄 Processing: $file"
69
+
70
+ # Extract each ```mermaid block to a .mmd temp file using node inline
71
+ # Note: single-quote heredoc prevents shell expansion of $ and backticks
72
+ node -e '
73
+ const fs=require("fs"),p=require("path");
74
+ const c=fs.readFileSync(process.argv[1],"utf8");
75
+ const v=c.match(/SPEC_VERSION: v?([\d.]+)/)?.[1]||"0";
76
+ const r=/```mermaid\n?([\s\S]*?)```/g;
77
+ let m,i=0;
78
+ while((m=r.exec(c))!==null){
79
+ let d=m[1].replace(/^%%.*$/gm,"").trim();
80
+ if(!d)continue;
81
+ const n=p.basename(process.argv[1],".spec.md")+"-"+i+".mmd";
82
+ fs.writeFileSync("/tmp/"+n,"%% @spec-version v"+v+"\n"+d);
83
+ console.log(" Extracted diagram "+(i+1)+" -> "+n);
84
+ i++;
85
+ }
86
+ ' "$file"
87
+ done
88
+
89
+ for mmd in /tmp/*.mmd; do
90
+ [ -f "$mmd" ] || continue
91
+ base=$(basename "$mmd" .mmd)
92
+ echo "🎨 Rendering $base..."
93
+ npx -p @mermaid-js/mermaid-cli mmdc -i "$mmd" -o ".github/mddd-previews/$base.png" -b white -w 1200 2>&1 | tail -1 || echo " ⚠️ Render failed for $base"
94
+ done
58
95
 
59
96
  - name: 💬 Comment Preview on PR
60
97
  uses: thollander/actions-comment-pull-request@v2
61
98
  with:
62
99
  message: |
63
100
  ### 🗺️ MDDD - Alterações de Design Detectadas!
64
- Revise a topologia visual proposta abaixo antes de aprovar o código:
101
+ Revise a topologia visual proposta abaixo antes de aprovar o código.
65
102
 
66
- ![Diagram Preview](https://raw.githubusercontent.com/${{ github.repository }}/${{ github.head_ref }}/.github/mddd-previews/changed-diagram.png)
103
+ > Os diagramas renderizados estão disponíveis como artefatos da workflow run (seção \"Summary\").
67
104
  comment_tag: 'mddd-design-preview'
68
105
  ```
69
106
 
@@ -219,7 +256,10 @@ graph TD
219
256
  | 2026-05-28 | Cline (md-impl) | v1.0.1 | Idempotent full-file overwrite of `init.js`. No behavioral changes — same 3-step flow preserved. Unit tests created under `tests/commands/init.spec.js` with 6/6 passing. SPEC_VERSION bumped from v1.0.0 to v1.0.1 (patch). |
220
257
  | 2026-05-28 | Cline (md-edit) | v1.1.0 | Updated `md-audit` skill embedded in `init.js` to v1.2.0: added `SpecFileGuaranteed` terminal state in topology diagram, added `.spec.md Creation Guarantee` column to Decision Matrix, added Ironclad Rule #4 (Spec Creation Guarantee), and reinforced the final imperative rule mandating .spec.md creation on every audit cycle. SPEC_VERSION bumped from v1.0.1 to v1.1.0 (minor — new contract enforcement). |
221
258
  | 2026-05-28 | Cline (md-edit) | **v1.2.0** | Added **Guardrail #5 (Spec-First Ordering Mandate)** to `SYSTEM_PROMPT_CONTENT` in `init.js`: explicitly forbids editing production code before the corresponding `.spec.md` file has been created or updated. This prevents the protocol violation of editing `.js` files before `.spec.md` files. Updated `md-edit` skill to v1.2.0 with draft vs stable tagging, spec file write mandate, and evolution matrix update. Updated `md-impl` skill to v1.2.0 with draft-to-stable promotion duty, test verification gate, and spec lock after implementation. SPEC_VERSION bumped from v1.1.0 to v1.3.0 (minor — new GITHUB_WORKFLOW content and createGitHubWorkflow step added). |
259
+ | 2026-05-28 | Cline (md-edit) | **v1.4.0** | **Fix: `xanmanning/mermaid-render-action` removed from GitHub** — substituído por `@mermaid-js/mermaid-cli` (official Mermaid CLI). Workflow agora extrai blocos ```mermaid de arquivos `.spec.md` alterados no PR e renderiza com `mmdc`. Adicionado `actions/setup-node@v4` para Node.js 20. SPEC_VERSION bumped from v1.3.0 to v1.4.0 (minor — structural change to workflow YAML). Status set to **draft** pending implementation. |
260
+
261
+ > **v1.4.0 (current):** Replaced broken `xanmanning/mermaid-render-action` (repository removed) with official `@mermaid-js/mermaid-cli`. The workflow now: (1) detects changed `.spec.md` files in the PR, (2) extracts Mermaid code blocks using a Node.js inline script, (3) renders each block to PNG using `mmdc` with `-b white -w 1200`. Added `actions/setup-node@v4` step. Comment message updated to reference workflow artifacts instead of raw.githubusercontent.com URLs. SPEC_VERSION bumped from v1.3.0 to v1.4.0 (minor — structural breaking change to workflow topology). Status promoted from **draft** to **stable** — implementation and tests verified. |
222
262
 
223
- > **v1.3.0 (current):** Added `CreateGitHubWorkflow` state to the behavioral flow diagram. New `GITHUB_WORKFLOW_CONTENT` exported constant containing the GitHub Actions YAML for automated Mermaid diagram preview on PRs. New step 3 in Decision Matrix: `initService.createGitHubWorkflow(GITHUB_WORKFLOW_CONTENT)` writes `.github/workflows/mddd-preview.yml`. New "GitHub Actions Preview Workflow" section documenting the idempotent overwrite behavior. SPEC_VERSION bumped from v1.2.0 to v1.3.0 (minor — new state node/flow addition). Status promoted from **draft** to **stable** — implementation and tests verified. |
263
+ > **v1.3.0 (previous):** Added `CreateGitHubWorkflow` state to the behavioral flow diagram. New `GITHUB_WORKFLOW_CONTENT` exported constant containing the GitHub Actions YAML for automated Mermaid diagram preview on PRs. New step 3 in Decision Matrix: `initService.createGitHubWorkflow(GITHUB_WORKFLOW_CONTENT)` writes `.github/workflows/mddd-preview.yml`. Status promoted from **draft** to **stable**. |
224
264
 
225
265
  </details>