genaicode 0.2.0 → 0.3.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 +2 -0
- package/bin/genaicode-dev.js +2 -1
- package/bin/genaicode.cjs +4 -4
- package/dist/ai-service/ai-studio.js +8 -2
- package/dist/ai-service/ai-studio.js.map +1 -1
- package/dist/ai-service/anthropic.js +21 -8
- package/dist/ai-service/anthropic.js.map +1 -1
- package/dist/ai-service/chat-gpt.js +21 -10
- package/dist/ai-service/chat-gpt.js.map +1 -1
- package/dist/ai-service/common.d.ts +9 -5
- package/dist/ai-service/common.js +6 -4
- package/dist/ai-service/common.js.map +1 -1
- package/dist/ai-service/common.test.js +3 -3
- package/dist/ai-service/common.test.js.map +1 -1
- package/dist/ai-service/vertex-ai-claude.js +5 -4
- package/dist/ai-service/vertex-ai-claude.js.map +1 -1
- package/dist/ai-service/vertex-ai.js +11 -2
- package/dist/ai-service/vertex-ai.js.map +1 -1
- package/dist/cli/cli-params.d.ts +2 -0
- package/dist/cli/cli-params.js +14 -2
- package/dist/cli/cli-params.js.map +1 -1
- package/dist/cli/validate-cli-params.js +3 -1
- package/dist/cli/validate-cli-params.js.map +1 -1
- package/dist/files/find-files.d.ts +1 -0
- package/dist/files/find-files.js +7 -2
- package/dist/files/find-files.js.map +1 -1
- package/dist/files/read-files.d.ts +2 -2
- package/dist/files/read-files.js +2 -2
- package/dist/files/read-files.js.map +1 -1
- package/dist/files/read-files.test.js +1 -1
- package/dist/files/read-files.test.js.map +1 -1
- package/dist/main/codegen-types.d.ts +13 -0
- package/dist/main/codegen.d.ts +2 -2
- package/dist/main/codegen.js +86 -52
- package/dist/main/codegen.js.map +1 -1
- package/dist/main/codegen.test.js +7 -4
- package/dist/main/codegen.test.js.map +1 -1
- package/dist/main/common/content-bus-types.d.ts +16 -0
- package/dist/main/common/content-bus-types.js +7 -0
- package/dist/main/common/content-bus-types.js.map +1 -0
- package/dist/main/common/content-bus.d.ts +9 -0
- package/dist/main/common/content-bus.js +25 -0
- package/dist/main/common/content-bus.js.map +1 -0
- package/dist/main/common/cost-collector.d.ts +15 -0
- package/dist/main/common/cost-collector.js +24 -0
- package/dist/main/common/cost-collector.js.map +1 -0
- package/dist/main/common/user-actions.d.ts +7 -0
- package/dist/main/common/user-actions.js +15 -0
- package/dist/main/common/user-actions.js.map +1 -0
- package/dist/main/config-lib.d.ts +19 -0
- package/dist/main/config-lib.js.map +1 -1
- package/dist/main/config.d.ts +2 -1
- package/dist/main/config.js +3 -0
- package/dist/main/config.js.map +1 -1
- package/dist/main/interactive/codegen-interactive.js +8 -2
- package/dist/main/interactive/codegen-interactive.js.map +1 -1
- package/dist/main/interactive/codegen-worker.d.ts +1 -1
- package/dist/main/interactive/codegen-worker.js +5 -2
- package/dist/main/interactive/codegen-worker.js.map +1 -1
- package/dist/main/interactive/task-file.js +9 -2
- package/dist/main/interactive/task-file.js.map +1 -1
- package/dist/main/interactive/user-action-handlers.d.ts +1 -0
- package/dist/main/interactive/user-action-handlers.js +13 -0
- package/dist/main/interactive/user-action-handlers.js.map +1 -0
- package/dist/main/interactive/user-interrupt.js +1 -1
- package/dist/main/interactive/user-interrupt.js.map +1 -1
- package/dist/main/ui/backend/api-utils.d.ts +2 -0
- package/dist/main/ui/backend/api-utils.js +18 -0
- package/dist/main/ui/backend/api-utils.js.map +1 -0
- package/dist/main/ui/backend/api.d.ts +2 -0
- package/dist/main/ui/backend/api.js +186 -0
- package/dist/main/ui/backend/api.js.map +1 -0
- package/dist/main/ui/backend/server.d.ts +2 -0
- package/dist/main/ui/backend/server.js +81 -0
- package/dist/main/ui/backend/server.js.map +1 -0
- package/dist/main/ui/backend/service.d.ts +47 -0
- package/dist/main/ui/backend/service.js +161 -0
- package/dist/main/ui/backend/service.js.map +1 -0
- package/dist/main/ui/codegen-ui.d.ts +2 -0
- package/dist/main/ui/codegen-ui.js +13 -0
- package/dist/main/ui/codegen-ui.js.map +1 -0
- package/dist/main/ui/frontend/assets/index-D9wcaSJU.js +598 -0
- package/dist/main/ui/frontend/assets/index-S_ocA1xG.css +1 -0
- package/dist/main/ui/frontend/assets/logo-BGHkG1-J.png +0 -0
- package/dist/main/ui/frontend/assets/logo-dark-KAsU1C78.png +0 -0
- package/dist/main/ui/frontend/assets/press-start-2p-cyrillic-400-normal-oElOGqNf.woff2 +0 -0
- package/dist/main/ui/frontend/assets/press-start-2p-cyrillic-ext-400-normal-COIQET2s.woff2 +0 -0
- package/dist/main/ui/frontend/assets/press-start-2p-greek-400-normal-DUIT0YPZ.woff2 +0 -0
- package/dist/main/ui/frontend/assets/press-start-2p-latin-400-normal-BKfmdmKK.woff +0 -0
- package/dist/main/ui/frontend/assets/press-start-2p-latin-400-normal-xj9lRvVs.woff2 +0 -0
- package/dist/main/ui/frontend/assets/press-start-2p-latin-ext-400-normal-B18ub5-k.woff +0 -0
- package/dist/main/ui/frontend/assets/press-start-2p-latin-ext-400-normal-DDIa4im3.woff2 +0 -0
- package/dist/main/ui/frontend/index.html +16 -0
- package/dist/main/ui/user-action-handlers.d.ts +2 -0
- package/dist/main/ui/user-action-handlers.js +9 -0
- package/dist/main/ui/user-action-handlers.js.map +1 -0
- package/dist/prompt/ai-service-fallback.d.ts +3 -0
- package/dist/prompt/ai-service-fallback.js +79 -0
- package/dist/prompt/ai-service-fallback.js.map +1 -0
- package/dist/prompt/function-calling.js +3 -1
- package/dist/prompt/function-calling.js.map +1 -1
- package/dist/prompt/function-defs/ask-question.d.ts +16 -13
- package/dist/prompt/function-defs/ask-question.js +16 -14
- package/dist/prompt/function-defs/ask-question.js.map +1 -1
- package/dist/prompt/function-defs/codegen-summary.d.ts +23 -21
- package/dist/prompt/function-defs/codegen-summary.js +28 -28
- package/dist/prompt/function-defs/codegen-summary.js.map +1 -1
- package/dist/prompt/function-defs/create-file.d.ts +4 -4
- package/dist/prompt/function-defs/create-file.js +4 -4
- package/dist/prompt/function-defs/create-file.js.map +1 -1
- package/dist/prompt/function-defs/delete-file.d.ts +4 -4
- package/dist/prompt/function-defs/delete-file.js +4 -4
- package/dist/prompt/function-defs/delete-file.js.map +1 -1
- package/dist/prompt/function-defs/generate-image.d.ts +4 -4
- package/dist/prompt/function-defs/generate-image.js +4 -4
- package/dist/prompt/function-defs/generate-image.js.map +1 -1
- package/dist/prompt/function-defs/get-source-code.d.ts +1 -1
- package/dist/prompt/function-defs/get-source-code.js +2 -1
- package/dist/prompt/function-defs/get-source-code.js.map +1 -1
- package/dist/prompt/function-defs/move-file.d.ts +4 -4
- package/dist/prompt/function-defs/move-file.js +4 -4
- package/dist/prompt/function-defs/move-file.js.map +1 -1
- package/dist/prompt/function-defs/optimize-context.d.ts +41 -0
- package/dist/prompt/function-defs/optimize-context.js +42 -0
- package/dist/prompt/function-defs/optimize-context.js.map +1 -0
- package/dist/prompt/function-defs/patch-file.d.ts +4 -4
- package/dist/prompt/function-defs/patch-file.js +4 -4
- package/dist/prompt/function-defs/patch-file.js.map +1 -1
- package/dist/prompt/function-defs/update-file.d.ts +4 -4
- package/dist/prompt/function-defs/update-file.js +4 -4
- package/dist/prompt/function-defs/update-file.js.map +1 -1
- package/dist/prompt/limits.d.ts +3 -3
- package/dist/prompt/limits.js +10 -8
- package/dist/prompt/limits.js.map +1 -1
- package/dist/prompt/limits.test.js +6 -6
- package/dist/prompt/limits.test.js.map +1 -1
- package/dist/prompt/prompt-codegen.js +38 -23
- package/dist/prompt/prompt-codegen.js.map +1 -1
- package/dist/prompt/prompt-codegen.test.js +2 -2
- package/dist/prompt/prompt-codegen.test.js.map +1 -1
- package/dist/prompt/prompt-service-ask-question.test.js +12 -5
- package/dist/prompt/prompt-service-ask-question.test.js.map +1 -1
- package/dist/prompt/prompt-service.d.ts +3 -9
- package/dist/prompt/prompt-service.js +37 -12
- package/dist/prompt/prompt-service.js.map +1 -1
- package/dist/prompt/prompt-service.test.js +40 -25
- package/dist/prompt/prompt-service.test.js.map +1 -1
- package/dist/prompt/steps/step-ask-question.d.ts +1 -1
- package/dist/prompt/steps/step-ask-question.js +35 -20
- package/dist/prompt/steps/step-ask-question.js.map +1 -1
- package/dist/prompt/steps/step-context-optimization.d.ts +6 -0
- package/dist/prompt/steps/step-context-optimization.js +146 -0
- package/dist/prompt/steps/step-context-optimization.js.map +1 -0
- package/dist/prompt/systemprompt.d.ts +1 -1
- package/dist/prompt/systemprompt.js +82 -32
- package/dist/prompt/systemprompt.js.map +1 -1
- package/dist/prompt/systemprompt.test.js +5 -8
- package/dist/prompt/systemprompt.test.js.map +1 -1
- package/dist/prompt/token-estimator.d.ts +8 -0
- package/dist/prompt/token-estimator.js +31 -0
- package/dist/prompt/token-estimator.js.map +1 -0
- package/package.json +24 -4
- package/dist/main/codegen-interactive-utils.d.ts +0 -8
- package/dist/main/codegen-interactive-utils.js +0 -148
- package/dist/main/codegen-interactive-utils.js.map +0 -1
- package/dist/main/codegen-interactive.d.ts +0 -2
- package/dist/main/codegen-interactive.js +0 -68
- package/dist/main/codegen-interactive.js.map +0 -1
- package/dist/main/interactive/worker-script.d.ts +0 -1
- package/dist/main/interactive/worker-script.js +0 -24
- package/dist/main/interactive/worker-script.js.map +0 -1
- package/dist/main/interactive/worker.d.ts +0 -2
- package/dist/main/interactive/worker.js +0 -55
- package/dist/main/interactive/worker.js.map +0 -1
|
@@ -11,14 +11,14 @@ export declare const createFile: {
|
|
|
11
11
|
readonly type: "string";
|
|
12
12
|
readonly description: "Path of the file that will be created, it must not be empty.";
|
|
13
13
|
};
|
|
14
|
-
readonly newContent: {
|
|
15
|
-
readonly type: "string";
|
|
16
|
-
readonly description: "Content of the file that will be created, it must no be empty.";
|
|
17
|
-
};
|
|
18
14
|
readonly explanation: {
|
|
19
15
|
readonly type: "string";
|
|
20
16
|
readonly description: "The explanation of the reasoning behind creating this file";
|
|
21
17
|
};
|
|
18
|
+
readonly newContent: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: "Content of the file that will be created, it must no be empty.";
|
|
21
|
+
};
|
|
22
22
|
};
|
|
23
23
|
readonly required: readonly ["filePath", "newContent"];
|
|
24
24
|
};
|
|
@@ -11,14 +11,14 @@ export const createFile = {
|
|
|
11
11
|
type: 'string',
|
|
12
12
|
description: 'Path of the file that will be created, it must not be empty.',
|
|
13
13
|
},
|
|
14
|
-
newContent: {
|
|
15
|
-
type: 'string',
|
|
16
|
-
description: 'Content of the file that will be created, it must no be empty.',
|
|
17
|
-
},
|
|
18
14
|
explanation: {
|
|
19
15
|
type: 'string',
|
|
20
16
|
description: 'The explanation of the reasoning behind creating this file',
|
|
21
17
|
},
|
|
18
|
+
newContent: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'Content of the file that will be created, it must no be empty.',
|
|
21
|
+
},
|
|
22
22
|
},
|
|
23
23
|
required: ['filePath', 'newContent'],
|
|
24
24
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-file.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/create-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,iKAAiK;IACnK,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8DAA8D;aAC5E;YACD,
|
|
1
|
+
{"version":3,"file":"create-file.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/create-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,iKAAiK;IACnK,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8DAA8D;aAC5E;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4DAA4D;aAC1E;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gEAAgE;aAC9E;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;KACrC;CACO,CAAC"}
|
|
@@ -7,14 +7,14 @@ export declare const deleteFile: {
|
|
|
7
7
|
readonly parameters: {
|
|
8
8
|
readonly type: "object";
|
|
9
9
|
readonly properties: {
|
|
10
|
-
readonly filePath: {
|
|
11
|
-
readonly type: "string";
|
|
12
|
-
readonly description: "The file path to delete.";
|
|
13
|
-
};
|
|
14
10
|
readonly explanation: {
|
|
15
11
|
readonly type: "string";
|
|
16
12
|
readonly description: "The explanation of the reasoning behind deleting this file";
|
|
17
13
|
};
|
|
14
|
+
readonly filePath: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly description: "The file path to delete.";
|
|
17
|
+
};
|
|
18
18
|
};
|
|
19
19
|
readonly required: readonly ["filePath"];
|
|
20
20
|
};
|
|
@@ -7,14 +7,14 @@ export const deleteFile = {
|
|
|
7
7
|
parameters: {
|
|
8
8
|
type: 'object',
|
|
9
9
|
properties: {
|
|
10
|
-
filePath: {
|
|
11
|
-
type: 'string',
|
|
12
|
-
description: 'The file path to delete.',
|
|
13
|
-
},
|
|
14
10
|
explanation: {
|
|
15
11
|
type: 'string',
|
|
16
12
|
description: 'The explanation of the reasoning behind deleting this file',
|
|
17
13
|
},
|
|
14
|
+
filePath: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'The file path to delete.',
|
|
17
|
+
},
|
|
18
18
|
},
|
|
19
19
|
required: ['filePath'],
|
|
20
20
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-file.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/delete-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,2DAA2D;IACxE,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,
|
|
1
|
+
{"version":3,"file":"delete-file.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/delete-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,2DAA2D;IACxE,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4DAA4D;aAC1E;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0BAA0B;aACxC;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,CAAC;KACvB;CACO,CAAC"}
|
|
@@ -7,6 +7,10 @@ export declare const generateImage: {
|
|
|
7
7
|
readonly parameters: {
|
|
8
8
|
readonly type: "object";
|
|
9
9
|
readonly properties: {
|
|
10
|
+
readonly explanation: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "The explanation of the reasoning behind generating this image";
|
|
13
|
+
};
|
|
10
14
|
readonly prompt: {
|
|
11
15
|
readonly type: "string";
|
|
12
16
|
readonly description: "The prompt that will be used to generate the image. This prompt must be detailed, it will be used by image generation model.";
|
|
@@ -31,10 +35,6 @@ export declare const generateImage: {
|
|
|
31
35
|
readonly type: "boolean";
|
|
32
36
|
readonly description: "true value means that the prompt will be executed with cheaper model, which work faster, but provides lower quality results, so please use it only in situation when lower quality results are acceptable for the prompt.";
|
|
33
37
|
};
|
|
34
|
-
readonly explanation: {
|
|
35
|
-
readonly type: "string";
|
|
36
|
-
readonly description: "The explanation of the reasoning behind generating this image";
|
|
37
|
-
};
|
|
38
38
|
};
|
|
39
39
|
readonly required: readonly ["prompt", "filePath", "width", "height"];
|
|
40
40
|
};
|
|
@@ -7,6 +7,10 @@ export const generateImage = {
|
|
|
7
7
|
parameters: {
|
|
8
8
|
type: 'object',
|
|
9
9
|
properties: {
|
|
10
|
+
explanation: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The explanation of the reasoning behind generating this image',
|
|
13
|
+
},
|
|
10
14
|
prompt: {
|
|
11
15
|
type: 'string',
|
|
12
16
|
description: 'The prompt that will be used to generate the image. This prompt must be detailed, it will be used by image generation model.',
|
|
@@ -31,10 +35,6 @@ export const generateImage = {
|
|
|
31
35
|
type: 'boolean',
|
|
32
36
|
description: 'true value means that the prompt will be executed with cheaper model, which work faster, but provides lower quality results, so please use it only in situation when lower quality results are acceptable for the prompt.',
|
|
33
37
|
},
|
|
34
|
-
explanation: {
|
|
35
|
-
type: 'string',
|
|
36
|
-
description: 'The explanation of the reasoning behind generating this image',
|
|
37
|
-
},
|
|
38
38
|
},
|
|
39
39
|
required: ['prompt', 'filePath', 'width', 'height'],
|
|
40
40
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-image.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/generate-image.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,2DAA2D;IACxE,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,8HAA8H;aACjI;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4CAA4C;aAC1D;YACD,gBAAgB,EAAE;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,wIAAwI;aAC3I;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oBAAoB;aAClC;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qBAAqB;aACnC;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS;gBACf,WAAW,EACT,2NAA2N;aAC9N;
|
|
1
|
+
{"version":3,"file":"generate-image.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/generate-image.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,2DAA2D;IACxE,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+DAA+D;aAC7E;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,8HAA8H;aACjI;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4CAA4C;aAC1D;YACD,gBAAgB,EAAE;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,wIAAwI;aAC3I;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oBAAoB;aAClC;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qBAAqB;aACnC;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS;gBACf,WAAW,EACT,2NAA2N;aAC9N;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC;KACpD;CACO,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const getSourceCode: {
|
|
5
5
|
readonly name: "getSourceCode";
|
|
6
|
-
readonly description:
|
|
6
|
+
readonly description: string;
|
|
7
7
|
readonly parameters: {
|
|
8
8
|
readonly type: "object";
|
|
9
9
|
readonly properties: {
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const getSourceCode = {
|
|
5
5
|
name: 'getSourceCode',
|
|
6
|
-
description: 'This function returns source code of the application in Map format, where absolute file path is the key, and the value is an object, where one of the properties may be the content of the file.
|
|
6
|
+
description: 'This function returns source code of the application in Map format, where absolute file path is the key, and the value is an object, where one of the properties may be the content of the file.' +
|
|
7
|
+
'Some keys may not provide content. Some keys may provide a short summary of content. This function can be called only once during the conversation, and only if suggested by the user.',
|
|
7
8
|
parameters: {
|
|
8
9
|
type: 'object',
|
|
9
10
|
properties: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-source-code.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/get-source-code.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"get-source-code.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/get-source-code.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,kMAAkM;QAClM,wLAAwL;IAC1L,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;CACO,CAAC"}
|
|
@@ -7,6 +7,10 @@ export declare const moveFile: {
|
|
|
7
7
|
readonly parameters: {
|
|
8
8
|
readonly type: "object";
|
|
9
9
|
readonly properties: {
|
|
10
|
+
readonly explanation: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "The explanation of the reasoning behind moving this file";
|
|
13
|
+
};
|
|
10
14
|
readonly source: {
|
|
11
15
|
readonly type: "string";
|
|
12
16
|
readonly description: "The current file path.";
|
|
@@ -15,10 +19,6 @@ export declare const moveFile: {
|
|
|
15
19
|
readonly type: "string";
|
|
16
20
|
readonly description: "The new file path.";
|
|
17
21
|
};
|
|
18
|
-
readonly explanation: {
|
|
19
|
-
readonly type: "string";
|
|
20
|
-
readonly description: "The explanation of the reasoning behind moving this file";
|
|
21
|
-
};
|
|
22
22
|
};
|
|
23
23
|
readonly required: readonly ["source", "destination"];
|
|
24
24
|
};
|
|
@@ -7,6 +7,10 @@ export const moveFile = {
|
|
|
7
7
|
parameters: {
|
|
8
8
|
type: 'object',
|
|
9
9
|
properties: {
|
|
10
|
+
explanation: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The explanation of the reasoning behind moving this file',
|
|
13
|
+
},
|
|
10
14
|
source: {
|
|
11
15
|
type: 'string',
|
|
12
16
|
description: 'The current file path.',
|
|
@@ -15,10 +19,6 @@ export const moveFile = {
|
|
|
15
19
|
type: 'string',
|
|
16
20
|
description: 'The new file path.',
|
|
17
21
|
},
|
|
18
|
-
explanation: {
|
|
19
|
-
type: 'string',
|
|
20
|
-
description: 'The explanation of the reasoning behind moving this file',
|
|
21
|
-
},
|
|
22
22
|
},
|
|
23
23
|
required: ['source', 'destination'],
|
|
24
24
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move-file.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/move-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,0CAA0C;IACvD,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,
|
|
1
|
+
{"version":3,"file":"move-file.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/move-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,0CAA0C;IACvD,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0DAA0D;aACxE;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wBAAwB;aACtC;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oBAAoB;aAClC;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;KACpC;CACO,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for optimizeContext
|
|
3
|
+
*/
|
|
4
|
+
export declare const optimizeContext: {
|
|
5
|
+
readonly name: "optimizeContext";
|
|
6
|
+
readonly description: "Analyzes each file to provide a brief summary and rate its relevance to the user's prompt on a scale of 0 to 1.";
|
|
7
|
+
readonly parameters: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly userPrompt: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "The user's original prompt.";
|
|
13
|
+
};
|
|
14
|
+
readonly optimizedContext: {
|
|
15
|
+
readonly type: "array";
|
|
16
|
+
readonly description: "An array of results, each corresponding to an analyzed file, containing the file path, a brief summary, and a relevance score.";
|
|
17
|
+
readonly items: {
|
|
18
|
+
readonly type: "object";
|
|
19
|
+
readonly properties: {
|
|
20
|
+
readonly path: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly description: "The file path of the analyzed file, matching the 'path' provided in the input.";
|
|
23
|
+
};
|
|
24
|
+
readonly summary: {
|
|
25
|
+
readonly type: "string";
|
|
26
|
+
readonly description: "A concise one-sentence summary of the file's content, highlighting its main purpose or functionality.";
|
|
27
|
+
};
|
|
28
|
+
readonly relevance: {
|
|
29
|
+
readonly type: "number";
|
|
30
|
+
readonly description: "A numeric score between 0 and 1 indicating the file's relevance to the user's prompt. A score of 0 means not relevant at all, while a score of 1 means highly relevant.";
|
|
31
|
+
readonly minimum: 0;
|
|
32
|
+
readonly maximum: 1;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
readonly required: readonly ["path", "summary", "relevance"];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
readonly required: readonly ["userPrompt", "optimizedContext"];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for optimizeContext
|
|
3
|
+
*/
|
|
4
|
+
export const optimizeContext = {
|
|
5
|
+
name: 'optimizeContext',
|
|
6
|
+
description: "Analyzes each file to provide a brief summary and rate its relevance to the user's prompt on a scale of 0 to 1.",
|
|
7
|
+
parameters: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
userPrompt: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: "The user's original prompt.",
|
|
13
|
+
},
|
|
14
|
+
optimizedContext: {
|
|
15
|
+
type: 'array',
|
|
16
|
+
description: 'An array of results, each corresponding to an analyzed file, containing the file path, a brief summary, and a relevance score.',
|
|
17
|
+
items: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
path: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
description: "The file path of the analyzed file, matching the 'path' provided in the input.",
|
|
23
|
+
},
|
|
24
|
+
summary: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: "A concise one-sentence summary of the file's content, highlighting its main purpose or functionality.",
|
|
27
|
+
},
|
|
28
|
+
relevance: {
|
|
29
|
+
type: 'number',
|
|
30
|
+
description: "A numeric score between 0 and 1 indicating the file's relevance to the user's prompt. A score of 0 means not relevant at all, while a score of 1 means highly relevant.",
|
|
31
|
+
minimum: 0,
|
|
32
|
+
maximum: 1,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ['path', 'summary', 'relevance'],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
required: ['userPrompt', 'optimizedContext'],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=optimize-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optimize-context.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/optimize-context.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,iHAAiH;IACnH,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,EACT,gIAAgI;gBAClI,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE;4BACJ,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,gFAAgF;yBAC9F;wBACD,OAAO,EAAE;4BACP,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,uGAAuG;yBAC1G;wBACD,SAAS,EAAE;4BACT,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,yKAAyK;4BAC3K,OAAO,EAAE,CAAC;4BACV,OAAO,EAAE,CAAC;yBACX;qBACF;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC;iBAC3C;aACF;SACF;QACD,QAAQ,EAAE,CAAC,YAAY,EAAE,kBAAkB,CAAC;KAC7C;CACO,CAAC"}
|
|
@@ -11,14 +11,14 @@ export declare const patchFile: {
|
|
|
11
11
|
readonly type: "string";
|
|
12
12
|
readonly description: "The file path to patch.";
|
|
13
13
|
};
|
|
14
|
-
readonly patch: {
|
|
15
|
-
readonly type: "string";
|
|
16
|
-
readonly description: "Modification to the file expressed in patch format. Example patch:\n\n```\nIndex: filename.js\n===================================================================\n--- filename.js\n+++ filename.js\n@@ -1,2 +1,3 @@\n line1\n+line3\n line2\n\\n```\n ";
|
|
17
|
-
};
|
|
18
14
|
readonly explanation: {
|
|
19
15
|
readonly type: "string";
|
|
20
16
|
readonly description: "The explanation of the reasoning behind the suggested code changes for this file";
|
|
21
17
|
};
|
|
18
|
+
readonly patch: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: "Modification to the file expressed in patch format. Example patch:\n\n```\nIndex: filename.js\n===================================================================\n--- filename.js\n+++ filename.js\n@@ -1,2 +1,3 @@\n line1\n+line3\n line2\n\\n```\n ";
|
|
21
|
+
};
|
|
22
22
|
};
|
|
23
23
|
readonly required: readonly ["filePath", "patch"];
|
|
24
24
|
};
|
|
@@ -11,6 +11,10 @@ export const patchFile = {
|
|
|
11
11
|
type: 'string',
|
|
12
12
|
description: 'The file path to patch.',
|
|
13
13
|
},
|
|
14
|
+
explanation: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'The explanation of the reasoning behind the suggested code changes for this file',
|
|
17
|
+
},
|
|
14
18
|
patch: {
|
|
15
19
|
type: 'string',
|
|
16
20
|
description: `Modification to the file expressed in patch format. Example patch:
|
|
@@ -28,10 +32,6 @@ Index: filename.js
|
|
|
28
32
|
\`\`\`
|
|
29
33
|
`,
|
|
30
34
|
},
|
|
31
|
-
explanation: {
|
|
32
|
-
type: 'string',
|
|
33
|
-
description: 'The explanation of the reasoning behind the suggested code changes for this file',
|
|
34
|
-
},
|
|
35
35
|
},
|
|
36
36
|
required: ['filePath', 'patch'],
|
|
37
37
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch-file.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/patch-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,mLAAmL;IACrL,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yBAAyB;aACvC;YACD,
|
|
1
|
+
{"version":3,"file":"patch-file.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/patch-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,mLAAmL;IACrL,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yBAAyB;aACvC;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kFAAkF;aAChG;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;;;;;;;;;;;;;WAaV;aACJ;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC;KAChC;CACO,CAAC"}
|
|
@@ -11,14 +11,14 @@ export declare const updateFile: {
|
|
|
11
11
|
readonly type: "string";
|
|
12
12
|
readonly description: "The file path to update.";
|
|
13
13
|
};
|
|
14
|
-
readonly newContent: {
|
|
15
|
-
readonly type: "string";
|
|
16
|
-
readonly description: "The content to update the file with. Must not be empty.";
|
|
17
|
-
};
|
|
18
14
|
readonly explanation: {
|
|
19
15
|
readonly type: "string";
|
|
20
16
|
readonly description: "The explanation of the reasoning behind the suggested code changes for this file";
|
|
21
17
|
};
|
|
18
|
+
readonly newContent: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: "The content to update the file with. Must not be empty.";
|
|
21
|
+
};
|
|
22
22
|
};
|
|
23
23
|
readonly required: readonly ["filePath", "newContent"];
|
|
24
24
|
};
|
|
@@ -11,14 +11,14 @@ export const updateFile = {
|
|
|
11
11
|
type: 'string',
|
|
12
12
|
description: 'The file path to update.',
|
|
13
13
|
},
|
|
14
|
-
newContent: {
|
|
15
|
-
type: 'string',
|
|
16
|
-
description: 'The content to update the file with. Must not be empty.',
|
|
17
|
-
},
|
|
18
14
|
explanation: {
|
|
19
15
|
type: 'string',
|
|
20
16
|
description: 'The explanation of the reasoning behind the suggested code changes for this file',
|
|
21
17
|
},
|
|
18
|
+
newContent: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'The content to update the file with. Must not be empty.',
|
|
21
|
+
},
|
|
22
22
|
},
|
|
23
23
|
required: ['filePath', 'newContent'],
|
|
24
24
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-file.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/update-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,kLAAkL;IACpL,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0BAA0B;aACxC;YACD,
|
|
1
|
+
{"version":3,"file":"update-file.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/update-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,kLAAkL;IACpL,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0BAA0B;aACxC;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kFAAkF;aAChG;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yDAAyD;aACvE;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;KACrC;CACO,CAAC"}
|
package/dist/prompt/limits.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function verifySystemPromptLimit(systemPrompt: string):
|
|
2
|
-
export declare function verifyCodegenPromptLimit(codeGenPrompt: string):
|
|
3
|
-
export declare function verifySourceCodeLimit(sourceCode: string):
|
|
1
|
+
export declare function verifySystemPromptLimit(systemPrompt: string): number;
|
|
2
|
+
export declare function verifyCodegenPromptLimit(codeGenPrompt: string): number;
|
|
3
|
+
export declare function verifySourceCodeLimit(sourceCode: string): number;
|
package/dist/prompt/limits.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
2
|
+
import { estimateTokenCount } from './token-estimator.js';
|
|
3
|
+
const SYSTEM_PROMPT_LIMIT = 1000;
|
|
4
|
+
const CODEGEN_PROMPT_LIMIT = 800;
|
|
5
|
+
const SOURCE_CODE_LIMIT = 100000;
|
|
5
6
|
function verifyPromptLimit(promptType, prompt, limit) {
|
|
6
|
-
const tokenCount = prompt
|
|
7
|
-
console.log(`${promptType} prompt token count: ${tokenCount}`);
|
|
7
|
+
const tokenCount = estimateTokenCount(prompt);
|
|
8
|
+
console.log(`${promptType} prompt estimated token count: ${tokenCount}`);
|
|
8
9
|
assert(tokenCount <= limit, `Token limit exceeded: ${tokenCount} > ${limit}`);
|
|
10
|
+
return tokenCount;
|
|
9
11
|
}
|
|
10
12
|
export function verifySystemPromptLimit(systemPrompt) {
|
|
11
|
-
verifyPromptLimit('system', systemPrompt, SYSTEM_PROMPT_LIMIT);
|
|
13
|
+
return verifyPromptLimit('system', systemPrompt, SYSTEM_PROMPT_LIMIT);
|
|
12
14
|
}
|
|
13
15
|
export function verifyCodegenPromptLimit(codeGenPrompt) {
|
|
14
|
-
verifyPromptLimit('codegen', codeGenPrompt, CODEGEN_PROMPT_LIMIT);
|
|
16
|
+
return verifyPromptLimit('codegen', codeGenPrompt, CODEGEN_PROMPT_LIMIT);
|
|
15
17
|
}
|
|
16
18
|
export function verifySourceCodeLimit(sourceCode) {
|
|
17
|
-
verifyPromptLimit('sourceCode', sourceCode, SOURCE_CODE_LIMIT);
|
|
19
|
+
return verifyPromptLimit('sourceCode', sourceCode, SOURCE_CODE_LIMIT);
|
|
18
20
|
}
|
|
19
21
|
//# sourceMappingURL=limits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/prompt/limits.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;
|
|
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,GAAG,CAAC;AACjC,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(2000);
|
|
11
|
+
expect(() => verifySystemPromptLimit(invalidPrompt)).toThrow('Token limit exceeded: 1300 > 1000');
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
describe('verifyCodegenPromptLimit', () => {
|
|
@@ -17,8 +17,8 @@ describe('Prompt Limits', () => {
|
|
|
17
17
|
expect(() => verifyCodegenPromptLimit(validPrompt)).not.toThrow();
|
|
18
18
|
});
|
|
19
19
|
it('should throw for a prompt exceeding the limit', () => {
|
|
20
|
-
const invalidPrompt = 'B '.repeat(
|
|
21
|
-
expect(() => verifyCodegenPromptLimit(invalidPrompt)).toThrow('Token limit exceeded:
|
|
20
|
+
const invalidPrompt = 'B '.repeat(10000);
|
|
21
|
+
expect(() => verifyCodegenPromptLimit(invalidPrompt)).toThrow('Token limit exceeded: 6500 > 800');
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
describe('verifySourceCodeLimit', () => {
|
|
@@ -27,8 +27,8 @@ describe('Prompt Limits', () => {
|
|
|
27
27
|
expect(() => verifySourceCodeLimit(validSourceCode)).not.toThrow();
|
|
28
28
|
});
|
|
29
29
|
it('should throw for source code exceeding the limit', () => {
|
|
30
|
-
const invalidSourceCode = 'C '.repeat(
|
|
31
|
-
expect(() => verifySourceCodeLimit(invalidSourceCode)).toThrow('Token limit exceeded:
|
|
30
|
+
const invalidSourceCode = 'C '.repeat(400001);
|
|
31
|
+
expect(() => verifySourceCodeLimit(invalidSourceCode)).toThrow('Token limit exceeded: 260001 > 100000');
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
});
|
|
@@ -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,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEvG,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACvC,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;YACzC,MAAM,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACvD,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,
|
|
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,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEvG,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACvC,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,GAA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,CAAC,OAAO,EAAE,CAAC;QACrE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAC1D,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC9C,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAC,uCAAuC,CAAC,CAAC;QAC1G,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -7,16 +7,13 @@ import { importantContext } from '../main/config.js';
|
|
|
7
7
|
/** Get codegen prompt */
|
|
8
8
|
export function getCodeGenPrompt(options) {
|
|
9
9
|
let { explicitPrompt } = options;
|
|
10
|
-
const { taskFile, considerAllFiles, allowFileCreate, allowFileDelete, allowDirectoryCreate, allowFileMove, vision, imagen, dependencyTree, verbose, askQuestion, interactive, } = options;
|
|
10
|
+
const { taskFile, considerAllFiles, allowFileCreate, allowFileDelete, allowDirectoryCreate, allowFileMove, vision, imagen, dependencyTree, verbose, askQuestion, interactive, ui, } = options;
|
|
11
11
|
assert(!explicitPrompt || !taskFile, 'Both taskFile and explicitPrompt are not allowed');
|
|
12
12
|
if (taskFile) {
|
|
13
13
|
explicitPrompt = `I want you to perform a coding task. The task is described in the ${taskFile} file. Use those instructions.`;
|
|
14
14
|
}
|
|
15
|
-
let codeGenFiles;
|
|
16
|
-
if (considerAllFiles) {
|
|
17
|
-
codeGenFiles = Object.keys(getSourceCode({ taskFile, forceAll: true }, options));
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
15
|
+
let codeGenFiles = [];
|
|
16
|
+
if (!considerAllFiles) {
|
|
20
17
|
codeGenFiles = Object.entries(getSourceCode({ taskFile, forceAll: true }, options))
|
|
21
18
|
.filter(([, { content }]) => content?.match(new RegExp(`([^'^\`]+)${CODEGEN_TRIGGER}`)))
|
|
22
19
|
.map(([path]) => path);
|
|
@@ -32,28 +29,46 @@ export function getCodeGenPrompt(options) {
|
|
|
32
29
|
codeGenFiles = Array.from(dependencyTreeFiles);
|
|
33
30
|
}
|
|
34
31
|
const importantTextPrompts = importantContext.textPrompts?.map((prompt) => prompt.content).join('\n\n') || '';
|
|
35
|
-
const requestPermissionText = askQuestion && interactive ? ' (request permission via `askQuestion`)' : '';
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
const requestPermissionText = askQuestion && (interactive || ui) ? ' (request permission via `askQuestion`)' : '';
|
|
33
|
+
const taskPrompt = explicitPrompt
|
|
34
|
+
? 'This is your task: ' + explicitPrompt + '\n\n'
|
|
35
|
+
: codeGenFiles.length > 0
|
|
36
|
+
? `I have marked some files with the ${CODEGEN_TRIGGER} fragments:\n${codeGenFiles.join('\n')}\nYour task is to generate updates for those files according to the ${CODEGEN_TRIGGER} comments/context.`
|
|
37
|
+
: `No files are marked with ${CODEGEN_TRIGGER} fragment, so you can consider doing changes in any file${askQuestion ? ', but you should consult me by asking a question first.' : ''}.`;
|
|
38
|
+
const codeGenPrompt = `${taskPrompt}
|
|
39
|
+
|
|
40
|
+
Before proceeding with code generation, please summarize the proposed updates by calling the \`codegenSummary\` function with the appropriate arguments.
|
|
41
|
+
|
|
42
|
+
Ensure that you include:
|
|
43
|
+
|
|
44
|
+
- **\`explanation\`**: A brief description of the planned changes or reasoning for no changes.
|
|
45
|
+
|
|
46
|
+
- **\`fileUpdates\`**: A list of proposed file updates, each with required properties:
|
|
47
|
+
- **\`path\`**: Absolute file path to be updated.
|
|
48
|
+
- **\`updateToolName\`**: The tool to be used for the update (e.g., \`createFile\`, \`updateFile\`).
|
|
49
|
+
- **\`prompt\`**: A detailed prompt summarizing the planned changes for this file.
|
|
50
|
+
- **Other Properties**: Include any other necessary properties as per the \`codegenSummary\` function definition.
|
|
51
|
+
|
|
52
|
+
- **\`contextPaths\`**: A list of file paths that should be used as context for the code generation requests.
|
|
53
|
+
|
|
54
|
+
## My Requirements for Task Execution:
|
|
55
|
+
|
|
45
56
|
${importantTextPrompts ? `${importantTextPrompts}\n` : ''}
|
|
46
57
|
${considerAllFiles
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
? 'You are allowed to modify all files in the application regardless if they contain codegen fragments or not.'
|
|
59
|
+
: 'Do not modify files which do not contain the fragments.'}
|
|
49
60
|
${allowFileCreate ? 'You are allowed to create new files.' : 'Do not create new files. (request permission via `askQuestion`)'}
|
|
50
61
|
${allowFileDelete
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
${allowDirectoryCreate
|
|
62
|
+
? 'You are allowed to delete files; in such cases, add an empty string as content.'
|
|
63
|
+
: 'Do not delete files. (request permission via `askQuestion`)'}
|
|
64
|
+
${allowDirectoryCreate
|
|
65
|
+
? 'You are allowed to create new directories.'
|
|
66
|
+
: `Do not create new directories.${requestPermissionText}`}
|
|
54
67
|
${allowFileMove ? 'You are allowed to move files.' : 'Do not move files. (request permission via `askQuestion`)'}
|
|
55
68
|
${vision ? 'You are allowed to analyze image assets.' : 'Do not analyze image assets. (request permission via `askQuestion`)'}
|
|
56
|
-
${imagen
|
|
69
|
+
${imagen
|
|
70
|
+
? 'You are allowed to generate images.'
|
|
71
|
+
: 'You are not allowed to generate images. (request permission via `askQuestion`)'}
|
|
57
72
|
`;
|
|
58
73
|
if (verbose) {
|
|
59
74
|
console.log('Code gen prompt:');
|
|
@@ -78,7 +93,7 @@ Lint command stderr:
|
|
|
78
93
|
\`\`\`
|
|
79
94
|
${stderr}
|
|
80
95
|
\`\`\`
|
|
81
|
-
|
|
96
|
+
|
|
82
97
|
Please suggest changes to fix these lint errors.`;
|
|
83
98
|
if (verbose) {
|
|
84
99
|
console.log('Lint fix prompt:');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-codegen.js","sourceRoot":"","sources":["../../src/prompt/prompt-codegen.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAYrD,yBAAyB;AACzB,MAAM,UAAU,gBAAgB,CAAC,OAAuB;IACtD,IAAI,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IACjC,MAAM,EACJ,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,MAAM,EACN,MAAM,EACN,cAAc,EACd,OAAO,EACP,WAAW,EACX,WAAW,
|
|
1
|
+
{"version":3,"file":"prompt-codegen.js","sourceRoot":"","sources":["../../src/prompt/prompt-codegen.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAYrD,yBAAyB;AACzB,MAAM,UAAU,gBAAgB,CAAC,OAAuB;IACtD,IAAI,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IACjC,MAAM,EACJ,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,MAAM,EACN,MAAM,EACN,cAAc,EACd,OAAO,EACP,WAAW,EACX,WAAW,EACX,EAAE,GACH,GAAG,OAAO,CAA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