@paths.design/caws-cli 6.0.0 → 7.0.1

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 (106) 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 +50 -0
  6. package/dist/commands/archive.d.ts.map +1 -0
  7. package/dist/commands/burnup.d.ts +6 -0
  8. package/dist/commands/burnup.d.ts.map +1 -0
  9. package/dist/commands/diagnose.d.ts +52 -0
  10. package/dist/commands/diagnose.d.ts.map +1 -0
  11. package/dist/commands/evaluate.d.ts +8 -0
  12. package/dist/commands/evaluate.d.ts.map +1 -0
  13. package/dist/commands/init.d.ts +5 -0
  14. package/dist/commands/init.d.ts.map +1 -0
  15. package/dist/commands/iterate.d.ts +8 -0
  16. package/dist/commands/iterate.d.ts.map +1 -0
  17. package/dist/commands/mode.d.ts +24 -0
  18. package/dist/commands/mode.d.ts.map +1 -0
  19. package/dist/commands/plan.d.ts +49 -0
  20. package/dist/commands/plan.d.ts.map +1 -0
  21. package/dist/commands/provenance.d.ts +32 -0
  22. package/dist/commands/provenance.d.ts.map +1 -0
  23. package/dist/commands/quality-gates.d.ts +52 -0
  24. package/dist/commands/quality-gates.d.ts.map +1 -0
  25. package/dist/commands/quality-gates.js +4 -2
  26. package/dist/commands/quality-monitor.d.ts +17 -0
  27. package/dist/commands/quality-monitor.d.ts.map +1 -0
  28. package/dist/commands/specs.d.ts +71 -0
  29. package/dist/commands/specs.d.ts.map +1 -0
  30. package/dist/commands/status.d.ts +44 -0
  31. package/dist/commands/status.d.ts.map +1 -0
  32. package/dist/commands/templates.d.ts +74 -0
  33. package/dist/commands/templates.d.ts.map +1 -0
  34. package/dist/commands/tool.d.ts +13 -0
  35. package/dist/commands/tool.d.ts.map +1 -0
  36. package/dist/commands/troubleshoot.d.ts +8 -0
  37. package/dist/commands/troubleshoot.d.ts.map +1 -0
  38. package/dist/commands/tutorial.d.ts +55 -0
  39. package/dist/commands/tutorial.d.ts.map +1 -0
  40. package/dist/commands/validate.d.ts +15 -0
  41. package/dist/commands/validate.d.ts.map +1 -0
  42. package/dist/commands/waivers.d.ts +8 -0
  43. package/dist/commands/waivers.d.ts.map +1 -0
  44. package/dist/commands/workflow.d.ts +85 -0
  45. package/dist/commands/workflow.d.ts.map +1 -0
  46. package/dist/config/index.d.ts +29 -0
  47. package/dist/config/index.d.ts.map +1 -0
  48. package/dist/config/modes.d.ts +225 -0
  49. package/dist/config/modes.d.ts.map +1 -0
  50. package/dist/constants/spec-types.d.ts +41 -0
  51. package/dist/constants/spec-types.d.ts.map +1 -0
  52. package/dist/error-handler.d.ts +164 -0
  53. package/dist/error-handler.d.ts.map +1 -0
  54. package/dist/generators/jest-config.d.ts +32 -0
  55. package/dist/generators/jest-config.d.ts.map +1 -0
  56. package/dist/generators/working-spec.d.ts +13 -0
  57. package/dist/generators/working-spec.d.ts.map +1 -0
  58. package/dist/index-new.d.ts +5 -0
  59. package/dist/index-new.d.ts.map +1 -0
  60. package/dist/index-new.js +317 -0
  61. package/dist/index.d.ts +5 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js.backup +4711 -0
  64. package/dist/minimal-cli.d.ts +3 -0
  65. package/dist/minimal-cli.d.ts.map +1 -0
  66. package/dist/policy/PolicyManager.d.ts +104 -0
  67. package/dist/policy/PolicyManager.d.ts.map +1 -0
  68. package/dist/scaffold/cursor-hooks.d.ts +7 -0
  69. package/dist/scaffold/cursor-hooks.d.ts.map +1 -0
  70. package/dist/scaffold/git-hooks.d.ts +20 -0
  71. package/dist/scaffold/git-hooks.d.ts.map +1 -0
  72. package/dist/scaffold/git-hooks.js +65 -7
  73. package/dist/scaffold/index.d.ts +20 -0
  74. package/dist/scaffold/index.d.ts.map +1 -0
  75. package/dist/scaffold/index.js +179 -41
  76. package/dist/spec/SpecFileManager.d.ts +146 -0
  77. package/dist/spec/SpecFileManager.d.ts.map +1 -0
  78. package/dist/test-analysis.d.ts +182 -0
  79. package/dist/test-analysis.d.ts.map +1 -0
  80. package/dist/tool-interface.d.ts +236 -0
  81. package/dist/tool-interface.d.ts.map +1 -0
  82. package/dist/tool-loader.d.ts +77 -0
  83. package/dist/tool-loader.d.ts.map +1 -0
  84. package/dist/tool-validator.d.ts +72 -0
  85. package/dist/tool-validator.d.ts.map +1 -0
  86. package/dist/utils/detection.d.ts +7 -0
  87. package/dist/utils/detection.d.ts.map +1 -0
  88. package/dist/utils/finalization.d.ts +17 -0
  89. package/dist/utils/finalization.d.ts.map +1 -0
  90. package/dist/utils/project-analysis.d.ts +14 -0
  91. package/dist/utils/project-analysis.d.ts.map +1 -0
  92. package/dist/utils/project-analysis.js +103 -0
  93. package/dist/utils/quality-gates.d.ts +49 -0
  94. package/dist/utils/quality-gates.d.ts.map +1 -0
  95. package/dist/utils/spec-resolver.d.ts +88 -0
  96. package/dist/utils/spec-resolver.d.ts.map +1 -0
  97. package/dist/utils/typescript-detector.d.ts +63 -0
  98. package/dist/utils/typescript-detector.d.ts.map +1 -0
  99. package/dist/validation/spec-validation.d.ts +43 -0
  100. package/dist/validation/spec-validation.d.ts.map +1 -0
  101. package/dist/waivers-manager.d.ts +167 -0
  102. package/dist/waivers-manager.d.ts.map +1 -0
  103. package/package.json +1 -1
  104. package/templates/COMMIT_CONVENTIONS.md +86 -0
  105. package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
  106. package/templates/apps/tools/caws/provenance.js.backup +73 -0
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=minimal-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minimal-cli.d.ts","sourceRoot":"","sources":["../src/minimal-cli.js"],"names":[],"mappings":""}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Policy Manager - Handles policy loading with intelligent caching
3
+ *
4
+ * Features:
5
+ * - TTL-based caching for performance
6
+ * - Graceful fallback to defaults when policy.yaml missing
7
+ * - Cache inspection and management API
8
+ * - Waiver validation and delta application
9
+ */
10
+ export class PolicyManager {
11
+ constructor(options?: {});
12
+ enableCaching: any;
13
+ cacheTTL: any;
14
+ policyCache: Map<any, any>;
15
+ /**
16
+ * Load CAWS policy from policy.yaml with caching
17
+ *
18
+ * @param {string} projectRoot - Project root directory
19
+ * @param {Object} options - Loading options
20
+ * @param {boolean} options.useCache - Use cache if available (default: true)
21
+ * @param {number} options.cacheTTL - Cache TTL override in milliseconds
22
+ * @returns {Promise<Object>} Policy object
23
+ */
24
+ loadPolicy(projectRoot: string, options?: {
25
+ useCache: boolean;
26
+ cacheTTL: number;
27
+ }): Promise<any>;
28
+ /**
29
+ * Load a waiver document by ID
30
+ *
31
+ * @param {string} waiverId - Waiver ID (e.g., WV-0001)
32
+ * @param {string} projectRoot - Project root directory
33
+ * @returns {Promise<Object|null>} Waiver document or null if not found
34
+ */
35
+ loadWaiver(waiverId: string, projectRoot: string): Promise<any | null>;
36
+ /**
37
+ * Check if a waiver is currently valid
38
+ *
39
+ * @param {Object} waiver - Waiver document
40
+ * @returns {boolean} True if waiver is valid and active
41
+ */
42
+ isWaiverValid(waiver: any): boolean;
43
+ /**
44
+ * Apply waivers to baseline budget
45
+ *
46
+ * @param {Object} baseline - Baseline budget from policy
47
+ * @param {string[]} waiverIds - Array of waiver IDs to apply
48
+ * @param {string} projectRoot - Project root directory
49
+ * @returns {Promise<Object>} Effective budget with waivers applied
50
+ */
51
+ applyWaivers(baseline: any, waiverIds: string[], projectRoot: string): Promise<any>;
52
+ /**
53
+ * Validate policy structure
54
+ *
55
+ * @param {Object} policy - Policy to validate
56
+ * @throws {Error} If policy is invalid
57
+ */
58
+ validatePolicy(policy: any): void;
59
+ /**
60
+ * Get default CAWS policy
61
+ *
62
+ * Returns sensible defaults when policy.yaml doesn't exist.
63
+ *
64
+ * @returns {Object} Default policy configuration
65
+ */
66
+ getDefaultPolicy(): any;
67
+ /**
68
+ * Clear policy cache
69
+ *
70
+ * @param {string} [projectRoot] - Specific project to clear, or all if omitted
71
+ */
72
+ clearCache(projectRoot?: string): void;
73
+ /**
74
+ * Get cache status for a project
75
+ *
76
+ * @param {string} projectRoot - Project root directory
77
+ * @returns {Object} Cache status information
78
+ */
79
+ getCacheStatus(projectRoot: string): any;
80
+ /**
81
+ * Reload policy from disk (bypassing cache)
82
+ *
83
+ * @param {string} projectRoot - Project root directory
84
+ * @returns {Promise<Object>} Fresh policy
85
+ */
86
+ reloadPolicy(projectRoot: string): Promise<any>;
87
+ /**
88
+ * Get all cached projects
89
+ *
90
+ * @returns {string[]} Array of project roots with cached policies
91
+ */
92
+ getCachedProjects(): string[];
93
+ /**
94
+ * Get cache statistics
95
+ *
96
+ * @returns {Object} Cache statistics
97
+ */
98
+ getCacheStats(): any;
99
+ }
100
+ export const defaultPolicyManager: PolicyManager;
101
+ export declare function loadPolicy(projectRoot: any, options: any): Promise<any>;
102
+ export declare function clearCache(projectRoot: any): void;
103
+ export declare function getCacheStatus(projectRoot: any): any;
104
+ //# sourceMappingURL=PolicyManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PolicyManager.d.ts","sourceRoot":"","sources":["../../src/policy/PolicyManager.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH;IACE,0BAIC;IAHC,mBAAkD;IAClD,cAA0C;IAC1C,2BAA4B;IAG9B;;;;;;;;OAQG;IACH,wBANW,MAAM,YAEd;QAAyB,QAAQ,EAAzB,OAAO;QACS,QAAQ,EAAxB,MAAM;KACd,GAAU,OAAO,KAAQ,CAuE3B;IAED;;;;;;OAMG;IACH,qBAJW,MAAM,eACN,MAAM,GACJ,OAAO,CAAC,MAAO,IAAI,CAAC,CAchC;IAED;;;;;OAKG;IACH,4BAFa,OAAO,CA2BnB;IAED;;;;;;;OAOG;IACH,uCAJW,MAAM,EAAE,eACR,MAAM,GACJ,OAAO,KAAQ,CA2B3B;IAED;;;;;OAKG;IACH,kCA8BC;IAED;;;;;;OAMG;IACH,wBAoDC;IAED;;;;OAIG;IACH,yBAFW,MAAM,QAQhB;IAED;;;;;OAKG;IACH,4BAHW,MAAM,OAmBhB;IAED;;;;;OAKG;IACH,0BAHW,MAAM,GACJ,OAAO,KAAQ,CAK3B;IAED;;;;OAIG;IACH,qBAFa,MAAM,EAAE,CAIpB;IAED;;;;OAIG;IACH,qBA2BC;CACF;AAGD,iDAAiD;AAOnC,iFAA+E;AAC/E,2DAA6D;AACzD,8DAAiE"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Scaffold Cursor hooks for a CAWS project
3
+ * @param {string} projectDir - Project directory path
4
+ * @param {string[]} levels - Hook levels to enable
5
+ */
6
+ export function scaffoldCursorHooks(projectDir: string, levels?: string[]): Promise<void>;
7
+ //# sourceMappingURL=cursor-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor-hooks.d.ts","sourceRoot":"","sources":["../../src/scaffold/cursor-hooks.js"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,gDAHW,MAAM,WACN,MAAM,EAAE,iBAqJlB"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Scaffold git hooks for CAWS provenance tracking
3
+ * @param {string} projectDir - Project directory path
4
+ * @param {Object} options - Hook options
5
+ */
6
+ export function scaffoldGitHooks(projectDir: string, options?: any): Promise<{
7
+ added: number;
8
+ skipped: number;
9
+ }>;
10
+ /**
11
+ * Remove CAWS git hooks
12
+ * @param {string} projectDir - Project directory path
13
+ */
14
+ export function removeGitHooks(projectDir: string): Promise<void>;
15
+ /**
16
+ * Check git hooks status
17
+ * @param {string} projectDir - Project directory path
18
+ */
19
+ export function checkGitHooksStatus(projectDir: string): Promise<void>;
20
+ //# sourceMappingURL=git-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-hooks.d.ts","sourceRoot":"","sources":["../../src/scaffold/git-hooks.js"],"names":[],"mappings":"AASA;;;;GAIG;AACH,6CAHW,MAAM;;;GAwGhB;AAwND;;;GAGG;AACH,2CAFW,MAAM,iBAkChB;AAED;;;GAGG;AACH,gDAFW,MAAM,iBAgDhB"}
@@ -147,10 +147,36 @@ fi
147
147
 
