genaicode 0.0.37 → 0.2.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 +3 -1
- package/bin/genaicode-dev.js +11 -0
- package/bin/genaicode.cjs +15 -1
- package/dist/ai-service/ai-studio.d.ts +6 -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 +6 -0
- package/dist/ai-service/anthropic.js +135 -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 +132 -0
- package/dist/ai-service/chat-gpt.js.map +1 -0
- package/dist/ai-service/common.d.ts +58 -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 +48 -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 +94 -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 +77 -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 +142 -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 +30 -0
- package/dist/cli/cli-params.js +109 -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 +129 -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 +18 -0
- package/dist/files/read-files.js +66 -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 +88 -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 +6 -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-interactive-utils.d.ts +8 -0
- package/dist/main/codegen-interactive-utils.js +148 -0
- package/dist/main/codegen-interactive-utils.js.map +1 -0
- package/dist/main/codegen-interactive.d.ts +2 -0
- package/dist/main/codegen-interactive.js +68 -0
- package/dist/main/codegen-interactive.js.map +1 -0
- package/dist/main/codegen-types.d.ts +28 -0
- package/dist/main/codegen-types.js +2 -0
- package/dist/main/codegen-types.js.map +1 -0
- package/dist/main/codegen.d.ts +4 -0
- package/dist/main/codegen.js +164 -0
- package/dist/main/codegen.js.map +1 -0
- package/dist/main/codegen.test.d.ts +2 -0
- package/dist/main/codegen.test.js +273 -0
- package/dist/main/codegen.test.js.map +1 -0
- package/dist/main/config-lib.d.ts +16 -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 +6 -0
- package/{src → dist}/main/config.js +28 -22
- package/dist/main/config.js.map +1 -0
- package/dist/main/interactive/codegen-interactive.d.ts +2 -0
- package/dist/main/interactive/codegen-interactive.js +55 -0
- package/dist/main/interactive/codegen-interactive.js.map +1 -0
- package/dist/main/interactive/codegen-interactive.test.d.ts +4 -0
- package/dist/main/interactive/codegen-interactive.test.js +77 -0
- package/dist/main/interactive/codegen-interactive.test.js.map +1 -0
- package/dist/main/interactive/codegen-worker.d.ts +3 -0
- package/dist/main/interactive/codegen-worker.js +47 -0
- package/dist/main/interactive/codegen-worker.js.map +1 -0
- package/dist/main/interactive/common.d.ts +5 -0
- package/dist/main/interactive/common.js +51 -0
- package/dist/main/interactive/common.js.map +1 -0
- package/dist/main/interactive/configure.d.ts +2 -0
- package/dist/main/interactive/configure.js +99 -0
- package/dist/main/interactive/configure.js.map +1 -0
- package/dist/main/interactive/error-handling.d.ts +4 -0
- package/dist/main/interactive/error-handling.js +49 -0
- package/dist/main/interactive/error-handling.js.map +1 -0
- package/dist/main/interactive/help.d.ts +1 -0
- package/dist/main/interactive/help.js +22 -0
- package/dist/main/interactive/help.js.map +1 -0
- package/dist/main/interactive/process-comments.d.ts +2 -0
- package/dist/main/interactive/process-comments.js +39 -0
- package/dist/main/interactive/process-comments.js.map +1 -0
- package/dist/main/interactive/select-ai-service.d.ts +2 -0
- package/dist/main/interactive/select-ai-service.js +27 -0
- package/dist/main/interactive/select-ai-service.js.map +1 -0
- package/dist/main/interactive/task-file.d.ts +2 -0
- package/dist/main/interactive/task-file.js +28 -0
- package/dist/main/interactive/task-file.js.map +1 -0
- package/dist/main/interactive/text-prompt.d.ts +2 -0
- package/dist/main/interactive/text-prompt.js +18 -0
- package/dist/main/interactive/text-prompt.js.map +1 -0
- package/dist/main/interactive/user-interrupt.d.ts +1 -0
- package/dist/main/interactive/user-interrupt.js +36 -0
- package/dist/main/interactive/user-interrupt.js.map +1 -0
- package/dist/main/interactive/worker-script.d.ts +1 -0
- package/dist/main/interactive/worker-script.js +24 -0
- package/dist/main/interactive/worker-script.js.map +1 -0
- package/dist/main/interactive/worker.d.ts +2 -0
- package/dist/main/interactive/worker.js +55 -0
- package/dist/main/interactive/worker.js.map +1 -0
- package/dist/prompt/function-calling-validate.d.ts +3 -0
- package/dist/prompt/function-calling-validate.js +33 -0
- package/dist/prompt/function-calling-validate.js.map +1 -0
- package/dist/prompt/function-calling.d.ts +5 -0
- package/{src → dist}/prompt/function-calling.js +25 -24
- package/dist/prompt/function-calling.js.map +1 -0
- package/dist/prompt/function-defs/ask-question.d.ts +65 -0
- package/dist/prompt/function-defs/ask-question.js +67 -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 +41 -0
- package/dist/prompt/function-defs/generate-image.js +42 -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 +9 -0
- package/dist/prompt/prompt-codegen.js +90 -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 +98 -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 +142 -0
- package/dist/prompt/prompt-service-ask-question.test.js.map +1 -0
- package/dist/prompt/prompt-service.d.ts +28 -0
- package/dist/prompt/prompt-service.js +163 -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 +531 -0
- package/dist/prompt/prompt-service.test.js.map +1 -0
- package/dist/prompt/steps/step-ask-question.d.ts +6 -0
- package/dist/prompt/steps/step-ask-question.js +82 -0
- package/dist/prompt/steps/step-ask-question.js.map +1 -0
- package/dist/prompt/steps/step-generate-image.d.ts +2 -0
- package/dist/prompt/steps/step-generate-image.js +29 -0
- package/dist/prompt/steps/step-generate-image.js.map +1 -0
- package/dist/prompt/steps/step-validate-recover.d.ts +13 -0
- package/dist/prompt/steps/step-validate-recover.js +51 -0
- package/dist/prompt/steps/step-validate-recover.js.map +1 -0
- package/dist/prompt/steps/step-verify-patch.d.ts +7 -0
- package/dist/prompt/steps/step-verify-patch.js +41 -0
- package/dist/prompt/steps/step-verify-patch.js.map +1 -0
- package/dist/prompt/steps/steps-types.d.ts +4 -0
- package/dist/prompt/steps/steps-types.js +6 -0
- package/dist/prompt/steps/steps-types.js.map +1 -0
- package/dist/prompt/systemprompt.d.ts +3 -0
- package/dist/prompt/systemprompt.js +47 -0
- package/dist/prompt/systemprompt.js.map +1 -0
- package/dist/prompt/systemprompt.test.d.ts +3 -0
- package/dist/prompt/systemprompt.test.js +46 -0
- package/dist/prompt/systemprompt.test.js.map +1 -0
- package/package.json +15 -5
- package/bin/genaicode.js +0 -5
- package/bin/vertex-monkey-patch.cjs +0 -33
- package/src/ai-service/anthropic.js +0 -126
- package/src/ai-service/chat-gpt.js +0 -126
- package/src/ai-service/common.js +0 -49
- 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 -132
- package/src/cli/cli-options.test.js +0 -50
- package/src/cli/cli-params.js +0 -114
- 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 -137
- 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 -65
- package/src/files/read-files.test.js +0 -103
- 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 -335
- 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-defs/ask-question.js +0 -33
- package/src/prompt/function-defs/codegen-summary.js +0 -87
- package/src/prompt/function-defs/create-directory.js +0 -21
- package/src/prompt/function-defs/create-file.js +0 -26
- package/src/prompt/function-defs/delete-file.js +0 -21
- package/src/prompt/function-defs/download-file.js +0 -25
- package/src/prompt/function-defs/explanation.js +0 -17
- package/src/prompt/function-defs/generate-image.js +0 -51
- package/src/prompt/function-defs/get-image-assets.js +0 -21
- package/src/prompt/function-defs/get-source-code.js +0 -21
- package/src/prompt/function-defs/imgly-remove-background.js +0 -25
- package/src/prompt/function-defs/move-file.js +0 -25
- package/src/prompt/function-defs/patch-file.js +0 -39
- package/src/prompt/function-defs/resize-image.js +0 -36
- package/src/prompt/function-defs/split-image.js +0 -45
- package/src/prompt/function-defs/update-file.js +0 -26
- 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-ask-question.test.js +0 -163
- package/src/prompt/prompt-service.js +0 -335
- package/src/prompt/prompt-service.test.js +0 -602
- package/src/prompt/systemprompt.js +0 -39
- package/src/prompt/systemprompt.test.js +0 -64
package/src/cli/cli-options.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// CLI options and their descriptions
|
|
2
|
-
const cliOptions = [
|
|
3
|
-
{
|
|
4
|
-
name: '--help',
|
|
5
|
-
description: 'Display this help message.',
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
name: '--dry-run',
|
|
9
|
-
description: 'Run the codegen script without updating the source code.',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
name: '--consider-all-files',
|
|
13
|
-
description: "Consider all files for code generation, even if they don't contain the @" + 'CODEGEN comments.',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
name: '--allow-file-create',
|
|
17
|
-
description: 'Allow the codegen script to create new files.',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: '--allow-file-delete',
|
|
21
|
-
description: 'Allow the codegen script to delete files.',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: '--allow-directory-create',
|
|
25
|
-
description: 'Allow codegen script to create directories.',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: '--allow-file-move',
|
|
29
|
-
description: 'Allow the codegen script to move files.',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: '--chat-gpt',
|
|
33
|
-
description: "Use the OpenAI model for code generation instead of Vertex AI with Google's Gemini Pro model.",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: '--anthropic',
|
|
37
|
-
description: "Use Anthropic's Claude model for code generation.",
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: '--vertex-ai',
|
|
41
|
-
description:
|
|
42
|
-
"Use Vertex AI with Google's Gemini Pro model for code generation (default if no AI model is specified).",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: '--vertex-ai-claude',
|
|
46
|
-
description: 'Use Claude via Vertex AI for code generation.',
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: '--explicit-prompt=<prompt>',
|
|
50
|
-
description: 'An explicit prompt to use for code generation.',
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: '--task-file=<file>',
|
|
54
|
-
description: 'Specifies a file with a task description for code generation.',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: '--dependency-tree',
|
|
58
|
-
description: 'Limit the scope of codegen only to files marked with @' + 'CODEGEN and their dependencies.',
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: '--verbose-prompt',
|
|
62
|
-
description: 'Print the prompt used for code generation.',
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: '--require-explanations',
|
|
66
|
-
description: 'Require explanations for all code generation operations.',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: '--disable-context-optimization',
|
|
70
|
-
description: 'Disable the optimization that uses context paths for more efficient code generation.',
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: '--gemini-block-none',
|
|
74
|
-
description: 'Disable safety settings for Gemini Pro model (requires whitelisted Cloud project).',
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: '--disable-initial-lint',
|
|
78
|
-
description: 'Skip the initial lint check before running the code generation process.',
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: '--temperature=<value>',
|
|
82
|
-
description: 'Set the temperature parameter for the AI model (default: 0.7).',
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
name: '--vision',
|
|
86
|
-
description:
|
|
87
|
-
'Enable vision capabilities for processing image inputs. This option allows the tool to analyze and generate code based on image content when used with compatible AI models.',
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: '--imagen=<service>',
|
|
91
|
-
description:
|
|
92
|
-
'Enable image generation functionality and specify the service to use (either "vertex-ai" or "dall-e").',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: '--cheap',
|
|
96
|
-
description: 'Switch to cheaper models in AI services for content and image generation.',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: '--content-mask=<path>',
|
|
100
|
-
description:
|
|
101
|
-
'Apply a content mask to limit the initial source code files included in the request. The value should be a prefix of the path relative to rootDir.',
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: '--ignore-pattern=<pattern>',
|
|
105
|
-
description: 'Specify a pattern of files to ignore during the initial source code fetching.',
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: '--disable-cache',
|
|
109
|
-
description: 'Disable caching for the application.',
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
name: '--ask-question',
|
|
113
|
-
description: 'Allows the AI assistant to ask questions for clarification during the code generation process.',
|
|
114
|
-
},
|
|
115
|
-
];
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Print the help message with all available CLI options
|
|
119
|
-
*/
|
|
120
|
-
export function printHelpMessage() {
|
|
121
|
-
console.log('GenAIcode - AI-powered code generation tool');
|
|
122
|
-
console.log('\nUsage: npx genaicode [options]');
|
|
123
|
-
console.log('\nOptions:');
|
|
124
|
-
|
|
125
|
-
cliOptions.forEach((option) => {
|
|
126
|
-
console.log(` ${option.name.padEnd(30)} ${option.description}`);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
console.log('\nFor more information, please refer to the project home page: https://github.com/gtanczyk/genaicode/');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export { cliOptions };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { printHelpMessage, cliOptions } from './cli-options.js';
|
|
3
|
-
|
|
4
|
-
describe('CLI Options', () => {
|
|
5
|
-
describe('printHelpMessage', () => {
|
|
6
|
-
it('should print the help message with all CLI options', () => {
|
|
7
|
-
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
8
|
-
|
|
9
|
-
printHelpMessage();
|
|
10
|
-
|
|
11
|
-
expect(consoleSpy).toHaveBeenCalledWith('GenAIcode - AI-powered code generation tool');
|
|
12
|
-
expect(consoleSpy).toHaveBeenCalledWith('\nUsage: npx genaicode [options]');
|
|
13
|
-
expect(consoleSpy).toHaveBeenCalledWith('\nOptions:');
|
|
14
|
-
|
|
15
|
-
cliOptions.forEach((option) => {
|
|
16
|
-
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining(option.name));
|
|
17
|
-
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining(option.description));
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('For more information'));
|
|
21
|
-
|
|
22
|
-
consoleSpy.mockRestore();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should include the --imagen option in the help message', () => {
|
|
26
|
-
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
27
|
-
|
|
28
|
-
printHelpMessage();
|
|
29
|
-
|
|
30
|
-
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('--imagen=<service>'));
|
|
31
|
-
expect(consoleSpy).toHaveBeenCalledWith(
|
|
32
|
-
expect.stringContaining(
|
|
33
|
-
'Enable image generation functionality and specify the service to use (either "vertex-ai" or "dall-e").',
|
|
34
|
-
),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
consoleSpy.mockRestore();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe('cliOptions', () => {
|
|
42
|
-
it('should include the --imagen option', () => {
|
|
43
|
-
const imagenOption = cliOptions.find((option) => option.name === '--imagen=<service>');
|
|
44
|
-
expect(imagenOption).toBeDefined();
|
|
45
|
-
expect(imagenOption.description).toBe(
|
|
46
|
-
'Enable image generation functionality and specify the service to use (either "vertex-ai" or "dall-e").',
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
package/src/cli/cli-params.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { serviceAutoDetect } from './service-autodetect.js';
|
|
4
|
-
import { rcConfig } from '../main/config.js';
|
|
5
|
-
|
|
6
|
-
const params = process.argv.slice(2);
|
|
7
|
-
|
|
8
|
-
export const dryRun = params.includes('--dry-run');
|
|
9
|
-
export const considerAllFiles = params.includes('--consider-all-files');
|
|
10
|
-
export const allowFileCreate = params.includes('--allow-file-create');
|
|
11
|
-
export const allowFileDelete = params.includes('--allow-file-delete');
|
|
12
|
-
export const allowDirectoryCreate = params.includes('--allow-directory-create');
|
|
13
|
-
export const allowFileMove = params.includes('--allow-file-move');
|
|
14
|
-
export let chatGpt = params.includes('--chat-gpt');
|
|
15
|
-
export let anthropic = params.includes('--anthropic');
|
|
16
|
-
export let vertexAi = params.includes('--vertex-ai');
|
|
17
|
-
export let vertexAiClaude = params.includes('--vertex-ai-claude');
|
|
18
|
-
export const dependencyTree = params.includes('--dependency-tree');
|
|
19
|
-
export const verbosePrompt = params.includes('--verbose-prompt');
|
|
20
|
-
export const disableCache = params.includes('--disable-cache');
|
|
21
|
-
export let explicitPrompt = params.find((param) => param.startsWith('--explicit-prompt'))?.split('=')[1];
|
|
22
|
-
export const disableContextOptimization = params.includes('--disable-context-optimization');
|
|
23
|
-
export let taskFile = params.find((param) => param.startsWith('--task-file'))?.split('=')[1];
|
|
24
|
-
export const requireExplanations = params.includes('--require-explanations');
|
|
25
|
-
export const geminiBlockNone = params.includes('--gemini-block-none');
|
|
26
|
-
export const disableInitialLint = params.includes('--disable-initial-lint');
|
|
27
|
-
export const vision = params.includes('--vision');
|
|
28
|
-
export const imagen = params.find((param) => param.startsWith('--imagen'))?.split('=')[1];
|
|
29
|
-
export const cheap = params.includes('--cheap');
|
|
30
|
-
export const askQuestion = params.includes('--ask-question');
|
|
31
|
-
|
|
32
|
-
// Add support for --help option
|
|
33
|
-
export const helpRequested = params.includes('--help');
|
|
34
|
-
|
|
35
|
-
// Export the lintCommand from rcConfig
|
|
36
|
-
export const lintCommand = rcConfig.lintCommand || null;
|
|
37
|
-
|
|
38
|
-
// Temperature parameter
|
|
39
|
-
export const temperature = parseFloat(
|
|
40
|
-
params.find((param) => param.startsWith('--temperature='))?.split('=')[1] || '0.7',
|
|
41
|
-
); // Default temperature value: 0.7
|
|
42
|
-
|
|
43
|
-
// New content mask parameter
|
|
44
|
-
export const contentMask = params.find((param) => param.startsWith('--content-mask='))?.split('=')[1] || null;
|
|
45
|
-
|
|
46
|
-
// New ignore pattern parameter
|
|
47
|
-
export const ignorePatterns = params
|
|
48
|
-
.filter((param) => param.startsWith('--ignore-pattern='))
|
|
49
|
-
.map((param) => param.split('=')[1]);
|
|
50
|
-
|
|
51
|
-
if (taskFile) {
|
|
52
|
-
if (explicitPrompt) {
|
|
53
|
-
throw new Error('The --task-file option is exclusive with the --explicit-prompt option');
|
|
54
|
-
}
|
|
55
|
-
if (!fs.existsSync(taskFile)) {
|
|
56
|
-
throw new Error(`The task file ${taskFile} does not exist`);
|
|
57
|
-
}
|
|
58
|
-
if (!path.isAbsolute(taskFile)) {
|
|
59
|
-
taskFile = path.join(process.cwd(), taskFile);
|
|
60
|
-
}
|
|
61
|
-
explicitPrompt = `I want you to perform a coding task. The task is described in the ${taskFile} file. Use those instructions.`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (considerAllFiles && dependencyTree) {
|
|
65
|
-
throw new Error('--consider-all-files and --dependency-tree are exclusive.');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if ([chatGpt, anthropic, vertexAi, vertexAiClaude].filter(Boolean).length > 1) {
|
|
69
|
-
throw new Error('--chat-gpt, --anthropic, --vertex-ai, and --vertex-ai-claude are mutually exclusive.');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!chatGpt && !anthropic && !vertexAi && !vertexAiClaude && !helpRequested) {
|
|
73
|
-
const detected = serviceAutoDetect();
|
|
74
|
-
if (detected === 'anthropic') {
|
|
75
|
-
console.log('Autodetected --anthropic');
|
|
76
|
-
anthropic = true;
|
|
77
|
-
} else if (detected === 'chat-gpt') {
|
|
78
|
-
console.log('Autodetected --chat-gpt');
|
|
79
|
-
chatGpt = true;
|
|
80
|
-
} else if (detected === 'vertex-ai') {
|
|
81
|
-
console.log('Autodetected --vertex-ai');
|
|
82
|
-
vertexAi = true;
|
|
83
|
-
} else {
|
|
84
|
-
throw new Error('Missing --chat-gpt, --anthropic, --vertex-ai, or --vertex-ai-claude');
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (lintCommand) {
|
|
89
|
-
console.log(`Lint command detected: ${lintCommand}`);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (temperature) {
|
|
93
|
-
console.log(`Temperature value: ${temperature}`);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (imagen) {
|
|
97
|
-
console.log('Image generation functionality enabled');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (cheap) {
|
|
101
|
-
console.log('Cheaper AI models will be used for content and image generation');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (contentMask) {
|
|
105
|
-
console.log(`Content mask: ${contentMask}`);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (ignorePatterns) {
|
|
109
|
-
console.log(`Ignore pattern: ${ignorePatterns}`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (askQuestion) {
|
|
113
|
-
console.log('Assistant can ask questions to the user');
|
|
114
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import { serviceAutoDetect } from './service-autodetect';
|
|
3
|
-
|
|
4
|
-
describe('serviceAutoDetect', () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
// Clean up environment variables after each test
|
|
7
|
-
delete process.env.ANTHROPIC_API_KEY;
|
|
8
|
-
delete process.env.OPENAI_API_KEY;
|
|
9
|
-
delete process.env.GOOGLE_CLOUD_PROJECT;
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should return "anthropic" when ANTHROPIC_API_KEY is set', () => {
|
|
13
|
-
process.env.ANTHROPIC_API_KEY = 'test-key';
|
|
14
|
-
expect(serviceAutoDetect()).toBe('anthropic');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should return "chat-gpt" when OPENAI_API_KEY is set', () => {
|
|
18
|
-
process.env.OPENAI_API_KEY = 'test-key';
|
|
19
|
-
expect(serviceAutoDetect()).toBe('chat-gpt');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should return "vertex-ai" when GOOGLE_CLOUD_PROJECT is set', () => {
|
|
23
|
-
process.env.GOOGLE_CLOUD_PROJECT = 'test-project';
|
|
24
|
-
expect(serviceAutoDetect()).toBe('vertex-ai');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should return null when no service is configured', () => {
|
|
28
|
-
expect(serviceAutoDetect()).toBeNull();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should prioritize anthropic over other services', () => {
|
|
32
|
-
process.env.ANTHROPIC_API_KEY = 'test-key';
|
|
33
|
-
process.env.OPENAI_API_KEY = 'test-key';
|
|
34
|
-
process.env.GOOGLE_CLOUD_PROJECT = 'test-project';
|
|
35
|
-
expect(serviceAutoDetect()).toBe('anthropic');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should prioritize chat-gpt over vertex-ai', () => {
|
|
39
|
-
process.env.OPENAI_API_KEY = 'test-key';
|
|
40
|
-
process.env.GOOGLE_CLOUD_PROJECT = 'test-project';
|
|
41
|
-
expect(serviceAutoDetect()).toBe('chat-gpt');
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** Detects if one of ai services is configured */
|
|
2
|
-
export function serviceAutoDetect() {
|
|
3
|
-
if (process.env.ANTHROPIC_API_KEY) {
|
|
4
|
-
return 'anthropic';
|
|
5
|
-
} else if (process.env.OPENAI_API_KEY) {
|
|
6
|
-
return 'chat-gpt';
|
|
7
|
-
} else if (process.env.GOOGLE_CLOUD_PROJECT) {
|
|
8
|
-
return 'vertex-ai';
|
|
9
|
-
}
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import { serviceAutoDetect } from './service-autodetect';
|
|
3
|
-
|
|
4
|
-
describe('serviceAutoDetect', () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
// Clean up environment variables after each test
|
|
7
|
-
delete process.env.ANTHROPIC_API_KEY;
|
|
8
|
-
delete process.env.OPENAI_API_KEY;
|
|
9
|
-
delete process.env.GOOGLE_CLOUD_PROJECT;
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should return "anthropic" when ANTHROPIC_API_KEY is set', () => {
|
|
13
|
-
process.env.ANTHROPIC_API_KEY = 'test-key';
|
|
14
|
-
expect(serviceAutoDetect()).toBe('anthropic');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should return "chat-gpt" when OPENAI_API_KEY is set', () => {
|
|
18
|
-
process.env.OPENAI_API_KEY = 'test-key';
|
|
19
|
-
expect(serviceAutoDetect()).toBe('chat-gpt');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should return "vertex-ai" when GOOGLE_CLOUD_PROJECT is set', () => {
|
|
23
|
-
process.env.GOOGLE_CLOUD_PROJECT = 'test-project';
|
|
24
|
-
expect(serviceAutoDetect()).toBe('vertex-ai');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should return null when no service is configured', () => {
|
|
28
|
-
expect(serviceAutoDetect()).toBeNull();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should prioritize anthropic over other services', () => {
|
|
32
|
-
process.env.ANTHROPIC_API_KEY = 'test-key';
|
|
33
|
-
process.env.OPENAI_API_KEY = 'test-key';
|
|
34
|
-
process.env.GOOGLE_CLOUD_PROJECT = 'test-project';
|
|
35
|
-
expect(serviceAutoDetect()).toBe('anthropic');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should prioritize chat-gpt over vertex-ai', () => {
|
|
39
|
-
process.env.OPENAI_API_KEY = 'test-key';
|
|
40
|
-
process.env.GOOGLE_CLOUD_PROJECT = 'test-project';
|
|
41
|
-
expect(serviceAutoDetect()).toBe('chat-gpt');
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import globRegex from 'glob-regex';
|
|
4
|
-
import { rcConfig } from '../main/config.js';
|
|
5
|
-
|
|
6
|
-
// List of allowed CLI parameters
|
|
7
|
-
const allowedParameters = [
|
|
8
|
-
'--dry-run',
|
|
9
|
-
'--consider-all-files',
|
|
10
|
-
'--allow-file-create',
|
|
11
|
-
'--allow-file-delete',
|
|
12
|
-
'--allow-directory-create',
|
|
13
|
-
'--allow-file-move',
|
|
14
|
-
'--chat-gpt',
|
|
15
|
-
'--vertex-ai',
|
|
16
|
-
'--vertex-ai-claude',
|
|
17
|
-
'--anthropic',
|
|
18
|
-
'--explicit-prompt=',
|
|
19
|
-
'--task-file=',
|
|
20
|
-
'--dependency-tree',
|
|
21
|
-
'--verbose-prompt',
|
|
22
|
-
'--require-explanations',
|
|
23
|
-
'--disable-context-optimization',
|
|
24
|
-
'--gemini-block-none',
|
|
25
|
-
'--disable-initial-lint',
|
|
26
|
-
'--temperature=',
|
|
27
|
-
'--vision',
|
|
28
|
-
'--imagen=',
|
|
29
|
-
'--cheap',
|
|
30
|
-
'--ask-question',
|
|
31
|
-
'--help',
|
|
32
|
-
'--content-mask=',
|
|
33
|
-
'--disable-cache',
|
|
34
|
-
'--ignore-pattern=',
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Validate CLI parameters according to those mentioned in README.md
|
|
39
|
-
* Fail the process if not valid, or if an unknown parameter is passed
|
|
40
|
-
* @throws {Error} If an invalid parameter is provided
|
|
41
|
-
*/
|
|
42
|
-
export function validateCliParams() {
|
|
43
|
-
const providedParameters = process.argv.slice(2);
|
|
44
|
-
|
|
45
|
-
// Check if --help is present
|
|
46
|
-
const helpRequested = providedParameters.includes('--help');
|
|
47
|
-
|
|
48
|
-
if (helpRequested) {
|
|
49
|
-
// If --help is present, no other parameters should be allowed
|
|
50
|
-
if (providedParameters.length > 1) {
|
|
51
|
-
console.error('The --help option cannot be used with other parameters.');
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
return; // Exit the function early as no further validation is needed
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
providedParameters.forEach((param) => {
|
|
58
|
-
if (!param.startsWith('--')) {
|
|
59
|
-
console.error(`Invalid parameter: ${param}, all parameters must start with --`);
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
if (!allowedParameters.some((p) => (p.endsWith('=') && param.startsWith(p)) || param === p)) {
|
|
63
|
-
console.error(`Invalid parameter: ${param}, allowed parameters are: ${allowedParameters.join(', ')}`);
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Validate temperature parameter, it must be a number between 0.0 and 2.0
|
|
69
|
-
const temperatureParam = providedParameters.find((param) => param.startsWith('--temperature='));
|
|
70
|
-
if (temperatureParam) {
|
|
71
|
-
const temperatureValue = parseFloat(temperatureParam.split('=')[1]);
|
|
72
|
-
if (isNaN(temperatureValue) || temperatureValue < 0.0 || temperatureValue > 2.0) {
|
|
73
|
-
console.error('Invalid temperature value. It must be a number between 0.0 and 2.0.');
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Validate --imagen parameter
|
|
79
|
-
const imagenParam = providedParameters.find((param) => param.startsWith('--imagen='));
|
|
80
|
-
if (imagenParam) {
|
|
81
|
-
const imagenValue = imagenParam.split('=')[1];
|
|
82
|
-
if (imagenValue !== 'vertex-ai' && imagenValue !== 'dall-e') {
|
|
83
|
-
throw new Error('Invalid --imagen value. It must be either "vertex-ai" or "dall-e".');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (providedParameters.includes('--vision') && providedParameters.includes('--vertex-ai')) {
|
|
88
|
-
throw new Error('--vision and --vertex-ai are currently not supported together.');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Validate content mask parameter
|
|
92
|
-
const contentMaskParam = providedParameters.find((param) => param.startsWith('--content-mask='));
|
|
93
|
-
if (contentMaskParam) {
|
|
94
|
-
const contentMaskValue = contentMaskParam.split('=')[1];
|
|
95
|
-
const fullPath = path.join(rcConfig.rootDir, contentMaskValue);
|
|
96
|
-
if (!fs.existsSync(fullPath) || !fs.statSync(fullPath).isDirectory()) {
|
|
97
|
-
throw new Error(
|
|
98
|
-
`Invalid --content-mask value. The path "${contentMaskValue}" does not exist or is not a directory within the project.`,
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Validate ignore pattern parameter
|
|
104
|
-
const ignorePatternParams = providedParameters.filter((param) => param.startsWith('--ignore-pattern='));
|
|
105
|
-
if (ignorePatternParams.length > 0) {
|
|
106
|
-
for (const ignorePatternParam of ignorePatternParams) {
|
|
107
|
-
const ignorePatternValue = ignorePatternParam.split('=')[1];
|
|
108
|
-
if (!ignorePatternValue) {
|
|
109
|
-
throw new Error('Invalid --ignore-pattern value. The pattern cannot be empty.');
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
globRegex(ignorePatternValue);
|
|
113
|
-
} catch (e) {
|
|
114
|
-
throw new Error(`Invalid --ignore-pattern value. The pattern "${ignorePatternValue}" is not valid.`, e);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Get the value of a CLI parameter
|
|
122
|
-
* @param {string} paramName - The name of the parameter to get the value for
|
|
123
|
-
* @returns {string|null} The value of the parameter, or null if not found
|
|
124
|
-
*/
|
|
125
|
-
export function getCliParamValue(paramName) {
|
|
126
|
-
const param = process.argv.find((arg) => arg.startsWith(`${paramName}=`));
|
|
127
|
-
return param ? param.split('=')[1] : null;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Check if a CLI parameter is present
|
|
132
|
-
* @param {string} paramName - The name of the parameter to check
|
|
133
|
-
* @returns {boolean} True if the parameter is present, false otherwise
|
|
134
|
-
*/
|
|
135
|
-
export function hasCliParam(paramName) {
|
|
136
|
-
return process.argv.includes(paramName) || !!getCliParamValue(paramName);
|
|
137
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import { validateCliParams, getCliParamValue, hasCliParam } from './validate-cli-params.js';
|
|
3
|
-
|
|
4
|
-
describe('validateCliParams', () => {
|
|
5
|
-
const originalArgv = process.argv;
|
|
6
|
-
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
process.argv = ['node', 'script.js'];
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
process.argv = originalArgv;
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should not throw for valid parameters', () => {
|
|
16
|
-
process.argv.push('--dry-run', '--consider-all-files');
|
|
17
|
-
expect(() => validateCliParams()).not.toThrow();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should throw for invalid parameters', () => {
|
|
21
|
-
process.argv.push('--invalid-param');
|
|
22
|
-
expect(() => validateCliParams()).toThrow();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should throw for parameters without --', () => {
|
|
26
|
-
process.argv.push('invalid-param');
|
|
27
|
-
expect(() => validateCliParams()).toThrow();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('should not throw for valid --temperature parameter', () => {
|
|
31
|
-
process.argv.push('--temperature=0.5');
|
|
32
|
-
expect(() => validateCliParams()).not.toThrow();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should throw for invalid --temperature parameter', () => {
|
|
36
|
-
process.argv.push('--temperature=invalid');
|
|
37
|
-
expect(() => validateCliParams()).toThrow();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should throw an error when both vision and vertexAi flags are true', () => {
|
|
41
|
-
process.argv.push('--vision');
|
|
42
|
-
process.argv.push('--vertex-ai');
|
|
43
|
-
|
|
44
|
-
expect(() => validateCliParams()).toThrow('--vision and --vertex-ai are currently not supported together.');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// New tests for --imagen parameter
|
|
48
|
-
it('should not throw for valid --imagen parameter with vertex-ai', () => {
|
|
49
|
-
process.argv.push('--imagen=vertex-ai');
|
|
50
|
-
expect(() => validateCliParams()).not.toThrow();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should not throw for valid --imagen parameter with dall-e', () => {
|
|
54
|
-
process.argv.push('--imagen=dall-e');
|
|
55
|
-
expect(() => validateCliParams()).not.toThrow();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should throw for invalid --imagen parameter value', () => {
|
|
59
|
-
process.argv.push('--imagen=invalid-service');
|
|
60
|
-
expect(() => validateCliParams()).toThrow('Invalid --imagen value. It must be either "vertex-ai" or "dall-e".');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should throw for --imagen parameter without value', () => {
|
|
64
|
-
process.argv.push('--imagen=');
|
|
65
|
-
expect(() => validateCliParams()).toThrow('Invalid --imagen value. It must be either "vertex-ai" or "dall-e".');
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe('getCliParamValue', () => {
|
|
70
|
-
const originalArgv = process.argv;
|
|
71
|
-
|
|
72
|
-
beforeEach(() => {
|
|
73
|
-
process.argv = ['node', 'script.js'];
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
afterEach(() => {
|
|
77
|
-
process.argv = originalArgv;
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('should return the value for a parameter with a value', () => {
|
|
81
|
-
process.argv.push('--explicit-prompt=Test prompt');
|
|
82
|
-
expect(getCliParamValue('--explicit-prompt')).toBe('Test prompt');
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should return null for a parameter without a value', () => {
|
|
86
|
-
process.argv.push('--dry-run');
|
|
87
|
-
expect(getCliParamValue('--dry-run')).toBeNull();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should return null for a non-existent parameter', () => {
|
|
91
|
-
expect(getCliParamValue('--non-existent')).toBeNull();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should return the value for --temperature parameter', () => {
|
|
95
|
-
process.argv.push('--temperature=0.5');
|
|
96
|
-
expect(getCliParamValue('--temperature')).toBe('0.5');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('should return the value for --imagen parameter', () => {
|
|
100
|
-
process.argv.push('--imagen=vertex-ai');
|
|
101
|
-
expect(getCliParamValue('--imagen')).toBe('vertex-ai');
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
describe('hasCliParam', () => {
|
|
106
|
-
const originalArgv = process.argv;
|
|
107
|
-
|
|
108
|
-
beforeEach(() => {
|
|
109
|
-
process.argv = ['node', 'script.js'];
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
afterEach(() => {
|
|
113
|
-
process.argv = originalArgv;
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('should return true for an existing parameter', () => {
|
|
117
|
-
process.argv.push('--dry-run');
|
|
118
|
-
expect(hasCliParam('--dry-run')).toBe(true);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('should return false for a non-existent parameter', () => {
|
|
122
|
-
expect(hasCliParam('--non-existent')).toBe(false);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('should return true for --temperature parameter', () => {
|
|
126
|
-
process.argv.push('--temperature=0.5');
|
|
127
|
-
expect(hasCliParam('--temperature')).toBe(true);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('should return true for --imagen parameter', () => {
|
|
131
|
-
process.argv.push('--imagen=dall-e');
|
|
132
|
-
expect(hasCliParam('--imagen')).toBe(true);
|
|
133
|
-
});
|
|
134
|
-
});
|
package/src/files/file-utils.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
/** Check if directory is ancestor of given directory */
|
|
4
|
-
export function isAncestorDirectory(parent, dir) {
|
|
5
|
-
const relative = path.relative(parent, dir);
|
|
6
|
-
return parent === dir || (relative && !relative.startsWith('..') && !path.isAbsolute(relative));
|
|
7
|
-
}
|