mta-mcp 2.4.1 → 2.6.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/dist/index.js +296 -577
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/standards/workflows/large-project-split.md +1 -1
package/dist/index.js
CHANGED
|
@@ -1726,49 +1726,18 @@ async function autoSetup(args) {
|
|
|
1726
1726
|
} else {
|
|
1727
1727
|
results.steps.push({ step: "\u68C0\u6D4B\u5230\u5DF2\u6709 .vscode \u76EE\u5F55", status: "skip" });
|
|
1728
1728
|
}
|
|
1729
|
-
let mcpServerPath = "";
|
|
1730
|
-
const possiblePaths = [
|
|
1731
|
-
path5.join(workspacePath, "mcp-server/build/index.js"),
|
|
1732
|
-
path5.join(workspacePath, "../copilot-prompts/mcp-server/build/index.js"),
|
|
1733
|
-
path5.join(workspacePath, "copilot-prompts/mcp-server/build/index.js")
|
|
1734
|
-
];
|
|
1735
|
-
for (const p of possiblePaths) {
|
|
1736
|
-
if (fs5.existsSync(p)) {
|
|
1737
|
-
mcpServerPath = p;
|
|
1738
|
-
break;
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
if (!mcpServerPath) {
|
|
1742
|
-
const srcPath = path5.join(workspacePath, "mcp-server/src/index.ts");
|
|
1743
|
-
if (fs5.existsSync(srcPath)) {
|
|
1744
|
-
results.warnings.push("\u68C0\u6D4B\u5230\u5F00\u53D1\u6A21\u5F0F\uFF0C\u8BF7\u5148\u8FD0\u884C npm run build \u7F16\u8BD1\u670D\u52A1\u5668");
|
|
1745
|
-
mcpServerPath = "${workspaceFolder}/mcp-server/build/index.js";
|
|
1746
|
-
} else {
|
|
1747
|
-
return {
|
|
1748
|
-
content: [{
|
|
1749
|
-
type: "text",
|
|
1750
|
-
text: JSON.stringify({
|
|
1751
|
-
error: "MCP \u670D\u52A1\u5668\u672A\u627E\u5230",
|
|
1752
|
-
hint: "\u8BF7\u786E\u4FDD mcp-server/build/index.js \u5B58\u5728\uFF0C\u6216\u8FD0\u884C npm run build"
|
|
1753
|
-
}, null, 2)
|
|
1754
|
-
}]
|
|
1755
|
-
};
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
const relativePath = mcpServerPath.startsWith(workspacePath) ? "${workspaceFolder}/" + path5.relative(workspacePath, mcpServerPath) : mcpServerPath;
|
|
1759
1729
|
results.steps.push({
|
|
1760
|
-
step: "\
|
|
1730
|
+
step: "\u4F7F\u7528 npx mta-mcp \u914D\u7F6E",
|
|
1761
1731
|
status: "success",
|
|
1762
|
-
detail:
|
|
1732
|
+
detail: "\u901A\u8FC7 npm \u5305\u8FD0\u884C\uFF0C\u65E0\u9700\u672C\u5730\u5B89\u88C5"
|
|
1763
1733
|
});
|
|
1764
1734
|
const mcpJsonPath = path5.join(vscodeDir, "mcp.json");
|
|
1765
1735
|
const mcpConfig = {
|
|
1766
1736
|
servers: {
|
|
1767
|
-
"
|
|
1768
|
-
command: "
|
|
1769
|
-
args: [
|
|
1770
|
-
env: {}
|
|
1771
|
-
autoStart: true
|
|
1737
|
+
"mta": {
|
|
1738
|
+
command: "npx",
|
|
1739
|
+
args: ["-y", "mta-mcp"],
|
|
1740
|
+
env: {}
|
|
1772
1741
|
}
|
|
1773
1742
|
}
|
|
1774
1743
|
};
|
|
@@ -1780,20 +1749,15 @@ async function autoSetup(args) {
|
|
|
1780
1749
|
existingConfig.servers = existingConfig.mcpServers;
|
|
1781
1750
|
delete existingConfig.mcpServers;
|
|
1782
1751
|
}
|
|
1783
|
-
if ((_a = existingConfig.servers) == null ? void 0 : _a
|
|
1784
|
-
|
|
1785
|
-
...mcpConfig.servers["copilot-prompts"],
|
|
1786
|
-
...existingConfig.servers["copilot-prompts"]
|
|
1787
|
-
};
|
|
1788
|
-
fs5.writeFileSync(mcpJsonPath, JSON.stringify(existingConfig, null, 2));
|
|
1789
|
-
results.steps.push({ step: "\u66F4\u65B0 mcp.json", status: "success" });
|
|
1752
|
+
if ((_a = existingConfig.servers) == null ? void 0 : _a.mta) {
|
|
1753
|
+
results.steps.push({ step: "mcp.json \u5DF2\u5305\u542B mta \u914D\u7F6E", status: "skip" });
|
|
1790
1754
|
} else {
|
|
1791
1755
|
existingConfig.servers = {
|
|
1792
1756
|
...existingConfig.servers,
|
|
1793
1757
|
...mcpConfig.servers
|
|
1794
1758
|
};
|
|
1795
1759
|
fs5.writeFileSync(mcpJsonPath, JSON.stringify(existingConfig, null, 2));
|
|
1796
|
-
results.steps.push({ step: "\
|
|
1760
|
+
results.steps.push({ step: "\u6DFB\u52A0 mta \u5230 mcp.json", status: "success" });
|
|
1797
1761
|
}
|
|
1798
1762
|
} catch (err) {
|
|
1799
1763
|
fs5.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
@@ -1941,9 +1905,6 @@ async function autoSetup(args) {
|
|
|
1941
1905
|
}
|
|
1942
1906
|
}
|
|
1943
1907
|
|
|
1944
|
-
// src/tools/getSmartStandards.ts
|
|
1945
|
-
import * as fs8 from "fs";
|
|
1946
|
-
|
|
1947
1908
|
// src/core/standardsManager.ts
|
|
1948
1909
|
import * as fs6 from "fs";
|
|
1949
1910
|
import * as path6 from "path";
|
|
@@ -2432,310 +2393,6 @@ ${content}
|
|
|
2432
2393
|
}
|
|
2433
2394
|
};
|
|
2434
2395
|
|
|
2435
|
-
// src/core/autoInitializer.ts
|
|
2436
|
-
import * as fs7 from "fs";
|
|
2437
|
-
import * as path7 from "path";
|
|
2438
|
-
var AutoInitializer = class {
|
|
2439
|
-
constructor(logger3) {
|
|
2440
|
-
this.logger = logger3;
|
|
2441
|
-
this.initialized = /* @__PURE__ */ new Map();
|
|
2442
|
-
}
|
|
2443
|
-
/**
|
|
2444
|
-
* 检查并初始化项目配置
|
|
2445
|
-
* @param workspacePath 工作区路径
|
|
2446
|
-
* @returns 是否需要初始化(返回 true 表示已执行初始化)
|
|
2447
|
-
*/
|
|
2448
|
-
async ensureProjectConfig(workspacePath) {
|
|
2449
|
-
var _a, _b, _c, _d;
|
|
2450
|
-
const projectPath = workspacePath || this.detectWorkspacePath();
|
|
2451
|
-
if (!projectPath) {
|
|
2452
|
-
return {
|
|
2453
|
-
needsInit: false,
|
|
2454
|
-
initialized: false,
|
|
2455
|
-
message: "\u672A\u68C0\u6D4B\u5230\u5DE5\u4F5C\u533A\u8DEF\u5F84"
|
|
2456
|
-
};
|
|
2457
|
-
}
|
|
2458
|
-
if (this.initialized.get(projectPath)) {
|
|
2459
|
-
return {
|
|
2460
|
-
needsInit: false,
|
|
2461
|
-
initialized: true,
|
|
2462
|
-
message: `\u9879\u76EE\u5DF2\u914D\u7F6E: ${path7.basename(projectPath)}`
|
|
2463
|
-
};
|
|
2464
|
-
}
|
|
2465
|
-
const configPath = path7.join(projectPath, ".github", "copilot-instructions.md");
|
|
2466
|
-
const hasConfig = fs7.existsSync(configPath);
|
|
2467
|
-
if (hasConfig) {
|
|
2468
|
-
this.initialized.set(projectPath, true);
|
|
2469
|
-
return {
|
|
2470
|
-
needsInit: false,
|
|
2471
|
-
initialized: true,
|
|
2472
|
-
message: `\u9879\u76EE\u5DF2\u6709\u914D\u7F6E: ${path7.basename(projectPath)}`
|
|
2473
|
-
};
|
|
2474
|
-
}
|
|
2475
|
-
this.log(`\u{1F50D} \u68C0\u6D4B\u5230\u9879\u76EE\u672A\u914D\u7F6E\uFF0C\u5F00\u59CB\u81EA\u52A8\u5206\u6790\u548C\u751F\u6210\u914D\u7F6E...`);
|
|
2476
|
-
this.log(`\u{1F4C1} \u9879\u76EE\u8DEF\u5F84: ${projectPath}`);
|
|
2477
|
-
try {
|
|
2478
|
-
this.log("1\uFE0F\u20E3 \u5206\u6790\u9879\u76EE\u6280\u672F\u6808...");
|
|
2479
|
-
const analysisResult = await analyzeProject({ projectPath });
|
|
2480
|
-
if ((_b = (_a = analysisResult.content) == null ? void 0 : _a[0]) == null ? void 0 : _b.text) {
|
|
2481
|
-
const analysis = JSON.parse(analysisResult.content[0].text);
|
|
2482
|
-
this.log(`\u2705 \u68C0\u6D4B\u5230: ${((_c = analysis.frameworks) == null ? void 0 : _c.join(", ")) || "\u672A\u77E5\u6280\u672F\u6808"}`);
|
|
2483
|
-
this.log("2\uFE0F\u20E3 \u751F\u6210\u9879\u76EE\u914D\u7F6E\u6587\u4EF6...");
|
|
2484
|
-
await generateConfig({
|
|
2485
|
-
projectPath,
|
|
2486
|
-
autoMatch: true
|
|
2487
|
-
});
|
|
2488
|
-
this.initialized.set(projectPath, true);
|
|
2489
|
-
return {
|
|
2490
|
-
needsInit: true,
|
|
2491
|
-
initialized: true,
|
|
2492
|
-
message: `\u2705 \u9879\u76EE\u914D\u7F6E\u5DF2\u81EA\u52A8\u751F\u6210
|
|
2493
|
-
\u{1F4C1} \u8DEF\u5F84: ${configPath}
|
|
2494
|
-
\u{1F3AF} \u6280\u672F\u6808: ${(_d = analysis.frameworks) == null ? void 0 : _d.join(", ")}`
|
|
2495
|
-
};
|
|
2496
|
-
}
|
|
2497
|
-
} catch (error) {
|
|
2498
|
-
this.log(`\u274C \u81EA\u52A8\u521D\u59CB\u5316\u5931\u8D25: ${error}`);
|
|
2499
|
-
return {
|
|
2500
|
-
needsInit: true,
|
|
2501
|
-
initialized: false,
|
|
2502
|
-
message: `\u26A0\uFE0F \u81EA\u52A8\u521D\u59CB\u5316\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`
|
|
2503
|
-
};
|
|
2504
|
-
}
|
|
2505
|
-
return {
|
|
2506
|
-
needsInit: true,
|
|
2507
|
-
initialized: false,
|
|
2508
|
-
message: "\u26A0\uFE0F \u65E0\u6CD5\u5B8C\u6210\u81EA\u52A8\u521D\u59CB\u5316"
|
|
2509
|
-
};
|
|
2510
|
-
}
|
|
2511
|
-
/**
|
|
2512
|
-
* 检测工作区路径
|
|
2513
|
-
*/
|
|
2514
|
-
detectWorkspacePath() {
|
|
2515
|
-
if (process.env.WORKSPACE_PATH) {
|
|
2516
|
-
return process.env.WORKSPACE_PATH;
|
|
2517
|
-
}
|
|
2518
|
-
const cwd = process.cwd();
|
|
2519
|
-
if (this.isValidProject(cwd)) {
|
|
2520
|
-
return cwd;
|
|
2521
|
-
}
|
|
2522
|
-
const possiblePaths = [
|
|
2523
|
-
path7.join(cwd, ".."),
|
|
2524
|
-
path7.join(cwd, "../..")
|
|
2525
|
-
];
|
|
2526
|
-
for (const possiblePath of possiblePaths) {
|
|
2527
|
-
if (this.isValidProject(possiblePath)) {
|
|
2528
|
-
return possiblePath;
|
|
2529
|
-
}
|
|
2530
|
-
}
|
|
2531
|
-
return null;
|
|
2532
|
-
}
|
|
2533
|
-
/**
|
|
2534
|
-
* 判断是否是有效的项目目录
|
|
2535
|
-
*/
|
|
2536
|
-
isValidProject(dirPath) {
|
|
2537
|
-
if (!fs7.existsSync(dirPath)) {
|
|
2538
|
-
return false;
|
|
2539
|
-
}
|
|
2540
|
-
const markers = [
|
|
2541
|
-
"package.json",
|
|
2542
|
-
"pubspec.yaml",
|
|
2543
|
-
"pom.xml",
|
|
2544
|
-
"go.mod",
|
|
2545
|
-
"Cargo.toml",
|
|
2546
|
-
".git"
|
|
2547
|
-
];
|
|
2548
|
-
return markers.some(
|
|
2549
|
-
(marker) => fs7.existsSync(path7.join(dirPath, marker))
|
|
2550
|
-
);
|
|
2551
|
-
}
|
|
2552
|
-
/**
|
|
2553
|
-
* 重置初始化状态(用于测试)
|
|
2554
|
-
*/
|
|
2555
|
-
reset() {
|
|
2556
|
-
this.initialized.clear();
|
|
2557
|
-
}
|
|
2558
|
-
log(message) {
|
|
2559
|
-
if (this.logger) {
|
|
2560
|
-
this.logger.log(message);
|
|
2561
|
-
} else {
|
|
2562
|
-
console.error(`[AutoInit] ${message}`);
|
|
2563
|
-
}
|
|
2564
|
-
}
|
|
2565
|
-
};
|
|
2566
|
-
|
|
2567
|
-
// src/tools/getSmartStandards.ts
|
|
2568
|
-
async function getSmartStandards(args) {
|
|
2569
|
-
var _a;
|
|
2570
|
-
const logger3 = new ConsoleLogger();
|
|
2571
|
-
const manager = new StandardsManager();
|
|
2572
|
-
const autoInit = new AutoInitializer(logger3);
|
|
2573
|
-
try {
|
|
2574
|
-
const initResult = await autoInit.ensureProjectConfig();
|
|
2575
|
-
if (initResult.needsInit) {
|
|
2576
|
-
logger3.log("\u{1F4CB} " + initResult.message);
|
|
2577
|
-
if (initResult.initialized) {
|
|
2578
|
-
return {
|
|
2579
|
-
content: [{
|
|
2580
|
-
type: "text",
|
|
2581
|
-
text: `\u{1F389} **\u9996\u6B21\u4F7F\u7528\u81EA\u52A8\u914D\u7F6E\u5B8C\u6210**
|
|
2582
|
-
|
|
2583
|
-
${initResult.message}
|
|
2584
|
-
|
|
2585
|
-
\u73B0\u5728\u53EF\u4EE5\u7EE7\u7EED\u4F7F\u7528 @mta \u8FDB\u884C\u5F00\u53D1\u4E86\uFF01
|
|
2586
|
-
|
|
2587
|
-
\u{1F4A1} \u63D0\u793A\uFF1A\u9879\u76EE\u914D\u7F6E\u6587\u4EF6\u5DF2\u751F\u6210\u5728 .github/copilot-instructions.md`
|
|
2588
|
-
}]
|
|
2589
|
-
};
|
|
2590
|
-
}
|
|
2591
|
-
}
|
|
2592
|
-
let detectedFileType = "unknown";
|
|
2593
|
-
let detectedImports = [];
|
|
2594
|
-
let detectedScenario = "";
|
|
2595
|
-
let analysisSource = "none";
|
|
2596
|
-
if (args.currentFile && fs8.existsSync(args.currentFile)) {
|
|
2597
|
-
analysisSource = "file-path";
|
|
2598
|
-
const ext = ((_a = args.currentFile.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
|
|
2599
|
-
const extMap = {
|
|
2600
|
-
"vue": "vue",
|
|
2601
|
-
"ts": "ts",
|
|
2602
|
-
"tsx": "tsx",
|
|
2603
|
-
"js": "js",
|
|
2604
|
-
"jsx": "jsx"
|
|
2605
|
-
};
|
|
2606
|
-
detectedFileType = extMap[ext] || "unknown";
|
|
2607
|
-
try {
|
|
2608
|
-
const content = fs8.readFileSync(args.currentFile, "utf-8");
|
|
2609
|
-
const imports = extractImports(content);
|
|
2610
|
-
detectedImports = imports;
|
|
2611
|
-
detectedScenario = inferScenario(content, detectedFileType);
|
|
2612
|
-
} catch {
|
|
2613
|
-
logger3.log("\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6\u5185\u5BB9\uFF0C\u4EC5\u4F7F\u7528\u6587\u4EF6\u7C7B\u578B");
|
|
2614
|
-
}
|
|
2615
|
-
}
|
|
2616
|
-
if (args.fileContent) {
|
|
2617
|
-
analysisSource = "file-content";
|
|
2618
|
-
const imports = extractImports(args.fileContent);
|
|
2619
|
-
detectedImports = [...detectedImports, ...imports];
|
|
2620
|
-
if (detectedFileType === "unknown") {
|
|
2621
|
-
if (args.fileContent.includes("<template>")) {
|
|
2622
|
-
detectedFileType = "vue";
|
|
2623
|
-
} else if (args.fileContent.includes("interface ") || args.fileContent.includes("type ")) {
|
|
2624
|
-
detectedFileType = "ts";
|
|
2625
|
-
}
|
|
2626
|
-
}
|
|
2627
|
-
const scenario = inferScenario(args.fileContent, detectedFileType);
|
|
2628
|
-
if (scenario) detectedScenario = scenario;
|
|
2629
|
-
}
|
|
2630
|
-
if (detectedFileType === "unknown") {
|
|
2631
|
-
analysisSource = "environment";
|
|
2632
|
-
const cwd = process.cwd();
|
|
2633
|
-
const packageJsonPath = `${cwd}/package.json`;
|
|
2634
|
-
if (fs8.existsSync(packageJsonPath)) {
|
|
2635
|
-
try {
|
|
2636
|
-
const pkg = JSON.parse(fs8.readFileSync(packageJsonPath, "utf-8"));
|
|
2637
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
2638
|
-
if (deps["vue"]) {
|
|
2639
|
-
detectedFileType = "vue";
|
|
2640
|
-
detectedImports.push("vue");
|
|
2641
|
-
}
|
|
2642
|
-
if (deps["react"]) {
|
|
2643
|
-
detectedFileType = "tsx";
|
|
2644
|
-
detectedImports.push("react");
|
|
2645
|
-
}
|
|
2646
|
-
if (deps["element-plus"]) detectedImports.push("element-plus");
|
|
2647
|
-
if (deps["pinia"]) detectedImports.push("pinia");
|
|
2648
|
-
if (deps["vue-i18n"]) detectedImports.push("vue-i18n");
|
|
2649
|
-
} catch {
|
|
2650
|
-
logger3.log("\u65E0\u6CD5\u89E3\u6790 package.json");
|
|
2651
|
-
}
|
|
2652
|
-
}
|
|
2653
|
-
}
|
|
2654
|
-
detectedImports = [...new Set(detectedImports)];
|
|
2655
|
-
logger3.log(`\u{1F50D} \u667A\u80FD\u68C0\u6D4B\u7ED3\u679C: fileType=${detectedFileType}, imports=${detectedImports.join(",")}, scenario=${detectedScenario}`);
|
|
2656
|
-
const standards = manager.getRelevantStandards({
|
|
2657
|
-
fileType: detectedFileType !== "unknown" ? detectedFileType : void 0,
|
|
2658
|
-
imports: detectedImports.length > 0 ? detectedImports : void 0,
|
|
2659
|
-
scenario: detectedScenario || void 0
|
|
2660
|
-
});
|
|
2661
|
-
const combinedContent = manager.combineStandards(standards);
|
|
2662
|
-
return {
|
|
2663
|
-
content: [{
|
|
2664
|
-
type: "text",
|
|
2665
|
-
text: JSON.stringify({
|
|
2666
|
-
success: true,
|
|
2667
|
-
analysis: {
|
|
2668
|
-
source: analysisSource,
|
|
2669
|
-
fileType: detectedFileType,
|
|
2670
|
-
imports: detectedImports,
|
|
2671
|
-
scenario: detectedScenario
|
|
2672
|
-
},
|
|
2673
|
-
standards,
|
|
2674
|
-
content: combinedContent,
|
|
2675
|
-
stats: {
|
|
2676
|
-
standardsCount: standards.length,
|
|
2677
|
-
contentLength: combinedContent.length,
|
|
2678
|
-
estimatedTokens: Math.ceil(combinedContent.length / 4)
|
|
2679
|
-
}
|
|
2680
|
-
}, null, 2)
|
|
2681
|
-
}]
|
|
2682
|
-
};
|
|
2683
|
-
} catch (error) {
|
|
2684
|
-
logger3.error(`\u667A\u80FD\u89C4\u8303\u63A8\u8350\u5931\u8D25: ${error}`);
|
|
2685
|
-
return {
|
|
2686
|
-
content: [{
|
|
2687
|
-
type: "text",
|
|
2688
|
-
text: JSON.stringify({
|
|
2689
|
-
error: error instanceof Error ? error.message : String(error)
|
|
2690
|
-
}, null, 2)
|
|
2691
|
-
}]
|
|
2692
|
-
};
|
|
2693
|
-
}
|
|
2694
|
-
}
|
|
2695
|
-
function extractImports(content) {
|
|
2696
|
-
const imports = [];
|
|
2697
|
-
const es6Regex = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
|
|
2698
|
-
let match;
|
|
2699
|
-
while ((match = es6Regex.exec(content)) !== null) {
|
|
2700
|
-
const pkg = match[1];
|
|
2701
|
-
if (!pkg.startsWith(".") && !pkg.startsWith("/")) {
|
|
2702
|
-
imports.push(pkg.split("/")[0]);
|
|
2703
|
-
}
|
|
2704
|
-
}
|
|
2705
|
-
const requireRegex = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
2706
|
-
while ((match = requireRegex.exec(content)) !== null) {
|
|
2707
|
-
const pkg = match[1];
|
|
2708
|
-
if (!pkg.startsWith(".") && !pkg.startsWith("/")) {
|
|
2709
|
-
imports.push(pkg.split("/")[0]);
|
|
2710
|
-
}
|
|
2711
|
-
}
|
|
2712
|
-
return [...new Set(imports)];
|
|
2713
|
-
}
|
|
2714
|
-
function inferScenario(content, fileType) {
|
|
2715
|
-
const scenarios = [];
|
|
2716
|
-
if (fileType === "vue") {
|
|
2717
|
-
if (content.includes("ElForm") || content.includes("<el-form")) {
|
|
2718
|
-
scenarios.push("\u8868\u5355\u7EC4\u4EF6");
|
|
2719
|
-
}
|
|
2720
|
-
if (content.includes("ElTable") || content.includes("<el-table")) {
|
|
2721
|
-
scenarios.push("\u8868\u683C\u7EC4\u4EF6");
|
|
2722
|
-
}
|
|
2723
|
-
if (content.includes("defineStore")) {
|
|
2724
|
-
scenarios.push("\u72B6\u6001\u7BA1\u7406");
|
|
2725
|
-
}
|
|
2726
|
-
if (content.includes("useI18n") || content.includes("$t(")) {
|
|
2727
|
-
scenarios.push("\u56FD\u9645\u5316");
|
|
2728
|
-
}
|
|
2729
|
-
}
|
|
2730
|
-
if (content.includes("fetch(") || content.includes("axios.")) {
|
|
2731
|
-
scenarios.push("API \u8C03\u7528");
|
|
2732
|
-
}
|
|
2733
|
-
if (content.includes("interface ") || content.includes("type ")) {
|
|
2734
|
-
scenarios.push("\u7C7B\u578B\u5B9A\u4E49");
|
|
2735
|
-
}
|
|
2736
|
-
return scenarios.join("\u3001");
|
|
2737
|
-
}
|
|
2738
|
-
|
|
2739
2396
|
// src/tools/usePreset.ts
|
|
2740
2397
|
var PRESETS = {
|
|
2741
2398
|
"vue3-component": {
|
|
@@ -2883,11 +2540,28 @@ async function listPresets() {
|
|
|
2883
2540
|
}
|
|
2884
2541
|
|
|
2885
2542
|
// src/tools/healthCheck.ts
|
|
2886
|
-
import * as
|
|
2887
|
-
import * as
|
|
2543
|
+
import * as fs7 from "fs";
|
|
2544
|
+
import * as path7 from "path";
|
|
2888
2545
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
2889
2546
|
var __filename3 = fileURLToPath3(import.meta.url);
|
|
2890
|
-
var __dirname4 =
|
|
2547
|
+
var __dirname4 = path7.dirname(__filename3);
|
|
2548
|
+
function getServerRoot() {
|
|
2549
|
+
const possibleRoots = [
|
|
2550
|
+
path7.resolve(__dirname4, "../.."),
|
|
2551
|
+
// 从 dist/tools/ 向上两级
|
|
2552
|
+
path7.resolve(__dirname4, "../../.."),
|
|
2553
|
+
// npm 包场景
|
|
2554
|
+
path7.resolve(process.cwd())
|
|
2555
|
+
// 当前工作目录
|
|
2556
|
+
];
|
|
2557
|
+
for (const root of possibleRoots) {
|
|
2558
|
+
const standardsPath = path7.join(root, "standards");
|
|
2559
|
+
if (fs7.existsSync(standardsPath)) {
|
|
2560
|
+
return root;
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
return possibleRoots[0];
|
|
2564
|
+
}
|
|
2891
2565
|
async function healthCheck(args) {
|
|
2892
2566
|
var _a, _b, _c, _d;
|
|
2893
2567
|
const logger3 = new ConsoleLogger();
|
|
@@ -2912,14 +2586,14 @@ async function healthCheck(args) {
|
|
|
2912
2586
|
}
|
|
2913
2587
|
logger3.log("\u{1F50D} \u68C0\u67E5\u914D\u7F6E\u6587\u4EF6...");
|
|
2914
2588
|
const workspacePath = args.workspacePath || process.cwd();
|
|
2915
|
-
const vscodeDir =
|
|
2916
|
-
if (
|
|
2589
|
+
const vscodeDir = path7.join(workspacePath, ".vscode");
|
|
2590
|
+
if (fs7.existsSync(vscodeDir)) {
|
|
2917
2591
|
checks.workspace.status = "healthy";
|
|
2918
2592
|
checks.workspace.details.push(`\u2705 \u5DE5\u4F5C\u533A\u8DEF\u5F84: ${workspacePath}`);
|
|
2919
|
-
const mcpJsonPath =
|
|
2920
|
-
if (
|
|
2593
|
+
const mcpJsonPath = path7.join(vscodeDir, "mcp.json");
|
|
2594
|
+
if (fs7.existsSync(mcpJsonPath)) {
|
|
2921
2595
|
try {
|
|
2922
|
-
const config = JSON.parse(
|
|
2596
|
+
const config = JSON.parse(fs7.readFileSync(mcpJsonPath, "utf-8"));
|
|
2923
2597
|
const hasNewFormat = (_a = config.servers) == null ? void 0 : _a["copilot-prompts"];
|
|
2924
2598
|
const hasOldFormat = (_b = config.mcpServers) == null ? void 0 : _b["copilot-prompts"];
|
|
2925
2599
|
if (hasNewFormat) {
|
|
@@ -2962,10 +2636,10 @@ async function healthCheck(args) {
|
|
|
2962
2636
|
checks.configuration.details.push("\u26A0\uFE0F mcp.json \u4E0D\u5B58\u5728");
|
|
2963
2637
|
checks.configuration.details.push("\u{1F4A1} \u5EFA\u8BAE: \u8FD0\u884C auto_setup \u5DE5\u5177\u81EA\u52A8\u914D\u7F6E");
|
|
2964
2638
|
}
|
|
2965
|
-
const settingsPath =
|
|
2966
|
-
if (
|
|
2639
|
+
const settingsPath = path7.join(vscodeDir, "settings.json");
|
|
2640
|
+
if (fs7.existsSync(settingsPath)) {
|
|
2967
2641
|
try {
|
|
2968
|
-
const settings = JSON.parse(
|
|
2642
|
+
const settings = JSON.parse(fs7.readFileSync(settingsPath, "utf-8"));
|
|
2969
2643
|
if (settings["github.copilot.chat.mcp.enabled"] === true) {
|
|
2970
2644
|
checks.configuration.details.push("\u2705 VS Code MCP \u5DF2\u542F\u7528");
|
|
2971
2645
|
} else {
|
|
@@ -2978,13 +2652,14 @@ async function healthCheck(args) {
|
|
|
2978
2652
|
} else {
|
|
2979
2653
|
checks.workspace.status = "error";
|
|
2980
2654
|
checks.workspace.details.push("\u274C .vscode \u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
2655
|
+
checks.workspace.details.push("\u{1F4A1} \u5EFA\u8BAE: \u8FD0\u884C auto_setup \u5DE5\u5177\u81EA\u52A8\u521B\u5EFA\u914D\u7F6E");
|
|
2981
2656
|
}
|
|
2982
2657
|
logger3.log("\u{1F50D} \u68C0\u67E5\u4F9D\u8D56...");
|
|
2983
|
-
const serverRoot =
|
|
2984
|
-
const packageJsonPath =
|
|
2985
|
-
if (
|
|
2658
|
+
const serverRoot = getServerRoot();
|
|
2659
|
+
const packageJsonPath = path7.join(serverRoot, "package.json");
|
|
2660
|
+
if (fs7.existsSync(packageJsonPath)) {
|
|
2986
2661
|
try {
|
|
2987
|
-
const pkg = JSON.parse(
|
|
2662
|
+
const pkg = JSON.parse(fs7.readFileSync(packageJsonPath, "utf-8"));
|
|
2988
2663
|
checks.dependencies.status = "healthy";
|
|
2989
2664
|
checks.dependencies.details.push(`\u2705 \u670D\u52A1\u5668\u7248\u672C: ${pkg.version}`);
|
|
2990
2665
|
if (verbose && pkg.dependencies) {
|
|
@@ -3008,14 +2683,14 @@ async function healthCheck(args) {
|
|
|
3008
2683
|
}
|
|
3009
2684
|
}
|
|
3010
2685
|
logger3.log("\u{1F50D} \u68C0\u67E5\u89C4\u8303\u6587\u4EF6...");
|
|
3011
|
-
const standardsDir =
|
|
3012
|
-
if (
|
|
2686
|
+
const standardsDir = path7.join(serverRoot, "standards");
|
|
2687
|
+
if (fs7.existsSync(standardsDir)) {
|
|
3013
2688
|
const categories = ["core", "frameworks", "libraries", "patterns"];
|
|
3014
2689
|
const foundStandards = [];
|
|
3015
2690
|
for (const category of categories) {
|
|
3016
|
-
const categoryPath =
|
|
3017
|
-
if (
|
|
3018
|
-
const files =
|
|
2691
|
+
const categoryPath = path7.join(standardsDir, category);
|
|
2692
|
+
if (fs7.existsSync(categoryPath)) {
|
|
2693
|
+
const files = fs7.readdirSync(categoryPath).filter((f) => f.endsWith(".md"));
|
|
3019
2694
|
foundStandards.push(...files.map((f) => `${category}/${f}`));
|
|
3020
2695
|
}
|
|
3021
2696
|
}
|
|
@@ -3092,7 +2767,7 @@ function generateRecommendations(checks) {
|
|
|
3092
2767
|
}
|
|
3093
2768
|
|
|
3094
2769
|
// src/tools/getCompactStandards.ts
|
|
3095
|
-
import * as
|
|
2770
|
+
import * as fs8 from "fs";
|
|
3096
2771
|
async function getCompactStandards(args) {
|
|
3097
2772
|
const logger3 = new ConsoleLogger();
|
|
3098
2773
|
const manager = new StandardsManager();
|
|
@@ -3139,7 +2814,7 @@ function detectContext(args, logger3) {
|
|
|
3139
2814
|
let fileType = "unknown";
|
|
3140
2815
|
let imports = [];
|
|
3141
2816
|
let scenario = "";
|
|
3142
|
-
if (args.currentFile &&
|
|
2817
|
+
if (args.currentFile && fs8.existsSync(args.currentFile)) {
|
|
3143
2818
|
const ext = ((_a = args.currentFile.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
|
|
3144
2819
|
const extMap = {
|
|
3145
2820
|
"vue": "vue",
|
|
@@ -3151,19 +2826,19 @@ function detectContext(args, logger3) {
|
|
|
3151
2826
|
};
|
|
3152
2827
|
fileType = extMap[ext] || "unknown";
|
|
3153
2828
|
try {
|
|
3154
|
-
const content =
|
|
3155
|
-
imports =
|
|
3156
|
-
scenario =
|
|
2829
|
+
const content = fs8.readFileSync(args.currentFile, "utf-8");
|
|
2830
|
+
imports = extractImports(content);
|
|
2831
|
+
scenario = inferScenario(content, fileType);
|
|
3157
2832
|
} catch {
|
|
3158
2833
|
}
|
|
3159
2834
|
}
|
|
3160
2835
|
if (args.fileContent) {
|
|
3161
|
-
imports = [...imports, ...
|
|
2836
|
+
imports = [...imports, ...extractImports(args.fileContent)];
|
|
3162
2837
|
if (fileType === "unknown") {
|
|
3163
2838
|
if (args.fileContent.includes("<template>")) fileType = "vue";
|
|
3164
2839
|
else if (args.fileContent.includes("interface ")) fileType = "ts";
|
|
3165
2840
|
}
|
|
3166
|
-
scenario = scenario ||
|
|
2841
|
+
scenario = scenario || inferScenario(args.fileContent, fileType);
|
|
3167
2842
|
}
|
|
3168
2843
|
return { fileType, imports: [...new Set(imports)], scenario };
|
|
3169
2844
|
}
|
|
@@ -3393,7 +3068,7 @@ function getFlutterKeyRules() {
|
|
|
3393
3068
|
- \u274C \`Colors.blue\` Material \u989C\u8272\u5E38\u91CF`
|
|
3394
3069
|
];
|
|
3395
3070
|
}
|
|
3396
|
-
function
|
|
3071
|
+
function extractImports(content) {
|
|
3397
3072
|
const imports = [];
|
|
3398
3073
|
const esImportRegex = /import\s+(?:(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
3399
3074
|
let match;
|
|
@@ -3406,7 +3081,7 @@ function extractImports2(content) {
|
|
|
3406
3081
|
}
|
|
3407
3082
|
return imports;
|
|
3408
3083
|
}
|
|
3409
|
-
function
|
|
3084
|
+
function inferScenario(content, fileType) {
|
|
3410
3085
|
const scenarios = [];
|
|
3411
3086
|
const lower = content.toLowerCase();
|
|
3412
3087
|
if (lower.includes("el-table") || lower.includes("el-form")) {
|
|
@@ -3422,8 +3097,8 @@ function inferScenario2(content, fileType) {
|
|
|
3422
3097
|
}
|
|
3423
3098
|
|
|
3424
3099
|
// src/tools/getStandardById.ts
|
|
3425
|
-
import * as
|
|
3426
|
-
import * as
|
|
3100
|
+
import * as fs9 from "fs";
|
|
3101
|
+
import * as path8 from "path";
|
|
3427
3102
|
var STANDARD_DIRS = [
|
|
3428
3103
|
"standards/core",
|
|
3429
3104
|
"standards/frameworks",
|
|
@@ -3461,7 +3136,7 @@ async function getStandardById(args) {
|
|
|
3461
3136
|
continue;
|
|
3462
3137
|
}
|
|
3463
3138
|
try {
|
|
3464
|
-
const fullContent =
|
|
3139
|
+
const fullContent = fs9.readFileSync(filePath, "utf-8");
|
|
3465
3140
|
const content = formatContent(fullContent, mode);
|
|
3466
3141
|
results.push({
|
|
3467
3142
|
id,
|
|
@@ -3518,33 +3193,33 @@ function ensureCache() {
|
|
|
3518
3193
|
standardsCache = /* @__PURE__ */ new Map();
|
|
3519
3194
|
const baseDir = findBaseDir();
|
|
3520
3195
|
for (const dir of STANDARD_DIRS) {
|
|
3521
|
-
const fullDir =
|
|
3522
|
-
if (!
|
|
3196
|
+
const fullDir = path8.join(baseDir, dir);
|
|
3197
|
+
if (!fs9.existsSync(fullDir)) continue;
|
|
3523
3198
|
scanDirectory(fullDir, standardsCache);
|
|
3524
3199
|
}
|
|
3525
3200
|
}
|
|
3526
3201
|
function findBaseDir() {
|
|
3527
3202
|
const possiblePaths = [
|
|
3528
3203
|
process.cwd(),
|
|
3529
|
-
|
|
3530
|
-
|
|
3204
|
+
path8.join(process.cwd(), ".."),
|
|
3205
|
+
path8.join(__dirname, "..", "..", "..")
|
|
3531
3206
|
];
|
|
3532
3207
|
for (const p of possiblePaths) {
|
|
3533
|
-
if (
|
|
3208
|
+
if (fs9.existsSync(path8.join(p, "standards"))) {
|
|
3534
3209
|
return p;
|
|
3535
3210
|
}
|
|
3536
3211
|
}
|
|
3537
3212
|
return process.cwd();
|
|
3538
3213
|
}
|
|
3539
3214
|
function scanDirectory(dir, cache) {
|
|
3540
|
-
const items =
|
|
3215
|
+
const items = fs9.readdirSync(dir);
|
|
3541
3216
|
for (const item of items) {
|
|
3542
|
-
const fullPath =
|
|
3543
|
-
const stat =
|
|
3217
|
+
const fullPath = path8.join(dir, item);
|
|
3218
|
+
const stat = fs9.statSync(fullPath);
|
|
3544
3219
|
if (stat.isDirectory()) {
|
|
3545
3220
|
scanDirectory(fullPath, cache);
|
|
3546
3221
|
} else if (item.endsWith(".md")) {
|
|
3547
|
-
const id =
|
|
3222
|
+
const id = path8.basename(item, ".md");
|
|
3548
3223
|
cache.set(id, fullPath);
|
|
3549
3224
|
}
|
|
3550
3225
|
}
|
|
@@ -3787,10 +3462,10 @@ async function listScenarios() {
|
|
|
3787
3462
|
}
|
|
3788
3463
|
|
|
3789
3464
|
// src/core/templates/discovery.ts
|
|
3790
|
-
import * as
|
|
3791
|
-
import * as
|
|
3792
|
-
var TEMPLATES_DIR =
|
|
3793
|
-
|
|
3465
|
+
import * as fs10 from "fs";
|
|
3466
|
+
import * as path9 from "path";
|
|
3467
|
+
var TEMPLATES_DIR = path9.resolve(
|
|
3468
|
+
path9.dirname(new URL(import.meta.url).pathname),
|
|
3794
3469
|
"../../../../templates"
|
|
3795
3470
|
);
|
|
3796
3471
|
var templatesCache = null;
|
|
@@ -3800,15 +3475,15 @@ function ensureCache2() {
|
|
|
3800
3475
|
scanTemplates(TEMPLATES_DIR, "");
|
|
3801
3476
|
}
|
|
3802
3477
|
function scanTemplates(dir, prefix) {
|
|
3803
|
-
if (!
|
|
3804
|
-
const entries =
|
|
3478
|
+
if (!fs10.existsSync(dir)) return;
|
|
3479
|
+
const entries = fs10.readdirSync(dir, { withFileTypes: true });
|
|
3805
3480
|
for (const entry of entries) {
|
|
3806
3481
|
if (!entry.isDirectory()) continue;
|
|
3807
3482
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
3808
|
-
const fullPath =
|
|
3483
|
+
const fullPath = path9.join(dir, entry.name);
|
|
3809
3484
|
const templateId = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
3810
|
-
const configPath =
|
|
3811
|
-
if (
|
|
3485
|
+
const configPath = path9.join(fullPath, "_CONFIG.md");
|
|
3486
|
+
if (fs10.existsSync(configPath)) {
|
|
3812
3487
|
const metadata = parseConfigMd(configPath, templateId, fullPath);
|
|
3813
3488
|
if (metadata) {
|
|
3814
3489
|
templatesCache.set(templateId, metadata);
|
|
@@ -3819,7 +3494,7 @@ function scanTemplates(dir, prefix) {
|
|
|
3819
3494
|
}
|
|
3820
3495
|
function parseConfigMd(configPath, templateId, templateDir) {
|
|
3821
3496
|
try {
|
|
3822
|
-
const content =
|
|
3497
|
+
const content = fs10.readFileSync(configPath, "utf-8");
|
|
3823
3498
|
const titleMatch = content.match(/^#\s+(.+)$/m);
|
|
3824
3499
|
const name = titleMatch ? titleMatch[1].trim() : templateId;
|
|
3825
3500
|
const descMatch = content.match(/^>\s*(.+)$/m);
|
|
@@ -3862,14 +3537,14 @@ function inferTemplateType(templateId, name) {
|
|
|
3862
3537
|
}
|
|
3863
3538
|
function getTemplateFiles(dir, prefix = "") {
|
|
3864
3539
|
const files = [];
|
|
3865
|
-
const entries =
|
|
3540
|
+
const entries = fs10.readdirSync(dir, { withFileTypes: true });
|
|
3866
3541
|
for (const entry of entries) {
|
|
3867
3542
|
const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
3868
3543
|
if (entry.name === "_CONFIG.md" || entry.name === "_template.json") {
|
|
3869
3544
|
continue;
|
|
3870
3545
|
}
|
|
3871
3546
|
if (entry.isDirectory()) {
|
|
3872
|
-
files.push(...getTemplateFiles(
|
|
3547
|
+
files.push(...getTemplateFiles(path9.join(dir, entry.name), relativePath));
|
|
3873
3548
|
} else {
|
|
3874
3549
|
files.push(relativePath);
|
|
3875
3550
|
}
|
|
@@ -3924,9 +3599,9 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3924
3599
|
ensureCache2();
|
|
3925
3600
|
const metadata = templatesCache.get(templateId);
|
|
3926
3601
|
if (!metadata) return null;
|
|
3927
|
-
const templateDir =
|
|
3928
|
-
const configPath =
|
|
3929
|
-
const configGuide =
|
|
3602
|
+
const templateDir = path9.join(TEMPLATES_DIR, templateId);
|
|
3603
|
+
const configPath = path9.join(templateDir, "_CONFIG.md");
|
|
3604
|
+
const configGuide = fs10.existsSync(configPath) ? fs10.readFileSync(configPath, "utf-8") : "";
|
|
3930
3605
|
const result = {
|
|
3931
3606
|
metadata,
|
|
3932
3607
|
configGuide
|
|
@@ -3934,11 +3609,11 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3934
3609
|
if (includeFiles) {
|
|
3935
3610
|
result.files = [];
|
|
3936
3611
|
for (const filePath of metadata.files) {
|
|
3937
|
-
const fullPath =
|
|
3938
|
-
if (
|
|
3612
|
+
const fullPath = path9.join(templateDir, filePath);
|
|
3613
|
+
if (fs10.existsSync(fullPath)) {
|
|
3939
3614
|
result.files.push({
|
|
3940
3615
|
path: filePath,
|
|
3941
|
-
content:
|
|
3616
|
+
content: fs10.readFileSync(fullPath, "utf-8"),
|
|
3942
3617
|
isConfig: filePath.startsWith("_")
|
|
3943
3618
|
});
|
|
3944
3619
|
}
|
|
@@ -3949,7 +3624,7 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3949
3624
|
function getTemplateDir(templateId) {
|
|
3950
3625
|
ensureCache2();
|
|
3951
3626
|
if (!templatesCache.has(templateId)) return null;
|
|
3952
|
-
return
|
|
3627
|
+
return path9.join(TEMPLATES_DIR, templateId);
|
|
3953
3628
|
}
|
|
3954
3629
|
function searchTemplates(query) {
|
|
3955
3630
|
const lower = query.toLowerCase();
|
|
@@ -4234,8 +3909,86 @@ function createLogger(name) {
|
|
|
4234
3909
|
return new Logger(name);
|
|
4235
3910
|
}
|
|
4236
3911
|
|
|
3912
|
+
// src/core/autoConfig.ts
|
|
3913
|
+
import * as fs11 from "fs";
|
|
3914
|
+
import * as path10 from "path";
|
|
3915
|
+
var checkedWorkspaces = /* @__PURE__ */ new Map();
|
|
3916
|
+
var CACHE_DURATION = 5 * 60 * 1e3;
|
|
3917
|
+
function ensureWorkspaceConfig(workspacePath) {
|
|
3918
|
+
var _a, _b;
|
|
3919
|
+
const result = {
|
|
3920
|
+
needsSetup: false,
|
|
3921
|
+
wasFixed: false,
|
|
3922
|
+
workspacePath
|
|
3923
|
+
};
|
|
3924
|
+
if (!workspacePath || !fs11.existsSync(workspacePath)) {
|
|
3925
|
+
return result;
|
|
3926
|
+
}
|
|
3927
|
+
const cached = checkedWorkspaces.get(workspacePath);
|
|
3928
|
+
const now = Date.now();
|
|
3929
|
+
if (cached && cached.configured && now - cached.timestamp < CACHE_DURATION) {
|
|
3930
|
+
return result;
|
|
3931
|
+
}
|
|
3932
|
+
const vscodeDir = path10.join(workspacePath, ".vscode");
|
|
3933
|
+
const mcpJsonPath = path10.join(vscodeDir, "mcp.json");
|
|
3934
|
+
const settingsPath = path10.join(vscodeDir, "settings.json");
|
|
3935
|
+
let hasMtaConfig = false;
|
|
3936
|
+
if (fs11.existsSync(mcpJsonPath)) {
|
|
3937
|
+
try {
|
|
3938
|
+
const config = JSON.parse(fs11.readFileSync(mcpJsonPath, "utf-8"));
|
|
3939
|
+
hasMtaConfig = !!(((_a = config.servers) == null ? void 0 : _a.mta) || ((_b = config.mcpServers) == null ? void 0 : _b.mta));
|
|
3940
|
+
} catch {
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
if (hasMtaConfig) {
|
|
3944
|
+
checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
|
|
3945
|
+
return result;
|
|
3946
|
+
}
|
|
3947
|
+
result.needsSetup = true;
|
|
3948
|
+
try {
|
|
3949
|
+
if (!fs11.existsSync(vscodeDir)) {
|
|
3950
|
+
fs11.mkdirSync(vscodeDir, { recursive: true });
|
|
3951
|
+
}
|
|
3952
|
+
let mcpConfig = { servers: {} };
|
|
3953
|
+
if (fs11.existsSync(mcpJsonPath)) {
|
|
3954
|
+
try {
|
|
3955
|
+
mcpConfig = JSON.parse(fs11.readFileSync(mcpJsonPath, "utf-8"));
|
|
3956
|
+
if (!mcpConfig.servers) {
|
|
3957
|
+
mcpConfig.servers = {};
|
|
3958
|
+
}
|
|
3959
|
+
} catch {
|
|
3960
|
+
mcpConfig = { servers: {} };
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
mcpConfig.servers.mta = {
|
|
3964
|
+
command: "npx",
|
|
3965
|
+
args: ["-y", "mta-mcp"],
|
|
3966
|
+
env: {}
|
|
3967
|
+
};
|
|
3968
|
+
fs11.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
3969
|
+
let settings = {};
|
|
3970
|
+
if (fs11.existsSync(settingsPath)) {
|
|
3971
|
+
try {
|
|
3972
|
+
settings = JSON.parse(fs11.readFileSync(settingsPath, "utf-8"));
|
|
3973
|
+
} catch {
|
|
3974
|
+
settings = {};
|
|
3975
|
+
}
|
|
3976
|
+
}
|
|
3977
|
+
if (!settings["github.copilot.chat.mcp.enabled"]) {
|
|
3978
|
+
settings["github.copilot.chat.mcp.enabled"] = true;
|
|
3979
|
+
fs11.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
3980
|
+
}
|
|
3981
|
+
result.wasFixed = true;
|
|
3982
|
+
result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${path10.basename(workspacePath)} \u914D\u7F6E MTA MCP\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3\u4F7F\u914D\u7F6E\u751F\u6548\u3002`;
|
|
3983
|
+
checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
|
|
3984
|
+
} catch (error) {
|
|
3985
|
+
result.message = `\u26A0\uFE0F \u81EA\u52A8\u914D\u7F6E\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`;
|
|
3986
|
+
}
|
|
3987
|
+
return result;
|
|
3988
|
+
}
|
|
3989
|
+
|
|
4237
3990
|
// src/index.ts
|
|
4238
|
-
var SERVER_VERSION = "2.
|
|
3991
|
+
var SERVER_VERSION = "2.6.0";
|
|
4239
3992
|
var logger2 = createLogger("Server");
|
|
4240
3993
|
var CopilotPromptsMCPServer = class {
|
|
4241
3994
|
constructor() {
|
|
@@ -4288,38 +4041,39 @@ var CopilotPromptsMCPServer = class {
|
|
|
4288
4041
|
tools: [
|
|
4289
4042
|
{
|
|
4290
4043
|
name: "analyze_project",
|
|
4291
|
-
description: "\u5206\u6790\u9879\u76EE\
|
|
4044
|
+
description: "\u5206\u6790\u9879\u76EE\u6280\u672F\u6808\u3001\u6846\u67B6\u3001\u5DE5\u5177\u548C\u7279\u5F81",
|
|
4292
4045
|
inputSchema: {
|
|
4293
4046
|
type: "object",
|
|
4294
4047
|
properties: {
|
|
4295
4048
|
projectPath: {
|
|
4296
4049
|
type: "string",
|
|
4297
|
-
description: "\u9879\u76EE\
|
|
4050
|
+
description: "\u9879\u76EE\u7EDD\u5BF9\u8DEF\u5F84\uFF08\u53EF\u9009\uFF09"
|
|
4298
4051
|
}
|
|
4299
4052
|
}
|
|
4300
4053
|
}
|
|
4301
4054
|
},
|
|
4302
4055
|
{
|
|
4303
4056
|
name: "auto_setup",
|
|
4304
|
-
description:
|
|
4057
|
+
description: '\u3010\u914D\u7F6E MTA\u3011\u5F53\u7528\u6237\u8BF4"\u914D\u7F6E MTA"\u3001"\u8BBE\u7F6E MCP"\u3001"MTA \u4E0D\u5DE5\u4F5C"\u65F6\u8C03\u7528\u6B64\u5DE5\u5177\u3002\u81EA\u52A8\u521B\u5EFA .vscode/mcp.json \u548C settings.json\uFF0C\u914D\u7F6E\u5B8C\u6210\u540E\u9700\u63D0\u793A\u7528\u6237\u91CD\u65B0\u52A0\u8F7D\u7A97\u53E3',
|
|
4305
4058
|
inputSchema: {
|
|
4306
4059
|
type: "object",
|
|
4307
4060
|
properties: {
|
|
4308
4061
|
workspacePath: {
|
|
4309
4062
|
type: "string",
|
|
4310
|
-
description: "\u5DE5\u4F5C\u533A\u8DEF\u5F84\uFF08\
|
|
4063
|
+
description: "\u5DE5\u4F5C\u533A\u7EDD\u5BF9\u8DEF\u5F84\uFF08\u5FC5\u987B\u63D0\u4F9B\uFF09"
|
|
4311
4064
|
},
|
|
4312
4065
|
generateInstructions: {
|
|
4313
4066
|
type: "boolean",
|
|
4314
|
-
description: "\u662F\u5426\
|
|
4067
|
+
description: "\u662F\u5426\u751F\u6210 copilot-instructions.md",
|
|
4315
4068
|
default: true
|
|
4316
4069
|
}
|
|
4317
|
-
}
|
|
4070
|
+
},
|
|
4071
|
+
required: ["workspacePath"]
|
|
4318
4072
|
}
|
|
4319
4073
|
},
|
|
4320
4074
|
{
|
|
4321
4075
|
name: "health_check",
|
|
4322
|
-
description: "\
|
|
4076
|
+
description: "\u68C0\u67E5 MCP \u670D\u52A1\u5668\u72B6\u6001\u548C\u914D\u7F6E\u95EE\u9898\uFF0C\u8FD4\u56DE\u8BCA\u65AD\u62A5\u544A\u548C\u4FEE\u590D\u5EFA\u8BAE",
|
|
4323
4077
|
inputSchema: {
|
|
4324
4078
|
type: "object",
|
|
4325
4079
|
properties: {
|
|
@@ -4329,31 +4083,14 @@ var CopilotPromptsMCPServer = class {
|
|
|
4329
4083
|
},
|
|
4330
4084
|
verbose: {
|
|
4331
4085
|
type: "boolean",
|
|
4332
|
-
description: "\
|
|
4333
|
-
}
|
|
4334
|
-
}
|
|
4335
|
-
}
|
|
4336
|
-
},
|
|
4337
|
-
{
|
|
4338
|
-
name: "get_smart_standards",
|
|
4339
|
-
description: "\u{1F9E0} \u96F6\u53C2\u6570\u667A\u80FD\u89C4\u8303\u63A8\u8350\u3002\u81EA\u52A8\u68C0\u6D4B\u5F53\u524D\u6587\u4EF6\u7C7B\u578B\u3001\u5BFC\u5165\u3001\u573A\u666F\uFF0C\u63A8\u8350\u6700\u76F8\u5173\u7684\u7F16\u7801\u89C4\u8303\u3002\u6BD4\u624B\u52A8\u6307\u5B9A\u53C2\u6570\u66F4\u7B80\u5355\u3002",
|
|
4340
|
-
inputSchema: {
|
|
4341
|
-
type: "object",
|
|
4342
|
-
properties: {
|
|
4343
|
-
currentFile: {
|
|
4344
|
-
type: "string",
|
|
4345
|
-
description: "\u5F53\u524D\u7F16\u8F91\u7684\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009\uFF09"
|
|
4346
|
-
},
|
|
4347
|
-
fileContent: {
|
|
4348
|
-
type: "string",
|
|
4349
|
-
description: "\u6587\u4EF6\u5185\u5BB9\uFF08\u53EF\u9009\uFF0C\u7528\u4E8E\u5206\u6790\u5BFC\u5165\u548C\u573A\u666F\uFF09"
|
|
4086
|
+
description: "\u663E\u793A\u8BE6\u7EC6\u4FE1\u606F"
|
|
4350
4087
|
}
|
|
4351
4088
|
}
|
|
4352
4089
|
}
|
|
4353
4090
|
},
|
|
4354
4091
|
{
|
|
4355
4092
|
name: "use_preset",
|
|
4356
|
-
description: "\
|
|
4093
|
+
description: "\u6309\u9884\u8BBE\u573A\u666F\u83B7\u53D6\u89C4\u8303\uFF08vue3-component\u3001api-call\u3001pinia-store \u7B49\uFF09",
|
|
4357
4094
|
inputSchema: {
|
|
4358
4095
|
type: "object",
|
|
4359
4096
|
properties: {
|
|
@@ -4365,7 +4102,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4365
4102
|
customImports: {
|
|
4366
4103
|
type: "array",
|
|
4367
4104
|
items: { type: "string" },
|
|
4368
|
-
description: "\u989D\u5916\
|
|
4105
|
+
description: "\u989D\u5916\u5BFC\u5165\uFF08\u53EF\u9009\uFF09"
|
|
4369
4106
|
}
|
|
4370
4107
|
},
|
|
4371
4108
|
required: ["preset"]
|
|
@@ -4373,7 +4110,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4373
4110
|
},
|
|
4374
4111
|
{
|
|
4375
4112
|
name: "list_presets",
|
|
4376
|
-
description: "\
|
|
4113
|
+
description: "\u5217\u51FA\u6240\u6709\u9884\u8BBE\u573A\u666F",
|
|
4377
4114
|
inputSchema: {
|
|
4378
4115
|
type: "object",
|
|
4379
4116
|
properties: {}
|
|
@@ -4381,13 +4118,13 @@ var CopilotPromptsMCPServer = class {
|
|
|
4381
4118
|
},
|
|
4382
4119
|
{
|
|
4383
4120
|
name: "match_agents",
|
|
4384
|
-
description: "\u6839\u636E\u9879\u76EE\u7279\u5F81\
|
|
4121
|
+
description: "\u6839\u636E\u9879\u76EE\u7279\u5F81\u5339\u914D Copilot Agents",
|
|
4385
4122
|
inputSchema: {
|
|
4386
4123
|
type: "object",
|
|
4387
4124
|
properties: {
|
|
4388
4125
|
projectFeatures: {
|
|
4389
4126
|
type: "object",
|
|
4390
|
-
description: "\u9879\u76EE\u7279\u5F81\
|
|
4127
|
+
description: "\u9879\u76EE\u7279\u5F81\uFF08\u4ECE analyze_project \u83B7\u53D6\uFF09",
|
|
4391
4128
|
properties: {
|
|
4392
4129
|
frameworks: { type: "array", items: { type: "string" } },
|
|
4393
4130
|
languages: { type: "array", items: { type: "string" } },
|
|
@@ -4399,7 +4136,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4399
4136
|
},
|
|
4400
4137
|
limit: {
|
|
4401
4138
|
type: "number",
|
|
4402
|
-
description: "\u8FD4\u56DE\
|
|
4139
|
+
description: "\u6700\u5927\u8FD4\u56DE\u6570\u91CF",
|
|
4403
4140
|
default: 10
|
|
4404
4141
|
}
|
|
4405
4142
|
},
|
|
@@ -4408,7 +4145,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4408
4145
|
},
|
|
4409
4146
|
{
|
|
4410
4147
|
name: "list_available_agents",
|
|
4411
|
-
description: "\
|
|
4148
|
+
description: "\u5217\u51FA\u6240\u6709\u53EF\u7528\u7684 Copilot Agents",
|
|
4412
4149
|
inputSchema: {
|
|
4413
4150
|
type: "object",
|
|
4414
4151
|
properties: {}
|
|
@@ -4416,33 +4153,33 @@ var CopilotPromptsMCPServer = class {
|
|
|
4416
4153
|
},
|
|
4417
4154
|
{
|
|
4418
4155
|
name: "generate_config",
|
|
4419
|
-
description: "\u4E3A\u9879\u76EE\u751F\u6210
|
|
4156
|
+
description: "\u4E3A\u9879\u76EE\u751F\u6210 copilot-instructions.md \u914D\u7F6E\u6587\u4EF6",
|
|
4420
4157
|
inputSchema: {
|
|
4421
4158
|
type: "object",
|
|
4422
4159
|
properties: {
|
|
4423
4160
|
projectPath: {
|
|
4424
4161
|
type: "string",
|
|
4425
|
-
description: "\u9879\u76EE\
|
|
4162
|
+
description: "\u9879\u76EE\u7EDD\u5BF9\u8DEF\u5F84"
|
|
4426
4163
|
},
|
|
4427
4164
|
agentIds: {
|
|
4428
4165
|
type: "array",
|
|
4429
4166
|
items: { type: "string" },
|
|
4430
|
-
description: "\
|
|
4167
|
+
description: "\u6307\u5B9A Agent ID \u5217\u8868\uFF08\u53EF\u9009\uFF09"
|
|
4431
4168
|
},
|
|
4432
4169
|
autoMatch: {
|
|
4433
4170
|
type: "boolean",
|
|
4434
|
-
description: "\
|
|
4171
|
+
description: "\u81EA\u52A8\u5339\u914D Agents",
|
|
4435
4172
|
default: true
|
|
4436
4173
|
},
|
|
4437
4174
|
updateMode: {
|
|
4438
4175
|
type: "string",
|
|
4439
4176
|
enum: ["merge", "overwrite"],
|
|
4440
|
-
description: "\
|
|
4177
|
+
description: "merge \u4FDD\u7559\u81EA\u5B9A\u4E49\u5185\u5BB9\uFF0Coverwrite \u8986\u76D6",
|
|
4441
4178
|
default: "merge"
|
|
4442
4179
|
},
|
|
4443
4180
|
configId: {
|
|
4444
4181
|
type: "string",
|
|
4445
|
-
description: "\u914D\u7F6E\u65B9\
|
|
4182
|
+
description: "\u914D\u7F6E\u65B9\u6848 ID"
|
|
4446
4183
|
}
|
|
4447
4184
|
},
|
|
4448
4185
|
required: ["projectPath"]
|
|
@@ -4450,7 +4187,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4450
4187
|
},
|
|
4451
4188
|
{
|
|
4452
4189
|
name: "get_compact_standards",
|
|
4453
|
-
description: "\
|
|
4190
|
+
description: "\u83B7\u53D6\u89C4\u8303\uFF08\u652F\u6301 summary/key-rules/full \u4E09\u79CD\u6A21\u5F0F\uFF0C\u9ED8\u8BA4 key-rules\uFF09",
|
|
4454
4191
|
inputSchema: {
|
|
4455
4192
|
type: "object",
|
|
4456
4193
|
properties: {
|
|
@@ -4460,7 +4197,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4460
4197
|
},
|
|
4461
4198
|
fileContent: {
|
|
4462
4199
|
type: "string",
|
|
4463
|
-
description: "\u6587\u4EF6\u5185\u5BB9\uFF08\u53EF\u9009\
|
|
4200
|
+
description: "\u6587\u4EF6\u5185\u5BB9\uFF08\u53EF\u9009\uFF09"
|
|
4464
4201
|
},
|
|
4465
4202
|
scenario: {
|
|
4466
4203
|
type: "string",
|
|
@@ -4469,70 +4206,31 @@ var CopilotPromptsMCPServer = class {
|
|
|
4469
4206
|
mode: {
|
|
4470
4207
|
type: "string",
|
|
4471
4208
|
enum: ["summary", "key-rules", "full"],
|
|
4472
|
-
description: "\u8FD4\u56DE\u6A21\u5F0F
|
|
4209
|
+
description: "\u8FD4\u56DE\u6A21\u5F0F",
|
|
4473
4210
|
default: "key-rules"
|
|
4474
4211
|
}
|
|
4475
4212
|
}
|
|
4476
4213
|
}
|
|
4477
4214
|
},
|
|
4478
|
-
{
|
|
4479
|
-
name: "get_relevant_standards",
|
|
4480
|
-
description: "\u6839\u636E\u5F53\u524D\u5F00\u53D1\u4E0A\u4E0B\u6587\uFF0C\u83B7\u53D6\u76F8\u5173\u7684\u7F16\u7801\u89C4\u8303\uFF08\u5B8C\u6574\u5185\u5BB9\uFF09\u3002\u5982\u9700\u8282\u7701 token\uFF0C\u8BF7\u4F7F\u7528 get_compact_standards\u3002",
|
|
4481
|
-
inputSchema: {
|
|
4482
|
-
type: "object",
|
|
4483
|
-
properties: {
|
|
4484
|
-
fileType: {
|
|
4485
|
-
type: "string",
|
|
4486
|
-
description: "\u6587\u4EF6\u7C7B\u578B\uFF08\u5982 vue, ts, tsx, js\uFF09"
|
|
4487
|
-
},
|
|
4488
|
-
imports: {
|
|
4489
|
-
type: "array",
|
|
4490
|
-
items: { type: "string" },
|
|
4491
|
-
description: '\u6587\u4EF6\u4E2D\u7684 import \u8BED\u53E5\uFF08\u5982 ["vue", "pinia", "element-plus"]\uFF09\u3002\u5982\u679C\u672A\u63D0\u4F9B\u4E14\u63D0\u4F9B\u4E86 fileContent\uFF0C\u5C06\u81EA\u52A8\u68C0\u6D4B\u3002'
|
|
4492
|
-
},
|
|
4493
|
-
scenario: {
|
|
4494
|
-
type: "string",
|
|
4495
|
-
description: '\u5F00\u53D1\u573A\u666F\u63CF\u8FF0\uFF08\u5982 "\u521B\u5EFA\u8868\u5355\u7EC4\u4EF6", "API \u8C03\u7528", "\u72B6\u6001\u7BA1\u7406"\uFF09'
|
|
4496
|
-
},
|
|
4497
|
-
fileContent: {
|
|
4498
|
-
type: "string",
|
|
4499
|
-
description: "\u6587\u4EF6\u5185\u5BB9\uFF08\u53EF\u9009\uFF09\u3002\u63D0\u4F9B\u540E\u53EF\u81EA\u52A8\u68C0\u6D4B imports \u5E76\u6839\u636E\u5173\u952E\u8BCD\u667A\u80FD\u5339\u914D\u89C4\u8303\u3002"
|
|
4500
|
-
}
|
|
4501
|
-
}
|
|
4502
|
-
}
|
|
4503
|
-
},
|
|
4504
|
-
{
|
|
4505
|
-
name: "get_standards_stats",
|
|
4506
|
-
description: "\u83B7\u53D6\u89C4\u8303\u7CFB\u7EDF\u7684\u4F7F\u7528\u7EDF\u8BA1\u548C\u6027\u80FD\u6307\u6807\u3002\u7528\u4E8E\u4E86\u89E3\u6700\u5E38\u7528\u7684\u89C4\u8303\u7EC4\u5408\u3001\u7F13\u5B58\u547D\u4E2D\u7387\u3001Token \u8282\u7701\u60C5\u51B5\u7B49\u3002",
|
|
4507
|
-
inputSchema: {
|
|
4508
|
-
type: "object",
|
|
4509
|
-
properties: {
|
|
4510
|
-
includeCache: {
|
|
4511
|
-
type: "boolean",
|
|
4512
|
-
description: "\u662F\u5426\u5305\u542B\u7F13\u5B58\u8BE6\u7EC6\u4FE1\u606F\uFF08\u9ED8\u8BA4 false\uFF09"
|
|
4513
|
-
}
|
|
4514
|
-
}
|
|
4515
|
-
}
|
|
4516
|
-
},
|
|
4517
4215
|
{
|
|
4518
4216
|
name: "get_standard_by_id",
|
|
4519
|
-
description: "\
|
|
4217
|
+
description: "\u6309 ID \u76F4\u63A5\u83B7\u53D6\u89C4\u8303",
|
|
4520
4218
|
inputSchema: {
|
|
4521
4219
|
type: "object",
|
|
4522
4220
|
properties: {
|
|
4523
4221
|
id: {
|
|
4524
4222
|
type: "string",
|
|
4525
|
-
description: "\u89C4\u8303 ID\uFF08\u5982 vue3-composition, element-plus
|
|
4223
|
+
description: "\u89C4\u8303 ID\uFF08\u5982 vue3-composition, element-plus\uFF09"
|
|
4526
4224
|
},
|
|
4527
4225
|
ids: {
|
|
4528
4226
|
type: "array",
|
|
4529
4227
|
items: { type: "string" },
|
|
4530
|
-
description: "\u591A\u4E2A\u89C4\u8303 ID
|
|
4228
|
+
description: "\u6279\u91CF\u83B7\u53D6\u591A\u4E2A\u89C4\u8303 ID"
|
|
4531
4229
|
},
|
|
4532
4230
|
mode: {
|
|
4533
4231
|
type: "string",
|
|
4534
4232
|
enum: ["summary", "key-rules", "full"],
|
|
4535
|
-
description: "\
|
|
4233
|
+
description: "\u8FD4\u56DE\u6A21\u5F0F",
|
|
4536
4234
|
default: "key-rules"
|
|
4537
4235
|
}
|
|
4538
4236
|
}
|
|
@@ -4540,33 +4238,33 @@ var CopilotPromptsMCPServer = class {
|
|
|
4540
4238
|
},
|
|
4541
4239
|
{
|
|
4542
4240
|
name: "query_mappings",
|
|
4543
|
-
description:
|
|
4241
|
+
description: "\u67E5\u8BE2\u573A\u666F-\u89C4\u8303\u6620\u5C04\u5173\u7CFB",
|
|
4544
4242
|
inputSchema: {
|
|
4545
4243
|
type: "object",
|
|
4546
4244
|
properties: {
|
|
4547
4245
|
scenario: {
|
|
4548
4246
|
type: "string",
|
|
4549
|
-
description: "\u573A\u666F\u540D\u79F0
|
|
4247
|
+
description: "\u573A\u666F\u540D\u79F0"
|
|
4550
4248
|
},
|
|
4551
4249
|
fileType: {
|
|
4552
4250
|
type: "string",
|
|
4553
|
-
description: "\u6587\u4EF6\u7C7B\u578B
|
|
4251
|
+
description: "\u6587\u4EF6\u7C7B\u578B"
|
|
4554
4252
|
},
|
|
4555
4253
|
imports: {
|
|
4556
4254
|
type: "array",
|
|
4557
4255
|
items: { type: "string" },
|
|
4558
|
-
description: "\u5BFC\u5165\u7684\u5305
|
|
4256
|
+
description: "\u5BFC\u5165\u7684\u5305"
|
|
4559
4257
|
},
|
|
4560
4258
|
listAll: {
|
|
4561
4259
|
type: "boolean",
|
|
4562
|
-
description: "\u5217\u51FA\u6240\u6709\u6620\u5C04
|
|
4260
|
+
description: "\u5217\u51FA\u6240\u6709\u6620\u5C04"
|
|
4563
4261
|
}
|
|
4564
4262
|
}
|
|
4565
4263
|
}
|
|
4566
4264
|
},
|
|
4567
4265
|
{
|
|
4568
4266
|
name: "list_scenarios",
|
|
4569
|
-
description: "\
|
|
4267
|
+
description: "\u5217\u51FA\u6240\u6709\u53EF\u7528\u573A\u666F",
|
|
4570
4268
|
inputSchema: {
|
|
4571
4269
|
type: "object",
|
|
4572
4270
|
properties: {}
|
|
@@ -4574,7 +4272,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4574
4272
|
},
|
|
4575
4273
|
{
|
|
4576
4274
|
name: "list_templates",
|
|
4577
|
-
description: "\
|
|
4275
|
+
description: "\u5217\u51FA\u53EF\u7528\u4EE3\u7801\u6A21\u677F",
|
|
4578
4276
|
inputSchema: {
|
|
4579
4277
|
type: "object",
|
|
4580
4278
|
properties: {
|
|
@@ -4585,7 +4283,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4585
4283
|
},
|
|
4586
4284
|
framework: {
|
|
4587
4285
|
type: "string",
|
|
4588
|
-
description: "\u6309\u6846\u67B6\u7B5B\u9009
|
|
4286
|
+
description: "\u6309\u6846\u67B6\u7B5B\u9009"
|
|
4589
4287
|
},
|
|
4590
4288
|
search: {
|
|
4591
4289
|
type: "string",
|
|
@@ -4596,23 +4294,23 @@ var CopilotPromptsMCPServer = class {
|
|
|
4596
4294
|
},
|
|
4597
4295
|
{
|
|
4598
4296
|
name: "get_template",
|
|
4599
|
-
description: "\
|
|
4297
|
+
description: "\u83B7\u53D6\u6A21\u677F\u8BE6\u60C5\u548C\u6587\u4EF6\u5185\u5BB9",
|
|
4600
4298
|
inputSchema: {
|
|
4601
4299
|
type: "object",
|
|
4602
4300
|
properties: {
|
|
4603
4301
|
id: {
|
|
4604
4302
|
type: "string",
|
|
4605
|
-
description: "\u6A21\u677F ID
|
|
4303
|
+
description: "\u6A21\u677F ID"
|
|
4606
4304
|
},
|
|
4607
4305
|
includeFiles: {
|
|
4608
4306
|
type: "boolean",
|
|
4609
|
-
description: "\
|
|
4307
|
+
description: "\u5305\u542B\u6587\u4EF6\u5185\u5BB9",
|
|
4610
4308
|
default: false
|
|
4611
4309
|
},
|
|
4612
4310
|
files: {
|
|
4613
4311
|
type: "array",
|
|
4614
4312
|
items: { type: "string" },
|
|
4615
|
-
description: "\u6307\u5B9A\
|
|
4313
|
+
description: "\u6307\u5B9A\u6587\u4EF6\u5217\u8868"
|
|
4616
4314
|
}
|
|
4617
4315
|
},
|
|
4618
4316
|
required: ["id"]
|
|
@@ -4621,48 +4319,81 @@ var CopilotPromptsMCPServer = class {
|
|
|
4621
4319
|
]
|
|
4622
4320
|
}));
|
|
4623
4321
|
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
4322
|
+
var _a, _b;
|
|
4624
4323
|
try {
|
|
4625
4324
|
const { name, arguments: args } = request.params;
|
|
4626
4325
|
logger2.debug(`\u8C03\u7528\u5DE5\u5177: ${name}`);
|
|
4627
4326
|
logger2.debug(`\u53C2\u6570:`, args);
|
|
4327
|
+
const workspacePath = (args == null ? void 0 : args.workspacePath) || (args == null ? void 0 : args.projectPath);
|
|
4328
|
+
let autoConfigMessage = null;
|
|
4329
|
+
if (workspacePath) {
|
|
4330
|
+
const configResult = ensureWorkspaceConfig(workspacePath);
|
|
4331
|
+
if (configResult.wasFixed) {
|
|
4332
|
+
autoConfigMessage = configResult.message || null;
|
|
4333
|
+
logger2.info(`\u81EA\u52A8\u914D\u7F6E\u5DF2\u4FEE\u590D: ${workspacePath}`);
|
|
4334
|
+
}
|
|
4335
|
+
}
|
|
4336
|
+
let result;
|
|
4628
4337
|
switch (name) {
|
|
4629
4338
|
case "analyze_project":
|
|
4630
|
-
|
|
4339
|
+
result = await analyzeProject(args);
|
|
4340
|
+
break;
|
|
4631
4341
|
case "auto_setup":
|
|
4632
|
-
|
|
4342
|
+
result = await autoSetup(args);
|
|
4343
|
+
break;
|
|
4633
4344
|
case "health_check":
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
return await getSmartStandards(args);
|
|
4345
|
+
result = await healthCheck(args);
|
|
4346
|
+
break;
|
|
4637
4347
|
case "use_preset":
|
|
4638
|
-
|
|
4348
|
+
result = await usePreset(args);
|
|
4349
|
+
break;
|
|
4639
4350
|
case "list_presets":
|
|
4640
|
-
|
|
4351
|
+
result = await listPresets();
|
|
4352
|
+
break;
|
|
4641
4353
|
case "match_agents":
|
|
4642
|
-
|
|
4354
|
+
result = await matchAgents(args);
|
|
4355
|
+
break;
|
|
4643
4356
|
case "list_available_agents":
|
|
4644
|
-
|
|
4357
|
+
result = await listAvailableAgents();
|
|
4358
|
+
break;
|
|
4645
4359
|
case "generate_config":
|
|
4646
|
-
|
|
4360
|
+
result = await generateConfig(args);
|
|
4361
|
+
break;
|
|
4647
4362
|
case "get_compact_standards":
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
return this.getRelevantStandards(args);
|
|
4651
|
-
case "get_standards_stats":
|
|
4652
|
-
return this.getStandardsStats(args);
|
|
4363
|
+
result = await getCompactStandards(args);
|
|
4364
|
+
break;
|
|
4653
4365
|
case "get_standard_by_id":
|
|
4654
|
-
|
|
4366
|
+
result = await getStandardById(args);
|
|
4367
|
+
break;
|
|
4655
4368
|
case "query_mappings":
|
|
4656
|
-
|
|
4369
|
+
result = await queryMappings(args);
|
|
4370
|
+
break;
|
|
4657
4371
|
case "list_scenarios":
|
|
4658
|
-
|
|
4372
|
+
result = await listScenarios();
|
|
4373
|
+
break;
|
|
4659
4374
|
case "list_templates":
|
|
4660
|
-
|
|
4375
|
+
result = await listTemplates(args);
|
|
4376
|
+
break;
|
|
4661
4377
|
case "get_template":
|
|
4662
|
-
|
|
4378
|
+
result = await getTemplate(args);
|
|
4379
|
+
break;
|
|
4663
4380
|
default:
|
|
4664
4381
|
throw new Error(`\u672A\u77E5\u5DE5\u5177: ${name}`);
|
|
4665
4382
|
}
|
|
4383
|
+
if (autoConfigMessage && ((_b = (_a = result == null ? void 0 : result.content) == null ? void 0 : _a[0]) == null ? void 0 : _b.text)) {
|
|
4384
|
+
try {
|
|
4385
|
+
const originalData = JSON.parse(result.content[0].text);
|
|
4386
|
+
result.content[0].text = JSON.stringify({
|
|
4387
|
+
...originalData,
|
|
4388
|
+
_autoConfigured: {
|
|
4389
|
+
message: autoConfigMessage,
|
|
4390
|
+
action: "\u26A0\uFE0F \u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3 (Cmd+Shift+P \u2192 Reload Window) \u4F7F\u914D\u7F6E\u751F\u6548"
|
|
4391
|
+
}
|
|
4392
|
+
}, null, 2);
|
|
4393
|
+
} catch {
|
|
4394
|
+
}
|
|
4395
|
+
}
|
|
4396
|
+
return result;
|
|
4666
4397
|
} catch (error) {
|
|
4667
4398
|
logger2.error(`\u5DE5\u5177\u6267\u884C\u5931\u8D25:`, error);
|
|
4668
4399
|
return errorResponse(error);
|
|
@@ -4700,61 +4431,49 @@ var CopilotPromptsMCPServer = class {
|
|
|
4700
4431
|
}
|
|
4701
4432
|
});
|
|
4702
4433
|
}
|
|
4703
|
-
/**
|
|
4704
|
-
* 获取相关编码规范
|
|
4705
|
-
*/
|
|
4706
|
-
getRelevantStandards(args) {
|
|
4707
|
-
const standardUris = this.standardsManager.getRelevantStandards(args);
|
|
4708
|
-
const content = this.standardsManager.combineStandards(standardUris);
|
|
4709
|
-
return {
|
|
4710
|
-
content: [{
|
|
4711
|
-
type: "text",
|
|
4712
|
-
text: JSON.stringify({
|
|
4713
|
-
success: true,
|
|
4714
|
-
standards: standardUris,
|
|
4715
|
-
content,
|
|
4716
|
-
tokenEstimate: Math.ceil(content.length / 4),
|
|
4717
|
-
// 粗略估算 token 数
|
|
4718
|
-
message: `\u5DF2\u52A0\u8F7D ${standardUris.length} \u4E2A\u76F8\u5173\u89C4\u8303`
|
|
4719
|
-
}, null, 2)
|
|
4720
|
-
}]
|
|
4721
|
-
};
|
|
4722
|
-
}
|
|
4723
|
-
/**
|
|
4724
|
-
* 获取规范系统统计信息(Phase 3)
|
|
4725
|
-
*/
|
|
4726
|
-
getStandardsStats(args) {
|
|
4727
|
-
const usageStats = this.standardsManager.getUsageStats();
|
|
4728
|
-
const performanceMetrics = this.standardsManager.getPerformanceMetrics();
|
|
4729
|
-
const result = {
|
|
4730
|
-
success: true,
|
|
4731
|
-
usage: usageStats,
|
|
4732
|
-
performance: performanceMetrics,
|
|
4733
|
-
summary: {
|
|
4734
|
-
totalCalls: usageStats.totalCalls,
|
|
4735
|
-
cacheHitRate: performanceMetrics.cacheHitRate,
|
|
4736
|
-
totalTokensSaved: performanceMetrics.totalTokensSaved,
|
|
4737
|
-
averageResponseTime: `${performanceMetrics.averageResponseTime.toFixed(2)}ms`
|
|
4738
|
-
}
|
|
4739
|
-
};
|
|
4740
|
-
if (args.includeCache) {
|
|
4741
|
-
result.cache = this.standardsManager.getCacheStats();
|
|
4742
|
-
}
|
|
4743
|
-
return {
|
|
4744
|
-
content: [{
|
|
4745
|
-
type: "text",
|
|
4746
|
-
text: JSON.stringify(result, null, 2)
|
|
4747
|
-
}]
|
|
4748
|
-
};
|
|
4749
|
-
}
|
|
4750
4434
|
async run() {
|
|
4751
4435
|
const transport = new StdioServerTransport();
|
|
4752
4436
|
await this.server.connect(transport);
|
|
4753
|
-
|
|
4437
|
+
const startupInfo = [
|
|
4438
|
+
`\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`,
|
|
4439
|
+
`\u{1F680} MTA MCP Server v${SERVER_VERSION} \u5DF2\u542F\u52A8`,
|
|
4440
|
+
`\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`,
|
|
4441
|
+
`\u{1F4C2} \u5DE5\u4F5C\u76EE\u5F55: ${process.cwd()}`,
|
|
4442
|
+
`\u{1F527} Node \u7248\u672C: ${process.version}`,
|
|
4443
|
+
`\u23F1\uFE0F \u542F\u52A8\u65F6\u95F4: ${(/* @__PURE__ */ new Date()).toLocaleString("zh-CN")}`,
|
|
4444
|
+
``,
|
|
4445
|
+
`\u{1F4CB} \u53EF\u7528\u5DE5\u5177:`,
|
|
4446
|
+
` \u2022 analyze_project - \u5206\u6790\u9879\u76EE\u6280\u672F\u6808`,
|
|
4447
|
+
` \u2022 auto_setup - \u4E00\u952E\u914D\u7F6E MCP`,
|
|
4448
|
+
` \u2022 health_check - \u5065\u5EB7\u68C0\u67E5\u8BCA\u65AD`,
|
|
4449
|
+
` \u2022 get_compact_standards - \u83B7\u53D6\u7F16\u7801\u89C4\u8303`,
|
|
4450
|
+
` \u2022 use_preset - \u4F7F\u7528\u9884\u8BBE\u573A\u666F`,
|
|
4451
|
+
` \u2022 match_agents - \u5339\u914D\u63A8\u8350 Agent`,
|
|
4452
|
+
``,
|
|
4453
|
+
`\u{1F4A1} \u63D0\u793A: \u5728 Copilot Chat \u4E2D\u4F7F\u7528 @mta \u8C03\u7528\u670D\u52A1`,
|
|
4454
|
+
`\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`
|
|
4455
|
+
];
|
|
4456
|
+
startupInfo.forEach((line) => console.error(line));
|
|
4457
|
+
logger2.info(`MCP Server \u5C31\u7EEA\uFF0C\u7B49\u5F85 Copilot Chat \u8FDE\u63A5...`);
|
|
4754
4458
|
}
|
|
4755
4459
|
};
|
|
4756
4460
|
var server = new CopilotPromptsMCPServer();
|
|
4757
4461
|
server.run().catch((error) => {
|
|
4462
|
+
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`);
|
|
4463
|
+
console.error(`\u274C MTA MCP Server \u542F\u52A8\u5931\u8D25`);
|
|
4464
|
+
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`);
|
|
4465
|
+
console.error(`\u9519\u8BEF\u4FE1\u606F: ${error instanceof Error ? error.message : String(error)}`);
|
|
4466
|
+
console.error(``);
|
|
4467
|
+
console.error(`\u{1F50D} \u53EF\u80FD\u7684\u539F\u56E0:`);
|
|
4468
|
+
console.error(` 1. Node.js \u7248\u672C\u8FC7\u4F4E\uFF08\u9700\u8981 16+\uFF09`);
|
|
4469
|
+
console.error(` 2. \u4F9D\u8D56\u5B89\u88C5\u4E0D\u5B8C\u6574`);
|
|
4470
|
+
console.error(` 3. \u7AEF\u53E3\u88AB\u5360\u7528`);
|
|
4471
|
+
console.error(``);
|
|
4472
|
+
console.error(`\u{1F4A1} \u89E3\u51B3\u5EFA\u8BAE:`);
|
|
4473
|
+
console.error(` \u2022 \u8FD0\u884C node --version \u68C0\u67E5\u7248\u672C`);
|
|
4474
|
+
console.error(` \u2022 \u8FD0\u884C npm install \u91CD\u65B0\u5B89\u88C5\u4F9D\u8D56`);
|
|
4475
|
+
console.error(` \u2022 \u68C0\u67E5\u662F\u5426\u6709\u5176\u4ED6 MCP \u670D\u52A1\u5668\u5B9E\u4F8B\u8FD0\u884C`);
|
|
4476
|
+
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`);
|
|
4758
4477
|
logger2.error("\u670D\u52A1\u5668\u542F\u52A8\u5931\u8D25:", error);
|
|
4759
4478
|
process.exit(1);
|
|
4760
4479
|
});
|