@paths.design/caws-cli 9.3.2 → 10.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 (286) hide show
  1. package/README.md +71 -32
  2. package/dist/budget-derivation.js +221 -74
  3. package/dist/commands/archive.js +67 -28
  4. package/dist/commands/burnup.js +20 -11
  5. package/dist/commands/diagnose.js +34 -22
  6. package/dist/commands/evaluate.js +41 -15
  7. package/dist/commands/gates.js +149 -0
  8. package/dist/commands/init.js +150 -19
  9. package/dist/commands/iterate.js +81 -4
  10. package/dist/commands/parallel.js +4 -0
  11. package/dist/commands/plan.js +9 -19
  12. package/dist/commands/provenance.js +53 -17
  13. package/dist/commands/quality-monitor.js +64 -45
  14. package/dist/commands/scope.js +264 -0
  15. package/dist/commands/sidecar.js +74 -0
  16. package/dist/commands/specs.js +381 -45
  17. package/dist/commands/status.js +117 -9
  18. package/dist/commands/templates.js +0 -8
  19. package/dist/commands/tutorial.js +10 -9
  20. package/dist/commands/validate.js +70 -6
  21. package/dist/commands/verify-acs.js +48 -76
  22. package/dist/commands/waivers.js +212 -13
  23. package/dist/commands/worktree.js +131 -26
  24. package/dist/error-handler.js +2 -13
  25. package/dist/gates/budget-limit.js +121 -0
  26. package/dist/gates/feedback.js +260 -0
  27. package/dist/gates/format.js +179 -0
  28. package/dist/gates/god-object.js +117 -0
  29. package/dist/gates/pipeline.js +167 -0
  30. package/dist/gates/scope-boundary.js +93 -0
  31. package/dist/gates/spec-completeness.js +109 -0
  32. package/dist/gates/todo-detection.js +205 -0
  33. package/dist/index.js +157 -151
  34. package/dist/parallel/parallel-manager.js +3 -3
  35. package/dist/policy/PolicyManager.js +51 -17
  36. package/dist/scaffold/claude-hooks.js +24 -1
  37. package/dist/scaffold/git-hooks.js +45 -102
  38. package/dist/scaffold/index.js +4 -3
  39. package/dist/session/session-manager.js +105 -14
  40. package/dist/sidecars/index.js +33 -0
  41. package/dist/sidecars/listeners.js +40 -0
  42. package/dist/sidecars/provenance-summary.js +238 -0
  43. package/dist/sidecars/quality-gaps.js +258 -0
  44. package/dist/sidecars/schema.js +149 -0
  45. package/dist/sidecars/spec-drift.js +151 -0
  46. package/dist/sidecars/waiver-draft.js +176 -0
  47. package/dist/templates/.caws/schemas/policy.schema.json +112 -0
  48. package/dist/templates/.caws/schemas/scope.schema.json +3 -3
  49. package/dist/templates/.caws/schemas/waivers.schema.json +96 -20
  50. package/dist/templates/.caws/schemas/working-spec.schema.json +264 -57
  51. package/dist/templates/.caws/schemas/worktrees.schema.json +3 -1
  52. package/dist/templates/.caws/templates/working-spec.template.yml +10 -4
  53. package/dist/templates/.caws/tools/scope-guard.js +66 -15
  54. package/dist/templates/.claude/README.md +1 -1
  55. package/dist/templates/.claude/hooks/audit.sh +0 -0
  56. package/dist/templates/.claude/hooks/block-dangerous.sh +52 -11
  57. package/dist/templates/.claude/hooks/classify_command.py +592 -0
  58. package/dist/templates/.claude/hooks/doc-frontmatter-check.sh +173 -0
  59. package/dist/templates/.claude/hooks/protected-paths.sh +39 -0
  60. package/dist/templates/.claude/hooks/quality-check.sh +23 -10
  61. package/dist/templates/.claude/hooks/scope-guard.sh +136 -55
  62. package/dist/templates/.claude/hooks/session-caws-status.sh +2 -2
  63. package/dist/templates/.claude/hooks/session-log.sh +76 -3
  64. package/dist/templates/.claude/hooks/stop-worktree-check.sh +1 -1
  65. package/dist/templates/.claude/hooks/test_classify_command.py +370 -0
  66. package/dist/templates/.claude/hooks/test_wrapper_smoke.sh +96 -0
  67. package/dist/templates/.claude/hooks/worktree-guard.sh +2 -2
  68. package/dist/templates/.claude/hooks/worktree-write-guard.sh +97 -4
  69. package/dist/templates/.claude/settings.json +31 -0
  70. package/dist/templates/.cursor/hooks/caws-quality-check.sh +4 -4
  71. package/dist/templates/.cursor/hooks/caws-scope-guard.sh +1 -1
  72. package/dist/templates/.cursor/hooks/session-log.sh +924 -0
  73. package/dist/templates/.cursor/hooks.json +25 -0
  74. package/dist/templates/.cursor/rules/02-quality-gates.mdc +3 -5
  75. package/dist/templates/.cursor/rules/10-documentation-quality-standards.mdc +6 -11
  76. package/dist/templates/.cursor/rules/11-scope-management-waivers.mdc +14 -18
  77. package/dist/templates/.cursor/rules/12-implementation-completeness.mdc +4 -4
  78. package/dist/templates/.cursor/rules/13-language-agnostic-standards.mdc +3 -13
  79. package/dist/templates/.github/copilot-instructions.md +5 -5
  80. package/dist/templates/.idea/runConfigurations/CAWS_Evaluate.xml +1 -1
  81. package/dist/templates/.junie/guidelines.md +2 -2
  82. package/dist/templates/.vscode/settings.json +3 -1
  83. package/dist/templates/.windsurf/rules/caws-quality-standards.md +2 -2
  84. package/dist/templates/.windsurf/workflows/caws-guided-development.md +3 -3
  85. package/dist/templates/CLAUDE.md +77 -8
  86. package/dist/templates/agents.md +50 -9
  87. package/dist/templates/docs/README.md +8 -7
  88. package/dist/templates/scripts/new_feature.sh +80 -0
  89. package/dist/test-analysis.js +43 -30
  90. package/dist/tool-loader.js +1 -1
  91. package/dist/utils/agent-session.js +202 -0
  92. package/dist/utils/detection.js +8 -2
  93. package/dist/utils/event-log.js +584 -0
  94. package/dist/utils/event-renderer.js +521 -0
  95. package/dist/utils/finalization.js +7 -6
  96. package/dist/utils/gitignore-updater.js +3 -0
  97. package/dist/utils/lifecycle-events.js +94 -0
  98. package/dist/utils/quality-gates-utils.js +29 -44
  99. package/dist/utils/schema-validator.js +50 -0
  100. package/dist/utils/spec-resolver.js +93 -21
  101. package/dist/utils/working-state.js +530 -0
  102. package/dist/validation/spec-validation.js +191 -31
  103. package/dist/waivers-manager.js +144 -6
  104. package/dist/worktree/worktree-manager.js +598 -95
  105. package/package.json +9 -8
  106. package/templates/.caws/schemas/policy.schema.json +112 -0
  107. package/templates/.caws/schemas/scope.schema.json +3 -3
  108. package/templates/.caws/schemas/waivers.schema.json +96 -20
  109. package/templates/.caws/schemas/working-spec.schema.json +264 -57
  110. package/templates/.caws/schemas/worktrees.schema.json +3 -1
  111. package/templates/.caws/templates/working-spec.template.yml +10 -4
  112. package/templates/.caws/tools/scope-guard.js +66 -15
  113. package/templates/.claude/README.md +1 -1
  114. package/templates/.claude/hooks/block-dangerous.sh +52 -11
  115. package/templates/.claude/hooks/classify_command.py +592 -0
  116. package/templates/.claude/hooks/doc-frontmatter-check.sh +173 -0
  117. package/templates/.claude/hooks/protected-paths.sh +39 -0
  118. package/templates/.claude/hooks/quality-check.sh +23 -10
  119. package/templates/.claude/hooks/scope-guard.sh +136 -55
  120. package/templates/.claude/hooks/session-caws-status.sh +2 -2
  121. package/templates/.claude/hooks/session-log.sh +76 -3
  122. package/templates/.claude/hooks/stop-worktree-check.sh +1 -1
  123. package/templates/.claude/hooks/test_classify_command.py +370 -0
  124. package/templates/.claude/hooks/test_wrapper_smoke.sh +96 -0
  125. package/templates/.claude/hooks/worktree-guard.sh +2 -2
  126. package/templates/.claude/hooks/worktree-write-guard.sh +97 -4
  127. package/templates/.claude/settings.json +31 -0
  128. package/templates/.cursor/hooks/caws-quality-check.sh +4 -4
  129. package/templates/.cursor/hooks/caws-scope-guard.sh +1 -1
  130. package/templates/.cursor/hooks/session-log.sh +924 -0
  131. package/templates/.cursor/hooks.json +25 -0
  132. package/templates/.cursor/rules/02-quality-gates.mdc +3 -5
  133. package/templates/.cursor/rules/10-documentation-quality-standards.mdc +6 -11
  134. package/templates/.cursor/rules/11-scope-management-waivers.mdc +14 -18
  135. package/templates/.cursor/rules/12-implementation-completeness.mdc +4 -4
  136. package/templates/.cursor/rules/13-language-agnostic-standards.mdc +3 -13
  137. package/templates/.github/copilot-instructions.md +5 -5
  138. package/templates/.idea/runConfigurations/CAWS_Evaluate.xml +1 -1
  139. package/templates/.junie/guidelines.md +2 -2
  140. package/templates/.vscode/settings.json +3 -1
  141. package/templates/.windsurf/rules/caws-quality-standards.md +2 -2
  142. package/templates/.windsurf/workflows/caws-guided-development.md +3 -3
  143. package/templates/CLAUDE.md +77 -8
  144. package/templates/{AGENTS.md → agents.md} +50 -9
  145. package/templates/docs/README.md +8 -7
  146. package/templates/scripts/new_feature.sh +80 -0
  147. package/dist/budget-derivation.d.ts +0 -74
  148. package/dist/budget-derivation.d.ts.map +0 -1
  149. package/dist/cicd-optimizer.d.ts +0 -142
  150. package/dist/cicd-optimizer.d.ts.map +0 -1
  151. package/dist/commands/archive.d.ts +0 -51
  152. package/dist/commands/archive.d.ts.map +0 -1
  153. package/dist/commands/burnup.d.ts +0 -6
  154. package/dist/commands/burnup.d.ts.map +0 -1
  155. package/dist/commands/diagnose.d.ts +0 -52
  156. package/dist/commands/diagnose.d.ts.map +0 -1
  157. package/dist/commands/evaluate.d.ts +0 -8
  158. package/dist/commands/evaluate.d.ts.map +0 -1
  159. package/dist/commands/init.d.ts +0 -5
  160. package/dist/commands/init.d.ts.map +0 -1
  161. package/dist/commands/iterate.d.ts +0 -8
  162. package/dist/commands/iterate.d.ts.map +0 -1
  163. package/dist/commands/mode.d.ts +0 -25
  164. package/dist/commands/mode.d.ts.map +0 -1
  165. package/dist/commands/parallel.d.ts +0 -7
  166. package/dist/commands/parallel.d.ts.map +0 -1
  167. package/dist/commands/plan.d.ts +0 -49
  168. package/dist/commands/plan.d.ts.map +0 -1
  169. package/dist/commands/provenance.d.ts +0 -32
  170. package/dist/commands/provenance.d.ts.map +0 -1
  171. package/dist/commands/quality-gates.d.ts +0 -6
  172. package/dist/commands/quality-gates.d.ts.map +0 -1
  173. package/dist/commands/quality-gates.js +0 -444
  174. package/dist/commands/quality-monitor.d.ts +0 -17
  175. package/dist/commands/quality-monitor.d.ts.map +0 -1
  176. package/dist/commands/session.d.ts +0 -7
  177. package/dist/commands/session.d.ts.map +0 -1
  178. package/dist/commands/specs.d.ts +0 -77
  179. package/dist/commands/specs.d.ts.map +0 -1
  180. package/dist/commands/status.d.ts +0 -44
  181. package/dist/commands/status.d.ts.map +0 -1
  182. package/dist/commands/templates.d.ts +0 -74
  183. package/dist/commands/templates.d.ts.map +0 -1
  184. package/dist/commands/tool.d.ts +0 -13
  185. package/dist/commands/tool.d.ts.map +0 -1
  186. package/dist/commands/troubleshoot.d.ts +0 -8
  187. package/dist/commands/troubleshoot.d.ts.map +0 -1
  188. package/dist/commands/troubleshoot.js +0 -104
  189. package/dist/commands/tutorial.d.ts +0 -55
  190. package/dist/commands/tutorial.d.ts.map +0 -1
  191. package/dist/commands/validate.d.ts +0 -15
  192. package/dist/commands/validate.d.ts.map +0 -1
  193. package/dist/commands/waivers.d.ts +0 -8
  194. package/dist/commands/waivers.d.ts.map +0 -1
  195. package/dist/commands/workflow.d.ts +0 -85
  196. package/dist/commands/workflow.d.ts.map +0 -1
  197. package/dist/commands/worktree.d.ts +0 -7
  198. package/dist/commands/worktree.d.ts.map +0 -1
  199. package/dist/config/index.d.ts +0 -29
  200. package/dist/config/index.d.ts.map +0 -1
  201. package/dist/config/lite-scope.d.ts +0 -33
  202. package/dist/config/lite-scope.d.ts.map +0 -1
  203. package/dist/config/modes.d.ts +0 -264
  204. package/dist/config/modes.d.ts.map +0 -1
  205. package/dist/constants/spec-types.d.ts +0 -93
  206. package/dist/constants/spec-types.d.ts.map +0 -1
  207. package/dist/error-handler.d.ts +0 -151
  208. package/dist/error-handler.d.ts.map +0 -1
  209. package/dist/generators/jest-config-generator.d.ts +0 -32
  210. package/dist/generators/jest-config-generator.d.ts.map +0 -1
  211. package/dist/generators/jest-config.d.ts +0 -32
  212. package/dist/generators/jest-config.d.ts.map +0 -1
  213. package/dist/generators/jest-config.js +0 -242
  214. package/dist/generators/working-spec.d.ts +0 -13
  215. package/dist/generators/working-spec.d.ts.map +0 -1
  216. package/dist/index-new.d.ts +0 -5
  217. package/dist/index-new.d.ts.map +0 -1
  218. package/dist/index-new.js +0 -317
  219. package/dist/index.d.ts +0 -5
  220. package/dist/index.d.ts.map +0 -1
  221. package/dist/index.js.backup +0 -4711
  222. package/dist/minimal-cli.d.ts +0 -3
  223. package/dist/minimal-cli.d.ts.map +0 -1
  224. package/dist/parallel/parallel-manager.d.ts +0 -67
  225. package/dist/parallel/parallel-manager.d.ts.map +0 -1
  226. package/dist/policy/PolicyManager.d.ts +0 -104
  227. package/dist/policy/PolicyManager.d.ts.map +0 -1
  228. package/dist/scaffold/claude-hooks.d.ts +0 -28
  229. package/dist/scaffold/claude-hooks.d.ts.map +0 -1
  230. package/dist/scaffold/cursor-hooks.d.ts +0 -7
  231. package/dist/scaffold/cursor-hooks.d.ts.map +0 -1
  232. package/dist/scaffold/git-hooks.d.ts +0 -38
  233. package/dist/scaffold/git-hooks.d.ts.map +0 -1
  234. package/dist/scaffold/index.d.ts +0 -17
  235. package/dist/scaffold/index.d.ts.map +0 -1
  236. package/dist/session/session-manager.d.ts +0 -94
  237. package/dist/session/session-manager.d.ts.map +0 -1
  238. package/dist/spec/SpecFileManager.d.ts +0 -146
  239. package/dist/spec/SpecFileManager.d.ts.map +0 -1
  240. package/dist/templates/.cursor/hooks/caws-tool-validation.sh +0 -121
  241. package/dist/templates/.github/copilot/instructions.md +0 -311
  242. package/dist/test-analysis.d.ts +0 -231
  243. package/dist/test-analysis.d.ts.map +0 -1
  244. package/dist/tool-interface.d.ts +0 -236
  245. package/dist/tool-interface.d.ts.map +0 -1
  246. package/dist/tool-loader.d.ts +0 -77
  247. package/dist/tool-loader.d.ts.map +0 -1
  248. package/dist/tool-validator.d.ts +0 -72
  249. package/dist/tool-validator.d.ts.map +0 -1
  250. package/dist/utils/async-utils.d.ts +0 -73
  251. package/dist/utils/async-utils.d.ts.map +0 -1
  252. package/dist/utils/command-wrapper.d.ts +0 -66
  253. package/dist/utils/command-wrapper.d.ts.map +0 -1
  254. package/dist/utils/detection.d.ts +0 -14
  255. package/dist/utils/detection.d.ts.map +0 -1
  256. package/dist/utils/error-categories.d.ts +0 -52
  257. package/dist/utils/error-categories.d.ts.map +0 -1
  258. package/dist/utils/finalization.d.ts +0 -17
  259. package/dist/utils/finalization.d.ts.map +0 -1
  260. package/dist/utils/git-lock.d.ts +0 -13
  261. package/dist/utils/git-lock.d.ts.map +0 -1
  262. package/dist/utils/gitignore-updater.d.ts +0 -39
  263. package/dist/utils/gitignore-updater.d.ts.map +0 -1
  264. package/dist/utils/ide-detection.d.ts +0 -89
  265. package/dist/utils/ide-detection.d.ts.map +0 -1
  266. package/dist/utils/project-analysis.d.ts +0 -34
  267. package/dist/utils/project-analysis.d.ts.map +0 -1
  268. package/dist/utils/promise-utils.d.ts +0 -30
  269. package/dist/utils/promise-utils.d.ts.map +0 -1
  270. package/dist/utils/quality-gates-utils.d.ts +0 -49
  271. package/dist/utils/quality-gates-utils.d.ts.map +0 -1
  272. package/dist/utils/quality-gates.d.ts +0 -49
  273. package/dist/utils/quality-gates.d.ts.map +0 -1
  274. package/dist/utils/quality-gates.js +0 -402
  275. package/dist/utils/spec-resolver.d.ts +0 -80
  276. package/dist/utils/spec-resolver.d.ts.map +0 -1
  277. package/dist/utils/typescript-detector.d.ts +0 -66
  278. package/dist/utils/typescript-detector.d.ts.map +0 -1
  279. package/dist/utils/yaml-validation.d.ts +0 -32
  280. package/dist/utils/yaml-validation.d.ts.map +0 -1
  281. package/dist/validation/spec-validation.d.ts +0 -43
  282. package/dist/validation/spec-validation.d.ts.map +0 -1
  283. package/dist/waivers-manager.d.ts +0 -167
  284. package/dist/waivers-manager.d.ts.map +0 -1
  285. package/dist/worktree/worktree-manager.d.ts +0 -54
  286. package/dist/worktree/worktree-manager.d.ts.map +0 -1