148
148
  QUALITY_GATES_RAN=false
149
149
 
150
- # Option 1: Node.js quality gates script
151
- if [ -f "scripts/quality-gates/run-quality-gates.js" ]; then
150
+ # Option 1: Quality gates package (installed via npm)
151
+ if [ -f "node_modules/@paths.design/quality-gates/run-quality-gates.mjs" ]; then
152
152
  if command -v node >/dev/null 2>&1; then
153
- echo "📁 Running Node.js quality gates script..."
153
+ echo "📁 Running quality gates package..."
154
+ if node node_modules/@paths.design/quality-gates/run-quality-gates.mjs --ci; then
155
+ echo "✅ Quality gates passed"
156
+ QUALITY_GATES_RAN=true
157
+ else
158
+ echo "❌ Quality gates failed - commit blocked"
159
+ echo "💡 Fix the violations above before committing"
160
+ exit 1
161
+ fi
162
+ fi
163
+ # Option 1b: Quality gates package (monorepo/local copy)
164
+ elif [ -f "node_modules/@caws/quality-gates/run-quality-gates.mjs" ]; then
165
+ if command -v node >/dev/null 2>&1; then
166
+ echo "📁 Running quality gates package (local)..."
167
+ if node node_modules/@caws/quality-gates/run-quality-gates.mjs --ci; then
168
+ echo "✅ Quality gates passed"
169
+ QUALITY_GATES_RAN=true
170
+ else
171
+ echo "❌ Quality gates failed - commit blocked"
172
+ echo "💡 Fix the violations above before committing"
173
+ exit 1
174
+ fi
175
+ fi
176
+ # Option 2: Legacy Node.js quality gates script (deprecated)
177
+ elif [ -f "scripts/quality-gates/run-quality-gates.js" ]; then
178
+ if command -v node >/dev/null 2>&1; then
179
+ echo "📁 Running legacy Node.js quality gates script..."
154
180
  if node scripts/quality-gates/run-quality-gates.js; then
