peaks-loop-mut 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.
Files changed (34) hide show
  1. package/dist/index.d.ts +15 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +14 -0
  4. package/dist/services/agent/ecc-cache-service.d.ts +98 -0
  5. package/dist/services/agent/ecc-cache-service.d.ts.map +1 -0
  6. package/dist/services/agent/ecc-cache-service.js +491 -0
  7. package/dist/services/mut/assert-scanner.d.ts +7 -0
  8. package/dist/services/mut/assert-scanner.d.ts.map +1 -0
  9. package/dist/services/mut/assert-scanner.js +116 -0
  10. package/dist/services/mut/index.d.ts +9 -0
  11. package/dist/services/mut/index.d.ts.map +1 -0
  12. package/dist/services/mut/index.js +7 -0
  13. package/dist/services/mut/mut-runner.d.ts +40 -0
  14. package/dist/services/mut/mut-runner.d.ts.map +1 -0
  15. package/dist/services/mut/mut-runner.js +29 -0
  16. package/dist/services/mut/production-stryker.d.ts +3 -0
  17. package/dist/services/mut/production-stryker.d.ts.map +1 -0
  18. package/dist/services/mut/production-stryker.js +75 -0
  19. package/dist/services/mut/report-builder.d.ts +12 -0
  20. package/dist/services/mut/report-builder.d.ts.map +1 -0
  21. package/dist/services/mut/report-builder.js +110 -0
  22. package/dist/services/mut/report-loader.d.ts +32 -0
  23. package/dist/services/mut/report-loader.d.ts.map +1 -0
  24. package/dist/services/mut/report-loader.js +78 -0
  25. package/dist/services/mut/thresholds.d.ts +22 -0
  26. package/dist/services/mut/thresholds.d.ts.map +1 -0
  27. package/dist/services/mut/thresholds.js +22 -0
  28. package/dist/services/mut/types.d.ts +337 -0
  29. package/dist/services/mut/types.d.ts.map +1 -0
  30. package/dist/services/mut/types.js +59 -0
  31. package/dist/shared/frontmatter.d.ts +17 -0
  32. package/dist/shared/frontmatter.d.ts.map +1 -0
  33. package/dist/shared/frontmatter.js +175 -0
  34. package/package.json +28 -0
