@houtini/lm 1.0.13 → 2.0.1

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