@liendev/lien 0.29.0 → 0.29.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
@@ -8803,6 +8803,25 @@ function deduplicateResults(results) {
8803
8803
  return true;
8804
8804
  });
8805
8805
  }
8806
+ function cleanMetadataValue(key, value) {
8807
+ if (value === void 0 || value === "") return null;
8808
+ if (Array.isArray(value)) {
8809
+ const filtered = value.filter((v) => v !== "");
8810
+ return filtered.length > 0 ? filtered : null;
8811
+ }
8812
+ if (key === "symbols" && typeof value === "object" && value !== null) {
8813
+ const symbols = value;
8814
+ const filterArr = (arr) => Array.isArray(arr) ? arr.filter((s) => s !== "") : [];
8815
+ const filtered = {
8816
+ functions: filterArr(symbols.functions),
8817
+ classes: filterArr(symbols.classes),
8818
+ interfaces: filterArr(symbols.interfaces)
8819
+ };
8820
+ const hasAny = filtered.functions.length > 0 || filtered.classes.length > 0 || filtered.interfaces.length > 0;
8821
+ return hasAny ? filtered : null;
8822
+ }
8823
+ return value;
8824
+ }
8806
8825
  function pickMetadata(metadata, allowlist) {
8807
8826
  const result = {
8808
8827
  file: metadata.file,
@@ -8812,8 +8831,9 @@ function pickMetadata(metadata, allowlist) {
8812
8831
  const out = result;
8813
8832
  for (const key of allowlist) {
8814
8833
  if (key === "file" || key === "startLine" || key === "endLine") continue;
8815
- if (metadata[key] !== void 0) {
8816
- out[key] = metadata[key];
8834
+ const cleaned = cleanMetadataValue(key, metadata[key]);
8835
+ if (cleaned !== null) {
8836
+ out[key] = cleaned;
8817
8837
  }
8818
8838
  }
8819
8839
  return result;
@@ -8881,17 +8901,12 @@ async function handleSemanticSearch(args, ctx) {
8881
8901
  }
8882
8902
  log(`Returning ${results.length} results`);
8883
8903
  const shaped = shapeResults(results, "semantic_search");
8884
- const response = {
8904
+ return {
8885
8905
  indexInfo: getIndexMetadata(),
8886
- results: shaped
8906
+ results: shaped,
8907
+ ...crossRepo && vectorDB instanceof QdrantDB && { groupedByRepo: groupResultsByRepo(shaped) },
8908
+ ...notes.length > 0 && { note: notes.join(" ") }
8887
8909
  };
8888
- if (crossRepo && vectorDB instanceof QdrantDB) {
8889
- response.groupedByRepo = groupResultsByRepo(shaped);
8890
- }
8891
- if (notes.length > 0) {
8892
- response.note = notes.join(" ");
8893
- }
8894
- return response;
8895
8910
  }
8896
8911
  )(args);
8897
8912
  }
@@ -9086,7 +9101,9 @@ async function findRelatedChunks(filepaths, fileChunksMap, ctx) {
9086
9101
  const targetCanonical = getCanonicalPath(filepath, workspaceRoot);
9087
9102
  relatedChunksMap[index] = related.filter((r) => {
9088
9103
  const chunkCanonical = getCanonicalPath(r.metadata.file, workspaceRoot);
9089
- return chunkCanonical !== targetCanonical;
9104
+ if (chunkCanonical === targetCanonical) return false;
9105
+ if (r.metadata.language === "markdown") return false;
9106
+ return true;
9090
9107
  });
9091
9108
  });
9092
9109
  return relatedChunksMap;
@@ -9122,23 +9139,15 @@ function findTestAssociations(filepaths, allChunks, ctx) {
9122
9139
  return Array.from(testFiles);
9123
9140
  });
9124
9141
  }
9125
- function deduplicateChunks(fileChunks, relatedChunks, workspaceRoot) {
9126
- const seenChunks = /* @__PURE__ */ new Set();
9127
- return [...fileChunks, ...relatedChunks].filter((chunk) => {
9128
- const canonicalFile = getCanonicalPath(chunk.metadata.file, workspaceRoot);
9129
- const chunkId = `${canonicalFile}:${chunk.metadata.startLine}-${chunk.metadata.endLine}`;
9130
- if (seenChunks.has(chunkId)) return false;
9131
- seenChunks.add(chunkId);
9132
- return true;
9133
- });
9142
+ function deduplicateChunks(fileChunks, relatedChunks) {
9143
+ return deduplicateResults([...fileChunks, ...relatedChunks]);
9134
9144
  }
9135
- function buildFilesData(filepaths, fileChunksMap, relatedChunksMap, testAssociationsMap, workspaceRoot) {
9145
+ function buildFilesData(filepaths, fileChunksMap, relatedChunksMap, testAssociationsMap) {
9136
9146
  const filesData = {};
9137
9147
  filepaths.forEach((filepath, i) => {
9138
9148
  const dedupedChunks = deduplicateChunks(
9139
9149
  fileChunksMap[i],
9140
- relatedChunksMap[i] || [],
9141
- workspaceRoot
9150
+ relatedChunksMap[i] || []
9142
9151
  );
9143
9152
  filesData[filepath] = {
9144
9153
  chunks: dedupedChunks,
@@ -9216,8 +9225,7 @@ async function handleGetFilesContext(args, ctx) {
9216
9225
  filepaths,
9217
9226
  fileChunksMap,
9218
9227
  relatedChunksMap,
9219
- testAssociationsMap,
9220
- workspaceRoot
9228
+ testAssociationsMap
9221
9229
  );
9222
9230
  const totalChunks = Object.values(filesData).reduce(
9223
9231
  (sum, f) => sum + f.chunks.length,
@@ -9796,7 +9804,11 @@ async function handleGetComplexity(args, ctx) {
9796
9804
  threshold,
9797
9805
  top ?? 10
9798
9806
  );
9799
- const response = {
9807
+ const note = buildCrossRepoFallbackNote(fallback);
9808
+ if (note) {
9809
+ log("Warning: crossRepo=true requires Qdrant backend. Falling back to single-repo analysis.", "warning");
9810
+ }
9811
+ return {
9800
9812
  indexInfo: getIndexMetadata(),
9801
9813
  summary: {
9802
9814
  filesAnalyzed: report.summary.filesAnalyzed,
@@ -9805,17 +9817,12 @@ async function handleGetComplexity(args, ctx) {
9805
9817
  violationCount: violations.length,
9806
9818
  bySeverity
9807
9819
  },
9808
- violations: topViolations
9820
+ violations: topViolations,
9821
+ ...crossRepo && !fallback && allChunks.length > 0 && {
9822
+ groupedByRepo: groupViolationsByRepo(topViolations, allChunks)
9823
+ },
9824
+ ...note && { note }
9809
9825
  };
9810
- if (crossRepo && !fallback && allChunks.length > 0) {
9811
- response.groupedByRepo = groupViolationsByRepo(topViolations, allChunks);
9812
- }
9813
- const note = buildCrossRepoFallbackNote(fallback);
9814
- if (note) {
9815
- log("Warning: crossRepo=true requires Qdrant backend. Falling back to single-repo analysis.", "warning");
9816
- response.note = note;
9817
- }
9818
- return response;
9819
9826
  }
9820
9827
  )(args);
9821
9828
  }