@atlisp/mcp 1.6.10 → 1.6.12

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/dist/atlisp-mcp.js +47 -68
  2. package/package.json +1 -1
@@ -1041,9 +1041,7 @@ async function getCadInfo() {
1041
1041
  await cad.connect();
1042
1042
  }
1043
1043
  if (!cad.connected) {
1044
- const result2 = { connected: false, platform: null, version: null, busy: false };
1045
- setCache("cad:info", result2);
1046
- return result2;
1044
+ return { connected: false, platform: null, version: null, busy: false };
1047
1045
  }
1048
1046
  let busy = false;
1049
1047
  try {
@@ -1068,9 +1066,7 @@ async function getEntities(params = {}) {
1068
1066
  if (!cad.connected)
1069
1067
  await cad.connect();
1070
1068
  if (!cad.connected) {
1071
- const result = { total: 0, entities: [] };
1072
- setCache(cacheKey, result);
1073
- return result;
1069
+ return { total: 0, entities: [] };
1074
1070
  }
1075
1071
  const hasFilter = params.type || params.layer || params.bbox;
1076
1072
  if (!hasFilter) {
@@ -1084,9 +1080,7 @@ async function getEntities(params = {}) {
1084
1080
  });
1085
1081
  const resultStr = await cad.sendCommandWithResult(code);
1086
1082
  if (!resultStr || resultStr === "" || resultStr === "nil") {
1087
- const result2 = { total: 0, entities: [] };
1088
- setCache(cacheKey, result2);
1089
- return result2;
1083
+ return { total: 0, entities: [] };
1090
1084
  }
1091
1085
  let total = 0;
1092
1086
  let entities = [];
@@ -1102,9 +1096,7 @@ async function getEntities(params = {}) {
1102
1096
  return result;
1103
1097
  } catch (e) {
1104
1098
  log(`getEntities error: ${e.message}`);
1105
- const result = { total: 0, entities: [] };
1106
- setCache(cacheKey, result);
1107
- return result;
1099
+ return { total: 0, entities: [] };
1108
1100
  }
1109
1101
  }
1110
1102
  async function getEntitiesSummary(cacheKey) {
@@ -1130,15 +1122,11 @@ async function getEntitiesSummary(cacheKey) {
1130
1122
  try {
1131
1123
  const resultStr = await cad.sendCommandWithResult(summaryCode);
1132
1124
  if (!resultStr || resultStr === "" || resultStr === "nil") {
1133
- const result2 = { total: 0, summary: [] };
1134
- setCache(cacheKey, result2);
1135
- return result2;
1125
+ return { total: 0, summary: [] };
1136
1126
  }
1137
1127
  const parsed = parseLispRecursive(resultStr);
1138
1128
  if (!parsed || !Array.isArray(parsed)) {
1139
- const result2 = { total: 0, summary: [] };
1140
- setCache(cacheKey, result2);
1141
- return result2;
1129
+ return { total: 0, summary: [] };
1142
1130
  }
1143
1131
  let total = 0;
1144
1132
  const summary = [];
@@ -1160,9 +1148,7 @@ async function getEntitiesSummary(cacheKey) {
1160
1148
  return result;
1161
1149
  } catch (e) {
1162
1150
  log(`getEntitiesSummary error: ${e.message}`);
1163
- const result = { total: 0, summary: [] };
1164
- setCache(cacheKey, result);
1165
- return result;
1151
+ return { total: 0, summary: [] };
1166
1152
  }
1167
1153
  }
1168
1154
  function buildTextContentCode({ layer, bbox, offset, limit }) {
@@ -1202,9 +1188,7 @@ async function getTextContent(params = {}) {
1202
1188
  if (!cad.connected)
1203
1189
  await cad.connect();
1204
1190
  if (!cad.connected) {
1205
- const result = { total: 0, offset: 0, limit: 5e3, texts: [] };
1206
- setCache(cacheKey, result);
1207
- return result;
1191
+ return { total: 0, offset: 0, limit: 5e3, texts: [] };
1208
1192
  }
1209
1193
  const offset = Math.max(0, parseInt(params.offset) || 0);
1210
1194
  const limit = Math.min(Math.max(1, parseInt(params.limit) || 5e3), 5e3);
@@ -1212,15 +1196,11 @@ async function getTextContent(params = {}) {
1212
1196
  const code = buildTextContentCode({ layer: params.layer, bbox: params.bbox, offset, limit });
1213
1197
  const resultStr = await cad.sendCommandWithResult(code);
1214
1198
  if (!resultStr || resultStr === "" || resultStr === "nil" || resultStr === "0") {
1215
- const result = { total: 0, offset, limit, texts: [] };
1216
- setCache(cacheKey, result);
1217
- return result;
1199
+ return { total: 0, offset, limit, texts: [] };
1218
1200
  }
1219
1201
  const parsed = parseLispRecursive(resultStr);
1220
1202
  if (!parsed || !Array.isArray(parsed)) {
1221
- const result = { total: 0, offset, limit, texts: [] };
1222
- setCache(cacheKey, result);
1223
- return result;
1203
+ return { total: 0, offset, limit, texts: [] };
1224
1204
  }
1225
1205
  const data = lispPairsToObject(parsed);
1226
1206
  const rawTexts = Array.isArray(data.texts) ? data.texts : [];
@@ -1243,9 +1223,7 @@ async function getTextContent(params = {}) {
1243
1223
  return data;
1244
1224
  } catch (e) {
1245
1225
  log(`getTextContent error: ${e.message}`);
1246
- const result = { total: 0, offset, limit, texts: [] };
1247
- setCache(cacheKey, result);
1248
- return result;
1226
+ return { total: 0, offset, limit, texts: [] };
1249
1227
  }
1250
1228
  }
1251
1229
  async function getDwgName() {
@@ -1376,23 +1354,17 @@ async function getBlockRefs(params = {}) {
1376
1354
  if (!cad.connected)
1377
1355
  await cad.connect();
1378
1356
  if (!cad.connected) {
1379
- const result = { total: 0, blockRefs: [] };
1380
- setCache(cacheKey, result);
1381
- return result;
1357
+ return { total: 0, blockRefs: [] };
1382
1358
  }
1383
1359
  try {
1384
1360
  const code = buildBlockRefsCode(params.blockName);
1385
1361
  const resultStr = await cad.sendCommandWithResult(code);
1386
1362
  if (!resultStr || resultStr === "" || resultStr === "nil") {
1387
- const result2 = { total: 0, blockRefs: [] };
1388
- setCache(cacheKey, result2);
1389
- return result2;
1363
+ return { total: 0, blockRefs: [] };
1390
1364
  }
1391
1365
  const parsed = parseLispRecursive(resultStr);
1392
1366
  if (!parsed || !Array.isArray(parsed)) {
1393
- const result2 = { total: 0, blockRefs: [] };
1394
- setCache(cacheKey, result2);
1395
- return result2;
1367
+ return { total: 0, blockRefs: [] };
1396
1368
  }
1397
1369
  const result = lispPairsToObject(parsed);
1398
1370
  const blockRefs = Array.isArray(result.blockRefs) ? result.blockRefs : [];
@@ -1423,22 +1395,22 @@ async function getBlockRefs(params = {}) {
1423
1395
  return finalResult;
1424
1396
  } catch (e) {
1425
1397
  log(`getBlockRefs error: ${e.message}`);
1426
- const result = { total: 0, blockRefs: [] };
1427
- setCache(cacheKey, result);
1428
- return result;
1398
+ return { total: 0, blockRefs: [] };
1429
1399
  }
1430
1400
  }
1431
1401
  var TBL_QUERIES = {
1432
1402
  layer: { name: "layer", lisp: `(progn
1433
1403
  (setq @d nil)
1434
- (vlax-for e (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
1404
+ (setq @e (tblnext "layer" t))
1405
+ (while @e
1435
1406
  (setq @d (cons (list
1436
- (cons 2 (vla-get-name e))
1437
- (cons 62 (vla-get-color e))
1438
- (cons 6 (vla-get-linetype e))
1439
- (cons 70 (logior (if (vla-get-freeze e) 1 0) (if (vla-get-lock e) 4 0)))
1440
- (cons 60 (if (vla-get-layeron e) 0 1))
1441
- ) @d)))
1407
+ (cons 2 (cdr (assoc 2 @e)))
1408
+ (cons 62 (cdr (assoc 62 @e)))
1409
+ (cons 6 (cdr (assoc 6 @e)))
1410
+ (cons 70 (cdr (assoc 70 @e)))
1411
+ (cons 60 (if (< (cdr (assoc 62 @e)) 0) 1 0))
1412
+ ) @d))
1413
+ (setq @e (tblnext "layer" nil)))
1442
1414
  (list (cons 'table 'layer) (cons 'total (length @d)) (cons 'data (list (reverse @d)))))` },
1443
1415
  block: { name: "block", lisp: `(progn
1444
1416
  (setq @d nil)
@@ -1449,7 +1421,15 @@ var TBL_QUERIES = {
1449
1421
  style: { name: "style", lisp: `(progn
1450
1422
  (setq @d nil)
1451
1423
  (vlax-for e (vla-get-textstyles (vla-get-activedocument (vlax-get-acad-object)))
1452
- (setq @d (cons (list (cons 2 (vla-get-name e)) (cons 70 0)) @d)))
1424
+ (setq @d (cons (list
1425
+ (cons 2 (vla-get-name e))
1426
+ (cons 1 (vla-get-fontfile e))
1427
+ (cons 3 (vla-get-bigfontfile e))
1428
+ (cons 40 (vla-get-height e))
1429
+ (cons 41 (vla-get-width e))
1430
+ (cons 42 (/ (* 180.0 (vla-get-obliqueangle e)) pi))
1431
+ (cons 70 (vla-get-textgenerationflag e))
1432
+ ) @d)))
1453
1433
  (list (cons 'table 'style) (cons 'total (length @d)) (cons 'data (list (reverse @d)))))` },
1454
1434
  dimstyle: { name: "dimstyle", lisp: `(progn
1455
1435
  (setq @d nil)
@@ -1462,8 +1442,15 @@ var TBL_QUERIES = {
1462
1442
  (setq @d (cons (list (cons 2 (vla-get-name e)) (cons 70 0)) @d)))
1463
1443
  (list (cons 'table 'linetype) (cons 'total (length @d)) (cons 'data (list (reverse @d)))))` }
1464
1444
  };
1445
+ var TBL_KEY_ALIAS = {
1446
+ textstyle: "style",
1447
+ textstyles: "style",
1448
+ ltype: "linetype",
1449
+ linetype: "ltype"
1450
+ };
1465
1451
  function buildTablesCode(tblName) {
1466
- const key = tblName.toLowerCase();
1452
+ const raw = tblName.toLowerCase();
1453
+ const key = TBL_KEY_ALIAS[raw] || raw;
1467
1454
  const query = TBL_QUERIES[key];
1468
1455
  if (query) {
1469
1456
  return `(progn (vl-load-com) ${query.lisp})`;
@@ -1500,7 +1487,9 @@ function parseTableRecord(rec) {
1500
1487
  else if (key === "42")
1501
1488
  obj.oblique = typeof val === "number" ? val : 0;
1502
1489
  else if (key === "3")
1503
- obj.description = String(val);
1490
+ obj.bigfont = String(val);
1491
+ else if (key === "50")
1492
+ obj.flags = typeof val === "number" ? val : 0;
1504
1493
  }
1505
1494
  }
1506
1495
  return obj.name ? obj : null;
@@ -1519,15 +1508,11 @@ async function getTables(params = {}) {
1519
1508
  const code = buildTablesCode(tblName);
1520
1509
  const resultStr = await cad.sendCommandWithResult(code);
1521
1510
  if (!resultStr || resultStr === "" || resultStr === "nil") {
1522
- const result2 = { table: tblName, data: [] };
1523
- setCache(cacheKey, result2);
1524
- return result2;
1511
+ return { table: tblName, data: [] };
1525
1512
  }
1526
1513
  const parsed = parseLispRecursive(resultStr);
1527
1514
  if (!parsed || !Array.isArray(parsed)) {
1528
- const result2 = { table: tblName, total: 0, data: [] };
1529
- setCache(cacheKey, result2);
1530
- return result2;
1515
+ return { table: tblName, total: 0, data: [] };
1531
1516
  }
1532
1517
  let result;
1533
1518
  if (parsed.length >= 3 && parsed[0] && String(parsed[0][0]).toUpperCase() === "TABLE") {
@@ -1599,9 +1584,7 @@ async function getTables(params = {}) {
1599
1584
  return result;
1600
1585
  } catch (e) {
1601
1586
  log(`getTables error: ${e.message}`);
1602
- const result = { table: tblName, data: [] };
1603
- setCache(cacheKey, result);
1604
- return result;
1587
+ return { table: tblName, data: [] };
1605
1588
  }
1606
1589
  }
1607
1590
  async function getPackages(filterName = null) {
@@ -1617,7 +1600,6 @@ async function getPackages(filterName = null) {
1617
1600
  const code = `(mapcar 'cdr @::*local-pkgs*)`;
1618
1601
  const result = await cad.sendCommandWithResult(code);
1619
1602
  if (!result || result === "" || result === "nil") {
1620
- setCache(cacheKey, []);
1621
1603
  return [];
1622
1604
  }
1623
1605
  let raw = [];
@@ -1688,7 +1670,6 @@ async function getPackages(filterName = null) {
1688
1670
  setCache(cacheKey, packages);
1689
1671
  return packages;
1690
1672
  } catch (e) {
1691
- setCache(cacheKey, []);
1692
1673
  return [];
1693
1674
  }
1694
1675
  }
@@ -1718,7 +1699,6 @@ async function getDwgList() {
1718
1699
  )`;
1719
1700
  const result = await cad.sendCommandWithResult(code);
1720
1701
  if (!result || result === "" || result === "nil") {
1721
- setCache(cacheKey, []);
1722
1702
  return [];
1723
1703
  }
1724
1704
  let parsed = [];
@@ -1741,7 +1721,6 @@ async function getDwgList() {
1741
1721
  setCache(cacheKey, dwgList);
1742
1722
  return dwgList;
1743
1723
  } catch (e) {
1744
- setCache(cacheKey, []);
1745
1724
  return [];
1746
1725
  }
1747
1726
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlisp/mcp",
3
- "version": "1.6.10",
3
+ "version": "1.6.12",
4
4
  "description": "MCP Server for @lisp on CAD,support AutoCAD/GstarCAD/ZWCAD/BricsCAD or CAD platform compatible with AutoLISP",
5
5
  "type": "module",
6
6
  "bin": {