genaicode 0.5.1 → 0.6.1

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 (627) hide show
  1. package/README.md +7 -11
  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 +31 -1
  41. package/dist/main/codegen-utils.d.ts +3 -0
  42. package/dist/main/codegen-utils.js +16 -0
  43. package/dist/main/codegen-utils.js.map +1 -0
  44. package/dist/main/codegen.js +15 -26
  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.d.ts +2 -1
  625. package/dist/vite-genaicode/vite-genaicode-plugin.js +20 -5
  626. package/dist/vite-genaicode/vite-genaicode-plugin.js.map +1 -1
  627. package/package.json +6 -3
@@ -0,0 +1,83 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import express from 'express';
3
+ import cors from 'cors';
4
+ import helmet from 'helmet';
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import http from 'http';
8
+ import { createRouter } from './api.js';
9
+ export async function startServer(service, { uiPort, additionalFrameAncestors }) {
10
+ const __dirname = fileURLToPath(new URL('.', import.meta.url));
11
+ const app = express();
12
+ // CORS configuration
13
+ const corsOptions = {
14
+ origin: `http://localhost:${uiPort}`,
15
+ optionsSuccessStatus: 200,
16
+ };
17
+ app.use(cors(corsOptions));
18
+ // Helmet for security headers including iframe protection
19
+ app.use(helmet({
20
+ contentSecurityPolicy: {
21
+ directives: {
22
+ defaultSrc: ["'self'"],
23
+ scriptSrc: ["'self'", "'unsafe-inline'"],
24
+ styleSrc: ["'self'", "'unsafe-inline'"],
25
+ imgSrc: ["'self'", 'data:', 'blob:'],
26
+ connectSrc: ["'self'", 'ws:'],
27
+ fontSrc: ["'self'"],
28
+ objectSrc: ["'none'"],
29
+ mediaSrc: ["'self'"],
30
+ frameSrc: ["'none'"],
31
+ frameAncestors: ["'self'", 'vscode-webview:', 'vscode-file:', ...(additionalFrameAncestors ?? [])],
32
+ },
33
+ },
34
+ referrerPolicy: {
35
+ policy: 'strict-origin-when-cross-origin',
36
+ },
37
+ frameguard: false,
38
+ }));
39
+ app.use(express.json());
40
+ const apiRouter = createRouter(service);
41
+ // API routes
42
+ app.use('/api', apiRouter);
43
+ const httpServer = http.createServer(app);
44
+ httpServer.on('error', console.error);
45
+ if (service.getCodegenOptions().isDev) {
46
+ console.log('GenAIcode Dev Mode!');
47
+ const { createServer } = await import('vite');
48
+ const vite = await createServer({
49
+ build: {
50
+ target: false,
51
+ rollupOptions: {
52
+ input: __dirname + '../frontend/index.html',
53
+ },
54
+ },
55
+ configFile: false,
56
+ root: __dirname + '../frontend',
57
+ server: {
58
+ middlewareMode: true,
59
+ },
60
+ plugins: [
61
+ {
62
+ name: 'security-token',
63
+ transformIndexHtml: (html) => html.replace('__SECURITY_TOKEN__', service.getToken()),
64
+ },
65
+ ],
66
+ });
67
+ httpServer.on('error', () => vite.close());
68
+ app.use(vite.middlewares);
69
+ }
70
+ else {
71
+ // Serve index.html with injected token
72
+ app.get('/', (_, res) => {
73
+ const indexPath = path.join(__dirname, '../frontend/index.html');
74
+ const html = fs.readFileSync(indexPath, 'utf-8').replace('__SECURITY_TOKEN__', service.getToken());
75
+ res.send(html);
76
+ });
77
+ app.use('/assets', express.static(__dirname + '../frontend/assets'));
78
+ }
79
+ httpServer.listen(uiPort, () => {
80
+ console.log(`Server is running on http://localhost:${uiPort}`);
81
+ });
82
+ }
83
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../src/main/ui/backend/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,I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G,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,uCAAuC;QACvC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE;YACtB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC;YACjE,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;YACnG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,GAAG,oBAAoB,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE;QAC7B,OAAO,CAAC,GAAG,CAAC,yCAAyC,MAAM,EAAE,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { AiServiceType, CodegenOptions } from '../../codegen-types.js';
2
+ import { RcConfig } from '../../config-lib.js';
3
+ import { ContentProps } from '../../common/content-bus-types.js';
4
+ import { UsageMetrics } from '../../common/cost-collector.js';
5
+ import { CodegenResult, ConfirmationProps, Question } from '../common/api-types.js';
6
+ interface ImageData {
7
+ buffer: Buffer;
8
+ mimetype: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
9
+ originalname: string;
10
+ }
11
+ export declare class Service {
12
+ private executionStatus;
13
+ private currentQuestion;
14
+ private askQuestionConversation;
15
+ private codegenOptions;
16
+ private content;
17
+ private pausePromiseResolve;
18
+ private securityToken;
19
+ constructor(codegenOptions: CodegenOptions);
20
+ private generateToken;
21
+ getToken(): string;
22
+ validateToken(token: string): boolean;
23
+ refreshToken(): string;
24
+ executeCodegen(prompt: string, options: CodegenOptions, images?: ImageData[]): Promise<CodegenResult>;
25
+ interruptExecution(): Promise<void>;
26
+ pauseExecution(): Promise<void>;
27
+ resumeExecution(): Promise<void>;
28
+ getExecutionStatus(): Promise<string>;
29
+ getCurrentQuestion(): Promise<Question | null>;
30
+ askQuestion(question: string, confirmation: ConfirmationProps): Promise<{
31
+ answer: string;
32
+ confirmed: boolean | undefined;
33
+ }>;
34
+ answerQuestion(questionId: string, answer: string, confirmed: boolean | undefined): Promise<void>;
35
+ handleContent(content: ContentProps): void;
36
+ getContent(): ContentProps[];
37
+ getUsageMetrics(): Promise<Record<AiServiceType | 'total', UsageMetrics>>;
38
+ getCodegenOptions(): CodegenOptions;
39
+ getRcConfig(): Promise<RcConfig>;
40
+ deleteIteration(iterationId: string): Promise<void>;
41
+ private waitForQuestionAnswer;
42
+ waitIfPaused(): Promise<void>;
43
+ }
44
+ export {};
@@ -0,0 +1,171 @@
1
+ import crypto from 'crypto';
2
+ import { rcConfig } from '../../config.js';
3
+ import { runCodegenWorker, abortController } from '../../interactive/codegen-worker.js';
4
+ import { getUsageMetrics } from '../../common/cost-collector.js';
5
+ import { putSystemMessage } from '../../common/content-bus.js';
6
+ export class Service {
7
+ executionStatus = 'idle';
8
+ currentQuestion = null;
9
+ askQuestionConversation = [];
10
+ codegenOptions;
11
+ content = [];
12
+ pausePromiseResolve = null;
13
+ securityToken;
14
+ constructor(codegenOptions) {
15
+ this.codegenOptions = codegenOptions;
16
+ this.securityToken = this.generateToken();
17
+ }
18
+ generateToken() {
19
+ return crypto.randomBytes(32).toString('hex');
20
+ }
21
+ getToken() {
22
+ return this.securityToken;
23
+ }
24
+ validateToken(token) {
25
+ return token === this.securityToken;
26
+ }
27
+ refreshToken() {
28
+ this.securityToken = this.generateToken();
29
+ return this.securityToken;
30
+ }
31
+ async executeCodegen(prompt, options, images) {
32
+ this.executionStatus = 'executing';
33
+ this.currentQuestion = null;
34
+ this.codegenOptions = { ...this.codegenOptions, ...options };
35
+ try {
36
+ const imageDataForPrompt = images?.map((image) => ({
37
+ base64url: image.buffer.toString('base64'),
38
+ mediaType: image.mimetype,
39
+ originalName: image.originalname,
40
+ }));
41
+ await runCodegenWorker({
42
+ ...this.codegenOptions,
43
+ explicitPrompt: prompt,
44
+ considerAllFiles: true,
45
+ images: imageDataForPrompt,
46
+ vision: this.codegenOptions.vision || !!imageDataForPrompt?.length,
47
+ }, () => this.waitIfPaused());
48
+ this.executionStatus = 'idle';
49
+ return { success: true };
50
+ }
51
+ catch (error) {
52
+ console.error('Error executing codegen:', error);
53
+ this.executionStatus = 'idle';
54
+ if (error instanceof Error) {
55
+ if (error.name === 'AbortError' || error.message.includes('interrupted')) {
56
+ return { success: false, message: 'Codegen execution was interrupted' };
57
+ }
58
+ else if (error.message.includes('Rate limit exceeded')) {
59
+ return {
60
+ success: false,
61
+ message: 'Rate limit exceeded. Consider switching to a different AI service or waiting before retrying.',
62
+ };
63
+ }
64
+ return { success: false, message: `An error occurred: ${error.message}` };
65
+ }
66
+ return { success: false, message: 'An unknown error occurred' };
67
+ }
68
+ }
69
+ async interruptExecution() {
70
+ if (this.executionStatus === 'executing' || this.executionStatus === 'paused') {
71
+ abortController?.abort();
72
+ this.executionStatus = 'interrupted';
73
+ this.currentQuestion = null;
74
+ putSystemMessage('Execution interrupted');
75
+ }
76
+ }
77
+ async pauseExecution() {
78
+ if (this.executionStatus === 'executing') {
79
+ this.executionStatus = 'paused';
80
+ putSystemMessage('Execution paused');
81
+ }
82
+ }
83
+ async resumeExecution() {
84
+ if (this.executionStatus === 'paused') {
85
+ this.executionStatus = 'executing';
86
+ putSystemMessage('Execution resumed');
87
+ if (this.pausePromiseResolve) {
88
+ this.pausePromiseResolve();
89
+ this.pausePromiseResolve = null;
90
+ }
91
+ }
92
+ }
93
+ async getExecutionStatus() {
94
+ return this.executionStatus;
95
+ }
96
+ async getCurrentQuestion() {
97
+ return this.currentQuestion;
98
+ }
99
+ async askQuestion(question, confirmation) {
100
+ const questionId = Date.now().toString();
101
+ this.currentQuestion = {
102
+ id: questionId,
103
+ text: question,
104
+ confirmation,
105
+ };
106
+ await this.waitForQuestionAnswer();
107
+ console.log('Question answer wait finished.');
108
+ const { answer, confirmed } = this.askQuestionConversation.find((q) => q.id === questionId) ?? {
109
+ answer: '',
110
+ confirmed: undefined,
111
+ };
112
+ return { answer, confirmed };
113
+ }
114
+ async answerQuestion(questionId, answer, confirmed) {
115
+ if (this.currentQuestion && this.currentQuestion.id === questionId) {
116
+ this.askQuestionConversation.push({
117
+ id: this.currentQuestion.id,
118
+ question: this.currentQuestion.text,
119
+ answer: answer,
120
+ confirmed,
121
+ confirmation: this.currentQuestion.confirmation,
122
+ });
123
+ this.currentQuestion = null;
124
+ }
125
+ }
126
+ handleContent(content) {
127
+ this.content.push(content);
128
+ }
129
+ getContent() {
130
+ return this.content;
131
+ }
132
+ async getUsageMetrics() {
133
+ return await getUsageMetrics();
134
+ }
135
+ getCodegenOptions() {
136
+ return this.codegenOptions;
137
+ }
138
+ async getRcConfig() {
139
+ return rcConfig;
140
+ }
141
+ async deleteIteration(iterationId) {
142
+ const currentIterationId = this.executionStatus !== 'idle' ? this.content.slice(-1)[0]?.message?.iterationId : null;
143
+ this.content = this.content.filter((content) => content.message?.iterationId !== iterationId ||
144
+ // do not delete ongoing iterations
145
+ iterationId === currentIterationId);
146
+ }
147
+ waitForQuestionAnswer() {
148
+ return new Promise((resolve, reject) => {
149
+ const checkQuestion = () => {
150
+ if (abortController?.signal.aborted || this.executionStatus === 'interrupted') {
151
+ reject(new Error('Codegen execution was interrupted'));
152
+ }
153
+ else if (this.currentQuestion === null) {
154
+ resolve();
155
+ }
156
+ else {
157
+ setTimeout(checkQuestion, 100);
158
+ }
159
+ };
160
+ checkQuestion();
161
+ });
162
+ }
163
+ async waitIfPaused() {
164
+ if (this.executionStatus === 'paused') {
165
+ return new Promise((resolve) => {
166
+ this.pausePromiseResolve = resolve;
167
+ });
168
+ }
169
+ }
170
+ }
171
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../../src/main/ui/backend/service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAExF,OAAO,EAAE,eAAe,EAAgB,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAS/D,MAAM,OAAO,OAAO;IACV,eAAe,GAAoD,MAAM,CAAC;IAC1E,eAAe,GAAoB,IAAI,CAAC;IACxC,uBAAuB,GAM1B,EAAE,CAAC;IACA,cAAc,CAAiB;IAC/B,OAAO,GAAmB,EAAE,CAAC;IAC7B,mBAAmB,GAAwB,IAAI,CAAC;IAChD,aAAa,CAAS;IAE9B,YAAY,cAA8B;QACxC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5C,CAAC;IAEO,aAAa;QACnB,OAAO,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAEM,aAAa,CAAC,KAAa;QAChC,OAAO,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC;IACtC,CAAC;IAEM,YAAY;QACjB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAc,EAAE,OAAuB,EAAE,MAAoB;QAChF,IAAI,CAAC,eAAe,GAAG,W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,CAAC,YAAY;QAChB,IAAI,IAAI,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;YACtC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC7B,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ import { CodegenOptions } from '../codegen-types.js';
2
+ export declare function runCodegenUI(options: CodegenOptions): Promise<void>;
@@ -0,0 +1,13 @@
1
+ import { registerContentHandler } from '../common/content-bus.js';
2
+ import { startServer } from './backend/server.js';
3
+ import { Service } from './backend/service.js';
4
+ import { registerUserActionHandlers } from './user-action-handlers.js';
5
+ export async function runCodegenUI(options) {
6
+ console.log('Starting Genaicode Web UI');
7
+ const service = new Service(options);
8
+ registerUserActionHandlers(service);
9
+ registerContentHandler((content) => service.handleContent(content));
10
+ await startServer(service, { uiPort: options.uiPort, additionalFrameAncestors: options.uiFrameAncestors });
11
+ console.log('Genaicode Web UI started');
12
+ }
13
+ //# sourceMappingURL=codegen-ui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen-ui.js","sourceRoot":"","sources":["../../../../src/main/ui/codegen-ui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAEvE,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAuB;IACxD,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IAEzC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAErC,0BAA0B,CAAC,OAAO,CAAC,CAAC;IACpC,sBAAsB,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAEpE,MAAM,WAAW,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAO,EAAE,wBAAwB,EAAE,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAE5G,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { AiServiceType } from '../../codegen-types.js';
2
+ import { UsageMetrics } from '../../common/cost-collector.js';
3
+ export type Usage = {
4
+ usageMetrics: Record<AiServiceType | 'total', UsageMetrics>;
5
+ };
6
+ export interface CodegenResult {
7
+ success: boolean;
8
+ message?: string;
9
+ }
10
+ export type ConfirmationProps = {
11
+ includeAnswer: boolean;
12
+ confirmLabel: string;
13
+ declineLabel: string;
14
+ defaultValue: boolean;
15
+ } | undefined;
16
+ export interface Question {
17
+ id: string;
18
+ text: string;
19
+ confirmation: ConfirmationProps;
20
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=api-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-types.js","sourceRoot":"","sources":["../../../../../src/main/ui/common/api-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import { Service } from './backend/service.js';
2
+ export declare function registerUserActionHandlers(service: Service): void;
@@ -0,0 +1,14 @@
1
+ import { registerConfirmHandler, registerInputHandler } from '../common/user-actions.js';
2
+ export function registerUserActionHandlers(service) {
3
+ registerInputHandler((_, message) => service.askQuestion(message, undefined).then((response) => response.answer));
4
+ registerConfirmHandler(async (props) => {
5
+ const response = await service.askQuestion(props.prompt, {
6
+ defaultValue: props.defaultValue,
7
+ includeAnswer: props.includeAnswer,
8
+ confirmLabel: props.confirmLabel,
9
+ declineLabel: props.declineLabel,
10
+ });
11
+ return response;
12
+ });
13
+ }
14
+ //# sourceMappingURL=user-action-handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-action-handlers.js","sourceRoot":"","sources":["../../../../src/main/ui/user-action-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGzF,MAAM,UAAU,0BAA0B,CAAC,OAAgB;IACzD,oBAAoB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAClH,sBAAsB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACrC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE;YACvD,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,YAAY,EAAE,KAAK,CAAC,YAAY;SACjC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { FunctionDef } from '../../ai-service/common';
2
+ /**
3
+ * Function definition for createDirectory
4
+ */
5
+ export declare const createDirectoryDef: FunctionDef;
6
+ export type CreateDirectoryArgs = {
7
+ filePath: string;
8
+ explanation?: string;
9
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Function definition for createDirectory
3
+ */
4
+ export const createDirectoryDef = {
5
+ name: 'createDirectory',
6
+ description: 'Create a new directory',
7
+ parameters: {
8
+ type: 'object',
9
+ properties: {
10
+ filePath: {
11
+ type: 'string',
12
+ description: 'The directory path to create.',
13
+ },
14
+ explanation: {
15
+ type: 'string',
16
+ description: 'The explanation of the reasoning behind creating this directory',
17
+ },
18
+ },
19
+ required: ['filePath'],
20
+ },
21
+ };
22
+ //# sourceMappingURL=create-directory-def.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-directory-def.js","sourceRoot":"","sources":["../../../../src/operations/create-directory/create-directory-def.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC7C,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,wBAAwB;IACrC,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+BAA+B;aAC7C;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iEAAiE;aAC/E;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,CAAC;KACvB;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { CodegenOptions } from '../../main/codegen-types.js';
2
+ import { CreateDirectoryArgs } from './create-directory-def.js';
3
+ declare function executeCreateDirectory(args: CreateDirectoryArgs, options: CodegenOptions): Promise<void>;
4
+ export declare const executor: typeof executeCreateDirectory;
5
+ export declare const def: import("../../ai-service/common.js").FunctionDef;
6
+ export {};
@@ -0,0 +1,22 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import assert from 'node:assert';
4
+ import { rcConfig } from '../../main/config.js';
5
+ import { isProjectPath } from '../../files/path-utils.js';
6
+ import { createDirectoryDef } from './create-directory-def.js';
7
+ async function executeCreateDirectory(args, options) {
8
+ const { filePath } = args;
9
+ const { allowDirectoryCreate } = options;
10
+ assert(filePath, 'filePath must not be empty');
11
+ const absoluteFilePath = path.isAbsolute(filePath) ? filePath : path.join(rcConfig.rootDir, filePath);
12
+ if (!isProjectPath(absoluteFilePath)) {
13
+ console.log(`Skipping directory: ${absoluteFilePath}`);
14
+ throw new Error(`Directory ${absoluteFilePath} is not located inside project directory, something is wrong?`);
15
+ }
16
+ assert(allowDirectoryCreate, 'Directory create option was not enabled');
17
+ console.log(`Creating directory: ${absoluteFilePath}`);
18
+ fs.mkdirSync(absoluteFilePath, { recursive: true });
19
+ }
20
+ export const executor = executeCreateDirectory;
21
+ export const def = createDirectoryDef;
22
+ //# sourceMappingURL=create-directory-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-directory-executor.js","sourceRoot":"","sources":["../../../../src/operations/create-directory/create-directory-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAuB,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpF,KAAK,UAAU,sBAAsB,CAAC,IAAyB,EAAE,OAAuB;IACtF,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC;IAEzC,MAAM,CAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAC;IAE/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEtG,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,uBAAuB,gBAAgB,EAAE,CAAC,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,aAAa,gBAAgB,+DAA+D,CAAC,CAAC;IAChH,CAAC;IAED,MAAM,CAAC,oBAAoB,EAAE,yCAAyC,CAAC,CAAC;IAExE,OAAO,CAAC,GAAG,CAAC,uBAAuB,gBAAgB,EAAE,CAAC,CAAC;IACvD,EAAE,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,sBAAsB,CAAC;AAC/C,MAAM,CAAC,MAAM,GAAG,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { FunctionDef } from '../../ai-service/common';
2
+ /**
3
+ * Function definition for createFile
4
+ */
5
+ export declare const createFileDef: FunctionDef;
6
+ export type CreateFileArgs = {
7
+ filePath: string;
8
+ explanation?: string;
9
+ newContent: string;
10
+ };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Function definition for createFile
3
+ */
4
+ export const createFileDef = {
5
+ name: 'createFile',
6
+ description: 'Create a new file with specified content. The file will be created inside of project folder structure. This tool should not be used of creation if image files.',
7
+ parameters: {
8
+ type: 'object',
9
+ properties: {
10
+ filePath: {
11
+ type: 'string',
12
+ description: 'Path of the file that will be created, it must not be empty.',
13
+ },
14
+ explanation: {
15
+ type: 'string',
16
+ description: 'The explanation of the reasoning behind creating this file',
17
+ },
18
+ newContent: {
19
+ type: 'string',
20
+ description: 'Content of the file that will be created, it must no be empty.',
21
+ },
22
+ },
23
+ required: ['filePath', 'newContent'],
24
+ },
25
+ };
26
+ //# sourceMappingURL=create-file-def.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-file-def.js","sourceRoot":"","sources":["../../../../src/operations/create-file/create-file-def.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAgB;IACxC,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,iKAAiK;IACnK,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8DAA8D;aAC5E;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4DAA4D;aAC1E;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gEAAgE;aAC9E;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;KACrC;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { CreateFileArgs } from './create-file-def.js';
2
+ import { CodegenOptions } from '../../main/codegen-types.js';
3
+ declare function executeCreateFile(args: CreateFileArgs, options: CodegenOptions): Promise<void>;
4
+ export declare const executor: typeof executeCreateFile;
5
+ export declare const def: import("../../ai-service/common.js").FunctionDef;
6
+ export {};
@@ -0,0 +1,27 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import assert from 'node:assert';
4
+ import { rcConfig } from '../../main/config.js';
5
+ import { isProjectPath } from '../../files/path-utils.js';
6
+ import { createFileDef } from './create-file-def.js';
7
+ async function executeCreateFile(args, options) {
8
+ const { filePath, newContent } = args;
9
+ const { allowFileCreate, allowDirectoryCreate } = options;
10
+ assert(filePath, 'filePath must not be empty');
11
+ assert(newContent, 'newContent must not be empty');
12
+ const absoluteFilePath = path.isAbsolute(filePath) ? filePath : path.join(rcConfig.rootDir, filePath);
13
+ if (!isProjectPath(absoluteFilePath)) {
14
+ console.log(`Skipping file: ${absoluteFilePath}`);
15
+ throw new Error(`File ${absoluteFilePath} is not located inside project directory, something is wrong?`);
16
+ }
17
+ assert(allowFileCreate, 'File create option was not enabled');
18
+ assert(!fs.existsSync(absoluteFilePath), 'File already exists');
19
+ console.log(`Creating file: ${absoluteFilePath}`);
20
+ if (allowDirectoryCreate) {
21
+ fs.mkdirSync(path.dirname(absoluteFilePath), { recursive: true });
22
+ }
23
+ fs.writeFileSync(absoluteFilePath, newContent, 'utf-8');
24
+ }
25
+ export const executor = executeCreateFile;
26
+ export const def = createFileDef;
27
+ //# sourceMappingURL=create-file-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-file-executor.js","sourceRoot":"","sources":["../../../../src/operations/create-file/create-file-executor.ts"],"names":[],"mappings":"A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EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAiB,CAAC;AAC1C,MAAM,CAAC,MAAM,GAAG,GAAG,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { FunctionDef } from '../../ai-service/common';
2
+ /**
3
+ * Function definition for deleteFile
4
+ */
5
+ export declare const deleteFileDef: FunctionDef;
6
+ export type DeleteFileArgs = {
7
+ filePath: string;
8
+ explanation?: string;
9
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Function definition for deleteFile
3
+ */
4
+ export const deleteFileDef = {
5
+ name: 'deleteFile',
6
+ description: 'Delete a specified file from the application source code.',
7
+ parameters: {
8
+ type: 'object',
9
+ properties: {
10
+ explanation: {
11
+ type: 'string',
12
+ description: 'The explanation of the reasoning behind deleting this file',
13
+ },
14
+ filePath: {
15
+ type: 'string',
16
+ description: 'The file path to delete.',
17
+ },
18
+ },
19
+ required: ['filePath'],
20
+ },
21
+ };
22
+ //# sourceMappingURL=delete-file-def.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-file-def.js","sourceRoot":"","sources":["../../../../src/operations/delete-file/delete-file-def.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAgB;IACxC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,2DAA2D;IACxE,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4DAA4D;aAC1E;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0BAA0B;aACxC;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,CAAC;KACvB;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { DeleteFileArgs } from './delete-file-def.js';
2
+ import { CodegenOptions } from '../../main/codegen-types.js';
3
+ declare function executeDeleteFile(args: DeleteFileArgs, options: CodegenOptions): Promise<void>;
4
+ export declare const executor: typeof executeDeleteFile;
5
+ export declare const def: import("../../ai-service/common.js").FunctionDef;
6
+ export {};
@@ -0,0 +1,23 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import assert from 'node:assert';
4
+ import { rcConfig } from '../../main/config.js';
5
+ import { isProjectPath } from '../../files/path-utils.js';
6
+ import { deleteFileDef } from './delete-file-def.js';
7
+ async function executeDeleteFile(args, options) {
8
+ const { filePath } = args;
9
+ const { allowFileDelete } = options;
10
+ assert(filePath, 'filePath must not be empty');
11
+ const absoluteFilePath = path.isAbsolute(filePath) ? filePath : path.join(rcConfig.rootDir, filePath);
12
+ if (!isProjectPath(absoluteFilePath)) {
13
+ console.log(`Skipping file: ${absoluteFilePath}`);
14
+ throw new Error(`File ${absoluteFilePath} is not located inside project directory, something is wrong?`);
15
+ }
16
+ assert(allowFileDelete, 'File delete option was not enabled');
17
+ assert(fs.existsSync(absoluteFilePath), 'File does not exist');
18
+ console.log(`Removing file: ${absoluteFilePath}`);
19
+ fs.unlinkSync(absoluteFilePath);
20
+ }
21
+ export const executor = executeDeleteFile;
22
+ export const def = deleteFileDef;
23
+ //# sourceMappingURL=delete-file-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-file-executor.js","sourceRoot":"","sources":["../../../../src/operations/delete-file/delete-file-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAkB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrE,KAAK,UAAU,iBAAiB,CAAC,IAAoB,EAAE,OAAuB;IAC5E,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAEpC,MAAM,CAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAC;IAE/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEtG,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,kBAAkB,gBAAgB,EAAE,CAAC,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,QAAQ,gBAAgB,+DAA+D,CAAC,CAAC;IAC3G,CAAC;IAED,MAAM,CAAC,eAAe,EAAE,oCAAoC,CAAC,CAAC;IAC9D,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAE/D,OAAO,CAAC,GAAG,CAAC,kBAAkB,gBAAgB,EAAE,CAAC,CAAC;IAClD,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAiB,CAAC;AAC1C,MAAM,CAAC,MAAM,GAAG,GAAG,aAAa,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { FunctionDef } from '../../ai-service/common';
2
+ /**
3
+ * Function definition for downloadFile
4
+ */
5
+ export declare const downloadFileDef: FunctionDef;
6
+ export type DownloadFileArgs = {
7
+ filePath: string;
8
+ downloadUrl: string;
9
+ explanation?: string;
10
+ };