@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,702 @@
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 MethodSignatureDiffer extends BasePlugin {
16
+ constructor() {
17
+ super();
18
+ this.name = 'diff_method_signatures';
19
+ this.category = 'analyze';
20
+ this.description = 'Compare method signatures between caller and callee to identify parameter mismatches and provide actionable fixes';
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 specific file paths (for multi-file analysis)',
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
+ // Specific parameters for method signature comparison
53
+ callingFile: {
54
+ type: 'string',
55
+ description: 'Absolute path to file containing the method call',
56
+ required: false
57
+ },
58
+ calledClass: {
59
+ type: 'string',
60
+ description: 'Class name containing the called method',
61
+ required: false
62
+ },
63
+ methodName: {
64
+ type: 'string',
65
+ description: 'Name of the method to check',
66
+ required: false
67
+ },
68
+ // Universal parameters
69
+ language: {
70
+ type: 'string',
71
+ description: 'Programming language',
72
+ required: false,
73
+ default: 'javascript'
74
+ },
75
+ analysisDepth: {
76
+ type: 'string',
77
+ description: 'Level of analysis detail',
78
+ enum: ['basic', 'detailed', 'comprehensive'],
79
+ default: 'detailed',
80
+ required: false
81
+ },
82
+ analysisType: {
83
+ type: 'string',
84
+ description: 'Type of analysis to perform',
85
+ enum: ['signature', 'compatibility', 'comprehensive'],
86
+ default: 'comprehensive',
87
+ required: false
88
+ }
89
+ };
90
+ this.analysisCache = getAnalysisCache();
91
+ this.multiFileAnalysis = new MultiFileAnalysis();
92
+ // Cache and analysis utilities are initialized above
93
+ }
94
+ async execute(params, llmClient) {
95
+ return await withSecurity(this, params, llmClient, async (secureParams) => {
96
+ try {
97
+ // 1. Auto-detect analysis mode based on parameters
98
+ const analysisMode = this.detectAnalysisMode(secureParams);
99
+ // 2. Validate parameters based on detected mode
100
+ this.validateParameters(secureParams, analysisMode);
101
+ // 3. Setup model
102
+ const { model, contextLength } = await ModelSetup.getReadyModel(llmClient);
103
+ // 4. Route to appropriate analysis method
104
+ if (analysisMode === 'single-file') {
105
+ return await this.executeSingleFileAnalysis(secureParams, model, contextLength);
106
+ }
107
+ else {
108
+ return await this.executeMultiFileAnalysis(secureParams, model, contextLength);
109
+ }
110
+ }
111
+ catch (error) {
112
+ return ErrorHandler.createExecutionError('diff_method_signatures', error);
113
+ }
114
+ });
115
+ }
116
+ /**
117
+ * Auto-detect whether this is single-file or multi-file analysis
118
+ */
119
+ detectAnalysisMode(params) {
120
+ // Single-file indicators take priority (avoids default parameter issues)
121
+ if (params.code || params.filePath) {
122
+ return 'single-file';
123
+ }
124
+ // Multi-file indicators - method signature comparison typically requires multiple files
125
+ if (params.projectPath || params.files ||
126
+ (params.callingFile && params.calledClass)) {
127
+ return 'multi-file';
128
+ }
129
+ // Default to multi-file for method signature comparison
130
+ return 'multi-file';
131
+ }
132
+ /**
133
+ * Validate parameters based on detected analysis mode
134
+ */
135
+ validateParameters(params, mode) {
136
+ if (mode === 'single-file') {
137
+ ParameterValidator.validateCodeOrFile(params);
138
+ }
139
+ else {
140
+ // For multi-file method signature comparison, we need either:
141
+ // 1. Specific method signature params (callingFile + calledClass + methodName)
142
+ // 2. General project analysis params (projectPath)
143
+ if (params.callingFile && params.calledClass && params.methodName) {
144
+ // Specific method signature comparison
145
+ if (!params.callingFile || typeof params.callingFile !== 'string') {
146
+ throw new Error('callingFile is required and must be a string for method signature comparison');
147
+ }
148
+ if (!params.calledClass || typeof params.calledClass !== 'string') {
149
+ throw new Error('calledClass is required and must be a string for method signature comparison');
150
+ }
151
+ if (!params.methodName || typeof params.methodName !== 'string') {
152
+ throw new Error('methodName is required and must be a string for method signature comparison');
153
+ }
154
+ }
155
+ else {
156
+ // General project analysis
157
+ ParameterValidator.validateProjectPath(params);
158
+ ParameterValidator.validateDepth(params);
159
+ }
160
+ }
161
+ // Universal validations
162
+ ParameterValidator.validateEnum(params, 'analysisType', ['signature', 'compatibility', 'comprehensive']);
163
+ ParameterValidator.validateEnum(params, 'analysisDepth', ['basic', 'detailed', 'comprehensive']);
164
+ }
165
+ /**
166
+ * Execute single-file analysis
167
+ */
168
+ async executeSingleFileAnalysis(params, model, contextLength) {
169
+ // Process single file input
170
+ let codeToAnalyze = params.code;
171
+ if (params.filePath) {
172
+ codeToAnalyze = await readFileContent(params.filePath);
173
+ }
174
+ // Generate prompt stages for single file
175
+ const promptStages = this.getSingleFilePromptStages({
176
+ ...params,
177
+ code: codeToAnalyze
178
+ });
179
+ // Execute with appropriate method
180
+ const promptManager = new ThreeStagePromptManager(contextLength);
181
+ const needsChunking = promptManager.needsChunking(promptStages);
182
+ if (needsChunking) {
183
+ const conversation = promptManager.createChunkedConversation(promptStages);
184
+ const messages = [
185
+ conversation.systemMessage,
186
+ ...conversation.dataMessages,
187
+ conversation.analysisMessage
188
+ ];
189
+ return await ResponseProcessor.executeChunked(messages, model, contextLength, 'diff_method_signatures', 'single');
190
+ }
191
+ else {
192
+ return await ResponseProcessor.executeDirect(promptStages, model, contextLength, 'diff_method_signatures');
193
+ }
194
+ }
195
+ /**
196
+ * Execute multi-file analysis
197
+ */
198
+ async executeMultiFileAnalysis(params, model, contextLength) {
199
+ // For specific method signature comparison
200
+ if (params.callingFile && params.calledClass && params.methodName) {
201
+ return await this.executeSpecificMethodComparison(params, model, contextLength);
202
+ }
203
+ // For general project analysis
204
+ let filesToAnalyze = params.files ||
205
+ await this.discoverRelevantFiles(params.projectPath, params.maxDepth, params.analysisType);
206
+ // Perform multi-file analysis with caching
207
+ const analysisResult = await this.performMultiFileAnalysis(filesToAnalyze, params, model, contextLength);
208
+ // Generate prompt stages for multi-file
209
+ const promptStages = this.getMultiFilePromptStages({
210
+ ...params,
211
+ analysisResult,
212
+ fileCount: filesToAnalyze.length
213
+ });
214
+ // Always use chunking for multi-file
215
+ const promptManager = new ThreeStagePromptManager(contextLength);
216
+ const conversation = promptManager.createChunkedConversation(promptStages);
217
+ const messages = [
218
+ conversation.systemMessage,
219
+ ...conversation.dataMessages,
220
+ conversation.analysisMessage
221
+ ];
222
+ return await ResponseProcessor.executeChunked(messages, model, contextLength, 'diff_method_signatures', 'multifile');
223
+ }
224
+ /**
225
+ * Execute specific method signature comparison
226
+ */
227
+ async executeSpecificMethodComparison(params, model, contextLength) {
228
+ try {
229
+ // Read calling file
230
+ const callingFileContent = await readFileContent(params.callingFile);
231
+ // Find files that might contain the called class
232
+ const { dirname } = await import('path');
233
+ const projectDir = dirname(params.callingFile);
234
+ const classFiles = await this.findClassFiles(params.calledClass, projectDir);
235
+ if (classFiles.length === 0) {
236
+ throw new Error(`Could not find any files containing class: ${params.calledClass}`);
237
+ }
238
+ // Read class file contents
239
+ const classFileContents = {};
240
+ for (const file of classFiles) {
241
+ try {
242
+ classFileContents[file] = await readFileContent(file);
243
+ }
244
+ catch (error) {
245
+ // Skip files we can't read
246
+ }
247
+ }
248
+ // Generate prompt stages for specific comparison
249
+ const promptStages = this.getSpecificComparisonPromptStages({
250
+ ...params,
251
+ callingFileContent,
252
+ classFileContents
253
+ });
254
+ // Execute with appropriate method
255
+ const promptManager = new ThreeStagePromptManager(contextLength);
256
+ const needsChunking = promptManager.needsChunking(promptStages);
257
+ if (needsChunking) {
258
+ const conversation = promptManager.createChunkedConversation(promptStages);
259
+ const messages = [
260
+ conversation.systemMessage,
261
+ ...conversation.dataMessages,
262
+ conversation.analysisMessage
263
+ ];
264
+ return await ResponseProcessor.executeChunked(messages, model, contextLength, 'diff_method_signatures', 'multifile');
265
+ }
266
+ else {
267
+ return await ResponseProcessor.executeDirect(promptStages, model, contextLength, 'diff_method_signatures');
268
+ }
269
+ }
270
+ catch (error) {
271
+ return ErrorHandler.createExecutionError('diff_method_signatures', error);
272
+ }
273
+ }
274
+ /**
275
+ * Single-file prompt stages for method signature analysis within one file
276
+ */
277
+ getSingleFilePromptStages(params) {
278
+ const { code, language, analysisDepth, analysisType } = params;
279
+ const systemAndContext = `You are a senior software engineer and code review expert specializing in ${analysisDepth} method signature analysis and compatibility assessment.
280
+
281
+ **Your Expertise:**
282
+ - 15+ years of experience in ${language} development
283
+ - Deep understanding of method signatures, parameter passing, and type systems
284
+ - Expert in identifying compatibility issues that cause runtime errors
285
+ - Skilled at providing actionable, specific fix recommendations
286
+
287
+ **Analysis Context:**
288
+ - Language: ${language}
289
+ - Analysis Depth: ${analysisDepth}
290
+ - Analysis Type: ${analysisType}
291
+ - Mode: Single File Analysis
292
+
293
+ **Your Mission:**
294
+ Analyze method signatures within this file to identify potential compatibility issues, parameter mismatches, and provide concrete solutions that prevent runtime errors.`;
295
+ const dataPayload = `File content to analyze for method signature issues:
296
+
297
+ \`\`\`${language}
298
+ ${code}
299
+ \`\`\``;
300
+ const outputInstructions = `**COMPREHENSIVE METHOD SIGNATURE ANALYSIS**
301
+
302
+ Provide your analysis in this structured format:
303
+
304
+ ## Method Signature Issues Found
305
+
306
+ ### Issue 1: [Type of Issue]
307
+ - **Method**: \`methodName()\`
308
+ - **Location**: Line X
309
+ - **Problem**: Clear description of the signature issue
310
+ - **Severity**: Critical/High/Medium/Low
311
+ - **Impact**: What happens at runtime
312
+ - **Fix**: Specific code change needed
313
+
314
+ ### Issue 2: [Type of Issue]
315
+ [Continue for all issues found...]
316
+
317
+ ## Method Compatibility Assessment
318
+
319
+ ### Well-Defined Methods ✅
320
+ - List methods with clear, compatible signatures
321
+
322
+ ### Problematic Methods ⚠️
323
+ - List methods with potential issues
324
+
325
+ ## Recommendations
326
+
327
+ ### Immediate Actions Required
328
+ 1. [Most critical fixes needed]
329
+ 2. [Second priority fixes]
330
+
331
+ ### Long-term Improvements
332
+ 1. [Architectural suggestions]
333
+ 2. [Best practice recommendations]
334
+
335
+ ## Code Examples
336
+
337
+ ### Before (Problematic):
338
+ \`\`\`${language}
339
+ // Show problematic signature
340
+ \`\`\`
341
+
342
+ ### After (Fixed):
343
+ \`\`\`${language}
344
+ // Show corrected signature
345
+ \`\`\`
346
+
347
+ **Analysis Confidence**: X%`;
348
+ return { systemAndContext, dataPayload, outputInstructions };
349
+ }
350
+ /**
351
+ * Multi-file prompt stages for cross-file method signature analysis
352
+ */
353
+ getMultiFilePromptStages(params) {
354
+ const { analysisResult, analysisType, analysisDepth, fileCount } = params;
355
+ const systemAndContext = `You are a senior software architect and integration specialist with ${analysisDepth} expertise in cross-file method signature compatibility.
356
+
357
+ **Your Expertise:**
358
+ - 20+ years of experience in large-scale software architecture
359
+ - Expert in identifying integration issues between modules and classes
360
+ - Deep knowledge of method signature compatibility across file boundaries
361
+ - Proven track record of preventing runtime integration failures
362
+
363
+ **Analysis Context:**
364
+ - Analysis Type: ${analysisType}
365
+ - Analysis Depth: ${analysisDepth}
366
+ - Files Analyzed: ${fileCount}
367
+ - Mode: Cross-File Integration Analysis
368
+
369
+ **Your Mission:**
370
+ Analyze method signatures across multiple files to identify integration risks, compatibility issues, and provide architectural recommendations for bulletproof inter-module communication.`;
371
+ const dataPayload = `Cross-file method signature analysis results:
372
+
373
+ ${JSON.stringify(analysisResult, null, 2)}`;
374
+ const outputInstructions = `**CROSS-FILE METHOD SIGNATURE COMPATIBILITY REPORT**
375
+
376
+ ## Executive Summary
377
+ - **Total Integration Points**: [number]
378
+ - **Critical Issues**: [number]
379
+ - **Files at Risk**: [list]
380
+ - **Overall Compatibility**: [percentage]
381
+
382
+ ## Critical Integration Issues
383
+
384
+ ### Issue 1: Method Signature Mismatch
385
+ - **Caller**: \`File A, Line X\`
386
+ - **Callee**: \`File B, Line Y\`
387
+ - **Method**: \`className.methodName()\`
388
+ - **Problem**: Detailed description of signature incompatibility
389
+ - **Runtime Impact**: What breaks when this is called
390
+ - **Severity**: Critical/High/Medium/Low
391
+ - **Fix Strategy**: Step-by-step resolution approach
392
+
393
+ [Continue for all critical issues...]
394
+
395
+ ## Architecture Assessment
396
+
397
+ ### Stable Integration Points ✅
398
+ - List well-designed, compatible method signatures
399
+
400
+ ### Fragile Integration Points ⚠️
401
+ - List risky method calls requiring attention
402
+
403
+ ### Missing Integration Points ❌
404
+ - Methods called but not found
405
+
406
+ ## Compatibility Matrix
407
+
408
+ | Caller File | Called Class | Method | Status | Risk Level |
409
+ |-------------|--------------|---------|---------|------------|
410
+ | FileA.js | ClassB | methodX | ⚠️ Mismatch | High |
411
+ | FileC.ts | ClassD | methodY | ✅ Compatible | Low |
412
+
413
+ ## Actionable Remediation Plan
414
+
415
+ ### Phase 1: Critical Fixes (Do Now)
416
+ 1. **Fix signature mismatch in ClassB.methodX**
417
+ - Change: \`methodX(param1)\` → \`methodX(param1, param2)\`
418
+ - Files to update: [specific files and lines]
419
+ - Test strategy: [how to verify fix]
420
+
421
+ ### Phase 2: Preventive Measures (Next Sprint)
422
+ 1. [Improvements to prevent future issues]
423
+ 2. [Tooling or process changes]
424
+
425
+ ### Phase 3: Architecture Improvements (Future)
426
+ 1. [Systematic improvements to method design]
427
+ 2. [Interface standardization recommendations]
428
+
429
+ ## Code Fixes
430
+
431
+ ### Critical Fix Example:
432
+ **Before (Broken):**
433
+ \`\`\`javascript
434
+ // Caller expects: user.updateProfile(name, email)
435
+ // Method provides: updateProfile(profileData)
436
+ \`\`\`
437
+
438
+ **After (Fixed):**
439
+ \`\`\`javascript
440
+ // Updated method signature for compatibility
441
+ \`\`\`
442
+
443
+ **Risk Assessment**: [Low/Medium/High] risk of regression`;
444
+ return { systemAndContext, dataPayload, outputInstructions };
445
+ }
446
+ /**
447
+ * Specific comparison prompt stages for targeted method signature analysis
448
+ */
449
+ getSpecificComparisonPromptStages(params) {
450
+ const { callingFile, calledClass, methodName, callingFileContent, classFileContents } = params;
451
+ const getBasename = (filePath) => {
452
+ const parts = filePath.replace(/\\/g, '/').split('/');
453
+ return parts[parts.length - 1];
454
+ };
455
+ const systemAndContext = `You are a world-class debugging specialist and method signature expert with forensic-level attention to detail.
456
+
457
+ **Your Expertise:**
458
+ - 25+ years of experience hunting down method signature bugs
459
+ - Expert in parameter compatibility, type coercion, and runtime behavior
460
+ - Legendary ability to spot subtle signature mismatches that cause production failures
461
+ - Known for providing surgical-precision fixes that solve problems permanently
462
+
463
+ **Debugging Mission:**
464
+ - **Target Method**: \`${calledClass}.${methodName}()\`
465
+ - **Calling File**: ${getBasename(callingFile)}
466
+ - **Called Class**: ${calledClass}
467
+
468
+ **Your Task:**
469
+ Perform forensic analysis of this specific method signature issue. Find the exact incompatibility, understand the runtime impact, and provide a bulletproof fix.`;
470
+ const dataPayload = `**=== CALLING FILE CONTENT ===**
471
+ File: ${callingFile}
472
+
473
+ ${callingFileContent}
474
+
475
+ **=== CLASS DEFINITION FILES ===**
476
+ ${Object.entries(classFileContents).map(([file, content]) => `File: ${file}\n${content}\n${'='.repeat(80)}`).join('\n\n')}`;
477
+ const outputInstructions = `**FORENSIC METHOD SIGNATURE ANALYSIS**
478
+
479
+ ## Method Call Investigation
480
+
481
+ ### 1. Call Site Analysis
482
+ - **File**: ${require('path').basename(callingFile)}
483
+ - **Line Number**: [exact line]
484
+ - **Call Pattern**: \`${calledClass}.${methodName}(parameters here)\`
485
+ - **Parameters Passed**:
486
+ 1. \`param1\` - Type: [type], Value: [value/expression]
487
+ 2. \`param2\` - Type: [type], Value: [value/expression]
488
+ [Continue for all parameters...]
489
+
490
+ ### 2. Method Definition Analysis
491
+ - **File**: [which file contains the class]
492
+ - **Line Number**: [exact line]
493
+ - **Method Signature**: \`${methodName}(expected parameters)\`
494
+ - **Expected Parameters**:
495
+ 1. \`param1\` - Type: [expected type], Required: [yes/no], Default: [if any]
496
+ 2. \`param2\` - Type: [expected type], Required: [yes/no], Default: [if any]
497
+ [Continue for all parameters...]
498
+
499
+ ### 3. Compatibility Assessment
500
+
501
+ #### ✅ Compatible Aspects
502
+ - [List what's working correctly]
503
+
504
+ #### ❌ Incompatibilities Found
505
+ 1. **Parameter Count Mismatch**
506
+ - Passed: X parameters
507
+ - Expected: Y parameters
508
+ - Impact: [specific runtime behavior]
509
+
510
+ 2. **Type Mismatches**
511
+ - Parameter 1: Passing [actualType] but expecting [expectedType]
512
+ - Parameter 2: [continue analysis...]
513
+
514
+ 3. **Parameter Order Issues**
515
+ - [If parameters are in wrong order]
516
+
517
+ ## Runtime Impact Analysis
518
+
519
+ ### What Happens When This Runs:
520
+ - **Best Case**: [if it somehow works]
521
+ - **Most Likely**: [typical failure mode]
522
+ - **Worst Case**: [catastrophic failure scenario]
523
+
524
+ ### Error Messages You'll See:
525
+ \`\`\`
526
+ [Likely error messages or unexpected behavior]
527
+ \`\`\`
528
+
529
+ ## Surgical Fix
530
+
531
+ ### Option 1: Update Method Call (Recommended)
532
+ **File**: ${require('path').basename(callingFile)}
533
+ **Change this:**
534
+ \`\`\`javascript
535
+ ${calledClass}.${methodName}(current_call_here)
536
+ \`\`\`
537
+
538
+ **To this:**
539
+ \`\`\`javascript
540
+ ${calledClass}.${methodName}(corrected_call_here)
541
+ \`\`\`
542
+
543
+ ### Option 2: Update Method Definition (If Needed)
544
+ **File**: [class definition file]
545
+ **Change the method signature if the call is correct but definition is wrong**
546
+
547
+ ### Option 3: Adapter Pattern (For Complex Cases)
548
+ \`\`\`javascript
549
+ // If both sides have valid reasons to stay as-is
550
+ const adapter = {
551
+ ${methodName}: (callerParams) => {
552
+ return ${calledClass}.${methodName}(convertedParams);
553
+ }
554
+ };
555
+ \`\`\`
556
+
557
+ ## Testing Strategy
558
+ 1. **Unit Test**: [specific test to verify fix]
559
+ 2. **Integration Test**: [test the full call path]
560
+ 3. **Regression Prevention**: [ensure fix doesn't break other callers]
561
+
562
+ **Confidence Level**: [High/Medium/Low] - with reasoning
563
+
564
+ **Fix Complexity**: [Simple/Moderate/Complex] - estimated effort required`;
565
+ return { systemAndContext, dataPayload, outputInstructions };
566
+ }
567
+ /**
568
+ * Implement for backwards compatibility
569
+ * The system still expects this method, so we intelligently route to the appropriate stages
570
+ */
571
+ getPromptStages(params) {
572
+ const mode = this.detectAnalysisMode(params);
573
+ // If we have specific method comparison parameters
574
+ if (params.callingFile && params.calledClass && params.methodName) {
575
+ return this.getSpecificComparisonPromptStages(params);
576
+ }
577
+ if (mode === 'single-file') {
578
+ return this.getSingleFilePromptStages(params);
579
+ }
580
+ else {
581
+ return this.getMultiFilePromptStages(params);
582
+ }
583
+ }
584
+ // Multi-file helper methods
585
+ async discoverRelevantFiles(projectPath, maxDepth, analysisType) {
586
+ const extensions = this.getFileExtensions(analysisType);
587
+ return await this.multiFileAnalysis.discoverFiles(projectPath, extensions, maxDepth);
588
+ }
589
+ async performMultiFileAnalysis(files, params, model, contextLength) {
590
+ const cacheKey = this.analysisCache.generateKey('diff_method_signatures', params, files);
591
+ const cached = await this.analysisCache.get(cacheKey);
592
+ if (cached)
593
+ return cached;
594
+ const fileAnalysisResults = await this.multiFileAnalysis.analyzeBatch(files, (file) => this.analyzeIndividualFile(file, params, model), contextLength);
595
+ // Aggregate results into proper analysis result format
596
+ const aggregatedResult = {
597
+ summary: `Method signature analysis of ${files.length} files`,
598
+ findings: fileAnalysisResults,
599
+ data: {
600
+ fileCount: files.length,
601
+ totalSize: fileAnalysisResults.reduce((sum, result) => sum + (result.size || 0), 0),
602
+ methodCalls: this.extractMethodCalls(fileAnalysisResults),
603
+ classDefinitions: this.extractClassDefinitions(fileAnalysisResults)
604
+ }
605
+ };
606
+ await this.analysisCache.cacheAnalysis(cacheKey, aggregatedResult, {
607
+ modelUsed: model.identifier || 'unknown',
608
+ executionTime: Date.now() - Date.now(), // TODO: Track actual execution time
609
+ timestamp: new Date().toISOString()
610
+ });
611
+ return aggregatedResult;
612
+ }
613
+ async analyzeIndividualFile(file, params, model) {
614
+ const content = await import('fs/promises').then(fs => fs.readFile(file, 'utf-8'));
615
+ return {
616
+ filePath: file,
617
+ size: content.length,
618
+ lines: content.split('\n').length,
619
+ extension: await import('path').then(p => p.extname(file)),
620
+ // Extract method calls and class definitions for signature analysis
621
+ methodCalls: this.findMethodCallsInContent(content),
622
+ classDefinitions: this.findClassDefinitionsInContent(content)
623
+ };
624
+ }
625
+ getFileExtensions(analysisType) {
626
+ const extensionMap = {
627
+ 'signature': ['.js', '.ts', '.jsx', '.tsx', '.php', '.py', '.java'],
628
+ 'compatibility': ['.js', '.ts', '.jsx', '.tsx', '.php', '.py', '.java'],
629
+ 'comprehensive': ['.js', '.ts', '.jsx', '.tsx', '.php', '.py', '.java', '.cs', '.cpp']
630
+ };
631
+ return extensionMap[analysisType] || extensionMap.comprehensive;
632
+ }
633
+ extractMethodCalls(results) {
634
+ return results.flatMap(result => result.methodCalls || []);
635
+ }
636
+ extractClassDefinitions(results) {
637
+ return results.flatMap(result => result.classDefinitions || []);
638
+ }
639
+ findMethodCallsInContent(content) {
640
+ // Simple heuristic to find method calls - can be enhanced
641
+ const methodCallPattern = /(\w+)\.(\w+)\s*\(/g;
642
+ const calls = [];
643
+ let match;
644
+ while ((match = methodCallPattern.exec(content)) !== null) {
645
+ calls.push({
646
+ object: match[1],
647
+ method: match[2],
648
+ line: content.substring(0, match.index).split('\n').length
649
+ });
650
+ }
651
+ return calls;
652
+ }
653
+ findClassDefinitionsInContent(content) {
654
+ // Simple heuristic to find class definitions
655
+ const classPattern = /class\s+(\w+)/g;
656
+ const classes = [];
657
+ let match;
658
+ while ((match = classPattern.exec(content)) !== null) {
659
+ classes.push({
660
+ name: match[1],
661
+ line: content.substring(0, match.index).split('\n').length
662
+ });
663
+ }
664
+ return classes;
665
+ }
666
+ /**
667
+ * Find files that might contain the specified class
668
+ */
669
+ async findClassFiles(className, searchDir) {
670
+ const files = await this.multiFileAnalysis.discoverFiles(searchDir, ['.js', '.ts', '.jsx', '.tsx', '.php', '.py', '.java'], 3);
671
+ const classFiles = [];
672
+ for (const file of files) {
673
+ try {
674
+ const content = await readFileContent(file);
675
+ if (this.fileContainsClass(content, className)) {
676
+ classFiles.push(file);
677
+ }
678
+ }
679
+ catch (error) {
680
+ // Skip files we can't read
681
+ }
682
+ }
683
+ return classFiles;
684
+ }
685
+ fileContainsClass(content, className) {
686
+ const classPatterns = [
687
+ new RegExp(`class\\s+${className}\\s*{`, 'i'),
688
+ new RegExp(`class\\s+${className}\\s+extends`, 'i'),
689
+ new RegExp(`class\\s+${className}\\s+implements`, 'i'),
690
+ new RegExp(`export\\s+class\\s+${className}`, 'i'),
691
+ new RegExp(`function\\s+${className}\\s*\\(`, 'i'), // Constructor function
692
+ ];
693
+ return classPatterns.some(pattern => pattern.test(content));
694
+ }
695
+ generateCacheKey(files, params) {
696
+ const fileHash = files.join('|');
697
+ const paramHash = JSON.stringify(params);
698
+ return `${fileHash}_${paramHash}`.substring(0, 64);
699
+ }
700
+ }
701
+ export default MethodSignatureDiffer;
702
+ //# sourceMappingURL=diff-signatures.js.map