155
181
  echo "✅ Quality gates passed"
156
182
  QUALITY_GATES_RAN=true
@@ -160,7 +186,7 @@ if [ -f "scripts/quality-gates/run-quality-gates.js" ]; then
160
186
  exit 1
161
187
  fi
162
188
  fi
163
- # Option 2: CAWS CLI validation
189
+ # Option 3: CAWS CLI validation
164
190
  elif command -v caws >/dev/null 2>&1; then
165
191
  echo "📋 Running CAWS CLI validation..."
166
192
  if caws validate --quiet 2>/dev/null; then
@@ -195,16 +221,48 @@ elif [ -f "scripts/simple_gates.py" ] && command -v python3 >/dev/null 2>&1; the
195
221
  else
196
222
  echo "⚠️ Quality gates not available - skipping"
197
223
  echo "💡 Available options:"
198
- echo " • Install: npm install -g @paths.design/caws-cli"
224
+ echo " • Install quality gates: npm install --save-dev @paths.design/quality-gates"
225
+ echo " • Install CAWS CLI: npm install -g @paths.design/caws-cli"
199
226
  echo " • Use Python: python3 scripts/simple_gates.py"
200
227
  echo " • Use Makefile: make caws-gates"
201
228
  QUALITY_GATES_RAN=true
