@rankcli/agent-runtime 0.0.15 → 0.0.16

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 (202) hide show
  1. package/dist/index.d.mts +43 -393
  2. package/dist/index.d.ts +43 -393
  3. package/dist/index.js +306 -6526
  4. package/dist/index.mjs +202 -6412
  5. package/package.json +6 -1
  6. package/scripts/build-deno.ts +0 -134
  7. package/src/analyzers/core-web-vitals-analyzer.test.ts +0 -236
  8. package/src/analyzers/core-web-vitals-analyzer.ts +0 -557
  9. package/src/analyzers/geo-analyzer.test.ts +0 -310
  10. package/src/analyzers/geo-analyzer.ts +0 -814
  11. package/src/analyzers/image-optimization-analyzer.test.ts +0 -145
  12. package/src/analyzers/image-optimization-analyzer.ts +0 -348
  13. package/src/analyzers/index.ts +0 -233
  14. package/src/analyzers/internal-linking-analyzer.test.ts +0 -141
  15. package/src/analyzers/internal-linking-analyzer.ts +0 -419
  16. package/src/analyzers/mobile-seo-analyzer.test.ts +0 -140
  17. package/src/analyzers/mobile-seo-analyzer.ts +0 -455
  18. package/src/analyzers/security-headers-analyzer.test.ts +0 -115
  19. package/src/analyzers/security-headers-analyzer.ts +0 -318
  20. package/src/analyzers/structured-data-analyzer.test.ts +0 -210
  21. package/src/analyzers/structured-data-analyzer.ts +0 -590
  22. package/src/audit/ai/analyzer.ts +0 -347
  23. package/src/audit/ai/index.ts +0 -29
  24. package/src/audit/ai/prompts/content-analysis.ts +0 -271
  25. package/src/audit/ai/types.ts +0 -179
  26. package/src/audit/checks/additional-checks.ts +0 -439
  27. package/src/audit/checks/agent-experience.ts +0 -108
  28. package/src/audit/checks/ai-citation-worthiness.ts +0 -399
  29. package/src/audit/checks/ai-content-structure.ts +0 -325
  30. package/src/audit/checks/ai-readiness.ts +0 -406
  31. package/src/audit/checks/anchor-text.ts +0 -179
  32. package/src/audit/checks/answer-conciseness.ts +0 -322
  33. package/src/audit/checks/asset-minification.ts +0 -270
  34. package/src/audit/checks/bing-optimization.ts +0 -206
  35. package/src/audit/checks/brand-mention-optimization.ts +0 -349
  36. package/src/audit/checks/caching-headers.ts +0 -305
  37. package/src/audit/checks/canonical-advanced.ts +0 -150
  38. package/src/audit/checks/canonical-domain.ts +0 -196
  39. package/src/audit/checks/citation-quality.ts +0 -358
  40. package/src/audit/checks/client-rendering.ts +0 -542
  41. package/src/audit/checks/color-contrast.ts +0 -342
  42. package/src/audit/checks/content-freshness.ts +0 -170
  43. package/src/audit/checks/content-science.ts +0 -589
  44. package/src/audit/checks/conversion-elements.ts +0 -526
  45. package/src/audit/checks/crawlability.ts +0 -220
  46. package/src/audit/checks/directory-listing.ts +0 -172
  47. package/src/audit/checks/dom-analysis.ts +0 -191
  48. package/src/audit/checks/dom-size.ts +0 -246
  49. package/src/audit/checks/duplicate-content.ts +0 -194
  50. package/src/audit/checks/eeat-signals.ts +0 -990
  51. package/src/audit/checks/entity-seo.ts +0 -396
  52. package/src/audit/checks/featured-snippet.ts +0 -473
  53. package/src/audit/checks/freshness-signals.ts +0 -443
  54. package/src/audit/checks/funnel-intent.ts +0 -463
  55. package/src/audit/checks/hreflang.ts +0 -174
  56. package/src/audit/checks/html-compliance.ts +0 -302
  57. package/src/audit/checks/image-dimensions.ts +0 -167
  58. package/src/audit/checks/images.ts +0 -160
  59. package/src/audit/checks/indexnow.ts +0 -275
  60. package/src/audit/checks/interactive-tools.ts +0 -475
  61. package/src/audit/checks/internal-link-graph.ts +0 -436
  62. package/src/audit/checks/keyword-analysis.ts +0 -239
  63. package/src/audit/checks/keyword-cannibalization.ts +0 -385
  64. package/src/audit/checks/keyword-placement.ts +0 -471
  65. package/src/audit/checks/links.ts +0 -273
  66. package/src/audit/checks/llms-txt.ts +0 -224
  67. package/src/audit/checks/local-seo.ts +0 -296
  68. package/src/audit/checks/mobile.ts +0 -167
  69. package/src/audit/checks/modern-images.ts +0 -226
  70. package/src/audit/checks/navboost-signals.ts +0 -395
  71. package/src/audit/checks/on-page.ts +0 -209
  72. package/src/audit/checks/page-resources.ts +0 -285
  73. package/src/audit/checks/pagination.ts +0 -180
  74. package/src/audit/checks/performance.ts +0 -153
  75. package/src/audit/checks/platform-presence.ts +0 -580
  76. package/src/audit/checks/rag-chunk-readiness.test.ts +0 -159
  77. package/src/audit/checks/rag-chunk-readiness.ts +0 -163
  78. package/src/audit/checks/redirect-analysis.ts +0 -153
  79. package/src/audit/checks/redirect-chain.ts +0 -389
  80. package/src/audit/checks/resource-hints.ts +0 -420
  81. package/src/audit/checks/responsive-css.ts +0 -247
  82. package/src/audit/checks/responsive-images.ts +0 -396
  83. package/src/audit/checks/review-ecosystem.ts +0 -415
  84. package/src/audit/checks/robots-validation.ts +0 -373
  85. package/src/audit/checks/security-headers.ts +0 -188
  86. package/src/audit/checks/security.ts +0 -144
  87. package/src/audit/checks/serp-preview.ts +0 -251
  88. package/src/audit/checks/site-maturity.ts +0 -453
  89. package/src/audit/checks/social-meta.test.ts +0 -275
  90. package/src/audit/checks/social-meta.ts +0 -134
  91. package/src/audit/checks/soft-404.ts +0 -151
  92. package/src/audit/checks/structured-data.ts +0 -238
  93. package/src/audit/checks/tech-detection.ts +0 -496
  94. package/src/audit/checks/topical-clusters.ts +0 -435
  95. package/src/audit/checks/tracker-bloat.ts +0 -462
  96. package/src/audit/checks/tracking-verification.test.ts +0 -371
  97. package/src/audit/checks/tracking-verification.ts +0 -636
  98. package/src/audit/checks/url-safety.ts +0 -682
  99. package/src/audit/deno-entry.ts +0 -66
  100. package/src/audit/discovery/index.ts +0 -15
  101. package/src/audit/discovery/link-crawler.ts +0 -233
  102. package/src/audit/discovery/repo-routes.ts +0 -347
  103. package/src/audit/engine.ts +0 -633
  104. package/src/audit/fixes/index.ts +0 -209
  105. package/src/audit/fixes/social-meta-fixes.test.ts +0 -329
  106. package/src/audit/fixes/social-meta-fixes.ts +0 -463
  107. package/src/audit/index.ts +0 -74
  108. package/src/audit/runner.test.ts +0 -299
  109. package/src/audit/runner.ts +0 -130
  110. package/src/audit/types.ts +0 -1987
  111. package/src/content/featured-snippet.ts +0 -367
  112. package/src/content/generator.test.ts +0 -534
  113. package/src/content/generator.ts +0 -501
  114. package/src/content/headline.ts +0 -317
  115. package/src/content/index.ts +0 -62
  116. package/src/content/intent.ts +0 -258
  117. package/src/content/keyword-density.ts +0 -349
  118. package/src/content/readability.ts +0 -262
  119. package/src/executor.ts +0 -336
  120. package/src/fixer/framework-fixes.test.ts +0 -489
  121. package/src/fixer/framework-fixes.ts +0 -5287
  122. package/src/fixer/index.ts +0 -6
  123. package/src/fixer/schemas.ts +0 -971
  124. package/src/fixer.ts +0 -642
  125. package/src/frameworks/detector.test.ts +0 -248
  126. package/src/frameworks/detector.ts +0 -899
  127. package/src/frameworks/index.ts +0 -68
  128. package/src/frameworks/recipes/angular.yaml +0 -171
  129. package/src/frameworks/recipes/astro.yaml +0 -206
  130. package/src/frameworks/recipes/django.yaml +0 -180
  131. package/src/frameworks/recipes/laravel.yaml +0 -137
  132. package/src/frameworks/recipes/nextjs.yaml +0 -268
  133. package/src/frameworks/recipes/nuxt.yaml +0 -175
  134. package/src/frameworks/recipes/rails.yaml +0 -188
  135. package/src/frameworks/recipes/react.yaml +0 -202
  136. package/src/frameworks/recipes/sveltekit.yaml +0 -154
  137. package/src/frameworks/recipes/vue.yaml +0 -137
  138. package/src/frameworks/recipes/wordpress.yaml +0 -209
  139. package/src/frameworks/suggestion-engine.ts +0 -357
  140. package/src/geo/geo-content.test.ts +0 -305
  141. package/src/geo/geo-content.ts +0 -266
  142. package/src/geo/geo-history.test.ts +0 -473
  143. package/src/geo/geo-history.ts +0 -433
  144. package/src/geo/geo-tracker.test.ts +0 -359
  145. package/src/geo/geo-tracker.ts +0 -411
  146. package/src/geo/index.ts +0 -11
  147. package/src/geo/llm-citation-checker.ts +0 -188
  148. package/src/git/commit-helper.test.ts +0 -261
  149. package/src/git/commit-helper.ts +0 -329
  150. package/src/git/index.ts +0 -12
  151. package/src/git/pr-helper.test.ts +0 -284
  152. package/src/git/pr-helper.ts +0 -307
  153. package/src/index.ts +0 -76
  154. package/src/keywords/ai-keyword-engine.ts +0 -1062
  155. package/src/keywords/ai-summarizer.ts +0 -387
  156. package/src/keywords/ci-mode.ts +0 -555
  157. package/src/keywords/engine.ts +0 -359
  158. package/src/keywords/index.ts +0 -151
  159. package/src/keywords/llm-judge.ts +0 -357
  160. package/src/keywords/nlp-analysis.ts +0 -706
  161. package/src/keywords/prioritizer.ts +0 -295
  162. package/src/keywords/site-crawler.ts +0 -342
  163. package/src/keywords/sources/autocomplete.ts +0 -139
  164. package/src/keywords/sources/competitive-search.ts +0 -450
  165. package/src/keywords/sources/competitor-analysis.ts +0 -374
  166. package/src/keywords/sources/dataforseo.ts +0 -206
  167. package/src/keywords/sources/free-sources.ts +0 -294
  168. package/src/keywords/sources/gsc.ts +0 -123
  169. package/src/keywords/topic-grouping.ts +0 -327
  170. package/src/keywords/types.ts +0 -144
  171. package/src/keywords/wizard.ts +0 -457
  172. package/src/loader.ts +0 -40
  173. package/src/ranking/index.ts +0 -5
  174. package/src/ranking/serp-client.ts +0 -348
  175. package/src/ranking/tracker.ts +0 -380
  176. package/src/ranking/types.ts +0 -123
  177. package/src/reports/index.ts +0 -7
  178. package/src/reports/report-generator.test.ts +0 -293
  179. package/src/reports/report-generator.ts +0 -713
  180. package/src/scheduler/alerts.test.ts +0 -458
  181. package/src/scheduler/alerts.ts +0 -328
  182. package/src/scheduler/index.ts +0 -8
  183. package/src/scheduler/scheduled-audit.test.ts +0 -377
  184. package/src/scheduler/scheduled-audit.ts +0 -149
  185. package/src/test/integration-test.ts +0 -325
  186. package/src/tools/analyzer.ts +0 -373
  187. package/src/tools/crawl.ts +0 -293
  188. package/src/tools/files.ts +0 -301
  189. package/src/tools/h1-fixer.ts +0 -249
  190. package/src/tools/index.ts +0 -67
  191. package/src/tracking/github-action.ts +0 -326
  192. package/src/tracking/google-analytics.ts +0 -265
  193. package/src/tracking/index.ts +0 -45
  194. package/src/tracking/report-generator.ts +0 -386
  195. package/src/tracking/search-console.ts +0 -335
  196. package/src/types.ts +0 -148
  197. package/src/utils/http.ts +0 -302
  198. package/src/wasm-adapter.ts +0 -297
  199. package/src/wasm-entry.ts +0 -14
  200. package/tsconfig.json +0 -17
  201. package/tsup.wasm.config.ts +0 -26
  202. package/vitest.config.ts +0 -15
