genaicode 0.0.37 → 0.2.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 (312) hide show
  1. package/README.md +3 -1
  2. package/bin/genaicode-dev.js +11 -0
  3. package/bin/genaicode.cjs +15 -1
  4. package/dist/ai-service/ai-studio.d.ts +6 -0
  5. package/dist/ai-service/ai-studio.js +135 -0
  6. package/dist/ai-service/ai-studio.js.map +1 -0
  7. package/dist/ai-service/anthropic.d.ts +6 -0
  8. package/dist/ai-service/anthropic.js +135 -0
  9. package/dist/ai-service/anthropic.js.map +1 -0
  10. package/dist/ai-service/chat-gpt.d.ts +5 -0
  11. package/dist/ai-service/chat-gpt.js +132 -0
  12. package/dist/ai-service/chat-gpt.js.map +1 -0
  13. package/dist/ai-service/common.d.ts +58 -0
  14. package/dist/ai-service/common.js +38 -0
  15. package/dist/ai-service/common.js.map +1 -0
  16. package/dist/ai-service/common.test.d.ts +1 -0
  17. package/dist/ai-service/common.test.js +85 -0
  18. package/dist/ai-service/common.test.js.map +1 -0
  19. package/dist/ai-service/dall-e.d.ts +14 -0
  20. package/dist/ai-service/dall-e.js +48 -0
  21. package/dist/ai-service/dall-e.js.map +1 -0
  22. package/dist/ai-service/vertex-ai-claude.d.ts +5 -0
  23. package/dist/ai-service/vertex-ai-claude.js +94 -0
  24. package/dist/ai-service/vertex-ai-claude.js.map +1 -0
  25. package/dist/ai-service/vertex-ai-imagen.d.ts +14 -0
  26. package/dist/ai-service/vertex-ai-imagen.js +77 -0
  27. package/dist/ai-service/vertex-ai-imagen.js.map +1 -0
  28. package/dist/ai-service/vertex-ai.d.ts +7 -0
  29. package/dist/ai-service/vertex-ai.js +142 -0
  30. package/dist/ai-service/vertex-ai.js.map +1 -0
  31. package/dist/cli/cli-options.d.ts +10 -0
  32. package/dist/cli/cli-options.js +124 -0
  33. package/dist/cli/cli-options.js.map +1 -0
  34. package/dist/cli/cli-options.test.d.ts +1 -0
  35. package/dist/cli/cli-options.test.js +34 -0
  36. package/dist/cli/cli-options.test.js.map +1 -0
  37. package/dist/cli/cli-params.d.ts +30 -0
  38. package/dist/cli/cli-params.js +109 -0
  39. package/dist/cli/cli-params.js.map +1 -0
  40. package/dist/cli/cli-params.test.d.ts +1 -0
  41. package/dist/cli/cli-params.test.js +38 -0
  42. package/dist/cli/cli-params.test.js.map +1 -0
  43. package/dist/cli/service-autodetect.d.ts +2 -0
  44. package/dist/cli/service-autodetect.js +17 -0
  45. package/dist/cli/service-autodetect.js.map +1 -0
  46. package/dist/cli/service-autodetect.test.d.ts +1 -0
  47. package/dist/cli/service-autodetect.test.js +38 -0
  48. package/dist/cli/service-autodetect.test.js.map +1 -0
  49. package/dist/cli/validate-cli-params.d.ts +18 -0
  50. package/dist/cli/validate-cli-params.js +129 -0
  51. package/dist/cli/validate-cli-params.js.map +1 -0
  52. package/dist/cli/validate-cli-params.test.d.ts +1 -0
  53. package/dist/cli/validate-cli-params.test.js +106 -0
  54. package/dist/cli/validate-cli-params.test.js.map +1 -0
  55. package/dist/files/file-utils.d.ts +2 -0
  56. package/dist/files/file-utils.js +7 -0
  57. package/dist/files/file-utils.js.map +1 -0
  58. package/dist/files/file-utils.test.d.ts +1 -0
  59. package/dist/files/file-utils.test.js +18 -0
  60. package/dist/files/file-utils.test.js.map +1 -0
  61. package/dist/files/find-files.d.ts +8 -0
  62. package/dist/files/find-files.js +76 -0
  63. package/dist/files/find-files.js.map +1 -0
  64. package/dist/files/read-files.d.ts +18 -0
  65. package/dist/files/read-files.js +66 -0
  66. package/dist/files/read-files.js.map +1 -0
  67. package/dist/files/read-files.test.d.ts +1 -0
  68. package/dist/files/read-files.test.js +88 -0
  69. package/dist/files/read-files.test.js.map +1 -0
  70. package/dist/files/temp-buffer.d.ts +2 -0
  71. package/dist/files/temp-buffer.js +12 -0
  72. package/dist/files/temp-buffer.js.map +1 -0
  73. package/dist/files/update-files.d.ts +6 -0
  74. package/dist/files/update-files.js +197 -0
  75. package/dist/files/update-files.js.map +1 -0
  76. package/dist/images/ensure-alpha.d.ts +1 -0
  77. package/dist/images/ensure-alpha.js +5 -0
  78. package/dist/images/ensure-alpha.js.map +1 -0
  79. package/dist/images/imgly-remove-background.d.ts +2 -0
  80. package/dist/images/imgly-remove-background.js +21 -0
  81. package/dist/images/imgly-remove-background.js.map +1 -0
  82. package/dist/images/resize-image.d.ts +19 -0
  83. package/dist/images/resize-image.js +22 -0
  84. package/dist/images/resize-image.js.map +1 -0
  85. package/dist/images/split-image.d.ts +18 -0
  86. package/dist/images/split-image.js +25 -0
  87. package/dist/images/split-image.js.map +1 -0
  88. package/dist/main/codegen-interactive-utils.d.ts +8 -0
  89. package/dist/main/codegen-interactive-utils.js +148 -0
  90. package/dist/main/codegen-interactive-utils.js.map +1 -0
  91. package/dist/main/codegen-interactive.d.ts +2 -0
  92. package/dist/main/codegen-interactive.js +68 -0
  93. package/dist/main/codegen-interactive.js.map +1 -0
  94. package/dist/main/codegen-types.d.ts +28 -0
  95. package/dist/main/codegen-types.js +2 -0
  96. package/dist/main/codegen-types.js.map +1 -0
  97. package/dist/main/codegen.d.ts +4 -0
  98. package/dist/main/codegen.js +164 -0
  99. package/dist/main/codegen.js.map +1 -0
  100. package/dist/main/codegen.test.d.ts +2 -0
  101. package/dist/main/codegen.test.js +273 -0
  102. package/dist/main/codegen.test.js.map +1 -0
  103. package/dist/main/config-lib.d.ts +16 -0
  104. package/dist/main/config-lib.js +28 -0
  105. package/dist/main/config-lib.js.map +1 -0
  106. package/dist/main/config-lib.test.d.ts +1 -0
  107. package/dist/main/config-lib.test.js +64 -0
  108. package/dist/main/config-lib.test.js.map +1 -0
  109. package/dist/main/config.d.ts +6 -0
  110. package/{src → dist}/main/config.js +28 -22
  111. package/dist/main/config.js.map +1 -0
  112. package/dist/main/interactive/codegen-interactive.d.ts +2 -0
  113. package/dist/main/interactive/codegen-interactive.js +55 -0
  114. package/dist/main/interactive/codegen-interactive.js.map +1 -0
  115. package/dist/main/interactive/codegen-interactive.test.d.ts +4 -0
  116. package/dist/main/interactive/codegen-interactive.test.js +77 -0
  117. package/dist/main/interactive/codegen-interactive.test.js.map +1 -0
  118. package/dist/main/interactive/codegen-worker.d.ts +3 -0
  119. package/dist/main/interactive/codegen-worker.js +47 -0
  120. package/dist/main/interactive/codegen-worker.js.map +1 -0
  121. package/dist/main/interactive/common.d.ts +5 -0
  122. package/dist/main/interactive/common.js +51 -0
  123. package/dist/main/interactive/common.js.map +1 -0
  124. package/dist/main/interactive/configure.d.ts +2 -0
  125. package/dist/main/interactive/configure.js +99 -0
  126. package/dist/main/interactive/configure.js.map +1 -0
  127. package/dist/main/interactive/error-handling.d.ts +4 -0
  128. package/dist/main/interactive/error-handling.js +49 -0
  129. package/dist/main/interactive/error-handling.js.map +1 -0
  130. package/dist/main/interactive/help.d.ts +1 -0
  131. package/dist/main/interactive/help.js +22 -0
  132. package/dist/main/interactive/help.js.map +1 -0
  133. package/dist/main/interactive/process-comments.d.ts +2 -0
  134. package/dist/main/interactive/process-comments.js +39 -0
  135. package/dist/main/interactive/process-comments.js.map +1 -0
  136. package/dist/main/interactive/select-ai-service.d.ts +2 -0
  137. package/dist/main/interactive/select-ai-service.js +27 -0
  138. package/dist/main/interactive/select-ai-service.js.map +1 -0
  139. package/dist/main/interactive/task-file.d.ts +2 -0
  140. package/dist/main/interactive/task-file.js +28 -0
  141. package/dist/main/interactive/task-file.js.map +1 -0
  142. package/dist/main/interactive/text-prompt.d.ts +2 -0
  143. package/dist/main/interactive/text-prompt.js +18 -0
  144. package/dist/main/interactive/text-prompt.js.map +1 -0
  145. package/dist/main/interactive/user-interrupt.d.ts +1 -0
  146. package/dist/main/interactive/user-interrupt.js +36 -0
  147. package/dist/main/interactive/user-interrupt.js.map +1 -0
  148. package/dist/main/interactive/worker-script.d.ts +1 -0
  149. package/dist/main/interactive/worker-script.js +24 -0
  150. package/dist/main/interactive/worker-script.js.map +1 -0
  151. package/dist/main/interactive/worker.d.ts +2 -0
  152. package/dist/main/interactive/worker.js +55 -0
  153. package/dist/main/interactive/worker.js.map +1 -0
  154. package/dist/prompt/function-calling-validate.d.ts +3 -0
  155. package/dist/prompt/function-calling-validate.js +33 -0
  156. package/dist/prompt/function-calling-validate.js.map +1 -0
  157. package/dist/prompt/function-calling.d.ts +5 -0
  158. package/{src → dist}/prompt/function-calling.js +25 -24
  159. package/dist/prompt/function-calling.js.map +1 -0
  160. package/dist/prompt/function-defs/ask-question.d.ts +65 -0
  161. package/dist/prompt/function-defs/ask-question.js +67 -0
  162. package/dist/prompt/function-defs/ask-question.js.map +1 -0
  163. package/dist/prompt/function-defs/codegen-summary.d.ts +63 -0
  164. package/dist/prompt/function-defs/codegen-summary.js +80 -0
  165. package/dist/prompt/function-defs/codegen-summary.js.map +1 -0
  166. package/dist/prompt/function-defs/create-directory.d.ts +21 -0
  167. package/dist/prompt/function-defs/create-directory.js +22 -0
  168. package/dist/prompt/function-defs/create-directory.js.map +1 -0
  169. package/dist/prompt/function-defs/create-file.d.ts +25 -0
  170. package/dist/prompt/function-defs/create-file.js +26 -0
  171. package/dist/prompt/function-defs/create-file.js.map +1 -0
  172. package/dist/prompt/function-defs/delete-file.d.ts +21 -0
  173. package/dist/prompt/function-defs/delete-file.js +22 -0
  174. package/dist/prompt/function-defs/delete-file.js.map +1 -0
  175. package/dist/prompt/function-defs/download-file.d.ts +25 -0
  176. package/dist/prompt/function-defs/download-file.js +26 -0
  177. package/dist/prompt/function-defs/download-file.js.map +1 -0
  178. package/dist/prompt/function-defs/explanation.d.ts +17 -0
  179. package/dist/prompt/function-defs/explanation.js +18 -0
  180. package/dist/prompt/function-defs/explanation.js.map +1 -0
  181. package/dist/prompt/function-defs/generate-image.d.ts +41 -0
  182. package/dist/prompt/function-defs/generate-image.js +42 -0
  183. package/dist/prompt/function-defs/generate-image.js.map +1 -0
  184. package/dist/prompt/function-defs/get-image-assets.d.ts +20 -0
  185. package/dist/prompt/function-defs/get-image-assets.js +21 -0
  186. package/dist/prompt/function-defs/get-image-assets.js.map +1 -0
  187. package/dist/prompt/function-defs/get-source-code.d.ts +20 -0
  188. package/dist/prompt/function-defs/get-source-code.js +21 -0
  189. package/dist/prompt/function-defs/get-source-code.js.map +1 -0
  190. package/dist/prompt/function-defs/imgly-remove-background.d.ts +25 -0
  191. package/dist/prompt/function-defs/imgly-remove-background.js +26 -0
  192. package/dist/prompt/function-defs/imgly-remove-background.js.map +1 -0
  193. package/dist/prompt/function-defs/move-file.d.ts +25 -0
  194. package/dist/prompt/function-defs/move-file.js +26 -0
  195. package/dist/prompt/function-defs/move-file.js.map +1 -0
  196. package/dist/prompt/function-defs/patch-file.d.ts +25 -0
  197. package/dist/prompt/function-defs/patch-file.js +39 -0
  198. package/dist/prompt/function-defs/patch-file.js.map +1 -0
  199. package/dist/prompt/function-defs/resize-image.d.ts +36 -0
  200. package/dist/prompt/function-defs/resize-image.js +37 -0
  201. package/dist/prompt/function-defs/resize-image.js.map +1 -0
  202. package/dist/prompt/function-defs/split-image.d.ts +57 -0
  203. package/dist/prompt/function-defs/split-image.js +46 -0
  204. package/dist/prompt/function-defs/split-image.js.map +1 -0
  205. package/dist/prompt/function-defs/update-file.d.ts +25 -0
  206. package/dist/prompt/function-defs/update-file.js +26 -0
  207. package/dist/prompt/function-defs/update-file.js.map +1 -0
  208. package/dist/prompt/limits.d.ts +3 -0
  209. package/dist/prompt/limits.js +19 -0
  210. package/dist/prompt/limits.js.map +1 -0
  211. package/dist/prompt/limits.test.d.ts +1 -0
  212. package/dist/prompt/limits.test.js +35 -0
  213. package/dist/prompt/limits.test.js.map +1 -0
  214. package/dist/prompt/prompt-codegen.d.ts +9 -0
  215. package/dist/prompt/prompt-codegen.js +90 -0
  216. package/dist/prompt/prompt-codegen.js.map +1 -0
  217. package/dist/prompt/prompt-codegen.test.d.ts +1 -0
  218. package/dist/prompt/prompt-codegen.test.js +98 -0
  219. package/dist/prompt/prompt-codegen.test.js.map +1 -0
  220. package/dist/prompt/prompt-consts.d.ts +1 -0
  221. package/{src → dist}/prompt/prompt-consts.js +1 -0
  222. package/dist/prompt/prompt-consts.js.map +1 -0
  223. package/dist/prompt/prompt-service-ask-question.test.d.ts +3 -0
  224. package/dist/prompt/prompt-service-ask-question.test.js +142 -0
  225. package/dist/prompt/prompt-service-ask-question.test.js.map +1 -0
  226. package/dist/prompt/prompt-service.d.ts +28 -0
  227. package/dist/prompt/prompt-service.js +163 -0
  228. package/dist/prompt/prompt-service.js.map +1 -0
  229. package/dist/prompt/prompt-service.test.d.ts +1 -0
  230. package/dist/prompt/prompt-service.test.js +531 -0
  231. package/dist/prompt/prompt-service.test.js.map +1 -0
  232. package/dist/prompt/steps/step-ask-question.d.ts +6 -0
  233. package/dist/prompt/steps/step-ask-question.js +82 -0
  234. package/dist/prompt/steps/step-ask-question.js.map +1 -0
  235. package/dist/prompt/steps/step-generate-image.d.ts +2 -0
  236. package/dist/prompt/steps/step-generate-image.js +29 -0
  237. package/dist/prompt/steps/step-generate-image.js.map +1 -0
  238. package/dist/prompt/steps/step-validate-recover.d.ts +13 -0
  239. package/dist/prompt/steps/step-validate-recover.js +51 -0
  240. package/dist/prompt/steps/step-validate-recover.js.map +1 -0
  241. package/dist/prompt/steps/step-verify-patch.d.ts +7 -0
  242. package/dist/prompt/steps/step-verify-patch.js +41 -0
  243. package/dist/prompt/steps/step-verify-patch.js.map +1 -0
  244. package/dist/prompt/steps/steps-types.d.ts +4 -0
  245. package/dist/prompt/steps/steps-types.js +6 -0
  246. package/dist/prompt/steps/steps-types.js.map +1 -0
  247. package/dist/prompt/systemprompt.d.ts +3 -0
  248. package/dist/prompt/systemprompt.js +47 -0
  249. package/dist/prompt/systemprompt.js.map +1 -0
  250. package/dist/prompt/systemprompt.test.d.ts +3 -0
  251. package/dist/prompt/systemprompt.test.js +46 -0
  252. package/dist/prompt/systemprompt.test.js.map +1 -0
  253. package/package.json +15 -5
  254. package/bin/genaicode.js +0 -5
  255. package/bin/vertex-monkey-patch.cjs +0 -33
  256. package/src/ai-service/anthropic.js +0 -126
  257. package/src/ai-service/chat-gpt.js +0 -126
  258. package/src/ai-service/common.js +0 -49
  259. package/src/ai-service/common.test.js +0 -107
  260. package/src/ai-service/dall-e.js +0 -50
  261. package/src/ai-service/vertex-ai-claude.js +0 -99
  262. package/src/ai-service/vertex-ai-imagen.js +0 -78
  263. package/src/ai-service/vertex-ai.js +0 -156
  264. package/src/cli/cli-options.js +0 -132
  265. package/src/cli/cli-options.test.js +0 -50
  266. package/src/cli/cli-params.js +0 -114
  267. package/src/cli/cli-params.test.js +0 -43
  268. package/src/cli/service-autodetect.js +0 -11
  269. package/src/cli/service-autodetect.test.js +0 -43
  270. package/src/cli/validate-cli-params.js +0 -137
  271. package/src/cli/validate-cli-params.test.js +0 -134
  272. package/src/files/file-utils.js +0 -7
  273. package/src/files/file-utils.test.js +0 -21
  274. package/src/files/find-files.js +0 -86
  275. package/src/files/read-files.js +0 -65
  276. package/src/files/read-files.test.js +0 -103
  277. package/src/files/temp-buffer.js +0 -13
  278. package/src/files/update-files.js +0 -205
  279. package/src/images/ensure-alpha.js +0 -5
  280. package/src/images/imgly-remove-background.js +0 -23
  281. package/src/images/resize-image.js +0 -23
  282. package/src/images/split-image.js +0 -26
  283. package/src/main/codegen.js +0 -120
  284. package/src/main/codegen.test.js +0 -335
  285. package/src/main/config-lib.js +0 -33
  286. package/src/main/config-lib.test.js +0 -80
  287. package/src/prompt/function-calling-validate.js +0 -25
  288. package/src/prompt/function-defs/ask-question.js +0 -33
  289. package/src/prompt/function-defs/codegen-summary.js +0 -87
  290. package/src/prompt/function-defs/create-directory.js +0 -21
  291. package/src/prompt/function-defs/create-file.js +0 -26
  292. package/src/prompt/function-defs/delete-file.js +0 -21
  293. package/src/prompt/function-defs/download-file.js +0 -25
  294. package/src/prompt/function-defs/explanation.js +0 -17
  295. package/src/prompt/function-defs/generate-image.js +0 -51
  296. package/src/prompt/function-defs/get-image-assets.js +0 -21
  297. package/src/prompt/function-defs/get-source-code.js +0 -21
  298. package/src/prompt/function-defs/imgly-remove-background.js +0 -25
  299. package/src/prompt/function-defs/move-file.js +0 -25
  300. package/src/prompt/function-defs/patch-file.js +0 -39
  301. package/src/prompt/function-defs/resize-image.js +0 -36
  302. package/src/prompt/function-defs/split-image.js +0 -45
  303. package/src/prompt/function-defs/update-file.js +0 -26
  304. package/src/prompt/limits.js +0 -23
  305. package/src/prompt/limits.test.js +0 -40
  306. package/src/prompt/prompt-codegen.js +0 -106
  307. package/src/prompt/prompt-codegen.test.js +0 -116
  308. package/src/prompt/prompt-service-ask-question.test.js +0 -163
  309. package/src/prompt/prompt-service.js +0 -335
  310. package/src/prompt/prompt-service.test.js +0 -602
  311. package/src/prompt/systemprompt.js +0 -39
  312. package/src/prompt/systemprompt.test.js +0 -64
