mddd-cli 1.0.5 → 1.0.7

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 (3) hide show
  1. package/bin/cli.js +25 -19
  2. package/package.json +1 -1
  3. package/readme.md +7 -1
package/bin/cli.js CHANGED
@@ -4,6 +4,9 @@ import { Command } from 'commander';
4
4
  import fs from 'fs';
5
5
  import path from 'path';
6
6
  import pc from 'picocolors';
7
+ import { createRequire } from 'module';
8
+ const require = createRequire(import.meta.url);
9
+ const pkg = require('./package.json');
7
10
 
8
11
  const program = new Command();
9
12
 
@@ -31,7 +34,7 @@ function findClosestMacro(currentDir) {
31
34
  program
32
35
  .name('md')
33
36
  .description('Manager for co-located specifications for Mermaid Diagram Driven Development (MDDD)')
34
- .version('3.0.0');
37
+ .version(pkg.version);
35
38
 
36
39
  // ==========================================
37
40
  // COMMAND: md init
@@ -53,8 +56,8 @@ You must strictly follow the modular feature specification architecture before c
53
56
 
54
57
  ## 1. Tree Structure and Co-location
55
58
  Visual specifications live universally in Markdown format (.md) exactly at the same level as the code they describe:
56
- - Macro modules/domains have a \`[name].spec.md\` file containing the global diagram (stateDiagram-v2 syntax).
57
- - Micro screens or sub-rule flows have a \`[name].spec.md\` file containing the interface flow (graph LR syntax) + Decision Tables.
59
+ - Macro modules/domains have a \`[name].spec.md\` file containing the global diagram.
60
+ - Micro screens or sub-rule flows have a \`[name].spec.md\` file containing the interface flow + Decision Tables.
58
61
 
59
62
  ## 2. Connection Rule Between Existing Flows
60
63
  Whenever you create or change a functionality using an explicit parent file:
@@ -68,6 +71,7 @@ Whenever you create or change a functionality using an explicit parent file:
68
71
  - Whenever you change a Mermaid diagram or a decision table using the \`/md-edit\` command, you MUST increment the file's semantic version in the header before saving:
69
72
  - Change the Patch (\`v1.0.0\` -> \`v1.0.1\`) for syntax fixes or minor adjustments to node text.
70
73
  - Change the Minor (\`v1.0.0\` -> \`v1.1.0\`) for new states, new transitions, or new columns in the decision matrix.
74
+ - Change the Major (\`v1.0.0\` -> \`v2.0.0\`) for structural changes that affect the overall flow or significant refactoring of the business rules.
71
75
  - Never remove the version tag. It is the guarantee that the code implementation is aligned with the correct design.
72
76
 
73
77
  ** SPECIFICATION WRITING GUIDELINE: **
@@ -82,22 +86,20 @@ If the file is the Feature Contract: Focus only on:
82
86
 
83
87
  ** RULES: **
84
88
  1. When generating diagrams from code, always remove function name parentheses. Keep the diagram clean and avoid rendering errors.
85
- 2. ASCII Art or drawings are PROHIBITED. Use only Mermaid diagrams for visual representation.
86
- 2. Every diagram must be encapsulated in markdown code blocks with the language 'mermaid'.
87
- 3. For architecture flows or business logic, use exclusively 'graph TD' or 'graph LR'.
88
- 4. For (finite) state machines, use 'stateDiagram-v2'.
89
- 5. Name the nodes, use specific shapes ([...], ([...]), { ... }) to indicate intent (Action, Start/End, Decision).
90
- 6. ALWAYS WORK ON THE .SPEC.MD FILES. If they don't exist, create them. They are the single source of truth. Never make changes directly in the code without reflecting them in the diagrams.
89
+ 2. Use only Mermaid diagrams for visual representation using the 'mermaid' language.
90
+ 4. Use the diagram type that best fits the specification.
91
+ 5. ALWAYS WORK ON THE {fileName}.spec.md files (RESPECT the path for colocalization). If they don't exist, create them. They are the single source of truth. Never make changes directly in the code without reflecting them in the diagrams.
92
+ 6. For audits, if the code is modular, cohesive, and clean: map the current flow in Mermaid, fill in the decision tables, and set the initial stable version as v1.0.0. If the code is chaotic, coupled, or complex: point out the architectural problems, suggest a REFACTORING proposal separating responsibilities, and assemble the Mermaid of how the flow SHOULD BE post-refactoring. Save this spec file with a draft status.
91
93
  `;
92
94
 
93
95
  fs.writeFileSync('system_prompt.md', promptContent);
94
96
 
95
97
  // 3. Skill Definitions
96
98
  const skills = {
97
- 'md-new': "Drawing Mode. You must run the terminal command \`md new [path_to_new_feature]\` (and include \`-p [path]\` if there is a parent). Then, assemble the Mermaid and tables within the generated file and pause to await visual approval.",
98
- 'md-edit': "Editing Mode. Open the specified file, apply the change to the Mermaid or tables while keeping the syntax 100% valid, and increment the header \`\`.",
99
- 'md-audit': "Drastic Legacy Audit Mode. Analyze the existing code file from the perspective of visual readability (MDDD):\n1. If the code is modular, cohesive, and clean: Run the terminal command \`md new [file_directory]\`. Then, map the current flow in Mermaid, fill in the decision tables, and set the initial stable version as \`\`.\n2. If the code is chaotic, coupled, or complex: YOU ARE PROHIBITED from creating a stable diagram. Instead, point out the architectural problems, suggest a REFACTORING proposal separating responsibilities, and assemble the Mermaid of how the flow SHOULD BE post-refactoring. Save this spec file with a draft status: \`\`.",
100
- 'md-impl': "Implementation Mode. Read the \`.spec.md\` file from the path as your only Source of Truth and write the productive code and equivalent tests."
99
+ 'md-new': "Drawing Mode. You must run the terminal command \`md new [path_to_audited_file]\` (and include \`-p [path]\` if there is a parent). Then, assemble the Mermaid and tables within the generated file and pause to await visual approval.",
100
+ 'md-edit': "Editing Mode. Open the .spec file, apply the required changes to it and increment the header.",
101
+ 'md-audit': "Drastic Legacy Audit Mode. Analyze the existing code file from the perspective of visual readability (MDDD):\n1. Run the terminal command \`md new [file_directory]\`. If the code is modular, cohesive, and clean: map the current flow in Mermaid, fill in the decision tables, and set the initial stable version as v1.0.0. If the code is chaotic, coupled, or complex: point out the architectural problems, suggest a REFACTORING proposal separating responsibilities, and assemble the Mermaid of how the flow SHOULD BE post-refactoring. Save this spec file with a draft status.",
102
+ 'md-impl': "Implementation Mode. Read the \`.spec.md\` file as your only Source of Truth and write the productive code and equivalent tests."
101
103
  };
102
104
 
103
105
  Object.keys(skills).forEach(skillName => {
@@ -110,15 +112,19 @@ If the file is the Feature Contract: Focus only on:
110
112
  // 2. Create SKILL.md file inside: .agents/skills/md-new/SKILL.md
111
113
  const skillFile = path.join(skillFolder, 'SKILL.md');
112
114
 
113
- if (!fs.existsSync(skillFile)) {
114
- // Adding an automatic title for better organization
115
- const content = `# ${skillName.toUpperCase()}\n\n${skills[skillName]}`;
116
- fs.writeFileSync(skillFile, content);
117
- console.log(pc.green(`✅ Encapsulated skill: ${skillFile}`));
115
+ if (fs.existsSync(skillFile)) {
116
+ fs.unlinkSync(skillFile);
118
117
  }
118
+
119
+ // Adding an automatic title for better organization
120
+ const content = `# ${skillName.toUpperCase()}\n\n${skills[skillName]}`;
121
+ fs.writeFileSync(skillFile, content);
122
+ console.log(pc.green(`✅ Encapsulated skill: ${skillFile}`));
123
+
119
124
  });
120
125
 
121
- console.log(pc.green('✅ Universal [system_prompt.md] file generated at the project root!'));
126
+ console.log(pc.green('✅ Universal [system_prompt.md] file generated at the project root! You should rename it according to your AI agent naming convention.'));
127
+ console.log(pc.green('Run the md init command everytime the npm package is updated.'));
122
128
  });
