@markdown-ai/cli 1.0.0-rc.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.
Files changed (66) hide show
  1. package/HOW-TO-USE.md +386 -0
  2. package/README.md +18 -0
  3. package/dist/cli.js +11297 -0
  4. package/dist/conformance/README.md +36 -0
  5. package/dist/conformance/invalid/11-name-uppercase.mda +8 -0
  6. package/dist/conformance/invalid/12-description-over-1024.mda +8 -0
  7. package/dist/conformance/invalid/13-skill-output-mda-extended-toplevel.md +10 -0
  8. package/dist/conformance/invalid/14-signature-without-integrity.mda +14 -0
  9. package/dist/conformance/invalid/15-version-range-compound.mda +13 -0
  10. package/dist/conformance/invalid/16-agents-md-allowed-tools-toplevel.md +8 -0
  11. package/dist/conformance/invalid/17-mcp-server-md-missing-name.md +7 -0
  12. package/dist/conformance/invalid/18-integrity-bad-digest-length.mda +11 -0
  13. package/dist/conformance/invalid/19-signature-digest-mismatch.mda +17 -0
  14. package/dist/conformance/invalid/24-unterminated-frontmatter.mda +7 -0
  15. package/dist/conformance/invalid/25-invalid-utf8.mda +8 -0
  16. package/dist/conformance/invalid/26-skill-md-body-only.md +3 -0
  17. package/dist/conformance/invalid/28-trust-policy-issuer-only.json +12 -0
  18. package/dist/conformance/invalid/29-sigstore-signature-without-rekor.mda +15 -0
  19. package/dist/conformance/invalid/30-did-web-signature-with-rekor.mda +17 -0
  20. package/dist/conformance/invalid/31-payload-type-jcs-suffix.mda +18 -0
  21. package/dist/conformance/invalid/32-trust-policy-sigstore-without-rekor.json +10 -0
  22. package/dist/conformance/invalid/33-trust-policy-sigstore-empty-rekor.json +11 -0
  23. package/dist/conformance/invalid/34-trust-policy-sigstore-rekor-disabled.json +14 -0
  24. package/dist/conformance/invalid/37-trusted-runtime-missing-integrity.mda +11 -0
  25. package/dist/conformance/invalid/38-trusted-runtime-missing-signature.mda +14 -0
  26. package/dist/conformance/invalid/39-trusted-runtime-duplicate-did-web-signature.mda +25 -0
  27. package/dist/conformance/invalid/40-trusted-runtime-untrusted-did-web-signer.mda +20 -0
  28. package/dist/conformance/invalid/41-trust-policy-did-web-with-rekor.json +12 -0
  29. package/dist/conformance/invalid/44-trusted-runtime-untrusted-sigstore-subject.mda +23 -0
  30. package/dist/conformance/invalid/45-runtime-policy-version-2.json +9 -0
  31. package/dist/conformance/manifest.yaml +376 -0
  32. package/dist/conformance/valid/01-frontmatter-minimal.mda +8 -0
  33. package/dist/conformance/valid/03-relationships-with-mirror.mda +20 -0
  34. package/dist/conformance/valid/04-depends-on-and-requires.mda +21 -0
  35. package/dist/conformance/valid/05-integrity-sha256.mda +14 -0
  36. package/dist/conformance/valid/06-sigstore-signed.mda +22 -0
  37. package/dist/conformance/valid/07-did-web-signed.mda +20 -0
  38. package/dist/conformance/valid/08-agents-md-frontmatter-free.md +9 -0
  39. package/dist/conformance/valid/09-agents-md-with-frontmatter.md +12 -0
  40. package/dist/conformance/valid/20-bom-prefixed.mda +8 -0
  41. package/dist/conformance/valid/21-crlf-line-endings.mda +8 -0
  42. package/dist/conformance/valid/22-body-with-horizontal-rule.mda +16 -0
  43. package/dist/conformance/valid/23-empty-body.mda +4 -0
  44. package/dist/conformance/valid/27-trust-policy-github-actions.json +13 -0
  45. package/dist/conformance/valid/35-trust-policy-did-web.json +9 -0
  46. package/dist/conformance/valid/36-trust-policy-did-web-two-signatures.json +14 -0
  47. package/dist/conformance/valid/42-trust-policy-human-sigstore.json +13 -0
  48. package/dist/conformance/valid/43-trusted-runtime-sigstore-signed.mda +23 -0
  49. package/dist/schemas/_defs/depends-on.schema.json +18 -0
  50. package/dist/schemas/_defs/description.schema.json +9 -0
  51. package/dist/schemas/_defs/integrity.schema.json +34 -0
  52. package/dist/schemas/_defs/iso8601.schema.json +8 -0
  53. package/dist/schemas/_defs/mda-extended.schema.json +43 -0
  54. package/dist/schemas/_defs/mda-keys.schema.json +34 -0
  55. package/dist/schemas/_defs/metadata-namespaces.schema.json +48 -0
  56. package/dist/schemas/_defs/name.schema.json +10 -0
  57. package/dist/schemas/_defs/requires.schema.json +13 -0
  58. package/dist/schemas/_defs/signature.schema.json +72 -0
  59. package/dist/schemas/_defs/version-range.schema.json +8 -0
  60. package/dist/schemas/frontmatter-agents-md.schema.json +24 -0
  61. package/dist/schemas/frontmatter-mcp-server-md.schema.json +25 -0
  62. package/dist/schemas/frontmatter-skill-md.schema.json +26 -0
  63. package/dist/schemas/frontmatter-source.schema.json +37 -0
  64. package/dist/schemas/mda-trust-policy.schema.json +113 -0
  65. package/dist/schemas/relationship-footnote.schema.json +45 -0
  66. package/package.json +42 -0
