mta-mcp 2.12.0 → 2.13.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
@@ -3623,7 +3623,11 @@ var SCENARIO_STANDARDS = {
3623
3623
  // ========== 特殊场景 ==========
3624
3624
  "logicflow": ["logicflow", "vue3-composition"],
3625
3625
  "permission": ["permission-design", "route-guard"],
3626
- "performance": ["performance-optimization", "lazy-loading"]
3626
+ "performance": ["performance-optimization", "lazy-loading"],
3627
+ // ========== 项目克隆场景 ==========
3628
+ "clone-project": ["project-structure", "architecture-patterns", "code-organization"],
3629
+ "project-skeleton": ["project-structure", "base-config", "utility-patterns"],
3630
+ "style-migration": ["css-architecture", "theme-system", "ui-customization"]
3627
3631
  };
3628
3632
  var FILETYPE_STANDARDS = {
3629
3633
  "vue": ["vue3-composition"],
@@ -4023,6 +4027,1206 @@ async function getTemplate(args) {
4023
4027
  }
4024
4028
  }
4025
4029
 
4030
+ // src/tools/cloneProject.ts
4031
+ import * as fs15 from "fs";
4032
+ import * as path14 from "path";
4033
+
4034
+ // src/core/projectCloneAnalyzer.ts
4035
+ import * as fs14 from "fs";
4036
+ import * as path13 from "path";
4037
+ import glob3 from "fast-glob";
4038
+ var ProjectCloneAnalyzer = class {
4039
+ constructor(logger3) {
4040
+ this.logger = logger3 || new ConsoleLogger();
4041
+ }
4042
+ /**
4043
+ * 深度分析项目
4044
+ */
4045
+ async analyzeProject(projectPath) {
4046
+ this.logger.log(`\u{1F50D} \u5F00\u59CB\u6DF1\u5EA6\u5206\u6790\u9879\u76EE: ${projectPath}`);
4047
+ if (!fs14.existsSync(projectPath)) {
4048
+ throw new Error(`\u9879\u76EE\u8DEF\u5F84\u4E0D\u5B58\u5728: ${projectPath}`);
4049
+ }
4050
+ const projectName = path13.basename(projectPath);
4051
+ const projectType = await this.detectProjectType(projectPath);
4052
+ this.logger.log(`\u{1F4E6} \u68C0\u6D4B\u5230\u9879\u76EE\u7C7B\u578B: ${projectType}`);
4053
+ let result;
4054
+ switch (projectType) {
4055
+ case "vue":
4056
+ result = await this.analyzeVueProject(projectPath, projectName);
4057
+ break;
4058
+ case "react":
4059
+ result = await this.analyzeReactProject(projectPath, projectName);
4060
+ break;
4061
+ case "flutter":
4062
+ result = await this.analyzeFlutterProject(projectPath, projectName);
4063
+ break;
4064
+ default:
4065
+ result = await this.analyzeGenericProject(projectPath, projectName);
4066
+ }
4067
+ result.qualityAssessment = this.assessQuality(result);
4068
+ result.templateSuggestions = this.suggestTemplates(result);
4069
+ this.logger.log(`\u2705 \u9879\u76EE\u5206\u6790\u5B8C\u6210`);
4070
+ return result;
4071
+ }
4072
+ /**
4073
+ * 检测项目类型
4074
+ */
4075
+ async detectProjectType(projectPath) {
4076
+ if (fs14.existsSync(path13.join(projectPath, "pubspec.yaml"))) {
4077
+ return "flutter";
4078
+ }
4079
+ const packageJsonPath = path13.join(projectPath, "package.json");
4080
+ if (fs14.existsSync(packageJsonPath)) {
4081
+ try {
4082
+ const pkg = JSON.parse(fs14.readFileSync(packageJsonPath, "utf-8"));
4083
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
4084
+ if (deps["vue"]) return "vue";
4085
+ if (deps["react"]) return "react";
4086
+ } catch {
4087
+ }
4088
+ }
4089
+ const vueFiles = await glob3("**/*.vue", { cwd: projectPath, ignore: ["node_modules/**"] });
4090
+ if (vueFiles.length > 0) return "vue";
4091
+ const tsxFiles = await glob3("**/*.tsx", { cwd: projectPath, ignore: ["node_modules/**"] });
4092
+ if (tsxFiles.length > 0) return "react";
4093
+ return "generic";
4094
+ }
4095
+ /**
4096
+ * 分析 Vue 项目
4097
+ */
4098
+ async analyzeVueProject(projectPath, projectName) {
4099
+ const result = {
4100
+ success: true,
4101
+ projectName,
4102
+ projectPath,
4103
+ analyzedAt: (/* @__PURE__ */ new Date()).toISOString(),
4104
+ techStack: {
4105
+ framework: "Vue 3",
4106
+ language: "TypeScript",
4107
+ buildTool: "Vite",
4108
+ uiLibrary: null,
4109
+ stateManagement: null
4110
+ },
4111
+ architectureLayers: [],
4112
+ utilities: [],
4113
+ styleSystem: await this.analyzeStyleSystem(projectPath, "vue"),
4114
+ configSystem: await this.analyzeConfigSystem(projectPath, "vue"),
4115
+ corePages: await this.analyzeCorePages(projectPath, "vue"),
4116
+ skeleton: {
4117
+ requiredDirectories: [],
4118
+ coreUtils: [],
4119
+ styleSystem: await this.analyzeStyleSystem(projectPath, "vue"),
4120
+ configSystem: await this.analyzeConfigSystem(projectPath, "vue"),
4121
+ corePages: await this.analyzeCorePages(projectPath, "vue"),
4122
+ businessFilesToRemove: [],
4123
+ filesToClean: []
4124
+ },
4125
+ qualityAssessment: {
4126
+ score: 0,
4127
+ strengths: [],
4128
+ weaknesses: [],
4129
+ suggestions: []
4130
+ },
4131
+ templateSuggestions: []
4132
+ };
4133
+ await this.analyzePackageJson(projectPath, result);
4134
+ result.architectureLayers = await this.analyzeVueArchitecture(projectPath);
4135
+ result.utilities = await this.analyzeUtilities(projectPath, "vue");
4136
+ result.skeleton = this.generateSkeleton(result);
4137
+ return result;
4138
+ }
4139
+ /**
4140
+ * 分析 React 项目
4141
+ */
4142
+ async analyzeReactProject(projectPath, projectName) {
4143
+ const result = await this.analyzeVueProject(projectPath, projectName);
4144
+ result.techStack.framework = "React";
4145
+ return result;
4146
+ }
4147
+ /**
4148
+ * 分析 Flutter 项目
4149
+ */
4150
+ async analyzeFlutterProject(projectPath, projectName) {
4151
+ const result = {
4152
+ success: true,
4153
+ projectName,
4154
+ projectPath,
4155
+ analyzedAt: (/* @__PURE__ */ new Date()).toISOString(),
4156
+ techStack: {
4157
+ framework: "Flutter",
4158
+ language: "Dart",
4159
+ buildTool: "Flutter SDK",
4160
+ uiLibrary: "Material Design",
4161
+ stateManagement: null
4162
+ },
4163
+ architectureLayers: [],
4164
+ utilities: [],
4165
+ styleSystem: await this.analyzeStyleSystem(projectPath, "flutter"),
4166
+ configSystem: await this.analyzeConfigSystem(projectPath, "flutter"),
4167
+ corePages: await this.analyzeCorePages(projectPath, "flutter"),
4168
+ skeleton: {
4169
+ requiredDirectories: [],
4170
+ coreUtils: [],
4171
+ styleSystem: await this.analyzeStyleSystem(projectPath, "flutter"),
4172
+ configSystem: await this.analyzeConfigSystem(projectPath, "flutter"),
4173
+ corePages: await this.analyzeCorePages(projectPath, "flutter"),
4174
+ businessFilesToRemove: [],
4175
+ filesToClean: []
4176
+ },
4177
+ qualityAssessment: {
4178
+ score: 0,
4179
+ strengths: [],
4180
+ weaknesses: [],
4181
+ suggestions: []
4182
+ },
4183
+ templateSuggestions: []
4184
+ };
4185
+ await this.analyzePubspec(projectPath, result);
4186
+ result.architectureLayers = await this.analyzeFlutterArchitecture(projectPath);
4187
+ result.utilities = await this.analyzeUtilities(projectPath, "flutter");
4188
+ result.skeleton = this.generateSkeleton(result);
4189
+ return result;
4190
+ }
4191
+ /**
4192
+ * 分析通用项目
4193
+ */
4194
+ async analyzeGenericProject(projectPath, projectName) {
4195
+ const result = {
4196
+ success: true,
4197
+ projectName,
4198
+ projectPath,
4199
+ analyzedAt: (/* @__PURE__ */ new Date()).toISOString(),
4200
+ techStack: {
4201
+ framework: "Unknown",
4202
+ language: "Unknown",
4203
+ buildTool: "Unknown",
4204
+ uiLibrary: null,
4205
+ stateManagement: null
4206
+ },
4207
+ architectureLayers: [],
4208
+ utilities: [],
4209
+ styleSystem: await this.analyzeStyleSystem(projectPath, "generic"),
4210
+ configSystem: await this.analyzeConfigSystem(projectPath, "generic"),
4211
+ corePages: await this.analyzeCorePages(projectPath, "generic"),
4212
+ skeleton: {
4213
+ requiredDirectories: [],
4214
+ coreUtils: [],
4215
+ styleSystem: await this.analyzeStyleSystem(projectPath, "generic"),
4216
+ configSystem: await this.analyzeConfigSystem(projectPath, "generic"),
4217
+ corePages: await this.analyzeCorePages(projectPath, "generic"),
4218
+ businessFilesToRemove: [],
4219
+ filesToClean: []
4220
+ },
4221
+ qualityAssessment: {
4222
+ score: 0,
4223
+ strengths: [],
4224
+ weaknesses: [],
4225
+ suggestions: []
4226
+ },
4227
+ templateSuggestions: []
4228
+ };
4229
+ return result;
4230
+ }
4231
+ /**
4232
+ * 分析 package.json
4233
+ */
4234
+ async analyzePackageJson(projectPath, result) {
4235
+ const packageJsonPath = path13.join(projectPath, "package.json");
4236
+ if (!fs14.existsSync(packageJsonPath)) return;
4237
+ try {
4238
+ const pkg = JSON.parse(fs14.readFileSync(packageJsonPath, "utf-8"));
4239
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
4240
+ if (deps["vite"]) result.techStack.buildTool = "Vite";
4241
+ else if (deps["webpack"]) result.techStack.buildTool = "Webpack";
4242
+ if (deps["element-plus"]) result.techStack.uiLibrary = "Element Plus";
4243
+ else if (deps["ant-design-vue"]) result.techStack.uiLibrary = "Ant Design Vue";
4244
+ else if (deps["naive-ui"]) result.techStack.uiLibrary = "Naive UI";
4245
+ if (deps["pinia"]) result.techStack.stateManagement = "Pinia";
4246
+ else if (deps["vuex"]) result.techStack.stateManagement = "Vuex";
4247
+ if (deps["typescript"]) result.techStack.language = "TypeScript";
4248
+ else result.techStack.language = "JavaScript";
4249
+ } catch (error) {
4250
+ this.logger.error(`\u89E3\u6790 package.json \u5931\u8D25: ${error}`);
4251
+ }
4252
+ }
4253
+ /**
4254
+ * 分析 pubspec.yaml
4255
+ */
4256
+ async analyzePubspec(projectPath, result) {
4257
+ const pubspecPath = path13.join(projectPath, "pubspec.yaml");
4258
+ if (!fs14.existsSync(pubspecPath)) return;
4259
+ try {
4260
+ const content = fs14.readFileSync(pubspecPath, "utf-8");
4261
+ if (content.includes("flutter_bloc:") || content.includes("bloc:")) {
4262
+ result.techStack.stateManagement = "BLoC";
4263
+ } else if (content.includes("provider:")) {
4264
+ result.techStack.stateManagement = "Provider";
4265
+ } else if (content.includes("riverpod:")) {
4266
+ result.techStack.stateManagement = "Riverpod";
4267
+ }
4268
+ } catch (error) {
4269
+ this.logger.error(`\u89E3\u6790 pubspec.yaml \u5931\u8D25: ${error}`);
4270
+ }
4271
+ }
4272
+ /**
4273
+ * 分析 Vue 项目架构
4274
+ */
4275
+ async analyzeVueArchitecture(projectPath) {
4276
+ const layers = [];
4277
+ const srcPath = path13.join(projectPath, "src");
4278
+ if (!fs14.existsSync(srcPath)) {
4279
+ return layers;
4280
+ }
4281
+ const directoryChecks = [
4282
+ { dir: "api", name: "API \u5C42", desc: "HTTP \u8BF7\u6C42\u5C01\u88C5", reusable: true, priority: 2 },
4283
+ { dir: "utils", name: "\u5DE5\u5177\u5C42", desc: "\u901A\u7528\u5DE5\u5177\u51FD\u6570", reusable: true, priority: 3 },
4284
+ { dir: "composables", name: "Composables", desc: "Vue \u7EC4\u5408\u5F0F\u51FD\u6570", reusable: true, priority: 4 },
4285
+ { dir: "hooks", name: "Hooks", desc: "Vue \u7EC4\u5408\u5F0F\u51FD\u6570", reusable: true, priority: 4 },
4286
+ { dir: "stores", name: "\u72B6\u6001\u7BA1\u7406", desc: "Pinia/Vuex \u72B6\u6001", reusable: false, priority: 5 },
4287
+ { dir: "store", name: "\u72B6\u6001\u7BA1\u7406", desc: "Pinia/Vuex \u72B6\u6001", reusable: false, priority: 5 },
4288
+ { dir: "router", name: "\u8DEF\u7531\u5C42", desc: "\u8DEF\u7531\u914D\u7F6E", reusable: true, priority: 3 },
4289
+ { dir: "components", name: "\u7EC4\u4EF6\u5C42", desc: "Vue \u7EC4\u4EF6", reusable: false, priority: 6 },
4290
+ { dir: "views", name: "\u89C6\u56FE\u5C42", desc: "\u9875\u9762\u7EC4\u4EF6", reusable: false, priority: 7 },
4291
+ { dir: "pages", name: "\u9875\u9762\u5C42", desc: "\u9875\u9762\u7EC4\u4EF6", reusable: false, priority: 7 },
4292
+ { dir: "assets", name: "\u8D44\u6E90\u5C42", desc: "\u9759\u6001\u8D44\u6E90", reusable: true, priority: 8 },
4293
+ { dir: "styles", name: "\u6837\u5F0F\u5C42", desc: "\u5168\u5C40\u6837\u5F0F", reusable: true, priority: 2 },
4294
+ { dir: "locales", name: "\u56FD\u9645\u5316", desc: "\u591A\u8BED\u8A00\u914D\u7F6E", reusable: true, priority: 4 },
4295
+ { dir: "i18n", name: "\u56FD\u9645\u5316", desc: "\u591A\u8BED\u8A00\u914D\u7F6E", reusable: true, priority: 4 },
4296
+ { dir: "config", name: "\u914D\u7F6E\u5C42", desc: "\u5E94\u7528\u914D\u7F6E", reusable: true, priority: 2 },
4297
+ { dir: "directives", name: "\u6307\u4EE4\u5C42", desc: "Vue \u81EA\u5B9A\u4E49\u6307\u4EE4", reusable: true, priority: 5 },
4298
+ { dir: "plugins", name: "\u63D2\u4EF6\u5C42", desc: "Vue \u63D2\u4EF6", reusable: true, priority: 4 },
4299
+ { dir: "types", name: "\u7C7B\u578B\u5B9A\u4E49", desc: "TypeScript \u7C7B\u578B", reusable: true, priority: 3 }
4300
+ ];
4301
+ for (const check of directoryChecks) {
4302
+ const dirPath = path13.join(srcPath, check.dir);
4303
+ if (fs14.existsSync(dirPath)) {
4304
+ const files = await glob3("**/*", { cwd: dirPath, onlyFiles: true });
4305
+ layers.push({
4306
+ name: check.name,
4307
+ description: check.desc,
4308
+ directories: [check.dir],
4309
+ keyFiles: files.slice(0, 10),
4310
+ // 只取前10个文件作为示例
4311
+ reusable: check.reusable,
4312
+ priority: check.priority
4313
+ });
4314
+ }
4315
+ }
4316
+ layers.sort((a, b) => a.priority - b.priority);
4317
+ return layers;
4318
+ }
4319
+ /**
4320
+ * 分析 Flutter 项目架构
4321
+ */
4322
+ async analyzeFlutterArchitecture(projectPath) {
4323
+ const layers = [];
4324
+ const libPath = path13.join(projectPath, "lib");
4325
+ if (!fs14.existsSync(libPath)) {
4326
+ return layers;
4327
+ }
4328
+ const directoryChecks = [
4329
+ { dir: "core", name: "\u6838\u5FC3\u5C42", desc: "\u6838\u5FC3\u529F\u80FD", reusable: true, priority: 1 },
4330
+ { dir: "data", name: "\u6570\u636E\u5C42", desc: "\u6570\u636E\u6E90\u548C\u4ED3\u5E93", reusable: false, priority: 3 },
4331
+ { dir: "domain", name: "\u9886\u57DF\u5C42", desc: "\u4E1A\u52A1\u903B\u8F91", reusable: false, priority: 4 },
4332
+ { dir: "presentation", name: "\u8868\u793A\u5C42", desc: "UI \u7EC4\u4EF6", reusable: false, priority: 5 },
4333
+ { dir: "features", name: "\u529F\u80FD\u6A21\u5757", desc: "\u529F\u80FD\u6A21\u5757", reusable: false, priority: 6 },
4334
+ { dir: "shared", name: "\u5171\u4EAB\u5C42", desc: "\u5171\u4EAB\u7EC4\u4EF6", reusable: true, priority: 2 },
4335
+ { dir: "widgets", name: "\u7EC4\u4EF6\u5C42", desc: "UI \u7EC4\u4EF6", reusable: true, priority: 4 },
4336
+ { dir: "utils", name: "\u5DE5\u5177\u5C42", desc: "\u5DE5\u5177\u51FD\u6570", reusable: true, priority: 2 },
4337
+ { dir: "services", name: "\u670D\u52A1\u5C42", desc: "\u4E1A\u52A1\u670D\u52A1", reusable: true, priority: 3 },
4338
+ { dir: "models", name: "\u6A21\u578B\u5C42", desc: "\u6570\u636E\u6A21\u578B", reusable: false, priority: 4 },
4339
+ { dir: "config", name: "\u914D\u7F6E\u5C42", desc: "\u5E94\u7528\u914D\u7F6E", reusable: true, priority: 2 },
4340
+ { dir: "theme", name: "\u4E3B\u9898\u5C42", desc: "\u4E3B\u9898\u6837\u5F0F", reusable: true, priority: 2 },
4341
+ { dir: "l10n", name: "\u56FD\u9645\u5316", desc: "\u591A\u8BED\u8A00", reusable: true, priority: 3 }
4342
+ ];
4343
+ for (const check of directoryChecks) {
4344
+ const dirPath = path13.join(libPath, check.dir);
4345
+ if (fs14.existsSync(dirPath)) {
4346
+ const files = await glob3("**/*.dart", { cwd: dirPath });
4347
+ layers.push({
4348
+ name: check.name,
4349
+ description: check.desc,
4350
+ directories: [check.dir],
4351
+ keyFiles: files.slice(0, 10),
4352
+ reusable: check.reusable,
4353
+ priority: check.priority
4354
+ });
4355
+ }
4356
+ }
4357
+ layers.sort((a, b) => a.priority - b.priority);
4358
+ return layers;
4359
+ }
4360
+ /**
4361
+ * 分析工具类
4362
+ */
4363
+ async analyzeUtilities(projectPath, type) {
4364
+ const utilities = [];
4365
+ const basePath = type === "flutter" ? path13.join(projectPath, "lib") : path13.join(projectPath, "src");
4366
+ if (!fs14.existsSync(basePath)) return utilities;
4367
+ const utilDirs = ["utils", "util", "helpers", "lib", "common", "shared"];
4368
+ const fileExt = type === "flutter" ? "**/*.dart" : "**/*.{ts,js}";
4369
+ for (const dir of utilDirs) {
4370
+ const dirPath = path13.join(basePath, dir);
4371
+ if (!fs14.existsSync(dirPath)) continue;
4372
+ const files = await glob3(fileExt, { cwd: dirPath });
4373
+ for (const file of files) {
4374
+ const filePath = path13.join(dirPath, file);
4375
+ const analysis = await this.analyzeUtilityFile(filePath, type);
4376
+ if (analysis) {
4377
+ utilities.push(analysis);
4378
+ }
4379
+ }
4380
+ }
4381
+ const apiDirs = ["api", "services", "http"];
4382
+ for (const dir of apiDirs) {
4383
+ const dirPath = path13.join(basePath, dir);
4384
+ if (!fs14.existsSync(dirPath)) continue;
4385
+ const files = await glob3(fileExt, { cwd: dirPath });
4386
+ for (const file of files) {
4387
+ const filePath = path13.join(dirPath, file);
4388
+ const analysis = await this.analyzeUtilityFile(filePath, type);
4389
+ if (analysis) {
4390
+ analysis.type = "http";
4391
+ utilities.push(analysis);
4392
+ }
4393
+ }
4394
+ }
4395
+ await this.calculateUsageCount(projectPath, utilities, type);
4396
+ for (const util of utilities) {
4397
+ util.recommended = util.usageCount > 3 || util.type === "http" || util.type === "validation" || util.type === "format";
4398
+ }
4399
+ return utilities;
4400
+ }
4401
+ /**
4402
+ * 分析单个工具类文件
4403
+ */
4404
+ async analyzeUtilityFile(filePath, type) {
4405
+ try {
4406
+ const content = fs14.readFileSync(filePath, "utf-8");
4407
+ const relativePath = filePath;
4408
+ const exports = [];
4409
+ if (type === "flutter") {
4410
+ const classMatches = content.matchAll(/class\s+(\w+)/g);
4411
+ for (const match of classMatches) {
4412
+ exports.push(match[1]);
4413
+ }
4414
+ const funcMatches = content.matchAll(/^\s*(\w+)\s*\([^)]*\)\s*{/gm);
4415
+ for (const match of funcMatches) {
4416
+ if (!["if", "for", "while", "switch", "catch"].includes(match[1])) {
4417
+ exports.push(match[1]);
4418
+ }
4419
+ }
4420
+ } else {
4421
+ const exportMatches = content.matchAll(/export\s+(?:const|function|class|interface|type)\s+(\w+)/g);
4422
+ for (const match of exportMatches) {
4423
+ exports.push(match[1]);
4424
+ }
4425
+ }
4426
+ let utilType = "other";
4427
+ const lowerContent = content.toLowerCase();
4428
+ const fileName = path13.basename(filePath).toLowerCase();
4429
+ if (lowerContent.includes("axios") || lowerContent.includes("fetch") || lowerContent.includes("http") || fileName.includes("request")) {
4430
+ utilType = "http";
4431
+ } else if (lowerContent.includes("localstorage") || lowerContent.includes("sessionstorage") || fileName.includes("storage")) {
4432
+ utilType = "storage";
4433
+ } else if (lowerContent.includes("validate") || lowerContent.includes("validator") || fileName.includes("valid")) {
4434
+ utilType = "validation";
4435
+ } else if (lowerContent.includes("format") || lowerContent.includes("date") || fileName.includes("format")) {
4436
+ utilType = "format";
4437
+ } else if (lowerContent.includes("token") || lowerContent.includes("auth") || fileName.includes("auth")) {
4438
+ utilType = "auth";
4439
+ } else if (lowerContent.includes("router") || lowerContent.includes("route")) {
4440
+ utilType = "router";
4441
+ } else if (lowerContent.includes("i18n") || lowerContent.includes("locale") || lowerContent.includes("translate")) {
4442
+ utilType = "i18n";
4443
+ }
4444
+ const dependencies = [];
4445
+ if (type === "flutter") {
4446
+ const importMatches = content.matchAll(/import\s+'package:(\w+)/g);
4447
+ for (const match of importMatches) {
4448
+ if (!dependencies.includes(match[1])) {
4449
+ dependencies.push(match[1]);
4450
+ }
4451
+ }
4452
+ } else {
4453
+ const importMatches = content.matchAll(/import\s+.*from\s+['"]([^'"]+)['"]/g);
4454
+ for (const match of importMatches) {
4455
+ const dep = match[1];
4456
+ if (!dep.startsWith(".") && !dep.startsWith("@/")) {
4457
+ const pkgName = dep.startsWith("@") ? dep.split("/").slice(0, 2).join("/") : dep.split("/")[0];
4458
+ if (!dependencies.includes(pkgName)) {
4459
+ dependencies.push(pkgName);
4460
+ }
4461
+ }
4462
+ }
4463
+ }
4464
+ return {
4465
+ path: relativePath,
4466
+ type: utilType,
4467
+ exports,
4468
+ dependencies,
4469
+ usageCount: 0,
4470
+ recommended: false
4471
+ };
4472
+ } catch (error) {
4473
+ return null;
4474
+ }
4475
+ }
4476
+ /**
4477
+ * 计算工具类使用频率
4478
+ */
4479
+ async calculateUsageCount(projectPath, utilities, type) {
4480
+ const basePath = type === "flutter" ? path13.join(projectPath, "lib") : path13.join(projectPath, "src");
4481
+ const fileExt = type === "flutter" ? "**/*.dart" : "**/*.{ts,js,vue,tsx,jsx}";
4482
+ const files = await glob3(fileExt, { cwd: basePath, ignore: ["node_modules/**"] });
4483
+ for (const file of files) {
4484
+ try {
4485
+ const content = fs14.readFileSync(path13.join(basePath, file), "utf-8");
4486
+ for (const util of utilities) {
4487
+ const utilName = path13.basename(util.path, path13.extname(util.path));
4488
+ if (content.includes(utilName)) {
4489
+ util.usageCount++;
4490
+ }
4491
+ }
4492
+ } catch {
4493
+ }
4494
+ }
4495
+ }
4496
+ /**
4497
+ * 分析样式系统
4498
+ */
4499
+ async analyzeStyleSystem(projectPath, type) {
4500
+ const result = {
4501
+ globalStyles: [],
4502
+ preprocessor: null,
4503
+ cssFrameworks: [],
4504
+ uiLibrary: null,
4505
+ uiOverrides: [],
4506
+ themeFiles: [],
4507
+ cssVariables: [],
4508
+ mixins: []
4509
+ };
4510
+ if (type === "flutter") {
4511
+ const themeFiles = await glob3("**/theme/**/*.dart", { cwd: projectPath });
4512
+ result.themeFiles = themeFiles;
4513
+ return result;
4514
+ }
4515
+ const srcPath = path13.join(projectPath, "src");
4516
+ if (!fs14.existsSync(srcPath)) return result;
4517
+ const stylePatterns = ["**/*.css", "**/*.scss", "**/*.sass", "**/*.less", "**/*.styl"];
4518
+ for (const pattern of stylePatterns) {
4519
+ const files = await glob3(pattern, { cwd: srcPath, ignore: ["node_modules/**"] });
4520
+ for (const file of files) {
4521
+ const ext = path13.extname(file).slice(1);
4522
+ if (ext === "scss" || ext === "sass") result.preprocessor = ext;
4523
+ else if (ext === "less") result.preprocessor = "less";
4524
+ else if (ext === "styl") result.preprocessor = "stylus";
4525
+ if (file.includes("global") || file.includes("base") || file.includes("main") || file.includes("app")) {
4526
+ result.globalStyles.push(file);
4527
+ }
4528
+ if (file.includes("variable") || file.includes("theme") || file.includes("token")) {
4529
+ result.themeFiles.push(file);
4530
+ }
4531
+ if (file.includes("mixin")) {
4532
+ result.mixins.push(file);
4533
+ }
4534
+ }
4535
+ }
4536
+ const overridePatterns = ["**/element*.{css,scss,less}", "**/antd*.{css,scss,less}", "**/override*.{css,scss,less}"];
4537
+ for (const pattern of overridePatterns) {
4538
+ const files = await glob3(pattern, { cwd: srcPath });
4539
+ if (files.length > 0) {
4540
+ result.uiOverrides.push({
4541
+ path: files[0],
4542
+ components: []
4543
+ // 需要进一步分析
4544
+ });
4545
+ }
4546
+ }
4547
+ return result;
4548
+ }
4549
+ /**
4550
+ * 分析配置系统
4551
+ */
4552
+ async analyzeConfigSystem(projectPath, type) {
4553
+ const result = {
4554
+ envFiles: [],
4555
+ buildConfig: null,
4556
+ routerConfig: null,
4557
+ stateConfig: null,
4558
+ httpConfig: null,
4559
+ i18nConfig: null,
4560
+ otherConfigs: []
4561
+ };
4562
+ const envFiles = await glob3(".env*", { cwd: projectPath, dot: true });
4563
+ result.envFiles = envFiles;
4564
+ if (type === "flutter") {
4565
+ return result;
4566
+ }
4567
+ if (fs14.existsSync(path13.join(projectPath, "vite.config.ts"))) {
4568
+ result.buildConfig = {
4569
+ tool: "vite",
4570
+ configFile: "vite.config.ts",
4571
+ keyFeatures: []
4572
+ };
4573
+ } else if (fs14.existsSync(path13.join(projectPath, "vue.config.js"))) {
4574
+ result.buildConfig = {
4575
+ tool: "webpack",
4576
+ configFile: "vue.config.js",
4577
+ keyFeatures: []
4578
+ };
4579
+ }
4580
+ const srcPath = path13.join(projectPath, "src");
4581
+ const routerFiles = await glob3("**/router/**/*.{ts,js}", { cwd: srcPath });
4582
+ if (routerFiles.length > 0) {
4583
+ result.routerConfig = {
4584
+ type: "vue-router",
4585
+ configFile: routerFiles[0],
4586
+ features: []
4587
+ };
4588
+ }
4589
+ const storeFiles = await glob3("**/{stores,store}/**/*.{ts,js}", { cwd: srcPath });
4590
+ if (storeFiles.length > 0) {
4591
+ result.stateConfig = {
4592
+ type: "pinia",
4593
+ configFile: storeFiles[0]
4594
+ };
4595
+ }
4596
+ const apiFiles = await glob3("**/api/**/*.{ts,js}", { cwd: srcPath });
4597
+ if (apiFiles.length > 0) {
4598
+ result.httpConfig = {
4599
+ client: "axios",
4600
+ configFile: apiFiles.find((f) => f.includes("request") || f.includes("axios") || f.includes("http")) || apiFiles[0],
4601
+ features: []
4602
+ };
4603
+ }
4604
+ const i18nFiles = await glob3("**/{i18n,locales}/**/*.{ts,js,json}", { cwd: srcPath });
4605
+ if (i18nFiles.length > 0) {
4606
+ const locales = i18nFiles.filter((f) => f.endsWith(".json")).map((f) => path13.basename(f, ".json"));
4607
+ result.i18nConfig = {
4608
+ type: "vue-i18n",
4609
+ configFile: i18nFiles.find((f) => f.includes("index")) || i18nFiles[0],
4610
+ locales: [...new Set(locales)]
4611
+ };
4612
+ }
4613
+ return result;
4614
+ }
4615
+ /**
4616
+ * 分析核心页面
4617
+ */
4618
+ async analyzeCorePages(projectPath, type) {
4619
+ const result = {
4620
+ loginPage: null,
4621
+ mainLayout: null,
4622
+ navigation: null,
4623
+ errorPages: [],
4624
+ otherCorePages: []
4625
+ };
4626
+ const basePath = type === "flutter" ? path13.join(projectPath, "lib") : path13.join(projectPath, "src");
4627
+ if (!fs14.existsSync(basePath)) return result;
4628
+ const fileExt = type === "flutter" ? "**/*.dart" : "**/*.{vue,tsx,jsx}";
4629
+ const files = await glob3(fileExt, { cwd: basePath });
4630
+ for (const file of files) {
4631
+ const fileName = file.toLowerCase();
4632
+ if (fileName.includes("login")) {
4633
+ result.loginPage = file;
4634
+ } else if (fileName.includes("layout") && (fileName.includes("main") || fileName.includes("default") || fileName.includes("app"))) {
4635
+ result.mainLayout = file;
4636
+ } else if (fileName.includes("sidebar") || fileName.includes("navbar") || fileName.includes("menu")) {
4637
+ result.navigation = file;
4638
+ } else if (fileName.includes("404") || fileName.includes("403") || fileName.includes("error") || fileName.includes("notfound")) {
4639
+ result.errorPages.push(file);
4640
+ }
4641
+ }
4642
+ return result;
4643
+ }
4644
+ /**
4645
+ * 生成项目骨架
4646
+ */
4647
+ generateSkeleton(analysis) {
4648
+ const skeleton = {
4649
+ requiredDirectories: [],
4650
+ coreUtils: [],
4651
+ styleSystem: analysis.styleSystem,
4652
+ configSystem: analysis.configSystem,
4653
+ corePages: analysis.corePages,
4654
+ businessFilesToRemove: [],
4655
+ filesToClean: []
4656
+ };
4657
+ for (const layer of analysis.architectureLayers) {
4658
+ if (layer.reusable) {
4659
+ skeleton.requiredDirectories.push({
4660
+ path: layer.directories[0],
4661
+ description: layer.description,
4662
+ files: layer.keyFiles
4663
+ });
4664
+ }
4665
+ }
4666
+ skeleton.coreUtils = analysis.utilities.filter((u) => u.recommended);
4667
+ for (const layer of analysis.architectureLayers) {
4668
+ if (!layer.reusable && layer.name !== "\u89C6\u56FE\u5C42" && layer.name !== "\u9875\u9762\u5C42") {
4669
+ skeleton.filesToClean.push(...layer.directories.map((d) => `src/${d}/**/*`));
4670
+ }
4671
+ }
4672
+ return skeleton;
4673
+ }
4674
+ /**
4675
+ * 评估项目质量
4676
+ */
4677
+ assessQuality(analysis) {
4678
+ const assessment = {
4679
+ score: 0,
4680
+ strengths: [],
4681
+ weaknesses: [],
4682
+ suggestions: []
4683
+ };
4684
+ let score = 50;
4685
+ if (analysis.architectureLayers.length >= 5) {
4686
+ score += 10;
4687
+ assessment.strengths.push("\u9879\u76EE\u67B6\u6784\u5C42\u7EA7\u6E05\u6670\uFF0C\u6A21\u5757\u5212\u5206\u5408\u7406");
4688
+ } else if (analysis.architectureLayers.length < 3) {
4689
+ score -= 10;
4690
+ assessment.weaknesses.push("\u9879\u76EE\u7ED3\u6784\u8F83\u7B80\u5355\uFF0C\u7F3A\u5C11\u6E05\u6670\u7684\u5206\u5C42");
4691
+ }
4692
+ const reusableUtils = analysis.utilities.filter((u) => u.recommended).length;
4693
+ if (reusableUtils >= 5) {
4694
+ score += 10;
4695
+ assessment.strengths.push("\u6709\u4E30\u5BCC\u7684\u53EF\u590D\u7528\u5DE5\u5177\u7C7B");
4696
+ }
4697
+ if (analysis.techStack.language === "TypeScript") {
4698
+ score += 10;
4699
+ assessment.strengths.push("\u4F7F\u7528 TypeScript \u63D0\u4F9B\u7C7B\u578B\u5B89\u5168");
4700
+ } else {
4701
+ assessment.suggestions.push("\u5EFA\u8BAE\u4F7F\u7528 TypeScript \u63D0\u5347\u4EE3\u7801\u8D28\u91CF");
4702
+ }
4703
+ if (analysis.styleSystem.themeFiles.length > 0) {
4704
+ score += 5;
4705
+ assessment.strengths.push("\u6709\u5B8C\u5584\u7684\u4E3B\u9898/\u53D8\u91CF\u7CFB\u7EDF");
4706
+ } else {
4707
+ assessment.suggestions.push("\u5EFA\u8BAE\u5EFA\u7ACB\u7EDF\u4E00\u7684\u4E3B\u9898\u53D8\u91CF\u7CFB\u7EDF");
4708
+ }
4709
+ if (analysis.configSystem.httpConfig) {
4710
+ score += 5;
4711
+ assessment.strengths.push("HTTP \u8BF7\u6C42\u5DF2\u7EDF\u4E00\u5C01\u88C5");
4712
+ }
4713
+ if (analysis.configSystem.i18nConfig) {
4714
+ score += 5;
4715
+ assessment.strengths.push("\u5DF2\u914D\u7F6E\u56FD\u9645\u5316\u652F\u6301");
4716
+ }
4717
+ assessment.score = Math.min(100, Math.max(0, score));
4718
+ return assessment;
4719
+ }
4720
+ /**
4721
+ * 建议 MCP 模板
4722
+ */
4723
+ suggestTemplates(analysis) {
4724
+ const suggestions = [];
4725
+ if (!analysis.configSystem.httpConfig) {
4726
+ suggestions.push({
4727
+ templateId: "vue/api-layer",
4728
+ reason: "\u7F3A\u5C11\u7EDF\u4E00\u7684 HTTP \u8BF7\u6C42\u5C01\u88C5",
4729
+ replaceFiles: []
4730
+ });
4731
+ }
4732
+ return suggestions;
4733
+ }
4734
+ /**
4735
+ * 生成开发计划
4736
+ */
4737
+ generateDevelopmentPlan(analysis, newProjectName) {
4738
+ var _a;
4739
+ const plan = {
4740
+ title: `\u57FA\u4E8E ${analysis.projectName} \u521B\u5EFA ${newProjectName} \u5F00\u53D1\u8BA1\u5212`,
4741
+ referenceProject: analysis.projectName,
4742
+ newProjectName,
4743
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
4744
+ phases: [],
4745
+ notes: []
4746
+ };
4747
+ plan.phases.push({
4748
+ phase: 1,
4749
+ name: "\u9879\u76EE\u521D\u59CB\u5316",
4750
+ description: "\u521B\u5EFA\u9879\u76EE\u9AA8\u67B6\uFF0C\u590D\u5236\u57FA\u7840\u914D\u7F6E",
4751
+ tasks: [
4752
+ { task: "\u521B\u5EFA\u9879\u76EE\u76EE\u5F55\u7ED3\u6784", priority: "high", estimatedTime: "10min" },
4753
+ { task: "\u590D\u5236\u6784\u5EFA\u914D\u7F6E", priority: "high", estimatedTime: "5min", files: [((_a = analysis.configSystem.buildConfig) == null ? void 0 : _a.configFile) || ""] },
4754
+ { task: "\u590D\u5236\u73AF\u5883\u914D\u7F6E", priority: "high", estimatedTime: "5min", files: analysis.configSystem.envFiles },
4755
+ { task: "\u5B89\u88C5\u4F9D\u8D56", priority: "high", estimatedTime: "5min" }
4756
+ ]
4757
+ });
4758
+ plan.phases.push({
4759
+ phase: 2,
4760
+ name: "\u57FA\u7840\u8BBE\u65BD\u642D\u5EFA",
4761
+ description: "\u590D\u5236\u5DE5\u5177\u7C7B\u3001\u914D\u7F6E\u6587\u4EF6\u7B49\u57FA\u7840\u4EE3\u7801",
4762
+ tasks: [
4763
+ { task: "\u590D\u5236\u5DE5\u5177\u7C7B", priority: "high", estimatedTime: "15min", files: analysis.skeleton.coreUtils.map((u) => u.path) },
4764
+ { task: "\u590D\u5236 HTTP \u914D\u7F6E", priority: "high", estimatedTime: "10min", files: analysis.configSystem.httpConfig ? [analysis.configSystem.httpConfig.configFile] : [] },
4765
+ { task: "\u590D\u5236\u8DEF\u7531\u914D\u7F6E\uFF08\u9AA8\u67B6\uFF09", priority: "medium", estimatedTime: "10min" },
4766
+ { task: "\u590D\u5236\u7C7B\u578B\u5B9A\u4E49", priority: "medium", estimatedTime: "5min" }
4767
+ ]
4768
+ });
4769
+ plan.phases.push({
4770
+ phase: 3,
4771
+ name: "\u6837\u5F0F\u7CFB\u7EDF\u8FC1\u79FB",
4772
+ description: "\u590D\u5236\u5168\u5C40\u6837\u5F0F\u3001\u4E3B\u9898\u914D\u7F6E\u3001UI \u7EC4\u4EF6\u8986\u76D6\u6837\u5F0F",
4773
+ tasks: [
4774
+ { task: "\u590D\u5236\u5168\u5C40\u6837\u5F0F", priority: "high", estimatedTime: "10min", files: analysis.styleSystem.globalStyles },
4775
+ { task: "\u590D\u5236\u4E3B\u9898/\u53D8\u91CF\u6587\u4EF6", priority: "high", estimatedTime: "5min", files: analysis.styleSystem.themeFiles },
4776
+ { task: "\u590D\u5236 UI \u7EC4\u4EF6\u8986\u76D6\u6837\u5F0F", priority: "medium", estimatedTime: "10min", files: analysis.styleSystem.uiOverrides.map((o) => o.path) },
4777
+ { task: "\u590D\u5236 mixins", priority: "low", estimatedTime: "5min", files: analysis.styleSystem.mixins }
4778
+ ]
4779
+ });
4780
+ plan.phases.push({
4781
+ phase: 4,
4782
+ name: "\u6838\u5FC3\u9875\u9762\u642D\u5EFA",
4783
+ description: "\u590D\u5236\u767B\u5F55\u9875\u3001\u4E3B\u5E03\u5C40\u3001\u5BFC\u822A\u7B49\u6838\u5FC3\u9875\u9762",
4784
+ tasks: [
4785
+ { task: "\u590D\u5236\u4E3B\u5E03\u5C40", priority: "high", estimatedTime: "15min", files: analysis.corePages.mainLayout ? [analysis.corePages.mainLayout] : [] },
4786
+ { task: "\u590D\u5236\u767B\u5F55\u9875", priority: "high", estimatedTime: "15min", files: analysis.corePages.loginPage ? [analysis.corePages.loginPage] : [] },
4787
+ { task: "\u590D\u5236\u5BFC\u822A\u7EC4\u4EF6", priority: "medium", estimatedTime: "10min", files: analysis.corePages.navigation ? [analysis.corePages.navigation] : [] },
4788
+ { task: "\u590D\u5236\u9519\u8BEF\u9875\u9762", priority: "low", estimatedTime: "10min", files: analysis.corePages.errorPages }
4789
+ ]
4790
+ });
4791
+ plan.phases.push({
4792
+ phase: 5,
4793
+ name: "\u6E05\u7406\u548C\u4F18\u5316",
4794
+ description: "\u5220\u9664\u4E1A\u52A1\u4EE3\u7801\u3001\u4F18\u5316\u914D\u7F6E",
4795
+ tasks: [
4796
+ { task: "\u6E05\u7406\u4E1A\u52A1\u7EC4\u4EF6", priority: "high", estimatedTime: "20min" },
4797
+ { task: "\u6E05\u7406\u4E1A\u52A1\u89C6\u56FE", priority: "high", estimatedTime: "20min" },
4798
+ { task: "\u6E05\u7406\u4E1A\u52A1 API", priority: "medium", estimatedTime: "15min" },
4799
+ { task: "\u66F4\u65B0\u9879\u76EE\u540D\u79F0\u548C\u914D\u7F6E", priority: "high", estimatedTime: "10min" }
4800
+ ]
4801
+ });
4802
+ plan.notes = [
4803
+ `\u53C2\u8003\u9879\u76EE\u6280\u672F\u6808: ${analysis.techStack.framework} + ${analysis.techStack.language}`,
4804
+ `UI \u5E93: ${analysis.techStack.uiLibrary || "\u65E0"}`,
4805
+ `\u72B6\u6001\u7BA1\u7406: ${analysis.techStack.stateManagement || "\u65E0"}`,
4806
+ "\u786E\u4FDD\u4FDD\u6301\u4E0E\u53C2\u8003\u9879\u76EE\u4E00\u81F4\u7684\u4EE3\u7801\u98CE\u683C",
4807
+ "\u6CE8\u610F\u68C0\u67E5\u786C\u7F16\u7801\u7684\u9879\u76EE\u540D\u79F0\u548C\u914D\u7F6E",
4808
+ "\u5EFA\u8BAE\u5148\u8FD0\u884C\u53C2\u8003\u9879\u76EE\uFF0C\u786E\u4FDD\u7406\u89E3\u5176\u529F\u80FD"
4809
+ ];
4810
+ return plan;
4811
+ }
4812
+ };
4813
+
4814
+ // src/tools/cloneProject.ts
4815
+ async function analyzeReferenceProject(args) {
4816
+ const logger3 = new ConsoleLogger();
4817
+ try {
4818
+ if (!args.projectPath) {
4819
+ return {
4820
+ content: [{
4821
+ type: "text",
4822
+ text: JSON.stringify({
4823
+ error: "\u8BF7\u63D0\u4F9B\u53C2\u8003\u9879\u76EE\u8DEF\u5F84 (projectPath)",
4824
+ usage: 'analyze_reference_project({ projectPath: "/path/to/project" })'
4825
+ }, null, 2)
4826
+ }]
4827
+ };
4828
+ }
4829
+ if (!fs15.existsSync(args.projectPath)) {
4830
+ return {
4831
+ content: [{
4832
+ type: "text",
4833
+ text: JSON.stringify({
4834
+ error: `\u53C2\u8003\u9879\u76EE\u8DEF\u5F84\u4E0D\u5B58\u5728: ${args.projectPath}`
4835
+ }, null, 2)
4836
+ }]
4837
+ };
4838
+ }
4839
+ logger3.log(`\u{1F50D} \u5F00\u59CB\u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE: ${args.projectPath}`);
4840
+ const analyzer = new ProjectCloneAnalyzer(logger3);
4841
+ const analysis = await analyzer.analyzeProject(args.projectPath);
4842
+ let developmentPlan = null;
4843
+ if (args.newProjectName) {
4844
+ developmentPlan = analyzer.generateDevelopmentPlan(analysis, args.newProjectName);
4845
+ }
4846
+ if (args.generateDocs && args.newProjectPath) {
4847
+ await generateAnalysisDocs(args.newProjectPath, analysis, developmentPlan);
4848
+ logger3.log(`\u{1F4C4} \u5DF2\u751F\u6210\u5206\u6790\u6587\u6863\u5230: ${args.newProjectPath}/docs/`);
4849
+ }
4850
+ const response = {
4851
+ success: true,
4852
+ message: "\u9879\u76EE\u5206\u6790\u5B8C\u6210",
4853
+ projectName: analysis.projectName,
4854
+ techStack: analysis.techStack,
4855
+ architectureSummary: {
4856
+ totalLayers: analysis.architectureLayers.length,
4857
+ reusableLayers: analysis.architectureLayers.filter((l) => l.reusable).length,
4858
+ layers: analysis.architectureLayers.map((l) => ({
4859
+ name: l.name,
4860
+ reusable: l.reusable,
4861
+ priority: l.priority
4862
+ }))
4863
+ },
4864
+ utilitiesSummary: {
4865
+ total: analysis.utilities.length,
4866
+ recommended: analysis.utilities.filter((u) => u.recommended).length,
4867
+ byType: groupBy(analysis.utilities, "type")
4868
+ },
4869
+ styleSystem: {
4870
+ preprocessor: analysis.styleSystem.preprocessor,
4871
+ globalStylesCount: analysis.styleSystem.globalStyles.length,
4872
+ themeFilesCount: analysis.styleSystem.themeFiles.length,
4873
+ uiLibrary: analysis.techStack.uiLibrary
4874
+ },
4875
+ corePages: {
4876
+ hasLogin: !!analysis.corePages.loginPage,
4877
+ hasMainLayout: !!analysis.corePages.mainLayout,
4878
+ hasNavigation: !!analysis.corePages.navigation,
4879
+ errorPagesCount: analysis.corePages.errorPages.length
4880
+ },
4881
+ qualityAssessment: analysis.qualityAssessment,
4882
+ templateSuggestions: analysis.templateSuggestions,
4883
+ skeleton: {
4884
+ requiredDirectoriesCount: analysis.skeleton.requiredDirectories.length,
4885
+ coreUtilsCount: analysis.skeleton.coreUtils.length,
4886
+ directories: analysis.skeleton.requiredDirectories.map((d) => ({
4887
+ path: d.path,
4888
+ description: d.description
4889
+ }))
4890
+ }
4891
+ };
4892
+ if (developmentPlan) {
4893
+ response.developmentPlan = {
4894
+ title: developmentPlan.title,
4895
+ phases: developmentPlan.phases.length,
4896
+ totalTasks: developmentPlan.phases.reduce((sum, p) => sum + p.tasks.length, 0),
4897
+ phasesSummary: developmentPlan.phases.map((p) => ({
4898
+ phase: p.phase,
4899
+ name: p.name,
4900
+ tasksCount: p.tasks.length
4901
+ }))
4902
+ };
4903
+ }
4904
+ response.nextSteps = [
4905
+ "1. \u67E5\u770B\u5206\u6790\u7ED3\u679C\uFF0C\u786E\u8BA4\u9AA8\u67B6\u5185\u5BB9\u7B26\u5408\u9884\u671F",
4906
+ "2. \u5982\u9700\u751F\u6210\u5B8C\u6574\u5206\u6790\u6587\u6863\uFF0C\u8BF7\u6307\u5B9A newProjectPath",
4907
+ "3. \u4F7F\u7528 generate_project_skeleton \u751F\u6210\u65B0\u9879\u76EE",
4908
+ "4. \u6309\u7167\u5F00\u53D1\u8BA1\u5212\u9010\u6B65\u5B8C\u6210\u9879\u76EE\u642D\u5EFA"
4909
+ ];
4910
+ response._fullAnalysis = analysis;
4911
+ return {
4912
+ content: [{
4913
+ type: "text",
4914
+ text: JSON.stringify(response, null, 2)
4915
+ }]
4916
+ };
4917
+ } catch (error) {
4918
+ logger3.error(`\u5206\u6790\u5931\u8D25: ${error}`);
4919
+ return {
4920
+ content: [{
4921
+ type: "text",
4922
+ text: JSON.stringify({
4923
+ error: error instanceof Error ? error.message : String(error),
4924
+ stack: error instanceof Error ? error.stack : void 0
4925
+ }, null, 2)
4926
+ }]
4927
+ };
4928
+ }
4929
+ }
4930
+ async function generateProjectSkeleton(args) {
4931
+ const logger3 = new ConsoleLogger();
4932
+ try {
4933
+ if (!args.referenceProjectPath || !args.newProjectPath || !args.newProjectName) {
4934
+ return {
4935
+ content: [{
4936
+ type: "text",
4937
+ text: JSON.stringify({
4938
+ error: "\u8BF7\u63D0\u4F9B\u5FC5\u8981\u53C2\u6570",
4939
+ required: ["referenceProjectPath", "newProjectPath", "newProjectName"]
4940
+ }, null, 2)
4941
+ }]
4942
+ };
4943
+ }
4944
+ if (!fs15.existsSync(args.referenceProjectPath)) {
4945
+ return {
4946
+ content: [{
4947
+ type: "text",
4948
+ text: JSON.stringify({
4949
+ error: `\u53C2\u8003\u9879\u76EE\u8DEF\u5F84\u4E0D\u5B58\u5728: ${args.referenceProjectPath}`
4950
+ }, null, 2)
4951
+ }]
4952
+ };
4953
+ }
4954
+ logger3.log(`\u{1F3D7}\uFE0F \u5F00\u59CB\u751F\u6210\u9879\u76EE\u9AA8\u67B6...`);
4955
+ logger3.log(`\u{1F4E6} \u53C2\u8003\u9879\u76EE: ${args.referenceProjectPath}`);
4956
+ logger3.log(`\u{1F4C1} \u65B0\u9879\u76EE: ${args.newProjectPath}`);
4957
+ const analyzer = new ProjectCloneAnalyzer(logger3);
4958
+ const analysis = await analyzer.analyzeProject(args.referenceProjectPath);
4959
+ const developmentPlan = analyzer.generateDevelopmentPlan(analysis, args.newProjectName);
4960
+ if (!fs15.existsSync(args.newProjectPath)) {
4961
+ fs15.mkdirSync(args.newProjectPath, { recursive: true });
4962
+ }
4963
+ if (args.generateDocs !== false) {
4964
+ await generateAnalysisDocs(args.newProjectPath, analysis, developmentPlan);
4965
+ logger3.log(`\u{1F4C4} \u5DF2\u751F\u6210\u5206\u6790\u6587\u6863`);
4966
+ }
4967
+ const skeletonGuide = generateSkeletonGuide(analysis, args);
4968
+ return {
4969
+ content: [{
4970
+ type: "text",
4971
+ text: JSON.stringify({
4972
+ success: true,
4973
+ message: "\u9879\u76EE\u9AA8\u67B6\u89C4\u5212\u5B8C\u6210",
4974
+ newProjectPath: args.newProjectPath,
4975
+ docsGenerated: args.generateDocs !== false,
4976
+ skeletonGuide,
4977
+ developmentPlan: {
4978
+ phases: developmentPlan.phases.length,
4979
+ totalTasks: developmentPlan.phases.reduce((sum, p) => sum + p.tasks.length, 0)
4980
+ },
4981
+ nextSteps: [
4982
+ `1. \u67E5\u770B ${args.newProjectPath}/docs/ \u76EE\u5F55\u4E0B\u7684\u5206\u6790\u6587\u6863`,
4983
+ "2. \u6309\u7167 DEVELOPMENT_PLAN.md \u4E2D\u7684\u6B65\u9AA4\u9010\u6B65\u6267\u884C",
4984
+ "3. \u6839\u636E PROJECT_ANALYSIS.md \u4E86\u89E3\u53C2\u8003\u9879\u76EE\u7684\u67B6\u6784",
4985
+ "4. \u590D\u5236\u5FC5\u8981\u7684\u6587\u4EF6\u540E\uFF0C\u8FD0\u884C\u9879\u76EE\u9A8C\u8BC1"
4986
+ ]
4987
+ }, null, 2)
4988
+ }]
4989
+ };
4990
+ } catch (error) {
4991
+ logger3.error(`\u751F\u6210\u5931\u8D25: ${error}`);
4992
+ return {
4993
+ content: [{
4994
+ type: "text",
4995
+ text: JSON.stringify({
4996
+ error: error instanceof Error ? error.message : String(error)
4997
+ }, null, 2)
4998
+ }]
4999
+ };
5000
+ }
5001
+ }
5002
+ async function generateAnalysisDocs(targetPath, analysis, plan) {
5003
+ const docsPath = path14.join(targetPath, "docs");
5004
+ if (!fs15.existsSync(docsPath)) {
5005
+ fs15.mkdirSync(docsPath, { recursive: true });
5006
+ }
5007
+ const analysisDoc = generateAnalysisMarkdown(analysis);
5008
+ fs15.writeFileSync(path14.join(docsPath, "PROJECT_ANALYSIS.md"), analysisDoc);
5009
+ if (plan) {
5010
+ const planDoc = generatePlanMarkdown(plan);
5011
+ fs15.writeFileSync(path14.join(docsPath, "DEVELOPMENT_PLAN.md"), planDoc);
5012
+ }
5013
+ const skeletonDoc = generateSkeletonMarkdown(analysis);
5014
+ fs15.writeFileSync(path14.join(docsPath, "SKELETON_CHECKLIST.md"), skeletonDoc);
5015
+ }
5016
+ function generateAnalysisMarkdown(analysis) {
5017
+ var _a, _b, _c, _d;
5018
+ let md = `# ${analysis.projectName} \u9879\u76EE\u5206\u6790\u62A5\u544A
5019
+
5020
+ > \u751F\u6210\u65F6\u95F4: ${analysis.analyzedAt}
5021
+
5022
+ ## \u6280\u672F\u6808
5023
+
5024
+ | \u9879\u76EE | \u503C |
5025
+ |------|-----|
5026
+ | \u6846\u67B6 | ${analysis.techStack.framework} |
5027
+ | \u8BED\u8A00 | ${analysis.techStack.language} |
5028
+ | \u6784\u5EFA\u5DE5\u5177 | ${analysis.techStack.buildTool} |
5029
+ | UI \u5E93 | ${analysis.techStack.uiLibrary || "\u65E0"} |
5030
+ | \u72B6\u6001\u7BA1\u7406 | ${analysis.techStack.stateManagement || "\u65E0"} |
5031
+
5032
+ ## \u67B6\u6784\u5C42\u7EA7
5033
+
5034
+ | \u5C42\u7EA7 | \u63CF\u8FF0 | \u53EF\u590D\u7528 | \u4F18\u5148\u7EA7 |
5035
+ |------|------|--------|--------|
5036
+ `;
5037
+ for (const layer of analysis.architectureLayers) {
5038
+ md += `| ${layer.name} | ${layer.description} | ${layer.reusable ? "\u2705" : "\u274C"} | ${layer.priority} |
5039
+ `;
5040
+ }
5041
+ md += `
5042
+ ## \u5DE5\u5177\u7C7B\u5206\u6790
5043
+
5044
+ **\u603B\u8BA1**: ${analysis.utilities.length} \u4E2A\u5DE5\u5177\u7C7B\uFF0C\u5176\u4E2D ${analysis.utilities.filter((u) => u.recommended).length} \u4E2A\u63A8\u8350\u590D\u7528
5045
+
5046
+ ### \u63A8\u8350\u590D\u7528\u7684\u5DE5\u5177\u7C7B
5047
+
5048
+ | \u8DEF\u5F84 | \u7C7B\u578B | \u4F7F\u7528\u6B21\u6570 |
5049
+ |------|------|---------|
5050
+ `;
5051
+ for (const util of analysis.utilities.filter((u) => u.recommended)) {
5052
+ md += `| ${util.path} | ${util.type} | ${util.usageCount} |
5053
+ `;
5054
+ }
5055
+ md += `
5056
+ ## \u6837\u5F0F\u7CFB\u7EDF
5057
+
5058
+ - **\u9884\u5904\u7406\u5668**: ${analysis.styleSystem.preprocessor || "CSS"}
5059
+ - **\u5168\u5C40\u6837\u5F0F**: ${analysis.styleSystem.globalStyles.length} \u4E2A\u6587\u4EF6
5060
+ - **\u4E3B\u9898\u6587\u4EF6**: ${analysis.styleSystem.themeFiles.length} \u4E2A\u6587\u4EF6
5061
+ - **Mixins**: ${analysis.styleSystem.mixins.length} \u4E2A\u6587\u4EF6
5062
+
5063
+ ### \u5168\u5C40\u6837\u5F0F\u6587\u4EF6
5064
+
5065
+ ${analysis.styleSystem.globalStyles.map((f) => `- \`${f}\``).join("\n")}
5066
+
5067
+ ### \u4E3B\u9898/\u53D8\u91CF\u6587\u4EF6
5068
+
5069
+ ${analysis.styleSystem.themeFiles.map((f) => `- \`${f}\``).join("\n")}
5070
+
5071
+ ## \u914D\u7F6E\u7CFB\u7EDF
5072
+
5073
+ - **\u6784\u5EFA\u914D\u7F6E**: ${((_a = analysis.configSystem.buildConfig) == null ? void 0 : _a.configFile) || "\u65E0"}
5074
+ - **\u8DEF\u7531\u914D\u7F6E**: ${((_b = analysis.configSystem.routerConfig) == null ? void 0 : _b.configFile) || "\u65E0"}
5075
+ - **HTTP \u914D\u7F6E**: ${((_c = analysis.configSystem.httpConfig) == null ? void 0 : _c.configFile) || "\u65E0"}
5076
+ - **\u56FD\u9645\u5316\u914D\u7F6E**: ${((_d = analysis.configSystem.i18nConfig) == null ? void 0 : _d.configFile) || "\u65E0"}
5077
+
5078
+ ## \u6838\u5FC3\u9875\u9762
5079
+
5080
+ | \u9875\u9762 | \u8DEF\u5F84 |
5081
+ |------|------|
5082
+ | \u767B\u5F55\u9875 | ${analysis.corePages.loginPage || "\u65E0"} |
5083
+ | \u4E3B\u5E03\u5C40 | ${analysis.corePages.mainLayout || "\u65E0"} |
5084
+ | \u5BFC\u822A\u7EC4\u4EF6 | ${analysis.corePages.navigation || "\u65E0"} |
5085
+ | \u9519\u8BEF\u9875\u9762 | ${analysis.corePages.errorPages.join(", ") || "\u65E0"} |
5086
+
5087
+ ## \u8D28\u91CF\u8BC4\u4F30
5088
+
5089
+ **\u8BC4\u5206**: ${analysis.qualityAssessment.score}/100
5090
+
5091
+ ### \u4F18\u70B9
5092
+
5093
+ ${analysis.qualityAssessment.strengths.map((s) => `- \u2705 ${s}`).join("\n")}
5094
+
5095
+ ### \u5F85\u6539\u8FDB
5096
+
5097
+ ${analysis.qualityAssessment.weaknesses.map((w) => `- \u26A0\uFE0F ${w}`).join("\n")}
5098
+
5099
+ ### \u5EFA\u8BAE
5100
+
5101
+ ${analysis.qualityAssessment.suggestions.map((s) => `- \u{1F4A1} ${s}`).join("\n")}
5102
+ `;
5103
+ return md;
5104
+ }
5105
+ function generatePlanMarkdown(plan) {
5106
+ var _a;
5107
+ let md = `# ${plan.title}
5108
+
5109
+ > \u751F\u6210\u65F6\u95F4: ${plan.generatedAt}
5110
+
5111
+ **\u53C2\u8003\u9879\u76EE**: ${plan.referenceProject}
5112
+ **\u65B0\u9879\u76EE**: ${plan.newProjectName}
5113
+
5114
+ ---
5115
+
5116
+ `;
5117
+ for (const phase of plan.phases) {
5118
+ md += `## \u9636\u6BB5 ${phase.phase}: ${phase.name}
5119
+
5120
+ ${phase.description}
5121
+
5122
+ | \u4EFB\u52A1 | \u4F18\u5148\u7EA7 | \u9884\u4F30\u65F6\u95F4 | \u76F8\u5173\u6587\u4EF6 |
5123
+ |------|--------|---------|----------|
5124
+ `;
5125
+ for (const task of phase.tasks) {
5126
+ const files = ((_a = task.files) == null ? void 0 : _a.filter((f) => f).join(", ")) || "-";
5127
+ md += `| ${task.task} | ${task.priority} | ${task.estimatedTime} | ${files} |
5128
+ `;
5129
+ }
5130
+ md += "\n";
5131
+ }
5132
+ md += `## \u6CE8\u610F\u4E8B\u9879
5133
+
5134
+ ${plan.notes.map((n) => `- ${n}`).join("\n")}
5135
+ `;
5136
+ return md;
5137
+ }
5138
+ function generateSkeletonMarkdown(analysis) {
5139
+ var _a;
5140
+ let md = `# \u9879\u76EE\u9AA8\u67B6\u6E05\u5355
5141
+
5142
+ > \u57FA\u4E8E ${analysis.projectName} \u5206\u6790\u751F\u6210
5143
+
5144
+ ## \u5FC5\u987B\u590D\u5236\u7684\u76EE\u5F55
5145
+
5146
+ `;
5147
+ for (const dir of analysis.skeleton.requiredDirectories) {
5148
+ md += `### ${dir.path}
5149
+
5150
+ - **\u63CF\u8FF0**: ${dir.description}
5151
+ - **\u5173\u952E\u6587\u4EF6**:
5152
+ ${((_a = dir.files) == null ? void 0 : _a.slice(0, 5).map((f) => ` - \`${f}\``).join("\n")) || " - (\u65E0)"}
5153
+
5154
+ `;
5155
+ }
5156
+ md += `## \u6838\u5FC3\u5DE5\u5177\u7C7B
5157
+
5158
+ \u9700\u8981\u590D\u5236\u4EE5\u4E0B\u5DE5\u5177\u7C7B\u6587\u4EF6\uFF1A
5159
+
5160
+ | \u6587\u4EF6 | \u7C7B\u578B | \u8BF4\u660E |
5161
+ |------|------|------|
5162
+ `;
5163
+ for (const util of analysis.skeleton.coreUtils) {
5164
+ md += `| ${util.path} | ${util.type} | \u4F7F\u7528 ${util.usageCount} \u6B21 |
5165
+ `;
5166
+ }
5167
+ md += `
5168
+ ## \u6837\u5F0F\u7CFB\u7EDF
5169
+
5170
+ ### \u5FC5\u987B\u590D\u5236
5171
+
5172
+ ${analysis.skeleton.styleSystem.globalStyles.map((f) => `- [ ] \`${f}\``).join("\n")}
5173
+
5174
+ ### \u4E3B\u9898\u6587\u4EF6
5175
+
5176
+ ${analysis.skeleton.styleSystem.themeFiles.map((f) => `- [ ] \`${f}\``).join("\n")}
5177
+
5178
+ ## \u6838\u5FC3\u9875\u9762
5179
+
5180
+ - [ ] \u767B\u5F55\u9875: \`${analysis.skeleton.corePages.loginPage || "\u65E0"}\`
5181
+ - [ ] \u4E3B\u5E03\u5C40: \`${analysis.skeleton.corePages.mainLayout || "\u65E0"}\`
5182
+ - [ ] \u5BFC\u822A\u7EC4\u4EF6: \`${analysis.skeleton.corePages.navigation || "\u65E0"}\`
5183
+
5184
+ ## \u6E05\u7406\u6E05\u5355
5185
+
5186
+ \u4EE5\u4E0B\u4E1A\u52A1\u6587\u4EF6\u9700\u8981\u5220\u9664\u6216\u6E05\u7A7A\uFF1A
5187
+
5188
+ ${analysis.skeleton.filesToClean.map((f) => `- [ ] \`${f}\``).join("\n")}
5189
+ `;
5190
+ return md;
5191
+ }
5192
+ function generateSkeletonGuide(analysis, args) {
5193
+ var _a;
5194
+ return {
5195
+ directories: analysis.skeleton.requiredDirectories.map((d) => ({
5196
+ from: path14.join(args.referenceProjectPath, "src", d.path),
5197
+ to: path14.join(args.newProjectPath, "src", d.path),
5198
+ description: d.description
5199
+ })),
5200
+ coreUtils: analysis.skeleton.coreUtils.map((u) => ({
5201
+ from: u.path,
5202
+ type: u.type,
5203
+ recommended: u.recommended
5204
+ })),
5205
+ styleFiles: [
5206
+ ...analysis.styleSystem.globalStyles,
5207
+ ...analysis.styleSystem.themeFiles,
5208
+ ...analysis.styleSystem.mixins
5209
+ ],
5210
+ configFiles: [
5211
+ (_a = analysis.configSystem.buildConfig) == null ? void 0 : _a.configFile,
5212
+ ...analysis.configSystem.envFiles
5213
+ ].filter(Boolean),
5214
+ corePages: [
5215
+ analysis.corePages.loginPage,
5216
+ analysis.corePages.mainLayout,
5217
+ analysis.corePages.navigation,
5218
+ ...analysis.corePages.errorPages
5219
+ ].filter(Boolean)
5220
+ };
5221
+ }
5222
+ function groupBy(arr, key) {
5223
+ return arr.reduce((acc, item) => {
5224
+ const k = item[key];
5225
+ acc[k] = (acc[k] || 0) + 1;
5226
+ return acc;
5227
+ }, {});
5228
+ }
5229
+
4026
5230
  // src/core/errors.ts
4027
5231
  var ERROR_MESSAGES = {
4028
5232
  [1e3 /* UNKNOWN */]: "\u672A\u77E5\u9519\u8BEF",
@@ -4105,7 +5309,7 @@ var globalConfig = {
4105
5309
  timestamp: false,
4106
5310
  prefix: "[MCP]"
4107
5311
  };
4108
- var Logger = class _Logger {
5312
+ var Logger2 = class _Logger {
4109
5313
  constructor(name, config) {
4110
5314
  this.name = name || "";
4111
5315
  this.config = { ...globalConfig, ...config };
@@ -4191,14 +5395,14 @@ var Logger = class _Logger {
4191
5395
  return new _Logger(childName, this.config);
4192
5396
  }
4193
5397
  };
4194
- var logger = new Logger();
5398
+ var logger = new Logger2();
4195
5399
  function createLogger(name) {
4196
- return new Logger(name);
5400
+ return new Logger2(name);
4197
5401
  }
4198
5402
 
4199
5403
  // src/core/autoConfig.ts
4200
- import * as fs14 from "fs";
4201
- import * as path13 from "path";
5404
+ import * as fs16 from "fs";
5405
+ import * as path15 from "path";
4202
5406
  var checkedWorkspaces = /* @__PURE__ */ new Map();
4203
5407
  var CACHE_DURATION = 5 * 60 * 1e3;
4204
5408
  function ensureWorkspaceConfig(workspacePath) {
@@ -4208,7 +5412,7 @@ function ensureWorkspaceConfig(workspacePath) {
4208
5412
  wasFixed: false,
4209
5413
  workspacePath
4210
5414
  };
4211
- if (!workspacePath || !fs14.existsSync(workspacePath)) {
5415
+ if (!workspacePath || !fs16.existsSync(workspacePath)) {
4212
5416
  return result;
4213
5417
  }
4214
5418
  const cached = checkedWorkspaces.get(workspacePath);
@@ -4216,13 +5420,13 @@ function ensureWorkspaceConfig(workspacePath) {
4216
5420
  if (cached && cached.configured && now - cached.timestamp < CACHE_DURATION) {
4217
5421
  return result;
4218
5422
  }
4219
- const vscodeDir = path13.join(workspacePath, ".vscode");
4220
- const mcpJsonPath = path13.join(vscodeDir, "mcp.json");
4221
- const settingsPath = path13.join(vscodeDir, "settings.json");
5423
+ const vscodeDir = path15.join(workspacePath, ".vscode");
5424
+ const mcpJsonPath = path15.join(vscodeDir, "mcp.json");
5425
+ const settingsPath = path15.join(vscodeDir, "settings.json");
4222
5426
  let hasMtaConfig = false;
4223
- if (fs14.existsSync(mcpJsonPath)) {
5427
+ if (fs16.existsSync(mcpJsonPath)) {
4224
5428
  try {
4225
- const config = JSON.parse(fs14.readFileSync(mcpJsonPath, "utf-8"));
5429
+ const config = JSON.parse(fs16.readFileSync(mcpJsonPath, "utf-8"));
4226
5430
  hasMtaConfig = !!(((_a = config.servers) == null ? void 0 : _a.mta) || ((_b = config.mcpServers) == null ? void 0 : _b.mta));
4227
5431
  } catch {
4228
5432
  }
@@ -4233,13 +5437,13 @@ function ensureWorkspaceConfig(workspacePath) {
4233
5437
  }
4234
5438
  result.needsSetup = true;
4235
5439
  try {
4236
- if (!fs14.existsSync(vscodeDir)) {
4237
- fs14.mkdirSync(vscodeDir, { recursive: true });
5440
+ if (!fs16.existsSync(vscodeDir)) {
5441
+ fs16.mkdirSync(vscodeDir, { recursive: true });
4238
5442
  }
4239
5443
  let mcpConfig = { servers: {} };
4240
- if (fs14.existsSync(mcpJsonPath)) {
5444
+ if (fs16.existsSync(mcpJsonPath)) {
4241
5445
  try {
4242
- mcpConfig = JSON.parse(fs14.readFileSync(mcpJsonPath, "utf-8"));
5446
+ mcpConfig = JSON.parse(fs16.readFileSync(mcpJsonPath, "utf-8"));
4243
5447
  if (!mcpConfig.servers) {
4244
5448
  mcpConfig.servers = {};
4245
5449
  }
@@ -4252,21 +5456,21 @@ function ensureWorkspaceConfig(workspacePath) {
4252
5456
  args: ["-y", "mta-mcp"],
4253
5457
  env: {}
4254
5458
  };
4255
- fs14.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
5459
+ fs16.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
4256
5460
  let settings = {};
4257
- if (fs14.existsSync(settingsPath)) {
5461
+ if (fs16.existsSync(settingsPath)) {
4258
5462
  try {
4259
- settings = JSON.parse(fs14.readFileSync(settingsPath, "utf-8"));
5463
+ settings = JSON.parse(fs16.readFileSync(settingsPath, "utf-8"));
4260
5464
  } catch {
4261
5465
  settings = {};
4262
5466
  }
4263
5467
  }
4264
5468
  if (!settings["github.copilot.chat.mcp.enabled"]) {
4265
5469
  settings["github.copilot.chat.mcp.enabled"] = true;
4266
- fs14.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
5470
+ fs16.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
4267
5471
  }
4268
5472
  result.wasFixed = true;
4269
- result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${path13.basename(workspacePath)} \u914D\u7F6E MTA MCP\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3\u4F7F\u914D\u7F6E\u751F\u6548\u3002`;
5473
+ result.message = `\u2705 \u5DF2\u81EA\u52A8\u4E3A ${path15.basename(workspacePath)} \u914D\u7F6E MTA MCP\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D VS Code \u7A97\u53E3\u4F7F\u914D\u7F6E\u751F\u6548\u3002`;
4270
5474
  checkedWorkspaces.set(workspacePath, { configured: true, timestamp: now });
