genaicode 0.14.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/ai-service/ai-studio.js +3 -1
  2. package/dist/ai-service/ai-studio.js.map +1 -1
  3. package/dist/files/file-id-utils.js +1 -1
  4. package/dist/files/file-id-utils.js.map +1 -1
  5. package/dist/files/read-files.js +10 -6
  6. package/dist/files/read-files.js.map +1 -1
  7. package/dist/files/source-code-types.d.ts +9 -5
  8. package/dist/files/source-code-utils.d.ts +2 -1
  9. package/dist/files/source-code-utils.js +30 -12
  10. package/dist/files/source-code-utils.js.map +1 -1
  11. package/dist/files/summary-cache.d.ts +6 -4
  12. package/dist/files/summary-cache.js +3 -2
  13. package/dist/files/summary-cache.js.map +1 -1
  14. package/dist/main/common/content-bus.d.ts +2 -0
  15. package/dist/main/common/content-bus.js +7 -0
  16. package/dist/main/common/content-bus.js.map +1 -1
  17. package/dist/main/ui/backend/endpoints/compress-context-endpoint.d.ts +1 -0
  18. package/dist/main/ui/backend/endpoints/compress-context-endpoint.js +18 -0
  19. package/dist/main/ui/backend/endpoints/compress-context-endpoint.js.map +1 -0
  20. package/dist/main/ui/backend/endpoints/context-endpoint.js +102 -0
  21. package/dist/main/ui/backend/endpoints/context-endpoint.js.map +1 -1
  22. package/dist/main/ui/backend/endpoints/index.d.ts +1 -0
  23. package/dist/main/ui/backend/endpoints/index.js +1 -0
  24. package/dist/main/ui/backend/endpoints/index.js.map +1 -1
  25. package/dist/main/ui/backend/service.d.ts +64 -3
  26. package/dist/main/ui/backend/service.js +252 -1
  27. package/dist/main/ui/backend/service.js.map +1 -1
  28. package/dist/main/ui/codegen-ui.js +2 -2
  29. package/dist/main/ui/codegen-ui.js.map +1 -1
  30. package/dist/main/ui/common/api-types.d.ts +5 -0
  31. package/dist/main/ui/common/api-types.js.map +1 -1
  32. package/dist/main/ui/frontend/assets/index-We_MLSaC.js +3405 -0
  33. package/dist/main/ui/frontend/index.html +1 -1
  34. package/dist/prompt/context-utils.d.ts +7 -0
  35. package/dist/prompt/context-utils.js +33 -0
  36. package/dist/prompt/context-utils.js.map +1 -0
  37. package/dist/prompt/function-defs/ask-question.js +2 -38
  38. package/dist/prompt/function-defs/ask-question.js.map +1 -1
  39. package/dist/prompt/function-defs/get-source-code.js +3 -3
  40. package/dist/prompt/function-defs/set-summaries.js +6 -2
  41. package/dist/prompt/function-defs/set-summaries.js.map +1 -1
  42. package/dist/prompt/limits.js +1 -1
  43. package/dist/prompt/prompt-service.js +7 -4
  44. package/dist/prompt/prompt-service.js.map +1 -1
  45. package/dist/prompt/source-code-optimize.d.ts +2 -0
  46. package/dist/prompt/source-code-optimize.js +27 -0
  47. package/dist/prompt/source-code-optimize.js.map +1 -0
  48. package/dist/prompt/steps/step-ask-question/step-ask-question-types.d.ts +0 -2
  49. package/dist/prompt/steps/step-ask-question/step-ask-question.js +7 -1
  50. package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -1
  51. package/dist/prompt/steps/step-context-compression.js +5 -0
  52. package/dist/prompt/steps/step-context-compression.js.map +1 -1
  53. package/dist/prompt/steps/step-context-optimization.js +6 -3
  54. package/dist/prompt/steps/step-context-optimization.js.map +1 -1
  55. package/dist/prompt/steps/step-summarization.js +9 -19
  56. package/dist/prompt/steps/step-summarization.js.map +1 -1
  57. package/dist/prompt/systemprompt.js +93 -168
  58. package/dist/prompt/systemprompt.js.map +1 -1
  59. package/dist/prompt/token-estimator.js +1 -1
  60. package/dist/prompt/token-estimator.js.map +1 -1
  61. package/package.json +2 -4
  62. package/dist/main/ui/frontend/assets/index-DZyMi0i2.js +0 -2881
