@aiready/ast-mcp-server 0.7.0 → 0.8.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.
package/dist/index.js CHANGED
@@ -445,9 +445,9 @@ var TypeScriptAdapter = class {
445
445
  await symbolIndex.buildIndex(searchPath);
446
446
  }
447
447
  }
448
- async resolveDefinition(symbolName, path6) {
449
- validateWorkspacePath(path6);
450
- await this.ensureIndex(path6);
448
+ async resolveDefinition(symbolName, path5) {
449
+ validateWorkspacePath(path5);
450
+ await this.ensureIndex(path5);
451
451
  const indexHits = symbolIndex.lookup(symbolName);
452
452
  if (indexHits.length > 0) {
453
453
  const results = [];
@@ -475,33 +475,33 @@ var TypeScriptAdapter = class {
475
475
  }
476
476
  return results;
477
477
  }
478
- if (fs3.statSync(path6).isDirectory()) {
478
+ if (fs3.statSync(path5).isDirectory()) {
479
479
  return [];
480
480
  }
481
- const tsconfig = await projectManager.findNearestTsConfig(path6);
481
+ const tsconfig = await projectManager.findNearestTsConfig(path5);
482
482
  if (!tsconfig) return [];
483
483
  try {
484
484
  const result = await this.pool.execute(
485
485
  "resolve_definition",
486
486
  {
487
487
  tsconfig,
488
- file: path6,
488
+ file: path5,
489
489
  symbol: symbolName
490
490
  }
491
491
  );
492
492
  return result;
493
493
  } catch {
494
494
  const project = projectManager.ensureProject(tsconfig);
495
- const sourceFile = project.addSourceFileAtPathIfExists(path6);
495
+ const sourceFile = project.addSourceFileAtPathIfExists(path5);
496
496
  if (!sourceFile) return [];
497
497
  const exported = sourceFile.getExportedDeclarations().get(symbolName);
498
498
  if (!exported) return [];
499
499
  return exported.map((decl) => this.mapToDefinitionLocation(decl));
500
500
  }
501
501
  }
502
- async findReferences(symbolName, path6, limit = 50, offset = 0) {
503
- validateWorkspacePath(path6);
504
- await this.ensureIndex(path6);
502
+ async findReferences(symbolName, path5, limit = 50, offset = 0) {
503
+ validateWorkspacePath(path5);
504
+ await this.ensureIndex(path5);
505
505
  const hits = symbolIndex.lookup(symbolName);
506
506
  if (hits.length === 0) return { references: [], total_count: 0 };
507
507
  const hit = hits[0];
@@ -514,7 +514,7 @@ var TypeScriptAdapter = class {
514
514
  const { searchCode: searchCode2 } = await import("./search-code-63QOEFQN.js");
515
515
  const searchResults = await searchCode2(
516
516
  symbolName,
517
- path6,
517
+ path5,
518
518
  "**/*.{ts,tsx,js,jsx}",
519
519
  1e3,
520
520
  false
@@ -551,9 +551,9 @@ var TypeScriptAdapter = class {
551
551
  total_count: unique.length
552
552
  };
553
553
  }
554
- async findImplementations(symbolName, path6, limit = 50, offset = 0) {
555
- validateWorkspacePath(path6);
556
- await this.ensureIndex(path6);
554
+ async findImplementations(symbolName, path5, limit = 50, offset = 0) {
555
+ validateWorkspacePath(path5);
556
+ await this.ensureIndex(path5);
557
557
  const hits = symbolIndex.lookup(symbolName);
558
558
  if (hits.length === 0) return { implementations: [], total_count: 0 };
559
559
  const hit = hits[0];
@@ -584,7 +584,7 @@ var TypeScriptAdapter = class {
584
584
  const { searchCode: searchCode2 } = await import("./search-code-63QOEFQN.js");
585
585
  const searchResults = await searchCode2(
586
586
  symbolName,
587
- path6,
587
+ path5,
588
588
  "**/*.{ts,tsx,js,jsx}",
589
589
  1e3,
590
590
  false
@@ -763,31 +763,31 @@ var TypeScriptAdapter = class {
763
763
  var typescriptAdapter = new TypeScriptAdapter();
764
764
 
765
765
  // src/utils/tool-utils.ts
766
- async function wrapAdapterCall(methodName, symbol, path6, ...args) {
766
+ async function wrapAdapterCall(methodName, symbol, path5, ...args) {
767
767
  const method = typescriptAdapter[methodName];
768
- return await method.apply(typescriptAdapter, [symbol, path6, ...args]);
768
+ return await method.apply(typescriptAdapter, [symbol, path5, ...args]);
769
769
  }
770
770
 
771
771
  // src/tools/resolve-definition.ts
772
- async function resolveDefinition(symbol, path6) {
772
+ async function resolveDefinition(symbol, path5) {
773
773
  return await wrapAdapterCall(
774
774
  "resolveDefinition",
775
775
  symbol,
776
- path6
776
+ path5
777
777
  );
778
778
  }
779
779
 
780
780
  // src/tools/find-references.ts
781
- async function findReferences(symbol, path6, limit = 50, offset = 0) {
782
- return await wrapAdapterCall("findReferences", symbol, path6, limit, offset);
781
+ async function findReferences(symbol, path5, limit = 50, offset = 0) {
782
+ return await wrapAdapterCall("findReferences", symbol, path5, limit, offset);
783
783
  }
784
784
 
785
785
  // src/tools/find-implementations.ts
786
- async function findImplementations(symbol, path6, limit = 50, offset = 0) {
786
+ async function findImplementations(symbol, path5, limit = 50, offset = 0) {
787
787
  return await wrapAdapterCall(
788
788
  "findImplementations",
789
789
  symbol,
790
- path6,
790
+ path5,
791
791
  limit,
792
792
  offset
793
793
  );
@@ -827,8 +827,8 @@ async function getSymbolDocs(symbol, filePath) {
827
827
  }
828
828
 
829
829
  // src/tools/build-symbol-index.ts
830
- async function buildSymbolIndex(path6) {
831
- return await symbolIndex.buildIndex(path6);
830
+ async function buildSymbolIndex(path5) {
831
+ return await symbolIndex.buildIndex(path5);
832
832
  }
833
833
 
834
834
  // src/tools/call-hierarchy.ts
@@ -984,115 +984,6 @@ async function checkSymbolGrounding(symbol, filePath) {
984
984
  };
985
985
  }
986
986
 
987
- // src/tools/codebase-audit.ts
988
- import { execFile } from "child_process";
989
- import { promisify } from "util";
990
- import { rgPath } from "@vscode/ripgrep";
991
- import * as fs4 from "fs";
992
- import * as path5 from "path";
993
- var execFileAsync = promisify(execFile);
994
- async function codebaseAudit(rootDir) {
995
- const safePath = validateWorkspacePath(rootDir);
996
- let debtMarkers = 0;
997
- try {
998
- const { stdout } = await execFileAsync(rgPath, [
999
- "--count-matches",
1000
- "--fixed-strings",
1001
- "-e",
1002
- "TODO",
1003
- "-e",
1004
- "FIXME",
1005
- "--glob",
1006
- "!**/node_modules/**",
1007
- "--glob",
1008
- "!**/.git/**",
1009
- "--glob",
1010
- "!**/dist/**",
1011
- safePath
1012
- ]);
1013
- const lines = stdout.split("\n").filter(Boolean);
1014
- for (const line of lines) {
1015
- const match = line.match(/:(\d+)$/);
1016
- if (match) {
1017
- debtMarkers += parseInt(match[1], 10);
1018
- }
1019
- }
1020
- } catch (error) {
1021
- if (error.code !== 1) {
1022
- console.error("[Audit] Error counting debt markers:", error);
1023
- }
1024
- }
1025
- const emptyDirs = [];
1026
- const scanEmpty = (dir) => {
1027
- const files = fs4.readdirSync(dir);
1028
- if (files.length === 0) {
1029
- emptyDirs.push(path5.relative(safePath, dir));
1030
- return;
1031
- }
1032
- for (const file of files) {
1033
- const fullPath = path5.join(dir, file);
1034
- if (fs4.statSync(fullPath).isDirectory()) {
1035
- if (["node_modules", ".git", "dist", ".sst", ".turbo", ".next"].includes(
1036
- file
1037
- ))
1038
- continue;
1039
- scanEmpty(fullPath);
1040
- }
1041
- }
1042
- };
1043
- scanEmpty(safePath);
1044
- const orphanedFiles = [];
1045
- const allFiles = [];
1046
- const collectFiles = (dir) => {
1047
- const files = fs4.readdirSync(dir);
1048
- for (const file of files) {
1049
- const fullPath = path5.join(dir, file);
1050
- if (fs4.statSync(fullPath).isDirectory()) {
1051
- if (["node_modules", ".git", "dist", ".sst", ".turbo", ".next"].includes(
1052
- file
1053
- ))
1054
- continue;
1055
- collectFiles(fullPath);
1056
- } else if (file.endsWith(".ts") || file.endsWith(".js") || file.endsWith(".tsx") || file.endsWith(".jsx")) {
1057
- allFiles.push(fullPath);
1058
- }
1059
- }
1060
- };
1061
- collectFiles(safePath);
1062
- for (const file of allFiles) {
1063
- const base = path5.basename(file, path5.extname(file));
1064
- if (base === "index" || base.endsWith(".test") || base.endsWith(".spec") || base === "sst.config")
1065
- continue;
1066
- let referenced = false;
1067
- try {
1068
- const { status } = await execFileAsync(rgPath, [
1069
- "--quiet",
1070
- "--fixed-strings",
1071
- "--word-regexp",
1072
- "--glob",
1073
- `!${path5.relative(safePath, file)}`,
1074
- "--glob",
1075
- "!**/node_modules/**",
1076
- "--glob",
1077
- "!**/.git/**",
1078
- base,
1079
- safePath
1080
- ]);
1081
- if (status === 0) referenced = true;
1082
- } catch (e) {
1083
- if (e.code === 0) referenced = true;
1084
- }
1085
- if (!referenced) {
1086
- orphanedFiles.push(path5.relative(safePath, file));
1087
- }
1088
- }
1089
- return {
1090
- debtMarkers,
1091
- emptyDirs,
1092
- orphanedFiles
1093
- };
1094
- }
1095
-
1096
987
  // src/index.ts
1097
988
  import {
1098
989
  ListResourcesRequestSchema,
@@ -1283,8 +1174,8 @@ var ASTExplorerServer = class {
1283
1174
  }
1284
1175
  },
1285
1176
  {
1286
- name: "codebase_audit",
1287
- description: "Performs a codebase-level audit for technical debt (TODOs) and bloat (empty dirs, orphans).",
1177
+ name: "hygiene_audit",
1178
+ description: "Performs a codebase-level hygiene check for technical debt (TODOs) and waste (empty dirs, orphans).",
1288
1179
  inputSchema: {
1289
1180
  type: "object",
1290
1181
  properties: {
@@ -1295,6 +1186,28 @@ var ASTExplorerServer = class {
1295
1186
  },
1296
1187
  required: ["path"]
1297
1188
  }
1189
+ },
1190
+ {
1191
+ name: "metabolism_audit",
1192
+ description: "Alias for hygiene_audit (Serverless Claw compat).",
1193
+ inputSchema: {
1194
+ type: "object",
1195
+ properties: {
1196
+ path: { type: "string" }
1197
+ },
1198
+ required: ["path"]
1199
+ }
1200
+ },
1201
+ {
1202
+ name: "codebase_audit",
1203
+ description: "Alias for hygiene_audit.",
1204
+ inputSchema: {
1205
+ type: "object",
1206
+ properties: {
1207
+ path: { type: "string" }
1208
+ },
1209
+ required: ["path"]
1210
+ }
1298
1211
  }
1299
1212
  ]
1300
1213
  };
@@ -1304,8 +1217,8 @@ var ASTExplorerServer = class {
1304
1217
  try {
1305
1218
  switch (name) {
1306
1219
  case "resolve_definition": {
1307
- const { symbol, path: path6 } = ResolveDefinitionSchema.parse(args);
1308
- const results = await resolveDefinition(symbol, path6);
1220
+ const { symbol, path: path5 } = ResolveDefinitionSchema.parse(args);
1221
+ const results = await resolveDefinition(symbol, path5);
1309
1222
  return {
1310
1223
  content: [
1311
1224
  { type: "text", text: JSON.stringify(results, null, 2) }
@@ -1313,8 +1226,8 @@ var ASTExplorerServer = class {
1313
1226
  };
1314
1227
  }
1315
1228
  case "find_references": {
1316
- const { symbol, path: path6, limit, offset } = FindReferencesSchema.parse(args);
1317
- const results = await findReferences(symbol, path6, limit, offset);
1229
+ const { symbol, path: path5, limit, offset } = FindReferencesSchema.parse(args);
1230
+ const results = await findReferences(symbol, path5, limit, offset);
1318
1231
  return {
1319
1232
  content: [
1320
1233
  { type: "text", text: JSON.stringify(results, null, 2) }
@@ -1322,10 +1235,10 @@ var ASTExplorerServer = class {
1322
1235
  };
1323
1236
  }
1324
1237
  case "find_implementations": {
1325
- const { symbol, path: path6, limit, offset } = FindImplementationsSchema.parse(args);
1238
+ const { symbol, path: path5, limit, offset } = FindImplementationsSchema.parse(args);
1326
1239
  const results = await findImplementations(
1327
1240
  symbol,
1328
- path6,
1241
+ path5,
1329
1242
  limit,
1330
1243
  offset
1331
1244
  );
@@ -1345,10 +1258,10 @@ var ASTExplorerServer = class {
1345
1258
  };
1346
1259
  }
1347
1260
  case "search_code": {
1348
- const { pattern, path: path6, filePattern, limit, offset, regex } = SearchCodeSchema.parse(args);
1261
+ const { pattern, path: path5, filePattern, limit, offset, regex } = SearchCodeSchema.parse(args);
1349
1262
  const results = await searchCode(
1350
1263
  pattern,
1351
- path6,
1264
+ path5,
1352
1265
  filePattern,
1353
1266
  limit,
1354
1267
  regex,
@@ -1361,22 +1274,22 @@ var ASTExplorerServer = class {
1361
1274
  };
1362
1275
  }
1363
1276
  case "get_symbol_docs": {
1364
- const { symbol, path: path6 } = GetSymbolDocsSchema.parse(args);
1365
- const docs = await getSymbolDocs(symbol, path6);
1277
+ const { symbol, path: path5 } = GetSymbolDocsSchema.parse(args);
1278
+ const docs = await getSymbolDocs(symbol, path5);
1366
1279
  return {
1367
1280
  content: [{ type: "text", text: JSON.stringify(docs, null, 2) }]
1368
1281
  };
1369
1282
  }
1370
1283
  case "build_symbol_index": {
1371
- const { path: path6 } = BuildSymbolIndexSchema.parse(args);
1372
- const stats = await buildSymbolIndex(path6);
1284
+ const { path: path5 } = BuildSymbolIndexSchema.parse(args);
1285
+ const stats = await buildSymbolIndex(path5);
1373
1286
  return {
1374
1287
  content: [{ type: "text", text: JSON.stringify(stats, null, 2) }]
1375
1288
  };
1376
1289
  }
1377
1290
  case "get_call_hierarchy": {
1378
- const { symbol, path: path6, direction } = GetCallHierarchySchema.parse(args);
1379
- const hierarchy = await getCallHierarchy(symbol, path6, direction);
1291
+ const { symbol, path: path5, direction } = GetCallHierarchySchema.parse(args);
1292
+ const hierarchy = await getCallHierarchy(symbol, path5, direction);
1380
1293
  return {
1381
1294
  content: [
1382
1295
  { type: "text", text: JSON.stringify(hierarchy, null, 2) }
@@ -1384,21 +1297,38 @@ var ASTExplorerServer = class {
1384
1297
  };
1385
1298
  }
1386
1299
  case "check_symbol_grounding": {
1387
- const { symbol, path: path6 } = CheckSymbolGroundingSchema.parse(args);
1388
- const result = await checkSymbolGrounding(symbol, path6);
1300
+ const { symbol, path: path5 } = CheckSymbolGroundingSchema.parse(args);
1301
+ const result = await checkSymbolGrounding(symbol, path5);
1389
1302
  return {
1390
1303
  content: [
1391
1304
  { type: "text", text: JSON.stringify(result, null, 2) }
1392
1305
  ]
1393
1306
  };
1394
1307
  }
1308
+ case "hygiene_audit":
1309
+ case "metabolism_audit":
1395
1310
  case "codebase_audit": {
1396
- const { path: path6 } = CodebaseAuditSchema.parse(args);
1397
- const result = await codebaseAudit(path6);
1311
+ const { path: rootDir } = CodebaseAuditSchema.parse(args);
1312
+ const { HygieneAuditProvider } = await import("@aiready/hygiene-audit");
1313
+ const provider = new HygieneAuditProvider();
1314
+ const result = await provider.analyze({ rootDir });
1315
+ const allIssues = result.results.flatMap((r) => r.issues);
1316
+ const metadata = {
1317
+ debtMarkers: result.metadata?.debtMarkers || 0,
1318
+ emptyDirs: result.metadata?.emptyDirs || [],
1319
+ orphanedFiles: result.metadata?.orphanedFiles || [],
1320
+ findings: allIssues.map((i) => ({
1321
+ expected: i.recommendation || i.suggestion || "",
1322
+ actual: i.message,
1323
+ severity: i.severity === "critical" ? "P0" : i.severity === "major" ? "P1" : "P2",
1324
+ recommendation: i.recommendation || i.suggestion || ""
1325
+ }))
1326
+ };
1398
1327
  return {
1399
1328
  content: [
1400
1329
  { type: "text", text: JSON.stringify(result, null, 2) }
1401
- ]
1330
+ ],
1331
+ metadata
1402
1332
  };
1403
1333
  }
1404
1334
  default: