mta-mcp 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2835,12 +2835,18 @@ function generateRecommendations(checks) {
2835
2835
 
2836
2836
  // src/tools/getCompactStandards.ts
2837
2837
  import * as fs9 from "fs";
2838
+ import * as path9 from "path";
2839
+ init_smartAgentMatcher();
2838
2840
  async function getCompactStandards(args) {
2839
2841
  const logger3 = new ConsoleLogger();
2840
2842
  const manager = new StandardsManager();
2841
2843
  const mode = args.mode || "key-rules";
2842
2844
  try {
2843
- const context = detectContext(args, logger3);
2845
+ let context = detectContext(args, logger3);
2846
+ if (args.projectPath && fs9.existsSync(args.projectPath)) {
2847
+ const projectContext = await analyzeProject2(args.projectPath, logger3);
2848
+ context = mergeContexts(context, projectContext);
2849
+ }
2844
2850
  const standardUris = manager.getRelevantStandards({
2845
2851
  fileType: context.fileType,
2846
2852
  imports: context.imports,
@@ -2858,6 +2864,13 @@ async function getCompactStandards(args) {
2858
2864
  responseContent = buildFullResponse(standardUris, manager);
2859
2865
  break;
2860
2866
  }
2867
+ if (args.projectPath && context.userConfiguredAgents) {
2868
+ responseContent.projectInfo = {
2869
+ hasUserConfig: true,
2870
+ userAgents: context.userConfiguredAgents,
2871
+ message: "\u2705 \u5DF2\u8BFB\u53D6\u7528\u6237\u914D\u7F6E\u7684 Agents\uFF0C\u5E76\u8865\u5145\u4E86\u7F3A\u5931\u7684\u89C4\u8303"
2872
+ };
2873
+ }
2861
2874
  return {
2862
2875
  content: [{
2863
2876
  type: "text",
@@ -2876,6 +2889,68 @@ async function getCompactStandards(args) {
2876
2889
  };
2877
2890
  }
2878
2891
  }
2892
+ async function analyzeProject2(projectPath, logger3) {
2893
+ var _a, _b;
2894
+ const result = {
2895
+ fileType: "unknown",
2896
+ imports: [],
2897
+ scenario: ""
2898
+ };
2899
+ const instructionsPath = path9.join(projectPath, ".github", "copilot-instructions.md");
2900
+ if (fs9.existsSync(instructionsPath)) {
2901
+ try {
2902
+ const content = fs9.readFileSync(instructionsPath, "utf-8");
2903
+ const agents = extractUserAgents(content);
2904
+ if (agents.length > 0) {
2905
+ result.userConfiguredAgents = agents;
2906
+ logger3.log(`\u2705 \u68C0\u6D4B\u5230\u7528\u6237\u914D\u7F6E\u7684 Agents: ${agents.join(", ")}`);
2907
+ }
2908
+ } catch (error) {
2909
+ logger3.error(`\u8BFB\u53D6\u7528\u6237\u914D\u7F6E\u5931\u8D25: ${error}`);
2910
+ }
2911
+ }
2912
+ const matcher = new SmartAgentMatcher(logger3);
2913
+ const workspaceFolder = {
2914
+ uri: { fsPath: projectPath },
2915
+ name: path9.basename(projectPath),
2916
+ index: 0
2917
+ };
2918
+ try {
2919
+ const features = await matcher.analyzeProject(workspaceFolder);
2920
+ if ((_a = features.frameworks) == null ? void 0 : _a.includes("vue")) {
2921
+ result.fileType = "vue";
2922
+ result.imports.push("vue");
2923
+ }
2924
+ if ((_b = features.frameworks) == null ? void 0 : _b.includes("flutter")) {
2925
+ result.fileType = "dart";
2926
+ result.imports.push("flutter");
2927
+ }
2928
+ if (features.libraries) {
2929
+ result.imports.push(...features.libraries);
2930
+ }
2931
+ logger3.log(`\u{1F50D} \u9879\u76EE\u6280\u672F\u6808: ${result.imports.join(", ")}`);
2932
+ } catch (error) {
2933
+ logger3.error(`\u9879\u76EE\u5206\u6790\u5931\u8D25: ${error}`);
2934
+ }
2935
+ return result;
2936
+ }
2937
+ function extractUserAgents(content) {
2938
+ const agents = [];
2939
+ const agentIdRegex = /- \*\*Agent ID\*\*:\s*`([^`]+)`/g;
2940
+ let match;
2941
+ while ((match = agentIdRegex.exec(content)) !== null) {
2942
+ agents.push(match[1]);
2943
+ }
2944
+ return agents;
2945
+ }
2946
+ function mergeContexts(fileContext, projectContext) {
2947
+ return {
2948
+ fileType: fileContext.fileType !== "unknown" ? fileContext.fileType : projectContext.fileType,
2949
+ imports: [.../* @__PURE__ */ new Set([...fileContext.imports, ...projectContext.imports])],
2950
+ scenario: fileContext.scenario || projectContext.scenario,
2951
+ userConfiguredAgents: projectContext.userConfiguredAgents
2952
+ };
2953
+ }
2879
2954
  function detectContext(args, logger3) {
2880
2955
  var _a;
2881
2956
  let fileType = "unknown";
@@ -3211,7 +3286,7 @@ function inferScenario(content, fileType) {
3211
3286
 
3212
3287
  // src/tools/getStandardById.ts
3213
3288
  import * as fs10 from "fs";
3214
- import * as path9 from "path";
3289
+ import * as path10 from "path";
3215
3290
  var STANDARD_DIRS = [
3216
3291
  "standards/core",
3217
3292
  "standards/frameworks",
@@ -3306,7 +3381,7 @@ function ensureCache() {
3306
3381
  standardsCache = /* @__PURE__ */ new Map();
3307
3382
  const baseDir = findBaseDir();
3308
3383
  for (const dir of STANDARD_DIRS) {
3309
- const fullDir = path9.join(baseDir, dir);
3384
+ const fullDir = path10.join(baseDir, dir);
3310
3385
  if (!fs10.existsSync(fullDir)) continue;
3311
3386
  scanDirectory(fullDir, standardsCache);
3312
3387
  }
@@ -3314,11 +3389,11 @@ function ensureCache() {
3314
3389
  function findBaseDir() {
3315
3390
  const possiblePaths = [
3316
3391
  process.cwd(),
3317
- path9.join(process.cwd(), ".."),
3318
- path9.join(__dirname, "..", "..", "..")
3392
+ path10.join(process.cwd(), ".."),
3393
+ path10.join(__dirname, "..", "..", "..")
3319
3394
  ];
3320
3395
  for (const p of possiblePaths) {
3321
- if (fs10.existsSync(path9.join(p, "standards"))) {
3396
+ if (fs10.existsSync(path10.join(p, "standards"))) {
3322
3397
  return p;
3323
3398
  }
3324
3399
  }
@@ -3327,12 +3402,12 @@ function findBaseDir() {
3327
3402
  function scanDirectory(dir, cache) {
3328
3403
  const items = fs10.readdirSync(dir);
3329
3404
  for (const item of items) {
3330
- const fullPath = path9.join(dir, item);
3405
+ const fullPath = path10.join(dir, item);
3331
3406
  const stat = fs10.statSync(fullPath);
3332
3407
  if (stat.isDirectory()) {
3333
3408
  scanDirectory(fullPath, cache);
3334
3409
  } else if (item.endsWith(".md")) {
3335
- const id = path9.basename(item, ".md");
3410
+ const id = path10.basename(item, ".md");
3336
3411
  cache.set(id, fullPath);
3337
3412
  }
3338
3413
  }
@@ -3576,9 +3651,9 @@ async function listScenarios() {
3576
3651
 
3577
3652
  // src/core/templates/discovery.ts
3578
3653
  import * as fs11 from "fs";
3579
- import * as path10 from "path";
3580
- var TEMPLATES_DIR = path10.resolve(
3581
- path10.dirname(new URL(import.meta.url).pathname),
3654
+ import * as path11 from "path";
3655
+ var TEMPLATES_DIR = path11.resolve(
3656
+ path11.dirname(new URL(import.meta.url).pathname),
3582
3657
  "../../../../templates"
3583
3658
  );
3584
3659
  var templatesCache = null;
@@ -3593,9 +3668,9 @@ function scanTemplates(dir, prefix) {
3593
3668
  for (const entry of entries) {
3594
3669
  if (!entry.isDirectory()) continue;
3595
3670
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
3596
- const fullPath = path10.join(dir, entry.name);
3671
+ const fullPath = path11.join(dir, entry.name);
3597
3672
  const templateId = prefix ? `${prefix}/${entry.name}` : entry.name;
3598
- const configPath = path10.join(fullPath, "_CONFIG.md");
3673
+ const configPath = path11.join(fullPath, "_CONFIG.md");
3599
3674
  if (fs11.existsSync(configPath)) {
3600
3675
  const metadata = parseConfigMd(configPath, templateId, fullPath);
3601
3676
  if (metadata) {
@@ -3657,7 +3732,7 @@ function getTemplateFiles(dir, prefix = "") {
3657
3732
  continue;
3658
3733
  }
3659
3734
  if (entry.isDirectory()) {
3660
- files.push(...getTemplateFiles(path10.join(dir, entry.name), relativePath));
3735
+ files.push(...getTemplateFiles(path11.join(dir, entry.name), relativePath));
3661
3736
  } else {
3662
3737
  files.push(relativePath);
3663
3738
  }
@@ -3712,8 +3787,8 @@ function getTemplateById(templateId, includeFiles = false) {
3712
3787
  ensureCache2();
3713
3788
  const metadata = templatesCache.get(templateId);
3714
3789
  if (!metadata) return null;
3715
- const templateDir = path10.join(TEMPLATES_DIR, templateId);
3716
- const configPath = path10.join(templateDir, "_CONFIG.md");
3790
+ const templateDir = path11.join(TEMPLATES_DIR, templateId);
3791
+ const configPath = path11.join(templateDir, "_CONFIG.md");
3717
3792
  const configGuide = fs11.existsSync(configPath) ? fs11.readFileSync(configPath, "utf-8") : "";
3718
3793
  const result = {
3719
3794
  metadata,
@@ -3722,7 +3797,7 @@ function getTemplateById(templateId, includeFiles = false) {
3722
3797
  if (includeFiles) {
3723
3798
  result.files = [];
3724
3799
  for (const filePath of metadata.files) {
3725
- const fullPath = path10.join(templateDir, filePath);
3800
+ const fullPath = path11.join(templateDir, filePath);
3726
3801
  if (fs11.existsSync(fullPath)) {
3727
3802
  result.files.push({
3728
3803
  path: filePath,
@@ -3737,7 +3812,7 @@ function getTemplateById(templateId, includeFiles = false) {
3737
3812
  function getTemplateDir(templateId) {
3738
3813
  ensureCache2();
3739
3814
  if (!templatesCache.has(templateId)) return null;
3740
- return path10.join(TEMPLATES_DIR, templateId);
3815
+ return path11.join(TEMPLATES_DIR, templateId);
3741
3816
  }
3742
3817
  function searchTemplates(query) {
3743
3818
  const lower = query.toLowerCase();
@@ -4024,7 +4099,7 @@ function createLogger(name) {
4024
4099
 
4025
4100
  // src/core/autoConfig.ts
4026
4101
  import * as fs12 from "fs";
4027
- import * as path11 from "path";
4102
+ import * as path12 from "path";
4028
4103
  var checkedWorkspaces = /* @__PURE__ */ new Map();
4029
4104
  var CACHE_DURATION = 5 * 60 * 1e3;
4030
4105
  function ensureWorkspaceConfig(workspacePath) {
@@ -4042,9 +4117,9 @@ function ensureWorkspaceConfig(workspacePath) {
4042
4117
  if (cached && cached.configured && now - cached.timestamp < CACHE_DURATION) {
4043
4118
  return result;
4044
4119
  }
4045
- const vscodeDir = path11.join(workspacePath, ".vscode");
4046
- const mcpJsonPath = path11.join(vscodeDir, "mcp.json");
4047
- const settingsPath = path11.join(vscodeDir, "settings.json");
4120
+ const vscodeDir = path12.join(workspacePath, ".vscode");
4121
+ const mcpJsonPath = path12.join(vscodeDir, "mcp.json");
4122
+ const settingsPath = path12.join(vscodeDir, "settings.json");
4048
4123
  let hasMtaConfig = false;
4049
4124
  if (fs12.existsSync(mcpJsonPath)) {
4050
4125
  try {
@@ -4092,7 +4167,7 @@ function ensureWorkspaceConfig(workspacePath) {
4092
4167
  fs12.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
4093
4168
  }
4094
4169
  result.wasFixed = true;
4095
- result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${path11.basename(workspacePath)} \u914D\u7F6E MTA MCP\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3\u4F7F\u914D\u7F6E\u751F\u6548\u3002`;
4170
+ result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${path12.basename(workspacePath)} \u914D\u7F6E MTA MCP\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3\u4F7F\u914D\u7F6E\u751F\u6548\u3002`;
4096
4171
  checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
4097
4172
  } catch (error) {
4098
4173
  result.message = `\u26A0\uFE0F \u81EA\u52A8\u914D\u7F6E\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`;
@@ -4306,7 +4381,16 @@ var CopilotPromptsMCPServer = class {
4306
4381
  },
4307
4382
  {
4308
4383
  name: "get_compact_standards",
4309
- description: "\u83B7\u53D6\u89C4\u8303\uFF08\u652F\u6301 summary/key-rules/full \u4E09\u79CD\u6A21\u5F0F\uFF0C\u9ED8\u8BA4 key-rules\uFF09",
4384
+ description: `\u83B7\u53D6\u7F16\u7801\u89C4\u8303\uFF08\u667A\u80FD\u6A21\u5F0F\uFF09
4385
+ \u529F\u80FD\uFF1A
4386
+ 1. \u81EA\u52A8\u5206\u6790\u9879\u76EE\u6280\u672F\u6808\uFF08\u901A\u8FC7 projectPath\uFF09
4387
+ 2. \u5982\u679C\u5B58\u5728 copilot-instructions.md\uFF0C\u4F18\u5148\u4F7F\u7528\u7528\u6237\u914D\u7F6E\u7684 Agents
4388
+ 3. \u667A\u80FD\u8865\u5145\u7528\u6237\u672A\u914D\u7F6E\u7684\u89C4\u8303
4389
+ 4. \u652F\u6301 summary/key-rules/full \u4E09\u79CD\u8FD4\u56DE\u6A21\u5F0F
4390
+
4391
+ \u4F7F\u7528\u573A\u666F\uFF1A
4392
+ - @mta \u8C03\u7528\u65F6\uFF0C\u4F20\u5165 projectPath \u83B7\u53D6\u5B8C\u6574\u9879\u76EE\u89C4\u8303
4393
+ - \u7F16\u5199\u4EE3\u7801\u65F6\uFF0C\u4F20\u5165 fileContent \u83B7\u53D6\u6587\u4EF6\u76F8\u5173\u89C4\u8303`,
4310
4394
  inputSchema: {
4311
4395
  type: "object",
4312
4396
  properties: {
@@ -4318,6 +4402,10 @@ var CopilotPromptsMCPServer = class {
4318
4402
  type: "string",
4319
4403
  description: "\u6587\u4EF6\u5185\u5BB9\uFF08\u53EF\u9009\uFF09"
4320
4404
  },
4405
+ projectPath: {
4406
+ type: "string",
4407
+ description: "\u9879\u76EE\u6839\u8DEF\u5F84\uFF08\u63A8\u8350\uFF09- \u4F1A\u81EA\u52A8\u5206\u6790\u9879\u76EE\u6280\u672F\u6808\u5E76\u8BFB\u53D6\u7528\u6237\u914D\u7F6E"
4408
+ },
4321
4409
  scenario: {
4322
4410
  type: "string",
4323
4411
  description: "\u5F00\u53D1\u573A\u666F\uFF08\u53EF\u9009\uFF09"
@@ -4325,7 +4413,7 @@ var CopilotPromptsMCPServer = class {
4325
4413
  mode: {
4326
4414
  type: "string",
4327
4415
  enum: ["summary", "key-rules", "full"],
4328
- description: "\u8FD4\u56DE\u6A21\u5F0F",
4416
+ description: "\u8FD4\u56DE\u6A21\u5F0F\uFF1Asummary(\u6458\u8981)/key-rules(\u5173\u952E\u89C4\u5219,\u9ED8\u8BA4)/full(\u5B8C\u6574\u5185\u5BB9)",
4329
4417
  default: "key-rules"
4330
4418
  }
4331
4419
  }