package/HOW-TO-USE.md ADDED
@@ -0,0 +1,386 @@
1
+ # Markdown AI CLI
2
+
3
+ `@markdown-ai/cli` gives you one small command: `mda`.
4
+
5
+ It takes a `.mda` source file and turns it into the Markdown files that agents already know how to read: `SKILL.md`, `AGENTS.md`, and `MCP-SERVER.md`.
6
+
7
+ The most useful path is simple:
8
+
9
+ ```sh
10
+ npx @markdown-ai/cli init hello-skill --out hello.mda
11
+ npx @markdown-ai/cli validate hello.mda
12
+ npx @markdown-ai/cli compile hello.mda --target SKILL.md AGENTS.md --out-dir out --integrity
13
+ ```
14
+
15
+ That is the main flow. Start there.
16
+
17
+ Run the command with no arguments whenever you are lost:
18
+
19
+ ```sh
20
+ npx @markdown-ai/cli
21
+ ```
22
+
23
+ No arguments means help. It does not validate files, write files, sign anything, verify anything, or touch the network.
24
+
25
+ After installation, the binary name is `mda`:
26
+
27
+ ```sh
28
+ npm install -g @markdown-ai/cli
29
+ mda --help
30
+ ```
31
+
32
+ ## Quick Start
33
+
34
+ Create a source file:
35
+
36
+ ```sh
37
+ mda init hello-skill --out hello.mda
38
+ ```
39
+
40
+ Validate it:
41
+
42
+ ```sh
43
+ mda validate hello.mda
44
+ ```
45
+
46
+ Compile it into agent-readable Markdown:
47
+
48
+ ```sh
49
+ mda compile hello.mda --target SKILL.md AGENTS.md --out-dir out --integrity
50
+ ```
51
+
52
+ Validate the output:
53
+
54
+ ```sh
55
+ mda validate out/SKILL.md --target SKILL.md
56
+ mda validate out/AGENTS.md --target AGENTS.md
57
+ ```
58
+
59
+ Check the integrity field:
60
+
61
+ ```sh
62
+ mda integrity verify out/SKILL.md --target SKILL.md
63
+ ```
64
+
65
+ For most users, that is enough. You create one `.mda`, compile it, and hand the output files to the system that needs them.
66
+
67
+ ## For AI Agents
68
+
69
+ Use `--json` almost every time.
70
+
71
+ Human output is for eyes. JSON output is for code. It gives you stable fields: `ok`, `command`, `exitCode`, and `diagnostics`.
72
+
73
+ There are two good ways for an agent to use this CLI.
74
+
75
+ The first is authoring. The agent creates or edits `.mda`, validates it, compiles it, then validates the outputs.
76
+
77
+ Recommended authoring flow:
78
+
79
+ ```sh
80
+ mda init task-skill --out task.mda --json
81
+ mda validate task.mda --target source --json
82
+ mda compile task.mda --target SKILL.md AGENTS.md MCP-SERVER.md --out-dir out --integrity --json
83
+ mda validate out/SKILL.md --target SKILL.md --json
84
+ mda validate out/AGENTS.md --target AGENTS.md --json
85
+ mda validate out/MCP-SERVER.md --target MCP-SERVER.md --json
86
+ mda integrity verify out/SKILL.md --target SKILL.md --json
87
+ ```
88
+
89
+ The second is runtime checking. This does not mean your application should depend on `@markdown-ai/cli`, or shell out from a library loader. It means an AI agent can run `mda` as an external gate before it trusts, edits, compiles, or acts on an MDA artifact.
90
+
91
+ Good runtime agent checks:
92
+
93
+ ```sh
94
+ mda validate config.mda --target source --json
95
+ mda integrity verify config.mda --target source --json
96
+ mda validate SKILL.md --target SKILL.md --json
97
+ mda validate AGENTS.md --target AGENTS.md --json
98
+ mda canonicalize SKILL.md --target SKILL.md --json
99
+ ```
100
+
101
+ For MCP multi-file artifacts:
102
+
103
+ ```sh
104
+ mda validate MCP-SERVER.md --target MCP-SERVER.md --json
105
+ mda integrity verify MCP-SERVER.md --target MCP-SERVER.md --sidecar mcp-server.json --json
106
+ ```
107
+
108
+ An agent should treat these checks as a gate:
109
+
110
+ - If `ok` is `true` and `exitCode` is `0`, continue.
111
+ - If the command exits non-zero, stop using that artifact and report `diagnostics`.
112
+ - If the file is a Markdown file with a non-standard name, pass `--target`.
113
+ - If the command needs to write files, write into a temp or staging directory first.
114
+
115
+ Do not use this CLI as the only runtime trust boundary for an application. `mda verify` is not a complete cryptographic verifier in this MVP, and `mda sign` is intentionally unavailable. Use library-level verifier hooks for application runtime trust decisions.
116
+
117
+ Read success like this:
118
+
119
+ - `ok: true`
120
+ - `exitCode: 0`
121
+
122
+ Read failure like this:
123
+
124
+ - Check `diagnostics[0].code` first.
125
+ - Then read `diagnostics[0].message`.
126
+ - Do not scrape human text from stderr when `--json` is available.
127
+
128
+ Use explicit targets when the filename is not obvious. The CLI can detect `hello.mda`, `SKILL.md`, `AGENTS.md`, and `MCP-SERVER.md`. Any other Markdown filename needs `--target`.
129
+
130
+ Good:
131
+
132
+ ```sh
133
+ mda validate generated.md --target SKILL.md --json
134
+ ```
135
+
136
+ Ambiguous:
137
+
138
+ ```sh
139
+ mda validate generated.md --json
140
+ ```
141
+
142
+ For MCP multi-file commands, always pass the sidecar when canonicalizing or checking integrity:
143
+
144
+ ```sh
145
+ mda canonicalize out/MCP-SERVER.md --target MCP-SERVER.md --sidecar out/mcp-server.json --json
146
+ mda integrity verify out/MCP-SERVER.md --target MCP-SERVER.md --sidecar out/mcp-server.json --json
147
+ ```
148
+
149
+ Plain validation of `MCP-SERVER.md` does not need the sidecar:
150
+
151
+ ```sh
152
+ mda validate out/MCP-SERVER.md --target MCP-SERVER.md --json
153
+ ```
154
+
155
+ ## For Humans
156
+
157
+ The easiest way is to run one command at a time and look at the file it produced.
158
+
159
+ Start with:
160
+
161
+ ```sh
162
+ mda init hello-skill --out hello.mda
163
+ ```
164
+
165
+ Open `hello.mda`. Edit the name, description, and body. Then run:
166
+
167
+ ```sh
168
+ mda validate hello.mda
169
+ ```
170
+
171
+ If it passes, compile:
172
+
173
+ ```sh
174
+ mda compile hello.mda --target SKILL.md AGENTS.md --out-dir out --integrity
175
+ ```
176
+
177
+ You will get files under `out/`. Use those files where your agent runtime expects them.
178
+
179
+ The word `integrity` sounds like cryptography. Here it mostly means "make a stable fingerprint of the file, then check that the file still matches it." It is like a checksum on a downloaded file. It tells you whether bytes changed. It does not prove who wrote the file.
180
+
181
+ Signing and full trust verification are not ready in this MVP. The CLI fails closed instead of pretending. That is intentional.
182
+
183
+ ## What To Use Most
184
+
185
+ Use these commands day to day:
186
+
187
+ ```sh
188
+ mda
189
+ mda init <name> --out <file.mda>
190
+ mda validate <file> [--target <target>]
191
+ mda compile <file.mda> --target SKILL.md AGENTS.md --out-dir out --integrity
192
+ mda integrity verify <file> --target <target>
193
+ ```
194
+
195
+ Use these when you need exact bytes or automated checks:
196
+
197
+ ```sh
198
+ mda canonicalize <file> --target <target> --json
199
+ mda integrity compute <file> --target <target> --algorithm sha256 --json
200
+ mda conformance --level V --json
201
+ ```
202
+
203
+ Use these carefully:
204
+
205
+ ```sh
206
+ mda verify <file> --policy <policy.json> --json
207
+ mda sign <file> --method did-web --key <key.pem> --identity <domain> --out <signed.md>
208
+ ```
209
+
210
+ `verify` validates policy shape and integrity, then fails when real signature verification is required. `sign` is unavailable in this MVP. Both commands exist so scripts can depend on the shape without getting a fake security result.
211
+
212
+ ## Targets
213
+
214
+ Targets tell the CLI what kind of artifact a file is.
215
+
216
+ Allowed targets:
217
+
218
+ - `source`
219
+ - `SKILL.md`
220
+ - `AGENTS.md`
221
+ - `MCP-SERVER.md`
222
+ - `auto`
223
+
224
+ Auto-detection is exact:
225
+
226
+ - `*.mda` means `source`
227
+ - `SKILL.md` means `SKILL.md`
228
+ - `AGENTS.md` means `AGENTS.md`
229
+ - `MCP-SERVER.md` means `MCP-SERVER.md`
230
+ - any other `.md` file needs `--target`
231
+
232
+ When in doubt, pass `--target`. It removes ambiguity for humans and agents.
233
+
234
+ ## Command Reference
235
+
236
+ Print full help:
237
+
238
+ ```sh
239
+ mda
240
+ mda --help
241
+ ```
242
+
243
+ Create a source scaffold:
244
+
245
+ ```sh
246
+ mda init <name> [--out <file>] [--json]
247
+ ```
248
+
249
+ Options:
250
+
251
+ - `--out <file>` writes the scaffold to a file and refuses to overwrite.
252
+ - `--json` returns the scaffold inside JSON instead of raw `.mda` text.
253
+
254
+ Validate a source or output file:
255
+
256
+ ```sh
257
+ mda validate <file> [--target source|SKILL.md|AGENTS.md|MCP-SERVER.md|auto] [--json]
258
+ ```
259
+
260
+ Options:
261
+
262
+ - `--target <target>` sets the artifact type. Default: `auto`.
263
+ - `--json` prints machine-readable output.
264
+
265
+ Compile a source file:
266
+
267
+ ```sh
268
+ mda compile <file.mda> --target <target...> [--out-dir <dir>] [--integrity] [--json]
269
+ ```
270
+
271
+ Options:
272
+
273
+ - `--target <target...>` is required. Use one or more of `SKILL.md`, `AGENTS.md`, `MCP-SERVER.md`.
274
+ - `--out-dir <dir>` writes outputs into a directory. Default: current directory.
275
+ - `--integrity` adds a `sha256` integrity field to emitted artifacts.
276
+ - `--json` lists planned and written output files.
277
+
278
+ Canonicalize a file:
279
+
280
+ ```sh
281
+ mda canonicalize <file> [--target source|SKILL.md|AGENTS.md|MCP-SERVER.md|auto] [--sidecar <path>] [--json]
282
+ ```
283
+
284
+ Options:
285
+
286
+ - `--target <target>` sets the artifact type. Default: `auto`.
287
+ - `--sidecar <path>` is required only for MCP multi-file canonical bytes.
288
+ - `--json` returns base64 canonical bytes and metadata. Without `--json`, raw canonical bytes are printed.
289
+
290
+ Compute integrity:
291
+
292
+ ```sh
293
+ mda integrity compute <file> [--target source|SKILL.md|AGENTS.md|MCP-SERVER.md|auto] [--sidecar <path>] [--algorithm sha256|sha384|sha512] [--json]
294
+ ```
295
+
296
+ Options:
297
+
298
+ - `--target <target>` sets the artifact type. Default: `auto`.
299
+ - `--sidecar <path>` is required only for `MCP-SERVER.md` multi-file integrity.
300
+ - `--algorithm <name>` chooses `sha256`, `sha384`, or `sha512`. Default: `sha256`.
301
+ - `--json` prints the digest in JSON.
302
+
303
+ Verify integrity:
304
+
305
+ ```sh
306
+ mda integrity verify <file> [--target source|SKILL.md|AGENTS.md|MCP-SERVER.md|auto] [--sidecar <path>] [--json]
307
+ ```
308
+
309
+ Options:
310
+
311
+ - `--target <target>` sets the artifact type. Default: `auto`.
312
+ - `--sidecar <path>` is required only for `MCP-SERVER.md` multi-file integrity.
313
+ - `--json` prints the verification result in JSON.
314
+
315
+ Verify trust policy and signatures:
316
+
317
+ ```sh
318
+ mda verify <file> --policy <path> [--target source|SKILL.md|AGENTS.md|MCP-SERVER.md|auto] [--sidecar <path>] [--json]
319
+ ```
320
+
321
+ Options:
322
+
323
+ - `--policy <path>` is required.
324
+ - `--target <target>` sets the artifact type. Default: `auto`.
325
+ - `--sidecar <path>` is required only for `MCP-SERVER.md` multi-file integrity.
326
+ - `--json` prints the result in JSON.
327
+ - `--offline` exists only as an unsupported MVP flag. It exits with a usage error.
328
+
329
+ Sign an artifact:
330
+
331
+ ```sh
332
+ mda sign <file> --method did-web --key <path> --identity <domain> (--out <file>|--in-place) [--json]
333
+ ```
334
+
335
+ Options:
336
+
337
+ - `--method did-web` is required.
338
+ - `--key <path>` is required.
339
+ - `--identity <domain>` is required.
340
+ - `--out <file>` writes signed output to a new file.
341
+ - `--in-place` replaces the input file.
342
+ - `--json` prints the result in JSON.
343
+
344
+ Signing is intentionally unavailable in this MVP. The command exits non-zero with `signing-unavailable`.
345
+
346
+ Run conformance:
347
+
348
+ ```sh
349
+ mda conformance [--suite <path>] [--level V|C] [--json]
350
+ ```
351
+
352
+ Options:
353
+
354
+ - `--suite <path>` points to a conformance suite directory.
355
+ - `--level V|C` selects validation or compile conformance. Default: `V`.
356
+ - `--json` prints pass and fail counts in JSON.
357
+
358
+ ## Global Flags
359
+
360
+ These flags work across commands:
361
+
362
+ - `--json` prints stable JSON only on stdout.
363
+ - `--quiet` suppresses non-essential human output.
364
+ - `--verbose` includes extra diagnostic context where available.
365
+ - `--no-color` disables ANSI color.
366
+ - `-h`, `--help` prints full help.
367
+
368
+ For agents, prefer `--json`. For humans, plain output is easier to read.
369
+
370
+ ## Exit Codes
371
+
372
+ - `0`: success
373
+ - `1`: command ran, but validation or verification failed
374
+ - `2`: usage error, such as a missing argument, unknown flag, or ambiguous target
375
+ - `3`: IO or configuration error, such as overwrite refusal or unreadable policy
376
+ - `4`: internal bug
377
+
378
+ Agents should use the exit code and JSON fields together. Humans can usually read the printed diagnostic and fix the command.
379
+
380
+ ## Status
381
+
382
+ This is the MVP CLI.
383
+
384
+ Validation, compilation, canonicalization, integrity checks, and level V conformance are the useful parts today.
385
+
386
+ Full signing and cryptographic trust verification are not complete. The CLI says no when it cannot prove the answer. Quietly, but clearly.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @markdown-ai/cli
2
+
3
+ Reference CLI for Markdown AI / MDA artifacts.
4
+
5
+ ```sh
6
+ npx @markdown-ai/cli --help
7
+ ```
8
+
9
+ The installed binary is `mda`.
10
+
11
+ ```sh
12
+ mda init hello-skill --out hello.mda
13
+ mda validate hello.mda --json
14
+ mda compile hello.mda --target SKILL.md AGENTS.md MCP-SERVER.md --out-dir out --integrity
15
+ mda conformance --level V --json
16
+ ```
17
+
18
+ See [HOW-TO-USE.md](./HOW-TO-USE.md) for the command manual.