code-auditor-mcp 1.3.1 → 1.6.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 (48) hide show
  1. package/README.md +133 -2
  2. package/dist/analyzers/solidAnalyzer.d.ts +5 -1
  3. package/dist/analyzers/solidAnalyzer.d.ts.map +1 -1
  4. package/dist/analyzers/solidAnalyzer.js +174 -2
  5. package/dist/analyzers/solidAnalyzer.js.map +1 -1
  6. package/dist/codeIndexDb.d.ts +47 -0
  7. package/dist/codeIndexDb.d.ts.map +1 -1
  8. package/dist/codeIndexDb.js +432 -5
  9. package/dist/codeIndexDb.js.map +1 -1
  10. package/dist/codeIndexService.d.ts +26 -0
  11. package/dist/codeIndexService.d.ts.map +1 -1
  12. package/dist/codeIndexService.js +60 -0
  13. package/dist/codeIndexService.js.map +1 -1
  14. package/dist/functionScanner.d.ts.map +1 -1
  15. package/dist/functionScanner.js +76 -6
  16. package/dist/functionScanner.js.map +1 -1
  17. package/dist/mcp-standalone.js +14 -4
  18. package/dist/mcp-standalone.js.map +1 -1
  19. package/dist/mcp-tools/workflowGuide.d.ts.map +1 -1
  20. package/dist/mcp-tools/workflowGuide.js +45 -0
  21. package/dist/mcp-tools/workflowGuide.js.map +1 -1
  22. package/dist/mcp.js +3 -3
  23. package/dist/mcp.js.map +1 -1
  24. package/dist/search/QueryParser.d.ts +2 -0
  25. package/dist/search/QueryParser.d.ts.map +1 -1
  26. package/dist/search/QueryParser.js +191 -26
  27. package/dist/search/QueryParser.js.map +1 -1
  28. package/dist/types.d.ts +135 -0
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/types.js +16 -1
  31. package/dist/types.js.map +1 -1
  32. package/dist/utils/astUtils.d.ts +17 -1
  33. package/dist/utils/astUtils.d.ts.map +1 -1
  34. package/dist/utils/astUtils.js +121 -0
  35. package/dist/utils/astUtils.js.map +1 -1
  36. package/dist/utils/componentPatterns.d.ts +22 -0
  37. package/dist/utils/componentPatterns.d.ts.map +1 -0
  38. package/dist/utils/componentPatterns.js +273 -0
  39. package/dist/utils/componentPatterns.js.map +1 -0
  40. package/dist/utils/componentResponsibility.d.ts +39 -0
  41. package/dist/utils/componentResponsibility.d.ts.map +1 -0
  42. package/dist/utils/componentResponsibility.js +487 -0
  43. package/dist/utils/componentResponsibility.js.map +1 -0
  44. package/dist/utils/dependencyExtractor.d.ts +30 -0
  45. package/dist/utils/dependencyExtractor.d.ts.map +1 -0
  46. package/dist/utils/dependencyExtractor.js +237 -0
  47. package/dist/utils/dependencyExtractor.js.map +1 -0
  48. package/package.json +16 -15
