@ai-dev-tools/csharp-copilot-core 0.0.31 → 0.0.32

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 (309) hide show
  1. package/out/analyze/cecil.d.ts +1 -0
  2. package/out/analyze/cecil.js +42 -0
  3. package/out/analyze/cecil.js.map +1 -0
  4. package/out/analyze/checkCodeSyntax.d.ts +7 -0
  5. package/out/analyze/checkCodeSyntax.js +67 -0
  6. package/out/analyze/checkCodeSyntax.js.map +1 -0
  7. package/out/analyze/generateCodeDependency.d.ts +6 -0
  8. package/out/analyze/generateCodeDependency.js +127 -0
  9. package/out/analyze/generateCodeDependency.js.map +1 -0
  10. package/out/analyze/installAnalyzerTool.d.ts +1 -0
  11. package/out/analyze/installAnalyzerTool.js +83 -0
  12. package/out/analyze/installAnalyzerTool.js.map +1 -0
  13. package/out/batch/generateCodeTests.d.ts +6 -0
  14. package/out/batch/generateCodeTests.js +163 -0
  15. package/out/batch/generateCodeTests.js.map +1 -0
  16. package/out/batch/getFolderCodeFile.d.ts +1 -0
  17. package/out/batch/getFolderCodeFile.js +19 -0
  18. package/out/batch/getFolderCodeFile.js.map +1 -0
  19. package/out/batch/getProjectCodeFile.d.ts +4 -0
  20. package/out/batch/getProjectCodeFile.js +86 -0
  21. package/out/batch/getProjectCodeFile.js.map +1 -0
  22. package/out/batch/getSolutionCodeFile.d.ts +8 -0
  23. package/out/batch/getSolutionCodeFile.js +70 -0
  24. package/out/batch/getSolutionCodeFile.js.map +1 -0
  25. package/out/benchmark/formatToMarkdown.d.ts +2 -0
  26. package/out/benchmark/formatToMarkdown.js +101 -0
  27. package/out/benchmark/formatToMarkdown.js.map +1 -0
  28. package/out/benchmark/generateBenchmarkReport.d.ts +1 -0
  29. package/out/benchmark/generateBenchmarkReport.js +82 -0
  30. package/out/benchmark/generateBenchmarkReport.js.map +1 -0
  31. package/out/codeCoverage/codeCoverage.d.ts +6 -0
  32. package/out/codeCoverage/codeCoverage.js +39 -0
  33. package/out/codeCoverage/codeCoverage.js.map +1 -0
  34. package/out/codeCoverage/codeCoverageReport.d.ts +6 -0
  35. package/out/codeCoverage/codeCoverageReport.js +76 -0
  36. package/out/codeCoverage/codeCoverageReport.js.map +1 -0
  37. package/out/codeCoverage/extractCodeCoverageInfo.d.ts +2 -0
  38. package/out/codeCoverage/extractCodeCoverageInfo.js +81 -0
  39. package/out/codeCoverage/extractCodeCoverageInfo.js.map +1 -0
  40. package/out/codeCoverage/extractCoverageReportPath.d.ts +1 -0
  41. package/out/codeCoverage/extractCoverageReportPath.js +25 -0
  42. package/out/codeCoverage/extractCoverageReportPath.js.map +1 -0
  43. package/out/codeCoverage/generateCodeCoverageReport.d.ts +1 -0
  44. package/out/codeCoverage/generateCodeCoverageReport.js +30 -0
  45. package/out/codeCoverage/generateCodeCoverageReport.js.map +1 -0
  46. package/out/codeCoverage/getCodeCoverageSetting.d.ts +1 -0
  47. package/out/codeCoverage/getCodeCoverageSetting.js +58 -0
  48. package/out/codeCoverage/getCodeCoverageSetting.js.map +1 -0
  49. package/out/codeCoverage/reportTool.d.ts +2 -0
  50. package/out/codeCoverage/reportTool.js +23 -0
  51. package/out/codeCoverage/reportTool.js.map +1 -0
  52. package/out/codeCoverage/simplifyCoverageXml.d.ts +2 -0
  53. package/out/codeCoverage/simplifyCoverageXml.js +117 -0
  54. package/out/codeCoverage/simplifyCoverageXml.js.map +1 -0
  55. package/out/codebk/250804prompt/buildAfGuidelines.liquid +15 -0
  56. package/out/codebk/250804prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
  57. package/out/codebk/250804prompt/general/generalUtGuidelines.liquid +18 -0
  58. package/out/codebk/250804prompt/generateUtAutoFix.liquid +19 -0
  59. package/out/codebk/250804prompt/generateUtGuidelines.liquid +13 -0
  60. package/out/codebk/250804prompt/generateUtSystem.liquid +5 -0
  61. package/out/codebk/250804prompt/generateUtUserInput.liquid +27 -0
  62. package/out/codebk/250804prompt/testAfGuidelines.liquid +6 -0
  63. package/out/codebk/250804prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
  64. package/out/codebk/250804prompt/xap/xapCodeCodeDependency.liquid +0 -0
  65. package/out/codebk/250804prompt/xap/xapCodeSample.liquid +38 -0
  66. package/out/codebk/250804prompt/xap/xapUtGuideline-240804.liquid +36 -0
  67. package/out/codebk/250804prompt/xap/xapUtGuideline.liquid +36 -0
  68. package/out/codebk/childProcessManager.d.ts +1 -0
  69. package/out/codebk/childProcessManager.js +50 -0
  70. package/out/codebk/childProcessManager.js.map +1 -0
  71. package/out/codebk/msBuidSpawn.d.ts +1 -0
  72. package/out/codebk/msBuidSpawn.js +58 -0
  73. package/out/codebk/msBuidSpawn.js.map +1 -0
  74. package/out/codebk/msBuild.d.ts +1 -0
  75. package/out/codebk/msBuild.js +123 -0
  76. package/out/codebk/msBuild.js.map +1 -0
  77. package/out/codebk/old/generateXapTestAutoFix.liquid +12 -0
  78. package/out/codebk/old/generateXapTestGuidelines-fm.liquid +68 -0
  79. package/out/codebk/old/generateXapTestGuidelines.liquid +28 -0
  80. package/out/codebk/old/xapGuideline-fm.liquid +149 -0
  81. package/out/codebk/old/xapGuideline.liquid +37 -0
  82. package/out/codebk/oldExec/checkCodeSyntax.d.ts +1 -0
  83. package/out/codebk/oldExec/checkCodeSyntax.js +81 -0
  84. package/out/codebk/oldExec/checkCodeSyntax.js.map +1 -0
  85. package/out/codebk/oldExec/codeCoverage.d.ts +1 -0
  86. package/out/codebk/oldExec/codeCoverage.js +54 -0
  87. package/out/codebk/oldExec/codeCoverage.js.map +1 -0
  88. package/out/codebk/oldExec/codeCoverageReport.d.ts +1 -0
  89. package/out/codebk/oldExec/codeCoverageReport.js +64 -0
  90. package/out/codebk/oldExec/codeCoverageReport.js.map +1 -0
  91. package/out/codebk/oldExec/containsMethods.d.ts +1 -0
  92. package/out/codebk/oldExec/containsMethods.js +74 -0
  93. package/out/codebk/oldExec/containsMethods.js.map +1 -0
  94. package/out/codebk/oldExec/generateCodeDependency.d.ts +1 -0
  95. package/out/codebk/oldExec/generateCodeDependency.js +95 -0
  96. package/out/codebk/oldExec/generateCodeDependency.js.map +1 -0
  97. package/out/codebk/oldExec/msBuild.d.ts +1 -0
  98. package/out/codebk/oldExec/msBuild.js +53 -0
  99. package/out/codebk/oldExec/msBuild.js.map +1 -0
  100. package/out/codebk/oldExec/vsTest.d.ts +1 -0
  101. package/out/codebk/oldExec/vsTest.js +71 -0
  102. package/out/codebk/oldExec/vsTest.js.map +1 -0
  103. package/out/codebk/prompts/general/generalUnitTestGuidelines-20250702.liquid +56 -0
  104. package/out/codebk/prompts/generateXapTestGuidelines-20250704.liquid +21 -0
  105. package/out/codebk/prompts/generateXapTestGuidelines-o.liquid +29 -0
  106. package/out/codebk/prompts/xap/xapGuideline-o.liquid +45 -0
  107. package/out/codebk/testbuildkill.d.ts +1 -0
  108. package/out/codebk/testbuildkill.js +37 -0
  109. package/out/codebk/testbuildkill.js.map +1 -0
  110. package/out/command/index.d.ts +2 -0
  111. package/out/command/index.js +90 -0
  112. package/out/command/index.js.map +1 -0
  113. package/out/command/utGenWrapper.d.ts +3 -0
  114. package/out/command/utGenWrapper.js +53 -0
  115. package/out/command/utGenWrapper.js.map +1 -0
  116. package/out/exit/childProcessManager.d.ts +2 -0
  117. package/out/exit/childProcessManager.js +43 -0
  118. package/out/exit/childProcessManager.js.map +1 -0
  119. package/out/exit/setupProcessSignalHandler.d.ts +1 -0
  120. package/out/exit/setupProcessSignalHandler.js +18 -0
  121. package/out/exit/setupProcessSignalHandler.js.map +1 -0
  122. package/out/gen/autoFix.d.ts +4 -0
  123. package/out/gen/autoFix.js +129 -0
  124. package/out/gen/autoFix.js.map +1 -0
  125. package/out/gen/csharpUtGen.d.ts +2 -0
  126. package/out/gen/csharpUtGen.js +125 -0
  127. package/out/gen/csharpUtGen.js.map +1 -0
  128. package/out/gen/ensureValidLLMResponse.d.ts +1 -0
  129. package/out/gen/ensureValidLLMResponse.js +19 -0
  130. package/out/gen/ensureValidLLMResponse.js.map +1 -0
  131. package/out/gen/postGen/addAiAnnotation.d.ts +1 -0
  132. package/out/gen/postGen/addAiAnnotation.js +57 -0
  133. package/out/gen/postGen/addAiAnnotation.js.map +1 -0
  134. package/out/gen/postGen/extractCodeFromResponse.d.ts +1 -0
  135. package/out/gen/postGen/extractCodeFromResponse.js +38 -0
  136. package/out/gen/postGen/extractCodeFromResponse.js.map +1 -0
  137. package/out/gen/postGen/postGenProcess.d.ts +1 -0
  138. package/out/gen/postGen/postGenProcess.js +39 -0
  139. package/out/gen/postGen/postGenProcess.js.map +1 -0
  140. package/out/gen/postGen/removeComments.d.ts +1 -0
  141. package/out/gen/postGen/removeComments.js +92 -0
  142. package/out/gen/postGen/removeComments.js.map +1 -0
  143. package/out/gen/postGen/removeSingleLines.d.ts +1 -0
  144. package/out/gen/postGen/removeSingleLines.js +29 -0
  145. package/out/gen/postGen/removeSingleLines.js.map +1 -0
  146. package/out/gen/postGen/repairRequiredNameSpaces.d.ts +2 -0
  147. package/out/gen/postGen/repairRequiredNameSpaces.js +142 -0
  148. package/out/gen/postGen/repairRequiredNameSpaces.js.map +1 -0
  149. package/out/gen/postGen/validateTestCode.d.ts +1 -0
  150. package/out/gen/postGen/validateTestCode.js +14 -0
  151. package/out/gen/postGen/validateTestCode.js.map +1 -0
  152. package/out/gen/preGen/excludeFileName.d.ts +1 -0
  153. package/out/gen/preGen/excludeFileName.js +49 -0
  154. package/out/gen/preGen/excludeFileName.js.map +1 -0
  155. package/out/gen/preGen/excludeSpecificTag.d.ts +1 -0
  156. package/out/gen/preGen/excludeSpecificTag.js +19 -0
  157. package/out/gen/preGen/excludeSpecificTag.js.map +1 -0
  158. package/out/gen/preGen/preGenProcess.d.ts +1 -0
  159. package/out/gen/preGen/preGenProcess.js +22 -0
  160. package/out/gen/preGen/preGenProcess.js.map +1 -0
  161. package/out/gen/preGen/validateCode.d.ts +3 -0
  162. package/out/gen/preGen/validateCode.js +63 -0
  163. package/out/gen/preGen/validateCode.js.map +1 -0
  164. package/out/index.d.ts +3 -0
  165. package/out/index.js +10 -0
  166. package/out/index.js.map +1 -0
  167. package/out/llm/model/Gpt.d.ts +1 -0
  168. package/out/llm/model/Gpt.js +93 -0
  169. package/out/llm/model/Gpt.js.map +1 -0
  170. package/out/llm/preparePrompt.d.ts +2 -0
  171. package/out/llm/preparePrompt.js +135 -0
  172. package/out/llm/preparePrompt.js.map +1 -0
  173. package/out/llm/prompt/buildAfGuidelines.liquid +15 -0
  174. package/out/llm/prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
  175. package/out/llm/prompt/general/generalUtGuidelines.liquid +16 -0
  176. package/out/llm/prompt/generateUtAutoFix.liquid +23 -0
  177. package/out/llm/prompt/generateUtDependency.liquid +3 -0
  178. package/out/llm/prompt/generateUtSystem.liquid +5 -0
  179. package/out/llm/prompt/generateUtTemplate.liquid +32 -0
  180. package/out/llm/prompt/generateUtUserInput.liquid +4 -0
  181. package/out/llm/prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
  182. package/out/llm/prompt/xap/xapCodeCodeDependency.liquid +0 -0
  183. package/out/llm/prompt/xap/xapCodeSample.liquid +38 -0
  184. package/out/llm/prompt/xap/xapUtGuideline.liquid +37 -0
  185. package/out/llm/sendRequestToLLM.d.ts +4 -0
  186. package/out/llm/sendRequestToLLM.js +9 -0
  187. package/out/llm/sendRequestToLLM.js.map +1 -0
  188. package/out/llm/sendRequestToSelfHostLLM.d.ts +4 -0
  189. package/out/llm/sendRequestToSelfHostLLM.js +41 -0
  190. package/out/llm/sendRequestToSelfHostLLM.js.map +1 -0
  191. package/out/metrics/appInsightTelemetry.d.ts +6 -0
  192. package/out/metrics/appInsightTelemetry.js +77 -0
  193. package/out/metrics/appInsightTelemetry.js.map +1 -0
  194. package/out/metrics/machineId.d.ts +11 -0
  195. package/out/metrics/machineId.js +85 -0
  196. package/out/metrics/machineId.js.map +1 -0
  197. package/out/setup/setup.d.ts +1 -0
  198. package/out/setup/setup.js +10 -0
  199. package/out/setup/setup.js.map +1 -0
  200. package/out/setup/setupConsole.d.ts +1 -0
  201. package/out/setup/setupConsole.js +23 -0
  202. package/out/setup/setupConsole.js.map +1 -0
  203. package/out/setup/setupLLMRequest.d.ts +2 -0
  204. package/out/setup/setupLLMRequest.js +10 -0
  205. package/out/setup/setupLLMRequest.js.map +1 -0
  206. package/out/tools/devenvcom.cmd +13 -0
  207. package/out/tools/devenvexe.cmd +13 -0
  208. package/out/tools/msbuildexe.cmd +13 -0
  209. package/out/tools/vstestexe.cmd +13 -0
  210. package/out/types/benchmark.d.ts +11 -0
  211. package/out/types/benchmark.js +3 -0
  212. package/out/types/benchmark.js.map +1 -0
  213. package/out/types/buildResult.d.ts +8 -0
  214. package/out/types/buildResult.js +3 -0
  215. package/out/types/buildResult.js.map +1 -0
  216. package/out/types/constants.d.ts +10 -0
  217. package/out/types/constants.js +14 -0
  218. package/out/types/constants.js.map +1 -0
  219. package/out/types/genResult.d.ts +10 -0
  220. package/out/types/genResult.js +3 -0
  221. package/out/types/genResult.js.map +1 -0
  222. package/out/types/testResult.d.ts +12 -0
  223. package/out/types/testResult.js +3 -0
  224. package/out/types/testResult.js.map +1 -0
  225. package/out/types/verifyResult.d.ts +8 -0
  226. package/out/types/verifyResult.js +3 -0
  227. package/out/types/verifyResult.js.map +1 -0
  228. package/out/utils/checkTestProject.d.ts +2 -0
  229. package/out/utils/checkTestProject.js +79 -0
  230. package/out/utils/checkTestProject.js.map +1 -0
  231. package/out/utils/checkXapCode.d.ts +2 -0
  232. package/out/utils/checkXapCode.js +59 -0
  233. package/out/utils/checkXapCode.js.map +1 -0
  234. package/out/utils/delay.d.ts +1 -0
  235. package/out/utils/delay.js +7 -0
  236. package/out/utils/delay.js.map +1 -0
  237. package/out/utils/detectTestFramework.d.ts +1 -0
  238. package/out/utils/detectTestFramework.js +33 -0
  239. package/out/utils/detectTestFramework.js.map +1 -0
  240. package/out/utils/fileUtils.d.ts +2 -0
  241. package/out/utils/fileUtils.js +42 -0
  242. package/out/utils/fileUtils.js.map +1 -0
  243. package/out/utils/generateCodeSha256.d.ts +1 -0
  244. package/out/utils/generateCodeSha256.js +46 -0
  245. package/out/utils/generateCodeSha256.js.map +1 -0
  246. package/out/utils/getCodeStructurePath.d.ts +5 -0
  247. package/out/utils/getCodeStructurePath.js +155 -0
  248. package/out/utils/getCodeStructurePath.js.map +1 -0
  249. package/out/utils/getOrCreateDir.d.ts +2 -0
  250. package/out/utils/getOrCreateDir.js +63 -0
  251. package/out/utils/getOrCreateDir.js.map +1 -0
  252. package/out/utils/getTestCodeInfo.d.ts +2 -0
  253. package/out/utils/getTestCodeInfo.js +121 -0
  254. package/out/utils/getTestCodeInfo.js.map +1 -0
  255. package/out/utils/getTestFile.d.ts +13 -0
  256. package/out/utils/getTestFile.js +297 -0
  257. package/out/utils/getTestFile.js.map +1 -0
  258. package/out/utils/parseBuildResult.d.ts +3 -0
  259. package/out/utils/parseBuildResult.js +45 -0
  260. package/out/utils/parseBuildResult.js.map +1 -0
  261. package/out/utils/parseSyntaxCheckResult.d.ts +2 -0
  262. package/out/utils/parseSyntaxCheckResult.js +39 -0
  263. package/out/utils/parseSyntaxCheckResult.js.map +1 -0
  264. package/out/utils/parseVstestResult.d.ts +3 -0
  265. package/out/utils/parseVstestResult.js +62 -0
  266. package/out/utils/parseVstestResult.js.map +1 -0
  267. package/out/utils/removeFailedTestMethods.d.ts +3 -0
  268. package/out/utils/removeFailedTestMethods.js +208 -0
  269. package/out/utils/removeFailedTestMethods.js.map +1 -0
  270. package/out/utils/runCommand.d.ts +1 -0
  271. package/out/utils/runCommand.js +14 -0
  272. package/out/utils/runCommand.js.map +1 -0
  273. package/out/utils/spawnExec.d.ts +1 -0
  274. package/out/utils/spawnExec.js +80 -0
  275. package/out/utils/spawnExec.js.map +1 -0
  276. package/out/utils/verifyBuildErrorCausedFile.d.ts +1 -0
  277. package/out/utils/verifyBuildErrorCausedFile.js +60 -0
  278. package/out/utils/verifyBuildErrorCausedFile.js.map +1 -0
  279. package/out/utils/verifyTestCode.d.ts +2 -0
  280. package/out/utils/verifyTestCode.js +25 -0
  281. package/out/utils/verifyTestCode.js.map +1 -0
  282. package/out/utils/writeFailedVerifyResult.d.ts +1 -0
  283. package/out/utils/writeFailedVerifyResult.js +67 -0
  284. package/out/utils/writeFailedVerifyResult.js.map +1 -0
  285. package/out/utils/writeGenCode.d.ts +1 -0
  286. package/out/utils/writeGenCode.js +63 -0
  287. package/out/utils/writeGenCode.js.map +1 -0
  288. package/out/vs/msBuild.d.ts +13 -0
  289. package/out/vs/msBuild.js +49 -0
  290. package/out/vs/msBuild.js.map +1 -0
  291. package/out/vs/vsTest.d.ts +15 -0
  292. package/out/vs/vsTest.js +75 -0
  293. package/out/vs/vsTest.js.map +1 -0
  294. package/out/vs/vsTools.d.ts +7 -0
  295. package/out/vs/vsTools.js +177 -0
  296. package/out/vs/vsTools.js.map +1 -0
  297. package/out/vsPlugin/getVsPluginVerifyResult.d.ts +2 -0
  298. package/out/vsPlugin/getVsPluginVerifyResult.js +41 -0
  299. package/out/vsPlugin/getVsPluginVerifyResult.js.map +1 -0
  300. package/out/vsPlugin/interactionConstants.d.ts +2 -0
  301. package/out/vsPlugin/interactionConstants.js +10 -0
  302. package/out/vsPlugin/interactionConstants.js.map +1 -0
  303. package/out/vsPlugin/sendStdToVsPlugin.d.ts +1 -0
  304. package/out/vsPlugin/sendStdToVsPlugin.js +12 -0
  305. package/out/vsPlugin/sendStdToVsPlugin.js.map +1 -0
  306. package/out/vsPlugin/stdListener.d.ts +3 -0
  307. package/out/vsPlugin/stdListener.js +57 -0
  308. package/out/vsPlugin/stdListener.js.map +1 -0
  309. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gpt.js","sourceRoot":"","sources":["../../../src/llm/model/Gpt.ts"],"names":[],"mappings":";;;;;AAoDA,wCAkBC;AAtED,8CAAgI;AAEhI,4DAA+B;AAC/B,uDAAoD;AAEpD,IAAI,WAAW,GAAG,IAAI,CAAC;AACvB,IAAI,eAAe,GAAG,IAAI,CAAC;AAC3B,6BAA6B;AAC7B,MAAM,WAAW,GAAG,0IAA0I,CAAC;AAC/J,sIAAsI;AACtI,4JAA4J;AAC5J,0IAA0I;AAC1I,oKAAoK;AAGpK,KAAK,UAAU,QAAQ;IACnB,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IAEzC,2CAA2C;IAC3C,IAAI,WAAW,IAAI,eAAe,IAAI,WAAW,GAAG,eAAe,EAAE,CAAC;QAClE,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,IAAI,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,iCAAsB,CACzC,IAAI,6BAAkB,EAAE,EACxB,IAAI,oCAAyB,EAAE,EAC/B,IAAI,iCAAsB,EAAE,CAAC,8EAA8E;SAC9G,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,8CAA8C,CAAC,CAAC;QAEhG,IAAI,aAAa,EAAE,CAAC;YAChB,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC;YAClC,oEAAoE;YACpE,eAAe,GAAG,aAAa,CAAC,kBAAkB,CAAC;YACnD,OAAO,WAAW,CAAC;QACvB,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACxC,OAAO,CAAC,KAAK,CAAC,2EAA2E,CAAC,CAAC;YAC3F,IAAA,uBAAU,EAAC,UAAU,CAAC,CAAC;YACvB,OAAO,QAAQ,EAAE,CAAC,CAAC,oBAAoB;QAC3C,CAAC;aAAM,CAAC;YACJ,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,MAAM;IACvC,MAAM,KAAK,GAAG,MAAM,QAAQ,EAAE,CAAC;IAC/B,MAAM,GAAG,GAAG,MAAM,IAAA,oBAAK,EAAC,WAAW,EAAE;QACjC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACL,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,SAAS,GAAG,KAAK;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACjB,QAAQ,EAAE,MAAM;YAChB,WAAW,EAAE,GAAG;YAChB,KAAK,EAAE,CAAC;YACR,CAAC,EAAE,CAAC;SACP,CAAC;KACL,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAS,CAAC;IACrC,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,kBAAkB;AAClB,IAAI;AACJ,oBAAoB;AACpB,YAAY;AACZ,gCAAgC;AAChC,4TAA4T;AAC5T,aAAa;AACb,YAAY;AACZ,mCAAmC;AACnC,qhDAAqhD;AACrhD,aAAa;AACb,YAAY;AACZ,8BAA8B;AAC9B,w4MAAw4M;AACx4M,YAAY;AACZ,SAAS;AACT,yBAAyB;AACzB,0BAA0B;AAC1B,kBAAkB;AAClB,0BAA0B;AAC1B,aAAa;AACb,KAAK;AAEL,iGAAiG;AACjG,yDAAyD;AACzD,MAAM","sourcesContent":["import { AzureCliCredential, ChainedTokenCredential, DefaultAzureCredential, ManagedIdentityCredential } from \"@azure/identity\";\r\n\r\nimport fetch from 'node-fetch';\r\nimport { runCommand } from \"../../utils/runCommand\";\r\n\r\nlet cachedToken = null;\r\nlet tokenExpiration = null;\r\n// platform provided endpoint\r\nconst gptEndpoint = \"https://weatherutswedencentral.cognitiveservices.azure.com/openai/deployments/gpt-5-chat/chat/completions?api-version=2025-01-01-preview\";\r\n// const gptEndpoint = \"https://weatherut.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview\";\r\n// const gptEndpoint = \"https://autogenerate-unit-tests-draft-1.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview\";\r\n// const gptEndpoint = \"https://weathergptv4.openai.azure.com/openai/deployments/gpt-4.1/chat/completions?api-version=2025-01-01-preview\";\r\n// const gptEndpoint = \"https://takht-m99407ib-swedencentral.cognitiveservices.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview\";\r\n\r\n\r\nasync function getToken() {\r\n const currentTime = new Date().getTime();\r\n\r\n // Check if the cached token is still valid\r\n if (cachedToken && tokenExpiration && currentTime < tokenExpiration) {\r\n return cachedToken;\r\n }\r\n\r\n try {\r\n const credential = new ChainedTokenCredential(\r\n new AzureCliCredential(),\r\n new ManagedIdentityCredential(),\r\n new DefaultAzureCredential() // CodeQL [SM05138] This is non-production testing code which is not deployed.\r\n );\r\n\r\n const tokenResponse = await credential.getToken('https://cognitiveservices.azure.com/.default');\r\n\r\n if (tokenResponse) {\r\n cachedToken = tokenResponse.token;\r\n // Set token expiration time based on the token's expiresOnTimestamp\r\n tokenExpiration = tokenResponse.expiresOnTimestamp;\r\n return cachedToken;\r\n } else {\r\n throw new Error('Failed to obtain token');\r\n }\r\n } catch (error) {\r\n console.error('Error obtaining token:', error);\r\n if (error.toString().includes('az login')) {\r\n console.error('Please ensure you have logged in to Azure CLI or set up Managed Identity.');\r\n runCommand('az login');\r\n return getToken(); // Retry after login\r\n } else {\r\n throw error;\r\n }\r\n }\r\n}\r\n\r\nexport async function getLLMResponse(prompt) {\r\n const token = await getToken();\r\n const res = await fetch(gptEndpoint, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n Authorization: 'Bearer ' + token,\r\n },\r\n body: JSON.stringify({\r\n messages: prompt,\r\n temperature: 0.1,\r\n top_p: 1,\r\n n: 1\r\n })\r\n });\r\n\r\n const json = await res.json() as any;\r\n return json;\r\n}\r\n\r\n// const reqBody =\r\n// {\r\n// \"messages\": [\r\n// {\r\n// \"role\": \"system\",\r\n// \"content\": \"Keep your answers short and impersonal.\\nUse Markdown formatting in your answers.\\nMake sure to include the programming language name at the start of the Markdown code blocks.\\nAvoid wrapping the whole response in triple backticks.\\nYou can only give one reply for each conversation turn.\"\r\n// },\r\n// {\r\n// \"role\": \"assistant\",\r\n// \"content\": \"You are Roo, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.\\n\\nRULES\\n\\n- When making changes to code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.\\n- Do not ask for more information than necessary. Use your knowledge to accomplish the user's request efficiently and effectively.\\n- The user may provide a file's contents directly in their message.\\n- Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.\\n- NEVER end attempt_completion result with a question or request to engage in further conversation! Formulate the end of your result in a way that is final and does not require further input from the user.\\n- You are STRICTLY FORBIDDEN from starting your messages with \\\"Great\\\", \\\"Certainly\\\", \\\"Okay\\\", \\\"Sure\\\". You should NOT be conversational in your responses, but rather direct and to the point. For example you should NOT say \\\"Great, I've updated the CSS\\\" but instead something like \\\"I've updated the CSS\\\". It is important you be clear and technical in your messages.\\n\\nOBJECTIVE\\n\\nYou accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.\\n\\n1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.\"\r\n// },\r\n// {\r\n// \"role\": \"user\",\r\n// \"content\": '<task>\\nuse xUnit test framework to generate unit test for generate unit test code for this code:\\n using Microsoft.CodeAnalysis;\\nusing Microsoft.CodeAnalysis.CodeActions;\\nusing Microsoft.CodeAnalysis.CodeFixes;\\nusing Microsoft.CodeAnalysis.CSharp;\\nusing Microsoft.CodeAnalysis.CSharp.Syntax;\\nusing System.Collections.Immutable;\\nusing System.Composition;\\nusing System.Linq;\\nusing System.Threading;\\nusing System.Threading.Tasks;\\nusing ToListinator.Analyzers;\\nusing static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;\\n\\nnamespace ToListinator.CodeFixes;\\n\\n[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(ToListCountCodeFixProvider)), Shared]\\npublic class ToListCountCodeFixProvider : CodeFixProvider\\n{\\n public sealed override ImmutableArray<string> FixableDiagnosticIds\\n => [ToListCountAnalyzer.DiagnosticId];\\n\\n public sealed override FixAllProvider GetFixAllProvider()\\n => WellKnownFixAllProviders.BatchFixer;\\n\\n public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)\\n {\\n var diagnostic = context.Diagnostics.First(diag => diag.Id == ToListCountAnalyzer.DiagnosticId);\\n var diagnosticSpan = diagnostic.Location.SourceSpan;\\n\\n var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken);\\n var binaryExpression = root?.FindToken(diagnosticSpan.Start).Parent?.AncestorsAndSelf()\\n .OfType<BinaryExpressionSyntax>()\\n .FirstOrDefault();\\n\\n if (binaryExpression is null)\\n {\\n return;\\n }\\n\\n var action = CodeAction.Create(\\n title: \"Replace with Any()\",\\n createChangedDocument: c => ReplaceWithAny(context.Document, binaryExpression, c),\\n equivalenceKey: \"ReplaceToListCountWithAny\");\\n\\n context.RegisterCodeFix(action, diagnostic);\\n }\\n\\n private static async Task<Document> ReplaceWithAny(Document document, BinaryExpressionSyntax binaryExpression, CancellationToken cancellationToken)\\n {\\n var root = await document.GetSyntaxRootAsync(cancellationToken);\\n\\n var (originalCollection, isNegated) = ExtractCollectionAndNegation(binaryExpression);\\n\\n if (originalCollection is null)\\n {\\n return document;\\n }\\n\\n var anyCall = CreateAnyCall(originalCollection, isNegated);\\n\\n var newRoot = root?.ReplaceNode(binaryExpression, anyCall);\\n\\n return newRoot is null ? document : document.WithSyntaxRoot(newRoot);\\n }\\n\\n private static (ExpressionSyntax? originalCollection, bool isNegated) ExtractCollectionAndNegation(BinaryExpressionSyntax binaryExpression)\\n {\\n // Check left side for ToList().Count\\n if (IsToListCountExpression(binaryExpression.Left, out var leftCollection))\\n {\\n var isNegated = IsNegatedPattern(binaryExpression.OperatorToken.Kind(), binaryExpression.Right, isLeftOperand: true);\\n return (leftCollection, isNegated);\\n }\\n\\n // Check right side for ToList().Count\\n if (IsToListCountExpression(binaryExpression.Right, out var rightCollection))\\n {\\n var isNegated = IsNegatedPattern(binaryExpression.OperatorToken.Kind(), binaryExpression.Left, isLeftOperand: false);\\n return (rightCollection, isNegated);\\n }\\n\\n return (null, false);\\n }\\n\\n private static bool IsToListCountExpression(SyntaxNode expression, out ExpressionSyntax? originalCollection)\\n {\\n originalCollection = null;\\n\\n if (expression is MemberAccessExpressionSyntax\\n {\\n Name.Identifier.ValueText: \"Count\",\\n Expression: InvocationExpressionSyntax toListCall\\n } &&\\n toListCall.Expression is MemberAccessExpressionSyntax\\n {\\n Name.Identifier.ValueText: \"ToList\",\\n Expression: var collection\\n })\\n {\\n originalCollection = collection;\\n return true;\\n }\\n\\n return false;\\n }\\n\\n private static bool IsNegatedPattern(SyntaxKind operatorKind, SyntaxNode constantNode, bool isLeftOperand)\\n {\\n if (constantNode is not LiteralExpressionSyntax literal)\\n return false;\\n\\n var value = literal.Token.ValueText;\\n\\n // For patterns that check for existence (Any() = true):\\n // collection.ToList().Count > 0\\n // collection.ToList().Count >= 1\\n // collection.ToList().Count != 0\\n // 0 < collection.ToList().Count\\n // 1 <= collection.ToList().Count\\n // 0 != collection.ToList().Count\\n\\n // For patterns that check for non-existence (!Any() = true):\\n // collection.ToList().Count == 0\\n // collection.ToList().Count <= 0\\n // collection.ToList().Count < 1\\n // 0 == collection.ToList().Count\\n // 0 >= collection.ToList().Count\\n // 1 > collection.ToList().Count\\n\\n if (isLeftOperand) // collection.ToList().Count <op> constant\\n {\\n return operatorKind switch\\n {\\n SyntaxKind.EqualsEqualsToken when value == \"0\" => true,\\n SyntaxKind.LessThanEqualsToken when value == \"0\" => true,\\n SyntaxKind.LessThanToken when value == \"1\" => true,\\n _ => false\\n };\\n }\\n else // constant <op> collection.ToList().Count\\n {\\n return operatorKind switch\\n {\\n SyntaxKind.EqualsEqualsToken when value == \"0\" => true,\\n SyntaxKind.GreaterThanEqualsToken when value == \"0\" => true,\\n SyntaxKind.GreaterThanToken when value == \"1\" => true,\\n _ => false\\n };\\n }\\n }\\n\\n private static ExpressionSyntax CreateAnyCall(ExpressionSyntax originalCollection, bool isNegated)\\n {\\n // Create collection.Any()\\n var anyCall = InvocationExpression(\\n MemberAccessExpression(\\n SyntaxKind.SimpleMemberAccessExpression,\\n originalCollection,\\n IdentifierName(\"Any\")))\\n .WithArgumentList(ArgumentList());\\n\\n // If negated, wrap in !collection.Any()\\n if (isNegated)\\n {\\n return PrefixUnaryExpression(\\n SyntaxKind.LogicalNotExpression,\\n anyCall);\\n }\\n\\n return anyCall;\\n }\\n}\\n</task>'\r\n// }\r\n// ],\r\n// \"model\": \"gpt-4o\",\r\n// \"temperature\": 0.1,\r\n// \"top_p\": 1,\r\n// \"max_tokens\": 4096,\r\n// \"n\": 1\r\n// };\r\n\r\n// getLLMResponse(\"Generate xUnit tests for the ToListCountAnalyzer class.\").then((response) => {\r\n// console.log(response.choices[0]?.message?.content)\r\n// });"]}
