@paths.design/caws-cli 7.0.0 → 7.0.2

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 (112) 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/diagnose.js +3 -2
  12. package/dist/commands/evaluate.d.ts +8 -0
  13. package/dist/commands/evaluate.d.ts.map +1 -0
  14. package/dist/commands/init.d.ts +5 -0
  15. package/dist/commands/init.d.ts.map +1 -0
  16. package/dist/commands/init.js +23 -3
  17. package/dist/commands/iterate.d.ts +8 -0
  18. package/dist/commands/iterate.d.ts.map +1 -0
  19. package/dist/commands/mode.d.ts +24 -0
  20. package/dist/commands/mode.d.ts.map +1 -0
  21. package/dist/commands/plan.d.ts +49 -0
  22. package/dist/commands/plan.d.ts.map +1 -0
  23. package/dist/commands/provenance.d.ts +32 -0
  24. package/dist/commands/provenance.d.ts.map +1 -0
  25. package/dist/commands/quality-gates.d.ts +52 -0
  26. package/dist/commands/quality-gates.d.ts.map +1 -0
  27. package/dist/commands/quality-monitor.d.ts +17 -0
  28. package/dist/commands/quality-monitor.d.ts.map +1 -0
  29. package/dist/commands/specs.d.ts +71 -0
  30. package/dist/commands/specs.d.ts.map +1 -0
  31. package/dist/commands/status.d.ts +44 -0
  32. package/dist/commands/status.d.ts.map +1 -0
  33. package/dist/commands/templates.d.ts +74 -0
  34. package/dist/commands/templates.d.ts.map +1 -0
  35. package/dist/commands/templates.js +10 -0
  36. package/dist/commands/tool.d.ts +13 -0
  37. package/dist/commands/tool.d.ts.map +1 -0
  38. package/dist/commands/troubleshoot.d.ts +8 -0
  39. package/dist/commands/troubleshoot.d.ts.map +1 -0
  40. package/dist/commands/tutorial.d.ts +55 -0
  41. package/dist/commands/tutorial.d.ts.map +1 -0
  42. package/dist/commands/validate.d.ts +15 -0
  43. package/dist/commands/validate.d.ts.map +1 -0
  44. package/dist/commands/validate.js +12 -0
  45. package/dist/commands/waivers.d.ts +8 -0
  46. package/dist/commands/waivers.d.ts.map +1 -0
  47. package/dist/commands/workflow.d.ts +85 -0
  48. package/dist/commands/workflow.d.ts.map +1 -0
  49. package/dist/config/index.d.ts +29 -0
  50. package/dist/config/index.d.ts.map +1 -0
  51. package/dist/config/modes.d.ts +225 -0
  52. package/dist/config/modes.d.ts.map +1 -0
  53. package/dist/constants/spec-types.d.ts +41 -0
  54. package/dist/constants/spec-types.d.ts.map +1 -0
  55. package/dist/error-handler.d.ts +164 -0
  56. package/dist/error-handler.d.ts.map +1 -0
  57. package/dist/generators/jest-config.d.ts +32 -0
  58. package/dist/generators/jest-config.d.ts.map +1 -0
  59. package/dist/generators/working-spec.d.ts +13 -0
  60. package/dist/generators/working-spec.d.ts.map +1 -0
  61. package/dist/generators/working-spec.js +26 -6
  62. package/dist/index-new.d.ts +5 -0
  63. package/dist/index-new.d.ts.map +1 -0
  64. package/dist/index-new.js +317 -0
  65. package/dist/index.d.ts +5 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js.backup +4711 -0
  68. package/dist/minimal-cli.d.ts +3 -0
  69. package/dist/minimal-cli.d.ts.map +1 -0
  70. package/dist/policy/PolicyManager.d.ts +104 -0
  71. package/dist/policy/PolicyManager.d.ts.map +1 -0
  72. package/dist/scaffold/cursor-hooks.d.ts +7 -0
  73. package/dist/scaffold/cursor-hooks.d.ts.map +1 -0
  74. package/dist/scaffold/cursor-hooks.js +10 -2
  75. package/dist/scaffold/git-hooks.d.ts +20 -0
  76. package/dist/scaffold/git-hooks.d.ts.map +1 -0
  77. package/dist/scaffold/git-hooks.js +62 -3
  78. package/dist/scaffold/index.d.ts +20 -0
  79. package/dist/scaffold/index.d.ts.map +1 -0
  80. package/dist/scaffold/index.js +57 -15
  81. package/dist/spec/SpecFileManager.d.ts +146 -0
  82. package/dist/spec/SpecFileManager.d.ts.map +1 -0
  83. package/dist/test-analysis.d.ts +182 -0
  84. package/dist/test-analysis.d.ts.map +1 -0
  85. package/dist/tool-interface.d.ts +236 -0
  86. package/dist/tool-interface.d.ts.map +1 -0
  87. package/dist/tool-loader.d.ts +77 -0
  88. package/dist/tool-loader.d.ts.map +1 -0
  89. package/dist/tool-validator.d.ts +72 -0
  90. package/dist/tool-validator.d.ts.map +1 -0
  91. package/dist/utils/detection.d.ts +7 -0
  92. package/dist/utils/detection.d.ts.map +1 -0
  93. package/dist/utils/detection.js +30 -3
  94. package/dist/utils/finalization.d.ts +17 -0
  95. package/dist/utils/finalization.d.ts.map +1 -0
  96. package/dist/utils/project-analysis.d.ts +14 -0
  97. package/dist/utils/project-analysis.d.ts.map +1 -0
  98. package/dist/utils/quality-gates.d.ts +49 -0
  99. package/dist/utils/quality-gates.d.ts.map +1 -0
  100. package/dist/utils/spec-resolver.d.ts +88 -0
  101. package/dist/utils/spec-resolver.d.ts.map +1 -0
  102. package/dist/utils/typescript-detector.d.ts +63 -0
  103. package/dist/utils/typescript-detector.d.ts.map +1 -0
  104. package/dist/validation/spec-validation.d.ts +43 -0
  105. package/dist/validation/spec-validation.d.ts.map +1 -0
  106. package/dist/validation/spec-validation.js +26 -2
  107. package/dist/waivers-manager.d.ts +167 -0
  108. package/dist/waivers-manager.d.ts.map +1 -0
  109. package/package.json +1 -1
  110. package/templates/COMMIT_CONVENTIONS.md +86 -0
  111. package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
  112. 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"}
