mta-mcp 2.14.0 → 2.16.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/agents/_TEMPLATE.md +153 -0
- package/agents/flutter.agent.md +118 -155
- package/agents/i18n.agent.md +50 -105
- package/agents/logicflow.agent.md +55 -1525
- package/agents/vue3.agent.md +84 -248
- package/agents/wechat-miniprogram.agent.md +48 -950
- package/dist/index.js +391 -443
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/standards/core/mandatory-rules.md +103 -0
- package/standards/frameworks/flutter.md +78 -0
- package/standards/libraries/logicflow.md +1007 -0
- package/standards/troubleshooting-cases/flutter/textfield-vertical-centering.md +107 -0
- package/standards/workflows/design-restoration-guide.md +164 -0
- package/standards/workflows/problem-diagnosis.md +68 -0
- package/standards/workflows/textfield-centering-guide.md +157 -0
- package/templates/config-templates/agents-section.md +9 -0
- package/templates/config-templates/custom-section.md +6 -0
- package/templates/config-templates/header.md +29 -0
- package/templates/config-templates/workflow-minimal.md +44 -0
package/dist/index.js
CHANGED
|
@@ -445,13 +445,13 @@ function getResourceLoader(logger4) {
|
|
|
445
445
|
}
|
|
446
446
|
return resourceLoaderInstance;
|
|
447
447
|
}
|
|
448
|
-
var __filename,
|
|
448
|
+
var __filename, __dirname, ResourceLoader, resourceLoaderInstance;
|
|
449
449
|
var init_resourceLoader = __esm({
|
|
450
450
|
"src/core/resourceLoader.ts"() {
|
|
451
451
|
"use strict";
|
|
452
452
|
init_smartAgentMatcher();
|
|
453
453
|
__filename = fileURLToPath(import.meta.url);
|
|
454
|
-
|
|
454
|
+
__dirname = path4.dirname(__filename);
|
|
455
455
|
ResourceLoader = class {
|
|
456
456
|
constructor(logger4) {
|
|
457
457
|
this.initialized = false;
|
|
@@ -464,7 +464,7 @@ var init_resourceLoader = __esm({
|
|
|
464
464
|
* 支持多种运行环境
|
|
465
465
|
*/
|
|
466
466
|
detectPackageRoot() {
|
|
467
|
-
const rootFromDist = path4.resolve(
|
|
467
|
+
const rootFromDist = path4.resolve(__dirname, "..");
|
|
468
468
|
const packageJsonPath = path4.join(rootFromDist, "package.json");
|
|
469
469
|
if (fs4.existsSync(packageJsonPath)) {
|
|
470
470
|
try {
|
|
@@ -516,7 +516,7 @@ var init_resourceLoader = __esm({
|
|
|
516
516
|
if (!fs4.existsSync(agentsDir)) {
|
|
517
517
|
this.error(`Agents \u76EE\u5F55\u4E0D\u5B58\u5728: ${agentsDir}`);
|
|
518
518
|
this.error(`\u5305\u6839\u76EE\u5F55: ${this.packageRoot}`);
|
|
519
|
-
this.error(`\u5F53\u524D __dirname: ${
|
|
519
|
+
this.error(`\u5F53\u524D __dirname: ${__dirname}`);
|
|
520
520
|
return agents;
|
|
521
521
|
}
|
|
522
522
|
const matcher = new SmartAgentMatcher(this.logger);
|
|
@@ -1117,7 +1117,7 @@ import * as fs5 from "fs";
|
|
|
1117
1117
|
import * as path5 from "path";
|
|
1118
1118
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1119
1119
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
1120
|
-
var
|
|
1120
|
+
var __dirname2 = path5.dirname(__filename2);
|
|
1121
1121
|
function parseAgentFile(filePath) {
|
|
1122
1122
|
try {
|
|
1123
1123
|
const content = fs5.readFileSync(filePath, "utf-8");
|
|
@@ -1157,7 +1157,7 @@ function parseAgentFile(filePath) {
|
|
|
1157
1157
|
}
|
|
1158
1158
|
function listAvailableAgents() {
|
|
1159
1159
|
try {
|
|
1160
|
-
const projectRoot = path5.resolve(
|
|
1160
|
+
const projectRoot = path5.resolve(__dirname2, "../..");
|
|
1161
1161
|
const agentsDir = path5.join(projectRoot, "agents");
|
|
1162
1162
|
if (!fs5.existsSync(agentsDir)) {
|
|
1163
1163
|
throw new Error(`Agents \u76EE\u5F55\u4E0D\u5B58\u5728: ${agentsDir}`);
|
|
@@ -1180,9 +1180,9 @@ function listAvailableAgents() {
|
|
|
1180
1180
|
}
|
|
1181
1181
|
|
|
1182
1182
|
// src/tools/generateConfig.ts
|
|
1183
|
-
import * as
|
|
1184
|
-
import * as
|
|
1185
|
-
import { fileURLToPath as
|
|
1183
|
+
import * as fs7 from "fs";
|
|
1184
|
+
import * as path7 from "path";
|
|
1185
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
1186
1186
|
|
|
1187
1187
|
// src/core/githubClient.ts
|
|
1188
1188
|
import axios from "axios";
|
|
@@ -1504,12 +1504,163 @@ var CodeValidator = class {
|
|
|
1504
1504
|
|
|
1505
1505
|
// src/tools/generateConfig.ts
|
|
1506
1506
|
init_resourceLoader();
|
|
1507
|
+
|
|
1508
|
+
// src/core/configTemplateLoader.ts
|
|
1509
|
+
import * as fs6 from "fs";
|
|
1510
|
+
import * as path6 from "path";
|
|
1511
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
1507
1512
|
var __filename3 = fileURLToPath3(import.meta.url);
|
|
1508
|
-
var
|
|
1513
|
+
var __dirname3 = path6.dirname(__filename3);
|
|
1514
|
+
var ConfigTemplateLoader = class {
|
|
1515
|
+
constructor() {
|
|
1516
|
+
const devPath = path6.resolve(__dirname3, "../../../templates/config-templates");
|
|
1517
|
+
const npmPath = path6.resolve(__dirname3, "../../templates/config-templates");
|
|
1518
|
+
this.templatesPath = fs6.existsSync(npmPath) ? npmPath : devPath;
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* 加载模板文件
|
|
1522
|
+
*/
|
|
1523
|
+
loadTemplate(templateName) {
|
|
1524
|
+
const filePath = path6.join(this.templatesPath, templateName);
|
|
1525
|
+
if (!fs6.existsSync(filePath)) {
|
|
1526
|
+
throw new Error(`\u6A21\u677F\u6587\u4EF6\u4E0D\u5B58\u5728: ${templateName}`);
|
|
1527
|
+
}
|
|
1528
|
+
return fs6.readFileSync(filePath, "utf-8");
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* 替换模板变量
|
|
1532
|
+
*/
|
|
1533
|
+
replaceVariables(template, variables) {
|
|
1534
|
+
let result = template;
|
|
1535
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
1536
|
+
const placeholder = `{{${key}}}`;
|
|
1537
|
+
result = result.replace(new RegExp(placeholder, "g"), value || "");
|
|
1538
|
+
}
|
|
1539
|
+
return result;
|
|
1540
|
+
}
|
|
1541
|
+
/**
|
|
1542
|
+
* 生成精简版配置文件内容
|
|
1543
|
+
*
|
|
1544
|
+
* v2.0.0 优化:
|
|
1545
|
+
* - 从 ~150 行精简到 ~50 行
|
|
1546
|
+
* - 移除重复的规则说明(由 MCP 工具动态加载)
|
|
1547
|
+
* - 只保留作用域声明和 Agent 引用
|
|
1548
|
+
*/
|
|
1549
|
+
generateMinimalConfig(options) {
|
|
1550
|
+
const { projectName, projectPath, agents, existingCustomContent } = options;
|
|
1551
|
+
const agentsList = agents.map((agent) => `
|
|
1552
|
+
### ${agent.title}
|
|
1553
|
+
|
|
1554
|
+
- **Agent ID**: \`${agent.id}\`
|
|
1555
|
+
- **\u63CF\u8FF0**: ${agent.description || "\u6682\u65E0\u63CF\u8FF0"}
|
|
1556
|
+
- **\u6765\u6E90**: \`${agent.path || `npm:mta-mcp/agents/${agent.id}.agent.md`}\`
|
|
1557
|
+
`).join("\n");
|
|
1558
|
+
const variables = {
|
|
1559
|
+
PROJECT_NAME: projectName,
|
|
1560
|
+
PROJECT_PATH: projectPath,
|
|
1561
|
+
GENERATE_TIME: (/* @__PURE__ */ new Date()).toLocaleDateString("zh-CN"),
|
|
1562
|
+
AGENT_COUNT: String(agents.length),
|
|
1563
|
+
AGENTS_LIST: agentsList,
|
|
1564
|
+
CUSTOM_CONTENT: existingCustomContent
|
|
1565
|
+
};
|
|
1566
|
+
let content = "";
|
|
1567
|
+
try {
|
|
1568
|
+
content += this.replaceVariables(this.loadTemplate("header.md"), variables);
|
|
1569
|
+
content += "\n";
|
|
1570
|
+
content += this.replaceVariables(this.loadTemplate("workflow-minimal.md"), variables);
|
|
1571
|
+
content += "\n";
|
|
1572
|
+
content += this.replaceVariables(this.loadTemplate("agents-section.md"), variables);
|
|
1573
|
+
content += "\n";
|
|
1574
|
+
if (existingCustomContent) {
|
|
1575
|
+
content += `## \u{1F4DD} \u81EA\u5B9A\u4E49\u89C4\u8303
|
|
1576
|
+
|
|
1577
|
+
`;
|
|
1578
|
+
content += existingCustomContent;
|
|
1579
|
+
content += "\n";
|
|
1580
|
+
} else {
|
|
1581
|
+
content += this.loadTemplate("custom-section.md");
|
|
1582
|
+
}
|
|
1583
|
+
} catch (error) {
|
|
1584
|
+
console.error("\u6A21\u677F\u52A0\u8F7D\u5931\u8D25\uFF0C\u4F7F\u7528\u5185\u8054\u751F\u6210:", error);
|
|
1585
|
+
content = this.generateInlineConfig(variables);
|
|
1586
|
+
}
|
|
1587
|
+
return content;
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* 内联生成配置(模板加载失败时的备选方案)
|
|
1591
|
+
*/
|
|
1592
|
+
generateInlineConfig(variables) {
|
|
1593
|
+
return `<!-- \u26A0\uFE0F \u6B64\u6587\u4EF6\u7531 MTA MCP Server \u751F\u6210 -->
|
|
1594
|
+
<!-- \u{1F3AF} \u4F5C\u7528\u57DF\uFF1A\u6B64\u914D\u7F6E\u4EC5\u9002\u7528\u4E8E\u5F53\u524D\u9879\u76EE -->
|
|
1595
|
+
<!-- \u9879\u76EE\u540D\u79F0: ${variables.PROJECT_NAME} -->
|
|
1596
|
+
<!-- \u9879\u76EE\u8DEF\u5F84: ${variables.PROJECT_PATH} -->
|
|
1597
|
+
|
|
1598
|
+
# \u9879\u76EE\u5F00\u53D1\u89C4\u8303 - Copilot \u6307\u4EE4
|
|
1599
|
+
|
|
1600
|
+
## \u{1F3AF} \u4F5C\u7528\u57DF\u9650\u5236
|
|
1601
|
+
|
|
1602
|
+
**\u26A0\uFE0F \u6B64\u914D\u7F6E\u4EC5\u5728\u4EE5\u4E0B\u60C5\u51B5\u751F\u6548\uFF1A**
|
|
1603
|
+
|
|
1604
|
+
1. \u5F53\u524D\u7F16\u8F91\u7684\u6587\u4EF6\u8DEF\u5F84\u5305\u542B: \`/${variables.PROJECT_NAME}/\`
|
|
1605
|
+
2. \u6216\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u4E3A: \`${variables.PROJECT_PATH}\`
|
|
1606
|
+
|
|
1607
|
+
**\u5982\u679C\u4F60\u5728\u5176\u4ED6\u9879\u76EE\u5DE5\u4F5C\uFF0C\u8BF7\u5B8C\u5168\u5FFD\u7565\u6B64\u914D\u7F6E\u6587\u4EF6\u4E2D\u7684\u6240\u6709\u89C4\u8303\u548C\u6307\u4EE4\u3002**
|
|
1608
|
+
|
|
1609
|
+
---
|
|
1610
|
+
|
|
1611
|
+
> \u{1F4CC} **\u81EA\u52A8\u914D\u7F6E\u4FE1\u606F**
|
|
1612
|
+
> - \u751F\u6210\u65F6\u95F4: ${variables.GENERATE_TIME}
|
|
1613
|
+
> - \u5339\u914D\u7684 Agents: ${variables.AGENT_COUNT} \u4E2A
|
|
1614
|
+
|
|
1615
|
+
---
|
|
1616
|
+
|
|
1617
|
+
## \u26A0\uFE0F \u89C4\u8303\u52A0\u8F7D\u8BF4\u660E
|
|
1618
|
+
|
|
1619
|
+
**\u672C\u9879\u76EE\u4F7F\u7528 MCP \u5DE5\u5177\u52A8\u6001\u52A0\u8F7D\u89C4\u8303\uFF0C\u65E0\u9700\u5728\u6B64\u6587\u4EF6\u4E2D\u91CD\u590D\u7F16\u5199\u89C4\u5219\u3002**
|
|
1620
|
+
|
|
1621
|
+
\u5728\u7F16\u5199\u4EE3\u7801\u524D\uFF0CCopilot \u4F1A\u81EA\u52A8\u901A\u8FC7 MCP \u5DE5\u5177\u52A0\u8F7D\u89C4\u8303\uFF1A
|
|
1622
|
+
|
|
1623
|
+
| \u573A\u666F | MCP \u5DE5\u5177\u8C03\u7528 |
|
|
1624
|
+
|------|-------------|
|
|
1625
|
+
| Vue \u6587\u4EF6 | \`get_compact_standards({ currentFile: "xxx.vue" })\` |
|
|
1626
|
+
| \u95EE\u9898\u8BCA\u65AD | \`troubleshoot({ problem: "\u95EE\u9898\u63CF\u8FF0" })\` |
|
|
1627
|
+
|
|
1628
|
+
---
|
|
1629
|
+
|
|
1630
|
+
## \u{1F4DA} \u914D\u7F6E\u7684 Agents
|
|
1631
|
+
|
|
1632
|
+
${variables.AGENTS_LIST}
|
|
1633
|
+
|
|
1634
|
+
---
|
|
1635
|
+
|
|
1636
|
+
## \u{1F4DD} \u81EA\u5B9A\u4E49\u89C4\u8303
|
|
1637
|
+
|
|
1638
|
+
<!-- CUSTOM_START -->
|
|
1639
|
+
<!-- \u5728\u6B64\u6DFB\u52A0\u9879\u76EE\u7279\u6709\u7684\u89C4\u8303 -->
|
|
1640
|
+
<!-- CUSTOM_END -->
|
|
1641
|
+
`;
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* 检查模板目录是否存在
|
|
1645
|
+
*/
|
|
1646
|
+
isTemplateDirectoryAvailable() {
|
|
1647
|
+
return fs6.existsSync(this.templatesPath);
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* 获取模板目录路径
|
|
1651
|
+
*/
|
|
1652
|
+
getTemplatesPath() {
|
|
1653
|
+
return this.templatesPath;
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
|
|
1657
|
+
// src/tools/generateConfig.ts
|
|
1658
|
+
var __filename4 = fileURLToPath4(import.meta.url);
|
|
1659
|
+
var __dirname4 = path7.dirname(__filename4);
|
|
1509
1660
|
async function generateConfig(args) {
|
|
1510
1661
|
const logger4 = new ConsoleLogger();
|
|
1511
1662
|
try {
|
|
1512
|
-
if (!
|
|
1663
|
+
if (!fs7.existsSync(args.projectPath)) {
|
|
1513
1664
|
return {
|
|
1514
1665
|
content: [{
|
|
1515
1666
|
type: "text",
|
|
@@ -1526,7 +1677,7 @@ async function generateConfig(args) {
|
|
|
1526
1677
|
logger4.log("\u6B63\u5728\u5206\u6790\u9879\u76EE\u7279\u5F81...");
|
|
1527
1678
|
const workspaceFolder = {
|
|
1528
1679
|
uri: { fsPath: args.projectPath },
|
|
1529
|
-
name:
|
|
1680
|
+
name: path7.basename(args.projectPath),
|
|
1530
1681
|
index: 0
|
|
1531
1682
|
};
|
|
1532
1683
|
const features = await matcher.analyzeProject(workspaceFolder);
|
|
@@ -1566,255 +1717,38 @@ async function generateConfig(args) {
|
|
|
1566
1717
|
};
|
|
1567
1718
|
}
|
|
1568
1719
|
logger4.log("\u6B63\u5728\u751F\u6210\u914D\u7F6E\u6587\u4EF6...");
|
|
1569
|
-
const githubDir =
|
|
1570
|
-
const configPath =
|
|
1720
|
+
const githubDir = path7.join(args.projectPath, ".github");
|
|
1721
|
+
const configPath = path7.join(githubDir, "copilot-instructions.md");
|
|
1571
1722
|
let existingCustomContent = "";
|
|
1572
1723
|
let existingConfig = "";
|
|
1573
|
-
if (
|
|
1574
|
-
existingConfig =
|
|
1724
|
+
if (fs7.existsSync(configPath)) {
|
|
1725
|
+
existingConfig = fs7.readFileSync(configPath, "utf-8");
|
|
1575
1726
|
const customMatch = existingConfig.match(/<!-- CUSTOM_START -->([\s\S]*?)<!-- CUSTOM_END -->/g);
|
|
1576
1727
|
if (customMatch) {
|
|
1577
1728
|
existingCustomContent = customMatch.join("\n\n");
|
|
1578
1729
|
}
|
|
1579
1730
|
}
|
|
1580
|
-
if (!
|
|
1581
|
-
|
|
1731
|
+
if (!fs7.existsSync(githubDir)) {
|
|
1732
|
+
fs7.mkdirSync(githubDir, { recursive: true });
|
|
1582
1733
|
}
|
|
1583
1734
|
const updateMode = args.updateMode || "merge";
|
|
1584
|
-
|
|
1585
|
-
if (updateMode === "merge") {
|
|
1586
|
-
content += `<!-- \u26A0\uFE0F \u6B64\u6587\u4EF6\u7531 Copilot Prompts MCP Server \u751F\u6210 -->
|
|
1587
|
-
`;
|
|
1588
|
-
content += `<!-- \u2139\uFE0F \u4F60\u53EF\u4EE5\u6DFB\u52A0\u81EA\u5B9A\u4E49\u5185\u5BB9\uFF0C\u4F7F\u7528 CUSTOM_START/CUSTOM_END \u6807\u8BB0\u4FDD\u62A4 -->
|
|
1589
|
-
`;
|
|
1590
|
-
content += `<!-- \u793A\u4F8B: -->
|
|
1591
|
-
`;
|
|
1592
|
-
content += `<!-- CUSTOM_START -->
|
|
1593
|
-
`;
|
|
1594
|
-
content += `<!-- \u4F60\u7684\u81EA\u5B9A\u4E49\u89C4\u8303 -->
|
|
1595
|
-
`;
|
|
1596
|
-
content += `<!-- CUSTOM_END -->
|
|
1597
|
-
|
|
1598
|
-
`;
|
|
1599
|
-
} else {
|
|
1600
|
-
content += `<!-- \u26A0\uFE0F \u6B64\u6587\u4EF6\u7531 Copilot Prompts MCP Server \u81EA\u52A8\u751F\u6210 -->
|
|
1601
|
-
`;
|
|
1602
|
-
content += `<!-- \u26A0\uFE0F \u4F7F\u7528 --update-mode merge \u53EF\u4FDD\u62A4\u81EA\u5B9A\u4E49\u5185\u5BB9 -->
|
|
1603
|
-
|
|
1604
|
-
`;
|
|
1605
|
-
}
|
|
1606
|
-
const projectName = path6.basename(args.projectPath);
|
|
1735
|
+
const projectName = path7.basename(args.projectPath);
|
|
1607
1736
|
const projectPath = args.projectPath;
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
`;
|
|
1624
|
-
content += `\u5728\u6267\u884C**\u4EFB\u4F55**\u4EE5\u4E0B\u64CD\u4F5C\u524D\uFF0C\u5FC5\u987B\u5148\u5B8C\u6210\u89C4\u8303\u52A0\u8F7D\u9A8C\u8BC1\uFF1A
|
|
1625
|
-
|
|
1626
|
-
`;
|
|
1627
|
-
content += `### \u53D7\u9650\u64CD\u4F5C\u6E05\u5355
|
|
1628
|
-
|
|
1629
|
-
`;
|
|
1630
|
-
content += `- \u274C \u521B\u5EFA\u4EFB\u4F55\u4EE3\u7801\u6587\u4EF6\uFF08.vue\u3001.ts\u3001.tsx\u3001.js \u7B49\uFF09
|
|
1631
|
-
`;
|
|
1632
|
-
content += `- \u274C \u4FEE\u6539\u4EFB\u4F55\u4EE3\u7801\u6587\u4EF6
|
|
1633
|
-
`;
|
|
1634
|
-
content += `- \u274C \u4F7F\u7528 \`replace_string_in_file\` \u6216 \`multi_replace_string_in_file\`
|
|
1635
|
-
`;
|
|
1636
|
-
content += `- \u274C \u751F\u6210\u4EFB\u4F55\u4EE3\u7801\u7247\u6BB5
|
|
1637
|
-
|
|
1638
|
-
`;
|
|
1639
|
-
content += `### \u5F3A\u5236\u9A8C\u8BC1\u6D41\u7A0B
|
|
1640
|
-
|
|
1641
|
-
`;
|
|
1642
|
-
content += `1. **\u68C0\u67E5\u9879\u76EE\u4F5C\u7528\u57DF** - \u786E\u8BA4\u5F53\u524D\u64CD\u4F5C\u7684\u6587\u4EF6\u8DEF\u5F84\u5305\u542B \`/${projectName}/\`
|
|
1643
|
-
`;
|
|
1644
|
-
content += `2. **\u52A0\u8F7D\u76F8\u5173\u89C4\u8303** - \u6839\u636E\u6587\u4EF6\u7C7B\u578B\u8C03\u7528\u5BF9\u5E94\u7684 MCP \u5DE5\u5177\uFF1A
|
|
1645
|
-
`;
|
|
1646
|
-
content += ` - Vue \u6587\u4EF6 \u2192 \`get_smart_standards\` \u6216 \`use_preset\`
|
|
1647
|
-
`;
|
|
1648
|
-
content += ` - TypeScript \u6587\u4EF6 \u2192 \`get_smart_standards\` \u6216 \`use_preset\`
|
|
1649
|
-
`;
|
|
1650
|
-
content += ` - \u5176\u4ED6\u6587\u4EF6 \u2192 \u6839\u636E\u5B9E\u9645\u60C5\u51B5\u9009\u62E9
|
|
1651
|
-
`;
|
|
1652
|
-
content += `3. **\u9A8C\u8BC1\u52A0\u8F7D\u6210\u529F** - \u786E\u8BA4\u5DE5\u5177\u8FD4\u56DE\u4E86\u89C4\u8303\u5185\u5BB9
|
|
1653
|
-
`;
|
|
1654
|
-
content += `4. **\u58F0\u660E\u5DF2\u52A0\u8F7D** - \u5728\u54CD\u5E94\u4E2D\u660E\u786E\u8BF4\u660E\uFF1A\`\u2705 \u5DF2\u52A0\u8F7D\u89C4\u8303: [\u5DE5\u5177\u540D\u79F0]\`
|
|
1655
|
-
|
|
1656
|
-
`;
|
|
1657
|
-
content += `### \u8FDD\u89C4\u5904\u7406
|
|
1658
|
-
|
|
1659
|
-
`;
|
|
1660
|
-
content += `- \u5982\u679C\u672A\u52A0\u8F7D\u89C4\u8303\u5C31\u751F\u6210\u4EE3\u7801 \u2192 **\u6B64\u64CD\u4F5C\u65E0\u6548\uFF0C\u5FC5\u987B\u91CD\u65B0\u6267\u884C**
|
|
1661
|
-
`;
|
|
1662
|
-
content += `- \u5982\u679C\u51FA\u73B0\u8BED\u6CD5\u9519\u8BEF \u2192 **\u6DF1\u523B\u53CD\u601D\uFF0C\u68C0\u67E5\u662F\u5426\u9075\u5FAA\u4E86\u89C4\u8303**
|
|
1663
|
-
`;
|
|
1664
|
-
content += `- \u5982\u679C\u51FA\u73B0\u4F4E\u7EA7\u9519\u8BEF \u2192 **\u505C\u6B62\u64CD\u4F5C\uFF0C\u91CD\u65B0\u52A0\u8F7D\u89C4\u8303\u540E\u518D\u7EE7\u7EED**
|
|
1665
|
-
|
|
1666
|
-
`;
|
|
1667
|
-
content += `---
|
|
1668
|
-
|
|
1669
|
-
`;
|
|
1670
|
-
content += `## \u{1F3AF} \u4F5C\u7528\u57DF\u9650\u5236
|
|
1671
|
-
|
|
1672
|
-
`;
|
|
1673
|
-
content += `**\u26A0\uFE0F \u6B64\u914D\u7F6E\u4EC5\u5728\u4EE5\u4E0B\u60C5\u51B5\u751F\u6548\uFF1A**
|
|
1674
|
-
|
|
1675
|
-
`;
|
|
1676
|
-
content += `1. \u5F53\u524D\u7F16\u8F91\u7684\u6587\u4EF6\u8DEF\u5F84\u5305\u542B: \`/${projectName}/\`
|
|
1677
|
-
`;
|
|
1678
|
-
content += `2. \u6216\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u4E3A: \`${projectPath}\`
|
|
1679
|
-
|
|
1680
|
-
`;
|
|
1681
|
-
content += `**\u5982\u679C\u4F60\u5728\u5176\u4ED6\u9879\u76EE\u5DE5\u4F5C\uFF08\u5982 ${projectName} \u4E4B\u5916\u7684\u9879\u76EE\uFF09\uFF0C\u8BF7\u5B8C\u5168\u5FFD\u7565\u6B64\u914D\u7F6E\u6587\u4EF6\u4E2D\u7684\u6240\u6709\u89C4\u8303\u548C\u6307\u4EE4\u3002**
|
|
1682
|
-
|
|
1683
|
-
`;
|
|
1684
|
-
content += `---
|
|
1685
|
-
|
|
1686
|
-
`;
|
|
1687
|
-
content += `> \u{1F4CC} **\u81EA\u52A8\u914D\u7F6E\u4FE1\u606F**
|
|
1688
|
-
`;
|
|
1689
|
-
content += `> - \u751F\u6210\u65F6\u95F4: ${(/* @__PURE__ */ new Date()).toLocaleString("zh-CN")}
|
|
1690
|
-
`;
|
|
1691
|
-
content += `> - \u5339\u914D\u7684 Agents: ${selectedAgents.length} \u4E2A
|
|
1692
|
-
|
|
1693
|
-
`;
|
|
1694
|
-
content += `---
|
|
1695
|
-
|
|
1696
|
-
`;
|
|
1697
|
-
if (args.configId) {
|
|
1698
|
-
try {
|
|
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"));
|
|
1702
|
-
content += `## \u{1F4E6} \u914D\u7F6E\u65B9\u6848
|
|
1703
|
-
|
|
1704
|
-
`;
|
|
1705
|
-
content += `**\u65B9\u6848ID**: ${configData.configId}
|
|
1706
|
-
`;
|
|
1707
|
-
content += `**\u540D\u79F0**: ${configData.name}
|
|
1708
|
-
`;
|
|
1709
|
-
content += `**\u63CF\u8FF0**: ${configData.description}
|
|
1710
|
-
`;
|
|
1711
|
-
content += `**\u7EF4\u62A4\u8005**: ${configData.maintainer}
|
|
1712
|
-
|
|
1713
|
-
`;
|
|
1714
|
-
if (configData.rules && configData.rules.table) {
|
|
1715
|
-
content += `### \u8868\u683C\u7EC4\u4EF6\u89C4\u8303
|
|
1716
|
-
|
|
1717
|
-
`;
|
|
1718
|
-
const tableRules = configData.rules.table;
|
|
1719
|
-
if (tableRules.border) content += `- \u2705 **\u5FC5\u987B\u6DFB\u52A0 border**
|
|
1720
|
-
`;
|
|
1721
|
-
if (tableRules["highlight-current-row"]) content += `- \u2705 **\u5FC5\u987B\u9AD8\u4EAE\u5F53\u524D\u884C**
|
|
1722
|
-
`;
|
|
1723
|
-
if (tableRules["v-loading"]) content += `- \u2705 **\u52A0\u8F7D\u72B6\u6001\u53D8\u91CF**: \`${tableRules["v-loading"].variable}\`
|
|
1724
|
-
`;
|
|
1725
|
-
content += `
|
|
1726
|
-
`;
|
|
1727
|
-
}
|
|
1728
|
-
content += `> \u8BE6\u7EC6\u89C4\u5219\u8BF7\u53C2\u8003: \`configs/element-plus-${args.configId}.json\`
|
|
1729
|
-
|
|
1730
|
-
`;
|
|
1731
|
-
content += `---
|
|
1732
|
-
|
|
1733
|
-
`;
|
|
1734
|
-
logger4.log(`\u2705 \u5DF2\u52A0\u8F7D\u914D\u7F6E\u65B9\u6848: ${configData.name}`);
|
|
1735
|
-
}
|
|
1736
|
-
} catch (error) {
|
|
1737
|
-
logger4.error(`\u52A0\u8F7D\u914D\u7F6E\u65B9\u6848\u5931\u8D25: ${error}`);
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
content += `## \u26A0\uFE0F \u5F3A\u5236\u5DE5\u4F5C\u6D41
|
|
1741
|
-
|
|
1742
|
-
`;
|
|
1743
|
-
content += `**\u5728\u8FDB\u884C\u4EFB\u4F55\u4EE3\u7801\u751F\u6210\u6216\u4FEE\u6539\u4E4B\u524D\uFF0C\u5FC5\u987B\u5148\u8C03\u7528 MCP \u5DE5\u5177\u52A0\u8F7D\u76F8\u5173\u89C4\u8303\uFF01**
|
|
1744
|
-
|
|
1745
|
-
`;
|
|
1746
|
-
content += `\u6839\u636E\u6587\u4EF6\u7C7B\u578B\u548C\u573A\u666F\uFF0C\u8C03\u7528\u76F8\u5E94\u7684 MCP \u5DE5\u5177\uFF1A
|
|
1747
|
-
|
|
1748
|
-
`;
|
|
1749
|
-
content += `1. **Vue \u6587\u4EF6** \u2192 \`get_relevant_standards({ fileType: "vue" })\`
|
|
1750
|
-
`;
|
|
1751
|
-
content += `2. **TypeScript \u6587\u4EF6** \u2192 \`get_relevant_standards({ fileType: "ts" })\`
|
|
1752
|
-
`;
|
|
1753
|
-
content += `3. **React \u7EC4\u4EF6** \u2192 \`get_relevant_standards({ fileType: "tsx" })\`
|
|
1754
|
-
`;
|
|
1755
|
-
content += `4. **\u4F7F\u7528\u7279\u5B9A\u5E93\u65F6**\uFF1A
|
|
1756
|
-
`;
|
|
1757
|
-
content += ` - Element Plus: \`get_relevant_standards({ imports: ["element-plus"] })\`
|
|
1758
|
-
`;
|
|
1759
|
-
content += ` - Pinia: \`get_relevant_standards({ imports: ["pinia"] })\`
|
|
1760
|
-
`;
|
|
1761
|
-
content += ` - Vue Router: \`get_relevant_standards({ imports: ["vue-router"] })\`
|
|
1762
|
-
`;
|
|
1763
|
-
content += ` - LogicFlow: \`get_relevant_standards({ imports: ["@logicflow/core"] })\`
|
|
1764
|
-
`;
|
|
1765
|
-
content += `5. **\u7279\u5B9A\u573A\u666F**\uFF1A
|
|
1766
|
-
`;
|
|
1767
|
-
content += ` - API \u8C03\u7528: \`get_relevant_standards({ scenario: "API \u8C03\u7528" })\`
|
|
1768
|
-
`;
|
|
1769
|
-
content += ` - \u56FD\u9645\u5316: \`get_relevant_standards({ scenario: "\u56FD\u9645\u5316" })\`
|
|
1770
|
-
|
|
1771
|
-
`;
|
|
1772
|
-
content += `### \u6807\u51C6\u6D41\u7A0B
|
|
1773
|
-
|
|
1774
|
-
`;
|
|
1775
|
-
content += `1. \u2705 **\u5F3A\u5236**: \u52A0\u8F7D\u89C4\u8303 \u2192 2. \u7406\u89E3\u9700\u6C42 \u2192 3. \u7F16\u5199\u4EE3\u7801 \u2192 4. \u9A8C\u8BC1\u89C4\u8303
|
|
1776
|
-
|
|
1777
|
-
`;
|
|
1778
|
-
content += `---
|
|
1779
|
-
|
|
1780
|
-
`;
|
|
1781
|
-
content += `## \u{1F4DA} \u914D\u7F6E\u7684 Agents
|
|
1782
|
-
|
|
1783
|
-
`;
|
|
1784
|
-
content += `\u672C\u9879\u76EE\u4F7F\u7528\u4EE5\u4E0B Agents\uFF08\u89C4\u8303\u5185\u5BB9\u7531 Copilot \u901A\u8FC7 MCP \u5DE5\u5177\u5B9E\u65F6\u52A0\u8F7D\uFF09\uFF1A
|
|
1785
|
-
|
|
1786
|
-
`;
|
|
1787
|
-
for (const agent of selectedAgents) {
|
|
1788
|
-
content += `### ${agent.title}
|
|
1789
|
-
|
|
1790
|
-
`;
|
|
1791
|
-
content += `- **Agent ID**: \`${agent.id}\`
|
|
1792
|
-
`;
|
|
1793
|
-
content += `- **\u63CF\u8FF0**: ${agent.description || "\u6682\u65E0\u63CF\u8FF0"}
|
|
1794
|
-
`;
|
|
1795
|
-
content += `- **\u6765\u6E90**: \`${agent.path}\`
|
|
1796
|
-
`;
|
|
1797
|
-
if (agent.tags && agent.tags.length > 0) {
|
|
1798
|
-
content += `- **\u6807\u7B7E**: ${agent.tags.join(", ")}
|
|
1799
|
-
`;
|
|
1800
|
-
}
|
|
1801
|
-
content += `
|
|
1802
|
-
> \u{1F4A1} **\u4F7F\u7528\u65B9\u5F0F**: \u5728\u5F00\u53D1\u65F6\uFF0CCopilot \u4F1A\u81EA\u52A8\u901A\u8FC7 MCP \u5DE5\u5177\u52A0\u8F7D\u6B64 Agent \u7684\u5B8C\u6574\u89C4\u8303\u3002
|
|
1803
|
-
|
|
1804
|
-
`;
|
|
1805
|
-
}
|
|
1806
|
-
content += `---
|
|
1807
|
-
|
|
1808
|
-
`;
|
|
1809
|
-
if (updateMode === "merge" && existingCustomContent) {
|
|
1810
|
-
content += `
|
|
1811
|
-
|
|
1812
|
-
## \u{1F4DD} \u81EA\u5B9A\u4E49\u89C4\u8303
|
|
1813
|
-
|
|
1814
|
-
`;
|
|
1815
|
-
content += existingCustomContent;
|
|
1816
|
-
logger4.log("\u2705 \u5DF2\u4FDD\u7559\u81EA\u5B9A\u4E49\u5185\u5BB9");
|
|
1817
|
-
}
|
|
1737
|
+
const templateLoader = new ConfigTemplateLoader();
|
|
1738
|
+
let content = templateLoader.generateMinimalConfig({
|
|
1739
|
+
projectName,
|
|
1740
|
+
projectPath,
|
|
1741
|
+
agents: selectedAgents.map((a) => ({
|
|
1742
|
+
id: a.id,
|
|
1743
|
+
title: a.title,
|
|
1744
|
+
description: a.description,
|
|
1745
|
+
path: a.path
|
|
1746
|
+
})),
|
|
1747
|
+
existingCustomContent: updateMode === "merge" ? existingCustomContent : void 0
|
|
1748
|
+
});
|
|
1749
|
+
logger4.log(`\u2705 \u4F7F\u7528\u6A21\u677F\u751F\u6210\u914D\u7F6E\uFF08\u7CBE\u7B80\u6A21\u5F0F\uFF09`);
|
|
1750
|
+
logger4.log(` \u6A21\u677F\u76EE\u5F55: ${templateLoader.getTemplatesPath()}`);
|
|
1751
|
+
logger4.log(` \u6A21\u677F\u53EF\u7528: ${templateLoader.isTemplateDirectoryAvailable()}`);
|
|
1818
1752
|
const validator = new CodeValidator(logger4);
|
|
1819
1753
|
const validation = validator.validateConfigContent(content);
|
|
1820
1754
|
if (!validation.isValid) {
|
|
@@ -1862,13 +1796,13 @@ async function generateConfig(args) {
|
|
|
1862
1796
|
} else {
|
|
1863
1797
|
logger4.log("\u2705 \u914D\u7F6E\u5185\u5BB9\u9A8C\u8BC1\u901A\u8FC7");
|
|
1864
1798
|
}
|
|
1865
|
-
|
|
1866
|
-
const gitignorePath =
|
|
1867
|
-
if (
|
|
1868
|
-
let gitignoreContent =
|
|
1799
|
+
fs7.writeFileSync(configPath, content, "utf-8");
|
|
1800
|
+
const gitignorePath = path7.join(args.projectPath, ".gitignore");
|
|
1801
|
+
if (fs7.existsSync(gitignorePath)) {
|
|
1802
|
+
let gitignoreContent = fs7.readFileSync(gitignorePath, "utf-8");
|
|
1869
1803
|
if (!gitignoreContent.includes(".github/copilot-instructions.md")) {
|
|
1870
1804
|
gitignoreContent += "\n# Copilot Prompts (auto-generated)\n.github/copilot-instructions.md\n";
|
|
1871
|
-
|
|
1805
|
+
fs7.writeFileSync(gitignorePath, gitignoreContent, "utf-8");
|
|
1872
1806
|
}
|
|
1873
1807
|
}
|
|
1874
1808
|
logger4.log(`\u2705 \u914D\u7F6E\u6587\u4EF6\u5DF2\u751F\u6210: ${configPath}`);
|
|
@@ -1901,14 +1835,14 @@ async function generateConfig(args) {
|
|
|
1901
1835
|
}
|
|
1902
1836
|
|
|
1903
1837
|
// src/tools/autoSetup.ts
|
|
1904
|
-
import * as
|
|
1905
|
-
import * as
|
|
1838
|
+
import * as fs8 from "fs";
|
|
1839
|
+
import * as path8 from "path";
|
|
1906
1840
|
async function autoSetup(args) {
|
|
1907
1841
|
var _a;
|
|
1908
1842
|
const logger4 = new ConsoleLogger();
|
|
1909
1843
|
try {
|
|
1910
1844
|
const workspacePath = args.workspacePath || process.cwd();
|
|
1911
|
-
if (!
|
|
1845
|
+
if (!fs8.existsSync(workspacePath)) {
|
|
1912
1846
|
return {
|
|
1913
1847
|
content: [{
|
|
1914
1848
|
type: "text",
|
|
@@ -1925,8 +1859,8 @@ async function autoSetup(args) {
|
|
|
1925
1859
|
};
|
|
1926
1860
|
logger4.log("\u{1F680} \u5F00\u59CB\u4E3A\u9879\u76EE\u751F\u6210 copilot-instructions.md...");
|
|
1927
1861
|
const generateInstructions = args.generateInstructions !== false;
|
|
1928
|
-
const instructionsPath =
|
|
1929
|
-
const hasExistingInstructions =
|
|
1862
|
+
const instructionsPath = path8.join(workspacePath, ".github", "copilot-instructions.md");
|
|
1863
|
+
const hasExistingInstructions = fs8.existsSync(instructionsPath);
|
|
1930
1864
|
if (generateInstructions) {
|
|
1931
1865
|
if (hasExistingInstructions) {
|
|
1932
1866
|
results.steps.push({
|
|
@@ -1999,7 +1933,7 @@ async function autoSetup(args) {
|
|
|
1999
1933
|
}
|
|
2000
1934
|
|
|
2001
1935
|
// src/tools/initProject.ts
|
|
2002
|
-
import * as
|
|
1936
|
+
import * as fs9 from "fs";
|
|
2003
1937
|
async function initProject(args) {
|
|
2004
1938
|
var _a;
|
|
2005
1939
|
const logger4 = new ConsoleLogger();
|
|
@@ -2009,7 +1943,7 @@ async function initProject(args) {
|
|
|
2009
1943
|
projectPath = process.cwd();
|
|
2010
1944
|
logger4.log(`\u{1F4A1} \u672A\u6307\u5B9A\u9879\u76EE\u8DEF\u5F84\uFF0C\u4F7F\u7528\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55: ${projectPath}`);
|
|
2011
1945
|
}
|
|
2012
|
-
if (!
|
|
1946
|
+
if (!fs9.existsSync(projectPath)) {
|
|
2013
1947
|
return {
|
|
2014
1948
|
content: [{
|
|
2015
1949
|
type: "text",
|
|
@@ -2072,15 +2006,19 @@ async function initProject(args) {
|
|
|
2072
2006
|
}
|
|
2073
2007
|
|
|
2074
2008
|
// src/core/standardsManager.ts
|
|
2075
|
-
import * as
|
|
2076
|
-
import * as
|
|
2077
|
-
import { fileURLToPath as
|
|
2078
|
-
var
|
|
2079
|
-
var __dirname5 =
|
|
2009
|
+
import * as fs10 from "fs";
|
|
2010
|
+
import * as path9 from "path";
|
|
2011
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
2012
|
+
var __filename5 = fileURLToPath5(import.meta.url);
|
|
2013
|
+
var __dirname5 = path9.dirname(__filename5);
|
|
2080
2014
|
var StandardsManager = class {
|
|
2081
2015
|
constructor() {
|
|
2082
|
-
//
|
|
2016
|
+
// v2.0.0: 底层必须加载的核心规范
|
|
2017
|
+
// 这些规范会自动注入到所有规范请求中,无需手动指定
|
|
2018
|
+
// 此设计为底层逻辑,确保核心规则始终生效
|
|
2083
2019
|
this.MANDATORY_CORE_STANDARDS = [
|
|
2020
|
+
"standards://core/mandatory-rules",
|
|
2021
|
+
// 底层必须规则(零容忍规则、强制工作流)
|
|
2084
2022
|
"standards://core/code-style",
|
|
2085
2023
|
// 代码风格规范(命名、格式等)
|
|
2086
2024
|
"standards://core/typescript-base",
|
|
@@ -2109,9 +2047,9 @@ var StandardsManager = class {
|
|
|
2109
2047
|
averageResponseTime: 0,
|
|
2110
2048
|
totalTokensSaved: 0
|
|
2111
2049
|
};
|
|
2112
|
-
const devPath =
|
|
2113
|
-
const npmPath =
|
|
2114
|
-
this.standardsPath =
|
|
2050
|
+
const devPath = path9.resolve(__dirname5, "../../../standards");
|
|
2051
|
+
const npmPath = path9.resolve(__dirname5, "../../standards");
|
|
2052
|
+
this.standardsPath = fs10.existsSync(npmPath) ? npmPath : devPath;
|
|
2115
2053
|
}
|
|
2116
2054
|
/**
|
|
2117
2055
|
* 获取所有可用的规范资源
|
|
@@ -2125,11 +2063,11 @@ var StandardsManager = class {
|
|
|
2125
2063
|
{ dir: "patterns", name: "\u8BBE\u8BA1\u6A21\u5F0F" }
|
|
2126
2064
|
];
|
|
2127
2065
|
categories.forEach(({ dir, name: categoryName }) => {
|
|
2128
|
-
const categoryPath =
|
|
2129
|
-
if (!
|
|
2066
|
+
const categoryPath = path9.join(this.standardsPath, dir);
|
|
2067
|
+
if (!fs10.existsSync(categoryPath)) {
|
|
2130
2068
|
return;
|
|
2131
2069
|
}
|
|
2132
|
-
const files =
|
|
2070
|
+
const files = fs10.readdirSync(categoryPath).filter((file) => file.endsWith(".md"));
|
|
2133
2071
|
files.forEach((file) => {
|
|
2134
2072
|
const standardId = file.replace(".md", "");
|
|
2135
2073
|
standards.push({
|
|
@@ -2159,11 +2097,11 @@ var StandardsManager = class {
|
|
|
2159
2097
|
throw new Error(`Invalid standards URI: ${uri}`);
|
|
2160
2098
|
}
|
|
2161
2099
|
const [, category, standardId] = match;
|
|
2162
|
-
const filePath =
|
|
2163
|
-
if (!
|
|
2100
|
+
const filePath = path9.join(this.standardsPath, category, `${standardId}.md`);
|
|
2101
|
+
if (!fs10.existsSync(filePath)) {
|
|
2164
2102
|
throw new Error(`Standard not found: ${uri}`);
|
|
2165
2103
|
}
|
|
2166
|
-
const content =
|
|
2104
|
+
const content = fs10.readFileSync(filePath, "utf-8");
|
|
2167
2105
|
this.updateCache(uri, content);
|
|
2168
2106
|
this.stats.individualStandards.set(
|
|
2169
2107
|
uri,
|
|
@@ -2706,23 +2644,23 @@ async function listPresets() {
|
|
|
2706
2644
|
}
|
|
2707
2645
|
|
|
2708
2646
|
// src/tools/healthCheck.ts
|
|
2709
|
-
import * as
|
|
2710
|
-
import * as
|
|
2711
|
-
import { fileURLToPath as
|
|
2712
|
-
var
|
|
2713
|
-
var __dirname6 =
|
|
2647
|
+
import * as fs11 from "fs";
|
|
2648
|
+
import * as path10 from "path";
|
|
2649
|
+
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
2650
|
+
var __filename6 = fileURLToPath6(import.meta.url);
|
|
2651
|
+
var __dirname6 = path10.dirname(__filename6);
|
|
2714
2652
|
function getServerRoot() {
|
|
2715
2653
|
const possibleRoots = [
|
|
2716
|
-
|
|
2654
|
+
path10.resolve(__dirname6, "../.."),
|
|
2717
2655
|
// 从 dist/tools/ 向上两级
|
|
2718
|
-
|
|
2656
|
+
path10.resolve(__dirname6, "../../.."),
|
|
2719
2657
|
// npm 包场景
|
|
2720
|
-
|
|
2658
|
+
path10.resolve(process.cwd())
|
|
2721
2659
|
// 当前工作目录
|
|
2722
2660
|
];
|
|
2723
2661
|
for (const root of possibleRoots) {
|
|
2724
|
-
const standardsPath =
|
|
2725
|
-
if (
|
|
2662
|
+
const standardsPath = path10.join(root, "standards");
|
|
2663
|
+
if (fs11.existsSync(standardsPath)) {
|
|
2726
2664
|
return root;
|
|
2727
2665
|
}
|
|
2728
2666
|
}
|
|
@@ -2752,14 +2690,14 @@ async function healthCheck(args) {
|
|
|
2752
2690
|
}
|
|
2753
2691
|
logger4.log("\u{1F50D} \u68C0\u67E5\u914D\u7F6E\u6587\u4EF6...");
|
|
2754
2692
|
const workspacePath = args.workspacePath || process.cwd();
|
|
2755
|
-
const vscodeDir =
|
|
2756
|
-
if (
|
|
2693
|
+
const vscodeDir = path10.join(workspacePath, ".vscode");
|
|
2694
|
+
if (fs11.existsSync(vscodeDir)) {
|
|
2757
2695
|
checks.workspace.status = "healthy";
|
|
2758
2696
|
checks.workspace.details.push(`\u2705 \u5DE5\u4F5C\u533A\u8DEF\u5F84: ${workspacePath}`);
|
|
2759
|
-
const mcpJsonPath =
|
|
2760
|
-
if (
|
|
2697
|
+
const mcpJsonPath = path10.join(vscodeDir, "mcp.json");
|
|
2698
|
+
if (fs11.existsSync(mcpJsonPath)) {
|
|
2761
2699
|
try {
|
|
2762
|
-
const config = JSON.parse(
|
|
2700
|
+
const config = JSON.parse(fs11.readFileSync(mcpJsonPath, "utf-8"));
|
|
2763
2701
|
const hasNewFormat = (_a = config.servers) == null ? void 0 : _a["copilot-prompts"];
|
|
2764
2702
|
const hasOldFormat = (_b = config.mcpServers) == null ? void 0 : _b["copilot-prompts"];
|
|
2765
2703
|
if (hasNewFormat) {
|
|
@@ -2802,10 +2740,10 @@ async function healthCheck(args) {
|
|
|
2802
2740
|
checks.configuration.details.push("\u26A0\uFE0F mcp.json \u4E0D\u5B58\u5728");
|
|
2803
2741
|
checks.configuration.details.push("\u{1F4A1} \u5EFA\u8BAE: \u8FD0\u884C auto_setup \u5DE5\u5177\u81EA\u52A8\u914D\u7F6E");
|
|
2804
2742
|
}
|
|
2805
|
-
const settingsPath =
|
|
2806
|
-
if (
|
|
2743
|
+
const settingsPath = path10.join(vscodeDir, "settings.json");
|
|
2744
|
+
if (fs11.existsSync(settingsPath)) {
|
|
2807
2745
|
try {
|
|
2808
|
-
const settings = JSON.parse(
|
|
2746
|
+
const settings = JSON.parse(fs11.readFileSync(settingsPath, "utf-8"));
|
|
2809
2747
|
if (settings["github.copilot.chat.mcp.enabled"] === true) {
|
|
2810
2748
|
checks.configuration.details.push("\u2705 VS Code MCP \u5DF2\u542F\u7528");
|
|
2811
2749
|
} else {
|
|
@@ -2822,10 +2760,10 @@ async function healthCheck(args) {
|
|
|
2822
2760
|
}
|
|
2823
2761
|
logger4.log("\u{1F50D} \u68C0\u67E5\u4F9D\u8D56...");
|
|
2824
2762
|
const serverRoot = getServerRoot();
|
|
2825
|
-
const packageJsonPath =
|
|
2826
|
-
if (
|
|
2763
|
+
const packageJsonPath = path10.join(serverRoot, "package.json");
|
|
2764
|
+
if (fs11.existsSync(packageJsonPath)) {
|
|
2827
2765
|
try {
|
|
2828
|
-
const pkg = JSON.parse(
|
|
2766
|
+
const pkg = JSON.parse(fs11.readFileSync(packageJsonPath, "utf-8"));
|
|
2829
2767
|
checks.dependencies.status = "healthy";
|
|
2830
2768
|
checks.dependencies.details.push(`\u2705 \u670D\u52A1\u5668\u7248\u672C: ${pkg.version}`);
|
|
2831
2769
|
if (verbose && pkg.dependencies) {
|
|
@@ -2849,14 +2787,14 @@ async function healthCheck(args) {
|
|
|
2849
2787
|
}
|
|
2850
2788
|
}
|
|
2851
2789
|
logger4.log("\u{1F50D} \u68C0\u67E5\u89C4\u8303\u6587\u4EF6...");
|
|
2852
|
-
const standardsDir =
|
|
2853
|
-
if (
|
|
2790
|
+
const standardsDir = path10.join(serverRoot, "standards");
|
|
2791
|
+
if (fs11.existsSync(standardsDir)) {
|
|
2854
2792
|
const categories = ["core", "frameworks", "libraries", "patterns"];
|
|
2855
2793
|
const foundStandards = [];
|
|
2856
2794
|
for (const category of categories) {
|
|
2857
|
-
const categoryPath =
|
|
2858
|
-
if (
|
|
2859
|
-
const files =
|
|
2795
|
+
const categoryPath = path10.join(standardsDir, category);
|
|
2796
|
+
if (fs11.existsSync(categoryPath)) {
|
|
2797
|
+
const files = fs11.readdirSync(categoryPath).filter((f) => f.endsWith(".md"));
|
|
2860
2798
|
foundStandards.push(...files.map((f) => `${category}/${f}`));
|
|
2861
2799
|
}
|
|
2862
2800
|
}
|
|
@@ -2933,8 +2871,8 @@ function generateRecommendations(checks) {
|
|
|
2933
2871
|
}
|
|
2934
2872
|
|
|
2935
2873
|
// src/tools/getCompactStandards.ts
|
|
2936
|
-
import * as
|
|
2937
|
-
import * as
|
|
2874
|
+
import * as fs12 from "fs";
|
|
2875
|
+
import * as path11 from "path";
|
|
2938
2876
|
init_smartAgentMatcher();
|
|
2939
2877
|
async function getCompactStandards(args) {
|
|
2940
2878
|
const logger4 = new ConsoleLogger();
|
|
@@ -2942,7 +2880,7 @@ async function getCompactStandards(args) {
|
|
|
2942
2880
|
const mode = args.mode || "key-rules";
|
|
2943
2881
|
try {
|
|
2944
2882
|
let context = detectContext(args, logger4);
|
|
2945
|
-
if (args.projectPath &&
|
|
2883
|
+
if (args.projectPath && fs12.existsSync(args.projectPath)) {
|
|
2946
2884
|
const projectContext = await analyzeProject2(args.projectPath, logger4);
|
|
2947
2885
|
context = mergeContexts(context, projectContext);
|
|
2948
2886
|
}
|
|
@@ -2995,10 +2933,10 @@ async function analyzeProject2(projectPath, logger4) {
|
|
|
2995
2933
|
imports: [],
|
|
2996
2934
|
scenario: ""
|
|
2997
2935
|
};
|
|
2998
|
-
const instructionsPath =
|
|
2999
|
-
if (
|
|
2936
|
+
const instructionsPath = path11.join(projectPath, ".github", "copilot-instructions.md");
|
|
2937
|
+
if (fs12.existsSync(instructionsPath)) {
|
|
3000
2938
|
try {
|
|
3001
|
-
const content =
|
|
2939
|
+
const content = fs12.readFileSync(instructionsPath, "utf-8");
|
|
3002
2940
|
const agents = extractUserAgents(content);
|
|
3003
2941
|
if (agents.length > 0) {
|
|
3004
2942
|
result.userConfiguredAgents = agents;
|
|
@@ -3011,7 +2949,7 @@ async function analyzeProject2(projectPath, logger4) {
|
|
|
3011
2949
|
const matcher = new SmartAgentMatcher(logger4);
|
|
3012
2950
|
const workspaceFolder = {
|
|
3013
2951
|
uri: { fsPath: projectPath },
|
|
3014
|
-
name:
|
|
2952
|
+
name: path11.basename(projectPath),
|
|
3015
2953
|
index: 0
|
|
3016
2954
|
};
|
|
3017
2955
|
try {
|
|
@@ -3055,7 +2993,7 @@ function detectContext(args, logger4) {
|
|
|
3055
2993
|
let fileType = "unknown";
|
|
3056
2994
|
let imports = [];
|
|
3057
2995
|
let scenario = "";
|
|
3058
|
-
if (args.currentFile &&
|
|
2996
|
+
if (args.currentFile && fs12.existsSync(args.currentFile)) {
|
|
3059
2997
|
const ext = ((_a = args.currentFile.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
|
|
3060
2998
|
const extMap = {
|
|
3061
2999
|
"vue": "vue",
|
|
@@ -3067,7 +3005,7 @@ function detectContext(args, logger4) {
|
|
|
3067
3005
|
};
|
|
3068
3006
|
fileType = extMap[ext] || "unknown";
|
|
3069
3007
|
try {
|
|
3070
|
-
const content =
|
|
3008
|
+
const content = fs12.readFileSync(args.currentFile, "utf-8");
|
|
3071
3009
|
imports = extractImports(content);
|
|
3072
3010
|
scenario = inferScenario(content, fileType);
|
|
3073
3011
|
} catch {
|
|
@@ -3384,8 +3322,11 @@ function inferScenario(content, fileType) {
|
|
|
3384
3322
|
}
|
|
3385
3323
|
|
|
3386
3324
|
// src/tools/getStandardById.ts
|
|
3387
|
-
import * as
|
|
3388
|
-
import * as
|
|
3325
|
+
import * as fs13 from "fs";
|
|
3326
|
+
import * as path12 from "path";
|
|
3327
|
+
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
3328
|
+
var __filename7 = fileURLToPath7(import.meta.url);
|
|
3329
|
+
var __dirname7 = path12.dirname(__filename7);
|
|
3389
3330
|
var STANDARD_DIRS = [
|
|
3390
3331
|
"standards/core",
|
|
3391
3332
|
"standards/frameworks",
|
|
@@ -3423,7 +3364,7 @@ async function getStandardById(args) {
|
|
|
3423
3364
|
continue;
|
|
3424
3365
|
}
|
|
3425
3366
|
try {
|
|
3426
|
-
const fullContent =
|
|
3367
|
+
const fullContent = fs13.readFileSync(filePath, "utf-8");
|
|
3427
3368
|
const content = formatContent(fullContent, mode);
|
|
3428
3369
|
results.push({
|
|
3429
3370
|
id,
|
|
@@ -3480,33 +3421,40 @@ function ensureCache() {
|
|
|
3480
3421
|
standardsCache = /* @__PURE__ */ new Map();
|
|
3481
3422
|
const baseDir = findBaseDir();
|
|
3482
3423
|
for (const dir of STANDARD_DIRS) {
|
|
3483
|
-
const fullDir =
|
|
3484
|
-
if (!
|
|
3424
|
+
const fullDir = path12.join(baseDir, dir);
|
|
3425
|
+
if (!fs13.existsSync(fullDir)) continue;
|
|
3485
3426
|
scanDirectory(fullDir, standardsCache);
|
|
3486
3427
|
}
|
|
3487
3428
|
}
|
|
3488
3429
|
function findBaseDir() {
|
|
3489
3430
|
const possiblePaths = [
|
|
3431
|
+
path12.join(__dirname7, ".."),
|
|
3432
|
+
// npm 包内: build/ -> mcp-server/
|
|
3433
|
+
path12.join(__dirname7, "..", ".."),
|
|
3434
|
+
// 开发时: src/tools -> mcp-server/
|
|
3435
|
+
path12.join(__dirname7, "..", "..", ".."),
|
|
3436
|
+
// 备选
|
|
3490
3437
|
process.cwd(),
|
|
3491
|
-
|
|
3492
|
-
path11.join(__dirname, "..", "..", "..")
|
|
3438
|
+
path12.join(process.cwd(), "..")
|
|
3493
3439
|
];
|
|
3494
3440
|
for (const p of possiblePaths) {
|
|
3495
|
-
|
|
3441
|
+
const standardsPath = path12.join(p, "standards");
|
|
3442
|
+
if (fs13.existsSync(standardsPath)) {
|
|
3496
3443
|
return p;
|
|
3497
3444
|
}
|
|
3498
3445
|
}
|
|
3446
|
+
console.error("\u26A0\uFE0F \u65E0\u6CD5\u627E\u5230 standards \u76EE\u5F55\uFF0C\u5C1D\u8BD5\u7684\u8DEF\u5F84:", possiblePaths);
|
|
3499
3447
|
return process.cwd();
|
|
3500
3448
|
}
|
|
3501
3449
|
function scanDirectory(dir, cache) {
|
|
3502
|
-
const items =
|
|
3450
|
+
const items = fs13.readdirSync(dir);
|
|
3503
3451
|
for (const item of items) {
|
|
3504
|
-
const fullPath =
|
|
3505
|
-
const stat =
|
|
3452
|
+
const fullPath = path12.join(dir, item);
|
|
3453
|
+
const stat = fs13.statSync(fullPath);
|
|
3506
3454
|
if (stat.isDirectory()) {
|
|
3507
3455
|
scanDirectory(fullPath, cache);
|
|
3508
3456
|
} else if (item.endsWith(".md")) {
|
|
3509
|
-
const id =
|
|
3457
|
+
const id = path12.basename(item, ".md");
|
|
3510
3458
|
cache.set(id, fullPath);
|
|
3511
3459
|
}
|
|
3512
3460
|
}
|
|
@@ -3753,10 +3701,10 @@ async function listScenarios() {
|
|
|
3753
3701
|
}
|
|
3754
3702
|
|
|
3755
3703
|
// src/core/templates/discovery.ts
|
|
3756
|
-
import * as
|
|
3757
|
-
import * as
|
|
3758
|
-
var TEMPLATES_DIR =
|
|
3759
|
-
|
|
3704
|
+
import * as fs14 from "fs";
|
|
3705
|
+
import * as path13 from "path";
|
|
3706
|
+
var TEMPLATES_DIR = path13.resolve(
|
|
3707
|
+
path13.dirname(new URL(import.meta.url).pathname),
|
|
3760
3708
|
"../../../../templates"
|
|
3761
3709
|
);
|
|
3762
3710
|
var templatesCache = null;
|
|
@@ -3766,15 +3714,15 @@ function ensureCache2() {
|
|
|
3766
3714
|
scanTemplates(TEMPLATES_DIR, "");
|
|
3767
3715
|
}
|
|
3768
3716
|
function scanTemplates(dir, prefix) {
|
|
3769
|
-
if (!
|
|
3770
|
-
const entries =
|
|
3717
|
+
if (!fs14.existsSync(dir)) return;
|
|
3718
|
+
const entries = fs14.readdirSync(dir, { withFileTypes: true });
|
|
3771
3719
|
for (const entry of entries) {
|
|
3772
3720
|
if (!entry.isDirectory()) continue;
|
|
3773
3721
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
3774
|
-
const fullPath =
|
|
3722
|
+
const fullPath = path13.join(dir, entry.name);
|
|
3775
3723
|
const templateId = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
3776
|
-
const configPath =
|
|
3777
|
-
if (
|
|
3724
|
+
const configPath = path13.join(fullPath, "_CONFIG.md");
|
|
3725
|
+
if (fs14.existsSync(configPath)) {
|
|
3778
3726
|
const metadata = parseConfigMd(configPath, templateId, fullPath);
|
|
3779
3727
|
if (metadata) {
|
|
3780
3728
|
templatesCache.set(templateId, metadata);
|
|
@@ -3785,7 +3733,7 @@ function scanTemplates(dir, prefix) {
|
|
|
3785
3733
|
}
|
|
3786
3734
|
function parseConfigMd(configPath, templateId, templateDir) {
|
|
3787
3735
|
try {
|
|
3788
|
-
const content =
|
|
3736
|
+
const content = fs14.readFileSync(configPath, "utf-8");
|
|
3789
3737
|
const titleMatch = content.match(/^#\s+(.+)$/m);
|
|
3790
3738
|
const name = titleMatch ? titleMatch[1].trim() : templateId;
|
|
3791
3739
|
const descMatch = content.match(/^>\s*(.+)$/m);
|
|
@@ -3828,14 +3776,14 @@ function inferTemplateType(templateId, name) {
|
|
|
3828
3776
|
}
|
|
3829
3777
|
function getTemplateFiles(dir, prefix = "") {
|
|
3830
3778
|
const files = [];
|
|
3831
|
-
const entries =
|
|
3779
|
+
const entries = fs14.readdirSync(dir, { withFileTypes: true });
|
|
3832
3780
|
for (const entry of entries) {
|
|
3833
3781
|
const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
3834
3782
|
if (entry.name === "_CONFIG.md" || entry.name === "_template.json") {
|
|
3835
3783
|
continue;
|
|
3836
3784
|
}
|
|
3837
3785
|
if (entry.isDirectory()) {
|
|
3838
|
-
files.push(...getTemplateFiles(
|
|
3786
|
+
files.push(...getTemplateFiles(path13.join(dir, entry.name), relativePath));
|
|
3839
3787
|
} else {
|
|
3840
3788
|
files.push(relativePath);
|
|
3841
3789
|
}
|
|
@@ -3890,9 +3838,9 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3890
3838
|
ensureCache2();
|
|
3891
3839
|
const metadata = templatesCache.get(templateId);
|
|
3892
3840
|
if (!metadata) return null;
|
|
3893
|
-
const templateDir =
|
|
3894
|
-
const configPath =
|
|
3895
|
-
const configGuide =
|
|
3841
|
+
const templateDir = path13.join(TEMPLATES_DIR, templateId);
|
|
3842
|
+
const configPath = path13.join(templateDir, "_CONFIG.md");
|
|
3843
|
+
const configGuide = fs14.existsSync(configPath) ? fs14.readFileSync(configPath, "utf-8") : "";
|
|
3896
3844
|
const result = {
|
|
3897
3845
|
metadata,
|
|
3898
3846
|
configGuide
|
|
@@ -3900,11 +3848,11 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3900
3848
|
if (includeFiles) {
|
|
3901
3849
|
result.files = [];
|
|
3902
3850
|
for (const filePath of metadata.files) {
|
|
3903
|
-
const fullPath =
|
|
3904
|
-
if (
|
|
3851
|
+
const fullPath = path13.join(templateDir, filePath);
|
|
3852
|
+
if (fs14.existsSync(fullPath)) {
|
|
3905
3853
|
result.files.push({
|
|
3906
3854
|
path: filePath,
|
|
3907
|
-
content:
|
|
3855
|
+
content: fs14.readFileSync(fullPath, "utf-8"),
|
|
3908
3856
|
isConfig: filePath.startsWith("_")
|
|
3909
3857
|
});
|
|
3910
3858
|
}
|
|
@@ -3915,7 +3863,7 @@ function getTemplateById(templateId, includeFiles = false) {
|
|
|
3915
3863
|
function getTemplateDir(templateId) {
|
|
3916
3864
|
ensureCache2();
|
|
3917
3865
|
if (!templatesCache.has(templateId)) return null;
|
|
3918
|
-
return
|
|
3866
|
+
return path13.join(TEMPLATES_DIR, templateId);
|
|
3919
3867
|
}
|
|
3920
3868
|
function searchTemplates(query) {
|
|
3921
3869
|
const lower = query.toLowerCase();
|
|
@@ -4028,12 +3976,12 @@ async function getTemplate(args) {
|
|
|
4028
3976
|
}
|
|
4029
3977
|
|
|
4030
3978
|
// src/tools/cloneProject.ts
|
|
4031
|
-
import * as
|
|
4032
|
-
import * as
|
|
3979
|
+
import * as fs16 from "fs";
|
|
3980
|
+
import * as path15 from "path";
|
|
4033
3981
|
|
|
4034
3982
|
// src/core/projectCloneAnalyzer.ts
|
|
4035
|
-
import * as
|
|
4036
|
-
import * as
|
|
3983
|
+
import * as fs15 from "fs";
|
|
3984
|
+
import * as path14 from "path";
|
|
4037
3985
|
import glob3 from "fast-glob";
|
|
4038
3986
|
var ProjectCloneAnalyzer = class {
|
|
4039
3987
|
constructor(logger4) {
|
|
@@ -4044,10 +3992,10 @@ var ProjectCloneAnalyzer = class {
|
|
|
4044
3992
|
*/
|
|
4045
3993
|
async analyzeProject(projectPath) {
|
|
4046
3994
|
this.logger.log(`\u{1F50D} \u5F00\u59CB\u6DF1\u5EA6\u5206\u6790\u9879\u76EE: ${projectPath}`);
|
|
4047
|
-
if (!
|
|
3995
|
+
if (!fs15.existsSync(projectPath)) {
|
|
4048
3996
|
throw new Error(`\u9879\u76EE\u8DEF\u5F84\u4E0D\u5B58\u5728: ${projectPath}`);
|
|
4049
3997
|
}
|
|
4050
|
-
const projectName =
|
|
3998
|
+
const projectName = path14.basename(projectPath);
|
|
4051
3999
|
const projectType = await this.detectProjectType(projectPath);
|
|
4052
4000
|
this.logger.log(`\u{1F4E6} \u68C0\u6D4B\u5230\u9879\u76EE\u7C7B\u578B: ${projectType}`);
|
|
4053
4001
|
let result;
|
|
@@ -4073,13 +4021,13 @@ var ProjectCloneAnalyzer = class {
|
|
|
4073
4021
|
* 检测项目类型
|
|
4074
4022
|
*/
|
|
4075
4023
|
async detectProjectType(projectPath) {
|
|
4076
|
-
if (
|
|
4024
|
+
if (fs15.existsSync(path14.join(projectPath, "pubspec.yaml"))) {
|
|
4077
4025
|
return "flutter";
|
|
4078
4026
|
}
|
|
4079
|
-
const packageJsonPath =
|
|
4080
|
-
if (
|
|
4027
|
+
const packageJsonPath = path14.join(projectPath, "package.json");
|
|
4028
|
+
if (fs15.existsSync(packageJsonPath)) {
|
|
4081
4029
|
try {
|
|
4082
|
-
const pkg = JSON.parse(
|
|
4030
|
+
const pkg = JSON.parse(fs15.readFileSync(packageJsonPath, "utf-8"));
|
|
4083
4031
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
4084
4032
|
if (deps["vue"]) return "vue";
|
|
4085
4033
|
if (deps["react"]) return "react";
|
|
@@ -4232,10 +4180,10 @@ var ProjectCloneAnalyzer = class {
|
|
|
4232
4180
|
* 分析 package.json
|
|
4233
4181
|
*/
|
|
4234
4182
|
async analyzePackageJson(projectPath, result) {
|
|
4235
|
-
const packageJsonPath =
|
|
4236
|
-
if (!
|
|
4183
|
+
const packageJsonPath = path14.join(projectPath, "package.json");
|
|
4184
|
+
if (!fs15.existsSync(packageJsonPath)) return;
|
|
4237
4185
|
try {
|
|
4238
|
-
const pkg = JSON.parse(
|
|
4186
|
+
const pkg = JSON.parse(fs15.readFileSync(packageJsonPath, "utf-8"));
|
|
4239
4187
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
4240
4188
|
if (deps["vite"]) result.techStack.buildTool = "Vite";
|
|
4241
4189
|
else if (deps["webpack"]) result.techStack.buildTool = "Webpack";
|
|
@@ -4254,10 +4202,10 @@ var ProjectCloneAnalyzer = class {
|
|
|
4254
4202
|
* 分析 pubspec.yaml
|
|
4255
4203
|
*/
|
|
4256
4204
|
async analyzePubspec(projectPath, result) {
|
|
4257
|
-
const pubspecPath =
|
|
4258
|
-
if (!
|
|
4205
|
+
const pubspecPath = path14.join(projectPath, "pubspec.yaml");
|
|
4206
|
+
if (!fs15.existsSync(pubspecPath)) return;
|
|
4259
4207
|
try {
|
|
4260
|
-
const content =
|
|
4208
|
+
const content = fs15.readFileSync(pubspecPath, "utf-8");
|
|
4261
4209
|
if (content.includes("flutter_bloc:") || content.includes("bloc:")) {
|
|
4262
4210
|
result.techStack.stateManagement = "BLoC";
|
|
4263
4211
|
} else if (content.includes("provider:")) {
|
|
@@ -4274,8 +4222,8 @@ var ProjectCloneAnalyzer = class {
|
|
|
4274
4222
|
*/
|
|
4275
4223
|
async analyzeVueArchitecture(projectPath) {
|
|
4276
4224
|
const layers = [];
|
|
4277
|
-
const srcPath =
|
|
4278
|
-
if (!
|
|
4225
|
+
const srcPath = path14.join(projectPath, "src");
|
|
4226
|
+
if (!fs15.existsSync(srcPath)) {
|
|
4279
4227
|
return layers;
|
|
4280
4228
|
}
|
|
4281
4229
|
const directoryChecks = [
|
|
@@ -4299,8 +4247,8 @@ var ProjectCloneAnalyzer = class {
|
|
|
4299
4247
|
{ dir: "types", name: "\u7C7B\u578B\u5B9A\u4E49", desc: "TypeScript \u7C7B\u578B", reusable: true, priority: 3 }
|
|
4300
4248
|
];
|
|
4301
4249
|
for (const check of directoryChecks) {
|
|
4302
|
-
const dirPath =
|
|
4303
|
-
if (
|
|
4250
|
+
const dirPath = path14.join(srcPath, check.dir);
|
|
4251
|
+
if (fs15.existsSync(dirPath)) {
|
|
4304
4252
|
const files = await glob3("**/*", { cwd: dirPath, onlyFiles: true });
|
|
4305
4253
|
layers.push({
|
|
4306
4254
|
name: check.name,
|
|
@@ -4321,8 +4269,8 @@ var ProjectCloneAnalyzer = class {
|
|
|
4321
4269
|
*/
|
|
4322
4270
|
async analyzeFlutterArchitecture(projectPath) {
|
|
4323
4271
|
const layers = [];
|
|
4324
|
-
const libPath =
|
|
4325
|
-
if (!
|
|
4272
|
+
const libPath = path14.join(projectPath, "lib");
|
|
4273
|
+
if (!fs15.existsSync(libPath)) {
|
|
4326
4274
|
return layers;
|
|
4327
4275
|
}
|
|
4328
4276
|
const directoryChecks = [
|
|
@@ -4341,8 +4289,8 @@ var ProjectCloneAnalyzer = class {
|
|
|
4341
4289
|
{ dir: "l10n", name: "\u56FD\u9645\u5316", desc: "\u591A\u8BED\u8A00", reusable: true, priority: 3 }
|
|
4342
4290
|
];
|
|
4343
4291
|
for (const check of directoryChecks) {
|
|
4344
|
-
const dirPath =
|
|
4345
|
-
if (
|
|
4292
|
+
const dirPath = path14.join(libPath, check.dir);
|
|
4293
|
+
if (fs15.existsSync(dirPath)) {
|
|
4346
4294
|
const files = await glob3("**/*.dart", { cwd: dirPath });
|
|
4347
4295
|
layers.push({
|
|
4348
4296
|
name: check.name,
|
|
@@ -4362,16 +4310,16 @@ var ProjectCloneAnalyzer = class {
|
|
|
4362
4310
|
*/
|
|
4363
4311
|
async analyzeUtilities(projectPath, type) {
|
|
4364
4312
|
const utilities = [];
|
|
4365
|
-
const basePath = type === "flutter" ?
|
|
4366
|
-
if (!
|
|
4313
|
+
const basePath = type === "flutter" ? path14.join(projectPath, "lib") : path14.join(projectPath, "src");
|
|
4314
|
+
if (!fs15.existsSync(basePath)) return utilities;
|
|
4367
4315
|
const utilDirs = ["utils", "util", "helpers", "lib", "common", "shared"];
|
|
4368
4316
|
const fileExt = type === "flutter" ? "**/*.dart" : "**/*.{ts,js}";
|
|
4369
4317
|
for (const dir of utilDirs) {
|
|
4370
|
-
const dirPath =
|
|
4371
|
-
if (!
|
|
4318
|
+
const dirPath = path14.join(basePath, dir);
|
|
4319
|
+
if (!fs15.existsSync(dirPath)) continue;
|
|
4372
4320
|
const files = await glob3(fileExt, { cwd: dirPath });
|
|
4373
4321
|
for (const file of files) {
|
|
4374
|
-
const filePath =
|
|
4322
|
+
const filePath = path14.join(dirPath, file);
|
|
4375
4323
|
const analysis = await this.analyzeUtilityFile(filePath, type);
|
|
4376
4324
|
if (analysis) {
|
|
4377
4325
|
utilities.push(analysis);
|
|
@@ -4380,11 +4328,11 @@ var ProjectCloneAnalyzer = class {
|
|
|
4380
4328
|
}
|
|
4381
4329
|
const apiDirs = ["api", "services", "http"];
|
|
4382
4330
|
for (const dir of apiDirs) {
|
|
4383
|
-
const dirPath =
|
|
4384
|
-
if (!
|
|
4331
|
+
const dirPath = path14.join(basePath, dir);
|
|
4332
|
+
if (!fs15.existsSync(dirPath)) continue;
|
|
4385
4333
|
const files = await glob3(fileExt, { cwd: dirPath });
|
|
4386
4334
|
for (const file of files) {
|
|
4387
|
-
const filePath =
|
|
4335
|
+
const filePath = path14.join(dirPath, file);
|
|
4388
4336
|
const analysis = await this.analyzeUtilityFile(filePath, type);
|
|
4389
4337
|
if (analysis) {
|
|
4390
4338
|
analysis.type = "http";
|
|
@@ -4403,7 +4351,7 @@ var ProjectCloneAnalyzer = class {
|
|
|
4403
4351
|
*/
|
|
4404
4352
|
async analyzeUtilityFile(filePath, type) {
|
|
4405
4353
|
try {
|
|
4406
|
-
const content =
|
|
4354
|
+
const content = fs15.readFileSync(filePath, "utf-8");
|
|
4407
4355
|
const relativePath = filePath;
|
|
4408
4356
|
const exports = [];
|
|
4409
4357
|
if (type === "flutter") {
|
|
@@ -4425,7 +4373,7 @@ var ProjectCloneAnalyzer = class {
|
|
|
4425
4373
|
}
|
|
4426
4374
|
let utilType = "other";
|
|
4427
4375
|
const lowerContent = content.toLowerCase();
|
|
4428
|
-
const fileName =
|
|
4376
|
+
const fileName = path14.basename(filePath).toLowerCase();
|
|
4429
4377
|
if (lowerContent.includes("axios") || lowerContent.includes("fetch") || lowerContent.includes("http") || fileName.includes("request")) {
|
|
4430
4378
|
utilType = "http";
|
|
4431
4379
|
} else if (lowerContent.includes("localstorage") || lowerContent.includes("sessionstorage") || fileName.includes("storage")) {
|
|
@@ -4477,14 +4425,14 @@ var ProjectCloneAnalyzer = class {
|
|
|
4477
4425
|
* 计算工具类使用频率
|
|
4478
4426
|
*/
|
|
4479
4427
|
async calculateUsageCount(projectPath, utilities, type) {
|
|
4480
|
-
const basePath = type === "flutter" ?
|
|
4428
|
+
const basePath = type === "flutter" ? path14.join(projectPath, "lib") : path14.join(projectPath, "src");
|
|
4481
4429
|
const fileExt = type === "flutter" ? "**/*.dart" : "**/*.{ts,js,vue,tsx,jsx}";
|
|
4482
4430
|
const files = await glob3(fileExt, { cwd: basePath, ignore: ["node_modules/**"] });
|
|
4483
4431
|
for (const file of files) {
|
|
4484
4432
|
try {
|
|
4485
|
-
const content =
|
|
4433
|
+
const content = fs15.readFileSync(path14.join(basePath, file), "utf-8");
|
|
4486
4434
|
for (const util of utilities) {
|
|
4487
|
-
const utilName =
|
|
4435
|
+
const utilName = path14.basename(util.path, path14.extname(util.path));
|
|
4488
4436
|
if (content.includes(utilName)) {
|
|
4489
4437
|
util.usageCount++;
|
|
4490
4438
|
}
|
|
@@ -4512,13 +4460,13 @@ var ProjectCloneAnalyzer = class {
|
|
|
4512
4460
|
result.themeFiles = themeFiles;
|
|
4513
4461
|
return result;
|
|
4514
4462
|
}
|
|
4515
|
-
const srcPath =
|
|
4516
|
-
if (!
|
|
4463
|
+
const srcPath = path14.join(projectPath, "src");
|
|
4464
|
+
if (!fs15.existsSync(srcPath)) return result;
|
|
4517
4465
|
const stylePatterns = ["**/*.css", "**/*.scss", "**/*.sass", "**/*.less", "**/*.styl"];
|
|
4518
4466
|
for (const pattern of stylePatterns) {
|
|
4519
4467
|
const files = await glob3(pattern, { cwd: srcPath, ignore: ["node_modules/**"] });
|
|
4520
4468
|
for (const file of files) {
|
|
4521
|
-
const ext =
|
|
4469
|
+
const ext = path14.extname(file).slice(1);
|
|
4522
4470
|
if (ext === "scss" || ext === "sass") result.preprocessor = ext;
|
|
4523
4471
|
else if (ext === "less") result.preprocessor = "less";
|
|
4524
4472
|
else if (ext === "styl") result.preprocessor = "stylus";
|
|
@@ -4564,20 +4512,20 @@ var ProjectCloneAnalyzer = class {
|
|
|
4564
4512
|
if (type === "flutter") {
|
|
4565
4513
|
return result;
|
|
4566
4514
|
}
|
|
4567
|
-
if (
|
|
4515
|
+
if (fs15.existsSync(path14.join(projectPath, "vite.config.ts"))) {
|
|
4568
4516
|
result.buildConfig = {
|
|
4569
4517
|
tool: "vite",
|
|
4570
4518
|
configFile: "vite.config.ts",
|
|
4571
4519
|
keyFeatures: []
|
|
4572
4520
|
};
|
|
4573
|
-
} else if (
|
|
4521
|
+
} else if (fs15.existsSync(path14.join(projectPath, "vue.config.js"))) {
|
|
4574
4522
|
result.buildConfig = {
|
|
4575
4523
|
tool: "webpack",
|
|
4576
4524
|
configFile: "vue.config.js",
|
|
4577
4525
|
keyFeatures: []
|
|
4578
4526
|
};
|
|
4579
4527
|
}
|
|
4580
|
-
const srcPath =
|
|
4528
|
+
const srcPath = path14.join(projectPath, "src");
|
|
4581
4529
|
const routerFiles = await glob3("**/router/**/*.{ts,js}", { cwd: srcPath });
|
|
4582
4530
|
if (routerFiles.length > 0) {
|
|
4583
4531
|
result.routerConfig = {
|
|
@@ -4603,7 +4551,7 @@ var ProjectCloneAnalyzer = class {
|
|
|
4603
4551
|
}
|
|
4604
4552
|
const i18nFiles = await glob3("**/{i18n,locales}/**/*.{ts,js,json}", { cwd: srcPath });
|
|
4605
4553
|
if (i18nFiles.length > 0) {
|
|
4606
|
-
const locales = i18nFiles.filter((f) => f.endsWith(".json")).map((f) =>
|
|
4554
|
+
const locales = i18nFiles.filter((f) => f.endsWith(".json")).map((f) => path14.basename(f, ".json"));
|
|
4607
4555
|
result.i18nConfig = {
|
|
4608
4556
|
type: "vue-i18n",
|
|
4609
4557
|
configFile: i18nFiles.find((f) => f.includes("index")) || i18nFiles[0],
|
|
@@ -4623,8 +4571,8 @@ var ProjectCloneAnalyzer = class {
|
|
|
4623
4571
|
errorPages: [],
|
|
4624
4572
|
otherCorePages: []
|
|
4625
4573
|
};
|
|
4626
|
-
const basePath = type === "flutter" ?
|
|
4627
|
-
if (!
|
|
4574
|
+
const basePath = type === "flutter" ? path14.join(projectPath, "lib") : path14.join(projectPath, "src");
|
|
4575
|
+
if (!fs15.existsSync(basePath)) return result;
|
|
4628
4576
|
const fileExt = type === "flutter" ? "**/*.dart" : "**/*.{vue,tsx,jsx}";
|
|
4629
4577
|
const files = await glob3(fileExt, { cwd: basePath });
|
|
4630
4578
|
for (const file of files) {
|
|
@@ -4826,7 +4774,7 @@ async function analyzeReferenceProject(args) {
|
|
|
4826
4774
|
}]
|
|
4827
4775
|
};
|
|
4828
4776
|
}
|
|
4829
|
-
if (!
|
|
4777
|
+
if (!fs16.existsSync(args.projectPath)) {
|
|
4830
4778
|
return {
|
|
4831
4779
|
content: [{
|
|
4832
4780
|
type: "text",
|
|
@@ -4941,7 +4889,7 @@ async function generateProjectSkeleton(args) {
|
|
|
4941
4889
|
}]
|
|
4942
4890
|
};
|
|
4943
4891
|
}
|
|
4944
|
-
if (!
|
|
4892
|
+
if (!fs16.existsSync(args.referenceProjectPath)) {
|
|
4945
4893
|
return {
|
|
4946
4894
|
content: [{
|
|
4947
4895
|
type: "text",
|
|
@@ -4957,8 +4905,8 @@ async function generateProjectSkeleton(args) {
|
|
|
4957
4905
|
const analyzer = new ProjectCloneAnalyzer(logger4);
|
|
4958
4906
|
const analysis = await analyzer.analyzeProject(args.referenceProjectPath);
|
|
4959
4907
|
const developmentPlan = analyzer.generateDevelopmentPlan(analysis, args.newProjectName);
|
|
4960
|
-
if (!
|
|
4961
|
-
|
|
4908
|
+
if (!fs16.existsSync(args.newProjectPath)) {
|
|
4909
|
+
fs16.mkdirSync(args.newProjectPath, { recursive: true });
|
|
4962
4910
|
}
|
|
4963
4911
|
if (args.generateDocs !== false) {
|
|
4964
4912
|
await generateAnalysisDocs(args.newProjectPath, analysis, developmentPlan);
|
|
@@ -5000,18 +4948,18 @@ async function generateProjectSkeleton(args) {
|
|
|
5000
4948
|
}
|
|
5001
4949
|
}
|
|
5002
4950
|
async function generateAnalysisDocs(targetPath, analysis, plan) {
|
|
5003
|
-
const docsPath =
|
|
5004
|
-
if (!
|
|
5005
|
-
|
|
4951
|
+
const docsPath = path15.join(targetPath, "docs");
|
|
4952
|
+
if (!fs16.existsSync(docsPath)) {
|
|
4953
|
+
fs16.mkdirSync(docsPath, { recursive: true });
|
|
5006
4954
|
}
|
|
5007
4955
|
const analysisDoc = generateAnalysisMarkdown(analysis);
|
|
5008
|
-
|
|
4956
|
+
fs16.writeFileSync(path15.join(docsPath, "PROJECT_ANALYSIS.md"), analysisDoc);
|
|
5009
4957
|
if (plan) {
|
|
5010
4958
|
const planDoc = generatePlanMarkdown(plan);
|
|
5011
|
-
|
|
4959
|
+
fs16.writeFileSync(path15.join(docsPath, "DEVELOPMENT_PLAN.md"), planDoc);
|
|
5012
4960
|
}
|
|
5013
4961
|
const skeletonDoc = generateSkeletonMarkdown(analysis);
|
|
5014
|
-
|
|
4962
|
+
fs16.writeFileSync(path15.join(docsPath, "SKELETON_CHECKLIST.md"), skeletonDoc);
|
|
5015
4963
|
}
|
|
5016
4964
|
function generateAnalysisMarkdown(analysis) {
|
|
5017
4965
|
var _a, _b, _c, _d;
|
|
@@ -5193,8 +5141,8 @@ function generateSkeletonGuide(analysis, args) {
|
|
|
5193
5141
|
var _a;
|
|
5194
5142
|
return {
|
|
5195
5143
|
directories: analysis.skeleton.requiredDirectories.map((d) => ({
|
|
5196
|
-
from:
|
|
5197
|
-
to:
|
|
5144
|
+
from: path15.join(args.referenceProjectPath, "src", d.path),
|
|
5145
|
+
to: path15.join(args.newProjectPath, "src", d.path),
|
|
5198
5146
|
description: d.description
|
|
5199
5147
|
})),
|
|
5200
5148
|
coreUtils: analysis.skeleton.coreUtils.map((u) => ({
|
|
@@ -5229,8 +5177,8 @@ function groupBy(arr, key) {
|
|
|
5229
5177
|
|
|
5230
5178
|
// src/tools/queryTroubleshootingCases.ts
|
|
5231
5179
|
init_resourceLoader();
|
|
5232
|
-
import * as
|
|
5233
|
-
import * as
|
|
5180
|
+
import * as fs18 from "fs";
|
|
5181
|
+
import * as path17 from "path";
|
|
5234
5182
|
|
|
5235
5183
|
// src/core/errors.ts
|
|
5236
5184
|
var ERROR_MESSAGES = {
|
|
@@ -5406,8 +5354,8 @@ function createLogger(name) {
|
|
|
5406
5354
|
}
|
|
5407
5355
|
|
|
5408
5356
|
// src/core/autoConfig.ts
|
|
5409
|
-
import * as
|
|
5410
|
-
import * as
|
|
5357
|
+
import * as fs17 from "fs";
|
|
5358
|
+
import * as path16 from "path";
|
|
5411
5359
|
var checkedWorkspaces = /* @__PURE__ */ new Map();
|
|
5412
5360
|
var CACHE_DURATION = 5 * 60 * 1e3;
|
|
5413
5361
|
function ensureWorkspaceConfig(workspacePath) {
|
|
@@ -5417,7 +5365,7 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
5417
5365
|
wasFixed: false,
|
|
5418
5366
|
workspacePath
|
|
5419
5367
|
};
|
|
5420
|
-
if (!workspacePath || !
|
|
5368
|
+
if (!workspacePath || !fs17.existsSync(workspacePath)) {
|
|
5421
5369
|
return result;
|
|
5422
5370
|
}
|
|
5423
5371
|
const cached = checkedWorkspaces.get(workspacePath);
|
|
@@ -5425,13 +5373,13 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
5425
5373
|
if (cached && cached.configured && now - cached.timestamp < CACHE_DURATION) {
|
|
5426
5374
|
return result;
|
|
5427
5375
|
}
|
|
5428
|
-
const vscodeDir =
|
|
5429
|
-
const mcpJsonPath =
|
|
5430
|
-
const settingsPath =
|
|
5376
|
+
const vscodeDir = path16.join(workspacePath, ".vscode");
|
|
5377
|
+
const mcpJsonPath = path16.join(vscodeDir, "mcp.json");
|
|
5378
|
+
const settingsPath = path16.join(vscodeDir, "settings.json");
|
|
5431
5379
|
let hasMtaConfig = false;
|
|
5432
|
-
if (
|
|
5380
|
+
if (fs17.existsSync(mcpJsonPath)) {
|
|
5433
5381
|
try {
|
|
5434
|
-
const config = JSON.parse(
|
|
5382
|
+
const config = JSON.parse(fs17.readFileSync(mcpJsonPath, "utf-8"));
|
|
5435
5383
|
hasMtaConfig = !!(((_a = config.servers) == null ? void 0 : _a.mta) || ((_b = config.mcpServers) == null ? void 0 : _b.mta));
|
|
5436
5384
|
} catch {
|
|
5437
5385
|
}
|
|
@@ -5442,13 +5390,13 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
5442
5390
|
}
|
|
5443
5391
|
result.needsSetup = true;
|
|
5444
5392
|
try {
|
|
5445
|
-
if (!
|
|
5446
|
-
|
|
5393
|
+
if (!fs17.existsSync(vscodeDir)) {
|
|
5394
|
+
fs17.mkdirSync(vscodeDir, { recursive: true });
|
|
5447
5395
|
}
|
|
5448
5396
|
let mcpConfig = { servers: {} };
|
|
5449
|
-
if (
|
|
5397
|
+
if (fs17.existsSync(mcpJsonPath)) {
|
|
5450
5398
|
try {
|
|
5451
|
-
mcpConfig = JSON.parse(
|
|
5399
|
+
mcpConfig = JSON.parse(fs17.readFileSync(mcpJsonPath, "utf-8"));
|
|
5452
5400
|
if (!mcpConfig.servers) {
|
|
5453
5401
|
mcpConfig.servers = {};
|
|
5454
5402
|
}
|
|
@@ -5461,21 +5409,21 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
5461
5409
|
args: ["-y", "mta-mcp"],
|
|
5462
5410
|
env: {}
|
|
5463
5411
|
};
|
|
5464
|
-
|
|
5412
|
+
fs17.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
5465
5413
|
let settings = {};
|
|
5466
|
-
if (
|
|
5414
|
+
if (fs17.existsSync(settingsPath)) {
|
|
5467
5415
|
try {
|
|
5468
|
-
settings = JSON.parse(
|
|
5416
|
+
settings = JSON.parse(fs17.readFileSync(settingsPath, "utf-8"));
|
|
5469
5417
|
} catch {
|
|
5470
5418
|
settings = {};
|
|
5471
5419
|
}
|
|
5472
5420
|
}
|
|
5473
5421
|
if (!settings["github.copilot.chat.mcp.enabled"]) {
|
|
5474
5422
|
settings["github.copilot.chat.mcp.enabled"] = true;
|
|
5475
|
-
|
|
5423
|
+
fs17.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
5476
5424
|
}
|
|
5477
5425
|
result.wasFixed = true;
|
|
5478
|
-
result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${
|
|
5426
|
+
result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${path16.basename(workspacePath)} \u914D\u7F6E MTA MCP\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3\u4F7F\u914D\u7F6E\u751F\u6548\u3002`;
|
|
5479
5427
|
checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
|
|
5480
5428
|
} catch (error) {
|
|
5481
5429
|
result.message = `\u26A0\uFE0F \u81EA\u52A8\u914D\u7F6E\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -5487,10 +5435,10 @@ function ensureWorkspaceConfig(workspacePath) {
|
|
|
5487
5435
|
var logger2 = createLogger("QueryTroubleshootingCases");
|
|
5488
5436
|
function extractCaseMetadata(filePath, framework) {
|
|
5489
5437
|
try {
|
|
5490
|
-
const content =
|
|
5438
|
+
const content = fs18.readFileSync(filePath, "utf-8");
|
|
5491
5439
|
const lines = content.split("\n");
|
|
5492
5440
|
const titleLine = lines.find((l) => l.trim().startsWith("# "));
|
|
5493
|
-
const title = titleLine ? titleLine.replace(/^#\s*/, "").trim() :
|
|
5441
|
+
const title = titleLine ? titleLine.replace(/^#\s*/, "").trim() : path17.basename(filePath, ".md");
|
|
5494
5442
|
let tags = [];
|
|
5495
5443
|
let problemType = "";
|
|
5496
5444
|
let severity = "\u4E2D\u7B49";
|
|
@@ -5520,7 +5468,7 @@ function extractCaseMetadata(filePath, framework) {
|
|
|
5520
5468
|
if (timeSavedMatch) {
|
|
5521
5469
|
timeSaved = timeSavedMatch[1] || `${timeSavedMatch[2]}\u8F6E\u5BF9\u8BDD`;
|
|
5522
5470
|
}
|
|
5523
|
-
const id =
|
|
5471
|
+
const id = path17.basename(filePath, ".md");
|
|
5524
5472
|
return {
|
|
5525
5473
|
id,
|
|
5526
5474
|
framework,
|
|
@@ -5563,7 +5511,7 @@ function calculateMatchScore(caseData, keywords, errorMessage) {
|
|
|
5563
5511
|
}
|
|
5564
5512
|
if (errorMessage && errorMessage.trim()) {
|
|
5565
5513
|
const errorLower = errorMessage.toLowerCase();
|
|
5566
|
-
const caseContent =
|
|
5514
|
+
const caseContent = fs18.readFileSync(caseData.filePath, "utf-8").toLowerCase();
|
|
5567
5515
|
const errorKeywords = errorLower.match(/\b[\u4e00-\u9fa5a-z]{4,}\b/g) || [];
|
|
5568
5516
|
const uniqueKeywords = [...new Set(errorKeywords)];
|
|
5569
5517
|
let matches = 0;
|
|
@@ -5585,7 +5533,7 @@ function calculateMatchScore(caseData, keywords, errorMessage) {
|
|
|
5585
5533
|
}
|
|
5586
5534
|
function generatePreview(filePath) {
|
|
5587
5535
|
try {
|
|
5588
|
-
const content =
|
|
5536
|
+
const content = fs18.readFileSync(filePath, "utf-8");
|
|
5589
5537
|
const lines = content.split("\n");
|
|
5590
5538
|
let sectionStart = lines.findIndex(
|
|
5591
5539
|
(l) => l.includes("## \u2705 \u6B63\u786E\u89E3\u51B3\u65B9\u6848") || l.includes("### \u6838\u5FC3\u539F\u7406")
|
|
@@ -5630,7 +5578,7 @@ async function queryTroubleshootingCases(params) {
|
|
|
5630
5578
|
try {
|
|
5631
5579
|
const loader = new ResourceLoader();
|
|
5632
5580
|
const troubleshootingDir = loader.getResourceDir("troubleshooting");
|
|
5633
|
-
if (!
|
|
5581
|
+
if (!fs18.existsSync(troubleshootingDir)) {
|
|
5634
5582
|
logger2.warn("\u6545\u969C\u6392\u9664\u76EE\u5F55\u4E0D\u5B58\u5728:", troubleshootingDir);
|
|
5635
5583
|
return {
|
|
5636
5584
|
cases: [],
|
|
@@ -5643,21 +5591,21 @@ async function queryTroubleshootingCases(params) {
|
|
|
5643
5591
|
if (framework) {
|
|
5644
5592
|
frameworksToSearch.push(framework);
|
|
5645
5593
|
} else {
|
|
5646
|
-
const dirs =
|
|
5594
|
+
const dirs = fs18.readdirSync(troubleshootingDir);
|
|
5647
5595
|
for (const dir of dirs) {
|
|
5648
|
-
const dirPath =
|
|
5649
|
-
if (
|
|
5596
|
+
const dirPath = path17.join(troubleshootingDir, dir);
|
|
5597
|
+
if (fs18.statSync(dirPath).isDirectory()) {
|
|
5650
5598
|
frameworksToSearch.push(dir);
|
|
5651
5599
|
}
|
|
5652
5600
|
}
|
|
5653
5601
|
}
|
|
5654
5602
|
for (const fw of frameworksToSearch) {
|
|
5655
|
-
const fwDir =
|
|
5656
|
-
if (!
|
|
5657
|
-
const files =
|
|
5603
|
+
const fwDir = path17.join(troubleshootingDir, fw);
|
|
5604
|
+
if (!fs18.existsSync(fwDir)) continue;
|
|
5605
|
+
const files = fs18.readdirSync(fwDir);
|
|
5658
5606
|
for (const file of files) {
|
|
5659
5607
|
if (!file.endsWith(".md") || file === "README.md") continue;
|
|
5660
|
-
const filePath =
|
|
5608
|
+
const filePath = path17.join(fwDir, file);
|
|
5661
5609
|
const metadata = extractCaseMetadata(filePath, fw);
|
|
5662
5610
|
if (metadata) {
|
|
5663
5611
|
allCases.push(metadata);
|
|
@@ -5704,11 +5652,11 @@ async function getTroubleshootingCaseContent(params) {
|
|
|
5704
5652
|
try {
|
|
5705
5653
|
const loader = new ResourceLoader();
|
|
5706
5654
|
const troubleshootingDir = loader.getResourceDir("troubleshooting");
|
|
5707
|
-
const casePath =
|
|
5708
|
-
if (!
|
|
5655
|
+
const casePath = path17.join(troubleshootingDir, framework, `${caseId}.md`);
|
|
5656
|
+
if (!fs18.existsSync(casePath)) {
|
|
5709
5657
|
throw new Error(`\u6848\u4F8B\u4E0D\u5B58\u5728: ${framework}/${caseId}`);
|
|
5710
5658
|
}
|
|
5711
|
-
const content =
|
|
5659
|
+
const content = fs18.readFileSync(casePath, "utf-8");
|
|
5712
5660
|
const metadata = extractCaseMetadata(casePath, framework);
|
|
5713
5661
|
return { content, metadata };
|
|
5714
5662
|
} catch (error) {
|
|
@@ -5722,19 +5670,19 @@ async function listTroubleshootingCases(framework) {
|
|
|
5722
5670
|
const troubleshootingDir = loader.getResourceDir("troubleshooting");
|
|
5723
5671
|
const frameworks = [];
|
|
5724
5672
|
const allCases = [];
|
|
5725
|
-
if (!
|
|
5673
|
+
if (!fs18.existsSync(troubleshootingDir)) {
|
|
5726
5674
|
return { cases: [], frameworks: [] };
|
|
5727
5675
|
}
|
|
5728
|
-
const dirs =
|
|
5676
|
+
const dirs = fs18.readdirSync(troubleshootingDir);
|
|
5729
5677
|
for (const dir of dirs) {
|
|
5730
|
-
const dirPath =
|
|
5731
|
-
if (!
|
|
5678
|
+
const dirPath = path17.join(troubleshootingDir, dir);
|
|
5679
|
+
if (!fs18.statSync(dirPath).isDirectory()) continue;
|
|
5732
5680
|
if (framework && dir !== framework) continue;
|
|
5733
5681
|
frameworks.push(dir);
|
|
5734
|
-
const files =
|
|
5682
|
+
const files = fs18.readdirSync(dirPath);
|
|
5735
5683
|
for (const file of files) {
|
|
5736
5684
|
if (!file.endsWith(".md") || file === "README.md") continue;
|
|
5737
|
-
const filePath =
|
|
5685
|
+
const filePath = path17.join(dirPath, file);
|
|
5738
5686
|
const metadata = extractCaseMetadata(filePath, dir);
|
|
5739
5687
|
if (metadata) {
|
|
5740
5688
|
allCases.push(metadata);
|