genaicode 0.6.1 → 0.8.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 (261) hide show
  1. package/README.md +0 -2
  2. package/dist/ai-service/ai-studio.js +7 -1
  3. package/dist/ai-service/ai-studio.js.map +1 -1
  4. package/dist/ai-service/anthropic.js +49 -19
  5. package/dist/ai-service/anthropic.js.map +1 -1
  6. package/dist/ai-service/chat-gpt.js +28 -11
  7. package/dist/ai-service/chat-gpt.js.map +1 -1
  8. package/dist/ai-service/common.d.ts +5 -4
  9. package/dist/ai-service/common.js +3 -4
  10. package/dist/ai-service/common.js.map +1 -1
  11. package/dist/ai-service/common.test.js +1 -1
  12. package/dist/ai-service/vertex-ai-claude.js +1 -1
  13. package/dist/ai-service/vertex-ai-claude.js.map +1 -1
  14. package/dist/ai-service/vertex-ai.js +7 -1
  15. package/dist/ai-service/vertex-ai.js.map +1 -1
  16. package/dist/cli/cli-options.js +0 -12
  17. package/dist/cli/cli-options.js.map +1 -1
  18. package/dist/cli/cli-params.d.ts +1 -4
  19. package/dist/cli/cli-params.js +1 -10
  20. package/dist/cli/cli-params.js.map +1 -1
  21. package/dist/cli/validate-cli-params.js +1 -7
  22. package/dist/cli/validate-cli-params.js.map +1 -1
  23. package/dist/cli/validate-cli-params.test.js +1 -1
  24. package/dist/cli/validate-cli-params.test.js.map +1 -1
  25. package/dist/eval/codegen-summary.test.d.ts +1 -0
  26. package/dist/eval/codegen-summary.test.js +93 -0
  27. package/dist/eval/codegen-summary.test.js.map +1 -0
  28. package/dist/eval/current-prompt-plugin.d.ts +3 -0
  29. package/dist/eval/current-prompt-plugin.js +10 -0
  30. package/dist/eval/current-prompt-plugin.js.map +1 -0
  31. package/dist/eval/data/current-prompt.d.ts +34 -0
  32. package/dist/eval/data/current-prompt.js +59 -0
  33. package/dist/eval/data/current-prompt.js.map +1 -0
  34. package/dist/eval/data/prompt-assistant-image.d.ts +49 -0
  35. package/dist/eval/data/prompt-assistant-image.js +67 -0
  36. package/dist/eval/data/prompt-assistant-image.js.map +1 -0
  37. package/dist/eval/data/prompt3.d.ts +34 -0
  38. package/dist/eval/data/prompt3.js +71 -0
  39. package/dist/eval/data/prompt3.js.map +1 -0
  40. package/dist/eval/prompt-debug.test.d.ts +1 -0
  41. package/dist/eval/prompt-debug.test.js +76 -0
  42. package/dist/eval/prompt-debug.test.js.map +1 -0
  43. package/dist/eval/prompt2.d.ts +34 -0
  44. package/dist/eval/prompt2.js +125 -0
  45. package/dist/eval/prompt2.js.map +1 -0
  46. package/dist/files/read-files.d.ts +29 -6
  47. package/dist/files/read-files.js +31 -10
  48. package/dist/files/read-files.js.map +1 -1
  49. package/dist/files/read-files.test.js +15 -9
  50. package/dist/files/read-files.test.js.map +1 -1
  51. package/dist/files/source-code-tree.d.ts +17 -0
  52. package/dist/files/source-code-tree.js +70 -0
  53. package/dist/files/source-code-tree.js.map +1 -0
  54. package/dist/main/codegen-types.d.ts +8 -5
  55. package/dist/main/codegen.ai-services.test.d.ts +3 -0
  56. package/dist/main/codegen.ai-services.test.js +198 -0
  57. package/dist/main/codegen.ai-services.test.js.map +1 -0
  58. package/dist/main/codegen.cli-options.test.d.ts +3 -0
  59. package/dist/main/codegen.cli-options.test.js +171 -0
  60. package/dist/main/codegen.cli-options.test.js.map +1 -0
  61. package/dist/main/codegen.image-generation.test.d.ts +3 -0
  62. package/dist/main/codegen.image-generation.test.js +187 -0
  63. package/dist/main/codegen.image-generation.test.js.map +1 -0
  64. package/dist/main/codegen.js +2 -5
  65. package/dist/main/codegen.js.map +1 -1
  66. package/dist/main/codegen.test-utils.d.ts +81 -0
  67. package/dist/main/codegen.test-utils.js +88 -0
  68. package/dist/main/codegen.test-utils.js.map +1 -0
  69. package/dist/main/codegen.test.js +47 -28
  70. package/dist/main/codegen.test.js.map +1 -1
  71. package/dist/main/common/content-bus-types.d.ts +6 -0
  72. package/dist/main/common/content-bus.d.ts +2 -2
  73. package/dist/main/common/content-bus.js +3 -1
  74. package/dist/main/common/content-bus.js.map +1 -1
  75. package/dist/main/common/user-actions.d.ts +8 -2
  76. package/dist/main/common/user-actions.js.map +1 -1
  77. package/dist/main/config-lib.js +20 -2
  78. package/dist/main/config-lib.js.map +1 -1
  79. package/dist/main/config.js +4 -28
  80. package/dist/main/config.js.map +1 -1
  81. package/dist/main/interactive/codegen-interactive.js +0 -4
  82. package/dist/main/interactive/codegen-interactive.js.map +1 -1
  83. package/dist/main/interactive/codegen-interactive.test.js +1 -7
  84. package/dist/main/interactive/codegen-interactive.test.js.map +1 -1
  85. package/dist/main/interactive/common.d.ts +1 -1
  86. package/dist/main/interactive/common.js +0 -2
  87. package/dist/main/interactive/common.js.map +1 -1
  88. package/dist/main/interactive/configure.js +0 -2
  89. package/dist/main/interactive/configure.js.map +1 -1
  90. package/dist/main/interactive/help.js +0 -2
  91. package/dist/main/interactive/help.js.map +1 -1
  92. package/dist/main/interactive/task-file.js +1 -1
  93. package/dist/main/interactive/task-file.js.map +1 -1
  94. package/dist/main/interactive/text-prompt.js +1 -1
  95. package/dist/main/interactive/text-prompt.js.map +1 -1
  96. package/dist/main/interactive/user-action-handlers.js +4 -2
  97. package/dist/main/interactive/user-action-handlers.js.map +1 -1
  98. package/dist/main/plugin-loader.d.ts +7 -1
  99. package/dist/main/plugin-loader.js +61 -0
  100. package/dist/main/plugin-loader.js.map +1 -1
  101. package/dist/main/ui/backend/api.js +9 -3
  102. package/dist/main/ui/backend/api.js.map +1 -1
  103. package/dist/main/ui/backend/service.d.ts +2 -1
  104. package/dist/main/ui/backend/service.js +6 -3
  105. package/dist/main/ui/backend/service.js.map +1 -1
  106. package/dist/main/ui/frontend/assets/index-QOcNx5ac.js +812 -0
  107. package/dist/main/ui/frontend/index.html +1 -1
  108. package/dist/main/ui/user-action-handlers.js +1 -1
  109. package/dist/main/ui/user-action-handlers.js.map +1 -1
  110. package/dist/project-profiles/detection.d.ts +40 -0
  111. package/dist/project-profiles/detection.js +131 -0
  112. package/dist/project-profiles/detection.js.map +1 -0
  113. package/dist/project-profiles/index.d.ts +35 -0
  114. package/dist/project-profiles/index.js +72 -0
  115. package/dist/project-profiles/index.js.map +1 -0
  116. package/dist/project-profiles/profiles/golang.d.ts +65 -0
  117. package/dist/project-profiles/profiles/golang.js +208 -0
  118. package/dist/project-profiles/profiles/golang.js.map +1 -0
  119. package/dist/project-profiles/profiles/java-maven.d.ts +80 -0
  120. package/dist/project-profiles/profiles/java-maven.js +165 -0
  121. package/dist/project-profiles/profiles/java-maven.js.map +1 -0
  122. package/dist/project-profiles/profiles/javascript-npm.d.ts +40 -0
  123. package/dist/project-profiles/profiles/javascript-npm.js +118 -0
  124. package/dist/project-profiles/profiles/javascript-npm.js.map +1 -0
  125. package/dist/project-profiles/profiles/javascript-react.d.ts +46 -0
  126. package/dist/project-profiles/profiles/javascript-react.js +147 -0
  127. package/dist/project-profiles/profiles/javascript-react.js.map +1 -0
  128. package/dist/project-profiles/profiles/python-django.d.ts +58 -0
  129. package/dist/project-profiles/profiles/python-django.js +200 -0
  130. package/dist/project-profiles/profiles/python-django.js.map +1 -0
  131. package/dist/project-profiles/types.d.ts +122 -0
  132. package/dist/project-profiles/types.js +77 -0
  133. package/dist/project-profiles/types.js.map +1 -0
  134. package/dist/prompt/function-calling.js +8 -3
  135. package/dist/prompt/function-calling.js.map +1 -1
  136. package/dist/prompt/function-defs/ask-question.d.ts +5 -0
  137. package/dist/prompt/function-defs/ask-question.js +140 -60
  138. package/dist/prompt/function-defs/ask-question.js.map +1 -1
  139. package/dist/prompt/function-defs/codegen-planning.d.ts +8 -0
  140. package/dist/prompt/function-defs/codegen-planning.js +50 -0
  141. package/dist/prompt/function-defs/codegen-planning.js.map +1 -0
  142. package/dist/prompt/function-defs/codegen-summary.js +2 -2
  143. package/dist/prompt/function-defs/codegen-summary.js.map +1 -1
  144. package/dist/prompt/function-defs/get-source-code.js +32 -2
  145. package/dist/prompt/function-defs/get-source-code.js.map +1 -1
  146. package/dist/prompt/function-defs/optimize-context.js +35 -12
  147. package/dist/prompt/function-defs/optimize-context.js.map +1 -1
  148. package/dist/prompt/function-defs/set-summaries.js +20 -1
  149. package/dist/prompt/function-defs/set-summaries.js.map +1 -1
  150. package/dist/prompt/limits.js +2 -2
  151. package/dist/prompt/limits.js.map +1 -1
  152. package/dist/prompt/limits.test.js +3 -3
  153. package/dist/prompt/limits.test.js.map +1 -1
  154. package/dist/prompt/prompt-codegen.js +7 -79
  155. package/dist/prompt/prompt-codegen.js.map +1 -1
  156. package/dist/prompt/prompt-codegen.test.js +8 -14
  157. package/dist/prompt/prompt-codegen.test.js.map +1 -1
  158. package/dist/prompt/prompt-service-ask-question.test.js +27 -80
  159. package/dist/prompt/prompt-service-ask-question.test.js.map +1 -1
  160. package/dist/prompt/prompt-service.ai-services.test.d.ts +1 -0
  161. package/dist/prompt/prompt-service.ai-services.test.js +149 -0
  162. package/dist/prompt/prompt-service.ai-services.test.js.map +1 -0
  163. package/dist/prompt/prompt-service.context-optimization.test.d.ts +1 -0
  164. package/dist/prompt/prompt-service.context-optimization.test.js +212 -0
  165. package/dist/prompt/prompt-service.context-optimization.test.js.map +1 -0
  166. package/dist/prompt/prompt-service.image-handling.test.d.ts +1 -0
  167. package/dist/prompt/prompt-service.image-handling.test.js +212 -0
  168. package/dist/prompt/prompt-service.image-handling.test.js.map +1 -0
  169. package/dist/prompt/prompt-service.js +41 -127
  170. package/dist/prompt/prompt-service.js.map +1 -1
  171. package/dist/prompt/prompt-service.test-utils.d.ts +66 -0
  172. package/dist/prompt/prompt-service.test-utils.js +169 -0
  173. package/dist/prompt/prompt-service.test-utils.js.map +1 -0
  174. package/dist/prompt/prompt-service.test.js +96 -20
  175. package/dist/prompt/prompt-service.test.js.map +1 -1
  176. package/dist/prompt/prompt-service.validation-recovery.test.d.ts +1 -0
  177. package/dist/prompt/prompt-service.validation-recovery.test.js +263 -0
  178. package/dist/prompt/prompt-service.validation-recovery.test.js.map +1 -0
  179. package/dist/prompt/static-prompts.d.ts +16 -0
  180. package/dist/prompt/static-prompts.js +22 -0
  181. package/dist/prompt/static-prompts.js.map +1 -0
  182. package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js +1 -3
  183. package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js.map +1 -1
  184. package/dist/prompt/steps/step-ask-question/handlers/code-generation.d.ts +2 -0
  185. package/dist/prompt/steps/step-ask-question/handlers/code-generation.js +58 -0
  186. package/dist/prompt/steps/step-ask-question/handlers/code-generation.js.map +1 -0
  187. package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.d.ts +1 -1
  188. package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.js +8 -7
  189. package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.js.map +1 -1
  190. package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js +6 -6
  191. package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js.map +1 -1
  192. package/dist/prompt/steps/step-ask-question/handlers/default-action.js +1 -4
  193. package/dist/prompt/steps/step-ask-question/handlers/default-action.js.map +1 -1
  194. package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.d.ts +2 -0
  195. package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.js +86 -0
  196. package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.js.map +1 -0
  197. package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.d.ts +2 -0
  198. package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.js +97 -0
  199. package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.js.map +1 -0
  200. package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.d.ts +2 -0
  201. package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js +20 -0
  202. package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js.map +1 -0
  203. package/dist/prompt/steps/step-ask-question/handlers/handler-utils.d.ts +0 -0
  204. package/dist/prompt/steps/step-ask-question/handlers/handler-utils.js +2 -0
  205. package/dist/prompt/steps/step-ask-question/handlers/handler-utils.js.map +1 -0
  206. package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.d.ts +1 -1
  207. package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.js +57 -15
  208. package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.js.map +1 -1
  209. package/dist/prompt/steps/step-ask-question/handlers/request-files-content.d.ts +1 -1
  210. package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js +109 -12
  211. package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js.map +1 -1
  212. package/dist/prompt/steps/step-ask-question/handlers/request-permissions.d.ts +1 -1
  213. package/dist/prompt/steps/step-ask-question/handlers/request-permissions.js +48 -26
  214. package/dist/prompt/steps/step-ask-question/handlers/request-permissions.js.map +1 -1
  215. package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.js +1 -1
  216. package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.js.map +1 -1
  217. package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.js +1 -0
  218. package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.js.map +1 -1
  219. package/dist/prompt/steps/step-ask-question/step-ask-question-types.d.ts +25 -21
  220. package/dist/prompt/steps/step-ask-question/step-ask-question.d.ts +2 -5
  221. package/dist/prompt/steps/step-ask-question/step-ask-question.js +36 -33
  222. package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -1
  223. package/dist/prompt/steps/step-codegen-planning.d.ts +10 -0
  224. package/dist/prompt/steps/step-codegen-planning.js +69 -0
  225. package/dist/prompt/steps/step-codegen-planning.js.map +1 -0
  226. package/dist/prompt/steps/step-codegen-summary.d.ts +7 -0
  227. package/dist/prompt/steps/step-codegen-summary.js +106 -0
  228. package/dist/prompt/steps/step-codegen-summary.js.map +1 -0
  229. package/dist/prompt/steps/step-codegen-summary.test.d.ts +1 -0
  230. package/dist/prompt/steps/step-codegen-summary.test.js +136 -0
  231. package/dist/prompt/steps/step-codegen-summary.test.js.map +1 -0
  232. package/dist/prompt/steps/step-context-optimization.js +243 -126
  233. package/dist/prompt/steps/step-context-optimization.js.map +1 -1
  234. package/dist/prompt/steps/step-context-optimization.test.d.ts +2 -0
  235. package/dist/prompt/steps/step-context-optimization.test.js +475 -0
  236. package/dist/prompt/steps/step-context-optimization.test.js.map +1 -0
  237. package/dist/prompt/steps/step-ensure-context.d.ts +15 -0
  238. package/dist/prompt/steps/step-ensure-context.js +102 -0
  239. package/dist/prompt/steps/step-ensure-context.js.map +1 -0
  240. package/dist/prompt/steps/step-ensure-context.test.d.ts +1 -0
  241. package/dist/prompt/steps/step-ensure-context.test.js +242 -0
  242. package/dist/prompt/steps/step-ensure-context.test.js.map +1 -0
  243. package/dist/prompt/steps/step-generate-image.d.ts +8 -1
  244. package/dist/prompt/steps/step-generate-image.js +1 -0
  245. package/dist/prompt/steps/step-generate-image.js.map +1 -1
  246. package/dist/prompt/steps/step-summarization.d.ts +2 -2
  247. package/dist/prompt/steps/step-summarization.js +45 -9
  248. package/dist/prompt/steps/step-summarization.js.map +1 -1
  249. package/dist/prompt/steps/step-validate-recover.js +24 -15
  250. package/dist/prompt/steps/step-validate-recover.js.map +1 -1
  251. package/dist/prompt/steps/steps-types.d.ts +2 -0
  252. package/dist/prompt/steps/steps-types.js.map +1 -1
  253. package/dist/prompt/systemprompt.d.ts +2 -2
  254. package/dist/prompt/systemprompt.js +74 -176
  255. package/dist/prompt/systemprompt.js.map +1 -1
  256. package/dist/prompt/systemprompt.test.js +4 -5
  257. package/dist/prompt/systemprompt.test.js.map +1 -1
  258. package/dist/vite-genaicode/vite-genaicode-plugin.js +0 -2
  259. package/dist/vite-genaicode/vite-genaicode-plugin.js.map +1 -1
  260. package/package.json +6 -2
  261. package/dist/main/ui/frontend/assets/index-Dk_qaEQg.js +0 -782
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Static prompts used in the prompt-service module.
3
+ * These prompts are used in the initial conversation with the AI service.
4
+ */
5
+ /** Initial greeting from the user */
6
+ export declare const INITIAL_GREETING = "Hello, GenAIcode!";
7
+ /** Assistant's response asking for source code and other assets */
8
+ export declare const REQUEST_SOURCE_CODE = "Hello there! I guess you have a task for me today. Before we start, could you please provide me with: \n - the current source code of your application\n - the image assets (if available)\n - and conversational history (if available)\n \n Thanks";
9
+ /** User's response when providing source code and assets */
10
+ export declare const SOURCE_CODE_RESPONSE = "Sure, here is the application source code, image assets, and the history.";
11
+ /** Assistant's acknowledgment after receiving source code */
12
+ export declare const READY_TO_ASSIST = "Thank you, I'm ready to assist you with your request.";
13
+ /** Assistant's response when generating code */
14
+ export declare const CODEGEN_SUMMARY_PROMPT = "Planning phase completed. Now please create the code generation summary.";
15
+ /** Template for partial prompt when requesting changes for a specific file */
16
+ export declare const getPartialPromptTemplate: (path: string) => string;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Static prompts used in the prompt-service module.
3
+ * These prompts are used in the initial conversation with the AI service.
4
+ */
5
+ /** Initial greeting from the user */
6
+ export const INITIAL_GREETING = 'Hello, GenAIcode!';
7
+ /** Assistant's response asking for source code and other assets */
8
+ export const REQUEST_SOURCE_CODE = `Hello there! I guess you have a task for me today. Before we start, could you please provide me with:
9
+ - the current source code of your application
10
+ - the image assets (if available)
11
+ - and conversational history (if available)
12
+
13
+ Thanks`;
14
+ /** User's response when providing source code and assets */
15
+ export const SOURCE_CODE_RESPONSE = 'Sure, here is the application source code, image assets, and the history.';
16
+ /** Assistant's acknowledgment after receiving source code */
17
+ export const READY_TO_ASSIST = "Thank you, I'm ready to assist you with your request.";
18
+ /** Assistant's response when generating code */
19
+ export const CODEGEN_SUMMARY_PROMPT = 'Planning phase completed. Now please create the code generation summary.';
20
+ /** Template for partial prompt when requesting changes for a specific file */
21
+ export const getPartialPromptTemplate = (path) => `Please now generate update for the \`${path}\` file using appropriate tools according to code generation summary.`;
22
+ //# sourceMappingURL=static-prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-prompts.js","sourceRoot":"","sources":["../../src/prompt/static-prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,qCAAqC;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAEpD,mEAAmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;aAKtB,CAAC;AAEd,4DAA4D;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,2EAA2E,CAAC;AAEhH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,uDAAuD,CAAC;AAEvF,gDAAgD;AAChD,MAAM,CAAC,MAAM,sBAAsB,GAAG,0EAA0E,CAAC;AAEjH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAU,EAAE,CAC/D,wCAAwC,IAAI,uEAAuE,CAAC"}
@@ -1,13 +1,11 @@
1
1
  import { putSystemMessage } from '../../../../main/common/content-bus.js';
