genaicode 0.0.35 → 0.1.1
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 +3 -0
- package/bin/genaicode-dev.js +11 -0
- package/bin/genaicode.cjs +8 -1
- package/dist/ai-service/ai-studio.d.ts +5 -0
- package/dist/ai-service/ai-studio.js +135 -0
- package/dist/ai-service/ai-studio.js.map +1 -0
- package/dist/ai-service/anthropic.d.ts +5 -0
- package/dist/ai-service/anthropic.js +133 -0
- package/dist/ai-service/anthropic.js.map +1 -0
- package/dist/ai-service/chat-gpt.d.ts +5 -0
- package/dist/ai-service/chat-gpt.js +131 -0
- package/dist/ai-service/chat-gpt.js.map +1 -0
- package/dist/ai-service/common.d.ts +57 -0
- package/dist/ai-service/common.js +38 -0
- package/dist/ai-service/common.js.map +1 -0
- package/dist/ai-service/common.test.d.ts +1 -0
- package/dist/ai-service/common.test.js +85 -0
- package/dist/ai-service/common.test.js.map +1 -0
- package/dist/ai-service/dall-e.d.ts +14 -0
- package/dist/ai-service/dall-e.js +47 -0
- package/dist/ai-service/dall-e.js.map +1 -0
- package/dist/ai-service/vertex-ai-claude.d.ts +5 -0
- package/dist/ai-service/vertex-ai-claude.js +93 -0
- package/dist/ai-service/vertex-ai-claude.js.map +1 -0
- package/dist/ai-service/vertex-ai-imagen.d.ts +14 -0
- package/dist/ai-service/vertex-ai-imagen.js +74 -0
- package/dist/ai-service/vertex-ai-imagen.js.map +1 -0
- package/dist/ai-service/vertex-ai.d.ts +7 -0
- package/dist/ai-service/vertex-ai.js +147 -0
- package/dist/ai-service/vertex-ai.js.map +1 -0
- package/dist/cli/cli-options.d.ts +10 -0
- package/dist/cli/cli-options.js +124 -0
- package/dist/cli/cli-options.js.map +1 -0
- package/dist/cli/cli-options.test.d.ts +1 -0
- package/dist/cli/cli-options.test.js +34 -0
- package/dist/cli/cli-options.test.js.map +1 -0
- package/dist/cli/cli-params.d.ts +29 -0
- package/dist/cli/cli-params.js +103 -0
- package/dist/cli/cli-params.js.map +1 -0
- package/dist/cli/cli-params.test.d.ts +1 -0
- package/dist/cli/cli-params.test.js +38 -0
- package/dist/cli/cli-params.test.js.map +1 -0
- package/dist/cli/service-autodetect.d.ts +2 -0
- package/dist/cli/service-autodetect.js +17 -0
- package/dist/cli/service-autodetect.js.map +1 -0
- package/dist/cli/service-autodetect.test.d.ts +1 -0
- package/dist/cli/service-autodetect.test.js +38 -0
- package/dist/cli/service-autodetect.test.js.map +1 -0
- package/dist/cli/validate-cli-params.d.ts +18 -0
- package/dist/cli/validate-cli-params.js +128 -0
- package/dist/cli/validate-cli-params.js.map +1 -0
- package/dist/cli/validate-cli-params.test.d.ts +1 -0
- package/dist/cli/validate-cli-params.test.js +106 -0
- package/dist/cli/validate-cli-params.test.js.map +1 -0
- package/dist/files/file-utils.d.ts +2 -0
- package/dist/files/file-utils.js +7 -0
- package/dist/files/file-utils.js.map +1 -0
- package/dist/files/file-utils.test.d.ts +1 -0
- package/dist/files/file-utils.test.js +18 -0
- package/dist/files/file-utils.test.js.map +1 -0
- package/dist/files/find-files.d.ts +8 -0
- package/dist/files/find-files.js +76 -0
- package/dist/files/find-files.js.map +1 -0
- package/dist/files/read-files.d.ts +13 -0
- package/dist/files/read-files.js +61 -0
- package/dist/files/read-files.js.map +1 -0
- package/dist/files/read-files.test.d.ts +1 -0
- package/dist/files/read-files.test.js +89 -0
- package/dist/files/read-files.test.js.map +1 -0
- package/dist/files/temp-buffer.d.ts +2 -0
- package/dist/files/temp-buffer.js +12 -0
- package/dist/files/temp-buffer.js.map +1 -0
- package/dist/files/update-files.d.ts +5 -0
- package/dist/files/update-files.js +197 -0
- package/dist/files/update-files.js.map +1 -0
- package/dist/images/ensure-alpha.d.ts +1 -0
- package/dist/images/ensure-alpha.js +5 -0
- package/dist/images/ensure-alpha.js.map +1 -0
- package/dist/images/imgly-remove-background.d.ts +2 -0
- package/dist/images/imgly-remove-background.js +21 -0
- package/dist/images/imgly-remove-background.js.map +1 -0
- package/dist/images/resize-image.d.ts +19 -0
- package/dist/images/resize-image.js +22 -0
- package/dist/images/resize-image.js.map +1 -0
- package/dist/images/split-image.d.ts +18 -0
- package/dist/images/split-image.js +25 -0
- package/dist/images/split-image.js.map +1 -0
- package/dist/main/codegen.d.ts +2 -0
- package/dist/main/codegen.js +101 -0
- package/dist/main/codegen.js.map +1 -0
- package/dist/main/codegen.test.d.ts +2 -0
- package/dist/main/codegen.test.js +259 -0
- package/dist/main/codegen.test.js.map +1 -0
- package/dist/main/config-lib.d.ts +8 -0
- package/dist/main/config-lib.js +28 -0
- package/dist/main/config-lib.js.map +1 -0
- package/dist/main/config-lib.test.d.ts +1 -0
- package/dist/main/config-lib.test.js +64 -0
- package/dist/main/config-lib.test.js.map +1 -0
- package/dist/main/config.d.ts +5 -0
- package/{src → dist}/main/config.js +16 -22
- package/dist/main/config.js.map +1 -0
- package/dist/prompt/function-calling-validate.d.ts +3 -0
- package/dist/prompt/function-calling-validate.js +27 -0
- package/dist/prompt/function-calling-validate.js.map +1 -0
- package/dist/prompt/function-calling.d.ts +5 -0
- package/dist/prompt/function-calling.js +48 -0
- package/dist/prompt/function-calling.js.map +1 -0
- package/dist/prompt/function-defs/ask-question.d.ts +31 -0
- package/dist/prompt/function-defs/ask-question.js +32 -0
- package/dist/prompt/function-defs/ask-question.js.map +1 -0
- package/dist/prompt/function-defs/codegen-summary.d.ts +63 -0
- package/dist/prompt/function-defs/codegen-summary.js +80 -0
- package/dist/prompt/function-defs/codegen-summary.js.map +1 -0
- package/dist/prompt/function-defs/create-directory.d.ts +21 -0
- package/dist/prompt/function-defs/create-directory.js +22 -0
- package/dist/prompt/function-defs/create-directory.js.map +1 -0
- package/dist/prompt/function-defs/create-file.d.ts +25 -0
- package/dist/prompt/function-defs/create-file.js +26 -0
- package/dist/prompt/function-defs/create-file.js.map +1 -0
- package/dist/prompt/function-defs/delete-file.d.ts +21 -0
- package/dist/prompt/function-defs/delete-file.js +22 -0
- package/dist/prompt/function-defs/delete-file.js.map +1 -0
- package/dist/prompt/function-defs/download-file.d.ts +25 -0
- package/dist/prompt/function-defs/download-file.js +26 -0
- package/dist/prompt/function-defs/download-file.js.map +1 -0
- package/dist/prompt/function-defs/explanation.d.ts +17 -0
- package/dist/prompt/function-defs/explanation.js +18 -0
- package/dist/prompt/function-defs/explanation.js.map +1 -0
- package/dist/prompt/function-defs/generate-image.d.ts +48 -0
- package/dist/prompt/function-defs/generate-image.js +49 -0
- package/dist/prompt/function-defs/generate-image.js.map +1 -0
- package/dist/prompt/function-defs/get-image-assets.d.ts +20 -0
- package/dist/prompt/function-defs/get-image-assets.js +21 -0
- package/dist/prompt/function-defs/get-image-assets.js.map +1 -0
- package/dist/prompt/function-defs/get-source-code.d.ts +20 -0
- package/dist/prompt/function-defs/get-source-code.js +21 -0
- package/dist/prompt/function-defs/get-source-code.js.map +1 -0
- package/dist/prompt/function-defs/imgly-remove-background.d.ts +25 -0
- package/dist/prompt/function-defs/imgly-remove-background.js +26 -0
- package/dist/prompt/function-defs/imgly-remove-background.js.map +1 -0
- package/dist/prompt/function-defs/move-file.d.ts +25 -0
- package/dist/prompt/function-defs/move-file.js +26 -0
- package/dist/prompt/function-defs/move-file.js.map +1 -0
- package/dist/prompt/function-defs/patch-file.d.ts +25 -0
- package/dist/prompt/function-defs/patch-file.js +39 -0
- package/dist/prompt/function-defs/patch-file.js.map +1 -0
- package/dist/prompt/function-defs/resize-image.d.ts +36 -0
- package/dist/prompt/function-defs/resize-image.js +37 -0
- package/dist/prompt/function-defs/resize-image.js.map +1 -0
- package/dist/prompt/function-defs/split-image.d.ts +57 -0
- package/dist/prompt/function-defs/split-image.js +46 -0
- package/dist/prompt/function-defs/split-image.js.map +1 -0
- package/dist/prompt/function-defs/update-file.d.ts +25 -0
- package/dist/prompt/function-defs/update-file.js +26 -0
- package/dist/prompt/function-defs/update-file.js.map +1 -0
- package/dist/prompt/limits.d.ts +3 -0
- package/dist/prompt/limits.js +19 -0
- package/dist/prompt/limits.js.map +1 -0
- package/dist/prompt/limits.test.d.ts +1 -0
- package/dist/prompt/limits.test.js +35 -0
- package/dist/prompt/limits.test.js.map +1 -0
- package/dist/prompt/prompt-codegen.d.ts +4 -0
- package/dist/prompt/prompt-codegen.js +81 -0
- package/dist/prompt/prompt-codegen.js.map +1 -0
- package/dist/prompt/prompt-codegen.test.d.ts +1 -0
- package/dist/prompt/prompt-codegen.test.js +94 -0
- package/dist/prompt/prompt-codegen.test.js.map +1 -0
- package/dist/prompt/prompt-consts.d.ts +1 -0
- package/{src → dist}/prompt/prompt-consts.js +1 -0
- package/dist/prompt/prompt-consts.js.map +1 -0
- package/dist/prompt/prompt-service-ask-question.test.d.ts +3 -0
- package/dist/prompt/prompt-service-ask-question.test.js +146 -0
- package/dist/prompt/prompt-service-ask-question.test.js.map +1 -0
- package/dist/prompt/prompt-service.d.ts +13 -0
- package/dist/prompt/prompt-service.js +278 -0
- package/dist/prompt/prompt-service.js.map +1 -0
- package/dist/prompt/prompt-service.test.d.ts +1 -0
- package/dist/prompt/prompt-service.test.js +511 -0
- package/dist/prompt/prompt-service.test.js.map +1 -0
- package/dist/prompt/systemprompt.d.ts +2 -0
- package/dist/prompt/systemprompt.js +43 -0
- package/dist/prompt/systemprompt.js.map +1 -0
- package/dist/prompt/systemprompt.test.d.ts +2 -0
- package/dist/prompt/systemprompt.test.js +47 -0
- package/dist/prompt/systemprompt.test.js.map +1 -0
- package/package.json +15 -5
- package/bin/genaicode.js +0 -5
- package/src/ai-service/anthropic.js +0 -95
- package/src/ai-service/chat-gpt.js +0 -99
- package/src/ai-service/common.js +0 -40
- package/src/ai-service/common.test.js +0 -107
- package/src/ai-service/dall-e.js +0 -50
- package/src/ai-service/vertex-ai-claude.js +0 -99
- package/src/ai-service/vertex-ai-imagen.js +0 -78
- package/src/ai-service/vertex-ai.js +0 -156
- package/src/cli/cli-options.js +0 -120
- package/src/cli/cli-options.test.js +0 -50
- package/src/cli/cli-params.js +0 -99
- package/src/cli/cli-params.test.js +0 -43
- package/src/cli/service-autodetect.js +0 -11
- package/src/cli/service-autodetect.test.js +0 -43
- package/src/cli/validate-cli-params.js +0 -117
- package/src/cli/validate-cli-params.test.js +0 -134
- package/src/files/file-utils.js +0 -7
- package/src/files/file-utils.test.js +0 -21
- package/src/files/find-files.js +0 -86
- package/src/files/read-files.js +0 -60
- package/src/files/read-files.test.js +0 -102
- package/src/files/temp-buffer.js +0 -13
- package/src/files/update-files.js +0 -205
- package/src/images/ensure-alpha.js +0 -5
- package/src/images/imgly-remove-background.js +0 -23
- package/src/images/resize-image.js +0 -23
- package/src/images/split-image.js +0 -26
- package/src/main/codegen.js +0 -120
- package/src/main/codegen.test.js +0 -334
- package/src/main/config-lib.js +0 -33
- package/src/main/config-lib.test.js +0 -80
- package/src/prompt/function-calling-validate.js +0 -25
- package/src/prompt/function-calling.js +0 -454
- package/src/prompt/limits.js +0 -23
- package/src/prompt/limits.test.js +0 -40
- package/src/prompt/prompt-codegen.js +0 -106
- package/src/prompt/prompt-codegen.test.js +0 -116
- package/src/prompt/prompt-service.js +0 -287
- package/src/prompt/prompt-service.test.js +0 -601
- package/src/prompt/systemprompt.js +0 -32
- package/src/prompt/systemprompt.test.js +0 -63
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for imglyRemoveBackground
|
|
3
|
+
*/
|
|
4
|
+
export const imglyRemoveBackground = {
|
|
5
|
+
name: 'imglyRemoveBackground',
|
|
6
|
+
description: 'Removes background from an image using @imgly/background-removal-node',
|
|
7
|
+
parameters: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
inputFilePath: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The file path of the input image.',
|
|
13
|
+
},
|
|
14
|
+
outputFilePath: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'The file path to save the output image with removed background.',
|
|
17
|
+
},
|
|
18
|
+
explanation: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'The explanation of the reasoning behind removing the background from this image',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
required: ['inputFilePath', 'outputFilePath'],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=imgly-remove-background.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imgly-remove-background.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/imgly-remove-background.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,uEAAuE;IACpF,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,aAAa,EAAE;gBACb,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mCAAmC;aACjD;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iEAAiE;aAC/E;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iFAAiF;aAC/F;SACF;QACD,QAAQ,EAAE,CAAC,eAAe,EAAE,gBAAgB,CAAC;KAC9C;CACO,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for moveFile
|
|
3
|
+
*/
|
|
4
|
+
export declare const moveFile: {
|
|
5
|
+
readonly name: "moveFile";
|
|
6
|
+
readonly description: "Move a file from one location to another";
|
|
7
|
+
readonly parameters: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly source: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "The current file path.";
|
|
13
|
+
};
|
|
14
|
+
readonly destination: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly description: "The new file path.";
|
|
17
|
+
};
|
|
18
|
+
readonly explanation: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: "The explanation of the reasoning behind moving this file";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly required: readonly ["source", "destination"];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for moveFile
|
|
3
|
+
*/
|
|
4
|
+
export const moveFile = {
|
|
5
|
+
name: 'moveFile',
|
|
6
|
+
description: 'Move a file from one location to another',
|
|
7
|
+
parameters: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
source: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The current file path.',
|
|
13
|
+
},
|
|
14
|
+
destination: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'The new file path.',
|
|
17
|
+
},
|
|
18
|
+
explanation: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'The explanation of the reasoning behind moving this file',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
required: ['source', 'destination'],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=move-file.js.map
|
|
@@ -0,0 +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,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wBAAwB;aACtC;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oBAAoB;aAClC;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0DAA0D;aACxE;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;KACpC;CACO,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for patchFile
|
|
3
|
+
*/
|
|
4
|
+
export declare const patchFile: {
|
|
5
|
+
readonly name: "patchFile";
|
|
6
|
+
readonly description: "Partially update a file content. The file must already exists in the application source code. The function should be called only if there is a need to actually change something.";
|
|
7
|
+
readonly parameters: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly filePath: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "The file path to patch.";
|
|
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
|
+
readonly explanation: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: "The explanation of the reasoning behind the suggested code changes for this file";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly required: readonly ["filePath", "patch"];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for patchFile
|
|
3
|
+
*/
|
|
4
|
+
export const patchFile = {
|
|
5
|
+
name: 'patchFile',
|
|
6
|
+
description: 'Partially update a file content. The file must already exists in the application source code. The function should be called only if there is a need to actually change something.',
|
|
7
|
+
parameters: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
filePath: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The file path to patch.',
|
|
13
|
+
},
|
|
14
|
+
patch: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: `Modification to the file expressed in patch format. Example patch:
|
|
17
|
+
|
|
18
|
+
\`\`\`
|
|
19
|
+
Index: filename.js
|
|
20
|
+
===================================================================
|
|
21
|
+
--- filename.js
|
|
22
|
+
+++ filename.js
|
|
23
|
+
@@ -1,2 +1,3 @@
|
|
24
|
+
line1
|
|
25
|
+
+line3
|
|
26
|
+
line2
|
|
27
|
+
\
|
|
28
|
+
\`\`\`
|
|
29
|
+
`,
|
|
30
|
+
},
|
|
31
|
+
explanation: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'The explanation of the reasoning behind the suggested code changes for this file',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
required: ['filePath', 'patch'],
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=patch-file.js.map
|
|
@@ -0,0 +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,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;;;;;;;;;;;;;WAaV;aACJ;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kFAAkF;aAChG;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC;KAChC;CACO,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for resizeImage
|
|
3
|
+
*/
|
|
4
|
+
export declare const resizeImage: {
|
|
5
|
+
readonly name: "resizeImage";
|
|
6
|
+
readonly description: "Resize image to the desired size";
|
|
7
|
+
readonly parameters: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly filePath: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "The file path of the image.";
|
|
13
|
+
};
|
|
14
|
+
readonly size: {
|
|
15
|
+
readonly type: "object";
|
|
16
|
+
readonly properties: {
|
|
17
|
+
readonly width: {
|
|
18
|
+
readonly type: "number";
|
|
19
|
+
readonly description: "width of the image";
|
|
20
|
+
};
|
|
21
|
+
readonly height: {
|
|
22
|
+
readonly type: "number";
|
|
23
|
+
readonly description: "height of the image";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
readonly required: readonly ["width", "height"];
|
|
27
|
+
readonly description: "The size of the image to generate.";
|
|
28
|
+
};
|
|
29
|
+
readonly explanation: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly description: "The explanation of the reasoning behind removing the background from this image";
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly required: readonly ["filePath", "size"];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for resizeImage
|
|
3
|
+
*/
|
|
4
|
+
export const resizeImage = {
|
|
5
|
+
name: 'resizeImage',
|
|
6
|
+
description: 'Resize image to the desired size',
|
|
7
|
+
parameters: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
filePath: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The file path of the image.',
|
|
13
|
+
},
|
|
14
|
+
size: {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
width: {
|
|
18
|
+
type: 'number',
|
|
19
|
+
description: 'width of the image',
|
|
20
|
+
},
|
|
21
|
+
height: {
|
|
22
|
+
type: 'number',
|
|
23
|
+
description: 'height of the image',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
required: ['width', 'height'],
|
|
27
|
+
description: 'The size of the image to generate.',
|
|
28
|
+
},
|
|
29
|
+
explanation: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'The explanation of the reasoning behind removing the background from this image',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
required: ['filePath', 'size'],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=resize-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resize-image.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/resize-image.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,kCAAkC;IAC/C,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6BAA6B;aAC3C;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,oBAAoB;qBAClC;oBACD,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,qBAAqB;qBACnC;iBACF;gBACD,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;gBAC7B,WAAW,EAAE,oCAAoC;aAClD;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iFAAiF;aAC/F;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC;KAC/B;CACO,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for splitImage
|
|
3
|
+
*/
|
|
4
|
+
export declare const splitImage: {
|
|
5
|
+
readonly name: "splitImage";
|
|
6
|
+
readonly description: "Split an image into multiple parts and save them as separate files.";
|
|
7
|
+
readonly parameters: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly inputFilePath: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "The file path of the input image to be split.";
|
|
13
|
+
};
|
|
14
|
+
readonly parts: {
|
|
15
|
+
readonly type: "array";
|
|
16
|
+
readonly items: {
|
|
17
|
+
readonly type: "object";
|
|
18
|
+
readonly properties: {
|
|
19
|
+
readonly rect: {
|
|
20
|
+
readonly type: "object";
|
|
21
|
+
readonly properties: {
|
|
22
|
+
readonly x: {
|
|
23
|
+
readonly type: "number";
|
|
24
|
+
readonly description: "The x-coordinate of the top-left corner of the rectangle.";
|
|
25
|
+
};
|
|
26
|
+
readonly y: {
|
|
27
|
+
readonly type: "number";
|
|
28
|
+
readonly description: "The y-coordinate of the top-left corner of the rectangle.";
|
|
29
|
+
};
|
|
30
|
+
readonly width: {
|
|
31
|
+
readonly type: "number";
|
|
32
|
+
readonly description: "The width of the rectangle.";
|
|
33
|
+
};
|
|
34
|
+
readonly height: {
|
|
35
|
+
readonly type: "number";
|
|
36
|
+
readonly description: "The height of the rectangle.";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
readonly required: readonly ["x", "y", "width", "height"];
|
|
40
|
+
};
|
|
41
|
+
readonly outputFilePath: {
|
|
42
|
+
readonly type: "string";
|
|
43
|
+
readonly description: "The file path to save the extracted part of the image.";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
readonly required: readonly ["rect", "outputFilePath"];
|
|
47
|
+
};
|
|
48
|
+
readonly description: "An array of parts to extract from the image, each with a rectangle and output file path.";
|
|
49
|
+
};
|
|
50
|
+
readonly explanation: {
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
readonly description: "The explanation of the reasoning behind splitting this image";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
readonly required: readonly ["inputFilePath", "parts"];
|
|
56
|
+
};
|
|
57
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for splitImage
|
|
3
|
+
*/
|
|
4
|
+
export const splitImage = {
|
|
5
|
+
name: 'splitImage',
|
|
6
|
+
description: 'Split an image into multiple parts and save them as separate files.',
|
|
7
|
+
parameters: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
inputFilePath: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The file path of the input image to be split.',
|
|
13
|
+
},
|
|
14
|
+
parts: {
|
|
15
|
+
type: 'array',
|
|
16
|
+
items: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
rect: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
x: { type: 'number', description: 'The x-coordinate of the top-left corner of the rectangle.' },
|
|
23
|
+
y: { type: 'number', description: 'The y-coordinate of the top-left corner of the rectangle.' },
|
|
24
|
+
width: { type: 'number', description: 'The width of the rectangle.' },
|
|
25
|
+
height: { type: 'number', description: 'The height of the rectangle.' },
|
|
26
|
+
},
|
|
27
|
+
required: ['x', 'y', 'width', 'height'],
|
|
28
|
+
},
|
|
29
|
+
outputFilePath: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'The file path to save the extracted part of the image.',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
required: ['rect', 'outputFilePath'],
|
|
35
|
+
},
|
|
36
|
+
description: 'An array of parts to extract from the image, each with a rectangle and output file path.',
|
|
37
|
+
},
|
|
38
|
+
explanation: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'The explanation of the reasoning behind splitting this image',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
required: ['inputFilePath', 'parts'],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=split-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-image.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/split-image.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,qEAAqE;IAClF,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,aAAa,EAAE;gBACb,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+CAA+C;aAC7D;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE;4BACJ,IAAI,EAAE,QAAQ;4BACd,UAAU,EAAE;gCACV,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2DAA2D,EAAE;gCAC/F,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2DAA2D,EAAE;gCAC/F,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6BAA6B,EAAE;gCACrE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8BAA8B,EAAE;6BACxE;4BACD,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC;yBACxC;wBACD,cAAc,EAAE;4BACd,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,wDAAwD;yBACtE;qBACF;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC;iBACrC;gBACD,WAAW,EAAE,0FAA0F;aACxG;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8DAA8D;aAC5E;SACF;QACD,QAAQ,EAAE,CAAC,eAAe,EAAE,OAAO,CAAC;KACrC;CACO,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for updateFile
|
|
3
|
+
*/
|
|
4
|
+
export declare const updateFile: {
|
|
5
|
+
readonly name: "updateFile";
|
|
6
|
+
readonly description: "Update a file with new content. The file must already exists in the application source code. The function should be called only if there is a need to actually change something.";
|
|
7
|
+
readonly parameters: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly filePath: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "The file path to update.";
|
|
13
|
+
};
|
|
14
|
+
readonly newContent: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly description: "The content to update the file with. Must not be empty.";
|
|
17
|
+
};
|
|
18
|
+
readonly explanation: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: "The explanation of the reasoning behind the suggested code changes for this file";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly required: readonly ["filePath", "newContent"];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function definition for updateFile
|
|
3
|
+
*/
|
|
4
|
+
export const updateFile = {
|
|
5
|
+
name: 'updateFile',
|
|
6
|
+
description: 'Update a file with new content. The file must already exists in the application source code. The function should be called only if there is a need to actually change something.',
|
|
7
|
+
parameters: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
filePath: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The file path to update.',
|
|
13
|
+
},
|
|
14
|
+
newContent: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'The content to update the file with. Must not be empty.',
|
|
17
|
+
},
|
|
18
|
+
explanation: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'The explanation of the reasoning behind the suggested code changes for this file',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
required: ['filePath', 'newContent'],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=update-file.js.map
|
|
@@ -0,0 +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,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yDAAyD;aACvE;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kFAAkF;aAChG;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;KACrC;CACO,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
const SYSTEM_PROMPT_LIMIT = 300;
|
|
3
|
+
const CODEGEN_PROMPT_LIMIT = 500;
|
|
4
|
+
const SOURCE_CODE_LIMIT = 20000;
|
|
5
|
+
function verifyPromptLimit(promptType, prompt, limit) {
|
|
6
|
+
const tokenCount = prompt.split(/\s+/).length;
|
|
7
|
+
console.log(`${promptType} prompt token count: ${tokenCount}`);
|
|
8
|
+
assert(tokenCount <= limit, `Token limit exceeded: ${tokenCount} > ${limit}`);
|
|
9
|
+
}
|
|
10
|
+
export function verifySystemPromptLimit(systemPrompt) {
|
|
11
|
+
verifyPromptLimit('system', systemPrompt, SYSTEM_PROMPT_LIMIT);
|
|
12
|
+
}
|
|
13
|
+
export function verifyCodegenPromptLimit(codeGenPrompt) {
|
|
14
|
+
verifyPromptLimit('codegen', codeGenPrompt, CODEGEN_PROMPT_LIMIT);
|
|
15
|
+
}
|
|
16
|
+
export function verifySourceCodeLimit(sourceCode) {
|
|
17
|
+
verifyPromptLimit('sourceCode', sourceCode, SOURCE_CODE_LIMIT);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/prompt/limits.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC,SAAS,iBAAiB,CAAC,UAAkB,EAAE,MAAc,EAAE,KAAa;IAC1E,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,wBAAwB,UAAU,EAAE,CAAC,CAAC;IAC/D,MAAM,CAAC,UAAU,IAAI,KAAK,EAAE,yBAAyB,UAAU,MAAM,KAAK,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,YAAoB;IAC1D,iBAAiB,CAAC,QAAQ,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,aAAqB;IAC5D,iBAAiB,CAAC,SAAS,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,UAAkB;IACtD,iBAAiB,CAAC,YAAY,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { verifySystemPromptLimit, verifyCodegenPromptLimit, verifySourceCodeLimit } from './limits.js';
|
|
3
|
+
describe('Prompt Limits', () => {
|
|
4
|
+
describe('verifySystemPromptLimit', () => {
|
|
5
|
+
it('should not throw for a prompt within the limit', () => {
|
|
6
|
+
const validPrompt = 'A '.repeat(200 - 1);
|
|
7
|
+
expect(() => verifySystemPromptLimit(validPrompt)).not.toThrow();
|
|
8
|
+
});
|
|
9
|
+
it('should throw for a prompt exceeding the limit', () => {
|
|
10
|
+
const invalidPrompt = 'A '.repeat(301);
|
|
11
|
+
expect(() => verifySystemPromptLimit(invalidPrompt)).toThrow('Token limit exceeded: 302 > 300');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
describe('verifyCodegenPromptLimit', () => {
|
|
15
|
+
it('should not throw for a prompt within the limit', () => {
|
|
16
|
+
const validPrompt = 'B '.repeat(200 - 1);
|
|
17
|
+
expect(() => verifyCodegenPromptLimit(validPrompt)).not.toThrow();
|
|
18
|
+
});
|
|
19
|
+
it('should throw for a prompt exceeding the limit', () => {
|
|
20
|
+
const invalidPrompt = 'B '.repeat(501);
|
|
21
|
+
expect(() => verifyCodegenPromptLimit(invalidPrompt)).toThrow('Token limit exceeded: 502 > 500');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('verifySourceCodeLimit', () => {
|
|
25
|
+
it('should not throw for source code within the limit', () => {
|
|
26
|
+
const validSourceCode = 'C '.repeat(20000 - 1);
|
|
27
|
+
expect(() => verifySourceCodeLimit(validSourceCode)).not.toThrow();
|
|
28
|
+
});
|
|
29
|
+
it('should throw for source code exceeding the limit', () => {
|
|
30
|
+
const invalidSourceCode = 'C '.repeat(20001);
|
|
31
|
+
expect(() => verifySourceCodeLimit(invalidSourceCode)).toThrow('Token limit exceeded: 20002 > 20000');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=limits.test.js.map
|
|
@@ -0,0 +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,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,GAAG,EAAE;YAC3D,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YAC/C,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACrE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAC1D,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7C,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;QACxG,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { getSourceCode } from '../files/read-files.js';
|
|
3
|
+
import { CODEGEN_TRIGGER } from './prompt-consts.js';
|
|
4
|
+
import { considerAllFiles, allowFileCreate, allowFileDelete, allowDirectoryCreate, allowFileMove, explicitPrompt, dependencyTree, verbosePrompt, vision, imagen, } from '../cli/cli-params.js';
|
|
5
|
+
import { getDependencyList } from '../files/find-files.js';
|
|
6
|
+
import { verifyCodegenPromptLimit } from './limits.js';
|
|
7
|
+
/** Get codegen prompt */
|
|
8
|
+
export function getCodeGenPrompt() {
|
|
9
|
+
let codeGenFiles;
|
|
10
|
+
if (considerAllFiles) {
|
|
11
|
+
codeGenFiles = Object.keys(getSourceCode());
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
codeGenFiles = Object.entries(getSourceCode())
|
|
15
|
+
.filter(([, { content }]) => content?.match(new RegExp(`([^'^\`]+)${CODEGEN_TRIGGER}`)))
|
|
16
|
+
.map(([path]) => path);
|
|
17
|
+
}
|
|
18
|
+
// Add logic to consider dependency tree
|
|
19
|
+
if (dependencyTree) {
|
|
20
|
+
assert(codeGenFiles.length > 0, `You must use ${CODEGEN_TRIGGER} together with --dependency-tree`);
|
|
21
|
+
const dependencyTreeFiles = new Set();
|
|
22
|
+
codeGenFiles
|
|
23
|
+
.map(getDependencyList)
|
|
24
|
+
.flat()
|
|
25
|
+
.forEach((key) => dependencyTreeFiles.add(key));
|
|
26
|
+
codeGenFiles = Array.from(dependencyTreeFiles);
|
|
27
|
+
}
|
|
28
|
+
const codeGenPrompt = (explicitPrompt ? explicitPrompt + '\n\n' : '') +
|
|
29
|
+
`${considerAllFiles
|
|
30
|
+
? codeGenFiles.length > 0
|
|
31
|
+
? `I have marked some files with the ${CODEGEN_TRIGGER} fragments:\n${codeGenFiles.join('\n')}`
|
|
32
|
+
: `No files are marked with ${CODEGEN_TRIGGER} fragment, so you can consider doing changes in any file.`
|
|
33
|
+
: codeGenFiles.length > 0
|
|
34
|
+
? `Generate updates only for the following files:\n${codeGenFiles.join('\n')}`
|
|
35
|
+
: ''}
|
|
36
|
+
|
|
37
|
+
${considerAllFiles
|
|
38
|
+
? 'You are allowed to modify all files in the application regardless if they contain codegen fragments or not.'
|
|
39
|
+
: 'Do not modify files which do not contain the fragments.'}
|
|
40
|
+
${allowFileCreate ? 'You are allowed to create new files.' : 'Do not create new files.'}
|
|
41
|
+
${allowFileDelete
|
|
42
|
+
? 'You are allowed to delete files, in such case add empty string as content.'
|
|
43
|
+
: 'Do not delete files.'}
|
|
44
|
+
${allowDirectoryCreate ? 'You are allowed to create new directories.' : 'Do not create new directories.'}
|
|
45
|
+
${allowFileMove ? 'You are allowed to move files.' : 'Do not move files.'}
|
|
46
|
+
${vision ? 'You are allowed to analyze image assets.' : 'Do not analyze image assets.'}
|
|
47
|
+
${imagen ? 'You are allowed to generate images.' : 'You are not allowed to generate images.'}
|
|
48
|
+
`;
|
|
49
|
+
if (verbosePrompt) {
|
|
50
|
+
console.log('Code gen prompt:');
|
|
51
|
+
console.log(codeGenPrompt);
|
|
52
|
+
}
|
|
53
|
+
verifyCodegenPromptLimit(codeGenPrompt);
|
|
54
|
+
return codeGenPrompt;
|
|
55
|
+
}
|
|
56
|
+
/** Get lint fix prompt */
|
|
57
|
+
export function getLintFixPrompt(command, stdout, stderr) {
|
|
58
|
+
const lintFixPrompt = `The following lint errors were encountered after the initial code generation:
|
|
59
|
+
|
|
60
|
+
Lint command: ${command}
|
|
61
|
+
Lint command stdout:
|
|
62
|
+
|
|
63
|
+
\`\`\`
|
|
64
|
+
${stdout}
|
|
65
|
+
\`\`\`
|
|
66
|
+
|
|
67
|
+
Lint command stderr:
|
|
68
|
+
|
|
69
|
+
\`\`\`
|
|
70
|
+
${stderr}
|
|
71
|
+
\`\`\`
|
|
72
|
+
|
|
73
|
+
Please suggest changes to fix these lint errors.`;
|
|
74
|
+
if (verbosePrompt) {
|
|
75
|
+
console.log('Lint fix prompt:');
|
|
76
|
+
console.log(lintFixPrompt);
|
|
77
|
+
}
|
|
78
|
+
verifyCodegenPromptLimit(lintFixPrompt);
|
|
79
|
+
return lintFixPrompt;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=prompt-codegen.js.map
|
|
@@ -0,0 +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,EACL,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,cAAc,EACd,aAAa,EACb,MAAM,EACN,MAAM,GACP,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAMvD,yBAAyB;AACzB,MAAM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