@atlisp/mcp 1.3.5 → 1.3.7

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.
@@ -454,16 +454,18 @@ async function evalLisp(code, withResult = false, encoding = null) {
454
454
  if (!cad.connected) {
455
455
  return { content: [{ type: "text", text: "\u672A\u8FDE\u63A5 CAD" }], isError: true };
456
456
  }
457
+ const trimmed = (code || "").trim();
458
+ if (!trimmed) return { content: [{ type: "text", text: "\u547D\u4EE4\u4E3A\u7A7A\uFF0C\u672A\u53D1\u9001" }] };
457
459
  try {
458
460
  if (withResult) {
459
- const result = await cad.sendCommandWithResult(code, encoding);
461
+ const result = await cad.sendCommandWithResult(trimmed, encoding);
460
462
  if (result !== null) {
461
463
  return { content: [{ type: "text", text: result }] };
462
464
  }
463
465
  return { content: [{ type: "text", text: "\u6267\u884C\u5931\u8D25\u6216\u65E0\u8FD4\u56DE\u503C" }], isError: true };
464
466
  } else {
465
- await cad.sendCommand(code + "\n");
466
- return { content: [{ type: "text", text: `\u5DF2\u53D1\u9001\u547D\u4EE4: ${code}` }] };
467
+ await cad.sendCommand(trimmed + "\n");
468
+ return { content: [{ type: "text", text: `\u5DF2\u53D1\u9001\u547D\u4EE4` }] };
467
469
  }
468
470
  } catch (e) {
469
471
  return { content: [{ type: "text", text: `\u9519\u8BEF: ${e.message}` }], isError: true };
@@ -479,8 +481,10 @@ async function getCadInfo() {
479
481
  }
480
482
  async function atCommand(command) {
481
483
  if (!cad.connected) return { content: [{ type: "text", text: "\u8BF7\u5148\u8FDE\u63A5 CAD" }], isError: true };
482
- await cad.sendCommand(command + "\n");
483
- return { content: [{ type: "text", text: `\u5DF2\u53D1\u9001\u547D\u4EE4: ${command}` }] };
484
+ const trimmed = (command || "").trim();
485
+ if (!trimmed) return { content: [{ type: "text", text: "\u547D\u4EE4\u4E3A\u7A7A\uFF0C\u672A\u53D1\u9001" }] };
486
+ await cad.sendCommand(trimmed + "\n");
487
+ return { content: [{ type: "text", text: "\u5DF2\u53D1\u9001\u547D\u4EE4" }] };
484
488
  }
485
489
  async function newDocument() {
486
490
  if (!cad.connected) {
@@ -1075,6 +1079,92 @@ var PROMPTS = [
1075
1079
  arguments: [
1076
1080
  { name: "format", description: "\u5BFC\u51FA\u683C\u5F0F (json/list)", required: false }
1077
1081
  ]
1082
+ },
1083
+ {
1084
+ name: "manage-layers",
1085
+ description: "\u56FE\u5C42\u7BA1\u7406\uFF1A\u521B\u5EFA\u3001\u51BB\u7ED3\u3001\u9501\u5B9A\u3001\u5220\u9664\u56FE\u5C42",
1086
+ arguments: [
1087
+ { name: "action", description: "\u64CD\u4F5C\u7C7B\u578B (list/freeze/lock/off/make/delete)", required: true },
1088
+ { name: "layers", description: "\u56FE\u5C42\u540D\uFF0C\u591A\u4E2A\u7528\u9017\u53F7\u5206\u9694", required: false },
1089
+ { name: "color", description: '\u56FE\u5C42\u989C\u8272 (ACI\u53F7\u6216RGB\u5982 "1,2,3")', required: false }
1090
+ ]
1091
+ },
1092
+ {
1093
+ name: "manage-blocks",
1094
+ description: "\u5757\u64CD\u4F5C\uFF1A\u63D2\u5165\u5757\u3001\u5217\u51FA\u5757\u3001\u83B7\u53D6/\u8BBE\u7F6E\u5C5E\u6027",
1095
+ arguments: [
1096
+ { name: "action", description: "\u64CD\u4F5C\u7C7B\u578B (list/insert/attributes/dynprops)", required: true },
1097
+ { name: "blockName", description: "\u5757\u540D", required: false },
1098
+ { name: "insertPoint", description: '\u63D2\u5165\u70B9 "x,y"', required: false },
1099
+ { name: "scale", description: "\u7F29\u653E\u6BD4\u4F8B", required: false }
1100
+ ]
1101
+ },
1102
+ {
1103
+ name: "curve-analysis",
1104
+ description: "\u66F2\u7EBF\u5206\u6790\uFF1A\u4EA4\u70B9\u3001\u6700\u8FD1\u70B9\u3001\u5B50\u6BB5\u3001\u7F13\u51B2\u533A",
1105
+ arguments: [
1106
+ { name: "action", description: "\u64CD\u4F5C (inters/subsegments/closestpoint/join)", required: true },
1107
+ { name: "distance", description: "\u8FDE\u63A5\u5BB9\u5DEE/\u504F\u79FB\u8DDD\u79BB", required: false }
1108
+ ]
1109
+ },
1110
+ {
1111
+ name: "geometry-calc",
1112
+ description: "\u51E0\u4F55\u8BA1\u7B97\uFF1A\u51F8\u5305\u3001\u70B9\u5230\u7EBF\u8DDD\u79BB\u3001\u9762\u5185\u6D4B\u8BD5\u3001\u53D8\u6362",
1113
+ arguments: [
1114
+ { name: "action", description: "\u64CD\u4F5C (convexhull/dist-point-line/in-curve-p/transform/centroid)", required: true },
1115
+ { name: "points", description: '\u70B9\u96C6 "x1,y1;x2,y2;..."', required: false }
1116
+ ]
1117
+ },
1118
+ {
1119
+ name: "text-process",
1120
+ description: "\u6587\u672C\u5904\u7406\uFF1AMTEXT\u89E3\u6790\u3001Markdown\u8F6CMTEXT\u3001\u53BB\u683C\u5F0F",
1121
+ arguments: [
1122
+ { name: "action", description: "\u64CD\u4F5C (parse-mtext/remove-fmt/from-markdown/mtext2text)", required: true },
1123
+ { name: "markdown", description: "Markdown\u6587\u672C\uFF08from-markdown\u64CD\u4F5C\u65F6\u7528\uFF09", required: false }
1124
+ ]
1125
+ },
1126
+ {
1127
+ name: "pickset-filter",
1128
+ description: "\u9009\u62E9\u96C6\u64CD\u4F5C\uFF1A\u8FC7\u6EE4\u3001\u8F6C\u6362\u3001\u6279\u91CF\u64CD\u4F5C",
1129
+ arguments: [
1130
+ { name: "action", description: "\u64CD\u4F5C (by-layer/by-type/by-box/erase/zoom)", required: true },
1131
+ { name: "dxfType", description: 'DXF\u7C7B\u578B "LINE, CIRCLE, LWPOLYLINE, INSERT, TEXT"', required: false },
1132
+ { name: "layerName", description: "\u56FE\u5C42\u540D", required: false }
1133
+ ]
1134
+ },
1135
+ {
1136
+ name: "color-convert",
1137
+ description: "\u989C\u8272\u8F6C\u6362\uFF1AACI/RGB/TrueColor/CSS\u4E92\u8F6C",
1138
+ arguments: [
1139
+ { name: "action", description: "\u64CD\u4F5C (aci2rgb/rgb2css/truecolor2rgb/rgb2truecolor)", required: true },
1140
+ { name: "value", description: "\u989C\u8272\u503C", required: true }
1141
+ ]
1142
+ },
1143
+ {
1144
+ name: "json-exchange",
1145
+ description: "JSON\u6570\u636E\u4EA4\u6362\uFF1A\u4ECE\u5B57\u7B26\u4E32\u89E3\u6790JSON alist\uFF0C\u4ECEalist\u751F\u6210JSON",
1146
+ arguments: [
1147
+ { name: "action", description: "\u64CD\u4F5C (encode/decode)", required: true },
1148
+ { name: "data", description: "JSON\u5B57\u7B26\u4E32\u6216Lisp alist\u6587\u672C", required: true }
1149
+ ]
1150
+ },
1151
+ {
1152
+ name: "excel-report",
1153
+ description: "Excel\u62A5\u8868\uFF1A\u5BFC\u51FACAD\u5B9E\u4F53\u6570\u636E\u5230Excel",
1154
+ arguments: [
1155
+ { name: "visible", description: "\u662F\u5426\u663E\u793AExcel\u7A97\u53E3 (true/false)", required: false },
1156
+ { name: "savePath", description: "\u4FDD\u5B58\u8DEF\u5F84\uFF0C\u4E0D\u586B\u5219\u4E0D\u4FDD\u5B58", required: false }
1157
+ ]
1158
+ },
1159
+ {
1160
+ name: "string-process",
1161
+ description: "\u5B57\u7B26\u4E32\u5904\u7406\uFF1A\u683C\u5F0F\u5316\u3001\u62C6\u5206\u3001\u66FF\u6362\u3001\u6B63\u5219",
1162
+ arguments: [
1163
+ { name: "action", description: "\u64CD\u4F5C (format/split/subst-all/regexp/trim/number2chinese)", required: true },
1164
+ { name: "input", description: "\u8F93\u5165\u5B57\u7B26\u4E32", required: true },
1165
+ { name: "arg1", description: "\u53C2\u65701\uFF08\u683C\u5F0F\u53C2\u6570/\u5206\u9694\u7B26/\u65E7\u4E32\uFF09", required: false },
1166
+ { name: "arg2", description: "\u53C2\u65702\uFF08\u65B0\u4E32/\u6B63\u5219\u6A21\u5F0F\uFF09", required: false }
1167
+ ]
1078
1168
  }
1079
1169
  ];
1080
1170
  async function listPrompts() {
@@ -1094,6 +1184,26 @@ async function getPrompt(name, arguments_ = {}) {
1094
1184
  return generateDimensionPrompt(arguments_);
1095
1185
  case "export-entities":
1096
1186
  return generateExportPrompt(arguments_);
1187
+ case "manage-layers":
1188
+ return generateManageLayersPrompt(arguments_);
1189
+ case "manage-blocks":
1190
+ return generateManageBlocksPrompt(arguments_);
1191
+ case "curve-analysis":
1192
+ return generateCurveAnalysisPrompt(arguments_);
1193
+ case "geometry-calc":
1194
+ return generateGeometryCalcPrompt(arguments_);
1195
+ case "text-process":
1196
+ return generateTextProcessPrompt(arguments_);
1197
+ case "pickset-filter":
1198
+ return generatePicksetFilterPrompt(arguments_);
1199
+ case "color-convert":
1200
+ return generateColorConvertPrompt(arguments_);
1201
+ case "json-exchange":
1202
+ return generateJsonExchangePrompt(arguments_);
1203
+ case "excel-report":
1204
+ return generateExcelReportPrompt(arguments_);
1205
+ case "string-process":
1206
+ return generateStringProcessPrompt(arguments_);
1097
1207
  default:
1098
1208
  throw new Error(`Unknown prompt: ${name}`);
1099
1209
  }
@@ -1311,6 +1421,418 @@ ${code}
1311
1421
  }]
1312
1422
  };
1313
1423
  }
