@vexyo/cli 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/LICENSE +202 -0
- package/README.md +14 -0
- package/dist/api.d.ts +17 -0
- package/dist/api.js +7 -0
- package/dist/api.js.map +1 -0
- package/dist/chunk-254CIBOC.js +208 -0
- package/dist/chunk-254CIBOC.js.map +1 -0
- package/dist/define.d.ts +52 -0
- package/dist/define.js +8 -0
- package/dist/define.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @vexyo/cli
|
|
2
|
+
|
|
3
|
+
The `vexyo` command line: run conformance checks and record/diff regression golden sets against an
|
|
4
|
+
MCP server, over stdio or Streamable HTTP.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
vexyo run --config vexyo.config.ts # conformance
|
|
8
|
+
vexyo record --config vexyo.config.ts # capture golden set
|
|
9
|
+
vexyo run --regression --config vexyo.config.ts --reporter markdown
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Exit codes: `0` pass, `1` findings at/above the failure threshold, `2` harness/config error.
|
|
13
|
+
|
|
14
|
+
Part of the [vexyo](https://github.com/vexyohq/vexyo) monorepo. Apache-2.0.
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RunResult } from '@vexyo/core';
|
|
2
|
+
|
|
3
|
+
interface ExecuteRunOptions {
|
|
4
|
+
config: string;
|
|
5
|
+
specVersion?: string;
|
|
6
|
+
regression?: boolean;
|
|
7
|
+
failOn?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Load config, connect over the configured transport, run the conformance suite
|
|
11
|
+
* (plus regression when requested), and return the {@link RunResult}. Throws
|
|
12
|
+
* `ConfigError`/`GoldenError`/connection errors for anything the caller should
|
|
13
|
+
* map to exit code 2. Shared by the `run` command and the GitHub Action.
|
|
14
|
+
*/
|
|
15
|
+
declare function executeRun(opts: ExecuteRunOptions): Promise<RunResult>;
|
|
16
|
+
|
|
17
|
+
export { type ExecuteRunOptions, executeRun };
|
package/dist/api.js
ADDED
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// src/commands/run.ts
|
|
2
|
+
import {
|
|
3
|
+
readGoldenSet,
|
|
4
|
+
runRegression,
|
|
5
|
+
runSuite
|
|
6
|
+
} from "@vexyo/core";
|
|
7
|
+
import {
|
|
8
|
+
consoleReporter,
|
|
9
|
+
jsonReporter,
|
|
10
|
+
junitReporter,
|
|
11
|
+
markdownReporter
|
|
12
|
+
} from "@vexyo/reporters";
|
|
13
|
+
|
|
14
|
+
// src/config.ts
|
|
15
|
+
import { resolve } from "path";
|
|
16
|
+
import { pathToFileURL } from "url";
|
|
17
|
+
import { createJiti } from "jiti";
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
var SPEC_VERSIONS = ["2025-11-25", "2026-07-28"];
|
|
20
|
+
var stdioTargetSchema = z.object({
|
|
21
|
+
transport: z.literal("stdio"),
|
|
22
|
+
command: z.string().min(1),
|
|
23
|
+
args: z.array(z.string()).optional(),
|
|
24
|
+
cwd: z.string().optional(),
|
|
25
|
+
env: z.record(z.string(), z.string()).optional()
|
|
26
|
+
});
|
|
27
|
+
var httpTargetSchema = z.object({
|
|
28
|
+
transport: z.literal("http"),
|
|
29
|
+
url: z.string().min(1),
|
|
30
|
+
/** Extra HTTP headers sent on every request (e.g. auth). */
|
|
31
|
+
headers: z.record(z.string(), z.string()).optional()
|
|
32
|
+
});
|
|
33
|
+
var targetSchema = z.discriminatedUnion("transport", [stdioTargetSchema, httpTargetSchema]);
|
|
34
|
+
var normalizerRefSchema = z.union([
|
|
35
|
+
z.string(),
|
|
36
|
+
z.object({
|
|
37
|
+
name: z.string(),
|
|
38
|
+
apply: z.custom((v) => typeof v === "function")
|
|
39
|
+
})
|
|
40
|
+
]);
|
|
41
|
+
var recordCaseSchema = z.object({
|
|
42
|
+
case: z.string().min(1),
|
|
43
|
+
arguments: z.record(z.string(), z.unknown()).default({})
|
|
44
|
+
});
|
|
45
|
+
var recordToolSchema = z.object({
|
|
46
|
+
cases: z.array(recordCaseSchema).min(1),
|
|
47
|
+
normalizers: z.array(normalizerRefSchema).optional()
|
|
48
|
+
});
|
|
49
|
+
var regressionSchema = z.object({
|
|
50
|
+
/** Committed golden directory (relative to the config file's cwd). */
|
|
51
|
+
goldenDir: z.string().default("vexyo/goldens"),
|
|
52
|
+
/** Severity at/above which drift fails the run. */
|
|
53
|
+
failOn: z.enum(["error", "warning"]).default("error"),
|
|
54
|
+
/** Default normalizers applied to every recorded tool. */
|
|
55
|
+
normalizers: z.array(normalizerRefSchema).default([]),
|
|
56
|
+
/** Tools to record/compare, keyed by name. Empty = record nothing (opt-in). */
|
|
57
|
+
record: z.record(z.string(), recordToolSchema).default({})
|
|
58
|
+
});
|
|
59
|
+
var configSchema = z.object({
|
|
60
|
+
specVersion: z.enum(SPEC_VERSIONS).default("2025-11-25"),
|
|
61
|
+
target: targetSchema,
|
|
62
|
+
security: z.boolean().default(false),
|
|
63
|
+
regression: regressionSchema.optional()
|
|
64
|
+
});
|
|
65
|
+
var ConfigError = class extends Error {
|
|
66
|
+
constructor(message, cause) {
|
|
67
|
+
super(message, cause !== void 0 ? { cause } : void 0);
|
|
68
|
+
this.name = "ConfigError";
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
function formatZodError(error) {
|
|
72
|
+
return error.issues.map((issue) => ` - ${issue.path.join(".") || "(root)"}: ${issue.message}`).join("\n");
|
|
73
|
+
}
|
|
74
|
+
async function loadConfig(configPath) {
|
|
75
|
+
const absolute = resolve(process.cwd(), configPath);
|
|
76
|
+
let mod;
|
|
77
|
+
try {
|
|
78
|
+
const jiti = createJiti(pathToFileURL(absolute).href);
|
|
79
|
+
mod = await jiti.import(absolute, { default: true });
|
|
80
|
+
} catch (err) {
|
|
81
|
+
throw new ConfigError(
|
|
82
|
+
`Could not load config file at ${absolute}. Check the path and that the file has a default export.`,
|
|
83
|
+
err
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
const parsed = configSchema.safeParse(mod);
|
|
87
|
+
if (!parsed.success) {
|
|
88
|
+
throw new ConfigError(`Invalid config at ${absolute}:
|
|
89
|
+
${formatZodError(parsed.error)}`);
|
|
90
|
+
}
|
|
91
|
+
return parsed.data;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/errors.ts
|
|
95
|
+
function reportHarnessError(err) {
|
|
96
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
97
|
+
process.stderr.write(`error: ${message}
|
|
98
|
+
`);
|
|
99
|
+
const cause = err instanceof Error ? err.cause : void 0;
|
|
100
|
+
if (cause !== void 0) {
|
|
101
|
+
process.stderr.write(` cause: ${cause instanceof Error ? cause.message : String(cause)}
|
|
102
|
+
`);
|
|
103
|
+
}
|
|
104
|
+
return 2;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/regression.ts
|
|
108
|
+
import { dirname, resolve as resolve2 } from "path";
|
|
109
|
+
function resolveGoldenDir(configPath, regression) {
|
|
110
|
+
return resolve2(dirname(resolve2(process.cwd(), configPath)), regression.goldenDir);
|
|
111
|
+
}
|
|
112
|
+
function toGoldenConfig(specVersion, regression) {
|
|
113
|
+
return {
|
|
114
|
+
specVersion,
|
|
115
|
+
defaultNormalizers: regression.normalizers,
|
|
116
|
+
tools: Object.fromEntries(
|
|
117
|
+
Object.entries(regression.record).map(([name, spec]) => [
|
|
118
|
+
name,
|
|
119
|
+
{ cases: spec.cases, normalizers: spec.normalizers }
|
|
120
|
+
])
|
|
121
|
+
)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/target.ts
|
|
126
|
+
function buildTarget(config) {
|
|
127
|
+
if (config.target.transport === "http") {
|
|
128
|
+
return {
|
|
129
|
+
transport: "http",
|
|
130
|
+
http: { url: config.target.url, headers: config.target.headers }
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return { transport: "stdio", stdio: config.target };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/commands/run.ts
|
|
137
|
+
var REPORTERS = {
|
|
138
|
+
console: consoleReporter,
|
|
139
|
+
json: jsonReporter,
|
|
140
|
+
markdown: markdownReporter,
|
|
141
|
+
junit: junitReporter
|
|
142
|
+
};
|
|
143
|
+
async function executeRun(opts) {
|
|
144
|
+
const config = await loadConfig(opts.config);
|
|
145
|
+
const specVersion = resolveSpecVersion(opts.specVersion, config);
|
|
146
|
+
const failOn = resolveFailOn(opts.failOn, config);
|
|
147
|
+
const extraChecks = await buildRegressionPhase(opts, config, specVersion);
|
|
148
|
+
return runSuite({
|
|
149
|
+
specVersion,
|
|
150
|
+
target: buildTarget(config),
|
|
151
|
+
failOn,
|
|
152
|
+
extraChecks
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
async function runCommand(opts) {
|
|
156
|
+
const reporter = REPORTERS[opts.reporter];
|
|
157
|
+
if (!reporter) {
|
|
158
|
+
return reportHarnessError(
|
|
159
|
+
new ConfigError(
|
|
160
|
+
`Unknown reporter "${opts.reporter}". Available reporters: ${Object.keys(REPORTERS).join(", ")}.`
|
|
161
|
+
)
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
let result;
|
|
165
|
+
try {
|
|
166
|
+
result = await executeRun(opts);
|
|
167
|
+
} catch (err) {
|
|
168
|
+
return reportHarnessError(err);
|
|
169
|
+
}
|
|
170
|
+
process.stdout.write(`${reporter.format(result)}
|
|
171
|
+
`);
|
|
172
|
+
return result.exitCode;
|
|
173
|
+
}
|
|
174
|
+
function resolveSpecVersion(override, config) {
|
|
175
|
+
const specVersion = override ?? config.specVersion;
|
|
176
|
+
if (specVersion !== "2025-11-25") {
|
|
177
|
+
throw new ConfigError(
|
|
178
|
+
`Spec version "${specVersion}" is not wired up in this build. Only 2025-11-25 is supported.`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
return specVersion;
|
|
182
|
+
}
|
|
183
|
+
function resolveFailOn(override, config) {
|
|
184
|
+
return override ?? config.regression?.failOn ?? "error";
|
|
185
|
+
}
|
|
186
|
+
async function buildRegressionPhase(opts, config, specVersion) {
|
|
187
|
+
if (!opts.regression) {
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
if (!config.regression) {
|
|
191
|
+
throw new ConfigError("`--regression` requires a `regression` block in the config.");
|
|
192
|
+
}
|
|
193
|
+
const goldenSet = await readGoldenSet(resolveGoldenDir(opts.config, config.regression));
|
|
194
|
+
const goldenCfg = toGoldenConfig(specVersion, config.regression);
|
|
195
|
+
return (ctx) => runRegression(ctx.client, goldenSet, goldenCfg);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export {
|
|
199
|
+
ConfigError,
|
|
200
|
+
loadConfig,
|
|
201
|
+
reportHarnessError,
|
|
202
|
+
resolveGoldenDir,
|
|
203
|
+
toGoldenConfig,
|
|
204
|
+
buildTarget,
|
|
205
|
+
executeRun,
|
|
206
|
+
runCommand
|
|
207
|
+
};
|
|
208
|
+
//# sourceMappingURL=chunk-254CIBOC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/run.ts","../src/config.ts","../src/errors.ts","../src/regression.ts","../src/target.ts"],"sourcesContent":["import {\n readGoldenSet,\n runRegression,\n runSuite,\n type RunResult,\n type RunSuiteOptions,\n type Severity,\n type SpecVersion,\n} from '@vexyo/core';\nimport {\n consoleReporter,\n jsonReporter,\n junitReporter,\n markdownReporter,\n type Reporter,\n} from '@vexyo/reporters';\nimport { ConfigError, loadConfig, type Config } from '../config';\nimport { reportHarnessError } from '../errors';\nimport { resolveGoldenDir, toGoldenConfig } from '../regression';\nimport { buildTarget } from '../target';\n\nexport interface RunCommandOptions {\n config: string;\n specVersion?: string;\n reporter: string;\n regression?: boolean;\n failOn?: string;\n}\n\nexport interface ExecuteRunOptions {\n config: string;\n specVersion?: string;\n regression?: boolean;\n failOn?: string;\n}\n\nconst REPORTERS: Record<string, Reporter> = {\n console: consoleReporter,\n json: jsonReporter,\n markdown: markdownReporter,\n junit: junitReporter,\n};\n\n/**\n * Load config, connect over the configured transport, run the conformance suite\n * (plus regression when requested), and return the {@link RunResult}. Throws\n * `ConfigError`/`GoldenError`/connection errors for anything the caller should\n * map to exit code 2. Shared by the `run` command and the GitHub Action.\n */\nexport async function executeRun(opts: ExecuteRunOptions): Promise<RunResult> {\n const config = await loadConfig(opts.config);\n const specVersion = resolveSpecVersion(opts.specVersion, config);\n const failOn = resolveFailOn(opts.failOn, config);\n const extraChecks = await buildRegressionPhase(opts, config, specVersion);\n\n return runSuite({\n specVersion,\n target: buildTarget(config),\n failOn,\n extraChecks,\n });\n}\n\n/**\n * Execute the `run` command. Returns the process exit code:\n * 0 = pass, 1 = findings at/above threshold, 2 = harness/config error.\n */\nexport async function runCommand(opts: RunCommandOptions): Promise<0 | 1 | 2> {\n const reporter = REPORTERS[opts.reporter];\n if (!reporter) {\n return reportHarnessError(\n new ConfigError(\n `Unknown reporter \"${opts.reporter}\". Available reporters: ${Object.keys(REPORTERS).join(', ')}.`,\n ),\n );\n }\n\n let result: RunResult;\n try {\n result = await executeRun(opts);\n } catch (err) {\n return reportHarnessError(err);\n }\n\n process.stdout.write(`${reporter.format(result)}\\n`);\n return result.exitCode;\n}\n\nfunction resolveSpecVersion(override: string | undefined, config: Config): SpecVersion {\n const specVersion = (override as SpecVersion | undefined) ?? config.specVersion;\n if (specVersion !== '2025-11-25') {\n throw new ConfigError(\n `Spec version \"${specVersion}\" is not wired up in this build. Only 2025-11-25 is supported.`,\n );\n }\n return specVersion;\n}\n\nfunction resolveFailOn(override: string | undefined, config: Config): Severity {\n return (override as Severity | undefined) ?? config.regression?.failOn ?? 'error';\n}\n\nasync function buildRegressionPhase(\n opts: ExecuteRunOptions,\n config: Config,\n specVersion: SpecVersion,\n): Promise<RunSuiteOptions['extraChecks']> {\n if (!opts.regression) {\n return undefined;\n }\n if (!config.regression) {\n throw new ConfigError('`--regression` requires a `regression` block in the config.');\n }\n const goldenSet = await readGoldenSet(resolveGoldenDir(opts.config, config.regression));\n const goldenCfg = toGoldenConfig(specVersion, config.regression);\n return (ctx) => runRegression(ctx.client, goldenSet, goldenCfg);\n}\n","import { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { createJiti } from 'jiti';\nimport { z } from 'zod';\n\nexport const SPEC_VERSIONS = ['2025-11-25', '2026-07-28'] as const;\n\nconst stdioTargetSchema = z.object({\n transport: z.literal('stdio'),\n command: z.string().min(1),\n args: z.array(z.string()).optional(),\n cwd: z.string().optional(),\n env: z.record(z.string(), z.string()).optional(),\n});\n\nconst httpTargetSchema = z.object({\n transport: z.literal('http'),\n url: z.string().min(1),\n /** Extra HTTP headers sent on every request (e.g. auth). */\n headers: z.record(z.string(), z.string()).optional(),\n});\n\nconst targetSchema = z.discriminatedUnion('transport', [stdioTargetSchema, httpTargetSchema]);\n\n/** A normalizer is a builtin name or an inline `{ name, apply }` object. */\nconst normalizerRefSchema = z.union([\n z.string(),\n z.object({\n name: z.string(),\n apply: z.custom<(value: unknown) => unknown>((v) => typeof v === 'function'),\n }),\n]);\n\nconst recordCaseSchema = z.object({\n case: z.string().min(1),\n arguments: z.record(z.string(), z.unknown()).default({}),\n});\n\nconst recordToolSchema = z.object({\n cases: z.array(recordCaseSchema).min(1),\n normalizers: z.array(normalizerRefSchema).optional(),\n});\n\nconst regressionSchema = z.object({\n /** Committed golden directory (relative to the config file's cwd). */\n goldenDir: z.string().default('vexyo/goldens'),\n /** Severity at/above which drift fails the run. */\n failOn: z.enum(['error', 'warning']).default('error'),\n /** Default normalizers applied to every recorded tool. */\n normalizers: z.array(normalizerRefSchema).default([]),\n /** Tools to record/compare, keyed by name. Empty = record nothing (opt-in). */\n record: z.record(z.string(), recordToolSchema).default({}),\n});\n\nexport const configSchema = z.object({\n specVersion: z.enum(SPEC_VERSIONS).default('2025-11-25'),\n target: targetSchema,\n security: z.boolean().default(false),\n regression: regressionSchema.optional(),\n});\n\nexport type RegressionConfig = z.infer<typeof regressionSchema>;\n\n/** Validated, defaults-applied config. */\nexport type Config = z.infer<typeof configSchema>;\n/** Shape a user writes in a config file (before defaults are applied). */\nexport type UserConfig = z.input<typeof configSchema>;\nexport type StdioTarget = Extract<Config['target'], { transport: 'stdio' }>;\n\n/** Raised for anything the user must fix in their config or invocation (exit 2). */\nexport class ConfigError extends Error {\n constructor(message: string, cause?: unknown) {\n super(message, cause !== undefined ? { cause } : undefined);\n this.name = 'ConfigError';\n }\n}\n\nfunction formatZodError(error: z.ZodError): string {\n return error.issues\n .map((issue) => ` - ${issue.path.join('.') || '(root)'}: ${issue.message}`)\n .join('\\n');\n}\n\n/**\n * Load and validate a config file. Supports `.ts`/`.js`/`.mjs` via jiti so the\n * blueprint's `examples/*.config.ts` work without a build step. The default\n * export is validated against {@link configSchema}.\n */\nexport async function loadConfig(configPath: string): Promise<Config> {\n const absolute = resolve(process.cwd(), configPath);\n\n let mod: unknown;\n try {\n const jiti = createJiti(pathToFileURL(absolute).href);\n mod = await jiti.import(absolute, { default: true });\n } catch (err) {\n throw new ConfigError(\n `Could not load config file at ${absolute}. Check the path and that the file has a default export.`,\n err,\n );\n }\n\n const parsed = configSchema.safeParse(mod);\n if (!parsed.success) {\n throw new ConfigError(`Invalid config at ${absolute}:\\n${formatZodError(parsed.error)}`);\n }\n return parsed.data;\n}\n","/** Print a harness/config error (with its cause, if any) and return exit code 2. */\nexport function reportHarnessError(err: unknown): 2 {\n const message = err instanceof Error ? err.message : String(err);\n process.stderr.write(`error: ${message}\\n`);\n const cause = err instanceof Error ? err.cause : undefined;\n if (cause !== undefined) {\n process.stderr.write(` cause: ${cause instanceof Error ? cause.message : String(cause)}\\n`);\n }\n return 2;\n}\n","import { dirname, resolve } from 'node:path';\nimport type { GoldenConfig } from '@vexyo/core';\nimport type { RegressionConfig } from './config';\n\n/** Resolve `goldenDir` relative to the config file's directory. */\nexport function resolveGoldenDir(configPath: string, regression: RegressionConfig): string {\n return resolve(dirname(resolve(process.cwd(), configPath)), regression.goldenDir);\n}\n\n/** Map the CLI's regression config onto the core engine's {@link GoldenConfig}. */\nexport function toGoldenConfig(specVersion: string, regression: RegressionConfig): GoldenConfig {\n return {\n specVersion,\n defaultNormalizers: regression.normalizers,\n tools: Object.fromEntries(\n Object.entries(regression.record).map(([name, spec]) => [\n name,\n { cases: spec.cases, normalizers: spec.normalizers },\n ]),\n ),\n };\n}\n","import type { ConnectTarget } from '@vexyo/core';\nimport type { Config } from './config';\n\n/** Map the validated config's target onto the core engine's {@link ConnectTarget}. */\nexport function buildTarget(config: Config): ConnectTarget {\n if (config.target.transport === 'http') {\n return {\n transport: 'http',\n http: { url: config.target.url, headers: config.target.headers },\n };\n }\n return { transport: 'stdio', stdio: config.target };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACfP,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,SAAS;AAEX,IAAM,gBAAgB,CAAC,cAAc,YAAY;AAExD,IAAM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;AAChE;","names":["resolve"]}
|
package/dist/define.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const configSchema: z.ZodObject<{
|
|
4
|
+
specVersion: z.ZodDefault<z.ZodEnum<{
|
|
5
|
+
"2025-11-25": "2025-11-25";
|
|
6
|
+
"2026-07-28": "2026-07-28";
|
|
7
|
+
}>>;
|
|
8
|
+
target: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
|
+
transport: z.ZodLiteral<"stdio">;
|
|
10
|
+
command: z.ZodString;
|
|
11
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
13
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
14
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
15
|
+
transport: z.ZodLiteral<"http">;
|
|
16
|
+
url: z.ZodString;
|
|
17
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
18
|
+
}, z.core.$strip>], "transport">;
|
|
19
|
+
security: z.ZodDefault<z.ZodBoolean>;
|
|
20
|
+
regression: z.ZodOptional<z.ZodObject<{
|
|
21
|
+
goldenDir: z.ZodDefault<z.ZodString>;
|
|
22
|
+
failOn: z.ZodDefault<z.ZodEnum<{
|
|
23
|
+
error: "error";
|
|
24
|
+
warning: "warning";
|
|
25
|
+
}>>;
|
|
26
|
+
normalizers: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
27
|
+
name: z.ZodString;
|
|
28
|
+
apply: z.ZodCustom<(value: unknown) => unknown, (value: unknown) => unknown>;
|
|
29
|
+
}, z.core.$strip>]>>>;
|
|
30
|
+
record: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
31
|
+
cases: z.ZodArray<z.ZodObject<{
|
|
32
|
+
case: z.ZodString;
|
|
33
|
+
arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
normalizers: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
36
|
+
name: z.ZodString;
|
|
37
|
+
apply: z.ZodCustom<(value: unknown) => unknown, (value: unknown) => unknown>;
|
|
38
|
+
}, z.core.$strip>]>>>;
|
|
39
|
+
}, z.core.$strip>>>;
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
/** Shape a user writes in a config file (before defaults are applied). */
|
|
43
|
+
type UserConfig = z.input<typeof configSchema>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Identity helper that gives config authors editor autocomplete and type
|
|
47
|
+
* checking. Kept free of runtime dependencies (no jiti/zod pulled in) so it is
|
|
48
|
+
* cheap to import from a config file.
|
|
49
|
+
*/
|
|
50
|
+
declare function defineConfig(config: UserConfig): UserConfig;
|
|
51
|
+
|
|
52
|
+
export { type UserConfig, defineConfig };
|
package/dist/define.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/define.ts"],"sourcesContent":["import type { UserConfig } from './config';\n\nexport type { UserConfig };\n\n/**\n * Identity helper that gives config authors editor autocomplete and type\n * checking. Kept free of runtime dependencies (no jiti/zod pulled in) so it is\n * cheap to import from a config file.\n */\nexport function defineConfig(config: UserConfig): UserConfig {\n return config;\n}\n"],"mappings":";AASO,SAAS,aAAa,QAAgC;AAC3D,SAAO;AACT;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
ConfigError,
|
|
4
|
+
buildTarget,
|
|
5
|
+
loadConfig,
|
|
6
|
+
reportHarnessError,
|
|
7
|
+
resolveGoldenDir,
|
|
8
|
+
runCommand,
|
|
9
|
+
toGoldenConfig
|
|
10
|
+
} from "./chunk-254CIBOC.js";
|
|
11
|
+
|
|
12
|
+
// src/index.ts
|
|
13
|
+
import { BRAND } from "@vexyo/core";
|
|
14
|
+
import { Command } from "commander";
|
|
15
|
+
|
|
16
|
+
// src/commands/record.ts
|
|
17
|
+
import { connectTarget, recordGoldens, writeGoldenSet } from "@vexyo/core";
|
|
18
|
+
async function recordCommand(opts) {
|
|
19
|
+
let config;
|
|
20
|
+
try {
|
|
21
|
+
config = await loadConfig(opts.config);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
return reportHarnessError(err);
|
|
24
|
+
}
|
|
25
|
+
if (!config.regression) {
|
|
26
|
+
return reportHarnessError(
|
|
27
|
+
new ConfigError("No `regression` block in the config \u2014 nothing to record.")
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
const goldenDir = resolveGoldenDir(opts.config, config.regression);
|
|
31
|
+
const goldenCfg = toGoldenConfig(config.specVersion, config.regression);
|
|
32
|
+
const toolCount = Object.keys(goldenCfg.tools).length;
|
|
33
|
+
process.stdout.write(
|
|
34
|
+
toolCount === 0 ? "No tools configured under `regression.record`; recording manifest only.\n" : `Recording ${toolCount} tool(s): ${Object.keys(goldenCfg.tools).sort().join(", ")}
|
|
35
|
+
`
|
|
36
|
+
);
|
|
37
|
+
let conn;
|
|
38
|
+
try {
|
|
39
|
+
conn = await connectTarget(buildTarget(config));
|
|
40
|
+
} catch (err) {
|
|
41
|
+
return reportHarnessError(err);
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const set = await recordGoldens(conn.client, goldenCfg);
|
|
45
|
+
const written = await writeGoldenSet(goldenDir, set);
|
|
46
|
+
process.stdout.write(`Wrote ${written.length} golden file(s) to ${goldenDir}:
|
|
47
|
+
`);
|
|
48
|
+
for (const path of written) {
|
|
49
|
+
process.stdout.write(` ${path}
|
|
50
|
+
`);
|
|
51
|
+
}
|
|
52
|
+
return 0;
|
|
53
|
+
} catch (err) {
|
|
54
|
+
return reportHarnessError(err);
|
|
55
|
+
} finally {
|
|
56
|
+
await conn.close().catch(() => void 0);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/index.ts
|
|
61
|
+
var program = new Command();
|
|
62
|
+
program.name(BRAND.bin).description("CI-native conformance harness for MCP servers");
|
|
63
|
+
program.command("run").description("Run the conformance suite (and optionally regression) against an MCP server").requiredOption("-c, --config <path>", "path to the vexyo config file").option("-s, --spec-version <version>", "override the spec version to target").option("-r, --reporter <name>", "output reporter (console, json, markdown)", "console").option("--regression", "also diff current behavior against the recorded golden set").option("--fail-on <severity>", "severity at/above which findings fail the run (error, warning)").action(
|
|
64
|
+
async (opts) => {
|
|
65
|
+
const code = await runCommand({
|
|
66
|
+
config: opts.config,
|
|
67
|
+
specVersion: opts.specVersion,
|
|
68
|
+
reporter: opts.reporter,
|
|
69
|
+
regression: opts.regression,
|
|
70
|
+
failOn: opts.failOn
|
|
71
|
+
});
|
|
72
|
+
process.exit(code);
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
program.command("record").description("Record golden files for the tools configured under `regression.record`").requiredOption("-c, --config <path>", "path to the vexyo config file").action(async (opts) => {
|
|
76
|
+
const code = await recordCommand({ config: opts.config });
|
|
77
|
+
process.exit(code);
|
|
78
|
+
});
|
|
79
|
+
var argv = process.argv.slice();
|
|
80
|
+
if (argv[2] === "--") argv.splice(2, 1);
|
|
81
|
+
program.parseAsync(argv).catch((err) => {
|
|
82
|
+
process.stderr.write(`fatal: ${err instanceof Error ? err.message : String(err)}
|
|
83
|
+
`);
|
|
84
|
+
process.exit(2);
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/commands/record.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { BRAND } from '@vexyo/core';\nimport { Command } from 'commander';\nimport { recordCommand } from './commands/record';\nimport { runCommand } from './commands/run';\n\nconst program = new Command();\n\nprogram.name(BRAND.bin).description('CI-native conformance harness for MCP servers');\n\nprogram\n .command('run')\n .description('Run the conformance suite (and optionally regression) against an MCP server')\n .requiredOption('-c, --config <path>', 'path to the vexyo config file')\n .option('-s, --spec-version <version>', 'override the spec version to target')\n .option('-r, --reporter <name>', 'output reporter (console, json, markdown)', 'console')\n .option('--regression', 'also diff current behavior against the recorded golden set')\n .option('--fail-on <severity>', 'severity at/above which findings fail the run (error, warning)')\n .action(\n async (opts: {\n config: string;\n specVersion?: string;\n reporter: string;\n regression?: boolean;\n failOn?: string;\n }) => {\n const code = await runCommand({\n config: opts.config,\n specVersion: opts.specVersion,\n reporter: opts.reporter,\n regression: opts.regression,\n failOn: opts.failOn,\n });\n process.exit(code);\n },\n );\n\nprogram\n .command('record')\n .description('Record golden files for the tools configured under `regression.record`')\n .requiredOption('-c, --config <path>', 'path to the vexyo config file')\n .action(async (opts: { config: string }) => {\n const code = await recordCommand({ config: opts.config });\n process.exit(code);\n });\n\n// `pnpm vexyo -- run ...` forwards the `--` separator literally; drop a\n// leading one so both that and `pnpm vexyo run ...` parse identically.\nconst argv = process.argv.slice();\nif (argv[2] === '--') argv.splice(2, 1);\n\nprogram.parseAsync(argv).catch((err: unknown) => {\n process.stderr.write(`fatal: ${err instanceof Error ? err.message : String(err)}\\n`);\n process.exit(2);\n});\n","import { connectTarget, recordGoldens, writeGoldenSet } from '@vexyo/core';\nimport { ConfigError, loadConfig, type Config } from '../config';\nimport { reportHarnessError } from '../errors';\nimport { resolveGoldenDir, toGoldenConfig } from '../regression';\nimport { buildTarget } from '../target';\n\nexport interface RecordCommandOptions {\n config: string;\n}\n\n/**\n * Capture golden files. Connects over the configured transport, snapshots the\n * schema manifest (read-only), and calls only the tools explicitly listed in\n * `regression.record` — never \"call everything\". Returns 0 on success, 2 on any\n * harness/config error.\n */\nexport async function recordCommand(opts: RecordCommandOptions): Promise<0 | 2> {\n let config: Config;\n try {\n config = await loadConfig(opts.config);\n } catch (err) {\n return reportHarnessError(err);\n }\n\n if (!config.regression) {\n return reportHarnessError(\n new ConfigError('No `regression` block in the config — nothing to record.'),\n );\n }\n\n const goldenDir = resolveGoldenDir(opts.config, config.regression);\n const goldenCfg = toGoldenConfig(config.specVersion, config.regression);\n\n const toolCount = Object.keys(goldenCfg.tools).length;\n process.stdout.write(\n toolCount === 0\n ? 'No tools configured under `regression.record`; recording manifest only.\\n'\n : `Recording ${toolCount} tool(s): ${Object.keys(goldenCfg.tools).sort().join(', ')}\\n`,\n );\n\n let conn: Awaited<ReturnType<typeof connectTarget>>;\n try {\n conn = await connectTarget(buildTarget(config));\n } catch (err) {\n return reportHarnessError(err);\n }\n\n try {\n const set = await recordGoldens(conn.client, goldenCfg);\n const written = await writeGoldenSet(goldenDir, set);\n process.stdout.write(`Wrote ${written.length} golden file(s) to ${goldenDir}:\\n`);\n for (const path of written) {\n process.stdout.write(` ${path}\\n`);\n }\n return 0;\n } catch (err) {\n return reportHarnessError(err);\n } finally {\n await conn.close().catch(() => undefined);\n }\n}\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,aAAa;AACtB,SAAS,eAAe;;;ACFxB,SAAS,eAAe,eAAe,sBAAsB;AAgB7D,eAAsB,cAAc,MAA4C;AAC9E,MAAI;AACJ,MAAI;AACF,aAAS,MAAM,WAAW,KAAK,MAAM;AAAA,EACvC,SAAS,KAAK;AACZ,WAAO,mBAAmB,GAAG;AAAA,EAC/B;AAEA,MAAI,CAAC,OAAO,YAAY;AACtB,WAAO;AAAA,MACL,IAAI,YAAY,+DAA0D;AAAA,IAC5E;AAAA,EACF;AAEA,QAAM,YAAY,iBAAiB,KAAK,QAAQ,OAAO,UAAU;AACjE,QAAM,YAAY,eAAe,OAAO,aAAa,OAAO,UAAU;AAEtE,QAAM,YAAY,OAAO,KAAK,UAAU,KAAK,EAAE;AAC/C,UAAQ,OAAO;AAAA,IACb,cAAc,IACV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+B,EACrE,OAAO,OAAO,SAA6B;AAC1C,QAAM,OAAO,MAAM,cAAc,EAAE,QAAQ,KAAK,OAAO,CAAC;AACxD,UAAQ,KAAK,IAAI;AACnB,CAAC;AAIH,IAAM,OAAO,QAAQ,KAAK,MAAM;AAChC,IAAI,KAAK,CAAC,MAAM,KAAM,MAAK,OAAO,GAAG,CAAC;AAEtC,QAAQ,WAAW,IAAI,EAAE,MAAM,CAAC,QAAiB;AAC/C,UAAQ,OAAO,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,CAAI;AACnF,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vexyo/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for vexyo — conformance and regression testing for MCP servers, for local dev and CI.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"model-context-protocol",
|
|
8
|
+
"testing",
|
|
9
|
+
"conformance",
|
|
10
|
+
"regression",
|
|
11
|
+
"ci",
|
|
12
|
+
"cli"
|
|
13
|
+
],
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/vexyohq/vexyo.git",
|
|
18
|
+
"directory": "packages/cli"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/vexyohq/vexyo#readme",
|
|
21
|
+
"private": false,
|
|
22
|
+
"type": "module",
|
|
23
|
+
"bin": {
|
|
24
|
+
"vexyo": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./config": {
|
|
32
|
+
"types": "./dist/define.d.ts",
|
|
33
|
+
"default": "./dist/define.js"
|
|
34
|
+
},
|
|
35
|
+
"./api": {
|
|
36
|
+
"types": "./dist/api.d.ts",
|
|
37
|
+
"default": "./dist/api.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"commander": "^13.1.0",
|
|
42
|
+
"jiti": "^2.4.2",
|
|
43
|
+
"zod": "^4.0.0",
|
|
44
|
+
"@vexyo/core": "0.1.0",
|
|
45
|
+
"@vexyo/reporters": "0.1.0"
|
|
46
|
+
},
|
|
47
|
+
"main": "./dist/index.js",
|
|
48
|
+
"types": "./dist/index.d.ts",
|
|
49
|
+
"files": [
|
|
50
|
+
"dist"
|
|
51
|
+
],
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup"
|
|
57
|
+
}
|
|
58
|
+
}
|