mta-mcp 3.1.0 → 3.2.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/_TEMPLATE.md +26 -0
- package/agents/flutter.agent.md +16 -10
- package/agents/i18n.agent.md +21 -0
- package/agents/logicflow.agent.md +22 -0
- package/agents/mta.agent.md +35 -0
- package/agents/vue3.agent.md +16 -10
- package/agents/wechat-miniprogram.agent.md +22 -0
- package/bin/mta.cjs +0 -98
- package/dist/index.js +948 -1355
- package/dist/index.js.map +1 -1
- package/package.json +6 -8
- package/dist/skills/filesystem.d.ts +0 -96
- package/dist/skills/filesystem.js +0 -269
- package/dist/skills/filesystem.js.map +0 -1
- package/dist/skills/http.d.ts +0 -73
- package/dist/skills/http.js +0 -234
- package/dist/skills/http.js.map +0 -1
- package/dist/skills/index.d.ts +0 -79
- package/dist/skills/index.js +0 -206
- package/dist/skills/index.js.map +0 -1
- package/dist/skills/memory.d.ts +0 -73
- package/dist/skills/memory.js +0 -223
- package/dist/skills/memory.js.map +0 -1
- package/dist/skills/thinking.d.ts +0 -48
- package/dist/skills/thinking.js +0 -199
- package/dist/skills/thinking.js.map +0 -1
- package/dist/skills/versionChecker.d.ts +0 -30
- package/dist/skills/versionChecker.js +0 -225
- package/dist/skills/versionChecker.js.map +0 -1
- package/skills.json +0 -68
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(logger4) {
|
|
22
|
+
this.logger = logger4;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* 分析项目特征
|
|
@@ -430,30 +430,6 @@ 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
|
-
|
|
457
433
|
// src/core/resourceLoader.ts
|
|
458
434
|
var resourceLoader_exports = {};
|
|
459
435
|
__export(resourceLoader_exports, {
|
|
@@ -463,9 +439,9 @@ __export(resourceLoader_exports, {
|
|
|
463
439
|
import * as fs4 from "fs";
|
|
464
440
|
import * as path4 from "path";
|
|
465
441
|
import { fileURLToPath } from "url";
|
|
466
|
-
function getResourceLoader(
|
|
442
|
+
function getResourceLoader(logger4) {
|
|
467
443
|
if (!resourceLoaderInstance) {
|
|
468
|
-
resourceLoaderInstance = new ResourceLoader(
|
|
444
|
+
resourceLoaderInstance = new ResourceLoader(logger4);
|
|
469
445
|
}
|
|
470
446
|
return resourceLoaderInstance;
|
|
471
447
|
}
|
|
@@ -477,9 +453,9 @@ var init_resourceLoader = __esm({
|
|
|
477
453
|
__filename = fileURLToPath(import.meta.url);
|
|
478
454
|
__dirname = path4.dirname(__filename);
|
|
479
455
|
ResourceLoader = class {
|
|
480
|
-
constructor(
|
|
456
|
+
constructor(logger4) {
|
|
481
457
|
this.initialized = false;
|
|
482
|
-
this.logger =
|
|
458
|
+
this.logger = logger4;
|
|
483
459
|
this.packageRoot = this.detectPackageRoot();
|
|
484
460
|
this.validateResources();
|
|
485
461
|
}
|
|
@@ -536,1077 +512,167 @@ var init_resourceLoader = __esm({
|
|
|
536
512
|
loadAllAgents() {
|
|
537
513
|
const agentsDir = this.getResourceDir("agents");
|
|
538
514
|
const agents = [];
|
|
539
|
-
this.log(`\u{1F4C1} \u4ECE\u5305\u5185\u52A0\u8F7D Agents: ${agentsDir}`);
|
|
540
|
-
if (!fs4.existsSync(agentsDir)) {
|
|
541
|
-
this.error(`Agents \u76EE\u5F55\u4E0D\u5B58\u5728: ${agentsDir}`);
|
|
542
|
-
this.error(`\u5305\u6839\u76EE\u5F55: ${this.packageRoot}`);
|
|
543
|
-
this.error(`\u5F53\u524D __dirname: ${__dirname}`);
|
|
544
|
-
return agents;
|
|
545
|
-
}
|
|
546
|
-
const matcher = new SmartAgentMatcher(this.logger);
|
|
547
|
-
const files = fs4.readdirSync(agentsDir);
|
|
548
|
-
for (const file of files) {
|
|
549
|
-
if (file.endsWith(".agent.md")) {
|
|
550
|
-
try {
|
|
551
|
-
const filePath = path4.join(agentsDir, file);
|
|
552
|
-
const content = fs4.readFileSync(filePath, "utf-8");
|
|
553
|
-
const metadata = matcher.parseAgentMetadata(`agents/${file}`, content);
|
|
554
|
-
agents.push(metadata);
|
|
555
|
-
this.log(`\u2705 \u52A0\u8F7D Agent: ${metadata.title}`);
|
|
556
|
-
} catch (error) {
|
|
557
|
-
this.error(`\u89E3\u6790 ${file} \u5931\u8D25: ${error}`);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
this.log(`\u2705 \u6210\u529F\u52A0\u8F7D ${agents.length} \u4E2A Agents`);
|
|
562
|
-
return agents;
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* 加载单个 Agent
|
|
566
|
-
*/
|
|
567
|
-
loadAgent(agentId) {
|
|
568
|
-
const agentsDir = this.getResourceDir("agents");
|
|
569
|
-
const filePath = path4.join(agentsDir, `${agentId}.agent.md`);
|
|
570
|
-
if (!fs4.existsSync(filePath)) {
|
|
571
|
-
this.error(`Agent \u4E0D\u5B58\u5728: ${agentId}`);
|
|
572
|
-
return null;
|
|
573
|
-
}
|
|
574
|
-
try {
|
|
575
|
-
const content = fs4.readFileSync(filePath, "utf-8");
|
|
576
|
-
const matcher = new SmartAgentMatcher(this.logger);
|
|
577
|
-
const metadata = matcher.parseAgentMetadata(`agents/${agentId}.agent.md`, content);
|
|
578
|
-
return { content, metadata };
|
|
579
|
-
} catch (error) {
|
|
580
|
-
this.error(`\u52A0\u8F7D Agent ${agentId} \u5931\u8D25: ${error}`);
|
|
581
|
-
return null;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* 列出所有可用的 Agent ID
|
|
586
|
-
*/
|
|
587
|
-
listAgentIds() {
|
|
588
|
-
const agentsDir = this.getResourceDir("agents");
|
|
589
|
-
if (!fs4.existsSync(agentsDir)) {
|
|
590
|
-
return [];
|
|
591
|
-
}
|
|
592
|
-
return fs4.readdirSync(agentsDir).filter((f) => f.endsWith(".agent.md")).map((f) => f.replace(".agent.md", ""));
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* 加载规范文件
|
|
596
|
-
*/
|
|
597
|
-
loadStandard(standardPath) {
|
|
598
|
-
const standardsDir = this.getResourceDir("standards");
|
|
599
|
-
const filePath = path4.join(standardsDir, standardPath);
|
|
600
|
-
if (!fs4.existsSync(filePath)) {
|
|
601
|
-
const commonPath = path4.join(this.getResourceDir("common"), standardPath);
|
|
602
|
-
if (fs4.existsSync(commonPath)) {
|
|
603
|
-
return fs4.readFileSync(commonPath, "utf-8");
|
|
604
|
-
}
|
|
605
|
-
this.error(`\u89C4\u8303\u6587\u4EF6\u4E0D\u5B58\u5728: ${standardPath}`);
|
|
606
|
-
return null;
|
|
607
|
-
}
|
|
608
|
-
return fs4.readFileSync(filePath, "utf-8");
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* 列出规范目录下的所有文件
|
|
612
|
-
*/
|
|
613
|
-
listStandards(subDir) {
|
|
614
|
-
const standardsDir = this.getResourceDir("standards");
|
|
615
|
-
const targetDir = subDir ? path4.join(standardsDir, subDir) : standardsDir;
|
|
616
|
-
if (!fs4.existsSync(targetDir)) {
|
|
617
|
-
return [];
|
|
618
|
-
}
|
|
619
|
-
const results = [];
|
|
620
|
-
this.walkDir(targetDir, standardsDir, results);
|
|
621
|
-
return results;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* 加载模板
|
|
625
|
-
*/
|
|
626
|
-
loadTemplate(templatePath) {
|
|
627
|
-
const templatesDir = this.getResourceDir("templates");
|
|
628
|
-
const filePath = path4.join(templatesDir, templatePath);
|
|
629
|
-
if (!fs4.existsSync(filePath)) {
|
|
630
|
-
this.error(`\u6A21\u677F\u6587\u4EF6\u4E0D\u5B58\u5728: ${templatePath}`);
|
|
631
|
-
return null;
|
|
632
|
-
}
|
|
633
|
-
return fs4.readFileSync(filePath, "utf-8");
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* 列出模板目录
|
|
637
|
-
*/
|
|
638
|
-
listTemplates(subDir) {
|
|
639
|
-
const templatesDir = this.getResourceDir("templates");
|
|
640
|
-
const targetDir = subDir ? path4.join(templatesDir, subDir) : templatesDir;
|
|
641
|
-
if (!fs4.existsSync(targetDir)) {
|
|
642
|
-
return [];
|
|
643
|
-
}
|
|
644
|
-
return fs4.readdirSync(targetDir);
|
|
645
|
-
}
|
|
646
|
-
/**
|
|
647
|
-
* 检查资源是否存在
|
|
648
|
-
*/
|
|
649
|
-
resourceExists(type, relativePath) {
|
|
650
|
-
const baseDir = this.getResourceDir(type);
|
|
651
|
-
return fs4.existsSync(path4.join(baseDir, relativePath));
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* 获取包版本
|
|
655
|
-
*/
|
|
656
|
-
getPackageVersion() {
|
|
657
|
-
try {
|
|
658
|
-
const packageJsonPath = path4.join(this.packageRoot, "package.json");
|
|
659
|
-
if (fs4.existsSync(packageJsonPath)) {
|
|
660
|
-
const packageJson = JSON.parse(fs4.readFileSync(packageJsonPath, "utf-8"));
|
|
661
|
-
return packageJson.version || "unknown";
|
|
662
|
-
}
|
|
663
|
-
} catch {
|
|
664
|
-
}
|
|
665
|
-
return "unknown";
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* 获取资源统计信息
|
|
669
|
-
*/
|
|
670
|
-
getResourceStats() {
|
|
671
|
-
return {
|
|
672
|
-
agents: this.listAgentIds().length,
|
|
673
|
-
standards: this.listStandards().length,
|
|
674
|
-
templates: this.listTemplates().length,
|
|
675
|
-
version: this.getPackageVersion()
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
walkDir(dir, baseDir, results) {
|
|
679
|
-
const files = fs4.readdirSync(dir);
|
|
680
|
-
for (const file of files) {
|
|
681
|
-
const filePath = path4.join(dir, file);
|
|
682
|
-
const stat = fs4.statSync(filePath);
|
|
683
|
-
if (stat.isDirectory()) {
|
|
684
|
-
this.walkDir(filePath, baseDir, results);
|
|
685
|
-
} else if (file.endsWith(".md")) {
|
|
686
|
-
results.push(path4.relative(baseDir, filePath));
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
log(message) {
|
|
691
|
-
var _a;
|
|
692
|
-
(_a = this.logger) == null ? void 0 : _a.log(message);
|
|
693
|
-
}
|
|
694
|
-
error(message) {
|
|
695
|
-
var _a;
|
|
696
|
-
(_a = this.logger) == null ? void 0 : _a.error(message);
|
|
697
|
-
}
|
|
698
|
-
};
|
|
699
|
-
resourceLoaderInstance = null;
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
|
|
703
|
-
// src/core/errors.ts
|
|
704
|
-
function errorResponse(error) {
|
|
705
|
-
if (error instanceof MCPError) {
|
|
706
|
-
return error.toResponse();
|
|
707
|
-
}
|
|
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"
|
|
741
|
-
};
|
|
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);
|
|
751
|
-
}
|
|
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
|
-
};
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* 转换为 MCP 响应格式
|
|
765
|
-
*/
|
|
766
|
-
toResponse() {
|
|
767
|
-
return {
|
|
768
|
-
content: [{
|
|
769
|
-
type: "text",
|
|
770
|
-
text: JSON.stringify(this.toJSON(), null, 2)
|
|
771
|
-
}]
|
|
772
|
-
};
|
|
773
|
-
}
|
|
774
|
-
};
|
|
775
|
-
}
|
|
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"
|
|
792
|
-
};
|
|
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
|
-
}
|
|
825
|
-
}
|
|
826
|
-
return String(arg);
|
|
827
|
-
});
|
|
828
|
-
parts.push(...formatted);
|
|
829
|
-
}
|
|
830
|
-
return parts.join(" ");
|
|
831
|
-
}
|
|
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"
|
|
515
|
+
this.log(`\u{1F4C1} \u4ECE\u5305\u5185\u52A0\u8F7D Agents: ${agentsDir}`);
|
|
516
|
+
if (!fs4.existsSync(agentsDir)) {
|
|
517
|
+
this.error(`Agents \u76EE\u5F55\u4E0D\u5B58\u5728: ${agentsDir}`);
|
|
518
|
+
this.error(`\u5305\u6839\u76EE\u5F55: ${this.packageRoot}`);
|
|
519
|
+
this.error(`\u5F53\u524D __dirname: ${__dirname}`);
|
|
520
|
+
return agents;
|
|
521
|
+
}
|
|
522
|
+
const matcher = new SmartAgentMatcher(this.logger);
|
|
523
|
+
const files = fs4.readdirSync(agentsDir);
|
|
524
|
+
for (const file of files) {
|
|
525
|
+
if (file.endsWith(".agent.md")) {
|
|
526
|
+
try {
|
|
527
|
+
const filePath = path4.join(agentsDir, file);
|
|
528
|
+
const content = fs4.readFileSync(filePath, "utf-8");
|
|
529
|
+
const metadata = matcher.parseAgentMetadata(`agents/${file}`, content);
|
|
530
|
+
agents.push(metadata);
|
|
531
|
+
this.log(`\u2705 \u52A0\u8F7D Agent: ${metadata.title}`);
|
|
532
|
+
} catch (error) {
|
|
533
|
+
this.error(`\u89E3\u6790 ${file} \u5931\u8D25: ${error}`);
|
|
1499
534
|
}
|
|
1500
|
-
}
|
|
1501
|
-
required: ["problem"]
|
|
535
|
+
}
|
|
1502
536
|
}
|
|
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();
|
|
537
|
+
this.log(`\u2705 \u6210\u529F\u52A0\u8F7D ${agents.length} \u4E2A Agents`);
|
|
538
|
+
return agents;
|
|
1535
539
|
}
|
|
1536
540
|
/**
|
|
1537
|
-
*
|
|
1538
|
-
* 从 npm 包内的 skills.json 加载,无需本地配置
|
|
541
|
+
* 加载单个 Agent
|
|
1539
542
|
*/
|
|
1540
|
-
|
|
1541
|
-
|
|
543
|
+
loadAgent(agentId) {
|
|
544
|
+
const agentsDir = this.getResourceDir("agents");
|
|
545
|
+
const filePath = path4.join(agentsDir, `${agentId}.agent.md`);
|
|
546
|
+
if (!fs4.existsSync(filePath)) {
|
|
547
|
+
this.error(`Agent \u4E0D\u5B58\u5728: ${agentId}`);
|
|
548
|
+
return null;
|
|
549
|
+
}
|
|
1542
550
|
try {
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
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
|
-
}
|
|
551
|
+
const content = fs4.readFileSync(filePath, "utf-8");
|
|
552
|
+
const matcher = new SmartAgentMatcher(this.logger);
|
|
553
|
+
const metadata = matcher.parseAgentMetadata(`agents/${agentId}.agent.md`, content);
|
|
554
|
+
return { content, metadata };
|
|
1552
555
|
} catch (error) {
|
|
1553
|
-
|
|
556
|
+
this.error(`\u52A0\u8F7D Agent ${agentId} \u5931\u8D25: ${error}`);
|
|
557
|
+
return null;
|
|
1554
558
|
}
|
|
1555
559
|
}
|
|
1556
560
|
/**
|
|
1557
|
-
*
|
|
561
|
+
* 列出所有可用的 Agent ID
|
|
562
|
+
*/
|
|
563
|
+
listAgentIds() {
|
|
564
|
+
const agentsDir = this.getResourceDir("agents");
|
|
565
|
+
if (!fs4.existsSync(agentsDir)) {
|
|
566
|
+
return [];
|
|
567
|
+
}
|
|
568
|
+
return fs4.readdirSync(agentsDir).filter((f) => f.endsWith(".agent.md")).map((f) => f.replace(".agent.md", ""));
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* 加载规范文件
|
|
1558
572
|
*/
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
573
|
+
loadStandard(standardPath) {
|
|
574
|
+
const standardsDir = this.getResourceDir("standards");
|
|
575
|
+
const filePath = path4.join(standardsDir, standardPath);
|
|
576
|
+
if (!fs4.existsSync(filePath)) {
|
|
577
|
+
const commonPath = path4.join(this.getResourceDir("common"), standardPath);
|
|
578
|
+
if (fs4.existsSync(commonPath)) {
|
|
579
|
+
return fs4.readFileSync(commonPath, "utf-8");
|
|
580
|
+
}
|
|
581
|
+
this.error(`\u89C4\u8303\u6587\u4EF6\u4E0D\u5B58\u5728: ${standardPath}`);
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
584
|
+
return fs4.readFileSync(filePath, "utf-8");
|
|
1562
585
|
}
|
|
1563
586
|
/**
|
|
1564
|
-
*
|
|
587
|
+
* 列出规范目录下的所有文件
|
|
1565
588
|
*/
|
|
1566
|
-
|
|
1567
|
-
const
|
|
1568
|
-
|
|
589
|
+
listStandards(subDir) {
|
|
590
|
+
const standardsDir = this.getResourceDir("standards");
|
|
591
|
+
const targetDir = subDir ? path4.join(standardsDir, subDir) : standardsDir;
|
|
592
|
+
if (!fs4.existsSync(targetDir)) {
|
|
593
|
+
return [];
|
|
594
|
+
}
|
|
595
|
+
const results = [];
|
|
596
|
+
this.walkDir(targetDir, standardsDir, results);
|
|
597
|
+
return results;
|
|
1569
598
|
}
|
|
1570
599
|
/**
|
|
1571
|
-
*
|
|
600
|
+
* 加载模板
|
|
1572
601
|
*/
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
602
|
+
loadTemplate(templatePath) {
|
|
603
|
+
const templatesDir = this.getResourceDir("templates");
|
|
604
|
+
const filePath = path4.join(templatesDir, templatePath);
|
|
605
|
+
if (!fs4.existsSync(filePath)) {
|
|
606
|
+
this.error(`\u6A21\u677F\u6587\u4EF6\u4E0D\u5B58\u5728: ${templatePath}`);
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
609
|
+
return fs4.readFileSync(filePath, "utf-8");
|
|
1576
610
|
}
|
|
1577
611
|
/**
|
|
1578
|
-
*
|
|
612
|
+
* 列出模板目录
|
|
1579
613
|
*/
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
}
|
|
614
|
+
listTemplates(subDir) {
|
|
615
|
+
const templatesDir = this.getResourceDir("templates");
|
|
616
|
+
const targetDir = subDir ? path4.join(templatesDir, subDir) : templatesDir;
|
|
617
|
+
if (!fs4.existsSync(targetDir)) {
|
|
618
|
+
return [];
|
|
619
|
+
}
|
|
620
|
+
return fs4.readdirSync(targetDir);
|
|
1586
621
|
}
|
|
1587
622
|
/**
|
|
1588
|
-
*
|
|
623
|
+
* 检查资源是否存在
|
|
1589
624
|
*/
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
return ((
|
|
625
|
+
resourceExists(type, relativePath) {
|
|
626
|
+
const baseDir = this.getResourceDir(type);
|
|
627
|
+
return fs4.existsSync(path4.join(baseDir, relativePath));
|
|
1593
628
|
}
|
|
1594
629
|
/**
|
|
1595
|
-
*
|
|
630
|
+
* 获取包版本
|
|
1596
631
|
*/
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
632
|
+
getPackageVersion() {
|
|
633
|
+
try {
|
|
634
|
+
const packageJsonPath = path4.join(this.packageRoot, "package.json");
|
|
635
|
+
if (fs4.existsSync(packageJsonPath)) {
|
|
636
|
+
const packageJson = JSON.parse(fs4.readFileSync(packageJsonPath, "utf-8"));
|
|
637
|
+
return packageJson.version || "unknown";
|
|
638
|
+
}
|
|
639
|
+
} catch {
|
|
640
|
+
}
|
|
641
|
+
return "unknown";
|
|
1600
642
|
}
|
|
1601
643
|
/**
|
|
1602
|
-
*
|
|
644
|
+
* 获取资源统计信息
|
|
1603
645
|
*/
|
|
1604
|
-
|
|
646
|
+
getResourceStats() {
|
|
647
|
+
return {
|
|
648
|
+
agents: this.listAgentIds().length,
|
|
649
|
+
standards: this.listStandards().length,
|
|
650
|
+
templates: this.listTemplates().length,
|
|
651
|
+
version: this.getPackageVersion()
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
walkDir(dir, baseDir, results) {
|
|
655
|
+
const files = fs4.readdirSync(dir);
|
|
656
|
+
for (const file of files) {
|
|
657
|
+
const filePath = path4.join(dir, file);
|
|
658
|
+
const stat = fs4.statSync(filePath);
|
|
659
|
+
if (stat.isDirectory()) {
|
|
660
|
+
this.walkDir(filePath, baseDir, results);
|
|
661
|
+
} else if (file.endsWith(".md")) {
|
|
662
|
+
results.push(path4.relative(baseDir, filePath));
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
log(message) {
|
|
667
|
+
var _a;
|
|
668
|
+
(_a = this.logger) == null ? void 0 : _a.log(message);
|
|
669
|
+
}
|
|
670
|
+
error(message) {
|
|
1605
671
|
var _a;
|
|
1606
|
-
|
|
672
|
+
(_a = this.logger) == null ? void 0 : _a.error(message);
|
|
1607
673
|
}
|
|
1608
674
|
};
|
|
1609
|
-
|
|
675
|
+
resourceLoaderInstance = null;
|
|
1610
676
|
}
|
|
1611
677
|
});
|
|
1612
678
|
|
|
@@ -1914,15 +980,32 @@ var I18nDetector = class {
|
|
|
1914
980
|
}
|
|
1915
981
|
};
|
|
1916
982
|
|
|
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
|
+
|
|
1917
1001
|
// src/tools/analyzeProject.ts
|
|
1918
|
-
init_types();
|
|
1919
1002
|
async function analyzeProject(args) {
|
|
1920
|
-
const
|
|
1003
|
+
const logger4 = new ConsoleLogger();
|
|
1921
1004
|
try {
|
|
1922
1005
|
let projectPath = args.projectPath;
|
|
1923
1006
|
if (!projectPath) {
|
|
1924
1007
|
projectPath = process.cwd();
|
|
1925
|
-
|
|
1008
|
+
logger4.log(`\u{1F4CD} \u672A\u6307\u5B9A\u8DEF\u5F84\uFF0C\u4F7F\u7528\u5F53\u524D\u76EE\u5F55: ${projectPath}`);
|
|
1926
1009
|
}
|
|
1927
1010
|
if (!fs3.existsSync(projectPath)) {
|
|
1928
1011
|
return {
|
|
@@ -1934,14 +1017,14 @@ async function analyzeProject(args) {
|
|
|
1934
1017
|
}]
|
|
1935
1018
|
};
|
|
1936
1019
|
}
|
|
1937
|
-
const matcher = new SmartAgentMatcher(
|
|
1020
|
+
const matcher = new SmartAgentMatcher(logger4);
|
|
1938
1021
|
const workspaceFolder = {
|
|
1939
1022
|
uri: { fsPath: projectPath },
|
|
1940
1023
|
name: path3.basename(projectPath),
|
|
1941
1024
|
index: 0
|
|
1942
1025
|
};
|
|
1943
1026
|
const features = await matcher.analyzeProject(workspaceFolder);
|
|
1944
|
-
|
|
1027
|
+
logger4.log(`\u{1F30D} \u68C0\u6D4B\u56FD\u9645\u5316\u914D\u7F6E...`);
|
|
1945
1028
|
const i18nConfig = await I18nDetector.detect(projectPath);
|
|
1946
1029
|
return {
|
|
1947
1030
|
content: [{
|
|
@@ -1972,7 +1055,7 @@ async function analyzeProject(args) {
|
|
|
1972
1055
|
}]
|
|
1973
1056
|
};
|
|
1974
1057
|
} catch (error) {
|
|
1975
|
-
|
|
1058
|
+
logger4.error(`\u5206\u6790\u9879\u76EE\u5931\u8D25: ${error}`);
|
|
1976
1059
|
return {
|
|
1977
1060
|
content: [{
|
|
1978
1061
|
type: "text",
|
|
@@ -1986,14 +1069,13 @@ async function analyzeProject(args) {
|
|
|
1986
1069
|
|
|
1987
1070
|
// src/tools/matchAgents.ts
|
|
1988
1071
|
init_smartAgentMatcher();
|
|
1989
|
-
init_types();
|
|
1990
1072
|
init_resourceLoader();
|
|
1991
1073
|
async function matchAgents(args) {
|
|
1992
|
-
const
|
|
1074
|
+
const logger4 = new ConsoleLogger();
|
|
1993
1075
|
try {
|
|
1994
|
-
const matcher = new SmartAgentMatcher(
|
|
1995
|
-
const resourceLoader = getResourceLoader(
|
|
1996
|
-
|
|
1076
|
+
const matcher = new SmartAgentMatcher(logger4);
|
|
1077
|
+
const resourceLoader = getResourceLoader(logger4);
|
|
1078
|
+
logger4.log("\u6B63\u5728\u4ECE\u5305\u5185\u52A0\u8F7D Agents...");
|
|
1997
1079
|
const availableAgents = resourceLoader.loadAllAgents();
|
|
1998
1080
|
const matchedAgents = matcher.matchAgents(args.projectFeatures, availableAgents);
|
|
1999
1081
|
const limit = args.limit || 10;
|
|
@@ -2018,7 +1100,7 @@ async function matchAgents(args) {
|
|
|
2018
1100
|
}]
|
|
2019
1101
|
};
|
|
2020
1102
|
} catch (error) {
|
|
2021
|
-
|
|
1103
|
+
logger4.error(`\u5339\u914D Agents \u5931\u8D25: ${error}`);
|
|
2022
1104
|
return {
|
|
2023
1105
|
content: [{
|
|
2024
1106
|
type: "text",
|
|
@@ -2105,8 +1187,8 @@ import { fileURLToPath as fileURLToPath4 } from "url";
|
|
|
2105
1187
|
// src/core/githubClient.ts
|
|
2106
1188
|
import axios from "axios";
|
|
2107
1189
|
var GitHubClient = class {
|
|
2108
|
-
constructor(
|
|
2109
|
-
this.logger =
|
|
1190
|
+
constructor(logger4) {
|
|
1191
|
+
this.logger = logger4;
|
|
2110
1192
|
this.owner = "ForLear";
|
|
2111
1193
|
this.repo = "copilot-prompts";
|
|
2112
1194
|
this.branch = "main";
|
|
@@ -2161,13 +1243,11 @@ var GitHubClient = class {
|
|
|
2161
1243
|
|
|
2162
1244
|
// src/tools/generateConfig.ts
|
|
2163
1245
|
init_smartAgentMatcher();
|
|
2164
|
-
init_types();
|
|
2165
1246
|
|
|
2166
1247
|
// src/core/codeValidator.ts
|
|
2167
|
-
init_types();
|
|
2168
1248
|
var CodeValidator = class {
|
|
2169
|
-
constructor(
|
|
2170
|
-
this.logger =
|
|
1249
|
+
constructor(logger4) {
|
|
1250
|
+
this.logger = logger4 || new ConsoleLogger();
|
|
2171
1251
|
}
|
|
2172
1252
|
/**
|
|
2173
1253
|
* 验证生成的配置文件内容
|
|
@@ -2578,7 +1658,7 @@ ${variables.AGENTS_LIST}
|
|
|
2578
1658
|
var __filename4 = fileURLToPath4(import.meta.url);
|
|
2579
1659
|
var __dirname4 = path7.dirname(__filename4);
|
|
2580
1660
|
async function generateConfig(args) {
|
|
2581
|
-
const
|
|
1661
|
+
const logger4 = new ConsoleLogger();
|
|
2582
1662
|
try {
|
|
2583
1663
|
if (!fs7.existsSync(args.projectPath)) {
|
|
2584
1664
|
return {
|
|
@@ -2590,39 +1670,39 @@ async function generateConfig(args) {
|
|
|
2590
1670
|
}]
|
|
2591
1671
|
};
|
|
2592
1672
|
}
|
|
2593
|
-
const matcher = new SmartAgentMatcher(
|
|
2594
|
-
const githubClient = new GitHubClient(
|
|
1673
|
+
const matcher = new SmartAgentMatcher(logger4);
|
|
1674
|
+
const githubClient = new GitHubClient(logger4);
|
|
2595
1675
|
let selectedAgents = [];
|
|
2596
1676
|
if (args.autoMatch !== false) {
|
|
2597
|
-
|
|
1677
|
+
logger4.log("\u6B63\u5728\u5206\u6790\u9879\u76EE\u7279\u5F81...");
|
|
2598
1678
|
const workspaceFolder = {
|
|
2599
1679
|
uri: { fsPath: args.projectPath },
|
|
2600
1680
|
name: path7.basename(args.projectPath),
|
|
2601
1681
|
index: 0
|
|
2602
1682
|
};
|
|
2603
1683
|
const features = await matcher.analyzeProject(workspaceFolder);
|
|
2604
|
-
|
|
2605
|
-
const resourceLoader = getResourceLoader(
|
|
1684
|
+
logger4.log("\u6B63\u5728\u5339\u914D Agents...");
|
|
1685
|
+
const resourceLoader = getResourceLoader(logger4);
|
|
2606
1686
|
const availableAgents = resourceLoader.loadAllAgents();
|
|
2607
1687
|
if (availableAgents.length === 0) {
|
|
2608
1688
|
throw new Error("\u65E0\u6CD5\u52A0\u8F7D Agents\uFF0C\u8BF7\u68C0\u67E5 npm \u5305\u662F\u5426\u5B8C\u6574");
|
|
2609
1689
|
}
|
|
2610
|
-
|
|
1690
|
+
logger4.log(`\u6210\u529F\u52A0\u8F7D ${availableAgents.length} \u4E2A Agents`);
|
|
2611
1691
|
selectedAgents = matcher.matchAgents(features, availableAgents);
|
|
2612
|
-
|
|
1692
|
+
logger4.log(`\u5339\u914D\u5230 ${selectedAgents.length} \u4E2A Agents`);
|
|
2613
1693
|
selectedAgents = selectedAgents.slice(0, 5);
|
|
2614
1694
|
}
|
|
2615
1695
|
if (args.agentIds && args.agentIds.length > 0) {
|
|
2616
|
-
|
|
1696
|
+
logger4.log(`\u4F7F\u7528\u6307\u5B9A\u7684 Agents: ${args.agentIds.join(", ")}`);
|
|
2617
1697
|
selectedAgents = [];
|
|
2618
|
-
const resourceLoader = getResourceLoader(
|
|
1698
|
+
const resourceLoader = getResourceLoader(logger4);
|
|
2619
1699
|
for (const id of args.agentIds) {
|
|
2620
1700
|
const agentData = resourceLoader.loadAgent(id);
|
|
2621
1701
|
if (agentData) {
|
|
2622
1702
|
selectedAgents.push(agentData.metadata);
|
|
2623
|
-
|
|
1703
|
+
logger4.log(`\u2705 \u52A0\u8F7D Agent: ${id}`);
|
|
2624
1704
|
} else {
|
|
2625
|
-
|
|
1705
|
+
logger4.error(`Agent ${id} \u4E0D\u5B58\u5728`);
|
|
2626
1706
|
}
|
|
2627
1707
|
}
|
|
2628
1708
|
}
|
|
@@ -2636,7 +1716,7 @@ async function generateConfig(args) {
|
|
|
2636
1716
|
}]
|
|
2637
1717
|
};
|
|
2638
1718
|
}
|
|
2639
|
-
|
|
1719
|
+
logger4.log("\u6B63\u5728\u751F\u6210\u914D\u7F6E\u6587\u4EF6...");
|
|
2640
1720
|
const githubDir = path7.join(args.projectPath, ".github");
|
|
2641
1721
|
const configPath = path7.join(githubDir, "copilot-instructions.md");
|
|
2642
1722
|
let existingCustomContent = "";
|
|
@@ -2666,23 +1746,23 @@ async function generateConfig(args) {
|
|
|
2666
1746
|
})),
|
|
2667
1747
|
existingCustomContent: updateMode === "merge" ? existingCustomContent : void 0
|
|
2668
1748
|
});
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
const validator = new CodeValidator(
|
|
1749
|
+
logger4.log(`\u2705 \u4F7F\u7528\u6A21\u677F\u751F\u6210\u914D\u7F6E\uFF08\u7CBE\u7B80\u6A21\u5F0F\uFF09`);
|
|
1750
|
+
logger4.log(` \u6A21\u677F\u76EE\u5F55: ${templateLoader.getTemplatesPath()}`);
|
|
1751
|
+
logger4.log(` \u6A21\u677F\u53EF\u7528: ${templateLoader.isTemplateDirectoryAvailable()}`);
|
|
1752
|
+
const validator = new CodeValidator(logger4);
|
|
2673
1753
|
const validation = validator.validateConfigContent(content);
|
|
2674
1754
|
if (!validation.isValid) {
|
|
2675
|
-
|
|
1755
|
+
logger4.error("\u26A0\uFE0F \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u5931\u8D25\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D...");
|
|
2676
1756
|
const fixResult = validator.attemptAutoFix(content);
|
|
2677
1757
|
if (fixResult.fixed) {
|
|
2678
1758
|
content = fixResult.content;
|
|
2679
|
-
|
|
2680
|
-
fixResult.changes.forEach((change) =>
|
|
1759
|
+
logger4.log(`\u2705 \u5DF2\u81EA\u52A8\u4FEE\u590D ${fixResult.changes.length} \u4E2A\u95EE\u9898:`);
|
|
1760
|
+
fixResult.changes.forEach((change) => logger4.log(` - ${change}`));
|
|
2681
1761
|
const revalidation = validator.validateConfigContent(content);
|
|
2682
1762
|
if (!revalidation.isValid) {
|
|
2683
1763
|
const report = validator.generateValidationReport(revalidation);
|
|
2684
|
-
|
|
2685
|
-
|
|
1764
|
+
logger4.error("\u274C \u81EA\u52A8\u4FEE\u590D\u540E\u4ECD\u5B58\u5728\u95EE\u9898:");
|
|
1765
|
+
logger4.error(report);
|
|
2686
1766
|
return {
|
|
2687
1767
|
content: [{
|
|
2688
1768
|
type: "text",
|
|
@@ -2696,7 +1776,7 @@ async function generateConfig(args) {
|
|
|
2696
1776
|
}
|
|
2697
1777
|
} else {
|
|
2698
1778
|
const report = validator.generateValidationReport(validation);
|
|
2699
|
-
|
|
1779
|
+
logger4.error(report);
|
|
2700
1780
|
return {
|
|
2701
1781
|
content: [{
|
|
2702
1782
|
type: "text",
|
|
@@ -2709,12 +1789,12 @@ async function generateConfig(args) {
|
|
|
2709
1789
|
};
|
|
2710
1790
|
}
|
|
2711
1791
|
} else if (validation.warnings.length > 0) {
|
|
2712
|
-
|
|
1792
|
+
logger4.log("\u26A0\uFE0F \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u901A\u8FC7\uFF0C\u4F46\u6709\u4EE5\u4E0B\u8B66\u544A:");
|
|
2713
1793
|
validation.warnings.forEach((warning) => {
|
|
2714
|
-
|
|
1794
|
+
logger4.log(` - [${warning.type}] ${warning.message}`);
|
|
2715
1795
|
});
|
|
2716
1796
|
} else {
|
|
2717
|
-
|
|
1797
|
+
logger4.log("\u2705 \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u901A\u8FC7");
|
|
2718
1798
|
}
|
|
2719
1799
|
fs7.writeFileSync(configPath, content, "utf-8");
|
|
2720
1800
|
const gitignorePath = path7.join(args.projectPath, ".gitignore");
|
|
@@ -2725,7 +1805,7 @@ async function generateConfig(args) {
|
|
|
2725
1805
|
fs7.writeFileSync(gitignorePath, gitignoreContent, "utf-8");
|
|
2726
1806
|
}
|
|
2727
1807
|
}
|
|
2728
|
-
|
|
1808
|
+
logger4.log(`\u2705 \u914D\u7F6E\u6587\u4EF6\u5DF2\u751F\u6210: ${configPath}`);
|
|
2729
1809
|
return {
|
|
2730
1810
|
content: [{
|
|
2731
1811
|
type: "text",
|
|
@@ -2742,7 +1822,7 @@ async function generateConfig(args) {
|
|
|
2742
1822
|
}]
|
|
2743
1823
|
};
|
|
2744
1824
|
} catch (error) {
|
|
2745
|
-
|
|
1825
|
+
logger4.error(`\u751F\u6210\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
2746
1826
|
return {
|
|
2747
1827
|
content: [{
|
|
2748
1828
|
type: "text",
|
|
@@ -2755,12 +1835,11 @@ async function generateConfig(args) {
|
|
|
2755
1835
|
}
|
|
2756
1836
|
|
|
2757
1837
|
// src/tools/autoSetup.ts
|
|
2758
|
-
init_types();
|
|
2759
1838
|
import * as fs8 from "fs";
|
|
2760
1839
|
import * as path8 from "path";
|
|
2761
1840
|
async function autoSetup(args) {
|
|
2762
1841
|
var _a;
|
|
2763
|
-
const
|
|
1842
|
+
const logger4 = new ConsoleLogger();
|
|
2764
1843
|
try {
|
|
2765
1844
|
const workspacePath = args.workspacePath || process.cwd();
|
|
2766
1845
|
if (!fs8.existsSync(workspacePath)) {
|
|
@@ -2778,7 +1857,7 @@ async function autoSetup(args) {
|
|
|
2778
1857
|
steps: [],
|
|
2779
1858
|
warnings: []
|
|
2780
1859
|
};
|
|
2781
|
-
|
|
1860
|
+
logger4.log("\u{1F680} \u5F00\u59CB\u4E3A\u9879\u76EE\u751F\u6210 copilot-instructions.md...");
|
|
2782
1861
|
const generateInstructions = args.generateInstructions !== false;
|
|
2783
1862
|
const instructionsPath = path8.join(workspacePath, ".github", "copilot-instructions.md");
|
|
2784
1863
|
const hasExistingInstructions = fs8.existsSync(instructionsPath);
|
|
@@ -2790,7 +1869,7 @@ async function autoSetup(args) {
|
|
|
2790
1869
|
detail: "\u4FDD\u7559\u73B0\u6709\u914D\u7F6E\uFF0C\u4E0D\u81EA\u52A8\u8986\u76D6"
|
|
2791
1870
|
});
|
|
2792
1871
|
} else {
|
|
2793
|
-
|
|
1872
|
+
logger4.log("\u{1F50D} \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\u6587\u4EF6\uFF0C\u5F00\u59CB\u5206\u6790\u9879\u76EE...");
|
|
2794
1873
|
try {
|
|
2795
1874
|
const configResult = await generateConfig({
|
|
2796
1875
|
projectPath: workspacePath,
|
|
@@ -2823,7 +1902,7 @@ async function autoSetup(args) {
|
|
|
2823
1902
|
} else {
|
|
2824
1903
|
results.steps.push({ step: "\u8DF3\u8FC7 copilot-instructions.md \u751F\u6210", status: "skip" });
|
|
2825
1904
|
}
|
|
2826
|
-
|
|
1905
|
+
logger4.log("\u2705 \u914D\u7F6E\u5B8C\u6210\uFF01");
|
|
2827
1906
|
return {
|
|
2828
1907
|
content: [{
|
|
2829
1908
|
type: "text",
|
|
@@ -2841,7 +1920,7 @@ async function autoSetup(args) {
|
|
|
2841
1920
|
}]
|
|
2842
1921
|
};
|
|
2843
1922
|
} catch (error) {
|
|
2844
|
-
|
|
1923
|
+
logger4.error(`\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
2845
1924
|
return {
|
|
2846
1925
|
content: [{
|
|
2847
1926
|
type: "text",
|
|
@@ -2854,16 +1933,15 @@ async function autoSetup(args) {
|
|
|
2854
1933
|
}
|
|
2855
1934
|
|
|
2856
1935
|
// src/tools/initProject.ts
|
|
2857
|
-
init_types();
|
|
2858
1936
|
import * as fs9 from "fs";
|
|
2859
1937
|
async function initProject(args) {
|
|
2860
1938
|
var _a;
|
|
2861
|
-
const
|
|
1939
|
+
const logger4 = new ConsoleLogger();
|
|
2862
1940
|
try {
|
|
2863
1941
|
let projectPath = args.projectPath;
|
|
2864
1942
|
if (!projectPath) {
|
|
2865
1943
|
projectPath = process.cwd();
|
|
2866
|
-
|
|
1944
|
+
logger4.log(`\u{1F4A1} \u672A\u6307\u5B9A\u9879\u76EE\u8DEF\u5F84\uFF0C\u4F7F\u7528\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55: ${projectPath}`);
|
|
2867
1945
|
}
|
|
2868
1946
|
if (!fs9.existsSync(projectPath)) {
|
|
2869
1947
|
return {
|
|
@@ -2876,7 +1954,7 @@ async function initProject(args) {
|
|
|
2876
1954
|
}]
|
|
2877
1955
|
};
|
|
2878
1956
|
}
|
|
2879
|
-
|
|
1957
|
+
logger4.log(`\u{1F680} \u5F00\u59CB\u521D\u59CB\u5316\u9879\u76EE: ${projectPath}`);
|
|
2880
1958
|
const result = await generateConfig({
|
|
2881
1959
|
projectPath,
|
|
2882
1960
|
autoMatch: true,
|
|
@@ -2915,7 +1993,7 @@ async function initProject(args) {
|
|
|
2915
1993
|
};
|
|
2916
1994
|
}
|
|
2917
1995
|
} catch (error) {
|
|
2918
|
-
|
|
1996
|
+
logger4.error(`\u521D\u59CB\u5316\u5931\u8D25: ${error}`);
|
|
2919
1997
|
return {
|
|
2920
1998
|
content: [{
|
|
2921
1999
|
type: "text",
|
|
@@ -3420,7 +2498,6 @@ ${content}
|
|
|
3420
2498
|
};
|
|
3421
2499
|
|
|
3422
2500
|
// src/tools/usePreset.ts
|
|
3423
|
-
init_types();
|
|
3424
2501
|
var PRESETS = {
|
|
3425
2502
|
"vue3-component": {
|
|
3426
2503
|
name: "Vue 3 \u7EC4\u4EF6\u5F00\u53D1",
|
|
@@ -3480,7 +2557,7 @@ var PRESETS = {
|
|
|
3480
2557
|
}
|
|
3481
2558
|
};
|
|
3482
2559
|
async function usePreset(args) {
|
|
3483
|
-
const
|
|
2560
|
+
const logger4 = new ConsoleLogger();
|
|
3484
2561
|
const manager = new StandardsManager();
|
|
3485
2562
|
try {
|
|
3486
2563
|
if (!(args.preset in PRESETS)) {
|
|
@@ -3499,7 +2576,7 @@ async function usePreset(args) {
|
|
|
3499
2576
|
};
|
|
3500
2577
|
}
|
|
3501
2578
|
const preset = PRESETS[args.preset];
|
|
3502
|
-
|
|
2579
|
+
logger4.log(`\u{1F3AF} \u4F7F\u7528\u9884\u8BBE: ${preset.name}`);
|
|
3503
2580
|
const imports = args.customImports ? [...preset.imports, ...args.customImports] : [...preset.imports];
|
|
3504
2581
|
const standards = manager.getRelevantStandards({
|
|
3505
2582
|
fileType: preset.fileType,
|
|
@@ -3533,7 +2610,7 @@ async function usePreset(args) {
|
|
|
3533
2610
|
}]
|
|
3534
2611
|
};
|
|
3535
2612
|
} catch (error) {
|
|
3536
|
-
|
|
2613
|
+
logger4.error(`\u4F7F\u7528\u9884\u8BBE\u5931\u8D25: ${error}`);
|
|
3537
2614
|
return {
|
|
3538
2615
|
content: [{
|
|
3539
2616
|
type: "text",
|
|
@@ -3567,7 +2644,6 @@ async function listPresets() {
|
|
|
3567
2644
|
}
|
|
3568
2645
|
|
|
3569
2646
|
// src/tools/healthCheck.ts
|
|
3570
|
-
init_types();
|
|
3571
2647
|
import * as fs11 from "fs";
|
|
3572
2648
|
import * as path10 from "path";
|
|
3573
2649
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
@@ -3592,7 +2668,7 @@ function getServerRoot() {
|
|
|
3592
2668
|
}
|
|
3593
2669
|
async function healthCheck(args) {
|
|
3594
2670
|
var _a, _b, _c, _d;
|
|
3595
|
-
const
|
|
2671
|
+
const logger4 = new ConsoleLogger();
|
|
3596
2672
|
const verbose = args.verbose ?? false;
|
|
3597
2673
|
try {
|
|
3598
2674
|
const checks = {
|
|
@@ -3602,7 +2678,7 @@ async function healthCheck(args) {
|
|
|
3602
2678
|
standards: { status: "unknown", details: [] },
|
|
3603
2679
|
workspace: { status: "unknown", details: [] }
|
|
3604
2680
|
};
|
|
3605
|
-
|
|
2681
|
+
logger4.log("\u{1F50D} \u68C0\u67E5\u670D\u52A1\u5668\u72B6\u6001...");
|
|
3606
2682
|
try {
|
|
3607
2683
|
checks.server.status = "healthy";
|
|
3608
2684
|
checks.server.details.push("\u2705 MCP \u670D\u52A1\u5668\u6B63\u5728\u8FD0\u884C");
|
|
@@ -3612,7 +2688,7 @@ async function healthCheck(args) {
|
|
|
3612
2688
|
checks.server.status = "error";
|
|
3613
2689
|
checks.server.details.push("\u274C \u670D\u52A1\u5668\u672A\u54CD\u5E94");
|
|
3614
2690
|
}
|
|
3615
|
-
|
|
2691
|
+
logger4.log("\u{1F50D} \u68C0\u67E5\u914D\u7F6E\u6587\u4EF6...");
|
|
3616
2692
|
const workspacePath = args.workspacePath || process.cwd();
|
|
3617
2693
|
const vscodeDir = path10.join(workspacePath, ".vscode");
|
|
3618
2694
|
if (fs11.existsSync(vscodeDir)) {
|
|
@@ -3682,7 +2758,7 @@ async function healthCheck(args) {
|
|
|
3682
2758
|
checks.workspace.details.push("\u274C .vscode \u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
3683
2759
|
checks.workspace.details.push("\u{1F4A1} \u5EFA\u8BAE: \u8FD0\u884C auto_setup \u5DE5\u5177\u81EA\u52A8\u521B\u5EFA\u914D\u7F6E");
|
|
3684
2760
|
}
|
|
3685
|
-
|
|
2761
|
+
logger4.log("\u{1F50D} \u68C0\u67E5\u4F9D\u8D56...");
|
|
3686
2762
|
const serverRoot = getServerRoot();
|
|
3687
2763
|
const packageJsonPath = path10.join(serverRoot, "package.json");
|
|
3688
2764
|
if (fs11.existsSync(packageJsonPath)) {
|
|
@@ -3710,7 +2786,7 @@ async function healthCheck(args) {
|
|
|
3710
2786
|
checks.dependencies.details.push("\u274C \u65E0\u6CD5\u8BFB\u53D6 package.json");
|
|
3711
2787
|
}
|
|
3712
2788
|
}
|
|
3713
|
-
|
|
2789
|
+
logger4.log("\u{1F50D} \u68C0\u67E5\u89C4\u8303\u6587\u4EF6...");
|
|
3714
2790
|
const standardsDir = path10.join(serverRoot, "standards");
|
|
3715
2791
|
if (fs11.existsSync(standardsDir)) {
|
|
3716
2792
|
const categories = ["core", "frameworks", "libraries", "patterns"];
|
|
@@ -3749,7 +2825,7 @@ async function healthCheck(args) {
|
|
|
3749
2825
|
error: "\u274C",
|
|
3750
2826
|
unknown: "\u2753"
|
|
3751
2827
|
};
|
|
3752
|
-
|
|
2828
|
+
logger4.log(`${statusEmoji[overallStatus]} \u5065\u5EB7\u68C0\u67E5\u5B8C\u6210`);
|
|
3753
2829
|
return {
|
|
3754
2830
|
content: [{
|
|
3755
2831
|
type: "text",
|
|
@@ -3763,7 +2839,7 @@ async function healthCheck(args) {
|
|
|
3763
2839
|
}]
|
|
3764
2840
|
};
|
|
3765
2841
|
} catch (error) {
|
|
3766
|
-
|
|
2842
|
+
logger4.error(`\u5065\u5EB7\u68C0\u67E5\u5931\u8D25: ${error}`);
|
|
3767
2843
|
return {
|
|
3768
2844
|
content: [{
|
|
3769
2845
|
type: "text",
|
|
@@ -3797,16 +2873,15 @@ function generateRecommendations(checks) {
|
|
|
3797
2873
|
// src/tools/getCompactStandards.ts
|
|
3798
2874
|
import * as fs12 from "fs";
|
|
3799
2875
|
import * as path11 from "path";
|
|
3800
|
-
init_types();
|
|
3801
2876
|
init_smartAgentMatcher();
|
|
3802
2877
|
async function getCompactStandards(args) {
|
|
3803
|
-
const
|
|
2878
|
+
const logger4 = new ConsoleLogger();
|
|
3804
2879
|
const manager = new StandardsManager();
|
|
3805
2880
|
const mode = args.mode || "key-rules";
|
|
3806
2881
|
try {
|
|
3807
|
-
let context = detectContext(args,
|
|
2882
|
+
let context = detectContext(args, logger4);
|
|
3808
2883
|
if (args.projectPath && fs12.existsSync(args.projectPath)) {
|
|
3809
|
-
const projectContext = await analyzeProject2(args.projectPath,
|
|
2884
|
+
const projectContext = await analyzeProject2(args.projectPath, logger4);
|
|
3810
2885
|
context = mergeContexts(context, projectContext);
|
|
3811
2886
|
}
|
|
3812
2887
|
const standardUris = manager.getRelevantStandards({
|
|
@@ -3840,7 +2915,7 @@ async function getCompactStandards(args) {
|
|
|
3840
2915
|
}]
|
|
3841
2916
|
};
|
|
3842
2917
|
} catch (error) {
|
|
3843
|
-
|
|
2918
|
+
logger4.error(`\u89C4\u8303\u83B7\u53D6\u5931\u8D25: ${error}`);
|
|
3844
2919
|
return {
|
|
3845
2920
|
content: [{
|
|
3846
2921
|
type: "text",
|
|
@@ -3851,7 +2926,7 @@ async function getCompactStandards(args) {
|
|
|
3851
2926
|
};
|
|
3852
2927
|
}
|
|
3853
2928
|
}
|
|
3854
|
-
async function analyzeProject2(projectPath,
|
|
2929
|
+
async function analyzeProject2(projectPath, logger4) {
|
|
3855
2930
|
var _a, _b;
|
|
3856
2931
|
const result = {
|
|
3857
2932
|
fileType: "unknown",
|
|
@@ -3865,13 +2940,13 @@ async function analyzeProject2(projectPath, logger9) {
|
|
|
3865
2940
|
const agents = extractUserAgents(content);
|
|
3866
2941
|
if (agents.length > 0) {
|
|
3867
2942
|
result.userConfiguredAgents = agents;
|
|
3868
|
-
|
|
2943
|
+
logger4.log(`\u2705 \u68C0\u6D4B\u5230\u7528\u6237\u914D\u7F6E\u7684 Agents: ${agents.join(", ")}`);
|
|
3869
2944
|
}
|
|
3870
2945
|
} catch (error) {
|
|
3871
|
-
|
|
2946
|
+
logger4.error(`\u8BFB\u53D6\u7528\u6237\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
3872
2947
|
}
|
|
3873
2948
|
}
|
|
3874
|
-
const matcher = new SmartAgentMatcher(
|
|
2949
|
+
const matcher = new SmartAgentMatcher(logger4);
|
|
3875
2950
|
const workspaceFolder = {
|
|
3876
2951
|
uri: { fsPath: projectPath },
|
|
3877
2952
|
name: path11.basename(projectPath),
|
|
@@ -3890,9 +2965,9 @@ async function analyzeProject2(projectPath, logger9) {
|
|
|
3890
2965
|
if (features.libraries) {
|
|
3891
2966
|
result.imports.push(...features.libraries);
|
|
3892
2967
|
}
|
|
3893
|
-
|
|
2968
|
+
logger4.log(`\u{1F50D} \u9879\u76EE\u6280\u672F\u6808: ${result.imports.join(", ")}`);
|
|
3894
2969
|
} catch (error) {
|
|
3895
|
-
|
|
2970
|
+
logger4.error(`\u9879\u76EE\u5206\u6790\u5931\u8D25: ${error}`);
|
|
3896
2971
|
}
|
|
3897
2972
|
return result;
|
|
3898
2973
|
}
|
|
@@ -3913,7 +2988,7 @@ function mergeContexts(fileContext, projectContext) {
|
|
|
3913
2988
|
userConfiguredAgents: projectContext.userConfiguredAgents
|
|
3914
2989
|
};
|
|
3915
2990
|
}
|
|
3916
|
-
function detectContext(args,
|
|
2991
|
+
function detectContext(args, logger4) {
|
|
3917
2992
|
var _a;
|
|
3918
2993
|
let fileType = "unknown";
|
|
3919
2994
|
let imports = [];
|
|
@@ -4247,7 +3322,6 @@ function inferScenario(content, fileType) {
|
|
|
4247
3322
|
}
|
|
4248
3323
|
|
|
4249
3324
|
// src/tools/getStandardById.ts
|
|
4250
|
-
init_types();
|
|
4251
3325
|
import * as fs13 from "fs";
|
|
4252
3326
|
import * as path12 from "path";
|
|
4253
3327
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
@@ -4262,7 +3336,7 @@ var STANDARD_DIRS = [
|
|
|
4262
3336
|
];
|
|
4263
3337
|
var standardsCache = null;
|
|
4264
3338
|
async function getStandardById(args) {
|
|
4265
|
-
const
|
|
3339
|
+
const logger4 = new ConsoleLogger();
|
|
4266
3340
|
const mode = args.mode || "key-rules";
|
|
4267
3341
|
try {
|
|
4268
3342
|
const idsToLoad = args.ids || (args.id ? [args.id] : []);
|
|
@@ -4327,7 +3401,7 @@ async function getStandardById(args) {
|
|
|
4327
3401
|
}]
|
|
4328
3402
|
};
|
|
4329
3403
|
} catch (error) {
|
|
4330
|
-
|
|
3404
|
+
logger4.error(`\u83B7\u53D6\u89C4\u8303\u5931\u8D25: ${error}`);
|
|
4331
3405
|
return {
|
|
4332
3406
|
content: [{
|
|
4333
3407
|
type: "text",
|
|
@@ -4548,9 +3622,8 @@ function suggestStandards(options) {
|
|
|
4548
3622
|
}
|
|
4549
3623
|
|
|
4550
3624
|
// src/tools/queryMappings.ts
|
|
4551
|
-
init_types();
|
|
4552
3625
|
async function queryMappings(args) {
|
|
4553
|
-
const
|
|
3626
|
+
const logger4 = new ConsoleLogger();
|
|
4554
3627
|
try {
|
|
4555
3628
|
if (args.listAll) {
|
|
4556
3629
|
return {
|
|
@@ -4603,7 +3676,7 @@ async function queryMappings(args) {
|
|
|
4603
3676
|
}]
|
|
4604
3677
|
};
|
|
4605
3678
|
} catch (error) {
|
|
4606
|
-
|
|
3679
|
+
logger4.error(`\u67E5\u8BE2\u6620\u5C04\u5931\u8D25: ${error}`);
|
|
4607
3680
|
return {
|
|
4608
3681
|
content: [{
|
|
4609
3682
|
type: "text",
|
|
@@ -4800,9 +3873,8 @@ function searchTemplates(query) {
|
|
|
4800
3873
|
}
|
|
4801
3874
|
|
|
4802
3875
|
// src/tools/listTemplates.ts
|
|
4803
|
-
init_types();
|
|
4804
3876
|
async function listTemplates(args) {
|
|
4805
|
-
const
|
|
3877
|
+
const logger4 = new ConsoleLogger();
|
|
4806
3878
|
try {
|
|
4807
3879
|
let templates;
|
|
4808
3880
|
if (args.search) {
|
|
@@ -4836,7 +3908,7 @@ async function listTemplates(args) {
|
|
|
4836
3908
|
}]
|
|
4837
3909
|
};
|
|
4838
3910
|
} catch (error) {
|
|
4839
|
-
|
|
3911
|
+
logger4.error(`\u5217\u51FA\u6A21\u677F\u5931\u8D25: ${error}`);
|
|
4840
3912
|
return {
|
|
4841
3913
|
content: [{
|
|
4842
3914
|
type: "text",
|
|
@@ -4849,9 +3921,8 @@ async function listTemplates(args) {
|
|
|
4849
3921
|
}
|
|
4850
3922
|
|
|
4851
3923
|
// src/tools/getTemplate.ts
|
|
4852
|
-
init_types();
|
|
4853
3924
|
async function getTemplate(args) {
|
|
4854
|
-
const
|
|
3925
|
+
const logger4 = new ConsoleLogger();
|
|
4855
3926
|
try {
|
|
4856
3927
|
const result = getTemplateById(args.id, args.includeFiles ?? false);
|
|
4857
3928
|
if (!result) {
|
|
@@ -4892,7 +3963,7 @@ async function getTemplate(args) {
|
|
|
4892
3963
|
}]
|
|
4893
3964
|
};
|
|
4894
3965
|
} catch (error) {
|
|
4895
|
-
|
|
3966
|
+
logger4.error(`\u83B7\u53D6\u6A21\u677F\u5931\u8D25: ${error}`);
|
|
4896
3967
|
return {
|
|
4897
3968
|
content: [{
|
|
4898
3969
|
type: "text",
|
|
@@ -4905,18 +3976,16 @@ async function getTemplate(args) {
|
|
|
4905
3976
|
}
|
|
4906
3977
|
|
|
4907
3978
|
// src/tools/cloneProject.ts
|
|
4908
|
-
init_types();
|
|
4909
3979
|
import * as fs16 from "fs";
|
|
4910
3980
|
import * as path15 from "path";
|
|
4911
3981
|
|
|
4912
3982
|
// src/core/projectCloneAnalyzer.ts
|
|
4913
|
-
init_types();
|
|
4914
3983
|
import * as fs15 from "fs";
|
|
4915
3984
|
import * as path14 from "path";
|
|
4916
3985
|
import glob3 from "fast-glob";
|
|
4917
3986
|
var ProjectCloneAnalyzer = class {
|
|
4918
|
-
constructor(
|
|
4919
|
-
this.logger =
|
|
3987
|
+
constructor(logger4) {
|
|
3988
|
+
this.logger = logger4 || new ConsoleLogger();
|
|
4920
3989
|
}
|
|
4921
3990
|
/**
|
|
4922
3991
|
* 深度分析项目
|
|
@@ -5692,7 +4761,7 @@ var ProjectCloneAnalyzer = class {
|
|
|
5692
4761
|
|
|
5693
4762
|
// src/tools/cloneProject.ts
|
|
5694
4763
|
async function analyzeReferenceProject(args) {
|
|
5695
|
-
const
|
|
4764
|
+
const logger4 = new ConsoleLogger();
|
|
5696
4765
|
try {
|
|
5697
4766
|
if (!args.projectPath) {
|
|
5698
4767
|
return {
|
|
@@ -5715,8 +4784,8 @@ async function analyzeReferenceProject(args) {
|
|
|
5715
4784
|
}]
|
|
5716
4785
|
};
|
|
5717
4786
|
}
|
|
5718
|
-
|
|
5719
|
-
const analyzer = new ProjectCloneAnalyzer(
|
|
4787
|
+
logger4.log(`\u{1F50D} \u5F00\u59CB\u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE: ${args.projectPath}`);
|
|
4788
|
+
const analyzer = new ProjectCloneAnalyzer(logger4);
|
|
5720
4789
|
const analysis = await analyzer.analyzeProject(args.projectPath);
|
|
5721
4790
|
let developmentPlan = null;
|
|
5722
4791
|
if (args.newProjectName) {
|
|
@@ -5724,7 +4793,7 @@ async function analyzeReferenceProject(args) {
|
|
|
5724
4793
|
}
|
|
5725
4794
|
if (args.generateDocs && args.newProjectPath) {
|
|
5726
4795
|
await generateAnalysisDocs(args.newProjectPath, analysis, developmentPlan);
|
|
5727
|
-
|
|
4796
|
+
logger4.log(`\u{1F4C4} \u5DF2\u751F\u6210\u5206\u6790\u6587\u6863\u5230: ${args.newProjectPath}/docs/`);
|
|
5728
4797
|
}
|
|
5729
4798
|
const response = {
|
|
5730
4799
|
success: true,
|
|
@@ -5794,7 +4863,7 @@ async function analyzeReferenceProject(args) {
|
|
|
5794
4863
|
}]
|
|
5795
4864
|
};
|
|
5796
4865
|
} catch (error) {
|
|
5797
|
-
|
|
4866
|
+
logger4.error(`\u5206\u6790\u5931\u8D25: ${error}`);
|
|
5798
4867
|
return {
|
|
5799
4868
|
content: [{
|
|
5800
4869
|
type: "text",
|
|
@@ -5807,7 +4876,7 @@ async function analyzeReferenceProject(args) {
|
|
|
5807
4876
|
}
|
|
5808
4877
|
}
|
|
5809
4878
|
async function generateProjectSkeleton(args) {
|
|
5810
|
-
const
|
|
4879
|
+
const logger4 = new ConsoleLogger();
|
|
5811
4880
|
try {
|
|
5812
4881
|
if (!args.referenceProjectPath || !args.newProjectPath || !args.newProjectName) {
|
|
5813
4882
|
return {
|
|
@@ -5830,10 +4899,10 @@ async function generateProjectSkeleton(args) {
|
|
|
5830
4899
|
}]
|
|
5831
4900
|
};
|
|
5832
4901
|
}
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
const analyzer = new ProjectCloneAnalyzer(
|
|
4902
|
+
logger4.log(`\u{1F3D7}\uFE0F \u5F00\u59CB\u751F\u6210\u9879\u76EE\u9AA8\u67B6...`);
|
|
4903
|
+
logger4.log(`\u{1F4E6} \u53C2\u8003\u9879\u76EE: ${args.referenceProjectPath}`);
|
|
4904
|
+
logger4.log(`\u{1F4C1} \u65B0\u9879\u76EE: ${args.newProjectPath}`);
|
|
4905
|
+
const analyzer = new ProjectCloneAnalyzer(logger4);
|
|
5837
4906
|
const analysis = await analyzer.analyzeProject(args.referenceProjectPath);
|
|
5838
4907
|
const developmentPlan = analyzer.generateDevelopmentPlan(analysis, args.newProjectName);
|
|
5839
4908
|
if (!fs16.existsSync(args.newProjectPath)) {
|
|
@@ -5841,7 +4910,7 @@ async function generateProjectSkeleton(args) {
|
|
|
5841
4910
|
}
|
|
5842
4911
|
if (args.generateDocs !== false) {
|
|
5843
4912
|
await generateAnalysisDocs(args.newProjectPath, analysis, developmentPlan);
|
|
5844
|
-
|
|
4913
|
+
logger4.log(`\u{1F4C4} \u5DF2\u751F\u6210\u5206\u6790\u6587\u6863`);
|
|
5845
4914
|
}
|
|
5846
4915
|
const skeletonGuide = generateSkeletonGuide(analysis, args);
|
|
5847
4916
|
return {
|
|
@@ -5867,7 +4936,7 @@ async function generateProjectSkeleton(args) {
|
|
|
5867
4936
|
}]
|
|
5868
4937
|
};
|
|
5869
4938
|
} catch (error) {
|
|
5870
|
-
|
|
4939
|
+
logger4.error(`\u751F\u6210\u5931\u8D25: ${error}`);
|
|
5871
4940
|
return {
|
|
5872
4941
|
content: [{
|
|
5873
4942
|
type: "text",
|
|
@@ -6107,10 +5176,262 @@ function groupBy(arr, key) {
|
|
|
6107
5176
|
}
|
|
6108
5177
|
|
|
6109
5178
|
// src/tools/queryTroubleshootingCases.ts
|
|
6110
|
-
init_resourceLoader();
|
|
6111
|
-
|
|
6112
|
-
import * as
|
|
6113
|
-
|
|
5179
|
+
init_resourceLoader();
|
|
5180
|
+
import * as fs18 from "fs";
|
|
5181
|
+
import * as path17 from "path";
|
|
5182
|
+
|
|
5183
|
+
// src/core/errors.ts
|
|
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
|
+
}
|
|
5251
|
+
|
|
5252
|
+
// src/core/logger.ts
|
|
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
|
+
}
|
|
5355
|
+
|
|
5356
|
+
// src/core/autoConfig.ts
|
|
5357
|
+
import * as fs17 from "fs";
|
|
5358
|
+
import * as path16 from "path";
|
|
5359
|
+
var checkedWorkspaces = /* @__PURE__ */ new Map();
|
|
5360
|
+
var CACHE_DURATION = 5 * 60 * 1e3;
|
|
5361
|
+
function ensureWorkspaceConfig(workspacePath) {
|
|
5362
|
+
var _a, _b;
|
|
5363
|
+
const result = {
|
|
5364
|
+
needsSetup: false,
|
|
5365
|
+
wasFixed: false,
|
|
5366
|
+
workspacePath
|
|
5367
|
+
};
|
|
5368
|
+
if (!workspacePath || !fs17.existsSync(workspacePath)) {
|
|
5369
|
+
return result;
|
|
5370
|
+
}
|
|
5371
|
+
const cached = checkedWorkspaces.get(workspacePath);
|
|
5372
|
+
const now = Date.now();
|
|
5373
|
+
if (cached && cached.configured && now - cached.timestamp < CACHE_DURATION) {
|
|
5374
|
+
return result;
|
|
5375
|
+
}
|
|
5376
|
+
const vscodeDir = path16.join(workspacePath, ".vscode");
|
|
5377
|
+
const mcpJsonPath = path16.join(vscodeDir, "mcp.json");
|
|
5378
|
+
const settingsPath = path16.join(vscodeDir, "settings.json");
|
|
5379
|
+
let hasMtaConfig = false;
|
|
5380
|
+
if (fs17.existsSync(mcpJsonPath)) {
|
|
5381
|
+
try {
|
|
5382
|
+
const config = JSON.parse(fs17.readFileSync(mcpJsonPath, "utf-8"));
|
|
5383
|
+
hasMtaConfig = !!(((_a = config.servers) == null ? void 0 : _a.mta) || ((_b = config.mcpServers) == null ? void 0 : _b.mta));
|
|
5384
|
+
} catch {
|
|
5385
|
+
}
|
|
5386
|
+
}
|
|
5387
|
+
if (hasMtaConfig) {
|
|
5388
|
+
checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
|
|
5389
|
+
return result;
|
|
5390
|
+
}
|
|
5391
|
+
result.needsSetup = true;
|
|
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));
|
|
5424
|
+
}
|
|
5425
|
+
result.wasFixed = true;
|
|
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)}`;
|
|
5430
|
+
}
|
|
5431
|
+
return result;
|
|
5432
|
+
}
|
|
5433
|
+
|
|
5434
|
+
// src/tools/queryTroubleshootingCases.ts
|
|
6114
5435
|
var logger2 = createLogger("QueryTroubleshootingCases");
|
|
6115
5436
|
function extractCaseMetadata(filePath, framework) {
|
|
6116
5437
|
try {
|
|
@@ -6378,10 +5699,200 @@ async function listTroubleshootingCases(framework) {
|
|
|
6378
5699
|
}
|
|
6379
5700
|
}
|
|
6380
5701
|
|
|
5702
|
+
// src/tools/memory.ts
|
|
5703
|
+
import path18 from "path";
|
|
5704
|
+
var KnowledgeGraphManagerClass = null;
|
|
5705
|
+
async function loadKnowledgeGraphManager() {
|
|
5706
|
+
if (!KnowledgeGraphManagerClass) {
|
|
5707
|
+
try {
|
|
5708
|
+
const module = await import("@modelcontextprotocol/server-memory");
|
|
5709
|
+
KnowledgeGraphManagerClass = module.KnowledgeGraphManager;
|
|
5710
|
+
} catch (error) {
|
|
5711
|
+
console.error("\u65E0\u6CD5\u52A0\u8F7D @modelcontextprotocol/server-memory:", error);
|
|
5712
|
+
throw new Error("\u77E5\u8BC6\u56FE\u8C31\u6A21\u5757\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u786E\u4FDD\u5DF2\u5B89\u88C5 @modelcontextprotocol/server-memory");
|
|
5713
|
+
}
|
|
5714
|
+
}
|
|
5715
|
+
return KnowledgeGraphManagerClass;
|
|
5716
|
+
}
|
|
5717
|
+
var memoryManager = null;
|
|
5718
|
+
async function getMemoryManager() {
|
|
5719
|
+
if (!memoryManager) {
|
|
5720
|
+
const Manager = await loadKnowledgeGraphManager();
|
|
5721
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
|
|
5722
|
+
const memoryPath = path18.join(homeDir, ".mta", "memory.jsonl");
|
|
5723
|
+
memoryManager = new Manager(memoryPath);
|
|
5724
|
+
}
|
|
5725
|
+
return memoryManager;
|
|
5726
|
+
}
|
|
5727
|
+
async function createEntities(args) {
|
|
5728
|
+
const manager = await getMemoryManager();
|
|
5729
|
+
const result = await manager.createEntities(args.entities);
|
|
5730
|
+
return {
|
|
5731
|
+
content: [{
|
|
5732
|
+
type: "text",
|
|
5733
|
+
text: JSON.stringify({
|
|
5734
|
+
success: true,
|
|
5735
|
+
created: result.length,
|
|
5736
|
+
entities: result
|
|
5737
|
+
}, null, 2)
|
|
5738
|
+
}]
|
|
5739
|
+
};
|
|
5740
|
+
}
|
|
5741
|
+
async function createRelations(args) {
|
|
5742
|
+
const manager = await getMemoryManager();
|
|
5743
|
+
const result = await manager.createRelations(args.relations);
|
|
5744
|
+
return {
|
|
5745
|
+
content: [{
|
|
5746
|
+
type: "text",
|
|
5747
|
+
text: JSON.stringify({
|
|
5748
|
+
success: true,
|
|
5749
|
+
created: result.length,
|
|
5750
|
+
relations: result
|
|
5751
|
+
}, null, 2)
|
|
5752
|
+
}]
|
|
5753
|
+
};
|
|
5754
|
+
}
|
|
5755
|
+
async function addObservations(args) {
|
|
5756
|
+
const manager = await getMemoryManager();
|
|
5757
|
+
const result = await manager.addObservations(args.observations);
|
|
5758
|
+
return {
|
|
5759
|
+
content: [{
|
|
5760
|
+
type: "text",
|
|
5761
|
+
text: JSON.stringify({
|
|
5762
|
+
success: true,
|
|
5763
|
+
results: result
|
|
5764
|
+
}, null, 2)
|
|
5765
|
+
}]
|
|
5766
|
+
};
|
|
5767
|
+
}
|
|
5768
|
+
async function deleteEntities(args) {
|
|
5769
|
+
const manager = await getMemoryManager();
|
|
5770
|
+
await manager.deleteEntities(args.entityNames);
|
|
5771
|
+
return {
|
|
5772
|
+
content: [{
|
|
5773
|
+
type: "text",
|
|
5774
|
+
text: JSON.stringify({
|
|
5775
|
+
success: true,
|
|
5776
|
+
message: `\u5DF2\u5220\u9664 ${args.entityNames.length} \u4E2A\u5B9E\u4F53\u53CA\u5176\u5173\u8054\u5173\u7CFB`
|
|
5777
|
+
}, null, 2)
|
|
5778
|
+
}]
|
|
5779
|
+
};
|
|
5780
|
+
}
|
|
5781
|
+
async function deleteObservations(args) {
|
|
5782
|
+
const manager = await getMemoryManager();
|
|
5783
|
+
await manager.deleteObservations(args.deletions);
|
|
5784
|
+
return {
|
|
5785
|
+
content: [{
|
|
5786
|
+
type: "text",
|
|
5787
|
+
text: JSON.stringify({
|
|
5788
|
+
success: true,
|
|
5789
|
+
message: "\u89C2\u5BDF\u5DF2\u5220\u9664"
|
|
5790
|
+
}, null, 2)
|
|
5791
|
+
}]
|
|
5792
|
+
};
|
|
5793
|
+
}
|
|
5794
|
+
async function deleteRelations(args) {
|
|
5795
|
+
const manager = await getMemoryManager();
|
|
5796
|
+
await manager.deleteRelations(args.relations);
|
|
5797
|
+
return {
|
|
5798
|
+
content: [{
|
|
5799
|
+
type: "text",
|
|
5800
|
+
text: JSON.stringify({
|
|
5801
|
+
success: true,
|
|
5802
|
+
message: `\u5DF2\u5220\u9664 ${args.relations.length} \u4E2A\u5173\u7CFB`
|
|
5803
|
+
}, null, 2)
|
|
5804
|
+
}]
|
|
5805
|
+
};
|
|
5806
|
+
}
|
|
5807
|
+
async function readGraph() {
|
|
5808
|
+
const manager = await getMemoryManager();
|
|
5809
|
+
const graph = await manager.readGraph();
|
|
5810
|
+
return {
|
|
5811
|
+
content: [{
|
|
5812
|
+
type: "text",
|
|
5813
|
+
text: JSON.stringify({
|
|
5814
|
+
entities: graph.entities.length,
|
|
5815
|
+
relations: graph.relations.length,
|
|
5816
|
+
graph
|
|
5817
|
+
}, null, 2)
|
|
5818
|
+
}]
|
|
5819
|
+
};
|
|
5820
|
+
}
|
|
5821
|
+
async function searchNodes(args) {
|
|
5822
|
+
const manager = await getMemoryManager();
|
|
5823
|
+
const graph = await manager.searchNodes(args.query);
|
|
5824
|
+
return {
|
|
5825
|
+
content: [{
|
|
5826
|
+
type: "text",
|
|
5827
|
+
text: JSON.stringify({
|
|
5828
|
+
query: args.query,
|
|
5829
|
+
found: {
|
|
5830
|
+
entities: graph.entities.length,
|
|
5831
|
+
relations: graph.relations.length
|
|
5832
|
+
},
|
|
5833
|
+
graph
|
|
5834
|
+
}, null, 2)
|
|
5835
|
+
}]
|
|
5836
|
+
};
|
|
5837
|
+
}
|
|
5838
|
+
async function openNodes(args) {
|
|
5839
|
+
const manager = await getMemoryManager();
|
|
5840
|
+
const graph = await manager.openNodes(args.names);
|
|
5841
|
+
return {
|
|
5842
|
+
content: [{
|
|
5843
|
+
type: "text",
|
|
5844
|
+
text: JSON.stringify({
|
|
5845
|
+
requested: args.names,
|
|
5846
|
+
found: {
|
|
5847
|
+
entities: graph.entities.length,
|
|
5848
|
+
relations: graph.relations.length
|
|
5849
|
+
},
|
|
5850
|
+
graph
|
|
5851
|
+
}, null, 2)
|
|
5852
|
+
}]
|
|
5853
|
+
};
|
|
5854
|
+
}
|
|
5855
|
+
|
|
5856
|
+
// src/tools/sequentialThinking.ts
|
|
5857
|
+
var SequentialThinkingServerClass = null;
|
|
5858
|
+
async function loadSequentialThinkingServer() {
|
|
5859
|
+
if (!SequentialThinkingServerClass) {
|
|
5860
|
+
try {
|
|
5861
|
+
const module = await import("@modelcontextprotocol/server-sequential-thinking");
|
|
5862
|
+
SequentialThinkingServerClass = module.SequentialThinkingServer;
|
|
5863
|
+
} catch (error) {
|
|
5864
|
+
console.error("\u65E0\u6CD5\u52A0\u8F7D @modelcontextprotocol/server-sequential-thinking:", error);
|
|
5865
|
+
throw new Error("\u987A\u5E8F\u601D\u8003\u6A21\u5757\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u786E\u4FDD\u5DF2\u5B89\u88C5 @modelcontextprotocol/server-sequential-thinking");
|
|
5866
|
+
}
|
|
5867
|
+
}
|
|
5868
|
+
return SequentialThinkingServerClass;
|
|
5869
|
+
}
|
|
5870
|
+
var thinkingServer = null;
|
|
5871
|
+
async function getThinkingServer() {
|
|
5872
|
+
if (!thinkingServer) {
|
|
5873
|
+
const Server2 = await loadSequentialThinkingServer();
|
|
5874
|
+
thinkingServer = new Server2();
|
|
5875
|
+
}
|
|
5876
|
+
return thinkingServer;
|
|
5877
|
+
}
|
|
5878
|
+
async function sequentialThinking(args) {
|
|
5879
|
+
const server = await getThinkingServer();
|
|
5880
|
+
const result = server.processThought(args);
|
|
5881
|
+
if (result.isError) {
|
|
5882
|
+
return result;
|
|
5883
|
+
}
|
|
5884
|
+
const parsedContent = JSON.parse(result.content[0].text);
|
|
5885
|
+
return {
|
|
5886
|
+
content: [{
|
|
5887
|
+
type: "text",
|
|
5888
|
+
text: JSON.stringify(parsedContent, null, 2)
|
|
5889
|
+
}]
|
|
5890
|
+
};
|
|
5891
|
+
}
|
|
5892
|
+
|
|
6381
5893
|
// src/index.ts
|
|
6382
|
-
|
|
6383
|
-
var
|
|
6384
|
-
var logger8 = createLogger("Server");
|
|
5894
|
+
var SERVER_VERSION = "3.2.0";
|
|
5895
|
+
var logger3 = createLogger("Server");
|
|
6385
5896
|
var CopilotPromptsMCPServer = class {
|
|
6386
5897
|
constructor() {
|
|
6387
5898
|
this.standardsManager = new StandardsManager();
|
|
@@ -6407,24 +5918,24 @@ var CopilotPromptsMCPServer = class {
|
|
|
6407
5918
|
*/
|
|
6408
5919
|
setupErrorHandlers() {
|
|
6409
5920
|
this.server.onerror = (error) => {
|
|
6410
|
-
|
|
5921
|
+
logger3.error("MCP \u670D\u52A1\u5668\u9519\u8BEF", error);
|
|
6411
5922
|
};
|
|
6412
5923
|
process.on("SIGINT", async () => {
|
|
6413
|
-
|
|
5924
|
+
logger3.info("\u6536\u5230\u5173\u95ED\u4FE1\u53F7\uFF0C\u6B63\u5728\u5173\u95ED\u670D\u52A1\u5668...");
|
|
6414
5925
|
await this.server.close();
|
|
6415
5926
|
process.exit(0);
|
|
6416
5927
|
});
|
|
6417
5928
|
process.on("SIGTERM", async () => {
|
|
6418
|
-
|
|
5929
|
+
logger3.info("\u6536\u5230\u7EC8\u6B62\u4FE1\u53F7\uFF0C\u6B63\u5728\u5173\u95ED\u670D\u52A1\u5668...");
|
|
6419
5930
|
await this.server.close();
|
|
6420
5931
|
process.exit(0);
|
|
6421
5932
|
});
|
|
6422
5933
|
process.on("uncaughtException", (error) => {
|
|
6423
|
-
|
|
5934
|
+
logger3.error("\u672A\u6355\u83B7\u7684\u5F02\u5E38:", error);
|
|
6424
5935
|
process.exit(1);
|
|
6425
5936
|
});
|
|
6426
5937
|
process.on("unhandledRejection", (reason, promise) => {
|
|
6427
|
-
|
|
5938
|
+
logger3.error("\u672A\u5904\u7406\u7684 Promise \u62D2\u7EDD:", reason);
|
|
6428
5939
|
process.exit(1);
|
|
6429
5940
|
});
|
|
6430
5941
|
}
|
|
@@ -6941,161 +6452,272 @@ var CopilotPromptsMCPServer = class {
|
|
|
6941
6452
|
}
|
|
6942
6453
|
}
|
|
6943
6454
|
},
|
|
6944
|
-
//
|
|
6455
|
+
// ================== 知识图谱记忆工具 ==================
|
|
6945
6456
|
{
|
|
6946
|
-
name: "
|
|
6947
|
-
description: "\
|
|
6457
|
+
name: "create_entities",
|
|
6458
|
+
description: "\u5728\u77E5\u8BC6\u56FE\u8C31\u4E2D\u521B\u5EFA\u591A\u4E2A\u65B0\u5B9E\u4F53",
|
|
6948
6459
|
inputSchema: {
|
|
6949
6460
|
type: "object",
|
|
6950
6461
|
properties: {
|
|
6951
|
-
|
|
6952
|
-
type: "
|
|
6953
|
-
description: "\
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
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"
|
|
6462
|
+
entities: {
|
|
6463
|
+
type: "array",
|
|
6464
|
+
description: "\u5B9E\u4F53\u6570\u7EC4",
|
|
6465
|
+
items: {
|
|
6466
|
+
type: "object",
|
|
6467
|
+
properties: {
|
|
6468
|
+
name: { type: "string", description: "\u5B9E\u4F53\u540D\u79F0\uFF08\u552F\u4E00\u6807\u8BC6\uFF09" },
|
|
6469
|
+
entityType: { type: "string", description: "\u5B9E\u4F53\u7C7B\u578B\uFF08\u5982 person\u3001project\u3001concept\uFF09" },
|
|
6470
|
+
observations: { type: "array", items: { type: "string" }, description: "\u5173\u4E8E\u8BE5\u5B9E\u4F53\u7684\u89C2\u5BDF/\u4E8B\u5B9E" }
|
|
6471
|
+
},
|
|
6472
|
+
required: ["name", "entityType", "observations"]
|
|
6473
|
+
}
|
|
6973
6474
|
}
|
|
6974
6475
|
},
|
|
6975
|
-
required: ["
|
|
6476
|
+
required: ["entities"]
|
|
6976
6477
|
}
|
|
6977
6478
|
},
|
|
6978
|
-
// Memory Skills
|
|
6979
6479
|
{
|
|
6980
|
-
name: "
|
|
6981
|
-
description: "\
|
|
6480
|
+
name: "create_relations",
|
|
6481
|
+
description: "\u5728\u77E5\u8BC6\u56FE\u8C31\u4E2D\u521B\u5EFA\u5B9E\u4F53\u4E4B\u95F4\u7684\u5173\u7CFB\uFF08\u4F7F\u7528\u4E3B\u52A8\u8BED\u6001\uFF09",
|
|
6982
6482
|
inputSchema: {
|
|
6983
6483
|
type: "object",
|
|
6984
6484
|
properties: {
|
|
6985
|
-
|
|
6986
|
-
type: "
|
|
6987
|
-
description: "\
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6485
|
+
relations: {
|
|
6486
|
+
type: "array",
|
|
6487
|
+
description: "\u5173\u7CFB\u6570\u7EC4",
|
|
6488
|
+
items: {
|
|
6489
|
+
type: "object",
|
|
6490
|
+
properties: {
|
|
6491
|
+
from: { type: "string", description: "\u8D77\u59CB\u5B9E\u4F53\u540D\u79F0" },
|
|
6492
|
+
to: { type: "string", description: "\u76EE\u6807\u5B9E\u4F53\u540D\u79F0" },
|
|
6493
|
+
relationType: { type: "string", description: "\u5173\u7CFB\u7C7B\u578B\uFF08\u4E3B\u52A8\u8BED\u6001\uFF0C\u5982 works_at\u3001uses\u3001depends_on\uFF09" }
|
|
6494
|
+
},
|
|
6495
|
+
required: ["from", "to", "relationType"]
|
|
6496
|
+
}
|
|
6992
6497
|
}
|
|
6993
6498
|
},
|
|
6994
|
-
required: ["
|
|
6499
|
+
required: ["relations"]
|
|
6995
6500
|
}
|
|
6996
6501
|
},
|
|
6997
6502
|
{
|
|
6998
|
-
name: "
|
|
6999
|
-
description: "\
|
|
6503
|
+
name: "add_observations",
|
|
6504
|
+
description: "\u5411\u73B0\u6709\u5B9E\u4F53\u6DFB\u52A0\u65B0\u7684\u89C2\u5BDF/\u4E8B\u5B9E",
|
|
7000
6505
|
inputSchema: {
|
|
7001
6506
|
type: "object",
|
|
7002
6507
|
properties: {
|
|
7003
|
-
|
|
7004
|
-
type: "
|
|
7005
|
-
description: "\
|
|
6508
|
+
observations: {
|
|
6509
|
+
type: "array",
|
|
6510
|
+
description: "\u89C2\u5BDF\u6570\u7EC4",
|
|
6511
|
+
items: {
|
|
6512
|
+
type: "object",
|
|
6513
|
+
properties: {
|
|
6514
|
+
entityName: { type: "string", description: "\u5B9E\u4F53\u540D\u79F0" },
|
|
6515
|
+
contents: { type: "array", items: { type: "string" }, description: "\u8981\u6DFB\u52A0\u7684\u89C2\u5BDF\u5185\u5BB9" }
|
|
6516
|
+
},
|
|
6517
|
+
required: ["entityName", "contents"]
|
|
6518
|
+
}
|
|
7006
6519
|
}
|
|
7007
6520
|
},
|
|
7008
|
-
required: ["
|
|
6521
|
+
required: ["observations"]
|
|
7009
6522
|
}
|
|
7010
6523
|
},
|
|
7011
6524
|
{
|
|
7012
|
-
name: "
|
|
7013
|
-
description: "\
|
|
6525
|
+
name: "delete_entities",
|
|
6526
|
+
description: "\u5220\u9664\u5B9E\u4F53\u53CA\u5176\u5173\u8054\u7684\u5173\u7CFB",
|
|
7014
6527
|
inputSchema: {
|
|
7015
6528
|
type: "object",
|
|
7016
|
-
properties: {
|
|
6529
|
+
properties: {
|
|
6530
|
+
entityNames: {
|
|
6531
|
+
type: "array",
|
|
6532
|
+
items: { type: "string" },
|
|
6533
|
+
description: "\u8981\u5220\u9664\u7684\u5B9E\u4F53\u540D\u79F0\u5217\u8868"
|
|
6534
|
+
}
|
|
6535
|
+
},
|
|
6536
|
+
required: ["entityNames"]
|
|
7017
6537
|
}
|
|
7018
6538
|
},
|
|
7019
|
-
// Filesystem Skills
|
|
7020
6539
|
{
|
|
7021
|
-
name: "
|
|
7022
|
-
description: "\
|
|
6540
|
+
name: "delete_observations",
|
|
6541
|
+
description: "\u4ECE\u5B9E\u4F53\u4E2D\u5220\u9664\u7279\u5B9A\u7684\u89C2\u5BDF",
|
|
7023
6542
|
inputSchema: {
|
|
7024
6543
|
type: "object",
|
|
7025
6544
|
properties: {
|
|
7026
|
-
|
|
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: {
|
|
6545
|
+
deletions: {
|
|
7035
6546
|
type: "array",
|
|
7036
|
-
items: {
|
|
7037
|
-
|
|
6547
|
+
items: {
|
|
6548
|
+
type: "object",
|
|
6549
|
+
properties: {
|
|
6550
|
+
entityName: { type: "string", description: "\u5B9E\u4F53\u540D\u79F0" },
|
|
6551
|
+
observations: { type: "array", items: { type: "string" }, description: "\u8981\u5220\u9664\u7684\u89C2\u5BDF" }
|
|
6552
|
+
},
|
|
6553
|
+
required: ["entityName", "observations"]
|
|
6554
|
+
}
|
|
7038
6555
|
}
|
|
7039
6556
|
},
|
|
7040
|
-
required: ["
|
|
6557
|
+
required: ["deletions"]
|
|
7041
6558
|
}
|
|
7042
6559
|
},
|
|
7043
6560
|
{
|
|
7044
|
-
name: "
|
|
7045
|
-
description: "\
|
|
6561
|
+
name: "delete_relations",
|
|
6562
|
+
description: "\u4ECE\u77E5\u8BC6\u56FE\u8C31\u4E2D\u5220\u9664\u5173\u7CFB",
|
|
7046
6563
|
inputSchema: {
|
|
7047
6564
|
type: "object",
|
|
7048
6565
|
properties: {
|
|
7049
|
-
|
|
6566
|
+
relations: {
|
|
7050
6567
|
type: "array",
|
|
7051
|
-
items: {
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
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"
|
|
6568
|
+
items: {
|
|
6569
|
+
type: "object",
|
|
6570
|
+
properties: {
|
|
6571
|
+
from: { type: "string", description: "\u8D77\u59CB\u5B9E\u4F53\u540D\u79F0" },
|
|
6572
|
+
to: { type: "string", description: "\u76EE\u6807\u5B9E\u4F53\u540D\u79F0" },
|
|
6573
|
+
relationType: { type: "string", description: "\u5173\u7CFB\u7C7B\u578B" }
|
|
6574
|
+
},
|
|
6575
|
+
required: ["from", "to", "relationType"]
|
|
6576
|
+
}
|
|
7069
6577
|
}
|
|
7070
6578
|
},
|
|
7071
|
-
required: ["
|
|
6579
|
+
required: ["relations"]
|
|
6580
|
+
}
|
|
6581
|
+
},
|
|
6582
|
+
{
|
|
6583
|
+
name: "read_graph",
|
|
6584
|
+
description: "\u8BFB\u53D6\u6574\u4E2A\u77E5\u8BC6\u56FE\u8C31",
|
|
6585
|
+
inputSchema: {
|
|
6586
|
+
type: "object",
|
|
6587
|
+
properties: {}
|
|
7072
6588
|
}
|
|
7073
6589
|
},
|
|
7074
|
-
// Thinking Skills
|
|
7075
6590
|
{
|
|
7076
|
-
name: "
|
|
7077
|
-
description: "\
|
|
6591
|
+
name: "search_nodes",
|
|
6592
|
+
description: "\u5728\u77E5\u8BC6\u56FE\u8C31\u4E2D\u641C\u7D22\u8282\u70B9\uFF08\u6309\u540D\u79F0\u3001\u7C7B\u578B\u6216\u89C2\u5BDF\u5185\u5BB9\u5339\u914D\uFF09",
|
|
7078
6593
|
inputSchema: {
|
|
7079
6594
|
type: "object",
|
|
7080
6595
|
properties: {
|
|
7081
|
-
|
|
7082
|
-
type: "string",
|
|
7083
|
-
description: "\u9700\u8981\u6DF1\u5165\u601D\u8003\u7684\u95EE\u9898\u6216\u4EFB\u52A1"
|
|
7084
|
-
},
|
|
7085
|
-
context: {
|
|
6596
|
+
query: {
|
|
7086
6597
|
type: "string",
|
|
7087
|
-
description: "\
|
|
6598
|
+
description: "\u641C\u7D22\u5173\u952E\u8BCD"
|
|
7088
6599
|
}
|
|
7089
6600
|
},
|
|
7090
|
-
required: ["
|
|
6601
|
+
required: ["query"]
|
|
7091
6602
|
}
|
|
7092
6603
|
},
|
|
7093
6604
|
{
|
|
7094
|
-
name: "
|
|
7095
|
-
description: "\
|
|
6605
|
+
name: "open_nodes",
|
|
6606
|
+
description: "\u6309\u540D\u79F0\u6253\u5F00\u7279\u5B9A\u8282\u70B9",
|
|
7096
6607
|
inputSchema: {
|
|
7097
6608
|
type: "object",
|
|
7098
|
-
properties: {
|
|
6609
|
+
properties: {
|
|
6610
|
+
names: {
|
|
6611
|
+
type: "array",
|
|
6612
|
+
items: { type: "string" },
|
|
6613
|
+
description: "\u8981\u68C0\u7D22\u7684\u5B9E\u4F53\u540D\u79F0\u5217\u8868"
|
|
6614
|
+
}
|
|
6615
|
+
},
|
|
6616
|
+
required: ["names"]
|
|
6617
|
+
}
|
|
6618
|
+
},
|
|
6619
|
+
// ================== 顺序思考工具 ==================
|
|
6620
|
+
{
|
|
6621
|
+
name: "sequentialthinking",
|
|
6622
|
+
description: `A detailed tool for dynamic and reflective problem-solving through thoughts.
|
|
6623
|
+
This tool helps analyze problems through a flexible thinking process that can adapt and evolve.
|
|
6624
|
+
Each thought can build on, question, or revise previous insights as understanding deepens.
|
|
6625
|
+
|
|
6626
|
+
When to use this tool:
|
|
6627
|
+
- Breaking down complex problems into steps
|
|
6628
|
+
- Planning and design with room for revision
|
|
6629
|
+
- Analysis that might need course correction
|
|
6630
|
+
- Problems where the full scope might not be clear initially
|
|
6631
|
+
- Problems that require a multi-step solution
|
|
6632
|
+
- Tasks that need to maintain context over multiple steps
|
|
6633
|
+
- Situations where irrelevant information needs to be filtered out
|
|
6634
|
+
|
|
6635
|
+
Key features:
|
|
6636
|
+
- You can adjust total_thoughts up or down as you progress
|
|
6637
|
+
- You can question or revise previous thoughts
|
|
6638
|
+
- You can add more thoughts even after reaching what seemed like the end
|
|
6639
|
+
- You can express uncertainty and explore alternative approaches
|
|
6640
|
+
- Not every thought needs to build linearly - you can branch or backtrack
|
|
6641
|
+
- Generates a solution hypothesis
|
|
6642
|
+
- Verifies the hypothesis based on the Chain of Thought steps
|
|
6643
|
+
- Repeats the process until satisfied
|
|
6644
|
+
- Provides a correct answer
|
|
6645
|
+
|
|
6646
|
+
Parameters explained:
|
|
6647
|
+
- thought: Your current thinking step, which can include:
|
|
6648
|
+
* Regular analytical steps
|
|
6649
|
+
* Revisions of previous thoughts
|
|
6650
|
+
* Questions about previous decisions
|
|
6651
|
+
* Realizations about needing more analysis
|
|
6652
|
+
* Changes in approach
|
|
6653
|
+
* Hypothesis generation
|
|
6654
|
+
* Hypothesis verification
|
|
6655
|
+
- nextThoughtNeeded: True if you need more thinking, even if at what seemed like the end
|
|
6656
|
+
- thoughtNumber: Current number in sequence (can go beyond initial total if needed)
|
|
6657
|
+
- totalThoughts: Current estimate of thoughts needed (can be adjusted up/down)
|
|
6658
|
+
- isRevision: A boolean indicating if this thought revises previous thinking
|
|
6659
|
+
- revisesThought: If is_revision is true, which thought number is being reconsidered
|
|
6660
|
+
- branchFromThought: If branching, which thought number is the branching point
|
|
6661
|
+
- branchId: Identifier for the current branch (if any)
|
|
6662
|
+
- needsMoreThoughts: If reaching end but realizing more thoughts needed
|
|
6663
|
+
|
|
6664
|
+
You should:
|
|
6665
|
+
1. Start with an initial estimate of needed thoughts, but be ready to adjust
|
|
6666
|
+
2. Feel free to question or revise previous thoughts
|
|
6667
|
+
3. Don't hesitate to add more thoughts if needed, even at the "end"
|
|
6668
|
+
4. Express uncertainty when present
|
|
6669
|
+
5. Mark thoughts that revise previous thinking or branch into new paths
|
|
6670
|
+
6. Ignore information that is irrelevant to the current step
|
|
6671
|
+
7. Generate a solution hypothesis when appropriate
|
|
6672
|
+
8. Verify the hypothesis based on the Chain of Thought steps
|
|
6673
|
+
9. Repeat the process until satisfied with the solution
|
|
6674
|
+
10. Provide a single, ideally correct answer as the final output
|
|
6675
|
+
11. Only set nextThoughtNeeded to false when truly done and a satisfactory answer is reached`,
|
|
6676
|
+
inputSchema: {
|
|
6677
|
+
type: "object",
|
|
6678
|
+
properties: {
|
|
6679
|
+
thought: {
|
|
6680
|
+
type: "string",
|
|
6681
|
+
description: "Your current thinking step"
|
|
6682
|
+
},
|
|
6683
|
+
nextThoughtNeeded: {
|
|
6684
|
+
type: "boolean",
|
|
6685
|
+
description: "Whether another thought step is needed"
|
|
6686
|
+
},
|
|
6687
|
+
thoughtNumber: {
|
|
6688
|
+
type: "integer",
|
|
6689
|
+
description: "Current thought number (numeric value, e.g., 1, 2, 3)",
|
|
6690
|
+
minimum: 1
|
|
6691
|
+
},
|
|
6692
|
+
totalThoughts: {
|
|
6693
|
+
type: "integer",
|
|
6694
|
+
description: "Estimated total thoughts needed (numeric value, e.g., 5, 10)",
|
|
6695
|
+
minimum: 1
|
|
6696
|
+
},
|
|
6697
|
+
isRevision: {
|
|
6698
|
+
type: "boolean",
|
|
6699
|
+
description: "Whether this revises previous thinking"
|
|
6700
|
+
},
|
|
6701
|
+
revisesThought: {
|
|
6702
|
+
type: "integer",
|
|
6703
|
+
description: "Which thought is being reconsidered",
|
|
6704
|
+
minimum: 1
|
|
6705
|
+
},
|
|
6706
|
+
branchFromThought: {
|
|
6707
|
+
type: "integer",
|
|
6708
|
+
description: "Branching point thought number",
|
|
6709
|
+
minimum: 1
|
|
6710
|
+
},
|
|
6711
|
+
branchId: {
|
|
6712
|
+
type: "string",
|
|
6713
|
+
description: "Branch identifier"
|
|
6714
|
+
},
|
|
6715
|
+
needsMoreThoughts: {
|
|
6716
|
+
type: "boolean",
|
|
6717
|
+
description: "If more thoughts are needed"
|
|
6718
|
+
}
|
|
6719
|
+
},
|
|
6720
|
+
required: ["thought", "nextThoughtNeeded", "thoughtNumber", "totalThoughts"]
|
|
7099
6721
|
}
|
|
7100
6722
|
}
|
|
7101
6723
|
]
|
|
@@ -7104,15 +6726,15 @@ var CopilotPromptsMCPServer = class {
|
|
|
7104
6726
|
var _a, _b;
|
|
7105
6727
|
try {
|
|
7106
6728
|
const { name, arguments: args } = request.params;
|
|
7107
|
-
|
|
7108
|
-
|
|
6729
|
+
logger3.debug(`\u8C03\u7528\u5DE5\u5177: ${name}`);
|
|
6730
|
+
logger3.debug(`\u53C2\u6570:`, args);
|
|
7109
6731
|
const workspacePath = (args == null ? void 0 : args.workspacePath) || (args == null ? void 0 : args.projectPath);
|
|
7110
6732
|
let autoConfigMessage = null;
|
|
7111
6733
|
if (workspacePath) {
|
|
7112
6734
|
const configResult = ensureWorkspaceConfig(workspacePath);
|
|
7113
6735
|
if (configResult.wasFixed) {
|
|
7114
6736
|
autoConfigMessage = configResult.message || null;
|
|
7115
|
-
|
|
6737
|
+
logger3.info(`\u81EA\u52A8\u914D\u7F6E\u5DF2\u4FEE\u590D: ${workspacePath}`);
|
|
7116
6738
|
}
|
|
7117
6739
|
}
|
|
7118
6740
|
let result;
|
|
@@ -7209,76 +6831,37 @@ var CopilotPromptsMCPServer = class {
|
|
|
7209
6831
|
case "list_troubleshooting_cases":
|
|
7210
6832
|
result = await listTroubleshootingCases(args == null ? void 0 : args.framework);
|
|
7211
6833
|
break;
|
|
7212
|
-
//
|
|
7213
|
-
case "
|
|
7214
|
-
|
|
7215
|
-
result = await handleHttpRequest2(args);
|
|
6834
|
+
// ================== 知识图谱记忆工具 ==================
|
|
6835
|
+
case "create_entities":
|
|
6836
|
+
result = await createEntities(args);
|
|
7216
6837
|
break;
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
const { handleStoreMemory: handleStoreMemory2 } = await Promise.resolve().then(() => (init_memory(), memory_exports));
|
|
7220
|
-
result = await handleStoreMemory2(args);
|
|
6838
|
+
case "create_relations":
|
|
6839
|
+
result = await createRelations(args);
|
|
7221
6840
|
break;
|
|
7222
|
-
case "
|
|
7223
|
-
|
|
7224
|
-
result = await handleRetrieveMemory2(args);
|
|
6841
|
+
case "add_observations":
|
|
6842
|
+
result = await addObservations(args);
|
|
7225
6843
|
break;
|
|
7226
|
-
case "
|
|
7227
|
-
|
|
7228
|
-
result = await handleListMemories2();
|
|
6844
|
+
case "delete_entities":
|
|
6845
|
+
result = await deleteEntities(args);
|
|
7229
6846
|
break;
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
const { handleGlobFiles: handleGlobFiles2 } = await Promise.resolve().then(() => (init_filesystem(), filesystem_exports));
|
|
7233
|
-
result = await handleGlobFiles2(args);
|
|
6847
|
+
case "delete_observations":
|
|
6848
|
+
result = await deleteObservations(args);
|
|
7234
6849
|
break;
|
|
7235
|
-
case "
|
|
7236
|
-
|
|
7237
|
-
result = await handleBatchRename2(args);
|
|
6850
|
+
case "delete_relations":
|
|
6851
|
+
result = await deleteRelations(args);
|
|
7238
6852
|
break;
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
const { handleThinkStepByStep: handleThinkStepByStep2 } = await Promise.resolve().then(() => (init_thinking(), thinking_exports));
|
|
7242
|
-
result = await handleThinkStepByStep2(args);
|
|
6853
|
+
case "read_graph":
|
|
6854
|
+
result = await readGraph();
|
|
7243
6855
|
break;
|
|
7244
|
-
case "
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
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
|
-
};
|
|
6856
|
+
case "search_nodes":
|
|
6857
|
+
result = await searchNodes(args);
|
|
6858
|
+
break;
|
|
6859
|
+
case "open_nodes":
|
|
6860
|
+
result = await openNodes(args);
|
|
6861
|
+
break;
|
|
6862
|
+
// ================== 顺序思考工具 ==================
|
|
6863
|
+
case "sequentialthinking":
|
|
6864
|
+
result = await sequentialThinking(args);
|
|
7282
6865
|
break;
|
|
7283
6866
|
default:
|
|
7284
6867
|
throw new Error(`\u672A\u77E5\u5DE5\u5177: ${name}`);
|
|
@@ -7298,7 +6881,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
7298
6881
|
}
|
|
7299
6882
|
return result;
|
|
7300
6883
|
} catch (error) {
|
|
7301
|
-
|
|
6884
|
+
logger3.error(`\u5DE5\u5177\u6267\u884C\u5931\u8D25:`, error);
|
|
7302
6885
|
return errorResponse(error);
|
|
7303
6886
|
}
|
|
7304
6887
|
});
|
|
@@ -7363,11 +6946,21 @@ var CopilotPromptsMCPServer = class {
|
|
|
7363
6946
|
` \u2022 analyze_reference_project - \u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE`,
|
|
7364
6947
|
` \u2022 generate_project_skeleton - \u751F\u6210\u9879\u76EE\u9AA8\u67B6`,
|
|
7365
6948
|
``,
|
|
6949
|
+
`\u{1F9E0} \u77E5\u8BC6\u56FE\u8C31\u8BB0\u5FC6:`,
|
|
6950
|
+
` \u2022 create_entities - \u521B\u5EFA\u5B9E\u4F53`,
|
|
6951
|
+
` \u2022 create_relations - \u521B\u5EFA\u5173\u7CFB`,
|
|
6952
|
+
` \u2022 add_observations - \u6DFB\u52A0\u89C2\u5BDF`,
|
|
6953
|
+
` \u2022 read_graph - \u8BFB\u53D6\u56FE\u8C31`,
|
|
6954
|
+
` \u2022 search_nodes - \u641C\u7D22\u8282\u70B9`,
|
|
6955
|
+
``,
|
|
6956
|
+
`\u{1F914} \u987A\u5E8F\u601D\u8003:`,
|
|
6957
|
+
` \u2022 sequentialthinking - \u52A8\u6001\u53CD\u601D\u6027\u95EE\u9898\u89E3\u51B3`,
|
|
6958
|
+
``,
|
|
7366
6959
|
`\u{1F4A1} \u63D0\u793A: \u5728 Copilot Chat \u4E2D\u4F7F\u7528 @mta \u8C03\u7528\u670D\u52A1`,
|
|
7367
6960
|
`\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`
|
|
7368
6961
|
];
|
|
7369
6962
|
startupInfo.forEach((line) => console.error(line));
|
|
7370
|
-
|
|
6963
|
+
logger3.info(`MCP Server \u5C31\u7EEA\uFF0C\u7B49\u5F85 Copilot Chat \u8FDE\u63A5...`);
|
|
7371
6964
|
}
|
|
7372
6965
|
};
|
|
7373
6966
|
var isTestMode = process.env.MTA_TEST_MODE === "true" || process.argv.includes("--test");
|
|
@@ -7389,7 +6982,7 @@ if (!isTestMode) {
|
|
|
7389
6982
|
console.error(` \u2022 \u8FD0\u884C npm install \u91CD\u65B0\u5B89\u88C5\u4F9D\u8D56`);
|
|
7390
6983
|
console.error(` \u2022 \u68C0\u67E5\u662F\u5426\u6709\u5176\u4ED6 MCP \u670D\u52A1\u5668\u5B9E\u4F8B\u8FD0\u884C`);
|
|
7391
6984
|
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`);
|
|
7392
|
-
|
|
6985
|
+
logger3.error("\u670D\u52A1\u5668\u542F\u52A8\u5931\u8D25:", error);
|
|
7393
6986
|
process.exit(1);
|
|
7394
6987
|
});
|
|
7395
6988
|
}
|