mddd-cli 4.2.4 → 4.4.0

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.
@@ -17,7 +17,7 @@ stateDiagram-v2
17
17
 
18
18
  state RenderTopology {
19
19
  [*] --> CheckCode: Analyze current code structure and dependencies
20
- CheckCode --> EvaluatedCodeIsClean: Map exact architecture as-is (v1.0.0 - stable)
20
+ CheckCode --> EvaluatedCodeIsClean: Map exact architecture as coese (v1.0.0 - stable)
21
21
  CheckCode --> EvaluatedCodeIsChaotic: Draw BOTH current chaotic logic AND ideal target refactored graph (v1.0.0 - draft)
22
22
  }
23
23
 
@@ -1,6 +1,6 @@
1
- # {{Feature Title}} Specification
1
+ **SPEC_VERSION:** v1.0.0draft|stable
2
2
 
3
- **SPEC_VERSION:** v1.0.0draft
3
+ # {{Feature Title}} Specification
4
4
 
5
5
  > ⚠️ **This is a freshly generated MDDD spec template.**
6
6
  > Replace every `{{placeholder}}`, remove this banner, and refine the diagram + matrix
@@ -12,11 +12,6 @@
12
12
 
13
13
  Describe **what** this spec governs and **why** it exists.
14
14
 
15
- - **Domain:** `{{domain_name}}`
16
- - **Feature / Module:** `{{feature_name}}`
17
- - **Scope (in):** {{what is covered}}
18
- - **Scope (out):** {{what is explicitly NOT covered}}
19
- - **Owners:** {{team_or_person}}
20
15
  - **Related specs:** {{parent_domain_spec, sibling_features}}
21
16
 
22
17
  ---
package/bin/cli.js CHANGED
@@ -17,7 +17,7 @@ const program = new Command();
17
17
  program
18
18
  .name('md')
19
19
  .description('Manager for co-located specifications for Mermaid Diagram Driven Development (MDDD)')
20
- .version('4.2.4');
20
+ .version('4.4.0');
21
21
 
22
22
  // ==========================================
23
23
  // COMMAND: md init
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mddd-cli",
3
- "version": "4.2.4",
3
+ "version": "4.4.0",
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",
@@ -10,7 +10,8 @@
10
10
  "files": [
11
11
  "src",
12
12
  "system_prompt.md",
13
- ".agents/skills"
13
+ ".agents/skills",
14
+ ".agents/templates"
14
15
  ],
15
16
  "engines": {
16
17
  "node": ">=18.0.0"
@@ -26,18 +26,25 @@ function readSystemPrompt() {
26
26
  export async function execute(initService) {
27
27
  const systemPrompt = readSystemPrompt();
28
28
 
29
- // 1. Descobre o caminho absoluto real da pasta oculta interna do pacote da CLI
30
- // Subindo de: src/commands/ -> src/ -> raiz do pacote CLI -> .agents/skills
29
+ // 1. Resolve o caminho absoluto da raiz do pacote CLI
31
30
  const currentFile = fileURLToPath(import.meta.url);
32
- const cliSkillsSourceDir = path.resolve(path.dirname(currentFile), '..', '..', '.agents', 'skills');
31
+ const cliRootDir = path.resolve(path.dirname(currentFile), '..', '..');
32
+
33
+ // 2. Caminhos de origem dentro do pacote da CLI
34
+ const cliSkillsSourceDir = path.join(cliRootDir, '.agents', 'skills');
35
+ const cliSpecTemplatePath = path.join(cliRootDir, '.agents', 'templates', 'spec-template.md');
33
36
 
34
37
  await initService.createSystemPrompt(systemPrompt);
35
-
36
- // 2. Passa o caminho da pasta oculta de origem para o serviço clonar recursivamente
38
+
39
+ // 3. Passa o caminho da pasta oculta de origem para o serviço clonar recursivamente
37
40
  await initService.createSkills(cliSkillsSourceDir, (msg) => console.log(msg));
38
-
41
+
42
+ // 4. Cria o workflow do GitHub
39
43
  await initService.createGitHubWorkflow(GITHUB_WORKFLOW_CONTENT, (msg) => console.log(msg));
40
44
 
41
- console.log(pc.green('\n🚀 Universal [system_prompt.md] and SKILLS generated successfully in the project root!'));
45
+ // 5. Copia o spec template para o projeto
46
+ await initService.createSpecTemplate(cliSpecTemplatePath, (msg) => console.log(msg));
47
+
48
+ console.log(pc.green('\n🚀 Universal [system_prompt.md], SKILLS, and spec template generated successfully in the project root!'));
42
49
  console.log(pc.green('Run the "md init" command whenever you update the MDDD-CLI NPM package.'));
43
50
  }
@@ -74,4 +74,25 @@ export class InitService {
74
74
 
75
75
  return workflowFile;
76
76
  }
77
- }
77
+
78
+ /**
79
+ * Copies the spec template file from the CLI package to the project's .agents/templates/ directory.
80
+ * @param {string} sourceTemplatePath - Absolute path to the CLI source spec-template.md
81
+ * @param {(message: string) => void} logger
82
+ * @returns {Promise<void>}
83
+ */
84
+ async createSpecTemplate(sourceTemplatePath, logger) {
85
+ const templatesDir = path.join('.agents', 'templates');
86
+ const targetFile = path.join(templatesDir, 'spec-template.md');
87
+
88
+ if (!fs.existsSync(sourceTemplatePath)) {
89
+ throw new Error(`Source spec template not found at: ${sourceTemplatePath}`);
90
+ }
91
+
92
+ this.#fs.ensureDir(templatesDir);
93
+
94
+ const content = fs.readFileSync(sourceTemplatePath, 'utf-8');
95
+ await this.#fs.writeFile(targetFile, content);
96
+ logger(`✅ Spec template copied: ${targetFile}`);
97
+ }
98
+ }
@@ -1,6 +1,6 @@
1
1
  # InitService — Specification