@@ -0,0 +1,273 @@
1
+ import { ResponsibilityType } from '../types.js';
2
+ import { areResponsibilitiesRelated } from './componentResponsibility.js';
3
+ // Form component pattern
4
+ export const FORM_PATTERN = {
5
+ name: 'Form',
6
+ indicators: [
7
+ { type: 'name', pattern: /Form|form/i, weight: 1.0 },
8
+ { type: 'path', pattern: /\/forms?\//i, weight: 0.8 },
9
+ { type: 'props', pattern: /onSubmit|initialValues|validation/i, weight: 0.9 },
10
+ { type: 'hooks', pattern: /useForm|useField|useFormik/i, weight: 1.0 },
11
+ { type: 'imports', pattern: /react-hook-form|formik|react-final-form/i, weight: 1.0 }
12
+ ],
13
+ allowedResponsibilities: [
14
+ ResponsibilityType.FormHandling,
15
+ ResponsibilityType.UIState,
16
+ ResponsibilityType.EventHandling,
17
+ ResponsibilityType.DataTransformation,
18
+ ResponsibilityType.ErrorHandling
19
+ ],
20
+ relatedResponsibilities: [
21
+ [ResponsibilityType.FormHandling, ResponsibilityType.UIState],
22
+ [ResponsibilityType.FormHandling, ResponsibilityType.EventHandling]
23
+ ],
24
+ complexityMultiplier: 1.5,
25
+ description: 'Form components are expected to have multiple state hooks and event handlers'
26
+ };
27
+ // Table/List component pattern
28
+ export const TABLE_PATTERN = {
29
+ name: 'Table',
30
+ indicators: [
31
+ { type: 'name', pattern: /Table|List|Grid|DataGrid/i, weight: 1.0 },
32
+ { type: 'path', pattern: /\/(tables?|lists?|grids?)\//i, weight: 0.8 },
33
+ { type: 'props', pattern: /columns|rows|data|onSort|onFilter/i, weight: 0.9 },
34
+ { type: 'hooks', pattern: /useTable|usePagination|useSort/i, weight: 1.0 },
35
+ { type: 'imports', pattern: /react-table|ag-grid|material-table/i, weight: 1.0 }
36
+ ],
37
+ allowedResponsibilities: [
38
+ ResponsibilityType.UIState,
39
+ ResponsibilityType.DataTransformation,
40
+ ResponsibilityType.EventHandling,
41
+ ResponsibilityType.Layout
42
+ ],
43
+ relatedResponsibilities: [
44
+ [ResponsibilityType.UIState, ResponsibilityType.DataTransformation],
45
+ [ResponsibilityType.UIState, ResponsibilityType.EventHandling]
46
+ ],
47
+ complexityMultiplier: 1.8,
48
+ description: 'Table components handle sorting, filtering, pagination, and selection'
49
+ };
50
+ // Dashboard component pattern
51
+ export const DASHBOARD_PATTERN = {
52
+ name: 'Dashboard',
53
+ indicators: [
54
+ { type: 'name', pattern: /Dashboard|Overview|Analytics|Report/i, weight: 1.0 },
55
+ { type: 'path', pattern: /\/(dashboard|analytics|reports?)\//i, weight: 0.8 },
56
+ { type: 'props', pattern: /metrics|charts|widgets/i, weight: 0.7 }
57
+ ],
58
+ allowedResponsibilities: [
59
+ ResponsibilityType.DataFetching,
60
+ ResponsibilityType.DataTransformation,
61
+ ResponsibilityType.UIState,
62
+ ResponsibilityType.Layout,
63
+ ResponsibilityType.Subscriptions
64
+ ],
65
+ relatedResponsibilities: [
66
+ [ResponsibilityType.DataFetching, ResponsibilityType.DataTransformation],
67
+ [ResponsibilityType.DataFetching, ResponsibilityType.Subscriptions]
68
+ ],
69
+ complexityMultiplier: 2.0,
70
+ description: 'Dashboard components orchestrate multiple data sources and visualizations'
71
+ };
72
+ // Modal/Dialog component pattern
73
+ export const MODAL_PATTERN = {
74
+ name: 'Modal',
75
+ indicators: [
76
+ { type: 'name', pattern: /Modal|Dialog|Popup|Drawer|Sheet/i, weight: 1.0 },
77
+ { type: 'path', pattern: /\/(modals?|dialogs?|popups?)\//i, weight: 0.8 },
78
+ { type: 'props', pattern: /open|isOpen|onClose|onDismiss/i, weight: 0.9 }
79
+ ],
80
+ allowedResponsibilities: [
81
+ ResponsibilityType.UIState,
82
+ ResponsibilityType.EventHandling,
83
+ ResponsibilityType.FormHandling,
84
+ ResponsibilityType.Layout
85
+ ],
86
+ relatedResponsibilities: [
87
+ [ResponsibilityType.UIState, ResponsibilityType.EventHandling],
88
+ [ResponsibilityType.FormHandling, ResponsibilityType.UIState]
89
+ ],
90
+ complexityMultiplier: 1.2,
91
+ description: 'Modal components manage open/close state and may contain forms'
92
+ };
93
+ // Page/Route component pattern
94
+ export const PAGE_PATTERN = {
95
+ name: 'Page',
96
+ indicators: [
97
+ { type: 'name', pattern: /Page|Route|Screen|View$/i, weight: 1.0 },
98
+ { type: 'path', pattern: /\/(pages?|routes?|screens?|views?)\//i, weight: 0.9 },
99
+ { type: 'imports', pattern: /next\/router|react-router|reach-router/i, weight: 0.8 }
100
+ ],
101
+ allowedResponsibilities: [
102
+ ResponsibilityType.DataFetching,
103
+ ResponsibilityType.Routing,
104
+ ResponsibilityType.Authentication,
105
+ ResponsibilityType.Layout,
106
+ ResponsibilityType.UIState
107
+ ],
108
+ relatedResponsibilities: [
109
+ [ResponsibilityType.DataFetching, ResponsibilityType.Routing],
110
+ [ResponsibilityType.Authentication, ResponsibilityType.Routing]
111
+ ],
112
+ complexityMultiplier: 1.5,
113
+ description: 'Page components can orchestrate data fetching and routing'
114
+ };
115
+ // Layout component pattern
116
+ export const LAYOUT_PATTERN = {
117
+ name: 'Layout',
118
+ indicators: [
119
+ { type: 'name', pattern: /Layout|Container|Wrapper|Shell|Frame/i, weight: 1.0 },
120
+ { type: 'path', pattern: /\/(layouts?|containers?|shell)\//i, weight: 0.8 },
121
+ { type: 'props', pattern: /children|header|footer|sidebar/i, weight: 0.7 }
122
+ ],
123
+ allowedResponsibilities: [
124
+ ResponsibilityType.Layout,
125
+ ResponsibilityType.UIState,
126
+ ResponsibilityType.Routing
127
+ ],
128
+ relatedResponsibilities: [
129
+ [ResponsibilityType.Layout, ResponsibilityType.UIState]
130
+ ],
131
+ complexityMultiplier: 1.0,
132
+ description: 'Layout components should focus on structure, not business logic'
133
+ };
134
+ // Button/Simple UI component pattern
135
+ export const SIMPLE_UI_PATTERN = {
136
+ name: 'SimpleUI',
137
+ indicators: [
138
+ { type: 'name', pattern: /^(Button|Icon|Badge|Chip|Tag|Label|Avatar)$/i, weight: 1.0 },
139
+ { type: 'path', pattern: /\/(ui|components?|atoms)\//i, weight: 0.6 }
140
+ ],
141
+ allowedResponsibilities: [
142
+ ResponsibilityType.UIState,
143
+ ResponsibilityType.EventHandling,
144
+ ResponsibilityType.Layout
145
+ ],
146
+ relatedResponsibilities: [
147
+ [ResponsibilityType.UIState, ResponsibilityType.EventHandling]
148
+ ],
149
+ complexityMultiplier: 0.5,
150
+ description: 'Simple UI components should have minimal responsibilities'
151
+ };
152
+ // Default patterns collection
153
+ export const DEFAULT_PATTERNS = [
154
+ FORM_PATTERN,
155
+ TABLE_PATTERN,
156
+ DASHBOARD_PATTERN,
157
+ MODAL_PATTERN,
158
+ PAGE_PATTERN,
159
+ LAYOUT_PATTERN,
160
+ SIMPLE_UI_PATTERN
161
+ ];
162
+ /**
163
+ * Detects which pattern a component matches based on various indicators
164
+ */
165
+ export function detectComponentPattern(componentName, filePath, props = [], hooks = [], imports = []) {
166
+ let bestMatch;
167
+ for (const pattern of DEFAULT_PATTERNS) {
168
+ let score = 0;
169
+ let matchedIndicators = 0;
170
+ for (const indicator of pattern.indicators) {
171
+ let matches = false;
172
+ switch (indicator.type) {
173
+ case 'name':
174
+ if (typeof indicator.pattern === 'string') {
175
+ matches = componentName.includes(indicator.pattern);
176
+ }
177
+ else {
178
+ matches = indicator.pattern.test(componentName);
179
+ }
180
+ break;
181
+ case 'path':
182
+ if (typeof indicator.pattern === 'string') {
183
+ matches = filePath.includes(indicator.pattern);
184
+ }
185
+ else {
186
+ matches = indicator.pattern.test(filePath);
187
+ }
188
+ break;
189
+ case 'props':
190
+ matches = props.some(prop => {
191
+ if (typeof indicator.pattern === 'string') {
192
+ return prop.includes(indicator.pattern);
193
+ }
194
+ else {
195
+ return indicator.pattern.test(prop);
196
+ }
197
+ });
198
+ break;
199
+ case 'hooks':
200
+ matches = hooks.some(hook => {
201
+ if (typeof indicator.pattern === 'string') {
202
+ return hook.includes(indicator.pattern);
203
+ }
204
+ else {
205
+ return indicator.pattern.test(hook);
206
+ }
207
+ });
208
+ break;
209
+ case 'imports':
210
+ matches = imports.some(imp => {
211
+ if (typeof indicator.pattern === 'string') {
212
+ return imp.includes(indicator.pattern);
213
+ }
214
+ else {
215
+ return indicator.pattern.test(imp);
216
+ }
217
+ });
218
+ break;
219
+ }
220
+ if (matches) {
221
+ matchedIndicators++;
222
+ score += indicator.weight || 1.0;
223
+ }
224
+ }
225
+ // Require at least one indicator match and better score than previous best
226
+ if (matchedIndicators > 0 && (!bestMatch || score > bestMatch.score)) {
227
+ bestMatch = { pattern, score };
228
+ }
229
+ }
230
+ // Return the best matching pattern if score is above threshold
231
+ return bestMatch && bestMatch.score >= 0.5 ? bestMatch.pattern : undefined;
232
+ }
233
+ /**
234
+ * Checks if a set of responsibilities is allowed for a given pattern
235
+ */
236
+ export function areResponsibilitiesAllowedForPattern(responsibilities, pattern) {
237
+ return responsibilities.every(resp => pattern.allowedResponsibilities.includes(resp));
238
+ }
239
+ /**
240
+ * Gets unrelated responsibilities for a pattern
241
+ */
242
+ export function getUnrelatedResponsibilities(responsibilities, pattern) {
243
+ const unrelatedGroups = [];
244
+ const disallowedResponsibilities = [];
245
+ // First, collect all disallowed responsibilities
246
+ for (const resp of responsibilities) {
247
+ if (!pattern.allowedResponsibilities.includes(resp)) {
248
+ disallowedResponsibilities.push(resp);
249
+ }
250
+ }
251
+ // Only create a group if there are multiple disallowed responsibilities
252
+ if (disallowedResponsibilities.length >= 2) {
253
+ unrelatedGroups.push(disallowedResponsibilities);
254
+ }
255
+ // Check allowed responsibilities for unrelated pairs
256
+ const allowedInComponent = responsibilities.filter(r => pattern.allowedResponsibilities.includes(r));
257
+ for (let i = 0; i < allowedInComponent.length; i++) {
258
+ for (let j = i + 1; j < allowedInComponent.length; j++) {
259
+ const resp1 = allowedInComponent[i];
260
+ const resp2 = allowedInComponent[j];
261
+ // Check if they're in a related group for this pattern
262
+ const areRelatedInPattern = pattern.relatedResponsibilities?.some(group => group.includes(resp1) && group.includes(resp2)) || false;
263
+ // Also check general relationship rules
264
+ const areGenerallyRelated = areResponsibilitiesRelated(resp1, resp2);
265
+ if (!areRelatedInPattern && !areGenerallyRelated) {
266
+ // These form an unrelated pair
267
+ unrelatedGroups.push([resp1, resp2]);
268
+ }
269
+ }
270
+ }
271
+ return unrelatedGroups;
272
+ }
273
+ //# sourceMappingURL=componentPatterns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentPatterns.js","sourceRoot":"","sources":["../../src/utils/componentPatterns.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAEnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,yBAAyB;AACzB,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC5C,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE;QACV,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE;QACpD,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE;QACrD,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,oCAAoC,EAAE,MAAM,EAAE,GAAG,EAAE;QAC7E,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,6BAA6B,EAAE,MAAM,EAAE,GAAG,EAAE;QACtE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,0CAA0C,EAAE,MAAM,EAAE,GAAG,EA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AAC,KAAK,CAAC,EAAE,CACxE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAC/C,IAAI,KAAK,CAAC;YAEX,wCAAwC;YACxC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAErE,IAAI,CAAC,mBAAmB,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBACjD,+BAA+B;gBAC/B,eAAe,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import * as ts from 'typescript';
2
+ import { ComponentResponsibility, ResponsibilityType, ComponentMetadata } from '../types.js';
3
+ /**
4
+ * Detects and categorizes responsibilities within a React component
5
+ */
6
+ export declare function detectComponentResponsibilities(sourceFile: ts.SourceFile, component: ts.Node, metadata?: ComponentMetadata): ComponentResponsibility[];
7
+ /**
8
+ * Identifies data fetching patterns in code
9
+ */
10
+ export declare function containsDataFetching(node: ts.Node): boolean;
11
+ /**
12
+ * Identifies form handling patterns
13
+ */
14
+ export declare function containsFormHandling(node: ts.Node, sourceFile: ts.SourceFile): boolean;
15
+ /**
16
+ * Identifies business logic patterns
17
+ */
18
+ export declare function containsBusinessLogic(node: ts.Node): boolean;
19
+ /**
20
+ * Helper to determine if responsibilities are related
21
+ */
22
+ export declare function areResponsibilitiesRelated(resp1: ResponsibilityType, resp2: ResponsibilityType): boolean;
23
+ /**
24
+ * Analyzes hook usage to identify responsibilities
25
+ */
26
+ export declare function analyzeHookUsage(sourceFile: ts.SourceFile, component: ts.Node, metadata?: ComponentMetadata): ComponentResponsibility[];
27
+ /**
28
+ * Analyzes useEffect hooks for side effects and data fetching
29
+ */
30
+ export declare function analyzeEffects(sourceFile: ts.SourceFile, component: ts.Node): ComponentResponsibility[];
31
+ /**
32
+ * Analyzes event handlers in a component
33
+ */
34
+ export declare function analyzeEventHandlers(sourceFile: ts.SourceFile, component: ts.Node): ComponentResponsibility[];
35
+ /**
36
+ * Analyzes rendering logic and JSX complexity
37
+ */
38
+ export declare function analyzeRenderingLogic(sourceFile: ts.SourceFile, component: ts.Node): ComponentResponsibility[];
39
+ //# sourceMappingURL=componentResponsibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentResponsibility.d.ts","sourceRoot":"","sources":["../../src/utils/componentResponsibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,aAAa,CAAC;AAGrB;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,SAAS,EAAE,EAAE,CAAC,IAAI,EAClB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,uBAAuB,EAAE,CA+B3B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CA0B3D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,OAAO,CA4BtF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CA6C5D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAoBT;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,SAAS,EAAE,EAAE,CAAC,IAAI,EAClB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,uBAAuB,EAAE,CAoG3B;AAED;;GAEG;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