@paths.design/caws-cli 8.0.0 → 8.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.
Files changed (149) hide show
  1. package/dist/budget-derivation.d.ts +74 -0
  2. package/dist/budget-derivation.d.ts.map +1 -0
  3. package/dist/cicd-optimizer.d.ts +142 -0
  4. package/dist/cicd-optimizer.d.ts.map +1 -0
  5. package/dist/commands/archive.d.ts +51 -0
  6. package/dist/commands/archive.d.ts.map +1 -0
  7. package/dist/commands/archive.js +114 -6
  8. package/dist/commands/burnup.d.ts +6 -0
  9. package/dist/commands/burnup.d.ts.map +1 -0
  10. package/dist/commands/burnup.js +109 -10
  11. package/dist/commands/diagnose.d.ts +52 -0
  12. package/dist/commands/diagnose.d.ts.map +1 -0
  13. package/dist/commands/diagnose.js +1 -1
  14. package/dist/commands/evaluate.d.ts +8 -0
  15. package/dist/commands/evaluate.d.ts.map +1 -0
  16. package/dist/commands/init.d.ts +5 -0
  17. package/dist/commands/init.d.ts.map +1 -0
  18. package/dist/commands/iterate.d.ts +8 -0
  19. package/dist/commands/iterate.d.ts.map +1 -0
  20. package/dist/commands/mode.d.ts +24 -0
  21. package/dist/commands/mode.d.ts.map +1 -0
  22. package/dist/commands/mode.js +24 -14
  23. package/dist/commands/plan.d.ts +49 -0
  24. package/dist/commands/plan.d.ts.map +1 -0
  25. package/dist/commands/provenance.d.ts +32 -0
  26. package/dist/commands/provenance.d.ts.map +1 -0
  27. package/dist/commands/provenance.js +216 -93
  28. package/dist/commands/quality-gates.d.ts +6 -0
  29. package/dist/commands/quality-gates.d.ts.map +1 -0
  30. package/dist/commands/quality-gates.js +82 -3
  31. package/dist/commands/quality-monitor.d.ts +17 -0
  32. package/dist/commands/quality-monitor.d.ts.map +1 -0
  33. package/dist/commands/specs.d.ts +71 -0
  34. package/dist/commands/specs.d.ts.map +1 -0
  35. package/dist/commands/specs.js +184 -6
  36. package/dist/commands/status.d.ts +44 -0
  37. package/dist/commands/status.d.ts.map +1 -0
  38. package/dist/commands/status.js +134 -10
  39. package/dist/commands/templates.d.ts +74 -0
  40. package/dist/commands/templates.d.ts.map +1 -0
  41. package/dist/commands/templates.js +2 -2
  42. package/dist/commands/tool.d.ts +13 -0
  43. package/dist/commands/tool.d.ts.map +1 -0
  44. package/dist/commands/troubleshoot.d.ts +8 -0
  45. package/dist/commands/troubleshoot.d.ts.map +1 -0
  46. package/dist/commands/tutorial.d.ts +55 -0
  47. package/dist/commands/tutorial.d.ts.map +1 -0
  48. package/dist/commands/validate.d.ts +15 -0
  49. package/dist/commands/validate.d.ts.map +1 -0
  50. package/dist/commands/waivers.d.ts +8 -0
  51. package/dist/commands/waivers.d.ts.map +1 -0
  52. package/dist/commands/workflow.d.ts +85 -0
  53. package/dist/commands/workflow.d.ts.map +1 -0
  54. package/dist/config/index.d.ts +29 -0
  55. package/dist/config/index.d.ts.map +1 -0
  56. package/dist/config/modes.d.ts +225 -0
  57. package/dist/config/modes.d.ts.map +1 -0
  58. package/dist/constants/spec-types.d.ts +41 -0
  59. package/dist/constants/spec-types.d.ts.map +1 -0
  60. package/dist/error-handler.d.ts +164 -0
  61. package/dist/error-handler.d.ts.map +1 -0
  62. package/dist/error-handler.js +6 -98
  63. package/dist/generators/jest-config-generator.js +242 -0
  64. package/dist/generators/jest-config.d.ts +32 -0
  65. package/dist/generators/jest-config.d.ts.map +1 -0
  66. package/dist/generators/working-spec.d.ts +13 -0
  67. package/dist/generators/working-spec.d.ts.map +1 -0
  68. package/dist/index-new.d.ts +5 -0
  69. package/dist/index-new.d.ts.map +1 -0
  70. package/dist/index-new.js +317 -0
  71. package/dist/index.d.ts +5 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +14 -7
  74. package/dist/index.js.backup +4711 -0
  75. package/dist/minimal-cli.d.ts +3 -0
  76. package/dist/minimal-cli.d.ts.map +1 -0
  77. package/dist/minimal-cli.js +3 -1
  78. package/dist/policy/PolicyManager.d.ts +104 -0
  79. package/dist/policy/PolicyManager.d.ts.map +1 -0
  80. package/dist/scaffold/claude-hooks.js +316 -0
  81. package/dist/scaffold/cursor-hooks.d.ts +7 -0
  82. package/dist/scaffold/cursor-hooks.d.ts.map +1 -0
  83. package/dist/scaffold/git-hooks.d.ts +38 -0
  84. package/dist/scaffold/git-hooks.d.ts.map +1 -0
  85. package/dist/scaffold/index.d.ts +15 -0
  86. package/dist/scaffold/index.d.ts.map +1 -0
  87. package/dist/scaffold/index.js +18 -0
  88. package/dist/spec/SpecFileManager.d.ts +146 -0
  89. package/dist/spec/SpecFileManager.d.ts.map +1 -0
  90. package/dist/templates/.claude/README.md +190 -0
  91. package/dist/templates/.claude/hooks/audit.sh +96 -0
  92. package/dist/templates/.claude/hooks/block-dangerous.sh +90 -0
  93. package/dist/templates/.claude/hooks/naming-check.sh +97 -0
  94. package/dist/templates/.claude/hooks/quality-check.sh +68 -0
  95. package/dist/templates/.claude/hooks/scan-secrets.sh +85 -0
  96. package/dist/templates/.claude/hooks/scope-guard.sh +105 -0
  97. package/dist/templates/.claude/hooks/validate-spec.sh +76 -0
  98. package/dist/templates/.claude/settings.json +95 -0
  99. package/dist/test-analysis.d.ts +182 -0
  100. package/dist/test-analysis.d.ts.map +1 -0
  101. package/dist/test-analysis.js +203 -10
  102. package/dist/tool-interface.d.ts +236 -0
  103. package/dist/tool-interface.d.ts.map +1 -0
  104. package/dist/tool-loader.d.ts +77 -0
  105. package/dist/tool-loader.d.ts.map +1 -0
  106. package/dist/tool-validator.d.ts +72 -0
  107. package/dist/tool-validator.d.ts.map +1 -0
  108. package/dist/utils/async-utils.d.ts +73 -0
  109. package/dist/utils/async-utils.d.ts.map +1 -0
  110. package/dist/utils/command-wrapper.d.ts +66 -0
  111. package/dist/utils/command-wrapper.d.ts.map +1 -0
  112. package/dist/utils/detection.d.ts +14 -0
  113. package/dist/utils/detection.d.ts.map +1 -0
  114. package/dist/utils/error-categories.js +210 -0
  115. package/dist/utils/finalization.d.ts +17 -0
  116. package/dist/utils/finalization.d.ts.map +1 -0
  117. package/dist/utils/git-lock.d.ts +13 -0
  118. package/dist/utils/git-lock.d.ts.map +1 -0
  119. package/dist/utils/gitignore-updater.d.ts +39 -0
  120. package/dist/utils/gitignore-updater.d.ts.map +1 -0
  121. package/dist/utils/project-analysis.d.ts +34 -0
  122. package/dist/utils/project-analysis.d.ts.map +1 -0
  123. package/dist/utils/promise-utils.d.ts +30 -0
  124. package/dist/utils/promise-utils.d.ts.map +1 -0
  125. package/dist/utils/quality-gates-utils.js +402 -0
  126. package/dist/utils/quality-gates.d.ts +49 -0
  127. package/dist/utils/quality-gates.d.ts.map +1 -0
  128. package/dist/utils/spec-resolver.d.ts +80 -0
  129. package/dist/utils/spec-resolver.d.ts.map +1 -0
  130. package/dist/utils/typescript-detector.d.ts +63 -0
  131. package/dist/utils/typescript-detector.d.ts.map +1 -0
  132. package/dist/utils/typescript-detector.js +36 -90
  133. package/dist/utils/yaml-validation.d.ts +32 -0
  134. package/dist/utils/yaml-validation.d.ts.map +1 -0
  135. package/dist/validation/spec-validation.d.ts +43 -0
  136. package/dist/validation/spec-validation.d.ts.map +1 -0
  137. package/dist/validation/spec-validation.js +59 -6
  138. package/dist/waivers-manager.d.ts +167 -0
  139. package/dist/waivers-manager.d.ts.map +1 -0
  140. package/package.json +5 -3
  141. package/templates/.claude/README.md +190 -0
  142. package/templates/.claude/hooks/audit.sh +96 -0
  143. package/templates/.claude/hooks/block-dangerous.sh +90 -0
  144. package/templates/.claude/hooks/naming-check.sh +97 -0
  145. package/templates/.claude/hooks/quality-check.sh +68 -0
  146. package/templates/.claude/hooks/scan-secrets.sh +85 -0
  147. package/templates/.claude/hooks/scope-guard.sh +105 -0
  148. package/templates/.claude/hooks/validate-spec.sh +76 -0
  149. package/templates/.claude/settings.json +95 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Derive budget for a working spec based on policy and waivers
