genaicode 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist/ai-service/ai-studio.js +7 -1
- package/dist/ai-service/ai-studio.js.map +1 -1
- package/dist/ai-service/anthropic.js +49 -19
- package/dist/ai-service/anthropic.js.map +1 -1
- package/dist/ai-service/chat-gpt.js +28 -11
- package/dist/ai-service/chat-gpt.js.map +1 -1
- package/dist/ai-service/common.d.ts +5 -4
- package/dist/ai-service/common.js +3 -4
- package/dist/ai-service/common.js.map +1 -1
- package/dist/ai-service/common.test.js +1 -1
- package/dist/ai-service/vertex-ai-claude.js +1 -1
- package/dist/ai-service/vertex-ai-claude.js.map +1 -1
- package/dist/ai-service/vertex-ai.js +7 -1
- package/dist/ai-service/vertex-ai.js.map +1 -1
- package/dist/cli/cli-options.js +0 -12
- package/dist/cli/cli-options.js.map +1 -1
- package/dist/cli/cli-params.d.ts +1 -4
- package/dist/cli/cli-params.js +1 -10
- package/dist/cli/cli-params.js.map +1 -1
- package/dist/cli/validate-cli-params.js +1 -7
- package/dist/cli/validate-cli-params.js.map +1 -1
- package/dist/cli/validate-cli-params.test.js +1 -1
- package/dist/cli/validate-cli-params.test.js.map +1 -1
- package/dist/eval/codegen-summary.test.d.ts +1 -0
- package/dist/eval/codegen-summary.test.js +93 -0
- package/dist/eval/codegen-summary.test.js.map +1 -0
- package/dist/eval/current-prompt-plugin.d.ts +3 -0
- package/dist/eval/current-prompt-plugin.js +10 -0
- package/dist/eval/current-prompt-plugin.js.map +1 -0
- package/dist/eval/data/current-prompt.d.ts +34 -0
- package/dist/eval/data/current-prompt.js +59 -0
- package/dist/eval/data/current-prompt.js.map +1 -0
- package/dist/eval/data/prompt-assistant-image.d.ts +49 -0
- package/dist/eval/data/prompt-assistant-image.js +67 -0
- package/dist/eval/data/prompt-assistant-image.js.map +1 -0
- package/dist/eval/data/prompt3.d.ts +34 -0
- package/dist/eval/data/prompt3.js +71 -0
- package/dist/eval/data/prompt3.js.map +1 -0
- package/dist/eval/prompt-debug.test.d.ts +1 -0
- package/dist/eval/prompt-debug.test.js +76 -0
- package/dist/eval/prompt-debug.test.js.map +1 -0
- package/dist/eval/prompt2.d.ts +34 -0
- package/dist/eval/prompt2.js +125 -0
- package/dist/eval/prompt2.js.map +1 -0
- package/dist/files/read-files.d.ts +29 -6
- package/dist/files/read-files.js +31 -10
- package/dist/files/read-files.js.map +1 -1
- package/dist/files/read-files.test.js +15 -9
- package/dist/files/read-files.test.js.map +1 -1
- package/dist/files/source-code-tree.d.ts +17 -0
- package/dist/files/source-code-tree.js +70 -0
- package/dist/files/source-code-tree.js.map +1 -0
- package/dist/main/codegen-types.d.ts +8 -5
- package/dist/main/codegen.ai-services.test.d.ts +3 -0
- package/dist/main/codegen.ai-services.test.js +198 -0
- package/dist/main/codegen.ai-services.test.js.map +1 -0
- package/dist/main/codegen.cli-options.test.d.ts +3 -0
- package/dist/main/codegen.cli-options.test.js +171 -0
- package/dist/main/codegen.cli-options.test.js.map +1 -0
- package/dist/main/codegen.image-generation.test.d.ts +3 -0
- package/dist/main/codegen.image-generation.test.js +187 -0
- package/dist/main/codegen.image-generation.test.js.map +1 -0
- package/dist/main/codegen.js +2 -5
- package/dist/main/codegen.js.map +1 -1
- package/dist/main/codegen.test-utils.d.ts +81 -0
- package/dist/main/codegen.test-utils.js +88 -0
- package/dist/main/codegen.test-utils.js.map +1 -0
- package/dist/main/codegen.test.js +47 -28
- package/dist/main/codegen.test.js.map +1 -1
- package/dist/main/common/content-bus-types.d.ts +6 -0
- package/dist/main/common/content-bus.d.ts +2 -2
- package/dist/main/common/content-bus.js +3 -1
- package/dist/main/common/content-bus.js.map +1 -1
- package/dist/main/common/user-actions.d.ts +8 -2
- package/dist/main/common/user-actions.js.map +1 -1
- package/dist/main/config-lib.js +20 -2
- package/dist/main/config-lib.js.map +1 -1
- package/dist/main/config.js +4 -28
- package/dist/main/config.js.map +1 -1
- package/dist/main/interactive/codegen-interactive.js +0 -4
- package/dist/main/interactive/codegen-interactive.js.map +1 -1
- package/dist/main/interactive/codegen-interactive.test.js +1 -7
- package/dist/main/interactive/codegen-interactive.test.js.map +1 -1
- package/dist/main/interactive/common.d.ts +1 -1
- package/dist/main/interactive/common.js +0 -2
- package/dist/main/interactive/common.js.map +1 -1
- package/dist/main/interactive/configure.js +0 -2
- package/dist/main/interactive/configure.js.map +1 -1
- package/dist/main/interactive/help.js +0 -2
- package/dist/main/interactive/help.js.map +1 -1
- package/dist/main/interactive/task-file.js +1 -1
- package/dist/main/interactive/task-file.js.map +1 -1
- package/dist/main/interactive/text-prompt.js +1 -1
- package/dist/main/interactive/text-prompt.js.map +1 -1
- package/dist/main/interactive/user-action-handlers.js +4 -2
- package/dist/main/interactive/user-action-handlers.js.map +1 -1
- package/dist/main/plugin-loader.d.ts +7 -1
- package/dist/main/plugin-loader.js +61 -0
- package/dist/main/plugin-loader.js.map +1 -1
- package/dist/main/ui/backend/api.js +9 -3
- package/dist/main/ui/backend/api.js.map +1 -1
- package/dist/main/ui/backend/service.d.ts +2 -1
- package/dist/main/ui/backend/service.js +6 -3
- package/dist/main/ui/backend/service.js.map +1 -1
- package/dist/main/ui/frontend/assets/index-QOcNx5ac.js +812 -0
- package/dist/main/ui/frontend/index.html +1 -1
- package/dist/main/ui/user-action-handlers.js +1 -1
- package/dist/main/ui/user-action-handlers.js.map +1 -1
- package/dist/project-profiles/detection.d.ts +40 -0
- package/dist/project-profiles/detection.js +131 -0
- package/dist/project-profiles/detection.js.map +1 -0
- package/dist/project-profiles/index.d.ts +35 -0
- package/dist/project-profiles/index.js +72 -0
- package/dist/project-profiles/index.js.map +1 -0
- package/dist/project-profiles/profiles/golang.d.ts +65 -0
- package/dist/project-profiles/profiles/golang.js +208 -0
- package/dist/project-profiles/profiles/golang.js.map +1 -0
- package/dist/project-profiles/profiles/java-maven.d.ts +80 -0
- package/dist/project-profiles/profiles/java-maven.js +165 -0
- package/dist/project-profiles/profiles/java-maven.js.map +1 -0
- package/dist/project-profiles/profiles/javascript-npm.d.ts +40 -0
- package/dist/project-profiles/profiles/javascript-npm.js +118 -0
- package/dist/project-profiles/profiles/javascript-npm.js.map +1 -0
- package/dist/project-profiles/profiles/javascript-react.d.ts +46 -0
- package/dist/project-profiles/profiles/javascript-react.js +147 -0
- package/dist/project-profiles/profiles/javascript-react.js.map +1 -0
- package/dist/project-profiles/profiles/python-django.d.ts +58 -0
- package/dist/project-profiles/profiles/python-django.js +200 -0
- package/dist/project-profiles/profiles/python-django.js.map +1 -0
- package/dist/project-profiles/types.d.ts +122 -0
- package/dist/project-profiles/types.js +77 -0
- package/dist/project-profiles/types.js.map +1 -0
- package/dist/prompt/function-calling.js +8 -3
- package/dist/prompt/function-calling.js.map +1 -1
- package/dist/prompt/function-defs/ask-question.d.ts +5 -0
- package/dist/prompt/function-defs/ask-question.js +140 -60
- package/dist/prompt/function-defs/ask-question.js.map +1 -1
- package/dist/prompt/function-defs/codegen-planning.d.ts +8 -0
- package/dist/prompt/function-defs/codegen-planning.js +50 -0
- package/dist/prompt/function-defs/codegen-planning.js.map +1 -0
- package/dist/prompt/function-defs/codegen-summary.js +2 -2
- package/dist/prompt/function-defs/codegen-summary.js.map +1 -1
- package/dist/prompt/function-defs/get-source-code.js +32 -2
- package/dist/prompt/function-defs/get-source-code.js.map +1 -1
- package/dist/prompt/function-defs/optimize-context.js +35 -12
- package/dist/prompt/function-defs/optimize-context.js.map +1 -1
- package/dist/prompt/function-defs/set-summaries.js +20 -1
- package/dist/prompt/function-defs/set-summaries.js.map +1 -1
- package/dist/prompt/limits.js +2 -2
- package/dist/prompt/limits.js.map +1 -1
- package/dist/prompt/limits.test.js +3 -3
- package/dist/prompt/limits.test.js.map +1 -1
- package/dist/prompt/prompt-codegen.js +7 -79
- package/dist/prompt/prompt-codegen.js.map +1 -1
- package/dist/prompt/prompt-codegen.test.js +8 -14
- package/dist/prompt/prompt-codegen.test.js.map +1 -1
- package/dist/prompt/prompt-service-ask-question.test.js +27 -80
- package/dist/prompt/prompt-service-ask-question.test.js.map +1 -1
- package/dist/prompt/prompt-service.ai-services.test.d.ts +1 -0
- package/dist/prompt/prompt-service.ai-services.test.js +149 -0
- package/dist/prompt/prompt-service.ai-services.test.js.map +1 -0
- package/dist/prompt/prompt-service.context-optimization.test.d.ts +1 -0
- package/dist/prompt/prompt-service.context-optimization.test.js +212 -0
- package/dist/prompt/prompt-service.context-optimization.test.js.map +1 -0
- package/dist/prompt/prompt-service.image-handling.test.d.ts +1 -0
- package/dist/prompt/prompt-service.image-handling.test.js +212 -0
- package/dist/prompt/prompt-service.image-handling.test.js.map +1 -0
- package/dist/prompt/prompt-service.js +41 -127
- package/dist/prompt/prompt-service.js.map +1 -1
- package/dist/prompt/prompt-service.test-utils.d.ts +66 -0
- package/dist/prompt/prompt-service.test-utils.js +169 -0
- package/dist/prompt/prompt-service.test-utils.js.map +1 -0
- package/dist/prompt/prompt-service.test.js +96 -20
- package/dist/prompt/prompt-service.test.js.map +1 -1
- package/dist/prompt/prompt-service.validation-recovery.test.d.ts +1 -0
- package/dist/prompt/prompt-service.validation-recovery.test.js +263 -0
- package/dist/prompt/prompt-service.validation-recovery.test.js.map +1 -0
- package/dist/prompt/static-prompts.d.ts +16 -0
- package/dist/prompt/static-prompts.js +22 -0
- package/dist/prompt/static-prompts.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js +1 -3
- package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/code-generation.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/code-generation.js +58 -0
- package/dist/prompt/steps/step-ask-question/handlers/code-generation.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.js +8 -7
- package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js +6 -6
- package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/default-action.js +1 -4
- package/dist/prompt/steps/step-ask-question/handlers/default-action.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.js +86 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer-with-image.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.js +97 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js +20 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handler-utils.d.ts +0 -0
- package/dist/prompt/steps/step-ask-question/handlers/handler-utils.js +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handler-utils.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.js +57 -15
- package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/request-files-content.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js +109 -12
- package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/request-permissions.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/request-permissions.js +48 -26
- package/dist/prompt/steps/step-ask-question/handlers/request-permissions.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.js +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.js +1 -0
- package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/step-ask-question-types.d.ts +25 -21
- package/dist/prompt/steps/step-ask-question/step-ask-question.d.ts +2 -5
- package/dist/prompt/steps/step-ask-question/step-ask-question.js +36 -33
- package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -1
- package/dist/prompt/steps/step-codegen-planning.d.ts +10 -0
- package/dist/prompt/steps/step-codegen-planning.js +69 -0
- package/dist/prompt/steps/step-codegen-planning.js.map +1 -0
- package/dist/prompt/steps/step-codegen-summary.d.ts +7 -0
- package/dist/prompt/steps/step-codegen-summary.js +106 -0
- package/dist/prompt/steps/step-codegen-summary.js.map +1 -0
- package/dist/prompt/steps/step-codegen-summary.test.d.ts +1 -0
- package/dist/prompt/steps/step-codegen-summary.test.js +136 -0
- package/dist/prompt/steps/step-codegen-summary.test.js.map +1 -0
- package/dist/prompt/steps/step-context-optimization.js +243 -126
- package/dist/prompt/steps/step-context-optimization.js.map +1 -1
- package/dist/prompt/steps/step-context-optimization.test.d.ts +2 -0
- package/dist/prompt/steps/step-context-optimization.test.js +475 -0
- package/dist/prompt/steps/step-context-optimization.test.js.map +1 -0
- package/dist/prompt/steps/step-ensure-context.d.ts +15 -0
- package/dist/prompt/steps/step-ensure-context.js +102 -0
- package/dist/prompt/steps/step-ensure-context.js.map +1 -0
- package/dist/prompt/steps/step-ensure-context.test.d.ts +1 -0
- package/dist/prompt/steps/step-ensure-context.test.js +242 -0
- package/dist/prompt/steps/step-ensure-context.test.js.map +1 -0
- package/dist/prompt/steps/step-generate-image.d.ts +8 -1
- package/dist/prompt/steps/step-generate-image.js +1 -0
- package/dist/prompt/steps/step-generate-image.js.map +1 -1
- package/dist/prompt/steps/step-summarization.d.ts +2 -2
- package/dist/prompt/steps/step-summarization.js +45 -9
- package/dist/prompt/steps/step-summarization.js.map +1 -1
- package/dist/prompt/steps/step-validate-recover.js +24 -15
- package/dist/prompt/steps/step-validate-recover.js.map +1 -1
- package/dist/prompt/steps/steps-types.d.ts +2 -0
- package/dist/prompt/steps/steps-types.js.map +1 -1
- package/dist/prompt/systemprompt.d.ts +2 -2
- package/dist/prompt/systemprompt.js +74 -176
- package/dist/prompt/systemprompt.js.map +1 -1
- package/dist/prompt/systemprompt.test.js +4 -5
- package/dist/prompt/systemprompt.test.js.map +1 -1
- package/dist/vite-genaicode/vite-genaicode-plugin.js +0 -2
- package/dist/vite-genaicode/vite-genaicode-plugin.js.map +1 -1
- package/package.json +6 -2
- package/dist/main/ui/frontend/assets/index-Dk_qaEQg.js +0 -782
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import { getRegisteredActionHandlerDescriptions, getRegisteredActionHandlers } from '../../main/plugin-loader.js';
|
|
2
|
-
/**
|
|
3
|
-
* Function definition for askQuestion
|
|
4
|
-
*
|
|
5
|
-
* Use this function to ask questions, seek clarification, request file permissions, or manage the flow of the conversation.
|
|
6
|
-
* Each actionType serves a specific purpose, ensuring clarity and proper task execution.
|
|
7
|
-
*/
|
|
8
2
|
function getActionTypeDescription() {
|
|
9
3
|
const pluginDescriptions = Array.from(getRegisteredActionHandlerDescriptions().entries())
|
|
10
4
|
.map(([actionType, description]) => ` - ${actionType}: ${description}`)
|
|
11
5
|
.join('\n');
|
|
12
|
-
return `This value instructs the program on what should happen next.
|
|
6
|
+
return `This value instructs the program on what should happen next.
|
|
13
7
|
|
|
14
8
|
Detailed Explanation of actionTypes:
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
9
|
+
- sendMessage: Use for general information, clarifications, or when no specific code is needed.
|
|
10
|
+
- sendMessageWithImage: Use when an image is needed to provide context or additional information.
|
|
11
|
+
- requestPermissions: Use **only when you lack necessary permissions** for actions like creating, deleting, or moving files, and need to request them from the user.
|
|
12
|
+
- requestFilesContent: Use specifically when needing to access or review the contents of files, and it was not provided yet in any of preceeding \`getSourceCode\` function responses.
|
|
18
13
|
- removeFilesFromContext: Use to remove unnecessary file contents from context, optimizing token usage.
|
|
19
14
|
- confirmCodeGeneration: Use to confirm with the user before starting code generation tasks.
|
|
20
|
-
-
|
|
21
|
-
- cancelCodeGeneration: Use if code generation should be stopped or canceled.
|
|
15
|
+
- cancelCodeGeneration: Use to stop the session, and the conversation.
|
|
22
16
|
- contextOptimization: Use to manage and optimize context during code generation tasks, allowing the LLM to provide guidance on what parts of the context are most relevant to keep.
|
|
23
17
|
${pluginDescriptions}`;
|
|
24
18
|
}
|
|
@@ -30,85 +24,171 @@ ${pluginDescriptions}`;
|
|
|
30
24
|
*/
|
|
31
25
|
export const getAskQuestionDef = () => ({
|
|
32
26
|
name: 'askQuestion',
|
|
33
|
-
description:
|
|
27
|
+
description: `Use this function to interact with the user for various purposes.
|
|
28
|
+
The \`decisionMakingProcess\` must be provided as first parameter to ensure clarity in decision-making, and impact on selection of \`actionType\` and \`message\`.
|
|
29
|
+
The \`message\` property must align with the chosen \`actionType\`.
|
|
30
|
+
|
|
31
|
+
The desired format of parameters is as follows:
|
|
32
|
+
\`\`\`
|
|
33
|
+
{
|
|
34
|
+
"decisionMakingProcess": "...", // A detailed decision-making framework the assistant followed before selecting an action.",
|
|
35
|
+
"actionType": "...", // The type of action to perform.
|
|
36
|
+
"message": "..." // The message to display to the user.
|
|
37
|
+
}
|
|
38
|
+
\`\`\`
|
|
39
|
+
|
|
40
|
+
**IMPORTANT**: Mind the order of the parameters, as the decision-making process must be provided first to ensure clarity in decision-making.
|
|
41
|
+
`,
|
|
34
42
|
parameters: {
|
|
35
43
|
type: 'object',
|
|
36
44
|
properties: {
|
|
45
|
+
decisionMakingProcess: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
description: `A detailed decision-making framework the assistant followed before selecting an action. You must think step about step about this, this process should include the following steps:
|
|
48
|
+
|
|
49
|
+
1. **Contextual Analysis**: Assess the current information, including available permissions, current context, and task requirements. Identify any missing elements that are critical to task completion.
|
|
50
|
+
|
|
51
|
+
2. **Decision Justification**: State the reasoning for the proposed action, considering whether planning, clarification, or action is required. If there's any ambiguity, prefer a confirmatory action (\`confirmCodeGeneration\`).
|
|
52
|
+
|
|
53
|
+
3. **Minimal Action Selection**: Determine the minimal action that can make progress toward the task goal. Avoid requesting unnecessary permissions or context that isn't strictly needed.
|
|
54
|
+
|
|
55
|
+
4. **Evaluation of Action Choice**: Double-check if the selected action aligns with task requirements and user-provided constraints.
|
|
56
|
+
|
|
57
|
+
Output this in step-by-step format to ensure clarity in decision-making.`,
|
|
58
|
+
},
|
|
37
59
|
actionType: {
|
|
38
60
|
type: 'string',
|
|
39
61
|
enum: [
|
|
40
|
-
'
|
|
62
|
+
'sendMessage',
|
|
63
|
+
'sendMessageWithImage',
|
|
41
64
|
'requestPermissions',
|
|
42
65
|
'requestFilesContent',
|
|
43
66
|
'removeFilesFromContext',
|
|
44
67
|
'confirmCodeGeneration',
|
|
45
|
-
'startCodeGeneration',
|
|
46
68
|
'cancelCodeGeneration',
|
|
47
69
|
'contextOptimization',
|
|
48
70
|
...Array.from(getRegisteredActionHandlers().keys()),
|
|
49
71
|
],
|
|
50
72
|
description: getActionTypeDescription(),
|
|
51
73
|
},
|
|
52
|
-
|
|
74
|
+
message: {
|
|
53
75
|
type: 'string',
|
|
54
|
-
description: 'The message
|
|
76
|
+
description: 'The message to display to the user.',
|
|
55
77
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
78
|
+
},
|
|
79
|
+
required: ['decisionMakingProcess', 'actionType', 'message'],
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
// requestFilesContent
|
|
83
|
+
export const requestFilesContent = {
|
|
84
|
+
name: 'requestFilesContent',
|
|
85
|
+
description: 'Use this function to request the content of files that are missing from the context.',
|
|
86
|
+
parameters: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
filePaths: {
|
|
63
90
|
type: 'array',
|
|
64
|
-
description: 'An array of absolute file paths for which you need the content. Use this when specific files are missing and you need them to proceed with the task.',
|
|
65
91
|
items: {
|
|
66
92
|
type: 'string',
|
|
67
93
|
},
|
|
94
|
+
description: 'An array of absolute file paths for which you need the content.',
|
|
68
95
|
},
|
|
69
|
-
|
|
96
|
+
},
|
|
97
|
+
required: ['filePaths'],
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
// sendMessageWithImage
|
|
101
|
+
export const sendMessageWithImage = {
|
|
102
|
+
name: 'sendMessageWithImage',
|
|
103
|
+
description: 'Use this function to send message to the user with accompanying image that will be generated using provided prompt, and optionally using other image as a context.',
|
|
104
|
+
parameters: {
|
|
105
|
+
type: 'object',
|
|
106
|
+
properties: {
|
|
107
|
+
prompt: {
|
|
108
|
+
type: 'string',
|
|
109
|
+
description: 'The prompt used to generate the image.',
|
|
110
|
+
},
|
|
111
|
+
contextImage: {
|
|
112
|
+
type: 'string',
|
|
113
|
+
description: 'Optional path to an image file used as context for image generation.',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
required: ['prompt'],
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
// removeFilesFromContext
|
|
120
|
+
export const removeFilesFromContext = {
|
|
121
|
+
name: 'removeFilesFromContext',
|
|
122
|
+
description: 'Use this function to remove files from the context that are no longer needed for code generation.',
|
|
123
|
+
parameters: {
|
|
124
|
+
type: 'object',
|
|
125
|
+
properties: {
|
|
126
|
+
filePaths: {
|
|
70
127
|
type: 'array',
|
|
71
|
-
description: 'An array of absolute file paths that should be removed from the context. Use this to optimize token usage by removing unnecessary file contents.',
|
|
72
128
|
items: {
|
|
73
129
|
type: 'string',
|
|
74
130
|
},
|
|
131
|
+
description: 'An array of absolute file paths to remove from the context.',
|
|
75
132
|
},
|
|
76
|
-
|
|
133
|
+
},
|
|
134
|
+
required: ['filePaths'],
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
// contextOptimization
|
|
138
|
+
export const contextOptimization = {
|
|
139
|
+
name: 'contextOptimization',
|
|
140
|
+
description: 'Use this function to optimize the context for code generation by specifying which parts are most relevant to keep.',
|
|
141
|
+
parameters: {
|
|
142
|
+
type: 'object',
|
|
143
|
+
properties: {
|
|
144
|
+
prompt: {
|
|
77
145
|
type: 'string',
|
|
78
|
-
description: '
|
|
146
|
+
description: 'The prompt used to guide the user in optimizing the context.',
|
|
79
147
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
148
|
+
},
|
|
149
|
+
required: ['prompt'],
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
// requestPermissions
|
|
153
|
+
export const requestPermissions = {
|
|
154
|
+
name: 'requestPermissions',
|
|
155
|
+
description: 'Use this function to request additional permissions needed for code generation if not already granted.',
|
|
156
|
+
parameters: {
|
|
157
|
+
type: 'object',
|
|
158
|
+
properties: {
|
|
159
|
+
allowDirectoryCreate: {
|
|
160
|
+
description: 'Request permission to create directories.',
|
|
161
|
+
type: 'boolean',
|
|
162
|
+
},
|
|
163
|
+
allowFileCreate: {
|
|
164
|
+
description: 'Request permission to create files.',
|
|
165
|
+
type: 'boolean',
|
|
166
|
+
},
|
|
167
|
+
allowFileDelete: {
|
|
168
|
+
description: 'Request permission to delete files.',
|
|
169
|
+
type: 'boolean',
|
|
170
|
+
},
|
|
171
|
+
allowFileMove: {
|
|
172
|
+
description: 'Request permission to move files.',
|
|
173
|
+
type: 'boolean',
|
|
174
|
+
},
|
|
175
|
+
enableVision: {
|
|
176
|
+
description: 'Request permission for vision capabilities, using images as context for code generation.',
|
|
177
|
+
type: 'boolean',
|
|
178
|
+
},
|
|
179
|
+
enableImagen: {
|
|
180
|
+
description: 'Request permission to generate images.',
|
|
181
|
+
type: 'boolean',
|
|
109
182
|
},
|
|
110
183
|
},
|
|
111
|
-
required: [
|
|
184
|
+
required: [
|
|
185
|
+
'allowDirectoryCreate',
|
|
186
|
+
'allowFileCreate',
|
|
187
|
+
'allowFileDelete',
|
|
188
|
+
'allowFileMove',
|
|
189
|
+
'enableVision',
|
|
190
|
+
'enableImagen',
|
|
191
|
+
],
|
|
112
192
|
},
|
|
113
|
-
}
|
|
193
|
+
};
|
|
114
194
|
//# sourceMappingURL=ask-question.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask-question.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/ask-question.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sCAAsC,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAElH
|
|
1
|
+
{"version":3,"file":"ask-question.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/ask-question.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sCAAsC,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAElH,SAAS,wBAAwB;IAC/B,MAAM,kBAAkB,GAAG,KAAK,CAAC,IAAI,CAAC,sCAAsC,EAAE,CAAC,OAAO,EAAE,CAAC;SACtF,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,MAAM,UAAU,KAAK,WAAW,EAAE,CAAC;SACtE,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;;;;;;;;;;;EAWP,kBAAkB,EAAE,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC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AAqC;gBAClD,IAAI,EAAE,SAAS;aAChB;YACD,aAAa,EAAE;gBACb,WAAW,EAAE,mCAAmC;gBAChD,IAAI,EAAE,SAAS;aAChB;YACD,YAAY,EAAE;gBACZ,WAAW,EAAE,0FAA0F;gBACvG,IAAI,EAAE,SAAS;aAChB;YACD,YAAY,EAAE;gBACZ,WAAW,EAAE,wCAAwC;gBACrD,IAAI,EAAE,SAAS;aAChB;SACF;QACD,QAAQ,EAAE;YACR,sBAAsB;YACtB,iBAAiB;YACjB,iBAAiB;YACjB,eAAe;YACf,cAAc;YACd,cAAc;SACf;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FunctionDef } from '../../ai-service/common.js';
|
|
2
|
+
/**
|
|
3
|
+
* Function definition for codegenPlanning
|
|
4
|
+
* This function analyzes the conversation and produces a detailed implementation plan
|
|
5
|
+
* before proceeding with actual code generation. This helps ensure all necessary files
|
|
6
|
+
* are identified and dependencies are properly handled.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getCodegenPlanningDef: () => FunctionDef;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for codegenPlanning
|
|
3
|
+
* This function analyzes the conversation and produces a detailed implementation plan
|
|
4
|
+
* before proceeding with actual code generation. This helps ensure all necessary files
|
|
5
|
+
* are identified and dependencies are properly handled.
|
|
6
|
+
*/
|
|
7
|
+
export const getCodegenPlanningDef = () => ({
|
|
8
|
+
name: 'codegenPlanning',
|
|
9
|
+
description: 'Analyzes the conversation to produce an implementation plan, identifying all affected files and dependencies before code generation.',
|
|
10
|
+
parameters: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
problemAnalysis: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
description: 'Detailed analysis of the problem.',
|
|
16
|
+
},
|
|
17
|
+
codeChanges: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
description: 'A step by step plan of code changes neccessary to solve the problem.',
|
|
20
|
+
},
|
|
21
|
+
affectedFiles: {
|
|
22
|
+
type: 'array',
|
|
23
|
+
description: 'A list of all files that need to be modified. The reason must precede the file path.',
|
|
24
|
+
items: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: {
|
|
27
|
+
reason: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'Reason for modifying this file.',
|
|
30
|
+
},
|
|
31
|
+
filePath: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Absolute path of the file.',
|
|
34
|
+
},
|
|
35
|
+
dependencies: {
|
|
36
|
+
type: 'array',
|
|
37
|
+
description: 'Related files that depend on or are depended upon by this file.',
|
|
38
|
+
items: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
required: ['reason', 'filePath'],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
required: ['problemAnalysis', 'codeChanges', 'affectedFiles'],
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=codegen-planning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen-planning.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/codegen-planning.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAgB,EAAE,CAAC,CAAC;IACvD,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,sIAAsI;IACxI,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,eAAe,EAAE;gBACf,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mCAAmC;aACjD;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,sEAAsE;aACpF;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,sFAAsF;gBACnG,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,MAAM,EAAE;4BACN,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,iCAAiC;yBAC/C;wBACD,QAAQ,EAAE;4BACR,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,4BAA4B;yBAC1C;wBACD,YAAY,EAAE;4BACZ,IAAI,EAAE,OAAO;4BACb,WAAW,EAAE,iEAAiE;4BAC9E,KAAK,EAAE;gCACL,IAAI,EAAE,QAAQ;6BACf;yBACF;qBACF;oBACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;iBACjC;aACF;SACF;QACD,QAAQ,EAAE,CAAC,iBAAiB,EAAE,aAAa,EAAE,eAAe,CAAC;KAC9D;CACF,CAAC,CAAC"}
|
|
@@ -6,9 +6,9 @@ export const getCodegenSummaryDef = () => ({
|
|
|
6
6
|
name: 'codegenSummary',
|
|
7
7
|
description: 'This function is called with a summary of proposed updates.\n' +
|
|
8
8
|
'- `explanation`: A general explanation of the planned code generation updates or reasoning for no code changes.\n' +
|
|
9
|
-
'- `fileUpdates`: A list of proposed file updates
|
|
9
|
+
'- `fileUpdates`: A list of proposed file updates, including all affected files and dependencies.\n' +
|
|
10
10
|
'- `contextPaths`: A list of file paths that make sense to use as context for code generation requests.\n' +
|
|
11
|
-
'It is critically important to adhere to the schema of parameters.',
|
|
11
|
+
'It is critically important to adhere to the schema of parameters and include all relevant files.',
|
|
12
12
|
parameters: {
|
|
13
13
|
type: 'object',
|
|
14
14
|
properties: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-summary.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/codegen-summary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAgB,EAAE,CAAC,CAAC;IACtD,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,+DAA+D;QAC/D,mHAAmH;QACnH,
|
|
1
|
+
{"version":3,"file":"codegen-summary.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/codegen-summary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAgB,EAAE,CAAC,CAAC;IACtD,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,+DAA+D;QAC/D,mHAAmH;QACnH,oGAAoG;QACpG,0GAA0G;QAC1G,kGAAkG;IACpG,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0FAA0F;aACxG;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,sFAAsF;gBACnG,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,8JAA8J;oBAChK,UAAU,EAAE;wBACV,QAAQ,EAAE;4BACR,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,gGAAgG;yBACnG;wBACD,MAAM,EAAE;4BACN,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,wJAAwJ;yBAC3J;wBACD,cAAc,EAAE;4BACd,IAAI,EAAE,QAAQ;4BACd,IAAI,EAAE;gCACJ,YAAY;gCACZ,YAAY;gCACZ,WAAW;gCACX,YAAY;gCACZ,iBAAiB;gCACjB,UAAU;gCACV,eAAe;gCACf,cAAc;gCACd,YAAY;gCACZ,aAAa;gCACb,uBAAuB;gCACvB,GAAG,uBAAuB,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;6BACpE;4BACD,WAAW,EAAE,+DAA+D;yBAC7E;wBACD,WAAW,EAAE;4BACX,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,oIAAoI;4BACtI,OAAO,EAAE,GAAG;4BACZ,OAAO,EAAE,GAAG;yBACb;wBACD,KAAK,EAAE;4BACL,IAAI,EAAE,SAAS;4BACf,WAAW,EACT,4JAA4J;yBAC/J;wBACD,kBAAkB,EAAE;4BAClB,IAAI,EAAE,OAAO;4BACb,WAAW,EACT,8JAA8J;4BAChK,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;yBAC1B;qBACF;oBACD,QAAQ,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,gBAAgB,CAAC;iBACnD;aACF;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,gLAAgL;gBAClL,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;SACF;QACD,QAAQ,EAAE,CAAC,aAAa,EAAE,aAAa,EAAE,cAAc,CAAC;KACzD;CACF,CAAC,CAAC"}
|
|
@@ -3,8 +3,38 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const getSourceCode = {
|
|
5
5
|
name: 'getSourceCode',
|
|
6
|
-
description:
|
|
7
|
-
|
|
6
|
+
description: `This function returns source code of the application in the following format:
|
|
7
|
+
\`\`\`
|
|
8
|
+
{
|
|
9
|
+
[directoryPath: string]: {
|
|
10
|
+
[filePath: string]: {content: string | null} | {summary: string};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
\`\`\`
|
|
14
|
+
|
|
15
|
+
Some keys may not provide content. Some keys may provide a short summary of content.
|
|
16
|
+
|
|
17
|
+
Here is an example of the returned object:
|
|
18
|
+
\`\`\`
|
|
19
|
+
{
|
|
20
|
+
'/path/to/directory': {
|
|
21
|
+
'file1.js': {content: 'console.log('Hello, World!');'},
|
|
22
|
+
},
|
|
23
|
+
'/path/to/directory/sub1/sub2': {
|
|
24
|
+
'file2.js': {summary: 'This file contains a simple log statement.'},
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
\`\`\`
|
|
28
|
+
|
|
29
|
+
How to understand this object:
|
|
30
|
+
- there are 2 files
|
|
31
|
+
- the first file has content: 'console.log('Hello, World!');'
|
|
32
|
+
- the second file has no content, but a summary: 'This file contains a simple log statement.'
|
|
33
|
+
- path of first file: '/path/to/directory/file1.js'
|
|
34
|
+
- path of second file: '/path/to/directory/sub1/sub2/file2.js'
|
|
35
|
+
|
|
36
|
+
This function is used to provide context to the AI model.
|
|
37
|
+
`,
|
|
8
38
|
parameters: {
|
|
9
39
|
type: 'object',
|
|
10
40
|
properties: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-source-code.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/get-source-code.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAgB;IACxC,IAAI,EAAE,eAAe;IACrB,WAAW,
|
|
1
|
+
{"version":3,"file":"get-source-code.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/get-source-code.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAgB;IACxC,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+BV;IACH,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,8EAA8E;gBAC3F,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;SACF;QACD,QAAQ,EAAE,EAAE;KACb;CACF,CAAC"}
|
|
@@ -3,7 +3,39 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const optimizeContext = {
|
|
5
5
|
name: 'optimizeContext',
|
|
6
|
-
description:
|
|
6
|
+
description: `This function helps prioritize files based on their importance to the user prompt.
|
|
7
|
+
|
|
8
|
+
Example:
|
|
9
|
+
1. User prompt: "I want to add a new test to util unit tests."
|
|
10
|
+
2. Assistant makes a function call for \`getSourceCode\` to get the source code.
|
|
11
|
+
3. User provides the source code in \`getSourceCode\` function response:
|
|
12
|
+
\`\`\`
|
|
13
|
+
{
|
|
14
|
+
'/path/to/directory': {
|
|
15
|
+
'something.js': ['console.log('Hello, World!');'],
|
|
16
|
+
},
|
|
17
|
+
'/path/to/directory/sub1/sub2': {
|
|
18
|
+
'util-tests.js': [null, 'This file contains unit tests.'],
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
\`\`\`
|
|
22
|
+
4. Assistant calls the \`optimizeContext\` function to narrow the context to relevant files:
|
|
23
|
+
\`\`\`
|
|
24
|
+
{
|
|
25
|
+
userPrompt: "I want to add a new test to util unit tests.",
|
|
26
|
+
optimizedContext: [
|
|
27
|
+
{
|
|
28
|
+
filePath: '/path/to/directory/sub1/sub2/util-tests.js',
|
|
29
|
+
relevance: 0.8,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
filePath: '/path/to/directory/something.js',
|
|
33
|
+
relevance: 0.2,
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
\`\`\`
|
|
37
|
+
|
|
38
|
+
This means that the file \`something.js\` file is less relevant to the user prompt, and \`util-tests.js\` is more relevant.`,
|
|
7
39
|
parameters: {
|
|
8
40
|
type: 'object',
|
|
9
41
|
properties: {
|
|
@@ -27,21 +59,12 @@ export const optimizeContext = {
|
|
|
27
59
|
minimum: 0,
|
|
28
60
|
maximum: 1,
|
|
29
61
|
},
|
|
30
|
-
tokenCount: {
|
|
31
|
-
type: 'integer',
|
|
32
|
-
description: 'The estimated token count for the file content.',
|
|
33
|
-
minimum: 0,
|
|
34
|
-
},
|
|
35
62
|
},
|
|
36
|
-
required: ['filePath', 'relevance'
|
|
63
|
+
required: ['filePath', 'relevance'],
|
|
37
64
|
},
|
|
38
65
|
},
|
|
39
|
-
totalTokenCount: {
|
|
40
|
-
type: 'number',
|
|
41
|
-
description: 'The estimated token count for the entire context.',
|
|
42
|
-
},
|
|
43
66
|
},
|
|
44
|
-
required: ['userPrompt', 'optimizedContext'
|
|
67
|
+
required: ['userPrompt', 'optimizedContext'],
|
|
45
68
|
},
|
|
46
69
|
};
|
|
47
70
|
//# sourceMappingURL=optimize-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimize-context.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/optimize-context.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,WAAW,
|
|
1
|
+
{"version":3,"file":"optimize-context.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/optimize-context.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4HAgC6G;IAC1H,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6BAA6B;aAC3C;YACD,gBAAgB,EAAE;gBAChB,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,4FAA4F;gBACzG,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,QAAQ,EAAE;4BACR,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,4CAA4C;yBAC1D;wBACD,SAAS,EAAE;4BACT,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,8EAA8E;4BAC3F,OAAO,EAAE,CAAC;4BACV,OAAO,EAAE,CAAC;yBACX;qBACF;oBACD,QAAQ,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC;iBACpC;aACF;SACF;QACD,QAAQ,EAAE,CAAC,YAAY,EAAE,kBAAkB,CAAC;KAC7C;CACF,CAAC"}
|
|
@@ -21,8 +21,27 @@ export const setSummaries = {
|
|
|
21
21
|
type: 'string',
|
|
22
22
|
description: "A summary of the file's content, highlighting its main purpose, functionality, or details which may be useful for context optimization.",
|
|
23
23
|
},
|
|
24
|
+
dependencies: {
|
|
25
|
+
type: 'array',
|
|
26
|
+
description: 'Optional list of file dependencies detected in the source code.',
|
|
27
|
+
items: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
path: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'Path to the dependent file or package/library name for external dependencies.',
|
|
33
|
+
},
|
|
34
|
+
type: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
enum: ['local', 'external'],
|
|
37
|
+
description: 'Type of dependency - local (file in project) or external (package/library/module).',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
required: ['path', 'type'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
24
43
|
},
|
|
25
|
-
required: ['filePath', 'summary'],
|
|
44
|
+
required: ['filePath', 'summary', 'dependencies'],
|
|
26
45
|
},
|
|
27
46
|
},
|
|
28
47
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-summaries.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/set-summaries.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgB;IACvC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,8CAA8C;IAC3D,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,sHAAsH;gBACxH,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,QAAQ,EAAE;4BACR,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,8CAA8C;yBAC5D;wBACD,OAAO,EAAE;4BACP,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,yIAAyI;yBAC5I;qBACF;oBACD,QAAQ,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"set-summaries.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/set-summaries.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgB;IACvC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,8CAA8C;IAC3D,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,sHAAsH;gBACxH,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,QAAQ,EAAE;4BACR,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,8CAA8C;yBAC5D;wBACD,OAAO,EAAE;4BACP,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,yIAAyI;yBAC5I;wBACD,YAAY,EAAE;4BACZ,IAAI,EAAE,OAAO;4BACb,WAAW,EAAE,iEAAiE;4BAC9E,KAAK,EAAE;gCACL,IAAI,EAAE,QAAQ;gCACd,UAAU,EAAE;oCACV,IAAI,EAAE;wCACJ,IAAI,EAAE,QAAQ;wCACd,WAAW,EAAE,+EAA+E;qCAC7F;oCACD,IAAI,EAAE;wCACJ,IAAI,EAAE,QAAQ;wCACd,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;wCAC3B,WAAW,EAAE,oFAAoF;qCAClG;iCACF;gCACD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;6BAC3B;yBACF;qBACF;oBACD,QAAQ,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,cAAc,CAAC;iBAClD;aACF;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB;CACF,CAAC"}
|
package/dist/prompt/limits.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import { estimateTokenCount } from './token-estimator.js';
|
|
3
|
-
const SYSTEM_PROMPT_LIMIT =
|
|
4
|
-
const CODEGEN_PROMPT_LIMIT =
|
|
3
|
+
const SYSTEM_PROMPT_LIMIT = 3500;
|
|
4
|
+
const CODEGEN_PROMPT_LIMIT = 1000;
|
|
5
5
|
const SOURCE_CODE_LIMIT = 100000;
|
|
6
6
|
function verifyPromptLimit(promptType, prompt, limit) {
|
|
7
7
|
const tokenCount = estimateTokenCount(prompt);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/prompt/limits.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,oBAAoB,GAAG,
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/prompt/limits.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC,SAAS,iBAAiB,CAAC,UAAkB,EAAE,MAAc,EAAE,KAAa;IAC1E,MAAM,UAAU,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,kCAAkC,UAAU,EAAE,CAAC,CAAC;IACzE,MAAM,CAAC,UAAU,IAAI,KAAK,EAAE,yBAAyB,UAAU,MAAM,KAAK,EAAE,CAAC,CAAC;IAC9E,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,YAAoB;IAC1D,OAAO,iBAAiB,CAAC,QAAQ,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,aAAqB;IAC5D,OAAO,iBAAiB,CAAC,SAAS,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,UAAkB;IACtD,OAAO,iBAAiB,CAAC,YAAY,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -7,8 +7,8 @@ describe('Prompt Limits', () => {
|
|
|
7
7
|
expect(() => verifySystemPromptLimit(validPrompt)).not.toThrow();
|
|
8
8
|
});
|
|
9
9
|
it('should throw for a prompt exceeding the limit', () => {
|
|
10
|
-
const invalidPrompt = 'A '.repeat(
|
|
11
|
-
expect(() => verifySystemPromptLimit(invalidPrompt)).toThrow('Token limit exceeded:
|
|
10
|
+
const invalidPrompt = 'A '.repeat(6000);
|
|
11
|
+
expect(() => verifySystemPromptLimit(invalidPrompt)).toThrow('Token limit exceeded: 3900 > 3500');
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
describe('verifyCodegenPromptLimit', () => {
|
|
@@ -18,7 +18,7 @@ describe('Prompt Limits', () => {
|
|
|
18
18
|
});
|
|
19
19
|
it('should throw for a prompt exceeding the limit', () => {
|
|
20
20
|
const invalidPrompt = 'B '.repeat(10000);
|
|
21
|
-
expect(() => verifyCodegenPromptLimit(invalidPrompt)).toThrow('Token limit exceeded: 6500 >
|
|
21
|
+
expect(() => verifyCodegenPromptLimit(invalidPrompt)).toThrow('Token limit exceeded: 6500 > 1000');
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
describe('verifySourceCodeLimit', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.test.js","sourceRoot":"","sources":["../../src/prompt/limits.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,wB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