mcp-react-toolkit 1.0.1 → 1.3.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 (275) hide show
  1. package/README.md +194 -44
  2. package/bin/cli.mjs +59 -0
  3. package/node_modules/@mcp-showcase/shared/build/McpServerBase.d.ts +18 -0
  4. package/node_modules/@mcp-showcase/shared/build/McpServerBase.d.ts.map +1 -0
  5. package/node_modules/@mcp-showcase/shared/build/McpServerBase.js +74 -0
  6. package/node_modules/@mcp-showcase/shared/build/McpServerBase.js.map +1 -0
  7. package/node_modules/@mcp-showcase/shared/build/ToolRegistry.d.ts +9 -0
  8. package/node_modules/@mcp-showcase/shared/build/ToolRegistry.d.ts.map +1 -0
  9. package/node_modules/@mcp-showcase/shared/build/ToolRegistry.js +22 -0
  10. package/node_modules/@mcp-showcase/shared/build/ToolRegistry.js.map +1 -0
  11. package/node_modules/@mcp-showcase/shared/build/fs.d.ts +8 -0
  12. package/node_modules/@mcp-showcase/shared/build/fs.d.ts.map +1 -0
  13. package/node_modules/@mcp-showcase/shared/build/fs.js +45 -0
  14. package/node_modules/@mcp-showcase/shared/build/fs.js.map +1 -0
  15. package/node_modules/@mcp-showcase/shared/build/index.d.ts +5 -0
  16. package/node_modules/@mcp-showcase/shared/build/index.d.ts.map +1 -0
  17. package/node_modules/@mcp-showcase/shared/build/index.js +5 -0
  18. package/node_modules/@mcp-showcase/shared/build/index.js.map +1 -0
  19. package/node_modules/@mcp-showcase/shared/build/types.d.ts +36 -0
  20. package/node_modules/@mcp-showcase/shared/build/types.d.ts.map +1 -0
  21. package/node_modules/@mcp-showcase/shared/build/types.js +5 -0
  22. package/node_modules/@mcp-showcase/shared/build/types.js.map +1 -0
  23. package/node_modules/@mcp-showcase/shared/package.json +24 -0
  24. package/node_modules/@mcp-showcase/shared/src/McpServerBase.ts +100 -0
  25. package/node_modules/@mcp-showcase/shared/src/ToolRegistry.ts +38 -0
  26. package/node_modules/@mcp-showcase/shared/src/fs.ts +49 -0
  27. package/node_modules/@mcp-showcase/shared/src/index.ts +12 -0
  28. package/node_modules/@mcp-showcase/shared/src/types.ts +44 -0
  29. package/node_modules/@mcp-showcase/shared/tsconfig.json +8 -0
  30. package/package.json +38 -4
  31. package/tools/accessibility-checker/build/index.js +9 -5
  32. package/tools/accessibility-checker/build/index.js.map +1 -1
  33. package/tools/accessibility-checker/build/rules.d.ts.map +1 -1
  34. package/tools/accessibility-checker/build/rules.js +325 -94
  35. package/tools/accessibility-checker/build/rules.js.map +1 -1
  36. package/tools/code-modernizer/build/tools/01-convert-to-typescript.d.ts.map +1 -1
  37. package/tools/code-modernizer/build/tools/01-convert-to-typescript.js +65 -50
  38. package/tools/code-modernizer/build/tools/01-convert-to-typescript.js.map +1 -1
  39. package/tools/code-modernizer/build/types.d.ts +1 -0
  40. package/tools/code-modernizer/build/types.d.ts.map +1 -1
  41. package/tools/code-modernizer/build/utils/ast-parser.d.ts.map +1 -1
  42. package/tools/code-modernizer/build/utils/ast-parser.js +30 -14
  43. package/tools/code-modernizer/build/utils/ast-parser.js.map +1 -1
  44. package/tools/code-modernizer/build/utils/type-generator.d.ts +1 -1
  45. package/tools/code-modernizer/build/utils/type-generator.d.ts.map +1 -1
  46. package/tools/code-modernizer/build/utils/type-generator.js +72 -23
  47. package/tools/code-modernizer/build/utils/type-generator.js.map +1 -1
  48. package/tools/component-factory/build/index.js +59 -7
  49. package/tools/component-factory/build/index.js.map +1 -1
  50. package/tools/component-fixer/README.md +44 -0
  51. package/tools/component-fixer/build/index.d.ts +3 -0
  52. package/tools/component-fixer/build/index.d.ts.map +1 -0
  53. package/tools/component-fixer/build/index.js +647 -0
  54. package/tools/component-fixer/build/index.js.map +1 -0
  55. package/tools/component-fixer/package.json +20 -0
  56. package/tools/component-reviewer/README.md +54 -0
  57. package/tools/component-reviewer/build/index.d.ts +39 -0
  58. package/tools/component-reviewer/build/index.d.ts.map +1 -0
  59. package/tools/component-reviewer/build/index.js +946 -0
  60. package/tools/component-reviewer/build/index.js.map +1 -0
  61. package/tools/component-reviewer/package.json +20 -0
  62. package/tools/dep-auditor/build/index.d.ts +1 -0
  63. package/tools/dep-auditor/build/index.d.ts.map +1 -1
  64. package/tools/dep-auditor/build/index.js +71 -16
  65. package/tools/dep-auditor/build/index.js.map +1 -1
  66. package/tools/generate-tests/build/analyzer.d.ts +14 -0
  67. package/tools/generate-tests/build/analyzer.d.ts.map +1 -1
  68. package/tools/generate-tests/build/analyzer.js +96 -42
  69. package/tools/generate-tests/build/analyzer.js.map +1 -1
  70. package/tools/generate-tests/build/generators.d.ts.map +1 -1
  71. package/tools/generate-tests/build/generators.js +304 -79
  72. package/tools/generate-tests/build/generators.js.map +1 -1
  73. package/tools/generate-tests/build/index.js +29 -10
  74. package/tools/generate-tests/build/index.js.map +1 -1
  75. package/tools/json-viewer/build/index.js +29 -6
  76. package/tools/json-viewer/build/index.js.map +1 -1
  77. package/tools/legacy-analyzer/README.md +66 -0
  78. package/tools/legacy-analyzer/build/index.d.ts +3 -0
  79. package/tools/legacy-analyzer/build/index.d.ts.map +1 -0
  80. package/tools/legacy-analyzer/build/index.js +209 -0
  81. package/tools/legacy-analyzer/build/index.js.map +1 -0
  82. package/tools/legacy-analyzer/build/tools/01-detect-project-tech.d.ts +3 -0
  83. package/tools/legacy-analyzer/build/tools/01-detect-project-tech.d.ts.map +1 -0
  84. package/tools/legacy-analyzer/build/tools/01-detect-project-tech.js +115 -0
  85. package/tools/legacy-analyzer/build/tools/01-detect-project-tech.js.map +1 -0
  86. package/tools/legacy-analyzer/build/tools/02-analyze-folder-structure.d.ts +3 -0
  87. package/tools/legacy-analyzer/build/tools/02-analyze-folder-structure.d.ts.map +1 -0
  88. package/tools/legacy-analyzer/build/tools/02-analyze-folder-structure.js +85 -0
  89. package/tools/legacy-analyzer/build/tools/02-analyze-folder-structure.js.map +1 -0
  90. package/tools/legacy-analyzer/build/tools/03-analyze-components.d.ts +3 -0
  91. package/tools/legacy-analyzer/build/tools/03-analyze-components.d.ts.map +1 -0
  92. package/tools/legacy-analyzer/build/tools/03-analyze-components.js +87 -0
  93. package/tools/legacy-analyzer/build/tools/03-analyze-components.js.map +1 -0
  94. package/tools/legacy-analyzer/build/tools/04-analyze-state-management.d.ts +3 -0
  95. package/tools/legacy-analyzer/build/tools/04-analyze-state-management.d.ts.map +1 -0
  96. package/tools/legacy-analyzer/build/tools/04-analyze-state-management.js +133 -0
  97. package/tools/legacy-analyzer/build/tools/04-analyze-state-management.js.map +1 -0
  98. package/tools/legacy-analyzer/build/tools/05-analyze-api-layer.d.ts +3 -0
  99. package/tools/legacy-analyzer/build/tools/05-analyze-api-layer.d.ts.map +1 -0
  100. package/tools/legacy-analyzer/build/tools/05-analyze-api-layer.js +160 -0
  101. package/tools/legacy-analyzer/build/tools/05-analyze-api-layer.js.map +1 -0
  102. package/tools/legacy-analyzer/build/tools/06-analyze-routing.d.ts +3 -0
  103. package/tools/legacy-analyzer/build/tools/06-analyze-routing.d.ts.map +1 -0
  104. package/tools/legacy-analyzer/build/tools/06-analyze-routing.js +150 -0
  105. package/tools/legacy-analyzer/build/tools/06-analyze-routing.js.map +1 -0
  106. package/tools/legacy-analyzer/build/tools/07-analyze-styling.d.ts +3 -0
  107. package/tools/legacy-analyzer/build/tools/07-analyze-styling.d.ts.map +1 -0
  108. package/tools/legacy-analyzer/build/tools/07-analyze-styling.js +131 -0
  109. package/tools/legacy-analyzer/build/tools/07-analyze-styling.js.map +1 -0
  110. package/tools/legacy-analyzer/build/tools/08-analyze-assets.d.ts +3 -0
  111. package/tools/legacy-analyzer/build/tools/08-analyze-assets.d.ts.map +1 -0
  112. package/tools/legacy-analyzer/build/tools/08-analyze-assets.js +85 -0
  113. package/tools/legacy-analyzer/build/tools/08-analyze-assets.js.map +1 -0
  114. package/tools/legacy-analyzer/build/tools/09-detect-anti-patterns.d.ts +3 -0
  115. package/tools/legacy-analyzer/build/tools/09-detect-anti-patterns.d.ts.map +1 -0
  116. package/tools/legacy-analyzer/build/tools/09-detect-anti-patterns.js +329 -0
  117. package/tools/legacy-analyzer/build/tools/09-detect-anti-patterns.js.map +1 -0
  118. package/tools/legacy-analyzer/build/tools/10-detect-duplication.d.ts +3 -0
  119. package/tools/legacy-analyzer/build/tools/10-detect-duplication.d.ts.map +1 -0
  120. package/tools/legacy-analyzer/build/tools/10-detect-duplication.js +192 -0
  121. package/tools/legacy-analyzer/build/tools/10-detect-duplication.js.map +1 -0
  122. package/tools/legacy-analyzer/build/tools/11-analyze-dependencies-usage.d.ts +3 -0
  123. package/tools/legacy-analyzer/build/tools/11-analyze-dependencies-usage.d.ts.map +1 -0
  124. package/tools/legacy-analyzer/build/tools/11-analyze-dependencies-usage.js +232 -0
  125. package/tools/legacy-analyzer/build/tools/11-analyze-dependencies-usage.js.map +1 -0
  126. package/tools/legacy-analyzer/build/tools/12-analyze-legacy-app.d.ts +3 -0
  127. package/tools/legacy-analyzer/build/tools/12-analyze-legacy-app.d.ts.map +1 -0
  128. package/tools/legacy-analyzer/build/tools/12-analyze-legacy-app.js +247 -0
  129. package/tools/legacy-analyzer/build/tools/12-analyze-legacy-app.js.map +1 -0
  130. package/tools/legacy-analyzer/build/tools/13-detect-features.d.ts +3 -0
  131. package/tools/legacy-analyzer/build/tools/13-detect-features.d.ts.map +1 -0
  132. package/tools/legacy-analyzer/build/tools/13-detect-features.js +141 -0
  133. package/tools/legacy-analyzer/build/tools/13-detect-features.js.map +1 -0
  134. package/tools/legacy-analyzer/build/tools/14-classify-files.d.ts +3 -0
  135. package/tools/legacy-analyzer/build/tools/14-classify-files.d.ts.map +1 -0
  136. package/tools/legacy-analyzer/build/tools/14-classify-files.js +76 -0
  137. package/tools/legacy-analyzer/build/tools/14-classify-files.js.map +1 -0
  138. package/tools/legacy-analyzer/build/tools/15-detect-shared-modules.d.ts +3 -0
  139. package/tools/legacy-analyzer/build/tools/15-detect-shared-modules.d.ts.map +1 -0
  140. package/tools/legacy-analyzer/build/tools/15-detect-shared-modules.js +70 -0
  141. package/tools/legacy-analyzer/build/tools/15-detect-shared-modules.js.map +1 -0
  142. package/tools/legacy-analyzer/build/tools/16-design-target-structure.d.ts +3 -0
  143. package/tools/legacy-analyzer/build/tools/16-design-target-structure.d.ts.map +1 -0
  144. package/tools/legacy-analyzer/build/tools/16-design-target-structure.js +26 -0
  145. package/tools/legacy-analyzer/build/tools/16-design-target-structure.js.map +1 -0
  146. package/tools/legacy-analyzer/build/tools/17-map-files-to-target.d.ts +3 -0
  147. package/tools/legacy-analyzer/build/tools/17-map-files-to-target.d.ts.map +1 -0
  148. package/tools/legacy-analyzer/build/tools/17-map-files-to-target.js +108 -0
  149. package/tools/legacy-analyzer/build/tools/17-map-files-to-target.js.map +1 -0
  150. package/tools/legacy-analyzer/build/tools/18-detect-boundary-violations.d.ts +3 -0
  151. package/tools/legacy-analyzer/build/tools/18-detect-boundary-violations.d.ts.map +1 -0
  152. package/tools/legacy-analyzer/build/tools/18-detect-boundary-violations.js +137 -0
  153. package/tools/legacy-analyzer/build/tools/18-detect-boundary-violations.js.map +1 -0
  154. package/tools/legacy-analyzer/build/tools/19-suggest-module-splitting.d.ts +3 -0
  155. package/tools/legacy-analyzer/build/tools/19-suggest-module-splitting.d.ts.map +1 -0
  156. package/tools/legacy-analyzer/build/tools/19-suggest-module-splitting.js +160 -0
  157. package/tools/legacy-analyzer/build/tools/19-suggest-module-splitting.js.map +1 -0
  158. package/tools/legacy-analyzer/build/tools/20-naming-standardizer.d.ts +3 -0
  159. package/tools/legacy-analyzer/build/tools/20-naming-standardizer.d.ts.map +1 -0
  160. package/tools/legacy-analyzer/build/tools/20-naming-standardizer.js +162 -0
  161. package/tools/legacy-analyzer/build/tools/20-naming-standardizer.js.map +1 -0
  162. package/tools/legacy-analyzer/build/tools/21-generate-refactor-plan.d.ts +3 -0
  163. package/tools/legacy-analyzer/build/tools/21-generate-refactor-plan.d.ts.map +1 -0
  164. package/tools/legacy-analyzer/build/tools/21-generate-refactor-plan.js +108 -0
  165. package/tools/legacy-analyzer/build/tools/21-generate-refactor-plan.js.map +1 -0
  166. package/tools/legacy-analyzer/build/tools/22-refactor-folder-structure.d.ts +3 -0
  167. package/tools/legacy-analyzer/build/tools/22-refactor-folder-structure.d.ts.map +1 -0
  168. package/tools/legacy-analyzer/build/tools/22-refactor-folder-structure.js +98 -0
  169. package/tools/legacy-analyzer/build/tools/22-refactor-folder-structure.js.map +1 -0
  170. package/tools/legacy-analyzer/build/types.d.ts +413 -0
  171. package/tools/legacy-analyzer/build/types.d.ts.map +1 -0
  172. package/tools/legacy-analyzer/build/types.js +12 -0
  173. package/tools/legacy-analyzer/build/types.js.map +1 -0
  174. package/tools/legacy-analyzer/build/utils/ast-parser.d.ts +34 -0
  175. package/tools/legacy-analyzer/build/utils/ast-parser.d.ts.map +1 -0
  176. package/tools/legacy-analyzer/build/utils/ast-parser.js +394 -0
  177. package/tools/legacy-analyzer/build/utils/ast-parser.js.map +1 -0
  178. package/tools/legacy-analyzer/build/utils/file-scanner.d.ts +51 -0
  179. package/tools/legacy-analyzer/build/utils/file-scanner.d.ts.map +1 -0
  180. package/tools/legacy-analyzer/build/utils/file-scanner.js +174 -0
  181. package/tools/legacy-analyzer/build/utils/file-scanner.js.map +1 -0
  182. package/tools/legacy-analyzer/build/utils/import-tracker.d.ts +38 -0
  183. package/tools/legacy-analyzer/build/utils/import-tracker.d.ts.map +1 -0
  184. package/tools/legacy-analyzer/build/utils/import-tracker.js +194 -0
  185. package/tools/legacy-analyzer/build/utils/import-tracker.js.map +1 -0
  186. package/tools/legacy-analyzer/build/utils/refactor-helpers.d.ts +88 -0
  187. package/tools/legacy-analyzer/build/utils/refactor-helpers.d.ts.map +1 -0
  188. package/tools/legacy-analyzer/build/utils/refactor-helpers.js +538 -0
  189. package/tools/legacy-analyzer/build/utils/refactor-helpers.js.map +1 -0
  190. package/tools/legacy-analyzer/package.json +20 -0
  191. package/tools/lighthouse-runner/README.md +45 -0
  192. package/tools/lighthouse-runner/build/index.d.ts +6 -0
  193. package/tools/lighthouse-runner/build/index.d.ts.map +1 -0
  194. package/tools/lighthouse-runner/build/index.js +295 -0
  195. package/tools/lighthouse-runner/build/index.js.map +1 -0
  196. package/tools/lighthouse-runner/package.json +20 -0
  197. package/tools/monorepo-manager/build/utils.d.ts.map +1 -1
  198. package/tools/monorepo-manager/build/utils.js +12 -9
  199. package/tools/monorepo-manager/build/utils.js.map +1 -1
  200. package/tools/performance-audit/README.md +37 -0
  201. package/tools/performance-audit/build/index.d.ts +13 -0
  202. package/tools/performance-audit/build/index.d.ts.map +1 -0
  203. package/tools/performance-audit/build/index.js +311 -0
  204. package/tools/performance-audit/build/index.js.map +1 -0
  205. package/tools/performance-audit/package.json +20 -0
  206. package/tools/quality-pipeline/build/index.js +55 -15
  207. package/tools/quality-pipeline/build/index.js.map +1 -1
  208. package/tools/render-analyzer/README.md +43 -0
  209. package/tools/render-analyzer/build/index.d.ts +25 -0
  210. package/tools/render-analyzer/build/index.d.ts.map +1 -0
  211. package/tools/render-analyzer/build/index.js +342 -0
  212. package/tools/render-analyzer/build/index.js.map +1 -0
  213. package/tools/render-analyzer/package.json +20 -0
  214. package/tools/shared/build/fs.d.ts +8 -0
  215. package/tools/shared/build/fs.d.ts.map +1 -0
  216. package/tools/shared/build/fs.js +45 -0
  217. package/tools/shared/build/fs.js.map +1 -0
  218. package/tools/shared/build/index.d.ts +1 -0
  219. package/tools/shared/build/index.d.ts.map +1 -1
  220. package/tools/shared/build/index.js +1 -0
  221. package/tools/shared/build/index.js.map +1 -1
  222. package/tools/shared/package.json +2 -1
  223. package/tools/storybook-generator/README.md +39 -0
  224. package/tools/storybook-generator/build/index.d.ts +13 -0
  225. package/tools/storybook-generator/build/index.d.ts.map +1 -0
  226. package/tools/storybook-generator/build/index.js +478 -0
  227. package/tools/storybook-generator/build/index.js.map +1 -0
  228. package/tools/storybook-generator/package.json +20 -0
  229. package/tools/test-gap-analyzer/README.md +41 -0
  230. package/tools/test-gap-analyzer/build/index.d.ts +20 -0
  231. package/tools/test-gap-analyzer/build/index.d.ts.map +1 -0
  232. package/tools/test-gap-analyzer/build/index.js +371 -0
  233. package/tools/test-gap-analyzer/build/index.js.map +1 -0
  234. package/tools/test-gap-analyzer/package.json +20 -0
  235. package/tools/typescript-enforcer/build/scanner.d.ts.map +1 -1
  236. package/tools/typescript-enforcer/build/scanner.js +13 -1
  237. package/tools/typescript-enforcer/build/scanner.js.map +1 -1
  238. package/tools/typescript-enforcer/build/types.d.ts +1 -0
  239. package/tools/typescript-enforcer/build/types.d.ts.map +1 -1
  240. package/CONTRIBUTING.md +0 -157
  241. package/demo/legacy-app/src/App.jsx +0 -12
  242. package/demo/legacy-app/src/components/Dashboard.jsx +0 -51
  243. package/demo/legacy-app/src/components/UserCard.jsx +0 -32
  244. package/demo/legacy-app/src/hooks/useUsers.js +0 -38
  245. package/demo/legacy-app/src/utils/api.js +0 -30
  246. package/glama.json +0 -4
  247. package/mcp-publisher +0 -0
  248. package/server.json +0 -20
  249. package/tools/accessibility-checker/build/rules.test.d.ts +0 -2
  250. package/tools/accessibility-checker/build/rules.test.d.ts.map +0 -1
  251. package/tools/accessibility-checker/build/rules.test.js.map +0 -1
  252. package/tools/code-modernizer/build/utils/file-ops.test.d.ts +0 -2
  253. package/tools/code-modernizer/build/utils/file-ops.test.d.ts.map +0 -1
  254. package/tools/code-modernizer/build/utils/file-ops.test.js.map +0 -1
  255. package/tools/component-factory/build/utils.test.d.ts +0 -2
  256. package/tools/component-factory/build/utils.test.d.ts.map +0 -1
  257. package/tools/component-factory/build/utils.test.js.map +0 -1
  258. package/tools/dep-auditor/build/index.test.d.ts +0 -2
  259. package/tools/dep-auditor/build/index.test.d.ts.map +0 -1
  260. package/tools/dep-auditor/build/index.test.js.map +0 -1
  261. package/tools/generate-tests/build/analyzer.test.d.ts +0 -2
  262. package/tools/generate-tests/build/analyzer.test.d.ts.map +0 -1
  263. package/tools/generate-tests/build/analyzer.test.js.map +0 -1
  264. package/tools/json-viewer/build/utils.test.d.ts +0 -2
  265. package/tools/json-viewer/build/utils.test.d.ts.map +0 -1
  266. package/tools/json-viewer/build/utils.test.js.map +0 -1
  267. package/tools/monorepo-manager/build/utils.test.d.ts +0 -2
  268. package/tools/monorepo-manager/build/utils.test.d.ts.map +0 -1
  269. package/tools/monorepo-manager/build/utils.test.js.map +0 -1
  270. package/tools/quality-pipeline/build/utils.test.d.ts +0 -2
  271. package/tools/quality-pipeline/build/utils.test.d.ts.map +0 -1
  272. package/tools/quality-pipeline/build/utils.test.js.map +0 -1
  273. package/tools/typescript-enforcer/build/scanner.test.d.ts +0 -2
  274. package/tools/typescript-enforcer/build/scanner.test.d.ts.map +0 -1
  275. package/tools/typescript-enforcer/build/scanner.test.js.map +0 -1
