camouf 0.3.1 → 0.4.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 (41) hide show
  1. package/README.md +107 -1
  2. package/dist/cli/commands/fix.d.ts +10 -0
  3. package/dist/cli/commands/fix.d.ts.map +1 -0
  4. package/dist/cli/commands/fix.js +218 -0
  5. package/dist/cli/commands/fix.js.map +1 -0
  6. package/dist/cli/commands/report.d.ts.map +1 -1
  7. package/dist/cli/commands/report.js +2 -1
  8. package/dist/cli/commands/report.js.map +1 -1
  9. package/dist/cli/index.js +3 -0
  10. package/dist/cli/index.js.map +1 -1
  11. package/dist/cli/version.d.ts +1 -1
  12. package/dist/cli/version.js +1 -1
  13. package/dist/core/agents/agent-integrations.js +112 -3
  14. package/dist/core/agents/agent-integrations.js.map +1 -1
  15. package/dist/core/reporter/report-generator.d.ts +1 -0
  16. package/dist/core/reporter/report-generator.d.ts.map +1 -1
  17. package/dist/core/reporter/report-generator.js +37 -0
  18. package/dist/core/reporter/report-generator.js.map +1 -1
  19. package/dist/core/reporter/signature-report.template.d.ts +38 -0
  20. package/dist/core/reporter/signature-report.template.d.ts.map +1 -0
  21. package/dist/core/reporter/signature-report.template.js +597 -0
  22. package/dist/core/reporter/signature-report.template.js.map +1 -0
  23. package/dist/core/reporter/violation-reporter.d.ts.map +1 -1
  24. package/dist/core/reporter/violation-reporter.js +3 -0
  25. package/dist/core/reporter/violation-reporter.js.map +1 -1
  26. package/dist/core/rules/builtin/function-signature-matching.rule.d.ts +115 -0
  27. package/dist/core/rules/builtin/function-signature-matching.rule.d.ts.map +1 -0
  28. package/dist/core/rules/builtin/function-signature-matching.rule.js +850 -0
  29. package/dist/core/rules/builtin/function-signature-matching.rule.js.map +1 -0
  30. package/dist/core/rules/builtin/index.d.ts +1 -0
  31. package/dist/core/rules/builtin/index.d.ts.map +1 -1
  32. package/dist/core/rules/builtin/index.js +1 -0
  33. package/dist/core/rules/builtin/index.js.map +1 -1
  34. package/dist/core/rules/rule-engine.d.ts.map +1 -1
  35. package/dist/core/rules/rule-engine.js +2 -0
  36. package/dist/core/rules/rule-engine.js.map +1 -1
  37. package/dist/types/config.types.d.ts +2 -0
  38. package/dist/types/config.types.d.ts.map +1 -1
  39. package/dist/types/config.types.js +0 -2
  40. package/dist/types/config.types.js.map +1 -1
  41. package/package.json +2 -1
package/README.md CHANGED
@@ -14,15 +14,89 @@ Camouf is a powerful, multi-language CLI tool for monitoring and enforcing softw
14
14
  - **Real-time Monitoring**: Watch mode for continuous architecture validation
15
15
  - **Multi-language Support**: TypeScript, JavaScript, Python, Java, Go, Rust
16
16
  - **Advanced Analysis**: Circular dependency detection, coupling metrics, hotspot identification
17
- - **12 Built-in Rules**: Comprehensive rule set for modern architectures
17
+ - **13 Built-in Rules**: Comprehensive rule set for modern architectures
18
+ - **AI Agent Safety**: Detects function/field name mismatches from AI context loss
18
19
  - **Security Scanning**: Detects hardcoded secrets, API keys, and credentials
19
20
  - **Multiple Report Formats**: HTML, JSON, Markdown, SARIF
20
21
  - **VS Code Integration**: Real-time Problems panel integration with custom tasks
21
22
  - **Highly Configurable**: JSON, YAML, or JavaScript configuration
22
23
 
