genaicode 0.8.5 → 0.8.6
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 +18 -1
- package/dist/ai-service/common.js +3 -2
- package/dist/ai-service/common.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/main/config-lib.d.ts +1 -36
- package/dist/main/config-lib.js.map +1 -1
- package/dist/main/config-types.d.ts +36 -0
- package/dist/main/config-types.js +2 -0
- package/dist/main/config-types.js.map +1 -0
- package/dist/main/config.d.ts +1 -1
- package/dist/main/config.js +1 -1
- package/dist/main/config.js.map +1 -1
- package/dist/main/plugin-loader.d.ts +1 -1
- package/dist/main/ui/backend/service.d.ts +1 -1
- package/dist/main/ui/frontend/assets/index-BAAQr5b1.js +1747 -0
- package/dist/main/ui/frontend/index.html +1 -1
- package/dist/prompt/function-calling.js +2 -1
- package/dist/prompt/function-calling.js.map +1 -1
- package/dist/prompt/function-defs/ask-question.d.ts +1 -0
- package/dist/prompt/function-defs/ask-question.js +88 -72
- package/dist/prompt/function-defs/ask-question.js.map +1 -1
- package/dist/prompt/function-defs/optimize-context.js +2 -2
- package/dist/prompt/function-defs/optimize-context.js.map +1 -1
- package/dist/prompt/prompt-service.js +2 -1
- package/dist/prompt/prompt-service.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js +2 -2
- package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.js +3 -3
- 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.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js +2 -2
- package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-search-code.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-search-code.js +5 -5
- package/dist/prompt/steps/step-ask-question/handlers/handle-search-code.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.js +4 -4
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message-with-image.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js +3 -3
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-update-file.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-update-file.js +136 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-update-file.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/lint.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/lint.js +27 -7
- package/dist/prompt/steps/step-ask-question/handlers/lint.js.map +1 -1
- 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 +3 -3
- 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 +7 -7
- 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 +3 -3
- package/dist/prompt/steps/step-ask-question/handlers/request-permissions.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/step-ask-question-types.d.ts +4 -16
- package/dist/prompt/steps/step-ask-question/step-ask-question.js +7 -8
- package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -1
- package/dist/prompt/steps/step-context-optimization.d.ts +3 -0
- package/dist/prompt/steps/step-context-optimization.js +60 -48
- package/dist/prompt/steps/step-context-optimization.js.map +1 -1
- package/dist/prompt/systemprompt.d.ts +2 -1
- package/dist/prompt/systemprompt.js +12 -4
- package/dist/prompt/systemprompt.js.map +1 -1
- package/package.json +1 -1
- package/dist/main/ui/frontend/assets/index-DY7-_JMu.js +0 -1759
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { executor as executeUpdateFile } from '../../../../operations/update-file/update-file-executor.js';
|
|
2
|
+
import { getSourceCode } from '../../../../files/read-files.js';
|
|
3
|
+
import { getFunctionDefs } from '../../../function-calling.js';
|
|
4
|
+
import { askUserForConfirmationWithAnswer } from '../../../../main/common/user-actions.js';
|
|
5
|
+
import { putSystemMessage } from '../../../../main/common/content-bus.js';
|
|
6
|
+
import { refreshFiles } from '../../../../files/find-files.js';
|
|
7
|
+
export const handleUpdateFile = async ({ askQuestionCall, options, prompt, generateContentFn, }) => {
|
|
8
|
+
putSystemMessage('File update requested, new content generation started.', askQuestionCall);
|
|
9
|
+
const [updateFileCall] = (await generateContentFn([
|
|
10
|
+
...prompt,
|
|
11
|
+
{
|
|
12
|
+
type: 'assistant',
|
|
13
|
+
text: askQuestionCall.args?.message ?? '',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: 'user',
|
|
17
|
+
text: 'Ok, please provide the update using `updateFile` function. Please remember to use absolute file path.',
|
|
18
|
+
},
|
|
19
|
+
], getFunctionDefs(), 'updateFile', options.temperature ?? 0.7, false, options));
|
|
20
|
+
if (!updateFileCall || !updateFileCall.args) {
|
|
21
|
+
return {
|
|
22
|
+
breakLoop: true,
|
|
23
|
+
items: [],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const { filePath } = updateFileCall.args;
|
|
27
|
+
const file = getSourceCode({ filterPaths: [filePath], forceAll: true }, options)[filePath];
|
|
28
|
+
if (!file || !('content' in file) || !file.content) {
|
|
29
|
+
// TODO: In this corner case we should probably retry the operation but prefix it with getSourceCode
|
|
30
|
+
return {
|
|
31
|
+
breakLoop: false,
|
|
32
|
+
items: [
|
|
33
|
+
{
|
|
34
|
+
assistant: {
|
|
35
|
+
type: 'assistant',
|
|
36
|
+
text: askQuestionCall.args.message,
|
|
37
|
+
},
|
|
38
|
+
user: {
|
|
39
|
+
type: 'user',
|
|
40
|
+
text: 'The file does not exist or is empty or its content is not present in the context.',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
putSystemMessage(`The assistant suggests updating the file ${filePath}.`, {
|
|
47
|
+
name: updateFileCall.name,
|
|
48
|
+
args: {
|
|
49
|
+
...updateFileCall.args,
|
|
50
|
+
oldContent: file.content,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
const userConfirmation = await askUserForConfirmationWithAnswer('The assistant suggests updating the file. Do you want to proceed?', 'Accept file update', 'Reject file update', false);
|
|
54
|
+
if (!userConfirmation.confirmed) {
|
|
55
|
+
return {
|
|
56
|
+
breakLoop: false,
|
|
57
|
+
items: [
|
|
58
|
+
{
|
|
59
|
+
assistant: {
|
|
60
|
+
type: 'assistant',
|
|
61
|
+
text: askQuestionCall.args.message,
|
|
62
|
+
functionCalls: [updateFileCall],
|
|
63
|
+
},
|
|
64
|
+
user: {
|
|
65
|
+
type: 'user',
|
|
66
|
+
text: 'Rejecting file update.' + (userConfirmation.answer ? ` ${userConfirmation.answer}` : ''),
|
|
67
|
+
functionResponses: [
|
|
68
|
+
{
|
|
69
|
+
name: 'updateFile',
|
|
70
|
+
call_id: updateFileCall.id,
|
|
71
|
+
content: '',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
try {
|
|
81
|
+
await executeUpdateFile(updateFileCall.args);
|
|
82
|
+
refreshFiles();
|
|
83
|
+
return {
|
|
84
|
+
breakLoop: false,
|
|
85
|
+
items: [
|
|
86
|
+
{
|
|
87
|
+
assistant: {
|
|
88
|
+
type: 'assistant',
|
|
89
|
+
text: askQuestionCall.args.message,
|
|
90
|
+
functionCalls: [updateFileCall],
|
|
91
|
+
},
|
|
92
|
+
user: {
|
|
93
|
+
type: 'user',
|
|
94
|
+
text: 'Accepting file update.' + (userConfirmation.answer ? ` ${userConfirmation.answer}` : ''),
|
|
95
|
+
functionResponses: [
|
|
96
|
+
{
|
|
97
|
+
name: 'updateFile',
|
|
98
|
+
call_id: updateFileCall.id,
|
|
99
|
+
content: '',
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return {
|
|
109
|
+
breakLoop: false,
|
|
110
|
+
items: [
|
|
111
|
+
{
|
|
112
|
+
assistant: {
|
|
113
|
+
type: 'assistant',
|
|
114
|
+
text: askQuestionCall.args.message,
|
|
115
|
+
functionCalls: [updateFileCall],
|
|
116
|
+
},
|
|
117
|
+
user: {
|
|
118
|
+
type: 'user',
|
|
119
|
+
text: 'Accepting file update.' +
|
|
120
|
+
(userConfirmation.answer ? ` ${userConfirmation.answer}` : '') +
|
|
121
|
+
' Unfortunately, the file update failed, the new content was not saved.',
|
|
122
|
+
functionResponses: [
|
|
123
|
+
{
|
|
124
|
+
name: 'updateFile',
|
|
125
|
+
call_id: updateFileCall.id,
|
|
126
|
+
content: '',
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=handle-update-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle-update-file.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-update-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,4DAA4D,CAAC;AAE3G,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,MAAM,CAAC,MAAM,gBAAgB,GAAkB,KAAK,EAAE,EACpD,eAAe,EACf,OAAO,EACP,MAAM,EACN,iBAAiB,GAClB,EAAyB,EAAE;IAC1B,gBAAgB,CAAC,wDAAwD,EAAE,eAAe,CAAC,CAAC;IAE5F,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,iBAAiB,CAC/C;QACE,GAAG,MAAM;QACT;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;SAC1C;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,uGAAuG;SAC9G;KACF,EACD,eAAe,EAAE,EACjB,YAAY,EACZ,OAAO,CAAC,WAAW,IAAI,GAAG,EAC1B,KAAK,EACL,OAAO,CACR,CAAkD,CAAC;IAEpD,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;QAC5C,OAAO;YACL,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC,IAAI,CAAC;IAEzC,MAAM,IAAI,GAAG,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,E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AE;gCACjB;oCACE,IAAI,EAAE,YAAY;oCAClB,OAAO,EAAE,cAAc,CAAC,EAAE;oCAC1B,OAAO,EAAE,EAAE;iCACZ;6BACF;yBACF;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -3,4 +3,4 @@ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js'
|
|
|
3
3
|
* Handles the lint action by executing the lint command and processing its results.
|
|
4
4
|
* If the lint command fails, it will ask for user confirmation to continue with code generation.
|
|
5
5
|
*/
|
|
6
|
-
export declare function handleLint({ askQuestionCall
|
|
6
|
+
export declare function handleLint({ askQuestionCall }: ActionHandlerProps): Promise<ActionResult>;
|
|
@@ -7,7 +7,7 @@ const execPromise = promisify(exec);
|
|
|
7
7
|
* Handles the lint action by executing the lint command and processing its results.
|
|
8
8
|
* If the lint command fails, it will ask for user confirmation to continue with code generation.
|
|
9
9
|
*/
|
|
10
|
-
export async function handleLint({ askQuestionCall
|
|
10
|
+
export async function handleLint({ askQuestionCall }) {
|
|
11
11
|
if (!rcConfig.lintCommand) {
|
|
12
12
|
return {
|
|
13
13
|
breakLoop: false,
|
|
@@ -15,11 +15,19 @@ export async function handleLint({ askQuestionCall, askQuestionMessage }) {
|
|
|
15
15
|
{
|
|
16
16
|
assistant: {
|
|
17
17
|
type: 'assistant',
|
|
18
|
-
text:
|
|
18
|
+
text: askQuestionCall.args?.message ?? '',
|
|
19
|
+
functionCalls: [{ name: 'lint', id: askQuestionCall.id + '_lint' }],
|
|
19
20
|
},
|
|
20
21
|
user: {
|
|
21
22
|
type: 'user',
|
|
22
23
|
text: 'Lint command not configured. Skipping lint check.',
|
|
24
|
+
functionResponses: [
|
|
25
|
+
{
|
|
26
|
+
name: 'lint',
|
|
27
|
+
call_id: askQuestionCall.id + '_lint',
|
|
28
|
+
content: JSON.stringify({ error: 'Lint command not configured' }),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
23
31
|
},
|
|
24
32
|
},
|
|
25
33
|
],
|
|
@@ -39,11 +47,19 @@ export async function handleLint({ askQuestionCall, askQuestionMessage }) {
|
|
|
39
47
|
{
|
|
40
48
|
assistant: {
|
|
41
49
|
type: 'assistant',
|
|
42
|
-
text:
|
|
50
|
+
text: askQuestionCall.args?.message ?? '',
|
|
51
|
+
functionCalls: [{ name: 'lint', id: askQuestionCall.id + '_lint' }],
|
|
43
52
|
},
|
|
44
53
|
user: {
|
|
45
54
|
type: 'user',
|
|
46
55
|
text: 'Lint command executed successfully, no issues found.',
|
|
56
|
+
functionResponses: [
|
|
57
|
+
{
|
|
58
|
+
name: 'lint',
|
|
59
|
+
call_id: askQuestionCall.id + '_lint',
|
|
60
|
+
content: JSON.stringify(lintResult),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
47
63
|
},
|
|
48
64
|
},
|
|
49
65
|
],
|
|
@@ -64,15 +80,19 @@ export async function handleLint({ askQuestionCall, askQuestionMessage }) {
|
|
|
64
80
|
{
|
|
65
81
|
assistant: {
|
|
66
82
|
type: 'assistant',
|
|
67
|
-
text:
|
|
68
|
-
functionCalls: [askQuestionCall],
|
|
83
|
+
text: askQuestionCall.args?.message ?? '',
|
|
84
|
+
functionCalls: [{ name: 'lint', id: askQuestionCall.id + '_lint' }],
|
|
69
85
|
},
|
|
70
86
|
user: {
|
|
71
87
|
type: 'user',
|
|
72
|
-
text: 'Lint command failed',
|
|
88
|
+
text: 'Lint command failed, please analyze the output.',
|
|
73
89
|
data: { stdout, stderr },
|
|
74
90
|
functionResponses: [
|
|
75
|
-
{
|
|
91
|
+
{
|
|
92
|
+
name: 'lint',
|
|
93
|
+
call_id: askQuestionCall.id + '_lint',
|
|
94
|
+
content: JSON.stringify(lintResult),
|
|
95
|
+
},
|
|
76
96
|
],
|
|
77
97
|
},
|
|
78
98
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/lint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAGtD,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/lint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAGtD,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,EAAE,eAAe,EAAsB;IACtE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC1B,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE;gBACL;oBACE,SAAS,EAAE;wBACT,IAAI,EAAE,WAAW;wBACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;wBACzC,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,eAAe,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;qBACpE;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,mDAAmD;wBACzD,iBAAiB,EAAE;4BACjB;gCACE,IAAI,EAAE,MAAM;gCACZ,O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B,UAAU;YACV,KAAK,EAAE;gBACL;oBACE,SAAS,EAAE;wBACT,IAAI,EAAE,WAAW;wBACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;wBACzC,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,eAAe,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;qBACpE;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,iDAAiD;wBACvD,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;wBACxB,iBAAiB,EAAE;4BACjB;gCACE,IAAI,EAAE,MAAM;gCACZ,OAAO,EAAE,eAAe,CAAC,EAAE,GAAG,OAAO;gCACrC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;6BACpC;yBACF;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
|
|
2
|
-
export declare function handleRemoveFilesFromContext({
|
|
2
|
+
export declare function handleRemoveFilesFromContext({ askQuestionCall, generateContentFn, prompt, options, }: ActionHandlerProps): Promise<ActionResult>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { getSourceCodeTree, parseSourceCodeTree } from '../../../../files/source-code-tree.js';
|
|
2
2
|
import { putSystemMessage } from '../../../../main/common/content-bus.js';
|
|
3
3
|
import { getFunctionDefs } from '../../../function-calling.js';
|
|
4
|
-
export async function handleRemoveFilesFromContext({
|
|
4
|
+
export async function handleRemoveFilesFromContext({ askQuestionCall, generateContentFn, prompt, options, }) {
|
|
5
5
|
const [removeFilesFromContextCall] = (await generateContentFn([
|
|
6
6
|
...prompt,
|
|
7
7
|
{
|
|
8
8
|
type: 'assistant',
|
|
9
|
-
text:
|
|
9
|
+
text: askQuestionCall.args?.message ?? '',
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
type: 'user',
|
|
@@ -35,7 +35,7 @@ export async function handleRemoveFilesFromContext({ askQuestionMessage, generat
|
|
|
35
35
|
{
|
|
36
36
|
assistant: {
|
|
37
37
|
type: 'assistant',
|
|
38
|
-
text:
|
|
38
|
+
text: askQuestionCall.args?.message ?? '',
|
|
39
39
|
functionCalls: [removeFilesFromContextCall],
|
|
40
40
|
},
|
|
41
41
|
user: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-files-from-context.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/remove-files-from-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,EACjD,
|
|
1
|
+
{"version":3,"file":"remove-files-from-context.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/remove-files-from-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,EACjD,eAAe,EACf,iBAAiB,EACjB,MAAM,EACN,OAAO,GACY;IACnB,MAAM,CAAC,0BAA0B,CAAC,GAAG,CAAC,MAAM,iBAAiB,CAC3D;QACE,GAAG,MAAM;QACT;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;SAC1C;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAA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rF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
|
|
2
|
-
export declare function handleRequestFilesContent({ askQuestionCall,
|
|
2
|
+
export declare function handleRequestFilesContent({ askQuestionCall, options, prompt, generateContentFn, }: ActionHandlerProps): Promise<ActionResult>;
|
|
@@ -34,8 +34,8 @@ function isFileContentAlreadyProvided(filePath, prompt) {
|
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
export async function handleRequestFilesContent({ askQuestionCall,
|
|
38
|
-
let requestFilesContentCall = await generateRequestFilesContentCall(generateContentFn, prompt,
|
|
37
|
+
export async function handleRequestFilesContent({ askQuestionCall, options, prompt, generateContentFn, }) {
|
|
38
|
+
let requestFilesContentCall = await generateRequestFilesContentCall(generateContentFn, prompt, askQuestionCall, options, true);
|
|
39
39
|
if (!requestFilesContentCall) {
|
|
40
40
|
return {
|
|
41
41
|
breakLoop: true,
|
|
@@ -50,7 +50,7 @@ export async function handleRequestFilesContent({ askQuestionCall, askQuestionMe
|
|
|
50
50
|
// All requested files are already provided
|
|
51
51
|
const assistant = {
|
|
52
52
|
type: 'assistant',
|
|
53
|
-
text:
|
|
53
|
+
text: askQuestionCall.args?.message ?? '',
|
|
54
54
|
functionCalls: [requestFilesContentCall],
|
|
55
55
|
};
|
|
56
56
|
const user = {
|
|
@@ -74,7 +74,7 @@ export async function handleRequestFilesContent({ askQuestionCall, askQuestionMe
|
|
|
74
74
|
refreshFiles();
|
|
75
75
|
let { legitimateFiles, illegitimateFiles } = categorizeLegitimateFiles(requestedFiles);
|
|
76
76
|
if (illegitimateFiles.length > 0) {
|
|
77
|
-
requestFilesContentCall = await generateRequestFilesContentCall(generateContentFn, prompt,
|
|
77
|
+
requestFilesContentCall = await generateRequestFilesContentCall(generateContentFn, prompt, askQuestionCall, options,
|
|
78
78
|
// use non cheap mode, as maybe the cheap mode didn't provide correct files
|
|
79
79
|
false);
|
|
80
80
|
if (!requestFilesContentCall) {
|
|
@@ -91,7 +91,7 @@ export async function handleRequestFilesContent({ askQuestionCall, askQuestionMe
|
|
|
91
91
|
const sourceCallId = (askQuestionCall.id ?? askQuestionCall.name) + '_source';
|
|
92
92
|
const assistant = {
|
|
93
93
|
type: 'assistant',
|
|
94
|
-
text:
|
|
94
|
+
text: askQuestionCall.args?.message ?? '',
|
|
95
95
|
functionCalls: [
|
|
96
96
|
requestFilesContentCall,
|
|
97
97
|
{ name: 'getSourceCode', id: sourceCallId, args: { filePaths: legitimateFiles } },
|
|
@@ -129,12 +129,12 @@ ${illegitimateFiles.map((path) => `- ${path}`).join('\n')}`
|
|
|
129
129
|
};
|
|
130
130
|
return { breakLoop: false, items: [{ assistant, user }] };
|
|
131
131
|
}
|
|
132
|
-
async function generateRequestFilesContentCall(generateContentFn, prompt,
|
|
132
|
+
async function generateRequestFilesContentCall(generateContentFn, prompt, askQuestionCall, options, cheap) {
|
|
133
133
|
const [requestFilesContentCall] = (await generateContentFn([
|
|
134
134
|
...prompt,
|
|
135
135
|
{
|
|
136
136
|
type: 'assistant',
|
|
137
|
-
text:
|
|
137
|
+
text: askQuestionCall.args?.message ?? '',
|
|
138
138
|
},
|
|
139
139
|
{
|
|
140
140
|
type: 'user',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-files-content.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/request-files-content.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"request-files-content.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/request-files-content.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAU/D;;;;;GAKG;AACH,SAAS,4BAA4B,CAAC,QAAgB,EAAE,MAAoB;IAC1E,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1B,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACpD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC9C,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBAC3D,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;gBACpD,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;gBACjE,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,C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AC,QAAQ,EAAE,EAAE;QAClC,IAAI,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,OAAO,cAAc,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
|
|
2
|
-
export declare function handleRequestPermissions({
|
|
2
|
+
export declare function handleRequestPermissions({ askQuestionCall, options, prompt, generateContentFn, }: ActionHandlerProps): Promise<ActionResult>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { askUserForConfirmation } from '../../../../main/common/user-actions.js';
|
|
2
2
|
import { getFunctionDefs } from '../../../function-calling.js';
|
|
3
|
-
export async function handleRequestPermissions({
|
|
3
|
+
export async function handleRequestPermissions({ askQuestionCall, options, prompt, generateContentFn, }) {
|
|
4
4
|
const [requestPermissionsCall] = (await generateContentFn([
|
|
5
5
|
...prompt,
|
|
6
6
|
{
|
|
7
7
|
type: 'assistant',
|
|
8
|
-
text:
|
|
8
|
+
text: askQuestionCall.args?.message ?? '',
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
type: 'user',
|
|
@@ -39,7 +39,7 @@ export async function handleRequestPermissions({ askQuestionMessage, options, pr
|
|
|
39
39
|
{
|
|
40
40
|
assistant: {
|
|
41
41
|
type: 'assistant',
|
|
42
|
-
text:
|
|
42
|
+
text: askQuestionCall.args?.message ?? '',
|
|
43
43
|
functionCalls: [requestPermissionsCall],
|
|
44
44
|
},
|
|
45
45
|
user,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-permissions.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/request-permissions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,EAC7C,
|
|
1
|
+
{"version":3,"file":"request-permissions.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/request-permissions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,EAC7C,eAAe,EACf,OAAO,EACP,MAAM,EACN,iBAAiB,GACE;IACnB,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,MAAM,iBAAiB,CACvD;QACE,GAAG,MAAM;QACT;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;SAC1C;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,uCAAuC;SAC9C;KACF,EACD,eAAe,EAAE,EACjB,oBAAoB,EACpB,GAAG,EACH,IAAI,EACJ,OAAO,CACR,CAAuD,CAAC;IAEzD,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC5B,OAAO;YACL,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,sBAAsB,CACnD,gFAAgF,EAChF,KAAK,CACN,CAAC;IAEF,MAAM,IAAI,GAAa;QACrB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,C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AI,WAAW,IAAI,WAAW,CAAC,eAAe;YAAE,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;QACpG,IAAI,eAAe,IAAI,WAAW,IAAI,WAAW,CAAC,aAAa;YAAE,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAChG,CAAC;AACH,CAAC"}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
import { FunctionCall, GenerateContentFunction, GenerateImageFunction, PromptItem, PromptItemImage } from '../../../ai-service/common.js';
|
|
2
2
|
import { CodegenOptions } from '../../../main/codegen-types.js';
|
|
3
3
|
import { PluginActionType } from '../../../main/codegen-types.js';
|
|
4
|
-
export type ActionType = 'codeGeneration' | 'sendMessage' | 'sendMessageWithImage' | 'requestPermissions' | 'requestFilesContent' | 'removeFilesFromContext' | 'confirmCodeGeneration' | 'cancelCodeGeneration' | 'contextOptimization' | 'searchCode' | 'lint' | PluginActionType;
|
|
4
|
+
export type ActionType = 'codeGeneration' | 'sendMessage' | 'sendMessageWithImage' | 'requestPermissions' | 'requestFilesContent' | 'removeFilesFromContext' | 'confirmCodeGeneration' | 'cancelCodeGeneration' | 'contextOptimization' | 'searchCode' | 'lint' | 'updateFile' | PluginActionType;
|
|
5
5
|
type AskQuestionArgs = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
value: string;
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
type: 'actionType';
|
|
13
|
-
value: ActionType;
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
type: 'message';
|
|
17
|
-
value: string;
|
|
18
|
-
}
|
|
19
|
-
];
|
|
6
|
+
actionType: ActionType;
|
|
7
|
+
message: string;
|
|
8
|
+
decisionMakingProcess?: string;
|
|
20
9
|
};
|
|
21
10
|
export type SendMessageWithImageArgs = {
|
|
22
11
|
prompt: string;
|
|
@@ -90,7 +79,6 @@ export interface ActionResult {
|
|
|
90
79
|
}
|
|
91
80
|
export type ActionHandlerProps = {
|
|
92
81
|
askQuestionCall: AskQuestionCall;
|
|
93
|
-
askQuestionMessage: string | undefined;
|
|
94
82
|
prompt: PromptItem[];
|
|
95
83
|
options: CodegenOptions;
|
|
96
84
|
generateContentFn: GenerateContentFunction;
|
|
@@ -5,7 +5,6 @@ import { handleRequestFilesContent } from './handlers/request-files-content.js';
|
|
|
5
5
|
import { handleContextOptimization } from './handlers/context-optimization.js';
|
|
6
6
|
import { handleRemoveFilesFromContext } from './handlers/remove-files-from-context.js';
|
|
7
7
|
import { handleRequestPermissions } from './handlers/request-permissions.js';
|
|
8
|
-
import { handleDefaultAction } from './handlers/default-action.js';
|
|
9
8
|
import { handleSendMessage } from './handlers/handle-send-message.js';
|
|
10
9
|
import { handleSendMessageWithImage } from './handlers/handle-send-message-with-image.js';
|
|
11
10
|
import { handleConfirmCodeGeneration } from './handlers/confirm-code-generation.js';
|
|
@@ -14,24 +13,24 @@ import { handleLint } from './handlers/lint.js';
|
|
|
14
13
|
import { getRegisteredActionHandlers } from '../../../main/plugin-loader.js';
|
|
15
14
|
import { handleCodeGeneration } from './handlers/code-generation.js';
|
|
16
15
|
import { handleSearchCode } from './handlers/handle-search-code.js';
|
|
16
|
+
import { handleUpdateFile } from './handlers/handle-update-file.js';
|
|
17
17
|
export async function executeStepAskQuestion(generateContentFn, generateImageFn, prompt, functionDefs, waitIfPaused, temperature, options) {
|
|
18
18
|
console.log('Allowing the assistant to ask a question...');
|
|
19
19
|
while (!abortController?.signal.aborted) {
|
|
20
20
|
try {
|
|
21
21
|
const askQuestionCall = await getAskQuestionCall(generateContentFn, prompt, functionDefs, temperature, options);
|
|
22
|
-
if (!askQuestionCall
|
|
22
|
+
if (!askQuestionCall) {
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
if (message) {
|
|
25
|
+
if (askQuestionCall.args?.message) {
|
|
27
26
|
// TODO: PromptItem should be included here, but a small refactor is needed to achieve this
|
|
28
|
-
putAssistantMessage(message, askQuestionCall.args);
|
|
27
|
+
putAssistantMessage(askQuestionCall.args.message, askQuestionCall.args);
|
|
29
28
|
}
|
|
29
|
+
const actionType = askQuestionCall.args?.actionType;
|
|
30
30
|
if (actionType) {
|
|
31
31
|
const actionHandler = getActionHandler(actionType);
|
|
32
32
|
let result = await actionHandler({
|
|
33
33
|
askQuestionCall,
|
|
34
|
-
askQuestionMessage: message,
|
|
35
34
|
prompt,
|
|
36
35
|
options,
|
|
37
36
|
generateContentFn,
|
|
@@ -47,7 +46,6 @@ export async function executeStepAskQuestion(generateContentFn, generateImageFn,
|
|
|
47
46
|
if (result.executeCodegen) {
|
|
48
47
|
result = await getActionHandler('codeGeneration')({
|
|
49
48
|
askQuestionCall,
|
|
50
|
-
askQuestionMessage: message,
|
|
51
49
|
prompt,
|
|
52
50
|
options,
|
|
53
51
|
generateContentFn,
|
|
@@ -104,7 +102,8 @@ function getActionHandler(actionType) {
|
|
|
104
102
|
searchCode: handleSearchCode,
|
|
105
103
|
lint: handleLint,
|
|
106
104
|
contextOptimization: handleContextOptimization,
|
|
105
|
+
updateFile: handleUpdateFile,
|
|
107
106
|
};
|
|
108
|
-
return handlers[actionType] ||
|
|
107
|
+
return handlers[actionType] || handleSendMessage;
|
|
109
108
|
}
|
|
110
109
|
//# sourceMappingURL=step-ask-question.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-ask-question.js","sourceRoot":"","sources":["../../../../src/prompt/steps/step-ask-question/step-ask-question.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"step-ask-question.js","sourceRoot":"","sources":["../../../../src/prompt/steps/step-ask-question/step-ask-question.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,iBAA0C,EAC1C,eAAsC,EACtC,MAAoB,EACpB,YAA2B,EAC3B,YAAiC,EACjC,WAAmB,EACnB,OAAuB;IAEvB,OAAO,CAAC,G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C"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { GenerateContentFunction, PromptItem } from '../../ai-service/common.js';
|
|
2
2
|
import { CodegenOptions } from '../../main/codegen-types.js';
|
|
3
3
|
import { StepResult } from './steps-types.js';
|
|
4
|
+
export declare const OPTIMIZATION_PROMPT = "You need to analyze the provided source code files and determine their relevance to the user's prompt. You will then call the `optimizeContext` function with the results.\n\n**Crucially, only include files in the `optimizedContext` array of the `optimizeContext` function call if their calculated relevance score is 0.5 or greater.**\n\nHere are the detailed steps:\n\n1. **Relevance Assessment (Scores from 0.0 to 1.0):**\n - Evaluate the relevance of each file to the user's prompt based on the following scale:\n - 0.0 \u2013 0.3: Not Relevant\n - 0.3 \u2013 0.7: Somewhat Relevant\n - 0.7 \u2013 0.9: Moderately Relevant\n - 0.9 \u2013 1.0: Highly Relevant\n - Consider:\n - Directly implements the core logic required to address the prompt's features.\n - Role in dependency chains of relevant files.\n - Keyword matches with the prompt.\n - Importance as a dependency.\n\n2. **Dependency Consideration:**\n - Understand how files depend on each other.\n - Prioritize files that are directly relevant or are dependencies of highly relevant files.\n - When evaluating a file, consider its position within dependency chains, but **do not include a file in the `optimizedContext` if its individual relevance score is below 0.5, even if it's part of a dependency chain of a relevant file.**\n\n3. **Token Awareness:**\n - Be mindful of token usage, but **relevance (specifically a score of 0.5 or higher) is the primary criterion for inclusion in `optimizedContext`.**\n\n4. **Function Call - `optimizeContext`:**\n - Call the `optimizeContext` function with the following arguments:\n - `\"userPrompt\"`: The original user prompt.\n - `\"reasoning\"`: A detailed, step-by-step explanation of the thought process used to determine the optimized context.\n - `\"optimizedContext\"`: **An array containing ONLY files with a relevance score of 0.5 or higher.** Each object in the array should have:\n - `\"reasoning\"`: Specific reasoning for why *this particular file* is relevant and has a score of 0.5 or higher.\n - `\"filePath\"`: Absolute file path.\n - `\"relevance\"`: The calculated relevance score (0.5 to 1.0).\n\n**Important Guidelines:**\n\n- **Strict Filtering:** **Only files with a relevance score of 0.5 or more should be included in the `optimizedContext` array.**\n- **No Guessing:** Only use files provided in the `getSourceCode` response.\n- **Evaluate Individually and in Chains:** Consider both individual relevance and dependencies, but the 0.5 threshold is paramount for inclusion.\n- **Proper JSON:** Ensure the `optimizeContext` call is valid JSON.\n- **Full Paths:** Use absolute file paths.\n- **Focus on 0.5+:** The `optimizedContext` array should be exclusively populated with files meeting the relevance criteria.\n- **Handling Codebase-Wide Operations:**\n - If the user prompt indicates a codebase-wide operation, choose one of the following `optimizeContext` strategies:\n - **Empty Context:** For operations applying to all files simultaneously, call `optimizeContext` with an empty `optimizedContext` and explain in the `reasoning`.\n - **Main Entry Points:** For operations starting with key files, identify main entry points and call `optimizeContext` with these files (relevance=1.0), explaining in the `reasoning`.\n- **Data Flow Consideration**: Consider the entire lifecycle of the data involved in the user's request, from the user interface to the database and back. Include files involved in handling, storing, and transmitting this data.\n- **Intent and Contribution Analysis:** For each file, evaluate its purpose and how it contributes to fulfilling the user's prompt. Consider the flow of logic and data. Which files are essential for the requested outcome, not just tangentially related?\n- **Functional Web Analysis:** Think of the codebase as a web of interconnected functionalities. Identify the key functional areas involved in the user's prompt and trace the connections between files within these areas.\n- **Core Responsibility Assessment:** Identify the files that are primarily responsible for managing the lifecycle, data, or logic of the entities involved in the `userPrompt`. These files are likely to be highly relevant.\n- **Data Flow Mapping:** Trace the flow of data related to the user's request. Identify the files involved in creating, storing, transforming, and retrieving this data.\n\nNow, analyze the source code and call the `optimizeContext` function accordingly.";
|
|
5
|
+
export declare const OPTIMIZATION_TRIGGER_PROMPT = "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?";
|
|
6
|
+
export declare const CONTEXT_OPTIMIZATION_TEMPERATURE = 0.2;
|
|
4
7
|
export declare function executeStepContextOptimization(generateContentFn: GenerateContentFunction, prompt: PromptItem[], options: CodegenOptions): Promise<StepResult>;
|