mta-mcp 2.3.0 → 2.4.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 +23 -29
- package/dist/index.js +100 -108
- package/dist/index.js.map +1 -1
- package/package.json +5 -7
- package/dist/index.cjs +0 -4784
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// node_modules/tsup/assets/esm_shims.js
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
var getFilename = () => fileURLToPath(import.meta.url);
|
|
7
|
-
var getDirname = () => path.dirname(getFilename());
|
|
8
|
-
var __dirname = /* @__PURE__ */ getDirname();
|
|
9
|
-
|
|
10
3
|
// src/index.ts
|
|
11
4
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
12
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -19,11 +12,11 @@ import {
|
|
|
19
12
|
|
|
20
13
|
// src/tools/analyzeProject.ts
|
|
21
14
|
import * as fs3 from "fs";
|
|
22
|
-
import * as
|
|
15
|
+
import * as path3 from "path";
|
|
23
16
|
|
|
24
17
|
// src/core/smartAgentMatcher.ts
|
|
25
18
|
import * as fs from "fs";
|
|
26
|
-
import * as
|
|
19
|
+
import * as path from "path";
|
|
27
20
|
import glob from "fast-glob";
|
|
28
21
|
var SmartAgentMatcher = class {
|
|
29
22
|
constructor(logger3) {
|
|
@@ -42,7 +35,7 @@ var SmartAgentMatcher = class {
|
|
|
42
35
|
projectType: "unknown"
|
|
43
36
|
};
|
|
44
37
|
const rootPath = workspaceFolder.uri.fsPath;
|
|
45
|
-
const pubspecPath =
|
|
38
|
+
const pubspecPath = path.join(rootPath, "pubspec.yaml");
|
|
46
39
|
if (fs.existsSync(pubspecPath)) {
|
|
47
40
|
const pubspecFeatures = this.analyzePubspecYaml(pubspecPath);
|
|
48
41
|
this.mergeFeatures(features, pubspecFeatures);
|
|
@@ -50,7 +43,7 @@ var SmartAgentMatcher = class {
|
|
|
50
43
|
this.log(`\u2705 \u9879\u76EE\u5206\u6790\u5B8C\u6210: ${features.projectType}`);
|
|
51
44
|
return features;
|
|
52
45
|
}
|
|
53
|
-
const packageJsonPath =
|
|
46
|
+
const packageJsonPath = path.join(rootPath, "package.json");
|
|
54
47
|
if (fs.existsSync(packageJsonPath)) {
|
|
55
48
|
const packageFeatures = this.analyzePackageJson(packageJsonPath);
|
|
56
49
|
this.mergeFeatures(features, packageFeatures);
|
|
@@ -321,7 +314,7 @@ var SmartAgentMatcher = class {
|
|
|
321
314
|
* 解析 Agent 元数据
|
|
322
315
|
*/
|
|
323
316
|
parseAgentMetadata(filePath, content) {
|
|
324
|
-
const id =
|
|
317
|
+
const id = path.basename(filePath, ".agent.md");
|
|
325
318
|
let description = "";
|
|
326
319
|
let tags = [];
|
|
327
320
|
if (content.startsWith("---")) {
|
|
@@ -430,18 +423,18 @@ var SmartAgentMatcher = class {
|
|
|
430
423
|
|
|
431
424
|
// src/core/i18nDetector.ts
|
|
432
425
|
import * as fs2 from "fs";
|
|
433
|
-
import * as
|
|
426
|
+
import * as path2 from "path";
|
|
434
427
|
import glob2 from "fast-glob";
|
|
435
428
|
var I18nDetector = class {
|
|
436
429
|
/**
|
|
437
430
|
* 检测项目的国际化配置
|
|
438
431
|
*/
|
|
439
432
|
static async detect(projectPath) {
|
|
440
|
-
const packageJsonPath =
|
|
433
|
+
const packageJsonPath = path2.join(projectPath, "package.json");
|
|
441
434
|
if (fs2.existsSync(packageJsonPath)) {
|
|
442
435
|
return this.detectFrontendI18n(projectPath, packageJsonPath);
|
|
443
436
|
}
|
|
444
|
-
const pubspecPath =
|
|
437
|
+
const pubspecPath = path2.join(projectPath, "pubspec.yaml");
|
|
445
438
|
if (fs2.existsSync(pubspecPath)) {
|
|
446
439
|
return this.detectFlutterI18n(projectPath, pubspecPath);
|
|
447
440
|
}
|
|
@@ -491,19 +484,19 @@ var I18nDetector = class {
|
|
|
491
484
|
"i18n.config.js"
|
|
492
485
|
];
|
|
493
486
|
for (const configPath of possibleConfigPaths) {
|
|
494
|
-
const fullPath =
|
|
487
|
+
const fullPath = path2.join(projectPath, configPath);
|
|
495
488
|
if (fs2.existsSync(fullPath)) {
|
|
496
489
|
configFiles.push(configPath);
|
|
497
490
|
}
|
|
498
491
|
}
|
|
499
492
|
const possibleMessageDirs = ["src/i18n", "src/locales", "src/lang"];
|
|
500
493
|
for (const dir of possibleMessageDirs) {
|
|
501
|
-
const fullDir =
|
|
494
|
+
const fullDir = path2.join(projectPath, dir);
|
|
502
495
|
if (fs2.existsSync(fullDir)) {
|
|
503
496
|
const files = fs2.readdirSync(fullDir);
|
|
504
497
|
for (const file of files) {
|
|
505
498
|
if (/^(zh|en|ja|ko|fr|de|es).*\.(ts|js|json)$/.test(file)) {
|
|
506
|
-
messageFiles.push(
|
|
499
|
+
messageFiles.push(path2.join(dir, file));
|
|
507
500
|
}
|
|
508
501
|
}
|
|
509
502
|
}
|
|
@@ -536,19 +529,19 @@ var I18nDetector = class {
|
|
|
536
529
|
"src/i18n/config.js"
|
|
537
530
|
];
|
|
538
531
|
for (const configPath of possibleConfigPaths) {
|
|
539
|
-
const fullPath =
|
|
532
|
+
const fullPath = path2.join(projectPath, configPath);
|
|
540
533
|
if (fs2.existsSync(fullPath)) {
|
|
541
534
|
configFiles.push(configPath);
|
|
542
535
|
}
|
|
543
536
|
}
|
|
544
537
|
const possibleMessageDirs = ["public/locales", "src/locales", "src/i18n"];
|
|
545
538
|
for (const dir of possibleMessageDirs) {
|
|
546
|
-
const fullDir =
|
|
539
|
+
const fullDir = path2.join(projectPath, dir);
|
|
547
540
|
if (fs2.existsSync(fullDir)) {
|
|
548
|
-
const pattern =
|
|
541
|
+
const pattern = path2.join(fullDir, "**/*.json");
|
|
549
542
|
try {
|
|
550
543
|
const files = glob2.sync(pattern);
|
|
551
|
-
messageFiles.push(...files.map((f) =>
|
|
544
|
+
messageFiles.push(...files.map((f) => path2.relative(projectPath, f)));
|
|
552
545
|
} catch (e) {
|
|
553
546
|
}
|
|
554
547
|
}
|
|
@@ -594,13 +587,13 @@ var I18nDetector = class {
|
|
|
594
587
|
const messageFiles = [];
|
|
595
588
|
const possibleDirs = ["src/locales", "src/i18n", "src/lang"];
|
|
596
589
|
for (const dir of possibleDirs) {
|
|
597
|
-
const fullDir =
|
|
590
|
+
const fullDir = path2.join(projectPath, dir);
|
|
598
591
|
if (fs2.existsSync(fullDir)) {
|
|
599
592
|
const files = fs2.readdirSync(fullDir);
|
|
600
593
|
for (const file of files) {
|
|
601
594
|
if (/messages?\.(ts|js)$/i.test(file)) {
|
|
602
|
-
messageFiles.push(
|
|
603
|
-
const content = fs2.readFileSync(
|
|
595
|
+
messageFiles.push(path2.join(dir, file));
|
|
596
|
+
const content = fs2.readFileSync(path2.join(fullDir, file), "utf-8");
|
|
604
597
|
if (content.includes("[") && content.includes("],")) {
|
|
605
598
|
return {
|
|
606
599
|
enabled: true,
|
|
@@ -657,7 +650,7 @@ var I18nDetector = class {
|
|
|
657
650
|
const content = fs2.readFileSync(pubspecPath, "utf-8");
|
|
658
651
|
if (content.includes("flutter_localizations")) {
|
|
659
652
|
const messageFiles = [];
|
|
660
|
-
const l10nDir =
|
|
653
|
+
const l10nDir = path2.join(projectPath, "lib", "l10n");
|
|
661
654
|
if (fs2.existsSync(l10nDir)) {
|
|
662
655
|
const files = fs2.readdirSync(l10nDir);
|
|
663
656
|
for (const file of files) {
|
|
@@ -666,7 +659,7 @@ var I18nDetector = class {
|
|
|
666
659
|
}
|
|
667
660
|
}
|
|
668
661
|
}
|
|
669
|
-
const l10nConfigPath =
|
|
662
|
+
const l10nConfigPath = path2.join(projectPath, "l10n.yaml");
|
|
670
663
|
const configFiles = fs2.existsSync(l10nConfigPath) ? ["l10n.yaml"] : [];
|
|
671
664
|
return {
|
|
672
665
|
enabled: true,
|
|
@@ -757,7 +750,7 @@ async function analyzeProject(args) {
|
|
|
757
750
|
const matcher = new SmartAgentMatcher(logger3);
|
|
758
751
|
const workspaceFolder = {
|
|
759
752
|
uri: { fsPath: projectPath },
|
|
760
|
-
name:
|
|
753
|
+
name: path3.basename(projectPath),
|
|
761
754
|
index: 0
|
|
762
755
|
};
|
|
763
756
|
const features = await matcher.analyzeProject(workspaceFolder);
|
|
@@ -769,7 +762,7 @@ async function analyzeProject(args) {
|
|
|
769
762
|
text: JSON.stringify({
|
|
770
763
|
success: true,
|
|
771
764
|
projectPath,
|
|
772
|
-
projectName:
|
|
765
|
+
projectName: path3.basename(projectPath),
|
|
773
766
|
autoDetected: !args.projectPath,
|
|
774
767
|
features: {
|
|
775
768
|
projectType: features.projectType,
|
|
@@ -993,8 +986,8 @@ async function listAvailableAgents() {
|
|
|
993
986
|
|
|
994
987
|
// src/tools/generateConfig.ts
|
|
995
988
|
import * as fs4 from "fs";
|
|
996
|
-
import * as
|
|
997
|
-
import { fileURLToPath
|
|
989
|
+
import * as path4 from "path";
|
|
990
|
+
import { fileURLToPath } from "url";
|
|
998
991
|
|
|
999
992
|
// src/core/codeValidator.ts
|
|
1000
993
|
var CodeValidator = class {
|
|
@@ -1255,8 +1248,8 @@ var CodeValidator = class {
|
|
|
1255
1248
|
};
|
|
1256
1249
|
|
|
1257
1250
|
// src/tools/generateConfig.ts
|
|
1258
|
-
var
|
|
1259
|
-
var __dirname2 =
|
|
1251
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
1252
|
+
var __dirname2 = path4.dirname(__filename);
|
|
1260
1253
|
async function generateConfig(args) {
|
|
1261
1254
|
const logger3 = new ConsoleLogger();
|
|
1262
1255
|
try {
|
|
@@ -1277,7 +1270,7 @@ async function generateConfig(args) {
|
|
|
1277
1270
|
logger3.log("\u6B63\u5728\u5206\u6790\u9879\u76EE\u7279\u5F81...");
|
|
1278
1271
|
const workspaceFolder = {
|
|
1279
1272
|
uri: { fsPath: args.projectPath },
|
|
1280
|
-
name:
|
|
1273
|
+
name: path4.basename(args.projectPath),
|
|
1281
1274
|
index: 0
|
|
1282
1275
|
};
|
|
1283
1276
|
const features = await matcher.analyzeProject(workspaceFolder);
|
|
@@ -1301,14 +1294,14 @@ async function generateConfig(args) {
|
|
|
1301
1294
|
logger3.log(`\u2705 \u4ECE GitHub \u6210\u529F\u52A0\u8F7D ${availableAgents.length} \u4E2A Agents`);
|
|
1302
1295
|
} catch (githubError) {
|
|
1303
1296
|
logger3.log("\u26A0\uFE0F GitHub \u83B7\u53D6\u5931\u8D25\uFF0C\u5C1D\u8BD5\u4ECE\u672C\u5730\u52A0\u8F7D...");
|
|
1304
|
-
const agentsDir =
|
|
1297
|
+
const agentsDir = path4.join(__dirname2, "../../../agents");
|
|
1305
1298
|
if (fs4.existsSync(agentsDir)) {
|
|
1306
1299
|
const agentFiles = fs4.readdirSync(agentsDir);
|
|
1307
1300
|
logger3.log(`\u627E\u5230 ${agentFiles.length} \u4E2A\u672C\u5730\u6587\u4EF6`);
|
|
1308
1301
|
for (const file of agentFiles) {
|
|
1309
1302
|
if (file.endsWith(".agent.md")) {
|
|
1310
1303
|
try {
|
|
1311
|
-
const filePath =
|
|
1304
|
+
const filePath = path4.join(agentsDir, file);
|
|
1312
1305
|
const content2 = fs4.readFileSync(filePath, "utf-8");
|
|
1313
1306
|
const metadata = matcher.parseAgentMetadata(`agents/${file}`, content2);
|
|
1314
1307
|
availableAgents.push(metadata);
|
|
@@ -1341,8 +1334,8 @@ async function generateConfig(args) {
|
|
|
1341
1334
|
logger3.log(`\u2705 \u4ECE GitHub \u52A0\u8F7D\u6210\u529F: ${id}`);
|
|
1342
1335
|
} catch (githubError) {
|
|
1343
1336
|
logger3.log(`GitHub \u83B7\u53D6\u5931\u8D25\uFF0C\u5C1D\u8BD5\u672C\u5730: ${id}`);
|
|
1344
|
-
const agentsDir =
|
|
1345
|
-
const localPath =
|
|
1337
|
+
const agentsDir = path4.join(__dirname2, "../../../agents");
|
|
1338
|
+
const localPath = path4.join(agentsDir, `${id}.agent.md`);
|
|
1346
1339
|
if (fs4.existsSync(localPath)) {
|
|
1347
1340
|
content2 = fs4.readFileSync(localPath, "utf-8");
|
|
1348
1341
|
logger3.log(`\u2705 \u4ECE\u672C\u5730\u52A0\u8F7D\u6210\u529F: ${id}`);
|
|
@@ -1368,8 +1361,8 @@ async function generateConfig(args) {
|
|
|
1368
1361
|
};
|
|
1369
1362
|
}
|
|
1370
1363
|
logger3.log("\u6B63\u5728\u751F\u6210\u914D\u7F6E\u6587\u4EF6...");
|
|
1371
|
-
const githubDir =
|
|
1372
|
-
const configPath =
|
|
1364
|
+
const githubDir = path4.join(args.projectPath, ".github");
|
|
1365
|
+
const configPath = path4.join(githubDir, "copilot-instructions.md");
|
|
1373
1366
|
let existingCustomContent = "";
|
|
1374
1367
|
let existingConfig = "";
|
|
1375
1368
|
if (fs4.existsSync(configPath)) {
|
|
@@ -1405,7 +1398,7 @@ async function generateConfig(args) {
|
|
|
1405
1398
|
|
|
1406
1399
|
`;
|
|
1407
1400
|
}
|
|
1408
|
-
const projectName =
|
|
1401
|
+
const projectName = path4.basename(args.projectPath);
|
|
1409
1402
|
const projectPath = args.projectPath;
|
|
1410
1403
|
content += `<!-- \u{1F3AF} \u4F5C\u7528\u57DF\uFF1A\u6B64\u914D\u7F6E\u4EC5\u9002\u7528\u4E8E\u5F53\u524D\u9879\u76EE -->
|
|
1411
1404
|
`;
|
|
@@ -1498,7 +1491,7 @@ async function generateConfig(args) {
|
|
|
1498
1491
|
`;
|
|
1499
1492
|
if (args.configId) {
|
|
1500
1493
|
try {
|
|
1501
|
-
const configFilePath =
|
|
1494
|
+
const configFilePath = path4.join(__dirname2, "../../../configs", `element-plus-${args.configId}.json`);
|
|
1502
1495
|
if (fs4.existsSync(configFilePath)) {
|
|
1503
1496
|
const configData = JSON.parse(fs4.readFileSync(configFilePath, "utf-8"));
|
|
1504
1497
|
content += `## \u{1F4E6} \u914D\u7F6E\u65B9\u6848
|
|
@@ -1665,7 +1658,7 @@ async function generateConfig(args) {
|
|
|
1665
1658
|
logger3.log("\u2705 \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u901A\u8FC7");
|
|
1666
1659
|
}
|
|
1667
1660
|
fs4.writeFileSync(configPath, content, "utf-8");
|
|
1668
|
-
const gitignorePath =
|
|
1661
|
+
const gitignorePath = path4.join(args.projectPath, ".gitignore");
|
|
1669
1662
|
if (fs4.existsSync(gitignorePath)) {
|
|
1670
1663
|
let gitignoreContent = fs4.readFileSync(gitignorePath, "utf-8");
|
|
1671
1664
|
if (!gitignoreContent.includes(".github/copilot-instructions.md")) {
|
|
@@ -1704,7 +1697,7 @@ async function generateConfig(args) {
|
|
|
1704
1697
|
|
|
1705
1698
|
// src/tools/autoSetup.ts
|
|
1706
1699
|
import * as fs5 from "fs";
|
|
1707
|
-
import * as
|
|
1700
|
+
import * as path5 from "path";
|
|
1708
1701
|
async function autoSetup(args) {
|
|
1709
1702
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1710
1703
|
const logger3 = new ConsoleLogger();
|
|
@@ -1726,7 +1719,7 @@ async function autoSetup(args) {
|
|
|
1726
1719
|
warnings: []
|
|
1727
1720
|
};
|
|
1728
1721
|
logger3.log("\u{1F680} \u5F00\u59CB\u81EA\u52A8\u914D\u7F6E MCP \u670D\u52A1\u5668...");
|
|
1729
|
-
const vscodeDir =
|
|
1722
|
+
const vscodeDir = path5.join(workspacePath, ".vscode");
|
|
1730
1723
|
if (!fs5.existsSync(vscodeDir)) {
|
|
1731
1724
|
fs5.mkdirSync(vscodeDir, { recursive: true });
|
|
1732
1725
|
results.steps.push({ step: "\u521B\u5EFA .vscode \u76EE\u5F55", status: "success" });
|
|
@@ -1735,9 +1728,9 @@ async function autoSetup(args) {
|
|
|
1735
1728
|
}
|
|
1736
1729
|
let mcpServerPath = "";
|
|
1737
1730
|
const possiblePaths = [
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1731
|
+
path5.join(workspacePath, "mcp-server/build/index.js"),
|
|
1732
|
+
path5.join(workspacePath, "../copilot-prompts/mcp-server/build/index.js"),
|
|
1733
|
+
path5.join(workspacePath, "copilot-prompts/mcp-server/build/index.js")
|
|
1741
1734
|
];
|
|
1742
1735
|
for (const p of possiblePaths) {
|
|
1743
1736
|
if (fs5.existsSync(p)) {
|
|
@@ -1746,7 +1739,7 @@ async function autoSetup(args) {
|
|
|
1746
1739
|
}
|
|
1747
1740
|
}
|
|
1748
1741
|
if (!mcpServerPath) {
|
|
1749
|
-
const srcPath =
|
|
1742
|
+
const srcPath = path5.join(workspacePath, "mcp-server/src/index.ts");
|
|
1750
1743
|
if (fs5.existsSync(srcPath)) {
|
|
1751
1744
|
results.warnings.push("\u68C0\u6D4B\u5230\u5F00\u53D1\u6A21\u5F0F\uFF0C\u8BF7\u5148\u8FD0\u884C npm run build \u7F16\u8BD1\u670D\u52A1\u5668");
|
|
1752
1745
|
mcpServerPath = "${workspaceFolder}/mcp-server/build/index.js";
|
|
@@ -1762,13 +1755,13 @@ async function autoSetup(args) {
|
|
|
1762
1755
|
};
|
|
1763
1756
|
}
|
|
1764
1757
|
}
|
|
1765
|
-
const relativePath = mcpServerPath.startsWith(workspacePath) ? "${workspaceFolder}/" +
|
|
1758
|
+
const relativePath = mcpServerPath.startsWith(workspacePath) ? "${workspaceFolder}/" + path5.relative(workspacePath, mcpServerPath) : mcpServerPath;
|
|
1766
1759
|
results.steps.push({
|
|
1767
1760
|
step: "\u68C0\u6D4B MCP \u670D\u52A1\u5668\u8DEF\u5F84",
|
|
1768
1761
|
status: "success",
|
|
1769
1762
|
detail: relativePath
|
|
1770
1763
|
});
|
|
1771
|
-
const mcpJsonPath =
|
|
1764
|
+
const mcpJsonPath = path5.join(vscodeDir, "mcp.json");
|
|
1772
1765
|
const mcpConfig = {
|
|
1773
1766
|
servers: {
|
|
1774
1767
|
"copilot-prompts": {
|
|
@@ -1811,7 +1804,7 @@ async function autoSetup(args) {
|
|
|
1811
1804
|
fs5.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
1812
1805
|
results.steps.push({ step: "\u521B\u5EFA mcp.json", status: "success" });
|
|
1813
1806
|
}
|
|
1814
|
-
const settingsJsonPath =
|
|
1807
|
+
const settingsJsonPath = path5.join(vscodeDir, "settings.json");
|
|
1815
1808
|
const mcpSettings = {
|
|
1816
1809
|
"github.copilot.chat.mcp.enabled": true,
|
|
1817
1810
|
"github.copilot.chat.mcp.configFile": "${workspaceFolder}/.vscode/mcp.json",
|
|
@@ -1831,7 +1824,7 @@ async function autoSetup(args) {
|
|
|
1831
1824
|
fs5.writeFileSync(settingsJsonPath, JSON.stringify(mcpSettings, null, 2) + "\n");
|
|
1832
1825
|
results.steps.push({ step: "\u521B\u5EFA settings.json", status: "success" });
|
|
1833
1826
|
}
|
|
1834
|
-
const extensionsJsonPath =
|
|
1827
|
+
const extensionsJsonPath = path5.join(vscodeDir, "extensions.json");
|
|
1835
1828
|
const recommendedExtensions = {
|
|
1836
1829
|
recommendations: [
|
|
1837
1830
|
"github.copilot",
|
|
@@ -1844,7 +1837,7 @@ async function autoSetup(args) {
|
|
|
1844
1837
|
} else {
|
|
1845
1838
|
results.steps.push({ step: "extensions.json \u5DF2\u5B58\u5728", status: "skip" });
|
|
1846
1839
|
}
|
|
1847
|
-
const gitignorePath =
|
|
1840
|
+
const gitignorePath = path5.join(workspacePath, ".gitignore");
|
|
1848
1841
|
if (fs5.existsSync(gitignorePath)) {
|
|
1849
1842
|
const gitignoreContent = fs5.readFileSync(gitignorePath, "utf-8");
|
|
1850
1843
|
if (!gitignoreContent.includes(".vscode/mcp.json")) {
|
|
@@ -1953,10 +1946,10 @@ import * as fs8 from "fs";
|
|
|
1953
1946
|
|
|
1954
1947
|
// src/core/standardsManager.ts
|
|
1955
1948
|
import * as fs6 from "fs";
|
|
1956
|
-
import * as
|
|
1957
|
-
import { fileURLToPath as
|
|
1958
|
-
var
|
|
1959
|
-
var __dirname3 =
|
|
1949
|
+
import * as path6 from "path";
|
|
1950
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1951
|
+
var __filename2 = fileURLToPath2(import.meta.url);
|
|
1952
|
+
var __dirname3 = path6.dirname(__filename2);
|
|
1960
1953
|
var StandardsManager = class {
|
|
1961
1954
|
constructor() {
|
|
1962
1955
|
// v1.2.0: 底层必须加载的核心规范
|
|
@@ -1989,8 +1982,8 @@ var StandardsManager = class {
|
|
|
1989
1982
|
averageResponseTime: 0,
|
|
1990
1983
|
totalTokensSaved: 0
|
|
1991
1984
|
};
|
|
1992
|
-
const devPath =
|
|
1993
|
-
const npmPath =
|
|
1985
|
+
const devPath = path6.resolve(__dirname3, "../../../standards");
|
|
1986
|
+
const npmPath = path6.resolve(__dirname3, "../../standards");
|
|
1994
1987
|
this.standardsPath = fs6.existsSync(npmPath) ? npmPath : devPath;
|
|
1995
1988
|
}
|
|
1996
1989
|
/**
|
|
@@ -2005,7 +1998,7 @@ var StandardsManager = class {
|
|
|
2005
1998
|
{ dir: "patterns", name: "\u8BBE\u8BA1\u6A21\u5F0F" }
|
|
2006
1999
|
];
|
|
2007
2000
|
categories.forEach(({ dir, name: categoryName }) => {
|
|
2008
|
-
const categoryPath =
|
|
2001
|
+
const categoryPath = path6.join(this.standardsPath, dir);
|
|
2009
2002
|
if (!fs6.existsSync(categoryPath)) {
|
|
2010
2003
|
return;
|
|
2011
2004
|
}
|
|
@@ -2039,7 +2032,7 @@ var StandardsManager = class {
|
|
|
2039
2032
|
throw new Error(`Invalid standards URI: ${uri}`);
|
|
2040
2033
|
}
|
|
2041
2034
|
const [, category, standardId] = match;
|
|
2042
|
-
const filePath =
|
|
2035
|
+
const filePath = path6.join(this.standardsPath, category, `${standardId}.md`);
|
|
2043
2036
|
if (!fs6.existsSync(filePath)) {
|
|
2044
2037
|
throw new Error(`Standard not found: ${uri}`);
|
|
2045
2038
|
}
|
|
@@ -2441,7 +2434,7 @@ ${content}
|
|
|
2441
2434
|
|
|
2442
2435
|
// src/core/autoInitializer.ts
|
|
2443
2436
|
import * as fs7 from "fs";
|
|
2444
|
-
import * as
|
|
2437
|
+
import * as path7 from "path";
|
|
2445
2438
|
var AutoInitializer = class {
|
|
2446
2439
|
constructor(logger3) {
|
|
2447
2440
|
this.logger = logger3;
|
|
@@ -2466,17 +2459,17 @@ var AutoInitializer = class {
|
|
|
2466
2459
|
return {
|
|
2467
2460
|
needsInit: false,
|
|
2468
2461
|
initialized: true,
|
|
2469
|
-
message: `\u9879\u76EE\u5DF2\u914D\u7F6E: ${
|
|
2462
|
+
message: `\u9879\u76EE\u5DF2\u914D\u7F6E: ${path7.basename(projectPath)}`
|
|
2470
2463
|
};
|
|
2471
2464
|
}
|
|
2472
|
-
const configPath =
|
|
2465
|
+
const configPath = path7.join(projectPath, ".github", "copilot-instructions.md");
|
|
2473
2466
|
const hasConfig = fs7.existsSync(configPath);
|
|
2474
2467
|
if (hasConfig) {
|
|
2475
2468
|
this.initialized.set(projectPath, true);
|
|
2476
2469
|
return {
|
|
2477
2470
|
needsInit: false,
|
|
2478
2471
|
initialized: true,
|
|
2479
|
-
message: `\u9879\u76EE\u5DF2\u6709\u914D\u7F6E: ${
|
|
2472
|
+
message: `\u9879\u76EE\u5DF2\u6709\u914D\u7F6E: ${path7.basename(projectPath)}`
|
|
2480
2473
|
};
|
|
2481
2474
|
}
|
|
2482
2475
|
this.log(`\u{1F50D} \u68C0\u6D4B\u5230\u9879\u76EE\u672A\u914D\u7F6E\uFF0C\u5F00\u59CB\u81EA\u52A8\u5206\u6790\u548C\u751F\u6210\u914D\u7F6E...`);
|
|
@@ -2527,8 +2520,8 @@ var AutoInitializer = class {
|
|
|
2527
2520
|
return cwd;
|
|
2528
2521
|
}
|
|
2529
2522
|
const possiblePaths = [
|
|
2530
|
-
|
|
2531
|
-
|
|
2523
|
+
path7.join(cwd, ".."),
|
|
2524
|
+
path7.join(cwd, "../..")
|
|
2532
2525
|
];
|
|
2533
2526
|
for (const possiblePath of possiblePaths) {
|
|
2534
2527
|
if (this.isValidProject(possiblePath)) {
|
|
@@ -2553,7 +2546,7 @@ var AutoInitializer = class {
|
|
|
2553
2546
|
".git"
|
|
2554
2547
|
];
|
|
2555
2548
|
return markers.some(
|
|
2556
|
-
(marker) => fs7.existsSync(
|
|
2549
|
+
(marker) => fs7.existsSync(path7.join(dirPath, marker))
|
|
2557
2550
|
);
|
|
2558
2551
|
}
|
|
2559
2552
|
/**
|
|
@@ -2891,14 +2884,14 @@ async function listPresets() {
|
|
|
2891
2884
|
|
|
2892
2885
|
// src/tools/healthCheck.ts
|
|
2893
2886
|
import * as fs9 from "fs";
|
|
2894
|
-
import * as
|
|
2895
|
-
import { fileURLToPath as
|
|
2896
|
-
var
|
|
2897
|
-
var __dirname4 =
|
|
2887
|
+
import * as path8 from "path";
|
|
2888
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
2889
|
+
var __filename3 = fileURLToPath3(import.meta.url);
|
|
2890
|
+
var __dirname4 = path8.dirname(__filename3);
|
|
2898
2891
|
async function healthCheck(args) {
|
|
2899
|
-
var _a, _b, _c, _d
|
|
2892
|
+
var _a, _b, _c, _d;
|
|
2900
2893
|
const logger3 = new ConsoleLogger();
|
|
2901
|
-
const verbose =
|
|
2894
|
+
const verbose = args.verbose ?? false;
|
|
2902
2895
|
try {
|
|
2903
2896
|
const checks = {
|
|
2904
2897
|
server: { status: "unknown", details: [] },
|
|
@@ -2919,25 +2912,25 @@ async function healthCheck(args) {
|
|
|
2919
2912
|
}
|
|
2920
2913
|
logger3.log("\u{1F50D} \u68C0\u67E5\u914D\u7F6E\u6587\u4EF6...");
|
|
2921
2914
|
const workspacePath = args.workspacePath || process.cwd();
|
|
2922
|
-
const vscodeDir =
|
|
2915
|
+
const vscodeDir = path8.join(workspacePath, ".vscode");
|
|
2923
2916
|
if (fs9.existsSync(vscodeDir)) {
|
|
2924
2917
|
checks.workspace.status = "healthy";
|
|
2925
2918
|
checks.workspace.details.push(`\u2705 \u5DE5\u4F5C\u533A\u8DEF\u5F84: ${workspacePath}`);
|
|
2926
|
-
const mcpJsonPath =
|
|
2919
|
+
const mcpJsonPath = path8.join(vscodeDir, "mcp.json");
|
|
2927
2920
|
if (fs9.existsSync(mcpJsonPath)) {
|
|
2928
2921
|
try {
|
|
2929
2922
|
const config = JSON.parse(fs9.readFileSync(mcpJsonPath, "utf-8"));
|
|
2930
|
-
const hasNewFormat = (
|
|
2931
|
-
const hasOldFormat = (
|
|
2923
|
+
const hasNewFormat = (_a = config.servers) == null ? void 0 : _a["copilot-prompts"];
|
|
2924
|
+
const hasOldFormat = (_b = config.mcpServers) == null ? void 0 : _b["copilot-prompts"];
|
|
2932
2925
|
if (hasNewFormat) {
|
|
2933
2926
|
checks.configuration.status = "healthy";
|
|
2934
2927
|
checks.configuration.details.push("\u2705 mcp.json \u914D\u7F6E\u6B63\u786E (\u4F7F\u7528\u65B0\u683C\u5F0F)");
|
|
2935
2928
|
const serverConfig = config.servers["copilot-prompts"];
|
|
2936
2929
|
if (verbose) {
|
|
2937
2930
|
checks.configuration.details.push(` Command: ${serverConfig.command}`);
|
|
2938
|
-
checks.configuration.details.push(` Args: ${(
|
|
2939
|
-
checks.configuration.details.push(` AutoStart: ${
|
|
2940
|
-
checks.configuration.details.push(` Env: ${JSON.stringify(
|
|
2931
|
+
checks.configuration.details.push(` Args: ${(_c = serverConfig.args) == null ? void 0 : _c.join(" ")}`);
|
|
2932
|
+
checks.configuration.details.push(` AutoStart: ${serverConfig.autoStart ?? "undefined"}`);
|
|
2933
|
+
checks.configuration.details.push(` Env: ${JSON.stringify(serverConfig.env ?? {})}`);
|
|
2941
2934
|
}
|
|
2942
2935
|
if (!serverConfig.env) {
|
|
2943
2936
|
checks.configuration.details.push('\u{1F4A1} \u5EFA\u8BAE: \u6DFB\u52A0 "env": {} \u5B57\u6BB5');
|
|
@@ -2952,7 +2945,7 @@ async function healthCheck(args) {
|
|
|
2952
2945
|
if (verbose) {
|
|
2953
2946
|
const serverConfig = config.mcpServers["copilot-prompts"];
|
|
2954
2947
|
checks.configuration.details.push(` Command: ${serverConfig.command}`);
|
|
2955
|
-
checks.configuration.details.push(` Args: ${(
|
|
2948
|
+
checks.configuration.details.push(` Args: ${(_d = serverConfig.args) == null ? void 0 : _d.join(" ")}`);
|
|
2956
2949
|
}
|
|
2957
2950
|
} else {
|
|
2958
2951
|
checks.configuration.status = "warning";
|
|
@@ -2969,7 +2962,7 @@ async function healthCheck(args) {
|
|
|
2969
2962
|
checks.configuration.details.push("\u26A0\uFE0F mcp.json \u4E0D\u5B58\u5728");
|
|
2970
2963
|
checks.configuration.details.push("\u{1F4A1} \u5EFA\u8BAE: \u8FD0\u884C auto_setup \u5DE5\u5177\u81EA\u52A8\u914D\u7F6E");
|
|
2971
2964
|
}
|
|
2972
|
-
const settingsPath =
|
|
2965
|
+
const settingsPath = path8.join(vscodeDir, "settings.json");
|
|
2973
2966
|
if (fs9.existsSync(settingsPath)) {
|
|
2974
2967
|
try {
|
|
2975
2968
|
const settings = JSON.parse(fs9.readFileSync(settingsPath, "utf-8"));
|
|
@@ -2987,8 +2980,8 @@ async function healthCheck(args) {
|
|
|
2987
2980
|
checks.workspace.details.push("\u274C .vscode \u76EE\u5F55\u4E0D\u5B58\u5728");
|
|
2988
2981
|
}
|
|
2989
2982
|
logger3.log("\u{1F50D} \u68C0\u67E5\u4F9D\u8D56...");
|
|
2990
|
-
const serverRoot =
|
|
2991
|
-
const packageJsonPath =
|
|
2983
|
+
const serverRoot = path8.resolve(__dirname4, "../..");
|
|
2984
|
+
const packageJsonPath = path8.join(serverRoot, "package.json");
|
|
2992
2985
|
if (fs9.existsSync(packageJsonPath)) {
|
|
2993
2986
|
try {
|
|
2994
2987
|
const pkg = JSON.parse(fs9.readFileSync(packageJsonPath, "utf-8"));
|
|
@@ -3015,12 +3008,12 @@ async function healthCheck(args) {
|
|
|
3015
3008
|
}
|
|
3016
3009
|
}
|
|
3017
3010
|
logger3.log("\u{1F50D} \u68C0\u67E5\u89C4\u8303\u6587\u4EF6...");
|
|
3018
|
-
const standardsDir =
|
|
3011
|
+
const standardsDir = path8.join(serverRoot, "standards");
|
|
3019
3012
|
if (fs9.existsSync(standardsDir)) {
|
|
3020
3013
|
const categories = ["core", "frameworks", "libraries", "patterns"];
|
|
3021
3014
|
const foundStandards = [];
|
|
3022
3015
|
for (const category of categories) {
|
|
3023
|
-
const categoryPath =
|
|
3016
|
+
const categoryPath = path8.join(standardsDir, category);
|
|
3024
3017
|
if (fs9.existsSync(categoryPath)) {
|
|
3025
3018
|
const files = fs9.readdirSync(categoryPath).filter((f) => f.endsWith(".md"));
|
|
3026
3019
|
foundStandards.push(...files.map((f) => `${category}/${f}`));
|
|
@@ -3430,7 +3423,7 @@ function inferScenario2(content, fileType) {
|
|
|
3430
3423
|
|
|
3431
3424
|
// src/tools/getStandardById.ts
|
|
3432
3425
|
import * as fs11 from "fs";
|
|
3433
|
-
import * as
|
|
3426
|
+
import * as path9 from "path";
|
|
3434
3427
|
var STANDARD_DIRS = [
|
|
3435
3428
|
"standards/core",
|
|
3436
3429
|
"standards/frameworks",
|
|
@@ -3525,7 +3518,7 @@ function ensureCache() {
|
|
|
3525
3518
|
standardsCache = /* @__PURE__ */ new Map();
|
|
3526
3519
|
const baseDir = findBaseDir();
|
|
3527
3520
|
for (const dir of STANDARD_DIRS) {
|
|
3528
|
-
const fullDir =
|
|
3521
|
+
const fullDir = path9.join(baseDir, dir);
|
|
3529
3522
|
if (!fs11.existsSync(fullDir)) continue;
|
|
3530
3523
|
scanDirectory(fullDir, standardsCache);
|
|
3531
3524
|
}
|
|
@@ -3533,11 +3526,11 @@ function ensureCache() {
|
|
|
3533
3526
|
function findBaseDir() {
|
|
3534
3527
|
const possiblePaths = [
|
|
3535
3528
|
process.cwd(),
|
|
3536
|
-
|
|
3537
|
-
|
|
3529
|
+
path9.join(process.cwd(), ".."),
|
|
3530
|
+
path9.join(__dirname, "..", "..", "..")
|
|
3538
3531
|
];
|
|
3539
3532
|
for (const p of possiblePaths) {
|
|
3540
|
-
if (fs11.existsSync(
|
|
3533
|
+
if (fs11.existsSync(path9.join(p, "standards"))) {
|
|
3541
3534
|
return p;
|
|
3542
3535
|
}
|
|
3543
3536
|
}
|
|
@@ -3546,12 +3539,12 @@ function findBaseDir() {
|
|
|
3546
3539
|
function scanDirectory(dir, cache) {
|
|
3547
3540
|
const items = fs11.readdirSync(dir);
|
|
3548
3541
|
for (const item of items) {
|
|
3549
|
-
const fullPath =
|
|
3542
|
+
const fullPath = path9.join(dir, item);
|
|
3550
3543
|
const stat = fs11.statSync(fullPath);
|
|
3551
3544
|
if (stat.isDirectory()) {
|
|
3552
3545
|
scanDirectory(fullPath, cache);
|
|
3553
3546
|
} else if (item.endsWith(".md")) {
|
|
3554
|
-
const id =
|
|
3547
|
+
const id = path9.basename(item, ".md");
|
|
3555
3548
|
cache.set(id, fullPath);
|
|
3556
3549
|
}
|
|
3557
3550
|
}
|
|
@@ -3795,9 +3788,9 @@ async function listScenarios() {
|
|
|
3795
3788
|
|
|
3796
3789
|
// src/core/templates/discovery.ts
|
|
3797
3790
|
import * as fs12 from "fs";
|
|
3798
|
-
import * as
|
|
3799
|
-
var TEMPLATES_DIR =
|
|
3800
|
-
|
|
3791
|
+
import * as path10 from "path";
|
|
3792
|
+
var TEMPLATES_DIR = path10.resolve(
|
|
3793
|
+
path10.dirname(new URL(import.meta.url).pathname),
|
|
3801
3794
|
"../../../../templates"
|
|
3802
3795
|
);
|
|
3803
3796
|
var templatesCache = null;
|
|
@@ -3812,9 +3805,9 @@ function scanTemplates(dir, prefix) {
|
|
|
3812
3805
|
for (const entry of entries) {
|
|
3813
3806
|
if (!entry.isDirectory()) continue;
|
|
3814
3807
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
3815
|
-
const fullPath =
|
|
3808
|
+
const fullPath = path10.join(dir, entry.name);
|
|
3816
3809
|
const templateId = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
3817
|
-
const configPath =
|
|
3810
|
+
const configPath = path10.join(fullPath, "_CONFIG.md");
|
|
3818
3811
|
if (fs12.existsSync(configPath)) {
|
|
3819
3812
|
const metadata = parseConfigMd(configPath, templateId, fullPath);
|
|
3820
3813
|
if (metadata) {
|
|
@@ -3876,7 +3869,7 @@ function getTemplateFiles(dir, prefix = "") {
|
|
|
3876
3869
|
continue;
|
|
3877
3870
|
}
|
|
3878
3871
|
if (entry.isDirectory()) {
|
|
3879
|
-
files.push(...getTemplateFiles(
|
|
3872
|
+
files.push(...getTemplateFiles(path10.join(dir, entry.name), relativePath));
|
|
3880
3873
|
} else {
|
|
3881
3874
|
files.push(relativePath);
|
|
3882
3875
|
}
|
|
@@ -3931,8 +3924,8 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3931
3924
|
ensureCache2();
|
|
3932
3925
|
const metadata = templatesCache.get(templateId);
|
|
3933
3926
|
if (!metadata) return null;
|
|
3934
|
-
const templateDir =
|
|
3935
|
-
const configPath =
|
|
3927
|
+
const templateDir = path10.join(TEMPLATES_DIR, templateId);
|
|
3928
|
+
const configPath = path10.join(templateDir, "_CONFIG.md");
|
|
3936
3929
|
const configGuide = fs12.existsSync(configPath) ? fs12.readFileSync(configPath, "utf-8") : "";
|
|
3937
3930
|
const result = {
|
|
3938
3931
|
metadata,
|
|
@@ -3941,7 +3934,7 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3941
3934
|
if (includeFiles) {
|
|
3942
3935
|
result.files = [];
|
|
3943
3936
|
for (const filePath of metadata.files) {
|
|
3944
|
-
const fullPath =
|
|
3937
|
+
const fullPath = path10.join(templateDir, filePath);
|
|
3945
3938
|
if (fs12.existsSync(fullPath)) {
|
|
3946
3939
|
result.files.push({
|
|
3947
3940
|
path: filePath,
|
|
@@ -3956,7 +3949,7 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3956
3949
|
function getTemplateDir(templateId) {
|
|
3957
3950
|
ensureCache2();
|
|
3958
3951
|
if (!templatesCache.has(templateId)) return null;
|
|
3959
|
-
return
|
|
3952
|
+
return path10.join(TEMPLATES_DIR, templateId);
|
|
3960
3953
|
}
|
|
3961
3954
|
function searchTemplates(query) {
|
|
3962
3955
|
const lower = query.toLowerCase();
|
|
@@ -4015,10 +4008,9 @@ async function listTemplates(args) {
|
|
|
4015
4008
|
|
|
4016
4009
|
// src/tools/getTemplate.ts
|
|
4017
4010
|
async function getTemplate(args) {
|
|
4018
|
-
var _a;
|
|
4019
4011
|
const logger3 = new ConsoleLogger();
|
|
4020
4012
|
try {
|
|
4021
|
-
const result = getTemplateById(args.id,
|
|
4013
|
+
const result = getTemplateById(args.id, args.includeFiles ?? false);
|
|
4022
4014
|
if (!result) {
|
|
4023
4015
|
return {
|
|
4024
4016
|
content: [{
|
|
@@ -4243,7 +4235,7 @@ function createLogger(name) {
|
|
|
4243
4235
|
}
|
|
4244
4236
|
|
|
4245
4237
|
// src/index.ts
|
|
4246
|
-
var SERVER_VERSION = "2.
|
|
4238
|
+
var SERVER_VERSION = "2.4.0";
|
|
4247
4239
|
var logger2 = createLogger("Server");
|
|
4248
4240
|
var CopilotPromptsMCPServer = class {
|
|
4249
4241
|
constructor() {
|