@@ -9,7 +9,7 @@ const path = require('path');
9
9
  const chalk = require('chalk');
10
10
 
11
11
  // Import detection utilities
12
- const { detectCAWSSetup } = require('../utils/detection');
12
+ const { detectCAWSSetup, findPackageRoot } = require('../utils/detection');
13
13
 
14
14
  /**
15
15
  * Scaffold Cursor hooks for a CAWS project
@@ -28,9 +28,17 @@ async function scaffoldCursorHooks(projectDir, levels = ['safety', 'quality', 's
28
28
 
29
29
  // Determine template directory - prefer bundled templates
30
30
  const setup = detectCAWSSetup(projectDir);
31
- const bundledTemplateDir = path.join(__dirname, '../../templates');
31
+
32
+ // Find package root using shared utility
33
+ const packageRoot = findPackageRoot(__dirname);
34
+
35
+ // Try templates relative to package root first (works in both dev and global install)
36
+ const bundledTemplateDir = path.join(packageRoot, 'templates');
37
+ const fallbackTemplateDir = path.join(__dirname, '../../templates');
32
38
  const templateDir = fs.existsSync(bundledTemplateDir)
33
39
  ? bundledTemplateDir
40
+ : fs.existsSync(fallbackTemplateDir)
41
+ ? fallbackTemplateDir
34
42
  : setup.templateDir || path.resolve(__dirname, '../templates');
35
43
 
36
44
  const cursorTemplateDir = path.join(templateDir, '.cursor');
@@ -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"}
@@ -364,12 +364,71 @@ fi
364
364
  # Run full validation suite
365
365
  if command -v caws >/dev/null 2>&1; then
366
366
  echo "📋 Running comprehensive CAWS validation..."
367
- if caws validate --quiet; then
367
+
368
+ # Run validation and capture output
369
+ VALIDATION_OUTPUT=$(caws validate 2>&1)
370
+ VALIDATION_EXIT=$?
371
+
372
+ if [ $VALIDATION_EXIT -eq 0 ]; then
368
373
  echo "✅ CAWS validation passed"
369
374
  else
370
375
  echo "❌ CAWS validation failed"
371
- echo "💡 Fix issues locally, then push again"
372
- echo "💡 You can commit fixes with: git commit --no-verify"
376
+ echo ""
377
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
378
+ echo "Validation Errors:"
379
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
380
+ echo "$VALIDATION_OUTPUT" | grep -E "(❌|error|Error|Missing|required)" || echo "$VALIDATION_OUTPUT"
381
+ echo ""
382
+
383
+ # Check for contract-related errors
384
+ if echo "$VALIDATION_OUTPUT" | grep -qi "contract"; then
385
+ echo "💡 Contract Requirements:"
386
+ echo " • Tier 1 & 2 changes require at least one contract"
387
+ echo " • For infrastructure/setup work, use 'chore' mode or add a minimal contract:"
388
+ echo ""
389
+ echo " Example minimal contract (.caws/working-spec.yaml):"
390
+ echo " contracts:"
391
+ echo " - type: 'project_setup'"
392
+ echo " path: '.caws/working-spec.yaml'"
393
+ echo " description: 'Project-level CAWS configuration'"
394
+ echo ""
395
+ echo " Or change mode to 'chore' for maintenance work:"
396
+ echo " mode: chore"
397
+ echo ""
398
+ fi
399
+
400
+ # Check for active waivers
401
+ echo "🔍 Checking for active waivers..."
402
+ if command -v caws >/dev/null 2>&1 && caws waivers list --status=active --format=count 2>/dev/null | grep -q "[1-9]"; then
403
+ ACTIVE_WAIVERS=$(caws waivers list --status=active 2>/dev/null)
404
+ echo "⚠️ Active waivers found:"
405
+ echo "$ACTIVE_WAIVERS" | head -5
406
+ echo ""
407
+ echo "💡 Note: Waivers may not cover all validation failures"
408
+ echo " Review waiver coverage: caws waivers list --status=active"
409
+ else
410
+ echo " No active waivers found"
411
+ echo ""
412
+ echo "💡 If this is infrastructure/setup work, you can create a waiver:"
413
+ echo " caws waivers create \\"
414
+ echo " --title='Initial CAWS setup' \\"
415
+ echo " --reason=infrastructure_limitation \\"
416
+ echo " --gates=contracts \\"
417
+ echo " --expires-at='2024-12-31T23:59:59Z' \\"
418
+ echo " --approved-by='@your-team' \\"
419
+ echo " --impact-level=low \\"
420
+ echo " --mitigation-plan='Contracts will be added as features are developed'"
421
+ fi
422
+
423
+ echo ""
424
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
425
+ echo "Next Steps:"
426
+ echo " 1. Review errors above"
427
+ echo " 2. Fix issues in .caws/working-spec.yaml"
428
+ echo " 3. Run: caws validate (to verify fixes)"
429
+ echo " 4. Commit fixes: git commit --no-verify (allowed)"
430
+ echo " 5. Push again: git push"
431
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
373
432
  exit 1
374
433
  fi
375
434
  fi
@@ -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"}
@@ -9,7 +9,7 @@ const path = require('path');
9
9
  const chalk = require('chalk');
10
10
 
11
11
  // Import detection utilities
12
- const { detectCAWSSetup } = require('../utils/detection');
12
+ const { detectCAWSSetup, findPackageRoot } = require('../utils/detection');
13
13
  const { detectsPublishing } = require('../utils/project-analysis');
14
14
 
15
15
  // Import git hooks scaffolding
@@ -23,8 +23,33 @@ const CLI_VERSION = require('../../package.json').version;
23
23
  * @param {string} targetDir - Target directory for scaffolding
24
24
  * @param {Object} options - Scaffold options
25
25
  */
