eslint-plugin-traceability 1.31.2 → 1.31.4

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 (39) hide show
  1. package/CHANGELOG.md +3 -2
  2. package/lib/index.d.ts +0 -8
  3. package/lib/index.js +4 -38
  4. package/lib/maintenance/batch.d.ts +4 -5
  5. package/lib/maintenance/batch.js +4 -5
  6. package/lib/maintenance/cli.d.ts +2 -4
  7. package/lib/maintenance/cli.js +12 -14
  8. package/lib/maintenance/commands.d.ts +11 -11
  9. package/lib/maintenance/commands.js +16 -16
  10. package/lib/maintenance/detect.d.ts +1 -1
  11. package/lib/maintenance/detect.js +35 -35
  12. package/lib/maintenance/flags.d.ts +5 -5
  13. package/lib/maintenance/flags.js +13 -13
  14. package/lib/maintenance/index.d.ts +5 -7
  15. package/lib/maintenance/index.js +5 -7
  16. package/lib/maintenance/report.d.ts +1 -2
  17. package/lib/maintenance/report.js +7 -9
  18. package/lib/maintenance/utils.d.ts +0 -1
  19. package/lib/maintenance/utils.js +1 -28
  20. package/lib/rules/helpers/require-story-core.js +1 -0
  21. package/lib/rules/helpers/require-story-io.js +1 -0
  22. package/lib/rules/helpers/require-story-node-utils.js +1 -0
  23. package/lib/rules/helpers/require-story-visitors.js +1 -0
  24. package/lib/rules/helpers/valid-annotation-format-validators.js +1 -0
  25. package/lib/rules/helpers/valid-annotation-utils.js +1 -0
  26. package/lib/rules/helpers/valid-req-reference-helpers.js +1 -0
  27. package/lib/rules/require-req-annotation.js +0 -1
  28. package/lib/rules/valid-annotation-format.js +1 -0
  29. package/lib/utils/annotation-checker.js +1 -0
  30. package/lib/utils/branch-annotation-helpers.d.ts +1 -1
  31. package/lib/utils/branch-annotation-helpers.js +3 -6
  32. package/lib/utils/branch-annotation-report-helpers.d.ts +1 -1
  33. package/lib/utils/branch-annotation-report-helpers.js +2 -2
  34. package/lib/utils/branch-validation.js +5 -5
  35. package/lib/utils/comment-text-helpers.d.ts +1 -1
  36. package/lib/utils/comment-text-helpers.js +1 -1
  37. package/lib/utils/reqAnnotationDetection.d.ts +2 -4
  38. package/lib/utils/reqAnnotationDetection.js +31 -55
  39. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,9 +1,10 @@