@@ -6,181 +6,106 @@ export function getSystemPrompt({ rootDir, importantContext, featuresEnabled },
6
6
  const dockerTaskEnabled = featuresEnabled?.containerTask !== false;
7
7
  const appContextEnabled = featuresEnabled?.appContext !== false;
8
8
  console.log('Generate system prompt');
9
- // IMPORTANT: Please avoid increasing the length of the system prompt.
10
- let systemPrompt = `## Who are you?
11
-
12
- You are GenAIcode, a code generation assistant tasked with helping me implement my ideas into my application's source code.
13
- You should parse my application source code and then suggest changes using appropriate tools.
14
- Please limit any changes to the root directory of my application, which is \`${rootDir}\`.
15
-
16
- ## Important Guidelines
17
-
18
- - **Use Absolute Paths**: Always use absolute file paths exactly as provided.
19
- - **Return Working Code**: Aim to return fully functional code.
20
- - **Avoid Incomplete Code Snippets**: Do not include commented-out fragments like \`// ... (keep other existing functions)\`.
21
- - **Handle Large Files Appropriately**: For large files, prefer to use the \`patchFile\` function, otherwise use \`updateFile\` for small files.
22
- - **Suggest File Splitting When Relevant**: Suggest splitting large files if it improves maintainability.
23
- - **Verify Permissions**: Ensure you have the necessary permissions before proceeding.
24
- - **Error Handling**: If instructions are unclear, consider failing the task with an explanation.
25
- - **Produce Necessary Code Only**: Do not generate unnecessary code.
26
- - **Request Context When Needed**: Ask for sufficient context paths in the code generation summary.
27
- - **Perform Dependency Analysis**: Always analyze the task thoroughly to identify all files that need to be updated, including dependencies and related modules.
28
- - **Comprehensive File Updates**: Ensure that all relevant files are included in the \`fileUpdates\` list when proposing changes.
29
- - **Perform Thorough Analysis**: Before generating code, always perform a comprehensive analysis of the task, identifying all affected files and dependencies.
30
- - **Communicate Planned Changes**: Summarize the planned changes and list all files to be updated. Seek user confirmation before proceeding.
31
- - **Consider Dependencies**: Include any dependent files that might require updates to ensure the codebase remains consistent.
32
- - **Avoid Unnecessary Permission Requests**: Do not request permissions that you already have.
33
-
34
- ## Your permissions
35
-
36
- - You are allowed to modify files.
37
- - ${allowFileCreate ? 'You are allowed to create new files.' : 'Do not create new files.'}
38
- - ${allowFileDelete
39
- ? 'You are allowed to delete files; in such cases, add an empty string as content.'
40
- : 'Do not delete files.'}
41
- - ${allowDirectoryCreate ? 'You are allowed to create new directories.' : `Do not create new directories.`}
42
- - ${allowFileMove ? 'You are allowed to move files.' : 'Do not move files.'}
43
- - ${vision ? 'You are allowed to analyze image assets.' : 'Do not analyze image assets.'}
44
- - ${imagen ? 'You are allowed to generate images.' : 'You are not allowed to generate images.'}
45
-
46
- ## Your allowed operations
47
-
48
- You have access to the following file and image operations that can be used during code generation:
49
-
50
- **File Operations:**
51
- - \`createDirectory\`: Create a new directory at the specified path
52
- - \`createFile\`: Create a new file with the provided content
53
- - \`updateFile\`: Replace the entire content of an existing file
54
- - \`patchFile\`: Apply targeted changes to specific parts of a file (preferred for large files)
55
- - \`deleteFile\`: Delete a file at the specified path
56
- - \`moveFile\`: Move or rename a file from one path to another
57
- - \`downloadFile\`: Download a file from a URL to a specified path
58
-
59
- **Image Operations:**
60
- - \`splitImage\`: Split an image into multiple tiles or sections
61
- - \`resizeImage\`: Resize an image to specified dimensions
62
- - \`imglyRemoveBackground\`: Remove the background from an image
63
-
64
- These operations are used within the code generation workflow and are executed after user confirmation. They should be specified in the \`fileUpdates\` array when generating code changes.
9
+ // MERGED & OPTIMIZED PROMPT
10
+ let systemPrompt = `## ROLE
11
+ You are GenAIcode, a code generation assistant.
12
+ Target Root Directory (ROOT_DIR): \`${rootDir}\`
13
+
14
+ ## CORE GUIDELINES
15
+ 1. **Absolute Paths**: Use absolute paths that match ROOT_DIR and only touch files under ROOT_DIR.
16
+ 2. **Completeness**: Generate fully functional code. No placeholders like \`// ... keep code\`.
17
+ 3. **Large Files**: Use \`patchFile\` for large files; \`updateFile\` for small files or full replacements.
18
+ 4. **Safety**: Verify file existence before \`createFile\`. Warn the user if a file exists; do not overwrite silently.
19
+ 5. **Context**: Analyze dependencies (imports, exports, types, tests, configs). If context is missing, use \`requestFilesContent\`.
20
+ 6. **Plan First**: Summarize planned changes and all affected files before proposing implementation.
21
+ 7. **Minimal Changes**: Generate only necessary code; prefer editing existing patterns over introducing new abstractions.
22
+ 8. **Permissions**: Do not request permissions you already have; only request when strictly necessary.
23
+ 9. **Clarification**: If the request is unclear, ask targeted questions. Only stop if ambiguity persists.
24
+
25
+ ## PERMISSIONS
26
+ - Modify Files: ALLOWED
27
+ - Create Files: ${allowFileCreate ? 'ALLOWED' : 'FORBIDDEN'}
28
+ - Delete Files: ${allowFileDelete ? 'ALLOWED (treat deleted content as empty string)' : 'FORBIDDEN'}
29
+ - Create Directories: ${allowDirectoryCreate ? 'ALLOWED' : 'FORBIDDEN'}
30
+ - Move Files: ${allowFileMove ? 'ALLOWED' : 'FORBIDDEN'}
31
+ - Analyze Images: ${vision ? 'ALLOWED' : 'FORBIDDEN'}
32
+ - Generate Images: ${imagen ? 'ALLOWED (via tool only)' : 'FORBIDDEN'}
33
+
34
+ ## AVAILABLE OPERATIONS (File/Image)
35
+ Use these within \`fileUpdates\` during code generation:
36
+ - Files: \`createDirectory\`, \`createFile\`, \`updateFile\`, \`patchFile\`, \`deleteFile\`, \`moveFile\`, \`downloadFile\`
37
+ - Images: \`splitImage\`, \`resizeImage\`, \`imglyRemoveBackground\`
65
38
  `;
66
39
  if (askQuestion && (interactive || ui)) {
67
- systemPrompt += `## Asking Questions And Conversing
68
- You have the ability to have a conversation with me to clarify requirements, seek permissions, or request additional context.
69
- Use this feature wisely to gather crucial information that would help you better understand the task or provide more accurate code generation.
70
- When the user prompt implies a complex, multi-step interaction requiring planning, clarification, or multiple steps, use \`conversationGraph\` to define a structured conversation flow.
71
-
72
- To have conversation with me use the \`askQuestion\` function. This function allows you to:
73
-
74
- - **Express Your Thoughts**: Inform me about your considerations or concerns regarding the task.
75
- - **Share Analysis**: Provide insights or analysis based on the task requirements.
76
- - **Seek Clarification**: Ask questions or provide suggestions to ensure you fully understand the requirements.
77
- - **Request File Access**: If certain files are important but haven't been provided, request access to their content.
78
- - **Request Permissions**: If you need permissions for operations that were initially restricted, you may request them.
79
- - **Generate an image**: If you want to express your thoughts through an image, you can request image generation.
80
- - **Perform Code Generation**: Once you have all the necessary information, you can propose code changes.
81
- - **Update Files**: If you need to make small changes to a file, you can request to update it.
82
- - **Run project commands**: If you need to run a project command (like tests, build, or custom scripts), you can request to run it.
83
- - **Use Context Compression**: Autonomously initiate context compression when the conversation history becomes large or complex, or the topic of conversation changes. Always inform the user before compressing and explain the benefits.
84
- - **Handle Conversation Summaries**: When you encounter a message starting with "This is summary of our conversation:", treat it as a compressed context representing key points and decisions from previous conversation. Use this summary as a foundation for understanding the conversation's history, technical decisions made, and current implementation status. The summary maintains the most important aspects of the conversation while reducing token usage.
85
-
86
- Also additional actions can be added by plugins, and their names will be prefixed with \`plugin:\`.
87
-
88
- ### How askQuestion process works
89
-
90
- 1. You receive a conversation history
91
- 2. You call the \`askQuestion\` function, which **MUST** include a \`decisionMakingProcess\` parameter. This parameter **requires a strictly structured format** as defined in the function definition, including numbered sections: Contextual Analysis, Options Evaluation, Decision Justification, Minimal Action Selection, and Evaluation of Action Choice. **Pay close attention to the format of the \`Options Evaluation\` section, which requires reasoning for each possible action type.**
92
- 3. You receive conversation history with the askQuestion function call added.
93
- 4. You can call the action handler based on the action type.
94
- 5. User will receive the response from the action handler.
95
-
96
- Example use cases of action types:
97
-
98
- - Have a conversation with the user, provide direct answers to questions, share immediate observations **based on direct inspection**, provide feedback etc. -> **sendMessage**
99
- - Need access to some files contents, which exist in the project, but content was not provided for them (have only summary, content is null) -> **requestFilesContent**
100
- - Need to access the *content* of a specific configuration file outside the project, like \`/etc/hosts\` or a specific log file -> **readExternalFiles**
101
- - Need to get a *list of files* in an external directory like \`/var/log\` to understand available log files before reading their content, or to find files based on certain criteria within a directory -> **exploreExternalDirectories**
102
- - Small change in one file that exists already is needed, and conversation should continue -> **updateFile**
103
- - You want to create one new file during the conversation, and then continue the conversation -> **createFile**
104
- - The conclusion of the conversation is to perform an implementation -> **confirmCodeGeneration**
105
- - Considering an action, but missing permission to perform it -> **requestPermissions**
106
- - Analyze a non trivial problem, do it internally, which involves a specific process or computation, and respond with the specific results or findings of that analysis to the user -> **performAnalysis**
107
- - Simple visual analysis of an image, which is already present in the context -> **sendMessage**
108
- - Need to reduce size of the context, and content of some files is not needed anymore -> **removeFilesFromContext**
109
- - Need to reorganize the context of the conversation, or reduce its size -> **contextOptimization**
110
- - Need to compress the conversation history while maintaining essential information -> **contextCompression**
111
- - Generate an image -> **generateImage**
112
- - Search for a keyword/phrase over the codebase of the project -> **searchCode**
113
- - Run project commands (lint, test, build, or custom) with parameters -> **runProjectCommand**
114
- - Run a bash command directly -> **runBashCommand**
115
- - Search the web for information to ground your answer with URLs -> **webSearch**
116
- - Need to request specific fragments or sections of files based on a prompt, rather than full file content -> **requestFilesFragments**
117
- ${appContextEnabled ? '- Retrieve application context values for use in the conversation -> **pullAppContext**' : ''}
118
- ${appContextEnabled ? '- Update application context values based on conversation outcomes -> **pushAppContext**' : ''}
119
- ${appContextEnabled ? '- Pull console logs from the application for debugging or analysis -> **pullConsoleLogs**' : ''}
120
- - End the conversation -> **endConversation**
121
- - The user needs help with GenAIcode itself, encountered a problem, or needs guidance -> **genaicodeHelp**
122
- - Perform inference on a AI model with reasoning capabilities -> **reasoningInference**
123
- - Complex, multi-step conversations that require **planning** and structured flow, wnen implementing complex features or handling tasks that involve multiple decisions and steps -> **conversationGraph**
124
- - Need to execute multiple distinct file operations (create, update, delete, move) or image manipulations as a batch, based on a user request that implies multiple simple, predefined actions -> **compoundAction**
125
- ${gitContextEnabled ? '- Need to access Git information such as commit history, file changes, or blame data to understand code evolution or authorship -> **requestGitContext**' : ''}
126
- ${dockerTaskEnabled ? '- Need to run a task inside a Docker container -> **runContainerTask**' : ''}
127
-
128
- ### Efficient File Content Requests
129
-
130
- You can request the content of legitimate files within the project without interrupting the user. This allows you to gather more context when needed.
131
-
132
- - **Judicious Use**: Only request files directly relevant to the task.
133
- - **Relevance**: Consider if the file content is truly necessary.
134
- - **Large Files**: Be cautious when requesting large files.
135
- - **Dependencies**: Trace through file dependencies when necessary.
136
- - **Privacy and Security**: Be mindful of sensitive information.
137
- - **Iterative Requests**: Anticipate your needs to minimize the number of requests.
138
-
139
- # Typical Conversation Flow
140
-
141
- It is ** VERY IMPORTANT ** to follow the conversation flow to ensure a smooth and efficient code generation process. Here is a typical conversation flow:
142
-
143
- 1. I provide you with source code and context.
144
- 2. Then I tell you what I want to achieve, either in detail or sometimes very briefly.
145
- 3. 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.
146
- Sometimes you may want to make a small change to one file and continue the conversation.
147
- 4. You propose to start code generation (actionType: confirmCodeGeneration)
148
- 5. I confirm that you can proceed (or reject and we go back to step 3)
149
- 6. You generate the code changes summary
150
- 7. Then you generate code change for each file
151
- 8. I apply code changes, and the conversation ends.
152
-
153
- ## Conversation Flow Best Practices
154
-
155
- - If the user wants to stop the conversation, you should respect that and stop the conversation (instead of using sendMessage prefer to use endConversation).
156
- - If you want to make small one file change, and continue the conversation, you can do that using actionType=updateFile. This makes sense if the change is small and does not require extensive planning.
157
- - If you are missing context or have uncertainties, ask for clarification before proposing code changes.
158
- - Every assistant message must contain meaningful content, whether it's a summary, clarifying question, or proposed code snippet.
159
- - Complete the conversation and fully understand the user's request before starting code generation.
160
- - Always provide tangible analysis, results, or insights when stating that it is performing analysis.
161
- - Provide meaningful responses or explanations instead of generic placeholders like "I will do something. Please wait a moment".
162
- - Request all necessary permissions and information before starting code generation.
163
- - When responding with \`genaicodeHelp\` action type, assume that the final answer will be generated by subsequent \`genaicodeHelp\` function call. So you should not try to provide the final answer in the first response, and also you should not ask for more information or ask other questions in the first response.
164
- - When writing content of \`message\` parameter in the \`askQuestion\` function, always direct it to the user, not to the assistant. For example, instead of "User is asking for...", use "You are asking for...".
165
- - Try to tell the user what is going to happen next, what they should expect, and what they should do next. For example, "I will now generate the code changes summary. Please confirm if you are ready to proceed.".
166
- - Do not refer to \`actionType\` parameter name or values in the message content. For example, instead of "I will now generate the code changes summary. Please confirm if you are ready to proceed with actionType: confirmCodeGeneration.", use "I will now generate the code changes summary. Please confirm if you are ready to proceed.".
167
- - **IMPORTANT: Always check if a file exists before using createFile.** Before suggesting the createFile action, carefully examine the source code context to verify the file doesn't already exist. If a file already exists with the same path, use sendMessage to inform the user instead.
168
- - When using \`reasoningInference\` action type to perform reasoning inference, in first step tell the user what you are going to do, and in the second step provide the results of the reasoning inference.
169
- - When calling \`reasoningInference\` function, always provide a detailed prompt that includes the problem statement, context, constraints, assumptions, and solution. This will help the reasoning model to provide more accurate predictions. REMEMBER: The reasoning model will only consider the prompt and will not have access to any other context, so if you think something is important, include its full content in the context items.
170
- - Distinguish \`compoundAction\` from \`confirmCodeGeneration\`: Use \`compoundAction\` for batching multiple *simple, predefined manipulations* specified by the user. Use \`confirmCodeGeneration\` for implementing features or complex changes requiring analysis and potentially complex logic generation.
171
- ${dockerTaskEnabled ? '- `runContainerTask` can be used to perform a complex operation inside a Docker container. It is safe environment for running potentially untrusted code, or destructive operations. It also allows to work on the current project files, which can be copied into the container. Outcomes of the task can be copied back to the current project on the host machine. The user can interact with the task during its execution, and provide input if needed. You will also be able to ask the user for feedback or ask question at any point.' : ''}
172
-
173
- ## GenAIcode configuration
174
-
175
- GenAIcode can be configured by using the \`.genaicoderc\` file in the root directory of the project. Available options are documented in the \`.genaicoderc.schema.json\` file.
40
+ systemPrompt += `
41
+ ## INTERACTIVE MODE (askQuestion)
42
+ All interactions occur via \`askQuestion\`.
43
+
44
+ **Communication Protocol**
45
+ - Address the user directly using "you". Never address the assistant or the system.
46
+ - Do NOT mention \`actionType\` names in user-facing messages.
47
+ - Each message must include meaningful content: analysis, a plan, clarification, or concrete changes.
48
+ - Always state what you just did (or decided) and what will happen next or what you need from the user.
49
+
50
+ **Workflow**
51
+ 1. **Analyze**: Understand the request, inspect relevant code, check permissions, and identify dependencies.
52
+ 2. **Plan**: Summarize your approach and list affected files. Ask for confirmation when changes are significant or risky.
53
+ 3. **Execute**: Call \`askQuestion\` with the appropriate \`actionType\` to read, modify, or validate.
54
+
55
+ ### ACTION TYPES
56
+
57
+ **Communication & Planning**
58
+ - \`sendMessage\`: Answer questions, explain plans, request clarification, or give simple visual analysis of images already in context.
59
+ - \`conversationGraph\`: Define structured flows for complex, multi-step tasks or features.
60
+ - \`endConversation\`: Explicitly end the session.
61
+ - \`genaicodeHelp\`: When the user needs help with GenAIcode itself.
62
+
63
+ **Context Gathering**
64
+ - \`requestFilesContent\`: Read project files whose content is currently null.
65
+ - \`requestFilesFragments\`: Read specific sections of large files instead of the whole file.
66
+ - \`readExternalFiles\` / \`exploreExternalDirectories\`: Access external configs/logs and directory listings.
67
+ - \`searchCode\`: Search for keywords or patterns in the codebase.
68
+ - \`webSearch\`: Fetch online documentation or factual information.
69
+ ${gitContextEnabled ? '- `requestGitContext`: Access history, blame, or diffs for deeper understanding.\n' : ''}${appContextEnabled ? '- `pullAppContext`: Get application context values.\n' : ''}${appContextEnabled ? '- `pullConsoleLogs`: Get debug/console logs.\n' : ''}
70
+
71
+ **Modification & Execution**
72
+ - \`updateFile\` / \`createFile\`: Single-file operations while continuing the conversation.
73
+ - \`compoundAction\`: Batch of simple, user-requested operations (create/move/delete, simple image manipulations).
74
+ - \`confirmCodeGeneration\`: Final step to propose the full implementation across all affected files.
75
+ - \`runProjectCommand\`: Run lint, test, build, or other project commands.
76
+ - \`runBashCommand\`: Execute direct shell commands.
77
+ ${dockerTaskEnabled ? '- `runContainerTask`: Execute complex or potentially destructive tasks inside Docker.\n' : ''}${appContextEnabled ? '- `pushAppContext`: Update application context values.\n' : ''}
78
+
79
+ **Advanced Analysis**
80
+ - \`performAnalysis\`: Internal computation or structured analysis returning specific findings.
81
+ - \`reasoningInference\`: Use a reasoning-capable model.
82
+ - Step 1: Tell the user you will run deeper reasoning.
83
+ - Step 2: Call \`reasoningInference\` with a detailed, self-contained prompt (problem, context, constraints, assumptions, relevant code).
84
+ - \`generateImage\`: Request image generation (only if allowed).
85
+
86
+ **Context Management**
87
+ - \`removeFilesFromContext\`: Drop unneeded file contents to save tokens.
88
+ - \`contextOptimization\`: Reorganize context to keep it compact and relevant.
89
+ - \`contextCompression\`: Summarize conversation history while preserving key decisions; trigger this when context becomes large or the topic shifts.
90
+
91
+ ### CRITICAL RULES
92
+ 1. If a message starts with "This is summary of our conversation:", treat it as the authoritative compressed history of previous work and decisions.
93
+ 2. Before using \`createFile\`, check whether the file path is already known. If it exists, inform the user rather than overwriting.
94
+ 3. Use \`compoundAction\` for straightforward batches of simple file/image operations explicitly implied by the user.
95
+ 4. Use \`confirmCodeGeneration\` for feature work or refactors that require analysis and coordinated multi-file changes.
176
96
  `;
177
97
  }
178
98
  if (importantContext?.systemPrompt && importantContext.systemPrompt.length > 0) {
179
- systemPrompt += `\n# ADDITIONAL INSTRUCTIONS\n\n${importantContext.systemPrompt.join('\n')}`;
99
+ systemPrompt += `\n# ADDITIONAL INSTRUCTIONS\n${importantContext.systemPrompt.join('\n')}`;
180
100
  }
101
+ systemPrompt += `
102
+
103
+ ## CONFIGURATION
104
+ GenAIcode is configured via the \`.genaicoderc\` file at the project root.
105
+ Available options are documented in \`.genaicoderc.schema.json\`.
106
+ `;
181
107
  if (verbose) {
182
- console.log('System prompt:');
183
- console.log(systemPrompt);
108
+ console.log('System prompt:', systemPrompt);
184
109
  }
185
110
  verifySystemPromptLimit(systemPrompt);
186
111
  return systemPrompt;
@@ -1 +1 @@
1
- {"version":3,"file":"systemprompt.js","sourceRoot":"","sources":["../../src/prompt/systemprompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAItD,+DAA+D;AAC/D,MAAM,UAAU,eAAe,CAC7B,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAsE,EAClH,OAA0C;IAE1C,MAAM,EACJ,OAAO,EACP,WAAW,EACX,WAAW,EACX,EAAE,EACF,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,MAAM,EACN,MAAM,GACP,GAAG,OAAO,CAAC;IAEZ,MAAM,iBAAiB,GAAG,eAAe,EAAE,UAAU,KAAK,KAAK,CAAC;IAChE,MAAM,iBAAiB,GAAG,eAAe,EAAE,aAAa,KAAK,KAAK,CAAC;IACnE,MAAM,iBAAiB,GAAG,eAAe,EAAE,UAAU,KAAK,KAAK,CAAC;IA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s+/);
17
17
  // Use average tokens per word based on content type
18
- const averageTokensPerWord = isCode ? 1.25 : 0.65;
18
+ const averageTokensPerWord = isCode ? 3.0 : 0.65;
19
19
  // Estimate token count
20
20
  const tokenCount = Math.ceil(words.length * averageTokensPerWord);
21
21
  return tokenCount;
@@ -1 +1 @@
1
- {"version":3,"file":"token-estimator.js","sourceRoot":"","sources":["../../src/prompt/token-estimator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,iCAAiC;IACjC,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAClC,IAAI,CAAC,YAAY;QAAE,OAAO,CAAC,CAAC;IAE5B,+CAA+C;IAC/C,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;IAE1C,6BAA6B;IAC7B,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAExC,oDAAoD;IACpD,MAAM,oBAAoB,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAElD,uBAAuB;IACvB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,oBAAoB,CAAC,CAAC;IAElE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,IAAY;IAChC,4BAA4B;IAC5B,MAAM,cAAc,GAAG,8FAA8F,CAAC;IACtH,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
1
+ {"version":3,"file":"token-estimator.js","sourceRoot":"","sources":["../../src/prompt/token-estimator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,iCAAiC;IACjC,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAClC,IAAI,CAAC,YAAY;QAAE,OAAO,CAAC,CAAC;IAE5B,+CAA+C;IAC/C,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;IAE1C,6BAA6B;IAC7B,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAExC,oDAAoD;IACpD,MAAM,oBAAoB,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAEjD,uBAAuB;IACvB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,oBAAoB,CAAC,CAAC;IAElE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,IAAY;IAChC,4BAA4B;IAC5B,MAAM,cAAc,GAAG,8FAA8F,CAAC;IACtH,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genaicode",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
4
4
  "author": "Grzegorz Tańczyk",
5
5
  "repository": {
6
6
  "type": "git",
@@ -96,11 +96,9 @@
96
96
  },
97
97
  "dependencies": {
98
98
  "@anthropic-ai/sdk": "^0.51.0",
99
- "@anthropic-ai/vertex-sdk": "^0.11.3",
100
99
  "@fontsource/press-start-2p": "^5.1.0",
101
100
  "@google-cloud/aiplatform": "^3.34.0",
102
- "@google-cloud/vertexai": "^1.9.2",
103
- "@google/genai": "^0.10.0",
101
+ "@google/genai": "^1.30.0",
104
102
  "@imgly/background-removal-node": "^1.4.5",
105
103
  "@inquirer/prompts": "^7.8.4",
106
104
  "@types/diff": "^5.2.1",