mddd-cli 3.1.0 → 3.2.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.
- package/bin/cli.js +1 -1
- package/package.json +1 -1
- package/src/commands/init.js +46 -6
- package/src/commands/init.spec.md +56 -5
- package/src/services/InitService.js +19 -1
- package/src/services/InitService.spec.md +15 -7
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.
|
|
19
|
+
.version('3.2.0');
|
|
20
20
|
|
|
21
21
|
// ==========================================
|
|
22
22
|
// COMMAND: md init
|
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -45,12 +45,12 @@ graph TD
|
|
|
45
45
|
|
|
46
46
|
| User Context | Target Spec Header | Human Request Path | Diagram Change Impact | AI Core Rule / Mandate / Ironclad Clause |
|
|
47
47
|
| :---: | :---: | :---: | :---: | :--- |
|
|
48
|
-
| | | - | **MISSING** | - | - | Never remove, omit, or bypass the version tag from files. |
|
|
49
|
-
| | | Code Change Needed | **SIGNED** | Contradicts Matrix | - | 🛑 **HALT**: Refuse code generation. Demand \`md edit\` to align design first. |
|
|
50
|
-
| | | Feature Writing | - | Continuous Text Block | - | 📊 **STRUCTURE**: Convert text into tables of primitive factors (yes/no/rigid values). |
|
|
51
|
-
| | | Command Executed | \`SPEC_VERSION\` | - | Typo / Label Only | Increment Patch (\`X.Y.Z\` -> \`X.Y.Z+1\`) |
|
|
52
|
-
| | | Command Executed | \`SPEC_VERSION\` | - | New State / Arrow / Matrix Column | Increment Minor (\`X.Y.Z\` -> \`X.Y+1.0\`) |
|
|
53
|
-
| | | Command Executed | \`SPEC_VERSION\` | - | Structural Breaking / Flow Overhaul | Increment Major (\`X.Y.Z\` -> \`X+1.0.0\`) |
|
|
48
|
+
| | | | - | **MISSING** | - | - | Never remove, omit, or bypass the version tag from files. |
|
|
49
|
+
| | | | Code Change Needed | **SIGNED** | Contradicts Matrix | - | 🛑 **HALT**: Refuse code generation. Demand \`md edit\` to align design first. |
|
|
50
|
+
| | | | Feature Writing | - | Continuous Text Block | - | 📊 **STRUCTURE**: Convert text into tables of primitive factors (yes/no/rigid values). |
|
|
51
|
+
| | | | Command Executed | \`SPEC_VERSION\` | - | Typo / Label Only | Increment Patch (\`X.Y.Z\` -> \`X.Y.Z+1\`) |
|
|
52
|
+
| | | | Command Executed | \`SPEC_VERSION\` | - | New State / Arrow / Matrix Column | Increment Minor (\`X.Y.Z\` -> \`X.Y+1.0\`) |
|
|
53
|
+
| | | | Command Executed | \`SPEC_VERSION\` | - | Structural Breaking / Flow Overhaul | Increment Major (\`X.Y.Z\` -> \`X+1.0.0\`) |
|
|
54
54
|
|
|
55
55
|
## 4. Anti-Hallucination Guardrails
|
|
56
56
|
1. **No Spec, No Code:** You are strictly forbidden from writing a single line of production code or unit tests if the corresponding \`.spec.md\` file does not exist or does not contain a populated Decision Matrix.
|
|
@@ -245,6 +245,45 @@ graph TD
|
|
|
245
245
|
5. **Spec File Lock After Implementation:** The \`.spec.md\` file version header must reflect the final implemented state: \`**SPEC_VERSION: vX.Y.Z — stable**\`. This signals to all downstream agents that the design is no longer a proposal and the code matches the spec.`,
|
|
246
246
|
};
|
|
247
247
|
|
|
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
|
+

