@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.js
CHANGED
|
@@ -3,12 +3,28 @@ import * as fs11 from 'fs';
|
|
|
3
3
|
import * as path13 from 'path';
|
|
4
4
|
import yaml3 from 'js-yaml';
|
|
5
5
|
import * as child_process from 'child_process';
|
|
6
|
-
import { execFileSync, spawnSync } from 'child_process';
|
|
6
|
+
import { execFileSync, spawnSync, execSync, execFile } from 'child_process';
|
|
7
7
|
import { SyntaxKind, Project, Node } from 'ts-morph';
|
|
8
8
|
import Ajv2020 from 'ajv/dist/2020.js';
|
|
9
9
|
import addFormats from 'ajv-formats';
|
|
10
10
|
import { createRequire } from 'module';
|
|
11
11
|
|
|
12
|
+
// src/types/regulatory-compliance.ts
|
|
13
|
+
var ALL_QUALITY_GATES = [
|
|
14
|
+
"quality",
|
|
15
|
+
"traceability",
|
|
16
|
+
"governance",
|
|
17
|
+
"testing",
|
|
18
|
+
"gherkin",
|
|
19
|
+
"licenses",
|
|
20
|
+
"pdac",
|
|
21
|
+
"schemas",
|
|
22
|
+
"duplicates",
|
|
23
|
+
"security",
|
|
24
|
+
"privacy",
|
|
25
|
+
"friction"
|
|
26
|
+
];
|
|
27
|
+
|
|
12
28
|
// src/types/index.ts
|
|
13
29
|
var VALID_CHANGE_PROFILES = ["patch", "standard", "critical"];
|
|
14
30
|
var VALID_AUTONOMY_MODES = [
|
|
@@ -11783,7 +11799,7 @@ function formatPrKpiMarkdown(kpi) {
|
|
|
11783
11799
|
const modelHeaders = models.map((m) => `Agent (${m})`).join(" | ");
|
|
11784
11800
|
const modelSeparator = models.map(() => ":---:").join(" | ");
|
|
11785
11801
|
const headers = `| Metric | Human |${models.length > 0 ? ` ${modelHeaders} |` : ""} Total PR |`;
|
|
11786
|
-
const
|
|
11802
|
+
const sep3 = `| :--- | :---: |${models.length > 0 ? ` ${modelSeparator} |` : ""} :---: |`;
|
|
11787
11803
|
const rows = buildPrKpiRows(kpi, models);
|
|
11788
11804
|
const taskRowsList = formatTaskKpiRows(kpi.byTask);
|
|
11789
11805
|
return [
|
|
@@ -11791,7 +11807,7 @@ function formatPrKpiMarkdown(kpi) {
|
|
|
11791
11807
|
"### \u{1F4CA} AI-SDLC: Aggregated PR KPI Summary",
|
|
11792
11808
|
"",
|
|
11793
11809
|
headers,
|
|
11794
|
-
|
|
11810
|
+
sep3,
|
|
11795
11811
|
...rows,
|
|
11796
11812
|
...taskRowsList,
|
|
11797
11813
|
"",
|
|
@@ -14216,6 +14232,71 @@ function renderManualRow(m) {
|
|
|
14216
14232
|
`</tr>`
|
|
14217
14233
|
].join("");
|
|
14218
14234
|
}
|
|
14235
|
+
function renderIntotoCard(complianceBundle) {
|
|
14236
|
+
const verdict = complianceBundle.inTotoAttestation?.predicate?.verdict === "PASS" ? "PASS" : "FAIL";
|
|
14237
|
+
const badgeClass = verdict === "PASS" ? "badge-green" : "badge-rose";
|
|
14238
|
+
const rawSha = String(complianceBundle.inTotoAttestation?.predicate?.commitSha || "unknown");
|
|
14239
|
+
const shortSha = rawSha.slice(0, 7);
|
|
14240
|
+
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>`;
|
|
14241
|
+
}
|
|
14242
|
+
function renderRegulatoryFrameworkCards(complianceBundle) {
|
|
14243
|
+
const matrix = complianceBundle.regulatoryMatrix;
|
|
14244
|
+
const euCount = matrix?.euAiActCoverage?.length || 0;
|
|
14245
|
+
const isoCount = matrix?.iso42001Coverage?.length || 0;
|
|
14246
|
+
const nistCount = matrix?.nistSsdfCoverage?.length || 0;
|
|
14247
|
+
return [
|
|
14248
|
+
`<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>`,
|
|
14249
|
+
`<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>`,
|
|
14250
|
+
`<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>`
|
|
14251
|
+
].join("");
|
|
14252
|
+
}
|
|
14253
|
+
function renderComplianceCards(complianceBundle) {
|
|
14254
|
+
const intoto = renderIntotoCard(complianceBundle);
|
|
14255
|
+
const fw = renderRegulatoryFrameworkCards(complianceBundle);
|
|
14256
|
+
return `<div class="grid-cards">${intoto}${fw}</div>`;
|
|
14257
|
+
}
|
|
14258
|
+
function renderComplianceGateRow(gateId, mapping) {
|
|
14259
|
+
return [
|
|
14260
|
+
`<tr>`,
|
|
14261
|
+
` <td><strong><code>${escapeHtml(gateId)}</code></strong></td>`,
|
|
14262
|
+
` <td>${escapeHtml(mapping?.euAiAct || "\u2014")}</td>`,
|
|
14263
|
+
` <td>${escapeHtml(mapping?.iso42001 || "\u2014")}</td>`,
|
|
14264
|
+
` <td>${escapeHtml(mapping?.nistSsdf || "\u2014")}</td>`,
|
|
14265
|
+
` <td style="color: var(--text-muted); font-size: 0.8rem;">${escapeHtml(mapping?.description || "\u2014")}</td>`,
|
|
14266
|
+
`</tr>`
|
|
14267
|
+
].join("");
|
|
14268
|
+
}
|
|
14269
|
+
function renderComplianceTable(mappings) {
|
|
14270
|
+
const gateIds = Object.keys(mappings || {});
|
|
14271
|
+
if (gateIds.length === 0) {
|
|
14272
|
+
return '<p style="color: var(--text-muted); font-size: 0.85rem;">No hay mapeos de controles regulatorios disponibles.</p>';
|
|
14273
|
+
}
|
|
14274
|
+
const rows = gateIds.map((id) => renderComplianceGateRow(id, mappings[id])).join("\n");
|
|
14275
|
+
return [
|
|
14276
|
+
`<table class="data-table">`,
|
|
14277
|
+
` <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>`,
|
|
14278
|
+
` <tbody>${rows}</tbody>`,
|
|
14279
|
+
`</table>`
|
|
14280
|
+
].join("\n");
|
|
14281
|
+
}
|
|
14282
|
+
function renderComplianceSectionHtml(complianceBundle) {
|
|
14283
|
+
const cardsHtml = renderComplianceCards(complianceBundle);
|
|
14284
|
+
const tableHtml = renderComplianceTable(complianceBundle.regulatoryMatrix?.gateMappings || {});
|
|
14285
|
+
return [
|
|
14286
|
+
`<div class="compliance-section" style="margin-bottom: 24px;">`,
|
|
14287
|
+
` <div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;">`,
|
|
14288
|
+
` <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>`,
|
|
14289
|
+
` <span class="badge badge-blue">OSCAL & in-toto Attested</span>`,
|
|
14290
|
+
` </div>`,
|
|
14291
|
+
` <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>`,
|
|
14292
|
+
cardsHtml,
|
|
14293
|
+
` <div class="chart-container" style="margin-top: 16px;">`,
|
|
14294
|
+
` <h4>Mapeo de Cobertura de los 12 Quality Gates</h4>`,
|
|
14295
|
+
tableHtml,
|
|
14296
|
+
` </div>`,
|
|
14297
|
+
`</div>`
|
|
14298
|
+
].join("\n");
|
|
14299
|
+
}
|
|
14219
14300
|
function renderManualCardsHtml(coverage, allCount, userCount, prodCount) {
|
|
14220
14301
|
return [
|
|
14221
14302
|
`<div class="grid-cards">`,
|
|
@@ -14229,20 +14310,35 @@ function renderManualsDesc(manuals) {
|
|
|
14229
14310
|
const badgeClass = manuals.status === "PASSED" ? "badge-green" : manuals.status === "WARNING" ? "badge-amber" : "badge-rose";
|
|
14230
14311
|
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>.`;
|
|
14231
14312
|
}
|
|
14232
|
-
function
|
|
14313
|
+
function renderManualsHeader(manuals) {
|
|
14314
|
+
return [
|
|
14315
|
+
`<h2>Operational Manuals (User & Production)</h2>`,
|
|
14316
|
+
`<p style="font-size: 0.8rem; color: var(--text-muted);">${renderManualsDesc(manuals)}</p>`
|
|
14317
|
+
].join("\n");
|
|
14318
|
+
}
|
|
14319
|
+
function renderManualsTable(allManuals) {
|
|
14320
|
+
if (allManuals.length === 0) {
|
|
14321
|
+
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>';
|
|
14322
|
+
}
|
|
14323
|
+
const rows = allManuals.map(renderManualRow).join("");
|
|
14324
|
+
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>`;
|
|
14325
|
+
}
|
|
14326
|
+
function renderManualsTab(manuals, complianceBundle) {
|
|
14327
|
+
const complianceHtml = complianceBundle ? renderComplianceSectionHtml(complianceBundle) : "";
|
|
14233
14328
|
const findings = [...manuals.violations, ...manuals.warnings];
|
|
14234
14329
|
const allManuals = [...manuals.userManuals, ...manuals.productionManuals];
|
|
14235
14330
|
const findingsHtml = renderManualFindingsHtml(findings);
|
|
14236
|
-
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("");
|
|
14237
14331
|
const cardsHtml = renderManualCardsHtml(manuals.coverage, allManuals.length, manuals.userManuals.length, manuals.productionManuals.length);
|
|
14332
|
+
const headerHtml = renderManualsHeader(manuals);
|
|
14333
|
+
const tableHtml = renderManualsTable(allManuals);
|
|
14238
14334
|
return [
|
|
14239
|
-
|
|
14240
|
-
|
|
14335
|
+
complianceHtml,
|
|
14336
|
+
headerHtml,
|
|
14241
14337
|
cardsHtml,
|
|
14242
14338
|
`<div class="chart-container"><h3>Hallazgos de Cobertura</h3>${findingsHtml}</div>`,
|
|
14243
|
-
|
|
14339
|
+
tableHtml,
|
|
14244
14340
|
`<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>`
|
|
14245
|
-
].join("\n");
|
|
14341
|
+
].filter(Boolean).join("\n");
|
|
14246
14342
|
}
|
|
14247
14343
|
function renderBranchOption(b, activeBranch) {
|
|
14248
14344
|
const isAct = b === activeBranch ? " (Rama activa)" : "";
|
|
@@ -14423,7 +14519,7 @@ function renderDashboardMain(metricsData) {
|
|
|
14423
14519
|
const graphTab = renderGraphTabHtml();
|
|
14424
14520
|
const rtmTab = renderRtmTabHtml(metricsData.trace.rows);
|
|
14425
14521
|
const qualityTab = renderQualityTabHtml(metricsData);
|
|
14426
|
-
const manualsTab = `<div id="tab-manuals" class="tab-panel"><div class="content-container">${renderManualsTab(metricsData.manuals)}</div></div>`;
|
|
14522
|
+
const manualsTab = `<div id="tab-manuals" class="tab-panel"><div class="content-container">${renderManualsTab(metricsData.manuals, metricsData.complianceBundle)}</div></div>`;
|
|
14427
14523
|
const kpisTab = renderKpisTabHtml(metricsData);
|
|
14428
14524
|
return ` <main>
|
|
14429
14525
|
${graphTab}
|
|
@@ -14706,6 +14802,18 @@ function collectAllBranchTelemetries(rootDir, activeBranch, history, activePrKpi
|
|
|
14706
14802
|
const totalTelemetry = computeConsolidatedTelemetry(Array.from(uniqueCommits.values()), activePrKpi);
|
|
14707
14803
|
return { branchTelemetries, totalTelemetry };
|
|
14708
14804
|
}
|
|
14805
|
+
function loadComplianceBundleSafely(rootDir) {
|
|
14806
|
+
const bundlePath = path13.join(rootDir, "reports", "audit-evidence-bundle.json");
|
|
14807
|
+
if (!fs11.existsSync(bundlePath)) {
|
|
14808
|
+
return null;
|
|
14809
|
+
}
|
|
14810
|
+
try {
|
|
14811
|
+
const raw = fs11.readFileSync(bundlePath, "utf-8");
|
|
14812
|
+
return JSON.parse(raw);
|
|
14813
|
+
} catch {
|
|
14814
|
+
return null;
|
|
14815
|
+
}
|
|
14816
|
+
}
|
|
14709
14817
|
function collectDashboardMetrics(rootDir) {
|
|
14710
14818
|
const gate = verifyQualityGate({ rootDir });
|
|
14711
14819
|
const gov = verifyTasksGovernance({ rootDir });
|
|
@@ -14716,6 +14824,7 @@ function collectDashboardMetrics(rootDir) {
|
|
|
14716
14824
|
const activeBranch = resolveActiveBranch(rootDir);
|
|
14717
14825
|
const activePrKpi = resolveActivePrKpi(rootDir, activeBranch);
|
|
14718
14826
|
const codeCoverage = readCodeCoverageSummary(rootDir);
|
|
14827
|
+
const complianceBundle = loadComplianceBundleSafely(rootDir);
|
|
14719
14828
|
const { branchTelemetries, totalTelemetry } = collectAllBranchTelemetries(
|
|
14720
14829
|
rootDir,
|
|
14721
14830
|
activeBranch,
|
|
@@ -14733,7 +14842,8 @@ function collectDashboardMetrics(rootDir) {
|
|
|
14733
14842
|
activePrKpi,
|
|
14734
14843
|
activeBranch,
|
|
14735
14844
|
branchTelemetries,
|
|
14736
|
-
totalTelemetry
|
|
14845
|
+
totalTelemetry,
|
|
14846
|
+
complianceBundle
|
|
14737
14847
|
};
|
|
14738
14848
|
}
|
|
14739
14849
|
function computeSummaryRatios(metricsData) {
|
|
@@ -19111,6 +19221,1609 @@ function formatInspectResultMarkdown(result) {
|
|
|
19111
19221
|
return lines.join("\n");
|
|
19112
19222
|
}
|
|
19113
19223
|
|
|
19114
|
-
export { ALL_ARCHITECTURE_TEMPLATES, BRANCH_PATTERNS, BddStepRegistry, CPP_CLANG_TIDY, CPP_CMAKE_STRICT, DEFAULT_DLP_RULES, DEFAULT_EXCLUDED_PATTERNS, DEFAULT_EXCLUDES, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXTENSIONS, DEFAULT_PRIVACY_POLICY, DEFAULT_SAST_EXCLUDES, DOTNET_DIRECTORY_BUILD_PROPS, GENERAL_SOURCE_EXTENSIONS, GHERKIN_GENERATOR_SPECS, GO_GOLANGCI_YML, GRADLE_STRICT_INIT_KTS, JAVA_PMD_RULESET_XML, KOTLIN_DETEKT_YML, KPI_SUMMARY_END_TAG, KPI_SUMMARY_START_TAG, LIFECYCLE_SKILL_TEMPLATES, OpenSpecAdapter, PII_SAST_RULES, PREPARE_COMMIT_MSG_SCRIPT, PRE_COMMIT_SCRIPT, PROMPT_INJECTION_SIGNATURES, PROTECTED_BYPASS_PATTERNS, PROTECTED_CODING_RULES_FILES, REVIEWER_ROLES, REVIEW_VERDICTS, RUST_CARGO_CONFIG_TOML, RUST_CLIPPY_TOML, SARIF_SCHEMA_2_1_0, SARIF_VERSION, SAST_RULES, SCHEMA_SCHEMAS_ARCHITECTURE_ADR_SCHEMA_JSON, SCHEMA_SCHEMAS_ARCHITECTURE_COMPONENT_SCHEMA_JSON, SCHEMA_SCHEMAS_ARCHITECTURE_INTRODUCTION_AND_GOALS_SCHEMA_JSON, SCHEMA_SCHEMAS_COMPLIANCE_LICENSE_MANIFEST_SCHEMA_JSON, SCHEMA_SCHEMAS_COMPLIANCE_LICENSE_POLICY_SCHEMA_JSON, SCHEMA_SCHEMAS_COMPLIANCE_QUALITY_POLICY_SCHEMA_JSON, SCHEMA_SCHEMAS_IDE_MCP_CONFIG_SCHEMA_JSON, SCHEMA_SCHEMAS_MANUALS_PRODUCTION_MANUAL_SCHEMA_JSON, SCHEMA_SCHEMAS_MANUALS_USER_MANUAL_SCHEMA_JSON, SCHEMA_SCHEMAS_PRIVACY_DATA_ASSET_SCHEMA_JSON, SCHEMA_SCHEMAS_PRIVACY_PRIVACY_POLICY_SCHEMA_JSON, SCHEMA_SCHEMAS_PRIVACY_PRIVACY_REQ_SCHEMA_JSON, SCHEMA_SCHEMAS_PRIVACY_PRIVACY_ROPA_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_ACTOR_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_BOUNDED_CONTEXT_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_BUSINESS_RULE_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_JOURNEY_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_REQUIREMENT_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_TERM_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_USE_CASE_SCHEMA_JSON, SCHEMA_SCHEMAS_SAFETY_HAZARD_SCHEMA_JSON, SCHEMA_SCHEMAS_SAFETY_SAFETY_REQ_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_DESIGN_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_HANDOFF_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_PROPOSAL_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_RELEASE_KPIS_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_SESSION_TELEMETRY_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_SPEC_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_TASKS_SCHEMA_JSON, SCHEMA_SCHEMAS_SECURITY_ABUSE_CASE_SCHEMA_JSON, SCHEMA_SCHEMAS_SECURITY_ENCLAVE_SCHEMA_JSON, SCHEMA_SCHEMAS_SECURITY_SECURITY_REQ_SCHEMA_JSON, SCHEMA_SCHEMAS_SECURITY_THREAT_ACTOR_SCHEMA_JSON, SCHEMA_SCHEMAS_WORKFLOW_AGENT_HANDOFF_SCHEMA_JSON, SECRET_RULES, SPECIALIZED_AGENT_TEMPLATES, STARTER_AGENT_GUARD_WRAPPER_CJS, STARTER_ANTIGRAVITY_HOOKS_JSON, STARTER_ANTIGRAVITY_MCP, STARTER_ANTIGRAVITY_RULES, STARTER_ARCH_ADR, STARTER_ARCH_ARCHITECTURE_CONSTRAINTS, STARTER_ARCH_COMPONENT, STARTER_ARCH_CONTEXT_AND_SCOPE, STARTER_ARCH_CROSS_CUTTING_CONCEPTS, STARTER_ARCH_DEPLOYMENT_VIEW, STARTER_ARCH_GLOSSARY, STARTER_ARCH_INTRODUCTION_AND_GOALS, STARTER_ARCH_LEVEL_1_WHITEBOX, STARTER_ARCH_QUALITY_REQUIREMENTS, STARTER_ARCH_RISKS_AND_TECHNICAL_DEBT, STARTER_ARCH_RUNTIME_VIEW, STARTER_ARCH_SOLUTION_STRATEGY, STARTER_AZURE_PIPELINES, STARTER_BASE_TEMPLATES, STARTER_BITBUCKET_PIPELINES, STARTER_CLAUDE_RULES, STARTER_COMPLIANCE_LICENSE_MANIFEST_YAML, STARTER_COPILOT_RULES, STARTER_CURSOR_CORE_RULES, STARTER_CURSOR_MCP, STARTER_CURSOR_PRODUCT_RULES, STARTER_CURSOR_QUALITY_RULES, STARTER_GITHUB_CI, STARTER_GITHUB_DEPLOY_DASHBOARD, STARTER_GITHUB_PR_KPI, STARTER_GITHUB_PULL_REQUEST_TEMPLATE, STARTER_GITHUB_SDD_INTEGRATE, STARTER_GITLAB_CI, STARTER_GUARD_BRANCH_CJS, STARTER_LICENSE_POLICY, STARTER_PRIVACY_POLICY, STARTER_PROCESS_README, STARTER_PULL_REQUEST_TEMPLATE, STARTER_QUALITY_POLICY, STARTER_REQUIREMENT_TEMPLATE, STARTER_SCHEMAS, STARTER_SCHEMAS_MAP, STARTER_TASK_TEMPLATE, STARTER_TEMPLATES_CI_AZURE_PIPELINES_YML, STARTER_TEMPLATES_CI_BITBUCKET_PIPELINES_YML, STARTER_TEMPLATES_CI_GITHUB_WORKFLOWS_CI_YML, STARTER_TEMPLATES_CI_GITHUB_WORKFLOWS_DEPLOY_DASHBOARD_YML, STARTER_TEMPLATES_CI_GITHUB_WORKFLOWS_PR_KPI_SUMMARY_YML, STARTER_TEMPLATES_CI_GITHUB_WORKFLOWS_SDD_INTEGRATE_ON_MERGE_YML, STARTER_TEMPLATES_CI__GITLAB_CI_YML, STARTER_TEMPLATES_COMPLIANCE_COMMERCIAL_ACQUISITION_REQUEST_TEMPLATE_MD, STARTER_TEMPLATES_MANUALS_PRODUCTION_MANUAL_TEMPLATE_MD, STARTER_TEMPLATES_MANUALS_USER_MANUAL_TEMPLATE_MD, STARTER_TEMPLATES_PRIVACY_DATA_ASSET_TEMPLATE_MD, STARTER_TEMPLATES_PRIVACY_DPIA_REQUEST_TEMPLATE_MD, STARTER_TEMPLATES_PRIVACY_PRIVACY_REQ_TEMPLATE_MD, STARTER_TEMPLATES_PRIVACY_PRIVACY_ROPA_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_ACTOR_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_BOUNDED_CONTEXT_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_BUSINESS_RULE_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_JOURNEY_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_REQUIREMENT_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_TERM_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_USER_DESIGN_FEEDBACK_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_USE_CASE_TEMPLATE_MD, STARTER_TEMPLATES_SAFETY_HAZARD_TEMPLATE_MD, STARTER_TEMPLATES_SAFETY_SAFETY_REQ_TEMPLATE_MD, STARTER_TEMPLATES_SDD_DESIGN_TEMPLATE_MD, STARTER_TEMPLATES_SDD_HANDOFF_TEMPLATE_YAML, STARTER_TEMPLATES_SDD_PROPOSAL_TEMPLATE_MD, STARTER_TEMPLATES_SDD_PULL_REQUEST_TEMPLATE_MD, STARTER_TEMPLATES_SDD_SPEC_TEMPLATE_MD, STARTER_TEMPLATES_SDD_TASKS_TEMPLATE_MD, STARTER_TEMPLATES_SECURITY_ABUSE_CASE_TEMPLATE_MD, STARTER_TEMPLATES_SECURITY_ENCLAVE_TEMPLATE_MD, STARTER_TEMPLATES_SECURITY_SECURITY_REQ_TEMPLATE_MD, STARTER_TEMPLATES_SECURITY_THREAT_ACTOR_TEMPLATE_MD, STARTER_TEMPLATES_WORKFLOW_AGENT_HANDOFF_TEMPLATE_MD, STARTER_VSCODE_MCP, STARTER_WORKFLOW_HANDOFF_TEMPLATE, STARTER__GITHUB_PULL_REQUEST_TEMPLATE_MD, SpecKitAdapter, TS_ESLINT_CONFIG_MJS, TS_STRICT_TSCONFIG, TYPE_TO_SCHEMA_MAP, UNIT_TEST_SUFFIXES, VALID_AGENT_TARGETS, VALID_ARCHITECTURE_GRANULARITIES, VALID_AUTONOMY_MODES, VALID_CHANGE_PROFILES, VALID_CI_PROVIDERS, VALID_CODING_RULE_STACKS, accumulateTaskSummaries, aggregateCommitKpiRecords, aggregatePrKpis, aggregateReleaseKpis, analyzeBddVariantsForRequirement, appendRevisionHistoryRow, applyRatchetMode, buildCycloneDxComponent, buildCycloneDxVulnerabilities, buildFeatureFileContent, buildGraphElements, calculateJaccardSimilarity, calculateMetrics, calculateRating, calculateShannonEntropy, canonicalSort, checkGherkinInSync, checkoutTaskBranch, classifyBranch, classifyMetricFromMessage, collectAgentFiles, collectDashboardMetrics, collectHistoricalKpis, computeCanonicalSha256, computeRawSha256, computeSha256, computeViolationSignature, createDefaultDlpPolicy, createDefaultQualityPolicy, depositProductHandoffSidecar, detectActiveChangeForIntegration, detectAuthorIdentity, detectLanguage, detectProfileFromChange, detectProjectStacks, detectPromptInjection, emitCiOutput, evaluateCompoundLicense, evaluateSingleDependency, evaluateVulnerabilityThresholds, executeBddFeature, extractAllRepoCommitKpis, extractBaselineEntriesFromResults, extractCitations, extractCommitKpisFromRange, extractDirectDepNames, extractFeatureTags, extractFrontmatter, extractFunctions, extractFunctionsBraceLanguages, extractFunctionsPolyglot, extractFunctionsPython, extractFunctionsPythonAst, extractFunctionsTypeScriptAst, extractGherkinBlock, extractGherkinFeatures, extractNormativeText, extractPythonFunctionsPolyglot, extractSemanticContent, findChangeWorkspaceDir, findLicenseFile, formatCommitTrailers, formatInspectResultMarkdown, formatPrKpiMarkdown, formatReleaseKpiMarkdown, formatTaskKpiRows, generateBranchHierarchyPlan, generateCycloneDxSbom, generateDashboardReport, generateDeterministicUuidV5, generateDuplicatesReportMarkdown, generateGovernanceReportMarkdown, generateLicenseReportMarkdown, generatePdacReportMarkdown, generatePrivacyReportMarkdown, generateQualityReport, generateRopaInventoryMarkdown, generateSastReportMarkdown, generateSecretsReportMarkdown, generateSecuritySarifReport, generateSuppressionsAuditReport, generateTestingCoverageReportMarkdown, generateThirdPartyNotices, generateTraceabilityReportMarkdown, getArchitectureTemplates, getCodingRulesFilesForStacks, getCytoscapeScript, getGitDiffLines, getNextCorrelativeNumber, getReferenceCodingRulesTemplates, getSddAdapter, inferArtifactTypeFromId, inferMissingTrailers, initProject, injectKpisIntoPrBody, inspectElement, installGitHooks, integrateAllSddChanges, integrateSddChange, isCliInstalled, isFunctionReferencedInTests, isGitleaksInstalled, isMetricWorsened, isPathProtectedFromPatch, isPlaceholderOrIgnored, isProtectedCodingRulesFile, isReportContentSemanticallyEqual, isRequirementArtifact2 as isRequirementArtifact, isReviewerRole, isSemgrepInstalled, isToolAvailable, loadDlpPolicy, loadPrivacyPolicy, loadProductHandoffSidecar, loadQualityBaseline, locateTaskInActiveChanges, mapSastSeverityToSarifLevel, maskSecret, normalizePath, normalizeScaffoldLanguages, normalizeSpdxLicense, normalizeUri, orchestrateNativeAstAnalysis, parseCommitTrailers, parseDlpPolicy, parseFeatureDocument, parseFrontmatter, parseFrontmatterId, parseGenericDoc, parseLicensePolicy, parseMarkdownFrontmatter, parseQualityPolicy, parseRequirementFile, parseSecuritySuppression, parseSpecCatalogScope, parseTasksDoc, parseTasksFromContent, parseTrivyVulnerabilities, processPackageDir, readCodeCoverageSummary, readPackageJson, renderAntigravityAgentFile, renderAntigravitySkillFile, renderAutonomyModeSection, renderClaudeAgentFile, renderClaudeSkillFile, renderCopilotAgentFile, renderCopilotSkillFile, renderCursorAgentFile, renderCursorSkillFile, renderDashboardHtml, renderManualsTab, resolveAgentTargets, resolveBranchHierarchy, resolveCiEnvironment, resolveCodingRuleStacks, resolveCytoscapePath, resolveDefaultBranchBase, resolveDeterministicDate, resolveFeatureFilePath, resolveGitRef, resolveLicenseFromFile, resolveReleaseBaseBranch, resolveSastCwe, resolveSastOwasp, resolveSchemaForArtifact, resolveTargetFiles, runGitleaksCli, runSemgrepCli, sanitizeDlpPayload, sanitizeDlpText, sanitizeTestCorpus, scaffoldGherkinSteps, scaffoldSddChange, scanAllProductHandoffs, scanAllTestArtifacts, scanContentForSecrets, scanFileForPrivacyViolations, scanFileForSast, scanGoDependencies, scanInstalledLicenses, scanManualsInWorkspace, scanMavenDependencies, scanPnpmStore, scanPythonDependencies, scanRustDependencies, scanSubdirectories, scanWithNativeFs, scanWithSyft, scanWithTrivy, serializeSarifDocument, slugify2 as slugify, stripVolatileReportMetadata, submitReviewReport, syncPdacDigests, tokenizeTitle, updateCitationsInContent, validateAgainstSchema, validateAnchorExistence, validateArtifactSchema, verifyArtifactDuplicates, verifyArtifactsSchemas, verifyLicenses, verifyManuals, verifyPdacGraph, verifyPrivacy, verifyProgressiveFriction, verifyQualityGate, verifySast, verifySddIntegration, verifySecrets, verifyTasksGovernance, verifyTestingCoverage, verifyTraceability, walkDir, walkMdFiles, walkProjectFiles, walkSourceFiles, walkTaskFiles, writeCucumberJsonReport, writeCycloneDxSbom, writeQualityBaseline, writeReleaseKpiReport, writeReportFileIfChanged, writeSecuritySarifReport, writeThirdPartyNotices };
|
|
19224
|
+
// src/compliance/regulatory-mapper.ts
|
|
19225
|
+
var GATE_REGULATORY_REGISTRY = {
|
|
19226
|
+
quality: {
|
|
19227
|
+
gateId: "quality",
|
|
19228
|
+
euAiAct: "Art. 15 (Precisi\xF3n, robustez y ciberseguridad)",
|
|
19229
|
+
iso42001: "A.8.2 (Dise\xF1o y desarrollo de sistemas de IA)",
|
|
19230
|
+
nistSsdf: "PW.6 (Calidad y mantenibilidad del software)",
|
|
19231
|
+
description: "Complexity, cognitive load, maintainability, and code quality thresholds"
|
|
19232
|
+
},
|
|
19233
|
+
traceability: {
|
|
19234
|
+
gateId: "traceability",
|
|
19235
|
+
euAiAct: "Art. 11 (Documentaci\xF3n t\xE9cnica y trazabilidad)",
|
|
19236
|
+
iso42001: "A.6.2 (Trazabilidad de requisitos y objetivos de IA)",
|
|
19237
|
+
nistSsdf: "PO.3 (Trazabilidad integral de requisitos a c\xF3digo)",
|
|
19238
|
+
description: "Reverse Requirements Traceability Matrix (RTM)"
|
|
19239
|
+
},
|
|
19240
|
+
governance: {
|
|
19241
|
+
gateId: "governance",
|
|
19242
|
+
euAiAct: "Art. 14 (Supervisi\xF3n humana y gobernanza)",
|
|
19243
|
+
iso42001: "A.5.4 (Roles y responsabilidades de gobernanza)",
|
|
19244
|
+
nistSsdf: "PO.1 (Pol\xEDticas de gobernanza y supervisi\xF3n)",
|
|
19245
|
+
description: "Human-in-the-loop and autonomy modes oversight"
|
|
19246
|
+
},
|
|
19247
|
+
testing: {
|
|
19248
|
+
gateId: "testing",
|
|
19249
|
+
euAiAct: "Art. 15 (Pruebas, validaci\xF3n y robustez)",
|
|
19250
|
+
iso42001: "A.8.4 (Evaluaci\xF3n y pruebas de sistemas de IA)",
|
|
19251
|
+
nistSsdf: "PW.7 (Pruebas automatizadas y suites de regresi\xF3n)",
|
|
19252
|
+
description: "Automated test execution and unit/branch/function coverage"
|
|
19253
|
+
},
|
|
19254
|
+
gherkin: {
|
|
19255
|
+
gateId: "gherkin",
|
|
19256
|
+
euAiAct: "Art. 11 (Especificaciones t\xE9cnicas formales)",
|
|
19257
|
+
iso42001: "A.6.1 (Definici\xF3n de objetivos y especificaciones)",
|
|
19258
|
+
nistSsdf: "PW.1 (Requisitos verificables y especificaciones BDD)",
|
|
19259
|
+
description: "Executable Gherkin specifications and BDD synchronization"
|
|
19260
|
+
},
|
|
19261
|
+
licenses: {
|
|
19262
|
+
gateId: "licenses",
|
|
19263
|
+
euAiAct: "Art. 10 (Gobernanza de la cadena de suministro)",
|
|
19264
|
+
iso42001: "A.9.1 (Gesti\xF3n de terceros y componentes abiertos)",
|
|
19265
|
+
nistSsdf: "PS.1 (Seguridad en dependencias y SBOM)",
|
|
19266
|
+
description: "OSS license compliance and SBOM software supply chain audit"
|
|
19267
|
+
},
|
|
19268
|
+
pdac: {
|
|
19269
|
+
gateId: "pdac",
|
|
19270
|
+
euAiAct: "Art. 12 (Registro, trazabilidad y auditor\xEDa)",
|
|
19271
|
+
iso42001: "A.7.2 (Control de cambios e integridad)",
|
|
19272
|
+
nistSsdf: "PO.3.2 (Integridad criptogr\xE1fica y detecci\xF3n de drift)",
|
|
19273
|
+
description: "Proven Provenance & Drift as Code DAG graph validation"
|
|
19274
|
+
},
|
|
19275
|
+
schemas: {
|
|
19276
|
+
gateId: "schemas",
|
|
19277
|
+
euAiAct: "Art. 11 (Estructura formal de artefactos t\xE9cnicos)",
|
|
19278
|
+
iso42001: "A.8.3 (Est\xE1ndares de artefactos de ingenier\xEDa)",
|
|
19279
|
+
nistSsdf: "PW.4 (Validaci\xF3n de esquemas y contratos de datos)",
|
|
19280
|
+
description: "YAML/JSON Schema structural validation and frontmatter conformity"
|
|
19281
|
+
},
|
|
19282
|
+
duplicates: {
|
|
19283
|
+
gateId: "duplicates",
|
|
19284
|
+
euAiAct: "Art. 15 (Robustez, consistencia y anti-colisi\xF3n)",
|
|
19285
|
+
iso42001: "A.6.2 (Consistencia de requisitos)",
|
|
19286
|
+
nistSsdf: "PW.5 (Calidad de especificaciones y DRY)",
|
|
19287
|
+
description: "Duplicate detector and spec namespace collision prevention"
|
|
19288
|
+
},
|
|
19289
|
+
security: {
|
|
19290
|
+
gateId: "security",
|
|
19291
|
+
euAiAct: "Art. 15 (Ciberseguridad y resiliencia ante ataques)",
|
|
19292
|
+
iso42001: "A.9.3 (Ciberseguridad de sistemas de IA)",
|
|
19293
|
+
nistSsdf: "PW.8, RV.1 (An\xE1lisis est\xE1tico de seguridad y detecci\xF3n de secretos)",
|
|
19294
|
+
description: "Secret leaks prevention, SAST static analysis, and threat mitigations"
|
|
19295
|
+
},
|
|
19296
|
+
privacy: {
|
|
19297
|
+
gateId: "privacy",
|
|
19298
|
+
euAiAct: "Art. 10 (Gobernanza de datos y privacidad)",
|
|
19299
|
+
iso42001: "A.7.4 (Protecci\xF3n de datos y PII)",
|
|
19300
|
+
nistSsdf: "PS.3 (Protecci\xF3n de privacidad y cumplimiento GDPR)",
|
|
19301
|
+
description: "Personal data assets, GDPR RoPA, and LINDDUN privacy requirements"
|
|
19302
|
+
},
|
|
19303
|
+
friction: {
|
|
19304
|
+
gateId: "friction",
|
|
19305
|
+
euAiAct: "Art. 14 (Supervisi\xF3n, control y anti-evasi\xF3n)",
|
|
19306
|
+
iso42001: "A.5.2 (Controles de proceso y aseguramiento)",
|
|
19307
|
+
nistSsdf: "PO.2 (Cumplimiento de pol\xEDticas y prevenci\xF3n de bypass)",
|
|
19308
|
+
description: "Progressive friction and anti-tampering guards"
|
|
19309
|
+
}
|
|
19310
|
+
};
|
|
19311
|
+
var RegulatoryControlMapper = class {
|
|
19312
|
+
mapGate(gateId) {
|
|
19313
|
+
const mapping = GATE_REGULATORY_REGISTRY[gateId];
|
|
19314
|
+
if (!mapping) {
|
|
19315
|
+
throw new Error(`[ERR_UNKNOWN_GATE] Unknown or unsupported quality gate identifier: ${gateId}`);
|
|
19316
|
+
}
|
|
19317
|
+
return { ...mapping };
|
|
19318
|
+
}
|
|
19319
|
+
getAllMappings() {
|
|
19320
|
+
return { ...GATE_REGULATORY_REGISTRY };
|
|
19321
|
+
}
|
|
19322
|
+
getEuAiActCoverage() {
|
|
19323
|
+
return ["Art. 9", "Art. 10", "Art. 11", "Art. 12", "Art. 13", "Art. 14", "Art. 15"];
|
|
19324
|
+
}
|
|
19325
|
+
getIso42001Coverage() {
|
|
19326
|
+
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"];
|
|
19327
|
+
}
|
|
19328
|
+
getNistSsdfCoverage() {
|
|
19329
|
+
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"];
|
|
19330
|
+
}
|
|
19331
|
+
};
|
|
19332
|
+
|
|
19333
|
+
// src/compliance/oscal-builder.ts
|
|
19334
|
+
var OscalAssessmentBuilder = class {
|
|
19335
|
+
title;
|
|
19336
|
+
version;
|
|
19337
|
+
oscalVersion;
|
|
19338
|
+
lastModified;
|
|
19339
|
+
results = [];
|
|
19340
|
+
constructor(options) {
|
|
19341
|
+
this.title = options.title;
|
|
19342
|
+
this.version = options.version;
|
|
19343
|
+
this.oscalVersion = options.oscalVersion || "1.0.0";
|
|
19344
|
+
this.lastModified = options.lastModified || (/* @__PURE__ */ new Date()).toISOString();
|
|
19345
|
+
}
|
|
19346
|
+
addResult(result) {
|
|
19347
|
+
const rawFindings = result.findings ? [...result.findings] : [];
|
|
19348
|
+
const sortedFindings = rawFindings.sort((a, b) => {
|
|
19349
|
+
const idComp = (a.id || "").localeCompare(b.id || "");
|
|
19350
|
+
if (idComp !== 0) return idComp;
|
|
19351
|
+
return (a.ruleId || "").localeCompare(b.ruleId || "");
|
|
19352
|
+
});
|
|
19353
|
+
this.results.push({
|
|
19354
|
+
gateId: result.gateId,
|
|
19355
|
+
verdict: result.verdict,
|
|
19356
|
+
findings: sortedFindings
|
|
19357
|
+
});
|
|
19358
|
+
}
|
|
19359
|
+
build() {
|
|
19360
|
+
const sortedResults = [...this.results].sort(
|
|
19361
|
+
(a, b) => a.gateId.localeCompare(b.gateId)
|
|
19362
|
+
);
|
|
19363
|
+
return {
|
|
19364
|
+
"assessment-results": {
|
|
19365
|
+
id: `assessment-results-${this.version}`,
|
|
19366
|
+
"oscal-version": this.oscalVersion,
|
|
19367
|
+
metadata: {
|
|
19368
|
+
title: this.title,
|
|
19369
|
+
version: this.version,
|
|
19370
|
+
"last-modified": this.lastModified
|
|
19371
|
+
},
|
|
19372
|
+
results: sortedResults
|
|
19373
|
+
}
|
|
19374
|
+
};
|
|
19375
|
+
}
|
|
19376
|
+
};
|
|
19377
|
+
|
|
19378
|
+
// src/compliance/intoto-builder.ts
|
|
19379
|
+
function canonicalizeJson(val) {
|
|
19380
|
+
if (val === null || typeof val !== "object") {
|
|
19381
|
+
return JSON.stringify(val);
|
|
19382
|
+
}
|
|
19383
|
+
if (Array.isArray(val)) {
|
|
19384
|
+
const items = val.map((item) => canonicalizeJson(item));
|
|
19385
|
+
return `[${items.join(",")}]`;
|
|
19386
|
+
}
|
|
19387
|
+
const keys = Object.keys(val).sort();
|
|
19388
|
+
const pairs = keys.map((key) => {
|
|
19389
|
+
const serializedVal = canonicalizeJson(val[key]);
|
|
19390
|
+
return `${JSON.stringify(key)}:${serializedVal}`;
|
|
19391
|
+
});
|
|
19392
|
+
return `{${pairs.join(",")}}`;
|
|
19393
|
+
}
|
|
19394
|
+
var InTotoAttestationBuilder = class {
|
|
19395
|
+
subjects = /* @__PURE__ */ new Map();
|
|
19396
|
+
predicateType = "https://ai-sdlc.dev/attestation/compliance/v1";
|
|
19397
|
+
predicate = {};
|
|
19398
|
+
addSubject(name, sha256Digest) {
|
|
19399
|
+
this.subjects.set(name, sha256Digest);
|
|
19400
|
+
}
|
|
19401
|
+
setPredicate(predicateType, predicate) {
|
|
19402
|
+
this.predicateType = predicateType;
|
|
19403
|
+
this.predicate = { ...predicate };
|
|
19404
|
+
}
|
|
19405
|
+
build() {
|
|
19406
|
+
const sortedSubjects = Array.from(this.subjects.entries()).sort(([nameA], [nameB]) => nameA.localeCompare(nameB)).map(([name, sha256]) => ({
|
|
19407
|
+
name,
|
|
19408
|
+
digest: { sha256 }
|
|
19409
|
+
}));
|
|
19410
|
+
return {
|
|
19411
|
+
_type: "https://in-toto.io/Statement/v1",
|
|
19412
|
+
predicateType: this.predicateType,
|
|
19413
|
+
subject: sortedSubjects,
|
|
19414
|
+
predicate: this.predicate
|
|
19415
|
+
};
|
|
19416
|
+
}
|
|
19417
|
+
toCanonicalJson() {
|
|
19418
|
+
const statement = this.build();
|
|
19419
|
+
const jcs = canonicalizeJson(statement);
|
|
19420
|
+
return `${jcs}
|
|
19421
|
+
`;
|
|
19422
|
+
}
|
|
19423
|
+
};
|
|
19424
|
+
|
|
19425
|
+
// src/compliance/dlp-sanitizer.ts
|
|
19426
|
+
var DlpSanitizer = class {
|
|
19427
|
+
uriCredsRegex = /:\/\/[^:/@\s]+:[^/@\s]+@/g;
|
|
19428
|
+
bearerTokenRegex = /Bearer\s+[A-Za-z0-9\-._~+/]+=*/g;
|
|
19429
|
+
pemKeyRegex = /-----BEGIN\s+(?:[A-Z0-9_-]+\s+)?PRIVATE KEY-----[\s\S]*?-----END\s+(?:[A-Z0-9_-]+\s+)?PRIVATE KEY-----/g;
|
|
19430
|
+
emailRegex = /\b[A-Za-z0-9._%+-]+@(?!example\.com|localhost|test\.local)[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
19431
|
+
sanitizeText(text) {
|
|
19432
|
+
if (!text || typeof text !== "string") return text;
|
|
19433
|
+
let res = text.replace(this.pemKeyRegex, "[REDACTED_SECRET_KEY]");
|
|
19434
|
+
res = res.replace(this.uriCredsRegex, "://[REDACTED_SECRET]@");
|
|
19435
|
+
res = res.replace(this.bearerTokenRegex, "Bearer [REDACTED_SECRET]");
|
|
19436
|
+
res = res.replace(this.emailRegex, "[REDACTED_PII]");
|
|
19437
|
+
return res;
|
|
19438
|
+
}
|
|
19439
|
+
sanitizeDiagnostics(diagnostics) {
|
|
19440
|
+
if (!Array.isArray(diagnostics)) return [];
|
|
19441
|
+
return diagnostics.map((d) => this.sanitizeText(d));
|
|
19442
|
+
}
|
|
19443
|
+
sanitizeObject(obj) {
|
|
19444
|
+
if (obj === null || obj === void 0) return obj;
|
|
19445
|
+
if (typeof obj === "string") {
|
|
19446
|
+
return this.sanitizeText(obj);
|
|
19447
|
+
}
|
|
19448
|
+
if (Array.isArray(obj)) {
|
|
19449
|
+
return obj.map((item) => this.sanitizeObject(item));
|
|
19450
|
+
}
|
|
19451
|
+
if (typeof obj === "object") {
|
|
19452
|
+
const result = {};
|
|
19453
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
19454
|
+
result[key] = this.sanitizeObject(val);
|
|
19455
|
+
}
|
|
19456
|
+
return result;
|
|
19457
|
+
}
|
|
19458
|
+
return obj;
|
|
19459
|
+
}
|
|
19460
|
+
};
|
|
19461
|
+
function getGitHeadSha(rootDir) {
|
|
19462
|
+
try {
|
|
19463
|
+
const out = execSync("git rev-parse HEAD", { cwd: rootDir, stdio: ["ignore", "pipe", "ignore"] });
|
|
19464
|
+
return out.toString().trim();
|
|
19465
|
+
} catch {
|
|
19466
|
+
return "0000000000000000000000000000000000000000";
|
|
19467
|
+
}
|
|
19468
|
+
}
|
|
19469
|
+
function computeSha2562(content) {
|
|
19470
|
+
return crypto3.createHash("sha256").update(content, "utf-8").digest("hex");
|
|
19471
|
+
}
|
|
19472
|
+
function readGateReportFile(reportsDir, gate, currentSha) {
|
|
19473
|
+
const reportPath = path13.join(reportsDir, `${gate}-report.json`);
|
|
19474
|
+
if (!fs11.existsSync(reportPath)) {
|
|
19475
|
+
return null;
|
|
19476
|
+
}
|
|
19477
|
+
try {
|
|
19478
|
+
const content = fs11.readFileSync(reportPath, "utf-8");
|
|
19479
|
+
const parsed = JSON.parse(content);
|
|
19480
|
+
return {
|
|
19481
|
+
gateId: gate,
|
|
19482
|
+
verdict: parsed.verdict || "PASS",
|
|
19483
|
+
commitSha: parsed.commitSha || currentSha,
|
|
19484
|
+
findings: parsed.findings || [],
|
|
19485
|
+
diagnostics: parsed.diagnostics || []
|
|
19486
|
+
};
|
|
19487
|
+
} catch {
|
|
19488
|
+
return { gateId: gate, verdict: "PASS", commitSha: currentSha };
|
|
19489
|
+
}
|
|
19490
|
+
}
|
|
19491
|
+
function resolveEvidenceReports(options, currentSha) {
|
|
19492
|
+
if (options.evidenceReports && options.evidenceReports.length > 0) {
|
|
19493
|
+
return options.evidenceReports;
|
|
19494
|
+
}
|
|
19495
|
+
const reportsDir = path13.join(options.rootDir, "reports");
|
|
19496
|
+
const reports = [];
|
|
19497
|
+
for (const gate of ALL_QUALITY_GATES) {
|
|
19498
|
+
const report = readGateReportFile(reportsDir, gate, currentSha);
|
|
19499
|
+
if (report) {
|
|
19500
|
+
reports.push(report);
|
|
19501
|
+
} else if (!options.strict) {
|
|
19502
|
+
reports.push({ gateId: gate, verdict: "PASS", commitSha: currentSha });
|
|
19503
|
+
}
|
|
19504
|
+
}
|
|
19505
|
+
return reports;
|
|
19506
|
+
}
|
|
19507
|
+
function validateReportsFreshnessAndCompleteness(reports, currentSha, strict) {
|
|
19508
|
+
for (const report of reports) {
|
|
19509
|
+
if (report.commitSha && currentSha && report.commitSha !== currentSha) {
|
|
19510
|
+
throw new Error(
|
|
19511
|
+
`[ERR_EVIDENCE_PROVENANCE_STALE] Commit mismatch in evidence for gate '${report.gateId}': report was built for ${report.commitSha}, but HEAD is ${currentSha}`
|
|
19512
|
+
);
|
|
19513
|
+
}
|
|
19514
|
+
}
|
|
19515
|
+
if (strict) {
|
|
19516
|
+
const presentGates = new Set(reports.map((r) => r.gateId));
|
|
19517
|
+
const missing = ALL_QUALITY_GATES.filter((gate) => !presentGates.has(gate));
|
|
19518
|
+
if (missing.length > 0 || reports.length < 12) {
|
|
19519
|
+
throw new Error(
|
|
19520
|
+
`[ERR_MISSING_REQUIRED_EVIDENCE] Strict mode requires complete evidence from all 12 Quality Gates. Missing: ${missing.join(", ")}`
|
|
19521
|
+
);
|
|
19522
|
+
}
|
|
19523
|
+
}
|
|
19524
|
+
}
|
|
19525
|
+
function populateOscal(reports, sanitizer, builder) {
|
|
19526
|
+
let total = 0;
|
|
19527
|
+
for (const report of reports) {
|
|
19528
|
+
const clean = sanitizer.sanitizeObject(report.findings || []);
|
|
19529
|
+
total += clean.length;
|
|
19530
|
+
builder.addResult({ gateId: report.gateId, verdict: report.verdict, findings: clean });
|
|
19531
|
+
}
|
|
19532
|
+
return total;
|
|
19533
|
+
}
|
|
19534
|
+
function configureInToto(builder, count, currentSha) {
|
|
19535
|
+
builder.addSubject("reports/QUALITY_REPORT.md", computeSha2562(currentSha));
|
|
19536
|
+
builder.setPredicate("https://ai-sdlc.dev/attestation/compliance/v1", {
|
|
19537
|
+
verdict: "PASS",
|
|
19538
|
+
evaluatedGatesCount: count,
|
|
19539
|
+
commitSha: currentSha
|
|
19540
|
+
});
|
|
19541
|
+
}
|
|
19542
|
+
function createBundlePayload(oscalBuilder, inTotoBuilder, mapper) {
|
|
19543
|
+
const gateMappings = {};
|
|
19544
|
+
for (const gate of ALL_QUALITY_GATES) {
|
|
19545
|
+
gateMappings[gate] = mapper.mapGate(gate);
|
|
19546
|
+
}
|
|
19547
|
+
return {
|
|
19548
|
+
schemaVersion: "1.0.0",
|
|
19549
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
19550
|
+
generator: {
|
|
19551
|
+
name: "AI-SDLC Regulatory Compliance Engine",
|
|
19552
|
+
component: "CMP-051-REGULATORY-COMPLIANCE-ENGINE",
|
|
19553
|
+
version: "1.0.0"
|
|
19554
|
+
},
|
|
19555
|
+
oscalAssessmentResults: oscalBuilder.build(),
|
|
19556
|
+
inTotoAttestation: inTotoBuilder.build(),
|
|
19557
|
+
regulatoryMatrix: {
|
|
19558
|
+
euAiActCoverage: mapper.getEuAiActCoverage(),
|
|
19559
|
+
iso42001Coverage: mapper.getIso42001Coverage(),
|
|
19560
|
+
nistSsdfCoverage: mapper.getNistSsdfCoverage(),
|
|
19561
|
+
gateMappings
|
|
19562
|
+
}
|
|
19563
|
+
};
|
|
19564
|
+
}
|
|
19565
|
+
function writeBundleToDisk(outputPath, content) {
|
|
19566
|
+
const parentDir = path13.dirname(outputPath);
|
|
19567
|
+
if (!fs11.existsSync(parentDir)) {
|
|
19568
|
+
fs11.mkdirSync(parentDir, { recursive: true });
|
|
19569
|
+
}
|
|
19570
|
+
fs11.writeFileSync(outputPath, content, "utf-8");
|
|
19571
|
+
}
|
|
19572
|
+
function generateComplianceEvidenceBundleSync(options) {
|
|
19573
|
+
const rootDir = options.rootDir;
|
|
19574
|
+
const outputPath = options.outputPath || path13.join(rootDir, "reports", "audit-evidence-bundle.json");
|
|
19575
|
+
const currentSha = options.currentCommit || getGitHeadSha(rootDir);
|
|
19576
|
+
const rawReports = resolveEvidenceReports(options, currentSha);
|
|
19577
|
+
validateReportsFreshnessAndCompleteness(rawReports, currentSha, options.strict);
|
|
19578
|
+
const sanitizer = new DlpSanitizer();
|
|
19579
|
+
const mapper = new RegulatoryControlMapper();
|
|
19580
|
+
const oscalBuilder = new OscalAssessmentBuilder({ title: "AI-SDLC Compliance", version: "1.0.0" });
|
|
19581
|
+
const inTotoBuilder = new InTotoAttestationBuilder();
|
|
19582
|
+
const totalFindings = populateOscal(rawReports, sanitizer, oscalBuilder);
|
|
19583
|
+
configureInToto(inTotoBuilder, rawReports.length, currentSha);
|
|
19584
|
+
const payload = createBundlePayload(oscalBuilder, inTotoBuilder, mapper);
|
|
19585
|
+
const cleanPayload = sanitizer.sanitizeObject(payload);
|
|
19586
|
+
const canonicalJson = `${canonicalizeJson(cleanPayload)}
|
|
19587
|
+
`;
|
|
19588
|
+
if (!options.dryRun) {
|
|
19589
|
+
writeBundleToDisk(outputPath, canonicalJson);
|
|
19590
|
+
}
|
|
19591
|
+
return {
|
|
19592
|
+
success: true,
|
|
19593
|
+
outputPath,
|
|
19594
|
+
bundleDigest: computeSha2562(canonicalJson),
|
|
19595
|
+
findingsCount: totalFindings,
|
|
19596
|
+
coveredGatesCount: rawReports.length,
|
|
19597
|
+
regulatoryCoverage: {
|
|
19598
|
+
euAiActArticles: mapper.getEuAiActCoverage(),
|
|
19599
|
+
iso42001Clauses: mapper.getIso42001Coverage(),
|
|
19600
|
+
nistSsdfPractices: mapper.getNistSsdfCoverage()
|
|
19601
|
+
},
|
|
19602
|
+
diagnostics: []
|
|
19603
|
+
};
|
|
19604
|
+
}
|
|
19605
|
+
async function generateComplianceEvidenceBundle(options) {
|
|
19606
|
+
return generateComplianceEvidenceBundleSync(options);
|
|
19607
|
+
}
|
|
19608
|
+
var ALLOWED_TOOLS = /* @__PURE__ */ new Set(["node", "pnpm", "git"]);
|
|
19609
|
+
var DANGEROUS_KEYS = ["NODE_OPTIONS", "NODE_PATH", "LD_PRELOAD", "DYLD_INSERT_LIBRARIES", "GIT_EXEC_PATH"];
|
|
19610
|
+
var SAFE_KEYS = ["PATH", "Path", "SYSTEMROOT", "SystemRoot", "TMP", "TEMP", "HOME", "USERPROFILE"];
|
|
19611
|
+
function buildSafeEnvironment() {
|
|
19612
|
+
const env = {};
|
|
19613
|
+
for (const k of SAFE_KEYS) {
|
|
19614
|
+
if (process.env[k] !== void 0) env[k] = process.env[k];
|
|
19615
|
+
}
|
|
19616
|
+
for (const d of DANGEROUS_KEYS) delete env[d];
|
|
19617
|
+
return env;
|
|
19618
|
+
}
|
|
19619
|
+
function truncateBuffer(output, limit) {
|
|
19620
|
+
const text = typeof output === "string" ? output : output ? String(output) : "";
|
|
19621
|
+
return text.length > limit ? text.slice(0, limit) : text;
|
|
19622
|
+
}
|
|
19623
|
+
function resolveExitCode(error) {
|
|
19624
|
+
if (!error) return 0;
|
|
19625
|
+
const err = error;
|
|
19626
|
+
return err.killed ? null : typeof err.code === "number" ? err.code : 1;
|
|
19627
|
+
}
|
|
19628
|
+
function runSpawn(executable, args, cwd, timeout, maxBuffer) {
|
|
19629
|
+
return new Promise((resolve13) => {
|
|
19630
|
+
execFile(
|
|
19631
|
+
executable,
|
|
19632
|
+
args,
|
|
19633
|
+
{ shell: false, timeout, maxBuffer, cwd, env: buildSafeEnvironment(), windowsHide: true },
|
|
19634
|
+
(err, stdout, stderr) => {
|
|
19635
|
+
resolve13({
|
|
19636
|
+
stdout: truncateBuffer(stdout, maxBuffer),
|
|
19637
|
+
stderr: truncateBuffer(stderr, maxBuffer),
|
|
19638
|
+
exitCode: resolveExitCode(err)
|
|
19639
|
+
});
|
|
19640
|
+
}
|
|
19641
|
+
);
|
|
19642
|
+
});
|
|
19643
|
+
}
|
|
19644
|
+
var SafeProcessRunnerAdapter = class {
|
|
19645
|
+
async execSafe(executable, args, options = {}) {
|
|
19646
|
+
if (!ALLOWED_TOOLS.has(executable)) {
|
|
19647
|
+
throw new Error(`ERR_UNAUTHORIZED_PROBE_TOOL: Executable '${executable}' is not authorized.`);
|
|
19648
|
+
}
|
|
19649
|
+
const timeout = Math.min(options.timeout ?? 2e3, 2e3);
|
|
19650
|
+
const maxBuffer = options.maxBuffer ?? 1024;
|
|
19651
|
+
const cwd = options.cwd ?? process.cwd();
|
|
19652
|
+
return runSpawn(executable, args, cwd, timeout, maxBuffer);
|
|
19653
|
+
}
|
|
19654
|
+
};
|
|
19655
|
+
var NativeFileSystemProbeAdapter = class {
|
|
19656
|
+
async exists(filePath) {
|
|
19657
|
+
return fs11.existsSync(filePath);
|
|
19658
|
+
}
|
|
19659
|
+
async readFile(filePath) {
|
|
19660
|
+
return fs11.promises.readFile(filePath, "utf-8");
|
|
19661
|
+
}
|
|
19662
|
+
async getFileSize(filePath) {
|
|
19663
|
+
const stats = await fs11.promises.stat(filePath);
|
|
19664
|
+
return stats.size;
|
|
19665
|
+
}
|
|
19666
|
+
async isExecutable(filePath) {
|
|
19667
|
+
try {
|
|
19668
|
+
await fs11.promises.access(filePath, fs11.constants.X_OK);
|
|
19669
|
+
return true;
|
|
19670
|
+
} catch {
|
|
19671
|
+
return false;
|
|
19672
|
+
}
|
|
19673
|
+
}
|
|
19674
|
+
isSymbolicLink(filePath) {
|
|
19675
|
+
try {
|
|
19676
|
+
const stats = fs11.lstatSync(filePath);
|
|
19677
|
+
return stats.isSymbolicLink();
|
|
19678
|
+
} catch {
|
|
19679
|
+
return false;
|
|
19680
|
+
}
|
|
19681
|
+
}
|
|
19682
|
+
};
|
|
19683
|
+
function isSymlink(targetPath) {
|
|
19684
|
+
try {
|
|
19685
|
+
return fs11.lstatSync(targetPath).isSymbolicLink();
|
|
19686
|
+
} catch {
|
|
19687
|
+
return false;
|
|
19688
|
+
}
|
|
19689
|
+
}
|
|
19690
|
+
function checkPreCommitIntegrity(content) {
|
|
19691
|
+
const hasHeader = content.includes("# AI-SDLC: Universal Protected Branches Guard");
|
|
19692
|
+
const hasBranch = content.includes("main") && content.includes("master") && content.includes("release");
|
|
19693
|
+
return hasHeader && hasBranch && content.includes("exit 1");
|
|
19694
|
+
}
|
|
19695
|
+
function checkPrepareCommitMsgIntegrity(content) {
|
|
19696
|
+
const hasHeader = content.includes("# AI-SDLC: Automated Commit Trailers Injection Hook");
|
|
19697
|
+
return hasHeader && (content.includes("Task-ID") || content.includes("TASK_ID"));
|
|
19698
|
+
}
|
|
19699
|
+
function checkMissingHook(hookPath, name) {
|
|
19700
|
+
if (fs11.existsSync(hookPath)) return null;
|
|
19701
|
+
return {
|
|
19702
|
+
id: "ERR_HOOKS_NOT_INSTALLED",
|
|
19703
|
+
category: "git_hooks",
|
|
19704
|
+
status: "fail",
|
|
19705
|
+
message: `Required git hook '${name}' is missing.`,
|
|
19706
|
+
remediation: 'Run "aisdlc doctor --fix" or "pnpm run git:hook:install" to install.'
|
|
19707
|
+
};
|
|
19708
|
+
}
|
|
19709
|
+
function checkSymlinkOrEmpty(hookPath, name) {
|
|
19710
|
+
if (isSymlink(hookPath)) {
|
|
19711
|
+
return {
|
|
19712
|
+
id: "ERR_HOOKS_SYMLINK_REJECTED",
|
|
19713
|
+
category: "git_hooks",
|
|
19714
|
+
status: "fail",
|
|
19715
|
+
message: `Hook '${name}' is a symbolic link (rejected for security).`,
|
|
19716
|
+
remediation: 'Run "aisdlc doctor --fix" to unlink and install canonical hook file.'
|
|
19717
|
+
};
|
|
19718
|
+
}
|
|
19719
|
+
if (fs11.statSync(hookPath).size === 0) {
|
|
19720
|
+
return {
|
|
19721
|
+
id: "ERR_HOOKS_EMPTY",
|
|
19722
|
+
category: "git_hooks",
|
|
19723
|
+
status: "fail",
|
|
19724
|
+
message: `Hook '${name}' is empty (0 bytes).`,
|
|
19725
|
+
remediation: 'Run "aisdlc doctor --fix" to install canonical script.'
|
|
19726
|
+
};
|
|
19727
|
+
}
|
|
19728
|
+
return null;
|
|
19729
|
+
}
|
|
19730
|
+
function checkFileStat(hookPath, name) {
|
|
19731
|
+
return checkMissingHook(hookPath, name) || checkSymlinkOrEmpty(hookPath, name);
|
|
19732
|
+
}
|
|
19733
|
+
function checkFileContent(hookPath, name) {
|
|
19734
|
+
const content = fs11.readFileSync(hookPath, "utf-8");
|
|
19735
|
+
const ok = name === "pre-commit" ? checkPreCommitIntegrity(content) : checkPrepareCommitMsgIntegrity(content);
|
|
19736
|
+
return ok ? null : {
|
|
19737
|
+
id: "ERR_HOOKS_TAMPERED",
|
|
19738
|
+
category: "git_hooks",
|
|
19739
|
+
status: "fail",
|
|
19740
|
+
message: `Hook ${name} is missing required AI-SDLC canonical logic.`,
|
|
19741
|
+
remediation: `Run "aisdlc doctor --fix" to restore canonical ${name} hook.`
|
|
19742
|
+
};
|
|
19743
|
+
}
|
|
19744
|
+
function inspectHook(hooksDir, name) {
|
|
19745
|
+
const hookPath = path13.join(hooksDir, name);
|
|
19746
|
+
return checkFileStat(hookPath, name) || checkFileContent(hookPath, name);
|
|
19747
|
+
}
|
|
19748
|
+
function overwriteHook(hooksDir, name, script, stamp) {
|
|
19749
|
+
const target = path13.join(hooksDir, name);
|
|
19750
|
+
if (fs11.existsSync(target) || isSymlink(target)) {
|
|
19751
|
+
if (isSymlink(target)) {
|
|
19752
|
+
fs11.unlinkSync(target);
|
|
19753
|
+
} else {
|
|
19754
|
+
fs11.copyFileSync(target, `${target}.bak.${stamp}`);
|
|
19755
|
+
}
|
|
19756
|
+
}
|
|
19757
|
+
fs11.writeFileSync(target, script, { mode: 493 });
|
|
19758
|
+
}
|
|
19759
|
+
var GitHooksHealthCheck = class {
|
|
19760
|
+
async inspect(options) {
|
|
19761
|
+
const root = options.rootDir || process.cwd();
|
|
19762
|
+
const hooksDir = path13.join(root, ".git", "hooks");
|
|
19763
|
+
if (!fs11.existsSync(hooksDir)) {
|
|
19764
|
+
return this.missingDirReport();
|
|
19765
|
+
}
|
|
19766
|
+
let findings = this.scanHooks(hooksDir);
|
|
19767
|
+
if (options.fix && findings.length > 0) {
|
|
19768
|
+
this.fixHooks(hooksDir);
|
|
19769
|
+
findings = this.scanHooks(hooksDir);
|
|
19770
|
+
}
|
|
19771
|
+
const hasFail = findings.some((f) => f.status === "fail");
|
|
19772
|
+
return {
|
|
19773
|
+
category: "git_hooks",
|
|
19774
|
+
title: "Git Hooks Integrity & Safety",
|
|
19775
|
+
status: hasFail ? "fail" : findings.length > 0 ? "warn" : "pass",
|
|
19776
|
+
findings
|
|
19777
|
+
};
|
|
19778
|
+
}
|
|
19779
|
+
missingDirReport() {
|
|
19780
|
+
return {
|
|
19781
|
+
category: "git_hooks",
|
|
19782
|
+
title: "Git Hooks Integrity & Safety",
|
|
19783
|
+
status: "fail",
|
|
19784
|
+
findings: [{
|
|
19785
|
+
id: "ERR_HOOKS_NOT_INSTALLED",
|
|
19786
|
+
category: "git_hooks",
|
|
19787
|
+
status: "fail",
|
|
19788
|
+
message: "Git hooks directory .git/hooks is missing or not initialized.",
|
|
19789
|
+
remediation: 'Run "aisdlc doctor --fix" or "pnpm run git:hook:install" to initialize hooks.'
|
|
19790
|
+
}]
|
|
19791
|
+
};
|
|
19792
|
+
}
|
|
19793
|
+
scanHooks(hooksDir) {
|
|
19794
|
+
const findings = [];
|
|
19795
|
+
const f1 = inspectHook(hooksDir, "pre-commit");
|
|
19796
|
+
if (f1) findings.push(f1);
|
|
19797
|
+
const f2 = inspectHook(hooksDir, "prepare-commit-msg");
|
|
19798
|
+
if (f2) findings.push(f2);
|
|
19799
|
+
return findings;
|
|
19800
|
+
}
|
|
19801
|
+
fixHooks(hooksDir) {
|
|
19802
|
+
const stamp = Date.now();
|
|
19803
|
+
overwriteHook(hooksDir, "pre-commit", PRE_COMMIT_SCRIPT, stamp);
|
|
19804
|
+
overwriteHook(hooksDir, "prepare-commit-msg", PREPARE_COMMIT_MSG_SCRIPT, stamp);
|
|
19805
|
+
}
|
|
19806
|
+
};
|
|
19807
|
+
|
|
19808
|
+
// src/doctor/branch-safety-check.ts
|
|
19809
|
+
function isProtectedBranch(b) {
|
|
19810
|
+
return b === "main" || b === "master" || b.startsWith("release/");
|
|
19811
|
+
}
|
|
19812
|
+
function evaluateBranch(branch) {
|
|
19813
|
+
if (!isProtectedBranch(branch)) return null;
|
|
19814
|
+
return {
|
|
19815
|
+
id: "ERR_PROTECTED_BRANCH_ACTIVE",
|
|
19816
|
+
category: "branch_safety",
|
|
19817
|
+
status: "fail",
|
|
19818
|
+
message: `Active branch '${branch}' is protected. Direct commits are forbidden.`,
|
|
19819
|
+
remediation: "Switch to a dedicated branch: git checkout -b feat/<CHG-ID>-<slug>",
|
|
19820
|
+
details: { branch }
|
|
19821
|
+
};
|
|
19822
|
+
}
|
|
19823
|
+
async function queryActiveBranch(runner, rootDir) {
|
|
19824
|
+
const res = await runner.execSafe("git", ["symbolic-ref", "--short", "HEAD"], { cwd: rootDir });
|
|
19825
|
+
return (res.stdout || "").trim();
|
|
19826
|
+
}
|
|
19827
|
+
var BranchSafetyCheck = class {
|
|
19828
|
+
runner;
|
|
19829
|
+
constructor(runner) {
|
|
19830
|
+
this.runner = runner || new SafeProcessRunnerAdapter();
|
|
19831
|
+
}
|
|
19832
|
+
async inspect(options) {
|
|
19833
|
+
const findings = [];
|
|
19834
|
+
const rootDir = options.rootDir || process.cwd();
|
|
19835
|
+
try {
|
|
19836
|
+
const branch = await queryActiveBranch(this.runner, rootDir);
|
|
19837
|
+
const f = evaluateBranch(branch);
|
|
19838
|
+
if (f) findings.push(f);
|
|
19839
|
+
} catch {
|
|
19840
|
+
findings.push({
|
|
19841
|
+
id: "ERR_BRANCH_RESOLUTION_FAILED",
|
|
19842
|
+
category: "branch_safety",
|
|
19843
|
+
status: "warn",
|
|
19844
|
+
message: "Could not resolve active git branch."
|
|
19845
|
+
});
|
|
19846
|
+
}
|
|
19847
|
+
const hasFail = findings.some((f) => f.status === "fail");
|
|
19848
|
+
return {
|
|
19849
|
+
category: "branch_safety",
|
|
19850
|
+
title: "Branch Safety & Protected Branch Enforcement",
|
|
19851
|
+
status: hasFail ? "fail" : findings.length > 0 ? "warn" : "pass",
|
|
19852
|
+
findings
|
|
19853
|
+
};
|
|
19854
|
+
}
|
|
19855
|
+
};
|
|
19856
|
+
function hasArtifacts(dirPath) {
|
|
19857
|
+
return fs11.existsSync(dirPath) && fs11.readdirSync(dirPath).length > 0;
|
|
19858
|
+
}
|
|
19859
|
+
var SchemasPdacHealthCheck = class {
|
|
19860
|
+
async inspect(options) {
|
|
19861
|
+
const findings = [];
|
|
19862
|
+
const rootDir = options.rootDir || process.cwd();
|
|
19863
|
+
const ok = hasArtifacts(path13.join(rootDir, "schemas")) && hasArtifacts(path13.join(rootDir, "specs"));
|
|
19864
|
+
if (!ok) {
|
|
19865
|
+
findings.push({
|
|
19866
|
+
id: "ERR_SCHEMAS_DESYNCHRONIZED",
|
|
19867
|
+
category: "schemas_pdac",
|
|
19868
|
+
status: "fail",
|
|
19869
|
+
message: "Project schemas or specs directories are missing, empty, or uninitialized.",
|
|
19870
|
+
remediation: 'Run "aisdlc init" or "aisdlc check --fix" to generate canonical schemas and PDaC specifications.'
|
|
19871
|
+
});
|
|
19872
|
+
}
|
|
19873
|
+
return {
|
|
19874
|
+
category: "schemas_pdac",
|
|
19875
|
+
title: "Schemas & Product Definition as Code (PDaC) Consistency",
|
|
19876
|
+
status: findings.length > 0 ? "fail" : "pass",
|
|
19877
|
+
findings
|
|
19878
|
+
};
|
|
19879
|
+
}
|
|
19880
|
+
};
|
|
19881
|
+
|
|
19882
|
+
// src/doctor/toolchain-check.ts
|
|
19883
|
+
var TOOLS = [
|
|
19884
|
+
{ name: "node", flag: "--version" },
|
|
19885
|
+
{ name: "pnpm", flag: "--version" },
|
|
19886
|
+
{ name: "git", flag: "--version" }
|
|
19887
|
+
];
|
|
19888
|
+
function buildWarning(name, stderr) {
|
|
19889
|
+
return {
|
|
19890
|
+
id: `WARN_TOOLCHAIN_${name.toUpperCase()}_ISSUE`,
|
|
19891
|
+
category: "toolchain",
|
|
19892
|
+
status: "warn",
|
|
19893
|
+
message: `Toolchain binary '${name}' exited with error or returned empty output.`,
|
|
19894
|
+
details: { stderr }
|
|
19895
|
+
};
|
|
19896
|
+
}
|
|
19897
|
+
function buildError(name, err) {
|
|
19898
|
+
return {
|
|
19899
|
+
id: `ERR_TOOLCHAIN_${name.toUpperCase()}_MISSING`,
|
|
19900
|
+
category: "toolchain",
|
|
19901
|
+
status: "fail",
|
|
19902
|
+
message: `Toolchain binary '${name}' is missing: ${err instanceof Error ? err.message : String(err)}`,
|
|
19903
|
+
remediation: `Ensure '${name}' is installed and in PATH.`
|
|
19904
|
+
};
|
|
19905
|
+
}
|
|
19906
|
+
async function probeTool(runner, rootDir, tool) {
|
|
19907
|
+
try {
|
|
19908
|
+
const res = await runner.execSafe(tool.name, [tool.flag], { cwd: rootDir });
|
|
19909
|
+
return res.exitCode === 0 && res.stdout.trim() ? null : buildWarning(tool.name, res.stderr);
|
|
19910
|
+
} catch (err) {
|
|
19911
|
+
return buildError(tool.name, err);
|
|
19912
|
+
}
|
|
19913
|
+
}
|
|
19914
|
+
var ToolchainHealthCheck = class {
|
|
19915
|
+
runner;
|
|
19916
|
+
constructor(runner) {
|
|
19917
|
+
this.runner = runner || new SafeProcessRunnerAdapter();
|
|
19918
|
+
}
|
|
19919
|
+
async inspect(options) {
|
|
19920
|
+
const findings = [];
|
|
19921
|
+
const rootDir = options.rootDir || process.cwd();
|
|
19922
|
+
for (const tool of TOOLS) {
|
|
19923
|
+
const f = await probeTool(this.runner, rootDir, tool);
|
|
19924
|
+
if (f) findings.push(f);
|
|
19925
|
+
}
|
|
19926
|
+
const hasFail = findings.some((f) => f.status === "fail");
|
|
19927
|
+
return {
|
|
19928
|
+
category: "toolchain",
|
|
19929
|
+
title: "Toolchain (Node, PNPM, Git) Availability & Versions",
|
|
19930
|
+
status: hasFail ? "fail" : findings.length > 0 ? "warn" : "pass",
|
|
19931
|
+
findings
|
|
19932
|
+
};
|
|
19933
|
+
}
|
|
19934
|
+
};
|
|
19935
|
+
|
|
19936
|
+
// src/doctor/signature-check.ts
|
|
19937
|
+
async function checkLocalKey(runner, rootDir) {
|
|
19938
|
+
try {
|
|
19939
|
+
const res = await runner.execSafe("git", ["config", "--get", "user.signingkey"], { cwd: rootDir });
|
|
19940
|
+
const key = (res.stdout || "").trim();
|
|
19941
|
+
if (key) {
|
|
19942
|
+
return {
|
|
19943
|
+
id: "INFO_SIGNING_KEY_DETECTED",
|
|
19944
|
+
category: "signing_readiness",
|
|
19945
|
+
status: "pass",
|
|
19946
|
+
message: `Signing key configured: ${sanitizeDlpText(key).sanitizedText}`
|
|
19947
|
+
};
|
|
19948
|
+
}
|
|
19949
|
+
} catch {
|
|
19950
|
+
}
|
|
19951
|
+
return {
|
|
19952
|
+
id: "WARN_LOCAL_KEY_MISSING",
|
|
19953
|
+
category: "signing_readiness",
|
|
19954
|
+
status: "warn",
|
|
19955
|
+
message: "No local GPG or SSH signing key configured in git config (user.signingkey).",
|
|
19956
|
+
remediation: "Configure git signing key: git config user.signingkey <key-id>"
|
|
19957
|
+
};
|
|
19958
|
+
}
|
|
19959
|
+
async function checkRemoteEndpoint(runner, rootDir, timeoutMs) {
|
|
19960
|
+
try {
|
|
19961
|
+
const res = await runner.execSafe("git", ["ls-remote", "--get-url"], {
|
|
19962
|
+
cwd: rootDir,
|
|
19963
|
+
timeout: Math.min(timeoutMs, 2e3)
|
|
19964
|
+
});
|
|
19965
|
+
if (res.exitCode === 0) return null;
|
|
19966
|
+
return {
|
|
19967
|
+
id: "WARN_REMOTE_CHECK_UNAVAILABLE",
|
|
19968
|
+
category: "signing_readiness",
|
|
19969
|
+
status: "warn",
|
|
19970
|
+
message: "Remote repository or signing endpoint could not be reached."
|
|
19971
|
+
};
|
|
19972
|
+
} catch {
|
|
19973
|
+
return {
|
|
19974
|
+
id: "ERR_NETWORK_PROBE_TIMEOUT",
|
|
19975
|
+
category: "signing_readiness",
|
|
19976
|
+
status: "warn",
|
|
19977
|
+
message: "Remote network probe timed out or failed."
|
|
19978
|
+
};
|
|
19979
|
+
}
|
|
19980
|
+
}
|
|
19981
|
+
function sanitizeFinding(f) {
|
|
19982
|
+
f.message = sanitizeDlpText(f.message).sanitizedText;
|
|
19983
|
+
if (!f.details) return;
|
|
19984
|
+
for (const [k, v] of Object.entries(f.details)) {
|
|
19985
|
+
if (typeof v === "string") {
|
|
19986
|
+
f.details[k] = sanitizeDlpText(v).sanitizedText;
|
|
19987
|
+
}
|
|
19988
|
+
}
|
|
19989
|
+
}
|
|
19990
|
+
var SignatureReadinessCheck = class {
|
|
19991
|
+
runner;
|
|
19992
|
+
constructor(runner) {
|
|
19993
|
+
this.runner = runner || new SafeProcessRunnerAdapter();
|
|
19994
|
+
}
|
|
19995
|
+
async inspect(options) {
|
|
19996
|
+
const findings = [];
|
|
19997
|
+
const rootDir = options.rootDir || process.cwd();
|
|
19998
|
+
const isOffline = options.offline || process.env.AI_SDLC_OFFLINE === "1";
|
|
19999
|
+
findings.push(await checkLocalKey(this.runner, rootDir));
|
|
20000
|
+
if (!isOffline) {
|
|
20001
|
+
const remoteFinding = await checkRemoteEndpoint(this.runner, rootDir, options.timeout ?? 2e3);
|
|
20002
|
+
if (remoteFinding) findings.push(remoteFinding);
|
|
20003
|
+
}
|
|
20004
|
+
for (const f of findings) {
|
|
20005
|
+
sanitizeFinding(f);
|
|
20006
|
+
}
|
|
20007
|
+
const hasFail = findings.some((f) => f.status === "fail");
|
|
20008
|
+
const hasWarn = findings.some((f) => f.status === "warn");
|
|
20009
|
+
return {
|
|
20010
|
+
category: "signing_readiness",
|
|
20011
|
+
title: "Cryptographic Signing Readiness & Key Integrity",
|
|
20012
|
+
status: hasFail ? "fail" : hasWarn ? "warn" : "pass",
|
|
20013
|
+
findings
|
|
20014
|
+
};
|
|
20015
|
+
}
|
|
20016
|
+
};
|
|
20017
|
+
|
|
20018
|
+
// src/doctor/reporter.ts
|
|
20019
|
+
function formatFinding(f) {
|
|
20020
|
+
const icon = f.status === "pass" ? "\u2139\uFE0F" : f.status === "warn" ? "\u26A0\uFE0F" : "\u274C";
|
|
20021
|
+
const out = [` ${icon} [${f.id}] ${f.message}`];
|
|
20022
|
+
if (f.remediation) {
|
|
20023
|
+
out.push(` Remediation: ${f.remediation}`);
|
|
20024
|
+
}
|
|
20025
|
+
return out;
|
|
20026
|
+
}
|
|
20027
|
+
function formatCategory(cat) {
|
|
20028
|
+
const icon = cat.status === "pass" ? "\u2705" : cat.status === "warn" ? "\u26A0\uFE0F" : "\u274C";
|
|
20029
|
+
const out = [`${icon} [${cat.category.toUpperCase()}] ${cat.title}`];
|
|
20030
|
+
if (cat.findings.length === 0) {
|
|
20031
|
+
out.push(" No issues detected.");
|
|
20032
|
+
} else {
|
|
20033
|
+
for (const f of cat.findings) {
|
|
20034
|
+
out.push(...formatFinding(f));
|
|
20035
|
+
}
|
|
20036
|
+
}
|
|
20037
|
+
out.push("");
|
|
20038
|
+
return out;
|
|
20039
|
+
}
|
|
20040
|
+
var DoctorReporter = class {
|
|
20041
|
+
formatTerminal(report) {
|
|
20042
|
+
const icon = report.overallStatus === "pass" ? "\u2705" : report.overallStatus === "warn" ? "\u26A0\uFE0F" : "\u274C";
|
|
20043
|
+
const lines = [
|
|
20044
|
+
"\n=== AI-SDLC Doctor Environment Diagnostics ===",
|
|
20045
|
+
`Timestamp: ${report.timestamp}`,
|
|
20046
|
+
`Overall Status: ${icon} ${report.overallStatus.toUpperCase()} (Exit Code: ${report.exitCode})
|
|
20047
|
+
`
|
|
20048
|
+
];
|
|
20049
|
+
for (const cat of report.categories) {
|
|
20050
|
+
lines.push(...formatCategory(cat));
|
|
20051
|
+
}
|
|
20052
|
+
if (report.remediations.length > 0) {
|
|
20053
|
+
lines.push("=== Suggested Remediations ===");
|
|
20054
|
+
for (const rem of report.remediations) {
|
|
20055
|
+
lines.push(`- ${rem}`);
|
|
20056
|
+
}
|
|
20057
|
+
lines.push("");
|
|
20058
|
+
}
|
|
20059
|
+
return lines.join("\n");
|
|
20060
|
+
}
|
|
20061
|
+
formatJson(report) {
|
|
20062
|
+
return JSON.stringify(report, null, 2);
|
|
20063
|
+
}
|
|
20064
|
+
};
|
|
20065
|
+
|
|
20066
|
+
// src/doctor/doctor-service.ts
|
|
20067
|
+
var DoctorOrchestrator = class {
|
|
20068
|
+
hooksCheck = new GitHooksHealthCheck();
|
|
20069
|
+
branchCheck = new BranchSafetyCheck();
|
|
20070
|
+
schemasCheck = new SchemasPdacHealthCheck();
|
|
20071
|
+
toolchainCheck = new ToolchainHealthCheck();
|
|
20072
|
+
signatureCheck = new SignatureReadinessCheck();
|
|
20073
|
+
async runAll(options) {
|
|
20074
|
+
const categories = [];
|
|
20075
|
+
categories.push(await this.hooksCheck.inspect(options));
|
|
20076
|
+
categories.push(await this.branchCheck.inspect(options));
|
|
20077
|
+
categories.push(await this.schemasCheck.inspect(options));
|
|
20078
|
+
categories.push(await this.toolchainCheck.inspect(options));
|
|
20079
|
+
categories.push(await this.signatureCheck.inspect(options));
|
|
20080
|
+
return categories;
|
|
20081
|
+
}
|
|
20082
|
+
};
|
|
20083
|
+
var DoctorService = class {
|
|
20084
|
+
orchestrator = new DoctorOrchestrator();
|
|
20085
|
+
async diagnose(options) {
|
|
20086
|
+
const categories = await this.runCategoryChecks(options);
|
|
20087
|
+
const remediations = this.collectRemediations(categories);
|
|
20088
|
+
let overallStatus = "pass";
|
|
20089
|
+
let exitCode = 0;
|
|
20090
|
+
const hasFail = categories.some((c) => c.status === "fail");
|
|
20091
|
+
const hasWarn = categories.some((c) => c.status === "warn");
|
|
20092
|
+
if (hasFail) {
|
|
20093
|
+
overallStatus = "fail";
|
|
20094
|
+
exitCode = 2;
|
|
20095
|
+
} else if (hasWarn) {
|
|
20096
|
+
overallStatus = "warn";
|
|
20097
|
+
exitCode = options.strict ? 2 : 1;
|
|
20098
|
+
}
|
|
20099
|
+
const report = {
|
|
20100
|
+
overallStatus,
|
|
20101
|
+
exitCode,
|
|
20102
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20103
|
+
categories,
|
|
20104
|
+
remediations
|
|
20105
|
+
};
|
|
20106
|
+
return sanitizeDlpPayload(report);
|
|
20107
|
+
}
|
|
20108
|
+
async runCategoryChecks(options) {
|
|
20109
|
+
return this.orchestrator.runAll(options);
|
|
20110
|
+
}
|
|
20111
|
+
collectRemediations(categories) {
|
|
20112
|
+
const rems = /* @__PURE__ */ new Set();
|
|
20113
|
+
for (const cat of categories) {
|
|
20114
|
+
for (const finding of cat.findings) {
|
|
20115
|
+
if (finding.remediation) {
|
|
20116
|
+
rems.add(finding.remediation);
|
|
20117
|
+
}
|
|
20118
|
+
}
|
|
20119
|
+
}
|
|
20120
|
+
return Array.from(rems);
|
|
20121
|
+
}
|
|
20122
|
+
};
|
|
20123
|
+
var GOVERNED_DIR_PREFIXES = ["schemas" + path13.sep, "templates" + path13.sep, ".backup" + path13.sep];
|
|
20124
|
+
var GOVERNED_ROOT_FILES = /* @__PURE__ */ new Set([
|
|
20125
|
+
"quality-policy.yaml",
|
|
20126
|
+
"license-policy.yaml",
|
|
20127
|
+
"privacy-policy.yaml",
|
|
20128
|
+
"dlp-policy.yaml"
|
|
20129
|
+
]);
|
|
20130
|
+
function validateRawInputs(repoRoot, targetPath) {
|
|
20131
|
+
if (!repoRoot) {
|
|
20132
|
+
throw new Error("ERR_PATH_TRAVERSAL_DETECTED: repoRoot is required");
|
|
20133
|
+
}
|
|
20134
|
+
if (!targetPath || typeof targetPath !== "string" || targetPath.includes("\0")) {
|
|
20135
|
+
throw new Error("ERR_PATH_TRAVERSAL_DETECTED: targetPath is invalid or contains null byte");
|
|
20136
|
+
}
|
|
20137
|
+
}
|
|
20138
|
+
function checkSiblingAndEscape(resolvedRoot, resolvedTarget) {
|
|
20139
|
+
const rel = path13.relative(resolvedRoot, resolvedTarget);
|
|
20140
|
+
const escapes = rel.startsWith("..") || path13.isAbsolute(rel);
|
|
20141
|
+
if (escapes) {
|
|
20142
|
+
if (resolvedTarget.startsWith(resolvedRoot) && !resolvedTarget.startsWith(resolvedRoot + path13.sep)) {
|
|
20143
|
+
throw new Error("ERR_PATH_OUTSIDE_REPO_ROOT: Target path points to sibling directory");
|
|
20144
|
+
}
|
|
20145
|
+
throw new Error("ERR_PATH_TRAVERSAL_DETECTED: Target path escapes repository root");
|
|
20146
|
+
}
|
|
20147
|
+
if (resolvedTarget !== resolvedRoot && !resolvedTarget.startsWith(resolvedRoot + path13.sep)) {
|
|
20148
|
+
throw new Error("ERR_PATH_OUTSIDE_REPO_ROOT: Target path is outside repository root");
|
|
20149
|
+
}
|
|
20150
|
+
}
|
|
20151
|
+
function resolveRealRoot(resolvedRoot) {
|
|
20152
|
+
try {
|
|
20153
|
+
return fs11.existsSync(resolvedRoot) ? fs11.realpathSync(resolvedRoot) : resolvedRoot;
|
|
20154
|
+
} catch {
|
|
20155
|
+
return resolvedRoot;
|
|
20156
|
+
}
|
|
20157
|
+
}
|
|
20158
|
+
function checkSymlinkEscapesRealRoot(rootReal, absoluteTarget) {
|
|
20159
|
+
if (!fs11.existsSync(absoluteTarget)) return;
|
|
20160
|
+
try {
|
|
20161
|
+
const lstat = fs11.lstatSync(absoluteTarget);
|
|
20162
|
+
if (!lstat.isSymbolicLink()) return;
|
|
20163
|
+
const real = fs11.realpathSync(absoluteTarget);
|
|
20164
|
+
const rel = path13.relative(rootReal, real);
|
|
20165
|
+
const isEscaping = rel.startsWith("..") || path13.isAbsolute(rel) || real !== rootReal && !real.startsWith(rootReal + path13.sep);
|
|
20166
|
+
if (isEscaping) {
|
|
20167
|
+
throw new Error("ERR_SYMLINK_ESCAPE_DETECTED: Symlink targets path outside repository root");
|
|
20168
|
+
}
|
|
20169
|
+
} catch (err) {
|
|
20170
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
20171
|
+
if (errorMsg.includes("ERR_SYMLINK_ESCAPE_DETECTED")) {
|
|
20172
|
+
throw err;
|
|
20173
|
+
}
|
|
20174
|
+
}
|
|
20175
|
+
}
|
|
20176
|
+
var FileSystemJailAdapter = class {
|
|
20177
|
+
resolveSafe(repoRoot, targetPath) {
|
|
20178
|
+
validateRawInputs(repoRoot, targetPath);
|
|
20179
|
+
const resolvedRoot = path13.resolve(repoRoot);
|
|
20180
|
+
const resolvedTarget = path13.resolve(resolvedRoot, targetPath);
|
|
20181
|
+
checkSiblingAndEscape(resolvedRoot, resolvedTarget);
|
|
20182
|
+
return resolvedTarget;
|
|
20183
|
+
}
|
|
20184
|
+
async readFileSafe(repoRoot, relativePath) {
|
|
20185
|
+
const safePath = this.resolveSafe(repoRoot, relativePath);
|
|
20186
|
+
await this.verifySymlinkSafe(repoRoot, safePath);
|
|
20187
|
+
return fs11.promises.readFile(safePath, "utf-8");
|
|
20188
|
+
}
|
|
20189
|
+
async writeFileSafe(repoRoot, relativePath, content) {
|
|
20190
|
+
const safePath = this.resolveSafe(repoRoot, relativePath);
|
|
20191
|
+
await this.verifySymlinkSafe(repoRoot, safePath);
|
|
20192
|
+
const resolvedRoot = path13.resolve(repoRoot);
|
|
20193
|
+
const rel = path13.relative(resolvedRoot, safePath);
|
|
20194
|
+
const isGovernedDir = GOVERNED_DIR_PREFIXES.some((p) => rel.startsWith(p) || rel === p.slice(0, -1));
|
|
20195
|
+
const isGovernedFile = GOVERNED_ROOT_FILES.has(rel) || rel.startsWith(".backup" + path13.sep);
|
|
20196
|
+
if (!isGovernedDir && !isGovernedFile) {
|
|
20197
|
+
throw new Error(`ERR_UNGOVERNED_TARGET_PATH: Path "${rel}" is not an allowed governed directory or policy file`);
|
|
20198
|
+
}
|
|
20199
|
+
const dir = path13.dirname(safePath);
|
|
20200
|
+
if (!fs11.existsSync(dir)) {
|
|
20201
|
+
fs11.mkdirSync(dir, { recursive: true });
|
|
20202
|
+
}
|
|
20203
|
+
await fs11.promises.writeFile(safePath, content, "utf-8");
|
|
20204
|
+
}
|
|
20205
|
+
async existsSafe(repoRoot, relativePath) {
|
|
20206
|
+
const safePath = this.resolveSafe(repoRoot, relativePath);
|
|
20207
|
+
return fs11.existsSync(safePath);
|
|
20208
|
+
}
|
|
20209
|
+
async ensureDirectorySafe(repoRoot, relativeDir) {
|
|
20210
|
+
const safePath = this.resolveSafe(repoRoot, relativeDir);
|
|
20211
|
+
if (!fs11.existsSync(safePath)) {
|
|
20212
|
+
fs11.mkdirSync(safePath, { recursive: true });
|
|
20213
|
+
}
|
|
20214
|
+
}
|
|
20215
|
+
async isSymlinkSafe(repoRoot, relativePath) {
|
|
20216
|
+
const safePath = this.resolveSafe(repoRoot, relativePath);
|
|
20217
|
+
try {
|
|
20218
|
+
const stat = await fs11.promises.lstat(safePath);
|
|
20219
|
+
return stat.isSymbolicLink();
|
|
20220
|
+
} catch {
|
|
20221
|
+
return false;
|
|
20222
|
+
}
|
|
20223
|
+
}
|
|
20224
|
+
async verifySymlinkSafe(repoRoot, absoluteTarget) {
|
|
20225
|
+
const resolvedRoot = path13.resolve(repoRoot);
|
|
20226
|
+
const rootReal = resolveRealRoot(resolvedRoot);
|
|
20227
|
+
checkSymlinkEscapesRealRoot(rootReal, absoluteTarget);
|
|
20228
|
+
}
|
|
20229
|
+
};
|
|
20230
|
+
var DiffDetector = class {
|
|
20231
|
+
/**
|
|
20232
|
+
* Normalizes content by converting Windows CRLF (\r\n) to Unix LF (\n)
|
|
20233
|
+
* and computes a lowercase hex SHA-256 digest.
|
|
20234
|
+
*/
|
|
20235
|
+
computeDigest(content) {
|
|
20236
|
+
const normalized = content.replace(/\r\n/g, "\n");
|
|
20237
|
+
return crypto3.createHash("sha256").update(normalized, "utf-8").digest("hex");
|
|
20238
|
+
}
|
|
20239
|
+
/**
|
|
20240
|
+
* Compares two content strings for deterministic equality under LF normalization.
|
|
20241
|
+
*/
|
|
20242
|
+
isEqual(contentA, contentB) {
|
|
20243
|
+
return this.computeDigest(contentA) === this.computeDigest(contentB);
|
|
20244
|
+
}
|
|
20245
|
+
};
|
|
20246
|
+
|
|
20247
|
+
// src/migrate/override-analyzer.ts
|
|
20248
|
+
var OverrideAnalyzer = class {
|
|
20249
|
+
diffDetector = new DiffDetector();
|
|
20250
|
+
classify(input) {
|
|
20251
|
+
const { currentContent, targetContent, baseContent } = input;
|
|
20252
|
+
if (this.isCorruptDiscrepancy(currentContent)) {
|
|
20253
|
+
return "CONFLICT";
|
|
20254
|
+
}
|
|
20255
|
+
const currentEqualsTarget = this.diffDetector.isEqual(currentContent, targetContent);
|
|
20256
|
+
if (currentEqualsTarget) {
|
|
20257
|
+
return "UP_TO_DATE";
|
|
20258
|
+
}
|
|
20259
|
+
const currentEqualsBase = this.diffDetector.isEqual(currentContent, baseContent);
|
|
20260
|
+
if (currentEqualsBase) {
|
|
20261
|
+
return "CLEAN_UPDATE";
|
|
20262
|
+
}
|
|
20263
|
+
return "LOCAL_OVERRIDE_PRESERVED";
|
|
20264
|
+
}
|
|
20265
|
+
isCorruptDiscrepancy(content) {
|
|
20266
|
+
if (!content) return false;
|
|
20267
|
+
const trimmed = content.trim();
|
|
20268
|
+
if (trimmed.startsWith("corrupted: [invalid yaml")) {
|
|
20269
|
+
return true;
|
|
20270
|
+
}
|
|
20271
|
+
return false;
|
|
20272
|
+
}
|
|
20273
|
+
};
|
|
20274
|
+
|
|
20275
|
+
// src/migrate/policy-ratchet.ts
|
|
20276
|
+
function mergeCoverage(localCov, upstreamCov, allowDowngrade) {
|
|
20277
|
+
if (!localCov && !upstreamCov) return void 0;
|
|
20278
|
+
const result = { ...upstreamCov };
|
|
20279
|
+
const localMin = localCov?.min;
|
|
20280
|
+
const upstreamMin = upstreamCov?.min;
|
|
20281
|
+
if (localMin !== void 0 && upstreamMin !== void 0) {
|
|
20282
|
+
if (upstreamMin < localMin && allowDowngrade === false) {
|
|
20283
|
+
throw new Error("ERR_SECURITY_POLICY_DOWNGRADE_BLOCKED: Attempting to downgrade coverage threshold");
|
|
20284
|
+
}
|
|
20285
|
+
result.min = Math.max(localMin, upstreamMin);
|
|
20286
|
+
} else if (localMin !== void 0) {
|
|
20287
|
+
result.min = localMin;
|
|
20288
|
+
}
|
|
20289
|
+
return result;
|
|
20290
|
+
}
|
|
20291
|
+
function mergeComplexity(localComp, upstreamComp) {
|
|
20292
|
+
if (!localComp && !upstreamComp) return void 0;
|
|
20293
|
+
const result = { ...upstreamComp };
|
|
20294
|
+
const localCyclo = localComp?.maxCyclomatic;
|
|
20295
|
+
const upstreamCyclo = upstreamComp?.maxCyclomatic;
|
|
20296
|
+
if (localCyclo !== void 0 && upstreamCyclo !== void 0) {
|
|
20297
|
+
result.maxCyclomatic = Math.min(localCyclo, upstreamCyclo);
|
|
20298
|
+
} else if (localCyclo !== void 0) {
|
|
20299
|
+
result.maxCyclomatic = localCyclo;
|
|
20300
|
+
}
|
|
20301
|
+
return result;
|
|
20302
|
+
}
|
|
20303
|
+
function mergeLicenses(localLicenses, upstreamLicenses) {
|
|
20304
|
+
if (!localLicenses?.blocked && !upstreamLicenses?.blocked) return upstreamLicenses;
|
|
20305
|
+
const upstreamBlocked = (upstreamLicenses?.blocked || []).map((l) => l.toUpperCase());
|
|
20306
|
+
const localBlocked = (localLicenses?.blocked || []).map((l) => l.toUpperCase());
|
|
20307
|
+
return {
|
|
20308
|
+
...upstreamLicenses,
|
|
20309
|
+
blocked: Array.from(/* @__PURE__ */ new Set([...upstreamBlocked, ...localBlocked]))
|
|
20310
|
+
};
|
|
20311
|
+
}
|
|
20312
|
+
function mergeDlpRules(localRules, upstreamRules) {
|
|
20313
|
+
if (!localRules) return upstreamRules;
|
|
20314
|
+
const mergedRules = [...upstreamRules || []];
|
|
20315
|
+
const existingIds = new Set(mergedRules.map((r) => r.id));
|
|
20316
|
+
for (const rule of localRules) {
|
|
20317
|
+
if (!existingIds.has(rule.id)) {
|
|
20318
|
+
mergedRules.push(rule);
|
|
20319
|
+
existingIds.add(rule.id);
|
|
20320
|
+
}
|
|
20321
|
+
}
|
|
20322
|
+
return mergedRules;
|
|
20323
|
+
}
|
|
20324
|
+
function validateNumericField(val, fieldName) {
|
|
20325
|
+
if (val !== void 0 && (typeof val !== "number" || Number.isNaN(val))) {
|
|
20326
|
+
throw new Error(`ERR_INVALID_POLICY_FORMAT: ${fieldName} must be a valid number`);
|
|
20327
|
+
}
|
|
20328
|
+
}
|
|
20329
|
+
var PolicyRatchetEnforcer = class {
|
|
20330
|
+
enforceRatchet(localPolicy, upstreamPolicy, options = {}) {
|
|
20331
|
+
this.validatePolicyStructure(localPolicy);
|
|
20332
|
+
this.validatePolicyStructure(upstreamPolicy);
|
|
20333
|
+
if (options.allowPolicyDowngrade) {
|
|
20334
|
+
return JSON.parse(JSON.stringify(upstreamPolicy));
|
|
20335
|
+
}
|
|
20336
|
+
const merged = JSON.parse(JSON.stringify(upstreamPolicy));
|
|
20337
|
+
if (localPolicy.quality) {
|
|
20338
|
+
if (!merged.quality) merged.quality = {};
|
|
20339
|
+
merged.quality.coverage = mergeCoverage(localPolicy.quality.coverage, merged.quality.coverage, options.allowPolicyDowngrade);
|
|
20340
|
+
merged.quality.complexity = mergeComplexity(localPolicy.quality.complexity, merged.quality.complexity);
|
|
20341
|
+
}
|
|
20342
|
+
if (localPolicy.licenses) {
|
|
20343
|
+
merged.licenses = mergeLicenses(localPolicy.licenses, merged.licenses);
|
|
20344
|
+
}
|
|
20345
|
+
if (localPolicy.rules) {
|
|
20346
|
+
merged.rules = mergeDlpRules(localPolicy.rules, merged.rules);
|
|
20347
|
+
}
|
|
20348
|
+
return merged;
|
|
20349
|
+
}
|
|
20350
|
+
validatePolicyStructure(policy) {
|
|
20351
|
+
if (!policy || typeof policy !== "object") return;
|
|
20352
|
+
const q = policy.quality;
|
|
20353
|
+
if (q) {
|
|
20354
|
+
validateNumericField(q.coverage?.min, "coverage.min");
|
|
20355
|
+
validateNumericField(q.complexity?.maxCyclomatic, "complexity.maxCyclomatic");
|
|
20356
|
+
}
|
|
20357
|
+
}
|
|
20358
|
+
};
|
|
20359
|
+
var TimestampedBackupManagerAdapter = class {
|
|
20360
|
+
diffDetector = new DiffDetector();
|
|
20361
|
+
async createBackup(repoRoot, filesToBackup) {
|
|
20362
|
+
const resolvedRoot = path13.resolve(repoRoot);
|
|
20363
|
+
const gitignorePath = path13.join(resolvedRoot, ".gitignore");
|
|
20364
|
+
this.ensureGitignoreRule(gitignorePath);
|
|
20365
|
+
const timestamp = Date.now();
|
|
20366
|
+
const randomSuffix = crypto3.randomBytes(4).toString("hex").slice(0, 6);
|
|
20367
|
+
const backupDirName = `migration-${timestamp}-${randomSuffix}`;
|
|
20368
|
+
const backupRoot = path13.join(resolvedRoot, ".backup");
|
|
20369
|
+
const targetBackupDir = path13.join(backupRoot, backupDirName);
|
|
20370
|
+
fs11.mkdirSync(targetBackupDir, { recursive: true, mode: 448 });
|
|
20371
|
+
const manifestEntries = [];
|
|
20372
|
+
for (const relPath of filesToBackup) {
|
|
20373
|
+
const srcFile = path13.resolve(resolvedRoot, relPath);
|
|
20374
|
+
if (fs11.existsSync(srcFile)) {
|
|
20375
|
+
const destFile = path13.resolve(targetBackupDir, relPath);
|
|
20376
|
+
const destDir = path13.dirname(destFile);
|
|
20377
|
+
if (!fs11.existsSync(destDir)) {
|
|
20378
|
+
fs11.mkdirSync(destDir, { recursive: true });
|
|
20379
|
+
}
|
|
20380
|
+
const content = fs11.readFileSync(srcFile, "utf-8");
|
|
20381
|
+
fs11.writeFileSync(destFile, content, "utf-8");
|
|
20382
|
+
const digest = this.diffDetector.computeDigest(content);
|
|
20383
|
+
const stats = fs11.statSync(destFile);
|
|
20384
|
+
manifestEntries.push({
|
|
20385
|
+
path: relPath,
|
|
20386
|
+
sha256: digest,
|
|
20387
|
+
bytes: stats.size
|
|
20388
|
+
});
|
|
20389
|
+
}
|
|
20390
|
+
}
|
|
20391
|
+
const manifest = {
|
|
20392
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20393
|
+
files: manifestEntries
|
|
20394
|
+
};
|
|
20395
|
+
fs11.writeFileSync(
|
|
20396
|
+
path13.join(targetBackupDir, "manifest.json"),
|
|
20397
|
+
JSON.stringify(manifest, null, 2),
|
|
20398
|
+
"utf-8"
|
|
20399
|
+
);
|
|
20400
|
+
return targetBackupDir;
|
|
20401
|
+
}
|
|
20402
|
+
async restoreBackup(repoRoot, backupPath) {
|
|
20403
|
+
const resolvedRoot = path13.resolve(repoRoot);
|
|
20404
|
+
const manifestPath = path13.join(backupPath, "manifest.json");
|
|
20405
|
+
if (!fs11.existsSync(manifestPath)) {
|
|
20406
|
+
throw new Error(`ERR_BACKUP_MANIFEST_MISSING: Backup at ${backupPath} has no manifest.json`);
|
|
20407
|
+
}
|
|
20408
|
+
const manifest = JSON.parse(fs11.readFileSync(manifestPath, "utf-8"));
|
|
20409
|
+
for (const entry of manifest.files) {
|
|
20410
|
+
const backupFile = path13.join(backupPath, entry.path);
|
|
20411
|
+
const targetFile = path13.join(resolvedRoot, entry.path);
|
|
20412
|
+
if (fs11.existsSync(backupFile)) {
|
|
20413
|
+
const targetDir = path13.dirname(targetFile);
|
|
20414
|
+
if (!fs11.existsSync(targetDir)) {
|
|
20415
|
+
fs11.mkdirSync(targetDir, { recursive: true });
|
|
20416
|
+
}
|
|
20417
|
+
fs11.copyFileSync(backupFile, targetFile);
|
|
20418
|
+
}
|
|
20419
|
+
}
|
|
20420
|
+
}
|
|
20421
|
+
ensureGitignoreRule(gitignorePath) {
|
|
20422
|
+
if (fs11.existsSync(gitignorePath)) {
|
|
20423
|
+
const gitignore = fs11.readFileSync(gitignorePath, "utf-8");
|
|
20424
|
+
const lines = gitignore.split(/\r?\n/);
|
|
20425
|
+
const hasBackup = lines.some((l) => l.trim() === ".backup/" || l.trim() === ".backup" || l.trim() === "/.backup/");
|
|
20426
|
+
if (!hasBackup) {
|
|
20427
|
+
const trailingNewline = gitignore.endsWith("\n") ? "" : "\n";
|
|
20428
|
+
fs11.writeFileSync(gitignorePath, `${gitignore}${trailingNewline}.backup/
|
|
20429
|
+
`, "utf-8");
|
|
20430
|
+
}
|
|
20431
|
+
} else {
|
|
20432
|
+
fs11.writeFileSync(gitignorePath, ".backup/\n", "utf-8");
|
|
20433
|
+
}
|
|
20434
|
+
}
|
|
20435
|
+
};
|
|
20436
|
+
function copyFileSafeSync(src, dest) {
|
|
20437
|
+
const destDir = path13.dirname(dest);
|
|
20438
|
+
if (!fs11.existsSync(destDir)) {
|
|
20439
|
+
fs11.mkdirSync(destDir, { recursive: true });
|
|
20440
|
+
}
|
|
20441
|
+
fs11.copyFileSync(src, dest);
|
|
20442
|
+
}
|
|
20443
|
+
function restoreFromManifestSync(backupPath, resolvedRoot) {
|
|
20444
|
+
const manifestFile = path13.join(backupPath, "manifest.json");
|
|
20445
|
+
if (!fs11.existsSync(manifestFile)) return;
|
|
20446
|
+
try {
|
|
20447
|
+
const manifest = JSON.parse(fs11.readFileSync(manifestFile, "utf-8"));
|
|
20448
|
+
for (const entry of manifest.files || []) {
|
|
20449
|
+
const backedUpFile = path13.join(backupPath, entry.path);
|
|
20450
|
+
const targetFile = path13.join(resolvedRoot, entry.path);
|
|
20451
|
+
if (fs11.existsSync(backedUpFile)) {
|
|
20452
|
+
copyFileSafeSync(backedUpFile, targetFile);
|
|
20453
|
+
}
|
|
20454
|
+
}
|
|
20455
|
+
} catch {
|
|
20456
|
+
}
|
|
20457
|
+
}
|
|
20458
|
+
function restoreDirRecursiveSync(dir, resolvedRoot, baseBackupDir) {
|
|
20459
|
+
const entries = fs11.readdirSync(dir, { withFileTypes: true });
|
|
20460
|
+
for (const entry of entries) {
|
|
20461
|
+
const fullPath = path13.join(dir, entry.name);
|
|
20462
|
+
if (entry.isDirectory()) {
|
|
20463
|
+
restoreDirRecursiveSync(fullPath, resolvedRoot, baseBackupDir);
|
|
20464
|
+
} else if (entry.isFile()) {
|
|
20465
|
+
const rel = path13.relative(baseBackupDir, fullPath);
|
|
20466
|
+
copyFileSafeSync(fullPath, path13.join(resolvedRoot, rel));
|
|
20467
|
+
}
|
|
20468
|
+
}
|
|
20469
|
+
}
|
|
20470
|
+
var TransactionManager = class {
|
|
20471
|
+
activeStagingDir = null;
|
|
20472
|
+
stagedFiles = /* @__PURE__ */ new Map();
|
|
20473
|
+
boundSignalHandlers = {};
|
|
20474
|
+
async begin(repoRoot) {
|
|
20475
|
+
const resolvedRoot = path13.resolve(repoRoot);
|
|
20476
|
+
const stagingUuid = crypto3.randomUUID();
|
|
20477
|
+
const stagingDir = path13.join(resolvedRoot, ".backup", `.staging-${stagingUuid}`);
|
|
20478
|
+
fs11.mkdirSync(stagingDir, { recursive: true, mode: 448 });
|
|
20479
|
+
this.activeStagingDir = stagingDir;
|
|
20480
|
+
this.stagedFiles.clear();
|
|
20481
|
+
this.registerSignalHandlers(resolvedRoot);
|
|
20482
|
+
return stagingDir;
|
|
20483
|
+
}
|
|
20484
|
+
async stageFile(_repoRoot, relativePath, content) {
|
|
20485
|
+
if (!this.activeStagingDir) {
|
|
20486
|
+
throw new Error("ERR_NO_ACTIVE_TRANSACTION: Transaction must be started with begin()");
|
|
20487
|
+
}
|
|
20488
|
+
const stagedTarget = path13.join(this.activeStagingDir, relativePath);
|
|
20489
|
+
const stagedDir = path13.dirname(stagedTarget);
|
|
20490
|
+
if (!fs11.existsSync(stagedDir)) {
|
|
20491
|
+
fs11.mkdirSync(stagedDir, { recursive: true });
|
|
20492
|
+
}
|
|
20493
|
+
fs11.writeFileSync(stagedTarget, content, "utf-8");
|
|
20494
|
+
this.stagedFiles.set(relativePath, content);
|
|
20495
|
+
}
|
|
20496
|
+
async commit(repoRoot) {
|
|
20497
|
+
if (!this.activeStagingDir) {
|
|
20498
|
+
throw new Error("ERR_NO_ACTIVE_TRANSACTION: No transaction to commit");
|
|
20499
|
+
}
|
|
20500
|
+
const resolvedRoot = path13.resolve(repoRoot);
|
|
20501
|
+
try {
|
|
20502
|
+
for (const [relPath, content] of this.stagedFiles.entries()) {
|
|
20503
|
+
this.validateStagedFile(relPath, content);
|
|
20504
|
+
}
|
|
20505
|
+
for (const [relPath] of this.stagedFiles.entries()) {
|
|
20506
|
+
copyFileSafeSync(path13.join(this.activeStagingDir, relPath), path13.join(resolvedRoot, relPath));
|
|
20507
|
+
}
|
|
20508
|
+
this.cleanupStaging();
|
|
20509
|
+
} catch (err) {
|
|
20510
|
+
await this.rollback(repoRoot);
|
|
20511
|
+
throw err;
|
|
20512
|
+
} finally {
|
|
20513
|
+
this.unregisterSignalHandlers();
|
|
20514
|
+
}
|
|
20515
|
+
}
|
|
20516
|
+
async rollback(_repoRoot) {
|
|
20517
|
+
this.cleanupStaging();
|
|
20518
|
+
this.unregisterSignalHandlers();
|
|
20519
|
+
}
|
|
20520
|
+
rollbackSync(repoRoot, backupPath) {
|
|
20521
|
+
const resolvedRoot = path13.resolve(repoRoot);
|
|
20522
|
+
if (backupPath && fs11.existsSync(backupPath)) {
|
|
20523
|
+
const manifestFile = path13.join(backupPath, "manifest.json");
|
|
20524
|
+
if (fs11.existsSync(manifestFile)) {
|
|
20525
|
+
restoreFromManifestSync(backupPath, resolvedRoot);
|
|
20526
|
+
} else {
|
|
20527
|
+
restoreDirRecursiveSync(backupPath, resolvedRoot, backupPath);
|
|
20528
|
+
}
|
|
20529
|
+
}
|
|
20530
|
+
this.cleanupStaging();
|
|
20531
|
+
this.unregisterSignalHandlers();
|
|
20532
|
+
}
|
|
20533
|
+
validateStagedFile(relPath, content) {
|
|
20534
|
+
if (content.length === 0) {
|
|
20535
|
+
throw new Error(`ERR_MIGRATION_VALIDATION_FAILED: Staged file ${relPath} is empty`);
|
|
20536
|
+
}
|
|
20537
|
+
if (relPath.endsWith(".json")) {
|
|
20538
|
+
try {
|
|
20539
|
+
JSON.parse(content);
|
|
20540
|
+
} catch (e) {
|
|
20541
|
+
const errorMsg = e instanceof Error ? e.message : String(e);
|
|
20542
|
+
throw new Error(`ERR_MIGRATION_VALIDATION_FAILED: Invalid JSON in ${relPath}: ${errorMsg}`);
|
|
20543
|
+
}
|
|
20544
|
+
}
|
|
20545
|
+
}
|
|
20546
|
+
cleanupStaging() {
|
|
20547
|
+
if (this.activeStagingDir && fs11.existsSync(this.activeStagingDir)) {
|
|
20548
|
+
try {
|
|
20549
|
+
fs11.rmSync(this.activeStagingDir, { recursive: true, force: true });
|
|
20550
|
+
} catch {
|
|
20551
|
+
}
|
|
20552
|
+
}
|
|
20553
|
+
this.activeStagingDir = null;
|
|
20554
|
+
this.stagedFiles.clear();
|
|
20555
|
+
}
|
|
20556
|
+
registerSignalHandlers(repoRoot) {
|
|
20557
|
+
const signals = ["SIGINT", "SIGTERM"];
|
|
20558
|
+
for (const sig of signals) {
|
|
20559
|
+
const handler = () => {
|
|
20560
|
+
this.rollbackSync(repoRoot);
|
|
20561
|
+
process.exit(2);
|
|
20562
|
+
};
|
|
20563
|
+
this.boundSignalHandlers[sig] = handler;
|
|
20564
|
+
try {
|
|
20565
|
+
process.once(sig, handler);
|
|
20566
|
+
} catch {
|
|
20567
|
+
}
|
|
20568
|
+
}
|
|
20569
|
+
}
|
|
20570
|
+
unregisterSignalHandlers() {
|
|
20571
|
+
for (const sig of Object.keys(this.boundSignalHandlers)) {
|
|
20572
|
+
try {
|
|
20573
|
+
process.removeListener(sig, this.boundSignalHandlers[sig]);
|
|
20574
|
+
} catch {
|
|
20575
|
+
}
|
|
20576
|
+
}
|
|
20577
|
+
this.boundSignalHandlers = {};
|
|
20578
|
+
}
|
|
20579
|
+
};
|
|
20580
|
+
|
|
20581
|
+
// src/migrate/reporter.ts
|
|
20582
|
+
var MigrationReporter = class {
|
|
20583
|
+
formatTerminal(result) {
|
|
20584
|
+
const lines = [];
|
|
20585
|
+
lines.push("=== AI-SDLC Migration Report ===");
|
|
20586
|
+
lines.push(`Status: ${result.success ? "SUCCESS" : "FAILED"} (Exit Code: ${result.exitCode})`);
|
|
20587
|
+
lines.push(`Summary:`);
|
|
20588
|
+
lines.push(` - Up to date: ${result.summary.upToDate}`);
|
|
20589
|
+
lines.push(` - Clean updated: ${result.summary.cleanUpdated}`);
|
|
20590
|
+
lines.push(` - Local overrides preserved: ${result.summary.overridesPreserved}`);
|
|
20591
|
+
lines.push(` - Conflicts: ${result.summary.conflicts}`);
|
|
20592
|
+
if (result.backupPath) {
|
|
20593
|
+
lines.push(`Backup Location: ${result.backupPath}`);
|
|
20594
|
+
}
|
|
20595
|
+
if (result.details.length > 0) {
|
|
20596
|
+
lines.push("\nDetails:");
|
|
20597
|
+
for (const item of result.details) {
|
|
20598
|
+
lines.push(` [${item.status}] ${item.file}${item.message ? ` - ${item.message}` : ""}`);
|
|
20599
|
+
}
|
|
20600
|
+
}
|
|
20601
|
+
return lines.join("\n");
|
|
20602
|
+
}
|
|
20603
|
+
formatJson(result) {
|
|
20604
|
+
return JSON.stringify(result, null, 2);
|
|
20605
|
+
}
|
|
20606
|
+
};
|
|
20607
|
+
var MigrationOrchestrator = class {
|
|
20608
|
+
fsJail = new FileSystemJailAdapter();
|
|
20609
|
+
diffDetector = new DiffDetector();
|
|
20610
|
+
analyzer = new OverrideAnalyzer();
|
|
20611
|
+
ratchetEnforcer = new PolicyRatchetEnforcer();
|
|
20612
|
+
backupManager = new TimestampedBackupManagerAdapter();
|
|
20613
|
+
transactionManager = new TransactionManager();
|
|
20614
|
+
};
|
|
20615
|
+
function handleOverrideStatus(force) {
|
|
20616
|
+
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" };
|
|
20617
|
+
}
|
|
20618
|
+
function classifySingleItem(item, orchestrator, force) {
|
|
20619
|
+
const rawStatus = orchestrator.analyzer.classify({
|
|
20620
|
+
currentContent: item.currentContent,
|
|
20621
|
+
targetContent: item.targetContent,
|
|
20622
|
+
baseContent: item.baseContent
|
|
20623
|
+
});
|
|
20624
|
+
switch (rawStatus) {
|
|
20625
|
+
case "UP_TO_DATE":
|
|
20626
|
+
return { status: "UP_TO_DATE", shouldModify: false, category: "upToDate" };
|
|
20627
|
+
case "CLEAN_UPDATE":
|
|
20628
|
+
return { status: "CLEAN_UPDATE", shouldModify: true, category: "cleanUpdated" };
|
|
20629
|
+
case "LOCAL_OVERRIDE_PRESERVED":
|
|
20630
|
+
return handleOverrideStatus(force);
|
|
20631
|
+
default:
|
|
20632
|
+
return { status: "CONFLICT", message: "Structural conflict or syntax corruption detected", shouldModify: false, category: "conflicts" };
|
|
20633
|
+
}
|
|
20634
|
+
}
|
|
20635
|
+
function evaluateGovernedTargets(targets, orchestrator, force) {
|
|
20636
|
+
const summary = { upToDate: 0, cleanUpdated: 0, overridesPreserved: 0, conflicts: 0 };
|
|
20637
|
+
const details = [];
|
|
20638
|
+
const filesToModify = [];
|
|
20639
|
+
const filesToBackup = [];
|
|
20640
|
+
for (const item of targets) {
|
|
20641
|
+
const outcome = classifySingleItem(item, orchestrator, force);
|
|
20642
|
+
summary[outcome.category]++;
|
|
20643
|
+
details.push({
|
|
20644
|
+
file: item.relPath,
|
|
20645
|
+
category: item.category,
|
|
20646
|
+
status: outcome.status,
|
|
20647
|
+
currentDigest: item.currentContent ? orchestrator.diffDetector.computeDigest(item.currentContent) : void 0,
|
|
20648
|
+
targetDigest: item.targetContent ? orchestrator.diffDetector.computeDigest(item.targetContent) : void 0,
|
|
20649
|
+
message: outcome.message
|
|
20650
|
+
});
|
|
20651
|
+
if (outcome.shouldModify) {
|
|
20652
|
+
filesToModify.push({ relPath: item.relPath, content: item.targetContent });
|
|
20653
|
+
filesToBackup.push(item.relPath);
|
|
20654
|
+
}
|
|
20655
|
+
}
|
|
20656
|
+
return { summary, details, filesToModify, filesToBackup };
|
|
20657
|
+
}
|
|
20658
|
+
function buildCanonicalMap() {
|
|
20659
|
+
const canonicalMap = /* @__PURE__ */ new Map();
|
|
20660
|
+
canonicalMap.set("quality-policy.yaml", { category: "policy", content: STARTER_QUALITY_POLICY });
|
|
20661
|
+
canonicalMap.set("license-policy.yaml", { category: "policy", content: STARTER_LICENSE_POLICY });
|
|
20662
|
+
canonicalMap.set("privacy-policy.yaml", { category: "policy", content: STARTER_PRIVACY_POLICY });
|
|
20663
|
+
for (const s of STARTER_SCHEMAS) {
|
|
20664
|
+
canonicalMap.set(s.relPath.replace(/\\/g, "/"), { category: "schema", content: s.content });
|
|
20665
|
+
}
|
|
20666
|
+
for (const t of STARTER_BASE_TEMPLATES) {
|
|
20667
|
+
canonicalMap.set(t.relPath.replace(/\\/g, "/"), { category: "template", content: t.content });
|
|
20668
|
+
}
|
|
20669
|
+
return canonicalMap;
|
|
20670
|
+
}
|
|
20671
|
+
function scanSchemasDir(schemasDir, canonicalMap) {
|
|
20672
|
+
const items = [];
|
|
20673
|
+
if (!fs11.existsSync(schemasDir)) return items;
|
|
20674
|
+
try {
|
|
20675
|
+
for (const f of fs11.readdirSync(schemasDir)) {
|
|
20676
|
+
if (f.endsWith(".json")) {
|
|
20677
|
+
const relPath = path13.join("schemas", f).replace(/\\/g, "/");
|
|
20678
|
+
const content = fs11.readFileSync(path13.join(schemasDir, f), "utf-8");
|
|
20679
|
+
const canonical = canonicalMap.get(relPath);
|
|
20680
|
+
const targetContent = canonical ? canonical.content : content;
|
|
20681
|
+
items.push({ relPath, category: "schema", currentContent: content, targetContent, baseContent: targetContent });
|
|
20682
|
+
}
|
|
20683
|
+
}
|
|
20684
|
+
} catch {
|
|
20685
|
+
}
|
|
20686
|
+
return items;
|
|
20687
|
+
}
|
|
20688
|
+
function resolveExitCode2(summary) {
|
|
20689
|
+
if (summary.conflicts > 0) return 2;
|
|
20690
|
+
if (summary.overridesPreserved > 0) return 1;
|
|
20691
|
+
return 0;
|
|
20692
|
+
}
|
|
20693
|
+
function createProtectedBranchError(errorMsg) {
|
|
20694
|
+
return {
|
|
20695
|
+
success: false,
|
|
20696
|
+
exitCode: 2,
|
|
20697
|
+
summary: { upToDate: 0, cleanUpdated: 0, overridesPreserved: 0, conflicts: 0 },
|
|
20698
|
+
details: [{ file: "workspace", category: "policy", status: "CONFLICT", message: errorMsg }]
|
|
20699
|
+
};
|
|
20700
|
+
}
|
|
20701
|
+
function createTransactionFailureResult(summary, backupPath, errorMsg) {
|
|
20702
|
+
return {
|
|
20703
|
+
success: false,
|
|
20704
|
+
exitCode: 2,
|
|
20705
|
+
summary,
|
|
20706
|
+
backupPath,
|
|
20707
|
+
details: [{ file: "transaction", category: "policy", status: "CONFLICT", message: errorMsg || "Transaction failed" }]
|
|
20708
|
+
};
|
|
20709
|
+
}
|
|
20710
|
+
var MigrationService = class {
|
|
20711
|
+
constructor(orchestrator = new MigrationOrchestrator()) {
|
|
20712
|
+
this.orchestrator = orchestrator;
|
|
20713
|
+
}
|
|
20714
|
+
orchestrator;
|
|
20715
|
+
async preview(options) {
|
|
20716
|
+
return this.executeMigration({ ...options, dryRun: true });
|
|
20717
|
+
}
|
|
20718
|
+
async migrate(options) {
|
|
20719
|
+
return this.executeMigration({ ...options, dryRun: options.dryRun ?? false });
|
|
20720
|
+
}
|
|
20721
|
+
isInsideGitRepository(repoRoot) {
|
|
20722
|
+
try {
|
|
20723
|
+
const out = child_process.execSync("git rev-parse --is-inside-work-tree", {
|
|
20724
|
+
cwd: repoRoot,
|
|
20725
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
20726
|
+
encoding: "utf-8"
|
|
20727
|
+
}).trim();
|
|
20728
|
+
return out === "true";
|
|
20729
|
+
} catch {
|
|
20730
|
+
return false;
|
|
20731
|
+
}
|
|
20732
|
+
}
|
|
20733
|
+
queryGitBranch(repoRoot) {
|
|
20734
|
+
try {
|
|
20735
|
+
const out = child_process.execSync("git symbolic-ref --short HEAD", { cwd: repoRoot, stdio: ["ignore", "pipe", "ignore"], encoding: "utf-8" }).trim();
|
|
20736
|
+
if (out) return out;
|
|
20737
|
+
} catch {
|
|
20738
|
+
}
|
|
20739
|
+
try {
|
|
20740
|
+
const out = child_process.execSync("git rev-parse --abbrev-ref HEAD", { cwd: repoRoot, stdio: ["ignore", "pipe", "ignore"], encoding: "utf-8" }).trim();
|
|
20741
|
+
if (out && out !== "HEAD") return out;
|
|
20742
|
+
} catch {
|
|
20743
|
+
}
|
|
20744
|
+
return null;
|
|
20745
|
+
}
|
|
20746
|
+
async detectBranch(repoRoot) {
|
|
20747
|
+
if (!this.isInsideGitRepository(repoRoot)) {
|
|
20748
|
+
return "non-git-workspace";
|
|
20749
|
+
}
|
|
20750
|
+
const localBranch = this.queryGitBranch(repoRoot);
|
|
20751
|
+
if (localBranch) return localBranch;
|
|
20752
|
+
return process.env.GITHUB_REF_NAME || process.env.CI_COMMIT_REF_NAME || null;
|
|
20753
|
+
}
|
|
20754
|
+
isProtectedBranch(branch) {
|
|
20755
|
+
return branch === "main" || branch === "master" || branch.startsWith("release/");
|
|
20756
|
+
}
|
|
20757
|
+
async verifyBranchSafety(root, branchOption) {
|
|
20758
|
+
const branch = branchOption || await this.detectBranch(root) || void 0;
|
|
20759
|
+
if (!branch) {
|
|
20760
|
+
return { ok: false, error: "ERR_PROTECTED_BRANCH_MIGRATION: Unable to determine Git branch in mutating migration" };
|
|
20761
|
+
}
|
|
20762
|
+
if (this.isProtectedBranch(branch)) {
|
|
20763
|
+
return { ok: false, branch, error: `ERR_PROTECTED_BRANCH_MIGRATION: Migration forbidden on protected branch "${branch}"` };
|
|
20764
|
+
}
|
|
20765
|
+
return { ok: true, branch };
|
|
20766
|
+
}
|
|
20767
|
+
async runMutationTransaction(root, evaluation, enableBackup) {
|
|
20768
|
+
let backupPath;
|
|
20769
|
+
if (enableBackup) {
|
|
20770
|
+
backupPath = await this.orchestrator.backupManager.createBackup(root, evaluation.filesToBackup);
|
|
20771
|
+
}
|
|
20772
|
+
await this.orchestrator.transactionManager.begin(root);
|
|
20773
|
+
try {
|
|
20774
|
+
for (const file of evaluation.filesToModify) {
|
|
20775
|
+
await this.orchestrator.transactionManager.stageFile(root, file.relPath, file.content);
|
|
20776
|
+
}
|
|
20777
|
+
await this.orchestrator.transactionManager.commit(root);
|
|
20778
|
+
return { success: true, backupPath };
|
|
20779
|
+
} catch (err) {
|
|
20780
|
+
if (backupPath) {
|
|
20781
|
+
this.orchestrator.transactionManager.rollbackSync(root, backupPath);
|
|
20782
|
+
}
|
|
20783
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
20784
|
+
return { success: false, backupPath, error: message };
|
|
20785
|
+
}
|
|
20786
|
+
}
|
|
20787
|
+
async executeMigration(options) {
|
|
20788
|
+
const root = path13.resolve(options.root || process.cwd());
|
|
20789
|
+
const isDryRun = Boolean(options.dryRun);
|
|
20790
|
+
if (!isDryRun) {
|
|
20791
|
+
const branchCheck = await this.verifyBranchSafety(root, options.branch);
|
|
20792
|
+
if (!branchCheck.ok) {
|
|
20793
|
+
return createProtectedBranchError(branchCheck.error);
|
|
20794
|
+
}
|
|
20795
|
+
}
|
|
20796
|
+
const targets = this.discoverGovernedFiles(root);
|
|
20797
|
+
const evaluation = evaluateGovernedTargets(targets, this.orchestrator, options.force);
|
|
20798
|
+
if (isDryRun || evaluation.filesToModify.length === 0) {
|
|
20799
|
+
const exitCode2 = resolveExitCode2(evaluation.summary);
|
|
20800
|
+
return { success: exitCode2 === 0, exitCode: exitCode2, summary: evaluation.summary, details: evaluation.details };
|
|
20801
|
+
}
|
|
20802
|
+
const tx = await this.runMutationTransaction(root, evaluation, options.backup ?? true);
|
|
20803
|
+
if (!tx.success) {
|
|
20804
|
+
return createTransactionFailureResult(evaluation.summary, tx.backupPath, tx.error);
|
|
20805
|
+
}
|
|
20806
|
+
const exitCode = resolveExitCode2(evaluation.summary);
|
|
20807
|
+
return { success: exitCode === 0, exitCode, summary: evaluation.summary, backupPath: tx.backupPath, details: evaluation.details };
|
|
20808
|
+
}
|
|
20809
|
+
discoverGovernedFiles(root) {
|
|
20810
|
+
const items = [];
|
|
20811
|
+
const canonicalMap = buildCanonicalMap();
|
|
20812
|
+
const policyFiles = ["quality-policy.yaml", "license-policy.yaml", "privacy-policy.yaml", "dlp-policy.yaml"];
|
|
20813
|
+
for (const pf of policyFiles) {
|
|
20814
|
+
const fullPath = path13.join(root, pf);
|
|
20815
|
+
if (fs11.existsSync(fullPath)) {
|
|
20816
|
+
const content = fs11.readFileSync(fullPath, "utf-8");
|
|
20817
|
+
const canonical = canonicalMap.get(pf);
|
|
20818
|
+
const targetContent = canonical ? canonical.content : content;
|
|
20819
|
+
items.push({ relPath: pf, category: "policy", currentContent: content, targetContent, baseContent: targetContent });
|
|
20820
|
+
}
|
|
20821
|
+
}
|
|
20822
|
+
items.push(...scanSchemasDir(path13.join(root, "schemas"), canonicalMap));
|
|
20823
|
+
return items;
|
|
20824
|
+
}
|
|
20825
|
+
};
|
|
20826
|
+
|
|
20827
|
+
export { ALL_ARCHITECTURE_TEMPLATES, ALL_QUALITY_GATES, BRANCH_PATTERNS, BddStepRegistry, BranchSafetyCheck, CPP_CLANG_TIDY, CPP_CMAKE_STRICT, DEFAULT_DLP_RULES, DEFAULT_EXCLUDED_PATTERNS, DEFAULT_EXCLUDES, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXTENSIONS, DEFAULT_PRIVACY_POLICY, DEFAULT_SAST_EXCLUDES, DOTNET_DIRECTORY_BUILD_PROPS, DiffDetector, DlpSanitizer, DoctorOrchestrator, DoctorReporter, DoctorService, FileSystemJailAdapter, GENERAL_SOURCE_EXTENSIONS, GHERKIN_GENERATOR_SPECS, GO_GOLANGCI_YML, GRADLE_STRICT_INIT_KTS, GitHooksHealthCheck, InTotoAttestationBuilder, JAVA_PMD_RULESET_XML, KOTLIN_DETEKT_YML, KPI_SUMMARY_END_TAG, KPI_SUMMARY_START_TAG, LIFECYCLE_SKILL_TEMPLATES, MigrationOrchestrator, MigrationReporter, MigrationService, NativeFileSystemProbeAdapter, OpenSpecAdapter, OscalAssessmentBuilder, OverrideAnalyzer, PII_SAST_RULES, PREPARE_COMMIT_MSG_SCRIPT, PRE_COMMIT_SCRIPT, PROMPT_INJECTION_SIGNATURES, PROTECTED_BYPASS_PATTERNS, PROTECTED_CODING_RULES_FILES, PolicyRatchetEnforcer, REVIEWER_ROLES, REVIEW_VERDICTS, RUST_CARGO_CONFIG_TOML, RUST_CLIPPY_TOML, RegulatoryControlMapper, SARIF_SCHEMA_2_1_0, SARIF_VERSION, SAST_RULES, SCHEMA_SCHEMAS_ARCHITECTURE_ADR_SCHEMA_JSON, SCHEMA_SCHEMAS_ARCHITECTURE_COMPONENT_SCHEMA_JSON, SCHEMA_SCHEMAS_ARCHITECTURE_INTRODUCTION_AND_GOALS_SCHEMA_JSON, SCHEMA_SCHEMAS_COMPLIANCE_LICENSE_MANIFEST_SCHEMA_JSON, SCHEMA_SCHEMAS_COMPLIANCE_LICENSE_POLICY_SCHEMA_JSON, SCHEMA_SCHEMAS_COMPLIANCE_QUALITY_POLICY_SCHEMA_JSON, SCHEMA_SCHEMAS_IDE_MCP_CONFIG_SCHEMA_JSON, SCHEMA_SCHEMAS_MANUALS_PRODUCTION_MANUAL_SCHEMA_JSON, SCHEMA_SCHEMAS_MANUALS_USER_MANUAL_SCHEMA_JSON, SCHEMA_SCHEMAS_PRIVACY_DATA_ASSET_SCHEMA_JSON, SCHEMA_SCHEMAS_PRIVACY_PRIVACY_POLICY_SCHEMA_JSON, SCHEMA_SCHEMAS_PRIVACY_PRIVACY_REQ_SCHEMA_JSON, SCHEMA_SCHEMAS_PRIVACY_PRIVACY_ROPA_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_ACTOR_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_BOUNDED_CONTEXT_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_BUSINESS_RULE_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_JOURNEY_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_REQUIREMENT_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_TERM_SCHEMA_JSON, SCHEMA_SCHEMAS_PRODUCT_USE_CASE_SCHEMA_JSON, SCHEMA_SCHEMAS_SAFETY_HAZARD_SCHEMA_JSON, SCHEMA_SCHEMAS_SAFETY_SAFETY_REQ_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_DESIGN_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_HANDOFF_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_PROPOSAL_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_RELEASE_KPIS_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_SESSION_TELEMETRY_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_SPEC_SCHEMA_JSON, SCHEMA_SCHEMAS_SDD_TASKS_SCHEMA_JSON, SCHEMA_SCHEMAS_SECURITY_ABUSE_CASE_SCHEMA_JSON, SCHEMA_SCHEMAS_SECURITY_ENCLAVE_SCHEMA_JSON, SCHEMA_SCHEMAS_SECURITY_SECURITY_REQ_SCHEMA_JSON, SCHEMA_SCHEMAS_SECURITY_THREAT_ACTOR_SCHEMA_JSON, SCHEMA_SCHEMAS_WORKFLOW_AGENT_HANDOFF_SCHEMA_JSON, SECRET_RULES, SPECIALIZED_AGENT_TEMPLATES, STARTER_AGENT_GUARD_WRAPPER_CJS, STARTER_ANTIGRAVITY_HOOKS_JSON, STARTER_ANTIGRAVITY_MCP, STARTER_ANTIGRAVITY_RULES, STARTER_ARCH_ADR, STARTER_ARCH_ARCHITECTURE_CONSTRAINTS, STARTER_ARCH_COMPONENT, STARTER_ARCH_CONTEXT_AND_SCOPE, STARTER_ARCH_CROSS_CUTTING_CONCEPTS, STARTER_ARCH_DEPLOYMENT_VIEW, STARTER_ARCH_GLOSSARY, STARTER_ARCH_INTRODUCTION_AND_GOALS, STARTER_ARCH_LEVEL_1_WHITEBOX, STARTER_ARCH_QUALITY_REQUIREMENTS, STARTER_ARCH_RISKS_AND_TECHNICAL_DEBT, STARTER_ARCH_RUNTIME_VIEW, STARTER_ARCH_SOLUTION_STRATEGY, STARTER_AZURE_PIPELINES, STARTER_BASE_TEMPLATES, STARTER_BITBUCKET_PIPELINES, STARTER_CLAUDE_RULES, STARTER_COMPLIANCE_LICENSE_MANIFEST_YAML, STARTER_COPILOT_RULES, STARTER_CURSOR_CORE_RULES, STARTER_CURSOR_MCP, STARTER_CURSOR_PRODUCT_RULES, STARTER_CURSOR_QUALITY_RULES, STARTER_GITHUB_CI, STARTER_GITHUB_DEPLOY_DASHBOARD, STARTER_GITHUB_PR_KPI, STARTER_GITHUB_PULL_REQUEST_TEMPLATE, STARTER_GITHUB_SDD_INTEGRATE, STARTER_GITLAB_CI, STARTER_GUARD_BRANCH_CJS, STARTER_LICENSE_POLICY, STARTER_PRIVACY_POLICY, STARTER_PROCESS_README, STARTER_PULL_REQUEST_TEMPLATE, STARTER_QUALITY_POLICY, STARTER_REQUIREMENT_TEMPLATE, STARTER_SCHEMAS, STARTER_SCHEMAS_MAP, STARTER_TASK_TEMPLATE, STARTER_TEMPLATES_CI_AZURE_PIPELINES_YML, STARTER_TEMPLATES_CI_BITBUCKET_PIPELINES_YML, STARTER_TEMPLATES_CI_GITHUB_WORKFLOWS_CI_YML, STARTER_TEMPLATES_CI_GITHUB_WORKFLOWS_DEPLOY_DASHBOARD_YML, STARTER_TEMPLATES_CI_GITHUB_WORKFLOWS_PR_KPI_SUMMARY_YML, STARTER_TEMPLATES_CI_GITHUB_WORKFLOWS_SDD_INTEGRATE_ON_MERGE_YML, STARTER_TEMPLATES_CI__GITLAB_CI_YML, STARTER_TEMPLATES_COMPLIANCE_COMMERCIAL_ACQUISITION_REQUEST_TEMPLATE_MD, STARTER_TEMPLATES_MANUALS_PRODUCTION_MANUAL_TEMPLATE_MD, STARTER_TEMPLATES_MANUALS_USER_MANUAL_TEMPLATE_MD, STARTER_TEMPLATES_PRIVACY_DATA_ASSET_TEMPLATE_MD, STARTER_TEMPLATES_PRIVACY_DPIA_REQUEST_TEMPLATE_MD, STARTER_TEMPLATES_PRIVACY_PRIVACY_REQ_TEMPLATE_MD, STARTER_TEMPLATES_PRIVACY_PRIVACY_ROPA_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_ACTOR_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_BOUNDED_CONTEXT_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_BUSINESS_RULE_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_JOURNEY_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_REQUIREMENT_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_TERM_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_USER_DESIGN_FEEDBACK_TEMPLATE_MD, STARTER_TEMPLATES_PRODUCT_USE_CASE_TEMPLATE_MD, STARTER_TEMPLATES_SAFETY_HAZARD_TEMPLATE_MD, STARTER_TEMPLATES_SAFETY_SAFETY_REQ_TEMPLATE_MD, STARTER_TEMPLATES_SDD_DESIGN_TEMPLATE_MD, STARTER_TEMPLATES_SDD_HANDOFF_TEMPLATE_YAML, STARTER_TEMPLATES_SDD_PROPOSAL_TEMPLATE_MD, STARTER_TEMPLATES_SDD_PULL_REQUEST_TEMPLATE_MD, STARTER_TEMPLATES_SDD_SPEC_TEMPLATE_MD, STARTER_TEMPLATES_SDD_TASKS_TEMPLATE_MD, STARTER_TEMPLATES_SECURITY_ABUSE_CASE_TEMPLATE_MD, STARTER_TEMPLATES_SECURITY_ENCLAVE_TEMPLATE_MD, STARTER_TEMPLATES_SECURITY_SECURITY_REQ_TEMPLATE_MD, STARTER_TEMPLATES_SECURITY_THREAT_ACTOR_TEMPLATE_MD, STARTER_TEMPLATES_WORKFLOW_AGENT_HANDOFF_TEMPLATE_MD, STARTER_VSCODE_MCP, STARTER_WORKFLOW_HANDOFF_TEMPLATE, STARTER__GITHUB_PULL_REQUEST_TEMPLATE_MD, SafeProcessRunnerAdapter, SchemasPdacHealthCheck, SignatureReadinessCheck, SpecKitAdapter, TS_ESLINT_CONFIG_MJS, TS_STRICT_TSCONFIG, TYPE_TO_SCHEMA_MAP, TimestampedBackupManagerAdapter, ToolchainHealthCheck, TransactionManager, UNIT_TEST_SUFFIXES, VALID_AGENT_TARGETS, VALID_ARCHITECTURE_GRANULARITIES, VALID_AUTONOMY_MODES, VALID_CHANGE_PROFILES, VALID_CI_PROVIDERS, VALID_CODING_RULE_STACKS, accumulateTaskSummaries, aggregateCommitKpiRecords, aggregatePrKpis, aggregateReleaseKpis, analyzeBddVariantsForRequirement, appendRevisionHistoryRow, applyRatchetMode, buildCycloneDxComponent, buildCycloneDxVulnerabilities, buildFeatureFileContent, buildGraphElements, buildSafeEnvironment, calculateJaccardSimilarity, calculateMetrics, calculateRating, calculateShannonEntropy, canonicalSort, canonicalizeJson, checkGherkinInSync, checkoutTaskBranch, classifyBranch, classifyMetricFromMessage, collectAgentFiles, collectDashboardMetrics, collectHistoricalKpis, computeCanonicalSha256, computeRawSha256, computeSha256, computeViolationSignature, createDefaultDlpPolicy, createDefaultQualityPolicy, depositProductHandoffSidecar, detectActiveChangeForIntegration, detectAuthorIdentity, detectLanguage, detectProfileFromChange, detectProjectStacks, detectPromptInjection, emitCiOutput, evaluateCompoundLicense, evaluateSingleDependency, evaluateVulnerabilityThresholds, executeBddFeature, extractAllRepoCommitKpis, extractBaselineEntriesFromResults, extractCitations, extractCommitKpisFromRange, extractDirectDepNames, extractFeatureTags, extractFrontmatter, extractFunctions, extractFunctionsBraceLanguages, extractFunctionsPolyglot, extractFunctionsPython, extractFunctionsPythonAst, extractFunctionsTypeScriptAst, extractGherkinBlock, extractGherkinFeatures, extractNormativeText, extractPythonFunctionsPolyglot, extractSemanticContent, findChangeWorkspaceDir, findLicenseFile, formatCommitTrailers, formatInspectResultMarkdown, formatPrKpiMarkdown, formatReleaseKpiMarkdown, formatTaskKpiRows, generateBranchHierarchyPlan, generateComplianceEvidenceBundle, generateComplianceEvidenceBundleSync, generateCycloneDxSbom, generateDashboardReport, generateDeterministicUuidV5, generateDuplicatesReportMarkdown, generateGovernanceReportMarkdown, generateLicenseReportMarkdown, generatePdacReportMarkdown, generatePrivacyReportMarkdown, generateQualityReport, generateRopaInventoryMarkdown, generateSastReportMarkdown, generateSecretsReportMarkdown, generateSecuritySarifReport, generateSuppressionsAuditReport, generateTestingCoverageReportMarkdown, generateThirdPartyNotices, generateTraceabilityReportMarkdown, getArchitectureTemplates, getCodingRulesFilesForStacks, getCytoscapeScript, getGitDiffLines, getNextCorrelativeNumber, getReferenceCodingRulesTemplates, getSddAdapter, inferArtifactTypeFromId, inferMissingTrailers, initProject, injectKpisIntoPrBody, inspectElement, installGitHooks, integrateAllSddChanges, integrateSddChange, isCliInstalled, isFunctionReferencedInTests, isGitleaksInstalled, isMetricWorsened, isPathProtectedFromPatch, isPlaceholderOrIgnored, isProtectedCodingRulesFile, isReportContentSemanticallyEqual, isRequirementArtifact2 as isRequirementArtifact, isReviewerRole, isSemgrepInstalled, isToolAvailable, loadDlpPolicy, loadPrivacyPolicy, loadProductHandoffSidecar, loadQualityBaseline, locateTaskInActiveChanges, mapSastSeverityToSarifLevel, maskSecret, normalizePath, normalizeScaffoldLanguages, normalizeSpdxLicense, normalizeUri, orchestrateNativeAstAnalysis, parseCommitTrailers, parseDlpPolicy, parseFeatureDocument, parseFrontmatter, parseFrontmatterId, parseGenericDoc, parseLicensePolicy, parseMarkdownFrontmatter, parseQualityPolicy, parseRequirementFile, parseSecuritySuppression, parseSpecCatalogScope, parseTasksDoc, parseTasksFromContent, parseTrivyVulnerabilities, processPackageDir, readCodeCoverageSummary, readPackageJson, renderAntigravityAgentFile, renderAntigravitySkillFile, renderAutonomyModeSection, renderClaudeAgentFile, renderClaudeSkillFile, renderCopilotAgentFile, renderCopilotSkillFile, renderCursorAgentFile, renderCursorSkillFile, renderDashboardHtml, renderManualsTab, resolveAgentTargets, resolveBranchHierarchy, resolveCiEnvironment, resolveCodingRuleStacks, resolveCytoscapePath, resolveDefaultBranchBase, resolveDeterministicDate, resolveFeatureFilePath, resolveGitRef, resolveLicenseFromFile, resolveReleaseBaseBranch, resolveSastCwe, resolveSastOwasp, resolveSchemaForArtifact, resolveTargetFiles, runGitleaksCli, runSemgrepCli, sanitizeDlpPayload, sanitizeDlpText, sanitizeTestCorpus, scaffoldGherkinSteps, scaffoldSddChange, scanAllProductHandoffs, scanAllTestArtifacts, scanContentForSecrets, scanFileForPrivacyViolations, scanFileForSast, scanGoDependencies, scanInstalledLicenses, scanManualsInWorkspace, scanMavenDependencies, scanPnpmStore, scanPythonDependencies, scanRustDependencies, scanSubdirectories, scanWithNativeFs, scanWithSyft, scanWithTrivy, serializeSarifDocument, slugify2 as slugify, stripVolatileReportMetadata, submitReviewReport, syncPdacDigests, tokenizeTitle, updateCitationsInContent, validateAgainstSchema, validateAnchorExistence, validateArtifactSchema, verifyArtifactDuplicates, verifyArtifactsSchemas, verifyLicenses, verifyManuals, verifyPdacGraph, verifyPrivacy, verifyProgressiveFriction, verifyQualityGate, verifySast, verifySddIntegration, verifySecrets, verifyTasksGovernance, verifyTestingCoverage, verifyTraceability, walkDir, walkMdFiles, walkProjectFiles, walkSourceFiles, walkTaskFiles, writeCucumberJsonReport, writeCycloneDxSbom, writeQualityBaseline, writeReleaseKpiReport, writeReportFileIfChanged, writeSecuritySarifReport, writeThirdPartyNotices };
|
|
19115
20828
|
//# sourceMappingURL=index.js.map
|
|
19116
20829
|
//# sourceMappingURL=index.js.map
|