@acid-cat/cli 0.17.0 → 0.18.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 +23 -23
- package/conformance/fixture.acidcat.json +4 -4
- package/dist/catalog.d.ts +2 -2
- package/dist/catalog.js +4 -4
- package/dist/conform/check.d.ts +4 -4
- package/dist/conform/check.js +10 -10
- package/dist/conform/cli.js +5 -5
- package/dist/conform/http.js +5 -5
- package/dist/conform/index.d.ts +4 -4
- package/dist/conform/index.js +1 -1
- package/dist/conform/mcp-stdio.js +1 -1
- package/dist/conform/mcp.js +9 -9
- package/dist/conform/poll.js +1 -1
- package/dist/conform/properties.d.ts +1 -1
- package/dist/conform/properties.js +2 -2
- package/dist/conform/server-card.js +1 -1
- package/dist/conform/webhook.js +1 -1
- package/dist/conform/webmcp.js +5 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/json/catalog.schema.json.js +5 -5
- package/dist/json/fixture.acidcat.json.js +4 -4
- package/dist/json/package.json.js +1 -1
- package/dist/main.js +10 -10
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -5,7 +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
|
|
8
|
+
acid-cat target <catalog.json> <target> # write the catalog of one target
|
|
9
9
|
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
10
|
[--poll-buffer <n>] [--poll-lease-mcp <url> --poll-lease-ms <ms>] [--webhook-principal <name> --webhook-cert <file> --webhook-key <file>]
|
|
11
11
|
[--webhook-other-principal <name>] [--webhook-min-ttl-ms <ms>] [--webhook-max-ttl-ms <ms>] [--webhook-max-subscriptions <n>]
|
|
@@ -28,9 +28,9 @@ It needs Node.js 24 or later. `acid-cat conform --webmcp <url>` also needs [Play
|
|
|
28
28
|
`check` and `conform` take `--output human` (the default) or `--output json`. Human output is text for a person. JSON output is one JSON document on standard output, for a script or an agent, and nothing on standard error. The exit code is the same in both modes.
|
|
29
29
|
|
|
30
30
|
- `check`: `{ "conforms": boolean, "catalogs": [{ "file", "errors": [string], "warnings": [string] }] }`. `conforms` is `false` when the exit code is 1. A file that cannot be read, or that is not JSON, is a catalog with one error.
|
|
31
|
-
- `conform`: `{ "passed": number, "failed": number, "warnings": number, "checks": [{ "
|
|
31
|
+
- `conform`: `{ "passed": number, "failed": number, "warnings": number, "checks": [{ "surface", "name", "rule", "passed", "warning"?, "detail"? }] }`. A check with a warning has `"passed": true` and `"warning": true`, and counts in both `passed` and `warnings`.
|
|
32
32
|
|
|
33
|
-
You get the JSON document only when the options are correct. With incorrect options, the exit code is 1, and standard output can hold the help text. `conform` writes one line of text to standard error, and nothing to standard output, when it gets no
|
|
33
|
+
You get the JSON document only when the options are correct. With incorrect options, the exit code is 1, and standard output can hold the help text. `conform` writes one line of text to standard error, and nothing to standard output, when it gets no surface, only some of the `--webhook-*` options, or a certificate file that it cannot read.
|
|
34
34
|
|
|
35
35
|
## check
|
|
36
36
|
|
|
@@ -39,7 +39,7 @@ You get the JSON document only when the options are correct. With incorrect opti
|
|
|
39
39
|
- 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
40
|
- 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
41
|
|
|
42
|
-
It also checks each alias in `options.cli` against the [alias rules](../../spec/
|
|
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
43
|
|
|
44
44
|
The exit code is 1 with errors, and 0 otherwise. With `--strict`, warnings also give exit code 1.
|
|
45
45
|
|
|
@@ -47,28 +47,28 @@ The exit code is 1 with errors, and 0 otherwise. With `--strict`, warnings also
|
|
|
47
47
|
|
|
48
48
|
`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
49
|
|
|
50
|
-
##
|
|
50
|
+
## target
|
|
51
51
|
|
|
52
|
-
`
|
|
52
|
+
`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.
|
|
53
53
|
|
|
54
54
|
## conform
|
|
55
55
|
|
|
56
|
-
`conform` tests a running implementation of the [conformance fixture](conformance/fixture.pkl) through its
|
|
56
|
+
`conform` tests a running implementation of the [conformance fixture](conformance/fixture.pkl) through its surfaces. Each AcidCat core runs it in its tests.
|
|
57
57
|
|
|
58
58
|
### Options
|
|
59
59
|
|
|
60
|
-
Each flag has an equivalent option for `conform()` in code. Give one or more
|
|
60
|
+
Each flag has an equivalent option for `conform()` in code. Give one or more surfaces.
|
|
61
61
|
|
|
62
62
|
| Flag | In code | What it does |
|
|
63
63
|
| --- | --- | --- |
|
|
64
|
-
| `--mcp <url>` | `mcp` | Test the MCP
|
|
65
|
-
| `--mcp-handshake` | `mcpHandshake: true` | Also test the [`initialize` handshake of earlier revisions](../../spec/
|
|
66
|
-
| `--mcp-stdio "<command>"` | `mcpStdio` | Test the MCP
|
|
67
|
-
| `--http <url>` | `http` | Test the HTTP
|
|
68
|
-
| `--cli "<command>"` | `cli` | Test the CLI
|
|
69
|
-
| `--webmcp <url>` | `webmcp` | Test the WebMCP
|
|
64
|
+
| `--mcp <url>` | `mcp` | Test the MCP surface through HTTP |
|
|
65
|
+
| `--mcp-handshake` | `mcpHandshake: true` | Also test the [`initialize` handshake of earlier revisions](../../spec/surfaces/mcp.md#earlier-revisions-through-http) through HTTP |
|
|
66
|
+
| `--mcp-stdio "<command>"` | `mcpStdio` | Test the MCP surface through stdio. Each check starts the server as a process |
|
|
67
|
+
| `--http <url>` | `http` | Test the HTTP surface. The URL is the base URL, before `/capabilities` |
|
|
68
|
+
| `--cli "<command>"` | `cli` | Test the CLI surface |
|
|
69
|
+
| `--webmcp <url>` | `webmcp` | Test the WebMCP surface on a page that serves the `app` target. In code, `webmcp` can also be a function that installs the implementation on a host in the same process |
|
|
70
70
|
| `--deadline <ms>` | `deadline` | The deadline of each check. The default is 30 000 |
|
|
71
|
-
| `--max-bytes <n>` | `maximumBytes` | The body limit of the remote
|
|
71
|
+
| `--max-bytes <n>` | `maximumBytes` | The body limit of the remote surfaces, in bytes. The default is 1 048 576 |
|
|
72
72
|
| `--poll-buffer <n>` | `poll.bufferLimit` | The deployment's poll buffer size, from 1 to 97 |
|
|
73
73
|
| `--poll-lease-mcp <url>`, `--poll-lease-ms <ms>` | `pollLease: { mcp, leaseMs }` | An MCP server through HTTP with a poll lease time shorter than the deadline, and that lease time. Give both together |
|
|
74
74
|
| `--webhook-principal <name>`, `--webhook-cert <file>`, `--webhook-key <file>` | `webhook: { principal, cert, key }`, with the PEM text | Test webhook delivery. Give all three together |
|
|
@@ -85,12 +85,12 @@ Each flag has an equivalent option for `conform()` in code. Give one or more bin
|
|
|
85
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`.
|
|
86
86
|
- 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
87
|
- 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
|
-
- [Poll delivery](../../spec/
|
|
89
|
-
- [Webhook delivery](../../spec/
|
|
90
|
-
- [Server Card](../../spec/
|
|
91
|
-
- [Hints](../../spec/
|
|
92
|
-
- [Heartbeat](../../spec/
|
|
93
|
-
- [Headers](../../spec/
|
|
88
|
+
- [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.
|
|
89
|
+
- [Webhook delivery](../../spec/surfaces/mcp.md#webhook): Through MCP over HTTP, with the three `--webhook-*` options. The checks run an HTTPS receiver on `127.0.0.1` with that certificate. Configure the deployment to trust the certificate, allow deliveries to private addresses, and give the principal `<name>` to a request with `Authorization: Bearer <name>`. The deadline must be longer than the deployment's first retry wait, and the maximum lifetime must be longer than the deadline. Give `--webhook-other-principal` with `--webhook-max-subscriptions`: the limit check then fills a principal that no other check uses. Without the webhook options, a server that does not list `webhook` must answer `Unsupported`.
|
|
90
|
+
- [Server Card](../../spec/surfaces/mcp.md#server-card): Through MCP over HTTP, when `<mcp>/server-card` gives 200. The card must pass the JSON Schema of the Server Card extension, have one remote with the URL of `--mcp`, the version of `server/discover` and the revisions that the server serves, the CORS and cache headers, 304 for its `ETag`, 204 for `OPTIONS`, public signing keys only, and egress ranges in CIDR text. With the webhook options and signing keys in the card, each webhook request must have one `v1a,` signature for each key, and each must verify. The JSON Schema is `conformance/server-card.schema.json`, from commit `28db12c` of [ext-server-card](https://github.com/modelcontextprotocol/ext-server-card), under the Apache License 2.0 in `conformance/server-card.LICENSE`.
|
|
91
|
+
- [Hints](../../spec/surfaces/mcp.md#tools): Each MCP tool's annotations match its capability's hints.
|
|
92
|
+
- [Heartbeat](../../spec/surfaces/mcp.md#push): Through MCP with each transport, each `notifications/events/active` grants a `heartbeatMs`. A suggestion is clamped between 1000 and 60 000, a heartbeat comes after the grant, and a suggestion that is not valid gets `-32602`.
|
|
93
|
+
- [Headers](../../spec/surfaces/mcp.md#headers): Through MCP over HTTP, a missing or wrong `Mcp-Method`, `Mcp-Name` or `Mcp-Param-*` header on `tools/call` and `events/stream` gets 400 and `-32020`, and a value in the base64 form is decoded, with a leading U+FEFF kept. Every request of conform mirrors the annotated arguments of the fixture (`fixture.switch.set` and `fixture.ticks`) into their headers.
|
|
94
94
|
- Properties: With fast-check, through MCP and HTTP: concurrent calls each get their own outcome, and a cancellation changes only its own call.
|
|
95
95
|
|
|
96
96
|
Each poll check uses a new key, so leases from an earlier run do not change the result.
|
|
@@ -105,7 +105,7 @@ A failed check of a SHOULD rule gives a warning, marked `!`, and passes. The exi
|
|
|
105
105
|
|
|
106
106
|
### Use it in code
|
|
107
107
|
|
|
108
|
-
`conform()` and `serve()` come from `@acid-cat/cli
|
|
108
|
+
`conform()` and `serve()` come from `@acid-cat/cli`. This `serve()` is for tests only: it listens on `127.0.0.1`, on a free port, with plain HTTP. To serve an application, use its core's server: `serve` from `@acid-cat/core-ts/node`, `NodeServer` from `@acid-cat/core-effect`, or `remote::serve` from the crate `acid-cat-core`.
|
|
109
109
|
|
|
110
110
|
## Implementation
|
|
111
111
|
|
|
@@ -113,7 +113,7 @@ The command line is an [Effect](https://effect.website) program built on `effect
|
|
|
113
113
|
|
|
114
114
|
| File | Contents |
|
|
115
115
|
| --- | --- |
|
|
116
|
-
| `src/catalog.ts` | The catalog rules,
|
|
116
|
+
| `src/catalog.ts` | The catalog rules, the catalog of a target, and bundling |
|
|
117
117
|
| `src/main.ts` | The commands |
|
|
118
118
|
| `src/conform/` | The conformance checks, and `serve`, which serves web handlers on a local port for the tests |
|
|
119
119
|
| `conformance/` | The conformance fixture, in Pkl and in JSON |
|
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
"description": "One capability or event for each behavior that acid-cat conform tests.",
|
|
5
5
|
"targets": {
|
|
6
6
|
"api": {
|
|
7
|
-
"
|
|
7
|
+
"surfaces": [
|
|
8
8
|
"http"
|
|
9
9
|
]
|
|
10
10
|
},
|
|
11
11
|
"app": {
|
|
12
|
-
"
|
|
12
|
+
"surfaces": [
|
|
13
13
|
"typescript",
|
|
14
14
|
"webmcp"
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"cli": {
|
|
18
|
-
"
|
|
18
|
+
"surfaces": [
|
|
19
19
|
"cli"
|
|
20
20
|
],
|
|
21
21
|
"options": {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
92
|
"mcp": {
|
|
93
|
-
"
|
|
93
|
+
"surfaces": [
|
|
94
94
|
"mcp"
|
|
95
95
|
]
|
|
96
96
|
}
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { bundle,
|
|
1
|
+
import { bundle, targetCatalog } from "@acid-cat/spec-ts";
|
|
2
2
|
import type { CatalogDocument as Catalog } from "@acid-cat/spec-ts";
|
|
3
|
-
export { bundle,
|
|
3
|
+
export { bundle, targetCatalog };
|
|
4
4
|
export type { Catalog };
|
|
5
5
|
/** The result of a check. An error breaks a rule. A warning breaks a recommendation. */
|
|
6
6
|
export interface Report {
|
package/dist/catalog.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import catalog_schema_default from "./json/catalog.schema.json.js";
|
|
2
2
|
import { isObject, isRecordOf, isStringArray } from "./json.js";
|
|
3
3
|
import { canonicalText } from "@acid-cat/catalog";
|
|
4
|
-
import { REFERENCE, bundle, cliAliases, eventSchemasOf, mcpHeaderErrors, resolveType, schemasOf,
|
|
4
|
+
import { REFERENCE, bundle, cliAliases, eventSchemasOf, mcpHeaderErrors, resolveType, schemasOf, targetCatalog, visitObjects } from "@acid-cat/spec-ts";
|
|
5
5
|
import { Result, Schema, SchemaIssue, SchemaRepresentation } from "effect";
|
|
6
6
|
// src/catalog.ts
|
|
7
7
|
const KNOWN_MEMBERS = {
|
|
@@ -15,7 +15,7 @@ const KNOWN_MEMBERS = {
|
|
|
15
15
|
"events"
|
|
16
16
|
],
|
|
17
17
|
target: [
|
|
18
|
-
"
|
|
18
|
+
"surfaces",
|
|
19
19
|
"description",
|
|
20
20
|
"options"
|
|
21
21
|
],
|
|
@@ -41,7 +41,7 @@ const KNOWN_MEMBERS = {
|
|
|
41
41
|
const optional = (object, key, isMember) => !Object.hasOwn(object, key) || isMember(object[key]);
|
|
42
42
|
const isString = (value) => typeof value === "string";
|
|
43
43
|
const isBoolean = (value) => typeof value === "boolean";
|
|
44
|
-
const isTarget = (value) => isObject(value) && isStringArray(value.
|
|
44
|
+
const isTarget = (value) => isObject(value) && isStringArray(value.surfaces);
|
|
45
45
|
const isCapability = (value) => isObject(value) && typeof value.description === "string" && optional(value, "audience", isStringArray) && optional(value, "input", isObject) && optional(value, "output", isObject) && optional(value, "state", isObject) && optional(value, "failures", (failures) => isRecordOf(failures, isObject)) && optional(value, "readOnly", isBoolean) && optional(value, "destructive", isBoolean) && optional(value, "idempotent", isBoolean);
|
|
46
46
|
const isEvent = (value) => isObject(value) && typeof value.description === "string" && optional(value, "audience", isStringArray) && optional(value, "input", isObject) && optional(value, "payload", isObject);
|
|
47
47
|
const isCatalog = (value) => isObject(value) && typeof value.acidcat === "string" && optional(value, "title", isString) && optional(value, "description", isString) && isRecordOf(value.targets, isTarget) && optional(value, "$defs", (types) => isRecordOf(types, isObject)) && isRecordOf(value.capabilities, isCapability) && optional(value, "events", (events) => isRecordOf(events, isEvent));
|
|
@@ -146,4 +146,4 @@ function referenceErrors(schema, types) {
|
|
|
146
146
|
});
|
|
147
147
|
return errors;
|
|
148
148
|
}
|
|
149
|
-
export { bundle, check, isCatalog,
|
|
149
|
+
export { bundle, check, isCatalog, targetCatalog };
|
package/dist/conform/check.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CatalogDocument, Occurrence, Outcome } from "@acid-cat/spec-ts";
|
|
2
2
|
export interface Check {
|
|
3
|
-
readonly
|
|
3
|
+
readonly surface: string;
|
|
4
4
|
readonly name: string;
|
|
5
|
-
/** The part of the specification that the check tests, for example `spec/
|
|
5
|
+
/** The part of the specification that the check tests, for example `spec/surfaces/mcp.md#tools`. */
|
|
6
6
|
readonly rule: string;
|
|
7
7
|
readonly passed: boolean;
|
|
8
8
|
/** `true` when the check tests a recommendation (SHOULD) that the implementation does not follow. The check still passes. */
|
|
@@ -21,9 +21,9 @@ export type Define = (name: string, rule: string, body: Body) => void;
|
|
|
21
21
|
export declare class Checks {
|
|
22
22
|
#private;
|
|
23
23
|
readonly results: Check[];
|
|
24
|
-
readonly
|
|
24
|
+
readonly surface: string;
|
|
25
25
|
readonly deadline: number;
|
|
26
|
-
constructor(
|
|
26
|
+
constructor(surface: string, deadline: number);
|
|
27
27
|
run(name: string, rule: string, body: Body): Promise<void>;
|
|
28
28
|
concurrently(define: (check: Define) => void): Promise<void>;
|
|
29
29
|
should(name: string, rule: string, body: Body): Promise<void>;
|
package/dist/conform/check.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fixture_acidcat_default from "../json/fixture.acidcat.json.js";
|
|
2
2
|
import { isObject } from "../json.js";
|
|
3
|
-
import { CALL_FAILURE_KINDS, isOccurrence,
|
|
3
|
+
import { CALL_FAILURE_KINDS, isOccurrence, targetCatalog } from "@acid-cat/spec-ts";
|
|
4
4
|
import { Schema, SchemaRepresentation } from "effect";
|
|
5
5
|
import { availableParallelism } from "node:os";
|
|
6
6
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
@@ -13,8 +13,8 @@ const isOutcome = (value) => {
|
|
|
13
13
|
if (value.ok === false) return "error" in value;
|
|
14
14
|
return !("ok" in value) && CALL_FAILURE_KINDS.some((kind) => kind === value.kind) && typeof value.message === "string";
|
|
15
15
|
};
|
|
16
|
-
const idsOf = (target) => Object.keys(
|
|
17
|
-
const eventIdsOf = (target) => Object.keys(
|
|
16
|
+
const idsOf = (target) => Object.keys(targetCatalog(fixture, target).capabilities).sort();
|
|
17
|
+
const eventIdsOf = (target) => Object.keys(targetCatalog(fixture, target).events ?? {}).sort();
|
|
18
18
|
const payloadChecks = /* @__PURE__ */ new Map();
|
|
19
19
|
function agreesWithPayload(id, data) {
|
|
20
20
|
let agrees = payloadChecks.get(id);
|
|
@@ -43,10 +43,10 @@ function expectOccurrence(value, id) {
|
|
|
43
43
|
const DEADLINE = 3e4;
|
|
44
44
|
var Checks = class {
|
|
45
45
|
results = [];
|
|
46
|
-
|
|
46
|
+
surface;
|
|
47
47
|
deadline;
|
|
48
|
-
constructor(
|
|
49
|
-
this.
|
|
48
|
+
constructor(surface, deadline) {
|
|
49
|
+
this.surface = surface;
|
|
50
50
|
this.deadline = deadline;
|
|
51
51
|
}
|
|
52
52
|
async run(name, rule, body) {
|
|
@@ -69,12 +69,12 @@ var Checks = class {
|
|
|
69
69
|
}
|
|
70
70
|
#result(name, rule, failure) {
|
|
71
71
|
return failure === void 0 ? {
|
|
72
|
-
|
|
72
|
+
surface: this.surface,
|
|
73
73
|
name,
|
|
74
74
|
rule,
|
|
75
75
|
passed: true
|
|
76
76
|
} : {
|
|
77
|
-
|
|
77
|
+
surface: this.surface,
|
|
78
78
|
name,
|
|
79
79
|
rule,
|
|
80
80
|
passed: false,
|
|
@@ -84,12 +84,12 @@ var Checks = class {
|
|
|
84
84
|
async should(name, rule, body) {
|
|
85
85
|
const failure = await this.#settle(body);
|
|
86
86
|
this.results.push(failure === void 0 ? {
|
|
87
|
-
|
|
87
|
+
surface: this.surface,
|
|
88
88
|
name,
|
|
89
89
|
rule,
|
|
90
90
|
passed: true
|
|
91
91
|
} : {
|
|
92
|
-
|
|
92
|
+
surface: this.surface,
|
|
93
93
|
name,
|
|
94
94
|
rule,
|
|
95
95
|
passed: true,
|
package/dist/conform/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ import { mkdtemp, rm } from "node:fs/promises";
|
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { isDeepStrictEqual } from "node:util";
|
|
9
9
|
// src/conform/cli.ts
|
|
10
|
-
const RULE = "spec/
|
|
10
|
+
const RULE = "spec/surfaces/cli.md";
|
|
11
11
|
const USAGES = {
|
|
12
12
|
"fixture.crash": "fixture crash",
|
|
13
13
|
"fixture.echo": "fixture echo --text <string>",
|
|
@@ -148,12 +148,12 @@ async function checkCli(command, options) {
|
|
|
148
148
|
2
|
|
149
149
|
],
|
|
150
150
|
[
|
|
151
|
-
"a capability outside the
|
|
151
|
+
"a capability outside the target has exit code 2",
|
|
152
152
|
["call", "fixture.hidden"],
|
|
153
153
|
2
|
|
154
154
|
],
|
|
155
155
|
[
|
|
156
|
-
"a capability outside the
|
|
156
|
+
"a capability outside the target with input that is not JSON has exit code 2",
|
|
157
157
|
[
|
|
158
158
|
"call",
|
|
159
159
|
"fixture.hidden",
|
|
@@ -317,7 +317,7 @@ async function checkCli(command, options) {
|
|
|
317
317
|
expectEqual(result.code, 0, "exit code");
|
|
318
318
|
expectEqual(parseJson(result.stdout), { text: "hello" }, "standard output");
|
|
319
319
|
});
|
|
320
|
-
check("list gives the
|
|
320
|
+
check("list gives the capabilities of the target, then its events", `${RULE}#commands`, async (signal) => {
|
|
321
321
|
const entries = await listed(signal);
|
|
322
322
|
const ids = (kind) => entries.filter((entry) => entry.kind === kind).map((entry) => entry.id);
|
|
323
323
|
expectEqual(sorted(ids("capability")), idsOf("cli"), "the ids of the items with kind: capability");
|
|
@@ -655,7 +655,7 @@ function checkWatch(check, command) {
|
|
|
655
655
|
3
|
|
656
656
|
],
|
|
657
657
|
[
|
|
658
|
-
"watch of an event outside the
|
|
658
|
+
"watch of an event outside the target has exit code 2",
|
|
659
659
|
["watch", "fixture.secret"],
|
|
660
660
|
2
|
|
661
661
|
],
|
package/dist/conform/http.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Checks, FORBIDDEN_ORIGIN, eventIdsOf, expect, expectEqual, expectOccurr
|
|
|
3
3
|
import { sseReader } from "./sse.js";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
// src/conform/http.ts
|
|
6
|
-
const RULE = "spec/
|
|
6
|
+
const RULE = "spec/surfaces/http.md";
|
|
7
7
|
const isEntry = (value) => isObject(value) && typeof value.id === "string";
|
|
8
8
|
async function entriesOf(response) {
|
|
9
9
|
const list = await readJson(response);
|
|
@@ -22,7 +22,7 @@ async function checkHttp(base, options) {
|
|
|
22
22
|
signal
|
|
23
23
|
});
|
|
24
24
|
const kindOf = async (response) => memberOf(await readJson(response), "kind");
|
|
25
|
-
await checks.run("GET /capabilities lists the
|
|
25
|
+
await checks.run("GET /capabilities lists the capabilities of the target with their availability", `${RULE}#requests`, async (signal) => {
|
|
26
26
|
const list = await entriesOf(await fetch(`${base}/capabilities`, { signal }));
|
|
27
27
|
expectEqual(sorted(list.map((entry) => entry.id)), idsOf("api"), "ids");
|
|
28
28
|
expect(list.every((entry) => typeof entry.available === "boolean"), "each entry must have available");
|
|
@@ -50,7 +50,7 @@ async function checkHttp(base, options) {
|
|
|
50
50
|
"invalid-input"
|
|
51
51
|
],
|
|
52
52
|
[
|
|
53
|
-
"a capability outside the
|
|
53
|
+
"a capability outside the target has the status 404",
|
|
54
54
|
"fixture.hidden",
|
|
55
55
|
{},
|
|
56
56
|
404,
|
|
@@ -171,14 +171,14 @@ async function checkEvents(checks, base) {
|
|
|
171
171
|
expect(typeof delivered === "number", `fixture.signal must give the number of subscriptions, got ${JSON.stringify(delivered)}`);
|
|
172
172
|
return delivered;
|
|
173
173
|
};
|
|
174
|
-
await checks.run("GET /events lists the events of the
|
|
174
|
+
await checks.run("GET /events lists the events of the target", `${RULE}#requests`, async (signal) => {
|
|
175
175
|
const list = await readJson(await fetch(`${base}/events`, { signal }));
|
|
176
176
|
if (!isArrayOf(list, isEntry)) throw new Error(`GET /events must give a list of objects with an id, got ${JSON.stringify(list)}`);
|
|
177
177
|
expectEqual(sorted(list.map((entry) => entry.id)), eventIdsOf("api"), "ids");
|
|
178
178
|
});
|
|
179
179
|
for (const [name, id, input, status, kind] of [
|
|
180
180
|
[
|
|
181
|
-
"a subscription to an event outside the
|
|
181
|
+
"a subscription to an event outside the target has the status 404",
|
|
182
182
|
"fixture.secret",
|
|
183
183
|
{},
|
|
184
184
|
404,
|
package/dist/conform/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface ConformOptions {
|
|
|
15
15
|
readonly mcp?: string | undefined;
|
|
16
16
|
/**
|
|
17
17
|
* Check the `initialize` handshake of revision 2025-11-25 through the MCP server too
|
|
18
|
-
* (spec/
|
|
18
|
+
* (spec/surfaces/mcp.md#earlier-revisions-through-http). The default is `false`.
|
|
19
19
|
*/
|
|
20
20
|
readonly mcpHandshake?: boolean | undefined;
|
|
21
21
|
/**
|
|
@@ -28,7 +28,7 @@ export interface ConformOptions {
|
|
|
28
28
|
/** The command that starts the command line, for example `["node", "fixture-cli.ts"]`. */
|
|
29
29
|
readonly cli?: readonly string[] | undefined;
|
|
30
30
|
/**
|
|
31
|
-
* The WebMCP
|
|
31
|
+
* The WebMCP surface: the URL of a page that serves the `app` target, or a function that installs the implementation
|
|
32
32
|
* on a host in the same process. A page runs in Chromium, through Playwright.
|
|
33
33
|
*/
|
|
34
34
|
readonly webmcp?: string | WebMcpInstall | undefined;
|
|
@@ -51,7 +51,7 @@ export interface ConformOptions {
|
|
|
51
51
|
* header `Authorization: Bearer <principal>`.
|
|
52
52
|
*/
|
|
53
53
|
readonly webhook?: WebhookSettings | undefined;
|
|
54
|
-
/** The body limit of the remote
|
|
54
|
+
/** The body limit of the remote surfaces, in bytes. The default is 1 MiB. */
|
|
55
55
|
readonly maximumBytes?: number | undefined;
|
|
56
56
|
/**
|
|
57
57
|
* The time, in milliseconds, that each check has to settle. A check that does not settle in this time fails. The
|
|
@@ -59,5 +59,5 @@ export interface ConformOptions {
|
|
|
59
59
|
*/
|
|
60
60
|
readonly deadline?: number | undefined;
|
|
61
61
|
}
|
|
62
|
-
/** Run all checks for the
|
|
62
|
+
/** Run all checks for the surfaces that the options give. */
|
|
63
63
|
export declare function conform(options: ConformOptions): Promise<readonly Check[]>;
|
package/dist/conform/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { browserDriver, checkWebMcp, processDriver } from "./webmcp.js";
|
|
|
8
8
|
import { checkPollLease } from "./poll.js";
|
|
9
9
|
import { serve } from "./serve.js";
|
|
10
10
|
// src/conform/index.ts
|
|
11
|
-
/** Run all checks for the
|
|
11
|
+
/** Run all checks for the surfaces that the options give. */
|
|
12
12
|
async function conform(options) {
|
|
13
13
|
const maximumBytes = options.maximumBytes ?? 1048576;
|
|
14
14
|
const deadline = options.deadline ?? 3e4;
|
|
@@ -7,7 +7,7 @@ import { randomUUID } from "node:crypto";
|
|
|
7
7
|
import { Client } from "@modelcontextprotocol/client";
|
|
8
8
|
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
|
9
9
|
// src/conform/mcp-stdio.ts
|
|
10
|
-
const RULE = "spec/
|
|
10
|
+
const RULE = "spec/surfaces/mcp.md#stdio";
|
|
11
11
|
const ERAS = [{
|
|
12
12
|
revision: "2026-07-28",
|
|
13
13
|
connects: "an MCP client connects with revision 2026-07-28",
|
package/dist/conform/mcp.js
CHANGED
|
@@ -4,11 +4,11 @@ import { checkPoll } from "./poll.js";
|
|
|
4
4
|
import { sseReader } from "./sse.js";
|
|
5
5
|
import { checkServerCard, signingKeysOf } from "./server-card.js";
|
|
6
6
|
import { checkWebhook } from "./webhook.js";
|
|
7
|
-
import { MCP_EVENTS_EXTENSION, MCP_HEADER_MISMATCH, MCP_HEARTBEAT_MAX_MS, MCP_HEARTBEAT_MIN_MS, MCP_PROTOCOL_VERSION_KEY, MCP_SUBSCRIPTION_ID, bundle, encodeMcpHeaderValue, mcpParamHeaders,
|
|
7
|
+
import { MCP_EVENTS_EXTENSION, MCP_HEADER_MISMATCH, MCP_HEARTBEAT_MAX_MS, MCP_HEARTBEAT_MIN_MS, MCP_PROTOCOL_VERSION_KEY, MCP_SUBSCRIPTION_ID, bundle, encodeMcpHeaderValue, mcpParamHeaders, targetCatalog } from "@acid-cat/spec-ts";
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
|
9
9
|
import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
|
|
10
10
|
// src/conform/mcp.ts
|
|
11
|
-
const RULE = "spec/
|
|
11
|
+
const RULE = "spec/surfaces/mcp.md";
|
|
12
12
|
async function mcpClient(url, signal, handshake = false) {
|
|
13
13
|
const client = new Client({
|
|
14
14
|
name: "acid-cat-conform",
|
|
@@ -86,12 +86,12 @@ async function checkMcp(url, options) {
|
|
|
86
86
|
if (options.handshake) await checkHandshake(checks, url, options.deadline);
|
|
87
87
|
return checks;
|
|
88
88
|
}
|
|
89
|
-
const
|
|
89
|
+
const mcpCatalog = targetCatalog(fixture, "mcp");
|
|
90
90
|
function inputSchemaOf(method, name) {
|
|
91
91
|
if (typeof name !== "string") return void 0;
|
|
92
|
-
const entries = method === "tools/call" ?
|
|
92
|
+
const entries = method === "tools/call" ? mcpCatalog.capabilities : method.startsWith("events/") ? mcpCatalog.events ?? {} : {};
|
|
93
93
|
const input = Object.hasOwn(entries, name) ? entries[name]?.input : void 0;
|
|
94
|
-
return input === void 0 ? void 0 : bundle(input,
|
|
94
|
+
return input === void 0 ? void 0 : bundle(input, mcpCatalog.$defs ?? {});
|
|
95
95
|
}
|
|
96
96
|
function mcpRequestHeaders(method, params) {
|
|
97
97
|
return {
|
|
@@ -279,7 +279,7 @@ async function checkTools(checks, mcp) {
|
|
|
279
279
|
await checks.run("the instructions are the description of the catalog", `${RULE}#server`, () => {
|
|
280
280
|
expectEqual(mcp.getInstructions(), fixture.description, "instructions");
|
|
281
281
|
});
|
|
282
|
-
await checks.run("tools/list gives each available capability of the
|
|
282
|
+
await checks.run("tools/list gives each available capability of the target", `${RULE}#tools`, async (signal) => {
|
|
283
283
|
const { tools } = await mcp.listTools(void 0, { signal });
|
|
284
284
|
expectEqual(sorted(tools.map((tool) => tool.name)), idsOf("mcp"), "tools");
|
|
285
285
|
});
|
|
@@ -325,7 +325,7 @@ async function checkTools(checks, mcp) {
|
|
|
325
325
|
const result = await call(signal, "fixture.echo", { text: 1 });
|
|
326
326
|
expectEqual(memberOf(textOf(result), "kind"), "invalid-input", "kind");
|
|
327
327
|
});
|
|
328
|
-
await checks.run("a capability outside the
|
|
328
|
+
await checks.run("a capability outside the target is an unknown tool", `${RULE}#tools`, async (signal) => {
|
|
329
329
|
const error = await call(signal, "fixture.hidden", {}).then(() => void 0, (caught) => caught);
|
|
330
330
|
expect(memberOf(error, "code") === -32602, `expected the JSON-RPC error -32602, got ${JSON.stringify(error)}`);
|
|
331
331
|
});
|
|
@@ -485,7 +485,7 @@ async function checkEvents(checks, channel, options) {
|
|
|
485
485
|
expect(isObject(memberOf(extensions, MCP_EVENTS_EXTENSION)), `the capabilities must have the extension ${MCP_EVENTS_EXTENSION}, got ${JSON.stringify(result)}`);
|
|
486
486
|
});
|
|
487
487
|
let delivery = [];
|
|
488
|
-
await checks.run("events/list gives each event of the
|
|
488
|
+
await checks.run("events/list gives each event of the target, with the delivery modes of the server and its schemas", RULE_EVENTS, async (signal) => {
|
|
489
489
|
const result = await resultOf("events/list", {}, signal);
|
|
490
490
|
const entries = result.events;
|
|
491
491
|
if (!isArrayOf(entries, isObject)) throw new Error(`events/list must give a list of events, got ${JSON.stringify(result)}`);
|
|
@@ -509,7 +509,7 @@ async function checkEvents(checks, channel, options) {
|
|
|
509
509
|
});
|
|
510
510
|
for (const [name, params, code, kind] of [
|
|
511
511
|
[
|
|
512
|
-
"events/stream of an event outside the
|
|
512
|
+
"events/stream of an event outside the target is NotFound, with the kind event",
|
|
513
513
|
{
|
|
514
514
|
name: "fixture.secret",
|
|
515
515
|
arguments: {}
|
package/dist/conform/poll.js
CHANGED
|
@@ -3,7 +3,7 @@ import { expect, expectEqual, expectOccurrence, until } from "./check.js";
|
|
|
3
3
|
import { eventRequests } from "./mcp.js";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
// src/conform/poll.ts
|
|
6
|
-
const RULE = "spec/
|
|
6
|
+
const RULE = "spec/surfaces/mcp.md#poll";
|
|
7
7
|
const MAXIMUM_TICKS = 100;
|
|
8
8
|
const MAXIMUM_EVENTS = 100;
|
|
9
9
|
function pollRequests(channel) {
|
|
@@ -9,4 +9,4 @@ export declare function mcpInvoke(url: string, signal: AbortSignal): Promise<{
|
|
|
9
9
|
close(): Promise<void>;
|
|
10
10
|
}>;
|
|
11
11
|
export declare function clientInvoke(client: Client): Invoke;
|
|
12
|
-
export declare function checkProperties(
|
|
12
|
+
export declare function checkProperties(surface: string, invoke: Invoke, deadline: number): Promise<Checks>;
|
|
@@ -124,8 +124,8 @@ const cancellations = fc.array(fc.boolean(), {
|
|
|
124
124
|
minLength: 2,
|
|
125
125
|
maxLength: 5
|
|
126
126
|
}).filter((flags) => flags.includes(true) && flags.includes(false));
|
|
127
|
-
async function checkProperties(
|
|
128
|
-
const checks = new Checks(`${
|
|
127
|
+
async function checkProperties(surface, invoke, deadline) {
|
|
128
|
+
const checks = new Checks(`${surface} properties`, deadline);
|
|
129
129
|
await checks.run("concurrent calls each get exactly their own outcome", RULE, async (signal) => {
|
|
130
130
|
await fc.assert(fc.asyncProperty(fc.array(operation, {
|
|
131
131
|
minLength: 1,
|
|
@@ -4,7 +4,7 @@ import { expect, expectEqual } from "./check.js";
|
|
|
4
4
|
import { MCP_EVENTS_EXTENSION, MCP_SERVER_CARD_CACHE_CONTROL, MCP_SERVER_CARD_MEDIA_TYPE, MCP_SERVER_CARD_PATH, isCidr } from "@acid-cat/spec-ts";
|
|
5
5
|
import { Result, Schema, SchemaIssue, SchemaRepresentation } from "effect";
|
|
6
6
|
// src/conform/server-card.ts
|
|
7
|
-
const RULE = "spec/
|
|
7
|
+
const RULE = "spec/surfaces/mcp.md#server-card";
|
|
8
8
|
const decodeCard = (() => {
|
|
9
9
|
const definitions = $defs;
|
|
10
10
|
const schema = SchemaRepresentation.fromJsonSchemaDocument({
|
package/dist/conform/webhook.js
CHANGED
|
@@ -5,7 +5,7 @@ import { MCP_WEBHOOK_DEFAULTS, isOccurrence, webhookSignature, webhookSubscripti
|
|
|
5
5
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
6
6
|
import { createServer } from "node:https";
|
|
7
7
|
// src/conform/webhook.ts
|
|
8
|
-
const RULE = "spec/
|
|
8
|
+
const RULE = "spec/surfaces/mcp.md#webhook";
|
|
9
9
|
const REFRESH_BEFORE_PRECISION_MS = 1;
|
|
10
10
|
const isVerification = (request) => memberOf(request.body, "type") === "verification";
|
|
11
11
|
async function startReceiver(settings) {
|
package/dist/conform/webmcp.js
CHANGED
|
@@ -2,7 +2,7 @@ import { isArrayOf, isObject, isStringArray, memberOf, parseJson } from "../json
|
|
|
2
2
|
import { Checks, abortable, expect, expectEqual, fixture, idsOf, sorted, until } from "./check.js";
|
|
3
3
|
import { REFERENCE, visitObjects } from "@acid-cat/spec-ts";
|
|
4
4
|
// src/conform/webmcp.ts
|
|
5
|
-
const RULE = "spec/
|
|
5
|
+
const RULE = "spec/surfaces/webmcp.md";
|
|
6
6
|
const TARGET = "app";
|
|
7
7
|
/** The function uses no imports and no outer variables, because the browser driver sends its source text to the page. */
|
|
8
8
|
function createTestHost() {
|
|
@@ -156,17 +156,17 @@ async function heldKeys(driver, signal) {
|
|
|
156
156
|
}
|
|
157
157
|
async function checkWebMcp(driver, options) {
|
|
158
158
|
const checks = new Checks("webmcp", options.deadline);
|
|
159
|
-
const
|
|
159
|
+
const capabilities = fixture.capabilities;
|
|
160
160
|
const expected = idsOf(TARGET);
|
|
161
|
-
await checks.run("each available capability of the
|
|
161
|
+
await checks.run("each available capability of the target is a tool", `${RULE}#tools`, async (signal) => {
|
|
162
162
|
await until(`the tools are ${expected.join(", ")}`, () => names(driver, signal), (tools) => JSON.stringify(tools) === JSON.stringify(expected), signal);
|
|
163
163
|
});
|
|
164
164
|
await checks.run("a tool has the description and the bundled input schema of its capability", `${RULE}#tools`, async (signal) => {
|
|
165
165
|
for (const tool of await driver.tools(signal)) {
|
|
166
|
-
expectEqual(tool.description,
|
|
166
|
+
expectEqual(tool.description, capabilities[tool.name]?.description, `description of ${tool.name}`);
|
|
167
167
|
const schema = tool.inputSchema;
|
|
168
168
|
expect(isObject(schema), `the input schema of ${tool.name} must be an object`);
|
|
169
|
-
expectSameInputShape(tool.name, schema,
|
|
169
|
+
expectSameInputShape(tool.name, schema, capabilities[tool.name]?.input ?? {});
|
|
170
170
|
expect(isBundled(schema), `the input schema of ${tool.name} must be bundled`);
|
|
171
171
|
}
|
|
172
172
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { bundle, check,
|
|
1
|
+
export { bundle, check, targetCatalog } from "./catalog.js";
|
|
2
2
|
export type { Catalog, Report } from "./catalog.js";
|
|
3
3
|
export { conform, fixture, serve } from "./conform/index.js";
|
|
4
4
|
export type { Check, ConformOptions, PollSettings, Routes, Served, WebHandler, WebhookSettings } from "./conform/index.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bundle, check,
|
|
1
|
+
import { bundle, check, targetCatalog } from "./catalog.js";
|
|
2
2
|
import { fixture } from "./conform/check.js";
|
|
3
3
|
import { serve } from "./conform/serve.js";
|
|
4
4
|
import { conform } from "./conform/index.js";
|
|
5
|
-
export { bundle, check, conform, fixture, serve,
|
|
5
|
+
export { bundle, check, conform, fixture, serve, targetCatalog };
|
|
@@ -52,7 +52,7 @@ var catalog_schema_default = {
|
|
|
52
52
|
"type": "string",
|
|
53
53
|
"pattern": "^[a-z][a-z0-9-]*(:[a-z][a-z0-9-]*)?$"
|
|
54
54
|
},
|
|
55
|
-
"
|
|
55
|
+
"surfaceName": {
|
|
56
56
|
"type": "string",
|
|
57
57
|
"pattern": "^[a-z][a-z0-9-]*(:[a-z][a-z0-9-]*)?$"
|
|
58
58
|
},
|
|
@@ -62,11 +62,11 @@ var catalog_schema_default = {
|
|
|
62
62
|
},
|
|
63
63
|
"target": {
|
|
64
64
|
"type": "object",
|
|
65
|
-
"required": ["
|
|
65
|
+
"required": ["surfaces"],
|
|
66
66
|
"properties": {
|
|
67
|
-
"
|
|
67
|
+
"surfaces": {
|
|
68
68
|
"type": "array",
|
|
69
|
-
"items": { "$ref": "#/$defs/
|
|
69
|
+
"items": { "$ref": "#/$defs/surfaceName" },
|
|
70
70
|
"minItems": 1,
|
|
71
71
|
"uniqueItems": true
|
|
72
72
|
},
|
|
@@ -78,7 +78,7 @@ var catalog_schema_default = {
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
"cliOptions": {
|
|
81
|
-
"description": "The settings of the CLI
|
|
81
|
+
"description": "The settings of the CLI surface. See spec/surfaces/cli.md#aliases.",
|
|
82
82
|
"type": "object",
|
|
83
83
|
"properties": {
|
|
84
84
|
"aliases": {
|
|
@@ -4,10 +4,10 @@ var fixture_acidcat_default = {
|
|
|
4
4
|
title: "AcidCat conformance fixture",
|
|
5
5
|
description: "One capability or event for each behavior that acid-cat conform tests.",
|
|
6
6
|
targets: {
|
|
7
|
-
"api": { "
|
|
8
|
-
"app": { "
|
|
7
|
+
"api": { "surfaces": ["http"] },
|
|
8
|
+
"app": { "surfaces": ["typescript", "webmcp"] },
|
|
9
9
|
"cli": {
|
|
10
|
-
"
|
|
10
|
+
"surfaces": ["cli"],
|
|
11
11
|
"options": { "cli": {
|
|
12
12
|
"aliases": {
|
|
13
13
|
"--hello": {
|
|
@@ -49,7 +49,7 @@ var fixture_acidcat_default = {
|
|
|
49
49
|
"default": "quick"
|
|
50
50
|
} }
|
|
51
51
|
},
|
|
52
|
-
"mcp": { "
|
|
52
|
+
"mcp": { "surfaces": ["mcp"] }
|
|
53
53
|
},
|
|
54
54
|
$defs: { "Note": {
|
|
55
55
|
"properties": {
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { version } from "./json/package.json.js";
|
|
3
|
-
import { check, isCatalog,
|
|
3
|
+
import { check, isCatalog, targetCatalog } from "./catalog.js";
|
|
4
4
|
import { DEADLINE } from "./conform/check.js";
|
|
5
5
|
import { conform } from "./conform/index.js";
|
|
6
6
|
import { parseJson } from "./json.js";
|
|
@@ -82,7 +82,7 @@ const formatCommand = Command.make("format", {
|
|
|
82
82
|
else yield* Effect.sync(() => process.stdout.write(text));
|
|
83
83
|
}
|
|
84
84
|
}, Effect.catchTag("UnreadableFile", reportUnreadable))).pipe(Command.withDescription("Write catalogs in canonical form."));
|
|
85
|
-
const
|
|
85
|
+
const targetCommand = Command.make("target", {
|
|
86
86
|
file: Argument.String("catalog").pipe(Argument.withDescription("A catalog file")),
|
|
87
87
|
target: Argument.String("target").pipe(Argument.withDescription("The name of a target in the catalog"))
|
|
88
88
|
}, Effect.fn(function* ({ file, target }) {
|
|
@@ -95,8 +95,8 @@ const viewCommand = Command.make("view", {
|
|
|
95
95
|
yield* Console.error(`${file}: error: there is no target ${target}`);
|
|
96
96
|
return yield* fail;
|
|
97
97
|
}
|
|
98
|
-
yield* Effect.sync(() => process.stdout.write(canonicalText(
|
|
99
|
-
}, Effect.catchTag("UnreadableFile", reportUnreadable))).pipe(Command.withDescription("Print the
|
|
98
|
+
yield* Effect.sync(() => process.stdout.write(canonicalText(targetCatalog(catalog, target))));
|
|
99
|
+
}, Effect.catchTag("UnreadableFile", reportUnreadable))).pipe(Command.withDescription("Print the catalog of one target."));
|
|
100
100
|
const url = (name, description) => Flag.String(name).pipe(Flag.withDescription(description), Flag.optional);
|
|
101
101
|
const conformCommand = Command.make("conform", {
|
|
102
102
|
mcp: url("mcp", "The URL of the MCP server"),
|
|
@@ -115,7 +115,7 @@ const conformCommand = Command.make("conform", {
|
|
|
115
115
|
webhookMaxTtlMs: Flag.Int("webhook-max-ttl-ms").pipe(Flag.withDescription("The maximum lifetime of a webhook subscription in the deployment. The default is 3600000"), Flag.optional),
|
|
116
116
|
webhookMinTtlMs: Flag.Int("webhook-min-ttl-ms").pipe(Flag.withDescription("The minimum lifetime of a webhook subscription in the deployment, shorter than the deadline. With it, conform tests that a subscription with no renewal ends"), Flag.optional),
|
|
117
117
|
webhookMaxSubscriptions: Flag.Int("webhook-max-subscriptions").pipe(Flag.withDescription("The maximum number of webhook subscriptions of one principal in the deployment. With it, conform tests the limit"), Flag.optional),
|
|
118
|
-
maximumBytes: Flag.Int("max-bytes").pipe(Flag.withDescription("The body limit of the remote
|
|
118
|
+
maximumBytes: Flag.Int("max-bytes").pipe(Flag.withDescription("The body limit of the remote surfaces"), Flag.withDefault(1048576)),
|
|
119
119
|
deadline: Flag.Int("deadline").pipe(Flag.withDescription("The time, in milliseconds, that each check has to settle. A check that does not settle in this time fails"), Flag.withDefault(DEADLINE)),
|
|
120
120
|
output
|
|
121
121
|
}, Effect.fn(function* (options) {
|
|
@@ -171,7 +171,7 @@ const conformCommand = Command.make("conform", {
|
|
|
171
171
|
deadline: options.deadline
|
|
172
172
|
}));
|
|
173
173
|
if (results.length === 0) {
|
|
174
|
-
yield* Console.error("Give at least one
|
|
174
|
+
yield* Console.error("Give at least one surface: --mcp, --mcp-stdio, --http, --cli or --webmcp.");
|
|
175
175
|
return yield* fail;
|
|
176
176
|
}
|
|
177
177
|
const failed = results.filter((result) => !result.passed).length;
|
|
@@ -186,14 +186,14 @@ const conformCommand = Command.make("conform", {
|
|
|
186
186
|
if (failed > 0) return yield* fail;
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
|
-
for (const result of results) yield* Console.log(`${result.warning === true ? "!" : result.passed ? "✓" : "✗"} ${result.
|
|
189
|
+
for (const result of results) yield* Console.log(`${result.warning === true ? "!" : result.passed ? "✓" : "✗"} ${result.surface}: ${result.name} (${result.rule})${result.detail ? `\n ${result.detail}` : ""}`);
|
|
190
190
|
yield* Console.log(`\n${results.length - failed} passed, ${failed} failed${warnings === 0 ? "" : `, ${warnings} with a warning`}.`);
|
|
191
191
|
if (failed > 0) return yield* fail;
|
|
192
|
-
}, Effect.catchTag("UnreadableFile", reportUnreadable))).pipe(Command.withDescription("Test a running implementation of the conformance fixture through its
|
|
193
|
-
const acidCat = Command.make("acid-cat").pipe(Command.withDescription("Check
|
|
192
|
+
}, Effect.catchTag("UnreadableFile", reportUnreadable))).pipe(Command.withDescription("Test a running implementation of the conformance fixture through its surfaces."));
|
|
193
|
+
const acidCat = Command.make("acid-cat").pipe(Command.withDescription("Check and format AcidCat catalogs, print the catalog of a target, and test implementations."), Command.withSubcommands([
|
|
194
194
|
checkCommand,
|
|
195
195
|
formatCommand,
|
|
196
|
-
|
|
196
|
+
targetCommand,
|
|
197
197
|
conformCommand
|
|
198
198
|
]));
|
|
199
199
|
const args = process.argv.slice(2);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acid-cat/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The AcidCat command line: check
|
|
3
|
+
"version": "0.18.0",
|
|
4
|
+
"description": "The AcidCat command line: check and format catalogs, print the catalog of a target, and test implementations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"acidcat",
|
|
7
7
|
"cli",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@acid-cat/catalog": "0.
|
|
43
|
-
"@acid-cat/spec-ts": "0.
|
|
42
|
+
"@acid-cat/catalog": "0.18.0",
|
|
43
|
+
"@acid-cat/spec-ts": "0.18.0",
|
|
44
44
|
"@effect/platform-node": "^4.1.3",
|
|
45
45
|
"@effect/platform-node-shared": "^4.1.3",
|
|
46
46
|
"@modelcontextprotocol/client": "2.4.0",
|