mddd-cli 1.0.5 → 1.0.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/bin/cli.js +24 -19
  2. package/package.json +1 -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,19 @@ 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.
91
92
  `;
92
93
 
93
94
  fs.writeFileSync('system_prompt.md', promptContent);
94
95
 
95
96
  // 3. Skill Definitions
96
97
  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."
98
+ '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.",
99
+ 'md-edit': "Editing Mode. Open the .spec file, apply the required changes to it and increment the header.",
100
+ '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.",
101
+ 'md-impl': "Implementation Mode. Read the \`.spec.md\` file as your only Source of Truth and write the productive code and equivalent tests."
101
102
  };
102
103
 
103
104
  Object.keys(skills).forEach(skillName => {
@@ -110,15 +111,19 @@ If the file is the Feature Contract: Focus only on:
110
111
  // 2. Create SKILL.md file inside: .agents/skills/md-new/SKILL.md
111
112
  const skillFile = path.join(skillFolder, 'SKILL.md');
112
113
 
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}`));
114
+ if (fs.existsSync(skillFile)) {
115
+ fs.unlinkSync(skillFile);
118
116
  }
117
+
118
+ // Adding an automatic title for better organization
119
+ const content = `# ${skillName.toUpperCase()}\n\n${skills[skillName]}`;
120
+ fs.writeFileSync(skillFile, content);
121
+ console.log(pc.green(`✅ Encapsulated skill: ${skillFile}`));
122
+
119
123
  });
120
124
 
121
- console.log(pc.green('✅ Universal [system_prompt.md] file generated at the project root!'));
125
+ 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.'));
126
+ console.log(pc.green('Run the md init command everytime the npm package is updated.'));
122
127
  });
123
128
 
124
129
  // ==========================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mddd-cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
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",