@@ -0,0 +1,647 @@
1
+ #!/usr/bin/env node
2
+ import { McpServerBase } from '@mcp-showcase/shared';
3
+ import * as fs from 'fs';
4
+ import * as path from 'path';
5
+ import { execSync } from 'child_process';
6
+ import { fileURLToPath } from 'url';
7
+ import { dirname } from 'path';
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+ // ============================================================================
11
+ // UTILITY FUNCTIONS
12
+ // ============================================================================
13
+ function readFileContent(filePath) {
14
+ try {
15
+ return fs.readFileSync(filePath, 'utf-8');
16
+ }
17
+ catch {
18
+ return null;
19
+ }
20
+ }
21
+ function writeFileContent(filePath, content) {
22
+ fs.writeFileSync(filePath, content, 'utf-8');
23
+ }
24
+ function findComponentFile(componentDir, componentName) {
25
+ const extensions = ['.tsx', '.ts', '.jsx', '.js'];
26
+ for (const ext of extensions) {
27
+ const filePath = path.join(componentDir, `${componentName}${ext}`);
28
+ if (fs.existsSync(filePath))
29
+ return filePath;
30
+ }
31
+ return null;
32
+ }
33
+ function findTsconfig(dir) {
34
+ let current = dir;
35
+ while (current !== '/' && current !== '.') {
36
+ const tsconfig = path.join(current, 'tsconfig.json');
37
+ if (fs.existsSync(tsconfig))
38
+ return tsconfig;
39
+ current = path.dirname(current);
40
+ }
41
+ return null;
42
+ }
43
+ function runTypeScriptCheck(componentDir) {
44
+ try {
45
+ const tsconfigPath = findTsconfig(componentDir);
46
+ if (!tsconfigPath) {
47
+ return { errors: ['No tsconfig.json found'], passed: false };
48
+ }
49
+ execSync(`npx tsc --noEmit --project ${tsconfigPath}`, {
50
+ cwd: componentDir,
51
+ stdio: 'pipe',
52
+ timeout: 30000,
53
+ });
54
+ return { errors: [], passed: true };
55
+ }
56
+ catch (error) {
57
+ const err = error;
58
+ const output = err.stdout?.toString() || err.stderr?.toString() || err.message;
59
+ const errors = output.split('\n').filter((line) => line.trim().length > 0);
60
+ return { errors: errors.slice(0, 20), passed: false };
61
+ }
62
+ }
63
+ // ============================================================================
64
+ // FIX ENGINE - Line-based transformations
65
+ // ============================================================================
66
+ class FixEngine {
67
+ content;
68
+ filePath;
69
+ lines;
70
+ modified = false;
71
+ fixes = [];
72
+ constructor(content, filePath) {
73
+ this.content = content;
74
+ this.filePath = filePath;
75
+ this.lines = content.split('\n');
76
+ }
77
+ hasModifications() {
78
+ return this.modified;
79
+ }
80
+ getFixes() {
81
+ return this.fixes;
82
+ }
83
+ getResult() {
84
+ return this.lines.join('\n');
85
+ }
86
+ applyFix(issue) {
87
+ if (!issue.fixable || !issue.fixType) {
88
+ this.fixes.push({
89
+ issueId: issue.id,
90
+ category: issue.category,
91
+ line: issue.line,
92
+ message: issue.message,
93
+ applied: false,
94
+ detail: 'Issue is not fixable or missing fixType',
95
+ });
96
+ return;
97
+ }
98
+ try {
99
+ switch (issue.fixType) {
100
+ case 'remove':
101
+ this.applyRemove(issue);
102
+ break;
103
+ case 'replace':
104
+ this.applyReplace(issue);
105
+ break;
106
+ case 'add':
107
+ this.applyAdd(issue);
108
+ break;
109
+ case 'refactor':
110
+ this.applyRefactor(issue);
111
+ break;
112
+ default:
113
+ this.fixes.push({
114
+ issueId: issue.id,
115
+ category: issue.category,
116
+ line: issue.line,
117
+ message: issue.message,
118
+ applied: false,
119
+ detail: `Unknown fixType: ${issue.fixType}`,
120
+ });
121
+ }
122
+ }
123
+ catch (error) {
124
+ this.fixes.push({
125
+ issueId: issue.id,
126
+ category: issue.category,
127
+ line: issue.line,
128
+ message: issue.message,
129
+ applied: false,
130
+ detail: `Error: ${error instanceof Error ? error.message : String(error)}`,
131
+ });
132
+ }
133
+ }
134
+ applyRemove(issue) {
135
+ if (issue.category === 'code-quality' && issue.message.includes('Console statement')) {
136
+ if (issue.line && issue.line > 0) {
137
+ const lineIdx = issue.line - 1;
138
+ const line = this.lines[lineIdx];
139
+ if (line.match(/console\.(log|debug|info)\(/)) {
140
+ this.lines.splice(lineIdx, 1);
141
+ this.modified = true;
142
+ this.fixes.push({
143
+ issueId: issue.id,
144
+ category: issue.category,
145
+ line: issue.line,
146
+ message: issue.message,
147
+ applied: true,
148
+ detail: `Removed console statement at line ${issue.line}`,
149
+ });
150
+ return;
151
+ }
152
+ }
153
+ }
154
+ this.fixes.push({
155
+ issueId: issue.id,
156
+ category: issue.category,
157
+ line: issue.line,
158
+ message: issue.message,
159
+ applied: false,
160
+ detail: 'Remove fix not implemented for this issue type',
161
+ });
162
+ }
163
+ applyReplace(issue) {
164
+ const lineIdx = issue.line ? issue.line - 1 : -1;
165
+ if (issue.category === 'type-safety' && issue.message.includes("'any' type")) {
166
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
167
+ let line = this.lines[lineIdx];
168
+ line = line.replace(/:\s*any\b/g, ': unknown');
169
+ line = line.replace(/<any>/g, '<unknown>');
170
+ line = line.replace(/\bas\s+any\b/g, 'as unknown');
171
+ this.lines[lineIdx] = line;
172
+ this.modified = true;
173
+ this.fixes.push({
174
+ issueId: issue.id,
175
+ category: issue.category,
176
+ line: issue.line,
177
+ message: issue.message,
178
+ applied: true,
179
+ detail: `Replaced 'any' with 'unknown' at line ${issue.line}`,
180
+ });
181
+ return;
182
+ }
183
+ }
184
+ if (issue.category === 'type-safety' && issue.message.includes('Non-null assertion')) {
185
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
186
+ let line = this.lines[lineIdx];
187
+ line = line.replace(/(\w+)!\./g, '$1?.');
188
+ this.lines[lineIdx] = line;
189
+ this.modified = true;
190
+ this.fixes.push({
191
+ issueId: issue.id,
192
+ category: issue.category,
193
+ line: issue.line,
194
+ message: issue.message,
195
+ applied: true,
196
+ detail: `Replaced non-null assertion with optional chaining at line ${issue.line}`,
197
+ });
198
+ return;
199
+ }
200
+ }
201
+ if (issue.category === 'accessibility' && issue.message.includes('positive tabIndex')) {
202
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
203
+ let line = this.lines[lineIdx];
204
+ line = line.replace(/tabIndex=["'][1-9]\d*["']/g, 'tabIndex={0}');
205
+ this.lines[lineIdx] = line;
206
+ this.modified = true;
207
+ this.fixes.push({
208
+ issueId: issue.id,
209
+ category: issue.category,
210
+ line: issue.line,
211
+ message: issue.message,
212
+ applied: true,
213
+ detail: `Replaced positive tabIndex with 0 at line ${issue.line}`,
214
+ });
215
+ return;
216
+ }
217
+ }
218
+ if (issue.category === 'accessibility' && issue.message.includes('Autoplay media')) {
219
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
220
+ let line = this.lines[lineIdx];
221
+ line = line.replace(/\s*autoPlay/, ' controls muted');
222
+ this.lines[lineIdx] = line;
223
+ this.modified = true;
224
+ this.fixes.push({
225
+ issueId: issue.id,
226
+ category: issue.category,
227
+ line: issue.line,
228
+ message: issue.message,
229
+ applied: true,
230
+ detail: `Replaced autoplay with controls muted at line ${issue.line}`,
231
+ });
232
+ return;
233
+ }
234
+ }
235
+ this.fixes.push({
236
+ issueId: issue.id,
237
+ category: issue.category,
238
+ line: issue.line,
239
+ message: issue.message,
240
+ applied: false,
241
+ detail: 'Replace fix not implemented for this issue type',
242
+ });
243
+ }
244
+ applyAdd(issue) {
245
+ if (issue.category === 'react-patterns' && issue.message.includes('displayName')) {
246
+ const componentNameMatch = issue.suggestion.match(/(\w+)\.displayName/);
247
+ const componentName = componentNameMatch ? componentNameMatch[1] : null;
248
+ if (componentName) {
249
+ let insertIdx = this.lines.length;
250
+ for (let i = this.lines.length - 1; i >= 0; i--) {
251
+ if (this.lines[i].match(/export\s*\{/) || this.lines[i].match(/export\s+default/)) {
252
+ insertIdx = i;
253
+ break;
254
+ }
255
+ }
256
+ this.lines.splice(insertIdx, 0, '', `${componentName}.displayName = '${componentName}';`);
257
+ this.modified = true;
258
+ this.fixes.push({
259
+ issueId: issue.id,
260
+ category: issue.category,
261
+ line: issue.line,
262
+ message: issue.message,
263
+ applied: true,
264
+ detail: `Added displayName = '${componentName}'`,
265
+ });
266
+ return;
267
+ }
268
+ }
269
+ const lineIdx = issue.line ? issue.line - 1 : -1;
270
+ if (issue.category === 'accessibility' && issue.message.includes('Image missing alt')) {
271
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
272
+ let line = this.lines[lineIdx];
273
+ if (line.match(/<img\s[^/]*\/?\s*>/)) {
274
+ line = line.replace(/<img\s/, '<img alt="" ');
275
+ this.lines[lineIdx] = line;
276
+ this.modified = true;
277
+ this.fixes.push({
278
+ issueId: issue.id,
279
+ category: issue.category,
280
+ line: issue.line,
281
+ message: issue.message,
282
+ applied: true,
283
+ detail: `Added alt="" to image at line ${issue.line}`,
284
+ });
285
+ return;
286
+ }
287
+ }
288
+ }
289
+ if (issue.category === 'accessibility' && issue.message.includes('Form input missing')) {
290
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
291
+ let line = this.lines[lineIdx];
292
+ if (!line.includes('aria-label') && !line.includes('aria-labelledby')) {
293
+ const inputTypeMatch = line.match(/type=["'](\w+)["']/);
294
+ const placeholder = inputTypeMatch ? inputTypeMatch[1] : 'input';
295
+ line = line.replace(/<input\s/, `<input aria-label="${placeholder}" `);
296
+ this.lines[lineIdx] = line;
297
+ this.modified = true;
298
+ this.fixes.push({
299
+ issueId: issue.id,
300
+ category: issue.category,
301
+ line: issue.line,
302
+ message: issue.message,
303
+ applied: true,
304
+ detail: `Added aria-label to input at line ${issue.line}`,
305
+ });
306
+ return;
307
+ }
308
+ }
309
+ }
310
+ if (issue.category === 'accessibility' && issue.message.includes('Clickable div missing')) {
311
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
312
+ let line = this.lines[lineIdx];
313
+ if (line.includes('onClick') && !line.includes('role=')) {
314
+ line = line.replace(/<div/, '<div role="button" tabIndex={0}');
315
+ this.lines[lineIdx] = line;
316
+ this.modified = true;
317
+ this.fixes.push({
318
+ issueId: issue.id,
319
+ category: issue.category,
320
+ line: issue.line,
321
+ message: issue.message,
322
+ applied: true,
323
+ detail: `Added role="button" and tabIndex={0} to clickable div at line ${issue.line}`,
324
+ });
325
+ return;
326
+ }
327
+ }
328
+ }
329
+ if (issue.category === 'accessibility' && issue.message.includes('Icon button missing')) {
330
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
331
+ let line = this.lines[lineIdx];
332
+ if ((line.includes('<button') || line.includes('<a')) && !line.includes('aria-label')) {
333
+ line = line.replace(/<(button|a)/, '<$1 aria-label="Button action"');
334
+ this.lines[lineIdx] = line;
335
+ this.modified = true;
336
+ this.fixes.push({
337
+ issueId: issue.id,
338
+ category: issue.category,
339
+ line: issue.line,
340
+ message: issue.message,
341
+ applied: true,
342
+ detail: `Added aria-label to icon button at line ${issue.line}`,
343
+ });
344
+ return;
345
+ }
346
+ }
347
+ }
348
+ if (issue.category === 'accessibility' && issue.message.includes('Link element missing href')) {
349
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
350
+ let line = this.lines[lineIdx];
351
+ if (line.match(/<a\s[^>]*>/) && !line.includes('href=')) {
352
+ line = line.replace(/<a\s/, '<a href="#" ');
353
+ this.lines[lineIdx] = line;
354
+ this.modified = true;
355
+ this.fixes.push({
356
+ issueId: issue.id,
357
+ category: issue.category,
358
+ line: issue.line,
359
+ message: issue.message,
360
+ applied: true,
361
+ detail: `Added href="#" to link at line ${issue.line} (update with actual URL)`,
362
+ });
363
+ return;
364
+ }
365
+ }
366
+ }
367
+ this.fixes.push({
368
+ issueId: issue.id,
369
+ category: issue.category,
370
+ line: issue.line,
371
+ message: issue.message,
372
+ applied: false,
373
+ detail: 'Add fix not implemented for this issue type',
374
+ });
375
+ }
376
+ applyRefactor(issue) {
377
+ const lineIdx = issue.line ? issue.line - 1 : -1;
378
+ if (issue.category === 'performance' && issue.message.includes('Inline arrow function')) {
379
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
380
+ const line = this.lines[lineIdx];
381
+ const handlerMatch = line.match(/(onClick|onChange|onSubmit|onFocus|onBlur)=\{([^}]+=>[^}]+)\}/);
382
+ if (handlerMatch) {
383
+ const eventName = handlerMatch[1];
384
+ const handlerBody = handlerMatch[2];
385
+ const handlerName = `handle${eventName.charAt(2).toUpperCase() + eventName.slice(3)}`;
386
+ this.lines[lineIdx] = line.replace(new RegExp(`${eventName}=\\{[^}]+=>[^}]+\\}`), `${eventName}={${handlerName}}`);
387
+ this.lines.splice(lineIdx, 0, `// TODO: Extract ${handlerName} = ${handlerBody} as a named function or useCallback`);
388
+ this.modified = true;
389
+ this.fixes.push({
390
+ issueId: issue.id,
391
+ category: issue.category,
392
+ line: issue.line,
393
+ message: issue.message,
394
+ applied: true,
395
+ detail: `Replaced inline ${eventName} handler with reference at line ${issue.line}`,
396
+ });
397
+ return;
398
+ }
399
+ }
400
+ }
401
+ if (issue.category === 'performance' && issue.message.includes('Inline object literal')) {
402
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
403
+ const line = this.lines[lineIdx];
404
+ const styleMatch = line.match(/style=\{\{([^}]+)\}\}/);
405
+ if (styleMatch) {
406
+ this.lines[lineIdx] = line.replace(/style=\{\{[^}]+\}\}/, 'style={styles} // TODO: Extract to constant or useMemo');
407
+ this.modified = true;
408
+ this.fixes.push({
409
+ issueId: issue.id,
410
+ category: issue.category,
411
+ line: issue.line,
412
+ message: issue.message,
413
+ applied: true,
414
+ detail: `Replaced inline style object with reference at line ${issue.line}`,
415
+ });
416
+ return;
417
+ }
418
+ }
419
+ }
420
+ if (issue.category === 'security' && issue.message.includes('innerHTML')) {
421
+ if (lineIdx >= 0 && lineIdx < this.lines.length) {
422
+ this.lines[lineIdx] = this.lines[lineIdx] + ' // TODO: Replace innerHTML with React declarative rendering';
423
+ this.modified = true;
424
+ this.fixes.push({
425
+ issueId: issue.id,
426
+ category: issue.category,
427
+ line: issue.line,
428
+ message: issue.message,
429
+ applied: true,
430
+ detail: `Added TODO comment for innerHTML usage at line ${issue.line}`,
431
+ });
432
+ return;
433
+ }
434
+ }
435
+ this.fixes.push({
436
+ issueId: issue.id,
437
+ category: issue.category,
438
+ line: issue.line,
439
+ message: issue.message,
440
+ applied: false,
441
+ detail: 'Refactor fix not implemented for this issue type',
442
+ });
443
+ }
444
+ }
445
+ // ============================================================================
446
+ // MAIN FIX HANDLER
447
+ // ============================================================================
448
+ function fixFromReview(componentDir, componentName, reviewResult) {
449
+ const componentFile = findComponentFile(componentDir, componentName);
450
+ if (!componentFile) {
451
+ return {
452
+ success: false,
453
+ component: componentName,
454
+ file: '',
455
+ summary: { totalFixable: 0, applied: 0, skipped: 0, failed: 0 },
456
+ fixes: [],
457
+ remainingIssues: [],
458
+ typescriptCheck: { passed: false, errors: ['Component file not found'] },
459
+ };
460
+ }
461
+ const content = readFileContent(componentFile);
462
+ if (!content) {
463
+ return {
464
+ success: false,
465
+ component: componentName,
466
+ file: componentFile,
467
+ summary: { totalFixable: 0, applied: 0, skipped: 0, failed: 0 },
468
+ fixes: [],
469
+ remainingIssues: [],
470
+ typescriptCheck: { passed: false, errors: ['Could not read component file'] },
471
+ };
472
+ }
473
+ const fixableIssues = reviewResult.issues.filter(i => i.fixable);
474
+ const scoreBefore = reviewResult.summary.overallScore;
475
+ const gradeBefore = reviewResult.summary.grade;
476
+ const engine = new FixEngine(content, componentFile);
477
+ for (const issue of fixableIssues) {
478
+ engine.applyFix(issue);
479
+ }
480
+ if (engine.hasModifications()) {
481
+ writeFileContent(componentFile, engine.getResult());
482
+ }
483
+ const tsResult = runTypeScriptCheck(componentDir);
484
+ const fixes = engine.getFixes();
485
+ const applied = fixes.filter(f => f.applied).length;
486
+ const skipped = fixes.filter(f => !f.applied && !f.detail.includes('Error')).length;
487
+ const failed = fixes.filter(f => !f.applied && f.detail.includes('Error')).length;
488
+ const remainingIssues = reviewResult.issues.filter(i => !i.fixable);
489
+ return {
490
+ success: true,
491
+ component: componentName,
492
+ file: path.relative(process.cwd(), componentFile),
493
+ summary: {
494
+ totalFixable: fixableIssues.length,
495
+ applied,
496
+ skipped,
497
+ failed,
498
+ scoreBefore,
499
+ gradeBefore,
500
+ },
501
+ fixes,
502
+ remainingIssues,
503
+ typescriptCheck: tsResult,
504
+ };
505
+ }
506
+ // ============================================================================
507
+ // MCP SERVER
508
+ // ============================================================================
509
+ class ComponentFixerServer extends McpServerBase {
510
+ constructor() {
511
+ super({ name: 'component-fixer', version: '3.0.0' });
512
+ }
513
+ registerTools() {
514
+ this.addTool('fix', 'Comprehensive React component fixer - applies fixes from review JSON output for type-safety, accessibility, performance, security, code quality, and more', {
515
+ type: 'object',
516
+ properties: {
517
+ path: {
518
+ type: 'string',
519
+ description: 'Path to the component directory',
520
+ },
521
+ reviewResult: {
522
+ type: 'object',
523
+ description: 'Review result JSON from component-reviewer (optional - if not provided, will run reviewer internally)',
524
+ },
525
+ },
526
+ required: ['path'],
527
+ }, this.handleFix.bind(this));
528
+ this.addTool('fix_from_review', 'Fix component issues from a pre-computed review JSON. Pass the exact output from component-reviewer.', {
529
+ type: 'object',
530
+ properties: {
531
+ path: {
532
+ type: 'string',
533
+ description: 'Path to the component directory',
534
+ },
535
+ reviewJson: {
536
+ type: 'string',
537
+ description: 'JSON string from component-reviewer output',
538
+ },
539
+ },
540
+ required: ['path', 'reviewJson'],
541
+ }, this.handleFixFromReview.bind(this));
542
+ }
543
+ async handleFix(args) {
544
+ const { path: componentPath, reviewResult } = args;
545
+ try {
546
+ const resolvedPath = path.resolve(componentPath);
547
+ if (!fs.existsSync(resolvedPath)) {
548
+ throw new Error(`Component path does not exist: ${componentPath}`);
549
+ }
550
+ let componentDir;
551
+ let componentName;
552
+ const stat = fs.statSync(resolvedPath);
553
+ if (stat.isFile()) {
554
+ componentDir = path.dirname(resolvedPath);
555
+ componentName = path.basename(resolvedPath, path.extname(resolvedPath));
556
+ }
557
+ else {
558
+ componentDir = resolvedPath;
559
+ componentName = path.basename(resolvedPath);
560
+ }
561
+ if (!reviewResult) {
562
+ return {
563
+ content: [{
564
+ type: 'text',
565
+ text: JSON.stringify({
566
+ success: false,
567
+ error: {
568
+ code: 'MISSING_REVIEW',
569
+ message: 'No reviewResult provided. Use fix_from_review with reviewJson.',
570
+ suggestion: 'Run component-reviewer first, then pass the result to fix_from_review.',
571
+ },
572
+ }, null, 2),
573
+ }],
574
+ isError: true,
575
+ };
576
+ }
577
+ const result = fixFromReview(componentDir, componentName, reviewResult);
578
+ return {
579
+ content: [{
580
+ type: 'text',
581
+ text: JSON.stringify(result, null, 2),
582
+ }],
583
+ };
584
+ }
585
+ catch (error) {
586
+ return {
587
+ content: [{
588
+ type: 'text',
589
+ text: JSON.stringify({
590
+ success: false,
591
+ error: {
592
+ code: error instanceof Error ? error.constructor.name : 'UNKNOWN_ERROR',
593
+ message: error instanceof Error ? error.message : String(error),
594
+ suggestion: 'Check input parameters and ensure the component path is valid.',
595
+ timestamp: new Date().toISOString(),
596
+ },
597
+ }, null, 2),
598
+ }],
599
+ isError: true,
600
+ };
601
+ }
602
+ }
603
+ async handleFixFromReview(args) {
604
+ const { path: componentPath, reviewJson } = args;
605
+ try {
606
+ const reviewResult = JSON.parse(reviewJson);
607
+ const resolvedPath = path.resolve(componentPath);
608
+ let componentDir;
609
+ let componentName;
610
+ const stat = fs.statSync(resolvedPath);
611
+ if (stat.isFile()) {
612
+ componentDir = path.dirname(resolvedPath);
613
+ componentName = path.basename(resolvedPath, path.extname(resolvedPath));
614
+ }
615
+ else {
616
+ componentDir = resolvedPath;
617
+ componentName = path.basename(resolvedPath);
618
+ }
619
+ const result = fixFromReview(componentDir, componentName, reviewResult);
620
+ return {
621
+ content: [{
622
+ type: 'text',
623
+ text: JSON.stringify(result, null, 2),
624
+ }],
625
+ };
626
+ }
627
+ catch (error) {
628
+ return {
629
+ content: [{
630
+ type: 'text',
631
+ text: JSON.stringify({
632
+ success: false,
633
+ error: {
634
+ code: error instanceof Error ? error.constructor.name : 'UNKNOWN_ERROR',
635
+ message: error instanceof Error ? error.message : String(error),
636
+ suggestion: 'Ensure reviewJson is valid JSON from component-reviewer.',
637
+ timestamp: new Date().toISOString(),
638
+ },
639
+ }, null, 2),
640
+ }],
641
+ isError: true,
642
+ };
643
+ }
644
+ }
645
+ }
646
+ new ComponentFixerServer().run().catch(console.error);
647
+ //# sourceMappingURL=index.js.map