26
+ /**
27
+ * Find the template directory using robust path resolution
28
+ * Works in both development and global install scenarios
29
+ * @returns {string|null} Template directory path or null
30
+ */
31
+ function findTemplateDir() {
32
+ // Find package root using shared utility
33
+ const packageRoot = findPackageRoot(__dirname);
34
+
35
+ // Try templates relative to package root first (works in both dev and global install)
36
+ const possiblePaths = [
37
+ path.join(packageRoot, 'templates'),
38
+ path.resolve(__dirname, '../../templates'), // Dev fallback
39
+ path.resolve(__dirname, '../templates'), // Legacy fallback
40
+ ];
41
+
42
+ for (const testPath of possiblePaths) {
43
+ if (fs.existsSync(testPath)) {
44
+ return testPath;
45
+ }
46
+ }
47
+
48
+ return null;
49
+ }
50
+
26
51
  async function scaffoldIDEIntegrations(targetDir, options) {
27
- const templateDir = path.join(__dirname, '../../templates');
52
+ const templateDir = findTemplateDir() || path.join(__dirname, '../../templates');
28
53
 
29
54
  console.log(chalk.cyan('🎨 Setting up IDE integrations...'));
30
55
 
@@ -192,19 +217,24 @@ async function scaffoldProject(options) {
192
217
  setup.templateDir = cawsSetup.templateDir;
193
218
  setup.hasTemplateDir = true;
194
219
  } else if (!setup.templateDir) {
195
- // Try to find template directory using absolute paths that work in CI
220
+ // Try to find template directory using robust path resolution
196
221
  const possiblePaths = [
197
- // 1. Bundled templates in CLI package (for global installs) - CHECK THIS FIRST!
222
+ // 1. Use the helper function to find templates (works in dev and global install)
223
+ findTemplateDir(),
224
+ // 2. Bundled templates relative to package root
225
+ path.join(findPackageRoot(__dirname), 'templates'),
226
+ // 3. Legacy fallback paths
198
227
  path.join(__dirname, '../../templates'),
199
- // 2. CI paths
228
+ path.join(__dirname, '../templates'),
229
+ // 4. CI paths
200
230
  '/home/runner/work/coding-agent-working-standard/coding-agent-working-standard/packages/caws-template',
201
231
  '/workspace/packages/caws-template',
202
232
  '/caws/packages/caws-template',
203
- // 3. Monorepo relative paths
233
+ // 5. Monorepo relative paths
204
234
  path.resolve(process.cwd(), '../../../packages/caws-template'),
205
235
  path.resolve(process.cwd(), '../../packages/caws-template'),
206
236
  path.resolve(process.cwd(), '../packages/caws-template'),
207
- ];
237
+ ].filter(Boolean); // Remove null values
208
238
 
209
239
  for (const testPath of possiblePaths) {
210
240
  if (fs.existsSync(testPath)) {
@@ -567,10 +597,22 @@ async function scaffoldProject(options) {
567
597
  console.warn(chalk.yellow(`⚠️ Failed to add ${enhancement.name}:`), copyError.message);
568
598
  }
569
599
  } else {
570
- // If source doesn't exist in template, create the directory structure
600
+ // If source doesn't exist in template, check if it should be a file or directory
571
601
  try {
572
- await fs.ensureDir(destPath);
573
- console.log(chalk.green(`✅ Created ${enhancement.description}`));
602
+ // Check if the enhancement name looks like a file (has extension)
603
+ const hasExtension = path.extname(enhancement.name).length > 0;
604
+
605
+ if (hasExtension) {
606
+ // Create an empty file for file-like enhancements
607
+ await fs.ensureDir(path.dirname(destPath));
608
+ await fs.writeFile(destPath, '');
609
+ console.log(chalk.yellow(`⚠️ Created empty ${enhancement.description} (template not found)`));
610
+ console.log(chalk.gray(` Template expected at: ${sourcePath}`));
611
+ } else {
612
+ // Create directory for directory-like enhancements
613
+ await fs.ensureDir(destPath);
614
+ console.log(chalk.green(`✅ Created ${enhancement.description}`));
615
+ }
574
616
  addedCount++;
575
617
  addedFiles.push(enhancement.name);
576
618
  } catch (createError) {
@@ -629,19 +671,19 @@ async function scaffoldProject(options) {
629
671
  console.log('3. Push to trigger automated publishing');
630
672
  console.log('4. Your existing CAWS tools remain unchanged');
631
673
  } else {
632
- console.log('2. Customize your working spec in .caws/working-spec.yaml');
633
- console.log('3. Run validation: caws validate --suggestions');
674
+ console.log('2. Run: caws validate (verify setup)');
675
+ console.log('3. Run: caws diagnose (check project health)');
676
+ console.log('4. Customize .caws/working-spec.yaml for your project');
677
+ console.log('5. Optional: Create .caws/policy.yaml for tier-specific budgets');
634
678
  if (!qualityGatesAdded && !options.minimal) {
635
679
  console.log(
636
- chalk.gray('4. Note: Quality gates scripts skipped (git hooks use CAWS CLI by default)')
680
+ chalk.gray('6. Note: Quality gates scripts skipped (git hooks use CAWS CLI by default)')
637
681
  );
638
682
  console.log(
639
683
  chalk.gray(
640
684
  ' Add --with-quality-gates flag if you want local scripts without global CLI'
641
685
  )
642
686
  );
643
- } else {
644
- console.log('4. Your existing CAWS tools remain unchanged');
645
687
  }
646
688
  }
647
689
  }
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Spec File Manager - Handles WorkingSpec file operations and YAML conversion
3
+ *
4
+ * Features:
5
+ * - Bidirectional WorkingSpec ↔ YAML conversion
6
+ * - Temporary file support for validation workflows
7
+ * - Backup/restore capabilities
8
+ * - Automatic cleanup of old temporary files
9
+ */
10
+ export class SpecFileManager {
11
+ constructor(config?: {});
12
+ projectRoot: any;
13
+ useTemporaryFiles: any;
14
+ tempDir: any;
15
+ /**
16
+ * Convert WorkingSpec object to YAML string
17
+ *
18
+ * @param {Object} spec - WorkingSpec to convert
19
+ * @returns {string} YAML string representation
20
+ */
21
+ specToYaml(spec: any): string;
22
+ /**
23
+ * Parse YAML string to WorkingSpec object
24
+ *
25
+ * @param {string} yamlContent - YAML string to parse
26
+ * @returns {Object} Parsed WorkingSpec object
27
+ * @throws {Error} If YAML is invalid or doesn't match WorkingSpec schema
28
+ */
29
+ yamlToSpec(yamlContent: string): any;
30
+ /**
31
+ * Get path to .caws/working-spec.yaml in project
32
+ *
33
+ * @returns {string} Absolute path to working spec file
34
+ */
35
+ getSpecFilePath(): string;
36
+ /**
37
+ * Check if working spec file exists
38
+ *
39
+ * @returns {Promise<boolean>} True if file exists
40
+ */
41
+ specFileExists(): Promise<boolean>;
42
+ /**
43
+ * Read working spec from .caws/working-spec.yaml
44
+ *
45
+ * @returns {Promise<Object>} Parsed WorkingSpec object
46
+ * @throws {Error} If file doesn't exist or is invalid
47
+ */
48
+ readSpecFile(): Promise<any>;
49
+ /**
50
+ * Write WorkingSpec to file
51
+ *
52
+ * Writes to .caws/working-spec.yaml or a temporary file based on configuration.
53
+ *
54
+ * @param {Object} spec - WorkingSpec to write
55
+ * @param {Object} options - Write options
56
+ * @param {boolean} options.useTemp - Override temp file usage
57
+ * @param {boolean} options.backup - Create backup before writing
58
+ * @returns {Promise<Object>} Write result with file path and cleanup function
59
+ */
60
+ writeSpecFile(spec: any, options?: {
61
+ useTemp: boolean;
62
+ backup: boolean;
63
+ }): Promise<any>;
64
+ /**
65
+ * Update existing working spec file
66
+ *
67
+ * Reads current spec, merges changes, and writes back.
68
+ *
69
+ * @param {Object} updates - Partial WorkingSpec with fields to update
70
+ * @returns {Promise<Object>} Updated WorkingSpec
71
+ */
72
+ updateSpecFile(updates: any): Promise<any>;
73
+ /**
74
+ * Create backup of working spec
75
+ *
76
+ * @returns {Promise<string>} Path to backup file
77
+ */
78
+ backupSpecFile(): Promise<string>;
79
+ /**
80
+ * Restore working spec from backup
81
+ *
82
+ * @param {string} backupPath - Path to backup file
83
+ * @returns {Promise<void>}
84
+ */
85
+ restoreSpecFile(backupPath: string): Promise<void>;
86
+ /**
87
+ * List all backup files
88
+ *
89
+ * @returns {Promise<string[]>} Array of backup file paths
90
+ */
91
+ listBackups(): Promise<string[]>;
92
+ /**
93
+ * Delete old backup files
94
+ *
95
+ * @param {Object} options - Cleanup options
96
+ * @param {number} options.maxAge - Maximum age in milliseconds (default: 7 days)
97
+ * @param {number} options.keep - Minimum number of backups to keep (default: 5)
98
+ * @returns {Promise<number>} Number of backups deleted
99
+ */
100
+ cleanupBackups(options?: {
101
+ maxAge: number;
102
+ keep: number;
103
+ }): Promise<number>;
104
+ /**
105
+ * Validate spec file exists and is parseable
106
+ *
107
+ * @returns {Promise<Object>} Validation result
108
+ */
109
+ validateSpecFile(): Promise<any>;
110
+ /**
111
+ * Clean up old temporary spec files
112
+ *
113
+ * Removes temp files older than specified age.
114
+ *
115
+ * @param {number} maxAge - Maximum age in milliseconds (default: 1 hour)
116
+ * @returns {Promise<number>} Number of files cleaned up
117
+ */
118
+ cleanupTempFiles(maxAge?: number): Promise<number>;
119
+ /**
120
+ * Get spec file stats (size, modified date, etc.)
121
+ *
122
+ * @returns {Promise<Object>} File stats
123
+ */
124
+ getSpecFileStats(): Promise<any>;
125
+ /**
126
+ * Create a new SpecFileManager instance with different configuration
127
+ *
128
+ * @param {Object} config - New configuration
129
+ * @returns {SpecFileManager} New instance
130
+ */
131
+ withConfig(config: any): SpecFileManager;
132
+ }
133
+ export const defaultSpecFileManager: SpecFileManager;
134
+ /**
135
+ * Create a SpecFileManager instance with default configuration
136
+ *
137
+ * @param {string} projectRoot - Project root directory
138
+ * @param {Object} options - Additional options
139
+ * @returns {SpecFileManager} SpecFileManager instance
140
+ */
141
+ export function createSpecFileManager(projectRoot: string, options?: any): SpecFileManager;
142
+ export declare function specToYaml(spec: any): string;
143
+ export declare function yamlToSpec(yaml: any): any;
144
+ export declare function readSpecFile(projectRoot: any): Promise<any>;
145
+ export declare function writeSpecFile(spec: any, projectRoot: any, options: any): Promise<any>;
146
+ //# sourceMappingURL=SpecFileManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpecFileManager.d.ts","sourceRoot":"","sources":["../../src/spec/SpecFileManager.js"],"names":[],"mappings":"AAaA;;;;;;;;GAQG;AACH;IACE,yBAIC;IAHC,iBAAsD;IACtD,uBAA0D;IAC1D,aAA4C;IAG9C;;;;;OAKG;IACH,uBAFa,MAAM,CASlB;IAED;;;;;;OAMG;IACH,wBAJW,MAAM,OAqBhB;IAED;;;;OAIG;IACH,mBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,kBAFa,OAAO,CAAC,OAAO,CAAC,CAS5B;IAED;;;;;OAKG;IACH,gBAHa,OAAO,KAAQ,CAe3B;IAED;;;;;;;;;;OAUG;IACH,mCAJG;QAAyB,OAAO,EAAxB,OAAO;QACU,MAAM,EAAvB,OAAO;KACf,GAAU,OAAO,KAAQ,CA2C3B;IAED;;;;;;;OAOG;IACH,8BAFa,OAAO,KAAQ,CAa3B;IAED;;;;OAIG;IACH,kBAFa,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;OAKG;IACH,4BAHW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAKzB;IAED;;;;OAIG;IACH,eAFa,OAAO,CAAC,MAAM,EAAE,CAAC,CAoB7B;IAED;;;;;;;OAOG;IACH,yBAJG;QAAwB,MAAM,EAAtB,MAAM;QACU,IAAI,EAApB,MAAM;KACd,GAAU,OAAO,CAAC,MAAM,CAAC,CA+B3B;IAED;;;;OAIG;IACH,oBAFa,OAAO,KAAQ,CAe3B;IAED;;;;;;;OAOG;IACH,0BAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CA6B3B;IAED;;;;OAIG;IACH,oBAFa,OAAO,KAAQ,CA0B3B;IAED;;;;;OAKG;IACH,yBAFa,eAAe,CAS3B;CACF;AAiBD,qDAAqD;AAfrD;;;;;;GAMG;AACH,mDAJW,MAAM,kBAEJ,eAAe,CAO3B;AAWa,sDAAiD;AACjD,mDAAiD;AAC/C,qEAKb;AACc,+FAKd"}