@aisdlc/cli 4.3.0 → 4.4.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 +90 -53
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5,10 +5,13 @@ import { Command } from "commander";
|
|
|
5
5
|
import pc12 from "picocolors";
|
|
6
6
|
|
|
7
7
|
// src/commands/check.ts
|
|
8
|
+
import * as fs from "fs";
|
|
9
|
+
import * as path2 from "path";
|
|
8
10
|
import pc2 from "picocolors";
|
|
9
11
|
import {
|
|
10
12
|
checkGherkinInSync as checkGherkinInSync2,
|
|
11
13
|
extractGherkinFeatures,
|
|
14
|
+
scaffoldGherkinSteps,
|
|
12
15
|
syncPdacDigests,
|
|
13
16
|
verifyArtifactDuplicates as verifyArtifactDuplicates2,
|
|
14
17
|
verifyArtifactsSchemas as verifyArtifactsSchemas2,
|
|
@@ -1037,19 +1040,23 @@ async function runVerifySecurityAsync(options = {}) {
|
|
|
1037
1040
|
const isOk = resultSecrets.success && resultSast.success && !hasExpired;
|
|
1038
1041
|
return handleSecurityOutput(options, resultSecrets, resultSast, isOk, hasExpired);
|
|
1039
1042
|
}
|
|
1040
|
-
function
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
})),
|
|
1047
|
-
...
|
|
1048
|
-
type: "
|
|
1043
|
+
function buildGherkinViolations(result) {
|
|
1044
|
+
const orphans = result.orphanFeatureFiles ?? [];
|
|
1045
|
+
const missingSteps = result.missingStepFiles ?? [];
|
|
1046
|
+
return [
|
|
1047
|
+
...result.missingFiles.map((f) => ({ type: "MISSING_FEATURE", file: f, message: `Missing .feature file: ${f}` })),
|
|
1048
|
+
...result.outOfSyncFiles.map((f) => ({ type: "OUT_OF_SYNC_FEATURE", file: f, message: `Out-of-sync .feature file: ${f}` })),
|
|
1049
|
+
...orphans.map((f) => ({ type: "ORPHAN_FEATURE", file: f, message: `Manual/orphan .feature file without Markdown source: ${f}` })),
|
|
1050
|
+
...missingSteps.map((f) => ({
|
|
1051
|
+
type: "MISSING_STEP_FILE",
|
|
1049
1052
|
file: f,
|
|
1050
|
-
message: `
|
|
1053
|
+
message: `Missing deterministic step definition file in tests/steps/ for: ${f}. Run 'aisdlc gherkin scaffold ${f} --lang <lang> --fallback'.`
|
|
1051
1054
|
}))
|
|
1052
1055
|
];
|
|
1056
|
+
}
|
|
1057
|
+
function emitGherkinVerifyJson(result) {
|
|
1058
|
+
const orphans = result.orphanFeatureFiles ?? [];
|
|
1059
|
+
const missingSteps = result.missingStepFiles ?? [];
|
|
1053
1060
|
const payload = {
|
|
1054
1061
|
gate: "gherkin",
|
|
1055
1062
|
success: result.inSync,
|
|
@@ -1057,22 +1064,30 @@ function emitGherkinVerifyJson(result) {
|
|
|
1057
1064
|
summary: {
|
|
1058
1065
|
totalFeatures: result.totalFeatures,
|
|
1059
1066
|
missingCount: result.missingFiles.length,
|
|
1060
|
-
outOfSyncCount: result.outOfSyncFiles.length
|
|
1067
|
+
outOfSyncCount: result.outOfSyncFiles.length,
|
|
1068
|
+
orphanFeatureCount: orphans.length,
|
|
1069
|
+
missingStepFileCount: missingSteps.length
|
|
1061
1070
|
},
|
|
1062
|
-
violations
|
|
1071
|
+
violations: buildGherkinViolations(result)
|
|
1063
1072
|
};
|
|
1064
1073
|
console.log(JSON.stringify(payload, null, 2));
|
|
1065
1074
|
}
|
|
1075
|
+
function printGherkinIssueList(items, tag, suffix = "") {
|
|
1076
|
+
for (const f of items) {
|
|
1077
|
+
const extra = suffix ? suffix.replace("{file}", f) : "";
|
|
1078
|
+
console.log(` ${pc.red("\u2716")} [${tag}] ${f}${extra}`);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1066
1081
|
function printGherkinVerifyConsole(result) {
|
|
1067
|
-
const
|
|
1082
|
+
const orphans = result.orphanFeatureFiles ?? [];
|
|
1083
|
+
const missingSteps = result.missingStepFiles ?? [];
|
|
1084
|
+
const totalOut = result.missingFiles.length + result.outOfSyncFiles.length + orphans.length + missingSteps.length;
|
|
1068
1085
|
console.log(` Evaluated features: ${pc.bold(String(result.totalFeatures))}`);
|
|
1069
|
-
console.log(`
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
console.log(` ${pc.red("\u2716")} [OUT_OF_SYNC] ${f}`);
|
|
1075
|
-
}
|
|
1086
|
+
console.log(` Violations / missing: ${totalOut > 0 ? pc.red(String(totalOut)) : pc.green("0")}`);
|
|
1087
|
+
printGherkinIssueList(result.missingFiles, "MISSING");
|
|
1088
|
+
printGherkinIssueList(result.outOfSyncFiles, "OUT_OF_SYNC");
|
|
1089
|
+
printGherkinIssueList(orphans, "ORPHAN_FEATURE");
|
|
1090
|
+
printGherkinIssueList(missingSteps, "MISSING_STEP_FILE", " (run: aisdlc gherkin scaffold {file} --lang <lang> --fallback)");
|
|
1076
1091
|
console.log(result.inSync ? pc.green("\n\u2714 BDD Synchronization COMPLIANT\n") : pc.red("\n\u2716 BDD Synchronization BLOCKED\n"));
|
|
1077
1092
|
}
|
|
1078
1093
|
function runVerifyGherkin(options = {}) {
|
|
@@ -1252,41 +1267,63 @@ async function runVerifyAllAsync(options = {}) {
|
|
|
1252
1267
|
}
|
|
1253
1268
|
|
|
1254
1269
|
// src/commands/check.ts
|
|
1270
|
+
function detectDefaultScaffoldLanguage(rootDir) {
|
|
1271
|
+
if (fs.existsSync(path2.join(rootDir, "pyproject.toml")) || fs.existsSync(path2.join(rootDir, "requirements.txt"))) return "py";
|
|
1272
|
+
if (fs.existsSync(path2.join(rootDir, "go.mod"))) return "go";
|
|
1273
|
+
if (fs.existsSync(path2.join(rootDir, "Cargo.toml"))) return "rs";
|
|
1274
|
+
return "ts";
|
|
1275
|
+
}
|
|
1276
|
+
function autoScaffoldMissingSteps(rootDir) {
|
|
1277
|
+
const sync = checkGherkinInSync2({ rootDir });
|
|
1278
|
+
const missing = sync.missingStepFiles ?? [];
|
|
1279
|
+
if (missing.length === 0) return 0;
|
|
1280
|
+
const lang = detectDefaultScaffoldLanguage(rootDir);
|
|
1281
|
+
let count = 0;
|
|
1282
|
+
for (const fp of missing) {
|
|
1283
|
+
if (scaffoldGherkinSteps({ rootDir, featurePath: fp, lang, allowFallback: true }).success) {
|
|
1284
|
+
count++;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
return count;
|
|
1288
|
+
}
|
|
1255
1289
|
function runAutoFix(rootDir, silent) {
|
|
1256
1290
|
const gherkinRes = extractGherkinFeatures({ rootDir });
|
|
1291
|
+
const scaffoldedCount = autoScaffoldMissingSteps(rootDir);
|
|
1257
1292
|
const pdacRes = syncPdacDigests({ rootDir });
|
|
1258
1293
|
if (!silent) {
|
|
1259
1294
|
if (gherkinRes.features.length > 0) {
|
|
1260
1295
|
console.log(` ${pc2.cyan("\u{1F527} [AUTO-FIX]")} Synchronized ${pc2.bold(String(gherkinRes.features.length))} .feature files (${gherkinRes.totalScenarios} scenarios).`);
|
|
1261
1296
|
}
|
|
1297
|
+
if (scaffoldedCount > 0) {
|
|
1298
|
+
console.log(` ${pc2.cyan("\u{1F527} [AUTO-FIX]")} Scaffolded ${pc2.bold(String(scaffoldedCount))} deterministic step files in tests/steps/.`);
|
|
1299
|
+
}
|
|
1262
1300
|
if (pdacRes.syncedCount > 0) {
|
|
1263
1301
|
console.log(` ${pc2.cyan("\u{1F527} [AUTO-FIX]")} Synchronized ${pc2.bold(String(pdacRes.syncedCount))} SHA-256 digests across ${pdacRes.updatedFiles.length} files.`);
|
|
1264
1302
|
}
|
|
1265
1303
|
}
|
|
1266
1304
|
return { gherkinCount: gherkinRes.features.length, digestsCount: pdacRes.syncedCount };
|
|
1267
1305
|
}
|
|
1306
|
+
function buildGherkinFailedGate(totalOut, hasMissingSteps) {
|
|
1307
|
+
const remediation = hasMissingSteps ? "Run 'aisdlc gherkin scaffold <feature-file> --lang <lang> --fallback' to generate step definitions in tests/steps/." : "Run 'aisdlc check --fix' to extract and regenerate .feature files, and remove orphan manual .feature files.";
|
|
1308
|
+
return {
|
|
1309
|
+
name: "BDD Synchronization (Gherkin -> .feature & steps)",
|
|
1310
|
+
status: "FAILED",
|
|
1311
|
+
message: `${totalOut} Gherkin sync/step-scaffold violation(s) detected`,
|
|
1312
|
+
remediation
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1268
1315
|
function auditGherkinGate(rootDir, wasAutoFixed) {
|
|
1269
1316
|
const syncCheck = checkGherkinInSync2({ rootDir });
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
name: "BDD Synchronization (Gherkin -> .feature)",
|
|
1273
|
-
status: "FIXED",
|
|
1274
|
-
message: `${syncCheck.totalFeatures} specifications automatically synchronized`
|
|
1275
|
-
};
|
|
1276
|
-
}
|
|
1317
|
+
const orphans = syncCheck.orphanFeatureFiles ?? [];
|
|
1318
|
+
const missingSteps = syncCheck.missingStepFiles ?? [];
|
|
1277
1319
|
if (!syncCheck.inSync) {
|
|
1278
|
-
const totalOut = syncCheck.missingFiles.length + syncCheck.outOfSyncFiles.length;
|
|
1279
|
-
return
|
|
1280
|
-
name: "BDD Synchronization (Gherkin -> .feature)",
|
|
1281
|
-
status: "FAILED",
|
|
1282
|
-
message: `${totalOut} out-of-sync or missing .feature file(s)`,
|
|
1283
|
-
remediation: "Run 'aisdlc check --fix' to extract and regenerate .feature files."
|
|
1284
|
-
};
|
|
1320
|
+
const totalOut = syncCheck.missingFiles.length + syncCheck.outOfSyncFiles.length + orphans.length + missingSteps.length;
|
|
1321
|
+
return buildGherkinFailedGate(totalOut, missingSteps.length > 0);
|
|
1285
1322
|
}
|
|
1286
1323
|
return {
|
|
1287
|
-
name: "BDD Synchronization (Gherkin -> .feature)",
|
|
1288
|
-
status: "PASSED",
|
|
1289
|
-
message: `${syncCheck.totalFeatures} specifications up to date on disk`
|
|
1324
|
+
name: "BDD Synchronization (Gherkin -> .feature & steps)",
|
|
1325
|
+
status: wasAutoFixed ? "FIXED" : "PASSED",
|
|
1326
|
+
message: wasAutoFixed ? `${syncCheck.totalFeatures} specifications automatically synchronized` : `${syncCheck.totalFeatures} specifications and step scaffolds up to date on disk`
|
|
1290
1327
|
};
|
|
1291
1328
|
}
|
|
1292
1329
|
function auditPdacGate(rootDir, wasAutoFixed) {
|
|
@@ -1598,7 +1635,7 @@ import * as readline2 from "readline";
|
|
|
1598
1635
|
import pc3 from "picocolors";
|
|
1599
1636
|
import {
|
|
1600
1637
|
extractGherkinFeatures as extractGherkinFeatures2,
|
|
1601
|
-
scaffoldGherkinSteps
|
|
1638
|
+
scaffoldGherkinSteps as scaffoldGherkinSteps2
|
|
1602
1639
|
} from "@aisdlc/core";
|
|
1603
1640
|
function printGherkinResult(result) {
|
|
1604
1641
|
console.log(` Generated .feature files: ${pc3.bold(String(result.features.length))}`);
|
|
@@ -1675,7 +1712,7 @@ async function handleInteractiveMissing(initialResult, featurePath, options, roo
|
|
|
1675
1712
|
const confirmed = await ask(
|
|
1676
1713
|
`Native BDD generator is not installed (${initialResult.installCommand}, license: ${initialResult.license}). Install now? [y/N]: `
|
|
1677
1714
|
);
|
|
1678
|
-
return
|
|
1715
|
+
return scaffoldGherkinSteps2({
|
|
1679
1716
|
rootDir,
|
|
1680
1717
|
featurePath,
|
|
1681
1718
|
lang: options.lang,
|
|
@@ -1696,7 +1733,7 @@ async function runGherkinScaffold(featurePath, options) {
|
|
|
1696
1733
|
const rootDir = options.root || process.cwd();
|
|
1697
1734
|
const useJson = isJsonOutput(options);
|
|
1698
1735
|
const isInteractive = Boolean(process.stdin.isTTY && process.stdout.isTTY && !useJson && !options.silent);
|
|
1699
|
-
let result =
|
|
1736
|
+
let result = scaffoldGherkinSteps2({
|
|
1700
1737
|
rootDir,
|
|
1701
1738
|
featurePath,
|
|
1702
1739
|
lang: options.lang,
|
|
@@ -2038,7 +2075,7 @@ function runInit(targetDir = ".", options = {}) {
|
|
|
2038
2075
|
}
|
|
2039
2076
|
|
|
2040
2077
|
// src/commands/kpi.ts
|
|
2041
|
-
import * as
|
|
2078
|
+
import * as fs2 from "fs";
|
|
2042
2079
|
import pc6 from "picocolors";
|
|
2043
2080
|
import {
|
|
2044
2081
|
aggregatePrKpis,
|
|
@@ -2050,15 +2087,15 @@ import {
|
|
|
2050
2087
|
} from "@aisdlc/core";
|
|
2051
2088
|
function applyKpiPrOutput(options, markdown) {
|
|
2052
2089
|
if (options.updateFile) {
|
|
2053
|
-
if (!
|
|
2090
|
+
if (!fs2.existsSync(options.updateFile)) {
|
|
2054
2091
|
console.error(pc6.red(`
|
|
2055
2092
|
\u2716 [ERROR] Target file '${options.updateFile}' does not exist.
|
|
2056
2093
|
`));
|
|
2057
2094
|
return false;
|
|
2058
2095
|
}
|
|
2059
|
-
const original =
|
|
2096
|
+
const original = fs2.readFileSync(options.updateFile, "utf-8");
|
|
2060
2097
|
const updated = injectKpisIntoPrBody(original, markdown);
|
|
2061
|
-
|
|
2098
|
+
fs2.writeFileSync(options.updateFile, updated, "utf-8");
|
|
2062
2099
|
console.log(pc6.green(`\u2714 [UPDATED] KPI summary injected into '${options.updateFile}'.`));
|
|
2063
2100
|
} else {
|
|
2064
2101
|
console.log("\n" + markdown + "\n");
|
|
@@ -2154,7 +2191,7 @@ async function runMcpServer(options = {}) {
|
|
|
2154
2191
|
}
|
|
2155
2192
|
|
|
2156
2193
|
// src/commands/report.ts
|
|
2157
|
-
import * as
|
|
2194
|
+
import * as path3 from "path";
|
|
2158
2195
|
import { spawn } from "child_process";
|
|
2159
2196
|
import pc8 from "picocolors";
|
|
2160
2197
|
import {
|
|
@@ -2163,7 +2200,7 @@ import {
|
|
|
2163
2200
|
generateQualityReport
|
|
2164
2201
|
} from "@aisdlc/core";
|
|
2165
2202
|
function openInBrowser(filePath) {
|
|
2166
|
-
const resolved =
|
|
2203
|
+
const resolved = path3.resolve(filePath);
|
|
2167
2204
|
const platform = process.platform;
|
|
2168
2205
|
try {
|
|
2169
2206
|
if (platform === "win32") {
|
|
@@ -2184,7 +2221,7 @@ function printDashboardMetrics(result, rootDir) {
|
|
|
2184
2221
|
console.log(` Global traceability: ${pc8.green(String(result.metrics.traceabilityRatio) + "%")}`);
|
|
2185
2222
|
console.log(` Maintainability: ${pc8.bold(String(result.metrics.avgMaintainability) + " / 100")}`);
|
|
2186
2223
|
console.log(` Gate verdict: ${result.metrics.qualityVerdict === "PASS" ? pc8.green("PASS") : pc8.red("FAIL")}`);
|
|
2187
|
-
const relPath =
|
|
2224
|
+
const relPath = path3.relative(rootDir, result.outputPath);
|
|
2188
2225
|
console.log(pc8.green(`
|
|
2189
2226
|
\u2714 Self-contained HTML dashboard successfully generated at: ${pc8.bold(relPath)}
|
|
2190
2227
|
`));
|
|
@@ -2223,7 +2260,7 @@ function printQualityReportMetrics(result, rootDir) {
|
|
|
2223
2260
|
` 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)")}`
|
|
2224
2261
|
);
|
|
2225
2262
|
console.log(` Release Gate verdict: ${result.verdict === "PASS" ? pc8.green("PASS") : pc8.red("FAIL")}`);
|
|
2226
|
-
const reportRelPath =
|
|
2263
|
+
const reportRelPath = path3.relative(rootDir, path3.join(rootDir, "reports", "QUALITY_REPORT.md"));
|
|
2227
2264
|
console.log(pc8.green(`
|
|
2228
2265
|
\u2714 Report successfully generated at: ${pc8.bold(reportRelPath)}
|
|
2229
2266
|
`));
|
|
@@ -2385,7 +2422,7 @@ async function runDoctor(opts = {}) {
|
|
|
2385
2422
|
}
|
|
2386
2423
|
|
|
2387
2424
|
// src/commands/migrate.ts
|
|
2388
|
-
import * as
|
|
2425
|
+
import * as path4 from "path";
|
|
2389
2426
|
import pc10 from "picocolors";
|
|
2390
2427
|
import {
|
|
2391
2428
|
MigrationService,
|
|
@@ -2402,7 +2439,7 @@ function printConsoleSummary(result, reporter) {
|
|
|
2402
2439
|
}
|
|
2403
2440
|
}
|
|
2404
2441
|
async function runMigrate(options) {
|
|
2405
|
-
const root =
|
|
2442
|
+
const root = path4.resolve(options.root || process.cwd());
|
|
2406
2443
|
const service = new MigrationService();
|
|
2407
2444
|
const reporter = new MigrationReporter();
|
|
2408
2445
|
const migrationOptions = {
|
|
@@ -2425,7 +2462,7 @@ async function runMigrate(options) {
|
|
|
2425
2462
|
}
|
|
2426
2463
|
|
|
2427
2464
|
// src/commands/sdd.ts
|
|
2428
|
-
import * as
|
|
2465
|
+
import * as path5 from "path";
|
|
2429
2466
|
import pc11 from "picocolors";
|
|
2430
2467
|
import {
|
|
2431
2468
|
depositProductHandoffSidecar,
|
|
@@ -2508,7 +2545,7 @@ function printHandoffEntry(isValid, id, relDir, reqCount) {
|
|
|
2508
2545
|
}
|
|
2509
2546
|
}
|
|
2510
2547
|
function processHandoffEntry(handoff, changeDir, rootDir, isSilent) {
|
|
2511
|
-
const relDir =
|
|
2548
|
+
const relDir = path5.relative(rootDir, changeDir).replace(/\\/g, "/");
|
|
2512
2549
|
const reqCount = handoff.subgraph && Array.isArray(handoff.subgraph.requirements) ? handoff.subgraph.requirements.length : 0;
|
|
2513
2550
|
const isValid = Boolean(handoff.id && handoff.id.startsWith("HOF-") && reqCount > 0);
|
|
2514
2551
|
const id = handoff.id || "UNKNOWN";
|
|
@@ -2824,7 +2861,7 @@ function runChangeNew(options) {
|
|
|
2824
2861
|
|
|
2825
2862
|
// src/index.ts
|
|
2826
2863
|
var program = new Command();
|
|
2827
|
-
program.name("aisdlc").description("AI-SDLC: Spec-Driven Development, Governance & Quality Gates for AI & Humans").version("4.
|
|
2864
|
+
program.name("aisdlc").description("AI-SDLC: Spec-Driven Development, Governance & Quality Gates for AI & Humans").version("4.4.0");
|
|
2828
2865
|
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
2866
|
const exitCode = await runDoctor({
|
|
2830
2867
|
rootDir: opts.root,
|