mta-mcp 2.13.0 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/flutter.agent.md +117 -1147
- package/agents/vue3.agent.md +177 -464
- package/dist/index.d.ts +63 -0
- package/dist/index.js +551 -132
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/troubleshooting/README.md +366 -0
- package/troubleshooting/USAGE_GUIDE.md +289 -0
- package/troubleshooting/flutter/clip-/351/230/264/345/275/261/350/243/201/345/211/252.md +244 -0
- package/troubleshooting/flutter/input-/345/255/227/346/256/265/347/274/272/345/244/261.md +240 -0
- package/troubleshooting/flutter/input-/350/276/271/346/241/206/351/227/256/351/242/230.md +236 -0
- package/troubleshooting/flutter/layout-/345/260/272/345/257/270/344/270/215/345/214/271/351/205/215.md +214 -0
- package/troubleshooting/flutter/shadow-/351/200/217/345/207/272/351/227/256/351/242/230.md +172 -0
- package/troubleshooting/flutter/sketch-/345/233/276/346/240/207/345/260/272/345/257/270.md +135 -0
- package/troubleshooting/flutter/sketch-/345/256/214/346/225/264/346/217/220/345/217/226.md +201 -0
- package/troubleshooting/flutter/sketch-/345/261/236/346/200/247/346/234/252/344/275/277/347/224/250.md +139 -0
- package/troubleshooting/flutter/svg-/346/234/252/345/261/205/344/270/255.md +120 -0
- package/troubleshooting/flutter/svg-/351/242/234/350/211/262/345/274/202/345/270/270.md +117 -0
- package/troubleshooting/flutter/tabbar-/345/212/250/347/224/273/345/220/214/346/255/245.md +107 -0
- package/troubleshooting/flutter/withopacity-/345/274/203/347/224/250.md +81 -0
- package/troubleshooting/vue3/cascader-/350/257/257/346/233/277/346/215/242.md +130 -0
- package/troubleshooting/vue3/drawer-input-/346/240/267/345/274/217.md +181 -0
- package/troubleshooting/vue3/table-/347/274/226/350/276/221/345/217/226/346/266/210.md +148 -0
- package/troubleshooting/vue3/table-/350/276/271/346/241/206/351/227/256/351/242/230.md +178 -0
package/dist/index.js
CHANGED
|
@@ -18,8 +18,8 @@ var init_smartAgentMatcher = __esm({
|
|
|
18
18
|
"src/core/smartAgentMatcher.ts"() {
|
|
19
19
|
"use strict";
|
|
20
20
|
SmartAgentMatcher = class {
|
|
21
|
-
constructor(
|
|
22
|
-
this.logger =
|
|
21
|
+
constructor(logger4) {
|
|
22
|
+
this.logger = logger4;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* 分析项目特征
|
|
@@ -439,9 +439,9 @@ __export(resourceLoader_exports, {
|
|
|
439
439
|
import * as fs4 from "fs";
|
|
440
440
|
import * as path4 from "path";
|
|
441
441
|
import { fileURLToPath } from "url";
|
|
442
|
-
function getResourceLoader(
|
|
442
|
+
function getResourceLoader(logger4) {
|
|
443
443
|
if (!resourceLoaderInstance) {
|
|
444
|
-
resourceLoaderInstance = new ResourceLoader(
|
|
444
|
+
resourceLoaderInstance = new ResourceLoader(logger4);
|
|
445
445
|
}
|
|
446
446
|
return resourceLoaderInstance;
|
|
447
447
|
}
|
|
@@ -453,9 +453,9 @@ var init_resourceLoader = __esm({
|
|
|
453
453
|
__filename = fileURLToPath(import.meta.url);
|
|
454
454
|
__dirname2 = path4.dirname(__filename);
|
|
455
455
|
ResourceLoader = class {
|
|
456
|
-
constructor(
|
|
456
|
+
constructor(logger4) {
|
|
457
457
|
this.initialized = false;
|
|
458
|
-
this.logger =
|
|
458
|
+
this.logger = logger4;
|
|
459
459
|
this.packageRoot = this.detectPackageRoot();
|
|
460
460
|
this.validateResources();
|
|
461
461
|
}
|
|
@@ -1000,12 +1000,12 @@ var ConsoleLogger = class {
|
|
|
1000
1000
|
|
|
1001
1001
|
// src/tools/analyzeProject.ts
|
|
1002
1002
|
async function analyzeProject(args) {
|
|
1003
|
-
const
|
|
1003
|
+
const logger4 = new ConsoleLogger();
|
|
1004
1004
|
try {
|
|
1005
1005
|
let projectPath = args.projectPath;
|
|
1006
1006
|
if (!projectPath) {
|
|
1007
1007
|
projectPath = process.cwd();
|
|
1008
|
-
|
|
1008
|
+
logger4.log(`\u{1F4CD} \u672A\u6307\u5B9A\u8DEF\u5F84\uFF0C\u4F7F\u7528\u5F53\u524D\u76EE\u5F55: ${projectPath}`);
|
|
1009
1009
|
}
|
|
1010
1010
|
if (!fs3.existsSync(projectPath)) {
|
|
1011
1011
|
return {
|
|
@@ -1017,14 +1017,14 @@ async function analyzeProject(args) {
|
|
|
1017
1017
|
}]
|
|
1018
1018
|
};
|
|
1019
1019
|
}
|
|
1020
|
-
const matcher = new SmartAgentMatcher(
|
|
1020
|
+
const matcher = new SmartAgentMatcher(logger4);
|
|
1021
1021
|
const workspaceFolder = {
|
|
1022
1022
|
uri: { fsPath: projectPath },
|
|
1023
1023
|
name: path3.basename(projectPath),
|
|
1024
1024
|
index: 0
|
|
1025
1025
|
};
|
|
1026
1026
|
const features = await matcher.analyzeProject(workspaceFolder);
|
|
1027
|
-
|
|
1027
|
+
logger4.log(`\u{1F30D} \u68C0\u6D4B\u56FD\u9645\u5316\u914D\u7F6E...`);
|
|
1028
1028
|
const i18nConfig = await I18nDetector.detect(projectPath);
|
|
1029
1029
|
return {
|
|
1030
1030
|
content: [{
|
|
@@ -1055,7 +1055,7 @@ async function analyzeProject(args) {
|
|
|
1055
1055
|
}]
|
|
1056
1056
|
};
|
|
1057
1057
|
} catch (error) {
|
|
1058
|
-
|
|
1058
|
+
logger4.error(`\u5206\u6790\u9879\u76EE\u5931\u8D25: ${error}`);
|
|
1059
1059
|
return {
|
|
1060
1060
|
content: [{
|
|
1061
1061
|
type: "text",
|
|
@@ -1071,11 +1071,11 @@ async function analyzeProject(args) {
|
|
|
1071
1071
|
init_smartAgentMatcher();
|
|
1072
1072
|
init_resourceLoader();
|
|
1073
1073
|
async function matchAgents(args) {
|
|
1074
|
-
const
|
|
1074
|
+
const logger4 = new ConsoleLogger();
|
|
1075
1075
|
try {
|
|
1076
|
-
const matcher = new SmartAgentMatcher(
|
|
1077
|
-
const resourceLoader = getResourceLoader(
|
|
1078
|
-
|
|
1076
|
+
const matcher = new SmartAgentMatcher(logger4);
|
|
1077
|
+
const resourceLoader = getResourceLoader(logger4);
|
|
1078
|
+
logger4.log("\u6B63\u5728\u4ECE\u5305\u5185\u52A0\u8F7D Agents...");
|
|
1079
1079
|
const availableAgents = resourceLoader.loadAllAgents();
|
|
1080
1080
|
const matchedAgents = matcher.matchAgents(args.projectFeatures, availableAgents);
|
|
1081
1081
|
const limit = args.limit || 10;
|
|
@@ -1100,7 +1100,7 @@ async function matchAgents(args) {
|
|
|
1100
1100
|
}]
|
|
1101
1101
|
};
|
|
1102
1102
|
} catch (error) {
|
|
1103
|
-
|
|
1103
|
+
logger4.error(`\u5339\u914D Agents \u5931\u8D25: ${error}`);
|
|
1104
1104
|
return {
|
|
1105
1105
|
content: [{
|
|
1106
1106
|
type: "text",
|
|
@@ -1187,8 +1187,8 @@ import { fileURLToPath as fileURLToPath3 } from "url";
|
|
|
1187
1187
|
// src/core/githubClient.ts
|
|
1188
1188
|
import axios from "axios";
|
|
1189
1189
|
var GitHubClient = class {
|
|
1190
|
-
constructor(
|
|
1191
|
-
this.logger =
|
|
1190
|
+
constructor(logger4) {
|
|
1191
|
+
this.logger = logger4;
|
|
1192
1192
|
this.owner = "ForLear";
|
|
1193
1193
|
this.repo = "copilot-prompts";
|
|
1194
1194
|
this.branch = "main";
|
|
@@ -1246,8 +1246,8 @@ init_smartAgentMatcher();
|
|
|
1246
1246
|
|
|
1247
1247
|
// src/core/codeValidator.ts
|
|
1248
1248
|
var CodeValidator = class {
|
|
1249
|
-
constructor(
|
|
1250
|
-
this.logger =
|
|
1249
|
+
constructor(logger4) {
|
|
1250
|
+
this.logger = logger4 || new ConsoleLogger();
|
|
1251
1251
|
}
|
|
1252
1252
|
/**
|
|
1253
1253
|
* 验证生成的配置文件内容
|
|
@@ -1507,7 +1507,7 @@ init_resourceLoader();
|
|
|
1507
1507
|
var __filename3 = fileURLToPath3(import.meta.url);
|
|
1508
1508
|
var __dirname4 = path6.dirname(__filename3);
|
|
1509
1509
|
async function generateConfig(args) {
|
|
1510
|
-
const
|
|
1510
|
+
const logger4 = new ConsoleLogger();
|
|
1511
1511
|
try {
|
|
1512
1512
|
if (!fs6.existsSync(args.projectPath)) {
|
|
1513
1513
|
return {
|
|
@@ -1519,39 +1519,39 @@ async function generateConfig(args) {
|
|
|
1519
1519
|
}]
|
|
1520
1520
|
};
|
|
1521
1521
|
}
|
|
1522
|
-
const matcher = new SmartAgentMatcher(
|
|
1523
|
-
const githubClient = new GitHubClient(
|
|
1522
|
+
const matcher = new SmartAgentMatcher(logger4);
|
|
1523
|
+
const githubClient = new GitHubClient(logger4);
|
|
1524
1524
|
let selectedAgents = [];
|
|
1525
1525
|
if (args.autoMatch !== false) {
|
|
1526
|
-
|
|
1526
|
+
logger4.log("\u6B63\u5728\u5206\u6790\u9879\u76EE\u7279\u5F81...");
|
|
1527
1527
|
const workspaceFolder = {
|
|
1528
1528
|
uri: { fsPath: args.projectPath },
|
|
1529
1529
|
name: path6.basename(args.projectPath),
|
|
1530
1530
|
index: 0
|
|
1531
1531
|
};
|
|
1532
1532
|
const features = await matcher.analyzeProject(workspaceFolder);
|
|
1533
|
-
|
|
1534
|
-
const resourceLoader = getResourceLoader(
|
|
1533
|
+
logger4.log("\u6B63\u5728\u5339\u914D Agents...");
|
|
1534
|
+
const resourceLoader = getResourceLoader(logger4);
|
|
1535
1535
|
const availableAgents = resourceLoader.loadAllAgents();
|
|
1536
1536
|
if (availableAgents.length === 0) {
|
|
1537
1537
|
throw new Error("\u65E0\u6CD5\u52A0\u8F7D Agents\uFF0C\u8BF7\u68C0\u67E5 npm \u5305\u662F\u5426\u5B8C\u6574");
|
|
1538
1538
|
}
|
|
1539
|
-
|
|
1539
|
+
logger4.log(`\u6210\u529F\u52A0\u8F7D ${availableAgents.length} \u4E2A Agents`);
|
|
1540
1540
|
selectedAgents = matcher.matchAgents(features, availableAgents);
|
|
1541
|
-
|
|
1541
|
+
logger4.log(`\u5339\u914D\u5230 ${selectedAgents.length} \u4E2A Agents`);
|
|
1542
1542
|
selectedAgents = selectedAgents.slice(0, 5);
|
|
1543
1543
|
}
|
|
1544
1544
|
if (args.agentIds && args.agentIds.length > 0) {
|
|
1545
|
-
|
|
1545
|
+
logger4.log(`\u4F7F\u7528\u6307\u5B9A\u7684 Agents: ${args.agentIds.join(", ")}`);
|
|
1546
1546
|
selectedAgents = [];
|
|
1547
|
-
const resourceLoader = getResourceLoader(
|
|
1547
|
+
const resourceLoader = getResourceLoader(logger4);
|
|
1548
1548
|
for (const id of args.agentIds) {
|
|
1549
1549
|
const agentData = resourceLoader.loadAgent(id);
|
|
1550
1550
|
if (agentData) {
|
|
1551
1551
|
selectedAgents.push(agentData.metadata);
|
|
1552
|
-
|
|
1552
|
+
logger4.log(`\u2705 \u52A0\u8F7D Agent: ${id}`);
|
|
1553
1553
|
} else {
|
|
1554
|
-
|
|
1554
|
+
logger4.error(`Agent ${id} \u4E0D\u5B58\u5728`);
|
|
1555
1555
|
}
|
|
1556
1556
|
}
|
|
1557
1557
|
}
|
|
@@ -1565,7 +1565,7 @@ async function generateConfig(args) {
|
|
|
1565
1565
|
}]
|
|
1566
1566
|
};
|
|
1567
1567
|
}
|
|
1568
|
-
|
|
1568
|
+
logger4.log("\u6B63\u5728\u751F\u6210\u914D\u7F6E\u6587\u4EF6...");
|
|
1569
1569
|
const githubDir = path6.join(args.projectPath, ".github");
|
|
1570
1570
|
const configPath = path6.join(githubDir, "copilot-instructions.md");
|
|
1571
1571
|
let existingCustomContent = "";
|
|
@@ -1731,10 +1731,10 @@ async function generateConfig(args) {
|
|
|
1731
1731
|
content += `---
|
|
1732
1732
|
|
|
1733
1733
|
`;
|
|
1734
|
-
|
|
1734
|
+
logger4.log(`\u2705 \u5DF2\u52A0\u8F7D\u914D\u7F6E\u65B9\u6848: ${configData.name}`);
|
|
1735
1735
|
}
|
|
1736
1736
|
} catch (error) {
|
|
1737
|
-
|
|
1737
|
+
logger4.error(`\u52A0\u8F7D\u914D\u7F6E\u65B9\u6848\u5931\u8D25: ${error}`);
|
|
1738
1738
|
}
|
|
1739
1739
|
}
|
|
1740
1740
|
content += `## \u26A0\uFE0F \u5F3A\u5236\u5DE5\u4F5C\u6D41
|
|
@@ -1813,22 +1813,22 @@ async function generateConfig(args) {
|
|
|
1813
1813
|
|
|
1814
1814
|
`;
|
|
1815
1815
|
content += existingCustomContent;
|
|
1816
|
-
|
|
1816
|
+
logger4.log("\u2705 \u5DF2\u4FDD\u7559\u81EA\u5B9A\u4E49\u5185\u5BB9");
|
|
1817
1817
|
}
|
|
1818
|
-
const validator = new CodeValidator(
|
|
1818
|
+
const validator = new CodeValidator(logger4);
|
|
1819
1819
|
const validation = validator.validateConfigContent(content);
|
|
1820
1820
|
if (!validation.isValid) {
|
|
1821
|
-
|
|
1821
|
+
logger4.error("\u26A0\uFE0F \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u5931\u8D25\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D...");
|
|
1822
1822
|
const fixResult = validator.attemptAutoFix(content);
|
|
1823
1823
|
if (fixResult.fixed) {
|
|
1824
1824
|
content = fixResult.content;
|
|
1825
|
-
|
|
1826
|
-
fixResult.changes.forEach((change) =>
|
|
1825
|
+
logger4.log(`\u2705 \u5DF2\u81EA\u52A8\u4FEE\u590D ${fixResult.changes.length} \u4E2A\u95EE\u9898:`);
|
|
1826
|
+
fixResult.changes.forEach((change) => logger4.log(` - ${change}`));
|
|
1827
1827
|
const revalidation = validator.validateConfigContent(content);
|
|
1828
1828
|
if (!revalidation.isValid) {
|
|
1829
1829
|
const report = validator.generateValidationReport(revalidation);
|
|
1830
|
-
|
|
1831
|
-
|
|
1830
|
+
logger4.error("\u274C \u81EA\u52A8\u4FEE\u590D\u540E\u4ECD\u5B58\u5728\u95EE\u9898:");
|
|
1831
|
+
logger4.error(report);
|
|
1832
1832
|
return {
|
|
1833
1833
|
content: [{
|
|
1834
1834
|
type: "text",
|
|
@@ -1842,7 +1842,7 @@ async function generateConfig(args) {
|
|
|
1842
1842
|
}
|
|
1843
1843
|
} else {
|
|
1844
1844
|
const report = validator.generateValidationReport(validation);
|
|
1845
|
-
|
|
1845
|
+
logger4.error(report);
|
|
1846
1846
|
return {
|
|
1847
1847
|
content: [{
|
|
1848
1848
|
type: "text",
|
|
@@ -1855,12 +1855,12 @@ async function generateConfig(args) {
|
|
|
1855
1855
|
};
|
|
1856
1856
|
}
|
|
1857
1857
|
} else if (validation.warnings.length > 0) {
|
|
1858
|
-
|
|
1858
|
+
logger4.log("\u26A0\uFE0F \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u901A\u8FC7\uFF0C\u4F46\u6709\u4EE5\u4E0B\u8B66\u544A:");
|
|
1859
1859
|
validation.warnings.forEach((warning) => {
|
|
1860
|
-
|
|
1860
|
+
logger4.log(` - [${warning.type}] ${warning.message}`);
|
|
1861
1861
|
});
|
|
1862
1862
|
} else {
|
|
1863
|
-
|
|
1863
|
+
logger4.log("\u2705 \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u901A\u8FC7");
|
|
1864
1864
|
}
|
|
1865
1865
|
fs6.writeFileSync(configPath, content, "utf-8");
|
|
1866
1866
|
const gitignorePath = path6.join(args.projectPath, ".gitignore");
|
|
@@ -1871,7 +1871,7 @@ async function generateConfig(args) {
|
|
|
1871
1871
|
fs6.writeFileSync(gitignorePath, gitignoreContent, "utf-8");
|
|
1872
1872
|
}
|
|
1873
1873
|
}
|
|
1874
|
-
|
|
1874
|
+
logger4.log(`\u2705 \u914D\u7F6E\u6587\u4EF6\u5DF2\u751F\u6210: ${configPath}`);
|
|
1875
1875
|
return {
|
|
1876
1876
|
content: [{
|
|
1877
1877
|
type: "text",
|
|
@@ -1888,7 +1888,7 @@ async function generateConfig(args) {
|
|
|
1888
1888
|
}]
|
|
1889
1889
|
};
|
|
1890
1890
|
} catch (error) {
|
|
1891
|
-
|
|
1891
|
+
logger4.error(`\u751F\u6210\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
1892
1892
|
return {
|
|
1893
1893
|
content: [{
|
|
1894
1894
|
type: "text",
|
|
@@ -1905,7 +1905,7 @@ import * as fs7 from "fs";
|
|
|
1905
1905
|
import * as path7 from "path";
|
|
1906
1906
|
async function autoSetup(args) {
|
|
1907
1907
|
var _a;
|
|
1908
|
-
const
|
|
1908
|
+
const logger4 = new ConsoleLogger();
|
|
1909
1909
|
try {
|
|
1910
1910
|
const workspacePath = args.workspacePath || process.cwd();
|
|
1911
1911
|
if (!fs7.existsSync(workspacePath)) {
|
|
@@ -1923,7 +1923,7 @@ async function autoSetup(args) {
|
|
|
1923
1923
|
steps: [],
|
|
1924
1924
|
warnings: []
|
|
1925
1925
|
};
|
|
1926
|
-
|
|
1926
|
+
logger4.log("\u{1F680} \u5F00\u59CB\u4E3A\u9879\u76EE\u751F\u6210 copilot-instructions.md...");
|
|
1927
1927
|
const generateInstructions = args.generateInstructions !== false;
|
|
1928
1928
|
const instructionsPath = path7.join(workspacePath, ".github", "copilot-instructions.md");
|
|
1929
1929
|
const hasExistingInstructions = fs7.existsSync(instructionsPath);
|
|
@@ -1935,7 +1935,7 @@ async function autoSetup(args) {
|
|
|
1935
1935
|
detail: "\u4FDD\u7559\u73B0\u6709\u914D\u7F6E\uFF0C\u4E0D\u81EA\u52A8\u8986\u76D6"
|
|
1936
1936
|
});
|
|
1937
1937
|
} else {
|
|
1938
|
-
|
|
1938
|
+
logger4.log("\u{1F50D} \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\u6587\u4EF6\uFF0C\u5F00\u59CB\u5206\u6790\u9879\u76EE...");
|
|
1939
1939
|
try {
|
|
1940
1940
|
const configResult = await generateConfig({
|
|
1941
1941
|
projectPath: workspacePath,
|
|
@@ -1968,7 +1968,7 @@ async function autoSetup(args) {
|
|
|
1968
1968
|
} else {
|
|
1969
1969
|
results.steps.push({ step: "\u8DF3\u8FC7 copilot-instructions.md \u751F\u6210", status: "skip" });
|
|
1970
1970
|
}
|
|
1971
|
-
|
|
1971
|
+
logger4.log("\u2705 \u914D\u7F6E\u5B8C\u6210\uFF01");
|
|
1972
1972
|
return {
|
|
1973
1973
|
content: [{
|
|
1974
1974
|
type: "text",
|
|
@@ -1986,7 +1986,7 @@ async function autoSetup(args) {
|
|
|
1986
1986
|
}]
|
|
1987
1987
|
};
|
|
1988
1988
|
} catch (error) {
|
|
1989
|
-
|
|
1989
|
+
logger4.error(`\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
1990
1990
|
return {
|
|
1991
1991
|
content: [{
|
|
1992
1992
|
type: "text",
|
|
@@ -2002,12 +2002,12 @@ async function autoSetup(args) {
|
|
|
2002
2002
|
import * as fs8 from "fs";
|
|
2003
2003
|
async function initProject(args) {
|
|
2004
2004
|
var _a;
|
|
2005
|
-
const
|
|
2005
|
+
const logger4 = new ConsoleLogger();
|
|
2006
2006
|
try {
|
|
2007
2007
|
let projectPath = args.projectPath;
|
|
2008
2008
|
if (!projectPath) {
|
|
2009
2009
|
projectPath = process.cwd();
|
|
2010
|
-
|
|
2010
|
+
logger4.log(`\u{1F4A1} \u672A\u6307\u5B9A\u9879\u76EE\u8DEF\u5F84\uFF0C\u4F7F\u7528\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55: ${projectPath}`);
|
|
2011
2011
|
}
|
|
2012
2012
|
if (!fs8.existsSync(projectPath)) {
|
|
2013
2013
|
return {
|
|
@@ -2020,7 +2020,7 @@ async function initProject(args) {
|
|
|
2020
2020
|
}]
|
|
2021
2021
|
};
|
|
2022
2022
|
}
|
|
2023
|
-
|
|
2023
|
+
logger4.log(`\u{1F680} \u5F00\u59CB\u521D\u59CB\u5316\u9879\u76EE: ${projectPath}`);
|
|
2024
2024
|
const result = await generateConfig({
|
|
2025
2025
|
projectPath,
|
|
2026
2026
|
autoMatch: true,
|
|
@@ -2059,7 +2059,7 @@ async function initProject(args) {
|
|
|
2059
2059
|
};
|
|
2060
2060
|
}
|
|
2061
2061
|
} catch (error) {
|
|
2062
|
-
|
|
2062
|
+
logger4.error(`\u521D\u59CB\u5316\u5931\u8D25: ${error}`);
|
|
2063
2063
|
return {
|
|
2064
2064
|
content: [{
|
|
2065
2065
|
type: "text",
|
|
@@ -2619,7 +2619,7 @@ var PRESETS = {
|
|
|
2619
2619
|
}
|
|
2620
2620
|
};
|
|
2621
2621
|
async function usePreset(args) {
|
|
2622
|
-
const
|
|
2622
|
+
const logger4 = new ConsoleLogger();
|
|
2623
2623
|
const manager = new StandardsManager();
|
|
2624
2624
|
try {
|
|
2625
2625
|
if (!(args.preset in PRESETS)) {
|
|
@@ -2638,7 +2638,7 @@ async function usePreset(args) {
|
|
|
2638
2638
|
};
|
|
2639
2639
|
}
|
|
2640
2640
|
const preset = PRESETS[args.preset];
|
|
2641
|
-
|
|
2641
|
+
logger4.log(`\u{1F3AF} \u4F7F\u7528\u9884\u8BBE: ${preset.name}`);
|
|
2642
2642
|
const imports = args.customImports ? [...preset.imports, ...args.customImports] : [...preset.imports];
|
|
2643
2643
|
const standards = manager.getRelevantStandards({
|
|
2644
2644
|
fileType: preset.fileType,
|
|
@@ -2672,7 +2672,7 @@ async function usePreset(args) {
|
|
|
2672
2672
|
}]
|
|
2673
2673
|
};
|
|
2674
2674
|
} catch (error) {
|
|
2675
|
-
|
|
2675
|
+
logger4.error(`\u4F7F\u7528\u9884\u8BBE\u5931\u8D25: ${error}`);
|
|
2676
2676
|
return {
|
|
2677
2677
|
content: [{
|
|
2678
2678
|
type: "text",
|
|
@@ -2730,7 +2730,7 @@ function getServerRoot() {
|
|
|
2730
2730
|
}
|
|
2731
2731
|
async function healthCheck(args) {
|
|
2732
2732
|
var _a, _b, _c, _d;
|
|
2733
|
-
const
|
|
2733
|
+
const logger4 = new ConsoleLogger();
|
|
2734
2734
|
const verbose = args.verbose ?? false;
|
|
2735
2735
|
try {
|
|
2736
2736
|
const checks = {
|
|
@@ -2740,7 +2740,7 @@ async function healthCheck(args) {
|
|
|
2740
2740
|
standards: { status: "unknown", details: [] },
|
|
2741
2741
|
workspace: { status: "unknown", details: [] }
|
|
2742
2742
|
};
|
|
2743
|
-
|
|
2743
|
+
logger4.log("\u{1F50D} \u68C0\u67E5\u670D\u52A1\u5668\u72B6\u6001...");
|
|
2744
2744
|
try {
|
|
2745
2745
|
checks.server.status = "healthy";
|
|
2746
2746
|
checks.server.details.push("\u2705 MCP \u670D\u52A1\u5668\u6B63\u5728\u8FD0\u884C");
|
|
@@ -2750,7 +2750,7 @@ async function healthCheck(args) {
|
|
|
2750
2750
|
checks.server.status = "error";
|
|
2751
2751
|
checks.server.details.push("\u274C \u670D\u52A1\u5668\u672A\u54CD\u5E94");
|
|
2752
2752
|
}
|
|
2753
|
-
|
|
2753
|
+
logger4.log("\u{1F50D} \u68C0\u67E5\u914D\u7F6E\u6587\u4EF6...");
|
|
2754
2754
|
const workspacePath = args.workspacePath || process.cwd();
|
|
2755
2755
|
const vscodeDir = path9.join(workspacePath, ".vscode");
|
|
2756
2756
|
if (fs10.existsSync(vscodeDir)) {
|
|
@@ -2820,7 +2820,7 @@ async function healthCheck(args) {
|
|
|
2820
2820
|
checks.workspace.details.push("\u274C .vscode \u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
2821
2821
|
checks.workspace.details.push("\u{1F4A1} \u5EFA\u8BAE: \u8FD0\u884C auto_setup \u5DE5\u5177\u81EA\u52A8\u521B\u5EFA\u914D\u7F6E");
|
|
2822
2822
|
}
|
|
2823
|
-
|
|
2823
|
+
logger4.log("\u{1F50D} \u68C0\u67E5\u4F9D\u8D56...");
|
|
2824
2824
|
const serverRoot = getServerRoot();
|
|
2825
2825
|
const packageJsonPath = path9.join(serverRoot, "package.json");
|
|
2826
2826
|
if (fs10.existsSync(packageJsonPath)) {
|
|
@@ -2848,7 +2848,7 @@ async function healthCheck(args) {
|
|
|
2848
2848
|
checks.dependencies.details.push("\u274C \u65E0\u6CD5\u8BFB\u53D6 package.json");
|
|
2849
2849
|
}
|
|
2850
2850
|
}
|
|
2851
|
-
|
|
2851
|
+
logger4.log("\u{1F50D} \u68C0\u67E5\u89C4\u8303\u6587\u4EF6...");
|
|
2852
2852
|
const standardsDir = path9.join(serverRoot, "standards");
|
|
2853
2853
|
if (fs10.existsSync(standardsDir)) {
|
|
2854
2854
|
const categories = ["core", "frameworks", "libraries", "patterns"];
|
|
@@ -2887,7 +2887,7 @@ async function healthCheck(args) {
|
|
|
2887
2887
|
error: "\u274C",
|
|
2888
2888
|
unknown: "\u2753"
|
|
2889
2889
|
};
|
|
2890
|
-
|
|
2890
|
+
logger4.log(`${statusEmoji[overallStatus]} \u5065\u5EB7\u68C0\u67E5\u5B8C\u6210`);
|
|
2891
2891
|
return {
|
|
2892
2892
|
content: [{
|
|
2893
2893
|
type: "text",
|
|
@@ -2901,7 +2901,7 @@ async function healthCheck(args) {
|
|
|
2901
2901
|
}]
|
|
2902
2902
|
};
|
|
2903
2903
|
} catch (error) {
|
|
2904
|
-
|
|
2904
|
+
logger4.error(`\u5065\u5EB7\u68C0\u67E5\u5931\u8D25: ${error}`);
|
|
2905
2905
|
return {
|
|
2906
2906
|
content: [{
|
|
2907
2907
|
type: "text",
|
|
@@ -2937,13 +2937,13 @@ import * as fs11 from "fs";
|
|
|
2937
2937
|
import * as path10 from "path";
|
|
2938
2938
|
init_smartAgentMatcher();
|
|
2939
2939
|
async function getCompactStandards(args) {
|
|
2940
|
-
const
|
|
2940
|
+
const logger4 = new ConsoleLogger();
|
|
2941
2941
|
const manager = new StandardsManager();
|
|
2942
2942
|
const mode = args.mode || "key-rules";
|
|
2943
2943
|
try {
|
|
2944
|
-
let context = detectContext(args,
|
|
2944
|
+
let context = detectContext(args, logger4);
|
|
2945
2945
|
if (args.projectPath && fs11.existsSync(args.projectPath)) {
|
|
2946
|
-
const projectContext = await analyzeProject2(args.projectPath,
|
|
2946
|
+
const projectContext = await analyzeProject2(args.projectPath, logger4);
|
|
2947
2947
|
context = mergeContexts(context, projectContext);
|
|
2948
2948
|
}
|
|
2949
2949
|
const standardUris = manager.getRelevantStandards({
|
|
@@ -2977,7 +2977,7 @@ async function getCompactStandards(args) {
|
|
|
2977
2977
|
}]
|
|
2978
2978
|
};
|
|
2979
2979
|
} catch (error) {
|
|
2980
|
-
|
|
2980
|
+
logger4.error(`\u89C4\u8303\u83B7\u53D6\u5931\u8D25: ${error}`);
|
|
2981
2981
|
return {
|
|
2982
2982
|
content: [{
|
|
2983
2983
|
type: "text",
|
|
@@ -2988,7 +2988,7 @@ async function getCompactStandards(args) {
|
|
|
2988
2988
|
};
|
|
2989
2989
|
}
|
|
2990
2990
|
}
|
|
2991
|
-
async function analyzeProject2(projectPath,
|
|
2991
|
+
async function analyzeProject2(projectPath, logger4) {
|
|
2992
2992
|
var _a, _b;
|
|
2993
2993
|
const result = {
|
|
2994
2994
|
fileType: "unknown",
|
|
@@ -3002,13 +3002,13 @@ async function analyzeProject2(projectPath, logger3) {
|
|
|
3002
3002
|
const agents = extractUserAgents(content);
|
|
3003
3003
|
if (agents.length > 0) {
|
|
3004
3004
|
result.userConfiguredAgents = agents;
|
|
3005
|
-
|
|
3005
|
+
logger4.log(`\u2705 \u68C0\u6D4B\u5230\u7528\u6237\u914D\u7F6E\u7684 Agents: ${agents.join(", ")}`);
|
|
3006
3006
|
}
|
|
3007
3007
|
} catch (error) {
|
|
3008
|
-
|
|
3008
|
+
logger4.error(`\u8BFB\u53D6\u7528\u6237\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
3009
3009
|
}
|
|
3010
3010
|
}
|
|
3011
|
-
const matcher = new SmartAgentMatcher(
|
|
3011
|
+
const matcher = new SmartAgentMatcher(logger4);
|
|
3012
3012
|
const workspaceFolder = {
|
|
3013
3013
|
uri: { fsPath: projectPath },
|
|
3014
3014
|
name: path10.basename(projectPath),
|
|
@@ -3027,9 +3027,9 @@ async function analyzeProject2(projectPath, logger3) {
|
|
|
3027
3027
|
if (features.libraries) {
|
|
3028
3028
|
result.imports.push(...features.libraries);
|
|
3029
3029
|
}
|
|
3030
|
-
|
|
3030
|
+
logger4.log(`\u{1F50D} \u9879\u76EE\u6280\u672F\u6808: ${result.imports.join(", ")}`);
|
|
3031
3031
|
} catch (error) {
|
|
3032
|
-
|
|
3032
|
+
logger4.error(`\u9879\u76EE\u5206\u6790\u5931\u8D25: ${error}`);
|
|
3033
3033
|
}
|
|
3034
3034
|
return result;
|
|
3035
3035
|
}
|
|
@@ -3050,7 +3050,7 @@ function mergeContexts(fileContext, projectContext) {
|
|
|
3050
3050
|
userConfiguredAgents: projectContext.userConfiguredAgents
|
|
3051
3051
|
};
|
|
3052
3052
|
}
|
|
3053
|
-
function detectContext(args,
|
|
3053
|
+
function detectContext(args, logger4) {
|
|
3054
3054
|
var _a;
|
|
3055
3055
|
let fileType = "unknown";
|
|
3056
3056
|
let imports = [];
|
|
@@ -3395,7 +3395,7 @@ var STANDARD_DIRS = [
|
|
|
3395
3395
|
];
|
|
3396
3396
|
var standardsCache = null;
|
|
3397
3397
|
async function getStandardById(args) {
|
|
3398
|
-
const
|
|
3398
|
+
const logger4 = new ConsoleLogger();
|
|
3399
3399
|
const mode = args.mode || "key-rules";
|
|
3400
3400
|
try {
|
|
3401
3401
|
const idsToLoad = args.ids || (args.id ? [args.id] : []);
|
|
@@ -3460,7 +3460,7 @@ async function getStandardById(args) {
|
|
|
3460
3460
|
}]
|
|
3461
3461
|
};
|
|
3462
3462
|
} catch (error) {
|
|
3463
|
-
|
|
3463
|
+
logger4.error(`\u83B7\u53D6\u89C4\u8303\u5931\u8D25: ${error}`);
|
|
3464
3464
|
return {
|
|
3465
3465
|
content: [{
|
|
3466
3466
|
type: "text",
|
|
@@ -3675,7 +3675,7 @@ function suggestStandards(options) {
|
|
|
3675
3675
|
|
|
3676
3676
|
// src/tools/queryMappings.ts
|
|
3677
3677
|
async function queryMappings(args) {
|
|
3678
|
-
const
|
|
3678
|
+
const logger4 = new ConsoleLogger();
|
|
3679
3679
|
try {
|
|
3680
3680
|
if (args.listAll) {
|
|
3681
3681
|
return {
|
|
@@ -3728,7 +3728,7 @@ async function queryMappings(args) {
|
|
|
3728
3728
|
}]
|
|
3729
3729
|
};
|
|
3730
3730
|
} catch (error) {
|
|
3731
|
-
|
|
3731
|
+
logger4.error(`\u67E5\u8BE2\u6620\u5C04\u5931\u8D25: ${error}`);
|
|
3732
3732
|
return {
|
|
3733
3733
|
content: [{
|
|
3734
3734
|
type: "text",
|
|
@@ -3926,7 +3926,7 @@ function searchTemplates(query) {
|
|
|
3926
3926
|
|
|
3927
3927
|
// src/tools/listTemplates.ts
|
|
3928
3928
|
async function listTemplates(args) {
|
|
3929
|
-
const
|
|
3929
|
+
const logger4 = new ConsoleLogger();
|
|
3930
3930
|
try {
|
|
3931
3931
|
let templates;
|
|
3932
3932
|
if (args.search) {
|
|
@@ -3960,7 +3960,7 @@ async function listTemplates(args) {
|
|
|
3960
3960
|
}]
|
|
3961
3961
|
};
|
|
3962
3962
|
} catch (error) {
|
|
3963
|
-
|
|
3963
|
+
logger4.error(`\u5217\u51FA\u6A21\u677F\u5931\u8D25: ${error}`);
|
|
3964
3964
|
return {
|
|
3965
3965
|
content: [{
|
|
3966
3966
|
type: "text",
|
|
@@ -3974,7 +3974,7 @@ async function listTemplates(args) {
|
|
|
3974
3974
|
|
|
3975
3975
|
// src/tools/getTemplate.ts
|
|
3976
3976
|
async function getTemplate(args) {
|
|
3977
|
-
const
|
|
3977
|
+
const logger4 = new ConsoleLogger();
|
|
3978
3978
|
try {
|
|
3979
3979
|
const result = getTemplateById(args.id, args.includeFiles ?? false);
|
|
3980
3980
|
if (!result) {
|
|
@@ -4015,7 +4015,7 @@ async function getTemplate(args) {
|
|
|
4015
4015
|
}]
|
|
4016
4016
|
};
|
|
4017
4017
|
} catch (error) {
|
|
4018
|
-
|
|
4018
|
+
logger4.error(`\u83B7\u53D6\u6A21\u677F\u5931\u8D25: ${error}`);
|
|
4019
4019
|
return {
|
|
4020
4020
|
content: [{
|
|
4021
4021
|
type: "text",
|
|
@@ -4036,8 +4036,8 @@ import * as fs14 from "fs";
|
|
|
4036
4036
|
import * as path13 from "path";
|
|
4037
4037
|
import glob3 from "fast-glob";
|
|
4038
4038
|
var ProjectCloneAnalyzer = class {
|
|
4039
|
-
constructor(
|
|
4040
|
-
this.logger =
|
|
4039
|
+
constructor(logger4) {
|
|
4040
|
+
this.logger = logger4 || new ConsoleLogger();
|
|
4041
4041
|
}
|
|
4042
4042
|
/**
|
|
4043
4043
|
* 深度分析项目
|
|
@@ -4813,7 +4813,7 @@ var ProjectCloneAnalyzer = class {
|
|
|
4813
4813
|
|
|
4814
4814
|
// src/tools/cloneProject.ts
|
|
4815
4815
|
async function analyzeReferenceProject(args) {
|
|
4816
|
-
const
|
|
4816
|
+
const logger4 = new ConsoleLogger();
|
|
4817
4817
|
try {
|
|
4818
4818
|
if (!args.projectPath) {
|
|
4819
4819
|
return {
|
|
@@ -4836,8 +4836,8 @@ async function analyzeReferenceProject(args) {
|
|
|
4836
4836
|
}]
|
|
4837
4837
|
};
|
|
4838
4838
|
}
|
|
4839
|
-
|
|
4840
|
-
const analyzer = new ProjectCloneAnalyzer(
|
|
4839
|
+
logger4.log(`\u{1F50D} \u5F00\u59CB\u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE: ${args.projectPath}`);
|
|
4840
|
+
const analyzer = new ProjectCloneAnalyzer(logger4);
|
|
4841
4841
|
const analysis = await analyzer.analyzeProject(args.projectPath);
|
|
4842
4842
|
let developmentPlan = null;
|
|
4843
4843
|
if (args.newProjectName) {
|
|
@@ -4845,7 +4845,7 @@ async function analyzeReferenceProject(args) {
|
|
|
4845
4845
|
}
|
|
4846
4846
|
if (args.generateDocs && args.newProjectPath) {
|
|
4847
4847
|
await generateAnalysisDocs(args.newProjectPath, analysis, developmentPlan);
|
|
4848
|
-
|
|
4848
|
+
logger4.log(`\u{1F4C4} \u5DF2\u751F\u6210\u5206\u6790\u6587\u6863\u5230: ${args.newProjectPath}/docs/`);
|
|
4849
4849
|
}
|
|
4850
4850
|
const response = {
|
|
4851
4851
|
success: true,
|
|
@@ -4915,7 +4915,7 @@ async function analyzeReferenceProject(args) {
|
|
|
4915
4915
|
}]
|
|
4916
4916
|
};
|
|
4917
4917
|
} catch (error) {
|
|
4918
|
-
|
|
4918
|
+
logger4.error(`\u5206\u6790\u5931\u8D25: ${error}`);
|
|
4919
4919
|
return {
|
|
4920
4920
|
content: [{
|
|
4921
4921
|
type: "text",
|
|
@@ -4928,7 +4928,7 @@ async function analyzeReferenceProject(args) {
|
|
|
4928
4928
|
}
|
|
4929
4929
|
}
|
|
4930
4930
|
async function generateProjectSkeleton(args) {
|
|
4931
|
-
const
|
|
4931
|
+
const logger4 = new ConsoleLogger();
|
|
4932
4932
|
try {
|
|
4933
4933
|
if (!args.referenceProjectPath || !args.newProjectPath || !args.newProjectName) {
|
|
4934
4934
|
return {
|
|
@@ -4951,10 +4951,10 @@ async function generateProjectSkeleton(args) {
|
|
|
4951
4951
|
}]
|
|
4952
4952
|
};
|
|
4953
4953
|
}
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
const analyzer = new ProjectCloneAnalyzer(
|
|
4954
|
+
logger4.log(`\u{1F3D7}\uFE0F \u5F00\u59CB\u751F\u6210\u9879\u76EE\u9AA8\u67B6...`);
|
|
4955
|
+
logger4.log(`\u{1F4E6} \u53C2\u8003\u9879\u76EE: ${args.referenceProjectPath}`);
|
|
4956
|
+
logger4.log(`\u{1F4C1} \u65B0\u9879\u76EE: ${args.newProjectPath}`);
|
|
4957
|
+
const analyzer = new ProjectCloneAnalyzer(logger4);
|
|
4958
4958
|
const analysis = await analyzer.analyzeProject(args.referenceProjectPath);
|
|
4959
4959
|
const developmentPlan = analyzer.generateDevelopmentPlan(analysis, args.newProjectName);
|
|
4960
4960
|
if (!fs15.existsSync(args.newProjectPath)) {
|
|
@@ -4962,7 +4962,7 @@ async function generateProjectSkeleton(args) {
|
|
|
4962
4962
|
}
|
|
4963
4963
|
if (args.generateDocs !== false) {
|
|
4964
4964
|
await generateAnalysisDocs(args.newProjectPath, analysis, developmentPlan);
|
|
4965
|
-
|
|
4965
|
+
logger4.log(`\u{1F4C4} \u5DF2\u751F\u6210\u5206\u6790\u6587\u6863`);
|
|
4966
4966
|
}
|
|
4967
4967
|
const skeletonGuide = generateSkeletonGuide(analysis, args);
|
|
4968
4968
|
return {
|
|
@@ -4988,7 +4988,7 @@ async function generateProjectSkeleton(args) {
|
|
|
4988
4988
|
}]
|
|
4989
4989
|
};
|
|
4990
4990
|
} catch (error) {
|
|
4991
|
-
|
|
4991
|
+
logger4.error(`\u751F\u6210\u5931\u8D25: ${error}`);
|
|
4992
4992
|
return {
|
|
4993
4993
|
content: [{
|
|
4994
4994
|
type: "text",
|
|
@@ -5227,6 +5227,11 @@ function groupBy(arr, key) {
|
|
|
5227
5227
|
}, {});
|
|
5228
5228
|
}
|
|
5229
5229
|
|
|
5230
|
+
// src/tools/queryTroubleshootingCases.ts
|
|
5231
|
+
init_resourceLoader();
|
|
5232
|
+
import * as fs17 from "fs";
|
|
5233
|
+
import * as path16 from "path";
|
|
5234
|
+
|
|
5230
5235
|
// src/core/errors.ts
|
|
5231
5236
|
var ERROR_MESSAGES = {
|
|
5232
5237
|
[1e3 /* UNKNOWN */]: "\u672A\u77E5\u9519\u8BEF",
|
|
@@ -5478,9 +5483,277 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
5478
5483
|
return result;
|
|
5479
5484
|
}
|
|
5480
5485
|
|
|
5486
|
+
// src/tools/queryTroubleshootingCases.ts
|
|
5487
|
+
var logger2 = createLogger("QueryTroubleshootingCases");
|
|
5488
|
+
function extractCaseMetadata(filePath, framework) {
|
|
5489
|
+
try {
|
|
5490
|
+
const content = fs17.readFileSync(filePath, "utf-8");
|
|
5491
|
+
const lines = content.split("\n");
|
|
5492
|
+
const titleLine = lines.find((l) => l.trim().startsWith("# "));
|
|
5493
|
+
const title = titleLine ? titleLine.replace(/^#\s*/, "").trim() : path16.basename(filePath, ".md");
|
|
5494
|
+
let tags = [];
|
|
5495
|
+
let problemType = "";
|
|
5496
|
+
let severity = "\u4E2D\u7B49";
|
|
5497
|
+
let timeSaved = "\u672A\u77E5";
|
|
5498
|
+
for (let i = 0; i < Math.min(20, lines.length); i++) {
|
|
5499
|
+
const line = lines[i];
|
|
5500
|
+
if (line.includes("**\u95EE\u9898\u6807\u7B7E**") || line.includes("**\u6807\u7B7E**")) {
|
|
5501
|
+
const tagsMatch = line.match(/[`"]([^`"]+)[`"]/g);
|
|
5502
|
+
if (tagsMatch) {
|
|
5503
|
+
tags = tagsMatch.map((t) => t.replace(/[`"]/g, "").trim());
|
|
5504
|
+
}
|
|
5505
|
+
}
|
|
5506
|
+
if (line.includes("**\u95EE\u9898\u7C7B\u578B**")) {
|
|
5507
|
+
const typeMatch = line.match(/[`"]([^`"]+)[`"]/);
|
|
5508
|
+
if (typeMatch) {
|
|
5509
|
+
problemType = typeMatch[1];
|
|
5510
|
+
}
|
|
5511
|
+
}
|
|
5512
|
+
if (line.includes("**\u4E25\u91CD\u7A0B\u5EA6**")) {
|
|
5513
|
+
const severityMatch = line.match(/低|中|高|中等/);
|
|
5514
|
+
if (severityMatch) {
|
|
5515
|
+
severity = severityMatch[0];
|
|
5516
|
+
}
|
|
5517
|
+
}
|
|
5518
|
+
}
|
|
5519
|
+
const timeSavedMatch = content.match(/节省时间[::]\s*([^\n]+)|(\d+-\d+)\s*轮/);
|
|
5520
|
+
if (timeSavedMatch) {
|
|
5521
|
+
timeSaved = timeSavedMatch[1] || `${timeSavedMatch[2]}\u8F6E\u5BF9\u8BDD`;
|
|
5522
|
+
}
|
|
5523
|
+
const id = path16.basename(filePath, ".md");
|
|
5524
|
+
return {
|
|
5525
|
+
id,
|
|
5526
|
+
framework,
|
|
5527
|
+
title,
|
|
5528
|
+
problemType: problemType || "\u672A\u5206\u7C7B",
|
|
5529
|
+
tags,
|
|
5530
|
+
severity,
|
|
5531
|
+
timeSaved,
|
|
5532
|
+
filePath
|
|
5533
|
+
};
|
|
5534
|
+
} catch (error) {
|
|
5535
|
+
logger2.error(`\u89E3\u6790\u6848\u4F8B\u6587\u4EF6\u5931\u8D25: ${filePath}`, error);
|
|
5536
|
+
return null;
|
|
5537
|
+
}
|
|
5538
|
+
}
|
|
5539
|
+
function calculateMatchScore(caseData, keywords, errorMessage) {
|
|
5540
|
+
let score = 0;
|
|
5541
|
+
const titleLower = caseData.title.toLowerCase();
|
|
5542
|
+
const problemTypeLower = caseData.problemType.toLowerCase();
|
|
5543
|
+
const tagsLower = caseData.tags.map((t) => t.toLowerCase());
|
|
5544
|
+
for (const keyword of keywords) {
|
|
5545
|
+
const kw = keyword.toLowerCase();
|
|
5546
|
+
if (tagsLower.includes(kw)) {
|
|
5547
|
+
score += 20;
|
|
5548
|
+
} else if (tagsLower.some((tag) => tag.includes(kw) || kw.includes(tag))) {
|
|
5549
|
+
score += 10;
|
|
5550
|
+
}
|
|
5551
|
+
}
|
|
5552
|
+
for (const keyword of keywords) {
|
|
5553
|
+
const kw = keyword.toLowerCase();
|
|
5554
|
+
if (titleLower.includes(kw)) {
|
|
5555
|
+
score += 15;
|
|
5556
|
+
}
|
|
5557
|
+
}
|
|
5558
|
+
for (const keyword of keywords) {
|
|
5559
|
+
const kw = keyword.toLowerCase();
|
|
5560
|
+
if (problemTypeLower.includes(kw)) {
|
|
5561
|
+
score += 8;
|
|
5562
|
+
}
|
|
5563
|
+
}
|
|
5564
|
+
if (errorMessage && errorMessage.trim()) {
|
|
5565
|
+
const errorLower = errorMessage.toLowerCase();
|
|
5566
|
+
const caseContent = fs17.readFileSync(caseData.filePath, "utf-8").toLowerCase();
|
|
5567
|
+
const errorKeywords = errorLower.match(/\b[\u4e00-\u9fa5a-z]{4,}\b/g) || [];
|
|
5568
|
+
const uniqueKeywords = [...new Set(errorKeywords)];
|
|
5569
|
+
let matches = 0;
|
|
5570
|
+
for (const kw of uniqueKeywords.slice(0, 10)) {
|
|
5571
|
+
if (caseContent.includes(kw)) {
|
|
5572
|
+
matches++;
|
|
5573
|
+
}
|
|
5574
|
+
}
|
|
5575
|
+
if (uniqueKeywords.length > 0) {
|
|
5576
|
+
score += Math.floor(matches / uniqueKeywords.length * 30);
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5579
|
+
for (const keyword of keywords) {
|
|
5580
|
+
if (caseData.tags.includes(keyword)) {
|
|
5581
|
+
score += 15;
|
|
5582
|
+
}
|
|
5583
|
+
}
|
|
5584
|
+
return Math.min(100, score);
|
|
5585
|
+
}
|
|
5586
|
+
function generatePreview(filePath) {
|
|
5587
|
+
try {
|
|
5588
|
+
const content = fs17.readFileSync(filePath, "utf-8");
|
|
5589
|
+
const lines = content.split("\n");
|
|
5590
|
+
let sectionStart = lines.findIndex(
|
|
5591
|
+
(l) => l.includes("## \u2705 \u6B63\u786E\u89E3\u51B3\u65B9\u6848") || l.includes("### \u6838\u5FC3\u539F\u7406")
|
|
5592
|
+
);
|
|
5593
|
+
if (sectionStart !== -1) {
|
|
5594
|
+
const preview = lines.slice(sectionStart + 1, sectionStart + 8).filter((l) => l.trim() && !l.startsWith("#") && !l.startsWith(">")).join(" ").replace(/```.*?```/g, "").replace(/\*\*/g, "").trim();
|
|
5595
|
+
if (preview.length > 50) {
|
|
5596
|
+
return preview.slice(0, 250) + "...";
|
|
5597
|
+
}
|
|
5598
|
+
}
|
|
5599
|
+
sectionStart = lines.findIndex(
|
|
5600
|
+
(l) => l.includes("### \u95EE\u9898\u539F\u56E0") || l.includes("## \u274C \u5E38\u89C1\u9519\u8BEF") || l.includes("### \u539F\u56E0")
|
|
5601
|
+
);
|
|
5602
|
+
if (sectionStart !== -1) {
|
|
5603
|
+
const preview = lines.slice(sectionStart + 1, sectionStart + 8).filter((l) => l.trim() && !l.startsWith("#") && !l.startsWith("|")).join(" ").replace(/```.*?```/g, "").replace(/\*\*/g, "").trim();
|
|
5604
|
+
if (preview.length > 50) {
|
|
5605
|
+
return preview.slice(0, 250) + "...";
|
|
5606
|
+
}
|
|
5607
|
+
}
|
|
5608
|
+
sectionStart = lines.findIndex((l) => l.includes("## \u{1F50D} \u95EE\u9898\u8BC6\u522B"));
|
|
5609
|
+
if (sectionStart !== -1) {
|
|
5610
|
+
const preview = lines.slice(sectionStart + 1, sectionStart + 10).filter((l) => l.trim() && !l.startsWith("#") && !l.startsWith("###")).join(" ").trim();
|
|
5611
|
+
if (preview.length > 50) {
|
|
5612
|
+
return preview.slice(0, 250) + "...";
|
|
5613
|
+
}
|
|
5614
|
+
}
|
|
5615
|
+
const fallbackPreview = lines.slice(0, 15).filter((l) => l.trim() && !l.startsWith("#") && !l.startsWith(">") && !l.startsWith("**")).slice(0, 3).join(" ").trim();
|
|
5616
|
+
return fallbackPreview.slice(0, 250) + "...";
|
|
5617
|
+
} catch (error) {
|
|
5618
|
+
return "\u9884\u89C8\u4E0D\u53EF\u7528";
|
|
5619
|
+
}
|
|
5620
|
+
}
|
|
5621
|
+
async function queryTroubleshootingCases(params) {
|
|
5622
|
+
const {
|
|
5623
|
+
framework,
|
|
5624
|
+
keywords = [],
|
|
5625
|
+
errorMessage,
|
|
5626
|
+
codePattern,
|
|
5627
|
+
limit = 5
|
|
5628
|
+
} = params;
|
|
5629
|
+
logger2.log("\u67E5\u8BE2\u6545\u969C\u6392\u9664\u6848\u4F8B", { framework, keywords, errorMessage });
|
|
5630
|
+
try {
|
|
5631
|
+
const loader = new ResourceLoader();
|
|
5632
|
+
const troubleshootingDir = loader.getResourceDir("troubleshooting");
|
|
5633
|
+
if (!fs17.existsSync(troubleshootingDir)) {
|
|
5634
|
+
logger2.warn("\u6545\u969C\u6392\u9664\u76EE\u5F55\u4E0D\u5B58\u5728:", troubleshootingDir);
|
|
5635
|
+
return {
|
|
5636
|
+
cases: [],
|
|
5637
|
+
totalFound: 0,
|
|
5638
|
+
queryInfo: { framework, keywords, errorMessage }
|
|
5639
|
+
};
|
|
5640
|
+
}
|
|
5641
|
+
const allCases = [];
|
|
5642
|
+
const frameworksToSearch = [];
|
|
5643
|
+
if (framework) {
|
|
5644
|
+
frameworksToSearch.push(framework);
|
|
5645
|
+
} else {
|
|
5646
|
+
const dirs = fs17.readdirSync(troubleshootingDir);
|
|
5647
|
+
for (const dir of dirs) {
|
|
5648
|
+
const dirPath = path16.join(troubleshootingDir, dir);
|
|
5649
|
+
if (fs17.statSync(dirPath).isDirectory()) {
|
|
5650
|
+
frameworksToSearch.push(dir);
|
|
5651
|
+
}
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
for (const fw of frameworksToSearch) {
|
|
5655
|
+
const fwDir = path16.join(troubleshootingDir, fw);
|
|
5656
|
+
if (!fs17.existsSync(fwDir)) continue;
|
|
5657
|
+
const files = fs17.readdirSync(fwDir);
|
|
5658
|
+
for (const file of files) {
|
|
5659
|
+
if (!file.endsWith(".md") || file === "README.md") continue;
|
|
5660
|
+
const filePath = path16.join(fwDir, file);
|
|
5661
|
+
const metadata = extractCaseMetadata(filePath, fw);
|
|
5662
|
+
if (metadata) {
|
|
5663
|
+
allCases.push(metadata);
|
|
5664
|
+
}
|
|
5665
|
+
}
|
|
5666
|
+
}
|
|
5667
|
+
logger2.log(`\u627E\u5230 ${allCases.length} \u4E2A\u6848\u4F8B`);
|
|
5668
|
+
let scoredCases = allCases.map((caseData) => ({
|
|
5669
|
+
caseData,
|
|
5670
|
+
score: calculateMatchScore(caseData, keywords, errorMessage || codePattern)
|
|
5671
|
+
}));
|
|
5672
|
+
scoredCases.sort((a, b) => b.score - a.score);
|
|
5673
|
+
let threshold = 10;
|
|
5674
|
+
if (errorMessage && errorMessage.trim()) {
|
|
5675
|
+
threshold = 5;
|
|
5676
|
+
}
|
|
5677
|
+
if (keywords.length >= 3) {
|
|
5678
|
+
threshold = 15;
|
|
5679
|
+
}
|
|
5680
|
+
scoredCases = scoredCases.filter((c) => c.score >= threshold);
|
|
5681
|
+
const topCases = scoredCases.slice(0, limit);
|
|
5682
|
+
const results = topCases.map(({ caseData, score }) => ({
|
|
5683
|
+
id: caseData.id,
|
|
5684
|
+
title: caseData.title,
|
|
5685
|
+
framework: caseData.framework,
|
|
5686
|
+
problemType: caseData.problemType,
|
|
5687
|
+
tags: caseData.tags,
|
|
5688
|
+
matchScore: score,
|
|
5689
|
+
timeSaved: caseData.timeSaved,
|
|
5690
|
+
preview: generatePreview(caseData.filePath)
|
|
5691
|
+
}));
|
|
5692
|
+
return {
|
|
5693
|
+
cases: results,
|
|
5694
|
+
totalFound: scoredCases.length,
|
|
5695
|
+
queryInfo: { framework, keywords, errorMessage }
|
|
5696
|
+
};
|
|
5697
|
+
} catch (error) {
|
|
5698
|
+
logger2.error("\u67E5\u8BE2\u6545\u969C\u6392\u9664\u6848\u4F8B\u5931\u8D25", error);
|
|
5699
|
+
throw error;
|
|
5700
|
+
}
|
|
5701
|
+
}
|
|
5702
|
+
async function getTroubleshootingCaseContent(params) {
|
|
5703
|
+
const { framework, caseId } = params;
|
|
5704
|
+
try {
|
|
5705
|
+
const loader = new ResourceLoader();
|
|
5706
|
+
const troubleshootingDir = loader.getResourceDir("troubleshooting");
|
|
5707
|
+
const casePath = path16.join(troubleshootingDir, framework, `${caseId}.md`);
|
|
5708
|
+
if (!fs17.existsSync(casePath)) {
|
|
5709
|
+
throw new Error(`\u6848\u4F8B\u4E0D\u5B58\u5728: ${framework}/${caseId}`);
|
|
5710
|
+
}
|
|
5711
|
+
const content = fs17.readFileSync(casePath, "utf-8");
|
|
5712
|
+
const metadata = extractCaseMetadata(casePath, framework);
|
|
5713
|
+
return { content, metadata };
|
|
5714
|
+
} catch (error) {
|
|
5715
|
+
logger2.error("\u83B7\u53D6\u6848\u4F8B\u5185\u5BB9\u5931\u8D25", error);
|
|
5716
|
+
throw error;
|
|
5717
|
+
}
|
|
5718
|
+
}
|
|
5719
|
+
async function listTroubleshootingCases(framework) {
|
|
5720
|
+
try {
|
|
5721
|
+
const loader = new ResourceLoader();
|
|
5722
|
+
const troubleshootingDir = loader.getResourceDir("troubleshooting");
|
|
5723
|
+
const frameworks = [];
|
|
5724
|
+
const allCases = [];
|
|
5725
|
+
if (!fs17.existsSync(troubleshootingDir)) {
|
|
5726
|
+
return { cases: [], frameworks: [] };
|
|
5727
|
+
}
|
|
5728
|
+
const dirs = fs17.readdirSync(troubleshootingDir);
|
|
5729
|
+
for (const dir of dirs) {
|
|
5730
|
+
const dirPath = path16.join(troubleshootingDir, dir);
|
|
5731
|
+
if (!fs17.statSync(dirPath).isDirectory()) continue;
|
|
5732
|
+
if (framework && dir !== framework) continue;
|
|
5733
|
+
frameworks.push(dir);
|
|
5734
|
+
const files = fs17.readdirSync(dirPath);
|
|
5735
|
+
for (const file of files) {
|
|
5736
|
+
if (!file.endsWith(".md") || file === "README.md") continue;
|
|
5737
|
+
const filePath = path16.join(dirPath, file);
|
|
5738
|
+
const metadata = extractCaseMetadata(filePath, dir);
|
|
5739
|
+
if (metadata) {
|
|
5740
|
+
allCases.push(metadata);
|
|
5741
|
+
}
|
|
5742
|
+
}
|
|
5743
|
+
}
|
|
5744
|
+
return {
|
|
5745
|
+
cases: allCases,
|
|
5746
|
+
frameworks
|
|
5747
|
+
};
|
|
5748
|
+
} catch (error) {
|
|
5749
|
+
logger2.error("\u5217\u51FA\u6545\u969C\u6392\u9664\u6848\u4F8B\u5931\u8D25", error);
|
|
5750
|
+
throw error;
|
|
5751
|
+
}
|
|
5752
|
+
}
|
|
5753
|
+
|
|
5481
5754
|
// src/index.ts
|
|
5482
|
-
var SERVER_VERSION = "2.
|
|
5483
|
-
var
|
|
5755
|
+
var SERVER_VERSION = "2.14.0";
|
|
5756
|
+
var logger3 = createLogger("Server");
|
|
5484
5757
|
var CopilotPromptsMCPServer = class {
|
|
5485
5758
|
constructor() {
|
|
5486
5759
|
this.standardsManager = new StandardsManager();
|
|
@@ -5506,24 +5779,24 @@ var CopilotPromptsMCPServer = class {
|
|
|
5506
5779
|
*/
|
|
5507
5780
|
setupErrorHandlers() {
|
|
5508
5781
|
this.server.onerror = (error) => {
|
|
5509
|
-
|
|
5782
|
+
logger3.error("MCP \u670D\u52A1\u5668\u9519\u8BEF", error);
|
|
5510
5783
|
};
|
|
5511
5784
|
process.on("SIGINT", async () => {
|
|
5512
|
-
|
|
5785
|
+
logger3.info("\u6536\u5230\u5173\u95ED\u4FE1\u53F7\uFF0C\u6B63\u5728\u5173\u95ED\u670D\u52A1\u5668...");
|
|
5513
5786
|
await this.server.close();
|
|
5514
5787
|
process.exit(0);
|
|
5515
5788
|
});
|
|
5516
5789
|
process.on("SIGTERM", async () => {
|
|
5517
|
-
|
|
5790
|
+
logger3.info("\u6536\u5230\u7EC8\u6B62\u4FE1\u53F7\uFF0C\u6B63\u5728\u5173\u95ED\u670D\u52A1\u5668...");
|
|
5518
5791
|
await this.server.close();
|
|
5519
5792
|
process.exit(0);
|
|
5520
5793
|
});
|
|
5521
5794
|
process.on("uncaughtException", (error) => {
|
|
5522
|
-
|
|
5795
|
+
logger3.error("\u672A\u6355\u83B7\u7684\u5F02\u5E38:", error);
|
|
5523
5796
|
process.exit(1);
|
|
5524
5797
|
});
|
|
5525
5798
|
process.on("unhandledRejection", (reason, promise) => {
|
|
5526
|
-
|
|
5799
|
+
logger3.error("\u672A\u5904\u7406\u7684 Promise \u62D2\u7EDD:", reason);
|
|
5527
5800
|
process.exit(1);
|
|
5528
5801
|
});
|
|
5529
5802
|
}
|
|
@@ -5942,6 +6215,103 @@ var CopilotPromptsMCPServer = class {
|
|
|
5942
6215
|
},
|
|
5943
6216
|
required: ["referenceProjectPath", "newProjectPath", "newProjectName"]
|
|
5944
6217
|
}
|
|
6218
|
+
},
|
|
6219
|
+
{
|
|
6220
|
+
name: "troubleshoot",
|
|
6221
|
+
description: `\u3010\u95EE\u9898\u8BCA\u65AD\u3011\u9047\u5230\u95EE\u9898\u65F6\u4F18\u5148\u8C03\u7528\uFF01\u57FA\u4E8E\u771F\u5B9E\u9879\u76EE\u7ECF\u9A8C\u7684\u6545\u969C\u6392\u9664\u5E93\u3002
|
|
6222
|
+
|
|
6223
|
+
\u26A0\uFE0F **\u4F55\u65F6\u4F7F\u7528**\uFF08AI \u8BF7\u6CE8\u610F\uFF09\uFF1A
|
|
6224
|
+
- \u7528\u6237\u63CF\u8FF0\u4E86\u4EFB\u4F55\u6280\u672F\u95EE\u9898\u6216\u9519\u8BEF
|
|
6225
|
+
- \u4EE3\u7801\u4E0D\u7B26\u5408\u9884\u671F\u6548\u679C\uFF08\u6837\u5F0F\u3001\u5E03\u5C40\u3001\u52A8\u753B\u7B49\uFF09
|
|
6226
|
+
- \u9700\u8981\u8C03\u8BD5\u6216\u4FEE\u590D\u95EE\u9898
|
|
6227
|
+
- \u7528\u6237\u95EE"\u4E3A\u4EC0\u4E48"\u6216"\u600E\u4E48\u89E3\u51B3"
|
|
6228
|
+
|
|
6229
|
+
\u{1F4A1} **\u76F4\u63A5\u4F20\u5165\u95EE\u9898\u63CF\u8FF0\u5373\u53EF**\uFF0C\u7CFB\u7EDF\u4F1A\u81EA\u52A8\uFF1A
|
|
6230
|
+
1. \u8BC6\u522B\u6846\u67B6\u7C7B\u578B\uFF08Flutter/Vue/React\uFF09
|
|
6231
|
+
2. \u63D0\u53D6\u5173\u952E\u8BCD\u5339\u914D\u6848\u4F8B
|
|
6232
|
+
3. \u8FD4\u56DE\u7ECF\u8FC7\u9A8C\u8BC1\u7684\u89E3\u51B3\u65B9\u6848
|
|
6233
|
+
4. \u663E\u793A\u5E94\u907F\u514D\u7684\u9519\u8BEF\u8DEF\u7EBF
|
|
6234
|
+
|
|
6235
|
+
\u{1F4CA} **\u6848\u4F8B\u5E93\u5305\u542B**\uFF1A
|
|
6236
|
+
- Flutter: \u9634\u5F71\u900F\u51FA\u3001\u5E03\u5C40\u504F\u79FB\u3001\u52A8\u753B\u540C\u6B65\u3001SVG\u95EE\u9898\u3001Sketch\u8FD8\u539F
|
|
6237
|
+
- Vue3: Element Plus\u8868\u683C\u8FB9\u6846\u3001\u6837\u5F0F\u51B2\u7A81
|
|
6238
|
+
- \u6301\u7EED\u66F4\u65B0\u4E2D...`,
|
|
6239
|
+
inputSchema: {
|
|
6240
|
+
type: "object",
|
|
6241
|
+
properties: {
|
|
6242
|
+
problem: {
|
|
6243
|
+
type: "string",
|
|
6244
|
+
description: "\u95EE\u9898\u63CF\u8FF0\uFF08\u7528\u6237\u8BF4\u7684\u8BDD\u6216\u9519\u8BEF\u4FE1\u606F\uFF09\uFF0C\u76F4\u63A5\u4F20\u5165\u5373\u53EF"
|
|
6245
|
+
},
|
|
6246
|
+
framework: {
|
|
6247
|
+
type: "string",
|
|
6248
|
+
enum: ["flutter", "vue3", "react"],
|
|
6249
|
+
description: "\u6846\u67B6\u7C7B\u578B\uFF08\u53EF\u9009\uFF0C\u4F1A\u81EA\u52A8\u68C0\u6D4B\uFF09"
|
|
6250
|
+
},
|
|
6251
|
+
codeSnippet: {
|
|
6252
|
+
type: "string",
|
|
6253
|
+
description: "\u76F8\u5173\u4EE3\u7801\u7247\u6BB5\uFF08\u53EF\u9009\uFF09"
|
|
6254
|
+
}
|
|
6255
|
+
}
|
|
6256
|
+
}
|
|
6257
|
+
},
|
|
6258
|
+
{
|
|
6259
|
+
name: "query_troubleshooting_cases",
|
|
6260
|
+
description: "\u3010\u9AD8\u7EA7\u3011\u7CBE\u786E\u67E5\u8BE2\u6545\u969C\u6392\u9664\u6848\u4F8B\uFF08\u666E\u901A\u95EE\u9898\u8BF7\u7528 troubleshoot\uFF09",
|
|
6261
|
+
inputSchema: {
|
|
6262
|
+
type: "object",
|
|
6263
|
+
properties: {
|
|
6264
|
+
framework: {
|
|
6265
|
+
type: "string",
|
|
6266
|
+
enum: ["flutter", "vue3", "react", "common"],
|
|
6267
|
+
description: "\u6846\u67B6\u7C7B\u578B"
|
|
6268
|
+
},
|
|
6269
|
+
keywords: {
|
|
6270
|
+
type: "array",
|
|
6271
|
+
items: { type: "string" },
|
|
6272
|
+
description: "\u95EE\u9898\u5173\u952E\u8BCD"
|
|
6273
|
+
},
|
|
6274
|
+
errorMessage: {
|
|
6275
|
+
type: "string",
|
|
6276
|
+
description: "\u9519\u8BEF\u4FE1\u606F"
|
|
6277
|
+
},
|
|
6278
|
+
limit: {
|
|
6279
|
+
type: "number",
|
|
6280
|
+
default: 5
|
|
6281
|
+
}
|
|
6282
|
+
}
|
|
6283
|
+
}
|
|
6284
|
+
},
|
|
6285
|
+
{
|
|
6286
|
+
name: "get_troubleshooting_case",
|
|
6287
|
+
description: "\u83B7\u53D6\u6307\u5B9A\u6545\u969C\u6392\u9664\u6848\u4F8B\u7684\u5B8C\u6574\u5185\u5BB9",
|
|
6288
|
+
inputSchema: {
|
|
6289
|
+
type: "object",
|
|
6290
|
+
properties: {
|
|
6291
|
+
framework: {
|
|
6292
|
+
type: "string",
|
|
6293
|
+
description: "\u6846\u67B6\u7C7B\u578B"
|
|
6294
|
+
},
|
|
6295
|
+
caseId: {
|
|
6296
|
+
type: "string",
|
|
6297
|
+
description: "\u6848\u4F8B ID"
|
|
6298
|
+
}
|
|
6299
|
+
},
|
|
6300
|
+
required: ["framework", "caseId"]
|
|
6301
|
+
}
|
|
6302
|
+
},
|
|
6303
|
+
{
|
|
6304
|
+
name: "list_troubleshooting_cases",
|
|
6305
|
+
description: "\u5217\u51FA\u6240\u6709\u53EF\u7528\u7684\u6545\u969C\u6392\u9664\u6848\u4F8B",
|
|
6306
|
+
inputSchema: {
|
|
6307
|
+
type: "object",
|
|
6308
|
+
properties: {
|
|
6309
|
+
framework: {
|
|
6310
|
+
type: "string",
|
|
6311
|
+
description: "\u6309\u6846\u67B6\u7B5B\u9009\uFF08\u53EF\u9009\uFF09"
|
|
6312
|
+
}
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
5945
6315
|
}
|
|
5946
6316
|
]
|
|
5947
6317
|
}));
|
|
@@ -5949,15 +6319,15 @@ var CopilotPromptsMCPServer = class {
|
|
|
5949
6319
|
var _a, _b;
|
|
5950
6320
|
try {
|
|
5951
6321
|
const { name, arguments: args } = request.params;
|
|
5952
|
-
|
|
5953
|
-
|
|
6322
|
+
logger3.debug(`\u8C03\u7528\u5DE5\u5177: ${name}`);
|
|
6323
|
+
logger3.debug(`\u53C2\u6570:`, args);
|
|
5954
6324
|
const workspacePath = (args == null ? void 0 : args.workspacePath) || (args == null ? void 0 : args.projectPath);
|
|
5955
6325
|
let autoConfigMessage = null;
|
|
5956
6326
|
if (workspacePath) {
|
|
5957
6327
|
const configResult = ensureWorkspaceConfig(workspacePath);
|
|
5958
6328
|
if (configResult.wasFixed) {
|
|
5959
6329
|
autoConfigMessage = configResult.message || null;
|
|
5960
|
-
|
|
6330
|
+
logger3.info(`\u81EA\u52A8\u914D\u7F6E\u5DF2\u4FEE\u590D: ${workspacePath}`);
|
|
5961
6331
|
}
|
|
5962
6332
|
}
|
|
5963
6333
|
let result;
|
|
@@ -6013,6 +6383,47 @@ var CopilotPromptsMCPServer = class {
|
|
|
6013
6383
|
case "generate_project_skeleton":
|
|
6014
6384
|
result = await generateProjectSkeleton(args);
|
|
6015
6385
|
break;
|
|
6386
|
+
case "query_troubleshooting_cases":
|
|
6387
|
+
result = await queryTroubleshootingCases(args);
|
|
6388
|
+
break;
|
|
6389
|
+
case "troubleshoot":
|
|
6390
|
+
const troubleshootArgs = args;
|
|
6391
|
+
const problemText = troubleshootArgs.problem || "";
|
|
6392
|
+
let detectedFramework = troubleshootArgs.framework;
|
|
6393
|
+
if (!detectedFramework) {
|
|
6394
|
+
if (problemText.toLowerCase().includes("flutter") || problemText.includes("Widget") || problemText.includes("BoxShadow") || problemText.includes("Dart")) {
|
|
6395
|
+
detectedFramework = "flutter";
|
|
6396
|
+
} else if (problemText.toLowerCase().includes("vue") || problemText.includes("Element") || problemText.includes("el-")) {
|
|
6397
|
+
detectedFramework = "vue3";
|
|
6398
|
+
} else if (problemText.toLowerCase().includes("react")) {
|
|
6399
|
+
detectedFramework = "react";
|
|
6400
|
+
}
|
|
6401
|
+
}
|
|
6402
|
+
const extractedKeywords = [];
|
|
6403
|
+
const keywordPatterns = [
|
|
6404
|
+
// 英文关键词
|
|
6405
|
+
/\b(shadow|阴影|透出|transparency|clip|裁剪|layout|布局|animation|动画|color|颜色|border|边框|svg|icon|图标|input|输入|button|按钮|table|表格|form|表单|style|样式)\b/gi
|
|
6406
|
+
];
|
|
6407
|
+
for (const pattern of keywordPatterns) {
|
|
6408
|
+
const matches = problemText.match(pattern);
|
|
6409
|
+
if (matches) {
|
|
6410
|
+
extractedKeywords.push(...matches.map((m) => m.toLowerCase()));
|
|
6411
|
+
}
|
|
6412
|
+
}
|
|
6413
|
+
const uniqueKeywords = [...new Set(extractedKeywords)];
|
|
6414
|
+
result = await queryTroubleshootingCases({
|
|
6415
|
+
framework: detectedFramework,
|
|
6416
|
+
keywords: uniqueKeywords.length > 0 ? uniqueKeywords : void 0,
|
|
6417
|
+
errorMessage: problemText,
|
|
6418
|
+
limit: 5
|
|
6419
|
+
});
|
|
6420
|
+
break;
|
|
6421
|
+
case "get_troubleshooting_case":
|
|
6422
|
+
result = await getTroubleshootingCaseContent(args);
|
|
6423
|
+
break;
|
|
6424
|
+
case "list_troubleshooting_cases":
|
|
6425
|
+
result = await listTroubleshootingCases(args == null ? void 0 : args.framework);
|
|
6426
|
+
break;
|
|
6016
6427
|
default:
|
|
6017
6428
|
throw new Error(`\u672A\u77E5\u5DE5\u5177: ${name}`);
|
|
6018
6429
|
}
|
|
@@ -6031,7 +6442,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
6031
6442
|
}
|
|
6032
6443
|
return result;
|
|
6033
6444
|
} catch (error) {
|
|
6034
|
-
|
|
6445
|
+
logger3.error(`\u5DE5\u5177\u6267\u884C\u5931\u8D25:`, error);
|
|
6035
6446
|
return errorResponse(error);
|
|
6036
6447
|
}
|
|
6037
6448
|
});
|
|
@@ -6100,27 +6511,35 @@ var CopilotPromptsMCPServer = class {
|
|
|
6100
6511
|
`\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`
|
|
6101
6512
|
];
|
|
6102
6513
|
startupInfo.forEach((line) => console.error(line));
|
|
6103
|
-
|
|
6514
|
+
logger3.info(`MCP Server \u5C31\u7EEA\uFF0C\u7B49\u5F85 Copilot Chat \u8FDE\u63A5...`);
|
|
6104
6515
|
}
|
|
6105
6516
|
};
|
|
6106
|
-
var
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6517
|
+
var isTestMode = process.env.MTA_TEST_MODE === "true" || process.argv.includes("--test");
|
|
6518
|
+
if (!isTestMode) {
|
|
6519
|
+
const server = new CopilotPromptsMCPServer();
|
|
6520
|
+
server.run().catch((error) => {
|
|
6521
|
+
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`);
|
|
6522
|
+
console.error(`\u274C MTA MCP Server \u542F\u52A8\u5931\u8D25`);
|
|
6523
|
+
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`);
|
|
6524
|
+
console.error(`\u9519\u8BEF\u4FE1\u606F: ${error instanceof Error ? error.message : String(error)}`);
|
|
6525
|
+
console.error(``);
|
|
6526
|
+
console.error(`\u{1F50D} \u53EF\u80FD\u7684\u539F\u56E0:`);
|
|
6527
|
+
console.error(` 1. Node.js \u7248\u672C\u8FC7\u4F4E\uFF08\u9700\u8981 16+\uFF09`);
|
|
6528
|
+
console.error(` 2. \u4F9D\u8D56\u5B89\u88C5\u4E0D\u5B8C\u6574`);
|
|
6529
|
+
console.error(` 3. \u7AEF\u53E3\u88AB\u5360\u7528`);
|
|
6530
|
+
console.error(``);
|
|
6531
|
+
console.error(`\u{1F4A1} \u89E3\u51B3\u5EFA\u8BAE:`);
|
|
6532
|
+
console.error(` \u2022 \u8FD0\u884C node --version \u68C0\u67E5\u7248\u672C`);
|
|
6533
|
+
console.error(` \u2022 \u8FD0\u884C npm install \u91CD\u65B0\u5B89\u88C5\u4F9D\u8D56`);
|
|
6534
|
+
console.error(` \u2022 \u68C0\u67E5\u662F\u5426\u6709\u5176\u4ED6 MCP \u670D\u52A1\u5668\u5B9E\u4F8B\u8FD0\u884C`);
|
|
6535
|
+
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`);
|
|
6536
|
+
logger3.error("\u670D\u52A1\u5668\u542F\u52A8\u5931\u8D25:", error);
|
|
6537
|
+
process.exit(1);
|
|
6538
|
+
});
|
|
6539
|
+
}
|
|
6540
|
+
export {
|
|
6541
|
+
getTroubleshootingCaseContent,
|
|
6542
|
+
listTroubleshootingCases,
|
|
6543
|
+
queryTroubleshootingCases
|
|
6544
|
+
};
|
|
6126
6545
|
//# sourceMappingURL=index.js.map
|