@@ -0,0 +1,27 @@
1
+ import { select } from '@inquirer/prompts';
2
+ const AI_SERVICE_CHOICES = [
3
+ { name: 'Vertex AI (Gemini)', value: 'vertex-ai' },
4
+ { name: 'AI Studio (Gemini)', value: 'ai-studio' },
5
+ { name: 'ChatGPT', value: 'chat-gpt' },
6
+ { name: 'Anthropic Claude', value: 'anthropic' },
7
+ { name: 'Claude via Vertex AI', value: 'vertex-ai-claude' },
8
+ ];
9
+ export const selectAiService = async (defaultAiService) => {
10
+ try {
11
+ const selectedAiService = await select({
12
+ message: 'Select the AI model you want to use:',
13
+ pageSize: AI_SERVICE_CHOICES.length,
14
+ choices: AI_SERVICE_CHOICES.map((choice) => ({
15
+ ...choice,
16
+ checked: defaultAiService === choice.value,
17
+ })),
18
+ default: defaultAiService,
19
+ });
20
+ return selectedAiService;
21
+ }
22
+ catch (error) {
23
+ console.error('Error selecting AI service:', error);
24
+ throw error;
25
+ }
26
+ };
27
+ //# sourceMappingURL=select-ai-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-ai-service.js","sourceRoot":"","sources":["../../../src/main/interactive/select-ai-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,MAAM,kBAAkB,GAAG;IACzB,EAAE,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,WAAW,EAAE;IAClD,EAAE,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,WAAW,EAAE;IAClD,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE;IACtC,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,WAAW,EAAE;IAChD,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,kBAAkB,EAAE;CACnD,CAAC;AAEX,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,gBAA2C,EAA0B,EAAE;IAC3G,IAAI,CAAC;QACH,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAgB;YACpD,OAAO,EAAE,sCAAsC;YAC/C,QAAQ,EAAE,kBAAkB,CAAC,MAAM;YACnC,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBAC3C,GAAG,MAAM;gBACT,OAAO,EAAE,gBAAgB,KAAK,MAAM,CAAC,KAAK;aAC3C,CAAC,CAAC;YACH,OAAO,EAAE,gBAAgB;SAC1B,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QACpD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { CodegenOptions } from '../codegen-types.js';
2
+ export declare function runTaskFile(options: CodegenOptions): Promise<void>;
@@ -0,0 +1,28 @@
1
+ import fileSelector from 'inquirer-file-selector';
2
+ import { rcConfig } from '../config.js';
3
+ import { runCodegenWorker } from './codegen-worker.js';
4
+ export async function runTaskFile(options) {
5
+ try {
6
+ const taskFile = await fileSelector({
7
+ message: 'Select task file:',
8
+ path: rcConfig.rootDir,
9
+ allowCancel: true,
10
+ });
11
+ if (taskFile === 'canceled') {
12
+ console.log('Task file selection cancelled. Returning to main menu...');
13
+ return;
14
+ }
15
+ else if (taskFile) {
16
+ console.log(`Selected task file: ${taskFile}`);
17
+ await runCodegenWorker({ ...options, taskFile, considerAllFiles: true });
18
+ }
19
+ else {
20
+ return;
21
+ }
22
+ }
23
+ catch (error) {
24
+ console.error('Error selecting task file:', error);
25
+ throw error;
26
+ }
27
+ }
28
+ //# sourceMappingURL=task-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-file.js","sourceRoot":"","sources":["../../../src/main/interactive/task-file.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAuB;IACvD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC;YAClC,OAAO,EAAE,mBAAmB;YAC5B,IAAI,EAAE,QAAQ,CAAC,OAAO;YACtB,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QAEH,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;YACxE,OAAO;QACT,CAAC;aAAM,IAAI,QAAQ,EAAE,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,uBAAuB,QAAQ,EAAE,CAAC,CAAC;YAC/C,MAAM,gBAAgB,CAAC,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3E,CAAC;aAAM,CAAC;YACN,OAAO;QACT,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QACnD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { CodegenOptions } from '../codegen-types.js';
2
+ export declare function runTextPrompt(options: CodegenOptions): Promise<void>;
@@ -0,0 +1,18 @@
1
+ import { input } from '@inquirer/prompts';
2
+ import { runCodegenWorker } from './codegen-worker.js';
3
+ export async function runTextPrompt(options) {
4
+ try {
5
+ const prompt = await input({
6
+ message: 'Enter your text prompt:',
7
+ });
8
+ console.log(`Received prompt: ${prompt}`);
9
+ if (prompt) {
10
+ await runCodegenWorker({ ...options, explicitPrompt: prompt, considerAllFiles: true });
11
+ }
12
+ }
13
+ catch (error) {
14
+ console.error('Error getting text prompt:', error);
15
+ throw error;
16
+ }
17
+ }
18
+ //# sourceMappingURL=text-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-prompt.js","sourceRoot":"","sources":["../../../src/main/interactive/text-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAuB;IACzD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC;YACzB,OAAO,EAAE,yBAAyB;SACnC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAM,EAAE,CAAC,CAAC;QAC1C,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,gBAAgB,CAAC,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QACnD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const handleUserInterrupt: (abortController: AbortController) => Promise<void>;
@@ -0,0 +1,36 @@
1
+ import readline from 'readline';
2
+ export const handleUserInterrupt = (abortController) => {
3
+ return new Promise((resolve) => {
4
+ const rl = createReadlineInterface();
5
+ console.log('\nPress Ctrl+C to interrupt the operation...');
6
+ const removeKeyPressHandler = setupKeyPressHandler(rl, abortController);
7
+ rl.on('close', () => {
8
+ removeKeyPressHandler();
9
+ resolve();
10
+ });
11
+ abortController.signal.addEventListener('abort', () => {
12
+ rl.close();
13
+ resolve();
14
+ }, { once: true });
15
+ });
16
+ };
17
+ const createReadlineInterface = () => {
18
+ return readline.createInterface({
19
+ input: process.stdin,
20
+ output: process.stdout,
21
+ });
22
+ };
23
+ const setupKeyPressHandler = (rl, abortController) => {
24
+ const handleKeyPress = (str, key) => {
25
+ if (key.ctrl && key.name === 'c') {
26
+ console.log('\nInterruption requested. Aborting operation...');
27
+ abortController.abort();
28
+ rl.close();
29
+ }
30
+ };
31
+ process.stdin.on('keypress', handleKeyPress);
32
+ return () => {
33
+ process.stdin.removeListener('keypress', handleKeyPress);
34
+ };
35
+ };
36
+ //# sourceMappingURL=user-interrupt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-interrupt.js","sourceRoot":"","sources":["../../../src/main/interactive/user-interrupt.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,eAAgC,EAAiB,EAAE;IACrF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,EAAE,GAAG,uBAAuB,EAAE,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;QAE5D,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;QAExE,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YAClB,qBAAqB,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;QAEH,eAAe,CAAC,MAAM,CAAC,gBAAgB,CACrC,OAAO,EACP,GAAG,EAAE;YACH,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;QACZ,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AACF,MAAM,uBAAuB,GAAG,GAAG,EAAE;IACnC,OAAO,QAAQ,CAAC,eAAe,CAAC;QAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,EAAsB,EAAE,eAAgC,EAAE,EAAE;IACxF,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,GAAoC,EAAE,EAAE;QAC3E,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;YAC/D,eAAe,CAAC,KAAK,EAAE,CAAC;YACxB,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAE7C,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { parentPort } from 'worker_threads';
2
+ import assert from 'node:assert';
3
+ import { runCodegenIteration } from '../codegen.js';
4
+ assert(parentPort, 'parentPort must be defined.');
5
+ parentPort.on('message', async ({ action, options, additionalData }) => {
6
+ try {
7
+ switch (action) {
8
+ case 'process_comments':
9
+ await runCodegenIteration(options);
10
+ break;
11
+ case 'text_prompt':
12
+ case 'task_file':
13
+ await runCodegenIteration({ ...options, ...additionalData });
14
+ break;
15
+ default:
16
+ throw new Error('Unknown action');
17
+ }
18
+ parentPort.postMessage('done');
19
+ }
20
+ catch (error) {
21
+ parentPort.postMessage({ error: error.message });
22
+ }
23
+ });
24
+ //# sourceMappingURL=worker-script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-script.js","sourceRoot":"","sources":["../../../src/main/interactive/worker-script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,CAAC,UAAU,EAAE,6BAA6B,CAAC,CAAC;AAElD,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE;IACrE,IAAI,CAAC;QACH,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,kBAAkB;gBACrB,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;gBACnC,MAAM;YACR,KAAK,aAAa,CAAC;YACnB,KAAK,WAAW;gBACd,MAAM,mBAAmB,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC,CAAC;gBAC7D,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACtC,CAAC;QACD,UAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAW,CAAC,WAAW,CAAC,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { CodegenOptions } from '../codegen-types.js';
2
+ export declare const runWorker: (action: string, options: CodegenOptions, additionalData?: Record<string, unknown>) => Promise<void>;
@@ -0,0 +1,55 @@
1
+ import { SHARE_ENV, Worker } from 'worker_threads';
2
+ import { handleUserInterrupt } from './common.js';
3
+ import { fileURLToPath } from 'url';
4
+ import path from 'path';
5
+ // Helper function to create and run a worker
6
+ export const runWorker = async (action, options, additionalData) => {
7
+ // Define __dirname and __filename using import.meta.url
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+ // Path to the worker file
11
+ const workerFile = path.join(__dirname, 'worker-script.js');
12
+ console.log('Start worker...');
13
+ const worker = new Worker(workerFile, {
14
+ env: SHARE_ENV,
15
+ });
16
+ worker.postMessage({ action, options, additionalData });
17
+ try {
18
+ await Promise.race([
19
+ new Promise((resolve, reject) => {
20
+ worker.on('message', (message) => {
21
+ if (message === 'done') {
22
+ resolve(message);
23
+ }
24
+ else if (message.error) {
25
+ reject(new Error(message.error));
26
+ }
27
+ });
28
+ worker.on('error', reject);
29
+ worker.on('exit', (code) => {
30
+ if (code !== 0)
31
+ reject(new Error(`Worker stopped with exit code ${code}`));
32
+ });
33
+ }),
34
+ handleUserInterrupt(worker),
35
+ ]);
36
+ }
37
+ catch (error) {
38
+ if (error instanceof Error) {
39
+ if (error.message === 'OPERATION_INTERRUPTED') {
40
+ console.log('Operation interrupted by user. Returning to main menu...');
41
+ }
42
+ else {
43
+ console.error(`Error during ${action}:`, error);
44
+ }
45
+ }
46
+ else {
47
+ console.log('Worker error', error);
48
+ }
49
+ }
50
+ finally {
51
+ console.log('Worker terminate.');
52
+ worker.terminate();
53
+ }
54
+ };
55
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/main/interactive/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,6CAA6C;AAC7C,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,MAAc,EACd,OAAuB,EACvB,cAAwC,EACzB,EAAE;IACjB,wDAAwD;IACxD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAE3C,0BAA0B;IAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE;QACpC,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IACH,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;IAExD,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,IAAI,CAAC;YACjB,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC9B,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;oBAC/B,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;wBACvB,OAAO,CAAC,OAAO,CAAC,CAAC;oBACnB,CAAC;yBAAM,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;wBACzB,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;oBACnC,CAAC;gBACH,CAAC,CAAC,CAAC;gBACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBAC3B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;oBACzB,IAAI,IAAI,KAAK,CAAC;wBAAE,MAAM,CAAC,IAAI,KAAK,CAAC,iCAAiC,IAAI,EAAE,CAAC,CAAC,CAAC;gBAC7E,CAAC,CAAC,CAAC;YACL,CAAC,CAAC;YACF,mBAAmB,CAAC,MAAM,CAAC;SAC5B,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,IAAI,KAAK,CAAC,OAAO,KAAK,uBAAuB,EAAE,CAAC;gBAC9C,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;YAC1E,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,gBAAgB,MAAM,GAAG,EAAE,KAAK,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACjC,MAAM,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ValidatorResult } from 'jsonschema';
2
+ import { FunctionCall } from '../ai-service/common.js';
3
+ export declare function validateFunctionCall(call: FunctionCall | undefined, requiredFunctionName: string): Omit<ValidatorResult, 'addError'> | undefined;
@@ -0,0 +1,33 @@
1
+ import { Validator } from 'jsonschema';
2
+ import { functionDefs } from './function-calling.js';
3
+ export function validateFunctionCall(call, requiredFunctionName) {
4
+ const validator = new Validator();
5
+ const functionDef = functionDefs.find((def) => def.name === call?.name);
6
+ if (!call || call.name !== requiredFunctionName) {
7
+ return makeError(`Function "${requiredFunctionName}" was not called.`, call);
8
+ }
9
+ if (!functionDef) {
10
+ return makeError(`Function "${call.name}" is not defined.`, call);
11
+ }
12
+ const validationResult = validator.validate(call.args, functionDef.parameters);
13
+ if (validationResult.errors.length > 0) {
14
+ return validationResult;
15
+ }
16
+ return undefined;
17
+ }
18
+ function makeError(message, call) {
19
+ return {
20
+ errors: [
21
+ {
22
+ message,
23
+ },
24
+ ],
25
+ valid: false,
26
+ instance: call,
27
+ schema: {},
28
+ propertyPath: '',
29
+ disableFormat: false,
30
+ throwError: true,
31
+ };
32
+ }
33
+ //# sourceMappingURL=function-calling-validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-calling-validate.js","sourceRoot":"","sources":["../../src/prompt/function-calling-validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA4C,MAAM,YAAY,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,UAAU,oBAAoB,CAClC,IAA8B,EAC9B,oBAA4B;IAE5B,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;IAClC,MAAM,WAAW,GAA4B,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,IAAI,CAAC,CAAC;IAEjG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAChD,OAAO,SAAS,CAAC,aAAa,oBAAoB,mBAAmB,EAAE,IAAI,CAAC,CAAC;IAC/E,CAAC;IAED,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC,aAAa,IAAI,CAAC,IAAI,mBAAmB,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,gBAAgB,GAAoB,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,UAA+B,CAAC,CAAC;IAErH,IAAI,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CAAC,OAAe,EAAE,IAA8B;IAChE,OAAO;QACL,MAAM,EAAE;YACN;gBACE,OAAO;aACsB;SAChC;QACD,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAY;QACpB,YAAY,EAAE,EAAE;QAChB,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,IAAI;KACjB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { FunctionDef } from '../ai-service/common.js';
2
+ /**
3
+ * Function definitions for function calling feature
4
+ */
5
+ export declare const functionDefs: FunctionDef[];
@@ -15,33 +15,34 @@ import { imglyRemoveBackground } from './function-defs/imgly-remove-background.j
15
15
  import { resizeImage } from './function-defs/resize-image.js';