2
2
 
3
- **SPEC_VERSION: v1.1.0 — stable**
3
+ **SPEC_VERSION: v1.2.0 — stable**
4
4
 
5
5
  ## Overview
6
6
 
@@ -13,24 +13,27 @@ Co-located with `src/services/InitService.js`.
13
13
  ## Behavioral Flow (Mermaid)
14
14
 
15
15
  ```mermaid
16
- %% @spec-version v1.1.0
16
+ %% @spec-version v1.2.0
17
17
  stateDiagram-v2
18
18
  [*] --> createSystemPrompt: initService.createSystemPrompt(promptContent)
19
19
  createSystemPrompt --> writeFile: this.#fs.writeFile('system_prompt.md', content)
20
- writeFile --> createSkills: initService.createSkills(skills, logger)
20
+ writeFile --> createSkills: initService.createSkills(sourceSkillsDir, logger)
21
21
 
22
- createSkills --> iterateSkills: for [skillName, content] of Object.entries(skills)
23
- iterateSkills --> ensureSkillFolder: this.#fs.ensureDir(skillFolder)
24
- ensureSkillFolder --> writeSkillFile: this.#fs.writeFile(skillFile, content)
25
- writeSkillFile --> consoleLog: logger( `✅ Skill encapsulated ${skillFile}`)
26
- consoleLog --> iterateSkills: next entry
27
- iterateSkills --> returnCreated: return created[]
28
- returnCreated --> createGitHubWorkflow: initService.createGitHubWorkflow(workflowYaml, logger)
22
+ createSkills --> ensureAgentsDir: this.#fs.ensureDir('.agents')
23
+ ensureAgentsDir --> ensureTargetSkillsDir: this.#fs.ensureDir('.agents/skills')
24
+ ensureTargetSkillsDir --> cpSyncSkills: fs.cpSync(source, target, recursive)
25
+ cpSyncSkills --> logSkills: logger per copied skill
26
+ logSkills --> createGitHubWorkflow: initService.createGitHubWorkflow(workflowYaml, logger)
29
27
 
30
28
  createGitHubWorkflow --> ensureWorkflowDir: this.#fs.ensureDir('.github/workflows')
31
29
  ensureWorkflowDir --> writeWorkflowFile: this.#fs.writeFile('.github/workflows/mddd-preview.yml', content)
32
- writeWorkflowFile --> logWorkflow: logger(`✅ GitHub workflow created ${workflowPath}`)
33
- logWorkflow --> [*]
30
+ writeWorkflowFile --> logWorkflow: logger(`✅ GitHub workflow created`)
31
+ logWorkflow --> createSpecTemplate: initService.createSpecTemplate(sourceTemplatePath, logger)
32
+
33
+ createSpecTemplate --> ensureTemplatesDir: this.#fs.ensureDir('.agents/templates')
34
+ ensureTemplatesDir --> writeTemplateFile: this.#fs.writeFile('.agents/templates/spec-template.md', content)
35
+ writeTemplateFile --> logTemplate: logger(`✅ Spec template copied`)
36
+ logTemplate --> [*]
34
37
  ```
35
38
 
36
39
  ---
@@ -40,13 +43,14 @@ stateDiagram-v2
40
43
  | Step | Method | I/O | Conditional Branch? | Error Handling | FS Side Effect |
41
44
  | :--- | :--- | :--- | :---: | :--- | :--- |
42
45
  | 1 | `createSystemPrompt(promptContent)` | Input: `string`<br>Output: `Promise<void>` | ❌ No | Delegated to `#fs.writeFile` | ✅ Writes `system_prompt.md` |
