@tryaura/aura-testkit 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 +144 -0
- package/dist/index.d.ts +306 -0
- package/dist/index.js +2005 -0
- package/package.json +52 -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,144 @@
|
|
|
1
|
+
# `@tryaura/aura-testkit`
|
|
2
|
+
|
|
3
|
+
Deterministic fake machines for testing Aura plugins and distributions. A test describes a HOME, a
|
|
4
|
+
workspace, and the executables on `PATH`; the testkit materializes them in a temporary directory,
|
|
5
|
+
runs the real CLI against them in process, and hands back output that is stable enough to snapshot.
|
|
6
|
+
|
|
7
|
+
Nothing in a seeded run reads the surrounding process — not the real home directory, not the real
|
|
8
|
+
`PATH`, and not the ambient environment. A secret in `process.env` is not visible to a command the
|
|
9
|
+
run spawns.
|
|
10
|
+
|
|
11
|
+
## Seeding a machine
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createSeedBuilder, runCheck } from "@tryaura/aura-testkit";
|
|
15
|
+
|
|
16
|
+
it("reports a legacy config", async () => {
|
|
17
|
+
await using seed = await createSeedBuilder()
|
|
18
|
+
.homeFile(".fixture/config.txt", "legacy=true\n")
|
|
19
|
+
.workspaceFile("AGENTS.md", "workspace instructions\n")
|
|
20
|
+
.shim("fixture-agent", [{ args: ["--version"], stdout: "fixture-agent 1.2.3\n" }])
|
|
21
|
+
.build();
|
|
22
|
+
|
|
23
|
+
const result = await runCheck({ distro, seed });
|
|
24
|
+
|
|
25
|
+
expect(result.findings).toMatchInlineSnapshot();
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`await using` disposes the seed at the end of the block. `seed.cleanup()` does the same thing
|
|
30
|
+
explicitly, and is safe to call more than once.
|
|
31
|
+
|
|
32
|
+
Seeded paths are relative and must stay inside their root. The seed root is canonicalized, so a
|
|
33
|
+
path a spawned tool resolves is the same string the seed reports.
|
|
34
|
+
|
|
35
|
+
## Shims
|
|
36
|
+
|
|
37
|
+
`shim(command, responses)` writes an executable onto the seeded `PATH`. Each response matches one
|
|
38
|
+
shape of invocation exactly, including how many arguments there are. Use `ANY_ARGUMENT` for a
|
|
39
|
+
position whose value a test cannot predict:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { ANY_ARGUMENT, createSeedBuilder } from "@tryaura/aura-testkit";
|
|
43
|
+
|
|
44
|
+
const seed = await createSeedBuilder()
|
|
45
|
+
.shim("fixture-agent", [
|
|
46
|
+
{ args: ["--version"], stdout: "fixture-agent 1.2.3\n" },
|
|
47
|
+
{ args: ["mcp", "add", ANY_ARGUMENT], stdout: "added\n" },
|
|
48
|
+
{ args: ["status"], exitCode: 7, stderr: "not ready\n" },
|
|
49
|
+
])
|
|
50
|
+
.build();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The first matching response wins, so declare overlapping ones from most to least specific. An
|
|
54
|
+
invocation nothing matches exits `2` and reports itself on stderr.
|
|
55
|
+
|
|
56
|
+
Every invocation is recorded, matched or not:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
await expect(seed.invocations("fixture-agent")).resolves.toEqual([["--version"]]);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Versioned official-app fixtures are also exported for adapter and binary integration tests:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { createClaudeCodeSeed, createCodexSeed, createCursorSeed } from "@tryaura/aura-testkit";
|
|
66
|
+
|
|
67
|
+
await using seed = await createClaudeCodeSeed({
|
|
68
|
+
authenticated: true,
|
|
69
|
+
version: "2.1.233",
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await using codexSeed = await createCodexSeed({
|
|
73
|
+
authenticated: true,
|
|
74
|
+
version: "0.147.0",
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
await using cursorSeed = await createCursorSeed({
|
|
78
|
+
rules: "legacy",
|
|
79
|
+
version: "3.11.0",
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Running a check
|
|
84
|
+
|
|
85
|
+
`runCheck` runs `check --json` and returns:
|
|
86
|
+
|
|
87
|
+
- `report` — the whole JSON document. Assert against this rather than `findings` alone when a test
|
|
88
|
+
needs to prove a check ran: a check that threw reports no findings and is explained only by
|
|
89
|
+
`report.diagnostics`.
|
|
90
|
+
- `findings` — shorthand for `report.findings`.
|
|
91
|
+
- `exitCode` — `0`, `1`, or `2`.
|
|
92
|
+
- `diffs` — every change under the fake HOME and workspace, as unified patches whose first line is
|
|
93
|
+
the entry's permission bits. Permission-only changes, empty directories, and binary files are all
|
|
94
|
+
visible. The seeded `PATH` directory is not diffed; use `seed.invocations` for what a shim did.
|
|
95
|
+
- `stdout` / `stderr` — captured, with seeded absolute paths replaced by `<HOME>`, `<WORKSPACE>`,
|
|
96
|
+
`<PATH>`, and `<SEED>`.
|
|
97
|
+
|
|
98
|
+
When a run produces no readable report, the failure carries the exit code and the CLI's own stderr,
|
|
99
|
+
which is where the actual explanation lives.
|
|
100
|
+
|
|
101
|
+
## Proving convergence
|
|
102
|
+
|
|
103
|
+
`expectConvergedTwice` runs a setup or fix callback twice and asserts that the second run reports
|
|
104
|
+
convergence, changes no captured path, and creates no undo-journal entry:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { expectConvergedTwice, runSetup } from "@tryaura/aura-testkit";
|
|
108
|
+
|
|
109
|
+
const { first, second } = await expectConvergedTwice(seed, () => runSetup({ distro, seed }));
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Paths under `agents/.backups/` are excluded from the diff comparisons and asserted separately by
|
|
113
|
+
journal entry name. Convergence is a claim about the machine's configuration, and the journal is
|
|
114
|
+
where a run records what it replaced — it also holds a target-lock directory a run touches whether
|
|
115
|
+
or not it writes anything, so comparing it byte for byte makes the assertion fail on timing.
|
|
116
|
+
|
|
117
|
+
The helper is test-runner independent and returns both results for additional assertions.
|
|
118
|
+
|
|
119
|
+
## Running a compiled distribution
|
|
120
|
+
|
|
121
|
+
`runBinaryCheck` applies the same seed and returns the same result shape while launching a compiled
|
|
122
|
+
Aura executable instead of calling `runCli` in process:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { runBinaryCheck } from "@tryaura/aura-testkit";
|
|
126
|
+
|
|
127
|
+
const result = await runBinaryCheck({
|
|
128
|
+
binaryPath: "/absolute/path/to/aura",
|
|
129
|
+
seed,
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The runner invokes `check --json` from the seeded workspace, supplies the seed's HOME and PATH, and
|
|
134
|
+
passes no ambient environment variables to the child. The binary path must be absolute, and `args`
|
|
135
|
+
may not repeat `--json`, `--home`, or `--path` — the runner supplies those and rejects a second one
|
|
136
|
+
rather than letting it parse as a duplicate.
|
|
137
|
+
|
|
138
|
+
Launch failures, signals, unsupported exit codes, and invalid reports reject with a captured
|
|
139
|
+
transcript. So does a run that hangs: `timeoutMs` (30 seconds by default) bounds how long the child
|
|
140
|
+
may take, after which it is killed and the failure carries whatever it had printed by then.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
const result = await runBinaryCheck({ binaryPath, seed, timeoutMs: 5_000 });
|
|
144
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { CheckReport, CheckReport as CheckReport$1, CliDistro, CliExitCode, ReportFinding } from "@tryaura/aura-cli";
|
|
2
|
+
import { Environment } from "@tryaura/aura-sdk";
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Matches any single argument in that position.
|
|
6
|
+
*
|
|
7
|
+
* Arity still has to match, so a response stays an exact description of one shape of invocation —
|
|
8
|
+
* this only frees the positions whose value a test cannot predict, such as a temporary path.
|
|
9
|
+
*/
|
|
10
|
+
declare const ANY_ARGUMENT: unique symbol;
|
|
11
|
+
/** One argument a shim matches on: an exact value, or {@link ANY_ARGUMENT}. */
|
|
12
|
+
type ShimArgument = string | typeof ANY_ARGUMENT;
|
|
13
|
+
/**
|
|
14
|
+
* One invocation a PATH shim knows how to answer.
|
|
15
|
+
*
|
|
16
|
+
* The first response whose arguments match wins, so order declarations from most to least specific
|
|
17
|
+
* when they overlap through {@link ANY_ARGUMENT}.
|
|
18
|
+
*/
|
|
19
|
+
interface ShimResponse {
|
|
20
|
+
readonly args: readonly ShimArgument[];
|
|
21
|
+
/** Defaults to zero. */
|
|
22
|
+
readonly exitCode?: number | undefined;
|
|
23
|
+
readonly stderr?: string | undefined;
|
|
24
|
+
readonly stdout?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
/** Materialized fake machine state owned by one test. */
|
|
27
|
+
interface TestSeed {
|
|
28
|
+
readonly homeDir: string;
|
|
29
|
+
readonly pathDir: string;
|
|
30
|
+
readonly workspaceDir: string;
|
|
31
|
+
/** Removes the whole temporary seed. Safe to call more than once. */
|
|
32
|
+
readonly cleanup: () => Promise<void>;
|
|
33
|
+
/** Disposes through `await using`, which is the leak-proof way to own a seed. */
|
|
34
|
+
readonly [Symbol.asyncDispose]: () => Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Every invocation of one seeded shim, in the order it happened.
|
|
37
|
+
*
|
|
38
|
+
* Records invocations no response matched too, which is what turns "the shim answered `exit 2`"
|
|
39
|
+
* into "the adapter asked for arguments no response declares". Empty for a command that was never
|
|
40
|
+
* run, or was never seeded.
|
|
41
|
+
*/
|
|
42
|
+
readonly invocations: (command: string) => Promise<readonly (readonly string[])[]>;
|
|
43
|
+
}
|
|
44
|
+
/** The directories a seed materialized, for file content that has to name one. */
|
|
45
|
+
interface SeedRoots {
|
|
46
|
+
readonly homeDir: string;
|
|
47
|
+
readonly workspaceDir: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* File content, or a function producing it from the directories the seed materialized.
|
|
51
|
+
*
|
|
52
|
+
* Those directories are temporary and only exist once `build` has run, so a fixture whose content
|
|
53
|
+
* has to contain one — a config keyed by workspace path, an absolute import — would otherwise have
|
|
54
|
+
* to write that file itself, outside the builder, and hand-roll the cleanup-on-failure and
|
|
55
|
+
* duplicate-path checks `build` already does.
|
|
56
|
+
*/
|
|
57
|
+
type SeedContent = string | ((roots: SeedRoots) => string);
|
|
58
|
+
/** Fluent description of files and executables to materialize for a test. */
|
|
59
|
+
interface TestSeedBuilder {
|
|
60
|
+
homeFile(path: string, content: SeedContent): TestSeedBuilder;
|
|
61
|
+
shim(command: string, responses: readonly ShimResponse[]): TestSeedBuilder;
|
|
62
|
+
workspaceFile(path: string, content: SeedContent): TestSeedBuilder;
|
|
63
|
+
build(): Promise<TestSeed>;
|
|
64
|
+
}
|
|
65
|
+
interface RunCheckOptions {
|
|
66
|
+
/** Check-command flags other than `--json`, which the runner always supplies. */
|
|
67
|
+
readonly args?: readonly string[] | undefined;
|
|
68
|
+
readonly distro: CliDistro;
|
|
69
|
+
readonly seed: TestSeed;
|
|
70
|
+
}
|
|
71
|
+
/** Options for running a compiled Aura distribution against a deterministic seed. */
|
|
72
|
+
interface RunBinaryCheckOptions {
|
|
73
|
+
/** Check-command flags other than `--json`, `--home`, and `--path`, which the runner rejects. */
|
|
74
|
+
readonly args?: readonly string[] | undefined;
|
|
75
|
+
/** Absolute path to the compiled distribution executable. */
|
|
76
|
+
readonly binaryPath: string;
|
|
77
|
+
readonly seed: TestSeed;
|
|
78
|
+
/**
|
|
79
|
+
* How long the compiled run may take before it is killed. Defaults to 30 seconds.
|
|
80
|
+
*
|
|
81
|
+
* A run that outlives this fails with the output it had produced by then, which is the only thing
|
|
82
|
+
* that distinguishes a binary that hung from a test runner that gave up on it.
|
|
83
|
+
*/
|
|
84
|
+
readonly timeoutMs?: number | undefined;
|
|
85
|
+
}
|
|
86
|
+
type TestFileDiffStatus = "added" | "modified" | "removed";
|
|
87
|
+
/**
|
|
88
|
+
* One stable, snapshot-ready change under the fake HOME or workspace.
|
|
89
|
+
*
|
|
90
|
+
* The seeded PATH directory is deliberately not diffed: its shims would be permanent noise in every
|
|
91
|
+
* snapshot. Use {@link TestSeed.invocations} to assert on what a shim did instead.
|
|
92
|
+
*/
|
|
93
|
+
interface TestFileDiff {
|
|
94
|
+
/**
|
|
95
|
+
* Unified diff of the entry, whose first line is always its permission bits.
|
|
96
|
+
*
|
|
97
|
+
* Carrying the mode inside the patch is what makes a permission-only fix visible: without it a
|
|
98
|
+
* `chmod` that changes nothing else would diff as no change at all.
|
|
99
|
+
*/
|
|
100
|
+
readonly patch: string;
|
|
101
|
+
readonly path: string;
|
|
102
|
+
readonly status: TestFileDiffStatus;
|
|
103
|
+
}
|
|
104
|
+
/** Captured result of running the distribution's check command in process. */
|
|
105
|
+
interface TestRunResult {
|
|
106
|
+
readonly diffs: readonly TestFileDiff[];
|
|
107
|
+
readonly exitCode: CliExitCode;
|
|
108
|
+
/** Shorthand for `report.findings`. */
|
|
109
|
+
readonly findings: readonly ReportFinding[];
|
|
110
|
+
/**
|
|
111
|
+
* The whole `check --json` document.
|
|
112
|
+
*
|
|
113
|
+
* Assert against this rather than {@link TestRunResult.findings} alone when a test needs to prove
|
|
114
|
+
* a check actually ran: a check that threw reports no findings and is explained only by
|
|
115
|
+
* `report.diagnostics`.
|
|
116
|
+
*/
|
|
117
|
+
readonly report: CheckReport$1;
|
|
118
|
+
readonly stderr: string;
|
|
119
|
+
readonly stdout: string;
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/binary-runner.d.ts
|
|
123
|
+
/** Runs a compiled Aura distribution's `check --json` command against one deterministic seed. */
|
|
124
|
+
declare function runBinaryCheck(options: RunBinaryCheckOptions): Promise<TestRunResult>;
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/runner.d.ts
|
|
127
|
+
/** Runs `check --json` without reading process state and returns snapshot-ready output. */
|
|
128
|
+
declare function runCheck(options: RunCheckOptions): Promise<TestRunResult>;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/setup-runner.d.ts
|
|
131
|
+
interface RunSetupOptions {
|
|
132
|
+
/** Setup-command flags other than `--yes`, which the runner always supplies. */
|
|
133
|
+
readonly args?: readonly string[] | undefined;
|
|
134
|
+
readonly distro: CliDistro;
|
|
135
|
+
/** Extra variables visible to the run, such as a skill-directory token. `PATH` stays seeded. */
|
|
136
|
+
readonly environmentVariables?: Readonly<Record<string, string>> | undefined;
|
|
137
|
+
readonly seed: TestSeed;
|
|
138
|
+
}
|
|
139
|
+
/** What one headless `setup --yes` run printed and changed. */
|
|
140
|
+
interface SetupRunResult {
|
|
141
|
+
readonly diffs: readonly TestFileDiff[];
|
|
142
|
+
readonly exitCode: number;
|
|
143
|
+
readonly stderr: string;
|
|
144
|
+
readonly stdout: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Runs `setup --yes` in-process against a seed and returns snapshot-ready output.
|
|
148
|
+
*
|
|
149
|
+
* `--yes` because this boundary has no terminal: every question resolves to the default the wizard
|
|
150
|
+
* would have proposed, which is exactly what the acceptance tests need to prove about converge and
|
|
151
|
+
* end-on-green behaviour. Interactive keypress flows are covered by the CLI's own engine tests.
|
|
152
|
+
*/
|
|
153
|
+
declare function runSetup(options: RunSetupOptions): Promise<SetupRunResult>;
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/convergence.d.ts
|
|
156
|
+
/** The common result surface returned by the testkit's setup and check runners. */
|
|
157
|
+
interface ConvergenceRunResult {
|
|
158
|
+
readonly diffs: readonly TestFileDiff[];
|
|
159
|
+
readonly exitCode: number;
|
|
160
|
+
readonly stderr: string;
|
|
161
|
+
readonly stdout: string;
|
|
162
|
+
}
|
|
163
|
+
interface ConvergedTwiceResult<Result extends ConvergenceRunResult> {
|
|
164
|
+
readonly first: Result;
|
|
165
|
+
readonly second: Result;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Runs one converge boundary twice and proves the second pass had no work to plan or journal.
|
|
169
|
+
*
|
|
170
|
+
* Throws framework-independent errors so distributions can use this helper from any test runner.
|
|
171
|
+
*/
|
|
172
|
+
declare function expectConvergedTwice<Result extends ConvergenceRunResult>(seed: TestSeed, run: () => Promise<Result>): Promise<ConvergedTwiceResult<Result>>;
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/filesystem.d.ts
|
|
175
|
+
interface DirectoryEntry {
|
|
176
|
+
readonly kind: "directory";
|
|
177
|
+
readonly mode: number;
|
|
178
|
+
}
|
|
179
|
+
interface FileEntry {
|
|
180
|
+
readonly kind: "file";
|
|
181
|
+
readonly mode: number;
|
|
182
|
+
readonly text: string;
|
|
183
|
+
}
|
|
184
|
+
/** A file whose bytes are not UTF-8 text, recorded by shape so a change is still visible. */
|
|
185
|
+
interface BinaryEntry {
|
|
186
|
+
readonly byteLength: number;
|
|
187
|
+
readonly digest: string;
|
|
188
|
+
readonly kind: "binary";
|
|
189
|
+
readonly mode: number;
|
|
190
|
+
}
|
|
191
|
+
interface SymlinkEntry {
|
|
192
|
+
readonly kind: "symlink";
|
|
193
|
+
readonly target: string;
|
|
194
|
+
}
|
|
195
|
+
type TreeEntry = BinaryEntry | DirectoryEntry | FileEntry | SymlinkEntry;
|
|
196
|
+
type FilesystemSnapshot = ReadonlyMap<string, TreeEntry>;
|
|
197
|
+
declare function captureFilesystem(seed: TestSeed): Promise<FilesystemSnapshot>;
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/seed.d.ts
|
|
200
|
+
/** Starts a fluent description of one isolated fake machine. */
|
|
201
|
+
declare function createSeedBuilder(): TestSeedBuilder;
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/http.d.ts
|
|
204
|
+
/**
|
|
205
|
+
* The network policy every testkit runner injects: loopback servers only.
|
|
206
|
+
*
|
|
207
|
+
* A test run is hermetic by construction — a distribution that registers a real skill directory
|
|
208
|
+
* must not make its integration tests reach that host. Mock servers listen on `127.0.0.1`, which
|
|
209
|
+
* this passes straight through to the kernel's own client, caps and all.
|
|
210
|
+
*/
|
|
211
|
+
declare const loopbackOnlyHttpGet: Environment["httpGet"];
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/mock-directory.d.ts
|
|
214
|
+
/** One listing a mock directory advertises in its `index.json`. */
|
|
215
|
+
interface MockDirectoryListing {
|
|
216
|
+
readonly description: string;
|
|
217
|
+
readonly id: string;
|
|
218
|
+
readonly name: string;
|
|
219
|
+
readonly version: string;
|
|
220
|
+
}
|
|
221
|
+
/** One file of a mock skill's content response. */
|
|
222
|
+
interface MockDirectoryFile {
|
|
223
|
+
readonly content: string;
|
|
224
|
+
readonly path: string;
|
|
225
|
+
}
|
|
226
|
+
/** One request the mock directory served, for asserting what a run sent — and did not send. */
|
|
227
|
+
interface MockDirectoryRequest {
|
|
228
|
+
readonly authorization: string | undefined;
|
|
229
|
+
readonly method: string;
|
|
230
|
+
readonly path: string;
|
|
231
|
+
}
|
|
232
|
+
/** A running mock skill directory. Dispose it, or `close` it, when the test is done. */
|
|
233
|
+
interface MockDirectory extends AsyncDisposable {
|
|
234
|
+
readonly close: () => Promise<void>;
|
|
235
|
+
readonly requests: readonly MockDirectoryRequest[];
|
|
236
|
+
/** Loopback base URL, ready to be used as a skill directory `url`. */
|
|
237
|
+
readonly url: string;
|
|
238
|
+
}
|
|
239
|
+
interface MockDirectoryBuilder {
|
|
240
|
+
/** Serves the listing plus a content response of exactly these files. */
|
|
241
|
+
readonly skill: (listing: MockDirectoryListing, files: readonly MockDirectoryFile[]) => MockDirectoryBuilder;
|
|
242
|
+
/** Appends a raw entry to a skill's `files` array — hostile paths, symlinks, junk. */
|
|
243
|
+
readonly rawFileEntry: (skillId: string, entry: unknown) => MockDirectoryBuilder;
|
|
244
|
+
/** Replaces a skill's content response with an oversized opaque payload. */
|
|
245
|
+
readonly payloadBytes: (skillId: string, bytes: number) => MockDirectoryBuilder;
|
|
246
|
+
/** Requires `Authorization: Bearer <token>` on every request; anything else gets 401. */
|
|
247
|
+
readonly requireToken: (token: string) => MockDirectoryBuilder;
|
|
248
|
+
readonly build: () => Promise<MockDirectory>;
|
|
249
|
+
}
|
|
250
|
+
/** A local `node:http` skill directory speaking the standard protocol, one call per scenario. */
|
|
251
|
+
declare function createMockDirectoryBuilder(): MockDirectoryBuilder;
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/fixtures/claude-code.d.ts
|
|
254
|
+
/** One version inside the adapter's supported range and one past its ceiling. */
|
|
255
|
+
type ClaudeCodeFixtureVersion = "2.1.233" | "3.0.0";
|
|
256
|
+
interface ClaudeCodeSeedOptions {
|
|
257
|
+
readonly authenticated: boolean;
|
|
258
|
+
/** Whether the fixture includes literals used by credential-redaction tests. Defaults to true. */
|
|
259
|
+
readonly inlineSecrets?: boolean | undefined;
|
|
260
|
+
readonly version: ClaudeCodeFixtureVersion;
|
|
261
|
+
}
|
|
262
|
+
/** The `claude` executable's answers, for composing multi-app seeds on one builder. */
|
|
263
|
+
declare function claudeCodeShimResponses(options: ClaudeCodeSeedOptions): readonly ShimResponse[];
|
|
264
|
+
/** Builds documented Claude Code global and project configuration against an exact CLI version. */
|
|
265
|
+
declare function createClaudeCodeSeed(options: ClaudeCodeSeedOptions): Promise<TestSeed>;
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/fixtures/codex.d.ts
|
|
268
|
+
/** Verified versions plus the first version outside the adapter's supported range. */
|
|
269
|
+
type CodexFixtureVersion = "0.146.0" | "0.147.0" | "0.148.0";
|
|
270
|
+
/**
|
|
271
|
+
* Which project instruction files the workspace ships.
|
|
272
|
+
*
|
|
273
|
+
* `"root"` seeds the repository-root `AGENTS.md` alone. `"nested"` adds a Git marker and a second
|
|
274
|
+
* `AGENTS.md` inside {@link CODEX_NESTED_PACKAGE}, so a scan invoked from that package walks the
|
|
275
|
+
* same two levels Codex does. `"override"` adds the root `AGENTS.override.md` that Codex prefers
|
|
276
|
+
* over the `AGENTS.md` beside it.
|
|
277
|
+
*/
|
|
278
|
+
type CodexProjectInstructions = "nested" | "override" | "root";
|
|
279
|
+
/** Workspace-relative directory the `"nested"` layout puts its second `AGENTS.md` in. */
|
|
280
|
+
declare const CODEX_NESTED_PACKAGE = "packages/app";
|
|
281
|
+
interface CodexSeedOptions {
|
|
282
|
+
readonly authenticated: boolean;
|
|
283
|
+
/** Project instruction layout. Omitted means the workspace ships none. */
|
|
284
|
+
readonly projectInstructions?: CodexProjectInstructions | undefined;
|
|
285
|
+
/** Record the workspace under `[projects]` in `config.toml`; omitted means no entry at all. */
|
|
286
|
+
readonly projectTrust?: "trusted" | "untrusted" | undefined;
|
|
287
|
+
readonly version: CodexFixtureVersion;
|
|
288
|
+
}
|
|
289
|
+
/** The `codex` executable's answers, for composing multi-app seeds on one builder. */
|
|
290
|
+
declare function codexShimResponses(options: Pick<CodexSeedOptions, "authenticated" | "version">): readonly ShimResponse[];
|
|
291
|
+
/** Builds one documented Codex configuration against an exact CLI version. */
|
|
292
|
+
declare function createCodexSeed(options: CodexSeedOptions): Promise<TestSeed>;
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region src/fixtures/cursor.d.ts
|
|
295
|
+
type CursorFixtureVersion = "3.11.0" | "4.0.0";
|
|
296
|
+
type CursorRulesFixture = "current" | "legacy";
|
|
297
|
+
interface CursorSeedOptions {
|
|
298
|
+
readonly rules: CursorRulesFixture;
|
|
299
|
+
readonly version: CursorFixtureVersion;
|
|
300
|
+
}
|
|
301
|
+
/** The `cursor` executable's answers, for composing multi-app seeds on one builder. */
|
|
302
|
+
declare function cursorShimResponses(options: Pick<CursorSeedOptions, "version">): readonly ShimResponse[];
|
|
303
|
+
/** Builds documented Cursor rule and MCP configuration against an exact editor version. */
|
|
304
|
+
declare function createCursorSeed(options: CursorSeedOptions): Promise<TestSeed>;
|
|
305
|
+
//#endregion
|
|
306
|
+
export { ANY_ARGUMENT, CODEX_NESTED_PACKAGE, type CheckReport, type ClaudeCodeFixtureVersion, type ClaudeCodeSeedOptions, type CodexFixtureVersion, type CodexProjectInstructions, type CodexSeedOptions, type ConvergedTwiceResult, type ConvergenceRunResult, type CursorFixtureVersion, type CursorRulesFixture, type CursorSeedOptions, type FilesystemSnapshot, type MockDirectory, type MockDirectoryBuilder, type MockDirectoryFile, type MockDirectoryListing, type MockDirectoryRequest, type RunBinaryCheckOptions, type RunCheckOptions, type RunSetupOptions, type SetupRunResult, type ShimArgument, type ShimResponse, type TestFileDiff, type TestFileDiffStatus, type TestRunResult, type TestSeed, type TestSeedBuilder, captureFilesystem, claudeCodeShimResponses, codexShimResponses, createClaudeCodeSeed, createCodexSeed, createCursorSeed, createMockDirectoryBuilder, createSeedBuilder, cursorShimResponses, expectConvergedTwice, loopbackOnlyHttpGet, runBinaryCheck, runCheck, runSetup };
|