202
229
  fi
203
230
 
204
- # Run hidden TODO analysis on staged files only (if Python available)
231
+ # Run hidden TODO analysis on staged files only (if available)
205
232
  if [ "$QUALITY_GATES_RAN" = true ]; then
206
233
  echo "🔍 Checking for hidden TODOs in staged files..."
207
- if command -v python3 >/dev/null 2>&1 && [ -f "scripts/v3/analysis/todo_analyzer.py" ]; then
234
+ # Try quality gates package TODO analyzer first (published package)
235
+ if [ -f "node_modules/@paths.design/quality-gates/todo-analyzer.mjs" ]; then
236
+ if command -v node >/dev/null 2>&1; then
237
+ if node node_modules/@paths.design/quality-gates/todo-analyzer.mjs --staged-only --ci-mode --min-confidence 0.8 >/dev/null 2>&1; then
238
+ echo "✅ No critical hidden TODOs found in staged files"
239
+ else
240
+ echo "❌ Critical hidden TODOs detected in staged files - commit blocked"
241
+ echo "💡 Fix stub implementations and placeholder code before committing"
242
+ echo "📖 See docs/PLACEHOLDER-DETECTION-GUIDE.md for classification"
243
+ echo ""
244
+ echo "🔍 Running detailed analysis on staged files..."
245
+ node node_modules/@paths.design/quality-gates/todo-analyzer.mjs --staged-only --min-confidence 0.8
246
+ exit 1
247
+ fi
248
+ fi
249
+ # Try quality gates package TODO analyzer (monorepo/local copy)
250
+ elif [ -f "node_modules/@caws/quality-gates/todo-analyzer.mjs" ]; then
251
+ if command -v node >/dev/null 2>&1; then
252
+ if node node_modules/@caws/quality-gates/todo-analyzer.mjs --staged-only --ci-mode --min-confidence 0.8 >/dev/null 2>&1; then
253
+ echo "✅ No critical hidden TODOs found in staged files"
254
+ else
255
+ echo "❌ Critical hidden TODOs detected in staged files - commit blocked"
256
+ echo "💡 Fix stub implementations and placeholder code before committing"
257
+ echo "📖 See docs/PLACEHOLDER-DETECTION-GUIDE.md for classification"
258
+ echo ""
259
+ echo "🔍 Running detailed analysis on staged files..."
260
+ node node_modules/@caws/quality-gates/todo-analyzer.mjs --staged-only --min-confidence 0.8
261
+ exit 1
262
+ fi
263
+ fi
264
+ # Fallback to legacy Python analyzer
265
+ elif command -v python3 >/dev/null 2>&1 && [ -f "scripts/v3/analysis/todo_analyzer.py" ]; then
208
266
  if python3 scripts/v3/analysis/todo_analyzer.py --staged-only --ci-mode --min-confidence 0.8 >/dev/null 2>&1; then
