@c4a/mcp-client 0.3.7-beta.2 → 0.3.8-beta.1

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.
Files changed (2) hide show
  1. package/index.js +246 -209
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // @bun
2
+ import { createRequire } from "node:module";
3
3
  var __create = Object.create;
4
4
  var __getProtoOf = Object.getPrototypeOf;
5
5
  var __defProp = Object.defineProperty;
@@ -26,7 +26,7 @@ var __export = (target, all) => {
26
26
  set: (newValue) => all[name2] = () => newValue
27
27
  });
28
28
  };
29
- var __require = import.meta.require;
29
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
30
30
 
31
31
  // ../../node_modules/.bun/ajv@8.17.1/node_modules/ajv/dist/compile/codegen/code.js
32
32
  var require_code = __commonJS((exports) => {
@@ -7517,7 +7517,7 @@ var require_constants = __commonJS((exports, module2) => {
7517
7517
  CHAR_LEFT_SQUARE_BRACKET: "[",
7518
7518
  CHAR_LINE_FEED: `
7519
7519
  `,
7520
- CHAR_NO_BREAK_SPACE: "\xA0",
7520
+ CHAR_NO_BREAK_SPACE: " ",
7521
7521
  CHAR_PERCENT: "%",
7522
7522
  CHAR_PLUS: "+",
7523
7523
  CHAR_QUESTION_MARK: "?",
@@ -18989,17 +18989,17 @@ m2: ${this.mapper2.__debugToString().split(`
18989
18989
  }
18990
18990
  let BoxCharacter;
18991
18991
  ((BoxCharacter2) => {
18992
- BoxCharacter2["lr"] = "\u2500";
18993
- BoxCharacter2["ud"] = "\u2502";
18994
- BoxCharacter2["dr"] = "\u256D";
18995
- BoxCharacter2["dl"] = "\u256E";
18996
- BoxCharacter2["ul"] = "\u256F";
18997
- BoxCharacter2["ur"] = "\u2570";
18998
- BoxCharacter2["udr"] = "\u251C";
18999
- BoxCharacter2["udl"] = "\u2524";
19000
- BoxCharacter2["dlr"] = "\u252C";
19001
- BoxCharacter2["ulr"] = "\u2534";
19002
- BoxCharacter2["udlr"] = "\u256B";
18992
+ BoxCharacter2["lr"] = "";
18993
+ BoxCharacter2["ud"] = "";
18994
+ BoxCharacter2["dr"] = "";
18995
+ BoxCharacter2["dl"] = "";
18996
+ BoxCharacter2["ul"] = "";
18997
+ BoxCharacter2["ur"] = "";
18998
+ BoxCharacter2["udr"] = "";
18999
+ BoxCharacter2["udl"] = "";
19000
+ BoxCharacter2["dlr"] = "";
19001
+ BoxCharacter2["ulr"] = "";
19002
+ BoxCharacter2["udlr"] = "";
19003
19003
  })(BoxCharacter || (BoxCharacter = {}));
19004
19004
  let Connection;
19005
19005
  ((Connection2) => {
@@ -19250,7 +19250,7 @@ m2: ${this.mapper2.__debugToString().split(`
19250
19250
  for (let column = 0;column < columnCount; column++) {
19251
19251
  for (let lane = 0;lane < lanes.length; lane++) {
19252
19252
  const connector = connectors[column][lane];
19253
- const fill2 = connector & 4 ? "\u2500" : " ";
19253
+ const fill2 = connector & 4 ? "" : " ";
19254
19254
  const node = grid[column][lane];
19255
19255
  if (!node) {
19256
19256
  if (column < columnCount - 1) {
@@ -19264,7 +19264,7 @@ m2: ${this.mapper2.__debugToString().split(`
19264
19264
  }
19265
19265
  }
19266
19266
  writeLane(lane, getBoxCharacter(connector));
19267
- writeLane(lane, connector & 8 && column < columnCount - 1 && !grid[column + 1][lane] ? "\u2500" : " ");
19267
+ writeLane(lane, connector & 8 && column < columnCount - 1 && !grid[column + 1][lane] ? "" : " ");
19268
19268
  }
19269
19269
  }
19270
19270
  return `
@@ -19278,27 +19278,27 @@ ${lanes.join(`
19278
19278
  function getBoxCharacter(connector) {
19279
19279
  switch (connector) {
19280
19280
  case 3:
19281
- return "\u2502";
19281
+ return "";
19282
19282
  case 12:
19283
- return "\u2500";
19283
+ return "";
19284
19284
  case 5:
19285
- return "\u256F";
19285
+ return "";
19286
19286
  case 9:
19287
- return "\u2570";
19287
+ return "";
19288
19288
  case 6:
19289
- return "\u256E";
19289
+ return "";
19290
19290
  case 10:
19291
- return "\u256D";
19291
+ return "";
19292
19292
  case 7:
19293
- return "\u2524";
19293
+ return "";
19294
19294
  case 11:
19295
- return "\u251C";
19295
+ return "";
19296
19296
  case 13:
19297
- return "\u2534";
19297
+ return "";
19298
19298
  case 14:
19299
- return "\u252C";
19299
+ return "";
19300
19300
  case 15:
19301
- return "\u256B";
19301
+ return "";
19302
19302
  }
19303
19303
  return " ";
19304
19304
  }
@@ -26364,7 +26364,7 @@ ${lanes.join(`
26364
26364
  Object.defineProperty(scanner2, "__debugShowCurrentPositionInText", {
26365
26365
  get: () => {
26366
26366
  const text2 = scanner2.getText();
26367
- return text2.slice(0, scanner2.getTokenFullStart()) + "\u2551" + text2.slice(scanner2.getTokenFullStart());
26367
+ return text2.slice(0, scanner2.getTokenFullStart()) + "" + text2.slice(scanner2.getTokenFullStart());
26368
26368
  }
26369
26369
  });
26370
26370
  }
@@ -33868,7 +33868,7 @@ ${lanes.join(`
33868
33868
  "`": "\\`",
33869
33869
  "\u2028": "\\u2028",
33870
33870
  "\u2029": "\\u2029",
33871
- "\x85": "\\u0085",
33871
+ "…": "\\u0085",
33872
33872
  "\r\n": "\\r\\n"
33873
33873
  }));
33874
33874
  function encodeUtf16EscapeSequence(charCode) {
@@ -127698,7 +127698,7 @@ ${lanes.join(`
127698
127698
  return contains(screenStartingMessageCodes, diagnostic.code) ? newLine + newLine : newLine;
127699
127699
  }
127700
127700
  function getLocaleTimeString(system) {
127701
- return !system.now ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }).replace("\u202F", " ");
127701
+ return !system.now ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }).replace("", " ");
127702
127702
  }
127703
127703
  function createWatchStatusReporter(system, pretty) {
127704
127704
  return pretty ? (diagnostic, newLine, options) => {
@@ -186770,15 +186770,15 @@ var require_errors2 = __commonJS((exports) => {
186770
186770
  let lineStr = src.substring(lc.lineStarts[line - 1], lc.lineStarts[line]).replace(/[\n\r]+$/, "");
186771
186771
  if (ci >= 60 && lineStr.length > 80) {
186772
186772
  const trimStart = Math.min(ci - 39, lineStr.length - 79);
186773
- lineStr = "\u2026" + lineStr.substring(trimStart);
186773
+ lineStr = "" + lineStr.substring(trimStart);
186774
186774
  ci -= trimStart - 1;
186775
186775
  }
186776
186776
  if (lineStr.length > 80)
186777
- lineStr = lineStr.substring(0, 79) + "\u2026";
186777
+ lineStr = lineStr.substring(0, 79) + "";
186778
186778
  if (line > 1 && /^ *$/.test(lineStr.substring(0, ci))) {
186779
186779
  let prev = src.substring(lc.lineStarts[line - 2], lc.lineStarts[line - 1]);
186780
186780
  if (prev.length > 80)
186781
- prev = prev.substring(0, 79) + `\u2026
186781
+ prev = prev.substring(0, 79) + `…
186782
186782
  `;
186783
186783
  lineStr = prev + lineStr;
186784
186784
  }
@@ -187833,8 +187833,8 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
187833
187833
  r: "\r",
187834
187834
  t: "\t",
187835
187835
  v: "\v",
187836
- N: "\x85",
187837
- _: "\xA0",
187836
+ N: "…",
187837
+ _: " ",
187838
187838
  L: "\u2028",
187839
187839
  P: "\u2029",
187840
187840
  " ": " ",
@@ -188105,7 +188105,7 @@ var require_composer = __commonJS((exports) => {
188105
188105
  var node_process = __require("process");
188106
188106
  var directives = require_directives();
188107
188107
  var Document = require_Document();
188108
- var errors4 = require_errors2();
188108
+ var errors5 = require_errors2();
188109
188109
  var identity = require_identity();
188110
188110
  var composeDoc = require_compose_doc();
188111
188111
  var resolveEnd = require_resolve_end();
@@ -188156,9 +188156,9 @@ var require_composer = __commonJS((exports) => {
188156
188156
  this.onError = (source, code, message, warning) => {
188157
188157
  const pos = getErrorPos(source);
188158
188158
  if (warning)
188159
- this.warnings.push(new errors4.YAMLWarning(pos, code, message));
188159
+ this.warnings.push(new errors5.YAMLWarning(pos, code, message));
188160
188160
  else
188161
- this.errors.push(new errors4.YAMLParseError(pos, code, message));
188161
+ this.errors.push(new errors5.YAMLParseError(pos, code, message));
188162
188162
  };
188163
188163
  this.directives = new directives.Directives({ version: options.version || "1.2" });
188164
188164
  this.options = options;
@@ -188242,7 +188242,7 @@ ${cb}` : comment;
188242
188242
  break;
188243
188243
  case "error": {
188244
188244
  const msg = token.source ? `${token.message}: ${JSON.stringify(token.source)}` : token.message;
188245
- const error2 = new errors4.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg);
188245
+ const error2 = new errors5.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg);
188246
188246
  if (this.atDirectives || !this.doc)
188247
188247
  this.errors.push(error2);
188248
188248
  else
@@ -188252,7 +188252,7 @@ ${cb}` : comment;
188252
188252
  case "doc-end": {
188253
188253
  if (!this.doc) {
188254
188254
  const msg = "Unexpected doc-end without preceding document";
188255
- this.errors.push(new errors4.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg));
188255
+ this.errors.push(new errors5.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg));
188256
188256
  break;
188257
188257
  }
188258
188258
  this.doc.directives.docEnd = true;
@@ -188267,7 +188267,7 @@ ${end.comment}` : end.comment;
188267
188267
  break;
188268
188268
  }
188269
188269
  default:
188270
- this.errors.push(new errors4.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", `Unsupported token ${token.type}`));
188270
+ this.errors.push(new errors5.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", `Unsupported token ${token.type}`));
188271
188271
  }
188272
188272
  }
188273
188273
  *end(forceDoc = false, endOffset = -1) {
@@ -188293,7 +188293,7 @@ ${end.comment}` : end.comment;
188293
188293
  var require_cst_scalar = __commonJS((exports) => {
188294
188294
  var resolveBlockScalar = require_resolve_block_scalar();
188295
188295
  var resolveFlowScalar = require_resolve_flow_scalar();
188296
- var errors4 = require_errors2();
188296
+ var errors5 = require_errors2();
188297
188297
  var stringifyString = require_stringifyString();
188298
188298
  function resolveAsScalar(token, strict = true, onError) {
188299
188299
  if (token) {
@@ -188302,7 +188302,7 @@ var require_cst_scalar = __commonJS((exports) => {
188302
188302
  if (onError)
188303
188303
  onError(offset, code, message);
188304
188304
  else
188305
- throw new errors4.YAMLParseError([offset, offset + 1], code, message);
188305
+ throw new errors5.YAMLParseError([offset, offset + 1], code, message);
188306
188306
  };
188307
188307
  switch (token.type) {
188308
188308
  case "scalar":
@@ -190164,7 +190164,7 @@ var require_parser = __commonJS((exports) => {
190164
190164
  var require_public_api = __commonJS((exports) => {
190165
190165
  var composer = require_composer();
190166
190166
  var Document = require_Document();
190167
- var errors4 = require_errors2();
190167
+ var errors5 = require_errors2();
190168
190168
  var log = require_log();
190169
190169
  var identity = require_identity();
190170
190170
  var lineCounter = require_line_counter();
@@ -190181,8 +190181,8 @@ var require_public_api = __commonJS((exports) => {
190181
190181
  const docs = Array.from(composer$1.compose(parser$1.parse(source)));
190182
190182
  if (prettyErrors && lineCounter2)
190183
190183
  for (const doc2 of docs) {
190184
- doc2.errors.forEach(errors4.prettifyError(source, lineCounter2));
190185
- doc2.warnings.forEach(errors4.prettifyError(source, lineCounter2));
190184
+ doc2.errors.forEach(errors5.prettifyError(source, lineCounter2));
190185
+ doc2.warnings.forEach(errors5.prettifyError(source, lineCounter2));
190186
190186
  }
190187
190187
  if (docs.length > 0)
190188
190188
  return docs;
@@ -190197,13 +190197,13 @@ var require_public_api = __commonJS((exports) => {
190197
190197
  if (!doc2)
190198
190198
  doc2 = _doc;
190199
190199
  else if (doc2.options.logLevel !== "silent") {
190200
- doc2.errors.push(new errors4.YAMLParseError(_doc.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
190200
+ doc2.errors.push(new errors5.YAMLParseError(_doc.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
190201
190201
  break;
190202
190202
  }
190203
190203
  }
190204
190204
  if (prettyErrors && lineCounter2) {
190205
- doc2.errors.forEach(errors4.prettifyError(source, lineCounter2));
190206
- doc2.warnings.forEach(errors4.prettifyError(source, lineCounter2));
190205
+ doc2.errors.forEach(errors5.prettifyError(source, lineCounter2));
190206
+ doc2.warnings.forEach(errors5.prettifyError(source, lineCounter2));
190207
190207
  }
190208
190208
  return doc2;
190209
190209
  }
@@ -190255,7 +190255,7 @@ var require_public_api = __commonJS((exports) => {
190255
190255
  });
190256
190256
 
190257
190257
  // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.25.1+fde825ba4efdc684/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
190258
- import process2 from "process";
190258
+ import process2 from "node:process";
190259
190259
 
190260
190260
  // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v4/core/core.js
190261
190261
  var NEVER = Object.freeze({
@@ -203178,11 +203178,11 @@ var ContractInputSchema = exports_external.object({
203178
203178
 
203179
203179
  // ../extract/src/extract-interfaces.ts
203180
203180
  var import_fast_glob = __toESM(require_out4(), 1);
203181
- import { stat as stat2 } from "fs/promises";
203181
+ import { stat as stat2 } from "node:fs/promises";
203182
203182
 
203183
203183
  // ../extract/src/parsers/codeParser.ts
203184
- import { readFile } from "fs/promises";
203185
- import { extname as extname2 } from "path";
203184
+ import { readFile } from "node:fs/promises";
203185
+ import { extname as extname2 } from "node:path";
203186
203186
 
203187
203187
  // ../extract/src/parsers/astBuilder.ts
203188
203188
  function buildSimplifiedAST(content, analysis, maxDepth) {
@@ -203301,12 +203301,12 @@ function calculateMetrics(content, interfaces, functions, imports, exports) {
203301
203301
 
203302
203302
  // ../extract/src/parsers/treeSitter.ts
203303
203303
  var import_web_tree_sitter = __toESM(require_tree_sitter(), 1);
203304
- import { existsSync } from "fs";
203305
- import { stat } from "fs/promises";
203306
- import { createRequire } from "module";
203307
- import { dirname, join } from "path";
203308
- import { fileURLToPath } from "url";
203309
- var require2 = createRequire(import.meta.url);
203304
+ import { existsSync } from "node:fs";
203305
+ import { stat } from "node:fs/promises";
203306
+ import { createRequire as createRequire2 } from "node:module";
203307
+ import { dirname, join } from "node:path";
203308
+ import { fileURLToPath } from "node:url";
203309
+ var require2 = createRequire2(import.meta.url);
203310
203310
  var initPromise2 = null;
203311
203311
  var languageCache = new Map;
203312
203312
  async function parseWithTreeSitter(languageKey, wasmFileName, content) {
@@ -203372,7 +203372,7 @@ async function resolveLanguageWasm(languageKey, wasmFileName) {
203372
203372
  return candidate;
203373
203373
  } catch {}
203374
203374
  }
203375
- throw new Error(`WASM not found for ${languageKey}. \u8BF7\u63D0\u4F9B ${envKey} \u6216 C4A_TREE_SITTER_WASM_DIR`);
203375
+ throw new Error(`WASM not found for ${languageKey}. 请提供 ${envKey} C4A_TREE_SITTER_WASM_DIR`);
203376
203376
  }
203377
203377
  function resolveLocalWasmDir() {
203378
203378
  return fileURLToPath(new URL("../../wasm", import.meta.url));
@@ -203388,7 +203388,7 @@ async function parseGo(filePath, content) {
203388
203388
  } catch (error2) {
203389
203389
  const analysis = parseGoWithRegex(filePath, content);
203390
203390
  analysis.warnings = [
203391
- `tree-sitter-go \u4E0D\u53EF\u7528\uFF0C\u5DF2\u56DE\u9000\u5230\u6B63\u5219\u89E3\u6790: ${error2 instanceof Error ? error2.message : String(error2)}`
203391
+ `tree-sitter-go 不可用,已回退到正则解析: ${error2 instanceof Error ? error2.message : String(error2)}`
203392
203392
  ];
203393
203393
  return analysis;
203394
203394
  }
@@ -203791,7 +203791,7 @@ function walk(node, visit) {
203791
203791
 
203792
203792
  // ../extract/src/parsers/typescriptParser.ts
203793
203793
  var import_typescript = __toESM(require_typescript(), 1);
203794
- import { extname } from "path";
203794
+ import { extname } from "node:path";
203795
203795
  function parseTypeScript(filePath, content) {
203796
203796
  const sourceFile = import_typescript.default.createSourceFile(filePath, content, import_typescript.default.ScriptTarget.Latest, true, getScriptKind(filePath));
203797
203797
  const imports = [];
@@ -204155,57 +204155,22 @@ async function extractAST(filePath, content, maxDepth = 10, language) {
204155
204155
  return buildSimplifiedAST(fileContent, analysis, maxDepth);
204156
204156
  }
204157
204157
  // ../extract/src/utils/pathGuard.ts
204158
- import { resolve as resolve2, relative as relative2 } from "path";
204159
-
204160
- // ../../node_modules/.bun/yaml@2.8.2/node_modules/yaml/dist/index.js
204161
- var composer = require_composer();
204162
- var Document = require_Document();
204163
- var Schema = require_Schema();
204164
- var errors4 = require_errors2();
204165
- var Alias = require_Alias();
204166
- var identity = require_identity();
204167
- var Pair = require_Pair();
204168
- var Scalar = require_Scalar();
204169
- var YAMLMap = require_YAMLMap();
204170
- var YAMLSeq = require_YAMLSeq();
204171
- var cst = require_cst();
204172
- var lexer = require_lexer();
204173
- var lineCounter = require_line_counter();
204174
- var parser = require_parser();
204175
- var publicApi = require_public_api();
204176
- var visit = require_visit();
204177
- var $Composer = composer.Composer;
204178
- var $Document = Document.Document;
204179
- var $Schema = Schema.Schema;
204180
- var $YAMLError = errors4.YAMLError;
204181
- var $YAMLParseError = errors4.YAMLParseError;
204182
- var $YAMLWarning = errors4.YAMLWarning;
204183
- var $Alias = Alias.Alias;
204184
- var $isAlias = identity.isAlias;
204185
- var $isCollection = identity.isCollection;
204186
- var $isDocument = identity.isDocument;
204187
- var $isMap = identity.isMap;
204188
- var $isNode = identity.isNode;
204189
- var $isPair = identity.isPair;
204190
- var $isScalar = identity.isScalar;
204191
- var $isSeq = identity.isSeq;
204192
- var $Pair = Pair.Pair;
204193
- var $Scalar = Scalar.Scalar;
204194
- var $YAMLMap = YAMLMap.YAMLMap;
204195
- var $YAMLSeq = YAMLSeq.YAMLSeq;
204196
- var $Lexer = lexer.Lexer;
204197
- var $LineCounter = lineCounter.LineCounter;
204198
- var $Parser = parser.Parser;
204199
- var $parse = publicApi.parse;
204200
- var $parseAllDocuments = publicApi.parseAllDocuments;
204201
- var $parseDocument = publicApi.parseDocument;
204202
- var $stringify = publicApi.stringify;
204203
- var $visit = visit.visit;
204204
- var $visitAsync = visit.visitAsync;
204205
- // ../core/src/utils/security.ts
204206
- import { lstat, open, realpath } from "fs/promises";
204207
- import { isAbsolute, relative, resolve } from "path";
204158
+ import { resolve as resolve2, relative as relative2 } from "node:path";
204208
204159
 
204160
+ // ../core/src/types/base.ts
204161
+ var ENTITY_TYPE_DEFS = {
204162
+ product: { dir: "products", perspective: "business", kind: "concept", scope: null },
204163
+ system: { dir: "systems", perspective: "technical", kind: "implementation", scope: "project" },
204164
+ container: { dir: "containers", perspective: "technical", kind: "implementation", scope: "project" },
204165
+ component: { dir: "components", perspective: "technical", kind: "implementation", scope: "project" },
204166
+ process: { dir: "processes", perspective: null, kind: "concept", scope: null },
204167
+ sor: { dir: "sors", perspective: null, kind: "concept", scope: null },
204168
+ contract: { dir: "contracts", perspective: "technical", kind: "implementation", scope: "project" },
204169
+ document: { dir: "documents", perspective: null, kind: null, scope: null },
204170
+ feat: { dir: "feats", perspective: null, kind: null, scope: null }
204171
+ };
204172
+ var ENTITY_TYPE_TO_DIR = Object.fromEntries(Object.entries(ENTITY_TYPE_DEFS).map(([type, def]) => [type, def.dir]));
204173
+ var DIR_TO_ENTITY_TYPE = Object.fromEntries(Object.entries(ENTITY_TYPE_DEFS).map(([type, def]) => [def.dir, type]));
204209
204174
  // ../core/src/types/errors.ts
204210
204175
  var INPUT_ERROR_CODES = {
204211
204176
  MISSING_REQUIRED_FIELD: "C4A-INPUT-001",
@@ -204350,69 +204315,69 @@ var ERROR_CODE_TO_HTTP_STATUS = {
204350
204315
  "C4A-VISUAL-001": 500
204351
204316
  };
204352
204317
  var ERROR_MESSAGES = {
204353
- "C4A-INPUT-001": { zh: "\u7F3A\u5C11\u5FC5\u586B\u5B57\u6BB5", en: "Missing required field" },
204354
- "C4A-INPUT-002": { zh: "\u5B57\u6BB5\u683C\u5F0F\u9519\u8BEF", en: "Invalid field format" },
204355
- "C4A-INPUT-003": { zh: "\u5B57\u6BB5\u503C\u8D85\u51FA\u8303\u56F4", en: "Field value out of range" },
204356
- "C4A-INPUT-004": { zh: "\u65E0\u6548\u7684\u5B9E\u4F53\u7C7B\u578B", en: "Invalid entity type" },
204357
- "C4A-INPUT-005": { zh: "\u65E0\u6548\u7684 ID \u683C\u5F0F", en: "Invalid ID format" },
204358
- "C4A-INPUT-006": { zh: "\u8DEF\u5F84\u5FC5\u987B\u5728\u9879\u76EE\u6839\u76EE\u5F55\u5185", en: "Path must be within project root" },
204359
- "C4A-INPUT-007": { zh: "\u8DEF\u5F84\u5305\u542B\u975E\u6CD5\u5B57\u7B26", en: "Path contains invalid characters" },
204360
- "C4A-DATA-001": { zh: "\u5F15\u7528\u7684\u5B9E\u4F53\u4E0D\u5B58\u5728", en: "Referenced entity not found" },
204361
- "C4A-DATA-002": { zh: "\u5B9E\u4F53\u5DF2\u5B58\u5728", en: "Entity already exists" },
204362
- "C4A-DATA-003": { zh: "\u68C0\u6D4B\u5230\u5FAA\u73AF\u4F9D\u8D56", en: "Circular dependency detected" },
204363
- "C4A-DATA-004": { zh: "\u5B58\u5728\u60AC\u7A7A\u5F15\u7528", en: "Dangling reference detected" },
204364
- "C4A-DATA-005": { zh: "\u7248\u672C\u51B2\u7A81\uFF0C\u8BF7\u83B7\u53D6\u6700\u65B0\u7248\u672C", en: "Version conflict, please fetch latest" },
204365
- "C4A-DATA-006": { zh: "\u5173\u7CFB\u7C7B\u578B\u4E0D\u5339\u914D", en: "Relation type mismatch" },
204366
- "C4A-DATA-007": { zh: "\u8DE8\u5C42\u7EA7\u5F15\u7528\u65E0\u6548", en: "Invalid cross-scope reference" },
204367
- "C4A-SYS-001": { zh: "\u6570\u636E\u5E93\u8FDE\u63A5\u5931\u8D25", en: "Database connection failed" },
204368
- "C4A-SYS-002": { zh: "MCP \u5DE5\u5177\u8C03\u7528\u8D85\u65F6", en: "MCP tool call timeout" },
204369
- "C4A-SYS-003": { zh: "\u5185\u90E8\u670D\u52A1\u9519\u8BEF", en: "Internal service error" },
204370
- "C4A-SYS-004": { zh: "\u5411\u91CF\u641C\u7D22\u670D\u52A1\u4E0D\u53EF\u7528", en: "Vector search service unavailable" },
204371
- "C4A-SYS-005": { zh: "\u8FDC\u7A0B\u670D\u52A1\u4E0D\u53EF\u7528", en: "Remote service unavailable" },
204372
- "C4A-SYS-006": { zh: "Gateway \u8D85\u65F6", en: "Gateway timeout" },
204373
- "C4A-SYS-007": { zh: "\u4E0A\u6E38\u670D\u52A1\u9519\u8BEF", en: "Bad gateway" },
204374
- "C4A-SYS-008": { zh: "Gateway \u670D\u52A1\u4E0D\u53EF\u7528", en: "Gateway service unavailable" },
204375
- "C4A-SYS-009": { zh: "\u4F20\u8F93\u5C42\u9519\u8BEF", en: "Transport error" },
204376
- "C4A-BIZ-003": { zh: "\u4E00\u81F4\u6027\u68C0\u67E5\u5931\u8D25", en: "Consistency check failed" },
204377
- "C4A-BIZ-004": { zh: "\u5408\u5E76\u51B2\u7A81", en: "Merge conflict" },
204378
- "C4A-BIZ-005": { zh: "\u5B9E\u4F53\u88AB\u5F15\u7528\uFF0C\u65E0\u6CD5\u5220\u9664", en: "Entity is referenced, cannot delete" },
204318
+ "C4A-INPUT-001": { zh: "缺少必填字段", en: "Missing required field" },
204319
+ "C4A-INPUT-002": { zh: "字段格式错误", en: "Invalid field format" },
204320
+ "C4A-INPUT-003": { zh: "字段值超出范围", en: "Field value out of range" },
204321
+ "C4A-INPUT-004": { zh: "无效的实体类型", en: "Invalid entity type" },
204322
+ "C4A-INPUT-005": { zh: "无效的 ID 格式", en: "Invalid ID format" },
204323
+ "C4A-INPUT-006": { zh: "路径必须在项目根目录内", en: "Path must be within project root" },
204324
+ "C4A-INPUT-007": { zh: "路径包含非法字符", en: "Path contains invalid characters" },
204325
+ "C4A-DATA-001": { zh: "引用的实体不存在", en: "Referenced entity not found" },
204326
+ "C4A-DATA-002": { zh: "实体已存在", en: "Entity already exists" },
204327
+ "C4A-DATA-003": { zh: "检测到循环依赖", en: "Circular dependency detected" },
204328
+ "C4A-DATA-004": { zh: "存在悬空引用", en: "Dangling reference detected" },
204329
+ "C4A-DATA-005": { zh: "版本冲突,请获取最新版本", en: "Version conflict, please fetch latest" },
204330
+ "C4A-DATA-006": { zh: "关系类型不匹配", en: "Relation type mismatch" },
204331
+ "C4A-DATA-007": { zh: "跨层级引用无效", en: "Invalid cross-scope reference" },
204332
+ "C4A-SYS-001": { zh: "数据库连接失败", en: "Database connection failed" },
204333
+ "C4A-SYS-002": { zh: "MCP 工具调用超时", en: "MCP tool call timeout" },
204334
+ "C4A-SYS-003": { zh: "内部服务错误", en: "Internal service error" },
204335
+ "C4A-SYS-004": { zh: "向量搜索服务不可用", en: "Vector search service unavailable" },
204336
+ "C4A-SYS-005": { zh: "远程服务不可用", en: "Remote service unavailable" },
204337
+ "C4A-SYS-006": { zh: "Gateway 超时", en: "Gateway timeout" },
204338
+ "C4A-SYS-007": { zh: "上游服务错误", en: "Bad gateway" },
204339
+ "C4A-SYS-008": { zh: "Gateway 服务不可用", en: "Gateway service unavailable" },
204340
+ "C4A-SYS-009": { zh: "传输层错误", en: "Transport error" },
204341
+ "C4A-BIZ-003": { zh: "一致性检查失败", en: "Consistency check failed" },
204342
+ "C4A-BIZ-004": { zh: "合并冲突", en: "Merge conflict" },
204343
+ "C4A-BIZ-005": { zh: "实体被引用,无法删除", en: "Entity is referenced, cannot delete" },
204379
204344
  "C4A-STORE-001": {
204380
- zh: "\u68C0\u6D4B\u5230\u5E76\u53D1\u4FEE\u6539\uFF0C\u8BF7\u534F\u8C03\u53D8\u66F4\u8303\u56F4",
204345
+ zh: "检测到并发修改,请协调变更范围",
204381
204346
  en: "Concurrent modification detected"
204382
204347
  },
204383
- "C4A-STORE-002": { zh: "\u7F3A\u5C11\u5173\u8054\u7684 ADR", en: "Missing related ADR" },
204384
- "C4A-STORE-003": { zh: "\u5B9E\u4F53\u88AB\u5176\u4ED6\u5B9E\u4F53\u5F15\u7528\uFF0C\u65E0\u6CD5\u5220\u9664", en: "Entity is referenced, cannot delete" },
204385
- "C4A-DEL-001": { zh: "\u5B9E\u4F53\u5B58\u5728\u4E0B\u6E38\u4F9D\u8D56\uFF0C\u65E0\u6CD5\u5220\u9664", en: "Entity has downstream dependencies" },
204386
- "C4A-PERM-001": { zh: "\u65E0\u5199\u6743\u9650", en: "No write permission" },
204387
- "C4A-PERM-002": { zh: "\u65E0\u6279\u51C6\u6743\u9650", en: "No approve permission" },
204388
- "C4A-PERM-003": { zh: "\u65E0\u8BFB\u6743\u9650", en: "No read permission" },
204389
- "C4A-PERM-004": { zh: "\u8BA4\u8BC1\u5931\u8D25", en: "Authentication failed" },
204390
- "C4A-PERM-005": { zh: "\u8DE8\u9879\u76EE\u64CD\u4F5C\u6743\u9650\u4E0D\u8DB3", en: "Insufficient cross-project permission" },
204391
- "C4A-MIGRATE-001": { zh: "\u7F3A\u5C11 root_id \u5B57\u6BB5", en: "Missing root_id field" },
204392
- "C4A-MIGRATE-002": { zh: "\u7F3A\u5C11 source_repo \u5B57\u6BB5", en: "Missing source_repo field" },
204393
- "C4A-MIGRATE-003": { zh: "root_id \u683C\u5F0F\u4E0D\u6B63\u786E", en: "Invalid root_id format" },
204394
- "C4A-MIGRATE-004": { zh: "source_repo \u683C\u5F0F\u5EFA\u8BAE\u6539\u8FDB", en: "source_repo format should be owner/repo" },
204348
+ "C4A-STORE-002": { zh: "缺少关联的 ADR", en: "Missing related ADR" },
204349
+ "C4A-STORE-003": { zh: "实体被其他实体引用,无法删除", en: "Entity is referenced, cannot delete" },
204350
+ "C4A-DEL-001": { zh: "实体存在下游依赖,无法删除", en: "Entity has downstream dependencies" },
204351
+ "C4A-PERM-001": { zh: "无写权限", en: "No write permission" },
204352
+ "C4A-PERM-002": { zh: "无批准权限", en: "No approve permission" },
204353
+ "C4A-PERM-003": { zh: "无读权限", en: "No read permission" },
204354
+ "C4A-PERM-004": { zh: "认证失败", en: "Authentication failed" },
204355
+ "C4A-PERM-005": { zh: "跨项目操作权限不足", en: "Insufficient cross-project permission" },
204356
+ "C4A-MIGRATE-001": { zh: "缺少 root_id 字段", en: "Missing root_id field" },
204357
+ "C4A-MIGRATE-002": { zh: "缺少 source_repo 字段", en: "Missing source_repo field" },
204358
+ "C4A-MIGRATE-003": { zh: "root_id 格式不正确", en: "Invalid root_id format" },
204359
+ "C4A-MIGRATE-004": { zh: "source_repo 格式建议改进", en: "source_repo format should be owner/repo" },
204395
204360
  "C4A-MIGRATE-005": {
204396
- zh: "Domain/Enterprise \u5C42\u7EA7\u4E0D\u5E94\u6709 root_id",
204361
+ zh: "Domain/Enterprise 层级不应有 root_id",
204397
204362
  en: "Domain/Enterprise scope should not have root_id"
204398
204363
  },
204399
204364
  "C4A-MIGRATE-006": {
204400
- zh: "Domain/Enterprise \u5C42\u7EA7\u4E0D\u5E94\u6709 source_repo",
204365
+ zh: "Domain/Enterprise 层级不应有 source_repo",
204401
204366
  en: "Domain/Enterprise scope should not have source_repo"
204402
204367
  },
204403
204368
  "C4A-MIGRATE-007": {
204404
- zh: "external \u5B9E\u4F53\u4E0D\u5E94\u6709 root_id",
204369
+ zh: "external 实体不应有 root_id",
204405
204370
  en: "External entity should not have root_id"
204406
204371
  },
204407
- "C4A-MIGRATE-008": { zh: "external \u5B9E\u4F53\u7F3A\u5C11 external_url", en: "External entity missing external_url" },
204408
- "C4A-VERSION-002": { zh: "\u7248\u672C\u683C\u5F0F\u65E0\u6548", en: "Invalid version format" },
204409
- "C4A-VERSION-003": { zh: "\u7248\u672C\u4E0D\u5B58\u5728", en: "Version not found" },
204410
- "C4A-VERSION-004": { zh: "\u65E0\u53EF\u56DE\u9000\u7684\u6B63\u5F0F\u7248\u672C", en: "No fallback stable version" },
204411
- "C4A-VERSION-005": { zh: "\u4E0D\u5141\u8BB8\u624B\u52A8\u6DFB\u52A0 0.0.0", en: "Cannot manually add 0.0.0" },
204412
- "C4A-VERSION-010": { zh: "\u6B63\u5F0F\u7248\u4E0D\u53EF\u4FEE\u6539", en: "Stable version is write-protected" },
204413
- "C4A-EXTRACT-001": { zh: "Extract MCP \u5185\u90E8\u9519\u8BEF", en: "Extract MCP internal error" },
204414
- "C4A-QUERY-001": { zh: "Query MCP \u5185\u90E8\u9519\u8BEF", en: "Query MCP internal error" },
204415
- "C4A-VISUAL-001": { zh: "Visual MCP \u5185\u90E8\u9519\u8BEF", en: "Visual MCP internal error" }
204372
+ "C4A-MIGRATE-008": { zh: "external 实体缺少 external_url", en: "External entity missing external_url" },
204373
+ "C4A-VERSION-002": { zh: "版本格式无效", en: "Invalid version format" },
204374
+ "C4A-VERSION-003": { zh: "版本不存在", en: "Version not found" },
204375
+ "C4A-VERSION-004": { zh: "无可回退的正式版本", en: "No fallback stable version" },
204376
+ "C4A-VERSION-005": { zh: "不允许手动添加 0.0.0", en: "Cannot manually add 0.0.0" },
204377
+ "C4A-VERSION-010": { zh: "正式版不可修改", en: "Stable version is write-protected" },
204378
+ "C4A-EXTRACT-001": { zh: "Extract MCP 内部错误", en: "Extract MCP internal error" },
204379
+ "C4A-QUERY-001": { zh: "Query MCP 内部错误", en: "Query MCP internal error" },
204380
+ "C4A-VISUAL-001": { zh: "Visual MCP 内部错误", en: "Visual MCP internal error" }
204416
204381
  };
204417
204382
 
204418
204383
  class C4AError extends Error {
@@ -204464,12 +204429,58 @@ function errorToMcpResponse(error2) {
204464
204429
  const message = error2 instanceof Error ? error2.message : String(error2);
204465
204430
  return {
204466
204431
  code: SYS_ERROR_CODES.INTERNAL_ERROR,
204467
- message: `\u5185\u90E8\u9519\u8BEF: ${message}`,
204432
+ message: `内部错误: ${message}`,
204468
204433
  timestamp: new Date().toISOString()
204469
204434
  };
204470
204435
  }
204471
-
204436
+ // ../../node_modules/.bun/yaml@2.8.2/node_modules/yaml/dist/index.js
204437
+ var composer = require_composer();
204438
+ var Document = require_Document();
204439
+ var Schema = require_Schema();
204440
+ var errors5 = require_errors2();
204441
+ var Alias = require_Alias();
204442
+ var identity = require_identity();
204443
+ var Pair = require_Pair();
204444
+ var Scalar = require_Scalar();
204445
+ var YAMLMap = require_YAMLMap();
204446
+ var YAMLSeq = require_YAMLSeq();
204447
+ var cst = require_cst();
204448
+ var lexer = require_lexer();
204449
+ var lineCounter = require_line_counter();
204450
+ var parser = require_parser();
204451
+ var publicApi = require_public_api();
204452
+ var visit = require_visit();
204453
+ var $Composer = composer.Composer;
204454
+ var $Document = Document.Document;
204455
+ var $Schema = Schema.Schema;
204456
+ var $YAMLError = errors5.YAMLError;
204457
+ var $YAMLParseError = errors5.YAMLParseError;
204458
+ var $YAMLWarning = errors5.YAMLWarning;
204459
+ var $Alias = Alias.Alias;
204460
+ var $isAlias = identity.isAlias;
204461
+ var $isCollection = identity.isCollection;
204462
+ var $isDocument = identity.isDocument;
204463
+ var $isMap = identity.isMap;
204464
+ var $isNode = identity.isNode;
204465
+ var $isPair = identity.isPair;
204466
+ var $isScalar = identity.isScalar;
204467
+ var $isSeq = identity.isSeq;
204468
+ var $Pair = Pair.Pair;
204469
+ var $Scalar = Scalar.Scalar;
204470
+ var $YAMLMap = YAMLMap.YAMLMap;
204471
+ var $YAMLSeq = YAMLSeq.YAMLSeq;
204472
+ var $Lexer = lexer.Lexer;
204473
+ var $LineCounter = lineCounter.LineCounter;
204474
+ var $Parser = parser.Parser;
204475
+ var $parse = publicApi.parse;
204476
+ var $parseAllDocuments = publicApi.parseAllDocuments;
204477
+ var $parseDocument = publicApi.parseDocument;
204478
+ var $stringify = publicApi.stringify;
204479
+ var $visit = visit.visit;
204480
+ var $visitAsync = visit.visitAsync;
204472
204481
  // ../core/src/utils/security.ts
204482
+ import { lstat, open, realpath } from "node:fs/promises";
204483
+ import { isAbsolute, relative, resolve } from "node:path";
204473
204484
  var WINDOWS_DRIVE_REGEX = /^[a-zA-Z]:[\\/]/;
204474
204485
  function normalizeInputPath(inputPath) {
204475
204486
  let normalized = inputPath.replace(/\\/g, "/");
@@ -204504,33 +204515,33 @@ async function resolveRealPathIfExists(targetPath) {
204504
204515
  }
204505
204516
  async function validatePath(inputPath, projectRoot) {
204506
204517
  if (!inputPath || typeof inputPath !== "string") {
204507
- return buildInvalid(INPUT_ERROR_CODES.INVALID_PATH_CHARS, "\u8DEF\u5F84\u4E0D\u80FD\u4E3A\u7A7A");
204518
+ return buildInvalid(INPUT_ERROR_CODES.INVALID_PATH_CHARS, "路径不能为空");
204508
204519
  }
204509
204520
  const normalized = normalizeInputPath(inputPath);
204510
204521
  if (!normalized || normalized === ".") {
204511
- return buildInvalid(INPUT_ERROR_CODES.INVALID_PATH_CHARS, "\u8DEF\u5F84\u4E0D\u80FD\u4E3A\u7A7A");
204522
+ return buildInvalid(INPUT_ERROR_CODES.INVALID_PATH_CHARS, "路径不能为空");
204512
204523
  }
204513
204524
  if (normalized.startsWith("/") || normalized.startsWith("//") || WINDOWS_DRIVE_REGEX.test(normalized)) {
204514
- return buildInvalid(INPUT_ERROR_CODES.INVALID_PATH_CHARS, "\u4E0D\u5141\u8BB8\u7EDD\u5BF9\u8DEF\u5F84");
204525
+ return buildInvalid(INPUT_ERROR_CODES.INVALID_PATH_CHARS, "不允许绝对路径");
204515
204526
  }
204516
204527
  const segments = normalized.split("/");
204517
204528
  if (segments.includes("..")) {
204518
- return buildInvalid(INPUT_ERROR_CODES.INVALID_PATH_CHARS, "\u4E0D\u5141\u8BB8\u7236\u76EE\u5F55\u5F15\u7528 (..)");
204529
+ return buildInvalid(INPUT_ERROR_CODES.INVALID_PATH_CHARS, "不允许父目录引用 (..)");
204519
204530
  }
204520
204531
  const resolvedRoot = resolve(projectRoot);
204521
204532
  const resolvedPath = resolve(resolvedRoot, normalized);
204522
204533
  if (isOutsideRoot(resolvedRoot, resolvedPath)) {
204523
- return buildInvalid(INPUT_ERROR_CODES.PATH_TRAVERSAL, "\u8DEF\u5F84\u5FC5\u987B\u5728\u9879\u76EE\u6839\u76EE\u5F55\u5185");
204534
+ return buildInvalid(INPUT_ERROR_CODES.PATH_TRAVERSAL, "路径必须在项目根目录内");
204524
204535
  }
204525
204536
  const realRoot = await realpath(resolvedRoot).catch(() => resolvedRoot);
204526
204537
  let realResolved = null;
204527
204538
  try {
204528
204539
  realResolved = await resolveRealPathIfExists(resolvedPath);
204529
204540
  } catch {
204530
- return buildInvalid(INPUT_ERROR_CODES.PATH_TRAVERSAL, "\u65E0\u6CD5\u89E3\u6790\u8DEF\u5F84");
204541
+ return buildInvalid(INPUT_ERROR_CODES.PATH_TRAVERSAL, "无法解析路径");
204531
204542
  }
204532
204543
  if (realResolved && isOutsideRoot(realRoot, realResolved)) {
204533
- return buildInvalid(INPUT_ERROR_CODES.PATH_TRAVERSAL, "\u7B26\u53F7\u94FE\u63A5\u6307\u5411\u9879\u76EE\u5916");
204544
+ return buildInvalid(INPUT_ERROR_CODES.PATH_TRAVERSAL, "符号链接指向项目外");
204534
204545
  }
204535
204546
  return { valid: true };
204536
204547
  }
@@ -204559,7 +204570,21 @@ async function resolveCodePath(inputPath) {
204559
204570
  const normalized = normalizeInputPath2(inputPath);
204560
204571
  const validation = await validatePath(normalized, root);
204561
204572
  if (!validation.valid) {
204562
- throw new Error(validation.error ?? "Invalid path");
204573
+ throw new C4AError(SYS_ERROR_CODES.INTERNAL_ERROR, {
204574
+ field: "path",
204575
+ expected: "relative path within project root",
204576
+ actual: inputPath,
204577
+ suggestion: validation.error ?? "Invalid path",
204578
+ recoverable_actions: [
204579
+ {
204580
+ action: "retry",
204581
+ label: "改用相对路径重试",
204582
+ params: {
204583
+ path: "<project-relative-path>"
204584
+ }
204585
+ }
204586
+ ]
204587
+ }, `内部错误: ${validation.error ?? "Invalid path"}`);
204563
204588
  }
204564
204589
  return resolve2(root, normalized);
204565
204590
  }
@@ -204698,7 +204723,7 @@ function getDefaultPatterns(language) {
204698
204723
  }
204699
204724
  // ../extract/src/extract-analyze.ts
204700
204725
  var import_fast_glob2 = __toESM(require_out4(), 1);
204701
- import { stat as stat3 } from "fs/promises";
204726
+ import { stat as stat3 } from "node:fs/promises";
204702
204727
  async function extractAnalyze(input) {
204703
204728
  const {
204704
204729
  path,
@@ -204898,7 +204923,7 @@ function isExternalDependency(source) {
204898
204923
  return true;
204899
204924
  }
204900
204925
  // ../extract/src/extract-ast.ts
204901
- import { readFile as readFile2 } from "fs/promises";
204926
+ import { readFile as readFile2 } from "node:fs/promises";
204902
204927
  async function extractAST2(input) {
204903
204928
  const { path, language, maxDepth = 10, nodeTypes } = input;
204904
204929
  const resolvedPath = await resolveCodePath(path);
@@ -204982,7 +205007,7 @@ function updateAstFile(node, filePath) {
204982
205007
  }
204983
205008
  // ../extract/src/extract-contract.ts
204984
205009
  var import_fast_glob3 = __toESM(require_out4(), 1);
204985
- import { stat as stat4 } from "fs/promises";
205010
+ import { stat as stat4 } from "node:fs/promises";
204986
205011
 
204987
205012
  // ../extract/src/extract-contract-asyncapi.ts
204988
205013
  function generateAsyncApiContract(analyses, options) {
@@ -204990,7 +205015,7 @@ function generateAsyncApiContract(analyses, options) {
204990
205015
  version: version3 = "2.6.0",
204991
205016
  title = "Async API",
204992
205017
  description = "",
204993
- errors: errors5
205018
+ errors: errors6
204994
205019
  } = options;
204995
205020
  const allInterfaces = [];
204996
205021
  const allMethods = [];
@@ -205036,7 +205061,7 @@ function generateAsyncApiContract(analyses, options) {
205036
205061
  content: JSON.stringify(spec, null, 2),
205037
205062
  endpoints,
205038
205063
  schemas: allInterfaces.map((iface) => iface.name),
205039
- errors: errors5 && errors5.length > 0 ? errors5 : undefined
205064
+ errors: errors6 && errors6.length > 0 ? errors6 : undefined
205040
205065
  };
205041
205066
  }
205042
205067
  function buildAsyncApiChannels(methods) {
@@ -205106,7 +205131,7 @@ function generateOpenApiContract(analyses, options) {
205106
205131
  title = "API",
205107
205132
  description = "",
205108
205133
  baseUrl = "/",
205109
- errors: errors5
205134
+ errors: errors6
205110
205135
  } = options;
205111
205136
  const allInterfaces = [];
205112
205137
  const allMethods = [];
@@ -205147,7 +205172,7 @@ function generateOpenApiContract(analyses, options) {
205147
205172
  content: JSON.stringify(spec, null, 2),
205148
205173
  endpoints,
205149
205174
  schemas: allInterfaces.map((iface) => iface.name),
205150
- errors: errors5 && errors5.length > 0 ? errors5 : undefined
205175
+ errors: errors6 && errors6.length > 0 ? errors6 : undefined
205151
205176
  };
205152
205177
  }
205153
205178
  function buildOpenApiPaths(methods) {
@@ -205247,7 +205272,7 @@ function mapTypeToOpenApi2(type) {
205247
205272
 
205248
205273
  // ../extract/src/extract-contract-proto.ts
205249
205274
  function generateProtoContract(analyses, options) {
205250
- const { title = "api", errors: errors5 } = options;
205275
+ const { title = "api", errors: errors6 } = options;
205251
205276
  const allInterfaces = [];
205252
205277
  const allMethods = [];
205253
205278
  for (const analysis of analyses) {
@@ -205318,7 +205343,7 @@ function generateProtoContract(analyses, options) {
205318
205343
  `),
205319
205344
  endpoints,
205320
205345
  schemas: allInterfaces.map((iface) => iface.name),
205321
- errors: errors5 && errors5.length > 0 ? errors5 : undefined
205346
+ errors: errors6 && errors6.length > 0 ? errors6 : undefined
205322
205347
  };
205323
205348
  }
205324
205349
  function mapTypeToProto(type) {
@@ -205356,7 +205381,7 @@ async function extractContract(input) {
205356
205381
  baseUrl
205357
205382
  } = input;
205358
205383
  const resolvedPath = await resolveCodePath(path);
205359
- const errors5 = [];
205384
+ const errors6 = [];
205360
205385
  const analyses = [];
205361
205386
  const pathStat = await stat4(resolvedPath);
205362
205387
  if (pathStat.isFile()) {
@@ -205364,14 +205389,14 @@ async function extractContract(input) {
205364
205389
  const analysis = await parseFile(resolvedPath);
205365
205390
  analysis.file = getDisplayPath(resolvedPath, resolvedPath, false);
205366
205391
  if (analysis.warnings) {
205367
- errors5.push(...analysis.warnings.map((warning) => ({
205392
+ errors6.push(...analysis.warnings.map((warning) => ({
205368
205393
  file: analysis.file,
205369
205394
  error: `warning: ${warning}`
205370
205395
  })));
205371
205396
  }
205372
205397
  analyses.push(analysis);
205373
205398
  } catch (error2) {
205374
- errors5.push({
205399
+ errors6.push({
205375
205400
  file: getDisplayPath(resolvedPath, resolvedPath, false),
205376
205401
  error: error2 instanceof Error ? error2.message : String(error2)
205377
205402
  });
@@ -205391,14 +205416,14 @@ async function extractContract(input) {
205391
205416
  const analysis = await parseFile(file, undefined, lang);
205392
205417
  analysis.file = getDisplayPath(file, resolvedPath, true);
205393
205418
  if (analysis.warnings) {
205394
- errors5.push(...analysis.warnings.map((warning) => ({
205419
+ errors6.push(...analysis.warnings.map((warning) => ({
205395
205420
  file: analysis.file,
205396
205421
  error: `warning: ${warning}`
205397
205422
  })));
205398
205423
  }
205399
205424
  analyses.push(analysis);
205400
205425
  } catch (error2) {
205401
- errors5.push({
205426
+ errors6.push({
205402
205427
  file: getDisplayPath(file, resolvedPath, true),
205403
205428
  error: error2 instanceof Error ? error2.message : String(error2)
205404
205429
  });
@@ -205412,35 +205437,21 @@ async function extractContract(input) {
205412
205437
  title,
205413
205438
  description,
205414
205439
  baseUrl,
205415
- errors: errors5
205440
+ errors: errors6
205416
205441
  });
205417
205442
  case "asyncapi":
205418
205443
  return generateAsyncApiContract(analyses, {
205419
205444
  version: version3,
205420
205445
  title,
205421
205446
  description,
205422
- errors: errors5
205447
+ errors: errors6
205423
205448
  });
205424
205449
  case "proto":
205425
- return generateProtoContract(analyses, { title, errors: errors5 });
205450
+ return generateProtoContract(analyses, { title, errors: errors6 });
205426
205451
  default:
205427
205452
  throw new Error(`Unsupported format: ${format}`);
205428
205453
  }
205429
205454
  }
205430
- // ../core/src/types/base.ts
205431
- var ENTITY_TYPE_DEFS = {
205432
- product: { dir: "products", perspective: "business", kind: "concept", scope: null },
205433
- system: { dir: "systems", perspective: "technical", kind: "implementation", scope: "project" },
205434
- container: { dir: "containers", perspective: "technical", kind: "implementation", scope: "project" },
205435
- component: { dir: "components", perspective: "technical", kind: "implementation", scope: "project" },
205436
- process: { dir: "processes", perspective: null, kind: "concept", scope: null },
205437
- sor: { dir: "sors", perspective: null, kind: "concept", scope: null },
205438
- contract: { dir: "contracts", perspective: "technical", kind: "implementation", scope: "project" },
205439
- document: { dir: "documents", perspective: null, kind: null, scope: null },
205440
- feat: { dir: "feats", perspective: null, kind: null, scope: null }
205441
- };
205442
- var ENTITY_TYPE_TO_DIR = Object.fromEntries(Object.entries(ENTITY_TYPE_DEFS).map(([type, def]) => [type, def.dir]));
205443
- var DIR_TO_ENTITY_TYPE = Object.fromEntries(Object.entries(ENTITY_TYPE_DEFS).map(([type, def]) => [def.dir, type]));
205444
205455
  // src/shared/handler.ts
205445
205456
  function formatSuccess(result) {
205446
205457
  return {
@@ -205474,12 +205485,38 @@ function buildToolHandler(handler) {
205474
205485
  };
205475
205486
  }
205476
205487
 
205488
+ // src/tools/extractPath.ts
205489
+ import { isAbsolute as isAbsolute2, relative as relative3, resolve as resolve3, sep } from "node:path";
205490
+ function normalizeExtractPath(inputPath) {
205491
+ const trimmed = inputPath.trim();
205492
+ if (!trimmed || !isAbsolute2(trimmed)) {
205493
+ return trimmed;
205494
+ }
205495
+ const root = resolve3(process.env.C4A_EXTRACT_ROOT ?? process.env.C4A_CODE_ROOT ?? process.cwd());
205496
+ const resolved = resolve3(trimmed);
205497
+ if (resolved === root) {
205498
+ return ".";
205499
+ }
205500
+ const rootPrefix = root.endsWith(sep) ? root : `${root}${sep}`;
205501
+ if (resolved.startsWith(rootPrefix)) {
205502
+ const relPath = relative3(root, resolved);
205503
+ return relPath || ".";
205504
+ }
205505
+ return trimmed;
205506
+ }
205507
+
205477
205508
  // src/tools/extract.ts
205509
+ function normalizePathArg(args2) {
205510
+ return {
205511
+ ...args2,
205512
+ path: normalizeExtractPath(args2.path)
205513
+ };
205514
+ }
205478
205515
  function registerExtractTools(server2) {
205479
- server2.tool("extract_interfaces", "\u4ECE\u4EE3\u7801\u6587\u4EF6\u4E2D\u63D0\u53D6\u63A5\u53E3\u3001\u7C7B\u578B\u3001\u7C7B\u7B49\u5B9A\u4E49", ExtractInputSchema.shape, buildToolHandler((args2) => extractInterfaces(args2)));
205480
- server2.tool("extract_analyze", "\u5206\u6790\u4EE3\u7801\u7ED3\u6784\u548C\u4F9D\u8D56\u5173\u7CFB", AnalyzeInputSchema.shape, buildToolHandler((args2) => extractAnalyze(args2)));
205481
- server2.tool("extract_ast", "\u83B7\u53D6\u4EE3\u7801\u6587\u4EF6\u7684 AST \u62BD\u8C61\u8BED\u6CD5\u6811\u7ED3\u6784", ASTInputSchema.shape, buildToolHandler((args2) => extractAST2(args2)));
205482
- server2.tool("extract_contract", "\u4ECE\u4EE3\u7801\u751F\u6210 API \u5951\u7EA6\uFF08OpenAPI\u3001AsyncAPI\u3001Proto\uFF09", ContractInputSchema.shape, buildToolHandler((args2) => extractContract(args2)));
205516
+ server2.tool("extract_interfaces", "从代码文件中提取接口、类型、类等定义", ExtractInputSchema.shape, buildToolHandler((args2) => extractInterfaces(normalizePathArg(args2))));
205517
+ server2.tool("extract_analyze", "分析代码结构和依赖关系", AnalyzeInputSchema.shape, buildToolHandler((args2) => extractAnalyze(normalizePathArg(args2))));
205518
+ server2.tool("extract_ast", "获取代码文件的 AST 抽象语法树结构", ASTInputSchema.shape, buildToolHandler((args2) => extractAST2(normalizePathArg(args2))));
205519
+ server2.tool("extract_contract", "从代码生成 API 契约(OpenAPI、AsyncAPI、Proto)", ContractInputSchema.shape, buildToolHandler((args2) => extractContract(normalizePathArg(args2))));
205483
205520
  }
205484
205521
 
205485
205522
  // src/server.ts
@@ -205502,7 +205539,7 @@ async function startStdioServer() {
205502
205539
  }
205503
205540
  async function main() {
205504
205541
  if (transport !== "stdio") {
205505
- console.error(`c4a-mcp-client \u4EC5\u652F\u6301 stdio \u6A21\u5F0F\uFF0C\u5F53\u524D MCP_TRANSPORT=${transport}`);
205542
+ console.error(`c4a-mcp-client 仅支持 stdio 模式,当前 MCP_TRANSPORT=${transport}`);
205506
205543
  process.exit(1);
205507
205544
  }
205508
205545
  await startStdioServer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/mcp-client",
3
- "version": "0.3.7-beta.2",
3
+ "version": "0.3.8-beta.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "c4a-mcp-client": "./index.js"