3
+ * Enhanced to use PolicyManager for caching
4
+ * @param {Object} spec - Working spec object
5
+ * @param {string} projectRoot - Project root directory
6
+ * @param {Object} options - Derivation options
7
+ * @param {boolean} options.useCache - Use cached policy (default: true)
8
+ * @returns {Object} Derived budget with baseline and effective limits
9
+ */
10
+ export function deriveBudget(spec: any, projectRoot?: string, options?: {
11
+ useCache: boolean;
12
+ }): any;
13
+ /**
14
+ * Load a waiver by ID
15
+ * Enhanced with structure validation and detailed error reporting
16
+ * @param {string} waiverId - Waiver ID (e.g., WV-0001)
17
+ * @param {string} projectRoot - Project root directory
18
+ * @returns {Object|null} Waiver object or null if not found
19
+ */
20
+ export function loadWaiver(waiverId: string, projectRoot: string): any | null;
21
+ /**
22
+ * Check if a waiver is currently valid
23
+ * Enhanced with proper expiry and approval validation
24
+ * @param {Object} waiver - Waiver object
25
+ * @param {Object} policy - Policy configuration (optional)
26
+ * @returns {boolean} Whether waiver is valid and active
27
+ */
28
+ export function isWaiverValid(waiver: any, policy?: any): boolean;
29
+ /**
30
+ * Check if current changes exceed derived budget
31
+ * @param {Object} derivedBudget - Budget from deriveBudget()
32
+ * @param {Object} currentStats - Current change statistics
33
+ * @returns {Object} Budget check result
34
+ */
35
+ export function checkBudgetCompliance(derivedBudget: any, currentStats: any): any;
36
+ /**
37
+ * Generate burn-up report for scope visibility
38
+ * Enhanced with utilization metrics and warnings
39
+ * @param {Object} derivedBudget - Budget from deriveBudget()
40
+ * @param {Object} currentStats - Current change statistics
41
+ * @returns {string} Human-readable burn-up report
42
+ */
43
+ export function generateBurnupReport(derivedBudget: any, currentStats: any): string;
44
+ /**
45
+ * Calculate budget utilization percentages
46
+ * @param {Object} budgetCompliance - Budget compliance result
47
+ * @returns {Object} Utilization percentages
48
+ */
49
+ export function calculateBudgetUtilization(budgetCompliance: any): any;
50
+ /**
51
+ * Check if changes are approaching budget limit
52
+ * @param {Object} budgetCompliance - Budget compliance result
53
+ * @param {number} threshold - Warning threshold (default 80)
54
+ * @returns {boolean} Whether approaching limit
55
+ */
56
+ export function isApproachingBudgetLimit(budgetCompliance: any, threshold?: number): boolean;
57
+ /**
58
+ * Validate policy structure and content
59
+ * @param {Object} policy - Policy object from policy.yaml
60
+ * @throws {Error} If policy is invalid
61
+ */
62
+ export function validatePolicy(policy: any): void;
63
+ /**
64
+ * Get default policy as fallback
65
+ * @returns {Object} Default CAWS policy
66
+ */
67
+ export function getDefaultPolicy(): any;
68
+ /**
69
+ * Validate waiver document structure
70
+ * @param {Object} waiver - Waiver document to validate
71
+ * @throws {Error} If waiver structure is invalid
72
+ */
73
+ export function validateWaiverStructure(waiver: any): void;
74
+ //# sourceMappingURL=budget-derivation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"budget-derivation.d.ts","sourceRoot":"","sources":["../src/budget-derivation.js"],"names":[],"mappings":"AA8JA;;;;;;;;GAQG;AACH,sDALW,MAAM,YAEd;IAAyB,QAAQ,EAAzB,OAAO;CACf,OAgGF;AA4FD;;;;;;GAMG;AACH,qCAJW,MAAM,eACN,MAAM,GACJ,MAAO,IAAI,CAuCvB;AAED;;;;;;GAMG;AACH,0DAFa,OAAO,CAgDnB;AAED;;;;;GAKG;AACH,kFA8BC;AAqCD;;;;;;GAMG;AACH,6EAFa,MAAM,CA8ClB;AAtFD;;;;GAIG;AACH,uEAiBC;AAED;;;;;GAKG;AACH,4EAHW,MAAM,GACJ,OAAO,CAKnB;AAjgBD;;;;GAIG;AACH,kDA+FC;AAED;;;GAGG;AACH,wCAsCC;AA2GD;;;;GAIG;AACH,2DAmFC"}
@@ -0,0 +1,142 @@
1
+ export = CICDOptimizer;
2
+ declare class CICDOptimizer {
3
+ constructor(options?: {});
4
+ projectRoot: any;
5
+ cacheDir: string;
6
+ optimizationConfig: string;
7
+ /**
8
+ * Analyze project and generate CI/CD optimization recommendations
9
+ */
10
+ analyzeProject(specPath?: string): Promise<{
11
+ project_tier: string;
12
+ recommended_optimizations: any[];
13
+ cache_strategy: {};
14
+ parallel_groups: any[];
15
+ conditional_execution: {};
16
+ estimated_savings: {};
17
+ }>;
18
+ /**
19
+ * Generate tier-based conditional execution rules
20
+ */
21
+ generateConditionalExecutionRules(tier: any): {
22
+ coverage_required: boolean;
23
+ mutation_required: boolean;
24
+ contract_testing: boolean;
25
+ accessibility_check: boolean;
26
+ performance_budget: boolean;
27
+ security_scan: boolean;
28
+ lint_strict: boolean;
29
+ };
30
+ /**
31
+ * Analyze what optimizations are beneficial for this tier
32
+ */
33
+ analyzeOptimizationOpportunities(tier: any): Promise<{
34
+ type: string;
35
+ description: string;
36
+ impact: string;
37
+ effort: string;
38
+ }[]>;
39
+ /**
40
+ * Generate intelligent caching strategy
41
+ */
42
+ generateCacheStrategy(): Promise<{
43
+ node_modules: {
44
+ key: string;
45
+ paths: string[];
46
+ restore_keys: string[];
47
+ };
48
+ build_artifacts: {
49
+ key: string;
50
+ paths: string[];
51
+ restore_keys: any[];
52
+ };
53
+ test_cache: {
54
+ key: string;
55
+ paths: string[];
56
+ restore_keys: string[];
57
+ };
58
+ }>;
59
+ /**
60
+ * Create parallel execution groups for quality gates
61
+ */
62
+ createParallelGroups(): Promise<{
63
+ name: string;
64
+ description: string;
65
+ jobs: string[];
66
+ max_parallel: number;
67
+ timeout: number;
68
+ }[]>;
69
+ /**
70
+ * Analyze changed files to determine what tests to run
71
+ */
72
+ analyzeChangedFiles(changedFiles?: any[]): Promise<{
73
+ unit: any[];
74
+ integration: any[];
75
+ contract: any[];
76
+ e2e: any[];
77
+ }>;
78
+ /**
79
+ * Estimate time savings from optimizations
80
+ */
81
+ estimateTimeSavings(analysis: any): {
82
+ original_minutes: any;
83
+ optimized_minutes: number;
84
+ savings_percent: number;
85
+ monthly_savings_hours: number;
86
+ };
87
+ /**
88
+ * Generate optimized CI/CD configuration
89
+ */
90
+ generateOptimizedConfig(platform?: string): Promise<string | {
91
+ name: string;
92
+ on: {
93
+ push: {
94
+ branches: string[];
95
+ };
96
+ pull_request: {
97
+ branches: string[];
98
+ };
99
+ };
100
+ jobs: {};
101
+ } | {
102
+ stages: string[];
103
+ cache: {
104
+ key: string;
105
+ paths: string[];
106
+ };
107
+ }>;
108
+ /**
109
+ * Generate optimized GitHub Actions workflow
110
+ */
111
+ generateGitHubActionsConfig(analysis: any): {
112
+ name: string;
113
+ on: {
114
+ push: {
115
+ branches: string[];
116
+ };
117
+ pull_request: {
118
+ branches: string[];
119
+ };
120
+ };
121
+ jobs: {};
122
+ };
123
+ /**
124
+ * Generate GitLab CI configuration
125
+ */
126
+ generateGitLabCIConfig(analysis: any): {
127
+ stages: string[];
128
+ cache: {
129
+ key: string;
130
+ paths: string[];
131
+ };
132
+ };
133
+ /**
134
+ * Generate Jenkins pipeline configuration
135
+ */
136
+ generateJenkinsConfig(analysis: any): string;
137
+ /**
138
+ * Create hash for cache invalidation
139
+ */
140
+ createCacheHash(files: any): string;
141
+ }
142
+ //# sourceMappingURL=cicd-optimizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cicd-optimizer.d.ts","sourceRoot":"","sources":["../src/cicd-optimizer.js"],"names":[],"mappings":";AAaA;IACE,0BASC;IARC,iBAAuD;IACvD,iBAA6D;IAC7D,2BAAkF;IAQpF;;OAEG;IACH;;;;;;;OAyCC;IAED;;OAEG;IACH;;;;;;;;MAyBC;IAED;;OAEG;IACH;;;;;SA6CC;IAED;;OAEG;IACH;;;;;;;;;;;;;;;;OA8CC;IAED;;OAEG;IACH;;;;;;SA0BC;IAED;;OAEG;IACH;;;;;OA2BC;IAED;;OAEG;IACH;;;;;MA+BC;IAED;;OAEG;IACH;;;;;;;;;;;;;;;;;OAYC;IAED;;OAEG;IACH;;;;;;;;;;;MA4EC;IAED;;OAEG;IACH;;;;;;MAiCC;IAED;;OAEG;IACH,6CA+CC;IAED;;OAEG;IACH,oCAQC;CACF"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Archive command handler
3
+ * @param {string} changeId - Change identifier to archive
4
+ * @param {Object} options - Command options
5
+ */
6
+ export function archiveCommand(changeId: string, options?: any): Promise<any>;
7
+ /**
8
+ * Load change folder structure
9
+ * @param {string} changeId - Change identifier
10
+ * @returns {Promise<Object|null>} Change data or null
11
+ */
12
+ export function loadChange(changeId: string): Promise<any | null>;
13
+ /**
14
+ * Validate all acceptance criteria are met
15
+ * @param {Object} workingSpec - Working specification
16
+ * @returns {Promise<Object>} Validation result
17
+ */
18
+ export function validateAcceptanceCriteria(workingSpec: any): Promise<any>;
19
+ /**
20
+ * Validate change meets quality gates
21
+ * Runs the actual quality gates runner and checks for violations
22
+ * @param {string} changeId - Change identifier
23
+ * @returns {Promise<Object>} Quality gate result
24
+ */
25
+ export function validateQualityGates(changeId: string): Promise<any>;
26
+ /**
27
+ * Generate change summary for archival
28
+ * @param {Object} change - Change data
29
+ * @returns {Promise<string>} Summary text
30
+ */
31
+ export function generateChangeSummary(change: any): Promise<string>;
32
+ /**
33
+ * Archive change folder to archive directory
34
+ * @param {Object} change - Change data
35
+ * @returns {Promise<void>}
36
+ */
37
+ export function archiveChange(change: any): Promise<void>;
38
+ /**
39
+ * Update provenance with completion
40
+ * @param {Object} change - Change data
41
+ * @returns {Promise<void>}
42
+ */
43
+ export function updateProvenance(change: any): Promise<void>;
44
+ /**
45
+ * Display archive results
46
+ * @param {Object} change - Change data
47
+ * @param {Object} validation - Validation result
48
+ * @param {Object} qualityGates - Quality gates result
49
+ */
50
+ export function displayArchiveResults(change: any, validation: any, qualityGates: any): void;
51
+ //# sourceMappingURL=archive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../src/commands/archive.js"],"names":[],"mappings":"AA0VA;;;;GAIG;AACH,yCAHW,MAAM,+BAqGhB;AAjbD;;;;GAIG;AACH,qCAHW,MAAM,GACJ,OAAO,CAAC,MAAO,IAAI,CAAC,CAgChC;AAED;;;;GAIG;AACH,8DAFa,OAAO,KAAQ,CA8B3B;AAED;;;;;GAKG;AACH,+CAHW,MAAM,GACJ,OAAO,KAAQ,CAmH3B;AAED;;;;GAIG;AACH,oDAFa,OAAO,CAAC,MAAM,CAAC,CAgC3B;AAED;;;;GAIG;AACH,4CAFa,OAAO,CAAC,IAAI,CAAC,CAazB;AAED;;;;GAIG;AACH,+CAFa,OAAO,CAAC,IAAI,CAAC,CAoCzB;AAED;;;;;GAKG;AACH,6FAiCC"}
@@ -8,6 +8,7 @@ const fs = require('fs-extra');
8
8
  const path = require('path');
