genaicode 0.1.1 → 0.2.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.
Files changed (146) hide show
  1. package/README.md +3 -1
  2. package/bin/genaicode.cjs +7 -0
  3. package/dist/ai-service/ai-studio.d.ts +2 -1
  4. package/dist/ai-service/ai-studio.js +5 -5
  5. package/dist/ai-service/ai-studio.js.map +1 -1
  6. package/dist/ai-service/anthropic.d.ts +2 -1
  7. package/dist/ai-service/anthropic.js +6 -4
  8. package/dist/ai-service/anthropic.js.map +1 -1
  9. package/dist/ai-service/chat-gpt.js +2 -1
  10. package/dist/ai-service/chat-gpt.js.map +1 -1
  11. package/dist/ai-service/common.d.ts +4 -3
  12. package/dist/ai-service/common.js.map +1 -1
  13. package/dist/ai-service/dall-e.js +3 -2
  14. package/dist/ai-service/dall-e.js.map +1 -1
  15. package/dist/ai-service/vertex-ai-claude.js +2 -1
  16. package/dist/ai-service/vertex-ai-claude.js.map +1 -1
  17. package/dist/ai-service/vertex-ai-imagen.js +3 -0
  18. package/dist/ai-service/vertex-ai-imagen.js.map +1 -1
  19. package/dist/ai-service/vertex-ai.d.ts +3 -3
  20. package/dist/ai-service/vertex-ai.js +18 -23
  21. package/dist/ai-service/vertex-ai.js.map +1 -1
  22. package/dist/cli/cli-options.js +2 -2
  23. package/dist/cli/cli-options.js.map +1 -1
  24. package/dist/cli/cli-params.d.ts +4 -3
  25. package/dist/cli/cli-params.js +12 -6
  26. package/dist/cli/cli-params.js.map +1 -1
  27. package/dist/cli/validate-cli-params.js +2 -1
  28. package/dist/cli/validate-cli-params.js.map +1 -1
  29. package/dist/files/read-files.d.ts +6 -1
  30. package/dist/files/read-files.js +13 -8
  31. package/dist/files/read-files.js.map +1 -1
  32. package/dist/files/read-files.test.js +5 -6
  33. package/dist/files/read-files.test.js.map +1 -1
  34. package/dist/files/update-files.d.ts +2 -1
  35. package/dist/files/update-files.js +6 -6
  36. package/dist/files/update-files.js.map +1 -1
  37. package/dist/main/codegen-interactive-utils.d.ts +8 -0
  38. package/dist/main/codegen-interactive-utils.js +148 -0
  39. package/dist/main/codegen-interactive-utils.js.map +1 -0
  40. package/dist/main/codegen-interactive.d.ts +2 -0
  41. package/dist/main/codegen-interactive.js +68 -0
  42. package/dist/main/codegen-interactive.js.map +1 -0
  43. package/dist/main/codegen-types.d.ts +28 -0
  44. package/dist/main/codegen-types.js +2 -0
  45. package/dist/main/codegen-types.js.map +1 -0
  46. package/dist/main/codegen.d.ts +2 -0
  47. package/dist/main/codegen.js +88 -25
  48. package/dist/main/codegen.js.map +1 -1
  49. package/dist/main/codegen.test.js +36 -22
  50. package/dist/main/codegen.test.js.map +1 -1
  51. package/dist/main/config-lib.d.ts +8 -0
  52. package/dist/main/config-lib.js.map +1 -1
  53. package/dist/main/config.d.ts +2 -1
  54. package/dist/main/config.js +12 -0
  55. package/dist/main/config.js.map +1 -1
  56. package/dist/main/interactive/codegen-interactive.d.ts +2 -0
  57. package/dist/main/interactive/codegen-interactive.js +55 -0
  58. package/dist/main/interactive/codegen-interactive.js.map +1 -0
  59. package/dist/main/interactive/codegen-interactive.test.d.ts +4 -0
  60. package/dist/main/interactive/codegen-interactive.test.js +77 -0
  61. package/dist/main/interactive/codegen-interactive.test.js.map +1 -0
  62. package/dist/main/interactive/codegen-worker.d.ts +3 -0
  63. package/dist/main/interactive/codegen-worker.js +47 -0
  64. package/dist/main/interactive/codegen-worker.js.map +1 -0
  65. package/dist/main/interactive/common.d.ts +5 -0
  66. package/dist/main/interactive/common.js +51 -0
  67. package/dist/main/interactive/common.js.map +1 -0
  68. package/dist/main/interactive/configure.d.ts +2 -0
  69. package/dist/main/interactive/configure.js +99 -0
  70. package/dist/main/interactive/configure.js.map +1 -0
  71. package/dist/main/interactive/error-handling.d.ts +4 -0
  72. package/dist/main/interactive/error-handling.js +49 -0
  73. package/dist/main/interactive/error-handling.js.map +1 -0
  74. package/dist/main/interactive/help.d.ts +1 -0
  75. package/dist/main/interactive/help.js +22 -0
  76. package/dist/main/interactive/help.js.map +1 -0
  77. package/dist/main/interactive/process-comments.d.ts +2 -0
  78. package/dist/main/interactive/process-comments.js +39 -0
  79. package/dist/main/interactive/process-comments.js.map +1 -0
  80. package/dist/main/interactive/select-ai-service.d.ts +2 -0
  81. package/dist/main/interactive/select-ai-service.js +27 -0
  82. package/dist/main/interactive/select-ai-service.js.map +1 -0
  83. package/dist/main/interactive/task-file.d.ts +2 -0
  84. package/dist/main/interactive/task-file.js +28 -0
  85. package/dist/main/interactive/task-file.js.map +1 -0
  86. package/dist/main/interactive/text-prompt.d.ts +2 -0
  87. package/dist/main/interactive/text-prompt.js +18 -0
  88. package/dist/main/interactive/text-prompt.js.map +1 -0
  89. package/dist/main/interactive/user-interrupt.d.ts +1 -0
  90. package/dist/main/interactive/user-interrupt.js +36 -0
  91. package/dist/main/interactive/user-interrupt.js.map +1 -0
  92. package/dist/main/interactive/worker-script.d.ts +1 -0
  93. package/dist/main/interactive/worker-script.js +24 -0
  94. package/dist/main/interactive/worker-script.js.map +1 -0
  95. package/dist/main/interactive/worker.d.ts +2 -0
  96. package/dist/main/interactive/worker.js +55 -0
  97. package/dist/main/interactive/worker.js.map +1 -0
  98. package/dist/prompt/function-calling-validate.d.ts +1 -1
  99. package/dist/prompt/function-calling-validate.js +21 -15
  100. package/dist/prompt/function-calling-validate.js.map +1 -1
  101. package/dist/prompt/function-defs/ask-question.d.ts +38 -1
  102. package/dist/prompt/function-defs/ask-question.js +39 -1
  103. package/dist/prompt/function-defs/ask-question.js.map +1 -1
  104. package/dist/prompt/function-defs/codegen-summary.d.ts +5 -5
  105. package/dist/prompt/function-defs/codegen-summary.js +8 -8
  106. package/dist/prompt/function-defs/codegen-summary.js.map +1 -1
  107. package/dist/prompt/function-defs/generate-image.d.ts +8 -15
  108. package/dist/prompt/function-defs/generate-image.js +8 -15
  109. package/dist/prompt/function-defs/generate-image.js.map +1 -1
  110. package/dist/prompt/limits.js +2 -2
  111. package/dist/prompt/limits.test.js +5 -5
  112. package/dist/prompt/prompt-codegen.d.ts +7 -2
  113. package/dist/prompt/prompt-codegen.js +26 -17
  114. package/dist/prompt/prompt-codegen.js.map +1 -1
  115. package/dist/prompt/prompt-codegen.test.js +11 -7
  116. package/dist/prompt/prompt-codegen.test.js.map +1 -1
  117. package/dist/prompt/prompt-service-ask-question.test.js +14 -18
  118. package/dist/prompt/prompt-service-ask-question.test.js.map +1 -1
  119. package/dist/prompt/prompt-service.d.ts +20 -5
  120. package/dist/prompt/prompt-service.js +40 -153
  121. package/dist/prompt/prompt-service.js.map +1 -1
  122. package/dist/prompt/prompt-service.test.js +42 -22
  123. package/dist/prompt/prompt-service.test.js.map +1 -1
  124. package/dist/prompt/steps/step-ask-question.d.ts +6 -0
  125. package/dist/prompt/steps/step-ask-question.js +80 -0
  126. package/dist/prompt/steps/step-ask-question.js.map +1 -0
  127. package/dist/prompt/steps/step-generate-image.d.ts +2 -0
  128. package/dist/prompt/steps/step-generate-image.js +29 -0
  129. package/dist/prompt/steps/step-generate-image.js.map +1 -0
  130. package/dist/prompt/steps/step-validate-recover.d.ts +13 -0
  131. package/dist/prompt/steps/step-validate-recover.js +51 -0
  132. package/dist/prompt/steps/step-validate-recover.js.map +1 -0
  133. package/dist/prompt/steps/step-verify-patch.d.ts +7 -0
  134. package/dist/prompt/steps/step-verify-patch.js +41 -0
  135. package/dist/prompt/steps/step-verify-patch.js.map +1 -0
  136. package/dist/prompt/steps/steps-types.d.ts +4 -0
  137. package/dist/prompt/steps/steps-types.js +6 -0
  138. package/dist/prompt/steps/steps-types.js.map +1 -0
  139. package/dist/prompt/systemprompt.d.ts +2 -1
  140. package/dist/prompt/systemprompt.js +11 -7
  141. package/dist/prompt/systemprompt.js.map +1 -1
  142. package/dist/prompt/systemprompt.test.d.ts +1 -0
  143. package/dist/prompt/systemprompt.test.js +4 -5
  144. package/dist/prompt/systemprompt.test.js.map +1 -1
  145. package/package.json +4 -3
  146. package/bin/vertex-monkey-patch.cjs +0 -33