4271
5475
  } catch (error) {
4272
5476
  result.message = `\u26A0\uFE0F \u81EA\u52A8\u914D\u7F6E\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`;
@@ -4275,7 +5479,7 @@ function ensureWorkspaceConfig(workspacePath) {
4275
5479
  }
4276
5480
 
4277
5481
  // src/index.ts
4278
- var SERVER_VERSION = "2.7.1";
5482
+ var SERVER_VERSION = "2.8.0";
4279
5483
  var logger2 = createLogger("Server");
4280
5484
  var CopilotPromptsMCPServer = class {
4281
5485
  constructor() {
@@ -4650,6 +5854,94 @@ var CopilotPromptsMCPServer = class {
4650
5854
  },
4651
5855
  required: ["id"]
4652
5856
  }
5857
+ },
5858
+ {
5859
+ name: "analyze_reference_project",
5860
+ description: `\u3010\u9879\u76EE\u514B\u9686\u3011\u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE\uFF0C\u7528\u4E8E\u521B\u5EFA\u98CE\u683C\u4E00\u81F4\u7684\u65B0\u9879\u76EE\u3002
5861
+
5862
+ \u89E6\u53D1\u8BCD\uFF1A
5863
+ - "\u53C2\u8003 xx \u9879\u76EE\u521B\u5EFA\u65B0\u9879\u76EE"
5864
+ - "\u6284 xx \u9879\u76EE"
5865
+ - "\u4EE5 xx \u9879\u76EE\u4E3A\u4F8B\u521B\u5EFA"
5866
+ - "\u521B\u5EFA\u4E00\u4E2A xx \u9879\u76EE\u53EA\u4FDD\u7559\u6700\u57FA\u7840\u7684\u529F\u80FD"
5867
+
5868
+ \u529F\u80FD\uFF1A
5869
+ 1. \u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE\u7684\u6280\u672F\u6808\u548C\u67B6\u6784
5870
+ 2. \u8BC6\u522B\u53EF\u590D\u7528\u7684\u5DE5\u5177\u7C7B\u3001\u6837\u5F0F\u7CFB\u7EDF\u3001\u914D\u7F6E\u6587\u4EF6
5871
+ 3. \u5206\u6790\u6838\u5FC3\u9875\u9762\u7ED3\u6784\uFF08\u767B\u5F55\u3001\u5E03\u5C40\u3001\u5BFC\u822A\u7B49\uFF09
5872
+ 4. \u751F\u6210\u9879\u76EE\u8D28\u91CF\u8BC4\u4F30\u548C MCP \u6A21\u677F\u5EFA\u8BAE
5873
+ 5. \u53EF\u9009\u62E9\u751F\u6210\u5206\u6790\u6587\u6863\u548C\u5F00\u53D1\u8BA1\u5212`,
5874
+ inputSchema: {
5875
+ type: "object",
5876
+ properties: {
5877
+ projectPath: {
5878
+ type: "string",
5879
+ description: "\u53C2\u8003\u9879\u76EE\u7684\u7EDD\u5BF9\u8DEF\u5F84"
5880
+ },
5881
+ generateDocs: {
5882
+ type: "boolean",
5883
+ description: "\u662F\u5426\u751F\u6210\u5206\u6790\u6587\u6863\u5230\u76EE\u6807\u9879\u76EE",
5884
+ default: false
5885
+ },
5886
+ newProjectName: {
5887
+ type: "string",
5888
+ description: "\u65B0\u9879\u76EE\u540D\u79F0\uFF08\u7528\u4E8E\u751F\u6210\u5F00\u53D1\u8BA1\u5212\uFF09"
5889
+ },
5890
+ newProjectPath: {
5891
+ type: "string",
5892
+ description: "\u65B0\u9879\u76EE\u8DEF\u5F84\uFF08\u7528\u4E8E\u751F\u6210\u6587\u6863\uFF09"
5893
+ }
5894
+ },
5895
+ required: ["projectPath"]
5896
+ }
5897
+ },
5898
+ {
5899
+ name: "generate_project_skeleton",
5900
+ description: `\u3010\u9879\u76EE\u514B\u9686\u3011\u57FA\u4E8E\u5206\u6790\u7ED3\u679C\u751F\u6210\u9879\u76EE\u9AA8\u67B6\u3002
5901
+
5902
+ \u529F\u80FD\uFF1A
5903
+ 1. \u5206\u6790\u53C2\u8003\u9879\u76EE\u7684\u67B6\u6784
5904
+ 2. \u5728\u65B0\u9879\u76EE\u76EE\u5F55\u751F\u6210\u5206\u6790\u6587\u6863
5905
+ 3. \u751F\u6210\u5F00\u53D1\u8BA1\u5212\u548C\u9AA8\u67B6\u6E05\u5355
5906
+ 4. \u63D0\u4F9B\u9010\u6B65\u6267\u884C\u7684\u4EFB\u52A1\u6307\u5357
5907
+
5908
+ \u751F\u6210\u7684\u6587\u6863\uFF1A
5909
+ - docs/PROJECT_ANALYSIS.md - \u9879\u76EE\u5206\u6790\u62A5\u544A
5910
+ - docs/DEVELOPMENT_PLAN.md - \u5F00\u53D1\u8BA1\u5212
5911
+ - docs/SKELETON_CHECKLIST.md - \u9AA8\u67B6\u6E05\u5355`,
5912
+ inputSchema: {
5913
+ type: "object",
5914
+ properties: {
5915
+ referenceProjectPath: {
5916
+ type: "string",
5917
+ description: "\u53C2\u8003\u9879\u76EE\u7684\u7EDD\u5BF9\u8DEF\u5F84"
5918
+ },
5919
+ newProjectPath: {
5920
+ type: "string",
5921
+ description: "\u65B0\u9879\u76EE\u7684\u7EDD\u5BF9\u8DEF\u5F84"
5922
+ },
5923
+ newProjectName: {
5924
+ type: "string",
5925
+ description: "\u65B0\u9879\u76EE\u540D\u79F0"
5926
+ },
5927
+ generateDocs: {
5928
+ type: "boolean",
5929
+ description: "\u662F\u5426\u751F\u6210\u5206\u6790\u6587\u6863",
5930
+ default: true
5931
+ },
5932
+ includeLayers: {
5933
+ type: "array",
5934
+ items: { type: "string" },
5935
+ description: "\u8981\u5305\u542B\u7684\u5C42\u7EA7\uFF08\u53EF\u9009\uFF09"
5936
+ },
5937
+ excludePatterns: {
5938
+ type: "array",
5939
+ items: { type: "string" },
5940
+ description: "\u8981\u6392\u9664\u7684\u6587\u4EF6\u6A21\u5F0F"
5941
+ }
5942
+ },
5943
+ required: ["referenceProjectPath", "newProjectPath", "newProjectName"]
5944
+ }
4653
5945
  }
4654
5946
  ]
