genaicode 0.3.0 → 0.4.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 (140) hide show
  1. package/README.md +9 -0
  2. package/dist/ai-service/ai-studio.js +58 -9
  3. package/dist/ai-service/ai-studio.js.map +1 -1
  4. package/dist/ai-service/anthropic.js +1 -0
  5. package/dist/ai-service/anthropic.js.map +1 -1
  6. package/dist/ai-service/chat-gpt.js +1 -0
  7. package/dist/ai-service/chat-gpt.js.map +1 -1
  8. package/dist/ai-service/common.d.ts +12 -3
  9. package/dist/ai-service/common.js +4 -3
  10. package/dist/ai-service/common.js.map +1 -1
  11. package/dist/ai-service/common.test.js +2 -2
  12. package/dist/ai-service/common.test.js.map +1 -1
  13. package/dist/ai-service/unescape-function-call.d.ts +7 -0
  14. package/dist/ai-service/unescape-function-call.js +59 -0
  15. package/dist/ai-service/unescape-function-call.js.map +1 -0
  16. package/dist/ai-service/unescape-function-call.test.d.ts +1 -0
  17. package/dist/ai-service/unescape-function-call.test.js +18 -0
  18. package/dist/ai-service/unescape-function-call.test.js.map +1 -0
  19. package/dist/ai-service/vertex-ai-claude.js +7 -1
  20. package/dist/ai-service/vertex-ai-claude.js.map +1 -1
  21. package/dist/ai-service/vertex-ai.d.ts +1 -1
  22. package/dist/ai-service/vertex-ai.js +63 -13
  23. package/dist/ai-service/vertex-ai.js.map +1 -1
  24. package/dist/cli/cli-options.js +8 -0
  25. package/dist/cli/cli-options.js.map +1 -1
  26. package/dist/cli/cli-params.d.ts +4 -0
  27. package/dist/cli/cli-params.js +12 -3
  28. package/dist/cli/cli-params.js.map +1 -1
  29. package/dist/cli/validate-cli-params.js +9 -1
  30. package/dist/cli/validate-cli-params.js.map +1 -1
  31. package/dist/files/cache-file.d.ts +3 -0
  32. package/dist/files/cache-file.js +36 -0
  33. package/dist/files/cache-file.js.map +1 -0
  34. package/dist/files/read-files.d.ts +4 -1
  35. package/dist/files/read-files.js +5 -3
  36. package/dist/files/read-files.js.map +1 -1
  37. package/dist/files/read-files.test.js +1 -0
  38. package/dist/files/read-files.test.js.map +1 -1
  39. package/dist/files/update-files.js +1 -4
  40. package/dist/files/update-files.js.map +1 -1
  41. package/dist/main/codegen-types.d.ts +2 -0
  42. package/dist/main/codegen.js +7 -2
  43. package/dist/main/codegen.js.map +1 -1
  44. package/dist/main/codegen.test.d.ts +1 -0
  45. package/dist/main/codegen.test.js +20 -7
  46. package/dist/main/codegen.test.js.map +1 -1
  47. package/dist/main/common/cost-collector.d.ts +10 -14
  48. package/dist/main/common/cost-collector.js +83 -17
  49. package/dist/main/common/cost-collector.js.map +1 -1
  50. package/dist/main/interactive/codegen-interactive.test.d.ts +1 -0
  51. package/dist/main/interactive/codegen-interactive.test.js +2 -0
  52. package/dist/main/interactive/codegen-interactive.test.js.map +1 -1
  53. package/dist/main/interactive/codegen-worker.js +5 -2
  54. package/dist/main/interactive/codegen-worker.js.map +1 -1
  55. package/dist/main/ui/backend/api.js +3 -3
  56. package/dist/main/ui/backend/api.js.map +1 -1
  57. package/dist/main/ui/backend/server.js +7 -3
  58. package/dist/main/ui/backend/server.js.map +1 -1
  59. package/dist/main/ui/backend/service.d.ts +3 -2
  60. package/dist/main/ui/backend/service.js +8 -8
  61. package/dist/main/ui/backend/service.js.map +1 -1
  62. package/dist/main/ui/frontend/assets/index-Bj9ZkmiD.js +638 -0
  63. package/dist/main/ui/frontend/index.html +1 -1
  64. package/dist/prompt/ai-service-fallback.js +5 -0
  65. package/dist/prompt/ai-service-fallback.js.map +1 -1
  66. package/dist/prompt/function-calling-validate.js +70 -4
  67. package/dist/prompt/function-calling-validate.js.map +1 -1
  68. package/dist/prompt/function-calling.js +8 -0
  69. package/dist/prompt/function-calling.js.map +1 -1
  70. package/dist/prompt/function-defs/ask-question-reflect.d.ts +20 -0
  71. package/dist/prompt/function-defs/ask-question-reflect.js +21 -0
  72. package/dist/prompt/function-defs/ask-question-reflect.js.map +1 -0
  73. package/dist/prompt/function-defs/ask-question.d.ts +22 -11
  74. package/dist/prompt/function-defs/ask-question.js +42 -11
  75. package/dist/prompt/function-defs/ask-question.js.map +1 -1
  76. package/dist/prompt/function-defs/codegen-summary.d.ts +3 -3
  77. package/dist/prompt/function-defs/codegen-summary.js +4 -4
  78. package/dist/prompt/function-defs/codegen-summary.js.map +1 -1
  79. package/dist/prompt/function-defs/optimize-context.d.ts +16 -11
  80. package/dist/prompt/function-defs/optimize-context.js +16 -11
  81. package/dist/prompt/function-defs/optimize-context.js.map +1 -1
  82. package/dist/prompt/function-defs/read-history.d.ts +13 -0
  83. package/dist/prompt/function-defs/read-history.js +14 -0
  84. package/dist/prompt/function-defs/read-history.js.map +1 -0
  85. package/dist/prompt/function-defs/set-summaries.d.ts +31 -0
  86. package/dist/prompt/function-defs/set-summaries.js +32 -0
  87. package/dist/prompt/function-defs/set-summaries.js.map +1 -0
  88. package/dist/prompt/function-defs/update-history.d.ts +21 -0
  89. package/dist/prompt/function-defs/update-history.js +22 -0
  90. package/dist/prompt/function-defs/update-history.js.map +1 -0
  91. package/dist/prompt/limits.js +2 -2
  92. package/dist/prompt/limits.test.js +3 -3
  93. package/dist/prompt/prompt-codegen.js +25 -13
  94. package/dist/prompt/prompt-codegen.js.map +1 -1
  95. package/dist/prompt/prompt-service-ask-question.test.d.ts +1 -0
  96. package/dist/prompt/prompt-service-ask-question.test.js +74 -8
  97. package/dist/prompt/prompt-service-ask-question.test.js.map +1 -1
  98. package/dist/prompt/prompt-service.d.ts +0 -1
  99. package/dist/prompt/prompt-service.js +41 -21
  100. package/dist/prompt/prompt-service.js.map +1 -1
  101. package/dist/prompt/prompt-service.test.d.ts +1 -0
  102. package/dist/prompt/prompt-service.test.js +40 -30
  103. package/dist/prompt/prompt-service.test.js.map +1 -1
  104. package/dist/prompt/steps/step-ask-question-handlers.d.ts +10 -0
  105. package/dist/prompt/steps/step-ask-question-handlers.js +265 -0
  106. package/dist/prompt/steps/step-ask-question-handlers.js.map +1 -0
  107. package/dist/prompt/steps/step-ask-question-reflect.d.ts +4 -0
  108. package/dist/prompt/steps/step-ask-question-reflect.js +40 -0
  109. package/dist/prompt/steps/step-ask-question-reflect.js.map +1 -0
  110. package/dist/prompt/steps/step-ask-question-types.d.ts +60 -0
  111. package/dist/prompt/steps/step-ask-question-types.js +2 -0
  112. package/dist/prompt/steps/step-ask-question-types.js.map +1 -0
  113. package/dist/prompt/steps/step-ask-question.d.ts +2 -2
  114. package/dist/prompt/steps/step-ask-question.js +65 -82
  115. package/dist/prompt/steps/step-ask-question.js.map +1 -1
  116. package/dist/prompt/steps/step-context-optimization.d.ts +1 -3
  117. package/dist/prompt/steps/step-context-optimization.js +120 -73
  118. package/dist/prompt/steps/step-context-optimization.js.map +1 -1
  119. package/dist/prompt/steps/step-history-update.d.ts +5 -0
  120. package/dist/prompt/steps/step-history-update.js +54 -0
  121. package/dist/prompt/steps/step-history-update.js.map +1 -0
  122. package/dist/prompt/steps/step-summarization.d.ts +8 -0
  123. package/dist/prompt/steps/step-summarization.js +75 -0
  124. package/dist/prompt/steps/step-summarization.js.map +1 -0
  125. package/dist/prompt/steps/step-validate-recover.d.ts +2 -13
  126. package/dist/prompt/steps/step-validate-recover.js +3 -3
  127. package/dist/prompt/steps/step-validate-recover.js.map +1 -1
  128. package/dist/prompt/steps/step-verify-patch.d.ts +1 -2
  129. package/dist/prompt/steps/step-verify-patch.js +3 -10
  130. package/dist/prompt/steps/step-verify-patch.js.map +1 -1
  131. package/dist/prompt/steps/steps-types.d.ts +16 -0
  132. package/dist/prompt/steps/steps-utils.d.ts +7 -0
  133. package/dist/prompt/steps/steps-utils.js +11 -0
  134. package/dist/prompt/steps/steps-utils.js.map +1 -0
  135. package/dist/prompt/systemprompt.js +124 -12
  136. package/dist/prompt/systemprompt.js.map +1 -1
  137. package/dist/prompt/systemprompt.test.js +3 -3
  138. package/dist/prompt/systemprompt.test.js.map +1 -1
  139. package/package.json +5 -1
  140. package/dist/main/ui/frontend/assets/index-D9wcaSJU.js +0 -598
