@aisdlc/cli 2.3.0 → 2.5.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 CHANGED
@@ -26,9 +26,9 @@ import {
26
26
 
27
27
  // src/commands/verify.ts
28
28
  import pc from "picocolors";
29
- import * as fs from "fs";
30
29
  import * as path from "path";
31
30
  import {
31
+ writeReportFileIfChanged,
32
32
  checkGherkinInSync,
33
33
  verifyArtifactDuplicates,
34
34
  verifyArtifactsSchemas,
@@ -482,6 +482,29 @@ function runVerifyLicenses(options = {}) {
482
482
  }
483
483
  return result.success;
484
484
  }
485
+ function buildPdacViolations(result) {
486
+ const drifts = result.drifts.map((d) => ({
487
+ sourceId: d.sourceId,
488
+ targetId: d.targetId,
489
+ sourceFile: d.sourceFile,
490
+ expectedDigest: d.expectedDigest,
491
+ actualDigest: d.actualDigest,
492
+ message: `Cryptographic drift in ${d.sourceFile} citing ${d.targetId}`
493
+ }));
494
+ const unresolved = (result.unresolvedCitations || []).map((u) => ({
495
+ sourceId: u.sourceFile,
496
+ targetId: u.targetId,
497
+ sourceFile: u.sourceFile,
498
+ message: `Unresolved citation in ${u.sourceFile} citing non-existent artifact '${u.targetId}'`
499
+ }));
500
+ const anchors = (result.invalidAnchors || []).map((a) => ({
501
+ sourceId: a.sourceFile,
502
+ targetId: a.targetId,
503
+ sourceFile: a.sourceFile,
504
+ message: a.reason
505
+ }));
506
+ return [...drifts, ...unresolved, ...anchors];
507
+ }
485
508
  function emitPdacJson(result) {
486
509
  const payload = {
487
510
  gate: "pdac",
@@ -490,30 +513,49 @@ function emitPdacJson(result) {
490
513
  summary: {
491
514
  totalNodes: result.totalNodes,
492
515
  totalEdges: result.totalEdges,
493
- driftCount: result.drifts.length
516
+ driftCount: result.drifts.length,
517
+ unresolvedCount: result.unresolvedCount || 0,
518
+ invalidAnchorCount: result.invalidAnchors?.length || 0
494
519
  },
495
- violations: result.drifts.map((d) => ({
496
- sourceId: d.sourceId,
497
- targetId: d.targetId,
498
- sourceFile: d.sourceFile,
499
- expectedDigest: d.expectedDigest,
500
- actualDigest: d.actualDigest,
501
- message: `Cryptographic drift in ${d.sourceFile} citing ${d.targetId}`
502
- }))
520
+ violations: buildPdacViolations(result)
503
521
  };
504
522
  console.log(JSON.stringify(payload, null, 2));
505
523
  }
524
+ function printDrifts(drifts) {
525
+ if (drifts.length === 0) return;
526
+ console.log(pc.red("\n Detected drifts (Status: STALE):"));
527
+ for (const d of drifts) {
528
+ console.log(` ${pc.red("\u2716")} In ${d.sourceFile} citing ${d.targetId}: misaligned digest.`);
529
+ }
530
+ }
531
+ function printUnresolved(unresolved) {
532
+ if (!unresolved || unresolved.length === 0) return;
533
+ console.log(pc.red("\n Unresolved citations:"));
534
+ for (const u of unresolved) {
535
+ console.log(` ${pc.red("\u2716")} In ${u.sourceFile}: references non-existent artifact '${u.targetId}'.`);
536
+ }
537
+ }
538
+ function printInvalidAnchors(anchors) {
539
+ if (!anchors || anchors.length === 0) return;
540
+ console.log(pc.red("\n Invalid anchors:"));
541
+ for (const a of anchors) {
542
+ console.log(` ${pc.red("\u2716")} In ${a.sourceFile}: ${a.reason}`);
543
+ }
544
+ }
506
545
  function printPdacConsole(result) {
507
546
  console.log(` PDaC baseline nodes: ${pc.bold(String(result.totalNodes))}`);
508
547
  console.log(` Evaluated citations: ${pc.bold(String(result.totalEdges))}`);
509
548
  console.log(` Cryptographic drifts: ${result.drifts.length > 0 ? pc.red(String(result.drifts.length)) : pc.green("0")}`);
510
- if (result.drifts.length > 0) {
511
- console.log(pc.red("\n Detected drifts (Status: STALE):"));
512
- for (const d of result.drifts) {
513
- console.log(` ${pc.red("\u2716")} In ${d.sourceFile} citing ${d.targetId}: misaligned digest.`);
514
- }
549
+ if (result.unresolvedCount && result.unresolvedCount > 0) {
550
+ console.log(` Unresolved citations: ${pc.red(String(result.unresolvedCount))}`);
551
+ }
552
+ if (result.invalidAnchors && result.invalidAnchors.length > 0) {
553
+ console.log(` Invalid anchors: ${pc.red(String(result.invalidAnchors.length))}`);
515
554
  }
516
- console.log(result.success ? pc.green("\n\u2714 PDaC Graph Free of Drift\n") : pc.red("\n\u2716 Cryptographic Drift Detected\n"));
555
+ printDrifts(result.drifts);
556
+ printUnresolved(result.unresolvedCitations);
557
+ printInvalidAnchors(result.invalidAnchors);
558
+ console.log(result.success ? pc.green("\n\u2714 PDaC Graph Free of Drift and Fully Verified\n") : pc.red("\n\u2716 PDaC Verification Failed (Drift, Unresolved Citations, or Invalid Anchors)\n"));
517
559
  }
518
560
  function runVerifyPdac(options = {}) {
519
561
  const rootDir = options.root || process.cwd();
@@ -871,15 +913,8 @@ function emitSecurityJson(resultSecrets, resultSast, isOk) {
871
913
  console.log(JSON.stringify(payload, null, 2));
872
914
  }
873
915
  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
- );
916
+ const targetPath = path.join(rootDir, "reports", "SUPPRESSIONS_AUDIT.md");
917
+ writeReportFileIfChanged(targetPath, generateSuppressionsAuditReport(suppressions));
883
918
  }
884
919
  function executeSecurityVerifiers(rootDir, options) {
885
920
  const entropyThreshold = options.entropy !== void 0 ? Number(options.entropy) : void 0;
@@ -1848,7 +1883,7 @@ function runInit(targetDir = ".", options = {}) {
1848
1883
  }
1849
1884
 
1850
1885
  // src/commands/kpi.ts
1851
- import * as fs2 from "fs";
1886
+ import * as fs from "fs";
1852
1887
  import pc6 from "picocolors";
1853
1888
  import {
1854
1889
  aggregatePrKpis,
@@ -1860,15 +1895,15 @@ import {
1860
1895
  } from "@aisdlc/core";
1861
1896
  function applyKpiPrOutput(options, markdown) {
1862
1897
  if (options.updateFile) {
1863
- if (!fs2.existsSync(options.updateFile)) {
1898
+ if (!fs.existsSync(options.updateFile)) {
1864
1899
  console.error(pc6.red(`
1865
1900
  \u2716 [ERROR] Target file '${options.updateFile}' does not exist.
1866
1901
  `));
1867
1902
  return false;
1868
1903
  }
1869
- const original = fs2.readFileSync(options.updateFile, "utf-8");
1904
+ const original = fs.readFileSync(options.updateFile, "utf-8");
1870
1905
  const updated = injectKpisIntoPrBody(original, markdown);
1871
- fs2.writeFileSync(options.updateFile, updated, "utf-8");
1906
+ fs.writeFileSync(options.updateFile, updated, "utf-8");
1872
1907
  console.log(pc6.green(`\u2714 [UPDATED] KPI summary injected into '${options.updateFile}'.`));
1873
1908
  } else {
1874
1909
  console.log("\n" + markdown + "\n");
@@ -1952,10 +1987,15 @@ async function runMcpServer(options = {}) {
1952
1987
  const rootDir = options.root || process.cwd();
1953
1988
  if (!options.silent) {
1954
1989
  console.error(pc7.bold(pc7.cyan("\n\u{1F680} [AI-SDLC MCP] Starting native Model Context Protocol (MCP) server (stdio)...")));
1955
- console.error(pc7.gray(` Base directory: ${rootDir}
1990
+ console.error(pc7.gray(` Base directory: ${rootDir}`));
1991
+ if (options.role) {
1992
+ console.error(pc7.gray(` Role context: ${options.role}
1956
1993
  `));
1994
+ } else {
1995
+ console.error("");
1996
+ }
1957
1997
  }
1958
- await startMcpServer({ rootDir });
1998
+ await startMcpServer({ rootDir, role: options.role });
1959
1999
  }
1960
2000
 
1961
2001
  // src/commands/report.ts
@@ -2403,7 +2443,7 @@ function runChangeNew(options) {
2403
2443
 
2404
2444
  // src/index.ts
2405
2445
  var program = new Command();
2406
- program.name("aisdlc").description("AI-SDLC: Spec-Driven Development, Governance & Quality Gates for AI & Humans").version("2.3.0");
2446
+ program.name("aisdlc").description("AI-SDLC: Spec-Driven Development, Governance & Quality Gates for AI & Humans").version("2.5.0");
2407
2447
  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) => {
2408
2448
  const passed = runCheck({
2409
2449
  fix: opts.fix,
@@ -2714,8 +2754,8 @@ program.command("init [directory]").description("Initialize a new repository wit
2714
2754
  });
2715
2755
  process.exit(passed ? 0 : 1);
2716
2756
  });
2717
- program.command("mcp").description("Start native AI-SDLC Model Context Protocol (MCP) server (stdio)").option("-r, --root <path>", "Project root directory").action(async (opts) => {
2718
- await runMcpServer({ root: opts.root });
2757
+ program.command("mcp").description("Start native AI-SDLC Model Context Protocol (MCP) server (stdio)").option("-r, --root <path>", "Project root directory").option("--role <role>", "Role context for MCP server authorization").action(async (opts) => {
2758
+ await runMcpServer({ root: opts.root, role: opts.role });
2719
2759
  });
2720
2760
  program.on("command:*", () => {
2721
2761
  console.error(pc10.red(`