4655
5947
  }));
@@ -4715,6 +6007,12 @@ var CopilotPromptsMCPServer = class {
4715
6007
  case "get_template":
4716
6008
  result = await getTemplate(args);
4717
6009
  break;
6010
+ case "analyze_reference_project":
6011
+ result = await analyzeReferenceProject(args);
6012
+ break;
6013
+ case "generate_project_skeleton":
6014
+ result = await generateProjectSkeleton(args);
6015
+ break;
4718
6016
  default:
4719
6017
  throw new Error(`\u672A\u77E5\u5DE5\u5177: ${name}`);
4720
6018
  }
@@ -4795,6 +6093,8 @@ var CopilotPromptsMCPServer = class {
4795
6093
  ` \u2022 get_compact_standards - \u83B7\u53D6\u7F16\u7801\u89C4\u8303`,
4796
6094
  ` \u2022 use_preset - \u4F7F\u7528\u9884\u8BBE\u573A\u666F`,
4797
6095
  ` \u2022 match_agents - \u5339\u914D\u63A8\u8350 Agent`,
6096
+ ` \u2022 analyze_reference_project - \u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE`,
6097
+ ` \u2022 generate_project_skeleton - \u751F\u6210\u9879\u76EE\u9AA8\u67B6`,
4798
6098
  ``,
4799
6099
  `\u{1F4A1} \u63D0\u793A: \u5728 Copilot Chat \u4E2D\u4F7F\u7528 @mta \u8C03\u7528\u670D\u52A1`,
4800
6100
  `\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`