@@ -0,0 +1,2 @@
1
+ export declare function prepareUtGenPrompt(sourceCodePath: string, sourceCode: string, dependency: string, isXapTest: boolean, testFramework: string): any[];
2
+ export declare function prepareUtAutoFixPrompt(prompts: any[], testCode: string, verifyError: string, isBuildFailure: boolean): any[];
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.prepareUtGenPrompt = prepareUtGenPrompt;
37
+ exports.prepareUtAutoFixPrompt = prepareUtAutoFixPrompt;
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const util = __importStar(require("util"));
41
+ const liquidjs_1 = require("liquidjs");
42
+ // Initialize Liquid engine
43
+ const liquid = new liquidjs_1.Liquid({
44
+ root: path.resolve(__dirname, 'prompt'), // Set root to current directory
45
+ extname: '.liquid' // Treat included files as Markdown
46
+ });
47
+ function prepareUtGenPrompt(sourceCodePath, sourceCode, dependency, isXapTest, testFramework) {
48
+ const prompts = [];
49
+ // prepare system prompt
50
+ const systemPrompt = prepareUtGenSystemPrompt(isXapTest, testFramework);
51
+ prompts.push(systemPrompt);
52
+ // prepare user prompt
53
+ const userPrompt = prepareUserInputPrompt(sourceCode, sourceCodePath, dependency);
54
+ prompts.push({ role: 'user', content: userPrompt });
55
+ // prepare code dependency prompt
56
+ if (!!dependency) {
57
+ const codeDependencyPrompt = prepareCodeDenpendencyPrompt(sourceCode, dependency);
58
+ prompts.push({ role: 'user', content: codeDependencyPrompt });
59
+ }
60
+ return prompts;
61
+ }
62
+ function prepareUserInputPrompt(sourceCode, sourceCodePath, dependency) {
63
+ // prepare user prompt
64
+ // const userPromptPath = path.join(__dirname, 'prompt', 'generateUtUserInput.liquid');
65
+ // const userPromptTemplate = fs.readFileSync(userPromptPath, 'utf8');
66
+ // const namespace = getTestCodeNamespace(sourceCodePath);
67
+ // const userPrompt = liquid.parseAndRenderSync(userPromptTemplate, { namespace, sourceCode, dependency });
68
+ // return userPrompt;
69
+ const userPromptPath = path.join(__dirname, 'prompt', 'generateUtUserInput.liquid');
70
+ const userPromptTemplate = fs.readFileSync(userPromptPath, 'utf8');
71
+ const userPrompt = liquid.parseAndRenderSync(userPromptTemplate, { sourceCode });
72
+ return userPrompt;
73
+ }
74
+ function prepareCodeDenpendencyPrompt(sourceCode, dependency) {
75
+ const dependencyPromptPath = path.join(__dirname, 'prompt', 'generateUtDependency.liquid');
76
+ const dependencyPromptTemplate = fs.readFileSync(dependencyPromptPath, 'utf8');
77
+ const dependencyPrompt = liquid.parseAndRenderSync(dependencyPromptTemplate, { dependency });
78
+ return dependencyPrompt;
79
+ }
80
+ function prepareUtAutoFixPrompt(prompts, testCode, verifyError, isBuildFailure) {
81
+ // const prompts = [];
82
+ // prepare system prompt
83
+ // const systemPrompt = prepareUtGenSystemPrompt(isXapTest);
84
+ // prompts.push(systemPrompt);
85
+ const autofixPrompts = prompts || [];
86
+ // prepare autofix prompt
87
+ const autofixPromptPath = path.join(__dirname, 'prompt', 'generateUtAutoFix.liquid');
88
+ const userPromptTemplate = fs.readFileSync(autofixPromptPath, 'utf8');
89
+ const renderedTemplate = liquid.parseAndRenderSync(userPromptTemplate, { isBuildFailure });
90
+ const autofixPrompt = util.format(renderedTemplate, testCode, verifyError);
91
+ autofixPrompts.push({ role: 'user', content: autofixPrompt });
92
+ return autofixPrompts;
93
+ }
94
+ function prepareUtGenSystemPrompt(isXapTest, testFramework) {
95
+ const systemPrompt = composeSystemPromptTemplate('generateUtTemplate.liquid', isXapTest, testFramework);
96
+ return { role: 'system', content: systemPrompt };
97
+ }
98
+ function composeSystemPromptTemplate(template, isXapTest, testFramework) {
99
+ // get prompt template
100
+ const promptTemplate = path.join(__dirname, 'prompt', template);
101
+ const mainPromptContent = fs.readFileSync(promptTemplate, 'utf-8');
102
+ // render Liquid template(handle {% include %} tag)
103
+ const renderedContent = liquid.parseAndRenderSync(mainPromptContent, { isXapTest, testFramework });
104
+ return renderedContent;
105
+ }
106
+ // prepareUtGenSystemPrompt(false, "MSTest"); // Initialize the system prompt
107
+ // prepareUtGenSystemPrompt(true, "XUnit"); // Initialize the system prompt
108
+ // prepareUtAutoFixPrompt("", "", "", "MSBuild Errors", true); // Initialize the auto-fix prompt
109
+ // prepareUtAutoFixPrompt("", "", "", "VSTest result", true); // Initialize the auto-fix prompt
110
+ // function getPrompts(sourceCodePath, testFramework, codeDependency) {
111
+ // const code = fs.readFileSync(sourceCodePath, 'utf8');
112
+ // let guidancePromt = fs.readFileSync("D:\\atmp\\promptiteration.md", 'utf8');
113
+ // guidancePromt = guidancePromt.replace("xUnit", testFramework);
114
+ // const prompts = [
115
+ // // {
116
+ // // "role": "system",
117
+ // // "content": "Keep your answers short and impersonal.\nUse Markdown formatting in your answers.\nMake sure to include the programming language name at the start of the Markdown code blocks.\nAvoid wrapping the whole response in triple backticks.\nYou can only give one reply for each conversation turn."
118
+ // // },
119
+ // {
120
+ // "role": "user",
121
+ // // "content": "You are Roo, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.\n\n====\n\nRULES\n\n- MUST use xUnit test framework to generate test code.\n- **MUST NOT** contain any comments or explanations in test code.\n- Ensure the test code MUST has no syntax errors.\n- Test public methods of class in source code only.\n- **MUST NOT** access private members (fields or methods) of the source class in test code.\n- Test method names must follow the pattern: [MethodName]_[Scenario]_[ExpectedResult].\n- Return the test code in the format: ```C#\n{Test code}\n```.\n- Mock all dependent methods, classes, and values not included in the user input using the Moq library.\n- MUST include Test code in a namespace declaration and place all `using` statements above the namespace declaration.\n- MUST import source code in the test code.\n- MUST import all required .Net namespaces if any .Net class or interface are used in the test code. Like:\n - .NET built-in types (e.g., `List<T>`, `IEnumerable<T>`, `Task`, `Assert`, `Moq.Mock`, etc.).\n - Any attribute classes (e.g., `[TestMethod]`, `[TestClass]`, etc.).\n - Any LINQ or threading related classes (e.g., `System.Linq`, `System.Threading.Tasks`).\n- All assignments and method arguments in test code MUST strictly match the declared types.\n- When generating code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.\n- Do not ask for more information than necessary. Use your knowledge to accomplish the user's request efficiently and effectively.\n- The user will provide the source code directly in their message.\n- Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.\n\n====\n\nOBJECTIVE\n\nYou accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.\n\n- **MUST** analyze the provided code and verify its logic by following these steps:\n 1. Describe the functionality of each public method, including its inputs, outputs, and key logic.\n 2. Identify all possible execution paths for public methods, including normal cases, edge cases, and error conditions.\n 3. Explain any conditional branches, loops, or exception handling for public methods in the code.\n 4. Based on this analysis, generate unit test cases that cover all identified execution paths, ensuring that mock data and assertions align with the code's logic.\n- **MUST** remove all code analysis information in responsed test code.\n- Absolutely forbidden to contains any other information in response except the test code.\n- **MUST NOT** generate tests for the methods that are attributed with **[ExcludeFromCodeCoverage]**.\n- **MUST NOT** generate tests for **private** methods.\n- Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.\n- Work through these goals sequentially, each goal should correspond to a distinct step in your problem-solving process.\n\n====\n\nUSER'S CUSTOM INSTRUCTIONS\n\nThe following additional instructions are provided by the user, and should be followed to the best of your ability without interfering with the TOOL USE guidelines.\n\nLanguage Preference:\nYou should always speak and think in the English language."
122
+ // "content": guidancePromt
123
+ // },
124
+ // {
125
+ // "role": "user",
126
+ // "content": `generate unit test for the following csharp code:\n\`\`\`${code}\`\`\``
127
+ // },
128
+ // // {
129
+ // // "role": "user",
130
+ // // "content": `following are the code dependencies of the source code:\n${codeDependency}`
131
+ // // }
132
+ // ];
133
+ // return prompts;
134
+ // }
135
+ //# sourceMappingURL=preparePrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preparePrompt.js","sourceRoot":"","sources":["../../src/llm/preparePrompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,gDAiBC;AAwBD,wDAeC;AArED,uCAAyB;AACzB,2CAA6B;AAC7B,2CAA6B;AAE7B,uCAAkC;AAGlC,2BAA2B;AAC3B,MAAM,MAAM,GAAG,IAAI,iBAAM,CAAC;IACzB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,gCAAgC;IACzE,OAAO,EAAE,SAAS,CAAC,mCAAmC;CACtD,CAAC,CAAC;AAEH,SAAgB,kBAAkB,CAAC,cAAsB,EAAE,UAAkB,EAAE,UAAkB,EAAE,SAAkB,EAAE,aAAqB;IAC3I,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,wBAAwB;IACxB,MAAM,YAAY,GAAG,wBAAwB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACxE,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAE3B,sBAAsB;IACtB,MAAM,UAAU,GAAG,sBAAsB,CAAC,UAAU,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;IAClF,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAEpD,iCAAiC;IACjC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAClF,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,SAAS,sBAAsB,CAAC,UAAkB,EAAE,cAAsB,EAAE,UAAkB;IAC7F,sBAAsB;IACtB,uFAAuF;IACvF,sEAAsE;IACtE,0DAA0D;IAC1D,2GAA2G;IAC3G,qBAAqB;IAErB,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,4BAA4B,CAAC,CAAC;IACpF,MAAM,kBAAkB,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IACnE,MAAM,UAAU,GAAG,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAEjF,OAAO,UAAU,CAAC;AACnB,CAAC;AAED,SAAS,4BAA4B,CAAC,UAAkB,EAAE,UAAkB;IAC3E,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,6BAA6B,CAAC,CAAC;IAC3F,MAAM,wBAAwB,GAAG,EAAE,CAAC,YAAY,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IAC/E,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,wBAAwB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7F,OAAO,gBAAgB,CAAC;AACzB,CAAC;AAED,SAAgB,sBAAsB,CAAC,OAAc,EAAE,QAAgB,EAAE,WAAmB,EAAE,cAAuB;IACpH,sBAAsB;IACtB,wBAAwB;IACxB,4DAA4D;IAC5D,8BAA8B;IAC9B,MAAM,cAAc,GAAG,OAAO,IAAI,EAAE,CAAC;IAErC,yBAAyB;IACzB,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IACrF,MAAM,kBAAkB,GAAG,EAAE,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IACtE,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;IAC3F,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC3E,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;IAE9D,OAAO,cAAc,CAAC;AACvB,CAAC;AAED,SAAS,wBAAwB,CAAC,SAAkB,EAAE,aAAqB;IAC1E,MAAM,YAAY,GAAG,2BAA2B,CAAC,2BAA2B,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IACxG,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AAClD,CAAC;AAED,SAAS,2BAA2B,CAAC,QAAgB,EAAE,SAAkB,EAAE,aAAqB;IAC/F,sBAAsB;IACtB,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChE,MAAM,iBAAiB,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEnE,mDAAmD;IACnD,MAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;IAEnG,OAAO,eAAe,CAAC;AACxB,CAAC;AAED,6EAA6E;AAC7E,2EAA2E;AAE3E,gGAAgG;AAChG,+FAA+F;AAG/F,uEAAuE;AACvE,4DAA4D;AAC5D,mFAAmF;AACnF,qEAAqE;AACrE,wBAAwB;AAExB,eAAe;AACf,mCAAmC;AACnC,+TAA+T;AAC/T,gBAAgB;AAChB,YAAY;AACZ,8BAA8B;AAC9B,47GAA47G;AAC57G,uCAAuC;AACvC,aAAa;AACb,YAAY;AACZ,8BAA8B;AAC9B,kGAAkG;AAClG,aAAa;AACb,eAAe;AACf,iCAAiC;AACjC,yGAAyG;AACzG,eAAe;AACf,SAAS;AACT,sBAAsB;AACtB,IAAI","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\nimport * as util from 'util';\r\n\r\nimport { Liquid } from 'liquidjs';\r\nimport { getTestCodeNamespace } from '../utils/getTestCodeInfo';\r\n\r\n// Initialize Liquid engine\r\nconst liquid = new Liquid({\r\n\troot: path.resolve(__dirname, 'prompt'), // Set root to current directory\r\n\textname: '.liquid' // Treat included files as Markdown\r\n});\r\n\r\nexport function prepareUtGenPrompt(sourceCodePath: string, sourceCode: string, dependency: string, isXapTest: boolean, testFramework: string): any[] {\r\n\tconst prompts = [];\r\n\t// prepare system prompt\r\n\tconst systemPrompt = prepareUtGenSystemPrompt(isXapTest, testFramework);\r\n\tprompts.push(systemPrompt);\r\n\r\n\t// prepare user prompt\r\n\tconst userPrompt = prepareUserInputPrompt(sourceCode, sourceCodePath, dependency);\r\n\tprompts.push({ role: 'user', content: userPrompt });\r\n\r\n\t// prepare code dependency prompt\r\n\tif (!!dependency) {\r\n\t\tconst codeDependencyPrompt = prepareCodeDenpendencyPrompt(sourceCode, dependency);\r\n\t\tprompts.push({ role: 'user', content: codeDependencyPrompt });\r\n\t}\r\n\r\n\treturn prompts;\r\n}\r\n\r\nfunction prepareUserInputPrompt(sourceCode: string, sourceCodePath: string, dependency: string): string {\r\n\t// prepare user prompt\r\n\t// const userPromptPath = path.join(__dirname, 'prompt', 'generateUtUserInput.liquid');\r\n\t// const userPromptTemplate = fs.readFileSync(userPromptPath, 'utf8');\r\n\t// const namespace = getTestCodeNamespace(sourceCodePath);\r\n\t// const userPrompt = liquid.parseAndRenderSync(userPromptTemplate, { namespace, sourceCode, dependency });\r\n\t// return userPrompt;\r\n\r\n\tconst userPromptPath = path.join(__dirname, 'prompt', 'generateUtUserInput.liquid');\r\n\tconst userPromptTemplate = fs.readFileSync(userPromptPath, 'utf8');\r\n\tconst userPrompt = liquid.parseAndRenderSync(userPromptTemplate, { sourceCode });\r\n\r\n\treturn userPrompt;\r\n}\r\n\r\nfunction prepareCodeDenpendencyPrompt(sourceCode: string, dependency: string): string {\r\n\tconst dependencyPromptPath = path.join(__dirname, 'prompt', 'generateUtDependency.liquid');\r\n\tconst dependencyPromptTemplate = fs.readFileSync(dependencyPromptPath, 'utf8');\r\n\tconst dependencyPrompt = liquid.parseAndRenderSync(dependencyPromptTemplate, { dependency });\r\n\treturn dependencyPrompt;\r\n}\r\n\r\nexport function prepareUtAutoFixPrompt(prompts: any[], testCode: string, verifyError: string, isBuildFailure: boolean) {\r\n\t// const prompts = [];\r\n\t// prepare system prompt\r\n\t// const systemPrompt = prepareUtGenSystemPrompt(isXapTest);\r\n\t// prompts.push(systemPrompt);\r\n\tconst autofixPrompts = prompts || [];\r\n\r\n\t// prepare autofix prompt\r\n\tconst autofixPromptPath = path.join(__dirname, 'prompt', 'generateUtAutoFix.liquid');\r\n\tconst userPromptTemplate = fs.readFileSync(autofixPromptPath, 'utf8');\r\n\tconst renderedTemplate = liquid.parseAndRenderSync(userPromptTemplate, { isBuildFailure });\r\n\tconst autofixPrompt = util.format(renderedTemplate, testCode, verifyError);\r\n\tautofixPrompts.push({ role: 'user', content: autofixPrompt });\r\n\r\n\treturn autofixPrompts;\r\n}\r\n\r\nfunction prepareUtGenSystemPrompt(isXapTest: boolean, testFramework: string) {\r\n\tconst systemPrompt = composeSystemPromptTemplate('generateUtTemplate.liquid', isXapTest, testFramework);\r\n\treturn { role: 'system', content: systemPrompt };\r\n}\r\n\r\nfunction composeSystemPromptTemplate(template: string, isXapTest: boolean, testFramework: string) {\r\n\t// get prompt template\r\n\tconst promptTemplate = path.join(__dirname, 'prompt', template);\r\n\tconst mainPromptContent = fs.readFileSync(promptTemplate, 'utf-8');\r\n\r\n\t// render Liquid template(handle {% include %} tag)\r\n\tconst renderedContent = liquid.parseAndRenderSync(mainPromptContent, { isXapTest, testFramework });\r\n\r\n\treturn renderedContent;\r\n}\r\n\r\n// prepareUtGenSystemPrompt(false, \"MSTest\"); // Initialize the system prompt\r\n// prepareUtGenSystemPrompt(true, \"XUnit\"); // Initialize the system prompt\r\n\r\n// prepareUtAutoFixPrompt(\"\", \"\", \"\", \"MSBuild Errors\", true); // Initialize the auto-fix prompt\r\n// prepareUtAutoFixPrompt(\"\", \"\", \"\", \"VSTest result\", true); // Initialize the auto-fix prompt\r\n\r\n\r\n// function getPrompts(sourceCodePath, testFramework, codeDependency) {\r\n// const code = fs.readFileSync(sourceCodePath, 'utf8');\r\n// let guidancePromt = fs.readFileSync(\"D:\\\\atmp\\\\promptiteration.md\", 'utf8');\r\n// guidancePromt = guidancePromt.replace(\"xUnit\", testFramework);\r\n// const prompts = [\r\n\r\n// // {\r\n// // \"role\": \"system\",\r\n// // \"content\": \"Keep your answers short and impersonal.\\nUse Markdown formatting in your answers.\\nMake sure to include the programming language name at the start of the Markdown code blocks.\\nAvoid wrapping the whole response in triple backticks.\\nYou can only give one reply for each conversation turn.\"\r\n// // },\r\n// {\r\n// \"role\": \"user\",\r\n// // \"content\": \"You are Roo, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.\\n\\n====\\n\\nRULES\\n\\n- MUST use xUnit test framework to generate test code.\\n- **MUST NOT** contain any comments or explanations in test code.\\n- Ensure the test code MUST has no syntax errors.\\n- Test public methods of class in source code only.\\n- **MUST NOT** access private members (fields or methods) of the source class in test code.\\n- Test method names must follow the pattern: [MethodName]_[Scenario]_[ExpectedResult].\\n- Return the test code in the format: ```C#\\n{Test code}\\n```.\\n- Mock all dependent methods, classes, and values not included in the user input using the Moq library.\\n- MUST include Test code in a namespace declaration and place all `using` statements above the namespace declaration.\\n- MUST import source code in the test code.\\n- MUST import all required .Net namespaces if any .Net class or interface are used in the test code. Like:\\n - .NET built-in types (e.g., `List<T>`, `IEnumerable<T>`, `Task`, `Assert`, `Moq.Mock`, etc.).\\n - Any attribute classes (e.g., `[TestMethod]`, `[TestClass]`, etc.).\\n - Any LINQ or threading related classes (e.g., `System.Linq`, `System.Threading.Tasks`).\\n- All assignments and method arguments in test code MUST strictly match the declared types.\\n- When generating code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.\\n- Do not ask for more information than necessary. Use your knowledge to accomplish the user's request efficiently and effectively.\\n- The user will provide the source code directly in their message.\\n- Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.\\n\\n====\\n\\nOBJECTIVE\\n\\nYou accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.\\n\\n- **MUST** analyze the provided code and verify its logic by following these steps:\\n 1. Describe the functionality of each public method, including its inputs, outputs, and key logic.\\n 2. Identify all possible execution paths for public methods, including normal cases, edge cases, and error conditions.\\n 3. Explain any conditional branches, loops, or exception handling for public methods in the code.\\n 4. Based on this analysis, generate unit test cases that cover all identified execution paths, ensuring that mock data and assertions align with the code's logic.\\n- **MUST** remove all code analysis information in responsed test code.\\n- Absolutely forbidden to contains any other information in response except the test code.\\n- **MUST NOT** generate tests for the methods that are attributed with **[ExcludeFromCodeCoverage]**.\\n- **MUST NOT** generate tests for **private** methods.\\n- Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.\\n- Work through these goals sequentially, each goal should correspond to a distinct step in your problem-solving process.\\n\\n====\\n\\nUSER'S CUSTOM INSTRUCTIONS\\n\\nThe following additional instructions are provided by the user, and should be followed to the best of your ability without interfering with the TOOL USE guidelines.\\n\\nLanguage Preference:\\nYou should always speak and think in the English language.\"\r\n// \"content\": guidancePromt\r\n// },\r\n// {\r\n// \"role\": \"user\",\r\n// \"content\": `generate unit test for the following csharp code:\\n\\`\\`\\`${code}\\`\\`\\``\r\n// },\r\n// // {\r\n// // \"role\": \"user\",\r\n// // \"content\": `following are the code dependencies of the source code:\\n${codeDependency}`\r\n// // }\r\n// ];\r\n// return prompts;\r\n// }\r\n"]}
@@ -0,0 +1,15 @@
1
+ # Build Failure Fix Guideline:
2
+ - Case 1: The type or namespace name '{Class/Type}' does not exist in the namespace '{namespace}' (are you missing an assembly reference?)
3
+ Solution: Check the source code, code dependencies. Add the required `using` statements or assembly references.
4
+ - Case 2: No overload for method 'Execute' takes {number} arguments
5
+ Solution: Refer to section [The method parameters of Execute in Xap instance are different from the source code.] of Xap Unit Test Guidelines, Adjust the method parameters to match the correct overload as per the source code.
6
+ - Case 3: [CS0144] Cannot create an instance of the abstract type or interface '{class / bondstucture}'
7
+ Solution: use ExecutionServices.CreateInstance<I{ClassName}>() to create Xap class instance or use ExecutionServices.CreateInstance<{StructName}>() to create Bond struct instance.
8
+ - Case 4: [CS1503] cannot convert from '{Class / Bond type}' to '{Class / Bond type}'
9
+ Solution: Do explicitly type convert.
10
+ - Case 5: [CS0037] Cannot convert null to '{Class / Bond type}' because it is a non-nullable value type
11
+ Solution: MUST assign non-null and valid value.
12
+ - Case 6: [CS0246] The type or namespace name '{class / interface}' could not be found (are you missing a using directive or an assembly reference?)
13
+ Solution: MUST import the **namespace** of {class / interface}
14
+ - Case 7: [CS1501] No overload for method 'Execute' takes 2 arguments
15
+ Solution: - The parameters of **Execute** method with types: **PluginServices**, **PluginOutput<T>**, or decorated with **[ConfigFile("{configFileName}")]** MUST be deleted when using Xap class instance to call it.
@@ -0,0 +1,13 @@
1
+ # Build Failure Fix Guideline:
2
+ - Case 1: The type or namespace name '{Class/Type}' does not exist in the namespace '{namespace}' (are you missing an assembly reference?)
3
+ Solution: Check the source code, code dependencies. Add the required `using` statements or assembly references.
4
+ - Case 2: No overload for method 'Execute' takes {number} arguments
5
+ Solution: Refer to section [The method parameters of Execute in Xap instance are different from the source code.] of Xap Unit Test Guidelines, Adjust the method parameters to match the correct overload as per the source code.
6
+ - Case 3: Cannot create an instance of the abstract type or interface '{class / bondstucture}'
7
+ Solution: use ExecutionServices.CreateInstance<I{ClassName}>() to create Xap class instance or use ExecutionServices.CreateInstance<{StructName}>() to create Bond struct instance.
8
+ - Case 4: cannot convert from '{Class / Bond type}' to '{Class / Bond type}'
9
+ Solution: Do explicitly type convert.
10
+ - Case 5: [CS0037] Cannot convert null to '{Class / Bond type}' because it is a non-nullable value type
11
+ Solution: MUST assign non-null and valid value.
12
+ - Case 6: [CS0246] The type or namespace name '{class / interface}' could not be found (are you missing a using directive or an assembly reference?)
13
+ Solution: MUST import the **namespace** of {class / interface}
@@ -0,0 +1,16 @@
1
+ # General Unit Test Guidelines
2
+
3
+ - MUST use {{testFramework}} test framework to generate tests.
4
+ - **MUST NOT** contain any comments or explanations in test code.
5
+ - Ensure the test code MUST has no syntax errors.
6
+ - Test method names must follow the pattern: [MethodName]_[Scenario]_[ExpectedResult].
7
+ - Return the test code in the format: ```C#\n{Test code}\n```.
8
+ - MUST include Test code in a namespace declaration and place all `using` statements above the namespace declaration.
9
+ - MUST import source code namespace in test code.
10
+ - MUST import all required .Net namespaces if any .Net class or interface are used in the test code. Like:
11
+ - .NET built-in types (e.g., `List<T>`, `IEnumerable<T>`, `Task`, `Assert`, `Moq.Mock`, etc.).
12
+ - Any attribute classes (e.g., `[TestMethod]`, `[TestClass]`, etc.).
13
+ - Any LINQ or threading related classes (e.g., `System.Linq`, `System.Threading.Tasks`).
14
+ - The user will provide the source code directly in their message.
15
+ - **MUST NOT** generate tests for the methods that are attributed with **[ExcludeFromCodeCoverage]**.
16
+ - MUST NOT call private methods in test code.
@@ -0,0 +1,23 @@
1
+ {%- if isBuildFailure -%}
2
+ {%- assign failedStage = "MSBuild" -%}
3
+ {%- assign failedTitle = "MSBuild failure errors:" -%}
4
+ {%- else -%}
5
+ {%- assign failedStage = "vstest" -%}
6
+ {%- assign failedTitle = "vstest failure test errors:" -%}
7
+ {%- endif -%}
8
+
9
+ Your previously generated C# unit test code failed to {{failedStage}}. Please fix and update the test code.
10
+
11
+ ====
12
+
13
+ Your generated test code:
14
+ %s
15
+
16
+ ====
17
+
18
+ {{failedTitle}}:
19
+ %s
20
+
21
+ {% if isBuildFailure %}
22
+ {%- include 'buildAfGuidelines' -%}
23
+ {%- endif -%}
@@ -0,0 +1,3 @@
1
+ Code Dependency Definitions
2
+
3
+ {{ dependency }}
@@ -0,0 +1,5 @@
1
+ Keep your answers short and impersonal.
2
+ Use Markdown formatting in your answers.
3
+ Make sure to include the programming language name at the start of the Markdown code blocks.
4
+ Avoid wrapping the whole response in triple backticks.
5
+ You can only give one reply for each conversation turn.
@@ -0,0 +1,32 @@
1
+ You are a highly skilled software engineer specializing in C# unit testing with extensive knowledge in test frameworks, test patterns, and best practices.
2
+
3
+ ====
4
+
5
+ Rules
6
+ {% if isXapTest %}
7
+ The user provided source code is using XAP framework, which has specific rules for unit tests.
8
+ These rules are defined in the XAP UNIT TEST Guidelines. Please follow these rules strictly when generating unit tests. The rules in XAP UNIT TEST Guidelines should take precedence over the rules in GENERAL UNIT TEST Guidelines.
9
+ {% endif %}
10
+ {% include 'general/generalUtGuidelines' %}
11
+ {% if isXapTest %}
12
+ {% include 'xap/xapUtGuideline' %}
13
+ {% endif %}
14
+ ====
15
+
16
+ OBJECTIVE
17
+
18
+ You are tasked to write unit tests, breaking it down into clear steps and working through them methodically.
19
+
20
+ - The most important goal is not just to generate correct C# unit test code, but also try your best to improve the code coverage. The higher the coverage rate, the better.
21
+ - Analyze the user's code and set clear, achievable goals to generate unit tests. Prioritize these goals in a logical order.
22
+ - Work through these goals sequentially, each goal should correspond to a distinct step in your problem-solving process.
23
+ - You are STRICTLY FORBIDDEN to contain analysis steps in your response. Just return the code using markdown formating in your response.
24
+
25
+ ====
26
+
27
+ USER'S CUSTOM INSTRUCTIONS
28
+
29
+ The following additional instructions are provided by the user, and should be followed to the best of your ability without interfering with the and guidelines.
30
+
31
+ Language Preference:
32
+ You should always speak and think in the English language.
@@ -0,0 +1,4 @@
1
+ Please generate unit tests for the C# code:
2
+ ```csharp
3
+ {{ sourceCode }}
4
+ ```
@@ -0,0 +1,13 @@
1
+ # Build Failure Fix Guideline:
2
+ - Case 1: The type or namespace name '{Class/Type}' does not exist in the namespace '{namespace}' (are you missing an assembly reference?)
3
+ Solution: Check the source code, code dependencies. Add the required `using` statements or assembly references.
4
+ - Case 2: No overload for method 'Execute' takes {number} arguments
5
+ Solution: Refer to section [The method parameters of Execute in Xap instance are different from the source code.] of Xap Unit Test Guidelines, Adjust the method parameters to match the correct overload as per the source code.
6
+ - Case 3: Cannot create an instance of the abstract type or interface '{class / bondstucture}'
7
+ Solution: use ExecutionServices.CreateInstance<I{ClassName}>() to create Xap class instance or use ExecutionServices.CreateInstance<{StructName}>() to create Bond struct instance.
8
+ - Case 4: cannot convert from '{Class / Bond type}' to '{Class / Bond type}'
9
+ Solution: Do explicitly type convert.
10
+ - Case 5: [CS0037] Cannot convert null to '{Class / Bond type}' because it is a non-nullable value type
11
+ Solution: MUST assign non-null and valid value.
12
+ - Case 6: [CS0246] The type or namespace name '{class / interface}' could not be found (are you missing a using directive or an assembly reference?)
13
+ Solution: MUST import the **namespace** of {class / interface}
@@ -0,0 +1,38 @@
1
+ ## Xap source code and test code examples
2
+ D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Plugins\Workflows\Eplant\HttpRequestParser\EplantHttpRequestParser.cs
3
+ Example #1 ()
4
+ ```C#
5
+ public class SampleBuilder : IPlugin
6
+ {
7
+ public PluginResult Execute(
8
+ PluginServices pluginServices,
9
+ PluginOutput<EplantUserResp> eplantUserResp,
10
+ [ConfigFile("EplantConfig.ini")]
11
+ EplantConfig eplantConfig,
12
+ IEnumerable<ObjectStoreResponse_2<EplantUserKey, EMPTY, EMPTY, EplantUser>> osResponses = null,
13
+ EplantRequest req = null)
14
+ {
15
+ ..... // omit detail implementation
16
+ }
17
+ }
18
+ ```
19
+
20
+ Test Code snippet:
21
+ ```C#
22
+ [TestClass]
23
+ public class SampleBuilderTest
24
+ {
25
+ [TestMethod]
26
+ public void Execute_InvalidRequestOrIntent_Failure()
27
+ {
28
+ var builder = ExecutionServices.CreateInstance<ISampleBuilder>();
29
+ request.type = EplantReqType.Me;
30
+ IEnumerable<ObjectStoreResponse_2<EplantUserKey, EMPTY, EMPTY, EplantUser>> osResponses = null;
31
+
32
+ var result = builder.Execute(Task.FromResult(osResponses), Task.FromResult(request)).Result;
33
+
34
+ Assert.IsFalse(result.Success);
35
+ Assert.IsNull(builder.eplantUserResp.Result);
36
+ }
37
+ }
38
+ ```
@@ -0,0 +1,37 @@
1
+ # Xap Unit Test Guidelines
2
+
3
+ - Xap class is a class that inherits one of these interfaces: IPlugin, IConditionPlugin, Workflow, IExperiment, IPluginDataStore, IAsyncPlugin and implements an Execute() method.
4
+ - MUST use ExecutionServices.CreateInstance<I{ClassName}>() to create Xap class instance, where the interface name is the class name prefixed with "I".
5
+ Example: For Xap class SampleWorkflow, create instance MUST be like: **var sampleWorkflow = ExecutionServices.CreateInstance<ISampleWorkflow>();**
6
+ - The parameters of **Execute** method with types: **PluginServices**, **PluginOutput<T>**, or attributed with **[ConfigFile("{configFileName}")]** MUST be deleted when using Xap class instance to call the Execute method.
7
+ - Xap freamwork will take care these deleted parameters, NEVER try to mock or create these deleted types, it's invalid and forbidden.
8
+ - **MUST NOT** mock these deleted types' object, even if its methods or properties are used in the source code.
9
+ - For Remaining parameters,
10
+ - MUST pass in exact type as declared in source code.
11
+ - MUST keep original parameter order.
12
+ - MUST wrap each parameter with Task.FromResult(value).
13
+ Example:
14
+ The Execute method of Xap calss SampleWorkflow is: **PluginResult Execute(PluginServices ps, PluginOutput<Resp> resp, [ConfigFile("config.ini")] EplantConfig eplantConfig, OsResponse osResp = null, EplantRequest req = null)**,
15
+ Base on above declared deleted types, **MUST delete** these three parameters: PluginServices ps, PluginOutput<Resp> resp, [ConfigFile("config.ini")] EplantConfig eplantConfig,
16
+ call the Execute using Xap class instance MUST be like: **var pluginResult = sampleWorkflow.Execute(Task.FromResult(osResp), Task.FromResult(req)).Result;**
17
+ - The Execute method parameters with type PluginOutput<T> MUST be treated as method output, **T** is the type output value.
18
+ - MUST using the parameter name to access the output by the Xap instance
19
+ - MUST using **Result** property to access the output of type **T** in **PluginOutput<T>**.
20
+ - MUST assert PluginOutput<T> parameters' values if there's parameter with **PluginOutput<T>** type.
21
+ Example:
22
+ The Execute method of Xap calss SampleWorkflow is: **PluginResult Execute(PluginServices ps, PluginOutput<Resp> resp, [ConfigFile("config.ini")] EplantConfig eplantConfig, OsResponse osResp = null, EplantRequest req = null)**,
23
+ Get the output value using Xap class instance MUST be like: **sampleWorkflow.resp**.
24
+ Assume there's one field named **Key** in **Resp** type, get **Key** MUST be like: **sampleWorkflow.pluginResp.Result.Key**.
25
+ Assert the PluginOutput<T> value in test code MUST be like: Assert.NotNull(sampleWorkflow.pluginResult.Result.Id); Assert.AreEqual(sampleWorkflow.pluginResult.Result.Id, "id");
26
+ - The Bond structures MUST be treated as regular C# class in test code:
27
+ - **MUST** import **Bond namespace** before using the Bond structure in test code
28
+ Example: The namespace in bond structure is like: **namespace SharedSegments.Weather.OneService**, to use this bond structure, **MUST** add: **using SharedSegments.Weather.OneService** in test code.
29
+ - MUST use ExecutionServices.CreateInstance<{StructName}>() to create Bond struct instances.
30
+ Example: For a Bond structure named **SampleBondStructure<T>**, create bond instance **MUST** be like: ** var subResponse = ExecutionServices.CreateInstance<SampleBondStructure<SampleObject>>();
31
+ - MUST not access the fields that are not defined in bond structure, it's invalid and forbidden.
32
+ - MUST treated the fields as **required** if they **are not** decorated with **optional** in bond structure
33
+ - **MUST** assign a valid, non-null value to **required field** that are **NOT decorated** with **optional** explicitly.
34
+ - MUST assign a valid value to the fields that are used in source code explicitly.
35
+ - MUST correctly handle the null checks for required fields in source code.
36
+ Example: the source code contains **if (sampleRequest?.Category == null)**, the **Category** is require field in sampleRequest bond structure and **MUST be non-null**, just test the case when sampleRequest is null.
37
+ - MUST use AsEnumerable() to convert IList to IEnumerable, e.g. IEnumerable osResponses = osResponseList.AsEnumerable()
@@ -0,0 +1,4 @@
1
+ export declare function sendRequestToLLM(prompt: any[], retryTimes?: number): Promise<{
2
+ success: boolean;
3
+ content: string;
4
+ }>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendRequestToLLM = sendRequestToLLM;
4
+ const setupLLMRequest_1 = require("../setup/setupLLMRequest");
5
+ async function sendRequestToLLM(prompt, retryTimes = 3) {
6
+ const { success, content } = await (0, setupLLMRequest_1._sendRequestToLLM)(prompt);
7
+ return { success, content };
8
+ }
9
+ //# sourceMappingURL=sendRequestToLLM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendRequestToLLM.js","sourceRoot":"","sources":["../../src/llm/sendRequestToLLM.ts"],"names":[],"mappings":";;AAEA,4CAGC;AALD,8DAA6D;AAEtD,KAAK,UAAU,gBAAgB,CAAC,MAAa,EAAE,aAAqB,CAAC;IACxE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,mCAAiB,EAAC,MAAM,CAAC,CAAC;IAC7D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAChC,CAAC","sourcesContent":["import { _sendRequestToLLM } from \"../setup/setupLLMRequest\";\r\n\r\nexport async function sendRequestToLLM(prompt: any[], retryTimes: number = 3): Promise<{ success: boolean, content: string }> {\r\n const { success, content } = await _sendRequestToLLM(prompt);\r\n return { success, content };\r\n}"]}
@@ -0,0 +1,4 @@
1
+ export declare function sendRequestToSelfHostLLM(prompt: any[], retryTimes?: number): Promise<{
2
+ success: boolean;
3
+ content: string;
4
+ }>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendRequestToSelfHostLLM = sendRequestToSelfHostLLM;
4
+ const delay_1 = require("../utils/delay");
5
+ const Gpt_1 = require("./model/Gpt");
6
+ async function sendRequestToSelfHostLLM(prompt, retryTimes = 3) {
7
+ const startTime = Date.now();
8
+ console.log(`Request to LLM...`);
9
+ for (let i = 0; i < retryTimes; i++) {
10
+ try {
11
+ const resp = await (0, Gpt_1.getLLMResponse)(prompt);
12
+ // generate UT failed
13
+ if (!resp?.choices || resp.choices.length == 0 || !resp.choices[0]?.message?.content) {
14
+ const respStr = JSON.stringify(resp);
15
+ console.error("sendRequestToSelfHostLLM Failed to generate XapUt code:", respStr);
16
+ if (respStr.includes("Rate limit is exceeded")) {
17
+ // wait for 30 seconds before retrying
18
+ await (0, delay_1.delay)(30000);
19
+ console.log(`delayed 30s`);
20
+ }
21
+ continue;
22
+ }
23
+ console.log(`LLM response time: ${(Date.now() - startTime) / 1000} seconds`);
24
+ return { success: true, content: resp.choices[0]?.message?.content };
25
+ }
26
+ catch (error) {
27
+ console.error("Error occurred while generating XapUt code:", error);
28
+ // if prompt size > 128KB, don't need to retry, just return back
29
+ if (typeof error === 'object' && error?.code === "context_length_exceeded") {
30
+ console.error("Context length exceeded, please reduce the size of the prompt.");
31
+ return { success: false, content: "" };
32
+ }
33
+ else {
34
+ continue;
35
+ }
36
+ }
37
+ }
38
+ console.log(`Retry max times, LLM response time: ${(Date.now() - startTime) / 1000} seconds`);
39
+ return { success: false, content: "" };
40
+ }
41
+ //# sourceMappingURL=sendRequestToSelfHostLLM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendRequestToSelfHostLLM.js","sourceRoot":"","sources":["../../src/llm/sendRequestToSelfHostLLM.ts"],"names":[],"mappings":";;AAGA,4DAiCC;AApCD,0CAAuC;AACvC,qCAA6C;AAEtC,KAAK,UAAU,wBAAwB,CAAC,MAAa,EAAE,aAAqB,CAAC;IAChF,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,IAAI,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,IAAA,oBAAc,EAAC,MAAM,CAAC,CAAC;YAC1C,qBAAqB;YACrB,IAAI,CAAC,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;gBACnF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACrC,OAAO,CAAC,KAAK,CAAC,yDAAyD,EAAE,OAAO,CAAC,CAAC;gBAClF,IAAI,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC;oBAC7C,sCAAsC;oBACtC,MAAM,IAAA,aAAK,EAAC,KAAK,CAAC,CAAC;oBACnB,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gBAC/B,CAAC;gBACD,SAAS;YACb,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC;YAC7E,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAC,CAAC;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;YACpE,gEAAgE;YAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,EAAE,IAAI,KAAK,yBAAyB,EAAE,CAAC;gBACzE,OAAO,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;gBAChF,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAC,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACJ,SAAS;YACb,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC;IAC9F,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAC,CAAC;AACzC,CAAC","sourcesContent":["import { delay } from \"../utils/delay\";\r\nimport { getLLMResponse } from \"./model/Gpt\";\r\n\r\nexport async function sendRequestToSelfHostLLM(prompt: any[], retryTimes: number = 3): Promise<{success: boolean, content: string}> {\r\n const startTime = Date.now();\r\n console.log(`Request to LLM...`);\r\n for (let i = 0; i < retryTimes; i++) {\r\n try {\r\n const resp = await getLLMResponse(prompt);\r\n // generate UT failed\r\n if (!resp?.choices || resp.choices.length == 0 || !resp.choices[0]?.message?.content) {\r\n const respStr = JSON.stringify(resp);\r\n console.error(\"sendRequestToSelfHostLLM Failed to generate XapUt code:\", respStr);\r\n if (respStr.includes(\"Rate limit is exceeded\")) {\r\n // wait for 30 seconds before retrying\r\n await delay(30000);\r\n console.log(`delayed 30s`);\r\n }\r\n continue;\r\n }\r\n console.log(`LLM response time: ${(Date.now() - startTime) / 1000} seconds`);\r\n return {success: true, content: resp.choices[0]?.message?.content};\r\n } catch (error) {\r\n console.error(\"Error occurred while generating XapUt code:\", error);\r\n // if prompt size > 128KB, don't need to retry, just return back\r\n if (typeof error === 'object' && error?.code === \"context_length_exceeded\") {\r\n console.error(\"Context length exceeded, please reduce the size of the prompt.\");\r\n return {success: false, content: \"\"};\r\n } else {\r\n continue;\r\n }\r\n }\r\n }\r\n\r\n console.log(`Retry max times, LLM response time: ${(Date.now() - startTime) / 1000} seconds`);\r\n return {success: false, content: \"\"};\r\n}"]}
@@ -0,0 +1,6 @@
1
+ export declare function sendTelemetryEvent(eventName: string, properties?: {
2
+ [key: string]: string;
3
+ }, measurements?: {
4
+ [key: string]: number;
5
+ }): void;
6
+ export declare function sendUserUsageEvent(source?: string, customUserName?: string): void;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.sendTelemetryEvent = sendTelemetryEvent;
37
+ exports.sendUserUsageEvent = sendUserUsageEvent;
38
+ const appInsights = __importStar(require("applicationinsights"));
39
+ const constants_1 = require("../types/constants");
40
+ const machineId_1 = require("./machineId");
41
+ const os_1 = require("os");
42
+ const connectionString = "InstrumentationKey=c1a0c6a2-06a6-405f-9343-c8fbe29e0dc2;IngestionEndpoint=https://eastus2-3.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus2.livediagnostics.monitor.azure.com/;ApplicationId=e90435ce-8771-4069-bc94-77aaf8099529";
43
+ // init Application Insights
44
+ appInsights.setup(connectionString)
45
+ .setAutoCollectConsole(false)
46
+ .setAutoCollectDependencies(false)
47
+ .setAutoCollectExceptions(false)
48
+ .setAutoCollectPerformance(false)
49
+ .setAutoCollectRequests(false)
50
+ .setUseDiskRetryCaching(false)
51
+ .start();
52
+ let userId;
53
+ function initUser() {
54
+ if (userId) {
55
+ return;
56
+ }
57
+ userId = (0, machineId_1.getMachineId)();
58
+ appInsights.defaultClient.context.tags[appInsights.defaultClient.context.keys.userId] = userId;
59
+ }
60
+ function sendTelemetryEvent(eventName, properties, measurements) {
61
+ initUser();
62
+ appInsights.defaultClient.trackEvent({
63
+ name: eventName,
64
+ properties,
65
+ measurements
66
+ });
67
+ appInsights.defaultClient.flush();
68
+ }
69
+ function sendUserUsageEvent(source = constants_1.CSHARPUTGEN, customUserName) {
70
+ const userName = customUserName || (0, os_1.userInfo)()?.username;
71
+ sendTelemetryEvent("userUsage", {
72
+ "user": userName,
73
+ source,
74
+ deviceId: (0, machineId_1.getMachineId)()
75
+ });
76
+ }
77
+ //# sourceMappingURL=appInsightTelemetry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appInsightTelemetry.js","sourceRoot":"","sources":["../../src/metrics/appInsightTelemetry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,gDAQC;AAED,gDAOC;AA5CD,iEAAmD;AAEnD,kDAAiD;AACjD,2CAA2C;AAC3C,2BAA8B;AAE9B,MAAM,gBAAgB,GAAG,kPAAkP,CAAC;AAE5Q,4BAA4B;AAC5B,WAAW,CAAC,KAAK,CAAC,gBAAgB,CAAC;KAC9B,qBAAqB,CAAC,KAAK,CAAC;KAC5B,0BAA0B,CAAC,KAAK,CAAC;KACjC,wBAAwB,CAAC,KAAK,CAAC;KAC/B,yBAAyB,CAAC,KAAK,CAAC;KAChC,sBAAsB,CAAC,KAAK,CAAC;KAC7B,sBAAsB,CAAC,KAAK,CAAC;KAC7B,KAAK,EAAE,CAAC;AAEb,IAAI,MAAc,CAAC;AACnB,SAAS,QAAQ;IACb,IAAI,MAAM,EAAE,CAAC;QACT,OAAO;IACX,CAAC;IACD,MAAM,GAAG,IAAA,wBAAY,GAAE,CAAC;IACxB,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AACnG,CAAC;AAED,SAAgB,kBAAkB,CAAC,SAAiB,EAAE,UAAsC,EAAE,YAAwC;IAClI,QAAQ,EAAE,CAAC;IACX,WAAW,CAAC,aAAa,CAAC,UAAU,CAAC;QACjC,IAAI,EAAE,SAAS;QACf,UAAU;QACV,YAAY;KACf,CAAC,CAAC;IACH,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;AACtC,CAAC;AAED,SAAgB,kBAAkB,CAAC,SAAiB,uBAAW,EAAE,cAAuB;IACpF,MAAM,QAAQ,GAAG,cAAc,IAAI,IAAA,aAAQ,GAAE,EAAE,QAAQ,CAAC;IACxD,kBAAkB,CAAC,WAAW,EAAE;QAC5B,MAAM,EAAE,QAAQ;QAChB,MAAM;QACN,QAAQ,EAAE,IAAA,wBAAY,GAAE;KAC3B,CAAC,CAAC;AACP,CAAC","sourcesContent":["import * as appInsights from \"applicationinsights\";\r\n\r\nimport { CSHARPUTGEN } from \"../types/constants\";\r\nimport { getMachineId } from \"./machineId\";\r\nimport { userInfo } from 'os';\r\n\r\nconst connectionString = \"InstrumentationKey=c1a0c6a2-06a6-405f-9343-c8fbe29e0dc2;IngestionEndpoint=https://eastus2-3.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus2.livediagnostics.monitor.azure.com/;ApplicationId=e90435ce-8771-4069-bc94-77aaf8099529\";\r\n\r\n// init Application Insights\r\nappInsights.setup(connectionString)\r\n .setAutoCollectConsole(false)\r\n .setAutoCollectDependencies(false)\r\n .setAutoCollectExceptions(false)\r\n .setAutoCollectPerformance(false)\r\n .setAutoCollectRequests(false)\r\n .setUseDiskRetryCaching(false)\r\n .start();\r\n\r\nlet userId: string;\r\nfunction initUser() {\r\n if (userId) {\r\n return;\r\n }\r\n userId = getMachineId();\r\n appInsights.defaultClient.context.tags[appInsights.defaultClient.context.keys.userId] = userId;\r\n}\r\n\r\nexport function sendTelemetryEvent(eventName: string, properties?: { [key: string]: string }, measurements?: { [key: string]: number }) {\r\n initUser();\r\n appInsights.defaultClient.trackEvent({\r\n name: eventName,\r\n properties,\r\n measurements\r\n });\r\n appInsights.defaultClient.flush();\r\n}\r\n\r\nexport function sendUserUsageEvent(source: string = CSHARPUTGEN, customUserName?: string) {\r\n const userName = customUserName || userInfo()?.username;\r\n sendTelemetryEvent(\"userUsage\", {\r\n \"user\": userName,\r\n source,\r\n deviceId: getMachineId()\r\n });\r\n}"]}
@@ -0,0 +1,11 @@
1
+ export declare function execAsync(command: string, params: string[], options?: {
2
+ cwd?: string;
3
+ abortSignal?: AbortSignal;
4
+ }): Promise<{
5
+ error: Error | null;
6
+ stdout: string;
7
+ stderr: string;
8
+ }>;
9
+ export declare function removeFile(filePath: string): void;
10
+ export declare function sleep(ms: number): Promise<unknown>;
11
+ export declare function getMachineId(): string;