2
- import { StepResult } from '../../steps-types.js';
3
2
  export async function handleCancelCodeGeneration({ askQuestionCall }) {
4
3
  putSystemMessage('Assistant requested to stop code generation. Exiting...');
5
4
  return {
6
5
  breakLoop: true,
7
- stepResult: StepResult.BREAK,
8
6
  items: [
9
7
  {
10
- assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [] },
8
+ assistant: { type: 'assistant', text: askQuestionCall.args?.message ?? '' },
11
9
  user: { type: 'user', text: 'Code generation cancelled.' },
12
10
  },
13
11
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"cancel-code-generation.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/cancel-code-generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,EAAE,eAAe,EAAsB;IACtF,gBAAgB,CAAC,yDAAyD,CAAC,CAAC;IAC5E,OAAO;QACL,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,UAAU,CAAC,KAAK;QAC5B,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE;gBAC9F,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4BAA4B,EAAE;aAC3D;SACF;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"cancel-code-generation.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/cancel-code-generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAG1E,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,EAAE,eAAe,EAAsB;IACtF,gBAAgB,CAAC,yDAAyD,CAAC,CAAC;IAC5E,OAAO;QACL,SAAS,EAAE,IAAI;QACf,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE;gBAC3E,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4BAA4B,EAAE;aAC3D;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ export declare function handleCodeGeneration({ generateContentFn, generateImageFn, waitIfPaused, prompt, options, }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,58 @@
1
+ import { putAssistantMessage, putUserMessage } from '../../../../main/common/content-bus.js';
2
+ import { askUserForConfirmationWithAnswer } from '../../../../main/common/user-actions.js';
3
+ import { getFunctionDefs } from '../../../function-calling.js';
4
+ import { executeStepCodegenPlanning } from '../../step-codegen-planning.js';
5
+ import { executeStepCodegenSummary } from '../../step-codegen-summary.js';
6
+ import { StepResult } from '../../steps-types.js';
7
+ export async function handleCodeGeneration({ generateContentFn, generateImageFn, waitIfPaused, prompt, options, }) {
8
+ const planningResult = await executeStepCodegenPlanning(generateContentFn, prompt, options);
9
+ if (planningResult === StepResult.BREAK) {
10
+ return {
11
+ breakLoop: true,
12
+ items: [],
13
+ };
14
+ }
15
+ // Ask user to confirm the planning result
16
+ const planningConfirmation = await askUserForConfirmationWithAnswer('Planning phase completed. Would you like to proceed with the planned changes?', 'Accept planning and continue', 'Reject planning and return to conversation', true);
17
+ if (!planningConfirmation.confirmed) {
18
+ // User rejected the planning, return to conversation
19
+ return {
20
+ breakLoop: false,
21
+ items: [
22
+ {
23
+ assistant: {
24
+ type: 'assistant',
25
+ text: 'Planning phase completed. Would you like to proceed with the planned changes?',
26
+ functionCalls: [],
27
+ },
28
+ user: {
29
+ type: 'user',
30
+ text: planningConfirmation.answer || 'Planning rejected. Returning to conversation.',
31
+ },
32
+ },
33
+ ],
34
+ };
35
+ }
36
+ putAssistantMessage('Planning phase completed. Would you like to proceed with the planned changes?');
37
+ putUserMessage('Accept planning and continue');
38
+ // Execute the codegen summary step
39
+ const result = await executeStepCodegenSummary(generateContentFn, prompt, getFunctionDefs(), options, waitIfPaused, generateImageFn);
40
+ const confirmed = await askUserForConfirmationWithAnswer('Code changes are generated, now what?', 'Apply code changes', 'Continue conversation', true);
41
+ return {
42
+ breakLoop: confirmed.confirmed ?? true,
43
+ stepResult: result,
44
+ items: [
45
+ {
46
+ assistant: {
47
+ type: 'assistant',
48
+ text: 'Code changes are generated, now what?',
49
+ },
50
+ user: {
51
+ type: 'user',
52
+ text: confirmed.answer || 'Apply code changes.',
53
+ },
54
+ },
55
+ ],
56
+ };
57
+ }
58
+ //# sourceMappingURL=code-generation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-generation.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/code-generation.ts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AA8B,CAAC,CAAC;IAE/C,mCAAmC;IACnC,MAAM,MAAM,GAAG,MAAM,yBAAyB,CAC5C,iBAAiB,EACjB,MAAM,EACN,eAAe,EAAE,EACjB,OAAO,EACP,YAAY,EACZ,eAAe,CAChB,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,gCAAgC,CACtD,uCAAuC,EACvC,oBAAoB,EACpB,uBAAuB,EACvB,IAAI,CACL,CAAC;IAEF,OAAO;QACL,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,IAAI;QACtC,UAAU,EAAE,MAAM;QAClB,KAAK,EAAE;YACL;gBACE,SAAS,EAAE;oBACT,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,uCAAuC;iBAC9C;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,SAAS,CAAC,MAAM,IAAI,qBAAqB;iBAChD;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -1,2 +1,2 @@
1
1
  import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
- export declare function handleConfirmCodeGeneration({ askQuestionCall }: ActionHandlerProps): Promise<ActionResult>;
2
+ export declare function handleConfirmCodeGeneration({ askQuestionCall, options, }: ActionHandlerProps): Promise<ActionResult>;
@@ -1,16 +1,19 @@
1
1
  import { putSystemMessage } from '../../../../main/common/content-bus.js';
2
2
  import { askUserForConfirmationWithAnswer } from '../../../../main/common/user-actions.js';
3
- import { StepResult } from '../../steps-types.js';
4
- export async function handleConfirmCodeGeneration({ askQuestionCall }) {
3
+ export async function handleConfirmCodeGeneration({ askQuestionCall, options, }) {
5
4
  const userConfirmation = await askUserForConfirmationWithAnswer('The assistant is ready to start code generation. Do you want to proceed?', 'Start code generation', 'Continue conversation', true);
5
+ if (userConfirmation.options?.aiService) {
6
+ options.aiService = userConfirmation.options.aiService;
7
+ options.cheap = userConfirmation.options.cheap;
8
+ }
6
9
  if (userConfirmation.confirmed) {
7
10
  putSystemMessage('Proceeding with code generation.');
8
11
  return {
9
12
  breakLoop: true,
10
- stepResult: StepResult.CONTINUE,
13
+ executeCodegen: true,
11
14
  items: [
12
15
  {
13
- assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [] },
16
+ assistant: { type: 'assistant', text: askQuestionCall.args?.message ?? '', functionCalls: [] },
14
17
  user: { type: 'user', text: userConfirmation.answer || 'Confirmed. Proceed with code generation.' },
15
18
  },
16
19
  ],
@@ -20,14 +23,12 @@ export async function handleConfirmCodeGeneration({ askQuestionCall }) {
20
23
  putSystemMessage('Declined. Continuing the conversation.');
21
24
  return {
22
25
  breakLoop: false,
23
- stepResult: StepResult.CONTINUE,
24
26
  items: [
25
27
  {
26
- assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [askQuestionCall] },
28
+ assistant: { type: 'assistant', text: askQuestionCall.args?.message ?? '' },
27
29
  user: {
28
30
  type: 'user',
29
31
  text: userConfirmation.answer || 'Declined. Please continue the conversation.',
30
- functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined }],
31
32
  },
32
33
  },
33
34
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"confirm-code-generation.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/confirm-code-generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,gCAAgC,EAAE,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,EAAE,eAAe,EAAsB;IACvF,MAAM,gBAAgB,GAAG,MAAM,gCAAgC,CAC7D,0EAA0E,EAC1E,uBAAuB,EACvB,uBAAuB,EACvB,IAAI,CACL,CAAC;IACF,IAAI,gBAAgB,CAAC,SAAS,EAAE,CAAC;QAC/B,gBAAgB,CAAC,kCAAkC,CAAC,CAAC;QACrD,OAAO;YACL,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,UAAU,CAAC,QAAQ;YAC/B,KAAK,EAAE;gBACL;oBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE;oBAC9F,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,IAAI,0CAA0C,EAAE;iBACpG;aACF;SACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,gBAAgB,CAAC,wCAAwC,CAAC,CAAC;QAC3D,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,UAAU,EAAE,UAAU,CAAC,QAAQ;YAC/B,KAAK,EAAE;gBACL;oBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,CAAC,eAAe,CAAC,EAAE;oBAC7G,IAAI,EAAE;wBACJ,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,gBAAgB,CAAC,MAAM,IAAI,6CAA6C;wBAC9E,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;qBACpG;iBACF;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"confirm-code-generation.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/confirm-code-generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,gCAAgC,EAAE,MAAM,yCAAyC,CAAC;AAG3F,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,EAChD,eAAe,EACf,OAAO,GACY;IACnB,MAAM,gBAAgB,GAAG,MAAM,gCAAgC,CAC7D,0EAA0E,EAC1E,uBAAuB,EACvB,uBAAuB,EACvB,IAAI,CACL,CAAC;IACF,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC;QACxC,OAAO,CAAC,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC;QACvD,OAAO,CAAC,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC;IACjD,CAAC;IACD,IAAI,gBAAgB,CAAC,SAAS,EAAE,CAAC;QAC/B,gBAAgB,CAAC,kCAAkC,CAAC,CAAC;QACrD,OAAO;YACL,SAAS,EAAE,IAAI;YACf,cAAc,EAAE,IAAI;YACpB,KAAK,EAAE;gBACL;oBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE;oBAC9F,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,IAAI,0CAA0C,EAAE;iBACpG;aACF;SACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,gBAAgB,CAAC,wCAAwC,CAAC,CAAC;QAC3D,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE;gBACL;oBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE;oBAC3E,IAAI,EAAE;wBACJ,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,gBAAgB,CAAC,MAAM,IAAI,6CAA6C;qBAC/E;iBACF;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -2,20 +2,21 @@ import { refreshFiles } from '../../../../files/find-files.js';
2
2
  import { putSystemMessage } from '../../../../main/common/content-bus.js';
3
3
  import { askUserForConfirmation } from '../../../../main/common/user-actions.js';
4
4
  import { executeStepContextOptimization } from '../../step-context-optimization.js';
5
- import { StepResult } from '../../steps-types.js';
6
5
  export async function handleContextOptimization({ askQuestionCall, prompt, options, generateContentFn, }) {
7
6
  const userConfirmation = await askUserForConfirmation('The assistant suggests optimizing the context to reduce token usage, cost, and latency. Do you want to proceed?', false);
7
+ if (userConfirmation.options?.aiService) {
8
+ options.aiService = userConfirmation.options.aiService;
9
+ options.cheap = userConfirmation.options.cheap;
10
+ }
8
11
  const user = {
9
12
  type: 'user',
10
13
  text: userConfirmation ? 'Context optimization applied.' : 'Context optimization not applied.',
11
- functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined }],
12
14
  };
13
15
  const assistant = {
14
16
  type: 'assistant',
15
- text: askQuestionCall.args?.content ?? '',
16
- functionCalls: [askQuestionCall],
17
+ text: askQuestionCall.args?.message ?? '',
17
18
  };
18
- if (userConfirmation) {
19
+ if (userConfirmation.confirmed) {
19
20
  // the request may be caused be an appearance of a new file, so lets refresh
20
21
  refreshFiles();
21
22
  // Execute context optimization step
@@ -24,7 +25,6 @@ export async function handleContextOptimization({ askQuestionCall, prompt, optio
24
25
  }
25
26
  return {
26
27
  breakLoop: false,
27
- stepResult: StepResult.CONTINUE,
28
28
  items: [
29
29
  {
30
30
  assistant,
@@ -1 +1 @@
1
- {"version":3,"file":"context-optimization.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/context-optimization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAC9C,eAAe,EACf,MAAM,EACN,OAAO,EACP,iBAAiB,GACE;IACnB,MAAM,gBAAgB,GAAG,MAAM,sBAAsB,CACnD,iHAAiH,EACjH,KAAK,CACN,CAAC;IAEF,MAAM,IAAI,GAAa;QACrB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,mCAAmC;QAC9F,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;KACpG,CAAC;IAEF,MAAM,SAAS,GAAkB;QAC/B,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;QACzC,aAAa,EAAE,CAAC,eAAe,CAAC;KACjC,CAAC;IAEF,IAAI,gBAAgB,EAAE,CAAC;QACrB,4EAA4E;QAC5E,YAAY,EAAE,CAAC;QAEf,oCAAoC;QACpC,gBAAgB,CAAC,sCAAsC,CAAC,CAAC;QACzD,MAAM,8BAA8B,CAAC,iBAAiB,EAAE,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACjG,CAAC;IAED,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,UAAU,CAAC,QAAQ;QAC/B,KAAK,EAAE;YACL;gBACE,SAAS;gBACT,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"context-optimization.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/context-optimization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AAGpF,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAC9C,eAAe,EACf,MAAM,EACN,OAAO,EACP,iBAAiB,GACE;IACnB,MAAM,gBAAgB,GAAG,MAAM,sBAAsB,CACnD,iHAAiH,EACjH,KAAK,CACN,CAAC;IAEF,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC;QACxC,OAAO,CAAC,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC;QACvD,OAAO,CAAC,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC;IACjD,CAAC;IAED,MAAM,IAAI,GAAa;QACrB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,mCAAmC;KAC/F,CAAC;IAEF,MAAM,SAAS,GAAkB;QAC/B,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;KAC1C,CAAC;IAEF,IAAI,gBAAgB,CAAC,SAAS,EAAE,CAAC;QAC/B,4EAA4E;QAC5E,YAAY,EAAE,CAAC;QAEf,oCAAoC;QACpC,gBAAgB,CAAC,sCAAsC,CAAC,CAAC;QACzD,MAAM,8BAA8B,CAAC,iBAAiB,EAAE,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACjG,CAAC;IAED,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE;YACL;gBACE,SAAS;gBACT,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -1,15 +1,12 @@
1
- import { StepResult } from '../../steps-types.js';
2
1
  export async function handleDefaultAction({ askQuestionCall }) {
3
2
  return {
4
3
  breakLoop: false,
5
- stepResult: StepResult.CONTINUE,
6
4
  items: [
7
5
  {
8
- assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [askQuestionCall] },
6
+ assistant: { type: 'assistant', text: askQuestionCall.args?.message ?? '' },
9
7
  user: {
10
8
  type: 'user',
11
9
  text: "I don't want to start the code generation yet, let's talk a bit more.",
12
- functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined }],
13
10
  },
14
11
  },
15
12
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"default-action.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/default-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,EAAE,eAAe,EAAsB;IAC/E,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,UAAU,CAAC,QAAQ;QAC/B,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,CAAC,eAAe,CAAC,EAAE;gBAC7G,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,uEAAuE;oBAC7E,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;iBACpG;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"default-action.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/default-action.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,EAAE,eAAe,EAAsB;IAC/E,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE;gBAC3E,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,uEAAuE;iBAC9E;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ export declare function handleRequestAnswerWithImage({ askQuestionCall, options, generateImageFn, }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,86 @@
1
+ import { askUserForInput } from '../../../../main/common/user-actions.js';
2
+ import { putAssistantMessage, putSystemMessage } from '../../../../main/common/content-bus.js';
3
+ import { StepResult } from '../../steps-types.js';
4
+ import { executeStepGenerateImage } from '../../step-generate-image.js';
5
+ export async function handleRequestAnswerWithImage({ askQuestionCall, options, generateImageFn, }) {
6
+ if (!options.imagen) {
7
+ putSystemMessage('Image generation is not enabled. Please enable it using --imagen parameter.');
8
+ return {
9
+ breakLoop: true,
10
+ stepResult: StepResult.BREAK,
11
+ items: [],
12
+ };
13
+ }
14
+ // Get the image generation request from the args
15
+ const imageGenerationRequest = askQuestionCall.args?.imageGenerationRequest;
16
+ if (!imageGenerationRequest?.prompt) {
17
+ putSystemMessage('Image generation request with prompt is required for requestAnswerWithImage action.');
18
+ return {
19
+ breakLoop: true,
20
+ stepResult: StepResult.BREAK,
21
+ items: [],
22
+ };
23
+ }
24
+ // Create a temporary file path for the generated image
25
+ const tempImagePath = `/tmp/question-image-${Date.now()}.png`;
26
+ // Generate the image using generateImage function call
27
+ const generateImageCall = {
28
+ name: 'generateImage',
29
+ args: {
30
+ prompt: imageGenerationRequest.prompt,
31
+ filePath: tempImagePath,
32
+ width: 1024,
33
+ height: 1024,
34
+ explanation: 'Generating image to support the question',
35
+ ...(imageGenerationRequest.contextImage && { contextImagePath: imageGenerationRequest.contextImage }),
36
+ },
37
+ };
38
+ // Execute image generation
39
+ const downloadFileCall = await executeStepGenerateImage(generateImageFn, generateImageCall);
40
+ // If image generation failed, the downloadFileCall will be an explanation
41
+ if (!downloadFileCall.args?.downloadUrl) {
42
+ putSystemMessage('Failed to generate image for the question.');
43
+ return {
44
+ breakLoop: true,
45
+ stepResult: StepResult.BREAK,
46
+ items: [],
47
+ };
48
+ }
49
+ const response = await fetch(downloadFileCall.args?.downloadUrl);
50
+ const arrayBuffer = await response.arrayBuffer();
51
+ const buffer = Buffer.from(arrayBuffer);
52
+ putAssistantMessage('Here is the image to support the question:', generateImageCall.args, [], [
53
+ {
54
+ base64url: buffer.toString('base64'),
55
+ mediaType: 'image/png',
56
+ },
57
+ ]);
58
+ // Get user's response with the image displayed
59
+ const userText = await askUserForInput('Your answer', askQuestionCall.args?.content ?? '');
60
+ // Return the conversation items with the generated image
61
+ return {
62
+ breakLoop: false,
63
+ stepResult: StepResult.CONTINUE,
64
+ items: [
65
+ {
66
+ assistant: {
67
+ type: 'assistant',
68
+ text: askQuestionCall.args?.content ?? '',
69
+ functionCalls: [askQuestionCall, generateImageCall, downloadFileCall],
70
+ },
71
+ user: {
72
+ type: 'user',
73
+ text: userText,
74
+ functionResponses: [
75
+ {
76
+ name: 'askQuestion',
77
+ call_id: askQuestionCall.id ?? '',
78
+ content: undefined,
79
+ },
80
+ ],
81
+ },
82
+ },
83
+ ],
84
+ };
85
+ }
86
+ //# sourceMappingURL=handle-request-answer-with-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-request-answer-with-image.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC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leSendMessageWithImage({ askQuestionCall, options, generateContentFn, prompt, generateImageFn, }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,97 @@
1
+ import { askUserForInput } from '../../../../main/common/user-actions.js';
2
+ import { putAssistantMessage, putSystemMessage } from '../../../../main/common/content-bus.js';
3
+ import { executeStepGenerateImage } from '../../step-generate-image.js';
4
+ import { getFunctionDefs } from '../../../function-calling.js';
5
+ export async function handleSendMessageWithImage({ askQuestionCall, options, generateContentFn, prompt, generateImageFn, }) {
6
+ if (!options.imagen) {
7
+ putSystemMessage('Image generation is not enabled. Please enable it using --imagen parameter.');
8
+ return {
9
+ breakLoop: true,
10
+ items: [],
11
+ };
12
+ }
13
+ const [sendMessageWithImageCall] = (await generateContentFn([
14
+ ...prompt,
15
+ {
16
+ type: 'assistant',
17
+ text: askQuestionCall.args?.message ?? '',
18
+ },
19
+ {
20
+ type: 'user',
21
+ text: 'Yes, you can generate an image.',
22
+ },
23
+ ], getFunctionDefs(), 'sendMessageWithImage', 0.7, true, options));
24
+ if (!sendMessageWithImageCall) {
25
+ return {
26
+ breakLoop: true,
27
+ items: [],
28
+ };
29
+ }
30
+ // Get the image generation request from the args
31
+ const imageGenerationRequest = sendMessageWithImageCall.args;
32
+ if (!imageGenerationRequest?.prompt) {
33
+ putSystemMessage('Image generation request with prompt is required for sendMessageWithImage action.');
34
+ return {
35
+ breakLoop: true,
36
+ items: [],
37
+ };
38
+ }
39
+ // Create a temporary file path for the generated image
40
+ const tempImagePath = `/tmp/question-image-${Date.now()}.png`;
41
+ // Generate the image using generateImage function call
42
+ const generateImageCall = {
43
+ id: 'generate_image_' + sendMessageWithImageCall.id,
44
+ name: 'generateImage',
45
+ args: {
46
+ prompt: imageGenerationRequest.prompt,
47
+ filePath: tempImagePath,
48
+ width: 1024,
49
+ height: 1024,
50
+ explanation: 'Generating image to support the question',
51
+ ...(imageGenerationRequest.contextImage && { contextImagePath: imageGenerationRequest.contextImage }),
52
+ },
53
+ };
54
+ // Execute image generation
55
+ const downloadFileCall = await executeStepGenerateImage(generateImageFn, generateImageCall);
56
+ // If image generation failed, the downloadFileCall will be an explanation
57
+ if (!downloadFileCall.args?.downloadUrl) {
58
+ putSystemMessage('Failed to generate image for the question.');
59
+ return {
60
+ breakLoop: true,
61
+ items: [],
62
+ };
63
+ }
64
+ const response = await fetch(downloadFileCall.args?.downloadUrl);
65
+ const arrayBuffer = await response.arrayBuffer();
66
+ const buffer = Buffer.from(arrayBuffer);
67
+ const imageData = {
68
+ base64url: buffer.toString('base64'),
69
+ mediaType: 'image/png',
70
+ };
71
+ putAssistantMessage('Here is the image to support the question:', generateImageCall.args, [], [imageData]);
72
+ // Get user's response with the image displayed
73
+ const inputResponse = await askUserForInput('Your answer', askQuestionCall.args?.message ?? '');
74
+ if (inputResponse.options?.aiService) {
75
+ options.aiService = inputResponse.options.aiService;
76
+ }
77
+ // Return the conversation items with the generated image included in the context
78
+ return {
79
+ breakLoop: false,
80
+ items: [
81
+ {
82
+ assistant: {
83
+ type: 'assistant',
84
+ text: askQuestionCall.args?.message ?? '',
85
+ functionCalls: [generateImageCall],
86
+ },
87
+ user: {
88
+ type: 'user',
89
+ text: inputResponse.answer,
90
+ images: [imageData],
91
+ functionResponses: [{ name: generateImageCall.name, call_id: generateImageCall.id, content: undefined }],
92
+ },
93
+ },
94
+ ],
95
+ };
96
+ }
97
+ //# sourceMappingURL=handle-send-message-with-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-send-message-with-image.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE/F,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/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AK;QAChB,KAAK,EAAE;YACL;gBACE,SAAS,EAAE;oBACT,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;oBACzC,aAAa,EAAE,CAAC,iBAAiB,CAAC;iBACnC;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,aAAa,CAAC,MAAM;oBAC1B,MAAM,EAAE,CAAC,SAAS,CAAC;oBACnB,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;iBACzG;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ export declare function handleSendMessage({ askQuestionCall, options }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,20 @@
1
+ import { askUserForInput } from '../../../../main/common/user-actions.js';
2
+ export async function handleSendMessage({ askQuestionCall, options }) {
3
+ const response = await askUserForInput('Your answer', askQuestionCall.args?.message ?? '');
4
+ if (response.options?.aiService) {
5
+ options.aiService = response.options.aiService;
6
+ }
7
+ return {
8
+ breakLoop: false,
9
+ items: [
10
+ {
11
+ assistant: { type: 'assistant', text: askQuestionCall.args?.message ?? '' },
12
+ user: {
13
+ type: 'user',
14
+ text: response.answer,
15
+ },
16
+ },
17
+ ],
18
+ };
19
+ }
20
+ //# sourceMappingURL=handle-send-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-send-message.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-send-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAG1E,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EAAE,eAAe,EAAE,OAAO,EAAsB;IACtF,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,aAAa,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;IAC3F,IAAI,QAAQ,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC;QAChC,OAAO,CAAC,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC;IACjD,CAAC;IACD,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE;gBAC3E,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,QAAQ,CAAC,MAAM;iBACtB;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=handler-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-utils.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handler-utils.ts"],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
1
  import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
- export declare function handleRemoveFilesFromContext({ askQuestionCall, prompt, }: ActionHandlerProps): Promise<ActionResult>;
2
+ export declare function handleRemoveFilesFromContext({ askQuestionCall, generateContentFn, prompt, options, }: ActionHandlerProps): Promise<ActionResult>;
@@ -1,8 +1,25 @@
1
+ import { getSourceCodeTree, parseSourceCodeTree } from '../../../../files/source-code-tree.js';
1
2
  import { putSystemMessage } from '../../../../main/common/content-bus.js';
2
- import { StepResult } from '../../steps-types.js';
3
- import { getSourceCodeResponse } from '../../steps-utils.js';
4
- export async function handleRemoveFilesFromContext({ askQuestionCall, prompt, }) {
5
- const filesToRemove = askQuestionCall.args?.removeFilesFromContext ?? [];
3
+ import { getFunctionDefs } from '../../../function-calling.js';
4
+ export async function handleRemoveFilesFromContext({ askQuestionCall, generateContentFn, prompt, options, }) {
5
+ const [removeFilesFromContextCall] = (await generateContentFn([
6
+ ...prompt,
7
+ {
8
+ type: 'assistant',
9
+ text: askQuestionCall.args?.message ?? '',
10
+ },
11
+ {
12
+ type: 'user',
13
+ text: 'Yes, you can request the removal of files from context.',
14
+ },
15
+ ], getFunctionDefs(), 'removeFilesFromContext', 0.7, true, options));
16
+ if (!removeFilesFromContextCall) {
17
+ return {
18
+ breakLoop: true,
19
+ items: [],
20
+ };
21
+ }
22
+ const filesToRemove = removeFilesFromContextCall.args?.filePaths ?? [];
6
23
  let userText = '';
7
24
  if (filesToRemove.length > 0) {
8
25
  removeFileContentsFromPrompt(prompt, filesToRemove);
@@ -14,30 +31,55 @@ export async function handleRemoveFilesFromContext({ askQuestionCall, prompt, })
14
31
  }
15
32
  return {
16
33
  breakLoop: false,
17
- stepResult: StepResult.CONTINUE,
18
34
  items: [
19
35
  {
20
- assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [askQuestionCall] },
36
+ assistant: {
37
+ type: 'assistant',
38
+ text: askQuestionCall.args?.message ?? '',
39
+ functionCalls: [removeFilesFromContextCall],
40
+ },
21
41
  user: {
22
42
  type: 'user',
23
43
  text: userText,
24
- functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined }],
44
+ functionResponses: [
45
+ { name: 'removeFilesFromContext', call_id: removeFilesFromContextCall.id, content: undefined },
46
+ ],
25
47
  },
26
48
  },
27
49
  ],
28
50
  };
29
51
  }
30
52
  function removeFileContentsFromPrompt(prompt, filesToRemove) {
31
- const response = getSourceCodeResponse(prompt);
32
- if (!response || !response.content) {
33
- throw new Error('Could not find source code response');
53
+ // Find all source code responses in the prompt history
54
+ const sourceCodeResponses = prompt.filter((item) => item.type === 'user' && item.functionResponses?.some((fr) => fr.name === 'getSourceCode'));
55
+ if (sourceCodeResponses.length === 0) {
56
+ console.warn('No source code responses found in prompt history');
57
+ return;
34
58
  }
35
- const contentObj = JSON.parse(response.content);
36
- filesToRemove.forEach((file) => {
37
- if (contentObj[file]) {
38
- delete contentObj[file].content;
59
+ sourceCodeResponses.forEach((response) => {
60
+ const sourceCodeResponse = response.functionResponses?.find((fr) => fr.name === 'getSourceCode');
61
+ if (!sourceCodeResponse || !sourceCodeResponse.content) {
62
+ console.warn('Skipping invalid source code response');
63
+ return;
64
+ }
65
+ try {
66
+ const contentObj = parseSourceCodeTree(JSON.parse(sourceCodeResponse.content));
67
+ let modifiedFiles = 0;
68
+ filesToRemove.forEach((file) => {
69
+ if (contentObj[file] && 'content' in contentObj[file]) {
70
+ contentObj[file].content = null;
71
+ modifiedFiles++;
72
+ }
73
+ });
74
+ // Only update if files were actually modified
75
+ if (modifiedFiles > 0) {
76
+ sourceCodeResponse.content = JSON.stringify(getSourceCodeTree(contentObj));
77
+ console.log(`Removed content from ${modifiedFiles} files in source code response`);
78
+ }
79
+ }
80
+ catch (error) {
81
+ console.error('Error processing source code response:', error);
39
82
  }
40
83
  });
41
- response.content = JSON.stringify(contentObj);
42
84
  }
43
85
  //# sourceMappingURL=remove-files-from-context.js.map