@aisdlc/cli 4.1.0 → 4.3.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.js +342 -116
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
-
import
|
|
5
|
+
import pc12 from "picocolors";
|
|
6
6
|
|
|
7
7
|
// src/commands/check.ts
|
|
8
8
|
import pc2 from "picocolors";
|
|
@@ -27,17 +27,21 @@ import {
|
|
|
27
27
|
// src/commands/verify.ts
|
|
28
28
|
import pc from "picocolors";
|
|
29
29
|
import * as path from "path";
|
|
30
|
+
import * as readline from "readline/promises";
|
|
30
31
|
import {
|
|
31
32
|
writeReportFileIfChanged,
|
|
32
33
|
checkGherkinInSync,
|
|
33
34
|
verifyArtifactDuplicates,
|
|
34
35
|
verifyArtifactsSchemas,
|
|
35
36
|
verifyLicenses,
|
|
37
|
+
verifyLicensesAsync,
|
|
36
38
|
verifyPdacGraph,
|
|
37
39
|
verifyPrivacy,
|
|
38
40
|
verifyProgressiveFriction,
|
|
39
41
|
verifyQualityGate,
|
|
40
42
|
verifySast,
|
|
43
|
+
verifySastAsync,
|
|
44
|
+
SarifIngestionError,
|
|
41
45
|
verifySecrets,
|
|
42
46
|
verifyTasksGovernance,
|
|
43
47
|
verifyTestingCoverage,
|
|
@@ -47,6 +51,19 @@ import {
|
|
|
47
51
|
serializeSarifDocument,
|
|
48
52
|
writeSecuritySarifReport
|
|
49
53
|
} from "@aisdlc/core";
|
|
54
|
+
function createTtyConfirmInstall() {
|
|
55
|
+
return async (spec) => {
|
|
56
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
57
|
+
try {
|
|
58
|
+
const answer = await rl.question(
|
|
59
|
+
`Tool "${spec.tool}" is not installed. Run "${spec.displayCommand}"? [y/N] `
|
|
60
|
+
);
|
|
61
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
62
|
+
} finally {
|
|
63
|
+
rl.close();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
50
67
|
function isJsonOutput(options = {}) {
|
|
51
68
|
if (options.json !== void 0) {
|
|
52
69
|
return Boolean(options.json);
|
|
@@ -463,18 +480,23 @@ function buildLicenseVerifyInput(options, rootDir) {
|
|
|
463
480
|
depth: options.depth,
|
|
464
481
|
generateSbom: options.sbom !== void 0 ? Boolean(options.sbom) : void 0,
|
|
465
482
|
sbomPath: typeof options.sbom === "string" ? options.sbom : void 0,
|
|
483
|
+
sbomInputPath: options.sbomInput,
|
|
466
484
|
generateNotices: options.notices !== void 0 ? Boolean(options.notices) : void 0,
|
|
467
485
|
noticesPath: typeof options.notices === "string" ? options.notices : void 0,
|
|
468
|
-
scanVulnerabilities: options.vuln !== void 0 ? Boolean(options.vuln) : void 0
|
|
486
|
+
scanVulnerabilities: options.vuln !== void 0 ? Boolean(options.vuln) : void 0,
|
|
487
|
+
nonInteractive: options.nonInteractive,
|
|
488
|
+
noInstallPrompt: options.noInstallPrompt,
|
|
489
|
+
ci: options.ci,
|
|
490
|
+
confirmInstall: createTtyConfirmInstall()
|
|
469
491
|
};
|
|
470
492
|
}
|
|
471
|
-
function
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
493
|
+
function finalizeLicensesOutput(result, options, useJson) {
|
|
494
|
+
if (result.warnings && result.warnings.length > 0 && !options.silent) {
|
|
495
|
+
for (const warning of result.warnings) {
|
|
496
|
+
process.stderr.write(`[SBOM WARNING] ${warning}
|
|
497
|
+
`);
|
|
498
|
+
}
|
|
476
499
|
}
|
|
477
|
-
const result = verifyLicenses(buildLicenseVerifyInput(options, rootDir));
|
|
478
500
|
if (useJson) {
|
|
479
501
|
emitLicensesJson(result);
|
|
480
502
|
} else if (!options.silent) {
|
|
@@ -482,6 +504,15 @@ function runVerifyLicenses(options = {}) {
|
|
|
482
504
|
}
|
|
483
505
|
return result.success;
|
|
484
506
|
}
|
|
507
|
+
async function runVerifyLicensesAsync(options = {}) {
|
|
508
|
+
const rootDir = options.root || process.cwd();
|
|
509
|
+
const useJson = isJsonOutput(options);
|
|
510
|
+
if (!options.silent && !useJson) {
|
|
511
|
+
console.log(pc.bold(pc.cyan("\n\u{1F50D} [AI-SDLC] Verifying Open Source License Compliance (SCA)...")));
|
|
512
|
+
}
|
|
513
|
+
const result = await verifyLicensesAsync(buildLicenseVerifyInput(options, rootDir));
|
|
514
|
+
return finalizeLicensesOutput(result, options, useJson);
|
|
515
|
+
}
|
|
485
516
|
function buildPdacViolations(result) {
|
|
486
517
|
const drifts = result.drifts.map((d) => ({
|
|
487
518
|
sourceId: d.sourceId,
|
|
@@ -827,7 +858,8 @@ function emitSastJson(result) {
|
|
|
827
858
|
type: v.type,
|
|
828
859
|
severity: v.severity,
|
|
829
860
|
message: v.message
|
|
830
|
-
}))
|
|
861
|
+
})),
|
|
862
|
+
...result.warnings?.length ? { warnings: result.warnings } : {}
|
|
831
863
|
};
|
|
832
864
|
console.log(JSON.stringify(payload, null, 2));
|
|
833
865
|
}
|
|
@@ -860,23 +892,44 @@ function handleSastOutput(result, options, useSarif, useJson) {
|
|
|
860
892
|
return result.success;
|
|
861
893
|
}
|
|
862
894
|
if (!options.silent) {
|
|
895
|
+
for (const warning of result.warnings ?? []) {
|
|
896
|
+
process.stderr.write(`[SAST WARNING] ${warning}
|
|
897
|
+
`);
|
|
898
|
+
}
|
|
863
899
|
printSastConsole(result);
|
|
864
900
|
}
|
|
865
901
|
return result.success;
|
|
866
902
|
}
|
|
867
|
-
function
|
|
903
|
+
function buildSastAsyncInput(rootDir, options) {
|
|
904
|
+
return {
|
|
905
|
+
rootDir,
|
|
906
|
+
semgrep: options.semgrep,
|
|
907
|
+
minSeverity: options.minSeverity,
|
|
908
|
+
sarifPaths: options.sarif,
|
|
909
|
+
orchestrate: options.orchestrate,
|
|
910
|
+
nonInteractive: options.nonInteractive,
|
|
911
|
+
noInstallPrompt: options.noInstallPrompt,
|
|
912
|
+
ci: options.ci,
|
|
913
|
+
confirmInstall: createTtyConfirmInstall()
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
async function runVerifySastAsync(options = {}) {
|
|
868
917
|
const rootDir = options.root || process.cwd();
|
|
869
918
|
const useJson = isJsonOutput(options);
|
|
870
919
|
const useSarif = isSarifOutput(options);
|
|
871
920
|
if (!options.silent && !useJson && !useSarif) {
|
|
872
921
|
console.log(pc.bold(pc.cyan("\n\u{1F6E1}\uFE0F [AI-SDLC] Verifying Shift-Left SAST Security (Injections & OWASP Top 10)...")));
|
|
873
922
|
}
|
|
874
|
-
|
|
875
|
-
rootDir,
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
923
|
+
try {
|
|
924
|
+
const result = await verifySastAsync(buildSastAsyncInput(rootDir, options));
|
|
925
|
+
return handleSastOutput(result, options, useSarif, useJson);
|
|
926
|
+
} catch (err) {
|
|
927
|
+
if (err instanceof SarifIngestionError) {
|
|
928
|
+
if (!options.silent) console.error(pc.red(`\u2716 ${err.message}`));
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
throw err;
|
|
932
|
+
}
|
|
880
933
|
}
|
|
881
934
|
function buildSecurityViolations(resultSecrets, resultSast) {
|
|
882
935
|
const secretViolations = resultSecrets.findings.map((f) => ({
|
|
@@ -916,7 +969,7 @@ function writeSuppressionsAuditReport(rootDir, suppressions) {
|
|
|
916
969
|
const targetPath = path.join(rootDir, "reports", "SUPPRESSIONS_AUDIT.md");
|
|
917
970
|
writeReportFileIfChanged(targetPath, generateSuppressionsAuditReport(suppressions));
|
|
918
971
|
}
|
|
919
|
-
function
|
|
972
|
+
async function executeSecurityVerifiersAsync(rootDir, options) {
|
|
920
973
|
const entropyThreshold = options.entropy !== void 0 ? Number(options.entropy) : void 0;
|
|
921
974
|
const resultSecrets = verifySecrets({
|
|
922
975
|
rootDir,
|
|
@@ -925,11 +978,7 @@ function executeSecurityVerifiers(rootDir, options) {
|
|
|
925
978
|
gitleaks: options.gitleaks,
|
|
926
979
|
entropyThreshold
|
|
927
980
|
});
|
|
928
|
-
const resultSast =
|
|
929
|
-
rootDir,
|
|
930
|
-
semgrep: options.semgrep,
|
|
931
|
-
minSeverity: options.minSeverity
|
|
932
|
-
});
|
|
981
|
+
const resultSast = await verifySastAsync(buildSastAsyncInput(rootDir, options));
|
|
933
982
|
return { resultSecrets, resultSast };
|
|
934
983
|
}
|
|
935
984
|
function printSecurityConsoleSummary(silent, hasExpired) {
|
|
@@ -947,6 +996,19 @@ function persistSecuritySarif(rootDir, resultSecrets, resultSast, customOutput)
|
|
|
947
996
|
const targetPath = customOutput || path.join(rootDir, "reports", "security.sarif");
|
|
948
997
|
writeSecuritySarifReport(targetPath, doc);
|
|
949
998
|
}
|
|
999
|
+
function printSecurityConsole(resultSecrets, resultSast, silent, hasExpired) {
|
|
1000
|
+
if (!silent) {
|
|
1001
|
+
console.log(pc.bold(pc.cyan("\n\u{1F510} [AI-SDLC] Verifying Deterministic Secrets and Credentials Detection (Gitleaks Gate)...")));
|
|
1002
|
+
printSecretsConsole(resultSecrets);
|
|
1003
|
+
console.log(pc.bold(pc.cyan("\n\u{1F6E1}\uFE0F [AI-SDLC] Verifying Shift-Left SAST Security (Injections & OWASP Top 10)...")));
|
|
1004
|
+
for (const warning of resultSast.warnings ?? []) {
|
|
1005
|
+
process.stderr.write(`[SAST WARNING] ${warning}
|
|
1006
|
+
`);
|
|
1007
|
+
}
|
|
1008
|
+
printSastConsole(resultSast);
|
|
1009
|
+
}
|
|
1010
|
+
printSecurityConsoleSummary(silent, hasExpired);
|
|
1011
|
+
}
|
|
950
1012
|
function handleSecurityOutput(options, resultSecrets, resultSast, isOk, hasExpired) {
|
|
951
1013
|
if (isSarifOutput(options)) {
|
|
952
1014
|
if (!options.output) {
|
|
@@ -962,18 +1024,13 @@ function handleSecurityOutput(options, resultSecrets, resultSast, isOk, hasExpir
|
|
|
962
1024
|
emitSecurityJson(resultSecrets, resultSast, isOk);
|
|
963
1025
|
return isOk;
|
|
964
1026
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
printSecurityConsoleSummary(options.silent, hasExpired);
|
|
968
|
-
return okS && okA && !hasExpired;
|
|
1027
|
+
printSecurityConsole(resultSecrets, resultSast, options.silent, hasExpired);
|
|
1028
|
+
return isOk;
|
|
969
1029
|
}
|
|
970
|
-
function
|
|
1030
|
+
async function runVerifySecurityAsync(options = {}) {
|
|
971
1031
|
const rootDir = options.root || process.cwd();
|
|
972
|
-
const { resultSecrets, resultSast } =
|
|
973
|
-
const allSuppressions = [
|
|
974
|
-
...resultSecrets.suppressions || [],
|
|
975
|
-
...resultSast.suppressions || []
|
|
976
|
-
];
|
|
1032
|
+
const { resultSecrets, resultSast } = await executeSecurityVerifiersAsync(rootDir, options);
|
|
1033
|
+
const allSuppressions = [...resultSecrets.suppressions || [], ...resultSast.suppressions || []];
|
|
977
1034
|
writeSuppressionsAuditReport(rootDir, allSuppressions);
|
|
978
1035
|
persistSecuritySarif(rootDir, resultSecrets, resultSast, options.output);
|
|
979
1036
|
const hasExpired = allSuppressions.some((s) => s.status === "expired");
|
|
@@ -1099,22 +1156,27 @@ function runVerifyPrivacy(options = {}) {
|
|
|
1099
1156
|
}
|
|
1100
1157
|
return result.success;
|
|
1101
1158
|
}
|
|
1102
|
-
function
|
|
1159
|
+
function collectSyncNonAsyncGates(options, root, isSilent) {
|
|
1103
1160
|
return {
|
|
1104
1161
|
quality: { success: runVerifyQuality({ ...options, root, silent: isSilent, json: false }) },
|
|
1105
1162
|
traceability: { success: runVerifyTraceability({ root, silent: isSilent, json: false }) },
|
|
1106
1163
|
governance: { success: runVerifyGovernance({ root, silent: isSilent, json: false }) },
|
|
1107
1164
|
testing: { success: runVerifyTesting({ root, silent: isSilent, json: false }) },
|
|
1108
1165
|
gherkin: { success: runVerifyGherkin({ root, silent: isSilent, json: false }) },
|
|
1109
|
-
licenses: { success: runVerifyLicenses({ root, silent: isSilent, json: false }) },
|
|
1110
1166
|
pdac: { success: runVerifyPdac({ root, silent: isSilent, json: false }) },
|
|
1111
1167
|
schemas: { success: runVerifySchemas({ root, silent: isSilent, json: false }) },
|
|
1112
1168
|
duplicates: { success: runVerifyDuplicates({ root, silent: isSilent, json: false }) },
|
|
1113
1169
|
friction: { success: runVerifyFriction({ root, silent: isSilent, json: false }) },
|
|
1114
|
-
security: { success: runVerifySecurity({ root, silent: isSilent, json: false }) },
|
|
1115
1170
|
privacy: { success: runVerifyPrivacy({ root, silent: isSilent, json: false }) }
|
|
1116
1171
|
};
|
|
1117
1172
|
}
|
|
1173
|
+
async function collectAllGatesAsync(options, root, isSilent) {
|
|
1174
|
+
return {
|
|
1175
|
+
...collectSyncNonAsyncGates(options, root, isSilent),
|
|
1176
|
+
licenses: { success: await runVerifyLicensesAsync({ root, silent: isSilent, json: false }) },
|
|
1177
|
+
security: { success: await runVerifySecurityAsync({ root, silent: isSilent, json: false }) }
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1118
1180
|
function resolveVerifyAllExitCode(allPassed, gatesSummary) {
|
|
1119
1181
|
if (allPassed) return 0;
|
|
1120
1182
|
if (!gatesSummary.security?.success) return 4;
|
|
@@ -1165,16 +1227,7 @@ function printVerifyAllSummaryTable(gatesSummary, allPassed) {
|
|
|
1165
1227
|
console.log(pc.bold(pc.red("\n\u26D4 FINAL VERDICT: BLOCKED BY DETECTED VIOLATIONS (EXIT 1)\n")));
|
|
1166
1228
|
}
|
|
1167
1229
|
}
|
|
1168
|
-
function
|
|
1169
|
-
const useJson = isJsonOutput(options);
|
|
1170
|
-
const isSilent = Boolean(options.silent || useJson);
|
|
1171
|
-
if (!isSilent) {
|
|
1172
|
-
console.log(pc.bold(pc.magenta("================================================================")));
|
|
1173
|
-
console.log(pc.bold(pc.magenta(" AI-SDLC: FULL QUALITY GATES AND GOVERNANCE SUITE ")));
|
|
1174
|
-
console.log(pc.bold(pc.magenta("================================================================")));
|
|
1175
|
-
}
|
|
1176
|
-
const root = options.root || process.cwd();
|
|
1177
|
-
const gatesSummary = collectAllGates(options, root, isSilent);
|
|
1230
|
+
function finalizeVerifyAll(gatesSummary, options, useJson) {
|
|
1178
1231
|
const allPassed = Object.values(gatesSummary).every((g) => g.success);
|
|
1179
1232
|
if (useJson) {
|
|
1180
1233
|
emitVerifyAllJson(gatesSummary, allPassed);
|
|
@@ -1185,6 +1238,18 @@ function runVerifyAll(options = {}) {
|
|
|
1185
1238
|
}
|
|
1186
1239
|
return allPassed;
|
|
1187
1240
|
}
|
|
1241
|
+
async function runVerifyAllAsync(options = {}) {
|
|
1242
|
+
const useJson = isJsonOutput(options);
|
|
1243
|
+
const isSilent = Boolean(options.silent || useJson);
|
|
1244
|
+
if (!isSilent) {
|
|
1245
|
+
console.log(pc.bold(pc.magenta("================================================================")));
|
|
1246
|
+
console.log(pc.bold(pc.magenta(" AI-SDLC: FULL QUALITY GATES AND GOVERNANCE SUITE ")));
|
|
1247
|
+
console.log(pc.bold(pc.magenta("================================================================")));
|
|
1248
|
+
}
|
|
1249
|
+
const root = options.root || process.cwd();
|
|
1250
|
+
const gatesSummary = await collectAllGatesAsync(options, root, isSilent);
|
|
1251
|
+
return finalizeVerifyAll(gatesSummary, options, useJson);
|
|
1252
|
+
}
|
|
1188
1253
|
|
|
1189
1254
|
// src/commands/check.ts
|
|
1190
1255
|
function runAutoFix(rootDir, silent) {
|
|
@@ -1529,7 +1594,7 @@ function runCheck(options = {}) {
|
|
|
1529
1594
|
}
|
|
1530
1595
|
|
|
1531
1596
|
// src/commands/gherkin.ts
|
|
1532
|
-
import * as
|
|
1597
|
+
import * as readline2 from "readline";
|
|
1533
1598
|
import pc3 from "picocolors";
|
|
1534
1599
|
import {
|
|
1535
1600
|
extractGherkinFeatures as extractGherkinFeatures2,
|
|
@@ -1574,12 +1639,12 @@ function runGherkinExtract(options = {}) {
|
|
|
1574
1639
|
return result.success;
|
|
1575
1640
|
}
|
|
1576
1641
|
function defaultConfirmInstall(question) {
|
|
1577
|
-
return new Promise((
|
|
1578
|
-
const rl =
|
|
1642
|
+
return new Promise((resolve3) => {
|
|
1643
|
+
const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
|
|
1579
1644
|
rl.question(question, (answer) => {
|
|
1580
1645
|
rl.close();
|
|
1581
1646
|
const normalized = answer.trim().toLowerCase();
|
|
1582
|
-
|
|
1647
|
+
resolve3(normalized === "y" || normalized === "yes");
|
|
1583
1648
|
});
|
|
1584
1649
|
});
|
|
1585
1650
|
}
|
|
@@ -1773,7 +1838,7 @@ function runGitDetectAuthor(options = {}) {
|
|
|
1773
1838
|
}
|
|
1774
1839
|
|
|
1775
1840
|
// src/commands/init.ts
|
|
1776
|
-
import * as
|
|
1841
|
+
import * as readline3 from "readline/promises";
|
|
1777
1842
|
import { initProject } from "@aisdlc/core";
|
|
1778
1843
|
import pc5 from "picocolors";
|
|
1779
1844
|
var CI_MENU = [
|
|
@@ -1802,7 +1867,7 @@ function parseCiChoice(answer) {
|
|
|
1802
1867
|
return trimmed in CI_CHOICE_MAP ? CI_CHOICE_MAP[trimmed] : trimmed;
|
|
1803
1868
|
}
|
|
1804
1869
|
async function promptForCi() {
|
|
1805
|
-
const rl =
|
|
1870
|
+
const rl = readline3.createInterface({ input: process.stdin, output: process.stdout });
|
|
1806
1871
|
console.log(CI_MENU);
|
|
1807
1872
|
try {
|
|
1808
1873
|
const answer = await rl.question(pc5.bold("\nWhich CI/CD provider do you wish to configure? [1-5] (default 1): "));
|
|
@@ -1825,7 +1890,7 @@ var ARCH_MENU = [
|
|
|
1825
1890
|
" 3) " + pc5.gray("None") + " (No architecture templates)"
|
|
1826
1891
|
].join("\n");
|
|
1827
1892
|
async function promptForArchitecture() {
|
|
1828
|
-
const rl =
|
|
1893
|
+
const rl = readline3.createInterface({ input: process.stdin, output: process.stdout });
|
|
1829
1894
|
console.log(ARCH_MENU);
|
|
1830
1895
|
try {
|
|
1831
1896
|
const answer = await rl.question(pc5.bold("\nWhich architecture granularity level do you wish to configure? [1-3] (default 1): "));
|
|
@@ -1858,7 +1923,7 @@ function parseAgentsChoice(answer) {
|
|
|
1858
1923
|
return !trimmed ? "all" : map[trimmed] || trimmed;
|
|
1859
1924
|
}
|
|
1860
1925
|
async function promptForAgents() {
|
|
1861
|
-
const rl =
|
|
1926
|
+
const rl = readline3.createInterface({ input: process.stdin, output: process.stdout });
|
|
1862
1927
|
console.log(AGENTS_MENU);
|
|
1863
1928
|
try {
|
|
1864
1929
|
const answer = await rl.question(pc5.bold("\nWhich agents do you wish to deploy? [1-7 or comma-separated list] (default 1): "));
|
|
@@ -2092,7 +2157,11 @@ async function runMcpServer(options = {}) {
|
|
|
2092
2157
|
import * as path2 from "path";
|
|
2093
2158
|
import { spawn } from "child_process";
|
|
2094
2159
|
import pc8 from "picocolors";
|
|
2095
|
-
import {
|
|
2160
|
+
import {
|
|
2161
|
+
generateComplianceEvidenceBundleSync,
|
|
2162
|
+
generateDashboardReport,
|
|
2163
|
+
generateQualityReport
|
|
2164
|
+
} from "@aisdlc/core";
|
|
2096
2165
|
function openInBrowser(filePath) {
|
|
2097
2166
|
const resolved = path2.resolve(filePath);
|
|
2098
2167
|
const platform = process.platform;
|
|
@@ -2173,6 +2242,50 @@ function runReportQuality(options = {}) {
|
|
|
2173
2242
|
printQualityReportMetrics(result, rootDir);
|
|
2174
2243
|
return result.verdict === "PASS";
|
|
2175
2244
|
}
|
|
2245
|
+
var ALLOWED_COMPLIANCE_OPTIONS = /* @__PURE__ */ new Set([
|
|
2246
|
+
"root",
|
|
2247
|
+
"output",
|
|
2248
|
+
"keyless",
|
|
2249
|
+
"strict",
|
|
2250
|
+
"offline",
|
|
2251
|
+
"dryRun"
|
|
2252
|
+
]);
|
|
2253
|
+
function validateComplianceOptions(options) {
|
|
2254
|
+
for (const key of Object.keys(options)) {
|
|
2255
|
+
if (!ALLOWED_COMPLIANCE_OPTIONS.has(key)) {
|
|
2256
|
+
console.error(pc8.red(`
|
|
2257
|
+
\u2716 [ERROR] Unknown option provided: --${key}
|
|
2258
|
+
`));
|
|
2259
|
+
return false;
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
return true;
|
|
2263
|
+
}
|
|
2264
|
+
function runReportCompliance(options = {}) {
|
|
2265
|
+
if (!validateComplianceOptions(options)) {
|
|
2266
|
+
return false;
|
|
2267
|
+
}
|
|
2268
|
+
const rootDir = options.root || process.cwd();
|
|
2269
|
+
console.log(pc8.bold(pc8.cyan("\n\u{1F4DC} [AI-SDLC] Generating Regulatory Compliance Evidence Bundle...")));
|
|
2270
|
+
try {
|
|
2271
|
+
const res = generateComplianceEvidenceBundleSync({
|
|
2272
|
+
rootDir,
|
|
2273
|
+
outputPath: options.output,
|
|
2274
|
+
keyless: options.keyless,
|
|
2275
|
+
strict: options.strict,
|
|
2276
|
+
offline: options.offline,
|
|
2277
|
+
dryRun: options.dryRun
|
|
2278
|
+
});
|
|
2279
|
+
console.log(pc8.green(`\u2714 Compliance evidence bundle generated successfully. Digest: ${res.bundleDigest}
|
|
2280
|
+
`));
|
|
2281
|
+
return res.success;
|
|
2282
|
+
} catch (err) {
|
|
2283
|
+
console.error(pc8.red(`
|
|
2284
|
+
\u2716 [ERROR] ${err instanceof Error ? err.message : String(err)}
|
|
2285
|
+
`));
|
|
2286
|
+
return false;
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2176
2289
|
|
|
2177
2290
|
// src/commands/review.ts
|
|
2178
2291
|
import pc9 from "picocolors";
|
|
@@ -2241,9 +2354,79 @@ function runInspect(query, options = {}) {
|
|
|
2241
2354
|
return result.found;
|
|
2242
2355
|
}
|
|
2243
2356
|
|
|
2244
|
-
// src/commands/
|
|
2357
|
+
// src/commands/doctor.ts
|
|
2358
|
+
import { DoctorService, DoctorReporter } from "@aisdlc/core";
|
|
2359
|
+
function printReport(report, reporter, asJson) {
|
|
2360
|
+
if (asJson) {
|
|
2361
|
+
console.log(reporter.formatJson(report));
|
|
2362
|
+
return;
|
|
2363
|
+
}
|
|
2364
|
+
const formatted = reporter.formatTerminal(report);
|
|
2365
|
+
if (report.exitCode === 2) {
|
|
2366
|
+
console.error(formatted);
|
|
2367
|
+
} else {
|
|
2368
|
+
console.log(formatted);
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
async function runDoctor(opts = {}) {
|
|
2372
|
+
const doctorOpts = {
|
|
2373
|
+
rootDir: opts.rootDir || process.cwd(),
|
|
2374
|
+
json: opts.json,
|
|
2375
|
+
fix: opts.fix,
|
|
2376
|
+
strict: opts.strict,
|
|
2377
|
+
offline: opts.offline || process.env.AI_SDLC_OFFLINE === "1",
|
|
2378
|
+
timeout: opts.timeout
|
|
2379
|
+
};
|
|
2380
|
+
const service = new DoctorService();
|
|
2381
|
+
const reporter = new DoctorReporter();
|
|
2382
|
+
const report = await service.diagnose(doctorOpts);
|
|
2383
|
+
printReport(report, reporter, Boolean(opts.json));
|
|
2384
|
+
return report.exitCode;
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
// src/commands/migrate.ts
|
|
2245
2388
|
import * as path3 from "path";
|
|
2246
2389
|
import pc10 from "picocolors";
|
|
2390
|
+
import {
|
|
2391
|
+
MigrationService,
|
|
2392
|
+
MigrationReporter
|
|
2393
|
+
} from "@aisdlc/core";
|
|
2394
|
+
function printConsoleSummary(result, reporter) {
|
|
2395
|
+
console.log(reporter.formatTerminal(result));
|
|
2396
|
+
if (result.exitCode === 0) {
|
|
2397
|
+
console.log(pc10.green("\nMigration completed successfully."));
|
|
2398
|
+
} else if (result.exitCode === 1) {
|
|
2399
|
+
console.log(pc10.yellow("\nMigration finished with local overrides preserved. Use --force to overwrite."));
|
|
2400
|
+
} else {
|
|
2401
|
+
console.error(pc10.red("\nMigration encountered errors or conflicts."));
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
async function runMigrate(options) {
|
|
2405
|
+
const root = path3.resolve(options.root || process.cwd());
|
|
2406
|
+
const service = new MigrationService();
|
|
2407
|
+
const reporter = new MigrationReporter();
|
|
2408
|
+
const migrationOptions = {
|
|
2409
|
+
root,
|
|
2410
|
+
dryRun: Boolean(options.dryRun),
|
|
2411
|
+
backup: options.backup ?? true,
|
|
2412
|
+
force: Boolean(options.force),
|
|
2413
|
+
allowPolicyDowngrade: Boolean(options.allowPolicyDowngrade),
|
|
2414
|
+
json: Boolean(options.json),
|
|
2415
|
+
verbose: Boolean(options.verbose),
|
|
2416
|
+
branch: options.branch
|
|
2417
|
+
};
|
|
2418
|
+
const result = await service.migrate(migrationOptions);
|
|
2419
|
+
if (options.json) {
|
|
2420
|
+
console.log(reporter.formatJson(result));
|
|
2421
|
+
} else {
|
|
2422
|
+
printConsoleSummary(result, reporter);
|
|
2423
|
+
}
|
|
2424
|
+
return result.exitCode;
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
// src/commands/sdd.ts
|
|
2428
|
+
import * as path4 from "path";
|
|
2429
|
+
import pc11 from "picocolors";
|
|
2247
2430
|
import {
|
|
2248
2431
|
depositProductHandoffSidecar,
|
|
2249
2432
|
detectActiveChangeForIntegration,
|
|
@@ -2271,8 +2454,8 @@ function buildHandoffPayload(options, changeId) {
|
|
|
2271
2454
|
return { handoff, reqList };
|
|
2272
2455
|
}
|
|
2273
2456
|
function printDepositSuccess(depositedPath, handoffId, reqList) {
|
|
2274
|
-
console.log(` ${
|
|
2275
|
-
console.log(` Handoff ID: ${
|
|
2457
|
+
console.log(` ${pc11.green("\u2714")} Sidecar successfully deposited: ${pc11.bold(depositedPath)}`);
|
|
2458
|
+
console.log(` Handoff ID: ${pc11.cyan(handoffId)}`);
|
|
2276
2459
|
console.log(` Delivered requirements: ${reqList.join(", ")}
|
|
2277
2460
|
`);
|
|
2278
2461
|
}
|
|
@@ -2288,12 +2471,12 @@ function emitDepositJson(success, changeId, framework, depositedPath, handoff, e
|
|
|
2288
2471
|
console.log(JSON.stringify(payload, null, 2));
|
|
2289
2472
|
}
|
|
2290
2473
|
function printDepositHeader(changeId, framework) {
|
|
2291
|
-
console.log(
|
|
2474
|
+
console.log(pc11.bold(pc11.cyan(`
|
|
2292
2475
|
\u{1F4E6} [AI-SDLC SDD] Depositing PDaC Handoff Sidecar for '${changeId}' (${framework})...`)));
|
|
2293
2476
|
}
|
|
2294
2477
|
function printDepositError(err) {
|
|
2295
2478
|
const errMessage = err instanceof Error ? err.message : String(err);
|
|
2296
|
-
console.error(
|
|
2479
|
+
console.error(pc11.red(` \u2716 Error depositing sidecar: ${errMessage}
|
|
2297
2480
|
`));
|
|
2298
2481
|
}
|
|
2299
2482
|
function runSddDeposit(options) {
|
|
@@ -2319,13 +2502,13 @@ function runSddDeposit(options) {
|
|
|
2319
2502
|
}
|
|
2320
2503
|
function printHandoffEntry(isValid, id, relDir, reqCount) {
|
|
2321
2504
|
if (isValid) {
|
|
2322
|
-
console.log(` ${
|
|
2505
|
+
console.log(` ${pc11.green("\u2714")} [${pc11.bold(id)}] in ${relDir} (Requirements: ${reqCount})`);
|
|
2323
2506
|
} else {
|
|
2324
|
-
console.log(` ${
|
|
2507
|
+
console.log(` ${pc11.red("\u2716")} [${pc11.bold(id)}] in ${relDir} - Invalid handoff schema or subgraph.`);
|
|
2325
2508
|
}
|
|
2326
2509
|
}
|
|
2327
2510
|
function processHandoffEntry(handoff, changeDir, rootDir, isSilent) {
|
|
2328
|
-
const relDir =
|
|
2511
|
+
const relDir = path4.relative(rootDir, changeDir).replace(/\\/g, "/");
|
|
2329
2512
|
const reqCount = handoff.subgraph && Array.isArray(handoff.subgraph.requirements) ? handoff.subgraph.requirements.length : 0;
|
|
2330
2513
|
const isValid = Boolean(handoff.id && handoff.id.startsWith("HOF-") && reqCount > 0);
|
|
2331
2514
|
const id = handoff.id || "UNKNOWN";
|
|
@@ -2337,7 +2520,7 @@ function processHandoffEntry(handoff, changeDir, rootDir, isSilent) {
|
|
|
2337
2520
|
function auditHandoffsMap(handoffsMap, rootDir, isSilent) {
|
|
2338
2521
|
if (handoffsMap.size === 0) {
|
|
2339
2522
|
if (!isSilent) {
|
|
2340
|
-
console.log(
|
|
2523
|
+
console.log(pc11.yellow(" [NOTICE] No handoff.yaml sidecar companion files found in specs/."));
|
|
2341
2524
|
}
|
|
2342
2525
|
return { handoffItems: [], validCount: 0, invalidCount: 0 };
|
|
2343
2526
|
}
|
|
@@ -2361,10 +2544,10 @@ function auditDuplicatesShiftLeft(rootDir, checkDuplicates, isSilent) {
|
|
|
2361
2544
|
}
|
|
2362
2545
|
const dupResult = verifyArtifactDuplicates3({ rootDir });
|
|
2363
2546
|
if (dupResult.errorCount > 0 && !isSilent) {
|
|
2364
|
-
console.log(
|
|
2547
|
+
console.log(pc11.red(`
|
|
2365
2548
|
\u2716 [Shift-Left Gate] Detected ${dupResult.errorCount} requirement collision(s)/duplicate(s) in workspace:`));
|
|
2366
2549
|
for (const issue of dupResult.issues.filter((i) => i.severity === "ERROR")) {
|
|
2367
|
-
console.log(` ${
|
|
2550
|
+
console.log(` ${pc11.red("\u2716")} [${issue.type}] ${issue.id} in ${issue.file}: ${issue.message}`);
|
|
2368
2551
|
}
|
|
2369
2552
|
}
|
|
2370
2553
|
return { duplicateErrors: dupResult.errorCount, duplicateIssues: dupResult.issues };
|
|
@@ -2385,12 +2568,12 @@ function emitSddVerifyJson(payload) {
|
|
|
2385
2568
|
}
|
|
2386
2569
|
function printSddVerifyVerdict(isOk) {
|
|
2387
2570
|
console.log(
|
|
2388
|
-
isOk ?
|
|
2571
|
+
isOk ? pc11.green("\n\u2714 SDD Integration COMPLIANT: All sidecars and requirements are valid.\n") : pc11.red("\n\u2716 SDD Integration BLOCKED: Non-compliant sidecars or duplicate requirements detected.\n")
|
|
2389
2572
|
);
|
|
2390
2573
|
}
|
|
2391
2574
|
function printSddVerifyHeader(totalFound) {
|
|
2392
|
-
console.log(
|
|
2393
|
-
console.log(` Found PDaC sidecars: ${
|
|
2575
|
+
console.log(pc11.bold(pc11.cyan("\n\u{1F50D} [AI-SDLC SDD] Verifying SDD Workspaces and Handoff Sidecars (HOF-*)...")));
|
|
2576
|
+
console.log(` Found PDaC sidecars: ${pc11.bold(String(totalFound))}`);
|
|
2394
2577
|
}
|
|
2395
2578
|
function runSddVerify(options = {}) {
|
|
2396
2579
|
const rootDir = options.root || process.cwd();
|
|
@@ -2414,7 +2597,7 @@ function runSddVerify(options = {}) {
|
|
|
2414
2597
|
}
|
|
2415
2598
|
function handleUndetectedChange(detection, isSilent, useJson) {
|
|
2416
2599
|
if (!isSilent) {
|
|
2417
|
-
console.log(
|
|
2600
|
+
console.log(pc11.yellow("\n\u2139 [AI-SDLC SDD] No active SDD change detected to integrate:"));
|
|
2418
2601
|
for (const r of detection.reasons) console.log(` - ${r}`);
|
|
2419
2602
|
console.log("");
|
|
2420
2603
|
}
|
|
@@ -2426,7 +2609,7 @@ function handleUndetectedChange(detection, isSilent, useJson) {
|
|
|
2426
2609
|
}
|
|
2427
2610
|
function handlePendingTasks(detection, isSilent, useJson) {
|
|
2428
2611
|
if (!isSilent) {
|
|
2429
|
-
console.log(
|
|
2612
|
+
console.log(pc11.red(`
|
|
2430
2613
|
\u2716 [AI-SDLC SDD] Detected change '${detection.changeId}' has pending tasks (${detection.completedTasksCount}/${detection.totalTasksCount} completed). All tasks must be in COMPLETED status.
|
|
2431
2614
|
`));
|
|
2432
2615
|
}
|
|
@@ -2458,7 +2641,7 @@ function resolveAutoChange(options, rootDir, isSilent, useJson) {
|
|
|
2458
2641
|
return handlePendingTasks(detection, isSilent, useJson);
|
|
2459
2642
|
}
|
|
2460
2643
|
if (!isSilent) {
|
|
2461
|
-
console.log(
|
|
2644
|
+
console.log(pc11.cyan(` \u2714 Automatically detected SDD change: ${pc11.bold(detection.changeId)} (via ${detection.source})`));
|
|
2462
2645
|
}
|
|
2463
2646
|
return detection.changeId;
|
|
2464
2647
|
}
|
|
@@ -2466,7 +2649,7 @@ function resolveIntegrationChangeId(options, rootDir, isSilent, useJson) {
|
|
|
2466
2649
|
const changeId = options.change || (options.auto ? resolveAutoChange(options, rootDir, isSilent, useJson) : null);
|
|
2467
2650
|
if (!changeId) {
|
|
2468
2651
|
if (!options.auto) {
|
|
2469
|
-
if (!isSilent) console.error(
|
|
2652
|
+
if (!isSilent) console.error(pc11.red("\n\u2716 Change identifier (--change <id>) or --auto option must be specified.\n"));
|
|
2470
2653
|
if (useJson) {
|
|
2471
2654
|
console.log(JSON.stringify({ command: "sdd:integrate", success: false, exitCode: 1, error: "Change identifier (--change <id>) or --auto option must be specified." }, null, 2));
|
|
2472
2655
|
}
|
|
@@ -2476,22 +2659,22 @@ function resolveIntegrationChangeId(options, rootDir, isSilent, useJson) {
|
|
|
2476
2659
|
return changeId;
|
|
2477
2660
|
}
|
|
2478
2661
|
function printIntegrationSuccess(changeId, result) {
|
|
2479
|
-
console.log(` ${
|
|
2480
|
-
console.log(` - Completed tasks: ${
|
|
2481
|
-
console.log(` - Integrated requirements: ${
|
|
2482
|
-
console.log(` - Created canonical artifacts: ${
|
|
2483
|
-
console.log(` - Updated product artifacts: ${
|
|
2484
|
-
console.log(` - Updated arc42 architecture: ${
|
|
2662
|
+
console.log(` ${pc11.green("\u2714")} Change '${changeId}' successfully processed:`);
|
|
2663
|
+
console.log(` - Completed tasks: ${pc11.bold(String(result.completedTasks.length))}`);
|
|
2664
|
+
console.log(` - Integrated requirements: ${pc11.green(result.integratedRequirements.join(", ") || "None")}`);
|
|
2665
|
+
console.log(` - Created canonical artifacts: ${pc11.green(result.createdCanonicalArtifacts?.join(", ") || "None")}`);
|
|
2666
|
+
console.log(` - Updated product artifacts: ${pc11.green(result.updatedProductArtifacts.join(", ") || "None")}`);
|
|
2667
|
+
console.log(` - Updated arc42 architecture: ${pc11.green(result.updatedArchitectureArtifacts.join(", ") || "None")}`);
|
|
2485
2668
|
if (result.archived) {
|
|
2486
|
-
console.log(` - Archived to: ${
|
|
2669
|
+
console.log(` - Archived to: ${pc11.cyan(result.archivedPath || "specs/changes/completed")}`);
|
|
2487
2670
|
}
|
|
2488
|
-
console.log(
|
|
2671
|
+
console.log(pc11.green("\n\u2714 Canonical specification integration COMPLETED (EXIT 0)\n"));
|
|
2489
2672
|
}
|
|
2490
2673
|
function printIntegrationFailure(changeId, errors) {
|
|
2491
|
-
console.log(
|
|
2674
|
+
console.log(pc11.red(`
|
|
2492
2675
|
\u2716 Failed to integrate change '${changeId}':`));
|
|
2493
|
-
for (const err of errors) console.log(` ${
|
|
2494
|
-
console.log(
|
|
2676
|
+
for (const err of errors) console.log(` ${pc11.red("\u2716")} ${err}`);
|
|
2677
|
+
console.log(pc11.red("\n\u2716 Integration BLOCKED (EXIT 1)\n"));
|
|
2495
2678
|
}
|
|
2496
2679
|
function emitIntegrateJson(changeId, result) {
|
|
2497
2680
|
const payload = {
|
|
@@ -2511,16 +2694,16 @@ function emitIntegrateJson(changeId, result) {
|
|
|
2511
2694
|
console.log(JSON.stringify(payload, null, 2));
|
|
2512
2695
|
}
|
|
2513
2696
|
function printBatchIntegrationResult(result) {
|
|
2514
|
-
console.log(` ${
|
|
2515
|
-
console.log(` ${
|
|
2516
|
-
console.log(` ${
|
|
2517
|
-
console.log(` ${
|
|
2518
|
-
console.log(` ${
|
|
2697
|
+
console.log(` ${pc11.green("\u2714")} Processed changes: ${pc11.bold(String(result.processedChanges.length))} (${result.processedChanges.join(", ") || "None"})`);
|
|
2698
|
+
console.log(` ${pc11.yellow("\u2139")} Skipped changes: ${pc11.bold(String(result.skippedChanges.length))}`);
|
|
2699
|
+
console.log(` ${pc11.green("\u2714")} Updated product artifacts: ${pc11.green(result.updatedProductArtifacts.join(", ") || "None")}`);
|
|
2700
|
+
console.log(` ${pc11.green("\u2714")} Updated arc42 architecture: ${pc11.green(result.updatedArchitectureArtifacts.join(", ") || "None")}`);
|
|
2701
|
+
console.log(` ${pc11.green("\u2714")} Synced PDaC SHA-256 digests: ${pc11.cyan(String(result.syncedDigestsCount))}`);
|
|
2519
2702
|
if (result.success) {
|
|
2520
|
-
console.log(
|
|
2703
|
+
console.log(pc11.green("\n\u2714 Batch canonical specification integration COMPLETED (EXIT 0)\n"));
|
|
2521
2704
|
} else {
|
|
2522
|
-
for (const err of result.errors) console.log(` ${
|
|
2523
|
-
console.log(
|
|
2705
|
+
for (const err of result.errors) console.log(` ${pc11.red("\u2716")} ${err}`);
|
|
2706
|
+
console.log(pc11.red("\n\u2716 Batch integration finished with errors (EXIT 1)\n"));
|
|
2524
2707
|
}
|
|
2525
2708
|
}
|
|
2526
2709
|
function emitBatchIntegrateJson(result) {
|
|
@@ -2540,7 +2723,7 @@ function emitBatchIntegrateJson(result) {
|
|
|
2540
2723
|
}
|
|
2541
2724
|
function runBatchSddIntegrate(options, rootDir, isSilent, useJson) {
|
|
2542
2725
|
if (!isSilent) {
|
|
2543
|
-
console.log(
|
|
2726
|
+
console.log(pc11.bold(pc11.cyan("\n\u{1F504} [AI-SDLC SDD] Consolidating all completed SDD changes into canonical specifications...")));
|
|
2544
2727
|
}
|
|
2545
2728
|
const result = integrateAllSddChanges({ rootDir, author: options.author, autoArchive: options.autoArchive });
|
|
2546
2729
|
if (!isSilent) printBatchIntegrationResult(result);
|
|
@@ -2557,7 +2740,7 @@ function runSddIntegrate(options) {
|
|
|
2557
2740
|
const changeId = resolveIntegrationChangeId(options, rootDir, isSilent, useJson);
|
|
2558
2741
|
if (!changeId) return false;
|
|
2559
2742
|
if (!isSilent) {
|
|
2560
|
-
console.log(
|
|
2743
|
+
console.log(pc11.bold(pc11.cyan(`
|
|
2561
2744
|
\u{1F504} [AI-SDLC SDD] Integrating change '${changeId}' into canonical specification...`)));
|
|
2562
2745
|
}
|
|
2563
2746
|
const result = integrateSddChange({ rootDir, changeId, author: options.author, autoArchive: options.autoArchive });
|
|
@@ -2569,24 +2752,24 @@ function runSddIntegrate(options) {
|
|
|
2569
2752
|
return result.success;
|
|
2570
2753
|
}
|
|
2571
2754
|
function printChangeNewSuccess(result) {
|
|
2572
|
-
console.log(` ${
|
|
2573
|
-
console.log(` ${
|
|
2574
|
-
console.log(` ${
|
|
2755
|
+
console.log(` ${pc11.green("\u2714")} Change directory: ${pc11.bold(result.changeDir)}`);
|
|
2756
|
+
console.log(` ${pc11.green("\u2714")} SDD Change ID: ${pc11.cyan(result.canonicalId)} (${result.changeId})`);
|
|
2757
|
+
console.log(` ${pc11.green("\u2714")} Risk profile: ${pc11.magenta(result.profile || "standard")}`);
|
|
2575
2758
|
if (result.productArtifactCreated) {
|
|
2576
|
-
console.log(` ${
|
|
2759
|
+
console.log(` ${pc11.green("\u2714")} Product artifact: ${pc11.bold(result.productArtifactCreated)} (status: draft)`);
|
|
2577
2760
|
}
|
|
2578
|
-
console.log(` ${
|
|
2761
|
+
console.log(` ${pc11.green("\u2714")} Cited artifacts: ${result.citedArtifacts.length}`);
|
|
2579
2762
|
for (const cite of result.citedArtifacts) {
|
|
2580
|
-
console.log(` - [${
|
|
2763
|
+
console.log(` - [${pc11.cyan(cite.id)}] ${cite.digest.substring(0, 19)}... (${cite.title || "Untitled"})`);
|
|
2581
2764
|
}
|
|
2582
|
-
console.log(` ${
|
|
2583
|
-
console.log(
|
|
2765
|
+
console.log(` ${pc11.green("\u2714")} Generated files: ${result.createdFiles.length}`);
|
|
2766
|
+
console.log(pc11.green("\n\u2714 SDD change successfully initialized and validated.\n"));
|
|
2584
2767
|
}
|
|
2585
2768
|
function printChangeNewFailure(name, errors) {
|
|
2586
|
-
console.log(
|
|
2769
|
+
console.log(pc11.red(`
|
|
2587
2770
|
\u2716 Failed to create SDD change '${name}':`));
|
|
2588
|
-
for (const err of errors) console.log(` ${
|
|
2589
|
-
console.log(
|
|
2771
|
+
for (const err of errors) console.log(` ${pc11.red("\u2716")} ${err}`);
|
|
2772
|
+
console.log(pc11.red("\n\u2716 Change creation BLOCKED\n"));
|
|
2590
2773
|
}
|
|
2591
2774
|
function emitChangeNewJson(name, result) {
|
|
2592
2775
|
const payload = {
|
|
@@ -2606,7 +2789,7 @@ function emitChangeNewJson(name, result) {
|
|
|
2606
2789
|
console.log(JSON.stringify(payload, null, 2));
|
|
2607
2790
|
}
|
|
2608
2791
|
function printChangeNewHeader(name, framework) {
|
|
2609
|
-
console.log(
|
|
2792
|
+
console.log(pc11.bold(pc11.cyan(`
|
|
2610
2793
|
\u{1F4E6} [AI-SDLC SDD] Scaffolding new SDD change '${name}' (${framework})...`)));
|
|
2611
2794
|
}
|
|
2612
2795
|
function handleScaffoldOutput(name, result, isSilent, useJson) {
|
|
@@ -2641,7 +2824,18 @@ function runChangeNew(options) {
|
|
|
2641
2824
|
|
|
2642
2825
|
// src/index.ts
|
|
2643
2826
|
var program = new Command();
|
|
2644
|
-
program.name("aisdlc").description("AI-SDLC: Spec-Driven Development, Governance & Quality Gates for AI & Humans").version("4.
|
|
2827
|
+
program.name("aisdlc").description("AI-SDLC: Spec-Driven Development, Governance & Quality Gates for AI & Humans").version("4.2.0");
|
|
2828
|
+
program.command("doctor").description("Comprehensive environment, toolchain, git-hooks, and security health diagnostics").option("-r, --root <path>", "Project root directory").option("--fix", "Automatically repair broken or missing git hooks with backup").option("--json", "Emit diagnostics report in structured JSON format").option("--strict", "Fail with non-zero exit code on warnings as well as critical failures").option("--offline", "Skip remote external network probes (e.g. for air-gapped environments)").option("--timeout <ms>", "Maximum timeout in milliseconds for subprocess execution", parseInt).action(async (opts) => {
|
|
2829
|
+
const exitCode = await runDoctor({
|
|
2830
|
+
rootDir: opts.root,
|
|
2831
|
+
fix: opts.fix,
|
|
2832
|
+
json: opts.json,
|
|
2833
|
+
strict: opts.strict,
|
|
2834
|
+
offline: opts.offline,
|
|
2835
|
+
timeout: opts.timeout
|
|
2836
|
+
});
|
|
2837
|
+
process.exit(exitCode);
|
|
2838
|
+
});
|
|
2645
2839
|
program.command("check").description("Unified pre-flight command: validates Quality Gates with optional non-destructive auto-fix").option("--fix", "Automatically synchronize Gherkin scenarios (.feature) and cryptographic digests of PDaC citations").option("-r, --root <path>", "Project root directory").option("--vuln", "Scan for known vulnerabilities (CVE/GHSA) in dependencies").option("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text or json").action((opts) => {
|
|
2646
2840
|
const passed = runCheck({
|
|
2647
2841
|
fix: opts.fix,
|
|
@@ -2652,8 +2846,8 @@ program.command("check").description("Unified pre-flight command: validates Qual
|
|
|
2652
2846
|
process.exit(passed ? 0 : 1);
|
|
2653
2847
|
});
|
|
2654
2848
|
var verifyCommand = program.command("verify").description("Run deterministic verifiers for quality, traceability, governance, and licenses");
|
|
2655
|
-
verifyCommand.command("all", { isDefault: true }).description("Run the full quality and governance suite (Quality Gate + RTM + Tasks + Tests + Licenses + PDaC + Schemas + Duplicates + Security + Privacy)").option("-r, --root <path>", "Project root directory").option("-p, --policy <path>", "Path to quality-policy.yaml").option("-C, --max-cyclomatic <number>", "Maximum Cyclomatic Complexity threshold").option("-K, --max-cognitive <number>", "Maximum Cognitive Complexity threshold").option("-M, --min-maintainability <number>", "Minimum Maintainability threshold (0-100)").option("-L, --max-lines <number>", "Maximum lines per function threshold").option("-m, --mode <mode>", "Enforcement mode: STRICT or PERMISSIVE").option("--no-vuln", "Disable dependency vulnerability scanning").option("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text or json").action((opts) => {
|
|
2656
|
-
const passed =
|
|
2849
|
+
verifyCommand.command("all", { isDefault: true }).description("Run the full quality and governance suite (Quality Gate + RTM + Tasks + Tests + Licenses + PDaC + Schemas + Duplicates + Security + Privacy)").option("-r, --root <path>", "Project root directory").option("-p, --policy <path>", "Path to quality-policy.yaml").option("-C, --max-cyclomatic <number>", "Maximum Cyclomatic Complexity threshold").option("-K, --max-cognitive <number>", "Maximum Cognitive Complexity threshold").option("-M, --min-maintainability <number>", "Minimum Maintainability threshold (0-100)").option("-L, --max-lines <number>", "Maximum lines per function threshold").option("-m, --mode <mode>", "Enforcement mode: STRICT or PERMISSIVE").option("--no-vuln", "Disable dependency vulnerability scanning").option("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text or json").action(async (opts) => {
|
|
2850
|
+
const passed = await runVerifyAllAsync({
|
|
2657
2851
|
root: opts.root,
|
|
2658
2852
|
policy: opts.policy,
|
|
2659
2853
|
maxCyclomatic: opts.maxCyclomatic,
|
|
@@ -2702,8 +2896,8 @@ verifyCommand.command("gherkin").description("Verify BDD synchronization between
|
|
|
2702
2896
|
const passed = runVerifyGherkin({ root: opts.root, json: opts.json, format: opts.format });
|
|
2703
2897
|
process.exit(passed ? 0 : 1);
|
|
2704
2898
|
});
|
|
2705
|
-
verifyCommand.command("licenses").description("Verify OSS license compliance against license-policy.yaml (dynamic SCA and SBOM)").option("-r, --root <path>", "Project root directory").option("-p, --policy <path>", "Path to license-policy.yaml").option("-m, --manifest <path>", "Path to license-manifest.yaml").option("--no-dynamic", "Disable dynamic scanning and require static manifest file").option("--sbom [path]", "Generate CycloneDX 1.5 JSON standard SBOM file").option("--notices [path]", "Generate THIRD_PARTY_NOTICES.md legal notices and attributions file").option("--tool <tool>", "SCA tool: native, trivy, syft", "native").option("--depth <depth>", "Analysis depth: direct or transitive", "transitive").option("--vuln", "Scan for known vulnerabilities (CVE/GHSA) in dependencies").option("--no-vuln", "Disable dependency vulnerability scanning").option("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text or json").action((opts) => {
|
|
2706
|
-
const passed =
|
|
2899
|
+
verifyCommand.command("licenses").description("Verify OSS license compliance against license-policy.yaml (dynamic SCA and SBOM)").option("-r, --root <path>", "Project root directory").option("-p, --policy <path>", "Path to license-policy.yaml").option("-m, --manifest <path>", "Path to license-manifest.yaml").option("--no-dynamic", "Disable dynamic scanning and require static manifest file").option("--sbom [path]", "Generate CycloneDX 1.5 JSON standard SBOM file").option("--sbom-input <path>", "Ingest an existing CycloneDX 1.x or SPDX 2.x SBOM JSON file to fill license gaps").option("--notices [path]", "Generate THIRD_PARTY_NOTICES.md legal notices and attributions file").option("--tool <tool>", "SCA tool: native, trivy, syft", "native").option("--depth <depth>", "Analysis depth: direct or transitive", "transitive").option("--vuln", "Scan for known vulnerabilities (CVE/GHSA) in dependencies").option("--no-vuln", "Disable dependency vulnerability scanning").option("--non-interactive", "Run in non-interactive mode without tool install prompts").option("--no-install-prompt", "Disable interactive tool install prompt").option("--ci", "Run in non-interactive CI mode").option("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text or json").action(async (opts) => {
|
|
2900
|
+
const passed = await runVerifyLicensesAsync({
|
|
2707
2901
|
root: opts.root,
|
|
2708
2902
|
policy: opts.policy,
|
|
2709
2903
|
manifest: opts.manifest,
|
|
@@ -2711,8 +2905,12 @@ verifyCommand.command("licenses").description("Verify OSS license compliance aga
|
|
|
2711
2905
|
tool: opts.tool,
|
|
2712
2906
|
depth: opts.depth,
|
|
2713
2907
|
sbom: opts.sbom,
|
|
2908
|
+
sbomInput: opts.sbomInput,
|
|
2714
2909
|
notices: opts.notices,
|
|
2715
2910
|
vuln: opts.vuln,
|
|
2911
|
+
nonInteractive: opts.nonInteractive,
|
|
2912
|
+
noInstallPrompt: opts.installPrompt === false,
|
|
2913
|
+
ci: opts.ci,
|
|
2716
2914
|
json: opts.json,
|
|
2717
2915
|
format: opts.format
|
|
2718
2916
|
});
|
|
@@ -2730,8 +2928,8 @@ verifyCommand.command("duplicates").description("Audit duplicate requirements, I
|
|
|
2730
2928
|
const passed = runVerifyDuplicates({ root: opts.root, similarity: opts.similarity, json: opts.json, format: opts.format });
|
|
2731
2929
|
process.exit(passed ? 0 : 1);
|
|
2732
2930
|
});
|
|
2733
|
-
verifyCommand.command("security").description("Unified security verification: deterministic secrets detection (Gitleaks) and shift-left SAST").option("-r, --root <path>", "Project root directory").option("-d, --diff", "Scan only lines added in the current branch git diff").option("-b, --base <branch>", "Base branch for git diff calculation (default: origin/main or HEAD)").option("-g, --gitleaks", "Delegate or contrast with native Gitleaks binary if available").option("-s, --semgrep", "Delegate to Semgrep CLI if installed").option("-e, --entropy <number>", "Minimum Shannon entropy threshold (0.0 to 8.0)", "4.3").option("-m, --min-severity <level>", "Minimum severity for SAST failure: CRITICAL, HIGH, MEDIUM", "HIGH").option("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text, json, or sarif").option("-o, --output <path>", "Output SARIF report file path (default: reports/security.sarif)").action((opts) => {
|
|
2734
|
-
const passed =
|
|
2931
|
+
verifyCommand.command("security").description("Unified security verification: deterministic secrets detection (Gitleaks) and shift-left SAST").option("-r, --root <path>", "Project root directory").option("-d, --diff", "Scan only lines added in the current branch git diff").option("-b, --base <branch>", "Base branch for git diff calculation (default: origin/main or HEAD)").option("-g, --gitleaks", "Delegate or contrast with native Gitleaks binary if available").option("-s, --semgrep", "Delegate to Semgrep CLI if installed").option("-e, --entropy <number>", "Minimum Shannon entropy threshold (0.0 to 8.0)", "4.3").option("-m, --min-severity <level>", "Minimum severity for SAST failure: CRITICAL, HIGH, MEDIUM", "HIGH").option("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text, json, or sarif").option("-o, --output <path>", "Output SARIF report file path (default: reports/security.sarif)").action(async (opts) => {
|
|
2932
|
+
const passed = await runVerifySecurityAsync({
|
|
2735
2933
|
root: opts.root,
|
|
2736
2934
|
diff: opts.diff,
|
|
2737
2935
|
base: opts.base,
|
|
@@ -2758,11 +2956,16 @@ verifyCommand.command("secrets").description("Verify absence of exposed credenti
|
|
|
2758
2956
|
});
|
|
2759
2957
|
process.exit(passed ? 0 : 4);
|
|
2760
2958
|
});
|
|
2761
|
-
verifyCommand.command("sast").description("Shift-left static application security testing (SAST) for critical patterns (SQLi, exec, SSRF)").option("-r, --root <path>", "Project root directory").option("-s, --semgrep", "Delegate to Semgrep CLI if installed").option("-m, --min-severity <level>", "Minimum severity for failure: CRITICAL, HIGH, MEDIUM", "HIGH").option("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text, json, or sarif").option("-o, --output <path>", "Output file path (e.g. reports/sast.sarif)").action((opts) => {
|
|
2762
|
-
const passed =
|
|
2959
|
+
verifyCommand.command("sast").description("Shift-left static application security testing (SAST) for critical patterns (SQLi, exec, SSRF)").option("-r, --root <path>", "Project root directory").option("-s, --semgrep", "Delegate to Semgrep CLI if installed").option("-m, --min-severity <level>", "Minimum severity for failure: CRITICAL, HIGH, MEDIUM", "HIGH").option("--sarif <paths...>", "Ingest external OASIS SARIF v2.1.0 report(s) for deterministic SAST evaluation").option("--orchestrate", "Auto-detect project ecosystems and orchestrate native SAST CLIs via SARIF").option("--non-interactive", "Run in non-interactive mode without tool install prompts").option("--no-install-prompt", "Disable interactive tool install prompt").option("--ci", "Run in non-interactive CI mode").option("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text, json, or sarif").option("-o, --output <path>", "Output file path (e.g. reports/sast.sarif)").action(async (opts) => {
|
|
2960
|
+
const passed = await runVerifySastAsync({
|
|
2763
2961
|
root: opts.root,
|
|
2764
2962
|
semgrep: opts.semgrep,
|
|
2765
2963
|
minSeverity: opts.minSeverity,
|
|
2964
|
+
sarif: opts.sarif,
|
|
2965
|
+
orchestrate: opts.orchestrate,
|
|
2966
|
+
nonInteractive: opts.nonInteractive,
|
|
2967
|
+
noInstallPrompt: opts.installPrompt === false,
|
|
2968
|
+
ci: opts.ci,
|
|
2766
2969
|
json: opts.json,
|
|
2767
2970
|
format: opts.format,
|
|
2768
2971
|
output: opts.output
|
|
@@ -2807,6 +3010,17 @@ reportCommand.command("dashboard").description("Generate interactive web dashboa
|
|
|
2807
3010
|
});
|
|
2808
3011
|
process.exit(passed ? 0 : 1);
|
|
2809
3012
|
});
|
|
3013
|
+
reportCommand.command("compliance").description("Generate Regulatory Compliance Evidence Bundle (EU AI Act, ISO 42001, NIST SSDF)").option("-r, --root <path>", "Project root directory").option("-o, --output <path>", "Output JSON file path (default: reports/audit-evidence-bundle.json)").option("--offline", "Offline execution: prohibit external network calls").option("--strict", "Strict mode: fail closed if any of 12 Quality Gates is missing or stale").option("--keyless", "Enable keyless OIDC attestation claims").option("--dry-run", "Dry run without writing to disk").action((opts) => {
|
|
3014
|
+
const passed = runReportCompliance({
|
|
3015
|
+
root: opts.root,
|
|
3016
|
+
output: opts.output,
|
|
3017
|
+
offline: opts.offline,
|
|
3018
|
+
strict: opts.strict,
|
|
3019
|
+
keyless: opts.keyless,
|
|
3020
|
+
dryRun: opts.dryRun
|
|
3021
|
+
});
|
|
3022
|
+
process.exit(passed ? 0 : 1);
|
|
3023
|
+
});
|
|
2810
3024
|
var gherkinCommand = program.command("gherkin").description("BDD / Gherkin synchronization and extraction tools");
|
|
2811
3025
|
gherkinCommand.command("extract").description("Extract ```gherkin``` blocks from Markdown specifications into .feature files").option("-r, --root <path>", "Project root directory").option("-p, --path <path>", "Target Markdown file or directory").option("-a, --all", "Process all specifications and requirements").option("--json", "Structured JSON format output").option("-F, --format <format>", "Output format: text or json").action((opts) => {
|
|
2812
3026
|
const passed = runGherkinExtract({
|
|
@@ -3003,10 +3217,22 @@ reviewCmd.command("submit").description("Persist a formal review report for an a
|
|
|
3003
3217
|
});
|
|
3004
3218
|
if (!ok) process.exit(1);
|
|
3005
3219
|
});
|
|
3220
|
+
program.command("migrate").description("Synchronize schemas, templates, and policies with upstream canonical versions").option("-r, --root <path>", "Repository root directory").option("--dry-run", "Preview changes without mutating filesystem").option("--no-backup", "Disable pre-migration backup").option("-f, --force", "Overwrite local customizations with canonical versions").option("--allow-policy-downgrade", "Permit relaxing stricter quality or security thresholds").option("--json", "Output migration report as JSON").option("-v, --verbose", "Enable verbose logging").action(async (opts) => {
|
|
3221
|
+
const exitCode = await runMigrate({
|
|
3222
|
+
root: opts.root,
|
|
3223
|
+
dryRun: opts.dryRun,
|
|
3224
|
+
backup: opts.backup,
|
|
3225
|
+
force: opts.force,
|
|
3226
|
+
allowPolicyDowngrade: opts.allowPolicyDowngrade,
|
|
3227
|
+
json: opts.json,
|
|
3228
|
+
verbose: opts.verbose
|
|
3229
|
+
});
|
|
3230
|
+
process.exit(exitCode);
|
|
3231
|
+
});
|
|
3006
3232
|
program.on("command:*", () => {
|
|
3007
|
-
console.error(
|
|
3233
|
+
console.error(pc12.red(`
|
|
3008
3234
|
[ERROR] Unrecognized command: ${program.args.join(" ")}`));
|
|
3009
|
-
console.log(
|
|
3235
|
+
console.log(pc12.yellow("Run `aisdlc --help` to see available commands.\n"));
|
|
3010
3236
|
process.exit(1);
|
|
3011
3237
|
});
|
|
3012
3238
|
program.parse(process.argv);
|