mta-mcp 2.9.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1112,51 +1112,77 @@ async function matchAgents(args) {
1112
1112
  }
1113
1113
  }
1114
1114
 
1115
- // src/tools/listAgents.ts
1116
- init_resourceLoader();
1117
- async function listAvailableAgents() {
1118
- const logger3 = new ConsoleLogger();
1115
+ // src/tools/listAvailableAgents.ts
1116
+ import * as fs5 from "fs";
1117
+ import * as path5 from "path";
1118
+ import { fileURLToPath as fileURLToPath2 } from "url";
1119
+ var __filename2 = fileURLToPath2(import.meta.url);
1120
+ var __dirname3 = path5.dirname(__filename2);
1121
+ function parseAgentFile(filePath) {
1119
1122
  try {
1120
- const resourceLoader = getResourceLoader(logger3);
1121
- logger3.log("\u6B63\u5728\u4ECE\u5305\u5185\u52A0\u8F7D Agents \u5217\u8868...");
1122
- const agents = resourceLoader.loadAllAgents();
1123
- const agentList = agents.map((agent) => ({
1124
- id: agent.id,
1125
- name: `${agent.id}.agent.md`,
1126
- title: agent.title,
1127
- description: agent.description || "\u6682\u65E0\u63CF\u8FF0",
1128
- path: agent.path,
1129
- tags: agent.tags
1130
- }));
1123
+ const content = fs5.readFileSync(filePath, "utf-8");
1124
+ const lines = content.split("\n");
1125
+ let title = "";
1126
+ let description = "";
1127
+ const tags = [];
1128
+ const titleLine = lines.find((l) => l.trim().startsWith("# "));
1129
+ if (titleLine) {
1130
+ title = titleLine.replace(/^#\s*/, "").trim();
1131
+ }
1132
+ const descLine = lines.find((l) => l.trim().startsWith("> "));
1133
+ if (descLine) {
1134
+ description = descLine.replace(/^>\s*/, "").trim();
1135
+ }
1136
+ const fileName = path5.basename(filePath);
1137
+ const id = fileName.replace(".agent.md", "");
1138
+ const tagsLine = lines.find(
1139
+ (l) => l.includes("**\u6807\u7B7E**") || l.includes("**\u5173\u952E\u8BCD**") || l.includes("**Tags**")
1140
+ );
1141
+ if (tagsLine) {
1142
+ const tagsMatch = tagsLine.match(/[::]\s*(.+)/);
1143
+ if (tagsMatch) {
1144
+ tags.push(...tagsMatch[1].split(/[,,、]/).map((t) => t.trim()));
1145
+ }
1146
+ }
1131
1147
  return {
1132
- content: [{
1133
- type: "text",
1134
- text: JSON.stringify({
1135
- success: true,
1136
- total: agentList.length,
1137
- agents: agentList,
1138
- source: "npm-package",
1139
- version: resourceLoader.getPackageVersion()
1140
- }, null, 2)
1141
- }]
1148
+ id,
1149
+ title: title || id,
1150
+ description: description || "\u6682\u65E0\u63CF\u8FF0",
1151
+ tags
1142
1152
  };
1143
1153
  } catch (error) {
1144
- logger3.error(`\u83B7\u53D6 Agents \u5217\u8868\u5931\u8D25: ${error}`);
1154
+ console.error(`\u89E3\u6790 Agent \u6587\u4EF6\u5931\u8D25: ${filePath}`, error);
1155
+ return null;
1156
+ }
1157
+ }
1158
+ function listAvailableAgents() {
1159
+ try {
1160
+ const projectRoot = path5.resolve(__dirname3, "../..");
1161
+ const agentsDir = path5.join(projectRoot, "agents");
1162
+ if (!fs5.existsSync(agentsDir)) {
1163
+ throw new Error(`Agents \u76EE\u5F55\u4E0D\u5B58\u5728: ${agentsDir}`);
1164
+ }
1165
+ const agentFiles = fs5.readdirSync(agentsDir).filter((f) => f.endsWith(".agent.md") && !f.endsWith(".bak")).map((f) => path5.join(agentsDir, f));
1166
+ const agents = [];
1167
+ for (const filePath of agentFiles) {
1168
+ const metadata = parseAgentFile(filePath);
1169
+ if (metadata) {
1170
+ agents.push(metadata);
1171
+ }
1172
+ }
1145
1173
  return {
1146
- content: [{
1147
- type: "text",
1148
- text: JSON.stringify({
1149
- error: error instanceof Error ? error.message : String(error)
1150
- }, null, 2)
1151
- }]
1174
+ agents: agents.sort((a, b) => a.title.localeCompare(b.title))
1152
1175
  };
1176
+ } catch (error) {
1177
+ console.error("\u5217\u51FA Agents \u5931\u8D25:", error);
1178
+ return { agents: [] };
1153
1179
  }
1154
1180
  }
1155
1181
 
1156
1182
  // src/tools/generateConfig.ts
1157
- import * as fs5 from "fs";
1158
- import * as path5 from "path";
1159
- import { fileURLToPath as fileURLToPath2 } from "url";
1183
+ import * as fs6 from "fs";
1184
+ import * as path6 from "path";
1185
+ import { fileURLToPath as fileURLToPath3 } from "url";
1160
1186
 
1161
1187
  // src/core/githubClient.ts
1162
1188
  import axios from "axios";
@@ -1478,12 +1504,12 @@ var CodeValidator = class {
1478
1504
 
1479
1505
  // src/tools/generateConfig.ts
1480
1506
  init_resourceLoader();
1481
- var __filename2 = fileURLToPath2(import.meta.url);
1482
- var __dirname3 = path5.dirname(__filename2);
1507
+ var __filename3 = fileURLToPath3(import.meta.url);
1508
+ var __dirname4 = path6.dirname(__filename3);
1483
1509
  async function generateConfig(args) {
1484
1510
  const logger3 = new ConsoleLogger();
1485
1511
  try {
1486
- if (!fs5.existsSync(args.projectPath)) {
1512
+ if (!fs6.existsSync(args.projectPath)) {
1487
1513
  return {
1488
1514
  content: [{
1489
1515
  type: "text",
@@ -1500,7 +1526,7 @@ async function generateConfig(args) {
1500
1526
  logger3.log("\u6B63\u5728\u5206\u6790\u9879\u76EE\u7279\u5F81...");
1501
1527
  const workspaceFolder = {
1502
1528
  uri: { fsPath: args.projectPath },
1503
- name: path5.basename(args.projectPath),
1529
+ name: path6.basename(args.projectPath),
1504
1530
  index: 0
1505
1531
  };
1506
1532
  const features = await matcher.analyzeProject(workspaceFolder);
@@ -1540,19 +1566,19 @@ async function generateConfig(args) {
1540
1566
  };
1541
1567
  }
1542
1568
  logger3.log("\u6B63\u5728\u751F\u6210\u914D\u7F6E\u6587\u4EF6...");
1543
- const githubDir = path5.join(args.projectPath, ".github");
1544
- const configPath = path5.join(githubDir, "copilot-instructions.md");
1569
+ const githubDir = path6.join(args.projectPath, ".github");
1570
+ const configPath = path6.join(githubDir, "copilot-instructions.md");
1545
1571
  let existingCustomContent = "";
1546
1572
  let existingConfig = "";
1547
- if (fs5.existsSync(configPath)) {
1548
- existingConfig = fs5.readFileSync(configPath, "utf-8");
1573
+ if (fs6.existsSync(configPath)) {
1574
+ existingConfig = fs6.readFileSync(configPath, "utf-8");
1549
1575
  const customMatch = existingConfig.match(/<!-- CUSTOM_START -->([\s\S]*?)<!-- CUSTOM_END -->/g);
1550
1576
  if (customMatch) {
1551
1577
  existingCustomContent = customMatch.join("\n\n");
1552
1578
  }
1553
1579
  }
1554
- if (!fs5.existsSync(githubDir)) {
1555
- fs5.mkdirSync(githubDir, { recursive: true });
1580
+ if (!fs6.existsSync(githubDir)) {
1581
+ fs6.mkdirSync(githubDir, { recursive: true });
1556
1582
  }
1557
1583
  const updateMode = args.updateMode || "merge";
1558
1584
  let content = "";
@@ -1577,7 +1603,7 @@ async function generateConfig(args) {
1577
1603
 
1578
1604
  `;
1579
1605
  }
1580
- const projectName = path5.basename(args.projectPath);
1606
+ const projectName = path6.basename(args.projectPath);
1581
1607
  const projectPath = args.projectPath;
1582
1608
  content += `<!-- \u{1F3AF} \u4F5C\u7528\u57DF\uFF1A\u6B64\u914D\u7F6E\u4EC5\u9002\u7528\u4E8E\u5F53\u524D\u9879\u76EE -->
1583
1609
  `;
@@ -1670,9 +1696,9 @@ async function generateConfig(args) {
1670
1696
  `;
1671
1697
  if (args.configId) {
1672
1698
  try {
1673
- const configFilePath = path5.join(__dirname3, "../../../configs", `element-plus-${args.configId}.json`);
1674
- if (fs5.existsSync(configFilePath)) {
1675
- const configData = JSON.parse(fs5.readFileSync(configFilePath, "utf-8"));
1699
+ const configFilePath = path6.join(__dirname4, "../../../configs", `element-plus-${args.configId}.json`);
1700
+ if (fs6.existsSync(configFilePath)) {
1701
+ const configData = JSON.parse(fs6.readFileSync(configFilePath, "utf-8"));
1676
1702
  content += `## \u{1F4E6} \u914D\u7F6E\u65B9\u6848
1677
1703
 
1678
1704
  `;
@@ -1836,13 +1862,13 @@ async function generateConfig(args) {
1836
1862
  } else {
1837
1863
  logger3.log("\u2705 \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u901A\u8FC7");
1838
1864
  }
1839
- fs5.writeFileSync(configPath, content, "utf-8");
1840
- const gitignorePath = path5.join(args.projectPath, ".gitignore");
1841
- if (fs5.existsSync(gitignorePath)) {
1842
- let gitignoreContent = fs5.readFileSync(gitignorePath, "utf-8");
1865
+ fs6.writeFileSync(configPath, content, "utf-8");
1866
+ const gitignorePath = path6.join(args.projectPath, ".gitignore");
1867
+ if (fs6.existsSync(gitignorePath)) {
1868
+ let gitignoreContent = fs6.readFileSync(gitignorePath, "utf-8");
1843
1869
  if (!gitignoreContent.includes(".github/copilot-instructions.md")) {
1844
1870
  gitignoreContent += "\n# Copilot Prompts (auto-generated)\n.github/copilot-instructions.md\n";
1845
- fs5.writeFileSync(gitignorePath, gitignoreContent, "utf-8");
1871
+ fs6.writeFileSync(gitignorePath, gitignoreContent, "utf-8");
1846
1872
  }
1847
1873
  }
1848
1874
  logger3.log(`\u2705 \u914D\u7F6E\u6587\u4EF6\u5DF2\u751F\u6210: ${configPath}`);
@@ -1875,14 +1901,14 @@ async function generateConfig(args) {
1875
1901
  }
1876
1902
 
1877
1903
  // src/tools/autoSetup.ts
1878
- import * as fs6 from "fs";
1879
- import * as path6 from "path";
1904
+ import * as fs7 from "fs";
1905
+ import * as path7 from "path";
1880
1906
  async function autoSetup(args) {
1881
1907
  var _a;
1882
1908
  const logger3 = new ConsoleLogger();
1883
1909
  try {
1884
1910
  const workspacePath = args.workspacePath || process.cwd();
1885
- if (!fs6.existsSync(workspacePath)) {
1911
+ if (!fs7.existsSync(workspacePath)) {
1886
1912
  return {
1887
1913
  content: [{
1888
1914
  type: "text",
@@ -1899,8 +1925,8 @@ async function autoSetup(args) {
1899
1925
  };
1900
1926
  logger3.log("\u{1F680} \u5F00\u59CB\u4E3A\u9879\u76EE\u751F\u6210 copilot-instructions.md...");
1901
1927
  const generateInstructions = args.generateInstructions !== false;
1902
- const instructionsPath = path6.join(workspacePath, ".github", "copilot-instructions.md");
1903
- const hasExistingInstructions = fs6.existsSync(instructionsPath);
1928
+ const instructionsPath = path7.join(workspacePath, ".github", "copilot-instructions.md");
1929
+ const hasExistingInstructions = fs7.existsSync(instructionsPath);
1904
1930
  if (generateInstructions) {
1905
1931
  if (hasExistingInstructions) {
1906
1932
  results.steps.push({
@@ -1972,12 +1998,85 @@ async function autoSetup(args) {
1972
1998
  }
1973
1999
  }
1974
2000
 
2001
+ // src/tools/initProject.ts
2002
+ import * as fs8 from "fs";
2003
+ async function initProject(args) {
2004
+ var _a;
2005
+ const logger3 = new ConsoleLogger();
2006
+ try {
2007
+ let projectPath = args.projectPath;
2008
+ if (!projectPath) {
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}`);
2011
+ }
2012
+ if (!fs8.existsSync(projectPath)) {
2013
+ return {
2014
+ content: [{
2015
+ type: "text",
2016
+ text: JSON.stringify({
2017
+ error: `\u9879\u76EE\u8DEF\u5F84\u4E0D\u5B58\u5728: ${projectPath}`,
2018
+ tip: "\u8BF7\u5728 Chat \u4E2D\u6DFB\u52A0\u9879\u76EE\u6587\u4EF6\u5939\uFF0C\u6216\u660E\u786E\u6307\u5B9A\u9879\u76EE\u8DEF\u5F84"
2019
+ }, null, 2)
2020
+ }]
2021
+ };
2022
+ }
2023
+ logger3.log(`\u{1F680} \u5F00\u59CB\u521D\u59CB\u5316\u9879\u76EE: ${projectPath}`);
2024
+ const result = await generateConfig({
2025
+ projectPath,
2026
+ autoMatch: true,
2027
+ updateMode: "merge"
2028
+ });
2029
+ const resultData = JSON.parse(result.content[0].text);
2030
+ if (resultData.success) {
2031
+ const agents = ((_a = resultData.agents) == null ? void 0 : _a.map((a) => a.id || a.title)) || [];
2032
+ return {
2033
+ content: [{
2034
+ type: "text",
2035
+ text: JSON.stringify({
2036
+ success: true,
2037
+ message: "\u{1F389} \u9879\u76EE\u521D\u59CB\u5316\u6210\u529F\uFF01",
2038
+ projectPath,
2039
+ configPath: resultData.configPath,
2040
+ agents,
2041
+ summary: `\u5DF2\u5E94\u7528 ${agents.length} \u4E2A Agents: ${agents.join(", ")}`,
2042
+ nextSteps: [
2043
+ "1. \u914D\u7F6E\u6587\u4EF6\u5DF2\u751F\u6210\uFF1A.github/copilot-instructions.md",
2044
+ "2. \u73B0\u5728\u53EF\u4EE5\u5F00\u59CB\u7F16\u7801\uFF0CCopilot \u4F1A\u81EA\u52A8\u5E94\u7528\u9879\u76EE\u89C4\u8303",
2045
+ '3. \u4F7F\u7528 @mta \u83B7\u53D6\u5177\u4F53\u89C4\u8303\uFF1A\u5982 "@mta Vue 3 \u7EC4\u4EF6\u89C4\u8303"'
2046
+ ]
2047
+ }, null, 2)
2048
+ }]
2049
+ };
2050
+ } else {
2051
+ return {
2052
+ content: [{
2053
+ type: "text",
2054
+ text: JSON.stringify({
2055
+ error: resultData.error || "\u521D\u59CB\u5316\u5931\u8D25",
2056
+ projectPath
2057
+ }, null, 2)
2058
+ }]
2059
+ };
2060
+ }
2061
+ } catch (error) {
2062
+ logger3.error(`\u521D\u59CB\u5316\u5931\u8D25: ${error}`);
2063
+ return {
2064
+ content: [{
2065
+ type: "text",
2066
+ text: JSON.stringify({
2067
+ error: error instanceof Error ? error.message : String(error)
2068
+ }, null, 2)
2069
+ }]
2070
+ };
2071
+ }
2072
+ }
2073
+
1975
2074
  // src/core/standardsManager.ts
1976
- import * as fs7 from "fs";
1977
- import * as path7 from "path";
1978
- import { fileURLToPath as fileURLToPath3 } from "url";
1979
- var __filename3 = fileURLToPath3(import.meta.url);
1980
- var __dirname4 = path7.dirname(__filename3);
2075
+ import * as fs9 from "fs";
2076
+ import * as path8 from "path";
2077
+ import { fileURLToPath as fileURLToPath4 } from "url";
2078
+ var __filename4 = fileURLToPath4(import.meta.url);
2079
+ var __dirname5 = path8.dirname(__filename4);
1981
2080
  var StandardsManager = class {
1982
2081
  constructor() {
1983
2082
  // v1.2.0: 底层必须加载的核心规范
@@ -2010,9 +2109,9 @@ var StandardsManager = class {
2010
2109
  averageResponseTime: 0,
2011
2110
  totalTokensSaved: 0
2012
2111
  };
2013
- const devPath = path7.resolve(__dirname4, "../../../standards");
2014
- const npmPath = path7.resolve(__dirname4, "../../standards");
2015
- this.standardsPath = fs7.existsSync(npmPath) ? npmPath : devPath;
2112
+ const devPath = path8.resolve(__dirname5, "../../../standards");
2113
+ const npmPath = path8.resolve(__dirname5, "../../standards");
2114
+ this.standardsPath = fs9.existsSync(npmPath) ? npmPath : devPath;
2016
2115
  }
2017
2116
  /**
2018
2117
  * 获取所有可用的规范资源
@@ -2026,11 +2125,11 @@ var StandardsManager = class {
2026
2125
  { dir: "patterns", name: "\u8BBE\u8BA1\u6A21\u5F0F" }
2027
2126
  ];
2028
2127
  categories.forEach(({ dir, name: categoryName }) => {
2029
- const categoryPath = path7.join(this.standardsPath, dir);
2030
- if (!fs7.existsSync(categoryPath)) {
2128
+ const categoryPath = path8.join(this.standardsPath, dir);
2129
+ if (!fs9.existsSync(categoryPath)) {
2031
2130
  return;
2032
2131
  }
2033
- const files = fs7.readdirSync(categoryPath).filter((file) => file.endsWith(".md"));
2132
+ const files = fs9.readdirSync(categoryPath).filter((file) => file.endsWith(".md"));
2034
2133
  files.forEach((file) => {
2035
2134
  const standardId = file.replace(".md", "");
2036
2135
  standards.push({
@@ -2060,11 +2159,11 @@ var StandardsManager = class {
2060
2159
  throw new Error(`Invalid standards URI: ${uri}`);
2061
2160
  }
2062
2161
  const [, category, standardId] = match;
2063
- const filePath = path7.join(this.standardsPath, category, `${standardId}.md`);
2064
- if (!fs7.existsSync(filePath)) {
2162
+ const filePath = path8.join(this.standardsPath, category, `${standardId}.md`);
2163
+ if (!fs9.existsSync(filePath)) {
2065
2164
  throw new Error(`Standard not found: ${uri}`);
2066
2165
  }
2067
- const content = fs7.readFileSync(filePath, "utf-8");
2166
+ const content = fs9.readFileSync(filePath, "utf-8");
2068
2167
  this.updateCache(uri, content);
2069
2168
  this.stats.individualStandards.set(
2070
2169
  uri,
@@ -2607,23 +2706,23 @@ async function listPresets() {
2607
2706
  }
2608
2707
 
2609
2708
  // src/tools/healthCheck.ts
2610
- import * as fs8 from "fs";
2611
- import * as path8 from "path";
2612
- import { fileURLToPath as fileURLToPath4 } from "url";
2613
- var __filename4 = fileURLToPath4(import.meta.url);
2614
- var __dirname5 = path8.dirname(__filename4);
2709
+ import * as fs10 from "fs";
2710
+ import * as path9 from "path";
2711
+ import { fileURLToPath as fileURLToPath5 } from "url";
2712
+ var __filename5 = fileURLToPath5(import.meta.url);
2713
+ var __dirname6 = path9.dirname(__filename5);
2615
2714
  function getServerRoot() {
2616
2715
  const possibleRoots = [
2617
- path8.resolve(__dirname5, "../.."),
2716
+ path9.resolve(__dirname6, "../.."),
2618
2717
  // 从 dist/tools/ 向上两级
2619
- path8.resolve(__dirname5, "../../.."),
2718
+ path9.resolve(__dirname6, "../../.."),
2620
2719
  // npm 包场景
2621
- path8.resolve(process.cwd())
2720
+ path9.resolve(process.cwd())
2622
2721
  // 当前工作目录
2623
2722
  ];
2624
2723
  for (const root of possibleRoots) {
2625
- const standardsPath = path8.join(root, "standards");
2626
- if (fs8.existsSync(standardsPath)) {
2724
+ const standardsPath = path9.join(root, "standards");
2725
+ if (fs10.existsSync(standardsPath)) {
2627
2726
  return root;
2628
2727
  }
2629
2728
  }
@@ -2653,14 +2752,14 @@ async function healthCheck(args) {
2653
2752
  }
2654
2753
  logger3.log("\u{1F50D} \u68C0\u67E5\u914D\u7F6E\u6587\u4EF6...");
2655
2754
  const workspacePath = args.workspacePath || process.cwd();
2656
- const vscodeDir = path8.join(workspacePath, ".vscode");
2657
- if (fs8.existsSync(vscodeDir)) {
2755
+ const vscodeDir = path9.join(workspacePath, ".vscode");
2756
+ if (fs10.existsSync(vscodeDir)) {
2658
2757
  checks.workspace.status = "healthy";
2659
2758
  checks.workspace.details.push(`\u2705 \u5DE5\u4F5C\u533A\u8DEF\u5F84: ${workspacePath}`);
2660
- const mcpJsonPath = path8.join(vscodeDir, "mcp.json");
2661
- if (fs8.existsSync(mcpJsonPath)) {
2759
+ const mcpJsonPath = path9.join(vscodeDir, "mcp.json");
2760
+ if (fs10.existsSync(mcpJsonPath)) {
2662
2761
  try {
2663
- const config = JSON.parse(fs8.readFileSync(mcpJsonPath, "utf-8"));
2762
+ const config = JSON.parse(fs10.readFileSync(mcpJsonPath, "utf-8"));
2664
2763
  const hasNewFormat = (_a = config.servers) == null ? void 0 : _a["copilot-prompts"];
2665
2764
  const hasOldFormat = (_b = config.mcpServers) == null ? void 0 : _b["copilot-prompts"];
2666
2765
  if (hasNewFormat) {
@@ -2703,10 +2802,10 @@ async function healthCheck(args) {
2703
2802
  checks.configuration.details.push("\u26A0\uFE0F mcp.json \u4E0D\u5B58\u5728");
2704
2803
  checks.configuration.details.push("\u{1F4A1} \u5EFA\u8BAE: \u8FD0\u884C auto_setup \u5DE5\u5177\u81EA\u52A8\u914D\u7F6E");
2705
2804
  }
2706
- const settingsPath = path8.join(vscodeDir, "settings.json");
2707
- if (fs8.existsSync(settingsPath)) {
2805
+ const settingsPath = path9.join(vscodeDir, "settings.json");
2806
+ if (fs10.existsSync(settingsPath)) {
2708
2807
  try {
2709
- const settings = JSON.parse(fs8.readFileSync(settingsPath, "utf-8"));
2808
+ const settings = JSON.parse(fs10.readFileSync(settingsPath, "utf-8"));
2710
2809
  if (settings["github.copilot.chat.mcp.enabled"] === true) {
2711
2810
  checks.configuration.details.push("\u2705 VS Code MCP \u5DF2\u542F\u7528");
2712
2811
  } else {
@@ -2723,10 +2822,10 @@ async function healthCheck(args) {
2723
2822
  }
2724
2823
  logger3.log("\u{1F50D} \u68C0\u67E5\u4F9D\u8D56...");
2725
2824
  const serverRoot = getServerRoot();
2726
- const packageJsonPath = path8.join(serverRoot, "package.json");
2727
- if (fs8.existsSync(packageJsonPath)) {
2825
+ const packageJsonPath = path9.join(serverRoot, "package.json");
2826
+ if (fs10.existsSync(packageJsonPath)) {
2728
2827
  try {
2729
- const pkg = JSON.parse(fs8.readFileSync(packageJsonPath, "utf-8"));
2828
+ const pkg = JSON.parse(fs10.readFileSync(packageJsonPath, "utf-8"));
2730
2829
  checks.dependencies.status = "healthy";
2731
2830
  checks.dependencies.details.push(`\u2705 \u670D\u52A1\u5668\u7248\u672C: ${pkg.version}`);
2732
2831
  if (verbose && pkg.dependencies) {
@@ -2750,14 +2849,14 @@ async function healthCheck(args) {
2750
2849
  }
2751
2850
  }
2752
2851
  logger3.log("\u{1F50D} \u68C0\u67E5\u89C4\u8303\u6587\u4EF6...");
2753
- const standardsDir = path8.join(serverRoot, "standards");
2754
- if (fs8.existsSync(standardsDir)) {
2852
+ const standardsDir = path9.join(serverRoot, "standards");
2853
+ if (fs10.existsSync(standardsDir)) {
2755
2854
  const categories = ["core", "frameworks", "libraries", "patterns"];
2756
2855
  const foundStandards = [];
2757
2856
  for (const category of categories) {
2758
- const categoryPath = path8.join(standardsDir, category);
2759
- if (fs8.existsSync(categoryPath)) {
2760
- const files = fs8.readdirSync(categoryPath).filter((f) => f.endsWith(".md"));
2857
+ const categoryPath = path9.join(standardsDir, category);
2858
+ if (fs10.existsSync(categoryPath)) {
2859
+ const files = fs10.readdirSync(categoryPath).filter((f) => f.endsWith(".md"));
2761
2860
  foundStandards.push(...files.map((f) => `${category}/${f}`));
2762
2861
  }
2763
2862
  }
@@ -2834,8 +2933,8 @@ function generateRecommendations(checks) {
2834
2933
  }
2835
2934
 
2836
2935
  // src/tools/getCompactStandards.ts
2837
- import * as fs9 from "fs";
2838
- import * as path9 from "path";
2936
+ import * as fs11 from "fs";
2937
+ import * as path10 from "path";
2839
2938
  init_smartAgentMatcher();
2840
2939
  async function getCompactStandards(args) {
2841
2940
  const logger3 = new ConsoleLogger();
@@ -2843,7 +2942,7 @@ async function getCompactStandards(args) {
2843
2942
  const mode = args.mode || "key-rules";
2844
2943
  try {
2845
2944
  let context = detectContext(args, logger3);
2846
- if (args.projectPath && fs9.existsSync(args.projectPath)) {
2945
+ if (args.projectPath && fs11.existsSync(args.projectPath)) {
2847
2946
  const projectContext = await analyzeProject2(args.projectPath, logger3);
2848
2947
  context = mergeContexts(context, projectContext);
2849
2948
  }
@@ -2896,10 +2995,10 @@ async function analyzeProject2(projectPath, logger3) {
2896
2995
  imports: [],
2897
2996
  scenario: ""
2898
2997
  };
2899
- const instructionsPath = path9.join(projectPath, ".github", "copilot-instructions.md");
2900
- if (fs9.existsSync(instructionsPath)) {
2998
+ const instructionsPath = path10.join(projectPath, ".github", "copilot-instructions.md");
2999
+ if (fs11.existsSync(instructionsPath)) {
2901
3000
  try {
2902
- const content = fs9.readFileSync(instructionsPath, "utf-8");
3001
+ const content = fs11.readFileSync(instructionsPath, "utf-8");
2903
3002
  const agents = extractUserAgents(content);
2904
3003
  if (agents.length > 0) {
2905
3004
  result.userConfiguredAgents = agents;
@@ -2912,7 +3011,7 @@ async function analyzeProject2(projectPath, logger3) {
2912
3011
  const matcher = new SmartAgentMatcher(logger3);
2913
3012
  const workspaceFolder = {
2914
3013
  uri: { fsPath: projectPath },
2915
- name: path9.basename(projectPath),
3014
+ name: path10.basename(projectPath),
2916
3015
  index: 0
2917
3016
  };
2918
3017
  try {
@@ -2956,7 +3055,7 @@ function detectContext(args, logger3) {
2956
3055
  let fileType = "unknown";
2957
3056
  let imports = [];
2958
3057
  let scenario = "";
2959
- if (args.currentFile && fs9.existsSync(args.currentFile)) {
3058
+ if (args.currentFile && fs11.existsSync(args.currentFile)) {
2960
3059
  const ext = ((_a = args.currentFile.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
2961
3060
  const extMap = {
2962
3061
  "vue": "vue",
@@ -2968,7 +3067,7 @@ function detectContext(args, logger3) {
2968
3067
  };
2969
3068
  fileType = extMap[ext] || "unknown";
2970
3069
  try {
2971
- const content = fs9.readFileSync(args.currentFile, "utf-8");
3070
+ const content = fs11.readFileSync(args.currentFile, "utf-8");
2972
3071
  imports = extractImports(content);
2973
3072
  scenario = inferScenario(content, fileType);
2974
3073
  } catch {
@@ -3285,8 +3384,8 @@ function inferScenario(content, fileType) {
3285
3384
  }
3286
3385
 
3287
3386
  // src/tools/getStandardById.ts
3288
- import * as fs10 from "fs";
3289
- import * as path10 from "path";
3387
+ import * as fs12 from "fs";
3388
+ import * as path11 from "path";
3290
3389
  var STANDARD_DIRS = [
3291
3390
  "standards/core",
3292
3391
  "standards/frameworks",
@@ -3324,7 +3423,7 @@ async function getStandardById(args) {
3324
3423
  continue;
3325
3424
  }
3326
3425
  try {
3327
- const fullContent = fs10.readFileSync(filePath, "utf-8");
3426
+ const fullContent = fs12.readFileSync(filePath, "utf-8");
3328
3427
  const content = formatContent(fullContent, mode);
3329
3428
  results.push({
3330
3429
  id,
@@ -3381,33 +3480,33 @@ function ensureCache() {
3381
3480
  standardsCache = /* @__PURE__ */ new Map();
3382
3481
  const baseDir = findBaseDir();
3383
3482
  for (const dir of STANDARD_DIRS) {
3384
- const fullDir = path10.join(baseDir, dir);
3385
- if (!fs10.existsSync(fullDir)) continue;
3483
+ const fullDir = path11.join(baseDir, dir);
3484
+ if (!fs12.existsSync(fullDir)) continue;
3386
3485
  scanDirectory(fullDir, standardsCache);
3387
3486
  }
3388
3487
  }
3389
3488
  function findBaseDir() {
3390
3489
  const possiblePaths = [
3391
3490
  process.cwd(),
3392
- path10.join(process.cwd(), ".."),
3393
- path10.join(__dirname, "..", "..", "..")
3491
+ path11.join(process.cwd(), ".."),
3492
+ path11.join(__dirname, "..", "..", "..")
3394
3493
  ];
3395
3494
  for (const p of possiblePaths) {
3396
- if (fs10.existsSync(path10.join(p, "standards"))) {
3495
+ if (fs12.existsSync(path11.join(p, "standards"))) {
3397
3496
  return p;
3398
3497
  }
3399
3498
  }
3400
3499
  return process.cwd();
3401
3500
  }
3402
3501
  function scanDirectory(dir, cache) {
3403
- const items = fs10.readdirSync(dir);
3502
+ const items = fs12.readdirSync(dir);
3404
3503
  for (const item of items) {
3405
- const fullPath = path10.join(dir, item);
3406
- const stat = fs10.statSync(fullPath);
3504
+ const fullPath = path11.join(dir, item);
3505
+ const stat = fs12.statSync(fullPath);
3407
3506
  if (stat.isDirectory()) {
3408
3507
  scanDirectory(fullPath, cache);
3409
3508
  } else if (item.endsWith(".md")) {
3410
- const id = path10.basename(item, ".md");
3509
+ const id = path11.basename(item, ".md");
3411
3510
  cache.set(id, fullPath);
3412
3511
  }
3413
3512
  }
@@ -3650,10 +3749,10 @@ async function listScenarios() {
3650
3749
  }
3651
3750
 
3652
3751
  // src/core/templates/discovery.ts
3653
- import * as fs11 from "fs";
3654
- import * as path11 from "path";
3655
- var TEMPLATES_DIR = path11.resolve(
3656
- path11.dirname(new URL(import.meta.url).pathname),
3752
+ import * as fs13 from "fs";
3753
+ import * as path12 from "path";
3754
+ var TEMPLATES_DIR = path12.resolve(
3755
+ path12.dirname(new URL(import.meta.url).pathname),
3657
3756
  "../../../../templates"
3658
3757
  );
3659
3758
  var templatesCache = null;
@@ -3663,15 +3762,15 @@ function ensureCache2() {
3663
3762
  scanTemplates(TEMPLATES_DIR, "");
3664
3763
  }
3665
3764
  function scanTemplates(dir, prefix) {
3666
- if (!fs11.existsSync(dir)) return;
3667
- const entries = fs11.readdirSync(dir, { withFileTypes: true });
3765
+ if (!fs13.existsSync(dir)) return;
3766
+ const entries = fs13.readdirSync(dir, { withFileTypes: true });
3668
3767
  for (const entry of entries) {
3669
3768
  if (!entry.isDirectory()) continue;
3670
3769
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
3671
- const fullPath = path11.join(dir, entry.name);
3770
+ const fullPath = path12.join(dir, entry.name);
3672
3771
  const templateId = prefix ? `${prefix}/${entry.name}` : entry.name;
3673
- const configPath = path11.join(fullPath, "_CONFIG.md");
3674
- if (fs11.existsSync(configPath)) {
3772
+ const configPath = path12.join(fullPath, "_CONFIG.md");
3773
+ if (fs13.existsSync(configPath)) {
3675
3774
  const metadata = parseConfigMd(configPath, templateId, fullPath);
3676
3775
  if (metadata) {
3677
3776
  templatesCache.set(templateId, metadata);
@@ -3682,7 +3781,7 @@ function scanTemplates(dir, prefix) {
3682
3781
  }
3683
3782
  function parseConfigMd(configPath, templateId, templateDir) {
3684
3783
  try {
3685
- const content = fs11.readFileSync(configPath, "utf-8");
3784
+ const content = fs13.readFileSync(configPath, "utf-8");
3686
3785
  const titleMatch = content.match(/^#\s+(.+)$/m);
3687
3786
  const name = titleMatch ? titleMatch[1].trim() : templateId;
3688
3787
  const descMatch = content.match(/^>\s*(.+)$/m);
@@ -3725,14 +3824,14 @@ function inferTemplateType(templateId, name) {
3725
3824
  }
3726
3825
  function getTemplateFiles(dir, prefix = "") {
3727
3826
  const files = [];
3728
- const entries = fs11.readdirSync(dir, { withFileTypes: true });
3827
+ const entries = fs13.readdirSync(dir, { withFileTypes: true });
3729
3828
  for (const entry of entries) {
3730
3829
  const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
3731
3830
  if (entry.name === "_CONFIG.md" || entry.name === "_template.json") {
3732
3831
  continue;
3733
3832
  }
3734
3833
  if (entry.isDirectory()) {
3735
- files.push(...getTemplateFiles(path11.join(dir, entry.name), relativePath));
3834
+ files.push(...getTemplateFiles(path12.join(dir, entry.name), relativePath));
3736
3835
  } else {
3737
3836
  files.push(relativePath);
3738
3837
  }
@@ -3787,9 +3886,9 @@ function getTemplateById(templateId, includeFiles = false) {
3787
3886
  ensureCache2();
3788
3887
  const metadata = templatesCache.get(templateId);
3789
3888
  if (!metadata) return null;
3790
- const templateDir = path11.join(TEMPLATES_DIR, templateId);
3791
- const configPath = path11.join(templateDir, "_CONFIG.md");
3792
- const configGuide = fs11.existsSync(configPath) ? fs11.readFileSync(configPath, "utf-8") : "";
3889
+ const templateDir = path12.join(TEMPLATES_DIR, templateId);
3890
+ const configPath = path12.join(templateDir, "_CONFIG.md");
3891
+ const configGuide = fs13.existsSync(configPath) ? fs13.readFileSync(configPath, "utf-8") : "";
3793
3892
  const result = {
3794
3893
  metadata,
3795
3894
  configGuide
@@ -3797,11 +3896,11 @@ function getTemplateById(templateId, includeFiles = false) {
3797
3896
  if (includeFiles) {
3798
3897
  result.files = [];
3799
3898
  for (const filePath of metadata.files) {
3800
- const fullPath = path11.join(templateDir, filePath);
3801
- if (fs11.existsSync(fullPath)) {
3899
+ const fullPath = path12.join(templateDir, filePath);
3900
+ if (fs13.existsSync(fullPath)) {
3802
3901
  result.files.push({
3803
3902
  path: filePath,
3804
- content: fs11.readFileSync(fullPath, "utf-8"),
3903
+ content: fs13.readFileSync(fullPath, "utf-8"),
3805
3904
  isConfig: filePath.startsWith("_")
3806
3905
  });
3807
3906
  }
@@ -3812,7 +3911,7 @@ function getTemplateById(templateId, includeFiles = false) {
3812
3911
  function getTemplateDir(templateId) {
3813
3912
  ensureCache2();
3814
3913
  if (!templatesCache.has(templateId)) return null;
3815
- return path11.join(TEMPLATES_DIR, templateId);
3914
+ return path12.join(TEMPLATES_DIR, templateId);
3816
3915
  }
3817
3916
  function searchTemplates(query) {
3818
3917
  const lower = query.toLowerCase();
@@ -4098,8 +4197,8 @@ function createLogger(name) {
4098
4197
  }
4099
4198
 
4100
4199
  // src/core/autoConfig.ts
4101
- import * as fs12 from "fs";
4102
- import * as path12 from "path";
4200
+ import * as fs14 from "fs";
4201
+ import * as path13 from "path";
4103
4202
  var checkedWorkspaces = /* @__PURE__ */ new Map();
4104
4203
  var CACHE_DURATION = 5 * 60 * 1e3;
4105
4204
  function ensureWorkspaceConfig(workspacePath) {
@@ -4109,7 +4208,7 @@ function ensureWorkspaceConfig(workspacePath) {
4109
4208
  wasFixed: false,
4110
4209
  workspacePath
4111
4210
  };
4112
- if (!workspacePath || !fs12.existsSync(workspacePath)) {
4211
+ if (!workspacePath || !fs14.existsSync(workspacePath)) {
4113
4212
  return result;
4114
4213
  }
4115
4214
  const cached = checkedWorkspaces.get(workspacePath);
@@ -4117,13 +4216,13 @@ function ensureWorkspaceConfig(workspacePath) {
4117
4216
  if (cached && cached.configured && now - cached.timestamp < CACHE_DURATION) {
4118
4217
  return result;
4119
4218
  }
4120
- const vscodeDir = path12.join(workspacePath, ".vscode");
4121
- const mcpJsonPath = path12.join(vscodeDir, "mcp.json");
4122
- const settingsPath = path12.join(vscodeDir, "settings.json");
4219
+ const vscodeDir = path13.join(workspacePath, ".vscode");
4220
+ const mcpJsonPath = path13.join(vscodeDir, "mcp.json");
4221
+ const settingsPath = path13.join(vscodeDir, "settings.json");
4123
4222
  let hasMtaConfig = false;
4124
- if (fs12.existsSync(mcpJsonPath)) {
4223
+ if (fs14.existsSync(mcpJsonPath)) {
4125
4224
  try {
4126
- const config = JSON.parse(fs12.readFileSync(mcpJsonPath, "utf-8"));
4225
+ const config = JSON.parse(fs14.readFileSync(mcpJsonPath, "utf-8"));
4127
4226
  hasMtaConfig = !!(((_a = config.servers) == null ? void 0 : _a.mta) || ((_b = config.mcpServers) == null ? void 0 : _b.mta));
4128
4227
  } catch {
4129
4228
  }
@@ -4134,13 +4233,13 @@ function ensureWorkspaceConfig(workspacePath) {
4134
4233
  }
4135
4234
  result.needsSetup = true;
4136
4235
  try {
4137
- if (!fs12.existsSync(vscodeDir)) {
4138
- fs12.mkdirSync(vscodeDir, { recursive: true });
4236
+ if (!fs14.existsSync(vscodeDir)) {
4237
+ fs14.mkdirSync(vscodeDir, { recursive: true });
4139
4238
  }
4140
4239
  let mcpConfig = { servers: {} };
4141
- if (fs12.existsSync(mcpJsonPath)) {
4240
+ if (fs14.existsSync(mcpJsonPath)) {
4142
4241
  try {
4143
- mcpConfig = JSON.parse(fs12.readFileSync(mcpJsonPath, "utf-8"));
4242
+ mcpConfig = JSON.parse(fs14.readFileSync(mcpJsonPath, "utf-8"));
4144
4243
  if (!mcpConfig.servers) {
4145
4244
  mcpConfig.servers = {};
4146
4245
  }
@@ -4153,21 +4252,21 @@ function ensureWorkspaceConfig(workspacePath) {
4153
4252
  args: ["-y", "mta-mcp"],
4154
4253
  env: {}
4155
4254
  };
4156
- fs12.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
4255
+ fs14.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
4157
4256
  let settings = {};
4158
- if (fs12.existsSync(settingsPath)) {
4257
+ if (fs14.existsSync(settingsPath)) {
4159
4258
  try {
4160
- settings = JSON.parse(fs12.readFileSync(settingsPath, "utf-8"));
4259
+ settings = JSON.parse(fs14.readFileSync(settingsPath, "utf-8"));
4161
4260
  } catch {
4162
4261
  settings = {};
4163
4262
  }
4164
4263
  }
4165
4264
  if (!settings["github.copilot.chat.mcp.enabled"]) {
4166
4265
  settings["github.copilot.chat.mcp.enabled"] = true;
4167
- fs12.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
4266
+ fs14.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
4168
4267
  }
4169
4268
  result.wasFixed = true;
4170
- result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${path12.basename(workspacePath)} \u914D\u7F6E MTA MCP\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3\u4F7F\u914D\u7F6E\u751F\u6548\u3002`;
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`;
4171
4270
  checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
4172
4271
  } catch (error) {
4173
4272
  result.message = `\u26A0\uFE0F \u81EA\u52A8\u914D\u7F6E\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`;
@@ -4265,6 +4364,35 @@ var CopilotPromptsMCPServer = class {
4265
4364
  required: ["workspacePath"]
4266
4365
  }
4267
4366
  },
4367
+ {
4368
+ name: "init_project",
4369
+ description: `\u3010\u521D\u59CB\u5316\u9879\u76EE\u3011\u5FEB\u901F\u521D\u59CB\u5316\u9879\u76EE\u7684 MTA \u914D\u7F6E\u3002
4370
+ \u7528\u6CD5\uFF1A@mta \u521D\u59CB\u5316\u9879\u76EE
4371
+
4372
+ \u529F\u80FD\uFF1A
4373
+ 1. \u81EA\u52A8\u4ECE\u804A\u5929\u4E0A\u4E0B\u6587\u4E2D\u68C0\u6D4B\u9879\u76EE\u8DEF\u5F84\uFF08Chat \u4E2D\u6DFB\u52A0\u7684\u6587\u4EF6\u5939\uFF09
4374
+ 2. \u5206\u6790\u9879\u76EE\u6280\u672F\u6808\u5E76\u751F\u6210 copilot-instructions.md
4375
+ 3. \u5982\u679C\u5DF2\u5B58\u5728\u914D\u7F6E\uFF0C\u4F1A\u8BFB\u53D6\u7528\u6237\u5DF2\u914D\u7F6E\u7684 Agents \u5E76\u8865\u5145\u7F3A\u5931\u7684\u89C4\u8303
4376
+
4377
+ \u63D0\u793A\uFF1A\u786E\u4FDD\u5728 Chat \u4E2D\u5DF2\u6DFB\u52A0\u9879\u76EE\u6587\u4EF6\u5939`,
4378
+ inputSchema: {
4379
+ type: "object",
4380
+ properties: {
4381
+ projectPath: {
4382
+ type: "string",
4383
+ description: "\u9879\u76EE\u8DEF\u5F84\uFF08\u53EF\u9009\uFF0C\u5982\u679C\u4E0D\u63D0\u4F9B\u4F1A\u5C1D\u8BD5\u4ECE\u4E0A\u4E0B\u6587\u63A8\u65AD\uFF09"
4384
+ }
4385
+ }
4386
+ }
4387
+ },
4388
+ {
4389
+ name: "list_available_agents",
4390
+ description: "\u5217\u51FA\u6240\u6709\u53EF\u7528\u7684 Agents\uFF08\u7528\u4E8E VSCode \u63D2\u4EF6\u7B49\u573A\u666F\uFF09\uFF0C\u8FD4\u56DE Agent \u5143\u6570\u636E\u5217\u8868",
4391
+ inputSchema: {
4392
+ type: "object",
4393
+ properties: {}
4394
+ }
4395
+ },
4268
4396
  {
4269
4397
  name: "health_check",
4270
4398
  description: "\u68C0\u67E5 MCP \u670D\u52A1\u5668\u72B6\u6001\u548C\u914D\u7F6E\u95EE\u9898\uFF0C\u8FD4\u56DE\u8BCA\u65AD\u62A5\u544A\u548C\u4FEE\u590D\u5EFA\u8BAE",
@@ -4548,6 +4676,9 @@ var CopilotPromptsMCPServer = class {
4548
4676
  case "auto_setup":
4549
4677
  result = await autoSetup(args);
4550
4678
  break;
4679
+ case "init_project":
4680
+ result = await initProject(args);
4681
+ break;
4551
4682
  case "health_check":
4552
4683
  result = await healthCheck(args);
4553
4684
  break;
@@ -4561,7 +4692,7 @@ var CopilotPromptsMCPServer = class {
4561
4692
  result = await matchAgents(args);
4562
4693
  break;
4563
4694
  case "list_available_agents":
4564
- result = await listAvailableAgents();
4695
+ result = listAvailableAgents();
4565
4696
  break;
4566
4697
  case "generate_config":
4567
4698
  result = await generateConfig(args);