@@ -1,402 +0,0 @@
1
- /**
2
- * CAWS Quality Gate Utilities
3
- *
4
- * Reusable quality gate scripts for CAWS projects.
5
- * Provides staged file analysis, god object detection, and TODO analysis.
6
- *
7
- * @author @darianrosebrook
8
- */
9
-
10
- const fs = require('fs');
11
- const path = require('path');
12
- const yaml = require('js-yaml');
13
- const { execSync } = require('child_process');
14
- const { getTodoAnalyzerSuggestion } = require('./project-analysis');
15
-
16
- /**
17
- * Quality Gate Configuration
18
- */
19
- const CONFIG = {
20
- godObjectThresholds: {
21
- warning: 1750,
22
- critical: 2000,
23
- },
24
- todoConfidenceThreshold: 0.8,
25
- supportedExtensions: ['.rs', '.ts', '.tsx', '.js', '.jsx', '.py'],
26
- crisisResponseThresholds: {
27
- godObjectCritical: 3000,
28
- todoConfidenceThreshold: 0.9,
29
- },
30
- };
31
-
32
- /**
33
- * Check if a waiver applies to the given gate
34
- * @param {string} gate - Gate name to check
35
- * @returns {Object} Waiver check result
36
- */
37
- function checkWaiver(gate) {
38
- try {
39
- const waiversPath = path.join(process.cwd(), '.caws/waivers.yml');
40
- if (!fs.existsSync(waiversPath)) {
41
- return { waived: false, reason: 'No waivers file found' };
42
- }
43
-
44
- const waiversConfig = yaml.load(fs.readFileSync(waiversPath, 'utf8'));
45
- const now = new Date();
46
-
47
- // Find active waivers for this gate
48
- const activeWaivers =
49
- waiversConfig.waivers?.filter((waiver) => {
50
- const expiresAt = new Date(waiver.expires_at);
51
- return waiver.gates.includes(gate) && expiresAt > now && waiver.status === 'active';
52
- }) || [];
53
-
54
- if (activeWaivers.length > 0) {
55
- const waiver = activeWaivers[0];
56
- return {
57
- waived: true,
58
- waiver,
59
- reason: `Active waiver: ${waiver.title} (expires: ${waiver.expires_at})`,
60
- };
61
- }
62
-
63
- return { waived: false, reason: 'No active waivers found' };
64
- } catch (error) {
65
- return { waived: false, reason: `Waiver check failed: ${error.message}` };
66
- }
67
- }
68
-
69
- /**
70
- * Detect if project is in crisis response mode
71
- * @returns {boolean} True if in crisis mode
72
- */
73
- function detectCrisisMode() {
74
- try {
75
- const crisisIndicators = [
76
- // Check for crisis response in working spec
77
- () => {
78
- const specPath = path.join(process.cwd(), '.caws/working-spec.yaml');
79
- if (fs.existsSync(specPath)) {
80
- const spec = yaml.load(fs.readFileSync(specPath, 'utf8'));
81
- return spec.mode === 'crisis' || spec.crisis_mode === true;
82
- }
83
- return false;
84
- },
85
- // Check for crisis response in environment
86
- () => process.env.CAWS_CRISIS_MODE === 'true',
87
- // Check for crisis response in git commit message
88
- () => {
89
- try {
90
- const lastCommit = execSync('git log -1 --pretty=%B', { encoding: 'utf8' });
91
- return (
92
- lastCommit.toLowerCase().includes('crisis') ||
93
- lastCommit.toLowerCase().includes('emergency')
94
- );
95
- } catch {
96
- return false;
97
- }
98
- },
99
- ];
100
-
101
- return crisisIndicators.some((indicator) => indicator());
102
- } catch (error) {
103
- return false;
104
- }
105
- }
106
-
107
- /**
108
- * Get staged files from git
109
- * @returns {string[]} Array of staged file paths
110
- */
111
- function getStagedFiles() {
112
- try {
113
- const stagedFiles = execSync('git diff --cached --name-only', { encoding: 'utf8' })
114
- .trim()
115
- .split('\n')
116
- .filter((file) => file.trim() !== '');
117
-
118
- return stagedFiles;
119
- } catch (error) {
120
- console.warn(`⚠️ Could not get staged files: ${error.message}`);
121
- return [];
122
- }
123
- }
124
-
125
- /**
126
- * Check for god objects in staged files
127
- * @param {string[]} stagedFiles - Array of staged file paths
128
- * @param {string} language - Language to check ('rust', 'typescript', etc.)
129
- * @returns {Object} God object analysis results
130
- */
131
- function checkGodObjects(stagedFiles, language = 'rust') {
132
- const extension =
133
- language === 'rust'
134
- ? '.rs'
135
- : language === 'typescript'
136
- ? '.ts'
137
- : language === 'javascript'
138
- ? '.js'
139
- : '.py';
140
-
141
- const files = stagedFiles.filter((file) => file.endsWith(extension));
142
-
143
- if (files.length === 0) {
144
- return { violations: [], warnings: [], total: 0 };
145
- }
146
-
147
- console.log(`📁 Found ${files.length} staged ${language} files to check`);
148
-
149
- const violations = [];
150
- const warnings = [];
151
-
152
- for (const file of files) {
153
- try {
154
- const fullPath = path.resolve(file);
155
- if (!fs.existsSync(fullPath)) continue;
156
-
157
- const content = fs.readFileSync(fullPath, 'utf8');
158
- const lineCount = content.split('\n').length;
159
-
160
- if (lineCount >= CONFIG.godObjectThresholds.critical) {
161
- violations.push({
162
- file,
163
- lines: lineCount,
164
- severity: 'critical',
165
- message: `CRITICAL: ${lineCount} LOC exceeds god object threshold (${CONFIG.godObjectThresholds.critical}+ LOC)`,
166
- });
167
- } else if (lineCount >= CONFIG.godObjectThresholds.warning) {
168
- warnings.push({
169
- file,
170
- lines: lineCount,
171
- severity: 'warning',
172
- message: `WARNING: ${lineCount} LOC approaches god object territory (${CONFIG.godObjectThresholds.warning}+ LOC)`,
173
- });
174
- }
175
- } catch (error) {
176
- console.warn(`⚠️ Could not analyze ${file}: ${error.message}`);
177
- }
178
- }
179
-
180
- return { violations, warnings, total: violations.length + warnings.length };
181
- }
182
-
183
- /**
184
- * Check for hidden TODOs in staged files
185
- * @param {string[]} stagedFiles - Array of staged file paths
186
- * @returns {Object} TODO analysis results
187
- */
188
- function checkHiddenTodos(stagedFiles) {
189
- const supportedFiles = stagedFiles.filter((file) =>
190
- CONFIG.supportedExtensions.some((ext) => file.endsWith(ext))
191
- );
192
-
193
- if (supportedFiles.length === 0) {
194
- return { todos: [], blocking: 0, total: 0 };
195
- }
196
-
197
- console.log(`📁 Found ${supportedFiles.length} staged files to analyze for TODOs`);
198
-
199
- try {
200
- // Find TODO analyzer .mjs file (preferred - no Python dependency)
201
- const possiblePaths = [
202
- // Published npm package (priority)
203
- path.join(
204
- process.cwd(),
205
- 'node_modules',
206
- '@paths.design',
207
- 'quality-gates',
208
- 'todo-analyzer.mjs'
209
- ),
210
- // Legacy monorepo local copy
211
- path.join(process.cwd(), 'node_modules', '@caws', 'quality-gates', 'todo-analyzer.mjs'),
212
- // Monorepo structure (development)
213
- path.join(process.cwd(), 'packages', 'quality-gates', 'todo-analyzer.mjs'),
214
- // Local copy in scripts directory (if scaffolded)
215
- path.join(process.cwd(), 'scripts', 'todo-analyzer.mjs'),
216
- // Legacy Python analyzer (deprecated)
217
- path.join(process.cwd(), 'scripts', 'v3', 'analysis', 'todo_analyzer.py'),
218
- ];
219
-
220
- let analyzerPath = null;
221
- let usePython = false;
222
-
223
- for (const testPath of possiblePaths) {
224
- if (fs.existsSync(testPath)) {
225
- analyzerPath = testPath;
226
- usePython = testPath.endsWith('.py');
227
- break;
228
- }
229
- }
230
-
231
- if (!analyzerPath) {
232
- console.warn('⚠️ TODO analyzer not found - skipping TODO analysis');
233
- const suggestion = getTodoAnalyzerSuggestion(process.cwd());
234
- console.warn('💡 Available options for TODO analysis:');
235
- console.warn(suggestion);
236
- return { todos: [], blocking: 0, total: 0 };
237
- }
238
-
239
- if (usePython) {
240
- console.warn('⚠️ Using legacy Python TODO analyzer (deprecated)');
241
- const suggestion = getTodoAnalyzerSuggestion(process.cwd());
242
- console.warn('💡 Consider upgrading to Node.js version:');
243
- console.warn(suggestion);
244
- }
245
-
246
- // Run the TODO analyzer with staged files
247
- const command = usePython
248
- ? `python3 ${analyzerPath} --staged-only --min-confidence ${CONFIG.todoConfidenceThreshold}`
249
- : `node ${analyzerPath} --staged-only --ci-mode --min-confidence ${CONFIG.todoConfidenceThreshold}`;
250
-
251
- const result = execSync(command, { encoding: 'utf8', cwd: process.cwd() });
252
-
253
- // Parse the output to extract TODO count
254
- const lines = result.split('\n');
255
- const summaryLine = lines.find((line) => line.includes('Total hidden TODOs:'));
256
- const todoCount = summaryLine ? parseInt(summaryLine.split(':')[1].trim()) : 0;
257
-
258
- return {
259
- todos: [],
260
- blocking: todoCount,
261
- total: todoCount,
262
- details: result,
263
- };
264
- } catch (error) {
265
- console.warn(`⚠️ Could not run TODO analysis: ${error.message}`);
266
- return { todos: [], blocking: 0, total: 0 };
267
- }
268
- }
269
-
270
- /**
271
- * Run comprehensive quality gates on staged files
272
- * @param {Object} options - Options for quality gates
273
- * @returns {Object} Quality gate results
274
- */
275
- function runQualityGates(options = {}) {
276
- const { languages = ['rust'], checkTodos = true, checkGodObjects = true, ci = false } = options;
277
-
278
- console.log(`🚦 Running Quality Gates${ci ? ' (CI Mode)' : ' - Crisis Response Mode'}`);
279
- console.log('==================================================');
280
-
281
- // Get staged files
282
- const stagedFiles = getStagedFiles();
283
-
284
- if (stagedFiles.length === 0) {
285
- console.log('✅ No staged files to analyze');
286
- return { passed: true, violations: [], warnings: [] };
287
- }
288
-
289
- console.log(`📁 Analyzing ${stagedFiles.length} staged files`);
290
-
291
- const results = {
292
- passed: true,
293
- violations: [],
294
- warnings: [],
295
- todos: 0,
296
- };
297
-
298
- // Check naming conventions
299
- console.log('\n🔤 Checking naming conventions...');
300
- console.log(' ✅ Naming conventions check passed');
301
-
302
- // Check code freeze compliance
303
- console.log('\n🚫 Checking code freeze compliance...');
304
- console.log(' ✅ Code freeze compliance check passed');
305
-
306
- // Check duplication
307
- console.log('\n📋 Checking duplication...');
308
- console.log(' ✅ No duplication regression detected');
309
-
310
- // Check god objects for each language
311
- if (checkGodObjects) {
312
- for (const language of languages) {
313
- console.log(`\n🏗️ Checking god objects (${language})...`);
314
- const godObjectResults = checkGodObjects(stagedFiles, language);
315
-
316
- results.violations.push(...godObjectResults.violations);
317
- results.warnings.push(...godObjectResults.warnings);
318
-
319
- if (godObjectResults.violations.length > 0) {
320
- console.log(' ❌ God object violations detected:');
321
- godObjectResults.violations.forEach((violation) => {
322
- console.log(` ${violation.file}: ${violation.message}`);
323
- });
324
- } else {
325
- console.log(' ✅ No blocking god object violations');
326
- }
327
-
328
- if (godObjectResults.warnings.length > 0) {
329
- console.log(' ⚠️ God object warnings:');
330
- godObjectResults.warnings.forEach((warning) => {
331
- console.log(` ${warning.file}: ${warning.message}`);
332
- });
333
- }
334
- }
335
- }
336
-
337
- // Check hidden TODOs
338
- if (checkTodos) {
339
- console.log('\n🔍 Checking hidden TODOs...');
340
- const todoResults = checkHiddenTodos(stagedFiles);
341
- results.todos = todoResults.total;
342
-
343
- if (todoResults.total > 0) {
344
- console.log(` ❌ Found ${todoResults.total} hidden TODOs in staged files`);
345
- console.log(' 💡 Fix stub implementations and placeholder code before committing');
346
- console.log(' 📖 See docs/PLACEHOLDER-DETECTION-GUIDE.md for classification');
347
- } else {
348
- console.log(' ✅ No critical hidden TODOs found in staged files');
349
- }
350
- }
351
-
352
- // Summary
353
- console.log('\n==================================================');
354
- console.log('📊 QUALITY GATES RESULTS');
355
- console.log('==================================================');
356
-
357
- const totalViolations = results.violations.length;
358
- const totalWarnings = results.warnings.length;
359
- const totalTodos = results.todos;
360
-
361
- if (totalViolations > 0) {
362
- console.log(`\n❌ CRITICAL VIOLATIONS (${totalViolations}):`);
363
- results.violations.forEach((violation) => {
364
- console.log(` ${violation.file}: ${violation.message}`);
365
- });
366
- results.passed = false;
367
- }
368
-
369
- if (totalWarnings > 0) {
370
- console.log(`\n⚠️ WARNINGS (${totalWarnings}):`);
371
- results.warnings.forEach((warning) => {
372
- console.log(` ${warning.file}: ${warning.message}`);
373
- });
374
- }
375
-
376
- if (totalTodos > 0) {
377
- console.log(`\n🔍 HIDDEN TODOS (${totalTodos}):`);
378
- console.log(` Found ${totalTodos} hidden TODOs in staged files`);
379
- results.passed = false;
380
- }
381
-
382
- // Final result
383
- if (results.passed) {
384
- console.log('\n✅ ALL QUALITY GATES PASSED');
385
- console.log('🎉 Commit allowed - quality maintained!');
386
- } else {
387
- console.log('\n❌ QUALITY GATES FAILED');
388
- console.log('🚫 Commit blocked - fix violations above');
389
- }
390
-
391
- return results;
392
- }
393
-
394
- module.exports = {
395
- getStagedFiles,
396
- checkGodObjects,
397
- checkHiddenTodos,
398
- checkWaiver,
399
- detectCrisisMode,
400
- runQualityGates,
401
- CONFIG,
402
- };
@@ -1,80 +0,0 @@
1
- /**
2
- * Resolve spec file path based on priority
3
- * @param {Object} options - Resolution options
4
- * @param {string} [options.specId] - Feature-specific spec ID (e.g., 'user-auth', 'FEAT-001')
5
- * @param {string} [options.specFile] - Explicit file path override
6
- * @param {boolean} [options.warnLegacy=true] - Warn when falling back to legacy spec
7
- * @param {boolean} [options.interactive=false] - Use interactive spec selection for multiple specs
8
- * @returns {Promise<{path: string, type: 'feature' | 'legacy', spec: Object}>}
9
- */
10
- export function resolveSpec(options?: {
11
- specId?: string;
12
- specFile?: string;
13
- warnLegacy?: boolean;
14
- interactive?: boolean;
15
- }): Promise<{
16
- path: string;
17
- type: "feature" | "legacy";
18
- spec: any;
19
- }>;
20
- /**
21
- * List all available specs
22
- * @returns {Promise<Array<{id: string, path: string, type: string}>>}
23
- */
24
- export function listAvailableSpecs(): Promise<Array<{
25
- id: string;
26
- path: string;
27
- type: string;
28
- }>>;
29
- /**
30
- * Check if project is using multi-spec architecture
31
- * @returns {Promise<{isMultiSpec: boolean, specCount: number, needsMigration: boolean}>}
32
- */
33
- export function checkMultiSpecStatus(): Promise<{
34
- isMultiSpec: boolean;
35
- specCount: number;
36
- needsMigration: boolean;
37
- }>;
38
- /**
39
- * Check for scope conflicts between specs
40
- * @param {string[]} specIds - Array of spec IDs to check
41
- * @returns {Promise<Array<{spec1: string, spec2: string, conflicts: string[]}>>} Array of conflicts
42
- */
43
- export function checkScopeConflicts(specIds: string[]): Promise<Array<{
44
- spec1: string;
45
- spec2: string;
46
- conflicts: string[];
47
- }>>;
48
- /**
49
- * Suggest migration from legacy to multi-spec
50
- * @returns {Promise<void>}
51
- */
52
- export function suggestMigration(): Promise<void>;
53
- /**
54
- * Interactive spec selection using readline
55
- * @param {string[]} specIds - Available spec IDs
56
- * @returns {Promise<string>} Selected spec ID
57
- */
58
- export function interactiveSpecSelection(specIds: string[]): Promise<string>;
59
- /**
60
- * Load specs registry
61
- * @returns {Promise<Object>} Registry data
62
- */
63
- export function loadSpecsRegistry(): Promise<any>;
64
- export function suggestFeatureBreakdown(legacySpec: any): any[];
65
- /**
66
- * Check if two paths overlap (simplified implementation)
67
- * @param {string} path1 - First path
68
- * @param {string} path2 - Second path
69
- * @returns {boolean} True if paths overlap
70
- */
71
- export function pathsOverlap(path1: string, path2: string): boolean;
72
- /**
73
- * Spec resolution priority:
74
- * 1. .caws/specs/<spec-id>.yaml (feature-specific, multi-agent safe)
75
- * 2. .caws/working-spec.yaml (legacy, single-agent only)
76
- */
77
- export const SPECS_DIR: ".caws/specs";
78
- export const LEGACY_SPEC: ".caws/working-spec.yaml";
79
- export const SPECS_REGISTRY: ".caws/specs/registry.json";
80
- //# sourceMappingURL=spec-resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spec-resolver.d.ts","sourceRoot":"","sources":["../../src/utils/spec-resolver.js"],"names":[],"mappings":"AAwBA;;;;;;;;GAQG;AACH,sCANG;IAAyB,MAAM,GAAvB,MAAM;IACW,QAAQ,GAAzB,MAAM;IACY,UAAU,GAA5B,OAAO;IACW,WAAW,GAA7B,OAAO;CACf,GAAU,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAAC,IAAI,MAAQ;CAAC,CAAC,CA+K7E;AA6BD;;;GAGG;AACH,sCAFa,OAAO,CAAC,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC,CAAC,CAoDpE;AAgDD;;;GAGG;AACH,wCAFa,OAAO,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAAC,CAAC,CAavF;AAED;;;;GAIG;AACH,6CAHW,MAAM,EAAE,GACN,OAAO,CAAC,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC,CAAC,CAwE/E;AA+DD;;;GAGG;AACH,oCAFa,OAAO,CAAC,IAAI,CAAC,CAczB;AAzND;;;;GAIG;AACH,kDAHW,MAAM,EAAE,GACN,OAAO,CAAC,MAAM,CAAC,CAyC3B;AA/HD;;;GAGG;AACH,qCAFa,OAAO,KAAQ,CAuB3B;AAsRD,gEAmGC;AAnLD;;;;;GAKG;AACH,oCAJW,MAAM,SACN,MAAM,GACJ,OAAO,CAuDnB;AA3dD;;;;GAIG;AACH,wBAAkB,aAAa,CAAC;AAChC,0BAAoB,yBAAyB,CAAC;AAC9C,6BAAuB,2BAA2B,CAAC"}
@@ -1,66 +0,0 @@
1
- /**
2
- * Detect if project is using TypeScript
3
- * @param {string} projectDir - Project directory path
4
- * @returns {Object} TypeScript detection result
5
- */
6
- export function detectTypeScript(projectDir?: string): any;
7
- /**
8
- * Detect testing framework in use
9
- * @param {string} projectDir - Project directory path
10
- * @param {Object} packageJson - Parsed package.json (optional)
11
- * @returns {Object} Testing framework detection result
12
- */
13
- export function detectTestFramework(projectDir?: string, packageJson?: any): any;
14
- export function getWorkspaceDirectories(projectDir?: string): string[];
15
- /**
16
- * Get workspace directories from npm/yarn package.json workspaces
17
- * @param {string} projectDir - Project directory path
18
- * @returns {string[]} Array of workspace directories
19
- */
20
- export function getNpmWorkspaces(projectDir: string): string[];
21
- /**
22
- * Get workspace directories from pnpm-workspace.yaml
23
- * @param {string} projectDir - Project directory path
24
- * @returns {string[]} Array of workspace directories
25
- */
26
- export function getPnpmWorkspaces(projectDir: string): string[];
27
- /**
28
- * Get workspace directories from lerna.json
29
- * @param {string} projectDir - Project directory path
30
- * @returns {string[]} Array of workspace directories
31
- */
32
- export function getLernaWorkspaces(projectDir: string): string[];
33
- /**
34
- * Expand workspace glob patterns to actual directories
35
- * Shared helper for npm, pnpm, and lerna workspace resolution
36
- * @param {string[]} patterns - Workspace patterns (may include globs like "packages/*")
37
- * @param {string} projectDir - Project directory path
38
- * @returns {string[]} Array of resolved workspace directory paths
39
- */
40
- export function expandWorkspacePatterns(patterns: string[], projectDir: string): string[];
41
- /**
42
- * Check if a dependency exists in hoisted node_modules
43
- * @param {string} depName - Dependency name to check
44
- * @param {string} projectDir - Project directory path
45
- * @returns {boolean} True if dependency found in hoisted node_modules
46
- */
47
- export function checkHoistedDependency(depName: string, projectDir: string): boolean;
48
- /**
49
- * Check if TypeScript project needs test configuration
50
- * @param {string} projectDir - Project directory path
51
- * @returns {Object} Configuration status
52
- */
53
- export function checkTypeScriptTestConfig(projectDir?: string): any;
54
- /**
55
- * Generate configuration recommendations
56
- * @param {Object} tsDetection - TypeScript detection result
57
- * @param {Object} testDetection - Test framework detection result
58
- * @returns {string[]} Array of recommendations
59
- */
60
- export function generateRecommendations(tsDetection: any, testDetection: any): string[];
61
- /**
62
- * Display TypeScript detection results
63
- * @param {Object} detection - Detection result from checkTypeScriptTestConfig
64
- */
65
- export function displayTypeScriptDetection(detection: any): void;
66
- //# sourceMappingURL=typescript-detector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typescript-detector.d.ts","sourceRoot":"","sources":["../../src/utils/typescript-detector.js"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,8CAHW,MAAM,OAkChB;AAED;;;;;GAKG;AACH,iDAJW,MAAM,0BAkDhB;AAgHD,uEASC;AApFD;;;;GAIG;AACH,6CAHW,MAAM,GACJ,MAAM,EAAE,CAgBpB;AAED;;;;GAIG;AACH,8CAHW,MAAM,GACJ,MAAM,EAAE,CAiBpB;AAED;;;;GAIG;AACH,+CAHW,MAAM,GACJ,MAAM,EAAE,CAgBpB;AAjGD;;;;;;GAMG;AACH,kDAJW,MAAM,EAAE,cACR,MAAM,GACJ,MAAM,EAAE,CA4BpB;AAkED;;;;;GAKG;AACH,gDAJW,MAAM,cACN,MAAM,GACJ,OAAO,CAKnB;AAaD;;;;GAIG;AACH,uDAHW,MAAM,OA0EhB;AAED;;;;;GAKG;AACH,+EAFa,MAAM,EAAE,CAuBpB;AAED;;;GAGG;AACH,iEAoBC"}
@@ -1,32 +0,0 @@
1
- /**
2
- * Validate YAML syntax for a file
3
- * @param {string} filePath - Path to YAML file
4
- * @returns {Object} Validation result with valid flag and error details
5
- */
6
- export function validateYamlSyntax(filePath: string): any;
7
- /**
8
- * Validate YAML syntax for multiple files
9
- * @param {string[]} filePaths - Array of file paths to validate
10
- * @returns {Object} Validation results with summary
11
- */
12
- export function validateYamlFiles(filePaths: string[]): any;
13
- /**
14
- * Find all YAML files in .caws directory
15
- * @param {string} projectRoot - Project root directory
16
- * @returns {string[]} Array of YAML file paths
17
- */
18
- export function findCawsYamlFiles(projectRoot: string): string[];
19
- /**
20
- * Validate all CAWS YAML files in project
21
- * @param {string} projectRoot - Project root directory
22
- * @returns {Object} Validation results
23
- */
24
- export function validateAllCawsYamlFiles(projectRoot: string): any;
25
- /**
26
- * Format validation error for display
27
- * @param {Object} error - Error object from validateYamlSyntax
28
- * @param {string} filePath - File path
29
- * @returns {string} Formatted error message
30
- */
31
- export function formatYamlError(error: any, filePath: string): string;
32
- //# sourceMappingURL=yaml-validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"yaml-validation.d.ts","sourceRoot":"","sources":["../../src/utils/yaml-validation.js"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,6CAHW,MAAM,OA2BhB;AAED;;;;GAIG;AACH,6CAHW,MAAM,EAAE,OAgClB;AAED;;;;GAIG;AACH,+CAHW,MAAM,GACJ,MAAM,EAAE,CA6BpB;AAED;;;;GAIG;AACH,sDAHW,MAAM,OAMhB;AAED;;;;;GAKG;AACH,sDAHW,MAAM,GACJ,MAAM,CAoBlB"}
@@ -1,43 +0,0 @@
1
- /**
2
- * Basic validation of working spec
3
- * @param {Object} spec - Working spec object
4
- * @param {Object} options - Validation options
5
- * @returns {Object} Validation result
6
- */
7
- export function validateWorkingSpec(spec: any, _options?: {}): any;
8
- /**
9
- * Enhanced validation with suggestions and auto-fix
10
- * @param {Object} spec - Working spec object
11
- * @param {Object} options - Validation options
12
- * @returns {Object} Enhanced validation result
13
- */
14
- export function validateWorkingSpecWithSuggestions(spec: any, options?: any): any;
15
- /**
16
- * Get suggestion for a missing field
17
- * @param {string} field - Field name
18
- * @param {Object} _spec - Spec object (for context)
19
- * @returns {string} Suggestion text
20
- */
21
- export function getFieldSuggestion(field: string, _spec: any): string;
22
- /**
23
- * Check if a field can be auto-fixed
24
- * @param {string} field - Field name
25
- * @param {Object} _spec - Spec object (for context)
26
- * @returns {boolean} Whether field can be auto-fixed
27
- */
28
- export function canAutoFixField(field: string, _spec: any): boolean;
29
- /**
30
- * Calculate compliance score based on errors and warnings
31
- * Score ranges from 0 (many issues) to 1 (perfect)
32
- * @param {Array} errors - Validation errors
33
- * @param {Array} warnings - Validation warnings
34
- * @returns {number} Compliance score (0-1)
35
- */
36
- export function calculateComplianceScore(errors: any[], warnings: any[]): number;
37
- /**
38
- * Get compliance grade from score
39
- * @param {number} score - Compliance score (0-1)
40
- * @returns {string} Grade (A, B, C, D, F)
41
- */
42
- export function getComplianceGrade(score: number): string;
43
- //# sourceMappingURL=spec-validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spec-validation.d.ts","sourceRoot":"","sources":["../../src/validation/spec-validation.js"],"names":[],"mappings":"AA6DA;;;;;GAKG;AACH,mEA8IC;AAED;;;;;GAKG;AACH,kFAycC;AAoCD;;;;;GAKG;AACH,0CAJW,MAAM,eAEJ,MAAM,CAkBlB;AAED;;;;;GAKG;AACH,uCAJW,MAAM,eAEJ,OAAO,CAKnB;AAnED;;;;;;GAMG;AACH,0EAFa,MAAM,CAclB;AAED;;;;GAIG;AACH,0CAHW,MAAM,GACJ,MAAM,CAQlB"}