mddd-cli 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +1 -1
- package/package.json +1 -1
- package/readme.md +99 -11
package/bin/cli.js
CHANGED
|
@@ -32,7 +32,7 @@ const program = new Command();
|
|
|
32
32
|
program
|
|
33
33
|
.name('md')
|
|
34
34
|
.description('Manager for co-located specifications for Mermaid Diagram Driven Development (MDDD)')
|
|
35
|
-
.version('2.1.
|
|
35
|
+
.version('2.1.2');
|
|
36
36
|
|
|
37
37
|
// ==========================================
|
|
38
38
|
// COMMAND: md init
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -39,12 +39,15 @@ Unlike traditional specification frameworks that generate dozens of text files a
|
|
|
39
39
|
| :--- | :--- | :--- |
|
|
40
40
|
| **Logic Structure** | Textual paragraphs, verbose rules, and conversational scenarios. | Binary/Factual Decision Matrices + Strict Structural Topologies. |
|
|
41
41
|
| **AI Context Consumption** | High token overhead due to massive text-based behavioral descriptions. | Ultra-low token footprint using concise matrix truth tables. |
|
|
42
|
+
| **Estimated Tokens per Rule (10 rules)** | **~8,000 – 12,000 tokens** (paragraphs + scenario descriptions + edge case text) | **~800 – 1,500 tokens** (10 matrix rows × 6 factor columns ≈ 60 cells of short text) |
|
|
43
|
+
| **Estimated Tokens per Rule (50 rules)** | **~40,000 – 60,000 tokens** (entire context window may be consumed) | **~4,000 – 7,500 tokens** (still fits comfortably within a small context) |
|
|
42
44
|
| **Scalability** | Adding rules creates massive text blocks prone to prompt fragmentation. | Adding rules scales horizontally by appending precise factor columns. |
|
|
43
45
|
| **Ambiguity Control** | High risk of LLM hallucination when interpreting nested "if/else" phrasing. | Mathematical precision; deterministic processing via matrix rows. |
|
|
44
|
-
| **Tool Footprint** | Massive boilerplate with a bloat of internal files and complex folder structures. | Ultra-lightweight: a
|
|
46
|
+
| **Tool Footprint** | Massive boilerplate with a bloat of internal files and complex folder structures. | Ultra-lightweight modular architecture: a thin router + cleanly separated command and service modules, each easily audited by any human. |
|
|
45
47
|
|
|
46
48
|
### 🚀 Why MDDD Decision Matrices Outperform OpenSpec:
|
|
47
49
|
* **Predictable Tokens:** For an LLM, reading an MDDD matrix table is identical to processing a binary truth table. It matches primitive factor columns (`Active Tenant?`, `Global Kill Switch?`) and instantly resolves whether the outcome is `ALLOW` or `DENY` without token-wasting lexical processing.
|
|
50
|
+
* **10× to 15× Less Tokens:** A complex business rule with 6 variable factors costs ~800 tokens in MDDD vs ~8,000+ tokens in OpenSpec (paragraphs + edge case descriptions). As rules grow, MDDD stays linear while OpenSpec grows exponentially in verbosity.
|
|
48
51
|
* **Infinite Columns = Infinite Variables:** If your system gains a new architectural constraint (e.g., `Is Environment Production?` or `IP Whitelisted?`), you simply append a new column to the matrix. The business logic scales horizontally without bloating or breaking Mermaid visual flows.
|
|
49
52
|
* **A True Replacement for OpenSpec:** OpenSpec requires writing multiple paragraphs and descriptive test scenarios to cover complex constraint combinations. MDDD completely handles this in a single, deterministic table row—slashing prompt context overhead and completely eliminating AI hallucinations.
|
|
50
53
|
|
|
@@ -182,10 +185,10 @@ When starting a new feature, create its visual contract:
|
|
|
182
185
|
|
|
183
186
|
```bash
|
|
184
187
|
# For a single feature
|
|
185
|
-
md
|
|
188
|
+
md new path/feature-name
|
|
186
189
|
|
|
187
190
|
# For a feature connecting to an existing flow
|
|
188
|
-
md
|
|
191
|
+
md new path/feature-name --parent path/to/parent
|
|
189
192
|
|
|
190
193
|
```
|
|
191
194
|
|
|
@@ -196,7 +199,7 @@ This will generate the `feature-name.spec.md` file containing the semantic versi
|
|
|
196
199
|
Need to refactor existing code? Audit it:
|
|
197
200
|
|
|
198
201
|
```bash
|
|
199
|
-
md
|
|
202
|
+
md audit path/to/legacy-file
|
|
200
203
|
|
|
201
204
|
```
|
|
202
205
|
|
|
@@ -238,8 +241,48 @@ src/
|
|
|
238
241
|
| Command | Description |
|
|
239
242
|
| --- | --- |
|
|
240
243
|
| `md init` | Configures the `system_prompt.md` file and the SKILL.md files which instructs the AI how to behave. Run this everytime you update MDDD-CLI NPM Package. |
|
|
244
|
+
| `md new <targetPath>` | Creates a new `.spec.md` file at the target directory. Supports `--macro` for module-level specs and `--parent` for explicit parent linking. |
|
|
245
|
+
| `md edit <specFilePath> <instruction...>` | Signals a pending change to an existing `.spec.md` file. The AI then applies the changes and increments semantic version. |
|
|
246
|
+
| `md audit <codeFilePath>` | Audits a code file to create a retroactive `.spec.md` or suggest refactoring. |
|
|
247
|
+
| `md impl <specFilePath>` | Prepares the ecosystem to implement production code and tests based on a signed `.spec.md`. |
|
|
241
248
|
|
|
242
|
-
|
|
249
|
+
> **💡 Note for AI agents:** These commands are designed to be invoked by AI tools (Cursor, Windsurf, Claude Code, GitHub Copilot). As a human, simply tell the AI which skill to use and the target file.
|
|
250
|
+
|
|
251
|
+
### Project Architecture
|
|
252
|
+
|
|
253
|
+
The CLI codebase follows a clean modular architecture, as documented in `bin/cli.spec.md`:
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
bin/
|
|
257
|
+
├── cli.js # Thin Commander router (< 100 lines)
|
|
258
|
+
└── cli.spec.md # Co-located spec (v2.0.0)
|
|
259
|
+
|
|
260
|
+
src/
|
|
261
|
+
├── commands/ # Command layer (5 modules)
|
|
262
|
+
│ ├── init.js
|
|
263
|
+
│ ├── new.js
|
|
264
|
+
│ ├── edit.js
|
|
265
|
+
│ ├── audit.js
|
|
266
|
+
│ └── impl.js
|
|
267
|
+
└── services/ # Shared services with DI
|
|
268
|
+
├── FileSystemService.js
|
|
269
|
+
├── TemplateFactory.js
|
|
270
|
+
├── ParentLinker.js
|
|
271
|
+
├── InitService.js
|
|
272
|
+
├── SpecGenerator.js
|
|
273
|
+
├── SpecValidator.js
|
|
274
|
+
├── SpecEditor.js
|
|
275
|
+
├── AuditService.js
|
|
276
|
+
└── ImplValidator.js
|
|
277
|
+
|
|
278
|
+
tests/ # Unit tests
|
|
279
|
+
├── SpecGenerator.test.js
|
|
280
|
+
├── ParentLinker.test.js
|
|
281
|
+
├── AuditService.test.js
|
|
282
|
+
└── TemplateFactory.test.js
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
All 21 unit tests pass with mocked file system (zero real I/O), ensuring full coverage of the core services.
|
|
243
286
|
|
|
244
287
|
---
|
|
245
288
|
|
|
@@ -249,6 +292,7 @@ Other commands are made for IA-only. You should only tell IA which skill you wan
|
|
|
249
292
|
* **Commander.js** — Robust and declarative CLI interface
|
|
250
293
|
* **Picocolors** — Colorful and lightweight terminal output
|
|
251
294
|
* **Mermaid.js** — Visual diagramming as the source of truth
|
|
295
|
+
* **Built-in Test Runner** (`node:test`) — Zero-dependency unit testing
|
|
252
296
|
|
|
253
297
|
---
|
|
254
298
|
|
|
@@ -288,13 +332,16 @@ Ao contrário de frameworks tradicionais de especificação que geram dezenas de
|
|
|
288
332
|
| --- | --- | --- |
|
|
289
333
|
| **Estrutura Lógica** | Parágrafos textuais, regras verbosas e cenários conversacionais. | Matrizes de Decisão Binárias/Factuais + Topologias Estruturais Estritas. |
|
|
290
334
|
| **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. |
|
|
335
|
+
| **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) |
|
|
336
|
+
| **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) |
|
|
291
337
|
| **Escalabilidade** | Adicionar regras cria blocos de texto massivos propensos a fragmentação de prompt. | Adicionar regras escala horizontalmente anexando colunas precisas de fatores. |
|
|
292
338
|
| **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. |
|
|
293
|
-
| **Pegada da Ferramenta** | Boilerplate massivo com poluição de arquivos internos e estruturas complexas de pastas. | Ultra-leve: um
|
|
339
|
+
| **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. |
|
|
294
340
|
|
|
295
341
|
### 🚀 Por que as Matrizes de Decisão MDDD Superam o OpenSpec:
|
|
296
342
|
|
|
297
343
|
* **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.
|
|
344
|
+
* **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.
|
|
298
345
|
* **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.
|
|
299
346
|
* **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.
|
|
300
347
|
|
|
@@ -432,10 +479,10 @@ Ao iniciar uma nova funcionalidade, crie o seu contrato visual:
|
|
|
432
479
|
|
|
433
480
|
```bash
|
|
434
481
|
# Para uma funcionalidade única
|
|
435
|
-
md
|
|
482
|
+
md new caminho/nome-da-feature
|
|
436
483
|
|
|
437
484
|
# Para uma funcionalidade conectando a um fluxo existente
|
|
438
|
-
md
|
|
485
|
+
md new caminho/nome-da-feature --parent caminho/para/pai
|
|
439
486
|
|
|
440
487
|
```
|
|
441
488
|
|
|
@@ -446,7 +493,7 @@ Isso gerará o arquivo `nome-da-feature.spec.md` contendo a estrutura de versão
|
|
|
446
493
|
Precisa refatorar um código existente? Audite-o:
|
|
447
494
|
|
|
448
495
|
```bash
|
|
449
|
-
md
|
|
496
|
+
md audit caminho/para/arquivo-legado
|
|
450
497
|
|
|
451
498
|
```
|
|
452
499
|
|
|
@@ -485,11 +532,51 @@ src/
|
|
|
485
532
|
|
|
486
533
|
## 📦 Comandos da CLI
|
|
487
534
|
|
|
488
|
-
| Comando |
|
|
535
|
+
| Comando | Descrição |
|
|
489
536
|
| --- | --- |
|
|
490
537
|
| `md init` | Configura os arquivos `system_prompt.md` e `SKILL.md` que instruem a IA sobre como se comportar. Execute isto sempre que atualizar o pacote NPM do MDDD-CLI. |
|
|
538
|
+
| `md new <targetPath>` | Cria um novo arquivo `.spec.md` no diretório alvo. Suporta `--macro` para specs de módulo e `--parent` para vinculação explícita ao pai. |
|
|
539
|
+
| `md edit <specFilePath> <instruction...>` | Sinaliza uma alteração pendente em um `.spec.md` existente. A IA então aplica as mudanças e incrementa a versão semântica. |
|
|
540
|
+
| `md audit <codeFilePath>` | Audita um arquivo de código para criar um `.spec.md` retroativo ou sugerir refatoração. |
|
|
541
|
+
| `md impl <specFilePath>` | Prepara o ecossistema para implementar código produtivo e testes com base em um `.spec.md` assinado. |
|
|
542
|
+
|
|
543
|
+
> **💡 Nota para agentes de IA:** Estes comandos foram projetados para serem invocados por ferramentas de IA (Cursor, Windsurf, Claude Code, GitHub Copilot). Como humano, basta dizer à IA qual skill usar e o arquivo de destino.
|
|
544
|
+
|
|
545
|
+
### Arquitetura do Projeto
|
|
546
|
+
|
|
547
|
+
O código-fonte da CLI segue uma arquitetura modular limpa, conforme documentado em `bin/cli.spec.md`:
|
|
548
|
+
|
|
549
|
+
```
|
|
550
|
+
bin/
|
|
551
|
+
├── cli.js # Router Commander enxuto (< 100 linhas)
|
|
552
|
+
└── cli.spec.md # Spec colocalizada (v2.0.0)
|
|
553
|
+
|
|
554
|
+
src/
|
|
555
|
+
├── commands/ # Camada de comandos (5 módulos)
|
|
556
|
+
│ ├── init.js
|
|
557
|
+
│ ├── new.js
|
|
558
|
+
│ ├── edit.js
|
|
559
|
+
│ ├── audit.js
|
|
560
|
+
│ └── impl.js
|
|
561
|
+
└── services/ # Serviços compartilhados com DI
|
|
562
|
+
├── FileSystemService.js
|
|
563
|
+
├── TemplateFactory.js
|
|
564
|
+
├── ParentLinker.js
|
|
565
|
+
├── InitService.js
|
|
566
|
+
├── SpecGenerator.js
|
|
567
|
+
├── SpecValidator.js
|
|
568
|
+
├── SpecEditor.js
|
|
569
|
+
├── AuditService.js
|
|
570
|
+
└── ImplValidator.js
|
|
571
|
+
|
|
572
|
+
tests/ # Testes unitários
|
|
573
|
+
├── SpecGenerator.test.js
|
|
574
|
+
├── ParentLinker.test.js
|
|
575
|
+
├── AuditService.test.js
|
|
576
|
+
└── TemplateFactory.test.js
|
|
577
|
+
```
|
|
491
578
|
|
|
492
|
-
|
|
579
|
+
Todos os 21 testes unitários passam com sistema de arquivos mockado (zero I/O real), garantindo cobertura total dos serviços principais.
|
|
493
580
|
|
|
494
581
|
---
|
|
495
582
|
|
|
@@ -499,6 +586,7 @@ Outros comandos foram feitos exclusivamente para o uso da IA. Você só precisa
|
|
|
499
586
|
* **Commander.js** — Interface CLI robusta e declarativa
|
|
500
587
|
* **Picocolors** — Saída colorida e leve no terminal
|
|
501
588
|
* **Mermaid.js** — Diagramação visual como fonte da verdade
|
|
589
|
+
* **Test Runner Nativo** (`node:test`) — Testes unitários sem dependências externas
|
|
502
590
|
|
|
503
591
|
---
|
|
504
592
|
|