@ai-dev-tools/csharp-copilot-core 0.0.30 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/out/analyze/cecil.d.ts +0 -1
- package/out/analyze/cecil.js +0 -42
- package/out/analyze/cecil.js.map +0 -1
- package/out/analyze/checkCodeSyntax.d.ts +0 -7
- package/out/analyze/checkCodeSyntax.js +0 -67
- package/out/analyze/checkCodeSyntax.js.map +0 -1
- package/out/analyze/generateCodeDependency.d.ts +0 -6
- package/out/analyze/generateCodeDependency.js +0 -126
- package/out/analyze/generateCodeDependency.js.map +0 -1
- package/out/analyze/installAnalyzerTool.d.ts +0 -1
- package/out/analyze/installAnalyzerTool.js +0 -82
- package/out/analyze/installAnalyzerTool.js.map +0 -1
- package/out/batch/generateCodeTests.d.ts +0 -6
- package/out/batch/generateCodeTests.js +0 -147
- package/out/batch/generateCodeTests.js.map +0 -1
- package/out/batch/getFolderCodeFile.d.ts +0 -1
- package/out/batch/getFolderCodeFile.js +0 -19
- package/out/batch/getFolderCodeFile.js.map +0 -1
- package/out/batch/getProjectCodeFile.d.ts +0 -4
- package/out/batch/getProjectCodeFile.js +0 -86
- package/out/batch/getProjectCodeFile.js.map +0 -1
- package/out/batch/getSolutionCodeFile.d.ts +0 -8
- package/out/batch/getSolutionCodeFile.js +0 -70
- package/out/batch/getSolutionCodeFile.js.map +0 -1
- package/out/benchmark/formatToMarkdown.d.ts +0 -2
- package/out/benchmark/formatToMarkdown.js +0 -101
- package/out/benchmark/formatToMarkdown.js.map +0 -1
- package/out/benchmark/generateBenchmarkReport.d.ts +0 -1
- package/out/benchmark/generateBenchmarkReport.js +0 -82
- package/out/benchmark/generateBenchmarkReport.js.map +0 -1
- package/out/codeCoverage/codeCoverage.d.ts +0 -6
- package/out/codeCoverage/codeCoverage.js +0 -39
- package/out/codeCoverage/codeCoverage.js.map +0 -1
- package/out/codeCoverage/codeCoverageReport.d.ts +0 -6
- package/out/codeCoverage/codeCoverageReport.js +0 -76
- package/out/codeCoverage/codeCoverageReport.js.map +0 -1
- package/out/codeCoverage/extractCodeCoverageInfo.d.ts +0 -2
- package/out/codeCoverage/extractCodeCoverageInfo.js +0 -80
- package/out/codeCoverage/extractCodeCoverageInfo.js.map +0 -1
- package/out/codeCoverage/extractCoverageReportPath.d.ts +0 -1
- package/out/codeCoverage/extractCoverageReportPath.js +0 -24
- package/out/codeCoverage/extractCoverageReportPath.js.map +0 -1
- package/out/codeCoverage/generateCodeCoverageReport.d.ts +0 -1
- package/out/codeCoverage/generateCodeCoverageReport.js +0 -30
- package/out/codeCoverage/generateCodeCoverageReport.js.map +0 -1
- package/out/codeCoverage/getCodeCoverageSetting.d.ts +0 -1
- package/out/codeCoverage/getCodeCoverageSetting.js +0 -58
- package/out/codeCoverage/getCodeCoverageSetting.js.map +0 -1
- package/out/codeCoverage/reportTool.d.ts +0 -2
- package/out/codeCoverage/reportTool.js +0 -22
- package/out/codeCoverage/reportTool.js.map +0 -1
- package/out/codeCoverage/simplifyCoverageXml.d.ts +0 -2
- package/out/codeCoverage/simplifyCoverageXml.js +0 -117
- package/out/codeCoverage/simplifyCoverageXml.js.map +0 -1
- package/out/codebk/250804prompt/buildAfGuidelines.liquid +0 -15
- package/out/codebk/250804prompt/general/generalBuildAutofixGuidelines.liquid +0 -13
- package/out/codebk/250804prompt/general/generalUtGuidelines.liquid +0 -18
- package/out/codebk/250804prompt/generateUtAutoFix.liquid +0 -19
- package/out/codebk/250804prompt/generateUtGuidelines.liquid +0 -13
- package/out/codebk/250804prompt/generateUtSystem.liquid +0 -5
- package/out/codebk/250804prompt/generateUtUserInput.liquid +0 -27
- package/out/codebk/250804prompt/testAfGuidelines.liquid +0 -6
- package/out/codebk/250804prompt/xap/xapBuildAutofixGuidelines.liquid +0 -13
- package/out/codebk/250804prompt/xap/xapCodeCodeDependency.liquid +0 -0
- package/out/codebk/250804prompt/xap/xapCodeSample.liquid +0 -38
- package/out/codebk/250804prompt/xap/xapUtGuideline-240804.liquid +0 -36
- package/out/codebk/250804prompt/xap/xapUtGuideline.liquid +0 -36
- package/out/codebk/childProcessManager.d.ts +0 -1
- package/out/codebk/childProcessManager.js +0 -50
- package/out/codebk/childProcessManager.js.map +0 -1
- package/out/codebk/msBuidSpawn.d.ts +0 -1
- package/out/codebk/msBuidSpawn.js +0 -58
- package/out/codebk/msBuidSpawn.js.map +0 -1
- package/out/codebk/msBuild.d.ts +0 -1
- package/out/codebk/msBuild.js +0 -123
- package/out/codebk/msBuild.js.map +0 -1
- package/out/codebk/old/generateXapTestAutoFix.liquid +0 -12
- package/out/codebk/old/generateXapTestGuidelines-fm.liquid +0 -68
- package/out/codebk/old/generateXapTestGuidelines.liquid +0 -28
- package/out/codebk/old/xapGuideline-fm.liquid +0 -149
- package/out/codebk/old/xapGuideline.liquid +0 -37
- package/out/codebk/oldExec/checkCodeSyntax.d.ts +0 -1
- package/out/codebk/oldExec/checkCodeSyntax.js +0 -81
- package/out/codebk/oldExec/checkCodeSyntax.js.map +0 -1
- package/out/codebk/oldExec/codeCoverage.d.ts +0 -1
- package/out/codebk/oldExec/codeCoverage.js +0 -54
- package/out/codebk/oldExec/codeCoverage.js.map +0 -1
- package/out/codebk/oldExec/codeCoverageReport.d.ts +0 -1
- package/out/codebk/oldExec/codeCoverageReport.js +0 -64
- package/out/codebk/oldExec/codeCoverageReport.js.map +0 -1
- package/out/codebk/oldExec/containsMethods.d.ts +0 -1
- package/out/codebk/oldExec/containsMethods.js +0 -74
- package/out/codebk/oldExec/containsMethods.js.map +0 -1
- package/out/codebk/oldExec/generateCodeDependency.d.ts +0 -1
- package/out/codebk/oldExec/generateCodeDependency.js +0 -95
- package/out/codebk/oldExec/generateCodeDependency.js.map +0 -1
- package/out/codebk/oldExec/msBuild.d.ts +0 -1
- package/out/codebk/oldExec/msBuild.js +0 -53
- package/out/codebk/oldExec/msBuild.js.map +0 -1
- package/out/codebk/oldExec/vsTest.d.ts +0 -1
- package/out/codebk/oldExec/vsTest.js +0 -71
- package/out/codebk/oldExec/vsTest.js.map +0 -1
- package/out/codebk/prompts/general/generalUnitTestGuidelines-20250702.liquid +0 -56
- package/out/codebk/prompts/generateXapTestGuidelines-20250704.liquid +0 -21
- package/out/codebk/prompts/generateXapTestGuidelines-o.liquid +0 -29
- package/out/codebk/prompts/xap/xapGuideline-o.liquid +0 -45
- package/out/codebk/testbuildkill.d.ts +0 -1
- package/out/codebk/testbuildkill.js +0 -37
- package/out/codebk/testbuildkill.js.map +0 -1
- package/out/command/index.d.ts +0 -2
- package/out/command/index.js +0 -94
- package/out/command/index.js.map +0 -1
- package/out/command/utGenWrapper.d.ts +0 -4
- package/out/command/utGenWrapper.js +0 -46
- package/out/command/utGenWrapper.js.map +0 -1
- package/out/exit/childProcessManager.d.ts +0 -2
- package/out/exit/childProcessManager.js +0 -43
- package/out/exit/childProcessManager.js.map +0 -1
- package/out/exit/setupProcessSignalHandler.d.ts +0 -1
- package/out/exit/setupProcessSignalHandler.js +0 -18
- package/out/exit/setupProcessSignalHandler.js.map +0 -1
- package/out/gen/autoFix.d.ts +0 -4
- package/out/gen/autoFix.js +0 -125
- package/out/gen/autoFix.js.map +0 -1
- package/out/gen/csharpUtGen.d.ts +0 -2
- package/out/gen/csharpUtGen.js +0 -125
- package/out/gen/csharpUtGen.js.map +0 -1
- package/out/gen/ensureValidLLMResponse.d.ts +0 -1
- package/out/gen/ensureValidLLMResponse.js +0 -19
- package/out/gen/ensureValidLLMResponse.js.map +0 -1
- package/out/gen/postGen/extractCodeFromResponse.d.ts +0 -1
- package/out/gen/postGen/extractCodeFromResponse.js +0 -37
- package/out/gen/postGen/extractCodeFromResponse.js.map +0 -1
- package/out/gen/postGen/postGenProcess.d.ts +0 -1
- package/out/gen/postGen/postGenProcess.js +0 -37
- package/out/gen/postGen/postGenProcess.js.map +0 -1
- package/out/gen/postGen/removeComments.d.ts +0 -1
- package/out/gen/postGen/removeComments.js +0 -92
- package/out/gen/postGen/removeComments.js.map +0 -1
- package/out/gen/postGen/removeSingleLines.d.ts +0 -1
- package/out/gen/postGen/removeSingleLines.js +0 -28
- package/out/gen/postGen/removeSingleLines.js.map +0 -1
- package/out/gen/postGen/repairRequiredNameSpaces.d.ts +0 -2
- package/out/gen/postGen/repairRequiredNameSpaces.js +0 -141
- package/out/gen/postGen/repairRequiredNameSpaces.js.map +0 -1
- package/out/gen/postGen/validateTestCode.d.ts +0 -1
- package/out/gen/postGen/validateTestCode.js +0 -14
- package/out/gen/postGen/validateTestCode.js.map +0 -1
- package/out/gen/preGen/excludeFileName.d.ts +0 -1
- package/out/gen/preGen/excludeFileName.js +0 -49
- package/out/gen/preGen/excludeFileName.js.map +0 -1
- package/out/gen/preGen/excludeSpecificTag.d.ts +0 -1
- package/out/gen/preGen/excludeSpecificTag.js +0 -18
- package/out/gen/preGen/excludeSpecificTag.js.map +0 -1
- package/out/gen/preGen/preGenProcess.d.ts +0 -1
- package/out/gen/preGen/preGenProcess.js +0 -22
- package/out/gen/preGen/preGenProcess.js.map +0 -1
- package/out/gen/preGen/validateCode.d.ts +0 -3
- package/out/gen/preGen/validateCode.js +0 -62
- package/out/gen/preGen/validateCode.js.map +0 -1
- package/out/index.d.ts +0 -3
- package/out/index.js +0 -10
- package/out/index.js.map +0 -1
- package/out/llm/model/Gpt.d.ts +0 -1
- package/out/llm/model/Gpt.js +0 -93
- package/out/llm/model/Gpt.js.map +0 -1
- package/out/llm/preparePrompt.d.ts +0 -2
- package/out/llm/preparePrompt.js +0 -135
- package/out/llm/preparePrompt.js.map +0 -1
- package/out/llm/prompt/buildAfGuidelines.liquid +0 -15
- package/out/llm/prompt/general/generalBuildAutofixGuidelines.liquid +0 -13
- package/out/llm/prompt/general/generalUtGuidelines.liquid +0 -16
- package/out/llm/prompt/generateUtAutoFix.liquid +0 -23
- package/out/llm/prompt/generateUtDependency.liquid +0 -3
- package/out/llm/prompt/generateUtSystem.liquid +0 -5
- package/out/llm/prompt/generateUtTemplate.liquid +0 -32
- package/out/llm/prompt/generateUtUserInput.liquid +0 -4
- package/out/llm/prompt/xap/xapBuildAutofixGuidelines.liquid +0 -13
- package/out/llm/prompt/xap/xapCodeCodeDependency.liquid +0 -0
- package/out/llm/prompt/xap/xapCodeSample.liquid +0 -38
- package/out/llm/prompt/xap/xapUtGuideline.liquid +0 -37
- package/out/llm/sendRequestToLLM.d.ts +0 -4
- package/out/llm/sendRequestToLLM.js +0 -9
- package/out/llm/sendRequestToLLM.js.map +0 -1
- package/out/llm/sendRequestToSelfHostLLM.d.ts +0 -4
- package/out/llm/sendRequestToSelfHostLLM.js +0 -41
- package/out/llm/sendRequestToSelfHostLLM.js.map +0 -1
- package/out/metrics/appInsightTelemetry.d.ts +0 -6
- package/out/metrics/appInsightTelemetry.js +0 -77
- package/out/metrics/appInsightTelemetry.js.map +0 -1
- package/out/metrics/machineId.d.ts +0 -11
- package/out/metrics/machineId.js +0 -85
- package/out/metrics/machineId.js.map +0 -1
- package/out/setup/setup.d.ts +0 -1
- package/out/setup/setup.js +0 -10
- package/out/setup/setup.js.map +0 -1
- package/out/setup/setupConsole.d.ts +0 -1
- package/out/setup/setupConsole.js +0 -23
- package/out/setup/setupConsole.js.map +0 -1
- package/out/setup/setupLLMRequest.d.ts +0 -2
- package/out/setup/setupLLMRequest.js +0 -10
- package/out/setup/setupLLMRequest.js.map +0 -1
- package/out/tools/devenvcom.cmd +0 -13
- package/out/tools/devenvexe.cmd +0 -13
- package/out/tools/msbuildexe.cmd +0 -13
- package/out/tools/vstestexe.cmd +0 -13
- package/out/types/benchmark.d.ts +0 -11
- package/out/types/benchmark.js +0 -3
- package/out/types/benchmark.js.map +0 -1
- package/out/types/buildResult.d.ts +0 -8
- package/out/types/buildResult.js +0 -3
- package/out/types/buildResult.js.map +0 -1
- package/out/types/constants.d.ts +0 -6
- package/out/types/constants.js +0 -10
- package/out/types/constants.js.map +0 -1
- package/out/types/genResult.d.ts +0 -10
- package/out/types/genResult.js +0 -3
- package/out/types/genResult.js.map +0 -1
- package/out/types/testResult.d.ts +0 -12
- package/out/types/testResult.js +0 -3
- package/out/types/testResult.js.map +0 -1
- package/out/types/verifyResult.d.ts +0 -8
- package/out/types/verifyResult.js +0 -3
- package/out/types/verifyResult.js.map +0 -1
- package/out/utils/checkTestProject.d.ts +0 -2
- package/out/utils/checkTestProject.js +0 -79
- package/out/utils/checkTestProject.js.map +0 -1
- package/out/utils/checkXapCode.d.ts +0 -2
- package/out/utils/checkXapCode.js +0 -59
- package/out/utils/checkXapCode.js.map +0 -1
- package/out/utils/delay.d.ts +0 -1
- package/out/utils/delay.js +0 -7
- package/out/utils/delay.js.map +0 -1
- package/out/utils/detectTestFramework.d.ts +0 -1
- package/out/utils/detectTestFramework.js +0 -33
- package/out/utils/detectTestFramework.js.map +0 -1
- package/out/utils/fileUtils.d.ts +0 -2
- package/out/utils/fileUtils.js +0 -42
- package/out/utils/fileUtils.js.map +0 -1
- package/out/utils/generateCodeSha256.d.ts +0 -1
- package/out/utils/generateCodeSha256.js +0 -46
- package/out/utils/generateCodeSha256.js.map +0 -1
- package/out/utils/getCodeStructurePath.d.ts +0 -5
- package/out/utils/getCodeStructurePath.js +0 -155
- package/out/utils/getCodeStructurePath.js.map +0 -1
- package/out/utils/getOrCreateDir.d.ts +0 -2
- package/out/utils/getOrCreateDir.js +0 -63
- package/out/utils/getOrCreateDir.js.map +0 -1
- package/out/utils/getTestCodeInfo.d.ts +0 -2
- package/out/utils/getTestCodeInfo.js +0 -121
- package/out/utils/getTestCodeInfo.js.map +0 -1
- package/out/utils/getTestFile.d.ts +0 -13
- package/out/utils/getTestFile.js +0 -295
- package/out/utils/getTestFile.js.map +0 -1
- package/out/utils/parseBuildResult.d.ts +0 -3
- package/out/utils/parseBuildResult.js +0 -44
- package/out/utils/parseBuildResult.js.map +0 -1
- package/out/utils/parseSyntaxCheckResult.d.ts +0 -2
- package/out/utils/parseSyntaxCheckResult.js +0 -38
- package/out/utils/parseSyntaxCheckResult.js.map +0 -1
- package/out/utils/parseVstestResult.d.ts +0 -3
- package/out/utils/parseVstestResult.js +0 -61
- package/out/utils/parseVstestResult.js.map +0 -1
- package/out/utils/removeFailedTestMethods.d.ts +0 -3
- package/out/utils/removeFailedTestMethods.js +0 -207
- package/out/utils/removeFailedTestMethods.js.map +0 -1
- package/out/utils/runCommand.d.ts +0 -1
- package/out/utils/runCommand.js +0 -14
- package/out/utils/runCommand.js.map +0 -1
- package/out/utils/spawnExec.d.ts +0 -1
- package/out/utils/spawnExec.js +0 -80
- package/out/utils/spawnExec.js.map +0 -1
- package/out/utils/verifyBuildErrorCausedFile.d.ts +0 -1
- package/out/utils/verifyBuildErrorCausedFile.js +0 -60
- package/out/utils/verifyBuildErrorCausedFile.js.map +0 -1
- package/out/utils/verifyTestCode.d.ts +0 -2
- package/out/utils/verifyTestCode.js +0 -25
- package/out/utils/verifyTestCode.js.map +0 -1
- package/out/utils/writeGenCode.d.ts +0 -1
- package/out/utils/writeGenCode.js +0 -50
- package/out/utils/writeGenCode.js.map +0 -1
- package/out/vs/msBuild.d.ts +0 -13
- package/out/vs/msBuild.js +0 -49
- package/out/vs/msBuild.js.map +0 -1
- package/out/vs/vsTest.d.ts +0 -15
- package/out/vs/vsTest.js +0 -75
- package/out/vs/vsTest.js.map +0 -1
- package/out/vs/vsTools.d.ts +0 -7
- package/out/vs/vsTools.js +0 -177
- package/out/vs/vsTools.js.map +0 -1
- package/out/vsPlugin/getVsPluginVerifyResult.d.ts +0 -2
- package/out/vsPlugin/getVsPluginVerifyResult.js +0 -41
- package/out/vsPlugin/getVsPluginVerifyResult.js.map +0 -1
- package/out/vsPlugin/interactionConstants.d.ts +0 -2
- package/out/vsPlugin/interactionConstants.js +0 -10
- package/out/vsPlugin/interactionConstants.js.map +0 -1
- package/out/vsPlugin/sendStdToVsPlugin.d.ts +0 -1
- package/out/vsPlugin/sendStdToVsPlugin.js +0 -12
- package/out/vsPlugin/sendStdToVsPlugin.js.map +0 -1
- package/out/vsPlugin/stdListener.d.ts +0 -3
- package/out/vsPlugin/stdListener.js +0 -57
- package/out/vsPlugin/stdListener.js.map +0 -1
package/out/llm/preparePrompt.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preparePrompt.js","sourceRoot":"","sources":["../../src/llm/preparePrompt.ts"],"names":[],"mappings":"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","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"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
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.
|
|
@@ -1,13 +0,0 @@
|
|
|
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}
|
|
@@ -1,16 +0,0 @@
|
|
|
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.
|
|
@@ -1,23 +0,0 @@
|
|
|
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 -%}
|
|
@@ -1,5 +0,0 @@
|
|
|
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.
|
|
@@ -1,32 +0,0 @@
|
|
|
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.
|
|
@@ -1,13 +0,0 @@
|
|
|
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}
|
|
File without changes
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
```
|
|
@@ -1,37 +0,0 @@
|
|
|
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()
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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}"]}
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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}"]}
|
|
@@ -1,77 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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}"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
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;
|