1424
+ async function generateManageLayersPrompt(args) {
1425
+ const { action = "list", layers = "", color = "" } = args;
1426
+ const layerList = layers ? layers.split(/[,, ]+/) : [];
1427
+ const codeMap = {
1428
+ list: `(layer:list)`,
1429
+ make: `(layer:make "${layerList[0] || "NEW-LAYER"}" ${color || "7"} "Continuous" 0)`,
1430
+ freeze: `(mapcar (function (lambda (x) (layer:freeze x 1))) '${JSON.stringify(layerList.length ? layerList : ["0"])})`,
1431
+ lock: `(mapcar (function (lambda (x) (layer:lock x 1))) '${JSON.stringify(layerList.length ? layerList : ["0"])})`,
1432
+ off: `(mapcar (function (lambda (x) (layer:off x))) '${JSON.stringify(layerList.length ? layerList : ["0"])})`,
1433
+ delete: `(mapcar (function (lambda (x) (layer:delete x))) '${JSON.stringify(layerList.length ? layerList : ["0"]).replace(/"/g, '"')})`
1434
+ };
1435
+ const code = codeMap[action] || codeMap.list;
1436
+ const descMap = {
1437
+ list: "\u5217\u51FA\u6240\u6709\u56FE\u5C42",
1438
+ make: `\u521B\u5EFA\u56FE\u5C42 ${layerList[0] || "NEW-LAYER"}\uFF0C\u989C\u8272 ${color || "7"}`,
1439
+ freeze: `\u51BB\u7ED3\u56FE\u5C42: ${layerList.join(", ") || "\u672A\u6307\u5B9A"}`,
1440
+ lock: `\u9501\u5B9A\u56FE\u5C42: ${layerList.join(", ") || "\u672A\u6307\u5B9A"}`,
1441
+ off: `\u5173\u95ED\u56FE\u5C42: ${layerList.join(", ") || "\u672A\u6307\u5B9A"}`,
1442
+ delete: `\u5220\u9664\u56FE\u5C42: ${layerList.join(", ") || "\u672A\u6307\u5B9A"}`
1443
+ };
1444
+ return {
1445
+ messages: [{
1446
+ role: "user",
1447
+ content: {
1448
+ type: "text",
1449
+ text: `${descMap[action] || descMap.list}
1450
+
1451
+ \`\`\`lisp
1452
+ ${code}
1453
+ \`\`\`
1454
+
1455
+ \u4F7F\u7528 \`eval_lisp_with_result\` \u6267\u884C\u83B7\u53D6\u7ED3\u679C\u3002`
1456
+ }
1457
+ }]
1458
+ };
1459
+ }
1460
+ async function generateManageBlocksPrompt(args) {
1461
+ const { action = "list", blockName = "\u5757\u540D", insertPoint = "0,0", scale = "1" } = args;
1462
+ const pt = insertPoint.split(",").map(Number);
1463
+ const codeMap = {
1464
+ list: `(block:list)`,
1465
+ insert: `(block:insert "${blockName}" "${blockName}" (list ${pt[0] || 0} ${pt[1] || 0}) 0 ${scale})`,
1466
+ attributes: `(block:get-attributes (car (pickset:to-list (ssget "_X" (list (cons 2 "${blockName}"))))))`,
1467
+ dynprops: `(block:get-dynamic-properties (car (pickset:to-list (ssget "_X" (list (cons 2 "${blockName}"))))))`
1468
+ };
1469
+ const code = codeMap[action] || codeMap.list;
1470
+ const descMap = {
1471
+ list: "\u5217\u51FA\u5F53\u524D\u56FE\u7EB8\u4E2D\u6240\u6709\u5757\u5B9A\u4E49",
1472
+ insert: `\u63D2\u5165\u5757 "${blockName}" \u5230\u70B9 (${pt[0] || 0}, ${pt[1] || 0})\uFF0C\u6BD4\u4F8B ${scale}`,
1473
+ attributes: `\u83B7\u53D6\u5757 "${blockName}" \u7684\u5C5E\u6027\u6807\u7B7E-\u503C\u5217\u8868`,
1474
+ dynprops: `\u83B7\u53D6\u52A8\u6001\u5757 "${blockName}" \u7684\u53EF\u8C03\u5C5E\u6027`
1475
+ };
1476
+ return {
1477
+ messages: [{
1478
+ role: "user",
1479
+ content: {
1480
+ type: "text",
1481
+ text: `${descMap[action] || descMap.list}
1482
+
1483
+ \`\`\`lisp
1484
+ ${code}
1485
+ \`\`\`
1486
+
1487
+ \u4F7F\u7528 \`eval_lisp_with_result\` \u6267\u884C\u83B7\u53D6\u7ED3\u679C\u3002`
1488
+ }
1489
+ }]
1490
+ };
1491
+ }
1492
+ async function generateCurveAnalysisPrompt(args) {
1493
+ const { action = "inters", distance = "100" } = args;
1494
+ const codeMap = {
1495
+ inters: `(progn
1496
+ (setq ss (ssget "_X" (list (cons 0 "LWPOLYLINE,LINE,ARC,CIRCLE"))))
1497
+ (if (and ss (>= (sslength ss) 2))
1498
+ (progn
1499
+ (setq elst (pickset:to-list ss))
1500
+ (setq e1 (car elst) e2 (cadr elst))
1501
+ (curve:inters e1 e2 0)
1502
+ )
1503
+ )
1504
+ )`,
1505
+ subsegments: `(progn
1506
+ (setq e (car (pickset:to-list (ssget ":S" (list (cons 0 "LWPOLYLINE"))))))
1507
+ (if e (curve:subsegments e))
1508
+ )`,
1509
+ closestpoint: `(progn
1510
+ (setq e (car (pickset:to-list (ssget ":S" (list (cons 0 "LWPOLYLINE,LINE,ARC,CIRCLE"))))))
1511
+ (if e (curve:pickclosepointto e (getpoint "\\n\u9009\u62E9\u53C2\u8003\u70B9: ")))
1512
+ )`,
1513
+ join: `(progn
1514
+ (setq ss (ssget (list (cons 0 "LINE,LWPOLYLINE"))))
1515
+ (if ss (curve:join (pickset:to-list ss) ${distance}))
1516
+ )`
1517
+ };
1518
+ const code = codeMap[action] || codeMap.inters;
1519
+ const descMap = {
1520
+ inters: "\u9009\u62E9\u524D\u4E24\u4E2A\u66F2\u7EBF\u5BF9\u8C61\uFF0C\u8BA1\u7B97\u5176\u4EA4\u70B9\uFF08\u53EF\u6307\u5B9A LWPOLYLINE, LINE, ARC, CIRCLE\uFF09",
1521
+ subsegments: "\u9009\u62E9\u4E00\u4E2ALWPOLYLINE\uFF0C\u8FD4\u56DE\u5176\u5B50\u6BB5\u6570",
1522
+ closestpoint: "\u9009\u62E9\u4E00\u4E2A\u66F2\u7EBF\u5BF9\u8C61\uFF0C\u7136\u540E\u62FE\u53D6\u4E00\u4E2A\u70B9\uFF0C\u8FD4\u56DE\u66F2\u7EBF\u4E0A\u79BB\u8BE5\u70B9\u6700\u8FD1\u7684\u70B9",
1523
+ join: "\u9009\u62E9LINE/LWPOLYLINE\u7EBF\u6BB5\uFF0C\u7528 PEDIT Join \u5408\u5E76\uFF0C\u5BB9\u5DEE\u8DDD\u79BB=" + distance
1524
+ };
1525
+ return {
1526
+ messages: [{
1527
+ role: "user",
1528
+ content: {
1529
+ type: "text",
1530
+ text: `\u66F2\u7EBF\u64CD\u4F5C\uFF1A${descMap[action] || descMap.inters}
1531
+
1532
+ \`\`\`lisp
1533
+ ${code}
1534
+ \`\`\`
1535
+
1536
+ \u63D0\u793A\uFF1A\u786E\u4FDD CAD \u4E2D\u5DF2\u6709\u5BF9\u5E94\u56FE\u5F62\u5BF9\u8C61\u3002`
1537
+ }
1538
+ }]
1539
+ };
1540
+ }
1541
+ async function generateGeometryCalcPrompt(args) {
1542
+ const { action = "centroid", points = "0,0;100,0;100,100;0,100" } = args;
1543
+ const ptList = points.split(";").map((p) => {
1544
+ const [x, y] = p.split(",").map(Number);
1545
+ return `(list ${x} ${y})`;
1546
+ });
1547
+ const ptsStr = `(list ${ptList.join(" ")})`;
1548
+ const codeMap = {
1549
+ centroid: `(point:centroid ${ptsStr})`,
1550
+ "convexhull": `(geometry:convexhull-by-graham-scan ${ptsStr})`,
1551
+ "dist-point-line": `(progn
1552
+ (setq ss (ssget ":S" (list (cons 0 "LINE"))))
1553
+ (if ss
1554
+ (progn
1555
+ (setq e (car (pickset:to-list ss)))
1556
+ (setq p1 (cdr (assoc 10 (entget e))))
1557
+ (setq p2 (cdr (assoc 11 (entget e))))
1558
+ (geometry:dist-pt-line (getpoint "\\n\u9009\u62E9\u6D4B\u91CF\u70B9: ") (list p1 p2))
1559
+ )
1560
+ )
1561
+ )`,
1562
+ "in-curve-p": `(progn
1563
+ (setq e (car (pickset:to-list (ssget ":S" (list (cons 0 "LWPOLYLINE"))))))
1564
+ (if e (point:in-curve-p (getpoint "\\n\u9009\u62E9\u6D4B\u8BD5\u70B9: ") e))
1565
+ )`,
1566
+ transform: `(matrix:transformation (list 0 0 0) (list 2 2 1) 0 (list 0 0 0))`
1567
+ };
1568
+ const code = codeMap[action] || codeMap.centroid;
1569
+ const descMap = {
1570
+ centroid: `\u8BA1\u7B97 ${points} \u7684\u51E0\u4F55\u4E2D\u5FC3\uFF08\u8D28\u5FC3\uFF09`,
1571
+ convexhull: `\u8BA1\u7B97 ${points} \u7684\u51F8\u5305\uFF08Graham Scan \u7B97\u6CD5\uFF09`,
1572
+ "dist-point-line": "\u9009\u62E9\u4E00\u6761\u76F4\u7EBF\uFF0C\u7136\u540E\u62FE\u53D6\u4E00\u4E2A\u70B9\uFF0C\u8BA1\u7B97\u70B9\u5230\u76F4\u7EBF\u7684\u8DDD\u79BB",
1573
+ "in-curve-p": "\u9009\u62E9\u4E00\u4E2A\u95ED\u5408 LWPOLYLINE\uFF0C\u7136\u540E\u62FE\u53D6\u4E00\u4E2A\u70B9\uFF0C\u68C0\u6D4B\u70B9\u662F\u5426\u5728\u66F2\u7EBF\u5185\u90E8",
1574
+ transform: "\u5750\u6807\u53D8\u6362\u793A\u4F8B\uFF1A\u7F29\u653E2\u500D (matrix:transformation \u5E73\u79FB \u7F29\u653E \u65CB\u8F6C \u57FA\u70B9)"
1575
+ };
1576
+ return {
1577
+ messages: [{
1578
+ role: "user",
1579
+ content: {
1580
+ type: "text",
1581
+ text: `\u51E0\u4F55\u8BA1\u7B97\uFF1A${descMap[action] || descMap.centroid}
1582
+
1583
+ \`\`\`lisp
1584
+ ${code}
1585
+ \`\`\`
1586
+
1587
+ \u4F7F\u7528 \`eval_lisp_with_result\` \u6267\u884C\u83B7\u53D6\u7ED3\u679C\u3002`
1588
+ }
1589
+ }]
1590
+ };
1591
+ }
1592
+ async function generateTextProcessPrompt(args) {
1593
+ const { action = "remove-fmt", markdown = "\u8FD9\u662F **\u7C97\u4F53** \u548C *\u659C\u4F53* \u6587\u672C" } = args;
1594
+ const codeMap = {
1595
+ "remove-fmt": `(progn
1596
+ (setq e (car (pickset:to-list (ssget ":S" (list (cons 0 "MTEXT"))))))
1597
+ (if e (text:remove-fmt (cdr (assoc 1 (entget e)))))
1598
+ )`,
1599
+ "parse-mtext": `(progn
1600
+ (setq e (car (pickset:to-list (ssget ":S" (list (cons 0 "MTEXT"))))))
1601
+ (if e (text:parse-mtext (cdr (assoc 1 (entget e)))))
1602
+ )`,
1603
+ "from-markdown": `(text:from-markdown "${markdown}")`,
1604
+ "mtext2text": `(progn
1605
+ (setq e (car (pickset:to-list (ssget ":S" (list (cons 0 "MTEXT"))))))
1606
+ (if e (text:mtext2text e))
1607
+ )`
1608
+ };
1609
+ const code = codeMap[action] || codeMap["remove-fmt"];
1610
+ const descMap = {
1611
+ "remove-fmt": "\u9009\u62E9\u4E00\u4E2AMTEXT\u5BF9\u8C61\uFF0C\u53BB\u9664\u6240\u6709\u683C\u5F0F\u4EE3\u7801\uFF0C\u8FD4\u56DE\u7EAF\u6587\u672C",
1612
+ "parse-mtext": "\u9009\u62E9\u4E00\u4E2AMTEXT\u5BF9\u8C61\uFF0C\u89E3\u6790\u4E3A (\u683C\u5F0F\u6216\u6587\u672C . \u5185\u5BB9) \u5217\u8868",
1613
+ "from-markdown": `\u5C06Markdown\u8F6C\u6362\u4E3AMTEXT\u683C\u5F0F\u4EE3\u7801\uFF1A
1614
+ ${markdown}`,
1615
+ "mtext2text": "\u9009\u62E9\u4E00\u4E2AMTEXT\u5BF9\u8C61\uFF0C\u5206\u89E3\u4E3A\u591A\u4E2A\u5355\u884CTEXT"
1616
+ };
1617
+ return {
1618
+ messages: [{
1619
+ role: "user",
1620
+ content: {
1621
+ type: "text",
1622
+ text: `\u6587\u672C\u5904\u7406\uFF1A${descMap[action] || descMap["remove-fmt"]}
1623
+
1624
+ \`\`\`lisp
1625
+ ${code}
1626
+ \`\`\`
1627
+
1628
+ \u4F7F\u7528 \`eval_lisp_with_result\` \u6267\u884C\u83B7\u53D6\u7ED3\u679C\u3002`
1629
+ }
1630
+ }]
1631
+ };
1632
+ }
1633
+ async function generatePicksetFilterPrompt(args) {
1634
+ const { action = "by-type", dxfType = "LINE", layerName = "0" } = args;
1635
+ const codeMap = {
1636
+ "by-type": `(progn
1637
+ (setq ss (ssget "_X" (list (cons 0 "${dxfType}"))))
1638
+ (if ss (list (sslength ss) (mapcar (function (lambda (x) (cdr (assoc 0 (entget x))))) (pickset:to-list ss))))
1639
+ )`,
1640
+ "by-layer": `(progn
1641
+ (setq ss (ssget "_X" (list (cons 8 "${layerName}"))))
1642
+ (if ss (list (sslength ss) (mapcar (function (lambda (x) (cdr (assoc 0 (entget x))))) (pickset:to-list ss))))
1643
+ )`,
1644
+ "by-box": `(progn
1645
+ (setq ss (ssget "_X"))
1646
+ (if ss (pickset:getbox ss 0))
1647
+ )`,
1648
+ erase: `(progn
1649
+ (setq ss (ssget (list (cons 0 "${dxfType}"))))
1650
+ (if ss (progn (pickset:erase ss) (princ (strcat "\u5DF2\u5220\u9664 " (itoa (sslength ss)) " \u4E2A " "${dxfType}" " \u5B9E\u4F53"))))
1651
+ )`,
1652
+ zoom: `(progn
1653
+ (setq ss (ssget "_X" (list (cons 0 "${dxfType}"))))
1654
+ (if ss (pickset:zoom ss))
1655
+ )`
1656
+ };
1657
+ const code = codeMap[action] || codeMap["by-type"];
1658
+ const descMap = {
1659
+ "by-type": `\u7EDF\u8BA1\u6240\u6709\u7C7B\u578B\u4E3A ${dxfType} \u7684\u5B9E\u4F53\u6570\u91CF`,
1660
+ "by-layer": `\u7EDF\u8BA1\u56FE\u5C42 ${layerName} \u4E0A\u7684\u5B9E\u4F53\u6570\u91CF\u548C\u7C7B\u578B`,
1661
+ "by-box": "\u8BA1\u7B97\u5168\u56FE\u9009\u62E9\u96C6\u7684\u8FB9\u754C\u6846",
1662
+ erase: `\u5220\u9664\u6240\u6709 ${dxfType} \u7C7B\u578B\u7684\u5B9E\u4F53`,
1663
+ zoom: `\u7F29\u653E\u5230\u6240\u6709 ${dxfType} \u7C7B\u578B\u7684\u5B9E\u4F53`
1664
+ };
1665
+ return {
1666
+ messages: [{
1667
+ role: "user",
1668
+ content: {
1669
+ type: "text",
1670
+ text: `\u9009\u62E9\u96C6\u64CD\u4F5C\uFF1A${descMap[action] || descMap["by-type"]}
1671
+
1672
+ \`\`\`lisp
1673
+ ${code}
1674
+ \`\`\`
1675
+
1676
+ \u4F7F\u7528 \`eval_lisp_with_result\` \u6267\u884C\u83B7\u53D6\u7ED3\u679C\u3002`
1677
+ }
1678
+ }]
1679
+ };
1680
+ }
1681
+ async function generateColorConvertPrompt(args) {
1682
+ const { action = "aci2rgb", value = "1" } = args;
1683
+ const codeMap = {
1684
+ aci2rgb: `(color:aci2rgb ${parseInt(value) || 1})`,
1685
+ rgb2css: `(color:rgb2css (list ${value.split(",").map((v) => parseInt(v) || 0).join(" ")}))`,
1686
+ truecolor2rgb: `(color:truecolor2rgb ${parseInt(value) || 16711680})`,
1687
+ rgb2truecolor: `(color:rgb2truecolor (list ${value.split(",").map((v) => parseInt(v) || 0).join(" ")}))`,
1688
+ rgb: `(color:rgb ${value.split(",").map((v) => parseInt(v) || 0).join(" ")})`
1689
+ };
1690
+ const code = codeMap[action] || codeMap.aci2rgb;
1691
+ const descMap = {
1692
+ aci2rgb: `ACI\u989C\u8272\u7D22\u5F15 ${value} \u8F6CRGB`,
1693
+ rgb2css: `RGB (${value || "255,0,0"}) \u8F6CCSS\u989C\u8272 #FFFFFF`,
1694
+ truecolor2rgb: `TrueColor\u6574\u6570 ${value} \u8F6CRGB\u5217\u8868`,
1695
+ rgb2truecolor: `RGB (${value || "255,0,0"}) \u8F6CTrueColor\u6574\u6570`,
1696
+ rgb: `\u8BA1\u7B97RGB\u5408\u6210\u503C\uFF1AR ${value.split(",")[0] || 255} G ${value.split(",")[1] || 0} B ${value.split(",")[2] || 0}`
1697
+ };
1698
+ return {
1699
+ messages: [{
1700
+ role: "user",
1701
+ content: {
1702
+ type: "text",
1703
+ text: `${descMap[action] || descMap.aci2rgb}
1704
+
1705
+ \`\`\`lisp
1706
+ ${code}
1707
+ \`\`\`
1708
+
1709
+ \u4F7F\u7528 \`eval_lisp_with_result\` \u6267\u884C\u83B7\u53D6\u7ED3\u679C\u3002`
1710
+ }
1711
+ }]
1712
+ };
1713
+ }
1714
+ async function generateJsonExchangePrompt(args) {
1715
+ const { action = "encode", data = '(("name" . "\u5BA2\u5385") ("area" . 45.5) ("layer" . "A-WALL"))' } = args;
1716
+ const codeMap = {
1717
+ encode: `(json:encode-from-alist '${data})`,
1718
+ decode: `(json:parse "${data.replace(/"/g, '\\"')}")`,
1719
+ "decode-json": `(json:decode-json-from-string "${data.replace(/"/g, '\\"')}")`
1720
+ };
1721
+ const code = codeMap[action] || codeMap.encode;
1722
+ const descMap = {
1723
+ encode: `\u5C06alist\u6570\u636E\u7F16\u7801\u4E3AJSON\u5B57\u7B26\u4E32`,
1724
+ decode: `\u4F7F\u7528\u7EAFLisp\u89E3\u6790\u5668\u89E3\u6790JSON\u5B57\u7B26\u4E32`,
1725
+ "decode-json": `\u4F7F\u7528\u670D\u52A1\u5668API\u89E3\u7801JSON\u5B57\u7B26\u4E32\uFF08\u652F\u6301GBK\u7F16\u7801\uFF09`
1726
+ };
1727
+ return {
1728
+ messages: [{
1729
+ role: "user",
1730
+ content: {
1731
+ type: "text",
1732
+ text: `JSON\u6570\u636E\u4EA4\u6362\uFF1A${descMap[action] || descMap.encode}
1733
+
1734
+ \`\`\`lisp
1735
+ ${code}
1736
+ \`\`\`
1737
+
1738
+ \u6570\u636E:
1739
+ ${data}
1740
+
1741
+ \u4F7F\u7528 \`eval_lisp_with_result\` \u6267\u884C\u83B7\u53D6\u7ED3\u679C\u3002`
1742
+ }
1743
+ }]
1744
+ };
1745
+ }
1746
+ async function generateExcelReportPrompt(args) {
1747
+ const { visible = "false", savePath = "" } = args;
1748
+ const code = `(progn
1749
+ ;; 1. \u7EDF\u8BA1\u56FE\u7EB8\u5B9E\u4F53
1750
+ (setq ss (ssget "_X"))
1751
+ (setq elst (if ss (pickset:to-list ss) nil))
1752
+ (setq type-count (if elst (stat:stat (mapcar (function (lambda (x) (cdr (assoc 0 (entget x))))) elst)) nil))
1753
+
1754
+ ;; 2. \u521B\u5EFAExcel
1755
+ (setq xl (excel:new ${visible === "true" ? "nil" : "t"}))
1756
+
1757
+ ;; 3. \u5199\u8868\u5934
1758
+ (excel:set-rangevalue xl 1 "\u5B9E\u4F53\u7C7B\u578B")
1759
+ (excel:set-rangevalue xl "B1" "\u6570\u91CF")
1760
+
1761
+ ;; 4. \u5199\u5165\u6570\u636E
1762
+ (setq row 2)
1763
+ (foreach item type-count
1764
+ (excel:set-rangevalue xl (list row 1) (car item))
1765
+ (excel:set-rangevalue xl (list row 2) (cdr item))
1766
+ (setq row (1+ row))
1767
+ )
1768
+
1769
+ ;; 5. \u83B7\u53D6\u56FE\u5C42\u5217\u8868
1770
+ (setq layers (layer:list))
1771
+ (excel:set-rangevalue xl (list 1 4) "\u56FE\u5C42\u5217\u8868")
1772
+ (setq row 2)
1773
+ (foreach lay layers
1774
+ (excel:set-rangevalue xl (list row 4) lay)
1775
+ (setq row (1+ row))
1776
+ )
1777
+
1778
+ ${savePath ? `(excel:saveas xl "${savePath}")` : ""}
1779
+ (princ (strcat "Excel\u62A5\u8868\u5DF2\u751F\u6210\uFF0C\u5171 " (itoa (1- row)) " \u884C\u6570\u636E"))
1780
+ )`;
1781
+ return {
1782
+ messages: [{
1783
+ role: "user",
1784
+ content: {
1785
+ type: "text",
1786
+ text: `\u5BFC\u51FACAD\u5B9E\u4F53\u7EDF\u8BA1\u5230Excel\u62A5\u8868\uFF1A
1787
+
1788
+ \`\`\`lisp
1789
+ ${code}
1790
+ \`\`\`
1791
+ ${savePath ? `
1792
+ \u4FDD\u5B58\u8DEF\u5F84: ${savePath}` : "\n\u6CE8\u610F\uFF1A\u8BF7\u66FF\u6362Excel\u4E3A\u53EF\u89C1\u6A21\u5F0F\u540E\u624B\u52A8\u4FDD\u5B58"}
1793
+
1794
+ \u4F7F\u7528 \`eval_lisp\` \u6267\u884C\u3002`
1795
+ }
1796
+ }]
1797
+ };
1798
+ }
1799
+ async function generateStringProcessPrompt(args) {
1800
+ const { action = "format", input = "Hello, {0}!", arg1 = "World", arg2 = "" } = args;
1801
+ const codeMap = {
1802
+ format: `(string:format "${input}" (list "${arg1}"))`,
1803
+ split: `(string:split "${input}" "${arg1}")`,
1804
+ "subst-all": `(string:subst-all "${arg2}" "${arg1}" "${input}")`,
1805
+ regexp: `(re:match "${arg1}" "${input}")`,
1806
+ trim: `(string:trim-space "${input}")`,
1807
+ number2chinese: `(string:number2chinese ${parseInt(input) || 12345})`,
1808
+ "to-list": `(string:to-list "${input}" "${arg1}")`
1809
+ };
1810
+ const code = codeMap[action] || codeMap.format;
1811
+ const descMap = {
1812
+ format: `\u683C\u5F0F\u5316: ${input} \u53C2\u6570: ${arg1}`,
1813
+ split: `\u62C6\u5206: "${input}" \u6309 "${arg1}" \u5206\u9694`,
1814
+ "subst-all": `\u66FF\u6362: \u5C06 "${input}" \u4E2D\u7684 "${arg1}" \u66FF\u6362\u4E3A "${arg2}"`,
1815
+ regexp: `\u6B63\u5219\u5339\u914D: "${input}" \u6A21\u5F0F: ${arg1}`,
1816
+ trim: `\u53BB\u9664\u9996\u5C3E\u7A7A\u683C: "${input}"`,
1817
+ number2chinese: `\u6570\u5B57 ${parseInt(input) || 12345} \u8F6C\u4E2D\u6587\u5927\u5199`,
1818
+ "to-list": `\u6309\u5206\u9694\u7B26 "${arg1}" \u62C6\u5206 "${input}" \u4E3A\u5217\u8868`
1819
+ };
1820
+ return {
1821
+ messages: [{
1822
+ role: "user",
1823
+ content: {
1824
+ type: "text",
1825
+ text: `${descMap[action] || descMap.format}
1826
+
1827
+ \`\`\`lisp
1828
+ ${code}
1829
+ \`\`\`
1830
+
1831
+ \u4F7F\u7528 \`eval_lisp_with_result\` \u6267\u884C\u83B7\u53D6\u7ED3\u679C\u3002`
1832
+ }
1833
+ }]
1834
+ };
1835
+ }
1314
1836
 
1315
1837
  // src/session-manager.js
1316
1838
  var Session = class {
@@ -129,7 +129,7 @@ const cadSendWithResult = edge.func(function() {/*
129
129
  string platform = d.platform.ToString();
130
130
  string encoding = d.encoding != null ? d.encoding.ToString() : "";
131
131
  string progId = platform + ".Application";
132
- string tempDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "@lisp");
132
+ string tempDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "@lisp", "tmp");
133
133
  System.IO.Directory.CreateDirectory(tempDir);
134
134
 
135
135
  tempFile = System.IO.Path.Combine(tempDir, "atlisp_result_" + System.Guid.NewGuid().ToString("N") + ".txt");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlisp/mcp",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "MCP Server for @lisp on CAD",
5
5
  "type": "module",
6
6
  "bin": {