@ontrails/regrade 1.0.0-beta.32 → 1.0.0-beta.41
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/CHANGELOG.md +135 -0
- package/package.json +6 -5
- package/src/downstream/ast-rewrite.ts +725 -17
- package/src/downstream/collect.ts +17 -2
- package/src/downstream/export-restructure.ts +1588 -0
- package/src/downstream/report.ts +409 -48
- package/src/downstream/vocabulary-registry.ts +96 -0
- package/src/downstream/vocabulary.ts +1160 -118
- package/src/index.ts +27 -0
- package/src/literal-transform.ts +26 -20
package/src/index.ts
CHANGED
|
@@ -14,10 +14,30 @@ export {
|
|
|
14
14
|
wardenTermRewriteClasses,
|
|
15
15
|
} from './downstream/report.js';
|
|
16
16
|
export {
|
|
17
|
+
cliAliasesExportRestructureClass,
|
|
18
|
+
createWardenExportRestructureClass,
|
|
19
|
+
exportRestructureClasses,
|
|
20
|
+
loadWardenRegradeClasses,
|
|
21
|
+
mcpTrailheadsExportRestructureClass,
|
|
22
|
+
} from './downstream/export-restructure.js';
|
|
23
|
+
export {
|
|
24
|
+
VOCABULARY_TRANSITION_RECORD_SCHEMA_VERSION,
|
|
25
|
+
buildVocabularyTransitionRecord,
|
|
26
|
+
readVocabularyTransitionRecord,
|
|
17
27
|
runVocabularyRegrade,
|
|
28
|
+
transitionRecordReportWithSummary,
|
|
29
|
+
vocabularyDispositionValues,
|
|
18
30
|
vocabularyRegradePlanSchema,
|
|
19
31
|
vocabularyRegradeRunOutput,
|
|
32
|
+
vocabularyTransitionRecordPath,
|
|
33
|
+
vocabularyTransitionRecordSchema,
|
|
34
|
+
writeVocabularyTransitionRecord,
|
|
20
35
|
} from './downstream/vocabulary.js';
|
|
36
|
+
export {
|
|
37
|
+
listVocabularyRegradePlansFromRegistry,
|
|
38
|
+
vocabularyRegradePlanFromTransition,
|
|
39
|
+
vocabularyRegradeTransitionForInput,
|
|
40
|
+
} from './downstream/vocabulary-registry.js';
|
|
21
41
|
export type {
|
|
22
42
|
RegradeApplySummary,
|
|
23
43
|
RegradeClass,
|
|
@@ -27,6 +47,7 @@ export type {
|
|
|
27
47
|
RegradeReportEntry,
|
|
28
48
|
RegradeReportEntrySelection,
|
|
29
49
|
RegradeReviewDetail,
|
|
50
|
+
RegradeReviewJudgment,
|
|
30
51
|
RegradeReviewSpan,
|
|
31
52
|
RegradeScanTargets,
|
|
32
53
|
RegradeSelection,
|
|
@@ -38,7 +59,9 @@ export type {
|
|
|
38
59
|
RegradeScanSummary,
|
|
39
60
|
} from './downstream/scan-summary.js';
|
|
40
61
|
export type {
|
|
62
|
+
VocabularyDisposition,
|
|
41
63
|
VocabularyOccurrence,
|
|
64
|
+
VocabularyPreserveInventoryEntry,
|
|
42
65
|
VocabularyPreserveRule,
|
|
43
66
|
VocabularyRegradePlan,
|
|
44
67
|
VocabularyRegradeScope,
|
|
@@ -46,11 +69,15 @@ export type {
|
|
|
46
69
|
VocabularyRunGate,
|
|
47
70
|
VocabularyRunLedger,
|
|
48
71
|
VocabularyRunReport,
|
|
72
|
+
VocabularyTransitionRecord,
|
|
73
|
+
VocabularyTransitionRecordEnvironment,
|
|
74
|
+
VocabularyTransitionRecordSummary,
|
|
49
75
|
VocabularyVerdict,
|
|
50
76
|
} from './downstream/vocabulary.js';
|
|
51
77
|
export {
|
|
52
78
|
createAstIdentifierRenameClass,
|
|
53
79
|
createAstRewriteClass,
|
|
80
|
+
createGovernedAstIdentifierRenameClasses,
|
|
54
81
|
} from './downstream/ast-rewrite.js';
|
|
55
82
|
export type {
|
|
56
83
|
AstIdentifierRenameClassOptions,
|
package/src/literal-transform.ts
CHANGED
|
@@ -16,10 +16,10 @@ const childInput = z.object({
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Parent input schema with its raw-to-
|
|
19
|
+
* Parent input schema with its raw-to-implementation transform attached.
|
|
20
20
|
*
|
|
21
21
|
* Naming the transformed schema lets examples and tests reference both its raw
|
|
22
|
-
* pre-transform input (`z.input`) and its post-transform
|
|
22
|
+
* pre-transform input (`z.input`) and its post-transform implementation input
|
|
23
23
|
* (`z.infer`) without restating either shape by hand.
|
|
24
24
|
*/
|
|
25
25
|
const regradeTransformInputToChild = regradeTransformInput.transform(
|
|
@@ -32,15 +32,15 @@ const regradeTransformInputToChild = regradeTransformInput.transform(
|
|
|
32
32
|
* Raw, pre-transform input accepted by {@link regradeTransformInputToChild}.
|
|
33
33
|
*
|
|
34
34
|
* Trail examples and `testExamples()` feed this shape through validation; the
|
|
35
|
-
* Zod transform then projects it into the
|
|
35
|
+
* Zod transform then projects it into the implementation input.
|
|
36
36
|
*/
|
|
37
37
|
type RegradeTransformRawInput = z.input<typeof regradeTransformInputToChild>;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Post-transform
|
|
40
|
+
* Post-transform implementation input shape — the trail's inferred input type `I`.
|
|
41
41
|
*
|
|
42
42
|
* TRL-842: With a `.transform()` input schema, the trail's inferred input type
|
|
43
|
-
* `I` is the transform OUTPUT (the
|
|
43
|
+
* `I` is the transform OUTPUT (the implementation input), while examples and
|
|
44
44
|
* `testExamples()` validate the raw pre-transform INPUT. Those two shapes are
|
|
45
45
|
* disjoint, so an authored example must carry raw input typed as the
|
|
46
46
|
* post-transform shape. A framework-level fix would thread a separate
|
|
@@ -49,7 +49,9 @@ type RegradeTransformRawInput = z.input<typeof regradeTransformInputToChild>;
|
|
|
49
49
|
* then the divergence is captured by the two named types here and exercised by
|
|
50
50
|
* the runtime validation test in `__tests__/literal-transform.test.ts`.
|
|
51
51
|
*/
|
|
52
|
-
type
|
|
52
|
+
type RegradeTransformImplementationInput = z.infer<
|
|
53
|
+
typeof regradeTransformInputToChild
|
|
54
|
+
>;
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* Raw example input, statically checked as valid pre-transform input. If the
|
|
@@ -63,7 +65,7 @@ const codeStringExampleInput: RegradeTransformRawInput = {
|
|
|
63
65
|
export const normalizeExportConstTrail = trail(
|
|
64
66
|
'regrade.literal.normalize-export-const',
|
|
65
67
|
{
|
|
66
|
-
|
|
68
|
+
implementation: (input) => {
|
|
67
69
|
const nextSource = input.source.replaceAll('export const', 'export let');
|
|
68
70
|
return Result.ok({
|
|
69
71
|
changed: nextSource !== input.source,
|
|
@@ -81,17 +83,6 @@ export const normalizeExportConstTrail = trail(
|
|
|
81
83
|
);
|
|
82
84
|
|
|
83
85
|
export const literalRegradeTrail = trail('regrade.literal.run', {
|
|
84
|
-
blaze: async (input, ctx) => {
|
|
85
|
-
if (!ctx.compose) {
|
|
86
|
-
return Result.err(
|
|
87
|
-
new InternalError(
|
|
88
|
-
'Literal Regrade tracer requires compose-capable execution.'
|
|
89
|
-
)
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
const blazeInput = input as RegradeTransformBlazeInput;
|
|
93
|
-
return await ctx.compose(normalizeExportConstTrail, blazeInput.child);
|
|
94
|
-
},
|
|
95
86
|
composes: [normalizeExportConstTrail],
|
|
96
87
|
examples: [
|
|
97
88
|
{
|
|
@@ -103,11 +94,26 @@ export const literalRegradeTrail = trail('regrade.literal.run', {
|
|
|
103
94
|
// TRL-842: author the raw pre-transform value (validated as
|
|
104
95
|
// RegradeTransformRawInput) and widen through `unknown` to the trail's
|
|
105
96
|
// inferred post-transform input type. The runtime still parses raw input;
|
|
106
|
-
// see
|
|
107
|
-
input:
|
|
97
|
+
// see RegradeTransformImplementationInput for why the two shapes diverge.
|
|
98
|
+
input:
|
|
99
|
+
codeStringExampleInput as unknown as RegradeTransformImplementationInput,
|
|
108
100
|
name: 'code-string fixture',
|
|
109
101
|
},
|
|
110
102
|
],
|
|
103
|
+
implementation: async (input, ctx) => {
|
|
104
|
+
if (!ctx.compose) {
|
|
105
|
+
return Result.err(
|
|
106
|
+
new InternalError(
|
|
107
|
+
'Literal Regrade tracer requires compose-capable execution.'
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
const implementationInput = input as RegradeTransformImplementationInput;
|
|
112
|
+
return await ctx.compose(
|
|
113
|
+
normalizeExportConstTrail,
|
|
114
|
+
implementationInput.child
|
|
115
|
+
);
|
|
116
|
+
},
|
|
111
117
|
input: regradeTransformInputToChild,
|
|
112
118
|
output: regradeTransformOutput,
|
|
113
119
|
});
|