genaicode 0.8.0 → 0.8.1
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/dist/eval/data/current-prompt.d.ts +22 -0
- package/dist/eval/data/current-prompt.js +79 -34
- package/dist/eval/data/current-prompt.js.map +1 -1
- package/dist/prompt/steps/step-context-optimization.js +6 -5
- package/dist/prompt/steps/step-context-optimization.js.map +1 -1
- package/package.json +1 -1
|
@@ -31,4 +31,26 @@ export const DEBUG_CURRENT_PROMPT: ({
|
|
|
31
31
|
cache: boolean;
|
|
32
32
|
systemPrompt?: undefined;
|
|
33
33
|
functionCalls?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
type: string;
|
|
36
|
+
functionCalls: {
|
|
37
|
+
name: string;
|
|
38
|
+
args: {
|
|
39
|
+
filePaths: string[];
|
|
40
|
+
};
|
|
41
|
+
}[];
|
|
42
|
+
systemPrompt?: undefined;
|
|
43
|
+
text?: undefined;
|
|
44
|
+
functionResponses?: undefined;
|
|
45
|
+
cache?: undefined;
|
|
46
|
+
} | {
|
|
47
|
+
type: string;
|
|
48
|
+
functionResponses: {
|
|
49
|
+
name: string;
|
|
50
|
+
content: string;
|
|
51
|
+
}[];
|
|
52
|
+
cache: boolean;
|
|
53
|
+
systemPrompt?: undefined;
|
|
54
|
+
text?: undefined;
|
|
55
|
+
functionCalls?: undefined;
|
|
34
56
|
})[];
|
|
@@ -1,59 +1,104 @@
|
|
|
1
1
|
export const DEBUG_CURRENT_PROMPT = [
|
|
2
2
|
{
|
|
3
|
-
type:
|
|
4
|
-
systemPrompt:
|
|
3
|
+
"type": "systemPrompt",
|
|
4
|
+
"systemPrompt": "## Who are you?\n\nYou are GenAIcode, a code generation assistant tasked with helping me implement my ideas into my application's source code.\nYou should parse my application source code and then suggest changes using appropriate tools.\nPlease limit any changes to the root directory of my application, which is `/Users/gtanczyk/src/codegen`.\n\n## Important Guidelines\n\n- **Use Absolute Paths**: Always use absolute file paths exactly as provided.\n- **Return Working Code**: Aim to return fully functional code.\n- **Avoid Incomplete Code Snippets**: Do not include commented-out fragments like `// ... (keep other existing functions)`.\n- **Handle Large Files Appropriately**: For large files, prefer to use the `patchFile` function.\n- **Suggest File Splitting When Relevant**: Suggest splitting large files if it improves maintainability.\n- **Verify Permissions**: Ensure you have the necessary permissions before proceeding.\n- **Error Handling**: If instructions are unclear, consider failing the task with an explanation.\n- **Produce Necessary Code Only**: Do not generate unnecessary code.\n- **Request Context When Needed**: Ask for sufficient context paths in the code generation summary.\n- **Perform Dependency Analysis**: Always analyze the task thoroughly to identify all files that need to be updated, including dependencies and related modules.\n- **Comprehensive File Updates**: Ensure that all relevant files are included in the `fileUpdates` list when proposing changes.\n- **Perform Thorough Analysis**: Before generating code, always perform a comprehensive analysis of the task, identifying all affected files and dependencies.\n- **Communicate Planned Changes**: Summarize the planned changes and list all files to be updated. Seek user confirmation before proceeding.\n- **Consider Dependencies**: Include any dependent files that might require updates to ensure the codebase remains consistent.\n- **Avoid Unnecessary Permission Requests**: Do not request permissions that you already have.\n\n## Your permissions\n\n- You are allowed to modify files.\n- You are allowed to create new files.\n- You are allowed to delete files; in such cases, add an empty string as content.\n- You are allowed to create new directories.\n- You are allowed to move files.\n- You are allowed to analyze image assets.\n- You are allowed to generate images.\n## Asking Questions And Conversing\nYou have the ability to have a conversation with me to clarify requirements, seek permissions, or request additional context.\nUse this feature wisely to gather crucial information that would help you better understand the task or provide more accurate code generation.\n\nTo have conversation with me use the `askQuestion` function. This function allows you to:\n\n- **Express Your Thoughts**: Inform me about your considerations or concerns regarding the task.\n- **Share Analysis**: Provide insights or analysis based on the task requirements.\n- **Seek Clarification**: Ask questions or provide suggestions to ensure you fully understand the requirements.\n- **Request File Access**: If certain files are important but haven't been provided, request access to their content.\n- **Request Permissions**: If you need permissions for operations that were initially restricted, you may request them.\n- **Generate an image**: If you want to express your thoughts through an image, you can request image generation.\n\n### Efficient File Content Requests\n\nYou can request the content of legitimate files within the project without interrupting the user. This allows you to gather more context when needed.\n\n- **Judicious Use**: Only request files directly relevant to the task.\n- **Relevance**: Consider if the file content is truly necessary.\n- **Large Files**: Be cautious when requesting large files.\n- **Dependencies**: Trace through file dependencies when necessary.\n- **Privacy and Security**: Be mindful of sensitive information.\n- **Iterative Requests**: Anticipate your needs to minimize the number of requests.\n\n# Typical Conversation Flow \n\nIt is ** VERY IMPORTANT ** to follow the conversation flow to ensure a smooth and efficient code generation process. Here is a typical conversation flow:\n\n1. I provide you with source code and context.\n2. Then I tell you what I want to achieve, either in detail or sometimes very briefly.\n3. We do a conversation, until we reach a point where you have all the information you need, and we either continue to next step or stop the conversation.\n4. You propose to start code generation (actionType: confirmCodeGeneration)\n5. I confirm that you can proceed (or reject and we go back to step 3)\n6. You generate the code changes summary\n7. Then you generate code change for each file\n8. I apply code changes, and the conversation ends.\n\n## Conversation Flow Best Practices\n\n- If the user wants to stop the conversation, you should respect that and stop the conversation (actionType: cancelCodeGeneration).\n\n## Common pitfalls to avoid\n\nIt is **VERY IMPORTANT** to not make the following mistakes:\n\n- Assistant wants to start code generation while the conversation is still ongoing.\n- Assistant says that it starts analysis, but it does not provide any analysis.\n- Assistant says something like \"please wait\", instead of providing a meaningful response.\n- Assistant starts code generation without requesting missing permissions.\n## Important Context\n[object Object]"
|
|
5
5
|
},
|
|
6
6
|
{
|
|
7
|
-
type:
|
|
8
|
-
text:
|
|
7
|
+
"type": "user",
|
|
8
|
+
"text": "Hello, GenAIcode!"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
|
-
type:
|
|
12
|
-
text:
|
|
13
|
-
functionCalls: [
|
|
11
|
+
"type": "assistant",
|
|
12
|
+
"text": "Hello there! I guess you have a task for me today. Before we start, could you please provide me with: \n - the current source code of your application\n - the image assets (if available)\n - and conversational history (if available)\n \n Thanks",
|
|
13
|
+
"functionCalls": [
|
|
14
14
|
{
|
|
15
|
-
name:
|
|
15
|
+
"name": "getSourceCode"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
|
-
name:
|
|
18
|
+
"name": "getImageAssets"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
name:
|
|
22
|
-
}
|
|
23
|
-
]
|
|
21
|
+
"name": "readHistory"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
type:
|
|
27
|
-
functionResponses: [
|
|
28
|
-
{
|
|
29
|
-
name: 'getSourceCode',
|
|
30
|
-
content: JSON.stringify({
|
|
31
|
-
'/Users/gtanczyk/src/testproject': {
|
|
32
|
-
'app.ts': {
|
|
33
|
-
content: "hello, I'm a simple app.ts file",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
}),
|
|
37
|
-
},
|
|
26
|
+
"type": "user",
|
|
27
|
+
"functionResponses": [
|
|
38
28
|
{
|
|
39
|
-
name:
|
|
40
|
-
content: '{}',
|
|
29
|
+
"name": "getSourceCode",
|
|
30
|
+
"content": "{\"/Users/gtanczyk/src/codegen\":{\".eslintrc.cjs\":{\"content\":null},\"README.md\":{\"content\":null},\"knip.json\":{\"content\":null},\"package.json\":{\"content\":null},\"tsconfig.json\":{\"content\":null},\"vitest.e2e.config.ts\":{\"content\":null},\"vitest.unit.config.ts\":{\"content\":null},\"vitest.workspace.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/bin\":{\"genaicode-dev.js\":{\"content\":null},\"genaicode.cjs\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/docs/design\":{\"configuration.md\":{\"content\":null},\"context_optimization_feature.md\":{\"content\":null},\"features.md\":{\"content\":null},\"file_operations.md\":{\"content\":null},\"genaicode_design_doc.md\":{\"content\":null},\"overview.md\":{\"content\":null},\"token_usage_reduction.md\":{\"content\":null},\"tri_state_codegen.md\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/docs/tasks\":{\"advanced_llm_prompt.md\":{\"content\":null},\"ai_token_usage.md\":{\"content\":null},\"allow_directory_create.md\":{\"content\":null},\"codegen_design_doc.md\":{\"content\":null},\"configurable_extensions.md\":{\"content\":null},\"content_mask.md\":{\"content\":null},\"context_shrinking.md\":{\"content\":null},\"conversation-history-management.md\":{\"content\":null},\"current_feedback.md\":{\"content\":null},\"interactive_cli.md\":{\"content\":null},\"lint_step.md\":{\"content\":null},\"multimodal_frontend.md\":{\"content\":null},\"new_config_options.md\":{\"content\":null},\"project_structure_refactor.md\":{\"content\":null},\"step_ask_question_refactor.md\":{\"content\":null},\"usage_monitoring.md\":{\"content\":null},\"web_ui.md\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/e2e-tests\":{\"genaicode-ui.test.ts\":{\"content\":null},\"project-profiles-test-utils.ts\":{\"content\":null},\"project-profiles.test.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/examples\":{\"README.md\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/examples/genaicode_plugins\":{\"fake_ai_service.ts\":{\"content\":null},\"grok_ai_service.ts\":{\"content\":null},\"nonsense_action_handler.ts\":{\"content\":null},\"nonsense_operation.ts\":{\"content\":null},\"vitest_runner.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/examples/vite_genaicode_example\":{\"vite.config.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/ai-service\":{\"ai-studio.ts\":{\"content\":null},\"anthropic.ts\":{\"content\":null},\"chat-gpt.ts\":{\"content\":null},\"common.test.ts\":{\"content\":null},\"common.ts\":{\"content\":null},\"dall-e.ts\":{\"content\":null},\"unescape-function-call.test.ts\":{\"content\":null},\"unescape-function-call.ts\":{\"content\":null},\"vertex-ai-claude.ts\":{\"content\":null},\"vertex-ai-imagen.ts\":{\"content\":null},\"vertex-ai.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/cli\":{\"cli-options.test.ts\":{\"content\":null},\"cli-options.ts\":{\"content\":null},\"cli-params.test.ts\":{\"content\":null},\"cli-params.ts\":{\"content\":null},\"service-autodetect.test.ts\":{\"content\":null},\"service-autodetect.ts\":{\"content\":null},\"validate-cli-params.test.ts\":{\"content\":null},\"validate-cli-params.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/eval\":{\"codegen-summary.test.ts\":{\"content\":null},\"current-prompt-plugin.ts\":{\"content\":null},\"prompt-debug.test.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/files\":{\"cache-file.ts\":{\"content\":null},\"file-utils.test.ts\":{\"content\":null},\"file-utils.ts\":{\"content\":null},\"find-files.ts\":{\"content\":null},\"path-utils.ts\":{\"content\":null},\"read-files.test.ts\":{\"content\":null},\"read-files.ts\":{\"content\":null},\"source-code-tree.ts\":{\"content\":null,\"dependencies\":[{\"path\":\"path\",\"type\":\"external\",\"direct\":true,\"importPath\":\"path\"}]},\"temp-buffer.ts\":{\"content\":null},\"update-files.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/images\":{\"ensure-alpha.ts\":{\"content\":null},\"imgly-remove-background.ts\":{\"content\":null},\"resize-image.ts\":{\"content\":null},\"split-image.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src\":{\"index.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main\":{\"codegen-types.ts\":{\"content\":null,\"dependencies\":[]},\"codegen-utils.ts\":{\"content\":null},\"codegen.ai-services.test.ts\":{\"content\":null},\"codegen.cli-options.test.ts\":{\"content\":null},\"codegen.image-generation.test.ts\":{\"content\":null},\"codegen.test-utils.ts\":{\"content\":null},\"codegen.ts\":{\"content\":null},\"config-lib.test.ts\":{\"content\":null},\"config-lib.ts\":{\"content\":null},\"config.ts\":{\"content\":null},\"plugin-loader.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/common\":{\"content-bus-types.ts\":{\"content\":null},\"content-bus.ts\":{\"content\":null},\"cost-collector.ts\":{\"content\":null},\"user-actions.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/interactive\":{\"codegen-interactive.test.ts\":{\"content\":null},\"codegen-interactive.ts\":{\"content\":null},\"codegen-worker.ts\":{\"content\":null},\"common.ts\":{\"content\":null},\"configure.ts\":{\"content\":null},\"error-handling.ts\":{\"content\":null},\"help.ts\":{\"content\":null},\"select-ai-service.ts\":{\"content\":null},\"task-file.ts\":{\"content\":null},\"text-prompt.ts\":{\"content\":null},\"user-action-handlers.ts\":{\"content\":null},\"user-interrupt.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui/backend\":{\"api-utils.ts\":{\"content\":null},\"api.ts\":{\"content\":null},\"server.ts\":{\"content\":null},\"service.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui\":{\"codegen-ui.ts\":{\"content\":null},\"user-action-handlers.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui/common\":{\"api-types.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui/frontend/app/api\":{\"api-client.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui/frontend/app/components\":{\"app-handlers.tsx\":{\"content\":null},\"app-layout.tsx\":{\"content\":null},\"app-state.tsx\":{\"content\":null},\"chat-interface.tsx\":{\"content\":null},\"info-icon.tsx\":{\"content\":null},\"progress-indicator.tsx\":{\"content\":null},\"question-handler.tsx\":{\"content\":null},\"styled-textarea.tsx\":{\"content\":null},\"theme-toggle.tsx\":{\"content\":null},\"unread-messages-notification.tsx\":{\"content\":null},\"usage-display.tsx\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui/frontend/app/components/chat\":{\"data-container.tsx\":{\"content\":null},\"message-container.tsx\":{\"content\":null},\"system-message-container.tsx\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui/frontend/app/components/chat/styles\":{\"chat-interface-styles.ts\":{\"content\":null},\"data-container-styles.ts\":{\"content\":null},\"message-container-styles.ts\":{\"content\":null},\"system-message-container-styles.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui/frontend/app/components/input-area\":{\"ai-service-selector.tsx\":{\"content\":null},\"button-container.tsx\":{\"content\":null},\"codegen-options-form.tsx\":{\"content\":null},\"image-upload.tsx\":{\"content\":null},\"input-area.tsx\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui/frontend/app\":{\"genaicode-app.tsx\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui/frontend/app/hooks\":{\"merged-messages.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui/frontend/app/theme\":{\"global-style.ts\":{\"content\":null},\"styled-components.d.ts\":{\"content\":null},\"theme.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/main/ui/frontend\":{\"index.js\":{\"content\":null},\"tsconfig.json\":{\"content\":null},\"vite-env.d.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/operations/create-directory\":{\"create-directory-def.ts\":{\"content\":null},\"create-directory-executor.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/operations/create-file\":{\"create-file-def.ts\":{\"content\":null},\"create-file-executor.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/operations/delete-file\":{\"delete-file-def.ts\":{\"content\":null},\"delete-file-executor.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/operations/download-file\":{\"download-file-def.ts\":{\"content\":null},\"download-file-executor.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/operations/imgly-remove-background\":{\"imgly-remove-background-def.ts\":{\"content\":null},\"imgly-remove-background-executor.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/operations/move-file\":{\"move-file-def.ts\":{\"content\":null},\"move-file-executor.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/operations\":{\"operations-index.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/operations/patch-file\":{\"patch-file-def.ts\":{\"content\":null},\"patch-file-executor.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/operations/resize-image\":{\"resize-image-def.ts\":{\"content\":null},\"resize-image-executor.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/operations/split-image\":{\"split-image-def.ts\":{\"content\":null},\"split-image-executor.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/operations/update-file\":{\"update-file-def.ts\":{\"content\":null},\"update-file-executor.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/project-profiles\":{\"detection.ts\":{\"content\":null},\"index.ts\":{\"content\":null},\"types.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/project-profiles/profiles\":{\"golang.ts\":{\"content\":null},\"java-maven.ts\":{\"content\":null},\"javascript-npm.ts\":{\"content\":null},\"javascript-react.ts\":{\"content\":null},\"python-django.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/prompt\":{\"ai-service-fallback.ts\":{\"content\":null},\"function-calling-validate.ts\":{\"content\":null},\"function-calling.ts\":{\"content\":null},\"limits.test.ts\":{\"content\":null},\"limits.ts\":{\"content\":null},\"prompt-codegen.test.ts\":{\"content\":null},\"prompt-codegen.ts\":{\"content\":null},\"prompt-service-ask-question.test.ts\":{\"content\":null},\"prompt-service.ai-services.test.ts\":{\"content\":null},\"prompt-service.context-optimization.test.ts\":{\"content\":null},\"prompt-service.image-handling.test.ts\":{\"content\":null},\"prompt-service.test-utils.ts\":{\"content\":null},\"prompt-service.ts\":{\"content\":null},\"prompt-service.validation-recovery.test.ts\":{\"content\":null},\"static-prompts.ts\":{\"content\":null},\"systemprompt.test.ts\":{\"content\":null},\"systemprompt.ts\":{\"content\":null},\"token-estimator.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/prompt/function-defs\":{\"ask-question.ts\":{\"content\":null},\"codegen-planning.ts\":{\"content\":null},\"codegen-summary.ts\":{\"content\":null},\"explanation.ts\":{\"content\":null},\"generate-image.ts\":{\"content\":null},\"get-image-assets.ts\":{\"content\":null},\"get-source-code.ts\":{\"content\":null},\"optimize-context.ts\":{\"content\":null},\"read-history.ts\":{\"content\":null},\"set-summaries.ts\":{\"content\":null},\"update-history.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question/handlers\":{\"cancel-code-generation.ts\":{\"content\":null},\"code-generation.ts\":{\"content\":null},\"confirm-code-generation.ts\":{\"content\":null},\"context-optimization.ts\":{\"content\":null},\"default-action.ts\":{\"content\":null},\"handle-send-message-with-image.ts\":{\"content\":null},\"handle-send-message.ts\":{\"content\":null},\"remove-files-from-context.ts\":{\"content\":null},\"request-files-content.ts\":{\"content\":null},\"request-permissions.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-ask-question\":{\"step-ask-question-types.ts\":{\"content\":null},\"step-ask-question.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/prompt/steps\":{\"step-codegen-planning.ts\":{\"content\":null},\"step-codegen-summary.test.ts\":{\"content\":null},\"step-codegen-summary.ts\":{\"content\":null},\"step-context-optimization.test.ts\":{\"content\":null,\"dependencies\":[{\"path\":\"vitest\",\"type\":\"external\"},{\"path\":\"../../files/read-files\",\"type\":\"local\"},{\"path\":\"../../main/codegen-types\",\"type\":\"local\"},{\"path\":\"../../main/common/content-bus\",\"type\":\"local\"}]},\"step-context-optimization.ts\":{\"content\":null,\"dependencies\":[{\"path\":\"../../ai-service/common.js\",\"type\":\"local\"},{\"path\":\"../../main/codegen-types.js\",\"type\":\"local\"},{\"path\":\"../../main/common/content-bus.js\",\"type\":\"local\"},{\"path\":\"../../files/read-files.js\",\"type\":\"local\"},{\"path\":\"../function-calling.js\",\"type\":\"local\"},{\"path\":\"./steps-types.js\",\"type\":\"local\"},{\"path\":\"../token-estimator.js\",\"type\":\"local\"},{\"path\":\"./step-summarization.js\",\"type\":\"local\"},{\"path\":\"./step-validate-recover.js\",\"type\":\"local\"},{\"path\":\"./steps-utils.js\",\"type\":\"local\"},{\"path\":\"../../files/source-code-tree.js\",\"type\":\"local\"}]},\"step-ensure-context.test.ts\":{\"content\":null},\"step-ensure-context.ts\":{\"content\":null},\"step-generate-image.ts\":{\"content\":null},\"step-generate-summary.ts\":{\"content\":null},\"step-history-update.ts\":{\"content\":null},\"step-summarization.ts\":{\"content\":null},\"step-validate-recover.ts\":{\"content\":null},\"step-verify-patch.ts\":{\"content\":null},\"steps-types.ts\":{\"content\":null},\"steps-utils.ts\":{\"content\":null}},\"/Users/gtanczyk/src/codegen/src/vite-genaicode\":{\"README.md\":{\"content\":null},\"tsconfig.json\":{\"content\":null},\"vite-env.d.ts\":{\"content\":null},\"vite-genaicode-frontend.ts\":{\"content\":null},\"vite-genaicode-plugin.ts\":{\"content\":null}}}"
|
|
41
31
|
},
|
|
42
32
|
{
|
|
43
|
-
name:
|
|
44
|
-
content:
|
|
33
|
+
"name": "getImageAssets",
|
|
34
|
+
"content": "{\"/Users/gtanczyk/src/codegen/media/logo-dark.png\":{\"mimeType\":\"image/png\",\"width\":1200,\"height\":686},\"/Users/gtanczyk/src/codegen/media/logo.png\":{\"mimeType\":\"image/png\",\"width\":1200,\"height\":686},\"/Users/gtanczyk/src/codegen/src/vite-genaicode/media/demo-for-readme.gif\":{\"mimeType\":\"image/gif\",\"width\":769,\"height\":465}}"
|
|
45
35
|
},
|
|
36
|
+
{
|
|
37
|
+
"name": "readHistory",
|
|
38
|
+
"content": "2024-11-17T21:02:00.146Z: GenAIcode Context Optimization Evolution\n- Context Mgmt Milestone:\n * Full Context Preservation for Small Codebases\n * Enhanced Dependency Tracking\n * Dynamic Context Handling Refined\n- Key Improvements:\n * Removed Early Return for Small Codebases\n * Preserved Full Dependency Chains\n * Maintained Structural Integrity\n- Optimization Strategies:\n * Granular Relevance Scoring\n * Token-Aware Context Management\n * Dependency Chain Analysis\n- Implementation Details:\n * step-context-optimization.ts Updated\n * Comprehensive Test Suite Expansion\n * Robust Error Handling Added\n- Continuous Objectives:\n * Context Optimization\n * Dependency Management\n * Performance Enhancement\n- Roadmap Progress:\n 1. Context Preservation ✓\n 2. Advanced Context Mgmt\n 3. Multi-Model Support\n 4. Custom Tool Evolution\n- Current Status:\n * Source Code Optimized\n * Context Handling Improved\n * Ready for Next Iteration"
|
|
39
|
+
}
|
|
46
40
|
],
|
|
47
|
-
text:
|
|
48
|
-
cache: true
|
|
41
|
+
"text": "Sure, here is the application source code, image assets, and the history.",
|
|
42
|
+
"cache": true
|
|
49
43
|
},
|
|
50
44
|
{
|
|
51
|
-
type:
|
|
52
|
-
text: "Thank you, I'm ready to assist you with your request."
|
|
45
|
+
"type": "assistant",
|
|
46
|
+
"text": "Thank you, I'm ready to assist you with your request."
|
|
53
47
|
},
|
|
54
48
|
{
|
|
55
|
-
type:
|
|
56
|
-
text:
|
|
49
|
+
"type": "user",
|
|
50
|
+
"text": "hello"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"type": "assistant",
|
|
54
|
+
"functionCalls": [
|
|
55
|
+
{
|
|
56
|
+
"name": "requestFilesContent",
|
|
57
|
+
"args": {
|
|
58
|
+
"filePaths": [
|
|
59
|
+
"/Users/gtanczyk/src/codegen/docs/design/context_optimization_feature.md",
|
|
60
|
+
"/Users/gtanczyk/src/codegen/docs/design/token_usage_reduction.md",
|
|
61
|
+
"/Users/gtanczyk/src/codegen/src/files/source-code-tree.ts",
|
|
62
|
+
"/Users/gtanczyk/src/codegen/src/main/codegen-types.ts",
|
|
63
|
+
"/Users/gtanczyk/src/codegen/src/prompt/prompt-service.ts",
|
|
64
|
+
"/Users/gtanczyk/src/codegen/src/prompt/steps/step-context-optimization.test.ts",
|
|
65
|
+
"/Users/gtanczyk/src/codegen/src/prompt/steps/step-context-optimization.ts",
|
|
66
|
+
"/Users/gtanczyk/src/codegen/src/prompt/steps/steps-types.ts",
|
|
67
|
+
"/Users/gtanczyk/src/codegen/src/prompt/token-estimator.ts"
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "getSourceCode",
|
|
73
|
+
"args": {
|
|
74
|
+
"filePaths": [
|
|
75
|
+
"/Users/gtanczyk/src/codegen/docs/design/context_optimization_feature.md",
|
|
76
|
+
"/Users/gtanczyk/src/codegen/docs/design/token_usage_reduction.md",
|
|
77
|
+
"/Users/gtanczyk/src/codegen/src/files/source-code-tree.ts",
|
|
78
|
+
"/Users/gtanczyk/src/codegen/src/main/codegen-types.ts",
|
|
79
|
+
"/Users/gtanczyk/src/codegen/src/prompt/prompt-service.ts",
|
|
80
|
+
"/Users/gtanczyk/src/codegen/src/prompt/steps/step-context-optimization.test.ts",
|
|
81
|
+
"/Users/gtanczyk/src/codegen/src/prompt/steps/step-context-optimization.ts",
|
|
82
|
+
"/Users/gtanczyk/src/codegen/src/prompt/steps/steps-types.ts",
|
|
83
|
+
"/Users/gtanczyk/src/codegen/src/prompt/token-estimator.ts"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
]
|
|
57
88
|
},
|
|
89
|
+
{
|
|
90
|
+
"type": "user",
|
|
91
|
+
"functionResponses": [
|
|
92
|
+
{
|
|
93
|
+
"name": "requestFilesContent",
|
|
94
|
+
"content": "{\"filePaths\":[\"/Users/gtanczyk/src/codegen/docs/design/context_optimization_feature.md\",\"/Users/gtanczyk/src/codegen/docs/design/token_usage_reduction.md\",\"/Users/gtanczyk/src/codegen/src/files/source-code-tree.ts\",\"/Users/gtanczyk/src/codegen/src/main/codegen-types.ts\",\"/Users/gtanczyk/src/codegen/src/prompt/prompt-service.ts\",\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-context-optimization.test.ts\",\"/Users/gtanczyk/src/codegen/src/prompt/steps/step-context-optimization.ts\",\"/Users/gtanczyk/src/codegen/src/prompt/steps/steps-types.ts\",\"/Users/gtanczyk/src/codegen/src/prompt/token-estimator.ts\"]}"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "getSourceCode",
|
|
98
|
+
"content": "{\"/Users/gtanczyk/src/codegen/docs/design\":{\"context_optimization_feature.md\":{\"content\":\"# Context Optimization Feature Implementation Plan\\n\\n## Overview\\n\\nThis document outlines the plan for implementing a new context optimization feature in the GenAIcode prompt service. The feature aims to reduce the initial context size by summarizing file contents and determining their relevance to the user's prompt.\\n\\n## Objectives\\n\\n1. Reduce token usage in the initial context.\\n2. Improve efficiency of the AI service by focusing on relevant files.\\n3. Implement the feature as a separate step before the \\\"ask question\\\" step.\\n\\n## Implementation Steps\\n\\n### 1. Create a new file: `step-context-optimization.ts`\\n\\n- Location: `/src/prompt/steps/step-context-optimization.ts`\\n- Purpose: Implement the context optimization logic\\n\\n### 2. Implement the context optimization step\\n\\n- Create a function `executeStepContextOptimization`\\n- Parameters:\\n - `generateContentFn`: The AI service function to use\\n - `prompt`: The user's prompt\\n - `sourceCode`: The initial source code object\\n - `options`: CodegenOptions\\n\\n### 3. Context optimization logic\\n\\n- For each file in the source code:\\n - Generate a summary (1 sentence)\\n - Rate the probability of relevance to the user's prompt (0-1)\\n- Use the cheap mode of the AI service for this step\\n- Return an optimized source code object with summaries and relevance scores\\n\\n### 4. Update `prompt-service.ts`\\n\\n- Import the new `executeStepContextOptimization` function\\n- Add a new step in the `promptService` function to call `executeStepContextOptimization`\\n- Use the optimized source code for the subsequent `getSourceCode` function call\\n- Implement a warning mechanism if the cheap model doesn't provide useful summaries\\n\\n### 5. Error Handling and Fallback\\n\\n- Implement a warning system using `putSystemMessage` when summaries are not useful\\n- Ensure the process continues even if optimization fails\\n\\n### 6. Testing\\n\\n- Create unit tests for the new `executeStepContextOptimization` function\\n- Update existing tests in `prompt-service.test.ts` to account for the new step\\n\\n### 7. Documentation\\n\\n- Update the main README.md to mention the new context optimization feature\\n- Add inline documentation to the new and modified functions\\n\\n## Timeline\\n\\n1. Implementation of `step-context-optimization.ts`: 2 hours\\n2. Integration with `prompt-service.ts`: 1 hour\\n3. Testing and debugging: 2 hours\\n4. Documentation updates: 1 hour\\n\\nTotal estimated time: 6 hours\\n\\n## Future Improvements\\n\\n- Fine-tune the relevance scoring algorithm\\n- Allow users to configure the threshold for file inclusion\\n- Implement caching of file summaries for frequently used files\\n\"},\"token_usage_reduction.md\":{\"content\":\"# Token Usage Reduction in GenAICode\\n\\n## Problem Statement\\n\\nGenAICode, an AI-powered code generation and management tool, is currently facing challenges with high token usage, particularly in input tokens. This high token consumption leads to increased costs and potential performance issues. The primary source of this problem is the large amount of code context provided to the AI models during the code generation process.\\n\\n## Proposed Solutions\\n\\n### 1. Context Pruning and Relevance Filtering\\n\\n- Implement an intelligent context pruning mechanism that selectively includes only the most relevant parts of files in the context.\\n- Develop a relevance scoring algorithm based on factors such as:\\n - Proximity to the current task\\n - Frequency of usage in previous related tasks\\n - Importance of the file (e.g., core modules, frequently imported files)\\n- Allow users to specify importance levels for certain files or directories in the configuration.\\n\\n### 2. Incremental Context Loading\\n\\n- Instead of loading the entire context at once, implement an incremental context loading mechanism.\\n- Start with a minimal context and gradually expand it as needed during the code generation process.\\n- Use a sliding window approach to maintain a balance between context size and relevance.\\n\\n### 3. Code Summarization\\n\\n- Implement a code summarization feature that generates concise representations of code sections.\\n- Use these summaries instead of full code blocks when providing context to the AI model.\\n- Develop language-specific summarization techniques for improved accuracy.\\n\\n### 4. Caching and Reuse of Previous Outputs\\n\\n- Implement a caching mechanism for previously generated code snippets and their corresponding contexts.\\n- Before sending a new request to the AI model, check if a similar context has been processed before and reuse the cached output if appropriate.\\n- Implement a similarity metric to determine when cached results can be reused.\\n\\n### 5. Token-Aware Prompt Engineering\\n\\n- Redesign prompts to be more token-efficient without losing necessary information.\\n- Develop a set of shorthand notations or abbreviations for common programming concepts to reduce token count.\\n- Implement dynamic prompt generation that adapts based on the current token usage and remaining quota.\\n\\n### 6. Compression Techniques\\n\\n- Implement lossless compression for code snippets before sending them to the AI model.\\n- Develop a custom tokenization scheme that is more efficient for code representation.\\n- Use techniques like variable name shortening or consistent formatting to reduce token count without losing information.\\n\\n### 7. Selective Code Inclusion\\n\\n- Implement a feature that allows users to explicitly mark sections of code for inclusion or exclusion from the context.\\n- Develop heuristics to automatically identify and exclude boilerplate code, comments, or other less relevant sections.\\n\\n## Impact Analysis\\n\\n### Potential Benefits\\n\\n1. Reduced Costs: By significantly reducing token usage, we can lower the operational costs associated with API calls to AI services.\\n2. Improved Performance: Smaller contexts can lead to faster processing times and quicker response from AI models.\\n3. Increased Efficiency: More focused contexts can potentially lead to more accurate and relevant code suggestions.\\n4. Scalability: Reduced token usage allows for handling larger projects and more complex code bases without hitting token limits.\\n\\n### Potential Risks\\n\\n1. Loss of Context: Aggressive pruning or summarization might lead to loss of important context, potentially affecting the quality of generated code.\\n2. Increased Complexity: Some proposed solutions (e.g., incremental loading, caching) add complexity to the system, which could lead to new types of bugs or maintenance challenges.\\n3. User Experience: Changes in how context is managed might require users to adapt their workflow or learn new configuration options.\\n\\n## Implementation Considerations\\n\\n1. Modular Design: Implement these features in a modular way, allowing easy enabling/disabling and configuration of different strategies.\\n2. Configuration Options: Provide users with granular control over token reduction strategies through configuration files.\\n3. Monitoring and Metrics: Implement robust monitoring to track token usage, strategy effectiveness, and impact on code quality.\\n4. Fallback Mechanisms: Design systems to gracefully handle cases where token reduction strategies might fail or be insufficient.\\n5. AI Model Compatibility: Ensure that implemented strategies are compatible with different AI models used by GenAICode (vertex-ai-claude, chat-gpt, etc.).\\n6. Testing and Validation: Develop a comprehensive testing suite to validate the effectiveness of token reduction strategies and ensure they don't negatively impact code generation quality.\\n7. Gradual Rollout: Consider implementing these changes incrementally, starting with the most impactful and least risky strategies.\\n8. User Feedback Loop: Establish a mechanism to collect and incorporate user feedback on the effectiveness and impact of token reduction strategies.\\n\\nBy carefully implementing these strategies and considering their impacts, GenAICode can significantly reduce its token usage, leading to cost savings and performance improvements while maintaining or even enhancing the quality of its code generation capabilities.\\n\"}},\"/Users/gtanczyk/src/codegen/src/files\":{\"source-code-tree.ts\":{\"content\":\"import path from 'path';\\nimport { SourceCodeMap, FileContent, FileSummary } from '../files/read-files.js';\\nimport { rcConfig } from '../main/config.js';\\n\\n/**\\n * Type guard to check if an object is a FileContent with dependencies\\n */\\nfunction hasContent(obj: FileContent | FileSummary): obj is FileContent {\\n return 'content' in obj;\\n}\\n\\n/**\\n * Type guard to check if an object is a FileSummary with dependencies\\n */\\nfunction hasSummary(obj: FileContent | FileSummary): obj is FileSummary {\\n return 'summary' in obj;\\n}\\n\\n/**\\n * Directory structure representing source code files with their content or summaries and dependencies\\n */\\nexport type SourceCodeTree = {\\n [directoryPath: string]: {\\n [filePath: string]: FileContent | FileSummary;\\n };\\n};\\n\\n/**\\n * Converts flat SourceCodeMap into a directory tree structure\\n */\\nexport function getSourceCodeTree(sourceCode: SourceCodeMap): SourceCodeTree {\\n const result: SourceCodeTree = {};\\n\\n for (const [filePath, fileData] of Object.entries(sourceCode)) {\\n if (!filePath.startsWith(rcConfig.rootDir)) {\\n continue;\\n }\\n\\n const dirPath = path.dirname(filePath);\\n const fileName = path.basename(filePath);\\n if (!result[dirPath]) {\\n result[dirPath] = {};\\n }\\n\\n // Handle both content and summary cases while preserving dependencies\\n if (hasContent(fileData)) {\\n result[dirPath][fileName] = {\\n content: fileData.content,\\n ...(fileData.dependencies && { dependencies: fileData.dependencies }),\\n };\\n } else if (hasSummary(fileData)) {\\n result[dirPath][fileName] = {\\n summary: fileData.summary,\\n ...(fileData.dependencies && { dependencies: fileData.dependencies }),\\n };\\n }\\n }\\n\\n return result;\\n}\\n\\n/**\\n * Converts directory tree structure back into flat SourceCodeMap\\n */\\nexport function parseSourceCodeTree(sourceCodeTree: SourceCodeTree): SourceCodeMap {\\n const result: SourceCodeMap = {};\\n\\n for (const [dirPath, files] of Object.entries(sourceCodeTree)) {\\n for (const [filePath, fileData] of Object.entries(files)) {\\n const fullPath = `${dirPath}/${filePath}`;\\n\\n // Handle both content and summary cases while preserving dependencies\\n if (hasContent(fileData)) {\\n result[fullPath] = {\\n content: fileData.content,\\n ...(fileData.dependencies && { dependencies: fileData.dependencies }),\\n };\\n } else if (hasSummary(fileData)) {\\n result[fullPath] = {\\n summary: fileData.summary,\\n ...(fileData.dependencies && { dependencies: fileData.dependencies }),\\n };\\n }\\n }\\n }\\n\\n return result;\\n}\\n\",\"dependencies\":[{\"path\":\"path\",\"type\":\"external\",\"direct\":true,\"importPath\":\"path\"}]}},\"/Users/gtanczyk/src/codegen/src/main\":{\"codegen-types.ts\":{\"summary\":\"Type defs\",\"dependencies\":[]}},\"/Users/gtanczyk/src/codegen/src/prompt\":{\"prompt-service.ts\":{\"summary\":\"AI prompt service managing content generation, context optimization, hooks\"},\"token-estimator.ts\":{\"content\":\"/**\\n * Estimates the token count of a given string.\\n * Uses average token-to-word ratios for plain text and code.\\n *\\n * @param input - The string to estimate token count for\\n * @returns The estimated token count\\n */\\nexport function estimateTokenCount(input: string): number {\\n // Trim and check for empty input\\n const trimmedInput = input.trim();\\n if (!trimmedInput) return 0;\\n\\n // Determine if the input is code or plain text\\n const isCode = containsCode(trimmedInput);\\n\\n // Split the input into words\\n const words = trimmedInput.split(/\\\\s+/);\\n\\n // Use average tokens per word based on content type\\n const averageTokensPerWord = isCode ? 1.25 : 0.65;\\n\\n // Estimate token count\\n const tokenCount = Math.ceil(words.length * averageTokensPerWord);\\n\\n return tokenCount;\\n}\\n\\n/**\\n * Heuristically determines if the text contains code.\\n */\\nfunction containsCode(text: string): boolean {\\n // Check for code indicators\\n const codeIndicators = /[{}()[\\\\];,.<>+\\\\-*/%=&|^!~?:#@]|function|const|let|var|if|else|for|while|return|import|export/;\\n return codeIndicators.test(text);\\n}\\n\"}},\"/Users/gtanczyk/src/codegen/src/prompt/steps\":{\"step-context-optimization.test.ts\":{\"content\":\"import { describe, it, expect, vi, beforeEach } from 'vitest';\\nimport { executeStepContextOptimization } from './step-context-optimization';\\nimport { FileContent, getSourceCode } from '../../files/read-files';\\nimport { SourceCodeTree } from '../../files/source-code-tree';\\nimport { StepResult } from './steps-types';\\nimport { CodegenOptions } from '../../main/codegen-types';\\nimport { putSystemMessage } from '../../main/common/content-bus';\\nimport '../../main/config.js';\\nimport '../../files/find-files.js';\\nimport { PromptItem } from '../../ai-service/common';\\n\\n// Mock dependencies\\nvi.mock('../../files/read-files');\\nvi.mock('../../files/find-files.js', () => ({\\n getSourceFiles: () => [],\\n getImageAssetFiles: () => [],\\n refreshFiles: () => null,\\n}));\\nvi.mock('../../main/common/content-bus');\\nvi.mock('../token-estimator', () => ({\\n estimateTokenCount: vi.fn((content: string) => {\\n // Simple mock implementation that returns length of content as token count\\n return content ? content.length : 0;\\n }),\\n}));\\nvi.mock('./step-summarization', () => ({\\n getSummary: vi.fn().mockReturnValue({ summary: 'Test summary', dependencies: [{ path: 'test-dep', type: 'local' }] }),\\n}));\\nvi.mock('../../main/config.js', () => ({\\n rootDir: '/test',\\n rcConfig: {\\n rootDir: '/test',\\n extensions: ['.js', '.ts', '.tsx', '.jsx'],\\n },\\n importantContext: {},\\n sourceExtensions: ['.ts'],\\n}));\\n\\ndescribe('executeStepContextOptimization', () => {\\n const mockGenerateContentFn = vi.fn();\\n const mockOptions: CodegenOptions = {\\n aiService: 'vertex-ai',\\n askQuestion: false,\\n };\\n\\n beforeEach(() => {\\n vi.clearAllMocks();\\n mockGenerateContentFn.mockReset();\\n });\\n\\n describe('Source code tree transformation', () => {\\n it('should correctly transform source code between flat and tree structures', async () => {\\n // Mock source code data\\n const mockSourceCode = {\\n '/test/file1.ts': { content: 'content1' + Array.from(Array(10000).keys()).join(',') },\\n '/test/file2.ts': { content: 'content2' },\\n };\\n\\n const mockSourceCodeTree: SourceCodeTree = {\\n '/test': {\\n 'file1.ts': { content: 'content1' + Array.from(Array(10000).keys()).join(',') },\\n 'file2.ts': { content: 'content2' },\\n },\\n };\\n\\n vi.mocked(getSourceCode).mockReturnValue(mockSourceCode);\\n\\n // Mock optimization response with high relevance scores\\n mockGenerateContentFn.mockResolvedValueOnce([\\n {\\n name: 'optimizeContext',\\n args: {\\n userPrompt: 'test prompt',\\n optimizedContext: [\\n { filePath: '/test/file1.ts', relevance: 0.9 },\\n { filePath: '/test/file2.ts', relevance: 0.8 },\\n ],\\n },\\n },\\n ]);\\n\\n const result = await executeStepContextOptimization(\\n mockGenerateContentFn,\\n [\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: JSON.stringify(mockSourceCodeTree),\\n },\\n ],\\n },\\n ],\\n mockOptions,\\n );\\n\\n expect(result).toBe(StepResult.CONTINUE);\\n expect(putSystemMessage).toHaveBeenCalledWith(\\n 'Context optimization in progress.',\\n expect.arrayContaining([\\n ['/test/file1.ts', 0.9],\\n ['/test/file2.ts', 0.8],\\n ]),\\n );\\n });\\n\\n it('should handle empty source code tree', async () => {\\n const emptySourceCode = {};\\n const emptySourceCodeTree = {};\\n\\n vi.mocked(getSourceCode).mockReturnValue(emptySourceCode);\\n\\n mockGenerateContentFn.mockResolvedValueOnce([\\n {\\n name: 'optimizeContext',\\n args: {\\n userPrompt: 'test prompt',\\n optimizedContext: [],\\n },\\n },\\n ]);\\n\\n const result = await executeStepContextOptimization(\\n mockGenerateContentFn,\\n [\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: JSON.stringify(emptySourceCodeTree),\\n },\\n ],\\n },\\n ],\\n mockOptions,\\n );\\n\\n expect(result).toBe(StepResult.CONTINUE);\\n expect(putSystemMessage).toHaveBeenCalledWith(\\n 'Context optimization is not needed, because the code base is small.',\\n );\\n });\\n });\\n\\n describe('Multiple getSourceCode responses handling', () => {\\n // This test verifies that when clearing previous getSourceCode responses:\\n // 1. Directory structure is preserved\\n // 2. File content is set to null\\n // 3. The overall structure of the conversation remains intact\\n it('should clear previous getSourceCode responses while preserving structure', async () => {\\n const mockSourceCode = {\\n '/test/file1.ts': { content: 'content1' + Array.from(Array(10000).keys()).join(',') },\\n };\\n\\n const mockSourceCodeTree: SourceCodeTree = {\\n '/test': {\\n 'file1.ts': { content: 'content1' + Array.from(Array(10000).keys()).join(',') },\\n },\\n };\\n\\n vi.mocked(getSourceCode).mockReturnValue(mockSourceCode);\\n\\n mockGenerateContentFn.mockResolvedValueOnce([\\n {\\n name: 'optimizeContext',\\n args: {\\n userPrompt: 'test prompt',\\n optimizedContext: [{ filePath: '/test/file1.ts', relevance: 0.9 }],\\n },\\n },\\n ]);\\n\\n const prompt: PromptItem[] = [\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: JSON.stringify({ '/test': { 'old-file.ts': { content: 'old content' } } }),\\n },\\n ],\\n },\\n {\\n type: 'assistant',\\n text: 'Some response',\\n },\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: JSON.stringify(mockSourceCodeTree),\\n },\\n ],\\n },\\n ];\\n\\n const result = await executeStepContextOptimization(mockGenerateContentFn, prompt, mockOptions);\\n\\n expect(result).toBe(StepResult.CONTINUE);\\n\\n // Verify that previous responses maintain structure but clear content\\n const expectedStructure = {\\n '/test': {\\n 'old-file.ts': { content: null },\\n },\\n };\\n expect(JSON.parse(prompt[0].functionResponses![0].content!)).toEqual(expectedStructure);\\n\\n // Verify that structure was preserved\\n expect(prompt[0].type).toBe('user');\\n expect(prompt[0].functionResponses![0].name).toBe('getSourceCode');\\n // Verify that non-getSourceCode items were preserved\\n expect(prompt[1].type).toBe('assistant');\\n expect(prompt[1].text).toBe('Some response');\\n });\\n\\n // This test verifies that when handling multiple responses:\\n // 1. Each response maintains its directory structure\\n // 2. Content is cleared (set to null) for all previous responses\\n // 3. The latest response remains unchanged\\n it('should handle multiple responses with different content', async () => {\\n const mockSourceCode = {\\n '/test/file1.ts': { content: 'content1' + Array.from(Array(10000).keys()).join(',') },\\n '/test/file2.ts': { content: 'content2' },\\n };\\n\\n const mockSourceCodeTree: SourceCodeTree = {\\n '/test': {\\n 'file1.ts': { content: 'content1' + Array.from(Array(10000).keys()).join(',') },\\n 'file2.ts': { content: 'content2' },\\n },\\n };\\n\\n vi.mocked(getSourceCode).mockReturnValue(mockSourceCode);\\n\\n mockGenerateContentFn.mockResolvedValueOnce([\\n {\\n name: 'optimizeContext',\\n args: {\\n userPrompt: 'test prompt',\\n optimizedContext: [\\n { filePath: '/test/file1.ts', relevance: 0.9 },\\n { filePath: '/test/file2.ts', relevance: 0.8 },\\n ],\\n },\\n },\\n ]);\\n\\n const prompt: PromptItem[] = [\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: JSON.stringify({ '/test': { 'file1.ts': { content: 'old content 1' } } }),\\n },\\n ],\\n },\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: JSON.stringify({ '/test': { 'file2.ts': { content: 'old content 2' } } }),\\n },\\n ],\\n },\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: JSON.stringify(mockSourceCodeTree),\\n },\\n ],\\n },\\n ];\\n\\n const result = await executeStepContextOptimization(mockGenerateContentFn, prompt, mockOptions);\\n\\n expect(result).toBe(StepResult.CONTINUE);\\n // Verify that previous responses maintain structure but clear content\\n prompt.slice(0, -1).forEach((item) => {\\n if (item.type === 'user' && item.functionResponses) {\\n const response = item.functionResponses.find((r) => r.name === 'getSourceCode');\\n const parsedContent = JSON.parse(response!.content!);\\n // Check that structure is preserved but content is null\\n expect(parsedContent).toHaveProperty('/test');\\n Object.values(parsedContent['/test']).forEach((file) => {\\n expect((file as FileContent).content).toBe(null);\\n });\\n }\\n });\\n });\\n\\n it('should handle edge case with no getSourceCode responses', async () => {\\n const mockSourceCode = {\\n '/test/file1.ts': { content: 'content1' + Array.from(Array(10000).keys()).join(',') },\\n };\\n\\n vi.mocked(getSourceCode).mockReturnValue(mockSourceCode);\\n\\n const prompt: PromptItem[] = [\\n {\\n type: 'user',\\n text: 'Some user message',\\n },\\n {\\n type: 'assistant',\\n text: 'Some assistant response',\\n },\\n ];\\n\\n const result = await executeStepContextOptimization(mockGenerateContentFn, prompt, mockOptions);\\n\\n expect(result).toBe(StepResult.CONTINUE);\\n // Verify that the prompt structure remains unchanged\\n expect(prompt).toHaveLength(2);\\n expect(prompt[0].type).toBe('user');\\n expect(prompt[0].text).toBe('Some user message');\\n expect(prompt[1].type).toBe('assistant');\\n expect(prompt[1].text).toBe('Some assistant response');\\n });\\n\\n it('should handle edge case with empty functionResponses', async () => {\\n const mockSourceCode = {\\n '/test/file1.ts': { content: 'content1' + Array.from(Array(10000).keys()).join(',') },\\n };\\n\\n vi.mocked(getSourceCode).mockReturnValue(mockSourceCode);\\n\\n const prompt: PromptItem[] = [\\n {\\n type: 'user',\\n functionResponses: [],\\n },\\n {\\n type: 'user',\\n functionResponses: undefined,\\n },\\n ];\\n\\n const result = await executeStepContextOptimization(mockGenerateContentFn, prompt, mockOptions);\\n\\n expect(result).toBe(StepResult.CONTINUE);\\n // Verify that the prompt structure remains unchanged\\n expect(prompt).toHaveLength(2);\\n expect(prompt[0].type).toBe('user');\\n expect(prompt[0].functionResponses).toEqual([]);\\n expect(prompt[1].type).toBe('user');\\n expect(prompt[1].functionResponses).toBeUndefined();\\n });\\n });\\n\\n describe('Context optimization process', () => {\\n it('should optimize context based on relevance scores', async () => {\\n const mockSourceCode = {\\n '/test/high-relevance.ts': { content: 'important content' + Array.from(Array(10000).keys()).join(',') },\\n '/test/medium-relevance.ts': { content: 'somewhat important' },\\n '/test/low-relevance.ts': { content: 'not important' },\\n };\\n\\n const mockSourceCodeTree: SourceCodeTree = {\\n '/test': {\\n 'high-relevance.ts': { content: 'important content' },\\n 'medium-relevance.ts': { content: 'somewhat important' },\\n 'low-relevance.ts': { content: 'not important' },\\n },\\n };\\n\\n vi.mocked(getSourceCode).mockReturnValue(mockSourceCode);\\n\\n mockGenerateContentFn.mockResolvedValueOnce([\\n {\\n name: 'optimizeContext',\\n args: {\\n userPrompt: 'test prompt',\\n optimizedContext: [\\n { filePath: '/test/high-relevance.ts', relevance: 0.9 },\\n { filePath: '/test/medium-relevance.ts', relevance: 0.6 },\\n { filePath: '/test/low-relevance.ts', relevance: 0.2 },\\n ],\\n },\\n },\\n ]);\\n\\n const result = await executeStepContextOptimization(\\n mockGenerateContentFn,\\n [\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: JSON.stringify(mockSourceCodeTree),\\n },\\n ],\\n },\\n ],\\n mockOptions,\\n );\\n\\n expect(result).toBe(StepResult.CONTINUE);\\n expect(putSystemMessage).toHaveBeenCalledWith(\\n 'Context optimization in progress.',\\n expect.arrayContaining([\\n ['/test/high-relevance.ts', 0.9],\\n ['/test/medium-relevance.ts', 0.6],\\n ]),\\n );\\n // Low relevance file should not be included\\n expect(putSystemMessage).not.toHaveBeenCalledWith(\\n 'Context optimization in progress.',\\n expect.arrayContaining(['/test/low-relevance.ts', 0.2]),\\n );\\n });\\n\\n it('should handle optimization failure gracefully', async () => {\\n const mockSourceCode = {\\n '/test/file.ts': { content: 'test content'.repeat(1000) }, // Make it large enough to trigger optimization\\n };\\n\\n const mockSourceCodeTree: SourceCodeTree = {\\n '/test': {\\n 'file.ts': { content: 'test content'.repeat(1000) },\\n },\\n };\\n\\n vi.mocked(getSourceCode).mockReturnValue(mockSourceCode);\\n\\n mockGenerateContentFn.mockResolvedValueOnce([\\n {\\n name: 'optimizeContext',\\n args: {\\n userPrompt: 'test prompt',\\n optimizedContext: [], // Empty context indicates optimization failure\\n },\\n },\\n ]);\\n\\n const result = await executeStepContextOptimization(\\n mockGenerateContentFn,\\n [\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: JSON.stringify(mockSourceCodeTree),\\n },\\n ],\\n },\\n ],\\n mockOptions,\\n );\\n\\n expect(result).toBe(StepResult.CONTINUE);\\n expect(putSystemMessage).toHaveBeenCalledWith(\\n 'Warning: Context optimization failed to produce useful summaries for all batches. Proceeding with current context.',\\n );\\n });\\n });\\n\\n describe('Edge cases and error handling', () => {\\n beforeEach(() => {\\n const mockSourceCode = {\\n '/test/file1.ts': { content: 'content1' + Array.from(Array(10000).keys()).join(',') },\\n };\\n\\n vi.mocked(getSourceCode).mockReturnValue(mockSourceCode);\\n });\\n\\n it('should handle missing source code response', async () => {\\n const result = await executeStepContextOptimization(\\n mockGenerateContentFn,\\n [], // Empty prompt array\\n mockOptions,\\n );\\n\\n expect(result).toBe(StepResult.CONTINUE);\\n expect(putSystemMessage).not.toHaveBeenCalledWith('Context optimization in progress.');\\n });\\n\\n it('should handle invalid JSON in source code response', async () => {\\n await expect(\\n executeStepContextOptimization(\\n mockGenerateContentFn,\\n [\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: 'invalid json',\\n },\\n ],\\n },\\n ],\\n mockOptions,\\n ),\\n ).rejects.toThrow('Unexpected token');\\n });\\n\\n it('should handle errors during optimization process', async () => {\\n vi.mocked(getSourceCode).mockImplementation(() => {\\n throw new Error('Unexpected error');\\n });\\n\\n await expect(\\n executeStepContextOptimization(\\n mockGenerateContentFn,\\n [\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: '{}',\\n },\\n ],\\n },\\n ],\\n mockOptions,\\n ),\\n ).rejects.toThrow('Unexpected error');\\n });\\n });\\n\\n describe('Token count handling', () => {\\n it('should respect MAX_TOTAL_TOKENS limit', async () => {\\n // Create source code that exceeds token limit\\n const largeContent = 'a'.repeat(12000); // Exceeds MAX_TOTAL_TOKENS (10000)\\n const smallContent = 'b'.repeat(3000);\\n\\n const mockSourceCode = {\\n '/test/large-file.ts': { content: largeContent },\\n '/test/small-file.ts': { content: smallContent },\\n };\\n\\n const mockSourceCodeTree: SourceCodeTree = {\\n '/test': {\\n 'large-file.ts': { content: largeContent },\\n 'small-file.ts': { content: smallContent },\\n },\\n };\\n\\n vi.mocked(getSourceCode).mockReturnValue(mockSourceCode);\\n\\n mockGenerateContentFn.mockResolvedValueOnce([\\n {\\n name: 'optimizeContext',\\n args: {\\n userPrompt: 'test prompt',\\n optimizedContext: [\\n { filePath: '/test/large-file.ts', relevance: 0.9 },\\n { filePath: '/test/small-file.ts', relevance: 0.8 },\\n ],\\n },\\n },\\n ]);\\n\\n const result = await executeStepContextOptimization(\\n mockGenerateContentFn,\\n [\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'getSourceCode',\\n content: JSON.stringify(mockSourceCodeTree),\\n },\\n ],\\n },\\n ],\\n mockOptions,\\n );\\n\\n expect(result).toBe(StepResult.CONTINUE);\\n expect(putSystemMessage).toHaveBeenCalledWith(\\n 'Context optimization completed successfully.',\\n expect.objectContaining({\\n tokensBefore: expect.any(Number),\\n tokensAfter: expect.any(Number),\\n contentTokenCount: expect.any(Number),\\n summaryTokenCount: expect.any(Number),\\n percentageReduced: expect.stringContaining('%'),\\n }),\\n );\\n });\\n });\\n});\\n\",\"dependencies\":[{\"path\":\"vitest\",\"type\":\"external\"},{\"path\":\"../../files/read-files\",\"type\":\"local\"},{\"path\":\"../../main/codegen-types\",\"type\":\"local\"},{\"path\":\"../../main/common/content-bus\",\"type\":\"local\"}]},\"step-context-optimization.ts\":{\"content\":\"import { GenerateContentFunction, PromptItem, FunctionCall, GenerateContentArgs } from '../../ai-service/common.js';\\nimport { CodegenOptions } from '../../main/codegen-types.js';\\nimport { putSystemMessage } from '../../main/common/content-bus.js';\\nimport { FileContent, getSourceCode, SourceCodeMap } from '../../files/read-files.js';\\nimport { getFunctionDefs } from '../function-calling.js';\\nimport { StepResult } from './steps-types.js';\\nimport { estimateTokenCount } from '../token-estimator.js';\\nimport { getSummary } from './step-summarization.js';\\nimport { validateAndRecoverSingleResult } from './step-validate-recover.js';\\nimport { getSourceCodeResponse } from './steps-utils.js';\\nimport { getSourceCodeTree, parseSourceCodeTree, SourceCodeTree } from '../../files/source-code-tree.js';\\n\\nconst 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:\\n\\n1. **Relevance and Dependency Analysis**:\\n - Rate the **relevance** of each file to the user's prompt on a scale from **0 to 1**, using the following guidelines:\\n - **0.0 – 0.3 (Not Relevant)**: The file has no apparent connection to the user's prompt.\\n - **0.3 – 0.7 (Somewhat Relevant)**: The file has minor or indirect relevance to the prompt.\\n - **0.7 – 0.9 (Moderately Relevant)**: The file is related and could contribute to addressing the prompt.\\n - **0.9 – 1.0 (Highly Relevant)**: The file is directly related and is important for addressing the prompt.\\n \\n - **Evaluation Criteria**:\\n - **Direct Relevance**: Does the file directly implement features mentioned in the prompt?\\n - **Dependency Chain**: Is the file part of a dependency chain of relevant files?\\n - **Keyword Matching**: Does the file contain keywords or topics from the prompt?\\n - **Dependency Importance**: Is the file a critical dependency for other relevant files?\\n\\n2. **Dependency-Aware Optimization**:\\n - Consider both direct and indirect dependencies\\n - Prioritize files that are:\\n - Directly relevant to the prompt\\n - Dependencies of highly relevant files\\n - Part of important dependency chains\\n - Handle dependency chains intelligently:\\n - Include critical dependencies even if they seem less relevant\\n - Consider the full dependency tree when evaluating relevance\\n - Avoid breaking dependency chains of important files\\n\\n3. **Token-Aware Optimization**:\\n - Balance relevance against token usage\\n - Consider the combined token cost of dependency chains\\n - Prioritize files where the relevance justifies the token usage\\n - Consider the token cost of including entire dependency chains\\n\\n4. **Function Call Response**:\\n - Call the \\\\`optimizeContext\\\\` function with:\\n - \\\\`\\\"userPrompt\\\"\\\\`: The original prompt\\n - \\\\`\\\"optimizedContext\\\"\\\\`: Array of objects containing:\\n - \\\\`\\\"filePath\\\"\\\\`: Absolute file path\\n - \\\\`\\\"relevance\\\"\\\\`: Calculated relevance score (0 to 1)\\n\\n**Important Guidelines**:\\n- **Only include files from \\\\`getSourceCode\\\\` response**\\n- **Do not guess or infer additional files**\\n- **Evaluate each file individually and as part of dependency chains**\\n- **Consider both direct and indirect dependencies**\\n- **Ensure proper JSON formatting**\\n- **Include full file paths**\\n- **Filter out low-relevance files (< 0.5)**\\n- **Maintain dependency chain integrity**\\n\\nNow could you please analyze the source code and return me the optimized context?\\n`;\\n\\nconst MAX_TOTAL_TOKENS = 10000;\\n\\nexport async function executeStepContextOptimization(\\n generateContentFn: GenerateContentFunction,\\n prompt: PromptItem[],\\n options: CodegenOptions,\\n): Promise<StepResult> {\\n const fullSourceCode = getSourceCode({ forceAll: true }, options);\\n const tokensBefore = estimateTokenCount(JSON.stringify(fullSourceCode));\\n\\n const sourceCodeResponse = getSourceCodeResponse(prompt);\\n if (!sourceCodeResponse || !sourceCodeResponse.content) {\\n console.warn('Could not find source code response, something is wrong, but lets continue anyway.');\\n return StepResult.CONTINUE;\\n }\\n\\n if (tokensBefore < MAX_TOTAL_TOKENS) {\\n putSystemMessage('Context optimization is not needed, because the code base is small.');\\n\\n sourceCodeResponse.content = JSON.stringify(getSourceCodeTree(fullSourceCode));\\n\\n return StepResult.CONTINUE;\\n }\\n\\n const sourceCode = parseSourceCodeTree(JSON.parse(sourceCodeResponse.content) as SourceCodeTree);\\n\\n try {\\n putSystemMessage('Context optimization is starting for large codebase');\\n\\n const optimizationPrompt: PromptItem[] = [\\n ...prompt,\\n {\\n type: 'assistant',\\n 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?',\\n },\\n {\\n type: 'user',\\n text: OPTIMIZATION_PROMPT,\\n },\\n ];\\n\\n const request: GenerateContentArgs = [optimizationPrompt, getFunctionDefs(), 'optimizeContext', 0.2, true, options];\\n let result = await generateContentFn(...request);\\n result = await validateAndRecoverSingleResult(request, result, generateContentFn);\\n\\n const [optimizedContext, irrelevantFiles] = parseOptimizationResult(fullSourceCode, result);\\n if (!optimizedContext) {\\n putSystemMessage(`Warning: Context optimization failed. We need to abort.`);\\n return StepResult.BREAK;\\n }\\n\\n if (optimizedContext.length === 0) {\\n putSystemMessage(\\n 'Warning: Context optimization failed to produce useful summaries for all batches. Proceeding with current context.',\\n );\\n return StepResult.CONTINUE;\\n }\\n\\n putSystemMessage('Context optimization in progress.', Array.from(optimizedContext));\\n\\n const [optimizedSourceCode, contentTokenCount, summaryTokenCount] = optimizeSourceCode(\\n sourceCode,\\n fullSourceCode,\\n Array.from(optimizedContext),\\n irrelevantFiles,\\n );\\n\\n const tokensAfter = estimateTokenCount(JSON.stringify(optimizedSourceCode));\\n const percentageReduced = ((tokensBefore - tokensAfter) / tokensBefore) * 100;\\n\\n // Clear previous getSourceCode responses\\n clearPreviousSourceCodeResponses(prompt, irrelevantFiles);\\n\\n prompt.push(\\n {\\n type: 'assistant',\\n functionCalls: [\\n {\\n name: 'requestFilesContent',\\n args: {\\n filePaths: Object.keys(optimizedSourceCode),\\n },\\n },\\n {\\n name: 'getSourceCode',\\n args: {\\n filePaths: Object.keys(optimizedSourceCode),\\n },\\n },\\n ],\\n },\\n {\\n type: 'user',\\n functionResponses: [\\n {\\n name: 'requestFilesContent',\\n content: JSON.stringify({ filePaths: Object.keys(optimizedSourceCode) }),\\n },\\n {\\n name: 'getSourceCode',\\n content: JSON.stringify(getSourceCodeTree(optimizedSourceCode)),\\n },\\n ],\\n cache: true,\\n },\\n );\\n\\n putSystemMessage('Context optimization completed successfully.', {\\n tokensBefore,\\n tokensAfter,\\n contentTokenCount,\\n summaryTokenCount,\\n percentageReduced: percentageReduced.toFixed(2) + '%',\\n });\\n return StepResult.CONTINUE;\\n } catch (error) {\\n putSystemMessage('Error: Context optimization failed. This is unexpected.');\\n console.error('Context optimization error:', error);\\n return StepResult.BREAK;\\n }\\n}\\n\\nfunction parseOptimizationResult(\\n fullSourceCode: SourceCodeMap,\\n calls: FunctionCall[],\\n): [[string, number][], Set<string>] {\\n const optimizeCall = calls.find((call) => call.name === 'optimizeContext');\\n if (!optimizeCall || !optimizeCall.args || !optimizeCall.args.optimizedContext) {\\n return [[], new Set()];\\n }\\n\\n let totalTokens = 0;\\n const result: [filePath: string, relevance: number][] = [];\\n const relevantFiles = new Set<string>();\\n const irrelevantFiles = new Set<string>();\\n\\n // First pass: collect initially relevant files and track irrelevant ones\\n for (const item of optimizeCall.args.optimizedContext as { filePath: string; relevance: number }[]) {\\n if (item.relevance >= 0.5) {\\n relevantFiles.add(item.filePath);\\n } else {\\n irrelevantFiles.add(item.filePath);\\n }\\n }\\n\\n // Add files which are in full source and are not in the optimized context\\n for (const filePath in fullSourceCode) {\\n if (!relevantFiles.has(filePath) && !irrelevantFiles.has(filePath)) {\\n irrelevantFiles.add(filePath);\\n }\\n }\\n\\n // Second pass: calculate final relevance including dependency weights\\n for (const item of (optimizeCall.args.optimizedContext as { filePath: string; relevance: number }[]).sort((a, b) =>\\n a.relevance > b.relevance ? -1 : 1,\\n )) {\\n const { filePath, relevance } = item;\\n if (relevance < 0.5) {\\n break;\\n }\\n\\n // Calculate dependency weight (0-0.3) and add to base relevance\\n const depWeight = calculateDependencyWeight(filePath, fullSourceCode, relevantFiles);\\n const finalRelevance = Math.min(1, relevance + depWeight);\\n\\n const content =\\n (fullSourceCode[filePath] && 'content' in fullSourceCode[filePath]\\n ? fullSourceCode[filePath]?.content\\n : undefined) ?? '';\\n\\n // Get all dependencies for token counting\\n const allDeps = getAllDependencies(filePath, fullSourceCode);\\n const depsContent = Array.from(allDeps)\\n .map(\\n (dep) =>\\n (fullSourceCode[dep] && 'content' in fullSourceCode[dep] ? fullSourceCode[dep]?.content : undefined) ?? '',\\n )\\n .join('');\\n\\n totalTokens += estimateTokenCount(content + depsContent);\\n result.push([item.filePath, finalRelevance]);\\n\\n // Break if we exceed token limit and the file isn't highly relevant\\n if (totalTokens > MAX_TOTAL_TOKENS && finalRelevance < 0.7) {\\n break;\\n }\\n }\\n\\n return [result, irrelevantFiles];\\n}\\n\\nfunction optimizeSourceCode(\\n sourceCode: SourceCodeMap,\\n fullSourceCode: SourceCodeMap,\\n optimizedContext: [filePath: string, relevance: number][],\\n irrelevantFiles: Set<string>,\\n): [optimizedSourceCode: SourceCodeMap, contentTokenCount: number, summaryTokenCount: number] {\\n const optimizedSourceCode: SourceCodeMap = {};\\n let contentTokenCount = 0;\\n let summaryTokenCount = 0;\\n\\n // Create a set of all required files (including dependencies)\\n const requiredFiles = new Set<string>();\\n for (const [path] of optimizedContext) {\\n requiredFiles.add(path);\\n // Add all dependencies\\n const deps = getAllDependencies(path, fullSourceCode);\\n deps.forEach((dep) => requiredFiles.add(dep));\\n }\\n\\n for (const [path] of Object.entries(fullSourceCode)) {\\n const isRequired = requiredFiles.has(path);\\n const isIrrelevant = irrelevantFiles.has(path);\\n const summary = getSummary(path);\\n const content =\\n (fullSourceCode[path] && 'content' in fullSourceCode[path] ? fullSourceCode[path]?.content : undefined) ?? null;\\n const dependencies =\\n fullSourceCode[path] && 'dependencies' in fullSourceCode[path] ? fullSourceCode[path]?.dependencies : undefined;\\n\\n if (isRequired && content && !(sourceCode[path] && 'content' in sourceCode[path])) {\\n contentTokenCount += estimateTokenCount(content);\\n optimizedSourceCode[path] = {\\n content,\\n ...(dependencies && !isIrrelevant && { dependencies }),\\n };\\n } else if (summary && !isIrrelevant) {\\n summaryTokenCount += estimateTokenCount(summary.summary);\\n optimizedSourceCode[path] = {\\n ...summary,\\n ...(dependencies && { dependencies }),\\n };\\n }\\n }\\n\\n return [optimizedSourceCode, contentTokenCount, summaryTokenCount];\\n}\\n\\n/**\\n * Helper function to clear content from previous getSourceCode responses while preserving the conversation structure\\n */\\nfunction clearPreviousSourceCodeResponses(prompt: PromptItem[], irrelevantFiles: Set<string>) {\\n for (const item of prompt) {\\n if (item.type === 'user' && item.functionResponses) {\\n for (const response of item.functionResponses) {\\n if (response.name === 'getSourceCode' && response.content) {\\n // Zero out the contents but keep the structure\\n const sourceCode = parseSourceCodeTree(JSON.parse(response.content));\\n for (const path in sourceCode) {\\n if ('content' in sourceCode[path]) {\\n sourceCode[path].content = null;\\n } else {\\n // Zero out content for irrelevant files\\n const file = sourceCode[path] as FileContent;\\n file.content = null;\\n }\\n\\n if (irrelevantFiles.has(path) && sourceCode[path]) {\\n // Remove summary and dependencies for irrelevant files\\n if ('summary' in sourceCode[path]) {\\n delete sourceCode[path].summary;\\n }\\n delete sourceCode[path].dependencies;\\n }\\n }\\n response.content = JSON.stringify(getSourceCodeTree(sourceCode));\\n }\\n }\\n }\\n }\\n}\\n\\n/**\\n * Calculate dependency chain weight for a file\\n * Returns a value between 0 and 0.3 based on dependency importance\\n */\\nfunction calculateDependencyWeight(\\n filePath: string,\\n sourceCode: SourceCodeMap,\\n relevantFiles: Set<string>,\\n visited = new Set<string>(),\\n): number {\\n if (visited.has(filePath)) {\\n return 0; // Prevent circular dependency loops\\n }\\n visited.add(filePath);\\n\\n const fileData = sourceCode[filePath];\\n if (!fileData || !('dependencies' in fileData) || !fileData.dependencies) {\\n return 0;\\n }\\n\\n let weight = 0;\\n for (const dep of fileData.dependencies) {\\n if (dep.type === 'local' && relevantFiles.has(dep.path)) {\\n // Direct dependency of a relevant file gets higher weight\\n weight = Math.max(weight, 0.2);\\n // Recursively check dependencies with diminishing weight\\n const depWeight = calculateDependencyWeight(dep.path, sourceCode, relevantFiles, visited) * 0.7;\\n weight = Math.max(weight, depWeight);\\n }\\n }\\n\\n return weight;\\n}\\n\\n/**\\n * Get all dependencies for a file, including transitive ones\\n */\\nfunction getAllDependencies(filePath: string, sourceCode: SourceCodeMap, visited = new Set<string>()): Set<string> {\\n if (visited.has(filePath)) {\\n return new Set(); // Prevent circular dependency loops\\n }\\n visited.add(filePath);\\n\\n const deps = new Set<string>();\\n const fileData = sourceCode[filePath];\\n if (!fileData || !('dependencies' in fileData) || !fileData.dependencies) {\\n return deps;\\n }\\n\\n for (const dep of fileData.dependencies) {\\n if (dep.type === 'local') {\\n deps.add(dep.path);\\n // Add transitive dependencies\\n const transitiveDeps = getAllDependencies(dep.path, sourceCode, visited);\\n transitiveDeps.forEach((d) => deps.add(d));\\n }\\n }\\n\\n return deps;\\n}\\n\",\"dependencies\":[{\"path\":\"../../ai-service/common.js\",\"type\":\"local\"},{\"path\":\"../../main/codegen-types.js\",\"type\":\"local\"},{\"path\":\"../../main/common/content-bus.js\",\"type\":\"local\"},{\"path\":\"../../files/read-files.js\",\"type\":\"local\"},{\"path\":\"../function-calling.js\",\"type\":\"local\"},{\"path\":\"./steps-types.js\",\"type\":\"local\"},{\"path\":\"../token-estimator.js\",\"type\":\"local\"},{\"path\":\"./step-summarization.js\",\"type\":\"local\"},{\"path\":\"./step-validate-recover.js\",\"type\":\"local\"},{\"path\":\"./steps-utils.js\",\"type\":\"local\"},{\"path\":\"../../files/source-code-tree.js\",\"type\":\"local\"}]},\"steps-types.ts\":{\"content\":\"import { DependencyInfo } from '../../files/read-files';\\n\\nexport enum StepResult {\\n CONTINUE,\\n BREAK,\\n}\\n\\nexport interface SummaryInfo {\\n filePath: string;\\n tokenCount: number;\\n summary: string;\\n}\\n\\nexport type SummaryCache = Record<\\n string,\\n {\\n tokenCount: number;\\n summary: string;\\n checksum: string;\\n dependencies: DependencyInfo[];\\n }\\n> & { _version: string };\\n\",\"dependencies\":[]}}}"
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"cache": true
|
|
102
|
+
}
|
|
58
103
|
];
|
|
59
104
|
//# sourceMappingURL=current-prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"current-prompt.js","sourceRoot":"","sources":["../../../src/eval/data/current-prompt.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC;QACE,
|
|
1
|
+
{"version":3,"file":"current-prompt.js","sourceRoot":"","sources":["../../../src/eval/data/current-prompt.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC;QACE,MAAM,EAAE,cAAc;QACtB,cAAc,EAAE,k1KAAk1K;KACn2K;IACD;QACE,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,mBAAmB;KAC5B;IACD;QACE,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,+QAA+Q;QACvR,eAAe,EAAE;YACf;gBACE,MAAM,EAAE,eAAe;aACxB;YACD;gBACE,MAAM,EAAE,gBAAgB;aACzB;YACD;gBACE,MAAM,EAAE,aAAa;aACtB;SACF;KACF;IACD;QACE,MAAM,EAAE,MAAM;QACd,mBAAmB,EAAE;YACnB;gBACE,MAAM,EAAE,eAAe;gBACvB,SAAS,EAAE,oqbAAoqb;aAChrb;YACD;gBACE,MAAM,EAAE,gBAAgB;gBACxB,SAAS,EAAE,mWAAmW;aAC/W;YACD;gBACE,MAAM,EAAE,aAAa;gBACrB,SAAS,EAAE,g9BAAg9B;aAC59B;SACF;QACD,MAAM,EAAE,2EAA2E;QACnF,OAAO,EAAE,IAAI;KACd;IACD;QACE,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,uDAAuD;KAChE;IACD;QACE,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,OAAO;KAChB;IACD;QACE,MAAM,EAAE,WAAW;QACnB,eAAe,EAAE;YACf;gBACE,MAAM,EAAE,qBAAqB;gBAC7B,MAAM,EAAE;oBACN,WAAW,EAAE;wBACX,yEAAyE;wBACzE,kEAAkE;wBAClE,2DAA2D;wBAC3D,uDAAuD;wBACvD,0DAA0D;wBAC1D,gFAAgF;wBAChF,2EAA2E;wBAC3E,6DAA6D;wBAC7D,2DAA2D;qBAC5D;iBACF;aACF;YACD;gBACE,MAAM,EAAE,eAAe;gBACvB,MAAM,EAAE;oBACN,WAAW,EAAE;wBACX,yEAAyE;wBACzE,kEAAkE;wBAClE,2DAA2D;wBAC3D,uDAAuD;wBACvD,0DAA0D;wBAC1D,gFAAgF;wBAChF,2EAA2E;wBAC3E,6DAA6D;wBAC7D,2DAA2D;qBAC5D;iBACF;aACF;SACF;KACF;IACD;QACE,MAAM,EAAE,MAAM;QACd,mBAAmB,EAAE;YACnB;gBACE,MAAM,EAAE,qBAAqB;gBAC7B,SAAS,EAAE,wnBAAwnB;aACpoB;YACD;gBACE,MAAM,EAAE,eAAe;gBACvB,SAAS,EAAE,g0hDAAg0hD;aAC50hD;SACF;QACD,OAAO,EAAE,IAAI;KACd;CACF,CAAC"}
|
|
@@ -62,18 +62,19 @@ const MAX_TOTAL_TOKENS = 10000;
|
|
|
62
62
|
export async function executeStepContextOptimization(generateContentFn, prompt, options) {
|
|
63
63
|
const fullSourceCode = getSourceCode({ forceAll: true }, options);
|
|
64
64
|
const tokensBefore = estimateTokenCount(JSON.stringify(fullSourceCode));
|
|
65
|
-
if (tokensBefore < MAX_TOTAL_TOKENS) {
|
|
66
|
-
putSystemMessage('Context optimization is not needed, because the code base is small.');
|
|
67
|
-
return StepResult.CONTINUE;
|
|
68
|
-
}
|
|
69
65
|
const sourceCodeResponse = getSourceCodeResponse(prompt);
|
|
70
66
|
if (!sourceCodeResponse || !sourceCodeResponse.content) {
|
|
71
67
|
console.warn('Could not find source code response, something is wrong, but lets continue anyway.');
|
|
72
68
|
return StepResult.CONTINUE;
|
|
73
69
|
}
|
|
70
|
+
if (tokensBefore < MAX_TOTAL_TOKENS) {
|
|
71
|
+
putSystemMessage('Context optimization is not needed, because the code base is small.');
|
|
72
|
+
sourceCodeResponse.content = JSON.stringify(getSourceCodeTree(fullSourceCode));
|
|
73
|
+
return StepResult.CONTINUE;
|
|
74
|
+
}
|
|
74
75
|
const sourceCode = parseSourceCodeTree(JSON.parse(sourceCodeResponse.content));
|
|
75
76
|
try {
|
|
76
|
-
putSystemMessage('Context optimization is starting');
|
|
77
|
+
putSystemMessage('Context optimization is starting for large codebase');
|
|
77
78
|
const optimizationPrompt = [
|
|
78
79
|
...prompt,
|
|
79
80
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-context-optimization.js","sourceRoot":"","sources":["../../../src/prompt/steps/step-context-optimization.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAe,aAAa,EAAiB,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;A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AAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
1
|
+
{"version":3,"file":"step-context-optimization.js","sourceRoot":"","sources":["../../../src/prompt/steps/step-context-optimization.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAe,aAAa,EAAiB,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAkB,MAAM,iCAAiC,CAAC;AAEzG,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkD3B,CAAC;AAEF,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,iBAA0C,EAC1C,MAAoB,EACpB,OAAuB;IAEvB,MAAM,cAAc,GAAG,aAAa,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAClE,MAAM,YAAY,GAAG,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;IAExE,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzD,IAAI,CAAC,kBAAkB,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;QACvD,OAAO,CAAC,IAAI,CAAC,oFAAoF,CAAC,CAAC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