@@ -0,0 +1,337 @@
1
+ /**
2
+ * Per spec §4.2 验收审计 + §7 阶段二 — MutReportJson v1.0.
3
+ *
4
+ * Hard constraints:
5
+ * H8 (audit trail hashable): sha256 + inputSig (chain to TACT.sig)
6
+ * H6 (CLI裁决, not LLM): passed boolean is computed by CLI, not LLM
7
+ */
8
+ import { z } from 'zod';
9
+ export type MutVersion = '1.0';
10
+ export type MutTool = 'stryker' | 'mutmut' | 'go-mutesting';
11
+ export type WeakPattern = 'toBeDefined' | 'toBeTruthy' | 'toEqual-self' | 'expect-anything' | 'toBe-self';
12
+ export interface SurvivedMutant {
13
+ readonly line: number;
14
+ readonly mutation: string;
15
+ readonly survivedBecause: string;
16
+ }
17
+ export interface FileMutationReport {
18
+ readonly file: string;
19
+ readonly killRate: number;
20
+ readonly survived: ReadonlyArray<SurvivedMutant>;
21
+ }
22
+ export interface MutationReport {
23
+ readonly tool: MutTool;
24
+ readonly mutantsTotal: number;
25
+ readonly mutantsKilled: number;
26
+ readonly mutantsSurvived: number;
27
+ readonly mutantsTimeout: number;
28
+ readonly killRate: number;
29
+ readonly byFile: ReadonlyArray<FileMutationReport>;
30
+ }
31
+ export interface WeakExample {
32
+ readonly file: string;
33
+ readonly line: number;
34
+ readonly code: string;
35
+ }
36
+ export interface WeakPatternCount {
37
+ readonly pattern: WeakPattern;
38
+ readonly count: number;
39
+ readonly examples: ReadonlyArray<WeakExample>;
40
+ }
41
+ export interface AssertionsReport {
42
+ readonly totalAssertions: number;
43
+ readonly weakAssertions: number;
44
+ readonly weakRate: number;
45
+ readonly weakPatterns: ReadonlyArray<WeakPatternCount>;
46
+ }
47
+ export interface ThresholdsConfig {
48
+ readonly mutationKillRateMin: number;
49
+ readonly weakAssertionRateMax: number;
50
+ readonly passed: boolean;
51
+ }
52
+ export type FollowupSeverity = 'soft' | 'hard';
53
+ export type FollowupIssue = 'low_kill_rate' | 'high_weak_assertions';
54
+ export interface Followup {
55
+ readonly file: string;
56
+ readonly issue: FollowupIssue;
57
+ readonly severity: FollowupSeverity;
58
+ readonly suggestion: string;
59
+ }
60
+ export interface MutReportJson {
61
+ readonly version: MutVersion;
62
+ readonly sha256: string;
63
+ readonly generatedAt: string;
64
+ readonly inputSig: string;
65
+ readonly mutation: MutationReport;
66
+ readonly assertions: AssertionsReport;
67
+ readonly thresholds: ThresholdsConfig;
68
+ readonly followups: ReadonlyArray<Followup>;
69
+ }
70
+ export declare const WeakPatternSchema: z.ZodEnum<["toBeDefined", "toBeTruthy", "toEqual-self", "expect-anything", "toBe-self"]>;
71
+ export declare const MutReportSchema: z.ZodObject<{
72
+ version: z.ZodLiteral<"1.0">;
73
+ sha256: z.ZodString;
74
+ generatedAt: z.ZodString;
75
+ inputSig: z.ZodString;
76
+ mutation: z.ZodObject<{
77
+ tool: z.ZodEnum<["stryker", "mutmut", "go-mutesting"]>;
78
+ mutantsTotal: z.ZodNumber;
79
+ mutantsKilled: z.ZodNumber;
80
+ mutantsSurvived: z.ZodNumber;
81
+ mutantsTimeout: z.ZodNumber;
82
+ killRate: z.ZodNumber;
83
+ byFile: z.ZodArray<z.ZodObject<{
84
+ file: z.ZodString;
85
+ killRate: z.ZodNumber;
86
+ survived: z.ZodArray<z.ZodObject<{
87
+ line: z.ZodNumber;
88
+ mutation: z.ZodString;
89
+ survivedBecause: z.ZodString;
90
+ }, "strip", z.ZodTypeAny, {
91
+ mutation: string;
92
+ line: number;
93
+ survivedBecause: string;
94
+ }, {
95
+ mutation: string;
96
+ line: number;
97
+ survivedBecause: string;
98
+ }>, "many">;
99
+ }, "strip", z.ZodTypeAny, {
100
+ killRate: number;
101
+ file: string;
102
+ survived: {
103
+ mutation: string;
104
+ line: number;
105
+ survivedBecause: string;
106
+ }[];
107
+ }, {
108
+ killRate: number;
109
+ file: string;
110
+ survived: {
111
+ mutation: string;
112
+ line: number;
113
+ survivedBecause: string;
114
+ }[];
115
+ }>, "many">;
116
+ }, "strip", z.ZodTypeAny, {
117
+ tool: "stryker" | "mutmut" | "go-mutesting";
118
+ mutantsTotal: number;
119
+ mutantsKilled: number;
120
+ mutantsSurvived: number;
121
+ mutantsTimeout: number;
122
+ killRate: number;
123
+ byFile: {
124
+ killRate: number;
125
+ file: string;
126
+ survived: {
127
+ mutation: string;
128
+ line: number;
129
+ survivedBecause: string;
130
+ }[];
131
+ }[];
132
+ }, {
133
+ tool: "stryker" | "mutmut" | "go-mutesting";
134
+ mutantsTotal: number;
135
+ mutantsKilled: number;
136
+ mutantsSurvived: number;
137
+ mutantsTimeout: number;
138
+ killRate: number;
139
+ byFile: {
140
+ killRate: number;
141
+ file: string;
142
+ survived: {
143
+ mutation: string;
144
+ line: number;
145
+ survivedBecause: string;
146
+ }[];
147
+ }[];
148
+ }>;
149
+ assertions: z.ZodObject<{
150
+ totalAssertions: z.ZodNumber;
151
+ weakAssertions: z.ZodNumber;
152
+ weakRate: z.ZodNumber;
153
+ weakPatterns: z.ZodArray<z.ZodObject<{
154
+ pattern: z.ZodEnum<["toBeDefined", "toBeTruthy", "toEqual-self", "expect-anything", "toBe-self"]>;
155
+ count: z.ZodNumber;
156
+ examples: z.ZodArray<z.ZodObject<{
157
+ file: z.ZodString;
158
+ line: z.ZodNumber;
159
+ code: z.ZodString;
160
+ }, "strip", z.ZodTypeAny, {
161
+ code: string;
162
+ file: string;
163
+ line: number;
164
+ }, {
165
+ code: string;
166
+ file: string;
167
+ line: number;
168
+ }>, "many">;
169
+ }, "strip", z.ZodTypeAny, {
170
+ pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
171
+ count: number;
172
+ examples: {
173
+ code: string;
174
+ file: string;
175
+ line: number;
176
+ }[];
177
+ }, {
178
+ pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
179
+ count: number;
180
+ examples: {
181
+ code: string;
182
+ file: string;
183
+ line: number;
184
+ }[];
185
+ }>, "many">;
186
+ }, "strip", z.ZodTypeAny, {
187
+ totalAssertions: number;
188
+ weakAssertions: number;
189
+ weakRate: number;
190
+ weakPatterns: {
191
+ pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
192
+ count: number;
193
+ examples: {
194
+ code: string;
195
+ file: string;
196
+ line: number;
197
+ }[];
198
+ }[];
199
+ }, {
200
+ totalAssertions: number;
201
+ weakAssertions: number;
202
+ weakRate: number;
203
+ weakPatterns: {
204
+ pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
205
+ count: number;
206
+ examples: {
207
+ code: string;
208
+ file: string;
209
+ line: number;
210
+ }[];
211
+ }[];
212
+ }>;
213
+ thresholds: z.ZodObject<{
214
+ mutationKillRateMin: z.ZodNumber;
215
+ weakAssertionRateMax: z.ZodNumber;
216
+ passed: z.ZodBoolean;
217
+ }, "strip", z.ZodTypeAny, {
218
+ mutationKillRateMin: number;
219
+ weakAssertionRateMax: number;
220
+ passed: boolean;
221
+ }, {
222
+ mutationKillRateMin: number;
223
+ weakAssertionRateMax: number;
224
+ passed: boolean;
225
+ }>;
226
+ followups: z.ZodArray<z.ZodObject<{
227
+ file: z.ZodString;
228
+ issue: z.ZodEnum<["low_kill_rate", "high_weak_assertions"]>;
229
+ severity: z.ZodEnum<["soft", "hard"]>;
230
+ suggestion: z.ZodString;
231
+ }, "strip", z.ZodTypeAny, {
232
+ file: string;
233
+ issue: "low_kill_rate" | "high_weak_assertions";
234
+ severity: "soft" | "hard";
235
+ suggestion: string;
236
+ }, {
237
+ file: string;
238
+ issue: "low_kill_rate" | "high_weak_assertions";
239
+ severity: "soft" | "hard";
240
+ suggestion: string;
241
+ }>, "many">;
242
+ }, "strip", z.ZodTypeAny, {
243
+ version: "1.0";
244
+ sha256: string;
245
+ generatedAt: string;
246
+ inputSig: string;
247
+ mutation: {
248
+ tool: "stryker" | "mutmut" | "go-mutesting";
249
+ mutantsTotal: number;
250
+ mutantsKilled: number;
251
+ mutantsSurvived: number;
252
+ mutantsTimeout: number;
253
+ killRate: number;
254
+ byFile: {
255
+ killRate: number;
256
+ file: string;
257
+ survived: {
258
+ mutation: string;
259
+ line: number;
260
+ survivedBecause: string;
261
+ }[];
262
+ }[];
263
+ };
264
+ assertions: {
265
+ totalAssertions: number;
266
+ weakAssertions: number;
267
+ weakRate: number;
268
+ weakPatterns: {
269
+ pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
270
+ count: number;
271
+ examples: {
272
+ code: string;
273
+ file: string;
274
+ line: number;
275
+ }[];
276
+ }[];
277
+ };
278
+ thresholds: {
279
+ mutationKillRateMin: number;
280
+ weakAssertionRateMax: number;
281
+ passed: boolean;
282
+ };
283
+ followups: {
284
+ file: string;
285
+ issue: "low_kill_rate" | "high_weak_assertions";
286
+ severity: "soft" | "hard";
287
+ suggestion: string;
288
+ }[];
289
+ }, {
290
+ version: "1.0";
291
+ sha256: string;
292
+ generatedAt: string;
293
+ inputSig: string;
294
+ mutation: {
295
+ tool: "stryker" | "mutmut" | "go-mutesting";
296
+ mutantsTotal: number;
297
+ mutantsKilled: number;
298
+ mutantsSurvived: number;
299
+ mutantsTimeout: number;
300
+ killRate: number;
301
+ byFile: {
302
+ killRate: number;
303
+ file: string;
304
+ survived: {
305
+ mutation: string;
306
+ line: number;
307
+ survivedBecause: string;
308
+ }[];
309
+ }[];
310
+ };
311
+ assertions: {
312
+ totalAssertions: number;
313
+ weakAssertions: number;
314
+ weakRate: number;
315
+ weakPatterns: {
316
+ pattern: "toBeDefined" | "toBeTruthy" | "toEqual-self" | "expect-anything" | "toBe-self";
317
+ count: number;
318
+ examples: {
319
+ code: string;
320
+ file: string;
321
+ line: number;
322
+ }[];
323
+ }[];
324
+ };
325
+ thresholds: {
326
+ mutationKillRateMin: number;
327
+ weakAssertionRateMax: number;
328
+ passed: boolean;
329
+ };
330
+ followups: {
331
+ file: string;
332
+ issue: "low_kill_rate" | "high_weak_assertions";
333
+ severity: "soft" | "hard";
334
+ suggestion: string;
335
+ }[];
336
+ }>;
337
+ //# sourceMappingURL=types.d.ts.map
@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AC;IACtC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,iBAAiB,0FAE5B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+C1B,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Per spec §4.2 验收审计 + §7 阶段二 — MutReportJson v1.0.
3
+ *
4
+ * Hard constraints:
5
+ * H8 (audit trail hashable): sha256 + inputSig (chain to TACT.sig)
6
+ * H6 (CLI裁决, not LLM): passed boolean is computed by CLI, not LLM
7
+ */
8
+ import { z } from 'zod';
9
+ export const WeakPatternSchema = z.enum([
10
+ 'toBeDefined', 'toBeTruthy', 'toEqual-self', 'expect-anything', 'toBe-self',
11
+ ]);
12
+ export const MutReportSchema = z.object({
13
+ version: z.literal('1.0'),
14
+ sha256: z.string().regex(/^[a-f0-9]{64}$/),
15
+ generatedAt: z.string().datetime(),
16
+ inputSig: z.string().regex(/^[a-f0-9]{64}$/),
17
+ mutation: z.object({
18
+ tool: z.enum(['stryker', 'mutmut', 'go-mutesting']),
19
+ mutantsTotal: z.number().int().nonnegative(),
20
+ mutantsKilled: z.number().int().nonnegative(),
21
+ mutantsSurvived: z.number().int().nonnegative(),
22
+ mutantsTimeout: z.number().int().nonnegative(),
23
+ killRate: z.number().min(0).max(1),
24
+ byFile: z.array(z.object({
25
+ file: z.string(),
26
+ killRate: z.number().min(0).max(1),
27
+ survived: z.array(z.object({
28
+ line: z.number().int(),
29
+ mutation: z.string(),
30
+ survivedBecause: z.string(),
31
+ })),
32
+ })),
33
+ }),
34
+ assertions: z.object({
35
+ totalAssertions: z.number().int().nonnegative(),
36
+ weakAssertions: z.number().int().nonnegative(),
37
+ weakRate: z.number().min(0).max(1),
38
+ weakPatterns: z.array(z.object({
39
+ pattern: WeakPatternSchema,
40
+ count: z.number().int().nonnegative(),
41
+ examples: z.array(z.object({
42
+ file: z.string(),
43
+ line: z.number().int(),
44
+ code: z.string(),
45
+ })),
46
+ })),
47
+ }),
48
+ thresholds: z.object({
49
+ mutationKillRateMin: z.number().min(0).max(1),
50
+ weakAssertionRateMax: z.number().min(0).max(1),
51
+ passed: z.boolean(),
52
+ }),
53
+ followups: z.array(z.object({
54
+ file: z.string(),
55
+ issue: z.enum(['low_kill_rate', 'high_weak_assertions']),
56
+ severity: z.enum(['soft', 'hard']),
57
+ suggestion: z.string(),
58
+ })),
59
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Frontmatter parser — copy of `src/shared/frontmatter.ts` from main peaks-loop.
3
+ *
4
+ * Duplicated into peaks-loop-mut to keep this package zero-dependency on the
5
+ * main package (avoids circular workspace deps). The two files MUST stay in
6
+ * sync. If `src/shared/frontmatter.ts` changes upstream, mirror the change
7
+ * here. See `.peaks/_runtime/2026-07-17-session-1d5ac0/rd/slice-2-mut.md` §3.5
8
+ * for the duplication rationale (frontmatter is a 176-LOC pure function with
9
+ * no transitive deps; lift-into-shared-package is a future slice).
10
+ */
11
+ export type SkillFrontmatter = {
12
+ name: string;
13
+ description: string;
14
+ [key: string]: string;
15
+ };
16
+ export declare function parseFrontmatter(markdown: string): SkillFrontmatter;
17
+ //# sourceMappingURL=frontmatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../src/shared/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAiHF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CA0DnE"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Frontmatter parser — copy of `src/shared/frontmatter.ts` from main peaks-loop.
3
+ *
4
+ * Duplicated into peaks-loop-mut to keep this package zero-dependency on the
5
+ * main package (avoids circular workspace deps). The two files MUST stay in
6
+ * sync. If `src/shared/frontmatter.ts` changes upstream, mirror the change
7
+ * here. See `.peaks/_runtime/2026-07-17-session-1d5ac0/rd/slice-2-mut.md` §3.5
8
+ * for the duplication rationale (frontmatter is a 176-LOC pure function with
9
+ * no transitive deps; lift-into-shared-package is a future slice).
10
+ */
11
+ const KEY_PATTERN = /^([A-Za-z0-9_.-]+):\s*(.*)$/;
12
+ /**
13
+ * Flatten a nested YAML mapping (max 2 levels deep) into dotted keys.
14
+ * `metadata:\n appliesTo: v2.12.0+` → `metadata.appliesTo: v2.12.0+`.
15
+ * `metadata:\n sources:\n - foo\n - bar` →
16
+ * `metadata.sources: foo, bar`.
17
+ *
18
+ * Skills only use this shape for the `metadata:` block (v2.12.0
19
+ * skill-versioning contract); deeper nesting is not currently emitted.
20
+ */
21
+ function flattenNestedFrontmatter(frontmatterLines) {
22
+ const flat = [];
23
+ let i = 0;
24
+ while (i < frontmatterLines.length) {
25
+ const line = frontmatterLines[i];
26
+ if (line === undefined) {
27
+ i += 1;
28
+ continue;
29
+ }
30
+ if (line.trim().length === 0) {
31
+ flat.push(line);
32
+ i += 1;
33
+ continue;
34
+ }
35
+ const parentMatch = /^([A-Za-z0-9_-]+):\s*$/.exec(line);
36
+ if (!parentMatch || parentMatch[1] === undefined) {
37
+ flat.push(line);
38
+ i += 1;
39
+ continue;
40
+ }
41
+ const parent = parentMatch[1];
42
+ // Collect children (2nd-level keys OR list items OR a 2nd-level parent key).
43
+ const children = [];
44
+ let listItemsAtParent = [];
45
+ let grandTotalConsumed = 0;
46
+ let j = i + 1;
47
+ while (j < frontmatterLines.length) {
48
+ const childLine = frontmatterLines[j];
49
+ if (childLine === undefined || childLine.trim().length === 0)
50
+ break;
51
+ // 2nd-level parent key (e.g. " sources:") — recurse one level.
52
+ const subParentMatch = /^\s{2,}([A-Za-z0-9_-]+):\s*$/.exec(childLine);
53
+ if (subParentMatch && subParentMatch[1] !== undefined) {
54
+ const subParent = subParentMatch[1];
55
+ const subList = [];
56
+ let k = j + 1;
57
+ let subConsumed = 0;
58
+ while (k < frontmatterLines.length) {
59
+ const gcLine = frontmatterLines[k];
60
+ if (gcLine === undefined || gcLine.trim().length === 0)
61
+ break;
62
+ const li = /^\s+-\s+(.+)$/.exec(gcLine);
63
+ if (li && li[1] !== undefined) {
64
+ subList.push(li[1].trim());
65
+ subConsumed += 1;
66
+ k += 1;
67
+ continue;
68
+ }
69
+ break;
70
+ }
71
+ if (subList.length > 0) {
72
+ children.push({ key: subParent, listItems: subList, grandChildren: [] });
73
+ }
74
+ else {
75
+ // Empty sub-parent; preserve as bare key (no value).
76
+ children.push({ key: subParent, listItems: [], grandChildren: [] });
77
+ }
78
+ grandTotalConsumed += subConsumed + 1;
79
+ j = k;
80
+ continue;
81
+ }
82
+ // Direct list item under parent (no nested key).
83
+ const directList = /^\s+-\s+(.+)$/.exec(childLine);
84
+ if (directList && directList[1] !== undefined) {
85
+ listItemsAtParent.push(directList[1].trim());
86
+ grandTotalConsumed += 1;
87
+ j += 1;
88
+ continue;
89
+ }
90
+ // 2nd-level scalar key.
91
+ const scalarMatch = /^\s{2,}([A-Za-z0-9_-]+):\s*(.*)$/.exec(childLine);
92
+ if (scalarMatch && scalarMatch[1] !== undefined) {
93
+ children.push({
94
+ key: scalarMatch[1],
95
+ listItems: [],
96
+ grandChildren: [`${parent}.${scalarMatch[1]}: ${scalarMatch[2] ?? ''}`.trimEnd()]
97
+ });
98
+ grandTotalConsumed += 1;
99
+ j += 1;
100
+ continue;
101
+ }
102
+ break;
103
+ }
104
+ if (listItemsAtParent.length > 0) {
105
+ flat.push(`${parent}: ${listItemsAtParent.join(', ')}`);
106
+ }
107
+ else if (children.length > 0) {
108
+ for (const child of children) {
109
+ if (child.listItems.length > 0) {
110
+ flat.push(`${parent}.${child.key}: ${child.listItems.join(', ')}`);
111
+ }
112
+ else if (child.grandChildren.length > 0) {
113
+ for (const gc of child.grandChildren)
114
+ flat.push(gc);
115
+ }
116
+ else {
117
+ flat.push(`${parent}.${child.key}:`);
118
+ }
119
+ }
120
+ }
121
+ else {
122
+ flat.push(line);
123
+ }
124
+ i += grandTotalConsumed + 1;
125
+ }
126
+ return flat;
127
+ }
128
+ export function parseFrontmatter(markdown) {
129
+ const lines = markdown.split(/\r?\n/);
130
+ if (lines[0] !== '---') {
131
+ throw new Error('Missing YAML frontmatter opening marker');
132
+ }
133
+ const endIndex = lines.findIndex((line, index) => index > 0 && line === '---');
134
+ if (endIndex === -1) {
135
+ throw new Error('Missing YAML frontmatter closing marker');
136
+ }
137
+ const rawLines = lines.slice(1, endIndex);
138
+ const frontmatterLines = flattenNestedFrontmatter(rawLines);
139
+ const metadata = {};
140
+ for (let index = 0; index < frontmatterLines.length; index += 1) {
141
+ const line = frontmatterLines[index];
142
+ if (!line || line.trim().length === 0) {
143
+ continue;
144
+ }
145
+ const blockMatch = line.match(/^([A-Za-z0-9_-]+):\s*[|>]\s*$/);
146
+ if (blockMatch?.[1]) {
147
+ const key = blockMatch[1];
148
+ const blockLines = [];
149
+ index += 1;
150
+ while (index < frontmatterLines.length) {
151
+ const blockLine = frontmatterLines[index];
152
+ if (blockLine && /^\S[^:]*:/.test(blockLine)) {
153
+ index -= 1;
154
+ break;
155
+ }
156
+ blockLines.push(blockLine?.replace(/^\s{2}/, '') ?? '');
157
+ index += 1;
158
+ }
159
+ metadata[key] = blockLines.join('\n').trim();
160
+ continue;
161
+ }
162
+ const match = line.match(KEY_PATTERN);
163
+ if (!match?.[1]) {
164
+ throw new Error(`Invalid frontmatter line: ${line}`);
165
+ }
166
+ metadata[match[1]] = (match[2] ?? '').trim().replace(/^['"]|['"]$/g, '');
167
+ }
168
+ if (!metadata.name) {
169
+ throw new Error('Missing required frontmatter field: name');
170
+ }
171
+ if (!metadata.description) {
172
+ throw new Error('Missing required frontmatter field: description');
173
+ }
174
+ return metadata;
175
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "peaks-loop-mut",
3
+ "version": "0.0.1",
4
+ "description": "Mutation testing + assertion scanning + ECC cache for peaks-loop (workspace-internal)",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist/**"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc -p tsconfig.json",
17
+ "test": "vitest run"
18
+ },
19
+ "engines": {
20
+ "node": ">=20.0.0"
21
+ },
22
+ "dependencies": {
23
+ "zod": "^3.25.76"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ }
28
+ }