16
16
  import { splitImage } from './function-defs/split-image.js';
17
17
  import { askQuestion } from './function-defs/ask-question.js';
18
-
19
18
  /**
20
19
  * Function definitions for function calling feature
21
20
  */
22
21
  export const functionDefs = [
23
- getSourceCode,
24
- getImageAssets,
25
- codegenSummary,
26
- updateFile,
27
- patchFile,
28
- createFile,
29
- deleteFile,
30
- explanation,
31
- createDirectory,
32
- moveFile,
33
- generateImage,
34
- downloadFile,
35
- imglyRemoveBackground,
36
- resizeImage,
37
- splitImage,
38
- askQuestion,
22
+ getSourceCode,
23
+ getImageAssets,
24
+ codegenSummary,
25
+ updateFile,
26
+ patchFile,
27
+ createFile,
28
+ deleteFile,
29
+ explanation,
30
+ createDirectory,
31
+ moveFile,
32
+ generateImage,
33
+ downloadFile,
34
+ imglyRemoveBackground,
35
+ resizeImage,
36
+ splitImage,
37
+ askQuestion,
38
+ // @ts-expect-error (fix this once fun defs are converted to ts)
39
39
  ].map((fd) => {
40
- if (requireExplanations && fd.parameters.properties.explanation && !fd.parameters.required.includes('explanation')) {
41
- fd.parameters.required.push('explanation');
42
- } else if (!requireExplanations) {
43
- delete fd.parameters.properties.explanation;
44
- }
45
-
46
- return fd;
40
+ if (requireExplanations && fd.parameters.properties.explanation && !fd.parameters.required.includes('explanation')) {
41
+ fd.parameters.required.push('explanation');
42
+ }
43
+ else if (!requireExplanations) {
44
+ delete fd.parameters.properties.explanation;
45
+ }
46
+ return fd;
47
47
  });