1
- ## [1.31.2](https://github.com/voder-ai/eslint-plugin-traceability/compare/v1.31.1...v1.31.2) (2026-01-14)
1
+ ## [1.31.4](https://github.com/voder-ai/eslint-plugin-traceability/compare/v1.31.3...v1.31.4) (2026-01-14)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * **rules:** add [@supports](https://github.com/supports) validation to valid-story-reference rule ([f30798b](https://github.com/voder-ai/eslint-plugin-traceability/commit/f30798b9437428b69e5553d75366e6cfd8d9eb99))
6
+ * **rules:** remove fake REQ-CREATE-HOOK from require-req-annotation.ts ([e8627a3](https://github.com/voder-ai/eslint-plugin-traceability/commit/e8627a35ae45a1e2089ca6fc0c392181726b6ec7))
7
+ * **src:** remove fake requirement IDs and convert to [@supports](https://github.com/supports) format in index.ts ([51fffcd](https://github.com/voder-ai/eslint-plugin-traceability/commit/51fffcda86df82e89f4bff97886ef76d1aa39b09))
7
8
 
8
9
  # Changelog
9
10
 
package/lib/index.d.ts CHANGED
@@ -5,10 +5,6 @@
5
5
  * @req REQ-ERROR-HANDLING - Gracefully handles plugin loading errors and missing dependencies
6
6
  */
7
7
  import type { Rule } from "eslint";
8
- /**
9
- * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
10
- * @req REQ-MAINTENANCE-API-EXPORT - Expose maintenance utilities alongside core plugin exports
11
- */
12
8
  import { detectStaleAnnotations, updateAnnotationReferences, batchUpdateAnnotations, verifyAnnotations, generateMaintenanceReport } from "./maintenance";
13
9
  declare const rules: Record<string, Rule.RuleModule>;
14
10
  /**
@@ -45,10 +41,6 @@ declare const configs: {
45
41
  };
46
42
  }[];
47
43
  };
48
- /**
49
- * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
50
- * @req REQ-MAINTENANCE-API-EXPORT - Expose maintenance utilities alongside core plugin exports
51
- */
52
44
  declare const maintenance: {
53
45
  detectStaleAnnotations: typeof detectStaleAnnotations;
54
46
  updateAnnotationReferences: typeof updateAnnotationReferences;
package/lib/index.js CHANGED
@@ -1,15 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.maintenance = exports.configs = exports.rules = void 0;
4
- /**
5
- * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
6
- * @req REQ-MAINTENANCE-API-EXPORT - Expose maintenance utilities alongside core plugin exports
7
- */
8
4
  const maintenance_1 = require("./maintenance");
9
- /**
10
- * @story docs/stories/002.0-DEV-ESLINT-CONFIG.story.md
11
- * @req REQ-RULE-LIST - Enumerate supported rule file names for plugin discovery
12
- */
13
5
  const RULE_NAMES = [
14
6
  "require-traceability",
15
7
  "require-story-annotation",
@@ -24,22 +16,8 @@ const RULE_NAMES = [
24
16
  ];
25
17
  const rules = {};
26
18
  exports.rules = rules;
27
- RULE_NAMES.forEach(
28
- /**
29
- * @story docs/stories/002.0-DEV-ESLINT-CONFIG.story.md
30
- * @req REQ-DYNAMIC-LOADING - Support dynamic rule loading by name at runtime
31
- * @param {RuleName} name - Rule file base name used to discover and load rule module
32
- */
33
- (name) => {
34
- /**
35
- * @story docs/stories/002.0-DEV-ESLINT-CONFIG.story.md
36
- * @req REQ-DYNAMIC-LOADING - Support dynamic rule loading by name at runtime
37
- */
19
+ RULE_NAMES.forEach((name) => {
38
20
  try {
39
- /**
40
- * @story docs/stories/002.0-DEV-ESLINT-CONFIG.story.md
41
- * @req REQ-DYNAMIC-LOADING - Support dynamic rule loading by name at runtime
42
- */
43
21
  // Dynamically require rule module
44
22
  const mod = require(`./rules/${name}`);
45
23
  // Support ESModule default export
@@ -47,11 +25,7 @@ RULE_NAMES.forEach(
47
25
  }
48
26
  catch (error) {
49
27
  /**
50
- * @story docs/stories/007.0-DEV-ERROR-REPORTING.story.md
51
- * @req REQ-ERROR-HANDLING - Provide fallback rule module and surface errors when rule loading fails
52
- */
53
- /**
54
- * @story docs/stories/007.0-DEV-ERROR-REPORTING.story.md
28
+ * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
55
29
  * @req REQ-ERROR-HANDLING - Provide fallback rule module and surface errors when rule loading fails
56
30
  */
57
31
  console.error(`[eslint-plugin-traceability] Failed to load rule "${name}": ${error.message}`);
@@ -238,12 +212,8 @@ const TRACEABILITY_RULE_SEVERITIES = {
238
212
  "traceability/no-redundant-annotation": "warn",
239
213
  };
240
214
  /**
241
- * @story docs/stories/007.0-DEV-ERROR-REPORTING.story.md
242
- * @req REQ-PLUGIN-STRUCTURE - Provide foundational plugin export and registration
243
- * @req REQ-ERROR-SEVERITY - Map rule types to appropriate ESLint severity levels (errors vs warnings)
244
- * @story docs/stories/002.0-DEV-ESLINT-CONFIG.story.md
245
- * @req REQ-CONFIG-PRESETS - Provide flat-config presets that self-register the plugin and core rules
246
- *
215
+ * Create flat config preset for ESLint v9.
216
+ * @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-PLUGIN-STRUCTURE
247
217
  * @supports docs/stories/007.0-DEV-ERROR-REPORTING.story.md REQ-ERROR-SEVERITY
248
218
  * @supports docs/stories/002.0-DEV-ESLINT-CONFIG.story.md REQ-CONFIG-PRESETS
249
219
  */
@@ -266,10 +236,6 @@ const configs = {
266
236
  };
267
237
  exports.configs = configs;
268
238
  plugin.configs = configs;
269
- /**
270
- * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
271
- * @req REQ-MAINTENANCE-API-EXPORT - Expose maintenance utilities alongside core plugin exports
272
- */
273
239
  const maintenance = {
274
240
  detectStaleAnnotations: maintenance_1.detectStaleAnnotations,
275
241
  updateAnnotationReferences: maintenance_1.updateAnnotationReferences,
@@ -3,9 +3,8 @@ import { GetAllFilesOptions } from "./utils";
3
3
  * Batch update annotations and verify references
4
4
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
5
5
  * @req REQ-MAINT-BATCH - Perform batch updates
6
- * @req REQ-MAINT-VERIFY - Verify annotation references
7
- * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
8
- * @req REQ-MAINT-UPDATE#1 - Update @supports references alongside @story
6
+ * @req REQ-MAINT-UPDATE - Update annotation references
7
+ * @req REQ-MAINT-CLI - Provide CLI command interface
9
8
  * @param codebasePath Absolute path to the workspace root where annotations will be updated.
10
9
  * @param mappings Array of mapping objects describing path changes, each containing an oldPath and newPath.
11
10
  * @param options Optional configuration including ESLint ignore patterns
@@ -21,8 +20,8 @@ export declare function batchUpdateAnnotations(codebasePath: string, mappings: {
21
20
  /**
22
21
  * Verify annotation references in codebase after maintenance operations
23
22
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
24
- * @req REQ-MAINT-VERIFY - Verify annotation references
25
- * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
23
+ * @req REQ-MAINT-CLI - Provide CLI command interface
24
+ * @req REQ-MAINT-MANUAL-TRIGGER - Manual developer execution
26
25
  * @param codebasePath Absolute path to the workspace root whose annotations should be verified.
27
26
  * @param options Optional configuration including ESLint ignore patterns
28
27
  * @returns Boolean indicating whether there are no stale annotations remaining (true if clean, false if any remain).
@@ -8,9 +8,8 @@ const detect_1 = require("./detect");
8
8
  * Batch update annotations and verify references
9
9
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
10
10
  * @req REQ-MAINT-BATCH - Perform batch updates
11
- * @req REQ-MAINT-VERIFY - Verify annotation references
12
- * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
13
- * @req REQ-MAINT-UPDATE#1 - Update @supports references alongside @story
11
+ * @req REQ-MAINT-UPDATE - Update annotation references
12
+ * @req REQ-MAINT-CLI - Provide CLI command interface
14
13
  * @param codebasePath Absolute path to the workspace root where annotations will be updated.
15
14
  * @param mappings Array of mapping objects describing path changes, each containing an oldPath and newPath.
16
15
  * @param options Optional configuration including ESLint ignore patterns
@@ -29,8 +28,8 @@ function batchUpdateAnnotations(codebasePath, mappings, options) {
29
28
  /**
30
29
  * Verify annotation references in codebase after maintenance operations
31
30
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
32
- * @req REQ-MAINT-VERIFY - Verify annotation references
33
- * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
31
+ * @req REQ-MAINT-CLI - Provide CLI command interface
32
+ * @req REQ-MAINT-MANUAL-TRIGGER - Manual developer execution
34
33
  * @param codebasePath Absolute path to the workspace root whose annotations should be verified.
35
34
  * @param options Optional configuration including ESLint ignore patterns
36
35
  * @returns Boolean indicating whether there are no stale annotations remaining (true if clean, false if any remain).
@@ -2,11 +2,9 @@
2
2
  /**
3
3
  * Maintenance CLI entry point.
4
4
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
5
- * @req REQ-MAINT-DETECT - CLI support for detection of stale annotations
6
- * @req REQ-MAINT-VERIFY - CLI support for verification of annotations
7
- * @req REQ-MAINT-REPORT - CLI support for human-readable reports
5
+ * @req REQ-MAINT-CLI - CLI support for maintenance commands
8
6
  * @req REQ-MAINT-UPDATE - CLI support for updating annotation references
9
7
  * @req REQ-MAINT-BATCH - CLI support for batch maintenance operations
10
- * @req REQ-MAINT-SAFE - Provide clear exit codes and avoid unsafe defaults
8
+ * @req REQ-MAINT-MANUAL-TRIGGER - Maintenance tools run only when manually executed
11
9
  */
12
10
  export declare function runMaintenanceCli(rawArgv: string[]): number;
@@ -7,18 +7,16 @@ const flags_1 = require("./flags");
7
7
  /**
8
8
  * Maintenance CLI entry point.
9
9
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
10
- * @req REQ-MAINT-DETECT - CLI support for detection of stale annotations
11
- * @req REQ-MAINT-VERIFY - CLI support for verification of annotations
12
- * @req REQ-MAINT-REPORT - CLI support for human-readable reports
10
+ * @req REQ-MAINT-CLI - CLI support for maintenance commands
13
11
  * @req REQ-MAINT-UPDATE - CLI support for updating annotation references
14
12
  * @req REQ-MAINT-BATCH - CLI support for batch maintenance operations
15
- * @req REQ-MAINT-SAFE - Provide clear exit codes and avoid unsafe defaults
13
+ * @req REQ-MAINT-MANUAL-TRIGGER - Maintenance tools run only when manually executed
16
14
  */
17
15
  function runMaintenanceCli(rawArgv) {
18
16
  const initialNormalized = (0, flags_1.normalizeCliArgs)(rawArgv);
19
17
  const { subcommand: command } = initialNormalized;
20
18
  if (!command || command === "-h" || command === "--help") {
21
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE
19
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-MANUAL-TRIGGER
22
20
  printHelp();
23
21
  return commands_1.EXIT_OK;
24
22
  }
@@ -26,35 +24,35 @@ function runMaintenanceCli(rawArgv) {
26
24
  // receive the subcommand name and its raw argument vector unchanged.
27
25
  const normalized = initialNormalized;
28
26
  try {
29
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE
27
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
30
28
  switch (command) {
31
29
  case "detect":
32
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
30
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
33
31
  return (0, commands_1.handleDetect)(normalized);
34
32
  case "verify":
35
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-VERIFY
33
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
36
34
  return (0, commands_1.handleVerify)(normalized);
37
35
  case "report":
38
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-REPORT
36
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
39
37
  return (0, commands_1.handleReport)(normalized);
40
38
  case "update": {
41
39
  // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-UPDATE
42
40
  const result = (0, commands_1.handleUpdate)(normalized);
43
41
  if (result === commands_1.EXIT_USAGE) {
44
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE
42
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-MANUAL-TRIGGER
45
43
  printHelp();
46
44
  }
47
45
  return result;
48
46
  }
49
47
  default:
50
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE
48
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-MANUAL-TRIGGER
51
49
  console.error(`Unknown command: ${command}`);
52
50
  printHelp();
53
51
  return commands_1.EXIT_USAGE;
54
52
  }
55
53
  }
56
54
  catch (error) {
57
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE
55
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-MANUAL-TRIGGER
58
56
  const message = error instanceof Error
59
57
  ? error.message
60
58
  : "Unknown error in maintenance CLI";
@@ -65,10 +63,10 @@ function runMaintenanceCli(rawArgv) {
65
63
  /**
66
64
  * Print CLI usage help for the maintenance tools.
67
65
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
68
- * @req REQ-MAINT-SAFE - Provide discoverable CLI usage information
66
+ * @req REQ-MAINT-MANUAL-TRIGGER - Provide discoverable CLI usage information
69
67
  */
70
68
  function printHelp() {
71
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE
69
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-MANUAL-TRIGGER
72
70
  console.log(`traceability-maint - Traceability annotation maintenance tools
73
71
 
74
72
  Usage:
@@ -5,35 +5,35 @@ export declare const EXIT_USAGE = 2;
5
5
  /**
6
6
  * Handle the `detect` subcommand for stale story annotations.
7
7
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
8
- * @req REQ-MAINT-DETECT - CLI surface for detection of stale annotations
9
- * @req REQ-MAINT-SAFE - Return specific exit codes for stale vs clean states
8
+ * @req REQ-MAINT-CLI - CLI surface for detection of stale annotations
9
+ * @req REQ-MAINT-CLI - Return specific exit codes for stale vs clean states
10
10
  * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
11
- * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT REQ-MAINT-SAFE
11
+ * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI REQ-MAINT-CLI
12
12
  */
13
13
  export declare function handleDetect(normalized: NormalizedCliArgs): number;
14
14
  /**
15
15
  * Handle the `verify` subcommand to validate traceability annotations.
16
16
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
17
- * @req REQ-MAINT-VERIFY - CLI surface for verification of annotations
18
- * @req REQ-MAINT-SAFE - Return distinct exit codes for verification failures
17
+ * @req REQ-MAINT-CLI - CLI surface for verification of annotations
18
+ * @req REQ-MAINT-CLI - Return distinct exit codes for verification failures
19
19
  * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
20
- * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-VERIFY REQ-MAINT-SAFE
20
+ * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI REQ-MAINT-CLI
21
21
  */
22
22
  export declare function handleVerify(normalized: NormalizedCliArgs): number;
23
23
  /**
24
24
  * Handle the `report` subcommand to generate a maintenance report.
25
25
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
26
- * @req REQ-MAINT-REPORT - CLI surface for human-readable maintenance reports
27
- * @req REQ-MAINT-SAFE - Support machine-readable formats for safe automation
26
+ * @req REQ-MAINT-CLI - CLI surface for human-readable maintenance reports
27
+ * @req REQ-MAINT-CLI - Support machine-readable formats for safe automation
28
28
  * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
29
- * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-REPORT REQ-MAINT-SAFE
29
+ * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI REQ-MAINT-CLI
30
30
  */
31
31
  export declare function handleReport(normalized: NormalizedCliArgs): number;
32
32
  /**
33
33
  * Handle the `update` subcommand to rewrite story annotation references.
34
34
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
35
35
  * @req REQ-MAINT-UPDATE - CLI surface for updating annotation references
36
- * @req REQ-MAINT-SAFE - Provide dry-run mode and explicit parameter checks
37
- * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-UPDATE REQ-MAINT-SAFE
36
+ * @req REQ-MAINT-CLI - Provide dry-run mode and explicit parameter checks
37
+ * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-UPDATE REQ-MAINT-CLI
38
38
  */
39
39
  export declare function handleUpdate(normalized: NormalizedCliArgs): number;
@@ -9,11 +9,11 @@ exports.handleUpdate = handleUpdate;
9
9
  * Subcommand handlers for the traceability-maint CLI.
10
10
  *
11
11
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
12
- * @req REQ-MAINT-DETECT - CLI support for detection of stale annotations.
13
- * @req REQ-MAINT-VERIFY - CLI support for verification of annotations
14
- * @req REQ-MAINT-REPORT - CLI support for human-readable reports
12
+ * @req REQ-MAINT-CLI - CLI support for detection of stale annotations.
13
+ * @req REQ-MAINT-CLI - CLI support for verification of annotations
14
+ * @req REQ-MAINT-CLI - CLI support for human-readable reports
15
15
  * @req REQ-MAINT-UPDATE - CLI support for updating annotation references
16
- * @req REQ-MAINT-SAFE - Provide clear exit codes and avoid unsafe defaults
16
+ * @req REQ-MAINT-CLI - Provide clear exit codes and avoid unsafe defaults
17
17
  */
18
18
  const detect_1 = require("./detect");
19
19
  const batch_1 = require("./batch");
@@ -26,10 +26,10 @@ exports.EXIT_USAGE = 2;
26
26
  /**
27
27
  * Handle the `detect` subcommand for stale story annotations.
28
28
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
29
- * @req REQ-MAINT-DETECT - CLI surface for detection of stale annotations
30
- * @req REQ-MAINT-SAFE - Return specific exit codes for stale vs clean states
29
+ * @req REQ-MAINT-CLI - CLI surface for detection of stale annotations
30
+ * @req REQ-MAINT-CLI - Return specific exit codes for stale vs clean states
31
31
  * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
32
- * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT REQ-MAINT-SAFE
32
+ * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI REQ-MAINT-CLI
33
33
  */
34
34
  function handleDetect(normalized) {
35
35
  const flags = (0, flags_1.parseFlags)(normalized);
@@ -57,10 +57,10 @@ Run 'traceability-maint report' for a structured summary.`);
57
57
  /**
58
58
  * Handle the `verify` subcommand to validate traceability annotations.
59
59
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
60
- * @req REQ-MAINT-VERIFY - CLI surface for verification of annotations
61
- * @req REQ-MAINT-SAFE - Return distinct exit codes for verification failures
60
+ * @req REQ-MAINT-CLI - CLI surface for verification of annotations
61
+ * @req REQ-MAINT-CLI - Return distinct exit codes for verification failures
62
62
  * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
63
- * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-VERIFY REQ-MAINT-SAFE
63
+ * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI REQ-MAINT-CLI
64
64
  */
65
65
  function handleVerify(normalized) {
66
66
  const flags = (0, flags_1.parseFlags)(normalized);
@@ -79,10 +79,10 @@ function handleVerify(normalized) {
79
79
  /**
80
80
  * Handle the `report` subcommand to generate a maintenance report.
81
81
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
82
- * @req REQ-MAINT-REPORT - CLI surface for human-readable maintenance reports
83
- * @req REQ-MAINT-SAFE - Support machine-readable formats for safe automation
82
+ * @req REQ-MAINT-CLI - CLI surface for human-readable maintenance reports
83
+ * @req REQ-MAINT-CLI - Support machine-readable formats for safe automation
84
84
  * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
85
- * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-REPORT REQ-MAINT-SAFE
85
+ * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI REQ-MAINT-CLI
86
86
  */
87
87
  function handleReport(normalized) {
88
88
  const flags = (0, flags_1.parseFlags)(normalized);
@@ -109,7 +109,7 @@ function handleReport(normalized) {
109
109
  /**
110
110
  * Handle dry-run mode for update command
111
111
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
112
- * @req REQ-MAINT-SAFE
112
+ * @req REQ-MAINT-CLI
113
113
  */
114
114
  function handleUpdateDryRun(root, from, to, flags) {
115
115
  const options = flags.ignorePatterns
@@ -137,8 +137,8 @@ function handleUpdateDryRun(root, from, to, flags) {
137
137
  * Handle the `update` subcommand to rewrite story annotation references.
138
138
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
139
139
  * @req REQ-MAINT-UPDATE - CLI surface for updating annotation references
140
- * @req REQ-MAINT-SAFE - Provide dry-run mode and explicit parameter checks
141
- * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-UPDATE REQ-MAINT-SAFE
140
+ * @req REQ-MAINT-CLI - Provide dry-run mode and explicit parameter checks
141
+ * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-UPDATE REQ-MAINT-CLI
142
142
  */
143
143
  function handleUpdate(normalized) {
144
144
  const flags = (0, flags_1.parseFlags)(normalized);
@@ -2,7 +2,7 @@ import { GetAllFilesOptions } from "./utils";
2
2
  /**
3
3
  * Detect stale annotation references that point to moved or deleted story files
4
4
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
5
- * @req REQ-MAINT-DETECT - Detect stale annotation references
5
+ * @req REQ-MAINT-CLI - Detect stale annotation references
6
6
  * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
7
7
  * @param codebasePath Path to the codebase root, treated as a workspace root and resolved against process.cwd().
8
8
  * @param options Optional configuration including ESLint ignore patterns
@@ -41,7 +41,7 @@ const storyReferenceUtils_1 = require("../utils/storyReferenceUtils");
41
41
  /**
42
42
  * Detect stale annotation references that point to moved or deleted story files
43
43
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
44
- * @req REQ-MAINT-DETECT - Detect stale annotation references
44
+ * @req REQ-MAINT-CLI - Detect stale annotation references
45
45
  * @req REQ-MAINT-UPDATE - Integrate with ESLint configuration
46
46
  * @param codebasePath Path to the codebase root, treated as a workspace root and resolved against process.cwd().
47
47
  * @param options Optional configuration including ESLint ignore patterns
@@ -50,24 +50,24 @@ const storyReferenceUtils_1 = require("../utils/storyReferenceUtils");
50
50
  function detectStaleAnnotations(codebasePath, options) {
51
51
  const cwd = process.cwd();
52
52
  // @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
53
- // @req REQ-MAINT-DETECT - Treat codebasePath as a workspace root resolved from process.cwd()
53
+ // @req REQ-MAINT-CLI - Treat codebasePath as a workspace root resolved from process.cwd()
54
54
  const workspaceRoot = path.resolve(cwd, codebasePath);
55
55
  // @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
56
- // @req REQ-MAINT-DETECT - Return empty result if workspaceRoot does not exist or is not a directory
56
+ // @req REQ-MAINT-CLI - Return empty result if workspaceRoot does not exist or is not a directory
57
57
  if (!fs.existsSync(workspaceRoot) ||
58
58
  !fs.statSync(workspaceRoot).isDirectory()) {
59
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
60
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE
61
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
59
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
60
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
61
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
62
62
  return [];
63
63
  }
64
64
  const stale = new Set();
65
65
  // @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
66
- // @req REQ-MAINT-DETECT - Iterate over all files in the isolated workspace root
66
+ // @req REQ-MAINT-CLI - Iterate over all files in the isolated workspace root
67
67
  // @req REQ-MAINT-UPDATE - Apply ESLint ignore patterns during file discovery
68
68
  const files = (0, utils_1.getAllFiles)(workspaceRoot, options);
69
69
  // @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
70
- // @req REQ-MAINT-DETECT - Loop over each workspace file to inspect its @story annotations
70
+ // @req REQ-MAINT-CLI - Loop over each workspace file to inspect its @story annotations
71
71
  for (const file of files) {
72
72
  processFileForStaleAnnotations(file, workspaceRoot, cwd, stale);
73
73
  }
@@ -75,88 +75,88 @@ function detectStaleAnnotations(codebasePath, options) {
75
75
  }
76
76
  /**
77
77
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
78
- * @req REQ-MAINT-DETECT - Process individual files to detect stale @story annotations
78
+ * @req REQ-MAINT-CLI - Process individual files to detect stale @story annotations
79
79
  */
80
80
  function processFileForStaleAnnotations(file, workspaceRoot, cwd, stale) {
81
81
  let content;
82
82
  // @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
83
- // @req REQ-MAINT-DETECT - Handle file read errors gracefully
83
+ // @req REQ-MAINT-CLI - Handle file read errors gracefully
84
84
  try {
85
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
85
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
86
86
  content = fs.readFileSync(file, "utf8");
87
87
  }
88
88
  catch {
89
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
90
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE
89
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
90
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
91
91
  return;
92
92
  }
93
93
  const regex = /@story\s+([^\s]+)/g;
94
94
  let match;
95
95
  // @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
96
- // @req REQ-MAINT-DETECT - Iterate over regex matches for @story annotations
96
+ // @req REQ-MAINT-CLI - Iterate over regex matches for @story annotations
97
97
  while ((match = regex.exec(content)) !== null) {
98
98
  handleStoryMatch(match[1], workspaceRoot, cwd, stale);
99
99
  }
100
100
  }
101
101
  /**
102
102
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
103
- * @req REQ-MAINT-DETECT REQ-SECURITY-VALIDATION - Handle individual @story matches within a file
103
+ * @req REQ-MAINT-CLI REQ-SECURITY-VALIDATION - Handle individual @story matches within a file
104
104
  */
105
105
  function handleStoryMatch(storyPath, workspaceRoot, cwd, stale) {
106
106
  // @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
107
- // @req REQ-MAINT-DETECT REQ-SECURITY-VALIDATION - Skip traversal/absolute-unsafe or invalid-extension story paths before any filesystem or boundary checks
107
+ // @req REQ-MAINT-CLI REQ-SECURITY-VALIDATION - Skip traversal/absolute-unsafe or invalid-extension story paths before any filesystem or boundary checks
108
108
  if ((0, storyReferenceUtils_1.isUnsafeStoryPath)(storyPath)) {
109
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
109
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
110
110
  return;
111
111
  }
112
112
  // @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
113
- // @req REQ-MAINT-DETECT - Compute project and codebase candidates relative to cwd and workspaceRoot
113
+ // @req REQ-MAINT-CLI - Compute project and codebase candidates relative to cwd and workspaceRoot
114
114
  const storyProjectCandidate = path.resolve(cwd, storyPath);
115
115
  const storyCodebaseCandidate = path.resolve(workspaceRoot, storyPath);
116
116
  // @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
117
- // @req REQ-MAINT-DETECT - Enforce workspaceRoot as the project boundary for resolved story paths
117
+ // @req REQ-MAINT-CLI - Enforce workspaceRoot as the project boundary for resolved story paths
118
118
  const inProjectCandidates = getInProjectCandidates(storyProjectCandidate, storyCodebaseCandidate, workspaceRoot);
119
119
  // If both candidates are out-of-project, do not mark as stale and skip FS checks
120
120
  if (inProjectCandidates.length === 0) {
121
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
121
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
122
122
  return;
123
123
  }
124
124
  // @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
125
- // @req REQ-MAINT-DETECT - Only check existence for in-project candidates
125
+ // @req REQ-MAINT-CLI - Only check existence for in-project candidates
126
126
  const anyExists = anyInProjectCandidateExists(inProjectCandidates);
127
127
  // @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
128
- // @req REQ-MAINT-DETECT - Mark story as stale if any in-project candidate exists conceptually but none exist on disk
128
+ // @req REQ-MAINT-CLI - Mark story as stale if any in-project candidate exists conceptually but none exist on disk
129
129
  if (!anyExists) {
130
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
130
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
131
131
  stale.add(storyPath);
132
132
  }
133
133
  }
134
134
  /**
135
135
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
136
- * @req REQ-MAINT-DETECT - Enforce project boundary and return in-project candidates
136
+ * @req REQ-MAINT-CLI - Enforce project boundary and return in-project candidates
137
137
  */
138
138
  function getInProjectCandidates(storyProjectCandidate, storyCodebaseCandidate, workspaceRoot) {
139
139
  let projectBoundary;
140
140
  let codebaseBoundary;
141
141
  try {
142
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
142
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
143
143
  projectBoundary = (0, storyReferenceUtils_1.enforceProjectBoundary)(storyProjectCandidate, workspaceRoot);
144
144
  }
145
145
  catch {
146
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
147
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE
146
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
147
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
148
148
  projectBoundary = {
149
149
  isWithinProject: false,
150
150
  candidate: storyProjectCandidate,
151
151
  };
152
152
  }
153
153
  try {
154
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
154
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
155
155
  codebaseBoundary = (0, storyReferenceUtils_1.enforceProjectBoundary)(storyCodebaseCandidate, workspaceRoot);
156
156
  }
157
157
  catch {
158
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
159
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE
158
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
159
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
160
160
  codebaseBoundary = {
161
161
  isWithinProject: false,
162
162
  candidate: storyCodebaseCandidate,
@@ -164,28 +164,28 @@ function getInProjectCandidates(storyProjectCandidate, storyCodebaseCandidate, w
164
164
  }
165
165
  const inProjectCandidates = [];
166
166
  if (projectBoundary.isWithinProject) {
167
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
167
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
168
168
  inProjectCandidates.push(projectBoundary.candidate);
169
169
  }
170
170
  if (codebaseBoundary.isWithinProject) {
171
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
171
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
172
172
  inProjectCandidates.push(codebaseBoundary.candidate);
173
173
  }
174
174
  return inProjectCandidates;
175
175
  }
176
176
  /**
177
177
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
178
- * @req REQ-MAINT-DETECT - Check on-disk existence of in-project candidates
178
+ * @req REQ-MAINT-CLI - Check on-disk existence of in-project candidates
179
179
  */
180
180
  function anyInProjectCandidateExists(inProjectCandidates) {
181
181
  return inProjectCandidates.some(
182
182
  /**
183
- * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT REQ-MAINT-SAFE
183
+ * @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI REQ-MAINT-CLI
184
184
  */
185
185
  (p) => {
186
186
  const exists = fs.existsSync(p);
187
187
  if (!exists) {
188
- // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE
188
+ // @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-CLI
189
189
  }
190
190
  return exists;
191
191
  });
@@ -4,7 +4,7 @@
4
4
  * Separates Node/V8 internals from the actual subcommand and its arguments.
5
5
  *
6
6
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
7
- * @req REQ-MAINT-SAFE - Provide predictable, minimal argument parsing
7
+ * @req REQ-MAINT-CLI - Provide predictable, minimal argument parsing
8
8
  */
9
9
  export interface ParsedCliInput {
10
10
  /**
@@ -39,7 +39,7 @@ export interface ParsedCliInput {
39
39
  * @returns ParsedCliInput with node, script, subcommand, and remaining args.
40
40
  *
41
41
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
42
- * @req REQ-MAINT-SAFE - Provide predictable, minimal argument parsing
42
+ * @req REQ-MAINT-CLI - Provide predictable, minimal argument parsing
43
43
  */
44
44
  export declare function parseCliInput(argv: string[]): ParsedCliInput;
45
45
  /**
@@ -49,7 +49,7 @@ export declare function parseCliInput(argv: string[]): ParsedCliInput;
49
49
  * subcommand name and its raw arguments for further flag parsing.
50
50
  *
51
51
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
52
- * @req REQ-MAINT-SAFE - Provide predictable, minimal argument parsing
52
+ * @req REQ-MAINT-CLI - Provide predictable, minimal argument parsing
53
53
  */
54
54
  export interface NormalizedCliArgs {
55
55
  /**
@@ -73,7 +73,7 @@ export interface NormalizedCliArgs {
73
73
  * @returns NormalizedCliArgs with subcommand and remaining args.
74
74
  *
75
75
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
76
- * @req REQ-MAINT-SAFE - Provide predictable, minimal argument parsing
76
+ * @req REQ-MAINT-CLI - Provide predictable, minimal argument parsing
77
77
  */
78
78
  export declare function normalizeCliArgs(rawArgv: string[]): NormalizedCliArgs;
79
79
  export interface ParsedFlags {
@@ -95,6 +95,6 @@ export interface ParsedFlags {
95
95
  * @returns ParsedFlags with defaults applied and any recognized flags set.
96
96
  *
97
97
  * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
98
- * @req REQ-MAINT-SAFE - Provide predictable, minimal argument parsing
98
+ * @req REQ-MAINT-CLI - Provide predictable, minimal argument parsing
99
99
  */
100
100
  export declare function parseFlags(normalized: NormalizedCliArgs): ParsedFlags;