@aisdlc/cli 2.0.2 → 2.2.1

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/README.md CHANGED
@@ -64,7 +64,7 @@ The `aisdlc` CLI provides comprehensive commands across 6 functional categories
64
64
 
65
65
  | Command | Description | Key Options |
66
66
  | --- | --- | --- |
67
- | `aisdlc init [directory]` | Bootstraps a repository with AI-SDLC folders, all 33 canonical JSON schemas (Draft 2020-12), 37 base starter templates (Product, Security, Privacy, Safety, Manuals, Compliance, SDD, CI), Pull Request templates, policies (`quality-policy.yaml`, `license-policy.yaml`, `privacy-policy.yaml`), and AI agent configs (11 specialized agents). Unconditionally generates universal MCP configurations (`antigravity.mcp.json`, `.vscode/mcp.json`, `.cursor/mcp.json`). Non-destructively injects standard npm scripts into consumer `package.json`. In interactive TTY mode, prompts for CI/CD provider, architecture level, and AI agent targets. | `-d, --dry-run`, `--ci <github\|gitlab\|azure\|bitbucket\|none>`, `--agents <all\|cursor\|claude\|antigravity\|copilot\|mcp\|none>`, `--arch <minimal\|full\|none>`, `--json`, `-F, --format <format>` |
67
+ | `aisdlc init [directory]` | Bootstraps a repository with AI-SDLC folders, all 34 canonical JSON schemas (Draft 2020-12), 38 base starter templates (Product, Security, Privacy, Safety, Manuals, Compliance, SDD, CI), Pull Request templates, policies (`quality-policy.yaml`, `license-policy.yaml`, `privacy-policy.yaml`), and AI agent configs (11 specialized agents). Unconditionally generates universal MCP configurations (`antigravity.mcp.json`, `.vscode/mcp.json`, `.cursor/mcp.json`). Non-destructively injects standard npm scripts into consumer `package.json`. In interactive TTY mode, prompts for CI/CD provider, architecture level, and AI agent targets. | `-d, --dry-run`, `--ci <github\|gitlab\|azure\|bitbucket\|none>`, `--agents <all\|cursor\|claude\|antigravity\|copilot\|mcp\|none>`, `--arch <minimal\|full\|none>`, `--json`, `-F, --format <format>` |
68
68
  | `aisdlc check` | Unified pre-flight gate: runs Quality Gate checks with optional auto-repair (syncs Gherkin to `.feature` and recalculates PDaC SHA-256 digests). | `--fix`, `-r, --root <path>`, `--json`, `-F, --format <format>` |
69
69
  | `aisdlc mcp` | Starts the native Model Context Protocol (MCP) server over `stdio` exposing 24 deterministic tools and 6 context resources. | `-r, --root <path>` |
70
70
 
@@ -76,8 +76,8 @@ Running `aisdlc init` (or `npx @aisdlc/cli init`) delivers a turnkey governance
76
76
  - **Architecture Granularity**: Minimal / Baseline (default: `ARCH-INTRO-*`, `CMP-*`, `ADR-*`), Full (all 12 arc42 sections), or None.
77
77
  - **AI Agents**: All (Cursor, Claude Code, Antigravity, Copilot, MCP - recommended) or granular environments.
78
78
  2. **Universal MCP Integration**: Regardless of CI provider or agent selection, automatically scaffolds `.cursor/mcp.json`, `antigravity.mcp.json`, and `.vscode/mcp.json` preconfigured for `@aisdlc/mcp`.
79
- 3. **Canonical Starter Templates**: Deploys 37 templates into `templates/` (product, security, privacy, safety, manuals, compliance, SDD, and CI/CD reference templates).
80
- 4. **JSON Schemas (Draft 2020-12)**: Scaffolds all 33 schemas under `schemas/` and provides automatic in-memory fallback during verification if disk files are deleted.
79
+ 3. **Canonical Starter Templates**: Deploys 38 templates into `templates/` (product, security, privacy, safety, manuals, compliance, SDD, and CI/CD reference templates).
80
+ 4. **JSON Schemas (Draft 2020-12)**: Scaffolds all 34 schemas under `schemas/` and provides automatic in-memory fallback during verification if disk files are deleted.
81
81
  5. **Pull Request Templates**: Deposits `.github/PULL_REQUEST_TEMPLATE.md` with non-negotiable Plan Execution Matrix (`[X]` vs `[O]`), Weak Points hotspots, and automated KPI tables.
82
82
  6. **Automatic Script Injection**: Non-destructively registers standard shortcuts in consumer `package.json` (`check`, `check:fix`, `verify:quality`, `verify:privacy`, `verify:all`, `change:new`).
83
83
 
@@ -101,12 +101,12 @@ Running `aisdlc init` (or `npx @aisdlc/cli init`) delivers a turnkey governance
101
101
  | `aisdlc verify governance` | Audits task governance, human review plans, and autonomy modes (`AUTONOMOUS`, `HUMAN_REVIEW_PLAN`, etc.). | `-r, --root <path>`, `--json` |
