@vibgrate/cli 2026.817.2 → 2026.818.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.
Files changed (153) hide show
  1. package/dist/activity-MF2GNYAI.js +5 -0
  2. package/dist/activity-MF2GNYAI.js.map +1 -0
  3. package/dist/agent-X6VYCE63.js +30 -0
  4. package/dist/{agent-UQC7QN77.js.map → agent-X6VYCE63.js.map} +1 -1
  5. package/dist/{approvals-ASPJQUZK.js → approvals-TPQFQSWG.js} +5 -5
  6. package/dist/{approvals-ASPJQUZK.js.map → approvals-TPQFQSWG.js.map} +1 -1
  7. package/dist/attach-G5JUIWIT.js +10 -0
  8. package/dist/attach-G5JUIWIT.js.map +1 -0
  9. package/dist/baseline-DXI64VLW.js +9 -0
  10. package/dist/{baseline-FIV6PR2M.js.map → baseline-DXI64VLW.js.map} +1 -1
  11. package/dist/{chunk-AXZZ5CCG.js → chunk-2C33WR5O.js} +38 -19
  12. package/dist/chunk-2C33WR5O.js.map +1 -0
  13. package/dist/chunk-4NTNMT6T.js +6 -0
  14. package/dist/{chunk-PRG2ULPK.js.map → chunk-4NTNMT6T.js.map} +1 -1
  15. package/dist/chunk-5IQBIXHS.js +23 -0
  16. package/dist/chunk-5IQBIXHS.js.map +1 -0
  17. package/dist/{chunk-6K3XK7C5.js → chunk-6ABMV74F.js} +6 -3
  18. package/dist/chunk-6ABMV74F.js.map +1 -0
  19. package/dist/chunk-6BEBJCK4.js +467 -0
  20. package/dist/chunk-6BEBJCK4.js.map +1 -0
  21. package/dist/{chunk-E2FAQREZ.js → chunk-6PFHDHOL.js} +174 -401
  22. package/dist/chunk-6PFHDHOL.js.map +1 -0
  23. package/dist/chunk-6WRG7VDO.js +118 -0
  24. package/dist/chunk-6WRG7VDO.js.map +1 -0
  25. package/dist/{chunk-3NJUOIZQ.js → chunk-AEJYA6HZ.js} +5 -5
  26. package/dist/{chunk-3NJUOIZQ.js.map → chunk-AEJYA6HZ.js.map} +1 -1
  27. package/dist/{chunk-O2DL2Q55.js → chunk-B4EXD5LK.js} +5 -5
  28. package/dist/{chunk-O2DL2Q55.js.map → chunk-B4EXD5LK.js.map} +1 -1
  29. package/dist/{chunk-EXV4QSAD.js → chunk-BMOFJIMG.js} +3 -3
  30. package/dist/{chunk-EXV4QSAD.js.map → chunk-BMOFJIMG.js.map} +1 -1
  31. package/dist/chunk-DBX3DL27.js +26 -0
  32. package/dist/chunk-DBX3DL27.js.map +1 -0
  33. package/dist/{chunk-KNGAZDGF.js → chunk-E3O5UKNA.js} +151 -42
  34. package/dist/chunk-E3O5UKNA.js.map +1 -0
  35. package/dist/{chunk-RBIRXQR6.js → chunk-E53WBVUQ.js} +7 -14
  36. package/dist/chunk-E53WBVUQ.js.map +1 -0
  37. package/dist/{chunk-C3LMWZKF.js → chunk-FFXGWFAE.js} +4 -4
  38. package/dist/{chunk-C3LMWZKF.js.map → chunk-FFXGWFAE.js.map} +1 -1
  39. package/dist/chunk-H5Q4JUY4.js +47 -0
  40. package/dist/chunk-H5Q4JUY4.js.map +1 -0
  41. package/dist/{chunk-LHKQGVRF.js → chunk-HF6R73UC.js} +100 -11
  42. package/dist/chunk-HF6R73UC.js.map +1 -0
  43. package/dist/{chunk-K6DXETMC.js → chunk-JGA63RGF.js} +13 -12
  44. package/dist/chunk-JGA63RGF.js.map +1 -0
  45. package/dist/{chunk-3FMRFECC.js → chunk-KU7FI5EV.js} +3 -3
  46. package/dist/{chunk-3FMRFECC.js.map → chunk-KU7FI5EV.js.map} +1 -1
  47. package/dist/{chunk-5OL2TSHK.js → chunk-L2OS4WHT.js} +4 -4
  48. package/dist/{chunk-5OL2TSHK.js.map → chunk-L2OS4WHT.js.map} +1 -1
  49. package/dist/chunk-LJSJX6U4.js +38 -0
  50. package/dist/chunk-LJSJX6U4.js.map +1 -0
  51. package/dist/{chunk-Q4G2BWE3.js → chunk-MRZHNUN7.js} +12 -6
  52. package/dist/chunk-MRZHNUN7.js.map +1 -0
  53. package/dist/chunk-NDNNOAS6.js +16 -0
  54. package/dist/chunk-NDNNOAS6.js.map +1 -0
  55. package/dist/chunk-NJQZRM55.js +100 -0
  56. package/dist/chunk-NJQZRM55.js.map +1 -0
  57. package/dist/{chunk-DVW3SVCW.js → chunk-NKLYDSB7.js} +29 -9
  58. package/dist/chunk-NKLYDSB7.js.map +1 -0
  59. package/dist/{chunk-TVDMNIUT.js → chunk-O5IJDMTB.js} +4 -4
  60. package/dist/{chunk-TVDMNIUT.js.map → chunk-O5IJDMTB.js.map} +1 -1
  61. package/dist/chunk-POOL355F.js +237 -0
  62. package/dist/chunk-POOL355F.js.map +1 -0
  63. package/dist/{chunk-XLXJC7H3.js → chunk-PRHH4DVO.js} +5 -118
  64. package/dist/chunk-PRHH4DVO.js.map +1 -0
  65. package/dist/{chunk-3H3SVJUY.js → chunk-RHKOUPWT.js} +107 -542
  66. package/dist/chunk-RHKOUPWT.js.map +1 -0
  67. package/dist/{chunk-WAKP7SK7.js → chunk-V2UGRUTL.js} +225 -48
  68. package/dist/chunk-V2UGRUTL.js.map +1 -0
  69. package/dist/{chunk-2FEB5KJS.js → chunk-V6WONSIK.js} +5 -4
  70. package/dist/chunk-V6WONSIK.js.map +1 -0
  71. package/dist/{chunk-WVMOGIPC.js → chunk-VMAIDM4K.js} +3 -3
  72. package/dist/{chunk-WVMOGIPC.js.map → chunk-VMAIDM4K.js.map} +1 -1
  73. package/dist/{chunk-GOGMS3ST.js → chunk-VQ5KMHW6.js} +860 -65
  74. package/dist/chunk-VQ5KMHW6.js.map +1 -0
  75. package/dist/{chunk-M7IO3DXH.js → chunk-X2MQ7UFL.js} +250 -30
  76. package/dist/chunk-X2MQ7UFL.js.map +1 -0
  77. package/dist/{chunk-OZ3IFXRD.js → chunk-YENM3HT7.js} +5 -4
  78. package/dist/chunk-YENM3HT7.js.map +1 -0
  79. package/dist/{chunk-KJT2R6WW.js → chunk-YF54UMOU.js} +3 -3
  80. package/dist/{chunk-KJT2R6WW.js.map → chunk-YF54UMOU.js.map} +1 -1
  81. package/dist/{chunk-Q3M6K3HY.js → chunk-ZUOBPKVK.js} +3 -3
  82. package/dist/{chunk-Q3M6K3HY.js.map → chunk-ZUOBPKVK.js.map} +1 -1
  83. package/dist/cli.d.ts +6 -0
  84. package/dist/cli.js +711 -463
  85. package/dist/cli.js.map +1 -1
  86. package/dist/client-UQIELEEZ.js +8 -0
  87. package/dist/client-UQIELEEZ.js.map +1 -0
  88. package/dist/daemon-GUMWMKCA.js +31 -0
  89. package/dist/{daemon-FPTRHO5N.js.map → daemon-GUMWMKCA.js.map} +1 -1
  90. package/dist/embed-worker-main.js +3 -3
  91. package/dist/ensure-map-FHDJTO7Y.js +41 -0
  92. package/dist/{ensure-map-342G2IV3.js.map → ensure-map-FHDJTO7Y.js.map} +1 -1
  93. package/dist/graph-backend-W2D3HRRD.js +16 -0
  94. package/dist/{graph-backend-RNWQBT3P.js.map → graph-backend-W2D3HRRD.js.map} +1 -1
  95. package/dist/index.d.ts +633 -4
  96. package/dist/index.js +26 -17
  97. package/dist/index.js.map +1 -1
  98. package/dist/{interactive-SR7TMF6M.js → interactive-2MK4TLRD.js} +42 -34
  99. package/dist/interactive-2MK4TLRD.js.map +1 -0
  100. package/dist/load-4R4HYMBB.js +11 -0
  101. package/dist/{load-AYFECIQB.js.map → load-4R4HYMBB.js.map} +1 -1
  102. package/dist/parse-worker.js +3 -2
  103. package/dist/parse-worker.js.map +1 -1
  104. package/dist/publish-7YHRTBRA.js +9 -0
  105. package/dist/publish-7YHRTBRA.js.map +1 -0
  106. package/dist/{run-outcome-YQQJG3LW.js → run-outcome-H5GVDDZJ.js} +5 -5
  107. package/dist/{run-outcome-YQQJG3LW.js.map → run-outcome-H5GVDDZJ.js.map} +1 -1
  108. package/dist/runtime-session-JBIHHH5N.js +27 -0
  109. package/dist/{runtime-session-CNJ4DAV5.js.map → runtime-session-JBIHHH5N.js.map} +1 -1
  110. package/dist/semantic-status-2JFLIQQJ.js +4 -0
  111. package/dist/semantic-status-2JFLIQQJ.js.map +1 -0
  112. package/dist/{session-H34HUV2Y.js → session-N5IU4K5Q.js} +8 -8
  113. package/dist/{session-H34HUV2Y.js.map → session-N5IU4K5Q.js.map} +1 -1
  114. package/dist/slot-subscription-25GOARW5.js +95 -0
  115. package/dist/slot-subscription-25GOARW5.js.map +1 -0
  116. package/dist/{stream-json-55YDNAFX.js → stream-json-4WLSUF6I.js} +18 -15
  117. package/dist/stream-json-4WLSUF6I.js.map +1 -0
  118. package/dist/version-DTEU3SQD.js +4 -0
  119. package/dist/{version-WSE3QOPK.js.map → version-DTEU3SQD.js.map} +1 -1
  120. package/dist/{vg-mcp-bridge-2CNLHNEL.js → vg-mcp-bridge-KDVYIMFX.js} +12 -11
  121. package/dist/vg-mcp-bridge-KDVYIMFX.js.map +1 -0
  122. package/dist/{vgd-URUZQORN.js → vgd-M7UOPWLB.js} +15 -10
  123. package/dist/vgd-M7UOPWLB.js.map +1 -0
  124. package/package.json +1 -1
  125. package/dist/agent-UQC7QN77.js +0 -27
  126. package/dist/baseline-FIV6PR2M.js +0 -9
  127. package/dist/chunk-2FEB5KJS.js.map +0 -1
  128. package/dist/chunk-3H3SVJUY.js.map +0 -1
  129. package/dist/chunk-6K3XK7C5.js.map +0 -1
  130. package/dist/chunk-AXZZ5CCG.js.map +0 -1
  131. package/dist/chunk-DVW3SVCW.js.map +0 -1
  132. package/dist/chunk-E2FAQREZ.js.map +0 -1
  133. package/dist/chunk-GOGMS3ST.js.map +0 -1
  134. package/dist/chunk-K6DXETMC.js.map +0 -1
  135. package/dist/chunk-KNGAZDGF.js.map +0 -1
  136. package/dist/chunk-LHKQGVRF.js.map +0 -1
  137. package/dist/chunk-M7IO3DXH.js.map +0 -1
  138. package/dist/chunk-OZ3IFXRD.js.map +0 -1
  139. package/dist/chunk-PRG2ULPK.js +0 -6
  140. package/dist/chunk-Q4G2BWE3.js.map +0 -1
  141. package/dist/chunk-RBIRXQR6.js.map +0 -1
  142. package/dist/chunk-WAKP7SK7.js.map +0 -1
  143. package/dist/chunk-XLXJC7H3.js.map +0 -1
  144. package/dist/daemon-FPTRHO5N.js +0 -26
  145. package/dist/ensure-map-342G2IV3.js +0 -33
  146. package/dist/graph-backend-RNWQBT3P.js +0 -15
  147. package/dist/interactive-SR7TMF6M.js.map +0 -1
  148. package/dist/load-AYFECIQB.js +0 -11
  149. package/dist/runtime-session-CNJ4DAV5.js +0 -22
  150. package/dist/stream-json-55YDNAFX.js.map +0 -1
  151. package/dist/version-WSE3QOPK.js +0 -4
  152. package/dist/vg-mcp-bridge-2CNLHNEL.js.map +0 -1
  153. package/dist/vgd-URUZQORN.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { G as GraphNode, a as GraphEdge, A as Area, R as ResolverKind, V as VgGr
2
2
  export { e as AnalysisTier, C as Centrality, D as DerivedBy, f as EpistemicTier, g as FactConfidence, h as FactKind, i as GraphMeta, j as GraphSummaries, H as HubBlastSummary, N as NodeKind, P as Provenance, k as SUPPORTED_SCHEMA_VERSIONS, l as Span, m as SupportedSchemaVersion, T as Toolchain, U as Unknown } from './types-DHqH0XIE.js';
3
3
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
4
 
5
- declare const VERSION = "2026.817.2";
5
+ declare const VERSION = "2026.818.2";
6
6
 
7
7
  /**
8
8
  * Analysis stage: importance, centrality, hubs, communities, and surprise.
@@ -699,9 +699,24 @@ interface QueryResult {
699
699
  }
700
700
  declare function queryGraph(graph: VgGraph, question: string, options?: QueryOptions): QueryResult;
701
701
  interface SemanticQueryOptions extends QueryOptions {
702
- embedder: Embedder;
702
+ /** Local embedder. Optional only when {@link semanticRanked} supplies the pass. */
703
+ embedder?: Embedder;
703
704
  /** Precomputed node vectors (from getNodeEmbeddings); falls back to lexical for nodes without one. */
704
- nodeVectors: Map<string, number[]>;
705
+ nodeVectors?: Map<string, number[]>;
706
+ /**
707
+ * A semantic pass someone else already ran — vgd ranking the question
708
+ * against its resident slot index. Supplied instead of `embedder` +
709
+ * `nodeVectors` so the caller pays neither a model load nor a vector scan,
710
+ * and no vectors cross the socket.
711
+ *
712
+ * Only the ORDER of this list is consumed (RRF fuses rankings, not scores),
713
+ * so a truncated top-K is not an approximation: a candidate ranked past a
714
+ * few hundred cannot reach a 12-row answer.
715
+ */
716
+ semanticRanked?: Array<{
717
+ id: string;
718
+ score: number;
719
+ }>;
705
720
  }
