@hyperfrontend/project-scope 0.1.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 (391) hide show
  1. package/ARCHITECTURE.md +370 -0
  2. package/CHANGELOG.md +10 -0
  3. package/FUNDING.md +141 -0
  4. package/LICENSE.md +21 -0
  5. package/README.md +242 -0
  6. package/SECURITY.md +82 -0
  7. package/analyze.d.ts +33 -0
  8. package/analyze.d.ts.map +1 -0
  9. package/cli/commands/analyze.d.ts +20 -0
  10. package/cli/commands/analyze.d.ts.map +1 -0
  11. package/cli/commands/config.d.ts +20 -0
  12. package/cli/commands/config.d.ts.map +1 -0
  13. package/cli/commands/deps.d.ts +18 -0
  14. package/cli/commands/deps.d.ts.map +1 -0
  15. package/cli/commands/tree.d.ts +24 -0
  16. package/cli/commands/tree.d.ts.map +1 -0
  17. package/cli/index.cjs.js +6639 -0
  18. package/cli/index.cjs.js.map +1 -0
  19. package/cli/index.d.ts +7 -0
  20. package/cli/index.d.ts.map +1 -0
  21. package/cli/index.esm.js +6629 -0
  22. package/cli/index.esm.js.map +1 -0
  23. package/cli/run.d.ts +25 -0
  24. package/cli/run.d.ts.map +1 -0
  25. package/cli/types.d.ts +55 -0
  26. package/cli/types.d.ts.map +1 -0
  27. package/core/cache.d.ts +157 -0
  28. package/core/cache.d.ts.map +1 -0
  29. package/core/encoding/convert.d.ts +32 -0
  30. package/core/encoding/convert.d.ts.map +1 -0
  31. package/core/encoding/detect.d.ts +86 -0
  32. package/core/encoding/detect.d.ts.map +1 -0
  33. package/core/encoding/index.cjs.js +751 -0
  34. package/core/encoding/index.cjs.js.map +1 -0
  35. package/core/encoding/index.d.ts +3 -0
  36. package/core/encoding/index.d.ts.map +1 -0
  37. package/core/encoding/index.esm.js +736 -0
  38. package/core/encoding/index.esm.js.map +1 -0
  39. package/core/errors/structured-errors.d.ts +64 -0
  40. package/core/errors/structured-errors.d.ts.map +1 -0
  41. package/core/fs/directory.d.ts +88 -0
  42. package/core/fs/directory.d.ts.map +1 -0
  43. package/core/fs/index.cjs.js +1079 -0
  44. package/core/fs/index.cjs.js.map +1 -0
  45. package/core/fs/index.d.ts +6 -0
  46. package/core/fs/index.d.ts.map +1 -0
  47. package/core/fs/index.esm.js +1056 -0
  48. package/core/fs/index.esm.js.map +1 -0
  49. package/core/fs/read.d.ts +86 -0
  50. package/core/fs/read.d.ts.map +1 -0
  51. package/core/fs/stat.d.ts +58 -0
  52. package/core/fs/stat.d.ts.map +1 -0
  53. package/core/fs/traversal.d.ts +26 -0
  54. package/core/fs/traversal.d.ts.map +1 -0
  55. package/core/fs/write.d.ts +75 -0
  56. package/core/fs/write.d.ts.map +1 -0
  57. package/core/index.cjs.js +2376 -0
  58. package/core/index.cjs.js.map +1 -0
  59. package/core/index.d.ts +9 -0
  60. package/core/index.d.ts.map +1 -0
  61. package/core/index.esm.js +2286 -0
  62. package/core/index.esm.js.map +1 -0
  63. package/core/logger.d.ts +111 -0
  64. package/core/logger.d.ts.map +1 -0
  65. package/core/path/index.cjs.js +254 -0
  66. package/core/path/index.cjs.js.map +1 -0
  67. package/core/path/index.d.ts +5 -0
  68. package/core/path/index.d.ts.map +1 -0
  69. package/core/path/index.esm.js +233 -0
  70. package/core/path/index.esm.js.map +1 -0
  71. package/core/path/join.d.ts +17 -0
  72. package/core/path/join.d.ts.map +1 -0
  73. package/core/path/normalize.d.ts +37 -0
  74. package/core/path/normalize.d.ts.map +1 -0
  75. package/core/path/resolve.d.ts +52 -0
  76. package/core/path/resolve.d.ts.map +1 -0
  77. package/core/path/segments.d.ts +59 -0
  78. package/core/path/segments.d.ts.map +1 -0
  79. package/core/patterns/glob.d.ts +46 -0
  80. package/core/patterns/glob.d.ts.map +1 -0
  81. package/core/platform/detect.d.ts +66 -0
  82. package/core/platform/detect.d.ts.map +1 -0
  83. package/core/platform/index.cjs.js +241 -0
  84. package/core/platform/index.cjs.js.map +1 -0
  85. package/core/platform/index.d.ts +3 -0
  86. package/core/platform/index.d.ts.map +1 -0
  87. package/core/platform/index.esm.js +226 -0
  88. package/core/platform/index.esm.js.map +1 -0
  89. package/core/platform/line-endings.d.ts +48 -0
  90. package/core/platform/line-endings.d.ts.map +1 -0
  91. package/heuristics/dependencies/analyze.d.ts +77 -0
  92. package/heuristics/dependencies/analyze.d.ts.map +1 -0
  93. package/heuristics/dependencies/index.cjs.js +1126 -0
  94. package/heuristics/dependencies/index.cjs.js.map +1 -0
  95. package/heuristics/dependencies/index.d.ts +2 -0
  96. package/heuristics/dependencies/index.d.ts.map +1 -0
  97. package/heuristics/dependencies/index.esm.js +1122 -0
  98. package/heuristics/dependencies/index.esm.js.map +1 -0
  99. package/heuristics/entry-points/discover.d.ts +86 -0
  100. package/heuristics/entry-points/discover.d.ts.map +1 -0
  101. package/heuristics/entry-points/index.cjs.js +1581 -0
  102. package/heuristics/entry-points/index.cjs.js.map +1 -0
  103. package/heuristics/entry-points/index.d.ts +2 -0
  104. package/heuristics/entry-points/index.d.ts.map +1 -0
  105. package/heuristics/entry-points/index.esm.js +1577 -0
  106. package/heuristics/entry-points/index.esm.js.map +1 -0
  107. package/heuristics/framework/identify.d.ts +84 -0
  108. package/heuristics/framework/identify.d.ts.map +1 -0
  109. package/heuristics/framework/index.cjs.js +3618 -0
  110. package/heuristics/framework/index.cjs.js.map +1 -0
  111. package/heuristics/framework/index.d.ts +2 -0
  112. package/heuristics/framework/index.d.ts.map +1 -0
  113. package/heuristics/framework/index.esm.js +3614 -0
  114. package/heuristics/framework/index.esm.js.map +1 -0
  115. package/heuristics/index.cjs.js +4833 -0
  116. package/heuristics/index.cjs.js.map +1 -0
  117. package/heuristics/index.d.ts +5 -0
  118. package/heuristics/index.d.ts.map +1 -0
  119. package/heuristics/index.esm.js +4822 -0
  120. package/heuristics/index.esm.js.map +1 -0
  121. package/heuristics/project-type/detect.d.ts +61 -0
  122. package/heuristics/project-type/detect.d.ts.map +1 -0
  123. package/heuristics/project-type/index.cjs.js +3633 -0
  124. package/heuristics/project-type/index.cjs.js.map +1 -0
  125. package/heuristics/project-type/index.d.ts +2 -0
  126. package/heuristics/project-type/index.d.ts.map +1 -0
  127. package/heuristics/project-type/index.esm.js +3631 -0
  128. package/heuristics/project-type/index.esm.js.map +1 -0
  129. package/index.cjs.js +10255 -0
  130. package/index.cjs.js.map +1 -0
  131. package/index.d.ts +10 -0
  132. package/index.d.ts.map +1 -0
  133. package/index.esm.js +10006 -0
  134. package/index.esm.js.map +1 -0
  135. package/models/index.cjs.js +3 -0
  136. package/models/index.cjs.js.map +1 -0
  137. package/models/index.d.ts +176 -0
  138. package/models/index.d.ts.map +1 -0
  139. package/models/index.esm.js +2 -0
  140. package/models/index.esm.js.map +1 -0
  141. package/nx/detect.d.ts +105 -0
  142. package/nx/detect.d.ts.map +1 -0
  143. package/nx/devkit-loader.d.ts +62 -0
  144. package/nx/devkit-loader.d.ts.map +1 -0
  145. package/nx/index.cjs.js +1302 -0
  146. package/nx/index.cjs.js.map +1 -0
  147. package/nx/index.d.ts +4 -0
  148. package/nx/index.d.ts.map +1 -0
  149. package/nx/index.esm.js +1286 -0
  150. package/nx/index.esm.js.map +1 -0
  151. package/nx/project-config.d.ts +109 -0
  152. package/nx/project-config.d.ts.map +1 -0
  153. package/package.json +218 -0
  154. package/project/config/detect.d.ts +77 -0
  155. package/project/config/detect.d.ts.map +1 -0
  156. package/project/config/index.cjs.js +1982 -0
  157. package/project/config/index.cjs.js.map +1 -0
  158. package/project/config/index.d.ts +4 -0
  159. package/project/config/index.d.ts.map +1 -0
  160. package/project/config/index.esm.js +1971 -0
  161. package/project/config/index.esm.js.map +1 -0
  162. package/project/config/parse.d.ts +53 -0
  163. package/project/config/parse.d.ts.map +1 -0
  164. package/project/config/patterns.d.ts +31 -0
  165. package/project/config/patterns.d.ts.map +1 -0
  166. package/project/index.cjs.js +2585 -0
  167. package/project/index.cjs.js.map +1 -0
  168. package/project/index.d.ts +5 -0
  169. package/project/index.d.ts.map +1 -0
  170. package/project/index.esm.js +2549 -0
  171. package/project/index.esm.js.map +1 -0
  172. package/project/package/dependencies.d.ts +101 -0
  173. package/project/package/dependencies.d.ts.map +1 -0
  174. package/project/package/index.cjs.js +972 -0
  175. package/project/package/index.cjs.js.map +1 -0
  176. package/project/package/index.d.ts +3 -0
  177. package/project/package/index.d.ts.map +1 -0
  178. package/project/package/index.esm.js +957 -0
  179. package/project/package/index.esm.js.map +1 -0
  180. package/project/package/read.d.ts +66 -0
  181. package/project/package/read.d.ts.map +1 -0
  182. package/project/root/detect.d.ts +65 -0
  183. package/project/root/detect.d.ts.map +1 -0
  184. package/project/root/index.cjs.js +860 -0
  185. package/project/root/index.cjs.js.map +1 -0
  186. package/project/root/index.d.ts +2 -0
  187. package/project/root/index.d.ts.map +1 -0
  188. package/project/root/index.esm.js +853 -0
  189. package/project/root/index.esm.js.map +1 -0
  190. package/project/traversal/index.cjs.js +1179 -0
  191. package/project/traversal/index.cjs.js.map +1 -0
  192. package/project/traversal/index.d.ts +3 -0
  193. package/project/traversal/index.d.ts.map +1 -0
  194. package/project/traversal/index.esm.js +1173 -0
  195. package/project/traversal/index.esm.js.map +1 -0
  196. package/project/traversal/search.d.ts +59 -0
  197. package/project/traversal/search.d.ts.map +1 -0
  198. package/project/traversal/walk.d.ts +63 -0
  199. package/project/traversal/walk.d.ts.map +1 -0
  200. package/tech/backend/detect-all.d.ts +13 -0
  201. package/tech/backend/detect-all.d.ts.map +1 -0
  202. package/tech/backend/express.d.ts +11 -0
  203. package/tech/backend/express.d.ts.map +1 -0
  204. package/tech/backend/fastify.d.ts +11 -0
  205. package/tech/backend/fastify.d.ts.map +1 -0
  206. package/tech/backend/hono.d.ts +11 -0
  207. package/tech/backend/hono.d.ts.map +1 -0
  208. package/tech/backend/index.cjs.js +939 -0
  209. package/tech/backend/index.cjs.js.map +1 -0
  210. package/tech/backend/index.d.ts +8 -0
  211. package/tech/backend/index.d.ts.map +1 -0
  212. package/tech/backend/index.esm.js +931 -0
  213. package/tech/backend/index.esm.js.map +1 -0
  214. package/tech/backend/koa.d.ts +11 -0
  215. package/tech/backend/koa.d.ts.map +1 -0
  216. package/tech/backend/nestjs.d.ts +11 -0
  217. package/tech/backend/nestjs.d.ts.map +1 -0
  218. package/tech/backend/types.d.ts +31 -0
  219. package/tech/backend/types.d.ts.map +1 -0
  220. package/tech/build/babel.d.ts +13 -0
  221. package/tech/build/babel.d.ts.map +1 -0
  222. package/tech/build/detect-all.d.ts +13 -0
  223. package/tech/build/detect-all.d.ts.map +1 -0
  224. package/tech/build/esbuild.d.ts +11 -0
  225. package/tech/build/esbuild.d.ts.map +1 -0
  226. package/tech/build/index.cjs.js +1118 -0
  227. package/tech/build/index.cjs.js.map +1 -0
  228. package/tech/build/index.d.ts +10 -0
  229. package/tech/build/index.d.ts.map +1 -0
  230. package/tech/build/index.esm.js +1102 -0
  231. package/tech/build/index.esm.js.map +1 -0
  232. package/tech/build/parcel.d.ts +13 -0
  233. package/tech/build/parcel.d.ts.map +1 -0
  234. package/tech/build/rollup.d.ts +13 -0
  235. package/tech/build/rollup.d.ts.map +1 -0
  236. package/tech/build/swc.d.ts +13 -0
  237. package/tech/build/swc.d.ts.map +1 -0
  238. package/tech/build/types.d.ts +31 -0
  239. package/tech/build/types.d.ts.map +1 -0
  240. package/tech/build/vite.d.ts +13 -0
  241. package/tech/build/vite.d.ts.map +1 -0
  242. package/tech/build/webpack.d.ts +13 -0
  243. package/tech/build/webpack.d.ts.map +1 -0
  244. package/tech/frontend/angular.d.ts +11 -0
  245. package/tech/frontend/angular.d.ts.map +1 -0
  246. package/tech/frontend/astro.d.ts +11 -0
  247. package/tech/frontend/astro.d.ts.map +1 -0
  248. package/tech/frontend/detect-all.d.ts +13 -0
  249. package/tech/frontend/detect-all.d.ts.map +1 -0
  250. package/tech/frontend/gatsby.d.ts +11 -0
  251. package/tech/frontend/gatsby.d.ts.map +1 -0
  252. package/tech/frontend/index.cjs.js +1310 -0
  253. package/tech/frontend/index.cjs.js.map +1 -0
  254. package/tech/frontend/index.d.ts +15 -0
  255. package/tech/frontend/index.d.ts.map +1 -0
  256. package/tech/frontend/index.esm.js +1295 -0
  257. package/tech/frontend/index.esm.js.map +1 -0
  258. package/tech/frontend/nextjs.d.ts +11 -0
  259. package/tech/frontend/nextjs.d.ts.map +1 -0
  260. package/tech/frontend/nuxt.d.ts +11 -0
  261. package/tech/frontend/nuxt.d.ts.map +1 -0
  262. package/tech/frontend/qwik.d.ts +11 -0
  263. package/tech/frontend/qwik.d.ts.map +1 -0
  264. package/tech/frontend/react.d.ts +11 -0
  265. package/tech/frontend/react.d.ts.map +1 -0
  266. package/tech/frontend/remix.d.ts +11 -0
  267. package/tech/frontend/remix.d.ts.map +1 -0
  268. package/tech/frontend/solid.d.ts +11 -0
  269. package/tech/frontend/solid.d.ts.map +1 -0
  270. package/tech/frontend/svelte.d.ts +11 -0
  271. package/tech/frontend/svelte.d.ts.map +1 -0
  272. package/tech/frontend/sveltekit.d.ts +11 -0
  273. package/tech/frontend/sveltekit.d.ts.map +1 -0
  274. package/tech/frontend/types.d.ts +35 -0
  275. package/tech/frontend/types.d.ts.map +1 -0
  276. package/tech/frontend/vue.d.ts +11 -0
  277. package/tech/frontend/vue.d.ts.map +1 -0
  278. package/tech/index.cjs.js +3684 -0
  279. package/tech/index.cjs.js.map +1 -0
  280. package/tech/index.d.ts +96 -0
  281. package/tech/index.d.ts.map +1 -0
  282. package/tech/index.esm.js +3603 -0
  283. package/tech/index.esm.js.map +1 -0
  284. package/tech/legacy/angularjs.d.ts +12 -0
  285. package/tech/legacy/angularjs.d.ts.map +1 -0
  286. package/tech/legacy/backbone.d.ts +11 -0
  287. package/tech/legacy/backbone.d.ts.map +1 -0
  288. package/tech/legacy/detect-all.d.ts +13 -0
  289. package/tech/legacy/detect-all.d.ts.map +1 -0
  290. package/tech/legacy/ember.d.ts +11 -0
  291. package/tech/legacy/ember.d.ts.map +1 -0
  292. package/tech/legacy/index.cjs.js +903 -0
  293. package/tech/legacy/index.cjs.js.map +1 -0
  294. package/tech/legacy/index.d.ts +7 -0
  295. package/tech/legacy/index.d.ts.map +1 -0
  296. package/tech/legacy/index.esm.js +896 -0
  297. package/tech/legacy/index.esm.js.map +1 -0
  298. package/tech/legacy/jquery.d.ts +11 -0
  299. package/tech/legacy/jquery.d.ts.map +1 -0
  300. package/tech/legacy/types.d.ts +33 -0
  301. package/tech/legacy/types.d.ts.map +1 -0
  302. package/tech/linting/biome.d.ts +11 -0
  303. package/tech/linting/biome.d.ts.map +1 -0
  304. package/tech/linting/detect-all.d.ts +13 -0
  305. package/tech/linting/detect-all.d.ts.map +1 -0
  306. package/tech/linting/eslint.d.ts +13 -0
  307. package/tech/linting/eslint.d.ts.map +1 -0
  308. package/tech/linting/index.cjs.js +992 -0
  309. package/tech/linting/index.cjs.js.map +1 -0
  310. package/tech/linting/index.d.ts +7 -0
  311. package/tech/linting/index.d.ts.map +1 -0
  312. package/tech/linting/index.esm.js +982 -0
  313. package/tech/linting/index.esm.js.map +1 -0
  314. package/tech/linting/prettier.d.ts +13 -0
  315. package/tech/linting/prettier.d.ts.map +1 -0
  316. package/tech/linting/stylelint.d.ts +13 -0
  317. package/tech/linting/stylelint.d.ts.map +1 -0
  318. package/tech/linting/types.d.ts +31 -0
  319. package/tech/linting/types.d.ts.map +1 -0
  320. package/tech/monorepo/detect-all.d.ts +13 -0
  321. package/tech/monorepo/detect-all.d.ts.map +1 -0
  322. package/tech/monorepo/index.cjs.js +1021 -0
  323. package/tech/monorepo/index.cjs.js.map +1 -0
  324. package/tech/monorepo/index.d.ts +10 -0
  325. package/tech/monorepo/index.d.ts.map +1 -0
  326. package/tech/monorepo/index.esm.js +1011 -0
  327. package/tech/monorepo/index.esm.js.map +1 -0
  328. package/tech/monorepo/lerna.d.ts +11 -0
  329. package/tech/monorepo/lerna.d.ts.map +1 -0
  330. package/tech/monorepo/npm-workspaces.d.ts +11 -0
  331. package/tech/monorepo/npm-workspaces.d.ts.map +1 -0
  332. package/tech/monorepo/nx.d.ts +11 -0
  333. package/tech/monorepo/nx.d.ts.map +1 -0
  334. package/tech/monorepo/pnpm-workspaces.d.ts +9 -0
  335. package/tech/monorepo/pnpm-workspaces.d.ts.map +1 -0
  336. package/tech/monorepo/rush.d.ts +11 -0
  337. package/tech/monorepo/rush.d.ts.map +1 -0
  338. package/tech/monorepo/turborepo.d.ts +11 -0
  339. package/tech/monorepo/turborepo.d.ts.map +1 -0
  340. package/tech/monorepo/types.d.ts +39 -0
  341. package/tech/monorepo/types.d.ts.map +1 -0
  342. package/tech/monorepo/yarn-workspaces.d.ts +11 -0
  343. package/tech/monorepo/yarn-workspaces.d.ts.map +1 -0
  344. package/tech/shared-utils/detector-helpers.d.ts +52 -0
  345. package/tech/shared-utils/detector-helpers.d.ts.map +1 -0
  346. package/tech/shared-utils/types.d.ts +41 -0
  347. package/tech/shared-utils/types.d.ts.map +1 -0
  348. package/tech/testing/cypress.d.ts +13 -0
  349. package/tech/testing/cypress.d.ts.map +1 -0
  350. package/tech/testing/detect-all.d.ts +13 -0
  351. package/tech/testing/detect-all.d.ts.map +1 -0
  352. package/tech/testing/index.cjs.js +1031 -0
  353. package/tech/testing/index.cjs.js.map +1 -0
  354. package/tech/testing/index.d.ts +8 -0
  355. package/tech/testing/index.d.ts.map +1 -0
  356. package/tech/testing/index.esm.js +1018 -0
  357. package/tech/testing/index.esm.js.map +1 -0
  358. package/tech/testing/jest.d.ts +13 -0
  359. package/tech/testing/jest.d.ts.map +1 -0
  360. package/tech/testing/mocha.d.ts +13 -0
  361. package/tech/testing/mocha.d.ts.map +1 -0
  362. package/tech/testing/playwright.d.ts +13 -0
  363. package/tech/testing/playwright.d.ts.map +1 -0
  364. package/tech/testing/types.d.ts +35 -0
  365. package/tech/testing/types.d.ts.map +1 -0
  366. package/tech/testing/vitest.d.ts +13 -0
  367. package/tech/testing/vitest.d.ts.map +1 -0
  368. package/tech/types/detectors.d.ts +67 -0
  369. package/tech/types/detectors.d.ts.map +1 -0
  370. package/tech/types/index.cjs.js +1045 -0
  371. package/tech/types/index.cjs.js.map +1 -0
  372. package/tech/types/index.d.ts +2 -0
  373. package/tech/types/index.d.ts.map +1 -0
  374. package/tech/types/index.esm.js +1039 -0
  375. package/tech/types/index.esm.js.map +1 -0
  376. package/vfs/commit.d.ts +32 -0
  377. package/vfs/commit.d.ts.map +1 -0
  378. package/vfs/diff.d.ts +73 -0
  379. package/vfs/diff.d.ts.map +1 -0
  380. package/vfs/factory.d.ts +37 -0
  381. package/vfs/factory.d.ts.map +1 -0
  382. package/vfs/fs-tree.d.ts +13 -0
  383. package/vfs/fs-tree.d.ts.map +1 -0
  384. package/vfs/index.cjs.js +1600 -0
  385. package/vfs/index.cjs.js.map +1 -0
  386. package/vfs/index.d.ts +6 -0
  387. package/vfs/index.d.ts.map +1 -0
  388. package/vfs/index.esm.js +1590 -0
  389. package/vfs/index.esm.js.map +1 -0
  390. package/vfs/types.d.ts +178 -0
  391. package/vfs/types.d.ts.map +1 -0
