genaicode 0.5.1 → 0.6.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 (626) hide show
  1. package/README.md +6 -10
  2. package/dist/ai-service/anthropic.js +7 -2
  3. package/dist/ai-service/anthropic.js.map +1 -1
  4. package/dist/ai-service/chat-gpt.d.ts +2 -0
  5. package/dist/ai-service/chat-gpt.js +7 -4
  6. package/dist/ai-service/chat-gpt.js.map +1 -1
  7. package/dist/ai-service/common.test.js +2 -1
  8. package/dist/ai-service/common.test.js.map +1 -1
  9. package/dist/ai-service/dall-e.js +1 -0
  10. package/dist/ai-service/dall-e.js.map +1 -1
  11. package/dist/ai-service/vertex-ai-claude.js +1 -0
  12. package/dist/ai-service/vertex-ai-claude.js.map +1 -1
  13. package/dist/cli/cli-options.js +10 -22
  14. package/dist/cli/cli-options.js.map +1 -1
  15. package/dist/cli/cli-params.d.ts +1 -5
  16. package/dist/cli/cli-params.js +10 -29
  17. package/dist/cli/cli-params.js.map +1 -1
  18. package/dist/cli/validate-cli-params.js +16 -11
  19. package/dist/cli/validate-cli-params.js.map +1 -1
  20. package/dist/cli/validate-cli-params.test.js +2 -2
  21. package/dist/cli/validate-cli-params.test.js.map +1 -1
  22. package/dist/examples/genaicode_plugins/fake_ai_service.d.ts +3 -0
  23. package/dist/examples/genaicode_plugins/fake_ai_service.js +11 -0
  24. package/dist/examples/genaicode_plugins/fake_ai_service.js.map +1 -0
  25. package/dist/examples/genaicode_plugins/grok_ai_service.d.ts +3 -0
  26. package/dist/examples/genaicode_plugins/grok_ai_service.js +153 -0
  27. package/dist/examples/genaicode_plugins/grok_ai_service.js.map +1 -0
  28. package/dist/examples/genaicode_plugins/nonsense_operation.d.ts +3 -0
  29. package/dist/examples/genaicode_plugins/nonsense_operation.js +23 -0
  30. package/dist/examples/genaicode_plugins/nonsense_operation.js.map +1 -0
  31. package/dist/files/path-utils.d.ts +1 -0
  32. package/dist/files/path-utils.js +12 -0
  33. package/dist/files/path-utils.js.map +1 -0
  34. package/dist/files/update-files.d.ts +1 -1
  35. package/dist/files/update-files.js +8 -183
  36. package/dist/files/update-files.js.map +1 -1
  37. package/dist/index.d.ts +6 -1
  38. package/dist/index.js +6 -0
  39. package/dist/index.js.map +1 -1
  40. package/dist/main/codegen-types.d.ts +29 -1
  41. package/dist/main/codegen-utils.d.ts +3 -0
  42. package/dist/main/codegen-utils.js +18 -0
  43. package/dist/main/codegen-utils.js.map +1 -0
  44. package/dist/main/codegen.js +14 -25
  45. package/dist/main/codegen.js.map +1 -1
  46. package/dist/main/codegen.test.js +12 -15
  47. package/dist/main/codegen.test.js.map +1 -1
  48. package/dist/main/common/user-actions.d.ts +14 -2
  49. package/dist/main/common/user-actions.js +16 -1
  50. package/dist/main/common/user-actions.js.map +1 -1
  51. package/dist/main/config-lib.d.ts +1 -0
  52. package/dist/main/config-lib.js +7 -0
  53. package/dist/main/config-lib.js.map +1 -1
  54. package/dist/main/config.js +3 -0
  55. package/dist/main/config.js.map +1 -1
  56. package/dist/main/interactive/user-action-handlers.js +2 -2
  57. package/dist/main/interactive/user-action-handlers.js.map +1 -1
  58. package/dist/main/plugin-loader.d.ts +9 -0
  59. package/dist/main/plugin-loader.js +55 -0
  60. package/dist/main/plugin-loader.js.map +1 -0
  61. package/dist/main/ui/backend/api-utils.js +2 -2
  62. package/dist/main/ui/backend/api-utils.js.map +1 -1
  63. package/dist/main/ui/backend/api.js +15 -3
  64. package/dist/main/ui/backend/api.js.map +1 -1
  65. package/dist/main/ui/backend/service.d.ts +6 -11
  66. package/dist/main/ui/backend/service.js +11 -7
  67. package/dist/main/ui/backend/service.js.map +1 -1
  68. package/dist/main/ui/common/api-types.d.ts +20 -0
  69. package/dist/main/ui/common/api-types.js +2 -0
  70. package/dist/main/ui/common/api-types.js.map +1 -0
  71. package/dist/main/ui/frontend/assets/{index-Dicb_1yw.js → index-Dk_qaEQg.js} +75 -72
  72. package/dist/main/ui/frontend/index.html +1 -1
  73. package/dist/main/ui/user-action-handlers.js +9 -4
  74. package/dist/main/ui/user-action-handlers.js.map +1 -1
  75. package/dist/operations/create-directory/create-directory-def.d.ts +9 -0
  76. package/dist/operations/create-directory/create-directory-def.js +22 -0
  77. package/dist/operations/create-directory/create-directory-def.js.map +1 -0
  78. package/dist/operations/create-directory/create-directory-executor.d.ts +6 -0
  79. package/dist/operations/create-directory/create-directory-executor.js +22 -0
  80. package/dist/operations/create-directory/create-directory-executor.js.map +1 -0
  81. package/dist/operations/create-file/create-file-def.d.ts +10 -0
  82. package/dist/operations/create-file/create-file-def.js +26 -0
  83. package/dist/operations/create-file/create-file-def.js.map +1 -0
  84. package/dist/operations/create-file/create-file-executor.d.ts +6 -0
  85. package/dist/operations/create-file/create-file-executor.js +27 -0
  86. package/dist/operations/create-file/create-file-executor.js.map +1 -0
  87. package/dist/operations/delete-file/delete-file-def.d.ts +9 -0
  88. package/dist/operations/delete-file/delete-file-def.js +22 -0
  89. package/dist/operations/delete-file/delete-file-def.js.map +1 -0
  90. package/dist/operations/delete-file/delete-file-executor.d.ts +6 -0
  91. package/dist/operations/delete-file/delete-file-executor.js +23 -0
  92. package/dist/operations/delete-file/delete-file-executor.js.map +1 -0
  93. package/dist/operations/download-file/download-file-def.d.ts +10 -0
  94. package/dist/operations/download-file/download-file-def.js +26 -0
  95. package/dist/operations/download-file/download-file-def.js.map +1 -0
  96. package/dist/operations/download-file/download-file-executor.d.ts +6 -0
  97. package/dist/operations/download-file/download-file-executor.js +44 -0
  98. package/dist/operations/download-file/download-file-executor.js.map +1 -0
  99. package/dist/operations/imgly-remove-background/imgly-remove-background-def.d.ts +10 -0
  100. package/dist/operations/imgly-remove-background/imgly-remove-background-def.js +26 -0
  101. package/dist/operations/imgly-remove-background/imgly-remove-background-def.js.map +1 -0
  102. package/dist/operations/imgly-remove-background/imgly-remove-background-executor.d.ts +6 -0
  103. package/dist/operations/imgly-remove-background/imgly-remove-background-executor.js +40 -0
  104. package/dist/operations/imgly-remove-background/imgly-remove-background-executor.js.map +1 -0
  105. package/dist/operations/move-file/move-file-def.d.ts +10 -0
  106. package/dist/operations/move-file/move-file-def.js +26 -0
  107. package/dist/operations/move-file/move-file-def.js.map +1 -0
  108. package/dist/operations/move-file/move-file-executor.d.ts +6 -0
  109. package/dist/operations/move-file/move-file-executor.js +29 -0
  110. package/dist/operations/move-file/move-file-executor.js.map +1 -0
  111. package/dist/operations/operations-index.d.ts +3 -0
  112. package/dist/operations/operations-index.js +33 -0
  113. package/dist/operations/operations-index.js.map +1 -0
  114. package/dist/operations/patch-file/patch-file-def.d.ts +10 -0
  115. package/dist/operations/patch-file/patch-file-def.js +39 -0
  116. package/dist/operations/patch-file/patch-file-def.js.map +1 -0
  117. package/dist/operations/patch-file/patch-file-executor.d.ts +5 -0
  118. package/dist/operations/patch-file/patch-file-executor.js +26 -0
  119. package/dist/operations/patch-file/patch-file-executor.js.map +1 -0
  120. package/dist/operations/resize-image/resize-image-def.d.ts +13 -0
  121. package/dist/operations/resize-image/resize-image-def.js +37 -0
  122. package/dist/operations/resize-image/resize-image-def.js.map +1 -0
  123. package/dist/operations/resize-image/resize-image-executor.d.ts +5 -0
  124. package/dist/operations/resize-image/resize-image-executor.js +30 -0
  125. package/dist/operations/resize-image/resize-image-executor.js.map +1 -0
  126. package/dist/operations/split-image/split-image-def.d.ts +18 -0
  127. package/dist/operations/split-image/split-image-def.js +46 -0
  128. package/dist/operations/split-image/split-image-def.js.map +1 -0
  129. package/dist/operations/split-image/split-image-executor.d.ts +6 -0
  130. package/dist/operations/split-image/split-image-executor.js +51 -0
  131. package/dist/operations/split-image/split-image-executor.js.map +1 -0
  132. package/dist/operations/update-file/update-file-def.d.ts +10 -0
  133. package/dist/operations/update-file/update-file-def.js +26 -0
  134. package/dist/operations/update-file/update-file-def.js.map +1 -0
  135. package/dist/operations/update-file/update-file-executor.d.ts +5 -0
  136. package/dist/operations/update-file/update-file-executor.js +22 -0
  137. package/dist/operations/update-file/update-file-executor.js.map +1 -0
  138. package/dist/prompt/ai-service-fallback.js.map +1 -1
  139. package/dist/prompt/function-calling-validate.js +2 -2
  140. package/dist/prompt/function-calling-validate.js.map +1 -1
  141. package/dist/prompt/function-calling.d.ts +1 -1
  142. package/dist/prompt/function-calling.js +29 -44
  143. package/dist/prompt/function-calling.js.map +1 -1
  144. package/dist/prompt/function-defs/ask-question-reflect.d.ts +2 -20
  145. package/dist/prompt/function-defs/ask-question-reflect.js.map +1 -1
  146. package/dist/prompt/function-defs/ask-question.d.ts +2 -73
  147. package/dist/prompt/function-defs/ask-question.js +28 -14
  148. package/dist/prompt/function-defs/ask-question.js.map +1 -1
  149. package/dist/prompt/function-defs/codegen-summary.d.ts +2 -62
  150. package/dist/prompt/function-defs/codegen-summary.js +4 -2
  151. package/dist/prompt/function-defs/codegen-summary.js.map +1 -1
  152. package/dist/prompt/function-defs/explanation.d.ts +2 -14
  153. package/dist/prompt/function-defs/explanation.js.map +1 -1
  154. package/dist/prompt/function-defs/generate-image.d.ts +2 -38
  155. package/dist/prompt/function-defs/generate-image.js.map +1 -1
  156. package/dist/prompt/function-defs/get-image-assets.d.ts +2 -17
  157. package/dist/prompt/function-defs/get-image-assets.js.map +1 -1
  158. package/dist/prompt/function-defs/get-source-code.d.ts +2 -17
  159. package/dist/prompt/function-defs/get-source-code.js.map +1 -1
  160. package/dist/prompt/function-defs/optimize-context.d.ts +2 -43
  161. package/dist/prompt/function-defs/optimize-context.js.map +1 -1
  162. package/dist/prompt/function-defs/read-history.d.ts +2 -13
  163. package/dist/prompt/function-defs/read-history.js.map +1 -1
  164. package/dist/prompt/function-defs/set-summaries.d.ts +2 -28
  165. package/dist/prompt/function-defs/set-summaries.js.map +1 -1
  166. package/dist/prompt/function-defs/update-history.d.ts +2 -18
  167. package/dist/prompt/function-defs/update-history.js.map +1 -1
  168. package/dist/prompt/prompt-service.js +6 -6
  169. package/dist/prompt/prompt-service.js.map +1 -1
  170. package/dist/prompt/prompt-service.test.js +16 -19
  171. package/dist/prompt/prompt-service.test.js.map +1 -1
  172. package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.d.ts +2 -0
  173. package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js +16 -0
  174. package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js.map +1 -0
  175. package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.d.ts +2 -0
  176. package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.js +37 -0
  177. package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.js.map +1 -0
  178. package/dist/prompt/steps/step-ask-question/handlers/context-optimization.d.ts +2 -0
  179. package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js +36 -0
  180. package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js.map +1 -0
  181. package/dist/prompt/steps/step-ask-question/handlers/default-action.d.ts +2 -0
  182. package/dist/prompt/steps/step-ask-question/handlers/default-action.js +18 -0
  183. package/dist/prompt/steps/step-ask-question/handlers/default-action.js.map +1 -0
  184. package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer.d.ts +2 -0
  185. package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer.js +20 -0
  186. package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer.js.map +1 -0
  187. package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.d.ts +2 -0
  188. package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.js +43 -0
  189. package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.js.map +1 -0
  190. package/dist/prompt/steps/step-ask-question/handlers/request-files-content.d.ts +2 -0
  191. package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js +49 -0
  192. package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js.map +1 -0
  193. package/dist/prompt/steps/step-ask-question/handlers/request-permissions.d.ts +2 -0
  194. package/dist/prompt/steps/step-ask-question/handlers/request-permissions.js +46 -0
  195. package/dist/prompt/steps/step-ask-question/handlers/request-permissions.js.map +1 -0
  196. package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.d.ts +2 -0
  197. package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.js +16 -0
  198. package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.js.map +1 -0
  199. package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.d.ts +0 -0
  200. package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.js +2 -0
  201. package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.js.map +1 -0
  202. package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.d.ts +4 -0
  203. package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.js +91 -0
  204. package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.js.map +1 -0
  205. package/dist/prompt/steps/step-ask-question/step-ask-question-types.d.ts +56 -0
  206. package/dist/prompt/steps/step-ask-question/step-ask-question-types.js +2 -0
  207. package/dist/prompt/steps/step-ask-question/step-ask-question-types.js.map +1 -0
  208. package/dist/prompt/steps/step-ask-question/step-ask-question.d.ts +6 -0
  209. package/dist/prompt/steps/step-ask-question/step-ask-question.js +95 -0
  210. package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -0
  211. package/dist/prompt/steps/step-context-optimization.js +9 -2
  212. package/dist/prompt/steps/step-context-optimization.js.map +1 -1
  213. package/dist/prompt/steps/step-generate-summary.js +2 -2
  214. package/dist/prompt/steps/step-generate-summary.js.map +1 -1
  215. package/dist/prompt/steps/step-history-update.js +2 -2
  216. package/dist/prompt/steps/step-history-update.js.map +1 -1
  217. package/dist/prompt/steps/step-summarization.js +2 -2
  218. package/dist/prompt/steps/step-summarization.js.map +1 -1
  219. package/dist/src/ai-service/ai-studio.d.ts +6 -0
  220. package/dist/src/ai-service/ai-studio.js +190 -0
  221. package/dist/src/ai-service/ai-studio.js.map +1 -0
  222. package/dist/src/ai-service/anthropic.d.ts +6 -0
  223. package/dist/src/ai-service/anthropic.js +150 -0
  224. package/dist/src/ai-service/anthropic.js.map +1 -0
  225. package/dist/src/ai-service/chat-gpt.d.ts +5 -0
  226. package/dist/src/ai-service/chat-gpt.js +146 -0
  227. package/dist/src/ai-service/chat-gpt.js.map +1 -0
  228. package/dist/src/ai-service/common.d.ts +69 -0
  229. package/dist/src/ai-service/common.js +38 -0
  230. package/dist/src/ai-service/common.js.map +1 -0
  231. package/dist/src/ai-service/common.test.d.ts +1 -0
  232. package/dist/src/ai-service/common.test.js +86 -0
  233. package/dist/src/ai-service/common.test.js.map +1 -0
  234. package/dist/src/ai-service/dall-e.d.ts +14 -0
  235. package/dist/src/ai-service/dall-e.js +50 -0
  236. package/dist/src/ai-service/dall-e.js.map +1 -0
  237. package/dist/src/ai-service/unescape-function-call.d.ts +7 -0
  238. package/dist/src/ai-service/unescape-function-call.js +59 -0
  239. package/dist/src/ai-service/unescape-function-call.js.map +1 -0
  240. package/dist/src/ai-service/unescape-function-call.test.d.ts +1 -0
  241. package/dist/src/ai-service/unescape-function-call.test.js +18 -0
  242. package/dist/src/ai-service/unescape-function-call.test.js.map +1 -0
  243. package/dist/src/ai-service/vertex-ai-claude.d.ts +5 -0
  244. package/dist/src/ai-service/vertex-ai-claude.js +104 -0
  245. package/dist/src/ai-service/vertex-ai-claude.js.map +1 -0
  246. package/dist/src/ai-service/vertex-ai-imagen.d.ts +14 -0
  247. package/dist/src/ai-service/vertex-ai-imagen.js +77 -0
  248. package/dist/src/ai-service/vertex-ai-imagen.js.map +1 -0
  249. package/dist/src/ai-service/vertex-ai.d.ts +6 -0
  250. package/dist/src/ai-service/vertex-ai.js +202 -0
  251. package/dist/src/ai-service/vertex-ai.js.map +1 -0
  252. package/dist/src/cli/cli-options.d.ts +10 -0
  253. package/dist/src/cli/cli-options.js +132 -0
  254. package/dist/src/cli/cli-options.js.map +1 -0
  255. package/dist/src/cli/cli-options.test.d.ts +1 -0
  256. package/dist/src/cli/cli-options.test.js +34 -0
  257. package/dist/src/cli/cli-options.test.js.map +1 -0
  258. package/dist/src/cli/cli-params.d.ts +32 -0
  259. package/dist/src/cli/cli-params.js +106 -0
  260. package/dist/src/cli/cli-params.js.map +1 -0
  261. package/dist/src/cli/cli-params.test.d.ts +1 -0
  262. package/dist/src/cli/cli-params.test.js +38 -0
  263. package/dist/src/cli/cli-params.test.js.map +1 -0
  264. package/dist/src/cli/service-autodetect.d.ts +2 -0
  265. package/dist/src/cli/service-autodetect.js +17 -0
  266. package/dist/src/cli/service-autodetect.js.map +1 -0
  267. package/dist/src/cli/service-autodetect.test.d.ts +1 -0
  268. package/dist/src/cli/service-autodetect.test.js +38 -0
  269. package/dist/src/cli/service-autodetect.test.js.map +1 -0
  270. package/dist/src/cli/validate-cli-params.d.ts +18 -0
  271. package/dist/src/cli/validate-cli-params.js +145 -0
  272. package/dist/src/cli/validate-cli-params.js.map +1 -0
  273. package/dist/src/cli/validate-cli-params.test.d.ts +1 -0
  274. package/dist/src/cli/validate-cli-params.test.js +106 -0
  275. package/dist/src/cli/validate-cli-params.test.js.map +1 -0
  276. package/dist/src/files/cache-file.d.ts +3 -0
  277. package/dist/src/files/cache-file.js +36 -0
  278. package/dist/src/files/cache-file.js.map +1 -0
  279. package/dist/src/files/file-utils.d.ts +2 -0
  280. package/dist/src/files/file-utils.js +7 -0
  281. package/dist/src/files/file-utils.js.map +1 -0
  282. package/dist/src/files/file-utils.test.d.ts +1 -0
  283. package/dist/src/files/file-utils.test.js +18 -0
  284. package/dist/src/files/file-utils.test.js.map +1 -0
  285. package/dist/src/files/find-files.d.ts +9 -0
  286. package/dist/src/files/find-files.js +81 -0
  287. package/dist/src/files/find-files.js.map +1 -0
  288. package/dist/src/files/path-utils.d.ts +1 -0
  289. package/dist/src/files/path-utils.js +12 -0
  290. package/dist/src/files/path-utils.js.map +1 -0
  291. package/dist/src/files/read-files.d.ts +21 -0
  292. package/dist/src/files/read-files.js +68 -0
  293. package/dist/src/files/read-files.js.map +1 -0
  294. package/dist/src/files/read-files.test.d.ts +1 -0
  295. package/dist/src/files/read-files.test.js +89 -0
  296. package/dist/src/files/read-files.test.js.map +1 -0
  297. package/dist/src/files/temp-buffer.d.ts +2 -0
  298. package/dist/src/files/temp-buffer.js +12 -0
  299. package/dist/src/files/temp-buffer.js.map +1 -0
  300. package/dist/src/files/update-files.d.ts +6 -0
  301. package/dist/src/files/update-files.js +19 -0
  302. package/dist/src/files/update-files.js.map +1 -0
  303. package/dist/src/images/ensure-alpha.d.ts +1 -0
  304. package/dist/src/images/ensure-alpha.js +5 -0
  305. package/dist/src/images/ensure-alpha.js.map +1 -0
  306. package/dist/src/images/imgly-remove-background.d.ts +2 -0
  307. package/dist/src/images/imgly-remove-background.js +21 -0
  308. package/dist/src/images/imgly-remove-background.js.map +1 -0
  309. package/dist/src/images/resize-image.d.ts +19 -0
  310. package/dist/src/images/resize-image.js +22 -0
  311. package/dist/src/images/resize-image.js.map +1 -0
  312. package/dist/src/images/split-image.d.ts +18 -0
  313. package/dist/src/images/split-image.js +25 -0
  314. package/dist/src/images/split-image.js.map +1 -0
  315. package/dist/src/index.d.ts +3 -0
  316. package/dist/src/index.js +3 -0
  317. package/dist/src/index.js.map +1 -0
  318. package/dist/src/main/codegen-types.d.ts +58 -0
  319. package/dist/src/main/codegen-types.js +2 -0
  320. package/dist/src/main/codegen-types.js.map +1 -0
  321. package/dist/src/main/codegen-utils.d.ts +3 -0
  322. package/dist/src/main/codegen-utils.js +18 -0
  323. package/dist/src/main/codegen-utils.js.map +1 -0
  324. package/dist/src/main/codegen.d.ts +4 -0
  325. package/dist/src/main/codegen.js +201 -0
  326. package/dist/src/main/codegen.js.map +1 -0
  327. package/dist/src/main/codegen.test.d.ts +3 -0
  328. package/dist/src/main/codegen.test.js +288 -0
  329. package/dist/src/main/codegen.test.js.map +1 -0
  330. package/dist/src/main/common/content-bus-types.d.ts +21 -0
  331. package/dist/src/main/common/content-bus-types.js +11 -0
  332. package/dist/src/main/common/content-bus-types.js.map +1 -0
  333. package/dist/src/main/common/content-bus.d.ts +10 -0
  334. package/dist/src/main/common/content-bus.js +39 -0
  335. package/dist/src/main/common/content-bus.js.map +1 -0
  336. package/dist/src/main/common/cost-collector.d.ts +11 -0
  337. package/dist/src/main/common/cost-collector.js +90 -0
  338. package/dist/src/main/common/cost-collector.js.map +1 -0
  339. package/dist/src/main/common/user-actions.d.ts +19 -0
  340. package/dist/src/main/common/user-actions.js +30 -0
  341. package/dist/src/main/common/user-actions.js.map +1 -0
  342. package/dist/src/main/config-lib.d.ts +36 -0
  343. package/dist/src/main/config-lib.js +51 -0
  344. package/dist/src/main/config-lib.js.map +1 -0
  345. package/dist/src/main/config-lib.test.d.ts +1 -0
  346. package/dist/src/main/config-lib.test.js +64 -0
  347. package/dist/src/main/config-lib.test.js.map +1 -0
  348. package/dist/src/main/config.d.ts +7 -0
  349. package/dist/src/main/config.js +51 -0
  350. package/dist/src/main/config.js.map +1 -0
  351. package/dist/src/main/interactive/codegen-interactive.d.ts +2 -0
  352. package/dist/src/main/interactive/codegen-interactive.js +61 -0
  353. package/dist/src/main/interactive/codegen-interactive.js.map +1 -0
  354. package/dist/src/main/interactive/codegen-interactive.test.d.ts +5 -0
  355. package/dist/src/main/interactive/codegen-interactive.test.js +79 -0
  356. package/dist/src/main/interactive/codegen-interactive.test.js.map +1 -0
  357. package/dist/src/main/interactive/codegen-worker.d.ts +3 -0
  358. package/dist/src/main/interactive/codegen-worker.js +54 -0
  359. package/dist/src/main/interactive/codegen-worker.js.map +1 -0
  360. package/dist/src/main/interactive/common.d.ts +5 -0
  361. package/dist/src/main/interactive/common.js +51 -0
  362. package/dist/src/main/interactive/common.js.map +1 -0
  363. package/dist/src/main/interactive/configure.d.ts +2 -0
  364. package/dist/src/main/interactive/configure.js +99 -0
  365. package/dist/src/main/interactive/configure.js.map +1 -0
  366. package/dist/src/main/interactive/error-handling.d.ts +1 -0
  367. package/dist/src/main/interactive/error-handling.js +43 -0
  368. package/dist/src/main/interactive/error-handling.js.map +1 -0
  369. package/dist/src/main/interactive/help.d.ts +1 -0
  370. package/dist/src/main/interactive/help.js +22 -0
  371. package/dist/src/main/interactive/help.js.map +1 -0
  372. package/dist/src/main/interactive/process-comments.d.ts +2 -0
  373. package/dist/src/main/interactive/process-comments.js +39 -0
  374. package/dist/src/main/interactive/process-comments.js.map +1 -0
  375. package/dist/src/main/interactive/select-ai-service.d.ts +2 -0
  376. package/dist/src/main/interactive/select-ai-service.js +27 -0
  377. package/dist/src/main/interactive/select-ai-service.js.map +1 -0
  378. package/dist/src/main/interactive/task-file.d.ts +2 -0
  379. package/dist/src/main/interactive/task-file.js +35 -0
  380. package/dist/src/main/interactive/task-file.js.map +1 -0
  381. package/dist/src/main/interactive/text-prompt.d.ts +2 -0
  382. package/dist/src/main/interactive/text-prompt.js +18 -0
  383. package/dist/src/main/interactive/text-prompt.js.map +1 -0
  384. package/dist/src/main/interactive/user-action-handlers.d.ts +1 -0
  385. package/dist/src/main/interactive/user-action-handlers.js +13 -0
  386. package/dist/src/main/interactive/user-action-handlers.js.map +1 -0
  387. package/dist/src/main/interactive/user-interrupt.d.ts +1 -0
  388. package/dist/src/main/interactive/user-interrupt.js +36 -0
  389. package/dist/src/main/interactive/user-interrupt.js.map +1 -0
  390. package/dist/src/main/plugin-loader.d.ts +6 -0
  391. package/dist/src/main/plugin-loader.js +40 -0
  392. package/dist/src/main/plugin-loader.js.map +1 -0
  393. package/dist/src/main/ui/backend/api-utils.d.ts +2 -0
  394. package/dist/src/main/ui/backend/api-utils.js +18 -0
  395. package/dist/src/main/ui/backend/api-utils.js.map +1 -0
  396. package/dist/src/main/ui/backend/api.d.ts +2 -0
  397. package/dist/src/main/ui/backend/api.js +210 -0
  398. package/dist/src/main/ui/backend/api.js.map +1 -0
  399. package/dist/src/main/ui/backend/server.d.ts +7 -0
  400. package/dist/src/main/ui/backend/server.js +83 -0
  401. package/dist/src/main/ui/backend/server.js.map +1 -0
  402. package/dist/src/main/ui/backend/service.d.ts +44 -0
  403. package/dist/src/main/ui/backend/service.js +171 -0
  404. package/dist/src/main/ui/backend/service.js.map +1 -0
  405. package/dist/src/main/ui/codegen-ui.d.ts +2 -0
  406. package/dist/src/main/ui/codegen-ui.js +13 -0
  407. package/dist/src/main/ui/codegen-ui.js.map +1 -0
  408. package/dist/src/main/ui/common/api-types.d.ts +20 -0
  409. package/dist/src/main/ui/common/api-types.js +2 -0
  410. package/dist/src/main/ui/common/api-types.js.map +1 -0
  411. package/dist/src/main/ui/user-action-handlers.d.ts +2 -0
  412. package/dist/src/main/ui/user-action-handlers.js +14 -0
  413. package/dist/src/main/ui/user-action-handlers.js.map +1 -0
  414. package/dist/src/operations/create-directory/create-directory-def.d.ts +9 -0
  415. package/dist/src/operations/create-directory/create-directory-def.js +22 -0
  416. package/dist/src/operations/create-directory/create-directory-def.js.map +1 -0
  417. package/dist/src/operations/create-directory/create-directory-executor.d.ts +6 -0
  418. package/dist/src/operations/create-directory/create-directory-executor.js +22 -0
  419. package/dist/src/operations/create-directory/create-directory-executor.js.map +1 -0
  420. package/dist/src/operations/create-file/create-file-def.d.ts +10 -0
  421. package/dist/src/operations/create-file/create-file-def.js +26 -0
  422. package/dist/src/operations/create-file/create-file-def.js.map +1 -0
  423. package/dist/src/operations/create-file/create-file-executor.d.ts +6 -0
  424. package/dist/src/operations/create-file/create-file-executor.js +27 -0
  425. package/dist/src/operations/create-file/create-file-executor.js.map +1 -0
  426. package/dist/src/operations/delete-file/delete-file-def.d.ts +9 -0
  427. package/dist/src/operations/delete-file/delete-file-def.js +22 -0
  428. package/dist/src/operations/delete-file/delete-file-def.js.map +1 -0
  429. package/dist/src/operations/delete-file/delete-file-executor.d.ts +6 -0
  430. package/dist/src/operations/delete-file/delete-file-executor.js +23 -0
  431. package/dist/src/operations/delete-file/delete-file-executor.js.map +1 -0
  432. package/dist/src/operations/download-file/download-file-def.d.ts +10 -0
  433. package/dist/src/operations/download-file/download-file-def.js +26 -0
  434. package/dist/src/operations/download-file/download-file-def.js.map +1 -0
  435. package/dist/src/operations/download-file/download-file-executor.d.ts +6 -0
  436. package/dist/src/operations/download-file/download-file-executor.js +44 -0
  437. package/dist/src/operations/download-file/download-file-executor.js.map +1 -0
  438. package/dist/src/operations/imgly-remove-background/imgly-remove-background-def.d.ts +10 -0
  439. package/dist/src/operations/imgly-remove-background/imgly-remove-background-def.js +26 -0
  440. package/dist/src/operations/imgly-remove-background/imgly-remove-background-def.js.map +1 -0
  441. package/dist/src/operations/imgly-remove-background/imgly-remove-background-executor.d.ts +6 -0
  442. package/dist/src/operations/imgly-remove-background/imgly-remove-background-executor.js +40 -0
  443. package/dist/src/operations/imgly-remove-background/imgly-remove-background-executor.js.map +1 -0
  444. package/dist/src/operations/move-file/move-file-def.d.ts +10 -0
  445. package/dist/src/operations/move-file/move-file-def.js +26 -0
  446. package/dist/src/operations/move-file/move-file-def.js.map +1 -0
  447. package/dist/src/operations/move-file/move-file-executor.d.ts +6 -0
  448. package/dist/src/operations/move-file/move-file-executor.js +29 -0
  449. package/dist/src/operations/move-file/move-file-executor.js.map +1 -0
  450. package/dist/src/operations/operations-index.d.ts +3 -0
  451. package/dist/src/operations/operations-index.js +33 -0
  452. package/dist/src/operations/operations-index.js.map +1 -0
  453. package/dist/src/operations/patch-file/patch-file-def.d.ts +10 -0
  454. package/dist/src/operations/patch-file/patch-file-def.js +39 -0
  455. package/dist/src/operations/patch-file/patch-file-def.js.map +1 -0
  456. package/dist/src/operations/patch-file/patch-file-executor.d.ts +5 -0
  457. package/dist/src/operations/patch-file/patch-file-executor.js +26 -0
  458. package/dist/src/operations/patch-file/patch-file-executor.js.map +1 -0
  459. package/dist/src/operations/resize-image/resize-image-def.d.ts +13 -0
  460. package/dist/src/operations/resize-image/resize-image-def.js +37 -0
  461. package/dist/src/operations/resize-image/resize-image-def.js.map +1 -0
  462. package/dist/src/operations/resize-image/resize-image-executor.d.ts +5 -0
  463. package/dist/src/operations/resize-image/resize-image-executor.js +30 -0
  464. package/dist/src/operations/resize-image/resize-image-executor.js.map +1 -0
  465. package/dist/src/operations/split-image/split-image-def.d.ts +18 -0
  466. package/dist/src/operations/split-image/split-image-def.js +46 -0
  467. package/dist/src/operations/split-image/split-image-def.js.map +1 -0
  468. package/dist/src/operations/split-image/split-image-executor.d.ts +6 -0
  469. package/dist/src/operations/split-image/split-image-executor.js +51 -0
  470. package/dist/src/operations/split-image/split-image-executor.js.map +1 -0
  471. package/dist/src/operations/update-file/update-file-def.d.ts +10 -0
  472. package/dist/src/operations/update-file/update-file-def.js +26 -0
  473. package/dist/src/operations/update-file/update-file-def.js.map +1 -0
  474. package/dist/src/operations/update-file/update-file-executor.d.ts +5 -0
  475. package/dist/src/operations/update-file/update-file-executor.js +22 -0
  476. package/dist/src/operations/update-file/update-file-executor.js.map +1 -0
  477. package/dist/src/prompt/ai-service-fallback.d.ts +3 -0
  478. package/dist/src/prompt/ai-service-fallback.js +84 -0
  479. package/dist/src/prompt/ai-service-fallback.js.map +1 -0
  480. package/dist/src/prompt/function-calling-validate.d.ts +3 -0
  481. package/dist/src/prompt/function-calling-validate.js +99 -0
  482. package/dist/src/prompt/function-calling-validate.js.map +1 -0
  483. package/dist/src/prompt/function-calling.d.ts +5 -0
  484. package/dist/src/prompt/function-calling.js +43 -0
  485. package/dist/src/prompt/function-calling.js.map +1 -0
  486. package/dist/src/prompt/function-defs/ask-question-reflect.d.ts +2 -0
  487. package/dist/src/prompt/function-defs/ask-question-reflect.js +21 -0
  488. package/dist/src/prompt/function-defs/ask-question-reflect.js.map +1 -0
  489. package/dist/src/prompt/function-defs/ask-question.d.ts +8 -0
  490. package/dist/src/prompt/function-defs/ask-question.js +100 -0
  491. package/dist/src/prompt/function-defs/ask-question.js.map +1 -0
  492. package/dist/src/prompt/function-defs/codegen-summary.d.ts +5 -0
  493. package/dist/src/prompt/function-defs/codegen-summary.js +82 -0
  494. package/dist/src/prompt/function-defs/codegen-summary.js.map +1 -0
  495. package/dist/src/prompt/function-defs/explanation.d.ts +5 -0
  496. package/dist/src/prompt/function-defs/explanation.js +18 -0
  497. package/dist/src/prompt/function-defs/explanation.js.map +1 -0
  498. package/dist/src/prompt/function-defs/generate-image.d.ts +5 -0
  499. package/dist/src/prompt/function-defs/generate-image.js +42 -0
  500. package/dist/src/prompt/function-defs/generate-image.js.map +1 -0
  501. package/dist/src/prompt/function-defs/get-image-assets.d.ts +5 -0
  502. package/dist/src/prompt/function-defs/get-image-assets.js +21 -0
  503. package/dist/src/prompt/function-defs/get-image-assets.js.map +1 -0
  504. package/dist/src/prompt/function-defs/get-source-code.d.ts +5 -0
  505. package/dist/src/prompt/function-defs/get-source-code.js +22 -0
  506. package/dist/src/prompt/function-defs/get-source-code.js.map +1 -0
  507. package/dist/src/prompt/function-defs/optimize-context.d.ts +5 -0
  508. package/dist/src/prompt/function-defs/optimize-context.js +47 -0
  509. package/dist/src/prompt/function-defs/optimize-context.js.map +1 -0
  510. package/dist/src/prompt/function-defs/read-history.d.ts +2 -0
  511. package/dist/src/prompt/function-defs/read-history.js +14 -0
  512. package/dist/src/prompt/function-defs/read-history.js.map +1 -0
  513. package/dist/src/prompt/function-defs/set-summaries.d.ts +5 -0
  514. package/dist/src/prompt/function-defs/set-summaries.js +32 -0
  515. package/dist/src/prompt/function-defs/set-summaries.js.map +1 -0
  516. package/dist/src/prompt/function-defs/update-history.d.ts +5 -0
  517. package/dist/src/prompt/function-defs/update-history.js +22 -0
  518. package/dist/src/prompt/function-defs/update-history.js.map +1 -0
  519. package/dist/src/prompt/limits.d.ts +3 -0
  520. package/dist/src/prompt/limits.js +21 -0
  521. package/dist/src/prompt/limits.js.map +1 -0
  522. package/dist/src/prompt/limits.test.d.ts +1 -0
  523. package/dist/src/prompt/limits.test.js +35 -0
  524. package/dist/src/prompt/limits.test.js.map +1 -0
  525. package/dist/src/prompt/prompt-codegen.d.ts +9 -0
  526. package/dist/src/prompt/prompt-codegen.js +117 -0
  527. package/dist/src/prompt/prompt-codegen.js.map +1 -0
  528. package/dist/src/prompt/prompt-codegen.test.d.ts +1 -0
  529. package/dist/src/prompt/prompt-codegen.test.js +98 -0
  530. package/dist/src/prompt/prompt-codegen.test.js.map +1 -0
  531. package/dist/src/prompt/prompt-consts.d.ts +1 -0
  532. package/dist/src/prompt/prompt-consts.js +2 -0
  533. package/dist/src/prompt/prompt-consts.js.map +1 -0
  534. package/dist/src/prompt/prompt-service-ask-question.test.d.ts +4 -0
  535. package/dist/src/prompt/prompt-service-ask-question.test.js +215 -0
  536. package/dist/src/prompt/prompt-service-ask-question.test.js.map +1 -0
  537. package/dist/src/prompt/prompt-service.d.ts +5 -0
  538. package/dist/src/prompt/prompt-service.js +214 -0
  539. package/dist/src/prompt/prompt-service.js.map +1 -0
  540. package/dist/src/prompt/prompt-service.test.d.ts +2 -0
  541. package/dist/src/prompt/prompt-service.test.js +553 -0
  542. package/dist/src/prompt/prompt-service.test.js.map +1 -0
  543. package/dist/src/prompt/steps/step-ask-question/handlers/cancel-code-generation.d.ts +2 -0
  544. package/dist/src/prompt/steps/step-ask-question/handlers/cancel-code-generation.js +16 -0
  545. package/dist/src/prompt/steps/step-ask-question/handlers/cancel-code-generation.js.map +1 -0
  546. package/dist/src/prompt/steps/step-ask-question/handlers/confirm-code-generation.d.ts +2 -0
  547. package/dist/src/prompt/steps/step-ask-question/handlers/confirm-code-generation.js +37 -0
  548. package/dist/src/prompt/steps/step-ask-question/handlers/confirm-code-generation.js.map +1 -0
  549. package/dist/src/prompt/steps/step-ask-question/handlers/context-optimization.d.ts +2 -0
  550. package/dist/src/prompt/steps/step-ask-question/handlers/context-optimization.js +36 -0
  551. package/dist/src/prompt/steps/step-ask-question/handlers/context-optimization.js.map +1 -0
  552. package/dist/src/prompt/steps/step-ask-question/handlers/default-action.d.ts +2 -0
  553. package/dist/src/prompt/steps/step-ask-question/handlers/default-action.js +18 -0
  554. package/dist/src/prompt/steps/step-ask-question/handlers/default-action.js.map +1 -0
  555. package/dist/src/prompt/steps/step-ask-question/handlers/handle-request-answer.d.ts +2 -0
  556. package/dist/src/prompt/steps/step-ask-question/handlers/handle-request-answer.js +20 -0
  557. package/dist/src/prompt/steps/step-ask-question/handlers/handle-request-answer.js.map +1 -0
  558. package/dist/src/prompt/steps/step-ask-question/handlers/remove-files-from-context.d.ts +2 -0
  559. package/dist/src/prompt/steps/step-ask-question/handlers/remove-files-from-context.js +43 -0
  560. package/dist/src/prompt/steps/step-ask-question/handlers/remove-files-from-context.js.map +1 -0
  561. package/dist/src/prompt/steps/step-ask-question/handlers/request-files-content.d.ts +2 -0
  562. package/dist/src/prompt/steps/step-ask-question/handlers/request-files-content.js +49 -0
  563. package/dist/src/prompt/steps/step-ask-question/handlers/request-files-content.js.map +1 -0
  564. package/dist/src/prompt/steps/step-ask-question/handlers/request-permissions.d.ts +2 -0
  565. package/dist/src/prompt/steps/step-ask-question/handlers/request-permissions.js +46 -0
  566. package/dist/src/prompt/steps/step-ask-question/handlers/request-permissions.js.map +1 -0
  567. package/dist/src/prompt/steps/step-ask-question/handlers/start-code-generation.d.ts +2 -0
  568. package/dist/src/prompt/steps/step-ask-question/handlers/start-code-generation.js +16 -0
  569. package/dist/src/prompt/steps/step-ask-question/handlers/start-code-generation.js.map +1 -0
  570. package/dist/src/prompt/steps/step-ask-question/step-ask-question-handlers.d.ts +0 -0
  571. package/dist/src/prompt/steps/step-ask-question/step-ask-question-handlers.js +2 -0
  572. package/dist/src/prompt/steps/step-ask-question/step-ask-question-handlers.js.map +1 -0
  573. package/dist/src/prompt/steps/step-ask-question/step-ask-question-reflect.d.ts +4 -0
  574. package/dist/src/prompt/steps/step-ask-question/step-ask-question-reflect.js +91 -0
  575. package/dist/src/prompt/steps/step-ask-question/step-ask-question-reflect.js.map +1 -0
  576. package/dist/src/prompt/steps/step-ask-question/step-ask-question-types.d.ts +55 -0
  577. package/dist/src/prompt/steps/step-ask-question/step-ask-question-types.js +2 -0
  578. package/dist/src/prompt/steps/step-ask-question/step-ask-question-types.js.map +1 -0
  579. package/dist/src/prompt/steps/step-ask-question/step-ask-question.d.ts +6 -0
  580. package/dist/src/prompt/steps/step-ask-question/step-ask-question.js +88 -0
  581. package/dist/src/prompt/steps/step-ask-question/step-ask-question.js.map +1 -0
  582. package/dist/src/prompt/steps/step-context-optimization.d.ts +4 -0
  583. package/dist/src/prompt/steps/step-context-optimization.js +200 -0
  584. package/dist/src/prompt/steps/step-context-optimization.js.map +1 -0
  585. package/dist/src/prompt/steps/step-generate-image.d.ts +2 -0
  586. package/dist/src/prompt/steps/step-generate-image.js +29 -0
  587. package/dist/src/prompt/steps/step-generate-image.js.map +1 -0
  588. package/dist/src/prompt/steps/step-generate-summary.d.ts +3 -0
  589. package/dist/src/prompt/steps/step-generate-summary.js +41 -0
  590. package/dist/src/prompt/steps/step-generate-summary.js.map +1 -0
  591. package/dist/src/prompt/steps/step-history-update.d.ts +5 -0
  592. package/dist/src/prompt/steps/step-history-update.js +54 -0
  593. package/dist/src/prompt/steps/step-history-update.js.map +1 -0
  594. package/dist/src/prompt/steps/step-summarization.d.ts +8 -0
  595. package/dist/src/prompt/steps/step-summarization.js +75 -0
  596. package/dist/src/prompt/steps/step-summarization.js.map +1 -0
  597. package/dist/src/prompt/steps/step-validate-recover.d.ts +2 -0
  598. package/dist/src/prompt/steps/step-validate-recover.js +51 -0
  599. package/dist/src/prompt/steps/step-validate-recover.js.map +1 -0
  600. package/dist/src/prompt/steps/step-verify-patch.d.ts +6 -0
  601. package/dist/src/prompt/steps/step-verify-patch.js +34 -0
  602. package/dist/src/prompt/steps/step-verify-patch.js.map +1 -0
  603. package/dist/src/prompt/steps/steps-types.d.ts +16 -0
  604. package/dist/src/prompt/steps/steps-types.js +6 -0
  605. package/dist/src/prompt/steps/steps-types.js.map +1 -0
  606. package/dist/src/prompt/steps/steps-utils.d.ts +7 -0
  607. package/dist/src/prompt/steps/steps-utils.js +11 -0
  608. package/dist/src/prompt/steps/steps-utils.js.map +1 -0
  609. package/dist/src/prompt/systemprompt.d.ts +3 -0
  610. package/dist/src/prompt/systemprompt.js +209 -0
  611. package/dist/src/prompt/systemprompt.js.map +1 -0
  612. package/dist/src/prompt/systemprompt.test.d.ts +3 -0
  613. package/dist/src/prompt/systemprompt.test.js +43 -0
  614. package/dist/src/prompt/systemprompt.test.js.map +1 -0
  615. package/dist/src/prompt/token-estimator.d.ts +8 -0
  616. package/dist/src/prompt/token-estimator.js +31 -0
  617. package/dist/src/prompt/token-estimator.js.map +1 -0
  618. package/dist/src/vite-genaicode/vite-genaicode-frontend.d.ts +1 -0
  619. package/dist/src/vite-genaicode/vite-genaicode-frontend.js +142 -0
  620. package/dist/src/vite-genaicode/vite-genaicode-frontend.js.map +1 -0
  621. package/dist/src/vite-genaicode/vite-genaicode-plugin.d.ts +7 -0
  622. package/dist/src/vite-genaicode/vite-genaicode-plugin.js +40 -0
  623. package/dist/src/vite-genaicode/vite-genaicode-plugin.js.map +1 -0
  624. package/dist/vite-genaicode/vite-genaicode-plugin.js +3 -3
  625. package/dist/vite-genaicode/vite-genaicode-plugin.js.map +1 -1
  626. package/package.json +4 -2
