artifact-graph 0.14.1 → 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 +29 -0
- package/INSTALL.md +9 -0
- package/README.md +24 -1
- package/README.zh-CN.md +20 -1
- package/contracts/spec/schema.json +44 -0
- package/dist/cli.js +905 -271
- package/dist/index.cjs +787 -323
- package/dist/index.d.cts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +837 -227
- package/package.json +4 -1
- package/profiles/project-artifact-profiles.json +109 -0
- package/schemas/project-artifact-profiles.schema.json +120 -0
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,
|
|
@@ -926,17 +1450,22 @@ async function bootstrapVersionLock(root, options = {}) {
|
|
|
926
1450
|
source: sourceRefFromNode(source)
|
|
927
1451
|
});
|
|
928
1452
|
}
|
|
929
|
-
const artifactRelationEntries =
|
|
1453
|
+
const artifactRelationEntries = /* @__PURE__ */ new Map();
|
|
930
1454
|
for (const edge2 of artifactRelationEdges(index)) {
|
|
931
1455
|
const source = nodeByUid.get(edge2.from);
|
|
932
1456
|
const target = nodeByUid.get(edge2.to);
|
|
933
1457
|
if (!source || !target) continue;
|
|
934
|
-
|
|
1458
|
+
const relationLock = artifactRelationLockFromEdge(edge2, source, target);
|
|
1459
|
+
const identity = artifactRelationLockSortKey(relationLock);
|
|
1460
|
+
if (artifactRelationEntries.has(identity)) {
|
|
1461
|
+
continue;
|
|
1462
|
+
}
|
|
1463
|
+
artifactRelationEntries.set(identity, relationLock);
|
|
935
1464
|
}
|
|
936
1465
|
const next = {
|
|
937
1466
|
schemaVersion: VERSION_LOCK_SCHEMA_VERSION,
|
|
938
1467
|
locks: sortBy([...entries.values()], (item) => item.edgeId),
|
|
939
|
-
artifactRelations: sortBy(artifactRelationEntries, artifactRelationLockSortKey)
|
|
1468
|
+
artifactRelations: sortBy([...artifactRelationEntries.values()], artifactRelationLockSortKey)
|
|
940
1469
|
};
|
|
941
1470
|
await writeVersionLock(root, lockPath, next);
|
|
942
1471
|
return next;
|
|
@@ -1324,7 +1853,7 @@ function renderTraceVersionMarkdown(result) {
|
|
|
1324
1853
|
async function readVersionLock(root, lockPath) {
|
|
1325
1854
|
const safeLockPath = normalizeRelativePath(root, lockPath);
|
|
1326
1855
|
try {
|
|
1327
|
-
const raw = await
|
|
1856
|
+
const raw = await readFile2(join3(root, safeLockPath), "utf-8");
|
|
1328
1857
|
let parsed;
|
|
1329
1858
|
try {
|
|
1330
1859
|
parsed = JSON.parse(raw);
|
|
@@ -1483,7 +2012,7 @@ function requireSafeRelativePath(value, path) {
|
|
|
1483
2012
|
}
|
|
1484
2013
|
async function writeVersionLock(root, lockPath, lock) {
|
|
1485
2014
|
const safeLockPath = normalizeRelativePath(root, lockPath);
|
|
1486
|
-
const fullPath =
|
|
2015
|
+
const fullPath = join3(root, safeLockPath);
|
|
1487
2016
|
await mkdir(dirname(fullPath), { recursive: true });
|
|
1488
2017
|
await writeFile(fullPath, `${JSON.stringify(lock, null, 2)}
|
|
1489
2018
|
`);
|
|
@@ -1666,7 +2195,7 @@ async function hashRelativePath(root, path, cache) {
|
|
|
1666
2195
|
const normalized = normalizeRelativePath(root, path);
|
|
1667
2196
|
const cached = cache.get(normalized);
|
|
1668
2197
|
if (cached) return cached;
|
|
1669
|
-
const content = await
|
|
2198
|
+
const content = await readFile2(join3(root, normalized));
|
|
1670
2199
|
const hash = `sha256:${createHash("sha256").update(content).digest("hex")}`;
|
|
1671
2200
|
cache.set(normalized, hash);
|
|
1672
2201
|
return hash;
|
|
@@ -1689,10 +2218,10 @@ async function getTestFileRunnerLiveness(root, filePath, config) {
|
|
|
1689
2218
|
if (!/e2e/i.test(filePath) && !/\.e2e\./i.test(filePath)) {
|
|
1690
2219
|
return "active";
|
|
1691
2220
|
}
|
|
1692
|
-
const fullSourcePath =
|
|
2221
|
+
const fullSourcePath = join3(root, filePath);
|
|
1693
2222
|
if (!existsSync(fullSourcePath)) return "inactive";
|
|
1694
2223
|
try {
|
|
1695
|
-
const content = await
|
|
2224
|
+
const content = await readFile2(fullSourcePath, "utf-8");
|
|
1696
2225
|
return /\/\/!?\s*@(?:e2e_test|tc)\s+/.test(content) ? "active" : "inactive";
|
|
1697
2226
|
} catch {
|
|
1698
2227
|
return "inactive";
|
|
@@ -1755,7 +2284,7 @@ var init_versioned_traceability = __esm({
|
|
|
1755
2284
|
});
|
|
1756
2285
|
|
|
1757
2286
|
// src/impact.ts
|
|
1758
|
-
import { isAbsolute, normalize, relative as relative3, resolve } from "path";
|
|
2287
|
+
import { isAbsolute as isAbsolute2, normalize, relative as relative3, resolve } from "path";
|
|
1759
2288
|
async function computeImpact(root, options = {}) {
|
|
1760
2289
|
const absoluteRoot = resolve(root);
|
|
1761
2290
|
const mode = options.mode ?? "worktree";
|
|
@@ -1829,7 +2358,7 @@ function normalizeExplicitPaths(root, paths) {
|
|
|
1829
2358
|
const normalized = paths.map((input) => {
|
|
1830
2359
|
const value = input.trim();
|
|
1831
2360
|
if (!value) return "";
|
|
1832
|
-
const absolutePath =
|
|
2361
|
+
const absolutePath = isAbsolute2(value) ? normalize(value) : resolve(root, value);
|
|
1833
2362
|
const projectRelative = relative3(root, absolutePath);
|
|
1834
2363
|
const result = projectRelative.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
1835
2364
|
if (result === ".." || result.startsWith("../") || result.startsWith("/")) {
|
|
@@ -2448,7 +2977,7 @@ var init_packet_assembler = __esm({
|
|
|
2448
2977
|
|
|
2449
2978
|
// src/packet-audit.ts
|
|
2450
2979
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
2451
|
-
import { join as
|
|
2980
|
+
import { join as join4 } from "path";
|
|
2452
2981
|
function parseTargetsFile(content, schema) {
|
|
2453
2982
|
const validTypes = schema ? new Set(getTargetArtifactTypes(schema)) : VALID_TYPES;
|
|
2454
2983
|
const validTypesLabel = [...validTypes].join(", ");
|
|
@@ -2539,7 +3068,7 @@ async function auditSingleTarget(target, graph, options) {
|
|
|
2539
3068
|
const fmt = options.format ?? "markdown";
|
|
2540
3069
|
const ext = fmt === "json" ? "json" : "md";
|
|
2541
3070
|
const filename = `${target.type}-${target.id}.packet.${ext}`;
|
|
2542
|
-
const outPath =
|
|
3071
|
+
const outPath = join4(options.outDir, filename);
|
|
2543
3072
|
let content;
|
|
2544
3073
|
if (fmt === "json") {
|
|
2545
3074
|
content = JSON.stringify(packet, null, 2) + "\n";
|
|
@@ -2619,7 +3148,7 @@ async function auditPackets(root, targets, options, graph) {
|
|
|
2619
3148
|
...isCompact ? { summaryDetail: "compact", countsByType } : {}
|
|
2620
3149
|
};
|
|
2621
3150
|
if (options.outDir) {
|
|
2622
|
-
const summaryPath =
|
|
3151
|
+
const summaryPath = join4(options.outDir, "summary.json");
|
|
2623
3152
|
await writeFile2(summaryPath, JSON.stringify(summary, null, 2) + "\n", "utf-8");
|
|
2624
3153
|
}
|
|
2625
3154
|
return summary;
|
|
@@ -2990,7 +3519,7 @@ var init_packet_prompt_validator = __esm({
|
|
|
2990
3519
|
// src/native-binding-diagnostics.ts
|
|
2991
3520
|
import { existsSync as existsSync2, readdirSync } from "fs";
|
|
2992
3521
|
import { createRequire } from "module";
|
|
2993
|
-
import { dirname as dirname2, join as
|
|
3522
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
2994
3523
|
import { fileURLToPath } from "url";
|
|
2995
3524
|
function parsePnpmVersion(stdout) {
|
|
2996
3525
|
const trimmed = stdout.trim();
|
|
@@ -3131,7 +3660,7 @@ function buildNativeBindingSuccessDiagnostic(probeContext) {
|
|
|
3131
3660
|
function findPackageRoot(anchorFile) {
|
|
3132
3661
|
let dir = dirname2(anchorFile);
|
|
3133
3662
|
for (; ; ) {
|
|
3134
|
-
if (existsSync2(
|
|
3663
|
+
if (existsSync2(join5(dir, "package.json"))) return dir;
|
|
3135
3664
|
const parent = dirname2(dir);
|
|
3136
3665
|
if (parent === dir) return void 0;
|
|
3137
3666
|
dir = parent;
|
|
@@ -3169,9 +3698,9 @@ function abiPrebuiltHint(detail) {
|
|
|
3169
3698
|
return match ? `\uFF1Bprebuilt \u76EE\u6807 NODE_MODULE_VERSION=${match[1]}` : "";
|
|
3170
3699
|
}
|
|
3171
3700
|
function betterSqlite3PackagePresent(root) {
|
|
3172
|
-
const direct =
|
|
3701
|
+
const direct = join5(root, "node_modules", "better-sqlite3", "package.json");
|
|
3173
3702
|
if (existsSync2(direct)) return true;
|
|
3174
|
-
const pnpmDir =
|
|
3703
|
+
const pnpmDir = join5(root, "node_modules", ".pnpm");
|
|
3175
3704
|
let entries;
|
|
3176
3705
|
try {
|
|
3177
3706
|
entries = readdirSync(pnpmDir);
|
|
@@ -3180,7 +3709,7 @@ function betterSqlite3PackagePresent(root) {
|
|
|
3180
3709
|
}
|
|
3181
3710
|
return entries.some((entry) => {
|
|
3182
3711
|
if (!entry.startsWith("better-sqlite3@")) return false;
|
|
3183
|
-
return existsSync2(
|
|
3712
|
+
return existsSync2(join5(pnpmDir, entry, "node_modules", "better-sqlite3", "package.json"));
|
|
3184
3713
|
});
|
|
3185
3714
|
}
|
|
3186
3715
|
var PNPM_ALLOW_BUILDS_SNIPPET;
|
|
@@ -3195,7 +3724,7 @@ var init_native_binding_diagnostics = __esm({
|
|
|
3195
3724
|
import { execFile as execFile2 } from "child_process";
|
|
3196
3725
|
import { constants, readFileSync, realpathSync } from "fs";
|
|
3197
3726
|
import { access } from "fs/promises";
|
|
3198
|
-
import { basename, dirname as dirname3, isAbsolute as
|
|
3727
|
+
import { basename, dirname as dirname3, isAbsolute as isAbsolute3, join as join6, resolve as resolve3 } from "path";
|
|
3199
3728
|
import { promisify as promisify2 } from "util";
|
|
3200
3729
|
async function resolveArtifactGraphCli(root, options = {}) {
|
|
3201
3730
|
const pathCli = await findCommandOnPath("artifact-graph");
|
|
@@ -3203,7 +3732,7 @@ async function resolveArtifactGraphCli(root, options = {}) {
|
|
|
3203
3732
|
const candidates = [
|
|
3204
3733
|
{
|
|
3205
3734
|
source: "node_modules",
|
|
3206
|
-
path:
|
|
3735
|
+
path: join6(root, "node_modules/.bin/artifact-graph"),
|
|
3207
3736
|
exists: false
|
|
3208
3737
|
},
|
|
3209
3738
|
{
|
|
@@ -3236,8 +3765,8 @@ async function resolveArtifactGraphCli(root, options = {}) {
|
|
|
3236
3765
|
}
|
|
3237
3766
|
async function doctorArtifactChain(root, options = {}) {
|
|
3238
3767
|
const cli = await resolveArtifactGraphCli(root, options);
|
|
3239
|
-
const configPath =
|
|
3240
|
-
const lockPath =
|
|
3768
|
+
const configPath = join6(root, "artifact-graph.config.yaml");
|
|
3769
|
+
const lockPath = join6(root, VERSION_LOCK_PATH);
|
|
3241
3770
|
const supportedCommands = cli.path ? await detectSupportedCommands(cli.path) : [];
|
|
3242
3771
|
const nodeCompatible = isNodeCompatible(process.versions.node);
|
|
3243
3772
|
const pnpmVersion = await detectPnpmVersion();
|
|
@@ -3257,12 +3786,28 @@ async function doctorArtifactChain(root, options = {}) {
|
|
|
3257
3786
|
probedFrom
|
|
3258
3787
|
};
|
|
3259
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
|
+
}
|
|
3260
3803
|
const warnings = [
|
|
3261
3804
|
...cli.warnings,
|
|
3262
3805
|
...nodeCompatible ? [] : [`Node.js ${process.versions.node} does not satisfy ${REQUIRED_NODE_VERSION}.`],
|
|
3263
3806
|
...probe.ok ? [] : [
|
|
3264
3807
|
`better-sqlite3 binding probe FAILED at stage "${probe.failedStage}" (cause ${probe.cause}): ${probe.suggestion}`
|
|
3265
|
-
]
|
|
3808
|
+
],
|
|
3809
|
+
...configShapeMessages,
|
|
3810
|
+
...loadConfigMessages
|
|
3266
3811
|
];
|
|
3267
3812
|
return {
|
|
3268
3813
|
schemaVersion: "1.0",
|
|
@@ -3372,7 +3917,7 @@ async function findCommandOnPath(command) {
|
|
|
3372
3917
|
}
|
|
3373
3918
|
}
|
|
3374
3919
|
function resolveCandidatePath(root, candidatePath) {
|
|
3375
|
-
return
|
|
3920
|
+
return isAbsolute3(candidatePath) ? candidatePath : resolve3(root, candidatePath);
|
|
3376
3921
|
}
|
|
3377
3922
|
function isNodeCompatible(version) {
|
|
3378
3923
|
const match = /^(\d+)\.(\d+)\.(\d+)(?:\+[0-9A-Za-z.-]+)?$/.exec(version);
|
|
@@ -3442,6 +3987,7 @@ var init_cli_resolver = __esm({
|
|
|
3442
3987
|
"src/cli-resolver.ts"() {
|
|
3443
3988
|
"use strict";
|
|
3444
3989
|
init_versioned_traceability();
|
|
3990
|
+
init_doctor();
|
|
3445
3991
|
init_native_binding_diagnostics();
|
|
3446
3992
|
execFileAsync2 = promisify2(execFile2);
|
|
3447
3993
|
REQUIRED_NODE_VERSION = ">=22.22.2 <23";
|
|
@@ -3473,7 +4019,7 @@ var init_cli_resolver = __esm({
|
|
|
3473
4019
|
|
|
3474
4020
|
// src/git-hook-path.ts
|
|
3475
4021
|
import { execFile as execFile3 } from "child_process";
|
|
3476
|
-
import { isAbsolute as
|
|
4022
|
+
import { isAbsolute as isAbsolute4, resolve as resolve4 } from "path";
|
|
3477
4023
|
import { promisify as promisify3 } from "util";
|
|
3478
4024
|
async function resolveGitHookPath(root, hookName) {
|
|
3479
4025
|
const { stdout } = await execFileAsync3("git", [
|
|
@@ -3485,7 +4031,7 @@ async function resolveGitHookPath(root, hookName) {
|
|
|
3485
4031
|
]);
|
|
3486
4032
|
const value = stdout.trim();
|
|
3487
4033
|
if (!value) throw new Error(`Git returned an empty hook path for ${hookName}`);
|
|
3488
|
-
return
|
|
4034
|
+
return isAbsolute4(value) ? resolve4(value) : resolve4(root, value);
|
|
3489
4035
|
}
|
|
3490
4036
|
var execFileAsync3;
|
|
3491
4037
|
var init_git_hook_path = __esm({
|
|
@@ -3499,7 +4045,7 @@ var init_git_hook_path = __esm({
|
|
|
3499
4045
|
import { constants as constants2 } from "fs";
|
|
3500
4046
|
import { randomUUID } from "crypto";
|
|
3501
4047
|
import { lstat, mkdir as mkdir3, open, readlink, rename, unlink } from "fs/promises";
|
|
3502
|
-
import { basename as basename2, dirname as dirname4, join as
|
|
4048
|
+
import { basename as basename2, dirname as dirname4, join as join7 } from "path";
|
|
3503
4049
|
function detectHookInterpreter(content) {
|
|
3504
4050
|
if (content.trim().length === 0) {
|
|
3505
4051
|
return "empty";
|
|
@@ -3605,6 +4151,10 @@ async function applyPreparedManagedHookBlocks(prepared) {
|
|
|
3605
4151
|
throw error;
|
|
3606
4152
|
}
|
|
3607
4153
|
}
|
|
4154
|
+
async function installManagedHookBlock(options) {
|
|
4155
|
+
const prepared = await prepareManagedHookBlock(options);
|
|
4156
|
+
return (await applyPreparedManagedHookBlocks([prepared]))[0];
|
|
4157
|
+
}
|
|
3608
4158
|
function beginMarker(markerId) {
|
|
3609
4159
|
return `# >>> ${markerId} managed block >>>`;
|
|
3610
4160
|
}
|
|
@@ -3807,7 +4357,7 @@ async function removeHookAtomically(hookPath, snapshot) {
|
|
|
3807
4357
|
}
|
|
3808
4358
|
async function writeHookAtomically(hookPath, content, snapshot, mode) {
|
|
3809
4359
|
await mkdir3(dirname4(hookPath), { recursive: true });
|
|
3810
|
-
const temporaryPath =
|
|
4360
|
+
const temporaryPath = join7(dirname4(hookPath), `.${basename2(hookPath)}.${randomUUID()}.tmp`);
|
|
3811
4361
|
let temporaryExists = false;
|
|
3812
4362
|
try {
|
|
3813
4363
|
const temporary = await open(temporaryPath, "wx", mode);
|
|
@@ -3925,7 +4475,7 @@ var init_hook_installer = __esm({
|
|
|
3925
4475
|
// src/professional-conclusion.ts
|
|
3926
4476
|
import { access as access2 } from "fs/promises";
|
|
3927
4477
|
import { createRequire as createRequire2 } from "module";
|
|
3928
|
-
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";
|
|
3929
4479
|
import { pathToFileURL } from "url";
|
|
3930
4480
|
async function loadContracts() {
|
|
3931
4481
|
return await import(CONTRACTS_PACKAGE_NAME);
|
|
@@ -3952,7 +4502,7 @@ function harnessKind(error) {
|
|
|
3952
4502
|
return typeof details?.kind === "string" ? details.kind : void 0;
|
|
3953
4503
|
}
|
|
3954
4504
|
async function missingRequiredConfig(root) {
|
|
3955
|
-
const configPath =
|
|
4505
|
+
const configPath = join8(root, "artifact-graph.config.yaml");
|
|
3956
4506
|
try {
|
|
3957
4507
|
await access2(configPath);
|
|
3958
4508
|
return void 0;
|
|
@@ -4125,7 +4675,7 @@ async function assertConclusionShape(conclusion) {
|
|
|
4125
4675
|
}
|
|
4126
4676
|
}
|
|
4127
4677
|
async function publishConclusion(absoluteOutput, conclusion) {
|
|
4128
|
-
if (!
|
|
4678
|
+
if (!isAbsolute5(absoluteOutput)) {
|
|
4129
4679
|
return "--conclusion-output must be an absolute path";
|
|
4130
4680
|
}
|
|
4131
4681
|
const outputRoot = dirname5(absoluteOutput);
|
|
@@ -4163,7 +4713,7 @@ async function runCheckProfessional(options) {
|
|
|
4163
4713
|
if (options.conclusionOutput === void 0) {
|
|
4164
4714
|
return { conclusion };
|
|
4165
4715
|
}
|
|
4166
|
-
if (!
|
|
4716
|
+
if (!isAbsolute5(options.conclusionOutput)) {
|
|
4167
4717
|
return { conclusion, writeError: "--conclusion-output must be an absolute path" };
|
|
4168
4718
|
}
|
|
4169
4719
|
const writeError = await publishConclusion(resolve5(options.conclusionOutput), conclusion);
|
|
@@ -4644,9 +5194,9 @@ __export(contract_kernel_exports, {
|
|
|
4644
5194
|
verifyDigest: () => verifyDigest
|
|
4645
5195
|
});
|
|
4646
5196
|
import { createHash as createHash2 } from "crypto";
|
|
4647
|
-
import { readFile as
|
|
4648
|
-
import { join as
|
|
4649
|
-
import
|
|
5197
|
+
import { readFile as readFile3, readdir as readdir2 } from "fs/promises";
|
|
5198
|
+
import { join as join9 } from "path";
|
|
5199
|
+
import _AjvModule2 from "ajv";
|
|
4650
5200
|
function isOfficialNamespace(namespace) {
|
|
4651
5201
|
return OFFICIAL_NAMESPACE_PATTERN.test(namespace);
|
|
4652
5202
|
}
|
|
@@ -5007,7 +5557,7 @@ function applyProjectPolicy(policy, baseContract) {
|
|
|
5007
5557
|
};
|
|
5008
5558
|
}
|
|
5009
5559
|
async function loadContract(contractPath, options) {
|
|
5010
|
-
const rawContent = await
|
|
5560
|
+
const rawContent = await readFile3(contractPath, "utf-8");
|
|
5011
5561
|
let schema;
|
|
5012
5562
|
try {
|
|
5013
5563
|
schema = JSON.parse(rawContent);
|
|
@@ -5058,7 +5608,7 @@ async function loadContractsFromDirectory(contractsDir, options) {
|
|
|
5058
5608
|
const entries = await readdir2(contractsDir, { withFileTypes: true });
|
|
5059
5609
|
for (const entry of entries) {
|
|
5060
5610
|
if (entry.isDirectory()) {
|
|
5061
|
-
const schemaPath =
|
|
5611
|
+
const schemaPath = join9(contractsDir, entry.name, "schema.json");
|
|
5062
5612
|
const contract = await loadContract(schemaPath, options);
|
|
5063
5613
|
contracts.push(contract);
|
|
5064
5614
|
}
|
|
@@ -5068,7 +5618,7 @@ async function loadContractsFromDirectory(contractsDir, options) {
|
|
|
5068
5618
|
function getValidator(schema) {
|
|
5069
5619
|
const key = `${schema.$id || "default"}#${computeRevisionDigest(JSON.stringify(schema))}`;
|
|
5070
5620
|
if (!_validatorCache.has(key)) {
|
|
5071
|
-
const AjvCtor =
|
|
5621
|
+
const AjvCtor = _AjvModule2;
|
|
5072
5622
|
const ajv = new AjvCtor({ allErrors: true, strict: false });
|
|
5073
5623
|
_validatorCache.set(key, ajv.compile(schema));
|
|
5074
5624
|
}
|
|
@@ -5650,7 +6200,7 @@ var init_restructure_software = __esm({
|
|
|
5650
6200
|
// src/restructure-file-set.ts
|
|
5651
6201
|
import { createHash as createHash3 } from "crypto";
|
|
5652
6202
|
import { chmod, lstat as lstat2, mkdir as mkdir4, realpath, statfs } from "fs/promises";
|
|
5653
|
-
import { join as
|
|
6203
|
+
import { join as join10, resolve as resolve6 } from "path";
|
|
5654
6204
|
async function loadFoundationModule() {
|
|
5655
6205
|
return await import(FOUNDATION_PACKAGE_NAME);
|
|
5656
6206
|
}
|
|
@@ -5747,7 +6297,7 @@ async function qualifyRestructureMechanism(root) {
|
|
|
5747
6297
|
return { ok: true, data: { root: canonical.data, filesystem: RESTRUCTURE_QUALIFIED_FILESYSTEM } };
|
|
5748
6298
|
}
|
|
5749
6299
|
async function ensureRestructureMechanismRoot(canonicalRoot, options) {
|
|
5750
|
-
const target =
|
|
6300
|
+
const target = join10(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH);
|
|
5751
6301
|
const current = async () => lstat2(target).catch((cause) => cause.code === "ENOENT" ? null : Promise.reject(cause));
|
|
5752
6302
|
let info = await current();
|
|
5753
6303
|
if (info === null) {
|
|
@@ -5861,7 +6411,7 @@ async function applyRestructureFileSet(canonicalRoot, plan, options) {
|
|
|
5861
6411
|
return await verifyMechanismResult(raw);
|
|
5862
6412
|
}
|
|
5863
6413
|
async function observeRestructureJournal(canonicalRoot) {
|
|
5864
|
-
const journalRoot =
|
|
6414
|
+
const journalRoot = join10(canonicalRoot, RESTRUCTURE_RECOVERY_REL_PATH, "journal");
|
|
5865
6415
|
const module = await loadFoundationModule();
|
|
5866
6416
|
try {
|
|
5867
6417
|
return { ok: true, data: await module.inspectStateStoreLock(journalRoot, { recoveryObservation: true }) };
|
|
@@ -6088,8 +6638,8 @@ __export(restructure_exports, {
|
|
|
6088
6638
|
restructureBoundaryFindings: () => restructureBoundaryFindings
|
|
6089
6639
|
});
|
|
6090
6640
|
import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
|
|
6091
|
-
import { lstat as lstat3, readFile as
|
|
6092
|
-
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";
|
|
6093
6643
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
6094
6644
|
function digestBytes(value) {
|
|
6095
6645
|
return `sha256:${createHash4("sha256").update(value).digest("hex")}`;
|
|
@@ -6105,7 +6655,7 @@ function digestRestructureValue(value) {
|
|
|
6105
6655
|
return digestBytes(canonicalJson(value));
|
|
6106
6656
|
}
|
|
6107
6657
|
function normalizeRelativePath2(value) {
|
|
6108
|
-
if (!value || value.includes("\0") ||
|
|
6658
|
+
if (!value || value.includes("\0") || isAbsolute6(value)) return void 0;
|
|
6109
6659
|
const normalized = value.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
6110
6660
|
if (!normalized || normalized === "." || normalized.split("/").some((part) => part === ".." || part === "")) return void 0;
|
|
6111
6661
|
return normalized;
|
|
@@ -6125,7 +6675,7 @@ async function readContainedFileWithMode(root, path) {
|
|
|
6125
6675
|
try {
|
|
6126
6676
|
const info = await lstat3(absolutePath);
|
|
6127
6677
|
if (info.isSymbolicLink() || !info.isFile()) throw new Error(`Path is not a regular file: ${path}`);
|
|
6128
|
-
return { buffer: await
|
|
6678
|
+
return { buffer: await readFile4(absolutePath), mode: info.mode & MAX_POSIX_MODE };
|
|
6129
6679
|
} catch (error) {
|
|
6130
6680
|
if (error.code === "ENOENT") return void 0;
|
|
6131
6681
|
throw error;
|
|
@@ -6153,7 +6703,7 @@ async function configSnapshot(root) {
|
|
|
6153
6703
|
return snapshotFile(root, "artifact-graph.config.yaml");
|
|
6154
6704
|
}
|
|
6155
6705
|
async function loadRestructureContract(name) {
|
|
6156
|
-
return loadContract(
|
|
6706
|
+
return loadContract(join11(CONTRACT_ROOT, `restructure-${name}`, "schema.json"), { expectedAuthority: "artifact" });
|
|
6157
6707
|
}
|
|
6158
6708
|
async function validateDomainContract(name, value) {
|
|
6159
6709
|
const contract = await loadRestructureContract(name);
|
|
@@ -6428,14 +6978,14 @@ async function scanUnsupportedReferences(root, sourcePaths, targetPaths) {
|
|
|
6428
6978
|
async function visit(directory) {
|
|
6429
6979
|
for (const entry of await readdir3(directory, { withFileTypes: true })) {
|
|
6430
6980
|
if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
|
|
6431
|
-
const absolute =
|
|
6981
|
+
const absolute = join11(directory, entry.name);
|
|
6432
6982
|
if (entry.isDirectory()) {
|
|
6433
6983
|
await visit(absolute);
|
|
6434
6984
|
continue;
|
|
6435
6985
|
}
|
|
6436
6986
|
if (!entry.isFile() || !TEXT_EXTENSIONS.test(entry.name)) continue;
|
|
6437
6987
|
const path = relative4(root, absolute).replace(/\\/g, "/");
|
|
6438
|
-
const raw = await
|
|
6988
|
+
const raw = await readFile4(absolute, "utf8");
|
|
6439
6989
|
const namesTheMigration = migrationPaths.some((reference) => raw.includes(reference));
|
|
6440
6990
|
const lines = raw.split(/\r?\n/);
|
|
6441
6991
|
for (const [index, line] of lines.entries()) {
|
|
@@ -6500,13 +7050,13 @@ async function scanConsumerCandidates(root, references, excludedPaths = /* @__PU
|
|
|
6500
7050
|
async function visit(directory) {
|
|
6501
7051
|
for (const entry of await readdir3(directory, { withFileTypes: true })) {
|
|
6502
7052
|
if (entry.isDirectory() && SKIPPED_SCAN_DIRS.has(entry.name)) continue;
|
|
6503
|
-
const absolute =
|
|
7053
|
+
const absolute = join11(directory, entry.name);
|
|
6504
7054
|
if (entry.isDirectory()) {
|
|
6505
7055
|
await visit(absolute);
|
|
6506
7056
|
} else if (entry.isFile() && TEXT_EXTENSIONS.test(entry.name)) {
|
|
6507
7057
|
const path = relative4(root, absolute).replace(/\\/g, "/");
|
|
6508
7058
|
if (excludedPaths.has(path)) continue;
|
|
6509
|
-
const raw = await
|
|
7059
|
+
const raw = await readFile4(absolute, "utf8");
|
|
6510
7060
|
raw.split(/\r?\n/).forEach((line, index) => {
|
|
6511
7061
|
for (const reference of references) {
|
|
6512
7062
|
if (path !== reference && line.includes(reference)) results.push({ path, line: index + 1, reference });
|
|
@@ -7009,7 +7559,7 @@ async function loadRestructurePlanDocument(operation, canonicalRoot, planPath) {
|
|
|
7009
7559
|
}
|
|
7010
7560
|
let bytes;
|
|
7011
7561
|
try {
|
|
7012
|
-
bytes = await
|
|
7562
|
+
bytes = await readFile4(absolute);
|
|
7013
7563
|
} catch (cause) {
|
|
7014
7564
|
return refusal("PLAN_FILE_UNREADABLE", `Plan document cannot be read: ${absolute} (${cause.message})`);
|
|
7015
7565
|
}
|
|
@@ -7041,7 +7591,7 @@ function planRootIdentityFindings(document) {
|
|
|
7041
7591
|
findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan does not record this project's configuration file: ${document.plan.config_snapshot.path}`));
|
|
7042
7592
|
}
|
|
7043
7593
|
const relativePlan = relative4(document.root, document.realPath);
|
|
7044
|
-
if (!relativePlan || relativePlan.startsWith("..") ||
|
|
7594
|
+
if (!relativePlan || relativePlan.startsWith("..") || isAbsolute6(relativePlan)) {
|
|
7045
7595
|
findings.push(finding("ROOT_IDENTITY_MISMATCH", `The plan document is outside the project root: ${document.realPath}`, document.realPath));
|
|
7046
7596
|
}
|
|
7047
7597
|
return findings;
|
|
@@ -7232,7 +7782,7 @@ var init_restructure = __esm({
|
|
|
7232
7782
|
MAX_POSIX_MODE = 511;
|
|
7233
7783
|
CREATE_MODE_BASE = 438;
|
|
7234
7784
|
MODULE_DIRECTORY = typeof __dirname === "string" ? __dirname : dirname6(fileURLToPath2(import.meta.url));
|
|
7235
|
-
CONTRACT_ROOT =
|
|
7785
|
+
CONTRACT_ROOT = join11(MODULE_DIRECTORY, "..", "contracts");
|
|
7236
7786
|
SKIPPED_SCAN_DIRS = /* @__PURE__ */ new Set([".git", "node_modules", "dist", "coverage", ".tmp", ".codex", ".worktrees", ".foundation-file-apply", ".artifact-graph"]);
|
|
7237
7787
|
TEXT_EXTENSIONS = /\.(?:md|markdown|json|ya?ml|[cm]?[jt]sx?)$/i;
|
|
7238
7788
|
MARKDOWN_LINK_PATTERN = /!?\[([^\]\n]*)\]\(([^)\n]+)\)/g;
|
|
@@ -7243,11 +7793,176 @@ var init_restructure = __esm({
|
|
|
7243
7793
|
});
|
|
7244
7794
|
|
|
7245
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
|
+
});
|
|
7246
7940
|
import matter from "gray-matter";
|
|
7247
|
-
import
|
|
7941
|
+
import yaml2 from "js-yaml";
|
|
7248
7942
|
import { accessSync, constants as fsConstants, existsSync as existsSync3, statSync } from "fs";
|
|
7249
|
-
import { mkdir as mkdir5, readFile as
|
|
7250
|
-
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
|
+
}
|
|
7251
7966
|
function isTargetArtifactType(type) {
|
|
7252
7967
|
return isPacketTargetType(type);
|
|
7253
7968
|
}
|
|
@@ -7289,30 +8004,22 @@ function resolveArtifactTypeName(schema, token) {
|
|
|
7289
8004
|
return void 0;
|
|
7290
8005
|
}
|
|
7291
8006
|
async function loadConfig(root) {
|
|
7292
|
-
const configPath =
|
|
7293
|
-
let
|
|
8007
|
+
const configPath = join12(root, "artifact-graph.config.yaml");
|
|
8008
|
+
let raw;
|
|
7294
8009
|
try {
|
|
7295
|
-
|
|
7296
|
-
parsed = yaml.load(raw) ?? {};
|
|
8010
|
+
raw = await readFile5(configPath, "utf-8");
|
|
7297
8011
|
} catch (error) {
|
|
7298
|
-
if (error.code
|
|
7299
|
-
throw
|
|
8012
|
+
if (error.code === "ENOENT") {
|
|
8013
|
+
throw new Error(`required configuration is missing: ${configPath}`);
|
|
7300
8014
|
}
|
|
8015
|
+
throw error;
|
|
7301
8016
|
}
|
|
7302
|
-
const
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
);
|
|
7307
|
-
}
|
|
7308
|
-
if (parsed.e2e !== void 0) {
|
|
7309
|
-
if (typeof parsed.e2e !== "object" || parsed.e2e === null || Array.isArray(parsed.e2e)) {
|
|
7310
|
-
throw new Error("Invalid e2e: must be an object.");
|
|
7311
|
-
}
|
|
7312
|
-
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);
|
|
7313
8021
|
}
|
|
7314
|
-
|
|
7315
|
-
validateStatusViewsConfig(parsed.statusViews);
|
|
8022
|
+
const parsed = document;
|
|
7316
8023
|
const mergedE2e = parsed.e2e === void 0 ? DEFAULT_SCHEMA.e2e : {
|
|
7317
8024
|
...DEFAULT_SCHEMA.e2e,
|
|
7318
8025
|
...parsed.e2e,
|
|
@@ -7327,13 +8034,14 @@ async function loadConfig(root) {
|
|
|
7327
8034
|
types: mergeArtifactTypes(DEFAULT_SCHEMA.types, parsed.types),
|
|
7328
8035
|
idPatterns: mergeRecord(DEFAULT_SCHEMA.idPatterns, parsed.idPatterns),
|
|
7329
8036
|
relationFields: mergeRecord(DEFAULT_SCHEMA.relationFields, parsed.relationFields),
|
|
7330
|
-
allowedEdges: parsed.allowedEdges
|
|
8037
|
+
allowedEdges: resolveAllowedEdges(parsed.allowedEdges),
|
|
7331
8038
|
forbiddenEdges: parsed.forbiddenEdges ?? DEFAULT_SCHEMA.forbiddenEdges,
|
|
7332
8039
|
statuses: parsed.statuses ?? DEFAULT_SCHEMA.statuses,
|
|
7333
8040
|
idRanges: mergeRecord(DEFAULT_SCHEMA.idRanges, parsed.idRanges),
|
|
7334
8041
|
e2e: mergedE2e
|
|
7335
8042
|
};
|
|
7336
8043
|
validateJsonArtifactTypes(merged.types);
|
|
8044
|
+
configDiagnosticsBySchema.set(merged, shapeDiagnosis);
|
|
7337
8045
|
return merged;
|
|
7338
8046
|
}
|
|
7339
8047
|
function validateJsonArtifactTypes(types) {
|
|
@@ -7358,131 +8066,6 @@ function validateJsonArtifactTypes(types) {
|
|
|
7358
8066
|
}
|
|
7359
8067
|
}
|
|
7360
8068
|
}
|
|
7361
|
-
function validateRelationSemanticsConfig(value) {
|
|
7362
|
-
if (value === void 0) return;
|
|
7363
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7364
|
-
throw new Error("Invalid relationSemantics: must be an object keyed by relation kind.");
|
|
7365
|
-
}
|
|
7366
|
-
for (const [kind, spec] of Object.entries(value)) {
|
|
7367
|
-
if (!kind.trim() || typeof spec !== "object" || spec === null || Array.isArray(spec)) {
|
|
7368
|
-
throw new Error(`Invalid relationSemantics.${kind}: must be an object.`);
|
|
7369
|
-
}
|
|
7370
|
-
if (typeof spec.label !== "string" || !spec.label.trim()) {
|
|
7371
|
-
throw new Error(`Invalid relationSemantics.${kind}.label: must be a non-empty string.`);
|
|
7372
|
-
}
|
|
7373
|
-
if (!Array.isArray(spec.targetTypes) || spec.targetTypes.some((item) => typeof item !== "string" || !item.trim())) {
|
|
7374
|
-
throw new Error(`Invalid relationSemantics.${kind}.targetTypes: must be an array of non-empty strings.`);
|
|
7375
|
-
}
|
|
7376
|
-
if (!Array.isArray(spec.fields) || spec.fields.length === 0 || spec.fields.some((item) => typeof item !== "string" || !item.trim())) {
|
|
7377
|
-
throw new Error(`Invalid relationSemantics.${kind}.fields: must be a non-empty array of strings.`);
|
|
7378
|
-
}
|
|
7379
|
-
if (spec.partial !== void 0 && (typeof spec.partial !== "object" || spec.partial === null || typeof spec.partial.sectionField !== "string" || !spec.partial.sectionField.trim())) {
|
|
7380
|
-
throw new Error(`Invalid relationSemantics.${kind}.partial.sectionField: must be a non-empty string.`);
|
|
7381
|
-
}
|
|
7382
|
-
}
|
|
7383
|
-
}
|
|
7384
|
-
function validateStatusViewsConfig(value) {
|
|
7385
|
-
if (value === void 0) return;
|
|
7386
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7387
|
-
throw new Error("Invalid statusViews: must be an object keyed by status.");
|
|
7388
|
-
}
|
|
7389
|
-
for (const [status, bucket] of Object.entries(value)) {
|
|
7390
|
-
if (!status.trim() || !["current", "planned", "history"].includes(bucket)) {
|
|
7391
|
-
throw new Error(`Invalid statusViews.${status}: expected current, planned, or history.`);
|
|
7392
|
-
}
|
|
7393
|
-
}
|
|
7394
|
-
}
|
|
7395
|
-
function validateE2eConfig(e2e) {
|
|
7396
|
-
for (const field of ["report_uncovered_scenarios", "report_uncovered_features"]) {
|
|
7397
|
-
if (e2e[field] !== void 0 && typeof e2e[field] !== "boolean") {
|
|
7398
|
-
throw new Error(`Invalid e2e.${field}: must be boolean.`);
|
|
7399
|
-
}
|
|
7400
|
-
}
|
|
7401
|
-
if (e2e.executable_ref_warning !== void 0) {
|
|
7402
|
-
if (typeof e2e.executable_ref_warning !== "number" || e2e.executable_ref_warning < 0 || e2e.executable_ref_warning > 1) {
|
|
7403
|
-
throw new Error(`Invalid e2e.executable_ref_warning: ${JSON.stringify(e2e.executable_ref_warning)}. Must be a number between 0 and 1.`);
|
|
7404
|
-
}
|
|
7405
|
-
}
|
|
7406
|
-
if (e2e.executable_ref_error !== void 0) {
|
|
7407
|
-
if (typeof e2e.executable_ref_error !== "number" || e2e.executable_ref_error < 0 || e2e.executable_ref_error > 1) {
|
|
7408
|
-
throw new Error(`Invalid e2e.executable_ref_error: ${JSON.stringify(e2e.executable_ref_error)}. Must be a number between 0 and 1.`);
|
|
7409
|
-
}
|
|
7410
|
-
}
|
|
7411
|
-
const validateWaivers = (waivers, field) => {
|
|
7412
|
-
if (waivers === void 0) return;
|
|
7413
|
-
if (!Array.isArray(waivers)) {
|
|
7414
|
-
throw new Error(`Invalid ${field}: must be an array of {id, reason} objects.`);
|
|
7415
|
-
}
|
|
7416
|
-
for (const w of waivers) {
|
|
7417
|
-
if (typeof w !== "object" || w === null || !("id" in w) || !("reason" in w)) {
|
|
7418
|
-
throw new Error(`Invalid ${field} entry: ${JSON.stringify(w)}. Must be {id, reason} object.`);
|
|
7419
|
-
}
|
|
7420
|
-
if (typeof w.id !== "string" || !w.id.trim()) {
|
|
7421
|
-
throw new Error(`Invalid ${field} entry: id must be a non-empty string. Got: ${JSON.stringify(w.id)}`);
|
|
7422
|
-
}
|
|
7423
|
-
if (typeof w.reason !== "string" || !w.reason.trim()) {
|
|
7424
|
-
throw new Error(`Invalid ${field} entry: reason must be a non-empty string. Got: ${JSON.stringify(w.reason)}`);
|
|
7425
|
-
}
|
|
7426
|
-
}
|
|
7427
|
-
};
|
|
7428
|
-
validateWaivers(e2e.scenario_waivers, "e2e.scenario_waivers");
|
|
7429
|
-
validateWaivers(e2e.feature_waivers, "e2e.feature_waivers");
|
|
7430
|
-
if (e2e.runners !== void 0) {
|
|
7431
|
-
if (!Array.isArray(e2e.runners)) {
|
|
7432
|
-
throw new Error(`Invalid e2e.runners: must be an array.`);
|
|
7433
|
-
}
|
|
7434
|
-
for (const runner of e2e.runners) {
|
|
7435
|
-
if (typeof runner !== "object" || runner === null) {
|
|
7436
|
-
throw new Error(`Invalid e2e.runners entry: must be an object.`);
|
|
7437
|
-
}
|
|
7438
|
-
if (typeof runner.name !== "string" || !runner.name.trim()) {
|
|
7439
|
-
throw new Error(`Invalid e2e.runners entry: name must be a non-empty string.`);
|
|
7440
|
-
}
|
|
7441
|
-
if (typeof runner.root !== "string" || !runner.root.trim()) {
|
|
7442
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: must be a non-empty string.`);
|
|
7443
|
-
}
|
|
7444
|
-
if (isAbsolute6(runner.root)) {
|
|
7445
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not be an absolute path.`);
|
|
7446
|
-
}
|
|
7447
|
-
if (runner.root.replace(/\\/g, "/").split("/").includes("..")) {
|
|
7448
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].root: "${runner.root}" must not contain ".." segments.`);
|
|
7449
|
-
}
|
|
7450
|
-
if (!Array.isArray(runner.include) || runner.include.length === 0) {
|
|
7451
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].include: must be a non-empty array of glob patterns.`);
|
|
7452
|
-
}
|
|
7453
|
-
for (const pattern of runner.include) {
|
|
7454
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7455
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].include: pattern must be a non-empty string.`);
|
|
7456
|
-
}
|
|
7457
|
-
}
|
|
7458
|
-
if (runner.exclude !== void 0) {
|
|
7459
|
-
if (!Array.isArray(runner.exclude)) {
|
|
7460
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].exclude: must be an array.`);
|
|
7461
|
-
}
|
|
7462
|
-
for (const pattern of runner.exclude) {
|
|
7463
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7464
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].exclude: pattern must be a non-empty string.`);
|
|
7465
|
-
}
|
|
7466
|
-
}
|
|
7467
|
-
}
|
|
7468
|
-
if (runner.testIgnore !== void 0) {
|
|
7469
|
-
if (!Array.isArray(runner.testIgnore)) {
|
|
7470
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].testIgnore: must be an array.`);
|
|
7471
|
-
}
|
|
7472
|
-
for (const pattern of runner.testIgnore) {
|
|
7473
|
-
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
7474
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].testIgnore: pattern must be a non-empty string.`);
|
|
7475
|
-
}
|
|
7476
|
-
}
|
|
7477
|
-
}
|
|
7478
|
-
if (runner.kind !== void 0) {
|
|
7479
|
-
if (!["unit", "integration", "e2e"].includes(runner.kind)) {
|
|
7480
|
-
throw new Error(`Invalid e2e.runners[${runner.name}].kind: "${runner.kind}". Must be unit, integration, or e2e.`);
|
|
7481
|
-
}
|
|
7482
|
-
}
|
|
7483
|
-
}
|
|
7484
|
-
}
|
|
7485
|
-
}
|
|
7486
8069
|
function buildGraph(nodes, edges, diagnostics = [], root) {
|
|
7487
8070
|
const graphNodes = nodes.map((node) => ({ ...node, uid: toUid(node.type, node.code) }));
|
|
7488
8071
|
graphNodes.sort(compareNode);
|
|
@@ -7530,7 +8113,7 @@ async function scanArtifacts(root, schema, options = {}) {
|
|
|
7530
8113
|
continue;
|
|
7531
8114
|
}
|
|
7532
8115
|
scannedFiles.set(file, type);
|
|
7533
|
-
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");
|
|
7534
8117
|
const parsed = parseFile(type, file, raw, config);
|
|
7535
8118
|
const semantic = isJsonOriginalType(type, config) ? { edges: [], diagnostics: [] } : parseConfiguredRelations(type, file, raw, parsed.nodes, config);
|
|
7536
8119
|
nodes.push(...parsed.nodes);
|
|
@@ -7538,7 +8121,7 @@ async function scanArtifacts(root, schema, options = {}) {
|
|
|
7538
8121
|
scanDiagnostics.push(...parsed.diagnostics, ...semantic.diagnostics);
|
|
7539
8122
|
}
|
|
7540
8123
|
}
|
|
7541
|
-
const absoluteRoot =
|
|
8124
|
+
const absoluteRoot = isAbsolute7(root) ? root : resolve8(root);
|
|
7542
8125
|
const graph = buildGraph(nodes, edges, scanDiagnostics, absoluteRoot);
|
|
7543
8126
|
return resolveMatrixEdges(graph);
|
|
7544
8127
|
}
|
|
@@ -7685,8 +8268,16 @@ function validateGraph(graph, schema = DEFAULT_SCHEMA) {
|
|
|
7685
8268
|
{ edge: edge2 }
|
|
7686
8269
|
));
|
|
7687
8270
|
}
|
|
7688
|
-
if (schema.forbiddenEdges.some((rule) => rule
|
|
8271
|
+
if (schema.forbiddenEdges.some((rule) => matchesEdgeRule(rule, fromType, toType, edge2.kind))) {
|
|
7689
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
|
+
));
|
|
7690
8281
|
}
|
|
7691
8282
|
}
|
|
7692
8283
|
issues.push(...validateE2eTests(graph));
|
|
@@ -7780,6 +8371,9 @@ function getExternalEntryInfo(node) {
|
|
|
7780
8371
|
...targetVersion ? { targetVersion } : {}
|
|
7781
8372
|
};
|
|
7782
8373
|
}
|
|
8374
|
+
function validateScenarioPrdLinks(graph, schema = DEFAULT_SCHEMA) {
|
|
8375
|
+
return validateScenarioPrdLinksInternal(graph, schema, true);
|
|
8376
|
+
}
|
|
7783
8377
|
function validateScenarioPrdLinksInternal(graph, schema, includeScanDiagnosedInvalid) {
|
|
7784
8378
|
if (!schema.relationFields.scenario?.includes("\u5173\u8054\u529F\u80FD") || !schema.relationFields.feature?.includes("scenarios")) {
|
|
7785
8379
|
return [];
|
|
@@ -7874,7 +8468,7 @@ async function validateScenarioPrdLinkIndex(root, graph) {
|
|
|
7874
8468
|
const indexPath = "artifacts/prd/feature-index.md";
|
|
7875
8469
|
let raw = "";
|
|
7876
8470
|
try {
|
|
7877
|
-
raw = await
|
|
8471
|
+
raw = await readFile5(join12(root, indexPath), "utf-8");
|
|
7878
8472
|
} catch (error) {
|
|
7879
8473
|
if (error.code === "ENOENT") {
|
|
7880
8474
|
return [];
|
|
@@ -8122,12 +8716,12 @@ function nextId(graph, schema, type, rangeName) {
|
|
|
8122
8716
|
throw new Error(`ID range ${type}.${rangeName} is exhausted`);
|
|
8123
8717
|
}
|
|
8124
8718
|
async function writeGraphCache(root, graph) {
|
|
8125
|
-
const cacheDir =
|
|
8719
|
+
const cacheDir = join12(root, ".artifact-graph");
|
|
8126
8720
|
await mkdir5(cacheDir, { recursive: true });
|
|
8127
|
-
await writeFile3(
|
|
8721
|
+
await writeFile3(join12(cacheDir, "index.json"), `${JSON.stringify(graph, null, 2)}
|
|
8128
8722
|
`);
|
|
8129
8723
|
const { default: Database } = await import("better-sqlite3");
|
|
8130
|
-
const db = new Database(
|
|
8724
|
+
const db = new Database(join12(cacheDir, "graph.sqlite"));
|
|
8131
8725
|
try {
|
|
8132
8726
|
db.exec(`
|
|
8133
8727
|
DROP TABLE IF EXISTS nodes;
|
|
@@ -10209,7 +10803,7 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10209
10803
|
const tcKeyToFields = /* @__PURE__ */ new Map();
|
|
10210
10804
|
const mdBatches = /* @__PURE__ */ new Set();
|
|
10211
10805
|
for (const relPath of e2eFiles) {
|
|
10212
|
-
const raw = await
|
|
10806
|
+
const raw = await readFile5(join12(root, relPath), "utf-8");
|
|
10213
10807
|
const parsed = matter(raw);
|
|
10214
10808
|
const data = parsed.data;
|
|
10215
10809
|
const batch = String(data.test_batch ?? basename5(relPath, extname(relPath))).trim();
|
|
@@ -10251,10 +10845,10 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10251
10845
|
const tcAnnotationRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+?)\s+\[(\w+)\]/;
|
|
10252
10846
|
const tcAnnotationNoLevelRegex = /\/\/!?\s*@(?:e2e_test|tc)\s+(\S+)/;
|
|
10253
10847
|
for (const specFile of specFiles) {
|
|
10254
|
-
const fullSpecPath =
|
|
10848
|
+
const fullSpecPath = join12(root, specFile);
|
|
10255
10849
|
let content;
|
|
10256
10850
|
try {
|
|
10257
|
-
content = await
|
|
10851
|
+
content = await readFile5(fullSpecPath, "utf-8");
|
|
10258
10852
|
} catch {
|
|
10259
10853
|
continue;
|
|
10260
10854
|
}
|
|
@@ -10333,7 +10927,7 @@ async function validateExecutableTraceability(root, config) {
|
|
|
10333
10927
|
if (entry.testId) {
|
|
10334
10928
|
let content;
|
|
10335
10929
|
try {
|
|
10336
|
-
content = await
|
|
10930
|
+
content = await readFile5(join12(root, normalizedRefFile), "utf-8");
|
|
10337
10931
|
} catch {
|
|
10338
10932
|
continue;
|
|
10339
10933
|
}
|
|
@@ -10568,7 +11162,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
|
|
|
10568
11162
|
let hasActiveE2eRef = false;
|
|
10569
11163
|
for (const entry of parseExecutableRefLines(execRef)) {
|
|
10570
11164
|
const normalized = resolveExecutableRefFile(entry.file, allProjectFiles);
|
|
10571
|
-
if (!normalized || !existsSync3(
|
|
11165
|
+
if (!normalized || !existsSync3(join12(root, normalized))) continue;
|
|
10572
11166
|
const accepting = await getAcceptingRunners(root, normalized, runners);
|
|
10573
11167
|
if (accepting.some((runner) => runner.kind === "e2e")) {
|
|
10574
11168
|
hasActiveE2eRef = true;
|
|
@@ -10627,7 +11221,7 @@ async function computeE2eCoverageStats(graph, root, thresholds = {}) {
|
|
|
10627
11221
|
const acCoverageRateByFeature = {};
|
|
10628
11222
|
const featureAcMap = /* @__PURE__ */ new Map();
|
|
10629
11223
|
for (const node of featureNodes) {
|
|
10630
|
-
const acs = parseAcceptanceCriteria(await
|
|
11224
|
+
const acs = parseAcceptanceCriteria(await readFile5(join12(root, node.path), "utf-8"));
|
|
10631
11225
|
featureAcMap.set(node.code, new Set(acs));
|
|
10632
11226
|
}
|
|
10633
11227
|
const coveredAcByFeature = /* @__PURE__ */ new Map();
|
|
@@ -10675,8 +11269,8 @@ async function generateE2eRegistry(root, opts) {
|
|
|
10675
11269
|
const batchIds = /* @__PURE__ */ new Set();
|
|
10676
11270
|
let totalTestCases = 0;
|
|
10677
11271
|
for (const file of files) {
|
|
10678
|
-
const filePath =
|
|
10679
|
-
const raw = await
|
|
11272
|
+
const filePath = join12(root, file);
|
|
11273
|
+
const raw = await readFile5(filePath, "utf-8");
|
|
10680
11274
|
const parsed = matter(raw);
|
|
10681
11275
|
const data = parsed.data;
|
|
10682
11276
|
const batch = String(data.test_batch ?? basename5(file, extname(file))).trim();
|
|
@@ -10801,10 +11395,10 @@ async function validatePartialRustEvidence(tcFields, tcKey, root, allFiles) {
|
|
|
10801
11395
|
if (!normalizedPath) {
|
|
10802
11396
|
return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
|
|
10803
11397
|
}
|
|
10804
|
-
const fullPath =
|
|
11398
|
+
const fullPath = join12(root, normalizedPath);
|
|
10805
11399
|
let content;
|
|
10806
11400
|
try {
|
|
10807
|
-
content = await
|
|
11401
|
+
content = await readFile5(fullPath, "utf-8");
|
|
10808
11402
|
} catch {
|
|
10809
11403
|
return { hasValidPartialRust: false, detail: `partial_rust file not found: ${ref.file}` };
|
|
10810
11404
|
}
|
|
@@ -10838,7 +11432,7 @@ function detectTestLevel(specFile, content) {
|
|
|
10838
11432
|
}
|
|
10839
11433
|
function resolveExecutableRefFile(refFile, allFiles) {
|
|
10840
11434
|
const normalized = refFile.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
10841
|
-
if (!normalized ||
|
|
11435
|
+
if (!normalized || isAbsolute7(refFile) || normalized.split("/").includes("..")) {
|
|
10842
11436
|
return void 0;
|
|
10843
11437
|
}
|
|
10844
11438
|
if (allFiles.includes(normalized)) {
|
|
@@ -11420,7 +12014,7 @@ function resolveArtifactContext(graph, opts) {
|
|
|
11420
12014
|
}
|
|
11421
12015
|
if (root) {
|
|
11422
12016
|
for (const ap of ALWAYS_PRESENT_ITEMS) {
|
|
11423
|
-
const fullPath =
|
|
12017
|
+
const fullPath = join12(root, ap.path);
|
|
11424
12018
|
let stat3;
|
|
11425
12019
|
try {
|
|
11426
12020
|
stat3 = statSync(fullPath);
|
|
@@ -11662,7 +12256,7 @@ function formatContextMarkdown(manifest) {
|
|
|
11662
12256
|
}
|
|
11663
12257
|
return lines.join("\n");
|
|
11664
12258
|
}
|
|
11665
|
-
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;
|
|
11666
12260
|
var init_index = __esm({
|
|
11667
12261
|
"src/index.ts"() {
|
|
11668
12262
|
"use strict";
|
|
@@ -11670,6 +12264,8 @@ var init_index = __esm({
|
|
|
11670
12264
|
init_packet_validator();
|
|
11671
12265
|
init_glob_matcher();
|
|
11672
12266
|
init_file_walker();
|
|
12267
|
+
init_doctor();
|
|
12268
|
+
init_doctor();
|
|
11673
12269
|
init_packet_constants();
|
|
11674
12270
|
init_target_selector();
|
|
11675
12271
|
init_impact();
|
|
@@ -11690,6 +12286,44 @@ var init_index = __esm({
|
|
|
11690
12286
|
init_restructure();
|
|
11691
12287
|
init_restructure_file_set();
|
|
11692
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
|
+
];
|
|
11693
12327
|
TARGET_ARTIFACT_TYPES = VALID_PACKET_TARGET_TYPES;
|
|
11694
12328
|
NON_TARGET_ROLES = ["context", "candidate", "not-recommended"];
|
|
11695
12329
|
DEFAULT_SCHEMA = {
|
|
@@ -11727,7 +12361,7 @@ var init_index = __esm({
|
|
|
11727
12361
|
e2e_test: ["test_batch", "scope", "ac_coverage", "related_scenarios", "related_decisions", "related_entities", "\u8986\u76D6\u573A\u666F", "\u8986\u76D6\u529F\u80FD"],
|
|
11728
12362
|
e2e_registry: ["batches"]
|
|
11729
12363
|
},
|
|
11730
|
-
allowedEdges:
|
|
12364
|
+
allowedEdges: DEFAULT_ALLOWED_EDGES,
|
|
11731
12365
|
forbiddenEdges: [{ from: "scenario", to: "entity", kind: "references" }],
|
|
11732
12366
|
statuses: ["planned", "active", "done", "deprecated"],
|
|
11733
12367
|
idRanges: {},
|
|
@@ -11808,7 +12442,7 @@ var init_index = __esm({
|
|
|
11808
12442
|
|
|
11809
12443
|
// src/packet-prompt-audit.ts
|
|
11810
12444
|
import { mkdir as mkdir6, writeFile as writeFile4 } from "fs/promises";
|
|
11811
|
-
import { join as
|
|
12445
|
+
import { join as join13 } from "path";
|
|
11812
12446
|
function promptFilename(target) {
|
|
11813
12447
|
return `prompt-${target.type}-${target.id}.md`;
|
|
11814
12448
|
}
|
|
@@ -11860,7 +12494,7 @@ async function auditSinglePromptTarget(target, graph, options) {
|
|
|
11860
12494
|
}
|
|
11861
12495
|
if (options.outDir) {
|
|
11862
12496
|
const filename = promptFilename(target);
|
|
11863
|
-
const outPath =
|
|
12497
|
+
const outPath = join13(options.outDir, filename);
|
|
11864
12498
|
await writeFile4(outPath, prompt, "utf-8");
|
|
11865
12499
|
entry.outputPath = outPath;
|
|
11866
12500
|
}
|
|
@@ -11966,9 +12600,9 @@ async function auditPromptBatch(root, targets, options, graph) {
|
|
|
11966
12600
|
};
|
|
11967
12601
|
if (options.outDir) {
|
|
11968
12602
|
await mkdir6(options.outDir, { recursive: true });
|
|
11969
|
-
const jsonPath =
|
|
12603
|
+
const jsonPath = join13(options.outDir, "prompt-audit-summary.json");
|
|
11970
12604
|
await writeFile4(jsonPath, JSON.stringify(summary, null, 2) + "\n", "utf-8");
|
|
11971
|
-
const mdPath =
|
|
12605
|
+
const mdPath = join13(options.outDir, "prompt-audit-summary.md");
|
|
11972
12606
|
await writeFile4(mdPath, renderPromptAuditSummaryMarkdown(summary), "utf-8");
|
|
11973
12607
|
}
|
|
11974
12608
|
return summary;
|
|
@@ -12008,10 +12642,10 @@ __export(refactor_id_exports, {
|
|
|
12008
12642
|
refactorId: () => refactorId,
|
|
12009
12643
|
renderRefactorIdMarkdown: () => renderRefactorIdMarkdown
|
|
12010
12644
|
});
|
|
12011
|
-
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";
|
|
12012
12646
|
import { randomBytes } from "crypto";
|
|
12013
|
-
import { basename as basename6, dirname as dirname8, join as
|
|
12014
|
-
import
|
|
12647
|
+
import { basename as basename6, dirname as dirname8, join as join14, relative as relative5 } from "path";
|
|
12648
|
+
import yaml3 from "js-yaml";
|
|
12015
12649
|
function escapeRegExp2(value) {
|
|
12016
12650
|
return value.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
12017
12651
|
}
|
|
@@ -12108,7 +12742,7 @@ function planFrontmatterEdits(path, raw, fileType, oldId, newId, config, isOwnFi
|
|
|
12108
12742
|
if (!block) return [];
|
|
12109
12743
|
let data;
|
|
12110
12744
|
try {
|
|
12111
|
-
const loaded =
|
|
12745
|
+
const loaded = yaml3.load(block.text);
|
|
12112
12746
|
if (typeof loaded !== "object" || loaded === null || Array.isArray(loaded)) return [];
|
|
12113
12747
|
data = loaded;
|
|
12114
12748
|
} catch {
|
|
@@ -12188,7 +12822,7 @@ async function walkTextFiles(root) {
|
|
|
12188
12822
|
for (const entry of entries) {
|
|
12189
12823
|
if (entry.name.startsWith(".") && PROSE_SCAN_SKIP_DIRS.has(entry.name)) continue;
|
|
12190
12824
|
if (PROSE_SCAN_SKIP_DIRS.has(entry.name)) continue;
|
|
12191
|
-
const full =
|
|
12825
|
+
const full = join14(dir, entry.name);
|
|
12192
12826
|
if (entry.isDirectory()) {
|
|
12193
12827
|
await visit(full);
|
|
12194
12828
|
} else if (entry.isFile()) {
|
|
@@ -12203,7 +12837,7 @@ async function walkTextFiles(root) {
|
|
|
12203
12837
|
return found.sort();
|
|
12204
12838
|
}
|
|
12205
12839
|
async function computeLockImpact(root, type, oldId) {
|
|
12206
|
-
const lockPath =
|
|
12840
|
+
const lockPath = join14(root, VERSION_LOCK_PATH);
|
|
12207
12841
|
const impact = {
|
|
12208
12842
|
lockPath: VERSION_LOCK_PATH,
|
|
12209
12843
|
affectedImplementationLocks: [],
|
|
@@ -12212,7 +12846,7 @@ async function computeLockImpact(root, type, oldId) {
|
|
|
12212
12846
|
};
|
|
12213
12847
|
let raw;
|
|
12214
12848
|
try {
|
|
12215
|
-
raw = await
|
|
12849
|
+
raw = await readFile6(lockPath, "utf-8");
|
|
12216
12850
|
} catch {
|
|
12217
12851
|
return impact;
|
|
12218
12852
|
}
|
|
@@ -12295,7 +12929,7 @@ async function refactorId(options) {
|
|
|
12295
12929
|
const fileContents = /* @__PURE__ */ new Map();
|
|
12296
12930
|
const readArtifactFile = async (path) => {
|
|
12297
12931
|
if (!fileContents.has(path)) {
|
|
12298
|
-
fileContents.set(path, await
|
|
12932
|
+
fileContents.set(path, await readFile6(join14(root, path), "utf-8"));
|
|
12299
12933
|
}
|
|
12300
12934
|
return fileContents.get(path);
|
|
12301
12935
|
};
|
|
@@ -12371,7 +13005,7 @@ async function refactorId(options) {
|
|
|
12371
13005
|
for (const relativePath of await walkTextFiles(root)) {
|
|
12372
13006
|
if (relativePath === VERSION_LOCK_PATH) continue;
|
|
12373
13007
|
if (relativePath === "artifact-graph.config.yaml") continue;
|
|
12374
|
-
const raw = await
|
|
13008
|
+
const raw = await readFile6(join14(root, relativePath), "utf-8");
|
|
12375
13009
|
if (!containsIdToken(raw, oldId)) continue;
|
|
12376
13010
|
const lines = raw.split(/\r?\n/);
|
|
12377
13011
|
lines.forEach((line, index) => {
|
|
@@ -12447,7 +13081,7 @@ async function refactorId(options) {
|
|
|
12447
13081
|
}
|
|
12448
13082
|
if (options.__beforeWriteVerify) await options.__beforeWriteVerify();
|
|
12449
13083
|
for (const path of targetFiles) {
|
|
12450
|
-
const disk = await
|
|
13084
|
+
const disk = await readFile6(join14(root, path), "utf-8");
|
|
12451
13085
|
if (disk !== fileContents.get(path)) {
|
|
12452
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 });
|
|
12453
13087
|
}
|
|
@@ -12458,7 +13092,7 @@ async function refactorId(options) {
|
|
|
12458
13092
|
const tempPathFor = options.__tempPathFor ?? ((targetPath) => {
|
|
12459
13093
|
tempSequence += 1;
|
|
12460
13094
|
const suffix = randomBytes(4).toString("hex");
|
|
12461
|
-
return
|
|
13095
|
+
return join14(dirname8(targetPath), `.${basename6(targetPath)}.${process.pid}.${tempSequence}.${suffix}.refactor-id.tmp`);
|
|
12462
13096
|
});
|
|
12463
13097
|
let stage = "write";
|
|
12464
13098
|
try {
|
|
@@ -12467,8 +13101,8 @@ async function refactorId(options) {
|
|
|
12467
13101
|
if (options.__injectWriteFailure?.(path)) {
|
|
12468
13102
|
throw Object.assign(new Error(`injected write failure: ${path}`), { code: "EINJECTED" });
|
|
12469
13103
|
}
|
|
12470
|
-
const original = fileContents.has(path) ? fileContents.get(path) : await
|
|
12471
|
-
const targetPath =
|
|
13104
|
+
const original = fileContents.has(path) ? fileContents.get(path) : await readFile6(join14(root, path), "utf-8");
|
|
13105
|
+
const targetPath = join14(root, path);
|
|
12472
13106
|
const originalMode = (await stat2(targetPath)).mode & 4095;
|
|
12473
13107
|
const tempPath = tempPathFor(targetPath);
|
|
12474
13108
|
await writeFile5(tempPath, newContents.get(path), { encoding: "utf-8", flag: "wx" });
|
|
@@ -12491,8 +13125,8 @@ async function refactorId(options) {
|
|
|
12491
13125
|
if (options.__injectRollbackFailure?.(entry.path)) {
|
|
12492
13126
|
throw Object.assign(new Error(`injected rollback failure: ${entry.path}`), { code: "EROLLBACKINJECTED" });
|
|
12493
13127
|
}
|
|
12494
|
-
await writeFile5(
|
|
12495
|
-
await chmod2(
|
|
13128
|
+
await writeFile5(join14(root, entry.path), entry.original, "utf-8");
|
|
13129
|
+
await chmod2(join14(root, entry.path), entry.originalMode);
|
|
12496
13130
|
} catch (rollbackError) {
|
|
12497
13131
|
rollbackErrors.push({ path: entry.path, message: rollbackError.message });
|
|
12498
13132
|
}
|
|
@@ -12623,10 +13257,10 @@ var cli_exports = {};
|
|
|
12623
13257
|
__export(cli_exports, {
|
|
12624
13258
|
runCli: () => runCli
|
|
12625
13259
|
});
|
|
12626
|
-
import
|
|
13260
|
+
import yaml4 from "js-yaml";
|
|
12627
13261
|
import { realpathSync as realpathSync2 } from "fs";
|
|
12628
|
-
import { access as access3, mkdir as mkdir7, readFile as
|
|
12629
|
-
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";
|
|
12630
13264
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
12631
13265
|
async function runCli(argv, io = {}) {
|
|
12632
13266
|
const parsed = parseArgs(argv);
|
|
@@ -12654,7 +13288,7 @@ async function runCli(argv, io = {}) {
|
|
|
12654
13288
|
switch (parsed.command) {
|
|
12655
13289
|
case "init": {
|
|
12656
13290
|
await initConfig(root);
|
|
12657
|
-
out(`Created ${
|
|
13291
|
+
out(`Created ${join15(root, "artifact-graph.config.yaml")}
|
|
12658
13292
|
`);
|
|
12659
13293
|
return 0;
|
|
12660
13294
|
}
|
|
@@ -12679,7 +13313,7 @@ async function runCli(argv, io = {}) {
|
|
|
12679
13313
|
err("Usage: artifact-graph check-professional --root <target> --format json [--conclusion-output <absolute-path>]\n");
|
|
12680
13314
|
return 1;
|
|
12681
13315
|
}
|
|
12682
|
-
if (typeof conclusionOutput === "string" && !
|
|
13316
|
+
if (typeof conclusionOutput === "string" && !isAbsolute8(conclusionOutput)) {
|
|
12683
13317
|
err("--conclusion-output must be an absolute path\n");
|
|
12684
13318
|
return 1;
|
|
12685
13319
|
}
|
|
@@ -13092,7 +13726,7 @@ async function runCli(argv, io = {}) {
|
|
|
13092
13726
|
if (packetJsonPath) {
|
|
13093
13727
|
let rawJson;
|
|
13094
13728
|
try {
|
|
13095
|
-
rawJson = await
|
|
13729
|
+
rawJson = await readFile7(packetJsonPath, "utf-8");
|
|
13096
13730
|
} catch (readErr) {
|
|
13097
13731
|
err(`\u9519\u8BEF\uFF1A\u65E0\u6CD5\u8BFB\u53D6 packet \u6587\u4EF6: "${packetJsonPath}" \u2014 ${readErr.message}
|
|
13098
13732
|
`);
|
|
@@ -13293,7 +13927,7 @@ async function runCli(argv, io = {}) {
|
|
|
13293
13927
|
universalBaseline: discoverConfig.context?.universal_baseline
|
|
13294
13928
|
});
|
|
13295
13929
|
} else {
|
|
13296
|
-
const targetsContent = await
|
|
13930
|
+
const targetsContent = await readFile7(targetsFile, "utf-8");
|
|
13297
13931
|
const auditConfig2 = await loadConfig(root);
|
|
13298
13932
|
const parseResult = parseTargetsFile(targetsContent, auditConfig2);
|
|
13299
13933
|
if (parseResult.errors.length > 0) {
|
|
@@ -13418,7 +14052,7 @@ async function runCli(argv, io = {}) {
|
|
|
13418
14052
|
} else {
|
|
13419
14053
|
let ppaTargetsContent;
|
|
13420
14054
|
try {
|
|
13421
|
-
ppaTargetsContent = await
|
|
14055
|
+
ppaTargetsContent = await readFile7(ppaTargetsFile, "utf-8");
|
|
13422
14056
|
} catch (readErr) {
|
|
13423
14057
|
err(`\u9519\u8BEF\uFF1A\u65E0\u6CD5\u8BFB\u53D6 targets \u6587\u4EF6: "${ppaTargetsFile}" \u2014 ${readErr.message}
|
|
13424
14058
|
`);
|
|
@@ -13676,7 +14310,7 @@ async function runCli(argv, io = {}) {
|
|
|
13676
14310
|
const prepared = [];
|
|
13677
14311
|
for (const hookName of hooks) {
|
|
13678
14312
|
const templatePath = fileURLToPath3(new URL(`../templates/git-hooks/${hookName}.sh`, import.meta.url));
|
|
13679
|
-
const block = await
|
|
14313
|
+
const block = await readFile7(templatePath, "utf-8");
|
|
13680
14314
|
prepared.push(await prepareManagedHookBlock({
|
|
13681
14315
|
hookPath: await resolveGitHookPath(root, hookName),
|
|
13682
14316
|
block,
|
|
@@ -13702,8 +14336,8 @@ async function runCli(argv, io = {}) {
|
|
|
13702
14336
|
out(`${JSON.stringify(report, null, 2)}
|
|
13703
14337
|
`);
|
|
13704
14338
|
} else {
|
|
13705
|
-
const config = await loadConfig(root);
|
|
13706
14339
|
out(renderDoctorMarkdown(report));
|
|
14340
|
+
const config = await loadConfig(root);
|
|
13707
14341
|
out(`Types: ${Object.keys(config.types).sort().join(", ")}
|
|
13708
14342
|
`);
|
|
13709
14343
|
out(`Forbidden edges: ${config.forbiddenEdges.length}
|
|
@@ -13720,10 +14354,10 @@ async function runCli(argv, io = {}) {
|
|
|
13720
14354
|
err("Usage: artifact-graph validate-review-result --file <path> [--format json]\n");
|
|
13721
14355
|
return 1;
|
|
13722
14356
|
}
|
|
13723
|
-
const resolvedPath =
|
|
14357
|
+
const resolvedPath = isAbsolute8(filePath) ? filePath : join15(root, filePath);
|
|
13724
14358
|
let content;
|
|
13725
14359
|
try {
|
|
13726
|
-
content = await
|
|
14360
|
+
content = await readFile7(resolvedPath, "utf-8");
|
|
13727
14361
|
} catch (readErr) {
|
|
13728
14362
|
err(`Error: Cannot read file: "${resolvedPath}" \u2014 ${readErr.message}
|
|
13729
14363
|
`);
|
|
@@ -13758,11 +14392,11 @@ async function runCli(argv, io = {}) {
|
|
|
13758
14392
|
const deterministic = checkMode || parsed.flags.deterministic === true;
|
|
13759
14393
|
const registry = await generateE2eRegistry(root, { deterministic });
|
|
13760
14394
|
const output = JSON.stringify(registry, null, 2) + "\n";
|
|
13761
|
-
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");
|
|
13762
14396
|
if (checkMode) {
|
|
13763
14397
|
let existing = "";
|
|
13764
14398
|
try {
|
|
13765
|
-
existing = await
|
|
14399
|
+
existing = await readFile7(outPath, "utf-8");
|
|
13766
14400
|
} catch {
|
|
13767
14401
|
err(`Check failed: ${outPath} does not exist or is not readable
|
|
13768
14402
|
`);
|
|
@@ -13810,10 +14444,10 @@ async function runCli(argv, io = {}) {
|
|
|
13810
14444
|
`);
|
|
13811
14445
|
return 1;
|
|
13812
14446
|
}
|
|
13813
|
-
const planPath =
|
|
14447
|
+
const planPath = isAbsolute8(planFlag) ? planFlag : join15(cwd, planFlag);
|
|
13814
14448
|
let planDocument;
|
|
13815
14449
|
try {
|
|
13816
|
-
planDocument = JSON.parse(await
|
|
14450
|
+
planDocument = JSON.parse(await readFile7(planPath, "utf8"));
|
|
13817
14451
|
} catch (planError) {
|
|
13818
14452
|
out(`${JSON.stringify({ ok: false, error: { code: "PLAN_UNREADABLE", message: `Cannot read a plan document from ${planPath}: ${planError.message}` } }, null, 2)}
|
|
13819
14453
|
`);
|
|
@@ -13877,10 +14511,10 @@ async function runCli(argv, io = {}) {
|
|
|
13877
14511
|
`);
|
|
13878
14512
|
return 1;
|
|
13879
14513
|
}
|
|
13880
|
-
const resolvedInput =
|
|
14514
|
+
const resolvedInput = isAbsolute8(inputPath) ? inputPath : join15(cwd, inputPath);
|
|
13881
14515
|
let input;
|
|
13882
14516
|
try {
|
|
13883
|
-
input = JSON.parse(await
|
|
14517
|
+
input = JSON.parse(await readFile7(resolvedInput, "utf8"));
|
|
13884
14518
|
} catch (inputError) {
|
|
13885
14519
|
out(`${JSON.stringify({ ok: false, error: { code: "INPUT_INVALID", message: `Cannot read valid JSON from ${inputPath}: ${inputError.message}` } }, null, 2)}
|
|
13886
14520
|
`);
|
|
@@ -13906,7 +14540,7 @@ async function runCli(argv, io = {}) {
|
|
|
13906
14540
|
return 1;
|
|
13907
14541
|
}
|
|
13908
14542
|
const packageDir = dirname9(fileURLToPath3(import.meta.url));
|
|
13909
|
-
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");
|
|
13910
14544
|
const revisionDigest = typeof parsed.flags["revision-digest"] === "string" ? parsed.flags["revision-digest"] : void 0;
|
|
13911
14545
|
async function resolveContract(contractId) {
|
|
13912
14546
|
const catalog = await loadContractCatalog(contractsDir);
|
|
@@ -14120,7 +14754,7 @@ async function runCli(argv, io = {}) {
|
|
|
14120
14754
|
}
|
|
14121
14755
|
let markdownContent;
|
|
14122
14756
|
try {
|
|
14123
|
-
markdownContent = await
|
|
14757
|
+
markdownContent = await readFile7(markdownPath, "utf-8");
|
|
14124
14758
|
} catch {
|
|
14125
14759
|
out(`${JSON.stringify({ ok: false, error: { code: "SCHEMA_VALIDATION_FAILED", path: "/markdown", message: `Could not read markdown file "${markdownPath}"` } }, null, 2)}
|
|
14126
14760
|
`);
|
|
@@ -14219,7 +14853,7 @@ function isGraphRelevantPath(path, schema) {
|
|
|
14219
14853
|
return path === "artifact-graph.config.yaml" || path === VERSION_LOCK_PATH || matchesConfiguredArtifactPath(path, schema);
|
|
14220
14854
|
}
|
|
14221
14855
|
async function initConfig(root) {
|
|
14222
|
-
const configPath =
|
|
14856
|
+
const configPath = join15(root, "artifact-graph.config.yaml");
|
|
14223
14857
|
try {
|
|
14224
14858
|
await access3(configPath);
|
|
14225
14859
|
throw new Error(`Config already exists: ${configPath}`);
|
|
@@ -14229,7 +14863,7 @@ async function initConfig(root) {
|
|
|
14229
14863
|
}
|
|
14230
14864
|
}
|
|
14231
14865
|
await mkdir7(root, { recursive: true });
|
|
14232
|
-
await writeFile6(configPath,
|
|
14866
|
+
await writeFile6(configPath, yaml4.dump(DEFAULT_SCHEMA, { lineWidth: 120 }));
|
|
14233
14867
|
}
|
|
14234
14868
|
function parseArgs(argv) {
|
|
14235
14869
|
const [command, ...rest] = argv;
|
|
@@ -14273,13 +14907,13 @@ function parseTimeViewFlag(value, err) {
|
|
|
14273
14907
|
}
|
|
14274
14908
|
async function readReleaseInput(root, value) {
|
|
14275
14909
|
if (value.includes(",")) return value.split(",");
|
|
14276
|
-
const candidate =
|
|
14910
|
+
const candidate = isAbsolute8(value) ? value : join15(root, value);
|
|
14277
14911
|
try {
|
|
14278
14912
|
await access3(candidate);
|
|
14279
14913
|
} catch {
|
|
14280
14914
|
return [value];
|
|
14281
14915
|
}
|
|
14282
|
-
const raw = await
|
|
14916
|
+
const raw = await readFile7(candidate, "utf-8");
|
|
14283
14917
|
try {
|
|
14284
14918
|
const parsed = JSON.parse(raw);
|
|
14285
14919
|
if (Array.isArray(parsed) && parsed.every((item) => typeof item === "string")) return parsed;
|