mta-mcp 2.8.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/bin/mta.cjs +65 -1
- package/dist/index.js +373 -154
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1112,51 +1112,77 @@ async function matchAgents(args) {
|
|
|
1112
1112
|
}
|
|
1113
1113
|
}
|
|
1114
1114
|
|
|
1115
|
-
// src/tools/
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
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
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
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
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
1158
|
-
import * as
|
|
1159
|
-
import { fileURLToPath as
|
|
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
|
|
1482
|
-
var
|
|
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 (!
|
|
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:
|
|
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 =
|
|
1544
|
-
const configPath =
|
|
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 (
|
|
1548
|
-
existingConfig =
|
|
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 (!
|
|
1555
|
-
|
|
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 =
|
|
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 =
|
|
1674
|
-
if (
|
|
1675
|
-
const configData = JSON.parse(
|
|
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
|
-
|
|
1840
|
-
const gitignorePath =
|
|
1841
|
-
if (
|
|
1842
|
-
let gitignoreContent =
|
|
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
|
-
|
|
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
|
|
1879
|
-
import * as
|
|
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 (!
|
|
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 =
|
|
1903
|
-
const hasExistingInstructions =
|
|
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
|
|
1977
|
-
import * as
|
|
1978
|
-
import { fileURLToPath as
|
|
1979
|
-
var
|
|
1980
|
-
var
|
|
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 =
|
|
2014
|
-
const npmPath =
|
|
2015
|
-
this.standardsPath =
|
|
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 =
|
|
2030
|
-
if (!
|
|
2128
|
+
const categoryPath = path8.join(this.standardsPath, dir);
|
|
2129
|
+
if (!fs9.existsSync(categoryPath)) {
|
|
2031
2130
|
return;
|
|
2032
2131
|
}
|
|
2033
|
-
const files =
|
|
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 =
|
|
2064
|
-
if (!
|
|
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 =
|
|
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
|
|
2611
|
-
import * as
|
|
2612
|
-
import { fileURLToPath as
|
|
2613
|
-
var
|
|
2614
|
-
var
|
|
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
|
-
|
|
2716
|
+
path9.resolve(__dirname6, "../.."),
|
|
2618
2717
|
// 从 dist/tools/ 向上两级
|
|
2619
|
-
|
|
2718
|
+
path9.resolve(__dirname6, "../../.."),
|
|
2620
2719
|
// npm 包场景
|
|
2621
|
-
|
|
2720
|
+
path9.resolve(process.cwd())
|
|
2622
2721
|
// 当前工作目录
|
|
2623
2722
|
];
|
|
2624
2723
|
for (const root of possibleRoots) {
|
|
2625
|
-
const standardsPath =
|
|
2626
|
-
if (
|
|
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 =
|
|
2657
|
-
if (
|
|
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 =
|
|
2661
|
-
if (
|
|
2759
|
+
const mcpJsonPath = path9.join(vscodeDir, "mcp.json");
|
|
2760
|
+
if (fs10.existsSync(mcpJsonPath)) {
|
|
2662
2761
|
try {
|
|
2663
|
-
const config = JSON.parse(
|
|
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 =
|
|
2707
|
-
if (
|
|
2805
|
+
const settingsPath = path9.join(vscodeDir, "settings.json");
|
|
2806
|
+
if (fs10.existsSync(settingsPath)) {
|
|
2708
2807
|
try {
|
|
2709
|
-
const settings = JSON.parse(
|
|
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 =
|
|
2727
|
-
if (
|
|
2825
|
+
const packageJsonPath = path9.join(serverRoot, "package.json");
|
|
2826
|
+
if (fs10.existsSync(packageJsonPath)) {
|
|
2728
2827
|
try {
|
|
2729
|
-
const pkg = JSON.parse(
|
|
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 =
|
|
2754
|
-
if (
|
|
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 =
|
|
2759
|
-
if (
|
|
2760
|
-
const files =
|
|
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,13 +2933,19 @@ function generateRecommendations(checks) {
|
|
|
2834
2933
|
}
|
|
2835
2934
|
|
|
2836
2935
|
// src/tools/getCompactStandards.ts
|
|
2837
|
-
import * as
|
|
2936
|
+
import * as fs11 from "fs";
|
|
2937
|
+
import * as path10 from "path";
|
|
2938
|
+
init_smartAgentMatcher();
|
|
2838
2939
|
async function getCompactStandards(args) {
|
|
2839
2940
|
const logger3 = new ConsoleLogger();
|
|
2840
2941
|
const manager = new StandardsManager();
|
|
2841
2942
|
const mode = args.mode || "key-rules";
|
|
2842
2943
|
try {
|
|
2843
|
-
|
|
2944
|
+
let context = detectContext(args, logger3);
|
|
2945
|
+
if (args.projectPath && fs11.existsSync(args.projectPath)) {
|
|
2946
|
+
const projectContext = await analyzeProject2(args.projectPath, logger3);
|
|
2947
|
+
context = mergeContexts(context, projectContext);
|
|
2948
|
+
}
|
|
2844
2949
|
const standardUris = manager.getRelevantStandards({
|
|
2845
2950
|
fileType: context.fileType,
|
|
2846
2951
|
imports: context.imports,
|
|
@@ -2858,6 +2963,13 @@ async function getCompactStandards(args) {
|
|
|
2858
2963
|
responseContent = buildFullResponse(standardUris, manager);
|
|
2859
2964
|
break;
|
|
2860
2965
|
}
|
|
2966
|
+
if (args.projectPath && context.userConfiguredAgents) {
|
|
2967
|
+
responseContent.projectInfo = {
|
|
2968
|
+
hasUserConfig: true,
|
|
2969
|
+
userAgents: context.userConfiguredAgents,
|
|
2970
|
+
message: "\u2705 \u5DF2\u8BFB\u53D6\u7528\u6237\u914D\u7F6E\u7684 Agents\uFF0C\u5E76\u8865\u5145\u4E86\u7F3A\u5931\u7684\u89C4\u8303"
|
|
2971
|
+
};
|
|
2972
|
+
}
|
|
2861
2973
|
return {
|
|
2862
2974
|
content: [{
|
|
2863
2975
|
type: "text",
|
|
@@ -2876,12 +2988,74 @@ async function getCompactStandards(args) {
|
|
|
2876
2988
|
};
|
|
2877
2989
|
}
|
|
2878
2990
|
}
|
|
2991
|
+
async function analyzeProject2(projectPath, logger3) {
|
|
2992
|
+
var _a, _b;
|
|
2993
|
+
const result = {
|
|
2994
|
+
fileType: "unknown",
|
|
2995
|
+
imports: [],
|
|
2996
|
+
scenario: ""
|
|
2997
|
+
};
|
|
2998
|
+
const instructionsPath = path10.join(projectPath, ".github", "copilot-instructions.md");
|
|
2999
|
+
if (fs11.existsSync(instructionsPath)) {
|
|
3000
|
+
try {
|
|
3001
|
+
const content = fs11.readFileSync(instructionsPath, "utf-8");
|
|
3002
|
+
const agents = extractUserAgents(content);
|
|
3003
|
+
if (agents.length > 0) {
|
|
3004
|
+
result.userConfiguredAgents = agents;
|
|
3005
|
+
logger3.log(`\u2705 \u68C0\u6D4B\u5230\u7528\u6237\u914D\u7F6E\u7684 Agents: ${agents.join(", ")}`);
|
|
3006
|
+
}
|
|
3007
|
+
} catch (error) {
|
|
3008
|
+
logger3.error(`\u8BFB\u53D6\u7528\u6237\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
3009
|
+
}
|
|
3010
|
+
}
|
|
3011
|
+
const matcher = new SmartAgentMatcher(logger3);
|
|
3012
|
+
const workspaceFolder = {
|
|
3013
|
+
uri: { fsPath: projectPath },
|
|
3014
|
+
name: path10.basename(projectPath),
|
|
3015
|
+
index: 0
|
|
3016
|
+
};
|
|
3017
|
+
try {
|
|
3018
|
+
const features = await matcher.analyzeProject(workspaceFolder);
|
|
3019
|
+
if ((_a = features.frameworks) == null ? void 0 : _a.includes("vue")) {
|
|
3020
|
+
result.fileType = "vue";
|
|
3021
|
+
result.imports.push("vue");
|
|
3022
|
+
}
|
|
3023
|
+
if ((_b = features.frameworks) == null ? void 0 : _b.includes("flutter")) {
|
|
3024
|
+
result.fileType = "dart";
|
|
3025
|
+
result.imports.push("flutter");
|
|
3026
|
+
}
|
|
3027
|
+
if (features.libraries) {
|
|
3028
|
+
result.imports.push(...features.libraries);
|
|
3029
|
+
}
|
|
3030
|
+
logger3.log(`\u{1F50D} \u9879\u76EE\u6280\u672F\u6808: ${result.imports.join(", ")}`);
|
|
3031
|
+
} catch (error) {
|
|
3032
|
+
logger3.error(`\u9879\u76EE\u5206\u6790\u5931\u8D25: ${error}`);
|
|
3033
|
+
}
|
|
3034
|
+
return result;
|
|
3035
|
+
}
|
|
3036
|
+
function extractUserAgents(content) {
|
|
3037
|
+
const agents = [];
|
|
3038
|
+
const agentIdRegex = /- \*\*Agent ID\*\*:\s*`([^`]+)`/g;
|
|
3039
|
+
let match;
|
|
3040
|
+
while ((match = agentIdRegex.exec(content)) !== null) {
|
|
3041
|
+
agents.push(match[1]);
|
|
3042
|
+
}
|
|
3043
|
+
return agents;
|
|
3044
|
+
}
|
|
3045
|
+
function mergeContexts(fileContext, projectContext) {
|
|
3046
|
+
return {
|
|
3047
|
+
fileType: fileContext.fileType !== "unknown" ? fileContext.fileType : projectContext.fileType,
|
|
3048
|
+
imports: [.../* @__PURE__ */ new Set([...fileContext.imports, ...projectContext.imports])],
|
|
3049
|
+
scenario: fileContext.scenario || projectContext.scenario,
|
|
3050
|
+
userConfiguredAgents: projectContext.userConfiguredAgents
|
|
3051
|
+
};
|
|
3052
|
+
}
|
|
2879
3053
|
function detectContext(args, logger3) {
|
|
2880
3054
|
var _a;
|
|
2881
3055
|
let fileType = "unknown";
|
|
2882
3056
|
let imports = [];
|
|
2883
3057
|
let scenario = "";
|
|
2884
|
-
if (args.currentFile &&
|
|
3058
|
+
if (args.currentFile && fs11.existsSync(args.currentFile)) {
|
|
2885
3059
|
const ext = ((_a = args.currentFile.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
|
|
2886
3060
|
const extMap = {
|
|
2887
3061
|
"vue": "vue",
|
|
@@ -2893,7 +3067,7 @@ function detectContext(args, logger3) {
|
|
|
2893
3067
|
};
|
|
2894
3068
|
fileType = extMap[ext] || "unknown";
|
|
2895
3069
|
try {
|
|
2896
|
-
const content =
|
|
3070
|
+
const content = fs11.readFileSync(args.currentFile, "utf-8");
|
|
2897
3071
|
imports = extractImports(content);
|
|
2898
3072
|
scenario = inferScenario(content, fileType);
|
|
2899
3073
|
} catch {
|
|
@@ -3210,8 +3384,8 @@ function inferScenario(content, fileType) {
|
|
|
3210
3384
|
}
|
|
3211
3385
|
|
|
3212
3386
|
// src/tools/getStandardById.ts
|
|
3213
|
-
import * as
|
|
3214
|
-
import * as
|
|
3387
|
+
import * as fs12 from "fs";
|
|
3388
|
+
import * as path11 from "path";
|
|
3215
3389
|
var STANDARD_DIRS = [
|
|
3216
3390
|
"standards/core",
|
|
3217
3391
|
"standards/frameworks",
|
|
@@ -3249,7 +3423,7 @@ async function getStandardById(args) {
|
|
|
3249
3423
|
continue;
|
|
3250
3424
|
}
|
|
3251
3425
|
try {
|
|
3252
|
-
const fullContent =
|
|
3426
|
+
const fullContent = fs12.readFileSync(filePath, "utf-8");
|
|
3253
3427
|
const content = formatContent(fullContent, mode);
|
|
3254
3428
|
results.push({
|
|
3255
3429
|
id,
|
|
@@ -3306,33 +3480,33 @@ function ensureCache() {
|
|
|
3306
3480
|
standardsCache = /* @__PURE__ */ new Map();
|
|
3307
3481
|
const baseDir = findBaseDir();
|
|
3308
3482
|
for (const dir of STANDARD_DIRS) {
|
|
3309
|
-
const fullDir =
|
|
3310
|
-
if (!
|
|
3483
|
+
const fullDir = path11.join(baseDir, dir);
|
|
3484
|
+
if (!fs12.existsSync(fullDir)) continue;
|
|
3311
3485
|
scanDirectory(fullDir, standardsCache);
|
|
3312
3486
|
}
|
|
3313
3487
|
}
|
|
3314
3488
|
function findBaseDir() {
|
|
3315
3489
|
const possiblePaths = [
|
|
3316
3490
|
process.cwd(),
|
|
3317
|
-
|
|
3318
|
-
|
|
3491
|
+
path11.join(process.cwd(), ".."),
|
|
3492
|
+
path11.join(__dirname, "..", "..", "..")
|
|
3319
3493
|
];
|
|
3320
3494
|
for (const p of possiblePaths) {
|
|
3321
|
-
if (
|
|
3495
|
+
if (fs12.existsSync(path11.join(p, "standards"))) {
|
|
3322
3496
|
return p;
|
|
3323
3497
|
}
|
|
3324
3498
|
}
|
|
3325
3499
|
return process.cwd();
|
|
3326
3500
|
}
|
|
3327
3501
|
function scanDirectory(dir, cache) {
|
|
3328
|
-
const items =
|
|
3502
|
+
const items = fs12.readdirSync(dir);
|
|
3329
3503
|
for (const item of items) {
|
|
3330
|
-
const fullPath =
|
|
3331
|
-
const stat =
|
|
3504
|
+
const fullPath = path11.join(dir, item);
|
|
3505
|
+
const stat = fs12.statSync(fullPath);
|
|
3332
3506
|
if (stat.isDirectory()) {
|
|
3333
3507
|
scanDirectory(fullPath, cache);
|
|
3334
3508
|
} else if (item.endsWith(".md")) {
|
|
3335
|
-
const id =
|
|
3509
|
+
const id = path11.basename(item, ".md");
|
|
3336
3510
|
cache.set(id, fullPath);
|
|
3337
3511
|
}
|
|
3338
3512
|
}
|
|
@@ -3575,10 +3749,10 @@ async function listScenarios() {
|
|
|
3575
3749
|
}
|
|
3576
3750
|
|
|
3577
3751
|
// src/core/templates/discovery.ts
|
|
3578
|
-
import * as
|
|
3579
|
-
import * as
|
|
3580
|
-
var TEMPLATES_DIR =
|
|
3581
|
-
|
|
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),
|
|
3582
3756
|
"../../../../templates"
|
|
3583
3757
|
);
|
|
3584
3758
|
var templatesCache = null;
|
|
@@ -3588,15 +3762,15 @@ function ensureCache2() {
|
|
|
3588
3762
|
scanTemplates(TEMPLATES_DIR, "");
|
|
3589
3763
|
}
|
|
3590
3764
|
function scanTemplates(dir, prefix) {
|
|
3591
|
-
if (!
|
|
3592
|
-
const entries =
|
|
3765
|
+
if (!fs13.existsSync(dir)) return;
|
|
3766
|
+
const entries = fs13.readdirSync(dir, { withFileTypes: true });
|
|
3593
3767
|
for (const entry of entries) {
|
|
3594
3768
|
if (!entry.isDirectory()) continue;
|
|
3595
3769
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
3596
|
-
const fullPath =
|
|
3770
|
+
const fullPath = path12.join(dir, entry.name);
|
|
3597
3771
|
const templateId = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
3598
|
-
const configPath =
|
|
3599
|
-
if (
|
|
3772
|
+
const configPath = path12.join(fullPath, "_CONFIG.md");
|
|
3773
|
+
if (fs13.existsSync(configPath)) {
|
|
3600
3774
|
const metadata = parseConfigMd(configPath, templateId, fullPath);
|
|
3601
3775
|
if (metadata) {
|
|
3602
3776
|
templatesCache.set(templateId, metadata);
|
|
@@ -3607,7 +3781,7 @@ function scanTemplates(dir, prefix) {
|
|
|
3607
3781
|
}
|
|
3608
3782
|
function parseConfigMd(configPath, templateId, templateDir) {
|
|
3609
3783
|
try {
|
|
3610
|
-
const content =
|
|
3784
|
+
const content = fs13.readFileSync(configPath, "utf-8");
|
|
3611
3785
|
const titleMatch = content.match(/^#\s+(.+)$/m);
|
|
3612
3786
|
const name = titleMatch ? titleMatch[1].trim() : templateId;
|
|
3613
3787
|
const descMatch = content.match(/^>\s*(.+)$/m);
|
|
@@ -3650,14 +3824,14 @@ function inferTemplateType(templateId, name) {
|
|
|
3650
3824
|
}
|
|
3651
3825
|
function getTemplateFiles(dir, prefix = "") {
|
|
3652
3826
|
const files = [];
|
|
3653
|
-
const entries =
|
|
3827
|
+
const entries = fs13.readdirSync(dir, { withFileTypes: true });
|
|
3654
3828
|
for (const entry of entries) {
|
|
3655
3829
|
const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
3656
3830
|
if (entry.name === "_CONFIG.md" || entry.name === "_template.json") {
|
|
3657
3831
|
continue;
|
|
3658
3832
|
}
|
|
3659
3833
|
if (entry.isDirectory()) {
|
|
3660
|
-
files.push(...getTemplateFiles(
|
|
3834
|
+
files.push(...getTemplateFiles(path12.join(dir, entry.name), relativePath));
|
|
3661
3835
|
} else {
|
|
3662
3836
|
files.push(relativePath);
|
|
3663
3837
|
}
|
|
@@ -3712,9 +3886,9 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3712
3886
|
ensureCache2();
|
|
3713
3887
|
const metadata = templatesCache.get(templateId);
|
|
3714
3888
|
if (!metadata) return null;
|
|
3715
|
-
const templateDir =
|
|
3716
|
-
const configPath =
|
|
3717
|
-
const configGuide =
|
|
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") : "";
|
|
3718
3892
|
const result = {
|
|
3719
3893
|
metadata,
|
|
3720
3894
|
configGuide
|
|
@@ -3722,11 +3896,11 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3722
3896
|
if (includeFiles) {
|
|
3723
3897
|
result.files = [];
|
|
3724
3898
|
for (const filePath of metadata.files) {
|
|
3725
|
-
const fullPath =
|
|
3726
|
-
if (
|
|
3899
|
+
const fullPath = path12.join(templateDir, filePath);
|
|
3900
|
+
if (fs13.existsSync(fullPath)) {
|
|
3727
3901
|
result.files.push({
|
|
3728
3902
|
path: filePath,
|
|
3729
|
-
content:
|
|
3903
|
+
content: fs13.readFileSync(fullPath, "utf-8"),
|
|
3730
3904
|
isConfig: filePath.startsWith("_")
|
|
3731
3905
|
});
|
|
3732
3906
|
}
|
|
@@ -3737,7 +3911,7 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3737
3911
|
function getTemplateDir(templateId) {
|
|
3738
3912
|
ensureCache2();
|
|
3739
3913
|
if (!templatesCache.has(templateId)) return null;
|
|
3740
|
-
return
|
|
3914
|
+
return path12.join(TEMPLATES_DIR, templateId);
|
|
3741
3915
|
}
|
|
3742
3916
|
function searchTemplates(query) {
|
|
3743
3917
|
const lower = query.toLowerCase();
|
|
@@ -4023,8 +4197,8 @@ function createLogger(name) {
|
|
|
4023
4197
|
}
|
|
4024
4198
|
|
|
4025
4199
|
// src/core/autoConfig.ts
|
|
4026
|
-
import * as
|
|
4027
|
-
import * as
|
|
4200
|
+
import * as fs14 from "fs";
|
|
4201
|
+
import * as path13 from "path";
|
|
4028
4202
|
var checkedWorkspaces = /* @__PURE__ */ new Map();
|
|
4029
4203
|
var CACHE_DURATION = 5 * 60 * 1e3;
|
|
4030
4204
|
function ensureWorkspaceConfig(workspacePath) {
|
|
@@ -4034,7 +4208,7 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
4034
4208
|
wasFixed: false,
|
|
4035
4209
|
workspacePath
|
|
4036
4210
|
};
|
|
4037
|
-
if (!workspacePath || !
|
|
4211
|
+
if (!workspacePath || !fs14.existsSync(workspacePath)) {
|
|
4038
4212
|
return result;
|
|
4039
4213
|
}
|
|
4040
4214
|
const cached = checkedWorkspaces.get(workspacePath);
|
|
@@ -4042,13 +4216,13 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
4042
4216
|
if (cached && cached.configured && now - cached.timestamp < CACHE_DURATION) {
|
|
4043
4217
|
return result;
|
|
4044
4218
|
}
|
|
4045
|
-
const vscodeDir =
|
|
4046
|
-
const mcpJsonPath =
|
|
4047
|
-
const settingsPath =
|
|
4219
|
+
const vscodeDir = path13.join(workspacePath, ".vscode");
|
|
4220
|
+
const mcpJsonPath = path13.join(vscodeDir, "mcp.json");
|
|
4221
|
+
const settingsPath = path13.join(vscodeDir, "settings.json");
|
|
4048
4222
|
let hasMtaConfig = false;
|
|
4049
|
-
if (
|
|
4223
|
+
if (fs14.existsSync(mcpJsonPath)) {
|
|
4050
4224
|
try {
|
|
4051
|
-
const config = JSON.parse(
|
|
4225
|
+
const config = JSON.parse(fs14.readFileSync(mcpJsonPath, "utf-8"));
|
|
4052
4226
|
hasMtaConfig = !!(((_a = config.servers) == null ? void 0 : _a.mta) || ((_b = config.mcpServers) == null ? void 0 : _b.mta));
|
|
4053
4227
|
} catch {
|
|
4054
4228
|
}
|
|
@@ -4059,13 +4233,13 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
4059
4233
|
}
|
|
4060
4234
|
result.needsSetup = true;
|
|
4061
4235
|
try {
|
|
4062
|
-
if (!
|
|
4063
|
-
|
|
4236
|
+
if (!fs14.existsSync(vscodeDir)) {
|
|
4237
|
+
fs14.mkdirSync(vscodeDir, { recursive: true });
|
|
4064
4238
|
}
|
|
4065
4239
|
let mcpConfig = { servers: {} };
|
|
4066
|
-
if (
|
|
4240
|
+
if (fs14.existsSync(mcpJsonPath)) {
|
|
4067
4241
|
try {
|
|
4068
|
-
mcpConfig = JSON.parse(
|
|
4242
|
+
mcpConfig = JSON.parse(fs14.readFileSync(mcpJsonPath, "utf-8"));
|
|
4069
4243
|
if (!mcpConfig.servers) {
|
|
4070
4244
|
mcpConfig.servers = {};
|
|
4071
4245
|
}
|
|
@@ -4078,21 +4252,21 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
4078
4252
|
args: ["-y", "mta-mcp"],
|
|
4079
4253
|
env: {}
|
|
4080
4254
|
};
|
|
4081
|
-
|
|
4255
|
+
fs14.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
4082
4256
|
let settings = {};
|
|
4083
|
-
if (
|
|
4257
|
+
if (fs14.existsSync(settingsPath)) {
|
|
4084
4258
|
try {
|
|
4085
|
-
settings = JSON.parse(
|
|
4259
|
+
settings = JSON.parse(fs14.readFileSync(settingsPath, "utf-8"));
|
|
4086
4260
|
} catch {
|
|
4087
4261
|
settings = {};
|
|
4088
4262
|
}
|
|
4089
4263
|
}
|
|
4090
4264
|
if (!settings["github.copilot.chat.mcp.enabled"]) {
|
|
4091
4265
|
settings["github.copilot.chat.mcp.enabled"] = true;
|
|
4092
|
-
|
|
4266
|
+
fs14.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
4093
4267
|
}
|
|
4094
4268
|
result.wasFixed = true;
|
|
4095
|
-
result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${
|
|
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`;
|
|
4096
4270
|
checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
|
|
4097
4271
|
} catch (error) {
|
|
4098
4272
|
result.message = `\u26A0\uFE0F \u81EA\u52A8\u914D\u7F6E\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -4190,6 +4364,35 @@ var CopilotPromptsMCPServer = class {
|
|
|
4190
4364
|
required: ["workspacePath"]
|
|
4191
4365
|
}
|
|
4192
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
|
+
},
|
|
4193
4396
|
{
|
|
4194
4397
|
name: "health_check",
|
|
4195
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",
|
|
@@ -4306,7 +4509,16 @@ var CopilotPromptsMCPServer = class {
|
|
|
4306
4509
|
},
|
|
4307
4510
|
{
|
|
4308
4511
|
name: "get_compact_standards",
|
|
4309
|
-
description:
|
|
4512
|
+
description: `\u83B7\u53D6\u7F16\u7801\u89C4\u8303\uFF08\u667A\u80FD\u6A21\u5F0F\uFF09
|
|
4513
|
+
\u529F\u80FD\uFF1A
|
|
4514
|
+
1. \u81EA\u52A8\u5206\u6790\u9879\u76EE\u6280\u672F\u6808\uFF08\u901A\u8FC7 projectPath\uFF09
|
|
4515
|
+
2. \u5982\u679C\u5B58\u5728 copilot-instructions.md\uFF0C\u4F18\u5148\u4F7F\u7528\u7528\u6237\u914D\u7F6E\u7684 Agents
|
|
4516
|
+
3. \u667A\u80FD\u8865\u5145\u7528\u6237\u672A\u914D\u7F6E\u7684\u89C4\u8303
|
|
4517
|
+
4. \u652F\u6301 summary/key-rules/full \u4E09\u79CD\u8FD4\u56DE\u6A21\u5F0F
|
|
4518
|
+
|
|
4519
|
+
\u4F7F\u7528\u573A\u666F\uFF1A
|
|
4520
|
+
- @mta \u8C03\u7528\u65F6\uFF0C\u4F20\u5165 projectPath \u83B7\u53D6\u5B8C\u6574\u9879\u76EE\u89C4\u8303
|
|
4521
|
+
- \u7F16\u5199\u4EE3\u7801\u65F6\uFF0C\u4F20\u5165 fileContent \u83B7\u53D6\u6587\u4EF6\u76F8\u5173\u89C4\u8303`,
|
|
4310
4522
|
inputSchema: {
|
|
4311
4523
|
type: "object",
|
|
4312
4524
|
properties: {
|
|
@@ -4318,6 +4530,10 @@ var CopilotPromptsMCPServer = class {
|
|
|
4318
4530
|
type: "string",
|
|
4319
4531
|
description: "\u6587\u4EF6\u5185\u5BB9\uFF08\u53EF\u9009\uFF09"
|
|
4320
4532
|
},
|
|
4533
|
+
projectPath: {
|
|
4534
|
+
type: "string",
|
|
4535
|
+
description: "\u9879\u76EE\u6839\u8DEF\u5F84\uFF08\u63A8\u8350\uFF09- \u4F1A\u81EA\u52A8\u5206\u6790\u9879\u76EE\u6280\u672F\u6808\u5E76\u8BFB\u53D6\u7528\u6237\u914D\u7F6E"
|
|
4536
|
+
},
|
|
4321
4537
|
scenario: {
|
|
4322
4538
|
type: "string",
|
|
4323
4539
|
description: "\u5F00\u53D1\u573A\u666F\uFF08\u53EF\u9009\uFF09"
|
|
@@ -4325,7 +4541,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4325
4541
|
mode: {
|
|
4326
4542
|
type: "string",
|
|
4327
4543
|
enum: ["summary", "key-rules", "full"],
|
|
4328
|
-
description: "\u8FD4\u56DE\u6A21\u5F0F",
|
|
4544
|
+
description: "\u8FD4\u56DE\u6A21\u5F0F\uFF1Asummary(\u6458\u8981)/key-rules(\u5173\u952E\u89C4\u5219,\u9ED8\u8BA4)/full(\u5B8C\u6574\u5185\u5BB9)",
|
|
4329
4545
|
default: "key-rules"
|
|
4330
4546
|
}
|
|
4331
4547
|
}
|
|
@@ -4460,6 +4676,9 @@ var CopilotPromptsMCPServer = class {
|
|
|
4460
4676
|
case "auto_setup":
|
|
4461
4677
|
result = await autoSetup(args);
|
|
4462
4678
|
break;
|
|
4679
|
+
case "init_project":
|
|
4680
|
+
result = await initProject(args);
|
|
4681
|
+
break;
|
|
4463
4682
|
case "health_check":
|
|
4464
4683
|
result = await healthCheck(args);
|
|
4465
4684
|
break;
|
|
@@ -4473,7 +4692,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4473
4692
|
result = await matchAgents(args);
|
|
4474
4693
|
break;
|
|
4475
4694
|
case "list_available_agents":
|
|
4476
|
-
result =
|
|
4695
|
+
result = listAvailableAgents();
|
|
4477
4696
|
break;
|
|
4478
4697
|
case "generate_config":
|
|
4479
4698
|
result = await generateConfig(args);
|