123
129
 
124
130
  // ==========================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mddd-cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Official CLI for modular, co-located, and versioned Mermaid Diagram Driven Development (MDDD).",
5
5
  "main": "bin/cli.js",
6
6
  "type": "module",
package/readme.md CHANGED
@@ -39,6 +39,9 @@ No **Mermaid Diagram Driven Development**, invertemos o ciclo tradicional de des
39
39
  ### Exemplo diagrama de inicialização de um app Flutter
40
40
  <img width="1316" height="444" alt="image" src="https://github.com/user-attachments/assets/5cacc283-e517-4468-a8cd-d67442a75bf2" />
41
41
 
42
+ ### Exemplo de matriz de decisão
43
+ <img width="1237" height="702" alt="image" src="https://github.com/user-attachments/assets/e8ffc227-9b2a-44d5-ad66-116dffedc8ba" />
44
+
42
45
  Para visualizar os diagramas Mermaid diretamente no seu editor durante o fluxo MDDD, você pode utilizar extensões que renderizam blocos ````mermaid```` em arquivos Markdown:
43
46
 
44
47
  ### VS Code
@@ -199,9 +202,12 @@ In **Mermaid Diagram Driven Development**, we invert the traditional AI chat-dri
199
202
 
200
203
  To preview Mermaid diagrams directly in your editor during the MDDD workflow, you can use extensions that render ````mermaid```` blocks in Markdown files:
201
204
 
202
- ### Exemplo diagrama de inicialização de um app Flutter
205
+ ### Flutter App Initialization Diagram Example
203
206
  <img width="1316" height="444" alt="image" src="https://github.com/user-attachments/assets/5cacc283-e517-4468-a8cd-d67442a75bf2" />
204
207
 
208
+ ### Decision Matrix Example
209
+ <img width="1237" height="702" alt="image" src="https://github.com/user-attachments/assets/e8ffc227-9b2a-44d5-ad66-116dffedc8ba" />
210
+
205
211
  ### VS Code
206
212
  - **Markdown Preview Mermaid Support** — Adds Mermaid diagram support to the native Markdown preview.
207
213
  - **Mermaid Editor** — Visual editor with side-by-side preview and export.