24
+ <p align="center">
25
+ <img src="docs/images/architecture-overview.svg" alt="Camouf Architecture Overview" width="800" />
26
+ </p>
27
+
28
+ ---
29
+
30
+ ## Function Signature Matching: Catch AI Agent Errors
31
+
32
+ AI coding agents like Claude Code and GitHub Copilot work with limited context windows.
33
+ When generating frontend code without full visibility into backend contracts, they often
34
+ use **similar but incorrect names** for functions and type fields.
35
+
36
+ These errors compile successfully but cause runtime failures.
37
+
38
+ ### The Problem
39
+
40
+ <p align="center">
41
+ <img src="docs/images/problem-flow.svg" alt="AI Context Loss Problem" width="800" />
42
+ </p>
43
+
44
+ ### How Camouf Solves It
45
+
46
+ Camouf's `function-signature-matching` rule scans your shared contracts and uses
47
+ fuzzy matching to detect when code uses names that are *close but not exact*:
48
+
49
+ <p align="center">
50
+ <img src="docs/images/camouf-workflow.svg" alt="Camouf Workflow" width="800" />
51
+ </p>
52
+
53
+ ### Example Detection
54
+
55
+ ```
56
+ Defined in shared/api.ts:15 Used in frontend/user.ts:42
57
+ getUserById(id) ◄────────── getUser(userId)
58
+ └── 75% similar, likely a typo
59
+ ```
60
+
61
+ ### Quick Fix Commands
62
+
63
+ ```bash
64
+ # Interactive mode: confirm each fix
65
+ npx camouf fix-signatures --interactive
66
+
67
+ # Fix all mismatches automatically
68
+ npx camouf fix-signatures --all
69
+
70
+ # Fix a specific mismatch by ID
71
+ npx camouf fix --id sig-001
72
+
73
+ # Preview what would be fixed
74
+ npx camouf fix-signatures --all --dry-run
75
+ ```
76
+
77
+ ### Interactive HTML Report
78
+
79
+ Run validation to generate a report with clickable quick-fix commands:
80
+
81
+ ```bash
82
+ npx camouf report --format html --output camouf-report/
83
+ ```
84
+
85
+ The report shows:
86
+
87
+ | Status | Type | Expected | Found | Quick Fix |
88
+ |--------|------|----------|-------|-----------|
89
+ | Error | Function | `getUserById` | `getUser` | `npx camouf fix --id sig-001` |
90
+ | Error | Field | `email` | `userEmail` | `npx camouf fix --id sig-002` |
91
+
92
+ See [AI Agent Challenges](docs/ai-agent-challenges.md) for a comprehensive guide on this feature.
93
+
94
+ ---
95
+
23
96
  ## Documentation
24
97
 
25
98
  - [Getting Started](docs/getting-started.md)
99
+ - [AI Agent Challenges](docs/ai-agent-challenges.md) — How Camouf catches AI-generated code errors
26
100
  - [Configuring Rules](docs/configuring-rules.md)
27
101
  - [CI/CD Integration](docs/ci-cd-integration.md)
28
102
  - [Changelog](CHANGELOG.md)
@@ -152,6 +226,36 @@ Options:
152
226
  -f, --format <type> Report format (html, json, markdown)
