@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,695 @@
1
+ /**
2
+ * WordPress Theme from Static Site Generator - Modern v4.3 Universal Template
3
+ *
4
+ * Converts static HTML/CSS/JS sites into fully functional WordPress themes
5
+ * Supports both URL analysis and local file directory conversion
6
+ * Intelligently handles multiple pages to understand site structure and styling
7
+ */
8
+ import { BasePlugin } from '../../plugins/base-plugin.js';
9
+ import { ThreeStagePromptManager } from '../../core/ThreeStagePromptManager.js';
10
+ import { withSecurity } from '../../security/integration-helpers.js';
11
+ import { readFileContent } from '../shared/helpers.js';
12
+ import { ModelSetup, ResponseProcessor, ParameterValidator, ErrorHandler, MultiFileAnalysis } from '../../utils/plugin-utilities.js';
13
+ import { getAnalysisCache } from '../../cache/index.js';
14
+ // Common Node.js modules - Use these instead of require()
15
+ import { basename, extname, relative } from 'path';
16
+ export class WordPressThemeFromStaticGenerator extends BasePlugin {
17
+ constructor() {
18
+ super();
19
+ this.name = 'wordpress_theme_from_static';
20
+ this.category = 'generate';
21
+ this.description = 'Convert static HTML/CSS/JS sites into fully functional WordPress themes with smart template detection';
22
+ // Universal parameter set - supports both single and multi-file scenarios
23
+ this.parameters = {
24
+ // Static site source parameters
25
+ urls: {
26
+ type: 'array',
27
+ description: 'Array of URLs to analyze for theme conversion (e.g., home, blog, about pages)',
28
+ required: false,
29
+ items: { type: 'string' }
30
+ },
31
+ url: {
32
+ type: 'string',
33
+ description: 'Single URL to analyze for theme conversion',
34
+ required: false
35
+ },
36
+ // WordPress theme parameters
37
+ themeName: {
38
+ type: 'string',
39
+ description: 'WordPress theme name',
40
+ required: false,
41
+ default: 'Custom Static Theme'
42
+ },
43
+ themeDescription: {
44
+ type: 'string',
45
+ description: 'Theme description',
46
+ required: false,
47
+ default: 'WordPress theme generated from static site'
48
+ },
49
+ themeAuthor: {
50
+ type: 'string',
51
+ description: 'Theme author name',
52
+ required: false,
53
+ default: 'Theme Generator'
54
+ },
55
+ themeVersion: {
56
+ type: 'string',
57
+ description: 'Theme version',
58
+ required: false,
59
+ default: '1.0.0'
60
+ },
61
+ // Template compatibility parameters
62
+ code: {
63
+ type: 'string',
64
+ description: 'HTML content to convert (for single-file analysis)',
65
+ required: false
66
+ },
67
+ filePath: {
68
+ type: 'string',
69
+ description: 'Path to HTML file to convert',
70
+ required: false
71
+ },
72
+ projectPath: {
73
+ type: 'string',
74
+ description: 'Path to static site directory (for multi-file analysis)',
75
+ required: false
76
+ },
77
+ files: {
78
+ type: 'array',
79
+ description: 'Array of specific static site files to analyze',
80
+ required: false,
81
+ items: { type: 'string' }
82
+ },
83
+ maxDepth: {
84
+ type: 'number',
85
+ description: 'Maximum directory depth for static site discovery (1-5)',
86
+ required: false,
87
+ default: 3
88
+ },
89
+ // Theme generation options
90
+ includeGutenberg: {
91
+ type: 'boolean',
92
+ description: 'Include Gutenberg block support',
93
+ required: false,
94
+ default: true
95
+ },
96
+ includeWooCommerce: {
97
+ type: 'boolean',
98
+ description: 'Include WooCommerce template support',
99
+ required: false,
100
+ default: false
101
+ },
102
+ includeCustomizer: {
103
+ type: 'boolean',
104
+ description: 'Include WordPress Customizer options',
105
+ required: false,
106
+ default: true
107
+ },
108
+ includeMenus: {
109
+ type: 'boolean',
110
+ description: 'Include dynamic WordPress menus',
111
+ required: false,
112
+ default: true
113
+ },
114
+ includeSidebars: {
115
+ type: 'boolean',
116
+ description: 'Include WordPress sidebar/widget areas',
117
+ required: false,
118
+ default: true
119
+ },
120
+ // Universal parameters
121
+ language: {
122
+ type: 'string',
123
+ description: 'Primary language (HTML/PHP for WordPress themes)',
124
+ required: false,
125
+ default: 'html'
126
+ },
127
+ analysisDepth: {
128
+ type: 'string',
129
+ description: 'Level of analysis detail for theme conversion',
130
+ enum: ['basic', 'detailed', 'comprehensive'],
131
+ default: 'comprehensive',
132
+ required: false
133
+ },
134
+ analysisType: {
135
+ type: 'string',
136
+ description: 'Type of theme conversion to perform',
137
+ enum: ['simple', 'responsive', 'comprehensive'],
138
+ default: 'comprehensive',
139
+ required: false
140
+ }
141
+ };
142
+ this.analysisCache = getAnalysisCache();
143
+ this.multiFileAnalysis = new MultiFileAnalysis();
144
+ // Cache and analysis utilities are initialized above
145
+ }
146
+ async execute(params, llmClient) {
147
+ return await withSecurity(this, params, llmClient, async (secureParams) => {
148
+ try {
149
+ // 1. Auto-detect analysis mode based on parameters
150
+ const analysisMode = this.detectAnalysisMode(secureParams);
151
+ // 2. Validate parameters based on detected mode
152
+ this.validateParameters(secureParams, analysisMode);
153
+ // 3. Setup model
154
+ const { model, contextLength } = await ModelSetup.getReadyModel(llmClient);
155
+ // 4. Route to appropriate analysis method
156
+ if (analysisMode === 'single-file') {
157
+ return await this.executeSingleFileAnalysis(secureParams, model, contextLength);
158
+ }
159
+ else {
160
+ return await this.executeMultiFileAnalysis(secureParams, model, contextLength);
161
+ }
162
+ }
163
+ catch (error) {
164
+ return ErrorHandler.createExecutionError('wordpress_theme_from_static', error);
165
+ }
166
+ });
167
+ }
168
+ /**
169
+ * Auto-detect whether this is single-page or multi-page/directory conversion
170
+ */
171
+ detectAnalysisMode(params) {
172
+ // Single-file indicators: single URL, HTML content, or single file path
173
+ if (params.url || params.code || params.filePath) {
174
+ return 'single-file';
175
+ }
176
+ // Multi-file indicators: multiple URLs, directory paths, or file arrays
177
+ if (params.urls && params.urls.length > 1) {
178
+ return 'multi-file';
179
+ }
180
+ if (params.projectPath || params.files) {
181
+ return 'multi-file';
182
+ }
183
+ // Default to single-file for simple conversions
184
+ return 'single-file';
185
+ }
186
+ /**
187
+ * Validate parameters based on detected analysis mode
188
+ */
189
+ validateParameters(params, mode) {
190
+ if (mode === 'single-file') {
191
+ // Validate single source input
192
+ if (!params.url && !params.code && !params.filePath && (!params.urls || params.urls.length === 0)) {
193
+ throw new Error('For theme conversion: url, urls, code, or filePath is required');
194
+ }
195
+ }
196
+ else {
197
+ // Validate multi-source input
198
+ if (params.projectPath) {
199
+ ParameterValidator.validateProjectPath(params);
200
+ ParameterValidator.validateDepth(params);
201
+ }
202
+ else if (!params.urls || params.urls.length === 0) {
203
+ throw new Error('For multi-file conversion: urls array or projectPath is required');
204
+ }
205
+ }
206
+ // Universal validations
207
+ ParameterValidator.validateEnum(params, 'analysisType', ['simple', 'responsive', 'comprehensive']);
208
+ ParameterValidator.validateEnum(params, 'analysisDepth', ['basic', 'detailed', 'comprehensive']);
209
+ }
210
+ /**
211
+ * Execute single-file analysis (single page/URL conversion)
212
+ */
213
+ async executeSingleFileAnalysis(params, model, contextLength) {
214
+ // Process single source input
215
+ let contentToAnalyze = params.code;
216
+ let sourceUrl = params.url;
217
+ if (params.filePath) {
218
+ contentToAnalyze = await readFileContent(params.filePath);
219
+ }
220
+ else if (params.urls && params.urls.length === 1) {
221
+ sourceUrl = params.urls[0];
222
+ }
223
+ // Generate prompt stages for single source conversion
224
+ const promptStages = this.getSingleFilePromptStages({
225
+ ...params,
226
+ content: contentToAnalyze,
227
+ sourceUrl
228
+ });
229
+ // Execute with appropriate method
230
+ const promptManager = new ThreeStagePromptManager(contextLength);
231
+ const needsChunking = promptManager.needsChunking(promptStages);
232
+ if (needsChunking) {
233
+ const conversation = promptManager.createChunkedConversation(promptStages);
234
+ const messages = [
235
+ conversation.systemMessage,
236
+ ...conversation.dataMessages,
237
+ conversation.analysisMessage
238
+ ];
239
+ return await ResponseProcessor.executeChunked(messages, model, contextLength, 'wordpress_theme_from_static', 'single');
240
+ }
241
+ else {
242
+ return await ResponseProcessor.executeDirect(promptStages, model, contextLength, 'wordpress_theme_from_static');
243
+ }
244
+ }
245
+ /**
246
+ * Execute multi-file analysis (multiple pages/URLs or directory conversion)
247
+ */
248
+ async executeMultiFileAnalysis(params, model, contextLength) {
249
+ let analysisResult;
250
+ if (params.projectPath) {
251
+ // Directory-based conversion
252
+ const filesToAnalyze = await this.discoverRelevantFiles(params.projectPath, params.maxDepth, params.analysisType);
253
+ analysisResult = await this.performMultiFileAnalysis(filesToAnalyze, params, model, contextLength);
254
+ }
255
+ else if (params.urls) {
256
+ // URL-based conversion
257
+ analysisResult = await this.performMultiUrlAnalysis(params.urls, params, model, contextLength);
258
+ }
259
+ // Generate prompt stages for multi-source conversion
260
+ const promptStages = this.getMultiFilePromptStages({
261
+ ...params,
262
+ analysisResult,
263
+ sourceCount: params.urls?.length || analysisResult?.findings?.length || 0
264
+ });
265
+ // Always use chunking for multi-file
266
+ const promptManager = new ThreeStagePromptManager(contextLength);
267
+ const conversation = promptManager.createChunkedConversation(promptStages);
268
+ const messages = [
269
+ conversation.systemMessage,
270
+ ...conversation.dataMessages,
271
+ conversation.analysisMessage
272
+ ];
273
+ return await ResponseProcessor.executeChunked(messages, model, contextLength, 'wordpress_theme_from_static', 'multifile');
274
+ }
275
+ /**
276
+ * Single-file prompt stages - Single page/URL to WordPress theme conversion
277
+ */
278
+ getSingleFilePromptStages(params) {
279
+ const { content, sourceUrl, analysisDepth, analysisType, themeName, themeDescription } = params;
280
+ const systemAndContext = `You are an expert WordPress theme developer specializing in converting static sites to ${analysisDepth} ${analysisType} WordPress themes.
281
+
282
+ WordPress Theme Development Expertise:
283
+ - Static to Dynamic Conversion: Transform HTML/CSS/JS into PHP template hierarchy
284
+ - WordPress Standards: Follow WordPress Theme Review Guidelines and coding standards
285
+ - Template Hierarchy: Master WordPress template hierarchy (index, home, single, page, archive, etc.)
286
+ - Dynamic Content Integration: Replace static content with WordPress functions and loops
287
+ - Responsive Design: Maintain original responsiveness while adding WordPress functionality
288
+ - Performance Optimization: Enqueue scripts/styles properly, optimize images, minimize HTTP requests
289
+ - Accessibility: Maintain WCAG compliance throughout conversion process
290
+ - Cross-browser Compatibility: Ensure theme works across all major browsers
291
+ - SEO Best Practices: Implement proper meta tags, structured data, and SEO-friendly markup
292
+
293
+ Conversion Context:
294
+ - Analysis Depth: ${analysisDepth}
295
+ - Theme Complexity: ${analysisType}
296
+ - Source Type: ${sourceUrl ? 'URL-based conversion' : 'File-based conversion'}
297
+ - WordPress Features: Gutenberg ${params.includeGutenberg ? 'enabled' : 'disabled'}, WooCommerce ${params.includeWooCommerce ? 'enabled' : 'disabled'}
298
+
299
+ Your task is to create a complete, professional WordPress theme that preserves the original design while adding full WordPress functionality.`;
300
+ const dataPayload = `Static Site Conversion Requirements:
301
+
302
+ **Theme Details:**
303
+ - Theme Name: ${themeName || 'Custom Static Theme'}
304
+ - Description: ${themeDescription || 'WordPress theme generated from static site'}
305
+ - Author: ${params.themeAuthor || 'Theme Generator'}
306
+ - Version: ${params.themeVersion || '1.0.0'}
307
+ ${sourceUrl ? `- Source URL: ${sourceUrl}` : ''}
308
+
309
+ **WordPress Features to Include:**
310
+ - Gutenberg Block Editor Support: ${params.includeGutenberg !== false}
311
+ - WooCommerce Template Support: ${params.includeWooCommerce || false}
312
+ - WordPress Customizer Integration: ${params.includeCustomizer !== false}
313
+ - Dynamic Navigation Menus: ${params.includeMenus !== false}
314
+ - Sidebar/Widget Areas: ${params.includeSidebars !== false}
315
+
316
+ **Static Site Content to Convert:**
317
+ ${content ? `
318
+ HTML Content:
319
+ \`\`\`html
320
+ ${content}
321
+ \`\`\`
322
+ ` : `
323
+ Source URL: ${sourceUrl}
324
+ Note: Analyze the provided URL to understand the site structure, design patterns, and styling approach.
325
+ `}
326
+
327
+ **Conversion Requirements:**
328
+ - Preserve exact visual design and layout
329
+ - Maintain responsive behavior and animations
330
+ - Convert static navigation to WordPress menus
331
+ - Transform static content areas into dynamic WordPress content
332
+ - Implement proper WordPress template hierarchy
333
+ - Add WordPress admin customization options`;
334
+ const outputInstructions = `Generate a complete WordPress theme structure that perfectly replicates the static site design:
335
+
336
+ ## Required WordPress Theme Structure:
337
+
338
+ ### 1. Theme Root Files
339
+ - **style.css**: Main stylesheet with proper WordPress theme header
340
+ - **index.php**: Default template with WordPress loop
341
+ - **functions.php**: Theme functions, enqueues, and WordPress feature support
342
+ - **screenshot.png**: Theme screenshot (1200x900px description)
343
+
344
+ ### 2. Template Hierarchy Files
345
+ Based on detected page types, include relevant templates:
346
+ - **home.php** / **front-page.php**: Homepage template
347
+ - **single.php**: Single post template
348
+ - **page.php**: Static page template
349
+ - **archive.php**: Archive pages template
350
+ - **search.php**: Search results template
351
+ - **404.php**: Error page template
352
+ - **header.php**: Header template with WordPress head functions
353
+ - **footer.php**: Footer template with WordPress footer functions
354
+ - **sidebar.php**: Sidebar with widget areas (if applicable)
355
+
356
+ ### 3. Asset Management
357
+ - **js/**: JavaScript files with proper WordPress enqueuing
358
+ - **css/**: Additional stylesheets organized by purpose
359
+ - **images/**: Theme images and assets
360
+ - **fonts/**: Custom fonts (if used)
361
+
362
+ ### 4. WordPress Integration Features
363
+ - **Template Parts**: Modular template components
364
+ - **Custom Post Types**: If needed for content structure
365
+ - **Customizer Options**: Theme customization panel
366
+ - **Widget Areas**: Dynamic sidebar/footer widget areas
367
+ - **Navigation Menus**: Dynamic menu locations
368
+
369
+ ${params.includeGutenberg ? `
370
+ ### 5. Gutenberg Block Support
371
+ - **blocks/**: Custom block styles and templates
372
+ - **theme.json**: Global theme settings for block editor
373
+ - **Block patterns**: Custom block patterns matching original design
374
+ ` : ''}
375
+
376
+ ${params.includeWooCommerce ? `
377
+ ### 6. WooCommerce Integration
378
+ - **woocommerce/**: WooCommerce template overrides
379
+ - **WooCommerce styling**: Product page styling matching theme design
380
+ - **Cart/checkout**: Styled cart and checkout pages
381
+ ` : ''}
382
+
383
+ ## WordPress Standards Implementation:
384
+
385
+ ### Theme Header Requirements (style.css):
386
+ \`\`\`css
387
+ /*
388
+ Theme Name: ${themeName || 'Custom Static Theme'}
389
+ Description: ${themeDescription || 'WordPress theme generated from static site'}
390
+ Author: ${params.themeAuthor || 'Theme Generator'}
391
+ Version: ${params.themeVersion || '1.0.0'}
392
+ Requires at least: 6.0
393
+ Tested up to: 6.4
394
+ Requires PHP: 7.4
395
+ License: GPL v2 or later
396
+ Text Domain: [theme-slug]
397
+ Tags: responsive, custom-design, static-conversion
398
+ */
399
+ \`\`\`
400
+
401
+ ### Functions.php Requirements:
402
+ - Proper theme setup with add_theme_support()
403
+ - Script/style enqueuing with wp_enqueue_script/style()
404
+ - Navigation menu registration
405
+ - Widget area registration
406
+ - Custom post type registration (if needed)
407
+ - Theme customizer options
408
+ - Gutenberg block support (if enabled)
409
+
410
+ ### Template Requirements:
411
+ - WordPress head/footer functions: wp_head(), wp_footer()
412
+ - Proper WordPress loops with get_template_part()
413
+ - Conditional template loading
414
+ - Escape all output: esc_html(), esc_url(), esc_attr()
415
+ - Internationalization: __(), _e(), _x() functions
416
+ - WordPress body classes: body_class()
417
+
418
+ ### Performance & SEO:
419
+ - Optimized CSS/JS loading
420
+ - Proper image handling with wp_get_attachment_image()
421
+ - Meta tags and structured data
422
+ - Page speed optimization
423
+ - Mobile-first responsive design
424
+
425
+ Provide complete, production-ready WordPress theme files that exactly replicate the original static site design while adding full WordPress functionality. Include detailed setup instructions and customization documentation.`;
426
+ return { systemAndContext, dataPayload, outputInstructions };
427
+ }
428
+ /**
429
+ * Multi-file prompt stages - Multiple pages/URLs or directory conversion
430
+ */
431
+ getMultiFilePromptStages(params) {
432
+ const { analysisResult, analysisType, analysisDepth, sourceCount } = params;
433
+ const systemAndContext = `You are an expert WordPress theme architect specializing in ${analysisDepth} ${analysisType} static site to WordPress conversions.
434
+
435
+ Multi-Source WordPress Theme Conversion Context:
436
+ - Analysis Type: ${analysisType}
437
+ - Analysis Depth: ${analysisDepth}
438
+ - Sources Analyzed: ${sourceCount}
439
+ - Mode: Multi-Page/Multi-File WordPress Theme Generation
440
+
441
+ Your task is to create a comprehensive WordPress theme that unifies multiple pages/sections while maintaining design consistency and adding full WordPress functionality.`;
442
+ const dataPayload = `Multi-source static site analysis results:
443
+
444
+ ${JSON.stringify(analysisResult, null, 2)}`;
445
+ const outputInstructions = `Generate a comprehensive WordPress theme from multiple static sources:
446
+
447
+ ## Multi-Source Theme Architecture:
448
+
449
+ ### 1. Unified Design System Analysis
450
+ - **Design Patterns**: Common elements across all analyzed sources
451
+ - **Color Schemes**: Consistent color palette extraction
452
+ - **Typography**: Font families and sizing scales used
453
+ - **Layout Grids**: Responsive grid systems identified
454
+ - **Component Library**: Reusable UI components found
455
+
456
+ ### 2. Template Hierarchy Strategy
457
+ Based on analyzed sources, create appropriate templates:
458
+ - **Page Templates**: Custom templates for different page types found
459
+ - **Content Variations**: Handle different content structures
460
+ - **Layout Variations**: Multiple layout options for different sections
461
+ - **Component Templates**: Reusable template parts
462
+
463
+ ### 3. WordPress Theme Structure
464
+ Generate complete theme with:
465
+ - **Unified style.css**: Combining all CSS while maintaining organization
466
+ - **Template files**: Appropriate templates for all page types discovered
467
+ - **functions.php**: Comprehensive theme setup with all required features
468
+ - **Asset organization**: Properly structured JS/CSS/image assets
469
+
470
+ ### 4. Multi-Source Integration Features
471
+ - **Content Type Detection**: Identify different content structures across sources
472
+ - **Navigation Synthesis**: Combine navigation patterns into cohesive menu system
473
+ - **Widget Area Strategy**: Determine optimal sidebar/widget placements
474
+ - **Customizer Options**: Theme options covering variations found in sources
475
+
476
+ ### 5. Cross-Page Consistency
477
+ - **Design System**: Unified component system across all templates
478
+ - **Performance**: Optimized asset loading for multi-template theme
479
+ - **Accessibility**: Consistent accessibility implementation across all templates
480
+ - **Responsive Behavior**: Unified responsive design strategy
481
+
482
+ ## Multi-Source Conversion Output:
483
+
484
+ {
485
+ "themeOverview": {
486
+ "detectedPageTypes": ["list of page types found"],
487
+ "commonDesignElements": ["shared design patterns"],
488
+ "uniqueFeatures": ["special features requiring custom implementation"],
489
+ "recommendedTemplates": ["WordPress templates to create"]
490
+ },
491
+ "unifiedDesignSystem": {
492
+ "colorPalette": ["primary colors extracted"],
493
+ "typography": ["font systems identified"],
494
+ "componentLibrary": ["reusable components found"],
495
+ "layoutSystems": ["grid and layout patterns"]
496
+ },
497
+ "themeFiles": [
498
+ {
499
+ "filename": "style.css",
500
+ "purpose": "Main stylesheet with unified design system",
501
+ "content": "Complete CSS code"
502
+ },
503
+ {
504
+ "filename": "index.php",
505
+ "purpose": "Default template with WordPress loop",
506
+ "content": "Complete PHP template code"
507
+ }
508
+ // ... additional theme files
509
+ ],
510
+ "implementationGuide": {
511
+ "setupInstructions": ["step-by-step theme setup"],
512
+ "customizationOptions": ["available theme customizer options"],
513
+ "maintenanceNotes": ["ongoing maintenance considerations"]
514
+ }
515
+ }
516
+
517
+ Provide a complete, unified WordPress theme that successfully combines all analyzed sources into a cohesive, professional theme with full WordPress functionality.`;
518
+ return { systemAndContext, dataPayload, outputInstructions };
519
+ }
520
+ /**
521
+ * Backwards compatibility method
522
+ */
523
+ getPromptStages(params) {
524
+ const mode = this.detectAnalysisMode(params);
525
+ if (mode === 'single-file') {
526
+ return this.getSingleFilePromptStages(params);
527
+ }
528
+ else {
529
+ return this.getMultiFilePromptStages(params);
530
+ }
531
+ }
532
+ // Multi-file helper methods
533
+ async discoverRelevantFiles(projectPath, maxDepth, analysisType) {
534
+ const extensions = this.getFileExtensions(analysisType);
535
+ return await this.multiFileAnalysis.discoverFiles(projectPath, extensions, maxDepth);
536
+ }
537
+ async performMultiFileAnalysis(files, params, model, contextLength) {
538
+ const cacheKey = this.analysisCache.generateKey('wordpress_theme_from_static', params, files);
539
+ const cached = await this.analysisCache.get(cacheKey);
540
+ if (cached)
541
+ return cached;
542
+ const fileAnalysisResults = await this.multiFileAnalysis.analyzeBatch(files, (file) => this.analyzeIndividualFile(file, params, model), contextLength);
543
+ // Aggregate results into theme-specific analysis format
544
+ const aggregatedResult = {
545
+ summary: `Static site directory analysis of ${files.length} files`,
546
+ findings: fileAnalysisResults,
547
+ data: {
548
+ fileCount: files.length,
549
+ totalSize: fileAnalysisResults.reduce((sum, result) => sum + (result.size || 0), 0),
550
+ htmlFiles: fileAnalysisResults.filter(f => f.extension === '.html').length,
551
+ cssFiles: fileAnalysisResults.filter(f => f.extension === '.css').length,
552
+ jsFiles: fileAnalysisResults.filter(f => f.extension === '.js').length,
553
+ imageFiles: fileAnalysisResults.filter(f => ['.jpg', '.jpeg', '.png', '.gif', '.svg', '.webp'].includes(f.extension)).length,
554
+ designPatterns: this.extractDesignPatterns(fileAnalysisResults),
555
+ pageTypes: this.identifyPageTypes(fileAnalysisResults)
556
+ }
557
+ };
558
+ await this.analysisCache.cacheAnalysis(cacheKey, aggregatedResult, {
559
+ modelUsed: model.identifier || 'unknown',
560
+ executionTime: Date.now() - Date.now(),
561
+ timestamp: new Date().toISOString()
562
+ });
563
+ return aggregatedResult;
564
+ }
565
+ async performMultiUrlAnalysis(urls, params, model, contextLength) {
566
+ // For URL analysis, we'll create a structured analysis result
567
+ // Note: Actual URL fetching would require additional implementation
568
+ const analysisResult = {
569
+ summary: `Multi-URL static site analysis of ${urls.length} pages`,
570
+ findings: urls.map(url => ({
571
+ url,
572
+ pageType: this.guessPageTypeFromUrl(url),
573
+ analysisNote: `URL analysis - would require fetch implementation for actual content`
574
+ })),
575
+ data: {
576
+ urlCount: urls.length,
577
+ estimatedPageTypes: urls.map(url => this.guessPageTypeFromUrl(url)),
578
+ conversionComplexity: urls.length > 5 ? 'high' : urls.length > 2 ? 'medium' : 'low'
579
+ }
580
+ };
581
+ return analysisResult;
582
+ }
583
+ async analyzeIndividualFile(file, params, model) {
584
+ const content = await import('fs/promises').then(fs => fs.readFile(file, 'utf-8'));
585
+ const stats = await import('fs/promises').then(fs => fs.stat(file));
586
+ // Static site specific analysis
587
+ const isHtmlFile = extname(file).toLowerCase() === '.html';
588
+ const isCssFile = extname(file).toLowerCase() === '.css';
589
+ const isJsFile = extname(file).toLowerCase() === '.js';
590
+ let pageType = 'unknown';
591
+ if (isHtmlFile) {
592
+ pageType = this.identifyHtmlPageType(basename(file), content);
593
+ }
594
+ return {
595
+ filePath: file,
596
+ fileName: basename(file),
597
+ size: content.length,
598
+ lines: content.split('\n').length,
599
+ extension: extname(file),
600
+ relativePath: relative(params.projectPath || '', file),
601
+ isHtmlFile,
602
+ isCssFile,
603
+ isJsFile,
604
+ pageType,
605
+ hasBootstrap: content.includes('bootstrap'),
606
+ hasJQuery: content.includes('jquery'),
607
+ hasResponsiveDesign: content.includes('@media'),
608
+ hasCustomFonts: content.includes('@font-face') || content.includes('googleapis.com/css')
609
+ };
610
+ }
611
+ identifyHtmlPageType(filename, content) {
612
+ const lowerName = filename.toLowerCase();
613
+ const lowerContent = content.toLowerCase();
614
+ if (lowerName.includes('index') || lowerName.includes('home'))
615
+ return 'homepage';
616
+ if (lowerName.includes('about'))
617
+ return 'about-page';
618
+ if (lowerName.includes('contact'))
619
+ return 'contact-page';
620
+ if (lowerName.includes('blog'))
621
+ return 'blog-page';
622
+ if (lowerName.includes('service'))
623
+ return 'services-page';
624
+ if (lowerName.includes('portfolio') || lowerName.includes('work'))
625
+ return 'portfolio-page';
626
+ if (lowerName.includes('product'))
627
+ return 'product-page';
628
+ if (lowerName.includes('news'))
629
+ return 'news-page';
630
+ // Content-based detection
631
+ if (lowerContent.includes('blog') && lowerContent.includes('post'))
632
+ return 'blog-page';
633
+ if (lowerContent.includes('contact') && lowerContent.includes('form'))
634
+ return 'contact-page';
635
+ if (lowerContent.includes('portfolio') || lowerContent.includes('gallery'))
636
+ return 'portfolio-page';
637
+ return 'content-page';
638
+ }
639
+ guessPageTypeFromUrl(url) {
640
+ const lowerUrl = url.toLowerCase();
641
+ if (lowerUrl.includes('/blog') || lowerUrl.includes('/news'))
642
+ return 'blog-page';
643
+ if (lowerUrl.includes('/about'))
644
+ return 'about-page';
645
+ if (lowerUrl.includes('/contact'))
646
+ return 'contact-page';
647
+ if (lowerUrl.includes('/services'))
648
+ return 'services-page';
649
+ if (lowerUrl.includes('/portfolio') || lowerUrl.includes('/work'))
650
+ return 'portfolio-page';
651
+ if (lowerUrl.includes('/products'))
652
+ return 'product-page';
653
+ if (lowerUrl.endsWith('/') || lowerUrl.includes('index'))
654
+ return 'homepage';
655
+ return 'content-page';
656
+ }
657
+ extractDesignPatterns(results) {
658
+ const patterns = {
659
+ hasBootstrap: results.some(f => f.hasBootstrap),
660
+ hasJQuery: results.some(f => f.hasJQuery),
661
+ hasResponsiveDesign: results.some(f => f.hasResponsiveDesign),
662
+ hasCustomFonts: results.some(f => f.hasCustomFonts),
663
+ commonFrameworks: []
664
+ };
665
+ if (patterns.hasBootstrap)
666
+ patterns.commonFrameworks.push('Bootstrap');
667
+ if (patterns.hasJQuery)
668
+ patterns.commonFrameworks.push('jQuery');
669
+ return patterns;
670
+ }
671
+ identifyPageTypes(results) {
672
+ const pageTypes = new Set();
673
+ results.forEach(result => {
674
+ if (result.pageType && result.pageType !== 'unknown') {
675
+ pageTypes.add(result.pageType);
676
+ }
677
+ });
678
+ return Array.from(pageTypes);
679
+ }
680
+ getFileExtensions(analysisType) {
681
+ const extensionMap = {
682
+ 'simple': ['.html', '.css', '.js'],
683
+ 'responsive': ['.html', '.css', '.js', '.scss', '.sass', '.less'],
684
+ 'comprehensive': ['.html', '.htm', '.css', '.js', '.scss', '.sass', '.less', '.json', '.xml', '.svg', '.jpg', '.jpeg', '.png', '.gif', '.webp', '.woff', '.woff2', '.ttf', '.eot']
685
+ };
686
+ return extensionMap[analysisType] || extensionMap.comprehensive;
687
+ }
688
+ generateCacheKey(files, params) {
689
+ const fileHash = files.join('|');
690
+ const paramHash = JSON.stringify(params);
691
+ return `${fileHash}_${paramHash}`.substring(0, 64);
692
+ }
693
+ }
694
+ export default WordPressThemeFromStaticGenerator;
695
+ //# sourceMappingURL=wordpress-theme-from-static.js.map