specdx 0.4.0-alpha.20 → 0.4.0-alpha.22

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.
Files changed (80) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +24 -6
  3. package/dist/{check-GGQB3SHI.js → check-PHXXA7VY.js} +64 -27
  4. package/dist/check-PHXXA7VY.js.map +1 -0
  5. package/dist/{chunk-ZB5R5SK5.js → chunk-3YXRWQGX.js} +11 -6
  6. package/dist/chunk-3YXRWQGX.js.map +1 -0
  7. package/dist/{chunk-FBMYBYFB.js → chunk-AQZQIURH.js} +18 -15
  8. package/dist/chunk-AQZQIURH.js.map +1 -0
  9. package/dist/chunk-DMGABJ6T.js +41 -0
  10. package/dist/chunk-DMGABJ6T.js.map +1 -0
  11. package/dist/{chunk-ZIPGRLYE.js → chunk-HCJDCS26.js} +2 -2
  12. package/dist/chunk-HCJDCS26.js.map +1 -0
  13. package/dist/{chunk-CI7KYTC7.js → chunk-KVLFW5MI.js} +2 -2
  14. package/dist/{chunk-CI7KYTC7.js.map → chunk-KVLFW5MI.js.map} +1 -1
  15. package/dist/{chunk-RY5CDUNN.js → chunk-NAWYG4VV.js} +2 -2
  16. package/dist/chunk-NAWYG4VV.js.map +1 -0
  17. package/dist/chunk-NHD44ZYN.js +20 -0
  18. package/dist/chunk-NHD44ZYN.js.map +1 -0
  19. package/dist/{chunk-MM325DR6.js → chunk-SNQNQ2MP.js} +3 -3
  20. package/dist/chunk-SNQNQ2MP.js.map +1 -0
  21. package/dist/{chunk-UZKOJL2N.js → chunk-UFTEMDPU.js} +31 -9
  22. package/dist/chunk-UFTEMDPU.js.map +1 -0
  23. package/dist/{chunk-T232GZ2L.js → chunk-YRQPY5NF.js} +2 -2
  24. package/dist/{diff-PHEX3HUT.js → diff-6C5LJ7SH.js} +25 -13
  25. package/dist/diff-6C5LJ7SH.js.map +1 -0
  26. package/dist/{dist-RT3MTIUW.js → dist-ROHCFKYT.js} +2 -2
  27. package/dist/{dist-DQ6NNKZO.js → dist-SOZ3I4RP.js} +7 -7
  28. package/dist/{generate-5VO6M4PB.js → generate-AVXZHH76.js} +5 -5
  29. package/dist/{generate-story-CJMV2F5K.js → generate-story-3O4T4CEV.js} +4 -4
  30. package/dist/{generate-test-plan-XBAFJKJI.js → generate-test-plan-Z46W3N3B.js} +3 -3
  31. package/dist/{graph-UZJMLX4J.js → graph-4RNURBNP.js} +47 -10
  32. package/dist/graph-4RNURBNP.js.map +1 -0
  33. package/dist/index.d.ts +111 -7
  34. package/dist/index.js +234 -54
  35. package/dist/index.js.map +1 -1
  36. package/dist/{lint-TVL2ILOQ.js → lint-PKWAK4CO.js} +33 -12
  37. package/dist/lint-PKWAK4CO.js.map +1 -0
  38. package/dist/main.js +3 -3
  39. package/dist/{mcp-F7LJBZ4X.js → mcp-VMHFWM3O.js} +3 -3
  40. package/dist/{migrate-DEFCNOAH.js → migrate-FKFC7UAO.js} +3 -3
  41. package/dist/{pack-PNLD5AYW.js → pack-DE4UBTCC.js} +12 -8
  42. package/dist/pack-DE4UBTCC.js.map +1 -0
  43. package/dist/{ready-2PHBPWJD.js → ready-IKVESKEB.js} +19 -10
  44. package/dist/ready-IKVESKEB.js.map +1 -0
  45. package/dist/skills/core/specdx-sprint-review/SKILL.md +1 -1
  46. package/dist/{skills-LHFTTEJ7.js → skills-36SRUEMR.js} +1 -1
  47. package/dist/skills-36SRUEMR.js.map +1 -0
  48. package/dist/{status-UKLQV4AI.js → status-NWMX2KJZ.js} +40 -27
  49. package/dist/status-NWMX2KJZ.js.map +1 -0
  50. package/dist/{update-KLDLDQZM.js → update-UFOHZEAK.js} +20 -11
  51. package/dist/update-UFOHZEAK.js.map +1 -0
  52. package/dist/{validate-FXD5WS4C.js → validate-EZHUB5TW.js} +34 -16
  53. package/dist/validate-EZHUB5TW.js.map +1 -0
  54. package/package.json +9 -9
  55. package/dist/check-GGQB3SHI.js.map +0 -1
  56. package/dist/chunk-FBMYBYFB.js.map +0 -1
  57. package/dist/chunk-GAM4MXPC.js +0 -15
  58. package/dist/chunk-GAM4MXPC.js.map +0 -1
  59. package/dist/chunk-MM325DR6.js.map +0 -1
  60. package/dist/chunk-RY5CDUNN.js.map +0 -1
  61. package/dist/chunk-UZKOJL2N.js.map +0 -1
  62. package/dist/chunk-ZB5R5SK5.js.map +0 -1
  63. package/dist/chunk-ZIPGRLYE.js.map +0 -1
  64. package/dist/diff-PHEX3HUT.js.map +0 -1
  65. package/dist/graph-UZJMLX4J.js.map +0 -1
  66. package/dist/lint-TVL2ILOQ.js.map +0 -1
  67. package/dist/pack-PNLD5AYW.js.map +0 -1
  68. package/dist/ready-2PHBPWJD.js.map +0 -1
  69. package/dist/skills-LHFTTEJ7.js.map +0 -1
  70. package/dist/status-UKLQV4AI.js.map +0 -1
  71. package/dist/update-KLDLDQZM.js.map +0 -1
  72. package/dist/validate-FXD5WS4C.js.map +0 -1
  73. /package/dist/{chunk-T232GZ2L.js.map → chunk-YRQPY5NF.js.map} +0 -0
  74. /package/dist/{dist-RT3MTIUW.js.map → dist-ROHCFKYT.js.map} +0 -0
  75. /package/dist/{dist-DQ6NNKZO.js.map → dist-SOZ3I4RP.js.map} +0 -0
  76. /package/dist/{generate-5VO6M4PB.js.map → generate-AVXZHH76.js.map} +0 -0
  77. /package/dist/{generate-story-CJMV2F5K.js.map → generate-story-3O4T4CEV.js.map} +0 -0
  78. /package/dist/{generate-test-plan-XBAFJKJI.js.map → generate-test-plan-Z46W3N3B.js.map} +0 -0
  79. /package/dist/{mcp-F7LJBZ4X.js.map → mcp-VMHFWM3O.js.map} +0 -0
  80. /package/dist/{migrate-DEFCNOAH.js.map → migrate-FKFC7UAO.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1716,7 +1716,7 @@ var base_spec_default = {
1716
1716
 
1717
1717
  // ../schema/dist/schemas/config.json
1718
1718
  var config_default = {
1719
- $id: "sdx-config",
1719
+ $id: "specdx-config",
1720
1720
  $schema: "http://json-schema.org/draft-07/schema#",
1721
1721
  type: "object",
1722
1722
  properties: {
@@ -2045,6 +2045,9 @@ async function scaffoldProject({
2045
2045
  template,
2046
2046
  targetDir
2047
2047
  }) {
2048
+ if (!targetDir) {
2049
+ throw new TypeError("scaffoldProject requires `targetDir` \u2014 where to create the project.");
2050
+ }
2048
2051
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
2049
2052
  const specsDir = join(targetDir, "specs");
2050
2053
  await mkdir(specsDir, { recursive: true });
@@ -2116,7 +2119,7 @@ var CONFIG_FILENAME = "spec.config.yaml";
2116
2119
  async function loadConfig(filePath, searchFrom) {
2117
2120
  const resolvedPath = filePath ?? await findConfig(searchFrom ?? process.cwd());
2118
2121
  if (!resolvedPath) {
2119
- throw new ConfigError(`No ${CONFIG_FILENAME} found. Run 'sdx init' to create one.`);
2122
+ throw new ConfigError(`No ${CONFIG_FILENAME} found. Run 'specdx init' to create one.`);
2120
2123
  }
2121
2124
  let raw;
2122
2125
  try {
@@ -2959,6 +2962,12 @@ var EDGE_CASE_KEYWORDS = [
2959
2962
  "unprocessable"
2960
2963
  ];
2961
2964
  var ERROR_STATUS_CODE = /\b[45]\d{2}\b/;
2965
+ var EDGE_CASE_SECTION = "edge cases";
2966
+ var PLACEHOLDER_BODIES = /^(todo|tbd|fixme|n\/a|na|none|xxx|\.{2,}|-|\*)$/i;
2967
+ var DISCLAIMED_BODIES = /^(none|no|nothing|n\/a)\b[\s\S]{0,40}$/i;
2968
+ function meaningfulContent(content) {
2969
+ return content.replace(/<!--[\s\S]*?-->/g, "").split("\n").map((line) => line.replace(/^\s*[-*+]\s+/, "").trim()).filter((line) => line.length > 0 && !/^-{3,}$/.test(line)).join("\n").trim();
2970
+ }
2962
2971
  var edgeCaseCoverageRule = {
2963
2972
  id: "completeness/edge-case-coverage",
2964
2973
  description: "Flag user stories or test plans that don't mention error states or edge cases",
@@ -2967,6 +2976,22 @@ var edgeCaseCoverageRule = {
2967
2976
  const type = context.spec.frontmatter.type;
2968
2977
  if (type !== "user-story" && type !== "test-plan")
2969
2978
  return [];
2979
+ const section = context.spec.parsedSections.find((s) => s.heading.trim().toLowerCase() === EDGE_CASE_SECTION);
2980
+ if (type === "test-plan" && section) {
2981
+ const body = meaningfulContent(section.content);
2982
+ const written = body !== "" && !PLACEHOLDER_BODIES.test(body) && !DISCLAIMED_BODIES.test(body);
2983
+ if (written)
2984
+ return [];
2985
+ return [
2986
+ {
2987
+ ruleId: "completeness/edge-case-coverage",
2988
+ severity: "warn",
2989
+ message: `The "${section.heading}" section lists no cases \u2014 describe the boundary conditions and failure modes this plan covers, or the plan asserts only the happy path.`,
2990
+ filePath: context.spec.filePath,
2991
+ section: section.heading
2992
+ }
2993
+ ];
2994
+ }
2970
2995
  const content = context.spec.content.toLowerCase();
2971
2996
  const hasEdgeCases = EDGE_CASE_KEYWORDS.some((kw) => content.includes(kw)) || ERROR_STATUS_CODE.test(content);
2972
2997
  if (hasEdgeCases)
@@ -3099,7 +3124,7 @@ var ambiguityScoreAiRule = {
3099
3124
  {
3100
3125
  ruleId: "clarity/ambiguity-score-ai",
3101
3126
  severity: "info",
3102
- message: "AI ambiguity analysis available \u2014 run `sdx check --ai` for LLM-powered ambiguity detection",
3127
+ message: "AI ambiguity analysis available \u2014 run `specdx check --ai` for LLM-powered ambiguity detection",
3103
3128
  filePath: context.spec.filePath
3104
3129
  }
3105
3130
  ];
@@ -3107,8 +3132,8 @@ var ambiguityScoreAiRule = {
3107
3132
  };
3108
3133
 
3109
3134
  // ../lint/dist/rules/no-placeholder-sections.js
3110
- var PLACEHOLDER_BODIES = /^(todo|tbd|fixme|n\/a|na|none|xxx|\.{2,}|-|\*)$/i;
3111
- function meaningfulContent(content) {
3135
+ var PLACEHOLDER_BODIES2 = /^(todo|tbd|fixme|n\/a|na|none|xxx|\.{2,}|-|\*)$/i;
3136
+ function meaningfulContent2(content) {
3112
3137
  return content.replace(/<!--[\s\S]*?-->/g, "").split("\n").map((line) => line.replace(/^\s*[-*+]\s+/, "").trim()).filter((line) => line.length > 0 && !/^-{3,}$/.test(line)).join("\n").trim();
3113
3138
  }
3114
3139
  var noPlaceholderSectionsRule = {
@@ -3117,8 +3142,8 @@ var noPlaceholderSectionsRule = {
3117
3142
  severity: "warn",
3118
3143
  run(context) {
3119
3144
  return context.spec.parsedSections.filter((section) => section.heading !== "").filter((section) => {
3120
- const body = meaningfulContent(section.content);
3121
- return body === "" || PLACEHOLDER_BODIES.test(body);
3145
+ const body = meaningfulContent2(section.content);
3146
+ return body === "" || PLACEHOLDER_BODIES2.test(body);
3122
3147
  }).map((section) => ({
3123
3148
  ruleId: "completeness/no-placeholder-sections",
3124
3149
  severity: "warn",
@@ -3193,7 +3218,7 @@ function getPreset(name) {
3193
3218
  case "recommended":
3194
3219
  return allBuiltinRules;
3195
3220
  case "strict":
3196
- return allBuiltinRules.map((rule) => ({ ...rule, severity: "error" }));
3221
+ return allBuiltinRules.map((rule) => rule.severity === "warn" ? { ...rule, severity: "error" } : rule);
3197
3222
  default:
3198
3223
  throw new Error(`Unknown preset: "${name}". Use "minimal", "recommended", or "strict", or resolve external presets via resolvePreset() from @specdx/core.`);
3199
3224
  }
@@ -3203,15 +3228,54 @@ function getPreset(name) {
3203
3228
  import { pathToFileURL } from "url";
3204
3229
 
3205
3230
  // src/shared-args.ts
3206
- var sharedArgs = {
3207
- quiet: { type: "boolean", description: "Suppress info output", alias: ["q"] },
3208
- verbose: { type: "boolean", description: "Enable debug output", alias: ["V"] },
3209
- format: {
3210
- type: "string",
3211
- description: "Output format (pretty, json, github)",
3212
- default: "pretty"
3213
- }
3231
+ var quietArg = {
3232
+ type: "boolean",
3233
+ description: "Suppress success and summary output; problems still print",
3234
+ alias: ["q"]
3214
3235
  };
3236
+ var verboseArg = {
3237
+ type: "boolean",
3238
+ description: "Enable debug output",
3239
+ alias: ["V"]
3240
+ };
3241
+ function formatArg(formats) {
3242
+ const [fallback] = formats;
3243
+ if (!fallback) throw new Error("formatArg requires at least one format");
3244
+ return {
3245
+ type: "string",
3246
+ description: `Output format (${formats.join(", ")})`,
3247
+ default: fallback
3248
+ };
3249
+ }
3250
+ function sharedArgs(formats) {
3251
+ return { quiet: quietArg, verbose: verboseArg, format: formatArg(formats) };
3252
+ }
3253
+ function resolveFormat(value, formats) {
3254
+ const [fallback] = formats;
3255
+ if (!fallback) throw new Error("resolveFormat requires at least one format");
3256
+ if (value === void 0) return { ok: true, format: fallback };
3257
+ if (formats.includes(value)) return { ok: true, format: value };
3258
+ return {
3259
+ ok: false,
3260
+ message: `unknown --format "${value}". This command renders: ${formats.join(", ")}.`
3261
+ };
3262
+ }
3263
+
3264
+ // src/output.ts
3265
+ function createOutput(options = {}) {
3266
+ const quiet = options.quiet === true;
3267
+ return {
3268
+ info(line = "") {
3269
+ if (!quiet) console.log(line);
3270
+ },
3271
+ out(line = "") {
3272
+ console.log(line);
3273
+ },
3274
+ error(line = "") {
3275
+ console.error(line);
3276
+ }
3277
+ };
3278
+ }
3215
3279
 
3216
3280
  // src/formatters/pretty.ts
3217
3281
  function formatPretty(diagnostics) {
@@ -3231,14 +3295,18 @@ function formatJson(diagnostics) {
3231
3295
  // src/formatters/github.ts
3232
3296
  function formatGithub(diagnostics) {
3233
3297
  return diagnostics.map((d) => {
3234
- const level = d.severity === "error" ? "error" : "warning";
3298
+ const level = d.severity === "error" ? "error" : d.severity === "warn" ? "warning" : "notice";
3235
3299
  const line = d.line ? `,line=${d.line}` : "";
3236
3300
  return `::${level} file=${d.filePath}${line}::${d.message} (${d.ruleId})`;
3237
3301
  }).join("\n");
3238
3302
  }
3239
3303
 
3240
3304
  // src/commands/core/lint.ts
3305
+ var FORMATS = ["pretty", "json", "github"];
3241
3306
  async function runLint(options) {
3307
+ if (!options.configDir) {
3308
+ throw new TypeError("runLint requires `configDir` \u2014 the directory holding spec.config.yaml.");
3309
+ }
3242
3310
  const config = await loadConfig(void 0, options.configDir);
3243
3311
  const preset = options.preset ?? config.lint?.extends ?? "recommended";
3244
3312
  const rules = getPreset(preset);
@@ -3273,18 +3341,26 @@ async function runLint(options) {
3273
3341
  });
3274
3342
  results.hasErrors = true;
3275
3343
  }
3276
- return { ...results, specCount: specs.length, assessed: specs.length > 0 };
3344
+ return { ...results, specFiles: specs.length, assessed: specs.length > 0 };
3277
3345
  }
3278
3346
  var lint_default = defineCommand2({
3279
3347
  meta: { name: "lint", description: "Lint all specs in the suite" },
3280
3348
  args: {
3281
- ...sharedArgs,
3349
+ ...sharedArgs(FORMATS),
3282
3350
  fix: { type: "boolean", description: "Auto-fix issues where possible" },
3283
3351
  path: { type: "positional", description: "Lint a specific spec file", required: false },
3284
3352
  preset: { type: "string", description: "Lint preset (minimal, recommended, strict)" }
3285
3353
  },
3286
3354
  async run({ args }) {
3287
3355
  const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });
3356
+ const output = createOutput({ quiet: args.quiet });
3357
+ const format = resolveFormat(args.format, FORMATS);
3358
+ if (!format.ok) {
3359
+ console.error(`
3360
+ \u2717 ${format.message}
3361
+ `);
3362
+ process.exit(1);
3363
+ }
3288
3364
  if (args.fix) {
3289
3365
  logger.info("No auto-fixable issues supported yet.");
3290
3366
  }
@@ -3294,14 +3370,19 @@ var lint_default = defineCommand2({
3294
3370
  specPath: args.path,
3295
3371
  preset: args.preset
3296
3372
  });
3297
- const formatter = args.format === "json" ? formatJson : args.format === "github" ? formatGithub : formatPretty;
3373
+ const formatter = format.format === "json" ? formatJson : format.format === "github" ? formatGithub : formatPretty;
3298
3374
  if (!results.assessed) {
3299
3375
  console.error(
3300
3376
  "\n \u26A0 No specs found \u2014 nothing was linted. Check the spec paths in spec.config.yaml.\n"
3301
3377
  );
3302
3378
  process.exit(3);
3303
3379
  }
3304
- console.log(formatter(results.diagnostics));
3380
+ const rendered = formatter(results.diagnostics);
3381
+ if (format.format === "pretty" && results.diagnostics.length === 0) {
3382
+ output.info(rendered);
3383
+ } else {
3384
+ output.out(rendered);
3385
+ }
3305
3386
  if (results.hasErrors) process.exit(1);
3306
3387
  } catch (err) {
3307
3388
  console.error(`
@@ -4022,6 +4103,9 @@ function emptyPackReason(stats, specsResolved) {
4022
4103
  return `all ${stats.specsExcluded} candidate spec(s) were excluded \u2014 widen --specs or raise --budget`;
4023
4104
  }
4024
4105
  async function runPack(options) {
4106
+ if (!options.configDir) {
4107
+ throw new TypeError("runPack requires `configDir` \u2014 the directory holding spec.config.yaml.");
4108
+ }
4025
4109
  const config = await loadConfig(void 0, options.configDir);
4026
4110
  const allSpecs = [];
4027
4111
  for (const [, entry] of Object.entries(config.specs)) {
@@ -4053,8 +4137,8 @@ async function runPack(options) {
4053
4137
  var pack_default = defineCommand3({
4054
4138
  meta: { name: "pack", description: "Pack specs into AI-ready context" },
4055
4139
  args: {
4056
- quiet: sharedArgs.quiet,
4057
- verbose: sharedArgs.verbose,
4140
+ quiet: quietArg,
4141
+ verbose: verboseArg,
4058
4142
  task: { type: "string", description: "Task or context to optimise relevance for" },
4059
4143
  specs: { type: "string", description: "Comma-separated spec IDs or glob patterns to include" },
4060
4144
  budget: { type: "string", description: "Maximum token budget for the output" },
@@ -5528,8 +5612,9 @@ function formatChangelog(result, baseRef, headRef) {
5528
5612
  }
5529
5613
 
5530
5614
  // src/commands/core/diff.ts
5615
+ var FORMATS2 = ["pretty", "json", "changelog"];
5531
5616
  async function runDiff(options) {
5532
- const configDir = process.cwd();
5617
+ const configDir = options.configDir ?? process.cwd();
5533
5618
  const config = await loadConfig(void 0, configDir);
5534
5619
  const baseRef = options.base ?? config.diff?.baseline_ref ?? DEFAULT_DIFF_CONFIG.baseline_ref;
5535
5620
  const headRef = options.head ?? "HEAD";
@@ -5554,13 +5639,17 @@ var diff_default = defineCommand4({
5554
5639
  default: false
5555
5640
  },
5556
5641
  spec: { type: "string", description: "Scope to a single spec ID" },
5557
- format: {
5558
- type: "string",
5559
- description: "Output format: pretty, json, changelog",
5560
- default: "pretty"
5561
- }
5642
+ ...sharedArgs(FORMATS2)
5562
5643
  },
5563
5644
  async run({ args }) {
5645
+ const format = resolveFormat(args.format, FORMATS2);
5646
+ if (!format.ok) {
5647
+ console.error(`
5648
+ \u2717 ${format.message}
5649
+ `);
5650
+ process.exit(1);
5651
+ }
5652
+ const output = createOutput({ quiet: args.quiet });
5564
5653
  try {
5565
5654
  try {
5566
5655
  const result = await runDiff({
@@ -5570,11 +5659,11 @@ var diff_default = defineCommand4({
5570
5659
  format: args.format,
5571
5660
  working: args.working
5572
5661
  });
5573
- if (args.format === "json") {
5662
+ if (format.format === "json") {
5574
5663
  console.log(JSON.stringify(result, null, 2));
5575
5664
  return;
5576
5665
  }
5577
- if (args.format === "changelog") {
5666
+ if (format.format === "changelog") {
5578
5667
  const baseRef = args.base ?? (await loadConfig(void 0, process.cwd())).diff?.baseline_ref ?? "main";
5579
5668
  console.log(
5580
5669
  formatChangelog(result, baseRef, args.working ? "working tree" : args.head ?? "HEAD")
@@ -5594,7 +5683,7 @@ var diff_default = defineCommand4({
5594
5683
  console.log(" Run with --working to include them.");
5595
5684
  };
5596
5685
  if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
5597
- console.log(" \u2713 No spec changes detected.");
5686
+ output.info(" \u2713 No spec changes detected.");
5598
5687
  printUncommittedWarning();
5599
5688
  return;
5600
5689
  }
@@ -5649,8 +5738,9 @@ var diff_default = defineCommand4({
5649
5738
 
5650
5739
  // src/commands/core/status.ts
5651
5740
  import { defineCommand as defineCommand5 } from "citty";
5652
- async function runStatus(_options = {}) {
5653
- const configDir = process.cwd();
5741
+ var FORMATS3 = ["pretty", "json", "github"];
5742
+ async function runStatus(options = {}) {
5743
+ const configDir = options.configDir ?? process.cwd();
5654
5744
  const config = await loadConfig(void 0, configDir);
5655
5745
  const specs = [];
5656
5746
  for (const [, entry] of Object.entries(config.specs)) {
@@ -5721,7 +5811,7 @@ async function runStatus(_options = {}) {
5721
5811
  else if (specs.length === 0) verdict = "unassessed";
5722
5812
  return {
5723
5813
  project: config.project?.name ?? "unknown",
5724
- specCount: specs.length,
5814
+ specFiles: specs.length,
5725
5815
  byStatus,
5726
5816
  lintHealth: { errors, warnings, passing: specs.length - errors },
5727
5817
  staleSpecs,
@@ -5731,21 +5821,23 @@ async function runStatus(_options = {}) {
5731
5821
  }
5732
5822
  var status_default = defineCommand5({
5733
5823
  meta: { name: "status", description: "Show spec suite health overview" },
5734
- args: {
5735
- format: {
5736
- type: "string",
5737
- description: "Output format: pretty, json, github",
5738
- default: "pretty"
5739
- }
5740
- },
5824
+ args: { ...sharedArgs(FORMATS3) },
5741
5825
  async run({ args }) {
5826
+ const format = resolveFormat(args.format, FORMATS3);
5827
+ if (!format.ok) {
5828
+ console.error(`
5829
+ \u2717 ${format.message}
5830
+ `);
5831
+ process.exit(1);
5832
+ }
5833
+ const output = createOutput({ quiet: args.quiet });
5742
5834
  try {
5743
- const result = await runStatus({ format: args.format });
5744
- if (args.format === "json") {
5835
+ const result = await runStatus();
5836
+ if (format.format === "json") {
5745
5837
  console.log(JSON.stringify(result, null, 2));
5746
5838
  return;
5747
5839
  }
5748
- if (args.format === "github") {
5840
+ if (format.format === "github") {
5749
5841
  for (const s of result.staleSpecs) {
5750
5842
  console.log(
5751
5843
  `::warning::Spec "${s.specId}" is stale (${s.daysSinceUpdate} days since update)`
@@ -5757,28 +5849,31 @@ var status_default = defineCommand5({
5757
5849
  return;
5758
5850
  }
5759
5851
  const icon = result.verdict === "healthy" ? "\u2713" : result.verdict === "warnings" || result.verdict === "unassessed" ? "\u26A0" : "\u2717";
5760
- console.log(`
5761
- ${icon} ${result.project} \u2014 ${result.verdict}`);
5852
+ const healthy = result.verdict === "healthy";
5853
+ const headline = `
5854
+ ${icon} ${result.project} \u2014 ${result.verdict}`;
5855
+ if (healthy) output.info(headline);
5856
+ else output.out(headline);
5762
5857
  if (result.verdict === "unassessed") {
5763
- console.log(
5858
+ output.out(
5764
5859
  " No specs resolved \u2014 nothing was assessed. Check the spec paths in spec.config.yaml."
5765
5860
  );
5766
5861
  }
5767
- console.log(
5768
- ` ${result.specCount} specs: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
5862
+ output.info(
5863
+ ` ${result.specFiles} specs: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
5769
5864
  );
5770
- console.log(
5865
+ output.info(
5771
5866
  ` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`
5772
5867
  );
5773
5868
  if (result.staleSpecs.length > 0) {
5774
- console.log(
5869
+ output.out(
5775
5870
  ` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(", ")}`
5776
5871
  );
5777
5872
  }
5778
5873
  if (result.integrityIssues.length > 0) {
5779
- console.log(` Issues: ${result.integrityIssues.join("; ")}`);
5874
+ output.out(` Issues: ${result.integrityIssues.join("; ")}`);
5780
5875
  }
5781
- console.log();
5876
+ output.info();
5782
5877
  } catch (err) {
5783
5878
  console.error(`
5784
5879
  \u2717 ${err.message}
@@ -5787,11 +5882,96 @@ var status_default = defineCommand5({
5787
5882
  }
5788
5883
  }
5789
5884
  });
5885
+
5886
+ // src/commands/core/validate.ts
5887
+ import { defineCommand as defineCommand6 } from "citty";
5888
+ var FORMATS4 = ["pretty", "json"];
5889
+ async function runValidate(configDir) {
5890
+ const warnings = [];
5891
+ try {
5892
+ const config = await loadConfig(void 0, configDir);
5893
+ buildGraph(config);
5894
+ let specFiles = 0;
5895
+ const missingRequired = [];
5896
+ for (const [key, entry] of Object.entries(config.specs)) {
5897
+ const files = await resolveGlob(entry.path, configDir);
5898
+ specFiles += files.length;
5899
+ if (files.length > 0) continue;
5900
+ if (entry.required) {
5901
+ missingRequired.push(`"${key}" (${entry.path})`);
5902
+ } else {
5903
+ warnings.push(`spec entry "${key}" resolves to no files: ${entry.path}`);
5904
+ }
5905
+ }
5906
+ if (missingRequired.length > 0) {
5907
+ return {
5908
+ valid: false,
5909
+ specEntries: Object.keys(config.specs).length,
5910
+ specFiles,
5911
+ warnings,
5912
+ error: `required spec entry resolves to no files: ${missingRequired.join(", ")}`
5913
+ };
5914
+ }
5915
+ if (specFiles === 0) {
5916
+ warnings.push(
5917
+ "no spec files found \u2014 every downstream check (lint, status, ready) would pass vacuously"
5918
+ );
5919
+ }
5920
+ return {
5921
+ valid: true,
5922
+ specEntries: Object.keys(config.specs).length,
5923
+ specFiles,
5924
+ warnings
5925
+ };
5926
+ } catch (err) {
5927
+ if (err instanceof ConfigError) {
5928
+ return { valid: false, warnings, error: err.message, details: err.errors ?? void 0 };
5929
+ }
5930
+ if (err instanceof GraphError) {
5931
+ return { valid: false, warnings, error: err.message };
5932
+ }
5933
+ throw err;
5934
+ }
5935
+ }
5936
+ var validate_default = defineCommand6({
5937
+ meta: { name: "validate", description: "Validate spec.config.yaml" },
5938
+ args: { ...sharedArgs(FORMATS4) },
5939
+ async run({ args }) {
5940
+ const format = resolveFormat(args.format, FORMATS4);
5941
+ if (!format.ok) {
5942
+ console.error(`
5943
+ \u2717 ${format.message}
5944
+ `);
5945
+ process.exit(1);
5946
+ }
5947
+ const output = createOutput({ quiet: args.quiet });
5948
+ const result = await runValidate(process.cwd());
5949
+ if (format.format === "json") {
5950
+ console.log(JSON.stringify(result, null, 2));
5951
+ if (!result.valid) process.exit(1);
5952
+ return;
5953
+ }
5954
+ if (result.valid) {
5955
+ output.info(
5956
+ ` \u2713 Config valid. ${result.specEntries} spec entries, ${result.specFiles} spec files.`
5957
+ );
5958
+ for (const w of result.warnings) output.out(` \u26A0 ${w}`);
5959
+ return;
5960
+ }
5961
+ console.error(` \u2717 Config invalid: ${result.error}`);
5962
+ for (const w of result.warnings) console.error(` \u26A0 ${w}`);
5963
+ if (result.details) {
5964
+ for (const e of result.details) console.error(` - ${JSON.stringify(e)}`);
5965
+ }
5966
+ process.exit(1);
5967
+ }
5968
+ });
5790
5969
  export {
5791
5970
  runDiff,
5792
5971
  runLint,
5793
5972
  runPack,
5794
5973
  runStatus,
5974
+ runValidate,
5795
5975
  scaffoldProject
5796
5976
  };
5797
5977
  //# sourceMappingURL=index.js.map