@houtini/lm 1.0.13 → 2.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 (262) hide show
  1. package/dist/index.d.ts +5 -3
  2. package/dist/index.js +142 -213
  3. package/dist/index.js.map +1 -1
  4. package/package.json +10 -33
  5. package/CHANGELOG.md +0 -282
  6. package/dist/cache/analysis-cache.d.ts +0 -33
  7. package/dist/cache/analysis-cache.d.ts.map +0 -1
  8. package/dist/cache/analysis-cache.js +0 -56
  9. package/dist/cache/analysis-cache.js.map +0 -1
  10. package/dist/cache/cache-manager.d.ts +0 -29
  11. package/dist/cache/cache-manager.d.ts.map +0 -1
  12. package/dist/cache/cache-manager.js +0 -85
  13. package/dist/cache/cache-manager.js.map +0 -1
  14. package/dist/cache/index.d.ts +0 -16
  15. package/dist/cache/index.d.ts.map +0 -1
  16. package/dist/cache/index.js +0 -17
  17. package/dist/cache/index.js.map +0 -1
  18. package/dist/cache/prompt-cache.d.ts +0 -33
  19. package/dist/cache/prompt-cache.d.ts.map +0 -1
  20. package/dist/cache/prompt-cache.js +0 -61
  21. package/dist/cache/prompt-cache.js.map +0 -1
  22. package/dist/config.d.ts +0 -41
  23. package/dist/config.d.ts.map +0 -1
  24. package/dist/config.js +0 -71
  25. package/dist/config.js.map +0 -1
  26. package/dist/core/ThreeStagePromptManager.d.ts +0 -23
  27. package/dist/core/ThreeStagePromptManager.d.ts.map +0 -1
  28. package/dist/core/ThreeStagePromptManager.js +0 -118
  29. package/dist/core/ThreeStagePromptManager.js.map +0 -1
  30. package/dist/index.d.ts.map +0 -1
  31. package/dist/plugins/base-plugin.d.ts +0 -55
  32. package/dist/plugins/base-plugin.d.ts.map +0 -1
  33. package/dist/plugins/base-plugin.js +0 -120
  34. package/dist/plugins/base-plugin.js.map +0 -1
  35. package/dist/plugins/index.d.ts +0 -58
  36. package/dist/plugins/index.d.ts.map +0 -1
  37. package/dist/plugins/index.js +0 -162
  38. package/dist/plugins/index.js.map +0 -1
  39. package/dist/plugins/types.d.ts +0 -5
  40. package/dist/plugins/types.d.ts.map +0 -1
  41. package/dist/plugins/types.js +0 -5
  42. package/dist/plugins/types.js.map +0 -1
  43. package/dist/prompts/analyze/code-quality.d.ts +0 -116
  44. package/dist/prompts/analyze/code-quality.d.ts.map +0 -1
  45. package/dist/prompts/analyze/code-quality.js +0 -437
  46. package/dist/prompts/analyze/code-quality.js.map +0 -1
  47. package/dist/prompts/analyze/compare-integration.d.ts +0 -130
  48. package/dist/prompts/analyze/compare-integration.d.ts.map +0 -1
  49. package/dist/prompts/analyze/compare-integration.js +0 -547
  50. package/dist/prompts/analyze/compare-integration.js.map +0 -1
  51. package/dist/prompts/analyze/count-files.d.ts +0 -109
  52. package/dist/prompts/analyze/count-files.d.ts.map +0 -1
  53. package/dist/prompts/analyze/count-files.js +0 -403
  54. package/dist/prompts/analyze/count-files.js.map +0 -1
  55. package/dist/prompts/analyze/database-queries.d.ts +0 -156
  56. package/dist/prompts/analyze/database-queries.d.ts.map +0 -1
  57. package/dist/prompts/analyze/database-queries.js +0 -763
  58. package/dist/prompts/analyze/database-queries.js.map +0 -1
  59. package/dist/prompts/analyze/dependencies.d.ts +0 -97
  60. package/dist/prompts/analyze/dependencies.d.ts.map +0 -1
  61. package/dist/prompts/analyze/dependencies.js +0 -337
  62. package/dist/prompts/analyze/dependencies.js.map +0 -1
  63. package/dist/prompts/analyze/diff-signatures.d.ts +0 -139
  64. package/dist/prompts/analyze/diff-signatures.d.ts.map +0 -1
  65. package/dist/prompts/analyze/diff-signatures.js +0 -708
  66. package/dist/prompts/analyze/diff-signatures.js.map +0 -1
  67. package/dist/prompts/analyze/find-patterns.d.ts +0 -128
  68. package/dist/prompts/analyze/find-patterns.d.ts.map +0 -1
  69. package/dist/prompts/analyze/find-patterns.js +0 -524
  70. package/dist/prompts/analyze/find-patterns.js.map +0 -1
  71. package/dist/prompts/analyze/find-unused-css.d.ts +0 -151
  72. package/dist/prompts/analyze/find-unused-css.d.ts.map +0 -1
  73. package/dist/prompts/analyze/find-unused-css.js +0 -760
  74. package/dist/prompts/analyze/find-unused-css.js.map +0 -1
  75. package/dist/prompts/analyze/n8n-workflow.d.ts +0 -137
  76. package/dist/prompts/analyze/n8n-workflow.d.ts.map +0 -1
  77. package/dist/prompts/analyze/n8n-workflow.js +0 -533
  78. package/dist/prompts/analyze/n8n-workflow.js.map +0 -1
  79. package/dist/prompts/analyze/project-structure.d.ts +0 -126
  80. package/dist/prompts/analyze/project-structure.d.ts.map +0 -1
  81. package/dist/prompts/analyze/project-structure.js +0 -573
  82. package/dist/prompts/analyze/project-structure.js.map +0 -1
  83. package/dist/prompts/analyze/security-audit.d.ts +0 -142
  84. package/dist/prompts/analyze/security-audit.d.ts.map +0 -1
  85. package/dist/prompts/analyze/security-audit.js +0 -641
  86. package/dist/prompts/analyze/security-audit.js.map +0 -1
  87. package/dist/prompts/analyze/single-file.d.ts +0 -162
  88. package/dist/prompts/analyze/single-file.d.ts.map +0 -1
  89. package/dist/prompts/analyze/single-file.js +0 -669
  90. package/dist/prompts/analyze/single-file.js.map +0 -1
  91. package/dist/prompts/analyze/trace-execution.d.ts +0 -126
  92. package/dist/prompts/analyze/trace-execution.d.ts.map +0 -1
  93. package/dist/prompts/analyze/trace-execution.js +0 -613
  94. package/dist/prompts/analyze/trace-execution.js.map +0 -1
  95. package/dist/prompts/analyze/wordpress-plugin-audit.d.ts +0 -116
  96. package/dist/prompts/analyze/wordpress-plugin-audit.d.ts.map +0 -1
  97. package/dist/prompts/analyze/wordpress-plugin-audit.js +0 -456
  98. package/dist/prompts/analyze/wordpress-plugin-audit.js.map +0 -1
  99. package/dist/prompts/analyze/wordpress-plugin-readiness.d.ts +0 -103
  100. package/dist/prompts/analyze/wordpress-plugin-readiness.d.ts.map +0 -1
  101. package/dist/prompts/analyze/wordpress-plugin-readiness.js +0 -506
  102. package/dist/prompts/analyze/wordpress-plugin-readiness.js.map +0 -1
  103. package/dist/prompts/analyze/wordpress-security.d.ts +0 -146
  104. package/dist/prompts/analyze/wordpress-security.d.ts.map +0 -1
  105. package/dist/prompts/analyze/wordpress-security.js +0 -702
  106. package/dist/prompts/analyze/wordpress-security.js.map +0 -1
  107. package/dist/prompts/analyze/wordpress-theme-audit.d.ts +0 -114
  108. package/dist/prompts/analyze/wordpress-theme-audit.d.ts.map +0 -1
  109. package/dist/prompts/analyze/wordpress-theme-audit.js +0 -540
  110. package/dist/prompts/analyze/wordpress-theme-audit.js.map +0 -1
  111. package/dist/prompts/custom/custom-prompt.d.ts +0 -135
  112. package/dist/prompts/custom/custom-prompt.d.ts.map +0 -1
  113. package/dist/prompts/custom/custom-prompt.js +0 -421
  114. package/dist/prompts/custom/custom-prompt.js.map +0 -1
  115. package/dist/prompts/fun/arcade-game.d.ts +0 -152
  116. package/dist/prompts/fun/arcade-game.d.ts.map +0 -1
  117. package/dist/prompts/fun/arcade-game.js +0 -657
  118. package/dist/prompts/fun/arcade-game.js.map +0 -1
  119. package/dist/prompts/fun/create_text_adventure.d.ts +0 -100
  120. package/dist/prompts/fun/create_text_adventure.d.ts.map +0 -1
  121. package/dist/prompts/fun/create_text_adventure.js +0 -401
  122. package/dist/prompts/fun/create_text_adventure.js.map +0 -1
  123. package/dist/prompts/fun/css-art-generator.d.ts +0 -168
  124. package/dist/prompts/fun/css-art-generator.d.ts.map +0 -1
  125. package/dist/prompts/fun/css-art-generator.js +0 -831
  126. package/dist/prompts/fun/css-art-generator.js.map +0 -1
  127. package/dist/prompts/generate/project-documentation.d.ts +0 -137
  128. package/dist/prompts/generate/project-documentation.d.ts.map +0 -1
  129. package/dist/prompts/generate/project-documentation.js +0 -670
  130. package/dist/prompts/generate/project-documentation.js.map +0 -1
  131. package/dist/prompts/generate/refactoring.d.ts +0 -164
  132. package/dist/prompts/generate/refactoring.d.ts.map +0 -1
  133. package/dist/prompts/generate/refactoring.js +0 -625
  134. package/dist/prompts/generate/refactoring.js.map +0 -1
  135. package/dist/prompts/generate/responsive-component.d.ts +0 -147
  136. package/dist/prompts/generate/responsive-component.d.ts.map +0 -1
  137. package/dist/prompts/generate/responsive-component.js +0 -957
  138. package/dist/prompts/generate/responsive-component.js.map +0 -1
  139. package/dist/prompts/generate/typescript-conversion.d.ts +0 -144
  140. package/dist/prompts/generate/typescript-conversion.d.ts.map +0 -1
  141. package/dist/prompts/generate/typescript-conversion.js +0 -531
  142. package/dist/prompts/generate/typescript-conversion.js.map +0 -1
  143. package/dist/prompts/generate/unit-tests.d.ts +0 -139
  144. package/dist/prompts/generate/unit-tests.d.ts.map +0 -1
  145. package/dist/prompts/generate/unit-tests.js +0 -582
  146. package/dist/prompts/generate/unit-tests.js.map +0 -1
  147. package/dist/prompts/generate/wordpress-plugin.d.ts +0 -179
  148. package/dist/prompts/generate/wordpress-plugin.d.ts.map +0 -1
  149. package/dist/prompts/generate/wordpress-plugin.js +0 -767
  150. package/dist/prompts/generate/wordpress-plugin.js.map +0 -1
  151. package/dist/prompts/generate/wordpress-theme-from-static.d.ts +0 -177
  152. package/dist/prompts/generate/wordpress-theme-from-static.d.ts.map +0 -1
  153. package/dist/prompts/generate/wordpress-theme-from-static.js +0 -699
  154. package/dist/prompts/generate/wordpress-theme-from-static.js.map +0 -1
  155. package/dist/prompts/shared/cache-manager.d.ts +0 -45
  156. package/dist/prompts/shared/cache-manager.d.ts.map +0 -1
  157. package/dist/prompts/shared/cache-manager.js +0 -129
  158. package/dist/prompts/shared/cache-manager.js.map +0 -1
  159. package/dist/prompts/shared/helpers.d.ts +0 -39
  160. package/dist/prompts/shared/helpers.d.ts.map +0 -1
  161. package/dist/prompts/shared/helpers.js +0 -151
  162. package/dist/prompts/shared/helpers.js.map +0 -1
  163. package/dist/prompts/shared/templates.d.ts +0 -35
  164. package/dist/prompts/shared/templates.d.ts.map +0 -1
  165. package/dist/prompts/shared/templates.js +0 -77
  166. package/dist/prompts/shared/templates.js.map +0 -1
  167. package/dist/prompts/shared/types.d.ts +0 -112
  168. package/dist/prompts/shared/types.d.ts.map +0 -1
  169. package/dist/prompts/shared/types.js +0 -5
  170. package/dist/prompts/shared/types.js.map +0 -1
  171. package/dist/prompts/system/find-unused-files.d.ts +0 -106
  172. package/dist/prompts/system/find-unused-files.d.ts.map +0 -1
  173. package/dist/prompts/system/find-unused-files.js +0 -357
  174. package/dist/prompts/system/find-unused-files.js.map +0 -1
  175. package/dist/security/index.d.ts +0 -39
  176. package/dist/security/index.d.ts.map +0 -1
  177. package/dist/security/index.js +0 -46
  178. package/dist/security/index.js.map +0 -1
  179. package/dist/security/integration-helpers.d.ts +0 -121
  180. package/dist/security/integration-helpers.d.ts.map +0 -1
  181. package/dist/security/integration-helpers.js +0 -190
  182. package/dist/security/integration-helpers.js.map +0 -1
  183. package/dist/security/output-encoder.d.ts +0 -94
  184. package/dist/security/output-encoder.d.ts.map +0 -1
  185. package/dist/security/output-encoder.js +0 -295
  186. package/dist/security/output-encoder.js.map +0 -1
  187. package/dist/security/prompt-injection-guard.d.ts +0 -59
  188. package/dist/security/prompt-injection-guard.d.ts.map +0 -1
  189. package/dist/security/prompt-injection-guard.js +0 -249
  190. package/dist/security/prompt-injection-guard.js.map +0 -1
  191. package/dist/security/sanitisation.d.ts +0 -67
  192. package/dist/security/sanitisation.d.ts.map +0 -1
  193. package/dist/security/sanitisation.js +0 -398
  194. package/dist/security/sanitisation.js.map +0 -1
  195. package/dist/security/security-service.d.ts +0 -103
  196. package/dist/security/security-service.d.ts.map +0 -1
  197. package/dist/security/security-service.js +0 -303
  198. package/dist/security/security-service.js.map +0 -1
  199. package/dist/security-config.d.ts +0 -45
  200. package/dist/security-config.d.ts.map +0 -1
  201. package/dist/security-config.js +0 -63
  202. package/dist/security-config.js.map +0 -1
  203. package/dist/system/function-list.d.ts +0 -61
  204. package/dist/system/function-list.d.ts.map +0 -1
  205. package/dist/system/function-list.js +0 -111
  206. package/dist/system/function-list.js.map +0 -1
  207. package/dist/system/function-registry.d.ts +0 -23
  208. package/dist/system/function-registry.d.ts.map +0 -1
  209. package/dist/system/function-registry.js +0 -136
  210. package/dist/system/function-registry.js.map +0 -1
  211. package/dist/system/health-check.d.ts +0 -33
  212. package/dist/system/health-check.d.ts.map +0 -1
  213. package/dist/system/health-check.js +0 -98
  214. package/dist/system/health-check.js.map +0 -1
  215. package/dist/system/path-resolver.d.ts +0 -55
  216. package/dist/system/path-resolver.d.ts.map +0 -1
  217. package/dist/system/path-resolver.js +0 -90
  218. package/dist/system/path-resolver.js.map +0 -1
  219. package/dist/templates/plugin-template.d.ts +0 -121
  220. package/dist/templates/plugin-template.d.ts.map +0 -1
  221. package/dist/templates/plugin-template.js +0 -454
  222. package/dist/templates/plugin-template.js.map +0 -1
  223. package/dist/types/chunking-types.d.ts +0 -88
  224. package/dist/types/chunking-types.d.ts.map +0 -1
  225. package/dist/types/chunking-types.js +0 -18
  226. package/dist/types/chunking-types.js.map +0 -1
  227. package/dist/types/prompt-stages.d.ts +0 -30
  228. package/dist/types/prompt-stages.d.ts.map +0 -1
  229. package/dist/types/prompt-stages.js +0 -6
  230. package/dist/types/prompt-stages.js.map +0 -1
  231. package/dist/types.d.ts +0 -45
  232. package/dist/types.d.ts.map +0 -1
  233. package/dist/types.js +0 -6
  234. package/dist/types.js.map +0 -1
  235. package/dist/utils/css-parser.d.ts +0 -26
  236. package/dist/utils/css-parser.d.ts.map +0 -1
  237. package/dist/utils/css-parser.js +0 -117
  238. package/dist/utils/css-parser.js.map +0 -1
  239. package/dist/utils/path-resolver.d.ts +0 -13
  240. package/dist/utils/path-resolver.d.ts.map +0 -1
  241. package/dist/utils/path-resolver.js +0 -78
  242. package/dist/utils/path-resolver.js.map +0 -1
  243. package/dist/utils/plugin-utilities.d.ts +0 -176
  244. package/dist/utils/plugin-utilities.d.ts.map +0 -1
  245. package/dist/utils/plugin-utilities.js +0 -269
  246. package/dist/utils/plugin-utilities.js.map +0 -1
  247. package/dist/utils/streamHandler.d.ts +0 -3
  248. package/dist/utils/streamHandler.d.ts.map +0 -1
  249. package/dist/utils/streamHandler.js +0 -137
  250. package/dist/utils/streamHandler.js.map +0 -1
  251. package/dist/validation/output-validator.d.ts +0 -136
  252. package/dist/validation/output-validator.d.ts.map +0 -1
  253. package/dist/validation/output-validator.js +0 -262
  254. package/dist/validation/output-validator.js.map +0 -1
  255. package/dist/validation/response-factory.d.ts +0 -44
  256. package/dist/validation/response-factory.d.ts.map +0 -1
  257. package/dist/validation/response-factory.js +0 -202
  258. package/dist/validation/response-factory.js.map +0 -1
  259. package/dist/validation/schemas.d.ts +0 -519
  260. package/dist/validation/schemas.d.ts.map +0 -1
  261. package/dist/validation/schemas.js +0 -6
  262. package/dist/validation/schemas.js.map +0 -1