706
721
  /**
707
722
  * Hybrid lexical + local-embedding retrieval, combined with Reciprocal Rank
@@ -802,6 +817,597 @@ declare class GraphIndex {
802
817
  private resolveTargets;
803
818
  }
804
819
 
820
+ /**
821
+ * Wire protocol for the lightweight Vibgrate daemon (`vgd`) — Fusion Runtime Phase 2 prototype.
822
+ *
823
+ * Line-delimited JSON over a local Unix domain socket (named pipe on Windows).
824
+ * No credentials leave this process; the socket is local-only.
825
+ */
826
+ declare const VGD_PROTOCOL_VERSION: "vgd/0";
827
+ interface WorkspaceRecord {
828
+ /** Stable repository id (same as global store key). */
829
+ id: string;
830
+ /** Absolute repository root. */
831
+ root: string;
832
+ /** Absolute path to the current graph snapshot (may not exist yet). */
833
+ graphPath: string;
834
+ /** ISO timestamp when this workspace was last registered / refreshed. */
835
+ registeredAt: string;
836
+ /** Optional federation label. */
837
+ label?: string;
838
+ /** Optional federation role. */
839
+ role?: 'primary' | 'member';
840
+ /** Git branch or detached SHA at registration (multi-branch ActiveGraph). */
841
+ gitRef?: string;
842
+ }
843
+ /** Lightweight ActiveGraph slot summary (no full graph payload). */
844
+ interface GraphSlotSummary {
845
+ repositoryId: string;
846
+ gitRef: string;
847
+ loadedAt: number;
848
+ lastAccessAt: number;
849
+ nodeCount: number;
850
+ current: boolean;
851
+ idleMs: number;
852
+ evictable: boolean;
853
+ }
854
+ type VgdRequest = {
855
+ op: 'ping';
856
+ } | {
857
+ op: 'status';
858
+ }
859
+ /** Ask the daemon to exit cleanly (honoured only by a standalone `vg daemon start`). */
860
+ | {
861
+ op: 'shutdown';
862
+ } | {
863
+ op: 'list';
864
+ } | {
865
+ op: 'register';
866
+ root: string;
867
+ label?: string;
868
+ role?: 'primary' | 'member';
869
+ } | {
870
+ op: 'unregister';
871
+ root: string;
872
+ } | {
873
+ op: 'register-federation';
874
+ primaryRoot: string;
875
+ members: Array<{
876
+ root: string;
877
+ label?: string;
878
+ role?: 'primary' | 'member';
879
+ }>;
880
+ } | {
881
+ op: 'list-graph-slots';
882
+ repositoryId?: string;
883
+ } | {
884
+ op: 'select-git-ref';
885
+ repositoryId: string;
886
+ gitRef: string;
887
+ } | {
888
+ op: 'put-graph';
889
+ repositoryId: string;
890
+ gitRef: string;
891
+ graph: unknown;
892
+ }
893
+ /**
894
+ * Load the workspace's on-disk code map into ActiveGraph inside the daemon
895
+ * (binary snapshot first, JSON fallback). The fast-path alternative to
896
+ * shipping the whole graph over the socket with put-graph — use it whenever
897
+ * the map already exists on disk.
898
+ */
899
+ | {
900
+ op: 'load-graph';
901
+ root: string;
902
+ gitRef?: string;
903
+ graphPath?: string;
904
+ }
905
+ /** Lexical/structural query against the ActiveGraph for a repository. */
906
+ | {
907
+ op: 'query-graph';
908
+ repositoryId: string;
909
+ query: string;
910
+ limit?: number;
911
+ gitRef?: string;
912
+ semantic?: boolean;
913
+ }
914
+ /** Blast-radius impact for a symbol id or qualified name. */
915
+ | {
916
+ op: 'impact-of';
917
+ repositoryId: string;
918
+ symbol: string;
919
+ depth?: number;
920
+ gitRef?: string;
921
+ }
922
+ /** Compact graph meta for the current (or named) slot — not the full graph. */
923
+ | {
924
+ op: 'graph-summary';
925
+ repositoryId: string;
926
+ gitRef?: string;
927
+ }
928
+ /** Semantic warm (docs/VGD-SEMANTIC-WARM-SPEC.md): worker + per-slot index state. */
929
+ | {
930
+ op: 'embed-status';
931
+ repositoryId?: string;
932
+ }
933
+ /** Embed one string in the daemon's warm worker; the caller ranks locally. */
934
+ | {
935
+ op: 'embed-query';
936
+ text: string;
937
+ }
938
+ /** Ensure the slot's vector index exists, building it if needed. */
939
+ | {
940
+ op: 'embed-index';
941
+ repositoryId: string;
942
+ gitRef?: string;
943
+ wait?: boolean;
944
+ } | {
945
+ op: 'embed-rank';
946
+ repositoryId: string;
947
+ gitRef?: string;
948
+ text: string;
949
+ limit?: number;
950
+ } | {
951
+ op: 'dep-context';
952
+ repositoryId: string;
953
+ }
954
+ /**
955
+ * Hold this connection open and stream slot changes on it. The only op that
956
+ * does not answer once and stop — everything else is request/response.
957
+ */
958
+ | {
959
+ op: 'watch-slots';
960
+ repositoryId?: string;
961
+ }
962
+ /** Approach B host broker: warm model status inside vgd. */
963
+ | {
964
+ op: 'host-status';
965
+ } | {
966
+ op: 'host-load';
967
+ modelPath: string;
968
+ } | {
969
+ op: 'host-unload';
970
+ modelPath?: string;
971
+ } | {
972
+ op: 'host-generate';
973
+ modelPath: string;
974
+ messages: Array<{
975
+ role: string;
976
+ content: string;
977
+ }>;
978
+ grammar?: string;
979
+ requireGrammar?: boolean;
980
+ maxTokens?: number;
981
+ temperature?: number;
982
+ };
983
+ /** Semantic warm state: the worker, and one row per resident slot index. */
984
+ interface EmbedStatusPayload {
985
+ worker: 'stopped' | 'starting' | 'ready' | 'unavailable';
986
+ pid?: number;
987
+ model?: string;
988
+ crashes: number;
989
+ reason?: string;
990
+ slots: Array<{
991
+ repositoryId: string;
992
+ gitRef: string;
993
+ state: string;
994
+ vectors: number;
995
+ nodeCount: number;
996
+ /** Targets still missing a vector on a slot that is not ready. */
997
+ pending?: number;
998
+ builtAt?: number;
999
+ buildMs?: number;
1000
+ error?: string;
1001
+ }>;
1002
+ }
1003
+ /** Compact match row for query-graph (no full node payloads). */
1004
+ interface VgdQueryMatch {
1005
+ id: string;
1006
+ qualifiedName: string;
1007
+ kind: string;
1008
+ file: string;
1009
+ line: number;
1010
+ score: number;
1011
+ why: string;
1012
+ }
1013
+ interface VgdImpactItem {
1014
+ id: string;
1015
+ name: string;
1016
+ kind: string;
1017
+ file: string;
1018
+ line: number;
1019
+ depth: number;
1020
+ confidence: number;
1021
+ }
1022
+ type VgdResponse = {
1023
+ ok: true;
1024
+ pong: true;
1025
+ version: typeof VGD_PROTOCOL_VERSION;
1026
+ } | {
1027
+ ok: true;
1028
+ pid: number;
1029
+ uptimeMs: number;
1030
+ workspaces: number;
1031
+ /** Resident multi-branch ActiveGraph slots (Fusion §4.1.1). */
1032
+ graphSlots?: number;
1033
+ version: typeof VGD_PROTOCOL_VERSION;
1034
+ socketPath: string;
1035
+ /** Calendar version of the CLI process serving this socket. */
1036
+ cliVersion?: string;
1037
+ /** What the daemon is watching, and what it is mid-rebuild on. */
1038
+ freshness?: Array<{
1039
+ repositoryId: string;
1040
+ root: string;
1041
+ gitRef: string;
1042
+ watching: boolean;
1043
+ pending: number;
1044
+ building: boolean;
1045
+ lastRebuildAt?: number;
1046
+ }>;
1047
+ } | {
1048
+ ok: true;
1049
+ workspaces: WorkspaceRecord[];
1050
+ } | {
1051
+ ok: true;
1052
+ workspace: WorkspaceRecord;
1053
+ } | {
1054
+ ok: true;
1055
+ workspaces: WorkspaceRecord[];
1056
+ federation: true;
1057
+ } | {
1058
+ ok: true;
1059
+ removed: boolean;
1060
+ } | {
1061
+ ok: true;
1062
+ stopping: true;
1063
+ } | {
1064
+ ok: true;
1065
+ slots: GraphSlotSummary[];
1066
+ } | {
1067
+ ok: true;
1068
+ watching: true;
1069
+ repositoryId?: string;
1070
+ }
1071
+ /**
1072
+ * An unsolicited frame on a `watch-slots` connection: this repo's map
1073
+ * changed and the subscriber should reload it. Carries the corpus hash so a
1074
+ * subscriber that already has that map can ignore the event.
1075
+ */
1076
+ | {
1077
+ ok: true;
1078
+ event: 'slot-changed';
1079
+ repositoryId: string;
1080
+ gitRef: string;
1081
+ nodeCount: number;
1082
+ corpusHash: string | null;
1083
+ } | {
1084
+ ok: true;
1085
+ semantic: EmbedStatusPayload;
1086
+ } | {
1087
+ ok: true;
1088
+ repositoryId: string;
1089
+ /** Digest of every manifest and lockfile in the tree. */
1090
+ manifestHash: string;
1091
+ /** Declared/installed dependency records, as `engine/drift.ts` builds them. */
1092
+ dependencies: Array<{
1093
+ name: string;
1094
+ ecosystem: string;
1095
+ declared: string;
1096
+ installed?: string;
1097
+ }>;
1098
+ builtAt: number;
1099
+ } | {
1100
+ ok: true;
1101
+ vector: number[];
1102
+ model?: string;
1103
+ } | {
1104
+ ok: true;
1105
+ ranked: Array<{
1106
+ id: string;
1107
+ score: number;
1108
+ }>;
1109
+ repositoryId: string;
1110
+ gitRef: string;
1111
+ state: string;
1112
+ vectors: number;
1113
+ model?: string;
1114
+ rankMs: number;
1115
+ } | {
1116
+ ok: true;
1117
+ indexed: true;
1118
+ repositoryId: string;
1119
+ gitRef: string;
1120
+ state: string;
1121
+ vectors: number;
1122
+ buildMs?: number;
1123
+ } | {
1124
+ ok: true;
1125
+ selected: true;
1126
+ repositoryId: string;
1127
+ gitRef: string;
1128
+ } | {
1129
+ ok: true;
1130
+ stored: true;
1131
+ repositoryId: string;
1132
+ gitRef: string;
1133
+ nodeCount: number;
1134
+ } | {
1135
+ ok: true;
1136
+ query: string;
1137
+ repositoryId: string;
1138
+ gitRef: string;
1139
+ /** How the ranking was produced — `lexical` when semantic was not available. */
1140
+ mode?: string;
1141
+ matches: VgdQueryMatch[];
1142
+ tokensEstimate: number;
1143
+ } | {
1144
+ ok: true;
1145
+ repositoryId: string;
1146
+ gitRef: string;
1147
+ symbol: string;
1148
+ root: {
1149
+ id: string;
1150
+ name: string;
1151
+ };
1152
+ depth: number;
1153
+ affected: VgdImpactItem[];
1154
+ direct: number;
1155
+ transitive: number;
1156
+ } | {
1157
+ ok: true;
1158
+ repositoryId: string;
1159
+ gitRef: string;
1160
+ summary: {
1161
+ nodeCount: number;
1162
+ edgeCount: number;
1163
+ languages: string[];
1164
+ corpusHash: string | null;
1165
+ root: string | null;
1166
+ };
1167
+ } | {
1168
+ ok: true;
1169
+ host: {
1170
+ poolSize: number;
1171
+ loadedModels: string[];
1172
+ bindingReady: boolean;
1173
+ };
1174
+ } | {
1175
+ ok: true;
1176
+ hostLoaded: true;
1177
+ modelPath: string;
1178
+ } | {
1179
+ ok: true;
1180
+ hostUnloaded: true;
1181
+ cleared: number;
1182
+ } | {
1183
+ ok: true;
1184
+ hostGenerated: true;
1185
+ text: string;
1186
+ model: string;
1187
+ constrained: boolean;
1188
+ grammarApplied?: boolean;
1189
+ draftAcceptedChars?: number;
1190
+ latencyMs?: number;
1191
+ unknownIdentifiers?: string[];
1192
+ } | {
1193
+ ok: false;
1194
+ error: string;
1195
+ code?: string;
1196
+ /** Present when `code` is `semantic_warming` so the client can show progress. */
1197
+ state?: string;
1198
+ vectors?: number;
1199
+ pending?: number;
1200
+ nodeCount?: number;
1201
+ };
1202
+
1203
+ interface VgdClientOptions {
1204
+ socketPath?: string;
1205
+ /** End-to-end response timeout in ms (default: per-op, see {@link defaultVgdTimeoutMs}). */
1206
+ timeoutMs?: number;
1207
+ }
1208
+ /**
1209
+ * Send one request to a running vgd and return the parsed response.
1210
+ * Rejects if the daemon is not reachable.
1211
+ */
1212
+ declare function vgdRequest(request: VgdRequest, options?: VgdClientOptions): Promise<VgdResponse>;
1213
+ /** True when a local vgd answers ping. */
1214
+ declare function vgdIsRunning(options?: VgdClientOptions): Promise<boolean>;
1215
+
1216
+ type VgdPublishOutcome = {
1217
+ status: 'not-running';
1218
+ } | {
1219
+ status: 'failed';
1220
+ error: string;
1221
+ }
1222
+ /** The daemon already holds this exact map — nothing was sent. */
1223
+ | {
1224
+ status: 'current';
1225
+ repositoryId: string;
1226
+ gitRef: string;
1227
+ } | {
1228
+ status: 'published';
1229
+ repositoryId: string;
1230
+ gitRef: string;
1231
+ nodeCount: number;
1232
+ semantic?: string;
1233
+ };
1234
+
1235
+ /**
1236
+ * The one way an ordinary command joins the local runtime.
1237
+ *
1238
+ * Until now vgd only ever existed because `vg code` or the VS Code extension
1239
+ * started it, so a developer running `vg`, `vg build` and `vg ask` all day
1240
+ * never had a runtime at all — every invocation re-read the map and re-loaded
1241
+ * the embedder from cold. Auto-start makes the daemon the normal case, and
1242
+ * publishing on attach makes it hold the thing it is supposed to accelerate.
1243
+ *
1244
+ * Three rules keep this safe to put in front of every command:
1245
+ *
1246
+ * - **Never blocking.** `ensureVgdSoft` spawns and waits ~1.5s, not the 30s
1247
+ * `vg daemon ensure` waits. A daemon that is still coming up simply is not
1248
+ * used this time; the command runs its in-process path and finds a warm
1249
+ * runtime on the next call.
1250
+ * - **Never fatal.** Every outcome is a value, never a throw. "No daemon" is a
1251
+ * supported configuration, and it must stay one — the fallbacks are the
1252
+ * code paths that exist today.
1253
+ * - **Always escapable.** `--no-daemon`, `VG_NO_DAEMON=1`, and `CI` all turn
1254
+ * auto-start off. A one-shot CI job should not leave a background process
1255
+ * behind, and a user who does not want one must be able to say so once.
1256
+ */
1257
+ type AttachStatus = 'attached' | 'disabled' | 'unavailable';
1258
+ interface AttachResult {
1259
+ status: AttachStatus;
1260
+ /** Why, when not attached — safe to show verbatim. */
1261
+ reason?: string;
1262
+ /** True when this call is what started the daemon. */
1263
+ started?: boolean;
1264
+ socketPath?: string;
1265
+ repositoryId?: string;
1266
+ gitRef?: string;
1267
+ /** Outcome of the map publish, when one was requested. */
1268
+ published?: VgdPublishOutcome;
1269
+ }
1270
+ interface AttachOptions {
1271
+ socketPath?: string;
1272
+ /** Spawn a daemon when none is listening (default true). */
1273
+ autoStart?: boolean;
1274
+ /** How long to wait for a just-spawned daemon before giving up (default 1500ms). */
1275
+ readyBudgetMs?: number;
1276
+ /** Publish this repo's map after attaching (default true). */
1277
+ publish?: boolean;
1278
+ /**
1279
+ * The corpus hash of the map the caller already holds. When the daemon's
1280
+ * slot reports the same hash the publish is skipped entirely.
1281
+ *
1282
+ * This matters more than it looks: `load-graph` runs the registry's slot
1283
+ * funnel, and `onGraphPut` deliberately drops the slot's vectors — so
1284
+ * re-publishing an unchanged map on every `vg ask` invalidated and re-seeded
1285
+ * the semantic index once per command, for nothing.
1286
+ */
1287
+ corpusHash?: string;
1288
+ /** Also wait for the slot's semantic index (default false — warming is background work). */
1289
+ warmSemantic?: boolean;
1290
+ gitRef?: string;
1291
+ /** Custom `--graph` artifact path. */
1292
+ graphPath?: string;
1293
+ /** Explicit opt-out from the caller's parsed flags (`--no-daemon`). */
1294
+ disabled?: boolean;
1295
+ /** Injected (tests). */
1296
+ isRunning?: typeof vgdIsRunning;
1297
+ request?: typeof vgdRequest;
1298
+ ensure?: (socketPath: string, readyBudgetMs: number) => Promise<{
1299
+ running: boolean;
1300
+ started: boolean;
1301
+ }>;
1302
+ env?: NodeJS.ProcessEnv;
1303
+ }
1304
+ /**
1305
+ * Ensure a local vgd is running and knows about this repository's map.
1306
+ * Resolves to a description of what happened; never throws.
1307
+ */
1308
+ declare function attachVgd(root: string, options?: AttachOptions): Promise<AttachResult>;
1309
+
1310
+ /**
1311
+ * One way to ask the daemon for a semantic ranking, shared by every surface.
1312
+ *
1313
+ * `vg ask`, `vg serve` and `vg lsp` each grew their own copy of "load the
1314
+ * embedder, embed the corpus, rank" — and `engine/refresh-scheduler.ts` records
1315
+ * what that costs: the per-server copies diverged, and one of them blocked an
1316
+ * editor Ask for ninety seconds. This is the single implementation of the
1317
+ * daemon path so that cannot happen again.
1318
+ *
1319
+ * Long-lived callers (the MCP server, the language server) hold one of these
1320
+ * for the process: it attaches once, remembers the slot, and per request sends
1321
+ * only the question. Short-lived callers get the same behaviour with the attach
1322
+ * folded into the first call.
1323
+ *
1324
+ * Every failure resolves to `null`, never a throw. `null` means "rank it
1325
+ * yourself" — the in-process path each caller already has, which is also what
1326
+ * happens when no daemon is running at all.
1327
+ */
1328
+ interface DaemonRanking {
1329
+ ranked: Array<{
1330
+ id: string;
1331
+ score: number;
1332
+ }>;
1333
+ /** How many vectors the slot holds — for logging, not correctness. */
1334
+ vectors: number;
1335
+ model?: string;
1336
+ }
1337
+ interface SemanticProgress {
1338
+ state: string;
1339
+ vectors: number;
1340
+ pending?: number;
1341
+ nodeCount?: number;
1342
+ model?: string;
1343
+ /** One line for a live status spinner. */
1344
+ detail: string;
1345
+ }
1346
+ interface RankWaitOptions {
1347
+ /** Called whenever the slot's status is sampled during a wait. */
1348
+ onProgress?: (status: SemanticProgress) => void;
1349
+ /** How often to poll `embed-status` while the index is warming (default 300ms). */
1350
+ pollMs?: number;
1351
+ /** Give up waiting and return null (default 10 minutes). */
1352
+ timeoutMs?: number;
1353
+ now?: () => number;
1354
+ sleep?: (ms: number) => Promise<void>;
1355
+ }
1356
+ interface SemanticSessionOptions extends Omit<AttachOptions, 'corpusHash'> {
1357
+ /** How long to wait before retrying after a failed attach (default 30s). */
1358
+ retryAfterMs?: number;
1359
+ now?: () => number;
1360
+ /** Injected (tests). */
1361
+ attach?: typeof attachVgd;
1362
+ request?: typeof vgdRequest;
1363
+ }
1364
+ declare class DaemonSemanticSession {
1365
+ private repositoryId;
1366
+ private gitRef;
1367
+ private socketPath;
1368
+ /** The map the daemon was last told about, so an unchanged one is not resent. */
1369
+ private publishedHash;
1370
+ /** Do not re-attach before this time — a down daemon must not cost every request. */
1371
+ private retryAfter;
1372
+ private attaching;
1373
+ private readonly root;
1374
+ private readonly options;
1375
+ private readonly retryAfterMs;
1376
+ private readonly now;
1377
+ private readonly attachImpl;
1378
+ private readonly requestImpl;
1379
+ constructor(root: string, options?: SemanticSessionOptions);
1380
+ /** True once a slot is known — useful for a one-line status log. */
1381
+ get attached(): boolean;
1382
+ /**
1383
+ * Rank `question` against the daemon's index for this repo.
1384
+ * `corpusHash` is the caller's current map: when it differs from what the
1385
+ * daemon holds, the map is republished before ranking, so a locally
1386
+ * refreshed map never ranks against yesterday's vectors.
1387
+ */
1388
+ rank(question: string, corpusHash?: string, wait?: RankWaitOptions): Promise<DaemonRanking | null>;
1389
+ private readProgress;
1390
+ private requestRank;
1391
+ /**
1392
+ * The daemon's shared dependency context for this repo — the manifest digest
1393
+ * and the dependency records — computed once per daemon instead of once per
1394
+ * process. Null whenever the daemon cannot answer, so the caller falls back
1395
+ * to computing it locally.
1396
+ */
1397
+ depContext(): Promise<{
1398
+ manifestHash: string;
1399
+ dependencies: Array<{
1400
+ name: string;
1401
+ ecosystem: string;
1402
+ declared: string;
1403
+ installed?: string;
1404
+ }>;
1405
+ } | null>;
1406
+ private reset;
1407
+ /** Attach once; concurrent callers share the one attempt. */
1408
+ private ensureAttached;
1409
+ }
1410
+
805
1411
  /**
806
1412
  * The read-only tool set for the LOCAL `vg serve` MCP. Every tool is
807
1413
  * side-effect-free and `readOnlyHint: true` (auto-approvable), and independent of
@@ -824,6 +1430,12 @@ interface ToolContext {
824
1430
  seen?: Set<string>;
825
1431
  /** Path the served graph was loaded from (locates its tags sidecar). */