9
9
  const yaml = require('js-yaml');
10
10
  const chalk = require('chalk');
11
+ const { execSync } = require('child_process');
11
12
  const { safeAsync, outputResult } = require('../error-handler');
12
13
 
13
14
  // Import spec resolution system
@@ -87,16 +88,123 @@ async function validateAcceptanceCriteria(workingSpec) {
87
88
 
88
89
  /**
89
90
  * Validate change meets quality gates
91
+ * Runs the actual quality gates runner and checks for violations
90
92
  * @param {string} changeId - Change identifier
91
93
  * @returns {Promise<Object>} Quality gate result
92
94
  */
93
95
  async function validateQualityGates(_changeId) {
94
- // For now, return success - in full implementation would run actual gate checks
95
- return {
96
- valid: true,
97
- message: 'Quality gates passed (implementation pending)',
98
- gates: ['test-coverage', 'linting', 'type-checking'],
99
- };
96
+ const gates = [];
97
+ const violations = [];
98
+ const warnings = [];
99
+
100
+ try {
101
+ // Try to run the quality gates runner
102
+ const qualityGatesPath = path.join(
103
+ __dirname,
104
+ '..',
105
+ '..',
106
+ '..',
107
+ 'quality-gates',
108
+ 'run-quality-gates.mjs'
109
+ );
110
+
111
+ // Check if quality gates runner exists
112
+ if (await fs.pathExists(qualityGatesPath)) {
113
+ try {
114
+ // Run quality gates in CI mode (checks all files, not just staged)
115
+ const result = execSync(`node "${qualityGatesPath}" --context=ci --json 2>&1`, {
116
+ encoding: 'utf8',
117
+ timeout: 60000, // 60 second timeout
118
+ cwd: process.cwd(),
119
+ });
120
+
121
+ // Try to parse JSON output
122
+ try {
123
+ const jsonMatch = result.match(/\{[\s\S]*\}$/);
124
+ if (jsonMatch) {
125
+ const parsed = JSON.parse(jsonMatch[0]);
126
+ if (parsed.violations) {
127
+ violations.push(...parsed.violations);
128
+ }
129
+ if (parsed.warnings) {
130
+ warnings.push(...parsed.warnings);
131
+ }
132
+ gates.push(...(parsed.gates || []));
133
+ }
134
+ } catch {
135
+ // JSON parsing failed, check for error indicators in output
136
+ if (result.includes('❌') || result.includes('FAIL')) {
137
+ violations.push({ message: 'Quality gates reported failures', output: result });
138
+ }
139
+ }
140
+ } catch (execError) {
141
+ // Command failed - check exit code and output
142
+ if (execError.status !== 0) {
143
+ const output = execError.stdout || execError.message;
144
+ if (output.includes('violations') || output.includes('❌')) {
145
+ violations.push({ message: 'Quality gates failed', output: output.substring(0, 500) });
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ // Also check for active waivers that might cover violations
152
+ const waiversPath = path.join(process.cwd(), '.caws', 'waivers', 'active-waivers.yaml');
153
+ let hasActiveWaivers = false;
154
+ if (await fs.pathExists(waiversPath)) {
155
+ const waiversContent = await fs.readFile(waiversPath, 'utf8');
156
+ const waivers = yaml.load(waiversContent);
157
+ if (waivers && waivers.waivers) {
158
+ const activeWaiverCount = Object.keys(waivers.waivers).length;
159
+ if (activeWaiverCount > 0) {
160
+ hasActiveWaivers = true;
161
+ gates.push(`${activeWaiverCount} active waiver(s)`);
162
+ }
163
+ }
164
+ }
165
+
166
+ // Determine overall validity
167
+ const hasBlockingViolations = violations.some(
168
+ (v) => v.severity === 'block' || v.severity === 'fail'
169
+ );
170
+
171
+ if (violations.length === 0) {
172
+ return {
173
+ valid: true,
174
+ message: 'All quality gates passed',
175
+ gates: gates.length > 0 ? gates : ['naming', 'duplication', 'god-objects', 'hidden-todo'],
176
+ violations: [],
177
+ warnings,
178
+ };
179
+ } else if (hasActiveWaivers && !hasBlockingViolations) {
180
+ return {
181
+ valid: true,
182
+ message: `Quality gates passed with ${violations.length} waived violation(s)`,
183
+ gates,
184
+ violations,
185
+ warnings,
186
+ waived: true,
187
+ };
188
+ } else {
189
+ return {
190
+ valid: false,
191
+ message: `${violations.length} quality gate violation(s) found`,
192
+ gates,
193
+ violations,
194
+ warnings,
195
+ };
196
+ }
197
+ } catch (error) {
198
+ // If quality gates can't be run, warn but don't block
199
+ return {
200
+ valid: true,
201
+ message: `Quality gates check skipped: ${error.message}`,
202
+ gates: [],
203
+ violations: [],
204
+ warnings: [{ message: `Could not run quality gates: ${error.message}` }],
205
+ skipped: true,
206
+ };
207
+ }
100
208
  }
101
209
 
102
210
  /**
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Burn-up command handler
3
+ * @param {string} specFile - Path to spec file
4
+ */
5
+ export function burnupCommand(specFile: string): Promise<void>;
6
+ //# sourceMappingURL=burnup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"burnup.d.ts","sourceRoot":"","sources":["../../src/commands/burnup.js"],"names":[],"mappings":"AAsFA;;;GAGG;AACH,wCAFW,MAAM,iBAgGhB"}
@@ -8,9 +8,82 @@ const fs = require('fs-extra');
8
8
  const path = require('path');
9
9
  const yaml = require('js-yaml');
10
10
  const chalk = require('chalk');
11
+ const { execSync } = require('child_process');
11
12
 
12
13
  const { deriveBudget, generateBurnupReport } = require('../budget-derivation');
13
14
 
15
+ /**
16
+ * Get actual git change statistics from the repository
17
+ * Analyzes changes since the last tag or initial commit
18
+ * @param {string} specDir - Directory containing the spec file
19
+ * @returns {Object} Stats with files_changed, lines_added, lines_removed, lines_changed
20
+ */
21
+ function getGitChangeStats(specDir) {
22
+ try {
23
+ const cwd = specDir || process.cwd();
24
+
25
+ // Find the base reference - prefer last tag, fall back to first commit
26
+ let baseRef;
27
+ try {
28
+ baseRef = execSync('git describe --tags --abbrev=0 2>/dev/null', {
29
+ cwd,
30
+ encoding: 'utf8',
31
+ }).trim();
32
+ } catch {
33
+ // No tags, use first commit
34
+ try {
35
+ baseRef = execSync('git rev-list --max-parents=0 HEAD', {
36
+ cwd,
37
+ encoding: 'utf8',
38
+ }).trim();
39
+ } catch {
40
+ // Not a git repo or no commits
41
+ return null;
42
+ }
43
+ }
44
+
45
+ // Get file change count
46
+ const filesOutput = execSync(`git diff --name-only ${baseRef}..HEAD`, {
47
+ cwd,
48
+ encoding: 'utf8',
49
+ });
50
+ const filesChanged = filesOutput.trim().split('\n').filter(Boolean).length;
51
+
52
+ // Get line statistics using --numstat
53
+ const numstatOutput = execSync(`git diff --numstat ${baseRef}..HEAD`, {
54
+ cwd,
55
+ encoding: 'utf8',
56
+ });
57
+
58
+ let linesAdded = 0;
59
+ let linesRemoved = 0;
60
+
61
+ numstatOutput
62
+ .trim()
63
+ .split('\n')
64
+ .filter(Boolean)
65
+ .forEach((line) => {
66
+ const [added, removed] = line.split('\t');
67
+ // Skip binary files (shown as '-')
68
+ if (added !== '-' && removed !== '-') {
69
+ linesAdded += parseInt(added, 10) || 0;
70
+ linesRemoved += parseInt(removed, 10) || 0;
71
+ }
72
+ });
73
+
74
+ return {
75
+ files_changed: filesChanged,
76
+ lines_added: linesAdded,
77
+ lines_removed: linesRemoved,
78
+ lines_changed: linesAdded + linesRemoved,
79
+ base_ref: baseRef,
80
+ };
81
+ } catch (error) {
82
+ // Return null if git analysis fails
83
+ return null;
84
+ }
85
+ }
86
+
14
87
  /**
15
88
  * Burn-up command handler
16
89
  * @param {string} specFile - Path to spec file
@@ -32,15 +105,34 @@ async function burnupCommand(specFile) {
32
105
  // Derive budget
33
106
  const derivedBudget = deriveBudget(spec, path.dirname(specPath));
34
107
 
35
- // Mock current stats - in real implementation this would analyze actual git changes
36
- const mockStats = {
37
- files_changed: 50, // This would be calculated from actual changes
38
- lines_changed: 5000,
39
- risk_tier: spec.risk_tier,
40
- };
108
+ // Get actual git change statistics
109
+ const gitStats = getGitChangeStats(path.dirname(specPath));
110
+
111
+ let currentStats;
112
+ if (gitStats) {
113
+ currentStats = {
114
+ files_changed: gitStats.files_changed,
115
+ lines_changed: gitStats.lines_changed,
116
+ lines_added: gitStats.lines_added,
117
+ lines_removed: gitStats.lines_removed,
118
+ risk_tier: spec.risk_tier,
119
+ base_ref: gitStats.base_ref,
120
+ };
121
+ console.log(chalk.gray(` Analyzing changes since: ${gitStats.base_ref}`));
122
+ } else {
123
+ // Fallback if git analysis fails (not in a repo or no commits)
124
+ console.log(chalk.yellow(' ⚠️ Could not analyze git history, using zero values'));
125
+ currentStats = {
126
+ files_changed: 0,
127
+ lines_changed: 0,
128
+ lines_added: 0,
129
+ lines_removed: 0,
130
+ risk_tier: spec.risk_tier,
131
+ };
132
+ }
41
133
 
42
134
  // Generate report
43
- const report = generateBurnupReport(derivedBudget, mockStats);
135
+ const report = generateBurnupReport(derivedBudget, currentStats);
44
136
 
45
137
  console.log(report);
46
138
 
@@ -63,15 +155,22 @@ async function burnupCommand(specFile) {
63
155
 
64
156
  console.log(
65
157
  chalk.gray(
66
- ` Current Usage: ${mockStats.files_changed} files, ${mockStats.lines_changed} LOC`
158
+ ` Current Usage: ${currentStats.files_changed} files, ${currentStats.lines_changed} LOC`
67
159
  )
68
160
  );
161
+ if (currentStats.lines_added !== undefined) {
162
+ console.log(
163
+ chalk.gray(
164
+ ` Breakdown: +${currentStats.lines_added} added, -${currentStats.lines_removed} removed`
165
+ )
166
+ );
167
+ }
69
168
 
70
169
  const filePercent = Math.round(
71
- (mockStats.files_changed / derivedBudget.effective.max_files) * 100
170
+ (currentStats.files_changed / derivedBudget.effective.max_files) * 100
72
171
  );
73
172
  const locPercent = Math.round(
74
- (mockStats.lines_changed / derivedBudget.effective.max_loc) * 100
173
+ (currentStats.lines_changed / derivedBudget.effective.max_loc) * 100
75
174
  );
76
175
 
77
176
  if (filePercent > 90 || locPercent > 90) {
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Diagnose command handler
3
+ * @param {Object} options - Command options
4
+ */
5
+ export function diagnoseCommand(options?: any): Promise<void>;
6
+ /**
7
+ * Run all health checks
8
+ * @returns {Promise<Object>} Diagnosis results
9
+ */
10
+ export function runDiagnosis(): Promise<any>;
11
+ /**
12
+ * Display diagnosis results
13
+ * @param {Object[]} results - Diagnosis results
14
+ */
15
+ export function displayResults(results: any[]): void;
16
+ /**
17
+ * Apply automatic fixes
18
+ * @param {Object[]} results - Diagnosis results
19
+ * @returns {Promise<Object>} Fix results
20
+ */
21
+ export function applyAutoFixes(results: any[]): Promise<any>;
22
+ /**
23
+ * Health check: Working spec validity
24
+ * @returns {Promise<Object>} Check result
25
+ */
26
+ export function checkWorkingSpec(): Promise<any>;
27
+ /**
28
+ * Health check: Git repository
29
+ * @returns {Promise<Object>} Check result
30
+ */
31
+ export function checkGitSetup(): Promise<any>;
32
+ /**
33
+ * Health check: Git hooks
34
+ * @returns {Promise<Object>} Check result
35
+ */
36
+ export function checkGitHooks(): Promise<any>;
37
+ /**
38
+ * Health check: TypeScript configuration
39
+ * @returns {Promise<Object>} Check result
40
+ */
41
+ export function checkTypeScriptConfig(): Promise<any>;
42
+ /**
43
+ * Health check: Test files exist
44
+ * @returns {Promise<Object>} Check result
45
+ */
46
+ export function checkTestFiles(): Promise<any>;
47
+ /**
48
+ * Health check: CAWS tools directory
49
+ * @returns {Promise<Object>} Check result
50
+ */
51
+ export function checkCAWSTools(): Promise<any>;
52
+ //# sourceMappingURL=diagnose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnose.d.ts","sourceRoot":"","sources":["../../src/commands/diagnose.js"],"names":[],"mappings":"AA0bA;;;GAGG;AACH,8DAoDC;AAvND;;;GAGG;AACH,gCAFa,OAAO,KAAQ,CAkD3B;AAED;;;GAGG;AACH,wCAFW,KAAQ,QA4ClB;AAED;;;;GAIG;AACH,wCAHW,KAAQ,GACN,OAAO,KAAQ,CAoD3B;AAzaD;;;GAGG;AACH,oCAFa,OAAO,KAAQ,CA2C3B;AAED;;;GAGG;AACH,iCAFa,OAAO,KAAQ,CAiB3B;AAED;;;GAGG;AACH,iCAFa,OAAO,KAAQ,CA0C3B;AAED;;;GAGG;AACH,yCAFa,OAAO,KAAQ,CAgE3B;AAED;;;GAGG;AACH,kCAFa,OAAO,KAAQ,CAoC3B;AAED;;;GAGG;AACH,kCAFa,OAAO,KAAQ,CA0C3B"}
@@ -11,7 +11,7 @@ const chalk = require('chalk');
11
11
 
12
12
  // Import utilities
13
13
  const { checkTypeScriptTestConfig } = require('../utils/typescript-detector');
14
- const { configureJestForTypeScript } = require('../generators/jest-config');
14
+ const { configureJestForTypeScript } = require('../generators/jest-config-generator');
15
15
 
16
16
  /**
17
17
  * Health check: Working spec validity
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Evaluate command handler
3
+ *
4
+ * @param {string} specFile - Path to working spec file
5
+ * @param {object} options - Command options
6
+ */
7
+ export function evaluateCommand(specFile?: string, options?: object): Promise<void>;
8
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/commands/evaluate.js"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,2CAHW,MAAM,YACN,MAAM,iBA0QhB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Initialize a new project with CAWS
3
+ */
4
+ export function initProject(projectName: any, options: any): Promise<void>;
5
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.js"],"names":[],"mappings":"AAqBA;;GAEG;AACH,2EAwiBC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Iterate command handler
3
+ *
4
+ * @param {string} specFile - Path to working spec file
5
+ * @param {object} options - Command options
6
+ */
7
+ export function iterateCommand(specFile?: string, options?: object): Promise<void>;
8
+ //# sourceMappingURL=iterate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterate.d.ts","sourceRoot":"","sources":["../../src/commands/iterate.js"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,0CAHW,MAAM,YACN,MAAM,iBAgLhB"}