@@ -7,7 +7,7 @@
7
7
  <meta name="keywords" content="GenAIcode, AI, code generation, programming" />
8
8
  <title>GenAIcode - AI-Powered Code Generation</title>
9
9
  <link rel="icon" href="/favicon.ico" type="image/x-icon" />
10
- <script type="module" crossorigin src="/assets/index-D9wcaSJU.js"></script>
10
+ <script type="module" crossorigin src="/assets/index-Bj9ZkmiD.js"></script>
11
11
  <link rel="stylesheet" crossorigin href="/assets/index-S_ocA1xG.css">
12
12
  </head>
13
13
  <body data-security-token="__SECURITY_TOKEN__">
@@ -1,5 +1,6 @@
1
1
  import { putSystemMessage } from '../main/common/content-bus.js';
2
2
  import { askUserForConfirmation } from '../main/common/user-actions.js';
3
+ import { abortController } from '../main/interactive/codegen-worker.js';
3
4
  const AI_SERVICES_MAP = [
4
5
  [() => process.env.ANTHROPIC_API_KEY, 'anthropic'],
5
6
  [() => process.env.GOOGLE_CLOUD_PROJECT && process.env.GOOGLE_CLOUD_REGION, 'vertex-ai-claude'],
@@ -12,6 +13,10 @@ export async function handleAiServiceFallback(generateContentFns, currentService
12
13
  const maxRetries = AI_SERVICES_MAP.length;
13
14
  let permanentService = currentService;
14
15
  while (retryCount < maxRetries) {
16
+ if (abortController?.signal.aborted) {
17
+ putSystemMessage(`Operation interrupted for ${permanentService}`);
18
+ throw new Error(`Operation interrupted`);
19
+ }
15
20
  try {
16
21
  const result = await generateContentFns[permanentService](...args);
17
22
  options.aiService = permanentService;
@@ -1 +1 @@
1
- {"version":3,"file":"ai-service-fallback.js","sourceRoot":"","sources":["../../src/prompt/ai-service-fallback.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAGxE,MAAM,eAAe,GAAG;IACtB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,WAAW,CAAC;IAClD,CAAC,GAAG,EAAE,CAAC,OAAO,C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YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACrD,IAAI,YAAY,KAAK,CAAC,CAAC,IAAI,YAAY,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/D,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;AACnC,CAAC"}
@@ -1,21 +1,87 @@
1
1
  import { Validator } from 'jsonschema';
2
+ import path from 'path';
2
3
  import { functionDefs } from './function-calling.js';
4
+ import { rcConfig } from '../main/config.js';
3
5
  export function validateFunctionCall(call, requiredFunctionName) {
4
6
  const validator = new Validator();
5
7
  const functionDef = functionDefs.find((def) => def.name === call?.name);
8
+ // Step 1: Check if the function name matches
6
9
  if (!call || call.name !== requiredFunctionName) {
7
- return makeError(`Function "${requiredFunctionName}" was not called.`, call);
10
+ return makeError(`Function "${requiredFunctionName}" was not called.`, call, '');
8
11
  }
12
+ // Step 2: Check if the function is defined
9
13
  if (!functionDef) {
10
- return makeError(`Function "${call.name}" is not defined.`, call);
14
+ return makeError(`Function "${call.name}" is not defined.`, call, '');
11
15
  }
16
+ // Step 3: Validate against the schema
12
17
  const validationResult = validator.validate(call.args, functionDef.parameters);
13
18
  if (validationResult.errors.length > 0) {
14
19
  return validationResult;
15
20
  }
21
+ // Step 4: Validate file paths
22
+ const filePathValidationError = validateFilePaths(call);
23
+ if (filePathValidationError) {
24
+ return filePathValidationError;
25
+ }
16
26
  return undefined;
17
27
  }
18
- function makeError(message, call) {
28
+ function validateFilePaths(call) {
29
+ const rootDir = path.normalize(rcConfig.rootDir);
30
+ function checkPaths(obj, parentKey = '') {
31
+ const errors = [];
32
+ if (Array.isArray(obj)) {
33
+ obj.forEach((item, index) => {
34
+ if (typeof item === 'string' && isPathProperty(parentKey)) {
35
+ errors.push(...validatePath(item, `${parentKey}[${index}]`));
36
+ }
37
+ else if (typeof item === 'object' && item !== null) {
38
+ errors.push(...checkPaths(item, `${parentKey}[${index}]`));
39
+ }
40
+ });
41
+ }
42
+ else if (typeof obj === 'object' && obj !== null) {
43
+ for (const [key, value] of Object.entries(obj)) {
44
+ const currentKey = parentKey ? `${parentKey}.${key}` : key;
45
+ if (typeof value === 'string' && isPathProperty(key)) {
46
+ errors.push(...validatePath(value, currentKey));
47
+ }
48
+ else if (Array.isArray(value) || (typeof value === 'object' && value !== null)) {
49
+ errors.push(...checkPaths(value, currentKey));
50
+ }
51
+ }
52
+ }
53
+ return errors;
54
+ }
55
+ function validatePath(value, key) {
56
+ const errors = [];
57
+ const normalizedPath = path.normalize(value);
58
+ if (!path.isAbsolute(value)) {
59
+ errors.push(makeError(`File path "${value}" is not absolute.`, call, key).errors[0]);
60
+ }
61
+ else if (!normalizedPath.startsWith(rootDir)) {
62
+ errors.push(makeError(`File path "${value}" is not inside the root directory "${rootDir}".`, call, key).errors[0]);
63
+ }
64
+ return errors;
65
+ }
66
+ const errors = checkPaths(call.args);
67
+ if (errors.length > 0) {
68
+ return { errors, valid: false };
69
+ }
70
+ return undefined;
71
+ }
72
+ function isPathProperty(prop) {
73
+ return [
74
+ 'filePath',
75
+ 'source',
76
+ 'destination',
77
+ 'inputFilePath',
78
+ 'outputFilePath',
79
+ 'contextPaths',
80
+ 'filePaths',
81
+ 'requestFilesContent',
82
+ ].includes(prop);
83
+ }
84
+ function makeError(message, call, propertyPath) {
19
85
  return {
20
86
  errors: [
21
87
  {
@@ -25,7 +91,7 @@ function makeError(message, call) {
25
91
  valid: false,
26
92
  instance: call,
27
93
  schema: {},
28
- propertyPath: '',
94
+ propertyPath,
29
95
  disableFormat: false,
30
96
  throwError: true,
31
97
  };
@@ -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,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"}
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;AACjF,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY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L,MAAM,EAAE;YACN;gBACE,OAAO;aACsB;SAChC;QACD,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAY;QACpB,YAAY;QACZ,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,IAAI;KACjB,CAAC;AACJ,CAAC"}
@@ -16,6 +16,10 @@ import { resizeImage } from './function-defs/resize-image.js';
16
16
  import { splitImage } from './function-defs/split-image.js';
17
17
  import { askQuestion } from './function-defs/ask-question.js';
18
18
  import { optimizeContext } from './function-defs/optimize-context.js';
19
+ import { setSummaries } from './function-defs/set-summaries.js';
20
+ import { updateHistory } from './function-defs/update-history.js';
21
+ import { readHistory } from './function-defs/read-history.js';
22
+ import { askQuestionReflect } from './function-defs/ask-question-reflect.js';
19
23
  /**
20
24
  * Function definitions for function calling feature
21
25
  */
@@ -37,6 +41,10 @@ export const functionDefs = [
37
41
  splitImage,
38
42
  askQuestion,
39
43
  optimizeContext,
44
+ setSummaries,
45
+ updateHistory,
46
+ readHistory,
47
+ askQuestionReflect,
40
48
  // @ts-expect-error (fix this once fun defs are converted to ts)
41
49
  ].map((fd) => {
42
50
  if (requireExplanations && fd.parameters.properties.explanation && !fd.parameters.required.includes('explanation')) {
@@ -1 +1 @@
1
- {"version":3,"file":"function-calling.js","sourceRoot":"","sources":["../../src/prompt/function-calling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAA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E7E;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC,aAAa;IACb,cAAc;IACd,cAAc;IACd,UAAU;IACV,SAAS;IACT,UAAU;IACV,UAAU;IACV,WAAW;IACX,eAAe;IACf,QAAQ;IACR,aAAa;IACb,YAAY;IACZ,qBAAqB;IACrB,WAAW;IACX,UAAU;IACV,WAAW;IACX,eAAe;IACf,YAAY;IACZ,aAAa;IACb,WAAW;IACX,kBAAkB;IAClB,gEAAgE;CACjE,CAAC,GAAG,CAAC,CAAC,EAAe,EAAE,EAAE;IACxB,IAAI,mBAAmB,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;QACnH,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAChD,CAAC;SAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC;IAC9C,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ export declare const askQuestionReflect: {
2
+ readonly name: "askQuestionReflect";
3
+ readonly description: "This function is used to decide whether to escalate the request to more advanced model.";
4
+ readonly parameters: {
5
+ readonly type: "object";
6
+ readonly properties: {
7
+ readonly reason: {
8
+ readonly type: "string";
9
+ readonly description: "The reason for the escalation necessity.";
10
+ };
11
+ readonly shouldEscalate: {
12
+ readonly type: "number";
13
+ readonly description: "A number that expresses the escalation necessity: 0 - no need to escalate, 100 - absolutely need to escalate to more advanced model.";
14
+ readonly minimum: 0;
15
+ readonly maximum: 100;
16
+ };
17
+ };
18
+ readonly required: readonly ["reason", "shouldEscalate"];
19
+ };
20
+ };
@@ -0,0 +1,21 @@
1
+ export const askQuestionReflect = {
2
+ name: 'askQuestionReflect',
3
+ description: 'This function is used to decide whether to escalate the request to more advanced model.',
4
+ parameters: {
5
+ type: 'object',
6
+ properties: {
7
+ reason: {
8
+ type: 'string',
9
+ description: 'The reason for the escalation necessity.',
10
+ },
11
+ shouldEscalate: {
12
+ type: 'number',
13
+ description: 'A number that expresses the escalation necessity: 0 - no need to escalate, 100 - absolutely need to escalate to more advanced model.',
14
+ minimum: 0,
15
+ maximum: 100,
16
+ },
17
+ },
18
+ required: ['reason', 'shouldEscalate'],
19
+ },
20
+ };
21
+ //# sourceMappingURL=ask-question-reflect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask-question-reflect.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/ask-question-reflect.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,yFAAyF;IACtG,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0CAA0C;aACxD;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,sIAAsI;gBACxI,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;aACb;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC;KACvC;CACO,CAAC"}
@@ -1,19 +1,23 @@
1
1
  /**
2
2
  * Function definition for askQuestion
3
+ *
4
+ * Use this function to ask questions, seek clarification, request file permissions, or manage the flow of the conversation.
5
+ * Each actionType serves a specific purpose, ensuring clarity and proper task execution.
3
6
  */
4
7
  export declare const askQuestion: {
5
8
  readonly name: "askQuestion";
6
- readonly description: "Use this function to ask a question or seek clarification from the user if needed. If you have all the necessary information and are ready to proceed, do not call this function.";
9
+ readonly description: "Use this function to ask a question, seek clarification, or manage the flow of the conversation. For analysis requests, use actionType \"requestAnswer\". Only proceed to code generation when explicitly instructed or after confirmation.";
7
10
  readonly parameters: {
8
11
  readonly type: "object";
9
12
  readonly properties: {
10
- readonly content: {
13
+ readonly actionType: {
11
14
  readonly type: "string";
12
- readonly description: "The message you want to display to the user. It can be a question if you need more information, or a confirmation/acknowledgment if you are proceeding without needing a response.";
15
+ readonly enum: readonly ["requestAnswer", "requestPermissions", "requestFilesContent", "removeFilesFromContext", "confirmCodeGeneration", "startCodeGeneration", "cancelCodeGeneration", "contextOptimization"];
16
+ readonly description: "This value instructs the program on what should happen next. Use \"requestAnswer\" for analysis requests or clarifications.,\n\n Detailed Explanation of actionTypes:\n - requestAnswer: Use for general information, clarifications, or when no specific code is needed.\n - requestPermissions: Use when additional permissions are required for actions like creating or deleting files.\n - requestFilesContent: Use specifically when needing to access or review the contents of files.\n - removeFilesFromContext: Use to remove unnecessary file contents from context, optimizing token usage.\n - confirmCodeGeneration: Use to confirm with the user before starting code generation tasks.\n - startCodeGeneration: Use only after receiving confirmation to begin code generation.\n - cancelCodeGeneration: Use if code generation should be stopped or canceled.\n - contextOptimization: Use to manage and optimize context during code generation tasks, allowing the LLM to provide guidance on what parts of the context are most relevant to keep.\n ";
13
17
  };
14
- readonly shouldPrompt: {
15
- readonly type: "boolean";
16
- readonly description: "Set to true **only if** you require a response from the user before proceeding. Set to false if you do not require a response and are ready to proceed with the task.";
18
+ readonly content: {
19
+ readonly type: "string";
20
+ readonly description: "The message you want to display to the user. It can be a question if you need more information, an analysis result, or a confirmation request before proceeding with code generation.";
17
21
  };
18
22
  readonly promptNecessity: {
19
23
  readonly type: "number";
@@ -21,10 +25,6 @@ export declare const askQuestion: {
21
25
  readonly maximum: 100;
22
26
  readonly description: "Indicates how strongly you need a response from the user. A higher value means a stronger need for user input.";
23
27
  };
24
- readonly stopCodegen: {
25
- readonly type: "boolean";
26
- readonly description: "Set to true if you want to stop the code generation process without error. Use this when you cannot proceed due to insufficient information or other issues.";
27
- };
28
28
  readonly requestFilesContent: {
29
29
  readonly type: "array";
30
30
  readonly description: "An array of absolute file paths for which you need the content. Use this when specific files are missing and you need them to proceed with the task.";
@@ -32,6 +32,17 @@ export declare const askQuestion: {
32
32
  readonly type: "string";
33
33
  };
34
34
  };
35
+ readonly removeFilesFromContext: {
36
+ readonly type: "array";
37
+ readonly description: "An array of absolute file paths that should be removed from the context. Use this to optimize token usage by removing unnecessary file contents.";
38
+ readonly items: {
39
+ readonly type: "string";
40
+ };
41
+ };
42
+ readonly contextOptimization: {
43
+ readonly type: "string";
44
+ readonly description: "A prompt generated to guide the LLM in optimizing context by specifying which parts of the context are most relevant to keep. This helps in efficient management during code generation tasks.";
45
+ };
35
46
  readonly requestPermissions: {
36
47
  readonly type: "object";
37
48
  readonly description: "Use this to request additional permissions needed for code generation if they are not already granted.";
@@ -63,6 +74,6 @@ export declare const askQuestion: {
63
74
  };
64
75
  };
65
76
  };
66
- readonly required: readonly ["content", "shouldPrompt", "promptNecessity", "stopCodegen"];
77
+ readonly required: readonly ["actionType", "content", "promptNecessity"];
67
78
  };
68
79
  };
@@ -1,19 +1,43 @@
1
1
  /**
2
2
  * Function definition for askQuestion
3
+ *
4
+ * Use this function to ask questions, seek clarification, request file permissions, or manage the flow of the conversation.
5
+ * Each actionType serves a specific purpose, ensuring clarity and proper task execution.
3
6
  */
4
7
  export const askQuestion = {
5
8
  name: 'askQuestion',
6
- description: 'Use this function to ask a question or seek clarification from the user if needed. If you have all the necessary information and are ready to proceed, do not call this function.',
9
+ description: 'Use this function to ask a question, seek clarification, or manage the flow of the conversation. For analysis requests, use actionType "requestAnswer". Only proceed to code generation when explicitly instructed or after confirmation.',
7
10
  parameters: {
8
11
  type: 'object',
9
12
  properties: {
10
- content: {
13
+ actionType: {
11
14
  type: 'string',
12
- description: 'The message you want to display to the user. It can be a question if you need more information, or a confirmation/acknowledgment if you are proceeding without needing a response.',
15
+ enum: [
16
+ 'requestAnswer',
17
+ 'requestPermissions',
18
+ 'requestFilesContent',
19
+ 'removeFilesFromContext',
20
+ 'confirmCodeGeneration',
21
+ 'startCodeGeneration',
22
+ 'cancelCodeGeneration',
23
+ 'contextOptimization',
24
+ ],
25
+ description: `This value instructs the program on what should happen next. Use "requestAnswer" for analysis requests or clarifications.,
26
+
27
+ Detailed Explanation of actionTypes:
28
+ - requestAnswer: Use for general information, clarifications, or when no specific code is needed.
29
+ - requestPermissions: Use when additional permissions are required for actions like creating or deleting files.
30
+ - requestFilesContent: Use specifically when needing to access or review the contents of files.
31
+ - removeFilesFromContext: Use to remove unnecessary file contents from context, optimizing token usage.
32
+ - confirmCodeGeneration: Use to confirm with the user before starting code generation tasks.
33
+ - startCodeGeneration: Use only after receiving confirmation to begin code generation.
34
+ - cancelCodeGeneration: Use if code generation should be stopped or canceled.
35
+ - contextOptimization: Use to manage and optimize context during code generation tasks, allowing the LLM to provide guidance on what parts of the context are most relevant to keep.
36
+ `,
13
37
  },
14
- shouldPrompt: {
15
- type: 'boolean',
16
- description: 'Set to true **only if** you require a response from the user before proceeding. Set to false if you do not require a response and are ready to proceed with the task.',
38
+ content: {
39
+ type: 'string',
40
+ description: 'The message you want to display to the user. It can be a question if you need more information, an analysis result, or a confirmation request before proceeding with code generation.',
17
41
  },
18
42
  promptNecessity: {
19
43
  type: 'number',
@@ -21,10 +45,6 @@ export const askQuestion = {
21
45
  maximum: 100,
22
46
  description: 'Indicates how strongly you need a response from the user. A higher value means a stronger need for user input.',
23
47
  },
24
- stopCodegen: {
25
- type: 'boolean',
26
- description: 'Set to true if you want to stop the code generation process without error. Use this when you cannot proceed due to insufficient information or other issues.',
27
- },
28
48
  requestFilesContent: {
29
49
  type: 'array',
30
50
  description: 'An array of absolute file paths for which you need the content. Use this when specific files are missing and you need them to proceed with the task.',
@@ -32,6 +52,17 @@ export const askQuestion = {
32
52
  type: 'string',
33
53
  },
34
54
  },
55
+ removeFilesFromContext: {
56
+ type: 'array',
57
+ description: 'An array of absolute file paths that should be removed from the context. Use this to optimize token usage by removing unnecessary file contents.',
58
+ items: {
59
+ type: 'string',
60
+ },
61
+ },
62
+ contextOptimization: {
63
+ type: 'string',
64
+ description: 'A prompt generated to guide the LLM in optimizing context by specifying which parts of the context are most relevant to keep. This helps in efficient management during code generation tasks.',
65
+ },
35
66
  requestPermissions: {
36
67
  type: 'object',
37
68
  description: 'Use this to request additional permissions needed for code generation if they are not already granted.',
@@ -63,7 +94,7 @@ export const askQuestion = {
63
94
  },
64
95
  },
65
96
  },
66
- required: ['content', 'shouldPrompt', 'promptNecessity', 'stopCodegen'],
97
+ required: ['actionType', 'content', 'promptNecessity'],
67
98
  },
68
99
  };
69
100
  //# sourceMappingURL=ask-question.js.map
@@ -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,mLAAmL;IACrL,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,oLAAoL;aACvL;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,SAAS;gBACf,WAAW,EACT,uKAAuK;aAC1K;YACD,eAAe,EAAE;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;gBACZ,WAAW,EACT,gHAAgH;aACnH;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,SAAS;gBACf,WAAW,EACT,8JAA8J;aACjK;YACD,mBAAmB,EAAE;gBACnB,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,sJAAsJ;gBACxJ,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,kBAAkB,EAAE;gBAClB,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,wGAAwG;gBAC1G,UAAU,EAAE;oBACV,oBAAoB,EAAE;wBACpB,WAAW,EAAE,6DAA6D;wBAC1E,IAAI,EAAE,SAAS;qBAChB;oBACD,eAAe,EAAE;wBACf,WAAW,EAAE,uDAAuD;wBACpE,IAAI,EAAE,SAAS;qBAChB;oBACD,eAAe,EAAE;wBACf,WAAW,EAAE,uDAAuD;wBACpE,IAAI,EAAE,SAAS;qBAChB;oBACD,aAAa,EAAE;wBACb,WAAW,EAAE,qDAAqD;wBAClE,IAAI,EAAE,SAAS;qBAChB;oBACD,YAAY,EAAE;wBACZ,WAAW,EACT,yGAAyG;wBAC3G,IAAI,EAAE,SAAS;qBAChB;oBACD,YAAY,EAAE;wBACZ,WAAW,EAAE,0DAA0D;wBACvE,IAAI,EAAE,SAAS;qBAChB;iBACF;aACF;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;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,2OAA2O;IAC7O,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE;oBACJ,eAAe;oBACf,oBAAoB;oBACpB,qBAAqB;oBACrB,wBAAwB;oBACxB,uBAAuB;oBACvB,qBAAqB;oBACrB,sBAAsB;oBACtB,qBAAqB;iBACtB;gBACD,WAAW,EAAE;;;;;;;;;;;SAWZ;aACF;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,uLAAuL;aAC1L;YACD,eAAe,EAAE;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;gBACZ,WAAW,EACT,gHAAgH;aACnH;YACD,mBAAmB,EAAE;gBACnB,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,sJAAsJ;gBACxJ,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,sBAAsB,EAAE;gBACtB,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,kJAAkJ;gBACpJ,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,mBAAmB,EAAE;gBACnB,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,gMAAgM;aACnM;YACD,kBAAkB,EAAE;gBAClB,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,wGAAwG;gBAC1G,UAAU,EAAE;oBACV,oBAAoB,EAAE;wBACpB,WAAW,EAAE,6DAA6D;wBAC1E,IAAI,EAAE,SAAS;qBAChB;oBACD,eAAe,EAAE;wBACf,WAAW,EAAE,uDAAuD;wBACpE,IAAI,EAAE,SAAS;qBAChB;oBACD,eAAe,EAAE;wBACf,WAAW,EAAE,uDAAuD;wBACpE,IAAI,EAAE,SAAS;qBAChB;oBACD,aAAa,EAAE;wBACb,WAAW,EAAE,qDAAqD;wBAClE,IAAI,EAAE,SAAS;qBAChB;oBACD,YAAY,EAAE;wBACZ,WAAW,EACT,yGAAyG;wBAC3G,IAAI,EAAE,SAAS;qBAChB;oBACD,YAAY,EAAE;wBACZ,WAAW,EAAE,0DAA0D;wBACvE,IAAI,EAAE,SAAS;qBAChB;iBACF;aACF;SACF;QACD,QAAQ,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,iBAAiB,CAAC;KACvD;CACO,CAAC"}
@@ -13,12 +13,12 @@ export declare const codegenSummary: {
13
13
  };
14
14
  readonly fileUpdates: {
15
15
  readonly type: "array";
16
- readonly description: "An array of proposed file updates. Each update is an object with several properties.";
16
+ readonly description: "An array of proposed file updates, each update is an object with several properties.";
17
17
  readonly items: {
18
18
  readonly type: "object";
19
19
  readonly description: "An object representing a proposed update to a file, containing properties like the absolute file path, the update tool name, and other important properties.";
20
20
  readonly properties: {
21
- readonly path: {
21
+ readonly filePath: {
22
22
  readonly type: "string";
23
23
  readonly description: "An absolute path of the project file that will be updated. This must be an absolute file path.";
24
24
  };
@@ -49,7 +49,7 @@ export declare const codegenSummary: {
49
49
  };
50
50
  };
51
51
  };
52
- readonly required: readonly ["path", "prompt", "updateToolName"];
52
+ readonly required: readonly ["filePath", "prompt", "updateToolName"];
53
53
  };
54
54
  };
55
55
  readonly contextPaths: {
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const codegenSummary = {
5
5
  name: 'codegenSummary',
6
- description: 'This function is called with a summary of proposed updates. The summary is an object containing:\n' +
6
+ description: 'This function is called with a summary of proposed updates.\n' +
7
7
  '- `explanation`: A general explanation of the planned code generation updates or reasoning for no code changes.\n' +
8
8
  '- `fileUpdates`: A list of proposed file updates that will be subject to subsequent code generation requests.\n' +
9
9
  '- `contextPaths`: A list of file paths that make sense to use as context for code generation requests.\n' +
@@ -17,12 +17,12 @@ export const codegenSummary = {
17
17
  },
18
18
  fileUpdates: {
19
19
  type: 'array',
20
- description: 'An array of proposed file updates. Each update is an object with several properties.',
20
+ description: 'An array of proposed file updates, each update is an object with several properties.',
21
21
  items: {
22
22
  type: 'object',
23
23
  description: 'An object representing a proposed update to a file, containing properties like the absolute file path, the update tool name, and other important properties.',
24
24
  properties: {
25
- path: {
25
+ filePath: {
26
26
  type: 'string',
27
27
  description: 'An absolute path of the project file that will be updated. This must be an absolute file path.',
28
28
  },
@@ -63,7 +63,7 @@ export const codegenSummary = {
63
63
  items: { type: 'string' },
64
64
  },
65
65
  },
66
- required: ['path', 'prompt', 'updateToolName'],
66
+ required: ['filePath', 'prompt', 'updateToolName'],
67
67
  },
68
68
  },
69
69
  contextPaths: {
@@ -1 +1 @@
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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AO;gBACb,WAAW,EACT,gLAAgL;gBAClL,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;SACF;QACD,QAAQ,EAAE,CAAC,aAAa,EAAE,aAAa,EAAE,cAAc,CAAC;KACzD;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,+DAA+D;QAC/D,mHAAmH;QACnH,iHAAiH;QACjH,0GAA0G;QAC1G,mEAAmE;IACrE,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0FAA0F;aACxG;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,sFAAsF;gBACnG,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,8JAA8J;oBAChK,UAAU,EAAE;wBACV,QAAQ,EAAE;4BACR,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,gGAAgG;yBACnG;wBACD,MAAM,EAAE;4BACN,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,wJAAwJ;yBAC3J;wBACD,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,+DAA+D;yBAC7E;wBACD,WAAW,EAAE;4BACX,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,oIAAoI;4BACtI,OAAO,EAAE,GAAG;4BACZ,OAAO,EAAE,GAAG;yBACb;wBACD,KAAK,EAAE;4BACL,IAAI,EAAE,SAAS;4BACf,WAAW,EACT,4JAA4J;yBAC/J;wBACD,kBAAkB,EAAE;4BAClB,IAAI,EAAE,OAAO;4BACb,WAAW,EACT,8JAA8J;4BAChK,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;yBAC1B;qBACF;oBACD,QAAQ,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,gBAAgB,CAAC;iBACnD;aACF;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,gLAAgL;gBAClL,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;SACF;QACD,QAAQ,EAAE,CAAC,aAAa,EAAE,aAAa,EAAE,cAAc,CAAC;KACzD;CACO,CAAC"}
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export declare const optimizeContext: {
5
5
  readonly name: "optimizeContext";
6
- readonly description: "Analyzes each file to provide a brief summary and rate its relevance to the user's prompt on a scale of 0 to 1.";
6
+ readonly description: "This function narrows the context of code generation to a list of relevant files, including their estimated token counts and relevance scores. It helps prioritize files based on their importance to the user prompt and manages token usage.";
7
7
  readonly parameters: {
8
8
  readonly type: "object";
9
9
  readonly properties: {
@@ -13,29 +13,34 @@ export declare const optimizeContext: {
13
13
  };
14
14
  readonly optimizedContext: {
15
15
  readonly type: "array";
16
- readonly description: "An array of results, each corresponding to an analyzed file, containing the file path, a brief summary, and a relevance score.";
16
+ readonly description: "An array of objects representing relevant files, their relevance scores, and token counts.";
17
17
  readonly items: {
18
18
  readonly type: "object";
19
19
  readonly properties: {
20
- readonly path: {
20
+ readonly filePath: {
21
21
  readonly type: "string";
22
- readonly description: "The file path of the analyzed file, matching the 'path' provided in the input.";
23
- };
24
- readonly summary: {
25
- readonly type: "string";
26
- readonly description: "A concise one-sentence summary of the file's content, highlighting its main purpose or functionality.";
22
+ readonly description: "The absolute file path of a relevant file.";
27
23
  };
28
24
  readonly relevance: {
29
25
  readonly type: "number";
30
- readonly description: "A numeric score between 0 and 1 indicating the file's relevance to the user's prompt. A score of 0 means not relevant at all, while a score of 1 means highly relevant.";
26
+ readonly description: "A score from 0 to 1 indicating the relevance of the file to the user prompt.";
31
27
  readonly minimum: 0;
32
28
  readonly maximum: 1;
33
29
  };
30
+ readonly tokenCount: {
31
+ readonly type: "integer";
32
+ readonly description: "The estimated token count for the file content.";
33
+ readonly minimum: 0;
34
+ };
34
35
  };
35
- readonly required: readonly ["path", "summary", "relevance"];
36
+ readonly required: readonly ["filePath", "relevance", "tokenCount"];
36
37
  };
37
38
  };
39
+ readonly totalTokenCount: {
40
+ readonly type: "number";
41
+ readonly description: "The estimated token count for the entire context.";
42
+ };
38
43
  };
39
- readonly required: readonly ["userPrompt", "optimizedContext"];
44
+ readonly required: readonly ["userPrompt", "optimizedContext", "totalTokenCount"];
40
45
  };
41
46
  };
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const optimizeContext = {
5
5
  name: 'optimizeContext',
6
- description: "Analyzes each file to provide a brief summary and rate its relevance to the user's prompt on a scale of 0 to 1.",
6
+ description: 'This function narrows the context of code generation to a list of relevant files, including their estimated token counts and relevance scores. It helps prioritize files based on their importance to the user prompt and manages token usage.',
7
7
  parameters: {
8
8
  type: 'object',
9
9
  properties: {
@@ -13,30 +13,35 @@ export const optimizeContext = {
13
13
  },
14
14
  optimizedContext: {
15
15
  type: 'array',
16
- description: 'An array of results, each corresponding to an analyzed file, containing the file path, a brief summary, and a relevance score.',
16
+ description: 'An array of objects representing relevant files, their relevance scores, and token counts.',
17
17
  items: {
18
18
  type: 'object',
19
19
  properties: {
20
- path: {
20
+ filePath: {
21
21
  type: 'string',
22
- description: "The file path of the analyzed file, matching the 'path' provided in the input.",
23
- },
24
- summary: {
25
- type: 'string',
26
- description: "A concise one-sentence summary of the file's content, highlighting its main purpose or functionality.",
22
+ description: 'The absolute file path of a relevant file.',
27
23
  },
28
24
  relevance: {
29
25
  type: 'number',
30
- description: "A numeric score between 0 and 1 indicating the file's relevance to the user's prompt. A score of 0 means not relevant at all, while a score of 1 means highly relevant.",
26
+ description: 'A score from 0 to 1 indicating the relevance of the file to the user prompt.',
31
27
  minimum: 0,
32
28
  maximum: 1,
33
29
  },
30
+ tokenCount: {
31
+ type: 'integer',
32
+ description: 'The estimated token count for the file content.',
33
+ minimum: 0,
34
+ },
34
35
  },
35
- required: ['path', 'summary', 'relevance'],
36
+ required: ['filePath', 'relevance', 'tokenCount'],
36
37
  },
37
38
  },
39
+ totalTokenCount: {
40
+ type: 'number',
41
+ description: 'The estimated token count for the entire context.',
42
+ },
38
43
  },
39
- required: ['userPrompt', 'optimizedContext'],
44
+ required: ['userPrompt', 'optimizedContext', 'totalTokenCount'],
40
45
  },
41
46
  };
42
47
  //# sourceMappingURL=optimize-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"optimize-context.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/optimize-context.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,iHAAiH;IACnH,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6BAA6B;aAC3C;YACD,gBAAgB,EAAE;gBAChB,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,gIAAgI;gBAClI,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE;4BACJ,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,gFAAgF;yBAC9F;wBACD,OAAO,EAAE;4BACP,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,uGAAuG;yBAC1G;wBACD,SAAS,EAAE;4BACT,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,yKAAyK;4BAC3K,OAAO,EAAE,CAAC;4BACV,OAAO,EAAE,CAAC;yBACX;qBACF;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC;iBAC3C;aACF;SACF;QACD,QAAQ,EAAE,CAAC,YAAY,EAAE,kBAAkB,CAAC;KAC7C;CACO,CAAC"}
1
+ {"version":3,"file":"optimize-context.js","sourceRoot":"","sources":["../../../src/prompt/function-defs/optimize-context.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,gPAAgP;IAClP,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6BAA6B;aAC3C;YACD,gBAAgB,EAAE;gBAChB,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,4FAA4F;gBACzG,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,QAAQ,EAAE;4BACR,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,4CAA4C;yBAC1D;wBACD,SAAS,EAAE;4BACT,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,8EAA8E;4BAC3F,OAAO,EAAE,CAAC;4BACV,OAAO,EAAE,CAAC;yBACX;wBACD,UAAU,EAAE;4BACV,IAAI,EAAE,SAAS;4BACf,WAAW,EAAE,iDAAiD;4BAC9D,OAAO,EAAE,CAAC;yBACX;qBACF;oBACD,QAAQ,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,YAAY,CAAC;iBAClD;aACF;YACD,eAAe,EAAE;gBACf,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mDAAmD;aACjE;SACF;QACD,QAAQ,EAAE,CAAC,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,CAAC;KAChE;CACO,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare const readHistory: {
2
+ name: string;
3
+ description: string;
4
+ parameters: {
5
+ type: string;
6
+ properties: {
7
+ dateTime: {
8
+ type: string;
9
+ };
10
+ };
11
+ required: never[];
12
+ };
13
+ };