153
227
  ```
154
228
 
229
+ ### `camouf fix`
230
+
231
+ Apply a single quick-fix by ID.
232
+
233
+ ```bash
234
+ camouf fix [options]
235
+
236
+ Options:
237
+ --id <id> Quick-fix ID (e.g., sig-001)
238
+ -c, --config <path> Path to configuration file
239
+ --dry-run Preview changes without applying
240
+ ```
241
+
242
+ ### `camouf fix-signatures`
243
+
244
+ Fix all function/field signature mismatches.
245
+
246
+ ```bash
247
+ camouf fix-signatures [options]
248
+
249
+ Options:
250
+ --all Fix all mismatches automatically
251
+ --interactive Confirm each fix interactively
252
+ --file <path> Fix only mismatches in specific file
253
+ --type <type> Fix only function or field mismatches
254
+ -c, --config <path> Path to configuration file
255
+ --dry-run Preview changes without applying
256
+ --ci CI/agent mode: no prompts, use --all for auto-fix
257
+ ```
258
+
155
259
  ## Configuration
156
260
 
157
261
  ### Configuration File
@@ -195,6 +299,7 @@ Camouf supports multiple configuration formats:
195
299
  "builtin": {
196
300
  "layer-dependencies": "error",
197
301
  "circular-dependencies": "error",
302
+ "function-signature-matching": "error",
198
303
  "performance-antipatterns": "warn",
199
304
  "type-safety": "warn",
200
305
  "data-flow-integrity": "error",
@@ -223,6 +328,7 @@ Camouf supports multiple configuration formats:
223
328
  | `circular-dependencies` | Detects circular dependency cycles | `error` |
224
329
  | `contract-mismatch` | Validates API contracts (OpenAPI/GraphQL) | `error` |
225
330
  | `ddd-boundaries` | Validates DDD principles and bounded contexts | `warn` |
331
+ | `function-signature-matching` | Detects mismatched function/field names between contracts and usage | `error` |
226
332
 
227
333
  ### Security Rules
228
334
 
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Fix Command
3
+ *
4
+ * Applies fixes for signature mismatches and other fixable violations.
5
+ * Supports both single fix by ID and batch operations.
6
+ */
7
+ import { Command } from 'commander';
8
+ export declare const fixCommand: Command;
9
+ export declare const fixSignaturesCommand: Command;
10
+ //# sourceMappingURL=fix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fix.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/fix.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkBpC,eAAO,MAAM,UAAU,SAYnB,CAAC;AAEL,eAAO,MAAM,oBAAoB,SAgB7B,CAAC"}
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Fix Command
3
+ *
4
+ * Applies fixes for signature mismatches and other fixable violations.
5
+ * Supports both single fix by ID and batch operations.
6
+ */
7
+ import { Command } from 'commander';
8
+ import * as fs from 'fs';
9
+ import * as path from 'path';
10
+ import { ConfigurationManager } from '../../core/config/configuration-manager.js';
11
+ import { ProjectScanner } from '../../core/scanner/project-scanner.js';
12
+ import { RuleEngine } from '../../core/rules/rule-engine.js';
13
+ import { Logger } from '../../core/logger.js';
14
+ import ora from 'ora';
15
+ export const fixCommand = new Command('fix')
16
+ .description('Fix signature mismatches and other fixable violations')
17
+ .option('-c, --config <path>', 'Path to configuration file')
18
+ .option('--id <id>', 'Fix specific mismatch by ID (e.g., sig-001)')
19
+ .option('--file <path>', 'Fix all mismatches in a specific file')
20
+ .option('--type <type>', 'Fix all mismatches of a specific type (function-name, parameter-name, type-field)')
21
+ .option('--all', 'Fix all signature mismatches')
22
+ .option('--interactive', 'Interactive mode: confirm each fix')
23
+ .option('--dry-run', 'Show what would be fixed without making changes')
24
+ .option('--ci', 'CI/agent mode: no prompts, no spinners')
25
+ .action(async (options) => {
26
+ await executeFixAction(options);
27
+ });
28
+ export const fixSignaturesCommand = new Command('fix-signatures')
29
+ .description('Fix function signature mismatches (alias for fix with signature options)')
30
+ .option('-c, --config <path>', 'Path to configuration file')
31
+ .option('--type <type>', 'Fix type: function-name, parameter-name, type-field')
32
+ .option('--file <path>', 'Fix all in specific file')
33
+ .option('--all', 'Fix all signature mismatches')
34
+ .option('--interactive', 'Interactive mode')
35
+ .option('--dry-run', 'Show what would be fixed')
36
+ .option('--ci', 'CI mode')
37
+ .action(async (options) => {
38
+ // Default to interactive if no mode specified
39
+ if (!options.type && !options.file && !options.all && !options.interactive) {
40
+ options.interactive = true;
41
+ }
42
+ // Execute the same action as fix command
43
+ await executeFixAction(options);
44
+ });
45
+ async function executeFixAction(options) {
46
+ const isCIMode = options.ci || !!process.env.CI || !!process.env.CAMOUF_CI;
47
+ const spinner = isCIMode ? null : ora('Loading configuration...').start();
48
+ try {
49
+ // Load configuration
50
+ const configManager = new ConfigurationManager();
51
+ const config = await configManager.loadConfig(options.config);
52
+ if (!config) {
53
+ if (spinner)
54
+ spinner.fail('No configuration found');
55
+ Logger.error('Run "npx camouf init" to initialize configuration.');
56
+ process.exit(1);
57
+ }
58
+ // Scan project and run function-signature-matching rule
59
+ if (spinner)
60
+ spinner.text = 'Scanning for signature mismatches...';
61
+ const scanner = new ProjectScanner(config);
62
+ const ruleEngine = new RuleEngine(config);
63
+ // Only run function-signature-matching rule
64
+ ruleEngine.filterRules(['function-signature-matching']);
65
+ const graph = await scanner.scan();
66
+ const fileContents = scanner.getFileContents();
67
+ const violations = await ruleEngine.validate(graph, fileContents);
68
+ if (spinner)
69
+ spinner.succeed(`Found ${violations.length} signature mismatches`);
70
+ if (violations.length === 0) {
71
+ if (!isCIMode)
72
+ Logger.success('\nNo signature mismatches found!\n');
73
+ return;
74
+ }
75
+ // Filter violations based on options
76
+ let targetViolations = violations.filter(v => v.ruleId === 'function-signature-matching');
77
+ if (options.id) {
78
+ targetViolations = targetViolations.filter(v => v.metadata?.mismatchId === options.id);
79
+ }
80
+ if (options.file) {
81
+ const targetPath = path.resolve(options.file);
82
+ targetViolations = targetViolations.filter(v => path.resolve(config.root, v.file).includes(targetPath));
83
+ }
84
+ if (options.type) {
85
+ targetViolations = targetViolations.filter(v => v.metadata?.mismatchType === options.type);
86
+ }
87
+ if (targetViolations.length === 0) {
88
+ Logger.warn('\nNo matching violations found with the given filters.\n');
89
+ return;
90
+ }
91
+ // If no action specified, show available fixes
92
+ if (!options.all && !options.interactive && !options.id) {
93
+ Logger.info('\nAvailable fixes:\n');
94
+ Logger.info('Usage:');
95
+ Logger.info(' npx camouf fix --id sig-001 # Fix specific mismatch');
96
+ Logger.info(' npx camouf fix --file src/api.ts # Fix all in file');
97
+ Logger.info(' npx camouf fix --type function-name # Fix by type');
98
+ Logger.info(' npx camouf fix --all # Fix all mismatches');
99
+ Logger.info(' npx camouf fix --interactive # Interactive mode\n');
100
+ // Show summary of mismatches
101
+ console.log('\nMismatches by type:');
102
+ const byType = new Map();
103
+ violations.forEach(v => {
104
+ const type = String(v.metadata?.mismatchType || 'unknown');
105
+ byType.set(type, (byType.get(type) || 0) + 1);
106
+ });
107
+ byType.forEach((count, type) => {
108
+ console.log(` ${type}: ${count}`);
109
+ });
110
+ console.log('');
111
+ return;
112
+ }
113
+ // Apply fixes
114
+ const fixes = [];
115
+ for (const violation of targetViolations) {
116
+ if (!violation.metadata)
117
+ continue;
118
+ const { expected, found, mismatchId, mismatchType } = violation.metadata;
119
+ if (expected && found && typeof expected === 'string' && typeof found === 'string') {
120
+ fixes.push({
121
+ id: String(mismatchId || 'unknown'),
122
+ file: violation.file,
123
+ line: violation.line || 0,
124
+ oldText: found,
125
+ newText: expected,
126
+ type: String(mismatchType || 'unknown'),
127
+ });
128
+ }
129
+ }
130
+ if (fixes.length === 0) {
131
+ Logger.warn('\nNo fixes could be generated from the violations.\n');
132
+ return;
133
+ }
134
+ // Interactive mode
135
+ if (options.interactive && !isCIMode) {
136
+ Logger.info(`\nFound ${fixes.length} fixes to apply:\n`);
137
+ for (const fix of fixes) {
138
+ console.log(` [${fix.id}] ${fix.file}:${fix.line}`);
139
+ console.log(` ${fix.type}: "${fix.oldText}" → "${fix.newText}"`);
140
+ }
141
+ // In interactive mode, we'd use inquirer to confirm each fix
142
+ // For now, just show them
143
+ Logger.info('\nUse --all to apply all fixes, or --id <id> for specific fixes.\n');
144
+ return;
145
+ }
146
+ // Dry run mode
147
+ if (options.dryRun) {
148
+ Logger.info('\n[DRY RUN] Would apply the following fixes:\n');
149
+ for (const fix of fixes) {
150
+ console.log(` [${fix.id}] ${fix.file}:${fix.line}`);
151
+ console.log(` ${fix.type}: "${fix.oldText}" → "${fix.newText}"`);
152
+ }
153
+ Logger.info(`\n[DRY RUN] Would fix ${fixes.length} mismatch(es).\n`);
154
+ return;
155
+ }
156
+ // Group fixes by file
157
+ const fixesByFile = new Map();
158
+ for (const fix of fixes) {
159
+ const existing = fixesByFile.get(fix.file) || [];
160
+ existing.push(fix);
161
+ fixesByFile.set(fix.file, existing);
162
+ }
163
+ // Apply fixes
164
+ if (spinner)
165
+ spinner.text = 'Applying fixes...';
166
+ let appliedCount = 0;
167
+ for (const [filePath, fileFixes] of fixesByFile) {
168
+ try {
169
+ const absolutePath = path.resolve(config.root, filePath);
170
+ let content = fs.readFileSync(absolutePath, 'utf-8');
171
+ // Apply fixes in reverse line order to preserve line numbers
172
+ const sortedFixes = [...fileFixes].sort((a, b) => b.line - a.line);
173
+ for (const fix of sortedFixes) {
174
+ // Replace the old text with new text (word boundary aware)
175
+ const regex = new RegExp(`\\b${escapeRegExp(fix.oldText)}\\b`, 'g');
176
+ const newContent = content.replace(regex, fix.newText);
177
+ if (newContent !== content) {
178
+ content = newContent;
179
+ appliedCount++;
180
+ if (!isCIMode) {
181
+ Logger.info(` Fixed: ${filePath}:${fix.line} - "${fix.oldText}" → "${fix.newText}"`);
182
+ }
183
+ }
184
+ }
185
+ // Write back
186
+ fs.writeFileSync(absolutePath, content, 'utf-8');
187
+ }
188
+ catch (error) {
189
+ Logger.error(`Failed to apply fixes to ${filePath}: ${error}`);
190
+ }
191
+ }
192
+ if (spinner)
193
+ spinner.succeed(`Applied ${appliedCount} fixes`);
194
+ // Output results
195
+ if (isCIMode) {
196
+ console.log(JSON.stringify({
197
+ applied: appliedCount,
198
+ total: fixes.length,
199
+ files: Array.from(fixesByFile.keys()),
200
+ }));
201
+ }
202
+ else {
203
+ Logger.success(`\nApplied ${appliedCount} fixes to ${fixesByFile.size} file(s).`);
204
+ Logger.info('Run "npx camouf validate" to verify the changes.\n');
205
+ }
206
+ }
207
+ catch (error) {
208
+ if (spinner)
209
+ spinner.fail(`Error: ${error}`);
210
+ else
211
+ console.error(`ERROR: ${error}`);
212
+ process.exit(1);
213
+ }
214
+ }
215
+ function escapeRegExp(str) {
216
+ return str.replace(/[.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1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/report.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,aAAa,SAwDtB,CAAC"}
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/report.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,aAAa,SAyDtB,CAAC"}
@@ -38,7 +38,8 @@ export const reportCommand = new Command('report')
38
38
  spinner.succeed(`Scanned ${graph.nodeCount()} files`);
39
39
  // Validate
40
40
  spinner.start('Running validation...');
41
- const violations = await ruleEngine.validate(graph);
41
+ const fileContents = scanner.getFileContents();
42
+ const violations = await ruleEngine.validate(graph, fileContents);
42
43
  spinner.succeed(`Found ${violations.length} violations`);
43
44
  // Generate report
44
45
  spinner.start('Generating report...');
@@ -1 +1 @@
1
- {"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/cli/commands/report.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,+BAA+B,CAAC;KAC5C,MAAM,CAAC,qBAAqB,EAAE,4BAA4B,CAAC;KAC3D,MAAM,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tD,WAAW;QACX,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;QACvC,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;QAC/C,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAClE,OAAO,CAAC,OAAO,CAAC,SAAS,UAAU,CAAC,MAAM,aAAa,CAAC,CAAC;QAEzD,kBAAkB;QAClB,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACtC,MAAM,eAAe,CAAC,QAAQ,CAAC;YAC7B,KAAK;YACL,UAAU;YACV,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,UAAU,EAAE,OAAO,CAAC,MAAM;YAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC,CAAC;QACH,OAAO,CAAC,OAAO,CAAC,uBAAuB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAEzD,MAAM,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC;QACvD,MAAM,CAAC,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM,mDAAmD,CAAC,CAAC;IAEzF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,6BAA8B,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC"}
package/dist/cli/index.js CHANGED
@@ -11,6 +11,7 @@ import { watchCommand } from './commands/watch.js';
11
11
  import { validateCommand } from './commands/validate.js';
12
12
  import { analyzeCommand } from './commands/analyze.js';
13
13
  import { reportCommand } from './commands/report.js';
14
+ import { fixCommand, fixSignaturesCommand } from './commands/fix.js';
14
15
  import { Logger } from '../core/logger.js';
15
16
  import { version, description } from './version.js';
16
17
  const program = new Command();
@@ -30,6 +31,8 @@ program.addCommand(watchCommand);
30
31
  program.addCommand(validateCommand);
31
32
  program.addCommand(analyzeCommand);
32
33
  program.addCommand(reportCommand);
34
+ program.addCommand(fixCommand);
35
+ program.addCommand(fixSignaturesCommand);
33
36
  // Error handling
34
37
  program.exitOverride((err) => {
35
38
  if (err.code === 'commander.help' || err.code === 'commander.version') {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,WAAW,CAAC;KACxB,OAAO,CAAC,OAAO,EAAE,eAAe,EAAE,6BAA6B,CAAC,CAAC;AAEpE,iBAAiB;AACjB,OAAO;KACJ,MAAM,CAAC,qBAAqB,EAAE,4BAA4B,CAAC;KAC3D,MAAM,CAAC,WAAW,EAAE,uBAAuB,CAAC;KAC5C,MAAM,CAAC,UAAU,EAAE,mCAAmC,CAAC;KACvD,MAAM,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAAC;AAElD,oBAAoB;AACpB,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;A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CAAC;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,yBAAyB,IAAI,GAAG,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;QAClF,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,kBAAkB;AAClB,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC/C,MAAM,CAAC,KAAK,CAAC,gBAAgB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Version and metadata for Camouf CLI
3
3
  */
4
- export declare const version = "0.3.1";
4
+ export declare const version = "0.3.2";
5
5
  export declare const name = "camouf";
6
6
  export declare const description = "Real-time architecture monitoring CLI tool with multi-language support";
7
7
  export declare const metadata: {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Version and metadata for Camouf CLI
3
3
  */
4
- export const version = '0.3.1';
4
+ export const version = '0.3.2';
5
5
  export const name = 'camouf';
6
6
  export const description = 'Real-time architecture monitoring CLI tool with multi-language support';
7
7
  export const metadata = {
@@ -68,6 +68,15 @@ async function generateClaudeIntegration(projectRoot, result, options) {
68
68
  else {
69
69
  result.filesSkipped.push('.claude/commands/camouf-fix.md');
70
70
  }
71
+ // 3b. Generate .claude/commands/camouf-fix-signatures.md
72
+ const fixSignaturesCommandPath = path.join(claudeCommandsDir, 'camouf-fix-signatures.md');
73
+ if (!fs.existsSync(fixSignaturesCommandPath) || options.force) {
74
+ fs.writeFileSync(fixSignaturesCommandPath, getClaudeFixSignaturesCommand());
75
+ result.filesCreated.push('.claude/commands/camouf-fix-signatures.md');
76
+ }
77
+ else {
78
+ result.filesSkipped.push('.claude/commands/camouf-fix-signatures.md');
79
+ }
71
80
  // 4. Generate .claude/rules/camouf.md
72
81
  const claudeRulesDir = path.join(projectRoot, '.claude', 'rules');
73
82
  if (!fs.existsSync(claudeRulesDir)) {
@@ -113,7 +122,9 @@ function getClaudeMdContent() {
113
122
  This project uses [Camouf](https://www.npmjs.com/package/camouf) for real-time architecture monitoring.
114
123
  Camouf enforces architecture rules (layer dependencies, circular dependencies, security, DDD boundaries, and more).
115
124
 
116
- ### Quick Commands
125
+ ### How to Run Camouf
126
+
127
+ **Always use \`npx camouf\` to invoke the CLI.** Do NOT use \`node camouf.js\` or \`camouf\` directly.
117
128
 
118
129
  \`\`\`bash
119
130
  # One-shot validation (JSON output for parsing)
@@ -142,6 +153,7 @@ Camouf validates 12 builtin rules (configured in \`camouf.config.json\`):
142
153
  | \`api-versioning\` | API endpoints must include version prefix |
143
154
  | \`data-flow-integrity\` | Input validation and output sanitization required |
144
155
  | \`contract-mismatch\` | Shared types must be consistent across layers |
156
+ | \`function-signature-matching\` | Function names and parameters must match across frontend/backend |
145
157
  | \`distributed-transactions\` | Multi-service calls need saga/compensation |
146
158
  | \`resilience-patterns\` | HTTP calls need timeout, retry, circuit breaker |
147
159
 
@@ -170,6 +182,8 @@ function getCamoufClaudeSection() {
170
182
 
171
183
  This project uses [Camouf](https://www.npmjs.com/package/camouf) for architecture monitoring.
172
184
 
185
+ **Always use \`npx camouf\` to invoke the CLI.** Do NOT use \`node camouf.js\` or \`camouf\` directly.
186
+
173
187
  ### Quick Commands
174
188
 
175
189
  \`\`\`bash
@@ -191,7 +205,9 @@ description: Run Camouf architecture validation and fix any violations found
191
205
  allowed-tools: Read, Grep, Bash, Write
192
206
  ---
193
207
 
194
- Run Camouf to validate the project architecture:
208
+ Run Camouf to validate the project architecture.
209
+
210
+ **Important**: Always use \`npx camouf\` to run Camouf. Do NOT use \`node camouf.js\` or bare \`camouf\`.
195
211
 
196
212
  1. Execute: \`npx camouf validate --format json --ci\`
197
213
  2. Parse the JSON output to identify violations
@@ -215,7 +231,9 @@ description: Run Camouf and automatically fix all architecture violations
215
231
  allowed-tools: Read, Grep, Bash, Write
216
232
  ---
217
233
 
218
- Run Camouf to find and fix architecture violations:
234
+ Run Camouf to find and fix architecture violations.
235
+
236
+ **Important**: Always use \`npx camouf\` to run Camouf. Do NOT use \`node camouf.js\` or bare \`camouf\`.
219
237
 
220
238
  1. Execute: \`npx camouf validate --format json --ci\`
221
239
  2. Parse the JSON output
@@ -237,6 +255,75 @@ Run Camouf to find and fix architecture violations:
237
255
  - **security-context**: Add authentication/authorization guards to routes
238
256
  - **performance-antipatterns**: Replace N+1 queries with batch operations, sync I/O with async
239
257
  - **type-safety**: Replace \`any\` with proper types, add return type annotations
258
+ - **function-signature-matching**: Rename functions/fields to match the shared contract definition
259
+ `;
260
+ }
261
+ function getClaudeFixSignaturesCommand() {
262
+ return `---
263
+ description: Fix function signature mismatches between frontend and backend code
264
+ allowed-tools: Read, Grep, Bash, Write
265
+ ---
266
+
267
+ Fix function signature mismatches detected by Camouf.
268
+
269
+ **Important**: Always use \`npx camouf\` to run Camouf. Do NOT use \`node camouf.js\` or bare \`camouf\`.
270
+
271
+ ## Background
272
+
273
+ AI coding agents often work with limited context windows and may create mismatched function names
274
+ or type field names between frontend and backend code. For example:
275
+
276
+ - Backend defines \`getUserById(id)\` but frontend calls \`getUser(userId)\`
277
+ - Shared DTO has \`email\` field but frontend accesses \`userEmail\`
278
+
279
+ These mismatches compile successfully but cause runtime errors.
280
+
281
+ ## Steps
282
+
283
+ 1. Run: \`npx camouf validate --format json --ci --rules function-signature-matching\`
284
+ 2. Parse the JSON output to find violations with \`ruleId: "function-signature-matching"\`
285
+ 3. For each violation:
286
+ - The \`metadata.expected\` field contains the correct name (as defined in shared contracts)
287
+ - The \`metadata.found\` field contains the incorrect name being used
288
+ - The \`metadata.definedIn\` shows where the correct definition is
289
+ - Read the file at \`violation.file\` line \`violation.line\`
290
+ - Rename \`found\` to \`expected\` in that location
291
+ 4. Re-run validation to confirm fixes
292
+ 5. Report summary of fixes applied
293
+
294
+ ## Alternative: Use the fix command
295
+
296
+ You can also use Camouf's built-in fix command:
297
+
298
+ \`\`\`bash
299
+ # Interactive mode - confirm each fix
300
+ npx camouf fix-signatures --interactive
301
+
302
+ # Fix all automatically
303
+ npx camouf fix-signatures --all
304
+
305
+ # Fix specific mismatch by ID
306
+ npx camouf fix --id sig-001
307
+
308
+ # Dry run to see what would be fixed
309
+ npx camouf fix-signatures --all --dry-run
310
+ \`\`\`
311
+
312
+ ## Example Violation
313
+
314
+ \`\`\`json
315
+ {
316
+ "ruleId": "function-signature-matching",
317
+ "message": "Function name mismatch: 'getUser' called but 'getUserById' is defined",
318
+ "file": "src/frontend/api.ts",
319
+ "line": 42,
320
+ "metadata": {
321
+ "expected": "getUserById",
322
+ "found": "getUser",
323
+ "definedIn": { "file": "src/shared/api-contracts.ts", "line": 15 }
324
+ }
325
+ }
326
+ \`\`\`
240
327
  `;
241
328
  }
