@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,699 +0,0 @@
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, TokenCalculator } 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();
231
- const needsChunking = TokenCalculator.needsChunking(promptStages, contextLength);
232
- if (needsChunking) {
233
- const chunkSize = TokenCalculator.calculateOptimalChunkSize(promptStages, contextLength);
234
- const dataChunks = promptManager.chunkDataPayload(promptStages.dataPayload, chunkSize);
235
- const conversation = promptManager.createChunkedConversation(promptStages, dataChunks);
236
- const messages = [
237
- conversation.systemMessage,
238
- ...conversation.dataMessages,
239
- conversation.analysisMessage
240
- ];
241
- return await ResponseProcessor.executeChunked(messages, model, contextLength, 'wordpress_theme_from_static', 'single');
242
- }
243
- else {
244
- return await ResponseProcessor.executeDirect(promptStages, model, contextLength, 'wordpress_theme_from_static');
245
- }
246
- }
247
- /**
248
- * Execute multi-file analysis (multiple pages/URLs or directory conversion)
249
- */
250
- async executeMultiFileAnalysis(params, model, contextLength) {
251
- let analysisResult;
252
- if (params.projectPath) {
253
- // Directory-based conversion
254
- const filesToAnalyze = await this.discoverRelevantFiles(params.projectPath, params.maxDepth, params.analysisType);
255
- analysisResult = await this.performMultiFileAnalysis(filesToAnalyze, params, model, contextLength);
256
- }
257
- else if (params.urls) {
258
- // URL-based conversion
259
- analysisResult = await this.performMultiUrlAnalysis(params.urls, params, model, contextLength);
260
- }
261
- // Generate prompt stages for multi-source conversion
262
- const promptStages = this.getMultiFilePromptStages({
263
- ...params,
264
- analysisResult,
265
- sourceCount: params.urls?.length || analysisResult?.findings?.length || 0
266
- });
267
- // Always use chunking for multi-file
268
- const promptManager = new ThreeStagePromptManager();
269
- const chunkSize = TokenCalculator.calculateOptimalChunkSize(promptStages, contextLength);
270
- const dataChunks = promptManager.chunkDataPayload(promptStages.dataPayload, chunkSize);
271
- const conversation = promptManager.createChunkedConversation(promptStages, dataChunks);
272
- const messages = [
273
- conversation.systemMessage,
274
- ...conversation.dataMessages,
275
- conversation.analysisMessage
276
- ];
277
- return await ResponseProcessor.executeChunked(messages, model, contextLength, 'wordpress_theme_from_static', 'multifile');
278
- }
279
- /**
280
- * Single-file prompt stages - Single page/URL to WordPress theme conversion
281
- */
282
- getSingleFilePromptStages(params) {
283
- const { content, sourceUrl, analysisDepth, analysisType, themeName, themeDescription } = params;
284
- const systemAndContext = `You are an expert WordPress theme developer specializing in converting static sites to ${analysisDepth} ${analysisType} WordPress themes.
285
-
286
- WordPress Theme Development Expertise:
287
- - Static to Dynamic Conversion: Transform HTML/CSS/JS into PHP template hierarchy
288
- - WordPress Standards: Follow WordPress Theme Review Guidelines and coding standards
289
- - Template Hierarchy: Master WordPress template hierarchy (index, home, single, page, archive, etc.)
290
- - Dynamic Content Integration: Replace static content with WordPress functions and loops
291
- - Responsive Design: Maintain original responsiveness while adding WordPress functionality
292
- - Performance Optimization: Enqueue scripts/styles properly, optimize images, minimize HTTP requests
293
- - Accessibility: Maintain WCAG compliance throughout conversion process
294
- - Cross-browser Compatibility: Ensure theme works across all major browsers
295
- - SEO Best Practices: Implement proper meta tags, structured data, and SEO-friendly markup
296
-
297
- Conversion Context:
298
- - Analysis Depth: ${analysisDepth}
299
- - Theme Complexity: ${analysisType}
300
- - Source Type: ${sourceUrl ? 'URL-based conversion' : 'File-based conversion'}
301
- - WordPress Features: Gutenberg ${params.includeGutenberg ? 'enabled' : 'disabled'}, WooCommerce ${params.includeWooCommerce ? 'enabled' : 'disabled'}
302
-
303
- Your task is to create a complete, professional WordPress theme that preserves the original design while adding full WordPress functionality.`;
304
- const dataPayload = `Static Site Conversion Requirements:
305
-
306
- **Theme Details:**
307
- - Theme Name: ${themeName || 'Custom Static Theme'}
308
- - Description: ${themeDescription || 'WordPress theme generated from static site'}
309
- - Author: ${params.themeAuthor || 'Theme Generator'}
310
- - Version: ${params.themeVersion || '1.0.0'}
311
- ${sourceUrl ? `- Source URL: ${sourceUrl}` : ''}
312
-
313
- **WordPress Features to Include:**
314
- - Gutenberg Block Editor Support: ${params.includeGutenberg !== false}
315
- - WooCommerce Template Support: ${params.includeWooCommerce || false}
316
- - WordPress Customizer Integration: ${params.includeCustomizer !== false}
317
- - Dynamic Navigation Menus: ${params.includeMenus !== false}
318
- - Sidebar/Widget Areas: ${params.includeSidebars !== false}
319
-
320
- **Static Site Content to Convert:**
321
- ${content ? `
322
- HTML Content:
323
- \`\`\`html
324
- ${content}
325
- \`\`\`
326
- ` : `
327
- Source URL: ${sourceUrl}
328
- Note: Analyze the provided URL to understand the site structure, design patterns, and styling approach.
329
- `}
330
-
331
- **Conversion Requirements:**
332
- - Preserve exact visual design and layout
333
- - Maintain responsive behavior and animations
334
- - Convert static navigation to WordPress menus
335
- - Transform static content areas into dynamic WordPress content
336
- - Implement proper WordPress template hierarchy
337
- - Add WordPress admin customization options`;
338
- const outputInstructions = `Generate a complete WordPress theme structure that perfectly replicates the static site design:
339
-
340
- ## Required WordPress Theme Structure:
341
-
342
- ### 1. Theme Root Files
343
- - **style.css**: Main stylesheet with proper WordPress theme header
344
- - **index.php**: Default template with WordPress loop
345
- - **functions.php**: Theme functions, enqueues, and WordPress feature support
346
- - **screenshot.png**: Theme screenshot (1200x900px description)
347
-
348
- ### 2. Template Hierarchy Files
349
- Based on detected page types, include relevant templates:
350
- - **home.php** / **front-page.php**: Homepage template
351
- - **single.php**: Single post template
352
- - **page.php**: Static page template
353
- - **archive.php**: Archive pages template
354
- - **search.php**: Search results template
355
- - **404.php**: Error page template
356
- - **header.php**: Header template with WordPress head functions
357
- - **footer.php**: Footer template with WordPress footer functions
358
- - **sidebar.php**: Sidebar with widget areas (if applicable)
359
-
360
- ### 3. Asset Management
361
- - **js/**: JavaScript files with proper WordPress enqueuing
362
- - **css/**: Additional stylesheets organized by purpose
363
- - **images/**: Theme images and assets
364
- - **fonts/**: Custom fonts (if used)
365
-
366
- ### 4. WordPress Integration Features
367
- - **Template Parts**: Modular template components
368
- - **Custom Post Types**: If needed for content structure
369
- - **Customizer Options**: Theme customization panel
370
- - **Widget Areas**: Dynamic sidebar/footer widget areas
371
- - **Navigation Menus**: Dynamic menu locations
372
-
373
- ${params.includeGutenberg ? `
374
- ### 5. Gutenberg Block Support
375
- - **blocks/**: Custom block styles and templates
376
- - **theme.json**: Global theme settings for block editor
377
- - **Block patterns**: Custom block patterns matching original design
378
- ` : ''}
379
-
380
- ${params.includeWooCommerce ? `
381
- ### 6. WooCommerce Integration
382
- - **woocommerce/**: WooCommerce template overrides
383
- - **WooCommerce styling**: Product page styling matching theme design
384
- - **Cart/checkout**: Styled cart and checkout pages
385
- ` : ''}
386
-
387
- ## WordPress Standards Implementation:
388
-
389
- ### Theme Header Requirements (style.css):
390
- \`\`\`css
391
- /*
392
- Theme Name: ${themeName || 'Custom Static Theme'}
393
- Description: ${themeDescription || 'WordPress theme generated from static site'}
394
- Author: ${params.themeAuthor || 'Theme Generator'}
395
- Version: ${params.themeVersion || '1.0.0'}
396
- Requires at least: 6.0
397
- Tested up to: 6.4
398
- Requires PHP: 7.4
399
- License: GPL v2 or later
400
- Text Domain: [theme-slug]
401
- Tags: responsive, custom-design, static-conversion
402
- */
403
- \`\`\`
404
-
405
- ### Functions.php Requirements:
406
- - Proper theme setup with add_theme_support()
407
- - Script/style enqueuing with wp_enqueue_script/style()
408
- - Navigation menu registration
409
- - Widget area registration
410
- - Custom post type registration (if needed)
411
- - Theme customizer options
412
- - Gutenberg block support (if enabled)
413
-
414
- ### Template Requirements:
415
- - WordPress head/footer functions: wp_head(), wp_footer()
416
- - Proper WordPress loops with get_template_part()
417
- - Conditional template loading
418
- - Escape all output: esc_html(), esc_url(), esc_attr()
419
- - Internationalization: __(), _e(), _x() functions
420
- - WordPress body classes: body_class()
421
-
422
- ### Performance & SEO:
423
- - Optimized CSS/JS loading
424
- - Proper image handling with wp_get_attachment_image()
425
- - Meta tags and structured data
426
- - Page speed optimization
427
- - Mobile-first responsive design
428
-
429
- 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.`;
430
- return { systemAndContext, dataPayload, outputInstructions };
431
- }
432
- /**
433
- * Multi-file prompt stages - Multiple pages/URLs or directory conversion
434
- */
435
- getMultiFilePromptStages(params) {
436
- const { analysisResult, analysisType, analysisDepth, sourceCount } = params;
437
- const systemAndContext = `You are an expert WordPress theme architect specializing in ${analysisDepth} ${analysisType} static site to WordPress conversions.
438
-
439
- Multi-Source WordPress Theme Conversion Context:
440
- - Analysis Type: ${analysisType}
441
- - Analysis Depth: ${analysisDepth}
442
- - Sources Analyzed: ${sourceCount}
443
- - Mode: Multi-Page/Multi-File WordPress Theme Generation
444
-
445
- Your task is to create a comprehensive WordPress theme that unifies multiple pages/sections while maintaining design consistency and adding full WordPress functionality.`;
446
- const dataPayload = `Multi-source static site analysis results:
447
-
448
- ${JSON.stringify(analysisResult, null, 2)}`;
449
- const outputInstructions = `Generate a comprehensive WordPress theme from multiple static sources:
450
-
451
- ## Multi-Source Theme Architecture:
452
-
453
- ### 1. Unified Design System Analysis
454
- - **Design Patterns**: Common elements across all analyzed sources
455
- - **Color Schemes**: Consistent color palette extraction
456
- - **Typography**: Font families and sizing scales used
457
- - **Layout Grids**: Responsive grid systems identified
458
- - **Component Library**: Reusable UI components found
459
-
460
- ### 2. Template Hierarchy Strategy
461
- Based on analyzed sources, create appropriate templates:
462
- - **Page Templates**: Custom templates for different page types found
463
- - **Content Variations**: Handle different content structures
464
- - **Layout Variations**: Multiple layout options for different sections
465
- - **Component Templates**: Reusable template parts
466
-
467
- ### 3. WordPress Theme Structure
468
- Generate complete theme with:
469
- - **Unified style.css**: Combining all CSS while maintaining organization
470
- - **Template files**: Appropriate templates for all page types discovered
471
- - **functions.php**: Comprehensive theme setup with all required features
472
- - **Asset organization**: Properly structured JS/CSS/image assets
473
-
474
- ### 4. Multi-Source Integration Features
475
- - **Content Type Detection**: Identify different content structures across sources
476
- - **Navigation Synthesis**: Combine navigation patterns into cohesive menu system
477
- - **Widget Area Strategy**: Determine optimal sidebar/widget placements
478
- - **Customizer Options**: Theme options covering variations found in sources
479
-
480
- ### 5. Cross-Page Consistency
481
- - **Design System**: Unified component system across all templates
482
- - **Performance**: Optimized asset loading for multi-template theme
483
- - **Accessibility**: Consistent accessibility implementation across all templates
484
- - **Responsive Behavior**: Unified responsive design strategy
485
-
486
- ## Multi-Source Conversion Output:
487
-
488
- {
489
- "themeOverview": {
490
- "detectedPageTypes": ["list of page types found"],
491
- "commonDesignElements": ["shared design patterns"],
492
- "uniqueFeatures": ["special features requiring custom implementation"],
493
- "recommendedTemplates": ["WordPress templates to create"]
494
- },
495
- "unifiedDesignSystem": {
496
- "colorPalette": ["primary colors extracted"],
497
- "typography": ["font systems identified"],
498
- "componentLibrary": ["reusable components found"],
499
- "layoutSystems": ["grid and layout patterns"]
500
- },
501
- "themeFiles": [
502
- {
503
- "filename": "style.css",
504
- "purpose": "Main stylesheet with unified design system",
505
- "content": "Complete CSS code"
506
- },
507
- {
508
- "filename": "index.php",
509
- "purpose": "Default template with WordPress loop",
510
- "content": "Complete PHP template code"
511
- }
512
- // ... additional theme files
513
- ],
514
- "implementationGuide": {
515
- "setupInstructions": ["step-by-step theme setup"],
516
- "customizationOptions": ["available theme customizer options"],
517
- "maintenanceNotes": ["ongoing maintenance considerations"]
518
- }
519
- }
520
-
521
- Provide a complete, unified WordPress theme that successfully combines all analyzed sources into a cohesive, professional theme with full WordPress functionality.`;
522
- return { systemAndContext, dataPayload, outputInstructions };
523
- }
524
- /**
525
- * Backwards compatibility method
526
- */
527
- getPromptStages(params) {
528
- const mode = this.detectAnalysisMode(params);
529
- if (mode === 'single-file') {
530
- return this.getSingleFilePromptStages(params);
531
- }
532
- else {
533
- return this.getMultiFilePromptStages(params);
534
- }
535
- }
536
- // Multi-file helper methods
537
- async discoverRelevantFiles(projectPath, maxDepth, analysisType) {
538
- const extensions = this.getFileExtensions(analysisType);
539
- return await this.multiFileAnalysis.discoverFiles(projectPath, extensions, maxDepth);
540
- }
541
- async performMultiFileAnalysis(files, params, model, contextLength) {
542
- const cacheKey = this.analysisCache.generateKey('wordpress_theme_from_static', params, files);
543
- const cached = await this.analysisCache.get(cacheKey);
544
- if (cached)
545
- return cached;
546
- const fileAnalysisResults = await this.multiFileAnalysis.analyzeBatch(files, (file) => this.analyzeIndividualFile(file, params, model), contextLength);
547
- // Aggregate results into theme-specific analysis format
548
- const aggregatedResult = {
549
- summary: `Static site directory analysis of ${files.length} files`,
550
- findings: fileAnalysisResults,
551
- data: {
552
- fileCount: files.length,
553
- totalSize: fileAnalysisResults.reduce((sum, result) => sum + (result.size || 0), 0),
554
- htmlFiles: fileAnalysisResults.filter(f => f.extension === '.html').length,
555
- cssFiles: fileAnalysisResults.filter(f => f.extension === '.css').length,
556
- jsFiles: fileAnalysisResults.filter(f => f.extension === '.js').length,
557
- imageFiles: fileAnalysisResults.filter(f => ['.jpg', '.jpeg', '.png', '.gif', '.svg', '.webp'].includes(f.extension)).length,
558
- designPatterns: this.extractDesignPatterns(fileAnalysisResults),
559
- pageTypes: this.identifyPageTypes(fileAnalysisResults)
560
- }
561
- };
562
- await this.analysisCache.cacheAnalysis(cacheKey, aggregatedResult, {
563
- modelUsed: model.identifier || 'unknown',
564
- executionTime: Date.now() - Date.now(),
565
- timestamp: new Date().toISOString()
566
- });
567
- return aggregatedResult;
568
- }
569
- async performMultiUrlAnalysis(urls, params, model, contextLength) {
570
- // For URL analysis, we'll create a structured analysis result
571
- // Note: Actual URL fetching would require additional implementation
572
- const analysisResult = {
573
- summary: `Multi-URL static site analysis of ${urls.length} pages`,
574
- findings: urls.map(url => ({
575
- url,
576
- pageType: this.guessPageTypeFromUrl(url),
577
- analysisNote: `URL analysis - would require fetch implementation for actual content`
578
- })),
579
- data: {
580
- urlCount: urls.length,
581
- estimatedPageTypes: urls.map(url => this.guessPageTypeFromUrl(url)),
582
- conversionComplexity: urls.length > 5 ? 'high' : urls.length > 2 ? 'medium' : 'low'
583
- }
584
- };
585
- return analysisResult;
586
- }
587
- async analyzeIndividualFile(file, params, model) {
588
- const content = await import('fs/promises').then(fs => fs.readFile(file, 'utf-8'));
589
- const stats = await import('fs/promises').then(fs => fs.stat(file));
590
- // Static site specific analysis
591
- const isHtmlFile = extname(file).toLowerCase() === '.html';
592
- const isCssFile = extname(file).toLowerCase() === '.css';
593
- const isJsFile = extname(file).toLowerCase() === '.js';
594
- let pageType = 'unknown';
595
- if (isHtmlFile) {
596
- pageType = this.identifyHtmlPageType(basename(file), content);
597
- }
598
- return {
599
- filePath: file,
600
- fileName: basename(file),
601
- size: content.length,
602
- lines: content.split('\n').length,
603
- extension: extname(file),
604
- relativePath: relative(params.projectPath || '', file),
605
- isHtmlFile,
606
- isCssFile,
607
- isJsFile,
608
- pageType,
609
- hasBootstrap: content.includes('bootstrap'),
610
- hasJQuery: content.includes('jquery'),
611
- hasResponsiveDesign: content.includes('@media'),
612
- hasCustomFonts: content.includes('@font-face') || content.includes('googleapis.com/css')
613
- };
614
- }
615
- identifyHtmlPageType(filename, content) {
616
- const lowerName = filename.toLowerCase();
617
- const lowerContent = content.toLowerCase();
618
- if (lowerName.includes('index') || lowerName.includes('home'))
619
- return 'homepage';
620
- if (lowerName.includes('about'))
621
- return 'about-page';
622
- if (lowerName.includes('contact'))
623
- return 'contact-page';
624
- if (lowerName.includes('blog'))
625
- return 'blog-page';
626
- if (lowerName.includes('service'))
627
- return 'services-page';
628
- if (lowerName.includes('portfolio') || lowerName.includes('work'))
629
- return 'portfolio-page';
630
- if (lowerName.includes('product'))
631
- return 'product-page';
632
- if (lowerName.includes('news'))
633
- return 'news-page';
634
- // Content-based detection
635
- if (lowerContent.includes('blog') && lowerContent.includes('post'))
636
- return 'blog-page';
637
- if (lowerContent.includes('contact') && lowerContent.includes('form'))
638
- return 'contact-page';
639
- if (lowerContent.includes('portfolio') || lowerContent.includes('gallery'))
640
- return 'portfolio-page';
641
- return 'content-page';
642
- }
643
- guessPageTypeFromUrl(url) {
644
- const lowerUrl = url.toLowerCase();
645
- if (lowerUrl.includes('/blog') || lowerUrl.includes('/news'))
646
- return 'blog-page';
647
- if (lowerUrl.includes('/about'))
648
- return 'about-page';
649
- if (lowerUrl.includes('/contact'))
650
- return 'contact-page';
651
- if (lowerUrl.includes('/services'))
652
- return 'services-page';
653
- if (lowerUrl.includes('/portfolio') || lowerUrl.includes('/work'))
654
- return 'portfolio-page';
655
- if (lowerUrl.includes('/products'))
656
- return 'product-page';
657
- if (lowerUrl.endsWith('/') || lowerUrl.includes('index'))
658
- return 'homepage';
659
- return 'content-page';
660
- }
661
- extractDesignPatterns(results) {
662
- const patterns = {
663
- hasBootstrap: results.some(f => f.hasBootstrap),
664
- hasJQuery: results.some(f => f.hasJQuery),
665
- hasResponsiveDesign: results.some(f => f.hasResponsiveDesign),
666
- hasCustomFonts: results.some(f => f.hasCustomFonts),
667
- commonFrameworks: []
668
- };
669
- if (patterns.hasBootstrap)
670
- patterns.commonFrameworks.push('Bootstrap');
671
- if (patterns.hasJQuery)
672
- patterns.commonFrameworks.push('jQuery');
673
- return patterns;
674
- }
675
- identifyPageTypes(results) {
676
- const pageTypes = new Set();
677
- results.forEach(result => {
678
- if (result.pageType && result.pageType !== 'unknown') {
679
- pageTypes.add(result.pageType);
680
- }
681
- });
682
- return Array.from(pageTypes);
683
- }
684
- getFileExtensions(analysisType) {
685
- const extensionMap = {
686
- 'simple': ['.html', '.css', '.js'],
687
- 'responsive': ['.html', '.css', '.js', '.scss', '.sass', '.less'],
688
- 'comprehensive': ['.html', '.htm', '.css', '.js', '.scss', '.sass', '.less', '.json', '.xml', '.svg', '.jpg', '.jpeg', '.png', '.gif', '.webp', '.woff', '.woff2', '.ttf', '.eot']
689
- };
690
- return extensionMap[analysisType] || extensionMap.comprehensive;
691
- }
692
- generateCacheKey(files, params) {
693
- const fileHash = files.join('|');
694
- const paramHash = JSON.stringify(params);
695
- return `${fileHash}_${paramHash}`.substring(0, 64);
696
- }
697
- }
698
- export default WordPressThemeFromStaticGenerator;
699
- //# sourceMappingURL=wordpress-theme-from-static.js.map