mason-context 0.16.1 → 0.16.3
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 +16 -0
- package/README.md +15 -8
- package/dist/mason-audit.js +86 -66
- package/dist/mason-audit.js.map +1 -1
- package/dist/mason-auto.js +989 -776
- package/dist/mason-auto.js.map +1 -1
- package/dist/mason-drift.js +13 -0
- package/dist/mason-drift.js.map +1 -1
- package/dist/mason-hook.js +13 -0
- package/dist/mason-hook.js.map +1 -1
- package/dist/mason-mcp.js +1385 -1177
- package/dist/mason-mcp.js.map +1 -1
- package/dist/mason-review.js +62 -49
- package/dist/mason-review.js.map +1 -1
- package/dist/mason.js +1060 -842
- package/dist/mason.js.map +1 -1
- package/package.json +2 -1
package/dist/mason-review.js
CHANGED
|
@@ -542,11 +542,24 @@ function decisionKnowledge(record, freshness = "unknown", proposalFreshness = "u
|
|
|
542
542
|
import fs4 from "fs/promises";
|
|
543
543
|
import path8 from "path";
|
|
544
544
|
import { createHash } from "crypto";
|
|
545
|
+
import { z as z3 } from "zod";
|
|
545
546
|
|
|
546
547
|
// src/context/lexical.ts
|
|
547
548
|
import path7 from "path";
|
|
548
549
|
|
|
549
550
|
// src/decisions/decisions.ts
|
|
551
|
+
var TITLE_MAX_CHARS = 80;
|
|
552
|
+
var BODY_RECOMMENDED_CHARS = 1500;
|
|
553
|
+
var BODY_MAX_CHARS = 2500;
|
|
554
|
+
var boundedText = (field, max, hint) => z3.string({
|
|
555
|
+
errorMap: (issue, ctx) => ({ message: issue.code === "too_big" ? `${field} has ${ctx.data.length} characters; maximum is ${max} (${ctx.data.length - max} over). ${hint}` : ctx.defaultError })
|
|
556
|
+
}).trim().min(1, `${field} must be non-empty`).max(max);
|
|
557
|
+
var decisionTitleSchema = boundedText("title", TITLE_MAX_CHARS, "Tighten it to a specific headline.");
|
|
558
|
+
var decisionBodySchema = boundedText(
|
|
559
|
+
"body",
|
|
560
|
+
BODY_MAX_CHARS,
|
|
561
|
+
`Aim for ${BODY_RECOMMENDED_CHARS} characters or fewer. Preserve the rule, reason, and exceptions; put supporting references in sources.`
|
|
562
|
+
);
|
|
550
563
|
async function loadDecisionStore(rootDir) {
|
|
551
564
|
const records = [];
|
|
552
565
|
const diagnostics = [];
|
|
@@ -675,10 +688,10 @@ async function findMissingPartners(resolvedRoot, changedFiles, existsOnDisk, all
|
|
|
675
688
|
|
|
676
689
|
// src/review/evidence.ts
|
|
677
690
|
import path10 from "path";
|
|
678
|
-
import { z as
|
|
691
|
+
import { z as z6 } from "zod";
|
|
679
692
|
|
|
680
693
|
// src/review/evidence/vitest.ts
|
|
681
|
-
import { z as
|
|
694
|
+
import { z as z4 } from "zod";
|
|
682
695
|
|
|
683
696
|
// src/review/evidence/paths.ts
|
|
684
697
|
function evidencePath(value, sourceRoot, uri = false) {
|
|
@@ -714,24 +727,24 @@ function messagePreview(message2) {
|
|
|
714
727
|
}
|
|
715
728
|
|
|
716
729
|
// src/review/evidence/vitest.ts
|
|
717
|
-
var count =
|
|
718
|
-
var schema =
|
|
719
|
-
success:
|
|
730
|
+
var count = z4.number().int().nonnegative();
|
|
731
|
+
var schema = z4.object({
|
|
732
|
+
success: z4.boolean(),
|
|
720
733
|
numTotalTests: count,
|
|
721
734
|
numPassedTests: count,
|
|
722
735
|
numFailedTests: count,
|
|
723
736
|
numPendingTests: count,
|
|
724
737
|
numTodoTests: count,
|
|
725
738
|
numFailedTestSuites: count,
|
|
726
|
-
testResults:
|
|
727
|
-
name:
|
|
728
|
-
status:
|
|
729
|
-
message:
|
|
730
|
-
assertionResults:
|
|
731
|
-
fullName:
|
|
732
|
-
status:
|
|
733
|
-
failureMessages:
|
|
734
|
-
location:
|
|
739
|
+
testResults: z4.array(z4.object({
|
|
740
|
+
name: z4.string().min(1),
|
|
741
|
+
status: z4.enum(["passed", "failed"]),
|
|
742
|
+
message: z4.string().optional(),
|
|
743
|
+
assertionResults: z4.array(z4.object({
|
|
744
|
+
fullName: z4.string(),
|
|
745
|
+
status: z4.enum(["passed", "failed", "pending", "skipped", "todo", "disabled"]),
|
|
746
|
+
failureMessages: z4.array(z4.string()).nullable().optional(),
|
|
747
|
+
location: z4.object({ line: count, column: count }).nullable().optional()
|
|
735
748
|
}))
|
|
736
749
|
}))
|
|
737
750
|
});
|
|
@@ -779,30 +792,30 @@ function parseVitest(raw, sourceRoot) {
|
|
|
779
792
|
}
|
|
780
793
|
|
|
781
794
|
// src/review/evidence/sarif.ts
|
|
782
|
-
import { z as
|
|
783
|
-
var index =
|
|
784
|
-
var artifact =
|
|
785
|
-
var message =
|
|
786
|
-
var level =
|
|
787
|
-
var location =
|
|
788
|
-
var schema2 =
|
|
789
|
-
version:
|
|
790
|
-
runs:
|
|
791
|
-
tool:
|
|
792
|
-
invocations:
|
|
793
|
-
versionControlProvenance:
|
|
794
|
-
originalUriBaseIds:
|
|
795
|
-
artifacts:
|
|
796
|
-
results:
|
|
797
|
-
ruleId:
|
|
795
|
+
import { z as z5 } from "zod";
|
|
796
|
+
var index = z5.number().int().nonnegative();
|
|
797
|
+
var artifact = z5.object({ uri: z5.string().optional(), uriBaseId: z5.string().optional(), index: index.optional() });
|
|
798
|
+
var message = z5.object({ text: z5.string().optional(), markdown: z5.string().optional(), id: z5.string().optional(), arguments: z5.array(z5.string()).optional() });
|
|
799
|
+
var level = z5.enum(["error", "warning", "note", "none"]);
|
|
800
|
+
var location = z5.object({ physicalLocation: z5.object({ artifactLocation: artifact.optional(), region: z5.object({ startLine: index.optional(), startColumn: index.optional() }).optional() }).optional() });
|
|
801
|
+
var schema2 = z5.object({
|
|
802
|
+
version: z5.literal("2.1.0"),
|
|
803
|
+
runs: z5.array(z5.object({
|
|
804
|
+
tool: z5.object({ driver: z5.object({ name: z5.string().min(1), rules: z5.array(z5.object({ id: z5.string(), defaultConfiguration: z5.object({ level: level.optional() }).optional(), messageStrings: z5.record(message).optional() })).optional(), globalMessageStrings: z5.record(message).optional() }) }),
|
|
805
|
+
invocations: z5.array(z5.object({ executionSuccessful: z5.boolean(), commandLine: z5.string().optional(), toolExecutionNotifications: z5.array(z5.object({ level: level.optional(), message })).optional() })).optional(),
|
|
806
|
+
versionControlProvenance: z5.array(z5.object({ revisionId: z5.string().optional() })).optional(),
|
|
807
|
+
originalUriBaseIds: z5.record(artifact).optional(),
|
|
808
|
+
artifacts: z5.array(z5.object({ location: artifact.optional() })).optional(),
|
|
809
|
+
results: z5.array(z5.object({
|
|
810
|
+
ruleId: z5.string().optional(),
|
|
798
811
|
ruleIndex: index.optional(),
|
|
799
812
|
message,
|
|
800
813
|
level: level.optional(),
|
|
801
|
-
kind:
|
|
802
|
-
baselineState:
|
|
803
|
-
suppressions:
|
|
804
|
-
locations:
|
|
805
|
-
relatedLocations:
|
|
814
|
+
kind: z5.enum(["fail", "pass", "open", "informational", "notApplicable", "review"]).optional(),
|
|
815
|
+
baselineState: z5.enum(["new", "unchanged", "updated", "absent"]).optional(),
|
|
816
|
+
suppressions: z5.array(z5.object({ kind: z5.enum(["inSource", "external"]), status: z5.enum(["accepted", "underReview", "rejected"]).optional() })).nullable().optional(),
|
|
817
|
+
locations: z5.array(location).optional(),
|
|
818
|
+
relatedLocations: z5.array(location).optional()
|
|
806
819
|
})).optional()
|
|
807
820
|
}))
|
|
808
821
|
});
|
|
@@ -892,19 +905,19 @@ function parseSarif(raw, sourceRoot) {
|
|
|
892
905
|
}
|
|
893
906
|
|
|
894
907
|
// src/review/evidence.ts
|
|
895
|
-
var checkSchema =
|
|
896
|
-
id:
|
|
897
|
-
kind:
|
|
898
|
-
tool:
|
|
899
|
-
command:
|
|
900
|
-
commit:
|
|
901
|
-
workingTreeClean:
|
|
902
|
-
source:
|
|
903
|
-
sourceRoot:
|
|
904
|
-
status:
|
|
905
|
-
reason:
|
|
906
|
-
exitCode:
|
|
907
|
-
report:
|
|
908
|
+
var checkSchema = z6.object({
|
|
909
|
+
id: z6.string().min(1).max(100),
|
|
910
|
+
kind: z6.enum(["tests", "static-analysis", "security", "complexity", "duplication"]),
|
|
911
|
+
tool: z6.string().min(1).max(200),
|
|
912
|
+
command: z6.string().min(1).max(2e3),
|
|
913
|
+
commit: z6.string().regex(/^(?:[a-fA-F0-9]{40}|[a-fA-F0-9]{64})$/).nullable().optional(),
|
|
914
|
+
workingTreeClean: z6.boolean().optional(),
|
|
915
|
+
source: z6.string().max(2e3).optional(),
|
|
916
|
+
sourceRoot: z6.string().min(1).max(4e3).optional(),
|
|
917
|
+
status: z6.enum(["completed", "skipped", "unavailable"]).default("completed"),
|
|
918
|
+
reason: z6.string().min(1).max(2e3).optional(),
|
|
919
|
+
exitCode: z6.number().int().nullable().optional(),
|
|
920
|
+
report: z6.object({ format: z6.enum(["vitest-json", "sarif"]), path: z6.string().min(1).max(4e3) }).optional()
|
|
908
921
|
});
|
|
909
922
|
function relativeArtifact(root, file) {
|
|
910
923
|
const relative = path10.isAbsolute(file) ? path10.relative(root, file) : file;
|
|
@@ -946,7 +959,7 @@ async function collectReviewEvidence(root, manifests, changedFiles, decisions, d
|
|
|
946
959
|
let manifest, raw;
|
|
947
960
|
try {
|
|
948
961
|
manifest = relativeArtifact(root, supplied);
|
|
949
|
-
raw =
|
|
962
|
+
raw = z6.object({ version: z6.literal(1), checks: z6.array(z6.unknown()) }).parse(await readStoreJson(root, manifest));
|
|
950
963
|
} catch (error) {
|
|
951
964
|
output.diagnostics.push(`${supplied}: ${String(error)}`);
|
|
952
965
|
continue;
|