826
1432
  graphPath?: string;
1433
+ /**
1434
+ * The local runtime's semantic index, when one is reachable. Held for the
1435
+ * life of the server: attaching once and sending only the question per call
1436
+ * is what removes this process's own model load and vector scan.
1437
+ */
1438
+ semanticSession?: DaemonSemanticSession;
827
1439
  }
828
1440
  interface VgTool {
829
1441
  name: string;
@@ -1121,6 +1733,8 @@ interface ServeOptions {
1121
1733
  dedup?: boolean;
1122
1734
  /** Auto-refresh the map when the working tree drifts (default true). */
1123
1735
  refresh?: boolean;
1736
+ /** `--no-daemon`: never auto-start or use the local runtime. */
1737
+ daemon?: boolean;
1124
1738
  /**
1125
1739
  * Event-driven refresh: recursive fs.watch on the workspace so a save
1126
1740
  * rebuilds in ~400 ms instead of waiting out the freshness poll (default
@@ -1152,6 +1766,12 @@ declare class GraphSource {
1152
1766
  /** Timing / root overrides (production passes `root`; tests may pass more). */
1153
1767
  private readonly tuning;
1154
1768
  private cachedMtimeMs;
1769
+ /**
1770
+ * True while the daemon owns freshness for this workspace. Set only after
1771
+ * the daemon confirms a subscription, cleared the instant it drops — so the
1772
+ * failure mode is "this process watches again", never "nobody watches".
1773
+ */
1774
+ private daemonOwnsFreshness;
1155
1775
  private cached;
1156
1776
  /** Project root used for freshness probes and rebuilds. */
1157
1777
  readonly root: string;
@@ -1170,6 +1790,15 @@ declare class GraphSource {
1170
1790
  constructor(graphPath: string, refresh?: boolean,
1171
1791
  /** Timing / root overrides (production passes `root`; tests may pass more). */
1172
1792
  tuning?: GraphSourceTuning);
1793
+ /**
1794
+ * Hand freshness to the daemon: stop probing on every call and stop watching.
1795
+ * The daemon pushes `slot-changed` and we reload from disk then.
1796
+ */
1797
+ deferFreshnessToDaemon(): void;
1798
+ /** The daemon went away — resume owning freshness locally. */
1799
+ resumeLocalFreshness(): void;
1800
+ /** The daemon says the map moved; drop the cache so the next get() re-reads. */
1801
+ reloadFromDisk(): void;
1173
1802
  /** Current graph: auto-refreshed if the tree drifted, reloaded if the file changed. */
1174
1803
  get(): Promise<VgGraph>;
1175
1804
  /**
@@ -1411,7 +2040,7 @@ interface DriftNote {
1411
2040
  installed?: string;
1412
2041
  drift: 'current' | 'behind' | 'ahead' | 'unknown';
1413
2042
  }
1414
- declare function driftFor(root: string, entry: LibEntry): DriftNote;
2043
+ declare function driftFor(root: string, entry: LibEntry, inv?: DriftInventory): DriftNote;
1415
2044
  interface AddOptions {
1416
2045
  root: string;
1417
2046
  name?: string;