mddd-cli 7.0.0 → 7.1.1
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 +53 -261
- package/src/commands/init.js +0 -5
- package/src/services/InitService.js +0 -17
- package/src/services/InitService.spec.md +5 -13
- package/src/workflows/mddd-preview.yml.js +0 -61
|
@@ -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.1');
|
|
25
25
|
|
|
26
26
|
// ==========================================
|
|
27
27
|
// COMMAND: md init
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
# Mermaid Diagram Driven Development (MDDD) CLI 🚀
|
|
2
2
|
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
<p align="center">
|
|
10
|
-
<a href="#english">🇺🇸 English</a> •
|
|
11
|
-
<a href="#portuguese">🇧🇷 Português</a>
|
|
12
|
-
</p>
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
<a id="english"></a>
|
|
17
|
-
|
|
18
9
|
# 🇺🇸 English
|
|
19
10
|
|
|
20
11
|
An agnostic, ultra-lightweight, and surgical CLI for implementing **MDDD (Mermaid Diagram Driven Development)** in a modular, co-located, and strictly versioned way.
|
|
@@ -144,7 +135,7 @@ npm install -g mddd-cli
|
|
|
144
135
|
|
|
145
136
|
## 🚀 Quick Start Guide
|
|
146
137
|
|
|
147
|
-
The MDDD
|
|
138
|
+
The MDDD protocol is based on skills to orchestrate AI agents development.
|
|
148
139
|
|
|
149
140
|
### 1. Initialize your project
|
|
150
141
|
|
|
@@ -155,13 +146,13 @@ md init
|
|
|
155
146
|
|
|
156
147
|
```
|
|
157
148
|
|
|
158
|
-
This will create the `AGENTS.md` and `SKILL.md` files in the root directory, containing the global instructions that will guide the AI in understanding the MDDD methodology and interacting with Git logs.
|
|
149
|
+
This will create the `AGENTS.md` and `SKILL.md` files in the root directory, containing the global instructions that will guide the AI in understanding the MDDD methodology and interacting with Git logs.
|
|
159
150
|
|
|
160
151
|
### 2. Audit legacy files or make new ones.
|
|
161
152
|
|
|
162
153
|
- Tell AI to `md-audit` the file you want to review. If it's clean and concise, AI will create the spec based on it. If it's not, then AI will propose a refactoring with the "to-be" spec.
|
|
163
154
|
|
|
164
|
-
- Tell AI to `md-new` a specification you need, connect to a Jira/Task, to a Figma/Design or simple tell AI what
|
|
155
|
+
- Tell AI to `md-new` a specification you need, connect to a Jira/Task, to a Figma/Design or simple tell AI what to do.
|
|
165
156
|
|
|
166
157
|
### 3. Implement the specification.
|
|
167
158
|
|
|
@@ -184,6 +175,33 @@ After running `md init`, your AI will understand these shortcuts when you type t
|
|
|
184
175
|
| `md-edit` | Requests changes to an existing `.spec.md` file (increments semantic version). |
|
|
185
176
|
| `md-audit` | Analyzes legacy code and proposes visual refactoring (Mermaid). |
|
|
186
177
|
| `md-impl` | Generates code and tests strictly based on the `.spec.md` layout, managing version history. |
|
|
178
|
+
| `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. |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 🗺️ Architecture Context Map
|
|
183
|
+
|
|
184
|
+
The `mddd-context-map` skill teaches the AI agent to produce a **product architecture diagram** that visualizes your system at **multiple levels**:
|
|
185
|
+
|
|
186
|
+
- **Macro areas (domains)** — each MACRO spec represents a high-level domain or business capability.
|
|
187
|
+
- **Micro components/services** — MICRO specs are the building blocks inside each domain.
|
|
188
|
+
- **Data flows** — connections between users, UI, backend, serverless functions, and external infrastructure.
|
|
189
|
+
|
|
190
|
+
The output is a stylized **`flowchart LR`** that combines domain grouping with internal components and external integrations, using `classDef` styling to differentiate node types:
|
|
191
|
+
|
|
192
|
+
| Node Class | Purpose | Visual |
|
|
193
|
+
| :--- | :--- | :--- |
|
|
194
|
+
| `userNode` | People, personas, roles | Warm yellow |
|
|
195
|
+
| `systemNode` | Internal services/components | Professional blue |
|
|
196
|
+
| `externalNode` | Third-party APIs, partner systems | Stand-out red-orange |
|
|
197
|
+
| `infraNode` | Databases, queues, caches | Subdued italic gray |
|
|
198
|
+
|
|
199
|
+
### How to use
|
|
200
|
+
|
|
201
|
+
1. Initialize your project with `md init` (this copies the architecture template to `.agents/templates/`).
|
|
202
|
+
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.
|
|
203
|
+
3. The output is saved to `ARCHITECTURE.spec.md` at the project root.
|
|
204
|
+
4. Every diagram is validated with `npx md validate` before being written.
|
|
187
205
|
|
|
188
206
|
---
|
|
189
207
|
|
|
@@ -208,8 +226,9 @@ src/
|
|
|
208
226
|
## 📦 CLI Commands
|
|
209
227
|
|
|
210
228
|
| Command | Description |
|
|
211
|
-
|
|
|
229
|
+
| :--- | :--- |
|
|
212
230
|
| `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. |
|
|
231
|
+
| `md status` | Generates a beautiful MDDD coverage report with metrics from all `.spec.md` files. Shows specs classification (Cohesive/Chaotic), discovery tasks progress, version changes, and impact metrics. |
|
|
213
232
|
|
|
214
233
|
### Project Architecture
|
|
215
234
|
|
|
@@ -222,10 +241,23 @@ bin/
|
|
|
222
241
|
|
|
223
242
|
src/
|
|
224
243
|
├── commands/ # Command layer
|
|
225
|
-
│
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
244
|
+
│ ├── init.js # Init command
|
|
245
|
+
│ ├── listSpecs.js # List specs command
|
|
246
|
+
│ ├── status.js # Status command
|
|
247
|
+
│ ├── status.spec.md # Status spec
|
|
248
|
+
│ └── validator.js # Validator utility
|
|
249
|
+
├── services/ # Shared services with DI
|
|
250
|
+
│ ├── FileSystemService.js
|
|
251
|
+
│ ├── FileSystemService.spec.md
|
|
252
|
+
│ ├── InitService.js
|
|
253
|
+
│ ├── InitService.spec.md
|
|
254
|
+
│ └── SpecFinderService.js
|
|
255
|
+
|
|
256
|
+
tests/
|
|
257
|
+
├── commands/
|
|
258
|
+
│ ├── init.spec.js
|
|
259
|
+
│ ├── listSpecs.spec.js
|
|
260
|
+
│ └── status.spec.js
|
|
229
261
|
```
|
|
230
262
|
|
|
231
263
|
---
|
|
@@ -248,244 +280,4 @@ If you encounter any issues, open a [GitHub Issue](https://github.com/JulioCRFil
|
|
|
248
280
|
|
|
249
281
|
## 📄 License
|
|
250
282
|
|
|
251
|
-
Distributed under the MIT license. See the [LICENSE](
|
|
252
|
-
|
|
253
|
-
---
|
|
254
|
-
<a id="portuguese"></a>
|
|
255
|
-
|
|
256
|
-
# 🇧🇷 Português
|
|
257
|
-
|
|
258
|
-
Uma CLI agnóstica, ultra-leve e cirúrgica para implementar **MDDD (Mermaid Diagram Driven Development)** de forma modular, colocalizada e estritamente versionada.
|
|
259
|
-
|
|
260
|
-
Esta ferramenta automatiza a criação e a conexão de arquivos de especificação visual (Markdown + Mermaid + Matrizes de Decisão) através do comando `md init`. O objetivo é envelopar as regras de negócio em arquivos `.spec.md` para que qualquer ferramenta de IA (**Cursor, Windsurf, Claude Code, GitHub Copilot**, etc.) use esses assets como a **Fonte Única da Verdade** antes de tocar no código produtivo.
|
|
261
|
-
|
|
262
|
-
---
|
|
263
|
-
|
|
264
|
-
## 📌 O Conceito: MDDD vs. Especificações em Texto
|
|
265
|
-
|
|
266
|
-
Ao contrário de frameworks tradicionais de especificação que geram dezenas de arquivos de texto e "deltas" que poluem o seu repositório, o MDDD introduz um paradigma **Visual-First & Focado em Fluxo**:
|
|
267
|
-
|
|
268
|
-
1. **Um Mapa Real da Arquitetura:** Em vez de mapas em formato de texto chapado, o MDDD permite conectar micro-especificações em uma visão macro do sistema. Ele se comporta como um mapa geográfico real de toda a sua arquitetura de software.
|
|
269
|
-
2. **Projetado para Alta Complexidade e CRUDs Gigantes:** Estados complexos, validações de múltiplos perfis e regras de negócio densas são estruturadas dentro de **Matrizes de Decisão** em tabelas markdown. Isso elimina a saturação visual dos layouts e resolve comportamentos complexos com precisão matemática.
|
|
270
|
-
3. **Poluição Zero de Arquivos (Nativo do Git):** Os requisitos mudam e são versionados diretamente no próprio local original. As IAs que utilizam recursos de terminal ou **MCP (Model Context Protocol)** podem consultar o histórico do Git instantaneamente para entender as mudanças evolutivas, significando zero arquivos temporários ou lixo arquitetural.
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
## ⚖️ MDDD vs. OpenSpec (SDD)
|
|
275
|
-
|
|
276
|
-
| Funcionalidade / Paradigma | OpenSpec (Specification Driven Development) | MDDD (Mermaid Diagram Driven Development) |
|
|
277
|
-
| --- | --- | --- |
|
|
278
|
-
| **Estrutura Lógica** | Parágrafos textuais, regras verbosas e cenários conversacionais. | Matrizes de Decisão Binárias/Factuais + Topologias Estruturais Estritas. |
|
|
279
|
-
| **Consumo de Contexto da IA** | Alto consumo de tokens devido a descrições comportamentais massivas em texto. | Consumo ultra-baixo de tokens através de tabelas de verdade concisas em matrizes. |
|
|
280
|
-
| **Estimativa de Tokens (10 regras)** | **~8.000 – 12.000 tokens** (parágrafos + descrições de cenário + casos de borda) | **~800 – 1.500 tokens** (10 linhas × 6 colunas de fatores ≈ 60 células de texto curto) |
|
|
281
|
-
| **Estimativa de Tokens (50 regras)** | **~40.000 – 60.000 tokens** (janela de contexto inteira pode ser consumida) | **~4.000 – 7.500 tokens** (ainda cabe confortavelmente em um contexto pequeno) |
|
|
282
|
-
| **Escalabilidade** | Adicionar regras cria blocos de texto massivos propensos a fragmentação de prompt. | Adicionar regras escala horizontalmente anexando colunas precisas de fatores. |
|
|
283
|
-
| **Controle de Ambiguidade** | Alto risco de alucinação de LLM ao interpretar frases aninhadas de "se/senão". | Precisão matemática pura; processamento determinístico via linhas de matriz. |
|
|
284
|
-
| **Pegada da Ferramenta** | Boilerplate massivo com poluição de arquivos internos e estruturas complexas de pastas. | Ultra-leve e modular: um router enxuto + módulos de comando e serviço claramente separados, cada um facilmente auditável. |
|
|
285
|
-
|
|
286
|
-
### 🚀 Por que as Matrizes de Decisão MDDD Superam o OpenSpec:
|
|
287
|
-
|
|
288
|
-
* **Tokens Previsíveis:** Para uma LLM, ler essa tabela é idêntico a processar uma matriz binária de verdade. Ela bate o olho nas colunas de fatores primitivos (`Tenant Ativo?`, `Kill Switch Global Ativo?`) e sabe exatamente se a combinação resulta em `ALLOW` ou `DENY` sem gastar processamento léxico ou tokens desnecessários.
|
|
289
|
-
* **10× a 15× Menos Tokens:** Uma regra de negócio complexa com 6 fatores variáveis custa ~800 tokens em MDDD vs ~8.000+ tokens em OpenSpec (parágrafos + descrições de casos de borda). Conforme as regras crescem, MDDD se mantém linear enquanto OpenSpec cresce exponencialmente em verborragia.
|
|
290
|
-
* **Infinitas Colunas = Infinitas Variáveis:** Se o seu sistema ganhar uma nova regra arquitetural (ex: `Ambiente é Produção?` ou `IP em White-list?`), basta adicionar uma nova coluna na matriz. A lógica de negócio expande horizontalmente sem poluir ou quebrar os fluxos visuais do Mermaid.
|
|
291
|
-
* **Substituição Real do OpenSpec:** O OpenSpec precisa escrever parágrafos descritivos e cenários de teste para cobrir combinações complexas de restrições. O MDDD resolve isso em uma única linha de tabela determinística, economizando o contexto do prompt e eliminando completamente alucinações da IA.
|
|
292
|
-
|
|
293
|
-
---
|
|
294
|
-
|
|
295
|
-
## 🛠️ O Pipeline MDDD
|
|
296
|
-
|
|
297
|
-
| Etapa | Ator | Ação / Gatilho | O que acontece |
|
|
298
|
-
| --- | --- | --- | --- |
|
|
299
|
-
| **1. Entrada** | Humano | Solicitação de Funcionalidade | O usuário propõe uma funcionalidade em linguagem natural, aponta a IA diretamente para uma Issue/Task do Jira ou GitHub, ou pede para a IA auditar um arquivo legado. |
|
|
300
|
-
| **2. Concepção** | IA | Autogeração | A IA avalia o escopo e constrói o arquivo `.spec.md` completo com diagramas de fluxo, ciclos de vida e as **Matrizes de Decisão** necessárias. |
|
|
301
|
-
| **3. Alinhamento** | Humano | Revisão Interativa | O usuário revisa a especificação dentro do editor. Os refinamentos são feitos de forma iterativa conversando com a IA. |
|
|
302
|
-
| **4. Planning** | IA | Quebra de Tarefas | Com a spec aprovada, a IA extrai um checklist granular e atômico dos passos de desenvolvimento diretamente dentro do arquivo. |
|
|
303
|
-
| **5. Execução** | IA | Geração de Código | A IA implementa o código produtivo e os testes baseando-se estritamente nas specs, atualizando o versionamento semântico ao concluir. |
|
|
304
|
-
|
|
305
|
-
---
|
|
306
|
-
|
|
307
|
-
## ✅ Pré-visualização dos Diagramas Mermaid
|
|
308
|
-
|
|
309
|
-
Para visualizar diagramas Mermaid diretamente no seu editor durante o fluxo MDDD, você pode usar extensões que renderizam blocos `mermaid` em arquivos Markdown:
|
|
310
|
-
|
|
311
|
-
### Exemplo de Diagrama Arquitetural
|
|
312
|
-
|
|
313
|
-
```mermaid
|
|
314
|
-
sequenceDiagram
|
|
315
|
-
autonumber
|
|
316
|
-
actor U as Usuário Merchant (Lojista)
|
|
317
|
-
actor A as Admin da Plataforma
|
|
318
|
-
participant Core as Core da Plataforma (Orquestrador)
|
|
319
|
-
participant Registry as Registro de Micro-Apps
|
|
320
|
-
participant Sandbox as Sandbox de Execução (Contexto Isolado)
|
|
321
|
-
participant TenantDB as Multi-Banco do Tenant
|
|
322
|
-
participant Billing as Motor de Tarifação (Uso Medido)
|
|
323
|
-
|
|
324
|
-
Note over U, Core: Cenário: Lojista tenta executar um micro-app customizado premium.
|
|
325
|
-
|
|
326
|
-
U->>Core: Requisita Execução do App (TenantID, AppID)
|
|
327
|
-
Core->>Registry: Busca Manifesto do Micro-App & Permissões de Escopo
|
|
328
|
-
Registry-->>Core: Retorna Manifesto (Escopos de API Requeridos, Nível de Tier)
|
|
329
|
-
|
|
330
|
-
Note over Core, TenantDB: Validação Dinâmica de Segurança & Multitenancy
|
|
331
|
-
Core->>TenantDB: Checa Assinatura do Tenant & Feature Flags
|
|
332
|
-
TenantDB-->>Core: Tenant Autorizado (Licença Ativa)
|
|
333
|
-
|
|
334
|
-
Core->>Billing: Rastreia Evento de Execução (API de Uso Medido)
|
|
335
|
-
activate Billing
|
|
336
|
-
Billing->>Billing: Registra Consumo de Tokens/Processamento
|
|
337
|
-
deactivate Billing
|
|
338
|
-
|
|
339
|
-
Note over Core, Sandbox: Initializing Sandbox em Container
|
|
340
|
-
Core->>Sandbox: Injeta Token de Segurança & Proxies de SDK Restritos
|
|
341
|
-
Core->>Sandbox: Inicializa o Bundle Frontend/Backend do Micro-App
|
|
342
|
-
|
|
343
|
-
activate Sandbox
|
|
344
|
-
Sandbox->>Sandbox: Executa Ciclo de Vida do Micro-App (onInit)
|
|
345
|
-
Sandbox->>Core: Chamada de API Restrita (Escrita de Dados do Tenant)
|
|
346
|
-
Core->>TenantDB: Persiste Mudanças com Segurança no Isolamento do Tenant
|
|
347
|
-
Sandbox-->>U: Renderiza Fragmento de UI Isolado / Micro-Frontend
|
|
348
|
-
deactivate Sandbox
|
|
349
|
-
|
|
350
|
-
Note over A, Core: Admin da Plataforma pode substituir a quente ou depreciar apps globalmente.
|
|
351
|
-
A->>Core: Deprecia Versão do App (Flag Global)
|
|
352
|
-
Core->>Registry: Atualiza Status para "DEPRECATED"
|
|
353
|
-
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
### Exemplo de Matriz de Decisão de Ciclo de Vida & Runtime de Micro-Apps
|
|
357
|
-
|
|
358
|
-
| Tenant Ativo? | App Premium? | Tier de Faturamento Ativo? | Usuário é Admin? | App em White-list? | Kill Switch Global Ativo? | Ação Proposta | Decisão (Resultado) | Estado de Transição (Novo Status) |
|
|
359
|
-
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
360
|
-
| ❌ NÃO | - | - | - | - | - | `BOOT_APP` | ❌ **DENY (Negar)** | - |
|
|
361
|
-
| ✅ SIM | ❌ NÃO | **FREE** | ❌ NÃO | ✅ SIM | ❌ NÃO | `BOOT_APP` | ✅ **ALLOW (Permitir)** | `ACTIVE_RUNTIME` |
|
|
362
|
-
| ✅ SIM | ✅ SIM | **FREE** | - | - | ❌ NÃO | `INSTALL_APP` | ❌ **DENY (Negar)** | - (Dispara Upsell) |
|
|
363
|
-
| ✅ SIM | ✅ SIM | **ENTERPRISE** | ✅ SIM | ✅ SIM | ❌ NÃO | `INSTALL_APP` | ✅ **ALLOW (Permitir)** | `INSTALLED` |
|
|
364
|
-
| ✅ SIM | - | - | ❌ NÃO | - | ❌ NÃO | `CONFIG_API` | ❌ **DENY (Negar)** | - |
|
|
365
|
-
| ✅ SIM | - | - | ✅ SIM | - | ❌ NÃO | `CONFIG_API` | ✅ **ALLOW (Permitir)** | `CONFIGURED` |
|
|
366
|
-
| ✅ SIM | - | - | - | - | ✅ SIM | `BOOT_APP` | ❌ **DENY (Negar)** | `MUTED_ISOLATION` |
|
|
367
|
-
| ✅ SIM | - | - | - | - | ✅ SIM | `HOT_RELOAD` | ❌ **DENY (Negar)** | - |
|
|
368
|
-
| ❌ NÃO | - | - | - | - | - | `PURGE_DATA` | ❌ **DENY (Negar)** | - |
|
|
369
|
-
|
|
370
|
-
---
|
|
371
|
-
|
|
372
|
-
## 📥 Instalação
|
|
373
|
-
|
|
374
|
-
Como o pacote está publicado no NPM, a instalação é global e simples:
|
|
375
|
-
|
|
376
|
-
```bash
|
|
377
|
-
# Instalação global
|
|
378
|
-
npm install -g mddd-cli
|
|
379
|
-
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
> **Note:** Certifique-se de ter o **Node.js v18 ou superior** instalado em sua máquina.
|
|
383
|
-
|
|
384
|
-
---
|
|
385
|
-
|
|
386
|
-
## 🚀 Guia de Uso Rápido
|
|
387
|
-
|
|
388
|
-
O fluxo MDDD é baseado em skills para orquestrar a IA no chat.
|
|
389
|
-
|
|
390
|
-
### 1. Inicialize seu projeto
|
|
391
|
-
|
|
392
|
-
Na raiz do seu projeto, execute:
|
|
393
|
-
|
|
394
|
-
```bash
|
|
395
|
-
md init
|
|
396
|
-
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
Isso criará os arquivos `AGENTS.md` e `SKILL.md` no diretório raiz, contendo as instruções globais que guiarão a IA na compreensão da metodologia MDDD e na interação com os logs do Git. Você pode renomear `AGENTS.md` para qualquer arquivo .rules que precisar (.cursorrules, .clinerules, etc.).
|
|
400
|
-
|
|
401
|
-
### 2. Auditar arquivos legados ou criar novos.
|
|
402
|
-
|
|
403
|
-
* Diga à IA para executar `md-audit` no arquivo que você deseja revisar. Se ele estiver limpo e conciso, a IA criará a especificação com base nele. Caso contrário, a IA proporá uma refatoração com a especificação ideal ("to-be").
|
|
404
|
-
* Diga à IA para executar `md-new` para uma especificação que você precisa, conectar a um Jira/Tarefa, a um Figma/Design ou simplesmente diga à IA o que você precisa.
|
|
405
|
-
|
|
406
|
-
### 3. Implementar a especificação.
|
|
407
|
-
|
|
408
|
-
Diga à IA para executar `md-impl` apontando para um arquivo .spec. Ela lerá toda a especificação, criará a lista de tarefas e começará a trabalhar nela.
|
|
409
|
-
|
|
410
|
-
### 4. Editar especificações existentes.
|
|
411
|
-
|
|
412
|
-
Se você precisar adicionar uma nova funcionalidade ou modificar uma existente, basta dizer à IA para executar `md-edit` no arquivo .spec com as modificações desejadas.
|
|
413
|
-
Revise até obter exatamente a especificação de que precisa e, em seguida, diga à IA para executá-lo com `md-impl`.
|
|
414
|
-
|
|
415
|
-
---
|
|
416
|
-
|
|
417
|
-
## 🤖 SKILLS (Gatilhos para IA)
|
|
418
|
-
|
|
419
|
-
Após rodar o `md init`, a sua IA passará a entender estes atalhos quando você os digitar no chat:
|
|
420
|
-
|
|
421
|
-
| Skill | Descrição |
|
|
422
|
-
| --- | --- |
|
|
423
|
-
| `md-new` | Inicia o modo de desenho para uma nova feature a partir de texto ou link de issue (gera diagramas/matrizes). |
|
|
424
|
-
| `md-edit` | Solicita alterações em um arquivo `.spec.md` existente (incrementa a versão semântica). |
|
|
425
|
-
| `md-audit` | Analisa código legado e propõe refatoração visual (Mermaid). |
|
|
426
|
-
| `md-impl` | Gera código e testes baseando-se estritamente na estrutura do `.spec.md`, gerenciando o histórico de versões. |
|
|
427
|
-
|
|
428
|
-
---
|
|
429
|
-
|
|
430
|
-
## 🏗️ Arquitetura de Especificação Colocalizada (Co-location)
|
|
431
|
-
|
|
432
|
-
As especificações visuais não ficam centralizadas em pastas distantes. Elas vivem no **mesmo diretório** do componente, tela ou feature que descrevem, mapeando o software de forma nativa.
|
|
433
|
-
|
|
434
|
-
```
|
|
435
|
-
src/
|
|
436
|
-
└── home/
|
|
437
|
-
├── home.spec.md # 🌎 Mapa global do módulo
|
|
438
|
-
├── guest/
|
|
439
|
-
│ ├── guest.spec.md # 🔬 Fluxo de tela com Matriz de Decisão
|
|
440
|
-
│ └── guest_page.dart # 💻 Código produtivo gerado pela IA
|
|
441
|
-
└── consumer/
|
|
442
|
-
└── consumer.spec.md # 🔬 Fluxo de tela com Matriz de Decisão
|
|
443
|
-
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
---
|
|
447
|
-
|
|
448
|
-
## 📦 Comandos da CLI
|
|
449
|
-
|
|
450
|
-
| Comando | Descrição |
|
|
451
|
-
| --- | --- |
|
|
452
|
-
| `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. |
|
|
453
|
-
|
|
454
|
-
### Arquitetura do Projeto
|
|
455
|
-
|
|
456
|
-
O código-fonte da CLI segue uma arquitetura modular limpa, conforme documentado em `bin/cli.spec.md`:
|
|
457
|
-
|
|
458
|
-
```
|
|
459
|
-
bin/
|
|
460
|
-
├── cli.js # Router Commander enxuto (< 30 linhas)
|
|
461
|
-
└── cli.spec.md # Spec colocalizada (v3.0.0)
|
|
462
|
-
|
|
463
|
-
src/
|
|
464
|
-
├── commands/ # Camada de comandos
|
|
465
|
-
│ └── init.js
|
|
466
|
-
└── services/ # Serviços compartilhados com DI
|
|
467
|
-
├── FileSystemService.js
|
|
468
|
-
└── InitService.js
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
---
|
|
472
|
-
|
|
473
|
-
## 🧪 Tecnologias
|
|
474
|
-
|
|
475
|
-
* **Node.js** >= 18
|
|
476
|
-
* **Commander.js** — Interface CLI robusta e declarativa
|
|
477
|
-
* **Picocolors** — Saída colorida e leve no terminal
|
|
478
|
-
* **Mermaid.js** — Diagramação visual como fonte da verdade
|
|
479
|
-
* **Test Runner Nativo** (`node:test`) — Testes unitários sem dependências externas
|
|
480
|
-
|
|
481
|
-
---
|
|
482
|
-
|
|
483
|
-
## 💬 Precisa de ajuda?
|
|
484
|
-
|
|
485
|
-
Se encontrar qualquer problema, abra uma [Issue no GitHub](https://github.com/JulioCRFilho/mermaid-diagram-driven-development/issues).
|
|
486
|
-
|
|
487
|
-
---
|
|
488
|
-
|
|
489
|
-
## 📄 Licença
|
|
490
|
-
|
|
491
|
-
Distribuído sob a licença MIT. Veja o arquivo [LICENSE](https://www.google.com/search?q=LICENSE) para mais informações.
|
|
283
|
+
Distributed under the MIT license. See the [LICENSE](./LICENSE) file for more information.
|
package/src/commands/init.js
CHANGED
|
@@ -5,8 +5,6 @@ import { fileURLToPath } from 'node:url';
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import pc from 'picocolors';
|
|
7
7
|
|
|
8
|
-
import { GITHUB_WORKFLOW_CONTENT } from '../workflows/mddd-preview.yml.js';
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* Resolve and read AGENTS.md from the project root.
|
|
12
10
|
* @returns {string}
|
|
@@ -40,9 +38,6 @@ export async function execute(initService) {
|
|
|
40
38
|
// 3. Passa o caminho da pasta oculta de origem para o serviço clonar recursivamente
|
|
41
39
|
await initService.createSkills(cliSkillsSourceDir, (msg) => console.log(msg));
|
|
42
40
|
|
|
43
|
-
// 4. Cria o workflow do GitHub
|
|
44
|
-
await initService.createGitHubWorkflow(GITHUB_WORKFLOW_CONTENT, (msg) => console.log(msg));
|
|
45
|
-
|
|
46
41
|
// 5. Copia o spec template para o projeto
|
|
47
42
|
await initService.createSpecTemplate(cliSpecTemplatePath, (msg) => console.log(msg));
|
|
48
43
|
|
|
@@ -58,23 +58,6 @@ export class InitService {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
/**
|
|
62
|
-
* Creates (or overwrites) the GitHub Actions workflow for Mermaid diagram preview on PRs.
|
|
63
|
-
* @param {string} workflowYaml - The YAML content for the GitHub workflow
|
|
64
|
-
* @param {(message: string) => void} logger
|
|
65
|
-
* @returns {Promise<string>} Path to the created workflow file
|
|
66
|
-
*/
|
|
67
|
-
async createGitHubWorkflow(workflowYaml, logger) {
|
|
68
|
-
const workflowsDir = path.join('.github', 'workflows');
|
|
69
|
-
const workflowFile = path.join(workflowsDir, 'mddd-preview.yml');
|
|
70
|
-
|
|
71
|
-
this.#fs.ensureDir(workflowsDir);
|
|
72
|
-
await this.#fs.writeFile(workflowFile, workflowYaml);
|
|
73
|
-
logger(`✅ GitHub workflow created: ${workflowFile}`);
|
|
74
|
-
|
|
75
|
-
return workflowFile;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
61
|
/**
|
|
79
62
|
* Copies the spec template file from the CLI package to the project's .agents/templates/ directory.
|
|
80
63
|
* @param {string} sourceTemplatePath - Absolute path to the CLI source spec-template.md
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# InitService — Specification
|
|
2
2
|
|
|
3
|
-
**SPEC_VERSION:** v1.
|
|
3
|
+
**SPEC_VERSION:** v1.3.0 — stable
|
|
4
4
|
**Classification:** Coeso
|
|
5
5
|
|
|
6
6
|
## Overview
|
|
@@ -14,7 +14,7 @@ Co-located with `src/services/InitService.js`.
|
|
|
14
14
|
## Behavioral Flow (Mermaid)
|
|
15
15
|
|
|
16
16
|
```mermaid
|
|
17
|
-
%% @spec-version v1.
|
|
17
|
+
%% @spec-version v1.3.0
|
|
18
18
|
stateDiagram-v2
|
|
19
19
|
[*] --> createSystemPrompt: initService.createSystemPrompt(promptContent)
|
|
20
20
|
createSystemPrompt --> writeFile: this.#fs.writeFile('AGENTS.md', content)
|
|
@@ -24,12 +24,7 @@ stateDiagram-v2
|
|
|
24
24
|
ensureAgentsDir --> ensureTargetSkillsDir: this.#fs.ensureDir('.agents/skills')
|
|
25
25
|
ensureTargetSkillsDir --> cpSyncSkills: fs.cpSync(source, target, recursive)
|
|
26
26
|
cpSyncSkills --> logSkills: logger per copied skill
|
|
27
|
-
logSkills -->
|
|
28
|
-
|
|
29
|
-
createGitHubWorkflow --> ensureWorkflowDir: this.#fs.ensureDir('.github/workflows')
|
|
30
|
-
ensureWorkflowDir --> writeWorkflowFile: this.#fs.writeFile('.github/workflows/mddd-preview.yml', content)
|
|
31
|
-
writeWorkflowFile --> logWorkflow: logger(`✅ GitHub workflow created`)
|
|
32
|
-
logWorkflow --> createSpecTemplate: initService.createSpecTemplate(sourceTemplatePath, logger)
|
|
27
|
+
logSkills --> createSpecTemplate: initService.createSpecTemplate(sourceTemplatePath, logger)
|
|
33
28
|
|
|
34
29
|
createSpecTemplate --> ensureTemplatesDir: this.#fs.ensureDir('.agents/templates')
|
|
35
30
|
ensureTemplatesDir --> writeTemplateFile: this.#fs.writeFile('.agents/templates/spec-template.md', content)
|
|
@@ -45,12 +40,10 @@ stateDiagram-v2
|
|
|
45
40
|
| :--- | :--- | :--- | :---: | :--- | :--- |
|
|
46
41
|
| 1 | `createSystemPrompt(promptContent)` | Input: `string`<br>Output: `Promise<void>` | ❌ No | Delegated to `#fs.writeFile` | ✅ Writes `AGENTS.md` |
|
|
47
42
|
| 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 |
|
|
48
|
-
| 3 | `
|
|
49
|
-
| 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` |
|
|
43
|
+
| 3 | `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` |
|
|
50
44
|
| 5 | `this.#fs.ensureDir(agentsDir)` | Path: `'.agents'` | ✅ Internal in FS: conditional mkdir | Delegated | ✅ Dir creation |
|
|
51
45
|
| 6 | `this.#fs.ensureDir(skillsDir)` | Path: `'.agents/skills'` | ✅ Internal in FS: conditional mkdir | Delegated | ✅ Dir creation |
|
|
52
|
-
| 7 | `this.#fs.ensureDir(
|
|
53
|
-
| 8 | `this.#fs.ensureDir(templatesDir)` | Path: `'.agents/templates'` | ✅ Internal in FS: conditional mkdir | Delegated | ✅ Dir creation |
|
|
46
|
+
| 7 | `this.#fs.ensureDir(templatesDir)` | Path: `'.agents/templates'` | ✅ Internal in FS: conditional mkdir | Delegated | ✅ Dir creation |
|
|
54
47
|
| 9 | `logger(…)` | stdout message | ❌ No | N/A | ❌ None |
|
|
55
48
|
|
|
56
49
|
---
|
|
@@ -80,7 +73,6 @@ stateDiagram-v2
|
|
|
80
73
|
| :--- | :--- | :---: | :--- |
|
|
81
74
|
| 2026-06-09 | Cline (md-audit) | v1.2.1 | **Fixed SPEC_VERSION header format** (added colon separator per template spec) and **added Classification: Coeso** — aligns with the existing code quality (DI, modular, well-structured orchestration). PATCH bump. |
|
|
82
75
|
| 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). |
|
|
83
|
-
| 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. |
|
|
84
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. |
|
|
85
77
|
|
|
86
78
|
</details>
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GitHub Actions workflow YAML for automated full specification and native Mermaid preview on PRs.
|
|
3
|
-
* Extracted from init.js v1.5.0 domain extraction.
|
|
4
|
-
*/
|
|
5
|
-
export const GITHUB_WORKFLOW_CONTENT = [
|
|
6
|
-
"name: 🗺️ MDDD Full Spec Preview",
|
|
7
|
-
"",
|
|
8
|
-
"on:",
|
|
9
|
-
" pull_request:",
|
|
10
|
-
" paths:",
|
|
11
|
-
" - '**/*.spec.md'",
|
|
12
|
-
"",
|
|
13
|
-
"jobs:",
|
|
14
|
-
" render-preview:",
|
|
15
|
-
" runs-on: ubuntu-latest",
|
|
16
|
-
" permissions:",
|
|
17
|
-
" pull-requests: write",
|
|
18
|
-
" contents: read",
|
|
19
|
-
"",
|
|
20
|
-
" steps:",
|
|
21
|
-
" - name: ⬇️ Checkout Repository",
|
|
22
|
-
" uses: actions/checkout@v4",
|
|
23
|
-
" with:",
|
|
24
|
-
" fetch-depth: 0", // CRUCIAL: Traz o histórico completo para o git diff funcionar
|
|
25
|
-
"",
|
|
26
|
-
" - name: 📸 Build Preview Comment",
|
|
27
|
-
" id: build-comment",
|
|
28
|
-
' run: |',
|
|
29
|
-
' echo "comment<<EOF" >> "$GITHUB_OUTPUT"',
|
|
30
|
-
' echo "### 🗺️ MDDD - Design Changes Detected!" >> "$GITHUB_OUTPUT"',
|
|
31
|
-
' echo "Review the proposed specification and visual topology below before approving." >> "$GITHUB_OUTPUT"',
|
|
32
|
-
' echo "" >> "$GITHUB_OUTPUT"',
|
|
33
|
-
"",
|
|
34
|
-
' # Busca os arquivos modificados comparando dinamicamente com a branch destino do PR',
|
|
35
|
-
' CHANGED=$(git diff --name-only "origin/${{ github.base_ref }}...HEAD" -- "*.spec.md" 2>/dev/null || echo "")',
|
|
36
|
-
"",
|
|
37
|
-
" for file in $CHANGED; do",
|
|
38
|
-
' [ -f "$file" ] || continue',
|
|
39
|
-
' echo "" >> "$GITHUB_OUTPUT"',
|
|
40
|
-
' echo "#### 📄 File: \`${file}\`" >> "$GITHUB_OUTPUT"',
|
|
41
|
-
' echo "" >> "$GITHUB_OUTPUT"',
|
|
42
|
-
' echo "<details open>" >> "$GITHUB_OUTPUT"',
|
|
43
|
-
' echo "<summary>Click to collapse full specification preview</summary>" >> "$GITHUB_OUTPUT"',
|
|
44
|
-
' echo "" >> "$GITHUB_OUTPUT"',
|
|
45
|
-
"",
|
|
46
|
-
' # Injeta o conteúdo completo do arquivo markdown',
|
|
47
|
-
' cat "$file" >> "$GITHUB_OUTPUT"',
|
|
48
|
-
' echo "" >> "$GITHUB_OUTPUT"',
|
|
49
|
-
"",
|
|
50
|
-
' echo "</details>" >> "$GITHUB_OUTPUT"',
|
|
51
|
-
' echo "" >> "$GITHUB_OUTPUT"',
|
|
52
|
-
" done",
|
|
53
|
-
"",
|
|
54
|
-
' echo "EOF" >> "$GITHUB_OUTPUT"',
|
|
55
|
-
"",
|
|
56
|
-
" - name: 💬 Comment Preview on PR",
|
|
57
|
-
" uses: thollander/actions-comment-pull-request@v2",
|
|
58
|
-
" with:",
|
|
59
|
-
' message: "${{ steps.build-comment.outputs.comment }}"',
|
|
60
|
-
" comment_tag: 'mddd-design-preview'",
|
|
61
|
-
].join('\n');
|