mta-mcp 2.7.1 → 2.9.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 +172 -134
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1878,7 +1878,7 @@ async function generateConfig(args) {
|
|
|
1878
1878
|
import * as fs6 from "fs";
|
|
1879
1879
|
import * as path6 from "path";
|
|
1880
1880
|
async function autoSetup(args) {
|
|
1881
|
-
var _a
|
|
1881
|
+
var _a;
|
|
1882
1882
|
const logger3 = new ConsoleLogger();
|
|
1883
1883
|
try {
|
|
1884
1884
|
const workspacePath = args.workspacePath || process.cwd();
|
|
@@ -1897,102 +1897,7 @@ async function autoSetup(args) {
|
|
|
1897
1897
|
steps: [],
|
|
1898
1898
|
warnings: []
|
|
1899
1899
|
};
|
|
1900
|
-
logger3.log("\u{1F680} \u5F00\u59CB\
|
|
1901
|
-
const vscodeDir = path6.join(workspacePath, ".vscode");
|
|
1902
|
-
if (!fs6.existsSync(vscodeDir)) {
|
|
1903
|
-
fs6.mkdirSync(vscodeDir, { recursive: true });
|
|
1904
|
-
results.steps.push({ step: "\u521B\u5EFA .vscode \u76EE\u5F55", status: "success" });
|
|
1905
|
-
} else {
|
|
1906
|
-
results.steps.push({ step: "\u68C0\u6D4B\u5230\u5DF2\u6709 .vscode \u76EE\u5F55", status: "skip" });
|
|
1907
|
-
}
|
|
1908
|
-
results.steps.push({
|
|
1909
|
-
step: "\u4F7F\u7528 npx mta-mcp \u914D\u7F6E",
|
|
1910
|
-
status: "success",
|
|
1911
|
-
detail: "\u901A\u8FC7 npm \u5305\u8FD0\u884C\uFF0C\u65E0\u9700\u672C\u5730\u5B89\u88C5"
|
|
1912
|
-
});
|
|
1913
|
-
const mcpJsonPath = path6.join(vscodeDir, "mcp.json");
|
|
1914
|
-
const mcpConfig = {
|
|
1915
|
-
servers: {
|
|
1916
|
-
"mta": {
|
|
1917
|
-
command: "npx",
|
|
1918
|
-
args: ["-y", "mta-mcp"],
|
|
1919
|
-
env: {}
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
};
|
|
1923
|
-
if (fs6.existsSync(mcpJsonPath)) {
|
|
1924
|
-
try {
|
|
1925
|
-
const existingConfig = JSON.parse(fs6.readFileSync(mcpJsonPath, "utf-8"));
|
|
1926
|
-
if (existingConfig.mcpServers && !existingConfig.servers) {
|
|
1927
|
-
results.warnings.push("\u68C0\u6D4B\u5230\u65E7\u7248\u914D\u7F6E\u683C\u5F0F(mcpServers)\uFF0C\u5DF2\u81EA\u52A8\u5347\u7EA7\u4E3A\u65B0\u683C\u5F0F(servers)");
|
|
1928
|
-
existingConfig.servers = existingConfig.mcpServers;
|
|
1929
|
-
delete existingConfig.mcpServers;
|
|
1930
|
-
}
|
|
1931
|
-
if ((_a = existingConfig.servers) == null ? void 0 : _a.mta) {
|
|
1932
|
-
results.steps.push({ step: "mcp.json \u5DF2\u5305\u542B mta \u914D\u7F6E", status: "skip" });
|
|
1933
|
-
} else {
|
|
1934
|
-
existingConfig.servers = {
|
|
1935
|
-
...existingConfig.servers,
|
|
1936
|
-
...mcpConfig.servers
|
|
1937
|
-
};
|
|
1938
|
-
fs6.writeFileSync(mcpJsonPath, JSON.stringify(existingConfig, null, 2));
|
|
1939
|
-
results.steps.push({ step: "\u6DFB\u52A0 mta \u5230 mcp.json", status: "success" });
|
|
1940
|
-
}
|
|
1941
|
-
} catch (err) {
|
|
1942
|
-
fs6.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
1943
|
-
results.steps.push({ step: "\u91CD\u65B0\u521B\u5EFA mcp.json", status: "success" });
|
|
1944
|
-
results.warnings.push(`\u539F\u914D\u7F6E\u6587\u4EF6\u89E3\u6790\u5931\u8D25: ${err}`);
|
|
1945
|
-
}
|
|
1946
|
-
} else {
|
|
1947
|
-
fs6.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
1948
|
-
results.steps.push({ step: "\u521B\u5EFA mcp.json", status: "success" });
|
|
1949
|
-
}
|
|
1950
|
-
const settingsJsonPath = path6.join(vscodeDir, "settings.json");
|
|
1951
|
-
const mcpSettings = {
|
|
1952
|
-
"github.copilot.chat.mcp.enabled": true,
|
|
1953
|
-
"github.copilot.chat.mcp.configFile": "${workspaceFolder}/.vscode/mcp.json",
|
|
1954
|
-
"github.copilot.chat.mcp.autoStart": true
|
|
1955
|
-
};
|
|
1956
|
-
if (fs6.existsSync(settingsJsonPath)) {
|
|
1957
|
-
try {
|
|
1958
|
-
const existingSettings = JSON.parse(fs6.readFileSync(settingsJsonPath, "utf-8"));
|
|
1959
|
-
const updated = { ...existingSettings, ...mcpSettings };
|
|
1960
|
-
fs6.writeFileSync(settingsJsonPath, JSON.stringify(updated, null, 2) + "\n");
|
|
1961
|
-
results.steps.push({ step: "\u66F4\u65B0 settings.json", status: "success" });
|
|
1962
|
-
} catch {
|
|
1963
|
-
fs6.writeFileSync(settingsJsonPath, JSON.stringify(mcpSettings, null, 2) + "\n");
|
|
1964
|
-
results.steps.push({ step: "\u91CD\u65B0\u521B\u5EFA settings.json", status: "success" });
|
|
1965
|
-
}
|
|
1966
|
-
} else {
|
|
1967
|
-
fs6.writeFileSync(settingsJsonPath, JSON.stringify(mcpSettings, null, 2) + "\n");
|
|
1968
|
-
results.steps.push({ step: "\u521B\u5EFA settings.json", status: "success" });
|
|
1969
|
-
}
|
|
1970
|
-
const extensionsJsonPath = path6.join(vscodeDir, "extensions.json");
|
|
1971
|
-
const recommendedExtensions = {
|
|
1972
|
-
recommendations: [
|
|
1973
|
-
"github.copilot",
|
|
1974
|
-
"github.copilot-chat"
|
|
1975
|
-
]
|
|
1976
|
-
};
|
|
1977
|
-
if (!fs6.existsSync(extensionsJsonPath)) {
|
|
1978
|
-
fs6.writeFileSync(extensionsJsonPath, JSON.stringify(recommendedExtensions, null, 2));
|
|
1979
|
-
results.steps.push({ step: "\u521B\u5EFA extensions.json", status: "success" });
|
|
1980
|
-
} else {
|
|
1981
|
-
results.steps.push({ step: "extensions.json \u5DF2\u5B58\u5728", status: "skip" });
|
|
1982
|
-
}
|
|
1983
|
-
const gitignorePath = path6.join(workspacePath, ".gitignore");
|
|
1984
|
-
if (fs6.existsSync(gitignorePath)) {
|
|
1985
|
-
const gitignoreContent = fs6.readFileSync(gitignorePath, "utf-8");
|
|
1986
|
-
if (!gitignoreContent.includes(".vscode/mcp.json")) {
|
|
1987
|
-
const updatedContent = gitignoreContent + "\n# MCP \u914D\u7F6E\uFF08\u672C\u5730\uFF09\n.vscode/mcp.json\n";
|
|
1988
|
-
fs6.writeFileSync(gitignorePath, updatedContent);
|
|
1989
|
-
results.steps.push({ step: "\u6DFB\u52A0\u5230 .gitignore", status: "success" });
|
|
1990
|
-
} else {
|
|
1991
|
-
results.steps.push({ step: ".gitignore \u5DF2\u5305\u542B\u914D\u7F6E", status: "skip" });
|
|
1992
|
-
}
|
|
1993
|
-
} else {
|
|
1994
|
-
results.warnings.push("\u672A\u68C0\u6D4B\u5230 .gitignore\uFF0C\u5EFA\u8BAE\u624B\u52A8\u6DFB\u52A0 .vscode/mcp.json");
|
|
1995
|
-
}
|
|
1900
|
+
logger3.log("\u{1F680} \u5F00\u59CB\u4E3A\u9879\u76EE\u751F\u6210 copilot-instructions.md...");
|
|
1996
1901
|
const generateInstructions = args.generateInstructions !== false;
|
|
1997
1902
|
const instructionsPath = path6.join(workspacePath, ".github", "copilot-instructions.md");
|
|
1998
1903
|
const hasExistingInstructions = fs6.existsSync(instructionsPath);
|
|
@@ -2015,7 +1920,7 @@ async function autoSetup(args) {
|
|
|
2015
1920
|
if (configContent.type === "text") {
|
|
2016
1921
|
const configData = JSON.parse(configContent.text);
|
|
2017
1922
|
if (configData.success) {
|
|
2018
|
-
const agentIds = ((
|
|
1923
|
+
const agentIds = ((_a = configData.agents) == null ? void 0 : _a.map((a) => a.id || a.title)) || [];
|
|
2019
1924
|
results.steps.push({
|
|
2020
1925
|
step: "\u2705 \u81EA\u52A8\u751F\u6210 copilot-instructions.md",
|
|
2021
1926
|
status: "success",
|
|
@@ -2037,16 +1942,16 @@ async function autoSetup(args) {
|
|
|
2037
1942
|
} else {
|
|
2038
1943
|
results.steps.push({ step: "\u8DF3\u8FC7 copilot-instructions.md \u751F\u6210", status: "skip" });
|
|
2039
1944
|
}
|
|
2040
|
-
logger3.log("\u2705 \
|
|
1945
|
+
logger3.log("\u2705 \u914D\u7F6E\u5B8C\u6210\uFF01");
|
|
2041
1946
|
return {
|
|
2042
1947
|
content: [{
|
|
2043
1948
|
type: "text",
|
|
2044
1949
|
text: JSON.stringify({
|
|
2045
1950
|
success: true,
|
|
2046
|
-
message: "\u{1F389}
|
|
1951
|
+
message: "\u{1F389} \u5DF2\u4E3A\u9879\u76EE\u751F\u6210 copilot-instructions.md",
|
|
2047
1952
|
...results,
|
|
2048
1953
|
nextSteps: [
|
|
2049
|
-
"1. \
|
|
1954
|
+
"1. \u786E\u4FDD MCP \u670D\u52A1\u5668\u5DF2\u542F\u52A8\uFF08\u901A\u8FC7 VS Code \u63D2\u4EF6\u81EA\u52A8\u914D\u7F6E\uFF09",
|
|
2050
1955
|
"2. \u6253\u5F00 GitHub Copilot Chat",
|
|
2051
1956
|
"3. \u5F00\u59CB\u4F7F\u7528\uFF1ACopilot \u4F1A\u81EA\u52A8\u5E94\u7528\u9879\u76EE\u89C4\u8303",
|
|
2052
1957
|
'4. \u9AD8\u7EA7\u7528\u6CD5\uFF1A\u5C1D\u8BD5\u8BF4"\u83B7\u53D6 Vue 3 \u76F8\u5173\u89C4\u8303"'
|
|
@@ -2055,7 +1960,7 @@ async function autoSetup(args) {
|
|
|
2055
1960
|
}]
|
|
2056
1961
|
};
|
|
2057
1962
|
} catch (error) {
|
|
2058
|
-
logger3.error(`\
|
|
1963
|
+
logger3.error(`\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
2059
1964
|
return {
|
|
2060
1965
|
content: [{
|
|
2061
1966
|
type: "text",
|
|
@@ -2930,12 +2835,18 @@ function generateRecommendations(checks) {
|
|
|
2930
2835
|
|
|
2931
2836
|
// src/tools/getCompactStandards.ts
|
|
2932
2837
|
import * as fs9 from "fs";
|
|
2838
|
+
import * as path9 from "path";
|
|
2839
|
+
init_smartAgentMatcher();
|
|
2933
2840
|
async function getCompactStandards(args) {
|
|
2934
2841
|
const logger3 = new ConsoleLogger();
|
|
2935
2842
|
const manager = new StandardsManager();
|
|
2936
2843
|
const mode = args.mode || "key-rules";
|
|
2937
2844
|
try {
|
|
2938
|
-
|
|
2845
|
+
let context = detectContext(args, logger3);
|
|
2846
|
+
if (args.projectPath && fs9.existsSync(args.projectPath)) {
|
|
2847
|
+
const projectContext = await analyzeProject2(args.projectPath, logger3);
|
|
2848
|
+
context = mergeContexts(context, projectContext);
|
|
2849
|
+
}
|
|
2939
2850
|
const standardUris = manager.getRelevantStandards({
|
|
2940
2851
|
fileType: context.fileType,
|
|
2941
2852
|
imports: context.imports,
|
|
@@ -2953,6 +2864,13 @@ async function getCompactStandards(args) {
|
|
|
2953
2864
|
responseContent = buildFullResponse(standardUris, manager);
|
|
2954
2865
|
break;
|
|
2955
2866
|
}
|
|
2867
|
+
if (args.projectPath && context.userConfiguredAgents) {
|
|
2868
|
+
responseContent.projectInfo = {
|
|
2869
|
+
hasUserConfig: true,
|
|
2870
|
+
userAgents: context.userConfiguredAgents,
|
|
2871
|
+
message: "\u2705 \u5DF2\u8BFB\u53D6\u7528\u6237\u914D\u7F6E\u7684 Agents\uFF0C\u5E76\u8865\u5145\u4E86\u7F3A\u5931\u7684\u89C4\u8303"
|
|
2872
|
+
};
|
|
2873
|
+
}
|
|
2956
2874
|
return {
|
|
2957
2875
|
content: [{
|
|
2958
2876
|
type: "text",
|
|
@@ -2971,6 +2889,68 @@ async function getCompactStandards(args) {
|
|
|
2971
2889
|
};
|
|
2972
2890
|
}
|
|
2973
2891
|
}
|
|
2892
|
+
async function analyzeProject2(projectPath, logger3) {
|
|
2893
|
+
var _a, _b;
|
|
2894
|
+
const result = {
|
|
2895
|
+
fileType: "unknown",
|
|
2896
|
+
imports: [],
|
|
2897
|
+
scenario: ""
|
|
2898
|
+
};
|
|
2899
|
+
const instructionsPath = path9.join(projectPath, ".github", "copilot-instructions.md");
|
|
2900
|
+
if (fs9.existsSync(instructionsPath)) {
|
|
2901
|
+
try {
|
|
2902
|
+
const content = fs9.readFileSync(instructionsPath, "utf-8");
|
|
2903
|
+
const agents = extractUserAgents(content);
|
|
2904
|
+
if (agents.length > 0) {
|
|
2905
|
+
result.userConfiguredAgents = agents;
|
|
2906
|
+
logger3.log(`\u2705 \u68C0\u6D4B\u5230\u7528\u6237\u914D\u7F6E\u7684 Agents: ${agents.join(", ")}`);
|
|
2907
|
+
}
|
|
2908
|
+
} catch (error) {
|
|
2909
|
+
logger3.error(`\u8BFB\u53D6\u7528\u6237\u914D\u7F6E\u5931\u8D25: ${error}`);
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
const matcher = new SmartAgentMatcher(logger3);
|
|
2913
|
+
const workspaceFolder = {
|
|
2914
|
+
uri: { fsPath: projectPath },
|
|
2915
|
+
name: path9.basename(projectPath),
|
|
2916
|
+
index: 0
|
|
2917
|
+
};
|
|
2918
|
+
try {
|
|
2919
|
+
const features = await matcher.analyzeProject(workspaceFolder);
|
|
2920
|
+
if ((_a = features.frameworks) == null ? void 0 : _a.includes("vue")) {
|
|
2921
|
+
result.fileType = "vue";
|
|
2922
|
+
result.imports.push("vue");
|
|
2923
|
+
}
|
|
2924
|
+
if ((_b = features.frameworks) == null ? void 0 : _b.includes("flutter")) {
|
|
2925
|
+
result.fileType = "dart";
|
|
2926
|
+
result.imports.push("flutter");
|
|
2927
|
+
}
|
|
2928
|
+
if (features.libraries) {
|
|
2929
|
+
result.imports.push(...features.libraries);
|
|
2930
|
+
}
|
|
2931
|
+
logger3.log(`\u{1F50D} \u9879\u76EE\u6280\u672F\u6808: ${result.imports.join(", ")}`);
|
|
2932
|
+
} catch (error) {
|
|
2933
|
+
logger3.error(`\u9879\u76EE\u5206\u6790\u5931\u8D25: ${error}`);
|
|
2934
|
+
}
|
|
2935
|
+
return result;
|
|
2936
|
+
}
|
|
2937
|
+
function extractUserAgents(content) {
|
|
2938
|
+
const agents = [];
|
|
2939
|
+
const agentIdRegex = /- \*\*Agent ID\*\*:\s*`([^`]+)`/g;
|
|
2940
|
+
let match;
|
|
2941
|
+
while ((match = agentIdRegex.exec(content)) !== null) {
|
|
2942
|
+
agents.push(match[1]);
|
|
2943
|
+
}
|
|
2944
|
+
return agents;
|
|
2945
|
+
}
|
|
2946
|
+
function mergeContexts(fileContext, projectContext) {
|
|
2947
|
+
return {
|
|
2948
|
+
fileType: fileContext.fileType !== "unknown" ? fileContext.fileType : projectContext.fileType,
|
|
2949
|
+
imports: [.../* @__PURE__ */ new Set([...fileContext.imports, ...projectContext.imports])],
|
|
2950
|
+
scenario: fileContext.scenario || projectContext.scenario,
|
|
2951
|
+
userConfiguredAgents: projectContext.userConfiguredAgents
|
|
2952
|
+
};
|
|
2953
|
+
}
|
|
2974
2954
|
function detectContext(args, logger3) {
|
|
2975
2955
|
var _a;
|
|
2976
2956
|
let fileType = "unknown";
|
|
@@ -3029,6 +3009,7 @@ function buildKeyRulesResponse(uris, context, manager) {
|
|
|
3029
3009
|
const keyRules = [];
|
|
3030
3010
|
if (context.fileType === "vue") {
|
|
3031
3011
|
keyRules.push(...getVueKeyRules(context.imports));
|
|
3012
|
+
keyRules.push(...getCssKeyRules());
|
|
3032
3013
|
} else if (context.fileType === "dart") {
|
|
3033
3014
|
keyRules.push(...getFlutterKeyRules());
|
|
3034
3015
|
} else if (context.fileType === "ts" || context.fileType === "tsx") {
|
|
@@ -3043,6 +3024,11 @@ function buildKeyRulesResponse(uris, context, manager) {
|
|
|
3043
3024
|
if (context.imports.includes("pinia")) {
|
|
3044
3025
|
keyRules.push(...getPiniaKeyRules());
|
|
3045
3026
|
}
|
|
3027
|
+
if (context.scenario.includes("\u6837\u5F0F") || context.scenario.includes("CSS")) {
|
|
3028
|
+
if (!keyRules.some((r) => r.includes("CSS \u6837\u5F0F\u89C4\u8303"))) {
|
|
3029
|
+
keyRules.push(...getCssKeyRules());
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3046
3032
|
return {
|
|
3047
3033
|
success: true,
|
|
3048
3034
|
mode: "key-rules",
|
|
@@ -3206,6 +3192,46 @@ async function fetchUser(id: number): Promise<User | null> {
|
|
|
3206
3192
|
\`\`\``
|
|
3207
3193
|
];
|
|
3208
3194
|
}
|
|
3195
|
+
function getCssKeyRules() {
|
|
3196
|
+
return [
|
|
3197
|
+
`## CSS \u6837\u5F0F\u89C4\u8303
|
|
3198
|
+
|
|
3199
|
+
### \u57FA\u672C\u539F\u5219
|
|
3200
|
+
- **\u7981\u6B62\u5185\u8054\u6837\u5F0F** - \u4E0D\u4F7F\u7528 \`style="..."\`\uFF0C\u7528 CSS \u7C7B\u66FF\u4EE3
|
|
3201
|
+
- Vue \u7EC4\u4EF6\u4F7F\u7528 \`<style scoped>\` \u548C\u5D4C\u5957 CSS \u8BED\u6CD5
|
|
3202
|
+
- \u5168\u5C40\u6837\u5F0F\u4F7F\u7528\u6807\u51C6 CSS \u8BED\u6CD5\uFF08\u5E26 \`:\`\u3001\`;\`\u3001\`{}\`\uFF09
|
|
3203
|
+
|
|
3204
|
+
### Element Plus \u7EC4\u4EF6\u6837\u5F0F
|
|
3205
|
+
- \u901A\u7528\u6837\u5F0F\u5FC5\u987B\u901A\u8FC7\u7236\u5BB9\u5668\u9650\u5B9A\u4F5C\u7528\u57DF\uFF08\u5982 \`.el-form-item\`\uFF09
|
|
3206
|
+
- **\u907F\u514D\u76F4\u63A5\u9009\u62E9\u57FA\u7840\u7EC4\u4EF6**\uFF1A\u4E0D\u76F4\u63A5\u9009\u62E9 \`.el-input\`\u3001\`.el-select\` \u7B49\uFF0C\u9632\u6B62\u5F71\u54CD\u590D\u5408\u7EC4\u4EF6\u5185\u90E8\u5E03\u5C40
|
|
3207
|
+
- **\u7981\u6B62\u8BBE\u7F6E __wrapper \u5BBD\u5EA6**\uFF1A\`.el-input__wrapper\`\u3001\`.el-select__wrapper\` \u7B49\u53EA\u80FD\u8BBE\u7F6E\u9AD8\u5EA6\u3001\u5185\u8FB9\u8DDD\u3001\u80CC\u666F\u8272\uFF0C\u4E0D\u80FD\u8BBE\u7F6E\u5BBD\u5EA6\uFF08\u4F1A\u5F71\u54CD\u5206\u9875\u5668\u3001\u65E5\u671F\u9009\u62E9\u5668\u7B49\uFF09
|
|
3208
|
+
|
|
3209
|
+
### \u53EF\u4F7F\u7528\u7684\u5DE5\u5177\u7C7B
|
|
3210
|
+
\`\`\`css
|
|
3211
|
+
/* \u95F4\u8DDD */
|
|
3212
|
+
.ml_8, .mr_8, .mt_8, .mb_8 /* 8px margin */
|
|
3213
|
+
.ml_16, .mr_16, .mt_16, .mb_16 /* 16px margin */
|
|
3214
|
+
|
|
3215
|
+
/* \u5BBD\u5EA6 */
|
|
3216
|
+
.w_100, .w_120, .w_180, .w_200 /* \u56FA\u5B9A\u5BBD\u5EA6 */
|
|
3217
|
+
\`\`\`
|
|
3218
|
+
|
|
3219
|
+
### \u793A\u4F8B
|
|
3220
|
+
\`\`\`vue
|
|
3221
|
+
<style scoped>
|
|
3222
|
+
/* \u2705 \u6B63\u786E\uFF1A\u901A\u8FC7\u7236\u5BB9\u5668\u9650\u5B9A */
|
|
3223
|
+
.my-form :deep(.el-form-item) {
|
|
3224
|
+
margin-bottom: 16px;
|
|
3225
|
+
}
|
|
3226
|
+
|
|
3227
|
+
/* \u274C \u9519\u8BEF\uFF1A\u76F4\u63A5\u8BBE\u7F6E\u5168\u5C40\u7EC4\u4EF6 */
|
|
3228
|
+
.el-input__wrapper {
|
|
3229
|
+
width: 200px; /* \u4F1A\u5F71\u54CD\u5206\u9875\u5668\u7B49\u5176\u4ED6\u7EC4\u4EF6 */
|
|
3230
|
+
}
|
|
3231
|
+
\`\`\`
|
|
3232
|
+
`
|
|
3233
|
+
];
|
|
3234
|
+
}
|
|
3209
3235
|
function getFlutterKeyRules() {
|
|
3210
3236
|
return [
|
|
3211
3237
|
`## Flutter UI \u7CFB\u7EDF\u5173\u952E\u89C4\u5219
|
|
@@ -3260,7 +3286,7 @@ function inferScenario(content, fileType) {
|
|
|
3260
3286
|
|
|
3261
3287
|
// src/tools/getStandardById.ts
|
|
3262
3288
|
import * as fs10 from "fs";
|
|
3263
|
-
import * as
|
|
3289
|
+
import * as path10 from "path";
|
|
3264
3290
|
var STANDARD_DIRS = [
|
|
3265
3291
|
"standards/core",
|
|
3266
3292
|
"standards/frameworks",
|
|
@@ -3355,7 +3381,7 @@ function ensureCache() {
|
|
|
3355
3381
|
standardsCache = /* @__PURE__ */ new Map();
|
|
3356
3382
|
const baseDir = findBaseDir();
|
|
3357
3383
|
for (const dir of STANDARD_DIRS) {
|
|
3358
|
-
const fullDir =
|
|
3384
|
+
const fullDir = path10.join(baseDir, dir);
|
|
3359
3385
|
if (!fs10.existsSync(fullDir)) continue;
|
|
3360
3386
|
scanDirectory(fullDir, standardsCache);
|
|
3361
3387
|
}
|
|
@@ -3363,11 +3389,11 @@ function ensureCache() {
|
|
|
3363
3389
|
function findBaseDir() {
|
|
3364
3390
|
const possiblePaths = [
|
|
3365
3391
|
process.cwd(),
|
|
3366
|
-
|
|
3367
|
-
|
|
3392
|
+
path10.join(process.cwd(), ".."),
|
|
3393
|
+
path10.join(__dirname, "..", "..", "..")
|
|
3368
3394
|
];
|
|
3369
3395
|
for (const p of possiblePaths) {
|
|
3370
|
-
if (fs10.existsSync(
|
|
3396
|
+
if (fs10.existsSync(path10.join(p, "standards"))) {
|
|
3371
3397
|
return p;
|
|
3372
3398
|
}
|
|
3373
3399
|
}
|
|
@@ -3376,12 +3402,12 @@ function findBaseDir() {
|
|
|
3376
3402
|
function scanDirectory(dir, cache) {
|
|
3377
3403
|
const items = fs10.readdirSync(dir);
|
|
3378
3404
|
for (const item of items) {
|
|
3379
|
-
const fullPath =
|
|
3405
|
+
const fullPath = path10.join(dir, item);
|
|
3380
3406
|
const stat = fs10.statSync(fullPath);
|
|
3381
3407
|
if (stat.isDirectory()) {
|
|
3382
3408
|
scanDirectory(fullPath, cache);
|
|
3383
3409
|
} else if (item.endsWith(".md")) {
|
|
3384
|
-
const id =
|
|
3410
|
+
const id = path10.basename(item, ".md");
|
|
3385
3411
|
cache.set(id, fullPath);
|
|
3386
3412
|
}
|
|
3387
3413
|
}
|
|
@@ -3625,9 +3651,9 @@ async function listScenarios() {
|
|
|
3625
3651
|
|
|
3626
3652
|
// src/core/templates/discovery.ts
|
|
3627
3653
|
import * as fs11 from "fs";
|
|
3628
|
-
import * as
|
|
3629
|
-
var TEMPLATES_DIR =
|
|
3630
|
-
|
|
3654
|
+
import * as path11 from "path";
|
|
3655
|
+
var TEMPLATES_DIR = path11.resolve(
|
|
3656
|
+
path11.dirname(new URL(import.meta.url).pathname),
|
|
3631
3657
|
"../../../../templates"
|
|
3632
3658
|
);
|
|
3633
3659
|
var templatesCache = null;
|
|
@@ -3642,9 +3668,9 @@ function scanTemplates(dir, prefix) {
|
|
|
3642
3668
|
for (const entry of entries) {
|
|
3643
3669
|
if (!entry.isDirectory()) continue;
|
|
3644
3670
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
3645
|
-
const fullPath =
|
|
3671
|
+
const fullPath = path11.join(dir, entry.name);
|
|
3646
3672
|
const templateId = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
3647
|
-
const configPath =
|
|
3673
|
+
const configPath = path11.join(fullPath, "_CONFIG.md");
|
|
3648
3674
|
if (fs11.existsSync(configPath)) {
|
|
3649
3675
|
const metadata = parseConfigMd(configPath, templateId, fullPath);
|
|
3650
3676
|
if (metadata) {
|
|
@@ -3706,7 +3732,7 @@ function getTemplateFiles(dir, prefix = "") {
|
|
|
3706
3732
|
continue;
|
|
3707
3733
|
}
|
|
3708
3734
|
if (entry.isDirectory()) {
|
|
3709
|
-
files.push(...getTemplateFiles(
|
|
3735
|
+
files.push(...getTemplateFiles(path11.join(dir, entry.name), relativePath));
|
|
3710
3736
|
} else {
|
|
3711
3737
|
files.push(relativePath);
|
|
3712
3738
|
}
|
|
@@ -3761,8 +3787,8 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3761
3787
|
ensureCache2();
|
|
3762
3788
|
const metadata = templatesCache.get(templateId);
|
|
3763
3789
|
if (!metadata) return null;
|
|
3764
|
-
const templateDir =
|
|
3765
|
-
const configPath =
|
|
3790
|
+
const templateDir = path11.join(TEMPLATES_DIR, templateId);
|
|
3791
|
+
const configPath = path11.join(templateDir, "_CONFIG.md");
|
|
3766
3792
|
const configGuide = fs11.existsSync(configPath) ? fs11.readFileSync(configPath, "utf-8") : "";
|
|
3767
3793
|
const result = {
|
|
3768
3794
|
metadata,
|
|
@@ -3771,7 +3797,7 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3771
3797
|
if (includeFiles) {
|
|
3772
3798
|
result.files = [];
|
|
3773
3799
|
for (const filePath of metadata.files) {
|
|
3774
|
-
const fullPath =
|
|
3800
|
+
const fullPath = path11.join(templateDir, filePath);
|
|
3775
3801
|
if (fs11.existsSync(fullPath)) {
|
|
3776
3802
|
result.files.push({
|
|
3777
3803
|
path: filePath,
|
|
@@ -3786,7 +3812,7 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3786
3812
|
function getTemplateDir(templateId) {
|
|
3787
3813
|
ensureCache2();
|
|
3788
3814
|
if (!templatesCache.has(templateId)) return null;
|
|
3789
|
-
return
|
|
3815
|
+
return path11.join(TEMPLATES_DIR, templateId);
|
|
3790
3816
|
}
|
|
3791
3817
|
function searchTemplates(query) {
|
|
3792
3818
|
const lower = query.toLowerCase();
|
|
@@ -4073,7 +4099,7 @@ function createLogger(name) {
|
|
|
4073
4099
|
|
|
4074
4100
|
// src/core/autoConfig.ts
|
|
4075
4101
|
import * as fs12 from "fs";
|
|
4076
|
-
import * as
|
|
4102
|
+
import * as path12 from "path";
|
|
4077
4103
|
var checkedWorkspaces = /* @__PURE__ */ new Map();
|
|
4078
4104
|
var CACHE_DURATION = 5 * 60 * 1e3;
|
|
4079
4105
|
function ensureWorkspaceConfig(workspacePath) {
|
|
@@ -4091,9 +4117,9 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
4091
4117
|
if (cached && cached.configured && now - cached.timestamp < CACHE_DURATION) {
|
|
4092
4118
|
return result;
|
|
4093
4119
|
}
|
|
4094
|
-
const vscodeDir =
|
|
4095
|
-
const mcpJsonPath =
|
|
4096
|
-
const settingsPath =
|
|
4120
|
+
const vscodeDir = path12.join(workspacePath, ".vscode");
|
|
4121
|
+
const mcpJsonPath = path12.join(vscodeDir, "mcp.json");
|
|
4122
|
+
const settingsPath = path12.join(vscodeDir, "settings.json");
|
|
4097
4123
|
let hasMtaConfig = false;
|
|
4098
4124
|
if (fs12.existsSync(mcpJsonPath)) {
|
|
4099
4125
|
try {
|
|
@@ -4141,7 +4167,7 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
4141
4167
|
fs12.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
4142
4168
|
}
|
|
4143
4169
|
result.wasFixed = true;
|
|
4144
|
-
result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${
|
|
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`;
|
|
4145
4171
|
checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
|
|
4146
4172
|
} catch (error) {
|
|
4147
4173
|
result.message = `\u26A0\uFE0F \u81EA\u52A8\u914D\u7F6E\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -4216,14 +4242,13 @@ var CopilotPromptsMCPServer = class {
|
|
|
4216
4242
|
},
|
|
4217
4243
|
{
|
|
4218
4244
|
name: "auto_setup",
|
|
4219
|
-
description: `\u3010\
|
|
4245
|
+
description: `\u3010\u751F\u6210\u9879\u76EE\u914D\u7F6E\u3011\u4E3A\u9879\u76EE\u751F\u6210 copilot-instructions.md \u914D\u7F6E\u6587\u4EF6\u3002
|
|
4220
4246
|
\u529F\u80FD\uFF1A
|
|
4221
|
-
1. \
|
|
4222
|
-
2. \
|
|
4223
|
-
3. \
|
|
4224
|
-
4. \u4F7F\u7528\u5B8C\u6574\u7684 SmartAgentMatcher \u5339\u914D\u6700\u5408\u9002\u7684 Agents
|
|
4247
|
+
1. \u68C0\u6D4B\u9879\u76EE\u4E2D\u662F\u5426\u5B58\u5728 .github/copilot-instructions.md
|
|
4248
|
+
2. \u5982\u679C\u4E0D\u5B58\u5728\uFF0C\u5219\u81EA\u52A8\u5206\u6790\u9879\u76EE\u6280\u672F\u6808\u5E76\u751F\u6210\u914D\u7F6E\u6587\u4EF6
|
|
4249
|
+
3. \u4F7F\u7528 SmartAgentMatcher \u5339\u914D\u6700\u5408\u9002\u7684 Agents
|
|
4225
4250
|
|
|
4226
|
-
\
|
|
4251
|
+
\u6CE8\u610F\uFF1AMCP \u670D\u52A1\u5668\u7531 VS Code \u63D2\u4EF6\u901A\u8FC7 npm \u5305\u81EA\u52A8\u914D\u7F6E\uFF0C\u6B64\u5DE5\u5177\u53EA\u8D1F\u8D23\u751F\u6210 copilot-instructions.md`,
|
|
4227
4252
|
inputSchema: {
|
|
4228
4253
|
type: "object",
|
|
4229
4254
|
properties: {
|
|
@@ -4356,7 +4381,16 @@ var CopilotPromptsMCPServer = class {
|
|
|
4356
4381
|
},
|
|
4357
4382
|
{
|
|
4358
4383
|
name: "get_compact_standards",
|
|
4359
|
-
description:
|
|
4384
|
+
description: `\u83B7\u53D6\u7F16\u7801\u89C4\u8303\uFF08\u667A\u80FD\u6A21\u5F0F\uFF09
|
|
4385
|
+
\u529F\u80FD\uFF1A
|
|
4386
|
+
1. \u81EA\u52A8\u5206\u6790\u9879\u76EE\u6280\u672F\u6808\uFF08\u901A\u8FC7 projectPath\uFF09
|
|
4387
|
+
2. \u5982\u679C\u5B58\u5728 copilot-instructions.md\uFF0C\u4F18\u5148\u4F7F\u7528\u7528\u6237\u914D\u7F6E\u7684 Agents
|
|
4388
|
+
3. \u667A\u80FD\u8865\u5145\u7528\u6237\u672A\u914D\u7F6E\u7684\u89C4\u8303
|
|
4389
|
+
4. \u652F\u6301 summary/key-rules/full \u4E09\u79CD\u8FD4\u56DE\u6A21\u5F0F
|
|
4390
|
+
|
|
4391
|
+
\u4F7F\u7528\u573A\u666F\uFF1A
|
|
4392
|
+
- @mta \u8C03\u7528\u65F6\uFF0C\u4F20\u5165 projectPath \u83B7\u53D6\u5B8C\u6574\u9879\u76EE\u89C4\u8303
|
|
4393
|
+
- \u7F16\u5199\u4EE3\u7801\u65F6\uFF0C\u4F20\u5165 fileContent \u83B7\u53D6\u6587\u4EF6\u76F8\u5173\u89C4\u8303`,
|
|
4360
4394
|
inputSchema: {
|
|
4361
4395
|
type: "object",
|
|
4362
4396
|
properties: {
|
|
@@ -4368,6 +4402,10 @@ var CopilotPromptsMCPServer = class {
|
|
|
4368
4402
|
type: "string",
|
|
4369
4403
|
description: "\u6587\u4EF6\u5185\u5BB9\uFF08\u53EF\u9009\uFF09"
|
|
4370
4404
|
},
|
|
4405
|
+
projectPath: {
|
|
4406
|
+
type: "string",
|
|
4407
|
+
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"
|
|
4408
|
+
},
|
|
4371
4409
|
scenario: {
|
|
4372
4410
|
type: "string",
|
|
4373
4411
|
description: "\u5F00\u53D1\u573A\u666F\uFF08\u53EF\u9009\uFF09"
|
|
@@ -4375,7 +4413,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4375
4413
|
mode: {
|
|
4376
4414
|
type: "string",
|
|
4377
4415
|
enum: ["summary", "key-rules", "full"],
|
|
4378
|
-
description: "\u8FD4\u56DE\u6A21\u5F0F",
|
|
4416
|
+
description: "\u8FD4\u56DE\u6A21\u5F0F\uFF1Asummary(\u6458\u8981)/key-rules(\u5173\u952E\u89C4\u5219,\u9ED8\u8BA4)/full(\u5B8C\u6574\u5185\u5BB9)",
|
|
4379
4417
|
default: "key-rules"
|
|
4380
4418
|
}
|
|
4381
4419
|
}
|
|
@@ -4621,7 +4659,7 @@ var CopilotPromptsMCPServer = class {
|
|
|
4621
4659
|
``,
|
|
4622
4660
|
`\u{1F4CB} \u53EF\u7528\u5DE5\u5177:`,
|
|
4623
4661
|
` \u2022 analyze_project - \u5206\u6790\u9879\u76EE\u6280\u672F\u6808`,
|
|
4624
|
-
` \u2022 auto_setup - \
|
|
4662
|
+
` \u2022 auto_setup - \u751F\u6210\u9879\u76EE\u914D\u7F6E`,
|
|
4625
4663
|
` \u2022 health_check - \u5065\u5EB7\u68C0\u67E5\u8BCA\u65AD`,
|
|
4626
4664
|
` \u2022 get_compact_standards - \u83B7\u53D6\u7F16\u7801\u89C4\u8303`,
|
|
4627
4665
|
` \u2022 use_preset - \u4F7F\u7528\u9884\u8BBE\u573A\u666F`,
|