genaicode 0.6.0 → 0.7.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 +1 -3
- 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 +0 -3
- package/dist/cli/cli-params.js +0 -9
- 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 +91 -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 +73 -0
- package/dist/eval/data/current-prompt.js +104 -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 +71 -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 +2 -2
- package/dist/files/read-files.js +13 -7
- package/dist/files/read-files.js.map +1 -1
- package/dist/files/read-files.test.js +12 -6
- package/dist/files/read-files.test.js.map +1 -1
- package/dist/files/source-code-tree.d.ts +12 -0
- package/dist/files/source-code-tree.js +27 -0
- package/dist/files/source-code-tree.js.map +1 -0
- package/dist/main/codegen-types.d.ts +9 -4
- package/dist/main/codegen-utils.d.ts +1 -1
- package/dist/main/codegen-utils.js +1 -3
- package/dist/main/codegen-utils.js.map +1 -1
- 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 +4 -7
- 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/interactive/codegen-interactive.js +0 -4
- package/dist/main/interactive/codegen-interactive.js.map +1 -1
- package/dist/main/interactive/codegen-interactive.test.js +0 -6
- 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 +2 -1
- package/dist/main/plugin-loader.js +8 -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-Dk_qaEQg.js → index-5e3ykhy6.js} +129 -103
- 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/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/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 +3 -10
- package/dist/prompt/prompt-codegen.test.js.map +1 -1
- package/dist/prompt/prompt-service-ask-question.test.js +26 -81
- 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 +36 -29
- 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 -1
- package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js.map +1 -1
- 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 +7 -4
- 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 -4
- 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 -2
- 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 +103 -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 +22 -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 +58 -13
- 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 +110 -10
- 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 +49 -24
- 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 +22 -19
- package/dist/prompt/steps/step-ask-question/step-ask-question.d.ts +2 -4
- package/dist/prompt/steps/step-ask-question/step-ask-question.js +18 -29
- 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-context-optimization.js +110 -80
- 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 +456 -0
- package/dist/prompt/steps/step-context-optimization.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 +0 -1
- package/dist/prompt/steps/step-summarization.js +6 -3
- 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/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 +2 -3
- package/dist/prompt/systemprompt.test.js.map +1 -1
- package/dist/vite-genaicode/vite-genaicode-plugin.d.ts +2 -1
- package/dist/vite-genaicode/vite-genaicode-plugin.js +15 -2
- package/dist/vite-genaicode/vite-genaicode-plugin.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,20 +1,32 @@
|
|
|
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
3
|
import { StepResult } from '../steps-types.js';
|
|
4
4
|
import { PluginActionType } from '../../../main/codegen-types.js';
|
|
5
|
-
export type ActionType = '
|
|
5
|
+
export type ActionType = 'sendMessage' | 'sendMessageWithImage' | 'requestPermissions' | 'requestFilesContent' | 'removeFilesFromContext' | 'confirmCodeGeneration' | 'cancelCodeGeneration' | 'contextOptimization' | PluginActionType;
|
|
6
6
|
type AskQuestionArgs = {
|
|
7
7
|
actionType: ActionType;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
export type SendMessageWithImageArgs = {
|
|
11
|
+
prompt: string;
|
|
12
|
+
contextImage?: string;
|
|
13
|
+
};
|
|
14
|
+
export type RequestPermissionsArgs = Record<'allowDirectoryCreate' | 'allowFileCreate' | 'allowFileDelete' | 'allowFileMove' | 'enableVision' | 'enableImagen', boolean>;
|
|
15
|
+
export type RequestFilesContentArgs = {
|
|
16
|
+
filePaths: string[];
|
|
17
|
+
};
|
|
18
|
+
export type RemoveFilesFromContextArgs = {
|
|
19
|
+
filePaths: string[];
|
|
20
|
+
};
|
|
21
|
+
export type ContextOptimizationArgs = {
|
|
22
|
+
filePaths: string[];
|
|
12
23
|
};
|
|
13
24
|
export type AskQuestionCall = FunctionCall<AskQuestionArgs>;
|
|
14
25
|
export interface AssistantItem {
|
|
15
26
|
type: 'assistant';
|
|
16
27
|
text: string;
|
|
17
|
-
functionCalls
|
|
28
|
+
functionCalls?: FunctionCall[];
|
|
29
|
+
images?: PromptItemImage[];
|
|
18
30
|
cache?: true;
|
|
19
31
|
}
|
|
20
32
|
export interface UserItem {
|
|
@@ -22,9 +34,10 @@ export interface UserItem {
|
|
|
22
34
|
text: string;
|
|
23
35
|
functionResponses?: Array<{
|
|
24
36
|
name: string;
|
|
25
|
-
call_id: string;
|
|
37
|
+
call_id: string | undefined;
|
|
26
38
|
content: string | undefined;
|
|
27
39
|
}>;
|
|
40
|
+
images?: PromptItemImage[];
|
|
28
41
|
cache?: true;
|
|
29
42
|
}
|
|
30
43
|
export interface ActionResult {
|
|
@@ -40,17 +53,7 @@ export type ActionHandlerProps = {
|
|
|
40
53
|
prompt: PromptItem[];
|
|
41
54
|
options: CodegenOptions;
|
|
42
55
|
generateContentFn: GenerateContentFunction;
|
|
43
|
-
|
|
44
|
-
contextSourceCode: (paths: string[], pathsOnly: boolean) => string;
|
|
45
|
-
};
|
|
56
|
+
generateImageFn: GenerateImageFunction;
|
|
46
57
|
};
|
|
47
58
|
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
59
|
export {};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { FunctionDef, GenerateContentFunction, PromptItem } from '../../../ai-service/common.js';
|
|
1
|
+
import { FunctionDef, GenerateContentFunction, PromptItem, GenerateImageFunction } from '../../../ai-service/common.js';
|
|
2
2
|
import { StepResult } from '../steps-types.js';
|
|
3
3
|
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>;
|
|
4
|
+
export declare function executeStepAskQuestion(generateContentFn: GenerateContentFunction, generateImageFn: GenerateImageFunction, prompt: PromptItem[], functionDefs: FunctionDef[], temperature: number, options: CodegenOptions): Promise<StepResult>;
|
|
@@ -7,38 +7,39 @@ import { handleContextOptimization } from './handlers/context-optimization.js';
|
|
|
7
7
|
import { handleRemoveFilesFromContext } from './handlers/remove-files-from-context.js';
|
|
8
8
|
import { handleRequestPermissions } from './handlers/request-permissions.js';
|
|
9
9
|
import { handleDefaultAction } from './handlers/default-action.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { handleSendMessage } from './handlers/handle-send-message.js';
|
|
11
|
+
import { handleSendMessageWithImage } from './handlers/handle-send-message-with-image.js';
|
|
12
12
|
import { handleConfirmCodeGeneration } from './handlers/confirm-code-generation.js';
|
|
13
13
|
import { handleCancelCodeGeneration } from './handlers/cancel-code-generation.js';
|
|
14
14
|
import { getRegisteredActionHandlers } from '../../../main/plugin-loader.js';
|
|
15
|
-
|
|
16
|
-
export async function executeStepAskQuestion(generateContentFn, prompt, functionDefs, temperature, messages, options) {
|
|
15
|
+
export async function executeStepAskQuestion(generateContentFn, generateImageFn, prompt, functionDefs, 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
|
-
const result = await actionHandler({
|
|
30
|
+
const result = await actionHandler({
|
|
31
|
+
askQuestionCall,
|
|
32
|
+
prompt,
|
|
33
|
+
options,
|
|
34
|
+
generateContentFn,
|
|
35
|
+
generateImageFn,
|
|
36
|
+
});
|
|
36
37
|
// This is important to display the content to the user interface (ui or interactive cli)
|
|
37
38
|
putUserMessage(result.items.slice(-1)[0].user.text);
|
|
39
|
+
prompt.push(...result.items.map(({ assistant, user }) => [assistant, user]).flat());
|
|
38
40
|
if (result.breakLoop) {
|
|
39
41
|
return result.stepResult;
|
|
40
42
|
}
|
|
41
|
-
prompt.push(...result.items.map(({ assistant, user }) => [assistant, user]).flat());
|
|
42
43
|
console.log('The question was answered');
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
@@ -55,23 +56,11 @@ export async function executeStepAskQuestion(generateContentFn, prompt, function
|
|
|
55
56
|
putSystemMessage('Assistant did not ask a question. This unexpected, we need to abort.');
|
|
56
57
|
return StepResult.BREAK;
|
|
57
58
|
}
|
|
58
|
-
async function getAskQuestionCall(generateContentFn, prompt, functionDefs, temperature, options
|
|
59
|
+
async function getAskQuestionCall(generateContentFn, prompt, functionDefs, temperature, options) {
|
|
59
60
|
const askQuestionRequest = [prompt, functionDefs, 'askQuestion', temperature, true, options];
|
|
60
61
|
let askQuestionResult = await generateContentFn(...askQuestionRequest);
|
|
61
62
|
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;
|
|
63
|
+
return askQuestionResult.find((call) => call.name === 'askQuestion');
|
|
75
64
|
}
|
|
76
65
|
function getActionHandler(actionType) {
|
|
77
66
|
// First, check if there's a plugin-provided handler for this action type
|
|
@@ -83,11 +72,11 @@ function getActionHandler(actionType) {
|
|
|
83
72
|
const handlers = {
|
|
84
73
|
cancelCodeGeneration: handleCancelCodeGeneration,
|
|
85
74
|
confirmCodeGeneration: handleConfirmCodeGeneration,
|
|
86
|
-
startCodeGeneration: handleStartCodeGeneration,
|
|
87
75
|
requestFilesContent: handleRequestFilesContent,
|
|
88
76
|
requestPermissions: handleRequestPermissions,
|
|
89
77
|
removeFilesFromContext: handleRemoveFilesFromContext,
|
|
90
|
-
|
|
78
|
+
sendMessage: handleSendMessage,
|
|
79
|
+
sendMessageWithImage: handleSendMessageWithImage,
|
|
91
80
|
contextOptimization: handleContextOptimization,
|
|
92
81
|
};
|
|
93
82
|
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-ask-question.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAE7E,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,iBAA0C,EAC1C,eAAsC,EACtC,MAAoB,EACpB,YAA2B,EAC3B,WAAmB,EACnB,OAAuB;IAEvB,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;IAE3D,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QACxC,IAAI,CAAC;YACH,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC,iBAAiB,EAAE,MAAM,EAAE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;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>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { getFunctionDefs } from '../function-calling.js';
|
|
2
|
+
import { putSystemMessage } from '../../main/common/content-bus.js';
|
|
3
|
+
import { validateAndRecoverSingleResult } from './step-validate-recover.js';
|
|
4
|
+
import { StepResult } from './steps-types.js';
|
|
5
|
+
import { CODEGEN_SUMMARY_PROMPT } from '../static-prompts.js';
|
|
6
|
+
export const PLANNING_PROMPT = `Please analyze the conversation so far and help plan the implementation:
|
|
7
|
+
|
|
8
|
+
1. Review the conversation history and requirements
|
|
9
|
+
2. Thoughtfully analyze the problem
|
|
10
|
+
3. Create a step-by-step implementation plan
|
|
11
|
+
4. List all files that will be affected during implementation
|
|
12
|
+
|
|
13
|
+
Remember to:
|
|
14
|
+
- Consider both direct and indirect dependencies
|
|
15
|
+
- Think about how changes in one file might affect others
|
|
16
|
+
- Include all necessary file paths
|
|
17
|
+
- Explain your reasoning for each step
|
|
18
|
+
- Consider edge cases and potential issues
|
|
19
|
+
|
|
20
|
+
Output the plan using \`codegenPlanning\` function provding all the required fields.`;
|
|
21
|
+
/**
|
|
22
|
+
* Execute the codegen planning step
|
|
23
|
+
* This step analyzes the conversation and produces a detailed implementation plan
|
|
24
|
+
* before proceeding with actual code generation
|
|
25
|
+
*/
|
|
26
|
+
export async function executeStepCodegenPlanning(generateContentFn, prompt, options) {
|
|
27
|
+
putSystemMessage('Starting codegen planning phase...');
|
|
28
|
+
// Add the planning prompt to the conversation
|
|
29
|
+
if (prompt.slice(-1)[0].type === 'user') {
|
|
30
|
+
prompt.slice(-1)[0].text += '\n\\n' + PLANNING_PROMPT;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
prompt.push({ type: 'user', text: PLANNING_PROMPT });
|
|
34
|
+
}
|
|
35
|
+
const planningRequest = [
|
|
36
|
+
prompt,
|
|
37
|
+
getFunctionDefs(),
|
|
38
|
+
'codegenPlanning',
|
|
39
|
+
options.temperature ?? 0.7,
|
|
40
|
+
options.cheap ?? true,
|
|
41
|
+
options,
|
|
42
|
+
];
|
|
43
|
+
try {
|
|
44
|
+
let planningResult = await generateContentFn(...planningRequest);
|
|
45
|
+
planningResult = await validateAndRecoverSingleResult(planningRequest, planningResult, generateContentFn);
|
|
46
|
+
const codegenPlanningRequest = planningResult.find((call) => call.name === 'codegenPlanning');
|
|
47
|
+
if (codegenPlanningRequest) {
|
|
48
|
+
putSystemMessage('Planning phase completed successfully', codegenPlanningRequest.args);
|
|
49
|
+
// Store the planning response in conversation history
|
|
50
|
+
prompt.push({ type: 'assistant', functionCalls: planningResult });
|
|
51
|
+
prompt.push({
|
|
52
|
+
type: 'user',
|
|
53
|
+
functionResponses: planningResult.map((call) => ({ name: call.name, call_id: call.id })),
|
|
54
|
+
text: CODEGEN_SUMMARY_PROMPT,
|
|
55
|
+
cache: true,
|
|
56
|
+
});
|
|
57
|
+
return StepResult.CONTINUE;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
putSystemMessage('Did not receive codegen planning result');
|
|
61
|
+
return StepResult.BREAK;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
putSystemMessage('Error during planning phase: ' + error.message);
|
|
66
|
+
return StepResult.BREAK;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=step-codegen-planning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-codegen-planning.js","sourceRoot":"","sources":["../../../src/prompt/steps/step-codegen-planning.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;qFAcsD,CAAC;AAEtF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,iBAA0C,EAC1C,MAAoB,EACpB,OAAuB;IAEvB,gBAAgB,CAAC,oCAAoC,CAAC,CAAC;IAEvD,8CAA8C;IAC9C,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,GAAG,eA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U,CAAC,KAAK,CAAC;QAC1B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gBAAgB,CAAC,+BAA+B,GAAI,KAAe,CAAC,OAAO,CAAC,CAAC;QAC7E,OAAO,UAAU,CAAC,KAAK,CAAC;IAC1B,CAAC;AACH,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { estimateTokenCount } from '../token-estimator.js';
|
|
|
6
6
|
import { getSummary } from './step-summarization.js';
|
|
7
7
|
import { validateAndRecoverSingleResult } from './step-validate-recover.js';
|
|
8
8
|
import { getSourceCodeResponse } from './steps-utils.js';
|
|
9
|
+
import { getSourceCodeTree, parseSourceCodeTree } from '../../files/source-code-tree.js';
|
|
9
10
|
const OPTIMIZATION_PROMPT = `You're correct, we need to optimize the context for code generation. Please perform the following tasks and respond by calling the \`optimizeContext\` function with the appropriate arguments:
|
|
10
11
|
|
|
11
12
|
1. **Relevance and Token Cost Evaluation**:
|
|
@@ -31,13 +32,11 @@ const OPTIMIZATION_PROMPT = `You're correct, we need to optimize the context for
|
|
|
31
32
|
- The function should have the following parameters:
|
|
32
33
|
- \`"userPrompt"\`: The user's original prompt.
|
|
33
34
|
- \`"optimizedContext"\`: An array of objects, each containing:
|
|
34
|
-
- \`"
|
|
35
|
+
- \`"filePath"\`: The absolute file path.
|
|
35
36
|
- \`"relevance"\`: The calculated relevance score (0 to 1).
|
|
36
|
-
- \`"tokenCount"\`: The token count for the file.
|
|
37
|
-
- \`"totalTokenCount"\`: The estimated total token count for the context.
|
|
38
37
|
|
|
39
38
|
**Important Guidelines**:
|
|
40
|
-
- **Only include files that are mentioned in \`getSourceCode\` function
|
|
39
|
+
- **Only include files that are mentioned in \`getSourceCode\` function response**. **Do not add any other files**.
|
|
41
40
|
- **Do not infer or guess additional files**.
|
|
42
41
|
- **Evaluate each file individually** based on the criteria above.
|
|
43
42
|
- **Avoid assumptions or hallucinations**; stick strictly to the provided data.
|
|
@@ -46,6 +45,7 @@ const OPTIMIZATION_PROMPT = `You're correct, we need to optimize the context for
|
|
|
46
45
|
- **Do not include any extra text** outside of the function call.
|
|
47
46
|
- **Ensure the JSON is properly formatted** and **does not contain strings representing JSON** (i.e., do not stringify the JSON, do not wrap strings into quotes).
|
|
48
47
|
- **Do not return files which are not relevant to the user prompt. Use relevance rating to judge that**
|
|
48
|
+
- **Formulate full file paths correctly using directoryPath and filePath from the \`getSourceCode\` function response**.
|
|
49
49
|
|
|
50
50
|
**Example of valid Function Call**:
|
|
51
51
|
|
|
@@ -53,18 +53,15 @@ const OPTIMIZATION_PROMPT = `You're correct, we need to optimize the context for
|
|
|
53
53
|
{
|
|
54
54
|
"function": "optimizeContext",
|
|
55
55
|
"arguments": {
|
|
56
|
-
"userPrompt": "Please review the helper
|
|
57
|
-
"totalTokenCount": 800,
|
|
56
|
+
"userPrompt": "Please review the helper module.",
|
|
58
57
|
"optimizedContext": [
|
|
59
58
|
{
|
|
60
59
|
"path": "/home/src/utils/helpers.js",
|
|
61
60
|
"relevance": 0.9,
|
|
62
|
-
"tokenCount": 500
|
|
63
61
|
},
|
|
64
62
|
{
|
|
65
63
|
"path": "/home/src/utils/math.js",
|
|
66
|
-
"relevance": 0.
|
|
67
|
-
"tokenCount": 300
|
|
64
|
+
"relevance": 0.4,
|
|
68
65
|
}
|
|
69
66
|
]
|
|
70
67
|
}
|
|
@@ -73,80 +70,89 @@ const OPTIMIZATION_PROMPT = `You're correct, we need to optimize the context for
|
|
|
73
70
|
|
|
74
71
|
Now could you please analyze the source code and return me the optimized context?
|
|
75
72
|
`;
|
|
76
|
-
const BATCH_SIZE = 100;
|
|
73
|
+
// const BATCH_SIZE = 100;
|
|
77
74
|
const MAX_TOTAL_TOKENS = 10000;
|
|
78
75
|
export async function executeStepContextOptimization(generateContentFn, prompt, options) {
|
|
79
76
|
const fullSourceCode = getSourceCode({ forceAll: true }, options);
|
|
77
|
+
const tokensBefore = estimateTokenCount(JSON.stringify(fullSourceCode));
|
|
78
|
+
if (tokensBefore < MAX_TOTAL_TOKENS) {
|
|
79
|
+
putSystemMessage('Context optimization is not needed, because the code base is small.');
|
|
80
|
+
return StepResult.CONTINUE;
|
|
81
|
+
}
|
|
80
82
|
const sourceCodeResponse = getSourceCodeResponse(prompt);
|
|
81
83
|
if (!sourceCodeResponse || !sourceCodeResponse.content) {
|
|
82
84
|
console.warn('Could not find source code response, something is wrong, but lets continue anyway.');
|
|
83
85
|
return StepResult.CONTINUE;
|
|
84
86
|
}
|
|
85
|
-
const sourceCode = JSON.parse(sourceCodeResponse.content);
|
|
86
|
-
const sourceCodeEntries = Object.entries(sourceCode);
|
|
87
|
-
// Lets remove source code from the context, because we will be providing it below, so lets not duplicate (and save some tokens)
|
|
88
|
-
const sourceCodeResponseContent = sourceCodeResponse.content;
|
|
89
|
-
sourceCodeResponse.content = '{}';
|
|
87
|
+
const sourceCode = parseSourceCodeTree(JSON.parse(sourceCodeResponse.content));
|
|
90
88
|
try {
|
|
91
89
|
putSystemMessage('Context optimization is starting');
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
text: OPTIMIZATION_PROMPT,
|
|
111
|
-
functionResponses: [
|
|
112
|
-
{ call_id: 'get_batch_source', name: 'getSourceCode', content: JSON.stringify(batchSourceCode) },
|
|
113
|
-
],
|
|
114
|
-
},
|
|
115
|
-
];
|
|
116
|
-
const request = [
|
|
117
|
-
optimizationPrompt,
|
|
118
|
-
getFunctionDefs(),
|
|
119
|
-
'optimizeContext',
|
|
120
|
-
0.2,
|
|
121
|
-
true,
|
|
122
|
-
options,
|
|
123
|
-
];
|
|
124
|
-
let result = await generateContentFn(...request);
|
|
125
|
-
result = await validateAndRecoverSingleResult(request, result, generateContentFn);
|
|
126
|
-
const batchOptimized = parseOptimizationResult(result);
|
|
127
|
-
if (!batchOptimized) {
|
|
128
|
-
putSystemMessage(`Warning: Context optimization failed to produce useful summaries for batch ${batchIndex + 1}. We need to abort.`);
|
|
129
|
-
return StepResult.BREAK;
|
|
130
|
-
}
|
|
131
|
-
optimizedContext.clear();
|
|
132
|
-
batchOptimized.forEach((path) => optimizedContext.add(path));
|
|
90
|
+
const optimizationPrompt = [
|
|
91
|
+
...prompt,
|
|
92
|
+
{
|
|
93
|
+
type: 'assistant',
|
|
94
|
+
text: 'Thank you for describing the task, I have noticed you have provided a very large context for your question. The amount of source code is very big in particular. Can we do something about it?',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: 'user',
|
|
98
|
+
text: OPTIMIZATION_PROMPT,
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
const request = [optimizationPrompt, getFunctionDefs(), 'optimizeContext', 0.2, true, options];
|
|
102
|
+
let result = await generateContentFn(...request);
|
|
103
|
+
result = await validateAndRecoverSingleResult(request, result, generateContentFn);
|
|
104
|
+
const optimizedContext = parseOptimizationResult(fullSourceCode, result);
|
|
105
|
+
if (!optimizedContext) {
|
|
106
|
+
putSystemMessage(`Warning: Context optimization failed. We need to abort.`);
|
|
107
|
+
return StepResult.BREAK;
|
|
133
108
|
}
|
|
134
|
-
if (optimizedContext.
|
|
135
|
-
// Restore the original context
|
|
136
|
-
sourceCodeResponse.content = sourceCodeResponseContent;
|
|
109
|
+
if (optimizedContext.length === 0) {
|
|
137
110
|
putSystemMessage('Warning: Context optimization failed to produce useful summaries for all batches. Proceeding with current context.');
|
|
138
111
|
return StepResult.CONTINUE;
|
|
139
112
|
}
|
|
140
|
-
const tokensBefore = estimateTokenCount(JSON.stringify(fullSourceCode));
|
|
141
113
|
putSystemMessage('Context optimization in progress.', Array.from(optimizedContext));
|
|
142
|
-
const optimizedSourceCode = optimizeSourceCode(sourceCode, fullSourceCode, Array.from(optimizedContext));
|
|
114
|
+
const [optimizedSourceCode, contentTokenCount, summaryTokenCount] = optimizeSourceCode(sourceCode, fullSourceCode, Array.from(optimizedContext));
|
|
143
115
|
const tokensAfter = estimateTokenCount(JSON.stringify(optimizedSourceCode));
|
|
144
116
|
const percentageReduced = ((tokensBefore - tokensAfter) / tokensBefore) * 100;
|
|
145
|
-
//
|
|
146
|
-
|
|
117
|
+
// Clear previous getSourceCode responses
|
|
118
|
+
clearPreviousSourceCodeResponses(prompt);
|
|
119
|
+
prompt.push({
|
|
120
|
+
type: 'assistant',
|
|
121
|
+
// we may want to put text question here
|
|
122
|
+
functionCalls: [
|
|
123
|
+
{
|
|
124
|
+
name: 'requestFilesContent',
|
|
125
|
+
args: {
|
|
126
|
+
filePaths: Object.keys(optimizedSourceCode),
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'getSourceCode',
|
|
131
|
+
args: {
|
|
132
|
+
filePaths: Object.keys(optimizedSourceCode),
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
}, {
|
|
137
|
+
type: 'user',
|
|
138
|
+
// we may want to put text answer here
|
|
139
|
+
functionResponses: [
|
|
140
|
+
{
|
|
141
|
+
name: 'requestFilesContent',
|
|
142
|
+
content: JSON.stringify({ filePaths: Object.keys(optimizedSourceCode) }),
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'getSourceCode',
|
|
146
|
+
content: JSON.stringify(getSourceCodeTree(optimizedSourceCode)),
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
cache: true,
|
|
150
|
+
});
|
|
147
151
|
putSystemMessage('Context optimization completed successfully.', {
|
|
148
152
|
tokensBefore,
|
|
149
153
|
tokensAfter,
|
|
154
|
+
contentTokenCount,
|
|
155
|
+
summaryTokenCount,
|
|
150
156
|
percentageReduced: percentageReduced.toFixed(2) + '%',
|
|
151
157
|
});
|
|
152
158
|
return StepResult.CONTINUE;
|
|
@@ -157,20 +163,24 @@ export async function executeStepContextOptimization(generateContentFn, prompt,
|
|
|
157
163
|
return StepResult.BREAK;
|
|
158
164
|
}
|
|
159
165
|
}
|
|
160
|
-
function parseOptimizationResult(calls) {
|
|
166
|
+
function parseOptimizationResult(fullSourceCode, calls) {
|
|
161
167
|
const optimizeCall = calls.find((call) => call.name === 'optimizeContext');
|
|
162
168
|
if (!optimizeCall || !optimizeCall.args || !optimizeCall.args.optimizedContext) {
|
|
163
169
|
return null;
|
|
164
170
|
}
|
|
165
171
|
let totalTokens = 0;
|
|
166
172
|
const result = [];
|
|
167
|
-
for (const item of optimizeCall.args.optimizedContext.sort((a, b) =>
|
|
168
|
-
|
|
173
|
+
for (const item of optimizeCall.args.optimizedContext.sort((a, b) => a.relevance > b.relevance ? -1 : 1)) {
|
|
174
|
+
const { filePath, relevance } = item;
|
|
175
|
+
if (relevance < 0.5) {
|
|
169
176
|
break;
|
|
170
177
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
178
|
+
const content = (fullSourceCode[filePath] && 'content' in fullSourceCode[filePath]
|
|
179
|
+
? fullSourceCode[filePath]?.content
|
|
180
|
+
: undefined) ?? '';
|
|
181
|
+
totalTokens += estimateTokenCount(content);
|
|
182
|
+
result.push([item.filePath, item.relevance]);
|
|
183
|
+
if (totalTokens > MAX_TOTAL_TOKENS && relevance < 0.7) {
|
|
174
184
|
break;
|
|
175
185
|
}
|
|
176
186
|
}
|
|
@@ -178,23 +188,43 @@ function parseOptimizationResult(calls) {
|
|
|
178
188
|
}
|
|
179
189
|
function optimizeSourceCode(sourceCode, fullSourceCode, optimizedContext) {
|
|
180
190
|
const optimizedSourceCode = {};
|
|
181
|
-
|
|
182
|
-
|
|
191
|
+
let contentTokenCount = 0;
|
|
192
|
+
let summaryTokenCount = 0;
|
|
193
|
+
for (const [path] of Object.entries(fullSourceCode)) {
|
|
194
|
+
const isContext = optimizedContext.filter((item) => item[0] === path).length > 0;
|
|
183
195
|
const summary = getSummary(path);
|
|
184
|
-
|
|
196
|
+
const content = (fullSourceCode[path] && 'content' in fullSourceCode[path] ? fullSourceCode[path]?.content : undefined) ?? null;
|
|
197
|
+
if (isContext && content && !(sourceCode[path] && 'content' in sourceCode[path])) {
|
|
198
|
+
contentTokenCount += estimateTokenCount(content);
|
|
185
199
|
optimizedSourceCode[path] = {
|
|
186
|
-
content
|
|
187
|
-
...summary,
|
|
200
|
+
content,
|
|
188
201
|
};
|
|
189
202
|
}
|
|
190
203
|
else {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
204
|
+
summaryTokenCount += estimateTokenCount(summary?.summary ?? '');
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return [optimizedSourceCode, contentTokenCount, summaryTokenCount];
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Helper function to clear content from previous getSourceCode responses while preserving the conversation structure
|
|
211
|
+
*/
|
|
212
|
+
function clearPreviousSourceCodeResponses(prompt) {
|
|
213
|
+
for (const item of prompt) {
|
|
214
|
+
if (item.type === 'user' && item.functionResponses) {
|
|
215
|
+
for (const response of item.functionResponses) {
|
|
216
|
+
if (response.name === 'getSourceCode' && response.content) {
|
|
217
|
+
// Zero out the contents but keep the structure
|
|
218
|
+
const sourceCode = parseSourceCodeTree(JSON.parse(response.content));
|
|
219
|
+
for (const path in sourceCode) {
|
|
220
|
+
if ('content' in sourceCode[path]) {
|
|
221
|
+
delete sourceCode[path];
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
response.content = JSON.stringify(getSourceCodeTree(sourceCode));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
196
227
|
}
|
|
197
228
|
}
|
|
198
|
-
return optimizedSourceCode;
|
|
199
229
|
}
|
|
200
230
|
//# sourceMappingURL=step-context-optimization.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-context-optimization.js","sourceRoot":"","sources":["../../../src/prompt/steps/step-context-optimization.ts"],"names":[],"mappings":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