@@ -1,670 +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 ProjectDocumentationGenerator extends BasePlugin {
16
- constructor() {
17
- super();
18
- this.name = 'generate_project_documentation';
19
- this.category = 'generate';
20
- this.description = 'Generate comprehensive project documentation based on codebase analysis with intelligent file discovery and structured output';
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: 'Absolute path to project root directory',
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 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 analysis to perform',
69
- enum: ['api', 'architecture', 'comprehensive'],
70
- default: 'comprehensive',
71
- required: false
72
- },
73
- // Documentation-specific parameters
74
- docStyle: {
75
- type: 'string',
76
- description: 'Documentation style to use',
77
- enum: ['markdown', 'jsdoc', 'typedoc', 'sphinx'],
78
- default: 'markdown',
79
- required: false
80
- },
81
- includeExamples: {
82
- type: 'boolean',
83
- description: 'Include usage examples in documentation',
84
- default: true,
85
- required: false
86
- },
87
- focusAreas: {
88
- type: 'array',
89
- description: 'Areas to focus on: api, architecture, setup, contributing',
90
- default: ['api', 'architecture', 'setup'],
91
- required: false,
92
- items: { type: 'string' }
93
- }
94
- };
95
- this.analysisCache = getAnalysisCache();
96
- this.multiFileAnalysis = new MultiFileAnalysis();
97
- // Cache and analysis utilities are initialized above
98
- }
99
- async execute(params, llmClient) {
100
- return await withSecurity(this, params, llmClient, async (secureParams) => {
101
- try {
102
- // 1. Auto-detect analysis mode based on parameters
103
- const analysisMode = this.detectAnalysisMode(secureParams);
104
- // 2. Validate parameters based on detected mode
105
- this.validateParameters(secureParams, analysisMode);
106
- // 3. Setup model
107
- const { model, contextLength } = await ModelSetup.getReadyModel(llmClient);
108
- // 4. Route to appropriate analysis method
109
- if (analysisMode === 'single-file') {
110
- return await this.executeSingleFileAnalysis(secureParams, model, contextLength);
111
- }
112
- else {
113
- return await this.executeMultiFileAnalysis(secureParams, model, contextLength);
114
- }
115
- }
116
- catch (error) {
117
- return ErrorHandler.createExecutionError('generate_project_documentation', error);
118
- }
119
- });
120
- }
121
- /**
122
- * Auto-detect whether this is single-file or multi-file analysis
123
- */
124
- detectAnalysisMode(params) {
125
- // Single-file indicators take priority (avoids default parameter issues)
126
- if (params.code || params.filePath) {
127
- return 'single-file';
128
- }
129
- // Multi-file indicators
130
- if (params.projectPath || params.files) {
131
- return 'multi-file';
132
- }
133
- // Default to multi-file for project documentation
134
- return 'multi-file';
135
- }
136
- /**
137
- * Validate parameters based on detected analysis mode
138
- */
139
- validateParameters(params, mode) {
140
- if (mode === 'single-file') {
141
- ParameterValidator.validateCodeOrFile(params);
142
- }
143
- else {
144
- ParameterValidator.validateProjectPath(params);
145
- ParameterValidator.validateDepth(params);
146
- }
147
- // Universal validations
148
- ParameterValidator.validateEnum(params, 'analysisType', ['api', 'architecture', 'comprehensive']);
149
- ParameterValidator.validateEnum(params, 'analysisDepth', ['basic', 'detailed', 'comprehensive']);
150
- ParameterValidator.validateEnum(params, 'docStyle', ['markdown', 'jsdoc', 'typedoc', 'sphinx']);
151
- }
152
- /**
153
- * Execute single-file analysis
154
- */
155
- async executeSingleFileAnalysis(params, model, contextLength) {
156
- // Process single file input
157
- let codeToAnalyze = params.code;
158
- if (params.filePath) {
159
- codeToAnalyze = await readFileContent(params.filePath);
160
- }
161
- // Generate prompt stages for single file
162
- const promptStages = this.getSingleFilePromptStages({
163
- ...params,
164
- code: codeToAnalyze
165
- });
166
- // Execute with appropriate method
167
- const promptManager = new ThreeStagePromptManager();
168
- const needsChunking = TokenCalculator.needsChunking(promptStages, contextLength);
169
- if (needsChunking) {
170
- const chunkSize = TokenCalculator.calculateOptimalChunkSize(promptStages, contextLength);
171
- const dataChunks = promptManager.chunkDataPayload(promptStages.dataPayload, chunkSize);
172
- const conversation = promptManager.createChunkedConversation(promptStages, dataChunks);
173
- const messages = [
174
- conversation.systemMessage,
175
- ...conversation.dataMessages,
176
- conversation.analysisMessage
177
- ];
178
- return await ResponseProcessor.executeChunked(messages, model, contextLength, 'generate_project_documentation', 'single');
179
- }
180
- else {
181
- return await ResponseProcessor.executeDirect(promptStages, model, contextLength, 'generate_project_documentation');
182
- }
183
- }
184
- /**
185
- * Execute multi-file analysis
186
- */
187
- async executeMultiFileAnalysis(params, model, contextLength) {
188
- // Discover files
189
- let filesToAnalyze = params.files ||
190
- await this.discoverRelevantFiles(params.projectPath, params.maxDepth, params.analysisType);
191
- // Perform multi-file analysis with caching
192
- const analysisResult = await this.performMultiFileAnalysis(filesToAnalyze, params, model, contextLength);
193
- // Generate prompt stages for multi-file
194
- const promptStages = this.getMultiFilePromptStages({
195
- ...params,
196
- analysisResult,
197
- fileCount: filesToAnalyze.length
198
- });
199
- // Always use chunking for multi-file
200
- const promptManager = new ThreeStagePromptManager();
201
- const chunkSize = TokenCalculator.calculateOptimalChunkSize(promptStages, contextLength);
202
- const dataChunks = promptManager.chunkDataPayload(promptStages.dataPayload, chunkSize);
203
- const conversation = promptManager.createChunkedConversation(promptStages, dataChunks);
204
- const messages = [
205
- conversation.systemMessage,
206
- ...conversation.dataMessages,
207
- conversation.analysisMessage
208
- ];
209
- return await ResponseProcessor.executeChunked(messages, model, contextLength, 'generate_project_documentation', 'multifile');
210
- }
211
- /**
212
- * Implement single-file documentation generation
213
- */
214
- getSingleFilePromptStages(params) {
215
- const { code, language, analysisDepth, analysisType, docStyle, includeExamples, focusAreas } = params;
216
- const systemAndContext = `You are an expert technical writer and documentation specialist with 15+ years of experience creating developer-focused documentation.
217
-
218
- **YOUR EXPERTISE:**
219
- - Technical writing for software projects
220
- - API documentation and developer experience
221
- - Code analysis and architectural documentation
222
- - Best practices for ${docStyle} documentation
223
- - Creating clear, actionable content for developers
224
-
225
- Analysis Context:
226
- - Language: ${language}
227
- - Analysis Depth: ${analysisDepth}
228
- - Analysis Type: ${analysisType}
229
- - Documentation Style: ${docStyle}
230
- - Include Examples: ${includeExamples}
231
- - Focus Areas: ${focusAreas.join(', ')}
232
- - Mode: Single File Documentation
233
-
234
- **DOCUMENTATION PHILOSOPHY:**
235
- Your documentation should be a developer's best friend - clear, practical, and immediately useful. Think of it as mentoring a fellow developer who needs to understand and use this code effectively.
236
-
237
- **KEY PRINCIPLES:**
238
- 1. Lead with practical value - what can the developer accomplish?
239
- 2. Explain the "why" behind architectural decisions
240
- 3. Provide runnable examples that actually work
241
- 4. Anticipate common questions and address them proactively
242
- 5. Make it scannable with clear hierarchies and formatting`;
243
- const dataPayload = `File to document:
244
-
245
- **File Analysis:**
246
- - Language: ${language}
247
- - Content Length: ${code.length} characters
248
- - Lines: ${code.split('\n').length}
249
-
250
- **Code Content:**
251
- \`\`\`${language}
252
- ${code}
253
- \`\`\``;
254
- const outputInstructions = `Generate comprehensive ${docStyle} documentation for this file that serves as a complete reference for developers.
255
-
256
- **REQUIRED DOCUMENTATION STRUCTURE:**
257
-
258
- ## File Overview
259
- - **Purpose**: Clear, one-sentence description of what this file does
260
- - **Key Features**: 3-5 bullet points of main capabilities
261
- - **Dependencies**: What this file requires to function
262
- - **Integration Points**: How this file connects to the broader system
263
-
264
- ## API Reference
265
- ${includeExamples ?
266
- `- **Functions/Classes**: Complete signature with parameter types and descriptions
267
- - **Usage Examples**: Practical, copy-pasteable code examples for each main function
268
- - **Return Values**: What developers can expect back, including error conditions
269
- - **Best Practices**: How to use the API effectively and avoid common pitfalls` :
270
- `- **Functions/Classes**: Method signatures with clear parameter descriptions
271
- - **Core Concepts**: Key ideas developers need to understand
272
- - **Integration Guidelines**: How to work with this file's functionality`}
273
-
274
- ## Implementation Details
275
- - **Architecture Notes**: Design decisions and their rationale
276
- - **Performance Considerations**: Important performance implications
277
- - **Error Handling**: How errors are managed and what to expect
278
- - **Configuration**: Any configuration options or environment dependencies
279
-
280
- ## Developer Guide
281
- ${focusAreas.includes('setup') ? `- **Setup Requirements**: What developers need to get started
282
- - **Environment Setup**: Step-by-step configuration instructions` : ''}
283
- ${focusAreas.includes('contributing') ? `- **Contributing**: How to modify or extend this file
284
- - **Testing**: How to test changes to this file` : ''}
285
- - **Troubleshooting**: Common issues and their solutions
286
- - **Related Files**: Other files developers should be aware of
287
-
288
- **OUTPUT REQUIREMENTS:**
289
- - Use proper ${docStyle} formatting with clear headers and code blocks
290
- - Include syntax highlighting for code examples
291
- - Create scannable content with bullet points and clear hierarchies
292
- - Make examples practical and immediately useful
293
- - Ensure content flows logically from overview to implementation details
294
- - Write in an encouraging, helpful tone that empowers developers`;
295
- return { systemAndContext, dataPayload, outputInstructions };
296
- }
297
- /**
298
- * Implement multi-file project documentation generation
299
- */
300
- getMultiFilePromptStages(params) {
301
- const { analysisResult, analysisType, analysisDepth, fileCount, docStyle, includeExamples, focusAreas } = params;
302
- const systemAndContext = `You are a senior technical writer and project documentation specialist with expertise in creating comprehensive project documentation that developers love to use.
303
-
304
- **YOUR EXPERTISE:**
305
- - 15+ years creating project documentation for open source and enterprise software
306
- - Expert in ${docStyle} documentation standards and best practices
307
- - Specializes in developer onboarding and API documentation
308
- - Deep understanding of software architecture and project organization
309
- - Proven track record of creating documentation that reduces support tickets by 80%
310
-
311
- Analysis Context:
312
- - Analysis Type: ${analysisType}
313
- - Analysis Depth: ${analysisDepth}
314
- - Files Analyzed: ${fileCount}
315
- - Documentation Style: ${docStyle}
316
- - Include Examples: ${includeExamples}
317
- - Focus Areas: ${focusAreas.join(', ')}
318
- - Mode: Complete Project Documentation
319
-
320
- **DOCUMENTATION MISSION:**
321
- Create documentation so clear and helpful that:
322
- 1. New developers can contribute within their first week
323
- 2. Existing developers can quickly find what they need
324
- 3. The project becomes more maintainable and accessible
325
- 4. Support questions decrease significantly
326
- 5. The project attracts more contributors and users
327
-
328
- **CORE PRINCIPLES:**
329
- - Start with what developers can accomplish (outcomes over features)
330
- - Provide a clear learning path from beginner to advanced
331
- - Include real, working examples that solve actual problems
332
- - Anticipate and answer the questions developers will have
333
- - Make the documentation as engaging and clear as the best technical books`;
334
- const dataPayload = `Comprehensive project analysis results:
335
-
336
- **Project Overview:**
337
- - Total Files Analyzed: ${fileCount}
338
- - Analysis Depth: ${analysisDepth}
339
- - Focus Areas: ${focusAreas.join(', ')}
340
-
341
- **Detailed Analysis:**
342
- ${JSON.stringify(analysisResult, null, 2)}`;
343
- const outputInstructions = `Create comprehensive ${docStyle} project documentation that serves as the definitive guide for this project.
344
-
345
- **REQUIRED DOCUMENTATION SECTIONS:**
346
-
347
- ## 🚀 Project Overview
348
- - **What This Project Does**: Clear, compelling description in plain English
349
- - **Why It Matters**: The problem this project solves and why developers should care
350
- - **Key Features**: 5-7 standout capabilities that make this project valuable
351
- - **Who Should Use This**: Target audience and use cases
352
- - **Technology Stack**: Core technologies and architectural approach
353
-
354
- ## ⚡ Quick Start Guide
355
- ${focusAreas.includes('setup') ?
356
- `- **Prerequisites**: Exact system requirements and dependencies
357
- - **Installation**: Step-by-step installation process with verification steps
358
- - **First Success**: Get developers to a working example in under 10 minutes
359
- - **Next Steps**: Clear pathway to more advanced usage` :
360
- `- **Getting Started**: Essential steps to begin using the project
361
- - **Core Concepts**: Key ideas developers need to understand upfront`}
362
-
363
- ## 📁 Project Architecture
364
- ${focusAreas.includes('architecture') ?
365
- `- **Directory Structure**: What each folder contains and why
366
- - **Key Components**: Core modules and their responsibilities
367
- - **Data Flow**: How information moves through the system
368
- - **Design Decisions**: Architectural choices and their rationale
369
- - **Extension Points**: Where and how the project can be customized` :
370
- `- **Project Organization**: How the codebase is structured
371
- - **Core Components**: Main modules and their purposes`}
372
-
373
- ## 🔧 API Documentation
374
- ${focusAreas.includes('api') ?
375
- `- **Core APIs**: Complete reference for main functions and classes
376
- - **Authentication**: Security and access patterns
377
- - **Request/Response Formats**: Data structures and examples
378
- - **Error Handling**: Common error scenarios and resolutions
379
- - **Rate Limits & Performance**: Important usage considerations` :
380
- `- **Main Functions**: Key APIs and their usage
381
- - **Integration Patterns**: How to work with the project's functionality`}
382
-
383
- ## 💡 Usage Examples
384
- ${includeExamples ?
385
- `- **Common Use Cases**: 5-10 practical scenarios with complete code examples
386
- - **Integration Examples**: How to use this project with other popular tools
387
- - **Advanced Patterns**: Sophisticated usage for experienced developers
388
- - **Best Practices**: Recommended approaches and patterns to avoid
389
- - **Sample Projects**: Links to complete example implementations` :
390
- `- **Basic Usage**: Essential usage patterns
391
- - **Integration Guidelines**: How to incorporate into existing projects
392
- - **Common Patterns**: Frequently used approaches`}
393
-
394
- ## 🛠️ Development Guide
395
- ${focusAreas.includes('contributing') ?
396
- `- **Development Setup**: Complete environment setup for contributors
397
- - **Code Style**: Coding standards and conventions
398
- - **Testing Strategy**: How to run and write tests
399
- - **Contribution Workflow**: Pull request process and guidelines
400
- - **Release Process**: How updates are published and versioned` :
401
- `- **Local Development**: Setting up for project modification
402
- - **Testing**: How to verify changes work correctly`}
403
-
404
- ## 🔍 Troubleshooting
405
- - **Common Issues**: The 10 most frequent problems and their solutions
406
- - **Debug Mode**: How to get more information when things go wrong
407
- - **Performance Issues**: Common performance problems and fixes
408
- - **Environment Problems**: OS-specific issues and resolutions
409
- - **Getting Help**: Where to find support and ask questions
410
-
411
- ## 🌟 Advanced Topics
412
- - **Performance Optimization**: How to get the best performance
413
- - **Security Considerations**: Important security practices
414
- - **Monitoring & Observability**: How to monitor the project in production
415
- - **Scaling Patterns**: Approaches for high-load scenarios
416
- - **Integration Ecosystem**: Compatible tools and frameworks
417
-
418
- ## 📚 Resources
419
- - **Related Projects**: Complementary tools and libraries
420
- - **Learning Resources**: Tutorials, videos, and educational content
421
- - **Community**: Where to connect with other users and contributors
422
- - **Changelog**: Recent updates and version history
423
- - **Roadmap**: Planned features and project direction
424
-
425
- **OUTPUT REQUIREMENTS:**
426
- - Use engaging ${docStyle} formatting with emojis in headers for visual appeal
427
- - Include practical, runnable code examples with clear explanations
428
- - Create a logical flow from basic concepts to advanced usage
429
- - Write in an encouraging, developer-friendly tone
430
- - Make content highly scannable with clear hierarchies and formatting
431
- - Include calls-to-action that encourage developers to try the project
432
- - Ensure examples are realistic and solve real problems developers face
433
- - Add tips, warnings, and pro-tips using appropriate markdown formatting`;
434
- return { systemAndContext, dataPayload, outputInstructions };
435
- }
436
- /**
437
- * Implement for backwards compatibility
438
- * The system still expects this method, so we intelligently route to the appropriate stages
439
- */
440
- getPromptStages(params) {
441
- const mode = this.detectAnalysisMode(params);
442
- if (mode === 'single-file') {
443
- return this.getSingleFilePromptStages(params);
444
- }
445
- else {
446
- return this.getMultiFilePromptStages(params);
447
- }
448
- }
449
- // Multi-file helper methods
450
- async discoverRelevantFiles(projectPath, maxDepth, analysisType) {
451
- const extensions = this.getFileExtensions(analysisType);
452
- // If analyzing /src, also include key files from parent directory
453
- const path = await import('path');
454
- const parentDir = path.dirname(projectPath);
455
- const isSourceDir = projectPath.endsWith('src') || projectPath.endsWith('src/');
456
- let sourceFiles = await this.multiFileAnalysis.discoverFiles(projectPath, extensions, maxDepth);
457
- if (isSourceDir) {
458
- // Add key project files from parent directory
459
- const keyProjectFiles = await this.findKeyProjectFiles(parentDir);
460
- sourceFiles = [...keyProjectFiles, ...sourceFiles];
461
- }
462
- return sourceFiles;
463
- }
464
- async findKeyProjectFiles(projectRoot) {
465
- const fs = await import('fs/promises');
466
- const path = await import('path');
467
- const keyFiles = [];
468
- const keyFileNames = [
469
- 'package.json', 'composer.json', 'requirements.txt', 'Cargo.toml',
470
- 'README.md', 'README.rst', 'README.txt', 'CHANGELOG.md',
471
- 'tsconfig.json', '.env.example', '.gitignore'
472
- ];
473
- for (const fileName of keyFileNames) {
474
- const filePath = path.join(projectRoot, fileName);
475
- try {
476
- await fs.access(filePath);
477
- keyFiles.push(filePath);
478
- }
479
- catch {
480
- // File doesn't exist, skip it
481
- }
482
- }
483
- return keyFiles;
484
- }
485
- async performMultiFileAnalysis(files, params, model, contextLength) {
486
- const cacheKey = this.analysisCache.generateKey('generate_project_documentation', params, files);
487
- const cached = await this.analysisCache.get(cacheKey);
488
- if (cached)
489
- return cached;
490
- const fileAnalysisResults = await this.multiFileAnalysis.analyzeBatch(files, (file) => this.analyzeIndividualFile(file, params, model), contextLength);
491
- // Aggregate results into proper analysis result format
492
- const aggregatedResult = {
493
- summary: `Project documentation analysis of ${files.length} files`,
494
- findings: fileAnalysisResults,
495
- data: {
496
- fileCount: files.length,
497
- totalSize: fileAnalysisResults.reduce((sum, result) => sum + (result.size || 0), 0),
498
- projectStructure: await this.buildProjectStructure(files, fileAnalysisResults),
499
- keyFiles: this.identifyKeyFiles(fileAnalysisResults),
500
- projectMetadata: this.extractProjectMetadata(files, fileAnalysisResults)
501
- }
502
- };
503
- await this.analysisCache.cacheAnalysis(cacheKey, aggregatedResult, {
504
- modelUsed: model.identifier || 'unknown',
505
- executionTime: Date.now() - Date.now(), // TODO: Track actual execution time
506
- timestamp: new Date().toISOString()
507
- });
508
- return aggregatedResult;
509
- }
510
- async analyzeIndividualFile(file, params, model) {
511
- const content = await import('fs/promises').then(fs => fs.readFile(file, 'utf-8'));
512
- const path = await import('path');
513
- const isKeyFile = this.isKeyFile(path.basename(file));
514
- return {
515
- filePath: file,
516
- fileName: path.basename(file),
517
- extension: path.extname(file),
518
- size: content.length,
519
- lines: content.split('\n').length,
520
- language: this.getLanguageFromExtension(path.extname(file)),
521
- isKeyFile,
522
- // Only include content for key files, and limit it
523
- content: isKeyFile && content.length < 2000 ? content :
524
- isKeyFile ? content.substring(0, 2000) + '...[truncated]' :
525
- '[Content excluded - non-key file]'
526
- };
527
- }
528
- getFileExtensions(analysisType) {
529
- const extensionMap = {
530
- 'api': ['.js', '.ts', '.jsx', '.tsx', '.php', '.py', '.java', '.json'], // Focus on API-relevant files
531
- 'architecture': ['.js', '.ts', '.jsx', '.tsx', '.php', '.py', '.java', '.md', '.json', '.yml', '.yaml'], // Include config and docs
532
- 'comprehensive': ['.js', '.ts', '.jsx', '.tsx', '.php', '.py', '.java', '.cs', '.cpp', '.h', '.css', '.html', '.md', '.json', '.xml', '.yml', '.yaml', '.sql'] // All relevant files
533
- };
534
- return extensionMap[analysisType] || extensionMap.comprehensive;
535
- }
536
- getLanguageFromExtension(ext) {
537
- const languageMap = {
538
- '.js': 'javascript',
539
- '.ts': 'typescript',
540
- '.jsx': 'react',
541
- '.tsx': 'react-typescript',
542
- '.php': 'php',
543
- '.py': 'python',
544
- '.java': 'java',
545
- '.cs': 'csharp',
546
- '.cpp': 'cpp',
547
- '.h': 'c',
548
- '.css': 'css',
549
- '.html': 'html',
550
- '.md': 'markdown',
551
- '.json': 'json',
552
- '.yml': 'yaml',
553
- '.yaml': 'yaml',
554
- '.sql': 'sql'
555
- };
556
- return languageMap[ext.toLowerCase()] || 'other';
557
- }
558
- isKeyFile(fileName) {
559
- const keyFilePatterns = [
560
- 'package.json', 'composer.json', 'requirements.txt', 'Cargo.toml',
561
- 'README.md', 'README.rst', 'README.txt', 'CHANGELOG.md',
562
- 'index.js', 'index.ts', 'main.js', 'main.ts', 'app.js', 'app.ts',
563
- 'config.js', 'config.ts', 'tsconfig.json', '.env.example'
564
- ];
565
- // Exact matches for critical files
566
- if (keyFilePatterns.includes(fileName.toLowerCase())) {
567
- return true;
568
- }
569
- // Pattern matches for important files
570
- const importantPatterns = [
571
- /^index\.(js|ts)$/i,
572
- /^main\.(js|ts)$/i,
573
- /^app\.(js|ts)$/i,
574
- /readme/i,
575
- /config/i
576
- ];
577
- return importantPatterns.some(pattern => pattern.test(fileName));
578
- }
579
- async buildProjectStructure(files, analysisResults) {
580
- const path = await import('path');
581
- const structure = {};
582
- files.forEach((file, index) => {
583
- const parts = file.split(path.sep);
584
- let current = structure;
585
- parts.forEach((part, partIndex) => {
586
- if (!current[part]) {
587
- current[part] = partIndex === parts.length - 1 ? analysisResults[index] : {};
588
- }
589
- if (partIndex < parts.length - 1) {
590
- current = current[part];
591
- }
592
- });
593
- });
594
- return structure;
595
- }
596
- identifyKeyFiles(analysisResults) {
597
- return analysisResults
598
- .filter(result => result.isKeyFile)
599
- .sort((a, b) => b.size - a.size)
600
- .slice(0, 10); // Top 10 key files
601
- }
602
- extractProjectMetadata(files, analysisResults) {
603
- const packageJsonFile = analysisResults.find(result => result.fileName === 'package.json');
604
- if (packageJsonFile) {
605
- try {
606
- const packageJson = JSON.parse(packageJsonFile.content);
607
- return {
608
- name: packageJson.name || 'Unknown Project',
609
- version: packageJson.version || '1.0.0',
610
- description: packageJson.description || '',
611
- type: this.detectProjectType(packageJson, analysisResults),
612
- dependencies: Object.keys(packageJson.dependencies || {}),
613
- scripts: Object.keys(packageJson.scripts || {}),
614
- author: packageJson.author || '',
615
- license: packageJson.license || ''
616
- };
617
- }
618
- catch (error) {
619
- // Fallback if package.json can't be parsed
620
- }
621
- }
622
- // Default metadata
623
- return {
624
- name: 'Project Documentation',
625
- version: '1.0.0',
626
- description: 'Comprehensive project documentation',
627
- type: this.detectProjectTypeFromFiles(analysisResults),
628
- dependencies: [],
629
- scripts: [],
630
- author: '',
631
- license: ''
632
- };
633
- }
634
- detectProjectType(packageJson, analysisResults) {
635
- if (packageJson.dependencies?.react)
636
- return 'react-application';
637
- if (packageJson.dependencies?.vue)
638
- return 'vue-application';
639
- if (packageJson.dependencies?.express)
640
- return 'node-api';
641
- if (packageJson.dependencies?.next)
642
- return 'nextjs-application';
643
- if (analysisResults.some(f => f.fileName.includes('plugin.php')))
644
- return 'wordpress-plugin';
645
- if (analysisResults.some(f => f.fileName === 'style.css' && f.content.includes('Theme')))
646
- return 'wordpress-theme';
647
- return 'node-project';
648
- }
649
- detectProjectTypeFromFiles(analysisResults) {
650
- const fileNames = analysisResults.map(r => r.fileName);
651
- if (fileNames.includes('package.json'))
652
- return 'node-project';
653
- if (fileNames.includes('composer.json'))
654
- return 'php-project';
655
- if (fileNames.includes('requirements.txt'))
656
- return 'python-project';
657
- if (fileNames.includes('Cargo.toml'))
658
- return 'rust-project';
659
- if (fileNames.some(f => f.endsWith('.csproj')))
660
- return 'dotnet-project';
661
- return 'generic-project';
662
- }
663
- generateCacheKey(files, params) {
664
- const fileHash = files.join('|');
665
- const paramHash = JSON.stringify(params);
666
- return `${fileHash}_${paramHash}`.substring(0, 64);
667
- }
668
- }
669
- export default ProjectDocumentationGenerator;
670
- //# sourceMappingURL=project-documentation.js.map