102
102
  | `aisdlc verify testing` | Audits that 100% of requirements and tasks have corresponding verifiable tests on disk. | `-r, --root <path>`, `--json` |
103
103
  | `aisdlc verify gherkin` | Verifies that `.feature` files match specification Gherkin scenarios with identical SHA-256 digests. | `-p, --path <path>`, `-a, --all`, `-r, --root <path>`, `--json` |
104
- | `aisdlc verify licenses` | Audits Open Source license compliance against `license-policy.yaml` with dynamic SCA scan, CycloneDX 1.5 SBOM, and legal notices. | `-p, --policy <path>`, `--sbom [path]`, `--notices [path]`, `--tool <native\|trivy\|syft>`, `--depth <direct\|transitive>`, `--json` |
104
+ | `aisdlc verify licenses` | Audits Open Source license compliance and CVE vulnerabilities against `license-policy.yaml` with dynamic SCA scan, CycloneDX 1.5 SBOM, and legal notices. | `-p, --policy <path>`, `--sbom [path]`, `--notices [path]`, `--tool <native\|trivy\|syft>`, `--depth <direct\|transitive>`, `--vuln`, `--vuln-max-critical <n>`, `--vuln-max-high <n>`, `--json` |
105
105
  | `aisdlc verify pdac` | Verifies the Product Definition as Code graph and checks for cryptographic drift against SHA-256 digests. | `-r, --root <path>`, `--json` |
106
106
  | `aisdlc verify schemas` | Validates specification Markdown artifacts and `handoff.yaml` sidecars against canonical JSON Schemas (Draft 2020-12). | `-p, --path <path>`, `-r, --root <path>`, `--json` |
107
107
  | `aisdlc verify duplicates` | Detects redundant requirements, ID collisions, title lexical redundancy ($\ge 85\%$), and BDD overlaps before coding. | `-s, --similarity <number>` *(default: 0.85)*, `-r, --root <path>`, `--json` |
108
108
  | `aisdlc verify friction [change]` | Evaluates progressive friction and Anti-Bypass rules (verifies change scope matches risk profile: `patch`, `standard`, `critical`). | `-r, --root <path>`, `--json` |
109
- | `aisdlc verify security` | Unified shift-left security gate: deterministic secret scanning (Gitleaks) and SAST (OWASP Top 10 vulnerabilities). | `-d, --diff`, `-b, --base <branch>`, `-g, --gitleaks`, `-s, --semgrep`, `-e, --entropy <n>`, `-m, --min-severity <level>`, `--json` |
109
+ | `aisdlc verify security` | Unified shift-left security gate: deterministic secret scanning (Gitleaks), SAST (OWASP Top 10), and audited exception comments. | `-d, --diff`, `-b, --base <branch>`, `-g, --gitleaks`, `-s, --semgrep`, `-e, --entropy <n>`, `-m, --min-severity <level>`, `--audit-suppressions`, `--suppressions-report <path>`, `--json` |
110
110
  | `aisdlc verify privacy` | Gate 12: Audits Data Protection & Privacy-by-Design (`DATA-ASSET-*`, `PRIV-ROPA-*`, `PRIV-REQ-*`, `DPIA-*`) and PII-SAST rules (`PRIV-001`–`PRIV-008`) against `privacy-policy.yaml`. Exits with code 5 on violations. | `-r, --root <path>`, `-p, --policy <path>`, `--no-reports`, `--json` |
111
111
  | `aisdlc verify secrets` | Scans for exposed credentials, API keys, tokens, and high-entropy secrets (Shannon entropy $\ge 4.3$). Fails with exit code 4. | `-d, --diff`, `-b, --base <branch>`, `-g, --gitleaks`, `-e, --entropy <n>`, `--json` |
112
112
  | `aisdlc verify sast` | Static Application Security Testing for SQL injection, command injection, eval, SSRF, path traversal, and prompt injection. | `-s, --semgrep`, `-m, --min-severity <CRITICAL\|HIGH\|MEDIUM>`, `--json` |
