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,125 @@
1
+ import { getSystemPrompt } from '../prompt/systemprompt';
2
+ export const DEBUG_PROMPT2 = [
3
+ {
4
+ type: 'systemPrompt',
5
+ systemPrompt: getSystemPrompt({ verbose: false, askQuestion: true, interactive: false, ui: true }),
6
+ },
7
+ {
8
+ type: 'user',
9
+ text: 'Hello, GenAIcode!',
10
+ },
11
+ {
12
+ type: 'assistant',
13
+ text: 'Hello there! I guess you have a task for me today. Before we start, could you please provide me with the current source code of your application, and the image assets?',
14
+ functionCalls: [
15
+ {
16
+ name: 'getSourceCode',
17
+ },
18
+ {
19
+ name: 'getImageAssets',
20
+ },
21
+ ],
22
+ },
23
+ {
24
+ type: 'user',
25
+ functionResponses: [
26
+ {
27
+ name: 'getSourceCode',
28
+ content: JSON.stringify({
29
+ '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers': {
30
+ 'cancel-code-generation.ts': { summary: 'Handles the cancellation of code generation.' },
31
+ 'confirm-code-generation.ts': { summary: 'Handles confirmation of code generation' },
32
+ 'context-optimization.ts': { summary: 'Handles context optimization' },
33
+ 'default-action.ts': { summary: 'Default action handler' },
34
+ 'handle-request-answer-with-image.ts': {
35
+ summary: 'Handles request to generate image and display it to user',
36
+ },
37
+ 'handle-request-answer.ts': { summary: 'Handles user answer requests' },
38
+ 'handler-utils.ts': { summary: 'Utility functions for step-ask-question handlers' },
39
+ 'remove-files-from-context.ts': { summary: 'Handles removing files from context' },
40
+ 'request-files-content.ts': { summary: 'Handles requesting content of missing files' },
41
+ 'request-permissions.ts': { summary: 'Handles requesting permissions from user' },
42
+ 'start-code-generation.ts': { summary: 'Handles the start of code generation.' },
43
+ },
44
+ }),
45
+ },
46
+ {
47
+ name: 'getImageAssets',
48
+ content: '{"/Users/gtanczyk/src/codegen/media/logo-dark.png":{"mimeType":"image/png","width":1200,"height":686},"/Users/gtanczyk/src/codegen/media/logo.png":{"mimeType":"image/png","width":1200,"height":686},"/Users/gtanczyk/src/codegen/src/vite-genaicode/media/demo-for-readme.gif":{"mimeType":"image/gif","width":769,"height":465}}',
49
+ },
50
+ ],
51
+ cache: true,
52
+ text: 'Sure, here is the application source code and image assets.',
53
+ },
54
+ {
55
+ type: 'assistant',
56
+ text: "Thank you, I'm ready to assist you with your request.",
57
+ },
58
+ {
59
+ type: 'user',
60
+ text: 'Hello',
61
+ },
62
+ {
63
+ type: 'assistant',
64
+ text: 'Hello, How can I assist you today?',
65
+ },
66
+ {
67
+ type: 'user',
68
+ text: 'we will be working on files from src/prompt/steps/step-ask-question/handlers, I want you to analyze them and provide me with a summary of the content of each file.',
69
+ },
70
+ // {
71
+ // type: 'assistant',
72
+ // text: 'Please provide the content of the following files from the src/prompt/steps/step-ask-question/handlers directory: \n- cancel-code-generation.ts\n- confirm-code-generation.ts \n- context-optimization.ts\n- default-action.ts\n- handle-request-answer-with-image.ts\n- handle-request-answer.ts\n- handler-utils.ts\n- remove-files-from-context.ts\n- request-files-content.ts\n- request-permissions.ts\n- start-code-generation.ts',
73
+ // functionCalls: [
74
+ // {
75
+ // name: 'getSourceCode',
76
+ // id: 'toolu_019TwZHC29M4DDNGqt72yKek_source',
77
+ // args: {
78
+ // filePaths: [
79
+ // '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/cancel-code-generation.ts',
80
+ // '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/confirm-code-generation.ts',
81
+ // '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/context-optimization.ts',
82
+ // '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/default-action.ts',
83
+ // '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.ts',
84
+ // '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/handle-request-answer.ts',
85
+ // '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/handler-utils.ts',
86
+ // '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/remove-files-from-context.ts',
87
+ // '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/request-files-content.ts',
88
+ // '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/request-permissions.ts',
89
+ // '/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/start-code-generation.ts',
90
+ // ],
91
+ // },
92
+ // },
93
+ // ],
94
+ // },
95
+ // {
96
+ // type: 'user',
97
+ // text: 'All requested file contents have been provided.',
98
+ // functionResponses: [
99
+ // {
100
+ // name: 'getSourceCode',
101
+ // call_id: 'toolu_019TwZHC29M4DDNGqt72yKek_source',
102
+ // content:
103
+ // "{\"/Users/gtanczyk/src/codegen/src/main/codegen-types.ts\":{\"content\":\"import { FunctionDef, GenerateContentFunction } from '../ai-service/common';\\nimport { ActionHandler } from '../prompt/steps/step-ask-question/step-ask-question-types';\\n\\n/** Example: {@link ../../examples/genaicode_plugins/grok_ai_service.ts} */\\nexport type PluginAiServiceType = `plugin:${string}`;\\n\\n/** Example: {@link ../../examples/genaicode_plugins/nonsense_action_handlers.ts} */\\nexport type PluginActionType = `plugin:${string}`;\\n\\nexport type AiServiceType =\\n | 'vertex-ai'\\n | 'ai-studio'\\n | 'vertex-ai-claude'\\n | 'chat-gpt'\\n | 'anthropic'\\n | PluginAiServiceType;\\n\\nexport type ImagenType = 'vertex-ai' | 'dall-e';\\n\\nexport interface UploadedImage {\\n base64url: string;\\n mediaType: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';\\n originalName: string;\\n}\\n\\nexport interface CodegenOptions {\\n explicitPrompt?: string;\\n taskFile?: string;\\n considerAllFiles?: boolean;\\n allowFileCreate?: boolean;\\n allowFileDelete?: boolean;\\n allowDirectoryCreate?: boolean;\\n allowFileMove?: boolean;\\n vision?: boolean;\\n imagen?: ImagenType;\\n aiService: AiServiceType;\\n\\n disableContextOptimization?: boolean;\\n temperature?: number;\\n cheap?: boolean;\\n dryRun?: boolean;\\n verbose?: boolean;\\n requireExplanations?: boolean;\\n geminiBlockNone?: boolean;\\n disableInitialLint?: boolean;\\n contentMask?: string;\\n ignorePatterns?: string[];\\n askQuestion?: boolean;\\n interactive?: boolean;\\n ui?: boolean;\\n uiPort?: number;\\n uiFrameAncestors?: string[];\\n disableCache?: boolean;\\n dependencyTree?: boolean;\\n historyEnabled?: boolean;\\n\\n disableAiServiceFallback?: boolean;\\n conversationSummaryEnabled?: boolean;\\n images?: UploadedImage[];\\n isDev?: boolean;\\n}\\n\\ninterface ExecutorArgs {\\n [key: string]: unknown;\\n}\\n\\nexport type OperationExecutor = (args: ExecutorArgs, options: CodegenOptions) => Promise<void>;\\n\\nexport type Operation = {\\n executor: OperationExecutor;\\n def: FunctionDef;\\n};\\n\\nexport interface Plugin {\\n name: string;\\n aiServices?: Record<string, GenerateContentFunction>;\\n operations?: Record<string, Operation>;\\n actionHandlers?: Record<\\n string,\\n {\\n /** The action handler implementation */\\n handler: ActionHandler;\\n /**\\n * Description of what this action handler does.\\n * This description will be included in the askQuestion function definition\\n * to help the AI understand when to use this action.\\n */\\n description: string;\\n }\\n >;\\n}\\n\"},\"/Users/gtanczyk/src/codegen/src/main/codegen.ts\":{\"content\":\"import { exec } from 'child_process';\\nimport util from 'util';\\n\\nimport * as cliParams from '../cli/cli-params.js';\\nimport { validateCliParams } from '../cli/validate-cli-params.js';\\nimport { generateContent as generateContentVertexAi } from '../ai-service/vertex-ai.js';\\nimport { generateContent as generateContentGPT } from '../ai-service/chat-gpt.js';\\nimport { generateContent as generateContentAnthropic } from '../ai-service/anthropic.js';\\nimport { generateContent as generateContentVertexAiClaude } from '../ai-service/vertex-ai-claude.js';\\nimport { generateContent as generateContentAiStudio } from '../ai-service/ai-studio.js';\\nimport { generateImage as generateImageDallE } from '../ai-service/dall-e.js';\\nimport { generateImage as generateImageVertexAi } from '../ai-service/vertex-ai-imagen.js';\\n\\nimport { promptService } from '../prompt/prompt-service.js';\\nimport { updateFiles } from '../files/update-files.js';\\nimport { rcConfig } from '../main/config.js';\\nimport { AiServiceType, CodegenOptions, ImagenType } from './codegen-types.js';\\nimport { getLintFixPrompt } from '../prompt/prompt-codegen.js';\\nimport { printHelpMessage } from '../cli/cli-options.js';\\nimport { FunctionCall, GenerateContentFunction, GenerateImageFunction } from '../ai-service/common.js';\\nimport { getCodeGenPrompt } from '../prompt/prompt-codegen.js';\\n\\nimport { runInteractiveMode } from './interactive/codegen-interactive.js';\\nimport { runCodegenUI } from './ui/codegen-ui.js';\\nimport {\\n putSystemMessage,\\n putUserMessage,\\n setCurrentIterationId,\\n unsetCurrentIterationId,\\n} from './common/content-bus.js';\\nimport { refreshFiles } from '../files/find-files.js';\\nimport { getRegisteredAiServices } from './plugin-loader.js';\\nimport { stringToAiServiceType } from './codegen-utils.js';\\n\\n/** Executes codegen */\\nexport async function runCodegen(isDev = false): Promise<void> {\\n // Print to console the received parameters\\n console.log(`Received parameters: ${process.argv.slice(2).join(' ')}`);\\n\\n validateCliParams();\\n\\n // Handle --help option\\n if (cliParams.helpRequested) {\\n printHelpMessage();\\n return;\\n }\\n\\n const options: CodegenOptions = {\\n explicitPrompt: cliParams.explicitPrompt,\\n taskFile: cliParams.taskFile,\\n considerAllFiles: cliParams.considerAllFiles,\\n dependencyTree: cliParams.dependencyTree,\\n\\n allowFileCreate: cliParams.allowFileCreate,\\n allowFileDelete: cliParams.allowFileDelete,\\n allowDirectoryCreate: cliParams.allowDirectoryCreate,\\n allowFileMove: cliParams.allowFileMove,\\n\\n aiService: stringToAiServiceType(cliParams.aiService),\\n vision: cliParams.vision,\\n imagen: cliParams.imagen,\\n\\n disableContextOptimization: cliParams.disableContextOptimization,\\n temperature: cliParams.temperature,\\n cheap: cliParams.cheap,\\n dryRun: cliParams.dryRun,\\n verbose: cliParams.verbosePrompt,\\n requireExplanations: !cliParams.disableExplanations,\\n geminiBlockNone: cliParams.geminiBlockNone,\\n disableInitialLint: cliParams.disableInitialLint,\\n contentMask: cliParams.contentMask,\\n ignorePatterns: cliParams.ignorePatterns,\\n askQuestion: cliParams.askQuestion,\\n disableCache: cliParams.disableCache,\\n interactive: cliParams.interactive,\\n ui: cliParams.ui,\\n uiPort: cliParams.uiPort,\\n disableAiServiceFallback: cliParams.disableAiServiceFallback,\\n historyEnabled: !cliParams.disableHistory,\\n conversationSummaryEnabled: !cliParams.disableConversationSummary,\\n\\n isDev,\\n };\\n\\n if (cliParams.ui) {\\n await runCodegenUI(options);\\n } else if (cliParams.interactive) {\\n // Handle interactive mode\\n await runInteractiveMode(options);\\n } else {\\n console.log('Executing codegen in non-interactive mode');\\n await runCodegenIteration(options);\\n }\\n}\\n\\nexport async function runCodegenIteration(\\n options: CodegenOptions,\\n abortSignal?: AbortSignal,\\n waitIfPaused: () => Promise<void> = () => Promise.resolve(),\\n) {\\n refreshFiles();\\n\\n setCurrentIterationId();\\n\\n putUserMessage(\\n options.explicitPrompt ?? options.taskFile ?? 'Run codegen iteration without explicit prompt.',\\n undefined,\\n undefined,\\n options.images,\\n );\\n\\n if (rcConfig.lintCommand && !options.disableInitialLint) {\\n try {\\n putSystemMessage(`Executing lint command: ${rcConfig.lintCommand}`);\\n await execPromise(rcConfig.lintCommand, { cwd: rcConfig.rootDir });\\n putSystemMessage('Lint command executed successfully');\\n } catch (error) {\\n const { stderr, stdout } = error as { stdout: string; stderr: string };\\n putSystemMessage(\\n 'Lint command failed. Aborting codegen, please fix lint issues before running codegen, or use --disable-initial-lint',\\n );\\n console.log('Lint errors:', stdout, stderr);\\n unsetCurrentIterationId();\\n return;\\n }\\n } else if (rcConfig.lintCommand && options.disableInitialLint) {\\n console.log('Initial lint was skipped.');\\n }\\n\\n if (abortSignal?.aborted) {\\n unsetCurrentIterationId();\\n throw new Error('Codegen iteration aborted');\\n }\\n\\n await waitIfPaused();\\n\\n putSystemMessage('Generating response');\\n try {\\n const functionCalls = await promptService(\\n getGenerateContentFunctions(),\\n GENERATE_IMAGE_FNS,\\n getCodeGenPrompt(options),\\n waitIfPaused,\\n );\\n console.log('Received function calls:', functionCalls);\\n\\n await waitIfPaused();\\n\\n if (functionCalls.length === 0) {\\n putSystemMessage('No updates to apply');\\n } else if (options.dryRun) {\\n putSystemMessage('Dry run mode, not updating files');\\n } else {\\n putSystemMessage('Update files');\\n await updateFiles(\\n functionCalls.filter((call) => call.name !== 'explanation' && call.name !== 'getSourceCode'),\\n options,\\n );\\n putSystemMessage('Initial updates applied');\\n\\n if (abortSignal?.aborted) {\\n throw new Error('Codegen iteration aborted after initial updates');\\n }\\n\\n await waitIfPaused();\\n\\n // Check if lintCommand is specified in .genaicoderc\\n if (rcConfig.lintCommand && functionCalls.length > 0) {\\n try {\\n putSystemMessage(`Executing lint command: ${rcConfig.lintCommand}`);\\n await execPromise(rcConfig.lintCommand, { cwd: rcConfig.rootDir });\\n putSystemMessage('Lint command executed successfully');\\n } catch (error) {\\n putSystemMessage('Lint command failed. Attempting to fix issues...');\\n\\n // Prepare the lint error output for the second pass\\n const firstLintError = error as { stdout: string; stderr: string };\\n const lintErrorPrompt = getLintFixPrompt(\\n rcConfig.lintCommand,\\n options,\\n firstLintError.stdout,\\n firstLintError.stderr,\\n );\\n\\n putSystemMessage('Generating response for lint fixes');\\n const lintFixFunctionCalls = (await promptService(\\n getGenerateContentFunctions(),\\n GENERATE_IMAGE_FNS,\\n {\\n prompt: lintErrorPrompt,\\n options: { ...options, considerAllFiles: true },\\n },\\n waitIfPaused,\\n )) as FunctionCall[];\\n\\n console.log('Received function calls for lint fixes:', lintFixFunctionCalls);\\n\\n await waitIfPaused();\\n\\n putSystemMessage('Applying lint fixes');\\n updateFiles(\\n lintFixFunctionCalls.filter((call) => call.name !== 'explanation' && call.name !== 'getSourceCode'),\\n options,\\n );\\n\\n if (abortSignal?.aborted) {\\n throw new Error('Codegen iteration aborted after lint fixes');\\n }\\n\\n // Run lint command again to verify fixes\\n try {\\n putSystemMessage(`Re-running lint command: ${rcConfig.lintCommand}`);\\n await execPromise(rcConfig.lintCommand);\\n putSystemMessage('Lint command executed successfully after fixes');\\n } catch (secondLintError) {\\n const error = secondLintError as { stdout: string; stderr: string };\\n putSystemMessage('Lint command still failing after fixes. Manual intervention may be required.');\\n console.log('Lint errors:', error.stdout, error.stderr);\\n }\\n }\\n }\\n\\n console.log('Done!');\\n }\\n } catch (error) {\\n if (error instanceof Error) {\\n if (error.name === 'AbortError' || error.message.includes('interrupted')) {\\n putSystemMessage('Codegen iteration was interrupted');\\n } else if (error.message.includes('Rate limit exceeded')) {\\n putSystemMessage(\\n 'Rate limit exceeded. Consider switching to a different AI service or waiting before retrying.',\\n );\\n } else {\\n putSystemMessage(`An error occurred during codegen: ${error.message}`);\\n }\\n } else {\\n putSystemMessage('An unknown error occurred during codegen');\\n }\\n console.error('Error details:', error);\\n } finally {\\n unsetCurrentIterationId();\\n }\\n}\\n\\n// helper functions and consts\\n\\nconst execPromise = util.promisify(exec);\\n\\nfunction getGenerateContentFunctions(): Record<AiServiceType, GenerateContentFunction> {\\n return {\\n 'vertex-ai-claude': generateContentVertexAiClaude,\\n 'vertex-ai': generateContentVertexAi,\\n 'ai-studio': generateContentAiStudio,\\n anthropic: generateContentAnthropic,\\n 'chat-gpt': generateContentGPT,\\n ...Object.fromEntries(getRegisteredAiServices().entries()),\\n };\\n}\\n\\nconst GENERATE_IMAGE_FNS: Record<ImagenType, GenerateImageFunction> = {\\n 'dall-e': generateImageDallE,\\n 'vertex-ai': generateImageVertexAi,\\n} as const;\\n\"},\"/Users/gtanczyk/src/codegen/src/prompt/prompt-service.ts\":{\"content\":\"import assert from 'node:assert';\\nimport fs from 'fs';\\nimport mime from 'mime-types';\\n\\nimport { getSystemPrompt } from './systemprompt.js';\\nimport { getFunctionDefs } from './function-calling.js';\\nimport { getSourceCode, getImageAssets } from '../files/read-files.js';\\nimport {\\n PromptItem,\\n FunctionDef,\\n FunctionCall,\\n GenerateContentFunction,\\n GenerateImageFunction,\\n} from '../ai-service/common.js';\\nimport { importantContext } from '../main/config.js';\\nimport { AiServiceType, CodegenOptions, ImagenType } from '../main/codegen-types.js';\\nimport { executeStepAskQuestion } from './steps/step-ask-question/step-ask-question.js';\\nimport { validateAndRecoverSingleResult } from './steps/step-validate-recover.js';\\nimport { executeStepVerifyPatch } from './steps/step-verify-patch.js';\\nimport { executeStepGenerateImage } from './steps/step-generate-image.js';\\nimport { executeStepContextOptimization } from './steps/step-context-optimization.js';\\nimport { StepResult } from './steps/steps-types.js';\\nimport { CodegenPrompt } from './prompt-codegen.js';\\nimport { putSystemMessage } from '../main/common/content-bus.js';\\nimport { handleAiServiceFallback } from './ai-service-fallback.js';\\nimport { summarizeSourceCode } from './steps/step-summarization.js';\\nimport { executeStepHistoryUpdate, getCurrentHistory } from './steps/step-history-update.js';\\nimport { executeStepGenerateSummary } from './steps/step-generate-summary.js';\\nimport { getSourceCodeTree } from '../files/source-code-tree.js';\\n\\n/** A function that communicates with model using */\\nexport async function promptService(\\n generateContentFns: Record<AiServiceType, GenerateContentFunction>,\\n generateImageFns: Record<ImagenType, GenerateImageFunction>,\\n codegenPrompt: CodegenPrompt,\\n waitIfPaused: () => Promise<void> = () => Promise.resolve(),\\n): Promise<FunctionCall[]> {\\n const generateContentFn: GenerateContentFunction = async (...args) => {\\n return await handleAiServiceFallback(\\n generateContentFns,\\n codegenPrompt.options.aiService,\\n codegenPrompt.options,\\n ...args,\\n );\\n };\\n\\n const generateImageFn: GenerateImageFunction = (...args) => {\\n assert(codegenPrompt.options.imagen, 'imagen value must be provided');\\n return generateImageFns[codegenPrompt.options.imagen](...args);\\n };\\n\\n const { result, prompt } = await executePromptService(\\n generateContentFn,\\n generateImageFn,\\n codegenPrompt,\\n waitIfPaused,\\n );\\n\\n if (codegenPrompt.options.historyEnabled) {\\n await executeStepHistoryUpdate(generateContentFn, prompt, codegenPrompt.options);\\n }\\n\\n return result;\\n}\\n\\nasync function executePromptService(\\n generateContentFn: GenerateContentFunction,\\n generateImageFn: GenerateImageFunction,\\n codegenPrompt: CodegenPrompt,\\n waitIfPaused: () => Promise<void> = () => Promise.resolve(),\\n): Promise<{ result: FunctionCall[]; prompt: PromptItem[] }> {\\n const messages = prepareMessages(codegenPrompt);\\n\\n // First stage: summarize the source code\\n if (!codegenPrompt.options.disableContextOptimization) {\\n await summarizeSourceCode(\\n generateContentFn,\\n getSourceCode({ forceAll: true }, codegenPrompt.options),\\n codegenPrompt.options,\\n );\\n }\\n\\n // Second stage: generate code generation summary, which should not take a lot of output tokens\\n const getSourceCodeRequest: FunctionCall = { name: 'getSourceCode' };\\n\\n const prompt: PromptItem[] = [\\n { type: 'systemPrompt', systemPrompt: getSystemPrompt(codegenPrompt.options) },\\n { type: 'user', text: messages.suggestSourceCode },\\n {\\n type: 'assistant',\\n text: messages.requestSourceCode,\\n functionCalls: [getSourceCodeRequest, ...(codegenPrompt.options.historyEnabled ? [{ name: 'readHistory' }] : [])],\\n },\\n ];\\n\\n const getSourceCodeResponse: PromptItem = {\\n type: 'user',\\n functionResponses: [\\n { name: 'getSourceCode', content: messages.sourceCode },\\n ...(codegenPrompt.options.historyEnabled ? [{ name: 'readHistory', content: getCurrentHistory() }] : []),\\n ],\\n cache: true,\\n };\\n prompt.push(getSourceCodeResponse);\\n\\n if (codegenPrompt.options.vision) {\\n prompt.slice(-1)[0].text = messages.suggestImageAssets;\\n prompt.push(\\n { type: 'assistant', text: messages.requestImageAssets, functionCalls: [{ name: 'getImageAssets' }] },\\n { type: 'user', functionResponses: [{ name: 'getImageAssets', content: messages.imageAssets }] },\\n );\\n }\\n\\n prompt.slice(-1)[0].text = messages.prompt;\\n\\n // Add uploaded images to the prompt if available\\n if (codegenPrompt.options.images && codegenPrompt.options.images.length > 0 && codegenPrompt.options.vision) {\\n prompt.slice(-1)[0].images = codegenPrompt.options.images.map((img) => ({\\n base64url: img.base64url,\\n mediaType: img.mediaType,\\n }));\\n }\\n\\n // Initial summary based on first user input\\n await executeStepGenerateSummary(generateContentFn, prompt, codegenPrompt.options);\\n\\n // Execute the context optimization step\\n if (!codegenPrompt.options.disableContextOptimization) {\\n const optimizationResult = await executeStepContextOptimization(generateContentFn, prompt, codegenPrompt.options);\\n\\n if (optimizationResult === StepResult.BREAK) {\\n return { result: [], prompt };\\n }\\n }\\n\\n // Execute the ask question step\\n if (codegenPrompt.options.askQuestion !== false && (codegenPrompt.options.interactive || codegenPrompt.options.ui)) {\\n const askQuestionResult = await executeStepAskQuestion(\\n generateContentFn,\\n generateImageFn,\\n prompt,\\n getFunctionDefs(),\\n codegenPrompt.options.temperature ?? 0.7,\\n messages,\\n codegenPrompt.options,\\n );\\n\\n // Summary based on the ask-question conversation history (may be different from the initial summary)\\n await executeStepGenerateSummary(generateContentFn, prompt, codegenPrompt.options);\\n\\n if (askQuestionResult === StepResult.BREAK) {\\n return { result: [], prompt };\\n }\\n } else if (codegenPrompt.options.askQuestion === false) {\\n console.log('Ask question is not enabled.');\\n // Also there is no need to generate conversation summary\\n }\\n\\n const baseRequest: [PromptItem[], FunctionDef[], string, number, boolean, CodegenOptions] = [\\n prompt,\\n getFunctionDefs(),\\n 'codegenSummary',\\n codegenPrompt.options.temperature ?? 0.7,\\n codegenPrompt.options.cheap ?? false,\\n codegenPrompt.options,\\n ];\\n let baseResult = await generateContentFn(...baseRequest);\\n\\n let codegenSummaryRequest = baseResult.find((call) => call.name === 'codegenSummary');\\n\\n if (codegenSummaryRequest) {\\n // Second stage: for each file request the actual code updates\\n putSystemMessage('Received codegen summary, will collect partial updates', codegenSummaryRequest.args);\\n\\n baseResult = await validateAndRecoverSingleResult(baseRequest, baseResult, generateContentFn);\\n codegenSummaryRequest = baseResult.find((call) => call.name === 'codegenSummary');\\n\\n // Sometimes the result happens to be a string\\n assert(Array.isArray(codegenSummaryRequest?.args?.fileUpdates), 'fileUpdates is not an array');\\n assert(Array.isArray(codegenSummaryRequest?.args.contextPaths), 'contextPaths is not an array');\\n\\n if (!codegenPrompt.options.disableContextOptimization) {\\n console.log('Optimize with context paths.');\\n // Monkey patch the initial getSourceCode, do not send parts of source code that are consider irrelevant\\n getSourceCodeRequest.args = {\\n filePaths: [\\n ...codegenSummaryRequest.args.fileUpdates.map((file: { filePath: string }) => file.filePath),\\n ...codegenSummaryRequest.args.contextPaths,\\n ...(importantContext.files ?? []),\\n ],\\n };\\n getSourceCodeResponse.functionResponses!.find((item) => item.name === 'getSourceCode')!.content =\\n messages.contextSourceCode(getSourceCodeRequest.args?.filePaths as string[]);\\n }\\n\\n // Store the first stage response entirely in conversation history\\n prompt.push({ type: 'assistant', functionCalls: baseResult });\\n prompt.push({\\n type: 'user',\\n functionResponses: baseResult.map((call) => ({ name: call.name, call_id: call.id })),\\n cache: true,\\n });\\n\\n const result: FunctionCall[] = [];\\n\\n for (const file of codegenSummaryRequest!.args.fileUpdates) {\\n putSystemMessage('Collecting partial update for: ' + file.filePath + ' using tool: ' + file.updateToolName, file);\\n console.log('- Prompt:', file.prompt);\\n console.log('- Temperature', file.temperature);\\n console.log('- Cheap', file.cheap);\\n if (codegenPrompt.options.vision) {\\n console.log('- Context image assets', file.contextImageAssets);\\n }\\n\\n // Check if execution is paused before proceeding\\n await waitIfPaused();\\n\\n // this is needed, otherwise we will get an error\\n if (prompt.slice(-1)[0].type === 'user') {\\n prompt.slice(-1)[0].text = file.prompt ?? messages.partialPromptTemplate(file.filePath);\\n } else {\\n prompt.push({ type: 'user', text: file.prompt ?? messages.partialPromptTemplate(file.filePath) });\\n }\\n\\n if (codegenPrompt.options.vision && file.contextImageAssets) {\\n prompt.slice(-1)[0].images = file.contextImageAssets.map((path: string) => ({\\n path,\\n base64url: fs.readFileSync(path, 'base64'),\\n mediaType: mime.lookup(path) || '',\\n }));\\n }\\n\\n const partialRequest: [PromptItem[], FunctionDef[], string, number, boolean, CodegenOptions] = [\\n prompt,\\n getFunctionDefs(),\\n file.updateToolName,\\n file.temperature ?? codegenPrompt.options.temperature,\\n file.cheap === true,\\n codegenPrompt.options,\\n ];\\n let partialResult = await generateContentFn(...partialRequest);\\n\\n putSystemMessage('Received partial update', partialResult);\\n\\n // Validate if function call is compliant with the schema\\n partialResult = await validateAndRecoverSingleResult(partialRequest, partialResult, generateContentFn);\\n\\n // Handle image generation requests\\n const generateImageCall = partialResult.find((call) => call.name === 'generateImage');\\n if (generateImageCall) {\\n partialResult.push(await executeStepGenerateImage(generateImageFn, generateImageCall));\\n }\\n\\n // Verify if patchFile is one of the functions called, and test if patch is valid and can be applied successfully\\n const patchFileCall = partialResult.find((call) => call.name === 'patchFile');\\n if (patchFileCall) {\\n partialResult = await executeStepVerifyPatch(\\n patchFileCall.args as { filePath: string; patch: string },\\n generateContentFn,\\n prompt,\\n getFunctionDefs(),\\n file.temperature ?? codegenPrompt.options.temperature,\\n file.cheap === true,\\n codegenPrompt.options,\\n );\\n }\\n\\n // add the code gen result to the context, as the subsequent code gen may depend on the result\\n prompt.push(\\n { type: 'assistant', functionCalls: partialResult },\\n {\\n type: 'user',\\n text: 'Update applied.',\\n functionResponses: partialResult.map((call) => ({ name: call.name, call_id: call.id })),\\n },\\n );\\n\\n result.push(...partialResult);\\n }\\n\\n return { result, prompt };\\n } else {\\n // This is unexpected, if happens probably means no code updates.\\n putSystemMessage('Did not receive codegen summary, returning result.');\\n return { result: baseResult, prompt };\\n }\\n}\\n\\n/**\\n * Function to prepare messages for AI services\\n */\\nfunction prepareMessages(codegen: CodegenPrompt) {\\n return {\\n suggestSourceCode: 'I should provide you with application source code.',\\n requestSourceCode: 'Please provide application source code.',\\n suggestImageAssets: 'I should also provide you with a summary of application image assets',\\n requestImageAssets: 'Please provide summary of application image assets.',\\n prompt:\\n codegen.prompt +\\n '\\\\n Start from generating codegen summary, this summary will be used as a context to generate updates, so make sure that it contains useful information.',\\n sourceCode: JSON.stringify(\\n getSourceCodeTree(getSourceCode({ taskFile: codegen.options.taskFile }, codegen.options)),\\n ),\\n contextSourceCode: (paths: string[], pathsOnly: boolean = false) =>\\n JSON.stringify(\\n getSourceCodeTree(\\n Object.fromEntries(\\n Object.entries(\\n getSourceCode(\\n { filterPaths: paths, taskFile: codegen.options.taskFile, forceAll: true },\\n codegen.options,\\n ),\\n ).filter(([path]) => !pathsOnly || paths.includes(path)),\\n ),\\n ),\\n ),\\n imageAssets: JSON.stringify(getImageAssets()),\\n partialPromptTemplate(path: string) {\\n return `Thank you for providing the summary, now suggest changes for the \\\\`${path}\\\\` file using appropriate tools.`;\\n },\\n };\\n}\\n\"},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/cancel-code-generation.ts\":{\"content\":\"import { putSystemMessage } from '../../../../main/common/content-bus.js';\\nimport { StepResult } from '../../steps-types.js';\\nimport { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';\\n\\nexport async function handleCancelCodeGeneration({ askQuestionCall }: ActionHandlerProps): Promise<ActionResult> {\\n putSystemMessage('Assistant requested to stop code generation. Exiting...');\\n return {\\n breakLoop: true,\\n stepResult: StepResult.BREAK,\\n items: [\\n {\\n assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [] },\\n user: { type: 'user', text: 'Code generation cancelled.' },\\n },\\n ],\\n };\\n}\\n\"},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/confirm-code-generation.ts\":{\"content\":\"import { putSystemMessage } from '../../../../main/common/content-bus.js';\\nimport { askUserForConfirmationWithAnswer } from '../../../../main/common/user-actions.js';\\nimport { StepResult } from '../../steps-types.js';\\nimport { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';\\n\\nexport async function handleConfirmCodeGeneration({\\n askQuestionCall,\\n options,\\n}: ActionHandlerProps): Promise<ActionResult> {\\n const userConfirmation = await askUserForConfirmationWithAnswer(\\n 'The assistant is ready to start code generation. Do you want to proceed?',\\n 'Start code generation',\\n 'Continue conversation',\\n true,\\n );\\n if (userConfirmation.options?.aiService) {\\n options.aiService = userConfirmation.options.aiService;\\n }\\n if (userConfirmation.confirmed) {\\n putSystemMessage('Proceeding with code generation.');\\n return {\\n breakLoop: true,\\n stepResult: StepResult.CONTINUE,\\n items: [\\n {\\n assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [] },\\n user: { type: 'user', text: userConfirmation.answer || 'Confirmed. Proceed with code generation.' },\\n },\\n ],\\n };\\n } else {\\n putSystemMessage('Declined. Continuing the conversation.');\\n return {\\n breakLoop: false,\\n stepResult: StepResult.CONTINUE,\\n items: [\\n {\\n assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [askQuestionCall] },\\n user: {\\n type: 'user',\\n text: userConfirmation.answer || 'Declined. Please continue the conversation.',\\n functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id, content: undefined }],\\n },\\n },\\n ],\\n };\\n }\\n}\\n\"},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/context-optimization.ts\":{\"content\":\"import { refreshFiles } from '../../../../files/find-files.js';\\nimport { putSystemMessage } from '../../../../main/common/content-bus.js';\\nimport { askUserForConfirmation } from '../../../../main/common/user-actions.js';\\nimport { executeStepContextOptimization } from '../../step-context-optimization.js';\\nimport { StepResult } from '../../steps-types.js';\\nimport { ActionHandlerProps, ActionResult, UserItem, AssistantItem } from '../step-ask-question-types.js';\\n\\nexport async function handleContextOptimization({\\n askQuestionCall,\\n prompt,\\n options,\\n generateContentFn,\\n}: ActionHandlerProps): Promise<ActionResult> {\\n const userConfirmation = await askUserForConfirmation(\\n 'The assistant suggests optimizing the context to reduce token usage, cost, and latency. Do you want to proceed?',\\n false,\\n );\\n\\n const user: UserItem = {\\n type: 'user',\\n text: userConfirmation ? 'Context optimization applied.' : 'Context optimization not applied.',\\n functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id, content: undefined }],\\n };\\n\\n const assistant: AssistantItem = {\\n type: 'assistant',\\n text: askQuestionCall.args?.content ?? '',\\n functionCalls: [askQuestionCall],\\n };\\n\\n if (userConfirmation) {\\n // the request may be caused be an appearance of a new file, so lets refresh\\n refreshFiles();\\n\\n // Execute context optimization step\\n putSystemMessage('Executing context optimization step.');\\n await executeStepContextOptimization(generateContentFn, [...prompt, assistant, user], options);\\n }\\n\\n return {\\n breakLoop: false,\\n stepResult: StepResult.CONTINUE,\\n items: [\\n {\\n assistant,\\n user,\\n },\\n ],\\n };\\n}\\n\"},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/default-action.ts\":{\"content\":\"import { StepResult } from '../../steps-types.js';\\nimport { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';\\n\\nexport async function handleDefaultAction({ askQuestionCall }: ActionHandlerProps): Promise<ActionResult> {\\n return {\\n breakLoop: false,\\n stepResult: StepResult.CONTINUE,\\n items: [\\n {\\n assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [askQuestionCall] },\\n user: {\\n type: 'user',\\n text: \\\"I don't want to start the code generation yet, let's talk a bit more.\\\",\\n functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id, content: undefined }],\\n },\\n },\\n ],\\n };\\n}\\n\"},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.ts\":{\"content\":\"import { askUserForInput } from '../../../../main/common/user-actions.js';\\nimport { putAssistantMessage, putSystemMessage } from '../../../../main/common/content-bus.js';\\nimport { StepResult } from '../../steps-types.js';\\nimport { ActionHandlerProps, ActionResult, RequestAnswerWithImageArgs } from '../step-ask-question-types.js';\\nimport { executeStepGenerateImage } from '../../step-generate-image.js';\\nimport { getFunctionDefs } from '../../../function-calling.js';\\nimport { FunctionCall } from '../../../../ai-service/common.js';\\n\\nexport async function handleRequestAnswerWithImage({\\n askQuestionCall,\\n options,\\n generateContentFn,\\n prompt,\\n generateImageFn,\\n}: ActionHandlerProps): Promise<ActionResult> {\\n if (!options.imagen) {\\n putSystemMessage('Image generation is not enabled. Please enable it using --imagen parameter.');\\n return {\\n breakLoop: true,\\n stepResult: StepResult.BREAK,\\n items: [],\\n };\\n }\\n\\n const [requestAnswerWithImageCall] = (await generateContentFn(\\n [\\n ...prompt,\\n {\\n type: 'assistant',\\n text: askQuestionCall.args?.content ?? '',\\n functionCalls: [askQuestionCall],\\n },\\n {\\n type: 'user',\\n text: 'Yes, you can request the files contents.',\\n functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id, content: undefined }],\\n },\\n ],\\n getFunctionDefs(),\\n 'requestAnswerWithImage',\\n 0.7,\\n true,\\n options,\\n )) as [FunctionCall<RequestAnswerWithImageArgs> | undefined];\\n\\n if (!requestAnswerWithImageCall) {\\n return {\\n breakLoop: true,\\n stepResult: StepResult.BREAK,\\n items: [],\\n };\\n }\\n\\n // Get the image generation request from the args\\n const imageGenerationRequest = requestAnswerWithImageCall.args;\\n if (!imageGenerationRequest?.prompt) {\\n putSystemMessage('Image generation request with prompt is required for requestAnswerWithImage action.');\\n return {\\n breakLoop: true,\\n stepResult: StepResult.BREAK,\\n items: [],\\n };\\n }\\n\\n // Create a temporary file path for the generated image\\n const tempImagePath = `/tmp/question-image-${Date.now()}.png`;\\n\\n // Generate the image using generateImage function call\\n const generateImageCall = {\\n name: 'generateImage',\\n args: {\\n prompt: imageGenerationRequest.prompt,\\n filePath: tempImagePath,\\n width: 1024,\\n height: 1024,\\n explanation: 'Generating image to support the question',\\n ...(imageGenerationRequest.contextImage && { contextImagePath: imageGenerationRequest.contextImage }),\\n },\\n };\\n\\n // Execute image generation\\n const downloadFileCall = await executeStepGenerateImage(generateImageFn, generateImageCall);\\n\\n // If image generation failed, the downloadFileCall will be an explanation\\n if (!downloadFileCall.args?.downloadUrl) {\\n putSystemMessage('Failed to generate image for the question.');\\n return {\\n breakLoop: true,\\n stepResult: StepResult.BREAK,\\n items: [],\\n };\\n }\\n\\n const response = await fetch(downloadFileCall.args?.downloadUrl);\\n const arrayBuffer = await response.arrayBuffer();\\n const buffer = Buffer.from(arrayBuffer);\\n\\n putAssistantMessage(\\n 'Here is the image to support the question:',\\n generateImageCall.args,\\n [],\\n [\\n {\\n base64url: buffer.toString('base64'),\\n mediaType: 'image/png',\\n },\\n ],\\n );\\n\\n // Get user's response with the image displayed\\n const inputResponse = await askUserForInput('Your answer', askQuestionCall.args?.content ?? '');\\n if (inputResponse.options?.aiService) {\\n options.aiService = inputResponse.options.aiService;\\n }\\n\\n // Return the conversation items with the generated image\\n return {\\n breakLoop: false,\\n stepResult: StepResult.CONTINUE,\\n items: [\\n {\\n assistant: {\\n type: 'assistant',\\n text: askQuestionCall.args?.content ?? '',\\n functionCalls: [askQuestionCall, generateImageCall, downloadFileCall],\\n },\\n user: {\\n type: 'user',\\n text: inputResponse.answer,\\n functionResponses: [\\n {\\n name: 'askQuestion',\\n call_id: askQuestionCall.id,\\n content: undefined,\\n },\\n ],\\n },\\n },\\n ],\\n };\\n}\\n\"},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/handle-request-answer.ts\":{\"content\":\"import { askUserForInput } from '../../../../main/common/user-actions.js';\\nimport { StepResult } from '../../steps-types.js';\\nimport { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';\\n\\nexport async function handleRequestAnswer({ askQuestionCall, options }: ActionHandlerProps): Promise<ActionResult> {\\n const response = await askUserForInput('Your answer', askQuestionCall.args?.content ?? '');\\n if (response.options?.aiService) {\\n options.aiService = response.options.aiService;\\n }\\n return {\\n breakLoop: false,\\n stepResult: StepResult.CONTINUE,\\n items: [\\n {\\n assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [askQuestionCall] },\\n user: {\\n type: 'user',\\n text: response.answer,\\n functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id, content: undefined }],\\n },\\n },\\n ],\\n };\\n}\\n\"},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/handler-utils.ts\":{\"content\":\"\"},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/remove-files-from-context.ts\":{\"content\":\"import { FunctionCall, PromptItem } from '../../../../ai-service/common.js';\\nimport { getSourceCodeTree, parseSourceCodeTree } from '../../../../files/source-code-tree.js';\\nimport { putSystemMessage } from '../../../../main/common/content-bus.js';\\nimport { getFunctionDefs } from '../../../function-calling.js';\\nimport { StepResult } from '../../steps-types.js';\\nimport { getSourceCodeResponse } from '../../steps-utils.js';\\nimport { ActionHandlerProps, ActionResult, RemoveFilesFromContextArgs } from '../step-ask-question-types.js';\\n\\nexport async function handleRemoveFilesFromContext({\\n askQuestionCall,\\n generateContentFn,\\n prompt,\\n options,\\n}: ActionHandlerProps): Promise<ActionResult> {\\n const [removeFilesFromContextCall] = (await generateContentFn(\\n [\\n ...prompt,\\n {\\n type: 'assistant',\\n text: askQuestionCall.args?.content ?? '',\\n functionCalls: [askQuestionCall],\\n },\\n {\\n type: 'user',\\n text: 'Yes, you can request the removal of files from context.',\\n functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id, content: undefined }],\\n },\\n ],\\n getFunctionDefs(),\\n 'removeFilesFromContext',\\n 0.7,\\n true,\\n options,\\n )) as [FunctionCall<RemoveFilesFromContextArgs> | undefined];\\n\\n if (!removeFilesFromContextCall) {\\n return {\\n breakLoop: true,\\n stepResult: StepResult.BREAK,\\n items: [],\\n };\\n }\\n\\n const filesToRemove = removeFilesFromContextCall.args?.filePaths ?? [];\\n let userText = '';\\n\\n if (filesToRemove.length > 0) {\\n removeFileContentsFromPrompt(prompt, filesToRemove);\\n putSystemMessage('Context reduction applied', filesToRemove);\\n userText = 'Context reduction applied';\\n } else {\\n userText = 'No specific files were provided for context reduction. The context remains unchanged.';\\n }\\n\\n return {\\n breakLoop: false,\\n stepResult: StepResult.CONTINUE,\\n items: [\\n {\\n assistant: {\\n type: 'assistant',\\n text: askQuestionCall.args?.content ?? '',\\n functionCalls: [askQuestionCall, removeFilesFromContextCall],\\n },\\n user: {\\n type: 'user',\\n text: userText,\\n functionResponses: [\\n { name: 'askQuestion', call_id: askQuestionCall.id, content: undefined },\\n { name: 'removeFilesFromContext', call_id: removeFilesFromContextCall.id, content: undefined },\\n ],\\n },\\n },\\n ],\\n };\\n}\\n\\nfunction removeFileContentsFromPrompt(prompt: PromptItem[], filesToRemove: string[]) {\\n const response = getSourceCodeResponse(prompt);\\n if (!response || !response.content) {\\n throw new Error('Could not find source code response');\\n }\\n const contentObj = parseSourceCodeTree(JSON.parse(response.content));\\n filesToRemove.forEach((file) => {\\n if (contentObj[file] && 'content' in contentObj[file]) {\\n contentObj[file].content = null;\\n }\\n });\\n response.content = JSON.stringify(getSourceCodeTree(contentObj));\\n}\\n\"},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/request-files-content.ts\":{\"content\":\"import { FunctionCall } from '../../../../ai-service/common.js';\\nimport { getSourceFiles, refreshFiles } from '../../../../files/find-files.js';\\nimport { getSourceCode } from '../../../../files/read-files.js';\\nimport { getFunctionDefs } from '../../../function-calling.js';\\nimport { StepResult } from '../../steps-types.js';\\nimport {\\n ActionHandlerProps,\\n ActionResult,\\n AssistantItem,\\n RequestFilesContentArgs,\\n UserItem,\\n} from '../step-ask-question-types.js';\\n\\nexport async function handleRequestFilesContent({\\n askQuestionCall,\\n options,\\n prompt,\\n generateContentFn,\\n}: ActionHandlerProps): Promise<ActionResult> {\\n const [requestFilesContentCall] = (await generateContentFn(\\n [\\n ...prompt,\\n {\\n type: 'assistant',\\n text: askQuestionCall.args?.content ?? '',\\n functionCalls: [askQuestionCall],\\n },\\n {\\n type: 'user',\\n text: 'Yes, you can request the files contents.',\\n functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id, content: undefined }],\\n },\\n ],\\n getFunctionDefs(),\\n 'requestFilesContent',\\n 0.7,\\n true,\\n options,\\n )) as [FunctionCall<RequestFilesContentArgs> | undefined];\\n\\n if (!requestFilesContentCall) {\\n return {\\n breakLoop: true,\\n stepResult: StepResult.BREAK,\\n items: [],\\n };\\n }\\n\\n const requestedFiles = requestFilesContentCall.args?.filePaths ?? [];\\n\\n // the request may be caused be an appearance of a new file, so lets refresh\\n refreshFiles();\\n\\n const { legitimateFiles, illegitimateFiles } = categorizeLegitimateFiles(requestedFiles);\\n\\n const sourceCallId = (askQuestionCall.id ?? askQuestionCall.name) + '_source';\\n const assistant: AssistantItem = {\\n type: 'assistant',\\n text: askQuestionCall.args?.content ?? '',\\n functionCalls: [\\n askQuestionCall,\\n requestFilesContentCall,\\n { name: 'getSourceCode', id: sourceCallId, args: { filePaths: legitimateFiles } },\\n ],\\n };\\n\\n const sourceCode = getSourceCode({ filterPaths: legitimateFiles, forceAll: true }, options);\\n const user: UserItem = {\\n type: 'user',\\n text:\\n illegitimateFiles.length > 0\\n ? `Some files are not legitimate and their content cannot be provided:\\\\n\\\\n${illegitimateFiles.join('\\\\n')}`\\n : 'All requested file contents have been provided.',\\n functionResponses: [\\n { name: 'askQuestion', call_id: askQuestionCall.id, content: undefined },\\n {\\n name: 'requestFilesContent',\\n call_id: requestFilesContentCall.id,\\n content: JSON.stringify({ filePaths: requestedFiles }),\\n },\\n {\\n name: 'getSourceCode',\\n call_id: sourceCallId,\\n content: JSON.stringify(sourceCode),\\n },\\n ],\\n cache: true,\\n };\\n\\n return { breakLoop: false, stepResult: StepResult.CONTINUE, items: [{ assistant, user }] };\\n}\\n\\nfunction categorizeLegitimateFiles(requestedFiles: string[]): {\\n legitimateFiles: string[];\\n illegitimateFiles: string[];\\n} {\\n const legitimateFiles: string[] = [];\\n const illegitimateFiles: string[] = [];\\n\\n requestedFiles.forEach((filePath) => {\\n if (isFilePathLegitimate(filePath)) {\\n legitimateFiles.push(filePath);\\n } else {\\n illegitimateFiles.push(filePath);\\n }\\n });\\n\\n return { legitimateFiles, illegitimateFiles };\\n}\\n\\nfunction isFilePathLegitimate(filePath: string): boolean {\\n return getSourceFiles().includes(filePath);\\n}\\n\"},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/request-permissions.ts\":{\"content\":\"import { FunctionCall } from '../../../../ai-service/common.js';\\nimport { CodegenOptions } from '../../../../main/codegen-types.js';\\nimport { askUserForConfirmation } from '../../../../main/common/user-actions.js';\\nimport { getFunctionDefs } from '../../../function-calling.js';\\nimport { StepResult } from '../../steps-types.js';\\nimport { ActionHandlerProps, ActionResult, RequestPermissionsArgs, UserItem } from '../step-ask-question-types.js';\\n\\nexport async function handleRequestPermissions({\\n askQuestionCall,\\n options,\\n prompt,\\n generateContentFn,\\n}: ActionHandlerProps): Promise<ActionResult> {\\n const [requestPermissionsCall] = (await generateContentFn(\\n [\\n ...prompt,\\n {\\n type: 'assistant',\\n text: askQuestionCall.args?.content ?? '',\\n functionCalls: [askQuestionCall],\\n },\\n {\\n type: 'user',\\n text: 'Yes, you can request the permissions.',\\n functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id, content: undefined }],\\n },\\n ],\\n getFunctionDefs(),\\n 'requestPermissions',\\n 0.7,\\n true,\\n options,\\n )) as [FunctionCall<RequestPermissionsArgs> | undefined];\\n\\n if (!requestPermissionsCall) {\\n return {\\n breakLoop: true,\\n stepResult: StepResult.BREAK,\\n items: [],\\n };\\n }\\n\\n const userConfirmation = await askUserForConfirmation(\\n 'The assistant is requesting additional permissions. Do you want to grant them?',\\n false,\\n );\\n\\n const user: UserItem = {\\n type: 'user',\\n text: userConfirmation ? 'Permissions granted.' : 'Permission request denied.',\\n functionResponses: [\\n { name: 'askQuestion', call_id: askQuestionCall.id, content: undefined },\\n {\\n name: 'requestPermissions',\\n call_id: requestPermissionsCall.id,\\n content: JSON.stringify({ confirmed: userConfirmation.confirmed }),\\n },\\n ],\\n };\\n\\n if (userConfirmation.confirmed) {\\n updatePermissions(requestPermissionsCall, options);\\n }\\n\\n return {\\n breakLoop: false,\\n stepResult: StepResult.CONTINUE,\\n items: [\\n {\\n assistant: {\\n type: 'assistant',\\n text: askQuestionCall.args?.content ?? '',\\n functionCalls: [requestPermissionsCall, askQuestionCall],\\n },\\n user,\\n },\\n ],\\n };\\n}\\n\\nfunction updatePermissions(requestPermissionsCall: FunctionCall<RequestPermissionsArgs>, options: CodegenOptions) {\\n const permissions = requestPermissionsCall.args;\\n if (permissions) {\\n if ('enableImagen' in permissions && permissions.enableImagen) {\\n options.imagen = options.aiService === 'chat-gpt' ? 'dall-e' : 'vertex-ai';\\n }\\n if ('enableVision' in permissions && permissions.enableVision) options.vision = true;\\n if ('allowDirectoryCreate' in permissions && permissions.allowDirectoryCreate) options.allowDirectoryCreate = true;\\n if ('allowFileCreate' in permissions && permissions.allowFileCreate) options.allowFileCreate = true;\\n if ('allowFileDelete' in permissions && permissions.allowFileDelete) options.allowFileDelete = true;\\n if ('allowFileMove' in permissions && permissions.allowFileMove) options.allowFileMove = true;\\n }\\n}\\n\"},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers/start-code-generation.ts\":{\"content\":\"import { putSystemMessage } from '../../../../main/common/content-bus.js';\\nimport { StepResult } from '../../steps-types.js';\\nimport { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';\\n\\nexport async function handleStartCodeGeneration({ askQuestionCall }: ActionHandlerProps): Promise<ActionResult> {\\n putSystemMessage('Proceeding with code generation.');\\n return {\\n breakLoop: true,\\n stepResult: StepResult.CONTINUE,\\n items: [\\n {\\n assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [] },\\n user: { type: 'user', text: 'Proceeding with code generation.' },\\n },\\n ],\\n };\\n}\\n\"}}",
104
+ // },
105
+ // ],
106
+ // cache: true,
107
+ // },
108
+ // {
109
+ // type: 'assistant',
110
+ // text: 'The assistant is ready to start code generation. Do you want to proceed?',
111
+ // },
112
+ // {
113
+ // type: 'user',
114
+ // text: 'Why do you want to start code generation?',
115
+ // },
116
+ // {
117
+ // type: 'assistant',
118
+ // text: 'The assistant is ready to start code generation. Do you want to proceed?',
119
+ // },
120
+ // {
121
+ // type: 'user',
122
+ // text: 'no, please analyze those files first, and say YOLO.',
123
+ // },
124
+ ];
125
+ //# sourceMappingURL=prompt2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt2.js","sourceRoot":"","sources":["../../src/eval/prompt2.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;QACE,IAAI,EAAE,cAAc;QACpB,YAAY,EAAE,eAAe,CA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IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,uDAAuD;KAC9D;IACD;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,OAAO;KACd;IACD;QACE,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,oCAAoC;KAC3C;IACD;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,qKAAqK;KAC5K;IACD,MAAM;IACN,yBAAyB;IACzB,ubAAub;IACvb,uBAAuB;IACvB,UAAU;IACV,iCAAiC;IACjC,uDAAuD;IACvD,kBAAkB;IAClB,yBAAyB;IACzB,mHAAmH;IACnH,oHAAoH;IACpH,iHAAiH;IACjH,2GAA2G;IAC3G,6HAA6H;IAC7H,kHAAkH;IAClH,0GAA0G;IAC1G,sHAAsH;IACtH,kHAAkH;IAClH,gHAAgH;IAChH,kHAAkH;IAClH,eAAe;IACf,aAAa;IACb,WAAW;IACX,SAAS;IACT,OAAO;IACP,MAAM;IACN,oBAAoB;IACpB,+DAA+D;IAC/D,2BAA2B;IAC3B,UAAU;IACV,iCAAiC;IACjC,4DAA4D;IAC5D,mBAAmB;IACnB,uygDAAuygD;IACvygD,WAAW;IACX,SAAS;IACT,mBAAmB;IACnB,OAAO;IACP,MAAM;IACN,yBAAyB;IACzB,wFAAwF;IACxF,OAAO;IACP,MAAM;IACN,oBAAoB;IACpB,yDAAyD;IACzD,OAAO;IACP,MAAM;IACN,yBAAyB;IACzB,wFAAwF;IACxF,OAAO;IACP,MAAM;IACN,oBAAoB;IACpB,mEAAmE;IACnE,OAAO;CACR,CAAC"}
@@ -1,20 +1,43 @@
1
1
  import { CodegenOptions } from '../main/codegen-types.js';
