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.
- package/README.md +0 -2
- package/dist/ai-service/ai-studio.js +7 -1
- package/dist/ai-service/ai-studio.js.map +1 -1
- package/dist/ai-service/anthropic.js +49 -19
- package/dist/ai-service/anthropic.js.map +1 -1
- package/dist/ai-service/chat-gpt.js +28 -11
- package/dist/ai-service/chat-gpt.js.map +1 -1
- package/dist/ai-service/common.d.ts +5 -4
- package/dist/ai-service/common.js +3 -4
- package/dist/ai-service/common.js.map +1 -1
- package/dist/ai-service/common.test.js +1 -1
- package/dist/ai-service/vertex-ai-claude.js +1 -1
- package/dist/ai-service/vertex-ai-claude.js.map +1 -1
- package/dist/ai-service/vertex-ai.js +7 -1
- package/dist/ai-service/vertex-ai.js.map +1 -1
- package/dist/cli/cli-options.js +0 -12
- package/dist/cli/cli-options.js.map +1 -1
- package/dist/cli/cli-params.d.ts +1 -4
- package/dist/cli/cli-params.js +1 -10
- package/dist/cli/cli-params.js.map +1 -1
- package/dist/cli/validate-cli-params.js +1 -7
- package/dist/cli/validate-cli-params.js.map +1 -1
- package/dist/cli/validate-cli-params.test.js +1 -1
- package/dist/cli/validate-cli-params.test.js.map +1 -1
- package/dist/eval/codegen-summary.test.d.ts +1 -0
- package/dist/eval/codegen-summary.test.js +93 -0
- package/dist/eval/codegen-summary.test.js.map +1 -0
- package/dist/eval/current-prompt-plugin.d.ts +3 -0
- package/dist/eval/current-prompt-plugin.js +10 -0
- package/dist/eval/current-prompt-plugin.js.map +1 -0
- package/dist/eval/data/current-prompt.d.ts +34 -0
- package/dist/eval/data/current-prompt.js +59 -0
- package/dist/eval/data/current-prompt.js.map +1 -0
- package/dist/eval/data/prompt-assistant-image.d.ts +49 -0
- package/dist/eval/data/prompt-assistant-image.js +67 -0
- package/dist/eval/data/prompt-assistant-image.js.map +1 -0
- package/dist/eval/data/prompt3.d.ts +34 -0
- package/dist/eval/data/prompt3.js +71 -0
- package/dist/eval/data/prompt3.js.map +1 -0
- package/dist/eval/prompt-debug.test.d.ts +1 -0
- package/dist/eval/prompt-debug.test.js +76 -0
- package/dist/eval/prompt-debug.test.js.map +1 -0
- package/dist/eval/prompt2.d.ts +34 -0
- package/dist/eval/prompt2.js +125 -0
- package/dist/eval/prompt2.js.map +1 -0
- package/dist/files/read-files.d.ts +29 -6
- package/dist/files/read-files.js +31 -10
- package/dist/files/read-files.js.map +1 -1
- package/dist/files/read-files.test.js +15 -9
- package/dist/files/read-files.test.js.map +1 -1
- package/dist/files/source-code-tree.d.ts +17 -0
- package/dist/files/source-code-tree.js +70 -0
- package/dist/files/source-code-tree.js.map +1 -0
- package/dist/main/codegen-types.d.ts +8 -5
- package/dist/main/codegen.ai-services.test.d.ts +3 -0
- package/dist/main/codegen.ai-services.test.js +198 -0
- package/dist/main/codegen.ai-services.test.js.map +1 -0
- package/dist/main/codegen.cli-options.test.d.ts +3 -0
- package/dist/main/codegen.cli-options.test.js +171 -0
- package/dist/main/codegen.cli-options.test.js.map +1 -0
- package/dist/main/codegen.image-generation.test.d.ts +3 -0
- package/dist/main/codegen.image-generation.test.js +187 -0
- package/dist/main/codegen.image-generation.test.js.map +1 -0
- package/dist/main/codegen.js +2 -5
- package/dist/main/codegen.js.map +1 -1
- package/dist/main/codegen.test-utils.d.ts +81 -0
- package/dist/main/codegen.test-utils.js +88 -0
- package/dist/main/codegen.test-utils.js.map +1 -0
- package/dist/main/codegen.test.js +47 -28
- package/dist/main/codegen.test.js.map +1 -1
- package/dist/main/common/content-bus-types.d.ts +6 -0
- package/dist/main/common/content-bus.d.ts +2 -2
- package/dist/main/common/content-bus.js +3 -1
- package/dist/main/common/content-bus.js.map +1 -1
- package/dist/main/common/user-actions.d.ts +8 -2
- package/dist/main/common/user-actions.js.map +1 -1
- package/dist/main/config-lib.js +20 -2
- package/dist/main/config-lib.js.map +1 -1
- package/dist/main/config.js +4 -28
- package/dist/main/config.js.map +1 -1
- package/dist/main/interactive/codegen-interactive.js +0 -4
- package/dist/main/interactive/codegen-interactive.js.map +1 -1
- package/dist/main/interactive/codegen-interactive.test.js +1 -7
- package/dist/main/interactive/codegen-interactive.test.js.map +1 -1
- package/dist/main/interactive/common.d.ts +1 -1
- package/dist/main/interactive/common.js +0 -2
- package/dist/main/interactive/common.js.map +1 -1
- package/dist/main/interactive/configure.js +0 -2
- package/dist/main/interactive/configure.js.map +1 -1
- package/dist/main/interactive/help.js +0 -2
- package/dist/main/interactive/help.js.map +1 -1
- package/dist/main/interactive/task-file.js +1 -1
- package/dist/main/interactive/task-file.js.map +1 -1
- package/dist/main/interactive/text-prompt.js +1 -1
- package/dist/main/interactive/text-prompt.js.map +1 -1
- package/dist/main/interactive/user-action-handlers.js +4 -2
- package/dist/main/interactive/user-action-handlers.js.map +1 -1
- package/dist/main/plugin-loader.d.ts +7 -1
- package/dist/main/plugin-loader.js +61 -0
- package/dist/main/plugin-loader.js.map +1 -1
- package/dist/main/ui/backend/api.js +9 -3
- package/dist/main/ui/backend/api.js.map +1 -1
- package/dist/main/ui/backend/service.d.ts +2 -1
- package/dist/main/ui/backend/service.js +6 -3
- package/dist/main/ui/backend/service.js.map +1 -1
- package/dist/main/ui/frontend/assets/index-QOcNx5ac.js +812 -0
- package/dist/main/ui/frontend/index.html +1 -1
- package/dist/main/ui/user-action-handlers.js +1 -1
- package/dist/main/ui/user-action-handlers.js.map +1 -1
- package/dist/project-profiles/detection.d.ts +40 -0
- package/dist/project-profiles/detection.js +131 -0
- package/dist/project-profiles/detection.js.map +1 -0
- package/dist/project-profiles/index.d.ts +35 -0
- package/dist/project-profiles/index.js +72 -0
- package/dist/project-profiles/index.js.map +1 -0
- package/dist/project-profiles/profiles/golang.d.ts +65 -0
- package/dist/project-profiles/profiles/golang.js +208 -0
- package/dist/project-profiles/profiles/golang.js.map +1 -0
- package/dist/project-profiles/profiles/java-maven.d.ts +80 -0
- package/dist/project-profiles/profiles/java-maven.js +165 -0
- package/dist/project-profiles/profiles/java-maven.js.map +1 -0
- package/dist/project-profiles/profiles/javascript-npm.d.ts +40 -0
- package/dist/project-profiles/profiles/javascript-npm.js +118 -0
- package/dist/project-profiles/profiles/javascript-npm.js.map +1 -0
- package/dist/project-profiles/profiles/javascript-react.d.ts +46 -0
- package/dist/project-profiles/profiles/javascript-react.js +147 -0
- package/dist/project-profiles/profiles/javascript-react.js.map +1 -0
- package/dist/project-profiles/profiles/python-django.d.ts +58 -0
- package/dist/project-profiles/profiles/python-django.js +200 -0
- package/dist/project-profiles/profiles/python-django.js.map +1 -0
- package/dist/project-profiles/types.d.ts +122 -0
- package/dist/project-profiles/types.js +77 -0
- package/dist/project-profiles/types.js.map +1 -0
- package/dist/prompt/function-calling.js +8 -3
- package/dist/prompt/function-calling.js.map +1 -1
- package/dist/prompt/function-defs/ask-question.d.ts +5 -0
- package/dist/prompt/function-defs/ask-question.js +140 -60
- package/dist/prompt/function-defs/ask-question.js.map +1 -1
- package/dist/prompt/function-defs/codegen-planning.d.ts +8 -0
- package/dist/prompt/function-defs/codegen-planning.js +50 -0
- package/dist/prompt/function-defs/codegen-planning.js.map +1 -0
- package/dist/prompt/function-defs/codegen-summary.js +2 -2
- package/dist/prompt/function-defs/codegen-summary.js.map +1 -1
- package/dist/prompt/function-defs/get-source-code.js +32 -2
- package/dist/prompt/function-defs/get-source-code.js.map +1 -1
- package/dist/prompt/function-defs/optimize-context.js +35 -12
- package/dist/prompt/function-defs/optimize-context.js.map +1 -1
- package/dist/prompt/function-defs/set-summaries.js +20 -1
- package/dist/prompt/function-defs/set-summaries.js.map +1 -1
- package/dist/prompt/limits.js +2 -2
- package/dist/prompt/limits.js.map +1 -1
- package/dist/prompt/limits.test.js +3 -3
- package/dist/prompt/limits.test.js.map +1 -1
- package/dist/prompt/prompt-codegen.js +7 -79
- package/dist/prompt/prompt-codegen.js.map +1 -1
- package/dist/prompt/prompt-codegen.test.js +8 -14
- package/dist/prompt/prompt-codegen.test.js.map +1 -1
- package/dist/prompt/prompt-service-ask-question.test.js +27 -80
- package/dist/prompt/prompt-service-ask-question.test.js.map +1 -1
- package/dist/prompt/prompt-service.ai-services.test.d.ts +1 -0
- package/dist/prompt/prompt-service.ai-services.test.js +149 -0
- package/dist/prompt/prompt-service.ai-services.test.js.map +1 -0
- package/dist/prompt/prompt-service.context-optimization.test.d.ts +1 -0
- package/dist/prompt/prompt-service.context-optimization.test.js +212 -0
- package/dist/prompt/prompt-service.context-optimization.test.js.map +1 -0
- package/dist/prompt/prompt-service.image-handling.test.d.ts +1 -0
- package/dist/prompt/prompt-service.image-handling.test.js +212 -0
- package/dist/prompt/prompt-service.image-handling.test.js.map +1 -0
- package/dist/prompt/prompt-service.js +41 -127
- package/dist/prompt/prompt-service.js.map +1 -1
- package/dist/prompt/prompt-service.test-utils.d.ts +66 -0
- package/dist/prompt/prompt-service.test-utils.js +169 -0
- package/dist/prompt/prompt-service.test-utils.js.map +1 -0
- package/dist/prompt/prompt-service.test.js +96 -20
- package/dist/prompt/prompt-service.test.js.map +1 -1
- package/dist/prompt/prompt-service.validation-recovery.test.d.ts +1 -0
- package/dist/prompt/prompt-service.validation-recovery.test.js +263 -0
- package/dist/prompt/prompt-service.validation-recovery.test.js.map +1 -0
- package/dist/prompt/static-prompts.d.ts +16 -0
- package/dist/prompt/static-prompts.js +22 -0
- package/dist/prompt/static-prompts.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js +1 -3
- package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/code-generation.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/code-generation.js +58 -0
- package/dist/prompt/steps/step-ask-question/handlers/code-generation.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.js +8 -7
- package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js +6 -6
- package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/default-action.js +1 -4
- package/dist/prompt/steps/step-ask-question/handlers/default-action.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.js +86 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.js +97 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js +20 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handler-utils.d.ts +0 -0
- package/dist/prompt/steps/step-ask-question/handlers/handler-utils.js +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handler-utils.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.js +57 -15
- package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/request-files-content.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js +109 -12
- package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/request-permissions.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/request-permissions.js +48 -26
- package/dist/prompt/steps/step-ask-question/handlers/request-permissions.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.js +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.js +1 -0
- package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/step-ask-question-types.d.ts +25 -21
- package/dist/prompt/steps/step-ask-question/step-ask-question.d.ts +2 -5
- package/dist/prompt/steps/step-ask-question/step-ask-question.js +36 -33
- package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -1
- package/dist/prompt/steps/step-codegen-planning.d.ts +10 -0
- package/dist/prompt/steps/step-codegen-planning.js +69 -0
- package/dist/prompt/steps/step-codegen-planning.js.map +1 -0
- package/dist/prompt/steps/step-codegen-summary.d.ts +7 -0
- package/dist/prompt/steps/step-codegen-summary.js +106 -0
- package/dist/prompt/steps/step-codegen-summary.js.map +1 -0
- package/dist/prompt/steps/step-codegen-summary.test.d.ts +1 -0
- package/dist/prompt/steps/step-codegen-summary.test.js +136 -0
- package/dist/prompt/steps/step-codegen-summary.test.js.map +1 -0
- package/dist/prompt/steps/step-context-optimization.js +243 -126
- package/dist/prompt/steps/step-context-optimization.js.map +1 -1
- package/dist/prompt/steps/step-context-optimization.test.d.ts +2 -0
- package/dist/prompt/steps/step-context-optimization.test.js +475 -0
- package/dist/prompt/steps/step-context-optimization.test.js.map +1 -0
- package/dist/prompt/steps/step-ensure-context.d.ts +15 -0
- package/dist/prompt/steps/step-ensure-context.js +102 -0
- package/dist/prompt/steps/step-ensure-context.js.map +1 -0
- package/dist/prompt/steps/step-ensure-context.test.d.ts +1 -0
- package/dist/prompt/steps/step-ensure-context.test.js +242 -0
- package/dist/prompt/steps/step-ensure-context.test.js.map +1 -0
- package/dist/prompt/steps/step-generate-image.d.ts +8 -1
- package/dist/prompt/steps/step-generate-image.js +1 -0
- package/dist/prompt/steps/step-generate-image.js.map +1 -1
- package/dist/prompt/steps/step-summarization.d.ts +2 -2
- package/dist/prompt/steps/step-summarization.js +45 -9
- package/dist/prompt/steps/step-summarization.js.map +1 -1
- package/dist/prompt/steps/step-validate-recover.js +24 -15
- package/dist/prompt/steps/step-validate-recover.js.map +1 -1
- package/dist/prompt/steps/steps-types.d.ts +2 -0
- package/dist/prompt/steps/steps-types.js.map +1 -1
- package/dist/prompt/systemprompt.d.ts +2 -2
- package/dist/prompt/systemprompt.js +74 -176
- package/dist/prompt/systemprompt.js.map +1 -1
- package/dist/prompt/systemprompt.test.js +4 -5
- package/dist/prompt/systemprompt.test.js.map +1 -1
- package/dist/vite-genaicode/vite-genaicode-plugin.js +0 -2
- package/dist/vite-genaicode/vite-genaicode-plugin.js.map +1 -1
- package/package.json +6 -2
- package/dist/main/ui/frontend/assets/index-Dk_qaEQg.js +0 -782
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-files-from-context.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/remove-files-from-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"remove-files-from-context.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/remove-files-from-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,EACjD,eAAe,EACf,iBAAiB,EACjB,MAAM,EACN,OAAO,GACY;IACnB,MAAM,CAAC,0BAA0B,CAAC,GAAG,CAAC,MAAM,iBAAiB,CAC3D;QACE,GAAG,MAAM;QACT;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;SAC1C;QACD;YACE,IAAI,EAAE,MAAM;Y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CAAC;YACrF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
|
|
2
|
-
export declare function handleRequestFilesContent({ askQuestionCall, options, }: ActionHandlerProps): Promise<ActionResult>;
|
|
2
|
+
export declare function handleRequestFilesContent({ askQuestionCall, options, prompt, generateContentFn, }: ActionHandlerProps): Promise<ActionResult>;
|
|
@@ -1,25 +1,108 @@
|
|
|
1
1
|
import { getSourceFiles, refreshFiles } from '../../../../files/find-files.js';
|
|
2
2
|
import { getSourceCode } from '../../../../files/read-files.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { getSourceCodeTree } from '../../../../files/source-code-tree.js';
|
|
4
|
+
import { getFunctionDefs } from '../../../function-calling.js';
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a file's content is already provided in the conversation history
|
|
7
|
+
* @param filePath The path of the file to check
|
|
8
|
+
* @param prompt The conversation history
|
|
9
|
+
* @returns true if the file content is already available in the history
|
|
10
|
+
*/
|
|
11
|
+
function isFileContentAlreadyProvided(filePath, prompt) {
|
|
12
|
+
return prompt.some((item) => {
|
|
13
|
+
if (item.type !== 'user' || !item.functionResponses) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return item.functionResponses.some((response) => {
|
|
17
|
+
if (response.name !== 'getSourceCode' || !response.content) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const sourceCodeTree = JSON.parse(response.content);
|
|
22
|
+
const dirPath = filePath.substring(0, filePath.lastIndexOf('/'));
|
|
23
|
+
const fileName = filePath.substring(filePath.lastIndexOf('/') + 1);
|
|
24
|
+
return (sourceCodeTree[dirPath] && sourceCodeTree[dirPath][fileName] && 'content' in sourceCodeTree[dirPath][fileName]);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.warn('Error parsing getSourceCode response:', error);
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export async function handleRequestFilesContent({ askQuestionCall, options, prompt, generateContentFn, }) {
|
|
34
|
+
let requestFilesContentCall = await generateRequestFilesContentCall(generateContentFn, prompt, askQuestionCall, options, false);
|
|
35
|
+
if (!requestFilesContentCall) {
|
|
36
|
+
return {
|
|
37
|
+
breakLoop: true,
|
|
38
|
+
items: [],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
let requestedFiles = requestFilesContentCall.args?.filePaths ?? [];
|
|
42
|
+
// Check which files are already provided in the conversation history
|
|
43
|
+
const alreadyProvidedFiles = requestedFiles.filter((file) => isFileContentAlreadyProvided(file, prompt));
|
|
44
|
+
if (alreadyProvidedFiles.length === requestedFiles.length) {
|
|
45
|
+
// All requested files are already provided
|
|
46
|
+
const assistant = {
|
|
47
|
+
type: 'assistant',
|
|
48
|
+
text: askQuestionCall.args?.message ?? '',
|
|
49
|
+
functionCalls: [requestFilesContentCall],
|
|
50
|
+
};
|
|
51
|
+
const user = {
|
|
52
|
+
type: 'user',
|
|
53
|
+
text: 'The requested file contents are already provided in the conversation history.',
|
|
54
|
+
functionResponses: [
|
|
55
|
+
{
|
|
56
|
+
name: 'requestFilesContent',
|
|
57
|
+
call_id: requestFilesContentCall.id,
|
|
58
|
+
content: JSON.stringify({ filePaths: requestedFiles }),
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
cache: true,
|
|
62
|
+
};
|
|
63
|
+
return { breakLoop: false, items: [{ assistant, user }] };
|
|
64
|
+
}
|
|
65
|
+
// Filter out already provided files
|
|
66
|
+
requestedFiles = requestedFiles.filter((file) => !isFileContentAlreadyProvided(file, prompt));
|
|
6
67
|
// the request may be caused be an appearance of a new file, so lets refresh
|
|
7
68
|
refreshFiles();
|
|
8
|
-
|
|
9
|
-
|
|
69
|
+
let { legitimateFiles, illegitimateFiles } = categorizeLegitimateFiles(requestedFiles);
|
|
70
|
+
if (illegitimateFiles.length > 0) {
|
|
71
|
+
requestFilesContentCall = await generateRequestFilesContentCall(generateContentFn, prompt, askQuestionCall, options, false);
|
|
72
|
+
if (!requestFilesContentCall) {
|
|
73
|
+
return {
|
|
74
|
+
breakLoop: true,
|
|
75
|
+
items: [],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
requestedFiles = requestFilesContentCall.args?.filePaths ?? [];
|
|
79
|
+
const categorized = categorizeLegitimateFiles(requestedFiles);
|
|
80
|
+
legitimateFiles = categorized.legitimateFiles;
|
|
81
|
+
illegitimateFiles = categorized.illegitimateFiles;
|
|
82
|
+
}
|
|
83
|
+
const sourceCallId = (askQuestionCall.id ?? askQuestionCall.name) + '_source';
|
|
10
84
|
const assistant = {
|
|
11
85
|
type: 'assistant',
|
|
12
|
-
text: askQuestionCall.args?.
|
|
13
|
-
functionCalls: [
|
|
86
|
+
text: askQuestionCall.args?.message ?? '',
|
|
87
|
+
functionCalls: [
|
|
88
|
+
requestFilesContentCall,
|
|
89
|
+
{ name: 'getSourceCode', id: sourceCallId, args: { filePaths: legitimateFiles } },
|
|
90
|
+
],
|
|
14
91
|
};
|
|
15
|
-
const sourceCode = getSourceCode({ filterPaths: legitimateFiles, forceAll: true }, options);
|
|
92
|
+
const sourceCode = getSourceCodeTree(getSourceCode({ filterPaths: legitimateFiles, forceAll: true, ignoreImportantFiles: true }, options));
|
|
16
93
|
const user = {
|
|
17
94
|
type: 'user',
|
|
18
95
|
text: illegitimateFiles.length > 0
|
|
19
|
-
?
|
|
20
|
-
:
|
|
96
|
+
? `Some files are not legitimate and their content cannot be provided:\n\n${illegitimateFiles.join('\n')}`
|
|
97
|
+
: alreadyProvidedFiles.length > 0
|
|
98
|
+
? `Some files were already provided in the conversation history:\n${alreadyProvidedFiles.join('\n')}\n\nProviding content for the remaining files.`
|
|
99
|
+
: 'All requested file contents have been provided.',
|
|
21
100
|
functionResponses: [
|
|
22
|
-
{
|
|
101
|
+
{
|
|
102
|
+
name: 'requestFilesContent',
|
|
103
|
+
call_id: requestFilesContentCall.id,
|
|
104
|
+
content: JSON.stringify({ filePaths: requestedFiles }),
|
|
105
|
+
},
|
|
23
106
|
{
|
|
24
107
|
name: 'getSourceCode',
|
|
25
108
|
call_id: sourceCallId,
|
|
@@ -28,7 +111,21 @@ export async function handleRequestFilesContent({ askQuestionCall, options, }) {
|
|
|
28
111
|
],
|
|
29
112
|
cache: true,
|
|
30
113
|
};
|
|
31
|
-
return { breakLoop: false,
|
|
114
|
+
return { breakLoop: false, items: [{ assistant, user }] };
|
|
115
|
+
}
|
|
116
|
+
async function generateRequestFilesContentCall(generateContentFn, prompt, askQuestionCall, options, cheap) {
|
|
117
|
+
const [requestFilesContentCall] = (await generateContentFn([
|
|
118
|
+
...prompt,
|
|
119
|
+
{
|
|
120
|
+
type: 'assistant',
|
|
121
|
+
text: askQuestionCall.args?.message ?? '',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
type: 'user',
|
|
125
|
+
text: 'Yes, you can request the files contents.',
|
|
126
|
+
},
|
|
127
|
+
], getFunctionDefs(), 'requestFilesContent', 0.7, cheap, options));
|
|
128
|
+
return requestFilesContentCall;
|
|
32
129
|
}
|
|
33
130
|
function categorizeLegitimateFiles(requestedFiles) {
|
|
34
131
|
const legitimateFiles = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-files-content.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/request-files-content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request-files-content.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/request-files-content.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,i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;SACjD;KACF,EACD,eAAe,EAAE,EACjB,qBAAqB,EACrB,GAAG,EACH,KAAK,EACL,OAAO,CACR,CAAwD,CAAC;IAE1D,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAED,SAAS,yBAAyB,CAAC,cAAwB;IAIzD,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,iBAAiB,GAAa,EAAE,CAAC;IAEvC,cAAc,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAClC,IAAI,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,OAAO,cAAc,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
|
|
2
|
-
export declare function handleRequestPermissions({ askQuestionCall, options, }: ActionHandlerProps): Promise<ActionResult>;
|
|
2
|
+
export declare function handleRequestPermissions({ askQuestionCall, options, prompt, generateContentFn, }: ActionHandlerProps): Promise<ActionResult>;
|
|
@@ -1,46 +1,68 @@
|
|
|
1
1
|
import { askUserForConfirmation } from '../../../../main/common/user-actions.js';
|
|
2
|
-
import {
|
|
3
|
-
export async function handleRequestPermissions({ askQuestionCall, options, }) {
|
|
2
|
+
import { getFunctionDefs } from '../../../function-calling.js';
|
|
3
|
+
export async function handleRequestPermissions({ askQuestionCall, options, prompt, generateContentFn, }) {
|
|
4
|
+
const [requestPermissionsCall] = (await generateContentFn([
|
|
5
|
+
...prompt,
|
|
6
|
+
{
|
|
7
|
+
type: 'assistant',
|
|
8
|
+
text: askQuestionCall.args?.message ?? '',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
type: 'user',
|
|
12
|
+
text: 'Yes, you can request the permissions.',
|
|
13
|
+
},
|
|
14
|
+
], getFunctionDefs(), 'requestPermissions', 0.7, true, options));
|
|
15
|
+
if (!requestPermissionsCall) {
|
|
16
|
+
return {
|
|
17
|
+
breakLoop: true,
|
|
18
|
+
items: [],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
4
21
|
const userConfirmation = await askUserForConfirmation('The assistant is requesting additional permissions. Do you want to grant them?', false);
|
|
5
22
|
const user = {
|
|
6
23
|
type: 'user',
|
|
7
24
|
text: userConfirmation ? 'Permissions granted.' : 'Permission request denied.',
|
|
8
|
-
functionResponses: [
|
|
25
|
+
functionResponses: [
|
|
26
|
+
{
|
|
27
|
+
name: 'requestPermissions',
|
|
28
|
+
call_id: requestPermissionsCall.id,
|
|
29
|
+
content: JSON.stringify({ confirmed: userConfirmation.confirmed }),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
9
32
|
};
|
|
10
|
-
if (userConfirmation) {
|
|
11
|
-
updatePermissions(
|
|
33
|
+
if (userConfirmation.confirmed) {
|
|
34
|
+
updatePermissions(requestPermissionsCall, options);
|
|
12
35
|
}
|
|
13
36
|
return {
|
|
14
37
|
breakLoop: false,
|
|
15
|
-
stepResult: StepResult.CONTINUE,
|
|
16
38
|
items: [
|
|
17
39
|
{
|
|
18
|
-
assistant: {
|
|
40
|
+
assistant: {
|
|
41
|
+
type: 'assistant',
|
|
42
|
+
text: askQuestionCall.args?.message ?? '',
|
|
43
|
+
functionCalls: [requestPermissionsCall],
|
|
44
|
+
},
|
|
19
45
|
user,
|
|
20
46
|
},
|
|
21
47
|
],
|
|
22
48
|
};
|
|
23
49
|
}
|
|
24
|
-
function updatePermissions(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
'
|
|
28
|
-
|
|
29
|
-
if (permissions && typeof permissions === 'object') {
|
|
30
|
-
if ('enableImagen' in permissions && permissions.enableImagen) {
|
|
31
|
-
options.imagen = options.aiService === 'chat-gpt' ? 'dall-e' : 'vertex-ai';
|
|
32
|
-
}
|
|
33
|
-
if ('enableVision' in permissions && permissions.enableVision)
|
|
34
|
-
options.vision = true;
|
|
35
|
-
if ('allowDirectoryCreate' in permissions && permissions.allowDirectoryCreate)
|
|
36
|
-
options.allowDirectoryCreate = true;
|
|
37
|
-
if ('allowFileCreate' in permissions && permissions.allowFileCreate)
|
|
38
|
-
options.allowFileCreate = true;
|
|
39
|
-
if ('allowFileDelete' in permissions && permissions.allowFileDelete)
|
|
40
|
-
options.allowFileDelete = true;
|
|
41
|
-
if ('allowFileMove' in permissions && permissions.allowFileMove)
|
|
42
|
-
options.allowFileMove = true;
|
|
50
|
+
function updatePermissions(requestPermissionsCall, options) {
|
|
51
|
+
const permissions = requestPermissionsCall.args;
|
|
52
|
+
if (permissions) {
|
|
53
|
+
if ('enableImagen' in permissions && permissions.enableImagen) {
|
|
54
|
+
options.imagen = options.aiService === 'chat-gpt' ? 'dall-e' : 'vertex-ai';
|
|
43
55
|
}
|
|
56
|
+
if ('enableVision' in permissions && permissions.enableVision)
|
|
57
|
+
options.vision = true;
|
|
58
|
+
if ('allowDirectoryCreate' in permissions && permissions.allowDirectoryCreate)
|
|
59
|
+
options.allowDirectoryCreate = true;
|
|
60
|
+
if ('allowFileCreate' in permissions && permissions.allowFileCreate)
|
|
61
|
+
options.allowFileCreate = true;
|
|
62
|
+
if ('allowFileDelete' in permissions && permissions.allowFileDelete)
|
|
63
|
+
options.allowFileDelete = true;
|
|
64
|
+
if ('allowFileMove' in permissions && permissions.allowFileMove)
|
|
65
|
+
options.allowFileMove = true;
|
|
44
66
|
}
|
|
45
67
|
}
|
|
46
68
|
//# sourceMappingURL=request-permissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-permissions.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/request-permissions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request-permissions.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/request-permissions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,EAC7C,eAAe,EACf,OAAO,EACP,MAAM,EACN,iBAAiB,GACE;IACnB,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,MAAM,iBAAiB,CACvD;QACE,GAAG,MAAM;QACT;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;SAC1C;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,uCAAuC;SAC9C;KACF,EACD,eAAe,EAAE,EACjB,oBAAoB,EACpB,GAAG,EACH,IAAI,EACJ,OAAO,CACR,CAAuD,CAAC;IAEzD,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC5B,OAAO;YACL,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,sBAAsB,CACnD,gFAAgF,EAChF,KAAK,CACN,CAAC;IAEF,MAAM,IAAI,GAAa;QACrB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,4BAA4B;QAC9E,iBAAiB,EAAE;YACjB;gBACE,IAAI,EAAE,oBAAoB;gBAC1B,OAAO,EAAE,sBAAsB,CAAC,EAAE;gBAClC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,gBAAgB,CAAC,SAAS,EAAE,CAAC;aACnE;SACF;KACF,CAAC;IAEF,IAAI,gBAAgB,CAAC,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{
|
|
|
7
7
|
stepResult: StepResult.CONTINUE,
|
|
8
8
|
items: [
|
|
9
9
|
{
|
|
10
|
-
assistant: { type: 'assistant', text: askQuestionCall.args?.
|
|
10
|
+
assistant: { type: 'assistant', text: askQuestionCall.args?.message ?? '' },
|
|
11
11
|
user: { type: 'user', text: 'Proceeding with code generation.' },
|
|
12
12
|
},
|
|
13
13
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-code-generation.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/start-code-generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAAE,eAAe,EAAsB;IACrF,gBAAgB,CAAC,kCAAkC,CAAC,CAAC;IACrD,OAAO;QACL,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,UAAU,CAAC,QAAQ;QAC/B,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE
|
|
1
|
+
{"version":3,"file":"start-code-generation.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/start-code-generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAAE,eAAe,EAAsB;IACrF,gBAAgB,CAAC,kCAAkC,CAAC,CAAC;IACrD,OAAO;QACL,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,UAAU,CAAC,QAAQ;QAC/B,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE;gBAC3E,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kCAAkC,EAAE;aACjE;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -19,6 +19,7 @@ Common problems/pitfalls:
|
|
|
19
19
|
- Saying that an analysis will be done, instead of actually doing the analysis
|
|
20
20
|
- The response is too similar to a previous question or response
|
|
21
21
|
- The assistant takes on the user's voice or persona instead of maintaining its own identity
|
|
22
|
+
- The assistant is using invalid actionType values, for example when requesting files contents not using requestFilesContent action types
|
|
22
23
|
|
|
23
24
|
Specific examples of problematic responses:
|
|
24
25
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-ask-question-reflect.js","sourceRoot":"","sources":["../../../../src/prompt/steps/step-ask-question/step-ask-question-reflect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAG7E,MAAM,mBAAmB,GAAG
|
|
1
|
+
{"version":3,"file":"step-ask-question-reflect.js","sourceRoot":"","sources":["../../../../src/prompt/steps/step-ask-question/step-ask-question-reflect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAG7E,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0WAwC8U,CAAC;AAE3W,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,eAAgC,EAChC,OAA8B,EAC9B,MAAoB,EACpB,YAA2B,EAC3B,OAAuB,EACvB,iBAA0C;IAE1C,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC;QACnC,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,MAAM,EAAE,oDAAoD;SAC7D,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;I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E,cAAqC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;IAC5F,MAAM,MAAM,GAAI,gBAAgB,EAAE,MAAiB,IAAI,EAAE,CAAC;IAE1D,OAAO;QACL,cAAc;QACd,MAAM,EACJ,MAAM;YACN,CAAC,cAAc;gBACb,CAAC,CAAC,uDAAuD;gBACzD,CAAC,CAAC,sCAAsC,CAAC;KAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -1,20 +1,31 @@
|
|
|
1
|
-
import { FunctionCall, GenerateContentFunction, PromptItem } from '../../../ai-service/common.js';
|
|
1
|
+
import { FunctionCall, GenerateContentFunction, GenerateImageFunction, PromptItem, PromptItemImage } from '../../../ai-service/common.js';
|
|
2
2
|
import { CodegenOptions } from '../../../main/codegen-types.js';
|
|
3
|
-
import { StepResult } from '../steps-types.js';
|
|
4
3
|
import { PluginActionType } from '../../../main/codegen-types.js';
|
|
5
|
-
export type ActionType = '
|
|
4
|
+
export type ActionType = 'codeGeneration' | 'sendMessage' | 'sendMessageWithImage' | 'requestPermissions' | 'requestFilesContent' | 'removeFilesFromContext' | 'confirmCodeGeneration' | 'cancelCodeGeneration' | 'contextOptimization' | PluginActionType;
|
|
6
5
|
type AskQuestionArgs = {
|
|
7
6
|
actionType: ActionType;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
export type SendMessageWithImageArgs = {
|
|
10
|
+
prompt: string;
|
|
11
|
+
contextImage?: string;
|
|
12
|
+
};
|
|
13
|
+
export type RequestPermissionsArgs = Record<'allowDirectoryCreate' | 'allowFileCreate' | 'allowFileDelete' | 'allowFileMove' | 'enableVision' | 'enableImagen', boolean>;
|
|
14
|
+
export type RequestFilesContentArgs = {
|
|
15
|
+
filePaths: string[];
|
|
16
|
+
};
|
|
17
|
+
export type RemoveFilesFromContextArgs = {
|
|
18
|
+
filePaths: string[];
|
|
19
|
+
};
|
|
20
|
+
export type ContextOptimizationArgs = {
|
|
21
|
+
filePaths: string[];
|
|
12
22
|
};
|
|
13
23
|
export type AskQuestionCall = FunctionCall<AskQuestionArgs>;
|
|
14
24
|
export interface AssistantItem {
|
|
15
25
|
type: 'assistant';
|
|
16
26
|
text: string;
|
|
17
|
-
functionCalls
|
|
27
|
+
functionCalls?: FunctionCall[];
|
|
28
|
+
images?: PromptItemImage[];
|
|
18
29
|
cache?: true;
|
|
19
30
|
}
|
|
20
31
|
export interface UserItem {
|
|
@@ -22,14 +33,16 @@ export interface UserItem {
|
|
|
22
33
|
text: string;
|
|
23
34
|
functionResponses?: Array<{
|
|
24
35
|
name: string;
|
|
25
|
-
call_id: string;
|
|
36
|
+
call_id: string | undefined;
|
|
26
37
|
content: string | undefined;
|
|
27
38
|
}>;
|
|
39
|
+
images?: PromptItemImage[];
|
|
28
40
|
cache?: true;
|
|
29
41
|
}
|
|
30
42
|
export interface ActionResult {
|
|
31
43
|
breakLoop: boolean;
|
|
32
|
-
|
|
44
|
+
executeCodegen?: boolean;
|
|
45
|
+
stepResult?: FunctionCall[];
|
|
33
46
|
items: Array<{
|
|
34
47
|
assistant: AssistantItem;
|
|
35
48
|
user: UserItem;
|
|
@@ -40,17 +53,8 @@ export type ActionHandlerProps = {
|
|
|
40
53
|
prompt: PromptItem[];
|
|
41
54
|
options: CodegenOptions;
|
|
42
55
|
generateContentFn: GenerateContentFunction;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
56
|
+
generateImageFn: GenerateImageFunction;
|
|
57
|
+
waitIfPaused: () => Promise<void>;
|
|
46
58
|
};
|
|
47
59
|
export type ActionHandler = (props: ActionHandlerProps) => Promise<ActionResult>;
|
|
48
|
-
export interface EscalationDecision {
|
|
49
|
-
shouldEscalate: boolean;
|
|
50
|
-
reason: string;
|
|
51
|
-
}
|
|
52
|
-
export interface SelfReflectionContext {
|
|
53
|
-
escalationCount: number;
|
|
54
|
-
lastEscalationTime: number;
|
|
55
|
-
}
|
|
56
60
|
export {};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { FunctionDef, GenerateContentFunction, PromptItem } from '../../../ai-service/common.js';
|
|
2
|
-
import { StepResult } from '../steps-types.js';
|
|
1
|
+
import { FunctionDef, GenerateContentFunction, PromptItem, GenerateImageFunction, FunctionCall } from '../../../ai-service/common.js';
|
|
3
2
|
import { CodegenOptions } from '../../../main/codegen-types.js';
|
|
4
|
-
export declare function executeStepAskQuestion(generateContentFn: GenerateContentFunction, prompt: PromptItem[], functionDefs: FunctionDef[], temperature: number,
|
|
5
|
-
contextSourceCode: (paths: string[], pathsOnly: boolean) => string;
|
|
6
|
-
}, options: CodegenOptions): Promise<StepResult>;
|
|
3
|
+
export declare function executeStepAskQuestion(generateContentFn: GenerateContentFunction, generateImageFn: GenerateImageFunction, prompt: PromptItem[], functionDefs: FunctionDef[], waitIfPaused: () => Promise<void>, temperature: number, options: CodegenOptions): Promise<FunctionCall[]>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { StepResult } from '../steps-types.js';
|
|
2
1
|
import { putAssistantMessage, putSystemMessage, putUserMessage } from '../../../main/common/content-bus.js';
|
|
3
2
|
import { abortController } from '../../../main/interactive/codegen-worker.js';
|
|
4
3
|
import { validateAndRecoverSingleResult } from '../step-validate-recover.js';
|
|
@@ -7,38 +6,53 @@ import { handleContextOptimization } from './handlers/context-optimization.js';
|
|
|
7
6
|
import { handleRemoveFilesFromContext } from './handlers/remove-files-from-context.js';
|
|
8
7
|
import { handleRequestPermissions } from './handlers/request-permissions.js';
|
|
9
8
|
import { handleDefaultAction } from './handlers/default-action.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { handleSendMessage } from './handlers/handle-send-message.js';
|
|
10
|
+
import { handleSendMessageWithImage } from './handlers/handle-send-message-with-image.js';
|
|
12
11
|
import { handleConfirmCodeGeneration } from './handlers/confirm-code-generation.js';
|
|
13
12
|
import { handleCancelCodeGeneration } from './handlers/cancel-code-generation.js';
|
|
14
13
|
import { getRegisteredActionHandlers } from '../../../main/plugin-loader.js';
|
|
15
|
-
import {
|
|
16
|
-
export async function executeStepAskQuestion(generateContentFn, prompt, functionDefs,
|
|
14
|
+
import { handleCodeGeneration } from './handlers/code-generation.js';
|
|
15
|
+
export async function executeStepAskQuestion(generateContentFn, generateImageFn, prompt, functionDefs, waitIfPaused, temperature, options) {
|
|
17
16
|
console.log('Allowing the assistant to ask a question...');
|
|
18
|
-
const selfReflectionContext = {
|
|
19
|
-
escalationCount: 0,
|
|
20
|
-
lastEscalationTime: 0,
|
|
21
|
-
};
|
|
22
17
|
while (!abortController?.signal.aborted) {
|
|
23
18
|
try {
|
|
24
|
-
const askQuestionCall = await getAskQuestionCall(generateContentFn, prompt, functionDefs, temperature, options
|
|
19
|
+
const askQuestionCall = await getAskQuestionCall(generateContentFn, prompt, functionDefs, temperature, options);
|
|
25
20
|
if (!askQuestionCall) {
|
|
26
21
|
break;
|
|
27
22
|
}
|
|
28
23
|
console.log('Assistant asks:', askQuestionCall.args);
|
|
29
|
-
if (askQuestionCall.args?.
|
|
30
|
-
putAssistantMessage(askQuestionCall.args.
|
|
24
|
+
if (askQuestionCall.args?.message) {
|
|
25
|
+
putAssistantMessage(askQuestionCall.args.message, askQuestionCall.args);
|
|
31
26
|
}
|
|
32
27
|
const actionType = askQuestionCall.args?.actionType;
|
|
33
28
|
if (actionType) {
|
|
34
29
|
const actionHandler = getActionHandler(actionType);
|
|
35
|
-
|
|
30
|
+
let result = await actionHandler({
|
|
31
|
+
askQuestionCall,
|
|
32
|
+
prompt,
|
|
33
|
+
options,
|
|
34
|
+
generateContentFn,
|
|
35
|
+
generateImageFn,
|
|
36
|
+
waitIfPaused,
|
|
37
|
+
});
|
|
36
38
|
// This is important to display the content to the user interface (ui or interactive cli)
|
|
37
39
|
putUserMessage(result.items.slice(-1)[0].user.text);
|
|
40
|
+
prompt.push(...result.items.map(({ assistant, user }) => [assistant, user]).flat());
|
|
41
|
+
if (result.executeCodegen) {
|
|
42
|
+
result = await getActionHandler('codeGeneration')({
|
|
43
|
+
askQuestionCall,
|
|
44
|
+
prompt,
|
|
45
|
+
options,
|
|
46
|
+
generateContentFn,
|
|
47
|
+
generateImageFn,
|
|
48
|
+
waitIfPaused,
|
|
49
|
+
});
|
|
50
|
+
putUserMessage(result.items.slice(-1)[0].user.text);
|
|
51
|
+
prompt.push(...result.items.map(({ assistant, user }) => [assistant, user]).flat());
|
|
52
|
+
}
|
|
38
53
|
if (result.breakLoop) {
|
|
39
|
-
return result.stepResult;
|
|
54
|
+
return result.stepResult ?? [];
|
|
40
55
|
}
|
|
41
|
-
prompt.push(...result.items.map(({ assistant, user }) => [assistant, user]).flat());
|
|
42
56
|
console.log('The question was answered');
|
|
43
57
|
}
|
|
44
58
|
else {
|
|
@@ -49,29 +63,17 @@ export async function executeStepAskQuestion(generateContentFn, prompt, function
|
|
|
49
63
|
catch (error) {
|
|
50
64
|
console.error('Error in executeStepAskQuestion:', error);
|
|
51
65
|
putSystemMessage(`An error occurred: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
-
return
|
|
66
|
+
return [];
|
|
53
67
|
}
|
|
54
68
|
}
|
|
55
69
|
putSystemMessage('Assistant did not ask a question. This unexpected, we need to abort.');
|
|
56
|
-
return
|
|
70
|
+
return [];
|
|
57
71
|
}
|
|
58
|
-
async function getAskQuestionCall(generateContentFn, prompt, functionDefs, temperature, options
|
|
72
|
+
async function getAskQuestionCall(generateContentFn, prompt, functionDefs, temperature, options) {
|
|
59
73
|
const askQuestionRequest = [prompt, functionDefs, 'askQuestion', temperature, true, options];
|
|
60
74
|
let askQuestionResult = await generateContentFn(...askQuestionRequest);
|
|
61
75
|
askQuestionResult = await validateAndRecoverSingleResult(askQuestionRequest, askQuestionResult, generateContentFn);
|
|
62
|
-
|
|
63
|
-
if (cheapModelResponse) {
|
|
64
|
-
const escalationDecision = await performSelfReflection(cheapModelResponse, selfReflectionContext, prompt, functionDefs, options, generateContentFn);
|
|
65
|
-
if (escalationDecision.shouldEscalate) {
|
|
66
|
-
console.log('Self-reflection suggests escalating to non-cheap model.');
|
|
67
|
-
// Re-run with non-cheap model
|
|
68
|
-
const nonCheapRequest = [prompt, functionDefs, 'askQuestion', temperature, false, options];
|
|
69
|
-
let nonCheapResult = await generateContentFn(...nonCheapRequest);
|
|
70
|
-
nonCheapResult = await validateAndRecoverSingleResult(nonCheapRequest, nonCheapResult, generateContentFn);
|
|
71
|
-
return nonCheapResult.find((call) => call.name === 'askQuestion');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return cheapModelResponse;
|
|
76
|
+
return askQuestionResult.find((call) => call.name === 'askQuestion');
|
|
75
77
|
}
|
|
76
78
|
function getActionHandler(actionType) {
|
|
77
79
|
// First, check if there's a plugin-provided handler for this action type
|
|
@@ -81,13 +83,14 @@ function getActionHandler(actionType) {
|
|
|
81
83
|
}
|
|
82
84
|
// If no plugin handler is found, use the built-in handlers
|
|
83
85
|
const handlers = {
|
|
86
|
+
codeGeneration: handleCodeGeneration,
|
|
84
87
|
cancelCodeGeneration: handleCancelCodeGeneration,
|
|
85
88
|
confirmCodeGeneration: handleConfirmCodeGeneration,
|
|
86
|
-
startCodeGeneration: handleStartCodeGeneration,
|
|
87
89
|
requestFilesContent: handleRequestFilesContent,
|
|
88
90
|
requestPermissions: handleRequestPermissions,
|
|
89
91
|
removeFilesFromContext: handleRemoveFilesFromContext,
|
|
90
|
-
|
|
92
|
+
sendMessage: handleSendMessage,
|
|
93
|
+
sendMessageWithImage: handleSendMessageWithImage,
|
|
91
94
|
contextOptimization: handleContextOptimization,
|
|
92
95
|
};
|
|
93
96
|
return handlers[actionType] || handleDefaultAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-ask-question.js","sourceRoot":"","sources":["../../../../src/prompt/steps/step-ask-question/step-ask-question.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"step-ask-question.js","sourceRoot":"","sources":["../../../../src/prompt/steps/step-ask-question/step-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I,CAAC,IAAI,KAAK,aAAa,CAAgC,CAAC;AACtG,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAsB;IAC9C,yEAAyE;IACzE,MAAM,aAAa,GAAG,2BAA2B,EAAE,CAAC,GAAG,CAAC,UAAgC,CAAC,CAAC;IAC1F,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,2DAA2D;IAC3D,MAAM,QAAQ,GAAsC;QAClD,cAAc,EAAE,oBAAoB;QACpC,oBAAoB,EAAE,0BAA0B;QAChD,qBAAqB,EAAE,2BAA2B;QAClD,mBAAmB,EAAE,yBAAyB;QAC9C,kBAAkB,EAAE,wBAAwB;QAC5C,sBAAsB,EAAE,4BAA4B;QACpD,WAAW,EAAE,iBAAiB;QAC9B,oBAAoB,EAAE,0BAA0B;QAChD,mBAAmB,EAAE,yBAAyB;KAC/C,CAAC;IAEF,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,mBAAmB,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GenerateContentFunction, PromptItem } from '../../ai-service/common.js';
|
|
2
|
+
import { CodegenOptions } from '../../main/codegen-types.js';
|
|
3
|
+
import { StepResult } from './steps-types.js';
|
|
4
|
+
export declare const PLANNING_PROMPT = "Please analyze the conversation so far and help plan the implementation:\n\n1. Review the conversation history and requirements\n2. Thoughtfully analyze the problem\n3. Create a step-by-step implementation plan\n4. List all files that will be affected during implementation\n\nRemember to:\n- Consider both direct and indirect dependencies\n- Think about how changes in one file might affect others\n- Include all necessary file paths\n- Explain your reasoning for each step\n- Consider edge cases and potential issues\n\nOutput the plan using `codegenPlanning` function provding all the required fields.";
|
|
5
|
+
/**
|
|
6
|
+
* Execute the codegen planning step
|
|
7
|
+
* This step analyzes the conversation and produces a detailed implementation plan
|
|
8
|
+
* before proceeding with actual code generation
|
|
9
|
+
*/
|
|
10
|
+
export declare function executeStepCodegenPlanning(generateContentFn: GenerateContentFunction, prompt: PromptItem[], options: CodegenOptions): Promise<StepResult>;
|