@@ -0,0 +1,24 @@
1
+ import { parentPort } from 'worker_threads';
2
+ import assert from 'node:assert';
3
+ import { runCodegenIteration } from '../codegen.js';
4
+ assert(parentPort, 'parentPort must be defined.');
5
+ parentPort.on('message', async ({ action, options, additionalData }) => {
6
+ try {
7
+ switch (action) {
8
+ case 'process_comments':
9
+ await runCodegenIteration(options);
10
+ break;
11
+ case 'text_prompt':
12
+ case 'task_file':
13
+ await runCodegenIteration({ ...options, ...additionalData });
14
+ break;
15
+ default:
16
+ throw new Error('Unknown action');
17
+ }
18
+ parentPort.postMessage('done');
19
+ }
20
+ catch (error) {
21
+ parentPort.postMessage({ error: error.message });
22
+ }
23
+ });
24
+ //# sourceMappingURL=worker-script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-script.js","sourceRoot":"","sources":["../../../src/main/interactive/worker-script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,CAAC,UAAU,EAAE,6BAA6B,CAAC,CAAC;AAElD,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE;IACrE,IAAI,CAAC;QACH,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,kBAAkB;gBACrB,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;gBACnC,MAAM;YACR,KAAK,aAAa,CAAC;YACnB,KAAK,WAAW;gBACd,MAAM,mBAAmB,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC,CAAC;gBAC7D,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACtC,CAAC;QACD,UAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAW,CAAC,WAAW,CAAC,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { CodegenOptions } from '../codegen-types.js';
2
+ export declare const runWorker: (action: string, options: CodegenOptions, additionalData?: Record<string, unknown>) => Promise<void>;
@@ -0,0 +1,55 @@
1
+ import { SHARE_ENV, Worker } from 'worker_threads';
2
+ import { handleUserInterrupt } from './common.js';
3
+ import { fileURLToPath } from 'url';
4
+ import path from 'path';
5
+ // Helper function to create and run a worker
6
+ export const runWorker = async (action, options, additionalData) => {
7
+ // Define __dirname and __filename using import.meta.url
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+ // Path to the worker file
11
+ const workerFile = path.join(__dirname, 'worker-script.js');
12
+ console.log('Start worker...');
13
+ const worker = new Worker(workerFile, {
14
+ env: SHARE_ENV,
15
+ });
16
+ worker.postMessage({ action, options, additionalData });
17
+ try {
18
+ await Promise.race([
19
+ new Promise((resolve, reject) => {
20
+ worker.on('message', (message) => {
21
+ if (message === 'done') {
22
+ resolve(message);
23
+ }
24
+ else if (message.error) {
25
+ reject(new Error(message.error));
26
+ }
27
+ });
28
+ worker.on('error', reject);
29
+ worker.on('exit', (code) => {
30
+ if (code !== 0)
31
+ reject(new Error(`Worker stopped with exit code ${code}`));
32
+ });
33
+ }),
34
+ handleUserInterrupt(worker),
35
+ ]);
36
+ }
37
+ catch (error) {
38
+ if (error instanceof Error) {
39
+ if (error.message === 'OPERATION_INTERRUPTED') {
40
+ console.log('Operation interrupted by user. Returning to main menu...');
41
+ }
42
+ else {
43
+ console.error(`Error during ${action}:`, error);
44
+ }
45
+ }
46
+ else {
47
+ console.log('Worker error', error);
48
+ }
49
+ }
50
+ finally {
51
+ console.log('Worker terminate.');
52
+ worker.terminate();
53
+ }
54
+ };
55
+ //# s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AM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;oBACnC,CAAC;gBACH,CAAC,CAAC,CAAC;gBACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBAC3B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;oBACzB,IAAI,IAAI,KAAK,CAAC;wBAAE,MAAM,CAAC,IAAI,KAAK,CAAC,iCAAiC,IAAI,EAAE,CAAC,CAAC,CAAC;gBAC7E,CAAC,CAAC,CAAC;YACL,CAAC,CAAC;YACF,mBAAmB,CAAC,MAAM,CAAC;SAC5B,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,IAAI,KAAK,CAAC,OAAO,KAAK,uBAAuB,EAAE,CAAC;gBAC9C,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;YAC1E,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,gBAAgB,MAAM,GAAG,EAAE,KAAK,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACjC,MAAM,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC;AACH,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { ValidatorResult } from 'jsonschema';
2
2
  import { FunctionCall } from '../ai-service/common.js';
