@mmmnt/cli 0.0.1 → 0.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/README.md +276 -1
- package/dist/moment.mjs +58852 -0
- package/dist/moment.mjs.map +7 -0
- package/package.json +31 -4
package/README.md
CHANGED
|
@@ -1,3 +1,278 @@
|
|
|
1
1
|
# @mmmnt/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Command-line interface for the Moment domain specification language and implementation toolchain.
|
|
4
|
+
|
|
5
|
+
[](../../LICENSE.md)
|
|
6
|
+
[](https://www.npmjs.com/package/@mmmnt/cli)
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
`@mmmnt/cli` provides the `moment` command, which is the primary way most developers interact with the Moment toolchain. It wraps every package in the `@mmmnt` ecosystem behind a consistent, discoverable command-line interface with 20+ commands covering the full specification-to-implementation workflow.
|
|
11
|
+
|
|
12
|
+
From initializing a new project to parsing specifications, deriving test topologies, generating TypeScript code and BDD scenarios, running conformance tests, detecting implementation drift, and managing schema lifecycles -- every operation is available as a single CLI command. The CLI handles file I/O, output formatting, error reporting, and watch mode so that the underlying library packages remain focused on their core logic.
|
|
13
|
+
|
|
14
|
+
The CLI is designed for both interactive development and CI/CD pipeline integration. All commands produce structured output suitable for scripting, and exit codes follow standard conventions for use in automated workflows. The `--format json` flag is available on most commands for machine-readable output, and `--verbose` enables detailed logging for debugging.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Install globally
|
|
20
|
+
npm install -g @mmmnt/cli
|
|
21
|
+
|
|
22
|
+
# Or run directly without installing
|
|
23
|
+
npx @mmmnt/cli
|
|
24
|
+
|
|
25
|
+
# Or install as a project dev dependency
|
|
26
|
+
npm install --save-dev @mmmnt/cli
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or with other package managers:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm add -g @mmmnt/cli
|
|
33
|
+
yarn global add @mmmnt/cli
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Initialize a new Moment project
|
|
40
|
+
moment init my-service
|
|
41
|
+
|
|
42
|
+
# Parse and validate a .moment specification
|
|
43
|
+
moment parse specs/my-service.moment
|
|
44
|
+
|
|
45
|
+
# Derive test topologies and scenarios
|
|
46
|
+
moment derive specs/my-service.moment
|
|
47
|
+
|
|
48
|
+
# Generate TypeScript types and test scaffolds
|
|
49
|
+
moment emit-ts specs/my-service.moment
|
|
50
|
+
|
|
51
|
+
# Generate Gherkin BDD scenarios
|
|
52
|
+
moment generate specs/my-service.moment
|
|
53
|
+
|
|
54
|
+
# Run specification conformance tests
|
|
55
|
+
moment test specs/my-service.moment
|
|
56
|
+
|
|
57
|
+
# Watch for spec changes and regenerate automatically
|
|
58
|
+
moment watch specs/
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Key Features
|
|
62
|
+
|
|
63
|
+
- **Unified entry point** -- a single `moment` binary that wraps all `@mmmnt` packages, so you do not need to import or configure individual libraries.
|
|
64
|
+
- **20+ commands** -- covers the full lifecycle from project initialization through specification, derivation, generation, testing, synchronization, and governance.
|
|
65
|
+
- **Watch mode** -- monitors `.moment` files and automatically re-parses and regenerates artifacts on save.
|
|
66
|
+
- **Structured output** -- all commands support `--format json` for machine-readable output in CI/CD pipelines.
|
|
67
|
+
- **Standard exit codes** -- non-zero exit on validation failures, drift detection, or test failures for pipeline gating.
|
|
68
|
+
- **Subcommand structure** -- complex operations like `sync` and `schema` use subcommands (`sync status`, `sync propose`, `sync accept`, `schema status`) for organized workflows.
|
|
69
|
+
- **Authentication support** -- `moment auth` subcommands manage credentials for Moment cloud services when applicable.
|
|
70
|
+
- **Verbose mode** -- `--verbose` enables detailed logging for debugging specification issues or generation failures.
|
|
71
|
+
|
|
72
|
+
## Commands
|
|
73
|
+
|
|
74
|
+
### Project Initialization
|
|
75
|
+
|
|
76
|
+
| Command | Description |
|
|
77
|
+
|---------|-------------|
|
|
78
|
+
| `moment init <name>` | Initialize a new Moment project with directory structure, `moment.manifest.json`, and a starter `.moment` specification file. |
|
|
79
|
+
|
|
80
|
+
### Specification
|
|
81
|
+
|
|
82
|
+
| Command | Description |
|
|
83
|
+
|---------|-------------|
|
|
84
|
+
| `moment parse <file>` | Parse and validate a `.moment` specification file. Reports syntax errors and semantic diagnostics with line numbers and column positions. |
|
|
85
|
+
| `moment watch <dir>` | Watch a directory for `.moment` file changes and automatically re-parse and regenerate artifacts. Runs until interrupted. |
|
|
86
|
+
|
|
87
|
+
### Derivation
|
|
88
|
+
|
|
89
|
+
| Command | Description |
|
|
90
|
+
|---------|-------------|
|
|
91
|
+
| `moment derive <file>` | Derive test topologies, simulation scenarios, event catalogs, impact analysis, and saga state machines from a specification. |
|
|
92
|
+
| `moment simulate <file>` | Run simulation scenarios against the specification and report event flow traces. |
|
|
93
|
+
|
|
94
|
+
### Code Generation
|
|
95
|
+
|
|
96
|
+
| Command | Description |
|
|
97
|
+
|---------|-------------|
|
|
98
|
+
| `moment emit-ts <file>` | Generate TypeScript interfaces, aggregate root classes, discriminated event union types, and test scaffold files from the specification. |
|
|
99
|
+
| `moment generate <file>` | Generate Gherkin `.feature` files, a `specification.md` document with Mermaid diagrams, and an `asyncapi.yaml` specification. |
|
|
100
|
+
|
|
101
|
+
### Testing
|
|
102
|
+
|
|
103
|
+
| Command | Description |
|
|
104
|
+
|---------|-------------|
|
|
105
|
+
| `moment test <file>` | Execute derived tests against your domain implementation and report conformance results. Non-zero exit code on failures. |
|
|
106
|
+
|
|
107
|
+
### Visualization
|
|
108
|
+
|
|
109
|
+
| Command | Description |
|
|
110
|
+
|---------|-------------|
|
|
111
|
+
| `moment viz <file>` | Generate visualization data (context maps, flow timelines) as a JSON `VizDataEnvelope`. Output can be piped to files or visualization tools. |
|
|
112
|
+
|
|
113
|
+
### Synchronization
|
|
114
|
+
|
|
115
|
+
| Command | Description |
|
|
116
|
+
|---------|-------------|
|
|
117
|
+
| `moment sync status <file>` | Detect drift between the specification and implementation by comparing generated and actual TypeScript files. Non-zero exit code on drift. |
|
|
118
|
+
| `moment sync propose <file>` | Generate change proposals to reconcile detected drift between specification and implementation. |
|
|
119
|
+
| `moment sync accept <file>` | Accept proposed changes and apply them to the implementation. |
|
|
120
|
+
| `moment reconcile <file>` | Run cascade reconciliation to classify and resolve drift. Supports `--mode local` and `--mode event` for different reconciliation sources. |
|
|
121
|
+
| `moment status <file>` | Display unified project status: parse validity, sync drift, schema lifecycle, and upstream fingerprint. |
|
|
122
|
+
|
|
123
|
+
### Schema Governance
|
|
124
|
+
|
|
125
|
+
| Command | Description |
|
|
126
|
+
|---------|-------------|
|
|
127
|
+
| `moment schema status <file>` | Display schema lifecycle status for all events and commands in the specification, grouped by phase. |
|
|
128
|
+
| `moment lint <file>` | Run codex governance rules against the specification and report policy violations. Supports `--format json` for CI integration. |
|
|
129
|
+
|
|
130
|
+
### Import
|
|
131
|
+
|
|
132
|
+
| Command | Description |
|
|
133
|
+
|---------|-------------|
|
|
134
|
+
| `moment import --from-sift <dir>` | Import Sift JSONL event streams from a `.domain/` directory into `.moment` specification files. Writes upstream fingerprint for drift tracking. |
|
|
135
|
+
|
|
136
|
+
### Authentication
|
|
137
|
+
|
|
138
|
+
| Command | Description |
|
|
139
|
+
|---------|-------------|
|
|
140
|
+
| `moment auth login` | Authenticate with Moment cloud services. Initiates an interactive login flow. |
|
|
141
|
+
| `moment auth status` | Display current authentication status and account information. |
|
|
142
|
+
| `moment auth logout` | Clear stored authentication credentials. |
|
|
143
|
+
|
|
144
|
+
## Global Options
|
|
145
|
+
|
|
146
|
+
| Option | Description |
|
|
147
|
+
|--------|-------------|
|
|
148
|
+
| `--help` | Display help for any command. |
|
|
149
|
+
| `--version` | Display the installed CLI version. |
|
|
150
|
+
| `--output <dir>` | Override the default output directory for generated artifacts. |
|
|
151
|
+
| `--format <fmt>` | Output format: `text` (default), `json`, or `silent`. |
|
|
152
|
+
| `--verbose` | Enable verbose logging for debugging. |
|
|
153
|
+
|
|
154
|
+
## Examples
|
|
155
|
+
|
|
156
|
+
### New Project Setup
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Scaffold a new project
|
|
160
|
+
moment init my-service
|
|
161
|
+
cd my-service
|
|
162
|
+
|
|
163
|
+
# Write your .moment specification, then generate everything
|
|
164
|
+
moment derive specs/my-service.moment
|
|
165
|
+
moment emit-ts specs/my-service.moment
|
|
166
|
+
moment generate specs/my-service.moment
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Continuous Development
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Watch mode regenerates on every save
|
|
173
|
+
moment watch specs/
|
|
174
|
+
|
|
175
|
+
# After implementing domain logic, run conformance tests
|
|
176
|
+
moment test specs/my-service.moment
|
|
177
|
+
|
|
178
|
+
# Check for drift
|
|
179
|
+
moment status specs/my-service.moment
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Upstream Specification Import
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Import from Sift event streams
|
|
186
|
+
moment import --from-sift .domain/
|
|
187
|
+
|
|
188
|
+
# Review the generated .moment files, then derive and generate
|
|
189
|
+
moment derive specs/my-service.moment
|
|
190
|
+
moment emit-ts specs/my-service.moment
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### CI/CD Pipeline
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
#!/bin/bash
|
|
197
|
+
set -e
|
|
198
|
+
|
|
199
|
+
# Validate specification
|
|
200
|
+
moment parse specs/my-service.moment
|
|
201
|
+
|
|
202
|
+
# Check for drift (non-zero exit code on drift)
|
|
203
|
+
moment sync status specs/my-service.moment
|
|
204
|
+
|
|
205
|
+
# Run conformance tests
|
|
206
|
+
moment test specs/my-service.moment
|
|
207
|
+
|
|
208
|
+
# Lint governance rules
|
|
209
|
+
moment lint specs/my-service.moment --format json
|
|
210
|
+
|
|
211
|
+
# Generate documentation artifacts
|
|
212
|
+
moment generate specs/my-service.moment
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Drift Detection and Reconciliation
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Check sync status
|
|
219
|
+
moment sync status specs/my-service.moment
|
|
220
|
+
|
|
221
|
+
# Generate proposals for detected drift
|
|
222
|
+
moment sync propose specs/my-service.moment
|
|
223
|
+
|
|
224
|
+
# Review proposals, then accept
|
|
225
|
+
moment sync accept specs/my-service.moment
|
|
226
|
+
|
|
227
|
+
# Or run full cascade reconciliation
|
|
228
|
+
moment reconcile specs/my-service.moment
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Schema Governance Audit
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# View schema lifecycle status
|
|
235
|
+
moment schema status specs/my-service.moment
|
|
236
|
+
|
|
237
|
+
# Run governance rules
|
|
238
|
+
moment lint specs/my-service.moment
|
|
239
|
+
|
|
240
|
+
# Machine-readable output for dashboards
|
|
241
|
+
moment schema status specs/my-service.moment --format json
|
|
242
|
+
moment lint specs/my-service.moment --format json
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Integration
|
|
246
|
+
|
|
247
|
+
`@mmmnt/cli` is the consumer-facing interface to the entire Moment toolchain. It depends on all library packages:
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
@mmmnt/cli
|
|
251
|
+
|
|
|
252
|
+
+-- @mmmnt/core (parsing and IR generation)
|
|
253
|
+
+-- @mmmnt/derive (test topology and scenario derivation)
|
|
254
|
+
+-- @mmmnt/emit-ts (TypeScript code generation)
|
|
255
|
+
+-- @mmmnt/generate (Gherkin, specification documents, AsyncAPI)
|
|
256
|
+
+-- @mmmnt/harness (test execution)
|
|
257
|
+
+-- @mmmnt/schema (schema lifecycle governance)
|
|
258
|
+
+-- @mmmnt/sync (drift detection and reconciliation)
|
|
259
|
+
+-- @mmmnt/viz (visualization data generation)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
For programmatic integration or AI agent workflows, see [@mmmnt/mcp](../mcp/README.md) which exposes the same capabilities over the Model Context Protocol.
|
|
263
|
+
|
|
264
|
+
## Contributing
|
|
265
|
+
|
|
266
|
+
This package is part of the [mmmnt monorepo](https://github.com/mmmnt/mmmnt). See the repository root for contribution guidelines, development setup, and the code of conduct.
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
git clone https://github.com/mmmnt/mmmnt.git
|
|
270
|
+
cd mmmnt
|
|
271
|
+
pnpm install
|
|
272
|
+
pnpm turbo build --filter=@mmmnt/cli
|
|
273
|
+
pnpm --filter @mmmnt/cli test
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## License
|
|
277
|
+
|
|
278
|
+
[FSL-1.1-Apache-2.0](../../LICENSE.md)
|