@aisdlc/cli 3.4.1 → 4.1.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
@@ -1529,8 +1529,12 @@ function runCheck(options = {}) {
1529
1529
  }
1530
1530
 
1531
1531
  // src/commands/gherkin.ts
1532
+ import * as readline from "readline";
1532
1533
  import pc3 from "picocolors";
1533
- import { extractGherkinFeatures as extractGherkinFeatures2 } from "@aisdlc/core";
1534
+ import {
1535
+ extractGherkinFeatures as extractGherkinFeatures2,
1536
+ scaffoldGherkinSteps
1537
+ } from "@aisdlc/core";
1534
1538
  function printGherkinResult(result) {
1535
1539
  console.log(` Generated .feature files: ${pc3.bold(String(result.features.length))}`);
1536
1540
  console.log(` Total scenarios: ${pc3.bold(String(result.totalScenarios))}`);
@@ -1569,6 +1573,79 @@ function runGherkinExtract(options = {}) {
1569
1573
  }
1570
1574
  return result.success;
1571
1575
  }
1576
+ function defaultConfirmInstall(question) {
1577
+ return new Promise((resolve2) => {
1578
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1579
+ rl.question(question, (answer) => {
1580
+ rl.close();
1581
+ const normalized = answer.trim().toLowerCase();
1582
+ resolve2(normalized === "y" || normalized === "yes");
1583
+ });
1584
+ });
1585
+ }
1586
+ function printScaffoldText(result) {
1587
+ if (result.status === "ERROR") {
1588
+ console.error(pc3.red(`
1589
+ \u2716 [Gherkin Scaffold] Error (${result.errorCode}): ${result.featureFile}
1590
+ `));
1591
+ return;
1592
+ }
1593
+ if (result.status === "GENERATOR_MISSING") {
1594
+ console.log(
1595
+ pc3.yellow(
1596
+ `
1597
+ \u26A0 Native generator (${result.generatorBin}) missing. Run: ${pc3.bold(result.installCommand || "")} (License: ${result.license})
1598
+ `
1599
+ )
1600
+ );
1601
+ return;
1602
+ }
1603
+ const files = result.outputFiles?.length ? result.outputFiles : [result.outputFile];
1604
+ for (const out of files.filter(Boolean)) {
1605
+ console.log(` ${pc3.green("\u2714")} [${result.status}] \u2794 ${pc3.bold(String(out))}`);
1606
+ }
1607
+ }
1608
+ async function handleInteractiveMissing(initialResult, featurePath, options, rootDir) {
1609
+ const ask = options.promptFn || defaultConfirmInstall;
1610
+ const confirmed = await ask(
1611
+ `Native BDD generator is not installed (${initialResult.installCommand}, license: ${initialResult.license}). Install now? [y/N]: `
1612
+ );
1613
+ return scaffoldGherkinSteps({
1614
+ rootDir,
1615
+ featurePath,
1616
+ lang: options.lang,
1617
+ outputPath: options.output,
1618
+ installMissing: confirmed,
1619
+ allowFallback: !confirmed,
1620
+ execFn: options.execFn
1621
+ });
1622
+ }
1623
+ function emitScaffoldOutput(result, options, useJson) {
1624
+ if (useJson) {
1625
+ console.log(JSON.stringify(result, null, 2));
1626
+ } else if (!options.silent) {
1627
+ printScaffoldText(result);
1628
+ }
1629
+ }
1630
+ async function runGherkinScaffold(featurePath, options) {
1631
+ const rootDir = options.root || process.cwd();
1632
+ const useJson = isJsonOutput(options);
1633
+ const isInteractive = Boolean(process.stdin.isTTY && process.stdout.isTTY && !useJson && !options.silent);
1634
+ let result = scaffoldGherkinSteps({
1635
+ rootDir,
1636
+ featurePath,
1637
+ lang: options.lang,
1638
+ outputPath: options.output,
1639
+ installMissing: options.install,
1640
+ allowFallback: options.fallback,
1641
+ execFn: options.execFn
1642
+ });
1643
+ if (result.status === "GENERATOR_MISSING" && (isInteractive || options.promptFn)) {
1644
+ result = await handleInteractiveMissing(result, featurePath, options, rootDir);
1645
+ }
1646
+ emitScaffoldOutput(result, options, useJson);
1647
+ return result.success;
1648
+ }
1572
1649
 
1573
1650
  // src/commands/git.ts
1574
1651
  import pc4 from "picocolors";
@@ -1696,7 +1773,7 @@ function runGitDetectAuthor(options = {}) {
1696
1773
  }
1697
1774
 
1698
1775
  // src/commands/init.ts
1699
- import * as readline from "readline/promises";
1776
+ import * as readline2 from "readline/promises";
1700
1777
  import { initProject } from "@aisdlc/core";
1701
1778
  import pc5 from "picocolors";