@@ -1,899 +0,0 @@
1
- /**
2
- * Framework Detection
3
- *
4
- * Detects web frameworks from:
5
- * 1. HTML signatures (data attributes, meta tags, scripts)
6
- * 2. package.json / Gemfile / requirements.txt / composer.json / etc.
7
- * 3. File structure patterns
8
- * 4. HTTP response headers
9
- *
10
- * Supports 25+ frameworks across JavaScript, Ruby, Python, PHP, Java, C#, Go, and Elixir.
11
- */
12
-
13
- export type Framework =
14
- // JavaScript/TypeScript
15
- | 'react'
16
- | 'nextjs'
17
- | 'vue'
18
- | 'nuxt'
19
- | 'angular'
20
- | 'svelte'
21
- | 'sveltekit'
22
- | 'astro'
23
- | 'remix'
24
- | 'gatsby'
25
- | 'solidjs'
26
- | 'qwik'
27
- | 'fresh'
28
- // Ruby
29
- | 'rails'
30
- // Python
31
- | 'django'
32
- | 'flask'
33
- | 'fastapi'
34
- // PHP
35
- | 'laravel'
36
- | 'symfony'
37
- | 'wordpress'
38
- // Java
39
- | 'spring'
40
- // C#
41
- | 'aspnet'
42
- // Go
43
- | 'go'
44
- // Elixir
45
- | 'phoenix'
46
- // Hypermedia
47
- | 'htmx'
48
- | 'hotwire'
49
- // Static Site Generators
50
- | 'hugo'
51
- | 'jekyll'
52
- | 'eleventy'
53
- | 'pelican'
54
- // Unknown
55
- | 'unknown';
56
-
57
- export type Language = 'javascript' | 'typescript' | 'ruby' | 'python' | 'php' | 'java' | 'csharp' | 'go' | 'elixir' | 'rust' | 'unknown';
58
-
59
- export interface FrameworkInfo {
60
- framework: Framework;
61
- version?: string;
62
- language: Language;
63
- confidence: 'high' | 'medium' | 'low';
64
- detected_from: 'html' | 'package.json' | 'files' | 'headers' | 'gemfile' | 'requirements' | 'composer' | 'pom' | 'csproj' | 'go.mod' | 'mix.exs';
65
- meta_framework?: Framework; // e.g., Next.js for React
66
- }
67
-
68
- interface HtmlSignature {
69
- framework: Framework;
70
- language: Language;
71
- patterns: RegExp[];
72
- confidence: 'high' | 'medium' | 'low';
73
- }
74
-
75
- const HTML_SIGNATURES: HtmlSignature[] = [
76
- // ============ JavaScript/TypeScript Frameworks ============
77
-
78
- // Next.js
79
- {
80
- framework: 'nextjs',
81
- language: 'typescript',
82
- patterns: [/__next/, /_next\//, /data-nscript/, /__NEXT_DATA__/, /next\/script/],
83
- confidence: 'high',
84
- },
85
- // Nuxt
86
- {
87
- framework: 'nuxt',
88
- language: 'typescript',
89
- patterns: [/__nuxt/, /_nuxt\//, /data-n-head/, /nuxt-link/, /__NUXT__/],
90
- confidence: 'high',
91
- },
92
- // Gatsby
93
- {
94
- framework: 'gatsby',
95
- language: 'javascript',
96
- patterns: [/___gatsby/, /gatsby-/, /gatsby-image/, /data-gatsby/],
97
- confidence: 'high',
98
- },
99
- // Astro
100
- {
101
- framework: 'astro',
102
- language: 'typescript',
103
- patterns: [/astro-/, /data-astro/, /_astro\//],
104
- confidence: 'high',
105
- },
106
- // SvelteKit
107
- {
108
- framework: 'sveltekit',
109
- language: 'typescript',
110
- patterns: [/__sveltekit/, /_app\/immutable/, /svelte-kit/],
111
- confidence: 'high',
112
- },
113
- // Svelte (standalone)
114
- {
115
- framework: 'svelte',
116
- language: 'javascript',
117
- patterns: [/svelte-\w+/, /__svelte/],
118
- confidence: 'medium',
119
- },
120
- // Remix
121
- {
122
- framework: 'remix',
123
- language: 'typescript',
124
- patterns: [/__remix/, /remix-/, /data-remix/],
125
- confidence: 'high',
126
- },
127
- // Solid.js
128
- {
129
- framework: 'solidjs',
130
- language: 'typescript',
131
- patterns: [/solid-/, /data-solid/, /_solid/],
132
- confidence: 'high',
133
- },
134
- // Qwik
135
- {
136
- framework: 'qwik',
137
- language: 'typescript',
138
- patterns: [/q:/, /qwik/, /q-/],
139
- confidence: 'high',
140
- },
141
- // Fresh (Deno)
142
- {
143
- framework: 'fresh',
144
- language: 'typescript',
145
- patterns: [/fresh-/, /_frsh\//, /data-fresh/],
146
- confidence: 'high',
147
- },
148
- // React (generic - lower priority)
149
- {
150
- framework: 'react',
151
- language: 'javascript',
152
- patterns: [/data-reactroot/, /data-react-helmet/, /_react/, /react-app/],
153
- confidence: 'medium',
154
- },
155
- // Vue (generic - lower priority)
156
- {
157
- framework: 'vue',
158
- language: 'javascript',
159
- patterns: [/data-v-[a-f0-9]+/, /v-cloak/, /__vue/],
160
- confidence: 'medium',
161
- },
162
- // Angular
163
- {
164
- framework: 'angular',
165
- language: 'typescript',
166
- patterns: [/ng-version/, /_ngcontent/, /ng-\w+=/, /\[ng/],
167
- confidence: 'high',
168
- },
169
-
170
- // ============ Hypermedia Frameworks ============
171
-
172
- // HTMX
173
- {
174
- framework: 'htmx',
175
- language: 'unknown',
176
- patterns: [/hx-get/, /hx-post/, /hx-trigger/, /hx-swap/, /htmx\.org/],
177
- confidence: 'high',
178
- },
179
- // Hotwire/Turbo
180
- {
181
- framework: 'hotwire',
182
- language: 'ruby',
183
- patterns: [/turbo-frame/, /turbo-stream/, /data-turbo/, /stimulus/],
184
- confidence: 'high',
185
- },
186
-
187
- // ============ PHP Frameworks ============
188
-
189
- // WordPress
190
- {
191
- framework: 'wordpress',
192
- language: 'php',
193
- patterns: [/wp-content/, /wp-includes/, /wp-json/, /wordpress/i],
194
- confidence: 'high',
195
- },
196
- // Laravel
197
- {
198
- framework: 'laravel',
199
- language: 'php',
200
- patterns: [/laravel_session/, /XSRF-TOKEN/, /@csrf/, /laravel/i],
201
- confidence: 'medium',
202
- },
203
- // Symfony
204
- {
205
- framework: 'symfony',
206
- language: 'php',
207
- patterns: [/symfony/, /sf2/, /_sf_/, /profiler\.css/],
208
- confidence: 'medium',
209
- },
210
-
211
- // ============ Ruby Frameworks ============
212
-
213
- // Rails
214
- {
215
- framework: 'rails',
216
- language: 'ruby',
217
- patterns: [/csrf-token/, /turbolinks/, /data-turbo/, /rails-ujs/, /action-cable/],
218
- confidence: 'medium',
219
- },
220
-
221
- // ============ Python Frameworks ============
222
-
223
- // Django
224
- {
225
- framework: 'django',
226
- language: 'python',
227
- patterns: [/csrfmiddlewaretoken/, /django/, /__debug__\//],
228
- confidence: 'medium',
229
- },
230
- // Flask
231
- {
232
- framework: 'flask',
233
- language: 'python',
234
- patterns: [/flask/, /werkzeug/i],
235
- confidence: 'low',
236
- },
237
- // FastAPI
238
- {
239
- framework: 'fastapi',
240
- language: 'python',
241
- patterns: [/fastapi/, /openapi\.json/],
242
- confidence: 'low',
243
- },
244
-
245
- // ============ Java Frameworks ============
246
-
247
- // Spring Boot
248
- {
249
- framework: 'spring',
250
- language: 'java',
251
- patterns: [/spring/, /thymeleaf/, /th:/, /_csrf/],
252
- confidence: 'medium',
253
- },
254
-
255
- // ============ C# Frameworks ============
256
-
257
- // ASP.NET Core
258
- {
259
- framework: 'aspnet',
260
- language: 'csharp',
261
- patterns: [/aspnetcore/, /__RequestVerificationToken/, /blazor/, /_framework\/blazor/],
262
- confidence: 'medium',
263
- },
264
-
265
- // ============ Elixir Frameworks ============
266
-
267
- // Phoenix
268
- {
269
- framework: 'phoenix',
270
- language: 'elixir',
271
- patterns: [/phx-/, /phoenix/, /live-socket/, /data-phx/],
272
- confidence: 'high',
273
- },
274
-
275
- // ============ Static Site Generators ============
276
-
277
- // Hugo
278
- {
279
- framework: 'hugo',
280
- language: 'go',
281
- patterns: [/hugo/, /generator.*hugo/i],
282
- confidence: 'medium',
283
- },
284
- // Jekyll
285
- {
286
- framework: 'jekyll',
287
- language: 'ruby',
288
- patterns: [/jekyll/, /generator.*jekyll/i],
289
- confidence: 'medium',
290
- },
291
- // Eleventy
292
- {
293
- framework: 'eleventy',
294
- language: 'javascript',
295
- patterns: [/11ty/, /eleventy/, /generator.*eleventy/i],
296
- confidence: 'medium',
297
- },
298
- // Pelican
299
- {
300
- framework: 'pelican',
301
- language: 'python',
302
- patterns: [/pelican/, /generator.*pelican/i],
303
- confidence: 'medium',
304
- },
305
- ];
306
-
307
- interface PackageDependency {
308
- framework: Framework;
309
- language: Language;
310
- packages: string[];
311
- meta_framework?: Framework;
312
- }
313
-
314
- // NPM package.json dependencies
315
- const PACKAGE_DEPENDENCIES: PackageDependency[] = [
316
- // Meta-frameworks (check first - more specific)
317
- { framework: 'nextjs', language: 'typescript', packages: ['next'], meta_framework: 'react' },
318
- { framework: 'gatsby', language: 'javascript', packages: ['gatsby'], meta_framework: 'react' },
319
- { framework: 'remix', language: 'typescript', packages: ['@remix-run/react', '@remix-run/node'], meta_framework: 'react' },
320
- { framework: 'nuxt', language: 'typescript', packages: ['nuxt', 'nuxt3'], meta_framework: 'vue' },
321
- { framework: 'sveltekit', language: 'typescript', packages: ['@sveltejs/kit'], meta_framework: 'svelte' },
322
- { framework: 'astro', language: 'typescript', packages: ['astro'] },
323
- { framework: 'solidjs', language: 'typescript', packages: ['solid-js', 'solid-start'] },
324
- { framework: 'qwik', language: 'typescript', packages: ['@builder.io/qwik'] },
325
- { framework: 'eleventy', language: 'javascript', packages: ['@11ty/eleventy'] },
326
-
327
- // Base frameworks
328
- { framework: 'react', language: 'javascript', packages: ['react', 'react-dom'] },
329
- { framework: 'vue', language: 'javascript', packages: ['vue'] },
330
- { framework: 'angular', language: 'typescript', packages: ['@angular/core'] },
331
- { framework: 'svelte', language: 'javascript', packages: ['svelte'] },
332
-
333
- // HTMX (can be used with any backend)
334
- { framework: 'htmx', language: 'unknown', packages: ['htmx.org'] },
335
- ];
336
-
337
- // Ruby Gemfile dependencies
338
- const GEMFILE_DEPENDENCIES: PackageDependency[] = [
339
- { framework: 'rails', language: 'ruby', packages: ['rails'] },
340
- { framework: 'hotwire', language: 'ruby', packages: ['turbo-rails', 'stimulus-rails'], meta_framework: 'rails' },
341
- { framework: 'jekyll', language: 'ruby', packages: ['jekyll'] },
342
- ];
343
-
344
- // Python requirements.txt / pyproject.toml dependencies
345
- const PYTHON_DEPENDENCIES: PackageDependency[] = [
346
- { framework: 'django', language: 'python', packages: ['django', 'Django'] },
347
- { framework: 'flask', language: 'python', packages: ['flask', 'Flask'] },
348
- { framework: 'fastapi', language: 'python', packages: ['fastapi', 'FastAPI'] },
349
- { framework: 'pelican', language: 'python', packages: ['pelican', 'Pelican'] },
350
- ];
351
-
352
- // PHP composer.json dependencies
353
- const COMPOSER_DEPENDENCIES: PackageDependency[] = [
354
- { framework: 'laravel', language: 'php', packages: ['laravel/framework'] },
355
- { framework: 'symfony', language: 'php', packages: ['symfony/framework-bundle', 'symfony/symfony'] },
356
- { framework: 'wordpress', language: 'php', packages: ['johnpbloch/wordpress-core'] },
357
- ];
358
-
359
- // Java pom.xml / build.gradle dependencies
360
- const JAVA_DEPENDENCIES: PackageDependency[] = [
361
- { framework: 'spring', language: 'java', packages: ['spring-boot-starter-web', 'org.springframework.boot'] },
362
- ];
363
-
364
- // C# .csproj dependencies
365
- const DOTNET_DEPENDENCIES: PackageDependency[] = [
366
- { framework: 'aspnet', language: 'csharp', packages: ['Microsoft.AspNetCore', 'Microsoft.NET.Sdk.Web'] },
367
- ];
368
-
369
- // Go go.mod dependencies
370
- const GO_DEPENDENCIES: PackageDependency[] = [
371
- { framework: 'hugo', language: 'go', packages: ['github.com/gohugoio/hugo'] },
372
- { framework: 'go', language: 'go', packages: ['github.com/gin-gonic/gin', 'github.com/labstack/echo', 'github.com/gofiber/fiber'] },
373
- ];
374
-
375
- // Elixir mix.exs dependencies
376
- const ELIXIR_DEPENDENCIES: PackageDependency[] = [
377
- { framework: 'phoenix', language: 'elixir', packages: [':phoenix', 'phoenix'] },
378
- ];
379
-
380
- /**
381
- * Detect framework from HTML content
382
- */
383
- export function detectFromHtml(html: string): FrameworkInfo | null {
384
- for (const signature of HTML_SIGNATURES) {
385
- for (const pattern of signature.patterns) {
386
- if (pattern.test(html)) {
387
- return {
388
- framework: signature.framework,
389
- language: signature.language,
390
- confidence: signature.confidence,
391
- detected_from: 'html',
392
- };
393
- }
394
- }
395
- }
396
- return null;
397
- }
398
-
399
- /**
400
- * Detect framework from package.json content (JavaScript/TypeScript)
401
- */
402
- export function detectFromPackageJson(packageJson: {
403
- dependencies?: Record<string, string>;
404
- devDependencies?: Record<string, string>;
405
- }): FrameworkInfo | null {
406
- const allDeps = {
407
- ...packageJson.dependencies,
408
- ...packageJson.devDependencies,
409
- };
410
-
411
- for (const dep of PACKAGE_DEPENDENCIES) {
412
- for (const pkg of dep.packages) {
413
- if (allDeps[pkg]) {
414
- return {
415
- framework: dep.framework,
416
- language: dep.language,
417
- version: allDeps[pkg],
418
- confidence: 'high',
419
- detected_from: 'package.json',
420
- meta_framework: dep.meta_framework,
421
- };
422
- }
423
- }
424
- }
425
-
426
- return null;
427
- }
428
-
429
- /**
430
- * Detect framework from Gemfile content (Ruby)
431
- */
432
- export function detectFromGemfile(gemfileContent: string): FrameworkInfo | null {
433
- const gemPattern = /gem\s+['"]([^'"]+)['"]/g;
434
- const gems: string[] = [];
435
- let match;
436
-
437
- while ((match = gemPattern.exec(gemfileContent)) !== null) {
438
- gems.push(match[1]);
439
- }
440
-
441
- for (const dep of GEMFILE_DEPENDENCIES) {
442
- for (const pkg of dep.packages) {
443
- if (gems.includes(pkg)) {
444
- return {
445
- framework: dep.framework,
446
- language: dep.language,
447
- confidence: 'high',
448
- detected_from: 'gemfile',
449
- meta_framework: dep.meta_framework,
450
- };
451
- }
452
- }
453
- }
454
-
455
- return null;
456
- }
457
-
458
- /**
459
- * Detect framework from requirements.txt or pyproject.toml (Python)
460
- */
461
- export function detectFromPythonDeps(content: string): FrameworkInfo | null {
462
- for (const dep of PYTHON_DEPENDENCIES) {
463
- for (const pkg of dep.packages) {
464
- // Match package name at start of line or after whitespace, ignoring version specs
465
- const pattern = new RegExp(`(^|\\s)${pkg.toLowerCase()}[\\s=<>~!]`, 'im');
466
- if (pattern.test(content.toLowerCase())) {
467
- return {
468
- framework: dep.framework,
469
- language: dep.language,
470
- confidence: 'high',
471
- detected_from: 'requirements',
472
- };
473
- }
474
- }
475
- }
476
-
477
- return null;
478
- }
479
-
480
- /**
481
- * Detect framework from composer.json (PHP)
482
- */
483
- export function detectFromComposerJson(composerJson: {
484
- require?: Record<string, string>;
485
- 'require-dev'?: Record<string, string>;
486
- }): FrameworkInfo | null {
487
- const allDeps = {
488
- ...composerJson.require,
489
- ...composerJson['require-dev'],
490
- };
491
-
492
- for (const dep of COMPOSER_DEPENDENCIES) {
493
- for (const pkg of dep.packages) {
494
- if (allDeps[pkg]) {
495
- return {
496
- framework: dep.framework,
497
- language: dep.language,
498
- version: allDeps[pkg],
499
- confidence: 'high',
500
- detected_from: 'composer',
501
- };
502
- }
503
- }
504
- }
505
-
506
- return null;
507
- }
508
-
509
- /**
510
- * Detect framework from pom.xml content (Java/Maven)
511
- */
512
- export function detectFromPomXml(pomContent: string): FrameworkInfo | null {
513
- for (const dep of JAVA_DEPENDENCIES) {
514
- for (const pkg of dep.packages) {
515
- if (pomContent.includes(pkg)) {
516
- return {
517
- framework: dep.framework,
518
- language: dep.language,
519
- confidence: 'high',
520
- detected_from: 'pom',
521
- };
522
- }
523
- }
524
- }
525
-
526
- return null;
527
- }
528
-
529
- /**
530
- * Detect framework from .csproj content (C#/.NET)
531
- */
532
- export function detectFromCsproj(csprojContent: string): FrameworkInfo | null {
533
- for (const dep of DOTNET_DEPENDENCIES) {
534
- for (const pkg of dep.packages) {
535
- if (csprojContent.includes(pkg)) {
536
- return {
537
- framework: dep.framework,
538
- language: dep.language,
539
- confidence: 'high',
540
- detected_from: 'csproj',
541
- };
542
- }
543
- }
544
- }
545
-
546
- return null;
547
- }
548
-
549
- /**
550
- * Detect framework from go.mod content (Go)
551
- */
552
- export function detectFromGoMod(goModContent: string): FrameworkInfo | null {
553
- for (const dep of GO_DEPENDENCIES) {
554
- for (const pkg of dep.packages) {
555
- if (goModContent.includes(pkg)) {
556
- return {
557
- framework: dep.framework,
558
- language: dep.language,
559
- confidence: 'high',
560
- detected_from: 'go.mod',
561
- };
562
- }
563
- }
564
- }
565
-
566
- return null;
567
- }
568
-
569
- /**
570
- * Detect framework from mix.exs content (Elixir)
571
- */
572
- export function detectFromMixExs(mixContent: string): FrameworkInfo | null {
573
- for (const dep of ELIXIR_DEPENDENCIES) {
574
- for (const pkg of dep.packages) {
575
- if (mixContent.includes(pkg)) {
576
- return {
577
- framework: dep.framework,
578
- language: dep.language,
579
- confidence: 'high',
580
- detected_from: 'mix.exs',
581
- };
582
- }
583
- }
584
- }
585
-
586
- return null;
587
- }
588
-
589
- /**
590
- * Detect framework from HTTP response headers
591
- */
592
- export function detectFromHeaders(headers: Record<string, string>): FrameworkInfo | null {
593
- const poweredBy = headers['x-powered-by']?.toLowerCase() || '';
594
- const server = headers['server']?.toLowerCase() || '';
595
- const generator = headers['x-generator']?.toLowerCase() || '';
596
-
597
- // JavaScript/TypeScript
598
- if (poweredBy.includes('next.js') || poweredBy.includes('next')) {
599
- return { framework: 'nextjs', language: 'typescript', confidence: 'high', detected_from: 'headers' };
600
- }
601
- if (poweredBy.includes('nuxt')) {
602
- return { framework: 'nuxt', language: 'typescript', confidence: 'high', detected_from: 'headers' };
603
- }
604
- if (poweredBy.includes('remix')) {
605
- return { framework: 'remix', language: 'typescript', confidence: 'high', detected_from: 'headers' };
606
- }
607
-
608
- // Ruby
609
- if (poweredBy.includes('phusion') || poweredBy.includes('passenger') || poweredBy.includes('puma') || poweredBy.includes('unicorn')) {
610
- return { framework: 'rails', language: 'ruby', confidence: 'medium', detected_from: 'headers' };
611
- }
612
-
613
- // Python
614
- if (poweredBy.includes('gunicorn') || poweredBy.includes('uvicorn') || poweredBy.includes('daphne')) {
615
- // Python but unclear which framework - needs HTML detection
616
- return null;
617
- }
618
-
619
- // PHP
620
- if (poweredBy.includes('php')) {
621
- // Could be WordPress, Laravel, or Symfony - needs HTML detection
622
- return null;
623
- }
624
-
625
- // Java
626
- if (server.includes('tomcat') || server.includes('jetty') || poweredBy.includes('spring')) {
627
- return { framework: 'spring', language: 'java', confidence: 'medium', detected_from: 'headers' };
628
- }
629
-
630
- // .NET
631
- if (poweredBy.includes('asp.net') || server.includes('kestrel')) {
632
- return { framework: 'aspnet', language: 'csharp', confidence: 'high', detected_from: 'headers' };
633
- }
634
-
635
- // Elixir
636
- if (poweredBy.includes('phoenix') || poweredBy.includes('cowboy')) {
637
- return { framework: 'phoenix', language: 'elixir', confidence: 'medium', detected_from: 'headers' };
638
- }
639
-
640
- // Go
641
- if (server.includes('gin') || server.includes('echo') || server.includes('fiber')) {
642
- return { framework: 'go', language: 'go', confidence: 'medium', detected_from: 'headers' };
643
- }
644
-
645
- // Static site generators (from generator meta/header)
646
- if (generator.includes('hugo')) {
647
- return { framework: 'hugo', language: 'go', confidence: 'high', detected_from: 'headers' };
648
- }
649
- if (generator.includes('jekyll')) {
650
- return { framework: 'jekyll', language: 'ruby', confidence: 'high', detected_from: 'headers' };
651
- }
652
- if (generator.includes('eleventy') || generator.includes('11ty')) {
653
- return { framework: 'eleventy', language: 'javascript', confidence: 'high', detected_from: 'headers' };
654
- }
655
- if (generator.includes('pelican')) {
656
- return { framework: 'pelican', language: 'python', confidence: 'high', detected_from: 'headers' };
657
- }
658
-
659
- return null;
660
- }
661
-
662
- /**
663
- * Combined detection using multiple sources
664
- */
665
- export function detectFramework(options: {
666
- html?: string;
667
- packageJson?: { dependencies?: Record<string, string>; devDependencies?: Record<string, string> };
668
- composerJson?: { require?: Record<string, string>; 'require-dev'?: Record<string, string> };
669
- gemfileContent?: string;
670
- requirementsContent?: string;
671
- pomXmlContent?: string;
672
- csprojContent?: string;
673
- goModContent?: string;
674
- mixExsContent?: string;
675
- headers?: Record<string, string>;
676
- files?: string[];
677
- }): FrameworkInfo {
678
- // Try dependency files first (most reliable)
679
-
680
- // JavaScript/TypeScript
681
- if (options.packageJson) {
682
- const result = detectFromPackageJson(options.packageJson);
683
- if (result) return result;
684
- }
685
-
686
- // Ruby
687
- if (options.gemfileContent) {
688
- const result = detectFromGemfile(options.gemfileContent);
689
- if (result) return result;
690
- }
691
-
692
- // Python
693
- if (options.requirementsContent) {
694
- const result = detectFromPythonDeps(options.requirementsContent);
695
- if (result) return result;
696
- }
697
-
698
- // PHP
699
- if (options.composerJson) {
700
- const result = detectFromComposerJson(options.composerJson);
701
- if (result) return result;
702
- }
703
-
704
- // Java
705
- if (options.pomXmlContent) {
706
- const result = detectFromPomXml(options.pomXmlContent);
707
- if (result) return result;
708
- }
709
-
710
- // C#
711
- if (options.csprojContent) {
712
- const result = detectFromCsproj(options.csprojContent);
713
- if (result) return result;
714
- }
715
-
716
- // Go
717
- if (options.goModContent) {
718
- const result = detectFromGoMod(options.goModContent);
719
- if (result) return result;
720
- }
721
-
722
- // Elixir
723
- if (options.mixExsContent) {
724
- const result = detectFromMixExs(options.mixExsContent);
725
- if (result) return result;
726
- }
727
-
728
- // Try headers
729
- if (options.headers) {
730
- const result = detectFromHeaders(options.headers);
731
- if (result) return result;
732
- }
733
-
734
- // Try HTML signatures
735
- if (options.html) {
736
- const result = detectFromHtml(options.html);
737
- if (result) return result;
738
- }
739
-
740
- // Check file patterns
741
- if (options.files) {
742
- // JavaScript/TypeScript
743
- if (options.files.some(f => f.includes('next.config'))) {
744
- return { framework: 'nextjs', language: 'typescript', confidence: 'high', detected_from: 'files' };
745
- }
746
- if (options.files.some(f => f.includes('nuxt.config'))) {
747
- return { framework: 'nuxt', language: 'typescript', confidence: 'high', detected_from: 'files' };
748
- }
749
- if (options.files.some(f => f.includes('astro.config'))) {
750
- return { framework: 'astro', language: 'typescript', confidence: 'high', detected_from: 'files' };
751
- }
752
- if (options.files.some(f => f.includes('svelte.config'))) {
753
- return { framework: 'sveltekit', language: 'typescript', confidence: 'high', detected_from: 'files' };
754
- }
755
- if (options.files.some(f => f.includes('angular.json'))) {
756
- return { framework: 'angular', language: 'typescript', confidence: 'high', detected_from: 'files' };
757
- }
758
- if (options.files.some(f => f.includes('gatsby-config'))) {
759
- return { framework: 'gatsby', language: 'javascript', confidence: 'high', detected_from: 'files' };
760
- }
761
- if (options.files.some(f => f.includes('remix.config'))) {
762
- return { framework: 'remix', language: 'typescript', confidence: 'high', detected_from: 'files' };
763
- }
764
- if (options.files.some(f => f.includes('.eleventy.js') || f.includes('eleventy.config'))) {
765
- return { framework: 'eleventy', language: 'javascript', confidence: 'high', detected_from: 'files' };
766
- }
767
-
768
- // PHP
769
- if (options.files.some(f => f === 'wp-config.php')) {
770
- return { framework: 'wordpress', language: 'php', confidence: 'high', detected_from: 'files' };
771
- }
772
- if (options.files.some(f => f === 'artisan')) {
773
- return { framework: 'laravel', language: 'php', confidence: 'high', detected_from: 'files' };
774
- }
775
- if (options.files.some(f => f.includes('symfony.lock') || f.includes('config/bundles.php'))) {
776
- return { framework: 'symfony', language: 'php', confidence: 'high', detected_from: 'files' };
777
- }
778
-
779
- // Python
780
- if (options.files.some(f => f === 'manage.py')) {
781
- return { framework: 'django', language: 'python', confidence: 'high', detected_from: 'files' };
782
- }
783
- if (options.files.some(f => f.includes('pelicanconf.py'))) {
784
- return { framework: 'pelican', language: 'python', confidence: 'high', detected_from: 'files' };
785
- }
786
-
787
- // Ruby
788
- if (options.files.some(f => f === 'Gemfile') && options.files.some(f => f.includes('config/routes.rb'))) {
789
- return { framework: 'rails', language: 'ruby', confidence: 'high', detected_from: 'files' };
790
- }
791
- if (options.files.some(f => f === '_config.yml') && options.files.some(f => f === 'Gemfile')) {
792
- return { framework: 'jekyll', language: 'ruby', confidence: 'high', detected_from: 'files' };
793
- }
794
-
795
- // Go
796
- if (options.files.some(f => f.includes('hugo.toml') || f.includes('hugo.yaml') || f.includes('config.toml'))) {
797
- return { framework: 'hugo', language: 'go', confidence: 'high', detected_from: 'files' };
798
- }
799
-
800
- // Java
801
- if (options.files.some(f => f.includes('pom.xml') || f.includes('build.gradle'))) {
802
- if (options.files.some(f => f.includes('src/main/resources/application'))) {
803
- return { framework: 'spring', language: 'java', confidence: 'high', detected_from: 'files' };
804
- }
805
- }
806
-
807
- // C#
808
- if (options.files.some(f => f.endsWith('.csproj'))) {
809
- return { framework: 'aspnet', language: 'csharp', confidence: 'medium', detected_from: 'files' };
810
- }
811
-
812
- // Elixir
813
- if (options.files.some(f => f === 'mix.exs') && options.files.some(f => f.includes('lib') && f.includes('_web'))) {
814
- return { framework: 'phoenix', language: 'elixir', confidence: 'high', detected_from: 'files' };
815
- }
816
- }
817
-
818
- return { framework: 'unknown', language: 'unknown', confidence: 'low', detected_from: 'html' };
819
- }
820
-
821
- /**
822
- * Get human-readable framework name
823
- */
824
- export function getFrameworkDisplayName(framework: Framework): string {
825
- const names: Record<Framework, string> = {
826
- // JavaScript/TypeScript
827
- react: 'React',
828
- nextjs: 'Next.js',
829
- vue: 'Vue.js',
830
- nuxt: 'Nuxt',
831
- angular: 'Angular',
832
- svelte: 'Svelte',
833
- sveltekit: 'SvelteKit',
834
- astro: 'Astro',
835
- remix: 'Remix',
836
- gatsby: 'Gatsby',
837
- solidjs: 'Solid.js',
838
- qwik: 'Qwik',
839
- fresh: 'Fresh (Deno)',
840
-
841
- // Ruby
842
- rails: 'Ruby on Rails',
843
-
844
- // Python
845
- django: 'Django',
846
- flask: 'Flask',
847
- fastapi: 'FastAPI',
848
-
849
- // PHP
850
- laravel: 'Laravel',
851
- symfony: 'Symfony',
852
- wordpress: 'WordPress',
853
-
854
- // Java
855
- spring: 'Spring Boot',
856
-
857
- // C#
858
- aspnet: 'ASP.NET Core',
859
-
860
- // Go
861
- go: 'Go (Gin/Echo/Fiber)',
862
-
863
- // Elixir
864
- phoenix: 'Phoenix',
865
-
866
- // Hypermedia
867
- htmx: 'HTMX',
868
- hotwire: 'Hotwire/Turbo',
869
-
870
- // Static Site Generators
871
- hugo: 'Hugo',
872
- jekyll: 'Jekyll',
873
- eleventy: 'Eleventy (11ty)',
874
- pelican: 'Pelican',
875
-
876
- unknown: 'Unknown',
877
- };
878
- return names[framework];
879
- }
880
-
881
- /**
882
- * Get language display name
883
- */
884
- export function getLanguageDisplayName(language: Language): string {
885
- const names: Record<Language, string> = {
886
- javascript: 'JavaScript',
887
- typescript: 'TypeScript',
888
- ruby: 'Ruby',
889
- python: 'Python',
890
- php: 'PHP',
891
- java: 'Java',
892
- csharp: 'C#',
893
- go: 'Go',
894
- elixir: 'Elixir',
895
- rust: 'Rust',
896
- unknown: 'Unknown',
897
- };
898
- return names[language];
899
- }