48
+ //# sourceMappingURL=function-calling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-calling.js","sourceRoot":"","sources":["../../src/prompt/function-calling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC,aAAa;IACb,cAAc;IACd,cAAc;IACd,UAAU;IACV,SAAS;IACT,UAAU;IACV,UAAU;IACV,WAAW;IACX,eAAe;IACf,QAAQ;IACR,aAAa;IACb,YAAY;IACZ,qBAAqB;IACrB,WAAW;IACX,UAAU;IACV,WAAW;IACX,gEAAgE;CACjE,CAAC,GAAG,CAAC,CAAC,EAAe,EAAE,EAAE;IACxB,IAAI,mBAAmB,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;QACnH,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;SAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC;IAC9C,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Function definition for askQuestion
3
+ */
4
+ export declare const askQuestion: {
5
+ readonly name: "askQuestion";
6
+ readonly description: "If there is a need ask a question to the user to gather more information or clarification. Alternatively this function can be called also if there is no need to prompt the user with any question.";
7
+ readonly parameters: {
8
+ readonly type: "object";
9
+ readonly properties: {
10
+ readonly content: {
11
+ readonly type: "string";
12
+ readonly description: "The message you want to display to the user, it can be either a question or a confirmation/ackoweledgment in case there is no intention to prompt the user.";
13
+ };
14
+ readonly shouldPrompt: {
15
+ readonly type: "boolean";
16
+ readonly description: "Set to true if the intention is to get response from the user.";
17
+ };
18
+ readonly promptNecessity: {
19
+ readonly type: "number";
20
+ readonly minimum: 0;
21
+ readonly maximum: 100;
22
+ readonly description: "How strong is the need to prompt the user? Higher value indicates a stronger need.";
23
+ };
24
+ readonly stopCodegen: {
25
+ readonly type: "boolean";
26
+ readonly description: "If set to true, it will break the code generation process without error, so you should use this parameter if you want to stop the code generation process.";
27
+ };
28
+ readonly requestFilesContent: {
29
+ readonly type: "array";
30
+ readonly description: string;
31
+ };
32
+ readonly requestPermissions: {
33
+ readonly type: "object";
34
+ readonly description: "Use this property to request enablement of permissions for code generation process if you detect that you don't have this permission listed in the requirements.";
35
+ readonly properties: {
36
+ readonly allowDirectoryCreate: {
37
+ readonly description: "Set to `true` to request permission for creating directories.";
38
+ readonly type: "boolean";
39
+ };
40
+ readonly allowFileCreate: {
41
+ readonly description: "Set to `true` to request permission for creating files.";
42
+ readonly type: "boolean";
43
+ };
44
+ readonly allowFileDelete: {
45
+ readonly description: "Set to `true` to request permission for deleting files.";
46
+ readonly type: "boolean";
47
+ };
48
+ readonly allowFileMove: {
49
+ readonly description: "Set to `true` to request permission for moving files.";
50
+ readonly type: "boolean";
51
+ };
52
+ readonly enableVision: {
53
+ readonly description: "Set to `true` to request permission for vision capabilities, using images as a context for further code generation operations.";
54
+ readonly type: "boolean";
55
+ };
56
+ readonly enableImagen: {
57
+ readonly description: "Set to `true` to request permission for generation of images.";
58
+ readonly type: "boolean";
59
+ };
60
+ };
61
+ };
62
+ };
63
+ readonly required: readonly ["content", "shouldPrompt", "promptNecessity", "stopCodegen"];
64
+ };
65
+ };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Function definition for askQuestion
3
+ */
4
+ export const askQuestion = {
5
+ name: 'askQuestion',
6
+ description: 'If there is a need ask a question to the user to gather more information or clarification. Alternatively this function can be called also if there is no need to prompt the user with any question.',
7
+ parameters: {
8
+ type: 'object',
9
+ properties: {
10
+ content: {
11
+ type: 'string',
12
+ description: 'The message you want to display to the user, it can be either a question or a confirmation/ackoweledgment in case there is no intention to prompt the user.',
13
+ },
14
+ shouldPrompt: {
15
+ type: 'boolean',
16
+ description: 'Set to true if the intention is to get response from the user.',
17
+ },
18
+ promptNecessity: {
19
+ type: 'number',
20
+ minimum: 0,
21
+ maximum: 100,
22
+ description: 'How strong is the need to prompt the user? Higher value indicates a stronger need.',
23
+ },
24
+ stopCodegen: {
25
+ type: 'boolean',
26
+ description: 'If set to true, it will break the code generation process without error, so you should use this parameter if you want to stop the code generation process.',
27
+ },
28
+ requestFilesContent: {
29
+ type: 'array',
30
+ description: 'This object property is used to request file contents to be provided by the user, use this property when a content of a file is missing(null in getSourceCode response), but we know that it exists.' +
31
+ 'An array of absolute paths of files that should be used to provide context for the following updates. Context files could be for example the dependencies, or files that depend on one of the files that we want to update in the next step.',
32
+ },
33
+ requestPermissions: {
34
+ type: 'object',
35
+ description: "Use this property to request enablement of permissions for code generation process if you detect that you don't have this permission listed in the requirements.",
36
+ properties: {
37
+ allowDirectoryCreate: {
38
+ description: 'Set to `true` to request permission for creating directories.',
39
+ type: 'boolean',
40
+ },
41
+ allowFileCreate: {
42
+ description: 'Set to `true` to request permission for creating files.',
43
+ type: 'boolean',
44
+ },
45
+ allowFileDelete: {
46
+ description: 'Set to `true` to request permission for deleting files.',
47
+ type: 'boolean',
48
+ },
49
+ allowFileMove: {
50
+ description: 'Set to `true` to request permission for moving files.',
51
+ type: 'boolean',
52
+ },
53
+ enableVision: {
54
+ description: 'Set to `true` to request permission for vision capabilities, using images as a context for further code generation operations.',
55
+ type: 'boolean',
56
+ },
57
+ enableImagen: {
58
+ description: 'Set to `true` to request permission for generation of images.',
59
+ type: 'boolean',
60
+ },
61
+ },
62
+ },
63
+ },
64
+ required: ['content', 'shouldPrompt', 'promptNecessity', 'stopCodegen'],
65
+ },
66
+ };
67
+ //# sourceMappingURL=ask-question.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask-question.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/ask-question.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,qMAAqM;IACvM,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,6JAA6J;aAChK;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,gEAAgE;aAC9E;YACD,eAAe,EAAE;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;gBACZ,WAAW,EAAE,oFAAoF;aAClG;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,SAAS;gBACf,WAAW,EACT,4JAA4J;aAC/J;YACD,mBAAmB,EAAE;gBACnB,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,sMAAsM;oBACtM,8OAA8O;aACjP;YACD,kBAAkB,EAAE;gBAClB,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,kKAAkK;gBACpK,UAAU,EAAE;oBACV,oBAAoB,EAAE;wBACpB,WAAW,EAAE,+DAA+D;wBAC5E,IAAI,EAAE,SAAS;qBAChB;oBACD,eAAe,EAAE;wBACf,WAAW,EAAE,yDAAyD;wBACtE,IAAI,EAAE,SAAS;qBAChB;oBACD,eAAe,EAAE;wBACf,WAAW,EAAE,yDAAyD;wBACtE,IAAI,EAAE,SAAS;qBAChB;oBACD,aAAa,EAAE;wBACb,WAAW,EAAE,uDAAuD;wBACpE,IAAI,EAAE,SAAS;qBAChB;oBACD,YAAY,EAAE;wBACZ,WAAW,EACT,gIAAgI;wBAClI,IAAI,EAAE,SAAS;qBAChB;oBACD,YAAY,EAAE;wBACZ,WAAW,EAAE,+DAA+D;wBAC5E,IAAI,EAAE,SAAS;qBAChB;iBACF;aACF;SACF;QACD,QAAQ,EAAE,CAAC,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,CAAC;KACxE;CACO,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Function definition for codegenSummary
3
+ */
4
+ export declare const codegenSummary: {
5
+ readonly name: "codegenSummary";
6
+ readonly description: string;
7
+ readonly parameters: {
8
+ readonly type: "object";
9
+ readonly properties: {
10
+ readonly contextPaths: {
11
+ readonly type: "array";
12
+ readonly description: "An array of absolute paths of files that should be used to provide context for the following updates. Context files could be for example the dependencies, or files that depend on one of the files that we want to update in the next step.";
13
+ readonly items: {
14
+ readonly type: "string";
15
+ };
16
+ };
17
+ readonly fileUpdates: {
18
+ readonly type: "array";
19
+ readonly description: "An array of proposed file updates, each update is an object with several properties.";
20
+ readonly items: {
21
+ readonly type: "object";
22
+ readonly description: "Proposed update of a file. The update is an object which contains properties like absolute file path, update tool name, and few other important properties.";
23
+ readonly properties: {
24
+ readonly path: {
25
+ readonly type: "string";
26
+ readonly description: "An absolute path of the project file that will be updated. This must be an absolute file path.";
27
+ };
28
+ readonly updateToolName: {
29
+ readonly type: "string";
30
+ readonly enum: readonly ["createFile", "updateFile", "patchFile", "deleteFile", "createDirectory", "moveFile", "generateImage", "downloadFile", "splitImage", "resizeImage", "imglyRemoveBackground"];
31
+ readonly description: "A name of the tool that will be used to perform the update.";
32
+ };
33
+ readonly temperature: {
34
+ readonly type: "number";
35
+ readonly description: "Temperature parameter that will be used for LLM request. The value is adjusted to the characteristic of the update. If there is a need for a more creative solution, the value should be lower, but stil within [0.0, 2.0] range.";
36
+ };
37
+ readonly cheap: {
38
+ readonly type: "boolean";
39
+ readonly description: "true value means that the prompt will be executed with cheaper model, which work faster, but provides lower quality results, so please use it only in situation when lower quality results are acceptable for the prompt.";
40
+ };
41
+ readonly prompt: {
42
+ readonly type: "string";
43
+ readonly description: "Prompt that will be passed to the model request together with the tool request. It summarizes the planned changes for this particular file, so it should be detailed enough for the model to generate necessary changes.";
44
+ };
45
+ readonly contextImageAssets: {
46
+ readonly type: "array";
47
+ readonly description: string;
48
+ readonly items: {
49
+ readonly type: "string";
50
+ };
51
+ };
52
+ };
53
+ readonly required: readonly ["path", "updateToolName"];
54
+ };
55
+ };
56
+ readonly explanation: {
57
+ readonly type: "string";
58
+ readonly description: "Explanation of planned changes or explanation of reasoning for no code changes";
59
+ };
60
+ };
61
+ readonly required: readonly ["fileUpdates", "contextPaths"];
62
+ };
63
+ };