@ai-dev-tools/test-copilot-core 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/azure-pipelines.yml +51 -0
- package/out/cli/commands/appInsightTelemetry.d.ts +7 -0
- package/out/cli/commands/appInsightTelemetry.d.ts.map +1 -0
- package/out/cli/commands/appInsightTelemetry.js +76 -0
- package/out/cli/commands/appInsightTelemetry.js.map +1 -0
- package/out/cli/commands/cliConfig.d.ts +4 -0
- package/out/cli/commands/cliConfig.d.ts.map +1 -0
- package/out/cli/commands/cliConfig.js +68 -0
- package/out/cli/commands/cliConfig.js.map +1 -0
- package/out/cli/commands/prompt.d.ts +6 -0
- package/out/cli/commands/prompt.d.ts.map +1 -0
- package/out/cli/commands/prompt.js +29 -0
- package/out/cli/commands/prompt.js.map +1 -0
- package/out/cli/commands/ut.d.ts +14 -0
- package/out/cli/commands/ut.d.ts.map +1 -0
- package/out/cli/commands/ut.js +72 -0
- package/out/cli/commands/ut.js.map +1 -0
- package/out/cli/commands/utPipeCmdWrapper.d.ts +18 -0
- package/out/cli/commands/utPipeCmdWrapper.d.ts.map +1 -0
- package/out/cli/commands/utPipeCmdWrapper.js +37 -0
- package/out/cli/commands/utPipeCmdWrapper.js.map +1 -0
- package/out/cli/config/index.d.ts +15 -0
- package/out/cli/config/index.d.ts.map +1 -0
- package/out/cli/config/index.js +10 -0
- package/out/cli/config/index.js.map +1 -0
- package/out/cli/index.d.ts +3 -0
- package/out/cli/index.d.ts.map +1 -0
- package/out/cli/index.js +169 -0
- package/out/cli/index.js.map +1 -0
- package/out/cli/type.d.ts +11 -0
- package/out/cli/type.d.ts.map +1 -0
- package/out/cli/type.js +3 -0
- package/out/cli/type.js.map +1 -0
- package/out/cli/utils/ds.d.ts +3 -0
- package/out/cli/utils/ds.d.ts.map +1 -0
- package/out/cli/utils/ds.js +50 -0
- package/out/cli/utils/ds.js.map +1 -0
- package/out/cli/utils/gpt.d.ts +3 -0
- package/out/cli/utils/gpt.d.ts.map +1 -0
- package/out/cli/utils/gpt.js +63 -0
- package/out/cli/utils/gpt.js.map +1 -0
- package/out/core/analyze/cjs.d.ts +61 -0
- package/out/core/analyze/cjs.d.ts.map +1 -0
- package/out/core/analyze/cjs.js +358 -0
- package/out/core/analyze/cjs.js.map +1 -0
- package/out/core/analyze/class.d.ts +4 -0
- package/out/core/analyze/class.d.ts.map +1 -0
- package/out/core/analyze/class.js +32 -0
- package/out/core/analyze/class.js.map +1 -0
- package/out/core/analyze/declares.d.ts +7 -0
- package/out/core/analyze/declares.d.ts.map +1 -0
- package/out/core/analyze/declares.js +316 -0
- package/out/core/analyze/declares.js.map +1 -0
- package/out/core/analyze/deps.d.ts +8 -0
- package/out/core/analyze/deps.d.ts.map +1 -0
- package/out/core/analyze/deps.js +210 -0
- package/out/core/analyze/deps.js.map +1 -0
- package/out/core/analyze/functionComponent.d.ts +4 -0
- package/out/core/analyze/functionComponent.d.ts.map +1 -0
- package/out/core/analyze/functionComponent.js +77 -0
- package/out/core/analyze/functionComponent.js.map +1 -0
- package/out/core/analyze/functions.d.ts +4 -0
- package/out/core/analyze/functions.d.ts.map +1 -0
- package/out/core/analyze/functions.js +46 -0
- package/out/core/analyze/functions.js.map +1 -0
- package/out/core/analyze/index.d.ts +16 -0
- package/out/core/analyze/index.d.ts.map +1 -0
- package/out/core/analyze/index.js +149 -0
- package/out/core/analyze/index.js.map +1 -0
- package/out/core/analyze/index.type.d.ts +69 -0
- package/out/core/analyze/index.type.d.ts.map +1 -0
- package/out/core/analyze/index.type.js +14 -0
- package/out/core/analyze/index.type.js.map +1 -0
- package/out/core/analyze/utils/global.d.ts +2 -0
- package/out/core/analyze/utils/global.d.ts.map +1 -0
- package/out/core/analyze/utils/global.js +84 -0
- package/out/core/analyze/utils/global.js.map +1 -0
- package/out/core/analyzev2/declare/class.d.ts +4 -0
- package/out/core/analyzev2/declare/class.d.ts.map +1 -0
- package/out/core/analyzev2/declare/class.js +24 -0
- package/out/core/analyzev2/declare/class.js.map +1 -0
- package/out/core/analyzev2/declare/funcLike.d.ts +8 -0
- package/out/core/analyzev2/declare/funcLike.d.ts.map +1 -0
- package/out/core/analyzev2/declare/funcLike.js +71 -0
- package/out/core/analyzev2/declare/funcLike.js.map +1 -0
- package/out/core/analyzev2/declare/variable.d.ts +3 -0
- package/out/core/analyzev2/declare/variable.d.ts.map +1 -0
- package/out/core/analyzev2/declare/variable.js +15 -0
- package/out/core/analyzev2/declare/variable.js.map +1 -0
- package/out/core/analyzev2/file.d.ts +19 -0
- package/out/core/analyzev2/file.d.ts.map +1 -0
- package/out/core/analyzev2/file.js +449 -0
- package/out/core/analyzev2/file.js.map +1 -0
- package/out/core/analyzev2/index.d.ts +5 -0
- package/out/core/analyzev2/index.d.ts.map +1 -0
- package/out/core/analyzev2/index.js +30 -0
- package/out/core/analyzev2/index.js.map +1 -0
- package/out/core/analyzev2/type.d.ts +35 -0
- package/out/core/analyzev2/type.d.ts.map +1 -0
- package/out/core/analyzev2/type.js +3 -0
- package/out/core/analyzev2/type.js.map +1 -0
- package/out/core/config/index.d.ts +25 -0
- package/out/core/config/index.d.ts.map +1 -0
- package/out/core/config/index.js +14 -0
- package/out/core/config/index.js.map +1 -0
- package/out/core/constants.d.ts +9 -0
- package/out/core/constants.d.ts.map +1 -0
- package/out/core/constants.js +12 -0
- package/out/core/constants.js.map +1 -0
- package/out/core/features/common/base.d.ts +20 -0
- package/out/core/features/common/base.d.ts.map +1 -0
- package/out/core/features/common/base.js +77 -0
- package/out/core/features/common/base.js.map +1 -0
- package/out/core/features/common/types.d.ts +16 -0
- package/out/core/features/common/types.d.ts.map +1 -0
- package/out/core/features/common/types.js +12 -0
- package/out/core/features/common/types.js.map +1 -0
- package/out/core/features/generateFile.d.ts +31 -0
- package/out/core/features/generateFile.d.ts.map +1 -0
- package/out/core/features/generateFile.js +148 -0
- package/out/core/features/generateFile.js.map +1 -0
- package/out/core/features/generateSingle.d.ts +28 -0
- package/out/core/features/generateSingle.d.ts.map +1 -0
- package/out/core/features/generateSingle.js +149 -0
- package/out/core/features/generateSingle.js.map +1 -0
- package/out/core/features/index.d.ts +9 -0
- package/out/core/features/index.d.ts.map +1 -0
- package/out/core/features/index.js +16 -0
- package/out/core/features/index.js.map +1 -0
- package/out/core/features/lintFix.d.ts +2 -0
- package/out/core/features/lintFix.d.ts.map +1 -0
- package/out/core/features/lintFix.js +33 -0
- package/out/core/features/lintFix.js.map +1 -0
- package/out/core/features/mergeUTFile.d.ts +19 -0
- package/out/core/features/mergeUTFile.d.ts.map +1 -0
- package/out/core/features/mergeUTFile.js +63 -0
- package/out/core/features/mergeUTFile.js.map +1 -0
- package/out/core/features/removeFailedCases.d.ts +23 -0
- package/out/core/features/removeFailedCases.d.ts.map +1 -0
- package/out/core/features/removeFailedCases.js +81 -0
- package/out/core/features/removeFailedCases.js.map +1 -0
- package/out/core/features/updateSpec.d.ts +20 -0
- package/out/core/features/updateSpec.d.ts.map +1 -0
- package/out/core/features/updateSpec.js +98 -0
- package/out/core/features/updateSpec.js.map +1 -0
- package/out/core/features/validFix.d.ts +29 -0
- package/out/core/features/validFix.d.ts.map +1 -0
- package/out/core/features/validFix.js +219 -0
- package/out/core/features/validFix.js.map +1 -0
- package/out/core/generate/UTGen.d.ts +79 -0
- package/out/core/generate/UTGen.d.ts.map +1 -0
- package/out/core/generate/UTGen.js +795 -0
- package/out/core/generate/UTGen.js.map +1 -0
- package/out/core/llm/index.d.ts +9 -0
- package/out/core/llm/index.d.ts.map +1 -0
- package/out/core/llm/index.js +39 -0
- package/out/core/llm/index.js.map +1 -0
- package/out/core/llm/prompts/config.d.ts +6 -0
- package/out/core/llm/prompts/config.d.ts.map +1 -0
- package/out/core/llm/prompts/config.js +239 -0
- package/out/core/llm/prompts/config.js.map +1 -0
- package/out/core/llm/prompts/templates/common.d.ts +3 -0
- package/out/core/llm/prompts/templates/common.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/common.js +27 -0
- package/out/core/llm/prompts/templates/common.js.map +1 -0
- package/out/core/llm/prompts/templates/fixCase.d.ts +4 -0
- package/out/core/llm/prompts/templates/fixCase.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/fixCase.js +46 -0
- package/out/core/llm/prompts/templates/fixCase.js.map +1 -0
- package/out/core/llm/prompts/templates/fixLint.d.ts +3 -0
- package/out/core/llm/prompts/templates/fixLint.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/fixLint.js +22 -0
- package/out/core/llm/prompts/templates/fixLint.js.map +1 -0
- package/out/core/llm/prompts/templates/genClassMemberUT.d.ts +5 -0
- package/out/core/llm/prompts/templates/genClassMemberUT.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/genClassMemberUT.js +115 -0
- package/out/core/llm/prompts/templates/genClassMemberUT.js.map +1 -0
- package/out/core/llm/prompts/templates/genFuncUT.d.ts +4 -0
- package/out/core/llm/prompts/templates/genFuncUT.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/genFuncUT.js +64 -0
- package/out/core/llm/prompts/templates/genFuncUT.js.map +1 -0
- package/out/core/llm/prompts/templates/mergeUT.d.ts +4 -0
- package/out/core/llm/prompts/templates/mergeUT.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/mergeUT.js +106 -0
- package/out/core/llm/prompts/templates/mergeUT.js.map +1 -0
- package/out/core/llm/prompts/templates/msnStudio.d.ts +3 -0
- package/out/core/llm/prompts/templates/msnStudio.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/msnStudio.js +36 -0
- package/out/core/llm/prompts/templates/msnStudio.js.map +1 -0
- package/out/core/llm/prompts/templates/snapshotUT.d.ts +4 -0
- package/out/core/llm/prompts/templates/snapshotUT.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/snapshotUT.js +68 -0
- package/out/core/llm/prompts/templates/snapshotUT.js.map +1 -0
- package/out/core/llm/prompts/templates/updateSpecBlock.d.ts +3 -0
- package/out/core/llm/prompts/templates/updateSpecBlock.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/updateSpecBlock.js +38 -0
- package/out/core/llm/prompts/templates/updateSpecBlock.js.map +1 -0
- package/out/core/llm/prompts/templates/updateSpecFile.d.ts +3 -0
- package/out/core/llm/prompts/templates/updateSpecFile.d.ts.map +1 -0
- package/out/core/llm/prompts/templates/updateSpecFile.js +30 -0
- package/out/core/llm/prompts/templates/updateSpecFile.js.map +1 -0
- package/out/core/llm/types.d.ts +80 -0
- package/out/core/llm/types.d.ts.map +1 -0
- package/out/core/llm/types.js +5 -0
- package/out/core/llm/types.js.map +1 -0
- package/out/core/quality/validateMockedTest.d.ts +3 -0
- package/out/core/quality/validateMockedTest.d.ts.map +1 -0
- package/out/core/quality/validateMockedTest.js +211 -0
- package/out/core/quality/validateMockedTest.js.map +1 -0
- package/out/core/utils/checkTestIgnore.d.ts +4 -0
- package/out/core/utils/checkTestIgnore.d.ts.map +1 -0
- package/out/core/utils/checkTestIgnore.js +52 -0
- package/out/core/utils/checkTestIgnore.js.map +1 -0
- package/out/core/utils/common.d.ts +4 -0
- package/out/core/utils/common.d.ts.map +1 -0
- package/out/core/utils/common.js +34 -0
- package/out/core/utils/common.js.map +1 -0
- package/out/core/utils/console.d.ts +8 -0
- package/out/core/utils/console.d.ts.map +1 -0
- package/out/core/utils/console.js +24 -0
- package/out/core/utils/console.js.map +1 -0
- package/out/core/utils/deps.d.ts +3 -0
- package/out/core/utils/deps.d.ts.map +1 -0
- package/out/core/utils/deps.js +58 -0
- package/out/core/utils/deps.js.map +1 -0
- package/out/core/utils/eslintRuleHandler.d.ts +3 -0
- package/out/core/utils/eslintRuleHandler.d.ts.map +1 -0
- package/out/core/utils/eslintRuleHandler.js +98 -0
- package/out/core/utils/eslintRuleHandler.js.map +1 -0
- package/out/core/utils/file.d.ts +18 -0
- package/out/core/utils/file.d.ts.map +1 -0
- package/out/core/utils/file.js +142 -0
- package/out/core/utils/file.js.map +1 -0
- package/out/core/utils/lint.d.ts +9 -0
- package/out/core/utils/lint.d.ts.map +1 -0
- package/out/core/utils/lint.js +95 -0
- package/out/core/utils/lint.js.map +1 -0
- package/out/core/utils/lru.d.ts +12 -0
- package/out/core/utils/lru.d.ts.map +1 -0
- package/out/core/utils/lru.js +47 -0
- package/out/core/utils/lru.js.map +1 -0
- package/out/core/utils/move.d.ts +12 -0
- package/out/core/utils/move.d.ts.map +1 -0
- package/out/core/utils/move.js +93 -0
- package/out/core/utils/move.js.map +1 -0
- package/out/core/utils/msnStudio.d.ts +13 -0
- package/out/core/utils/msnStudio.d.ts.map +1 -0
- package/out/core/utils/msnStudio.js +150 -0
- package/out/core/utils/msnStudio.js.map +1 -0
- package/out/core/utils/parseCustomizedCmd.d.ts +2 -0
- package/out/core/utils/parseCustomizedCmd.d.ts.map +1 -0
- package/out/core/utils/parseCustomizedCmd.js +32 -0
- package/out/core/utils/parseCustomizedCmd.js.map +1 -0
- package/out/core/utils/specBlock.d.ts +20 -0
- package/out/core/utils/specBlock.d.ts.map +1 -0
- package/out/core/utils/specBlock.js +231 -0
- package/out/core/utils/specBlock.js.map +1 -0
- package/out/core/utils/system.d.ts +13 -0
- package/out/core/utils/system.d.ts.map +1 -0
- package/out/core/utils/system.js +86 -0
- package/out/core/utils/system.js.map +1 -0
- package/out/core/utils/telemetry.d.ts +9 -0
- package/out/core/utils/telemetry.d.ts.map +1 -0
- package/out/core/utils/telemetry.js +32 -0
- package/out/core/utils/telemetry.js.map +1 -0
- package/out/core/utils/tsMorph.d.ts +13 -0
- package/out/core/utils/tsMorph.d.ts.map +1 -0
- package/out/core/utils/tsMorph.js +76 -0
- package/out/core/utils/tsMorph.js.map +1 -0
- package/out/core/valid/customizedLint.d.ts +2 -0
- package/out/core/valid/customizedLint.d.ts.map +1 -0
- package/out/core/valid/customizedLint.js +64 -0
- package/out/core/valid/customizedLint.js.map +1 -0
- package/out/core/valid/customizedTest.d.ts +3 -0
- package/out/core/valid/customizedTest.d.ts.map +1 -0
- package/out/core/valid/customizedTest.js +58 -0
- package/out/core/valid/customizedTest.js.map +1 -0
- package/out/core/valid/extractVitestConfig.d.ts +5 -0
- package/out/core/valid/extractVitestConfig.d.ts.map +1 -0
- package/out/core/valid/extractVitestConfig.js +97 -0
- package/out/core/valid/extractVitestConfig.js.map +1 -0
- package/out/core/valid/getViteConfig.d.ts +2 -0
- package/out/core/valid/getViteConfig.d.ts.map +1 -0
- package/out/core/valid/getViteConfig.js +65 -0
- package/out/core/valid/getViteConfig.js.map +1 -0
- package/out/core/valid/index.d.ts +15 -0
- package/out/core/valid/index.d.ts.map +1 -0
- package/out/core/valid/index.js +99 -0
- package/out/core/valid/index.js.map +1 -0
- package/out/core/valid/jest.d.ts +4 -0
- package/out/core/valid/jest.d.ts.map +1 -0
- package/out/core/valid/jest.js +121 -0
- package/out/core/valid/jest.js.map +1 -0
- package/out/core/valid/mock.d.ts +2 -0
- package/out/core/valid/mock.d.ts.map +1 -0
- package/out/core/valid/mock.js +149 -0
- package/out/core/valid/mock.js.map +1 -0
- package/out/core/valid/remove.d.ts +5 -0
- package/out/core/valid/remove.d.ts.map +1 -0
- package/out/core/valid/remove.js +109 -0
- package/out/core/valid/remove.js.map +1 -0
- package/out/core/valid/tag.d.ts +3 -0
- package/out/core/valid/tag.d.ts.map +1 -0
- package/out/core/valid/tag.js +91 -0
- package/out/core/valid/tag.js.map +1 -0
- package/out/core/valid/type.d.ts +83 -0
- package/out/core/valid/type.d.ts.map +1 -0
- package/out/core/valid/type.js +3 -0
- package/out/core/valid/type.js.map +1 -0
- package/out/core/valid/vitest.d.ts +3 -0
- package/out/core/valid/vitest.d.ts.map +1 -0
- package/out/core/valid/vitest.js +82 -0
- package/out/core/valid/vitest.js.map +1 -0
- package/out/index.d.ts +20 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +60 -0
- package/out/index.js.map +1 -0
- package/out/setup.d.ts +11 -0
- package/out/setup.d.ts.map +1 -0
- package/out/setup.js +14 -0
- package/out/setup.js.map +1 -0
- package/out/types.d.ts +23 -0
- package/out/types.d.ts.map +1 -0
- package/out/types.js +3 -0
- package/out/types.js.map +1 -0
- package/package.json +39 -0
- package/package_devops.json +42 -0
package/out/cli/index.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const cliConfig_1 = require("./commands/cliConfig");
|
|
8
|
+
const constants_1 = require("../core/constants");
|
|
9
|
+
const yargs_1 = __importDefault(require("yargs/yargs"));
|
|
10
|
+
const prompt_1 = require("./commands/prompt");
|
|
11
|
+
const helpers_1 = require("yargs/helpers");
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const ut_1 = require("./commands/ut");
|
|
14
|
+
const utPipeCmdWrapper_1 = require("./commands/utPipeCmdWrapper");
|
|
15
|
+
// const hardcodedArgs = ['', '', 'utcmd', '--sourceMeta',
|
|
16
|
+
// '[{\"codePath\":\"D:/code/msnews-experiences/experiences/sports-retention-full/src/SportsRetentionFull.ts\",\"prompt\":\"\",\"covPath\":\"\",\"exclude\":[],\"lineRanges\":[[79,80],[100,101],[145,145],[384,384],[451,451]],\"methods\":[],\"testCodePath\":\"\",\"verifyTests\":1}]'];
|
|
17
|
+
function main() {
|
|
18
|
+
// Yargs(hideBin(hardcodedArgs))
|
|
19
|
+
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
20
|
+
.scriptName('test-copilot')
|
|
21
|
+
.option('source', {
|
|
22
|
+
alias: 's',
|
|
23
|
+
describe: 'where the test copilot is running',
|
|
24
|
+
choices: ['localCmd', 'vsplugin', 'cloudpipe', 'cloudbatch'],
|
|
25
|
+
default: 'localCmd',
|
|
26
|
+
type: 'string',
|
|
27
|
+
})
|
|
28
|
+
.option('mode', {
|
|
29
|
+
alias: 'm',
|
|
30
|
+
describe: 'test copilot work mode',
|
|
31
|
+
choices: ['generate', 'repair'],
|
|
32
|
+
default: 'repair',
|
|
33
|
+
type: 'string',
|
|
34
|
+
})
|
|
35
|
+
.option('type', {
|
|
36
|
+
// alias: 'l',
|
|
37
|
+
describe: 'type of test to generate',
|
|
38
|
+
choices: ['ut', 'vp', "snapshot"],
|
|
39
|
+
default: 'ut',
|
|
40
|
+
type: 'string',
|
|
41
|
+
})
|
|
42
|
+
.option('code', {
|
|
43
|
+
describe: 'code type',
|
|
44
|
+
choices: ['ts', 'c#'],
|
|
45
|
+
default: 'ts',
|
|
46
|
+
type: 'string',
|
|
47
|
+
})
|
|
48
|
+
.option('keepFailedTestFile', {
|
|
49
|
+
describe: 'whether to keep failed test file',
|
|
50
|
+
choices: [0, 1],
|
|
51
|
+
default: 0,
|
|
52
|
+
type: 'number',
|
|
53
|
+
})
|
|
54
|
+
.option('removeFailedTestCases', {
|
|
55
|
+
describe: 'whether to remove failed test cases',
|
|
56
|
+
choices: [0, 1],
|
|
57
|
+
default: 1,
|
|
58
|
+
type: 'number',
|
|
59
|
+
})
|
|
60
|
+
.option('skipFileLevelCheck', {
|
|
61
|
+
describe: 'whether to skip file level check for existing test file, to resolve negative code coverage issue',
|
|
62
|
+
choices: [0, 1],
|
|
63
|
+
default: 0,
|
|
64
|
+
type: 'number',
|
|
65
|
+
})
|
|
66
|
+
.option('enableCov', {
|
|
67
|
+
describe: 'whether to run coverage',
|
|
68
|
+
choices: [0, 1],
|
|
69
|
+
default: 0,
|
|
70
|
+
type: 'number',
|
|
71
|
+
})
|
|
72
|
+
.option('LLMModel', {
|
|
73
|
+
describe: 'use which LLM model',
|
|
74
|
+
default: "gpt4o",
|
|
75
|
+
type: 'string',
|
|
76
|
+
})
|
|
77
|
+
.option('LLMAuthKey', {
|
|
78
|
+
describe: 'LLM service Auth Key',
|
|
79
|
+
type: 'string',
|
|
80
|
+
})
|
|
81
|
+
.option('sourceMeta', {
|
|
82
|
+
describe: 'source meta data to generate test. it\'s json object string',
|
|
83
|
+
type: 'string',
|
|
84
|
+
})
|
|
85
|
+
.option('config', {
|
|
86
|
+
alias: 'c',
|
|
87
|
+
describe: 'Path to the configuration file',
|
|
88
|
+
type: 'string',
|
|
89
|
+
})
|
|
90
|
+
.option('target', {
|
|
91
|
+
alias: 't',
|
|
92
|
+
describe: 'Target file or directory',
|
|
93
|
+
type: 'string',
|
|
94
|
+
})
|
|
95
|
+
.option('line', {
|
|
96
|
+
alias: 'l',
|
|
97
|
+
describe: 'Target line in the code file (1-based; ignored if target is a directory)',
|
|
98
|
+
type: 'number',
|
|
99
|
+
})
|
|
100
|
+
.option('userName', {
|
|
101
|
+
describe: 'User name for telemetry',
|
|
102
|
+
type: 'string',
|
|
103
|
+
})
|
|
104
|
+
.option('testDirRelativeToPackage', {
|
|
105
|
+
alias: 'tdrtp',
|
|
106
|
+
describe: 'Test directory relative to package',
|
|
107
|
+
type: 'string',
|
|
108
|
+
})
|
|
109
|
+
.option('customizedTestCmd', {
|
|
110
|
+
alias: 'ctc',
|
|
111
|
+
describe: 'Custom command to run tests, If there are multiple CMDs, please separate them by a semicolon.',
|
|
112
|
+
type: 'string',
|
|
113
|
+
})
|
|
114
|
+
.option('customizedLintCmd', {
|
|
115
|
+
alias: 'clc',
|
|
116
|
+
describe: 'Custom command to run lint, If there are multiple CMDs, please separate them by a semicolon.',
|
|
117
|
+
type: 'string',
|
|
118
|
+
})
|
|
119
|
+
.command('init', 'Init config file', (yargs) => {
|
|
120
|
+
return yargs
|
|
121
|
+
.option('out', {
|
|
122
|
+
alias: 'o',
|
|
123
|
+
describe: 'Output file path',
|
|
124
|
+
type: 'string',
|
|
125
|
+
});
|
|
126
|
+
}, (c) => {
|
|
127
|
+
(0, cliConfig_1.initConfigFile)(c.out);
|
|
128
|
+
})
|
|
129
|
+
.command('ut', 'Generate unit test', (yargs) => {
|
|
130
|
+
return yargs
|
|
131
|
+
.option('runTest', {
|
|
132
|
+
describe: 'Run the test after running the code',
|
|
133
|
+
type: 'boolean',
|
|
134
|
+
default: true
|
|
135
|
+
})
|
|
136
|
+
.option('repair', {
|
|
137
|
+
describe: 'Repair the test if spec file already exists',
|
|
138
|
+
type: 'boolean',
|
|
139
|
+
default: false
|
|
140
|
+
});
|
|
141
|
+
}, (c) => {
|
|
142
|
+
const config = (0, cliConfig_1.readConfig)(c.config);
|
|
143
|
+
return (0, ut_1.runUT)({
|
|
144
|
+
...c,
|
|
145
|
+
config
|
|
146
|
+
});
|
|
147
|
+
})
|
|
148
|
+
.command('utcmd', 'Generate unit test using command line for pipeline', () => { }, (c) => {
|
|
149
|
+
return (0, utPipeCmdWrapper_1.runUTCmd)({
|
|
150
|
+
...c
|
|
151
|
+
});
|
|
152
|
+
})
|
|
153
|
+
.command('expose-prompt', 'Expose prompt template to customize', (yargs) => {
|
|
154
|
+
return yargs
|
|
155
|
+
.option('out', {
|
|
156
|
+
alias: 'o',
|
|
157
|
+
describe: 'Output file path',
|
|
158
|
+
type: 'string',
|
|
159
|
+
});
|
|
160
|
+
}, (c) => {
|
|
161
|
+
const outPath = path_1.default.resolve(c.out || `./${constants_1.TEST_COPILOT_CONFIG_PROMPTS_UT_TS}`);
|
|
162
|
+
(0, prompt_1.exposePrompt)(outPath);
|
|
163
|
+
})
|
|
164
|
+
.help()
|
|
165
|
+
.alias('help', 'h')
|
|
166
|
+
.parse();
|
|
167
|
+
}
|
|
168
|
+
main();
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;AAEA,oDAAkE;AAElE,iDAAsE;AACtE,wDAAgC;AAChC,8CAAiD;AACjD,2CAAwC;AACxC,gDAAwB;AACxB,sCAAsC;AACtC,kEAAuD;AAEvD,0DAA0D;AAC1D,+RAA+R;AAE/R,SAAS,IAAI;IACT,gCAAgC;IAChC,IAAA,eAAK,EAAC,IAAA,iBAAO,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YACX,KAAK,EAAE,GAAG;YACV,QAAQ,EAAE,kBAAkB;YAC5B,IAAI,EAAE,QAAQ;SACjB,CAAC,CAAC;IACX,CAAC,EACD,CAAC,CAAC,EAAE,EAAE;QACF,MAAM,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,6CAAiC,EAAE,CAAC,CAAC;QAChF,IAAA,qBAAY,EAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CACJ;SACA,IAAI,EAAE;SACN,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC;SAClB,KAAK,EAAE,CAAC;AACjB,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PromptConfigs } from "../core/llm";
|
|
2
|
+
import { CoreConfig } from "../core/config";
|
|
3
|
+
export interface ConfigFile {
|
|
4
|
+
customizePrompt?: true | string;
|
|
5
|
+
common?: CoreConfig['common'];
|
|
6
|
+
gpt?: CoreConfig['gpt'];
|
|
7
|
+
}
|
|
8
|
+
export interface CliConfig extends Omit<ConfigFile, 'customizePrompt'> {
|
|
9
|
+
promptConfigs?: Partial<PromptConfigs>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/cli/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,WAAW,UAAU;IACvB,eAAe,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9B,GAAG,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;CAC3B;AAED,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,UAAU,EAAE,iBAAiB,CAAC;IAClE,aAAa,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAC1C"}
|
package/out/cli/type.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/cli/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ds.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/ds.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAQ,MAAM,gBAAgB,CAAC;AAKpD,eAAO,MAAM,aAAa,EAAE,YAyC3B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDSResponse = void 0;
|
|
4
|
+
const identity_1 = require("@azure/identity");
|
|
5
|
+
const console_1 = require("../../core/utils/console");
|
|
6
|
+
const credential = new identity_1.DefaultAzureCredential(); // CodeQL [SM05138] This is non-production testing code which is not deployed.
|
|
7
|
+
const getDSResponse = async (messages) => {
|
|
8
|
+
const model = 'DeepSeekV3-AMD';
|
|
9
|
+
let start = Date.now();
|
|
10
|
+
const token = (await credential.getToken('api://5fe538a8-15d5-4a84-961e-be66cd036687/.default')).token;
|
|
11
|
+
console.log(`Token duration: ${Date.now() - start}ms`);
|
|
12
|
+
start = Date.now();
|
|
13
|
+
(0, console_1.getConsole)().log(`Fetching response from DeepSeek (${model})...`);
|
|
14
|
+
const res = await fetch('https://NorthCentralUS.papyrus.binginternal.com/chat/completions', {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: {
|
|
17
|
+
'Content-Type': 'application/json',
|
|
18
|
+
Authorization: `Bearer ${token}`,
|
|
19
|
+
"papyrus-model-name": model,
|
|
20
|
+
"papyrus-quota-id": 'deepseekamdmsnverticals',
|
|
21
|
+
"papyrus-timeout-ms": "600000",
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify({
|
|
24
|
+
messages: messages.map(el => ({
|
|
25
|
+
...el,
|
|
26
|
+
role: el.role === "system" /* Role.System */ ? "user" /* Role.User */ : el.role
|
|
27
|
+
})),
|
|
28
|
+
max_tokens: 4000
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
console.log(`Response duration: ${Date.now() - start}ms`);
|
|
32
|
+
const text = await res.text();
|
|
33
|
+
const json = JSON.parse(text);
|
|
34
|
+
const content = json.choices[0].message.content || '';
|
|
35
|
+
const [think, result] = content.split('</think>');
|
|
36
|
+
if (result) {
|
|
37
|
+
return {
|
|
38
|
+
reason: think.trim(),
|
|
39
|
+
content: result.trim(),
|
|
40
|
+
success: true
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
;
|
|
44
|
+
return {
|
|
45
|
+
content: content.trim(),
|
|
46
|
+
success: true
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
exports.getDSResponse = getDSResponse;
|
|
50
|
+
//# sourceMappingURL=ds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ds.js","sourceRoot":"","sources":["../../../src/cli/utils/ds.ts"],"names":[],"mappings":";;;AAAA,8CAAyD;AAEzD,sDAAsD;AAEtD,MAAM,UAAU,GAAG,IAAI,iCAAsB,EAAE,CAAC,CAAC,8EAA8E;AAExH,MAAM,aAAa,GAAiB,KAAK,EAAE,QAAQ,EAAE,EAAE;IAC1D,MAAM,KAAK,GAAG,gBAAgB,CAAC;IAC/B,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,KAAK,GAAG,CAAC,MAAM,UAAU,CAAC,QAAQ,CAAC,qDAAqD,CAAC,CAAC,CAAC,KAAK,CAAC;IACvG,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;IACvD,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACnB,IAAA,o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AAE,OAAO,CAAC,IAAI,EAAE;QACvB,OAAO,EAAE,IAAI;KAChB,CAAC;AACN,CAAC,CAAC;AAzCW,QAAA,aAAa,iBAyCxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpt.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/gpt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAQ,MAAM,gBAAgB,CAAC;AA0CpD,eAAO,MAAM,cAAc,EAAE,YA0B5B,CAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGPTResponse = void 0;
|
|
4
|
+
const identity_1 = require("@azure/identity");
|
|
5
|
+
const config_1 = require("../../core/config");
|
|
6
|
+
let cachedToken = null;
|
|
7
|
+
let tokenExpiration = null;
|
|
8
|
+
// platform provided endpoint
|
|
9
|
+
// const gpt4oEndpoint = "https://autogenerate-unit-tests-draft-1.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview";
|
|
10
|
+
const gpt5Endpoint = "https://peregrine-utgen-eus2.cognitiveservices.azure.com/openai/deployments/gpt-5-chat/chat/completions?api-version=2025-01-01-preview";
|
|
11
|
+
async function getToken() {
|
|
12
|
+
const currentTime = new Date().getTime();
|
|
13
|
+
// Check if the cached token is still valid
|
|
14
|
+
if (cachedToken && tokenExpiration && currentTime < tokenExpiration) {
|
|
15
|
+
return cachedToken;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const credential = new identity_1.ChainedTokenCredential(new identity_1.AzureCliCredential(), new identity_1.ManagedIdentityCredential(), new identity_1.DefaultAzureCredential() // CodeQL [SM05138] This is non-production testing code which is not deployed.
|
|
19
|
+
);
|
|
20
|
+
const tokenResponse = await credential.getToken('https://cognitiveservices.azure.com/.default');
|
|
21
|
+
if (tokenResponse) {
|
|
22
|
+
cachedToken = tokenResponse.token;
|
|
23
|
+
// Set token expiration time based on the token's expiresOnTimestamp
|
|
24
|
+
tokenExpiration = tokenResponse.expiresOnTimestamp;
|
|
25
|
+
return cachedToken;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw new Error('Failed to obtain token');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error('Error obtaining token:', error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const getGPTResponse = async (messages) => {
|
|
37
|
+
const token = await getToken();
|
|
38
|
+
const endpoint = (0, config_1.getConfig)().gpt?.api ?? gpt5Endpoint;
|
|
39
|
+
const res = await fetch(endpoint, {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
headers: {
|
|
42
|
+
'Content-Type': 'application/json',
|
|
43
|
+
Authorization: 'Bearer ' + token,
|
|
44
|
+
},
|
|
45
|
+
body: JSON.stringify({
|
|
46
|
+
messages: messages.map(el => ({
|
|
47
|
+
...el,
|
|
48
|
+
role: el.role === "system" /* Role.System */ ? "user" /* Role.User */ : el.role
|
|
49
|
+
})),
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
const json = await res.json();
|
|
53
|
+
if (!res.ok) {
|
|
54
|
+
console.error('GPT response error:', json.error);
|
|
55
|
+
return { success: false, content: undefined };
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
success: res.ok,
|
|
59
|
+
content: json.choices?.[0]?.message?.content
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
exports.getGPTResponse = getGPTResponse;
|
|
63
|
+
//# sourceMappingURL=gpt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpt.js","sourceRoot":"","sources":["../../../src/cli/utils/gpt.ts"],"names":[],"mappings":";;;AAAA,8CAAgI;AAGhI,8CAA8C;AAE9C,IAAI,WAAW,GAAG,IAAI,CAAC;AACvB,IAAI,eAAe,GAAG,IAAI,CAAC;AAC3B,6B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Aa,EAAE,SAAS,GAAG,KAAK;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACjB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC1B,GAAG,EAAE;gBACL,IAAI,EAAE,EAAE,CAAC,IAAI,+BAAgB,CAAC,CAAC,wBAAW,CAAC,CAAC,EAAE,CAAC,IAAI;aACtD,CAAC,CAAC;SACN,CAAC;KACL,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAS,CAAC;IACrC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAClD,CAAC;IACD,OAAO;QACH,OAAO,EAAE,GAAG,CAAC,EAAE;QACf,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO;KAC/C,CAAC;AACN,CAAC,CAAA;AA1BY,QAAA,cAAc,kBA0B1B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CodeDetailData } from "./index.type";
|
|
2
|
+
export declare function maybeCjs(fileName: string, fileContent: string): boolean;
|
|
3
|
+
export declare class CommonJSAnalyzer {
|
|
4
|
+
#private;
|
|
5
|
+
/**
|
|
6
|
+
* Analyzes a CommonJS file to extract imports and exports
|
|
7
|
+
*/
|
|
8
|
+
analyzeFile(filePath: string): CodeDetailData[];
|
|
9
|
+
/**
|
|
10
|
+
* Analyzes require() imports in a CommonJS file
|
|
11
|
+
*/
|
|
12
|
+
private analyzeRequireImports;
|
|
13
|
+
/**
|
|
14
|
+
* Extracts require() call information from a variable declaration
|
|
15
|
+
*/
|
|
16
|
+
private extractRequireInfo;
|
|
17
|
+
/**
|
|
18
|
+
* Processes a require declaration and adds it to the imports array
|
|
19
|
+
*/
|
|
20
|
+
private processRequireDeclaration;
|
|
21
|
+
/**
|
|
22
|
+
* Analyzes exports and module.exports in a CommonJS file
|
|
23
|
+
*/
|
|
24
|
+
private analyzeExports;
|
|
25
|
+
/**
|
|
26
|
+
* Processes a single export statement
|
|
27
|
+
*/
|
|
28
|
+
private processExportStatement;
|
|
29
|
+
/**
|
|
30
|
+
* Processes a named export (exports.xxx = ...)
|
|
31
|
+
*/
|
|
32
|
+
private processNamedExport;
|
|
33
|
+
/**
|
|
34
|
+
* Processes module.exports assignment
|
|
35
|
+
*/
|
|
36
|
+
private processModuleExport;
|
|
37
|
+
/**
|
|
38
|
+
* Processes object literal exports (module.exports = { ... })
|
|
39
|
+
*/
|
|
40
|
+
private processObjectLiteralExport;
|
|
41
|
+
/**
|
|
42
|
+
* Processes property assignment in object literal export
|
|
43
|
+
*/
|
|
44
|
+
private processPropertyAssignment;
|
|
45
|
+
/**
|
|
46
|
+
* Processes shorthand property in object literal export
|
|
47
|
+
*/
|
|
48
|
+
private processShorthandProperty;
|
|
49
|
+
private checkNode;
|
|
50
|
+
private extractFunction;
|
|
51
|
+
private extractClass;
|
|
52
|
+
/**
|
|
53
|
+
* Extracts class functions from a class expression
|
|
54
|
+
*/
|
|
55
|
+
private extractClassFunctions;
|
|
56
|
+
private extractRange;
|
|
57
|
+
private addClassFunction;
|
|
58
|
+
private findByName;
|
|
59
|
+
}
|
|
60
|
+
export declare function analyzeCommonJSFile(filePath: string): CodeDetailData[];
|
|
61
|
+
//# sourceMappingURL=cjs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cjs.d.ts","sourceRoot":"","sources":["../../../src/core/analyze/cjs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAoC,MAAM,cAAc,CAAC;AAMhF,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAUvE;AAED,qBAAa,gBAAgB;;IAQzB;;OAEG;IACI,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE;IAoDtD;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAkB7B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAsB1B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA6BjC;;OAEG;IACH,OAAO,CAAC,cAAc;IAoBtB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAY3B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAUlC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAejC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAShC,OAAO,CAAC,SAAS;IAiBjB,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,YAAY;IAuBpB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,UAAU;CAMrB;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,CAQtE"}
|