mta-mcp 2.12.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.
Files changed (24) hide show
  1. package/agents/flutter.agent.md +117 -1147
  2. package/agents/vue3.agent.md +177 -464
  3. package/dist/index.d.ts +63 -0
  4. package/dist/index.js +1858 -139
  5. package/dist/index.js.map +1 -1
  6. package/package.json +2 -1
  7. package/troubleshooting/README.md +366 -0
  8. package/troubleshooting/USAGE_GUIDE.md +289 -0
  9. package/troubleshooting/flutter/clip-/351/230/264/345/275/261/350/243/201/345/211/252.md +244 -0
  10. package/troubleshooting/flutter/input-/345/255/227/346/256/265/347/274/272/345/244/261.md +240 -0
  11. package/troubleshooting/flutter/input-/350/276/271/346/241/206/351/227/256/351/242/230.md +236 -0
  12. package/troubleshooting/flutter/layout-/345/260/272/345/257/270/344/270/215/345/214/271/351/205/215.md +214 -0
  13. package/troubleshooting/flutter/shadow-/351/200/217/345/207/272/351/227/256/351/242/230.md +172 -0
  14. package/troubleshooting/flutter/sketch-/345/233/276/346/240/207/345/260/272/345/257/270.md +135 -0
  15. package/troubleshooting/flutter/sketch-/345/256/214/346/225/264/346/217/220/345/217/226.md +201 -0
  16. package/troubleshooting/flutter/sketch-/345/261/236/346/200/247/346/234/252/344/275/277/347/224/250.md +139 -0
  17. package/troubleshooting/flutter/svg-/346/234/252/345/261/205/344/270/255.md +120 -0
  18. package/troubleshooting/flutter/svg-/351/242/234/350/211/262/345/274/202/345/270/270.md +117 -0
  19. package/troubleshooting/flutter/tabbar-/345/212/250/347/224/273/345/220/214/346/255/245.md +107 -0
  20. package/troubleshooting/flutter/withopacity-/345/274/203/347/224/250.md +81 -0
  21. package/troubleshooting/vue3/cascader-/350/257/257/346/233/277/346/215/242.md +130 -0
  22. package/troubleshooting/vue3/drawer-input-/346/240/267/345/274/217.md +181 -0
  23. package/troubleshooting/vue3/table-/347/274/226/350/276/221/345/217/226/346/266/210.md +148 -0
  24. 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(logger3) {
22
- this.logger = logger3;
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(logger3) {
442
+ function getResourceLoader(logger4) {
443
443
  if (!resourceLoaderInstance) {
444
- resourceLoaderInstance = new ResourceLoader(logger3);
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(logger3) {
456
+ constructor(logger4) {
457
457
  this.initialized = false;
458
- this.logger = logger3;
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 logger3 = new ConsoleLogger();
1003
+ const logger4 = new ConsoleLogger();
1004
1004
  try {
1005
1005
  let projectPath = args.projectPath;
1006
1006
  if (!projectPath) {
1007
1007
  projectPath = process.cwd();
1008
- logger3.log(`\u{1F4CD} \u672A\u6307\u5B9A\u8DEF\u5F84\uFF0C\u4F7F\u7528\u5F53\u524D\u76EE\u5F55: ${projectPath}`);
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(logger3);
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
- logger3.log(`\u{1F30D} \u68C0\u6D4B\u56FD\u9645\u5316\u914D\u7F6E...`);
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
- logger3.error(`\u5206\u6790\u9879\u76EE\u5931\u8D25: ${error}`);
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 logger3 = new ConsoleLogger();
1074
+ const logger4 = new ConsoleLogger();
1075
1075
  try {
1076
- const matcher = new SmartAgentMatcher(logger3);
1077
- const resourceLoader = getResourceLoader(logger3);
1078
- logger3.log("\u6B63\u5728\u4ECE\u5305\u5185\u52A0\u8F7D Agents...");
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
- logger3.error(`\u5339\u914D Agents \u5931\u8D25: ${error}`);
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(logger3) {
1191
- this.logger = logger3;
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(logger3) {
1250
- this.logger = logger3 || new ConsoleLogger();
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 logger3 = new ConsoleLogger();
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(logger3);
1523
- const githubClient = new GitHubClient(logger3);
1522
+ const matcher = new SmartAgentMatcher(logger4);
1523
+ const githubClient = new GitHubClient(logger4);
1524
1524
  let selectedAgents = [];
1525
1525
  if (args.autoMatch !== false) {
1526
- logger3.log("\u6B63\u5728\u5206\u6790\u9879\u76EE\u7279\u5F81...");
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
- logger3.log("\u6B63\u5728\u5339\u914D Agents...");
1534
- const resourceLoader = getResourceLoader(logger3);
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
- logger3.log(`\u6210\u529F\u52A0\u8F7D ${availableAgents.length} \u4E2A Agents`);
1539
+ logger4.log(`\u6210\u529F\u52A0\u8F7D ${availableAgents.length} \u4E2A Agents`);
1540
1540
  selectedAgents = matcher.matchAgents(features, availableAgents);
1541
- logger3.log(`\u5339\u914D\u5230 ${selectedAgents.length} \u4E2A Agents`);
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
- logger3.log(`\u4F7F\u7528\u6307\u5B9A\u7684 Agents: ${args.agentIds.join(", ")}`);
1545
+ logger4.log(`\u4F7F\u7528\u6307\u5B9A\u7684 Agents: ${args.agentIds.join(", ")}`);
1546
1546
  selectedAgents = [];
1547
- const resourceLoader = getResourceLoader(logger3);
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
- logger3.log(`\u2705 \u52A0\u8F7D Agent: ${id}`);
1552
+ logger4.log(`\u2705 \u52A0\u8F7D Agent: ${id}`);
1553
1553
  } else {
1554
- logger3.error(`Agent ${id} \u4E0D\u5B58\u5728`);
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
- logger3.log("\u6B63\u5728\u751F\u6210\u914D\u7F6E\u6587\u4EF6...");
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
- logger3.log(`\u2705 \u5DF2\u52A0\u8F7D\u914D\u7F6E\u65B9\u6848: ${configData.name}`);
1734
+ logger4.log(`\u2705 \u5DF2\u52A0\u8F7D\u914D\u7F6E\u65B9\u6848: ${configData.name}`);
1735
1735
  }
1736
1736
  } catch (error) {
1737
- logger3.error(`\u52A0\u8F7D\u914D\u7F6E\u65B9\u6848\u5931\u8D25: ${error}`);
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
- logger3.log("\u2705 \u5DF2\u4FDD\u7559\u81EA\u5B9A\u4E49\u5185\u5BB9");
1816
+ logger4.log("\u2705 \u5DF2\u4FDD\u7559\u81EA\u5B9A\u4E49\u5185\u5BB9");
1817
1817
  }
1818
- const validator = new CodeValidator(logger3);
1818
+ const validator = new CodeValidator(logger4);
1819
1819
  const validation = validator.validateConfigContent(content);
1820
1820
  if (!validation.isValid) {
1821
- logger3.error("\u26A0\uFE0F \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u5931\u8D25\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D...");
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
- logger3.log(`\u2705 \u5DF2\u81EA\u52A8\u4FEE\u590D ${fixResult.changes.length} \u4E2A\u95EE\u9898:`);
1826
- fixResult.changes.forEach((change) => logger3.log(` - ${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
- logger3.error("\u274C \u81EA\u52A8\u4FEE\u590D\u540E\u4ECD\u5B58\u5728\u95EE\u9898:");
1831
- logger3.error(report);
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
- logger3.error(report);
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
- logger3.log("\u26A0\uFE0F \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u901A\u8FC7\uFF0C\u4F46\u6709\u4EE5\u4E0B\u8B66\u544A:");
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
- logger3.log(` - [${warning.type}] ${warning.message}`);
1860
+ logger4.log(` - [${warning.type}] ${warning.message}`);
1861
1861
  });
1862
1862
  } else {
1863
- logger3.log("\u2705 \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u901A\u8FC7");
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
- logger3.log(`\u2705 \u914D\u7F6E\u6587\u4EF6\u5DF2\u751F\u6210: ${configPath}`);
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
- logger3.error(`\u751F\u6210\u914D\u7F6E\u5931\u8D25: ${error}`);
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 logger3 = new ConsoleLogger();
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
- logger3.log("\u{1F680} \u5F00\u59CB\u4E3A\u9879\u76EE\u751F\u6210 copilot-instructions.md...");
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
- logger3.log("\u{1F50D} \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\u6587\u4EF6\uFF0C\u5F00\u59CB\u5206\u6790\u9879\u76EE...");
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
- logger3.log("\u2705 \u914D\u7F6E\u5B8C\u6210\uFF01");
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
- logger3.error(`\u914D\u7F6E\u5931\u8D25: ${error}`);
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 logger3 = new ConsoleLogger();
2005
+ const logger4 = new ConsoleLogger();
2006
2006
  try {
2007
2007
  let projectPath = args.projectPath;
2008
2008
  if (!projectPath) {
2009
2009
  projectPath = process.cwd();
2010
- logger3.log(`\u{1F4A1} \u672A\u6307\u5B9A\u9879\u76EE\u8DEF\u5F84\uFF0C\u4F7F\u7528\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55: ${projectPath}`);
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
- logger3.log(`\u{1F680} \u5F00\u59CB\u521D\u59CB\u5316\u9879\u76EE: ${projectPath}`);
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
- logger3.error(`\u521D\u59CB\u5316\u5931\u8D25: ${error}`);
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 logger3 = new ConsoleLogger();
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
- logger3.log(`\u{1F3AF} \u4F7F\u7528\u9884\u8BBE: ${preset.name}`);
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
- logger3.error(`\u4F7F\u7528\u9884\u8BBE\u5931\u8D25: ${error}`);
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 logger3 = new ConsoleLogger();
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
- logger3.log("\u{1F50D} \u68C0\u67E5\u670D\u52A1\u5668\u72B6\u6001...");
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
- logger3.log("\u{1F50D} \u68C0\u67E5\u914D\u7F6E\u6587\u4EF6...");
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
- logger3.log("\u{1F50D} \u68C0\u67E5\u4F9D\u8D56...");
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
- logger3.log("\u{1F50D} \u68C0\u67E5\u89C4\u8303\u6587\u4EF6...");
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
- logger3.log(`${statusEmoji[overallStatus]} \u5065\u5EB7\u68C0\u67E5\u5B8C\u6210`);
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
- logger3.error(`\u5065\u5EB7\u68C0\u67E5\u5931\u8D25: ${error}`);
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 logger3 = new ConsoleLogger();
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, logger3);
2944
+ let context = detectContext(args, logger4);
2945
2945
  if (args.projectPath && fs11.existsSync(args.projectPath)) {
2946
- const projectContext = await analyzeProject2(args.projectPath, logger3);
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
- logger3.error(`\u89C4\u8303\u83B7\u53D6\u5931\u8D25: ${error}`);
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, logger3) {
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
- logger3.log(`\u2705 \u68C0\u6D4B\u5230\u7528\u6237\u914D\u7F6E\u7684 Agents: ${agents.join(", ")}`);
3005
+ logger4.log(`\u2705 \u68C0\u6D4B\u5230\u7528\u6237\u914D\u7F6E\u7684 Agents: ${agents.join(", ")}`);
3006
3006
  }
3007
3007
  } catch (error) {
3008
- logger3.error(`\u8BFB\u53D6\u7528\u6237\u914D\u7F6E\u5931\u8D25: ${error}`);
3008
+ logger4.error(`\u8BFB\u53D6\u7528\u6237\u914D\u7F6E\u5931\u8D25: ${error}`);
3009
3009
  }
3010
3010
  }
3011
- const matcher = new SmartAgentMatcher(logger3);
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
- logger3.log(`\u{1F50D} \u9879\u76EE\u6280\u672F\u6808: ${result.imports.join(", ")}`);
3030
+ logger4.log(`\u{1F50D} \u9879\u76EE\u6280\u672F\u6808: ${result.imports.join(", ")}`);
3031
3031
  } catch (error) {
3032
- logger3.error(`\u9879\u76EE\u5206\u6790\u5931\u8D25: ${error}`);
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, logger3) {
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 logger3 = new ConsoleLogger();
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
- logger3.error(`\u83B7\u53D6\u89C4\u8303\u5931\u8D25: ${error}`);
3463
+ logger4.error(`\u83B7\u53D6\u89C4\u8303\u5931\u8D25: ${error}`);
3464
3464
  return {
3465
3465
  content: [{
3466
3466
  type: "text",
@@ -3623,7 +3623,11 @@ var SCENARIO_STANDARDS = {
3623
3623
  // ========== 特殊场景 ==========
3624
3624
  "logicflow": ["logicflow", "vue3-composition"],
3625
3625
  "permission": ["permission-design", "route-guard"],
3626
- "performance": ["performance-optimization", "lazy-loading"]
3626
+ "performance": ["performance-optimization", "lazy-loading"],
3627
+ // ========== 项目克隆场景 ==========
3628
+ "clone-project": ["project-structure", "architecture-patterns", "code-organization"],
3629
+ "project-skeleton": ["project-structure", "base-config", "utility-patterns"],
3630
+ "style-migration": ["css-architecture", "theme-system", "ui-customization"]
3627
3631
  };
3628
3632
  var FILETYPE_STANDARDS = {
3629
3633
  "vue": ["vue3-composition"],
@@ -3671,7 +3675,7 @@ function suggestStandards(options) {
3671
3675
 
3672
3676
  // src/tools/queryMappings.ts
3673
3677
  async function queryMappings(args) {
3674
- const logger3 = new ConsoleLogger();
3678
+ const logger4 = new ConsoleLogger();
3675
3679
  try {
3676
3680
  if (args.listAll) {
3677
3681
  return {
@@ -3724,7 +3728,7 @@ async function queryMappings(args) {
3724
3728
  }]
3725
3729
  };
3726
3730
  } catch (error) {
3727
- logger3.error(`\u67E5\u8BE2\u6620\u5C04\u5931\u8D25: ${error}`);
3731
+ logger4.error(`\u67E5\u8BE2\u6620\u5C04\u5931\u8D25: ${error}`);
3728
3732
  return {
3729
3733
  content: [{
3730
3734
  type: "text",
@@ -3922,7 +3926,7 @@ function searchTemplates(query) {
3922
3926
 
3923
3927
  // src/tools/listTemplates.ts
3924
3928
  async function listTemplates(args) {
3925
- const logger3 = new ConsoleLogger();
3929
+ const logger4 = new ConsoleLogger();
3926
3930
  try {
3927
3931
  let templates;
3928
3932
  if (args.search) {
@@ -3956,7 +3960,7 @@ async function listTemplates(args) {
3956
3960
  }]
3957
3961
  };
3958
3962
  } catch (error) {
3959
- logger3.error(`\u5217\u51FA\u6A21\u677F\u5931\u8D25: ${error}`);
3963
+ logger4.error(`\u5217\u51FA\u6A21\u677F\u5931\u8D25: ${error}`);
3960
3964
  return {
3961
3965
  content: [{
3962
3966
  type: "text",
@@ -3970,7 +3974,7 @@ async function listTemplates(args) {
3970
3974
 
3971
3975
  // src/tools/getTemplate.ts
3972
3976
  async function getTemplate(args) {
3973
- const logger3 = new ConsoleLogger();
3977
+ const logger4 = new ConsoleLogger();
3974
3978
  try {
3975
3979
  const result = getTemplateById(args.id, args.includeFiles ?? false);
3976
3980
  if (!result) {
@@ -4011,7 +4015,7 @@ async function getTemplate(args) {
4011
4015
  }]
4012
4016
  };
4013
4017
  } catch (error) {
4014
- logger3.error(`\u83B7\u53D6\u6A21\u677F\u5931\u8D25: ${error}`);
4018
+ logger4.error(`\u83B7\u53D6\u6A21\u677F\u5931\u8D25: ${error}`);
4015
4019
  return {
4016
4020
  content: [{
4017
4021
  type: "text",
@@ -4023,6 +4027,1211 @@ async function getTemplate(args) {
4023
4027
  }
4024
4028
  }
4025
4029
 
4030
+ // src/tools/cloneProject.ts
4031
+ import * as fs15 from "fs";
4032
+ import * as path14 from "path";
4033
+
4034
+ // src/core/projectCloneAnalyzer.ts
4035
+ import * as fs14 from "fs";
4036
+ import * as path13 from "path";
4037
+ import glob3 from "fast-glob";
4038
+ var ProjectCloneAnalyzer = class {
4039
+ constructor(logger4) {
4040
+ this.logger = logger4 || new ConsoleLogger();
4041
+ }
4042
+ /**
4043
+ * 深度分析项目
4044
+ */
4045
+ async analyzeProject(projectPath) {
4046
+ this.logger.log(`\u{1F50D} \u5F00\u59CB\u6DF1\u5EA6\u5206\u6790\u9879\u76EE: ${projectPath}`);
4047
+ if (!fs14.existsSync(projectPath)) {
4048
+ throw new Error(`\u9879\u76EE\u8DEF\u5F84\u4E0D\u5B58\u5728: ${projectPath}`);
4049
+ }
4050
+ const projectName = path13.basename(projectPath);
4051
+ const projectType = await this.detectProjectType(projectPath);
4052
+ this.logger.log(`\u{1F4E6} \u68C0\u6D4B\u5230\u9879\u76EE\u7C7B\u578B: ${projectType}`);
4053
+ let result;
4054
+ switch (projectType) {
4055
+ case "vue":
4056
+ result = await this.analyzeVueProject(projectPath, projectName);
4057
+ break;
4058
+ case "react":
4059
+ result = await this.analyzeReactProject(projectPath, projectName);
4060
+ break;
4061
+ case "flutter":
4062
+ result = await this.analyzeFlutterProject(projectPath, projectName);
4063
+ break;
4064
+ default:
4065
+ result = await this.analyzeGenericProject(projectPath, projectName);
4066
+ }
4067
+ result.qualityAssessment = this.assessQuality(result);
4068
+ result.templateSuggestions = this.suggestTemplates(result);
4069
+ this.logger.log(`\u2705 \u9879\u76EE\u5206\u6790\u5B8C\u6210`);
4070
+ return result;
4071
+ }
4072
+ /**
4073
+ * 检测项目类型
4074
+ */
4075
+ async detectProjectType(projectPath) {
4076
+ if (fs14.existsSync(path13.join(projectPath, "pubspec.yaml"))) {
4077
+ return "flutter";
4078
+ }
4079
+ const packageJsonPath = path13.join(projectPath, "package.json");
4080
+ if (fs14.existsSync(packageJsonPath)) {
4081
+ try {
4082
+ const pkg = JSON.parse(fs14.readFileSync(packageJsonPath, "utf-8"));
4083
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
4084
+ if (deps["vue"]) return "vue";
4085
+ if (deps["react"]) return "react";
4086
+ } catch {
4087
+ }
4088
+ }
4089
+ const vueFiles = await glob3("**/*.vue", { cwd: projectPath, ignore: ["node_modules/**"] });
4090
+ if (vueFiles.length > 0) return "vue";
4091
+ const tsxFiles = await glob3("**/*.tsx", { cwd: projectPath, ignore: ["node_modules/**"] });
4092
+ if (tsxFiles.length > 0) return "react";
4093
+ return "generic";
4094
+ }
4095
+ /**
4096
+ * 分析 Vue 项目
4097
+ */
4098
+ async analyzeVueProject(projectPath, projectName) {
4099
+ const result = {
4100
+ success: true,
4101
+ projectName,
4102
+ projectPath,
4103
+ analyzedAt: (/* @__PURE__ */ new Date()).toISOString(),
4104
+ techStack: {
4105
+ framework: "Vue 3",
4106
+ language: "TypeScript",
4107
+ buildTool: "Vite",
4108
+ uiLibrary: null,
4109
+ stateManagement: null
4110
+ },
4111
+ architectureLayers: [],
4112
+ utilities: [],
4113
+ styleSystem: await this.analyzeStyleSystem(projectPath, "vue"),
4114
+ configSystem: await this.analyzeConfigSystem(projectPath, "vue"),
4115
+ corePages: await this.analyzeCorePages(projectPath, "vue"),
4116
+ skeleton: {
4117
+ requiredDirectories: [],
4118
+ coreUtils: [],
4119
+ styleSystem: await this.analyzeStyleSystem(projectPath, "vue"),
4120
+ configSystem: await this.analyzeConfigSystem(projectPath, "vue"),
4121
+ corePages: await this.analyzeCorePages(projectPath, "vue"),
4122
+ businessFilesToRemove: [],
4123
+ filesToClean: []
4124
+ },
4125
+ qualityAssessment: {
4126
+ score: 0,
4127
+ strengths: [],
4128
+ weaknesses: [],
4129
+ suggestions: []
4130
+ },
4131
+ templateSuggestions: []
4132
+ };
4133
+ await this.analyzePackageJson(projectPath, result);
4134
+ result.architectureLayers = await this.analyzeVueArchitecture(projectPath);
4135
+ result.utilities = await this.analyzeUtilities(projectPath, "vue");
4136
+ result.skeleton = this.generateSkeleton(result);
4137
+ return result;
4138
+ }
4139
+ /**
4140
+ * 分析 React 项目
4141
+ */
4142
+ async analyzeReactProject(projectPath, projectName) {
4143
+ const result = await this.analyzeVueProject(projectPath, projectName);
4144
+ result.techStack.framework = "React";
4145
+ return result;
4146
+ }
4147
+ /**
4148
+ * 分析 Flutter 项目
4149
+ */
4150
+ async analyzeFlutterProject(projectPath, projectName) {
4151
+ const result = {
4152
+ success: true,
4153
+ projectName,
4154
+ projectPath,
4155
+ analyzedAt: (/* @__PURE__ */ new Date()).toISOString(),
4156
+ techStack: {
4157
+ framework: "Flutter",
4158
+ language: "Dart",
4159
+ buildTool: "Flutter SDK",
4160
+ uiLibrary: "Material Design",
4161
+ stateManagement: null
4162
+ },
4163
+ architectureLayers: [],
4164
+ utilities: [],
4165
+ styleSystem: await this.analyzeStyleSystem(projectPath, "flutter"),
4166
+ configSystem: await this.analyzeConfigSystem(projectPath, "flutter"),
4167
+ corePages: await this.analyzeCorePages(projectPath, "flutter"),
4168
+ skeleton: {
4169
+ requiredDirectories: [],
4170
+ coreUtils: [],
4171
+ styleSystem: await this.analyzeStyleSystem(projectPath, "flutter"),
4172
+ configSystem: await this.analyzeConfigSystem(projectPath, "flutter"),
4173
+ corePages: await this.analyzeCorePages(projectPath, "flutter"),
4174
+ businessFilesToRemove: [],
4175
+ filesToClean: []
4176
+ },
4177
+ qualityAssessment: {
4178
+ score: 0,
4179
+ strengths: [],
4180
+ weaknesses: [],
4181
+ suggestions: []
4182
+ },
4183
+ templateSuggestions: []
4184
+ };
4185
+ await this.analyzePubspec(projectPath, result);
4186
+ result.architectureLayers = await this.analyzeFlutterArchitecture(projectPath);
4187
+ result.utilities = await this.analyzeUtilities(projectPath, "flutter");
4188
+ result.skeleton = this.generateSkeleton(result);
4189
+ return result;
4190
+ }
4191
+ /**
4192
+ * 分析通用项目
4193
+ */
4194
+ async analyzeGenericProject(projectPath, projectName) {
4195
+ const result = {
4196
+ success: true,
4197
+ projectName,
4198
+ projectPath,
4199
+ analyzedAt: (/* @__PURE__ */ new Date()).toISOString(),
4200
+ techStack: {
4201
+ framework: "Unknown",
4202
+ language: "Unknown",
4203
+ buildTool: "Unknown",
4204
+ uiLibrary: null,
4205
+ stateManagement: null
4206
+ },
4207
+ architectureLayers: [],
4208
+ utilities: [],
4209
+ styleSystem: await this.analyzeStyleSystem(projectPath, "generic"),
4210
+ configSystem: await this.analyzeConfigSystem(projectPath, "generic"),
4211
+ corePages: await this.analyzeCorePages(projectPath, "generic"),
4212
+ skeleton: {
4213
+ requiredDirectories: [],
4214
+ coreUtils: [],
4215
+ styleSystem: await this.analyzeStyleSystem(projectPath, "generic"),
4216
+ configSystem: await this.analyzeConfigSystem(projectPath, "generic"),
4217
+ corePages: await this.analyzeCorePages(projectPath, "generic"),
4218
+ businessFilesToRemove: [],
4219
+ filesToClean: []
4220
+ },
4221
+ qualityAssessment: {
4222
+ score: 0,
4223
+ strengths: [],
4224
+ weaknesses: [],
4225
+ suggestions: []
4226
+ },
4227
+ templateSuggestions: []
4228
+ };
4229
+ return result;
4230
+ }
4231
+ /**
4232
+ * 分析 package.json
4233
+ */
4234
+ async analyzePackageJson(projectPath, result) {
4235
+ const packageJsonPath = path13.join(projectPath, "package.json");
4236
+ if (!fs14.existsSync(packageJsonPath)) return;
4237
+ try {
4238
+ const pkg = JSON.parse(fs14.readFileSync(packageJsonPath, "utf-8"));
4239
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
4240
+ if (deps["vite"]) result.techStack.buildTool = "Vite";
4241
+ else if (deps["webpack"]) result.techStack.buildTool = "Webpack";
4242
+ if (deps["element-plus"]) result.techStack.uiLibrary = "Element Plus";
4243
+ else if (deps["ant-design-vue"]) result.techStack.uiLibrary = "Ant Design Vue";
4244
+ else if (deps["naive-ui"]) result.techStack.uiLibrary = "Naive UI";
4245
+ if (deps["pinia"]) result.techStack.stateManagement = "Pinia";
4246
+ else if (deps["vuex"]) result.techStack.stateManagement = "Vuex";
4247
+ if (deps["typescript"]) result.techStack.language = "TypeScript";
4248
+ else result.techStack.language = "JavaScript";
4249
+ } catch (error) {
4250
+ this.logger.error(`\u89E3\u6790 package.json \u5931\u8D25: ${error}`);
4251
+ }
4252
+ }
4253
+ /**
4254
+ * 分析 pubspec.yaml
4255
+ */
4256
+ async analyzePubspec(projectPath, result) {
4257
+ const pubspecPath = path13.join(projectPath, "pubspec.yaml");
4258
+ if (!fs14.existsSync(pubspecPath)) return;
4259
+ try {
4260
+ const content = fs14.readFileSync(pubspecPath, "utf-8");
4261
+ if (content.includes("flutter_bloc:") || content.includes("bloc:")) {
4262
+ result.techStack.stateManagement = "BLoC";
4263
+ } else if (content.includes("provider:")) {
4264
+ result.techStack.stateManagement = "Provider";
4265
+ } else if (content.includes("riverpod:")) {
4266
+ result.techStack.stateManagement = "Riverpod";
4267
+ }
4268
+ } catch (error) {
4269
+ this.logger.error(`\u89E3\u6790 pubspec.yaml \u5931\u8D25: ${error}`);
4270
+ }
4271
+ }
4272
+ /**
4273
+ * 分析 Vue 项目架构
4274
+ */
4275
+ async analyzeVueArchitecture(projectPath) {
4276
+ const layers = [];
4277
+ const srcPath = path13.join(projectPath, "src");
4278
+ if (!fs14.existsSync(srcPath)) {
4279
+ return layers;
4280
+ }
4281
+ const directoryChecks = [
4282
+ { dir: "api", name: "API \u5C42", desc: "HTTP \u8BF7\u6C42\u5C01\u88C5", reusable: true, priority: 2 },
4283
+ { dir: "utils", name: "\u5DE5\u5177\u5C42", desc: "\u901A\u7528\u5DE5\u5177\u51FD\u6570", reusable: true, priority: 3 },
4284
+ { dir: "composables", name: "Composables", desc: "Vue \u7EC4\u5408\u5F0F\u51FD\u6570", reusable: true, priority: 4 },
4285
+ { dir: "hooks", name: "Hooks", desc: "Vue \u7EC4\u5408\u5F0F\u51FD\u6570", reusable: true, priority: 4 },
4286
+ { dir: "stores", name: "\u72B6\u6001\u7BA1\u7406", desc: "Pinia/Vuex \u72B6\u6001", reusable: false, priority: 5 },
4287
+ { dir: "store", name: "\u72B6\u6001\u7BA1\u7406", desc: "Pinia/Vuex \u72B6\u6001", reusable: false, priority: 5 },
4288
+ { dir: "router", name: "\u8DEF\u7531\u5C42", desc: "\u8DEF\u7531\u914D\u7F6E", reusable: true, priority: 3 },
4289
+ { dir: "components", name: "\u7EC4\u4EF6\u5C42", desc: "Vue \u7EC4\u4EF6", reusable: false, priority: 6 },
4290
+ { dir: "views", name: "\u89C6\u56FE\u5C42", desc: "\u9875\u9762\u7EC4\u4EF6", reusable: false, priority: 7 },
4291
+ { dir: "pages", name: "\u9875\u9762\u5C42", desc: "\u9875\u9762\u7EC4\u4EF6", reusable: false, priority: 7 },
4292
+ { dir: "assets", name: "\u8D44\u6E90\u5C42", desc: "\u9759\u6001\u8D44\u6E90", reusable: true, priority: 8 },
4293
+ { dir: "styles", name: "\u6837\u5F0F\u5C42", desc: "\u5168\u5C40\u6837\u5F0F", reusable: true, priority: 2 },
4294
+ { dir: "locales", name: "\u56FD\u9645\u5316", desc: "\u591A\u8BED\u8A00\u914D\u7F6E", reusable: true, priority: 4 },
4295
+ { dir: "i18n", name: "\u56FD\u9645\u5316", desc: "\u591A\u8BED\u8A00\u914D\u7F6E", reusable: true, priority: 4 },
4296
+ { dir: "config", name: "\u914D\u7F6E\u5C42", desc: "\u5E94\u7528\u914D\u7F6E", reusable: true, priority: 2 },
4297
+ { dir: "directives", name: "\u6307\u4EE4\u5C42", desc: "Vue \u81EA\u5B9A\u4E49\u6307\u4EE4", reusable: true, priority: 5 },
4298
+ { dir: "plugins", name: "\u63D2\u4EF6\u5C42", desc: "Vue \u63D2\u4EF6", reusable: true, priority: 4 },
4299
+ { dir: "types", name: "\u7C7B\u578B\u5B9A\u4E49", desc: "TypeScript \u7C7B\u578B", reusable: true, priority: 3 }
4300
+ ];
4301
+ for (const check of directoryChecks) {
4302
+ const dirPath = path13.join(srcPath, check.dir);
4303
+ if (fs14.existsSync(dirPath)) {
4304
+ const files = await glob3("**/*", { cwd: dirPath, onlyFiles: true });
4305
+ layers.push({
4306
+ name: check.name,
4307
+ description: check.desc,
4308
+ directories: [check.dir],
4309
+ keyFiles: files.slice(0, 10),
4310
+ // 只取前10个文件作为示例
4311
+ reusable: check.reusable,
4312
+ priority: check.priority
4313
+ });
4314
+ }
4315
+ }
4316
+ layers.sort((a, b) => a.priority - b.priority);
4317
+ return layers;
4318
+ }
4319
+ /**
4320
+ * 分析 Flutter 项目架构
4321
+ */
4322
+ async analyzeFlutterArchitecture(projectPath) {
4323
+ const layers = [];
4324
+ const libPath = path13.join(projectPath, "lib");
4325
+ if (!fs14.existsSync(libPath)) {
4326
+ return layers;
4327
+ }
4328
+ const directoryChecks = [
4329
+ { dir: "core", name: "\u6838\u5FC3\u5C42", desc: "\u6838\u5FC3\u529F\u80FD", reusable: true, priority: 1 },
4330
+ { dir: "data", name: "\u6570\u636E\u5C42", desc: "\u6570\u636E\u6E90\u548C\u4ED3\u5E93", reusable: false, priority: 3 },
4331
+ { dir: "domain", name: "\u9886\u57DF\u5C42", desc: "\u4E1A\u52A1\u903B\u8F91", reusable: false, priority: 4 },
4332
+ { dir: "presentation", name: "\u8868\u793A\u5C42", desc: "UI \u7EC4\u4EF6", reusable: false, priority: 5 },
4333
+ { dir: "features", name: "\u529F\u80FD\u6A21\u5757", desc: "\u529F\u80FD\u6A21\u5757", reusable: false, priority: 6 },
4334
+ { dir: "shared", name: "\u5171\u4EAB\u5C42", desc: "\u5171\u4EAB\u7EC4\u4EF6", reusable: true, priority: 2 },
4335
+ { dir: "widgets", name: "\u7EC4\u4EF6\u5C42", desc: "UI \u7EC4\u4EF6", reusable: true, priority: 4 },
4336
+ { dir: "utils", name: "\u5DE5\u5177\u5C42", desc: "\u5DE5\u5177\u51FD\u6570", reusable: true, priority: 2 },
4337
+ { dir: "services", name: "\u670D\u52A1\u5C42", desc: "\u4E1A\u52A1\u670D\u52A1", reusable: true, priority: 3 },
4338
+ { dir: "models", name: "\u6A21\u578B\u5C42", desc: "\u6570\u636E\u6A21\u578B", reusable: false, priority: 4 },
4339
+ { dir: "config", name: "\u914D\u7F6E\u5C42", desc: "\u5E94\u7528\u914D\u7F6E", reusable: true, priority: 2 },
4340
+ { dir: "theme", name: "\u4E3B\u9898\u5C42", desc: "\u4E3B\u9898\u6837\u5F0F", reusable: true, priority: 2 },
4341
+ { dir: "l10n", name: "\u56FD\u9645\u5316", desc: "\u591A\u8BED\u8A00", reusable: true, priority: 3 }
4342
+ ];
4343
+ for (const check of directoryChecks) {
4344
+ const dirPath = path13.join(libPath, check.dir);
4345
+ if (fs14.existsSync(dirPath)) {
4346
+ const files = await glob3("**/*.dart", { cwd: dirPath });
4347
+ layers.push({
4348
+ name: check.name,
4349
+ description: check.desc,
4350
+ directories: [check.dir],
4351
+ keyFiles: files.slice(0, 10),
4352
+ reusable: check.reusable,
4353
+ priority: check.priority
4354
+ });
4355
+ }
4356
+ }
4357
+ layers.sort((a, b) => a.priority - b.priority);
4358
+ return layers;
4359
+ }
4360
+ /**
4361
+ * 分析工具类
4362
+ */
4363
+ async analyzeUtilities(projectPath, type) {
4364
+ const utilities = [];
4365
+ const basePath = type === "flutter" ? path13.join(projectPath, "lib") : path13.join(projectPath, "src");
4366
+ if (!fs14.existsSync(basePath)) return utilities;
4367
+ const utilDirs = ["utils", "util", "helpers", "lib", "common", "shared"];
4368
+ const fileExt = type === "flutter" ? "**/*.dart" : "**/*.{ts,js}";
4369
+ for (const dir of utilDirs) {
4370
+ const dirPath = path13.join(basePath, dir);
4371
+ if (!fs14.existsSync(dirPath)) continue;
4372
+ const files = await glob3(fileExt, { cwd: dirPath });
4373
+ for (const file of files) {
4374
+ const filePath = path13.join(dirPath, file);
4375
+ const analysis = await this.analyzeUtilityFile(filePath, type);
4376
+ if (analysis) {
4377
+ utilities.push(analysis);
4378
+ }
4379
+ }
4380
+ }
4381
+ const apiDirs = ["api", "services", "http"];
4382
+ for (const dir of apiDirs) {
4383
+ const dirPath = path13.join(basePath, dir);
4384
+ if (!fs14.existsSync(dirPath)) continue;
4385
+ const files = await glob3(fileExt, { cwd: dirPath });
4386
+ for (const file of files) {
4387
+ const filePath = path13.join(dirPath, file);
4388
+ const analysis = await this.analyzeUtilityFile(filePath, type);
4389
+ if (analysis) {
4390
+ analysis.type = "http";
4391
+ utilities.push(analysis);
4392
+ }
4393
+ }
4394
+ }
4395
+ await this.calculateUsageCount(projectPath, utilities, type);
4396
+ for (const util of utilities) {
4397
+ util.recommended = util.usageCount > 3 || util.type === "http" || util.type === "validation" || util.type === "format";
4398
+ }
4399
+ return utilities;
4400
+ }
4401
+ /**
4402
+ * 分析单个工具类文件
4403
+ */
4404
+ async analyzeUtilityFile(filePath, type) {
4405
+ try {
4406
+ const content = fs14.readFileSync(filePath, "utf-8");
4407
+ const relativePath = filePath;
4408
+ const exports = [];
4409
+ if (type === "flutter") {
4410
+ const classMatches = content.matchAll(/class\s+(\w+)/g);
4411
+ for (const match of classMatches) {
4412
+ exports.push(match[1]);
4413
+ }
4414
+ const funcMatches = content.matchAll(/^\s*(\w+)\s*\([^)]*\)\s*{/gm);
4415
+ for (const match of funcMatches) {
4416
+ if (!["if", "for", "while", "switch", "catch"].includes(match[1])) {
4417
+ exports.push(match[1]);
4418
+ }
4419
+ }
4420
+ } else {
4421
+ const exportMatches = content.matchAll(/export\s+(?:const|function|class|interface|type)\s+(\w+)/g);
4422
+ for (const match of exportMatches) {
4423
+ exports.push(match[1]);
4424
+ }
4425
+ }
4426
+ let utilType = "other";
4427
+ const lowerContent = content.toLowerCase();
4428
+ const fileName = path13.basename(filePath).toLowerCase();
4429
+ if (lowerContent.includes("axios") || lowerContent.includes("fetch") || lowerContent.includes("http") || fileName.includes("request")) {
4430
+ utilType = "http";
4431
+ } else if (lowerContent.includes("localstorage") || lowerContent.includes("sessionstorage") || fileName.includes("storage")) {
4432
+ utilType = "storage";
4433
+ } else if (lowerContent.includes("validate") || lowerContent.includes("validator") || fileName.includes("valid")) {
4434
+ utilType = "validation";
4435
+ } else if (lowerContent.includes("format") || lowerContent.includes("date") || fileName.includes("format")) {
4436
+ utilType = "format";
4437
+ } else if (lowerContent.includes("token") || lowerContent.includes("auth") || fileName.includes("auth")) {
4438
+ utilType = "auth";
4439
+ } else if (lowerContent.includes("router") || lowerContent.includes("route")) {
4440
+ utilType = "router";
4441
+ } else if (lowerContent.includes("i18n") || lowerContent.includes("locale") || lowerContent.includes("translate")) {
4442
+ utilType = "i18n";
4443
+ }
4444
+ const dependencies = [];
4445
+ if (type === "flutter") {
4446
+ const importMatches = content.matchAll(/import\s+'package:(\w+)/g);
4447
+ for (const match of importMatches) {
4448
+ if (!dependencies.includes(match[1])) {
4449
+ dependencies.push(match[1]);
4450
+ }
4451
+ }
4452
+ } else {
4453
+ const importMatches = content.matchAll(/import\s+.*from\s+['"]([^'"]+)['"]/g);
4454
+ for (const match of importMatches) {
4455
+ const dep = match[1];
4456
+ if (!dep.startsWith(".") && !dep.startsWith("@/")) {
4457
+ const pkgName = dep.startsWith("@") ? dep.split("/").slice(0, 2).join("/") : dep.split("/")[0];
4458
+ if (!dependencies.includes(pkgName)) {
4459
+ dependencies.push(pkgName);
4460
+ }
4461
+ }
4462
+ }
4463
+ }
4464
+ return {
4465
+ path: relativePath,
4466
+ type: utilType,
4467
+ exports,
4468
+ dependencies,
4469
+ usageCount: 0,
4470
+ recommended: false
4471
+ };
4472
+ } catch (error) {
4473
+ return null;
4474
+ }
4475
+ }
4476
+ /**
4477
+ * 计算工具类使用频率
4478
+ */
4479
+ async calculateUsageCount(projectPath, utilities, type) {
4480
+ const basePath = type === "flutter" ? path13.join(projectPath, "lib") : path13.join(projectPath, "src");
4481
+ const fileExt = type === "flutter" ? "**/*.dart" : "**/*.{ts,js,vue,tsx,jsx}";
4482
+ const files = await glob3(fileExt, { cwd: basePath, ignore: ["node_modules/**"] });
4483
+ for (const file of files) {
4484
+ try {
4485
+ const content = fs14.readFileSync(path13.join(basePath, file), "utf-8");
4486
+ for (const util of utilities) {
4487
+ const utilName = path13.basename(util.path, path13.extname(util.path));
4488
+ if (content.includes(utilName)) {
4489
+ util.usageCount++;
4490
+ }
4491
+ }
4492
+ } catch {
4493
+ }
4494
+ }
4495
+ }
4496
+ /**
4497
+ * 分析样式系统
4498
+ */
4499
+ async analyzeStyleSystem(projectPath, type) {
4500
+ const result = {
4501
+ globalStyles: [],
4502
+ preprocessor: null,
4503
+ cssFrameworks: [],
4504
+ uiLibrary: null,
4505
+ uiOverrides: [],
4506
+ themeFiles: [],
4507
+ cssVariables: [],
4508
+ mixins: []
4509
+ };
4510
+ if (type === "flutter") {
4511
+ const themeFiles = await glob3("**/theme/**/*.dart", { cwd: projectPath });
4512
+ result.themeFiles = themeFiles;
4513
+ return result;
4514
+ }
4515
+ const srcPath = path13.join(projectPath, "src");
4516
+ if (!fs14.existsSync(srcPath)) return result;
4517
+ const stylePatterns = ["**/*.css", "**/*.scss", "**/*.sass", "**/*.less", "**/*.styl"];
4518
+ for (const pattern of stylePatterns) {
4519
+ const files = await glob3(pattern, { cwd: srcPath, ignore: ["node_modules/**"] });
4520
+ for (const file of files) {
4521
+ const ext = path13.extname(file).slice(1);
4522
+ if (ext === "scss" || ext === "sass") result.preprocessor = ext;
4523
+ else if (ext === "less") result.preprocessor = "less";
4524
+ else if (ext === "styl") result.preprocessor = "stylus";
4525
+ if (file.includes("global") || file.includes("base") || file.includes("main") || file.includes("app")) {
4526
+ result.globalStyles.push(file);
4527
+ }
4528
+ if (file.includes("variable") || file.includes("theme") || file.includes("token")) {
4529
+ result.themeFiles.push(file);
4530
+ }
4531
+ if (file.includes("mixin")) {
4532
+ result.mixins.push(file);
4533
+ }
4534
+ }
4535
+ }
4536
+ const overridePatterns = ["**/element*.{css,scss,less}", "**/antd*.{css,scss,less}", "**/override*.{css,scss,less}"];
4537
+ for (const pattern of overridePatterns) {
4538
+ const files = await glob3(pattern, { cwd: srcPath });
4539
+ if (files.length > 0) {
4540
+ result.uiOverrides.push({
4541
+ path: files[0],
4542
+ components: []
4543
+ // 需要进一步分析
4544
+ });
4545
+ }
4546
+ }
4547
+ return result;
4548
+ }
4549
+ /**
4550
+ * 分析配置系统
4551
+ */
4552
+ async analyzeConfigSystem(projectPath, type) {
4553
+ const result = {
4554
+ envFiles: [],
4555
+ buildConfig: null,
4556
+ routerConfig: null,
4557
+ stateConfig: null,
4558
+ httpConfig: null,
4559
+ i18nConfig: null,
4560
+ otherConfigs: []
4561
+ };
4562
+ const envFiles = await glob3(".env*", { cwd: projectPath, dot: true });
4563
+ result.envFiles = envFiles;
4564
+ if (type === "flutter") {
4565
+ return result;
4566
+ }
4567
+ if (fs14.existsSync(path13.join(projectPath, "vite.config.ts"))) {
4568
+ result.buildConfig = {
4569
+ tool: "vite",
4570
+ configFile: "vite.config.ts",
4571
+ keyFeatures: []
4572
+ };
4573
+ } else if (fs14.existsSync(path13.join(projectPath, "vue.config.js"))) {
4574
+ result.buildConfig = {
4575
+ tool: "webpack",
4576
+ configFile: "vue.config.js",
4577
+ keyFeatures: []
4578
+ };
4579
+ }
4580
+ const srcPath = path13.join(projectPath, "src");
4581
+ const routerFiles = await glob3("**/router/**/*.{ts,js}", { cwd: srcPath });
4582
+ if (routerFiles.length > 0) {
4583
+ result.routerConfig = {
4584
+ type: "vue-router",
4585
+ configFile: routerFiles[0],
4586
+ features: []
4587
+ };
4588
+ }
4589
+ const storeFiles = await glob3("**/{stores,store}/**/*.{ts,js}", { cwd: srcPath });
4590
+ if (storeFiles.length > 0) {
4591
+ result.stateConfig = {
4592
+ type: "pinia",
4593
+ configFile: storeFiles[0]
4594
+ };
4595
+ }
4596
+ const apiFiles = await glob3("**/api/**/*.{ts,js}", { cwd: srcPath });
4597
+ if (apiFiles.length > 0) {
4598
+ result.httpConfig = {
4599
+ client: "axios",
4600
+ configFile: apiFiles.find((f) => f.includes("request") || f.includes("axios") || f.includes("http")) || apiFiles[0],
4601
+ features: []
4602
+ };
4603
+ }
4604
+ const i18nFiles = await glob3("**/{i18n,locales}/**/*.{ts,js,json}", { cwd: srcPath });
4605
+ if (i18nFiles.length > 0) {
4606
+ const locales = i18nFiles.filter((f) => f.endsWith(".json")).map((f) => path13.basename(f, ".json"));
4607
+ result.i18nConfig = {
4608
+ type: "vue-i18n",
4609
+ configFile: i18nFiles.find((f) => f.includes("index")) || i18nFiles[0],
4610
+ locales: [...new Set(locales)]
4611
+ };
4612
+ }
4613
+ return result;
4614
+ }
4615
+ /**
4616
+ * 分析核心页面
4617
+ */
4618
+ async analyzeCorePages(projectPath, type) {
4619
+ const result = {
4620
+ loginPage: null,
4621
+ mainLayout: null,
4622
+ navigation: null,
4623
+ errorPages: [],
4624
+ otherCorePages: []
4625
+ };
4626
+ const basePath = type === "flutter" ? path13.join(projectPath, "lib") : path13.join(projectPath, "src");
4627
+ if (!fs14.existsSync(basePath)) return result;
4628
+ const fileExt = type === "flutter" ? "**/*.dart" : "**/*.{vue,tsx,jsx}";
4629
+ const files = await glob3(fileExt, { cwd: basePath });
4630
+ for (const file of files) {
4631
+ const fileName = file.toLowerCase();
4632
+ if (fileName.includes("login")) {
4633
+ result.loginPage = file;
4634
+ } else if (fileName.includes("layout") && (fileName.includes("main") || fileName.includes("default") || fileName.includes("app"))) {
4635
+ result.mainLayout = file;
4636
+ } else if (fileName.includes("sidebar") || fileName.includes("navbar") || fileName.includes("menu")) {
4637
+ result.navigation = file;
4638
+ } else if (fileName.includes("404") || fileName.includes("403") || fileName.includes("error") || fileName.includes("notfound")) {
4639
+ result.errorPages.push(file);
4640
+ }
4641
+ }
4642
+ return result;
4643
+ }
4644
+ /**
4645
+ * 生成项目骨架
4646
+ */
4647
+ generateSkeleton(analysis) {
4648
+ const skeleton = {
4649
+ requiredDirectories: [],
4650
+ coreUtils: [],
4651
+ styleSystem: analysis.styleSystem,
4652
+ configSystem: analysis.configSystem,
4653
+ corePages: analysis.corePages,
4654
+ businessFilesToRemove: [],
4655
+ filesToClean: []
4656
+ };
4657
+ for (const layer of analysis.architectureLayers) {
4658
+ if (layer.reusable) {
4659
+ skeleton.requiredDirectories.push({
4660
+ path: layer.directories[0],
4661
+ description: layer.description,
4662
+ files: layer.keyFiles
4663
+ });
4664
+ }
4665
+ }
4666
+ skeleton.coreUtils = analysis.utilities.filter((u) => u.recommended);
4667
+ for (const layer of analysis.architectureLayers) {
4668
+ if (!layer.reusable && layer.name !== "\u89C6\u56FE\u5C42" && layer.name !== "\u9875\u9762\u5C42") {
4669
+ skeleton.filesToClean.push(...layer.directories.map((d) => `src/${d}/**/*`));
4670
+ }
4671
+ }
4672
+ return skeleton;
4673
+ }
4674
+ /**
4675
+ * 评估项目质量
4676
+ */
4677
+ assessQuality(analysis) {
4678
+ const assessment = {
4679
+ score: 0,
4680
+ strengths: [],
4681
+ weaknesses: [],
4682
+ suggestions: []
4683
+ };
4684
+ let score = 50;
4685
+ if (analysis.architectureLayers.length >= 5) {
4686
+ score += 10;
4687
+ assessment.strengths.push("\u9879\u76EE\u67B6\u6784\u5C42\u7EA7\u6E05\u6670\uFF0C\u6A21\u5757\u5212\u5206\u5408\u7406");
4688
+ } else if (analysis.architectureLayers.length < 3) {
4689
+ score -= 10;
4690
+ assessment.weaknesses.push("\u9879\u76EE\u7ED3\u6784\u8F83\u7B80\u5355\uFF0C\u7F3A\u5C11\u6E05\u6670\u7684\u5206\u5C42");
4691
+ }
4692
+ const reusableUtils = analysis.utilities.filter((u) => u.recommended).length;
4693
+ if (reusableUtils >= 5) {
4694
+ score += 10;
4695
+ assessment.strengths.push("\u6709\u4E30\u5BCC\u7684\u53EF\u590D\u7528\u5DE5\u5177\u7C7B");
4696
+ }
4697
+ if (analysis.techStack.language === "TypeScript") {
4698
+ score += 10;
4699
+ assessment.strengths.push("\u4F7F\u7528 TypeScript \u63D0\u4F9B\u7C7B\u578B\u5B89\u5168");
4700
+ } else {
4701
+ assessment.suggestions.push("\u5EFA\u8BAE\u4F7F\u7528 TypeScript \u63D0\u5347\u4EE3\u7801\u8D28\u91CF");
4702
+ }
4703
+ if (analysis.styleSystem.themeFiles.length > 0) {
4704
+ score += 5;
4705
+ assessment.strengths.push("\u6709\u5B8C\u5584\u7684\u4E3B\u9898/\u53D8\u91CF\u7CFB\u7EDF");
4706
+ } else {
4707
+ assessment.suggestions.push("\u5EFA\u8BAE\u5EFA\u7ACB\u7EDF\u4E00\u7684\u4E3B\u9898\u53D8\u91CF\u7CFB\u7EDF");
4708
+ }
4709
+ if (analysis.configSystem.httpConfig) {
4710
+ score += 5;
4711
+ assessment.strengths.push("HTTP \u8BF7\u6C42\u5DF2\u7EDF\u4E00\u5C01\u88C5");
4712
+ }
4713
+ if (analysis.configSystem.i18nConfig) {
4714
+ score += 5;
4715
+ assessment.strengths.push("\u5DF2\u914D\u7F6E\u56FD\u9645\u5316\u652F\u6301");
4716
+ }
4717
+ assessment.score = Math.min(100, Math.max(0, score));
4718
+ return assessment;
4719
+ }
4720
+ /**
4721
+ * 建议 MCP 模板
4722
+ */
4723
+ suggestTemplates(analysis) {
4724
+ const suggestions = [];
4725
+ if (!analysis.configSystem.httpConfig) {
4726
+ suggestions.push({
4727
+ templateId: "vue/api-layer",
4728
+ reason: "\u7F3A\u5C11\u7EDF\u4E00\u7684 HTTP \u8BF7\u6C42\u5C01\u88C5",
4729
+ replaceFiles: []
4730
+ });
4731
+ }
4732
+ return suggestions;
4733
+ }
4734
+ /**
4735
+ * 生成开发计划
4736
+ */
4737
+ generateDevelopmentPlan(analysis, newProjectName) {
4738
+ var _a;
4739
+ const plan = {
4740
+ title: `\u57FA\u4E8E ${analysis.projectName} \u521B\u5EFA ${newProjectName} \u5F00\u53D1\u8BA1\u5212`,
4741
+ referenceProject: analysis.projectName,
4742
+ newProjectName,
4743
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
4744
+ phases: [],
4745
+ notes: []
4746
+ };
4747
+ plan.phases.push({
4748
+ phase: 1,
4749
+ name: "\u9879\u76EE\u521D\u59CB\u5316",
4750
+ description: "\u521B\u5EFA\u9879\u76EE\u9AA8\u67B6\uFF0C\u590D\u5236\u57FA\u7840\u914D\u7F6E",
4751
+ tasks: [
4752
+ { task: "\u521B\u5EFA\u9879\u76EE\u76EE\u5F55\u7ED3\u6784", priority: "high", estimatedTime: "10min" },
4753
+ { task: "\u590D\u5236\u6784\u5EFA\u914D\u7F6E", priority: "high", estimatedTime: "5min", files: [((_a = analysis.configSystem.buildConfig) == null ? void 0 : _a.configFile) || ""] },
4754
+ { task: "\u590D\u5236\u73AF\u5883\u914D\u7F6E", priority: "high", estimatedTime: "5min", files: analysis.configSystem.envFiles },
4755
+ { task: "\u5B89\u88C5\u4F9D\u8D56", priority: "high", estimatedTime: "5min" }
4756
+ ]
4757
+ });
4758
+ plan.phases.push({
4759
+ phase: 2,
4760
+ name: "\u57FA\u7840\u8BBE\u65BD\u642D\u5EFA",
4761
+ description: "\u590D\u5236\u5DE5\u5177\u7C7B\u3001\u914D\u7F6E\u6587\u4EF6\u7B49\u57FA\u7840\u4EE3\u7801",
4762
+ tasks: [
4763
+ { task: "\u590D\u5236\u5DE5\u5177\u7C7B", priority: "high", estimatedTime: "15min", files: analysis.skeleton.coreUtils.map((u) => u.path) },
4764
+ { task: "\u590D\u5236 HTTP \u914D\u7F6E", priority: "high", estimatedTime: "10min", files: analysis.configSystem.httpConfig ? [analysis.configSystem.httpConfig.configFile] : [] },
4765
+ { task: "\u590D\u5236\u8DEF\u7531\u914D\u7F6E\uFF08\u9AA8\u67B6\uFF09", priority: "medium", estimatedTime: "10min" },
4766
+ { task: "\u590D\u5236\u7C7B\u578B\u5B9A\u4E49", priority: "medium", estimatedTime: "5min" }
4767
+ ]
4768
+ });
4769
+ plan.phases.push({
4770
+ phase: 3,
4771
+ name: "\u6837\u5F0F\u7CFB\u7EDF\u8FC1\u79FB",
4772
+ description: "\u590D\u5236\u5168\u5C40\u6837\u5F0F\u3001\u4E3B\u9898\u914D\u7F6E\u3001UI \u7EC4\u4EF6\u8986\u76D6\u6837\u5F0F",
4773
+ tasks: [
4774
+ { task: "\u590D\u5236\u5168\u5C40\u6837\u5F0F", priority: "high", estimatedTime: "10min", files: analysis.styleSystem.globalStyles },
4775
+ { task: "\u590D\u5236\u4E3B\u9898/\u53D8\u91CF\u6587\u4EF6", priority: "high", estimatedTime: "5min", files: analysis.styleSystem.themeFiles },
4776
+ { task: "\u590D\u5236 UI \u7EC4\u4EF6\u8986\u76D6\u6837\u5F0F", priority: "medium", estimatedTime: "10min", files: analysis.styleSystem.uiOverrides.map((o) => o.path) },
4777
+ { task: "\u590D\u5236 mixins", priority: "low", estimatedTime: "5min", files: analysis.styleSystem.mixins }
4778
+ ]
4779
+ });
4780
+ plan.phases.push({
4781
+ phase: 4,
4782
+ name: "\u6838\u5FC3\u9875\u9762\u642D\u5EFA",
4783
+ description: "\u590D\u5236\u767B\u5F55\u9875\u3001\u4E3B\u5E03\u5C40\u3001\u5BFC\u822A\u7B49\u6838\u5FC3\u9875\u9762",
4784
+ tasks: [
4785
+ { task: "\u590D\u5236\u4E3B\u5E03\u5C40", priority: "high", estimatedTime: "15min", files: analysis.corePages.mainLayout ? [analysis.corePages.mainLayout] : [] },
4786
+ { task: "\u590D\u5236\u767B\u5F55\u9875", priority: "high", estimatedTime: "15min", files: analysis.corePages.loginPage ? [analysis.corePages.loginPage] : [] },
4787
+ { task: "\u590D\u5236\u5BFC\u822A\u7EC4\u4EF6", priority: "medium", estimatedTime: "10min", files: analysis.corePages.navigation ? [analysis.corePages.navigation] : [] },
4788
+ { task: "\u590D\u5236\u9519\u8BEF\u9875\u9762", priority: "low", estimatedTime: "10min", files: analysis.corePages.errorPages }
4789
+ ]
4790
+ });
4791
+ plan.phases.push({
4792
+ phase: 5,
4793
+ name: "\u6E05\u7406\u548C\u4F18\u5316",
4794
+ description: "\u5220\u9664\u4E1A\u52A1\u4EE3\u7801\u3001\u4F18\u5316\u914D\u7F6E",
4795
+ tasks: [
4796
+ { task: "\u6E05\u7406\u4E1A\u52A1\u7EC4\u4EF6", priority: "high", estimatedTime: "20min" },
4797
+ { task: "\u6E05\u7406\u4E1A\u52A1\u89C6\u56FE", priority: "high", estimatedTime: "20min" },
4798
+ { task: "\u6E05\u7406\u4E1A\u52A1 API", priority: "medium", estimatedTime: "15min" },
4799
+ { task: "\u66F4\u65B0\u9879\u76EE\u540D\u79F0\u548C\u914D\u7F6E", priority: "high", estimatedTime: "10min" }
4800
+ ]
4801
+ });
4802
+ plan.notes = [
4803
+ `\u53C2\u8003\u9879\u76EE\u6280\u672F\u6808: ${analysis.techStack.framework} + ${analysis.techStack.language}`,
4804
+ `UI \u5E93: ${analysis.techStack.uiLibrary || "\u65E0"}`,
4805
+ `\u72B6\u6001\u7BA1\u7406: ${analysis.techStack.stateManagement || "\u65E0"}`,
4806
+ "\u786E\u4FDD\u4FDD\u6301\u4E0E\u53C2\u8003\u9879\u76EE\u4E00\u81F4\u7684\u4EE3\u7801\u98CE\u683C",
4807
+ "\u6CE8\u610F\u68C0\u67E5\u786C\u7F16\u7801\u7684\u9879\u76EE\u540D\u79F0\u548C\u914D\u7F6E",
4808
+ "\u5EFA\u8BAE\u5148\u8FD0\u884C\u53C2\u8003\u9879\u76EE\uFF0C\u786E\u4FDD\u7406\u89E3\u5176\u529F\u80FD"
4809
+ ];
4810
+ return plan;
4811
+ }
4812
+ };
4813
+
4814
+ // src/tools/cloneProject.ts
4815
+ async function analyzeReferenceProject(args) {
4816
+ const logger4 = new ConsoleLogger();
4817
+ try {
4818
+ if (!args.projectPath) {
4819
+ return {
4820
+ content: [{
4821
+ type: "text",
4822
+ text: JSON.stringify({
4823
+ error: "\u8BF7\u63D0\u4F9B\u53C2\u8003\u9879\u76EE\u8DEF\u5F84 (projectPath)",
4824
+ usage: 'analyze_reference_project({ projectPath: "/path/to/project" })'
4825
+ }, null, 2)
4826
+ }]
4827
+ };
4828
+ }
4829
+ if (!fs15.existsSync(args.projectPath)) {
4830
+ return {
4831
+ content: [{
4832
+ type: "text",
4833
+ text: JSON.stringify({
4834
+ error: `\u53C2\u8003\u9879\u76EE\u8DEF\u5F84\u4E0D\u5B58\u5728: ${args.projectPath}`
4835
+ }, null, 2)
4836
+ }]
4837
+ };
4838
+ }
4839
+ logger4.log(`\u{1F50D} \u5F00\u59CB\u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE: ${args.projectPath}`);
4840
+ const analyzer = new ProjectCloneAnalyzer(logger4);
4841
+ const analysis = await analyzer.analyzeProject(args.projectPath);
4842
+ let developmentPlan = null;
4843
+ if (args.newProjectName) {
4844
+ developmentPlan = analyzer.generateDevelopmentPlan(analysis, args.newProjectName);
4845
+ }
4846
+ if (args.generateDocs && args.newProjectPath) {
4847
+ await generateAnalysisDocs(args.newProjectPath, analysis, developmentPlan);
4848
+ logger4.log(`\u{1F4C4} \u5DF2\u751F\u6210\u5206\u6790\u6587\u6863\u5230: ${args.newProjectPath}/docs/`);
4849
+ }
4850
+ const response = {
4851
+ success: true,
4852
+ message: "\u9879\u76EE\u5206\u6790\u5B8C\u6210",
4853
+ projectName: analysis.projectName,
4854
+ techStack: analysis.techStack,
4855
+ architectureSummary: {
4856
+ totalLayers: analysis.architectureLayers.length,
4857
+ reusableLayers: analysis.architectureLayers.filter((l) => l.reusable).length,
4858
+ layers: analysis.architectureLayers.map((l) => ({
4859
+ name: l.name,
4860
+ reusable: l.reusable,
4861
+ priority: l.priority
4862
+ }))
4863
+ },
4864
+ utilitiesSummary: {
4865
+ total: analysis.utilities.length,
4866
+ recommended: analysis.utilities.filter((u) => u.recommended).length,
4867
+ byType: groupBy(analysis.utilities, "type")
4868
+ },
4869
+ styleSystem: {
4870
+ preprocessor: analysis.styleSystem.preprocessor,
4871
+ globalStylesCount: analysis.styleSystem.globalStyles.length,
4872
+ themeFilesCount: analysis.styleSystem.themeFiles.length,
4873
+ uiLibrary: analysis.techStack.uiLibrary
4874
+ },
4875
+ corePages: {
4876
+ hasLogin: !!analysis.corePages.loginPage,
4877
+ hasMainLayout: !!analysis.corePages.mainLayout,
4878
+ hasNavigation: !!analysis.corePages.navigation,
4879
+ errorPagesCount: analysis.corePages.errorPages.length
4880
+ },
4881
+ qualityAssessment: analysis.qualityAssessment,
4882
+ templateSuggestions: analysis.templateSuggestions,
4883
+ skeleton: {
4884
+ requiredDirectoriesCount: analysis.skeleton.requiredDirectories.length,
4885
+ coreUtilsCount: analysis.skeleton.coreUtils.length,
4886
+ directories: analysis.skeleton.requiredDirectories.map((d) => ({
4887
+ path: d.path,
4888
+ description: d.description
4889
+ }))
4890
+ }
4891
+ };
4892
+ if (developmentPlan) {
4893
+ response.developmentPlan = {
4894
+ title: developmentPlan.title,
4895
+ phases: developmentPlan.phases.length,
4896
+ totalTasks: developmentPlan.phases.reduce((sum, p) => sum + p.tasks.length, 0),
4897
+ phasesSummary: developmentPlan.phases.map((p) => ({
4898
+ phase: p.phase,
4899
+ name: p.name,
4900
+ tasksCount: p.tasks.length
4901
+ }))
4902
+ };
4903
+ }
4904
+ response.nextSteps = [
4905
+ "1. \u67E5\u770B\u5206\u6790\u7ED3\u679C\uFF0C\u786E\u8BA4\u9AA8\u67B6\u5185\u5BB9\u7B26\u5408\u9884\u671F",
4906
+ "2. \u5982\u9700\u751F\u6210\u5B8C\u6574\u5206\u6790\u6587\u6863\uFF0C\u8BF7\u6307\u5B9A newProjectPath",
4907
+ "3. \u4F7F\u7528 generate_project_skeleton \u751F\u6210\u65B0\u9879\u76EE",
4908
+ "4. \u6309\u7167\u5F00\u53D1\u8BA1\u5212\u9010\u6B65\u5B8C\u6210\u9879\u76EE\u642D\u5EFA"
4909
+ ];
4910
+ response._fullAnalysis = analysis;
4911
+ return {
4912
+ content: [{
4913
+ type: "text",
4914
+ text: JSON.stringify(response, null, 2)
4915
+ }]
4916
+ };
4917
+ } catch (error) {
4918
+ logger4.error(`\u5206\u6790\u5931\u8D25: ${error}`);
4919
+ return {
4920
+ content: [{
4921
+ type: "text",
4922
+ text: JSON.stringify({
4923
+ error: error instanceof Error ? error.message : String(error),
4924
+ stack: error instanceof Error ? error.stack : void 0
4925
+ }, null, 2)
4926
+ }]
4927
+ };
4928
+ }
4929
+ }
4930
+ async function generateProjectSkeleton(args) {
4931
+ const logger4 = new ConsoleLogger();
4932
+ try {
4933
+ if (!args.referenceProjectPath || !args.newProjectPath || !args.newProjectName) {
4934
+ return {
4935
+ content: [{
4936
+ type: "text",
4937
+ text: JSON.stringify({
4938
+ error: "\u8BF7\u63D0\u4F9B\u5FC5\u8981\u53C2\u6570",
4939
+ required: ["referenceProjectPath", "newProjectPath", "newProjectName"]
4940
+ }, null, 2)
4941
+ }]
4942
+ };
4943
+ }
4944
+ if (!fs15.existsSync(args.referenceProjectPath)) {
4945
+ return {
4946
+ content: [{
4947
+ type: "text",
4948
+ text: JSON.stringify({
4949
+ error: `\u53C2\u8003\u9879\u76EE\u8DEF\u5F84\u4E0D\u5B58\u5728: ${args.referenceProjectPath}`
4950
+ }, null, 2)
4951
+ }]
4952
+ };
4953
+ }
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
+ const analysis = await analyzer.analyzeProject(args.referenceProjectPath);
4959
+ const developmentPlan = analyzer.generateDevelopmentPlan(analysis, args.newProjectName);
4960
+ if (!fs15.existsSync(args.newProjectPath)) {
4961
+ fs15.mkdirSync(args.newProjectPath, { recursive: true });
4962
+ }
4963
+ if (args.generateDocs !== false) {
4964
+ await generateAnalysisDocs(args.newProjectPath, analysis, developmentPlan);
4965
+ logger4.log(`\u{1F4C4} \u5DF2\u751F\u6210\u5206\u6790\u6587\u6863`);
4966
+ }
4967
+ const skeletonGuide = generateSkeletonGuide(analysis, args);
4968
+ return {
4969
+ content: [{
4970
+ type: "text",
4971
+ text: JSON.stringify({
4972
+ success: true,
4973
+ message: "\u9879\u76EE\u9AA8\u67B6\u89C4\u5212\u5B8C\u6210",
4974
+ newProjectPath: args.newProjectPath,
4975
+ docsGenerated: args.generateDocs !== false,
4976
+ skeletonGuide,
4977
+ developmentPlan: {
4978
+ phases: developmentPlan.phases.length,
4979
+ totalTasks: developmentPlan.phases.reduce((sum, p) => sum + p.tasks.length, 0)
4980
+ },
4981
+ nextSteps: [
4982
+ `1. \u67E5\u770B ${args.newProjectPath}/docs/ \u76EE\u5F55\u4E0B\u7684\u5206\u6790\u6587\u6863`,
4983
+ "2. \u6309\u7167 DEVELOPMENT_PLAN.md \u4E2D\u7684\u6B65\u9AA4\u9010\u6B65\u6267\u884C",
4984
+ "3. \u6839\u636E PROJECT_ANALYSIS.md \u4E86\u89E3\u53C2\u8003\u9879\u76EE\u7684\u67B6\u6784",
4985
+ "4. \u590D\u5236\u5FC5\u8981\u7684\u6587\u4EF6\u540E\uFF0C\u8FD0\u884C\u9879\u76EE\u9A8C\u8BC1"
4986
+ ]
4987
+ }, null, 2)
4988
+ }]
4989
+ };
4990
+ } catch (error) {
4991
+ logger4.error(`\u751F\u6210\u5931\u8D25: ${error}`);
4992
+ return {
4993
+ content: [{
4994
+ type: "text",
4995
+ text: JSON.stringify({
4996
+ error: error instanceof Error ? error.message : String(error)
4997
+ }, null, 2)
4998
+ }]
4999
+ };
5000
+ }
5001
+ }
5002
+ async function generateAnalysisDocs(targetPath, analysis, plan) {
5003
+ const docsPath = path14.join(targetPath, "docs");
5004
+ if (!fs15.existsSync(docsPath)) {
5005
+ fs15.mkdirSync(docsPath, { recursive: true });
5006
+ }
5007
+ const analysisDoc = generateAnalysisMarkdown(analysis);
5008
+ fs15.writeFileSync(path14.join(docsPath, "PROJECT_ANALYSIS.md"), analysisDoc);
5009
+ if (plan) {
5010
+ const planDoc = generatePlanMarkdown(plan);
5011
+ fs15.writeFileSync(path14.join(docsPath, "DEVELOPMENT_PLAN.md"), planDoc);
5012
+ }
5013
+ const skeletonDoc = generateSkeletonMarkdown(analysis);
5014
+ fs15.writeFileSync(path14.join(docsPath, "SKELETON_CHECKLIST.md"), skeletonDoc);
5015
+ }
5016
+ function generateAnalysisMarkdown(analysis) {
5017
+ var _a, _b, _c, _d;
5018
+ let md = `# ${analysis.projectName} \u9879\u76EE\u5206\u6790\u62A5\u544A
5019
+
5020
+ > \u751F\u6210\u65F6\u95F4: ${analysis.analyzedAt}
5021
+
5022
+ ## \u6280\u672F\u6808
5023
+
5024
+ | \u9879\u76EE | \u503C |
5025
+ |------|-----|
5026
+ | \u6846\u67B6 | ${analysis.techStack.framework} |
5027
+ | \u8BED\u8A00 | ${analysis.techStack.language} |
5028
+ | \u6784\u5EFA\u5DE5\u5177 | ${analysis.techStack.buildTool} |
5029
+ | UI \u5E93 | ${analysis.techStack.uiLibrary || "\u65E0"} |
5030
+ | \u72B6\u6001\u7BA1\u7406 | ${analysis.techStack.stateManagement || "\u65E0"} |
5031
+
5032
+ ## \u67B6\u6784\u5C42\u7EA7
5033
+
5034
+ | \u5C42\u7EA7 | \u63CF\u8FF0 | \u53EF\u590D\u7528 | \u4F18\u5148\u7EA7 |
5035
+ |------|------|--------|--------|
5036
+ `;
5037
+ for (const layer of analysis.architectureLayers) {
5038
+ md += `| ${layer.name} | ${layer.description} | ${layer.reusable ? "\u2705" : "\u274C"} | ${layer.priority} |
5039
+ `;
5040
+ }
5041
+ md += `
5042
+ ## \u5DE5\u5177\u7C7B\u5206\u6790
5043
+
5044
+ **\u603B\u8BA1**: ${analysis.utilities.length} \u4E2A\u5DE5\u5177\u7C7B\uFF0C\u5176\u4E2D ${analysis.utilities.filter((u) => u.recommended).length} \u4E2A\u63A8\u8350\u590D\u7528
5045
+
5046
+ ### \u63A8\u8350\u590D\u7528\u7684\u5DE5\u5177\u7C7B
5047
+
5048
+ | \u8DEF\u5F84 | \u7C7B\u578B | \u4F7F\u7528\u6B21\u6570 |
5049
+ |------|------|---------|
5050
+ `;
5051
+ for (const util of analysis.utilities.filter((u) => u.recommended)) {
5052
+ md += `| ${util.path} | ${util.type} | ${util.usageCount} |
5053
+ `;
5054
+ }
5055
+ md += `
5056
+ ## \u6837\u5F0F\u7CFB\u7EDF
5057
+
5058
+ - **\u9884\u5904\u7406\u5668**: ${analysis.styleSystem.preprocessor || "CSS"}
5059
+ - **\u5168\u5C40\u6837\u5F0F**: ${analysis.styleSystem.globalStyles.length} \u4E2A\u6587\u4EF6
5060
+ - **\u4E3B\u9898\u6587\u4EF6**: ${analysis.styleSystem.themeFiles.length} \u4E2A\u6587\u4EF6
5061
+ - **Mixins**: ${analysis.styleSystem.mixins.length} \u4E2A\u6587\u4EF6
5062
+
5063
+ ### \u5168\u5C40\u6837\u5F0F\u6587\u4EF6
5064
+
5065
+ ${analysis.styleSystem.globalStyles.map((f) => `- \`${f}\``).join("\n")}
5066
+
5067
+ ### \u4E3B\u9898/\u53D8\u91CF\u6587\u4EF6
5068
+
5069
+ ${analysis.styleSystem.themeFiles.map((f) => `- \`${f}\``).join("\n")}
5070
+
5071
+ ## \u914D\u7F6E\u7CFB\u7EDF
5072
+
5073
+ - **\u6784\u5EFA\u914D\u7F6E**: ${((_a = analysis.configSystem.buildConfig) == null ? void 0 : _a.configFile) || "\u65E0"}
5074
+ - **\u8DEF\u7531\u914D\u7F6E**: ${((_b = analysis.configSystem.routerConfig) == null ? void 0 : _b.configFile) || "\u65E0"}
5075
+ - **HTTP \u914D\u7F6E**: ${((_c = analysis.configSystem.httpConfig) == null ? void 0 : _c.configFile) || "\u65E0"}
5076
+ - **\u56FD\u9645\u5316\u914D\u7F6E**: ${((_d = analysis.configSystem.i18nConfig) == null ? void 0 : _d.configFile) || "\u65E0"}
5077
+
5078
+ ## \u6838\u5FC3\u9875\u9762
5079
+
5080
+ | \u9875\u9762 | \u8DEF\u5F84 |
5081
+ |------|------|
5082
+ | \u767B\u5F55\u9875 | ${analysis.corePages.loginPage || "\u65E0"} |
5083
+ | \u4E3B\u5E03\u5C40 | ${analysis.corePages.mainLayout || "\u65E0"} |
5084
+ | \u5BFC\u822A\u7EC4\u4EF6 | ${analysis.corePages.navigation || "\u65E0"} |
5085
+ | \u9519\u8BEF\u9875\u9762 | ${analysis.corePages.errorPages.join(", ") || "\u65E0"} |
5086
+
5087
+ ## \u8D28\u91CF\u8BC4\u4F30
5088
+
5089
+ **\u8BC4\u5206**: ${analysis.qualityAssessment.score}/100
5090
+
5091
+ ### \u4F18\u70B9
5092
+
5093
+ ${analysis.qualityAssessment.strengths.map((s) => `- \u2705 ${s}`).join("\n")}
5094
+
5095
+ ### \u5F85\u6539\u8FDB
5096
+
5097
+ ${analysis.qualityAssessment.weaknesses.map((w) => `- \u26A0\uFE0F ${w}`).join("\n")}
5098
+
5099
+ ### \u5EFA\u8BAE
5100
+
5101
+ ${analysis.qualityAssessment.suggestions.map((s) => `- \u{1F4A1} ${s}`).join("\n")}
5102
+ `;
5103
+ return md;
5104
+ }
5105
+ function generatePlanMarkdown(plan) {
5106
+ var _a;
5107
+ let md = `# ${plan.title}
5108
+
5109
+ > \u751F\u6210\u65F6\u95F4: ${plan.generatedAt}
5110
+
5111
+ **\u53C2\u8003\u9879\u76EE**: ${plan.referenceProject}
5112
+ **\u65B0\u9879\u76EE**: ${plan.newProjectName}
5113
+
5114
+ ---
5115
+
5116
+ `;
5117
+ for (const phase of plan.phases) {
5118
+ md += `## \u9636\u6BB5 ${phase.phase}: ${phase.name}
5119
+
5120
+ ${phase.description}
5121
+
5122
+ | \u4EFB\u52A1 | \u4F18\u5148\u7EA7 | \u9884\u4F30\u65F6\u95F4 | \u76F8\u5173\u6587\u4EF6 |
5123
+ |------|--------|---------|----------|
5124
+ `;
5125
+ for (const task of phase.tasks) {
5126
+ const files = ((_a = task.files) == null ? void 0 : _a.filter((f) => f).join(", ")) || "-";
5127
+ md += `| ${task.task} | ${task.priority} | ${task.estimatedTime} | ${files} |
5128
+ `;
5129
+ }
5130
+ md += "\n";
5131
+ }
5132
+ md += `## \u6CE8\u610F\u4E8B\u9879
5133
+
5134
+ ${plan.notes.map((n) => `- ${n}`).join("\n")}
5135
+ `;
5136
+ return md;
5137
+ }
5138
+ function generateSkeletonMarkdown(analysis) {
5139
+ var _a;
5140
+ let md = `# \u9879\u76EE\u9AA8\u67B6\u6E05\u5355
5141
+
5142
+ > \u57FA\u4E8E ${analysis.projectName} \u5206\u6790\u751F\u6210
5143
+
5144
+ ## \u5FC5\u987B\u590D\u5236\u7684\u76EE\u5F55
5145
+
5146
+ `;
5147
+ for (const dir of analysis.skeleton.requiredDirectories) {
5148
+ md += `### ${dir.path}
5149
+
5150
+ - **\u63CF\u8FF0**: ${dir.description}
5151
+ - **\u5173\u952E\u6587\u4EF6**:
5152
+ ${((_a = dir.files) == null ? void 0 : _a.slice(0, 5).map((f) => ` - \`${f}\``).join("\n")) || " - (\u65E0)"}
5153
+
5154
+ `;
5155
+ }
5156
+ md += `## \u6838\u5FC3\u5DE5\u5177\u7C7B
5157
+
5158
+ \u9700\u8981\u590D\u5236\u4EE5\u4E0B\u5DE5\u5177\u7C7B\u6587\u4EF6\uFF1A
5159
+
5160
+ | \u6587\u4EF6 | \u7C7B\u578B | \u8BF4\u660E |
5161
+ |------|------|------|
5162
+ `;
5163
+ for (const util of analysis.skeleton.coreUtils) {
5164
+ md += `| ${util.path} | ${util.type} | \u4F7F\u7528 ${util.usageCount} \u6B21 |
5165
+ `;
5166
+ }
5167
+ md += `
5168
+ ## \u6837\u5F0F\u7CFB\u7EDF
5169
+
5170
+ ### \u5FC5\u987B\u590D\u5236
5171
+
5172
+ ${analysis.skeleton.styleSystem.globalStyles.map((f) => `- [ ] \`${f}\``).join("\n")}
5173
+
5174
+ ### \u4E3B\u9898\u6587\u4EF6
5175
+
5176
+ ${analysis.skeleton.styleSystem.themeFiles.map((f) => `- [ ] \`${f}\``).join("\n")}
5177
+
5178
+ ## \u6838\u5FC3\u9875\u9762
5179
+
5180
+ - [ ] \u767B\u5F55\u9875: \`${analysis.skeleton.corePages.loginPage || "\u65E0"}\`
5181
+ - [ ] \u4E3B\u5E03\u5C40: \`${analysis.skeleton.corePages.mainLayout || "\u65E0"}\`
5182
+ - [ ] \u5BFC\u822A\u7EC4\u4EF6: \`${analysis.skeleton.corePages.navigation || "\u65E0"}\`
5183
+
5184
+ ## \u6E05\u7406\u6E05\u5355
5185
+
5186
+ \u4EE5\u4E0B\u4E1A\u52A1\u6587\u4EF6\u9700\u8981\u5220\u9664\u6216\u6E05\u7A7A\uFF1A
5187
+
5188
+ ${analysis.skeleton.filesToClean.map((f) => `- [ ] \`${f}\``).join("\n")}
5189
+ `;
5190
+ return md;
5191
+ }
5192
+ function generateSkeletonGuide(analysis, args) {
5193
+ var _a;
5194
+ return {
5195
+ directories: analysis.skeleton.requiredDirectories.map((d) => ({
5196
+ from: path14.join(args.referenceProjectPath, "src", d.path),
5197
+ to: path14.join(args.newProjectPath, "src", d.path),
5198
+ description: d.description
5199
+ })),
5200
+ coreUtils: analysis.skeleton.coreUtils.map((u) => ({
5201
+ from: u.path,
5202
+ type: u.type,
5203
+ recommended: u.recommended
5204
+ })),
5205
+ styleFiles: [
5206
+ ...analysis.styleSystem.globalStyles,
5207
+ ...analysis.styleSystem.themeFiles,
5208
+ ...analysis.styleSystem.mixins
5209
+ ],
5210
+ configFiles: [
5211
+ (_a = analysis.configSystem.buildConfig) == null ? void 0 : _a.configFile,
5212
+ ...analysis.configSystem.envFiles
5213
+ ].filter(Boolean),
5214
+ corePages: [
5215
+ analysis.corePages.loginPage,
5216
+ analysis.corePages.mainLayout,
5217
+ analysis.corePages.navigation,
5218
+ ...analysis.corePages.errorPages
5219
+ ].filter(Boolean)
5220
+ };
5221
+ }
5222
+ function groupBy(arr, key) {
5223
+ return arr.reduce((acc, item) => {
5224
+ const k = item[key];
5225
+ acc[k] = (acc[k] || 0) + 1;
5226
+ return acc;
5227
+ }, {});
5228
+ }
5229
+
5230
+ // src/tools/queryTroubleshootingCases.ts
5231
+ init_resourceLoader();
5232
+ import * as fs17 from "fs";
5233
+ import * as path16 from "path";
5234
+
4026
5235
  // src/core/errors.ts
4027
5236
  var ERROR_MESSAGES = {
4028
5237
  [1e3 /* UNKNOWN */]: "\u672A\u77E5\u9519\u8BEF",
@@ -4105,7 +5314,7 @@ var globalConfig = {
4105
5314
  timestamp: false,
4106
5315
  prefix: "[MCP]"
4107
5316
  };
4108
- var Logger = class _Logger {
5317
+ var Logger2 = class _Logger {
4109
5318
  constructor(name, config) {
4110
5319
  this.name = name || "";
4111
5320
  this.config = { ...globalConfig, ...config };
@@ -4191,14 +5400,14 @@ var Logger = class _Logger {
4191
5400
  return new _Logger(childName, this.config);
4192
5401
  }
4193
5402
  };
4194
- var logger = new Logger();
5403
+ var logger = new Logger2();
4195
5404
  function createLogger(name) {
4196
- return new Logger(name);
5405
+ return new Logger2(name);
4197
5406
  }
4198
5407
 
4199
5408
  // src/core/autoConfig.ts
4200
- import * as fs14 from "fs";
4201
- import * as path13 from "path";
5409
+ import * as fs16 from "fs";
5410
+ import * as path15 from "path";
4202
5411
  var checkedWorkspaces = /* @__PURE__ */ new Map();
4203
5412
  var CACHE_DURATION = 5 * 60 * 1e3;
4204
5413
  function ensureWorkspaceConfig(workspacePath) {
@@ -4208,7 +5417,7 @@ function ensureWorkspaceConfig(workspacePath) {
4208
5417
  wasFixed: false,
4209
5418
  workspacePath
4210
5419
  };
4211
- if (!workspacePath || !fs14.existsSync(workspacePath)) {
5420
+ if (!workspacePath || !fs16.existsSync(workspacePath)) {
4212
5421
  return result;
4213
5422
  }
4214
5423
  const cached = checkedWorkspaces.get(workspacePath);
@@ -4216,13 +5425,13 @@ function ensureWorkspaceConfig(workspacePath) {
4216
5425
  if (cached && cached.configured && now - cached.timestamp < CACHE_DURATION) {
4217
5426
  return result;
4218
5427
  }
4219
- const vscodeDir = path13.join(workspacePath, ".vscode");
4220
- const mcpJsonPath = path13.join(vscodeDir, "mcp.json");
4221
- const settingsPath = path13.join(vscodeDir, "settings.json");
5428
+ const vscodeDir = path15.join(workspacePath, ".vscode");
5429
+ const mcpJsonPath = path15.join(vscodeDir, "mcp.json");
5430
+ const settingsPath = path15.join(vscodeDir, "settings.json");
4222
5431
  let hasMtaConfig = false;
4223
- if (fs14.existsSync(mcpJsonPath)) {
5432
+ if (fs16.existsSync(mcpJsonPath)) {
4224
5433
  try {
4225
- const config = JSON.parse(fs14.readFileSync(mcpJsonPath, "utf-8"));
5434
+ const config = JSON.parse(fs16.readFileSync(mcpJsonPath, "utf-8"));
4226
5435
  hasMtaConfig = !!(((_a = config.servers) == null ? void 0 : _a.mta) || ((_b = config.mcpServers) == null ? void 0 : _b.mta));
4227
5436
  } catch {
4228
5437
  }
@@ -4233,13 +5442,13 @@ function ensureWorkspaceConfig(workspacePath) {
4233
5442
  }
4234
5443
  result.needsSetup = true;
4235
5444
  try {
4236
- if (!fs14.existsSync(vscodeDir)) {
4237
- fs14.mkdirSync(vscodeDir, { recursive: true });
5445
+ if (!fs16.existsSync(vscodeDir)) {
5446
+ fs16.mkdirSync(vscodeDir, { recursive: true });
4238
5447
  }
4239
5448
  let mcpConfig = { servers: {} };
4240
- if (fs14.existsSync(mcpJsonPath)) {
5449
+ if (fs16.existsSync(mcpJsonPath)) {
4241
5450
  try {
4242
- mcpConfig = JSON.parse(fs14.readFileSync(mcpJsonPath, "utf-8"));
5451
+ mcpConfig = JSON.parse(fs16.readFileSync(mcpJsonPath, "utf-8"));
4243
5452
  if (!mcpConfig.servers) {
4244
5453
  mcpConfig.servers = {};
4245
5454
  }
@@ -4252,21 +5461,21 @@ function ensureWorkspaceConfig(workspacePath) {
4252
5461
  args: ["-y", "mta-mcp"],
4253
5462
  env: {}
4254
5463
  };
4255
- fs14.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
5464
+ fs16.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
4256
5465
  let settings = {};
4257
- if (fs14.existsSync(settingsPath)) {
5466
+ if (fs16.existsSync(settingsPath)) {
4258
5467
  try {
4259
- settings = JSON.parse(fs14.readFileSync(settingsPath, "utf-8"));
5468
+ settings = JSON.parse(fs16.readFileSync(settingsPath, "utf-8"));
4260
5469
  } catch {
4261
5470
  settings = {};
4262
5471
  }
4263
5472
  }
4264
5473
  if (!settings["github.copilot.chat.mcp.enabled"]) {
4265
5474
  settings["github.copilot.chat.mcp.enabled"] = true;
4266
- fs14.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
5475
+ fs16.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
4267
5476
  }
4268
5477
  result.wasFixed = true;
4269
- result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${path13.basename(workspacePath)} \u914D\u7F6E MTA MCP\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3\u4F7F\u914D\u7F6E\u751F\u6548\u3002`;
5478
+ result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${path15.basename(workspacePath)} \u914D\u7F6E MTA MCP\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3\u4F7F\u914D\u7F6E\u751F\u6548\u3002`;
4270
5479
  checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
4271
5480
  } catch (error) {
4272
5481
  result.message = `\u26A0\uFE0F \u81EA\u52A8\u914D\u7F6E\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`;
@@ -4274,9 +5483,277 @@ function ensureWorkspaceConfig(workspacePath) {
4274
5483
  return result;
4275
5484
  }
4276
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
+
4277
5754
  // src/index.ts
4278
- var SERVER_VERSION = "2.7.1";
4279
- var logger2 = createLogger("Server");
5755
+ var SERVER_VERSION = "2.14.0";
5756
+ var logger3 = createLogger("Server");
4280
5757
  var CopilotPromptsMCPServer = class {
4281
5758
  constructor() {
4282
5759
  this.standardsManager = new StandardsManager();
@@ -4302,24 +5779,24 @@ var CopilotPromptsMCPServer = class {
4302
5779
  */
4303
5780
  setupErrorHandlers() {
4304
5781
  this.server.onerror = (error) => {
4305
- logger2.error("MCP \u670D\u52A1\u5668\u9519\u8BEF", error);
5782
+ logger3.error("MCP \u670D\u52A1\u5668\u9519\u8BEF", error);
4306
5783
  };
4307
5784
  process.on("SIGINT", async () => {
4308
- logger2.info("\u6536\u5230\u5173\u95ED\u4FE1\u53F7\uFF0C\u6B63\u5728\u5173\u95ED\u670D\u52A1\u5668...");
5785
+ logger3.info("\u6536\u5230\u5173\u95ED\u4FE1\u53F7\uFF0C\u6B63\u5728\u5173\u95ED\u670D\u52A1\u5668...");
4309
5786
  await this.server.close();
4310
5787
  process.exit(0);
4311
5788
  });
4312
5789
  process.on("SIGTERM", async () => {
4313
- logger2.info("\u6536\u5230\u7EC8\u6B62\u4FE1\u53F7\uFF0C\u6B63\u5728\u5173\u95ED\u670D\u52A1\u5668...");
5790
+ logger3.info("\u6536\u5230\u7EC8\u6B62\u4FE1\u53F7\uFF0C\u6B63\u5728\u5173\u95ED\u670D\u52A1\u5668...");
4314
5791
  await this.server.close();
4315
5792
  process.exit(0);
4316
5793
  });
4317
5794
  process.on("uncaughtException", (error) => {
4318
- logger2.error("\u672A\u6355\u83B7\u7684\u5F02\u5E38:", error);
5795
+ logger3.error("\u672A\u6355\u83B7\u7684\u5F02\u5E38:", error);
4319
5796
  process.exit(1);
4320
5797
  });
4321
5798
  process.on("unhandledRejection", (reason, promise) => {
4322
- logger2.error("\u672A\u5904\u7406\u7684 Promise \u62D2\u7EDD:", reason);
5799
+ logger3.error("\u672A\u5904\u7406\u7684 Promise \u62D2\u7EDD:", reason);
4323
5800
  process.exit(1);
4324
5801
  });
4325
5802
  }
@@ -4650,6 +6127,191 @@ var CopilotPromptsMCPServer = class {
4650
6127
  },
4651
6128
  required: ["id"]
4652
6129
  }
6130
+ },
6131
+ {
6132
+ name: "analyze_reference_project",
6133
+ description: `\u3010\u9879\u76EE\u514B\u9686\u3011\u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE\uFF0C\u7528\u4E8E\u521B\u5EFA\u98CE\u683C\u4E00\u81F4\u7684\u65B0\u9879\u76EE\u3002
6134
+
6135
+ \u89E6\u53D1\u8BCD\uFF1A
6136
+ - "\u53C2\u8003 xx \u9879\u76EE\u521B\u5EFA\u65B0\u9879\u76EE"
6137
+ - "\u6284 xx \u9879\u76EE"
6138
+ - "\u4EE5 xx \u9879\u76EE\u4E3A\u4F8B\u521B\u5EFA"
6139
+ - "\u521B\u5EFA\u4E00\u4E2A xx \u9879\u76EE\u53EA\u4FDD\u7559\u6700\u57FA\u7840\u7684\u529F\u80FD"
6140
+
6141
+ \u529F\u80FD\uFF1A
6142
+ 1. \u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE\u7684\u6280\u672F\u6808\u548C\u67B6\u6784
6143
+ 2. \u8BC6\u522B\u53EF\u590D\u7528\u7684\u5DE5\u5177\u7C7B\u3001\u6837\u5F0F\u7CFB\u7EDF\u3001\u914D\u7F6E\u6587\u4EF6
6144
+ 3. \u5206\u6790\u6838\u5FC3\u9875\u9762\u7ED3\u6784\uFF08\u767B\u5F55\u3001\u5E03\u5C40\u3001\u5BFC\u822A\u7B49\uFF09
6145
+ 4. \u751F\u6210\u9879\u76EE\u8D28\u91CF\u8BC4\u4F30\u548C MCP \u6A21\u677F\u5EFA\u8BAE
6146
+ 5. \u53EF\u9009\u62E9\u751F\u6210\u5206\u6790\u6587\u6863\u548C\u5F00\u53D1\u8BA1\u5212`,
6147
+ inputSchema: {
6148
+ type: "object",
6149
+ properties: {
6150
+ projectPath: {
6151
+ type: "string",
6152
+ description: "\u53C2\u8003\u9879\u76EE\u7684\u7EDD\u5BF9\u8DEF\u5F84"
6153
+ },
6154
+ generateDocs: {
6155
+ type: "boolean",
6156
+ description: "\u662F\u5426\u751F\u6210\u5206\u6790\u6587\u6863\u5230\u76EE\u6807\u9879\u76EE",
6157
+ default: false
6158
+ },
6159
+ newProjectName: {
6160
+ type: "string",
6161
+ description: "\u65B0\u9879\u76EE\u540D\u79F0\uFF08\u7528\u4E8E\u751F\u6210\u5F00\u53D1\u8BA1\u5212\uFF09"
6162
+ },
6163
+ newProjectPath: {
6164
+ type: "string",
6165
+ description: "\u65B0\u9879\u76EE\u8DEF\u5F84\uFF08\u7528\u4E8E\u751F\u6210\u6587\u6863\uFF09"
6166
+ }
6167
+ },
6168
+ required: ["projectPath"]
6169
+ }
6170
+ },
6171
+ {
6172
+ name: "generate_project_skeleton",
6173
+ description: `\u3010\u9879\u76EE\u514B\u9686\u3011\u57FA\u4E8E\u5206\u6790\u7ED3\u679C\u751F\u6210\u9879\u76EE\u9AA8\u67B6\u3002
6174
+
6175
+ \u529F\u80FD\uFF1A
6176
+ 1. \u5206\u6790\u53C2\u8003\u9879\u76EE\u7684\u67B6\u6784
6177
+ 2. \u5728\u65B0\u9879\u76EE\u76EE\u5F55\u751F\u6210\u5206\u6790\u6587\u6863
6178
+ 3. \u751F\u6210\u5F00\u53D1\u8BA1\u5212\u548C\u9AA8\u67B6\u6E05\u5355
6179
+ 4. \u63D0\u4F9B\u9010\u6B65\u6267\u884C\u7684\u4EFB\u52A1\u6307\u5357
6180
+
6181
+ \u751F\u6210\u7684\u6587\u6863\uFF1A
6182
+ - docs/PROJECT_ANALYSIS.md - \u9879\u76EE\u5206\u6790\u62A5\u544A
6183
+ - docs/DEVELOPMENT_PLAN.md - \u5F00\u53D1\u8BA1\u5212
6184
+ - docs/SKELETON_CHECKLIST.md - \u9AA8\u67B6\u6E05\u5355`,
6185
+ inputSchema: {
6186
+ type: "object",
6187
+ properties: {
6188
+ referenceProjectPath: {
6189
+ type: "string",
6190
+ description: "\u53C2\u8003\u9879\u76EE\u7684\u7EDD\u5BF9\u8DEF\u5F84"
6191
+ },
6192
+ newProjectPath: {
6193
+ type: "string",
6194
+ description: "\u65B0\u9879\u76EE\u7684\u7EDD\u5BF9\u8DEF\u5F84"
6195
+ },
6196
+ newProjectName: {
6197
+ type: "string",
6198
+ description: "\u65B0\u9879\u76EE\u540D\u79F0"
6199
+ },
6200
+ generateDocs: {
6201
+ type: "boolean",
6202
+ description: "\u662F\u5426\u751F\u6210\u5206\u6790\u6587\u6863",
6203
+ default: true
6204
+ },
6205
+ includeLayers: {
6206
+ type: "array",
6207
+ items: { type: "string" },
6208
+ description: "\u8981\u5305\u542B\u7684\u5C42\u7EA7\uFF08\u53EF\u9009\uFF09"
6209
+ },
6210
+ excludePatterns: {
6211
+ type: "array",
6212
+ items: { type: "string" },
6213
+ description: "\u8981\u6392\u9664\u7684\u6587\u4EF6\u6A21\u5F0F"
6214
+ }
6215
+ },
6216
+ required: ["referenceProjectPath", "newProjectPath", "newProjectName"]
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
+ }
4653
6315
  }
4654
6316
  ]
4655
6317
  }));
@@ -4657,15 +6319,15 @@ var CopilotPromptsMCPServer = class {
4657
6319
  var _a, _b;
4658
6320
  try {
4659
6321
  const { name, arguments: args } = request.params;
4660
- logger2.debug(`\u8C03\u7528\u5DE5\u5177: ${name}`);
4661
- logger2.debug(`\u53C2\u6570:`, args);
6322
+ logger3.debug(`\u8C03\u7528\u5DE5\u5177: ${name}`);
6323
+ logger3.debug(`\u53C2\u6570:`, args);
4662
6324
  const workspacePath = (args == null ? void 0 : args.workspacePath) || (args == null ? void 0 : args.projectPath);
4663
6325
  let autoConfigMessage = null;
4664
6326
  if (workspacePath) {
4665
6327
  const configResult = ensureWorkspaceConfig(workspacePath);
4666
6328
  if (configResult.wasFixed) {
4667
6329
  autoConfigMessage = configResult.message || null;
4668
- logger2.info(`\u81EA\u52A8\u914D\u7F6E\u5DF2\u4FEE\u590D: ${workspacePath}`);
6330
+ logger3.info(`\u81EA\u52A8\u914D\u7F6E\u5DF2\u4FEE\u590D: ${workspacePath}`);
4669
6331
  }
4670
6332
  }
4671
6333
  let result;
@@ -4715,6 +6377,53 @@ var CopilotPromptsMCPServer = class {
4715
6377
  case "get_template":
4716
6378
  result = await getTemplate(args);
4717
6379
  break;
6380
+ case "analyze_reference_project":
6381
+ result = await analyzeReferenceProject(args);
6382
+ break;
6383
+ case "generate_project_skeleton":
6384
+ result = await generateProjectSkeleton(args);
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;
4718
6427
  default:
4719
6428
  throw new Error(`\u672A\u77E5\u5DE5\u5177: ${name}`);
4720
6429
  }
@@ -4733,7 +6442,7 @@ var CopilotPromptsMCPServer = class {
4733
6442
  }
4734
6443
  return result;
4735
6444
  } catch (error) {
4736
- logger2.error(`\u5DE5\u5177\u6267\u884C\u5931\u8D25:`, error);
6445
+ logger3.error(`\u5DE5\u5177\u6267\u884C\u5931\u8D25:`, error);
4737
6446
  return errorResponse(error);
4738
6447
  }
4739
6448
  });
@@ -4795,32 +6504,42 @@ var CopilotPromptsMCPServer = class {
4795
6504
  ` \u2022 get_compact_standards - \u83B7\u53D6\u7F16\u7801\u89C4\u8303`,
4796
6505
  ` \u2022 use_preset - \u4F7F\u7528\u9884\u8BBE\u573A\u666F`,
4797
6506
  ` \u2022 match_agents - \u5339\u914D\u63A8\u8350 Agent`,
6507
+ ` \u2022 analyze_reference_project - \u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE`,
6508
+ ` \u2022 generate_project_skeleton - \u751F\u6210\u9879\u76EE\u9AA8\u67B6`,
4798
6509
  ``,
4799
6510
  `\u{1F4A1} \u63D0\u793A: \u5728 Copilot Chat \u4E2D\u4F7F\u7528 @mta \u8C03\u7528\u670D\u52A1`,
4800
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`
4801
6512
  ];
4802
6513
  startupInfo.forEach((line) => console.error(line));
4803
- logger2.info(`MCP Server \u5C31\u7EEA\uFF0C\u7B49\u5F85 Copilot Chat \u8FDE\u63A5...`);
6514
+ logger3.info(`MCP Server \u5C31\u7EEA\uFF0C\u7B49\u5F85 Copilot Chat \u8FDE\u63A5...`);
4804
6515
  }
4805
6516
  };
4806
- var server = new CopilotPromptsMCPServer();
4807
- server.run().catch((error) => {
4808
- 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`);
4809
- console.error(`\u274C MTA MCP Server \u542F\u52A8\u5931\u8D25`);
4810
- 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`);
4811
- console.error(`\u9519\u8BEF\u4FE1\u606F: ${error instanceof Error ? error.message : String(error)}`);
4812
- console.error(``);
4813
- console.error(`\u{1F50D} \u53EF\u80FD\u7684\u539F\u56E0:`);
4814
- console.error(` 1. Node.js \u7248\u672C\u8FC7\u4F4E\uFF08\u9700\u8981 16+\uFF09`);
4815
- console.error(` 2. \u4F9D\u8D56\u5B89\u88C5\u4E0D\u5B8C\u6574`);
4816
- console.error(` 3. \u7AEF\u53E3\u88AB\u5360\u7528`);
4817
- console.error(``);
4818
- console.error(`\u{1F4A1} \u89E3\u51B3\u5EFA\u8BAE:`);
4819
- console.error(` \u2022 \u8FD0\u884C node --version \u68C0\u67E5\u7248\u672C`);
4820
- console.error(` \u2022 \u8FD0\u884C npm install \u91CD\u65B0\u5B89\u88C5\u4F9D\u8D56`);
4821
- console.error(` \u2022 \u68C0\u67E5\u662F\u5426\u6709\u5176\u4ED6 MCP \u670D\u52A1\u5668\u5B9E\u4F8B\u8FD0\u884C`);
4822
- 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`);
4823
- logger2.error("\u670D\u52A1\u5668\u542F\u52A8\u5931\u8D25:", error);
4824
- process.exit(1);
4825
- });
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
+ };
4826
6545
  //# sourceMappingURL=index.js.map