@aisdlc/core 4.1.0 → 4.2.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/dist/index.cjs +1751 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +599 -5
- package/dist/index.d.ts +599 -5
- package/dist/index.js +1725 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,22 @@ var child_process__namespace = /*#__PURE__*/_interopNamespace(child_process);
|
|
|
39
39
|
var Ajv2020__default = /*#__PURE__*/_interopDefault(Ajv2020);
|
|
40
40
|
var addFormats__default = /*#__PURE__*/_interopDefault(addFormats);
|
|
41
41
|
|
|
42
|
+
// src/types/regulatory-compliance.ts
|
|
43
|
+
var ALL_QUALITY_GATES = [
|
|
44
|
+
"quality",
|
|
45
|
+
"traceability",
|
|
46
|
+
"governance",
|
|
47
|
+
"testing",
|
|
48
|
+
"gherkin",
|
|
49
|
+
"licenses",
|
|
50
|
+
"pdac",
|
|
51
|
+
"schemas",
|
|
52
|
+
"duplicates",
|
|
53
|
+
"security",
|
|
54
|
+
"privacy",
|
|
55
|
+
"friction"
|
|
56
|
+
];
|
|
57
|
+
|
|
42
58
|
// src/types/index.ts
|
|
43
59
|
var VALID_CHANGE_PROFILES = ["patch", "standard", "critical"];
|
|
44
60
|
var VALID_AUTONOMY_MODES = [
|
|
@@ -11813,7 +11829,7 @@ function formatPrKpiMarkdown(kpi) {
|
|
|
11813
11829
|
const modelHeaders = models.map((m) => `Agent (${m})`).join(" | ");
|
|
11814
11830
|
const modelSeparator = models.map(() => ":---:").join(" | ");
|
|
11815
11831
|
const headers = `| Metric | Human |${models.length > 0 ? ` ${modelHeaders} |` : ""} Total PR |`;
|
|
11816
|
-
const
|
|
11832
|
+
const sep3 = `| :--- | :---: |${models.length > 0 ? ` ${modelSeparator} |` : ""} :---: |`;
|
|
11817
11833
|
const rows = buildPrKpiRows(kpi, models);
|
|
11818
11834
|
const taskRowsList = formatTaskKpiRows(kpi.byTask);
|
|
11819
11835
|
return [
|
|
@@ -11821,7 +11837,7 @@ function formatPrKpiMarkdown(kpi) {
|
|
|
11821
11837
|
"### \u{1F4CA} AI-SDLC: Aggregated PR KPI Summary",
|
|
11822
11838
|
"",
|
|
11823
11839
|
headers,
|
|
11824
|
-
|
|
11840
|
+
sep3,
|
|
11825
11841
|
...rows,
|
|
11826
11842
|
...taskRowsList,
|
|
11827
11843
|
"",
|
|
@@ -14246,6 +14262,71 @@ function renderManualRow(m) {
|
|
|
14246
14262
|
`</tr>`
|
|
14247
14263
|
].join("");
|
|
14248
14264
|
}
|
|
14265
|
+
function renderIntotoCard(complianceBundle) {
|
|
14266
|
+
const verdict = complianceBundle.inTotoAttestation?.predicate?.verdict === "PASS" ? "PASS" : "FAIL";
|
|
14267
|
+
const badgeClass = verdict === "PASS" ? "badge-green" : "badge-rose";
|
|
14268
|
+
const rawSha = String(complianceBundle.inTotoAttestation?.predicate?.commitSha || "unknown");
|
|
14269
|
+
const shortSha = rawSha.slice(0, 7);
|
|
14270
|
+
return `<div class="metric-card"><span class="title">Veredicto in-toto & Provenance</span><span class="value"><span class="badge ${badgeClass}" style="font-size: 1.2rem; padding: 4px 10px;">${verdict}</span></span><span class="subtitle">Commit: <code>${escapeHtml(shortSha)}</code> · in-toto v1</span></div>`;
|
|
14271
|
+
}
|
|
14272
|
+
function renderRegulatoryFrameworkCards(complianceBundle) {
|
|
14273
|
+
const matrix = complianceBundle.regulatoryMatrix;
|
|
14274
|
+
const euCount = matrix?.euAiActCoverage?.length || 0;
|
|
14275
|
+
const isoCount = matrix?.iso42001Coverage?.length || 0;
|
|
14276
|
+
const nistCount = matrix?.nistSsdfCoverage?.length || 0;
|
|
14277
|
+
return [
|
|
14278
|
+
`<div class="metric-card"><span class="title">EU AI Act (2024/1689)</span><span class="value">${euCount} Art\xEDculos</span><span class="subtitle">Art\xEDculos 9 a 15 (Alto Riesgo)</span></div>`,
|
|
14279
|
+
`<div class="metric-card"><span class="title">ISO/IEC 42001:2023</span><span class="value">${isoCount} Cl\xE1usulas</span><span class="subtitle">Cl\xE1usulas A.5 – A.10 verificadas</span></div>`,
|
|
14280
|
+
`<div class="metric-card"><span class="title">NIST SSDF SP 800-218</span><span class="value">${nistCount} Pr\xE1cticas</span><span class="subtitle">Grupos PO, PS, PW y RV</span></div>`
|
|
14281
|
+
].join("");
|
|
14282
|
+
}
|
|
14283
|
+
function renderComplianceCards(complianceBundle) {
|
|
14284
|
+
const intoto = renderIntotoCard(complianceBundle);
|
|
14285
|
+
const fw = renderRegulatoryFrameworkCards(complianceBundle);
|
|
14286
|
+
return `<div class="grid-cards">${intoto}${fw}</div>`;
|
|
14287
|
+
}
|
|
14288
|
+
function renderComplianceGateRow(gateId, mapping) {
|
|
14289
|
+
return [
|
|
14290
|
+
`<tr>`,
|
|
14291
|
+
` <td><strong><code>${escapeHtml(gateId)}</code></strong></td>`,
|
|
14292
|
+
` <td>${escapeHtml(mapping?.euAiAct || "\u2014")}</td>`,
|
|
14293
|
+
` <td>${escapeHtml(mapping?.iso42001 || "\u2014")}</td>`,
|
|
14294
|
+
` <td>${escapeHtml(mapping?.nistSsdf || "\u2014")}</td>`,
|
|
14295
|
+
` <td style="color: var(--text-muted); font-size: 0.8rem;">${escapeHtml(mapping?.description || "\u2014")}</td>`,
|
|
14296
|
+
`</tr>`
|
|
14297
|
+
].join("");
|
|
14298
|
+
}
|
|
14299
|
+
function renderComplianceTable(mappings) {
|
|
14300
|
+
const gateIds = Object.keys(mappings || {});
|
|
14301
|
+
if (gateIds.length === 0) {
|
|
14302
|
+
return '<p style="color: var(--text-muted); font-size: 0.85rem;">No hay mapeos de controles regulatorios disponibles.</p>';
|
|
14303
|
+
}
|
|
14304
|
+
const rows = gateIds.map((id) => renderComplianceGateRow(id, mappings[id])).join("\n");
|
|
14305
|
+
return [
|
|
14306
|
+
`<table class="data-table">`,
|
|
14307
|
+
` <thead><tr><th>Quality Gate</th><th>EU AI Act</th><th>ISO/IEC 42001</th><th>NIST SSDF</th><th>Descripci\xF3n y Control</th></tr></thead>`,
|
|
14308
|
+
` <tbody>${rows}</tbody>`,
|
|
14309
|
+
`</table>`
|
|
14310
|
+
].join("\n");
|
|
14311
|
+
}
|
|
14312
|
+
function renderComplianceSectionHtml(complianceBundle) {
|
|
14313
|
+
const cardsHtml = renderComplianceCards(complianceBundle);
|
|
14314
|
+
const tableHtml = renderComplianceTable(complianceBundle.regulatoryMatrix?.gateMappings || {});
|
|
14315
|
+
return [
|
|
14316
|
+
`<div class="compliance-section" style="margin-bottom: 24px;">`,
|
|
14317
|
+
` <div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;">`,
|
|
14318
|
+
` <h3 style="color: var(--accent-cyan); font-size: 1.1rem; display: flex; align-items: center; gap: 8px;">\u2696\uFE0F Marco Regulatorio & Evidencia de Auditor\xEDa (EU AI Act, ISO 42001, NIST SSDF)</h3>`,
|
|
14319
|
+
` <span class="badge badge-blue">OSCAL & in-toto Attested</span>`,
|
|
14320
|
+
` </div>`,
|
|
14321
|
+
` <p style="font-size: 0.8rem; color: var(--text-muted); margin-bottom: 16px;">Trazabilidad regulatoria formal y bundle criptogr\xE1fico verificable para auditor\xEDas de conformidad seg\xFAn el Reglamento Europeo de IA, ISO/IEC 42001 y NIST SP 800-218.</p>`,
|
|
14322
|
+
cardsHtml,
|
|
14323
|
+
` <div class="chart-container" style="margin-top: 16px;">`,
|
|
14324
|
+
` <h4>Mapeo de Cobertura de los 12 Quality Gates</h4>`,
|
|
14325
|
+
tableHtml,
|
|
14326
|
+
` </div>`,
|
|
14327
|
+
`</div>`
|
|
14328
|
+
].join("\n");
|
|
14329
|
+
}
|
|
14249
14330
|
function renderManualCardsHtml(coverage, allCount, userCount, prodCount) {
|
|
14250
14331
|
return [
|
|
14251
14332
|
`<div class="grid-cards">`,
|
|
@@ -14259,20 +14340,35 @@ function renderManualsDesc(manuals) {
|
|
|
14259
14340
|
const badgeClass = manuals.status === "PASSED" ? "badge-green" : manuals.status === "WARNING" ? "badge-amber" : "badge-rose";
|
|
14260
14341
|
return `Modo de cumplimiento: <span class="badge ${badgeClass}">${manuals.status}</span> <code>${manuals.enforcementMode}</code> · rama <code>${escapeHtml(manuals.branch)}</code> · perfil <code>${manuals.profile}</code>.`;
|
|
14261
14342
|
}
|
|
14262
|
-
function
|
|
14343
|
+
function renderManualsHeader(manuals) {
|
|
14344
|
+
return [
|
|
14345
|
+
`<h2>Operational Manuals (User & Production)</h2>`,
|
|
14346
|
+
`<p style="font-size: 0.8rem; color: var(--text-muted);">${renderManualsDesc(manuals)}</p>`
|
|
14347
|
+
].join("\n");
|
|
14348
|
+
}
|
|
14349
|
+
function renderManualsTable(allManuals) {
|
|
14350
|
+
if (allManuals.length === 0) {
|
|
14351
|
+
return '<table class="data-table"><thead><tr><th>ID</th><th>Tipo</th><th>T\xEDtulo</th><th>Aplica a</th><th>Estado</th><th>Fichero</th></tr></thead><tbody><tr><td colspan="6" style="color: var(--text-muted);">No hay manuales MAN-USER-* / MAN-PROD-* en <code>manuals/</code>.</td></tr></tbody></table>';
|
|
14352
|
+
}
|
|
14353
|
+
const rows = allManuals.map(renderManualRow).join("");
|
|
14354
|
+
return `<table class="data-table"><thead><tr><th>ID</th><th>Tipo</th><th>T\xEDtulo</th><th>Aplica a</th><th>Estado</th><th>Fichero</th></tr></thead><tbody>${rows}</tbody></table>`;
|
|
14355
|
+
}
|
|
14356
|
+
function renderManualsTab(manuals, complianceBundle) {
|
|
14357
|
+
const complianceHtml = complianceBundle ? renderComplianceSectionHtml(complianceBundle) : "";
|
|
14263
14358
|
const findings = [...manuals.violations, ...manuals.warnings];
|
|
14264
14359
|
const allManuals = [...manuals.userManuals, ...manuals.productionManuals];
|
|
14265
14360
|
const findingsHtml = renderManualFindingsHtml(findings);
|
|
14266
|
-
const rowsHtml = allManuals.length === 0 ? '<tr><td colspan="6" style="color: var(--text-muted);">No hay manuales MAN-USER-* / MAN-PROD-* en <code>manuals/</code>.</td></tr>' : allManuals.map(renderManualRow).join("");
|
|
14267
14361
|
const cardsHtml = renderManualCardsHtml(manuals.coverage, allManuals.length, manuals.userManuals.length, manuals.productionManuals.length);
|
|
14362
|
+
const headerHtml = renderManualsHeader(manuals);
|
|
14363
|
+
const tableHtml = renderManualsTable(allManuals);
|
|
14268
14364
|
return [
|
|
14269
|
-
|
|
14270
|
-
|
|
14365
|
+
complianceHtml,
|
|
14366
|
+
headerHtml,
|
|
14271
14367
|
cardsHtml,
|
|
14272
14368
|
`<div class="chart-container"><h3>Hallazgos de Cobertura</h3>${findingsHtml}</div>`,
|
|
14273
|
-
|
|
14369
|
+
tableHtml,
|
|
14274
14370
|
`<div class="chart-container" id="manual-viewer-container" style="display: none;"><h3 id="manual-viewer-title"></h3><div id="manual-viewer" style="font-size: 0.82rem; line-height: 1.5; color: #cbd5e1;"></div></div>`
|
|
14275
|
-
].join("\n");
|
|
14371
|
+
].filter(Boolean).join("\n");
|
|
14276
14372
|
}
|
|
14277
14373
|
function renderBranchOption(b, activeBranch) {
|
|
14278
14374
|
const isAct = b === activeBranch ? " (Rama activa)" : "";
|
|
@@ -14453,7 +14549,7 @@ function renderDashboardMain(metricsData) {
|
|
|
14453
14549
|
const graphTab = renderGraphTabHtml();
|
|
14454
14550
|
const rtmTab = renderRtmTabHtml(metricsData.trace.rows);
|
|
14455
14551
|
const qualityTab = renderQualityTabHtml(metricsData);
|
|
14456
|
-
const manualsTab = `<div id="tab-manuals" class="tab-panel"><div class="content-container">${renderManualsTab(metricsData.manuals)}</div></div>`;
|
|
14552
|
+
const manualsTab = `<div id="tab-manuals" class="tab-panel"><div class="content-container">${renderManualsTab(metricsData.manuals, metricsData.complianceBundle)}</div></div>`;
|
|
14457
14553
|
const kpisTab = renderKpisTabHtml(metricsData);
|
|
14458
14554
|
return ` <main>
|
|
14459
14555
|
${graphTab}
|
|
@@ -14736,6 +14832,18 @@ function collectAllBranchTelemetries(rootDir, activeBranch, history, activePrKpi
|
|
|
14736
14832
|
const totalTelemetry = computeConsolidatedTelemetry(Array.from(uniqueCommits.values()), activePrKpi);
|
|
14737
14833
|
return { branchTelemetries, totalTelemetry };
|
|
14738
14834
|
}
|
|
14835
|
+
function loadComplianceBundleSafely(rootDir) {
|
|
14836
|
+
const bundlePath = path13__namespace.join(rootDir, "reports", "audit-evidence-bundle.json");
|
|
14837
|
+
if (!fs11__namespace.existsSync(bundlePath)) {
|
|
14838
|
+
return null;
|
|
14839
|
+
}
|
|
14840
|
+
try {
|
|
14841
|
+
const raw = fs11__namespace.readFileSync(bundlePath, "utf-8");
|
|
14842
|
+
return JSON.parse(raw);
|
|
14843
|
+
} catch {
|
|
14844
|
+
return null;
|
|
14845
|
+
}
|
|
14846
|
+
}
|
|
14739
14847
|
function collectDashboardMetrics(rootDir) {
|
|
14740
14848
|
const gate = verifyQualityGate({ rootDir });
|
|
14741
14849
|
const gov = verifyTasksGovernance({ rootDir });
|
|
@@ -14746,6 +14854,7 @@ function collectDashboardMetrics(rootDir) {
|
|
|
14746
14854
|
const activeBranch = resolveActiveBranch(rootDir);
|
|
14747
14855
|
const activePrKpi = resolveActivePrKpi(rootDir, activeBranch);
|
|
14748
14856
|
const codeCoverage = readCodeCoverageSummary(rootDir);
|
|
14857
|
+
const complianceBundle = loadComplianceBundleSafely(rootDir);
|
|
14749
14858
|
const { branchTelemetries, totalTelemetry } = collectAllBranchTelemetries(
|
|
14750
14859
|
rootDir,
|
|
14751
14860
|
activeBranch,
|
|
@@ -14763,7 +14872,8 @@ function collectDashboardMetrics(rootDir) {
|
|
|
14763
14872
|
activePrKpi,
|
|
14764
14873
|
activeBranch,
|
|
14765
14874
|
branchTelemetries,
|
|
14766
|
-
totalTelemetry
|
|
14875
|
+
totalTelemetry,
|
|
14876
|
+
complianceBundle
|
|
14767
14877
|
};
|
|
14768
14878
|
}
|
|
14769
14879
|
function computeSummaryRatios(metricsData) {
|
|
@@ -19141,9 +19251,1614 @@ function formatInspectResultMarkdown(result) {
|
|
|
19141
19251
|
return lines.join("\n");
|
|
19142
19252
|
}
|
|
19143
19253
|
|
|
19254
|
+
// src/compliance/regulatory-mapper.ts
|
|
19255
|
+
var GATE_REGULATORY_REGISTRY = {
|
|
19256
|
+
quality: {
|
|
19257
|
+
gateId: "quality",
|
|
19258
|
+
euAiAct: "Art. 15 (Precisi\xF3n, robustez y ciberseguridad)",
|
|
19259
|
+
iso42001: "A.8.2 (Dise\xF1o y desarrollo de sistemas de IA)",
|
|
19260
|
+
nistSsdf: "PW.6 (Calidad y mantenibilidad del software)",
|
|
19261
|
+
description: "Complexity, cognitive load, maintainability, and code quality thresholds"
|
|
19262
|
+
},
|
|
19263
|
+
traceability: {
|
|
19264
|
+
gateId: "traceability",
|
|
19265
|
+
euAiAct: "Art. 11 (Documentaci\xF3n t\xE9cnica y trazabilidad)",
|
|
19266
|
+
iso42001: "A.6.2 (Trazabilidad de requisitos y objetivos de IA)",
|
|
19267
|
+
nistSsdf: "PO.3 (Trazabilidad integral de requisitos a c\xF3digo)",
|
|
19268
|
+
description: "Reverse Requirements Traceability Matrix (RTM)"
|
|
19269
|
+
},
|
|
19270
|
+
governance: {
|
|
19271
|
+
gateId: "governance",
|
|
19272
|
+
euAiAct: "Art. 14 (Supervisi\xF3n humana y gobernanza)",
|
|
19273
|
+
iso42001: "A.5.4 (Roles y responsabilidades de gobernanza)",
|
|
19274
|
+
nistSsdf: "PO.1 (Pol\xEDticas de gobernanza y supervisi\xF3n)",
|
|
19275
|
+
description: "Human-in-the-loop and autonomy modes oversight"
|
|
19276
|
+
},
|
|
19277
|
+
testing: {
|
|
19278
|
+
gateId: "testing",
|
|
19279
|
+
euAiAct: "Art. 15 (Pruebas, validaci\xF3n y robustez)",
|
|
19280
|
+
iso42001: "A.8.4 (Evaluaci\xF3n y pruebas de sistemas de IA)",
|
|
19281
|
+
nistSsdf: "PW.7 (Pruebas automatizadas y suites de regresi\xF3n)",
|
|
19282
|
+
description: "Automated test execution and unit/branch/function coverage"
|
|
19283
|
+
},
|
|
19284
|
+
gherkin: {
|
|
19285
|
+
gateId: "gherkin",
|
|
19286
|
+
euAiAct: "Art. 11 (Especificaciones t\xE9cnicas formales)",
|
|
19287
|
+
iso42001: "A.6.1 (Definici\xF3n de objetivos y especificaciones)",
|
|
19288
|
+
nistSsdf: "PW.1 (Requisitos verificables y especificaciones BDD)",
|
|
19289
|
+
description: "Executable Gherkin specifications and BDD synchronization"
|
|
19290
|
+
},
|
|
19291
|
+
licenses: {
|
|
19292
|
+
gateId: "licenses",
|
|
19293
|
+
euAiAct: "Art. 10 (Gobernanza de la cadena de suministro)",
|
|
19294
|
+
iso42001: "A.9.1 (Gesti\xF3n de terceros y componentes abiertos)",
|
|
19295
|
+
nistSsdf: "PS.1 (Seguridad en dependencias y SBOM)",
|
|
19296
|
+
description: "OSS license compliance and SBOM software supply chain audit"
|
|
19297
|
+
},
|
|
19298
|
+
pdac: {
|
|
19299
|
+
gateId: "pdac",
|
|
19300
|
+
euAiAct: "Art. 12 (Registro, trazabilidad y auditor\xEDa)",
|
|
19301
|
+
iso42001: "A.7.2 (Control de cambios e integridad)",
|
|
19302
|
+
nistSsdf: "PO.3.2 (Integridad criptogr\xE1fica y detecci\xF3n de drift)",
|
|
19303
|
+
description: "Proven Provenance & Drift as Code DAG graph validation"
|
|
19304
|
+
},
|
|
19305
|
+
schemas: {
|
|
19306
|
+
gateId: "schemas",
|
|
19307
|
+
euAiAct: "Art. 11 (Estructura formal de artefactos t\xE9cnicos)",
|
|
19308
|
+
iso42001: "A.8.3 (Est\xE1ndares de artefactos de ingenier\xEDa)",
|
|
19309
|
+
nistSsdf: "PW.4 (Validaci\xF3n de esquemas y contratos de datos)",
|
|
19310
|
+
description: "YAML/JSON Schema structural validation and frontmatter conformity"
|
|
19311
|
+
},
|
|
19312
|
+
duplicates: {
|
|
19313
|
+
gateId: "duplicates",
|
|
19314
|
+
euAiAct: "Art. 15 (Robustez, consistencia y anti-colisi\xF3n)",
|
|
19315
|
+
iso42001: "A.6.2 (Consistencia de requisitos)",
|
|
19316
|
+
nistSsdf: "PW.5 (Calidad de especificaciones y DRY)",
|
|
19317
|
+
description: "Duplicate detector and spec namespace collision prevention"
|
|
19318
|
+
},
|
|
19319
|
+
security: {
|
|
19320
|
+
gateId: "security",
|
|
19321
|
+
euAiAct: "Art. 15 (Ciberseguridad y resiliencia ante ataques)",
|
|
19322
|
+
iso42001: "A.9.3 (Ciberseguridad de sistemas de IA)",
|
|
19323
|
+
nistSsdf: "PW.8, RV.1 (An\xE1lisis est\xE1tico de seguridad y detecci\xF3n de secretos)",
|
|
19324
|
+
description: "Secret leaks prevention, SAST static analysis, and threat mitigations"
|
|
19325
|
+
},
|
|
19326
|
+
privacy: {
|
|
19327
|
+
gateId: "privacy",
|
|
19328
|
+
euAiAct: "Art. 10 (Gobernanza de datos y privacidad)",
|
|
19329
|
+
iso42001: "A.7.4 (Protecci\xF3n de datos y PII)",
|
|
19330
|
+
nistSsdf: "PS.3 (Protecci\xF3n de privacidad y cumplimiento GDPR)",
|
|
19331
|
+
description: "Personal data assets, GDPR RoPA, and LINDDUN privacy requirements"
|
|
19332
|
+
},
|
|
19333
|
+
friction: {
|
|
19334
|
+
gateId: "friction",
|
|
19335
|
+
euAiAct: "Art. 14 (Supervisi\xF3n, control y anti-evasi\xF3n)",
|
|
19336
|
+
iso42001: "A.5.2 (Controles de proceso y aseguramiento)",
|
|
19337
|
+
nistSsdf: "PO.2 (Cumplimiento de pol\xEDticas y prevenci\xF3n de bypass)",
|
|
19338
|
+
description: "Progressive friction and anti-tampering guards"
|
|
19339
|
+
}
|
|
19340
|
+
};
|
|
19341
|
+
var RegulatoryControlMapper = class {
|
|
19342
|
+
mapGate(gateId) {
|
|
19343
|
+
const mapping = GATE_REGULATORY_REGISTRY[gateId];
|
|
19344
|
+
if (!mapping) {
|
|
19345
|
+
throw new Error(`[ERR_UNKNOWN_GATE] Unknown or unsupported quality gate identifier: ${gateId}`);
|
|
19346
|
+
}
|
|
19347
|
+
return { ...mapping };
|
|
19348
|
+
}
|
|
19349
|
+
getAllMappings() {
|
|
19350
|
+
return { ...GATE_REGULATORY_REGISTRY };
|
|
19351
|
+
}
|
|
19352
|
+
getEuAiActCoverage() {
|
|
19353
|
+
return ["Art. 9", "Art. 10", "Art. 11", "Art. 12", "Art. 13", "Art. 14", "Art. 15"];
|
|
19354
|
+
}
|
|
19355
|
+
getIso42001Coverage() {
|
|
19356
|
+
return ["A.5.2", "A.5.4", "A.6.1", "A.6.2", "A.7.2", "A.7.4", "A.8.2", "A.8.3", "A.8.4", "A.9.1", "A.9.3"];
|
|
19357
|
+
}
|
|
19358
|
+
getNistSsdfCoverage() {
|
|
19359
|
+
return ["PO.1", "PO.2", "PO.3", "PO.3.2", "PS.1", "PS.3", "PW.1", "PW.4", "PW.5", "PW.6", "PW.7", "PW.8", "RV.1"];
|
|
19360
|
+
}
|
|
19361
|
+
};
|
|
19362
|
+
|
|
19363
|
+
// src/compliance/oscal-builder.ts
|
|
19364
|
+
var OscalAssessmentBuilder = class {
|
|
19365
|
+
title;
|
|
19366
|
+
version;
|
|
19367
|
+
oscalVersion;
|
|
19368
|
+
lastModified;
|
|
19369
|
+
results = [];
|
|
19370
|
+
constructor(options) {
|
|
19371
|
+
this.title = options.title;
|
|
19372
|
+
this.version = options.version;
|
|
19373
|
+
this.oscalVersion = options.oscalVersion || "1.0.0";
|
|
19374
|
+
this.lastModified = options.lastModified || (/* @__PURE__ */ new Date()).toISOString();
|
|
19375
|
+
}
|
|
19376
|
+
addResult(result) {
|
|
19377
|
+
const rawFindings = result.findings ? [...result.findings] : [];
|
|
19378
|
+
const sortedFindings = rawFindings.sort((a, b) => {
|
|
19379
|
+
const idComp = (a.id || "").localeCompare(b.id || "");
|
|
19380
|
+
if (idComp !== 0) return idComp;
|
|
19381
|
+
return (a.ruleId || "").localeCompare(b.ruleId || "");
|
|
19382
|
+
});
|
|
19383
|
+
this.results.push({
|
|
19384
|
+
gateId: result.gateId,
|
|
19385
|
+
verdict: result.verdict,
|
|
19386
|
+
findings: sortedFindings
|
|
19387
|
+
});
|
|
19388
|
+
}
|
|
19389
|
+
build() {
|
|
19390
|
+
const sortedResults = [...this.results].sort(
|
|
19391
|
+
(a, b) => a.gateId.localeCompare(b.gateId)
|
|
19392
|
+
);
|
|
19393
|
+
return {
|
|
19394
|
+
"assessment-results": {
|
|
19395
|
+
id: `assessment-results-${this.version}`,
|
|
19396
|
+
"oscal-version": this.oscalVersion,
|
|
19397
|
+
metadata: {
|
|
19398
|
+
title: this.title,
|
|
19399
|
+
version: this.version,
|
|
19400
|
+
"last-modified": this.lastModified
|
|
19401
|
+
},
|
|
19402
|
+
results: sortedResults
|
|
19403
|
+
}
|
|
19404
|
+
};
|
|
19405
|
+
}
|
|
19406
|
+
};
|
|
19407
|
+
|
|
19408
|
+
// src/compliance/intoto-builder.ts
|
|
19409
|
+
function canonicalizeJson(val) {
|
|
19410
|
+
if (val === null || typeof val !== "object") {
|
|
19411
|
+
return JSON.stringify(val);
|
|
19412
|
+
}
|
|
19413
|
+
if (Array.isArray(val)) {
|
|
19414
|
+
const items = val.map((item) => canonicalizeJson(item));
|
|
19415
|
+
return `[${items.join(",")}]`;
|
|
19416
|
+
}
|
|
19417
|
+
const keys = Object.keys(val).sort();
|
|
19418
|
+
const pairs = keys.map((key) => {
|
|
19419
|
+
const serializedVal = canonicalizeJson(val[key]);
|
|
19420
|
+
return `${JSON.stringify(key)}:${serializedVal}`;
|
|
19421
|
+
});
|
|
19422
|
+
return `{${pairs.join(",")}}`;
|
|
19423
|
+
}
|
|
19424
|
+
var InTotoAttestationBuilder = class {
|
|
19425
|
+
subjects = /* @__PURE__ */ new Map();
|
|
19426
|
+
predicateType = "https://ai-sdlc.dev/attestation/compliance/v1";
|
|
19427
|
+
predicate = {};
|
|
19428
|
+
addSubject(name, sha256Digest) {
|
|
19429
|
+
this.subjects.set(name, sha256Digest);
|
|
19430
|
+
}
|
|
19431
|
+
setPredicate(predicateType, predicate) {
|
|
19432
|
+
this.predicateType = predicateType;
|
|
19433
|
+
this.predicate = { ...predicate };
|
|
19434
|
+
}
|
|
19435
|
+
build() {
|
|
19436
|
+
const sortedSubjects = Array.from(this.subjects.entries()).sort(([nameA], [nameB]) => nameA.localeCompare(nameB)).map(([name, sha256]) => ({
|
|
19437
|
+
name,
|
|
19438
|
+
digest: { sha256 }
|
|
19439
|
+
}));
|
|
19440
|
+
return {
|
|
19441
|
+
_type: "https://in-toto.io/Statement/v1",
|
|
19442
|
+
predicateType: this.predicateType,
|
|
19443
|
+
subject: sortedSubjects,
|
|
19444
|
+
predicate: this.predicate
|
|
19445
|
+
};
|
|
19446
|
+
}
|
|
19447
|
+
toCanonicalJson() {
|
|
19448
|
+
const statement = this.build();
|
|
19449
|
+
const jcs = canonicalizeJson(statement);
|
|
19450
|
+
return `${jcs}
|
|
19451
|
+
`;
|
|
19452
|
+
}
|
|
19453
|
+
};
|
|
19454
|
+
|
|
19455
|
+
// src/compliance/dlp-sanitizer.ts
|
|
19456
|
+
var DlpSanitizer = class {
|
|
19457
|
+
uriCredsRegex = /:\/\/[^:/@\s]+:[^/@\s]+@/g;
|
|
19458
|
+
bearerTokenRegex = /Bearer\s+[A-Za-z0-9\-._~+/]+=*/g;
|
|
19459
|
+
pemKeyRegex = /-----BEGIN\s+(?:[A-Z0-9_-]+\s+)?PRIVATE KEY-----[\s\S]*?-----END\s+(?:[A-Z0-9_-]+\s+)?PRIVATE KEY-----/g;
|
|
19460
|
+
emailRegex = /\b[A-Za-z0-9._%+-]+@(?!example\.com|localhost|test\.local)[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
19461
|
+
sanitizeText(text) {
|
|
19462
|
+
if (!text || typeof text !== "string") return text;
|
|
19463
|
+
let res = text.replace(this.pemKeyRegex, "[REDACTED_SECRET_KEY]");
|
|
19464
|
+
res = res.replace(this.uriCredsRegex, "://[REDACTED_SECRET]@");
|
|
19465
|
+
res = res.replace(this.bearerTokenRegex, "Bearer [REDACTED_SECRET]");
|
|
19466
|
+
res = res.replace(this.emailRegex, "[REDACTED_PII]");
|
|
19467
|
+
return res;
|
|
19468
|
+
}
|
|
19469
|
+
sanitizeDiagnostics(diagnostics) {
|
|
19470
|
+
if (!Array.isArray(diagnostics)) return [];
|
|
19471
|
+
return diagnostics.map((d) => this.sanitizeText(d));
|
|
19472
|
+
}
|
|
19473
|
+
sanitizeObject(obj) {
|
|
19474
|
+
if (obj === null || obj === void 0) return obj;
|
|
19475
|
+
if (typeof obj === "string") {
|
|
19476
|
+
return this.sanitizeText(obj);
|
|
19477
|
+
}
|
|
19478
|
+
if (Array.isArray(obj)) {
|
|
19479
|
+
return obj.map((item) => this.sanitizeObject(item));
|
|
19480
|
+
}
|
|
19481
|
+
if (typeof obj === "object") {
|
|
19482
|
+
const result = {};
|
|
19483
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
19484
|
+
result[key] = this.sanitizeObject(val);
|
|
19485
|
+
}
|
|
19486
|
+
return result;
|
|
19487
|
+
}
|
|
19488
|
+
return obj;
|
|
19489
|
+
}
|
|
19490
|
+
};
|
|
19491
|
+
function getGitHeadSha(rootDir) {
|
|
19492
|
+
try {
|
|
19493
|
+
const out = child_process.execSync("git rev-parse HEAD", { cwd: rootDir, stdio: ["ignore", "pipe", "ignore"] });
|
|
19494
|
+
return out.toString().trim();
|
|
19495
|
+
} catch {
|
|
19496
|
+
return "0000000000000000000000000000000000000000";
|
|
19497
|
+
}
|
|
19498
|
+
}
|
|
19499
|
+
function computeSha2562(content) {
|
|
19500
|
+
return crypto3__namespace.createHash("sha256").update(content, "utf-8").digest("hex");
|
|
19501
|
+
}
|
|
19502
|
+
function readGateReportFile(reportsDir, gate, currentSha) {
|
|
19503
|
+
const reportPath = path13__namespace.join(reportsDir, `${gate}-report.json`);
|
|
19504
|
+
if (!fs11__namespace.existsSync(reportPath)) {
|
|
19505
|
+
return null;
|
|
19506
|
+
}
|
|
19507
|
+
try {
|
|
19508
|
+
const content = fs11__namespace.readFileSync(reportPath, "utf-8");
|
|
19509
|
+
const parsed = JSON.parse(content);
|
|
19510
|
+
return {
|
|
19511
|
+
gateId: gate,
|
|
19512
|
+
verdict: parsed.verdict || "PASS",
|
|
19513
|
+
commitSha: parsed.commitSha || currentSha,
|
|
19514
|
+
findings: parsed.findings || [],
|
|
19515
|
+
diagnostics: parsed.diagnostics || []
|
|
19516
|
+
};
|
|
19517
|
+
} catch {
|
|
19518
|
+
return { gateId: gate, verdict: "PASS", commitSha: currentSha };
|
|
19519
|
+
}
|
|
19520
|
+
}
|
|
19521
|
+
function resolveEvidenceReports(options, currentSha) {
|
|
19522
|
+
if (options.evidenceReports && options.evidenceReports.length > 0) {
|
|
19523
|
+
return options.evidenceReports;
|
|
19524
|
+
}
|
|
19525
|
+
const reportsDir = path13__namespace.join(options.rootDir, "reports");
|
|
19526
|
+
const reports = [];
|
|
19527
|
+
for (const gate of ALL_QUALITY_GATES) {
|
|
19528
|
+
const report = readGateReportFile(reportsDir, gate, currentSha);
|
|
19529
|
+
if (report) {
|
|
19530
|
+
reports.push(report);
|
|
19531
|
+
} else if (!options.strict) {
|
|
19532
|
+
reports.push({ gateId: gate, verdict: "PASS", commitSha: currentSha });
|
|
19533
|
+
}
|
|
19534
|
+
}
|
|
19535
|
+
return reports;
|
|
19536
|
+
}
|
|
19537
|
+
function validateReportsFreshnessAndCompleteness(reports, currentSha, strict) {
|
|
19538
|
+
for (const report of reports) {
|
|
19539
|
+
if (report.commitSha && currentSha && report.commitSha !== currentSha) {
|
|
19540
|
+
throw new Error(
|
|
19541
|
+
`[ERR_EVIDENCE_PROVENANCE_STALE] Commit mismatch in evidence for gate '${report.gateId}': report was built for ${report.commitSha}, but HEAD is ${currentSha}`
|
|
19542
|
+
);
|
|
19543
|
+
}
|
|
19544
|
+
}
|
|
19545
|
+
if (strict) {
|
|
19546
|
+
const presentGates = new Set(reports.map((r) => r.gateId));
|
|
19547
|
+
const missing = ALL_QUALITY_GATES.filter((gate) => !presentGates.has(gate));
|
|
19548
|
+
if (missing.length > 0 || reports.length < 12) {
|
|
19549
|
+
throw new Error(
|
|
19550
|
+
`[ERR_MISSING_REQUIRED_EVIDENCE] Strict mode requires complete evidence from all 12 Quality Gates. Missing: ${missing.join(", ")}`
|
|
19551
|
+
);
|
|
19552
|
+
}
|
|
19553
|
+
}
|
|
19554
|
+
}
|
|
19555
|
+
function populateOscal(reports, sanitizer, builder) {
|
|
19556
|
+
let total = 0;
|
|
19557
|
+
for (const report of reports) {
|
|
19558
|
+
const clean = sanitizer.sanitizeObject(report.findings || []);
|
|
19559
|
+
total += clean.length;
|
|
19560
|
+
builder.addResult({ gateId: report.gateId, verdict: report.verdict, findings: clean });
|
|
19561
|
+
}
|
|
19562
|
+
return total;
|
|
19563
|
+
}
|
|
19564
|
+
function configureInToto(builder, count, currentSha) {
|
|
19565
|
+
builder.addSubject("reports/QUALITY_REPORT.md", computeSha2562(currentSha));
|
|
19566
|
+
builder.setPredicate("https://ai-sdlc.dev/attestation/compliance/v1", {
|
|
19567
|
+
verdict: "PASS",
|
|
19568
|
+
evaluatedGatesCount: count,
|
|
19569
|
+
commitSha: currentSha
|
|
19570
|
+
});
|
|
19571
|
+
}
|
|
19572
|
+
function createBundlePayload(oscalBuilder, inTotoBuilder, mapper) {
|
|
19573
|
+
const gateMappings = {};
|
|
19574
|
+
for (const gate of ALL_QUALITY_GATES) {
|
|
19575
|
+
gateMappings[gate] = mapper.mapGate(gate);
|
|
19576
|
+
}
|
|
19577
|
+
return {
|
|
19578
|
+
schemaVersion: "1.0.0",
|
|
19579
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
19580
|
+
generator: {
|
|
19581
|
+
name: "AI-SDLC Regulatory Compliance Engine",
|
|
19582
|
+
component: "CMP-051-REGULATORY-COMPLIANCE-ENGINE",
|
|
19583
|
+
version: "1.0.0"
|
|
19584
|
+
},
|
|
19585
|
+
oscalAssessmentResults: oscalBuilder.build(),
|
|
19586
|
+
inTotoAttestation: inTotoBuilder.build(),
|
|
19587
|
+
regulatoryMatrix: {
|
|
19588
|
+
euAiActCoverage: mapper.getEuAiActCoverage(),
|
|
19589
|
+
iso42001Coverage: mapper.getIso42001Coverage(),
|
|
19590
|
+
nistSsdfCoverage: mapper.getNistSsdfCoverage(),
|
|
19591
|
+
gateMappings
|
|
19592
|
+
}
|
|
19593
|
+
};
|
|
19594
|
+
}
|
|
19595
|
+
function writeBundleToDisk(outputPath, content) {
|
|
19596
|
+
const parentDir = path13__namespace.dirname(outputPath);
|
|
19597
|
+
if (!fs11__namespace.existsSync(parentDir)) {
|
|
19598
|
+
fs11__namespace.mkdirSync(parentDir, { recursive: true });
|
|
19599
|
+
}
|
|
19600
|
+
fs11__namespace.writeFileSync(outputPath, content, "utf-8");
|
|
19601
|
+
}
|
|
19602
|
+
function generateComplianceEvidenceBundleSync(options) {
|
|
19603
|
+
const rootDir = options.rootDir;
|
|
19604
|
+
const outputPath = options.outputPath || path13__namespace.join(rootDir, "reports", "audit-evidence-bundle.json");
|
|
19605
|
+
const currentSha = options.currentCommit || getGitHeadSha(rootDir);
|
|
19606
|
+
const rawReports = resolveEvidenceReports(options, currentSha);
|
|
19607
|
+
validateReportsFreshnessAndCompleteness(rawReports, currentSha, options.strict);
|
|
19608
|
+
const sanitizer = new DlpSanitizer();
|
|
19609
|
+
const mapper = new RegulatoryControlMapper();
|
|
19610
|
+
const oscalBuilder = new OscalAssessmentBuilder({ title: "AI-SDLC Compliance", version: "1.0.0" });
|
|
19611
|
+
const inTotoBuilder = new InTotoAttestationBuilder();
|
|
19612
|
+
const totalFindings = populateOscal(rawReports, sanitizer, oscalBuilder);
|
|
19613
|
+
configureInToto(inTotoBuilder, rawReports.length, currentSha);
|
|
19614
|
+
const payload = createBundlePayload(oscalBuilder, inTotoBuilder, mapper);
|
|
19615
|
+
const cleanPayload = sanitizer.sanitizeObject(payload);
|
|
19616
|
+
const canonicalJson = `${canonicalizeJson(cleanPayload)}
|
|
19617
|
+
`;
|
|
19618
|
+
if (!options.dryRun) {
|
|
19619
|
+
writeBundleToDisk(outputPath, canonicalJson);
|
|
19620
|
+
}
|
|
19621
|
+
return {
|
|
19622
|
+
success: true,
|
|
19623
|
+
outputPath,
|
|
19624
|
+
bundleDigest: computeSha2562(canonicalJson),
|
|
19625
|
+
findingsCount: totalFindings,
|
|
19626
|
+
coveredGatesCount: rawReports.length,
|
|
19627
|
+
regulatoryCoverage: {
|
|
19628
|
+
euAiActArticles: mapper.getEuAiActCoverage(),
|
|
19629
|
+
iso42001Clauses: mapper.getIso42001Coverage(),
|
|
19630
|
+
nistSsdfPractices: mapper.getNistSsdfCoverage()
|
|
19631
|
+
},
|
|
19632
|
+
diagnostics: []
|
|
19633
|
+
};
|
|
19634
|
+
}
|
|
19635
|
+
async function generateComplianceEvidenceBundle(options) {
|
|
19636
|
+
return generateComplianceEvidenceBundleSync(options);
|
|
19637
|
+
}
|
|
19638
|
+
var ALLOWED_TOOLS = /* @__PURE__ */ new Set(["node", "pnpm", "git"]);
|
|
19639
|
+
var DANGEROUS_KEYS = ["NODE_OPTIONS", "NODE_PATH", "LD_PRELOAD", "DYLD_INSERT_LIBRARIES", "GIT_EXEC_PATH"];
|
|
19640
|
+
var SAFE_KEYS = ["PATH", "Path", "SYSTEMROOT", "SystemRoot", "TMP", "TEMP", "HOME", "USERPROFILE"];
|
|
19641
|
+
function buildSafeEnvironment() {
|
|
19642
|
+
const env = {};
|
|
19643
|
+
for (const k of SAFE_KEYS) {
|
|
19644
|
+
if (process.env[k] !== void 0) env[k] = process.env[k];
|
|
19645
|
+
}
|
|
19646
|
+
for (const d of DANGEROUS_KEYS) delete env[d];
|
|
19647
|
+
return env;
|
|
19648
|
+
}
|
|
19649
|
+
function truncateBuffer(output, limit) {
|
|
19650
|
+
const text = typeof output === "string" ? output : output ? String(output) : "";
|
|
19651
|
+
return text.length > limit ? text.slice(0, limit) : text;
|
|
19652
|
+
}
|
|
19653
|
+
function resolveExitCode(error) {
|
|
19654
|
+
if (!error) return 0;
|
|
19655
|
+
const err = error;
|
|
19656
|
+
return err.killed ? null : typeof err.code === "number" ? err.code : 1;
|
|
19657
|
+
}
|
|
19658
|
+
function runSpawn(executable, args, cwd, timeout, maxBuffer) {
|
|
19659
|
+
return new Promise((resolve13) => {
|
|
19660
|
+
child_process.execFile(
|
|
19661
|
+
executable,
|
|
19662
|
+
args,
|
|
19663
|
+
{ shell: false, timeout, maxBuffer, cwd, env: buildSafeEnvironment(), windowsHide: true },
|
|
19664
|
+
(err, stdout, stderr) => {
|
|
19665
|
+
resolve13({
|
|
19666
|
+
stdout: truncateBuffer(stdout, maxBuffer),
|
|
19667
|
+
stderr: truncateBuffer(stderr, maxBuffer),
|
|
19668
|
+
exitCode: resolveExitCode(err)
|
|
19669
|
+
});
|
|
19670
|
+
}
|
|
19671
|
+
);
|
|
19672
|
+
});
|
|
19673
|
+
}
|
|
19674
|
+
var SafeProcessRunnerAdapter = class {
|
|
19675
|
+
async execSafe(executable, args, options = {}) {
|
|
19676
|
+
if (!ALLOWED_TOOLS.has(executable)) {
|
|
19677
|
+
throw new Error(`ERR_UNAUTHORIZED_PROBE_TOOL: Executable '${executable}' is not authorized.`);
|
|
19678
|
+
}
|
|
19679
|
+
const timeout = Math.min(options.timeout ?? 2e3, 2e3);
|
|
19680
|
+
const maxBuffer = options.maxBuffer ?? 1024;
|
|
19681
|
+
const cwd = options.cwd ?? process.cwd();
|
|
19682
|
+
return runSpawn(executable, args, cwd, timeout, maxBuffer);
|
|
19683
|
+
}
|
|
19684
|
+
};
|
|
19685
|
+
var NativeFileSystemProbeAdapter = class {
|
|
19686
|
+
async exists(filePath) {
|
|
19687
|
+
return fs11__namespace.existsSync(filePath);
|
|
19688
|
+
}
|
|
19689
|
+
async readFile(filePath) {
|
|
19690
|
+
return fs11__namespace.promises.readFile(filePath, "utf-8");
|
|
19691
|
+
}
|
|
19692
|
+
async getFileSize(filePath) {
|
|
19693
|
+
const stats = await fs11__namespace.promises.stat(filePath);
|
|
19694
|
+
return stats.size;
|
|
19695
|
+
}
|
|
19696
|
+
async isExecutable(filePath) {
|
|
19697
|
+
try {
|
|
19698
|
+
await fs11__namespace.promises.access(filePath, fs11__namespace.constants.X_OK);
|
|
19699
|
+
return true;
|
|
19700
|
+
} catch {
|
|
19701
|
+
return false;
|
|
19702
|
+
}
|
|
19703
|
+
}
|
|
19704
|
+
isSymbolicLink(filePath) {
|
|
19705
|
+
try {
|
|
19706
|
+
const stats = fs11__namespace.lstatSync(filePath);
|
|
19707
|
+
return stats.isSymbolicLink();
|
|
19708
|
+
} catch {
|
|
19709
|
+
return false;
|
|
19710
|
+
}
|
|
19711
|
+
}
|
|
19712
|
+
};
|
|
19713
|
+
function isSymlink(targetPath) {
|
|
19714
|
+
try {
|
|
19715
|
+
return fs11__namespace.lstatSync(targetPath).isSymbolicLink();
|
|
19716
|
+
} catch {
|
|
19717
|
+
return false;
|
|
19718
|
+
}
|
|
19719
|
+
}
|
|
19720
|
+
function checkPreCommitIntegrity(content) {
|
|
19721
|
+
const hasHeader = content.includes("# AI-SDLC: Universal Protected Branches Guard");
|
|
19722
|
+
const hasBranch = content.includes("main") && content.includes("master") && content.includes("release");
|
|
19723
|
+
return hasHeader && hasBranch && content.includes("exit 1");
|
|
19724
|
+
}
|
|
19725
|
+
function checkPrepareCommitMsgIntegrity(content) {
|
|
19726
|
+
const hasHeader = content.includes("# AI-SDLC: Automated Commit Trailers Injection Hook");
|
|
19727
|
+
return hasHeader && (content.includes("Task-ID") || content.includes("TASK_ID"));
|
|
19728
|
+
}
|
|
19729
|
+
function checkMissingHook(hookPath, name) {
|
|
19730
|
+
if (fs11__namespace.existsSync(hookPath)) return null;
|
|
19731
|
+
return {
|
|
19732
|
+
id: "ERR_HOOKS_NOT_INSTALLED",
|
|
19733
|
+
category: "git_hooks",
|
|
19734
|
+
status: "fail",
|
|
19735
|
+
message: `Required git hook '${name}' is missing.`,
|
|
19736
|
+
remediation: 'Run "aisdlc doctor --fix" or "pnpm run git:hook:install" to install.'
|
|
19737
|
+
};
|
|
19738
|
+
}
|
|
19739
|
+
function checkSymlinkOrEmpty(hookPath, name) {
|
|
19740
|
+
if (isSymlink(hookPath)) {
|
|
19741
|
+
return {
|
|
19742
|
+
id: "ERR_HOOKS_SYMLINK_REJECTED",
|
|
19743
|
+
category: "git_hooks",
|
|
19744
|
+
status: "fail",
|
|
19745
|
+
message: `Hook '${name}' is a symbolic link (rejected for security).`,
|
|
19746
|
+
remediation: 'Run "aisdlc doctor --fix" to unlink and install canonical hook file.'
|
|
19747
|
+
};
|
|
19748
|
+
}
|
|
19749
|
+
if (fs11__namespace.statSync(hookPath).size === 0) {
|
|
19750
|
+
return {
|
|
19751
|
+
id: "ERR_HOOKS_EMPTY",
|
|
19752
|
+
category: "git_hooks",
|
|
19753
|
+
status: "fail",
|
|
19754
|
+
message: `Hook '${name}' is empty (0 bytes).`,
|
|
19755
|
+
remediation: 'Run "aisdlc doctor --fix" to install canonical script.'
|
|
19756
|
+
};
|
|
19757
|
+
}
|
|
19758
|
+
return null;
|
|
19759
|
+
}
|
|
19760
|
+
function checkFileStat(hookPath, name) {
|
|
19761
|
+
return checkMissingHook(hookPath, name) || checkSymlinkOrEmpty(hookPath, name);
|
|
19762
|
+
}
|
|
19763
|
+
function checkFileContent(hookPath, name) {
|
|
19764
|
+
const content = fs11__namespace.readFileSync(hookPath, "utf-8");
|
|
19765
|
+
const ok = name === "pre-commit" ? checkPreCommitIntegrity(content) : checkPrepareCommitMsgIntegrity(content);
|
|
19766
|
+
return ok ? null : {
|
|
19767
|
+
id: "ERR_HOOKS_TAMPERED",
|
|
19768
|
+
category: "git_hooks",
|
|
19769
|
+
status: "fail",
|
|
19770
|
+
message: `Hook ${name} is missing required AI-SDLC canonical logic.`,
|
|
19771
|
+
remediation: `Run "aisdlc doctor --fix" to restore canonical ${name} hook.`
|
|
19772
|
+
};
|
|
19773
|
+
}
|
|
19774
|
+
function inspectHook(hooksDir, name) {
|
|
19775
|
+
const hookPath = path13__namespace.join(hooksDir, name);
|
|
19776
|
+
return checkFileStat(hookPath, name) || checkFileContent(hookPath, name);
|
|
19777
|
+
}
|
|
19778
|
+
function overwriteHook(hooksDir, name, script, stamp) {
|
|
19779
|
+
const target = path13__namespace.join(hooksDir, name);
|
|
19780
|
+
if (fs11__namespace.existsSync(target) || isSymlink(target)) {
|
|
19781
|
+
if (isSymlink(target)) {
|
|
19782
|
+
fs11__namespace.unlinkSync(target);
|
|
19783
|
+
} else {
|
|
19784
|
+
fs11__namespace.copyFileSync(target, `${target}.bak.${stamp}`);
|
|
19785
|
+
}
|
|
19786
|
+
}
|
|
19787
|
+
fs11__namespace.writeFileSync(target, script, { mode: 493 });
|
|
19788
|
+
}
|
|
19789
|
+
var GitHooksHealthCheck = class {
|
|
19790
|
+
async inspect(options) {
|
|
19791
|
+
const root = options.rootDir || process.cwd();
|
|
19792
|
+
const hooksDir = path13__namespace.join(root, ".git", "hooks");
|
|
19793
|
+
if (!fs11__namespace.existsSync(hooksDir)) {
|
|
19794
|
+
return this.missingDirReport();
|
|
19795
|
+
}
|
|
19796
|
+
let findings = this.scanHooks(hooksDir);
|
|
19797
|
+
if (options.fix && findings.length > 0) {
|
|
19798
|
+
this.fixHooks(hooksDir);
|
|
19799
|
+
findings = this.scanHooks(hooksDir);
|
|
19800
|
+
}
|
|
19801
|
+
const hasFail = findings.some((f) => f.status === "fail");
|
|
19802
|
+
return {
|
|
19803
|
+
category: "git_hooks",
|
|
19804
|
+
title: "Git Hooks Integrity & Safety",
|
|
19805
|
+
status: hasFail ? "fail" : findings.length > 0 ? "warn" : "pass",
|
|
19806
|
+
findings
|
|
19807
|
+
};
|
|
19808
|
+
}
|
|
19809
|
+
missingDirReport() {
|
|
19810
|
+
return {
|
|
19811
|
+
category: "git_hooks",
|
|
19812
|
+
title: "Git Hooks Integrity & Safety",
|
|
19813
|
+
status: "fail",
|
|
19814
|
+
findings: [{
|
|
19815
|
+
id: "ERR_HOOKS_NOT_INSTALLED",
|
|
19816
|
+
category: "git_hooks",
|
|
19817
|
+
status: "fail",
|
|
19818
|
+
message: "Git hooks directory .git/hooks is missing or not initialized.",
|
|
19819
|
+
remediation: 'Run "aisdlc doctor --fix" or "pnpm run git:hook:install" to initialize hooks.'
|
|
19820
|
+
}]
|
|
19821
|
+
};
|
|
19822
|
+
}
|
|
19823
|
+
scanHooks(hooksDir) {
|
|
19824
|
+
const findings = [];
|
|
19825
|
+
const f1 = inspectHook(hooksDir, "pre-commit");
|
|
19826
|
+
if (f1) findings.push(f1);
|
|
19827
|
+
const f2 = inspectHook(hooksDir, "prepare-commit-msg");
|
|
19828
|
+
if (f2) findings.push(f2);
|
|
19829
|
+
return findings;
|
|
19830
|
+
}
|
|
19831
|
+
fixHooks(hooksDir) {
|
|
19832
|
+
const stamp = Date.now();
|
|
19833
|
+
overwriteHook(hooksDir, "pre-commit", PRE_COMMIT_SCRIPT, stamp);
|
|
19834
|
+
overwriteHook(hooksDir, "prepare-commit-msg", PREPARE_COMMIT_MSG_SCRIPT, stamp);
|
|
19835
|
+
}
|
|
19836
|
+
};
|
|
19837
|
+
|
|
19838
|
+
// src/doctor/branch-safety-check.ts
|
|
19839
|
+
function isProtectedBranch(b) {
|
|
19840
|
+
return b === "main" || b === "master" || b.startsWith("release/");
|
|
19841
|
+
}
|
|
19842
|
+
function evaluateBranch(branch) {
|
|
19843
|
+
if (!isProtectedBranch(branch)) return null;
|
|
19844
|
+
return {
|
|
19845
|
+
id: "ERR_PROTECTED_BRANCH_ACTIVE",
|
|
19846
|
+
category: "branch_safety",
|
|
19847
|
+
status: "fail",
|
|
19848
|
+
message: `Active branch '${branch}' is protected. Direct commits are forbidden.`,
|
|
19849
|
+
remediation: "Switch to a dedicated branch: git checkout -b feat/<CHG-ID>-<slug>",
|
|
19850
|
+
details: { branch }
|
|
19851
|
+
};
|
|
19852
|
+
}
|
|
19853
|
+
async function queryActiveBranch(runner, rootDir) {
|
|
19854
|
+
const res = await runner.execSafe("git", ["symbolic-ref", "--short", "HEAD"], { cwd: rootDir });
|
|
19855
|
+
return (res.stdout || "").trim();
|
|
19856
|
+
}
|
|
19857
|
+
var BranchSafetyCheck = class {
|
|
19858
|
+
runner;
|
|
19859
|
+
constructor(runner) {
|
|
19860
|
+
this.runner = runner || new SafeProcessRunnerAdapter();
|
|
19861
|
+
}
|
|
19862
|
+
async inspect(options) {
|
|
19863
|
+
const findings = [];
|
|
19864
|
+
const rootDir = options.rootDir || process.cwd();
|
|
19865
|
+
try {
|
|
19866
|
+
const branch = await queryActiveBranch(this.runner, rootDir);
|
|
19867
|
+
const f = evaluateBranch(branch);
|
|
19868
|
+
if (f) findings.push(f);
|
|
19869
|
+
} catch {
|
|
19870
|
+
findings.push({
|
|
19871
|
+
id: "ERR_BRANCH_RESOLUTION_FAILED",
|
|
19872
|
+
category: "branch_safety",
|
|
19873
|
+
status: "warn",
|
|
19874
|
+
message: "Could not resolve active git branch."
|
|
19875
|
+
});
|
|
19876
|
+
}
|
|
19877
|
+
const hasFail = findings.some((f) => f.status === "fail");
|
|
19878
|
+
return {
|
|
19879
|
+
category: "branch_safety",
|
|
19880
|
+
title: "Branch Safety & Protected Branch Enforcement",
|
|
19881
|
+
status: hasFail ? "fail" : findings.length > 0 ? "warn" : "pass",
|
|
19882
|
+
findings
|
|
19883
|
+
};
|
|
19884
|
+
}
|
|
19885
|
+
};
|
|
19886
|
+
function hasArtifacts(dirPath) {
|
|
19887
|
+
return fs11__namespace.existsSync(dirPath) && fs11__namespace.readdirSync(dirPath).length > 0;
|
|
19888
|
+
}
|
|
19889
|
+
var SchemasPdacHealthCheck = class {
|
|
19890
|
+
async inspect(options) {
|
|
19891
|
+
const findings = [];
|
|
19892
|
+
const rootDir = options.rootDir || process.cwd();
|
|
19893
|
+
const ok = hasArtifacts(path13__namespace.join(rootDir, "schemas")) && hasArtifacts(path13__namespace.join(rootDir, "specs"));
|
|
19894
|
+
if (!ok) {
|
|
19895
|
+
findings.push({
|
|
19896
|
+
id: "ERR_SCHEMAS_DESYNCHRONIZED",
|
|
19897
|
+
category: "schemas_pdac",
|
|
19898
|
+
status: "fail",
|
|
19899
|
+
message: "Project schemas or specs directories are missing, empty, or uninitialized.",
|
|
19900
|
+
remediation: 'Run "aisdlc init" or "aisdlc check --fix" to generate canonical schemas and PDaC specifications.'
|
|
19901
|
+
});
|
|
19902
|
+
}
|
|
19903
|
+
return {
|
|
19904
|
+
category: "schemas_pdac",
|
|
19905
|
+
title: "Schemas & Product Definition as Code (PDaC) Consistency",
|
|
19906
|
+
status: findings.length > 0 ? "fail" : "pass",
|
|
19907
|
+
findings
|
|
19908
|
+
};
|
|
19909
|
+
}
|
|
19910
|
+
};
|
|
19911
|
+
|
|
19912
|
+
// src/doctor/toolchain-check.ts
|
|
19913
|
+
var TOOLS = [
|
|
19914
|
+
{ name: "node", flag: "--version" },
|
|
19915
|
+
{ name: "pnpm", flag: "--version" },
|
|
19916
|
+
{ name: "git", flag: "--version" }
|
|
19917
|
+
];
|
|
19918
|
+
function buildWarning(name, stderr) {
|
|
19919
|
+
return {
|
|
19920
|
+
id: `WARN_TOOLCHAIN_${name.toUpperCase()}_ISSUE`,
|
|
19921
|
+
category: "toolchain",
|
|
19922
|
+
status: "warn",
|
|
19923
|
+
message: `Toolchain binary '${name}' exited with error or returned empty output.`,
|
|
19924
|
+
details: { stderr }
|
|
19925
|
+
};
|
|
19926
|
+
}
|
|
19927
|
+
function buildError(name, err) {
|
|
19928
|
+
return {
|
|
19929
|
+
id: `ERR_TOOLCHAIN_${name.toUpperCase()}_MISSING`,
|
|
19930
|
+
category: "toolchain",
|
|
19931
|
+
status: "fail",
|
|
19932
|
+
message: `Toolchain binary '${name}' is missing: ${err instanceof Error ? err.message : String(err)}`,
|
|
19933
|
+
remediation: `Ensure '${name}' is installed and in PATH.`
|
|
19934
|
+
};
|
|
19935
|
+
}
|
|
19936
|
+
async function probeTool(runner, rootDir, tool) {
|
|
19937
|
+
try {
|
|
19938
|
+
const res = await runner.execSafe(tool.name, [tool.flag], { cwd: rootDir });
|
|
19939
|
+
return res.exitCode === 0 && res.stdout.trim() ? null : buildWarning(tool.name, res.stderr);
|
|
19940
|
+
} catch (err) {
|
|
19941
|
+
return buildError(tool.name, err);
|
|
19942
|
+
}
|
|
19943
|
+
}
|
|
19944
|
+
var ToolchainHealthCheck = class {
|
|
19945
|
+
runner;
|
|
19946
|
+
constructor(runner) {
|
|
19947
|
+
this.runner = runner || new SafeProcessRunnerAdapter();
|
|
19948
|
+
}
|
|
19949
|
+
async inspect(options) {
|
|
19950
|
+
const findings = [];
|
|
19951
|
+
const rootDir = options.rootDir || process.cwd();
|
|
19952
|
+
for (const tool of TOOLS) {
|
|
19953
|
+
const f = await probeTool(this.runner, rootDir, tool);
|
|
19954
|
+
if (f) findings.push(f);
|
|
19955
|
+
}
|
|
19956
|
+
const hasFail = findings.some((f) => f.status === "fail");
|
|
19957
|
+
return {
|
|
19958
|
+
category: "toolchain",
|
|
19959
|
+
title: "Toolchain (Node, PNPM, Git) Availability & Versions",
|
|
19960
|
+
status: hasFail ? "fail" : findings.length > 0 ? "warn" : "pass",
|
|
19961
|
+
findings
|
|
19962
|
+
};
|
|
19963
|
+
}
|
|
19964
|
+
};
|
|
19965
|
+
|
|
19966
|
+
// src/doctor/signature-check.ts
|
|
19967
|
+
async function checkLocalKey(runner, rootDir) {
|
|
19968
|
+
try {
|
|
19969
|
+
const res = await runner.execSafe("git", ["config", "--get", "user.signingkey"], { cwd: rootDir });
|
|
19970
|
+
const key = (res.stdout || "").trim();
|
|
19971
|
+
if (key) {
|
|
19972
|
+
return {
|
|
19973
|
+
id: "INFO_SIGNING_KEY_DETECTED",
|
|
19974
|
+
category: "signing_readiness",
|
|
19975
|
+
status: "pass",
|
|
19976
|
+
message: `Signing key configured: ${sanitizeDlpText(key).sanitizedText}`
|
|
19977
|
+
};
|
|
19978
|
+
}
|
|
19979
|
+
} catch {
|
|
19980
|
+
}
|
|
19981
|
+
return {
|
|
19982
|
+
id: "WARN_LOCAL_KEY_MISSING",
|
|
19983
|
+
category: "signing_readiness",
|
|
19984
|
+
status: "warn",
|
|
19985
|
+
message: "No local GPG or SSH signing key configured in git config (user.signingkey).",
|
|
19986
|
+
remediation: "Configure git signing key: git config user.signingkey <key-id>"
|
|
19987
|
+
};
|
|
19988
|
+
}
|
|
19989
|
+
async function checkRemoteEndpoint(runner, rootDir, timeoutMs) {
|
|
19990
|
+
try {
|
|
19991
|
+
const res = await runner.execSafe("git", ["ls-remote", "--get-url"], {
|
|
19992
|
+
cwd: rootDir,
|
|
19993
|
+
timeout: Math.min(timeoutMs, 2e3)
|
|
19994
|
+
});
|
|
19995
|
+
if (res.exitCode === 0) return null;
|
|
19996
|
+
return {
|
|
19997
|
+
id: "WARN_REMOTE_CHECK_UNAVAILABLE",
|
|
19998
|
+
category: "signing_readiness",
|
|
19999
|
+
status: "warn",
|
|
20000
|
+
message: "Remote repository or signing endpoint could not be reached."
|
|
20001
|
+
};
|
|
20002
|
+
} catch {
|
|
20003
|
+
return {
|
|
20004
|
+
id: "ERR_NETWORK_PROBE_TIMEOUT",
|
|
20005
|
+
category: "signing_readiness",
|
|
20006
|
+
status: "warn",
|
|
20007
|
+
message: "Remote network probe timed out or failed."
|
|
20008
|
+
};
|
|
20009
|
+
}
|
|
20010
|
+
}
|
|
20011
|
+
function sanitizeFinding(f) {
|
|
20012
|
+
f.message = sanitizeDlpText(f.message).sanitizedText;
|
|
20013
|
+
if (!f.details) return;
|
|
20014
|
+
for (const [k, v] of Object.entries(f.details)) {
|
|
20015
|
+
if (typeof v === "string") {
|
|
20016
|
+
f.details[k] = sanitizeDlpText(v).sanitizedText;
|
|
20017
|
+
}
|
|
20018
|
+
}
|
|
20019
|
+
}
|
|
20020
|
+
var SignatureReadinessCheck = class {
|
|
20021
|
+
runner;
|
|
20022
|
+
constructor(runner) {
|
|
20023
|
+
this.runner = runner || new SafeProcessRunnerAdapter();
|
|
20024
|
+
}
|
|
20025
|
+
async inspect(options) {
|
|
20026
|
+
const findings = [];
|
|
20027
|
+
const rootDir = options.rootDir || process.cwd();
|
|
20028
|
+
const isOffline = options.offline || process.env.AI_SDLC_OFFLINE === "1";
|
|
20029
|
+
findings.push(await checkLocalKey(this.runner, rootDir));
|
|
20030
|
+
if (!isOffline) {
|
|
20031
|
+
const remoteFinding = await checkRemoteEndpoint(this.runner, rootDir, options.timeout ?? 2e3);
|
|
20032
|
+
if (remoteFinding) findings.push(remoteFinding);
|
|
20033
|
+
}
|
|
20034
|
+
for (const f of findings) {
|
|
20035
|
+
sanitizeFinding(f);
|
|
20036
|
+
}
|
|
20037
|
+
const hasFail = findings.some((f) => f.status === "fail");
|
|
20038
|
+
const hasWarn = findings.some((f) => f.status === "warn");
|
|
20039
|
+
return {
|
|
20040
|
+
category: "signing_readiness",
|
|
20041
|
+
title: "Cryptographic Signing Readiness & Key Integrity",
|
|
20042
|
+
status: hasFail ? "fail" : hasWarn ? "warn" : "pass",
|
|
20043
|
+
findings
|
|
20044
|
+
};
|
|
20045
|
+
}
|
|
20046
|
+
};
|
|
20047
|
+
|
|
20048
|
+
// src/doctor/reporter.ts
|
|
20049
|
+
function formatFinding(f) {
|
|
20050
|
+
const icon = f.status === "pass" ? "\u2139\uFE0F" : f.status === "warn" ? "\u26A0\uFE0F" : "\u274C";
|
|
20051
|
+
const out = [` ${icon} [${f.id}] ${f.message}`];
|
|
20052
|
+
if (f.remediation) {
|
|
20053
|
+
out.push(` Remediation: ${f.remediation}`);
|
|
20054
|
+
}
|
|
20055
|
+
return out;
|
|
20056
|
+
}
|
|
20057
|
+
function formatCategory(cat) {
|
|
20058
|
+
const icon = cat.status === "pass" ? "\u2705" : cat.status === "warn" ? "\u26A0\uFE0F" : "\u274C";
|
|
20059
|
+
const out = [`${icon} [${cat.category.toUpperCase()}] ${cat.title}`];
|
|
20060
|
+
if (cat.findings.length === 0) {
|
|
20061
|
+
out.push(" No issues detected.");
|
|
20062
|
+
} else {
|
|
20063
|
+
for (const f of cat.findings) {
|
|
20064
|
+
out.push(...formatFinding(f));
|
|
20065
|
+
}
|
|
20066
|
+
}
|
|
20067
|
+
out.push("");
|
|
20068
|
+
return out;
|
|
20069
|
+
}
|
|
20070
|
+
var DoctorReporter = class {
|
|
20071
|
+
formatTerminal(report) {
|
|
20072
|
+
const icon = report.overallStatus === "pass" ? "\u2705" : report.overallStatus === "warn" ? "\u26A0\uFE0F" : "\u274C";
|
|
20073
|
+
const lines = [
|
|
20074
|
+
"\n=== AI-SDLC Doctor Environment Diagnostics ===",
|
|
20075
|
+
`Timestamp: ${report.timestamp}`,
|
|
20076
|
+
`Overall Status: ${icon} ${report.overallStatus.toUpperCase()} (Exit Code: ${report.exitCode})
|
|
20077
|
+
`
|
|
20078
|
+
];
|
|
20079
|
+
for (const cat of report.categories) {
|
|
20080
|
+
lines.push(...formatCategory(cat));
|
|
20081
|
+
}
|
|
20082
|
+
if (report.remediations.length > 0) {
|
|
20083
|
+
lines.push("=== Suggested Remediations ===");
|
|
20084
|
+
for (const rem of report.remediations) {
|
|
20085
|
+
lines.push(`- ${rem}`);
|
|
20086
|
+
}
|
|
20087
|
+
lines.push("");
|
|
20088
|
+
}
|
|
20089
|
+
return lines.join("\n");
|
|
20090
|
+
}
|
|
20091
|
+
formatJson(report) {
|
|
20092
|
+
return JSON.stringify(report, null, 2);
|
|
20093
|
+
}
|
|
20094
|
+
};
|
|
20095
|
+
|
|
20096
|
+
// src/doctor/doctor-service.ts
|
|
20097
|
+
var DoctorOrchestrator = class {
|
|
20098
|
+
hooksCheck = new GitHooksHealthCheck();
|
|
20099
|
+
branchCheck = new BranchSafetyCheck();
|
|
20100
|
+
schemasCheck = new SchemasPdacHealthCheck();
|
|
20101
|
+
toolchainCheck = new ToolchainHealthCheck();
|
|
20102
|
+
signatureCheck = new SignatureReadinessCheck();
|
|
20103
|
+
async runAll(options) {
|
|
20104
|
+
const categories = [];
|
|
20105
|
+
categories.push(await this.hooksCheck.inspect(options));
|
|
20106
|
+
categories.push(await this.branchCheck.inspect(options));
|
|
20107
|
+
categories.push(await this.schemasCheck.inspect(options));
|
|
20108
|
+
categories.push(await this.toolchainCheck.inspect(options));
|
|
20109
|
+
categories.push(await this.signatureCheck.inspect(options));
|
|
20110
|
+
return categories;
|
|
20111
|
+
}
|
|
20112
|
+
};
|
|
20113
|
+
var DoctorService = class {
|
|
20114
|
+
orchestrator = new DoctorOrchestrator();
|
|
20115
|
+
async diagnose(options) {
|
|
20116
|
+
const categories = await this.runCategoryChecks(options);
|
|
20117
|
+
const remediations = this.collectRemediations(categories);
|
|
20118
|
+
let overallStatus = "pass";
|
|
20119
|
+
let exitCode = 0;
|
|
20120
|
+
const hasFail = categories.some((c) => c.status === "fail");
|
|
20121
|
+
const hasWarn = categories.some((c) => c.status === "warn");
|
|
20122
|
+
if (hasFail) {
|
|
20123
|
+
overallStatus = "fail";
|
|
20124
|
+
exitCode = 2;
|
|
20125
|
+
} else if (hasWarn) {
|
|
20126
|
+
overallStatus = "warn";
|
|
20127
|
+
exitCode = options.strict ? 2 : 1;
|
|
20128
|
+
}
|
|
20129
|
+
const report = {
|
|
20130
|
+
overallStatus,
|
|
20131
|
+
exitCode,
|
|
20132
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20133
|
+
categories,
|
|
20134
|
+
remediations
|
|
20135
|
+
};
|
|
20136
|
+
return sanitizeDlpPayload(report);
|
|
20137
|
+
}
|
|
20138
|
+
async runCategoryChecks(options) {
|
|
20139
|
+
return this.orchestrator.runAll(options);
|
|
20140
|
+
}
|
|
20141
|
+
collectRemediations(categories) {
|
|
20142
|
+
const rems = /* @__PURE__ */ new Set();
|
|
20143
|
+
for (const cat of categories) {
|
|
20144
|
+
for (const finding of cat.findings) {
|
|
20145
|
+
if (finding.remediation) {
|
|
20146
|
+
rems.add(finding.remediation);
|
|
20147
|
+
}
|
|
20148
|
+
}
|
|
20149
|
+
}
|
|
20150
|
+
return Array.from(rems);
|
|
20151
|
+
}
|
|
20152
|
+
};
|
|
20153
|
+
var GOVERNED_DIR_PREFIXES = ["schemas" + path13__namespace.sep, "templates" + path13__namespace.sep, ".backup" + path13__namespace.sep];
|
|
20154
|
+
var GOVERNED_ROOT_FILES = /* @__PURE__ */ new Set([
|
|
20155
|
+
"quality-policy.yaml",
|
|
20156
|
+
"license-policy.yaml",
|
|
20157
|
+
"privacy-policy.yaml",
|
|
20158
|
+
"dlp-policy.yaml"
|
|
20159
|
+
]);
|
|
20160
|
+
function validateRawInputs(repoRoot, targetPath) {
|
|
20161
|
+
if (!repoRoot) {
|
|
20162
|
+
throw new Error("ERR_PATH_TRAVERSAL_DETECTED: repoRoot is required");
|
|
20163
|
+
}
|
|
20164
|
+
if (!targetPath || typeof targetPath !== "string" || targetPath.includes("\0")) {
|
|
20165
|
+
throw new Error("ERR_PATH_TRAVERSAL_DETECTED: targetPath is invalid or contains null byte");
|
|
20166
|
+
}
|
|
20167
|
+
}
|
|
20168
|
+
function checkSiblingAndEscape(resolvedRoot, resolvedTarget) {
|
|
20169
|
+
const rel = path13__namespace.relative(resolvedRoot, resolvedTarget);
|
|
20170
|
+
const escapes = rel.startsWith("..") || path13__namespace.isAbsolute(rel);
|
|
20171
|
+
if (escapes) {
|
|
20172
|
+
if (resolvedTarget.startsWith(resolvedRoot) && !resolvedTarget.startsWith(resolvedRoot + path13__namespace.sep)) {
|
|
20173
|
+
throw new Error("ERR_PATH_OUTSIDE_REPO_ROOT: Target path points to sibling directory");
|
|
20174
|
+
}
|
|
20175
|
+
throw new Error("ERR_PATH_TRAVERSAL_DETECTED: Target path escapes repository root");
|
|
20176
|
+
}
|
|
20177
|
+
if (resolvedTarget !== resolvedRoot && !resolvedTarget.startsWith(resolvedRoot + path13__namespace.sep)) {
|
|
20178
|
+
throw new Error("ERR_PATH_OUTSIDE_REPO_ROOT: Target path is outside repository root");
|
|
20179
|
+
}
|
|
20180
|
+
}
|
|
20181
|
+
function resolveRealRoot(resolvedRoot) {
|
|
20182
|
+
try {
|
|
20183
|
+
return fs11__namespace.existsSync(resolvedRoot) ? fs11__namespace.realpathSync(resolvedRoot) : resolvedRoot;
|
|
20184
|
+
} catch {
|
|
20185
|
+
return resolvedRoot;
|
|
20186
|
+
}
|
|
20187
|
+
}
|
|
20188
|
+
function checkSymlinkEscapesRealRoot(rootReal, absoluteTarget) {
|
|
20189
|
+
if (!fs11__namespace.existsSync(absoluteTarget)) return;
|
|
20190
|
+
try {
|
|
20191
|
+
const lstat = fs11__namespace.lstatSync(absoluteTarget);
|
|
20192
|
+
if (!lstat.isSymbolicLink()) return;
|
|
20193
|
+
const real = fs11__namespace.realpathSync(absoluteTarget);
|
|
20194
|
+
const rel = path13__namespace.relative(rootReal, real);
|
|
20195
|
+
const isEscaping = rel.startsWith("..") || path13__namespace.isAbsolute(rel) || real !== rootReal && !real.startsWith(rootReal + path13__namespace.sep);
|
|
20196
|
+
if (isEscaping) {
|
|
20197
|
+
throw new Error("ERR_SYMLINK_ESCAPE_DETECTED: Symlink targets path outside repository root");
|
|
20198
|
+
}
|
|
20199
|
+
} catch (err) {
|
|
20200
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
20201
|
+
if (errorMsg.includes("ERR_SYMLINK_ESCAPE_DETECTED")) {
|
|
20202
|
+
throw err;
|
|
20203
|
+
}
|
|
20204
|
+
}
|
|
20205
|
+
}
|
|
20206
|
+
var FileSystemJailAdapter = class {
|
|
20207
|
+
resolveSafe(repoRoot, targetPath) {
|
|
20208
|
+
validateRawInputs(repoRoot, targetPath);
|
|
20209
|
+
const resolvedRoot = path13__namespace.resolve(repoRoot);
|
|
20210
|
+
const resolvedTarget = path13__namespace.resolve(resolvedRoot, targetPath);
|
|
20211
|
+
checkSiblingAndEscape(resolvedRoot, resolvedTarget);
|
|
20212
|
+
return resolvedTarget;
|
|
20213
|
+
}
|
|
20214
|
+
async readFileSafe(repoRoot, relativePath) {
|
|
20215
|
+
const safePath = this.resolveSafe(repoRoot, relativePath);
|
|
20216
|
+
await this.verifySymlinkSafe(repoRoot, safePath);
|
|
20217
|
+
return fs11__namespace.promises.readFile(safePath, "utf-8");
|
|
20218
|
+
}
|
|
20219
|
+
async writeFileSafe(repoRoot, relativePath, content) {
|
|
20220
|
+
const safePath = this.resolveSafe(repoRoot, relativePath);
|
|
20221
|
+
await this.verifySymlinkSafe(repoRoot, safePath);
|
|
20222
|
+
const resolvedRoot = path13__namespace.resolve(repoRoot);
|
|
20223
|
+
const rel = path13__namespace.relative(resolvedRoot, safePath);
|
|
20224
|
+
const isGovernedDir = GOVERNED_DIR_PREFIXES.some((p) => rel.startsWith(p) || rel === p.slice(0, -1));
|
|
20225
|
+
const isGovernedFile = GOVERNED_ROOT_FILES.has(rel) || rel.startsWith(".backup" + path13__namespace.sep);
|
|
20226
|
+
if (!isGovernedDir && !isGovernedFile) {
|
|
20227
|
+
throw new Error(`ERR_UNGOVERNED_TARGET_PATH: Path "${rel}" is not an allowed governed directory or policy file`);
|
|
20228
|
+
}
|
|
20229
|
+
const dir = path13__namespace.dirname(safePath);
|
|
20230
|
+
if (!fs11__namespace.existsSync(dir)) {
|
|
20231
|
+
fs11__namespace.mkdirSync(dir, { recursive: true });
|
|
20232
|
+
}
|
|
20233
|
+
await fs11__namespace.promises.writeFile(safePath, content, "utf-8");
|
|
20234
|
+
}
|
|
20235
|
+
async existsSafe(repoRoot, relativePath) {
|
|
20236
|
+
const safePath = this.resolveSafe(repoRoot, relativePath);
|
|
20237
|
+
return fs11__namespace.existsSync(safePath);
|
|
20238
|
+
}
|
|
20239
|
+
async ensureDirectorySafe(repoRoot, relativeDir) {
|
|
20240
|
+
const safePath = this.resolveSafe(repoRoot, relativeDir);
|
|
20241
|
+
if (!fs11__namespace.existsSync(safePath)) {
|
|
20242
|
+
fs11__namespace.mkdirSync(safePath, { recursive: true });
|
|
20243
|
+
}
|
|
20244
|
+
}
|
|
20245
|
+
async isSymlinkSafe(repoRoot, relativePath) {
|
|
20246
|
+
const safePath = this.resolveSafe(repoRoot, relativePath);
|
|
20247
|
+
try {
|
|
20248
|
+
const stat = await fs11__namespace.promises.lstat(safePath);
|
|
20249
|
+
return stat.isSymbolicLink();
|
|
20250
|
+
} catch {
|
|
20251
|
+
return false;
|
|
20252
|
+
}
|
|
20253
|
+
}
|
|
20254
|
+
async verifySymlinkSafe(repoRoot, absoluteTarget) {
|
|
20255
|
+
const resolvedRoot = path13__namespace.resolve(repoRoot);
|
|
20256
|
+
const rootReal = resolveRealRoot(resolvedRoot);
|
|
20257
|
+
checkSymlinkEscapesRealRoot(rootReal, absoluteTarget);
|
|
20258
|
+
}
|
|
20259
|
+
};
|
|
20260
|
+
var DiffDetector = class {
|
|
20261
|
+
/**
|
|
20262
|
+
* Normalizes content by converting Windows CRLF (\r\n) to Unix LF (\n)
|
|
20263
|
+
* and computes a lowercase hex SHA-256 digest.
|
|
20264
|
+
*/
|
|
20265
|
+
computeDigest(content) {
|
|
20266
|
+
const normalized = content.replace(/\r\n/g, "\n");
|
|
20267
|
+
return crypto3__namespace.createHash("sha256").update(normalized, "utf-8").digest("hex");
|
|
20268
|
+
}
|
|
20269
|
+
/**
|
|
20270
|
+
* Compares two content strings for deterministic equality under LF normalization.
|
|
20271
|
+
*/
|
|
20272
|
+
isEqual(contentA, contentB) {
|
|
20273
|
+
return this.computeDigest(contentA) === this.computeDigest(contentB);
|
|
20274
|
+
}
|
|
20275
|
+
};
|
|
20276
|
+
|
|
20277
|
+
// src/migrate/override-analyzer.ts
|
|
20278
|
+
var OverrideAnalyzer = class {
|
|
20279
|
+
diffDetector = new DiffDetector();
|
|
20280
|
+
classify(input) {
|
|
20281
|
+
const { currentContent, targetContent, baseContent } = input;
|
|
20282
|
+
if (this.isCorruptDiscrepancy(currentContent)) {
|
|
20283
|
+
return "CONFLICT";
|
|
20284
|
+
}
|
|
20285
|
+
const currentEqualsTarget = this.diffDetector.isEqual(currentContent, targetContent);
|
|
20286
|
+
if (currentEqualsTarget) {
|
|
20287
|
+
return "UP_TO_DATE";
|
|
20288
|
+
}
|
|
20289
|
+
const currentEqualsBase = this.diffDetector.isEqual(currentContent, baseContent);
|
|
20290
|
+
if (currentEqualsBase) {
|
|
20291
|
+
return "CLEAN_UPDATE";
|
|
20292
|
+
}
|
|
20293
|
+
return "LOCAL_OVERRIDE_PRESERVED";
|
|
20294
|
+
}
|
|
20295
|
+
isCorruptDiscrepancy(content) {
|
|
20296
|
+
if (!content) return false;
|
|
20297
|
+
const trimmed = content.trim();
|
|
20298
|
+
if (trimmed.startsWith("corrupted: [invalid yaml")) {
|
|
20299
|
+
return true;
|
|
20300
|
+
}
|
|
20301
|
+
return false;
|
|
20302
|
+
}
|
|
20303
|
+
};
|
|
20304
|
+
|
|
20305
|
+
// src/migrate/policy-ratchet.ts
|
|
20306
|
+
function mergeCoverage(localCov, upstreamCov, allowDowngrade) {
|
|
20307
|
+
if (!localCov && !upstreamCov) return void 0;
|
|
20308
|
+
const result = { ...upstreamCov };
|
|
20309
|
+
const localMin = localCov?.min;
|
|
20310
|
+
const upstreamMin = upstreamCov?.min;
|
|
20311
|
+
if (localMin !== void 0 && upstreamMin !== void 0) {
|
|
20312
|
+
if (upstreamMin < localMin && allowDowngrade === false) {
|
|
20313
|
+
throw new Error("ERR_SECURITY_POLICY_DOWNGRADE_BLOCKED: Attempting to downgrade coverage threshold");
|
|
20314
|
+
}
|
|
20315
|
+
result.min = Math.max(localMin, upstreamMin);
|
|
20316
|
+
} else if (localMin !== void 0) {
|
|
20317
|
+
result.min = localMin;
|
|
20318
|
+
}
|
|
20319
|
+
return result;
|
|
20320
|
+
}
|
|
20321
|
+
function mergeComplexity(localComp, upstreamComp) {
|
|
20322
|
+
if (!localComp && !upstreamComp) return void 0;
|
|
20323
|
+
const result = { ...upstreamComp };
|
|
20324
|
+
const localCyclo = localComp?.maxCyclomatic;
|
|
20325
|
+
const upstreamCyclo = upstreamComp?.maxCyclomatic;
|
|
20326
|
+
if (localCyclo !== void 0 && upstreamCyclo !== void 0) {
|
|
20327
|
+
result.maxCyclomatic = Math.min(localCyclo, upstreamCyclo);
|
|
20328
|
+
} else if (localCyclo !== void 0) {
|
|
20329
|
+
result.maxCyclomatic = localCyclo;
|
|
20330
|
+
}
|
|
20331
|
+
return result;
|
|
20332
|
+
}
|
|
20333
|
+
function mergeLicenses(localLicenses, upstreamLicenses) {
|
|
20334
|
+
if (!localLicenses?.blocked && !upstreamLicenses?.blocked) return upstreamLicenses;
|
|
20335
|
+
const upstreamBlocked = (upstreamLicenses?.blocked || []).map((l) => l.toUpperCase());
|
|
20336
|
+
const localBlocked = (localLicenses?.blocked || []).map((l) => l.toUpperCase());
|
|
20337
|
+
return {
|
|
20338
|
+
...upstreamLicenses,
|
|
20339
|
+
blocked: Array.from(/* @__PURE__ */ new Set([...upstreamBlocked, ...localBlocked]))
|
|
20340
|
+
};
|
|
20341
|
+
}
|
|
20342
|
+
function mergeDlpRules(localRules, upstreamRules) {
|
|
20343
|
+
if (!localRules) return upstreamRules;
|
|
20344
|
+
const mergedRules = [...upstreamRules || []];
|
|
20345
|
+
const existingIds = new Set(mergedRules.map((r) => r.id));
|
|
20346
|
+
for (const rule of localRules) {
|
|
20347
|
+
if (!existingIds.has(rule.id)) {
|
|
20348
|
+
mergedRules.push(rule);
|
|
20349
|
+
existingIds.add(rule.id);
|
|
20350
|
+
}
|
|
20351
|
+
}
|
|
20352
|
+
return mergedRules;
|
|
20353
|
+
}
|
|
20354
|
+
function validateNumericField(val, fieldName) {
|
|
20355
|
+
if (val !== void 0 && (typeof val !== "number" || Number.isNaN(val))) {
|
|
20356
|
+
throw new Error(`ERR_INVALID_POLICY_FORMAT: ${fieldName} must be a valid number`);
|
|
20357
|
+
}
|
|
20358
|
+
}
|
|
20359
|
+
var PolicyRatchetEnforcer = class {
|
|
20360
|
+
enforceRatchet(localPolicy, upstreamPolicy, options = {}) {
|
|
20361
|
+
this.validatePolicyStructure(localPolicy);
|
|
20362
|
+
this.validatePolicyStructure(upstreamPolicy);
|
|
20363
|
+
if (options.allowPolicyDowngrade) {
|
|
20364
|
+
return JSON.parse(JSON.stringify(upstreamPolicy));
|
|
20365
|
+
}
|
|
20366
|
+
const merged = JSON.parse(JSON.stringify(upstreamPolicy));
|
|
20367
|
+
if (localPolicy.quality) {
|
|
20368
|
+
if (!merged.quality) merged.quality = {};
|
|
20369
|
+
merged.quality.coverage = mergeCoverage(localPolicy.quality.coverage, merged.quality.coverage, options.allowPolicyDowngrade);
|
|
20370
|
+
merged.quality.complexity = mergeComplexity(localPolicy.quality.complexity, merged.quality.complexity);
|
|
20371
|
+
}
|
|
20372
|
+
if (localPolicy.licenses) {
|
|
20373
|
+
merged.licenses = mergeLicenses(localPolicy.licenses, merged.licenses);
|
|
20374
|
+
}
|
|
20375
|
+
if (localPolicy.rules) {
|
|
20376
|
+
merged.rules = mergeDlpRules(localPolicy.rules, merged.rules);
|
|
20377
|
+
}
|
|
20378
|
+
return merged;
|
|
20379
|
+
}
|
|
20380
|
+
validatePolicyStructure(policy) {
|
|
20381
|
+
if (!policy || typeof policy !== "object") return;
|
|
20382
|
+
const q = policy.quality;
|
|
20383
|
+
if (q) {
|
|
20384
|
+
validateNumericField(q.coverage?.min, "coverage.min");
|
|
20385
|
+
validateNumericField(q.complexity?.maxCyclomatic, "complexity.maxCyclomatic");
|
|
20386
|
+
}
|
|
20387
|
+
}
|
|
20388
|
+
};
|
|
20389
|
+
var TimestampedBackupManagerAdapter = class {
|
|
20390
|
+
diffDetector = new DiffDetector();
|
|
20391
|
+
async createBackup(repoRoot, filesToBackup) {
|
|
20392
|
+
const resolvedRoot = path13__namespace.resolve(repoRoot);
|
|
20393
|
+
const gitignorePath = path13__namespace.join(resolvedRoot, ".gitignore");
|
|
20394
|
+
this.ensureGitignoreRule(gitignorePath);
|
|
20395
|
+
const timestamp = Date.now();
|
|
20396
|
+
const randomSuffix = crypto3__namespace.randomBytes(4).toString("hex").slice(0, 6);
|
|
20397
|
+
const backupDirName = `migration-${timestamp}-${randomSuffix}`;
|
|
20398
|
+
const backupRoot = path13__namespace.join(resolvedRoot, ".backup");
|
|
20399
|
+
const targetBackupDir = path13__namespace.join(backupRoot, backupDirName);
|
|
20400
|
+
fs11__namespace.mkdirSync(targetBackupDir, { recursive: true, mode: 448 });
|
|
20401
|
+
const manifestEntries = [];
|
|
20402
|
+
for (const relPath of filesToBackup) {
|
|
20403
|
+
const srcFile = path13__namespace.resolve(resolvedRoot, relPath);
|
|
20404
|
+
if (fs11__namespace.existsSync(srcFile)) {
|
|
20405
|
+
const destFile = path13__namespace.resolve(targetBackupDir, relPath);
|
|
20406
|
+
const destDir = path13__namespace.dirname(destFile);
|
|
20407
|
+
if (!fs11__namespace.existsSync(destDir)) {
|
|
20408
|
+
fs11__namespace.mkdirSync(destDir, { recursive: true });
|
|
20409
|
+
}
|
|
20410
|
+
const content = fs11__namespace.readFileSync(srcFile, "utf-8");
|
|
20411
|
+
fs11__namespace.writeFileSync(destFile, content, "utf-8");
|
|
20412
|
+
const digest = this.diffDetector.computeDigest(content);
|
|
20413
|
+
const stats = fs11__namespace.statSync(destFile);
|
|
20414
|
+
manifestEntries.push({
|
|
20415
|
+
path: relPath,
|
|
20416
|
+
sha256: digest,
|
|
20417
|
+
bytes: stats.size
|
|
20418
|
+
});
|
|
20419
|
+
}
|
|
20420
|
+
}
|
|
20421
|
+
const manifest = {
|
|
20422
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20423
|
+
files: manifestEntries
|
|
20424
|
+
};
|
|
20425
|
+
fs11__namespace.writeFileSync(
|
|
20426
|
+
path13__namespace.join(targetBackupDir, "manifest.json"),
|
|
20427
|
+
JSON.stringify(manifest, null, 2),
|
|
20428
|
+
"utf-8"
|
|
20429
|
+
);
|
|
20430
|
+
return targetBackupDir;
|
|
20431
|
+
}
|
|
20432
|
+
async restoreBackup(repoRoot, backupPath) {
|
|
20433
|
+
const resolvedRoot = path13__namespace.resolve(repoRoot);
|
|
20434
|
+
const manifestPath = path13__namespace.join(backupPath, "manifest.json");
|
|
20435
|
+
if (!fs11__namespace.existsSync(manifestPath)) {
|
|
20436
|
+
throw new Error(`ERR_BACKUP_MANIFEST_MISSING: Backup at ${backupPath} has no manifest.json`);
|
|
20437
|
+
}
|
|
20438
|
+
const manifest = JSON.parse(fs11__namespace.readFileSync(manifestPath, "utf-8"));
|
|
20439
|
+
for (const entry of manifest.files) {
|
|
20440
|
+
const backupFile = path13__namespace.join(backupPath, entry.path);
|
|
20441
|
+
const targetFile = path13__namespace.join(resolvedRoot, entry.path);
|
|
20442
|
+
if (fs11__namespace.existsSync(backupFile)) {
|
|
20443
|
+
const targetDir = path13__namespace.dirname(targetFile);
|
|
20444
|
+
if (!fs11__namespace.existsSync(targetDir)) {
|
|
20445
|
+
fs11__namespace.mkdirSync(targetDir, { recursive: true });
|
|
20446
|
+
}
|
|
20447
|
+
fs11__namespace.copyFileSync(backupFile, targetFile);
|
|
20448
|
+
}
|
|
20449
|
+
}
|
|
20450
|
+
}
|
|
20451
|
+
ensureGitignoreRule(gitignorePath) {
|
|
20452
|
+
if (fs11__namespace.existsSync(gitignorePath)) {
|
|
20453
|
+
const gitignore = fs11__namespace.readFileSync(gitignorePath, "utf-8");
|
|
20454
|
+
const lines = gitignore.split(/\r?\n/);
|
|
20455
|
+
const hasBackup = lines.some((l) => l.trim() === ".backup/" || l.trim() === ".backup" || l.trim() === "/.backup/");
|
|
20456
|
+
if (!hasBackup) {
|
|
20457
|
+
const trailingNewline = gitignore.endsWith("\n") ? "" : "\n";
|
|
20458
|
+
fs11__namespace.writeFileSync(gitignorePath, `${gitignore}${trailingNewline}.backup/
|
|
20459
|
+
`, "utf-8");
|
|
20460
|
+
}
|
|
20461
|
+
} else {
|
|
20462
|
+
fs11__namespace.writeFileSync(gitignorePath, ".backup/\n", "utf-8");
|
|
20463
|
+
}
|
|
20464
|
+
}
|
|
20465
|
+
};
|
|
20466
|
+
function copyFileSafeSync(src, dest) {
|
|
20467
|
+
const destDir = path13__namespace.dirname(dest);
|
|
20468
|
+
if (!fs11__namespace.existsSync(destDir)) {
|
|
20469
|
+
fs11__namespace.mkdirSync(destDir, { recursive: true });
|
|
20470
|
+
}
|
|
20471
|
+
fs11__namespace.copyFileSync(src, dest);
|
|
20472
|
+
}
|
|
20473
|
+
function restoreFromManifestSync(backupPath, resolvedRoot) {
|
|
20474
|
+
const manifestFile = path13__namespace.join(backupPath, "manifest.json");
|
|
20475
|
+
if (!fs11__namespace.existsSync(manifestFile)) return;
|
|
20476
|
+
try {
|
|
20477
|
+
const manifest = JSON.parse(fs11__namespace.readFileSync(manifestFile, "utf-8"));
|
|
20478
|
+
for (const entry of manifest.files || []) {
|
|
20479
|
+
const backedUpFile = path13__namespace.join(backupPath, entry.path);
|
|
20480
|
+
const targetFile = path13__namespace.join(resolvedRoot, entry.path);
|
|
20481
|
+
if (fs11__namespace.existsSync(backedUpFile)) {
|
|
20482
|
+
copyFileSafeSync(backedUpFile, targetFile);
|
|
20483
|
+
}
|
|
20484
|
+
}
|
|
20485
|
+
} catch {
|
|
20486
|
+
}
|
|
20487
|
+
}
|
|
20488
|
+
function restoreDirRecursiveSync(dir, resolvedRoot, baseBackupDir) {
|
|
20489
|
+
const entries = fs11__namespace.readdirSync(dir, { withFileTypes: true });
|
|
20490
|
+
for (const entry of entries) {
|
|
20491
|
+
const fullPath = path13__namespace.join(dir, entry.name);
|
|
20492
|
+
if (entry.isDirectory()) {
|
|
20493
|
+
restoreDirRecursiveSync(fullPath, resolvedRoot, baseBackupDir);
|
|
20494
|
+
} else if (entry.isFile()) {
|
|
20495
|
+
const rel = path13__namespace.relative(baseBackupDir, fullPath);
|
|
20496
|
+
copyFileSafeSync(fullPath, path13__namespace.join(resolvedRoot, rel));
|
|
20497
|
+
}
|
|
20498
|
+
}
|
|
20499
|
+
}
|
|
20500
|
+
var TransactionManager = class {
|
|
20501
|
+
activeStagingDir = null;
|
|
20502
|
+
stagedFiles = /* @__PURE__ */ new Map();
|
|
20503
|
+
boundSignalHandlers = {};
|
|
20504
|
+
async begin(repoRoot) {
|
|
20505
|
+
const resolvedRoot = path13__namespace.resolve(repoRoot);
|
|
20506
|
+
const stagingUuid = crypto3__namespace.randomUUID();
|
|
20507
|
+
const stagingDir = path13__namespace.join(resolvedRoot, ".backup", `.staging-${stagingUuid}`);
|
|
20508
|
+
fs11__namespace.mkdirSync(stagingDir, { recursive: true, mode: 448 });
|
|
20509
|
+
this.activeStagingDir = stagingDir;
|
|
20510
|
+
this.stagedFiles.clear();
|
|
20511
|
+
this.registerSignalHandlers(resolvedRoot);
|
|
20512
|
+
return stagingDir;
|
|
20513
|
+
}
|
|
20514
|
+
async stageFile(_repoRoot, relativePath, content) {
|
|
20515
|
+
if (!this.activeStagingDir) {
|
|
20516
|
+
throw new Error("ERR_NO_ACTIVE_TRANSACTION: Transaction must be started with begin()");
|
|
20517
|
+
}
|
|
20518
|
+
const stagedTarget = path13__namespace.join(this.activeStagingDir, relativePath);
|
|
20519
|
+
const stagedDir = path13__namespace.dirname(stagedTarget);
|
|
20520
|
+
if (!fs11__namespace.existsSync(stagedDir)) {
|
|
20521
|
+
fs11__namespace.mkdirSync(stagedDir, { recursive: true });
|
|
20522
|
+
}
|
|
20523
|
+
fs11__namespace.writeFileSync(stagedTarget, content, "utf-8");
|
|
20524
|
+
this.stagedFiles.set(relativePath, content);
|
|
20525
|
+
}
|
|
20526
|
+
async commit(repoRoot) {
|
|
20527
|
+
if (!this.activeStagingDir) {
|
|
20528
|
+
throw new Error("ERR_NO_ACTIVE_TRANSACTION: No transaction to commit");
|
|
20529
|
+
}
|
|
20530
|
+
const resolvedRoot = path13__namespace.resolve(repoRoot);
|
|
20531
|
+
try {
|
|
20532
|
+
for (const [relPath, content] of this.stagedFiles.entries()) {
|
|
20533
|
+
this.validateStagedFile(relPath, content);
|
|
20534
|
+
}
|
|
20535
|
+
for (const [relPath] of this.stagedFiles.entries()) {
|
|
20536
|
+
copyFileSafeSync(path13__namespace.join(this.activeStagingDir, relPath), path13__namespace.join(resolvedRoot, relPath));
|
|
20537
|
+
}
|
|
20538
|
+
this.cleanupStaging();
|
|
20539
|
+
} catch (err) {
|
|
20540
|
+
await this.rollback(repoRoot);
|
|
20541
|
+
throw err;
|
|
20542
|
+
} finally {
|
|
20543
|
+
this.unregisterSignalHandlers();
|
|
20544
|
+
}
|
|
20545
|
+
}
|
|
20546
|
+
async rollback(_repoRoot) {
|
|
20547
|
+
this.cleanupStaging();
|
|
20548
|
+
this.unregisterSignalHandlers();
|
|
20549
|
+
}
|
|
20550
|
+
rollbackSync(repoRoot, backupPath) {
|
|
20551
|
+
const resolvedRoot = path13__namespace.resolve(repoRoot);
|
|
20552
|
+
if (backupPath && fs11__namespace.existsSync(backupPath)) {
|
|
20553
|
+
const manifestFile = path13__namespace.join(backupPath, "manifest.json");
|
|
20554
|
+
if (fs11__namespace.existsSync(manifestFile)) {
|
|
20555
|
+
restoreFromManifestSync(backupPath, resolvedRoot);
|
|
20556
|
+
} else {
|
|
20557
|
+
restoreDirRecursiveSync(backupPath, resolvedRoot, backupPath);
|
|
20558
|
+
}
|
|
20559
|
+
}
|
|
20560
|
+
this.cleanupStaging();
|
|
20561
|
+
this.unregisterSignalHandlers();
|
|
20562
|
+
}
|
|
20563
|
+
validateStagedFile(relPath, content) {
|
|
20564
|
+
if (content.length === 0) {
|
|
20565
|
+
throw new Error(`ERR_MIGRATION_VALIDATION_FAILED: Staged file ${relPath} is empty`);
|
|
20566
|
+
}
|
|
20567
|
+
if (relPath.endsWith(".json")) {
|
|
20568
|
+
try {
|
|
20569
|
+
JSON.parse(content);
|
|
20570
|
+
} catch (e) {
|
|
20571
|
+
const errorMsg = e instanceof Error ? e.message : String(e);
|
|
20572
|
+
throw new Error(`ERR_MIGRATION_VALIDATION_FAILED: Invalid JSON in ${relPath}: ${errorMsg}`);
|
|
20573
|
+
}
|
|
20574
|
+
}
|
|
20575
|
+
}
|
|
20576
|
+
cleanupStaging() {
|
|
20577
|
+
if (this.activeStagingDir && fs11__namespace.existsSync(this.activeStagingDir)) {
|
|
20578
|
+
try {
|
|
20579
|
+
fs11__namespace.rmSync(this.activeStagingDir, { recursive: true, force: true });
|
|
20580
|
+
} catch {
|
|
20581
|
+
}
|
|
20582
|
+
}
|
|
20583
|
+
this.activeStagingDir = null;
|
|
20584
|
+
this.stagedFiles.clear();
|
|
20585
|
+
}
|
|
20586
|
+
registerSignalHandlers(repoRoot) {
|
|
20587
|
+
const signals = ["SIGINT", "SIGTERM"];
|
|
20588
|
+
for (const sig of signals) {
|
|
20589
|
+
const handler = () => {
|
|
20590
|
+
this.rollbackSync(repoRoot);
|
|
20591
|
+
process.exit(2);
|
|
20592
|
+
};
|
|
20593
|
+
this.boundSignalHandlers[sig] = handler;
|
|
20594
|
+
try {
|
|
20595
|
+
process.once(sig, handler);
|
|
20596
|
+
} catch {
|
|
20597
|
+
}
|
|
20598
|
+
}
|
|
20599
|
+
}
|
|
20600
|
+
unregisterSignalHandlers() {
|
|
20601
|
+
for (const sig of Object.keys(this.boundSignalHandlers)) {
|
|
20602
|
+
try {
|
|
20603
|
+
process.removeListener(sig, this.boundSignalHandlers[sig]);
|
|
20604
|
+
} catch {
|
|
20605
|
+
}
|
|
20606
|
+
}
|
|
20607
|
+
this.boundSignalHandlers = {};
|
|
20608
|
+
}
|
|
20609
|
+
};
|
|
20610
|
+
|
|
20611
|
+
// src/migrate/reporter.ts
|
|
20612
|
+
var MigrationReporter = class {
|
|
20613
|
+
formatTerminal(result) {
|
|
20614
|
+
const lines = [];
|
|
20615
|
+
lines.push("=== AI-SDLC Migration Report ===");
|
|
20616
|
+
lines.push(`Status: ${result.success ? "SUCCESS" : "FAILED"} (Exit Code: ${result.exitCode})`);
|
|
20617
|
+
lines.push(`Summary:`);
|
|
20618
|
+
lines.push(` - Up to date: ${result.summary.upToDate}`);
|
|
20619
|
+
lines.push(` - Clean updated: ${result.summary.cleanUpdated}`);
|
|
20620
|
+
lines.push(` - Local overrides preserved: ${result.summary.overridesPreserved}`);
|
|
20621
|
+
lines.push(` - Conflicts: ${result.summary.conflicts}`);
|
|
20622
|
+
if (result.backupPath) {
|
|
20623
|
+
lines.push(`Backup Location: ${result.backupPath}`);
|
|
20624
|
+
}
|
|
20625
|
+
if (result.details.length > 0) {
|
|
20626
|
+
lines.push("\nDetails:");
|
|
20627
|
+
for (const item of result.details) {
|
|
20628
|
+
lines.push(` [${item.status}] ${item.file}${item.message ? ` - ${item.message}` : ""}`);
|
|
20629
|
+
}
|
|
20630
|
+
}
|
|
20631
|
+
return lines.join("\n");
|
|
20632
|
+
}
|
|
20633
|
+
formatJson(result) {
|
|
20634
|
+
return JSON.stringify(result, null, 2);
|
|
20635
|
+
}
|
|
20636
|
+
};
|
|
20637
|
+
var MigrationOrchestrator = class {
|
|
20638
|
+
fsJail = new FileSystemJailAdapter();
|
|
20639
|
+
diffDetector = new DiffDetector();
|
|
20640
|
+
analyzer = new OverrideAnalyzer();
|
|
20641
|
+
ratchetEnforcer = new PolicyRatchetEnforcer();
|
|
20642
|
+
backupManager = new TimestampedBackupManagerAdapter();
|
|
20643
|
+
transactionManager = new TransactionManager();
|
|
20644
|
+
};
|
|
20645
|
+
function handleOverrideStatus(force) {
|
|
20646
|
+
return force ? { status: "CLEAN_UPDATE", message: "Overridden file updated due to --force flag", shouldModify: true, category: "cleanUpdated" } : { status: "LOCAL_OVERRIDE_PRESERVED", message: "Local customization retained (use --force to overwrite)", shouldModify: false, category: "overridesPreserved" };
|
|
20647
|
+
}
|
|
20648
|
+
function classifySingleItem(item, orchestrator, force) {
|
|
20649
|
+
const rawStatus = orchestrator.analyzer.classify({
|
|
20650
|
+
currentContent: item.currentContent,
|
|
20651
|
+
targetContent: item.targetContent,
|
|
20652
|
+
baseContent: item.baseContent
|
|
20653
|
+
});
|
|
20654
|
+
switch (rawStatus) {
|
|
20655
|
+
case "UP_TO_DATE":
|
|
20656
|
+
return { status: "UP_TO_DATE", shouldModify: false, category: "upToDate" };
|
|
20657
|
+
case "CLEAN_UPDATE":
|
|
20658
|
+
return { status: "CLEAN_UPDATE", shouldModify: true, category: "cleanUpdated" };
|
|
20659
|
+
case "LOCAL_OVERRIDE_PRESERVED":
|
|
20660
|
+
return handleOverrideStatus(force);
|
|
20661
|
+
default:
|
|
20662
|
+
return { status: "CONFLICT", message: "Structural conflict or syntax corruption detected", shouldModify: false, category: "conflicts" };
|
|
20663
|
+
}
|
|
20664
|
+
}
|
|
20665
|
+
function evaluateGovernedTargets(targets, orchestrator, force) {
|
|
20666
|
+
const summary = { upToDate: 0, cleanUpdated: 0, overridesPreserved: 0, conflicts: 0 };
|
|
20667
|
+
const details = [];
|
|
20668
|
+
const filesToModify = [];
|
|
20669
|
+
const filesToBackup = [];
|
|
20670
|
+
for (const item of targets) {
|
|
20671
|
+
const outcome = classifySingleItem(item, orchestrator, force);
|
|
20672
|
+
summary[outcome.category]++;
|
|
20673
|
+
details.push({
|
|
20674
|
+
file: item.relPath,
|
|
20675
|
+
category: item.category,
|
|
20676
|
+
status: outcome.status,
|
|
20677
|
+
currentDigest: item.currentContent ? orchestrator.diffDetector.computeDigest(item.currentContent) : void 0,
|
|
20678
|
+
targetDigest: item.targetContent ? orchestrator.diffDetector.computeDigest(item.targetContent) : void 0,
|
|
20679
|
+
message: outcome.message
|
|
20680
|
+
});
|
|
20681
|
+
if (outcome.shouldModify) {
|
|
20682
|
+
filesToModify.push({ relPath: item.relPath, content: item.targetContent });
|
|
20683
|
+
filesToBackup.push(item.relPath);
|
|
20684
|
+
}
|
|
20685
|
+
}
|
|
20686
|
+
return { summary, details, filesToModify, filesToBackup };
|
|
20687
|
+
}
|
|
20688
|
+
function buildCanonicalMap() {
|
|
20689
|
+
const canonicalMap = /* @__PURE__ */ new Map();
|
|
20690
|
+
canonicalMap.set("quality-policy.yaml", { category: "policy", content: STARTER_QUALITY_POLICY });
|
|
20691
|
+
canonicalMap.set("license-policy.yaml", { category: "policy", content: STARTER_LICENSE_POLICY });
|
|
20692
|
+
canonicalMap.set("privacy-policy.yaml", { category: "policy", content: STARTER_PRIVACY_POLICY });
|
|
20693
|
+
for (const s of STARTER_SCHEMAS) {
|
|
20694
|
+
canonicalMap.set(s.relPath.replace(/\\/g, "/"), { category: "schema", content: s.content });
|
|
20695
|
+
}
|
|
20696
|
+
for (const t of STARTER_BASE_TEMPLATES) {
|
|
20697
|
+
canonicalMap.set(t.relPath.replace(/\\/g, "/"), { category: "template", content: t.content });
|
|
20698
|
+
}
|
|
20699
|
+
return canonicalMap;
|
|
20700
|
+
}
|
|
20701
|
+
function scanSchemasDir(schemasDir, canonicalMap) {
|
|
20702
|
+
const items = [];
|
|
20703
|
+
if (!fs11__namespace.existsSync(schemasDir)) return items;
|
|
20704
|
+
try {
|
|
20705
|
+
for (const f of fs11__namespace.readdirSync(schemasDir)) {
|
|
20706
|
+
if (f.endsWith(".json")) {
|
|
20707
|
+
const relPath = path13__namespace.join("schemas", f).replace(/\\/g, "/");
|
|
20708
|
+
const content = fs11__namespace.readFileSync(path13__namespace.join(schemasDir, f), "utf-8");
|
|
20709
|
+
const canonical = canonicalMap.get(relPath);
|
|
20710
|
+
const targetContent = canonical ? canonical.content : content;
|
|
20711
|
+
items.push({ relPath, category: "schema", currentContent: content, targetContent, baseContent: targetContent });
|
|
20712
|
+
}
|
|
20713
|
+
}
|
|
20714
|
+
} catch {
|
|
20715
|
+
}
|
|
20716
|
+
return items;
|
|
20717
|
+
}
|
|
20718
|
+
function resolveExitCode2(summary) {
|
|
20719
|
+
if (summary.conflicts > 0) return 2;
|
|
20720
|
+
if (summary.overridesPreserved > 0) return 1;
|
|
20721
|
+
return 0;
|
|
20722
|
+
}
|
|
20723
|
+
function createProtectedBranchError(errorMsg) {
|
|
20724
|
+
return {
|
|
20725
|
+
success: false,
|
|
20726
|
+
exitCode: 2,
|
|
20727
|
+
summary: { upToDate: 0, cleanUpdated: 0, overridesPreserved: 0, conflicts: 0 },
|
|
20728
|
+
details: [{ file: "workspace", category: "policy", status: "CONFLICT", message: errorMsg }]
|
|
20729
|
+
};
|
|
20730
|
+
}
|
|
20731
|
+
function createTransactionFailureResult(summary, backupPath, errorMsg) {
|
|
20732
|
+
return {
|
|
20733
|
+
success: false,
|
|
20734
|
+
exitCode: 2,
|
|
20735
|
+
summary,
|
|
20736
|
+
backupPath,
|
|
20737
|
+
details: [{ file: "transaction", category: "policy", status: "CONFLICT", message: errorMsg || "Transaction failed" }]
|
|
20738
|
+
};
|
|
20739
|
+
}
|
|
20740
|
+
var MigrationService = class {
|
|
20741
|
+
constructor(orchestrator = new MigrationOrchestrator()) {
|
|
20742
|
+
this.orchestrator = orchestrator;
|
|
20743
|
+
}
|
|
20744
|
+
orchestrator;
|
|
20745
|
+
async preview(options) {
|
|
20746
|
+
return this.executeMigration({ ...options, dryRun: true });
|
|
20747
|
+
}
|
|
20748
|
+
async migrate(options) {
|
|
20749
|
+
return this.executeMigration({ ...options, dryRun: options.dryRun ?? false });
|
|
20750
|
+
}
|
|
20751
|
+
isInsideGitRepository(repoRoot) {
|
|
20752
|
+
try {
|
|
20753
|
+
const out = child_process__namespace.execSync("git rev-parse --is-inside-work-tree", {
|
|
20754
|
+
cwd: repoRoot,
|
|
20755
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
20756
|
+
encoding: "utf-8"
|
|
20757
|
+
}).trim();
|
|
20758
|
+
return out === "true";
|
|
20759
|
+
} catch {
|
|
20760
|
+
return false;
|
|
20761
|
+
}
|
|
20762
|
+
}
|
|
20763
|
+
queryGitBranch(repoRoot) {
|
|
20764
|
+
try {
|
|
20765
|
+
const out = child_process__namespace.execSync("git symbolic-ref --short HEAD", { cwd: repoRoot, stdio: ["ignore", "pipe", "ignore"], encoding: "utf-8" }).trim();
|
|
20766
|
+
if (out) return out;
|
|
20767
|
+
} catch {
|
|
20768
|
+
}
|
|
20769
|
+
try {
|
|
20770
|
+
const out = child_process__namespace.execSync("git rev-parse --abbrev-ref HEAD", { cwd: repoRoot, stdio: ["ignore", "pipe", "ignore"], encoding: "utf-8" }).trim();
|
|
20771
|
+
if (out && out !== "HEAD") return out;
|
|
20772
|
+
} catch {
|
|
20773
|
+
}
|
|
20774
|
+
return null;
|
|
20775
|
+
}
|
|
20776
|
+
async detectBranch(repoRoot) {
|
|
20777
|
+
if (!this.isInsideGitRepository(repoRoot)) {
|
|
20778
|
+
return "non-git-workspace";
|
|
20779
|
+
}
|
|
20780
|
+
const localBranch = this.queryGitBranch(repoRoot);
|
|
20781
|
+
if (localBranch) return localBranch;
|
|
20782
|
+
return process.env.GITHUB_REF_NAME || process.env.CI_COMMIT_REF_NAME || null;
|
|
20783
|
+
}
|
|
20784
|
+
isProtectedBranch(branch) {
|
|
20785
|
+
return branch === "main" || branch === "master" || branch.startsWith("release/");
|
|
20786
|
+
}
|
|
20787
|
+
async verifyBranchSafety(root, branchOption) {
|
|
20788
|
+
const branch = branchOption || await this.detectBranch(root) || void 0;
|
|
20789
|
+
if (!branch) {
|
|
20790
|
+
return { ok: false, error: "ERR_PROTECTED_BRANCH_MIGRATION: Unable to determine Git branch in mutating migration" };
|
|
20791
|
+
}
|
|
20792
|
+
if (this.isProtectedBranch(branch)) {
|
|
20793
|
+
return { ok: false, branch, error: `ERR_PROTECTED_BRANCH_MIGRATION: Migration forbidden on protected branch "${branch}"` };
|
|
20794
|
+
}
|
|
20795
|
+
return { ok: true, branch };
|
|
20796
|
+
}
|
|
20797
|
+
async runMutationTransaction(root, evaluation, enableBackup) {
|
|
20798
|
+
let backupPath;
|
|
20799
|
+
if (enableBackup) {
|
|
20800
|
+
backupPath = await this.orchestrator.backupManager.createBackup(root, evaluation.filesToBackup);
|
|
20801
|
+
}
|
|
20802
|
+
await this.orchestrator.transactionManager.begin(root);
|
|
20803
|
+
try {
|
|
20804
|
+
for (const file of evaluation.filesToModify) {
|
|
20805
|
+
await this.orchestrator.transactionManager.stageFile(root, file.relPath, file.content);
|
|
20806
|
+
}
|
|
20807
|
+
await this.orchestrator.transactionManager.commit(root);
|
|
20808
|
+
return { success: true, backupPath };
|
|
20809
|
+
} catch (err) {
|
|
20810
|
+
if (backupPath) {
|
|
20811
|
+
this.orchestrator.transactionManager.rollbackSync(root, backupPath);
|
|
20812
|
+
}
|
|
20813
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
20814
|
+
return { success: false, backupPath, error: message };
|
|
20815
|
+
}
|
|
20816
|
+
}
|
|
20817
|
+
async executeMigration(options) {
|
|
20818
|
+
const root = path13__namespace.resolve(options.root || process.cwd());
|
|
20819
|
+
const isDryRun = Boolean(options.dryRun);
|
|
20820
|
+
if (!isDryRun) {
|
|
20821
|
+
const branchCheck = await this.verifyBranchSafety(root, options.branch);
|
|
20822
|
+
if (!branchCheck.ok) {
|
|
20823
|
+
return createProtectedBranchError(branchCheck.error);
|
|
20824
|
+
}
|
|
20825
|
+
}
|
|
20826
|
+
const targets = this.discoverGovernedFiles(root);
|
|
20827
|
+
const evaluation = evaluateGovernedTargets(targets, this.orchestrator, options.force);
|
|
20828
|
+
if (isDryRun || evaluation.filesToModify.length === 0) {
|
|
20829
|
+
const exitCode2 = resolveExitCode2(evaluation.summary);
|
|
20830
|
+
return { success: exitCode2 === 0, exitCode: exitCode2, summary: evaluation.summary, details: evaluation.details };
|
|
20831
|
+
}
|
|
20832
|
+
const tx = await this.runMutationTransaction(root, evaluation, options.backup ?? true);
|
|
20833
|
+
if (!tx.success) {
|
|
20834
|
+
return createTransactionFailureResult(evaluation.summary, tx.backupPath, tx.error);
|
|
20835
|
+
}
|
|
20836
|
+
const exitCode = resolveExitCode2(evaluation.summary);
|
|
20837
|
+
return { success: exitCode === 0, exitCode, summary: evaluation.summary, backupPath: tx.backupPath, details: evaluation.details };
|
|
20838
|
+
}
|
|
20839
|
+
discoverGovernedFiles(root) {
|
|
20840
|
+
const items = [];
|
|
20841
|
+
const canonicalMap = buildCanonicalMap();
|
|
20842
|
+
const policyFiles = ["quality-policy.yaml", "license-policy.yaml", "privacy-policy.yaml", "dlp-policy.yaml"];
|
|
20843
|
+
for (const pf of policyFiles) {
|
|
20844
|
+
const fullPath = path13__namespace.join(root, pf);
|
|
20845
|
+
if (fs11__namespace.existsSync(fullPath)) {
|
|
20846
|
+
const content = fs11__namespace.readFileSync(fullPath, "utf-8");
|
|
20847
|
+
const canonical = canonicalMap.get(pf);
|
|
20848
|
+
const targetContent = canonical ? canonical.content : content;
|
|
20849
|
+
items.push({ relPath: pf, category: "policy", currentContent: content, targetContent, baseContent: targetContent });
|
|
20850
|
+
}
|
|
20851
|
+
}
|
|
20852
|
+
items.push(...scanSchemasDir(path13__namespace.join(root, "schemas"), canonicalMap));
|
|
20853
|
+
return items;
|
|
20854
|
+
}
|
|
20855
|
+
};
|
|
20856
|
+
|
|
19144
20857
|
exports.ALL_ARCHITECTURE_TEMPLATES = ALL_ARCHITECTURE_TEMPLATES;
|
|
20858
|
+
exports.ALL_QUALITY_GATES = ALL_QUALITY_GATES;
|
|
19145
20859
|
exports.BRANCH_PATTERNS = BRANCH_PATTERNS;
|
|
19146
20860
|
exports.BddStepRegistry = BddStepRegistry;
|
|
20861
|
+
exports.BranchSafetyCheck = BranchSafetyCheck;
|
|
19147
20862
|
exports.CPP_CLANG_TIDY = CPP_CLANG_TIDY;
|
|
19148
20863
|
exports.CPP_CMAKE_STRICT = CPP_CMAKE_STRICT;
|
|
19149
20864
|
exports.DEFAULT_DLP_RULES = DEFAULT_DLP_RULES;
|
|
@@ -19154,26 +20869,42 @@ exports.DEFAULT_EXTENSIONS = DEFAULT_EXTENSIONS;
|
|
|
19154
20869
|
exports.DEFAULT_PRIVACY_POLICY = DEFAULT_PRIVACY_POLICY;
|
|
19155
20870
|
exports.DEFAULT_SAST_EXCLUDES = DEFAULT_SAST_EXCLUDES;
|
|
19156
20871
|
exports.DOTNET_DIRECTORY_BUILD_PROPS = DOTNET_DIRECTORY_BUILD_PROPS;
|
|
20872
|
+
exports.DiffDetector = DiffDetector;
|
|
20873
|
+
exports.DlpSanitizer = DlpSanitizer;
|
|
20874
|
+
exports.DoctorOrchestrator = DoctorOrchestrator;
|
|
20875
|
+
exports.DoctorReporter = DoctorReporter;
|
|
20876
|
+
exports.DoctorService = DoctorService;
|
|
20877
|
+
exports.FileSystemJailAdapter = FileSystemJailAdapter;
|
|
19157
20878
|
exports.GENERAL_SOURCE_EXTENSIONS = GENERAL_SOURCE_EXTENSIONS;
|
|
19158
20879
|
exports.GHERKIN_GENERATOR_SPECS = GHERKIN_GENERATOR_SPECS;
|
|
19159
20880
|
exports.GO_GOLANGCI_YML = GO_GOLANGCI_YML;
|
|
19160
20881
|
exports.GRADLE_STRICT_INIT_KTS = GRADLE_STRICT_INIT_KTS;
|
|
20882
|
+
exports.GitHooksHealthCheck = GitHooksHealthCheck;
|
|
20883
|
+
exports.InTotoAttestationBuilder = InTotoAttestationBuilder;
|
|
19161
20884
|
exports.JAVA_PMD_RULESET_XML = JAVA_PMD_RULESET_XML;
|
|
19162
20885
|
exports.KOTLIN_DETEKT_YML = KOTLIN_DETEKT_YML;
|
|
19163
20886
|
exports.KPI_SUMMARY_END_TAG = KPI_SUMMARY_END_TAG;
|
|
19164
20887
|
exports.KPI_SUMMARY_START_TAG = KPI_SUMMARY_START_TAG;
|
|
19165
20888
|
exports.LIFECYCLE_SKILL_TEMPLATES = LIFECYCLE_SKILL_TEMPLATES;
|
|
20889
|
+
exports.MigrationOrchestrator = MigrationOrchestrator;
|
|
20890
|
+
exports.MigrationReporter = MigrationReporter;
|
|
20891
|
+
exports.MigrationService = MigrationService;
|
|
20892
|
+
exports.NativeFileSystemProbeAdapter = NativeFileSystemProbeAdapter;
|
|
19166
20893
|
exports.OpenSpecAdapter = OpenSpecAdapter;
|
|
20894
|
+
exports.OscalAssessmentBuilder = OscalAssessmentBuilder;
|
|
20895
|
+
exports.OverrideAnalyzer = OverrideAnalyzer;
|
|
19167
20896
|
exports.PII_SAST_RULES = PII_SAST_RULES;
|
|
19168
20897
|
exports.PREPARE_COMMIT_MSG_SCRIPT = PREPARE_COMMIT_MSG_SCRIPT;
|
|
19169
20898
|
exports.PRE_COMMIT_SCRIPT = PRE_COMMIT_SCRIPT;
|
|
19170
20899
|
exports.PROMPT_INJECTION_SIGNATURES = PROMPT_INJECTION_SIGNATURES;
|
|
19171
20900
|
exports.PROTECTED_BYPASS_PATTERNS = PROTECTED_BYPASS_PATTERNS;
|
|
19172
20901
|
exports.PROTECTED_CODING_RULES_FILES = PROTECTED_CODING_RULES_FILES;
|
|
20902
|
+
exports.PolicyRatchetEnforcer = PolicyRatchetEnforcer;
|
|
19173
20903
|
exports.REVIEWER_ROLES = REVIEWER_ROLES;
|
|
19174
20904
|
exports.REVIEW_VERDICTS = REVIEW_VERDICTS;
|
|
19175
20905
|
exports.RUST_CARGO_CONFIG_TOML = RUST_CARGO_CONFIG_TOML;
|
|
19176
20906
|
exports.RUST_CLIPPY_TOML = RUST_CLIPPY_TOML;
|
|
20907
|
+
exports.RegulatoryControlMapper = RegulatoryControlMapper;
|
|
19177
20908
|
exports.SARIF_SCHEMA_2_1_0 = SARIF_SCHEMA_2_1_0;
|
|
19178
20909
|
exports.SARIF_VERSION = SARIF_VERSION;
|
|
19179
20910
|
exports.SAST_RULES = SAST_RULES;
|
|
@@ -19294,10 +21025,16 @@ exports.STARTER_TEMPLATES_WORKFLOW_AGENT_HANDOFF_TEMPLATE_MD = STARTER_TEMPLATES
|
|
|
19294
21025
|
exports.STARTER_VSCODE_MCP = STARTER_VSCODE_MCP;
|
|
19295
21026
|
exports.STARTER_WORKFLOW_HANDOFF_TEMPLATE = STARTER_WORKFLOW_HANDOFF_TEMPLATE;
|
|
19296
21027
|
exports.STARTER__GITHUB_PULL_REQUEST_TEMPLATE_MD = STARTER__GITHUB_PULL_REQUEST_TEMPLATE_MD;
|
|
21028
|
+
exports.SafeProcessRunnerAdapter = SafeProcessRunnerAdapter;
|
|
21029
|
+
exports.SchemasPdacHealthCheck = SchemasPdacHealthCheck;
|
|
21030
|
+
exports.SignatureReadinessCheck = SignatureReadinessCheck;
|
|
19297
21031
|
exports.SpecKitAdapter = SpecKitAdapter;
|
|
19298
21032
|
exports.TS_ESLINT_CONFIG_MJS = TS_ESLINT_CONFIG_MJS;
|
|
19299
21033
|
exports.TS_STRICT_TSCONFIG = TS_STRICT_TSCONFIG;
|
|
19300
21034
|
exports.TYPE_TO_SCHEMA_MAP = TYPE_TO_SCHEMA_MAP;
|
|
21035
|
+
exports.TimestampedBackupManagerAdapter = TimestampedBackupManagerAdapter;
|
|
21036
|
+
exports.ToolchainHealthCheck = ToolchainHealthCheck;
|
|
21037
|
+
exports.TransactionManager = TransactionManager;
|
|
19301
21038
|
exports.UNIT_TEST_SUFFIXES = UNIT_TEST_SUFFIXES;
|
|
19302
21039
|
exports.VALID_AGENT_TARGETS = VALID_AGENT_TARGETS;
|
|
19303
21040
|
exports.VALID_ARCHITECTURE_GRANULARITIES = VALID_ARCHITECTURE_GRANULARITIES;
|
|
@@ -19316,11 +21053,13 @@ exports.buildCycloneDxComponent = buildCycloneDxComponent;
|
|
|
19316
21053
|
exports.buildCycloneDxVulnerabilities = buildCycloneDxVulnerabilities;
|
|
19317
21054
|
exports.buildFeatureFileContent = buildFeatureFileContent;
|
|
19318
21055
|
exports.buildGraphElements = buildGraphElements;
|
|
21056
|
+
exports.buildSafeEnvironment = buildSafeEnvironment;
|
|
19319
21057
|
exports.calculateJaccardSimilarity = calculateJaccardSimilarity;
|
|
19320
21058
|
exports.calculateMetrics = calculateMetrics;
|
|
19321
21059
|
exports.calculateRating = calculateRating;
|
|
19322
21060
|
exports.calculateShannonEntropy = calculateShannonEntropy;
|
|
19323
21061
|
exports.canonicalSort = canonicalSort;
|
|
21062
|
+
exports.canonicalizeJson = canonicalizeJson;
|
|
19324
21063
|
exports.checkGherkinInSync = checkGherkinInSync;
|
|
19325
21064
|
exports.checkoutTaskBranch = checkoutTaskBranch;
|
|
19326
21065
|
exports.classifyBranch = classifyBranch;
|
|
@@ -19372,6 +21111,8 @@ exports.formatPrKpiMarkdown = formatPrKpiMarkdown;
|
|
|
19372
21111
|
exports.formatReleaseKpiMarkdown = formatReleaseKpiMarkdown;
|
|
19373
21112
|
exports.formatTaskKpiRows = formatTaskKpiRows;
|
|
19374
21113
|
exports.generateBranchHierarchyPlan = generateBranchHierarchyPlan;
|
|
21114
|
+
exports.generateComplianceEvidenceBundle = generateComplianceEvidenceBundle;
|
|
21115
|
+
exports.generateComplianceEvidenceBundleSync = generateComplianceEvidenceBundleSync;
|
|
19375
21116
|
exports.generateCycloneDxSbom = generateCycloneDxSbom;
|
|
19376
21117
|
exports.generateDashboardReport = generateDashboardReport;
|
|
19377
21118
|
exports.generateDeterministicUuidV5 = generateDeterministicUuidV5;
|