242
329
  function getClaudeRule() {
@@ -255,6 +342,8 @@ When writing or modifying code in this project, follow these architecture princi
255
342
  - Validate all user inputs before processing
256
343
  - Add timeout, retry, and error handling to external HTTP calls
257
344
 
345
+ **Always use \`npx camouf\` to invoke the CLI.** Do NOT use \`node camouf.js\` or bare \`camouf\`.
346
+
258
347
  Run \`npx camouf validate --format json --ci\` to check compliance.
259
348
  `;
260
349
  }
@@ -266,6 +355,8 @@ function getAgentsMdContent() {
266
355
  This project uses [Camouf](https://www.npmjs.com/package/camouf) for real-time architecture monitoring.
267
356
  Camouf enforces architecture rules and catches violations before they reach production.
268
357
 
358
+ **Always use \`npx camouf\` to invoke the CLI.** Do NOT use \`node camouf.js\` or bare \`camouf\`.
359
+
269
360
  ### Commands
270
361
 
271
362
  \`\`\`bash
@@ -320,9 +411,25 @@ The following rules are enforced (configured in \`camouf.config.json\`):
320
411
  - \`api-versioning\` — API endpoints must include version prefix
321
412
  - \`data-flow-integrity\` — Input validation and output sanitization
322
413
  - \`contract-mismatch\` — Shared types must be consistent
414
+ - \`function-signature-matching\` — Function/field names must match across frontend/backend
323
415
  - \`distributed-transactions\` — Multi-service calls need saga/compensation
324
416
  - \`resilience-patterns\` — HTTP calls need timeout, retry, circuit breaker
325
417
 
418
+ ### Signature Mismatch Fixing
419
+
420
+ Camouf can detect and fix function/field name mismatches caused by AI context loss:
421
+
422
+ \`\`\`bash
423
+ # Find signature mismatches
424
+ npx camouf validate --format json --ci --rules function-signature-matching
425
+
426
+ # Fix all mismatches
427
+ npx camouf fix-signatures --all
428
+
429
+ # Fix single mismatch
430
+ npx camouf fix --id sig-001
431
+ \`\`\`
432
+
326
433
  ### Workflow
327
434
 
328
435
  1. Before committing code changes, run \`npx camouf validate --format json --ci\`
@@ -345,6 +452,8 @@ function getCamoufAgentsSection() {
345
452
 
346
453
  This project uses [Camouf](https://www.npmjs.com/package/camouf) for architecture monitoring.
347
454
 
455
+ **Always use \`npx camouf\` to invoke the CLI.** Do NOT use \`node camouf.js\` or bare \`camouf\`.
456
+
348
457
  ### Commands
349
458
 
350
459
  \`\`\`bash