mta-mcp 3.0.0 → 3.1.0
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/agents/flutter.agent.md +17 -0
- package/agents/vue3.agent.md +17 -0
- package/bin/mta.cjs +98 -0
- package/dist/index.js +1668 -760
- package/dist/index.js.map +1 -1
- package/dist/skills/filesystem.d.ts +96 -0
- package/dist/skills/filesystem.js +269 -0
- package/dist/skills/filesystem.js.map +1 -0
- package/dist/skills/http.d.ts +73 -0
- package/dist/skills/http.js +234 -0
- package/dist/skills/http.js.map +1 -0
- package/dist/skills/index.d.ts +79 -0
- package/dist/skills/index.js +206 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/memory.d.ts +73 -0
- package/dist/skills/memory.js +223 -0
- package/dist/skills/memory.js.map +1 -0
- package/dist/skills/thinking.d.ts +48 -0
- package/dist/skills/thinking.js +199 -0
- package/dist/skills/thinking.js.map +1 -0
- package/dist/skills/versionChecker.d.ts +30 -0
- package/dist/skills/versionChecker.js +225 -0
- package/dist/skills/versionChecker.js.map +1 -0
- package/package.json +7 -2
- package/skills.json +68 -0
package/dist/index.js
CHANGED
|
@@ -18,8 +18,8 @@ var init_smartAgentMatcher = __esm({
|
|
|
18
18
|
"src/core/smartAgentMatcher.ts"() {
|
|
19
19
|
"use strict";
|
|
20
20
|
SmartAgentMatcher = class {
|
|
21
|
-
constructor(
|
|
22
|
-
this.logger =
|
|
21
|
+
constructor(logger9) {
|
|
22
|
+
this.logger = logger9;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* 分析项目特征
|
|
@@ -430,6 +430,30 @@ var init_smartAgentMatcher = __esm({
|
|
|
430
430
|
}
|
|
431
431
|
});
|
|
432
432
|
|
|
433
|
+
// src/core/types.ts
|
|
434
|
+
var ConsoleLogger;
|
|
435
|
+
var init_types = __esm({
|
|
436
|
+
"src/core/types.ts"() {
|
|
437
|
+
"use strict";
|
|
438
|
+
ConsoleLogger = class {
|
|
439
|
+
constructor(enableDebug = false) {
|
|
440
|
+
this.enableDebug = enableDebug;
|
|
441
|
+
}
|
|
442
|
+
log(message) {
|
|
443
|
+
console.error(`[MCP] [INFO] ${message}`);
|
|
444
|
+
}
|
|
445
|
+
error(message) {
|
|
446
|
+
console.error(`[MCP] [ERROR] ${message}`);
|
|
447
|
+
}
|
|
448
|
+
debug(message) {
|
|
449
|
+
if (this.enableDebug) {
|
|
450
|
+
console.error(`[MCP] [DEBUG] ${message}`);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
|
|
433
457
|
// src/core/resourceLoader.ts
|
|
434
458
|
var resourceLoader_exports = {};
|
|
435
459
|
__export(resourceLoader_exports, {
|
|
@@ -439,9 +463,9 @@ __export(resourceLoader_exports, {
|
|
|
439
463
|
import * as fs4 from "fs";
|
|
440
464
|
import * as path4 from "path";
|
|
441
465
|
import { fileURLToPath } from "url";
|
|
442
|
-
function getResourceLoader(
|
|
466
|
+
function getResourceLoader(logger9) {
|
|
443
467
|
if (!resourceLoaderInstance) {
|
|
444
|
-
resourceLoaderInstance = new ResourceLoader(
|
|
468
|
+
resourceLoaderInstance = new ResourceLoader(logger9);
|
|
445
469
|
}
|
|
446
470
|
return resourceLoaderInstance;
|
|
447
471
|
}
|
|
@@ -453,9 +477,9 @@ var init_resourceLoader = __esm({
|
|
|
453
477
|
__filename = fileURLToPath(import.meta.url);
|
|
454
478
|
__dirname = path4.dirname(__filename);
|
|
455
479
|
ResourceLoader = class {
|
|
456
|
-
constructor(
|
|
480
|
+
constructor(logger9) {
|
|
457
481
|
this.initialized = false;
|
|
458
|
-
this.logger =
|
|
482
|
+
this.logger = logger9;
|
|
459
483
|
this.packageRoot = this.detectPackageRoot();
|
|
460
484
|
this.validateResources();
|
|
461
485
|
}
|
|
@@ -676,216 +700,1126 @@ var init_resourceLoader = __esm({
|
|
|
676
700
|
}
|
|
677
701
|
});
|
|
678
702
|
|
|
679
|
-
// src/
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
CallToolRequestSchema,
|
|
684
|
-
ListToolsRequestSchema,
|
|
685
|
-
ListResourcesRequestSchema,
|
|
686
|
-
ReadResourceRequestSchema
|
|
687
|
-
} from "@modelcontextprotocol/sdk/types.js";
|
|
688
|
-
|
|
689
|
-
// src/tools/analyzeProject.ts
|
|
690
|
-
init_smartAgentMatcher();
|
|
691
|
-
import * as fs3 from "fs";
|
|
692
|
-
import * as path3 from "path";
|
|
693
|
-
|
|
694
|
-
// src/core/i18nDetector.ts
|
|
695
|
-
import * as fs2 from "fs";
|
|
696
|
-
import * as path2 from "path";
|
|
697
|
-
import glob2 from "fast-glob";
|
|
698
|
-
var I18nDetector = class {
|
|
699
|
-
/**
|
|
700
|
-
* 检测项目的国际化配置
|
|
701
|
-
*/
|
|
702
|
-
static async detect(projectPath) {
|
|
703
|
-
const packageJsonPath = path2.join(projectPath, "package.json");
|
|
704
|
-
if (fs2.existsSync(packageJsonPath)) {
|
|
705
|
-
return this.detectFrontendI18n(projectPath, packageJsonPath);
|
|
706
|
-
}
|
|
707
|
-
const pubspecPath = path2.join(projectPath, "pubspec.yaml");
|
|
708
|
-
if (fs2.existsSync(pubspecPath)) {
|
|
709
|
-
return this.detectFlutterI18n(projectPath, pubspecPath);
|
|
710
|
-
}
|
|
711
|
-
return {
|
|
712
|
-
enabled: false,
|
|
713
|
-
type: "none",
|
|
714
|
-
configFiles: [],
|
|
715
|
-
messageFiles: [],
|
|
716
|
-
method: "",
|
|
717
|
-
example: "",
|
|
718
|
-
tips: ["\u9879\u76EE\u672A\u914D\u7F6E\u56FD\u9645\u5316\uFF0C\u5EFA\u8BAE\u6DFB\u52A0\u4E2D\u82F1\u53CC\u8BED\u652F\u6301"]
|
|
719
|
-
};
|
|
703
|
+
// src/core/errors.ts
|
|
704
|
+
function errorResponse(error) {
|
|
705
|
+
if (error instanceof MCPError) {
|
|
706
|
+
return error.toResponse();
|
|
720
707
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
708
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
709
|
+
return {
|
|
710
|
+
content: [{
|
|
711
|
+
type: "text",
|
|
712
|
+
text: JSON.stringify({
|
|
713
|
+
error: true,
|
|
714
|
+
code: 1e3 /* UNKNOWN */,
|
|
715
|
+
message
|
|
716
|
+
}, null, 2)
|
|
717
|
+
}]
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
var ERROR_MESSAGES, MCPError;
|
|
721
|
+
var init_errors = __esm({
|
|
722
|
+
"src/core/errors.ts"() {
|
|
723
|
+
"use strict";
|
|
724
|
+
ERROR_MESSAGES = {
|
|
725
|
+
[1e3 /* UNKNOWN */]: "\u672A\u77E5\u9519\u8BEF",
|
|
726
|
+
[1001 /* INVALID_PARAMETER */]: "\u53C2\u6570\u65E0\u6548",
|
|
727
|
+
[1002 /* NOT_FOUND */]: "\u8D44\u6E90\u672A\u627E\u5230",
|
|
728
|
+
[1003 /* PERMISSION_DENIED */]: "\u6743\u9650\u4E0D\u8DB3",
|
|
729
|
+
[2001 /* PROJECT_NOT_FOUND */]: "\u9879\u76EE\u76EE\u5F55\u4E0D\u5B58\u5728",
|
|
730
|
+
[2002 /* PROJECT_PARSE_ERROR */]: "\u9879\u76EE\u89E3\u6790\u5931\u8D25",
|
|
731
|
+
[2003 /* CONFIG_READ_ERROR */]: "\u914D\u7F6E\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25",
|
|
732
|
+
[3001 /* STANDARD_NOT_FOUND */]: "\u89C4\u8303\u672A\u627E\u5230",
|
|
733
|
+
[3002 /* STANDARD_LOAD_ERROR */]: "\u89C4\u8303\u52A0\u8F7D\u5931\u8D25",
|
|
734
|
+
[3003 /* PRESET_NOT_FOUND */]: "\u9884\u8BBE\u672A\u627E\u5230",
|
|
735
|
+
[4001 /* TEMPLATE_NOT_FOUND */]: "\u6A21\u677F\u672A\u627E\u5230",
|
|
736
|
+
[4002 /* TEMPLATE_PARSE_ERROR */]: "\u6A21\u677F\u89E3\u6790\u5931\u8D25",
|
|
737
|
+
[5001 /* AGENT_NOT_FOUND */]: "Agent \u672A\u627E\u5230",
|
|
738
|
+
[5002 /* AGENT_LOAD_ERROR */]: "Agent \u52A0\u8F7D\u5931\u8D25",
|
|
739
|
+
[6001 /* CONFIG_GENERATE_ERROR */]: "\u914D\u7F6E\u751F\u6210\u5931\u8D25",
|
|
740
|
+
[6002 /* FILE_WRITE_ERROR */]: "\u6587\u4EF6\u5199\u5165\u5931\u8D25"
|
|
730
741
|
};
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
return this.detectCustomI18n(projectPath);
|
|
741
|
-
}
|
|
742
|
-
/**
|
|
743
|
-
* 检测 vue-i18n 配置
|
|
744
|
-
*/
|
|
745
|
-
static detectVueI18n(projectPath) {
|
|
746
|
-
const configFiles = [];
|
|
747
|
-
const messageFiles = [];
|
|
748
|
-
const possibleConfigPaths = [
|
|
749
|
-
"src/i18n/index.ts",
|
|
750
|
-
"src/i18n/index.js",
|
|
751
|
-
"src/locales/index.ts",
|
|
752
|
-
"src/locales/index.js",
|
|
753
|
-
"i18n.config.ts",
|
|
754
|
-
"i18n.config.js"
|
|
755
|
-
];
|
|
756
|
-
for (const configPath of possibleConfigPaths) {
|
|
757
|
-
const fullPath = path2.join(projectPath, configPath);
|
|
758
|
-
if (fs2.existsSync(fullPath)) {
|
|
759
|
-
configFiles.push(configPath);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
const possibleMessageDirs = ["src/i18n", "src/locales", "src/lang"];
|
|
763
|
-
for (const dir of possibleMessageDirs) {
|
|
764
|
-
const fullDir = path2.join(projectPath, dir);
|
|
765
|
-
if (fs2.existsSync(fullDir)) {
|
|
766
|
-
const files = fs2.readdirSync(fullDir);
|
|
767
|
-
for (const file of files) {
|
|
768
|
-
if (/^(zh|en|ja|ko|fr|de|es).*\.(ts|js|json)$/.test(file)) {
|
|
769
|
-
messageFiles.push(path2.join(dir, file));
|
|
770
|
-
}
|
|
771
|
-
}
|
|
742
|
+
MCPError = class _MCPError extends Error {
|
|
743
|
+
constructor(code, message, options) {
|
|
744
|
+
const defaultMessage = ERROR_MESSAGES[code] || "\u672A\u77E5\u9519\u8BEF";
|
|
745
|
+
super(message || defaultMessage);
|
|
746
|
+
this.name = "MCPError";
|
|
747
|
+
this.code = code;
|
|
748
|
+
this.cause = options == null ? void 0 : options.cause;
|
|
749
|
+
this.context = options == null ? void 0 : options.context;
|
|
750
|
+
Object.setPrototypeOf(this, _MCPError.prototype);
|
|
772
751
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
"\u6240\u6709\u6309\u94AE\u3001\u6807\u7B7E\u3001\u63D0\u793A\u6587\u5B57\u5FC5\u987B\u4F7F\u7528 $t()",
|
|
784
|
-
"\u8868\u5355\u9A8C\u8BC1\u89C4\u5219\u7684 message \u4E5F\u9700\u8981\u56FD\u9645\u5316",
|
|
785
|
-
"\u786E\u4FDD zh-CN.ts \u548C en-US.ts \u4E2D\u7684\u952E\u540D\u5B8C\u5168\u4E00\u81F4"
|
|
786
|
-
]
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
/**
|
|
790
|
-
* 检测 react-i18next 配置
|
|
791
|
-
*/
|
|
792
|
-
static detectReactI18n(projectPath) {
|
|
793
|
-
const configFiles = [];
|
|
794
|
-
const messageFiles = [];
|
|
795
|
-
const possibleConfigPaths = [
|
|
796
|
-
"src/i18n.ts",
|
|
797
|
-
"src/i18n.js",
|
|
798
|
-
"src/i18n/config.ts",
|
|
799
|
-
"src/i18n/config.js"
|
|
800
|
-
];
|
|
801
|
-
for (const configPath of possibleConfigPaths) {
|
|
802
|
-
const fullPath = path2.join(projectPath, configPath);
|
|
803
|
-
if (fs2.existsSync(fullPath)) {
|
|
804
|
-
configFiles.push(configPath);
|
|
752
|
+
/**
|
|
753
|
+
* 转换为 JSON 格式(用于 MCP 响应)
|
|
754
|
+
*/
|
|
755
|
+
toJSON() {
|
|
756
|
+
return {
|
|
757
|
+
error: true,
|
|
758
|
+
code: this.code,
|
|
759
|
+
message: this.message,
|
|
760
|
+
...this.context && { context: this.context }
|
|
761
|
+
};
|
|
805
762
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
}
|
|
816
|
-
}
|
|
763
|
+
/**
|
|
764
|
+
* 转换为 MCP 响应格式
|
|
765
|
+
*/
|
|
766
|
+
toResponse() {
|
|
767
|
+
return {
|
|
768
|
+
content: [{
|
|
769
|
+
type: "text",
|
|
770
|
+
text: JSON.stringify(this.toJSON(), null, 2)
|
|
771
|
+
}]
|
|
772
|
+
};
|
|
817
773
|
}
|
|
818
|
-
}
|
|
819
|
-
return {
|
|
820
|
-
enabled: true,
|
|
821
|
-
type: "react-i18n",
|
|
822
|
-
configFiles,
|
|
823
|
-
messageFiles,
|
|
824
|
-
method: "t() \u6216 useTranslation()",
|
|
825
|
-
example: `{t('common.save')} \u6216 const { t } = useTranslation()`,
|
|
826
|
-
tips: [
|
|
827
|
-
"\u4F7F\u7528 useTranslation() hook \u83B7\u53D6 t \u51FD\u6570",
|
|
828
|
-
'\u547D\u540D\u7A7A\u95F4\u683C\u5F0F\uFF1At("common.save")',
|
|
829
|
-
"\u6240\u6709\u6587\u6848\u5FC5\u987B\u901A\u8FC7 t() \u51FD\u6570\u5305\u88F9",
|
|
830
|
-
"\u786E\u4FDD\u6240\u6709\u8BED\u8A00\u7684\u7FFB\u8BD1\u6587\u4EF6\u540C\u6B65\u66F4\u65B0"
|
|
831
|
-
]
|
|
832
774
|
};
|
|
833
775
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
]
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
// src/core/logger.ts
|
|
779
|
+
function createLogger(name) {
|
|
780
|
+
return new Logger2(name);
|
|
781
|
+
}
|
|
782
|
+
var LOG_LEVEL_NAMES, globalConfig, Logger2, logger;
|
|
783
|
+
var init_logger = __esm({
|
|
784
|
+
"src/core/logger.ts"() {
|
|
785
|
+
"use strict";
|
|
786
|
+
LOG_LEVEL_NAMES = {
|
|
787
|
+
[0 /* DEBUG */]: "DEBUG",
|
|
788
|
+
[1 /* INFO */]: "INFO",
|
|
789
|
+
[2 /* WARN */]: "WARN",
|
|
790
|
+
[3 /* ERROR */]: "ERROR",
|
|
791
|
+
[4 /* SILENT */]: "SILENT"
|
|
851
792
|
};
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
}
|
|
793
|
+
globalConfig = {
|
|
794
|
+
level: process.env.DEBUG ? 0 /* DEBUG */ : 1 /* INFO */,
|
|
795
|
+
timestamp: false,
|
|
796
|
+
prefix: "[MCP]"
|
|
797
|
+
};
|
|
798
|
+
Logger2 = class _Logger {
|
|
799
|
+
constructor(name, config) {
|
|
800
|
+
this.name = name || "";
|
|
801
|
+
this.config = { ...globalConfig, ...config };
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* 格式化日志消息
|
|
805
|
+
*/
|
|
806
|
+
format(level, message, ...args) {
|
|
807
|
+
const parts = [];
|
|
808
|
+
if (this.config.timestamp) {
|
|
809
|
+
parts.push((/* @__PURE__ */ new Date()).toISOString());
|
|
810
|
+
}
|
|
811
|
+
parts.push(this.config.prefix);
|
|
812
|
+
if (this.name) {
|
|
813
|
+
parts.push(`[${this.name}]`);
|
|
814
|
+
}
|
|
815
|
+
parts.push(`[${LOG_LEVEL_NAMES[level]}]`);
|
|
816
|
+
parts.push(message);
|
|
817
|
+
if (args.length > 0) {
|
|
818
|
+
const formatted = args.map((arg) => {
|
|
819
|
+
if (typeof arg === "object") {
|
|
820
|
+
try {
|
|
821
|
+
return JSON.stringify(arg, null, 2);
|
|
822
|
+
} catch {
|
|
823
|
+
return String(arg);
|
|
824
|
+
}
|
|
882
825
|
}
|
|
883
|
-
|
|
826
|
+
return String(arg);
|
|
827
|
+
});
|
|
828
|
+
parts.push(...formatted);
|
|
884
829
|
}
|
|
830
|
+
return parts.join(" ");
|
|
885
831
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
832
|
+
/**
|
|
833
|
+
* 检查日志级别是否应该输出
|
|
834
|
+
*/
|
|
835
|
+
shouldLog(level) {
|
|
836
|
+
return level >= this.config.level;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* 调试日志
|
|
840
|
+
*/
|
|
841
|
+
debug(message, ...args) {
|
|
842
|
+
if (this.shouldLog(0 /* DEBUG */)) {
|
|
843
|
+
console.error(this.format(0 /* DEBUG */, message, ...args));
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* 信息日志
|
|
848
|
+
*/
|
|
849
|
+
info(message, ...args) {
|
|
850
|
+
if (this.shouldLog(1 /* INFO */)) {
|
|
851
|
+
console.error(this.format(1 /* INFO */, message, ...args));
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* 简化的 log 方法(等同于 info)
|
|
856
|
+
*/
|
|
857
|
+
log(message, ...args) {
|
|
858
|
+
this.info(message, ...args);
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* 警告日志
|
|
862
|
+
*/
|
|
863
|
+
warn(message, ...args) {
|
|
864
|
+
if (this.shouldLog(2 /* WARN */)) {
|
|
865
|
+
console.error(this.format(2 /* WARN */, message, ...args));
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* 错误日志
|
|
870
|
+
*/
|
|
871
|
+
error(message, ...args) {
|
|
872
|
+
if (this.shouldLog(3 /* ERROR */)) {
|
|
873
|
+
console.error(this.format(3 /* ERROR */, message, ...args));
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* 创建子 Logger
|
|
878
|
+
*/
|
|
879
|
+
child(name) {
|
|
880
|
+
const childName = this.name ? `${this.name}:${name}` : name;
|
|
881
|
+
return new _Logger(childName, this.config);
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
logger = new Logger2();
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
// src/core/autoConfig.ts
|
|
889
|
+
import * as fs17 from "fs";
|
|
890
|
+
import * as path16 from "path";
|
|
891
|
+
function ensureWorkspaceConfig(workspacePath) {
|
|
892
|
+
var _a, _b;
|
|
893
|
+
const result = {
|
|
894
|
+
needsSetup: false,
|
|
895
|
+
wasFixed: false,
|
|
896
|
+
workspacePath
|
|
897
|
+
};
|
|
898
|
+
if (!workspacePath || !fs17.existsSync(workspacePath)) {
|
|
899
|
+
return result;
|
|
900
|
+
}
|
|
901
|
+
const cached = checkedWorkspaces.get(workspacePath);
|
|
902
|
+
const now = Date.now();
|
|
903
|
+
if (cached && cached.configured && now - cached.timestamp < CACHE_DURATION) {
|
|
904
|
+
return result;
|
|
905
|
+
}
|
|
906
|
+
const vscodeDir = path16.join(workspacePath, ".vscode");
|
|
907
|
+
const mcpJsonPath = path16.join(vscodeDir, "mcp.json");
|
|
908
|
+
const settingsPath = path16.join(vscodeDir, "settings.json");
|
|
909
|
+
let hasMtaConfig = false;
|
|
910
|
+
if (fs17.existsSync(mcpJsonPath)) {
|
|
911
|
+
try {
|
|
912
|
+
const config = JSON.parse(fs17.readFileSync(mcpJsonPath, "utf-8"));
|
|
913
|
+
hasMtaConfig = !!(((_a = config.servers) == null ? void 0 : _a.mta) || ((_b = config.mcpServers) == null ? void 0 : _b.mta));
|
|
914
|
+
} catch {
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
if (hasMtaConfig) {
|
|
918
|
+
checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
|
|
919
|
+
return result;
|
|
920
|
+
}
|
|
921
|
+
result.needsSetup = true;
|
|
922
|
+
try {
|
|
923
|
+
if (!fs17.existsSync(vscodeDir)) {
|
|
924
|
+
fs17.mkdirSync(vscodeDir, { recursive: true });
|
|
925
|
+
}
|
|
926
|
+
let mcpConfig = { servers: {} };
|
|
927
|
+
if (fs17.existsSync(mcpJsonPath)) {
|
|
928
|
+
try {
|
|
929
|
+
mcpConfig = JSON.parse(fs17.readFileSync(mcpJsonPath, "utf-8"));
|
|
930
|
+
if (!mcpConfig.servers) {
|
|
931
|
+
mcpConfig.servers = {};
|
|
932
|
+
}
|
|
933
|
+
} catch {
|
|
934
|
+
mcpConfig = { servers: {} };
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
mcpConfig.servers.mta = {
|
|
938
|
+
command: "npx",
|
|
939
|
+
args: ["-y", "mta-mcp"],
|
|
940
|
+
env: {}
|
|
941
|
+
};
|
|
942
|
+
fs17.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
943
|
+
let settings = {};
|
|
944
|
+
if (fs17.existsSync(settingsPath)) {
|
|
945
|
+
try {
|
|
946
|
+
settings = JSON.parse(fs17.readFileSync(settingsPath, "utf-8"));
|
|
947
|
+
} catch {
|
|
948
|
+
settings = {};
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
if (!settings["github.copilot.chat.mcp.enabled"]) {
|
|
952
|
+
settings["github.copilot.chat.mcp.enabled"] = true;
|
|
953
|
+
fs17.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
954
|
+
}
|
|
955
|
+
result.wasFixed = true;
|
|
956
|
+
result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${path16.basename(workspacePath)} \u914D\u7F6E MTA MCP\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3\u4F7F\u914D\u7F6E\u751F\u6548\u3002`;
|
|
957
|
+
checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
|
|
958
|
+
} catch (error) {
|
|
959
|
+
result.message = `\u26A0\uFE0F \u81EA\u52A8\u914D\u7F6E\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`;
|
|
960
|
+
}
|
|
961
|
+
return result;
|
|
962
|
+
}
|
|
963
|
+
var checkedWorkspaces, CACHE_DURATION;
|
|
964
|
+
var init_autoConfig = __esm({
|
|
965
|
+
"src/core/autoConfig.ts"() {
|
|
966
|
+
"use strict";
|
|
967
|
+
checkedWorkspaces = /* @__PURE__ */ new Map();
|
|
968
|
+
CACHE_DURATION = 5 * 60 * 1e3;
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
|
|
972
|
+
// src/core/index.ts
|
|
973
|
+
var init_core = __esm({
|
|
974
|
+
"src/core/index.ts"() {
|
|
975
|
+
"use strict";
|
|
976
|
+
init_errors();
|
|
977
|
+
init_logger();
|
|
978
|
+
init_autoConfig();
|
|
979
|
+
init_types();
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
// src/skills/http.ts
|
|
984
|
+
var http_exports = {};
|
|
985
|
+
__export(http_exports, {
|
|
986
|
+
handleHttpRequest: () => handleHttpRequest,
|
|
987
|
+
httpRequest: () => httpRequest,
|
|
988
|
+
httpRequestToolDefinition: () => httpRequestToolDefinition
|
|
989
|
+
});
|
|
990
|
+
import axios2 from "axios";
|
|
991
|
+
async function httpRequest(args) {
|
|
992
|
+
const { url, method = "GET", headers = {}, body, timeout = 3e4 } = args;
|
|
993
|
+
logger3.info(`\u53D1\u9001 ${method} \u8BF7\u6C42: ${url}`);
|
|
994
|
+
const startTime = Date.now();
|
|
995
|
+
try {
|
|
996
|
+
const config = {
|
|
997
|
+
url,
|
|
998
|
+
method,
|
|
999
|
+
headers,
|
|
1000
|
+
timeout,
|
|
1001
|
+
validateStatus: () => true
|
|
1002
|
+
// 不抛出 HTTP 错误
|
|
1003
|
+
};
|
|
1004
|
+
if (body && ["POST", "PUT", "PATCH"].includes(method)) {
|
|
1005
|
+
config.data = body;
|
|
1006
|
+
}
|
|
1007
|
+
const response = await axios2(config);
|
|
1008
|
+
const timing = Date.now() - startTime;
|
|
1009
|
+
const responseHeaders = {};
|
|
1010
|
+
for (const [key, value] of Object.entries(response.headers)) {
|
|
1011
|
+
if (typeof value === "string") {
|
|
1012
|
+
responseHeaders[key] = value;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
logger3.info(`\u8BF7\u6C42\u5B8C\u6210: ${response.status} ${response.statusText} (${timing}ms)`);
|
|
1016
|
+
return {
|
|
1017
|
+
status: response.status,
|
|
1018
|
+
statusText: response.statusText,
|
|
1019
|
+
headers: responseHeaders,
|
|
1020
|
+
data: response.data,
|
|
1021
|
+
timing
|
|
1022
|
+
};
|
|
1023
|
+
} catch (error) {
|
|
1024
|
+
const timing = Date.now() - startTime;
|
|
1025
|
+
logger3.error(`\u8BF7\u6C42\u5931\u8D25: ${error.message}`);
|
|
1026
|
+
return {
|
|
1027
|
+
status: 0,
|
|
1028
|
+
statusText: "Request Failed",
|
|
1029
|
+
headers: {},
|
|
1030
|
+
data: { error: error.message },
|
|
1031
|
+
timing
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
async function handleHttpRequest(args) {
|
|
1036
|
+
try {
|
|
1037
|
+
const result = await httpRequest(args);
|
|
1038
|
+
let output = `## HTTP \u54CD\u5E94
|
|
1039
|
+
|
|
1040
|
+
`;
|
|
1041
|
+
output += `**\u72B6\u6001**: ${result.status} ${result.statusText}
|
|
1042
|
+
`;
|
|
1043
|
+
output += `**\u8017\u65F6**: ${result.timing}ms
|
|
1044
|
+
|
|
1045
|
+
`;
|
|
1046
|
+
if (Object.keys(result.headers).length > 0) {
|
|
1047
|
+
output += `### \u54CD\u5E94\u5934
|
|
1048
|
+
\`\`\`json
|
|
1049
|
+
${JSON.stringify(result.headers, null, 2)}
|
|
1050
|
+
\`\`\`
|
|
1051
|
+
|
|
1052
|
+
`;
|
|
1053
|
+
}
|
|
1054
|
+
output += `### \u54CD\u5E94\u4F53
|
|
1055
|
+
`;
|
|
1056
|
+
if (typeof result.data === "object") {
|
|
1057
|
+
output += `\`\`\`json
|
|
1058
|
+
${JSON.stringify(result.data, null, 2)}
|
|
1059
|
+
\`\`\``;
|
|
1060
|
+
} else {
|
|
1061
|
+
output += `\`\`\`
|
|
1062
|
+
${result.data}
|
|
1063
|
+
\`\`\``;
|
|
1064
|
+
}
|
|
1065
|
+
return {
|
|
1066
|
+
content: [{ type: "text", text: output }]
|
|
1067
|
+
};
|
|
1068
|
+
} catch (error) {
|
|
1069
|
+
return {
|
|
1070
|
+
content: [{ type: "text", text: `\u274C HTTP \u8BF7\u6C42\u5931\u8D25: ${error.message}` }]
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
var logger3, httpRequestToolDefinition;
|
|
1075
|
+
var init_http = __esm({
|
|
1076
|
+
"src/skills/http.ts"() {
|
|
1077
|
+
"use strict";
|
|
1078
|
+
init_core();
|
|
1079
|
+
logger3 = createLogger("Skills:HTTP");
|
|
1080
|
+
httpRequestToolDefinition = {
|
|
1081
|
+
name: "http_request",
|
|
1082
|
+
description: "\u53D1\u9001 HTTP \u8BF7\u6C42\u3002\u652F\u6301 GET/POST/PUT/DELETE \u7B49\u65B9\u6CD5\uFF0C\u53EF\u81EA\u5B9A\u4E49\u8BF7\u6C42\u5934\u548C\u8BF7\u6C42\u4F53\u3002\u9002\u7528\u4E8E API \u6D4B\u8BD5\u3001\u6570\u636E\u83B7\u53D6\u7B49\u573A\u666F\u3002",
|
|
1083
|
+
inputSchema: {
|
|
1084
|
+
type: "object",
|
|
1085
|
+
properties: {
|
|
1086
|
+
url: {
|
|
1087
|
+
type: "string",
|
|
1088
|
+
description: "\u8BF7\u6C42 URL\uFF08\u5FC5\u987B\u662F\u5B8C\u6574 URL\uFF0C\u5305\u542B\u534F\u8BAE\uFF09"
|
|
1089
|
+
},
|
|
1090
|
+
method: {
|
|
1091
|
+
type: "string",
|
|
1092
|
+
enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
|
|
1093
|
+
default: "GET",
|
|
1094
|
+
description: "HTTP \u65B9\u6CD5"
|
|
1095
|
+
},
|
|
1096
|
+
headers: {
|
|
1097
|
+
type: "object",
|
|
1098
|
+
additionalProperties: { type: "string" },
|
|
1099
|
+
description: "\u8BF7\u6C42\u5934\uFF08\u5982 Authorization\u3001Content-Type \u7B49\uFF09"
|
|
1100
|
+
},
|
|
1101
|
+
body: {
|
|
1102
|
+
description: "\u8BF7\u6C42\u4F53\uFF08POST/PUT/PATCH \u65F6\u4F7F\u7528\uFF09"
|
|
1103
|
+
},
|
|
1104
|
+
timeout: {
|
|
1105
|
+
type: "number",
|
|
1106
|
+
default: 3e4,
|
|
1107
|
+
description: "\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09"
|
|
1108
|
+
}
|
|
1109
|
+
},
|
|
1110
|
+
required: ["url"]
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
|
|
1116
|
+
// src/skills/memory.ts
|
|
1117
|
+
var memory_exports = {};
|
|
1118
|
+
__export(memory_exports, {
|
|
1119
|
+
MEMORY_TOOLS: () => MEMORY_TOOLS,
|
|
1120
|
+
handleListMemories: () => handleListMemories,
|
|
1121
|
+
handleRetrieveMemory: () => handleRetrieveMemory,
|
|
1122
|
+
handleStoreMemory: () => handleStoreMemory,
|
|
1123
|
+
listMemories: () => listMemories,
|
|
1124
|
+
retrieveMemory: () => retrieveMemory,
|
|
1125
|
+
storeMemory: () => storeMemory
|
|
1126
|
+
});
|
|
1127
|
+
async function storeMemory(key, value) {
|
|
1128
|
+
memoryStore.set(key, value);
|
|
1129
|
+
logger4.info(`\u5DF2\u5B58\u50A8\u8BB0\u5FC6: ${key}`);
|
|
1130
|
+
}
|
|
1131
|
+
async function retrieveMemory(key) {
|
|
1132
|
+
const value = memoryStore.get(key);
|
|
1133
|
+
if (value) {
|
|
1134
|
+
logger4.info(`\u68C0\u7D22\u8BB0\u5FC6: ${key}`);
|
|
1135
|
+
return value;
|
|
1136
|
+
}
|
|
1137
|
+
logger4.warn(`\u8BB0\u5FC6\u4E0D\u5B58\u5728: ${key}`);
|
|
1138
|
+
return null;
|
|
1139
|
+
}
|
|
1140
|
+
async function listMemories() {
|
|
1141
|
+
const result = {};
|
|
1142
|
+
for (const [key, value] of memoryStore.entries()) {
|
|
1143
|
+
result[key] = value;
|
|
1144
|
+
}
|
|
1145
|
+
logger4.info(`\u5217\u51FA\u6240\u6709\u8BB0\u5FC6\uFF0C\u5171 ${memoryStore.size} \u6761`);
|
|
1146
|
+
return result;
|
|
1147
|
+
}
|
|
1148
|
+
async function handleStoreMemory(args) {
|
|
1149
|
+
const { key, value } = args;
|
|
1150
|
+
if (!key || !value) {
|
|
1151
|
+
return {
|
|
1152
|
+
error: "\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: key \u548C value"
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
await storeMemory(key, value);
|
|
1156
|
+
return {
|
|
1157
|
+
success: true,
|
|
1158
|
+
message: `\u5DF2\u5B58\u50A8\u8BB0\u5FC6: ${key}`
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
async function handleRetrieveMemory(args) {
|
|
1162
|
+
const { key } = args;
|
|
1163
|
+
if (!key) {
|
|
1164
|
+
return {
|
|
1165
|
+
error: "\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: key"
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
const value = await retrieveMemory(key);
|
|
1169
|
+
if (value === null) {
|
|
1170
|
+
return {
|
|
1171
|
+
found: false,
|
|
1172
|
+
message: `\u8BB0\u5FC6\u4E0D\u5B58\u5728: ${key}`
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
return {
|
|
1176
|
+
found: true,
|
|
1177
|
+
key,
|
|
1178
|
+
value
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
async function handleListMemories() {
|
|
1182
|
+
const memories = await listMemories();
|
|
1183
|
+
return {
|
|
1184
|
+
count: Object.keys(memories).length,
|
|
1185
|
+
memories
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
var logger4, memoryStore, MEMORY_TOOLS;
|
|
1189
|
+
var init_memory = __esm({
|
|
1190
|
+
"src/skills/memory.ts"() {
|
|
1191
|
+
"use strict";
|
|
1192
|
+
init_core();
|
|
1193
|
+
logger4 = createLogger("Skills:Memory");
|
|
1194
|
+
memoryStore = /* @__PURE__ */ new Map();
|
|
1195
|
+
MEMORY_TOOLS = [
|
|
1196
|
+
{
|
|
1197
|
+
name: "store_memory",
|
|
1198
|
+
description: "\u5B58\u50A8\u4E00\u6761\u8BB0\u5FC6\uFF0C\u7528\u4E8E\u8DE8\u4F1A\u8BDD\u4FDD\u5B58\u9879\u76EE\u7EA6\u5B9A\u3001\u4E1A\u52A1\u89C4\u5219\u7B49\u4FE1\u606F",
|
|
1199
|
+
inputSchema: {
|
|
1200
|
+
type: "object",
|
|
1201
|
+
properties: {
|
|
1202
|
+
key: {
|
|
1203
|
+
type: "string",
|
|
1204
|
+
description: "\u8BB0\u5FC6\u7684\u952E\uFF08\u552F\u4E00\u6807\u8BC6\uFF09"
|
|
1205
|
+
},
|
|
1206
|
+
value: {
|
|
1207
|
+
type: "string",
|
|
1208
|
+
description: "\u8BB0\u5FC6\u7684\u5185\u5BB9"
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
required: ["key", "value"]
|
|
1212
|
+
}
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
name: "retrieve_memory",
|
|
1216
|
+
description: "\u68C0\u7D22\u4E00\u6761\u8BB0\u5FC6",
|
|
1217
|
+
inputSchema: {
|
|
1218
|
+
type: "object",
|
|
1219
|
+
properties: {
|
|
1220
|
+
key: {
|
|
1221
|
+
type: "string",
|
|
1222
|
+
description: "\u8BB0\u5FC6\u7684\u952E"
|
|
1223
|
+
}
|
|
1224
|
+
},
|
|
1225
|
+
required: ["key"]
|
|
1226
|
+
}
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
name: "list_memories",
|
|
1230
|
+
description: "\u5217\u51FA\u6240\u6709\u5B58\u50A8\u7684\u8BB0\u5FC6",
|
|
1231
|
+
inputSchema: {
|
|
1232
|
+
type: "object",
|
|
1233
|
+
properties: {}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
];
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
// src/skills/filesystem.ts
|
|
1241
|
+
var filesystem_exports = {};
|
|
1242
|
+
__export(filesystem_exports, {
|
|
1243
|
+
FILESYSTEM_TOOLS: () => FILESYSTEM_TOOLS,
|
|
1244
|
+
batchRename: () => batchRename,
|
|
1245
|
+
globFiles: () => globFiles,
|
|
1246
|
+
handleBatchRename: () => handleBatchRename,
|
|
1247
|
+
handleGlobFiles: () => handleGlobFiles
|
|
1248
|
+
});
|
|
1249
|
+
import * as fs19 from "fs";
|
|
1250
|
+
import * as path18 from "path";
|
|
1251
|
+
import { glob as glob4 } from "fast-glob";
|
|
1252
|
+
async function globFiles(pattern, options) {
|
|
1253
|
+
try {
|
|
1254
|
+
const files = await glob4(pattern, {
|
|
1255
|
+
cwd: (options == null ? void 0 : options.cwd) || process.cwd(),
|
|
1256
|
+
ignore: (options == null ? void 0 : options.ignore) || ["**/node_modules/**", "**/.git/**"],
|
|
1257
|
+
absolute: false
|
|
1258
|
+
});
|
|
1259
|
+
logger5.info(`glob \u67E5\u627E: ${pattern}, \u627E\u5230 ${files.length} \u4E2A\u6587\u4EF6`);
|
|
1260
|
+
return files;
|
|
1261
|
+
} catch (error) {
|
|
1262
|
+
logger5.error(`glob \u67E5\u627E\u5931\u8D25: ${error}`);
|
|
1263
|
+
throw error;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
async function batchRename(files, pattern, replacement, options) {
|
|
1267
|
+
const cwd = (options == null ? void 0 : options.cwd) || process.cwd();
|
|
1268
|
+
const dryRun = (options == null ? void 0 : options.dryRun) || false;
|
|
1269
|
+
const changes = [];
|
|
1270
|
+
let success = 0;
|
|
1271
|
+
let failed = 0;
|
|
1272
|
+
const regex = new RegExp(pattern);
|
|
1273
|
+
for (const file of files) {
|
|
1274
|
+
const basename11 = path18.basename(file);
|
|
1275
|
+
const dirname11 = path18.dirname(file);
|
|
1276
|
+
if (!regex.test(basename11)) {
|
|
1277
|
+
continue;
|
|
1278
|
+
}
|
|
1279
|
+
const newBasename = basename11.replace(regex, replacement);
|
|
1280
|
+
if (newBasename === basename11) {
|
|
1281
|
+
continue;
|
|
1282
|
+
}
|
|
1283
|
+
const fromPath = path18.join(cwd, file);
|
|
1284
|
+
const toPath = path18.join(cwd, dirname11, newBasename);
|
|
1285
|
+
changes.push({
|
|
1286
|
+
from: file,
|
|
1287
|
+
to: path18.join(dirname11, newBasename)
|
|
1288
|
+
});
|
|
1289
|
+
if (!dryRun) {
|
|
1290
|
+
try {
|
|
1291
|
+
fs19.renameSync(fromPath, toPath);
|
|
1292
|
+
success++;
|
|
1293
|
+
logger5.info(`\u91CD\u547D\u540D: ${file} -> ${newBasename}`);
|
|
1294
|
+
} catch (error) {
|
|
1295
|
+
failed++;
|
|
1296
|
+
logger5.error(`\u91CD\u547D\u540D\u5931\u8D25: ${file} - ${error}`);
|
|
1297
|
+
}
|
|
1298
|
+
} else {
|
|
1299
|
+
success++;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
return { success, failed, changes };
|
|
1303
|
+
}
|
|
1304
|
+
async function handleGlobFiles(args) {
|
|
1305
|
+
const { pattern, cwd, ignore } = args;
|
|
1306
|
+
if (!pattern) {
|
|
1307
|
+
return {
|
|
1308
|
+
error: "\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: pattern"
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
try {
|
|
1312
|
+
const files = await globFiles(pattern, { cwd, ignore });
|
|
1313
|
+
return {
|
|
1314
|
+
count: files.length,
|
|
1315
|
+
files
|
|
1316
|
+
};
|
|
1317
|
+
} catch (error) {
|
|
1318
|
+
return {
|
|
1319
|
+
error: error.message
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
async function handleBatchRename(args) {
|
|
1324
|
+
const { files, pattern, replacement, cwd, dryRun } = args;
|
|
1325
|
+
if (!files || !pattern || !replacement) {
|
|
1326
|
+
return {
|
|
1327
|
+
error: "\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: files, pattern, replacement"
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
try {
|
|
1331
|
+
const result = await batchRename(files, pattern, replacement, { cwd, dryRun });
|
|
1332
|
+
return {
|
|
1333
|
+
...result,
|
|
1334
|
+
dryRun: dryRun || false,
|
|
1335
|
+
message: dryRun ? "\u6A21\u62DF\u8FD0\u884C\uFF0C\u672A\u5B9E\u9645\u6267\u884C\u91CD\u547D\u540D" : `\u6210\u529F\u91CD\u547D\u540D ${result.success} \u4E2A\u6587\u4EF6`
|
|
1336
|
+
};
|
|
1337
|
+
} catch (error) {
|
|
1338
|
+
return {
|
|
1339
|
+
error: error.message
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
var logger5, FILESYSTEM_TOOLS;
|
|
1344
|
+
var init_filesystem = __esm({
|
|
1345
|
+
"src/skills/filesystem.ts"() {
|
|
1346
|
+
"use strict";
|
|
1347
|
+
init_core();
|
|
1348
|
+
logger5 = createLogger("Skills:Filesystem");
|
|
1349
|
+
FILESYSTEM_TOOLS = [
|
|
1350
|
+
{
|
|
1351
|
+
name: "glob_files",
|
|
1352
|
+
description: "\u4F7F\u7528 glob \u6A21\u5F0F\u67E5\u627E\u6587\u4EF6\uFF0C\u652F\u6301\u901A\u914D\u7B26\uFF08\u5982 **/*.ts\uFF09",
|
|
1353
|
+
inputSchema: {
|
|
1354
|
+
type: "object",
|
|
1355
|
+
properties: {
|
|
1356
|
+
pattern: {
|
|
1357
|
+
type: "string",
|
|
1358
|
+
description: "glob \u6A21\u5F0F\uFF08\u5982 src/**/*.ts\uFF09"
|
|
1359
|
+
},
|
|
1360
|
+
cwd: {
|
|
1361
|
+
type: "string",
|
|
1362
|
+
description: "\u5DE5\u4F5C\u76EE\u5F55\uFF08\u53EF\u9009\uFF0C\u9ED8\u8BA4\u4E3A\u5F53\u524D\u76EE\u5F55\uFF09"
|
|
1363
|
+
},
|
|
1364
|
+
ignore: {
|
|
1365
|
+
type: "array",
|
|
1366
|
+
items: { type: "string" },
|
|
1367
|
+
description: "\u5FFD\u7565\u7684\u6A21\u5F0F\u5217\u8868\uFF08\u53EF\u9009\uFF09"
|
|
1368
|
+
}
|
|
1369
|
+
},
|
|
1370
|
+
required: ["pattern"]
|
|
1371
|
+
}
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
name: "batch_rename",
|
|
1375
|
+
description: "\u6279\u91CF\u91CD\u547D\u540D\u6587\u4EF6\uFF0C\u4F7F\u7528\u6B63\u5219\u8868\u8FBE\u5F0F\u66FF\u6362",
|
|
1376
|
+
inputSchema: {
|
|
1377
|
+
type: "object",
|
|
1378
|
+
properties: {
|
|
1379
|
+
files: {
|
|
1380
|
+
type: "array",
|
|
1381
|
+
items: { type: "string" },
|
|
1382
|
+
description: "\u8981\u91CD\u547D\u540D\u7684\u6587\u4EF6\u5217\u8868"
|
|
1383
|
+
},
|
|
1384
|
+
pattern: {
|
|
1385
|
+
type: "string",
|
|
1386
|
+
description: "\u6B63\u5219\u8868\u8FBE\u5F0F\u6A21\u5F0F\uFF08\u7528\u4E8E\u5339\u914D\u6587\u4EF6\u540D\uFF09"
|
|
1387
|
+
},
|
|
1388
|
+
replacement: {
|
|
1389
|
+
type: "string",
|
|
1390
|
+
description: "\u66FF\u6362\u5B57\u7B26\u4E32\uFF08\u652F\u6301 $1, $2 \u7B49\u6355\u83B7\u7EC4\uFF09"
|
|
1391
|
+
},
|
|
1392
|
+
cwd: {
|
|
1393
|
+
type: "string",
|
|
1394
|
+
description: "\u5DE5\u4F5C\u76EE\u5F55\uFF08\u53EF\u9009\uFF09"
|
|
1395
|
+
},
|
|
1396
|
+
dryRun: {
|
|
1397
|
+
type: "boolean",
|
|
1398
|
+
description: "\u6A21\u62DF\u8FD0\u884C\uFF0C\u4E0D\u5B9E\u9645\u6267\u884C\uFF08\u53EF\u9009\uFF09"
|
|
1399
|
+
}
|
|
1400
|
+
},
|
|
1401
|
+
required: ["files", "pattern", "replacement"]
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
];
|
|
1405
|
+
}
|
|
1406
|
+
});
|
|
1407
|
+
|
|
1408
|
+
// src/skills/thinking.ts
|
|
1409
|
+
var thinking_exports = {};
|
|
1410
|
+
__export(thinking_exports, {
|
|
1411
|
+
THINKING_TOOLS: () => THINKING_TOOLS,
|
|
1412
|
+
getThinkingHistory: () => getThinkingHistory,
|
|
1413
|
+
handleThinkStepByStep: () => handleThinkStepByStep,
|
|
1414
|
+
thinkStepByStep: () => thinkStepByStep
|
|
1415
|
+
});
|
|
1416
|
+
async function thinkStepByStep(problem, context) {
|
|
1417
|
+
logger6.info(`\u5F00\u59CB\u5206\u6B65\u601D\u8003: ${problem}`);
|
|
1418
|
+
const steps = [
|
|
1419
|
+
{
|
|
1420
|
+
step: 1,
|
|
1421
|
+
title: "\u95EE\u9898\u5206\u6790",
|
|
1422
|
+
analysis: `\u5206\u6790\u95EE\u9898: ${problem}
|
|
1423
|
+
${context ? `\u4E0A\u4E0B\u6587: ${context}` : ""}`
|
|
1424
|
+
},
|
|
1425
|
+
{
|
|
1426
|
+
step: 2,
|
|
1427
|
+
title: "\u62C6\u89E3\u5B50\u95EE\u9898",
|
|
1428
|
+
analysis: "\u5C06\u95EE\u9898\u62C6\u89E3\u4E3A\u591A\u4E2A\u53EF\u7BA1\u7406\u7684\u5B50\u95EE\u9898"
|
|
1429
|
+
},
|
|
1430
|
+
{
|
|
1431
|
+
step: 3,
|
|
1432
|
+
title: "\u8BC4\u4F30\u65B9\u6848",
|
|
1433
|
+
analysis: "\u8BC4\u4F30\u4E0D\u540C\u7684\u89E3\u51B3\u65B9\u6848\u53CA\u5176\u4F18\u7F3A\u70B9"
|
|
1434
|
+
},
|
|
1435
|
+
{
|
|
1436
|
+
step: 4,
|
|
1437
|
+
title: "\u9009\u62E9\u6700\u4F18\u65B9\u6848",
|
|
1438
|
+
analysis: "\u57FA\u4E8E\u8BC4\u4F30\u7ED3\u679C\u9009\u62E9\u6700\u9002\u5408\u7684\u65B9\u6848"
|
|
1439
|
+
}
|
|
1440
|
+
];
|
|
1441
|
+
const result = {
|
|
1442
|
+
problem,
|
|
1443
|
+
steps,
|
|
1444
|
+
finalConclusion: "\u7B49\u5F85 AI \u8865\u5145\u5177\u4F53\u7684\u601D\u8003\u5185\u5BB9",
|
|
1445
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1446
|
+
};
|
|
1447
|
+
thinkingHistory.push(result);
|
|
1448
|
+
return result;
|
|
1449
|
+
}
|
|
1450
|
+
async function handleThinkStepByStep(args) {
|
|
1451
|
+
const { problem, context } = args;
|
|
1452
|
+
if (!problem) {
|
|
1453
|
+
return {
|
|
1454
|
+
error: "\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: problem"
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
try {
|
|
1458
|
+
const result = await thinkStepByStep(problem, context);
|
|
1459
|
+
return {
|
|
1460
|
+
success: true,
|
|
1461
|
+
thinking: result,
|
|
1462
|
+
guidance: [
|
|
1463
|
+
"1. \u8FD9\u662F\u4E00\u4E2A\u601D\u8003\u6846\u67B6\uFF0C\u8BF7\u57FA\u4E8E\u6B64\u6846\u67B6\u5C55\u5F00\u8BE6\u7EC6\u5206\u6790",
|
|
1464
|
+
"2. \u6BCF\u4E00\u6B65\u90FD\u9700\u8981\u6DF1\u5165\u601D\u8003\uFF0C\u4E0D\u8981\u6025\u4E8E\u5F97\u51FA\u7ED3\u8BBA",
|
|
1465
|
+
"3. \u8003\u8651\u591A\u4E2A\u89D2\u5EA6\u548C\u53EF\u80FD\u7684\u5F71\u54CD",
|
|
1466
|
+
"4. \u5728\u6700\u540E\u4E00\u6B65\u7ED9\u51FA\u660E\u786E\u7684\u5EFA\u8BAE\u6216\u7ED3\u8BBA"
|
|
1467
|
+
]
|
|
1468
|
+
};
|
|
1469
|
+
} catch (error) {
|
|
1470
|
+
return {
|
|
1471
|
+
error: error.message
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
function getThinkingHistory() {
|
|
1476
|
+
return thinkingHistory;
|
|
1477
|
+
}
|
|
1478
|
+
var logger6, thinkingHistory, THINKING_TOOLS;
|
|
1479
|
+
var init_thinking = __esm({
|
|
1480
|
+
"src/skills/thinking.ts"() {
|
|
1481
|
+
"use strict";
|
|
1482
|
+
init_core();
|
|
1483
|
+
logger6 = createLogger("Skills:Thinking");
|
|
1484
|
+
thinkingHistory = [];
|
|
1485
|
+
THINKING_TOOLS = [
|
|
1486
|
+
{
|
|
1487
|
+
name: "think_step_by_step",
|
|
1488
|
+
description: "\u5BF9\u590D\u6742\u95EE\u9898\u8FDB\u884C\u5206\u6B65\u601D\u8003\uFF0C\u9002\u7528\u4E8E\u67B6\u6784\u8BBE\u8BA1\u3001\u91CD\u6784\u89C4\u5212\u7B49\u9700\u8981\u6DF1\u5EA6\u5206\u6790\u7684\u573A\u666F",
|
|
1489
|
+
inputSchema: {
|
|
1490
|
+
type: "object",
|
|
1491
|
+
properties: {
|
|
1492
|
+
problem: {
|
|
1493
|
+
type: "string",
|
|
1494
|
+
description: "\u9700\u8981\u6DF1\u5165\u601D\u8003\u7684\u95EE\u9898\u6216\u4EFB\u52A1"
|
|
1495
|
+
},
|
|
1496
|
+
context: {
|
|
1497
|
+
type: "string",
|
|
1498
|
+
description: "\u76F8\u5173\u80CC\u666F\u4FE1\u606F\u6216\u7EA6\u675F\u6761\u4EF6\uFF08\u53EF\u9009\uFF09"
|
|
1499
|
+
}
|
|
1500
|
+
},
|
|
1501
|
+
required: ["problem"]
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
];
|
|
1505
|
+
}
|
|
1506
|
+
});
|
|
1507
|
+
|
|
1508
|
+
// src/skills/index.ts
|
|
1509
|
+
var skills_exports = {};
|
|
1510
|
+
__export(skills_exports, {
|
|
1511
|
+
SkillsManager: () => SkillsManager,
|
|
1512
|
+
getSkillsManager: () => getSkillsManager
|
|
1513
|
+
});
|
|
1514
|
+
import * as fs20 from "fs";
|
|
1515
|
+
import * as path19 from "path";
|
|
1516
|
+
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
1517
|
+
function getSkillsManager() {
|
|
1518
|
+
if (!skillsManagerInstance) {
|
|
1519
|
+
skillsManagerInstance = new SkillsManager();
|
|
1520
|
+
}
|
|
1521
|
+
return skillsManagerInstance;
|
|
1522
|
+
}
|
|
1523
|
+
var __filename8, __dirname8, logger7, SkillsManager, skillsManagerInstance;
|
|
1524
|
+
var init_skills = __esm({
|
|
1525
|
+
"src/skills/index.ts"() {
|
|
1526
|
+
"use strict";
|
|
1527
|
+
init_core();
|
|
1528
|
+
__filename8 = fileURLToPath8(import.meta.url);
|
|
1529
|
+
__dirname8 = path19.dirname(__filename8);
|
|
1530
|
+
logger7 = createLogger("Skills");
|
|
1531
|
+
SkillsManager = class {
|
|
1532
|
+
constructor() {
|
|
1533
|
+
this.registry = null;
|
|
1534
|
+
this.loadRegistry();
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* 加载 Skills 注册表
|
|
1538
|
+
* 从 npm 包内的 skills.json 加载,无需本地配置
|
|
1539
|
+
*/
|
|
1540
|
+
loadRegistry() {
|
|
1541
|
+
var _a, _b;
|
|
1542
|
+
try {
|
|
1543
|
+
const registryPath = path19.join(__dirname8, "../../skills.json");
|
|
1544
|
+
if (fs20.existsSync(registryPath)) {
|
|
1545
|
+
this.registry = JSON.parse(fs20.readFileSync(registryPath, "utf-8"));
|
|
1546
|
+
const enabledCount = Object.values(((_a = this.registry) == null ? void 0 : _a.skills) || {}).filter((s) => s.enabled).length;
|
|
1547
|
+
const totalCount = Object.keys(((_b = this.registry) == null ? void 0 : _b.skills) || {}).length;
|
|
1548
|
+
logger7.info(`Skills \u6CE8\u518C\u8868\u5DF2\u52A0\u8F7D\uFF1A${enabledCount}/${totalCount} \u4E2A\u5DF2\u542F\u7528`);
|
|
1549
|
+
} else {
|
|
1550
|
+
logger7.warn("skills.json \u4E0D\u5B58\u5728\uFF0CSkills \u529F\u80FD\u4E0D\u53EF\u7528");
|
|
1551
|
+
}
|
|
1552
|
+
} catch (error) {
|
|
1553
|
+
logger7.warn("\u52A0\u8F7D Skills \u6CE8\u518C\u8868\u5931\u8D25", error);
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
/**
|
|
1557
|
+
* 获取所有已启用的 Skills
|
|
1558
|
+
*/
|
|
1559
|
+
getEnabledSkills() {
|
|
1560
|
+
if (!this.registry) return [];
|
|
1561
|
+
return Object.values(this.registry.skills).filter((skill) => skill.enabled);
|
|
1562
|
+
}
|
|
1563
|
+
/**
|
|
1564
|
+
* 检查 Skill 是否可用(已启用且依赖包已集成)
|
|
1565
|
+
*/
|
|
1566
|
+
isSkillAvailable(skillId) {
|
|
1567
|
+
const skill = this.getSkill(skillId);
|
|
1568
|
+
return (skill == null ? void 0 : skill.enabled) === true;
|
|
1569
|
+
}
|
|
1570
|
+
/**
|
|
1571
|
+
* 获取 Skill 配置
|
|
1572
|
+
*/
|
|
1573
|
+
getSkill(skillId) {
|
|
1574
|
+
if (!this.registry) return null;
|
|
1575
|
+
return this.registry.skills[skillId] || null;
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
* 获取所有 Skills 信息(用于状态展示)
|
|
1579
|
+
*/
|
|
1580
|
+
getAllSkillsInfo() {
|
|
1581
|
+
if (!this.registry) return [];
|
|
1582
|
+
return Object.entries(this.registry.skills).map(([id, config]) => ({
|
|
1583
|
+
id,
|
|
1584
|
+
config
|
|
1585
|
+
}));
|
|
1586
|
+
}
|
|
1587
|
+
/**
|
|
1588
|
+
* 获取分类信息
|
|
1589
|
+
*/
|
|
1590
|
+
getCategories() {
|
|
1591
|
+
var _a;
|
|
1592
|
+
return ((_a = this.registry) == null ? void 0 : _a.categories) || {};
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* 获取注册表版本
|
|
1596
|
+
*/
|
|
1597
|
+
getVersion() {
|
|
1598
|
+
var _a;
|
|
1599
|
+
return ((_a = this.registry) == null ? void 0 : _a.version) || "0.0.0";
|
|
1600
|
+
}
|
|
1601
|
+
/**
|
|
1602
|
+
* 获取最后检查时间
|
|
1603
|
+
*/
|
|
1604
|
+
getLastCheck() {
|
|
1605
|
+
var _a;
|
|
1606
|
+
return ((_a = this.registry) == null ? void 0 : _a.lastCheck) || null;
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
1609
|
+
skillsManagerInstance = null;
|
|
1610
|
+
}
|
|
1611
|
+
});
|
|
1612
|
+
|
|
1613
|
+
// src/index.ts
|
|
1614
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
1615
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
1616
|
+
import {
|
|
1617
|
+
CallToolRequestSchema,
|
|
1618
|
+
ListToolsRequestSchema,
|
|
1619
|
+
ListResourcesRequestSchema,
|
|
1620
|
+
ReadResourceRequestSchema
|
|
1621
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
1622
|
+
|
|
1623
|
+
// src/tools/analyzeProject.ts
|
|
1624
|
+
init_smartAgentMatcher();
|
|
1625
|
+
import * as fs3 from "fs";
|
|
1626
|
+
import * as path3 from "path";
|
|
1627
|
+
|
|
1628
|
+
// src/core/i18nDetector.ts
|
|
1629
|
+
import * as fs2 from "fs";
|
|
1630
|
+
import * as path2 from "path";
|
|
1631
|
+
import glob2 from "fast-glob";
|
|
1632
|
+
var I18nDetector = class {
|
|
1633
|
+
/**
|
|
1634
|
+
* 检测项目的国际化配置
|
|
1635
|
+
*/
|
|
1636
|
+
static async detect(projectPath) {
|
|
1637
|
+
const packageJsonPath = path2.join(projectPath, "package.json");
|
|
1638
|
+
if (fs2.existsSync(packageJsonPath)) {
|
|
1639
|
+
return this.detectFrontendI18n(projectPath, packageJsonPath);
|
|
1640
|
+
}
|
|
1641
|
+
const pubspecPath = path2.join(projectPath, "pubspec.yaml");
|
|
1642
|
+
if (fs2.existsSync(pubspecPath)) {
|
|
1643
|
+
return this.detectFlutterI18n(projectPath, pubspecPath);
|
|
1644
|
+
}
|
|
1645
|
+
return {
|
|
1646
|
+
enabled: false,
|
|
1647
|
+
type: "none",
|
|
1648
|
+
configFiles: [],
|
|
1649
|
+
messageFiles: [],
|
|
1650
|
+
method: "",
|
|
1651
|
+
example: "",
|
|
1652
|
+
tips: ["\u9879\u76EE\u672A\u914D\u7F6E\u56FD\u9645\u5316\uFF0C\u5EFA\u8BAE\u6DFB\u52A0\u4E2D\u82F1\u53CC\u8BED\u652F\u6301"]
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* 检测前端项目的国际化配置(Vue/React)
|
|
1657
|
+
*/
|
|
1658
|
+
static detectFrontendI18n(projectPath, packageJsonPath) {
|
|
1659
|
+
const content = fs2.readFileSync(packageJsonPath, "utf-8");
|
|
1660
|
+
const packageJson = JSON.parse(content);
|
|
1661
|
+
const allDeps = {
|
|
1662
|
+
...packageJson.dependencies,
|
|
1663
|
+
...packageJson.devDependencies
|
|
1664
|
+
};
|
|
1665
|
+
if (allDeps["vue-i18n"]) {
|
|
1666
|
+
return this.detectVueI18n(projectPath);
|
|
1667
|
+
}
|
|
1668
|
+
if (allDeps["react-i18next"] || allDeps["i18next"]) {
|
|
1669
|
+
return this.detectReactI18n(projectPath);
|
|
1670
|
+
}
|
|
1671
|
+
if (allDeps["react-intl"]) {
|
|
1672
|
+
return this.detectReactIntl(projectPath);
|
|
1673
|
+
}
|
|
1674
|
+
return this.detectCustomI18n(projectPath);
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* 检测 vue-i18n 配置
|
|
1678
|
+
*/
|
|
1679
|
+
static detectVueI18n(projectPath) {
|
|
1680
|
+
const configFiles = [];
|
|
1681
|
+
const messageFiles = [];
|
|
1682
|
+
const possibleConfigPaths = [
|
|
1683
|
+
"src/i18n/index.ts",
|
|
1684
|
+
"src/i18n/index.js",
|
|
1685
|
+
"src/locales/index.ts",
|
|
1686
|
+
"src/locales/index.js",
|
|
1687
|
+
"i18n.config.ts",
|
|
1688
|
+
"i18n.config.js"
|
|
1689
|
+
];
|
|
1690
|
+
for (const configPath of possibleConfigPaths) {
|
|
1691
|
+
const fullPath = path2.join(projectPath, configPath);
|
|
1692
|
+
if (fs2.existsSync(fullPath)) {
|
|
1693
|
+
configFiles.push(configPath);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
const possibleMessageDirs = ["src/i18n", "src/locales", "src/lang"];
|
|
1697
|
+
for (const dir of possibleMessageDirs) {
|
|
1698
|
+
const fullDir = path2.join(projectPath, dir);
|
|
1699
|
+
if (fs2.existsSync(fullDir)) {
|
|
1700
|
+
const files = fs2.readdirSync(fullDir);
|
|
1701
|
+
for (const file of files) {
|
|
1702
|
+
if (/^(zh|en|ja|ko|fr|de|es).*\.(ts|js|json)$/.test(file)) {
|
|
1703
|
+
messageFiles.push(path2.join(dir, file));
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
return {
|
|
1709
|
+
enabled: true,
|
|
1710
|
+
type: "vue-i18n",
|
|
1711
|
+
configFiles,
|
|
1712
|
+
messageFiles,
|
|
1713
|
+
method: "$t()",
|
|
1714
|
+
example: `{{ $t('common.save') }} \u6216 :label="$t('user.username')"`,
|
|
1715
|
+
tips: [
|
|
1716
|
+
'\u4F7F\u7528\u547D\u540D\u7A7A\u95F4\u683C\u5F0F\uFF1A$t("common.save")',
|
|
1717
|
+
"\u6240\u6709\u6309\u94AE\u3001\u6807\u7B7E\u3001\u63D0\u793A\u6587\u5B57\u5FC5\u987B\u4F7F\u7528 $t()",
|
|
1718
|
+
"\u8868\u5355\u9A8C\u8BC1\u89C4\u5219\u7684 message \u4E5F\u9700\u8981\u56FD\u9645\u5316",
|
|
1719
|
+
"\u786E\u4FDD zh-CN.ts \u548C en-US.ts \u4E2D\u7684\u952E\u540D\u5B8C\u5168\u4E00\u81F4"
|
|
1720
|
+
]
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* 检测 react-i18next 配置
|
|
1725
|
+
*/
|
|
1726
|
+
static detectReactI18n(projectPath) {
|
|
1727
|
+
const configFiles = [];
|
|
1728
|
+
const messageFiles = [];
|
|
1729
|
+
const possibleConfigPaths = [
|
|
1730
|
+
"src/i18n.ts",
|
|
1731
|
+
"src/i18n.js",
|
|
1732
|
+
"src/i18n/config.ts",
|
|
1733
|
+
"src/i18n/config.js"
|
|
1734
|
+
];
|
|
1735
|
+
for (const configPath of possibleConfigPaths) {
|
|
1736
|
+
const fullPath = path2.join(projectPath, configPath);
|
|
1737
|
+
if (fs2.existsSync(fullPath)) {
|
|
1738
|
+
configFiles.push(configPath);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
const possibleMessageDirs = ["public/locales", "src/locales", "src/i18n"];
|
|
1742
|
+
for (const dir of possibleMessageDirs) {
|
|
1743
|
+
const fullDir = path2.join(projectPath, dir);
|
|
1744
|
+
if (fs2.existsSync(fullDir)) {
|
|
1745
|
+
const pattern = path2.join(fullDir, "**/*.json");
|
|
1746
|
+
try {
|
|
1747
|
+
const files = glob2.sync(pattern);
|
|
1748
|
+
messageFiles.push(...files.map((f) => path2.relative(projectPath, f)));
|
|
1749
|
+
} catch (e) {
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
return {
|
|
1754
|
+
enabled: true,
|
|
1755
|
+
type: "react-i18n",
|
|
1756
|
+
configFiles,
|
|
1757
|
+
messageFiles,
|
|
1758
|
+
method: "t() \u6216 useTranslation()",
|
|
1759
|
+
example: `{t('common.save')} \u6216 const { t } = useTranslation()`,
|
|
1760
|
+
tips: [
|
|
1761
|
+
"\u4F7F\u7528 useTranslation() hook \u83B7\u53D6 t \u51FD\u6570",
|
|
1762
|
+
'\u547D\u540D\u7A7A\u95F4\u683C\u5F0F\uFF1At("common.save")',
|
|
1763
|
+
"\u6240\u6709\u6587\u6848\u5FC5\u987B\u901A\u8FC7 t() \u51FD\u6570\u5305\u88F9",
|
|
1764
|
+
"\u786E\u4FDD\u6240\u6709\u8BED\u8A00\u7684\u7FFB\u8BD1\u6587\u4EF6\u540C\u6B65\u66F4\u65B0"
|
|
1765
|
+
]
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
/**
|
|
1769
|
+
* 检测 react-intl 配置
|
|
1770
|
+
*/
|
|
1771
|
+
static detectReactIntl(projectPath) {
|
|
1772
|
+
return {
|
|
1773
|
+
enabled: true,
|
|
1774
|
+
type: "react-i18n",
|
|
1775
|
+
configFiles: [],
|
|
1776
|
+
messageFiles: [],
|
|
1777
|
+
method: "formatMessage() \u6216 FormattedMessage",
|
|
1778
|
+
example: `<FormattedMessage id="common.save" /> \u6216 intl.formatMessage({ id: 'common.save' })`,
|
|
1779
|
+
tips: [
|
|
1780
|
+
"\u4F7F\u7528 FormattedMessage \u7EC4\u4EF6\u6216 formatMessage \u65B9\u6CD5",
|
|
1781
|
+
"\u6D88\u606F ID \u683C\u5F0F\uFF1Acommon.save",
|
|
1782
|
+
"\u6240\u6709\u6587\u6848\u5FC5\u987B\u5B9A\u4E49\u5728\u6D88\u606F\u6587\u4EF6\u4E2D",
|
|
1783
|
+
"\u786E\u4FDD\u591A\u8BED\u8A00\u6587\u4EF6\u7684\u6D88\u606F ID \u4FDD\u6301\u4E00\u81F4"
|
|
1784
|
+
]
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
/**
|
|
1788
|
+
* 检测自定义国际化方案
|
|
1789
|
+
*/
|
|
1790
|
+
static detectCustomI18n(projectPath) {
|
|
1791
|
+
const messageFiles = [];
|
|
1792
|
+
const possibleDirs = ["src/locales", "src/i18n", "src/lang"];
|
|
1793
|
+
for (const dir of possibleDirs) {
|
|
1794
|
+
const fullDir = path2.join(projectPath, dir);
|
|
1795
|
+
if (fs2.existsSync(fullDir)) {
|
|
1796
|
+
const files = fs2.readdirSync(fullDir);
|
|
1797
|
+
for (const file of files) {
|
|
1798
|
+
if (/messages?\.(ts|js)$/i.test(file)) {
|
|
1799
|
+
messageFiles.push(path2.join(dir, file));
|
|
1800
|
+
const content = fs2.readFileSync(path2.join(fullDir, file), "utf-8");
|
|
1801
|
+
if (content.includes("[") && content.includes("],")) {
|
|
1802
|
+
return {
|
|
1803
|
+
enabled: true,
|
|
1804
|
+
type: "custom",
|
|
1805
|
+
configFiles: [],
|
|
1806
|
+
messageFiles,
|
|
1807
|
+
method: "$t()",
|
|
1808
|
+
example: `{{ $t('\u4FDD\u5B58') }} \u6216 :label="$t('\u7528\u6237\u540D')"`,
|
|
1809
|
+
tips: [
|
|
1810
|
+
'\u4F7F\u7528\u76F4\u63A5\u952E\u540D\u683C\u5F0F\uFF1A$t("\u4FDD\u5B58")',
|
|
1811
|
+
"\u6240\u6709\u6309\u94AE\u3001\u6807\u7B7E\u3001\u63D0\u793A\u6587\u5B57\u5FC5\u987B\u4F7F\u7528 $t()",
|
|
1812
|
+
"\u8868\u5355\u9A8C\u8BC1\u89C4\u5219\u7684 message \u4E5F\u9700\u8981\u56FD\u9645\u5316",
|
|
1813
|
+
"\u65B0\u589E\u6587\u6848\u65F6\u9700\u8981\u540C\u65F6\u6DFB\u52A0\u4E2D\u82F1\u6587\u7FFB\u8BD1"
|
|
1814
|
+
]
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
if (messageFiles.length > 0) {
|
|
1822
|
+
return {
|
|
889
1823
|
enabled: true,
|
|
890
1824
|
type: "custom",
|
|
891
1825
|
configFiles: [],
|
|
@@ -980,32 +1914,15 @@ var I18nDetector = class {
|
|
|
980
1914
|
}
|
|
981
1915
|
};
|
|
982
1916
|
|
|
983
|
-
// src/core/types.ts
|
|
984
|
-
var ConsoleLogger = class {
|
|
985
|
-
constructor(enableDebug = false) {
|
|
986
|
-
this.enableDebug = enableDebug;
|
|
987
|
-
}
|
|
988
|
-
log(message) {
|
|
989
|
-
console.error(`[MCP] [INFO] ${message}`);
|
|
990
|
-
}
|
|
991
|
-
error(message) {
|
|
992
|
-
console.error(`[MCP] [ERROR] ${message}`);
|
|
993
|
-
}
|
|
994
|
-
debug(message) {
|
|
995
|
-
if (this.enableDebug) {
|
|
996
|
-
console.error(`[MCP] [DEBUG] ${message}`);
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
};
|
|
1000
|
-
|
|
1001
1917
|
// src/tools/analyzeProject.ts
|
|
1918
|
+
init_types();
|
|
1002
1919
|
async function analyzeProject(args) {
|
|
1003
|
-
const
|
|
1920
|
+
const logger9 = new ConsoleLogger();
|
|
1004
1921
|
try {
|
|
1005
1922
|
let projectPath = args.projectPath;
|
|
1006
1923
|
if (!projectPath) {
|
|
1007
1924
|
projectPath = process.cwd();
|
|
1008
|
-
|
|
1925
|
+
logger9.log(`\u{1F4CD} \u672A\u6307\u5B9A\u8DEF\u5F84\uFF0C\u4F7F\u7528\u5F53\u524D\u76EE\u5F55: ${projectPath}`);
|
|
1009
1926
|
}
|
|
1010
1927
|
if (!fs3.existsSync(projectPath)) {
|
|
1011
1928
|
return {
|
|
@@ -1017,14 +1934,14 @@ async function analyzeProject(args) {
|
|
|
1017
1934
|
}]
|
|
1018
1935
|
};
|
|
1019
1936
|
}
|
|
1020
|
-
const matcher = new SmartAgentMatcher(
|
|
1937
|
+
const matcher = new SmartAgentMatcher(logger9);
|
|
1021
1938
|
const workspaceFolder = {
|
|
1022
1939
|
uri: { fsPath: projectPath },
|
|
1023
1940
|
name: path3.basename(projectPath),
|
|
1024
1941
|
index: 0
|
|
1025
1942
|
};
|
|
1026
1943
|
const features = await matcher.analyzeProject(workspaceFolder);
|
|
1027
|
-
|
|
1944
|
+
logger9.log(`\u{1F30D} \u68C0\u6D4B\u56FD\u9645\u5316\u914D\u7F6E...`);
|
|
1028
1945
|
const i18nConfig = await I18nDetector.detect(projectPath);
|
|
1029
1946
|
return {
|
|
1030
1947
|
content: [{
|
|
@@ -1055,7 +1972,7 @@ async function analyzeProject(args) {
|
|
|
1055
1972
|
}]
|
|
1056
1973
|
};
|
|
1057
1974
|
} catch (error) {
|
|
1058
|
-
|
|
1975
|
+
logger9.error(`\u5206\u6790\u9879\u76EE\u5931\u8D25: ${error}`);
|
|
1059
1976
|
return {
|
|
1060
1977
|
content: [{
|
|
1061
1978
|
type: "text",
|
|
@@ -1069,13 +1986,14 @@ async function analyzeProject(args) {
|
|
|
1069
1986
|
|
|
1070
1987
|
// src/tools/matchAgents.ts
|
|
1071
1988
|
init_smartAgentMatcher();
|
|
1989
|
+
init_types();
|
|
1072
1990
|
init_resourceLoader();
|
|
1073
1991
|
async function matchAgents(args) {
|
|
1074
|
-
const
|
|
1992
|
+
const logger9 = new ConsoleLogger();
|
|
1075
1993
|
try {
|
|
1076
|
-
const matcher = new SmartAgentMatcher(
|
|
1077
|
-
const resourceLoader = getResourceLoader(
|
|
1078
|
-
|
|
1994
|
+
const matcher = new SmartAgentMatcher(logger9);
|
|
1995
|
+
const resourceLoader = getResourceLoader(logger9);
|
|
1996
|
+
logger9.log("\u6B63\u5728\u4ECE\u5305\u5185\u52A0\u8F7D Agents...");
|
|
1079
1997
|
const availableAgents = resourceLoader.loadAllAgents();
|
|
1080
1998
|
const matchedAgents = matcher.matchAgents(args.projectFeatures, availableAgents);
|
|
1081
1999
|
const limit = args.limit || 10;
|
|
@@ -1100,7 +2018,7 @@ async function matchAgents(args) {
|
|
|
1100
2018
|
}]
|
|
1101
2019
|
};
|
|
1102
2020
|
} catch (error) {
|
|
1103
|
-
|
|
2021
|
+
logger9.error(`\u5339\u914D Agents \u5931\u8D25: ${error}`);
|
|
1104
2022
|
return {
|
|
1105
2023
|
content: [{
|
|
1106
2024
|
type: "text",
|
|
@@ -1187,8 +2105,8 @@ import { fileURLToPath as fileURLToPath4 } from "url";
|
|
|
1187
2105
|
// src/core/githubClient.ts
|
|
1188
2106
|
import axios from "axios";
|
|
1189
2107
|
var GitHubClient = class {
|
|
1190
|
-
constructor(
|
|
1191
|
-
this.logger =
|
|
2108
|
+
constructor(logger9) {
|
|
2109
|
+
this.logger = logger9;
|
|
1192
2110
|
this.owner = "ForLear";
|
|
1193
2111
|
this.repo = "copilot-prompts";
|
|
1194
2112
|
this.branch = "main";
|
|
@@ -1243,11 +2161,13 @@ var GitHubClient = class {
|
|
|
1243
2161
|
|
|
1244
2162
|
// src/tools/generateConfig.ts
|
|
1245
2163
|
init_smartAgentMatcher();
|
|
2164
|
+
init_types();
|
|
1246
2165
|
|
|
1247
2166
|
// src/core/codeValidator.ts
|
|
2167
|
+
init_types();
|
|
1248
2168
|
var CodeValidator = class {
|
|
1249
|
-
constructor(
|
|
1250
|
-
this.logger =
|
|
2169
|
+
constructor(logger9) {
|
|
2170
|
+
this.logger = logger9 || new ConsoleLogger();
|
|
1251
2171
|
}
|
|
1252
2172
|
/**
|
|
1253
2173
|
* 验证生成的配置文件内容
|
|
@@ -1658,7 +2578,7 @@ ${variables.AGENTS_LIST}
|
|
|
1658
2578
|
var __filename4 = fileURLToPath4(import.meta.url);
|
|
1659
2579
|
var __dirname4 = path7.dirname(__filename4);
|
|
1660
2580
|
async function generateConfig(args) {
|
|
1661
|
-
const
|
|
2581
|
+
const logger9 = new ConsoleLogger();
|
|
1662
2582
|
try {
|
|
1663
2583
|
if (!fs7.existsSync(args.projectPath)) {
|
|
1664
2584
|
return {
|
|
@@ -1670,39 +2590,39 @@ async function generateConfig(args) {
|
|
|
1670
2590
|
}]
|
|
1671
2591
|
};
|
|
1672
2592
|
}
|
|
1673
|
-
const matcher = new SmartAgentMatcher(
|
|
1674
|
-
const githubClient = new GitHubClient(
|
|
2593
|
+
const matcher = new SmartAgentMatcher(logger9);
|
|
2594
|
+
const githubClient = new GitHubClient(logger9);
|
|
1675
2595
|
let selectedAgents = [];
|
|
1676
2596
|
if (args.autoMatch !== false) {
|
|
1677
|
-
|
|
2597
|
+
logger9.log("\u6B63\u5728\u5206\u6790\u9879\u76EE\u7279\u5F81...");
|
|
1678
2598
|
const workspaceFolder = {
|
|
1679
2599
|
uri: { fsPath: args.projectPath },
|
|
1680
2600
|
name: path7.basename(args.projectPath),
|
|
1681
2601
|
index: 0
|
|
1682
2602
|
};
|
|
1683
2603
|
const features = await matcher.analyzeProject(workspaceFolder);
|
|
1684
|
-
|
|
1685
|
-
const resourceLoader = getResourceLoader(
|
|
2604
|
+
logger9.log("\u6B63\u5728\u5339\u914D Agents...");
|
|
2605
|
+
const resourceLoader = getResourceLoader(logger9);
|
|
1686
2606
|
const availableAgents = resourceLoader.loadAllAgents();
|
|
1687
2607
|
if (availableAgents.length === 0) {
|
|
1688
2608
|
throw new Error("\u65E0\u6CD5\u52A0\u8F7D Agents\uFF0C\u8BF7\u68C0\u67E5 npm \u5305\u662F\u5426\u5B8C\u6574");
|
|
1689
2609
|
}
|
|
1690
|
-
|
|
2610
|
+
logger9.log(`\u6210\u529F\u52A0\u8F7D ${availableAgents.length} \u4E2A Agents`);
|
|
1691
2611
|
selectedAgents = matcher.matchAgents(features, availableAgents);
|
|
1692
|
-
|
|
2612
|
+
logger9.log(`\u5339\u914D\u5230 ${selectedAgents.length} \u4E2A Agents`);
|
|
1693
2613
|
selectedAgents = selectedAgents.slice(0, 5);
|
|
1694
2614
|
}
|
|
1695
2615
|
if (args.agentIds && args.agentIds.length > 0) {
|
|
1696
|
-
|
|
2616
|
+
logger9.log(`\u4F7F\u7528\u6307\u5B9A\u7684 Agents: ${args.agentIds.join(", ")}`);
|
|
1697
2617
|
selectedAgents = [];
|
|
1698
|
-
const resourceLoader = getResourceLoader(
|
|
2618
|
+
const resourceLoader = getResourceLoader(logger9);
|
|
1699
2619
|
for (const id of args.agentIds) {
|
|
1700
2620
|
const agentData = resourceLoader.loadAgent(id);
|
|
1701
2621
|
if (agentData) {
|
|
1702
2622
|
selectedAgents.push(agentData.metadata);
|
|
1703
|
-
|
|
2623
|
+
logger9.log(`\u2705 \u52A0\u8F7D Agent: ${id}`);
|
|
1704
2624
|
} else {
|
|
1705
|
-
|
|
2625
|
+
logger9.error(`Agent ${id} \u4E0D\u5B58\u5728`);
|
|
1706
2626
|
}
|
|
1707
2627
|
}
|
|
1708
2628
|
}
|
|
@@ -1716,7 +2636,7 @@ async function generateConfig(args) {
|
|
|
1716
2636
|
}]
|
|
1717
2637
|
};
|
|
1718
2638
|
}
|
|
1719
|
-
|
|
2639
|
+
logger9.log("\u6B63\u5728\u751F\u6210\u914D\u7F6E\u6587\u4EF6...");
|
|
1720
2640
|
const githubDir = path7.join(args.projectPath, ".github");
|
|
1721
2641
|
const configPath = path7.join(githubDir, "copilot-instructions.md");
|
|
1722
2642
|
let existingCustomContent = "";
|
|
@@ -1746,23 +2666,23 @@ async function generateConfig(args) {
|
|
|
1746
2666
|
})),
|
|
1747
2667
|
existingCustomContent: updateMode === "merge" ? existingCustomContent : void 0
|
|
1748
2668
|
});
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
const validator = new CodeValidator(
|
|
2669
|
+
logger9.log(`\u2705 \u4F7F\u7528\u6A21\u677F\u751F\u6210\u914D\u7F6E\uFF08\u7CBE\u7B80\u6A21\u5F0F\uFF09`);
|
|
2670
|
+
logger9.log(` \u6A21\u677F\u76EE\u5F55: ${templateLoader.getTemplatesPath()}`);
|
|
2671
|
+
logger9.log(` \u6A21\u677F\u53EF\u7528: ${templateLoader.isTemplateDirectoryAvailable()}`);
|
|
2672
|
+
const validator = new CodeValidator(logger9);
|
|
1753
2673
|
const validation = validator.validateConfigContent(content);
|
|
1754
2674
|
if (!validation.isValid) {
|
|
1755
|
-
|
|
2675
|
+
logger9.error("\u26A0\uFE0F \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u5931\u8D25\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D...");
|
|
1756
2676
|
const fixResult = validator.attemptAutoFix(content);
|
|
1757
2677
|
if (fixResult.fixed) {
|
|
1758
2678
|
content = fixResult.content;
|
|
1759
|
-
|
|
1760
|
-
fixResult.changes.forEach((change) =>
|
|
2679
|
+
logger9.log(`\u2705 \u5DF2\u81EA\u52A8\u4FEE\u590D ${fixResult.changes.length} \u4E2A\u95EE\u9898:`);
|
|
2680
|
+
fixResult.changes.forEach((change) => logger9.log(` - ${change}`));
|
|
1761
2681
|
const revalidation = validator.validateConfigContent(content);
|
|
1762
2682
|
if (!revalidation.isValid) {
|
|
1763
2683
|
const report = validator.generateValidationReport(revalidation);
|
|
1764
|
-
|
|
1765
|
-
|
|
2684
|
+
logger9.error("\u274C \u81EA\u52A8\u4FEE\u590D\u540E\u4ECD\u5B58\u5728\u95EE\u9898:");
|
|
2685
|
+
logger9.error(report);
|
|
1766
2686
|
return {
|
|
1767
2687
|
content: [{
|
|
1768
2688
|
type: "text",
|
|
@@ -1776,7 +2696,7 @@ async function generateConfig(args) {
|
|
|
1776
2696
|
}
|
|
1777
2697
|
} else {
|
|
1778
2698
|
const report = validator.generateValidationReport(validation);
|
|
1779
|
-
|
|
2699
|
+
logger9.error(report);
|
|
1780
2700
|
return {
|
|
1781
2701
|
content: [{
|
|
1782
2702
|
type: "text",
|
|
@@ -1789,12 +2709,12 @@ async function generateConfig(args) {
|
|
|
1789
2709
|
};
|
|
1790
2710
|
}
|
|
1791
2711
|
} else if (validation.warnings.length > 0) {
|
|
1792
|
-
|
|
2712
|
+
logger9.log("\u26A0\uFE0F \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u901A\u8FC7\uFF0C\u4F46\u6709\u4EE5\u4E0B\u8B66\u544A:");
|
|
1793
2713
|
validation.warnings.forEach((warning) => {
|
|
1794
|
-
|
|
2714
|
+
logger9.log(` - [${warning.type}] ${warning.message}`);
|
|
1795
2715
|
});
|
|
1796
2716
|
} else {
|
|
1797
|
-
|
|
2717
|
+
logger9.log("\u2705 \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u901A\u8FC7");
|
|
1798
2718
|
}
|
|
1799
2719
|
fs7.writeFileSync(configPath, content, "utf-8");
|
|
1800
2720
|
const gitignorePath = path7.join(args.projectPath, ".gitignore");
|
|
@@ -1805,7 +2725,7 @@ async function generateConfig(args) {
|
|
|
1805
2725
|
fs7.writeFileSync(gitignorePath, gitignoreContent, "utf-8");
|
|
1806
2726
|
}
|
|
1807
2727
|
}
|
|
1808
|
-
|
|
2728
|
+
logger9.log(`\u2705 \u914D\u7F6E\u6587\u4EF6\u5DF2\u751F\u6210: ${configPath}`);
|
|
1809
2729
|
return {
|
|
1810
2730
|
content: [{
|
|
1811
2731
|
type: "text",
|
|
@@ -1822,7 +2742,7 @@ async function generateConfig(args) {
|
|
|
1822
2742
|
}]
|
|
1823
2743
|
};
|
|
1824
2744
|
} catch (error) {
|
|
1825
|
-
|
|
2745
|
+
logger9.error(`\u751F\u6210\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
1826
2746
|
return {
|
|
1827
2747
|
content: [{
|
|
1828
2748
|
type: "text",
|
|
@@ -1835,11 +2755,12 @@ async function generateConfig(args) {
|
|
|
1835
2755
|
}
|
|
1836
2756
|
|
|
1837
2757
|
// src/tools/autoSetup.ts
|
|
2758
|
+
init_types();
|
|
1838
2759
|
import * as fs8 from "fs";
|
|
1839
2760
|
import * as path8 from "path";
|
|
1840
2761
|
async function autoSetup(args) {
|
|
1841
2762
|
var _a;
|
|
1842
|
-
const
|
|
2763
|
+
const logger9 = new ConsoleLogger();
|
|
1843
2764
|
try {
|
|
1844
2765
|
const workspacePath = args.workspacePath || process.cwd();
|
|
1845
2766
|
if (!fs8.existsSync(workspacePath)) {
|
|
@@ -1857,7 +2778,7 @@ async function autoSetup(args) {
|
|
|
1857
2778
|
steps: [],
|
|
1858
2779
|
warnings: []
|
|
1859
2780
|
};
|
|
1860
|
-
|
|
2781
|
+
logger9.log("\u{1F680} \u5F00\u59CB\u4E3A\u9879\u76EE\u751F\u6210 copilot-instructions.md...");
|
|
1861
2782
|
const generateInstructions = args.generateInstructions !== false;
|
|
1862
2783
|
const instructionsPath = path8.join(workspacePath, ".github", "copilot-instructions.md");
|
|
1863
2784
|
const hasExistingInstructions = fs8.existsSync(instructionsPath);
|
|
@@ -1869,7 +2790,7 @@ async function autoSetup(args) {
|
|
|
1869
2790
|
detail: "\u4FDD\u7559\u73B0\u6709\u914D\u7F6E\uFF0C\u4E0D\u81EA\u52A8\u8986\u76D6"
|
|
1870
2791
|
});
|
|
1871
2792
|
} else {
|
|
1872
|
-
|
|
2793
|
+
logger9.log("\u{1F50D} \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\u6587\u4EF6\uFF0C\u5F00\u59CB\u5206\u6790\u9879\u76EE...");
|
|
1873
2794
|
try {
|
|
1874
2795
|
const configResult = await generateConfig({
|
|
1875
2796
|
projectPath: workspacePath,
|
|
@@ -1902,7 +2823,7 @@ async function autoSetup(args) {
|
|
|
1902
2823
|
} else {
|
|
1903
2824
|
results.steps.push({ step: "\u8DF3\u8FC7 copilot-instructions.md \u751F\u6210", status: "skip" });
|
|
1904
2825
|
}
|
|
1905
|
-
|
|
2826
|
+
logger9.log("\u2705 \u914D\u7F6E\u5B8C\u6210\uFF01");
|
|
1906
2827
|
return {
|
|
1907
2828
|
content: [{
|
|
1908
2829
|
type: "text",
|
|
@@ -1920,7 +2841,7 @@ async function autoSetup(args) {
|
|
|
1920
2841
|
}]
|
|
1921
2842
|
};
|
|
1922
2843
|
} catch (error) {
|
|
1923
|
-
|
|
2844
|
+
logger9.error(`\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
1924
2845
|
return {
|
|
1925
2846
|
content: [{
|
|
1926
2847
|
type: "text",
|
|
@@ -1933,15 +2854,16 @@ async function autoSetup(args) {
|
|
|
1933
2854
|
}
|
|
1934
2855
|
|
|
1935
2856
|
// src/tools/initProject.ts
|
|
2857
|
+
init_types();
|
|
1936
2858
|
import * as fs9 from "fs";
|
|
1937
2859
|
async function initProject(args) {
|
|
1938
2860
|
var _a;
|
|
1939
|
-
const
|
|
2861
|
+
const logger9 = new ConsoleLogger();
|
|
1940
2862
|
try {
|
|
1941
2863
|
let projectPath = args.projectPath;
|
|
1942
2864
|
if (!projectPath) {
|
|
1943
2865
|
projectPath = process.cwd();
|
|
1944
|
-
|
|
2866
|
+
logger9.log(`\u{1F4A1} \u672A\u6307\u5B9A\u9879\u76EE\u8DEF\u5F84\uFF0C\u4F7F\u7528\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55: ${projectPath}`);
|
|
1945
2867
|
}
|
|
1946
2868
|
if (!fs9.existsSync(projectPath)) {
|
|
1947
2869
|
return {
|
|
@@ -1954,7 +2876,7 @@ async function initProject(args) {
|
|
|
1954
2876
|
}]
|
|
1955
2877
|
};
|
|
1956
2878
|
}
|
|
1957
|
-
|
|
2879
|
+
logger9.log(`\u{1F680} \u5F00\u59CB\u521D\u59CB\u5316\u9879\u76EE: ${projectPath}`);
|
|
1958
2880
|
const result = await generateConfig({
|
|
1959
2881
|
projectPath,
|
|
1960
2882
|
autoMatch: true,
|
|
@@ -1993,7 +2915,7 @@ async function initProject(args) {
|
|
|
1993
2915
|
};
|
|
1994
2916
|
}
|
|
1995
2917
|
} catch (error) {
|
|
1996
|
-
|
|
2918
|
+
logger9.error(`\u521D\u59CB\u5316\u5931\u8D25: ${error}`);
|
|
1997
2919
|
return {
|
|
1998
2920
|
content: [{
|
|
1999
2921
|
type: "text",
|
|
@@ -2498,6 +3420,7 @@ ${content}
|
|
|
2498
3420
|
};
|
|
2499
3421
|
|
|
2500
3422
|
// src/tools/usePreset.ts
|
|
3423
|
+
init_types();
|
|
2501
3424
|
var PRESETS = {
|
|
2502
3425
|
"vue3-component": {
|
|
2503
3426
|
name: "Vue 3 \u7EC4\u4EF6\u5F00\u53D1",
|
|
@@ -2557,7 +3480,7 @@ var PRESETS = {
|
|
|
2557
3480
|
}
|
|
2558
3481
|
};
|
|
2559
3482
|
async function usePreset(args) {
|
|
2560
|
-
const
|
|
3483
|
+
const logger9 = new ConsoleLogger();
|
|
2561
3484
|
const manager = new StandardsManager();
|
|
2562
3485
|
try {
|
|
2563
3486
|
if (!(args.preset in PRESETS)) {
|
|
@@ -2576,7 +3499,7 @@ async function usePreset(args) {
|
|
|
2576
3499
|
};
|
|
2577
3500
|
}
|
|
2578
3501
|
const preset = PRESETS[args.preset];
|
|
2579
|
-
|
|
3502
|
+
logger9.log(`\u{1F3AF} \u4F7F\u7528\u9884\u8BBE: ${preset.name}`);
|
|
2580
3503
|
const imports = args.customImports ? [...preset.imports, ...args.customImports] : [...preset.imports];
|
|
2581
3504
|
const standards = manager.getRelevantStandards({
|
|
2582
3505
|
fileType: preset.fileType,
|
|
@@ -2610,7 +3533,7 @@ async function usePreset(args) {
|
|
|
2610
3533
|
}]
|
|
2611
3534
|
};
|
|
2612
3535
|
} catch (error) {
|
|
2613
|
-
|
|
3536
|
+
logger9.error(`\u4F7F\u7528\u9884\u8BBE\u5931\u8D25: ${error}`);
|
|
2614
3537
|
return {
|
|
2615
3538
|
content: [{
|
|
2616
3539
|
type: "text",
|
|
@@ -2644,6 +3567,7 @@ async function listPresets() {
|
|
|
2644
3567
|
}
|
|
2645
3568
|
|
|
2646
3569
|
// src/tools/healthCheck.ts
|
|
3570
|
+
init_types();
|
|
2647
3571
|
import * as fs11 from "fs";
|
|
2648
3572
|
import * as path10 from "path";
|
|
2649
3573
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
@@ -2668,7 +3592,7 @@ function getServerRoot() {
|
|
|
2668
3592
|
}
|
|
2669
3593
|
async function healthCheck(args) {
|
|
2670
3594
|
var _a, _b, _c, _d;
|
|
2671
|
-
const
|
|
3595
|
+
const logger9 = new ConsoleLogger();
|
|
2672
3596
|
const verbose = args.verbose ?? false;
|
|
2673
3597
|
try {
|
|
2674
3598
|
const checks = {
|
|
@@ -2678,7 +3602,7 @@ async function healthCheck(args) {
|
|
|
2678
3602
|
standards: { status: "unknown", details: [] },
|
|
2679
3603
|
workspace: { status: "unknown", details: [] }
|
|
2680
3604
|
};
|
|
2681
|
-
|
|
3605
|
+
logger9.log("\u{1F50D} \u68C0\u67E5\u670D\u52A1\u5668\u72B6\u6001...");
|
|
2682
3606
|
try {
|
|
2683
3607
|
checks.server.status = "healthy";
|
|
2684
3608
|
checks.server.details.push("\u2705 MCP \u670D\u52A1\u5668\u6B63\u5728\u8FD0\u884C");
|
|
@@ -2688,7 +3612,7 @@ async function healthCheck(args) {
|
|
|
2688
3612
|
checks.server.status = "error";
|
|
2689
3613
|
checks.server.details.push("\u274C \u670D\u52A1\u5668\u672A\u54CD\u5E94");
|
|
2690
3614
|
}
|
|
2691
|
-
|
|
3615
|
+
logger9.log("\u{1F50D} \u68C0\u67E5\u914D\u7F6E\u6587\u4EF6...");
|
|
2692
3616
|
const workspacePath = args.workspacePath || process.cwd();
|
|
2693
3617
|
const vscodeDir = path10.join(workspacePath, ".vscode");
|
|
2694
3618
|
if (fs11.existsSync(vscodeDir)) {
|
|
@@ -2758,7 +3682,7 @@ async function healthCheck(args) {
|
|
|
2758
3682
|
checks.workspace.details.push("\u274C .vscode \u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
2759
3683
|
checks.workspace.details.push("\u{1F4A1} \u5EFA\u8BAE: \u8FD0\u884C auto_setup \u5DE5\u5177\u81EA\u52A8\u521B\u5EFA\u914D\u7F6E");
|
|
2760
3684
|
}
|
|
2761
|
-
|
|
3685
|
+
logger9.log("\u{1F50D} \u68C0\u67E5\u4F9D\u8D56...");
|
|
2762
3686
|
const serverRoot = getServerRoot();
|
|
2763
3687
|
const packageJsonPath = path10.join(serverRoot, "package.json");
|
|
2764
3688
|
if (fs11.existsSync(packageJsonPath)) {
|
|
@@ -2786,7 +3710,7 @@ async function healthCheck(args) {
|
|
|
2786
3710
|
checks.dependencies.details.push("\u274C \u65E0\u6CD5\u8BFB\u53D6 package.json");
|
|
2787
3711
|
}
|
|
2788
3712
|
}
|
|
2789
|
-
|
|
3713
|
+
logger9.log("\u{1F50D} \u68C0\u67E5\u89C4\u8303\u6587\u4EF6...");
|
|
2790
3714
|
const standardsDir = path10.join(serverRoot, "standards");
|
|
2791
3715
|
if (fs11.existsSync(standardsDir)) {
|
|
2792
3716
|
const categories = ["core", "frameworks", "libraries", "patterns"];
|
|
@@ -2825,7 +3749,7 @@ async function healthCheck(args) {
|
|
|
2825
3749
|
error: "\u274C",
|
|
2826
3750
|
unknown: "\u2753"
|
|
2827
3751
|
};
|
|
2828
|
-
|
|
3752
|
+
logger9.log(`${statusEmoji[overallStatus]} \u5065\u5EB7\u68C0\u67E5\u5B8C\u6210`);
|
|
2829
3753
|
return {
|
|
2830
3754
|
content: [{
|
|
2831
3755
|
type: "text",
|
|
@@ -2839,7 +3763,7 @@ async function healthCheck(args) {
|
|
|
2839
3763
|
}]
|
|
2840
3764
|
};
|
|
2841
3765
|
} catch (error) {
|
|
2842
|
-
|
|
3766
|
+
logger9.error(`\u5065\u5EB7\u68C0\u67E5\u5931\u8D25: ${error}`);
|
|
2843
3767
|
return {
|
|
2844
3768
|
content: [{
|
|
2845
3769
|
type: "text",
|
|
@@ -2873,15 +3797,16 @@ function generateRecommendations(checks) {
|
|
|
2873
3797
|
// src/tools/getCompactStandards.ts
|
|
2874
3798
|
import * as fs12 from "fs";
|
|
2875
3799
|
import * as path11 from "path";
|
|
3800
|
+
init_types();
|
|
2876
3801
|
init_smartAgentMatcher();
|
|
2877
3802
|
async function getCompactStandards(args) {
|
|
2878
|
-
const
|
|
3803
|
+
const logger9 = new ConsoleLogger();
|
|
2879
3804
|
const manager = new StandardsManager();
|
|
2880
3805
|
const mode = args.mode || "key-rules";
|
|
2881
3806
|
try {
|
|
2882
|
-
let context = detectContext(args,
|
|
3807
|
+
let context = detectContext(args, logger9);
|
|
2883
3808
|
if (args.projectPath && fs12.existsSync(args.projectPath)) {
|
|
2884
|
-
const projectContext = await analyzeProject2(args.projectPath,
|
|
3809
|
+
const projectContext = await analyzeProject2(args.projectPath, logger9);
|
|
2885
3810
|
context = mergeContexts(context, projectContext);
|
|
2886
3811
|
}
|
|
2887
3812
|
const standardUris = manager.getRelevantStandards({
|
|
@@ -2915,7 +3840,7 @@ async function getCompactStandards(args) {
|
|
|
2915
3840
|
}]
|
|
2916
3841
|
};
|
|
2917
3842
|
} catch (error) {
|
|
2918
|
-
|
|
3843
|
+
logger9.error(`\u89C4\u8303\u83B7\u53D6\u5931\u8D25: ${error}`);
|
|
2919
3844
|
return {
|
|
2920
3845
|
content: [{
|
|
2921
3846
|
type: "text",
|
|
@@ -2926,7 +3851,7 @@ async function getCompactStandards(args) {
|
|
|
2926
3851
|
};
|
|
2927
3852
|
}
|
|
2928
3853
|
}
|
|
2929
|
-
async function analyzeProject2(projectPath,
|
|
3854
|
+
async function analyzeProject2(projectPath, logger9) {
|
|
2930
3855
|
var _a, _b;
|
|
2931
3856
|
const result = {
|
|
2932
3857
|
fileType: "unknown",
|
|
@@ -2940,13 +3865,13 @@ async function analyzeProject2(projectPath, logger4) {
|
|
|
2940
3865
|
const agents = extractUserAgents(content);
|
|
2941
3866
|
if (agents.length > 0) {
|
|
2942
3867
|
result.userConfiguredAgents = agents;
|
|
2943
|
-
|
|
3868
|
+
logger9.log(`\u2705 \u68C0\u6D4B\u5230\u7528\u6237\u914D\u7F6E\u7684 Agents: ${agents.join(", ")}`);
|
|
2944
3869
|
}
|
|
2945
3870
|
} catch (error) {
|
|
2946
|
-
|
|
3871
|
+
logger9.error(`\u8BFB\u53D6\u7528\u6237\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
2947
3872
|
}
|
|
2948
3873
|
}
|
|
2949
|
-
const matcher = new SmartAgentMatcher(
|
|
3874
|
+
const matcher = new SmartAgentMatcher(logger9);
|
|
2950
3875
|
const workspaceFolder = {
|
|
2951
3876
|
uri: { fsPath: projectPath },
|
|
2952
3877
|
name: path11.basename(projectPath),
|
|
@@ -2965,9 +3890,9 @@ async function analyzeProject2(projectPath, logger4) {
|
|
|
2965
3890
|
if (features.libraries) {
|
|
2966
3891
|
result.imports.push(...features.libraries);
|
|
2967
3892
|
}
|
|
2968
|
-
|
|
3893
|
+
logger9.log(`\u{1F50D} \u9879\u76EE\u6280\u672F\u6808: ${result.imports.join(", ")}`);
|
|
2969
3894
|
} catch (error) {
|
|
2970
|
-
|
|
3895
|
+
logger9.error(`\u9879\u76EE\u5206\u6790\u5931\u8D25: ${error}`);
|
|
2971
3896
|
}
|
|
2972
3897
|
return result;
|
|
2973
3898
|
}
|
|
@@ -2988,7 +3913,7 @@ function mergeContexts(fileContext, projectContext) {
|
|
|
2988
3913
|
userConfiguredAgents: projectContext.userConfiguredAgents
|
|
2989
3914
|
};
|
|
2990
3915
|
}
|
|
2991
|
-
function detectContext(args,
|
|
3916
|
+
function detectContext(args, logger9) {
|
|
2992
3917
|
var _a;
|
|
2993
3918
|
let fileType = "unknown";
|
|
2994
3919
|
let imports = [];
|
|
@@ -3322,6 +4247,7 @@ function inferScenario(content, fileType) {
|
|
|
3322
4247
|
}
|
|
3323
4248
|
|
|
3324
4249
|
// src/tools/getStandardById.ts
|
|
4250
|
+
init_types();
|
|
3325
4251
|
import * as fs13 from "fs";
|
|
3326
4252
|
import * as path12 from "path";
|
|
3327
4253
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
@@ -3336,7 +4262,7 @@ var STANDARD_DIRS = [
|
|
|
3336
4262
|
];
|
|
3337
4263
|
var standardsCache = null;
|
|
3338
4264
|
async function getStandardById(args) {
|
|
3339
|
-
const
|
|
4265
|
+
const logger9 = new ConsoleLogger();
|
|
3340
4266
|
const mode = args.mode || "key-rules";
|
|
3341
4267
|
try {
|
|
3342
4268
|
const idsToLoad = args.ids || (args.id ? [args.id] : []);
|
|
@@ -3401,7 +4327,7 @@ async function getStandardById(args) {
|
|
|
3401
4327
|
}]
|
|
3402
4328
|
};
|
|
3403
4329
|
} catch (error) {
|
|
3404
|
-
|
|
4330
|
+
logger9.error(`\u83B7\u53D6\u89C4\u8303\u5931\u8D25: ${error}`);
|
|
3405
4331
|
return {
|
|
3406
4332
|
content: [{
|
|
3407
4333
|
type: "text",
|
|
@@ -3622,8 +4548,9 @@ function suggestStandards(options) {
|
|
|
3622
4548
|
}
|
|
3623
4549
|
|
|
3624
4550
|
// src/tools/queryMappings.ts
|
|
4551
|
+
init_types();
|
|
3625
4552
|
async function queryMappings(args) {
|
|
3626
|
-
const
|
|
4553
|
+
const logger9 = new ConsoleLogger();
|
|
3627
4554
|
try {
|
|
3628
4555
|
if (args.listAll) {
|
|
3629
4556
|
return {
|
|
@@ -3676,7 +4603,7 @@ async function queryMappings(args) {
|
|
|
3676
4603
|
}]
|
|
3677
4604
|
};
|
|
3678
4605
|
} catch (error) {
|
|
3679
|
-
|
|
4606
|
+
logger9.error(`\u67E5\u8BE2\u6620\u5C04\u5931\u8D25: ${error}`);
|
|
3680
4607
|
return {
|
|
3681
4608
|
content: [{
|
|
3682
4609
|
type: "text",
|
|
@@ -3873,8 +4800,9 @@ function searchTemplates(query) {
|
|
|
3873
4800
|
}
|
|
3874
4801
|
|
|
3875
4802
|
// src/tools/listTemplates.ts
|
|
4803
|
+
init_types();
|
|
3876
4804
|
async function listTemplates(args) {
|
|
3877
|
-
const
|
|
4805
|
+
const logger9 = new ConsoleLogger();
|
|
3878
4806
|
try {
|
|
3879
4807
|
let templates;
|
|
3880
4808
|
if (args.search) {
|
|
@@ -3908,7 +4836,7 @@ async function listTemplates(args) {
|
|
|
3908
4836
|
}]
|
|
3909
4837
|
};
|
|
3910
4838
|
} catch (error) {
|
|
3911
|
-
|
|
4839
|
+
logger9.error(`\u5217\u51FA\u6A21\u677F\u5931\u8D25: ${error}`);
|
|
3912
4840
|
return {
|
|
3913
4841
|
content: [{
|
|
3914
4842
|
type: "text",
|
|
@@ -3921,8 +4849,9 @@ async function listTemplates(args) {
|
|
|
3921
4849
|
}
|
|
3922
4850
|
|
|
3923
4851
|
// src/tools/getTemplate.ts
|
|
4852
|
+
init_types();
|
|
3924
4853
|
async function getTemplate(args) {
|
|
3925
|
-
const
|
|
4854
|
+
const logger9 = new ConsoleLogger();
|
|
3926
4855
|
try {
|
|
3927
4856
|
const result = getTemplateById(args.id, args.includeFiles ?? false);
|
|
3928
4857
|
if (!result) {
|
|
@@ -3963,7 +4892,7 @@ async function getTemplate(args) {
|
|
|
3963
4892
|
}]
|
|
3964
4893
|
};
|
|
3965
4894
|
} catch (error) {
|
|
3966
|
-
|
|
4895
|
+
logger9.error(`\u83B7\u53D6\u6A21\u677F\u5931\u8D25: ${error}`);
|
|
3967
4896
|
return {
|
|
3968
4897
|
content: [{
|
|
3969
4898
|
type: "text",
|
|
@@ -3976,16 +4905,18 @@ async function getTemplate(args) {
|
|
|
3976
4905
|
}
|
|
3977
4906
|
|
|
3978
4907
|
// src/tools/cloneProject.ts
|
|
4908
|
+
init_types();
|
|
3979
4909
|
import * as fs16 from "fs";
|
|
3980
4910
|
import * as path15 from "path";
|
|
3981
4911
|
|
|
3982
4912
|
// src/core/projectCloneAnalyzer.ts
|
|
4913
|
+
init_types();
|
|
3983
4914
|
import * as fs15 from "fs";
|
|
3984
4915
|
import * as path14 from "path";
|
|
3985
4916
|
import glob3 from "fast-glob";
|
|
3986
4917
|
var ProjectCloneAnalyzer = class {
|
|
3987
|
-
constructor(
|
|
3988
|
-
this.logger =
|
|
4918
|
+
constructor(logger9) {
|
|
4919
|
+
this.logger = logger9 || new ConsoleLogger();
|
|
3989
4920
|
}
|
|
3990
4921
|
/**
|
|
3991
4922
|
* 深度分析项目
|
|
@@ -4761,7 +5692,7 @@ var ProjectCloneAnalyzer = class {
|
|
|
4761
5692
|
|
|
4762
5693
|
// src/tools/cloneProject.ts
|
|
4763
5694
|
async function analyzeReferenceProject(args) {
|
|
4764
|
-
const
|
|
5695
|
+
const logger9 = new ConsoleLogger();
|
|
4765
5696
|
try {
|
|
4766
5697
|
if (!args.projectPath) {
|
|
4767
5698
|
return {
|
|
@@ -4784,8 +5715,8 @@ async function analyzeReferenceProject(args) {
|
|
|
4784
5715
|
}]
|
|
4785
5716
|
};
|
|
4786
5717
|
}
|
|
4787
|
-
|
|
4788
|
-
const analyzer = new ProjectCloneAnalyzer(
|
|
5718
|
+
logger9.log(`\u{1F50D} \u5F00\u59CB\u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE: ${args.projectPath}`);
|
|
5719
|
+
const analyzer = new ProjectCloneAnalyzer(logger9);
|
|
4789
5720
|
const analysis = await analyzer.analyzeProject(args.projectPath);
|
|
4790
5721
|
let developmentPlan = null;
|
|
4791
5722
|
if (args.newProjectName) {
|
|
@@ -4793,7 +5724,7 @@ async function analyzeReferenceProject(args) {
|
|
|
4793
5724
|
}
|
|
4794
5725
|
if (args.generateDocs && args.newProjectPath) {
|
|
4795
5726
|
await generateAnalysisDocs(args.newProjectPath, analysis, developmentPlan);
|
|
4796
|
-
|
|
5727
|
+
logger9.log(`\u{1F4C4} \u5DF2\u751F\u6210\u5206\u6790\u6587\u6863\u5230: ${args.newProjectPath}/docs/`);
|
|
4797
5728
|
}
|
|
4798
5729
|
const response = {
|
|
4799
5730
|
success: true,
|
|
@@ -4863,7 +5794,7 @@ async function analyzeReferenceProject(args) {
|
|
|
4863
5794
|
}]
|
|
4864
5795
|
};
|
|
4865
5796
|
} catch (error) {
|
|
4866
|
-
|
|
5797
|
+
logger9.error(`\u5206\u6790\u5931\u8D25: ${error}`);
|
|
4867
5798
|
return {
|
|
4868
5799
|
content: [{
|
|
4869
5800
|
type: "text",
|
|
@@ -4876,7 +5807,7 @@ async function analyzeReferenceProject(args) {
|
|
|
4876
5807
|
}
|
|
4877
5808
|
}
|
|
4878
5809
|
async function generateProjectSkeleton(args) {
|
|
4879
|
-
const
|
|
5810
|
+
const logger9 = new ConsoleLogger();
|
|
4880
5811
|
try {
|
|
4881
5812
|
if (!args.referenceProjectPath || !args.newProjectPath || !args.newProjectName) {
|
|
4882
5813
|
return {
|
|
@@ -4899,10 +5830,10 @@ async function generateProjectSkeleton(args) {
|
|
|
4899
5830
|
}]
|
|
4900
5831
|
};
|
|
4901
5832
|
}
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
const analyzer = new ProjectCloneAnalyzer(
|
|
5833
|
+
logger9.log(`\u{1F3D7}\uFE0F \u5F00\u59CB\u751F\u6210\u9879\u76EE\u9AA8\u67B6...`);
|
|
5834
|
+
logger9.log(`\u{1F4E6} \u53C2\u8003\u9879\u76EE: ${args.referenceProjectPath}`);
|
|
5835
|
+
logger9.log(`\u{1F4C1} \u65B0\u9879\u76EE: ${args.newProjectPath}`);
|
|
5836
|
+
const analyzer = new ProjectCloneAnalyzer(logger9);
|
|
4906
5837
|
const analysis = await analyzer.analyzeProject(args.referenceProjectPath);
|
|
4907
5838
|
const developmentPlan = analyzer.generateDevelopmentPlan(analysis, args.newProjectName);
|
|
4908
5839
|
if (!fs16.existsSync(args.newProjectPath)) {
|
|
@@ -4910,7 +5841,7 @@ async function generateProjectSkeleton(args) {
|
|
|
4910
5841
|
}
|
|
4911
5842
|
if (args.generateDocs !== false) {
|
|
4912
5843
|
await generateAnalysisDocs(args.newProjectPath, analysis, developmentPlan);
|
|
4913
|
-
|
|
5844
|
+
logger9.log(`\u{1F4C4} \u5DF2\u751F\u6210\u5206\u6790\u6587\u6863`);
|
|
4914
5845
|
}
|
|
4915
5846
|
const skeletonGuide = generateSkeletonGuide(analysis, args);
|
|
4916
5847
|
return {
|
|
@@ -4936,7 +5867,7 @@ async function generateProjectSkeleton(args) {
|
|
|
4936
5867
|
}]
|
|
4937
5868
|
};
|
|
4938
5869
|
} catch (error) {
|
|
4939
|
-
|
|
5870
|
+
logger9.error(`\u751F\u6210\u5931\u8D25: ${error}`);
|
|
4940
5871
|
return {
|
|
4941
5872
|
content: [{
|
|
4942
5873
|
type: "text",
|
|
@@ -4972,466 +5903,214 @@ function generateAnalysisMarkdown(analysis) {
|
|
|
4972
5903
|
| \u9879\u76EE | \u503C |
|
|
4973
5904
|
|------|-----|
|
|
4974
5905
|
| \u6846\u67B6 | ${analysis.techStack.framework} |
|
|
4975
|
-
| \u8BED\u8A00 | ${analysis.techStack.language} |
|
|
4976
|
-
| \u6784\u5EFA\u5DE5\u5177 | ${analysis.techStack.buildTool} |
|
|
4977
|
-
| UI \u5E93 | ${analysis.techStack.uiLibrary || "\u65E0"} |
|
|
4978
|
-
| \u72B6\u6001\u7BA1\u7406 | ${analysis.techStack.stateManagement || "\u65E0"} |
|
|
4979
|
-
|
|
4980
|
-
## \u67B6\u6784\u5C42\u7EA7
|
|
4981
|
-
|
|
4982
|
-
| \u5C42\u7EA7 | \u63CF\u8FF0 | \u53EF\u590D\u7528 | \u4F18\u5148\u7EA7 |
|
|
4983
|
-
|------|------|--------|--------|
|
|
4984
|
-
`;
|
|
4985
|
-
for (const layer of analysis.architectureLayers) {
|
|
4986
|
-
md += `| ${layer.name} | ${layer.description} | ${layer.reusable ? "\u2705" : "\u274C"} | ${layer.priority} |
|
|
4987
|
-
`;
|
|
4988
|
-
}
|
|
4989
|
-
md += `
|
|
4990
|
-
## \u5DE5\u5177\u7C7B\u5206\u6790
|
|
4991
|
-
|
|
4992
|
-
**\u603B\u8BA1**: ${analysis.utilities.length} \u4E2A\u5DE5\u5177\u7C7B\uFF0C\u5176\u4E2D ${analysis.utilities.filter((u) => u.recommended).length} \u4E2A\u63A8\u8350\u590D\u7528
|
|
4993
|
-
|
|
4994
|
-
### \u63A8\u8350\u590D\u7528\u7684\u5DE5\u5177\u7C7B
|
|
4995
|
-
|
|
4996
|
-
| \u8DEF\u5F84 | \u7C7B\u578B | \u4F7F\u7528\u6B21\u6570 |
|
|
4997
|
-
|------|------|---------|
|
|
4998
|
-
`;
|
|
4999
|
-
for (const util of analysis.utilities.filter((u) => u.recommended)) {
|
|
5000
|
-
md += `| ${util.path} | ${util.type} | ${util.usageCount} |
|
|
5001
|
-
`;
|
|
5002
|
-
}
|
|
5003
|
-
md += `
|
|
5004
|
-
## \u6837\u5F0F\u7CFB\u7EDF
|
|
5005
|
-
|
|
5006
|
-
- **\u9884\u5904\u7406\u5668**: ${analysis.styleSystem.preprocessor || "CSS"}
|
|
5007
|
-
- **\u5168\u5C40\u6837\u5F0F**: ${analysis.styleSystem.globalStyles.length} \u4E2A\u6587\u4EF6
|
|
5008
|
-
- **\u4E3B\u9898\u6587\u4EF6**: ${analysis.styleSystem.themeFiles.length} \u4E2A\u6587\u4EF6
|
|
5009
|
-
- **Mixins**: ${analysis.styleSystem.mixins.length} \u4E2A\u6587\u4EF6
|
|
5010
|
-
|
|
5011
|
-
### \u5168\u5C40\u6837\u5F0F\u6587\u4EF6
|
|
5012
|
-
|
|
5013
|
-
${analysis.styleSystem.globalStyles.map((f) => `- \`${f}\``).join("\n")}
|
|
5014
|
-
|
|
5015
|
-
### \u4E3B\u9898/\u53D8\u91CF\u6587\u4EF6
|
|
5016
|
-
|
|
5017
|
-
${analysis.styleSystem.themeFiles.map((f) => `- \`${f}\``).join("\n")}
|
|
5018
|
-
|
|
5019
|
-
## \u914D\u7F6E\u7CFB\u7EDF
|
|
5020
|
-
|
|
5021
|
-
- **\u6784\u5EFA\u914D\u7F6E**: ${((_a = analysis.configSystem.buildConfig) == null ? void 0 : _a.configFile) || "\u65E0"}
|
|
5022
|
-
- **\u8DEF\u7531\u914D\u7F6E**: ${((_b = analysis.configSystem.routerConfig) == null ? void 0 : _b.configFile) || "\u65E0"}
|
|
5023
|
-
- **HTTP \u914D\u7F6E**: ${((_c = analysis.configSystem.httpConfig) == null ? void 0 : _c.configFile) || "\u65E0"}
|
|
5024
|
-
- **\u56FD\u9645\u5316\u914D\u7F6E**: ${((_d = analysis.configSystem.i18nConfig) == null ? void 0 : _d.configFile) || "\u65E0"}
|
|
5025
|
-
|
|
5026
|
-
## \u6838\u5FC3\u9875\u9762
|
|
5027
|
-
|
|
5028
|
-
| \u9875\u9762 | \u8DEF\u5F84 |
|
|
5029
|
-
|------|------|
|
|
5030
|
-
| \u767B\u5F55\u9875 | ${analysis.corePages.loginPage || "\u65E0"} |
|
|
5031
|
-
| \u4E3B\u5E03\u5C40 | ${analysis.corePages.mainLayout || "\u65E0"} |
|
|
5032
|
-
| \u5BFC\u822A\u7EC4\u4EF6 | ${analysis.corePages.navigation || "\u65E0"} |
|
|
5033
|
-
| \u9519\u8BEF\u9875\u9762 | ${analysis.corePages.errorPages.join(", ") || "\u65E0"} |
|
|
5034
|
-
|
|
5035
|
-
## \u8D28\u91CF\u8BC4\u4F30
|
|
5036
|
-
|
|
5037
|
-
**\u8BC4\u5206**: ${analysis.qualityAssessment.score}/100
|
|
5038
|
-
|
|
5039
|
-
### \u4F18\u70B9
|
|
5040
|
-
|
|
5041
|
-
${analysis.qualityAssessment.strengths.map((s) => `- \u2705 ${s}`).join("\n")}
|
|
5042
|
-
|
|
5043
|
-
### \u5F85\u6539\u8FDB
|
|
5044
|
-
|
|
5045
|
-
${analysis.qualityAssessment.weaknesses.map((w) => `- \u26A0\uFE0F ${w}`).join("\n")}
|
|
5046
|
-
|
|
5047
|
-
### \u5EFA\u8BAE
|
|
5048
|
-
|
|
5049
|
-
${analysis.qualityAssessment.suggestions.map((s) => `- \u{1F4A1} ${s}`).join("\n")}
|
|
5050
|
-
`;
|
|
5051
|
-
return md;
|
|
5052
|
-
}
|
|
5053
|
-
function generatePlanMarkdown(plan) {
|
|
5054
|
-
var _a;
|
|
5055
|
-
let md = `# ${plan.title}
|
|
5056
|
-
|
|
5057
|
-
> \u751F\u6210\u65F6\u95F4: ${plan.generatedAt}
|
|
5058
|
-
|
|
5059
|
-
**\u53C2\u8003\u9879\u76EE**: ${plan.referenceProject}
|
|
5060
|
-
**\u65B0\u9879\u76EE**: ${plan.newProjectName}
|
|
5061
|
-
|
|
5062
|
-
---
|
|
5063
|
-
|
|
5064
|
-
`;
|
|
5065
|
-
for (const phase of plan.phases) {
|
|
5066
|
-
md += `## \u9636\u6BB5 ${phase.phase}: ${phase.name}
|
|
5067
|
-
|
|
5068
|
-
${phase.description}
|
|
5069
|
-
|
|
5070
|
-
| \u4EFB\u52A1 | \u4F18\u5148\u7EA7 | \u9884\u4F30\u65F6\u95F4 | \u76F8\u5173\u6587\u4EF6 |
|
|
5071
|
-
|------|--------|---------|----------|
|
|
5072
|
-
`;
|
|
5073
|
-
for (const task of phase.tasks) {
|
|
5074
|
-
const files = ((_a = task.files) == null ? void 0 : _a.filter((f) => f).join(", ")) || "-";
|
|
5075
|
-
md += `| ${task.task} | ${task.priority} | ${task.estimatedTime} | ${files} |
|
|
5076
|
-
`;
|
|
5077
|
-
}
|
|
5078
|
-
md += "\n";
|
|
5079
|
-
}
|
|
5080
|
-
md += `## \u6CE8\u610F\u4E8B\u9879
|
|
5081
|
-
|
|
5082
|
-
${plan.notes.map((n) => `- ${n}`).join("\n")}
|
|
5083
|
-
`;
|
|
5084
|
-
return md;
|
|
5085
|
-
}
|
|
5086
|
-
function generateSkeletonMarkdown(analysis) {
|
|
5087
|
-
var _a;
|
|
5088
|
-
let md = `# \u9879\u76EE\u9AA8\u67B6\u6E05\u5355
|
|
5089
|
-
|
|
5090
|
-
> \u57FA\u4E8E ${analysis.projectName} \u5206\u6790\u751F\u6210
|
|
5906
|
+
| \u8BED\u8A00 | ${analysis.techStack.language} |
|
|
5907
|
+
| \u6784\u5EFA\u5DE5\u5177 | ${analysis.techStack.buildTool} |
|
|
5908
|
+
| UI \u5E93 | ${analysis.techStack.uiLibrary || "\u65E0"} |
|
|
5909
|
+
| \u72B6\u6001\u7BA1\u7406 | ${analysis.techStack.stateManagement || "\u65E0"} |
|
|
5091
5910
|
|
|
5092
|
-
## \
|
|
5911
|
+
## \u67B6\u6784\u5C42\u7EA7
|
|
5093
5912
|
|
|
5913
|
+
| \u5C42\u7EA7 | \u63CF\u8FF0 | \u53EF\u590D\u7528 | \u4F18\u5148\u7EA7 |
|
|
5914
|
+
|------|------|--------|--------|
|
|
5094
5915
|
`;
|
|
5095
|
-
for (const
|
|
5096
|
-
md +=
|
|
5097
|
-
|
|
5098
|
-
- **\u63CF\u8FF0**: ${dir.description}
|
|
5099
|
-
- **\u5173\u952E\u6587\u4EF6**:
|
|
5100
|
-
${((_a = dir.files) == null ? void 0 : _a.slice(0, 5).map((f) => ` - \`${f}\``).join("\n")) || " - (\u65E0)"}
|
|
5101
|
-
|
|
5916
|
+
for (const layer of analysis.architectureLayers) {
|
|
5917
|
+
md += `| ${layer.name} | ${layer.description} | ${layer.reusable ? "\u2705" : "\u274C"} | ${layer.priority} |
|
|
5102
5918
|
`;
|
|
5103
5919
|
}
|
|
5104
|
-
md +=
|
|
5920
|
+
md += `
|
|
5921
|
+
## \u5DE5\u5177\u7C7B\u5206\u6790
|
|
5105
5922
|
|
|
5106
|
-
\
|
|
5923
|
+
**\u603B\u8BA1**: ${analysis.utilities.length} \u4E2A\u5DE5\u5177\u7C7B\uFF0C\u5176\u4E2D ${analysis.utilities.filter((u) => u.recommended).length} \u4E2A\u63A8\u8350\u590D\u7528
|
|
5107
5924
|
|
|
5108
|
-
|
|
5109
|
-
|
|
5925
|
+
### \u63A8\u8350\u590D\u7528\u7684\u5DE5\u5177\u7C7B
|
|
5926
|
+
|
|
5927
|
+
| \u8DEF\u5F84 | \u7C7B\u578B | \u4F7F\u7528\u6B21\u6570 |
|
|
5928
|
+
|------|------|---------|
|
|
5110
5929
|
`;
|
|
5111
|
-
for (const util of analysis.
|
|
5112
|
-
md += `| ${util.path} | ${util.type} |
|
|
5930
|
+
for (const util of analysis.utilities.filter((u) => u.recommended)) {
|
|
5931
|
+
md += `| ${util.path} | ${util.type} | ${util.usageCount} |
|
|
5113
5932
|
`;
|
|
5114
5933
|
}
|
|
5115
5934
|
md += `
|
|
5116
5935
|
## \u6837\u5F0F\u7CFB\u7EDF
|
|
5117
5936
|
|
|
5118
|
-
|
|
5937
|
+
- **\u9884\u5904\u7406\u5668**: ${analysis.styleSystem.preprocessor || "CSS"}
|
|
5938
|
+
- **\u5168\u5C40\u6837\u5F0F**: ${analysis.styleSystem.globalStyles.length} \u4E2A\u6587\u4EF6
|
|
5939
|
+
- **\u4E3B\u9898\u6587\u4EF6**: ${analysis.styleSystem.themeFiles.length} \u4E2A\u6587\u4EF6
|
|
5940
|
+
- **Mixins**: ${analysis.styleSystem.mixins.length} \u4E2A\u6587\u4EF6
|
|
5119
5941
|
|
|
5120
|
-
|
|
5942
|
+
### \u5168\u5C40\u6837\u5F0F\u6587\u4EF6
|
|
5121
5943
|
|
|
5122
|
-
|
|
5944
|
+
${analysis.styleSystem.globalStyles.map((f) => `- \`${f}\``).join("\n")}
|
|
5123
5945
|
|
|
5124
|
-
|
|
5946
|
+
### \u4E3B\u9898/\u53D8\u91CF\u6587\u4EF6
|
|
5125
5947
|
|
|
5126
|
-
|
|
5948
|
+
${analysis.styleSystem.themeFiles.map((f) => `- \`${f}\``).join("\n")}
|
|
5127
5949
|
|
|
5128
|
-
|
|
5129
|
-
- [ ] \u4E3B\u5E03\u5C40: \`${analysis.skeleton.corePages.mainLayout || "\u65E0"}\`
|
|
5130
|
-
- [ ] \u5BFC\u822A\u7EC4\u4EF6: \`${analysis.skeleton.corePages.navigation || "\u65E0"}\`
|
|
5950
|
+
## \u914D\u7F6E\u7CFB\u7EDF
|
|
5131
5951
|
|
|
5132
|
-
|
|
5952
|
+
- **\u6784\u5EFA\u914D\u7F6E**: ${((_a = analysis.configSystem.buildConfig) == null ? void 0 : _a.configFile) || "\u65E0"}
|
|
5953
|
+
- **\u8DEF\u7531\u914D\u7F6E**: ${((_b = analysis.configSystem.routerConfig) == null ? void 0 : _b.configFile) || "\u65E0"}
|
|
5954
|
+
- **HTTP \u914D\u7F6E**: ${((_c = analysis.configSystem.httpConfig) == null ? void 0 : _c.configFile) || "\u65E0"}
|
|
5955
|
+
- **\u56FD\u9645\u5316\u914D\u7F6E**: ${((_d = analysis.configSystem.i18nConfig) == null ? void 0 : _d.configFile) || "\u65E0"}
|
|
5133
5956
|
|
|
5134
|
-
\
|
|
5957
|
+
## \u6838\u5FC3\u9875\u9762
|
|
5135
5958
|
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
}
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
return {
|
|
5143
|
-
directories: analysis.skeleton.requiredDirectories.map((d) => ({
|
|
5144
|
-
from: path15.join(args.referenceProjectPath, "src", d.path),
|
|
5145
|
-
to: path15.join(args.newProjectPath, "src", d.path),
|
|
5146
|
-
description: d.description
|
|
5147
|
-
})),
|
|
5148
|
-
coreUtils: analysis.skeleton.coreUtils.map((u) => ({
|
|
5149
|
-
from: u.path,
|
|
5150
|
-
type: u.type,
|
|
5151
|
-
recommended: u.recommended
|
|
5152
|
-
})),
|
|
5153
|
-
styleFiles: [
|
|
5154
|
-
...analysis.styleSystem.globalStyles,
|
|
5155
|
-
...analysis.styleSystem.themeFiles,
|
|
5156
|
-
...analysis.styleSystem.mixins
|
|
5157
|
-
],
|
|
5158
|
-
configFiles: [
|
|
5159
|
-
(_a = analysis.configSystem.buildConfig) == null ? void 0 : _a.configFile,
|
|
5160
|
-
...analysis.configSystem.envFiles
|
|
5161
|
-
].filter(Boolean),
|
|
5162
|
-
corePages: [
|
|
5163
|
-
analysis.corePages.loginPage,
|
|
5164
|
-
analysis.corePages.mainLayout,
|
|
5165
|
-
analysis.corePages.navigation,
|
|
5166
|
-
...analysis.corePages.errorPages
|
|
5167
|
-
].filter(Boolean)
|
|
5168
|
-
};
|
|
5169
|
-
}
|
|
5170
|
-
function groupBy(arr, key) {
|
|
5171
|
-
return arr.reduce((acc, item) => {
|
|
5172
|
-
const k = item[key];
|
|
5173
|
-
acc[k] = (acc[k] || 0) + 1;
|
|
5174
|
-
return acc;
|
|
5175
|
-
}, {});
|
|
5176
|
-
}
|
|
5959
|
+
| \u9875\u9762 | \u8DEF\u5F84 |
|
|
5960
|
+
|------|------|
|
|
5961
|
+
| \u767B\u5F55\u9875 | ${analysis.corePages.loginPage || "\u65E0"} |
|
|
5962
|
+
| \u4E3B\u5E03\u5C40 | ${analysis.corePages.mainLayout || "\u65E0"} |
|
|
5963
|
+
| \u5BFC\u822A\u7EC4\u4EF6 | ${analysis.corePages.navigation || "\u65E0"} |
|
|
5964
|
+
| \u9519\u8BEF\u9875\u9762 | ${analysis.corePages.errorPages.join(", ") || "\u65E0"} |
|
|
5177
5965
|
|
|
5178
|
-
|
|
5179
|
-
init_resourceLoader();
|
|
5180
|
-
import * as fs18 from "fs";
|
|
5181
|
-
import * as path17 from "path";
|
|
5966
|
+
## \u8D28\u91CF\u8BC4\u4F30
|
|
5182
5967
|
|
|
5183
|
-
|
|
5184
|
-
var ERROR_MESSAGES = {
|
|
5185
|
-
[1e3 /* UNKNOWN */]: "\u672A\u77E5\u9519\u8BEF",
|
|
5186
|
-
[1001 /* INVALID_PARAMETER */]: "\u53C2\u6570\u65E0\u6548",
|
|
5187
|
-
[1002 /* NOT_FOUND */]: "\u8D44\u6E90\u672A\u627E\u5230",
|
|
5188
|
-
[1003 /* PERMISSION_DENIED */]: "\u6743\u9650\u4E0D\u8DB3",
|
|
5189
|
-
[2001 /* PROJECT_NOT_FOUND */]: "\u9879\u76EE\u76EE\u5F55\u4E0D\u5B58\u5728",
|
|
5190
|
-
[2002 /* PROJECT_PARSE_ERROR */]: "\u9879\u76EE\u89E3\u6790\u5931\u8D25",
|
|
5191
|
-
[2003 /* CONFIG_READ_ERROR */]: "\u914D\u7F6E\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25",
|
|
5192
|
-
[3001 /* STANDARD_NOT_FOUND */]: "\u89C4\u8303\u672A\u627E\u5230",
|
|
5193
|
-
[3002 /* STANDARD_LOAD_ERROR */]: "\u89C4\u8303\u52A0\u8F7D\u5931\u8D25",
|
|
5194
|
-
[3003 /* PRESET_NOT_FOUND */]: "\u9884\u8BBE\u672A\u627E\u5230",
|
|
5195
|
-
[4001 /* TEMPLATE_NOT_FOUND */]: "\u6A21\u677F\u672A\u627E\u5230",
|
|
5196
|
-
[4002 /* TEMPLATE_PARSE_ERROR */]: "\u6A21\u677F\u89E3\u6790\u5931\u8D25",
|
|
5197
|
-
[5001 /* AGENT_NOT_FOUND */]: "Agent \u672A\u627E\u5230",
|
|
5198
|
-
[5002 /* AGENT_LOAD_ERROR */]: "Agent \u52A0\u8F7D\u5931\u8D25",
|
|
5199
|
-
[6001 /* CONFIG_GENERATE_ERROR */]: "\u914D\u7F6E\u751F\u6210\u5931\u8D25",
|
|
5200
|
-
[6002 /* FILE_WRITE_ERROR */]: "\u6587\u4EF6\u5199\u5165\u5931\u8D25"
|
|
5201
|
-
};
|
|
5202
|
-
var MCPError = class _MCPError extends Error {
|
|
5203
|
-
constructor(code, message, options) {
|
|
5204
|
-
const defaultMessage = ERROR_MESSAGES[code] || "\u672A\u77E5\u9519\u8BEF";
|
|
5205
|
-
super(message || defaultMessage);
|
|
5206
|
-
this.name = "MCPError";
|
|
5207
|
-
this.code = code;
|
|
5208
|
-
this.cause = options == null ? void 0 : options.cause;
|
|
5209
|
-
this.context = options == null ? void 0 : options.context;
|
|
5210
|
-
Object.setPrototypeOf(this, _MCPError.prototype);
|
|
5211
|
-
}
|
|
5212
|
-
/**
|
|
5213
|
-
* 转换为 JSON 格式(用于 MCP 响应)
|
|
5214
|
-
*/
|
|
5215
|
-
toJSON() {
|
|
5216
|
-
return {
|
|
5217
|
-
error: true,
|
|
5218
|
-
code: this.code,
|
|
5219
|
-
message: this.message,
|
|
5220
|
-
...this.context && { context: this.context }
|
|
5221
|
-
};
|
|
5222
|
-
}
|
|
5223
|
-
/**
|
|
5224
|
-
* 转换为 MCP 响应格式
|
|
5225
|
-
*/
|
|
5226
|
-
toResponse() {
|
|
5227
|
-
return {
|
|
5228
|
-
content: [{
|
|
5229
|
-
type: "text",
|
|
5230
|
-
text: JSON.stringify(this.toJSON(), null, 2)
|
|
5231
|
-
}]
|
|
5232
|
-
};
|
|
5233
|
-
}
|
|
5234
|
-
};
|
|
5235
|
-
function errorResponse(error) {
|
|
5236
|
-
if (error instanceof MCPError) {
|
|
5237
|
-
return error.toResponse();
|
|
5238
|
-
}
|
|
5239
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
5240
|
-
return {
|
|
5241
|
-
content: [{
|
|
5242
|
-
type: "text",
|
|
5243
|
-
text: JSON.stringify({
|
|
5244
|
-
error: true,
|
|
5245
|
-
code: 1e3 /* UNKNOWN */,
|
|
5246
|
-
message
|
|
5247
|
-
}, null, 2)
|
|
5248
|
-
}]
|
|
5249
|
-
};
|
|
5250
|
-
}
|
|
5968
|
+
**\u8BC4\u5206**: ${analysis.qualityAssessment.score}/100
|
|
5251
5969
|
|
|
5252
|
-
|
|
5253
|
-
var LOG_LEVEL_NAMES = {
|
|
5254
|
-
[0 /* DEBUG */]: "DEBUG",
|
|
5255
|
-
[1 /* INFO */]: "INFO",
|
|
5256
|
-
[2 /* WARN */]: "WARN",
|
|
5257
|
-
[3 /* ERROR */]: "ERROR",
|
|
5258
|
-
[4 /* SILENT */]: "SILENT"
|
|
5259
|
-
};
|
|
5260
|
-
var globalConfig = {
|
|
5261
|
-
level: process.env.DEBUG ? 0 /* DEBUG */ : 1 /* INFO */,
|
|
5262
|
-
timestamp: false,
|
|
5263
|
-
prefix: "[MCP]"
|
|
5264
|
-
};
|
|
5265
|
-
var Logger2 = class _Logger {
|
|
5266
|
-
constructor(name, config) {
|
|
5267
|
-
this.name = name || "";
|
|
5268
|
-
this.config = { ...globalConfig, ...config };
|
|
5269
|
-
}
|
|
5270
|
-
/**
|
|
5271
|
-
* 格式化日志消息
|
|
5272
|
-
*/
|
|
5273
|
-
format(level, message, ...args) {
|
|
5274
|
-
const parts = [];
|
|
5275
|
-
if (this.config.timestamp) {
|
|
5276
|
-
parts.push((/* @__PURE__ */ new Date()).toISOString());
|
|
5277
|
-
}
|
|
5278
|
-
parts.push(this.config.prefix);
|
|
5279
|
-
if (this.name) {
|
|
5280
|
-
parts.push(`[${this.name}]`);
|
|
5281
|
-
}
|
|
5282
|
-
parts.push(`[${LOG_LEVEL_NAMES[level]}]`);
|
|
5283
|
-
parts.push(message);
|
|
5284
|
-
if (args.length > 0) {
|
|
5285
|
-
const formatted = args.map((arg) => {
|
|
5286
|
-
if (typeof arg === "object") {
|
|
5287
|
-
try {
|
|
5288
|
-
return JSON.stringify(arg, null, 2);
|
|
5289
|
-
} catch {
|
|
5290
|
-
return String(arg);
|
|
5291
|
-
}
|
|
5292
|
-
}
|
|
5293
|
-
return String(arg);
|
|
5294
|
-
});
|
|
5295
|
-
parts.push(...formatted);
|
|
5296
|
-
}
|
|
5297
|
-
return parts.join(" ");
|
|
5298
|
-
}
|
|
5299
|
-
/**
|
|
5300
|
-
* 检查日志级别是否应该输出
|
|
5301
|
-
*/
|
|
5302
|
-
shouldLog(level) {
|
|
5303
|
-
return level >= this.config.level;
|
|
5304
|
-
}
|
|
5305
|
-
/**
|
|
5306
|
-
* 调试日志
|
|
5307
|
-
*/
|
|
5308
|
-
debug(message, ...args) {
|
|
5309
|
-
if (this.shouldLog(0 /* DEBUG */)) {
|
|
5310
|
-
console.error(this.format(0 /* DEBUG */, message, ...args));
|
|
5311
|
-
}
|
|
5312
|
-
}
|
|
5313
|
-
/**
|
|
5314
|
-
* 信息日志
|
|
5315
|
-
*/
|
|
5316
|
-
info(message, ...args) {
|
|
5317
|
-
if (this.shouldLog(1 /* INFO */)) {
|
|
5318
|
-
console.error(this.format(1 /* INFO */, message, ...args));
|
|
5319
|
-
}
|
|
5320
|
-
}
|
|
5321
|
-
/**
|
|
5322
|
-
* 简化的 log 方法(等同于 info)
|
|
5323
|
-
*/
|
|
5324
|
-
log(message, ...args) {
|
|
5325
|
-
this.info(message, ...args);
|
|
5326
|
-
}
|
|
5327
|
-
/**
|
|
5328
|
-
* 警告日志
|
|
5329
|
-
*/
|
|
5330
|
-
warn(message, ...args) {
|
|
5331
|
-
if (this.shouldLog(2 /* WARN */)) {
|
|
5332
|
-
console.error(this.format(2 /* WARN */, message, ...args));
|
|
5333
|
-
}
|
|
5334
|
-
}
|
|
5335
|
-
/**
|
|
5336
|
-
* 错误日志
|
|
5337
|
-
*/
|
|
5338
|
-
error(message, ...args) {
|
|
5339
|
-
if (this.shouldLog(3 /* ERROR */)) {
|
|
5340
|
-
console.error(this.format(3 /* ERROR */, message, ...args));
|
|
5341
|
-
}
|
|
5342
|
-
}
|
|
5343
|
-
/**
|
|
5344
|
-
* 创建子 Logger
|
|
5345
|
-
*/
|
|
5346
|
-
child(name) {
|
|
5347
|
-
const childName = this.name ? `${this.name}:${name}` : name;
|
|
5348
|
-
return new _Logger(childName, this.config);
|
|
5349
|
-
}
|
|
5350
|
-
};
|
|
5351
|
-
var logger = new Logger2();
|
|
5352
|
-
function createLogger(name) {
|
|
5353
|
-
return new Logger2(name);
|
|
5354
|
-
}
|
|
5970
|
+
### \u4F18\u70B9
|
|
5355
5971
|
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
}
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
try {
|
|
5393
|
-
if (!fs17.existsSync(vscodeDir)) {
|
|
5394
|
-
fs17.mkdirSync(vscodeDir, { recursive: true });
|
|
5395
|
-
}
|
|
5396
|
-
let mcpConfig = { servers: {} };
|
|
5397
|
-
if (fs17.existsSync(mcpJsonPath)) {
|
|
5398
|
-
try {
|
|
5399
|
-
mcpConfig = JSON.parse(fs17.readFileSync(mcpJsonPath, "utf-8"));
|
|
5400
|
-
if (!mcpConfig.servers) {
|
|
5401
|
-
mcpConfig.servers = {};
|
|
5402
|
-
}
|
|
5403
|
-
} catch {
|
|
5404
|
-
mcpConfig = { servers: {} };
|
|
5405
|
-
}
|
|
5406
|
-
}
|
|
5407
|
-
mcpConfig.servers.mta = {
|
|
5408
|
-
command: "npx",
|
|
5409
|
-
args: ["-y", "mta-mcp"],
|
|
5410
|
-
env: {}
|
|
5411
|
-
};
|
|
5412
|
-
fs17.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
5413
|
-
let settings = {};
|
|
5414
|
-
if (fs17.existsSync(settingsPath)) {
|
|
5415
|
-
try {
|
|
5416
|
-
settings = JSON.parse(fs17.readFileSync(settingsPath, "utf-8"));
|
|
5417
|
-
} catch {
|
|
5418
|
-
settings = {};
|
|
5419
|
-
}
|
|
5420
|
-
}
|
|
5421
|
-
if (!settings["github.copilot.chat.mcp.enabled"]) {
|
|
5422
|
-
settings["github.copilot.chat.mcp.enabled"] = true;
|
|
5423
|
-
fs17.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
5972
|
+
${analysis.qualityAssessment.strengths.map((s) => `- \u2705 ${s}`).join("\n")}
|
|
5973
|
+
|
|
5974
|
+
### \u5F85\u6539\u8FDB
|
|
5975
|
+
|
|
5976
|
+
${analysis.qualityAssessment.weaknesses.map((w) => `- \u26A0\uFE0F ${w}`).join("\n")}
|
|
5977
|
+
|
|
5978
|
+
### \u5EFA\u8BAE
|
|
5979
|
+
|
|
5980
|
+
${analysis.qualityAssessment.suggestions.map((s) => `- \u{1F4A1} ${s}`).join("\n")}
|
|
5981
|
+
`;
|
|
5982
|
+
return md;
|
|
5983
|
+
}
|
|
5984
|
+
function generatePlanMarkdown(plan) {
|
|
5985
|
+
var _a;
|
|
5986
|
+
let md = `# ${plan.title}
|
|
5987
|
+
|
|
5988
|
+
> \u751F\u6210\u65F6\u95F4: ${plan.generatedAt}
|
|
5989
|
+
|
|
5990
|
+
**\u53C2\u8003\u9879\u76EE**: ${plan.referenceProject}
|
|
5991
|
+
**\u65B0\u9879\u76EE**: ${plan.newProjectName}
|
|
5992
|
+
|
|
5993
|
+
---
|
|
5994
|
+
|
|
5995
|
+
`;
|
|
5996
|
+
for (const phase of plan.phases) {
|
|
5997
|
+
md += `## \u9636\u6BB5 ${phase.phase}: ${phase.name}
|
|
5998
|
+
|
|
5999
|
+
${phase.description}
|
|
6000
|
+
|
|
6001
|
+
| \u4EFB\u52A1 | \u4F18\u5148\u7EA7 | \u9884\u4F30\u65F6\u95F4 | \u76F8\u5173\u6587\u4EF6 |
|
|
6002
|
+
|------|--------|---------|----------|
|
|
6003
|
+
`;
|
|
6004
|
+
for (const task of phase.tasks) {
|
|
6005
|
+
const files = ((_a = task.files) == null ? void 0 : _a.filter((f) => f).join(", ")) || "-";
|
|
6006
|
+
md += `| ${task.task} | ${task.priority} | ${task.estimatedTime} | ${files} |
|
|
6007
|
+
`;
|
|
5424
6008
|
}
|
|
5425
|
-
|
|
5426
|
-
result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${path16.basename(workspacePath)} \u914D\u7F6E MTA MCP\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3\u4F7F\u914D\u7F6E\u751F\u6548\u3002`;
|
|
5427
|
-
checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
|
|
5428
|
-
} catch (error) {
|
|
5429
|
-
result.message = `\u26A0\uFE0F \u81EA\u52A8\u914D\u7F6E\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`;
|
|
6009
|
+
md += "\n";
|
|
5430
6010
|
}
|
|
5431
|
-
|
|
6011
|
+
md += `## \u6CE8\u610F\u4E8B\u9879
|
|
6012
|
+
|
|
6013
|
+
${plan.notes.map((n) => `- ${n}`).join("\n")}
|
|
6014
|
+
`;
|
|
6015
|
+
return md;
|
|
6016
|
+
}
|
|
6017
|
+
function generateSkeletonMarkdown(analysis) {
|
|
6018
|
+
var _a;
|
|
6019
|
+
let md = `# \u9879\u76EE\u9AA8\u67B6\u6E05\u5355
|
|
6020
|
+
|
|
6021
|
+
> \u57FA\u4E8E ${analysis.projectName} \u5206\u6790\u751F\u6210
|
|
6022
|
+
|
|
6023
|
+
## \u5FC5\u987B\u590D\u5236\u7684\u76EE\u5F55
|
|
6024
|
+
|
|
6025
|
+
`;
|
|
6026
|
+
for (const dir of analysis.skeleton.requiredDirectories) {
|
|
6027
|
+
md += `### ${dir.path}
|
|
6028
|
+
|
|
6029
|
+
- **\u63CF\u8FF0**: ${dir.description}
|
|
6030
|
+
- **\u5173\u952E\u6587\u4EF6**:
|
|
6031
|
+
${((_a = dir.files) == null ? void 0 : _a.slice(0, 5).map((f) => ` - \`${f}\``).join("\n")) || " - (\u65E0)"}
|
|
6032
|
+
|
|
6033
|
+
`;
|
|
6034
|
+
}
|
|
6035
|
+
md += `## \u6838\u5FC3\u5DE5\u5177\u7C7B
|
|
6036
|
+
|
|
6037
|
+
\u9700\u8981\u590D\u5236\u4EE5\u4E0B\u5DE5\u5177\u7C7B\u6587\u4EF6\uFF1A
|
|
6038
|
+
|
|
6039
|
+
| \u6587\u4EF6 | \u7C7B\u578B | \u8BF4\u660E |
|
|
6040
|
+
|------|------|------|
|
|
6041
|
+
`;
|
|
6042
|
+
for (const util of analysis.skeleton.coreUtils) {
|
|
6043
|
+
md += `| ${util.path} | ${util.type} | \u4F7F\u7528 ${util.usageCount} \u6B21 |
|
|
6044
|
+
`;
|
|
6045
|
+
}
|
|
6046
|
+
md += `
|
|
6047
|
+
## \u6837\u5F0F\u7CFB\u7EDF
|
|
6048
|
+
|
|
6049
|
+
### \u5FC5\u987B\u590D\u5236
|
|
6050
|
+
|
|
6051
|
+
${analysis.skeleton.styleSystem.globalStyles.map((f) => `- [ ] \`${f}\``).join("\n")}
|
|
6052
|
+
|
|
6053
|
+
### \u4E3B\u9898\u6587\u4EF6
|
|
6054
|
+
|
|
6055
|
+
${analysis.skeleton.styleSystem.themeFiles.map((f) => `- [ ] \`${f}\``).join("\n")}
|
|
6056
|
+
|
|
6057
|
+
## \u6838\u5FC3\u9875\u9762
|
|
6058
|
+
|
|
6059
|
+
- [ ] \u767B\u5F55\u9875: \`${analysis.skeleton.corePages.loginPage || "\u65E0"}\`
|
|
6060
|
+
- [ ] \u4E3B\u5E03\u5C40: \`${analysis.skeleton.corePages.mainLayout || "\u65E0"}\`
|
|
6061
|
+
- [ ] \u5BFC\u822A\u7EC4\u4EF6: \`${analysis.skeleton.corePages.navigation || "\u65E0"}\`
|
|
6062
|
+
|
|
6063
|
+
## \u6E05\u7406\u6E05\u5355
|
|
6064
|
+
|
|
6065
|
+
\u4EE5\u4E0B\u4E1A\u52A1\u6587\u4EF6\u9700\u8981\u5220\u9664\u6216\u6E05\u7A7A\uFF1A
|
|
6066
|
+
|
|
6067
|
+
${analysis.skeleton.filesToClean.map((f) => `- [ ] \`${f}\``).join("\n")}
|
|
6068
|
+
`;
|
|
6069
|
+
return md;
|
|
6070
|
+
}
|
|
6071
|
+
function generateSkeletonGuide(analysis, args) {
|
|
6072
|
+
var _a;
|
|
6073
|
+
return {
|
|
6074
|
+
directories: analysis.skeleton.requiredDirectories.map((d) => ({
|
|
6075
|
+
from: path15.join(args.referenceProjectPath, "src", d.path),
|
|
6076
|
+
to: path15.join(args.newProjectPath, "src", d.path),
|
|
6077
|
+
description: d.description
|
|
6078
|
+
})),
|
|
6079
|
+
coreUtils: analysis.skeleton.coreUtils.map((u) => ({
|
|
6080
|
+
from: u.path,
|
|
6081
|
+
type: u.type,
|
|
6082
|
+
recommended: u.recommended
|
|
6083
|
+
})),
|
|
6084
|
+
styleFiles: [
|
|
6085
|
+
...analysis.styleSystem.globalStyles,
|
|
6086
|
+
...analysis.styleSystem.themeFiles,
|
|
6087
|
+
...analysis.styleSystem.mixins
|
|
6088
|
+
],
|
|
6089
|
+
configFiles: [
|
|
6090
|
+
(_a = analysis.configSystem.buildConfig) == null ? void 0 : _a.configFile,
|
|
6091
|
+
...analysis.configSystem.envFiles
|
|
6092
|
+
].filter(Boolean),
|
|
6093
|
+
corePages: [
|
|
6094
|
+
analysis.corePages.loginPage,
|
|
6095
|
+
analysis.corePages.mainLayout,
|
|
6096
|
+
analysis.corePages.navigation,
|
|
6097
|
+
...analysis.corePages.errorPages
|
|
6098
|
+
].filter(Boolean)
|
|
6099
|
+
};
|
|
6100
|
+
}
|
|
6101
|
+
function groupBy(arr, key) {
|
|
6102
|
+
return arr.reduce((acc, item) => {
|
|
6103
|
+
const k = item[key];
|
|
6104
|
+
acc[k] = (acc[k] || 0) + 1;
|
|
6105
|
+
return acc;
|
|
6106
|
+
}, {});
|
|
5432
6107
|
}
|
|
5433
6108
|
|
|
5434
6109
|
// src/tools/queryTroubleshootingCases.ts
|
|
6110
|
+
init_resourceLoader();
|
|
6111
|
+
init_core();
|
|
6112
|
+
import * as fs18 from "fs";
|
|
6113
|
+
import * as path17 from "path";
|
|
5435
6114
|
var logger2 = createLogger("QueryTroubleshootingCases");
|
|
5436
6115
|
function extractCaseMetadata(filePath, framework) {
|
|
5437
6116
|
try {
|
|
@@ -5700,8 +6379,9 @@ async function listTroubleshootingCases(framework) {
|
|
|
5700
6379
|
}
|
|
5701
6380
|
|
|
5702
6381
|
// src/index.ts
|
|
5703
|
-
|
|
5704
|
-
var
|
|
6382
|
+
init_core();
|
|
6383
|
+
var SERVER_VERSION = "3.1.0";
|
|
6384
|
+
var logger8 = createLogger("Server");
|
|
5705
6385
|
var CopilotPromptsMCPServer = class {
|
|
5706
6386
|
constructor() {
|
|
5707
6387
|
this.standardsManager = new StandardsManager();
|
|
@@ -5727,24 +6407,24 @@ var CopilotPromptsMCPServer = class {
|
|
|
5727
6407
|
*/
|
|
5728
6408
|
setupErrorHandlers() {
|
|
5729
6409
|
this.server.onerror = (error) => {
|
|
5730
|
-
|
|
6410
|
+
logger8.error("MCP \u670D\u52A1\u5668\u9519\u8BEF", error);
|
|
5731
6411
|
};
|
|
5732
6412
|
process.on("SIGINT", async () => {
|
|
5733
|
-
|
|
6413
|
+
logger8.info("\u6536\u5230\u5173\u95ED\u4FE1\u53F7\uFF0C\u6B63\u5728\u5173\u95ED\u670D\u52A1\u5668...");
|
|
5734
6414
|
await this.server.close();
|
|
5735
6415
|
process.exit(0);
|
|
5736
6416
|
});
|
|
5737
6417
|
process.on("SIGTERM", async () => {
|
|
5738
|
-
|
|
6418
|
+
logger8.info("\u6536\u5230\u7EC8\u6B62\u4FE1\u53F7\uFF0C\u6B63\u5728\u5173\u95ED\u670D\u52A1\u5668...");
|
|
5739
6419
|
await this.server.close();
|
|
5740
6420
|
process.exit(0);
|
|
5741
6421
|
});
|
|
5742
6422
|
process.on("uncaughtException", (error) => {
|
|
5743
|
-
|
|
6423
|
+
logger8.error("\u672A\u6355\u83B7\u7684\u5F02\u5E38:", error);
|
|
5744
6424
|
process.exit(1);
|
|
5745
6425
|
});
|
|
5746
6426
|
process.on("unhandledRejection", (reason, promise) => {
|
|
5747
|
-
|
|
6427
|
+
logger8.error("\u672A\u5904\u7406\u7684 Promise \u62D2\u7EDD:", reason);
|
|
5748
6428
|
process.exit(1);
|
|
5749
6429
|
});
|
|
5750
6430
|
}
|
|
@@ -6260,6 +6940,163 @@ var CopilotPromptsMCPServer = class {
|
|
|
6260
6940
|
}
|
|
6261
6941
|
}
|
|
6262
6942
|
}
|
|
6943
|
+
},
|
|
6944
|
+
// ========== Skills 工具(扩展能力,不影响核心功能) ==========
|
|
6945
|
+
{
|
|
6946
|
+
name: "http_request",
|
|
6947
|
+
description: "\u53D1\u9001 HTTP \u8BF7\u6C42\u3002\u652F\u6301 GET/POST/PUT/DELETE \u7B49\u65B9\u6CD5\uFF0C\u53EF\u81EA\u5B9A\u4E49\u8BF7\u6C42\u5934\u548C\u8BF7\u6C42\u4F53\u3002\u9002\u7528\u4E8E API \u6D4B\u8BD5\u3001\u6570\u636E\u83B7\u53D6\u7B49\u573A\u666F\u3002",
|
|
6948
|
+
inputSchema: {
|
|
6949
|
+
type: "object",
|
|
6950
|
+
properties: {
|
|
6951
|
+
url: {
|
|
6952
|
+
type: "string",
|
|
6953
|
+
description: "\u8BF7\u6C42 URL\uFF08\u5FC5\u987B\u662F\u5B8C\u6574 URL\uFF0C\u5305\u542B\u534F\u8BAE\uFF09"
|
|
6954
|
+
},
|
|
6955
|
+
method: {
|
|
6956
|
+
type: "string",
|
|
6957
|
+
enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
|
|
6958
|
+
default: "GET",
|
|
6959
|
+
description: "HTTP \u65B9\u6CD5"
|
|
6960
|
+
},
|
|
6961
|
+
headers: {
|
|
6962
|
+
type: "object",
|
|
6963
|
+
additionalProperties: { type: "string" },
|
|
6964
|
+
description: "\u8BF7\u6C42\u5934\uFF08\u5982 Authorization\u3001Content-Type \u7B49\uFF09"
|
|
6965
|
+
},
|
|
6966
|
+
body: {
|
|
6967
|
+
description: "\u8BF7\u6C42\u4F53\uFF08POST/PUT/PATCH \u65F6\u4F7F\u7528\uFF09"
|
|
6968
|
+
},
|
|
6969
|
+
timeout: {
|
|
6970
|
+
type: "number",
|
|
6971
|
+
default: 3e4,
|
|
6972
|
+
description: "\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09"
|
|
6973
|
+
}
|
|
6974
|
+
},
|
|
6975
|
+
required: ["url"]
|
|
6976
|
+
}
|
|
6977
|
+
},
|
|
6978
|
+
// Memory Skills
|
|
6979
|
+
{
|
|
6980
|
+
name: "store_memory",
|
|
6981
|
+
description: "\u5B58\u50A8\u4E00\u6761\u8BB0\u5FC6\uFF0C\u7528\u4E8E\u8DE8\u4F1A\u8BDD\u4FDD\u5B58\u9879\u76EE\u7EA6\u5B9A\u3001\u4E1A\u52A1\u89C4\u5219\u7B49\u4FE1\u606F",
|
|
6982
|
+
inputSchema: {
|
|
6983
|
+
type: "object",
|
|
6984
|
+
properties: {
|
|
6985
|
+
key: {
|
|
6986
|
+
type: "string",
|
|
6987
|
+
description: "\u8BB0\u5FC6\u7684\u952E\uFF08\u552F\u4E00\u6807\u8BC6\uFF09"
|
|
6988
|
+
},
|
|
6989
|
+
value: {
|
|
6990
|
+
type: "string",
|
|
6991
|
+
description: "\u8BB0\u5FC6\u7684\u5185\u5BB9"
|
|
6992
|
+
}
|
|
6993
|
+
},
|
|
6994
|
+
required: ["key", "value"]
|
|
6995
|
+
}
|
|
6996
|
+
},
|
|
6997
|
+
{
|
|
6998
|
+
name: "retrieve_memory",
|
|
6999
|
+
description: "\u68C0\u7D22\u4E00\u6761\u8BB0\u5FC6",
|
|
7000
|
+
inputSchema: {
|
|
7001
|
+
type: "object",
|
|
7002
|
+
properties: {
|
|
7003
|
+
key: {
|
|
7004
|
+
type: "string",
|
|
7005
|
+
description: "\u8BB0\u5FC6\u7684\u952E"
|
|
7006
|
+
}
|
|
7007
|
+
},
|
|
7008
|
+
required: ["key"]
|
|
7009
|
+
}
|
|
7010
|
+
},
|
|
7011
|
+
{
|
|
7012
|
+
name: "list_memories",
|
|
7013
|
+
description: "\u5217\u51FA\u6240\u6709\u5B58\u50A8\u7684\u8BB0\u5FC6",
|
|
7014
|
+
inputSchema: {
|
|
7015
|
+
type: "object",
|
|
7016
|
+
properties: {}
|
|
7017
|
+
}
|
|
7018
|
+
},
|
|
7019
|
+
// Filesystem Skills
|
|
7020
|
+
{
|
|
7021
|
+
name: "glob_files",
|
|
7022
|
+
description: "\u4F7F\u7528 glob \u6A21\u5F0F\u67E5\u627E\u6587\u4EF6\uFF0C\u652F\u6301\u901A\u914D\u7B26\uFF08\u5982 **/*.ts\uFF09",
|
|
7023
|
+
inputSchema: {
|
|
7024
|
+
type: "object",
|
|
7025
|
+
properties: {
|
|
7026
|
+
pattern: {
|
|
7027
|
+
type: "string",
|
|
7028
|
+
description: "glob \u6A21\u5F0F\uFF08\u5982 src/**/*.ts\uFF09"
|
|
7029
|
+
},
|
|
7030
|
+
cwd: {
|
|
7031
|
+
type: "string",
|
|
7032
|
+
description: "\u5DE5\u4F5C\u76EE\u5F55\uFF08\u53EF\u9009\uFF0C\u9ED8\u8BA4\u4E3A\u5F53\u524D\u76EE\u5F55\uFF09"
|
|
7033
|
+
},
|
|
7034
|
+
ignore: {
|
|
7035
|
+
type: "array",
|
|
7036
|
+
items: { type: "string" },
|
|
7037
|
+
description: "\u5FFD\u7565\u7684\u6A21\u5F0F\u5217\u8868\uFF08\u53EF\u9009\uFF09"
|
|
7038
|
+
}
|
|
7039
|
+
},
|
|
7040
|
+
required: ["pattern"]
|
|
7041
|
+
}
|
|
7042
|
+
},
|
|
7043
|
+
{
|
|
7044
|
+
name: "batch_rename",
|
|
7045
|
+
description: "\u6279\u91CF\u91CD\u547D\u540D\u6587\u4EF6\uFF0C\u4F7F\u7528\u6B63\u5219\u8868\u8FBE\u5F0F\u66FF\u6362",
|
|
7046
|
+
inputSchema: {
|
|
7047
|
+
type: "object",
|
|
7048
|
+
properties: {
|
|
7049
|
+
files: {
|
|
7050
|
+
type: "array",
|
|
7051
|
+
items: { type: "string" },
|
|
7052
|
+
description: "\u8981\u91CD\u547D\u540D\u7684\u6587\u4EF6\u5217\u8868"
|
|
7053
|
+
},
|
|
7054
|
+
pattern: {
|
|
7055
|
+
type: "string",
|
|
7056
|
+
description: "\u6B63\u5219\u8868\u8FBE\u5F0F\u6A21\u5F0F\uFF08\u7528\u4E8E\u5339\u914D\u6587\u4EF6\u540D\uFF09"
|
|
7057
|
+
},
|
|
7058
|
+
replacement: {
|
|
7059
|
+
type: "string",
|
|
7060
|
+
description: "\u66FF\u6362\u5B57\u7B26\u4E32\uFF08\u652F\u6301 $1, $2 \u7B49\u6355\u83B7\u7EC4\uFF09"
|
|
7061
|
+
},
|
|
7062
|
+
cwd: {
|
|
7063
|
+
type: "string",
|
|
7064
|
+
description: "\u5DE5\u4F5C\u76EE\u5F55\uFF08\u53EF\u9009\uFF09"
|
|
7065
|
+
},
|
|
7066
|
+
dryRun: {
|
|
7067
|
+
type: "boolean",
|
|
7068
|
+
description: "\u6A21\u62DF\u8FD0\u884C\uFF0C\u4E0D\u5B9E\u9645\u6267\u884C\uFF08\u53EF\u9009\uFF09"
|
|
7069
|
+
}
|
|
7070
|
+
},
|
|
7071
|
+
required: ["files", "pattern", "replacement"]
|
|
7072
|
+
}
|
|
7073
|
+
},
|
|
7074
|
+
// Thinking Skills
|
|
7075
|
+
{
|
|
7076
|
+
name: "think_step_by_step",
|
|
7077
|
+
description: "\u5BF9\u590D\u6742\u95EE\u9898\u8FDB\u884C\u5206\u6B65\u601D\u8003\uFF0C\u9002\u7528\u4E8E\u67B6\u6784\u8BBE\u8BA1\u3001\u91CD\u6784\u89C4\u5212\u7B49\u9700\u8981\u6DF1\u5EA6\u5206\u6790\u7684\u573A\u666F",
|
|
7078
|
+
inputSchema: {
|
|
7079
|
+
type: "object",
|
|
7080
|
+
properties: {
|
|
7081
|
+
problem: {
|
|
7082
|
+
type: "string",
|
|
7083
|
+
description: "\u9700\u8981\u6DF1\u5165\u601D\u8003\u7684\u95EE\u9898\u6216\u4EFB\u52A1"
|
|
7084
|
+
},
|
|
7085
|
+
context: {
|
|
7086
|
+
type: "string",
|
|
7087
|
+
description: "\u76F8\u5173\u80CC\u666F\u4FE1\u606F\u6216\u7EA6\u675F\u6761\u4EF6\uFF08\u53EF\u9009\uFF09"
|
|
7088
|
+
}
|
|
7089
|
+
},
|
|
7090
|
+
required: ["problem"]
|
|
7091
|
+
}
|
|
7092
|
+
},
|
|
7093
|
+
{
|
|
7094
|
+
name: "list_skills",
|
|
7095
|
+
description: "\u5217\u51FA MTA \u5DF2\u96C6\u6210\u7684\u6240\u6709 Skills\uFF08\u6269\u5C55\u80FD\u529B\uFF09",
|
|
7096
|
+
inputSchema: {
|
|
7097
|
+
type: "object",
|
|
7098
|
+
properties: {}
|
|
7099
|
+
}
|
|
6263
7100
|
}
|
|
6264
7101
|
]
|
|
6265
7102
|
}));
|
|
@@ -6267,15 +7104,15 @@ var CopilotPromptsMCPServer = class {
|
|
|
6267
7104
|
var _a, _b;
|
|
6268
7105
|
try {
|
|
6269
7106
|
const { name, arguments: args } = request.params;
|
|
6270
|
-
|
|
6271
|
-
|
|
7107
|
+
logger8.debug(`\u8C03\u7528\u5DE5\u5177: ${name}`);
|
|
7108
|
+
logger8.debug(`\u53C2\u6570:`, args);
|
|
6272
7109
|
const workspacePath = (args == null ? void 0 : args.workspacePath) || (args == null ? void 0 : args.projectPath);
|
|
6273
7110
|
let autoConfigMessage = null;
|
|
6274
7111
|
if (workspacePath) {
|
|
6275
7112
|
const configResult = ensureWorkspaceConfig(workspacePath);
|
|
6276
7113
|
if (configResult.wasFixed) {
|
|
6277
7114
|
autoConfigMessage = configResult.message || null;
|
|
6278
|
-
|
|
7115
|
+
logger8.info(`\u81EA\u52A8\u914D\u7F6E\u5DF2\u4FEE\u590D: ${workspacePath}`);
|
|
6279
7116
|
}
|
|
6280
7117
|
}
|
|
6281
7118
|
let result;
|
|
@@ -6372,6 +7209,77 @@ var CopilotPromptsMCPServer = class {
|
|
|
6372
7209
|
case "list_troubleshooting_cases":
|
|
6373
7210
|
result = await listTroubleshootingCases(args == null ? void 0 : args.framework);
|
|
6374
7211
|
break;
|
|
7212
|
+
// ========== Skills 工具处理 ==========
|
|
7213
|
+
case "http_request":
|
|
7214
|
+
const { handleHttpRequest: handleHttpRequest2 } = await Promise.resolve().then(() => (init_http(), http_exports));
|
|
7215
|
+
result = await handleHttpRequest2(args);
|
|
7216
|
+
break;
|
|
7217
|
+
// Memory Skills
|
|
7218
|
+
case "store_memory":
|
|
7219
|
+
const { handleStoreMemory: handleStoreMemory2 } = await Promise.resolve().then(() => (init_memory(), memory_exports));
|
|
7220
|
+
result = await handleStoreMemory2(args);
|
|
7221
|
+
break;
|
|
7222
|
+
case "retrieve_memory":
|
|
7223
|
+
const { handleRetrieveMemory: handleRetrieveMemory2 } = await Promise.resolve().then(() => (init_memory(), memory_exports));
|
|
7224
|
+
result = await handleRetrieveMemory2(args);
|
|
7225
|
+
break;
|
|
7226
|
+
case "list_memories":
|
|
7227
|
+
const { handleListMemories: handleListMemories2 } = await Promise.resolve().then(() => (init_memory(), memory_exports));
|
|
7228
|
+
result = await handleListMemories2();
|
|
7229
|
+
break;
|
|
7230
|
+
// Filesystem Skills
|
|
7231
|
+
case "glob_files":
|
|
7232
|
+
const { handleGlobFiles: handleGlobFiles2 } = await Promise.resolve().then(() => (init_filesystem(), filesystem_exports));
|
|
7233
|
+
result = await handleGlobFiles2(args);
|
|
7234
|
+
break;
|
|
7235
|
+
case "batch_rename":
|
|
7236
|
+
const { handleBatchRename: handleBatchRename2 } = await Promise.resolve().then(() => (init_filesystem(), filesystem_exports));
|
|
7237
|
+
result = await handleBatchRename2(args);
|
|
7238
|
+
break;
|
|
7239
|
+
// Thinking Skills
|
|
7240
|
+
case "think_step_by_step":
|
|
7241
|
+
const { handleThinkStepByStep: handleThinkStepByStep2 } = await Promise.resolve().then(() => (init_thinking(), thinking_exports));
|
|
7242
|
+
result = await handleThinkStepByStep2(args);
|
|
7243
|
+
break;
|
|
7244
|
+
case "list_skills":
|
|
7245
|
+
const { getSkillsManager: getSkillsManager2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
|
|
7246
|
+
const skillsManager = getSkillsManager2();
|
|
7247
|
+
const allSkills = skillsManager.getAllSkillsInfo();
|
|
7248
|
+
let skillsOutput = `## MTA Skills\uFF08\u6269\u5C55\u80FD\u529B\uFF09
|
|
7249
|
+
|
|
7250
|
+
`;
|
|
7251
|
+
skillsOutput += `> \u4EE5\u4E0B Skills \u5DF2\u96C6\u6210\u5230 MTA\uFF0C\u53EF\u76F4\u63A5\u8C03\u7528\u5BF9\u5E94\u5DE5\u5177
|
|
7252
|
+
|
|
7253
|
+
`;
|
|
7254
|
+
const enabledSkills = allSkills.filter((s) => s.config.enabled);
|
|
7255
|
+
const disabledSkills = allSkills.filter((s) => !s.config.enabled);
|
|
7256
|
+
if (enabledSkills.length > 0) {
|
|
7257
|
+
skillsOutput += `### \u2705 \u5DF2\u542F\u7528
|
|
7258
|
+
|
|
7259
|
+
`;
|
|
7260
|
+
for (const skill of enabledSkills) {
|
|
7261
|
+
skillsOutput += `- **${skill.id}** (v${skill.config.version})
|
|
7262
|
+
`;
|
|
7263
|
+
skillsOutput += ` - ${skill.config.description}
|
|
7264
|
+
`;
|
|
7265
|
+
skillsOutput += ` - \u5DE5\u5177: ${skill.config.tools.join(", ")}
|
|
7266
|
+
|
|
7267
|
+
`;
|
|
7268
|
+
}
|
|
7269
|
+
}
|
|
7270
|
+
if (disabledSkills.length > 0) {
|
|
7271
|
+
skillsOutput += `### \u23F8\uFE0F \u5F85\u96C6\u6210
|
|
7272
|
+
|
|
7273
|
+
`;
|
|
7274
|
+
for (const skill of disabledSkills) {
|
|
7275
|
+
skillsOutput += `- **${skill.id}** - ${skill.config.description}
|
|
7276
|
+
`;
|
|
7277
|
+
}
|
|
7278
|
+
}
|
|
7279
|
+
result = {
|
|
7280
|
+
content: [{ type: "text", text: skillsOutput }]
|
|
7281
|
+
};
|
|
7282
|
+
break;
|
|
6375
7283
|
default:
|
|
6376
7284
|
throw new Error(`\u672A\u77E5\u5DE5\u5177: ${name}`);
|
|
6377
7285
|
}
|
|
@@ -6390,7 +7298,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
6390
7298
|
}
|
|
6391
7299
|
return result;
|
|
6392
7300
|
} catch (error) {
|
|
6393
|
-
|
|
7301
|
+
logger8.error(`\u5DE5\u5177\u6267\u884C\u5931\u8D25:`, error);
|
|
6394
7302
|
return errorResponse(error);
|
|
6395
7303
|
}
|
|
6396
7304
|
});
|
|
@@ -6459,7 +7367,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
6459
7367
|
`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`
|
|
6460
7368
|
];
|
|
6461
7369
|
startupInfo.forEach((line) => console.error(line));
|
|
6462
|
-
|
|
7370
|
+
logger8.info(`MCP Server \u5C31\u7EEA\uFF0C\u7B49\u5F85 Copilot Chat \u8FDE\u63A5...`);
|
|
6463
7371
|
}
|
|
6464
7372
|
};
|
|
6465
7373
|
var isTestMode = process.env.MTA_TEST_MODE === "true" || process.argv.includes("--test");
|
|
@@ -6481,7 +7389,7 @@ if (!isTestMode) {
|
|
|
6481
7389
|
console.error(` \u2022 \u8FD0\u884C npm install \u91CD\u65B0\u5B89\u88C5\u4F9D\u8D56`);
|
|
6482
7390
|
console.error(` \u2022 \u68C0\u67E5\u662F\u5426\u6709\u5176\u4ED6 MCP \u670D\u52A1\u5668\u5B9E\u4F8B\u8FD0\u884C`);
|
|
6483
7391
|
console.error(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`);
|
|
6484
|
-
|
|
7392
|
+
logger8.error("\u670D\u52A1\u5668\u542F\u52A8\u5931\u8D25:", error);
|
|
6485
7393
|
process.exit(1);
|
|
6486
7394
|
});
|
|
6487
7395
|
}
|