mddd-cli 6.2.2 → 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 +192 -0
- package/bin/cli.js +15 -1
- package/package.json +2 -2
- package/readme.md +105 -19
- package/src/commands/init.js +3 -3
- package/src/commands/status.js +534 -0
- package/src/commands/status.spec.md +131 -0
- package/src/services/FileSystemService.spec.md +3 -1
- package/src/services/InitService.js +1 -1
- package/src/services/InitService.spec.md +7 -5
- package/system_prompt.md +0 -171
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# InitService — Specification
|
|
2
2
|
|
|
3
|
-
**SPEC_VERSION
|
|
3
|
+
**SPEC_VERSION:** v1.2.0 — stable
|
|
4
|
+
**Classification:** Coeso
|
|
4
5
|
|
|
5
6
|
## Overview
|
|
6
7
|
|
|
@@ -16,7 +17,7 @@ Co-located with `src/services/InitService.js`.
|
|
|
16
17
|
%% @spec-version v1.2.0
|
|
17
18
|
stateDiagram-v2
|
|
18
19
|
[*] --> createSystemPrompt: initService.createSystemPrompt(promptContent)
|
|
19
|
-
createSystemPrompt --> writeFile: this.#fs.writeFile('
|
|
20
|
+
createSystemPrompt --> writeFile: this.#fs.writeFile('AGENTS.md', content)
|
|
20
21
|
writeFile --> createSkills: initService.createSkills(sourceSkillsDir, logger)
|
|
21
22
|
|
|
22
23
|
createSkills --> ensureAgentsDir: this.#fs.ensureDir('.agents')
|
|
@@ -42,7 +43,7 @@ stateDiagram-v2
|
|
|
42
43
|
|
|
43
44
|
| Step | Method | I/O | Conditional Branch? | Error Handling | FS Side Effect |
|
|
44
45
|
| :--- | :--- | :--- | :---: | :--- | :--- |
|
|
45
|
-
| 1 | `createSystemPrompt(promptContent)` | Input: `string`<br>Output: `Promise<void>` | ❌ No | Delegated to `#fs.writeFile` | ✅ Writes `
|
|
46
|
+
| 1 | `createSystemPrompt(promptContent)` | Input: `string`<br>Output: `Promise<void>` | ❌ No | Delegated to `#fs.writeFile` | ✅ Writes `AGENTS.md` |
|
|
46
47
|
| 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 |
|
|
47
48
|
| 3 | `createGitHubWorkflow(workflowYaml, logger)` | Input: `string` + logger fn<br>Output: `Promise<string>` | ❌ No | Delegated to `#fs` methods | ✅ Creates `.github/workflows/mddd-preview.yml` |
|
|
48
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` |
|
|
@@ -77,8 +78,9 @@ stateDiagram-v2
|
|
|
77
78
|
|
|
78
79
|
| Date | Agent | Version | Change Summary |
|
|
79
80
|
| :--- | :--- | :---: | :--- |
|
|
80
|
-
| 2026-
|
|
81
|
-
| 2026-05-28 | Cline (md-edit) | v1.1.0 | **New method `createGitHubWorkflow`.** Added to support `md init` creating `.github/workflows/mddd-preview.yml`. Updated behavioral flow diagram with new states. Updated Decision Matrix with steps 3, 7, 8. SPEC_VERSION bumped from v1.0.0 to v1.1.0 (minor — new method). Status promoted from **draft** to **stable** — implementation and tests verified. |
|
|
81
|
+
| 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
82
|
| 2026-06-04 | Cline (md-edit) | v1.2.0 | **New method `createSpecTemplate`.** Added to support `md init` copying `.agents/templates/spec-template.md` from the CLI package to the project. Reads the template file content via `fs.readFileSync`, ensures `.agents/templates/` dir exists, then writes `spec-template.md` via `#fs.writeFile`. Updated behavioral flow diagram with new states (`createSpecTemplate → ensureTemplatesDir → writeTemplateFile → logTemplate`). Updated Decision Matrix with steps 4, 8. SPEC_VERSION bumped from v1.1.0 to v1.2.0 (minor — new method). |
|
|
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
|
+
| 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. |
|
|
83
85
|
|
|
84
86
|
</details>
|
package/system_prompt.md
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
# Mermaid Diagram Driven Development (MDDD) Protocol
|
|
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.
|
|
5
|
-
|
|
6
|
-
Spec template path: .agents/templates/spec-template.md
|
|
7
|
-
|
|
8
|
-
Mark the analysis as Coese or Chaotic
|
|
9
|
-
|
|
10
|
-
```mermaid
|
|
11
|
-
stateDiagram-v2
|
|
12
|
-
[*] --> CheckSpec: UNIVERSAL RULE — Check specification file
|
|
13
|
-
|
|
14
|
-
state CheckSpec {
|
|
15
|
-
SpecExists --> ReadSpecification: Request Allowed.
|
|
16
|
-
SpecNotFound --> SkillCheck: Check skill requested.
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
state SkillCheck {
|
|
20
|
-
MdNew --> ReadSpecification: Request Allowed.
|
|
21
|
-
MdAudit --> ReadSpecification: Request Allowed.
|
|
22
|
-
Other --> Denied: Specification file required.
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
Denied --> ConflictResolution: Explain missing spec
|
|
26
|
-
|
|
27
|
-
state ReadSpecification {
|
|
28
|
-
[*] --> CreateSpec: Create file from template
|
|
29
|
-
CreateSpec --> ParseMermaidDiagrams: Extract all diagrams
|
|
30
|
-
ParseMermaidDiagrams --> ExtractDecisionMatrices: Map topology nodes/edges
|
|
31
|
-
ExtractDecisionMatrices --> ValidatePrimitiveFactors: Check factor columns
|
|
32
|
-
ValidatePrimitiveFactors --> [*]: Spec loaded into context
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
ReadSpecification --> CheckDecisionMatrix: Evaluate Primitive Factors
|
|
36
|
-
CheckDecisionMatrix --> HaltWithConflict: Constraint Violation / Feature Creep
|
|
37
|
-
CheckDecisionMatrix --> ExecuteAction: Strict Match Confirmed
|
|
38
|
-
HaltWithConflict --> ConflictResolution: Auto-detect conflict source
|
|
39
|
-
|
|
40
|
-
state ConflictResolution {
|
|
41
|
-
ExplainConflict --> LogConflict: Document in Audit History
|
|
42
|
-
LogConflict --> ProposeAlternatives: Suggest decision matrix changes
|
|
43
|
-
ProposeAlternatives --> UserDecision: Await human input
|
|
44
|
-
UserDecision --> CheckDecisionMatrix: Matrix updated
|
|
45
|
-
UserDecision --> HaltProcess: User cancels
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
HaltProcess --> UpdateDetailsFooter: Record aborted attempt
|
|
49
|
-
ExecuteAction --> MutateState: Apply File/Code Changes
|
|
50
|
-
MutateState --> UpdateVersionHeader: Apply Semantic Version Rules (MAJOR.MINOR.PATCH)
|
|
51
|
-
UpdateVersionHeader --> UpdateDetailsFooter: Append Audit History entry
|
|
52
|
-
UpdateDetailsFooter --> [*]
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### 2 Reverse Consistency (Parent → Child)
|
|
56
|
-
|
|
57
|
-
When a parent domain spec is modified, the following MUST be verified:
|
|
58
|
-
|
|
59
|
-
2.1. **Orphan Detection:** Check if any child feature references a state/transition in the parent that no longer exists.
|
|
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.
|
|
62
|
-
|
|
63
|
-
## 3. Decision Matrix & Primitive Factors
|
|
64
|
-
|
|
65
|
-
### 3.1 Decision Matrix Definition
|
|
66
|
-
|
|
67
|
-
A **Decision Matrix** is a Markdown truth table that maps combinations of **Primitive Factors** (binary/nominal inputs) to deterministic **Actions** and **Outcomes**. It lives inside the `.spec.md` file.
|
|
68
|
-
|
|
69
|
-
### 3.2 Primitive Factors
|
|
70
|
-
|
|
71
|
-
**Primitive Factors** are the atomic boolean or categorical variables used to evaluate a decision. Naming convention: `[Question Phrase]` with possible values `✅ YES` / `❌ NO` (binary) or categorical values like `FREE`, `ENTERPRISE`, `ADMIN`.
|
|
72
|
-
|
|
73
|
-
| Factor Type | Example | Allowed Values |
|
|
74
|
-
| --- | --- | --- |
|
|
75
|
-
| Binary | `Active Tenant?` | `✅ YES` / `❌ NO` |
|
|
76
|
-
| Categorical | `Active Billing Tier?` | `FREE`, `PRO`, `ENTERPRISE` |
|
|
77
|
-
| Negated Binary | `Global Kill Switch Active?` | `✅ YES` (blocked) / `❌ NO` (normal) |
|
|
78
|
-
|
|
79
|
-
### 3.3 Matrix Resolution Rule
|
|
80
|
-
|
|
81
|
-
For each row:
|
|
82
|
-
1. Match ALL Primitive Factors against the current system state.
|
|
83
|
-
2. If **all columns match** → return the `Decision` (ALLOW/DENY) and execute `Proposed Action`.
|
|
84
|
-
3. If **no row fully matches** → return `HaltWithConflict`.
|
|
85
|
-
4. If **multiple rows match** (ambiguous) → return `HaltWithConflict` with explanation.
|
|
86
|
-
|
|
87
|
-
### 3.4 Example Decision Matrix
|
|
88
|
-
|
|
89
|
-
| Active Tenant? | Premium App? | Active Billing Tier? | User Has Role Admin? | App Whitelisted? | Global Kill Switch? | Proposed Action | Decision | Transition State |
|
|
90
|
-
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
91
|
-
| ❌ NO | - | - | - | - | - | `BOOT_APP` | ❌ DENY | - |
|
|
92
|
-
| ✅ YES | ✅ YES | **ENTERPRISE** | ✅ YES | ✅ YES | ❌ NO | `INSTALL_APP` | ✅ ALLOW | `INSTALLED` |
|
|
93
|
-
| ✅ YES | - | - | - | - | ✅ YES | `BOOT_APP` | ❌ DENY | `MUTED_ISOLATION` |
|
|
94
|
-
|
|
95
|
-
> `-` = wildcard / any value matches.
|
|
96
|
-
|
|
97
|
-
## 4. Versioning Policy
|
|
98
|
-
|
|
99
|
-
### 4.1 Semantic Version for Specs
|
|
100
|
-
|
|
101
|
-
Every `.spec.md` file carries a `%% @spec-version` header. Use **Semantic Versioning (MAJOR.MINOR.PATCH)**:
|
|
102
|
-
|
|
103
|
-
| Bump | When | Example |
|
|
104
|
-
| --- | --- | --- |
|
|
105
|
-
| **MAJOR** | Breaking change: removing states/transitions, renaming factors, changing decision outcomes. | `1.2.3` → `2.0.0` |
|
|
106
|
-
| **MINOR** | Adding: new states/transitions, new factor columns, new features without breaking existing rows. | `1.2.3` → `1.3.0` |
|
|
107
|
-
| **PATCH** | Fixing: typos, clarifying descriptions, reformatting, updating child references. | `1.2.3` → `1.2.4` |
|
|
108
|
-
|
|
109
|
-
### 4.2 Audit History (Change Log)
|
|
110
|
-
|
|
111
|
-
Each change MUST append a row to the **Change History** table at the bottom of the `.spec.md` file:
|
|
112
|
-
|
|
113
|
-
```
|
|
114
|
-
## Change History
|
|
115
|
-
| Version | Date | Author | Change Description | Change Type |
|
|
116
|
-
| --- | --- | --- | --- | --- |
|
|
117
|
-
| 1.1.0 | 2025-06-01 | AI | Added refund retry logic state | MINOR |
|
|
118
|
-
| 1.0.0 | 2025-05-15 | AI | Initial spec creation | MAJOR |
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## 5. Conflict Resolution Protocol
|
|
122
|
-
|
|
123
|
-
When `HaltWithConflict` is triggered, the system MUST:
|
|
124
|
-
|
|
125
|
-
1. **Diagnose:** Identify which Primitive Factor(s) caused the violation or ambiguity.
|
|
126
|
-
2. **Document:** Log the conflict details in the Audit History (see section 4.3).
|
|
127
|
-
3. **Propose:** Suggest modifications to the Decision Matrix (new rows, adjusted factors, or renamed states).
|
|
128
|
-
4. **Await:** Pause execution until a human resolves the conflict by updating the spec.
|
|
129
|
-
5. **Resume:** After the spec is updated, re-enter `CheckDecisionMatrix`.
|
|
130
|
-
|
|
131
|
-
## 6. Parent Interaction Logic (Reverse Consistency)
|
|
132
|
-
|
|
133
|
-
```mermaid
|
|
134
|
-
graph TD
|
|
135
|
-
A[Parent .spec.md Modified] --> B[Scan All Child Features]
|
|
136
|
-
B --> C{Child References\nDeleted State?}
|
|
137
|
-
C -->|Yes| D[Flag Orphan Reference]
|
|
138
|
-
C -->|No| E{Child Transitions\nStill Valid?}
|
|
139
|
-
E -->|No| D
|
|
140
|
-
E -->|Yes| F[Update Child @spec-version: PATCH bump]
|
|
141
|
-
D --> G[Human Review Required]
|
|
142
|
-
G --> H[Update Child Spec]
|
|
143
|
-
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
|
-
```
|