|
|
285
|
+
comment_tag: 'mddd-design-preview'`;
|
|
286
|
+
|
|
248
287
|
/**
|
|
249
288
|
* Executes the \`md init\` command.
|
|
250
289
|
* @param {import('../services/InitService.js').InitService} initService
|
|
@@ -253,6 +292,7 @@ graph TD
|
|
|
253
292
|
export async function execute(initService) {
|
|
254
293
|
await initService.createSystemPrompt(SYSTEM_PROMPT_CONTENT);
|
|
255
294
|
await initService.createSkills(SKILLS, (msg) => console.log(msg));
|
|
295
|
+
await initService.createGitHubWorkflow(GITHUB_WORKFLOW_CONTENT, (msg) => console.log(msg));
|
|
256
296
|
|
|
257
297
|
console.log(pc.green('\n🚀 Universal [system_prompt.md] and SKILLS generated successfully in the project root!'));
|
|
258
298
|
console.log(pc.green('Run the "md init" command whenever you update the MDDD-CLI NPM package.'));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# init.js — Command Specification
|
|
2
2
|
|
|
3
|
-
**SPEC_VERSION: v1.
|
|
3
|
+
**SPEC_VERSION: v1.3.0 — stable**
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
@@ -11,17 +11,64 @@ The `init.js` module implements the `md init` CLI command. It holds the canonica
|
|
|
11
11
|
## Behavioral Flow (Reverse Engineered)
|
|
12
12
|
|
|
13
13
|
```mermaid
|
|
14
|
-
%% @spec-version v1.
|
|
14
|
+
%% @spec-version v1.3.0
|
|
15
15
|
stateDiagram-v2
|
|
16
16
|
[*] --> ExecuteCommand: User runs "md init"
|
|
17
17
|
ExecuteCommand --> CreateSystemPrompt: initService.createSystemPrompt(content)
|
|
18
18
|
CreateSystemPrompt --> CreateSkills: initService.createSkills(skillMap, logger)
|
|
19
|
-
CreateSkills -->
|
|
19
|
+
CreateSkills --> CreateGitHubWorkflow: initService.createGitHubWorkflow(workflowYaml)
|
|
20
|
+
CreateGitHubWorkflow --> ReportSuccess: console.log(…) green messages
|
|
20
21
|
ReportSuccess --> [*]
|
|
21
22
|
```
|
|
22
23
|
|
|
23
24
|
---
|
|
24
25
|
|
|
26
|
+
## GitHub Actions Preview Workflow
|
|
27
|
+
|
|
28
|
+
A partir da v1.3.0, o `md init` também cria/atualiza um workflow do GitHub Actions em `.github/workflows/mddd-preview.yml`. Esse workflow gera previews visuais dos diagramas Mermaid alterados em pull requests que tocam arquivos `.spec.md`.
|
|
29
|
+
|
|
30
|
+
> **Idempotência garantida:** Se o arquivo `.github/workflows/mddd-preview.yml` já existir, ele será sobrescrito com o conteúdo canônico atual. Isso garante que todos os projetos inicializados com `md init` tenham a versão mais recente do workflow de preview.
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
name: 🗺️ MDDD Diagram Preview
|
|
34
|
+
|
|
35
|
+
on:
|
|
36
|
+
pull_request:
|
|
37
|
+
paths:
|
|
38
|
+
- '**/*.spec.md'
|
|
39
|
+
|
|
40
|
+
jobs:
|
|
41
|
+
render-preview:
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
permissions:
|
|
44
|
+
pull-requests: write
|
|
45
|
+
contents: read
|
|
46
|
+
|
|
47
|
+
steps:
|
|
48
|
+
- name: ⬇️ Checkout Repository
|
|
49
|
+
uses: actions/checkout@v4
|
|
50
|
+
|
|
51
|
+
- name: 📸 Render Mermaid Diagrams to Images
|
|
52
|
+
uses: xanmanning/mermaid-render-action@v1.2.1
|
|
53
|
+
id: mermaid-render
|
|
54
|
+
with:
|
|
55
|
+
manifest: 'mddd-manifest.json'
|
|
56
|
+
output-dir: '.github/mddd-previews'
|
|
57
|
+
format: 'png'
|
|
58
|
+
|
|
59
|
+
- name: 💬 Comment Preview on PR
|
|
60
|
+
uses: thollander/actions-comment-pull-request@v2
|
|
61
|
+
with:
|
|
62
|
+
message: |
|
|
63
|
+
### 🗺️ MDDD - Alterações de Design Detectadas!
|
|
64
|
+
Revise a topologia visual proposta abaixo antes de aprovar o código:
|
|
65
|
+
|
|
66
|
+

|
|
67
|
+
comment_tag: 'mddd-design-preview'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
25
72
|
## Embedded Skill Inventory
|
|
26
73
|
|
|
27
74
|
The `SKILLS` map in `init.js` contains four behavioral sub-specifications. The table below tracks their individual versions and key contract guarantees:
|
|
@@ -144,7 +191,8 @@ graph TD
|
|
|
144
191
|
| :--- | :--- | :--- | :---: | :--- |
|
|
145
192
|
| 1 | `initService.createSystemPrompt(SYSTEM_PROMPT_CONTENT)` | Writes `system_prompt.md` | ❌ No | Delegated to InitService |
|
|
146
193
|
| 2 | `initService.createSkills(SKILLS, logFn)` | Writes `SKILLS/*.md` files | ❌ No | Delegated to InitService |
|
|
147
|
-
| 3 | `
|
|
194
|
+
| 3 | `initService.createGitHubWorkflow(GITHUB_WORKFLOW_CONTENT)` | Writes `.github/workflows/mddd-preview.yml` | ❌ No | Delegated to InitService |
|
|
195
|
+
| 4 | `console.log(pc.green(…))` | stdout — success report | ❌ No | N/A |
|
|
148
196
|
|
|
149
197
|
> **Note:** The `SKILLS` map contains four embedded behavioral sub-specifications (`md-new`, `md-edit`, `md-audit`, `md-impl`), each with its own internal topology and decision logic. Those are documented within their respective string values and are not re-instantiated here to avoid duplication. For details on the `md-audit` v1.2.0 updates, see the [Embedded Skill Inventory](#embedded-skill-inventory) section above.
|
|
150
198
|
|
|
@@ -156,6 +204,7 @@ graph TD
|
|
|
156
204
|
| :--- | :--- | :--- |
|
|
157
205
|
| `SYSTEM_PROMPT_CONTENT` | `string` | Full MDDD protocol prompt text (now includes Guardrail #5: Spec-First Ordering Mandate) |
|
|
158
206
|
| `SKILLS` | `Record<string, string>` | Skill-name → SKILL.md content mapping |
|
|
207
|
+
| `GITHUB_WORKFLOW_CONTENT` | `string` | GitHub Actions workflow YAML for Mermaid diagram preview on PRs |
|
|
159
208
|
| `execute(initService)` | `async function` | Command entry point |
|
|
160
209
|
|
|
161
210
|
---
|
|
@@ -169,6 +218,8 @@ graph TD
|
|
|
169
218
|
| 2026-05-28 | Cline (md-audit) | v1.0.0 | Initial reverse-engineered spec from production code. Code classified as **Clean / Modular**. No modifications to `init.js`. |
|
|
170
219
|
| 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). |
|
|
171
220
|
| 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). |
|
|
172
|
-
| 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.
|
|
221
|
+
| 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). |
|
|
222
|
+
|
|
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. |
|
|
173
224
|
|
|
174
225
|
</details>
|
|
@@ -26,7 +26,8 @@ export class InitService {
|
|
|
26
26
|
/**
|
|
27
27
|
* Creates all skill folders and SKILL.md files.
|
|
28
28
|
* @param {Record<string, string>} skills - Map of skill name to skill content
|
|
29
|
-
* @
|
|
29
|
+
* @param {(message: string) => void} logger
|
|
30
|
+
* @returns {Promise<string[]>} Array of file paths created
|
|
30
31
|
*/
|
|
31
32
|
async createSkills(skills, logger) {
|
|
32
33
|
const agentsDir = '.agents';
|
|
@@ -49,4 +50,21 @@ export class InitService {
|
|
|
49
50
|
|
|
50
51
|
return created;
|
|
51
52
|
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Creates (or overwrites) the GitHub Actions workflow for Mermaid diagram preview on PRs.
|
|
56
|
+
* @param {string} workflowYaml - The YAML content for the GitHub workflow
|
|
57
|
+
* @param {(message: string) => void} logger
|
|
58
|
+
* @returns {Promise<string>} Path to the created workflow file
|
|
59
|
+
*/
|
|
60
|
+
async createGitHubWorkflow(workflowYaml, logger) {
|
|
61
|
+
const workflowsDir = path.join('.github', 'workflows');
|
|
62
|
+
const workflowFile = path.join(workflowsDir, 'mddd-preview.yml');
|
|
63
|
+
|
|
64
|
+
this.#fs.ensureDir(workflowsDir);
|
|
65
|
+
await this.#fs.writeFile(workflowFile, workflowYaml);
|
|
66
|
+
logger(`✅ GitHub workflow created: ${workflowFile}`);
|
|
67
|
+
|
|
68
|
+
return workflowFile;
|
|
69
|
+
}
|
|
52
70
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# InitService — Specification
|
|
2
2
|
|
|
3
|
-
**SPEC_VERSION: v1.
|
|
3
|
+
**SPEC_VERSION: v1.1.0 — stable**
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ Co-located with `src/services/InitService.js`.
|
|
|
13
13
|
## Behavioral Flow (Mermaid)
|
|
14
14
|
|
|
15
15
|
```mermaid
|
|
16
|
-
%% @spec-version v1.
|
|
16
|
+
%% @spec-version v1.1.0
|
|
17
17
|
stateDiagram-v2
|
|
18
18
|
[*] --> createSystemPrompt: initService.createSystemPrompt(promptContent)
|
|
19
19
|
createSystemPrompt --> writeFile: this.#fs.writeFile('system_prompt.md', content)
|
|
@@ -25,7 +25,12 @@ stateDiagram-v2
|
|
|
25
25
|
writeSkillFile --> consoleLog: logger( `✅ Skill encapsulated ${skillFile}`)
|
|
26
26
|
consoleLog --> iterateSkills: next entry
|
|
27
27
|
iterateSkills --> returnCreated: return created[]
|
|
28
|
-
returnCreated -->
|
|
28
|
+
returnCreated --> createGitHubWorkflow: initService.createGitHubWorkflow(workflowYaml, logger)
|
|
29
|
+
|
|
30
|
+
createGitHubWorkflow --> ensureWorkflowDir: this.#fs.ensureDir('.github/workflows')
|
|
31
|
+
ensureWorkflowDir --> writeWorkflowFile: this.#fs.writeFile('.github/workflows/mddd-preview.yml', content)
|
|
32
|
+
writeWorkflowFile --> logWorkflow: logger(`✅ GitHub workflow created ${workflowPath}`)
|
|
33
|
+
logWorkflow --> [*]
|
|
29
34
|
```
|
|
30
35
|
|
|
31
36
|
---
|
|
@@ -36,10 +41,12 @@ stateDiagram-v2
|
|
|
36
41
|
| :--- | :--- | :--- | :---: | :--- | :--- |
|
|
37
42
|
| 1 | `createSystemPrompt(promptContent)` | Input: `string`<br>Output: `Promise<void>` | ❌ No | Delegated to `#fs.writeFile` | ✅ Writes `system_prompt.md` |
|
|
38
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 |
|
|
39
|
-
| 3 | `
|
|
40
|
-
| 4 | `this.#fs.ensureDir(
|
|
41
|
-
| 5 | `this.#fs.ensureDir(
|
|
42
|
-
| 6 | `
|
|
44
|
+
| 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
|
+
| 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 |
|
|
43
50
|
|
|
44
51
|
---
|
|
45
52
|
|
|
@@ -67,5 +74,6 @@ stateDiagram-v2
|
|
|
67
74
|
| Date | Agent | Version | Change Summary |
|
|
68
75
|
| :--- | :--- | :---: | :--- |
|
|
69
76
|
| 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
|
+
| 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. |
|
|
70
78
|
|
|
71
79
|
</details>
|