3
- export declare function validateFunctionCall(call: FunctionCall): Omit<ValidatorResult, 'addError'> | undefined;
3
+ export declare function validateFunctionCall(call: FunctionCall | undefined, requiredFunctionName: string): Omit<ValidatorResult, 'addError'> | undefined;
@@ -1,22 +1,13 @@
1
1
  import { Validator } from 'jsonschema';
2
2
  import { functionDefs } from './function-calling.js';
3
- export function validateFunctionCall(call) {
3
+ export function validateFunctionCall(call, requiredFunctionName) {
4
4
  const validator = new Validator();
5
- const functionDef = functionDefs.find((def) => def.name === call.name);
5
+ const functionDef = functionDefs.find((def) => def.name === call?.name);
6
+ if (!call || call.name !== requiredFunctionName) {
7
+ return makeError(`Function "${requiredFunctionName}" was not called.`, call);
8
+ }
6
9
  if (!functionDef) {
7
- return {
8
- errors: [
9
- {
10
- message: `Function "${call.name}" is not defined.`,
11
- },
12
- ],
13
- valid: false,
14
- instance: call,
15
- schema: {},
16
- propertyPath: '',
17
- disableFormat: false,
18
- throwError: true,
19
- };
10
+ return makeError(`Function "${call.name}" is not defined.`, call);
20
11
  }
21
12
  const validationResult = validator.validate(call.args, functionDef.parameters);
22
13
  if (validationResult.errors.length > 0) {
@@ -24,4 +15,19 @@ export function validateFunctionCall(call) {
24
15
  }
25
16
  return undefined;
26
17
  }
18
+ function makeError(message, call) {
19
+ return {
20
+ errors: [
21
+ {
22
+ message,
23
+ },
24
+ ],
25
+ valid: false,
26
+ instance: call,
27
+ schema: {},
28
+ propertyPath: '',
29
+ disableFormat: false,
30
+ throwError: true,
31
+ };
32
+ }
27
33
  //# sourceMappingURL=function-calling-validate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"function-calling-validate.js","sourceRoot":"","sources":["../../src/prompt/function-calling-validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA4C,MAAM,YAAY,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,UAAU,oBAAoB,CAAC,IAAkB;IACrD,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;IAClC,MAAM,WAAW,GAA4B,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhG,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO;YACL,MAAM,EAAE;gBACN;oBACE,OAAO,EAAE,aAAa,IAAI,CAAC,IAAI,mBAAmB;iBACrB;aAChC;YACD,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,EAAY;YACpB,YAAY,EAAE,EAAE;YAChB,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,IAAI;SACjB,CAAC;IACJ,CAAC;IAED,MAAM,gBAAgB,GAAoB,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,UAA+B,CAAC,CAAC;IAErH,IAAI,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
1
+ {"version":3,"file":"function-calling-validate.js","sourceRoot":"","sources":["../../src/prompt/function-calling-validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA4C,MAAM,YAAY,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,UAAU,oBAAoB,CAClC,IAA8B,EAC9B,oBAA4B;IAE5B,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;IAClC,MAAM,WAAW,GAA4B,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,IAAI,CAAC,CAAC;IAEjG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAChD,OAAO,SAAS,CAAC,aAAa,oBAAoB,mBAAmB,EAAE,IAAI,CAAC,CAAC;IAC/E,CAAC;IAED,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC,aAAa,IAAI,CAAC,IAAI,mBAAmB,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,gBAAgB,GAAoB,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,UAA+B,CAAC,CAAC;IAErH,IAAI,gBAAgB,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CAAC,OAAe,EAAE,IAA8B;IAChE,OAAO;QACL,MAAM,EAAE;YACN;gBACE,OAAO;aACsB;SAChC;QACD,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAY;QACpB,YAAY,EAAE,EAAE;QAChB,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,IAAI;KACjB,CAAC;AACJ,CAAC"}
@@ -23,7 +23,44 @@ export declare const askQuestion: {
23
23
  };
24
24
  readonly stopCodegen: {
25
25
  readonly type: "boolean";
26
- readonly description: "If set to true, it will break the code generation process without error.";
26
+ readonly description: "If set to true, it will break the code generation process without error, so you should use this parameter if you want to stop the code generation process.";
27
+ };
28
+ readonly requestFilesContent: {
29
+ readonly type: "array";
30
+ readonly description: string;
31
+ readonly items: {
32
+ readonly type: "string";
33
+ };
34
+ };
35
+ readonly requestPermissions: {
36
+ readonly type: "object";
37
+ readonly description: "Use this property to request enablement of permissions for code generation process if you detect that you don't have this permission listed in the requirements.";
38
+ readonly properties: {
39
+ readonly allowDirectoryCreate: {
40
+ readonly description: "Set to `true` to request permission for creating directories.";
41
+ readonly type: "boolean";
42
+ };
43
+ readonly allowFileCreate: {
44
+ readonly description: "Set to `true` to request permission for creating files.";
45
+ readonly type: "boolean";
46
+ };
47
+ readonly allowFileDelete: {
48
+ readonly description: "Set to `true` to request permission for deleting files.";
49
+ readonly type: "boolean";
50
+ };
51
+ readonly allowFileMove: {
52
+ readonly description: "Set to `true` to request permission for moving files.";
53
+ readonly type: "boolean";
54
+ };
55
+ readonly enableVision: {
56
+ readonly description: "Set to `true` to request permission for vision capabilities, using images as a context for further code generation operations.";
57
+ readonly type: "boolean";
58
+ };
59
+ readonly enableImagen: {
60
+ readonly description: "Set to `true` to request permission for generation of images.";
61
+ readonly type: "boolean";
62
+ };
63
+ };
27
64
  };
28
65
  };
29
66
  readonly required: readonly ["content", "shouldPrompt", "promptNecessity", "stopCodegen"];
@@ -23,7 +23,45 @@ export const askQuestion = {
23
23
  },
24
24
  stopCodegen: {
25
25
  type: 'boolean',
26
- description: 'If set to true, it will break the code generation process without error.',
26
+ description: 'If set to true, it will break the code generation process without error, so you should use this parameter if you want to stop the code generation process.',
27
+ },
28
+ requestFilesContent: {
29
+ type: 'array',
30
+ description: 'This object property is used to request file contents to be provided by the user, use this property when a content of a file is missing(null in getSourceCode response), but we know that it exists.' +
31
+ 'An array of absolute paths of files that should be used to provide context for the following updates. Context files could be for example the dependencies, or files that depend on one of the files that we want to update in the next step.',
32
+ items: {
33
+ type: 'string',
34
+ },
35
+ },
36
+ requestPermissions: {
37
+ type: 'object',
38
+ description: "Use this property to request enablement of permissions for code generation process if you detect that you don't have this permission listed in the requirements.",
39
+ properties: {
40
+ allowDirectoryCreate: {
41
+ description: 'Set to `true` to request permission for creating directories.',
42
+ type: 'boolean',
43
+ },
44
+ allowFileCreate: {
45
+ description: 'Set to `true` to request permission for creating files.',
46
+ type: 'boolean',
47
+ },
48
+ allowFileDelete: {
49
+ description: 'Set to `true` to request permission for deleting files.',
50
+ type: 'boolean',
51
+ },
52
+ allowFileMove: {
53
+ description: 'Set to `true` to request permission for moving files.',
54
+ type: 'boolean',
55
+ },
56
+ enableVision: {
57
+ description: 'Set to `true` to request permission for vision capabilities, using images as a context for further code generation operations.',
58
+ type: 'boolean',
59
+ },
60
+ enableImagen: {
61
+ description: 'Set to `true` to request permission for generation of images.',
62
+ type: 'boolean',
63
+ },
64
+ },
27
65
  },
28
66
  },
29
67
  required: ['content', 'shouldPrompt', 'promptNecessity', 'stopCodegen'],
@@ -1 +1 @@
1
- {"version":3,"file":"ask-question.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/ask-question.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,qMAAqM;IACvM,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,6JAA6J;aAChK;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,gEAAgE;aAC9E;YACD,eAAe,EAAE;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;gBACZ,WAAW,EAAE,oFAAoF;aAClG;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,0EAA0E;aACxF;SACF;QACD,QAAQ,EAAE,CAAC,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,CAAC;KACxE;CACO,CAAC"}
1
+ {"version":3,"file":"ask-question.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/ask-question.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,qMAAqM;IACvM,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,6JAA6J;aAChK;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,gEAAgE;aAC9E;YACD,eAAe,EAAE;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;gBACZ,WAAW,EAAE,oFAAoF;aAClG;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,SAAS;gBACf,WAAW,EACT,4JAA4J;aAC/J;YACD,mBAAmB,EAAE;gBACnB,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,sMAAsM;oBACtM,8OAA8O;gBAChP,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,kBAAkB,EAAE;gBAClB,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,kKAAkK;gBACpK,UAAU,EAAE;oBACV,oBAAoB,EAAE;wBACpB,WAAW,EAAE,+DAA+D;wBAC5E,IAAI,EAAE,SAAS;qBAChB;oBACD,eAAe,EAAE;wBACf,WAAW,EAAE,yDAAyD;wBACtE,IAAI,EAAE,SAAS;qBAChB;oBACD,eAAe,EAAE;wBACf,WAAW,EAAE,yDAAyD;wBACtE,IAAI,EAAE,SAAS;qBAChB;oBACD,aAAa,EAAE;wBACb,WAAW,EAAE,uDAAuD;wBACpE,IAAI,EAAE,SAAS;qBAChB;oBACD,YAAY,EAAE;wBACZ,WAAW,EACT,gIAAgI;wBAClI,IAAI,EAAE,SAAS;qBAChB;oBACD,YAAY,EAAE;wBACZ,WAAW,EAAE,+DAA+D;wBAC5E,IAAI,EAAE,SAAS;qBAChB;iBACF;aACF;SACF;QACD,QAAQ,EAAE,CAAC,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,CAAC;KACxE;CACO,CAAC"}
@@ -19,11 +19,11 @@ export declare const codegenSummary: {
19
19
  readonly description: "An array of proposed file updates, each update is an object with several properties.";
20
20
  readonly items: {
21
21
  readonly type: "object";
22
- readonly description: "Proposed update of a file. The update is an object which contains properties like file path, update tool name, and few other important properties.";
22
+ readonly description: "Proposed update of a file. The update is an object which contains properties like absolute file path, update tool name, and few other important properties.";
23
23
  readonly properties: {
24
24
  readonly path: {
25
25
  readonly type: "string";
26
- readonly description: "An absolute path of the project file that will be updated";
26
+ readonly description: "An absolute path of the project file that will be updated. This must be an absolute file path.";
27
27
  };
28
28
  readonly updateToolName: {
29
29
  readonly type: "string";
@@ -32,11 +32,11 @@ export declare const codegenSummary: {
32
32
  };
33
33
  readonly temperature: {
34
34
  readonly type: "number";
35
- readonly description: string;
35
+ readonly description: "Temperature parameter that will be used for LLM request. The value is adjusted to the characteristic of the update. If there is a need for a more creative solution, the value should be lower, but stil within [0.0, 2.0] range.";
36
36
  };
37
37
  readonly cheap: {
38
38
  readonly type: "boolean";
39
- readonly description: string;
39
+ 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.";
40
40
  };
41
41
  readonly prompt: {
42
42
  readonly type: "string";
@@ -50,7 +50,7 @@ export declare const codegenSummary: {
50
50
  };
51
51
  };
52
52
  };
53
- readonly required: readonly ["path", "updateToolName", ...string[]];
53
+ readonly required: readonly ["path", "updateToolName"];
54
54
  };
55
55
  };
56
56
  readonly explanation: {
@@ -1,4 +1,3 @@
1
- import { temperature, cheap, vision } from '../../cli/cli-params.js';
2
1
  /**
3
2
  * Function definition for codegenSummary
4
3
  */
@@ -25,9 +24,12 @@ export const codegenSummary = {
25
24
  description: 'An array of proposed file updates, each update is an object with several properties.',
26
25
  items: {
27
26
  type: 'object',
28
- description: 'Proposed update of a file. The update is an object which contains properties like file path, update tool name, and few other important properties.',
27
+ description: 'Proposed update of a file. The update is an object which contains properties like absolute file path, update tool name, and few other important properties.',
29
28
  properties: {
30
- path: { type: 'string', description: 'An absolute path of the project file that will be updated' },
29
+ path: {
30
+ type: 'string',
31
+ description: 'An absolute path of the project file that will be updated. This must be an absolute file path.',
32
+ },
31
33
  updateToolName: {
32
34
  type: 'string',
33
35
  enum: [
@@ -47,13 +49,11 @@ export const codegenSummary = {
47
49
  },
48
50
  temperature: {
49
51
  type: 'number',
50
- description: 'Temperature parameter that will be used for LLM request. The value is adjusted to the characteristic of the update. If there is a need for a more creative solution, the value should be lower, but stil within [0.0, 2.0] range. The default value is: ' +
51
- temperature,
52
+ description: 'Temperature parameter that will be used for LLM request. The value is adjusted to the characteristic of the update. If there is a need for a more creative solution, the value should be lower, but stil within [0.0, 2.0] range.',
52
53
  },
53
54
  cheap: {
54
55
  type: 'boolean',
55
- 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. The default value is: ' +
56
- !!cheap,
56
+ 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.',
57
57
  },
58
58
  prompt: {
59
59
  type: 'string',
@@ -66,7 +66,7 @@ export const codegenSummary = {
66
66
  items: { type: 'string' },
67
67
  },
68
68
  },
69
- required: ['path', 'updateToolName', ...(vision ? ['contextImageAssets'] : [])],
69
+ required: ['path', 'updateToolName'],
70
70
  },
71
71
  },
72
72
  explanation: {
@@ -1 +1 @@
1
- {"version":3,"file":"codegen-summary.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/codegen-summary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,6DAA6D;QAC7D,uDAAuD;QACvD,6GAA6G;QAC7G,wGAAwG;QACxG,2EAA2E;QAC3E,kEAAkE;IACpE,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,YAAY,EAAE;gBACZ,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,8OAA8O;gBAChP,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,sFAAsF;gBACnG,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,oJAAoJ;oBACtJ,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2DAA2D,EAAE;wBAClG,cAAc,EAAE;4BACd,IAAI,EAAE,QAAQ;4BACd,IAAI,EAAE;gCACJ,YAAY;gCACZ,YAAY;gCACZ,WAAW;gCACX,YAAY;gCACZ,iBAAiB;gCACjB,UAAU;gCACV,eAAe;gCACf,cAAc;gCACd,YAAY;gCACZ,aAAa;gCACb,uBAAuB;6BACxB;4BACD,WAAW,EAAE,6DAA6D;yBAC3E;wBACD,WAAW,EAAE;4BACX,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,0PAA0P;gCAC1P,WAAW;yBACd;wBACD,KAAK,EAAE;4BACL,IAAI,EAAE,SAAS;4BACf,WAAW,EACT,kPAAkP;gCAClP,CAAC,CAAC,KAAK;yBACV;wBACD,MAAM,EAAE;4BACN,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,0NAA0N;yBAC7N;wBACD,kBAAkB,EAAE;4BAClB,IAAI,EAAE,OAAO;4BACb,WAAW,EACT,gGAAgG;gCAChG,qEAAqE;4BACvE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;yBAC1B;qBACF;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;iBAChF;aACF;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gFAAgF;aAC9F;SACF;QACD,QAAQ,EAAE,CAAC,aAAa,EAAE,cAAc,CAAC;KAC1C;CACO,CAAC"}
1
+ {"version":3,"file":"codegen-summary.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/codegen-summary.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,6DAA6D;QAC7D,uDAAuD;QACvD,6GAA6G;QAC7G,wGAAwG;QACxG,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AAC,aAAa,EAAE,cAAc,CAAC;KAC1C;CACO,CAAC"}
@@ -19,20 +19,13 @@ export declare const generateImage: {
19
19
  readonly type: "string";
20
20
  readonly description: "Path to a image file that will be used as a context for image generation. It is useful if there is a need to edit an image with genAI.";
21
21
  };
22
- readonly size: {
23
- readonly type: "object";
24
- readonly properties: {
25
- readonly width: {
26
- readonly type: "number";
27
- readonly description: "width of the image";
28
- };
29
- readonly height: {
30
- readonly type: "number";
31
- readonly description: "height of the image";
32
- };
33
- };
34
- readonly required: readonly ["width", "height"];
35
- readonly description: "The size of the image to generate.";
22
+ readonly width: {
23
+ readonly type: "number";
24
+ readonly description: "width of the image";
25
+ };
26
+ readonly height: {
27
+ readonly type: "number";
28
+ readonly description: "height of the image";
36
29
  };
37
30
  readonly cheap: {
38
31
  readonly type: "boolean";
@@ -43,6 +36,6 @@ export declare const generateImage: {
43
36
  readonly description: "The explanation of the reasoning behind generating this image";
44
37
  };
45
38
  };
46
- readonly required: readonly ["prompt", "filePath", "size", "cheap"];
39
+ readonly required: readonly ["prompt", "filePath", "width", "height"];
47
40
  };
48
41
  };
@@ -19,20 +19,13 @@ export const generateImage = {
19
19
  type: 'string',
20
20
  description: 'Path to a image file that will be used as a context for image generation. It is useful if there is a need to edit an image with genAI.',
21
21
  },
22
- size: {
23
- type: 'object',
24
- properties: {
25
- width: {
26
- type: 'number',
27
- description: 'width of the image',
28
- },
29
- height: {
30
- type: 'number',
31
- description: 'height of the image',
32
- },
33
- },
34
- required: ['width', 'height'],
35
- description: 'The size of the image to generate.',
22
+ width: {
23
+ type: 'number',
24
+ description: 'width of the image',
25
+ },
26
+ height: {
27
+ type: 'number',
28
+ description: 'height of the image',
36
29
  },
37
30
  cheap: {
38
31
  type: 'boolean',
@@ -43,7 +36,7 @@ export const generateImage = {
43
36
  description: 'The explanation of the reasoning behind generating this image',
44
37
  },
45
38
  },
46
- required: ['prompt', 'filePath', 'size', 'cheap'],
39
+ required: ['prompt', 'filePath', 'width', 'height'],
47
40
  },
48
41
  };
49
42
  //# sourceMappingURL=generate-image.js.map
@@ -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,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,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS;gBACf,WAAW,EACT,2NAA2N;aAC9N;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+DAA+D;aAC7E;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;KAClD;CACO,CAAC"}
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;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+DAA+D;aAC7E;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC;KACpD;CACO,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import assert from 'node:assert';
2
- const SYSTEM_PROMPT_LIMIT = 300;
2
+ const SYSTEM_PROMPT_LIMIT = 450;
3
3
  const CODEGEN_PROMPT_LIMIT = 500;
4
- const SOURCE_CODE_LIMIT = 20000;
4
+ const SOURCE_CODE_LIMIT = 40000;
5
5
  function verifyPromptLimit(promptType, prompt, limit) {
6
6
  const tokenCount = prompt.split(/\s+/).length;
7
7
  console.log(`${promptType} prompt token count: ${tokenCount}`);
@@ -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(301);
11
- expect(() => verifySystemPromptLimit(invalidPrompt)).toThrow('Token limit exceeded: 302 > 300');
10
+ const invalidPrompt = 'A '.repeat(451);
11
+ expect(() => verifySystemPromptLimit(invalidPrompt)).toThrow('Token limit exceeded: 452 > 450');
12
12
  });
13
13
  });
14
14
  describe('verifyCodegenPromptLimit', () => {
@@ -23,12 +23,12 @@ describe('Prompt Limits', () => {
23
23
  });
24
24
  describe('verifySourceCodeLimit', () => {
25
25
  it('should not throw for source code within the limit', () => {
26
- const validSourceCode = 'C '.repeat(20000 - 1);
26
+ const validSourceCode = 'C '.repeat(40000 - 1);
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(20001);
31
- expect(() => verifySourceCodeLimit(invalidSourceCode)).toThrow('Token limit exceeded: 20002 > 20000');
30
+ const invalidSourceCode = 'C '.repeat(40001);
31
+ expect(() => verifySourceCodeLimit(invalidSourceCode)).toThrow('Token limit exceeded: 40002 > 40000');
32
32
  });
33
33
  });
34
34
  });
@@ -1,4 +1,9 @@
1
+ import { CodegenOptions } from '../main/codegen-types.js';
2
+ export interface CodegenPrompt {
3
+ prompt: string;
4
+ options: CodegenOptions;
5
+ }
1
6
  /** Get codegen prompt */
2
- export declare function getCodeGenPrompt(): string;
7
+ export declare function getCodeGenPrompt(options: CodegenOptions): CodegenPrompt;
3
8
  /** Get lint fix prompt */
4
- export declare function getLintFixPrompt(command: string, stdout: string, stderr: string): string;
9
+ export declare function getLintFixPrompt(command: string, { verbose }: CodegenOptions, stdout: string, stderr: string): string;
@@ -1,17 +1,23 @@
1
1
  import assert from 'node:assert';
2
2
  import { getSourceCode } from '../files/read-files.js';
3
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
4
  import { getDependencyList } from '../files/find-files.js';
6
5
  import { verifyCodegenPromptLimit } from './limits.js';
6
+ import { importantContext } from '../main/config.js';
7
7
  /** Get codegen prompt */
8
- export function getCodeGenPrompt() {
8
+ export function getCodeGenPrompt(options) {
9
+ let { explicitPrompt } = options;
10
+ const { taskFile, considerAllFiles, allowFileCreate, allowFileDelete, allowDirectoryCreate, allowFileMove, vision, imagen, dependencyTree, verbose, askQuestion, interactive, } = options;
11
+ assert(!explicitPrompt || !taskFile, 'Both taskFile and explicitPrompt are not allowed');
12
+ if (taskFile) {
13
+ explicitPrompt = `I want you to perform a coding task. The task is described in the ${taskFile} file. Use those instructions.`;
14
+ }
9
15
  let codeGenFiles;
10
16
  if (considerAllFiles) {
11
- codeGenFiles = Object.keys(getSourceCode());
17
+ codeGenFiles = Object.keys(getSourceCode({ taskFile, forceAll: true }, options));
12
18
  }
13
19
  else {
14
- codeGenFiles = Object.entries(getSourceCode())
20
+ codeGenFiles = Object.entries(getSourceCode({ taskFile, forceAll: true }, options))
15
21
  .filter(([, { content }]) => content?.match(new RegExp(`([^'^\`]+)${CODEGEN_TRIGGER}`)))
16
22
  .map(([path]) => path);
17
23
  }
@@ -25,36 +31,39 @@ export function getCodeGenPrompt() {
25
31
  .forEach((key) => dependencyTreeFiles.add(key));
26
32
  codeGenFiles = Array.from(dependencyTreeFiles);
27
33
  }
28
- const codeGenPrompt = (explicitPrompt ? explicitPrompt + '\n\n' : '') +
34
+ const importantTextPrompts = importantContext.textPrompts?.map((prompt) => prompt.content).join('\n\n') || '';
35
+ const requestPermissionText = askQuestion && interactive ? ' (request permission via `askQuestion`)' : '';
36
+ const codeGenPrompt = (explicitPrompt ? 'This is your task: ' + explicitPrompt + '\n\n' : '') +
29
37
  `${considerAllFiles
30
38
  ? codeGenFiles.length > 0
31
39
  ? `I have marked some files with the ${CODEGEN_TRIGGER} fragments:\n${codeGenFiles.join('\n')}`
32
40
  : `No files are marked with ${CODEGEN_TRIGGER} fragment, so you can consider doing changes in any file.`
33
41
  : codeGenFiles.length > 0
34
- ? `Generate updates only for the following files:\n${codeGenFiles.join('\n')}`
42
+ ? `Generate updates only for the following files:\n${codeGenFiles.join('\n')}\n`
35
43
  : ''}
36
-
44
+ My additional requirements for task execution are:
45
+ ${importantTextPrompts ? `${importantTextPrompts}\n` : ''}
37
46
  ${considerAllFiles
38
47
  ? 'You are allowed to modify all files in the application regardless if they contain codegen fragments or not.'
39
48
  : 'Do not modify files which do not contain the fragments.'}
40
- ${allowFileCreate ? 'You are allowed to create new files.' : 'Do not create new files.'}
49
+ ${allowFileCreate ? 'You are allowed to create new files.' : 'Do not create new files. (request permission via `askQuestion`)'}
41
50
  ${allowFileDelete
42
51
  ? '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.'}
52
+ : 'Do not delete files. (request permission via `askQuestion`)'}
53
+ ${allowDirectoryCreate ? 'You are allowed to create new directories.' : `Do not create new directories.${requestPermissionText}`}
54
+ ${allowFileMove ? 'You are allowed to move files.' : 'Do not move files. (request permission via `askQuestion`)'}
55
+ ${vision ? 'You are allowed to analyze image assets.' : 'Do not analyze image assets. (request permission via `askQuestion`)'}
56
+ ${imagen ? 'You are allowed to generate images.' : 'You are not allowed to generate images. (request permission via `askQuestion`)'}
48
57
  `;
49
- if (verbosePrompt) {
58
+ if (verbose) {
50
59
  console.log('Code gen prompt:');
51
60
  console.log(codeGenPrompt);
52
61
  }
53
62
  verifyCodegenPromptLimit(codeGenPrompt);
54
- return codeGenPrompt;
63
+ return { prompt: codeGenPrompt, options };
55
64
  }
56
65
  /** Get lint fix prompt */
57
- export function getLintFixPrompt(command, stdout, stderr) {
66
+ export function getLintFixPrompt(command, { verbose }, stdout, stderr) {
58
67
  const lintFixPrompt = `The following lint errors were encountered after the initial code generation:
59
68
 
60
69
  Lint command: ${command}
@@ -71,7 +80,7 @@ ${stderr}
71
80
  \`\`\`
72
81
 
73
82
  Please suggest changes to fix these lint errors.`;
74
- if (verbosePrompt) {
83
+ if (verbose) {
75
84
  console.log('Lint fix prompt:');
76
85
  console.log(lintFixPrompt);
77
86
  }
@@ -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,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,UAAU,gBAAgB;IAC9B,IAAI,YAAsB,CAAC;IAC3B,IAAI,gBAAgB,EAAE,CAAC;QACrB,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IAC9C,CAAC;SAAM,CAAC;QACN,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,EAAqC,CAAC;aAC9E,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,aAAa,eAAe,EAAE,CAAC,CAAC,CAAC;aACvF,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,wCAAwC;IACxC,IAAI,cAAc,EAAE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