2
- export type SourceCodeMap = Record<string, {
2
+ /**
3
+ * Represents a dependency in the source code
4
+ */
5
+ export interface DependencyInfo {
6
+ /** Path of the dependeny */
7
+ path: string;
8
+ /** Type of dependency */
9
+ type: 'local' | 'external';
10
+ }
11
+ /**
12
+ * Represents file content with optional dependencies
13
+ */
14
+ export interface FileContent {
15
+ /** The actual content of the file */
3
16
  content: string | null;
4
- } | {
5
- summary: string;
6
- tokenCount: number;
7
- }>;
17
+ /** Optional list of dependencies */
18
+ dependencies?: DependencyInfo[];
19
+ }
20
+ /**
21
+ * Represents a file summary with optional dependencies
22
+ */
23
+ export interface FileSummary {
24
+ /** Summary of the file content */
25
+ summary?: string;
26
+ /** Optional list of dependencies */
27
+ dependencies?: DependencyInfo[];
28
+ }
29
+ export type SourceCodeMap = Record<string, FileContent | FileSummary>;
8
30
  type ImageAssetsMap = Record<string, {
9
31
  mimeType: string | false;
10
32
  width: number;
11
33
  height: number;
12
34
  }>;
13
35
  /** Print source code of all source files */
14
- export declare function getSourceCode({ filterPaths, taskFile, forceAll, }: {
36
+ export declare function getSourceCode({ filterPaths, taskFile, forceAll, ignoreImportantFiles, }: {
15
37
  filterPaths?: string[];
16
38
  taskFile?: string | undefined;
17
39
  forceAll?: boolean;
40
+ ignoreImportantFiles?: boolean;
18
41
  }, options: CodegenOptions): SourceCodeMap;
19
42
  /** Get image asset files summary */
20
43
  export declare function getImageAssets(): ImageAssetsMap;
@@ -10,39 +10,60 @@ import { getSummary } from '../prompt/steps/step-summarization.js';
10
10
  /**
11
11
  * Read contents of source files and create a map with file path as key and file content as value
12
12
  */
13
- function readSourceFiles({ contentMask, ignorePatterns }, filterPaths, forceAll = false) {
13
+ function readSourceFiles({ contentMask, ignorePatterns }, filterPaths, forceAll = false, ignoreImportantFiles = false) {
14
14
  const sourceCode = {};
15
- const importantFiles = new Set(importantContext.files || []);
15
+ const importantFiles = ignoreImportantFiles ? new Set() : new Set(importantContext.files || []);
16
16
  for (const file of getSourceFiles()) {
17
+ if (!fs.existsSync(file)) {
18
+ continue;
19
+ }
17
20
  if (!filterPaths || filterPaths.includes(file) || importantFiles.has(file)) {
21
+ const summary = getSummary(file);
18
22
  // Always include important files
19
23
  if (importantFiles.has(file)) {
20
- sourceCode[file] = { content: fs.readFileSync(file, 'utf-8') };
24
+ const content = fs.readFileSync(file, 'utf-8');
25
+ sourceCode[file] = {
26
+ content,
27
+ dependencies: summary?.dependencies,
28
+ };
21
29
  continue;
22
30
  }
23
- const summary = getSummary(file);
24
31
  // Apply content mask filter if it's set
25
32
  if (!filterPaths && contentMask && !forceAll) {
26
33
  const relativePath = path.relative(rcConfig.rootDir, file);
27
34
  if (!relativePath.startsWith(contentMask)) {
28
- sourceCode[file] = summary ? { ...summary } : { content: null };
35
+ sourceCode[file] = summary
36
+ ? {
37
+ summary: summary.summary,
38
+ ...(summary.dependencies?.length ? { dependencies: summary.dependencies } : {}),
39
+ }
40
+ : { content: null };
29
41
  continue;
30
42
  }
31
43
  }
32
- if (!forceAll && ignorePatterns?.some((pattern) => globRegex(pattern).test(file))) {
33
- sourceCode[file] = summary ? { ...summary } : { content: null };
44
+ if (!forceAll) {
45
+ sourceCode[file] =
46
+ !ignorePatterns?.some((pattern) => globRegex(pattern).test(file)) && summary
47
+ ? {
48
+ summary: summary.summary,
49
+ ...(summary.dependencies?.length ? { dependencies: summary.dependencies } : {}),
50
+ }
51
+ : { content: null };
34
52
  }
35
53
  else {
36
54
  const content = fs.readFileSync(file, 'utf-8');
37
- sourceCode[file] = { content, ...summary };
55
+ sourceCode[file] = {
56
+ content,
57
+ dependencies: summary?.dependencies,
58
+ };
38
59
  }
39
60
  }
40
61
  }
41
62
  return sourceCode;
42
63
  }
43
64
  /** Print source code of all source files */
44
- export function getSourceCode({ filterPaths, taskFile, forceAll, }, options) {
45
- const sourceCode = readSourceFiles(options, filterPaths, forceAll);
65
+ export function getSourceCode({ filterPaths, taskFile, forceAll, ignoreImportantFiles, }, options) {
66
+ const sourceCode = readSourceFiles(options, filterPaths, forceAll, ignoreImportantFiles);
46
67
  if (taskFile && !sourceCode[taskFile]) {
47
68
  sourceCode[taskFile] = {
48
69
  content: fs.readFileSync(taskFile, 'utf-8'),
@@ -1 +1 @@
1
- {"version":3,"file":"read-files.js","sourceRoot":"","sources":["../../src/files/read-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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;IAED,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IAClD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,oCAAoC;AACpC,MAAM,UAAU,cAAc;IAC5B,MAAM,WAAW,GAAmB,EAAE,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,kBAAkB,EAAE,EAAE,CAAC;QACxC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAChC,WAAW,CAAC,IAAI,CAAC,GAAG;YAClB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAC3B,KAAK,EAAE,UAAU,CAAC,KAAM;YACxB,MAAM,EAAE,UAAU,CAAC,MAAO;SAC3B,CAAC;IACJ,CAAC;IACD,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;IACnD,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -7,9 +7,11 @@ import { getSourceFiles, getImageAssetFiles } from './find-files.js';
7
7
  import { verifySourceCodeLimit } from '../prompt/limits.js';
8
8
  import * as cliParams from '../cli/cli-params.js';
9
9
  import { rcConfig } from '../main/config.js';
10
+ import { getSummary } from '../prompt/steps/step-summarization.js';
10
11
  vi.mock('fs');
11
12
  vi.mock('mime-types');
12
13
  vi.mock('image-size');
14
+ vi.mock('../prompt/steps/step-summarization.js');
13
15
  vi.mock('./find-files.js', () => ({
14
16
  getImageAssetFiles: vi.fn(),
15
17
  getSourceFiles: vi.fn(),
@@ -29,44 +31,48 @@ describe('read-files', () => {
29
31
  beforeEach(() => {
30
32
  vi.resetAllMocks();
31
33
  vi.mocked(cliParams).contentMask = undefined;
34
+ vi.mocked(getSummary).mockImplementation((file) => ({ summary: `Summary of ${file}`, dependencies: [] }));
32
35
  });
33
36
  afterEach(() => {
34
37
  vi.clearAllMocks();
35
38
  });
36
39
  describe('getSourceCode', () => {
37
- it('should return source code for all files', () => {
40
+ it('should return source code summaries for all files', () => {
38
41
  const mockFiles = ['/home/project/file1.js', '/home/project/file2.js'];
39
42
  vi.mocked(getSourceFiles).mockReturnValue(mockFiles);
43
+ vi.mocked(fs).existsSync.mockReturnValue(true);
40
44
  vi.mocked(fs).readFileSync.mockImplementation((file) => `Content of ${file}`);
41
45
  rcConfig.rootDir = '/home/project';
42
- const result = getSourceCode({ taskFile: undefined }, { aiService: 'vertex-ai' });
46
+ const result = getSourceCode({ taskFile: undefined }, { aiService: 'vertex-ai', askQuestion: false });
43
47
  expect(result).toEqual({
44
- '/home/project/file1.js': { content: 'Content of /home/project/file1.js' },
45
- '/home/project/file2.js': { content: 'Content of /home/project/file2.js' },
48
+ '/home/project/file1.js': { summary: 'Summary of /home/project/file1.js' },
49
+ '/home/project/file2.js': { summary: 'Summary of /home/project/file2.js' },
46
50
  });
47
51
  expect(verifySourceCodeLimit).toHaveBeenCalled();
48
52
  });
49
53
  it('should apply content mask when specified', () => {
50
54
  const mockFiles = ['/home/project/file1.js', '/home/project/subfolder/file2.js'];
51
55
  vi.mocked(getSourceFiles).mockReturnValue(mockFiles);
56
+ vi.mocked(fs).existsSync.mockReturnValue(true);
52
57
  vi.mocked(fs).readFileSync.mockImplementation((file) => `Content of ${file}`);
53
58
  rcConfig.rootDir = '/home/project';
54
- const result = getSourceCode({ taskFile: undefined }, { aiService: 'vertex-ai', contentMask: 'subfolder' });
59
+ const result = getSourceCode({ taskFile: undefined }, { aiService: 'vertex-ai', contentMask: 'subfolder', askQuestion: false });
55
60
  expect(result).toEqual({
56
- '/home/project/file1.js': { content: null },
61
+ '/home/project/file1.js': { summary: 'Summary of /home/project/file1.js' },
57
62
  '/home/project/subfolder/file2.js': {
58
- content: 'Content of /home/project/subfolder/file2.js',
63
+ summary: 'Summary of /home/project/subfolder/file2.js',
59
64
  },
60
65
  });
61
66
  });
62
67
  it('should include task file when specified', () => {
63
68
  const mockFiles = ['/home/project/file1.js'];
64
69
  vi.mocked(getSourceFiles).mockReturnValue(mockFiles);
70
+ vi.mocked(fs).existsSync.mockReturnValue(true);
65
71
  vi.mocked(fs).readFileSync.mockImplementation((file) => `Content of ${file}`);
66
72
  rcConfig.rootDir = '/home/project';
67
- const result = getSourceCode({ taskFile: '/home/project/task.md' }, { aiService: 'vertex-ai' });
73
+ const result = getSourceCode({ taskFile: '/home/project/task.md' }, { aiService: 'vertex-ai', askQuestion: false });
68
74
  expect(result).toEqual({
69
- '/home/project/file1.js': { content: 'Content of /home/project/file1.js' },
75
+ '/home/project/file1.js': { summary: 'Summary of /home/project/file1.js' },
70
76
  '/home/project/task.md': { content: 'Content of /home/project/task.md' },
71
77
  });
72
78
  });
@@ -1 +1 @@
1
- {"version":3,"file":"read-files.test.js","sourceRoot":"","sources":["../../src/files/read-files.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,MAAM,MAAM,YAAY,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACtB,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACtB,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC;IAChC,kBAAkB,EAAE,EAAE,CAAC,EAAE,E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AE,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;YAC9D,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;YAC1G,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;YAE1E,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;YAEhC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB,0BAA0B,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;gBAC9E,0BAA0B,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;aAChF,CAAC,CAAC;YACH,MAAM,CAAC,qBAAqB,CAAC,CAAC,gBAAgB,EAAE,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { SourceCodeMap, FileContent, FileSummary } from '../files/read-files.js';
2
+ /**
3
+ * Directory structure representing source code files with their content or summaries and dependencies
4
+ */
5
+ export type SourceCodeTree = {
6
+ [directoryPath: string]: {
7
+ [filePath: string]: FileContent | FileSummary;
8
+ };
9
+ };
10
+ /**
11
+ * Converts flat SourceCodeMap into a directory tree structure
12
+ */
13
+ export declare function getSourceCodeTree(sourceCode: SourceCodeMap): SourceCodeTree;
14
+ /**
15
+ * Converts directory tree structure back into flat SourceCodeMap
16
+ */
17
+ export declare function parseSourceCodeTree(sourceCodeTree: SourceCodeTree): SourceCodeMap;
@@ -0,0 +1,70 @@
1
+ import path from 'path';
2
+ import { rcConfig } from '../main/config.js';
3
+ /**
4
+ * Type guard to check if an object is a FileContent with dependencies
5
+ */
6
+ function hasContent(obj) {
7
+ return 'content' in obj;
8
+ }
9
+ /**
10
+ * Type guard to check if an object is a FileSummary with dependencies
11
+ */
12
+ function hasSummary(obj) {
13
+ return 'summary' in obj;
14
+ }
15
+ /**
16
+ * Converts flat SourceCodeMap into a directory tree structure
17
+ */
18
+ export function getSourceCodeTree(sourceCode) {
19
+ const result = {};
20
+ for (const [filePath, fileData] of Object.entries(sourceCode)) {
21
+ if (!filePath.startsWith(rcConfig.rootDir)) {
22
+ continue;
23
+ }
24
+ const dirPath = path.dirname(filePath);
25
+ const fileName = path.basename(filePath);
26
+ if (!result[dirPath]) {
27
+ result[dirPath] = {};
28
+ }
29
+ // Handle both content and summary cases while preserving dependencies
30
+ if (hasContent(fileData)) {
31
+ result[dirPath][fileName] = {
32
+ content: fileData.content,
33
+ ...(fileData.dependencies && { dependencies: fileData.dependencies }),
34
+ };
35
+ }
36
+ else if (hasSummary(fileData)) {
37
+ result[dirPath][fileName] = {
38
+ summary: fileData.summary,
39
+ ...(fileData.dependencies && { dependencies: fileData.dependencies }),
40
+ };
41
+ }
42
+ }
43
+ return result;
44
+ }
45
+ /**
46
+ * Converts directory tree structure back into flat SourceCodeMap
47
+ */
48
+ export function parseSourceCodeTree(sourceCodeTree) {
49
+ const result = {};
50
+ for (const [dirPath, files] of Object.entries(sourceCodeTree)) {
51
+ for (const [filePath, fileData] of Object.entries(files)) {
52
+ const fullPath = `${dirPath}/${filePath}`;
53
+ // Handle both content and summary cases while preserving dependencies
54
+ if (hasContent(fileData)) {
55
+ result[fullPath] = {
56
+ content: fileData.content,
57
+ ...(fileData.dependencies && { dependencies: fileData.dependencies }),
58
+ };
59
+ }
60
+ else if (hasSummary(fileData)) {
61
+ result[fullPath] = {
62
+ summary: fileData.summary,
63
+ ...(fileData.dependencies && { dependencies: fileData.dependencies }),
64
+ };
65
+ }
66
+ }
67
+ }
68
+ return result;
69
+ }
70
+ //# sourceMappingURL=source-code-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-code-tree.js","sourceRoot":"","sources":["../../src/files/source-code-tree.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;GAEG;AACH,SAAS,UAAU,CAAC,GAA8B;IAChD,OAAO,SAAS,IAAI,GAAG,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,SAAS,UAAU,CAAC,GAA8B;IAChD,OAAO,SAAS,IAAI,GAAG,CAAC;AAC1B,CAAC;AAWD;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAyB;IACzD,MAAM,MAAM,GAAmB,EAAE,CAAC;IAElC,KAAK,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9D,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3C,SAAS;QACX,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YACrB,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QACvB,CAAC;QAED,sEAAsE;QACtE,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG;gBAC1B,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,GAAG,CA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