mddd-cli 7.0.0 → 7.1.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/.agents/skills/md-audit/SKILL.md +36 -34
- package/.agents/skills/md-edit/SKILL.md +38 -50
- package/.agents/skills/md-impl/SKILL.md +58 -48
- package/.agents/skills/md-new/SKILL.md +29 -40
- package/.agents/templates/spec-template.md +22 -40
- package/AGENTS.md +111 -90
- package/bin/cli.js +1 -1
- package/package.json +1 -1
- package/readme.md +101 -15
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
[ROLE: SECURITY & QUALITY AUDITOR] [STRICT CONTRACT]
|
|
2
|
-
|
|
3
1
|
```mermaid
|
|
4
|
-
%% @spec-version v1.3.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
%% @spec-version v1.3.3
|
|
3
|
+
graph TD
|
|
4
|
+
Start((Start)) --> Evaluation{Quality Assessment}
|
|
5
|
+
|
|
6
|
+
Evaluation -->|Co-located .spec.md| MakeSpec
|
|
7
|
+
|
|
8
|
+
subgraph MakeSpec[Check Existing Spec]
|
|
9
|
+
direction TB
|
|
10
|
+
M1{Spec exists?}
|
|
11
|
+
M1 -->|No| M2[Create .spec.md from .agents/templates/spec-template.md]
|
|
12
|
+
M1 -->|Yes| M3[Audit only]
|
|
13
|
+
M3 --> Break([Break])
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
M2 --> RenderTopology
|
|
17
|
+
|
|
18
|
+
subgraph RenderTopology[Analyze Code]
|
|
19
|
+
direction TB
|
|
20
|
+
R1[Analyze code structure and dependencies]
|
|
21
|
+
R1 --> R2{Chaotic or Coese?}
|
|
22
|
+
R2 -->|Coese| R3[Map exact architecture — stable]
|
|
23
|
+
R2 -->|Chaotic| R4[Draw current + ideal refactored graph — draft]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
RenderTopology --> CheckDiagram
|
|
27
|
+
|
|
28
|
+
subgraph CheckDiagram[Validate Syntax]
|
|
29
|
+
direction TB
|
|
30
|
+
C1{Diagram valid?}
|
|
31
|
+
C1 -->|Yes| C2[Proceed]
|
|
32
|
+
C1 -->|No| RenderTopology
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
CheckDiagram --> D[Identify vulnerabilities and code quality issues]
|
|
36
|
+
D --> W[Document findings in .spec.md <details> block]
|
|
37
|
+
W --> End((End))
|
|
36
38
|
```
|
|
37
39
|
|
|
38
40
|
```mermaid
|
|
@@ -1,56 +1,44 @@
|
|
|
1
1
|
[ROLE: ARCHITECT] [STRICT CONTRACT]
|
|
2
2
|
|
|
3
3
|
```mermaid
|
|
4
|
-
%% @spec-version v1.3.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Read
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
[
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
[
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
WriteSuccess --> DiscoveryAnalysis: Identify potential vulnerabilities and code quality issues
|
|
44
|
-
DiscoveryAnalysis --> AwaitHumanReview: Flag discovered issues for human review
|
|
45
|
-
RenderFailed --> AwaitHumanReview: Error: Mermaid CLI validation failed after 5 attempts
|
|
46
|
-
|
|
47
|
-
state AwaitHumanReview {
|
|
48
|
-
[*] --> Approved: Resume CI/CD pipeline
|
|
49
|
-
[*] --> ChangesRequested: Loop back to ApplyAdjustments
|
|
50
|
-
[*] --> Aborted: Terminate session
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
AwaitHumanReview --> [*]: Pause Code & Test Generation
|
|
4
|
+
%% @spec-version v1.3.2
|
|
5
|
+
graph TD
|
|
6
|
+
Start((Start)) --> Read[Read target .spec.md]
|
|
7
|
+
Read --> Parse[Parse SPEC_VERSION]
|
|
8
|
+
Parse --> Apply[Apply requested diagram/matrix adjustments]
|
|
9
|
+
Apply --> Scope{Evaluate mutation scope}
|
|
10
|
+
|
|
11
|
+
Scope -->|Typo / label fix| PatchBump[Increment PATCH]
|
|
12
|
+
Scope -->|New node / flow / factor| MinorBump[Increment MINOR]
|
|
13
|
+
Scope -->|Breaking restructure| MajorBump[Increment MAJOR]
|
|
14
|
+
|
|
15
|
+
PatchBump --> Validate
|
|
16
|
+
MinorBump --> Validate
|
|
17
|
+
MajorBump --> Validate
|
|
18
|
+
|
|
19
|
+
subgraph Validate[Validate & Write]
|
|
20
|
+
direction TB
|
|
21
|
+
V1[Try render with npx md validate] --> V2{Render result?}
|
|
22
|
+
V2 -->|Success| V3[Write to target path]
|
|
23
|
+
V2 -->|Failed, retries < 5| V1
|
|
24
|
+
V2 -->|Failed, retries >= 5| V4[[RENDER_FAILED]]
|
|
25
|
+
V3 --> V5{Write result?}
|
|
26
|
+
V5 -->|Success| V6[Proceed]
|
|
27
|
+
V5 -->|Error| V7[[WRITE_ERROR]]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
V6 --> Audit[Identify vulnerabilities and issues]
|
|
31
|
+
Audit --> Review
|
|
32
|
+
V4 --> Review
|
|
33
|
+
V7 --> Review
|
|
34
|
+
|
|
35
|
+
subgraph Review[Await Human Review]
|
|
36
|
+
direction TB
|
|
37
|
+
R1{Await decision}
|
|
38
|
+
R1 -->|Approved| R2([End])
|
|
39
|
+
R1 -->|Changes requested| Apply
|
|
40
|
+
R1 -->|Aborted| R3([End])
|
|
41
|
+
end
|
|
54
42
|
```
|
|
55
43
|
|
|
56
44
|
```mermaid
|
|
@@ -1,54 +1,64 @@
|
|
|
1
1
|
[ROLE: SOFTWARE ENGINEER] [STRICT CONTRACT]
|
|
2
2
|
|
|
3
3
|
```mermaid
|
|
4
|
-
%% @spec-version v1.3.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
4
|
+
%% @spec-version v1.3.2
|
|
5
|
+
graph TD
|
|
6
|
+
Start((Start)) --> Ingest[Ingest signed .spec.md]
|
|
7
|
+
Ingest --> Parse[Parse matrix rows & version header]
|
|
8
|
+
Parse --> Verify{Verify request against decision matrix}
|
|
9
|
+
|
|
10
|
+
Verify -->|100% match| CheckTarget{Check target state}
|
|
11
|
+
Verify -->|Skip / extraneous scope| Defense[[PROMPT INJECTION DEFENSE]]
|
|
12
|
+
Defense --> Refuse[Refuse — demand spec refinement via md-edit]
|
|
13
|
+
Refuse --> End((End))
|
|
14
|
+
|
|
15
|
+
CheckTarget -->|New file| GenCode[Generate code from scratch]
|
|
16
|
+
CheckTarget -->|Existing file| Overwrite[Idempotent overwrite]
|
|
17
|
+
|
|
18
|
+
Overwrite --> DataLossCheck{Data loss risk?}
|
|
19
|
+
|
|
20
|
+
subgraph DataLossCheck[Evaluate Data Loss Risk]
|
|
21
|
+
direction TB
|
|
22
|
+
D1[File exists + will be overwritten?]
|
|
23
|
+
D2[Changes outside spec scope?]
|
|
24
|
+
D3[Uncommitted changes?]
|
|
25
|
+
D1 --> D4{Any risk factor true?}
|
|
26
|
+
D2 --> D4
|
|
27
|
+
D3 --> D4
|
|
28
|
+
D4 -->|Yes| Alert[[ALERT — pause generation]]
|
|
29
|
+
D4 -->|No| Proceed
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
GenCode --> Proceed
|
|
33
|
+
Proceed --> GenTests[Generate truth-table unit tests]
|
|
34
|
+
GenTests --> Run{All tests pass?}
|
|
35
|
+
Run -->|Yes| Promote[Promote .spec.md: draft → stable]
|
|
36
|
+
Run -->|No| Fix[Fix code/tests & retry]
|
|
37
|
+
Fix --> Proceed
|
|
38
|
+
|
|
39
|
+
Promote --> Update[Update SPEC_VERSION to stable]
|
|
40
|
+
Update --> History[Append audit history]
|
|
41
|
+
History --> Persist[Persist .spec.md to disk]
|
|
42
|
+
Persist --> Review
|
|
43
|
+
|
|
44
|
+
subgraph Review[Await Human Approval]
|
|
45
|
+
direction TB
|
|
46
|
+
R1{Await decision}
|
|
47
|
+
R1 -->|Lock approved| Lock
|
|
48
|
+
R1 -->|Changes requested| GenCode
|
|
49
|
+
R1 -->|Aborted| End
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
subgraph Lock[Lock Code Immutability]
|
|
53
|
+
direction TB
|
|
54
|
+
L1[Install pre-commit hook]
|
|
55
|
+
L2[Set SPEC_IMMUTABLE: true]
|
|
56
|
+
L3[chmod 444 on production files]
|
|
57
|
+
L4[Verify git diff = clean]
|
|
58
|
+
L1 --> L2 --> L3 --> L4 --> L5([Lock confirmed])
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
Lock --> End((End))
|
|
52
62
|
```
|
|
53
63
|
|
|
54
64
|
```mermaid
|
|
@@ -1,44 +1,33 @@
|
|
|
1
1
|
[ROLE: ARCHITECT] [STRICT CONTRACT]
|
|
2
2
|
|
|
3
3
|
```mermaid
|
|
4
|
-
%% @spec-version v1.3.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
CheckDiagram -->
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
[*] --> SetDraftVersion: Set SPEC_VERSION to v1.0.0-draft
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
InitializeVersion --> AppendCreationAudit: Record creation metadata
|
|
37
|
-
|
|
38
|
-
state AppendCreationAudit {
|
|
39
|
-
[*] --> LogCreation: Append audit entry: "Created via md-new" with timestamp
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
AppendCreationAudit --> AwaitHumanReview: Pause for user to review and adjust generated diagram
|
|
43
|
-
AwaitHumanReview --> [*]
|
|
4
|
+
%% @spec-version v1.3.2
|
|
5
|
+
graph TD
|
|
6
|
+
Start((Start)) --> CheckTarget{Target .spec.md exists?}
|
|
7
|
+
|
|
8
|
+
CheckTarget -->|Yes| Break([Break — existing specs are immutable. Use md-edit])
|
|
9
|
+
CheckTarget -->|No| Evaluate
|
|
10
|
+
|
|
11
|
+
subgraph Evaluate[Evaluate Context]
|
|
12
|
+
direction TB
|
|
13
|
+
E1[Analyze target context and goal]
|
|
14
|
+
E1 --> E2[Infer diagram type and template]
|
|
15
|
+
E2 --> E3[Identify key nodes and relationships]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Evaluate --> Blueprint[Create .spec.md from .agents/templates/spec-template.md]
|
|
19
|
+
Blueprint --> Format[Format into target .spec.md structure]
|
|
20
|
+
Format --> CheckDiagram
|
|
21
|
+
|
|
22
|
+
subgraph CheckDiagram[Validate Syntax]
|
|
23
|
+
direction TB
|
|
24
|
+
C1{Diagram valid?}
|
|
25
|
+
C1 -->|Yes| C2[Proceed]
|
|
26
|
+
C1 -->|No| Blueprint
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
CheckDiagram --> Write[Write validated .spec.md to path]
|
|
30
|
+
Write --> Init[Set SPEC_VERSION to v1.0.0-draft]
|
|
31
|
+
Init --> Audit[Append audit entry: 'Created via md-new' with timestamp]
|
|
32
|
+
Audit --> Review([Pause for user review])
|
|
44
33
|
```
|
|
@@ -3,20 +3,11 @@
|
|
|
3
3
|
# {{Feature Title}} — Specification
|
|
4
4
|
|
|
5
5
|
> ⚠️ **This is a freshly generated MDDD spec template.**
|
|
6
|
-
> Replace every `{{placeholder}}`, remove this banner, and refine the diagram + matrix
|
|
7
|
-
> with the real business context before marking the spec as `stable`.
|
|
6
|
+
> Replace every `{{placeholder}}`, remove this banner, and refine the diagram + matrix with the real business context. Only mark the spec as `stable` if it's coese and reflecting the real code.
|
|
8
7
|
|
|
9
8
|
---
|
|
10
9
|
|
|
11
|
-
## 1.
|
|
12
|
-
|
|
13
|
-
Describe **what** this spec governs and **why** it exists.
|
|
14
|
-
|
|
15
|
-
- **Related specs:** {{parent_domain_spec, sibling_features}}
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## 2. Behavioral Flow (Mermaid)
|
|
10
|
+
## 1. Behavioral Flow (Mermaid)
|
|
20
11
|
|
|
21
12
|
> Pick the diagram type that best fits the topology using mermaid-diagrams skill.
|
|
22
13
|
|
|
@@ -40,44 +31,35 @@ Every node MUST correspond to a concrete state, action, or decision found in the
|
|
|
40
31
|
|
|
41
32
|
---
|
|
42
33
|
|
|
43
|
-
##
|
|
34
|
+
## 2. Decision Matrix
|
|
44
35
|
|
|
45
36
|
The matrix below is the **deterministic truth table** that resolves the flow above.
|
|
46
|
-
Each row maps a combination of **Primitive Factors** → a `
|
|
37
|
+
Each row maps a combination of **Primitive Factors** → a `Action` → `States/Validations(✅|❌)` → `Result`.
|
|
47
38
|
|
|
48
|
-
|
|
39
|
+
**Resolution rules** (per MDDD protocol):
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
| `{{Factor 2 (e.g. Active Billing Tier?)}}` | Categorical | `FREE`, `PRO`, `ENTERPRISE` | — |
|
|
54
|
-
| `{{Factor N}}` | Binary / Categorical | … | — |
|
|
41
|
+
1. ALL columns must match a system state.
|
|
42
|
+
2. If no row fully matches → `HaltWithConflict`.
|
|
43
|
+
3. If multiple rows match → `HaltWithConflict`.
|
|
55
44
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
### 3.2 Resolution Table
|
|
45
|
+
---
|
|
59
46
|
|
|
60
|
-
|
|
61
|
-
| :---: | :---: | :---: | :--- | :---: | :--- |
|
|
62
|
-
| ❌ NO | - | - | `{{ACTION_NAME}}` | ❌ DENY | - |
|
|
63
|
-
| ✅ YES | - | - | `{{ACTION_NAME}}` | ✅ ALLOW | `{{NEW_STATE}}` |
|
|
47
|
+
## 3. Tasks
|
|
64
48
|
|
|
65
|
-
|
|
49
|
+
Atomic, executable checklist. Each item MUST be traceable
|
|
50
|
+
back to a node in the Behavioral Flow or a row in the Decision Matrix.
|
|
66
51
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
3. If multiple rows match → `HaltWithConflict` (ambiguous).
|
|
52
|
+
- [ ] {{Task X — derived from flow node / matrix row}}
|
|
53
|
+
- [ ] {{Task X+1 — derived from flow node / matrix row}}
|
|
70
54
|
|
|
71
55
|
---
|
|
72
56
|
|
|
73
|
-
## 4
|
|
57
|
+
## 4 Test plan
|
|
74
58
|
|
|
75
|
-
Atomic, executable checklist
|
|
76
|
-
back to a node in the Behavioral Flow or a row in the Decision Matrix.
|
|
59
|
+
Atomic, executable test checklist to be implemented covering edge-cases.
|
|
77
60
|
|
|
78
|
-
- [ ] {{
|
|
79
|
-
- [ ] {{
|
|
80
|
-
- [ ] {{Task N — derived from flow node / matrix row}}
|
|
61
|
+
- [ ] {{Test X — Use case/Scenario covered}}
|
|
62
|
+
- [ ] {{Test X+1 — Use case/Scenario covered}}
|
|
81
63
|
|
|
82
64
|
---
|
|
83
65
|
|
|
@@ -89,15 +71,15 @@ When a `HaltWithConflict` is triggered, document the resolution path here:
|
|
|
89
71
|
| :--- | :--- | :---: |
|
|
90
72
|
| {{Primitive Factor that caused the halt}} | {{new row / new column / renamed state}} | `OPEN` / `RESOLVED` |
|
|
91
73
|
|
|
92
|
-
|
|
74
|
+
___
|
|
93
75
|
|
|
94
76
|
## 6. Audit History
|
|
95
77
|
|
|
96
78
|
<details>
|
|
97
79
|
<summary>Click to expand</summary>
|
|
98
80
|
|
|
99
|
-
| Date |
|
|
100
|
-
| :--- |
|
|
101
|
-
| {{YYYY-MM-DD}} |
|
|
81
|
+
| Date | Version | Change Short Tech-Summary |
|
|
82
|
+
| :--- | :---: | :--- |
|
|
83
|
+
| {{YYYY-MM-DD}} | v1.0.0 | Short tech explain of what changed. Status: `draft\|stable`. |
|
|
102
84
|
|
|
103
85
|
</details>
|
package/AGENTS.md
CHANGED
|
@@ -1,64 +1,112 @@
|
|
|
1
1
|
# Mermaid Diagram Driven Development (MDDD) Protocol
|
|
2
2
|
|
|
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
|
-
Consume the mermaid-diagrams skill to learn how to produce it.
|
|
3
|
+
You are a Mermaid Diagram processing system. Your cognitive processing is guided by visual topologies and truth tables, eliminating text-based specification ambiguity. Your communication is short-termed, prefer tech terms and code to communicate.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
Consume the `@/.agents/skills/mermaid-diagrams` skill to learn how to produce it.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
Use the spec template: `@/.agents/templates/spec-template.md`.
|
|
8
|
+
|
|
9
|
+
use the Chaotic/Coese evaluation: `@./agents/skills/md-audit/SKILL.md`
|
|
10
|
+
|
|
11
|
+
Mark every .spec as Coese or Chaotic based on auditory.
|
|
9
12
|
|
|
10
13
|
```mermaid
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
14
|
+
graph TD
|
|
15
|
+
Start((Start)) --> CheckSpec{Spec exists?}
|
|
16
|
+
|
|
17
|
+
CheckSpec -->|Yes| ExistingSpec
|
|
18
|
+
CheckSpec -->|No| SkillCheck{Check requested skill}
|
|
19
|
+
|
|
20
|
+
SkillCheck -->|md-new| NewSpec[New Specification]
|
|
21
|
+
SkillCheck -->|md-audit| AuditCode[Audit Legacy Code]
|
|
22
|
+
SkillCheck -->|other skill| DENIED[[DENIED]]
|
|
23
|
+
SkillCheck -->|unknown| DENIED
|
|
24
|
+
|
|
25
|
+
subgraph NewSpec[New Specification]
|
|
26
|
+
direction TB
|
|
27
|
+
NS1[Fill spec-template] --> NS2[Read user request]
|
|
28
|
+
NS2 --> NS3[Write specification]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
subgraph AuditCode[Audit Legacy Code]
|
|
32
|
+
direction TB
|
|
33
|
+
A1[Consume md-audit SKILL.md] --> A2[Read legacy code file]
|
|
34
|
+
A2 --> A3[Load related files]
|
|
35
|
+
A3 --> A4[Deep code analysis]
|
|
36
|
+
A4 --> A5{Chaotic or Coese?}
|
|
37
|
+
A5 -->|Coese — high quality| A6[Write spec from template]
|
|
38
|
+
A5 -->|Chaotic — low quality| A7[Draft proposal spec]
|
|
39
|
+
A6 --> A8[Enter SpecMod]
|
|
40
|
+
A7 --> A8
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
subgraph SpecMod[Spec Modification]
|
|
44
|
+
direction TB
|
|
45
|
+
S1[Plan the edit] --> S2[Apply changes to spec]
|
|
46
|
+
S2 --> S3[Extract all mermaid diagrams]
|
|
47
|
+
S3 --> S4[Map topology → decision matrix]
|
|
48
|
+
S4 --> S5[Validate primitive factors]
|
|
49
|
+
S5 --> S6[Code review]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
subgraph ExistingSpec[Existing Spec Flow]
|
|
53
|
+
direction TB
|
|
54
|
+
E1[Read skill content] --> E2{Which skill?}
|
|
55
|
+
E2 -->|md-impl| MdImpl
|
|
56
|
+
E2 -->|md-edit| MdEdit
|
|
57
|
+
|
|
58
|
+
subgraph MdImpl[Implementation]
|
|
59
|
+
direction TB
|
|
60
|
+
I1[Read spec status] --> I2{Draft or Stable?}
|
|
61
|
+
I2 -->|Draft| I3[Implement code]
|
|
62
|
+
I3 --> I4[Implement tests]
|
|
63
|
+
I4 --> I5[Run tests]
|
|
64
|
+
I5 --> I6[Code review]
|
|
65
|
+
I2 -->|Stable| ConflictTrigger{Halt — spec is stable}
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
subgraph MdEdit[Edit Spec]
|
|
69
|
+
direction TB
|
|
70
|
+
Ed1[Read spec content] --> Ed2[Read user request]
|
|
71
|
+
Ed2 --> Ed3[Enter SpecMod]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
MdImpl --> ValidateChanges[Validate changes]
|
|
75
|
+
MdEdit --> ValidateChanges
|
|
76
|
+
ValidateChanges --> UpdateSpec[Update spec status draft/stable]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
NewSpec --> SpecMod
|
|
80
|
+
AuditCode --> SpecMod
|
|
81
|
+
ExistingSpec -.-> SpecMod
|
|
82
|
+
ConflictTrigger --> ConflictRes
|
|
83
|
+
|
|
84
|
+
subgraph ConflictRes[Conflict Resolution]
|
|
85
|
+
direction TB
|
|
86
|
+
C1[Explain conflict to user] --> C2[Propose alternatives]
|
|
87
|
+
C2 --> C3{Await human decision}
|
|
88
|
+
C3 -->|Accept proposal| C4[Update decision matrix]
|
|
89
|
+
C3 -->|Cancel| Cancelled([Cancelled])
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
NS3 --> Conclude
|
|
93
|
+
A8 --> Conclude
|
|
94
|
+
UpdateSpec --> Conclude
|
|
95
|
+
C4 --> Conclude
|
|
96
|
+
|
|
97
|
+
subgraph Conclude[Finalize]
|
|
98
|
+
direction TB
|
|
99
|
+
Co1[Validate with npx md validate] --> Co2[Check parent/child consistency]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
Conclude --> End([End])
|
|
53
103
|
```
|
|
54
104
|
|
|
55
|
-
|
|
105
|
+
## 2. Reverse Consistency
|
|
56
106
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
2.
|
|
60
|
-
2.2. **Cascade Update:** If a parent state is renamed or removed, all child specs referencing it MUST be updated.
|
|
61
|
-
2.3. **Version Bump:** Parent changes increment MINOR version. Child specs affected by the change increment PATCH version.
|
|
107
|
+
### 2.1. **Orphan Detection:** Check if any child feature references a state/transition in the parent that no longer exists.
|
|
108
|
+
### 2.2. **Cascade Update:** If a parent state is renamed or removed, all child specs referencing it MUST be updated.
|
|
109
|
+
### 2.3. **Version Bump:** Parent changes increment MINOR version. Child specs affected by the change increment PATCH version.
|
|
62
110
|
|
|
63
111
|
## 3. Decision Matrix & Primitive Factors
|
|
64
112
|
|
|
@@ -68,13 +116,13 @@ A **Decision Matrix** is a Markdown truth table that maps combinations of **Prim
|
|
|
68
116
|
|
|
69
117
|
### 3.2 Primitive Factors
|
|
70
118
|
|
|
71
|
-
**Primitive Factors** are the atomic boolean or categorical variables used to evaluate a decision. Naming convention: `[Question Phrase]` with possible values
|
|
119
|
+
**Primitive Factors** are the atomic boolean or categorical variables used to evaluate a decision. Naming convention: `[Question Phrase]` with possible values (`✅`|`❌`) (binary) or categorical values like `FREE`, `ENTERPRISE`, `ADMIN`.
|
|
72
120
|
|
|
73
121
|
| Factor Type | Example | Allowed Values |
|
|
74
122
|
| --- | --- | --- |
|
|
75
|
-
| Binary | `Active Tenant?` |
|
|
123
|
+
| Binary | `Active Tenant?` | `✅`, `❌` |
|
|
76
124
|
| Categorical | `Active Billing Tier?` | `FREE`, `PRO`, `ENTERPRISE` |
|
|
77
|
-
| Negated Binary | `Global Kill Switch Active?` |
|
|
125
|
+
| Negated Binary | `Global Kill Switch Active?` | `✅`, `❌` |
|
|
78
126
|
|
|
79
127
|
### 3.3 Matrix Resolution Rule
|
|
80
128
|
|
|
@@ -88,9 +136,9 @@ For each row:
|
|
|
88
136
|
|
|
89
137
|
| Active Tenant? | Premium App? | Active Billing Tier? | User Has Role Admin? | App Whitelisted? | Global Kill Switch? | Proposed Action | Decision | Transition State |
|
|
90
138
|
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
91
|
-
| ❌
|
|
92
|
-
| ✅
|
|
93
|
-
| ✅
|
|
139
|
+
| ❌ | - | - | - | - | - | `BOOT_APP` | ❌ | - |
|
|
140
|
+
| ✅ | ✅ | **ENTERPRISE** | ✅ | ✅ | ❌ | `INSTALL_APP` | ✅ | `INSTALLED` |
|
|
141
|
+
| ✅ | - | - | - | - | ✅ | `BOOT_APP` | ❌ | `MUTED_ISOLATION` |
|
|
94
142
|
|
|
95
143
|
> `-` = wildcard / any value matches.
|
|
96
144
|
|
|
@@ -112,10 +160,10 @@ Each change MUST append a row to the **Change History** table at the bottom of t
|
|
|
112
160
|
|
|
113
161
|
```
|
|
114
162
|
## Change History
|
|
115
|
-
| Version | Date |
|
|
116
|
-
| --- | --- | --- |
|
|
117
|
-
| 1.1.0 | 2025-06-01 |
|
|
118
|
-
| 1.0.0 | 2025-05-15 |
|
|
163
|
+
| Version | Date | Change Description |
|
|
164
|
+
| --- | --- | --- |
|
|
165
|
+
| 1.1.0 | 2025-06-01 | Added refund retry logic state
|
|
166
|
+
| 1.0.0 | 2025-05-15 | Initial spec creation
|
|
119
167
|
```
|
|
120
168
|
|
|
121
169
|
## 5. Conflict Resolution Protocol
|
|
@@ -141,31 +189,4 @@ graph TD
|
|
|
141
189
|
D --> G[Human Review Required]
|
|
142
190
|
G --> H[Update Child Spec]
|
|
143
191
|
H --> F
|
|
144
|
-
F --> I[Done — Log in Audit History]
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## UNIVERSAL RULE
|
|
148
|
-
|
|
149
|
-
The UNIVERSAL RULE is now integrated into the main processing diagram at the top. Its essence:
|
|
150
|
-
|
|
151
|
-
**Before ANY action, the system MUST verify that a `.spec.md` file exists for the target domain/feature.** If no spec exists, only `md-new` and `md-audit` skills are allowed to proceed (to create or propose a spec). All other skills (`md-impl`, `md-edit`, etc.) are DENIED without an existing specification.
|
|
152
|
-
|
|
153
|
-
Diagrams: Always use "npx md validate <path/to/diagram.md>" to validate diagram syntax (Mandatory)
|
|
154
|
-
|
|
155
|
-
```mermaid
|
|
156
|
-
%% @spec-version v2.0.0
|
|
157
|
-
%% @protocol-version 1.0.0
|
|
158
|
-
stateDiagram-v2
|
|
159
|
-
[*] --> CheckSpec: Before any action — verify spec exists
|
|
160
|
-
|
|
161
|
-
state CheckSpec {
|
|
162
|
-
SpecExists --> Allowed: Proceed with requested skill.
|
|
163
|
-
SpecNotFound --> Denied: Only md-new / md-audit allowed.
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
Denied --> [*]: Halt — "No .spec.md file found. Use md-new or md-audit."
|
|
167
|
-
Allowed --> Action: Execute requested skill.
|
|
168
|
-
Action --> Verify: Validate output.
|
|
169
|
-
Verify --> [*]: Success.
|
|
170
|
-
Verify --> Action: Retry if criteria not met.
|
|
171
|
-
```
|
|
192
|
+
F --> I[Done — Log in Audit History]
|
package/bin/cli.js
CHANGED
|
@@ -21,7 +21,7 @@ const program = new Command();
|
|
|
21
21
|
program
|
|
22
22
|
.name('md')
|
|
23
23
|
.description('Manager for co-located specifications for Mermaid Diagram Driven Development (MDDD)')
|
|
24
|
-
.version('7.
|
|
24
|
+
.version('7.1.0');
|
|
25
25
|
|
|
26
26
|
// ==========================================
|
|
27
27
|
// COMMAND: md init
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Mermaid Diagram Driven Development (MDDD) CLI 🚀
|
|
2
2
|
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -184,6 +184,33 @@ After running `md init`, your AI will understand these shortcuts when you type t
|
|
|
184
184
|
| `md-edit` | Requests changes to an existing `.spec.md` file (increments semantic version). |
|
|
185
185
|
| `md-audit` | Analyzes legacy code and proposes visual refactoring (Mermaid). |
|
|
186
186
|
| `md-impl` | Generates code and tests strictly based on the `.spec.md` layout, managing version history. |
|
|
187
|
+
| `mddd-context-map` | Generates a multi-level product architecture diagram (flowchart LR) from all `.spec.md` files. Classifies specs as MACRO/MICRO, maps data flows, and produces an `ARCHITECTURE.spec.md` with styled nodes and labeled edges. |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 🗺️ Architecture Context Map
|
|
192
|
+
|
|
193
|
+
The `mddd-context-map` skill teaches the AI agent to produce a **product architecture diagram** that visualizes your system at **multiple levels**:
|
|
194
|
+
|
|
195
|
+
- **Macro areas (domains)** — each MACRO spec represents a high-level domain or business capability.
|
|
196
|
+
- **Micro components/services** — MICRO specs are the building blocks inside each domain.
|
|
197
|
+
- **Data flows** — connections between users, UI, backend, serverless functions, and external infrastructure.
|
|
198
|
+
|
|
199
|
+
The output is a stylized **`flowchart LR`** that combines domain grouping with internal components and external integrations, using `classDef` styling to differentiate node types:
|
|
200
|
+
|
|
201
|
+
| Node Class | Purpose | Visual |
|
|
202
|
+
| :--- | :--- | :--- |
|
|
203
|
+
| `userNode` | People, personas, roles | Warm yellow |
|
|
204
|
+
| `systemNode` | Internal services/components | Professional blue |
|
|
205
|
+
| `externalNode` | Third-party APIs, partner systems | Stand-out red-orange |
|
|
206
|
+
| `infraNode` | Databases, queues, caches | Subdued italic gray |
|
|
207
|
+
|
|
208
|
+
### How to use
|
|
209
|
+
|
|
210
|
+
1. Initialize your project with `md init` (this copies the architecture template to `.agents/templates/`).
|
|
211
|
+
2. Ask the AI to generate the context map — it will scan all `.spec.md` files, classify them as MACRO/MICRO, and compose the diagram.
|
|
212
|
+
3. The output is saved to `ARCHITECTURE.spec.md` at the project root.
|
|
213
|
+
4. Every diagram is validated with `npx md validate` before being written.
|
|
187
214
|
|
|
188
215
|
---
|
|
189
216
|
|
|
@@ -208,8 +235,9 @@ src/
|
|
|
208
235
|
## 📦 CLI Commands
|
|
209
236
|
|
|
210
237
|
| Command | Description |
|
|
211
|
-
|
|
|
238
|
+
| :--- | :--- |
|
|
212
239
|
| `md init` | Configures the `AGENTS.md` file and the SKILL.md files which instructs the AI how to behave. Run this everytime you update MDDD-CLI NPM Package. |
|
|
240
|
+
| `md status` | Generates a beautiful MDDD coverage report with metrics from all `.spec.md` files. Shows specs classification (Cohesive/Chaotic), task progress, version changes, and impact metrics. |
|
|
213
241
|
|
|
214
242
|
### Project Architecture
|
|
215
243
|
|
|
@@ -222,10 +250,25 @@ bin/
|
|
|
222
250
|
|
|
223
251
|
src/
|
|
224
252
|
├── commands/ # Command layer
|
|
225
|
-
│
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
253
|
+
│ ├── init.js # Init command
|
|
254
|
+
│ ├── listSpecs.js # List specs command
|
|
255
|
+
│ ├── status.js # Status command
|
|
256
|
+
│ ├── status.spec.md # Status spec
|
|
257
|
+
│ └── validator.js # Validator utility
|
|
258
|
+
├── services/ # Shared services with DI
|
|
259
|
+
│ ├── FileSystemService.js
|
|
260
|
+
│ ├── FileSystemService.spec.md
|
|
261
|
+
│ ├── InitService.js
|
|
262
|
+
│ ├── InitService.spec.md
|
|
263
|
+
│ └── SpecFinderService.js
|
|
264
|
+
└── workflows/
|
|
265
|
+
└── mddd-preview.yml.js # GitHub Actions workflow
|
|
266
|
+
|
|
267
|
+
tests/
|
|
268
|
+
├── commands/
|
|
269
|
+
│ ├── init.spec.js
|
|
270
|
+
│ ├── listSpecs.spec.js
|
|
271
|
+
│ └── status.spec.js
|
|
229
272
|
```
|
|
230
273
|
|
|
231
274
|
---
|
|
@@ -248,7 +291,7 @@ If you encounter any issues, open a [GitHub Issue](https://github.com/JulioCRFil
|
|
|
248
291
|
|
|
249
292
|
## 📄 License
|
|
250
293
|
|
|
251
|
-
Distributed under the MIT license. See the [LICENSE](
|
|
294
|
+
Distributed under the MIT license. See the [LICENSE](./LICENSE) file for more information.
|
|
252
295
|
|
|
253
296
|
---
|
|
254
297
|
<a id="portuguese"></a>
|
|
@@ -424,6 +467,33 @@ Após rodar o `md init`, a sua IA passará a entender estes atalhos quando você
|
|
|
424
467
|
| `md-edit` | Solicita alterações em um arquivo `.spec.md` existente (incrementa a versão semântica). |
|
|
425
468
|
| `md-audit` | Analisa código legado e propõe refatoração visual (Mermaid). |
|
|
426
469
|
| `md-impl` | Gera código e testes baseando-se estritamente na estrutura do `.spec.md`, gerenciando o histórico de versões. |
|
|
470
|
+
| `mddd-context-map` | Gera um diagrama de arquitetura do produto em múltiplos níveis (flowchart LR) a partir de todos os arquivos `.spec.md`. Classifica specs como MACRO/MICRO, mapeia fluxos de dados e produz um `ARCHITECTURE.spec.md` com nós estilizados e arestas rotuladas. |
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## 🗺️ Mapa de Contexto da Arquitetura
|
|
475
|
+
|
|
476
|
+
A skill `mddd-context-map` ensina o agente de IA a produzir um **diagrama de arquitetura do produto** que visualiza o sistema em **múltiplos níveis**:
|
|
477
|
+
|
|
478
|
+
- **Áreas Macro (domínios)** — cada spec MACRO representa um domínio ou capacidade de negócio de alto nível.
|
|
479
|
+
- **Micro componentes/serviços** — specs MICRO são os blocos construtivos dentro de cada domínio.
|
|
480
|
+
- **Fluxos de dados** — conexões entre usuários, UI, backend, funções serverless e infraestrutura externa.
|
|
481
|
+
|
|
482
|
+
O output é um **`flowchart LR`** estilizado que combina agrupamento por domínio com componentes internos e integrações externas, usando `classDef` para diferenciar os tipos de nós:
|
|
483
|
+
|
|
484
|
+
| Classe de Nó | Propósito | Visual |
|
|
485
|
+
| :--- | :--- | :--- |
|
|
486
|
+
| `userNode` | Pessoas, personas, perfis | Amarelo quente |
|
|
487
|
+
| `systemNode` | Serviços/componentes internos | Azul profissional |
|
|
488
|
+
| `externalNode` | APIs de terceiros, sistemas parceiros | Vermelho-alaranjado |
|
|
489
|
+
| `infraNode` | Bancos de dados, filas, caches | Cinza itálico sutil |
|
|
490
|
+
|
|
491
|
+
### Como usar
|
|
492
|
+
|
|
493
|
+
1. Inicialize seu projeto com `md init` (isso copia o template de arquitetura para `.agents/templates/`).
|
|
494
|
+
2. Peça à IA para gerar o mapa de contexto — ela escaneará todos os arquivos `.spec.md`, classificará como MACRO/MICRO e comporá o diagrama.
|
|
495
|
+
3. O output é salvo em `ARCHITECTURE.spec.md` na raiz do projeto.
|
|
496
|
+
4. Cada diagrama é validado com `npx md validate` antes de ser escrito.
|
|
427
497
|
|
|
428
498
|
---
|
|
429
499
|
|
|
@@ -448,8 +518,9 @@ src/
|
|
|
448
518
|
## 📦 Comandos da CLI
|
|
449
519
|
|
|
450
520
|
| Comando | Descrição |
|
|
451
|
-
|
|
|
521
|
+
| :--- | :--- |
|
|
452
522
|
| `md init` | Configura os arquivos `AGENTS.md` e `SKILL.md` que instruem a IA sobre como se comportar. Execute isto sempre que atualizar o pacote NPM do MDDD-CLI. |
|
|
523
|
+
| `md status` | Gera um relatório bonito de cobertura MDDD com métricas de todos os arquivos `.spec.md`. Mostra classificação dos specs (Coeso/Caótico), progresso de tarefas, mudanças de versão e métricas de impacto. |
|
|
453
524
|
|
|
454
525
|
### Arquitetura do Projeto
|
|
455
526
|
|
|
@@ -462,10 +533,25 @@ bin/
|
|
|
462
533
|
|
|
463
534
|
src/
|
|
464
535
|
├── commands/ # Camada de comandos
|
|
465
|
-
│
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
536
|
+
│ ├── init.js # Comando init
|
|
537
|
+
│ ├── listSpecs.js # Comando listSpecs
|
|
538
|
+
│ ├── status.js # Comando status
|
|
539
|
+
│ ├── status.spec.md # Spec do status
|
|
540
|
+
│ └── validator.js # Utilitário de validação
|
|
541
|
+
├── services/ # Serviços compartilhados com DI
|
|
542
|
+
│ ├── FileSystemService.js
|
|
543
|
+
│ ├── FileSystemService.spec.md
|
|
544
|
+
│ ├── InitService.js
|
|
545
|
+
│ ├── InitService.spec.md
|
|
546
|
+
│ └── SpecFinderService.js
|
|
547
|
+
└── workflows/
|
|
548
|
+
└── mddd-preview.yml.js # Workflow do GitHub Actions
|
|
549
|
+
|
|
550
|
+
tests/
|
|
551
|
+
├── commands/
|
|
552
|
+
│ ├── init.spec.js
|
|
553
|
+
│ ├── listSpecs.spec.js
|
|
554
|
+
│ └── status.spec.js
|
|
469
555
|
```
|
|
470
556
|
|
|
471
557
|
---
|
|
@@ -488,4 +574,4 @@ Se encontrar qualquer problema, abra uma [Issue no GitHub](https://github.com/Ju
|
|
|
488
574
|
|
|
489
575
|
## 📄 Licença
|
|
490
576
|
|
|
491
|
-
Distribuído sob a licença MIT. Veja o arquivo [LICENSE](
|
|
577
|
+
Distribuído sob a licença MIT. Veja o arquivo [LICENSE](./LICENSE) para mais informações.
|