@acid-cat/cli 0.19.0 → 0.21.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 +32 -2
- package/conformance/fixture.acidcat.json +96 -0
- package/dist/conform-LH9KgQ9-.js +5045 -0
- package/dist/index.d.ts +164 -4
- package/dist/index.js +96 -4
- package/dist/main.d.ts +1 -2
- package/dist/main.js +1090 -7
- package/package.json +4 -3
- package/dist/catalog.d.ts +0 -12
- package/dist/catalog.js +0 -149
- package/dist/conform/check.d.ts +0 -47
- package/dist/conform/check.js +0 -178
- package/dist/conform/cli.d.ts +0 -5
- package/dist/conform/cli.js +0 -721
- package/dist/conform/http.d.ts +0 -6
- package/dist/conform/http.js +0 -297
- package/dist/conform/index.d.ts +0 -69
- package/dist/conform/index.js +0 -80
- package/dist/conform/mcp-stdio.d.ts +0 -7
- package/dist/conform/mcp-stdio.js +0 -291
- package/dist/conform/mcp.d.ts +0 -47
- package/dist/conform/mcp.js +0 -754
- package/dist/conform/poll.d.ts +0 -13
- package/dist/conform/poll.js +0 -295
- package/dist/conform/properties.d.ts +0 -12
- package/dist/conform/properties.js +0 -151
- package/dist/conform/serve.d.ts +0 -12
- package/dist/conform/serve.js +0 -96
- package/dist/conform/server-card.d.ts +0 -5
- package/dist/conform/server-card.js +0 -142
- package/dist/conform/sse.d.ts +0 -9
- package/dist/conform/sse.js +0 -53
- package/dist/conform/webhook.d.ts +0 -30
- package/dist/conform/webhook.js +0 -481
- package/dist/conform/webmcp.d.ts +0 -53
- package/dist/conform/webmcp.js +0 -232
- package/dist/json/catalog.schema.json.js +0 -170
- package/dist/json/fixture.acidcat.json.js +0 -396
- package/dist/json/package.json.js +0 -3
- package/dist/json/server-card.schema.json.js +0 -281
- package/dist/json.d.ts +0 -11
- package/dist/json.js +0 -13
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ The AcidCat command line, published on npm as `@acid-cat/cli`. It gives the `aci
|
|
|
5
5
|
```sh
|
|
6
6
|
acid-cat check [--strict] [--output json] <catalog.json ...> # check catalogs
|
|
7
7
|
acid-cat format [--write] <catalog.json ...> # write catalogs in canonical form
|
|
8
|
+
acid-cat generate <catalog.json> --core effect|ts|rust --out <file> [--check] # write the declarations of a catalog
|
|
8
9
|
acid-cat target <catalog.json> <target> # write the catalog of one target
|
|
9
10
|
acid-cat conform --mcp <url> [--mcp-handshake] --mcp-stdio "<command>" --http <url> --cli "<command>" --webmcp <url> [--deadline <ms>] [--max-bytes <n>] [--output json] # test an implementation
|
|
10
11
|
[--poll-buffer <n>] [--poll-lease-mcp <url> --poll-lease-ms <ms>] [--webhook-principal <name> --webhook-cert <file> --webhook-key <file>]
|
|
@@ -39,7 +40,7 @@ You get the JSON document only when the options are correct. With incorrect opti
|
|
|
39
40
|
- An **error** is a broken rule. Examples: an audience that names an unknown target, an event payload that is not an object, or an id that is both a capability and an event.
|
|
40
41
|
- A **warning** is a broken recommendation. Examples: a file that is not in [canonical form](../../spec/catalog.md#canonical-form), or a member with no `x-` prefix.
|
|
41
42
|
|
|
42
|
-
It also checks each alias in `options.cli` against the [alias rules](../../spec/surfaces/cli.md#aliases), and each `x-mcp-header` member in an input schema against the [header annotation rules](../../spec/surfaces/mcp.md#header-annotations) of MCP. An error about `x-mcp-header` names the capability or the event, and the location of the member as a JSON pointer into the bundled input schema.
|
|
43
|
+
It also checks each alias in `options.cli` against the [alias rules](../../spec/surfaces/cli.md#aliases), its [positional arguments](../../spec/surfaces/cli.md#positional-arguments) included, and each `x-mcp-header` member in an input schema against the [header annotation rules](../../spec/surfaces/mcp.md#header-annotations) of MCP. An error about `x-mcp-header` names the capability or the event, and the location of the member as a JSON pointer into the bundled input schema.
|
|
43
44
|
|
|
44
45
|
The exit code is 1 with errors, and 0 otherwise. With `--strict`, warnings also give exit code 1.
|
|
45
46
|
|
|
@@ -47,6 +48,35 @@ The exit code is 1 with errors, and 0 otherwise. With `--strict`, warnings also
|
|
|
47
48
|
|
|
48
49
|
`format` writes a catalog in [canonical form](../../spec/catalog.md#canonical-form). Use it for catalogs that no catalog library wrote: Pkl output, generated files, or files you edit by hand. `--write` changes the files in place.
|
|
49
50
|
|
|
51
|
+
## generate
|
|
52
|
+
|
|
53
|
+
Use a catalog file as the build input of a program ([the catalog file and the build](../../README.md#-the-catalog-file-and-the-build)). The command writes one file for the core that `--core` names: a TypeScript module with `effect` for `@acid-cat/core-effect` and `ts` for `@acid-cat/core-ts`, and a Rust module with `rust` for `acid-cat-core`. The TypeScript module exports the types of the catalog (`$defs`), a schema and a type for each type and each other schema, a declaration for each capability and event, and the application title, description and targets. The targets include the command-line aliases. A declaration has every member of a capability or an event except its handler: spread it into the function that makes the capability or the event, and add the handler, the state source and the availability. Each schema carries its JSON Schema from the catalog, so the core writes the catalog again byte for byte.
|
|
54
|
+
|
|
55
|
+
With `--core effect`, each schema is an Effect schema. The module imports only `effect` and `@acid-cat/core-effect`. Some schemas also get the check of the schema as code, the same check that `--core ts` writes: a schema that Effect cannot express, for example one with `oneOf` and `not`, and a schema with an object that has `additionalProperties: false`, because Effect removes the properties that a struct does not name. The Effect schema runs this check before the struct removes a property: on a value that it decodes, such as an input, and on a value that it encodes, such as an output, a failure, a state or a payload. It gives each issue with its message and its path. A schema that Effect cannot express has the type of a JSON value. The keywords of the table below apply only to a schema that has a check. A schema that Effect expresses fully has no check, so it can use any keyword that Effect reads, for example `uniqueItems`.
|
|
56
|
+
|
|
57
|
+
With `--core rust`, the module holds:
|
|
58
|
+
|
|
59
|
+
- A Rust type with `serde` for each type of `$defs` and each other schema: a struct for an object with `properties`, an enum for an `enum` of strings, `Vec` for an array, `Option` for a property that is not required, `String`, `bool`, `i64` and `f64`, and the named type for a `$ref`. A property name that is not snake case gets `#[serde(rename)]`. A schema with no Rust form, for example one with `oneOf`, is `serde_json::Value`. The back end never stops for a keyword: the core checks each value against the JSON Schema of the catalog.
|
|
60
|
+
- An enum with `#[serde(tag = "_tag")]` for each different set of failures, for example `FailureOfflineOrPoweredOff`, with one variant for each tag. A failure that is a `$ref` to an object type is a variant that holds that type, and the enum implements `From` for it.
|
|
61
|
+
- A function for each capability and each event, for example `aircon_status_get`, that returns a `Capability` or an `Event` with the id, the description, the audience, the hints and the schemas of the catalog. The function of a capability with state takes the state source. Add the availability, then the handler with `run` or `subscribe`.
|
|
62
|
+
- `application()`, which returns the `App` with the title, the description, the targets with their options and the types of `$defs`, and no capabilities. Add each capability and each event in the order that the command line lists them. A capability or an event that the program does not add is missing from its catalog, so the byte comparison with the catalog file finds it.
|
|
63
|
+
|
|
64
|
+
acid-cat-core cannot write a member of a capability, an event or a target that starts with `x-`, so for such a member the command writes no file and exits with 1. The module holds each schema as `serde_json::json!`. Include it with `#[rustfmt::skip]` and `#[path = "catalog.generated.rs"] mod catalog;`, because `cargo fmt` formats the module in a different way. The program needs `serde`, `serde_json`, and `tokio` if a capability has state.
|
|
65
|
+
|
|
66
|
+
With `--core ts`, the module holds the check of each schema as code: a function that checks a JSON value and gives each issue with a message and a path. Each schema is a [Standard Schema](https://standardschema.dev) that calls this function. The module imports only `@acid-cat/core-ts` and `@acid-cat/spec-ts`. A failure schema checks the failure without its `_tag`. The checks of `--core ts` and `--core effect` know these keywords:
|
|
67
|
+
|
|
68
|
+
| Kind | Keywords |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| Any value | `type`, `enum`, `const`, `$ref`, `allOf`, `anyOf`, `oneOf`, `not` |
|
|
71
|
+
| Number | `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum` |
|
|
72
|
+
| String | `minLength`, `maxLength` (in code points), `pattern` (a regular expression with the `u` flag) |
|
|
73
|
+
| Object | `properties`, `required`, `additionalProperties` |
|
|
74
|
+
| Array | `items`, `minItems`, `maxItems` |
|
|
75
|
+
|
|
76
|
+
The annotations `title`, `description`, `default`, `examples`, `deprecated`, `readOnly`, `writeOnly`, `$comment`, `$schema`, `contentMediaType`, `contentEncoding`, `contentSchema` and each member that starts with `x-` need no check. `format` is an annotation, as JSON Schema 2020-12 defines it by default: the check accepts a string in any format. The other cores also accept it. For any other keyword in a schema that has a check, the command writes no file, names the keyword and the place in the catalog, and exits with 1.
|
|
77
|
+
|
|
78
|
+
Commit the generated file beside the program. Run the same command with `--check` in CI. It writes nothing and exits with 0 for the current file or 1 for a stale or missing file. See the [Effect example](../../examples/aircon/core-effect/aircon.ts), the [TypeScript example](../../examples/aircon/core-ts/aircon.ts) and the [Rust example](../../examples/aircon/core-rust/src/main.rs) for the handlers.
|
|
79
|
+
|
|
50
80
|
## target
|
|
51
81
|
|
|
52
82
|
`target` writes the [catalog of one target](../../spec/catalog.md#the-catalog-of-a-target): the capabilities, events and types that the target can use.
|
|
@@ -82,7 +112,7 @@ Each flag has an equivalent option for `conform()` in code. Give one or more sur
|
|
|
82
112
|
[`acid-cat conform`](../../spec/conformance.md#acid-cat-conform) lists every check. In short:
|
|
83
113
|
|
|
84
114
|
- MCP through HTTP and stdio: The official MCP client tests the tools and outcomes with revision `2026-07-28`, and with the `initialize` handshake of `2025-11-25` through stdio, or through HTTP with `--mcp-handshake`. Raw requests test rejections. Through stdio, raw lines also test version negotiation, lines that are not JSON, a clean standard output and the end of standard input.
|
|
85
|
-
- HTTP and CLI: Each outcome, each kind of call failure, availability and rejections. For the CLI: each kind of flag, usage lines, help, shared prefixes, aliases, interrupts with exit code 130, and `watch --cursor`.
|
|
115
|
+
- HTTP and CLI: Each outcome, each kind of call failure, availability and rejections. For the CLI: each kind of flag, usage lines, help, shared prefixes, aliases and their positional arguments, [document outputs](../../spec/surfaces/cli.md#documents) written byte for byte, the value `-` that reads [standard input](../../spec/surfaces/cli.md#standard-input), interrupts with exit code 130, and `watch --cursor`.
|
|
86
116
|
- WebMCP: The checks act as the host: they open the page in Chromium through [Playwright](https://playwright.dev) with a test `modelContext`. Install it first: `pnpm add -D playwright`, then `pnpm exec playwright install chromium`.
|
|
87
117
|
- Events: Through HTTP, MCP and the CLI: the list of events, failures before the first occurrence, each occurrence against `schemas/occurrence.schema.json` and its payload schema, order, `truncated`, the cursor, each end, and cancellation. Through WebMCP, no event is a tool.
|
|
88
118
|
- [Poll delivery](../../spec/surfaces/mcp.md#poll): Through MCP, when `events/list` gives `poll`. Otherwise the check gives a warning and `events/poll` must answer `Unsupported`. `--poll-buffer` adds a cursor older than the buffer. The lease time of `--mcp` and `--mcp-stdio` must be longer than the deadline, because a check uses a lease for its whole time. `--poll-lease-mcp` with `--poll-lease-ms` adds the end of an unused lease. Serve it from a second MCP server with a lease time shorter than the deadline, for example 1000.
|
|
@@ -60,6 +60,19 @@
|
|
|
60
60
|
"loud": true
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
+
"page": {
|
|
64
|
+
"arguments": [
|
|
65
|
+
"text"
|
|
66
|
+
],
|
|
67
|
+
"capability": "fixture.document"
|
|
68
|
+
},
|
|
69
|
+
"pick": {
|
|
70
|
+
"arguments": [
|
|
71
|
+
"mode",
|
|
72
|
+
"label"
|
|
73
|
+
],
|
|
74
|
+
"capability": "fixture.flags"
|
|
75
|
+
},
|
|
63
76
|
"quick": {
|
|
64
77
|
"capability": "fixture.flags",
|
|
65
78
|
"input": {
|
|
@@ -69,6 +82,15 @@
|
|
|
69
82
|
"raw": {
|
|
70
83
|
"capability": "fixture.raw"
|
|
71
84
|
},
|
|
85
|
+
"read": {
|
|
86
|
+
"arguments": [
|
|
87
|
+
"text"
|
|
88
|
+
],
|
|
89
|
+
"capability": "fixture.read"
|
|
90
|
+
},
|
|
91
|
+
"release": {
|
|
92
|
+
"capability": "fixture.release"
|
|
93
|
+
},
|
|
72
94
|
"say": {
|
|
73
95
|
"capability": "fixture.echo"
|
|
74
96
|
},
|
|
@@ -78,11 +100,26 @@
|
|
|
78
100
|
"text": "HELLO"
|
|
79
101
|
}
|
|
80
102
|
},
|
|
103
|
+
"steps": {
|
|
104
|
+
"arguments": [
|
|
105
|
+
"steps"
|
|
106
|
+
],
|
|
107
|
+
"capability": "fixture.flags",
|
|
108
|
+
"input": {
|
|
109
|
+
"mode": "fast"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
81
112
|
"ticks": {
|
|
82
113
|
"event": "fixture.ticks",
|
|
83
114
|
"input": {
|
|
84
115
|
"count": 2
|
|
85
116
|
}
|
|
117
|
+
},
|
|
118
|
+
"ticks-to": {
|
|
119
|
+
"arguments": [
|
|
120
|
+
"count"
|
|
121
|
+
],
|
|
122
|
+
"event": "fixture.ticks"
|
|
86
123
|
}
|
|
87
124
|
},
|
|
88
125
|
"default": "quick"
|
|
@@ -121,6 +158,28 @@
|
|
|
121
158
|
"api"
|
|
122
159
|
]
|
|
123
160
|
},
|
|
161
|
+
"fixture.document": {
|
|
162
|
+
"description": "Return the input text as a plain-text document.",
|
|
163
|
+
"audience": [
|
|
164
|
+
"cli"
|
|
165
|
+
],
|
|
166
|
+
"input": {
|
|
167
|
+
"properties": {
|
|
168
|
+
"text": {
|
|
169
|
+
"type": "string"
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"required": [
|
|
173
|
+
"text"
|
|
174
|
+
],
|
|
175
|
+
"type": "object"
|
|
176
|
+
},
|
|
177
|
+
"output": {
|
|
178
|
+
"contentMediaType": "text/plain",
|
|
179
|
+
"type": "string"
|
|
180
|
+
},
|
|
181
|
+
"readOnly": true
|
|
182
|
+
},
|
|
124
183
|
"fixture.echo": {
|
|
125
184
|
"description": "Return the input text.",
|
|
126
185
|
"audience": [
|
|
@@ -332,6 +391,43 @@
|
|
|
332
391
|
"type": "object"
|
|
333
392
|
}
|
|
334
393
|
},
|
|
394
|
+
"fixture.read": {
|
|
395
|
+
"description": "Return the input. The text is a plain-text document.",
|
|
396
|
+
"audience": [
|
|
397
|
+
"cli"
|
|
398
|
+
],
|
|
399
|
+
"input": {
|
|
400
|
+
"properties": {
|
|
401
|
+
"data": {
|
|
402
|
+
"type": "object"
|
|
403
|
+
},
|
|
404
|
+
"text": {
|
|
405
|
+
"contentMediaType": "text/plain",
|
|
406
|
+
"type": "string"
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
"required": [
|
|
410
|
+
"text"
|
|
411
|
+
],
|
|
412
|
+
"type": "object"
|
|
413
|
+
},
|
|
414
|
+
"output": {
|
|
415
|
+
"properties": {
|
|
416
|
+
"data": {
|
|
417
|
+
"type": "object"
|
|
418
|
+
},
|
|
419
|
+
"text": {
|
|
420
|
+
"contentMediaType": "text/plain",
|
|
421
|
+
"type": "string"
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
"required": [
|
|
425
|
+
"text"
|
|
426
|
+
],
|
|
427
|
+
"type": "object"
|
|
428
|
+
},
|
|
429
|
+
"readOnly": true
|
|
430
|
+
},
|
|
335
431
|
"fixture.refuse": {
|
|
336
432
|
"description": "Always return the failure Refused.",
|
|
337
433
|
"audience": [
|