@kage-core/kage-graph-mcp 1.1.1 → 1.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kage-core/kage-graph-mcp",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Local-first repo memory, code graph, and recall MCP server for coding agents",
5
5
  "main": "dist/index.js",
6
6
  "files": [
package/viewer/app.js CHANGED
@@ -35,21 +35,37 @@
35
35
 
36
36
  var palette = {
37
37
  repo: "#41ff8f",
38
- memory: "#b88cff",
38
+ memory: "#41ff8f",
39
39
  path: "#ff6b6b",
40
40
  tag: "#ffd166",
41
41
  package: "#6ad7ff",
42
42
  command: "#9be7c0",
43
43
  memory_type: "#41ff8f",
44
44
  file: "#6ad7ff",
45
- symbol: "#b88cff",
46
- route: "#ff8fab",
45
+ symbol: "#9be7c0",
46
+ route: "#6ad7ff",
47
47
  test: "#ffd166",
48
- external: "#93a4a0",
48
+ external: "#62776b",
49
49
  script: "#6ad7ff",
50
50
  default: "#9be7c0"
51
51
  };
52
52
 
53
+ var graphPalette = {
54
+ background: "#020503",
55
+ grid: "rgba(65,255,143,0.040)",
56
+ gridStrong: "rgba(65,255,143,0.070)",
57
+ text: "#d7f9df",
58
+ muted: "#6ea77d",
59
+ memory: "#41ff8f",
60
+ code: "#6ad7ff",
61
+ amber: "#ffd166",
62
+ danger: "#ff6b6b",
63
+ dependency: "#62776b",
64
+ body: "rgba(4,12,8,0.88)",
65
+ bodyCode: "rgba(5,16,18,0.88)",
66
+ bodyMemory: "rgba(5,18,10,0.90)"
67
+ };
68
+
53
69
  var els = {
54
70
  graphFile: document.getElementById("graphFile"),
55
71
  graphSummary: document.getElementById("graphSummary"),
@@ -454,7 +470,7 @@
454
470
  function render() {
455
471
  if (!state.graph) return;
456
472
 
457
- var query = normalize(els.searchInput.value);
473
+ var query = parseSearchQuery(els.searchInput.value);
458
474
  var mode = els.viewMode.value;
459
475
  var type = els.typeFilter.value;
460
476
  var relation = els.relationFilter.value;
@@ -464,7 +480,7 @@
464
480
  state.entities.forEach(function (entity) {
465
481
  if (mode !== "combined" && entity.graph_kind !== mode) return;
466
482
  var passesType = !type || entity.type === type;
467
- var passesSearch = !query || searchableText(entity).indexOf(query) !== -1;
483
+ var passesSearch = matchesSearchQuery(entity, query);
468
484
  if (passesType && passesSearch) matchedEntityIds.add(entity.id);
469
485
  });
470
486
 
@@ -472,7 +488,7 @@
472
488
  if (mode !== "combined" && edge.graph_kind !== mode) return;
473
489
  var fromMatched = matchedEntityIds.has(edge.from);
474
490
  var toMatched = matchedEntityIds.has(edge.to);
475
- var edgeMatchesSearch = !query || searchableText(edge).indexOf(query) !== -1;
491
+ var edgeMatchesSearch = matchesSearchQuery(edge, query);
476
492
  var passesRelation = !relation || edge.relation === relation;
477
493
  if (passesRelation && (edgeMatchesSearch || fromMatched || toMatched)) {
478
494
  matchedEdgeIds.add(edge.id);
@@ -483,7 +499,7 @@
483
499
  }
484
500
  });
485
501
 
486
- if (!query && !type && !relation) {
502
+ if (!query.active && !type && !relation) {
487
503
  matchedEntityIds = new Set(state.entities.filter(function (entity) { return mode === "combined" || entity.graph_kind === mode; }).map(function (entity) { return entity.id; }));
488
504
  matchedEdgeIds = new Set(state.edges.filter(function (edge) { return mode === "combined" || edge.graph_kind === mode; }).map(function (edge) { return edge.id; }));
489
505
  }
@@ -520,7 +536,7 @@
520
536
  Array.from(entities).forEach(function (id) {
521
537
  var entity = state.entityById.get(id);
522
538
  if (!entity) return;
523
- if (isDependencyEntity(entity) && !(options.query && searchableText(entity).indexOf(options.query) !== -1)) {
539
+ if (isDependencyEntity(entity) && !matchesSearchQuery(entity, options.query)) {
524
540
  entities.delete(id);
525
541
  }
526
542
  });
@@ -751,9 +767,15 @@
751
767
 
752
768
  function drawCanvasGrid(ctx, width, height) {
753
769
  ctx.save();
754
- ctx.fillStyle = "#020503";
770
+ ctx.fillStyle = graphPalette.background;
755
771
  ctx.fillRect(0, 0, width, height);
756
- ctx.strokeStyle = "rgba(65,255,143,0.045)";
772
+ var gradient = ctx.createRadialGradient(width * 0.52, height * 0.44, 40, width * 0.52, height * 0.44, Math.max(width, height) * 0.72);
773
+ gradient.addColorStop(0, "rgba(65,255,143,0.080)");
774
+ gradient.addColorStop(0.48, "rgba(65,255,143,0.018)");
775
+ gradient.addColorStop(1, "rgba(2,5,3,0)");
776
+ ctx.fillStyle = gradient;
777
+ ctx.fillRect(0, 0, width, height);
778
+ ctx.strokeStyle = graphPalette.grid;
757
779
  ctx.lineWidth = 1;
758
780
  var grid = 28;
759
781
  for (var x = 0; x < width; x += grid) {
@@ -768,22 +790,29 @@
768
790
  ctx.lineTo(width, y);
769
791
  ctx.stroke();
770
792
  }
793
+ ctx.strokeStyle = graphPalette.gridStrong;
794
+ ctx.beginPath();
795
+ ctx.moveTo(0, height / 2);
796
+ ctx.lineTo(width, height / 2);
797
+ ctx.moveTo(width / 2, 0);
798
+ ctx.lineTo(width / 2, height);
799
+ ctx.stroke();
771
800
  ctx.restore();
772
801
  }
773
802
 
774
803
  function drawCanvasEdges(ctx) {
775
804
  var nodeMap = state.sim.nodeById;
776
805
  var focusId = focusedCanvasNodeId();
777
- var query = normalize(els.searchInput.value);
806
+ var query = parseSearchQuery(els.searchInput.value);
778
807
  var dense = state.sim.nodes.length > 55;
779
808
  state.sim.edges.forEach(function (edge) {
780
809
  var from = nodeMap.get(edge.from);
781
810
  var to = nodeMap.get(edge.to);
782
811
  if (!from || !to) return;
783
812
  var connected = focusId && (edge.from === focusId || edge.to === focusId);
784
- var matches = !query || searchableText(edge).indexOf(query) !== -1 || searchableText(from.entity).indexOf(query) !== -1 || searchableText(to.entity).indexOf(query) !== -1;
785
- var alpha = !matches ? 0.04 : focusId ? (connected ? 0.78 : 0.07) : (dense ? 0.18 : 0.34);
786
- var color = hexToRgb(palette[from.entity.type] || palette[from.entity.graph_kind] || palette.default);
813
+ var matches = matchesSearchQuery(edge, query) || matchesSearchQuery(from.entity, query) || matchesSearchQuery(to.entity, query);
814
+ var alpha = !matches ? 0.035 : focusId ? (connected ? 0.62 : 0.055) : (dense ? 0.13 : 0.22);
815
+ var color = hexToRgb(edgeThemeColor(edge, from.entity, to.entity));
787
816
  var dx = to.x - from.x;
788
817
  var dy = to.y - from.y;
789
818
  var dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
@@ -794,7 +823,7 @@
794
823
  ctx.moveTo(from.x, from.y);
795
824
  ctx.quadraticCurveTo(cx, cy, to.x, to.y);
796
825
  ctx.strokeStyle = "rgba(" + color.r + "," + color.g + "," + color.b + "," + alpha + ")";
797
- ctx.lineWidth = connected ? 2.8 : 1.2;
826
+ ctx.lineWidth = connected ? 2.2 : 1;
798
827
  ctx.stroke();
799
828
  if (connected || (!dense && state.sim.zoom > 1.25)) drawArrow(ctx, from, to, cx, cy, color, alpha);
800
829
  if (connected && state.sim.zoom > 0.62) drawEdgeLabel(ctx, edge, cx, cy);
@@ -803,7 +832,7 @@
803
832
 
804
833
  function drawCanvasNodes(ctx) {
805
834
  var focusId = focusedCanvasNodeId();
806
- var query = normalize(els.searchInput.value);
835
+ var query = parseSearchQuery(els.searchInput.value);
807
836
  var dense = state.sim.nodes.length > 55;
808
837
  state.sim.nodes.forEach(function (node) {
809
838
  var entity = node.entity;
@@ -812,35 +841,42 @@
812
841
  var connected = focusId && (node.id === focusId || state.sim.edges.some(function (edge) {
813
842
  return (edge.from === focusId && edge.to === node.id) || (edge.to === focusId && edge.from === node.id);
814
843
  }));
815
- var matches = !query || searchableText(entity).indexOf(query) !== -1;
844
+ var matches = matchesSearchQuery(entity, query);
816
845
  var alpha = !matches ? 0.12 : focusId && !connected ? 0.20 : 1;
817
- var color = palette[entity.type] || palette[entity.graph_kind] || palette.default;
846
+ var color = nodeThemeColor(entity);
818
847
  ctx.save();
819
848
  ctx.globalAlpha = alpha;
820
- if (selected || hovered || (!focusId && !dense)) {
849
+ if (selected || hovered) {
821
850
  ctx.shadowColor = color;
822
- ctx.shadowBlur = selected ? 20 : hovered ? 16 : 5;
851
+ ctx.shadowBlur = selected ? 14 : 10;
823
852
  }
824
853
  drawNodeShape(ctx, node.x, node.y, node.r, entity);
825
- var grad = ctx.createRadialGradient(node.x - node.r * 0.3, node.y - node.r * 0.3, 1, node.x, node.y, node.r * 1.35);
826
- grad.addColorStop(0, brighten(color, 54));
827
- grad.addColorStop(1, color);
828
- ctx.fillStyle = grad;
854
+ ctx.fillStyle = nodeFillColor(entity);
829
855
  ctx.fill();
856
+ ctx.strokeStyle = color;
857
+ ctx.lineWidth = selected || hovered ? 2.2 : 1.2;
858
+ ctx.stroke();
859
+ if (entity.graph_kind === "memory") {
860
+ ctx.fillStyle = color;
861
+ ctx.globalAlpha = alpha * 0.85;
862
+ ctx.beginPath();
863
+ ctx.arc(node.x, node.y, Math.max(2.4, node.r * 0.18), 0, Math.PI * 2);
864
+ ctx.fill();
865
+ }
830
866
  ctx.restore();
831
867
 
832
868
  if (selected || hovered) {
833
869
  ctx.save();
834
870
  drawNodeShape(ctx, node.x, node.y, node.r + 4, entity);
835
871
  ctx.strokeStyle = color;
836
- ctx.lineWidth = selected ? 3 : 2;
872
+ ctx.lineWidth = selected ? 2.6 : 1.8;
837
873
  ctx.shadowColor = color;
838
- ctx.shadowBlur = 12;
874
+ ctx.shadowBlur = 8;
839
875
  ctx.stroke();
840
876
  ctx.restore();
841
877
  }
842
878
 
843
- var shouldLabel = matches && (selected || hovered || (query && matches) || (!dense && state.sim.zoom > 0.75) || (dense && state.sim.zoom > 1.55 && node.r > 13));
879
+ var shouldLabel = matches && (selected || hovered || (query.active && matches) || (!dense && state.sim.zoom > 0.75) || (dense && state.sim.zoom > 1.55 && node.r > 13));
844
880
  if (shouldLabel) drawNodeLabel(ctx, node, selected || hovered);
845
881
  });
846
882
  }
@@ -851,8 +887,8 @@
851
887
  var tipY = to.y - to.r * Math.sin(angle);
852
888
  ctx.beginPath();
853
889
  ctx.moveTo(tipX, tipY);
854
- ctx.lineTo(tipX - 8 * Math.cos(angle - 0.35), tipY - 8 * Math.sin(angle - 0.35));
855
- ctx.lineTo(tipX - 8 * Math.cos(angle + 0.35), tipY - 8 * Math.sin(angle + 0.35));
890
+ ctx.lineTo(tipX - 6 * Math.cos(angle - 0.32), tipY - 6 * Math.sin(angle - 0.32));
891
+ ctx.lineTo(tipX - 6 * Math.cos(angle + 0.32), tipY - 6 * Math.sin(angle + 0.32));
856
892
  ctx.closePath();
857
893
  ctx.fillStyle = "rgba(" + color.r + "," + color.g + "," + color.b + "," + Math.min(0.85, alpha + 0.10) + ")";
858
894
  ctx.fill();
@@ -861,9 +897,9 @@
861
897
  function drawEdgeLabel(ctx, edge, x, y) {
862
898
  var inv = 1 / state.sim.zoom;
863
899
  ctx.save();
864
- ctx.font = "700 " + (10 * inv).toFixed(1) + "px ui-monospace, Menlo, monospace";
900
+ ctx.font = "700 " + (9 * inv).toFixed(1) + "px ui-monospace, Menlo, monospace";
865
901
  ctx.textAlign = "center";
866
- ctx.fillStyle = "rgba(215,249,223,0.82)";
902
+ ctx.fillStyle = "rgba(155,231,192,0.72)";
867
903
  ctx.fillText(shortName(edge.relation || "related", 22), x, y - 5 * inv);
868
904
  ctx.restore();
869
905
  }
@@ -872,17 +908,17 @@
872
908
  var inv = 1 / state.sim.zoom;
873
909
  var label = shortName(displayName(node.entity), strong ? 30 : 20);
874
910
  ctx.save();
875
- ctx.font = (strong ? "800 " : "700 ") + (12 * inv).toFixed(1) + "px ui-monospace, Menlo, monospace";
911
+ ctx.font = (strong ? "800 " : "700 ") + (11 * inv).toFixed(1) + "px ui-monospace, Menlo, monospace";
876
912
  var width = ctx.measureText(label).width + 16 * inv;
877
913
  var height = 20 * inv;
878
914
  var x = node.x - width / 2;
879
915
  var y = node.y + node.r + 8 * inv;
880
- ctx.fillStyle = "rgba(3,6,4,0.88)";
916
+ ctx.fillStyle = "rgba(2,5,3,0.92)";
881
917
  roundedRect(ctx, x, y, width, height, 4 * inv);
882
918
  ctx.fill();
883
- ctx.strokeStyle = strong ? "rgba(65,255,143,0.55)" : "rgba(65,255,143,0.18)";
919
+ ctx.strokeStyle = strong ? "rgba(65,255,143,0.45)" : "rgba(65,255,143,0.14)";
884
920
  ctx.stroke();
885
- ctx.fillStyle = strong ? "#d7f9df" : "#9be7c0";
921
+ ctx.fillStyle = strong ? graphPalette.text : graphPalette.muted;
886
922
  ctx.textAlign = "center";
887
923
  ctx.fillText(label, node.x, y + 14 * inv);
888
924
  ctx.restore();
@@ -919,6 +955,30 @@
919
955
  ctx.arc(x, y, r, 0, Math.PI * 2);
920
956
  }
921
957
 
958
+ function nodeThemeColor(entity) {
959
+ if (isDependencyEntity(entity) || entity.type === "external") return graphPalette.dependency;
960
+ if (entity.type === "test" || entity.type === "tag") return graphPalette.amber;
961
+ if (entity.type === "bug_fix" || entity.type === "path") return graphPalette.danger;
962
+ if (entity.graph_kind === "memory" || ["memory", "repo", "memory_type", "decision", "runbook", "workflow", "convention", "gotcha", "reference", "policy"].indexOf(entity.type) !== -1) return graphPalette.memory;
963
+ if (entity.graph_kind === "code" || ["file", "symbol", "route", "script", "command", "package"].indexOf(entity.type) !== -1) return graphPalette.code;
964
+ return graphPalette.muted;
965
+ }
966
+
967
+ function nodeFillColor(entity) {
968
+ if (isDependencyEntity(entity) || entity.type === "external") return "rgba(7,13,10,0.88)";
969
+ if (entity.graph_kind === "memory" || entity.type === "memory") return graphPalette.bodyMemory;
970
+ if (entity.graph_kind === "code") return graphPalette.bodyCode;
971
+ return graphPalette.body;
972
+ }
973
+
974
+ function edgeThemeColor(edge, fromEntity, toEntity) {
975
+ if (edge.relation && /test|covers/i.test(edge.relation)) return graphPalette.amber;
976
+ if (edge.relation && /invalid|risk|missing|bug/i.test(edge.relation)) return graphPalette.danger;
977
+ if (isDependencyEntity(fromEntity) || isDependencyEntity(toEntity)) return graphPalette.dependency;
978
+ if (fromEntity.graph_kind === "memory" || toEntity.graph_kind === "memory") return graphPalette.memory;
979
+ return graphPalette.code;
980
+ }
981
+
922
982
  function renderSvg() {
923
983
  els.edgeLayer.textContent = "";
924
984
  els.nodeLayer.textContent = "";
@@ -1461,7 +1521,7 @@
1461
1521
  }
1462
1522
  var entity = node.entity;
1463
1523
  var relationCount = state.sim.edges.filter(function (edge) { return edge.from === node.id || edge.to === node.id; }).length;
1464
- var color = palette[entity.type] || palette[entity.graph_kind] || palette.default;
1524
+ var color = nodeThemeColor(entity);
1465
1525
  els.tooltip.innerHTML = [
1466
1526
  "<div class=\"tt-name\"></div>",
1467
1527
  "<div class=\"tt-type\"></div>",
@@ -1653,6 +1713,77 @@
1653
1713
  return normalize(JSON.stringify(value || {}));
1654
1714
  }
1655
1715
 
1716
+ function parseSearchQuery(value) {
1717
+ var raw = normalize(value);
1718
+ var tokens = raw
1719
+ .replace(/[^a-z0-9_./:-]+/g, " ")
1720
+ .split(/\s+/)
1721
+ .map(searchStem)
1722
+ .filter(Boolean)
1723
+ .filter(function (token) { return !SEARCH_STOP_WORDS.has(token); });
1724
+ if ((tokens.indexOf("run") !== -1 || tokens.indexOf("runn") !== -1) && tokens.indexOf("test") !== -1) tokens.push("runtest");
1725
+ var groups = tokens.map(function (token) {
1726
+ return unique([token].concat(SEARCH_SYNONYMS[token] || []).map(searchStem).filter(Boolean));
1727
+ });
1728
+ return {
1729
+ active: raw.trim().length > 0,
1730
+ raw: raw,
1731
+ tokens: unique(groups.reduce(function (all, group) { return all.concat(group); }, [])),
1732
+ groups: groups
1733
+ };
1734
+ }
1735
+
1736
+ var SEARCH_STOP_WORDS = new Set([
1737
+ "a", "an", "and", "are", "about", "can", "do", "does", "for", "from", "how", "i", "in", "is", "it", "me", "of", "on", "or", "please", "show", "that", "the", "there", "this", "to", "what", "when", "where", "which", "who", "why", "with"
1738
+ ]);
1739
+
1740
+ var SEARCH_SYNONYMS = {
1741
+ memory: ["packet", "runbook", "decision", "workflow", "gotcha", "reference"],
1742
+ test: ["tests", "testing", "vitest", "jest", "pytest", "spec"],
1743
+ run: ["running", "command", "script", "npm", "pnpm", "yarn"],
1744
+ runn: ["run", "running", "command", "script", "npm", "pnpm", "yarn"],
1745
+ runtest: ["run", "test", "runbook", "command"],
1746
+ start: ["serve", "dev", "launch"],
1747
+ build: ["compile", "tsc"],
1748
+ bug: ["fix", "gotcha", "error"],
1749
+ route: ["endpoint", "api"],
1750
+ file: ["path"],
1751
+ dependency: ["package", "external", "deps"]
1752
+ };
1753
+
1754
+ function matchesSearchQuery(value, query) {
1755
+ if (!query || !query.active) return true;
1756
+ var text = searchableText(value);
1757
+ if (query.raw && text.indexOf(query.raw) !== -1) return true;
1758
+ if (!query.tokens.length) return true;
1759
+ var textTokens = new Set(text
1760
+ .replace(/[^a-z0-9_./:-]+/g, " ")
1761
+ .split(/\s+/)
1762
+ .map(searchStem)
1763
+ .filter(Boolean));
1764
+ var requiredGroups = (query.groups || []).filter(function (group) {
1765
+ return group.some(function (token) { return SEARCH_SOFT_TOKENS.has(token) ? text.indexOf(token) !== -1 || textTokens.has(token) : true; });
1766
+ });
1767
+ if (!requiredGroups.length) requiredGroups = query.groups || [query.tokens];
1768
+ return requiredGroups.every(function (group) {
1769
+ return group.some(function (token) {
1770
+ if (text.indexOf(token) !== -1) return true;
1771
+ return textTokens.has(token);
1772
+ });
1773
+ });
1774
+ }
1775
+
1776
+ var SEARCH_SOFT_TOKENS = new Set(["memory", "packet", "about"]);
1777
+
1778
+ function searchStem(value) {
1779
+ var token = String(value || "").toLowerCase();
1780
+ if (token.length > 5 && token.endsWith("ing")) token = token.slice(0, -3);
1781
+ if (token.length > 4 && token.endsWith("ies")) token = token.slice(0, -3) + "y";
1782
+ if (token.length > 4 && token.endsWith("es")) token = token.slice(0, -2);
1783
+ if (token.length > 3 && token.endsWith("s")) token = token.slice(0, -1);
1784
+ return token;
1785
+ }
1786
+
1656
1787
  function shortName(value, max) {
1657
1788
  var text = String(value || "");
1658
1789
  return text.length > max ? text.slice(0, Math.max(1, max - 1)) + "..." : text;
package/viewer/styles.css CHANGED
@@ -331,7 +331,7 @@ input:focus, select:focus, button:focus, .file-picker:focus-within {
331
331
  height: 100%;
332
332
  overflow: hidden;
333
333
  background:
334
- radial-gradient(circle at 52% 46%, rgba(65, 255, 143, 0.10), transparent 44%),
334
+ radial-gradient(circle at 52% 46%, rgba(65, 255, 143, 0.055), transparent 44%),
335
335
  #020503;
336
336
  }
337
337
 
@@ -367,10 +367,10 @@ input:focus, select:focus, button:focus, .file-picker:focus-within {
367
367
  display: none;
368
368
  max-width: min(320px, calc(100% - 28px));
369
369
  padding: 10px 12px;
370
- border: 1px solid rgba(65, 255, 143, 0.32);
371
- border-radius: 6px;
372
- background: rgba(3, 6, 4, 0.90);
373
- box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(65, 255, 143, 0.08);
370
+ border: 1px solid rgba(65, 255, 143, 0.28);
371
+ border-radius: 4px;
372
+ background: rgba(2, 5, 3, 0.94);
373
+ box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42), inset 0 0 0 1px rgba(65, 255, 143, 0.06);
374
374
  backdrop-filter: blur(12px);
375
375
  color: var(--text);
376
376
  pointer-events: none;
@@ -378,14 +378,14 @@ input:focus, select:focus, button:focus, .file-picker:focus-within {
378
378
  .graph-tooltip.visible { display: block; }
379
379
  .tt-name {
380
380
  color: var(--terminal);
381
- font-weight: 850;
381
+ font-weight: 820;
382
382
  overflow-wrap: anywhere;
383
383
  }
384
384
  .tt-type {
385
385
  margin-top: 4px;
386
386
  font-size: 10px;
387
387
  font-weight: 800;
388
- letter-spacing: 0.08em;
388
+ letter-spacing: 0.10em;
389
389
  text-transform: uppercase;
390
390
  }
391
391
  .tt-summary {