mddd-cli 4.0.1 → 4.0.3
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
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('4.0.
|
|
19
|
+
.version('4.0.3');
|
|
20
20
|
|
|
21
21
|
// ==========================================
|
|
22
22
|
// COMMAND: md init
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
export default `[ROLE: SECURITY & QUALITY AUDITOR] [STRICT CONTRACT]
|
|
2
2
|
|
|
3
3
|
\`\`\`mermaid
|
|
4
|
-
%% @spec-version v1.3.
|
|
4
|
+
%% @spec-version v1.3.2
|
|
5
5
|
stateDiagram-v2
|
|
6
|
-
[*] --> Evaluation: Quality Assessment
|
|
7
|
-
Evaluation --> MakeSpec: Co-located .spec.md
|
|
6
|
+
[*] --> Evaluation: Quality Assessment.
|
|
7
|
+
Evaluation --> MakeSpec: Co-located .spec.md.
|
|
8
8
|
|
|
9
9
|
state MakeSpec {
|
|
10
|
-
[*] --> SpecExists: Check for existing .spec.md
|
|
11
|
-
SpecNotFound --> CreateSpec: Create
|
|
10
|
+
[*] --> SpecExists: Check for existing .spec.md.
|
|
11
|
+
SpecNotFound --> CreateSpec: Create .spec.md from "src/templates/spec-template.md".
|
|
12
12
|
SpecExists --> Break: Audit only.
|
|
13
13
|
Break --> [*]
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
CreateSpec --> RenderTopology: Create new co-located .spec.md
|
|
16
|
+
CreateSpec --> RenderTopology: Create new co-located .spec.md.
|
|
17
17
|
|
|
18
18
|
state RenderTopology {
|
|
19
19
|
[*] --> CheckCode: Analyze current code structure and dependencies
|
|
@@ -21,14 +21,16 @@ stateDiagram-v2
|
|
|
21
21
|
CheckCode --> EvaluatedCodeIsChaotic: Draw BOTH current chaotic logic AND ideal target refactored graph (v1.0.0 - draft)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
RenderTopology --> CheckDiagram: Use npx @mermaid-js/mermaid-cli to Validate Syntax
|
|
24
|
+
RenderTopology --> CheckDiagram: Use npx @mermaid-js/mermaid-cli to Validate Diagrams Syntax (Mandatory)
|
|
25
25
|
|
|
26
26
|
state CheckDiagram {
|
|
27
27
|
[*] --> DiagramValid: Proceed to next step
|
|
28
28
|
DiagramInvalid --> RenderTopology: Re-render until valid
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
CheckDiagram -->
|
|
31
|
+
CheckDiagram --> DiscoveryAnalysis: Identify potential vulnerabilities and code quality issues
|
|
32
|
+
DiscoveryAnalysis --> WriteToAuditTag: Document findings and recommendations in the .spec.md file
|
|
33
|
+
WriteToAuditTag: Inject payloads inside <details> block
|
|
32
34
|
WriteToAuditTag --> EnforceImmutability: Lock Production Code File
|
|
33
35
|
EnforceImmutability --> [*]
|
|
34
36
|
\`\`\`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default `[ROLE: ARCHITECT] [STRICT CONTRACT]
|
|
2
2
|
|
|
3
3
|
\`\`\`mermaid
|
|
4
|
-
%% @spec-version v1.3.
|
|
4
|
+
%% @spec-version v1.3.1
|
|
5
5
|
stateDiagram-v2
|
|
6
6
|
[*] --> Read TargetSpec: Read Target .spec.md
|
|
7
7
|
Read TargetSpec --> ParseVersion: Parse Current SPEC_VERSION
|
|
@@ -28,8 +28,8 @@ stateDiagram-v2
|
|
|
28
28
|
[*] --> TryRender
|
|
29
29
|
TryRender --> DiagramValid: Render succeeded
|
|
30
30
|
TryRender --> IncrementRetry: Render failed
|
|
31
|
-
IncrementRetry --> TryRender: Retry count <
|
|
32
|
-
IncrementRetry --> RenderFailed: Retry count >=
|
|
31
|
+
IncrementRetry --> TryRender: Retry count < 5
|
|
32
|
+
IncrementRetry --> RenderFailed: Retry count >= 5
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
CheckDiagram --> WriteToFile: Write validated .spec.md to target path
|
|
@@ -40,8 +40,9 @@ stateDiagram-v2
|
|
|
40
40
|
}
|
|
41
41
|
WriteError --> AwaitHumanReview: Error: manual intervention required
|
|
42
42
|
|
|
43
|
-
WriteSuccess -->
|
|
44
|
-
|
|
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
|
|
45
46
|
|
|
46
47
|
state AwaitHumanReview {
|
|
47
48
|
[*] --> Approved: Resume CI/CD pipeline
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default `[ROLE: ARCHITECT] [STRICT CONTRACT]
|
|
2
2
|
|
|
3
3
|
\`\`\`mermaid
|
|
4
|
-
%% @spec-version v1.3.
|
|
4
|
+
%% @spec-version v1.3.1
|
|
5
5
|
stateDiagram-v2
|
|
6
6
|
[*] --> TargetVerification
|
|
7
7
|
|
|
@@ -17,9 +17,9 @@ stateDiagram-v2
|
|
|
17
17
|
DiagramTypeInference --> InferNodes: Identify key nodes and relationships to be represented
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
EvaluateContext --> GenerateBlueprint: Create .spec.md
|
|
20
|
+
EvaluateContext --> GenerateBlueprint: Create .spec.md from "src/templates/spec-template.md".
|
|
21
21
|
GenerateBlueprint --> FormatSpecOutput: Format blueprint into target .spec.md structure
|
|
22
|
-
FormatSpecOutput --> CheckDiagram: Use npx @mermaid-js/mermaid-cli to Validate Syntax
|
|
22
|
+
FormatSpecOutput --> CheckDiagram: Use npx @mermaid-js/mermaid-cli to Validate Diagrams Syntax (Mandatory)
|
|
23
23
|
|
|
24
24
|
state CheckDiagram {
|
|
25
25
|
[*] --> DiagramValid: Proceed to next step
|
|
@@ -40,6 +40,6 @@ stateDiagram-v2
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
AppendCreationAudit --> AwaitHumanReview: Pause for user to review and adjust generated diagram
|
|
43
|
-
AwaitHumanReview --> [*]
|
|
43
|
+
AwaitHumanReview --> [*]
|
|
44
44
|
\`\`\`
|
|
45
45
|
`;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
%% @spec-version 1.0.0
|
|
2
|
+
%% @domain {{domain_name}}
|
|
3
|
+
%% @feature {{feature_name}}
|
|
4
|
+
%% @author {{author_name}}
|
|
5
|
+
|
|
6
|
+
# {{Feature Title}} — Specification
|
|
7
|
+
|
|
8
|
+
**SPEC_VERSION:** v1.0.0 — draft
|
|
9
|
+
|
|
10
|
+
> ⚠️ **This is a freshly generated MDDD spec template.**
|
|
11
|
+
> Replace every `{{placeholder}}`, remove this banner, and refine the diagram + matrix
|
|
12
|
+
> with the real business context before marking the spec as `stable`.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 1. Context
|
|
17
|
+
|
|
18
|
+
Describe **what** this spec governs and **why** it exists.
|
|
19
|
+
|
|
20
|
+
- **Domain:** `{{domain_name}}`
|
|
21
|
+
- **Feature / Module:** `{{feature_name}}`
|
|
22
|
+
- **Scope (in):** {{what is covered}}
|
|
23
|
+
- **Scope (out):** {{what is explicitly NOT covered}}
|
|
24
|
+
- **Owners:** {{team_or_person}}
|
|
25
|
+
- **Related specs:** {{parent_domain_spec, sibling_features}}
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 2. Behavioral Flow (Mermaid)
|
|
30
|
+
|
|
31
|
+
> Pick the diagram type that best fits the topology:
|
|
32
|
+
> `stateDiagram-v2` for lifecycles, `graph TD/LR` for procedural flows,
|
|
33
|
+
> `sequenceDiagram` for multi-actor protocols, `flowchart` for branching logic.
|
|
34
|
+
|
|
35
|
+
```mermaid
|
|
36
|
+
%% @spec-version 1.0.0
|
|
37
|
+
stateDiagram-v2
|
|
38
|
+
[*] --> Idle: initial entry point
|
|
39
|
+
|
|
40
|
+
state "Decision Node" as Decision
|
|
41
|
+
state "Happy Path" as Happy
|
|
42
|
+
state "Conflict / Halt" as Halt
|
|
43
|
+
|
|
44
|
+
Idle --> Decision: trigger event
|
|
45
|
+
Decision --> Happy: ✅ Primitive Factors match an ALLOW row
|
|
46
|
+
Decision --> Halt: ❌ No row matches / multiple rows match
|
|
47
|
+
Happy --> [*]
|
|
48
|
+
Halt --> [*]: escalate to human via Conflict Resolution
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Replace the diagram above with the real topology** for this feature.
|
|
52
|
+
Every node MUST correspond to a concrete state, action, or decision found in the Decision Matrix.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 3. Decision Matrix
|
|
57
|
+
|
|
58
|
+
The matrix below is the **deterministic truth table** that resolves the flow above.
|
|
59
|
+
Each row maps a combination of **Primitive Factors** → a `Proposed Action` → a `Decision` (`✅ ALLOW` / `❌ DENY`) → an optional `Transition State`.
|
|
60
|
+
|
|
61
|
+
### 3.1 Primitive Factors
|
|
62
|
+
|
|
63
|
+
| Factor | Type | Allowed Values | Default |
|
|
64
|
+
| :--- | :--- | :--- | :--- |
|
|
65
|
+
| `{{Factor 1 (e.g. Active Tenant?)}}` | Binary | `✅ YES` / `❌ NO` | — |
|
|
66
|
+
| `{{Factor 2 (e.g. Active Billing Tier?)}}` | Categorical | `FREE`, `PRO`, `ENTERPRISE` | — |
|
|
67
|
+
| `{{Factor N}}` | Binary / Categorical | … | — |
|
|
68
|
+
|
|
69
|
+
> Use `-` (dash) as a wildcard when a column does not affect the decision.
|
|
70
|
+
|
|
71
|
+
### 3.2 Resolution Table
|
|
72
|
+
|
|
73
|
+
| {{Factor 1}} | {{Factor 2}} | … | Proposed Action | Decision | Transition State |
|
|
74
|
+
| :---: | :---: | :---: | :--- | :---: | :--- |
|
|
75
|
+
| ❌ NO | - | - | `{{ACTION_NAME}}` | ❌ DENY | - |
|
|
76
|
+
| ✅ YES | - | - | `{{ACTION_NAME}}` | ✅ ALLOW | `{{NEW_STATE}}` |
|
|
77
|
+
|
|
78
|
+
**Resolution rules** (per MDDD protocol, section 3.3):
|
|
79
|
+
|
|
80
|
+
1. ALL columns must match the current system state.
|
|
81
|
+
2. If no row fully matches → `HaltWithConflict` (section 5).
|
|
82
|
+
3. If multiple rows match → `HaltWithConflict` (ambiguous).
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 4. Tasks
|
|
87
|
+
|
|
88
|
+
Atomic, executable checklist extracted from the spec. Each item MUST be traceable
|
|
89
|
+
back to a node in the Behavioral Flow or a row in the Decision Matrix.
|
|
90
|
+
|
|
91
|
+
- [ ] {{Task 1 — derived from flow node / matrix row}}
|
|
92
|
+
- [ ] {{Task 2 — derived from flow node / matrix row}}
|
|
93
|
+
- [ ] {{Task N — derived from flow node / matrix row}}
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 5. Conflict Resolution Notes
|
|
98
|
+
|
|
99
|
+
When a `HaltWithConflict` is triggered, document the resolution path here:
|
|
100
|
+
|
|
101
|
+
| Conflict Source | Proposed Matrix Change | Status |
|
|
102
|
+
| :--- | :--- | :---: |
|
|
103
|
+
| {{Primitive Factor that caused the halt}} | {{new row / new column / renamed state}} | `OPEN` / `RESOLVED` |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 6. Change History
|
|
108
|
+
|
|
109
|
+
| Version | Date | Author | Change Description | Change Type |
|
|
110
|
+
| :---: | :--- | :--- | :--- | :---: |
|
|
111
|
+
| 1.0.0 | {{YYYY-MM-DD}} | {{author_name}} | Initial spec creation via `md-new` | MAJOR |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 7. Audit History
|
|
116
|
+
|
|
117
|
+
<details>
|
|
118
|
+
<summary>Click to expand</summary>
|
|
119
|
+
|
|
120
|
+
| Date | Agent | Version | Change Summary |
|
|
121
|
+
| :--- | :--- | :---: | :--- |
|
|
122
|
+
| {{YYYY-MM-DD}} | Cline (`md-new`) | v1.0.0 | **Spec created from template.** All placeholders pending replacement. Mermaid diagram uses a generic state lifecycle as a structural seed. Decision Matrix seeded with one wildcard row — must be expanded to cover the real primitive factors before `md-impl` is invoked. Status: **draft**. |
|
|
123
|
+
|
|
124
|
+
</details>
|
package/system_prompt.md
CHANGED
|
@@ -217,6 +217,8 @@ The UNIVERSAL RULE is now integrated into the main processing diagram at the top
|
|
|
217
217
|
|
|
218
218
|
**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.
|
|
219
219
|
|
|
220
|
+
Diagrams: Always use npx @mermaid-js/mermaid-cli to Validate Diagrams Syntax (Mandatory)
|
|
221
|
+
|
|
220
222
|
```mermaid
|
|
221
223
|
%% @spec-version v2.0.0
|
|
222
224
|
%% @protocol-version 1.0.0
|
|
@@ -232,4 +234,5 @@ stateDiagram-v2
|
|
|
232
234
|
Allowed --> Action: Execute requested skill.
|
|
233
235
|
Action --> Verify: Validate output.
|
|
234
236
|
Verify --> [*]: Success.
|
|
235
|
-
Verify --> Action: Retry if criteria not met.
|
|
237
|
+
Verify --> Action: Retry if criteria not met.
|
|
238
|
+
```
|