43
- | 2 | `createSkills(skills, logger)` | Input: `Record<string,string>` + logger fn<br>Output: `Promise<string[]>` | No (iteration only) | Delegated to `#fs` methods | ✅ Creates `.agents/`, `.agents/skills/`, `skillName/SKILL.md` per entry |
46
+ | 2 | `createSkills(sourceSkillsDir, logger)` | Input: `string` (source dir) + logger fn<br>Output: `Promise<void>` | Checks `fs.existsSync(sourceSkillsDir)` | Throws `Error` if source dir not found | ✅ Creates `.agents/`, `.agents/skills/`, copies all skill folders recursively |
44
47
  | 3 | `createGitHubWorkflow(workflowYaml, logger)` | Input: `string` + logger fn<br>Output: `Promise<string>` | ❌ No | Delegated to `#fs` methods | ✅ Creates `.github/workflows/mddd-preview.yml` |
45
- | 4 | `this.#fs.ensureDir(agentsDir)` | Path: `'.agents'` | Internal in FS: conditional mkdir | Delegated | ✅ Dir creation |
46
- | 5 | `this.#fs.ensureDir(skillsDir)` | Path: `'.agents/skills'` | ✅ Internal in FS: conditional mkdir | Delegated | ✅ Dir creation |
47
- | 6 | `this.#fs.ensureDir(skillFolder)` | Path: per skill | ✅ Internal in FS: conditional mkdir | Delegated | ✅ Dir creation |
48
+ | 4 | `createSpecTemplate(sourceTemplatePath, logger)` | Input: `string` (source path) + logger fn<br>Output: `Promise<void>` | ✅ Checks `fs.existsSync(sourceTemplatePath)` | Throws `Error` if source file not found | ✅ Creates `.agents/templates/`, writes `spec-template.md` |
49
+ | 5 | `this.#fs.ensureDir(agentsDir)` | Path: `'.agents'` | ✅ Internal in FS: conditional mkdir | Delegated | ✅ Dir creation |
50
+ | 6 | `this.#fs.ensureDir(skillsDir)` | Path: `'.agents/skills'` | ✅ Internal in FS: conditional mkdir | Delegated | ✅ Dir creation |
48
51
  | 7 | `this.#fs.ensureDir(workflowsDir)` | Path: `'.github/workflows'` | ✅ Internal in FS: conditional mkdir | Delegated | ✅ Dir creation |
49
- | 8 | `logger()` | stdout message | No | N/A | None |
52
+ | 8 | `this.#fs.ensureDir(templatesDir)` | Path: `'.agents/templates'` | Internal in FS: conditional mkdir | Delegated | Dir creation |
53
+ | 9 | `logger(…)` | stdout message | ❌ No | N/A | ❌ None |
50
54
 
51
55
  ---
52
56
 
@@ -75,5 +79,6 @@ stateDiagram-v2
75
79
  | :--- | :--- | :---: | :--- |
76
80
  | 2026-05-28 | Cline (md-audit) | v1.0.0 | **Spec created by md-audit.** Reverse-engineered from `src/services/InitService.js` (52 lines). Code classified as **Clean / Service with DI**. All orchestration steps documented with primitive factor analysis. No modifications to production code. |
77
81
  | 2026-05-28 | Cline (md-edit) | v1.1.0 | **New method `createGitHubWorkflow`.** Added to support `md init` creating `.github/workflows/mddd-preview.yml`. Updated behavioral flow diagram with new states. Updated Decision Matrix with steps 3, 7, 8. SPEC_VERSION bumped from v1.0.0 to v1.1.0 (minor — new method). Status promoted from **draft** to **stable** — implementation and tests verified. |
82
+ | 2026-06-04 | Cline (md-edit) | v1.2.0 | **New method `createSpecTemplate`.** Added to support `md init` copying `.agents/templates/spec-template.md` from the CLI package to the project. Reads the template file content via `fs.readFileSync`, ensures `.agents/templates/` dir exists, then writes `spec-template.md` via `#fs.writeFile`. Updated behavioral flow diagram with new states (`createSpecTemplate → ensureTemplatesDir → writeTemplateFile → logTemplate`). Updated Decision Matrix with steps 4, 8. SPEC_VERSION bumped from v1.1.0 to v1.2.0 (minor — new method). |
78
83
 
79
84
  </details>
package/system_prompt.md CHANGED
@@ -3,7 +3,9 @@
3
3
  You are a Mermaid Diagram processing system. Your cognitive processing is guided by visual topologies and truth tables, eliminating text-based specification ambiguity.
4
4
  Consume the mermaid-diagrams skill to learn how to produce it.
5
5
 
6
- Spec template path: node_modules/seu-pacote/src/templates/spec-template.md
6
+ Spec template path: .agents/templates/spec-template.md
7
+
8
+ Mark the analysis as Coese or Chaotic
7
9
 
8
10
  ```mermaid
9
11
  stateDiagram-v2