reflection-check 0.0.1
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 +21 -0
- package/README.md +55 -0
- package/dist/adapters/route-manifest.d.ts +3 -0
- package/dist/adapters/route-manifest.js +98 -0
- package/dist/adapters/route-manifest.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +93 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/doctor.d.ts +4 -0
- package/dist/commands/doctor.js +5 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/gc.d.ts +8 -0
- package/dist/commands/gc.js +45 -0
- package/dist/commands/gc.js.map +1 -0
- package/dist/commands/review.d.ts +7 -0
- package/dist/commands/review.js +149 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/run.d.ts +10 -0
- package/dist/commands/run.js +168 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/update.d.ts +11 -0
- package/dist/commands/update.js +183 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/contracts/browser/assertions.d.ts +34 -0
- package/dist/contracts/browser/assertions.js +87 -0
- package/dist/contracts/browser/assertions.js.map +1 -0
- package/dist/contracts/browser/browser-contract.d.ts +13 -0
- package/dist/contracts/browser/browser-contract.js +35 -0
- package/dist/contracts/browser/browser-contract.js.map +1 -0
- package/dist/contracts/browser/console-observer.d.ts +6 -0
- package/dist/contracts/browser/console-observer.js +14 -0
- package/dist/contracts/browser/console-observer.js.map +1 -0
- package/dist/contracts/browser/overflow-check.d.ts +6 -0
- package/dist/contracts/browser/overflow-check.js +15 -0
- package/dist/contracts/browser/overflow-check.js.map +1 -0
- package/dist/contracts/browser/route-runner.d.ts +21 -0
- package/dist/contracts/browser/route-runner.js +98 -0
- package/dist/contracts/browser/route-runner.js.map +1 -0
- package/dist/contracts/component/component-visual-contract.d.ts +30 -0
- package/dist/contracts/component/component-visual-contract.js +147 -0
- package/dist/contracts/component/component-visual-contract.js.map +1 -0
- package/dist/contracts/design/command-adapter.d.ts +17 -0
- package/dist/contracts/design/command-adapter.js +60 -0
- package/dist/contracts/design/command-adapter.js.map +1 -0
- package/dist/contracts/design/design-contract.d.ts +8 -0
- package/dist/contracts/design/design-contract.js +149 -0
- package/dist/contracts/design/design-contract.js.map +1 -0
- package/dist/contracts/visual/baseline-compare.d.ts +19 -0
- package/dist/contracts/visual/baseline-compare.js +94 -0
- package/dist/contracts/visual/baseline-compare.js.map +1 -0
- package/dist/contracts/visual/image-diff.d.ts +27 -0
- package/dist/contracts/visual/image-diff.js +58 -0
- package/dist/contracts/visual/image-diff.js.map +1 -0
- package/dist/contracts/visual/thresholds.d.ts +15 -0
- package/dist/contracts/visual/thresholds.js +11 -0
- package/dist/contracts/visual/thresholds.js.map +1 -0
- package/dist/contracts/visual/visual-contract.d.ts +11 -0
- package/dist/contracts/visual/visual-contract.js +32 -0
- package/dist/contracts/visual/visual-contract.js.map +1 -0
- package/dist/core/artifact-store.d.ts +18 -0
- package/dist/core/artifact-store.js +105 -0
- package/dist/core/artifact-store.js.map +1 -0
- package/dist/core/baseline-store.d.ts +18 -0
- package/dist/core/baseline-store.js +56 -0
- package/dist/core/baseline-store.js.map +1 -0
- package/dist/core/config.d.ts +129 -0
- package/dist/core/config.js +159 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/define-reflection.d.ts +2 -0
- package/dist/core/define-reflection.js +4 -0
- package/dist/core/define-reflection.js.map +1 -0
- package/dist/core/exit-codes.d.ts +7 -0
- package/dist/core/exit-codes.js +9 -0
- package/dist/core/exit-codes.js.map +1 -0
- package/dist/core/failure-classifier.d.ts +3 -0
- package/dist/core/failure-classifier.js +19 -0
- package/dist/core/failure-classifier.js.map +1 -0
- package/dist/core/gc.d.ts +19 -0
- package/dist/core/gc.js +161 -0
- package/dist/core/gc.js.map +1 -0
- package/dist/core/manifest.d.ts +23 -0
- package/dist/core/manifest.js +21 -0
- package/dist/core/manifest.js.map +1 -0
- package/dist/core/redaction.d.ts +3 -0
- package/dist/core/redaction.js +63 -0
- package/dist/core/redaction.js.map +1 -0
- package/dist/core/report-schema.d.ts +262 -0
- package/dist/core/report-schema.js +112 -0
- package/dist/core/report-schema.js.map +1 -0
- package/dist/core/report-writer.d.ts +4 -0
- package/dist/core/report-writer.js +77 -0
- package/dist/core/report-writer.js.map +1 -0
- package/dist/core/server-manager.d.ts +23 -0
- package/dist/core/server-manager.js +64 -0
- package/dist/core/server-manager.js.map +1 -0
- package/dist/core/target-ir.d.ts +64 -0
- package/dist/core/target-ir.js +85 -0
- package/dist/core/target-ir.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/playwright/browser-manager.d.ts +2 -0
- package/dist/integrations/playwright/browser-manager.js +5 -0
- package/dist/integrations/playwright/browser-manager.js.map +1 -0
- package/dist/integrations/playwright/context-factory.d.ts +7 -0
- package/dist/integrations/playwright/context-factory.js +19 -0
- package/dist/integrations/playwright/context-factory.js.map +1 -0
- package/dist/integrations/playwright/trace-policy.d.ts +5 -0
- package/dist/integrations/playwright/trace-policy.js +7 -0
- package/dist/integrations/playwright/trace-policy.js.map +1 -0
- package/dist/integrations/storybook/index-json.d.ts +21 -0
- package/dist/integrations/storybook/index-json.js +44 -0
- package/dist/integrations/storybook/index-json.js.map +1 -0
- package/dist/integrations/storybook/server.d.ts +8 -0
- package/dist/integrations/storybook/server.js +23 -0
- package/dist/integrations/storybook/server.js.map +1 -0
- package/dist/integrations/storybook/story-url.d.ts +2 -0
- package/dist/integrations/storybook/story-url.js +13 -0
- package/dist/integrations/storybook/story-url.js.map +1 -0
- package/dist/utils/process.d.ts +9 -0
- package/dist/utils/process.js +69 -0
- package/dist/utils/process.js.map +1 -0
- package/docs/agent-workflows.md +146 -0
- package/docs/artifacts-and-gc.md +125 -0
- package/docs/browser-contract.md +98 -0
- package/docs/ci.md +44 -0
- package/docs/configuration.md +210 -0
- package/docs/getting-started.md +166 -0
- package/docs/plans/reflection-implementation-plan.md +898 -0
- package/docs/target-ir-and-adapters.md +111 -0
- package/docs/validation-process.md +172 -0
- package/docs/visual-contract.md +174 -0
- package/package.json +62 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ExitCode } from './exit-codes.js';
|
|
3
|
+
import type { RunMode } from './config.js';
|
|
4
|
+
export declare const CheckStatusSchema: z.ZodEnum<{
|
|
5
|
+
error: "error";
|
|
6
|
+
pass: "pass";
|
|
7
|
+
fail: "fail";
|
|
8
|
+
warn: "warn";
|
|
9
|
+
skipped: "skipped";
|
|
10
|
+
}>;
|
|
11
|
+
export declare const CheckSeveritySchema: z.ZodEnum<{
|
|
12
|
+
blocking: "blocking";
|
|
13
|
+
review: "review";
|
|
14
|
+
info: "info";
|
|
15
|
+
}>;
|
|
16
|
+
export declare const CheckSuiteSchema: z.ZodEnum<{
|
|
17
|
+
design: "design";
|
|
18
|
+
visual: "visual";
|
|
19
|
+
component: "component";
|
|
20
|
+
browser: "browser";
|
|
21
|
+
environment: "environment";
|
|
22
|
+
}>;
|
|
23
|
+
export declare const ReportStatusSchema: z.ZodEnum<{
|
|
24
|
+
error: "error";
|
|
25
|
+
pass: "pass";
|
|
26
|
+
fail: "fail";
|
|
27
|
+
"pass-with-review": "pass-with-review";
|
|
28
|
+
}>;
|
|
29
|
+
export declare const ArtifactTypeSchema: z.ZodEnum<{
|
|
30
|
+
report: "report";
|
|
31
|
+
screenshot: "screenshot";
|
|
32
|
+
image: "image";
|
|
33
|
+
"visual-diff": "visual-diff";
|
|
34
|
+
trace: "trace";
|
|
35
|
+
video: "video";
|
|
36
|
+
log: "log";
|
|
37
|
+
metadata: "metadata";
|
|
38
|
+
}>;
|
|
39
|
+
export declare const ArtifactRoleSchema: z.ZodEnum<{
|
|
40
|
+
trace: "trace";
|
|
41
|
+
expected: "expected";
|
|
42
|
+
evidence: "evidence";
|
|
43
|
+
actual: "actual";
|
|
44
|
+
diff: "diff";
|
|
45
|
+
debug: "debug";
|
|
46
|
+
}>;
|
|
47
|
+
export declare const ArtifactRefSchema: z.ZodObject<{
|
|
48
|
+
type: z.ZodEnum<{
|
|
49
|
+
report: "report";
|
|
50
|
+
screenshot: "screenshot";
|
|
51
|
+
image: "image";
|
|
52
|
+
"visual-diff": "visual-diff";
|
|
53
|
+
trace: "trace";
|
|
54
|
+
video: "video";
|
|
55
|
+
log: "log";
|
|
56
|
+
metadata: "metadata";
|
|
57
|
+
}>;
|
|
58
|
+
role: z.ZodOptional<z.ZodEnum<{
|
|
59
|
+
trace: "trace";
|
|
60
|
+
expected: "expected";
|
|
61
|
+
evidence: "evidence";
|
|
62
|
+
actual: "actual";
|
|
63
|
+
diff: "diff";
|
|
64
|
+
debug: "debug";
|
|
65
|
+
}>>;
|
|
66
|
+
path: z.ZodString;
|
|
67
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export declare const CheckResultSchema: z.ZodObject<{
|
|
71
|
+
id: z.ZodString;
|
|
72
|
+
suite: z.ZodEnum<{
|
|
73
|
+
design: "design";
|
|
74
|
+
visual: "visual";
|
|
75
|
+
component: "component";
|
|
76
|
+
browser: "browser";
|
|
77
|
+
environment: "environment";
|
|
78
|
+
}>;
|
|
79
|
+
target: z.ZodString;
|
|
80
|
+
status: z.ZodEnum<{
|
|
81
|
+
error: "error";
|
|
82
|
+
pass: "pass";
|
|
83
|
+
fail: "fail";
|
|
84
|
+
warn: "warn";
|
|
85
|
+
skipped: "skipped";
|
|
86
|
+
}>;
|
|
87
|
+
severity: z.ZodEnum<{
|
|
88
|
+
blocking: "blocking";
|
|
89
|
+
review: "review";
|
|
90
|
+
info: "info";
|
|
91
|
+
}>;
|
|
92
|
+
summary: z.ZodString;
|
|
93
|
+
details: z.ZodOptional<z.ZodString>;
|
|
94
|
+
artifacts: z.ZodArray<z.ZodObject<{
|
|
95
|
+
type: z.ZodEnum<{
|
|
96
|
+
report: "report";
|
|
97
|
+
screenshot: "screenshot";
|
|
98
|
+
image: "image";
|
|
99
|
+
"visual-diff": "visual-diff";
|
|
100
|
+
trace: "trace";
|
|
101
|
+
video: "video";
|
|
102
|
+
log: "log";
|
|
103
|
+
metadata: "metadata";
|
|
104
|
+
}>;
|
|
105
|
+
role: z.ZodOptional<z.ZodEnum<{
|
|
106
|
+
trace: "trace";
|
|
107
|
+
expected: "expected";
|
|
108
|
+
evidence: "evidence";
|
|
109
|
+
actual: "actual";
|
|
110
|
+
diff: "diff";
|
|
111
|
+
debug: "debug";
|
|
112
|
+
}>>;
|
|
113
|
+
path: z.ZodString;
|
|
114
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, z.core.$strip>>;
|
|
117
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
118
|
+
suggestedNextStep: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
export declare const SuggestedNextStepSchema: z.ZodObject<{
|
|
121
|
+
kind: z.ZodString;
|
|
122
|
+
summary: z.ZodString;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
export declare const ReportSummarySchema: z.ZodObject<{
|
|
125
|
+
passed: z.ZodNumber;
|
|
126
|
+
failed: z.ZodNumber;
|
|
127
|
+
warnings: z.ZodNumber;
|
|
128
|
+
skipped: z.ZodNumber;
|
|
129
|
+
blockingFailures: z.ZodNumber;
|
|
130
|
+
reviewItems: z.ZodNumber;
|
|
131
|
+
}, z.core.$strip>;
|
|
132
|
+
export declare const ReflectionReportSchema: z.ZodObject<{
|
|
133
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
134
|
+
runId: z.ZodString;
|
|
135
|
+
project: z.ZodString;
|
|
136
|
+
startedAt: z.ZodString;
|
|
137
|
+
finishedAt: z.ZodString;
|
|
138
|
+
status: z.ZodEnum<{
|
|
139
|
+
error: "error";
|
|
140
|
+
pass: "pass";
|
|
141
|
+
fail: "fail";
|
|
142
|
+
"pass-with-review": "pass-with-review";
|
|
143
|
+
}>;
|
|
144
|
+
mode: z.ZodEnum<{
|
|
145
|
+
smoke: "smoke";
|
|
146
|
+
design: "design";
|
|
147
|
+
visual: "visual";
|
|
148
|
+
full: "full";
|
|
149
|
+
}>;
|
|
150
|
+
ci: z.ZodBoolean;
|
|
151
|
+
environment: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
152
|
+
summary: z.ZodObject<{
|
|
153
|
+
passed: z.ZodNumber;
|
|
154
|
+
failed: z.ZodNumber;
|
|
155
|
+
warnings: z.ZodNumber;
|
|
156
|
+
skipped: z.ZodNumber;
|
|
157
|
+
blockingFailures: z.ZodNumber;
|
|
158
|
+
reviewItems: z.ZodNumber;
|
|
159
|
+
}, z.core.$strip>;
|
|
160
|
+
checks: z.ZodArray<z.ZodObject<{
|
|
161
|
+
id: z.ZodString;
|
|
162
|
+
suite: z.ZodEnum<{
|
|
163
|
+
design: "design";
|
|
164
|
+
visual: "visual";
|
|
165
|
+
component: "component";
|
|
166
|
+
browser: "browser";
|
|
167
|
+
environment: "environment";
|
|
168
|
+
}>;
|
|
169
|
+
target: z.ZodString;
|
|
170
|
+
status: z.ZodEnum<{
|
|
171
|
+
error: "error";
|
|
172
|
+
pass: "pass";
|
|
173
|
+
fail: "fail";
|
|
174
|
+
warn: "warn";
|
|
175
|
+
skipped: "skipped";
|
|
176
|
+
}>;
|
|
177
|
+
severity: z.ZodEnum<{
|
|
178
|
+
blocking: "blocking";
|
|
179
|
+
review: "review";
|
|
180
|
+
info: "info";
|
|
181
|
+
}>;
|
|
182
|
+
summary: z.ZodString;
|
|
183
|
+
details: z.ZodOptional<z.ZodString>;
|
|
184
|
+
artifacts: z.ZodArray<z.ZodObject<{
|
|
185
|
+
type: z.ZodEnum<{
|
|
186
|
+
report: "report";
|
|
187
|
+
screenshot: "screenshot";
|
|
188
|
+
image: "image";
|
|
189
|
+
"visual-diff": "visual-diff";
|
|
190
|
+
trace: "trace";
|
|
191
|
+
video: "video";
|
|
192
|
+
log: "log";
|
|
193
|
+
metadata: "metadata";
|
|
194
|
+
}>;
|
|
195
|
+
role: z.ZodOptional<z.ZodEnum<{
|
|
196
|
+
trace: "trace";
|
|
197
|
+
expected: "expected";
|
|
198
|
+
evidence: "evidence";
|
|
199
|
+
actual: "actual";
|
|
200
|
+
diff: "diff";
|
|
201
|
+
debug: "debug";
|
|
202
|
+
}>>;
|
|
203
|
+
path: z.ZodString;
|
|
204
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
205
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
206
|
+
}, z.core.$strip>>;
|
|
207
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
208
|
+
suggestedNextStep: z.ZodOptional<z.ZodString>;
|
|
209
|
+
}, z.core.$strip>>;
|
|
210
|
+
artifacts: z.ZodArray<z.ZodObject<{
|
|
211
|
+
type: z.ZodEnum<{
|
|
212
|
+
report: "report";
|
|
213
|
+
screenshot: "screenshot";
|
|
214
|
+
image: "image";
|
|
215
|
+
"visual-diff": "visual-diff";
|
|
216
|
+
trace: "trace";
|
|
217
|
+
video: "video";
|
|
218
|
+
log: "log";
|
|
219
|
+
metadata: "metadata";
|
|
220
|
+
}>;
|
|
221
|
+
role: z.ZodOptional<z.ZodEnum<{
|
|
222
|
+
trace: "trace";
|
|
223
|
+
expected: "expected";
|
|
224
|
+
evidence: "evidence";
|
|
225
|
+
actual: "actual";
|
|
226
|
+
diff: "diff";
|
|
227
|
+
debug: "debug";
|
|
228
|
+
}>>;
|
|
229
|
+
path: z.ZodString;
|
|
230
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
231
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
232
|
+
}, z.core.$strip>>;
|
|
233
|
+
suggestedNextSteps: z.ZodArray<z.ZodObject<{
|
|
234
|
+
kind: z.ZodString;
|
|
235
|
+
summary: z.ZodString;
|
|
236
|
+
}, z.core.$strip>>;
|
|
237
|
+
}, z.core.$strip>;
|
|
238
|
+
export type CheckStatus = z.output<typeof CheckStatusSchema>;
|
|
239
|
+
export type CheckSeverity = z.output<typeof CheckSeveritySchema>;
|
|
240
|
+
export type CheckSuite = z.output<typeof CheckSuiteSchema>;
|
|
241
|
+
export type ReportStatus = z.output<typeof ReportStatusSchema>;
|
|
242
|
+
export type ArtifactRef = z.output<typeof ArtifactRefSchema>;
|
|
243
|
+
export type CheckResult = z.output<typeof CheckResultSchema>;
|
|
244
|
+
export type ReflectionReport = z.output<typeof ReflectionReportSchema>;
|
|
245
|
+
export type ReportSummary = z.output<typeof ReportSummarySchema>;
|
|
246
|
+
export type SuggestedNextStep = z.output<typeof SuggestedNextStepSchema>;
|
|
247
|
+
export declare function summarizeChecks(checks: CheckResult[]): ReportSummary;
|
|
248
|
+
export declare function deriveReportStatus(checks: CheckResult[]): ReportStatus;
|
|
249
|
+
export declare function deriveExitCode(status: ReportStatus): ExitCode;
|
|
250
|
+
export declare function validateReport(report: unknown): ReflectionReport;
|
|
251
|
+
export declare function createReport(input: {
|
|
252
|
+
runId: string;
|
|
253
|
+
project: string;
|
|
254
|
+
startedAt: Date;
|
|
255
|
+
finishedAt: Date;
|
|
256
|
+
mode: RunMode;
|
|
257
|
+
ci: boolean;
|
|
258
|
+
environment?: Record<string, unknown>;
|
|
259
|
+
checks: CheckResult[];
|
|
260
|
+
artifacts?: ArtifactRef[];
|
|
261
|
+
suggestedNextSteps?: SuggestedNextStep[];
|
|
262
|
+
}): ReflectionReport;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ExitCode } from './exit-codes.js';
|
|
3
|
+
export const CheckStatusSchema = z.enum(['pass', 'fail', 'warn', 'skipped', 'error']);
|
|
4
|
+
export const CheckSeveritySchema = z.enum(['blocking', 'review', 'info']);
|
|
5
|
+
export const CheckSuiteSchema = z.enum(['design', 'browser', 'visual', 'component', 'environment']);
|
|
6
|
+
export const ReportStatusSchema = z.enum(['pass', 'fail', 'pass-with-review', 'error']);
|
|
7
|
+
export const ArtifactTypeSchema = z.enum(['report', 'screenshot', 'image', 'visual-diff', 'trace', 'video', 'log', 'metadata']);
|
|
8
|
+
export const ArtifactRoleSchema = z.enum(['evidence', 'expected', 'actual', 'diff', 'trace', 'debug']);
|
|
9
|
+
export const ArtifactRefSchema = z.object({
|
|
10
|
+
type: ArtifactTypeSchema,
|
|
11
|
+
role: ArtifactRoleSchema.optional(),
|
|
12
|
+
path: z.string().min(1),
|
|
13
|
+
bytes: z.number().int().nonnegative().optional(),
|
|
14
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/).optional()
|
|
15
|
+
});
|
|
16
|
+
export const CheckResultSchema = z.object({
|
|
17
|
+
id: z.string().min(1),
|
|
18
|
+
suite: CheckSuiteSchema,
|
|
19
|
+
target: z.string().min(1),
|
|
20
|
+
status: CheckStatusSchema,
|
|
21
|
+
severity: CheckSeveritySchema,
|
|
22
|
+
summary: z.string().min(1),
|
|
23
|
+
details: z.string().optional(),
|
|
24
|
+
artifacts: z.array(ArtifactRefSchema),
|
|
25
|
+
metadata: z.record(z.string(), z.unknown()),
|
|
26
|
+
suggestedNextStep: z.string().optional()
|
|
27
|
+
});
|
|
28
|
+
export const SuggestedNextStepSchema = z.object({
|
|
29
|
+
kind: z.string().min(1),
|
|
30
|
+
summary: z.string().min(1)
|
|
31
|
+
});
|
|
32
|
+
export const ReportSummarySchema = z.object({
|
|
33
|
+
passed: z.number().int().nonnegative(),
|
|
34
|
+
failed: z.number().int().nonnegative(),
|
|
35
|
+
warnings: z.number().int().nonnegative(),
|
|
36
|
+
skipped: z.number().int().nonnegative(),
|
|
37
|
+
blockingFailures: z.number().int().nonnegative(),
|
|
38
|
+
reviewItems: z.number().int().nonnegative()
|
|
39
|
+
});
|
|
40
|
+
export const ReflectionReportSchema = z.object({
|
|
41
|
+
schemaVersion: z.literal(1),
|
|
42
|
+
runId: z.string().min(1),
|
|
43
|
+
project: z.string().min(1),
|
|
44
|
+
startedAt: z.string().datetime(),
|
|
45
|
+
finishedAt: z.string().datetime(),
|
|
46
|
+
status: ReportStatusSchema,
|
|
47
|
+
mode: z.enum(['smoke', 'design', 'visual', 'full']),
|
|
48
|
+
ci: z.boolean(),
|
|
49
|
+
environment: z.record(z.string(), z.unknown()),
|
|
50
|
+
summary: ReportSummarySchema,
|
|
51
|
+
checks: z.array(CheckResultSchema),
|
|
52
|
+
artifacts: z.array(ArtifactRefSchema),
|
|
53
|
+
suggestedNextSteps: z.array(SuggestedNextStepSchema)
|
|
54
|
+
});
|
|
55
|
+
export function summarizeChecks(checks) {
|
|
56
|
+
return {
|
|
57
|
+
passed: checks.filter((check) => check.status === 'pass').length,
|
|
58
|
+
failed: checks.filter((check) => check.status === 'fail').length,
|
|
59
|
+
warnings: checks.filter((check) => check.status === 'warn').length,
|
|
60
|
+
skipped: checks.filter((check) => check.status === 'skipped').length,
|
|
61
|
+
blockingFailures: checks.filter((check) => check.severity === 'blocking' && (check.status === 'fail' || check.status === 'error')).length,
|
|
62
|
+
reviewItems: checks.filter((check) => check.severity === 'review' && (check.status === 'warn' || check.status === 'fail')).length
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export function deriveReportStatus(checks) {
|
|
66
|
+
if (checks.some((check) => check.status === 'error')) {
|
|
67
|
+
return 'error';
|
|
68
|
+
}
|
|
69
|
+
if (checks.some((check) => check.severity === 'blocking' && check.status === 'fail')) {
|
|
70
|
+
return 'fail';
|
|
71
|
+
}
|
|
72
|
+
if (checks.some((check) => check.severity === 'review' && (check.status === 'warn' || check.status === 'fail'))) {
|
|
73
|
+
return 'pass-with-review';
|
|
74
|
+
}
|
|
75
|
+
return 'pass';
|
|
76
|
+
}
|
|
77
|
+
export function deriveExitCode(status) {
|
|
78
|
+
if (status === 'fail') {
|
|
79
|
+
return ExitCode.BlockingFailure;
|
|
80
|
+
}
|
|
81
|
+
if (status === 'error') {
|
|
82
|
+
return ExitCode.ToolOrConfigError;
|
|
83
|
+
}
|
|
84
|
+
return ExitCode.Success;
|
|
85
|
+
}
|
|
86
|
+
export function validateReport(report) {
|
|
87
|
+
const parsed = ReflectionReportSchema.safeParse(report);
|
|
88
|
+
if (!parsed.success) {
|
|
89
|
+
const details = parsed.error.issues.map((issue) => `${issue.path.join('.') || 'report'}: ${issue.message}`).join('; ');
|
|
90
|
+
throw new Error(`Invalid Reflection report: ${details}`);
|
|
91
|
+
}
|
|
92
|
+
return parsed.data;
|
|
93
|
+
}
|
|
94
|
+
export function createReport(input) {
|
|
95
|
+
const status = deriveReportStatus(input.checks);
|
|
96
|
+
return validateReport({
|
|
97
|
+
schemaVersion: 1,
|
|
98
|
+
runId: input.runId,
|
|
99
|
+
project: input.project,
|
|
100
|
+
startedAt: input.startedAt.toISOString(),
|
|
101
|
+
finishedAt: input.finishedAt.toISOString(),
|
|
102
|
+
status,
|
|
103
|
+
mode: input.mode,
|
|
104
|
+
ci: input.ci,
|
|
105
|
+
environment: input.environment ?? {},
|
|
106
|
+
summary: summarizeChecks(input.checks),
|
|
107
|
+
checks: input.checks,
|
|
108
|
+
artifacts: input.artifacts ?? [],
|
|
109
|
+
suggestedNextSteps: input.suggestedNextSteps ?? []
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=report-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-schema.js","sourceRoot":"","sources":["../../src/core/report-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AACtF,MAAM,C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AAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE;QAC1C,MAAM;QACN,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,EAAE;QACpC,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC;QACtC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,EAAE;QAChC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAAI,EAAE;KACnD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ArtifactStore } from './artifact-store.js';
|
|
2
|
+
import type { ArtifactRef, ReflectionReport } from './report-schema.js';
|
|
3
|
+
export declare function writeReports(store: ArtifactStore, report: ReflectionReport): Promise<ArtifactRef[]>;
|
|
4
|
+
export declare function renderMarkdownReport(report: ReflectionReport): string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export async function writeReports(store, report) {
|
|
2
|
+
await store.ensureRunDir();
|
|
3
|
+
const reportJson = await store.writeJson('report.json', report);
|
|
4
|
+
const reportMd = await store.writeText('report.md', renderMarkdownReport(report));
|
|
5
|
+
await store.updateLatestPointer();
|
|
6
|
+
return [
|
|
7
|
+
{ ...reportJson, type: 'report', role: 'evidence' },
|
|
8
|
+
{ ...reportMd, type: 'report', role: 'evidence' }
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
export function renderMarkdownReport(report) {
|
|
12
|
+
const lines = [];
|
|
13
|
+
lines.push('# Reflection Report');
|
|
14
|
+
lines.push('');
|
|
15
|
+
lines.push(`Project: ${report.project}`);
|
|
16
|
+
lines.push(`Run: ${report.runId}`);
|
|
17
|
+
lines.push(`Mode: ${report.mode}`);
|
|
18
|
+
lines.push(`Status: ${report.status}`);
|
|
19
|
+
lines.push('');
|
|
20
|
+
lines.push('## Summary');
|
|
21
|
+
lines.push('');
|
|
22
|
+
lines.push(`- Passed: ${report.summary.passed}`);
|
|
23
|
+
lines.push(`- Failed: ${report.summary.failed}`);
|
|
24
|
+
lines.push(`- Warnings: ${report.summary.warnings}`);
|
|
25
|
+
lines.push(`- Skipped: ${report.summary.skipped}`);
|
|
26
|
+
lines.push(`- Blocking failures: ${report.summary.blockingFailures}`);
|
|
27
|
+
lines.push(`- Review items: ${report.summary.reviewItems}`);
|
|
28
|
+
const blocking = report.checks.filter(isBlockingFailure);
|
|
29
|
+
if (blocking.length > 0) {
|
|
30
|
+
lines.push('');
|
|
31
|
+
lines.push('## Blocking failures');
|
|
32
|
+
lines.push('');
|
|
33
|
+
for (const check of blocking) {
|
|
34
|
+
lines.push(renderCheckLine(check));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const review = report.checks.filter(isReviewItem);
|
|
38
|
+
if (review.length > 0) {
|
|
39
|
+
lines.push('');
|
|
40
|
+
lines.push('## Review items');
|
|
41
|
+
lines.push('');
|
|
42
|
+
for (const check of review) {
|
|
43
|
+
lines.push(renderCheckLine(check));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
lines.push('');
|
|
47
|
+
lines.push('## Checks');
|
|
48
|
+
lines.push('');
|
|
49
|
+
for (const check of report.checks) {
|
|
50
|
+
lines.push(renderCheckLine(check));
|
|
51
|
+
if (check.artifacts.length > 0) {
|
|
52
|
+
for (const artifact of check.artifacts) {
|
|
53
|
+
lines.push(` - ${artifact.role ?? artifact.type}: ${artifact.path}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (report.suggestedNextSteps.length > 0) {
|
|
58
|
+
lines.push('');
|
|
59
|
+
lines.push('## Suggested next steps');
|
|
60
|
+
lines.push('');
|
|
61
|
+
for (const step of report.suggestedNextSteps) {
|
|
62
|
+
lines.push(`- ${step.summary}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
lines.push('');
|
|
66
|
+
return `${lines.join('\n')}\n`;
|
|
67
|
+
}
|
|
68
|
+
function isBlockingFailure(check) {
|
|
69
|
+
return check.severity === 'blocking' && (check.status === 'fail' || check.status === 'error');
|
|
70
|
+
}
|
|
71
|
+
function isReviewItem(check) {
|
|
72
|
+
return check.severity === 'review' && (check.status === 'warn' || check.status === 'fail');
|
|
73
|
+
}
|
|
74
|
+
function renderCheckLine(check) {
|
|
75
|
+
return `- ${check.status.toUpperCase()} ${check.id}: ${check.summary}`;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=report-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-writer.js","sourceRoot":"","sources":["../../src/core/report-writer.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAoB,EAAE,MAAwB;IAC/E,MAAM,KAAK,CAAC,YAAY,EAAE,CAAC;IAC3B,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;IAClF,MAAM,KAAK,CAAC,mBAAmB,EAAE,CAAC;IAElC,OAAO;QACL,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE;QACnD,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE;KAClD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAwB;IAC3D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAClC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,OAAO,EAAE,CAAC,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C,EAAE,CAAC,CAAC;QACf,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;YAC7C,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAkB;IAC3C,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC;AAChG,CAAC;AAED,SAAS,YAAY,CAAC,KAAkB;IACtC,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AAC7F,CAAC;AAED,SAAS,eAAe,CAAC,KAAkB;IACzC,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type ServerConfig = {
|
|
2
|
+
command: string;
|
|
3
|
+
readyUrl: string;
|
|
4
|
+
reuseExisting?: boolean;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
};
|
|
7
|
+
export type StartManagedServerOptions = {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
logPath?: string;
|
|
10
|
+
};
|
|
11
|
+
export type ManagedServer = {
|
|
12
|
+
readyUrl: string;
|
|
13
|
+
reused: boolean;
|
|
14
|
+
started: boolean;
|
|
15
|
+
pid: number | undefined;
|
|
16
|
+
stop: () => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
export type WaitForUrlOptions = {
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
intervalMs?: number;
|
|
21
|
+
};
|
|
22
|
+
export declare function startManagedServer(config: ServerConfig, options?: StartManagedServerOptions): Promise<ManagedServer>;
|
|
23
|
+
export declare function waitForUrl(url: string, options?: WaitForUrlOptions): Promise<void>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { spawnManagedProcess } from '../utils/process.js';
|
|
2
|
+
export async function startManagedServer(config, options = {}) {
|
|
3
|
+
const timeoutMs = config.timeoutMs ?? 60_000;
|
|
4
|
+
if (config.reuseExisting ?? true) {
|
|
5
|
+
const existingReachable = await isUrlReachable(config.readyUrl);
|
|
6
|
+
if (existingReachable) {
|
|
7
|
+
return {
|
|
8
|
+
readyUrl: config.readyUrl,
|
|
9
|
+
reused: true,
|
|
10
|
+
started: false,
|
|
11
|
+
pid: undefined,
|
|
12
|
+
stop: async () => undefined
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const process = await spawnManagedProcess(config.command, options);
|
|
17
|
+
try {
|
|
18
|
+
await waitForUrl(config.readyUrl, { timeoutMs });
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
await process.stop();
|
|
22
|
+
const logHint = options.logPath ? ` Logs: ${options.logPath}` : '';
|
|
23
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
24
|
+
throw new Error(`Reflection server did not become ready at ${config.readyUrl}: ${message}.${logHint}`);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
readyUrl: config.readyUrl,
|
|
28
|
+
reused: false,
|
|
29
|
+
started: true,
|
|
30
|
+
pid: process.pid,
|
|
31
|
+
stop: process.stop
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export async function waitForUrl(url, options = {}) {
|
|
35
|
+
const timeoutMs = options.timeoutMs ?? 60_000;
|
|
36
|
+
const intervalMs = options.intervalMs ?? 250;
|
|
37
|
+
const deadline = Date.now() + timeoutMs;
|
|
38
|
+
let lastError;
|
|
39
|
+
while (Date.now() <= deadline) {
|
|
40
|
+
if (await isUrlReachable(url).catch((error) => {
|
|
41
|
+
lastError = error;
|
|
42
|
+
return false;
|
|
43
|
+
})) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
await sleep(intervalMs);
|
|
47
|
+
}
|
|
48
|
+
const reason = lastError instanceof Error ? ` Last error: ${lastError.message}` : '';
|
|
49
|
+
throw new Error(`URL not reachable before timeout: ${url}.${reason}`);
|
|
50
|
+
}
|
|
51
|
+
async function isUrlReachable(url) {
|
|
52
|
+
try {
|
|
53
|
+
const response = await fetch(url, { cache: 'no-store' });
|
|
54
|
+
await response.body?.cancel();
|
|
55
|
+
return response.status >= 200 && response.status < 500;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function sleep(ms) {
|
|
62
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=server-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-manager.js","sourceRoot":"","sources":["../../src/core/server-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AA2B1D,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAAoB,EAAE,UAAqC,EAAE;IACpG,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC;IAE7C,IAAI,MAAM,CAAC,aAAa,IAAI,IAAI,EAAE,CAAC;QACjC,MAAM,iBAAiB,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,iBAAiB,EAAE,CAAC;YACtB,OAAO;gBACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,MAAM,EAAE,IAAI;gBACZ,OAAO,EAAE,KAAK;gB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G,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC9B,IAAI,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACrD,SAAS,GAAG,KAAK,CAAC;YAClB,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,EAAE,CAAC;YACH,OAAO;QACT,CAAC;QAED,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,MAAM,GAAG,SAAS,YAAY,KAAK,CAAC,CAAC,CAAC,gBAAgB,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACrF,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,GAAW;IACvC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QACzD,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAC9B,OAAO,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,KAAK,UAAU,KAAK,CAAC,EAAU;IAC7B,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ReflectionConfig, RunMode } from './config.js';
|
|
2
|
+
export type TargetSource = 'reflection-config' | 'adapter';
|
|
3
|
+
export type TargetFamily = 'browser-route' | 'route-visual' | 'component-visual' | 'design-command';
|
|
4
|
+
export type TargetIR = {
|
|
5
|
+
project: string;
|
|
6
|
+
targets: ReflectionTarget[];
|
|
7
|
+
};
|
|
8
|
+
export type ReflectionTarget = BrowserRouteTarget | RouteVisualTarget | ComponentVisualTarget | DesignCommandTarget;
|
|
9
|
+
type TargetBase = {
|
|
10
|
+
id: string;
|
|
11
|
+
family: TargetFamily;
|
|
12
|
+
source: TargetSource;
|
|
13
|
+
runModes: RunMode[];
|
|
14
|
+
blocking: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type BrowserRouteTarget = TargetBase & {
|
|
17
|
+
family: 'browser-route';
|
|
18
|
+
route: {
|
|
19
|
+
path: string;
|
|
20
|
+
name?: string | undefined;
|
|
21
|
+
viewports: string[];
|
|
22
|
+
expects: unknown[];
|
|
23
|
+
};
|
|
24
|
+
browser: {
|
|
25
|
+
baseUrl: string;
|
|
26
|
+
maskSelectors: string[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export type RouteVisualTarget = TargetBase & {
|
|
30
|
+
family: 'route-visual';
|
|
31
|
+
route: {
|
|
32
|
+
path: string;
|
|
33
|
+
};
|
|
34
|
+
visual: {
|
|
35
|
+
viewport: string;
|
|
36
|
+
baseline: string;
|
|
37
|
+
baselineRoot?: string | undefined;
|
|
38
|
+
threshold?: unknown;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type ComponentVisualTarget = TargetBase & {
|
|
42
|
+
family: 'component-visual';
|
|
43
|
+
story: {
|
|
44
|
+
storyId: string;
|
|
45
|
+
statePolicy: 'story-controlled' | 'browser-forced-with-stabilization';
|
|
46
|
+
stateNote?: string | undefined;
|
|
47
|
+
browserState?: unknown;
|
|
48
|
+
};
|
|
49
|
+
visual: {
|
|
50
|
+
viewport: string;
|
|
51
|
+
baseline: string;
|
|
52
|
+
baselineRoot?: string | undefined;
|
|
53
|
+
threshold?: unknown;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export type DesignCommandTarget = TargetBase & {
|
|
57
|
+
family: 'design-command';
|
|
58
|
+
command: {
|
|
59
|
+
command: string;
|
|
60
|
+
cwd?: string | undefined;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export declare function compileReflectionTargets(config: ReflectionConfig): TargetIR;
|
|
64
|
+
export {};
|