@houtini/lm 1.0.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 (260) hide show
  1. package/CHANGELOG.md +273 -0
  2. package/LICENSE +21 -0
  3. package/README.md +203 -0
  4. package/dist/cache/analysis-cache.d.ts +33 -0
  5. package/dist/cache/analysis-cache.d.ts.map +1 -0
  6. package/dist/cache/analysis-cache.js +56 -0
  7. package/dist/cache/analysis-cache.js.map +1 -0
  8. package/dist/cache/cache-manager.d.ts +29 -0
  9. package/dist/cache/cache-manager.d.ts.map +1 -0
  10. package/dist/cache/cache-manager.js +85 -0
  11. package/dist/cache/cache-manager.js.map +1 -0
  12. package/dist/cache/index.d.ts +16 -0
  13. package/dist/cache/index.d.ts.map +1 -0
  14. package/dist/cache/index.js +17 -0
  15. package/dist/cache/index.js.map +1 -0
  16. package/dist/cache/prompt-cache.d.ts +33 -0
  17. package/dist/cache/prompt-cache.d.ts.map +1 -0
  18. package/dist/cache/prompt-cache.js +61 -0
  19. package/dist/cache/prompt-cache.js.map +1 -0
  20. package/dist/config.d.ts +43 -0
  21. package/dist/config.d.ts.map +1 -0
  22. package/dist/config.js +70 -0
  23. package/dist/config.js.map +1 -0
  24. package/dist/core/ThreeStagePromptManager.d.ts +39 -0
  25. package/dist/core/ThreeStagePromptManager.d.ts.map +1 -0
  26. package/dist/core/ThreeStagePromptManager.js +176 -0
  27. package/dist/core/ThreeStagePromptManager.js.map +1 -0
  28. package/dist/index.d.ts +6 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +230 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/plugins/base-plugin.d.ts +47 -0
  33. package/dist/plugins/base-plugin.d.ts.map +1 -0
  34. package/dist/plugins/base-plugin.js +90 -0
  35. package/dist/plugins/base-plugin.js.map +1 -0
  36. package/dist/plugins/index.d.ts +58 -0
  37. package/dist/plugins/index.d.ts.map +1 -0
  38. package/dist/plugins/index.js +161 -0
  39. package/dist/plugins/index.js.map +1 -0
  40. package/dist/plugins/types.d.ts +5 -0
  41. package/dist/plugins/types.d.ts.map +1 -0
  42. package/dist/plugins/types.js +5 -0
  43. package/dist/plugins/types.js.map +1 -0
  44. package/dist/prompts/analyze/code-quality.d.ts +116 -0
  45. package/dist/prompts/analyze/code-quality.d.ts.map +1 -0
  46. package/dist/prompts/analyze/code-quality.js +433 -0
  47. package/dist/prompts/analyze/code-quality.js.map +1 -0
  48. package/dist/prompts/analyze/compare-integration.d.ts +130 -0
  49. package/dist/prompts/analyze/compare-integration.d.ts.map +1 -0
  50. package/dist/prompts/analyze/compare-integration.js +543 -0
  51. package/dist/prompts/analyze/compare-integration.js.map +1 -0
  52. package/dist/prompts/analyze/count-files.d.ts +109 -0
  53. package/dist/prompts/analyze/count-files.d.ts.map +1 -0
  54. package/dist/prompts/analyze/count-files.js +399 -0
  55. package/dist/prompts/analyze/count-files.js.map +1 -0
  56. package/dist/prompts/analyze/database-queries.d.ts +156 -0
  57. package/dist/prompts/analyze/database-queries.d.ts.map +1 -0
  58. package/dist/prompts/analyze/database-queries.js +759 -0
  59. package/dist/prompts/analyze/database-queries.js.map +1 -0
  60. package/dist/prompts/analyze/dependencies.d.ts +97 -0
  61. package/dist/prompts/analyze/dependencies.d.ts.map +1 -0
  62. package/dist/prompts/analyze/dependencies.js +333 -0
  63. package/dist/prompts/analyze/dependencies.js.map +1 -0
  64. package/dist/prompts/analyze/diff-signatures.d.ts +139 -0
  65. package/dist/prompts/analyze/diff-signatures.d.ts.map +1 -0
  66. package/dist/prompts/analyze/diff-signatures.js +702 -0
  67. package/dist/prompts/analyze/diff-signatures.js.map +1 -0
  68. package/dist/prompts/analyze/find-patterns.d.ts +128 -0
  69. package/dist/prompts/analyze/find-patterns.d.ts.map +1 -0
  70. package/dist/prompts/analyze/find-patterns.js +520 -0
  71. package/dist/prompts/analyze/find-patterns.js.map +1 -0
  72. package/dist/prompts/analyze/find-unused-css.d.ts +151 -0
  73. package/dist/prompts/analyze/find-unused-css.d.ts.map +1 -0
  74. package/dist/prompts/analyze/find-unused-css.js +754 -0
  75. package/dist/prompts/analyze/find-unused-css.js.map +1 -0
  76. package/dist/prompts/analyze/n8n-workflow.d.ts +137 -0
  77. package/dist/prompts/analyze/n8n-workflow.d.ts.map +1 -0
  78. package/dist/prompts/analyze/n8n-workflow.js +529 -0
  79. package/dist/prompts/analyze/n8n-workflow.js.map +1 -0
  80. package/dist/prompts/analyze/project-structure.d.ts +126 -0
  81. package/dist/prompts/analyze/project-structure.d.ts.map +1 -0
  82. package/dist/prompts/analyze/project-structure.js +569 -0
  83. package/dist/prompts/analyze/project-structure.js.map +1 -0
  84. package/dist/prompts/analyze/security-audit.d.ts +142 -0
  85. package/dist/prompts/analyze/security-audit.d.ts.map +1 -0
  86. package/dist/prompts/analyze/security-audit.js +637 -0
  87. package/dist/prompts/analyze/security-audit.js.map +1 -0
  88. package/dist/prompts/analyze/single-file.d.ts +162 -0
  89. package/dist/prompts/analyze/single-file.d.ts.map +1 -0
  90. package/dist/prompts/analyze/single-file.js +665 -0
  91. package/dist/prompts/analyze/single-file.js.map +1 -0
  92. package/dist/prompts/analyze/trace-execution.d.ts +126 -0
  93. package/dist/prompts/analyze/trace-execution.d.ts.map +1 -0
  94. package/dist/prompts/analyze/trace-execution.js +609 -0
  95. package/dist/prompts/analyze/trace-execution.js.map +1 -0
  96. package/dist/prompts/analyze/wordpress-plugin-audit.d.ts +116 -0
  97. package/dist/prompts/analyze/wordpress-plugin-audit.d.ts.map +1 -0
  98. package/dist/prompts/analyze/wordpress-plugin-audit.js +454 -0
  99. package/dist/prompts/analyze/wordpress-plugin-audit.js.map +1 -0
  100. package/dist/prompts/analyze/wordpress-security.d.ts +146 -0
  101. package/dist/prompts/analyze/wordpress-security.d.ts.map +1 -0
  102. package/dist/prompts/analyze/wordpress-security.js +698 -0
  103. package/dist/prompts/analyze/wordpress-security.js.map +1 -0
  104. package/dist/prompts/analyze/wordpress-theme-audit.d.ts +114 -0
  105. package/dist/prompts/analyze/wordpress-theme-audit.d.ts.map +1 -0
  106. package/dist/prompts/analyze/wordpress-theme-audit.js +538 -0
  107. package/dist/prompts/analyze/wordpress-theme-audit.js.map +1 -0
  108. package/dist/prompts/custom/custom-prompt.d.ts +135 -0
  109. package/dist/prompts/custom/custom-prompt.d.ts.map +1 -0
  110. package/dist/prompts/custom/custom-prompt.js +419 -0
  111. package/dist/prompts/custom/custom-prompt.js.map +1 -0
  112. package/dist/prompts/fun/arcade-game.d.ts +152 -0
  113. package/dist/prompts/fun/arcade-game.d.ts.map +1 -0
  114. package/dist/prompts/fun/arcade-game.js +653 -0
  115. package/dist/prompts/fun/arcade-game.js.map +1 -0
  116. package/dist/prompts/fun/create_text_adventure.d.ts +100 -0
  117. package/dist/prompts/fun/create_text_adventure.d.ts.map +1 -0
  118. package/dist/prompts/fun/create_text_adventure.js +397 -0
  119. package/dist/prompts/fun/create_text_adventure.js.map +1 -0
  120. package/dist/prompts/fun/css-art-generator.d.ts +168 -0
  121. package/dist/prompts/fun/css-art-generator.d.ts.map +1 -0
  122. package/dist/prompts/fun/css-art-generator.js +827 -0
  123. package/dist/prompts/fun/css-art-generator.js.map +1 -0
  124. package/dist/prompts/generate/project-documentation.d.ts +137 -0
  125. package/dist/prompts/generate/project-documentation.d.ts.map +1 -0
  126. package/dist/prompts/generate/project-documentation.js +666 -0
  127. package/dist/prompts/generate/project-documentation.js.map +1 -0
  128. package/dist/prompts/generate/refactoring.d.ts +164 -0
  129. package/dist/prompts/generate/refactoring.d.ts.map +1 -0
  130. package/dist/prompts/generate/refactoring.js +621 -0
  131. package/dist/prompts/generate/refactoring.js.map +1 -0
  132. package/dist/prompts/generate/responsive-component.d.ts +147 -0
  133. package/dist/prompts/generate/responsive-component.d.ts.map +1 -0
  134. package/dist/prompts/generate/responsive-component.js +955 -0
  135. package/dist/prompts/generate/responsive-component.js.map +1 -0
  136. package/dist/prompts/generate/typescript-conversion.d.ts +144 -0
  137. package/dist/prompts/generate/typescript-conversion.d.ts.map +1 -0
  138. package/dist/prompts/generate/typescript-conversion.js +527 -0
  139. package/dist/prompts/generate/typescript-conversion.js.map +1 -0
  140. package/dist/prompts/generate/unit-tests.d.ts +139 -0
  141. package/dist/prompts/generate/unit-tests.d.ts.map +1 -0
  142. package/dist/prompts/generate/unit-tests.js +578 -0
  143. package/dist/prompts/generate/unit-tests.js.map +1 -0
  144. package/dist/prompts/generate/wordpress-plugin.d.ts +179 -0
  145. package/dist/prompts/generate/wordpress-plugin.d.ts.map +1 -0
  146. package/dist/prompts/generate/wordpress-plugin.js +763 -0
  147. package/dist/prompts/generate/wordpress-plugin.js.map +1 -0
  148. package/dist/prompts/generate/wordpress-theme-from-static.d.ts +177 -0
  149. package/dist/prompts/generate/wordpress-theme-from-static.d.ts.map +1 -0
  150. package/dist/prompts/generate/wordpress-theme-from-static.js +695 -0
  151. package/dist/prompts/generate/wordpress-theme-from-static.js.map +1 -0
  152. package/dist/prompts/shared/cache-manager.d.ts +45 -0
  153. package/dist/prompts/shared/cache-manager.d.ts.map +1 -0
  154. package/dist/prompts/shared/cache-manager.js +129 -0
  155. package/dist/prompts/shared/cache-manager.js.map +1 -0
  156. package/dist/prompts/shared/helpers.d.ts +39 -0
  157. package/dist/prompts/shared/helpers.d.ts.map +1 -0
  158. package/dist/prompts/shared/helpers.js +151 -0
  159. package/dist/prompts/shared/helpers.js.map +1 -0
  160. package/dist/prompts/shared/templates.d.ts +35 -0
  161. package/dist/prompts/shared/templates.d.ts.map +1 -0
  162. package/dist/prompts/shared/templates.js +77 -0
  163. package/dist/prompts/shared/templates.js.map +1 -0
  164. package/dist/prompts/shared/types.d.ts +112 -0
  165. package/dist/prompts/shared/types.d.ts.map +1 -0
  166. package/dist/prompts/shared/types.js +5 -0
  167. package/dist/prompts/shared/types.js.map +1 -0
  168. package/dist/prompts/system/find-unused-files.d.ts +106 -0
  169. package/dist/prompts/system/find-unused-files.d.ts.map +1 -0
  170. package/dist/prompts/system/find-unused-files.js +353 -0
  171. package/dist/prompts/system/find-unused-files.js.map +1 -0
  172. package/dist/security/index.d.ts +39 -0
  173. package/dist/security/index.d.ts.map +1 -0
  174. package/dist/security/index.js +46 -0
  175. package/dist/security/index.js.map +1 -0
  176. package/dist/security/integration-helpers.d.ts +121 -0
  177. package/dist/security/integration-helpers.d.ts.map +1 -0
  178. package/dist/security/integration-helpers.js +190 -0
  179. package/dist/security/integration-helpers.js.map +1 -0
  180. package/dist/security/output-encoder.d.ts +94 -0
  181. package/dist/security/output-encoder.d.ts.map +1 -0
  182. package/dist/security/output-encoder.js +295 -0
  183. package/dist/security/output-encoder.js.map +1 -0
  184. package/dist/security/prompt-injection-guard.d.ts +59 -0
  185. package/dist/security/prompt-injection-guard.d.ts.map +1 -0
  186. package/dist/security/prompt-injection-guard.js +249 -0
  187. package/dist/security/prompt-injection-guard.js.map +1 -0
  188. package/dist/security/sanitisation.d.ts +67 -0
  189. package/dist/security/sanitisation.d.ts.map +1 -0
  190. package/dist/security/sanitisation.js +398 -0
  191. package/dist/security/sanitisation.js.map +1 -0
  192. package/dist/security/security-service.d.ts +103 -0
  193. package/dist/security/security-service.d.ts.map +1 -0
  194. package/dist/security/security-service.js +303 -0
  195. package/dist/security/security-service.js.map +1 -0
  196. package/dist/security-config.d.ts +45 -0
  197. package/dist/security-config.d.ts.map +1 -0
  198. package/dist/security-config.js +63 -0
  199. package/dist/security-config.js.map +1 -0
  200. package/dist/system/function-list.d.ts +61 -0
  201. package/dist/system/function-list.d.ts.map +1 -0
  202. package/dist/system/function-list.js +111 -0
  203. package/dist/system/function-list.js.map +1 -0
  204. package/dist/system/function-registry.d.ts +23 -0
  205. package/dist/system/function-registry.d.ts.map +1 -0
  206. package/dist/system/function-registry.js +136 -0
  207. package/dist/system/function-registry.js.map +1 -0
  208. package/dist/system/health-check.d.ts +33 -0
  209. package/dist/system/health-check.d.ts.map +1 -0
  210. package/dist/system/health-check.js +98 -0
  211. package/dist/system/health-check.js.map +1 -0
  212. package/dist/system/path-resolver.d.ts +55 -0
  213. package/dist/system/path-resolver.d.ts.map +1 -0
  214. package/dist/system/path-resolver.js +90 -0
  215. package/dist/system/path-resolver.js.map +1 -0
  216. package/dist/templates/plugin-template.d.ts +121 -0
  217. package/dist/templates/plugin-template.d.ts.map +1 -0
  218. package/dist/templates/plugin-template.js +450 -0
  219. package/dist/templates/plugin-template.js.map +1 -0
  220. package/dist/types/chunking-types.d.ts +88 -0
  221. package/dist/types/chunking-types.d.ts.map +1 -0
  222. package/dist/types/chunking-types.js +18 -0
  223. package/dist/types/chunking-types.js.map +1 -0
  224. package/dist/types/prompt-stages.d.ts +42 -0
  225. package/dist/types/prompt-stages.d.ts.map +1 -0
  226. package/dist/types/prompt-stages.js +6 -0
  227. package/dist/types/prompt-stages.js.map +1 -0
  228. package/dist/types.d.ts +46 -0
  229. package/dist/types.d.ts.map +1 -0
  230. package/dist/types.js +6 -0
  231. package/dist/types.js.map +1 -0
  232. package/dist/utils/css-parser.d.ts +26 -0
  233. package/dist/utils/css-parser.d.ts.map +1 -0
  234. package/dist/utils/css-parser.js +117 -0
  235. package/dist/utils/css-parser.js.map +1 -0
  236. package/dist/utils/path-resolver.d.ts +13 -0
  237. package/dist/utils/path-resolver.d.ts.map +1 -0
  238. package/dist/utils/path-resolver.js +78 -0
  239. package/dist/utils/path-resolver.js.map +1 -0
  240. package/dist/utils/plugin-utilities.d.ts +171 -0
  241. package/dist/utils/plugin-utilities.d.ts.map +1 -0
  242. package/dist/utils/plugin-utilities.js +221 -0
  243. package/dist/utils/plugin-utilities.js.map +1 -0
  244. package/dist/utils/streamHandler.d.ts +3 -0
  245. package/dist/utils/streamHandler.d.ts.map +1 -0
  246. package/dist/utils/streamHandler.js +137 -0
  247. package/dist/utils/streamHandler.js.map +1 -0
  248. package/dist/validation/output-validator.d.ts +136 -0
  249. package/dist/validation/output-validator.d.ts.map +1 -0
  250. package/dist/validation/output-validator.js +262 -0
  251. package/dist/validation/output-validator.js.map +1 -0
  252. package/dist/validation/response-factory.d.ts +44 -0
  253. package/dist/validation/response-factory.d.ts.map +1 -0
  254. package/dist/validation/response-factory.js +202 -0
  255. package/dist/validation/response-factory.js.map +1 -0
  256. package/dist/validation/schemas.d.ts +519 -0
  257. package/dist/validation/schemas.d.ts.map +1 -0
  258. package/dist/validation/schemas.js +6 -0
  259. package/dist/validation/schemas.js.map +1 -0
  260. package/package.json +72 -0
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Plugin Template - Modern v4.2 (Single Source of Truth)
3
+ *
4
+ * Universal template that intelligently handles both single-file and multi-file analysis
5
+ * Automatically detects analysis type based on provided parameters
6
+ *
7
+ * Copy this template for creating any new plugin - it adapts to your needs
8
+ */
9
+ import { BasePlugin } from '../../plugins/base-plugin.js';
10
+ import { IPromptPlugin } from '../shared/types.js';
11
+ import { PromptStages } from '../../types/prompt-stages.js';
12
+ export declare class IntegrationComparator extends BasePlugin implements IPromptPlugin {
13
+ name: string;
14
+ category: "analyze";
15
+ description: string;
16
+ parameters: {
17
+ code: {
18
+ type: "string";
19
+ description: string;
20
+ required: boolean;
21
+ };
22
+ filePath: {
23
+ type: "string";
24
+ description: string;
25
+ required: boolean;
26
+ };
27
+ projectPath: {
28
+ type: "string";
29
+ description: string;
30
+ required: boolean;
31
+ };
32
+ files: {
33
+ type: "array";
34
+ description: string;
35
+ required: boolean;
36
+ items: {
37
+ type: "string";
38
+ };
39
+ };
40
+ maxDepth: {
41
+ type: "number";
42
+ description: string;
43
+ required: boolean;
44
+ default: number;
45
+ };
46
+ language: {
47
+ type: "string";
48
+ description: string;
49
+ required: boolean;
50
+ default: string;
51
+ };
52
+ analysisDepth: {
53
+ type: "string";
54
+ description: string;
55
+ enum: string[];
56
+ default: string;
57
+ required: boolean;
58
+ };
59
+ analysisType: {
60
+ type: "string";
61
+ description: string;
62
+ enum: string[];
63
+ default: string;
64
+ required: boolean;
65
+ };
66
+ focus: {
67
+ type: "array";
68
+ description: string;
69
+ required: boolean;
70
+ default: any[];
71
+ items: {
72
+ type: "string";
73
+ };
74
+ };
75
+ };
76
+ private analysisCache;
77
+ private multiFileAnalysis;
78
+ constructor();
79
+ execute(params: any, llmClient: any): Promise<any>;
80
+ /**
81
+ * Auto-detect whether this is single-file or multi-file analysis
82
+ * Integration comparison is primarily a multi-file operation
83
+ */
84
+ private detectAnalysisMode;
85
+ /**
86
+ * Validate parameters based on detected analysis mode
87
+ */
88
+ private validateParameters;
89
+ /**
90
+ * Execute single-file analysis for integration patterns
91
+ */
92
+ private executeSingleFileAnalysis;
93
+ /**
94
+ * Execute multi-file analysis for cross-file integration
95
+ */
96
+ private executeMultiFileAnalysis;
97
+ /**
98
+ * Single-file integration pattern analysis
99
+ */
100
+ private getSingleFilePromptStages;
101
+ /**
102
+ * Multi-file cross-integration analysis
103
+ */
104
+ private getMultiFilePromptStages;
105
+ /**
106
+ * Backwards compatibility method
107
+ */
108
+ getPromptStages(params: any): PromptStages;
109
+ private discoverRelevantFiles;
110
+ private performMultiFileAnalysis;
111
+ private analyzeIndividualFile;
112
+ private countExports;
113
+ private countImports;
114
+ private countMethods;
115
+ private countInterfaces;
116
+ private identifyIntegrationPatterns;
117
+ private identifyPotentialIssues;
118
+ private extractExports;
119
+ private extractImports;
120
+ private extractMethods;
121
+ private extractInterfaces;
122
+ private extractFileImports;
123
+ private extractFileExports;
124
+ private extractFileMethods;
125
+ private extractFileInterfaces;
126
+ private getFileExtensions;
127
+ private generateCacheKey;
128
+ }
129
+ export default IntegrationComparator;
130
+ //# sourceMappingURL=compare-integration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare-integration.d.ts","sourceRoot":"","sources":["../../../src/prompts/analyze/compare-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAY5D,qBAAa,qBAAsB,SAAQ,UAAW,YAAW,aAAa;IAC5E,IAAI,SAAyB;IAC7B,QAAQ,EAAG,SAAS,CAAU;IAC9B,WAAW,SAA+J;IAG1K,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4DR;IAEF,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,iBAAiB,CAA2B;;IAO9C,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;IAyBzC;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAe1B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAmB1B;;OAEG;YACW,yBAAyB;IA0CvC;;OAEG;YACW,wBAAwB;IA0CtC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAwDjC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAmGhC;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,YAAY;YAW5B,qBAAqB;YASrB,wBAAwB;YAsDxB,qBAAqB;IA2BnC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,2BAA2B;IAenC,OAAO,CAAC,uBAAuB;IAgB/B,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,kBAAkB;IAgB1B,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,gBAAgB;CAKzB;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,543 @@
1
+ /**
2
+ * Plugin Template - Modern v4.2 (Single Source of Truth)
3
+ *
4
+ * Universal template that intelligently handles both single-file and multi-file analysis
5
+ * Automatically detects analysis type based on provided parameters
6
+ *
7
+ * Copy this template for creating any new plugin - it adapts to your needs
8
+ */
9
+ import { BasePlugin } from '../../plugins/base-plugin.js';
10
+ import { ThreeStagePromptManager } from '../../core/ThreeStagePromptManager.js';
11
+ import { withSecurity } from '../../security/integration-helpers.js';
12
+ import { readFileContent } from '../shared/helpers.js';
13
+ import { ModelSetup, ResponseProcessor, ParameterValidator, ErrorHandler, MultiFileAnalysis } from '../../utils/plugin-utilities.js';
14
+ import { getAnalysisCache } from '../../cache/index.js';
15
+ export class IntegrationComparator extends BasePlugin {
16
+ constructor() {
17
+ super();
18
+ this.name = 'compare_integration';
19
+ this.category = 'analyze';
20
+ this.description = 'Compare integration between multiple files to identify mismatches, missing imports, and compatibility issues. Returns actionable fixes with line numbers.';
21
+ // Universal parameter set - supports both single and multi-file scenarios
22
+ this.parameters = {
23
+ // Single-file parameters
24
+ code: {
25
+ type: 'string',
26
+ description: 'The code to analyze (for single-file analysis)',
27
+ required: false
28
+ },
29
+ filePath: {
30
+ type: 'string',
31
+ description: 'Path to single file to analyze',
32
+ required: false
33
+ },
34
+ // Multi-file parameters
35
+ projectPath: {
36
+ type: 'string',
37
+ description: 'Path to project root (for multi-file analysis)',
38
+ required: false
39
+ },
40
+ files: {
41
+ type: 'array',
42
+ description: 'Array of absolute file paths to analyze',
43
+ required: false,
44
+ items: { type: 'string' }
45
+ },
46
+ maxDepth: {
47
+ type: 'number',
48
+ description: 'Maximum directory depth for multi-file discovery (1-5)',
49
+ required: false,
50
+ default: 3
51
+ },
52
+ // Universal parameters
53
+ language: {
54
+ type: 'string',
55
+ description: 'Programming language',
56
+ required: false,
57
+ default: 'javascript'
58
+ },
59
+ analysisDepth: {
60
+ type: 'string',
61
+ description: 'Level of analysis detail',
62
+ enum: ['basic', 'detailed', 'comprehensive'],
63
+ default: 'detailed',
64
+ required: false
65
+ },
66
+ analysisType: {
67
+ type: 'string',
68
+ description: 'Type of integration analysis to perform',
69
+ enum: ['integration', 'compatibility', 'dependencies'],
70
+ default: 'integration',
71
+ required: false
72
+ },
73
+ focus: {
74
+ type: 'array',
75
+ description: 'Specific areas to focus on: method_compatibility, namespace_dependencies, data_flow, missing_connections',
76
+ required: false,
77
+ default: [],
78
+ items: { type: 'string' }
79
+ }
80
+ };
81
+ this.analysisCache = getAnalysisCache();
82
+ this.multiFileAnalysis = new MultiFileAnalysis();
83
+ // Cache and analysis utilities are initialized above
84
+ }
85
+ async execute(params, llmClient) {
86
+ return await withSecurity(this, params, llmClient, async (secureParams) => {
87
+ try {
88
+ // 1. Auto-detect analysis mode based on parameters
89
+ const analysisMode = this.detectAnalysisMode(secureParams);
90
+ // 2. Validate parameters based on detected mode
91
+ this.validateParameters(secureParams, analysisMode);
92
+ // 3. Setup model
93
+ const { model, contextLength } = await ModelSetup.getReadyModel(llmClient);
94
+ // 4. Route to appropriate analysis method
95
+ if (analysisMode === 'single-file') {
96
+ return await this.executeSingleFileAnalysis(secureParams, model, contextLength);
97
+ }
98
+ else {
99
+ return await this.executeMultiFileAnalysis(secureParams, model, contextLength);
100
+ }
101
+ }
102
+ catch (error) {
103
+ return ErrorHandler.createExecutionError('compare_integration', error);
104
+ }
105
+ });
106
+ }
107
+ /**
108
+ * Auto-detect whether this is single-file or multi-file analysis
109
+ * Integration comparison is primarily a multi-file operation
110
+ */
111
+ detectAnalysisMode(params) {
112
+ // Single-file indicators (for analyzing integration patterns within one file)
113
+ if (params.code || (params.filePath && !params.files && !params.projectPath)) {
114
+ return 'single-file';
115
+ }
116
+ // Multi-file indicators - primary use case
117
+ if (params.projectPath || params.files) {
118
+ return 'multi-file';
119
+ }
120
+ // Default to multi-file for integration comparison
121
+ return 'multi-file';
122
+ }
123
+ /**
124
+ * Validate parameters based on detected analysis mode
125
+ */
126
+ validateParameters(params, mode) {
127
+ if (mode === 'single-file') {
128
+ ParameterValidator.validateCodeOrFile(params);
129
+ }
130
+ else {
131
+ // For multi-file, we need either projectPath OR files (at least 2)
132
+ if (!params.projectPath && (!params.files || params.files.length < 2)) {
133
+ throw new Error('Multi-file integration analysis requires either projectPath or at least 2 files');
134
+ }
135
+ if (params.projectPath) {
136
+ ParameterValidator.validateProjectPath(params);
137
+ ParameterValidator.validateDepth(params);
138
+ }
139
+ }
140
+ // Universal validations
141
+ ParameterValidator.validateEnum(params, 'analysisType', ['integration', 'compatibility', 'dependencies']);
142
+ ParameterValidator.validateEnum(params, 'analysisDepth', ['basic', 'detailed', 'comprehensive']);
143
+ }
144
+ /**
145
+ * Execute single-file analysis for integration patterns
146
+ */
147
+ async executeSingleFileAnalysis(params, model, contextLength) {
148
+ // Process single file input
149
+ let codeToAnalyze = params.code;
150
+ if (params.filePath) {
151
+ codeToAnalyze = await readFileContent(params.filePath);
152
+ }
153
+ // Generate prompt stages for single file
154
+ const promptStages = this.getSingleFilePromptStages({
155
+ ...params,
156
+ code: codeToAnalyze
157
+ });
158
+ // Execute with appropriate method
159
+ const promptManager = new ThreeStagePromptManager(contextLength);
160
+ const needsChunking = promptManager.needsChunking(promptStages);
161
+ if (needsChunking) {
162
+ const conversation = promptManager.createChunkedConversation(promptStages);
163
+ const messages = [
164
+ conversation.systemMessage,
165
+ ...conversation.dataMessages,
166
+ conversation.analysisMessage
167
+ ];
168
+ return await ResponseProcessor.executeChunked(messages, model, contextLength, 'compare_integration', 'single');
169
+ }
170
+ else {
171
+ return await ResponseProcessor.executeDirect(promptStages, model, contextLength, 'compare_integration');
172
+ }
173
+ }
174
+ /**
175
+ * Execute multi-file analysis for cross-file integration
176
+ */
177
+ async executeMultiFileAnalysis(params, model, contextLength) {
178
+ // Discover files
179
+ let filesToAnalyze = params.files ||
180
+ await this.discoverRelevantFiles(params.projectPath, params.maxDepth, params.analysisType);
181
+ // Perform multi-file analysis with caching
182
+ const analysisResult = await this.performMultiFileAnalysis(filesToAnalyze, params, model, contextLength);
183
+ // Generate prompt stages for multi-file
184
+ const promptStages = this.getMultiFilePromptStages({
185
+ ...params,
186
+ analysisResult,
187
+ fileCount: filesToAnalyze.length
188
+ });
189
+ // Always use chunking for multi-file
190
+ const promptManager = new ThreeStagePromptManager(contextLength);
191
+ const conversation = promptManager.createChunkedConversation(promptStages);
192
+ const messages = [
193
+ conversation.systemMessage,
194
+ ...conversation.dataMessages,
195
+ conversation.analysisMessage
196
+ ];
197
+ return await ResponseProcessor.executeChunked(messages, model, contextLength, 'compare_integration', 'multifile');
198
+ }
199
+ /**
200
+ * Single-file integration pattern analysis
201
+ */
202
+ getSingleFilePromptStages(params) {
203
+ const { code, language, analysisDepth, analysisType, focus } = params;
204
+ const systemAndContext = `You are a senior software architect and integration specialist with 15+ years of experience analyzing ${language} codebases.
205
+
206
+ **ANALYSIS CONTEXT:**
207
+ - Language: ${language}
208
+ - Analysis Depth: ${analysisDepth}
209
+ - Analysis Type: ${analysisType}
210
+ - Focus Areas: ${focus && focus.length > 0 ? focus.join(', ') : 'General integration patterns'}
211
+ - Mode: Single File Integration Pattern Analysis
212
+
213
+ **YOUR EXPERTISE:**
214
+ - Deep understanding of integration patterns and anti-patterns
215
+ - Master of API design, interface contracts, and dependency management
216
+ - Expert in identifying potential integration issues before they cause runtime problems
217
+ - Specialist in providing actionable, specific recommendations with code examples
218
+
219
+ Your task is to analyze this single file for integration readiness, interface design quality, and potential compatibility issues with other components.`;
220
+ const dataPayload = `**FILE TO ANALYZE FOR INTEGRATION PATTERNS:**
221
+
222
+ \`\`\`${language}
223
+ ${code}
224
+ \`\`\``;
225
+ const outputInstructions = `**PROVIDE CLEAN MARKDOWN INTEGRATION ANALYSIS:**
226
+
227
+ # Single File Integration Analysis
228
+
229
+ ## Integration Readiness: [Excellent/Good/Fair/Poor]
230
+
231
+ ## Key Findings
232
+ - **Interface Quality**: [Assessment of exports/public methods]
233
+ - **Dependency Health**: [Import/dependency structure assessment]
234
+ - **Contract Clarity**: [Method signatures and types assessment]
235
+
236
+ ## Integration Issues Found
237
+
238
+ ### Critical Issues
239
+ - [Issue description with line numbers if applicable]
240
+
241
+ ### Recommendations
242
+ 1. [Specific actionable recommendations]
243
+ 2. [Interface improvements needed]
244
+ 3. [Type safety enhancements]
245
+
246
+ ## Integration Strengths
247
+ - [Good patterns already in use]
248
+ - [Defensive programming practices]
249
+
250
+ **Analysis Complete** - Focus on actionable insights, not raw code dumps.`;
251
+ return { systemAndContext, dataPayload, outputInstructions };
252
+ }
253
+ /**
254
+ * Multi-file cross-integration analysis
255
+ */
256
+ getMultiFilePromptStages(params) {
257
+ const { analysisResult, analysisType, analysisDepth, fileCount, focus } = params;
258
+ const systemAndContext = `You are a senior software architect and integration specialist with 15+ years of experience analyzing complex multi-file systems.
259
+
260
+ **ANALYSIS CONTEXT:**
261
+ - Analysis Type: ${analysisType}
262
+ - Analysis Depth: ${analysisDepth}
263
+ - Files Analyzed: ${fileCount}
264
+ - Focus Areas: ${focus && focus.length > 0 ? focus.join(', ') : 'Comprehensive integration analysis'}
265
+ - Mode: Multi-File Integration Comparison
266
+
267
+ **YOUR EXPERTISE:**
268
+ - Master of cross-file dependency analysis and interface compatibility
269
+ - Expert in identifying integration anti-patterns that cause runtime failures
270
+ - Specialist in API contract validation and method signature compatibility
271
+ - Authority on data flow analysis and architectural integration patterns
272
+ - Expert at providing specific, actionable fixes with line numbers and code examples
273
+
274
+ **CRITICAL ANALYSIS AREAS:**
275
+ - Method signature mismatches between files
276
+ - Missing imports and unused exports
277
+ - Data type incompatibilities across interfaces
278
+ - Circular dependency detection
279
+ - Interface contract violations
280
+ - Error handling consistency across file boundaries
281
+
282
+ Your task is to perform deep cross-file integration analysis, identifying ALL compatibility issues with specific fixes.`;
283
+ const dataPayload = `**MULTI-FILE INTEGRATION ANALYSIS DATA:**
284
+
285
+ ${JSON.stringify(analysisResult, null, 2)}`;
286
+ const outputInstructions = `**PROVIDE CLEAN MARKDOWN MULTI-FILE INTEGRATION ANALYSIS:**
287
+
288
+ # Multi-File Integration Analysis Report
289
+
290
+ ## Executive Summary
291
+ - **Overall Integration Health**: [Excellent/Good/Fair/Poor/Critical]
292
+ - **Files Analyzed**: ${fileCount}
293
+ - **Critical Issues**: [Count]
294
+ - **Integration Risk**: [Low/Medium/High/Critical]
295
+
296
+ ## Key Integration Issues Found
297
+
298
+ ### 🚨 Critical Issues (Fix Immediately)
299
+ 1. **[Issue Type]** in [filename.ts:123]
300
+ - **Problem**: [Brief description]
301
+ - **Impact**: [What breaks]
302
+ - **Fix**: [Specific solution]
303
+
304
+ ### ⚠️ High Priority Issues
305
+ 1. **[Issue Type]** between [file1.ts] and [file2.ts]
306
+ - **Problem**: [Description]
307
+ - **Fix**: [Solution]
308
+
309
+ ### 📋 Medium Priority Issues
310
+ - [List of less critical but important issues]
311
+
312
+ ## Method Compatibility Analysis
313
+ - **Compatible Calls**: [Count] ✅
314
+ - **Signature Mismatches**: [Count] ❌
315
+ - **Missing Implementations**: [Count] ⚠️
316
+
317
+ ## Import/Export Health
318
+ - **Clean Dependencies**: [Count] ✅
319
+ - **Unused Exports**: [Count] 🧹
320
+ - **Missing Imports**: [Count] ❌
321
+ - **Circular Dependencies**: [Count] 🔄
322
+
323
+ ## Architecture Assessment
324
+ - **Design Patterns**: [Good patterns found]
325
+ - **Anti-Patterns**: [Problematic patterns]
326
+ - **Coupling**: [Tight/Loose assessment]
327
+
328
+ ## Priority Action Plan
329
+
330
+ ### Phase 1: Critical Fixes (Do First)
331
+ 1. [Fix critical integration breakages]
332
+ 2. [Resolve method signature mismatches]
333
+
334
+ ### Phase 2: Improvements (Do Next)
335
+ 1. [Clean up unused exports]
336
+ 2. [Improve interface consistency]
337
+
338
+ ### Phase 3: Long-term (Do Later)
339
+ 1. [Architectural improvements]
340
+ 2. [Enhanced error handling]
341
+
342
+ ## Integration Testing Recommendations
343
+ - [Specific integration tests to write]
344
+ - [Mock strategies to use]
345
+ - [Error scenarios to test]
346
+
347
+ **Analysis Complete** - Focused on actionable insights, not data dumps.`;
348
+ return { systemAndContext, dataPayload, outputInstructions };
349
+ }
350
+ /**
351
+ * Backwards compatibility method
352
+ */
353
+ getPromptStages(params) {
354
+ const mode = this.detectAnalysisMode(params);
355
+ if (mode === 'single-file') {
356
+ return this.getSingleFilePromptStages(params);
357
+ }
358
+ else {
359
+ return this.getMultiFilePromptStages(params);
360
+ }
361
+ }
362
+ // Multi-file helper methods
363
+ async discoverRelevantFiles(projectPath, maxDepth, analysisType) {
364
+ const extensions = this.getFileExtensions(analysisType);
365
+ return await this.multiFileAnalysis.discoverFiles(projectPath, extensions, maxDepth);
366
+ }
367
+ async performMultiFileAnalysis(files, params, model, contextLength) {
368
+ const cacheKey = this.analysisCache.generateKey('compare_integration', params, files);
369
+ const cached = await this.analysisCache.get(cacheKey);
370
+ if (cached)
371
+ return cached;
372
+ const fileAnalysisResults = await this.multiFileAnalysis.analyzeBatch(files, (file) => this.analyzeIndividualFile(file, params, model), contextLength);
373
+ // Aggregate results for integration analysis (focus on insights, not raw content)
374
+ const aggregatedResult = {
375
+ summary: `Integration analysis of ${files.length} files`,
376
+ integrationInsights: {
377
+ fileCount: files.length,
378
+ totalSize: fileAnalysisResults.reduce((sum, result) => sum + (result.size || 0), 0),
379
+ exportCount: this.countExports(fileAnalysisResults),
380
+ importCount: this.countImports(fileAnalysisResults),
381
+ methodCount: this.countMethods(fileAnalysisResults),
382
+ interfaceCount: this.countInterfaces(fileAnalysisResults),
383
+ integrationPatterns: this.identifyIntegrationPatterns(fileAnalysisResults),
384
+ potentialIssues: this.identifyPotentialIssues(fileAnalysisResults)
385
+ },
386
+ fileList: fileAnalysisResults.map(f => ({
387
+ fileName: f.fileName,
388
+ filePath: f.filePath,
389
+ size: f.size,
390
+ lines: f.lines,
391
+ hasExports: f.integrationInfo?.exports?.length > 0,
392
+ hasImports: f.integrationInfo?.imports?.length > 0,
393
+ methodCount: f.integrationInfo?.methods?.length || 0
394
+ }))
395
+ };
396
+ await this.analysisCache.cacheAnalysis(cacheKey, aggregatedResult, {
397
+ modelUsed: model.identifier || 'unknown',
398
+ executionTime: Date.now() - Date.now(), // TODO: Track actual execution time
399
+ timestamp: new Date().toISOString()
400
+ });
401
+ return aggregatedResult;
402
+ }
403
+ async analyzeIndividualFile(file, params, model) {
404
+ const content = await import('fs/promises').then(fs => fs.readFile(file, 'utf-8'));
405
+ const stats = await import('fs/promises').then(fs => fs.stat(file));
406
+ // Extract integration-relevant information
407
+ const imports = this.extractFileImports(content);
408
+ const exports = this.extractFileExports(content);
409
+ const methods = this.extractFileMethods(content);
410
+ const interfaces = this.extractFileInterfaces(content);
411
+ return {
412
+ filePath: file,
413
+ fileName: file.split(/[/\\]/).pop(),
414
+ size: content.length,
415
+ lines: content.split('\n').length,
416
+ extension: file.split('.').pop() || '',
417
+ modified: stats.mtime,
418
+ content: content.length < 2000 ? content : `[${content.length} characters] - Content available for analysis`, // Minimal content for context
419
+ integrationInfo: {
420
+ imports,
421
+ exports,
422
+ methods,
423
+ interfaces
424
+ }
425
+ };
426
+ }
427
+ countExports(fileResults) {
428
+ return fileResults.reduce((sum, file) => sum + (file.integrationInfo?.exports?.length || 0), 0);
429
+ }
430
+ countImports(fileResults) {
431
+ return fileResults.reduce((sum, file) => sum + (file.integrationInfo?.imports?.length || 0), 0);
432
+ }
433
+ countMethods(fileResults) {
434
+ return fileResults.reduce((sum, file) => sum + (file.integrationInfo?.methods?.length || 0), 0);
435
+ }
436
+ countInterfaces(fileResults) {
437
+ return fileResults.reduce((sum, file) => sum + (file.integrationInfo?.interfaces?.length || 0), 0);
438
+ }
439
+ identifyIntegrationPatterns(fileResults) {
440
+ const patterns = [];
441
+ // Simple pattern detection based on file analysis
442
+ if (fileResults.some(f => f.fileName?.includes('base-') || f.fileName?.includes('Base'))) {
443
+ patterns.push('Inheritance Pattern');
444
+ }
445
+ if (fileResults.some(f => f.fileName?.includes('interface') || f.fileName?.includes('Interface'))) {
446
+ patterns.push('Interface Segregation');
447
+ }
448
+ if (fileResults.some(f => f.fileName?.includes('factory') || f.fileName?.includes('Factory'))) {
449
+ patterns.push('Factory Pattern');
450
+ }
451
+ return patterns;
452
+ }
453
+ identifyPotentialIssues(fileResults) {
454
+ const issues = [];
455
+ // Simple issue detection
456
+ const largeFiles = fileResults.filter(f => f.size > 50000);
457
+ if (largeFiles.length > 0) {
458
+ issues.push(`Large files detected: ${largeFiles.length} files > 50KB`);
459
+ }
460
+ const filesWithManyMethods = fileResults.filter(f => (f.integrationInfo?.methods?.length || 0) > 20);
461
+ if (filesWithManyMethods.length > 0) {
462
+ issues.push(`High method count: ${filesWithManyMethods.length} files with >20 methods`);
463
+ }
464
+ return issues;
465
+ }
466
+ extractExports(fileResults) {
467
+ return fileResults.flatMap(file => file.integrationInfo?.exports || []);
468
+ }
469
+ extractImports(fileResults) {
470
+ return fileResults.flatMap(file => file.integrationInfo?.imports || []);
471
+ }
472
+ extractMethods(fileResults) {
473
+ return fileResults.flatMap(file => file.integrationInfo?.methods || []);
474
+ }
475
+ extractInterfaces(fileResults) {
476
+ return fileResults.flatMap(file => file.integrationInfo?.interfaces || []);
477
+ }
478
+ // Simple pattern matching for integration elements (can be enhanced)
479
+ extractFileImports(content) {
480
+ const importRegex = /import\s+.*\s+from\s+['"`]([^'"`]+)['"`]/g;
481
+ const imports = [];
482
+ let match;
483
+ while ((match = importRegex.exec(content)) !== null) {
484
+ imports.push({
485
+ module: match[1],
486
+ line: content.substring(0, match.index).split('\n').length
487
+ });
488
+ }
489
+ return imports;
490
+ }
491
+ extractFileExports(content) {
492
+ const exportRegex = /export\s+(function|class|const|let|var|interface|type)\s+(\w+)/g;
493
+ const exports = [];
494
+ let match;
495
+ while ((match = exportRegex.exec(content)) !== null) {
496
+ exports.push({
497
+ type: match[1],
498
+ name: match[2],
499
+ line: content.substring(0, match.index).split('\n').length
500
+ });
501
+ }
502
+ return exports;
503
+ }
504
+ extractFileMethods(content) {
505
+ const methodRegex = /(function\s+(\w+)|(\w+)\s*\(.*?\)\s*[{:])/g;
506
+ const methods = [];
507
+ let match;
508
+ while ((match = methodRegex.exec(content)) !== null) {
509
+ methods.push({
510
+ name: match[2] || match[3],
511
+ line: content.substring(0, match.index).split('\n').length
512
+ });
513
+ }
514
+ return methods;
515
+ }
516
+ extractFileInterfaces(content) {
517
+ const interfaceRegex = /interface\s+(\w+)/g;
518
+ const interfaces = [];
519
+ let match;
520
+ while ((match = interfaceRegex.exec(content)) !== null) {
521
+ interfaces.push({
522
+ name: match[1],
523
+ line: content.substring(0, match.index).split('\n').length
524
+ });
525
+ }
526
+ return interfaces;
527
+ }
528
+ getFileExtensions(analysisType) {
529
+ const extensionMap = {
530
+ 'integration': ['.js', '.ts', '.jsx', '.tsx', '.py', '.php', '.java', '.cs'],
531
+ 'compatibility': ['.js', '.ts', '.jsx', '.tsx', '.d.ts'],
532
+ 'dependencies': ['.js', '.ts', '.jsx', '.tsx', '.json', '.package.json']
533
+ };
534
+ return extensionMap[analysisType] || extensionMap.integration;
535
+ }
536
+ generateCacheKey(files, params) {
537
+ const fileHash = files.join('|');
538
+ const paramHash = JSON.stringify(params);
539
+ return `${fileHash}_${paramHash}`.substring(0, 64);
540
+ }
541
+ }
542
+ export default IntegrationComparator;
543
+ //# sourceMappingURL=compare-integration.js.map