package/dist/index.js CHANGED
@@ -26,6 +26,8 @@ import {
26
26
 
27
27
  // src/commands/verify.ts
28
28
  import pc from "picocolors";
29
+ import * as fs from "fs";
30
+ import * as path from "path";
29
31
  import {
30
32
  checkGherkinInSync,
31
33
  verifyArtifactDuplicates,
@@ -39,7 +41,11 @@ import {
39
41
  verifySecrets,
40
42
  verifyTasksGovernance,
41
43
  verifyTestingCoverage,
42
- verifyTraceability
44
+ verifyTraceability,
45
+ generateSuppressionsAuditReport,
46
+ generateSecuritySarifReport,
47
+ serializeSarifDocument,
48
+ writeSecuritySarifReport
43
49
  } from "@aisdlc/core";
44
50
  function isJsonOutput(options = {}) {
45
51
  if (options.json !== void 0) {
@@ -51,6 +57,13 @@ function isJsonOutput(options = {}) {
51
57
  const env = process.env.AISDLC_FORMAT?.trim().toLowerCase() || process.env.AISDLC_OUTPUT?.trim().toLowerCase();
52
58
  return env === "json";
53
59
  }
60
+ function isSarifOutput(options = {}) {
61
+ if (options.format !== void 0) {
62
+ return options.format.trim().toLowerCase() === "sarif";
63
+ }
64
+ const env = process.env.AISDLC_FORMAT?.trim().toLowerCase() || process.env.AISDLC_OUTPUT?.trim().toLowerCase();
65
+ return env === "sarif";
66
+ }
54
67
  function buildFunctionMetricViolations(results) {
55
68
  return results.filter((r) => r.status === "FAIL").flatMap(
56
69
  (r) => r.violations.map((v) => ({
@@ -85,7 +98,11 @@ function emitQualityJson(result) {
85
98
  passCount: result.passCount,
86
99
  failCount: result.failCount,
87
100
  untestedFunctionsCount: result.untestedFunctions?.length || 0,
88
- coverageViolationsCount: result.coverageViolations?.length || 0
101
+ coverageViolationsCount: result.coverageViolations?.length || 0,
102
+ baselineViolationsCount: result.baselineViolationsCount || 0,
103
+ toleratedViolationsCount: result.toleratedViolationsCount || 0,
104
+ newViolationsCount: result.newViolationsCount || 0,
105
+ baselineUpdated: result.baselineUpdated || false
89
106
  },
90
107
  violations
91
108
  };
@@ -115,15 +132,22 @@ function printQualityTestAndCoverageGaps(result) {
115
132
  console.log(` ${pc.red("\u2716")} ${cv}`);
116
133
  }
117
134
  }
135
+ function printQualitySummary(result, isPermissive) {
136
+ console.log(` Analyzed files: ${pc.bold(String(result.totalFiles))}`);
137
+ console.log(` Evaluated functions: ${pc.bold(String(result.totalFunctions))}`);
138
+ console.log(` Compliant functions: ${pc.green(String(result.passCount))}`);
139
+ if (result.toleratedViolationsCount && result.toleratedViolationsCount > 0) {
140
+ console.log(` Tolerated warnings: ${pc.yellow(String(result.toleratedViolationsCount))} (Ratchet mode)`);
141
+ }
142
+ const failStr = result.failCount > 0 ? isPermissive ? pc.yellow(String(result.failCount)) : pc.red(String(result.failCount)) : pc.green("0");
143
+ console.log(` Failing functions: ${failStr}`);
144
+ }
118
145
  function printQualityConsole(result) {
119
146
  const isPermissive = result.policy.enforce_mode === "PERMISSIVE";
120
147
  console.log(
121
148
  ` Active thresholds: CC <= ${result.policy.max_cyclomatic} | Cognitive <= ${result.policy.max_cognitive} | MI >= ${result.policy.min_maintainability} | Lines <= ${result.policy.max_function_lines} | Mode: ${result.policy.enforce_mode}`
122
149
  );
123
- console.log(` Analyzed files: ${pc.bold(String(result.totalFiles))}`);
124
- console.log(` Evaluated functions: ${pc.bold(String(result.totalFunctions))}`);
125
- console.log(` Compliant functions: ${pc.green(String(result.passCount))}`);
126
- console.log(` Failing functions: ${result.failCount > 0 ? isPermissive ? pc.yellow(String(result.failCount)) : pc.red(String(result.failCount)) : pc.green("0")}`);
150
+ printQualitySummary(result, isPermissive);
127
151
  if (result.failCount > 0) {
128
152
  printQualityFailingDetails(result.results.filter((r) => r.status === "FAIL"), isPermissive);
129
153
  }
@@ -151,7 +175,10 @@ function runVerifyQuality(options = {}) {
151
175
  const result = verifyQualityGate({
152
176
  rootDir,
153
177
  policyPath: options.policy,
154
- thresholds: buildQualityThresholds(options)
178
+ thresholds: buildQualityThresholds(options),
179
+ updateBaseline: options.updateBaseline,
180
+ baseline: options.baseline,
181
+ ratchet: options.ratchet
155
182
  });
156
183
  if (useJson) {
157
184
  emitQualityJson(result);
@@ -395,21 +422,34 @@ function emitLicensesJson(result) {
395
422
  };
396
423
  console.log(JSON.stringify(payload, null, 2));
397
424
  }
425
+ function printDetectedVulnerabilities(vulnerabilities) {
426
+ if (!vulnerabilities || vulnerabilities.length === 0) return;
427
+ console.log(pc.yellow("\n Detected package vulnerabilities (CVE/GHSA):"));
428
+ for (const v of vulnerabilities) {
429
+ console.log(` ${pc.red("\u2716")} [${v.severity}] [${v.id}] ${v.packageName}@${v.installedVersion} (CVSS: ${v.cvssV3Score ?? "N/A"}): ${v.primaryUrl || ""}`);
430
+ }
431
+ }
432
+ function printLicenseArtifacts(sbomPath, noticesPath) {
433
+ if (sbomPath) console.log(` CycloneDX SBOM generated: ${pc.cyan(sbomPath)}`);
434
+ if (noticesPath) console.log(` Legal notices generated: ${pc.cyan(noticesPath)}`);
435
+ }
436
+ function printLicenseViolations(violations) {
437
+ if (violations.length === 0) return;
438
+ console.log(pc.red("\n Detected license violations:"));
439
+ for (const v of violations) {
440
+ console.log(` ${pc.red("\u2716")} [${v.category}] ${v.packageName} (${v.license}): ${v.reason}`);
441
+ }
442
+ }
398
443
  function printLicensesConsole(result) {
399
444
  console.log(` Evaluated dependencies: ${pc.bold(String(result.totalEvaluated))}`);
400
445
  console.log(` Compliant dependencies: ${pc.green(String(result.permittedCount))}`);
401
446
  console.log(` License violations: ${result.violations.length > 0 ? pc.red(String(result.violations.length)) : pc.green("0")}`);
402
- if (result.sbomPath) {
403
- console.log(` CycloneDX SBOM generated: ${pc.cyan(result.sbomPath)}`);
404
- }
405
- if (result.noticesPath) {
406
- console.log(` Legal notices generated: ${pc.cyan(result.noticesPath)}`);
407
- }
408
- if (result.violations.length > 0) {
409
- console.log(pc.red("\n Detected license violations:"));
410
- for (const v of result.violations) {
411
- console.log(` ${pc.red("\u2716")} [${v.category}] ${v.packageName} (${v.license}): ${v.reason}`);
412
- }
447
+ printLicenseArtifacts(result.sbomPath, result.noticesPath);
448
+ printLicenseViolations(result.violations);
449
+ if (result.vulnerabilitiesSkipped) {
450
+ console.log(pc.gray(" Vulnerabilities (CVE/GHSA): skipped (Trivy not installed in environment; enforced in CI)"));
451
+ } else {
452
+ printDetectedVulnerabilities(result.vulnerabilities);
413
453
  }
414
454
  console.log(result.success ? pc.green("\n\u2714 OSS License Governance COMPLIANT\n") : pc.red("\n\u2716 OSS License Governance BLOCKED\n"));
415
455
  }
@@ -424,7 +464,8 @@ function buildLicenseVerifyInput(options, rootDir) {
424
464
  generateSbom: options.sbom !== void 0 ? Boolean(options.sbom) : void 0,
425
465
  sbomPath: typeof options.sbom === "string" ? options.sbom : void 0,
426
466
  generateNotices: options.notices !== void 0 ? Boolean(options.notices) : void 0,
427
- noticesPath: typeof options.notices === "string" ? options.notices : void 0
467
+ noticesPath: typeof options.notices === "string" ? options.notices : void 0,
468
+ scanVulnerabilities: options.vuln !== void 0 ? Boolean(options.vuln) : void 0
428
469
  };
429
470
  }
430
471
  function runVerifyLicenses(options = {}) {
@@ -689,12 +730,34 @@ function printSecretsConsole(result) {
689
730
  }
690
731
  console.log(result.success ? pc.green("\n\u2714 Secrets Detection COMPLIANT (0 Credential Leaks)\n") : pc.red("\n\u2716 Secrets Detection BLOCKED (Exit Code 4: Exposed Secret)\n"));
691
732
  }
733
+ function emitSecretsSarif(result, output) {
734
+ const doc = generateSecuritySarifReport({ secretsResult: result });
735
+ if (output) {
736
+ writeSecuritySarifReport(output, doc);
737
+ } else {
738
+ console.log(serializeSarifDocument(doc));
739
+ }
740
+ }
741
+ function handleSecretsOutput(result, options, useSarif, useJson) {
742
+ if (useSarif || options.output) {
743
+ emitSecretsSarif(result, options.output);
744
+ return result.success;
745
+ }
746
+ if (useJson) {
747
+ emitSecretsJson(result);
748
+ return result.success;
749
+ }
750
+ if (!options.silent) {
751
+ printSecretsConsole(result);
752
+ }
753
+ return result.success;
754
+ }
692
755
  function runVerifySecrets(options = {}) {
693
756
  const rootDir = options.root || process.cwd();
694
757
  const entropyThreshold = options.entropy !== void 0 ? Number(options.entropy) : void 0;
695
758
  const useJson = isJsonOutput(options);
696
- const isSilent = Boolean(options.silent || useJson);
697
- if (!isSilent) {
759
+ const useSarif = isSarifOutput(options);
760
+ if (!options.silent && !useJson && !useSarif) {
698
761
  console.log(pc.bold(pc.cyan("\n\u{1F510} [AI-SDLC] Verifying Deterministic Secrets and Credentials Detection (Gitleaks Gate)...")));
699
762
  }
700
763
  const result = verifySecrets({
@@ -704,14 +767,7 @@ function runVerifySecrets(options = {}) {
704
767
  gitleaks: options.gitleaks,
705
768
  entropyThreshold
706
769
  });
707
- if (useJson) {
708
- emitSecretsJson(result);
709
- return result.success;
710
- }
711
- if (!options.silent) {
712
- printSecretsConsole(result);
713
- }
714
- return result.success;
770
+ return handleSecretsOutput(result, options, useSarif, useJson);
715
771
  }
716
772
  function emitSastJson(result) {
717
773
  const payload = {
@@ -744,11 +800,33 @@ function printSastConsole(result) {
744
800
  }
745
801
  console.log(result.success ? pc.green("\n\u2714 SAST Analysis COMPLIANT (0 Critical Vulnerabilities)\n") : pc.red("\n\u2716 SAST Analysis BLOCKED (Vulnerabilities Detected)\n"));
746
802
  }
803
+ function emitSastSarif(result, output) {
804
+ const doc = generateSecuritySarifReport({ sastResult: result });
805
+ if (output) {
806
+ writeSecuritySarifReport(output, doc);
807
+ } else {
808
+ console.log(serializeSarifDocument(doc));
809
+ }
810
+ }
811
+ function handleSastOutput(result, options, useSarif, useJson) {
812
+ if (useSarif || options.output) {
813
+ emitSastSarif(result, options.output);
814
+ return result.success;
815
+ }
816
+ if (useJson) {
817
+ emitSastJson(result);
818
+ return result.success;
819
+ }
820
+ if (!options.silent) {
821
+ printSastConsole(result);
822
+ }
823
+ return result.success;
824
+ }
747
825
  function runVerifySast(options = {}) {
748
826
  const rootDir = options.root || process.cwd();
749
827
  const useJson = isJsonOutput(options);
750
- const isSilent = Boolean(options.silent || useJson);
751
- if (!isSilent) {
828
+ const useSarif = isSarifOutput(options);
829
+ if (!options.silent && !useJson && !useSarif) {
752
830
  console.log(pc.bold(pc.cyan("\n\u{1F6E1}\uFE0F [AI-SDLC] Verifying Shift-Left SAST Security (Injections & OWASP Top 10)...")));
753
831
  }
754
832
  const result = verifySast({
@@ -756,14 +834,7 @@ function runVerifySast(options = {}) {
756
834
  semgrep: options.semgrep,
757
835
  minSeverity: options.minSeverity
758
836
  });
759
- if (useJson) {
760
- emitSastJson(result);
761
- return result.success;
762
- }
763
- if (!options.silent) {
764
- printSastConsole(result);
765
- }
766
- return result.success;
837
+ return handleSastOutput(result, options, useSarif, useJson);
767
838
  }
768
839
  function buildSecurityViolations(resultSecrets, resultSast) {
769
840
  const secretViolations = resultSecrets.findings.map((f) => ({
@@ -799,9 +870,18 @@ function emitSecurityJson(resultSecrets, resultSast, isOk) {
799
870
  };
800
871
  console.log(JSON.stringify(payload, null, 2));
801
872
  }
802
- function runVerifySecurity(options = {}) {
803
- const rootDir = options.root || process.cwd();
804
- const useJson = isJsonOutput(options);
873
+ function writeSuppressionsAuditReport(rootDir, suppressions) {
874
+ const reportsDir = path.join(rootDir, "reports");
875
+ if (!fs.existsSync(reportsDir)) {
876
+ fs.mkdirSync(reportsDir, { recursive: true });
877
+ }
878
+ fs.writeFileSync(
879
+ path.join(reportsDir, "SUPPRESSIONS_AUDIT.md"),
880
+ generateSuppressionsAuditReport(suppressions),
881
+ "utf-8"
882
+ );
883
+ }
884
+ function executeSecurityVerifiers(rootDir, options) {
805
885
  const entropyThreshold = options.entropy !== void 0 ? Number(options.entropy) : void 0;
806
886
  const resultSecrets = verifySecrets({
807
887
  rootDir,
@@ -815,14 +895,55 @@ function runVerifySecurity(options = {}) {
815
895
  semgrep: options.semgrep,
816
896
  minSeverity: options.minSeverity
817
897
  });
818
- const isOk = resultSecrets.success && resultSast.success;
819
- if (useJson) {
898
+ return { resultSecrets, resultSast };
899
+ }
900
+ function printSecurityConsoleSummary(silent, hasExpired) {
901
+ if (silent) return;
902
+ console.log(` Audit exceptions report: ${pc.cyan("reports/SUPPRESSIONS_AUDIT.md")}`);
903
+ if (hasExpired) {
904
+ console.log(pc.red(" \u2716 One or more security suppressions have expired! Quality Gate blocked.\n"));
905
+ }
906
+ }
907
+ function persistSecuritySarif(rootDir, resultSecrets, resultSast, customOutput) {
908
+ const doc = generateSecuritySarifReport({
909
+ secretsResult: resultSecrets,
910
+ sastResult: resultSast
911
+ });
912
+ const targetPath = customOutput || path.join(rootDir, "reports", "security.sarif");
913
+ writeSecuritySarifReport(targetPath, doc);
914
+ }
915
+ function handleSecurityOutput(options, resultSecrets, resultSast, isOk, hasExpired) {
916
+ if (isSarifOutput(options)) {
917
+ if (!options.output) {
918
+ const doc = generateSecuritySarifReport({
919
+ secretsResult: resultSecrets,
920
+ sastResult: resultSast
921
+ });
922
+ console.log(serializeSarifDocument(doc));
923
+ }
924
+ return isOk;
925
+ }
926
+ if (isJsonOutput(options)) {
820
927
  emitSecurityJson(resultSecrets, resultSast, isOk);
821
928
  return isOk;
822
929
  }
823
930
  const okS = runVerifySecrets({ ...options, silent: options.silent });
824
931
  const okA = runVerifySast({ ...options, silent: options.silent });
825
- return okS && okA;
932
+ printSecurityConsoleSummary(options.silent, hasExpired);
933
+ return okS && okA && !hasExpired;
934
+ }
935
+ function runVerifySecurity(options = {}) {
936
+ const rootDir = options.root || process.cwd();
937
+ const { resultSecrets, resultSast } = executeSecurityVerifiers(rootDir, options);
938
+ const allSuppressions = [
939
+ ...resultSecrets.suppressions || [],
940
+ ...resultSast.suppressions || []
941
+ ];
942
+ writeSuppressionsAuditReport(rootDir, allSuppressions);
943
+ persistSecuritySarif(rootDir, resultSecrets, resultSast, options.output);
944
+ const hasExpired = allSuppressions.some((s) => s.status === "expired");
945
+ const isOk = resultSecrets.success && resultSast.success && !hasExpired;
946
+ return handleSecurityOutput(options, resultSecrets, resultSast, isOk, hasExpired);
826
947
  }
827
948
  function emitGherkinVerifyJson(result) {
828
949
  const violations = [
@@ -1727,7 +1848,7 @@ function runInit(targetDir = ".", options = {}) {
1727
1848
  }
1728
1849
 
1729
1850
  // src/commands/kpi.ts
1730
- import * as fs from "fs";
1851
+ import * as fs2 from "fs";
1731
1852
  import pc6 from "picocolors";
1732
1853
  import {
1733
1854
  aggregatePrKpis,
@@ -1738,15 +1859,15 @@ import {
1738
1859
  } from "@aisdlc/core";
1739
1860
  function applyKpiPrOutput(options, markdown) {
1740
1861
  if (options.updateFile) {
1741
- if (!fs.existsSync(options.updateFile)) {
1862
+ if (!fs2.existsSync(options.updateFile)) {
1742
1863
  console.error(pc6.red(`
1743
1864
  \u2716 [ERROR] Target file '${options.updateFile}' does not exist.
1744
1865
  `));
1745
1866
  return false;
1746
1867
  }
1747
- const original = fs.readFileSync(options.updateFile, "utf-8");
1868
+ const original = fs2.readFileSync(options.updateFile, "utf-8");
1748
1869
  const updated = injectKpisIntoPrBody(original, markdown);
1749
- fs.writeFileSync(options.updateFile, updated, "utf-8");
1870
+ fs2.writeFileSync(options.updateFile, updated, "utf-8");
1750
1871
  console.log(pc6.green(`\u2714 [UPDATED] KPI summary injected into '${options.updateFile}'.`));
1751
1872
  } else {
1752
1873
  console.log("\n" + markdown + "\n");
@@ -1837,12 +1958,12 @@ async function runMcpServer(options = {}) {
1837
1958
  }
1838
1959
 
1839
1960
  // src/commands/report.ts
1840
- import * as path from "path";
1961
+ import * as path2 from "path";
1841
1962
  import { spawn } from "child_process";
1842
1963
  import pc8 from "picocolors";
1843
1964
  import { generateDashboardReport, generateQualityReport } from "@aisdlc/core";
1844
1965
  function openInBrowser(filePath) {
1845
- const resolved = path.resolve(filePath);
1966
+ const resolved = path2.resolve(filePath);
1846
1967
  const platform = process.platform;
1847
1968
  try {
1848
1969
  if (platform === "win32") {
@@ -1863,7 +1984,7 @@ function printDashboardMetrics(result, rootDir) {
1863
1984
  console.log(` Global traceability: ${pc8.green(String(result.metrics.traceabilityRatio) + "%")}`);
1864
1985
  console.log(` Maintainability: ${pc8.bold(String(result.metrics.avgMaintainability) + " / 100")}`);
1865
1986
  console.log(` Gate verdict: ${result.metrics.qualityVerdict === "PASS" ? pc8.green("PASS") : pc8.red("FAIL")}`);
1866
- const relPath = path.relative(rootDir, result.outputPath);
1987
+ const relPath = path2.relative(rootDir, result.outputPath);
1867
1988
  console.log(pc8.green(`
1868
1989
  \u2714 Self-contained HTML dashboard successfully generated at: ${pc8.bold(relPath)}
1869
1990
  `));
@@ -1902,7 +2023,7 @@ function printQualityReportMetrics(result, rootDir) {
1902
2023
  ` Code coverage (L/B/F): ${result.coverage ? pc8.bold(`${result.coverage.linesPct}% / ${result.coverage.branchesPct}% / ${result.coverage.functionsPct}%`) : pc8.dim("N/A (Run test:coverage)")}`
1903
2024
  );
1904
2025
  console.log(` Release Gate verdict: ${result.verdict === "PASS" ? pc8.green("PASS") : pc8.red("FAIL")}`);
1905
- const reportRelPath = path.relative(rootDir, path.join(rootDir, "reports", "QUALITY_REPORT.md"));
2026
+ const reportRelPath = path2.relative(rootDir, path2.join(rootDir, "reports", "QUALITY_REPORT.md"));
1906
2027
  console.log(pc8.green(`
1907
2028
  \u2714 Report successfully generated at: ${pc8.bold(reportRelPath)}
1908
2029
  `));
@@ -1923,7 +2044,7 @@ function runReportQuality(options = {}) {
1923
2044
  }
1924
2045
 
1925
2046
  // src/commands/sdd.ts
1926
- import * as path2 from "path";
2047
+ import * as path3 from "path";
1927
2048
  import pc9 from "picocolors";
1928
2049
  import {
1929
2050
  depositProductHandoffSidecar,
@@ -2005,7 +2126,7 @@ function printHandoffEntry(isValid, id, relDir, reqCount) {
2005
2126
  }
2006
2127
  }
2007
2128
  function processHandoffEntry(handoff, changeDir, rootDir, isSilent) {
2008
- const relDir = path2.relative(rootDir, changeDir).replace(/\\/g, "/");
2129
+ const relDir = path3.relative(rootDir, changeDir).replace(/\\/g, "/");
2009
2130
  const reqCount = handoff.subgraph && Array.isArray(handoff.subgraph.requirements) ? handoff.subgraph.requirements.length : 0;
2010
2131
  const isValid = Boolean(handoff.id && handoff.id.startsWith("HOF-") && reqCount > 0);
2011
2132
  const id = handoff.id || "UNKNOWN";
@@ -2281,8 +2402,8 @@ function runChangeNew(options) {
2281
2402
 
2282
2403
  // src/index.ts
2283
2404
  var program = new Command();
2284
- program.name("aisdlc").description("AI-SDLC: Spec-Driven Development, Governance & Quality Gates for AI & Humans").version("2.0.2");
2285
- 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("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text or json").action((opts) => {
2405
+ program.name("aisdlc").description("AI-SDLC: Spec-Driven Development, Governance & Quality Gates for AI & Humans").version("2.2.1");
2406
+ 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) => {
2286
2407
  const passed = runCheck({
2287
2408
  fix: opts.fix,
2288
2409
  root: opts.root,
@@ -2292,7 +2413,7 @@ program.command("check").description("Unified pre-flight command: validates Qual
2292
2413
  process.exit(passed ? 0 : 1);
2293
2414
  });
2294
2415
  var verifyCommand = program.command("verify").description("Run deterministic verifiers for quality, traceability, governance, and licenses");
2295
- 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("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text or json").action((opts) => {
2416
+ 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) => {
2296
2417
  const passed = runVerifyAll({
2297
2418
  root: opts.root,
2298
2419
  policy: opts.policy,
@@ -2302,11 +2423,14 @@ verifyCommand.command("all", { isDefault: true }).description("Run the full qual
2302
2423
  maxLines: opts.maxLines,
2303
2424
  enforceMode: opts.mode,
2304
2425
  json: opts.json,
2305
- format: opts.format
2426
+ format: opts.format,
2427
+ updateBaseline: opts.updateBaseline,
2428
+ baseline: opts.baseline,
2429
+ ratchet: opts.ratchet
2306
2430
  });
2307
2431
  process.exit(passed ? 0 : 1);
2308
2432
  });
2309
- verifyCommand.command("quality").description("Quality Release Gate (Cyclomatic Complexity <= 10, Maintainability >= 50)").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("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text or json").action((opts) => {
2433
+ verifyCommand.command("quality").description("Quality Release Gate (Cyclomatic Complexity <= 10, Maintainability >= 50)").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("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text or json").option("--update-baseline", "Update quality baseline snapshot with current violations").option("--baseline <path>", "Path to quality baseline JSON file").option("--ratchet", "Enforce ratchet mode against baseline").action((opts) => {
2310
2434
  const passed = runVerifyQuality({
2311
2435
  root: opts.root,
2312
2436
  policy: opts.policy,
@@ -2316,7 +2440,10 @@ verifyCommand.command("quality").description("Quality Release Gate (Cyclomatic C
2316
2440
  maxLines: opts.maxLines,
2317
2441
  enforceMode: opts.mode,
2318
2442
  json: opts.json,
2319
- format: opts.format
2443
+ format: opts.format,
2444
+ updateBaseline: opts.updateBaseline,
2445
+ baseline: opts.baseline,
2446
+ ratchet: opts.ratchet
2320
2447
  });
2321
2448
  process.exit(passed ? 0 : 1);
2322
2449
  });
@@ -2336,7 +2463,7 @@ verifyCommand.command("gherkin").description("Verify BDD synchronization between
2336
2463
  const passed = runVerifyGherkin({ root: opts.root, json: opts.json, format: opts.format });
2337
2464
  process.exit(passed ? 0 : 1);
2338
2465
  });
2339
- 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("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text or json").action((opts) => {
2466
+ 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) => {
2340
2467
  const passed = runVerifyLicenses({
2341
2468
  root: opts.root,
2342
2469
  policy: opts.policy,
@@ -2346,6 +2473,7 @@ verifyCommand.command("licenses").description("Verify OSS license compliance aga
2346
2473
  depth: opts.depth,
2347
2474
  sbom: opts.sbom,
2348
2475
  notices: opts.notices,
2476
+ vuln: opts.vuln,
2349
2477
  json: opts.json,
2350
2478
  format: opts.format
2351
2479
  });
@@ -2363,7 +2491,7 @@ verifyCommand.command("duplicates").description("Audit duplicate requirements, I
2363
2491
  const passed = runVerifyDuplicates({ root: opts.root, similarity: opts.similarity, json: opts.json, format: opts.format });
2364
2492
  process.exit(passed ? 0 : 1);
2365
2493
  });
2366
- 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 or json").action((opts) => {
2494
+ 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) => {
2367
2495
  const passed = runVerifySecurity({
2368
2496
  root: opts.root,
2369
2497
  diff: opts.diff,
@@ -2373,11 +2501,12 @@ verifyCommand.command("security").description("Unified security verification: de
2373
2501
  entropy: opts.entropy,
2374
2502
  minSeverity: opts.minSeverity,
2375
2503
  json: opts.json,
2376
- format: opts.format
2504
+ format: opts.format,
2505
+ output: opts.output
2377
2506
  });
2378
2507
  process.exit(passed ? 0 : 4);
2379
2508
  });
2380
- verifyCommand.command("secrets").description("Verify absence of exposed credentials, API keys, and certificates (Gitleaks Gate)").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("-e, --entropy <number>", "Minimum Shannon entropy threshold (0.0 to 8.0)", "4.3").option("--json", "Emit verification results in structured JSON format").option("-F, --format <format>", "Output format: text or json").action((opts) => {
2509
+ verifyCommand.command("secrets").description("Verify absence of exposed credentials, API keys, and certificates (Gitleaks Gate)").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("-e, --entropy <number>", "Minimum Shannon entropy threshold (0.0 to 8.0)", "4.3").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/secrets.sarif)").action((opts) => {
2381
2510
  const passed = runVerifySecrets({
2382
2511
  root: opts.root,
2383
2512
  diff: opts.diff,
@@ -2385,17 +2514,19 @@ verifyCommand.command("secrets").description("Verify absence of exposed credenti
2385
2514
  gitleaks: opts.gitleaks,
2386
2515
  entropy: opts.entropy,
2387
2516
  json: opts.json,
2388
- format: opts.format
2517
+ format: opts.format,
2518
+ output: opts.output
2389
2519
  });
2390
2520
  process.exit(passed ? 0 : 4);
2391
2521
  });
2392
- 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 or json").action((opts) => {
2522
+ 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) => {
2393
2523
  const passed = runVerifySast({
2394
2524
  root: opts.root,
2395
2525
  semgrep: opts.semgrep,
2396
2526
  minSeverity: opts.minSeverity,
2397
2527
  json: opts.json,
2398
- format: opts.format
2528
+ format: opts.format,
2529
+ output: opts.output
2399
2530
  });
2400
2531
  process.exit(passed ? 0 : 1);
2401
2532
  });