1702
1779
  var CI_MENU = [
@@ -1725,7 +1802,7 @@ function parseCiChoice(answer) {
1725
1802
  return trimmed in CI_CHOICE_MAP ? CI_CHOICE_MAP[trimmed] : trimmed;
1726
1803
  }
1727
1804
  async function promptForCi() {
1728
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1805
+ const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
1729
1806
  console.log(CI_MENU);
1730
1807
  try {
1731
1808
  const answer = await rl.question(pc5.bold("\nWhich CI/CD provider do you wish to configure? [1-5] (default 1): "));
@@ -1748,7 +1825,7 @@ var ARCH_MENU = [
1748
1825
  " 3) " + pc5.gray("None") + " (No architecture templates)"
1749
1826
  ].join("\n");
1750
1827
  async function promptForArchitecture() {
1751
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1828
+ const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
1752
1829
  console.log(ARCH_MENU);
1753
1830
  try {
1754
1831
  const answer = await rl.question(pc5.bold("\nWhich architecture granularity level do you wish to configure? [1-3] (default 1): "));
@@ -1781,7 +1858,7 @@ function parseAgentsChoice(answer) {
1781
1858
  return !trimmed ? "all" : map[trimmed] || trimmed;
1782
1859
  }
1783
1860
  async function promptForAgents() {
1784
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1861
+ const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
1785
1862
  console.log(AGENTS_MENU);
1786
1863
  try {
1787
1864
  const answer = await rl.question(pc5.bold("\nWhich agents do you wish to deploy? [1-7 or comma-separated list] (default 1): "));
@@ -2564,7 +2641,7 @@ function runChangeNew(options) {
2564
2641
 
2565
2642
  // src/index.ts
2566
2643
  var program = new Command();
2567
- program.name("aisdlc").description("AI-SDLC: Spec-Driven Development, Governance & Quality Gates for AI & Humans").version("3.4.1");
2644
+ program.name("aisdlc").description("AI-SDLC: Spec-Driven Development, Governance & Quality Gates for AI & Humans").version("4.1.0");
2568
2645
  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) => {
2569
2646
  const passed = runCheck({
2570
2647
  fix: opts.fix,
@@ -2741,6 +2818,18 @@ gherkinCommand.command("extract").description("Extract ```gherkin``` blocks from
2741
2818
  });
2742
2819
  process.exit(passed ? 0 : 1);
2743
2820
  });
2821
+ gherkinCommand.command("scaffold <feature-file>").description("Scaffold failing RED BDD step definitions across target languages (ts, py, go, rs, cs)").requiredOption("--lang <langs...>", "Target language(s): ts, py, go, rs, cs (comma-separated or multiple)").option("-o, --output <path>", "Explicit output file path for generated step definitions").option("--install", "Automatically install missing native BDD generator").option("--fallback", "Use deterministic RED fallback template if native generator is missing").option("-r, --root <path>", "Project root directory").option("--json", "Structured JSON format output").option("-F, --format <format>", "Output format: text or json").action(async (featureFile, opts) => {
2822
+ const passed = await runGherkinScaffold(featureFile, {
2823
+ root: opts.root,
2824
+ lang: opts.lang,
2825
+ output: opts.output,
2826
+ install: opts.install,
2827
+ fallback: opts.fallback,
2828
+ json: opts.json,
2829
+ format: opts.format
2830
+ });
2831
+ process.exit(passed ? 0 : 1);
2832
+ });
2744
2833
  var gitCommand = program.command("git").description("Tools for the 4-tier hierarchical Git branch model");
2745
2834
  gitCommand.command("validate <branch>").description("Validate naming and hierarchy of a Git branch (Tier 1 to 4)").action((branch) => {
2746
2835
  const passed = runGitValidate(branch);
@@ -2836,11 +2925,10 @@ sddCommand.command("verify").description("Validate compliance of handoff.yaml si
2836
2925
  });
2837
2926
  process.exit(passed ? 0 : 1);
2838
2927
  });
2839
- sddCommand.command("integrate").description("Integrate and synchronize implemented SDD changes into canonical specification (product, requirements, and architecture)").option("-c, --change <id>", "Change identifier (e.g. chg-001-telemetry)").option("--all", "Consolidate and integrate all completed SDD changes across active and completed workspaces").option("--auto", "Automatically detect active change to integrate based on branch, PR, or diff").option("--head-ref <ref>", "Source branch for automatic resolution").option("--pr-title <title>", "Pull Request title for automatic resolution").option("--pr-body <body>", "Pull Request body for automatic resolution").option("-r, --root <path>", "Project root directory").option("-a, --author <author>", "Name of author or agent performing integration").option("--no-archive", "Do not archive change to specs/changes/completed after integration").option("--json", "Structured JSON format output").option("-F, --format <format>", "Output format: text or json").action((opts) => {
2928
+ sddCommand.command("integrate").description("Integrate and synchronize implemented SDD changes into canonical specification (product, requirements, and architecture)").option("-c, --change <id>", "Change identifier (e.g. chg-001-telemetry)").option("--auto", "Automatically detect active change to integrate based on branch, PR, or diff").option("--head-ref <ref>", "Source branch for automatic resolution").option("--pr-title <title>", "Pull Request title for automatic resolution").option("--pr-body <body>", "Pull Request body for automatic resolution").option("-r, --root <path>", "Project root directory").option("-a, --author <author>", "Name of author or agent performing integration").option("--no-archive", "Do not archive change to specs/changes/completed after integration").option("--json", "Structured JSON format output").option("-F, --format <format>", "Output format: text or json").action((opts) => {
2840
2929
  const passed = runSddIntegrate({
2841
2930
  root: opts.root,
2842
2931
  change: opts.change,
2843
- all: opts.all,
2844
2932
  auto: opts.auto,
2845
2933
  headRef: opts.headRef,
2846
2934
  prTitle: opts.prTitle,