artifact-graph 0.15.0 → 0.16.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/CHANGELOG.md +19 -0
- package/INSTALL.md +9 -0
- package/README.md +6 -1
- package/README.zh-CN.md +6 -1
- package/contracts/spec/schema.json +44 -0
- package/dist/cli.js +897 -268
- package/dist/index.cjs +779 -320
- package/dist/index.d.cts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +829 -224
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -261,7 +261,22 @@ function validatePacket(packet, schema) {
|
|
|
261
261
|
const hasError = issues.some((i) => i.severity === "error");
|
|
262
262
|
return { ok: !hasError, issues };
|
|
263
263
|
}
|
|
264
|
-
|
|
264
|
+
function validatePacketMarkdown(markdown) {
|
|
265
|
+
const issues = [];
|
|
266
|
+
for (const section of REQUIRED_SECTIONS) {
|
|
267
|
+
if (!markdown.includes(section)) {
|
|
268
|
+
issues.push({
|
|
269
|
+
severity: "error",
|
|
270
|
+
code: "PKT-008",
|
|
271
|
+
message: `missing required section: "${section}"`,
|
|
272
|
+
path: "markdown"
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const hasError = issues.some((i) => i.severity === "error");
|
|
277
|
+
return { ok: !hasError, issues };
|
|
278
|
+
}
|
|
279
|
+
var MIN_VALIDATION_COMMANDS, VALID_PACKET_TARGET_TYPES, VALID_TARGET_TYPES, REQUIRED_SECTIONS;
|
|
265
280
|
var init_packet_validator = __esm({
|
|
266
281
|
"src/packet-validator.ts"() {
|
|
267
282
|
"use strict";
|
|
@@ -269,6 +284,16 @@ var init_packet_validator = __esm({
|
|
|
269
284
|
MIN_VALIDATION_COMMANDS = 4;
|
|
270
285
|
VALID_PACKET_TARGET_TYPES = ["feature", "scenario", "decision", "design", "e2e_test"];
|
|
271
286
|
VALID_TARGET_TYPES = [...VALID_PACKET_TARGET_TYPES];
|
|
287
|
+
REQUIRED_SECTIONS = [
|
|
288
|
+
"## 1. \u5B9E\u73B0\u76EE\u6807",
|
|
289
|
+
"## 2. \u4E0A\u4E0B\u6587\u6E05\u5355\u6458\u8981",
|
|
290
|
+
"## 3. Required Baseline\uFF08\u5FC5\u8BFB\u5236\u54C1\uFF09",
|
|
291
|
+
"## 8. Implementation Blueprint Draft\uFF08\u5B9E\u73B0\u84DD\u56FE\u8349\u6848\uFF09",
|
|
292
|
+
"### 8.3 \u7EA6\u675F\u4E0E\u8FB9\u754C",
|
|
293
|
+
"### 8.4 \u9A8C\u8BC1\u547D\u4EE4",
|
|
294
|
+
"### 8.5 \u63A8\u8350\u5BA1\u9605\u987A\u5E8F",
|
|
295
|
+
"### 8.6 \u98CE\u9669\u68C0\u67E5\u6E05\u5355"
|
|
296
|
+
];
|
|
272
297
|
}
|
|
273
298
|
});
|
|
274
299
|
|
|
@@ -351,6 +376,505 @@ var init_file_walker = __esm({
|
|
|
351
376
|
}
|
|
352
377
|
});
|
|
353
378
|
|
|
379
|
+
// src/doctor.ts
|
|
380
|
+
import yaml from "js-yaml";
|
|
381
|
+
import _AjvModule from "ajv";
|
|
382
|
+
import { readFile } from "fs/promises";
|
|
383
|
+
import { isAbsolute, join as join2 } from "path";
|
|
384
|
+
function getShapeValidator() {
|
|
385
|
+
if (!_validateConfigShape) {
|
|
386
|
+
const AjvCtor = _AjvModule;
|
|
387
|
+
const ajv = new AjvCtor({ allErrors: true, strict: false });
|
|
388
|
+
_validateConfigShape = ajv.compile(CONFIG_SHAPE_SCHEMA);
|
|
389
|
+
}
|
|
390
|
+
return _validateConfigShape;
|
|
391
|
+
}
|
|
392
|
+
function instancePathToField(instancePath, params) {
|
|
393
|
+
const missing = typeof params?.missingProperty === "string" ? params.missingProperty : void 0;
|
|
394
|
+
if (!instancePath || instancePath === "") {
|
|
395
|
+
return missing && missing.length > 0 ? missing : "(root)";
|
|
396
|
+
}
|
|
397
|
+
const path = instancePath.replace(/^\//, "").replace(/\//g, ".");
|
|
398
|
+
return missing && missing.length > 0 ? `${path}.${missing}` : path;
|
|
399
|
+
}
|
|
400
|
+
function pushError(errors, path, message) {
|
|
401
|
+
errors.push({ path, message, severity: "error" });
|
|
402
|
+
}
|
|
403
|
+
function warnUnknownObjectKeys(value, path, knownKeys, warnings) {
|
|
404
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return;
|
|
405
|
+
for (const key of Object.keys(value)) {
|
|
406
|
+
if (knownKeys.has(key)) continue;
|
|
407
|
+
const field = path ? `${path}.${key}` : key;
|
|
408
|
+
warnings.push({
|
|
409
|
+
path: field,
|
|
410
|
+
message: `Unknown config key ${key} at ${field}: kept for compatibility and not treated as a declared field.`,
|
|
411
|
+
severity: "warning"
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
function warnUnknownArrayObjectKeys(value, path, knownKeys, warnings) {
|
|
416
|
+
if (!Array.isArray(value)) return;
|
|
417
|
+
value.forEach((entry, index) => {
|
|
418
|
+
warnUnknownObjectKeys(entry, `${path}.${index}`, knownKeys, warnings);
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
function collectNestedUnknownKeyWarnings(document, warnings) {
|
|
422
|
+
warnUnknownObjectKeys(document, "", KNOWN_TOP_LEVEL_KEYS, warnings);
|
|
423
|
+
const types = document.types;
|
|
424
|
+
if (types && typeof types === "object" && !Array.isArray(types)) {
|
|
425
|
+
for (const [typeName, definition] of Object.entries(types)) {
|
|
426
|
+
const typePath = `types.${typeName}`;
|
|
427
|
+
warnUnknownObjectKeys(definition, typePath, TYPE_OBJECT_KEYS, warnings);
|
|
428
|
+
if (definition && typeof definition === "object" && !Array.isArray(definition)) {
|
|
429
|
+
warnUnknownArrayObjectKeys(
|
|
430
|
+
definition.extraFields,
|
|
431
|
+
`${typePath}.extraFields`,
|
|
432
|
+
EXTRA_FIELD_KEYS,
|
|
433
|
+
warnings
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
warnUnknownArrayObjectKeys(document.allowedEdges, "allowedEdges", EDGE_RULE_KEYS, warnings);
|
|
439
|
+
warnUnknownArrayObjectKeys(document.forbiddenEdges, "forbiddenEdges", EDGE_RULE_KEYS, warnings);
|
|
440
|
+
warnUnknownObjectKeys(document.context, "context", CONTEXT_KEYS, warnings);
|
|
441
|
+
const idRanges = document.idRanges;
|
|
442
|
+
if (idRanges && typeof idRanges === "object" && !Array.isArray(idRanges)) {
|
|
443
|
+
for (const [layer, ranges] of Object.entries(idRanges)) {
|
|
444
|
+
if (!ranges || typeof ranges !== "object" || Array.isArray(ranges)) continue;
|
|
445
|
+
for (const [rangeName, entry] of Object.entries(ranges)) {
|
|
446
|
+
warnUnknownObjectKeys(entry, `idRanges.${layer}.${rangeName}`, ID_RANGE_ENTRY_KEYS, warnings);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const relationSemantics = document.relationSemantics;
|
|
451
|
+
if (relationSemantics && typeof relationSemantics === "object" && !Array.isArray(relationSemantics)) {
|
|
452
|
+
for (const [kind, spec] of Object.entries(relationSemantics)) {
|
|
453
|
+
const specPath = `relationSemantics.${kind}`;
|
|
454
|
+
warnUnknownObjectKeys(spec, specPath, RELATION_SEMANTICS_KEYS, warnings);
|
|
455
|
+
if (spec && typeof spec === "object" && !Array.isArray(spec)) {
|
|
456
|
+
warnUnknownObjectKeys(
|
|
457
|
+
spec.partial,
|
|
458
|
+
`${specPath}.partial`,
|
|
459
|
+
RELATION_PARTIAL_KEYS,
|
|
460
|
+
warnings
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const e2e = document.e2e;
|
|
466
|
+
if (e2e && typeof e2e === "object" && !Array.isArray(e2e)) {
|
|
467
|
+
const e2eRecord = e2e;
|
|
468
|
+
warnUnknownObjectKeys(e2eRecord, "e2e", E2E_KEYS, warnings);
|
|
469
|
+
warnUnknownArrayObjectKeys(e2eRecord.scenario_waivers, "e2e.scenario_waivers", WAIVER_KEYS, warnings);
|
|
470
|
+
warnUnknownArrayObjectKeys(e2eRecord.feature_waivers, "e2e.feature_waivers", WAIVER_KEYS, warnings);
|
|
471
|
+
warnUnknownArrayObjectKeys(e2eRecord.runners, "e2e.runners", RUNNER_KEYS, warnings);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function typeHasDefaultPaths(typeName) {
|
|
475
|
+
const base = DEFAULT_SCHEMA.types[typeName];
|
|
476
|
+
return Array.isArray(base?.paths);
|
|
477
|
+
}
|
|
478
|
+
function collectCustomTypePathErrors(types, errors) {
|
|
479
|
+
if (types === void 0) return;
|
|
480
|
+
if (typeof types !== "object" || types === null || Array.isArray(types)) return;
|
|
481
|
+
for (const [typeName, definition] of Object.entries(types)) {
|
|
482
|
+
if (definition === void 0 || definition === null) {
|
|
483
|
+
if (!typeHasDefaultPaths(typeName)) {
|
|
484
|
+
pushError(errors, `types.${typeName}.paths`, `Invalid types.${typeName}.paths: must be array`);
|
|
485
|
+
}
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
if (typeof definition !== "object" || Array.isArray(definition)) continue;
|
|
489
|
+
const paths = definition.paths;
|
|
490
|
+
if (paths === void 0 && !typeHasDefaultPaths(typeName)) {
|
|
491
|
+
pushError(errors, `types.${typeName}.paths`, `Invalid types.${typeName}.paths: must be array`);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
function collectRelationSemanticsErrors(value, errors) {
|
|
496
|
+
if (value === void 0) return;
|
|
497
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
498
|
+
pushError(errors, "relationSemantics", "Invalid relationSemantics: must be an object keyed by relation kind.");
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
for (const [kind, spec] of Object.entries(value)) {
|
|
502
|
+
const path = `relationSemantics.${kind}`;
|
|
503
|
+
if (!kind.trim() || typeof spec !== "object" || spec === null || Array.isArray(spec)) {
|
|
504
|
+
pushError(errors, path, `Invalid relationSemantics.${kind}: must be an object.`);
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
const record = spec;
|
|
508
|
+
if (typeof record.label !== "string" || !record.label.trim()) {
|
|
509
|
+
pushError(errors, `${path}.label`, `Invalid relationSemantics.${kind}.label: must be a non-empty string.`);
|
|
510
|
+
}
|
|
511
|
+
if (!Array.isArray(record.targetTypes) || record.targetTypes.some((item) => typeof item !== "string" || !item.trim())) {
|
|
512
|
+
pushError(errors, `${path}.targetTypes`, `Invalid relationSemantics.${kind}.targetTypes: must be an array of non-empty strings.`);
|
|
513
|
+
}
|
|
514
|
+
if (!Array.isArray(record.fields) || record.fields.length === 0 || record.fields.some((item) => typeof item !== "string" || !item.trim())) {
|
|
515
|
+
pushError(errors, `${path}.fields`, `Invalid relationSemantics.${kind}.fields: must be a non-empty array of strings.`);
|
|
516
|
+
}
|
|
517
|
+
if (record.partial !== void 0 && (typeof record.partial !== "object" || record.partial === null || Array.isArray(record.partial) || typeof record.partial.sectionField !== "string" || !record.partial.sectionField.trim())) {
|
|
518
|
+
pushError(
|
|
519
|
+
errors,
|
|
520
|
+
`${path}.partial.sectionField`,
|
|
521
|
+
`Invalid relationSemantics.${kind}.partial.sectionField: must be a non-empty string.`
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
function collectStatusViewsErrors(value, errors) {
|
|
527
|
+
if (value === void 0) return;
|
|
528
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
529
|
+
pushError(errors, "statusViews", "Invalid statusViews: must be an object keyed by status.");
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
for (const [status, bucket] of Object.entries(value)) {
|
|
533
|
+
if (!status.trim() || !["current", "planned", "history"].includes(bucket)) {
|
|
534
|
+
pushError(errors, `statusViews.${status}`, `Invalid statusViews.${status}: expected current, planned, or history.`);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
function collectWaiverErrors(waivers, field, errors) {
|
|
539
|
+
if (waivers === void 0) return;
|
|
540
|
+
if (!Array.isArray(waivers)) {
|
|
541
|
+
pushError(errors, field, `Invalid ${field}: must be an array of {id, reason} objects.`);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
waivers.forEach((entry, index) => {
|
|
545
|
+
const path = `${field}.${index}`;
|
|
546
|
+
if (typeof entry !== "object" || entry === null || !("id" in entry) || !("reason" in entry)) {
|
|
547
|
+
pushError(errors, path, `Invalid ${field} entry: ${JSON.stringify(entry)}. Must be {id, reason} object.`);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
const record = entry;
|
|
551
|
+
if (typeof record.id !== "string" || !record.id.trim()) {
|
|
552
|
+
pushError(errors, `${path}.id`, `Invalid ${field} entry: id must be a non-empty string. Got: ${JSON.stringify(record.id)}`);
|
|
553
|
+
}
|
|
554
|
+
if (typeof record.reason !== "string" || !record.reason.trim()) {
|
|
555
|
+
pushError(errors, `${path}.reason`, `Invalid ${field} entry: reason must be a non-empty string. Got: ${JSON.stringify(record.reason)}`);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
function collectE2eConfigErrors(e2e, errors) {
|
|
560
|
+
if (e2e === void 0) return;
|
|
561
|
+
if (typeof e2e !== "object" || e2e === null || Array.isArray(e2e)) {
|
|
562
|
+
pushError(errors, "e2e", "Invalid e2e: must be an object.");
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
const record = e2e;
|
|
566
|
+
for (const field of ["report_uncovered_scenarios", "report_uncovered_features"]) {
|
|
567
|
+
if (record[field] !== void 0 && typeof record[field] !== "boolean") {
|
|
568
|
+
pushError(errors, `e2e.${field}`, `Invalid e2e.${field}: must be boolean.`);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
if (record.executable_ref_warning !== void 0) {
|
|
572
|
+
if (typeof record.executable_ref_warning !== "number" || record.executable_ref_warning < 0 || record.executable_ref_warning > 1) {
|
|
573
|
+
pushError(
|
|
574
|
+
errors,
|
|
575
|
+
"e2e.executable_ref_warning",
|
|
576
|
+
`Invalid e2e.executable_ref_warning: ${JSON.stringify(record.executable_ref_warning)}. Must be a number between 0 and 1.`
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if (record.executable_ref_error !== void 0) {
|
|
581
|
+
if (typeof record.executable_ref_error !== "number" || record.executable_ref_error < 0 || record.executable_ref_error > 1) {
|
|
582
|
+
pushError(
|
|
583
|
+
errors,
|
|
584
|
+
"e2e.executable_ref_error",
|
|
585
|
+
`Invalid e2e.executable_ref_error: ${JSON.stringify(record.executable_ref_error)}. Must be a number between 0 and 1.`
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
collectWaiverErrors(record.scenario_waivers, "e2e.scenario_waivers", errors);
|
|
590
|
+
collectWaiverErrors(record.feature_waivers, "e2e.feature_waivers", errors);
|
|
591
|
+
if (record.runners === void 0) return;
|
|
592
|
+
if (!Array.isArray(record.runners)) {
|
|
593
|
+
pushError(errors, "e2e.runners", "Invalid e2e.runners: must be an array.");
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
record.runners.forEach((runner, index) => {
|
|
597
|
+
const runnerPath = `e2e.runners.${index}`;
|
|
598
|
+
if (typeof runner !== "object" || runner === null) {
|
|
599
|
+
pushError(errors, runnerPath, "Invalid e2e.runners entry: must be an object.");
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
const runnerRecord = runner;
|
|
603
|
+
const name = runnerRecord.name;
|
|
604
|
+
if (typeof name !== "string" || !name.trim()) {
|
|
605
|
+
pushError(errors, `${runnerPath}.name`, "Invalid e2e.runners entry: name must be a non-empty string.");
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (typeof runnerRecord.root !== "string" || !runnerRecord.root.trim()) {
|
|
609
|
+
pushError(errors, `${runnerPath}.root`, `Invalid e2e.runners[${name}].root: must be a non-empty string.`);
|
|
610
|
+
} else {
|
|
611
|
+
if (isAbsolute(runnerRecord.root)) {
|
|
612
|
+
pushError(errors, `${runnerPath}.root`, `Invalid e2e.runners[${name}].root: "${runnerRecord.root}" must not be an absolute path.`);
|
|
613
|
+
}
|
|
614
|
+
if (runnerRecord.root.replace(/\\/g, "/").split("/").includes("..")) {
|
|
615
|
+
pushError(errors, `${runnerPath}.root`, `Invalid e2e.runners[${name}].root: "${runnerRecord.root}" must not contain ".." segments.`);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
if (!Array.isArray(runnerRecord.include) || runnerRecord.include.length === 0) {
|
|
619
|
+
pushError(errors, `${runnerPath}.include`, `Invalid e2e.runners[${name}].include: must be a non-empty array of glob patterns.`);
|
|
620
|
+
} else {
|
|
621
|
+
for (const pattern of runnerRecord.include) {
|
|
622
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
623
|
+
pushError(errors, `${runnerPath}.include`, `Invalid e2e.runners[${name}].include: pattern must be a non-empty string.`);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (runnerRecord.exclude !== void 0) {
|
|
628
|
+
if (!Array.isArray(runnerRecord.exclude)) {
|
|
629
|
+
pushError(errors, `${runnerPath}.exclude`, `Invalid e2e.runners[${name}].exclude: must be an array.`);
|
|
630
|
+
} else {
|
|
631
|
+
for (const pattern of runnerRecord.exclude) {
|
|
632
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
633
|
+
pushError(errors, `${runnerPath}.exclude`, `Invalid e2e.runners[${name}].exclude: pattern must be a non-empty string.`);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (runnerRecord.testIgnore !== void 0) {
|
|
639
|
+
if (!Array.isArray(runnerRecord.testIgnore)) {
|
|
640
|
+
pushError(errors, `${runnerPath}.testIgnore`, `Invalid e2e.runners[${name}].testIgnore: must be an array.`);
|
|
641
|
+
} else {
|
|
642
|
+
for (const pattern of runnerRecord.testIgnore) {
|
|
643
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
644
|
+
pushError(errors, `${runnerPath}.testIgnore`, `Invalid e2e.runners[${name}].testIgnore: pattern must be a non-empty string.`);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
if (runnerRecord.kind !== void 0) {
|
|
650
|
+
if (!["unit", "integration", "e2e"].includes(runnerRecord.kind)) {
|
|
651
|
+
pushError(errors, `${runnerPath}.kind`, `Invalid e2e.runners[${name}].kind: "${runnerRecord.kind}". Must be unit, integration, or e2e.`);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
function collectAllowedEdgesPresenceError(document, errors) {
|
|
657
|
+
if (!Object.prototype.hasOwnProperty.call(document, "allowedEdges")) {
|
|
658
|
+
pushError(errors, "allowedEdges", ALLOWED_EDGES_REQUIRED_MESSAGE);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
function collectExistingLoaderErrors(document, errors) {
|
|
662
|
+
collectCustomTypePathErrors(document.types, errors);
|
|
663
|
+
collectE2eConfigErrors(document.e2e, errors);
|
|
664
|
+
collectRelationSemanticsErrors(document.relationSemantics, errors);
|
|
665
|
+
collectStatusViewsErrors(document.statusViews, errors);
|
|
666
|
+
collectAllowedEdgesPresenceError(document, errors);
|
|
667
|
+
}
|
|
668
|
+
function diagnoseConfigDocument(parsed) {
|
|
669
|
+
const errors = [];
|
|
670
|
+
const warnings = [];
|
|
671
|
+
if (parsed === void 0 || parsed === null) {
|
|
672
|
+
return { errors, warnings };
|
|
673
|
+
}
|
|
674
|
+
if (typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
675
|
+
errors.push({
|
|
676
|
+
path: "(root)",
|
|
677
|
+
message: `Invalid artifact-graph.config.yaml: expected an object, got ${Array.isArray(parsed) ? "array" : typeof parsed}.`,
|
|
678
|
+
severity: "error"
|
|
679
|
+
});
|
|
680
|
+
return { errors, warnings };
|
|
681
|
+
}
|
|
682
|
+
const document = parsed;
|
|
683
|
+
const validate = getShapeValidator();
|
|
684
|
+
const valid = validate(document);
|
|
685
|
+
if (!valid) {
|
|
686
|
+
for (const err of validate.errors ?? []) {
|
|
687
|
+
const path = instancePathToField(err.instancePath, err.params);
|
|
688
|
+
errors.push({
|
|
689
|
+
path,
|
|
690
|
+
message: `Invalid ${path}: ${err.message ?? "validation error"}`,
|
|
691
|
+
severity: "error"
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
collectExistingLoaderErrors(document, errors);
|
|
696
|
+
collectNestedUnknownKeyWarnings(document, warnings);
|
|
697
|
+
return { errors, warnings };
|
|
698
|
+
}
|
|
699
|
+
async function diagnoseProjectConfig(root) {
|
|
700
|
+
const configPath = join2(root, "artifact-graph.config.yaml");
|
|
701
|
+
let raw;
|
|
702
|
+
try {
|
|
703
|
+
raw = await readFile(configPath, "utf-8");
|
|
704
|
+
} catch (error) {
|
|
705
|
+
if (error.code === "ENOENT") {
|
|
706
|
+
return { exists: false, errors: [], warnings: [] };
|
|
707
|
+
}
|
|
708
|
+
return {
|
|
709
|
+
exists: true,
|
|
710
|
+
errors: [{
|
|
711
|
+
path: "artifact-graph.config.yaml",
|
|
712
|
+
message: `Unable to read artifact-graph.config.yaml: ${error.message}`,
|
|
713
|
+
severity: "error"
|
|
714
|
+
}],
|
|
715
|
+
warnings: []
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
let document;
|
|
719
|
+
try {
|
|
720
|
+
document = yaml.load(raw) ?? {};
|
|
721
|
+
} catch (error) {
|
|
722
|
+
return {
|
|
723
|
+
exists: true,
|
|
724
|
+
errors: [{
|
|
725
|
+
path: "artifact-graph.config.yaml",
|
|
726
|
+
message: `Invalid artifact-graph.config.yaml: ${error.message}`,
|
|
727
|
+
severity: "error"
|
|
728
|
+
}],
|
|
729
|
+
warnings: []
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
const diagnosis = diagnoseConfigDocument(document);
|
|
733
|
+
return { exists: true, errors: diagnosis.errors, warnings: diagnosis.warnings };
|
|
734
|
+
}
|
|
735
|
+
var KNOWN_TOP_LEVEL_KEYS, TYPE_OBJECT_KEYS, EXTRA_FIELD_KEYS, EDGE_RULE_KEYS, CONTEXT_KEYS, ID_RANGE_ENTRY_KEYS, RELATION_SEMANTICS_KEYS, RELATION_PARTIAL_KEYS, E2E_KEYS, WAIVER_KEYS, RUNNER_KEYS, EDGE_RULE_SCHEMA, EXTRA_FIELD_SCHEMA, ID_RANGE_ENTRY_SCHEMA, CONFIG_SHAPE_SCHEMA, _validateConfigShape, ALLOWED_EDGES_REQUIRED_MESSAGE;
|
|
736
|
+
var init_doctor = __esm({
|
|
737
|
+
"src/doctor.ts"() {
|
|
738
|
+
"use strict";
|
|
739
|
+
init_index();
|
|
740
|
+
KNOWN_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
|
|
741
|
+
"types",
|
|
742
|
+
"idPatterns",
|
|
743
|
+
"relationFields",
|
|
744
|
+
"allowedEdges",
|
|
745
|
+
"forbiddenEdges",
|
|
746
|
+
"statuses",
|
|
747
|
+
"idRanges",
|
|
748
|
+
"relationSemantics",
|
|
749
|
+
"statusViews",
|
|
750
|
+
"context",
|
|
751
|
+
"e2e"
|
|
752
|
+
]);
|
|
753
|
+
TYPE_OBJECT_KEYS = /* @__PURE__ */ new Set([
|
|
754
|
+
"paths",
|
|
755
|
+
"idPattern",
|
|
756
|
+
"displayName",
|
|
757
|
+
"role",
|
|
758
|
+
"layer",
|
|
759
|
+
"aliases",
|
|
760
|
+
"target",
|
|
761
|
+
"extraFields",
|
|
762
|
+
"format",
|
|
763
|
+
"idField"
|
|
764
|
+
]);
|
|
765
|
+
EXTRA_FIELD_KEYS = /* @__PURE__ */ new Set(["name", "type", "enum"]);
|
|
766
|
+
EDGE_RULE_KEYS = /* @__PURE__ */ new Set(["from", "to", "kind"]);
|
|
767
|
+
CONTEXT_KEYS = /* @__PURE__ */ new Set(["universal_baseline"]);
|
|
768
|
+
ID_RANGE_ENTRY_KEYS = /* @__PURE__ */ new Set(["prefix", "start", "end"]);
|
|
769
|
+
RELATION_SEMANTICS_KEYS = /* @__PURE__ */ new Set(["label", "targetTypes", "fields", "partial"]);
|
|
770
|
+
RELATION_PARTIAL_KEYS = /* @__PURE__ */ new Set(["sectionField"]);
|
|
771
|
+
E2E_KEYS = /* @__PURE__ */ new Set([
|
|
772
|
+
"executable_ref_warning",
|
|
773
|
+
"executable_ref_error",
|
|
774
|
+
"report_uncovered_scenarios",
|
|
775
|
+
"report_uncovered_features",
|
|
776
|
+
"scenario_waivers",
|
|
777
|
+
"feature_waivers",
|
|
778
|
+
"runners"
|
|
779
|
+
]);
|
|
780
|
+
WAIVER_KEYS = /* @__PURE__ */ new Set(["id", "reason"]);
|
|
781
|
+
RUNNER_KEYS = /* @__PURE__ */ new Set(["name", "kind", "root", "include", "exclude", "testIgnore"]);
|
|
782
|
+
EDGE_RULE_SCHEMA = {
|
|
783
|
+
type: "object",
|
|
784
|
+
additionalProperties: true,
|
|
785
|
+
required: ["from", "to", "kind"],
|
|
786
|
+
properties: {
|
|
787
|
+
from: { type: "string", minLength: 1 },
|
|
788
|
+
to: { type: "string", minLength: 1 },
|
|
789
|
+
kind: { type: "string", minLength: 1 }
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
EXTRA_FIELD_SCHEMA = {
|
|
793
|
+
type: "object",
|
|
794
|
+
additionalProperties: true,
|
|
795
|
+
required: ["name", "type"],
|
|
796
|
+
properties: {
|
|
797
|
+
name: { type: "string", minLength: 1 },
|
|
798
|
+
type: { type: "string", enum: ["string", "number", "boolean", "enum"] },
|
|
799
|
+
enum: {
|
|
800
|
+
type: "array",
|
|
801
|
+
items: {
|
|
802
|
+
anyOf: [
|
|
803
|
+
{ type: "string" },
|
|
804
|
+
{ type: "number" },
|
|
805
|
+
{ type: "boolean" }
|
|
806
|
+
]
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
ID_RANGE_ENTRY_SCHEMA = {
|
|
812
|
+
type: "object",
|
|
813
|
+
additionalProperties: true,
|
|
814
|
+
required: ["prefix", "start", "end"],
|
|
815
|
+
properties: {
|
|
816
|
+
prefix: { type: "string" },
|
|
817
|
+
start: { type: "number" },
|
|
818
|
+
end: { type: "number" }
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
CONFIG_SHAPE_SCHEMA = {
|
|
822
|
+
type: "object",
|
|
823
|
+
additionalProperties: true,
|
|
824
|
+
properties: {
|
|
825
|
+
statuses: { type: "array", items: { type: "string" } },
|
|
826
|
+
allowedEdges: {
|
|
827
|
+
anyOf: [
|
|
828
|
+
{ type: "null" },
|
|
829
|
+
{ type: "array", items: EDGE_RULE_SCHEMA }
|
|
830
|
+
]
|
|
831
|
+
},
|
|
832
|
+
forbiddenEdges: { type: "array", items: EDGE_RULE_SCHEMA },
|
|
833
|
+
idPatterns: {
|
|
834
|
+
type: "object",
|
|
835
|
+
additionalProperties: { type: "string" }
|
|
836
|
+
},
|
|
837
|
+
relationFields: {
|
|
838
|
+
type: "object",
|
|
839
|
+
additionalProperties: { type: "array", items: { type: "string" } }
|
|
840
|
+
},
|
|
841
|
+
context: {
|
|
842
|
+
type: "object",
|
|
843
|
+
additionalProperties: true,
|
|
844
|
+
properties: {
|
|
845
|
+
universal_baseline: { type: "boolean" }
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
idRanges: {
|
|
849
|
+
type: "object",
|
|
850
|
+
additionalProperties: {
|
|
851
|
+
type: "object",
|
|
852
|
+
additionalProperties: ID_RANGE_ENTRY_SCHEMA
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
types: {
|
|
856
|
+
type: "object",
|
|
857
|
+
additionalProperties: {
|
|
858
|
+
type: "object",
|
|
859
|
+
additionalProperties: true,
|
|
860
|
+
properties: {
|
|
861
|
+
paths: { type: "array", items: { type: "string" } },
|
|
862
|
+
idPattern: { type: "string" },
|
|
863
|
+
displayName: { type: "string" },
|
|
864
|
+
role: { type: "string" },
|
|
865
|
+
layer: { type: "string" },
|
|
866
|
+
aliases: { type: "array", items: { type: "string" } },
|
|
867
|
+
target: { type: "boolean" },
|
|
868
|
+
extraFields: { type: "array", items: EXTRA_FIELD_SCHEMA }
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
ALLOWED_EDGES_REQUIRED_MESSAGE = "Invalid allowedEdges: field is required. Use allowedEdges: [] or allowedEdges: null to adopt the built-in DEFAULT_SCHEMA.allowedEdges, or list explicit {from, to, kind} triples as a strict whitelist that replaces the default table.";
|
|
875
|
+
}
|
|
876
|
+
});
|
|
877
|
+
|
|
354
878
|
// src/target-selector.ts
|
|
355
879
|
function parseTargetSelector(value) {
|
|
356
880
|
const separator = value.indexOf(":");
|
|
@@ -483,8 +1007,8 @@ var init_git_changes = __esm({
|
|
|
483
1007
|
// src/versioned-traceability.ts
|
|
484
1008
|
import { createHash } from "crypto";
|
|
485
1009
|
import { existsSync } from "fs";
|
|
486
|
-
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
487
|
-
import { dirname, join as
|
|
1010
|
+
import { mkdir, readFile as readFile2, writeFile } from "fs/promises";
|
|
1011
|
+
import { dirname, join as join3, relative as relative2 } from "path";
|
|
488
1012
|
async function buildVersionIndex(root, graph) {
|
|
489
1013
|
const scannedGraph = graph ?? await scanArtifacts(root);
|
|
490
1014
|
const hashCache = /* @__PURE__ */ new Map();
|
|
@@ -620,7 +1144,7 @@ async function auditVersionLock(root, lockPath = VERSION_LOCK_PATH, graph, confi
|
|
|
620
1144
|
for (const entry of lock.locks) {
|
|
621
1145
|
if (entry.kind !== "verifies") continue;
|
|
622
1146
|
const sourcePath = entry.source.path;
|
|
623
|
-
const fullSourcePath =
|
|
1147
|
+
const fullSourcePath = join3(root, sourcePath);
|
|
624
1148
|
if (!existsSync(fullSourcePath)) continue;
|
|
625
1149
|
let liveness = livenessCache.get(sourcePath);
|
|
626
1150
|
if (liveness === void 0) {
|
|
@@ -715,14 +1239,14 @@ async function auditVersionLock(root, lockPath = VERSION_LOCK_PATH, graph, confi
|
|
|
715
1239
|
currentArtifactHash: targetNode.contentHash
|
|
716
1240
|
});
|
|
717
1241
|
}
|
|
718
|
-
if (!existsSync(
|
|
1242
|
+
if (!existsSync(join3(root, sourceNode.path))) {
|
|
719
1243
|
entryIssues.push({
|
|
720
1244
|
status: "orphan_lock",
|
|
721
1245
|
edgeId: relEdgeId,
|
|
722
1246
|
message: `Artifact relation source file ${sourceNode.path} no longer exists`
|
|
723
1247
|
});
|
|
724
1248
|
}
|
|
725
|
-
if (!existsSync(
|
|
1249
|
+
if (!existsSync(join3(root, targetNode.path))) {
|
|
726
1250
|
entryIssues.push({
|
|
727
1251
|
status: "orphan_lock",
|
|
728
1252
|
edgeId: relEdgeId,
|
|
@@ -1329,7 +1853,7 @@ function renderTraceVersionMarkdown(result) {
|
|
|
1329
1853
|
async function readVersionLock(root, lockPath) {
|
|
1330
1854
|
const safeLockPath = normalizeRelativePath(root, lockPath);
|
|
1331
1855
|
try {
|
|
1332
|
-
const raw = await
|
|
1856
|
+
const raw = await readFile2(join3(root, safeLockPath), "utf-8");
|
|
1333
1857
|
let parsed;
|
|
1334
1858
|
try {
|
|
1335
1859
|
parsed = JSON.parse(raw);
|
|
@@ -1488,7 +2012,7 @@ function requireSafeRelativePath(value, path) {
|
|
|
1488
2012
|
}
|
|
1489
2013
|
async function writeVersionLock(root, lockPath, lock) {
|
|
1490
2014
|
const safeLockPath = normalizeRelativePath(root, lockPath);
|
|
1491
|
-
const fullPath =
|
|
2015
|
+
const fullPath = join3(root, safeLockPath);
|
|
1492
2016
|
await mkdir(dirname(fullPath), { recursive: true });
|
|
1493
2017
|
await writeFile(fullPath, `${JSON.stringify(lock, null, 2)}
|
|
1494
2018
|
`);
|
|
@@ -1671,7 +2195,7 @@ async function hashRelativePath(root, path, cache) {
|
|
|
1671
2195
|
const normalized = normalizeRelativePath(root, path);
|
|
1672
2196
|
const cached = cache.get(normalized);
|
|
1673
2197
|
if (cached) return cached;
|
|
1674
|
-
const content = await
|
|
2198
|
+
const content = await readFile2(join3(root, normalized));
|
|
1675
2199
|
const hash = `sha256:${createHash("sha256").update(content).digest("hex")}`;
|
|
1676
2200
|
cache.set(normalized, hash);
|
|
1677
2201
|
return hash;
|
|
@@ -1694,10 +2218,10 @@ async function getTestFileRunnerLiveness(root, filePath, config) {
|
|
|
1694
2218
|
if (!/e2e/i.test(filePath) && !/\.e2e\./i.test(filePath)) {
|
|
1695
2219
|
return "active";
|
|
1696
2220
|
}
|
|
1697
|
-
const fullSourcePath =
|
|
2221
|
+
const fullSourcePath = join3(root, filePath);
|
|
1698
2222
|
if (!existsSync(fullSourcePath)) return "inactive";
|
|
1699
2223
|
try {
|
|
1700
|
-
const content = await
|
|
2224
|
+
const content = await readFile2(fullSourcePath, "utf-8");
|
|
1701
2225
|
return /\/\/!?\s*@(?:e2e_test|tc)\s+/.test(content) ? "active" : "inactive";
|
|
1702
2226
|
} catch {
|
|
1703
2227
|
return "inactive";
|
|
@@ -1760,7 +2284,7 @@ var init_versioned_traceability = __esm({
|
|
|
1760
2284
|
});
|
|
1761
2285
|
|
|
1762
2286
|
// src/impact.ts
|
|
1763
|
-
import { isAbsolute, normalize, relative as relative3, resolve } from "path";
|
|
2287
|
+
import { isAbsolute as isAbsolute2, normalize, relative as relative3, resolve } from "path";
|
|
1764
2288
|
async function computeImpact(root, options = {}) {
|
|
1765
2289
|
const absoluteRoot = resolve(root);
|
|
1766
2290
|
const mode = options.mode ?? "worktree";
|
|
@@ -1834,7 +2358,7 @@ function normalizeExplicitPaths(root, paths) {
|
|
|
1834
2358
|
const normalized = paths.map((input) => {
|
|
1835
2359
|
const value = input.trim();
|
|
1836
2360
|
if (!value) return "";
|
|
1837
|
-
const absolutePath =
|
|
2361
|
+
const absolutePath = isAbsolute2(value) ? normalize(value) : resolve(root, value);
|
|
1838
2362
|
const projectRelative = relative3(root, absolutePath);
|
|
1839
2363
|
const result = projectRelative.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
1840
2364
|
if (result === ".." || result.startsWith("../") || result.startsWith("/")) {
|
|
@@ -2453,7 +2977,7 @@ var init_packet_assembler = __esm({
|
|
|
2453
2977
|
|
|
2454
2978
|
// src/packet-audit.ts
|
|
2455
2979
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
2456
|
-
import { join as
|
|
2980
|
+
import { join as join4 } from "path";
|
|
2457
2981
|
function parseTargetsFile(content, schema) {
|
|
2458
2982
|
const validTypes = schema ? new Set(getTargetArtifactTypes(schema)) : VALID_TYPES;
|
|
2459
2983
|
const validTypesLabel = [...validTypes].join(", ");
|
|
@@ -2544,7 +3068,7 @@ async function auditSingleTarget(target, graph, options) {
|
|
|
2544
3068
|
const fmt = options.format ?? "markdown";
|
|
2545
3069
|
const ext = fmt === "json" ? "json" : "md";
|
|
2546
3070
|
const filename = `${target.type}-${target.id}.packet.${ext}`;
|
|
2547
|
-
const outPath =
|
|
3071
|
+
const outPath = join4(options.outDir, filename);
|
|
2548
3072
|
let content;
|
|
2549
3073
|
if (fmt === "json") {
|
|
2550
3074
|
content = JSON.stringify(packet, null, 2) + "\n";
|
|
@@ -2624,7 +3148,7 @@ async function auditPackets(root, targets, options, graph) {
|
|
|
2624
3148
|
...isCompact ? { summaryDetail: "compact", countsByType } : {}
|
|
2625
3149
|
};
|
|
2626
3150
|
if (options.outDir) {
|
|
2627
|
-
const summaryPath =
|
|
3151
|
+
const summaryPath = join4(options.outDir, "summary.json");
|
|
2628
3152
|
await writeFile2(summaryPath, JSON.stringify(summary, null, 2) + "\n", "utf-8");
|
|
2629
3153
|
}
|
|
2630
3154
|
return summary;
|
|
@@ -2995,7 +3519,7 @@ var init_packet_prompt_validator = __esm({
|
|
|
2995
3519
|
// src/native-binding-diagnostics.ts
|
|
2996
3520
|
import { existsSync as existsSync2, readdirSync } from "fs";
|
|
2997
3521
|
import { createRequire } from "module";
|
|
2998
|
-
import { dirname as dirname2, join as
|
|
3522
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
2999
3523
|
import { fileURLToPath } from "url";
|
|
3000
3524
|
function parsePnpmVersion(stdout) {
|
|
3001
3525
|
const trimmed = stdout.trim();
|
|
@@ -3136,7 +3660,7 @@ function buildNativeBindingSuccessDiagnostic(probeContext) {
|
|
|
3136
3660
|
function findPackageRoot(anchorFile) {
|
|
3137
3661
|
let dir = dirname2(anchorFile);
|
|
3138
3662
|
for (; ; ) {
|
|
3139
|
-
if (existsSync2(
|
|
3663
|
+
if (existsSync2(join5(dir, "package.json"))) return dir;
|
|
3140
3664
|
const parent = dirname2(dir);
|
|
3141
3665
|
if (parent === dir) return void 0;
|
|
3142
3666
|
dir = parent;
|
|
@@ -3174,9 +3698,9 @@ function abiPrebuiltHint(detail) {
|
|
|
3174
3698
|
return match ? `\uFF1Bprebuilt \u76EE\u6807 NODE_MODULE_VERSION=${match[1]}` : "";
|
|
3175
3699
|
}
|
|
3176
3700
|
function betterSqlite3PackagePresent(root) {
|
|
3177
|
-
const direct =
|
|
3701
|
+
const direct = join5(root, "node_modules", "better-sqlite3", "package.json");
|
|
3178
3702
|
if (existsSync2(direct)) return true;
|
|
3179
|
-
const pnpmDir =
|
|
3703
|
+
const pnpmDir = join5(root, "node_modules", ".pnpm");
|
|
3180
3704
|
let entries;
|
|
3181
3705
|
try {
|
|
3182
3706
|
entries = readdirSync(pnpmDir);
|
|
@@ -3185,7 +3709,7 @@ function betterSqlite3PackagePresent(root) {
|
|
|
3185
3709
|
}
|
|
3186
3710
|
return entries.some((entry) => {
|
|
3187
3711
|
if (!entry.startsWith("better-sqlite3@")) return false;
|
|
3188
|
-
return existsSync2(
|
|
3712
|
+
return existsSync2(join5(pnpmDir, entry, "node_modules", "better-sqlite3", "package.json"));
|
|
3189
3713
|
});
|
|
3190
3714
|
}
|
|
3191
3715
|
var PNPM_ALLOW_BUILDS_SNIPPET;
|
|
@@ -3200,7 +3724,7 @@ var init_native_binding_diagnostics = __esm({
|
|
|
3200
3724
|
import { execFile as execFile2 } from "child_process";
|
|
3201
3725
|
import { constants, readFileSync, realpathSync } from "fs";
|
|
3202
3726
|
import { access } from "fs/promises";
|
|
3203
|
-
import { basename, dirname as dirname3, isAbsolute as
|
|
3727
|
+
import { basename, dirname as dirname3, isAbsolute as isAbsolute3, join as join6, resolve as resolve3 } from "path";
|
|
3204
3728
|
import { promisify as promisify2 } from "util";
|
|
3205
3729
|
async function resolveArtifactGraphCli(root, options = {}) {
|
|
3206
3730
|
const pathCli = await findCommandOnPath("artifact-graph");
|
|
@@ -3208,7 +3732,7 @@ async function resolveArtifactGraphCli(root, options = {}) {
|
|
|
3208
3732
|
const candidates = [
|
|
3209
3733
|
{
|
|
3210
3734
|
source: "node_modules",
|
|
3211
|
-
path:
|
|
3735
|
+
path: join6(root, "node_modules/.bin/artifact-graph"),
|
|
3212
3736
|
exists: false
|
|
3213
3737
|
},
|
|
3214
3738
|
{
|
|
@@ -3241,8 +3765,8 @@ async function resolveArtifactGraphCli(root, options = {}) {
|
|
|
3241
3765
|
}
|
|
3242
3766
|
async function doctorArtifactChain(root, options = {}) {
|
|
3243
3767
|
const cli = await resolveArtifactGraphCli(root, options);
|
|
3244
|
-
const configPath =
|
|
3245
|
-
const lockPath =
|
|
3768
|
+
const configPath = join6(root, "artifact-graph.config.yaml");
|
|
3769
|
+
const lockPath = join6(root, VERSION_LOCK_PATH);
|
|
3246
3770
|
const supportedCommands = cli.path ? await detectSupportedCommands(cli.path) : [];
|
|
3247
3771
|
const nodeCompatible = isNodeCompatible(process.versions.node);
|
|
3248
3772
|
const pnpmVersion = await detectPnpmVersion();
|
|
@@ -3262,12 +3786,28 @@ async function doctorArtifactChain(root, options = {}) {
|
|
|
3262
3786
|
probedFrom
|
|
3263
3787
|
};
|
|
3264
3788
|
const nativeBinding = probe.ok ? { ok: true, ...buildNativeBindingSuccessDiagnostic(probeContext) } : { ok: false, ...buildNativeBindingDiagnostic(probe, probeContext) };
|
|
3789
|
+
const configDiagnosis = await diagnoseProjectConfig(root);
|
|
3790
|
+
const configShapeMessages = [
|
|
3791
|
+
...configDiagnosis.errors.map((item) => item.message),
|
|
3792
|
+
...configDiagnosis.warnings.map((item) => item.message)
|
|
3793
|
+
];
|
|
3794
|
+
const loadConfigMessages = [];
|
|
3795
|
+
if (configDiagnosis.exists && configDiagnosis.errors.length === 0) {
|
|
3796
|
+
try {
|
|
3797
|
+
const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_index(), index_exports));
|
|
3798
|
+
await loadConfig2(root);
|
|
3799
|
+
} catch (error) {
|
|
3800
|
+
loadConfigMessages.push(error.message);
|
|
3801
|
+
}
|
|
3802
|
+
}
|
|
3265
3803
|
const warnings = [
|
|
3266
3804
|
...cli.warnings,
|
|
3267
3805
|
...nodeCompatible ? [] : [`Node.js ${process.versions.node} does not satisfy ${REQUIRED_NODE_VERSION}.`],
|
|
3268
3806
|
...probe.ok ? [] : [
|
|
3269
3807
|
`better-sqlite3 binding probe FAILED at stage "${probe.failedStage}" (cause ${probe.cause}): ${probe.suggestion}`
|
|
3270
|
-
]
|
|
3808
|
+
],
|
|
3809
|
+
...configShapeMessages,
|
|
3810
|
+
...loadConfigMessages
|
|
3271
3811
|
];
|
|
3272
3812
|
return {
|
|
3273
3813
|
schemaVersion: "1.0",
|
|
@@ -3377,7 +3917,7 @@ async function findCommandOnPath(command) {
|
|
|
3377
3917
|
}
|
|
3378
3918
|
}
|
|
3379
3919
|
function resolveCandidatePath(root, candidatePath) {
|
|
3380
|
-
return
|
|
3920
|
+
return isAbsolute3(candidatePath) ? candidatePath : resolve3(root, candidatePath);
|
|
3381
3921
|
}
|
|
3382
3922
|
function isNodeCompatible(version) {
|
|
3383
3923
|
const match = /^(\d+)\.(\d+)\.(\d+)(?:\+[0-9A-Za-z.-]+)?$/.exec(version);
|
|
@@ -3447,6 +3987,7 @@ var init_cli_resolver = __esm({
|
|
|
3447
3987
|
"src/cli-resolver.ts"() {
|
|
3448
3988
|
"use strict";
|
|
3449
3989
|
init_versioned_traceability();
|
|
3990
|
+
init_doctor();
|
|
3450
3991
|
init_native_binding_diagnostics();
|
|
3451
3992
|
execFileAsync2 = promisify2(execFile2);
|
|
3452
3993
|
REQUIRED_NODE_VERSION = ">=22.22.2 <23";
|
|
@@ -3478,7 +4019,7 @@ var init_cli_resolver = __esm({
|
|
|
3478
4019
|
|
|
3479
4020
|
// src/git-hook-path.ts
|
|
3480
4021
|
import { execFile as execFile3 } from "child_process";
|
|
3481
|
-
import { isAbsolute as
|
|
4022
|
+
import { isAbsolute as isAbsolute4, resolve as resolve4 } from "path";
|
|
3482
4023
|
import { promisify as promisify3 } from "util";
|
|
3483
4024
|
async function resolveGitHookPath(root, hookName) {
|
|
3484
4025
|
const { stdout } = await execFileAsync3("git", [
|
|
@@ -3490,7 +4031,7 @@ async function resolveGitHookPath(root, hookName) {
|
|
|
3490
4031
|
]);
|
|
3491
4032
|
const value = stdout.trim();
|
|
3492
4033
|
if (!value) throw new Error(`Git returned an empty hook path for ${hookName}`);
|
|
3493
|
-
return
|
|
4034
|
+
return isAbsolute4(value) ? resolve4(value) : resolve4(root, value);
|
|
3494
4035
|
}
|
|
3495
4036
|
var execFileAsync3;
|
|
3496
4037
|
var init_git_hook_path = __esm({
|
|
@@ -3504,7 +4045,7 @@ var init_git_hook_path = __esm({
|
|
|
3504
4045
|
import { constants as constants2 } from "fs";
|
|
3505
4046
|
import { randomUUID } from "crypto";
|
|
3506
4047
|
import { lstat, mkdir as mkdir3, open, readlink, rename, unlink } from "fs/promises";
|
|
3507
|
-
import { basename as basename2, dirname as dirname4, join as
|
|
4048
|
+
import { basename as basename2, dirname as dirname4, join as join7 } from "path";
|
|
3508
4049
|
function detectHookInterpreter(content) {
|
|
3509
4050
|
if (content.trim().length === 0) {
|
|
3510
4051
|
return "empty";
|
|
@@ -3610,6 +4151,10 @@ async function applyPreparedManagedHookBlocks(prepared) {
|
|
|
3610
4151
|
throw error;
|
|
3611
4152
|
}
|
|
3612
4153
|
}
|
|
4154
|
+
async function installManagedHookBlock(options) {
|
|
4155
|
+
const prepared = await prepareManagedHookBlock(options);
|
|
4156
|
+
return (await applyPreparedManagedHookBlocks([prepared]))[0];
|
|
4157
|
+
}
|
|
3613
4158
|
function beginMarker(markerId) {
|
|
3614
4159
|
return `# >>> ${markerId} managed block >>>`;
|
|
3615
4160
|
}
|
|
@@ -3812,7 +4357,7 @@ async function removeHookAtomically(hookPath, snapshot) {
|
|
|
3812
4357
|
}
|
|
3813
4358
|
async function writeHookAtomically(hookPath, content, snapshot, mode) {
|
|
3814
4359
|
await mkdir3(dirname4(hookPath), { recursive: true });
|
|
3815
|
-
const temporaryPath =
|
|
4360
|
+
const temporaryPath = join7(dirname4(hookPath), `.${basename2(hookPath)}.${randomUUID()}.tmp`);
|
|
3816
4361
|
let temporaryExists = false;
|
|
3817
4362
|
try {
|
|
3818
4363
|
const temporary = await open(temporaryPath, "wx", mode);
|
|
@@ -3930,7 +4475,7 @@ var init_hook_installer = __esm({
|
|
|
3930
4475
|
// src/professional-conclusion.ts
|
|
3931
4476
|
import { access as access2 } from "fs/promises";
|
|
3932
4477
|
import { createRequire as createRequire2 } from "module";
|
|
3933
|
-
import { basename as basename3, dirname as dirname5, isAbsolute as
|
|
4478
|
+
import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute5, join as join8, resolve as resolve5 } from "path";
|
|
3934
4479
|
import { pathToFileURL } from "url";
|
|
3935
4480
|
async function loadContracts() {
|
|
3936
4481
|
return await import(CONTRACTS_PACKAGE_NAME);
|
|
@@ -3957,7 +4502,7 @@ function harnessKind(error) {
|
|
|
3957
4502
|
return typeof details?.kind === "string" ? details.kind : void 0;
|
|
3958
4503
|
}
|
|
3959
4504
|
async function missingRequiredConfig(root) {
|
|
3960
|
-
const configPath =
|
|
4505
|
+
const configPath = join8(root, "artifact-graph.config.yaml");
|
|
3961
4506
|
try {
|
|
3962
4507
|
await access2(configPath);
|
|
3963
4508
|
return void 0;
|
|
@@ -4130,7 +4675,7 @@ async function assertConclusionShape(conclusion) {
|
|
|
4130
4675
|
}
|
|
4131
4676
|
}
|
|
4132
4677
|
async function publishConclusion(absoluteOutput, conclusion) {
|
|
4133
|
-
if (!
|
|
4678
|
+
if (!isAbsolute5(absoluteOutput)) {
|
|
4134
4679
|
return "--conclusion-output must be an absolute path";
|
|
4135
4680
|
}
|
|
4136
4681
|
const outputRoot = dirname5(absoluteOutput);
|
|
@@ -4168,7 +4713,7 @@ async function runCheckProfessional(options) {
|
|
|
4168
4713
|
if (options.conclusionOutput === void 0) {
|
|
4169
4714
|
return { conclusion };
|
|
4170
4715
|
}
|
|
4171
|
-
if (!
|
|
4716
|
+
if (!isAbsolute5(options.conclusionOutput)) {
|
|
4172
4717
|
return { conclusion, writeError: "--conclusion-output must be an absolute path" };
|
|
4173
4718
|
}
|
|
4174
4719
|
const writeError = await publishConclusion(resolve5(options.conclusionOutput), conclusion);
|
|
@@ -4649,9 +5194,9 @@ __export(contract_kernel_exports, {
|
|
|
4649
5194
|
verifyDigest: () => verifyDigest
|
|
4650
5195
|
});
|
|
4651
5196
|
import { createHash as createHash2 } from "crypto";
|
|
4652
|
-
import { readFile as
|
|
4653
|
-
import { join as
|
|
4654
|
-
import
|
|
5197
|
+
import { readFile as readFile3, readdir as readdir2 } from "fs/promises";
|
|
5198
|
+
import { join as join9 } from "path";
|
|
5199
|
+
import _AjvModule2 from "ajv";
|
|
4655
5200
|
function isOfficialNamespace(namespace) {
|
|
4656
5201
|
return OFFICIAL_NAMESPACE_PATTERN.test(namespace);
|
|
4657
5202
|
}
|
|
@@ -5012,7 +5557,7 @@ function applyProjectPolicy(policy, baseContract) {
|
|
|
5012
5557
|
};
|
|
5013
5558
|
}
|
|
5014
5559
|
async function loadContract(contractPath, options) {
|
|
5015
|
-
const rawContent = await
|
|
5560
|
+
const rawContent = await readFile3(contractPath, "utf-8");
|
|
5016
5561
|
let schema;
|
|
5017
5562
|
try {
|
|
5018
5563
|
schema = JSON.parse(rawContent);
|
|
@@ -5063,7 +5608,7 @@ async function loadContractsFromDirectory(contractsDir, options) {
|
|
|
5063
5608
|
const entries = await readdir2(contractsDir, { withFileTypes: true });
|
|
5064
5609
|
for (const entry of entries) {
|
|
5065
5610
|
if (entry.isDirectory()) {
|
|
5066
|
-
const schemaPath =
|
|
5611
|
+
const schemaPath = join9(contractsDir, entry.name, "schema.json");
|
|
5067
5612
|
const contract = await loadContract(schemaPath, options);
|
|
5068
5613
|
contracts.push(contract);
|
|
5069
5614
|
}
|
|
@@ -5073,7 +5618,7 @@ async function loadContractsFromDirectory(contractsDir, options) {
|
|
|
5073
5618
|
function getValidator(schema) {
|
|
5074
5619
|
const key = `${schema.$id || "default"}#${computeRevisionDigest(JSON.stringify(schema))}`;
|
|
5075
5620
|
if (!_validatorCache.has(key)) {
|
|
5076
|
-
const AjvCtor =
|
|
5621
|
+
const AjvCtor = _AjvModule2;
|
|
5077
5622
|
const ajv = new AjvCtor({ allErrors: true, strict: false });
|
|
5078
5623
|
_validatorCache.set(key, ajv.compile(schema));
|
|
5079
5624
|
}
|
|
@@ -5655,7 +6200,7 @@ var init_restructure_software = __esm({
|
|
|
5655
6200
|
// src/restructure-file-set.ts
|
|
5656
6201
|
import { createHash as createHash3 } from "crypto";
|
|
5657
6202
|
import { chmod, lstat as lstat2, mkdir as mkdir4, realpath, statfs } from "fs/promises";
|
|
5658
|
-
import { join as
|
|
6203
|
+
import { join as join10, resolve as resolve6 } from "path";
|
|
5659
6204
|
async function loadFoundationModule() {
|
|
5660
6205
|
return await import(FOUNDATION_PACKAGE_NAME);
|
|
5661
6206
|
}
|
|
@@ -5752,7 +6297,7 @@ async function qualifyRestructureMechanism(root) {
|
|
|
5752
6297
|
return { ok: true, data: { root: canonical.data, filesystem: RESTRUCTURE_QUALIFIED_FILESYSTEM } };
|
|
5753
6298
|
}
|
|
5754
6299
|
async function ensureRestructureMechanismRoot(canonicalRoot, options) {
|
|
5755
|
-
const target =
|
|
6300
|
+
const target = join10(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH);
|
|
5756
6301
|
const current = async () => lstat2(target).catch((cause) => cause.code === "ENOENT" ? null : Promise.reject(cause));
|
|
5757
6302
|
let info = await current();
|
|
5758
6303
|
if (info === null) {
|
|
@@ -5866,7 +6411,7 @@ async function applyRestructureFileSet(canonicalRoot, plan, options) {
|
|
|
5866
6411
|
return await verifyMechanismResult(raw);
|
|
5867
6412
|
}
|
|
5868
6413
|
async function observeRestructureJournal(canonicalRoot) {
|
|
5869
|
-
const journalRoot =
|
|
6414
|
+
const journalRoot = join10(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH, "journal");
|
|
5870
6415
|
const module = await loadFoundationModule();
|
|
5871
6416
|
try {
|
|
5872
6417
|
return { ok: true, data: await module.inspectStateStoreLock(journalRoot, { recoveryObservation: true }) };
|
|
@@ -6093,8 +6638,8 @@ __export(restructure_exports, {
|
|
|
6093
6638
|
restructureBoundaryFindings: () => restructureBoundaryFindings
|
|
6094
6639
|
});
|
|
6095
6640
|
import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
|
|
6096
|
-
import { lstat as lstat3, readFile as
|
|
6097
|
-
import { dirname as dirname6, isAbsolute as
|
|
6641
|
+
import { lstat as lstat3, readFile as readFile4, readdir as readdir3, realpath as realpath2, stat } from "fs/promises";
|
|
6642
|
+
import { dirname as dirname6, isAbsolute as isAbsolute6, join as join11, posix, relative as relative4, resolve as resolve7 } from "path";
|
|
6098
6643
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
6099
6644
|
function digestBytes(value) {
|
|
6100
6645
|
return `sha256:${createHash4("sha256").update(value).digest("hex")}`;
|
|
@@ -6110,7 +6655,7 @@ function digestRestructureValue(value) {
|
|
|
6110
6655
|
return digestBytes(canonicalJson(value));
|
|
6111
6656
|
}
|
|
6112
6657
|
function normalizeRelativePath2(value) {
|
|
6113
|
-
if (!value || value.includes("\0") ||
|
|
6658
|
+
if (!value || value.includes("\0") || isAbsolute6(value)) return void 0;
|
|
6114
6659
|
const normalized = value.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
6115
6660
|
if (!normalized || normalized === "." || normalized.split("/").some((part) => part === ".." || part === "")) return void 0;
|
|
6116
6661
|
return normalized;
|
|
@@ -6130,7 +6675,7 @@ async function readContainedFileWithMode(root, path) {
|
|
|
6130
6675
|
try {
|
|
6131
6676
|
const info = await lstat3(absolutePath);
|
|
6132
6677
|
if (info.isSymbolicLink() || !info.isFile()) throw new Error(`Path is not a regular file: ${path}`);
|
|
6133
|
-
return { buffer: await
|
|
6678
|
+
return { buffer: await readFile4(absolutePath), mode: info.mode & MAX_POSIX_MODE };
|
|
6134
6679
|
} catch (error) {
|
|
6135
6680
|
if (error.code === "ENOENT") return void 0;
|
|
6136
6681
|
throw error;
|
|
@@ -6158,7 +6703,7 @@ async function configSnapshot(root) {
|
|
|
6158
6703
|
return snapshotFile(root, "artifact-graph.config.yaml");
|
|
6159
6704
|
}
|
|
6160
6705
|
async function loadRestructureContract(name) {
|
|
6161
|
-
return loadContract(
|
|
6706
|
+
return loadContract(join11(CONTRACT_ROOT, `restructure-${name}`, "schema.json"), { expectedAuthority: "artifact" });
|
|
6162
6707
|
}
|
|
6163
6708
|
async function validateDomainContract(name, value) {
|
|
6164
6709
|
const contract = await loadRestructureContract(name);
|
|
@@ -6433,14 +6978,14 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
|
|
|
6433
6978
|
async function visit(directory) {
|
|
6434
6979
|
for (const entry of await readdir3(directory, { withFileTypes: true })) {
|
|
6435
6980
|
if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
|
|
6436
|
-
const absolute =
|
|
6981
|
+
const absolute = join11(directory, entry.name);
|
|
6437
6982
|
if (entry.isDirectory()) {
|
|
6438
6983
|
await visit(absolute);
|
|
6439
6984
|
continue;
|
|
6440
6985
|
}
|
|
6441
6986
|
if (!entry.isFile() || !TEXT_EXTENSIONS.test(entry.name)) continue;
|
|
6442
6987
|
const path = relative4(root, absolute).replace(/\\/g, "/");
|
|
6443
|
-
const raw = await
|
|
6988
|
+
const raw = await readFile4(absolute, "utf8");
|
|
6444
6989
|
const namesTheMigration = migrationPaths.some((reference) => raw.includes(reference));
|
|
6445
6990
|
const lines = raw.split(/\r?\n/);
|
|
6446
6991
|
for (const [index, line] of lines.entries()) {
|
|
@@ -6505,13 +7050,13 @@ async function scanConsumerCandidates(root, references, excludedPaths = /* @__PU
|
|
|
6505
7050
|
async function visit(directory) {
|
|
6506
7051
|
for (const entry of await readdir3(directory, { withFileTypes: true })) {
|
|
6507
7052
|
if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
|
|
6508
|
-
const absolute =
|
|
7053
|
+
const absolute = join11(directory, entry.name);
|
|
6509
7054
|
if (entry.isDirectory()) {
|
|
6510
7055
|
await visit(absolute);
|
|
6511
7056
|
} else if (entry.isFile() && TEXT_EXTENSIONS.test(entry.name)) {
|
|
6512
7057
|
const path = relative4(root, absolute).replace(/\\/g, "/");
|
|
6513
7058
|
if (excludedPaths.has(path)) continue;
|
|
6514
|
-
const raw = await
|
|
7059
|
+
const raw = await readFile4(absolute, "utf8");
|
|
6515
7060
|
raw.split(/\r?\n/).forEach((line, index) => {
|
|
6516
7061
|
for (const reference of references) {
|
|
6517
7062
|
if (path !== reference && line.includes(reference)) results.push({ path, line: index + 1, reference });
|
|
@@ -7014,7 +7559,7 @@ async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
|
|
|
7014
7559
|
}
|
|
7015
7560
|
let bytes;
|
|
7016
7561
|
try {
|
|
7017
|
-
bytes = await
|
|
7562
|
+
bytes = await readFile4(absolute);
|
|
7018
7563
|
} catch (cause) {
|
|
7019
7564
|
return refusal("PLAN_FILE_UNREADABLE", `Plan document cannot be read: ${absolute} (${cause.message})`);
|
|
7020
7565
|
}
|
|
@@ -7046,7 +7591,7 @@ function planRootIdentityFindings(document) {
|
|
|
7046
7591
|
findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan does not record this project's configuration file: ${document.plan.config_snapshot.path}`));
|
|
7047
7592
|
}
|
|
7048
7593
|
const relativePlan = relative4(document.root, document.realPath);
|
|
7049
|
-
if (!relativePlan || relativePlan.startsWith("..") ||
|
|
7594
|
+
if (!relativePlan || relativePlan.startsWith("..") || isAbsolute6(relativePlan)) {
|
|
7050
7595
|
findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan document is outside the project root: ${document.realPath}`, document.realPath));
|
|
7051
7596
|
}
|
|
7052
7597
|
return findings;
|
|
@@ -7237,7 +7782,7 @@ var init_restructure = __esm({
|
|
|
7237
7782
|
MAX_POSIX_MODE = 511;
|
|
7238
7783
|
CREATE_MODE_BASE = 438;
|
|
7239
7784
|
MODULE_DIRECTORY = typeof __dirname === "string" ? __dirname : dirname6(fileURLToPath2(import.meta.url));
|
|
7240
|
-
CONTRACT_ROOT =
|
|
7785
|
+
CONTRACT_ROOT = join11(MODULE_DIRECTORY, "..", "contracts");
|
|
7241
7786
|
SKIPPED_SCAN_DIRS = /* @__PURE__ */ new Set([".git", "node_modules", "dist", "coverage", ".tmp", ".codex", ".worktrees", ".foundation-file-apply", ".artifact-graph"]);
|
|
7242
7787
|
TEXT_EXTENSIONS = /\.(?:md|markdown|json|ya?ml|[cm]?[jt]sx?)$/i;
|
|
7243
7788
|
MARKDOWN_LINK_PATTERN = /!?\[([^\]\n]*)\]\(([^)\n]+)\)/g;
|
|
@@ -7248,11 +7793,176 @@ var init_restructure = __esm({
|
|
|
7248
7793
|
});
|
|
7249
7794
|
|
|
7250
7795
|
// src/index.ts
|
|
7796
|
+
var index_exports = {};
|
|
7797
|
+
__export(index_exports, {
|
|
7798
|
+
ALWAYS_PRESENT: () => ALWAYS_PRESENT_ITEMS,
|
|
7799
|
+
BASELINE_CONSTRAINTS: () => BASELINE_CONSTRAINTS,
|
|
7800
|
+
BASELINE_CONSTRAINTS_COUNT: () => BASELINE_CONSTRAINTS_COUNT,
|
|
7801
|
+
BASELINE_ITEMS_COUNT: () => BASELINE_ITEMS_COUNT,
|
|
7802
|
+
CONTRACTS_PACKAGE_NAME: () => CONTRACTS_PACKAGE_NAME2,
|
|
7803
|
+
CONTRACT_ERROR_CODES: () => CONTRACT_ERROR_CODES,
|
|
7804
|
+
ContractCatalog: () => ContractCatalog,
|
|
7805
|
+
ContractError: () => ContractError,
|
|
7806
|
+
ContractRegistry: () => ContractRegistry,
|
|
7807
|
+
DEFAULT_MAX_CHARS: () => DEFAULT_MAX_CHARS,
|
|
7808
|
+
DEFAULT_SCHEMA: () => DEFAULT_SCHEMA,
|
|
7809
|
+
E2E_NORMALIZER_CONFIG: () => E2E_NORMALIZER_CONFIG,
|
|
7810
|
+
FILE_SET_RESULT_OBJECT: () => FILE_SET_RESULT_OBJECT,
|
|
7811
|
+
FOUNDATION_PACKAGE_NAME: () => FOUNDATION_PACKAGE_NAME,
|
|
7812
|
+
GRAPH_DOMAIN_CODES: () => GRAPH_DOMAIN_CODES,
|
|
7813
|
+
GRAPH_PROVIDER_ENTRY: () => GRAPH_PROVIDER_ENTRY,
|
|
7814
|
+
GRAPH_PROVIDER_ID: () => GRAPH_PROVIDER_ID,
|
|
7815
|
+
MIN_PROMPT_CHARS: () => MIN_PROMPT_CHARS,
|
|
7816
|
+
PROFESSIONAL_CONCLUSION_OBJECT: () => PROFESSIONAL_CONCLUSION_OBJECT,
|
|
7817
|
+
RESTRUCTURE_MAX_OPERATIONS: () => RESTRUCTURE_MAX_OPERATIONS,
|
|
7818
|
+
RESTRUCTURE_MAX_TOTAL_BYTES: () => RESTRUCTURE_MAX_TOTAL_BYTES,
|
|
7819
|
+
RESTRUCTURE_PLAN_SCHEMA_VERSION: () => RESTRUCTURE_PLAN_SCHEMA_VERSION,
|
|
7820
|
+
RESTRUCTURE_QUALIFIED_ARCH: () => RESTRUCTURE_QUALIFIED_ARCH,
|
|
7821
|
+
RESTRUCTURE_QUALIFIED_FILESYSTEM: () => RESTRUCTURE_QUALIFIED_FILESYSTEM,
|
|
7822
|
+
RESTRUCTURE_QUALIFIED_PLATFORM: () => RESTRUCTURE_QUALIFIED_PLATFORM,
|
|
7823
|
+
RESTRUCTURE_RECOVERY_JOURNAL_REL_PATH: () => RESTRUCTURE_RECOVERY_JOURNAL_REL_PATH,
|
|
7824
|
+
RESTRUCTURE_RECOVERY_REL_PATH: () => RESTRUCTURE_RECOVERY_REL_PATH,
|
|
7825
|
+
RESTRUCTURE_RECOVERY_ROOT_MODE: () => RESTRUCTURE_RECOVERY_ROOT_MODE,
|
|
7826
|
+
RESTRUCTURE_VALIDATION_TIMEOUT_MS: () => RESTRUCTURE_VALIDATION_TIMEOUT_MS,
|
|
7827
|
+
TARGET_ARTIFACT_TYPES: () => TARGET_ARTIFACT_TYPES,
|
|
7828
|
+
VALID_PACKET_TARGET_TYPES: () => VALID_PACKET_TARGET_TYPES,
|
|
7829
|
+
VERSION_INDEX_SCHEMA_VERSION: () => VERSION_INDEX_SCHEMA_VERSION,
|
|
7830
|
+
VERSION_LOCK_PATH: () => VERSION_LOCK_PATH,
|
|
7831
|
+
VERSION_LOCK_SCHEMA_VERSION: () => VERSION_LOCK_SCHEMA_VERSION,
|
|
7832
|
+
applyPreparedManagedHookBlocks: () => applyPreparedManagedHookBlocks,
|
|
7833
|
+
applyRestructure: () => applyRestructure,
|
|
7834
|
+
applyRestructureFileSet: () => applyRestructureFileSet,
|
|
7835
|
+
assemblePacket: () => assemblePacket,
|
|
7836
|
+
auditPackets: () => auditPackets,
|
|
7837
|
+
auditVersionLock: () => auditVersionLock,
|
|
7838
|
+
bootstrapVersionLock: () => bootstrapVersionLock,
|
|
7839
|
+
buildFileSetApplyRequest: () => buildFileSetApplyRequest,
|
|
7840
|
+
buildGraph: () => buildGraph,
|
|
7841
|
+
buildVersionIndex: () => buildVersionIndex,
|
|
7842
|
+
candidateByteDigest: () => candidateByteDigest,
|
|
7843
|
+
collectChangedPaths: () => collectChangedPaths,
|
|
7844
|
+
computeCoverageBoundary: () => computeCoverageBoundary,
|
|
7845
|
+
computeE2eCoverageStats: () => computeE2eCoverageStats,
|
|
7846
|
+
computeImpact: () => computeImpact,
|
|
7847
|
+
computeRevisionDigest: () => computeRevisionDigest,
|
|
7848
|
+
createModeForUmask: () => createModeForUmask,
|
|
7849
|
+
createRestructureRootBinding: () => createRestructureRootBinding,
|
|
7850
|
+
createRestructureValidationCallback: () => createRestructureValidationCallback,
|
|
7851
|
+
diagnoseConfigDocument: () => diagnoseConfigDocument,
|
|
7852
|
+
diagnoseProjectConfig: () => diagnoseProjectConfig,
|
|
7853
|
+
digestRestructureValue: () => digestRestructureValue,
|
|
7854
|
+
dirname: () => dirname7,
|
|
7855
|
+
discoverAndAuditPackets: () => discoverAndAuditPackets,
|
|
7856
|
+
discoverTargets: () => discoverTargets,
|
|
7857
|
+
doctorArtifactChain: () => doctorArtifactChain,
|
|
7858
|
+
ensureRestructureMechanismRoot: () => ensureRestructureMechanismRoot,
|
|
7859
|
+
extname: () => extname,
|
|
7860
|
+
filterGraphByView: () => filterGraphByView,
|
|
7861
|
+
formatContextMarkdown: () => formatContextMarkdown,
|
|
7862
|
+
gateRestructureOperationPlan: () => gateRestructureOperationPlan,
|
|
7863
|
+
generateE2eRegistry: () => generateE2eRegistry,
|
|
7864
|
+
getArtifactTypeMetadata: () => getArtifactTypeMetadata,
|
|
7865
|
+
getConfigDiagnostics: () => getConfigDiagnostics,
|
|
7866
|
+
getExternalEntryInfo: () => getExternalEntryInfo,
|
|
7867
|
+
getTargetArtifactTypes: () => getTargetArtifactTypes,
|
|
7868
|
+
inspectRestructure: () => inspectRestructure,
|
|
7869
|
+
installManagedHookBlock: () => installManagedHookBlock,
|
|
7870
|
+
isOfficialNamespace: () => isOfficialNamespace,
|
|
7871
|
+
isPacketTargetType: () => isPacketTargetType,
|
|
7872
|
+
isPacketTargetTypeDynamic: () => isPacketTargetTypeDynamic,
|
|
7873
|
+
isTargetArtifactType: () => isTargetArtifactType,
|
|
7874
|
+
isVersionLockIssueBlocking: () => isVersionLockIssueBlocking,
|
|
7875
|
+
loadConfig: () => loadConfig,
|
|
7876
|
+
loadContract: () => loadContract,
|
|
7877
|
+
loadContractCatalog: () => loadContractCatalog,
|
|
7878
|
+
loadContractsFromDirectory: () => loadContractsFromDirectory,
|
|
7879
|
+
loadFoundationModule: () => loadFoundationModule,
|
|
7880
|
+
locateSoftwareRecord: () => locateSoftwareRecord,
|
|
7881
|
+
markdownRecordHeadings: () => markdownRecordHeadings,
|
|
7882
|
+
matchesConfiguredArtifactPath: () => matchesConfiguredArtifactPath,
|
|
7883
|
+
nextId: () => nextId,
|
|
7884
|
+
normalizeE2eLegacyArtifact: () => normalizeE2eLegacyArtifact,
|
|
7885
|
+
normalizeToCanonical: () => normalizeToCanonical,
|
|
7886
|
+
observeRestructureJournal: () => observeRestructureJournal,
|
|
7887
|
+
parseTargetSelector: () => parseTargetSelector,
|
|
7888
|
+
parseTargetsFile: () => parseTargetsFile,
|
|
7889
|
+
planRestructure: () => planRestructure,
|
|
7890
|
+
planningUmask: () => planningUmask,
|
|
7891
|
+
prepareManagedHookBlock: () => prepareManagedHookBlock,
|
|
7892
|
+
projectRestructureFileSetResult: () => projectRestructureFileSetResult,
|
|
7893
|
+
pruneRestructureFileSet: () => pruneRestructureFileSet,
|
|
7894
|
+
pruneRestructureRecovery: () => pruneRestructureRecovery,
|
|
7895
|
+
qualifyRestructureMechanism: () => qualifyRestructureMechanism,
|
|
7896
|
+
queryGraph: () => queryGraph,
|
|
7897
|
+
recoverRestructure: () => recoverRestructure,
|
|
7898
|
+
recoverRestructureFileSet: () => recoverRestructureFileSet,
|
|
7899
|
+
refreshVersionLock: () => refreshVersionLock,
|
|
7900
|
+
renderCoverageBoundaryMarkdown: () => renderCoverageBoundaryMarkdown,
|
|
7901
|
+
renderDoctorMarkdown: () => renderDoctorMarkdown,
|
|
7902
|
+
renderImpactMarkdown: () => renderImpactMarkdown,
|
|
7903
|
+
renderMermaid: () => renderMermaid,
|
|
7904
|
+
renderPacketMarkdown: () => renderPacketMarkdown,
|
|
7905
|
+
renderPacketPrompt: () => renderPacketPrompt,
|
|
7906
|
+
renderTraceVersionMarkdown: () => renderTraceVersionMarkdown,
|
|
7907
|
+
renderVersionLockAuditMarkdown: () => renderVersionLockAuditMarkdown,
|
|
7908
|
+
renderVersionLockRefreshMarkdown: () => renderVersionLockRefreshMarkdown,
|
|
7909
|
+
replaceSoftwareHeader: () => replaceSoftwareHeader,
|
|
7910
|
+
resolveArtifactContext: () => resolveArtifactContext,
|
|
7911
|
+
resolveArtifactGraphCli: () => resolveArtifactGraphCli,
|
|
7912
|
+
resolveArtifactTypeName: () => resolveArtifactTypeName,
|
|
7913
|
+
resolveCliTarget: () => resolveCliTarget,
|
|
7914
|
+
resolveGitHookPath: () => resolveGitHookPath,
|
|
7915
|
+
resolveMatrixEdges: () => resolveMatrixEdges,
|
|
7916
|
+
resolveNodeTimeView: () => resolveNodeTimeView,
|
|
7917
|
+
resolveRealRoot: () => resolveRealRoot,
|
|
7918
|
+
restructureBoundaryFindings: () => restructureBoundaryFindings,
|
|
7919
|
+
runCheckProfessional: () => runCheckProfessional,
|
|
7920
|
+
runReadProof: () => runReadProof,
|
|
7921
|
+
scanArtifacts: () => scanArtifacts,
|
|
7922
|
+
traceVersion: () => traceVersion,
|
|
7923
|
+
updateVersionLock: () => updateVersionLock,
|
|
7924
|
+
validateContractAgainstSchema: () => validateContractAgainstSchema,
|
|
7925
|
+
validateExecutableTraceability: () => validateExecutableTraceability,
|
|
7926
|
+
validateGraph: () => validateGraph,
|
|
7927
|
+
validateNamespaceAuthority: () => validateNamespaceAuthority,
|
|
7928
|
+
validatePacket: () => validatePacket,
|
|
7929
|
+
validatePacketMarkdown: () => validatePacketMarkdown,
|
|
7930
|
+
validatePacketPrompt: () => validatePacketPrompt,
|
|
7931
|
+
validatePolicyCompatibility: () => validatePolicyCompatibility,
|
|
7932
|
+
validateReviewResult: () => validateReviewResult,
|
|
7933
|
+
validateScenarioPrdLinkIndex: () => validateScenarioPrdLinkIndex,
|
|
7934
|
+
validateScenarioPrdLinks: () => validateScenarioPrdLinks,
|
|
7935
|
+
verifyDigest: () => verifyDigest,
|
|
7936
|
+
verifyMechanismResult: () => verifyMechanismResult,
|
|
7937
|
+
versionLockIssueSeverity: () => versionLockIssueSeverity,
|
|
7938
|
+
writeGraphCache: () => writeGraphCache
|
|
7939
|
+
});
|
|
7251
7940
|
import matter from "gray-matter";
|
|
7252
|
-
import
|
|
7941
|
+
import yaml2 from "js-yaml";
|
|
7253
7942
|
import { accessSync, constants as fsConstants, existsSync as existsSync3, statSync } from "fs";
|
|
7254
|
-
import { mkdir as mkdir5, readFile as
|
|
7255
|
-
import { basename as basename5, dirname as dirname7, extname, isAbsolute as
|
|
7943
|
+
import { mkdir as mkdir5, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
7944
|
+
import { basename as basename5, dirname as dirname7, extname, isAbsolute as isAbsolute7, join as join12, resolve as resolve8 } from "path";
|
|
7945
|
+
function getConfigDiagnostics(schema) {
|
|
7946
|
+
return configDiagnosticsBySchema.get(schema);
|
|
7947
|
+
}
|
|
7948
|
+
function edgeRule(from, to, kind) {
|
|
7949
|
+
return { from, to, kind };
|
|
7950
|
+
}
|
|
7951
|
+
function matchesEdgeRule(rule, fromType, toType, kind) {
|
|
7952
|
+
return rule.from === fromType && rule.to === toType && rule.kind === kind;
|
|
7953
|
+
}
|
|
7954
|
+
function cloneEdgeRules(rules) {
|
|
7955
|
+
return rules.map((rule) => ({ ...rule }));
|
|
7956
|
+
}
|
|
7957
|
+
function isEmptyAllowedEdgesValue(value) {
|
|
7958
|
+
return value === null || Array.isArray(value) && value.length === 0;
|
|
7959
|
+
}
|
|
7960
|
+
function resolveAllowedEdges(value) {
|
|
7961
|
+
if (isEmptyAllowedEdgesValue(value)) {
|
|
7962
|
+
return cloneEdgeRules(DEFAULT_ALLOWED_EDGES);
|
|
7963
|
+
}
|
|
7964
|
+
return cloneEdgeRules(value);
|
|
7965
|
+
}
|
|
7256
7966
|
function isTargetArtifactType(type) {
|
|
7257
7967
|
return isPacketTargetType(type);
|
|
7258
7968
|
}
|
|
@@ -7294,30 +8004,22 @@ function resolveArtifactTypeName(schema, token) {
|
|
|
7294
8004
|
return void 0;
|
|
7295
8005
|
}
|
|
7296
8006
|
async function loadConfig(root) {
|
|
7297
|
-
const configPath =
|
|
7298
|
-
let
|
|
8007
|
+
const configPath = join12(root, "artifact-graph.config.yaml");
|
|
8008
|
+
let raw;
|
|
7299
8009
|
try {
|
|
7300
|
-
|
|
7301
|
-
parsed = yaml.load(raw) ?? {};
|
|
8010
|
+
raw = await readFile5(configPath, "utf-8");
|
|
7302
8011
|
} catch (error) {
|
|
7303
|
-
if (error.code
|
|
7304
|
-
throw
|
|
8012
|
+
if (error.code === "ENOENT") {
|
|
8013
|
+
throw new Error(`required configuration is missing: ${configPath}`);
|
|
7305
8014
|
}
|
|
8015
|
+
throw error;
|
|
7306
8016
|
}
|
|
7307
|
-
const
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
);
|
|
7312
|
-
}
|
|
7313
|
-
if (parsed.e2e !== void 0) {
|
|
7314
|
-
if (typeof parsed.e2e !== "object" || parsed.e2e === null || Array.isArray(parsed.e2e)) {
|
|
7315
|
-
throw new Error("Invalid e2e: must be an object.");
|
|
7316
|
-
}
|
|
7317
|
-
validateE2eConfig(parsed.e2e);
|
|
8017
|
+
const document = yaml2.load(raw) ?? {};
|
|
8018
|
+
const shapeDiagnosis = diagnoseConfigDocument(document);
|
|
8019
|
+
if (shapeDiagnosis.errors.length > 0) {
|
|
8020
|
+
throw new Error(shapeDiagnosis.errors[0].message);
|
|
7318
8021
|
}
|
|
7319
|
-
|
|
7320
|
-
validateStatusViewsConfig(parsed.statusViews);
|
|
8022
|
+
const parsed = document;
|
|
7321
8023
|
const mergedE2e = parsed.e2e === void 0 ? DEFAULT_SCHEMA.e2e : {
|
|
7322
8024
|
...DEFAULT_SCHEMA.e2e,
|
|
7323
8025
|
...parsed.e2e,
|
|
@@ -7332,13 +8034,14 @@ async function loadConfig(root) {
|
|
|
7332
8034
|
types: mergeArtifactTypes(DEFAULT_SCHEMA.types, parsed.types),
|
|
7333
8035
|
idPatterns: mergeRecord(DEFAULT_SCHEMA.idPatterns, parsed.idPatterns),
|
|
7334
8036
|
relationFields: mergeRecord(DEFAULT_SCHEMA.relationFields, parsed.relationFields),
|
|
7335
|
-
allowedEdges: parsed.allowedEdges
|
|
8037
|
+
allowedEdges: resolveAllowedEdges(parsed.allowedEdges),
|
|
7336
8038
|
forbiddenEdges: parsed.forbiddenEdges ?? DEFAULT_SCHEMA.forbiddenEdges,
|
|
7337
8039
|
statuses: parsed.statuses ?? DEFAULT_SCHEMA.statuses,
|
|
7338
8040
|
idRanges: mergeRecord(DEFAULT_SCHEMA.idRanges, parsed.idRanges),
|
|
7339
8041
|
e2e: mergedE2e
|
|
7340
8042
|
};
|
|
7341
8043
|
validateJsonArtifactTypes(merged.types);
|
|
8044
|
+
configDiagnosticsBySchema.set(merged, shapeDiagnosis);
|
|
7342
8045
|
return merged;
|
|
7343
8046
|
}
|
|
7344
8047
|
function validateJsonArtifactTypes(types) {
|
|
@@ -7363,131 +8066,6 @@ function validateJsonArtifactTypes(types) {
|
|
|
7363
8066
|
}
|
|
7364
8067
|
}
|
|
7365
8068
|
}
|
|
7366
|
-
function validateRelationSemanticsConfig(value) {
|
|
7367
|
-
if (value === void 0) return;
|
|
7368
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7369
|
-
throw new Error("Invalid relationSemantics: must be an object keyed by relation kind.");
|
|
7370
|
-
}
|
|
7371
|
-
for (const [kind, spec] of Object.entries(value)) {
|
|
7372
|
-
if (!kind.trim() || typeof spec !== "object" || spec === null || Array.isArray(spec)) {
|
|
7373
|
-
throw new Error(`Invalid relationSemantics.${kind}: must be an object.`);
|
|
7374
|
-
}
|
|
7375
|
-
if (typeof spec.label !== "string" || !spec.label.trim()) {
|
|
7376
|
-
throw new Error(`Invalid relationSemantics.${kind}.label: must be a non-empty string.`);
|
|
7377
|
-
}
|
|
7378
|
-
if (!Array.isArray(spec.targetTypes) || spec.targetTypes.some((item) => typeof item !== "string" || !item.trim())) {
|
|
7379
|
-
throw new Error(`Invalid relationSemantics.${kind}.targetTypes: must be an array of non-empty strings.`);
|
|
7380
|
-
}
|
|
7381
|
-
if (!Array.isArray(spec.fields) || spec.fields.length === 0 || spec.fields.some((item) => typeof item !== "string" || !item.trim())) {
|
|
7382
|
-
throw new Error(`Invalid relationSemantics.${kind}.fields: must be a non-empty array of strings.`);
|
|
7383
|
-
}
|
|
7384
|
-
if (spec.partial !== void 0 && (typeof spec.partial !== "object" || spec.partial === null || typeof spec.partial.sectionField !== "string" || !spec.partial.sectionField.trim())) {
|
|
7385
|
-
throw new Error(`Invalid relationSemantics.${kind}.partial.sectionField: must be a non-empty string.`);
|
|
7386
|
-
}
|
|
7387
|
-
}
|
|
7388
|
-
}
|
|
7389
|
-
function validateStatusViewsConfig(value) {
|
|
7390
|
-
if (value === void 0) return;
|
|
7391
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7392
|
-
throw new Error("Invalid statusViews: must be an object keyed by status.");
|
|
7393
|
-
}
|
|
7394
|
-
for (const [status, bucket] of Object.entries(value)) {
|
|
7395
|
-
if (!status.trim() || !["current", "planned", "history"].includes(bucket)) {
|
|
7396
|
-
throw new Error(`Invalid statusViews.${status}: expected current, planned, or history.`);
|
|
7397
|
-
}
|
|
7398
|
-
}
|
|
7399
|
-
}
|
|
7400
|
-
function validateE2eConfig(e2e) {
|
|
7401
|
-
for (const field of ["report_uncovered_scenarios", "report_uncovered_features"]) {
|
|
7402
|
-
if (e2e[field] !== void 0 && typeof e2e[field] !== "boolean") {
|
|
7403
|
-
throw new Error(`Invalid e2e.${field}: must be boolean.`);
|
|
7404
|
-
}
|
|
7405
|
-
}
|
|
7406
|
-
if (e2e.executable_ref_warning !== void 0) {
|
|
7407
|
-
if (typeof e2e.executable_ref_warning !== "number" || e2e.executable_ref_warning < 0 || e2e.executable_ref_warning > 1) {
|
|
7408
|
-
throw new Error(`Invalid e2e.executable_ref_warning: ${JSON.stringify(e2e.executable_ref_warning)}. Must be a number between 0 and 1.`);
|
|
7409
|
-
}
|
|
7410
|
-
}
|
|
7411
|
-
if (e2e.executable_ref_error !== void 0) {
|
|
7412
|
-
if (typeof e2e.executable_ref_error !== "number" || e2e.executable_ref_error < 0 || e2e.executable_ref_error > 1) {
|
|
7413
|
-
throw new Error(`Invalid e2e.executable_ref_error: ${JSON.stringify(e2e.executable_ref_error)}. Must be a number between 0 and 1.`);
|
|
7414
|
-
}
|
|
7415
|
-
}
|
|
7416
|
-
const validateWaivers = (waivers, field) => {
|
|
7417
|
-
if (waivers === void 0) return;
|
|
7418
|
-
if (!Array.isArray(waivers)) {
|
|
7419
|
-
throw new Error(`Invalid ${field}: must be an array of {id, reason} objects.`);
|
|
7420
|
-
}
|
|
7421
|
-
for (const w of waivers) {
|
|
7422
|
-
if (typeof w !== "object" || w === null || !("id" in w) || !("reason" in w)) {
|
|
7423
|
-
throw new Error(`Invalid ${field} entry: ${JSON.stringify(w)}. Must be {id, reason} object.`);
|
|
7424
|
-
}
|
|
7425
|
-
if (typeof w.id !== "string" || !w.id.trim()) {
|
|
7426
|
-
throw new Error(`Invalid ${field} entry: id must be a non-empty string. Got: ${JSON.stringify(w.id)}`);
|
|
7427
|
-
}
|
|
7428
|
-
if (typeof w.reason !== "string" || !w.reason.trim()) {
|
|
7429
|
-
throw new Error(`Invalid ${field} entry: reason must be a non-empty string. Got: ${JSON.stringify(w.reason)}`);
|
|
7430
|
-
}
|
|
7431
|
-
}
|
|
7432
|
-
};
|
|
7433
|
-
validateWaivers(e2e.scenario_waivers, "e2e.scenario_waivers");
|
|
7434
|
-
validateWaivers(e2e.feature_waivers, "e2e.feature_waivers");
|
|
7435
|
-
if (e2e.runners !== void 0) {
|
|
7436
|
-
if (!Array.isArray(e2e.runners)) {
|
|
7437
|
-
throw new Error(`Invalid e2e.runners: must be an array.`);
|
|
7438
|
-
}
|
|
7439
|
-
for (const runner of e2e.runners) {
|
|
7440
|
-
if (typeof runner !== "object" || runner === null) {
|
|
7441
|
-
throw new Error(`Invalid e2e.runners entry: must be an object.`);
|
|
7442
|
-
}
|
|
7443
|
-
if (typeof runner.name !== "string" || !runner.name.trim()) {
|
|
7444
|
-
throw new Error(`Invalid e2e.runners entry: name must be a non-empty string.`);
|
|
7445
|
-
}
|
|
7446
|
-
if (typeof runner.root !== "string" || !runner.root.trim()) {
|
|
7447
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: must be a non-empty string.`);
|
|
7448
|
-
}
|
|
7449
|
-
if (isAbsolute6(runner.root)) {
|
|
7450
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not be an absolute path.`);
|
|
7451
|
-
}
|
|
7452
|
-
if (runner.root.replace(/\\/g, "/").split("/").includes("..")) {
|
|
7453
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not contain ".." segments.`);
|
|
7454
|
-
}
|
|
7455
|
-
if (!Array.isArray(runner.include) || runner.include.length === 0) {
|
|
7456
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].include: must be a non-empty array of glob patterns.`);
|
|
7457
|
-
}
|
|
7458
|
-
for (const pattern of runner.include) {
|
|
7459
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7460
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].include: pattern must be a non-empty string.`);
|
|
7461
|
-
}
|
|
7462
|
-
}
|
|
7463
|
-
if (runner.exclude !== void 0) {
|
|
7464
|
-
if (!Array.isArray(runner.exclude)) {
|
|
7465
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].exclude: must be an array.`);
|
|
7466
|
-
}
|
|
7467
|
-
for (const pattern of runner.exclude) {
|
|
7468
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7469
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].exclude: pattern must be a non-empty string.`);
|
|
7470
|
-
}
|
|
7471
|
-
}
|
|
7472
|
-
}
|
|
7473
|
-
if (runner.testIgnore !== void 0) {
|
|
7474
|
-
if (!Array.isArray(runner.testIgnore)) {
|
|
7475
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].testIgnore: must be an array.`);
|
|
7476
|
-
}
|
|
7477
|
-
for (const pattern of runner.testIgnore) {
|
|
7478
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7479
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].testIgnore: pattern must be a non-empty string.`);
|
|
7480
|
-
}
|
|
7481
|
-
}
|
|
7482
|
-
}
|
|
7483
|
-
if (runner.kind !== void 0) {
|
|
7484
|
-
if (!["unit", "integration", "e2e"].includes(runner.kind)) {
|
|
7485
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].kind: "${runner.kind}". Must be unit, integration, or e2e.`);
|
|
7486
|
-
}
|
|
7487
|
-
}
|
|
7488
|
-
}
|
|
7489
|
-
}
|
|
7490
|
-
}
|
|
7491
8069
|
function buildGraph(nodes, edges, diagnostics = [], root) {
|
|
7492
8070
|
const graphNodes = nodes.map((node) => ({ ...node, uid: toUid(node.type, node.code) }));
|
|
7493
8071
|
graphNodes.sort(compareNode);
|
|
@@ -7535,7 +8113,7 @@ async function scanArtifacts(root, schema, options = {}) {
|
|
|
7535
8113
|
continue;
|
|
7536
8114
|
}
|
|
7537
8115
|
scannedFiles.set(file, type);
|
|
7538
|
-
const raw = contentOverrides.has(file) ? contentOverrides.get(file) : await
|
|
8116
|
+
const raw = contentOverrides.has(file) ? contentOverrides.get(file) : await readFile5(join12(root, file), "utf-8");
|
|
7539
8117
|
const parsed = parseFile(type, file, raw, config);
|
|
7540
8118
|
const semantic = isJsonOriginalType(type, config) ? { edges: [], diagnostics: [] } : parseConfiguredRelations(type, file, raw, parsed.nodes, config);
|
|
7541
8119
|
nodes.push(...parsed.nodes);
|
|
@@ -7543,7 +8121,7 @@ async function scanArtifacts(root, schema, options = {}) {
|
|
|
7543
8121
|
scanDiagnostics.push(...parsed.diagnostics, ...semantic.diagnostics);
|
|
7544
8122
|
}
|
|
7545
8123
|
}
|
|
7546
|
-
const absoluteRoot =
|
|
8124
|
+
const absoluteRoot = isAbsolute7(root) ? root : resolve8(root);
|
|
7547
8125
|
const graph = buildGraph(nodes, edges, scanDiagnostics, absoluteRoot);
|
|
7548
8126
|
return resolveMatrixEdges(graph);
|
|
7549
8127
|
}
|
|
@@ -7690,8 +8268,16 @@ function validateGraph(graph, schema = DEFAULT_SCHEMA) {
|
|
|
7690
8268
|
{ edge: edge2 }
|
|
7691
8269
|
));
|
|
7692
8270
|
}
|
|
7693
|
-
if (schema.forbiddenEdges.some((rule) => rule
|
|
8271
|
+
if (schema.forbiddenEdges.some((rule) => matchesEdgeRule(rule, fromType, toType, edge2.kind))) {
|
|
7694
8272
|
issues.push(issue("FORBIDDEN_EDGE", `Forbidden ${fromType} -> ${toType} ${edge2.kind} relation`, edge2.sourcePath, edge2.sourceLine, { edge: edge2 }));
|
|
8273
|
+
} else if (!schema.allowedEdges.some((rule) => matchesEdgeRule(rule, fromType, toType, edge2.kind))) {
|
|
8274
|
+
issues.push(issue(
|
|
8275
|
+
"DISALLOWED_EDGE",
|
|
8276
|
+
`Disallowed ${fromType} -> ${toType} ${edge2.kind} relation`,
|
|
8277
|
+
edge2.sourcePath,
|
|
8278
|
+
edge2.sourceLine,
|
|
8279
|
+
{ edge: edge2 }
|
|
8280
|
+
));
|
|
7695
8281
|
}
|
|
7696
8282
|
}
|
|
7697
8283
|
issues.push(...validateE2eTests(graph));
|
|
@@ -7785,6 +8371,9 @@ function getExternalEntryInfo(node) {
|
|
|
7785
8371
|
...targetVersion ? { targetVersion } : {}
|
|
7786
8372
|
};
|
|
7787
8373
|
}
|
|
8374
|
+
function validateScenarioPrdLinks(graph, schema = DEFAULT_SCHEMA) {
|
|
8375
|
+
return validateScenarioPrdLinksInternal(graph, schema, true);
|
|
8376
|
+
}
|
|
7788
8377
|
function validateScenarioPrdLinksInternal(graph, schema, includeScanDiagnosedInvalid) {
|
|
7789
8378
|
if (!schema.relationFields.scenario?.includes("\u5173\u8054\u529F\u80FD") || !schema.relationFields.feature?.includes("scenarios")) {
|
|
7790
8379
|
return [];
|
|
@@ -7879,7 +8468,7 @@ async function validateScenarioPrdLinkIndex(root, graph) {
|
|
|
7879
8468
|
const indexPath = "artifacts/prd/feature-index.md";
|
|
7880
8469
|
let raw = "";
|
|
7881
8470
|
try {
|
|
7882
|
-
raw = await
|
|
8471
|
+
raw = await readFile5(join12(root, indexPath), "utf-8");
|
|
7883
8472
|
} catch (error) {
|
|
7884
8473
|
if (error.code === "ENOENT") {
|
|
7885
8474
|
return [];
|
|
@@ -8127,12 +8716,12 @@ function nextId(graph, schema, type, rangeName) {
|
|
|
8127
8716
|
throw new Error(`ID range ${type}.${rangeName} is exhausted`);
|
|
8128
8717
|
}
|
|
8129
8718
|
async function writeGraphCache(root, graph) {
|
|
8130
|
-
const cacheDir =
|
|
8719
|
+
const cacheDir = join12(root, ".artifact-graph");
|
|
8131
8720
|
await mkdir5(cacheDir, { recursive: true });
|
|
8132
|
-
await writeFile3(
|
|
8721
|
+
await writeFile3(join12(cacheDir, "index.json"), `${JSON.stringify(graph, null, 2)}
|
|
8133
8722
|
`);
|
|
8134
8723
|
const { default: Database } = await import("better-sqlite3");
|
|
8135
|
-
const db = new Database(
|
|
8724
|
+
const db = new Database(join12(cacheDir, "graph.sqlite"));
|
|
8136
8725
|
try {
|
|
8137
8726
|
db.exec(`
|
|
8138
8727
|
DROP TABLE IF EXISTS nodes;
|
|
@@ -10214,7 +10803,7 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10214
10803
|
const tcKeyToFields = /* @__PURE__ */ new Map();
|
|
10215
10804
|
const mdBatches = /* @__PURE__ */ new Set();
|
|
10216
10805
|
for (const relPath of e2eFiles) {
|
|
10217
|
-
const raw = await
|
|
10806
|
+
const raw = await readFile5(join12(root, relPath), "utf-8");
|
|
10218
10807
|
const parsed = matter(raw);
|
|
10219
10808
|
const data = parsed.data;
|
|
10220
10809
|
const batch = String(data.test_batch ?? basename5(relPath, extname(relPath))).trim();
|
|
@@ -10256,10 +10845,10 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10256
10845
|
const tcAnnotationRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+?)\s+\[(\w+)\]/;
|
|
10257
10846
|
const tcAnnotationNoLevelRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+)/;
|
|
10258
10847
|
for (const specFile of specFiles) {
|
|
10259
|
-
const fullSpecPath =
|
|
10848
|
+
const fullSpecPath = join12(root, specFile);
|
|
10260
10849
|
let content;
|
|
10261
10850
|
try {
|
|
10262
|
-
content = await
|
|
10851
|
+
content = await readFile5(fullSpecPath, "utf-8");
|
|
10263
10852
|
} catch {
|
|
10264
10853
|
continue;
|
|
10265
10854
|
}
|
|
@@ -10338,7 +10927,7 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10338
10927
|
if (entry.testId) {
|
|
10339
10928
|
let content;
|
|
10340
10929
|
try {
|
|
10341
|
-
content = await
|
|
10930
|
+
content = await readFile5(join12(root, normalizedRefFile), "utf-8");
|
|
10342
10931
|
} catch {
|
|
10343
10932
|
continue;
|
|
10344
10933
|
}
|
|
@@ -10573,7 +11162,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
|
|
|
10573
11162
|
let hasActiveE2eRef = false;
|
|
10574
11163
|
for (const entry of parseExecutableRefLines(execRef)) {
|
|
10575
11164
|
const normalized = resolveExecutableRefFile(entry.file, allProjectFiles);
|
|
10576
|
-
if (!normalized || !existsSync3(
|
|
11165
|
+
if (!normalized || !existsSync3(join12(root, normalized))) continue;
|
|
10577
11166
|
const accepting = await getAcceptingRunners(root, normalized, runners);
|
|
10578
11167
|
if (accepting.some((runner) => runner.kind === "e2e")) {
|
|
10579
11168
|
hasActiveE2eRef = true;
|
|
@@ -10632,7 +11221,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
|
|
|
10632
11221
|
const acCoverageRateByFeature = {};
|
|
10633
11222
|
const featureAcMap = /* @__PURE__ */ new Map();
|
|
10634
11223
|
for (const node of featureNodes) {
|
|
10635
|
-
const acs = parseAcceptanceCriteria(await
|
|
11224
|
+
const acs = parseAcceptanceCriteria(await readFile5(join12(root, node.path), "utf-8"));
|
|
10636
11225
|
featureAcMap.set(node.code, new Set(acs));
|
|
10637
11226
|
}
|
|
10638
11227
|
const coveredAcByFeature = /* @__PURE__ */ new Map();
|
|
@@ -10680,8 +11269,8 @@ async function generateE2eRegistry(root, opts) {
|
|
|
10680
11269
|
const batchIds = /* @__PURE__ */ new Set();
|
|
10681
11270
|
let totalTestCases = 0;
|
|
10682
11271
|
for (const file of files) {
|
|
10683
|
-
const filePath =
|
|
10684
|
-
const raw = await
|
|
11272
|
+
const filePath = join12(root, file);
|
|
11273
|
+
const raw = await readFile5(filePath, "utf-8");
|
|
10685
11274
|
const parsed = matter(raw);
|
|
10686
11275
|
const data = parsed.data;
|
|
10687
11276
|
const batch = String(data.test_batch ?? basename5(file, extname(file))).trim();
|
|
@@ -10806,10 +11395,10 @@ async function validatePartialRustEvidence(tcFields, tcKey, root, allFiles) {
|
|
|
10806
11395
|
if (!normalizedPath) {
|
|
10807
11396
|
return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
|
|
10808
11397
|
}
|
|
10809
|
-
const fullPath =
|
|
11398
|
+
const fullPath = join12(root, normalizedPath);
|
|
10810
11399
|
let content;
|
|
10811
11400
|
try {
|
|
10812
|
-
content = await
|
|
11401
|
+
content = await readFile5(fullPath, "utf-8");
|
|
10813
11402
|
} catch {
|
|
10814
11403
|
return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
|
|
10815
11404
|
}
|
|
@@ -10843,7 +11432,7 @@ function detectTestLevel(specFile, content) {
|
|
|
10843
11432
|
}
|
|
10844
11433
|
function resolveExecutableRefFile(refFile, allFiles) {
|
|
10845
11434
|
const normalized = refFile.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
10846
|
-
if (!normalized ||
|
|
11435
|
+
if (!normalized || isAbsolute7(refFile) || normalized.split("/").includes("..")) {
|
|
10847
11436
|
return void 0;
|
|
10848
11437
|
}
|
|
10849
11438
|
if (allFiles.includes(normalized)) {
|
|
@@ -11425,7 +12014,7 @@ function resolveArtifactContext(graph, opts) {
|
|
|
11425
12014
|
}
|
|
11426
12015
|
if (root) {
|
|
11427
12016
|
for (const ap of ALWAYS_PRESENT_ITEMS) {
|
|
11428
|
-
const fullPath =
|
|
12017
|
+
const fullPath = join12(root, ap.path);
|
|
11429
12018
|
let stat3;
|
|
11430
12019
|
try {
|
|
11431
12020
|
stat3 = statSync(fullPath);
|
|
@@ -11667,7 +12256,7 @@ function formatContextMarkdown(manifest) {
|
|
|
11667
12256
|
}
|
|
11668
12257
|
return lines.join("\n");
|
|
11669
12258
|
}
|
|
11670
|
-
var TARGET_ARTIFACT_TYPES, NON_TARGET_ROLES, DEFAULT_SCHEMA, SPECIALIZED_PARSER_TYPES, EMPTY_RELATION_FIELD_VALUES, VALID_TC_STATUSES, VALID_CHAIN_TYPES, DEPRECATED_CHAIN_TYPE_ALIASES, CONTEXT_CATEGORIES, TIER_ORDER;
|
|
12259
|
+
var configDiagnosticsBySchema, DEFAULT_ALLOWED_EDGES, TARGET_ARTIFACT_TYPES, NON_TARGET_ROLES, DEFAULT_SCHEMA, SPECIALIZED_PARSER_TYPES, EMPTY_RELATION_FIELD_VALUES, VALID_TC_STATUSES, VALID_CHAIN_TYPES, DEPRECATED_CHAIN_TYPE_ALIASES, CONTEXT_CATEGORIES, TIER_ORDER;
|
|
11671
12260
|
var init_index = __esm({
|
|
11672
12261
|
"src/index.ts"() {
|
|
11673
12262
|
"use strict";
|
|
@@ -11675,6 +12264,8 @@ var init_index = __esm({
|
|
|
11675
12264
|
init_packet_validator();
|
|
11676
12265
|
init_glob_matcher();
|
|
11677
12266
|
init_file_walker();
|
|
12267
|
+
init_doctor();
|
|
12268
|
+
init_doctor();
|
|
11678
12269
|
init_packet_constants();
|
|
11679
12270
|
init_target_selector();
|
|
11680
12271
|
init_impact();
|
|
@@ -11695,6 +12286,44 @@ var init_index = __esm({
|
|
|
11695
12286
|
init_restructure();
|
|
11696
12287
|
init_restructure_file_set();
|
|
11697
12288
|
init_restructure_software();
|
|
12289
|
+
configDiagnosticsBySchema = /* @__PURE__ */ new WeakMap();
|
|
12290
|
+
DEFAULT_ALLOWED_EDGES = [
|
|
12291
|
+
edgeRule("feature", "scenario", "covers"),
|
|
12292
|
+
edgeRule("feature", "decision", "references"),
|
|
12293
|
+
edgeRule("feature", "feature", "depends_on"),
|
|
12294
|
+
edgeRule("feature", "design", "references"),
|
|
12295
|
+
edgeRule("scenario", "feature", "references"),
|
|
12296
|
+
edgeRule("scenario", "decision", "references"),
|
|
12297
|
+
edgeRule("scenario", "entity", "references"),
|
|
12298
|
+
edgeRule("entity", "decision", "references"),
|
|
12299
|
+
edgeRule("decision", "feature", "references"),
|
|
12300
|
+
edgeRule("decision", "scenario", "references"),
|
|
12301
|
+
edgeRule("design", "feature", "references"),
|
|
12302
|
+
edgeRule("design", "scenario", "references"),
|
|
12303
|
+
edgeRule("design", "decision", "references"),
|
|
12304
|
+
edgeRule("design", "entity", "references"),
|
|
12305
|
+
edgeRule("test", "feature", "verifies"),
|
|
12306
|
+
edgeRule("test", "scenario", "verifies"),
|
|
12307
|
+
edgeRule("test", "decision", "verifies"),
|
|
12308
|
+
edgeRule("test", "entity", "verifies"),
|
|
12309
|
+
edgeRule("implementation", "feature", "implements"),
|
|
12310
|
+
edgeRule("implementation", "scenario", "implements"),
|
|
12311
|
+
edgeRule("implementation", "decision", "implements"),
|
|
12312
|
+
edgeRule("implementation", "entity", "implements"),
|
|
12313
|
+
edgeRule("e2e_test", "scenario", "verifies"),
|
|
12314
|
+
edgeRule("e2e_test", "feature", "verifies"),
|
|
12315
|
+
edgeRule("e2e_test", "decision", "references"),
|
|
12316
|
+
edgeRule("e2e_test", "entity", "references"),
|
|
12317
|
+
edgeRule("rule-golden-cases", "design", "references"),
|
|
12318
|
+
edgeRule("traceability-matrix-v2", "traceability-matrix-v2", "references"),
|
|
12319
|
+
edgeRule("traceability-matrix-v2", "traceability-matrix-v2", "covers"),
|
|
12320
|
+
edgeRule("traceability-matrix-v2", "resolve", "references"),
|
|
12321
|
+
edgeRule("traceability-matrix-v2", "resolve", "covers"),
|
|
12322
|
+
...["feature", "scenario", "decision", "design", "entity", "test", "e2e_test"].flatMap((to) => [
|
|
12323
|
+
edgeRule("traceability-matrix-v2", to, "references"),
|
|
12324
|
+
edgeRule("traceability-matrix-v2", to, "covers")
|
|
12325
|
+
])
|
|
12326
|
+
];
|
|
11698
12327
|
TARGET_ARTIFACT_TYPES = VALID_PACKET_TARGET_TYPES;
|
|
11699
12328
|
NON_TARGET_ROLES = ["context", "candidate", "not-recommended"];
|
|
11700
12329
|
DEFAULT_SCHEMA = {
|
|
@@ -11732,7 +12361,7 @@ var init_index = __esm({
|
|
|
11732
12361
|
e2e_test: ["test_batch", "scope", "ac_coverage", "related_scenarios", "related_decisions", "related_entities", "\u8986\u76D6\u573A\u666F", "\u8986\u76D6\u529F\u80FD"],
|
|
11733
12362
|
e2e_registry: ["batches"]
|
|
11734
12363
|
},
|
|
11735
|
-
allowedEdges:
|
|
12364
|
+
allowedEdges: DEFAULT_ALLOWED_EDGES,
|
|
11736
12365
|
forbiddenEdges: [{ from: "scenario", to: "entity", kind: "references" }],
|
|
11737
12366
|
statuses: ["planned", "active", "done", "deprecated"],
|
|
11738
12367
|
idRanges: {},
|
|
@@ -11813,7 +12442,7 @@ var init_index = __esm({
|
|
|
11813
12442
|
|
|
11814
12443
|
// src/packet-prompt-audit.ts
|
|
11815
12444
|
import { mkdir as mkdir6, writeFile as writeFile4 } from "fs/promises";
|
|
11816
|
-
import { join as
|
|
12445
|
+
import { join as join13 } from "path";
|
|
11817
12446
|
function promptFilename(target) {
|
|
11818
12447
|
return `prompt-${target.type}-${target.id}.md`;
|
|
11819
12448
|
}
|
|
@@ -11865,7 +12494,7 @@ async function auditSinglePromptTarget(target, graph, options) {
|
|
|
11865
12494
|
}
|
|
11866
12495
|
if (options.outDir) {
|
|
11867
12496
|
const filename = promptFilename(target);
|
|
11868
|
-
const outPath =
|
|
12497
|
+
const outPath = join13(options.outDir, filename);
|
|
11869
12498
|
await writeFile4(outPath, prompt, "utf-8");
|
|
11870
12499
|
entry.outputPath = outPath;
|
|
11871
12500
|
}
|
|
@@ -11971,9 +12600,9 @@ async function auditPromptBatch(root, targets, options, graph) {
|
|
|
11971
12600
|
};
|
|
11972
12601
|
if (options.outDir) {
|
|
11973
12602
|
await mkdir6(options.outDir, { recursive: true });
|
|
11974
|
-
const jsonPath =
|
|
12603
|
+
const jsonPath = join13(options.outDir, "prompt-audit-summary.json");
|
|
11975
12604
|
await writeFile4(jsonPath, JSON.stringify(summary, null, 2) + "\n", "utf-8");
|
|
11976
|
-
const mdPath =
|
|
12605
|
+
const mdPath = join13(options.outDir, "prompt-audit-summary.md");
|
|
11977
12606
|
await writeFile4(mdPath, renderPromptAuditSummaryMarkdown(summary), "utf-8");
|
|
11978
12607
|
}
|
|
11979
12608
|
return summary;
|
|
@@ -12013,10 +12642,10 @@ __export(refactor_id_exports, {
|
|
|
12013
12642
|
refactorId: () => refactorId,
|
|
12014
12643
|
renderRefactorIdMarkdown: () => renderRefactorIdMarkdown
|
|
12015
12644
|
});
|
|
12016
|
-
import { chmod as chmod2, readFile as
|
|
12645
|
+
import { chmod as chmod2, readFile as readFile6, rename as rename2, rm, readdir as readdir4, stat as stat2, writeFile as writeFile5 } from "fs/promises";
|
|
12017
12646
|
import { randomBytes } from "crypto";
|
|
12018
|
-
import { basename as basename6, dirname as dirname8, join as
|
|
12019
|
-
import
|
|
12647
|
+
import { basename as basename6, dirname as dirname8, join as join14, relative as relative5 } from "path";
|
|
12648
|
+
import yaml3 from "js-yaml";
|
|
12020
12649
|
function escapeRegExp2(value) {
|
|
12021
12650
|
return value.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
12022
12651
|
}
|
|
@@ -12113,7 +12742,7 @@ function planFrontmatterEdits(path, raw, fileType, oldId, newId, config, isOwnFi
|
|
|
12113
12742
|
if (!block) return [];
|
|
12114
12743
|
let data;
|
|
12115
12744
|
try {
|
|
12116
|
-
const loaded =
|
|
12745
|
+
const loaded = yaml3.load(block.text);
|
|
12117
12746
|
if (typeof loaded !== "object" || loaded === null || Array.isArray(loaded)) return [];
|
|
12118
12747
|
data = loaded;
|
|
12119
12748
|
} catch {
|
|
@@ -12193,7 +12822,7 @@ async function walkTextFiles(root) {
|
|
|
12193
12822
|
for (const entry of entries) {
|
|
12194
12823
|
if (entry.name.startsWith(".") && PROSE_SCAN_SKIP_DIRS.has(entry.name)) continue;
|
|
12195
12824
|
if (PROSE_SCAN_SKIP_DIRS.has(entry.name)) continue;
|
|
12196
|
-
const full =
|
|
12825
|
+
const full = join14(dir, entry.name);
|
|
12197
12826
|
if (entry.isDirectory()) {
|
|
12198
12827
|
await visit(full);
|
|
12199
12828
|
} else if (entry.isFile()) {
|
|
@@ -12208,7 +12837,7 @@ async function walkTextFiles(root) {
|
|
|
12208
12837
|
return found.sort();
|
|
12209
12838
|
}
|
|
12210
12839
|
async function computeLockImpact(root, type, oldId) {
|
|
12211
|
-
const lockPath =
|
|
12840
|
+
const lockPath = join14(root, VERSION_LOCK_PATH);
|
|
12212
12841
|
const impact = {
|
|
12213
12842
|
lockPath: VERSION_LOCK_PATH,
|
|
12214
12843
|
affectedImplementationLocks: [],
|
|
@@ -12217,7 +12846,7 @@ async function computeLockImpact(root, type, oldId) {
|
|
|
12217
12846
|
};
|
|
12218
12847
|
let raw;
|
|
12219
12848
|
try {
|
|
12220
|
-
raw = await
|
|
12849
|
+
raw = await readFile6(lockPath, "utf-8");
|
|
12221
12850
|
} catch {
|
|
12222
12851
|
return impact;
|
|
12223
12852
|
}
|
|
@@ -12300,7 +12929,7 @@ async function refactorId(options) {
|
|
|
12300
12929
|
const fileContents = /* @__PURE__ */ new Map();
|
|
12301
12930
|
const readArtifactFile = async (path) => {
|
|
12302
12931
|
if (!fileContents.has(path)) {
|
|
12303
|
-
fileContents.set(path, await
|
|
12932
|
+
fileContents.set(path, await readFile6(join14(root, path), "utf-8"));
|
|
12304
12933
|
}
|
|
12305
12934
|
return fileContents.get(path);
|
|
12306
12935
|
};
|
|
@@ -12376,7 +13005,7 @@ async function refactorId(options) {
|
|
|
12376
13005
|
for (const relativePath of await walkTextFiles(root)) {
|
|
12377
13006
|
if (relativePath === VERSION_LOCK_PATH) continue;
|
|
12378
13007
|
if (relativePath === "artifact-graph.config.yaml") continue;
|
|
12379
|
-
const raw = await
|
|
13008
|
+
const raw = await readFile6(join14(root, relativePath), "utf-8");
|
|
12380
13009
|
if (!containsIdToken(raw, oldId)) continue;
|
|
12381
13010
|
const lines = raw.split(/\r?\n/);
|
|
12382
13011
|
lines.forEach((line, index) => {
|
|
@@ -12452,7 +13081,7 @@ async function refactorId(options) {
|
|
|
12452
13081
|
}
|
|
12453
13082
|
if (options.__beforeWriteVerify) await options.__beforeWriteVerify();
|
|
12454
13083
|
for (const path of targetFiles) {
|
|
12455
|
-
const disk = await
|
|
13084
|
+
const disk = await readFile6(join14(root, path), "utf-8");
|
|
12456
13085
|
if (disk !== fileContents.get(path)) {
|
|
12457
13086
|
return fail("PLAN_DRIFT", `\u8BA1\u5212\u4E0E\u5199\u5165\u4E4B\u95F4\u76EE\u6807\u6587\u4EF6\u53D1\u751F\u53D8\u5316\uFF08apply \u4E2D\u6B62\uFF0C\u96F6\u5199\u5165\uFF09\uFF1A${path}`, { path });
|
|
12458
13087
|
}
|
|
@@ -12463,7 +13092,7 @@ async function refactorId(options) {
|
|
|
12463
13092
|
const tempPathFor = options.__tempPathFor ?? ((targetPath) => {
|
|
12464
13093
|
tempSequence += 1;
|
|
12465
13094
|
const suffix = randomBytes(4).toString("hex");
|
|
12466
|
-
return
|
|
13095
|
+
return join14(dirname8(targetPath), `.${basename6(targetPath)}.${process.pid}.${tempSequence}.${suffix}.refactor-id.tmp`);
|
|
12467
13096
|
});
|
|
12468
13097
|
let stage = "write";
|
|
12469
13098
|
try {
|
|
@@ -12472,8 +13101,8 @@ async function refactorId(options) {
|
|
|
12472
13101
|
if (options.__injectWriteFailure?.(path)) {
|
|
12473
13102
|
throw Object.assign(new Error(`injected write failure: ${path}`), { code: "EINJECTED" });
|
|
12474
13103
|
}
|
|
12475
|
-
const original = fileContents.has(path) ? fileContents.get(path) : await
|
|
12476
|
-
const targetPath =
|
|
13104
|
+
const original = fileContents.has(path) ? fileContents.get(path) : await readFile6(join14(root, path), "utf-8");
|
|
13105
|
+
const targetPath = join14(root, path);
|
|
12477
13106
|
const originalMode = (await stat2(targetPath)).mode & 4095;
|
|
12478
13107
|
const tempPath = tempPathFor(targetPath);
|
|
12479
13108
|
await writeFile5(tempPath, newContents.get(path), { encoding: "utf-8", flag: "wx" });
|
|
@@ -12496,8 +13125,8 @@ async function refactorId(options) {
|
|
|
12496
13125
|
if (options.__injectRollbackFailure?.(entry.path)) {
|
|
12497
13126
|
throw Object.assign(new Error(`injected rollback failure: ${entry.path}`), { code: "EROLLBACKINJECTED" });
|
|
12498
13127
|
}
|
|
12499
|
-
await writeFile5(
|
|
12500
|
-
await chmod2(
|
|
13128
|
+
await writeFile5(join14(root, entry.path), entry.original, "utf-8");
|
|
13129
|
+
await chmod2(join14(root, entry.path), entry.originalMode);
|
|
12501
13130
|
} catch (rollbackError) {
|
|
12502
13131
|
rollbackErrors.push({ path: entry.path, message: rollbackError.message });
|
|
12503
13132
|
}
|
|
@@ -12628,10 +13257,10 @@ var cli_exports = {};
|
|
|
12628
13257
|
__export(cli_exports, {
|
|
12629
13258
|
runCli: () => runCli
|
|
12630
13259
|
});
|
|
12631
|
-
import
|
|
13260
|
+
import yaml4 from "js-yaml";
|
|
12632
13261
|
import { realpathSync as realpathSync2 } from "fs";
|
|
12633
|
-
import { access as access3, mkdir as mkdir7, readFile as
|
|
12634
|
-
import { dirname as dirname9, isAbsolute as
|
|
13262
|
+
import { access as access3, mkdir as mkdir7, readFile as readFile7, writeFile as writeFile6 } from "fs/promises";
|
|
13263
|
+
import { dirname as dirname9, isAbsolute as isAbsolute8, join as join15 } from "path";
|
|
12635
13264
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
12636
13265
|
async function runCli(argv, io = {}) {
|
|
12637
13266
|
const parsed = parseArgs(argv);
|
|
@@ -12659,7 +13288,7 @@ async function runCli(argv, io = {}) {
|
|
|
12659
13288
|
switch (parsed.command) {
|
|
12660
13289
|
case "init": {
|
|
12661
13290
|
await initConfig(root);
|
|
12662
|
-
out(`Created ${
|
|
13291
|
+
out(`Created ${join15(root, "artifact-graph.config.yaml")}
|
|
12663
13292
|
`);
|
|
12664
13293
|
return 0;
|
|
12665
13294
|
}
|
|
@@ -12684,7 +13313,7 @@ async function runCli(argv, io = {}) {
|
|
|
12684
13313
|
err("Usage: artifact-graph check-professional --root <target> --format json [--conclusion-output <absolute-path>]\n");
|
|
12685
13314
|
return 1;
|
|
12686
13315
|
}
|
|
12687
|
-
if (typeof conclusionOutput === "string" && !
|
|
13316
|
+
if (typeof conclusionOutput === "string" && !isAbsolute8(conclusionOutput)) {
|
|
12688
13317
|
err("--conclusion-output must be an absolute path\n");
|
|
12689
13318
|
return 1;
|
|
12690
13319
|
}
|
|
@@ -13097,7 +13726,7 @@ async function runCli(argv, io = {}) {
|
|
|
13097
13726
|
if (packetJsonPath) {
|
|
13098
13727
|
let rawJson;
|
|
13099
13728
|
try {
|
|
13100
|
-
rawJson = await
|
|
13729
|
+
rawJson = await readFile7(packetJsonPath, "utf-8");
|
|
13101
13730
|
} catch (readErr) {
|
|
13102
13731
|
err(`\u9519\u8BEF\uFF1A\u65E0\u6CD5\u8BFB\u53D6 packet \u6587\u4EF6: "${packetJsonPath}" \u2014 ${readErr.message}
|
|
13103
13732
|
`);
|
|
@@ -13298,7 +13927,7 @@ async function runCli(argv, io = {}) {
|
|
|
13298
13927
|
universalBaseline: discoverConfig.context?.universal_baseline
|
|
13299
13928
|
});
|
|
13300
13929
|
} else {
|
|
13301
|
-
const targetsContent = await
|
|
13930
|
+
const targetsContent = await readFile7(targetsFile, "utf-8");
|
|
13302
13931
|
const auditConfig2 = await loadConfig(root);
|
|
13303
13932
|
const parseResult = parseTargetsFile(targetsContent, auditConfig2);
|
|
13304
13933
|
if (parseResult.errors.length > 0) {
|
|
@@ -13423,7 +14052,7 @@ async function runCli(argv, io = {}) {
|
|
|
13423
14052
|
} else {
|
|
13424
14053
|
let ppaTargetsContent;
|
|
13425
14054
|
try {
|
|
13426
|
-
ppaTargetsContent = await
|
|
14055
|
+
ppaTargetsContent = await readFile7(ppaTargetsFile, "utf-8");
|
|
13427
14056
|
} catch (readErr) {
|
|
13428
14057
|
err(`\u9519\u8BEF\uFF1A\u65E0\u6CD5\u8BFB\u53D6 targets \u6587\u4EF6: "${ppaTargetsFile}" \u2014 ${readErr.message}
|
|
13429
14058
|
`);
|
|
@@ -13681,7 +14310,7 @@ async function runCli(argv, io = {}) {
|
|
|
13681
14310
|
const prepared = [];
|
|
13682
14311
|
for (const hookName of hooks) {
|
|
13683
14312
|
const templatePath = fileURLToPath3(new URL(`../templates/git-hooks/${hookName}.sh`, import.meta.url));
|
|
13684
|
-
const block = await
|
|
14313
|
+
const block = await readFile7(templatePath, "utf-8");
|
|
13685
14314
|
prepared.push(await prepareManagedHookBlock({
|
|
13686
14315
|
hookPath: await resolveGitHookPath(root, hookName),
|
|
13687
14316
|
block,
|
|
@@ -13707,8 +14336,8 @@ async function runCli(argv, io = {}) {
|
|
|
13707
14336
|
out(`${JSON.stringify(report, null, 2)}
|
|
13708
14337
|
`);
|
|
13709
14338
|
} else {
|
|
13710
|
-
const config = await loadConfig(root);
|
|
13711
14339
|
out(renderDoctorMarkdown(report));
|
|
14340
|
+
const config = await loadConfig(root);
|
|
13712
14341
|
out(`Types: ${Object.keys(config.types).sort().join(", ")}
|
|
13713
14342
|
`);
|
|
13714
14343
|
out(`Forbidden edges: ${config.forbiddenEdges.length}
|
|
@@ -13725,10 +14354,10 @@ async function runCli(argv, io = {}) {
|
|
|
13725
14354
|
err("Usage: artifact-graph validate-review-result --file <path> [--format json]\n");
|
|
13726
14355
|
return 1;
|
|
13727
14356
|
}
|
|
13728
|
-
const resolvedPath =
|
|
14357
|
+
const resolvedPath = isAbsolute8(filePath) ? filePath : join15(root, filePath);
|
|
13729
14358
|
let content;
|
|
13730
14359
|
try {
|
|
13731
|
-
content = await
|
|
14360
|
+
content = await readFile7(resolvedPath, "utf-8");
|
|
13732
14361
|
} catch (readErr) {
|
|
13733
14362
|
err(`Error: Cannot read file: "${resolvedPath}" \u2014 ${readErr.message}
|
|
13734
14363
|
`);
|
|
@@ -13763,11 +14392,11 @@ async function runCli(argv, io = {}) {
|
|
|
13763
14392
|
const deterministic = checkMode || parsed.flags.deterministic === true;
|
|
13764
14393
|
const registry = await generateE2eRegistry(root, { deterministic });
|
|
13765
14394
|
const output = JSON.stringify(registry, null, 2) + "\n";
|
|
13766
|
-
const outPath = typeof parsed.flags.out === "string" ? parsed.flags.out :
|
|
14395
|
+
const outPath = typeof parsed.flags.out === "string" ? parsed.flags.out : join15(root, "artifacts/tests/e2e/e2e-test-registry.json");
|
|
13767
14396
|
if (checkMode) {
|
|
13768
14397
|
let existing = "";
|
|
13769
14398
|
try {
|
|
13770
|
-
existing = await
|
|
14399
|
+
existing = await readFile7(outPath, "utf-8");
|
|
13771
14400
|
} catch {
|
|
13772
14401
|
err(`Check failed: ${outPath} does not exist or is not readable
|
|
13773
14402
|
`);
|
|
@@ -13815,10 +14444,10 @@ async function runCli(argv, io = {}) {
|
|
|
13815
14444
|
`);
|
|
13816
14445
|
return 1;
|
|
13817
14446
|
}
|
|
13818
|
-
const planPath =
|
|
14447
|
+
const planPath = isAbsolute8(planFlag) ? planFlag : join15(cwd, planFlag);
|
|
13819
14448
|
let planDocument;
|
|
13820
14449
|
try {
|
|
13821
|
-
planDocument = JSON.parse(await
|
|
14450
|
+
planDocument = JSON.parse(await readFile7(planPath, "utf8"));
|
|
13822
14451
|
} catch (planError) {
|
|
13823
14452
|
out(`${JSON.stringify({ ok: false, error: { code: "PLAN_UNREADABLE", message: `Cannot read a plan document from ${planPath}: ${planError.message}` } }, null, 2)}
|
|
13824
14453
|
`);
|
|
@@ -13882,10 +14511,10 @@ async function runCli(argv, io = {}) {
|
|
|
13882
14511
|
`);
|
|
13883
14512
|
return 1;
|
|
13884
14513
|
}
|
|
13885
|
-
const resolvedInput =
|
|
14514
|
+
const resolvedInput = isAbsolute8(inputPath) ? inputPath : join15(cwd, inputPath);
|
|
13886
14515
|
let input;
|
|
13887
14516
|
try {
|
|
13888
|
-
input = JSON.parse(await
|
|
14517
|
+
input = JSON.parse(await readFile7(resolvedInput, "utf8"));
|
|
13889
14518
|
} catch (inputError) {
|
|
13890
14519
|
out(`${JSON.stringify({ ok: false, error: { code: "INPUT_INVALID", message: `Cannot read valid JSON from ${inputPath}: ${inputError.message}` } }, null, 2)}
|
|
13891
14520
|
`);
|
|
@@ -13911,7 +14540,7 @@ async function runCli(argv, io = {}) {
|
|
|
13911
14540
|
return 1;
|
|
13912
14541
|
}
|
|
13913
14542
|
const packageDir = dirname9(fileURLToPath3(import.meta.url));
|
|
13914
|
-
const contractsDir = typeof parsed.flags["contracts-dir"] === "string" ? parsed.flags["contracts-dir"] :
|
|
14543
|
+
const contractsDir = typeof parsed.flags["contracts-dir"] === "string" ? parsed.flags["contracts-dir"] : join15(packageDir, "..", "contracts");
|
|
13915
14544
|
const revisionDigest = typeof parsed.flags["revision-digest"] === "string" ? parsed.flags["revision-digest"] : void 0;
|
|
13916
14545
|
async function resolveContract(contractId) {
|
|
13917
14546
|
const catalog = await loadContractCatalog(contractsDir);
|
|
@@ -14125,7 +14754,7 @@ async function runCli(argv, io = {}) {
|
|
|
14125
14754
|
}
|
|
14126
14755
|
let markdownContent;
|
|
14127
14756
|
try {
|
|
14128
|
-
markdownContent = await
|
|
14757
|
+
markdownContent = await readFile7(markdownPath, "utf-8");
|
|
14129
14758
|
} catch {
|
|
14130
14759
|
out(`${JSON.stringify({ ok: false, error: { code: "SCHEMA_VALIDATION_FAILED", path: "/markdown", message: `Could not read markdown file "${markdownPath}"` } }, null, 2)}
|
|
14131
14760
|
`);
|
|
@@ -14224,7 +14853,7 @@ function isGraphRelevantPath(path, schema) {
|
|
|
14224
14853
|
return path === "artifact-graph.config.yaml" || path === VERSION_LOCK_PATH || matchesConfiguredArtifactPath(path, schema);
|
|
14225
14854
|
}
|
|
14226
14855
|
async function initConfig(root) {
|
|
14227
|
-
const configPath =
|
|
14856
|
+
const configPath = join15(root, "artifact-graph.config.yaml");
|
|
14228
14857
|
try {
|
|
14229
14858
|
await access3(configPath);
|
|
14230
14859
|
throw new Error(`Config already exists: ${configPath}`);
|
|
@@ -14234,7 +14863,7 @@ async function initConfig(root) {
|
|
|
14234
14863
|
}
|
|
14235
14864
|
}
|
|
14236
14865
|
await mkdir7(root, { recursive: true });
|
|
14237
|
-
await writeFile6(configPath,
|
|
14866
|
+
await writeFile6(configPath, yaml4.dump(DEFAULT_SCHEMA, { lineWidth: 120 }));
|
|
14238
14867
|
}
|
|
14239
14868
|
function parseArgs(argv) {
|
|
14240
14869
|
const [command, ...rest] = argv;
|
|
@@ -14278,13 +14907,13 @@ function parseTimeViewFlag(value, err) {
|
|
|
14278
14907
|
}
|
|
14279
14908
|
async function readReleaseInput(root, value) {
|
|
14280
14909
|
if (value.includes(",")) return value.split(",");
|
|
14281
|
-
const candidate =
|
|
14910
|
+
const candidate = isAbsolute8(value) ? value : join15(root, value);
|
|
14282
14911
|
try {
|
|
14283
14912
|
await access3(candidate);
|
|
14284
14913
|
} catch {
|
|
14285
14914
|
return [value];
|
|
14286
14915
|
}
|
|
14287
|
-
const raw = await
|
|
14916
|
+
const raw = await readFile7(candidate, "utf-8");
|
|
14288
14917
|
try {
|
|
14289
14918
|
const parsed = JSON.parse(raw);
|
|
14290
14919
|
if (Array.isArray(parsed) && parsed.every((item) => typeof item === "string")) return parsed;
|