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
@@ -1,25 +1,29 @@
1
1
  import assert from 'node:assert';
2
- import fs from 'fs';
3
- import mime from 'mime-types';
4
2
  import { getSystemPrompt } from './systemprompt.js';
5
3
  import { getFunctionDefs } from './function-calling.js';
6
4
  import { getSourceCode, getImageAssets } from '../files/read-files.js';
7
- import { importantContext } from '../main/config.js';
8
5
  import { executeStepAskQuestion } from './steps/step-ask-question/step-ask-question.js';
9
- import { validateAndRecoverSingleResult } from './steps/step-validate-recover.js';
10
- import { executeStepVerifyPatch } from './steps/step-verify-patch.js';
11
- import { executeStepGenerateImage } from './steps/step-generate-image.js';
12
6
  import { executeStepContextOptimization } from './steps/step-context-optimization.js';
13
7
  import { StepResult } from './steps/steps-types.js';
14
- import { putSystemMessage } from '../main/common/content-bus.js';
15
8
  import { handleAiServiceFallback } from './ai-service-fallback.js';
16
9
  import { summarizeSourceCode } from './steps/step-summarization.js';
17
10
  import { executeStepHistoryUpdate, getCurrentHistory } from './steps/step-history-update.js';
18
11
  import { executeStepGenerateSummary } from './steps/step-generate-summary.js';
12
+ import { getSourceCodeTree } from '../files/source-code-tree.js';
13
+ import { INITIAL_GREETING, REQUEST_SOURCE_CODE, SOURCE_CODE_RESPONSE, READY_TO_ASSIST } from './static-prompts.js';
14
+ import { executeStepCodegenPlanning } from './steps/step-codegen-planning.js';
15
+ import { getRegisteredGenerateContentHooks } from '../main/plugin-loader.js';
16
+ import { executeStepCodegenSummary } from './steps/step-codegen-summary.js';
19
17
  /** A function that communicates with model using */
