micro-contracts 0.15.0 → 0.15.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/README.md +62 -0
- package/cli-contract.yaml +620 -0
- package/dist/agents/context-builder.d.ts +5 -0
- package/dist/agents/context-builder.d.ts.map +1 -0
- package/dist/agents/context-builder.js +239 -0
- package/dist/agents/context-builder.js.map +1 -0
- package/dist/agents/formatter.d.ts +9 -0
- package/dist/agents/formatter.d.ts.map +1 -0
- package/dist/agents/formatter.js +124 -0
- package/dist/agents/formatter.js.map +1 -0
- package/dist/agents/index.d.ts +5 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +3 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +5 -0
- package/dist/agents/orchestrator.d.ts.map +1 -0
- package/dist/agents/orchestrator.js +105 -0
- package/dist/agents/orchestrator.js.map +1 -0
- package/dist/agents/types.d.ts +21 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/cli.d.ts +0 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +814 -1161
- package/dist/cli.js.map +1 -1
- package/dist/commands/audit-guardrails.d.ts +13 -0
- package/dist/commands/audit-guardrails.d.ts.map +1 -0
- package/dist/commands/audit-guardrails.js +32 -0
- package/dist/commands/audit-guardrails.js.map +1 -0
- package/dist/commands/audit-openapi.d.ts +13 -0
- package/dist/commands/audit-openapi.d.ts.map +1 -0
- package/dist/commands/audit-openapi.js +32 -0
- package/dist/commands/audit-openapi.js.map +1 -0
- package/dist/commands/propose-overlays.d.ts +13 -0
- package/dist/commands/propose-overlays.d.ts.map +1 -0
- package/dist/commands/propose-overlays.js +32 -0
- package/dist/commands/propose-overlays.js.map +1 -0
- package/dist/commands/review-published.d.ts +13 -0
- package/dist/commands/review-published.d.ts.map +1 -0
- package/dist/commands/review-published.js +32 -0
- package/dist/commands/review-published.js.map +1 -0
- package/dist/generated/commands.d.ts +2 -0
- package/dist/generated/commands.d.ts.map +1 -0
- package/dist/generated/commands.js +2 -0
- package/dist/generated/commands.js.map +1 -0
- package/dist/generated/dsl/agents.d.ts +34 -0
- package/dist/generated/dsl/agents.d.ts.map +1 -0
- package/dist/generated/dsl/agents.js +98 -0
- package/dist/generated/dsl/agents.js.map +1 -0
- package/dist/generated/dsl/handoffs.d.ts +1209 -0
- package/dist/generated/dsl/handoffs.d.ts.map +1 -0
- package/dist/generated/dsl/handoffs.js +205 -0
- package/dist/generated/dsl/handoffs.js.map +1 -0
- package/dist/generated/dsl/index.d.ts +13 -0
- package/dist/generated/dsl/index.d.ts.map +1 -0
- package/dist/generated/dsl/index.js +10 -0
- package/dist/generated/dsl/index.js.map +1 -0
- package/dist/generated/dsl/tasks.d.ts +26 -0
- package/dist/generated/dsl/tasks.d.ts.map +1 -0
- package/dist/generated/dsl/tasks.js +133 -0
- package/dist/generated/dsl/tasks.js.map +1 -0
- package/dist/generated/dsl/workflows.d.ts +34 -0
- package/dist/generated/dsl/workflows.d.ts.map +1 -0
- package/dist/generated/dsl/workflows.js +84 -0
- package/dist/generated/dsl/workflows.js.map +1 -0
- package/dist/generated/index.d.ts +7 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +7 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/policy-runtime.d.ts +114 -0
- package/dist/generated/policy-runtime.d.ts.map +1 -0
- package/dist/generated/policy-runtime.js +195 -0
- package/dist/generated/policy-runtime.js.map +1 -0
- package/dist/generated/policy.d.ts +619 -0
- package/dist/generated/policy.d.ts.map +1 -0
- package/dist/generated/policy.js +802 -0
- package/dist/generated/policy.js.map +1 -0
- package/dist/generated/program.d.ts +112 -0
- package/dist/generated/program.d.ts.map +1 -0
- package/dist/generated/program.js +266 -0
- package/dist/generated/program.js.map +1 -0
- package/dist/generated/schemas.d.ts +778 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +1005 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +395 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +3 -0
- package/dist/generated/types.js.map +1 -0
- package/docs/cli-reference.md +300 -0
- package/package.json +20 -2
package/docs/cli-reference.md
CHANGED
|
@@ -15,6 +15,10 @@ Contract-first OpenAPI toolchain for TypeScript Web/API systems. Generates contr
|
|
|
15
15
|
- [deps](#micro-contracts-deps)
|
|
16
16
|
- [guardrails-init](#micro-contracts-guardrails-init)
|
|
17
17
|
- [manifest](#micro-contracts-manifest)
|
|
18
|
+
- [audit-openapi](#micro-contracts-audit-openapi)
|
|
19
|
+
- [review-published](#micro-contracts-review-published)
|
|
20
|
+
- [propose-overlays](#micro-contracts-propose-overlays)
|
|
21
|
+
- [audit-guardrails](#micro-contracts-audit-guardrails)
|
|
18
22
|
|
|
19
23
|
---
|
|
20
24
|
|
|
@@ -514,3 +518,299 @@ x-agent:
|
|
|
514
518
|
```
|
|
515
519
|
|
|
516
520
|
---
|
|
521
|
+
|
|
522
|
+
### audit-openapi
|
|
523
|
+
|
|
524
|
+
Run LLM-based OpenAPI design quality audit.
|
|
525
|
+
|
|
526
|
+
Performs a semantic review of OpenAPI specification design quality using an LLM agent. Evaluates path design, module boundary alignment, schema bloat, CRUD vs use-case orientation, and cross-cutting concern coverage. Requires agent-contracts-runtime.
|
|
527
|
+
|
|
528
|
+
**Usage:**
|
|
529
|
+
|
|
530
|
+
```
|
|
531
|
+
micro-contracts audit-openapi
|
|
532
|
+
```
|
|
533
|
+
```
|
|
534
|
+
micro-contracts audit-openapi -m core
|
|
535
|
+
```
|
|
536
|
+
```
|
|
537
|
+
micro-contracts audit-openapi --adapter cursor --report-format text
|
|
538
|
+
```
|
|
539
|
+
```
|
|
540
|
+
micro-contracts audit-openapi --show-prompt
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
#### Options
|
|
544
|
+
|
|
545
|
+
| Option | Aliases | Required | Default | Description |
|
|
546
|
+
|---|---|---|---|---|
|
|
547
|
+
| `--config` | -c | No | | Path to config file (micro-contracts.config.yaml). |
|
|
548
|
+
| `--module` | -m | No | | Module name to audit (default is all modules). |
|
|
549
|
+
| `--adapter` | -a | No | | SDK adapter to use for LLM execution. |
|
|
550
|
+
| `--model` | | No | | LLM model override. |
|
|
551
|
+
| `--fail-on` | | No | `"error"` | Minimum severity that causes a non-zero exit. |
|
|
552
|
+
| `--output` | -o | No | | Write result to a file instead of stdout. |
|
|
553
|
+
| `--report-format` | | No | `"text"` | Output format for the audit report. |
|
|
554
|
+
|
|
555
|
+
#### Exit Codes
|
|
556
|
+
|
|
557
|
+
**Exit 0:** Audit completed, no blocking findings.
|
|
558
|
+
|
|
559
|
+
- **stdout:** format=`{options.report-format}`
|
|
560
|
+
|
|
561
|
+
**Exit 1:** Unexpected error.
|
|
562
|
+
|
|
563
|
+
- **stderr:** format=`text`
|
|
564
|
+
|
|
565
|
+
**Exit 3:** Input validation failed (config not found, spec invalid).
|
|
566
|
+
|
|
567
|
+
- **stderr:** format=`text`
|
|
568
|
+
|
|
569
|
+
**Exit 10:** Completed with blocking findings.
|
|
570
|
+
|
|
571
|
+
- **stdout:** format=`{options.report-format}`
|
|
572
|
+
|
|
573
|
+
**Exit 11:** Runtime dependency missing (agent-contracts-runtime).
|
|
574
|
+
|
|
575
|
+
- **stderr:** format=`text`
|
|
576
|
+
|
|
577
|
+
**Exit 12:** LLM provider or adapter error.
|
|
578
|
+
|
|
579
|
+
- **stderr:** format=`text`
|
|
580
|
+
|
|
581
|
+
#### Extensions
|
|
582
|
+
|
|
583
|
+
```yaml
|
|
584
|
+
x-agent:
|
|
585
|
+
risk_level: low
|
|
586
|
+
requires_confirmation: false
|
|
587
|
+
idempotent: true
|
|
588
|
+
side_effects:
|
|
589
|
+
- network
|
|
590
|
+
sideEffectNote: Network calls to LLM provider when adapter is not mock. Filesystem write only when --output is specified.
|
|
591
|
+
safe_dry_run_option: show-prompt
|
|
592
|
+
expectedDurationMs: 120000
|
|
593
|
+
retryableExitCodes:
|
|
594
|
+
- 12
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
599
|
+
### review-published
|
|
600
|
+
|
|
601
|
+
Review published API surface for internal leakage.
|
|
602
|
+
|
|
603
|
+
Analyzes the published (public-facing) API specification for internal type leakage, backward compatibility risks, and x-micro-contracts-non-exportable violations. Requires agent-contracts-runtime.
|
|
604
|
+
|
|
605
|
+
**Usage:**
|
|
606
|
+
|
|
607
|
+
```
|
|
608
|
+
micro-contracts review-published
|
|
609
|
+
```
|
|
610
|
+
```
|
|
611
|
+
micro-contracts review-published -m billing
|
|
612
|
+
```
|
|
613
|
+
```
|
|
614
|
+
micro-contracts review-published --adapter claude --report-format json
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
#### Options
|
|
618
|
+
|
|
619
|
+
| Option | Aliases | Required | Default | Description |
|
|
620
|
+
|---|---|---|---|---|
|
|
621
|
+
| `--config` | -c | No | | Path to config file (micro-contracts.config.yaml). |
|
|
622
|
+
| `--module` | -m | No | | Module name to review (default is all modules). |
|
|
623
|
+
| `--adapter` | -a | No | | SDK adapter to use for LLM execution. |
|
|
624
|
+
| `--model` | | No | | LLM model override. |
|
|
625
|
+
| `--fail-on` | | No | `"error"` | Minimum severity that causes a non-zero exit. |
|
|
626
|
+
| `--output` | -o | No | | Write result to a file instead of stdout. |
|
|
627
|
+
| `--report-format` | | No | `"text"` | Output format for the review report. |
|
|
628
|
+
|
|
629
|
+
#### Exit Codes
|
|
630
|
+
|
|
631
|
+
**Exit 0:** Review completed, no blocking findings.
|
|
632
|
+
|
|
633
|
+
- **stdout:** format=`{options.report-format}`
|
|
634
|
+
|
|
635
|
+
**Exit 1:** Unexpected error.
|
|
636
|
+
|
|
637
|
+
- **stderr:** format=`text`
|
|
638
|
+
|
|
639
|
+
**Exit 3:** Input validation failed.
|
|
640
|
+
|
|
641
|
+
- **stderr:** format=`text`
|
|
642
|
+
|
|
643
|
+
**Exit 10:** Completed with blocking findings.
|
|
644
|
+
|
|
645
|
+
- **stdout:** format=`{options.report-format}`
|
|
646
|
+
|
|
647
|
+
**Exit 11:** Runtime dependency missing (agent-contracts-runtime).
|
|
648
|
+
|
|
649
|
+
- **stderr:** format=`text`
|
|
650
|
+
|
|
651
|
+
**Exit 12:** LLM provider or adapter error.
|
|
652
|
+
|
|
653
|
+
- **stderr:** format=`text`
|
|
654
|
+
|
|
655
|
+
#### Extensions
|
|
656
|
+
|
|
657
|
+
```yaml
|
|
658
|
+
x-agent:
|
|
659
|
+
risk_level: low
|
|
660
|
+
requires_confirmation: false
|
|
661
|
+
idempotent: true
|
|
662
|
+
side_effects:
|
|
663
|
+
- network
|
|
664
|
+
sideEffectNote: Network calls to LLM provider when adapter is not mock. Filesystem write only when --output is specified.
|
|
665
|
+
safe_dry_run_option: show-prompt
|
|
666
|
+
expectedDurationMs: 120000
|
|
667
|
+
retryableExitCodes:
|
|
668
|
+
- 12
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
---
|
|
672
|
+
|
|
673
|
+
### propose-overlays
|
|
674
|
+
|
|
675
|
+
Propose cross-cutting overlay candidates.
|
|
676
|
+
|
|
677
|
+
Analyzes the OpenAPI specification and proposes cross-cutting overlay candidates for authentication, tenancy, rate limiting, audit logging, and other patterns. Verifies proposals do not conflict with existing overlay definitions. Requires agent-contracts-runtime.
|
|
678
|
+
|
|
679
|
+
**Usage:**
|
|
680
|
+
|
|
681
|
+
```
|
|
682
|
+
micro-contracts propose-overlays
|
|
683
|
+
```
|
|
684
|
+
```
|
|
685
|
+
micro-contracts propose-overlays -m core
|
|
686
|
+
```
|
|
687
|
+
```
|
|
688
|
+
micro-contracts propose-overlays --adapter openai --report-format json
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
#### Options
|
|
692
|
+
|
|
693
|
+
| Option | Aliases | Required | Default | Description |
|
|
694
|
+
|---|---|---|---|---|
|
|
695
|
+
| `--config` | -c | No | | Path to config file (micro-contracts.config.yaml). |
|
|
696
|
+
| `--module` | -m | No | | Module name to analyze (default is all modules). |
|
|
697
|
+
| `--adapter` | -a | No | | SDK adapter to use for LLM execution. |
|
|
698
|
+
| `--model` | | No | | LLM model override. |
|
|
699
|
+
| `--fail-on` | | No | `"error"` | Minimum severity that causes a non-zero exit. |
|
|
700
|
+
| `--output` | -o | No | | Write result to a file instead of stdout. |
|
|
701
|
+
| `--report-format` | | No | `"json"` | Output format for the proposal report. |
|
|
702
|
+
|
|
703
|
+
#### Exit Codes
|
|
704
|
+
|
|
705
|
+
**Exit 0:** Proposal generated successfully.
|
|
706
|
+
|
|
707
|
+
- **stdout:** format=`{options.report-format}`
|
|
708
|
+
|
|
709
|
+
**Exit 1:** Unexpected error.
|
|
710
|
+
|
|
711
|
+
- **stderr:** format=`text`
|
|
712
|
+
|
|
713
|
+
**Exit 3:** Input validation failed.
|
|
714
|
+
|
|
715
|
+
- **stderr:** format=`text`
|
|
716
|
+
|
|
717
|
+
**Exit 10:** Completed with blocking findings.
|
|
718
|
+
|
|
719
|
+
- **stdout:** format=`{options.report-format}`
|
|
720
|
+
|
|
721
|
+
**Exit 11:** Runtime dependency missing (agent-contracts-runtime).
|
|
722
|
+
|
|
723
|
+
- **stderr:** format=`text`
|
|
724
|
+
|
|
725
|
+
**Exit 12:** LLM provider or adapter error.
|
|
726
|
+
|
|
727
|
+
- **stderr:** format=`text`
|
|
728
|
+
|
|
729
|
+
#### Extensions
|
|
730
|
+
|
|
731
|
+
```yaml
|
|
732
|
+
x-agent:
|
|
733
|
+
risk_level: low
|
|
734
|
+
requires_confirmation: false
|
|
735
|
+
idempotent: true
|
|
736
|
+
side_effects:
|
|
737
|
+
- network
|
|
738
|
+
sideEffectNote: Network calls to LLM provider when adapter is not mock. Filesystem write only when --output is specified.
|
|
739
|
+
safe_dry_run_option: show-prompt
|
|
740
|
+
expectedDurationMs: 120000
|
|
741
|
+
retryableExitCodes:
|
|
742
|
+
- 12
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
---
|
|
746
|
+
|
|
747
|
+
### audit-guardrails
|
|
748
|
+
|
|
749
|
+
Audit guardrails configuration for drift and lint coverage.
|
|
750
|
+
|
|
751
|
+
Checks that guardrails.yaml configuration covers all generated output directories for drift detection and that OpenAPI lint rules are properly configured. Note: file permission and editing checks have been moved to artifact-contracts. Requires agent-contracts-runtime.
|
|
752
|
+
|
|
753
|
+
**Usage:**
|
|
754
|
+
|
|
755
|
+
```
|
|
756
|
+
micro-contracts audit-guardrails
|
|
757
|
+
```
|
|
758
|
+
```
|
|
759
|
+
micro-contracts audit-guardrails --adapter mock --report-format json
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
#### Options
|
|
763
|
+
|
|
764
|
+
| Option | Aliases | Required | Default | Description |
|
|
765
|
+
|---|---|---|---|---|
|
|
766
|
+
| `--config` | -c | No | | Path to config file (micro-contracts.config.yaml). |
|
|
767
|
+
| `--guardrails` | -g | No | | Path to guardrails.yaml. |
|
|
768
|
+
| `--adapter` | -a | No | | SDK adapter to use for LLM execution. |
|
|
769
|
+
| `--model` | | No | | LLM model override. |
|
|
770
|
+
| `--fail-on` | | No | `"error"` | Minimum severity that causes a non-zero exit. |
|
|
771
|
+
| `--output` | -o | No | | Write result to a file instead of stdout. |
|
|
772
|
+
| `--report-format` | | No | `"text"` | Output format for the audit report. |
|
|
773
|
+
|
|
774
|
+
#### Exit Codes
|
|
775
|
+
|
|
776
|
+
**Exit 0:** Audit completed, no blocking findings.
|
|
777
|
+
|
|
778
|
+
- **stdout:** format=`{options.report-format}`
|
|
779
|
+
|
|
780
|
+
**Exit 1:** Unexpected error.
|
|
781
|
+
|
|
782
|
+
- **stderr:** format=`text`
|
|
783
|
+
|
|
784
|
+
**Exit 3:** Input validation failed (guardrails.yaml not found).
|
|
785
|
+
|
|
786
|
+
- **stderr:** format=`text`
|
|
787
|
+
|
|
788
|
+
**Exit 10:** Completed with blocking findings.
|
|
789
|
+
|
|
790
|
+
- **stdout:** format=`{options.report-format}`
|
|
791
|
+
|
|
792
|
+
**Exit 11:** Runtime dependency missing (agent-contracts-runtime).
|
|
793
|
+
|
|
794
|
+
- **stderr:** format=`text`
|
|
795
|
+
|
|
796
|
+
**Exit 12:** LLM provider or adapter error.
|
|
797
|
+
|
|
798
|
+
- **stderr:** format=`text`
|
|
799
|
+
|
|
800
|
+
#### Extensions
|
|
801
|
+
|
|
802
|
+
```yaml
|
|
803
|
+
x-agent:
|
|
804
|
+
risk_level: low
|
|
805
|
+
requires_confirmation: false
|
|
806
|
+
idempotent: true
|
|
807
|
+
side_effects:
|
|
808
|
+
- network
|
|
809
|
+
sideEffectNote: Network calls to LLM provider when adapter is not mock. Filesystem write only when --output is specified.
|
|
810
|
+
safe_dry_run_option: show-prompt
|
|
811
|
+
expectedDurationMs: 120000
|
|
812
|
+
retryableExitCodes:
|
|
813
|
+
- 12
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "micro-contracts",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "Contract-first OpenAPI toolchain that keeps TypeScript UI and microservices aligned via code generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
"test": "vitest run",
|
|
22
22
|
"test:watch": "vitest",
|
|
23
23
|
"generate": "tsx src/cli.ts generate",
|
|
24
|
+
"contract:validate": "npx cli-contracts validate",
|
|
25
|
+
"contract:generate": "npx cli-contracts generate",
|
|
26
|
+
"dsl:generate": "npx agent-runtime generate --config dsl/agent-runtime.config.yaml",
|
|
24
27
|
"docs:sync": "npx embedoc build",
|
|
25
28
|
"docs:check": "npx embedoc build && git diff --exit-code README.md docs/",
|
|
26
29
|
"prepublishOnly": "npm run build && npm test"
|
|
@@ -47,15 +50,30 @@
|
|
|
47
50
|
"url": "https://github.com/foo-ogawa/micro-contracts/issues"
|
|
48
51
|
},
|
|
49
52
|
"dependencies": {
|
|
53
|
+
"chalk": "^5.3.0",
|
|
50
54
|
"commander": "^12.1.0",
|
|
51
55
|
"glob": "^10.3.10",
|
|
52
56
|
"handlebars": "^4.7.8",
|
|
53
57
|
"js-yaml": "^4.1.0",
|
|
54
|
-
"yaml": "^2.8.2"
|
|
58
|
+
"yaml": "^2.8.2",
|
|
59
|
+
"zod": "^3.22.0"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"agent-contracts-runtime": ">=0.30.0"
|
|
63
|
+
},
|
|
64
|
+
"peerDependenciesMeta": {
|
|
65
|
+
"agent-contracts-runtime": {
|
|
66
|
+
"optional": true
|
|
67
|
+
}
|
|
55
68
|
},
|
|
56
69
|
"devDependencies": {
|
|
70
|
+
"@cursor/sdk": "^1.0.13",
|
|
71
|
+
"@google/genai": "^2.4.0",
|
|
72
|
+
"@openai/agents": "^0.11.1",
|
|
57
73
|
"@types/js-yaml": "^4.0.9",
|
|
58
74
|
"@types/node": "^20.11.0",
|
|
75
|
+
"agent-contracts": "^0.30.1",
|
|
76
|
+
"agent-contracts-runtime": "^0.30.0",
|
|
59
77
|
"cli-contracts": "^0.30.2",
|
|
60
78
|
"embedoc": "^0.9.0",
|
|
61
79
|
"tsx": "^4.7.0",
|