@@ -0,0 +1,38 @@
1
+ import { describe, it, expect, afterEach } from 'vitest';
2
+ import { serviceAutoDetect } from './service-autodetect.js';
3
+ describe('serviceAutoDetect', () => {
4
+ afterEach(() => {
5
+ // Clean up environment variables after each test
6
+ delete process.env.ANTHROPIC_API_KEY;
7
+ delete process.env.OPENAI_API_KEY;
8
+ delete process.env.GOOGLE_CLOUD_PROJECT;
9
+ delete process.env.API_KEY;
10
+ });
11
+ it('should return "anthropic" when ANTHROPIC_API_KEY is set', () => {
12
+ process.env.ANTHROPIC_API_KEY = 'test-key';
13
+ expect(serviceAutoDetect()).toBe('anthropic');
14
+ });
15
+ it('should return "chat-gpt" when OPENAI_API_KEY is set', () => {
16
+ process.env.OPENAI_API_KEY = 'test-key';
17
+ expect(serviceAutoDetect()).toBe('chat-gpt');
18
+ });
19
+ it('should return "vertex-ai" when GOOGLE_CLOUD_PROJECT is set', () => {
20
+ process.env.GOOGLE_CLOUD_PROJECT = 'test-project';
21
+ expect(serviceAutoDetect()).toBe('vertex-ai');
22
+ });
23
+ it('should return null when no service is configured', () => {
24
+ expect(serviceAutoDetect()).toBeNull();
25
+ });
26
+ it('should prioritize anthropic over other services', () => {
27
+ process.env.ANTHROPIC_API_KEY = 'test-key';
28
+ process.env.OPENAI_API_KEY = 'test-key';
29
+ process.env.GOOGLE_CLOUD_PROJECT = 'test-project';
30
+ expect(serviceAutoDetect()).toBe('anthropic');
31
+ });
32
+ it('should prioritize chat-gpt over vertex-ai', () => {
33
+ process.env.OPENAI_API_KEY = 'test-key';
34
+ process.env.GOOGLE_CLOUD_PROJECT = 'test-project';
35
+ expect(serviceAutoDetect()).toBe('chat-gpt');
36
+ });
37
+ });
38
+ //# sourceMappingURL=service-autodetect.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-autodetect.test.js","sourceRoot":"","sources":["../../../src/cli/service-autodetect.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,SAAS,CAAC,GAAG,EAAE;QACb,iDAAiD;QACjD,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QACrC,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QAClC,OAAO,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;QACxC,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,UAAU,CAAC;QAC3C,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,UAAU,CAAC;QACxC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,OAAO,CAAC,GAAG,CAAC,oBAAoB,GAAG,cAAc,CAAC;QAClD,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,UAAU,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,UAAU,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,oBAAoB,GAAG,cAAc,CAAC;QAClD,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,UAAU,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,oBAAoB,GAAG,cAAc,CAAC;QAClD,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Validate CLI parameters according to those mentioned in README.md
3
+ * Fail the process if not valid, or if an unknown parameter is passed
4
+ * @throws {Error} If an invalid parameter is provided
5
+ */
6
+ export declare function validateCliParams(): void;
7
+ /**
8
+ * Get the value of a CLI parameter
9
+ * @param {string} paramName - The name of the parameter to get the value for
10
+ * @returns {string|null} The value of the parameter, or null if not found
11
+ */
12
+ export declare function getCliParamValue(paramName: string): string | null;
13
+ /**
14
+ * Check if a CLI parameter is present
15
+ * @param {string} paramName - The name of the parameter to check
16
+ * @returns {boolean} True if the parameter is present, false otherwise
17
+ */
18
+ export declare function hasCliParam(paramName: string): boolean;
@@ -0,0 +1,145 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import globRegex from 'glob-regex';
4
+ import { rcConfig } from '../main/config.js';
5
+ // List of allowed CLI parameters
6
+ const allowedParameters = [
7
+ '--dry-run',
8
+ '--interactive',
9
+ '--ui',
10
+ '--ui-port=',
11
+ '--consider-all-files',
12
+ '--disallow-file-create',
13
+ '--disallow-file-delete',
14
+ '--disallow-directory-create',
15
+ '--disallow-file-move',
16
+ '--ai-service=',
17
+ '--explicit-prompt=',
18
+ '--task-file=',
19
+ '--dependency-tree',
20
+ '--verbose-prompt',
21
+ '--disable-explanations',
22
+ '--disable-context-optimization',
23
+ '--gemini-block-none',
24
+ '--disable-initial-lint',
25
+ '--temperature=',
26
+ '--vision',
27
+ '--imagen=',
28
+ '--cheap',
29
+ '--disable-ask-question',
30
+ '--help',
31
+ '--content-mask=',
32
+ '--disable-cache',
33
+ '--ignore-pattern=',
34
+ '--force-dist',
35
+ '--disable-ai-service-fallback',
36
+ '--disable-history',
37
+ '--disable-vertex-unescape',
38
+ '--disable-self-reflection',
39
+ '--disable-conversation-summary',
40
+ ];
41
+ /**
42
+ * Validate CLI parameters according to those mentioned in README.md
43
+ * Fail the process if not valid, or if an unknown parameter is passed
44
+ * @throws {Error} If an invalid parameter is provided
45
+ */
46
+ export function validateCliParams() {
47
+ const providedParameters = process.argv.slice(2);
48
+ // Check if --help is present
49
+ const helpRequested = providedParameters.includes('--help');
50
+ if (helpRequested) {
51
+ // If --help is present, no other parameters should be allowed
52
+ if (providedParameters.length > 1) {
53
+ console.error('The --help option cannot be used with other parameters.');
54
+ process.exit(1);
55
+ }
56
+ return; // Exit the function early as no further validation is needed
57
+ }
58
+ providedParameters.forEach((param) => {
59
+ if (!param.startsWith('--')) {
60
+ console.error(`Invalid parameter: ${param}, all parameters must start with --`);
61
+ process.exit(1);
62
+ }
63
+ if (!allowedParameters.some((p) => (p.endsWith('=') && param.startsWith(p)) || param === p)) {
64
+ console.error(`Invalid parameter: ${param}, allowed parameters are: ${allowedParameters.join(', ')}`);
65
+ process.exit(1);
66
+ }
67
+ });
68
+ // Validate --ai-service parameter
69
+ const aiServiceParam = providedParameters.find((param) => param.startsWith('--ai-service='));
70
+ if (aiServiceParam) {
71
+ const aiServiceValue = aiServiceParam.split('=')[1];
72
+ if (!['vertex-ai', 'chat-gpt', 'anthropic', 'ai-studio', 'vertex-ai-claude'].includes(aiServiceValue) &&
73
+ !aiServiceValue.startsWith('plugin:')) {
74
+ throw new Error('Invalid --ai-service value');
75
+ }
76
+ }
77
+ // Validate temperature parameter, it must be a number between 0.0 and 2.0
78
+ const temperatureParam = providedParameters.find((param) => param.startsWith('--temperature='));
79
+ if (temperatureParam) {
80
+ const temperatureValue = parseFloat(temperatureParam.split('=')[1]);
81
+ if (isNaN(temperatureValue) || temperatureValue < 0.0 || temperatureValue > 2.0) {
82
+ console.error('Invalid temperature value. It must be a number between 0.0 and 2.0.');
83
+ process.exit(1);
84
+ }
85
+ }
86
+ // Validate --imagen parameter
87
+ const imagenParam = providedParameters.find((param) => param.startsWith('--imagen='));
88
+ if (imagenParam) {
89
+ const imagenValue = imagenParam.split('=')[1];
90
+ if (imagenValue !== 'vertex-ai' && imagenValue !== 'dall-e') {
91
+ throw new Error('Invalid --imagen value. It must be either "vertex-ai" or "dall-e".');
92
+ }
93
+ }
94
+ if (providedParameters.includes('--vision') && providedParameters.includes('--ai-service=vertex-ai')) {
95
+ throw new Error('--vision and --ai-service=vertex-ai are currently not supported together.');
96
+ }
97
+ // Validate content mask parameter
98
+ const contentMaskParam = providedParameters.find((param) => param.startsWith('--content-mask='));
99
+ if (contentMaskParam) {
100
+ const contentMaskValue = contentMaskParam.split('=')[1];
101
+ const fullPath = path.join(rcConfig.rootDir, contentMaskValue);
102
+ if (!fs.existsSync(fullPath) || !fs.statSync(fullPath).isDirectory()) {
103
+ throw new Error(`Invalid --content-mask value. The path "${contentMaskValue}" does not exist or is not a directory within the project.`);
104
+ }
105
+ }
106
+ // Validate ignore pattern parameter
107
+ const ignorePatternParams = providedParameters.filter((param) => param.startsWith('--ignore-pattern='));
108
+ if (ignorePatternParams.length > 0) {
109
+ for (const ignorePatternParam of ignorePatternParams) {
110
+ const ignorePatternValue = ignorePatternParam.split('=')[1];
111
+ if (!ignorePatternValue) {
112
+ throw new Error('Invalid --ignore-pattern value. The pattern cannot be empty.');
113
+ }
114
+ try {
115
+ globRegex(ignorePatternValue);
116
+ }
117
+ catch (e) {
118
+ console.error(e);
119
+ throw new Error(`Invalid --ignore-pattern value. The pattern "${ignorePatternValue}" is not valid.`);
120
+ }
121
+ }
122
+ }
123
+ // Validate --disable-self-reflection
124
+ if (providedParameters.includes('--disable-self-reflection') && providedParameters.includes('--cheap')) {
125
+ console.warn('Warning: --disable-self-reflection is redundant when --cheap is used, as cheap mode already skips self-reflection.');
126
+ }
127
+ }
128
+ /**
129
+ * Get the value of a CLI parameter
130
+ * @param {string} paramName - The name of the parameter to get the value for
131
+ * @returns {string|null} The value of the parameter, or null if not found
132
+ */
133
+ export function getCliParamValue(paramName) {
134
+ const param = process.argv.find((arg) => arg.startsWith(`${paramName}=`));
135
+ return param ? param.split('=')[1] : null;
136
+ }
137
+ /**
138
+ * Check if a CLI parameter is present
139
+ * @param {string} paramName - The name of the parameter to check
140
+ * @returns {boolean} True if the parameter is present, false otherwise
141
+ */
142
+ export function hasCliParam(paramName) {
143
+ return process.argv.includes(paramName) || !!getCliParamValue(paramName);
144
+ }
145
+ //# sourceMappingURL=validate-cli-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-cli-params.js","sourceRoot":"","sources":["../../../src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,SAAiB;IAChD,MAAM,KAAK,GAAuB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC;IAC9F,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB;IAC3C,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,106 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
2
+ import { validateCliParams, getCliParamValue, hasCliParam } from './validate-cli-params.js';
3
+ describe('validateCliParams', () => {
4
+ const originalArgv = process.argv;
5
+ beforeEach(() => {
6
+ process.argv = ['node', 'script.js'];
7
+ });
8
+ afterEach(() => {
9
+ process.argv = originalArgv;
10
+ });
11
+ it('should not throw for valid parameters', () => {
12
+ process.argv.push('--dry-run', '--consider-all-files');
13
+ expect(() => validateCliParams()).not.toThrow();
14
+ });
15
+ it('should throw for invalid parameters', () => {
16
+ process.argv.push('--invalid-param');
17
+ expect(() => validateCliParams()).toThrow();
18
+ });
19
+ it('should throw for parameters without --', () => {
20
+ process.argv.push('invalid-param');
21
+ expect(() => validateCliParams()).toThrow();
22
+ });
23
+ it('should not throw for valid --temperature parameter', () => {
24
+ process.argv.push('--temperature=0.5');
25
+ expect(() => validateCliParams()).not.toThrow();
26
+ });
27
+ it('should throw for invalid --temperature parameter', () => {
28
+ process.argv.push('--temperature=invalid');
29
+ expect(() => validateCliParams()).toThrow();
30
+ });
31
+ it('should throw an error when both vision and vertexAi flags are true', () => {
32
+ process.argv.push('--vision');
33
+ process.argv.push('--ai-service=vertex-ai');
34
+ expect(() => validateCliParams()).toThrow('--vision and --ai-service=vertex-ai are currently not supported together.');
35
+ });
36
+ // New tests for --imagen parameter
37
+ it('should not throw for valid --imagen parameter with vertex-ai', () => {
38
+ process.argv.push('--imagen=vertex-ai');
39
+ expect(() => validateCliParams()).not.toThrow();
40
+ });
41
+ it('should not throw for valid --imagen parameter with dall-e', () => {
42
+ process.argv.push('--imagen=dall-e');
43
+ expect(() => validateCliParams()).not.toThrow();
44
+ });
45
+ it('should throw for invalid --imagen parameter value', () => {
46
+ process.argv.push('--imagen=invalid-service');
47
+ expect(() => validateCliParams()).toThrow('Invalid --imagen value. It must be either "vertex-ai" or "dall-e".');
48
+ });
49
+ it('should throw for --imagen parameter without value', () => {
50
+ process.argv.push('--imagen=');
51
+ expect(() => validateCliParams()).toThrow('Invalid --imagen value. It must be either "vertex-ai" or "dall-e".');
52
+ });
53
+ });
54
+ describe('getCliParamValue', () => {
55
+ const originalArgv = process.argv;
56
+ beforeEach(() => {
57
+ process.argv = ['node', 'script.js'];
58
+ });
59
+ afterEach(() => {
60
+ process.argv = originalArgv;
61
+ });
62
+ it('should return the value for a parameter with a value', () => {
63
+ process.argv.push('--explicit-prompt=Test prompt');
64
+ expect(getCliParamValue('--explicit-prompt')).toBe('Test prompt');
65
+ });
66
+ it('should return null for a parameter without a value', () => {
67
+ process.argv.push('--dry-run');
68
+ expect(getCliParamValue('--dry-run')).toBeNull();
69
+ });
70
+ it('should return null for a non-existent parameter', () => {
71
+ expect(getCliParamValue('--non-existent')).toBeNull();
72
+ });
73
+ it('should return the value for --temperature parameter', () => {
74
+ process.argv.push('--temperature=0.5');
75
+ expect(getCliParamValue('--temperature')).toBe('0.5');
76
+ });
77
+ it('should return the value for --imagen parameter', () => {
78
+ process.argv.push('--imagen=vertex-ai');
79
+ expect(getCliParamValue('--imagen')).toBe('vertex-ai');
80
+ });
81
+ });
82
+ describe('hasCliParam', () => {
83
+ const originalArgv = process.argv;
84
+ beforeEach(() => {
85
+ process.argv = ['node', 'script.js'];
86
+ });
87
+ afterEach(() => {
88
+ process.argv = originalArgv;
89
+ });
90
+ it('should return true for an existing parameter', () => {
91
+ process.argv.push('--dry-run');
92
+ expect(hasCliParam('--dry-run')).toBe(true);
93
+ });
94
+ it('should return false for a non-existent parameter', () => {
95
+ expect(hasCliParam('--non-existent')).toBe(false);
96
+ });
97
+ it('should return true for --temperature parameter', () => {
98
+ process.argv.push('--temperature=0.5');
99
+ expect(hasCliParam('--temperature')).toBe(true);
100
+ });
101
+ it('should return true for --imagen parameter', () => {
102
+ process.argv.push('--imagen=dall-e');
103
+ expect(hasCliParam('--imagen')).toBe(true);
104
+ });
105
+ });
106
+ //# sourceMappingURL=validate-cli-params.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-cli-params.test.js","sourceRoot":"","sources":["../../../src/cli/validate-cli-params.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5F,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAElC,UAAU,CAAC,GAAG,EAAE;QACd,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC;QACvD,MAAM,CAAC,GAAG,EAAE,CAAC,i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AAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC/B,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACvC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACrC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function readCache<T>(key: string, defaultValue: T): T;
2
+ export declare function writeCache<T>(key: string, value: T): void;
3
+ export declare function md5(content: string): string;
@@ -0,0 +1,36 @@
1
+ import os from 'node:os';
2
+ import fs from 'node:fs';
3
+ import crypto from 'node:crypto';
4
+ import path from 'path';
5
+ import findCacheDir from 'find-cache-dir';
6
+ import { rcConfig } from '../main/config.js';
7
+ const cacheDirectory = findCacheDir({ name: 'genaicode' }) || os.tmpdir();
8
+ export function readCache(key, defaultValue) {
9
+ const cache = readCacheFile();
10
+ return (key in cache ? cache[key] : defaultValue);
11
+ }
12
+ export function writeCache(key, value) {
13
+ const cache = readCacheFile();
14
+ cache[key] = value;
15
+ writeCacheFile(cache);
16
+ }
17
+ function getCacheFileName() {
18
+ return md5(rcConfig.rootDir) + '.cache.json';
19
+ }
20
+ function readCacheFile() {
21
+ const cacheFileName = path.join(cacheDirectory, getCacheFileName());
22
+ try {
23
+ return JSON.parse(fs.readFileSync(cacheFileName, 'utf-8'));
24
+ }
25
+ catch {
26
+ return {};
27
+ }
28
+ }
29
+ function writeCacheFile(content) {
30
+ fs.mkdirSync(cacheDirectory, { recursive: true });
31
+ fs.writeFileSync(path.join(cacheDirectory, getCacheFileName()), JSON.stringify(content), 'utf-8');
32
+ }
33
+ export function md5(content) {
34
+ return crypto.createHash('md5').update(content).digest('hex');
35
+ }
36
+ //# sourceMappingURL=cache-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-file.js","sourceRoot":"","sources":["../../../src/files/cache-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,cAAc,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC;AAE1E,MAAM,UAAU,SAAS,CAAI,GAAW,EAAE,YAAe;IACvD,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAC9B,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAM,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,UAAU,CAAI,GAAW,EAAE,KAAQ;IACjD,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAC9B,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,cAAc,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,gBAAgB;IACvB,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC;AAC/C,CAAC;AAED,SAAS,aAAa;IACpB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACpE,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,OAAgC;IACtD,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,gBAAgB,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AACpG,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,OAAe;IACjC,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** Check if directory is ancestor of given directory */
2
+ export declare function isAncestorDirectory(parent: string, dir: string): boolean;
@@ -0,0 +1,7 @@
1
+ import path from 'path';
2
+ /** Check if directory is ancestor of given directory */
3
+ export function isAncestorDirectory(parent, dir) {
4
+ const relative = path.relative(parent, dir);
5
+ return parent === dir || (relative ? !relative.startsWith('..') && !path.isAbsolute(relative) : false);
6
+ }
7
+ //# sourceMappingURL=file-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-utils.js","sourceRoot":"","sources":["../../../src/files/file-utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,wDAAwD;AACxD,MAAM,UAAU,mBAAmB,CAAC,MAAc,EAAE,GAAW;IAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5C,OAAO,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACzG,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { vi, describe, beforeEach, it, expect } from 'vitest';
2
+ import { isAncestorDirectory } from './file-utils.js';
3
+ // Test for isAncestorDirectory
4
+ describe('isAncestorDirectory', () => {
5
+ beforeEach(() => {
6
+ vi.resetAllMocks();
7
+ });
8
+ it('should return true if directories are the same', () => {
9
+ expect(isAncestorDirectory('/project', '/project')).toBe(true);
10
+ });
11
+ it('should return true if parent is ancestor of dir', () => {
12
+ expect(isAncestorDirectory('/project', '/project/src')).toBe(true);
13
+ });
14
+ it('should return false if parent is not ancestor of dir', () => {
15
+ expect(isAncestorDirectory('/project', '/other')).toBe(false);
16
+ });
17
+ });
18
+ //# sourceMappingURL=file-utils.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-utils.test.js","sourceRoot":"","sources":["../../../src/files/file-utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,+BAA+B;AAC/B,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ type DependencyList = string[];
2
+ /** Generates a dependency list for given file */
3
+ export declare function getDependencyList(entryFile: string): DependencyList;
4
+ /** Get source files of the application */
5
+ export declare function getSourceFiles(): string[];
6
+ /** Get source files of the application */
7
+ export declare function getImageAssetFiles(): string[];
8
+ export declare function refreshFiles(): void;
9
+ export {};
@@ -0,0 +1,81 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { rcConfig, sourceExtensions, IMAGE_ASSET_EXTENSIONS, ignorePaths } from '../main/config.js';
4
+ // List of possible extensions for dependency resolution
5
+ const POSSIBLE_DEPENDENCY_EXTENSIONS = ['.ts', '.js', '.tsx', '.jsx'];
6
+ function findFiles(dir, recursive, extensions) {
7
+ const files = [];
8
+ const items = fs.readdirSync(dir);
9
+ for (const item of items) {
10
+ const fullPath = path.join(dir, item);
11
+ if (ignorePaths.some((ignorePath) => fullPath.endsWith(ignorePath))) {
12
+ continue;
13
+ }
14
+ if (fs.statSync(fullPath).isDirectory()) {
15
+ if (recursive) {
16
+ files.push(...findFiles(fullPath, true, extensions));
17
+ }
18
+ }
19
+ else if (extensions.includes(path.extname(fullPath))) {
20
+ files.push(fullPath);
21
+ }
22
+ }
23
+ return files;
24
+ }
25
+ function getDependencies(filePath) {
26
+ const content = fs.readFileSync(filePath, 'utf-8');
27
+ const dependencyRegex = /import\s+.+?\s+from\s+['"](.+?\/?[^'"]+)['"]/g;
28
+ const dependencies = [];
29
+ let match;
30
+ while ((match = dependencyRegex.exec(content)) !== null) {
31
+ const dependencyPath = match[1];
32
+ // Resolve relative paths from the file's directory
33
+ const resolvedPath = path.resolve(path.dirname(filePath), dependencyPath);
34
+ // Only add the dependency if it's a local file and not a module
35
+ if (fs.existsSync(resolvedPath)) {
36
+ dependencies.push(resolvedPath);
37
+ }
38
+ else {
39
+ const possibleExtensions = POSSIBLE_DEPENDENCY_EXTENSIONS;
40
+ for (const ext of possibleExtensions) {
41
+ const extendedPath = resolvedPath + ext;
42
+ if (fs.existsSync(extendedPath)) {
43
+ dependencies.push(extendedPath);
44
+ }
45
+ }
46
+ }
47
+ }
48
+ return dependencies;
49
+ }
50
+ /** Generates a dependency list for given file */
51
+ export function getDependencyList(entryFile) {
52
+ const visitedFiles = new Set();
53
+ const result = new Set();
54
+ function traverse(file) {
55
+ if (visitedFiles.has(file))
56
+ return;
57
+ visitedFiles.add(file);
58
+ const dependencies = getDependencies(file);
59
+ dependencies.forEach((dependency) => result.add(dependency));
60
+ dependencies.forEach(traverse);
61
+ }
62
+ result.add(path.resolve(entryFile));
63
+ traverse(entryFile);
64
+ return Array.from(result);
65
+ }
66
+ let sourceFiles = [];
67
+ let imageAssetFiles = [];
68
+ refreshFiles();
69
+ /** Get source files of the application */
70
+ export function getSourceFiles() {
71
+ return [...sourceFiles];
72
+ }
73
+ /** Get source files of the application */
74
+ export function getImageAssetFiles() {
75
+ return [...imageAssetFiles];
76
+ }
77
+ export function refreshFiles() {
78
+ sourceFiles = findFiles(rcConfig.rootDir, true, sourceExtensions);
79
+ imageAssetFiles = findFiles(rcConfig.rootDir, true, IMAGE_ASSET_EXTENSIONS);
80
+ }
81
+ //# sourceMappingURL=find-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-files.js","sourceRoot":"","sources":["../../../src/files/find-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEpG,wDAAwD;AACxD,MAAM,8BAA8B,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAMtE,SAAS,SAAS,CAAC,GAAW,EAAE,SAAkB,EAAE,UAA0B;IAC5E,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEtC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,UAAkB,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;YAC5E,SAAS;QACX,CAAC;QAED,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YACxC,IAAI,SAAS,EAAE,CAAC;gBACd,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,EAA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ePath: string): boolean;
@@ -0,0 +1,12 @@
1
+ import path from 'path';
2
+ import { getSourceFiles } from './find-files.js';
3
+ import { rcConfig } from '../main/config.js';
4
+ import { isAncestorDirectory } from './file-utils.js';
5
+ export function isProjectPath(filePath) {
6
+ const sourceFiles = getSourceFiles();
7
+ return (isAncestorDirectory(rcConfig.rootDir, filePath) ||
8
+ sourceFiles.includes(filePath) ||
9
+ !sourceFiles.some((sourceFile) => path.dirname(filePath) === path.dirname(sourceFile) ||
10
+ isAncestorDirectory(path.dirname(sourceFile), path.dirname(filePath))));
11
+ }
12
+ //# sourceMappingURL=path-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../../src/files/path-utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,OAAO,CACL,mBAAmB,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;QAC/C,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC9B,CAAC,WAAW,CAAC,IAAI,CACf,CAAC,UAAU,EAAE,EAAE,CACb,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;YACnD,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CACxE,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { CodegenOptions } from '../main/codegen-types.js';
2
+ export type SourceCodeMap = Record<string, {
3
+ content: string | null;
4
+ } | {
5
+ summary: string;
6
+ tokenCount: number;
7
+ }>;
8
+ type ImageAssetsMap = Record<string, {
9
+ mimeType: string | false;
10
+ width: number;
11
+ height: number;
12
+ }>;
13
+ /** Print source code of all source files */
14
+ export declare function getSourceCode({ filterPaths, taskFile, forceAll, }: {
15
+ filterPaths?: string[];
16
+ taskFile?: string | undefined;
17
+ forceAll?: boolean;
18
+ }, options: CodegenOptions): SourceCodeMap;
19
+ /** Get image asset files summary */
20
+ export declare function getImageAssets(): ImageAssetsMap;
21
+ export {};
@@ -0,0 +1,68 @@
1
+ import fs from 'fs';
2
+ import mime from 'mime-types';
3
+ import sizeOf from 'image-size';
4
+ import path from 'path';
5
+ import globRegex from 'glob-regex';
6
+ import { getSourceFiles, getImageAssetFiles } from './find-files.js';
7
+ import { rcConfig, importantContext } from '../main/config.js';
8
+ import { verifySourceCodeLimit } from '../prompt/limits.js';
9
+ import { getSummary } from '../prompt/steps/step-summarization.js';
10
+ /**
11
+ * Read contents of source files and create a map with file path as key and file content as value
12
+ */
13
+ function readSourceFiles({ contentMask, ignorePatterns }, filterPaths, forceAll = false) {
14
+ const sourceCode = {};
15
+ const importantFiles = new Set(importantContext.files || []);
16
+ for (const file of getSourceFiles()) {
17
+ if (!filterPaths || filterPaths.includes(file) || importantFiles.has(file)) {
18
+ // Always include important files
19
+ if (importantFiles.has(file)) {
20
+ sourceCode[file] = { content: fs.readFileSync(file, 'utf-8') };
21
+ continue;
22
+ }
23
+ const summary = getSummary(file);
24
+ // Apply content mask filter if it's set
25
+ if (!filterPaths && contentMask && !forceAll) {
26
+ const relativePath = path.relative(rcConfig.rootDir, file);
27
+ if (!relativePath.startsWith(contentMask)) {
28
+ sourceCode[file] = summary ? { ...summary } : { content: null };
29
+ continue;
30
+ }
31
+ }
32
+ if (!forceAll && ignorePatterns?.some((pattern) => globRegex(pattern).test(file))) {
33
+ sourceCode[file] = summary ? { ...summary } : { content: null };
34
+ }
35
+ else {
36
+ const content = fs.readFileSync(file, 'utf-8');
37
+ sourceCode[file] = { content, ...summary };
38
+ }
39
+ }
40
+ }
41
+ return sourceCode;
42
+ }
43
+ /** Print source code of all source files */
44
+ export function getSourceCode({ filterPaths, taskFile, forceAll, }, options) {
45
+ const sourceCode = readSourceFiles(options, filterPaths, forceAll);
46
+ if (taskFile && !sourceCode[taskFile]) {
47
+ sourceCode[taskFile] = {
48
+ content: fs.readFileSync(taskFile, 'utf-8'),
49
+ };
50
+ }
51
+ verifySourceCodeLimit(JSON.stringify(sourceCode));
52
+ return sourceCode;
53
+ }
54
+ /** Get image asset files summary */
55
+ export function getImageAssets() {
56
+ const imageAssets = {};
57
+ for (const file of getImageAssetFiles()) {
58
+ const dimensions = sizeOf(file);
59
+ imageAssets[file] = {
60
+ mimeType: mime.lookup(file),
61
+ width: dimensions.width,
62
+ height: dimensions.height,
63
+ };
64
+ }
65
+ verifySourceCodeLimit(JSON.stringify(imageAssets));
66
+ return imageAssets;
67
+ }
68
+ //# sourceMappingURL=read-files.js.map