20
18
  export async function promptService(generateContentFns, generateImageFns, codegenPrompt, waitIfPaused = () => Promise.resolve()) {
21
19
  const generateContentFn = async (...args) => {
22
- return await handleAiServiceFallback(generateContentFns, codegenPrompt.options.aiService, codegenPrompt.options, ...args);
20
+ // Get the base result from the AI service
21
+ const result = await handleAiServiceFallback(generateContentFns, codegenPrompt.options.aiService, codegenPrompt.options, ...args);
22
+ // Get registered hooks for the current AI service
23
+ for (const hook of getRegisteredGenerateContentHooks()) {
24
+ await hook(args, result);
25
+ }
26
+ return result;
23
27
  };
24
28
  const generateImageFn = (...args) => {
25
29
  assert(codegenPrompt.options.imagen, 'imagen value must be provided');
@@ -41,27 +45,35 @@ async function executePromptService(generateContentFn, generateImageFn, codegenP
41
45
  const getSourceCodeRequest = { name: 'getSourceCode' };
42
46
  const prompt = [
43
47
  { type: 'systemPrompt', systemPrompt: getSystemPrompt(codegenPrompt.options) },
44
- { type: 'user', text: messages.suggestSourceCode },
48
+ { type: 'user', text: INITIAL_GREETING },
45
49
  {
46
50
  type: 'assistant',
47
- text: messages.requestSourceCode,
48
- functionCalls: [getSourceCodeRequest, ...(codegenPrompt.options.historyEnabled ? [{ name: 'readHistory' }] : [])],
51
+ text: REQUEST_SOURCE_CODE,
52
+ functionCalls: [
53
+ getSourceCodeRequest,
54
+ ...(codegenPrompt.options.vision ? [{ name: 'getImageAssets' }] : []),
55
+ ...(codegenPrompt.options.historyEnabled ? [{ name: 'readHistory' }] : []),
56
+ ],
49
57
  },
50
58
  ];
51
59
  const getSourceCodeResponse = {
52
60
  type: 'user',
53
61
  functionResponses: [
54
62
  { name: 'getSourceCode', content: messages.sourceCode },
63
+ ...(codegenPrompt.options.vision ? [{ name: 'getImageAssets', content: messages.imageAssets }] : []),
55
64
  ...(codegenPrompt.options.historyEnabled ? [{ name: 'readHistory', content: getCurrentHistory() }] : []),
56
65
  ],
66
+ text: SOURCE_CODE_RESPONSE,
57
67
  cache: true,
58
68
  };
59
69
  prompt.push(getSourceCodeResponse);
60
- if (codegenPrompt.options.vision) {
61
- prompt.slice(-1)[0].text = messages.suggestImageAssets;
62
- prompt.push({ type: 'assistant', text: messages.requestImageAssets, functionCalls: [{ name: 'getImageAssets' }] }, { type: 'user', functionResponses: [{ name: 'getImageAssets', content: messages.imageAssets }] });
63
- }
64
- prompt.slice(-1)[0].text = messages.prompt;
70
+ prompt.push({
71
+ type: 'assistant',
72
+ text: READY_TO_ASSIST,
73
+ }, {
74
+ type: 'user',
75
+ text: codegenPrompt.prompt,
76
+ });
65
77
  // Add uploaded images to the prompt if available
66
78
  if (codegenPrompt.options.images && codegenPrompt.options.images.length > 0 && codegenPrompt.options.vision) {
67
79
  prompt.slice(-1)[0].images = codegenPrompt.options.images.map((img) => ({
@@ -80,116 +92,27 @@ async function executePromptService(generateContentFn, generateImageFn, codegenP
80
92
  }
81
93
  // Execute the ask question step
82
94
  if (codegenPrompt.options.askQuestion !== false && (codegenPrompt.options.interactive || codegenPrompt.options.ui)) {
83
- const askQuestionResult = await executeStepAskQuestion(generateContentFn, prompt, getFunctionDefs(), codegenPrompt.options.temperature ?? 0.7, messages, codegenPrompt.options);
95
+ const askQuestionResult = await executeStepAskQuestion(generateContentFn, generateImageFn, prompt, getFunctionDefs(), waitIfPaused, codegenPrompt.options.temperature ?? 0.7, codegenPrompt.options);
84
96
  // Summary based on the ask-question conversation history (may be different from the initial summary)
85
97
  await executeStepGenerateSummary(generateContentFn, prompt, codegenPrompt.options);
86
- if (askQuestionResult === StepResult.BREAK) {
87
- return { result: [], prompt };
88
- }
98
+ return { result: askQuestionResult, prompt };
89
99
  }
90
100
  else if (codegenPrompt.options.askQuestion === false) {
91
101
  console.log('Ask question is not enabled.');
92
102
  // Also there is no need to generate conversation summary
93
- }
94
- const baseRequest = [
95
- prompt,
96
- getFunctionDefs(),
97
- 'codegenSummary',
98
- codegenPrompt.options.temperature ?? 0.7,
99
- codegenPrompt.options.cheap ?? false,
100
- codegenPrompt.options,
101
- ];
102
- let baseResult = await generateContentFn(...baseRequest);
103
- let codegenSummaryRequest = baseResult.find((call) => call.name === 'codegenSummary');
104
- if (codegenSummaryRequest) {
105
- // Second stage: for each file request the actual code updates
106
- putSystemMessage('Received codegen summary, will collect partial updates', codegenSummaryRequest.args);
107
- baseResult = await validateAndRecoverSingleResult(baseRequest, baseResult, generateContentFn);
108
- codegenSummaryRequest = baseResult.find((call) => call.name === 'codegenSummary');
109
- // Sometimes the result happens to be a string
110
- assert(Array.isArray(codegenSummaryRequest?.args?.fileUpdates), 'fileUpdates is not an array');
111
- assert(Array.isArray(codegenSummaryRequest?.args.contextPaths), 'contextPaths is not an array');
112
- if (!codegenPrompt.options.disableContextOptimization) {
113
- console.log('Optimize with context paths.');
114
- // Monkey patch the initial getSourceCode, do not send parts of source code that are consider irrelevant
115
- getSourceCodeRequest.args = {
116
- filePaths: [
117
- ...codegenSummaryRequest.args.fileUpdates.map((file) => file.filePath),
118
- ...codegenSummaryRequest.args.contextPaths,
119
- ...(importantContext.files ?? []),
120
- ],
121
- };
122
- getSourceCodeResponse.functionResponses.find((item) => item.name === 'getSourceCode').content =
123
- messages.contextSourceCode(getSourceCodeRequest.args?.filePaths);
124
- }
125
- // Store the first stage response entirely in conversation history
126
- prompt.push({ type: 'assistant', functionCalls: baseResult });
127
- prompt.push({
128
- type: 'user',
129
- functionResponses: baseResult.map((call) => ({ name: call.name, call_id: call.id })),
130
- cache: true,
131
- });
132
- const result = [];
133
- for (const file of codegenSummaryRequest.args.fileUpdates) {
134
- putSystemMessage('Collecting partial update for: ' + file.filePath + ' using tool: ' + file.updateToolName, file);
135
- console.log('- Prompt:', file.prompt);
136
- console.log('- Temperature', file.temperature);
137
- console.log('- Cheap', file.cheap);
138
- if (codegenPrompt.options.vision) {
139
- console.log('- Context image assets', file.contextImageAssets);
140
- }
141
- // Check if execution is paused before proceeding
142
- await waitIfPaused();
143
- // this is needed, otherwise we will get an error
144
- if (prompt.slice(-1)[0].type === 'user') {
145
- prompt.slice(-1)[0].text = file.prompt ?? messages.partialPromptTemplate(file.filePath);
146
- }
147
- else {
148
- prompt.push({ type: 'user', text: file.prompt ?? messages.partialPromptTemplate(file.filePath) });
149
- }
150
- if (codegenPrompt.options.vision && file.contextImageAssets) {
151
- prompt.slice(-1)[0].images = file.contextImageAssets.map((path) => ({
152
- path,
153
- base64url: fs.readFileSync(path, 'base64'),
154
- mediaType: mime.lookup(path) || '',
155
- }));
156
- }
157
- const partialRequest = [
158
- prompt,
159
- getFunctionDefs(),
160
- file.updateToolName,
161
- file.temperature ?? codegenPrompt.options.temperature,
162
- file.cheap === true,
163
- codegenPrompt.options,
164
- ];
165
- let partialResult = await generateContentFn(...partialRequest);
166
- putSystemMessage('Received partial update', partialResult);
167
- // Validate if function call is compliant with the schema
168
- partialResult = await validateAndRecoverSingleResult(partialRequest, partialResult, generateContentFn);
169
- // Handle image generation requests
170
- const generateImageCall = partialResult.find((call) => call.name === 'generateImage');
171
- if (generateImageCall) {
172
- partialResult.push(await executeStepGenerateImage(generateImageFn, generateImageCall));
173
- }
174
- // Verify if patchFile is one of the functions called, and test if patch is valid and can be applied successfully
175
- const patchFileCall = partialResult.find((call) => call.name === 'patchFile');
176
- if (patchFileCall) {
177
- partialResult = await executeStepVerifyPatch(patchFileCall.args, generateContentFn, prompt, getFunctionDefs(), file.temperature ?? codegenPrompt.options.temperature, file.cheap === true, codegenPrompt.options);
178
- }
179
- // add the code gen result to the context, as the subsequent code gen may depend on the result
180
- prompt.push({ type: 'assistant', functionCalls: partialResult }, {
181
- type: 'user',
182
- text: 'Update applied.',
183
- functionResponses: partialResult.map((call) => ({ name: call.name, call_id: call.id })),
184
- });
185
- result.push(...partialResult);
103
+ const planningResult = await executeStepCodegenPlanning(generateContentFn, prompt, codegenPrompt.options);
104
+ if (planningResult === StepResult.BREAK) {
105
+ return { result: [], prompt };
186
106
  }
107
+ // Execute the codegen summary step
108
+ const result = await executeStepCodegenSummary(generateContentFn, prompt, getFunctionDefs(),
109
+ // messages,
110
+ codegenPrompt.options, waitIfPaused, generateImageFn);
187
111
  return { result, prompt };
188
112
  }
189
113
  else {
190
- // This is unexpected, if happens probably means no code updates.
191
- putSystemMessage('Did not receive codegen summary, returning result.');
192
- return { result: baseResult, prompt };
114
+ console.log('Code generation skipped altogether.');
115
+ return { result: [], prompt };
193
116
  }
194
117
  }
195
118
  /**
@@ -197,18 +120,9 @@ async function executePromptService(generateContentFn, generateImageFn, codegenP
197
120
  */
198
121
  function prepareMessages(codegen) {
199
122
  return {
200
- suggestSourceCode: 'I should provide you with application source code.',
201
- requestSourceCode: 'Please provide application source code.',
202
- suggestImageAssets: 'I should also provide you with a summary of application image assets',
203
- requestImageAssets: 'Please provide summary of application image assets.',
204
- prompt: codegen.prompt +
205
- '\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.',
206
- sourceCode: JSON.stringify(getSourceCode({ taskFile: codegen.options.taskFile }, codegen.options)),
207
- contextSourceCode: (paths, pathsOnly = false) => JSON.stringify(Object.fromEntries(Object.entries(getSourceCode({ filterPaths: paths, taskFile: codegen.options.taskFile, forceAll: true }, codegen.options)).filter(([path]) => !pathsOnly || paths.includes(path)))),
123
+ sourceCode: JSON.stringify(getSourceCodeTree(getSourceCode({ taskFile: codegen.options.taskFile }, codegen.options))),
124
+ contextSourceCode: (paths, pathsOnly = false) => JSON.stringify(getSourceCodeTree(Object.fromEntries(Object.entries(getSourceCode({ filterPaths: paths, taskFile: codegen.options.taskFile, forceAll: true }, codegen.options)).filter(([path]) => !pathsOnly || paths.includes(path))))),
208
125
  imageAssets: JSON.stringify(getImageAssets()),
209
- partialPromptTemplate(path) {
210
- return `Thank you for providing the summary, now suggest changes for the \`${path}\` file using appropriate tools.`;
211
- },
212
126
  };
213
127
  }
214
128
  //# sourceMappingURL=prompt-service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-service.js","sourceRoot":"","sources":["../../src/prompt/prompt-service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,YAAY,CAAC;AAE9B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAQvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE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AAe,CAAC,OAAsB;IAC7C,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,SAAS,CACxB,iBAAiB,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAC1F;QACD,iBAAiB,EAAE,CAAC,KAAe,EAAE,YAAqB,KAAK,EAAE,EAAE,CACjE,IAAI,CAAC,SAAS,CACZ,iBAAiB,CACf,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CACZ,aAAa,CACX,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAC1E,OAAO,CAAC,OAAO,CAChB,CACF,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CACzD,CACF,CACF;QACH,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;KAC9C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { FunctionCall } from '../ai-service/common';
2
+ /**
3
+ * Common mock function call responses
4
+ */
5
+ export declare const mockResponses: {
6
+ mockPlanningResponse: (filePath: string) => FunctionCall[];
7
+ mockCodegenSummary: (filePath: string, updateToolName?: string) => FunctionCall[];
8
+ mockUpdateFile: (filePath: string, content: string) => FunctionCall[];
9
+ mockCreateFile: (filePath: string, content: string) => FunctionCall[];
10
+ mockDeleteFile: (filePath: string) => FunctionCall[];
11
+ mockPatchFile: (filePath: string, patch: string) => FunctionCall[];
12
+ mockGenerateImage: (filePath: string, width?: number, height?: number) => FunctionCall[];
13
+ mockDownloadFile: (filePath: string, downloadUrl: string) => FunctionCall[];
14
+ mockExplanation: (text: string) => FunctionCall[];
15
+ };
16
+ /**
17
+ * Common mock data structures
18
+ */
19
+ export declare const mockData: {
20
+ imageAssets: {
21
+ '/path/to/image1.png': {
22
+ width: number;
23
+ height: number;
24
+ mimeType: string;
25
+ };
26
+ '/path/to/image2.jpg': {
27
+ width: number;
28
+ height: number;
29
+ mimeType: string;
30
+ };
31
+ };
32
+ fileContent: string;
33
+ paths: {
34
+ root: string;
35
+ readonly test: string;
36
+ readonly image: string;
37
+ readonly context1: string;
38
+ readonly context2: string;
39
+ };
40
+ imageGenerationUrl: string;
41
+ };
42
+ /**
43
+ * Common test configurations
44
+ */
45
+ export declare const testConfigs: {
46
+ baseConfig: {
47
+ askQuestion: boolean;
48
+ disableContextOptimization: boolean;
49
+ explicitPrompt: string;
50
+ aiService: "vertex-ai";
51
+ };
52
+ visionConfig: {
53
+ askQuestion: boolean;
54
+ disableContextOptimization: boolean;
55
+ explicitPrompt: string;
56
+ aiService: "chat-gpt";
57
+ vision: boolean;
58
+ };
59
+ imagenConfig: {
60
+ askQuestion: boolean;
61
+ disableContextOptimization: boolean;
62
+ explicitPrompt: string;
63
+ aiService: "vertex-ai";
64
+ imagen: "dall-e";
65
+ };
66
+ };
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Common mock function call responses
3
+ */
4
+ export const mockResponses = {
5
+ // Mock response for codegenPlanning function
6
+ mockPlanningResponse: (filePath) => [
7
+ {
8
+ name: 'codegenPlanning',
9
+ args: {
10
+ problemAnalysis: 'Test problem analysis',
11
+ codeChanges: 'Test code changes plan',
12
+ affectedFiles: [
13
+ {
14
+ filePath,
15
+ reason: 'Test reason for modification',
16
+ dependencies: [],
17
+ },
18
+ ],
19
+ },
20
+ },
21
+ ],
22
+ // Mock response for codegenSummary function
23
+ mockCodegenSummary: (filePath, updateToolName = 'updateFile') => [
24
+ {
25
+ name: 'codegenSummary',
26
+ args: {
27
+ fileUpdates: [
28
+ {
29
+ filePath,
30
+ updateToolName,
31
+ prompt: 'Generate file',
32
+ },
33
+ ],
34
+ contextPaths: [],
35
+ explanation: 'Mock summary',
36
+ },
37
+ },
38
+ ],
39
+ // Mock response for updateFile function
40
+ mockUpdateFile: (filePath, content) => [
41
+ {
42
+ name: 'updateFile',
43
+ args: {
44
+ filePath,
45
+ newContent: content,
46
+ },
47
+ },
48
+ ],
49
+ // Mock response for createFile function
50
+ mockCreateFile: (filePath, content) => [
51
+ {
52
+ name: 'createFile',
53
+ args: {
54
+ filePath,
55
+ newContent: content,
56
+ },
57
+ },
58
+ ],
59
+ // Mock response for deleteFile function
60
+ mockDeleteFile: (filePath) => [
61
+ {
62
+ name: 'deleteFile',
63
+ args: {
64
+ filePath,
65
+ },
66
+ },
67
+ ],
68
+ // Mock response for patchFile function
69
+ mockPatchFile: (filePath, patch) => [
70
+ {
71
+ name: 'patchFile',
72
+ args: {
73
+ filePath,
74
+ patch,
75
+ },
76
+ },
77
+ ],
78
+ // Mock response for generateImage function
79
+ mockGenerateImage: (filePath, width = 256, height = 256) => [
80
+ {
81
+ name: 'generateImage',
82
+ args: {
83
+ prompt: 'A test image',
84
+ filePath,
85
+ width,
86
+ height,
87
+ },
88
+ },
89
+ ],
90
+ // Mock response for downloadFile function (used after image generation)
91
+ mockDownloadFile: (filePath, downloadUrl) => [
92
+ {
93
+ name: 'downloadFile',
94
+ args: {
95
+ filePath,
96
+ explanation: 'Downloading generated image',
97
+ downloadUrl,
98
+ },
99
+ },
100
+ ],
101
+ // Mock response for explanation function
102
+ mockExplanation: (text) => [
103
+ {
104
+ name: 'explanation',
105
+ args: {
106
+ text,
107
+ },
108
+ },
109
+ ],
110
+ };
111
+ /**
112
+ * Common mock data structures
113
+ */
114
+ export const mockData = {
115
+ // Mock image assets
116
+ imageAssets: {
117
+ '/path/to/image1.png': { width: 100, height: 100, mimeType: 'image/png' },
118
+ '/path/to/image2.jpg': { width: 200, height: 200, mimeType: 'image/jpeg' },
119
+ },
120
+ // Mock file content
121
+ fileContent: 'Original content',
122
+ // Mock base paths
123
+ paths: {
124
+ root: '/mocked/root/dir',
125
+ get test() {
126
+ return `${this.root}/test.js`;
127
+ },
128
+ get image() {
129
+ return `${this.root}/image.png`;
130
+ },
131
+ get context1() {
132
+ return `${this.root}/context1.js`;
133
+ },
134
+ get context2() {
135
+ return `${this.root}/context2.js`;
136
+ },
137
+ },
138
+ // Mock image generation URL
139
+ imageGenerationUrl: 'https://example.com/generated-image.png',
140
+ };
141
+ /**
142
+ * Common test configurations
143
+ */
144
+ export const testConfigs = {
145
+ // Base configuration for tests
146
+ baseConfig: {
147
+ askQuestion: false,
148
+ disableContextOptimization: true,
149
+ explicitPrompt: 'testx',
150
+ aiService: 'vertex-ai',
151
+ },
152
+ // Configuration with vision enabled
153
+ visionConfig: {
154
+ askQuestion: false,
155
+ disableContextOptimization: true,
156
+ explicitPrompt: 'testx',
157
+ aiService: 'chat-gpt',
158
+ vision: true,
159
+ },
160
+ // Configuration with imagen enabled
161
+ imagenConfig: {
162
+ askQuestion: false,
163
+ disableContextOptimization: true,
164
+ explicitPrompt: 'testx',
165
+ aiService: 'vertex-ai',
166
+ imagen: 'dall-e',
167
+ },
168
+ };
169
+ //# sourceMappingURL=prompt-service.test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-service.test-utils.js","sourceRoot":"","sources":["../../src/prompt/prompt-service.test-utils.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,6CAA6C;IAC7C,oBAAoB,EAAE,CAAC,QAAgB,EAAkB,EAAE,CAAC;QAC1D;YACE,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE;gBACJ,eAAe,EAAE,uBAAuB;gBACxC,WAAW,EAAE,wBAAwB;gBACrC,aAAa,EAAE;oBACb;wBACE,QAAQ;wBACR,MAAM,EAAE,8BAA8B;wBACtC,YAAY,EAAE,EAAE;qBACjB;iBACF;aACF;SACF;KACF;IAED,4CAA4C;IAC5C,kBAAkB,EAAE,CAAC,QAAgB,EAAE,iBAAyB,YAAY,EAAkB,EAAE,CAAC;QAC/F;YACE,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