@@ -0,0 +1,3684 @@
1
+ 'use strict';
2
+
3
+ var node_path = require('node:path');
4
+ var node_fs = require('node:fs');
5
+
6
+ /**
7
+ * Safe copies of Map built-in via factory function.
8
+ *
9
+ * Since constructors cannot be safely captured via Object.assign, this module
10
+ * provides a factory function that uses Reflect.construct internally.
11
+ *
12
+ * These references are captured at module initialization time to protect against
13
+ * prototype pollution attacks. Import only what you need for tree-shaking.
14
+ *
15
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/map
16
+ */
17
+ // Capture references at module initialization time
18
+ const _Map = globalThis.Map;
19
+ const _Reflect$2 = globalThis.Reflect;
20
+ /**
21
+ * (Safe copy) Creates a new Map using the captured Map constructor.
22
+ * Use this instead of `new Map()`.
23
+ *
24
+ * @param iterable - Optional iterable of key-value pairs.
25
+ * @returns A new Map instance.
26
+ */
27
+ const createMap = (iterable) => _Reflect$2.construct(_Map, iterable ? [iterable] : []);
28
+
29
+ /**
30
+ * Safe copies of Object built-in methods.
31
+ *
32
+ * These references are captured at module initialization time to protect against
33
+ * prototype pollution attacks. Import only what you need for tree-shaking.
34
+ *
35
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/object
36
+ */
37
+ // Capture references at module initialization time
38
+ const _Object = globalThis.Object;
39
+ /**
40
+ * (Safe copy) Prevents modification of existing property attributes and values,
41
+ * and prevents the addition of new properties.
42
+ */
43
+ const freeze = _Object.freeze;
44
+ /**
45
+ * (Safe copy) Returns the names of the enumerable string properties and methods of an object.
46
+ */
47
+ const keys = _Object.keys;
48
+ /**
49
+ * (Safe copy) Returns an array of key/values of the enumerable own properties of an object.
50
+ */
51
+ const entries = _Object.entries;
52
+ /**
53
+ * (Safe copy) Returns an array of values of the enumerable own properties of an object.
54
+ */
55
+ const values = _Object.values;
56
+ /**
57
+ * (Safe copy) Adds one or more properties to an object, and/or modifies attributes of existing properties.
58
+ */
59
+ const defineProperties = _Object.defineProperties;
60
+
61
+ /**
62
+ * Safe copies of Set built-in via factory function.
63
+ *
64
+ * Since constructors cannot be safely captured via Object.assign, this module
65
+ * provides a factory function that uses Reflect.construct internally.
66
+ *
67
+ * These references are captured at module initialization time to protect against
68
+ * prototype pollution attacks. Import only what you need for tree-shaking.
69
+ *
70
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/set
71
+ */
72
+ // Capture references at module initialization time
73
+ const _Set = globalThis.Set;
74
+ const _Reflect$1 = globalThis.Reflect;
75
+ /**
76
+ * (Safe copy) Creates a new Set using the captured Set constructor.
77
+ * Use this instead of `new Set()`.
78
+ *
79
+ * @param iterable - Optional iterable of values.
80
+ * @returns A new Set instance.
81
+ */
82
+ const createSet = (iterable) => _Reflect$1.construct(_Set, iterable ? [iterable] : []);
83
+
84
+ /**
85
+ * Global registry of all caches for bulk operations.
86
+ */
87
+ const cacheRegistry = createSet();
88
+ /**
89
+ * Create a cache with optional TTL and size limits.
90
+ *
91
+ * The cache provides a simple key-value store with:
92
+ * - Optional TTL (time-to-live) for automatic expiration
93
+ * - Optional maxSize for limiting cache size with FIFO eviction
94
+ * - Lazy expiration (entries are checked on access)
95
+ *
96
+ * @param options - Cache configuration options
97
+ * @returns Cache instance
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * // Basic cache
102
+ * const cache = createCache<string, number>()
103
+ * cache.set('answer', 42)
104
+ * cache.get('answer') // 42
105
+ *
106
+ * // Cache with TTL (expires after 60 seconds)
107
+ * const ttlCache = createCache<string, object>({ ttl: 60000 })
108
+ *
109
+ * // Cache with max size (evicts oldest when full)
110
+ * const lruCache = createCache<string, object>({ maxSize: 100 })
111
+ *
112
+ * // Combined options
113
+ * const configCache = createCache<string, object>({
114
+ * ttl: 30000,
115
+ * maxSize: 50
116
+ * })
117
+ * ```
118
+ */
119
+ function createCache(options) {
120
+ const { ttl, maxSize } = options ?? {};
121
+ const store = createMap();
122
+ // Track insertion order for FIFO eviction
123
+ const insertionOrder = [];
124
+ /**
125
+ * Check if an entry is expired.
126
+ *
127
+ * @param entry - Cache entry to check
128
+ * @returns True if entry is expired
129
+ */
130
+ function isExpired(entry) {
131
+ if (ttl === undefined)
132
+ return false;
133
+ // eslint-disable-next-line workspace/no-unsafe-builtin-methods -- Date.now() is needed for Jest fake timers compatibility
134
+ return Date.now() - entry.timestamp > ttl;
135
+ }
136
+ /**
137
+ * Evict oldest entries to make room for new ones.
138
+ */
139
+ function evictIfNeeded() {
140
+ if (maxSize === undefined)
141
+ return;
142
+ while (store.size >= maxSize && insertionOrder.length > 0) {
143
+ const oldestKey = insertionOrder.shift();
144
+ if (oldestKey !== undefined) {
145
+ store.delete(oldestKey);
146
+ }
147
+ }
148
+ }
149
+ /**
150
+ * Remove key from insertion order tracking.
151
+ *
152
+ * @param key - Key to remove from order tracking
153
+ */
154
+ function removeFromOrder(key) {
155
+ const index = insertionOrder.indexOf(key);
156
+ if (index !== -1) {
157
+ insertionOrder.splice(index, 1);
158
+ }
159
+ }
160
+ const cache = {
161
+ get(key) {
162
+ const entry = store.get(key);
163
+ if (!entry)
164
+ return undefined;
165
+ if (isExpired(entry)) {
166
+ store.delete(key);
167
+ removeFromOrder(key);
168
+ return undefined;
169
+ }
170
+ return entry.value;
171
+ },
172
+ set(key, value) {
173
+ // If key exists, remove from order first
174
+ if (store.has(key)) {
175
+ removeFromOrder(key);
176
+ }
177
+ else {
178
+ // Evict if needed before adding new entry
179
+ evictIfNeeded();
180
+ }
181
+ // eslint-disable-next-line workspace/no-unsafe-builtin-methods -- Date.now() is needed for Jest fake timers compatibility
182
+ store.set(key, { value, timestamp: Date.now() });
183
+ insertionOrder.push(key);
184
+ },
185
+ has(key) {
186
+ const entry = store.get(key);
187
+ if (!entry)
188
+ return false;
189
+ if (isExpired(entry)) {
190
+ store.delete(key);
191
+ removeFromOrder(key);
192
+ return false;
193
+ }
194
+ return true;
195
+ },
196
+ delete(key) {
197
+ removeFromOrder(key);
198
+ return store.delete(key);
199
+ },
200
+ clear() {
201
+ store.clear();
202
+ insertionOrder.length = 0;
203
+ },
204
+ size() {
205
+ return store.size;
206
+ },
207
+ keys() {
208
+ return [...insertionOrder];
209
+ },
210
+ };
211
+ // Register cache for global operations
212
+ cacheRegistry.add(cache);
213
+ return freeze(cache);
214
+ }
215
+
216
+ /**
217
+ * Safe copies of Array built-in static methods.
218
+ *
219
+ * These references are captured at module initialization time to protect against
220
+ * prototype pollution attacks. Import only what you need for tree-shaking.
221
+ *
222
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/array
223
+ */
224
+ // Capture references at module initialization time
225
+ const _Array = globalThis.Array;
226
+ /**
227
+ * (Safe copy) Determines whether the passed value is an Array.
228
+ */
229
+ const isArray = _Array.isArray;
230
+
231
+ /**
232
+ * Safe copies of Console built-in methods.
233
+ *
234
+ * These references are captured at module initialization time to protect against
235
+ * prototype pollution attacks. Import only what you need for tree-shaking.
236
+ *
237
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/console
238
+ */
239
+ // Capture references at module initialization time
240
+ const _console = globalThis.console;
241
+ /**
242
+ * (Safe copy) Outputs a message to the console.
243
+ */
244
+ const log = _console.log.bind(_console);
245
+ /**
246
+ * (Safe copy) Outputs a warning message to the console.
247
+ */
248
+ const warn = _console.warn.bind(_console);
249
+ /**
250
+ * (Safe copy) Outputs an error message to the console.
251
+ */
252
+ const error = _console.error.bind(_console);
253
+ /**
254
+ * (Safe copy) Outputs an informational message to the console.
255
+ */
256
+ const info = _console.info.bind(_console);
257
+ /**
258
+ * (Safe copy) Outputs a debug message to the console.
259
+ */
260
+ const debug = _console.debug.bind(_console);
261
+ /**
262
+ * (Safe copy) Outputs a stack trace to the console.
263
+ */
264
+ _console.trace.bind(_console);
265
+ /**
266
+ * (Safe copy) Displays an interactive listing of the properties of a specified object.
267
+ */
268
+ _console.dir.bind(_console);
269
+ /**
270
+ * (Safe copy) Displays tabular data as a table.
271
+ */
272
+ _console.table.bind(_console);
273
+ /**
274
+ * (Safe copy) Writes an error message to the console if the assertion is false.
275
+ */
276
+ _console.assert.bind(_console);
277
+ /**
278
+ * (Safe copy) Clears the console.
279
+ */
280
+ _console.clear.bind(_console);
281
+ /**
282
+ * (Safe copy) Logs the number of times that this particular call to count() has been called.
283
+ */
284
+ _console.count.bind(_console);
285
+ /**
286
+ * (Safe copy) Resets the counter used with console.count().
287
+ */
288
+ _console.countReset.bind(_console);
289
+ /**
290
+ * (Safe copy) Creates a new inline group in the console.
291
+ */
292
+ _console.group.bind(_console);
293
+ /**
294
+ * (Safe copy) Creates a new inline group in the console that is initially collapsed.
295
+ */
296
+ _console.groupCollapsed.bind(_console);
297
+ /**
298
+ * (Safe copy) Exits the current inline group.
299
+ */
300
+ _console.groupEnd.bind(_console);
301
+ /**
302
+ * (Safe copy) Starts a timer with a name specified as an input parameter.
303
+ */
304
+ _console.time.bind(_console);
305
+ /**
306
+ * (Safe copy) Stops a timer that was previously started.
307
+ */
308
+ _console.timeEnd.bind(_console);
309
+ /**
310
+ * (Safe copy) Logs the current value of a timer that was previously started.
311
+ */
312
+ _console.timeLog.bind(_console);
313
+
314
+ /**
315
+ * Safe copies of JSON built-in methods.
316
+ *
317
+ * These references are captured at module initialization time to protect against
318
+ * prototype pollution attacks. Import only what you need for tree-shaking.
319
+ *
320
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/json
321
+ */
322
+ // Capture references at module initialization time
323
+ const _JSON = globalThis.JSON;
324
+ /**
325
+ * (Safe copy) Converts a JavaScript Object Notation (JSON) string into an object.
326
+ */
327
+ const parse = _JSON.parse;
328
+ /**
329
+ * (Safe copy) Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
330
+ */
331
+ const stringify = _JSON.stringify;
332
+
333
+ const registeredClasses = [];
334
+
335
+ /**
336
+ * Returns the data type of the target.
337
+ * Uses native `typeof` operator, however, makes distinction between `null`, `array`, and `object`.
338
+ * Also, when classes are registered via `registerClass`, it checks if objects are instance of any known registered class.
339
+ *
340
+ * @param target - The target to get the data type of.
341
+ * @returns The data type of the target.
342
+ */
343
+ const getType = (target) => {
344
+ if (target === null)
345
+ return 'null';
346
+ const nativeDataType = typeof target;
347
+ if (nativeDataType === 'object') {
348
+ if (isArray(target))
349
+ return 'array';
350
+ for (const registeredClass of registeredClasses) {
351
+ if (target instanceof registeredClass)
352
+ return registeredClass.name;
353
+ }
354
+ }
355
+ return nativeDataType;
356
+ };
357
+
358
+ /**
359
+ * Safe copies of Error built-ins via factory functions.
360
+ *
361
+ * Since constructors cannot be safely captured via Object.assign, this module
362
+ * provides factory functions that use Reflect.construct internally.
363
+ *
364
+ * These references are captured at module initialization time to protect against
365
+ * prototype pollution attacks. Import only what you need for tree-shaking.
366
+ *
367
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/error
368
+ */
369
+ // Capture references at module initialization time
370
+ const _Error = globalThis.Error;
371
+ const _Reflect = globalThis.Reflect;
372
+ /**
373
+ * (Safe copy) Creates a new Error using the captured Error constructor.
374
+ * Use this instead of `new Error()`.
375
+ *
376
+ * @param message - Optional error message.
377
+ * @param options - Optional error options.
378
+ * @returns A new Error instance.
379
+ */
380
+ const createError = (message, options) => _Reflect.construct(_Error, [message, options]);
381
+
382
+ /**
383
+ * Safe copies of Math built-in methods.
384
+ *
385
+ * These references are captured at module initialization time to protect against
386
+ * prototype pollution attacks. Import only what you need for tree-shaking.
387
+ *
388
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/math
389
+ */
390
+ // Capture references at module initialization time
391
+ const _Math = globalThis.Math;
392
+ /**
393
+ * (Safe copy) Returns the smaller of zero or more numbers.
394
+ */
395
+ const min = _Math.min;
396
+
397
+ /* eslint-disable @typescript-eslint/no-explicit-any */
398
+ /**
399
+ * Creates a wrapper function that only executes the wrapped function if the condition function returns true.
400
+ *
401
+ * @param func - The function to be conditionally executed.
402
+ * @param conditionFunc - A function that returns a boolean, determining if `func` should be executed.
403
+ * @returns A wrapped version of `func` that executes conditionally.
404
+ */
405
+ function createConditionalExecutionFunction(func, conditionFunc) {
406
+ return function (...args) {
407
+ if (conditionFunc()) {
408
+ return func(...args);
409
+ }
410
+ };
411
+ }
412
+
413
+ /* eslint-disable @typescript-eslint/no-explicit-any */
414
+ /**
415
+ * Creates a wrapper function that silently ignores any errors thrown by the wrapped void function.
416
+ * This function is specifically for wrapping functions that do not return a value (void functions).
417
+ * Exceptions are swallowed without any logging or handling.
418
+ *
419
+ * @param func - The void function to be wrapped.
420
+ * @returns A wrapped version of the input function that ignores errors.
421
+ */
422
+ function createErrorIgnoringFunction(func) {
423
+ return function (...args) {
424
+ try {
425
+ func(...args);
426
+ }
427
+ catch {
428
+ // Deliberately swallowing/ignoring the exception
429
+ }
430
+ };
431
+ }
432
+
433
+ /* eslint-disable @typescript-eslint/no-unused-vars */
434
+ /**
435
+ * A no-operation function (noop) that does nothing regardless of the arguments passed.
436
+ * It is designed to be as permissive as possible in its typing without using the `Function` keyword.
437
+ *
438
+ * @param args - Any arguments passed to the function (ignored)
439
+ */
440
+ const noop = (...args) => {
441
+ // Intentionally does nothing
442
+ };
443
+
444
+ const logLevels = ['none', 'error', 'warn', 'log', 'info', 'debug'];
445
+ const priority = {
446
+ error: 4,
447
+ warn: 3,
448
+ log: 2,
449
+ info: 1,
450
+ debug: 0,
451
+ };
452
+ /**
453
+ * Validates whether a given string is a valid log level.
454
+ *
455
+ * @param level - The log level to validate
456
+ * @returns True if the level is valid, false otherwise
457
+ */
458
+ function isValidLogLevel(level) {
459
+ return logLevels.includes(level);
460
+ }
461
+ /**
462
+ * Creates a log level configuration manager for controlling logging behavior.
463
+ * Provides methods to get, set, and evaluate log levels based on priority.
464
+ *
465
+ * @param level - The initial log level (defaults to 'error')
466
+ * @returns A configuration object with log level management methods
467
+ * @throws {Error} When the provided level is not a valid log level
468
+ */
469
+ function createLogLevelConfig(level = 'error') {
470
+ if (!isValidLogLevel(level)) {
471
+ throw createError('Cannot create log level configuration with a valid default log level');
472
+ }
473
+ const state = { level };
474
+ const getLogLevel = () => state.level;
475
+ const setLogLevel = (level) => {
476
+ if (!isValidLogLevel(level)) {
477
+ throw createError(`Cannot set value '${level}' level. Expected levels are ${logLevels}.`);
478
+ }
479
+ state.level = level;
480
+ };
481
+ const shouldLog = (level) => {
482
+ if (state.level === 'none' || level === 'none' || !isValidLogLevel(level)) {
483
+ return false;
484
+ }
485
+ return priority[level] >= priority[state.level];
486
+ };
487
+ return freeze({
488
+ getLogLevel,
489
+ setLogLevel,
490
+ shouldLog,
491
+ });
492
+ }
493
+
494
+ /**
495
+ * Creates a logger instance with configurable log level filtering.
496
+ * Each log function is wrapped to respect the current log level setting.
497
+ *
498
+ * @param error - Function to handle error-level logs (required)
499
+ * @param warn - Function to handle warning-level logs (optional, defaults to noop)
500
+ * @param log - Function to handle standard logs (optional, defaults to noop)
501
+ * @param info - Function to handle info-level logs (optional, defaults to noop)
502
+ * @param debug - Function to handle debug-level logs (optional, defaults to noop)
503
+ * @returns A frozen logger object with log methods and level control
504
+ * @throws {ErrorLevelFn} When any provided log function is invalid
505
+ */
506
+ function createLogger(error, warn = noop, log = noop, info = noop, debug = noop) {
507
+ if (notValidLogFn(error)) {
508
+ throw createError(notFnMsg('error'));
509
+ }
510
+ if (notValidLogFn(warn)) {
511
+ throw createError(notFnMsg('warn'));
512
+ }
513
+ if (notValidLogFn(log)) {
514
+ throw createError(notFnMsg('log'));
515
+ }
516
+ if (notValidLogFn(info)) {
517
+ throw createError(notFnMsg('info'));
518
+ }
519
+ if (notValidLogFn(debug)) {
520
+ throw createError(notFnMsg('debug'));
521
+ }
522
+ const { setLogLevel, getLogLevel, shouldLog } = createLogLevelConfig();
523
+ const wrapLogFn = (fn, level) => {
524
+ if (fn === noop)
525
+ return fn;
526
+ const condition = () => shouldLog(level);
527
+ return createConditionalExecutionFunction(createErrorIgnoringFunction(fn), condition);
528
+ };
529
+ return freeze({
530
+ error: wrapLogFn(error, 'error'),
531
+ warn: wrapLogFn(warn, 'warn'),
532
+ log: wrapLogFn(log, 'log'),
533
+ info: wrapLogFn(info, 'info'),
534
+ debug: wrapLogFn(debug, 'debug'),
535
+ setLogLevel,
536
+ getLogLevel,
537
+ });
538
+ }
539
+ /**
540
+ * Validates whether a given value is a valid log function.
541
+ *
542
+ * @param fn - The value to validate
543
+ * @returns True if the value is not a function (invalid), false if it is valid
544
+ */
545
+ function notValidLogFn(fn) {
546
+ return getType(fn) !== 'function' && fn !== noop;
547
+ }
548
+ /**
549
+ * Generates an error message for invalid log function parameters.
550
+ *
551
+ * @param label - The name of the log function that failed validation
552
+ * @returns A formatted error message string
553
+ */
554
+ function notFnMsg(label) {
555
+ return `Cannot create a logger when ${label} is not a function`;
556
+ }
557
+
558
+ createLogger(error, warn, log, info, debug);
559
+
560
+ /**
561
+ * Global log level registry.
562
+ * Tracks all created scoped loggers to allow global log level changes.
563
+ */
564
+ const loggerRegistry = createSet();
565
+ /** Redacted placeholder for sensitive values */
566
+ const REDACTED = '[REDACTED]';
567
+ /**
568
+ * Patterns that indicate a sensitive key name.
569
+ * Keys containing these patterns will have their values sanitized.
570
+ */
571
+ const SENSITIVE_KEY_PATTERNS = [
572
+ /token/i,
573
+ /key/i,
574
+ /password/i,
575
+ /secret/i,
576
+ /credential/i,
577
+ /auth/i,
578
+ /bearer/i,
579
+ /api[_-]?key/i,
580
+ /private/i,
581
+ /passphrase/i,
582
+ ];
583
+ /**
584
+ * Checks if a key name indicates sensitive data.
585
+ *
586
+ * @param key - Key name to check
587
+ * @returns True if the key indicates sensitive data
588
+ */
589
+ function isSensitiveKey(key) {
590
+ return SENSITIVE_KEY_PATTERNS.some((pattern) => pattern.test(key));
591
+ }
592
+ /**
593
+ * Sanitizes an object by replacing sensitive values with REDACTED.
594
+ * This function recursively processes nested objects and arrays.
595
+ *
596
+ * @param obj - Object to sanitize
597
+ * @returns New object with sensitive values redacted
598
+ */
599
+ function sanitize(obj) {
600
+ if (obj === null || obj === undefined) {
601
+ return obj;
602
+ }
603
+ if (isArray(obj)) {
604
+ return obj.map((item) => sanitize(item));
605
+ }
606
+ if (typeof obj === 'object') {
607
+ const result = {};
608
+ for (const [key, value] of entries(obj)) {
609
+ if (isSensitiveKey(key)) {
610
+ result[key] = REDACTED;
611
+ }
612
+ else if (typeof value === 'object' && value !== null) {
613
+ result[key] = sanitize(value);
614
+ }
615
+ else {
616
+ result[key] = value;
617
+ }
618
+ }
619
+ return result;
620
+ }
621
+ return obj;
622
+ }
623
+ /**
624
+ * Formats a log message with optional metadata.
625
+ *
626
+ * @param namespace - Logger namespace prefix
627
+ * @param message - Log message
628
+ * @param meta - Optional metadata object
629
+ * @returns Formatted log string
630
+ */
631
+ function formatMessage(namespace, message, meta) {
632
+ const prefix = `[${namespace}]`;
633
+ if (meta && keys(meta).length > 0) {
634
+ const sanitizedMeta = sanitize(meta);
635
+ return `${prefix} ${message} ${stringify(sanitizedMeta)}`;
636
+ }
637
+ return `${prefix} ${message}`;
638
+ }
639
+ /**
640
+ * Creates a scoped logger with namespace prefix and optional secret sanitization.
641
+ * All log messages will be prefixed with [namespace] and sensitive metadata
642
+ * values will be automatically redacted.
643
+ *
644
+ * @param namespace - Logger namespace (e.g., 'project-scope', 'analyze')
645
+ * @param options - Logger configuration options
646
+ * @returns A configured scoped logger instance
647
+ *
648
+ * @example
649
+ * ```typescript
650
+ * const logger = createScopedLogger('project-scope')
651
+ * logger.setLogLevel('debug')
652
+ *
653
+ * // Basic logging
654
+ * logger.info('Starting analysis', { path: './project' })
655
+ *
656
+ * // Sensitive data is automatically redacted
657
+ * logger.debug('Config loaded', { apiKey: 'secret123' })
658
+ * // Output: [project-scope] Config loaded {"apiKey":"[REDACTED]"}
659
+ * ```
660
+ */
661
+ function createScopedLogger(namespace, options = {}) {
662
+ const { level = 'error', sanitizeSecrets = true } = options;
663
+ // Create wrapper functions that add namespace prefix and sanitization
664
+ const createLogFn = (baseFn) => (message, meta) => {
665
+ const processedMeta = sanitizeSecrets && meta ? sanitize(meta) : meta;
666
+ baseFn(formatMessage(namespace, message, processedMeta));
667
+ };
668
+ // Create base logger with wrapped functions
669
+ const baseLogger = createLogger(createLogFn(error), createLogFn(warn), createLogFn(log), createLogFn(info), createLogFn(debug));
670
+ // Set initial log level (use global override if set)
671
+ baseLogger.setLogLevel(level);
672
+ const scopedLogger = freeze({
673
+ error: (message, meta) => baseLogger.error(message, meta),
674
+ warn: (message, meta) => baseLogger.warn(message, meta),
675
+ log: (message, meta) => baseLogger.log(message, meta),
676
+ info: (message, meta) => baseLogger.info(message, meta),
677
+ debug: (message, meta) => baseLogger.debug(message, meta),
678
+ setLogLevel: baseLogger.setLogLevel,
679
+ getLogLevel: baseLogger.getLogLevel,
680
+ });
681
+ // Register logger for global level management
682
+ loggerRegistry.add(scopedLogger);
683
+ return scopedLogger;
684
+ }
685
+ /**
686
+ * Default logger instance for the project-scope library.
687
+ * Use this for general logging within the library.
688
+ *
689
+ * @example
690
+ * ```typescript
691
+ * import { logger } from '@hyperfrontend/project-scope/core'
692
+ *
693
+ * logger.setLogLevel('debug')
694
+ * logger.debug('Analyzing project', { path: './src' })
695
+ * ```
696
+ */
697
+ createScopedLogger('project-scope');
698
+
699
+ createScopedLogger('project-scope:fs');
700
+ /**
701
+ * Create a file system error with code and context.
702
+ *
703
+ * @param message - The error message describing what went wrong
704
+ * @param code - The category code for this type of filesystem failure
705
+ * @param context - Additional context including path, operation, and cause
706
+ * @returns A configured Error object with code and context properties
707
+ */
708
+ function createFileSystemError(message, code, context) {
709
+ const error = createError(message);
710
+ defineProperties(error, {
711
+ code: { value: code, enumerable: true },
712
+ context: { value: context, enumerable: true },
713
+ });
714
+ return error;
715
+ }
716
+ /**
717
+ * Read file if exists, return null otherwise.
718
+ *
719
+ * @param filePath - Path to file
720
+ * @param encoding - File encoding (default: utf-8)
721
+ * @returns File contents or null if file doesn't exist
722
+ */
723
+ function readFileIfExists(filePath, encoding = 'utf-8') {
724
+ if (!node_fs.existsSync(filePath)) {
725
+ return null;
726
+ }
727
+ try {
728
+ return node_fs.readFileSync(filePath, { encoding });
729
+ }
730
+ catch {
731
+ return null;
732
+ }
733
+ }
734
+
735
+ createScopedLogger('project-scope:fs:write');
736
+
737
+ /**
738
+ * Get file stats with error handling.
739
+ *
740
+ * @param filePath - Path to file
741
+ * @param followSymlinks - Whether to follow symlinks (default: true)
742
+ * @returns File stats or null if path doesn't exist
743
+ */
744
+ function getFileStat(filePath, followSymlinks = true) {
745
+ if (!node_fs.existsSync(filePath)) {
746
+ return null;
747
+ }
748
+ try {
749
+ const stat = followSymlinks ? node_fs.statSync(filePath) : node_fs.lstatSync(filePath);
750
+ return {
751
+ isFile: stat.isFile(),
752
+ isDirectory: stat.isDirectory(),
753
+ isSymlink: stat.isSymbolicLink(),
754
+ size: stat.size,
755
+ created: stat.birthtime,
756
+ modified: stat.mtime,
757
+ accessed: stat.atime,
758
+ mode: stat.mode,
759
+ };
760
+ }
761
+ catch {
762
+ return null;
763
+ }
764
+ }
765
+ /**
766
+ * Check if path is a directory.
767
+ *
768
+ * @param dirPath - Path to check
769
+ * @returns True if path is a directory
770
+ */
771
+ function isDirectory(dirPath) {
772
+ const stats = getFileStat(dirPath);
773
+ return stats?.isDirectory ?? false;
774
+ }
775
+ /**
776
+ * Check if path exists.
777
+ *
778
+ * @param filePath - Path to check
779
+ * @returns True if path exists
780
+ */
781
+ function exists(filePath) {
782
+ return node_fs.existsSync(filePath);
783
+ }
784
+
785
+ const fsDirLogger = createScopedLogger('project-scope:fs:dir');
786
+ /**
787
+ * List immediate contents of a directory.
788
+ *
789
+ * @param dirPath - Absolute or relative path to the directory
790
+ * @returns Array of entries with metadata for each file/directory
791
+ * @throws {Error} If directory doesn't exist or isn't a directory
792
+ *
793
+ * @example
794
+ * ```typescript
795
+ * import { readDirectory } from '@hyperfrontend/project-scope'
796
+ *
797
+ * const entries = readDirectory('./src')
798
+ * for (const entry of entries) {
799
+ * console.log(entry.name, entry.isFile ? 'file' : 'directory')
800
+ * }
801
+ * ```
802
+ */
803
+ function readDirectory(dirPath) {
804
+ fsDirLogger.debug('Reading directory', { path: dirPath });
805
+ if (!node_fs.existsSync(dirPath)) {
806
+ fsDirLogger.debug('Directory not found', { path: dirPath });
807
+ throw createFileSystemError(`Directory not found: ${dirPath}`, 'FS_NOT_FOUND', { path: dirPath, operation: 'readdir' });
808
+ }
809
+ if (!isDirectory(dirPath)) {
810
+ fsDirLogger.debug('Path is not a directory', { path: dirPath });
811
+ throw createFileSystemError(`Not a directory: ${dirPath}`, 'FS_NOT_A_DIRECTORY', { path: dirPath, operation: 'readdir' });
812
+ }
813
+ try {
814
+ const entries = node_fs.readdirSync(dirPath, { withFileTypes: true });
815
+ fsDirLogger.debug('Directory read complete', { path: dirPath, entryCount: entries.length });
816
+ return entries.map((entry) => ({
817
+ name: entry.name,
818
+ path: node_path.join(dirPath, entry.name),
819
+ isFile: entry.isFile(),
820
+ isDirectory: entry.isDirectory(),
821
+ isSymlink: entry.isSymbolicLink(),
822
+ }));
823
+ }
824
+ catch (error) {
825
+ fsDirLogger.warn('Failed to read directory', { path: dirPath, error: error instanceof Error ? error.message : String(error) });
826
+ throw createFileSystemError(`Failed to read directory: ${dirPath}`, 'FS_READ_ERROR', {
827
+ path: dirPath,
828
+ operation: 'readdir',
829
+ cause: error,
830
+ });
831
+ }
832
+ }
833
+
834
+ /**
835
+ * Join path segments.
836
+ * Uses platform-specific separators (e.g., / or \).
837
+ *
838
+ * @param paths - Path segments to join
839
+ * @returns Joined path
840
+ */
841
+ function join(...paths) {
842
+ return node_path.join(...paths);
843
+ }
844
+
845
+ createScopedLogger('project-scope:fs:traversal');
846
+
847
+ const packageLogger = createScopedLogger('project-scope:project:package');
848
+ /**
849
+ * Verifies that a value is an object with only string values,
850
+ * used for validating dependency maps and script definitions.
851
+ *
852
+ * @param value - Value to check
853
+ * @returns True if value is a record of strings
854
+ */
855
+ function isStringRecord(value) {
856
+ if (typeof value !== 'object' || value === null)
857
+ return false;
858
+ return values(value).every((v) => typeof v === 'string');
859
+ }
860
+ /**
861
+ * Extracts and normalizes the workspaces field from package.json,
862
+ * supporting both array format and object with packages array.
863
+ *
864
+ * @param value - Raw workspaces value from package.json
865
+ * @returns Normalized workspace patterns or undefined if invalid
866
+ */
867
+ function parseWorkspaces(value) {
868
+ if (isArray(value) && value.every((v) => typeof v === 'string')) {
869
+ return value;
870
+ }
871
+ if (typeof value === 'object' && value !== null) {
872
+ const obj = value;
873
+ if (isArray(obj['packages'])) {
874
+ return { packages: obj['packages'] };
875
+ }
876
+ }
877
+ return undefined;
878
+ }
879
+ /**
880
+ * Validate and normalize package.json data.
881
+ *
882
+ * @param data - Raw parsed data
883
+ * @returns Validated package.json
884
+ */
885
+ function validatePackageJson(data) {
886
+ if (typeof data !== 'object' || data === null) {
887
+ throw createError('package.json must be an object');
888
+ }
889
+ const pkg = data;
890
+ return {
891
+ name: typeof pkg['name'] === 'string' ? pkg['name'] : undefined,
892
+ version: typeof pkg['version'] === 'string' ? pkg['version'] : undefined,
893
+ description: typeof pkg['description'] === 'string' ? pkg['description'] : undefined,
894
+ main: typeof pkg['main'] === 'string' ? pkg['main'] : undefined,
895
+ module: typeof pkg['module'] === 'string' ? pkg['module'] : undefined,
896
+ browser: typeof pkg['browser'] === 'string' ? pkg['browser'] : undefined,
897
+ types: typeof pkg['types'] === 'string' ? pkg['types'] : undefined,
898
+ bin: typeof pkg['bin'] === 'string' || isStringRecord(pkg['bin']) ? pkg['bin'] : undefined,
899
+ scripts: isStringRecord(pkg['scripts']) ? pkg['scripts'] : undefined,
900
+ dependencies: isStringRecord(pkg['dependencies']) ? pkg['dependencies'] : undefined,
901
+ devDependencies: isStringRecord(pkg['devDependencies']) ? pkg['devDependencies'] : undefined,
902
+ peerDependencies: isStringRecord(pkg['peerDependencies']) ? pkg['peerDependencies'] : undefined,
903
+ optionalDependencies: isStringRecord(pkg['optionalDependencies']) ? pkg['optionalDependencies'] : undefined,
904
+ workspaces: parseWorkspaces(pkg['workspaces']),
905
+ exports: typeof pkg['exports'] === 'object' ? pkg['exports'] : undefined,
906
+ engines: isStringRecord(pkg['engines']) ? pkg['engines'] : undefined,
907
+ ...pkg,
908
+ };
909
+ }
910
+ /**
911
+ * Attempts to read and parse package.json if it exists,
912
+ * returning null on missing file or parse failure.
913
+ *
914
+ * @param projectPath - Project directory path or path to package.json
915
+ * @returns Parsed package.json or null if not found
916
+ */
917
+ function readPackageJsonIfExists(projectPath) {
918
+ const packageJsonPath = projectPath.endsWith('package.json') ? projectPath : node_path.join(projectPath, 'package.json');
919
+ const content = readFileIfExists(packageJsonPath);
920
+ if (!content) {
921
+ packageLogger.debug('Package.json not found', { path: packageJsonPath });
922
+ return null;
923
+ }
924
+ try {
925
+ const validated = validatePackageJson(parse(content));
926
+ packageLogger.debug('Package.json loaded', { path: packageJsonPath, name: validated.name });
927
+ return validated;
928
+ }
929
+ catch {
930
+ packageLogger.debug('Failed to parse package.json, returning null', { path: packageJsonPath });
931
+ return null;
932
+ }
933
+ }
934
+
935
+ /**
936
+ * Get combined dependencies from package.json.
937
+ * Merges dependencies, devDependencies, peerDependencies, and optionalDependencies.
938
+ *
939
+ * @param packageJson - The package.json object to extract dependencies from
940
+ * @returns Combined dependencies as a single record
941
+ */
942
+ function collectAllDependencies(packageJson) {
943
+ return {
944
+ ...packageJson?.dependencies,
945
+ ...packageJson?.devDependencies,
946
+ ...packageJson?.peerDependencies,
947
+ ...packageJson?.optionalDependencies,
948
+ };
949
+ }
950
+ /**
951
+ * Extract clean version from dependency version string.
952
+ * Removes semver prefixes like ^, ~, >=, etc.
953
+ * Uses character-by-character parsing to avoid ReDoS vulnerabilities.
954
+ *
955
+ * @param versionString - The version string with optional prefix characters
956
+ * @returns The cleaned version string without prefix characters
957
+ */
958
+ function parseVersionString(versionString) {
959
+ if (versionString === undefined || versionString === null)
960
+ return undefined;
961
+ // Manual parsing instead of regex to avoid ReDoS
962
+ let start = 0;
963
+ while (start < versionString.length) {
964
+ const char = versionString[start];
965
+ if (char !== '^' && char !== '~' && char !== '>' && char !== '=' && char !== '<') {
966
+ break;
967
+ }
968
+ start++;
969
+ }
970
+ return versionString.slice(start);
971
+ }
972
+ /**
973
+ * Find first matching config file in project.
974
+ * Note: Name avoids similarity to fs.readFile/fs.readFileSync.
975
+ *
976
+ * @param projectPath - The project directory path
977
+ * @param patterns - Array of config file patterns to search for
978
+ * @returns The first matching config file path or undefined
979
+ */
980
+ function locateConfigFile(projectPath, patterns) {
981
+ for (const pattern of patterns) {
982
+ const fullPath = join(projectPath, pattern);
983
+ if (exists(fullPath)) {
984
+ return pattern;
985
+ }
986
+ }
987
+ return undefined;
988
+ }
989
+ /**
990
+ * Find scripts containing a specific command.
991
+ *
992
+ * @param scripts - The scripts object from package.json
993
+ * @param command - The command string to search for
994
+ * @returns Array of script names that contain the command
995
+ */
996
+ function filterScriptsByCommand(scripts, command) {
997
+ if (!scripts)
998
+ return [];
999
+ return entries(scripts)
1000
+ .filter(([, script]) => script.includes(command))
1001
+ .map(([name]) => name);
1002
+ }
1003
+
1004
+ /**
1005
+ * Detect Express in project.
1006
+ *
1007
+ * @param projectPath - Project directory path
1008
+ * @param packageJson - Optional pre-loaded package.json
1009
+ * @returns Detection result or null if not detected
1010
+ */
1011
+ function expressDetector(projectPath, packageJson) {
1012
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1013
+ const sources = [];
1014
+ let confidence = 0;
1015
+ let version;
1016
+ const deps = collectAllDependencies(pkg);
1017
+ if (deps['express']) {
1018
+ confidence += 80;
1019
+ version = parseVersionString(deps['express']);
1020
+ sources.push({ type: 'package.json', field: 'dependencies.express' });
1021
+ }
1022
+ // @types/express (indicates usage)
1023
+ if (deps['@types/express']) {
1024
+ confidence += 10;
1025
+ sources.push({ type: 'package.json', field: 'dependencies.@types/express' });
1026
+ }
1027
+ const expressMiddleware = keys(deps).filter((d) => d.includes('express-') || d === 'body-parser' || d === 'cors' || d === 'helmet' || d === 'morgan');
1028
+ if (expressMiddleware.length > 0) {
1029
+ confidence += 10;
1030
+ sources.push({ type: 'package.json', field: 'dependencies (express middleware)' });
1031
+ }
1032
+ if (confidence === 0) {
1033
+ return null;
1034
+ }
1035
+ return {
1036
+ id: 'express',
1037
+ name: 'Express',
1038
+ version,
1039
+ confidence: min(confidence, 100),
1040
+ detectedFrom: sources,
1041
+ };
1042
+ }
1043
+
1044
+ /**
1045
+ * Detect NestJS in project.
1046
+ *
1047
+ * @param projectPath - Project directory path
1048
+ * @param packageJson - Optional pre-loaded package.json
1049
+ * @returns Detection result or null if not detected
1050
+ */
1051
+ function nestDetector(projectPath, packageJson) {
1052
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1053
+ const sources = [];
1054
+ let confidence = 0;
1055
+ let version;
1056
+ let configPath;
1057
+ const deps = collectAllDependencies(pkg);
1058
+ // @nestjs/core package
1059
+ if (deps['@nestjs/core']) {
1060
+ confidence += 70;
1061
+ version = parseVersionString(deps['@nestjs/core']);
1062
+ sources.push({ type: 'package.json', field: 'dependencies.@nestjs/core' });
1063
+ }
1064
+ // @nestjs/common
1065
+ if (deps['@nestjs/common']) {
1066
+ confidence += 15;
1067
+ sources.push({ type: 'package.json', field: 'dependencies.@nestjs/common' });
1068
+ }
1069
+ if (exists(node_path.join(projectPath, 'nest-cli.json'))) {
1070
+ confidence += 15;
1071
+ configPath = 'nest-cli.json';
1072
+ sources.push({ type: 'config-file', path: 'nest-cli.json' });
1073
+ }
1074
+ const nestPackages = keys(deps).filter((d) => d.startsWith('@nestjs/'));
1075
+ if (nestPackages.length > 2) {
1076
+ confidence += 5;
1077
+ sources.push({ type: 'package.json', field: 'dependencies (@nestjs packages)' });
1078
+ }
1079
+ if (confidence === 0) {
1080
+ return null;
1081
+ }
1082
+ return {
1083
+ id: 'nestjs',
1084
+ name: 'NestJS',
1085
+ version,
1086
+ configPath,
1087
+ confidence: min(confidence, 100),
1088
+ detectedFrom: sources,
1089
+ };
1090
+ }
1091
+
1092
+ /**
1093
+ * Detect Fastify in project.
1094
+ *
1095
+ * @param projectPath - Project directory path
1096
+ * @param packageJson - Optional pre-loaded package.json
1097
+ * @returns Detection result or null if not detected
1098
+ */
1099
+ function fastifyDetector(projectPath, packageJson) {
1100
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1101
+ const sources = [];
1102
+ let confidence = 0;
1103
+ let version;
1104
+ const deps = collectAllDependencies(pkg);
1105
+ if (deps['fastify']) {
1106
+ confidence += 80;
1107
+ version = parseVersionString(deps['fastify']);
1108
+ sources.push({ type: 'package.json', field: 'dependencies.fastify' });
1109
+ }
1110
+ const fastifyPlugins = keys(deps).filter((d) => d.startsWith('@fastify/') || d.startsWith('fastify-'));
1111
+ if (fastifyPlugins.length > 0) {
1112
+ confidence += 15;
1113
+ sources.push({ type: 'package.json', field: 'dependencies (fastify plugins)' });
1114
+ }
1115
+ // @types/fastify (older versions)
1116
+ if (deps['@types/fastify']) {
1117
+ confidence += 5;
1118
+ sources.push({ type: 'package.json', field: 'dependencies.@types/fastify' });
1119
+ }
1120
+ if (confidence === 0) {
1121
+ return null;
1122
+ }
1123
+ return {
1124
+ id: 'fastify',
1125
+ name: 'Fastify',
1126
+ version,
1127
+ confidence: min(confidence, 100),
1128
+ detectedFrom: sources,
1129
+ };
1130
+ }
1131
+
1132
+ /**
1133
+ * Detect Koa in project.
1134
+ *
1135
+ * @param projectPath - Project directory path
1136
+ * @param packageJson - Optional pre-loaded package.json
1137
+ * @returns Detection result or null if not detected
1138
+ */
1139
+ function koaDetector(projectPath, packageJson) {
1140
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1141
+ const sources = [];
1142
+ let confidence = 0;
1143
+ let version;
1144
+ const deps = collectAllDependencies(pkg);
1145
+ if (deps['koa']) {
1146
+ confidence += 80;
1147
+ version = parseVersionString(deps['koa']);
1148
+ sources.push({ type: 'package.json', field: 'dependencies.koa' });
1149
+ }
1150
+ // @types/koa
1151
+ if (deps['@types/koa']) {
1152
+ confidence += 10;
1153
+ sources.push({ type: 'package.json', field: 'dependencies.@types/koa' });
1154
+ }
1155
+ const koaMiddleware = keys(deps).filter((d) => d.startsWith('koa-') || d.startsWith('@koa/'));
1156
+ if (koaMiddleware.length > 0) {
1157
+ confidence += 10;
1158
+ sources.push({ type: 'package.json', field: 'dependencies (koa middleware)' });
1159
+ }
1160
+ if (confidence === 0) {
1161
+ return null;
1162
+ }
1163
+ return {
1164
+ id: 'koa',
1165
+ name: 'Koa',
1166
+ version,
1167
+ confidence: min(confidence, 100),
1168
+ detectedFrom: sources,
1169
+ };
1170
+ }
1171
+
1172
+ /**
1173
+ * Detect Hono in project.
1174
+ *
1175
+ * @param projectPath - Project directory path
1176
+ * @param packageJson - Optional pre-loaded package.json
1177
+ * @returns Detection result or null if not detected
1178
+ */
1179
+ function honoDetector(projectPath, packageJson) {
1180
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1181
+ const sources = [];
1182
+ let confidence = 0;
1183
+ let version;
1184
+ const deps = collectAllDependencies(pkg);
1185
+ if (deps['hono']) {
1186
+ confidence += 85;
1187
+ version = parseVersionString(deps['hono']);
1188
+ sources.push({ type: 'package.json', field: 'dependencies.hono' });
1189
+ }
1190
+ const honoAdapters = keys(deps).filter((d) => d.startsWith('@hono/'));
1191
+ if (honoAdapters.length > 0) {
1192
+ confidence += 15;
1193
+ sources.push({ type: 'package.json', field: 'dependencies (@hono adapters)' });
1194
+ }
1195
+ if (confidence === 0) {
1196
+ return null;
1197
+ }
1198
+ return {
1199
+ id: 'hono',
1200
+ name: 'Hono',
1201
+ version,
1202
+ confidence: min(confidence, 100),
1203
+ detectedFrom: sources,
1204
+ };
1205
+ }
1206
+
1207
+ /** All backend framework detectors */
1208
+ const backendDetectors = [
1209
+ { id: 'express', name: 'Express', detect: expressDetector },
1210
+ { id: 'nestjs', name: 'NestJS', detect: nestDetector },
1211
+ { id: 'fastify', name: 'Fastify', detect: fastifyDetector },
1212
+ { id: 'koa', name: 'Koa', detect: koaDetector },
1213
+ { id: 'hono', name: 'Hono', detect: honoDetector },
1214
+ ];
1215
+ /**
1216
+ * Detect all backend frameworks in project.
1217
+ *
1218
+ * @param projectPath - Project directory path
1219
+ * @param packageJson - Optional pre-loaded package.json
1220
+ * @returns Array of detected frameworks, sorted by confidence
1221
+ */
1222
+ function detectBackendFrameworks(projectPath, packageJson) {
1223
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1224
+ const results = [];
1225
+ for (const detector of backendDetectors) {
1226
+ const detection = detector.detect(projectPath, pkg ?? undefined);
1227
+ if (detection) {
1228
+ results.push(detection);
1229
+ }
1230
+ }
1231
+ return results.sort((a, b) => b.confidence - a.confidence);
1232
+ }
1233
+
1234
+ /** Config patterns for Webpack */
1235
+ const WEBPACK_CONFIG_PATTERNS = [
1236
+ 'webpack.config.js',
1237
+ 'webpack.config.ts',
1238
+ 'webpack.config.cjs',
1239
+ 'webpack.config.mjs',
1240
+ 'webpack.config.babel.js',
1241
+ ];
1242
+ /**
1243
+ * Detect Webpack in project.
1244
+ *
1245
+ * @param projectPath - Project directory path
1246
+ * @param packageJson - Optional pre-loaded package.json
1247
+ * @returns Detection result or null if not detected
1248
+ */
1249
+ function webpackDetector(projectPath, packageJson) {
1250
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1251
+ const sources = [];
1252
+ let confidence = 0;
1253
+ let version;
1254
+ const deps = collectAllDependencies(pkg);
1255
+ if (deps['webpack']) {
1256
+ confidence += 50;
1257
+ version = parseVersionString(deps['webpack']);
1258
+ sources.push({ type: 'package.json', field: 'dependencies.webpack' });
1259
+ }
1260
+ const configPath = locateConfigFile(projectPath, WEBPACK_CONFIG_PATTERNS);
1261
+ if (configPath) {
1262
+ confidence += 40;
1263
+ sources.push({ type: 'config-file', path: configPath });
1264
+ }
1265
+ if (deps['webpack-cli']) {
1266
+ confidence += 10;
1267
+ sources.push({ type: 'package.json', field: 'dependencies.webpack-cli' });
1268
+ }
1269
+ const scriptMatches = filterScriptsByCommand(pkg?.scripts, 'webpack');
1270
+ for (const name of scriptMatches) {
1271
+ confidence = min(confidence + 5, 100);
1272
+ sources.push({ type: 'package.json', field: `scripts.${name}` });
1273
+ }
1274
+ if (confidence === 0) {
1275
+ return null;
1276
+ }
1277
+ return {
1278
+ id: 'webpack',
1279
+ name: 'Webpack',
1280
+ version,
1281
+ configPath,
1282
+ confidence: min(confidence, 100),
1283
+ detectedFrom: sources,
1284
+ };
1285
+ }
1286
+
1287
+ /** Config patterns for Vite */
1288
+ const VITE_CONFIG_PATTERNS = ['vite.config.js', 'vite.config.ts', 'vite.config.mjs', 'vite.config.cjs'];
1289
+ /**
1290
+ * Detect Vite in project.
1291
+ *
1292
+ * @param projectPath - Project directory path
1293
+ * @param packageJson - Optional pre-loaded package.json
1294
+ * @returns Detection result or null if not detected
1295
+ */
1296
+ function viteDetector(projectPath, packageJson) {
1297
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1298
+ const sources = [];
1299
+ let confidence = 0;
1300
+ let version;
1301
+ const deps = collectAllDependencies(pkg);
1302
+ if (deps['vite']) {
1303
+ confidence += 60;
1304
+ version = parseVersionString(deps['vite']);
1305
+ sources.push({ type: 'package.json', field: 'dependencies.vite' });
1306
+ }
1307
+ const configPath = locateConfigFile(projectPath, VITE_CONFIG_PATTERNS);
1308
+ if (configPath) {
1309
+ confidence += 35;
1310
+ sources.push({ type: 'config-file', path: configPath });
1311
+ }
1312
+ if (deps['vitest']) {
1313
+ confidence += 10;
1314
+ sources.push({ type: 'package.json', field: 'dependencies.vitest' });
1315
+ }
1316
+ const vitePlugins = keys(deps).filter((d) => d.startsWith('vite-plugin-') || d.startsWith('@vitejs/'));
1317
+ if (vitePlugins.length > 0) {
1318
+ confidence += 10;
1319
+ sources.push({ type: 'package.json', field: 'dependencies (vite plugins)' });
1320
+ }
1321
+ if (confidence === 0) {
1322
+ return null;
1323
+ }
1324
+ return {
1325
+ id: 'vite',
1326
+ name: 'Vite',
1327
+ version,
1328
+ configPath,
1329
+ confidence: min(confidence, 100),
1330
+ detectedFrom: sources,
1331
+ };
1332
+ }
1333
+
1334
+ /** Config patterns for Rollup */
1335
+ const ROLLUP_CONFIG_PATTERNS = ['rollup.config.js', 'rollup.config.ts', 'rollup.config.mjs', 'rollup.config.cjs'];
1336
+ /**
1337
+ * Detect Rollup in project.
1338
+ *
1339
+ * @param projectPath - Project directory path
1340
+ * @param packageJson - Optional pre-loaded package.json
1341
+ * @returns Detection result or null if not detected
1342
+ */
1343
+ function rollupDetector(projectPath, packageJson) {
1344
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1345
+ const sources = [];
1346
+ let confidence = 0;
1347
+ let version;
1348
+ const deps = collectAllDependencies(pkg);
1349
+ if (deps['rollup']) {
1350
+ confidence += 55;
1351
+ version = parseVersionString(deps['rollup']);
1352
+ sources.push({ type: 'package.json', field: 'dependencies.rollup' });
1353
+ }
1354
+ const configPath = locateConfigFile(projectPath, ROLLUP_CONFIG_PATTERNS);
1355
+ if (configPath) {
1356
+ confidence += 40;
1357
+ sources.push({ type: 'config-file', path: configPath });
1358
+ }
1359
+ const rollupPlugins = keys(deps).filter((d) => d.startsWith('@rollup/') || d.startsWith('rollup-plugin-'));
1360
+ if (rollupPlugins.length > 0) {
1361
+ confidence += 10;
1362
+ sources.push({ type: 'package.json', field: 'dependencies (rollup plugins)' });
1363
+ }
1364
+ const scriptMatches = filterScriptsByCommand(pkg?.scripts, 'rollup');
1365
+ for (const name of scriptMatches) {
1366
+ confidence = min(confidence + 5, 100);
1367
+ sources.push({ type: 'package.json', field: `scripts.${name}` });
1368
+ }
1369
+ if (confidence === 0) {
1370
+ return null;
1371
+ }
1372
+ return {
1373
+ id: 'rollup',
1374
+ name: 'Rollup',
1375
+ version,
1376
+ configPath,
1377
+ confidence: min(confidence, 100),
1378
+ detectedFrom: sources,
1379
+ };
1380
+ }
1381
+
1382
+ /**
1383
+ * Detect esbuild in project.
1384
+ *
1385
+ * @param projectPath - Project directory path
1386
+ * @param packageJson - Optional pre-loaded package.json
1387
+ * @returns Detection result or null if not detected
1388
+ */
1389
+ function esbuildDetector(projectPath, packageJson) {
1390
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1391
+ const sources = [];
1392
+ let confidence = 0;
1393
+ let version;
1394
+ const deps = collectAllDependencies(pkg);
1395
+ if (deps['esbuild']) {
1396
+ confidence += 70;
1397
+ version = parseVersionString(deps['esbuild']);
1398
+ sources.push({ type: 'package.json', field: 'dependencies.esbuild' });
1399
+ }
1400
+ const esbuildPlugins = keys(deps).filter((d) => d.includes('esbuild-plugin') || d.includes('esbuild-'));
1401
+ if (esbuildPlugins.length > 0) {
1402
+ confidence += 15;
1403
+ sources.push({ type: 'package.json', field: 'dependencies (esbuild plugins)' });
1404
+ }
1405
+ const scriptMatches = filterScriptsByCommand(pkg?.scripts, 'esbuild');
1406
+ for (const name of scriptMatches) {
1407
+ confidence = min(confidence + 10, 100);
1408
+ sources.push({ type: 'package.json', field: `scripts.${name}` });
1409
+ }
1410
+ if (confidence === 0) {
1411
+ return null;
1412
+ }
1413
+ return {
1414
+ id: 'esbuild',
1415
+ name: 'esbuild',
1416
+ version,
1417
+ confidence: min(confidence, 100),
1418
+ detectedFrom: sources,
1419
+ };
1420
+ }
1421
+
1422
+ /** Config patterns for Babel */
1423
+ const BABEL_CONFIG_PATTERNS = ['babel.config.js', 'babel.config.cjs', 'babel.config.mjs', 'babel.config.json', '.babelrc', '.babelrc.json', '.babelrc.js'];
1424
+ /**
1425
+ * Detect Babel in project.
1426
+ *
1427
+ * @param projectPath - Project directory path
1428
+ * @param packageJson - Optional pre-loaded package.json
1429
+ * @returns Detection result or null if not detected
1430
+ */
1431
+ function babelDetector(projectPath, packageJson) {
1432
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1433
+ const sources = [];
1434
+ let confidence = 0;
1435
+ let version;
1436
+ const deps = collectAllDependencies(pkg);
1437
+ if (deps['@babel/core']) {
1438
+ confidence += 50;
1439
+ version = parseVersionString(deps['@babel/core']);
1440
+ sources.push({ type: 'package.json', field: 'dependencies.@babel/core' });
1441
+ }
1442
+ const configPath = locateConfigFile(projectPath, BABEL_CONFIG_PATTERNS);
1443
+ if (configPath) {
1444
+ confidence += 40;
1445
+ sources.push({ type: 'config-file', path: configPath });
1446
+ }
1447
+ if (pkg && 'babel' in pkg) {
1448
+ confidence += 30;
1449
+ sources.push({ type: 'package.json', field: 'babel' });
1450
+ }
1451
+ const babelPackages = keys(deps).filter((d) => d.startsWith('@babel/'));
1452
+ if (babelPackages.length > 1) {
1453
+ confidence += 10;
1454
+ sources.push({ type: 'package.json', field: 'dependencies (@babel packages)' });
1455
+ }
1456
+ if (confidence === 0) {
1457
+ return null;
1458
+ }
1459
+ return {
1460
+ id: 'babel',
1461
+ name: 'Babel',
1462
+ version,
1463
+ configPath,
1464
+ confidence: min(confidence, 100),
1465
+ detectedFrom: sources,
1466
+ };
1467
+ }
1468
+
1469
+ /** Config patterns for SWC */
1470
+ const SWC_CONFIG_PATTERNS = ['.swcrc', 'swc.config.js'];
1471
+ /**
1472
+ * Detect SWC in project.
1473
+ *
1474
+ * @param projectPath - Project directory path
1475
+ * @param packageJson - Optional pre-loaded package.json
1476
+ * @returns Detection result or null if not detected
1477
+ */
1478
+ function swcDetector(projectPath, packageJson) {
1479
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1480
+ const sources = [];
1481
+ let confidence = 0;
1482
+ let version;
1483
+ const deps = collectAllDependencies(pkg);
1484
+ if (deps['@swc/core']) {
1485
+ confidence += 60;
1486
+ version = parseVersionString(deps['@swc/core']);
1487
+ sources.push({ type: 'package.json', field: 'dependencies.@swc/core' });
1488
+ }
1489
+ const configPath = locateConfigFile(projectPath, SWC_CONFIG_PATTERNS);
1490
+ if (configPath) {
1491
+ confidence += 35;
1492
+ sources.push({ type: 'config-file', path: configPath });
1493
+ }
1494
+ if (deps['@swc/cli']) {
1495
+ confidence += 10;
1496
+ sources.push({ type: 'package.json', field: 'dependencies.@swc/cli' });
1497
+ }
1498
+ const swcPlugins = keys(deps).filter((d) => d.startsWith('@swc/') || d.includes('swc-plugin'));
1499
+ if (swcPlugins.length > 1) {
1500
+ confidence += 5;
1501
+ sources.push({ type: 'package.json', field: 'dependencies (@swc packages)' });
1502
+ }
1503
+ if (confidence === 0) {
1504
+ return null;
1505
+ }
1506
+ return {
1507
+ id: 'swc',
1508
+ name: 'SWC',
1509
+ version,
1510
+ configPath,
1511
+ confidence: min(confidence, 100),
1512
+ detectedFrom: sources,
1513
+ };
1514
+ }
1515
+
1516
+ /** Config patterns for Parcel */
1517
+ const PARCEL_CONFIG_PATTERNS = ['.parcelrc'];
1518
+ /**
1519
+ * Detect Parcel in project.
1520
+ *
1521
+ * @param projectPath - Project directory path
1522
+ * @param packageJson - Optional pre-loaded package.json
1523
+ * @returns Detection result or null if not detected
1524
+ */
1525
+ function parcelDetector(projectPath, packageJson) {
1526
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1527
+ const sources = [];
1528
+ let confidence = 0;
1529
+ let version;
1530
+ const deps = collectAllDependencies(pkg);
1531
+ if (deps['parcel']) {
1532
+ confidence += 60;
1533
+ version = parseVersionString(deps['parcel']);
1534
+ sources.push({ type: 'package.json', field: 'dependencies.parcel' });
1535
+ }
1536
+ if (deps['parcel-bundler']) {
1537
+ confidence += 60;
1538
+ version = parseVersionString(deps['parcel-bundler']);
1539
+ sources.push({ type: 'package.json', field: 'dependencies.parcel-bundler' });
1540
+ }
1541
+ const configPath = locateConfigFile(projectPath, PARCEL_CONFIG_PATTERNS);
1542
+ if (configPath) {
1543
+ confidence += 30;
1544
+ sources.push({ type: 'config-file', path: configPath });
1545
+ }
1546
+ const scriptMatches = filterScriptsByCommand(pkg?.scripts, 'parcel');
1547
+ for (const name of scriptMatches) {
1548
+ confidence = min(confidence + 10, 100);
1549
+ sources.push({ type: 'package.json', field: `scripts.${name}` });
1550
+ }
1551
+ if (confidence === 0) {
1552
+ return null;
1553
+ }
1554
+ return {
1555
+ id: 'parcel',
1556
+ name: 'Parcel',
1557
+ version,
1558
+ configPath,
1559
+ confidence: min(confidence, 100),
1560
+ detectedFrom: sources,
1561
+ };
1562
+ }
1563
+
1564
+ /** All build tool detectors */
1565
+ const buildToolDetectors = [
1566
+ { id: 'webpack', name: 'Webpack', detect: webpackDetector },
1567
+ { id: 'vite', name: 'Vite', detect: viteDetector },
1568
+ { id: 'rollup', name: 'Rollup', detect: rollupDetector },
1569
+ { id: 'esbuild', name: 'esbuild', detect: esbuildDetector },
1570
+ { id: 'babel', name: 'Babel', detect: babelDetector },
1571
+ { id: 'swc', name: 'SWC', detect: swcDetector },
1572
+ { id: 'parcel', name: 'Parcel', detect: parcelDetector },
1573
+ ];
1574
+ /**
1575
+ * Detect all build tools in project.
1576
+ *
1577
+ * @param projectPath - Project directory path
1578
+ * @param packageJson - Optional pre-loaded package.json
1579
+ * @returns Array of detected build tools, sorted by confidence
1580
+ */
1581
+ function detectBuildTools(projectPath, packageJson) {
1582
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1583
+ const results = [];
1584
+ for (const detector of buildToolDetectors) {
1585
+ const detection = detector.detect(projectPath, pkg ?? undefined);
1586
+ if (detection) {
1587
+ results.push(detection);
1588
+ }
1589
+ }
1590
+ return results.sort((a, b) => b.confidence - a.confidence);
1591
+ }
1592
+
1593
+ /**
1594
+ * Detect React in project.
1595
+ *
1596
+ * @param projectPath - Project directory path
1597
+ * @param packageJson - Optional pre-loaded package.json
1598
+ * @returns Detection result or null if not detected
1599
+ */
1600
+ function reactDetector(projectPath, packageJson) {
1601
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1602
+ const sources = [];
1603
+ let confidence = 0;
1604
+ let version;
1605
+ const metaFrameworks = [];
1606
+ const deps = collectAllDependencies(pkg);
1607
+ if (deps['react']) {
1608
+ confidence += 60;
1609
+ version = parseVersionString(deps['react']);
1610
+ sources.push({ type: 'package.json', field: 'dependencies.react' });
1611
+ }
1612
+ if (deps['react-dom']) {
1613
+ confidence += 20;
1614
+ sources.push({ type: 'package.json', field: 'dependencies.react-dom' });
1615
+ }
1616
+ if (deps['react-native']) {
1617
+ confidence += 20;
1618
+ sources.push({ type: 'package.json', field: 'dependencies.react-native' });
1619
+ }
1620
+ const hasJsxFiles = exists(node_path.join(projectPath, 'src', 'App.tsx')) ||
1621
+ exists(node_path.join(projectPath, 'src', 'App.jsx')) ||
1622
+ exists(node_path.join(projectPath, 'src', 'index.tsx')) ||
1623
+ exists(node_path.join(projectPath, 'src', 'index.jsx'));
1624
+ if (hasJsxFiles) {
1625
+ confidence += 10;
1626
+ sources.push({ type: 'directory', path: 'src/*.tsx or src/*.jsx' });
1627
+ }
1628
+ if (deps['next']) {
1629
+ metaFrameworks.push({
1630
+ id: 'nextjs',
1631
+ name: 'Next.js',
1632
+ category: 'meta-framework',
1633
+ version: parseVersionString(deps['next']),
1634
+ confidence: 90,
1635
+ detectedFrom: [{ type: 'package.json', field: 'dependencies.next' }],
1636
+ });
1637
+ }
1638
+ if (deps['gatsby']) {
1639
+ metaFrameworks.push({
1640
+ id: 'gatsby',
1641
+ name: 'Gatsby',
1642
+ category: 'meta-framework',
1643
+ version: parseVersionString(deps['gatsby']),
1644
+ confidence: 90,
1645
+ detectedFrom: [{ type: 'package.json', field: 'dependencies.gatsby' }],
1646
+ });
1647
+ }
1648
+ if (deps['@remix-run/react'] || deps['remix']) {
1649
+ metaFrameworks.push({
1650
+ id: 'remix',
1651
+ name: 'Remix',
1652
+ category: 'meta-framework',
1653
+ version: parseVersionString(deps['@remix-run/react'] ?? deps['remix']),
1654
+ confidence: 90,
1655
+ detectedFrom: [{ type: 'package.json', field: 'dependencies.@remix-run/react' }],
1656
+ });
1657
+ }
1658
+ if (confidence === 0) {
1659
+ return null;
1660
+ }
1661
+ return {
1662
+ id: 'react',
1663
+ name: 'React',
1664
+ category: 'frontend',
1665
+ version,
1666
+ confidence: min(confidence, 100),
1667
+ detectedFrom: sources,
1668
+ metaFrameworks: metaFrameworks.length > 0 ? metaFrameworks : undefined,
1669
+ };
1670
+ }
1671
+
1672
+ /**
1673
+ * Detect Next.js in project.
1674
+ *
1675
+ * @param projectPath - Project directory path
1676
+ * @param packageJson - Optional pre-loaded package.json
1677
+ * @returns Detection result or null if not detected
1678
+ */
1679
+ function nextjsDetector(projectPath, packageJson) {
1680
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1681
+ const sources = [];
1682
+ let confidence = 0;
1683
+ let version;
1684
+ const deps = collectAllDependencies(pkg);
1685
+ if (deps['next']) {
1686
+ confidence += 70;
1687
+ version = parseVersionString(deps['next']);
1688
+ sources.push({ type: 'package.json', field: 'dependencies.next' });
1689
+ }
1690
+ if (exists(node_path.join(projectPath, 'next.config.js')) ||
1691
+ exists(node_path.join(projectPath, 'next.config.mjs')) ||
1692
+ exists(node_path.join(projectPath, 'next.config.ts'))) {
1693
+ confidence += 25;
1694
+ sources.push({ type: 'config-file', path: 'next.config.*' });
1695
+ }
1696
+ if (exists(node_path.join(projectPath, 'pages')) ||
1697
+ exists(node_path.join(projectPath, 'app')) ||
1698
+ exists(node_path.join(projectPath, 'src', 'pages')) ||
1699
+ exists(node_path.join(projectPath, 'src', 'app'))) {
1700
+ confidence += 5;
1701
+ sources.push({ type: 'directory', path: 'pages/ or app/' });
1702
+ }
1703
+ if (confidence === 0) {
1704
+ return null;
1705
+ }
1706
+ return {
1707
+ id: 'nextjs',
1708
+ name: 'Next.js',
1709
+ category: 'meta-framework',
1710
+ version,
1711
+ confidence: min(confidence, 100),
1712
+ detectedFrom: sources,
1713
+ };
1714
+ }
1715
+
1716
+ /**
1717
+ * Detect Remix in project.
1718
+ *
1719
+ * @param projectPath - Project directory path
1720
+ * @param packageJson - Optional pre-loaded package.json
1721
+ * @returns Detection result or null if not detected
1722
+ */
1723
+ function remixDetector(projectPath, packageJson) {
1724
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1725
+ const sources = [];
1726
+ let confidence = 0;
1727
+ let version;
1728
+ const deps = collectAllDependencies(pkg);
1729
+ // @remix-run packages
1730
+ if (deps['@remix-run/react']) {
1731
+ confidence += 70;
1732
+ version = parseVersionString(deps['@remix-run/react']);
1733
+ sources.push({ type: 'package.json', field: 'dependencies.@remix-run/react' });
1734
+ }
1735
+ if (deps['@remix-run/node'] || deps['@remix-run/cloudflare'] || deps['@remix-run/deno']) {
1736
+ confidence += 20;
1737
+ sources.push({ type: 'package.json', field: 'dependencies.@remix-run/*' });
1738
+ }
1739
+ if (exists(node_path.join(projectPath, 'remix.config.js')) || exists(node_path.join(projectPath, 'remix.config.ts'))) {
1740
+ confidence += 10;
1741
+ sources.push({ type: 'config-file', path: 'remix.config.*' });
1742
+ }
1743
+ if (confidence === 0) {
1744
+ return null;
1745
+ }
1746
+ return {
1747
+ id: 'remix',
1748
+ name: 'Remix',
1749
+ category: 'meta-framework',
1750
+ version,
1751
+ confidence: min(confidence, 100),
1752
+ detectedFrom: sources,
1753
+ };
1754
+ }
1755
+
1756
+ /**
1757
+ * Detect Gatsby in project.
1758
+ *
1759
+ * @param projectPath - Project directory path
1760
+ * @param packageJson - Optional pre-loaded package.json
1761
+ * @returns Detection result or null if not detected
1762
+ */
1763
+ function gatsbyDetector(projectPath, packageJson) {
1764
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1765
+ const sources = [];
1766
+ let confidence = 0;
1767
+ let version;
1768
+ const deps = collectAllDependencies(pkg);
1769
+ if (deps['gatsby']) {
1770
+ confidence += 70;
1771
+ version = parseVersionString(deps['gatsby']);
1772
+ sources.push({ type: 'package.json', field: 'dependencies.gatsby' });
1773
+ }
1774
+ if (exists(node_path.join(projectPath, 'gatsby-config.js')) || exists(node_path.join(projectPath, 'gatsby-config.ts'))) {
1775
+ confidence += 25;
1776
+ sources.push({ type: 'config-file', path: 'gatsby-config.*' });
1777
+ }
1778
+ const gatsbyPlugins = keys(deps).filter((d) => d.startsWith('gatsby-plugin-') || d.startsWith('gatsby-source-'));
1779
+ if (gatsbyPlugins.length > 0) {
1780
+ confidence += 5;
1781
+ sources.push({ type: 'package.json', field: 'dependencies (gatsby plugins)' });
1782
+ }
1783
+ if (confidence === 0) {
1784
+ return null;
1785
+ }
1786
+ return {
1787
+ id: 'gatsby',
1788
+ name: 'Gatsby',
1789
+ category: 'meta-framework',
1790
+ version,
1791
+ confidence: min(confidence, 100),
1792
+ detectedFrom: sources,
1793
+ };
1794
+ }
1795
+
1796
+ /**
1797
+ * Detect Vue in project.
1798
+ *
1799
+ * @param projectPath - Project directory path
1800
+ * @param packageJson - Optional pre-loaded package.json
1801
+ * @returns Detection result or null if not detected
1802
+ */
1803
+ function vueDetector(projectPath, packageJson) {
1804
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1805
+ const sources = [];
1806
+ let confidence = 0;
1807
+ let version;
1808
+ const metaFrameworks = [];
1809
+ const deps = collectAllDependencies(pkg);
1810
+ if (deps['vue']) {
1811
+ confidence += 70;
1812
+ version = parseVersionString(deps['vue']);
1813
+ sources.push({ type: 'package.json', field: 'dependencies.vue' });
1814
+ }
1815
+ if (deps['@vue/cli-service']) {
1816
+ confidence += 15;
1817
+ sources.push({ type: 'package.json', field: 'dependencies.@vue/cli-service' });
1818
+ }
1819
+ const hasVueFiles = exists(node_path.join(projectPath, 'src', 'App.vue')) || exists(node_path.join(projectPath, 'src', 'main.vue'));
1820
+ if (hasVueFiles) {
1821
+ confidence += 10;
1822
+ sources.push({ type: 'directory', path: 'src/*.vue' });
1823
+ }
1824
+ if (exists(node_path.join(projectPath, 'vue.config.js'))) {
1825
+ confidence += 5;
1826
+ sources.push({ type: 'config-file', path: 'vue.config.js' });
1827
+ }
1828
+ if (deps['nuxt'] || deps['nuxt3']) {
1829
+ metaFrameworks.push({
1830
+ id: 'nuxt',
1831
+ name: 'Nuxt',
1832
+ category: 'meta-framework',
1833
+ version: parseVersionString(deps['nuxt'] ?? deps['nuxt3']),
1834
+ confidence: 90,
1835
+ detectedFrom: [{ type: 'package.json', field: 'dependencies.nuxt' }],
1836
+ });
1837
+ }
1838
+ if (confidence === 0) {
1839
+ return null;
1840
+ }
1841
+ return {
1842
+ id: 'vue',
1843
+ name: 'Vue',
1844
+ category: 'frontend',
1845
+ version,
1846
+ confidence: min(confidence, 100),
1847
+ detectedFrom: sources,
1848
+ metaFrameworks: metaFrameworks.length > 0 ? metaFrameworks : undefined,
1849
+ };
1850
+ }
1851
+
1852
+ /**
1853
+ * Detect Nuxt in project.
1854
+ *
1855
+ * @param projectPath - Project directory path
1856
+ * @param packageJson - Optional pre-loaded package.json
1857
+ * @returns Detection result or null if not detected
1858
+ */
1859
+ function nuxtDetector(projectPath, packageJson) {
1860
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1861
+ const sources = [];
1862
+ let confidence = 0;
1863
+ let version;
1864
+ const deps = collectAllDependencies(pkg);
1865
+ if (deps['nuxt'] || deps['nuxt3']) {
1866
+ confidence += 70;
1867
+ version = parseVersionString(deps['nuxt'] ?? deps['nuxt3']);
1868
+ sources.push({ type: 'package.json', field: 'dependencies.nuxt' });
1869
+ }
1870
+ if (exists(node_path.join(projectPath, 'nuxt.config.js')) || exists(node_path.join(projectPath, 'nuxt.config.ts'))) {
1871
+ confidence += 25;
1872
+ sources.push({ type: 'config-file', path: 'nuxt.config.*' });
1873
+ }
1874
+ if (exists(node_path.join(projectPath, 'pages'))) {
1875
+ confidence += 5;
1876
+ sources.push({ type: 'directory', path: 'pages/' });
1877
+ }
1878
+ if (confidence === 0) {
1879
+ return null;
1880
+ }
1881
+ return {
1882
+ id: 'nuxt',
1883
+ name: 'Nuxt',
1884
+ category: 'meta-framework',
1885
+ version,
1886
+ confidence: min(confidence, 100),
1887
+ detectedFrom: sources,
1888
+ };
1889
+ }
1890
+
1891
+ /**
1892
+ * Detect Angular in project.
1893
+ *
1894
+ * @param projectPath - Project directory path
1895
+ * @param packageJson - Optional pre-loaded package.json
1896
+ * @returns Detection result or null if not detected
1897
+ */
1898
+ function angularDetector(projectPath, packageJson) {
1899
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1900
+ const sources = [];
1901
+ let confidence = 0;
1902
+ let version;
1903
+ const deps = collectAllDependencies(pkg);
1904
+ if (deps['@angular/core']) {
1905
+ confidence += 70;
1906
+ version = parseVersionString(deps['@angular/core']);
1907
+ sources.push({ type: 'package.json', field: 'dependencies.@angular/core' });
1908
+ }
1909
+ if (deps['@angular/cli']) {
1910
+ confidence += 15;
1911
+ sources.push({ type: 'package.json', field: 'dependencies.@angular/cli' });
1912
+ }
1913
+ if (exists(node_path.join(projectPath, 'angular.json'))) {
1914
+ confidence += 15;
1915
+ sources.push({ type: 'config-file', path: 'angular.json' });
1916
+ }
1917
+ if (deps['angular'] && !deps['@angular/core']) {
1918
+ return {
1919
+ id: 'angularjs',
1920
+ name: 'AngularJS (Legacy)',
1921
+ category: 'frontend',
1922
+ version: parseVersionString(deps['angular']),
1923
+ confidence: 80,
1924
+ detectedFrom: [{ type: 'package.json', field: 'dependencies.angular' }],
1925
+ };
1926
+ }
1927
+ if (confidence === 0) {
1928
+ return null;
1929
+ }
1930
+ return {
1931
+ id: 'angular',
1932
+ name: 'Angular',
1933
+ category: 'frontend',
1934
+ version,
1935
+ confidence: min(confidence, 100),
1936
+ detectedFrom: sources,
1937
+ };
1938
+ }
1939
+
1940
+ /**
1941
+ * Detect Svelte in project.
1942
+ *
1943
+ * @param projectPath - Project directory path
1944
+ * @param packageJson - Optional pre-loaded package.json
1945
+ * @returns Detection result or null if not detected
1946
+ */
1947
+ function svelteDetector(projectPath, packageJson) {
1948
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
1949
+ const sources = [];
1950
+ let confidence = 0;
1951
+ let version;
1952
+ const metaFrameworks = [];
1953
+ const deps = collectAllDependencies(pkg);
1954
+ if (deps['svelte']) {
1955
+ confidence += 70;
1956
+ version = parseVersionString(deps['svelte']);
1957
+ sources.push({ type: 'package.json', field: 'dependencies.svelte' });
1958
+ }
1959
+ if (exists(node_path.join(projectPath, 'svelte.config.js'))) {
1960
+ confidence += 20;
1961
+ sources.push({ type: 'config-file', path: 'svelte.config.js' });
1962
+ }
1963
+ const hasSvelteFiles = exists(node_path.join(projectPath, 'src', 'App.svelte')) || exists(node_path.join(projectPath, 'src', 'routes'));
1964
+ if (hasSvelteFiles) {
1965
+ confidence += 10;
1966
+ sources.push({ type: 'directory', path: 'src/*.svelte or src/routes/' });
1967
+ }
1968
+ if (deps['@sveltejs/kit']) {
1969
+ metaFrameworks.push({
1970
+ id: 'sveltekit',
1971
+ name: 'SvelteKit',
1972
+ category: 'meta-framework',
1973
+ version: parseVersionString(deps['@sveltejs/kit']),
1974
+ confidence: 90,
1975
+ detectedFrom: [{ type: 'package.json', field: 'dependencies.@sveltejs/kit' }],
1976
+ });
1977
+ }
1978
+ if (confidence === 0) {
1979
+ return null;
1980
+ }
1981
+ return {
1982
+ id: 'svelte',
1983
+ name: 'Svelte',
1984
+ category: 'frontend',
1985
+ version,
1986
+ confidence: min(confidence, 100),
1987
+ detectedFrom: sources,
1988
+ metaFrameworks: metaFrameworks.length > 0 ? metaFrameworks : undefined,
1989
+ };
1990
+ }
1991
+
1992
+ /**
1993
+ * Detect SvelteKit in project.
1994
+ *
1995
+ * @param projectPath - Project directory path
1996
+ * @param packageJson - Optional pre-loaded package.json
1997
+ * @returns Detection result or null if not detected
1998
+ */
1999
+ function sveltekitDetector(projectPath, packageJson) {
2000
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2001
+ const sources = [];
2002
+ let confidence = 0;
2003
+ let version;
2004
+ const deps = collectAllDependencies(pkg);
2005
+ // @sveltejs/kit package
2006
+ if (deps['@sveltejs/kit']) {
2007
+ confidence += 70;
2008
+ version = parseVersionString(deps['@sveltejs/kit']);
2009
+ sources.push({ type: 'package.json', field: 'dependencies.@sveltejs/kit' });
2010
+ }
2011
+ if (exists(node_path.join(projectPath, 'svelte.config.js'))) {
2012
+ confidence += 20;
2013
+ sources.push({ type: 'config-file', path: 'svelte.config.js' });
2014
+ }
2015
+ if (exists(node_path.join(projectPath, 'src', 'routes'))) {
2016
+ confidence += 10;
2017
+ sources.push({ type: 'directory', path: 'src/routes/' });
2018
+ }
2019
+ if (confidence === 0) {
2020
+ return null;
2021
+ }
2022
+ return {
2023
+ id: 'sveltekit',
2024
+ name: 'SvelteKit',
2025
+ category: 'meta-framework',
2026
+ version,
2027
+ confidence: min(confidence, 100),
2028
+ detectedFrom: sources,
2029
+ };
2030
+ }
2031
+
2032
+ /**
2033
+ * Detect Solid in project.
2034
+ *
2035
+ * @param projectPath - Project directory path
2036
+ * @param packageJson - Optional pre-loaded package.json
2037
+ * @returns Detection result or null if not detected
2038
+ */
2039
+ function solidDetector(projectPath, packageJson) {
2040
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2041
+ const sources = [];
2042
+ let confidence = 0;
2043
+ let version;
2044
+ const deps = collectAllDependencies(pkg);
2045
+ if (deps['solid-js']) {
2046
+ confidence += 70;
2047
+ version = parseVersionString(deps['solid-js']);
2048
+ sources.push({ type: 'package.json', field: 'dependencies.solid-js' });
2049
+ }
2050
+ if (deps['vite-plugin-solid']) {
2051
+ confidence += 20;
2052
+ sources.push({ type: 'package.json', field: 'dependencies.vite-plugin-solid' });
2053
+ }
2054
+ if (deps['solid-start'] || deps['@solidjs/start']) {
2055
+ confidence += 10;
2056
+ sources.push({ type: 'package.json', field: 'dependencies.solid-start' });
2057
+ }
2058
+ if (confidence === 0) {
2059
+ return null;
2060
+ }
2061
+ return {
2062
+ id: 'solid',
2063
+ name: 'Solid',
2064
+ category: 'frontend',
2065
+ version,
2066
+ confidence: min(confidence, 100),
2067
+ detectedFrom: sources,
2068
+ };
2069
+ }
2070
+
2071
+ /**
2072
+ * Detect Qwik in project.
2073
+ *
2074
+ * @param projectPath - Project directory path
2075
+ * @param packageJson - Optional pre-loaded package.json
2076
+ * @returns Detection result or null if not detected
2077
+ */
2078
+ function qwikDetector(projectPath, packageJson) {
2079
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2080
+ const sources = [];
2081
+ let confidence = 0;
2082
+ let version;
2083
+ const deps = collectAllDependencies(pkg);
2084
+ // @builder.io/qwik package
2085
+ if (deps['@builder.io/qwik']) {
2086
+ confidence += 70;
2087
+ version = parseVersionString(deps['@builder.io/qwik']);
2088
+ sources.push({ type: 'package.json', field: 'dependencies.@builder.io/qwik' });
2089
+ }
2090
+ // @builder.io/qwik-city
2091
+ if (deps['@builder.io/qwik-city']) {
2092
+ confidence += 20;
2093
+ sources.push({ type: 'package.json', field: 'dependencies.@builder.io/qwik-city' });
2094
+ }
2095
+ if (exists(node_path.join(projectPath, 'qwik.config.ts')) || exists(node_path.join(projectPath, 'qwik.config.js'))) {
2096
+ confidence += 10;
2097
+ sources.push({ type: 'config-file', path: 'qwik.config.*' });
2098
+ }
2099
+ if (confidence === 0) {
2100
+ return null;
2101
+ }
2102
+ return {
2103
+ id: 'qwik',
2104
+ name: 'Qwik',
2105
+ category: 'frontend',
2106
+ version,
2107
+ confidence: min(confidence, 100),
2108
+ detectedFrom: sources,
2109
+ };
2110
+ }
2111
+
2112
+ /**
2113
+ * Detect Astro in project.
2114
+ *
2115
+ * @param projectPath - Project directory path
2116
+ * @param packageJson - Optional pre-loaded package.json
2117
+ * @returns Detection result or null if not detected
2118
+ */
2119
+ function astroDetector(projectPath, packageJson) {
2120
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2121
+ const sources = [];
2122
+ let confidence = 0;
2123
+ let version;
2124
+ const deps = collectAllDependencies(pkg);
2125
+ if (deps['astro']) {
2126
+ confidence += 70;
2127
+ version = parseVersionString(deps['astro']);
2128
+ sources.push({ type: 'package.json', field: 'dependencies.astro' });
2129
+ }
2130
+ if (exists(node_path.join(projectPath, 'astro.config.mjs')) ||
2131
+ exists(node_path.join(projectPath, 'astro.config.ts')) ||
2132
+ exists(node_path.join(projectPath, 'astro.config.js'))) {
2133
+ confidence += 25;
2134
+ sources.push({ type: 'config-file', path: 'astro.config.*' });
2135
+ }
2136
+ if (exists(node_path.join(projectPath, 'src', 'pages'))) {
2137
+ confidence += 5;
2138
+ sources.push({ type: 'directory', path: 'src/pages/' });
2139
+ }
2140
+ if (confidence === 0) {
2141
+ return null;
2142
+ }
2143
+ return {
2144
+ id: 'astro',
2145
+ name: 'Astro',
2146
+ category: 'meta-framework',
2147
+ version,
2148
+ confidence: min(confidence, 100),
2149
+ detectedFrom: sources,
2150
+ };
2151
+ }
2152
+
2153
+ /** All frontend framework detectors */
2154
+ const frameworkDetectors = [
2155
+ { id: 'react', name: 'React', category: 'frontend', detect: reactDetector },
2156
+ { id: 'nextjs', name: 'Next.js', category: 'meta-framework', detect: nextjsDetector },
2157
+ { id: 'remix', name: 'Remix', category: 'meta-framework', detect: remixDetector },
2158
+ { id: 'gatsby', name: 'Gatsby', category: 'meta-framework', detect: gatsbyDetector },
2159
+ { id: 'vue', name: 'Vue', category: 'frontend', detect: vueDetector },
2160
+ { id: 'nuxt', name: 'Nuxt', category: 'meta-framework', detect: nuxtDetector },
2161
+ { id: 'angular', name: 'Angular', category: 'frontend', detect: angularDetector },
2162
+ { id: 'svelte', name: 'Svelte', category: 'frontend', detect: svelteDetector },
2163
+ { id: 'sveltekit', name: 'SvelteKit', category: 'meta-framework', detect: sveltekitDetector },
2164
+ { id: 'solid', name: 'Solid', category: 'frontend', detect: solidDetector },
2165
+ { id: 'qwik', name: 'Qwik', category: 'frontend', detect: qwikDetector },
2166
+ { id: 'astro', name: 'Astro', category: 'meta-framework', detect: astroDetector },
2167
+ ];
2168
+ /**
2169
+ * Detect all frontend frameworks in project.
2170
+ *
2171
+ * @param projectPath - Project directory path
2172
+ * @param packageJson - Optional pre-loaded package.json
2173
+ * @returns Array of detected frameworks, sorted by confidence
2174
+ */
2175
+ function detectFrontendFrameworks(projectPath, packageJson) {
2176
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2177
+ const results = [];
2178
+ for (const detector of frameworkDetectors) {
2179
+ const detection = detector.detect(projectPath, pkg ?? undefined);
2180
+ if (detection) {
2181
+ results.push(detection);
2182
+ }
2183
+ }
2184
+ return results.sort((a, b) => b.confidence - a.confidence);
2185
+ }
2186
+
2187
+ /**
2188
+ * Detect AngularJS (1.x) in project.
2189
+ * AngularJS is the original Angular framework, distinct from Angular 2+.
2190
+ *
2191
+ * @param projectPath - Project directory path
2192
+ * @param packageJson - Optional pre-loaded package.json
2193
+ * @returns Detection result or null if not detected
2194
+ */
2195
+ function angularJSDetector(projectPath, packageJson) {
2196
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2197
+ const sources = [];
2198
+ let confidence = 0;
2199
+ let version;
2200
+ const deps = collectAllDependencies(pkg);
2201
+ // AngularJS package (angular, not @angular/core)
2202
+ if (deps['angular']) {
2203
+ confidence += 70;
2204
+ version = parseVersionString(deps['angular']);
2205
+ sources.push({ type: 'package.json', field: 'dependencies.angular' });
2206
+ }
2207
+ // AngularJS router
2208
+ if (deps['angular-route']) {
2209
+ confidence += 15;
2210
+ sources.push({ type: 'package.json', field: 'dependencies.angular-route' });
2211
+ }
2212
+ // AngularJS resource
2213
+ if (deps['angular-resource']) {
2214
+ confidence += 10;
2215
+ sources.push({ type: 'package.json', field: 'dependencies.angular-resource' });
2216
+ }
2217
+ // AngularJS animate
2218
+ if (deps['angular-animate']) {
2219
+ confidence += 5;
2220
+ sources.push({ type: 'package.json', field: 'dependencies.angular-animate' });
2221
+ }
2222
+ if (confidence === 0) {
2223
+ return null;
2224
+ }
2225
+ return {
2226
+ id: 'angularjs',
2227
+ name: 'AngularJS',
2228
+ category: 'legacy-frontend',
2229
+ version,
2230
+ confidence: min(confidence, 100),
2231
+ detectedFrom: sources,
2232
+ };
2233
+ }
2234
+
2235
+ /**
2236
+ * Detect Backbone.js in project.
2237
+ *
2238
+ * @param projectPath - Project directory path
2239
+ * @param packageJson - Optional pre-loaded package.json
2240
+ * @returns Detection result or null if not detected
2241
+ */
2242
+ function backboneDetector(projectPath, packageJson) {
2243
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2244
+ const sources = [];
2245
+ let confidence = 0;
2246
+ let version;
2247
+ const deps = collectAllDependencies(pkg);
2248
+ // Backbone package
2249
+ if (deps['backbone']) {
2250
+ confidence += 70;
2251
+ version = parseVersionString(deps['backbone']);
2252
+ sources.push({ type: 'package.json', field: 'dependencies.backbone' });
2253
+ // Underscore (commonly used with Backbone)
2254
+ if (deps['underscore']) {
2255
+ confidence += 15;
2256
+ sources.push({ type: 'package.json', field: 'dependencies.underscore' });
2257
+ }
2258
+ // Lodash can be used as underscore replacement
2259
+ if (deps['lodash']) {
2260
+ confidence += 5;
2261
+ sources.push({ type: 'package.json', field: 'dependencies.lodash' });
2262
+ }
2263
+ }
2264
+ // Marionette (Backbone framework)
2265
+ if (deps['backbone.marionette'] || deps['marionette']) {
2266
+ confidence += 10;
2267
+ sources.push({ type: 'package.json', field: 'dependencies.backbone.marionette' });
2268
+ }
2269
+ if (confidence === 0) {
2270
+ return null;
2271
+ }
2272
+ return {
2273
+ id: 'backbone',
2274
+ name: 'Backbone.js',
2275
+ category: 'legacy-frontend',
2276
+ version,
2277
+ confidence: min(confidence, 100),
2278
+ detectedFrom: sources,
2279
+ };
2280
+ }
2281
+
2282
+ /**
2283
+ * Detect Ember.js in project.
2284
+ *
2285
+ * @param projectPath - Project directory path
2286
+ * @param packageJson - Optional pre-loaded package.json
2287
+ * @returns Detection result or null if not detected
2288
+ */
2289
+ function emberDetector(projectPath, packageJson) {
2290
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2291
+ const sources = [];
2292
+ let confidence = 0;
2293
+ let version;
2294
+ const deps = collectAllDependencies(pkg);
2295
+ // Ember source package
2296
+ if (deps['ember-source']) {
2297
+ confidence += 70;
2298
+ version = parseVersionString(deps['ember-source']);
2299
+ sources.push({ type: 'package.json', field: 'dependencies.ember-source' });
2300
+ }
2301
+ // Ember CLI
2302
+ if (deps['ember-cli']) {
2303
+ confidence += 20;
2304
+ sources.push({ type: 'package.json', field: 'devDependencies.ember-cli' });
2305
+ }
2306
+ // Ember Data
2307
+ if (deps['ember-data']) {
2308
+ confidence += 10;
2309
+ sources.push({ type: 'package.json', field: 'dependencies.ember-data' });
2310
+ }
2311
+ if (confidence === 0) {
2312
+ return null;
2313
+ }
2314
+ return {
2315
+ id: 'ember',
2316
+ name: 'Ember.js',
2317
+ category: 'legacy-frontend',
2318
+ version,
2319
+ confidence: min(confidence, 100),
2320
+ detectedFrom: sources,
2321
+ };
2322
+ }
2323
+
2324
+ /**
2325
+ * Detect jQuery in project.
2326
+ *
2327
+ * @param projectPath - Project directory path
2328
+ * @param packageJson - Optional pre-loaded package.json
2329
+ * @returns Detection result or null if not detected
2330
+ */
2331
+ function jqueryDetector(projectPath, packageJson) {
2332
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2333
+ const sources = [];
2334
+ let confidence = 0;
2335
+ let version;
2336
+ const deps = collectAllDependencies(pkg);
2337
+ // jQuery package
2338
+ if (deps['jquery']) {
2339
+ confidence += 80;
2340
+ version = parseVersionString(deps['jquery']);
2341
+ sources.push({ type: 'package.json', field: 'dependencies.jquery' });
2342
+ }
2343
+ // jQuery UI
2344
+ if (deps['jquery-ui']) {
2345
+ confidence += 10;
2346
+ sources.push({ type: 'package.json', field: 'dependencies.jquery-ui' });
2347
+ }
2348
+ // jQuery plugins
2349
+ if (deps['jquery-validation']) {
2350
+ confidence += 5;
2351
+ sources.push({ type: 'package.json', field: 'dependencies.jquery-validation' });
2352
+ }
2353
+ if (confidence === 0) {
2354
+ return null;
2355
+ }
2356
+ return {
2357
+ id: 'jquery',
2358
+ name: 'jQuery',
2359
+ category: 'legacy-frontend',
2360
+ version,
2361
+ confidence: min(confidence, 100),
2362
+ detectedFrom: sources,
2363
+ };
2364
+ }
2365
+
2366
+ /** All legacy framework detectors */
2367
+ const legacyDetectors = [
2368
+ { id: 'angularjs', name: 'AngularJS', category: 'legacy-frontend', detect: angularJSDetector },
2369
+ { id: 'backbone', name: 'Backbone.js', category: 'legacy-frontend', detect: backboneDetector },
2370
+ { id: 'ember', name: 'Ember.js', category: 'legacy-frontend', detect: emberDetector },
2371
+ { id: 'jquery', name: 'jQuery', category: 'legacy-frontend', detect: jqueryDetector },
2372
+ ];
2373
+ /**
2374
+ * Detect all legacy frameworks in project.
2375
+ *
2376
+ * @param projectPath - Project directory path
2377
+ * @param packageJson - Optional pre-loaded package.json
2378
+ * @returns Array of detected legacy frameworks, sorted by confidence
2379
+ */
2380
+ function detectLegacyFrameworks(projectPath, packageJson) {
2381
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2382
+ const results = [];
2383
+ for (const detector of legacyDetectors) {
2384
+ const detection = detector.detect(projectPath, pkg ?? undefined);
2385
+ if (detection) {
2386
+ results.push(detection);
2387
+ }
2388
+ }
2389
+ return results.sort((a, b) => b.confidence - a.confidence);
2390
+ }
2391
+
2392
+ /** Config patterns for ESLint */
2393
+ const ESLINT_CONFIG_PATTERNS = [
2394
+ 'eslint.config.js',
2395
+ 'eslint.config.mjs',
2396
+ 'eslint.config.cjs',
2397
+ 'eslint.config.ts',
2398
+ '.eslintrc.js',
2399
+ '.eslintrc.cjs',
2400
+ '.eslintrc.json',
2401
+ '.eslintrc.yaml',
2402
+ '.eslintrc.yml',
2403
+ '.eslintrc',
2404
+ ];
2405
+ /**
2406
+ * Detect ESLint in project.
2407
+ *
2408
+ * @param projectPath - Project directory path
2409
+ * @param packageJson - Optional pre-loaded package.json
2410
+ * @returns Detection result or null if not detected
2411
+ */
2412
+ function eslintDetector(projectPath, packageJson) {
2413
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2414
+ const sources = [];
2415
+ let confidence = 0;
2416
+ let version;
2417
+ const deps = collectAllDependencies(pkg);
2418
+ if (deps['eslint']) {
2419
+ confidence += 50;
2420
+ version = parseVersionString(deps['eslint']);
2421
+ sources.push({ type: 'package.json', field: 'dependencies.eslint' });
2422
+ }
2423
+ const configPath = locateConfigFile(projectPath, ESLINT_CONFIG_PATTERNS);
2424
+ if (configPath) {
2425
+ confidence += 40;
2426
+ sources.push({ type: 'config-file', path: configPath });
2427
+ }
2428
+ if (pkg && 'eslintConfig' in pkg) {
2429
+ confidence += 30;
2430
+ sources.push({ type: 'package.json', field: 'eslintConfig' });
2431
+ }
2432
+ const eslintPlugins = keys(deps).filter((d) => d.startsWith('eslint-plugin-') || d.startsWith('@typescript-eslint/') || d.startsWith('eslint-config-'));
2433
+ if (eslintPlugins.length > 0) {
2434
+ confidence += 10;
2435
+ sources.push({ type: 'package.json', field: 'dependencies (eslint plugins)' });
2436
+ }
2437
+ const lintScript = pkg?.scripts?.['lint'] ?? '';
2438
+ if (lintScript.includes('eslint')) {
2439
+ confidence += 5;
2440
+ sources.push({ type: 'package.json', field: 'scripts.lint' });
2441
+ }
2442
+ if (confidence === 0) {
2443
+ return null;
2444
+ }
2445
+ return {
2446
+ id: 'eslint',
2447
+ name: 'ESLint',
2448
+ version,
2449
+ configPath,
2450
+ confidence: min(confidence, 100),
2451
+ detectedFrom: sources,
2452
+ };
2453
+ }
2454
+
2455
+ /** Config patterns for Prettier */
2456
+ const PRETTIER_CONFIG_PATTERNS = [
2457
+ 'prettier.config.js',
2458
+ 'prettier.config.mjs',
2459
+ 'prettier.config.cjs',
2460
+ '.prettierrc',
2461
+ '.prettierrc.json',
2462
+ '.prettierrc.yaml',
2463
+ '.prettierrc.yml',
2464
+ '.prettierrc.js',
2465
+ '.prettierrc.cjs',
2466
+ '.prettierrc.toml',
2467
+ ];
2468
+ /**
2469
+ * Detect Prettier in project.
2470
+ *
2471
+ * @param projectPath - Project directory path
2472
+ * @param packageJson - Optional pre-loaded package.json
2473
+ * @returns Detection result or null if not detected
2474
+ */
2475
+ function prettierDetector(projectPath, packageJson) {
2476
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2477
+ const sources = [];
2478
+ let confidence = 0;
2479
+ let version;
2480
+ const deps = collectAllDependencies(pkg);
2481
+ if (deps['prettier']) {
2482
+ confidence += 50;
2483
+ version = parseVersionString(deps['prettier']);
2484
+ sources.push({ type: 'package.json', field: 'dependencies.prettier' });
2485
+ }
2486
+ const configPath = locateConfigFile(projectPath, PRETTIER_CONFIG_PATTERNS);
2487
+ if (configPath) {
2488
+ confidence += 40;
2489
+ sources.push({ type: 'config-file', path: configPath });
2490
+ }
2491
+ if (pkg && 'prettier' in pkg) {
2492
+ confidence += 30;
2493
+ sources.push({ type: 'package.json', field: 'prettier' });
2494
+ }
2495
+ // .prettierignore file
2496
+ if (exists(node_path.join(projectPath, '.prettierignore'))) {
2497
+ confidence += 10;
2498
+ sources.push({ type: 'config-file', path: '.prettierignore' });
2499
+ }
2500
+ const prettierPlugins = keys(deps).filter((d) => d.startsWith('prettier-plugin-'));
2501
+ if (prettierPlugins.length > 0) {
2502
+ confidence += 5;
2503
+ sources.push({ type: 'package.json', field: 'dependencies (prettier plugins)' });
2504
+ }
2505
+ const formatScript = pkg?.scripts?.['format'] ?? pkg?.scripts?.['prettier'] ?? '';
2506
+ if (formatScript.includes('prettier')) {
2507
+ confidence += 5;
2508
+ sources.push({ type: 'package.json', field: 'scripts.format' });
2509
+ }
2510
+ if (confidence === 0) {
2511
+ return null;
2512
+ }
2513
+ return {
2514
+ id: 'prettier',
2515
+ name: 'Prettier',
2516
+ version,
2517
+ configPath,
2518
+ confidence: min(confidence, 100),
2519
+ detectedFrom: sources,
2520
+ };
2521
+ }
2522
+
2523
+ /** Config patterns for Stylelint */
2524
+ const STYLELINT_CONFIG_PATTERNS = [
2525
+ '.stylelintrc',
2526
+ '.stylelintrc.json',
2527
+ '.stylelintrc.js',
2528
+ 'stylelint.config.js',
2529
+ 'stylelint.config.cjs',
2530
+ ];
2531
+ /**
2532
+ * Detect Stylelint in project.
2533
+ *
2534
+ * @param projectPath - Project directory path
2535
+ * @param packageJson - Optional pre-loaded package.json
2536
+ * @returns Detection result or null if not detected
2537
+ */
2538
+ function stylelintDetector(projectPath, packageJson) {
2539
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2540
+ const sources = [];
2541
+ let confidence = 0;
2542
+ let configPath;
2543
+ let version;
2544
+ const deps = collectAllDependencies(pkg);
2545
+ if (deps['stylelint']) {
2546
+ confidence += 60;
2547
+ version = parseVersionString(deps['stylelint']);
2548
+ sources.push({ type: 'package.json', field: 'dependencies.stylelint' });
2549
+ }
2550
+ for (const config of STYLELINT_CONFIG_PATTERNS) {
2551
+ if (exists(node_path.join(projectPath, config))) {
2552
+ confidence += 35;
2553
+ configPath = config;
2554
+ sources.push({ type: 'config-file', path: config });
2555
+ break;
2556
+ }
2557
+ }
2558
+ const stylelintPlugins = keys(deps).filter((d) => d.startsWith('stylelint-'));
2559
+ if (stylelintPlugins.length > 0) {
2560
+ confidence += 5;
2561
+ sources.push({ type: 'package.json', field: 'dependencies (stylelint plugins)' });
2562
+ }
2563
+ if (confidence === 0) {
2564
+ return null;
2565
+ }
2566
+ return {
2567
+ id: 'stylelint',
2568
+ name: 'Stylelint',
2569
+ version,
2570
+ configPath,
2571
+ confidence: min(confidence, 100),
2572
+ detectedFrom: sources,
2573
+ };
2574
+ }
2575
+
2576
+ /**
2577
+ * Detect Biome in project.
2578
+ *
2579
+ * @param projectPath - Project directory path
2580
+ * @param packageJson - Optional pre-loaded package.json
2581
+ * @returns Detection result or null if not detected
2582
+ */
2583
+ function biomeDetector(projectPath, packageJson) {
2584
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2585
+ const sources = [];
2586
+ let confidence = 0;
2587
+ let configPath;
2588
+ let version;
2589
+ const deps = collectAllDependencies(pkg);
2590
+ // @biomejs/biome package
2591
+ if (deps['@biomejs/biome']) {
2592
+ confidence += 70;
2593
+ version = parseVersionString(deps['@biomejs/biome']);
2594
+ sources.push({ type: 'package.json', field: 'dependencies.@biomejs/biome' });
2595
+ }
2596
+ if (exists(node_path.join(projectPath, 'biome.json'))) {
2597
+ confidence += 30;
2598
+ configPath = 'biome.json';
2599
+ sources.push({ type: 'config-file', path: 'biome.json' });
2600
+ }
2601
+ if (!configPath && exists(node_path.join(projectPath, 'biome.jsonc'))) {
2602
+ confidence += 30;
2603
+ configPath = 'biome.jsonc';
2604
+ sources.push({ type: 'config-file', path: 'biome.jsonc' });
2605
+ }
2606
+ if (confidence === 0) {
2607
+ return null;
2608
+ }
2609
+ return {
2610
+ id: 'biome',
2611
+ name: 'Biome',
2612
+ version,
2613
+ configPath,
2614
+ confidence: min(confidence, 100),
2615
+ detectedFrom: sources,
2616
+ };
2617
+ }
2618
+
2619
+ /** All linting tool detectors */
2620
+ const lintingDetectors = [
2621
+ { id: 'eslint', name: 'ESLint', detect: eslintDetector },
2622
+ { id: 'prettier', name: 'Prettier', detect: prettierDetector },
2623
+ { id: 'stylelint', name: 'Stylelint', detect: stylelintDetector },
2624
+ { id: 'biome', name: 'Biome', detect: biomeDetector },
2625
+ ];
2626
+ /**
2627
+ * Detect all linting tools in project.
2628
+ *
2629
+ * @param projectPath - Project directory path
2630
+ * @param packageJson - Optional pre-loaded package.json
2631
+ * @returns Array of detected linting tools, sorted by confidence
2632
+ */
2633
+ function detectLintingTools(projectPath, packageJson) {
2634
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2635
+ const results = [];
2636
+ for (const detector of lintingDetectors) {
2637
+ const detection = detector.detect(projectPath, pkg ?? undefined);
2638
+ if (detection) {
2639
+ results.push(detection);
2640
+ }
2641
+ }
2642
+ return results.sort((a, b) => b.confidence - a.confidence);
2643
+ }
2644
+
2645
+ /**
2646
+ * Detect NX in project.
2647
+ *
2648
+ * @param workspacePath - Workspace directory path
2649
+ * @param packageJson - Optional pre-loaded package.json
2650
+ * @returns Detection result or null if not detected
2651
+ */
2652
+ function nxDetector(workspacePath, packageJson) {
2653
+ const pkg = packageJson ?? readPackageJsonIfExists(workspacePath);
2654
+ const sources = [];
2655
+ let confidence = 0;
2656
+ let version;
2657
+ let workspaceLayout;
2658
+ const nxJsonPath = node_path.join(workspacePath, 'nx.json');
2659
+ if (exists(nxJsonPath)) {
2660
+ confidence += 70;
2661
+ sources.push({ type: 'config-file', path: 'nx.json' });
2662
+ }
2663
+ const deps = collectAllDependencies(pkg);
2664
+ if (deps['nx']) {
2665
+ confidence += 20;
2666
+ version = parseVersionString(deps['nx']);
2667
+ sources.push({ type: 'package.json', field: 'dependencies.nx' });
2668
+ }
2669
+ const hasApps = exists(node_path.join(workspacePath, 'apps'));
2670
+ const hasLibs = exists(node_path.join(workspacePath, 'libs'));
2671
+ if (hasApps || hasLibs) {
2672
+ confidence += 10;
2673
+ sources.push({ type: 'directory', path: 'apps/ or libs/' });
2674
+ workspaceLayout = {
2675
+ appsDir: hasApps ? 'apps' : '',
2676
+ libsDir: hasLibs ? 'libs' : '',
2677
+ };
2678
+ }
2679
+ const nxPackages = keys(deps).filter((d) => d.startsWith('@nx/') || d.startsWith('@nrwl/'));
2680
+ if (nxPackages.length > 0) {
2681
+ confidence += 10;
2682
+ sources.push({ type: 'package.json', field: '@nx/* packages' });
2683
+ }
2684
+ if (confidence === 0) {
2685
+ return null;
2686
+ }
2687
+ return {
2688
+ id: 'nx',
2689
+ name: 'NX',
2690
+ version,
2691
+ configPath: exists(nxJsonPath) ? 'nx.json' : undefined,
2692
+ confidence: min(confidence, 100),
2693
+ detectedFrom: sources,
2694
+ workspaceLayout,
2695
+ };
2696
+ }
2697
+
2698
+ /**
2699
+ * Detect Turborepo in project.
2700
+ *
2701
+ * @param workspacePath - Workspace directory path
2702
+ * @param packageJson - Optional pre-loaded package.json
2703
+ * @returns Detection result or null if not detected
2704
+ */
2705
+ function turborepoDetector(workspacePath, packageJson) {
2706
+ const pkg = packageJson ?? readPackageJsonIfExists(workspacePath);
2707
+ const sources = [];
2708
+ let confidence = 0;
2709
+ let version;
2710
+ let configPath;
2711
+ const turboJsonPath = node_path.join(workspacePath, 'turbo.json');
2712
+ if (exists(turboJsonPath)) {
2713
+ confidence += 80;
2714
+ configPath = 'turbo.json';
2715
+ sources.push({ type: 'config-file', path: 'turbo.json' });
2716
+ }
2717
+ const deps = collectAllDependencies(pkg);
2718
+ if (deps['turbo']) {
2719
+ confidence += 15;
2720
+ version = parseVersionString(deps['turbo']);
2721
+ sources.push({ type: 'package.json', field: 'dependencies.turbo' });
2722
+ }
2723
+ const scripts = pkg?.scripts ?? {};
2724
+ if (values(scripts).some((s) => s?.includes('turbo'))) {
2725
+ confidence += 5;
2726
+ sources.push({ type: 'package.json', field: 'scripts (turbo commands)' });
2727
+ }
2728
+ if (confidence === 0) {
2729
+ return null;
2730
+ }
2731
+ return {
2732
+ id: 'turborepo',
2733
+ name: 'Turborepo',
2734
+ version,
2735
+ configPath,
2736
+ confidence: min(confidence, 100),
2737
+ detectedFrom: sources,
2738
+ };
2739
+ }
2740
+
2741
+ /**
2742
+ * Detect Lerna in project.
2743
+ *
2744
+ * @param workspacePath - Workspace directory path
2745
+ * @param packageJson - Optional pre-loaded package.json
2746
+ * @returns Detection result or null if not detected
2747
+ */
2748
+ function lernaDetector(workspacePath, packageJson) {
2749
+ const pkg = packageJson ?? readPackageJsonIfExists(workspacePath);
2750
+ const sources = [];
2751
+ let confidence = 0;
2752
+ let version;
2753
+ let configPath;
2754
+ const lernaJsonPath = node_path.join(workspacePath, 'lerna.json');
2755
+ if (exists(lernaJsonPath)) {
2756
+ confidence += 80;
2757
+ configPath = 'lerna.json';
2758
+ sources.push({ type: 'config-file', path: 'lerna.json' });
2759
+ }
2760
+ const deps = collectAllDependencies(pkg);
2761
+ if (deps['lerna']) {
2762
+ confidence += 15;
2763
+ version = parseVersionString(deps['lerna']);
2764
+ sources.push({ type: 'package.json', field: 'dependencies.lerna' });
2765
+ }
2766
+ if (exists(node_path.join(workspacePath, 'packages'))) {
2767
+ confidence += 5;
2768
+ sources.push({ type: 'directory', path: 'packages/' });
2769
+ }
2770
+ if (confidence === 0) {
2771
+ return null;
2772
+ }
2773
+ return {
2774
+ id: 'lerna',
2775
+ name: 'Lerna',
2776
+ version,
2777
+ configPath,
2778
+ confidence: min(confidence, 100),
2779
+ detectedFrom: sources,
2780
+ };
2781
+ }
2782
+
2783
+ /**
2784
+ * Detect Rush in project.
2785
+ *
2786
+ * @param workspacePath - Workspace directory path
2787
+ * @param packageJson - Optional pre-loaded package.json
2788
+ * @returns Detection result or null if not detected
2789
+ */
2790
+ function rushDetector(workspacePath, packageJson) {
2791
+ const pkg = packageJson ?? readPackageJsonIfExists(workspacePath);
2792
+ const sources = [];
2793
+ let confidence = 0;
2794
+ let version;
2795
+ let configPath;
2796
+ const rushJsonPath = node_path.join(workspacePath, 'rush.json');
2797
+ if (exists(rushJsonPath)) {
2798
+ confidence += 90;
2799
+ configPath = 'rush.json';
2800
+ sources.push({ type: 'config-file', path: 'rush.json' });
2801
+ }
2802
+ const deps = collectAllDependencies(pkg);
2803
+ if (deps['@microsoft/rush']) {
2804
+ confidence += 10;
2805
+ version = parseVersionString(deps['@microsoft/rush']);
2806
+ sources.push({ type: 'package.json', field: 'dependencies.@microsoft/rush' });
2807
+ }
2808
+ if (exists(node_path.join(workspacePath, 'common', 'config', 'rush'))) {
2809
+ confidence += 5;
2810
+ sources.push({ type: 'directory', path: 'common/config/rush/' });
2811
+ }
2812
+ if (confidence === 0) {
2813
+ return null;
2814
+ }
2815
+ return {
2816
+ id: 'rush',
2817
+ name: 'Rush',
2818
+ version,
2819
+ configPath,
2820
+ confidence: min(confidence, 100),
2821
+ detectedFrom: sources,
2822
+ };
2823
+ }
2824
+
2825
+ /**
2826
+ * Detect pnpm workspaces in project.
2827
+ *
2828
+ * @param workspacePath - Workspace directory path
2829
+ * @returns Detection result or null if not detected
2830
+ */
2831
+ function pnpmWorkspacesDetector(workspacePath) {
2832
+ const sources = [];
2833
+ let confidence = 0;
2834
+ let configPath;
2835
+ const pnpmWorkspacePath = node_path.join(workspacePath, 'pnpm-workspace.yaml');
2836
+ if (exists(pnpmWorkspacePath)) {
2837
+ confidence += 90;
2838
+ configPath = 'pnpm-workspace.yaml';
2839
+ sources.push({ type: 'config-file', path: 'pnpm-workspace.yaml' });
2840
+ }
2841
+ if (exists(node_path.join(workspacePath, 'pnpm-lock.yaml'))) {
2842
+ confidence += 10;
2843
+ sources.push({ type: 'lockfile', path: 'pnpm-lock.yaml' });
2844
+ }
2845
+ if (confidence === 0) {
2846
+ return null;
2847
+ }
2848
+ return {
2849
+ id: 'pnpm-workspaces',
2850
+ name: 'pnpm Workspaces',
2851
+ configPath,
2852
+ confidence: min(confidence, 100),
2853
+ detectedFrom: sources,
2854
+ };
2855
+ }
2856
+
2857
+ /**
2858
+ * Detect npm workspaces in project.
2859
+ *
2860
+ * @param workspacePath - Workspace directory path
2861
+ * @param packageJson - Optional pre-loaded package.json
2862
+ * @returns Detection result or null if not detected
2863
+ */
2864
+ function npmWorkspacesDetector(workspacePath, packageJson) {
2865
+ const pkg = packageJson ?? readPackageJsonIfExists(workspacePath);
2866
+ const sources = [];
2867
+ let confidence = 0;
2868
+ if (pkg?.workspaces) {
2869
+ confidence += 80;
2870
+ sources.push({ type: 'package.json', field: 'workspaces' });
2871
+ }
2872
+ if (exists(node_path.join(workspacePath, 'package-lock.json'))) {
2873
+ confidence += 10;
2874
+ sources.push({ type: 'lockfile', path: 'package-lock.json' });
2875
+ }
2876
+ if (exists(node_path.join(workspacePath, 'yarn.lock'))) {
2877
+ return null; // Let yarn workspace detector handle this
2878
+ }
2879
+ if (confidence === 0) {
2880
+ return null;
2881
+ }
2882
+ return {
2883
+ id: 'npm-workspaces',
2884
+ name: 'npm Workspaces',
2885
+ configPath: 'package.json',
2886
+ confidence: min(confidence, 100),
2887
+ detectedFrom: sources,
2888
+ };
2889
+ }
2890
+
2891
+ /**
2892
+ * Detect yarn workspaces in project.
2893
+ *
2894
+ * @param workspacePath - Workspace directory path
2895
+ * @param packageJson - Optional pre-loaded package.json
2896
+ * @returns Detection result or null if not detected
2897
+ */
2898
+ function yarnWorkspacesDetector(workspacePath, packageJson) {
2899
+ const pkg = packageJson ?? readPackageJsonIfExists(workspacePath);
2900
+ const sources = [];
2901
+ let confidence = 0;
2902
+ if (pkg?.workspaces) {
2903
+ confidence += 70;
2904
+ sources.push({ type: 'package.json', field: 'workspaces' });
2905
+ }
2906
+ if (exists(node_path.join(workspacePath, 'yarn.lock'))) {
2907
+ confidence += 20;
2908
+ sources.push({ type: 'lockfile', path: 'yarn.lock' });
2909
+ }
2910
+ if (exists(node_path.join(workspacePath, '.yarnrc.yml'))) {
2911
+ confidence += 10;
2912
+ sources.push({ type: 'config-file', path: '.yarnrc.yml' });
2913
+ }
2914
+ if (confidence === 0 || !pkg?.workspaces) {
2915
+ return null;
2916
+ }
2917
+ return {
2918
+ id: 'yarn-workspaces',
2919
+ name: 'Yarn Workspaces',
2920
+ configPath: 'package.json',
2921
+ confidence: min(confidence, 100),
2922
+ detectedFrom: sources,
2923
+ };
2924
+ }
2925
+
2926
+ /** All monorepo detectors */
2927
+ const monorepoDetectors = [
2928
+ { id: 'nx', name: 'NX', detect: nxDetector },
2929
+ { id: 'turborepo', name: 'Turborepo', detect: turborepoDetector },
2930
+ { id: 'lerna', name: 'Lerna', detect: lernaDetector },
2931
+ { id: 'rush', name: 'Rush', detect: rushDetector },
2932
+ { id: 'pnpm-workspaces', name: 'pnpm Workspaces', detect: pnpmWorkspacesDetector },
2933
+ { id: 'npm-workspaces', name: 'npm Workspaces', detect: npmWorkspacesDetector },
2934
+ { id: 'yarn-workspaces', name: 'Yarn Workspaces', detect: yarnWorkspacesDetector },
2935
+ ];
2936
+ /**
2937
+ * Detect all monorepo tools in project.
2938
+ *
2939
+ * @param workspacePath - Workspace directory path
2940
+ * @param packageJson - Optional pre-loaded package.json
2941
+ * @returns Array of detected monorepo tools, sorted by confidence
2942
+ */
2943
+ function detectMonorepoTools(workspacePath, packageJson) {
2944
+ const pkg = packageJson ?? readPackageJsonIfExists(workspacePath);
2945
+ const results = [];
2946
+ for (const detector of monorepoDetectors) {
2947
+ const detection = detector.detect(workspacePath, pkg ?? undefined);
2948
+ if (detection) {
2949
+ results.push(detection);
2950
+ }
2951
+ }
2952
+ return results.sort((a, b) => b.confidence - a.confidence);
2953
+ }
2954
+
2955
+ /** Config patterns for Jest */
2956
+ const JEST_CONFIG_PATTERNS = ['jest.config.js', 'jest.config.ts', 'jest.config.mjs', 'jest.config.cjs', 'jest.config.json'];
2957
+ /**
2958
+ * Detect Jest in project.
2959
+ *
2960
+ * @param projectPath - Project directory path
2961
+ * @param packageJson - Optional pre-loaded package.json
2962
+ * @returns Detection result or null if not detected
2963
+ */
2964
+ function jestDetector(projectPath, packageJson) {
2965
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
2966
+ const sources = [];
2967
+ let confidence = 0;
2968
+ let version;
2969
+ const deps = collectAllDependencies(pkg);
2970
+ if (deps['jest']) {
2971
+ confidence += 60;
2972
+ version = parseVersionString(deps['jest']);
2973
+ sources.push({ type: 'package.json', field: 'dependencies.jest' });
2974
+ }
2975
+ const configPath = locateConfigFile(projectPath, JEST_CONFIG_PATTERNS);
2976
+ if (configPath) {
2977
+ confidence += 30;
2978
+ sources.push({ type: 'config-file', path: configPath });
2979
+ }
2980
+ if (pkg && 'jest' in pkg) {
2981
+ confidence += 20;
2982
+ sources.push({ type: 'package.json', field: 'jest' });
2983
+ }
2984
+ const testScript = pkg?.scripts?.['test'] ?? '';
2985
+ if (testScript.includes('jest')) {
2986
+ confidence += 10;
2987
+ sources.push({ type: 'package.json', field: 'scripts.test' });
2988
+ }
2989
+ if (deps['@types/jest']) {
2990
+ confidence += 5;
2991
+ sources.push({ type: 'package.json', field: 'dependencies.@types/jest' });
2992
+ }
2993
+ if (deps['ts-jest']) {
2994
+ confidence += 5;
2995
+ sources.push({ type: 'package.json', field: 'dependencies.ts-jest' });
2996
+ }
2997
+ if (confidence === 0) {
2998
+ return null;
2999
+ }
3000
+ return {
3001
+ id: 'jest',
3002
+ name: 'Jest',
3003
+ type: 'unit',
3004
+ version,
3005
+ configPath,
3006
+ confidence: min(confidence, 100),
3007
+ detectedFrom: sources,
3008
+ };
3009
+ }
3010
+
3011
+ /** Config patterns for Vitest */
3012
+ const VITEST_CONFIG_PATTERNS = ['vitest.config.js', 'vitest.config.ts', 'vitest.config.mjs'];
3013
+ /**
3014
+ * Detect Vitest in project.
3015
+ *
3016
+ * @param projectPath - Project directory path
3017
+ * @param packageJson - Optional pre-loaded package.json
3018
+ * @returns Detection result or null if not detected
3019
+ */
3020
+ function vitestDetector(projectPath, packageJson) {
3021
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
3022
+ const sources = [];
3023
+ let confidence = 0;
3024
+ let version;
3025
+ const deps = collectAllDependencies(pkg);
3026
+ if (deps['vitest']) {
3027
+ confidence += 70;
3028
+ version = parseVersionString(deps['vitest']);
3029
+ sources.push({ type: 'package.json', field: 'dependencies.vitest' });
3030
+ }
3031
+ const configPath = locateConfigFile(projectPath, VITEST_CONFIG_PATTERNS);
3032
+ if (configPath) {
3033
+ confidence += 25;
3034
+ sources.push({ type: 'config-file', path: configPath });
3035
+ }
3036
+ if (!configPath) {
3037
+ const viteConfig = exists(node_path.join(projectPath, 'vite.config.ts')) ||
3038
+ exists(node_path.join(projectPath, 'vite.config.js')) ||
3039
+ exists(node_path.join(projectPath, 'vite.config.mjs'));
3040
+ if (viteConfig && deps['vitest']) {
3041
+ confidence += 5;
3042
+ sources.push({ type: 'config-file', path: 'vite.config.*' });
3043
+ }
3044
+ }
3045
+ const testScript = pkg?.scripts?.['test'] ?? '';
3046
+ if (testScript.includes('vitest')) {
3047
+ confidence += 10;
3048
+ sources.push({ type: 'package.json', field: 'scripts.test' });
3049
+ }
3050
+ if (confidence === 0) {
3051
+ return null;
3052
+ }
3053
+ return {
3054
+ id: 'vitest',
3055
+ name: 'Vitest',
3056
+ type: 'unit',
3057
+ version,
3058
+ configPath,
3059
+ confidence: min(confidence, 100),
3060
+ detectedFrom: sources,
3061
+ };
3062
+ }
3063
+
3064
+ /** Config patterns for Mocha */
3065
+ const MOCHA_CONFIG_PATTERNS = ['.mocharc.js', '.mocharc.json', '.mocharc.yaml', '.mocharc.yml', 'mocha.opts'];
3066
+ /**
3067
+ * Detect Mocha in project.
3068
+ *
3069
+ * @param projectPath - Project directory path
3070
+ * @param packageJson - Optional pre-loaded package.json
3071
+ * @returns Detection result or null if not detected
3072
+ */
3073
+ function mochaDetector(projectPath, packageJson) {
3074
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
3075
+ const sources = [];
3076
+ let confidence = 0;
3077
+ let version;
3078
+ const deps = collectAllDependencies(pkg);
3079
+ if (deps['mocha']) {
3080
+ confidence += 65;
3081
+ version = parseVersionString(deps['mocha']);
3082
+ sources.push({ type: 'package.json', field: 'dependencies.mocha' });
3083
+ }
3084
+ const configPath = locateConfigFile(projectPath, MOCHA_CONFIG_PATTERNS);
3085
+ if (configPath) {
3086
+ confidence += 30;
3087
+ sources.push({ type: 'config-file', path: configPath });
3088
+ }
3089
+ if (deps['@types/mocha']) {
3090
+ confidence += 5;
3091
+ sources.push({ type: 'package.json', field: 'dependencies.@types/mocha' });
3092
+ }
3093
+ if (deps['chai']) {
3094
+ confidence += 5;
3095
+ sources.push({ type: 'package.json', field: 'dependencies.chai' });
3096
+ }
3097
+ const testScript = pkg?.scripts?.['test'] ?? '';
3098
+ if (testScript.includes('mocha')) {
3099
+ confidence += 10;
3100
+ sources.push({ type: 'package.json', field: 'scripts.test' });
3101
+ }
3102
+ if (confidence === 0) {
3103
+ return null;
3104
+ }
3105
+ return {
3106
+ id: 'mocha',
3107
+ name: 'Mocha',
3108
+ type: 'unit',
3109
+ version,
3110
+ configPath,
3111
+ confidence: min(confidence, 100),
3112
+ detectedFrom: sources,
3113
+ };
3114
+ }
3115
+
3116
+ /** Config patterns for Cypress */
3117
+ const CYPRESS_CONFIG_PATTERNS = ['cypress.config.js', 'cypress.config.ts', 'cypress.config.mjs', 'cypress.json'];
3118
+ /**
3119
+ * Detect Cypress in project.
3120
+ *
3121
+ * @param projectPath - Project directory path
3122
+ * @param packageJson - Optional pre-loaded package.json
3123
+ * @returns Detection result or null if not detected
3124
+ */
3125
+ function cypressDetector(projectPath, packageJson) {
3126
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
3127
+ const sources = [];
3128
+ let confidence = 0;
3129
+ let version;
3130
+ const deps = collectAllDependencies(pkg);
3131
+ if (deps['cypress']) {
3132
+ confidence += 60;
3133
+ version = parseVersionString(deps['cypress']);
3134
+ sources.push({ type: 'package.json', field: 'dependencies.cypress' });
3135
+ }
3136
+ const configPath = locateConfigFile(projectPath, CYPRESS_CONFIG_PATTERNS);
3137
+ if (configPath) {
3138
+ confidence += 30;
3139
+ sources.push({ type: 'config-file', path: configPath });
3140
+ }
3141
+ if (exists(node_path.join(projectPath, 'cypress'))) {
3142
+ confidence += 10;
3143
+ sources.push({ type: 'directory', path: 'cypress/' });
3144
+ }
3145
+ const e2eScript = pkg?.scripts?.['e2e'] ?? pkg?.scripts?.['test:e2e'] ?? '';
3146
+ if (e2eScript.includes('cypress')) {
3147
+ confidence += 5;
3148
+ sources.push({ type: 'package.json', field: 'scripts.e2e or scripts.test:e2e' });
3149
+ }
3150
+ if (confidence === 0) {
3151
+ return null;
3152
+ }
3153
+ return {
3154
+ id: 'cypress',
3155
+ name: 'Cypress',
3156
+ type: 'e2e',
3157
+ version,
3158
+ configPath,
3159
+ confidence: min(confidence, 100),
3160
+ detectedFrom: sources,
3161
+ };
3162
+ }
3163
+
3164
+ /** Config patterns for Playwright */
3165
+ const PLAYWRIGHT_CONFIG_PATTERNS = ['playwright.config.js', 'playwright.config.ts', 'playwright.config.mjs'];
3166
+ /**
3167
+ * Detect Playwright in project.
3168
+ *
3169
+ * @param projectPath - Project directory path
3170
+ * @param packageJson - Optional pre-loaded package.json
3171
+ * @returns Detection result or null if not detected
3172
+ */
3173
+ function playwrightDetector(projectPath, packageJson) {
3174
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
3175
+ const sources = [];
3176
+ let confidence = 0;
3177
+ let version;
3178
+ const deps = collectAllDependencies(pkg);
3179
+ if (deps['@playwright/test']) {
3180
+ confidence += 70;
3181
+ version = parseVersionString(deps['@playwright/test']);
3182
+ sources.push({ type: 'package.json', field: 'dependencies.@playwright/test' });
3183
+ }
3184
+ if (deps['playwright']) {
3185
+ confidence += 50;
3186
+ version = version ?? parseVersionString(deps['playwright']);
3187
+ sources.push({ type: 'package.json', field: 'dependencies.playwright' });
3188
+ }
3189
+ const configPath = locateConfigFile(projectPath, PLAYWRIGHT_CONFIG_PATTERNS);
3190
+ if (configPath) {
3191
+ confidence += 25;
3192
+ sources.push({ type: 'config-file', path: configPath });
3193
+ }
3194
+ if (exists(node_path.join(projectPath, 'e2e')) || exists(node_path.join(projectPath, 'tests'))) {
3195
+ confidence += 5;
3196
+ sources.push({ type: 'directory', path: 'e2e/ or tests/' });
3197
+ }
3198
+ const e2eScript = pkg?.scripts?.['e2e'] ?? pkg?.scripts?.['test:e2e'] ?? '';
3199
+ if (e2eScript.includes('playwright')) {
3200
+ confidence += 5;
3201
+ sources.push({ type: 'package.json', field: 'scripts.e2e or scripts.test:e2e' });
3202
+ }
3203
+ if (confidence === 0) {
3204
+ return null;
3205
+ }
3206
+ return {
3207
+ id: 'playwright',
3208
+ name: 'Playwright',
3209
+ type: 'e2e',
3210
+ version,
3211
+ configPath,
3212
+ confidence: min(confidence, 100),
3213
+ detectedFrom: sources,
3214
+ };
3215
+ }
3216
+
3217
+ /** All testing framework detectors */
3218
+ const testingDetectors = [
3219
+ { id: 'jest', name: 'Jest', testType: 'unit', detect: jestDetector },
3220
+ { id: 'vitest', name: 'Vitest', testType: 'unit', detect: vitestDetector },
3221
+ { id: 'mocha', name: 'Mocha', testType: 'unit', detect: mochaDetector },
3222
+ { id: 'cypress', name: 'Cypress', testType: 'e2e', detect: cypressDetector },
3223
+ { id: 'playwright', name: 'Playwright', testType: 'e2e', detect: playwrightDetector },
3224
+ ];
3225
+ /**
3226
+ * Detect all testing frameworks in project.
3227
+ *
3228
+ * @param projectPath - Project directory path
3229
+ * @param packageJson - Optional pre-loaded package.json
3230
+ * @returns Array of detected testing frameworks, sorted by confidence
3231
+ */
3232
+ function detectTestingFrameworks(projectPath, packageJson) {
3233
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
3234
+ const results = [];
3235
+ for (const detector of testingDetectors) {
3236
+ const detection = detector.detect(projectPath, pkg ?? undefined);
3237
+ if (detection) {
3238
+ results.push(detection);
3239
+ }
3240
+ }
3241
+ return results.sort((a, b) => b.confidence - a.confidence);
3242
+ }
3243
+
3244
+ /**
3245
+ * Check if tsconfig has strict mode enabled.
3246
+ *
3247
+ * @param projectPath - The project directory path
3248
+ * @returns True if strict mode is enabled, undefined if unable to determine
3249
+ */
3250
+ function checkTsConfigStrict(projectPath) {
3251
+ const tsconfigPath = node_path.join(projectPath, 'tsconfig.json');
3252
+ const content = readFileIfExists(tsconfigPath);
3253
+ if (!content)
3254
+ return undefined;
3255
+ try {
3256
+ // Simple JSON parsing - doesn't handle comments but good enough for strict check
3257
+ const cleanContent = content.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '');
3258
+ const parsed = parse(cleanContent);
3259
+ return parsed?.compilerOptions?.strict === true;
3260
+ }
3261
+ catch {
3262
+ return undefined;
3263
+ }
3264
+ }
3265
+ /**
3266
+ * Detect TypeScript in project.
3267
+ *
3268
+ * @param projectPath - Project directory path
3269
+ * @param packageJson - Optional pre-loaded package.json
3270
+ * @returns Detection result or null if not detected
3271
+ */
3272
+ function typescriptDetector(projectPath, packageJson) {
3273
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
3274
+ const sources = [];
3275
+ let confidence = 0;
3276
+ let configPath;
3277
+ let version;
3278
+ const deps = collectAllDependencies(pkg);
3279
+ // TypeScript package
3280
+ if (deps['typescript']) {
3281
+ confidence += 50;
3282
+ version = parseVersionString(deps['typescript']);
3283
+ sources.push({ type: 'package.json', field: 'dependencies.typescript' });
3284
+ }
3285
+ // tsconfig.json
3286
+ if (exists(node_path.join(projectPath, 'tsconfig.json'))) {
3287
+ confidence += 40;
3288
+ configPath = 'tsconfig.json';
3289
+ sources.push({ type: 'config-file', path: 'tsconfig.json' });
3290
+ }
3291
+ // tsconfig.*.json variants
3292
+ const tsconfigVariants = ['tsconfig.build.json', 'tsconfig.lib.json', 'tsconfig.spec.json', 'tsconfig.app.json'];
3293
+ for (const variant of tsconfigVariants) {
3294
+ if (exists(node_path.join(projectPath, variant))) {
3295
+ confidence += 5;
3296
+ sources.push({ type: 'config-file', path: variant });
3297
+ break;
3298
+ }
3299
+ }
3300
+ // @types packages
3301
+ const typePackages = keys(deps).filter((d) => d.startsWith('@types/'));
3302
+ if (typePackages.length > 0) {
3303
+ confidence += 10;
3304
+ sources.push({ type: 'package.json', field: '@types/* packages' });
3305
+ }
3306
+ if (confidence === 0) {
3307
+ return null;
3308
+ }
3309
+ const strictMode = checkTsConfigStrict(projectPath);
3310
+ return {
3311
+ id: 'typescript',
3312
+ name: 'TypeScript',
3313
+ version,
3314
+ configPath,
3315
+ strictMode,
3316
+ confidence: min(confidence, 100),
3317
+ detectedFrom: sources,
3318
+ };
3319
+ }
3320
+ /**
3321
+ * Detect Flow in project.
3322
+ *
3323
+ * @param projectPath - Project directory path
3324
+ * @param packageJson - Optional pre-loaded package.json
3325
+ * @returns Detection result or null if not detected
3326
+ */
3327
+ function flowDetector(projectPath, packageJson) {
3328
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
3329
+ const sources = [];
3330
+ let confidence = 0;
3331
+ let configPath;
3332
+ let version;
3333
+ const deps = collectAllDependencies(pkg);
3334
+ // flow-bin package
3335
+ if (deps['flow-bin']) {
3336
+ confidence += 60;
3337
+ version = parseVersionString(deps['flow-bin']);
3338
+ sources.push({ type: 'package.json', field: 'dependencies.flow-bin' });
3339
+ }
3340
+ // .flowconfig
3341
+ if (exists(node_path.join(projectPath, '.flowconfig'))) {
3342
+ confidence += 40;
3343
+ configPath = '.flowconfig';
3344
+ sources.push({ type: 'config-file', path: '.flowconfig' });
3345
+ }
3346
+ // flow-typed directory
3347
+ if (exists(node_path.join(projectPath, 'flow-typed'))) {
3348
+ confidence += 10;
3349
+ sources.push({ type: 'directory', path: 'flow-typed/' });
3350
+ }
3351
+ // @babel/preset-flow
3352
+ if (deps['@babel/preset-flow']) {
3353
+ confidence += 10;
3354
+ sources.push({ type: 'package.json', field: 'dependencies.@babel/preset-flow' });
3355
+ }
3356
+ if (confidence === 0) {
3357
+ return null;
3358
+ }
3359
+ return {
3360
+ id: 'flow',
3361
+ name: 'Flow',
3362
+ version,
3363
+ configPath,
3364
+ confidence: min(confidence, 100),
3365
+ detectedFrom: sources,
3366
+ };
3367
+ }
3368
+ /**
3369
+ * Check if a file contains JSDoc type annotations.
3370
+ *
3371
+ * @param content - The file content to check.
3372
+ * @returns `true` if the content contains JSDoc type annotations.
3373
+ */
3374
+ function hasJsDocTypes(content) {
3375
+ // Check for JSDoc type annotations
3376
+ return (content.includes('@type {') ||
3377
+ content.includes('@param {') ||
3378
+ content.includes('@returns {') ||
3379
+ content.includes('@typedef') ||
3380
+ content.includes('@template'));
3381
+ }
3382
+ /**
3383
+ * Detect JSDoc type annotations in project.
3384
+ *
3385
+ * @param projectPath - Project directory path
3386
+ * @param packageJson - Optional pre-loaded package.json
3387
+ * @returns Detection result or null if not detected
3388
+ */
3389
+ function jsdocDetector(projectPath, packageJson) {
3390
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
3391
+ const sources = [];
3392
+ let confidence = 0;
3393
+ const deps = collectAllDependencies(pkg);
3394
+ // jsdoc package
3395
+ if (deps['jsdoc']) {
3396
+ confidence += 30;
3397
+ sources.push({ type: 'package.json', field: 'dependencies.jsdoc' });
3398
+ }
3399
+ // typescript with checkJs (JSDoc type checking)
3400
+ if (deps['typescript']) {
3401
+ // Check if checkJs is enabled in tsconfig
3402
+ const tsconfigPath = node_path.join(projectPath, 'tsconfig.json');
3403
+ const content = readFileIfExists(tsconfigPath);
3404
+ if (content) {
3405
+ try {
3406
+ const cleanContent = content.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '');
3407
+ const parsed = parse(cleanContent);
3408
+ if (parsed?.compilerOptions?.checkJs === true || parsed?.compilerOptions?.allowJs === true) {
3409
+ confidence += 30;
3410
+ sources.push({ type: 'config-file', path: 'tsconfig.json (checkJs/allowJs)' });
3411
+ }
3412
+ }
3413
+ catch {
3414
+ // Ignore parsing errors
3415
+ }
3416
+ }
3417
+ }
3418
+ // Check for jsconfig.json (VS Code JS type checking)
3419
+ if (exists(node_path.join(projectPath, 'jsconfig.json'))) {
3420
+ confidence += 40;
3421
+ sources.push({ type: 'config-file', path: 'jsconfig.json' });
3422
+ }
3423
+ // Sample check for JSDoc annotations in source files
3424
+ const srcDir = node_path.join(projectPath, 'src');
3425
+ if (exists(srcDir)) {
3426
+ try {
3427
+ const entries = readDirectory(srcDir);
3428
+ const files = entries.filter((e) => e.isFile && (e.name.endsWith('.js') || e.name.endsWith('.mjs'))).map((e) => e.name);
3429
+ for (const file of files.slice(0, 3)) {
3430
+ const content = readFileIfExists(node_path.join(srcDir, file));
3431
+ if (content && hasJsDocTypes(content)) {
3432
+ confidence += 20;
3433
+ sources.push({ type: 'directory', path: `src/${file} (JSDoc annotations)` });
3434
+ break;
3435
+ }
3436
+ }
3437
+ }
3438
+ catch {
3439
+ // Ignore directory read errors
3440
+ }
3441
+ }
3442
+ if (confidence === 0) {
3443
+ return null;
3444
+ }
3445
+ return {
3446
+ id: 'jsdoc',
3447
+ name: 'JSDoc',
3448
+ confidence: min(confidence, 100),
3449
+ detectedFrom: sources,
3450
+ };
3451
+ }
3452
+ /** All type system detectors */
3453
+ const typeSystemDetectors = [
3454
+ { id: 'typescript', name: 'TypeScript', detect: typescriptDetector },
3455
+ { id: 'flow', name: 'Flow', detect: flowDetector },
3456
+ { id: 'jsdoc', name: 'JSDoc', detect: jsdocDetector },
3457
+ ];
3458
+ /**
3459
+ * Detect all type systems in project.
3460
+ *
3461
+ * @param projectPath - Project directory path
3462
+ * @param packageJson - Optional pre-loaded package.json
3463
+ * @returns Array of detected type systems, sorted by confidence
3464
+ */
3465
+ function detectTypeSystems(projectPath, packageJson) {
3466
+ const pkg = packageJson ?? readPackageJsonIfExists(projectPath);
3467
+ const results = [];
3468
+ for (const detector of typeSystemDetectors) {
3469
+ const detection = detector.detect(projectPath, pkg ?? undefined);
3470
+ if (detection) {
3471
+ results.push(detection);
3472
+ }
3473
+ }
3474
+ return results.sort((a, b) => b.confidence - a.confidence);
3475
+ }
3476
+
3477
+ const techLogger = createScopedLogger('project-scope:tech');
3478
+ /**
3479
+ * Cache for tech detection results.
3480
+ * TTL: 60 seconds (tech stack can change during active development)
3481
+ */
3482
+ const detectAllCache = createCache({ ttl: 60000, maxSize: 50 });
3483
+ /**
3484
+ * All available detectors organized by category.
3485
+ */
3486
+ const allDetectors = {
3487
+ build: buildToolDetectors,
3488
+ monorepo: monorepoDetectors,
3489
+ frontend: frameworkDetectors,
3490
+ backend: backendDetectors,
3491
+ legacy: legacyDetectors,
3492
+ testing: testingDetectors,
3493
+ types: typeSystemDetectors,
3494
+ linting: lintingDetectors,
3495
+ };
3496
+ /**
3497
+ * Check if the value is a DetectAllOptions object.
3498
+ *
3499
+ * @param value - Value to check
3500
+ * @returns True if value is DetectAllOptions
3501
+ */
3502
+ function isDetectAllOptions(value) {
3503
+ if (typeof value !== 'object' || value === null)
3504
+ return false;
3505
+ // DetectAllOptions has skipCache or packageJson fields specifically
3506
+ // PackageJson never has skipCache field
3507
+ return 'skipCache' in value || 'packageJson' in value;
3508
+ }
3509
+ /**
3510
+ * Run all technology detectors on a project.
3511
+ *
3512
+ * Results are cached for 60 seconds per project path to avoid
3513
+ * redundant file system operations on repeated calls.
3514
+ *
3515
+ * @param projectPath - Path to project directory
3516
+ * @param packageJsonOrOptions - Optional pre-loaded package.json or options object
3517
+ * @returns All detection results organized by category
3518
+ *
3519
+ * @example
3520
+ * ```typescript
3521
+ * import { detectAll } from '@hyperfrontend/project-scope'
3522
+ *
3523
+ * const detections = detectAll('./my-project')
3524
+ *
3525
+ * // Check frontend frameworks
3526
+ * for (const fw of detections.frontendFrameworks) {
3527
+ * console.log(`${fw.name} v${fw.version} (${fw.confidence}% confidence)`)
3528
+ * }
3529
+ *
3530
+ * // Check build tools
3531
+ * console.log('Build tools:', detections.buildTools.map(t => t.name))
3532
+ *
3533
+ * // Check testing frameworks
3534
+ * console.log('Testing:', detections.testingFrameworks.map(t => t.name))
3535
+ * ```
3536
+ */
3537
+ function detectAll(projectPath, packageJsonOrOptions) {
3538
+ // Handle backward-compatible arguments
3539
+ const options = isDetectAllOptions(packageJsonOrOptions) ? packageJsonOrOptions : { packageJson: packageJsonOrOptions };
3540
+ // Check cache first (unless skipCache is true)
3541
+ if (!options.skipCache) {
3542
+ const cached = detectAllCache.get(projectPath);
3543
+ if (cached) {
3544
+ techLogger.debug('Returning cached tech detection results', { projectPath });
3545
+ return cached;
3546
+ }
3547
+ }
3548
+ const pkg = options.packageJson ?? readPackageJsonIfExists(projectPath);
3549
+ techLogger.debug('Running all tech detectors', { projectPath });
3550
+ const result = {
3551
+ buildTools: buildToolDetectors
3552
+ .map((d) => d.detect(projectPath, pkg ?? undefined))
3553
+ .filter((r) => r !== null)
3554
+ .sort((a, b) => b.confidence - a.confidence),
3555
+ monorepo: monorepoDetectors
3556
+ .map((d) => d.detect(projectPath, pkg ?? undefined))
3557
+ .filter((r) => r !== null)
3558
+ .sort((a, b) => b.confidence - a.confidence),
3559
+ frontendFrameworks: frameworkDetectors
3560
+ .map((d) => d.detect(projectPath, pkg ?? undefined))
3561
+ .filter((r) => r !== null)
3562
+ .sort((a, b) => b.confidence - a.confidence),
3563
+ backendFrameworks: backendDetectors
3564
+ .map((d) => d.detect(projectPath, pkg ?? undefined))
3565
+ .filter((r) => r !== null)
3566
+ .sort((a, b) => b.confidence - a.confidence),
3567
+ legacyFrameworks: legacyDetectors
3568
+ .map((d) => d.detect(projectPath, pkg ?? undefined))
3569
+ .filter((r) => r !== null)
3570
+ .sort((a, b) => b.confidence - a.confidence),
3571
+ testingFrameworks: testingDetectors
3572
+ .map((d) => d.detect(projectPath, pkg ?? undefined))
3573
+ .filter((r) => r !== null)
3574
+ .sort((a, b) => b.confidence - a.confidence),
3575
+ typeSystem: typeSystemDetectors
3576
+ .map((d) => d.detect(projectPath, pkg ?? undefined))
3577
+ .filter((r) => r !== null)
3578
+ .sort((a, b) => b.confidence - a.confidence),
3579
+ linting: lintingDetectors
3580
+ .map((d) => d.detect(projectPath, pkg ?? undefined))
3581
+ .filter((r) => r !== null)
3582
+ .sort((a, b) => b.confidence - a.confidence),
3583
+ };
3584
+ techLogger.debug('Tech detection complete', {
3585
+ buildTools: result.buildTools.map((t) => t.id),
3586
+ frontendFrameworks: result.frontendFrameworks.map((f) => f.id),
3587
+ backendFrameworks: result.backendFrameworks.map((f) => f.id),
3588
+ legacyFrameworks: result.legacyFrameworks.map((f) => f.id),
3589
+ testingFrameworks: result.testingFrameworks.map((f) => f.id),
3590
+ });
3591
+ // Cache the result
3592
+ detectAllCache.set(projectPath, result);
3593
+ return result;
3594
+ }
3595
+ /**
3596
+ * Clear the tech detection cache.
3597
+ *
3598
+ * Useful for testing or when the project files have changed.
3599
+ */
3600
+ function clearTechDetectionCache() {
3601
+ detectAllCache.clear();
3602
+ }
3603
+
3604
+ exports.BABEL_CONFIG_PATTERNS = BABEL_CONFIG_PATTERNS;
3605
+ exports.CYPRESS_CONFIG_PATTERNS = CYPRESS_CONFIG_PATTERNS;
3606
+ exports.ESLINT_CONFIG_PATTERNS = ESLINT_CONFIG_PATTERNS;
3607
+ exports.JEST_CONFIG_PATTERNS = JEST_CONFIG_PATTERNS;
3608
+ exports.MOCHA_CONFIG_PATTERNS = MOCHA_CONFIG_PATTERNS;
3609
+ exports.PARCEL_CONFIG_PATTERNS = PARCEL_CONFIG_PATTERNS;
3610
+ exports.PLAYWRIGHT_CONFIG_PATTERNS = PLAYWRIGHT_CONFIG_PATTERNS;
3611
+ exports.PRETTIER_CONFIG_PATTERNS = PRETTIER_CONFIG_PATTERNS;
3612
+ exports.ROLLUP_CONFIG_PATTERNS = ROLLUP_CONFIG_PATTERNS;
3613
+ exports.STYLELINT_CONFIG_PATTERNS = STYLELINT_CONFIG_PATTERNS;
3614
+ exports.SWC_CONFIG_PATTERNS = SWC_CONFIG_PATTERNS;
3615
+ exports.VITEST_CONFIG_PATTERNS = VITEST_CONFIG_PATTERNS;
3616
+ exports.VITE_CONFIG_PATTERNS = VITE_CONFIG_PATTERNS;
3617
+ exports.WEBPACK_CONFIG_PATTERNS = WEBPACK_CONFIG_PATTERNS;
3618
+ exports.allDetectors = allDetectors;
3619
+ exports.angularDetector = angularDetector;
3620
+ exports.angularJSDetector = angularJSDetector;
3621
+ exports.astroDetector = astroDetector;
3622
+ exports.babelDetector = babelDetector;
3623
+ exports.backboneDetector = backboneDetector;
3624
+ exports.backendDetectors = backendDetectors;
3625
+ exports.biomeDetector = biomeDetector;
3626
+ exports.buildToolDetectors = buildToolDetectors;
3627
+ exports.clearTechDetectionCache = clearTechDetectionCache;
3628
+ exports.cypressDetector = cypressDetector;
3629
+ exports.detectAll = detectAll;
3630
+ exports.detectBackendFrameworks = detectBackendFrameworks;
3631
+ exports.detectBuildTools = detectBuildTools;
3632
+ exports.detectFrontendFrameworks = detectFrontendFrameworks;
3633
+ exports.detectLegacyFrameworks = detectLegacyFrameworks;
3634
+ exports.detectLintingTools = detectLintingTools;
3635
+ exports.detectMonorepoTools = detectMonorepoTools;
3636
+ exports.detectTestingFrameworks = detectTestingFrameworks;
3637
+ exports.detectTypeSystems = detectTypeSystems;
3638
+ exports.emberDetector = emberDetector;
3639
+ exports.esbuildDetector = esbuildDetector;
3640
+ exports.eslintDetector = eslintDetector;
3641
+ exports.expressDetector = expressDetector;
3642
+ exports.fastifyDetector = fastifyDetector;
3643
+ exports.flowDetector = flowDetector;
3644
+ exports.frameworkDetectors = frameworkDetectors;
3645
+ exports.gatsbyDetector = gatsbyDetector;
3646
+ exports.honoDetector = honoDetector;
3647
+ exports.jestDetector = jestDetector;
3648
+ exports.jqueryDetector = jqueryDetector;
3649
+ exports.jsdocDetector = jsdocDetector;
3650
+ exports.koaDetector = koaDetector;
3651
+ exports.legacyDetectors = legacyDetectors;
3652
+ exports.lernaDetector = lernaDetector;
3653
+ exports.lintingDetectors = lintingDetectors;
3654
+ exports.mochaDetector = mochaDetector;
3655
+ exports.monorepoDetectors = monorepoDetectors;
3656
+ exports.nestDetector = nestDetector;
3657
+ exports.nextjsDetector = nextjsDetector;
3658
+ exports.npmWorkspacesDetector = npmWorkspacesDetector;
3659
+ exports.nuxtDetector = nuxtDetector;
3660
+ exports.nxDetector = nxDetector;
3661
+ exports.parcelDetector = parcelDetector;
3662
+ exports.playwrightDetector = playwrightDetector;
3663
+ exports.pnpmWorkspacesDetector = pnpmWorkspacesDetector;
3664
+ exports.prettierDetector = prettierDetector;
3665
+ exports.qwikDetector = qwikDetector;
3666
+ exports.reactDetector = reactDetector;
3667
+ exports.remixDetector = remixDetector;
3668
+ exports.rollupDetector = rollupDetector;
3669
+ exports.rushDetector = rushDetector;
3670
+ exports.solidDetector = solidDetector;
3671
+ exports.stylelintDetector = stylelintDetector;
3672
+ exports.svelteDetector = svelteDetector;
3673
+ exports.sveltekitDetector = sveltekitDetector;
3674
+ exports.swcDetector = swcDetector;
3675
+ exports.testingDetectors = testingDetectors;
3676
+ exports.turborepoDetector = turborepoDetector;
3677
+ exports.typeSystemDetectors = typeSystemDetectors;
3678
+ exports.typescriptDetector = typescriptDetector;
3679
+ exports.viteDetector = viteDetector;
3680
+ exports.vitestDetector = vitestDetector;
3681
+ exports.vueDetector = vueDetector;
3682
+ exports.webpackDetector = webpackDetector;
3683
+ exports.yarnWorkspacesDetector = yarnWorkspacesDetector;
3684
+ //# sourceMappingURL=index.cjs.js.map