genaicode 0.9.0 → 0.9.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.
- package/dist/ai-service/common-types.d.ts +1 -0
- package/dist/ai-service/openai.js +1 -1
- package/dist/ai-service/service-configurations.js +1 -1
- package/dist/cli/cli-params.js +21 -0
- package/dist/cli/cli-params.js.map +1 -1
- package/dist/cli/validate-cli-params.js +19 -11
- package/dist/cli/validate-cli-params.js.map +1 -1
- package/dist/files/read-files.js +8 -2
- package/dist/files/read-files.js.map +1 -1
- package/dist/files/source-code-tree.d.ts +2 -5
- package/dist/files/source-code-tree.js +3 -32
- package/dist/files/source-code-tree.js.map +1 -1
- package/dist/files/source-code-types.d.ts +7 -2
- package/dist/files/source-code-utils.d.ts +22 -0
- package/dist/files/source-code-utils.js +70 -0
- package/dist/files/source-code-utils.js.map +1 -0
- package/dist/files/summary-cache.d.ts +1 -1
- package/dist/files/summary-cache.js +1 -1
- package/dist/main/common/user-actions.d.ts +1 -1
- package/dist/main/common/user-actions.js +3 -3
- package/dist/main/common/user-actions.js.map +1 -1
- package/dist/main/ui/backend/endpoints/generate-content-endpoint.js +6 -5
- package/dist/main/ui/backend/endpoints/generate-content-endpoint.js.map +1 -1
- package/dist/main/ui/backend/service.js +10 -8
- package/dist/main/ui/backend/service.js.map +1 -1
- package/dist/main/ui/frontend/assets/{index-DfiFNFf2.js → index-B0R1bgBi.js} +69 -65
- package/dist/main/ui/frontend/index.html +1 -1
- package/dist/prompt/ai-service-fallback.js +1 -1
- package/dist/prompt/ai-service-fallback.js.map +1 -1
- package/dist/prompt/function-calling-validate.js +1 -0
- package/dist/prompt/function-calling-validate.js.map +1 -1
- package/dist/prompt/function-calling.js +2 -0
- package/dist/prompt/function-calling.js.map +1 -1
- package/dist/prompt/function-defs/ask-question.js +4 -0
- package/dist/prompt/function-defs/ask-question.js.map +1 -1
- package/dist/prompt/function-defs/context-compression.d.ts +27 -0
- package/dist/prompt/function-defs/context-compression.js +34 -0
- package/dist/prompt/function-defs/context-compression.js.map +1 -0
- package/dist/prompt/function-defs/get-source-code.js +8 -11
- package/dist/prompt/function-defs/get-source-code.js.map +1 -1
- package/dist/prompt/function-defs/set-summaries.d.ts +1 -1
- package/dist/prompt/function-defs/set-summaries.js +10 -6
- package/dist/prompt/function-defs/set-summaries.js.map +1 -1
- package/dist/prompt/prompt-service.js +3 -3
- package/dist/prompt/prompt-service.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/code-generation.js +26 -6
- package/dist/prompt/steps/step-ask-question/handlers/code-generation.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-context-compression.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-context-compression.js +33 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-context-compression.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-end-conversation.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-end-conversation.js +17 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-end-conversation.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-pull-app-context.js +35 -45
- package/dist/prompt/steps/step-ask-question/handlers/handle-pull-app-context.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-push-app-context.js +35 -36
- package/dist/prompt/steps/step-ask-question/handlers/handle-push-app-context.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-reasoning-inference.js +24 -14
- package/dist/prompt/steps/step-ask-question/handlers/handle-reasoning-inference.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.js +15 -19
- 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.js +36 -23
- package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/step-ask-question-types.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question/step-ask-question.js +2 -0
- package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -1
- package/dist/prompt/steps/step-context-compression.d.ts +8 -0
- package/dist/prompt/steps/step-context-compression.js +121 -0
- package/dist/prompt/steps/step-context-compression.js.map +1 -0
- package/dist/prompt/steps/step-context-optimization.js +8 -6
- package/dist/prompt/steps/step-context-optimization.js.map +1 -1
- package/dist/prompt/steps/step-ensure-context.js +4 -9
- package/dist/prompt/steps/step-ensure-context.js.map +1 -1
- package/dist/prompt/steps/step-generate-summary.js +1 -0
- package/dist/prompt/steps/step-generate-summary.js.map +1 -1
- package/dist/prompt/steps/step-process-file-updates.js +1 -0
- package/dist/prompt/steps/step-process-file-updates.js.map +1 -1
- package/dist/prompt/steps/step-summarization.d.ts +5 -0
- package/dist/prompt/steps/step-summarization.js +77 -42
- package/dist/prompt/steps/step-summarization.js.map +1 -1
- package/dist/prompt/systemprompt.js +1 -0
- package/dist/prompt/systemprompt.js.map +1 -1
- package/package.json +2 -2
|
@@ -29,61 +29,51 @@ export async function handlePullAppContext({ generateContentFn, prompt, options,
|
|
|
29
29
|
? `Retrieved context value for key "${key}": ${JSON.stringify(contextValue, null, 2)}`
|
|
30
30
|
: `No context value found for key "${key}"`;
|
|
31
31
|
const reasonInfo = reason ? `\nReason for retrieval: ${reason}` : '';
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
putSystemMessage('Context retrieved successfully', {
|
|
33
|
+
contextKey: key,
|
|
34
|
+
contextValue: contextValue,
|
|
35
|
+
reason,
|
|
36
|
+
operation: 'get',
|
|
37
|
+
});
|
|
38
|
+
prompt.push({
|
|
39
|
+
type: 'assistant',
|
|
40
|
+
text: `${contextInfo}${reasonInfo}`,
|
|
41
|
+
functionCalls: [pullAppContextCall],
|
|
42
|
+
}, {
|
|
43
|
+
type: 'user',
|
|
44
|
+
functionResponses: [
|
|
36
45
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
functionCalls: [pullAppContextCall],
|
|
41
|
-
},
|
|
42
|
-
user: {
|
|
43
|
-
type: 'user',
|
|
44
|
-
text: 'Context retrieved successfully.',
|
|
45
|
-
functionResponses: [
|
|
46
|
-
{
|
|
47
|
-
name: 'pullAppContext',
|
|
48
|
-
call_id: pullAppContextCall.id,
|
|
49
|
-
content: JSON.stringify({ contextKey: key, contextValue, reason, operation: 'get' }),
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
data: {
|
|
53
|
-
contextKey: key,
|
|
54
|
-
contextValue: contextValue,
|
|
55
|
-
reason,
|
|
56
|
-
operation: 'get',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
46
|
+
name: 'pullAppContext',
|
|
47
|
+
call_id: pullAppContextCall.id,
|
|
48
|
+
content: JSON.stringify({ contextKey: key, contextValue, reason, operation: 'get' }),
|
|
59
49
|
},
|
|
60
50
|
],
|
|
51
|
+
});
|
|
52
|
+
// Return the action result with context information
|
|
53
|
+
return {
|
|
54
|
+
breakLoop: false,
|
|
55
|
+
items: [],
|
|
61
56
|
};
|
|
62
57
|
}
|
|
63
58
|
catch (error) {
|
|
64
59
|
// Handle any errors that occur during context retrieval
|
|
65
60
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
66
|
-
putSystemMessage(`Error retrieving context
|
|
61
|
+
putSystemMessage(`Error retrieving context`, {
|
|
62
|
+
contextKey: key,
|
|
63
|
+
error: errorMessage,
|
|
64
|
+
reason,
|
|
65
|
+
operation: 'get',
|
|
66
|
+
});
|
|
67
|
+
prompt.push({
|
|
68
|
+
type: 'assistant',
|
|
69
|
+
text: `Failed to retrieve context for key "${key}": ${errorMessage}`,
|
|
70
|
+
}, {
|
|
71
|
+
type: 'user',
|
|
72
|
+
text: 'Context retrieval failed.',
|
|
73
|
+
});
|
|
67
74
|
return {
|
|
68
75
|
breakLoop: false,
|
|
69
|
-
items: [
|
|
70
|
-
{
|
|
71
|
-
assistant: {
|
|
72
|
-
type: 'assistant',
|
|
73
|
-
text: `Failed to retrieve context for key "${key}": ${errorMessage}`,
|
|
74
|
-
},
|
|
75
|
-
user: {
|
|
76
|
-
type: 'user',
|
|
77
|
-
text: 'Context retrieval failed.',
|
|
78
|
-
data: {
|
|
79
|
-
contextKey: key,
|
|
80
|
-
error: errorMessage,
|
|
81
|
-
reason,
|
|
82
|
-
operation: 'get',
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
],
|
|
76
|
+
items: [],
|
|
87
77
|
};
|
|
88
78
|
}
|
|
89
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-pull-app-context.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-pull-app-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACzC,iBAAiB,EACjB,MAAM,EACN,OAAO,GACY;IACnB,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;IAC1C,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,iBAAiB,CACnD,MAAM,EACN,eAAe,EAAE,EACjB,gBAAgB,EAChB,GAAG,EACH,SAAS,CAAC,KAAK,EACf,OAAO,CACR,CAAmD,CAAC;IAErD,IAAI,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC;QAC9B,gBAAgB,CAAC,4CAA4C,CAAC,CAAC;QAC/D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACzC,CAAC;IAED,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC;IAEhD,IAAI,CAAC;QACH,iBAAiB;QACjB,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QAED,qCAAqC;QACrC,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC;QAEhD,uCAAuC;QACvC,MAAM,WAAW,GAAG,YAAY;YAC9B,CAAC,CAAC,oCAAoC,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;YACtF,CAAC,CAAC,mCAAmC,GAAG,GAAG,CAAC;QAE9C,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,2BAA2B,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAErE,
|
|
1
|
+
{"version":3,"file":"handle-pull-app-context.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-pull-app-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACzC,iBAAiB,EACjB,MAAM,EACN,OAAO,GACY;IACnB,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;IAC1C,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,iBAAiB,CACnD,MAAM,EACN,eAAe,EAAE,EACjB,gBAAgB,EAChB,GAAG,EACH,SAAS,CAAC,KAAK,EACf,OAAO,CACR,CAAmD,CAAC;IAErD,IAAI,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC;QAC9B,gBAA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SACF,CACF,CAAC;QAEF,oDAAoD;QACpD,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,wDAAwD;QACxD,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;QACvF,gBAAgB,CAAC,0BAA0B,EAAE;YAC3C,UAAU,EAAE,GAAG;YACf,KAAK,EAAE,YAAY;YACnB,MAAM;YACN,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CACT;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,uCAAuC,GAAG,MAAM,YAAY,EAAE;SACrE,EACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,2BAA2B;SAClC,CACF,CAAC;QAEF,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -36,55 +36,54 @@ export async function handlePushAppContext({ generateContentFn, prompt, options,
|
|
|
36
36
|
// Note: setContextValue includes value validation internally
|
|
37
37
|
await setContextValue(key, value);
|
|
38
38
|
// Format success message
|
|
39
|
-
const updateInfo = `Successfully updated context key "${key}"
|
|
39
|
+
const updateInfo = `Successfully updated context key "${key}"`;
|
|
40
40
|
const reasonInfo = reason ? `\nReason for update: ${reason}` : '';
|
|
41
|
+
putSystemMessage('Context updated successfully.', {
|
|
42
|
+
contextKey: key,
|
|
43
|
+
contextValue: value,
|
|
44
|
+
reason,
|
|
45
|
+
operation: 'set',
|
|
46
|
+
});
|
|
47
|
+
prompt.push({
|
|
48
|
+
type: 'assistant',
|
|
49
|
+
text: `${updateInfo}${reasonInfo}`,
|
|
50
|
+
functionCalls: [pushAppContextCall],
|
|
51
|
+
}, {
|
|
52
|
+
type: 'user',
|
|
53
|
+
functionResponses: [{ name: 'pushAppContext', call_id: pushAppContextCall.id, content: '' }],
|
|
54
|
+
});
|
|
41
55
|
// Return the action result with update confirmation
|
|
42
56
|
return {
|
|
43
57
|
breakLoop: false,
|
|
44
|
-
items: [
|
|
45
|
-
{
|
|
46
|
-
assistant: {
|
|
47
|
-
type: 'assistant',
|
|
48
|
-
text: `${updateInfo}${reasonInfo}`,
|
|
49
|
-
},
|
|
50
|
-
user: {
|
|
51
|
-
type: 'user',
|
|
52
|
-
text: 'Context updated successfully.',
|
|
53
|
-
data: {
|
|
54
|
-
contextKey: key,
|
|
55
|
-
contextValue: value,
|
|
56
|
-
reason,
|
|
57
|
-
operation: 'set',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
],
|
|
58
|
+
items: [],
|
|
62
59
|
};
|
|
63
60
|
}
|
|
64
61
|
catch (error) {
|
|
65
62
|
// Handle any errors that occur during context update
|
|
66
63
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
67
64
|
putSystemMessage(`Error updating context: ${errorMessage}`);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
prompt.push({
|
|
66
|
+
type: 'assistant',
|
|
67
|
+
functionCalls: [pushAppContextCall],
|
|
68
|
+
}, {
|
|
69
|
+
type: 'user',
|
|
70
|
+
text: 'Context update failed.',
|
|
71
|
+
functionResponses: [
|
|
71
72
|
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
contextKey: key,
|
|
81
|
-
error: errorMessage,
|
|
82
|
-
reason,
|
|
83
|
-
operation: 'set',
|
|
84
|
-
},
|
|
85
|
-
},
|
|
73
|
+
name: 'pushAppContext',
|
|
74
|
+
call_id: pushAppContextCall.id,
|
|
75
|
+
content: JSON.stringify({
|
|
76
|
+
contextKey: key,
|
|
77
|
+
error: errorMessage,
|
|
78
|
+
reason,
|
|
79
|
+
operation: 'set',
|
|
80
|
+
}),
|
|
86
81
|
},
|
|
87
82
|
],
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
breakLoop: false,
|
|
86
|
+
items: [],
|
|
88
87
|
};
|
|
89
88
|
}
|
|
90
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-push-app-context.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-push-app-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACzC,iBAAiB,EACjB,MAAM,EACN,OAAO,GACY;IACnB,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IAExC,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,iBAAiB,CACnD,MAAM,EACN,eAAe,EAAE,EACjB,gBAAgB,EAChB,GAAG,EACH,SAAS,CAAC,KAAK,EACf,OAAO,CACR,CAAuC,CAAC;IAEzC,IAAI,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC;QAC9B,gBAAgB,CAAC,4CAA4C,CAAC,CAAC;QAC/D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACzC,CAAC;IAED,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC;IAChD,IAAI,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC;IAExC,IAAI,CAAC;QACH,iBAAiB;QACjB,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,CAAC;YACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,eAAe;QACjB,CAAC;QAED,sCAAsC;QACtC,6DAA6D;QAC7D,MAAM,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAElC,yBAAyB;QACzB,MAAM,UAAU,GAAG,qCAAqC,GAAG,
|
|
1
|
+
{"version":3,"file":"handle-push-app-context.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-push-app-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACzC,iBAAiB,EACjB,MAAM,EACN,OAAO,GACY;IACnB,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IAExC,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,iBAAiB,CACnD,MAAM,EACN,eAAe,EAAE,EACjB,gBAAgB,EAChB,GAAG,EACH,SAAS,CAAC,KAAK,EACf,OAAO,CACR,CAAuC,CAAC;IAEzC,IAAI,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC;QAC9B,gBAAgB,CAAC,4CAA4C,CAAC,CAAC;QAC/D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACzC,CAAC;IAED,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EAAE,KAAK;YAChB,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,qDAAqD;QACrD,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;QACvF,gBAAgB,CAAC,2BAA2B,YAAY,EAAE,CAAC,CAAC;QAE5D,MAAM,CAAC,IAAI,CACT;YACE,IAAI,EAAE,WAAW;YACjB,aAAa,EAAE,CAAC,kBAAkB,CAAC;SACpC,EACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,wBAAwB;YAC9B,iBAAiB,EAAE;gBACjB;oBACE,IAAI,EAAE,gBAAgB;oBACtB,OAAO,EAAE,kBAAkB,CAAC,EAAE;oBAC9B,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;wBACtB,UAAU,EAAE,GAAG;wBACf,KAAK,EAAE,YAAY;wBACnB,MAAM;wBACN,SAAS,EAAE,KAAK;qBACjB,CAAC;iBACH;aACF;SACF,CACF,CAAC;QAEF,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ModelType } from '../../../../ai-service/common-types.js';
|
|
2
|
-
import { getSourceCode } from '../../../../files/read-files.js';
|
|
3
2
|
import { putSystemMessage } from '../../../../main/common/content-bus.js';
|
|
4
3
|
import { getFunctionDefs } from '../../../function-calling.js';
|
|
4
|
+
import { validateAndRecoverSingleResult } from '../../step-validate-recover.js';
|
|
5
|
+
import { getContextSourceCode } from '../../../../files/source-code-utils.js';
|
|
5
6
|
/**
|
|
6
7
|
* Handler for the reasoningInference action.
|
|
7
8
|
* This handler is designed to work with models that don't support function calling
|
|
@@ -10,13 +11,22 @@ import { getFunctionDefs } from '../../../function-calling.js';
|
|
|
10
11
|
export async function handleReasoningInference({ askQuestionCall, prompt, generateContentFn, options, }) {
|
|
11
12
|
try {
|
|
12
13
|
putSystemMessage('Reasoning inference: generating prompt');
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const request = [
|
|
15
|
+
[
|
|
16
|
+
...prompt,
|
|
17
|
+
{
|
|
18
|
+
type: 'assistant',
|
|
19
|
+
text: askQuestionCall.args.message,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
getFunctionDefs(),
|
|
23
|
+
'reasoningInference',
|
|
24
|
+
0.7,
|
|
25
|
+
ModelType.CHEAP,
|
|
26
|
+
options,
|
|
27
|
+
];
|
|
28
|
+
const result = await generateContentFn(...request);
|
|
29
|
+
const [reasoningInferenceCall] = (await validateAndRecoverSingleResult(request, result, generateContentFn));
|
|
20
30
|
if (!reasoningInferenceCall?.args?.prompt) {
|
|
21
31
|
putSystemMessage('Failed to get valid reasoningInference request');
|
|
22
32
|
prompt.push({
|
|
@@ -29,18 +39,17 @@ export async function handleReasoningInference({ askQuestionCall, prompt, genera
|
|
|
29
39
|
return { breakLoop: false, items: [] };
|
|
30
40
|
}
|
|
31
41
|
putSystemMessage('Reasoning inference: calling reasoning model', reasoningInferenceCall.args);
|
|
42
|
+
// Get expanded context using getContextSourceCode
|
|
43
|
+
const contextPaths = reasoningInferenceCall.args.contextPaths || [];
|
|
44
|
+
const expandedContextSourceCodeMap = getContextSourceCode(contextPaths, options);
|
|
32
45
|
// Call the reasoning model with appropriate settings
|
|
33
46
|
const [reasoningInferenceResponseCall] = (await generateContentFn([
|
|
34
47
|
{
|
|
35
48
|
type: 'user',
|
|
36
49
|
text: reasoningInferenceCall.args.prompt +
|
|
37
|
-
(
|
|
50
|
+
(Object.keys(expandedContextSourceCodeMap).length > 0
|
|
38
51
|
? '\n\nContents of relevant files:\n' +
|
|
39
|
-
Object.entries(
|
|
40
|
-
filterPaths: reasoningInferenceCall.args.contextPaths,
|
|
41
|
-
forceAll: true,
|
|
42
|
-
ignoreImportantFiles: true,
|
|
43
|
-
}, options))
|
|
52
|
+
Object.entries(expandedContextSourceCodeMap)
|
|
44
53
|
.map(([path, file]) => 'content' in file && file.content ? `File: ${path}\n\`\`\`${file.content}\`\`\`` : '')
|
|
45
54
|
.filter(Boolean)
|
|
46
55
|
.join('\n\n')
|
|
@@ -79,6 +88,7 @@ export async function handleReasoningInference({ askQuestionCall, prompt, genera
|
|
|
79
88
|
text: `Error during reasoning inference.`,
|
|
80
89
|
});
|
|
81
90
|
return {
|
|
91
|
+
// TODO: rather do a retry here?
|
|
82
92
|
breakLoop: true,
|
|
83
93
|
items: [],
|
|
84
94
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-reasoning-inference.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-reasoning-inference.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"handle-reasoning-inference.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-reasoning-inference.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAOhF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAE9E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,EAC7C,eAAe,EACf,MAAM,EACN,iBAAiB,EACjB,OAAO,GACY;IACnB,IAAI,CAAC;QACH,gBAAgB,CAAC,wCAAwC,CAAC,CAAC;QAE3D,MAAM,OAAO,GAAwB;YACnC;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YACjB,IAAI,EAAE,eAAe,CAAC,IAAK,CAAC,OAAO;SACpC,EACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,mCAAmC;SAC1C,CACF,CAAC;QAEF,OAAO;YACL,gCAAgC;YAChC,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ModelType } from '../../../../ai-service/common-types.js';
|
|
2
|
-
import { getSourceCodeTree, parseSourceCodeTree } from '../../../../files/source-code-tree.js';
|
|
3
2
|
import { putSystemMessage } from '../../../../main/common/content-bus.js';
|
|
4
3
|
import { getFunctionDefs } from '../../../function-calling.js';
|
|
5
4
|
export async function handleRemoveFilesFromContext({ askQuestionCall, generateContentFn, prompt, options, }) {
|
|
@@ -28,26 +27,23 @@ export async function handleRemoveFilesFromContext({ askQuestionCall, generateCo
|
|
|
28
27
|
userText = 'Context reduction applied';
|
|
29
28
|
}
|
|
30
29
|
else {
|
|
30
|
+
putSystemMessage('No specific files were provided for context reduction. The context remains unchanged.');
|
|
31
31
|
userText = 'No specific files were provided for context reduction. The context remains unchanged.';
|
|
32
32
|
}
|
|
33
|
+
prompt.push({
|
|
34
|
+
type: 'assistant',
|
|
35
|
+
text: askQuestionCall.args?.message ?? '',
|
|
36
|
+
functionCalls: [removeFilesFromContextCall],
|
|
37
|
+
}, {
|
|
38
|
+
type: 'user',
|
|
39
|
+
text: userText,
|
|
40
|
+
functionResponses: [
|
|
41
|
+
{ name: 'removeFilesFromContext', call_id: removeFilesFromContextCall.id, content: undefined },
|
|
42
|
+
],
|
|
43
|
+
});
|
|
33
44
|
return {
|
|
34
45
|
breakLoop: false,
|
|
35
|
-
items: [
|
|
36
|
-
{
|
|
37
|
-
assistant: {
|
|
38
|
-
type: 'assistant',
|
|
39
|
-
text: askQuestionCall.args?.message ?? '',
|
|
40
|
-
functionCalls: [removeFilesFromContextCall],
|
|
41
|
-
},
|
|
42
|
-
user: {
|
|
43
|
-
type: 'user',
|
|
44
|
-
text: userText,
|
|
45
|
-
functionResponses: [
|
|
46
|
-
{ name: 'removeFilesFromContext', call_id: removeFilesFromContextCall.id, content: undefined },
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
],
|
|
46
|
+
items: [],
|
|
51
47
|
};
|
|
52
48
|
}
|
|
53
49
|
function removeFileContentsFromPrompt(prompt, filesToRemove) {
|
|
@@ -64,7 +60,7 @@ function removeFileContentsFromPrompt(prompt, filesToRemove) {
|
|
|
64
60
|
return;
|
|
65
61
|
}
|
|
66
62
|
try {
|
|
67
|
-
const contentObj =
|
|
63
|
+
const contentObj = JSON.parse(sourceCodeResponse.content);
|
|
68
64
|
let modifiedFiles = 0;
|
|
69
65
|
filesToRemove.forEach((file) => {
|
|
70
66
|
if (contentObj[file] && 'content' in contentObj[file]) {
|
|
@@ -74,7 +70,7 @@ function removeFileContentsFromPrompt(prompt, filesToRemove) {
|
|
|
74
70
|
});
|
|
75
71
|
// Only update if files were actually modified
|
|
76
72
|
if (modifiedFiles > 0) {
|
|
77
|
-
sourceCodeResponse.content = JSON.stringify(
|
|
73
|
+
sourceCodeResponse.content = JSON.stringify(contentObj);
|
|
78
74
|
console.log(`Removed content from ${modifiedFiles} files in source code response`);
|
|
79
75
|
}
|
|
80
76
|
}
|
|
@@ -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":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,
|
|
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":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,g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CAAC,IAAI,CAAC,IAAI,SAAS,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtD,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC;oBAChC,aAAa,EAAE,CAAC;gBAClB,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,8CAA8C;YAC9C,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;gBACtB,kBAAkB,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBACxD,OAAO,CAAC,GAAG,CAAC,wBAAwB,aAAa,gCAAgC,CAAC,CAAC;YACrF,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,9 +1,10 @@
|
|
|
1
1
|
import { ModelType } from '../../../../ai-service/common-types.js';
|
|
2
2
|
import { getSourceFiles, refreshFiles } from '../../../../files/find-files.js';
|
|
3
3
|
import { getSourceCode } from '../../../../files/read-files.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getExpandedContextPaths } from '../../../../files/source-code-utils.js';
|
|
5
5
|
import { putSystemMessage } from '../../../../main/common/content-bus.js';
|
|
6
6
|
import { getFunctionDefs } from '../../../function-calling.js';
|
|
7
|
+
import { validateAndRecoverSingleResult } from '../../step-validate-recover.js';
|
|
7
8
|
export async function handleRequestFilesContent({ askQuestionCall, options, prompt, generateContentFn, }) {
|
|
8
9
|
let requestFilesContentCall = await generateRequestFilesContentCall(generateContentFn, prompt, askQuestionCall, options, ModelType.CHEAP);
|
|
9
10
|
if (!requestFilesContentCall) {
|
|
@@ -12,8 +13,11 @@ export async function handleRequestFilesContent({ askQuestionCall, options, prom
|
|
|
12
13
|
items: [],
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
|
-
let requestedFiles = requestFilesContentCall.args?.filePaths ?? [];
|
|
16
|
-
putSystemMessage('Requesting files content',
|
|
16
|
+
let requestedFiles = getExpandedContextPaths(requestFilesContentCall.args?.filePaths ?? [], options);
|
|
17
|
+
putSystemMessage('Requesting files content', {
|
|
18
|
+
requestedFiles,
|
|
19
|
+
expandedRequestedFiles: requestedFiles.filter((file) => !requestFilesContentCall?.args?.filePaths?.includes(file)),
|
|
20
|
+
});
|
|
17
21
|
// Check which files are already provided in the conversation history
|
|
18
22
|
const alreadyProvidedFiles = requestedFiles.filter((file) => isFileContentAlreadyProvided(file, prompt));
|
|
19
23
|
if (alreadyProvidedFiles.length === requestedFiles.length) {
|
|
@@ -65,11 +69,12 @@ export async function handleRequestFilesContent({ askQuestionCall, options, prom
|
|
|
65
69
|
{ name: 'getSourceCode', id: sourceCallId, args: { filePaths: legitimateFiles } },
|
|
66
70
|
],
|
|
67
71
|
};
|
|
68
|
-
const sourceCode =
|
|
72
|
+
const sourceCode = getSourceCode({ filterPaths: legitimateFiles, forceAll: true, ignoreImportantFiles: true }, options);
|
|
69
73
|
const user = {
|
|
70
74
|
type: 'user',
|
|
71
75
|
text: (alreadyProvidedFiles.length > 0
|
|
72
|
-
?
|
|
76
|
+
? // TODO: Maybe reference to some specific getSourceCode call id
|
|
77
|
+
`Some files were already provided in the conversation history:
|
|
73
78
|
${alreadyProvidedFiles.map((path) => `- ${path}`).join('\n')}
|
|
74
79
|
|
|
75
80
|
Providing content for the remaining files:
|
|
@@ -99,17 +104,26 @@ ${illegitimateFiles.map((path) => `- ${path}`).join('\n')}`
|
|
|
99
104
|
return { breakLoop: false, items: [] };
|
|
100
105
|
}
|
|
101
106
|
export async function generateRequestFilesContentCall(generateContentFn, prompt, askQuestionCall, options, modelType) {
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
const req = [
|
|
108
|
+
[
|
|
109
|
+
...prompt,
|
|
110
|
+
{
|
|
111
|
+
type: 'assistant',
|
|
112
|
+
text: askQuestionCall.args?.message ?? '',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
type: 'user',
|
|
116
|
+
text: 'Yes, you can request the files contents.',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
getFunctionDefs(),
|
|
120
|
+
'requestFilesContent',
|
|
121
|
+
0.7,
|
|
122
|
+
modelType,
|
|
123
|
+
options,
|
|
124
|
+
];
|
|
125
|
+
const result = await generateContentFn(...req);
|
|
126
|
+
const [requestFilesContentCall] = (await validateAndRecoverSingleResult(req, result, generateContentFn));
|
|
113
127
|
return requestFilesContentCall;
|
|
114
128
|
}
|
|
115
129
|
/**
|
|
@@ -128,13 +142,11 @@ function isFileContentAlreadyProvided(filePath, prompt) {
|
|
|
128
142
|
return false;
|
|
129
143
|
}
|
|
130
144
|
try {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
'content' in sourceCodeTree[dirPath][fileName] &&
|
|
137
|
-
sourceCodeTree[dirPath][fileName].content !== null);
|
|
145
|
+
const sourceCodeMap = JSON.parse(response.content);
|
|
146
|
+
return (sourceCodeMap[filePath] &&
|
|
147
|
+
sourceCodeMap[filePath] &&
|
|
148
|
+
'content' in sourceCodeMap[filePath] &&
|
|
149
|
+
sourceCodeMap[filePath].content !== null);
|
|
138
150
|
}
|
|
139
151
|
catch (error) {
|
|
140
152
|
console.warn('Error parsing getSourceCode response:', error);
|
|
@@ -146,6 +158,7 @@ function isFileContentAlreadyProvided(filePath, prompt) {
|
|
|
146
158
|
function categorizeLegitimateFiles(requestedFiles) {
|
|
147
159
|
const legitimateFiles = [];
|
|
148
160
|
const illegitimateFiles = [];
|
|
161
|
+
// TODO: allow some small mistakes in the path, fix them to correct paths
|
|
149
162
|
requestedFiles.forEach((filePath) => {
|
|
150
163
|
if (isFilePathLegitimate(filePath)) {
|
|
151
164
|
legitimateFiles.push(filePath);
|
|
@@ -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":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"request-files-content.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/request-files-content.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAUhF,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAC9C,eAAe,EACf,OAAO,EACP,MAAM,EACN,iBAAiB,GACE;IACnB,IAAI,uBAAuB,GAAG,MAAM,+BAA+B,CACjE,iBAAiB,EACjB,MAAM,EACN,eAAe,EACf,OAAO,EACP,SAAS,CAAC,KAAK,CAChB,CAAC;IAEF,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC7B,OAAO;YACL,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAED,IAAI,cAAc,GAAG,uBAAuB,CAAC,uBAAuB,CAAC,IAAI,EAAE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,IAAI,CACzC,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;gBAC7D,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,yBAAyB,CAAC,cAAwB;IAIzD,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,iBAAiB,GAAa,EAAE,CAAC;IACvC,yEAAyE;IAEzE,cAAc,CAAC,OAAO,CAAC,CAAC,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"}
|
|
@@ -5,7 +5,7 @@ import { PromptItemImage } from '../../../ai-service/common-types.js';
|
|
|
5
5
|
import { FunctionCall } from '../../../ai-service/common-types.js';
|
|
6
6
|
import { CodegenOptions } from '../../../main/codegen-types.js';
|
|
7
7
|
import { PluginActionType } from '../../../ai-service/service-configurations-types.js';
|
|
8
|
-
export type ActionType = 'codeGeneration' | 'sendMessage' | 'generateImage' | 'requestPermissions' | 'requestFilesContent' | 'removeFilesFromContext' | 'confirmCodeGeneration' | 'endConversation' | 'contextOptimization' | 'searchCode' | 'lint' | 'updateFile' | 'performAnalysis' | 'createFile' | 'pullAppContext' | 'genaicodeHelp' | 'pushAppContext' | 'reasoningInference' | PluginActionType;
|
|
8
|
+
export type ActionType = 'codeGeneration' | 'sendMessage' | 'generateImage' | 'requestPermissions' | 'requestFilesContent' | 'removeFilesFromContext' | 'confirmCodeGeneration' | 'endConversation' | 'contextOptimization' | 'contextCompression' | 'searchCode' | 'lint' | 'updateFile' | 'performAnalysis' | 'createFile' | 'pullAppContext' | 'genaicodeHelp' | 'pushAppContext' | 'reasoningInference' | PluginActionType;
|
|
9
9
|
type AskQuestionArgs = {
|
|
10
10
|
actionType: ActionType;
|
|
11
11
|
message: string;
|
|
@@ -21,6 +21,7 @@ import { handlePullAppContext } from './handlers/handle-pull-app-context.js';
|
|
|
21
21
|
import { handlePushAppContext } from './handlers/handle-push-app-context.js';
|
|
22
22
|
import { handleReasoningInference } from './handlers/handle-reasoning-inference.js';
|
|
23
23
|
import { handleGenaicodeHelp } from './handlers/handle-genaicode-help.js';
|
|
24
|
+
import { handleContextCompression } from './handlers/handle-context-compression.js';
|
|
24
25
|
export async function executeStepAskQuestion(generateContentFn, generateImageFn, prompt, functionDefs, waitIfPaused, temperature, options) {
|
|
25
26
|
putSystemMessage('Allowing the assistant to ask a question...');
|
|
26
27
|
while (!abortController?.signal.aborted) {
|
|
@@ -120,6 +121,7 @@ function getActionHandler(actionType) {
|
|
|
120
121
|
genaicodeHelp: handleGenaicodeHelp,
|
|
121
122
|
reasoningInference: handleReasoningInference,
|
|
122
123
|
pushAppContext: handlePushAppContext,
|
|
124
|
+
contextCompression: handleContextCompression,
|
|
123
125
|
};
|
|
124
126
|
return handlers[actionType] || handleSendMessage;
|
|
125
127
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-ask-question.js","sourceRoot":"","sources":["../../../../src/prompt/steps/step-ask-question/step-ask-question.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC5G,OAAO,EAAE,eAAe,EAA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E,gBAAgB;QAC5B,UAAU,EAAE,gBAAgB;QAC5B,eAAe,EAAE,qBAAqB;QACtC,cAAc,EAAE,oBAAoB;QACpC,aAAa,EAAE,mBAAmB;QAClC,kBAAkB,EAAE,wBAAwB;QAC5C,cAAc,EAAE,oBAAoB;QACpC,kBAAkB,EAAE,wBAAwB;KAC7C,CAAC;IAEF,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,iBAAiB,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GenerateContentFunction, PromptItem } from '../../ai-service/common-types.js';
|
|
2
|
+
import { CodegenOptions } from '../../main/codegen-types.js';
|
|
3
|
+
import { StepResult } from './steps-types.js';
|
|
4
|
+
export declare const CONTEXT_COMPRESSION_PROMPT = "Analyze the conversation history and source code dependencies to create a comprehensive context summary that preserves essential information while maintaining reasonable token efficiency.\n\nKey Principles:\n1. Preserve Rich Context: Maintain detailed information about the conversation, especially for expensive operations like reasoning inference, code analysis, or complex decision-making.\n2. Token Efficiency: Aim for a meaningful compression (e.g., 5k tokens for a 100k token conversation) without being overly aggressive.\n3. File Handling: Do not include file contents in the summary - use filePaths array for this purpose.\n4. Temporal Context: Preserve chronological progression of important decisions and changes.\n\nRequired Information to Preserve:\n1. Conversation Flow:\n - Initial problem statement or task\n - Key questions asked and answers received\n - Important decisions made and their rationale\n - Results of expensive operations (reasoning inference, analysis)\n - Critical user preferences or constraints\n - Any errors or issues encountered\n\n2. Technical Details:\n - Code changes proposed or implemented\n - Architecture decisions\n - Performance considerations\n - Security implications\n - Dependencies identified\n - Testing requirements\n\n3. Implementation Status:\n - Current stage of development\n - Completed steps\n - Pending tasks\n - Known issues or challenges\n - Validation results\n\nFormat your response as a structured JSON object with:\n- conversationSummary: Detailed summary preserving rich context of the conversation's progression and key decisions\n- codegenIntent: Comprehensive description of the primary goal, constraints, and special requirements\n- filePaths: Array of file paths that are critical for the task (no file contents, just paths)\n\nExample of good summary structure:\n{\n \"conversationSummary\": \"Started: User requested CONTEXT_COMPRESSION_PROMPT improvement. Analysis: Current compression too aggressive (100k->100 tokens). Key Decision: Allow larger summaries (5k tokens ok). Reasoning inference revealed importance of preserving expensive operation results. Implementation: Updating compression logic in step-context-compression.ts. Requirements: 1) Less aggressive compression, 2) Rich conversation preservation, 3) No file contents in summary.\",\n \"codegenIntent\": \"Enhance context compression to preserve more information (up to 5k tokens) while maintaining efficiency. Focus on rich conversation details, especially expensive operations like reasoning inference. Exclude file contents from summary/intent, using filePaths instead. Goal: Better balance between compression and information preservation.\",\n \"filePaths\": [\"/path/to/relevant/files\"]\n}\n\nFocus on creating a summary that:\n1. Is comprehensive enough for the AI to understand the full context\n2. Preserves expensive computation results\n3. Maintains chronological flow of decisions\n4. Captures technical details and requirements\n5. Excludes file contents but includes critical file paths";
|
|
5
|
+
/**
|
|
6
|
+
* Executes the context compression step
|
|
7
|
+
*/
|
|
8
|
+
export declare function executeStepContextCompression(generateContentFn: GenerateContentFunction, prompt: PromptItem[], options: CodegenOptions): Promise<StepResult>;
|