209
267
  echo "✅ No critical hidden TODOs found in staged files"
210
268
  else
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Scaffold existing project with CAWS components
3
+ * @param {Object} options - Scaffold options
4
+ */
5
+ export function scaffoldProject(options: any): Promise<void>;
6
+ /**
7
+ * Scaffold IDE integrations for comprehensive CAWS development experience
8
+ * @param {string} targetDir - Target directory for scaffolding
9
+ * @param {Object} options - Scaffold options
10
+ */
11
+ export function scaffoldIDEIntegrations(targetDir: string, options: any): Promise<{
12
+ added: number;
13
+ skipped: number;
14
+ }>;
15
+ /**
16
+ * Set dependencies for scaffold module
17
+ * @param {Object} deps - Dependencies object
18
+ */
19
+ export function setScaffoldDependencies(deps: any): void;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scaffold/index.js"],"names":[],"mappings":"AAkKA;;;GAGG;AACH,6DA6VC;AAhfD;;;;GAIG;AACH,mDAHW,MAAM;;;GA8HhB;AAMD;;;GAGG;AACH,yDAGC"}
@@ -10,6 +10,7 @@ const chalk = require('chalk');
10
10
 
11
11
  // Import detection utilities
12
12
  const { detectCAWSSetup } = require('../utils/detection');
