Files
ruflo/v2/scripts/fix-error-handling.cjs
T
rUvandClaude Opus 4.5 1b6a1971f7 feat(v3): add comprehensive v3 implementation plans and swarm architecture
- Reorganize v3/ into implementation/ subfolders:
  - planning/, architecture/, migration/, integration/
  - security/, adrs/, research/, swarm-plans/

- Add 15-agent concurrent swarm implementation plans:
  - SWARM-OVERVIEW.md: Hierarchical mesh topology, 4 phases
  - AGENT-SPECIFICATIONS.md: 15 agent configs with capabilities
  - TDD-LONDON-SCHOOL-PLAN.md: Mock-first TDD methodology
  - BENCHMARK-OPTIMIZATION.md: Performance targets (2.49x-7.47x)
  - DEPLOYMENT-PLAN.md: Release strategy, CI/CD, rollback
  - GITHUB-ISSUE-TRACKING.md: Issue workflow with agent replies

- Update .claude/settings.json with proper hooks format
- Add bash aliases for claude --dangerously-skip-permissions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 15:40:51 +00:00

70 lines
1.9 KiB
JavaScript
Executable File

#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const glob = require('glob');
// Find all TypeScript files
const files = glob.sync('src/**/*.ts', {
ignore: ['src/**/*.test.ts', 'src/**/*.spec.ts']
});
let totalFixed = 0;
files.forEach(file => {
let content = fs.readFileSync(file, 'utf8');
let modified = false;
// Fix error handling patterns
const patterns = [
// Fix unknown error types in catch blocks
{
regex: /catch\s*\(\s*error\s*\)\s*{([^}]+error\.message)/g,
replacement: 'catch (error) {$1'
},
// Fix error.message access
{
regex: /(\$\{|`)error\.message/g,
replacement: '$1(error instanceof Error ? error.message : String(error))'
},
// Fix standalone error.message
{
regex: /([^`$])error\.message/g,
replacement: '$1(error instanceof Error ? error.message : String(error))'
},
// Fix error type annotations
{
regex: /catch\s*\(\s*error:\s*any\s*\)/g,
replacement: 'catch (error)'
},
// Fix error type in functions
{
regex: /\(error:\s*unknown\)/g,
replacement: '(error)'
}
];
patterns.forEach(pattern => {
const before = content;
content = content.replace(pattern.regex, pattern.replacement);
if (before !== content) {
modified = true;
}
});
if (modified) {
// Add error handler import if needed
if (!content.includes("from '../utils/error-handler'") &&
!content.includes("from '../../utils/error-handler'") &&
content.includes('error instanceof Error')) {
const importPath = file.includes('cli/commands') ? '../../utils/error-handler' : '../utils/error-handler';
content = `import { getErrorMessage } from '${importPath}';\n` + content;
}
fs.writeFileSync(file, content);
totalFixed++;
console.log(`Fixed: ${file}`);
}
});
console.log(`\nTotal files fixed: ${totalFixed}`);