13
+ const { detectsPublishing } = require('../utils/project-analysis');
13
14
 
14
15
  // Import git hooks scaffolding
15
16
  const { scaffoldGitHooks } = require('./git-hooks');
@@ -311,47 +312,152 @@ async function scaffoldProject(options) {
311
312
  },
312
313
  });
313
314
 
314
- // Add quality gates scripts for staged file analysis
315
- enhancements.push({
316
- name: 'scripts/quality-gates/run-quality-gates.js',
317
- description: 'Quality gates runner for staged files',
318
- required: false,
319
- });
315
+ // Add quality gates package and configuration if requested
316
+ // Note: These are optional - git hooks fall back to CAWS CLI if package isn't installed
317
+ if (options.withQualityGates) {
318
+ // Copy quality gates configuration files from templates
319
+ enhancements.push({
320
+ name: 'duplication.qualitygatesrc.yaml',
321
+ description: 'Duplication gate configuration',
322
+ required: false,
323
+ sourcePath: path.join(
324
+ __dirname,
325
+ '../../quality-gates/templates/duplication.qualitygatesrc.yaml'
326
+ ),
327
+ });
320
328
 
321
- enhancements.push({
322
- name: 'scripts/quality-gates/check-god-objects.js',
323
- description: 'God object detector for staged files',
324
- required: false,
325
- });
329
+ enhancements.push({
330
+ name: 'godObject.qualitygatesrc.yaml',
331
+ description: 'God objects gate configuration',
332
+ required: false,
333
+ sourcePath: path.join(
334
+ __dirname,
335
+ '../../quality-gates/templates/godObject.qualitygatesrc.yaml'
336
+ ),
337
+ });
326
338
 
327
- enhancements.push({
328
- name: 'scripts/v3/analysis/todo_analyzer.py',
329
- description: 'Advanced hidden TODO analyzer with dependency resolution',
330
- required: false,
331
- });
339
+ // Create docs-status directory structure
340
+ enhancements.push({
341
+ name: 'docs-status',
342
+ description: 'Quality gates status directory',
343
+ required: false,
344
+ customHandler: async (targetDir) => {
345
+ const docsStatusDir = path.join(targetDir, 'docs-status');
346
+ await fs.ensureDir(docsStatusDir);
347
+
348
+ // Copy template files from quality-gates package
349
+ const qualityGatesTemplates = path.join(
350
+ __dirname,
351
+ '../../quality-gates/templates/docs-status'
352
+ );
353
+ if (fs.existsSync(qualityGatesTemplates)) {
354
+ await fs.copy(qualityGatesTemplates, docsStatusDir);
355
+ return { added: 1, skipped: 0 };
356
+ }
357
+ return { added: 1, skipped: 0 };
358
+ },
359
+ });
332
360
 
333
- // Install quality gates package if requested
334
- if (options.withQualityGates) {
335
- console.log(chalk.blue('\n📦 Installing quality gates package...'));
361
+ // Install quality gates package
362
+ console.log(chalk.blue('\n📦 Setting up quality gates package...'));
336
363
  try {
337
364
  const { execSync } = require('child_process');
338
- const npmCommand = fs.existsSync(path.join(currentDir, 'package.json'))
339
- ? 'npm install --save-dev @paths.design/quality-gates'
340
- : 'npm install -g @paths.design/quality-gates';
341
-
342
- console.log(chalk.gray(` Running: ${npmCommand}`));
343
- execSync(npmCommand, {
344
- cwd: currentDir,
345
- stdio: 'inherit',
346
- });
347
- console.log(chalk.green('✅ Quality gates package installed'));
348
- console.log(chalk.blue('💡 You can now use: caws quality-gates'));
365
+
366
+ // Check if we're in monorepo (can copy files directly) or need npm install
367
+ const qualityGatesPath = path.resolve(__dirname, '../../../quality-gates');
368
+ const isMonorepo = fs.existsSync(qualityGatesPath);
369
+
370
+ if (isMonorepo && fs.existsSync(path.join(currentDir, 'package.json'))) {
371
+ // In monorepo - copy files directly instead of installing package
372
+ console.log(
373
+ chalk.gray(' Detected monorepo structure - copying quality gates files...')
374
+ );
375
+
376
+ const qualityGatesDest = path.join(currentDir, 'node_modules', '@caws', 'quality-gates');
377
+ await fs.ensureDir(qualityGatesDest);
378
+
379
+ // Copy all .mjs files
380
+ const mjsFiles = fs.readdirSync(qualityGatesPath).filter((f) => f.endsWith('.mjs'));
381
+ for (const file of mjsFiles) {
382
+ await fs.copy(path.join(qualityGatesPath, file), path.join(qualityGatesDest, file));
383
+ }
384
+
385
+ // Copy templates directory
386
+ if (fs.existsSync(path.join(qualityGatesPath, 'templates'))) {
387
+ await fs.copy(
388
+ path.join(qualityGatesPath, 'templates'),
389
+ path.join(qualityGatesDest, 'templates')
390
+ );
391
+ }
392
+
393
+ // Copy package.json for dependencies
394
+ await fs.copy(
395
+ path.join(qualityGatesPath, 'package.json'),
396
+ path.join(qualityGatesDest, 'package.json')
397
+ );
398
+
399
+ // Install dependencies
400
+ console.log(chalk.gray(' Installing quality gates dependencies...'));
401
+ execSync('npm install --production --no-audit --no-fund', {
402
+ cwd: qualityGatesDest,
403
+ stdio: 'inherit',
404
+ });
405
+
406
+ console.log(chalk.green('✅ Quality gates files copied and dependencies installed'));
407
+ } else if (fs.existsSync(path.join(currentDir, 'package.json'))) {
408
+ // Regular project - try to install from npm (when published)
409
+ console.log(chalk.gray(' Installing @paths.design/quality-gates package...'));
410
+
411
+ try {
412
+ const npmCommand = 'npm install --save-dev @paths.design/quality-gates';
413
+ execSync(npmCommand, {
414
+ cwd: currentDir,
415
+ stdio: 'inherit',
416
+ });
417
+ console.log(chalk.green('✅ Quality gates package installed from npm'));
418
+ } catch (npmError) {
419
+ console.log(
420
+ chalk.yellow('⚠️ Package not found on npm - quality gates will use local files')
421
+ );
422
+ console.log(
423
+ chalk.gray(
424
+ ' Package will be available once published as @paths.design/quality-gates'
425
+ )
426
+ );
427
+ console.log(
428
+ chalk.gray(' For now, quality gates will work via CAWS CLI or local scripts')
429
+ );
430
+ }
431
+ } else {
432
+ // No package.json - suggest global install or manual setup
433
+ console.log(chalk.yellow('⚠️ No package.json found - skipping package installation'));
434
+ console.log(chalk.gray(' Options:'));
435
+ console.log(
436
+ chalk.gray(' • Install globally: npm install -g @paths.design/quality-gates')
437
+ );
438
+ console.log(
439
+ chalk.gray(
440
+ ' • Create package.json and run: npm install --save-dev @paths.design/quality-gates'
441
+ )
442
+ );
443
+ console.log(chalk.gray(' • Use CAWS CLI: caws quality-gates'));
444
+ }
445
+
446
+ console.log(
447
+ chalk.blue(
448
+ '💡 You can now use: node node_modules/@paths.design/quality-gates/run-quality-gates.mjs'
449
+ )
450
+ );
451
+ console.log(chalk.blue(' Or: caws quality-gates'));
349
452
  } catch (error) {
350
- console.log(chalk.yellow(`⚠️ Failed to install quality gates package: ${error.message}`));
453
+ console.log(chalk.yellow(`⚠️ Failed to set up quality gates package: ${error.message}`));
351
454
  console.log(
352
- chalk.gray(' You can install manually: npm install -g @paths.design/quality-gates')
455
+ chalk.gray(
456
+ ' You can install manually: npm install --save-dev @paths.design/quality-gates'
457
+ )
353
458
  );
354
- console.log(chalk.gray(' Or use Python scripts: python3 scripts/simple_gates.py'));
459
+ console.log(chalk.gray(' Or globally: npm install -g @paths.design/quality-gates'));
460
+ console.log(chalk.gray(' Or use CAWS CLI: caws quality-gates'));
355
461
  }
356
462
  }
357
463
 
@@ -377,16 +483,26 @@ async function scaffoldProject(options) {
377
483
  });
378
484
  }
379
485
 
380
- // Add OIDC setup guide if requested or not minimal
381
- if (
382
- (options.withOidc || (!options.minimal && !options.withOidc)) &&
383
- (!setup.isEnhanced || !fs.existsSync(path.join(currentDir, 'OIDC_SETUP.md')))
384
- ) {
486
+ // Add OIDC setup guide only if:
487
+ // 1. Explicitly requested with --with-oidc flag, OR
488
+ // 2. Project detects publishing configuration (package.json with publishConfig, pyproject.toml, etc.)
489
+ const needsOidc = options.withOidc || detectsPublishing(currentDir);
490
+ const oidcExists = fs.existsSync(path.join(currentDir, 'OIDC_SETUP.md'));
491
+
492
+ if (needsOidc && !oidcExists) {
385
493
  enhancements.push({
386
494
  name: 'OIDC_SETUP.md',
387
495
  description: 'OIDC trusted publisher setup guide',
388
496
  required: false,
389
497
  });
498
+ } else if (needsOidc && oidcExists) {
499
+ console.log(chalk.gray('⏭️ Skipped OIDC_SETUP.md (already exists)'));
500
+ } else if (!needsOidc && !options.minimal) {
501
+ // Inform user that OIDC is available but not needed
502
+ console.log(
503
+ chalk.blue('ℹ️ OIDC setup skipped (project does not appear to publish packages)')
504
+ );
505
+ console.log(chalk.gray(' Add --with-oidc flag if you plan to publish packages later'));
390
506
  }
391
507
 
392
508
  // For enhanced setups, preserve existing tools
@@ -424,13 +540,20 @@ async function scaffoldProject(options) {
424
540
  continue;
425
541
  }
426
542
 
427
- if (!setup?.templateDir) {
543
+ // Handle custom sourcePath (for quality gates configs from monorepo)
544
+ const sourcePath = enhancement.sourcePath
545
+ ? enhancement.sourcePath
546
+ : setup?.templateDir
547
+ ? path.join(setup.templateDir, enhancement.name)
548
+ : null;
549
+
550
+ if (!sourcePath && !enhancement.sourcePath) {
428
551
  console.warn(
429
552
  chalk.yellow(`⚠️ Template directory not available for enhancement: ${enhancement.name}`)
430
553
  );
431
554
  continue;
432
555
  }
433
- const sourcePath = path.join(setup.templateDir, enhancement.name);
556
+
434
557
  const destPath = path.join(currentDir, enhancement.name);
435
558
 
436
559
  if (!fs.existsSync(destPath)) {
@@ -497,6 +620,10 @@ async function scaffoldProject(options) {
497
620
 
498
621
  // Check if OIDC was added
499
622
  const oidcAdded = addedFiles.some((file) => file.includes('OIDC_SETUP'));
623
+ const qualityGatesAdded = addedFiles.some(
624
+ (file) => file.includes('quality-gates') || file.includes('todo_analyzer')
625
+ );
626
+
500
627
  if (oidcAdded) {
501
628
  console.log('2. Set up OIDC trusted publisher (see OIDC_SETUP.md)');
502
629
  console.log('3. Push to trigger automated publishing');
@@ -504,7 +631,18 @@ async function scaffoldProject(options) {
504
631
  } else {
505
632
  console.log('2. Customize your working spec in .caws/working-spec.yaml');
506
633
  console.log('3. Run validation: caws validate --suggestions');
507
- console.log('4. Your existing CAWS tools remain unchanged');
634
+ if (!qualityGatesAdded && !options.minimal) {
635
+ console.log(
636
+ chalk.gray('4. Note: Quality gates scripts skipped (git hooks use CAWS CLI by default)')
637
+ );
638
+ console.log(
639
+ chalk.gray(
640
+ ' Add --with-quality-gates flag if you want local scripts without global CLI'
641
+ )
642
+ );
643
+ } else {
644
+ console.log('4. Your existing CAWS tools remain unchanged');
645
+ }
508
646
  }
509
647
  }
510
648