@vibgrate/cli 2026.819.3 → 2026.825.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.
Files changed (107) hide show
  1. package/dist/{agent-AFMDB4GM.js → agent-IHNUBFBM.js} +13 -12
  2. package/dist/{agent-AFMDB4GM.js.map → agent-IHNUBFBM.js.map} +1 -1
  3. package/dist/{approvals-F2DJGPU7.js → approvals-HRIMDIX3.js} +5 -5
  4. package/dist/{approvals-F2DJGPU7.js.map → approvals-HRIMDIX3.js.map} +1 -1
  5. package/dist/{attach-XTX2Q3AD.js → attach-L43JUJ7A.js} +3 -3
  6. package/dist/{attach-XTX2Q3AD.js.map → attach-L43JUJ7A.js.map} +1 -1
  7. package/dist/{baseline-KTE2C3LW.js → baseline-EZQ7SCRT.js} +3 -3
  8. package/dist/{baseline-KTE2C3LW.js.map → baseline-EZQ7SCRT.js.map} +1 -1
  9. package/dist/{chunk-TD4JAEMH.js → chunk-4PCFSRYH.js} +5 -5
  10. package/dist/{chunk-TD4JAEMH.js.map → chunk-4PCFSRYH.js.map} +1 -1
  11. package/dist/{chunk-ARGYMFST.js → chunk-5BFA532E.js} +3 -3
  12. package/dist/{chunk-ARGYMFST.js.map → chunk-5BFA532E.js.map} +1 -1
  13. package/dist/{chunk-UAPA5AHX.js → chunk-6VLOI2ZP.js} +35 -14
  14. package/dist/chunk-6VLOI2ZP.js.map +1 -0
  15. package/dist/{chunk-DMI4BMUL.js → chunk-B5X246UH.js} +3 -3
  16. package/dist/{chunk-DMI4BMUL.js.map → chunk-B5X246UH.js.map} +1 -1
  17. package/dist/{chunk-3XMTRK24.js → chunk-BCK2NIBM.js} +6 -6
  18. package/dist/{chunk-3XMTRK24.js.map → chunk-BCK2NIBM.js.map} +1 -1
  19. package/dist/{chunk-SOAEPTSW.js → chunk-CIC3NY2D.js} +60 -24
  20. package/dist/chunk-CIC3NY2D.js.map +1 -0
  21. package/dist/{chunk-XZDI2N7M.js → chunk-DLNNNESQ.js} +3 -3
  22. package/dist/{chunk-XZDI2N7M.js.map → chunk-DLNNNESQ.js.map} +1 -1
  23. package/dist/{chunk-5R4HYDTC.js → chunk-ECQFRZJI.js} +4 -4
  24. package/dist/{chunk-5R4HYDTC.js.map → chunk-ECQFRZJI.js.map} +1 -1
  25. package/dist/{chunk-C5AOLTQS.js → chunk-FVBN4E5C.js} +53 -463
  26. package/dist/chunk-FVBN4E5C.js.map +1 -0
  27. package/dist/{chunk-UEXDSWKN.js → chunk-GRMZU24V.js} +3 -3
  28. package/dist/{chunk-UEXDSWKN.js.map → chunk-GRMZU24V.js.map} +1 -1
  29. package/dist/{chunk-CEJIX3O7.js → chunk-JSZ46IDG.js} +6 -6
  30. package/dist/{chunk-CEJIX3O7.js.map → chunk-JSZ46IDG.js.map} +1 -1
  31. package/dist/chunk-KFLNWYZG.js +6 -0
  32. package/dist/{chunk-MQJY4EQV.js.map → chunk-KFLNWYZG.js.map} +1 -1
  33. package/dist/{chunk-WI66PODG.js → chunk-L3YEEJ6U.js} +25 -5
  34. package/dist/chunk-L3YEEJ6U.js.map +1 -0
  35. package/dist/{chunk-XAS45W3G.js → chunk-LKJIYGO5.js} +11 -12
  36. package/dist/chunk-LKJIYGO5.js.map +1 -0
  37. package/dist/chunk-LUJ4H4RJ.js +605 -0
  38. package/dist/chunk-LUJ4H4RJ.js.map +1 -0
  39. package/dist/{chunk-5RMME7PT.js → chunk-M7O6IVKN.js} +3 -3
  40. package/dist/{chunk-5RMME7PT.js.map → chunk-M7O6IVKN.js.map} +1 -1
  41. package/dist/{chunk-3SOJZ3VV.js → chunk-QTQRM7HQ.js} +3 -3
  42. package/dist/{chunk-3SOJZ3VV.js.map → chunk-QTQRM7HQ.js.map} +1 -1
  43. package/dist/{chunk-PQISIPYP.js → chunk-RHYRMMN3.js} +3 -3
  44. package/dist/{chunk-PQISIPYP.js.map → chunk-RHYRMMN3.js.map} +1 -1
  45. package/dist/{chunk-HRYF4PWE.js → chunk-S3HMG6BC.js} +3 -3
  46. package/dist/{chunk-HRYF4PWE.js.map → chunk-S3HMG6BC.js.map} +1 -1
  47. package/dist/{chunk-QOU2Q5L4.js → chunk-TLYNLQL2.js} +221 -10
  48. package/dist/chunk-TLYNLQL2.js.map +1 -0
  49. package/dist/{chunk-EXFA7QFC.js → chunk-UUVOA6WD.js} +10 -8
  50. package/dist/chunk-UUVOA6WD.js.map +1 -0
  51. package/dist/{chunk-UP2BR6TV.js → chunk-X34HVFZ6.js} +8 -8
  52. package/dist/{chunk-UP2BR6TV.js.map → chunk-X34HVFZ6.js.map} +1 -1
  53. package/dist/{chunk-HVJHFTIV.js → chunk-Y3X3ORQ3.js} +10 -12
  54. package/dist/chunk-Y3X3ORQ3.js.map +1 -0
  55. package/dist/{chunk-HB3SONYP.js → chunk-YIRDV4YJ.js} +3 -3
  56. package/dist/{chunk-HB3SONYP.js.map → chunk-YIRDV4YJ.js.map} +1 -1
  57. package/dist/chunk-YP243ZKD.js +90 -0
  58. package/dist/chunk-YP243ZKD.js.map +1 -0
  59. package/dist/cli.js +381 -542
  60. package/dist/cli.js.map +1 -1
  61. package/dist/{daemon-VMQKIIYP.js → daemon-WPX2SBVV.js} +9 -9
  62. package/dist/{daemon-VMQKIIYP.js.map → daemon-WPX2SBVV.js.map} +1 -1
  63. package/dist/embed-worker-main.js +3 -3
  64. package/dist/{ensure-map-YIUJWMBK.js → ensure-map-MLI4XCRV.js} +14 -14
  65. package/dist/{ensure-map-YIUJWMBK.js.map → ensure-map-MLI4XCRV.js.map} +1 -1
  66. package/dist/{graph-backend-FDZUY4TR.js → graph-backend-LK5EFQXN.js} +7 -7
  67. package/dist/{graph-backend-FDZUY4TR.js.map → graph-backend-LK5EFQXN.js.map} +1 -1
  68. package/dist/index.d.ts +115 -132
  69. package/dist/index.js +15 -14
  70. package/dist/index.js.map +1 -1
  71. package/dist/{interactive-CS4PGZPK.js → interactive-K446F42I.js} +27 -25
  72. package/dist/interactive-K446F42I.js.map +1 -0
  73. package/dist/load-2FRH37JY.js +11 -0
  74. package/dist/{load-4EY64JJO.js.map → load-2FRH37JY.js.map} +1 -1
  75. package/dist/parse-worker.js +3 -2
  76. package/dist/parse-worker.js.map +1 -1
  77. package/dist/{run-outcome-T7VDBNWB.js → run-outcome-4ETNDPX6.js} +5 -5
  78. package/dist/{run-outcome-T7VDBNWB.js.map → run-outcome-4ETNDPX6.js.map} +1 -1
  79. package/dist/{runtime-session-WZLVADPQ.js → runtime-session-RMSKXFIJ.js} +9 -9
  80. package/dist/{runtime-session-WZLVADPQ.js.map → runtime-session-RMSKXFIJ.js.map} +1 -1
  81. package/dist/{session-VPP2VGUN.js → session-22BGDYWF.js} +8 -8
  82. package/dist/{session-VPP2VGUN.js.map → session-22BGDYWF.js.map} +1 -1
  83. package/dist/{stream-json-XXCFN4MF.js → stream-json-MD7MSSCH.js} +13 -12
  84. package/dist/stream-json-MD7MSSCH.js.map +1 -0
  85. package/dist/version-FRUT6RI2.js +4 -0
  86. package/dist/{version-2UBJ7N2I.js.map → version-FRUT6RI2.js.map} +1 -1
  87. package/dist/{vg-mcp-bridge-H6GXYNKV.js → vg-mcp-bridge-H6I3ALUW.js} +8 -8
  88. package/dist/{vg-mcp-bridge-H6GXYNKV.js.map → vg-mcp-bridge-H6I3ALUW.js.map} +1 -1
  89. package/dist/{vgd-SBZO4ONQ.js → vgd-TW7HU2PH.js} +8 -8
  90. package/dist/vgd-TW7HU2PH.js.map +1 -0
  91. package/package.json +2 -4
  92. package/dist/chunk-C5AOLTQS.js.map +0 -1
  93. package/dist/chunk-EXFA7QFC.js.map +0 -1
  94. package/dist/chunk-HVJHFTIV.js.map +0 -1
  95. package/dist/chunk-MQJY4EQV.js +0 -6
  96. package/dist/chunk-QOU2Q5L4.js.map +0 -1
  97. package/dist/chunk-SOAEPTSW.js.map +0 -1
  98. package/dist/chunk-UAPA5AHX.js.map +0 -1
  99. package/dist/chunk-VEQA2FSM.js +0 -699
  100. package/dist/chunk-VEQA2FSM.js.map +0 -1
  101. package/dist/chunk-WI66PODG.js.map +0 -1
  102. package/dist/chunk-XAS45W3G.js.map +0 -1
  103. package/dist/interactive-CS4PGZPK.js.map +0 -1
  104. package/dist/load-4EY64JJO.js +0 -11
  105. package/dist/stream-json-XXCFN4MF.js.map +0 -1
  106. package/dist/version-2UBJ7N2I.js +0 -4
  107. package/dist/vgd-SBZO4ONQ.js.map +0 -1
@@ -1,30 +1,31 @@
1
- export { CONTEXT_POLICY_VERSION, DISCOVERY_TOOLS, MUTATION_TOOLS, compact, compactWithModel, runAgent } from './chunk-SOAEPTSW.js';
1
+ export { CONTEXT_POLICY_VERSION, DISCOVERY_TOOLS, MUTATION_TOOLS, compact, compactWithModel, runAgent } from './chunk-CIC3NY2D.js';
2
2
  import './chunk-543E6WDJ.js';
3
- import './chunk-3SOJZ3VV.js';
4
- import './chunk-HB3SONYP.js';
3
+ import './chunk-QTQRM7HQ.js';
4
+ import './chunk-YIRDV4YJ.js';
5
5
  import './chunk-SHD5TCZ5.js';
6
6
  import './chunk-3HNPVXUK.js';
7
7
  import './chunk-5HYCB55P.js';
8
+ import './chunk-YP243ZKD.js';
8
9
  import './chunk-VIWZ4QT7.js';
9
- import './chunk-HRYF4PWE.js';
10
- export { summarizeCapsule } from './chunk-UAPA5AHX.js';
10
+ import './chunk-S3HMG6BC.js';
11
+ export { summarizeCapsule } from './chunk-6VLOI2ZP.js';
11
12
  import './chunk-EZ7UC5Y5.js';
12
13
  import './chunk-6BEBJCK4.js';
13
14
  import './chunk-J7LKEB2R.js';
14
- import './chunk-VEQA2FSM.js';
15
+ import './chunk-LUJ4H4RJ.js';
15
16
  import './chunk-VHRSG6CF.js';
16
17
  import './chunk-6H2QV5DR.js';
17
- import './chunk-WI66PODG.js';
18
+ import './chunk-L3YEEJ6U.js';
18
19
  import './chunk-T7RSQ5WD.js';
19
20
  import './chunk-6WRG7VDO.js';
20
- import './chunk-DMI4BMUL.js';
21
- import './chunk-C5AOLTQS.js';
21
+ import './chunk-B5X246UH.js';
22
+ import './chunk-FVBN4E5C.js';
22
23
  import './chunk-MVPRPSXU.js';
23
24
  import './chunk-O3LABX6I.js';
24
- import './chunk-MQJY4EQV.js';
25
+ import './chunk-KFLNWYZG.js';
25
26
  import './chunk-XP6UUCZZ.js';
26
27
  import './chunk-JFGYT6BI.js';
27
28
  import './chunk-XQNKCA2J.js';
28
29
  import './chunk-Z6ZWNWWR.js';
29
- //# sourceMappingURL=agent-AFMDB4GM.js.map
30
- //# sourceMappingURL=agent-AFMDB4GM.js.map
30
+ //# sourceMappingURL=agent-IHNUBFBM.js.map
31
+ //# sourceMappingURL=agent-IHNUBFBM.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-AFMDB4GM.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-IHNUBFBM.js"}
@@ -1,10 +1,10 @@
1
- export { addApprovalRule, approvalsPath, findMatchingRule, globMatch, loadApprovalRules, normalizeCommandPrefix, removeApprovalRule, ruleForAction, ruleKey, ruleLabel, saveApprovalRules } from './chunk-3SOJZ3VV.js';
2
- import './chunk-C5AOLTQS.js';
1
+ export { addApprovalRule, approvalsPath, findMatchingRule, globMatch, loadApprovalRules, normalizeCommandPrefix, removeApprovalRule, ruleForAction, ruleKey, ruleLabel, saveApprovalRules } from './chunk-QTQRM7HQ.js';
2
+ import './chunk-FVBN4E5C.js';
3
3
  import './chunk-O3LABX6I.js';
4
- import './chunk-MQJY4EQV.js';
4
+ import './chunk-KFLNWYZG.js';
5
5
  import './chunk-XP6UUCZZ.js';
6
6
  import './chunk-JFGYT6BI.js';
7
7
  import './chunk-XQNKCA2J.js';
8
8
  import './chunk-Z6ZWNWWR.js';
9
- //# sourceMappingURL=approvals-F2DJGPU7.js.map
10
- //# sourceMappingURL=approvals-F2DJGPU7.js.map
9
+ //# sourceMappingURL=approvals-HRIMDIX3.js.map
10
+ //# sourceMappingURL=approvals-HRIMDIX3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"approvals-F2DJGPU7.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"approvals-HRIMDIX3.js"}
@@ -1,4 +1,4 @@
1
- export { attachVgd, daemonDisabledReason } from './chunk-UEXDSWKN.js';
1
+ export { attachVgd, daemonDisabledReason } from './chunk-GRMZU24V.js';
2
2
  import './chunk-A3WWRW7U.js';
3
3
  import './chunk-VHRSG6CF.js';
4
4
  import './chunk-6H2QV5DR.js';
@@ -6,5 +6,5 @@ import './chunk-XP6UUCZZ.js';
6
6
  import './chunk-JFGYT6BI.js';
7
7
  import './chunk-XQNKCA2J.js';
8
8
  import './chunk-Z6ZWNWWR.js';
9
- //# sourceMappingURL=attach-XTX2Q3AD.js.map
10
- //# sourceMappingURL=attach-XTX2Q3AD.js.map
9
+ //# sourceMappingURL=attach-L43JUJ7A.js.map
10
+ //# sourceMappingURL=attach-L43JUJ7A.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"attach-XTX2Q3AD.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"attach-L43JUJ7A.js"}
@@ -3,7 +3,7 @@ import './chunk-5UG4UHKU.js';
3
3
  import './chunk-PVNALGTG.js';
4
4
  import './chunk-CRAMOEBE.js';
5
5
  import './chunk-T7RSQ5WD.js';
6
- import './chunk-MQJY4EQV.js';
6
+ import './chunk-KFLNWYZG.js';
7
7
  import './chunk-Z6ZWNWWR.js';
8
- //# sourceMappingURL=baseline-KTE2C3LW.js.map
9
- //# sourceMappingURL=baseline-KTE2C3LW.js.map
8
+ //# sourceMappingURL=baseline-EZQ7SCRT.js.map
9
+ //# sourceMappingURL=baseline-EZQ7SCRT.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"baseline-KTE2C3LW.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"baseline-EZQ7SCRT.js"}
@@ -1,7 +1,7 @@
1
- import { probeFreshness, hasDrift, buildGraph, writeSnapshot } from './chunk-EXFA7QFC.js';
1
+ import { probeFreshness, hasDrift, buildGraph, writeSnapshot } from './chunk-UUVOA6WD.js';
2
2
  import { mergeExcludes } from './chunk-RTURQXQL.js';
3
- import { acquireLock, releaseLock } from './chunk-DMI4BMUL.js';
4
- import { vibgrateDir, writeArtifacts } from './chunk-C5AOLTQS.js';
3
+ import { acquireLock, releaseLock } from './chunk-B5X246UH.js';
4
+ import { vibgrateDir, writeArtifacts } from './chunk-FVBN4E5C.js';
5
5
  import { cacheDir } from './chunk-MVPRPSXU.js';
6
6
  import * as fs from 'fs';
7
7
  import * as path from 'path';
@@ -63,5 +63,5 @@ async function refreshIfStale(root, opts = {}) {
63
63
  }
64
64
 
65
65
  export { refreshIfStale };
66
- //# sourceMappingURL=chunk-TD4JAEMH.js.map
67
- //# sourceMappingURL=chunk-TD4JAEMH.js.map
66
+ //# sourceMappingURL=chunk-4PCFSRYH.js.map
67
+ //# sourceMappingURL=chunk-4PCFSRYH.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/engine/refresh.ts"],"names":[],"mappings":";;;;;;;;AAuDA,IAAM,qBAAA,GAAwB,KAAK,EAAA,GAAK,GAAA;AAExC,SAAS,gBAAgB,IAAA,EAAsB;AAC7C,EAAA,OAAY,IAAA,CAAA,IAAA,CAAK,QAAA,CAAS,IAAI,CAAA,EAAG,cAAc,CAAA;AACjD;AAMA,eAAsB,cAAA,CAAe,IAAA,EAAc,IAAA,GAAuB,EAAC,EAA4B;AACrG,EAAA,MAAM,KAAA,GAAQ,eAAe,IAAI,CAAA;AACjC,EAAA,IAAI,CAAC,KAAA,EAAO,OAAO,EAAE,QAAQ,aAAA,EAAc;AAC3C,EAAA,IAAI,CAAC,SAAS,KAAA,CAAM,KAAK,GAAG,OAAO,EAAE,QAAQ,OAAA,EAAQ;AAErD,EAAA,MAAM,IAAA,GAAO,gBAAgB,IAAI,CAAA;AACjC,EAAA,IAAI,CAAC,YAAY,IAAA,EAAM,q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,IACH;AACA,IAAA,aAAA,CAAc,IAAA,EAAM,MAAA,CAAO,KAAA,CAAM,UAAA,CAAW,UAAA,EAAY,MAAA,CAAO,SAAA,EAAW,EAAE,GAAG,KAAA,EAAO,OAAA,EAAS,CAAA;AAE/F,IAAA,MAAM,KAAK,MAAA,CAAA,CAAQ,OAAA,CAAQ,OAAO,MAAA,EAAO,GAAI,SAAS,QAAQ,CAAA;AAC9D,IAAA,OAAO;AAAA,MACL,MAAA,EAAQ,WAAA;AAAA,MACR,OAAO,KAAA,CAAM,KAAA;AAAA,MACb,EAAA;AAAA,MACA,UAAU,MAAA,CAAO,QAAA;AAAA,MACjB,YAAY,MAAA,CAAO,UAAA;AAAA,MACnB;AAAA,KACF;AAAA,EACF,SAAS,GAAA,EAAK;AACZ,IAAA,OAAO,EAAE,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAU,IAAc,OAAA,EAAQ;AAAA,EAC5D,CAAA,SAAE;AACA,IAAA,WAAA,CAAY,IAAI,CAAA;AAAA,EAClB;AACF","file":"chunk-TD4JAEMH.js","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { buildGraph } from './build.js';\nimport { mergeExcludes } from './discover.js';\nimport { probeFreshness, writeSnapshot, hasDrift, type Drift } from './freshness.js';\nimport { writeArtifacts, vibgrateDir } from './artifacts.js';\nimport { acquireLock, releaseLock } from './lock.js';\nimport { cacheDir } from './cache.js';\nimport type { ClusterMode } from './analyze.js';\n\n/**\n * Auto-refresh: bring the code map back in sync with the working tree when the\n * freshness probe says it drifted. The rebuild is the ordinary incremental\n * `buildGraph` (warm parse cache → only changed files re-parse), replaying the\n * scope recorded at the last explicit build, guarded by a cross-process lock\n * so a serving MCP process and a foreground command never write at once.\n *\n * Two properties keep this safe to run implicitly:\n * - **No git churn**: if the rebuilt corpusHash equals the snapshot's (e.g. a\n * drift that reverted itself), `graph.json` is left untouched — the artifact\n * stays byte-identical.\n * - **No surprise artifacts**: `GRAPH_REPORT.md`/`graph.html` are rewritten\n * only if they already exist; a refresh never adds files a user's explicit\n * build chose not to produce.\n */\n\nexport interface RefreshOptions {\n /** Force single-threaded parsing (tests / constrained hosts). */\n inline?: boolean;\n /** Worker count for the parse pool. */\n jobs?: number;\n /**\n * The map path already resolved by the caller (e.g. `vg serve`'s startup\n * resolution). Passed straight through to `writeArtifacts` so a refresh\n * never re-resolves it: `defaultGraphPath` shells out to `git rev-parse`\n * (Fusion §4.1.1 branch keying), and re-running that on every drift-driven\n * refresh put a synchronous git spawn back on the hot tool-call path this\n * function exists to keep off of. Omit only when no caller-known path\n * exists (falls back to a fresh `defaultGraphPath` resolution).\n */\n graphPath?: string;\n}\n\nexport type RefreshOutcome =\n /** Map already matches the working tree. */\n | { status: 'fresh' }\n /** No freshness snapshot — no build ever ran here, so scope is unknown. */\n | { status: 'no-snapshot' }\n /** Another vg process is rebuilding right now; its write will land shortly. */\n | { status: 'locked' }\n /** Rebuilt. `wrote` is false when the corpus turned out unchanged. */\n | { status: 'refreshed'; drift: Drift; ms: number; reparsed: number; totalFiles: number; wrote: boolean }\n | { status: 'error'; message: string };\n\n/** A refresh stuck longer than this is presumed crashed and its lock reclaimed. */\nconst REFRESH_LOCK_STALE_MS = 10 * 60 * 1000;\n\nfunction refreshLockPath(root: string): string {\n return path.join(cacheDir(root), 'refresh.lock');\n}\n\n/**\n * Probe, and rebuild incrementally if the tree drifted from the map.\n * Silent (no output) — callers own the messaging for their surface.\n */\nexport async function refreshIfStale(root: string, opts: RefreshOptions = {}): Promise<RefreshOutcome> {\n const probe = probeFreshness(root);\n if (!probe) return { status: 'no-snapshot' };\n if (!hasDrift(probe.drift)) return { status: 'fresh' };\n\n const lock = refreshLockPath(root);\n if (!acquireLock(lock, REFRESH_LOCK_STALE_MS)) return { status: 'locked' };\n\n const start = process.hrtime.bigint();\n try {\n const { scope } = probe;\n const exclude = mergeExcludes(root, scope.exclude);\n const result = await buildGraph({\n root,\n only: scope.only,\n exclude,\n paths: scope.paths,\n deep: scope.deep,\n noGround: scope.noGround,\n scip: scope.scip,\n noScip: scope.noScip,\n noTsc: scope.noTsc,\n cluster: scope.cluster as ClusterMode | undefined,\n grammarsDir: scope.grammarsDir,\n inline: opts.inline,\n jobs: opts.jobs,\n });\n\n const wrote = result.graph.provenance.corpusHash !== probe.corpusHash;\n if (wrote) {\n const dir = vibgrateDir(root);\n writeArtifacts(result.graph, {\n root,\n graphPath: opts.graphPath,\n report: fs.existsSync(path.join(dir, 'GRAPH_REPORT.md')),\n html: fs.existsSync(path.join(dir, 'graph.html')),\n });\n }\n writeSnapshot(root, result.graph.provenance.corpusHash, result.fileStats, { ...scope, exclude });\n\n const ms = Number((process.hrtime.bigint() - start) / 1000000n);\n return {\n status: 'refreshed',\n drift: probe.drift,\n ms,\n reparsed: result.reparsed,\n totalFiles: result.totalFiles,\n wrote,\n };\n } catch (err) {\n return { status: 'error', message: (err as Error).message };\n } finally {\n releaseLock(lock);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/engine/refresh.ts"],"names":[],"mappings":";;;;;;;;AAuDA,IAAM,qBAAA,GAAwB,KAAK,EAAA,GAAK,GAAA;AAExC,SAAS,gBAAgB,IAAA,EAAsB;AAC7C,EAAA,OAAY,IAAA,CAAA,IAAA,CAAK,QAAA,CAAS,IAAI,CAAA,EAAG,cAAc,CAAA;AACjD;AAMA,eAAsB,cAAA,CAAe,IAAA,EAAc,IAAA,GAAuB,EAAC,EAA4B;AACrG,EAAA,MAAM,KAAA,GAAQ,eAAe,IAAI,CAAA;AACjC,EAAA,IAAI,CAAC,KAAA,EAAO,OAAO,EAAE,QAAQ,aAAA,EAAc;AAC3C,EAAA,IAAI,CAAC,SAAS,KAAA,CAAM,KAAK,GAAG,OAAO,EAAE,QAAQ,OAAA,EAAQ;AAErD,EAAA,MAAM,IAAA,GAAO,gBAAgB,IAAI,CAAA;AACjC,EAAA,IAAI,CAAC,YAAY,IAAA,EAAM,qBAAqB,GAAG,OAAO,EAAE,QAAQ,QAAA,EAAS;A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,CAAO,KAAA,CAAM,UAAA,CAAW,UAAA,EAAY,MAAA,CAAO,SAAA,EAAW,EAAE,GAAG,KAAA,EAAO,OAAA,EAAS,CAAA;AAE/F,IAAA,MAAM,KAAK,MAAA,CAAA,CAAQ,OAAA,CAAQ,OAAO,MAAA,EAAO,GAAI,SAAS,QAAQ,CAAA;AAC9D,IAAA,OAAO;AAAA,MACL,MAAA,EAAQ,WAAA;AAAA,MACR,OAAO,KAAA,CAAM,KAAA;AAAA,MACb,EAAA;AAAA,MACA,UAAU,MAAA,CAAO,QAAA;AAAA,MACjB,YAAY,MAAA,CAAO,UAAA;AAAA,MACnB;AAAA,KACF;AAAA,EACF,SAAS,GAAA,EAAK;AACZ,IAAA,OAAO,EAAE,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAU,IAAc,OAAA,EAAQ;AAAA,EAC5D,CAAA,SAAE;AACA,IAAA,WAAA,CAAY,IAAI,CAAA;AAAA,EAClB;AACF","file":"chunk-4PCFSRYH.js","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { buildGraph } from './build.js';\nimport { mergeExcludes } from './discover.js';\nimport { probeFreshness, writeSnapshot, hasDrift, type Drift } from './freshness.js';\nimport { writeArtifacts, vibgrateDir } from './artifacts.js';\nimport { acquireLock, releaseLock } from './lock.js';\nimport { cacheDir } from './cache.js';\nimport type { ClusterMode } from './analyze.js';\n\n/**\n * Auto-refresh: bring the code map back in sync with the working tree when the\n * freshness probe says it drifted. The rebuild is the ordinary incremental\n * `buildGraph` (warm parse cache → only changed files re-parse), replaying the\n * scope recorded at the last explicit build, guarded by a cross-process lock\n * so a serving MCP process and a foreground command never write at once.\n *\n * Two properties keep this safe to run implicitly:\n * - **No git churn**: if the rebuilt corpusHash equals the snapshot's (e.g. a\n * drift that reverted itself), `graph.json` is left untouched — the artifact\n * stays byte-identical.\n * - **No surprise artifacts**: `GRAPH_REPORT.md`/`graph.html` are rewritten\n * only if they already exist; a refresh never adds files a user's explicit\n * build chose not to produce.\n */\n\nexport interface RefreshOptions {\n /** Force single-threaded parsing (tests / constrained hosts). */\n inline?: boolean;\n /** Worker count for the parse pool. */\n jobs?: number;\n /**\n * The map path already resolved by the caller (e.g. `vg serve`'s startup\n * resolution). Passed straight through to `writeArtifacts` so a refresh\n * never re-resolves it: `defaultGraphPath` shells out to `git rev-parse`\n * (Fusion §4.1.1 branch keying), and re-running that on every drift-driven\n * refresh put a synchronous git spawn back on the hot tool-call path this\n * function exists to keep off of. Omit only when no caller-known path\n * exists (falls back to a fresh `defaultGraphPath` resolution).\n */\n graphPath?: string;\n}\n\nexport type RefreshOutcome =\n /** Map already matches the working tree. */\n | { status: 'fresh' }\n /** No freshness snapshot — no build ever ran here, so scope is unknown. */\n | { status: 'no-snapshot' }\n /** Another vg process is rebuilding right now; its write will land shortly. */\n | { status: 'locked' }\n /** Rebuilt. `wrote` is false when the corpus turned out unchanged. */\n | { status: 'refreshed'; drift: Drift; ms: number; reparsed: number; totalFiles: number; wrote: boolean }\n | { status: 'error'; message: string };\n\n/** A refresh stuck longer than this is presumed crashed and its lock reclaimed. */\nconst REFRESH_LOCK_STALE_MS = 10 * 60 * 1000;\n\nfunction refreshLockPath(root: string): string {\n return path.join(cacheDir(root), 'refresh.lock');\n}\n\n/**\n * Probe, and rebuild incrementally if the tree drifted from the map.\n * Silent (no output) — callers own the messaging for their surface.\n */\nexport async function refreshIfStale(root: string, opts: RefreshOptions = {}): Promise<RefreshOutcome> {\n const probe = probeFreshness(root);\n if (!probe) return { status: 'no-snapshot' };\n if (!hasDrift(probe.drift)) return { status: 'fresh' };\n\n const lock = refreshLockPath(root);\n if (!acquireLock(lock, REFRESH_LOCK_STALE_MS)) return { status: 'locked' };\n\n const start = process.hrtime.bigint();\n try {\n const { scope } = probe;\n const exclude = mergeExcludes(root, scope.exclude);\n const result = await buildGraph({\n root,\n only: scope.only,\n exclude,\n paths: scope.paths,\n deep: scope.deep,\n noGround: scope.noGround,\n scip: scope.scip,\n noScip: scope.noScip,\n noTsc: scope.noTsc,\n cluster: scope.cluster as ClusterMode | undefined,\n grammarsDir: scope.grammarsDir,\n inline: opts.inline,\n jobs: opts.jobs,\n });\n\n const wrote = result.graph.provenance.corpusHash !== probe.corpusHash;\n if (wrote) {\n const dir = vibgrateDir(root);\n writeArtifacts(result.graph, {\n root,\n graphPath: opts.graphPath,\n report: fs.existsSync(path.join(dir, 'GRAPH_REPORT.md')),\n html: fs.existsSync(path.join(dir, 'graph.html')),\n });\n }\n writeSnapshot(root, result.graph.provenance.corpusHash, result.fileStats, { ...scope, exclude });\n\n const ms = Number((process.hrtime.bigint() - start) / 1000000n);\n return {\n status: 'refreshed',\n drift: probe.drift,\n ms,\n reparsed: result.reparsed,\n totalFiles: result.totalFiles,\n wrote,\n };\n } catch (err) {\n return { status: 'error', message: (err as Error).message };\n } finally {\n releaseLock(lock);\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { loadGraphFileWithSnapshot, resolveGraphPath } from './chunk-C5AOLTQS.js';
1
+ import { loadGraphFileWithSnapshot, resolveGraphPath } from './chunk-FVBN4E5C.js';
2
2
  import { cacheDir } from './chunk-MVPRPSXU.js';
3
3
  import { __require } from './chunk-Z6ZWNWWR.js';
4
4
  import * as fs from 'fs';
@@ -200,5 +200,5 @@ function loadGraph(root, graphPath) {
200
200
  }
201
201
 
202
202
  export { SCHEMA_VERSION, SUPPORTED_SCHEMA_VERSIONS, loadGraph, loadGraphPreferIndex, writeGraphIndex };
203
- //# sourceMappingURL=chunk-ARGYMFST.js.map
204
- //# sourceMappingURL=chunk-ARGYMFST.js.map
203
+ //# sourceMappingURL=chunk-5BFA532E.js.map
204
+ //# sourceMappingURL=chunk-5BFA532E.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schema.ts","../src/engine/index-db.ts","../src/engine/load.ts"],"names":[],"mappings":";;;;;;;AAoBO,IAAM,cAAA,GAAiB;AAQvB,IAAM,yBAAA,GAA4B,CAAC,cAAA,EAAgB,cAAc;;;ACQ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U,MAAc,SAAA,EAAoC;AAC1E,EAAA,MAAM,IAAA,GAAO,gBAAA,CAAiB,IAAA,EAAM,SAAS,CAAA;AAG7C,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,MAAM,SAAA,GAAY,oBAAA,CAAqB,IAAA,EAAM,IAAI,CAAA;AACjD,IAAA,IAAI,SAAA,SAAkB,SAAA,CAAU,KAAA;AAAA,EAClC;AACA,EAAA,OAAO,0BAA0B,IAAI,CAAA;AACvC","file":"chunk-ARGYMFST.js","sourcesContent":["/**\n * The `vg-graph/1.1` on-disk schema.\n *\n * This is vg's own open schema (VG-PACKAGE-AND-SCHEMA.md §4) — informed by good\n * ideas (content-hashed ids, epistemic typing of facts) but standalone and\n * self-contained. Every collection is deterministically serialized\n * (sorted keys, stable element order). These TypeScript shapes are normative.\n *\n * ## Version history\n *\n * - `vg-graph/1.0` — code-only vocabulary.\n * - `vg-graph/1.1` — **additive**: toolchain node kinds (`resource`, `workload`,\n * `job`, `step`, `image`, `chart`) and toolchain edge kinds (`depends_on`,\n * `provisions`, `deploys`, `triggers`, `exposes`, `mounts`, `builds_from`),\n * produced by `engine/toolchain/`. Nothing was removed or renamed, so a 1.0\n * reader that tolerates unknown kinds reads a 1.1 graph correctly; readers\n * that hard-match the version string need widening (see\n * `SUPPORTED_SCHEMA_VERSIONS`).\n */\n\nexport const SCHEMA_VERSION = 'vg-graph/1.1' as const;\n\n/**\n * Schema versions a reader should accept. The toolchain vocabulary added in 1.1\n * is purely additive, so a 1.0 artifact still loads — only the newer kinds are\n * absent from it. Readers must prefer this over an equality check on\n * {@link SCHEMA_VERSION}, which rejects perfectly readable older graphs.\n */\nexport const SUPPORTED_SCHEMA_VERSIONS = ['vg-graph/1.0', 'vg-graph/1.1'] as const;\n\nexport type SupportedSchemaVersion = (typeof SUPPORTED_SCHEMA_VERSIONS)[number];\n\nexport type ResolverKind = 'scip' | 'stackgraph' | 'tsc' | 'heuristic';\n\n/** Coarse, honest resolution tier for an edge (see engine/epistemic.ts). */\nexport type EpistemicTier = 'observed' | 'name-matched' | 'declared';\n\n/**\n * The toolchain that produced this graph — the reproducibility fingerprint.\n * Everything here deterministically affects graph *content* (parse trees change\n * between grammar releases; resolvers change which edges resolve), so a CI run\n * and a laptop run that disagree can be caught by comparing `fingerprint`.\n * Deliberately excludes the Node/OS version so the graph stays byte-stable\n * across host runtimes; `fingerprint` pins the parse/resolve toolchain only.\n */\nexport interface Toolchain {\n schema: string; // SCHEMA_VERSION\n tool: string; // vg calendar version\n grammars: string; // tree-sitter grammar set version string\n resolvers: ResolverKind[]; // resolver kinds available, sorted\n fingerprint: string; // shortId over the fields above — the value `vg attest` signs\n}\n\nexport interface Provenance {\n tool: 'vg';\n version: string; // calendar version\n grammars: Record<string, string>; // lang → grammar version (determinism input)\n resolver: ResolverKind[];\n deep: boolean; // did the heavier open passes run\n semanticModel?: string; // embedding model id+version if --deep semantic links\n corpusHash: string; // blake3 over the included file set + hashes\n toolchain?: Toolchain; // reproducibility fingerprint (checked by `vg verify`)\n}\n\n/** Analysis cost tier — auto-selected by node count (or forced). Reported honestly. */\nexport type AnalysisTier = 'full' | 'large' | 'xl';\n\nexport interface GraphMeta {\n root: string; // relative; portable across machines\n languages: string[];\n counts: {\n nodes: number;\n edges: number;\n areas: number;\n tests: number;\n untested: number;\n };\n cluster: 'leiden' | 'louvain' | 'none';\n /** Auto-selected (or forced) analysis tier for large maps. */\n analysisTier?: AnalysisTier;\n edgeKinds: EdgeKind[];\n}\n\nexport type NodeKind =\n | 'file'\n | 'module'\n | 'package'\n | 'class'\n | 'interface'\n | 'function'\n | 'method'\n | 'property'\n | 'test'\n | 'route'\n | 'component'\n /** Documentation / config text ingested for semantic ask (markdown, txt, env examples). */\n | 'document'\n | 'external'\n // ── Toolchain kinds (engine/toolchain/) ──────────────────────────────────\n // Structural extraction of the infrastructure/CI corpus. These sit alongside\n // the code kinds above and never replace the `document` node for the same\n // file: the document node stays the semantic-ask surface, these carry the\n // structure. Additive — consumers must tolerate unknown kinds.\n /** A declared infrastructure object: Terraform resource/data, K8s object, Compose service. */\n | 'resource'\n /** A deployable unit that runs containers (Deployment, StatefulSet, DaemonSet, Job, CronJob). */\n | 'workload'\n /** A CI job (GitHub Actions job, GitLab CI job). */\n | 'job'\n /** A single step within a CI job. */\n | 'step'\n /** A container image reference (`ghcr.io/acme/web:1.2.3`) or a Dockerfile build stage. */\n | 'image'\n /** A Helm chart (from `Chart.yaml`). */\n | 'chart';\n\nexport interface Span {\n start: number; // 1-based start line\n end: number; // 1-based end line\n}\n\nexport interface Centrality {\n degree: number;\n pagerank: number;\n betweenness: number;\n eigenvector: number;\n}\n\nexport interface GraphNode {\n id: string; // blake3(canonical(kind, qualifiedName, file, signature))\n kind: NodeKind;\n name: string; // short name\n qualifiedName: string;\n file: string; // relative path\n span: Span; // line range (excluded from id hash)\n lang: string;\n visibility?: 'public' | 'private' | 'protected' | 'internal';\n signature?: string;\n doc?: string; // short leading doc-comment / docstring summary (deterministic; not a full body)\n importance: number; // 0..1 blended centrality\n centrality: Centrality;\n area: number; // area id (the node's community); -1 = unassigned (cluster \"none\")\n isHub: boolean; // centrality outlier — surfaced by `vg hubs`\n tested: boolean | null; // null = not analyzable (e.g. external)\n coverage?: number; // 0..1 line coverage if a coverage report was ingested\n changeCoupling?: string[]; // node ids that historically change together\n}\n\nexport type EdgeKind =\n | 'call'\n | 'import'\n | 'contains'\n | 'extends'\n | 'implements'\n | 'references'\n | 'test'\n | 'coverage'\n // ── Toolchain edge kinds (engine/toolchain/) ─────────────────────────────\n // Every edge below is produced by structural extraction or by the\n // cross-domain linker. Linker-produced edges are always\n // `resolution: 'heuristic'` with a calibrated confidence — an inferred\n // `deploys` is not a declared `import` and must never claim to be.\n /** Declared ordering/reference dependency (Terraform `depends_on` + interpolation, Compose `depends_on`, CI `needs`). */\n | 'depends_on'\n /** An IaC declaration creates infrastructure (Terraform module → resource, chart → workload). */\n | 'provisions'\n /** A CI job or IaC declaration puts a workload/image into an environment. */\n | 'deploys'\n /** An event or upstream job causes a workflow/job to run. */\n | 'triggers'\n /** A workload/service publishes a port or endpoint. */\n | 'exposes'\n /** A workload/service consumes a volume, config map, or secret *by reference*. */\n | 'mounts'\n /** A build stage or workload is derived from a container image. */\n | 'builds_from';\n\nexport interface GraphEdge {\n id: string; // blake3(canonical(kind, src, dst))\n kind: EdgeKind;\n src: string; // node id\n dst: string; // node id\n resolution: ResolverKind; // how the edge was resolved\n confidence: number; // 0..1 (1.0 for scip/declared; lower for heuristic/dynamic)\n epistemic?: EpistemicTier; // coarse honesty tier derived from resolution+kind\n surprise?: number; // 0..1 improbability under the area model (`vg oddities`)\n count?: number; // call-site multiplicity\n}\n\nexport interface Area {\n id: number; // stable across runs (remapped to previous committed map)\n label: string; // most-central member's name (editable via `vg label`)\n size: number;\n members: string[]; // node ids, sorted\n cohesion: number; // 0..1\n externalEdges: number; // cross-area edge count\n}\n\nexport type FactKind = 'contract' | 'invariant' | 'characterization';\nexport type DerivedBy = 'declared' | 'static';\nexport type FactConfidence = 'Observed' | 'Derived';\n\nexport interface Fact {\n id: string; // blake3(canonical(kind, subjectIds, predicate))\n kind: FactKind;\n subjectIds: string[]; // node ids this fact constrains\n predicate: unknown; // the constraint\n derivedBy: DerivedBy;\n confidence: FactConfidence;\n evidence: { file: string; span: Span }[];\n}\n\n/**\n * A reference the graph could not resolve — surfaced by `vg unknowns`. Reporting\n * what it *cannot* connect (ranked by blast radius) is the honest inverse of a\n * scanner that hides its unknowns. Only unknowns the precise rungs (tsc/scip)\n * did not supersede are recorded, so a compiler-resolved file never shows here.\n */\nexport interface Unknown {\n from: string; // node id where the unresolved reference occurs\n name: string; // the callee/type name that could not be resolved\n kind: 'call' | 'extends' | 'implements';\n count: number; // occurrences at this site\n}\n\nexport type GroundingKind = 'should_follow' | 'smells_like' | 'relevant_to';\n\nexport interface GroundingEdge {\n src: string; // node id\n packEntryId: string;\n kind: GroundingKind;\n confidence: number; // 0..1\n rationale: 'recommended' | 'conjectured';\n citation: { title: string; url: string };\n}\n\n/** Precomputed hub blast-radius counts for fast agent answers (optional). */\nexport interface HubBlastSummary {\n id: string;\n name: string;\n kind: string;\n file: string;\n importance: number;\n direct: number;\n depth2: number;\n files: number;\n tested: boolean | null;\n}\n\nexport interface GraphSummaries {\n hubs: HubBlastSummary[];\n}\n\nexport interface VgGraph {\n /**\n * The schema this artifact was written against. A freshly built graph always\n * carries {@link SCHEMA_VERSION}; a graph *loaded* from disk may carry any\n * member of {@link SUPPORTED_SCHEMA_VERSIONS}, since older artifacts stay\n * readable (the 1.1 additions are additive).\n */\n schemaVersion: SupportedSchemaVersion;\n generatedAt: string; // ISO; the ONLY nondeterministic field (pinned by --generated-at)\n provenance: Provenance;\n meta: GraphMeta;\n nodes: GraphNode[]; // sorted by id\n edges: GraphEdge[]; // sorted by (kind, src, dst)\n areas: Area[]; // sorted by id\n facts?: Fact[]; // open facts (contract/invariant/characterization); sorted by id\n grounding?: GroundingEdge[]; // free-pack grounding (default on; omit with --no-ground)\n unknowns?: Unknown[]; // heuristic references left unresolved; sorted by (from, kind, name)\n /** Build-time hub blast-radius summaries (always on; tiny). */\n summaries?: GraphSummaries;\n}\n","/**\n * SQLite serve index for large maps (scale past flat-JSON-only serve).\n *\n * The canonical artifact remains `graph.json` (determinism / git). The index\n * at `.vibgrate/cache/graph.db` is a derived, gitignored structure built after\n * every successful build:\n * - denormalized name/edge columns for O(log n) lookup\n * - full node/edge/area JSON for reconstructing a `VgGraph` without parsing\n * the pretty-printed graph.json (faster cold serve on XL maps)\n *\n * Uses Node's built-in `node:sqlite` (Node ≥22) — no native npm dependency.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { cacheDir } from './cache.js';\nimport { loadGraphFileWithSnapshot } from './snapshot.js';\nimport type {\n Area,\n EpistemicTier,\n GraphEdge,\n GraphNode,\n ResolverKind,\n VgGraph,\n} from '../schema.js';\nimport { SCHEMA_VERSION } from '../schema.js';\n\nexport interface IndexWriteResult {\n path: string;\n nodes: number;\n edges: number;\n /** False when node:sqlite is unavailable — callers should not fail the build. */\n ok: boolean;\n reason?: string;\n}\n\nexport function indexDbPath(root: string): string {\n return path.join(cacheDir(root), 'graph.db');\n}\n\n/** Write (replace) the SQLite index from a built graph. Never throws to callers. */\nexport function writeGraphIndex(root: string, graph: VgGraph): IndexWriteResult {\n const file = indexDbPath(root);\n try {\n \n const { DatabaseSync } = require('node:sqlite') as typeof import('node:sqlite');\n fs.mkdirSync(path.dirname(file), { recursive: true });\n const tmp = `${file}.${process.pid}.tmp`;\n try {\n if (fs.existsSync(tmp)) fs.unlinkSync(tmp);\n } catch {\n /* ignore */\n }\n\n const db = new DatabaseSync(tmp);\n db.exec(`\n PRAGMA journal_mode = OFF;\n PRAGMA synchronous = OFF;\n CREATE TABLE meta (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n );\n CREATE TABLE nodes (\n id TEXT PRIMARY KEY,\n name TEXT NOT NULL,\n qualified_name TEXT NOT NULL,\n kind TEXT NOT NULL,\n file TEXT NOT NULL,\n line INTEGER NOT NULL,\n importance REAL NOT NULL,\n area INTEGER NOT NULL,\n is_hub INTEGER NOT NULL,\n lang TEXT NOT NULL,\n json TEXT NOT NULL\n );\n CREATE TABLE edges (\n id TEXT PRIMARY KEY,\n kind TEXT NOT NULL,\n src TEXT NOT NULL,\n dst TEXT NOT NULL,\n resolution TEXT NOT NULL,\n confidence REAL NOT NULL,\n epistemic TEXT NOT NULL,\n json TEXT NOT NULL\n );\n CREATE TABLE areas (\n id INTEGER PRIMARY KEY,\n json TEXT NOT NULL\n );\n CREATE INDEX idx_nodes_name ON nodes(name);\n CREATE INDEX idx_nodes_qn ON nodes(qualified_name);\n CREATE INDEX idx_nodes_file ON nodes(file);\n CREATE INDEX idx_edges_src ON edges(src);\n CREATE INDEX idx_edges_dst ON edges(dst);\n CREATE INDEX idx_edges_kind ON edges(kind);\n `);\n\n const insMeta = db.prepare('INSERT INTO meta(key, value) VALUES (?, ?)');\n insMeta.run('corpusHash', graph.provenance.corpusHash);\n insMeta.run('schemaVersion', graph.schemaVersion);\n insMeta.run('generatedAt', graph.generatedAt);\n insMeta.run('nodeCount', String(graph.nodes.length));\n insMeta.run('edgeCount', String(graph.edges.length));\n insMeta.run('analysisTier', graph.meta.analysisTier ?? 'full');\n insMeta.run('indexVersion', 'vg-graph-index/2');\n // Full meta + provenance for reconstruct without graph.json parse.\n insMeta.run('graphMeta', JSON.stringify(graph.meta));\n insMeta.run('graphProvenance', JSON.stringify(graph.provenance));\n if (graph.facts) insMeta.run('factsJson', JSON.stringify(graph.facts));\n if (graph.grounding) insMeta.run('groundingJson', JSON.stringify(graph.grounding));\n if (graph.summaries) insMeta.run('summariesJson', JSON.stringify(graph.summaries));\n if (graph.unknowns) insMeta.run('unknownsJson', JSON.stringify(graph.unknowns));\n\n const insNode = db.prepare(\n `INSERT INTO nodes(id, name, qualified_name, kind, file, line, importance, area, is_hub, lang, json)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n );\n for (const n of graph.nodes) {\n insNode.run(\n n.id,\n n.name,\n n.qualifiedName,\n n.kind,\n n.file,\n n.span.start,\n n.importance,\n n.area,\n n.isHub ? 1 : 0,\n n.lang,\n JSON.stringify(n),\n );\n }\n\n const insEdge = db.prepare(\n `INSERT INTO edges(id, kind, src, dst, resolution, confidence, epistemic, json)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,\n );\n for (const e of graph.edges) {\n insEdge.run(\n e.id,\n e.kind,\n e.src,\n e.dst,\n e.resolution,\n e.confidence,\n e.epistemic ?? 'observed',\n JSON.stringify(e),\n );\n }\n\n const insArea = db.prepare('INSERT INTO areas(id, json) VALUES (?, ?)');\n for (const a of graph.areas) {\n insArea.run(a.id, JSON.stringify(a));\n }\n\n db.close();\n fs.renameSync(tmp, file);\n return { path: file, nodes: graph.nodes.length, edges: graph.edges.length, ok: true };\n } catch (err) {\n return {\n path: file,\n nodes: 0,\n edges: 0,\n ok: false,\n reason: (err as Error).message,\n };\n }\n}\n\nexport interface NameHit {\n id: string;\n name: string;\n qualifiedName: string;\n kind: string;\n file: string;\n line: number;\n importance: number;\n}\n\n/** Fast name / prefix lookup against the index. Empty if index missing. */\nexport function lookupNameIndex(root: string, query: string, limit = 20): NameHit[] {\n const file = indexDbPath(root);\n if (!fs.existsSync(file) || !query.trim()) return [];\n try {\n \n const { DatabaseSync } = require('node:sqlite') as typeof import('node:sqlite');\n const db = new DatabaseSync(file, { readOnly: true });\n const q = query.trim();\n const rows = db\n .prepare(\n `SELECT id, name, qualified_name, kind, file, line, importance\n FROM nodes\n WHERE name = ? OR qualified_name = ? OR name LIKE ? OR qualified_name LIKE ?\n ORDER BY\n CASE WHEN name = ? OR qualified_name = ? THEN 0\n WHEN name LIKE ? THEN 1\n ELSE 2 END,\n importance DESC\n LIMIT ?`,\n )\n .all(q, q, `${q}%`, `%${q}%`, q, q, `${q}%`, limit) as Record<string, unknown>[];\n db.close();\n return rows.map((r) => ({\n id: String(r.id),\n name: String(r.name),\n qualifiedName: String(r.qualified_name),\n kind: String(r.kind),\n file: String(r.file),\n line: Number(r.line),\n importance: Number(r.importance),\n }));\n } catch {\n return [];\n }\n}\n\n/** Neighbor edges for a node id (src or dst). Empty if index missing. */\nexport function lookupNeighbors(\n root: string,\n nodeId: string,\n direction: 'out' | 'in' | 'both' = 'both',\n limit = 50,\n): GraphEdge[] {\n const file = indexDbPath(root);\n if (!fs.existsSync(file) || !nodeId) return [];\n try {\n \n const { DatabaseSync } = require('node:sqlite') as typeof import('node:sqlite');\n const db = new DatabaseSync(file, { readOnly: true });\n let rows: Record<string, unknown>[] = [];\n if (direction === 'out' || direction === 'both') {\n rows = rows.concat(\n db\n .prepare(`SELECT json FROM edges WHERE src = ? LIMIT ?`)\n .all(nodeId, limit) as Record<string, unknown>[],\n );\n }\n if (direction === 'in' || direction === 'both') {\n rows = rows.concat(\n db\n .prepare(`SELECT json FROM edges WHERE dst = ? LIMIT ?`)\n .all(nodeId, limit) as Record<string, unknown>[],\n );\n }\n db.close();\n const byId = new Map<string, GraphEdge>();\n for (const r of rows) {\n try {\n const e = JSON.parse(String(r.json)) as GraphEdge;\n byId.set(e.id, e);\n } catch {\n /* skip bad row */\n }\n }\n return [...byId.values()];\n } catch {\n return [];\n }\n}\n\n/** Read index meta (corpusHash etc.) or null if missing. */\nexport function readIndexMeta(root: string): Record<string, string> | null {\n const file = indexDbPath(root);\n if (!fs.existsSync(file)) return null;\n try {\n \n const { DatabaseSync } = require('node:sqlite') as typeof import('node:sqlite');\n const db = new DatabaseSync(file, { readOnly: true });\n const rows = db.prepare('SELECT key, value FROM meta').all() as { key: string; value: string }[];\n db.close();\n const out: Record<string, string> = {};\n for (const r of rows) out[r.key] = r.value;\n return out;\n } catch {\n return null;\n }\n}\n\n/**\n * Reconstruct a full `VgGraph` from the SQLite index (indexVersion ≥ 2).\n * Returns null if the index is missing, stale schema, or incomplete.\n * Prefer this over JSON.parse of pretty graph.json for cold serve on large maps.\n */\nexport function loadGraphFromIndex(root: string): VgGraph | null {\n const file = indexDbPath(root);\n if (!fs.existsSync(file)) return null;\n try {\n \n const { DatabaseSync } = require('node:sqlite') as typeof import('node:sqlite');\n const db = new DatabaseSync(file, { readOnly: true });\n const metaRows = db.prepare('SELECT key, value FROM meta').all() as {\n key: string;\n value: string;\n }[];\n const meta: Record<string, string> = {};\n for (const r of metaRows) meta[r.key] = r.value;\n\n if (meta.indexVersion !== 'vg-graph-index/2' || !meta.graphMeta || !meta.graphProvenance) {\n db.close();\n return null;\n }\n\n const nodeRows = db.prepare('SELECT json FROM nodes ORDER BY id').all() as {\n json: string;\n }[];\n const edgeRows = db.prepare('SELECT json FROM edges ORDER BY id').all() as {\n json: string;\n }[];\n const areaRows = db.prepare('SELECT json FROM areas ORDER BY id').all() as {\n json: string;\n }[];\n db.close();\n\n const nodes = nodeRows.map((r) => JSON.parse(r.json) as GraphNode);\n const edges = edgeRows.map((r) => JSON.parse(r.json) as GraphEdge);\n const areas = areaRows.map((r) => JSON.parse(r.json) as Area);\n\n // Stable sorts match serialize contract (ids already ordered by SQL, re-sort for safety).\n nodes.sort((a, b) => a.id.localeCompare(b.id));\n edges.sort(\n (a, b) =>\n a.kind.localeCompare(b.kind) || a.src.localeCompare(b.src) || a.dst.localeCompare(b.dst),\n );\n areas.sort((a, b) => a.id - b.id);\n\n const graph: VgGraph = {\n schemaVersion: (meta.schemaVersion as typeof SCHEMA_VERSION) || SCHEMA_VERSION,\n generatedAt: meta.generatedAt ?? new Date(0).toISOString(),\n provenance: JSON.parse(meta.graphProvenance),\n meta: JSON.parse(meta.graphMeta),\n nodes,\n edges,\n areas,\n };\n if (meta.factsJson) graph.facts = JSON.parse(meta.factsJson);\n if (meta.groundingJson) graph.grounding = JSON.parse(meta.groundingJson);\n if (meta.summariesJson) graph.summaries = JSON.parse(meta.summariesJson);\n if (meta.unknownsJson) graph.unknowns = JSON.parse(meta.unknownsJson);\n\n // Lightweight integrity: edge resolution types stay valid.\n for (const e of edges) {\n if (!e.resolution) e.resolution = 'heuristic' as ResolverKind;\n if (!e.epistemic) e.epistemic = 'observed' as EpistemicTier;\n }\n return graph;\n } catch {\n return null;\n }\n}\n\n/**\n * Load the graph preferring the SQLite index when its corpusHash matches the\n * committed graph.json provenance (or when only the index exists). Falls back\n * to graph.json. Returns null if neither is usable.\n */\nexport function loadGraphPreferIndex(\n root: string,\n graphJsonPath: string,\n): { graph: VgGraph; source: 'index' | 'json' } | null {\n // Snapshot-first: skips the large-string JSON.parse when a fresh binary\n // snapshot exists (sidecar or store-mode standalone), and self-heals the\n // sidecar when not (see engine/snapshot.ts).\n const jsonGraph: VgGraph | null = loadGraphFileWithSnapshot(graphJsonPath);\n\n const fromIndex = loadGraphFromIndex(root);\n if (fromIndex) {\n if (!jsonGraph || fromIndex.provenance.corpusHash === jsonGraph.provenance.corpusHash) {\n return { graph: fromIndex, source: 'index' };\n }\n // Index stale vs graph.json — prefer canonical JSON and let next build refresh.\n }\n if (jsonGraph) return { graph: jsonGraph, source: 'json' };\n return null;\n}\n","import { resolveGraphPath } from './artifacts.js';\nimport { loadGraphFileWithSnapshot } from './snapshot.js';\nimport { loadGraphPreferIndex } from './index-db.js';\nimport type { VgGraph } from '../schema.js';\n\n/**\n * Load the code map for a repository.\n *\n * When `graphPath` is omitted, prefers an existing global-store snapshot, then\n * the legacy `.vibgrate/graph.json`, matching {@link resolveGraphPath}.\n * Prefers the SQLite index when its corpusHash matches the committed map\n * (faster cold serve on large repos). Returns null if none exists.\n */\nexport function loadGraph(root: string, graphPath?: string): VgGraph | null {\n const file = resolveGraphPath(root, graphPath);\n // Index is always rooted at the project root; only use it when loading the\n // default map for that root (not an arbitrary --graph path).\n if (!graphPath) {\n const preferred = loadGraphPreferIndex(root, file);\n if (preferred) return preferred.graph;\n }\n return loadGraphFileWithSnapshot(file);\n}\n"]}
1
+ {"version":3,"sources":["../src/schema.ts","../src/engine/index-db.ts","../src/engine/load.ts"],"names":[],"mappings":";;;;;;;AAoBO,IAAM,cAAA,GAAiB;AAQvB,IAAM,yBAAA,GAA4B,CAAC,cAAA,EAAgB,cAAc;;;ACQjE,SAAS,YAAY,IAAA,EAAsB;AAChD,EAAA,OAAY,IAAA,CAAA,IAAA,CAAK,QAAA,CAAS,IAAI,CAAA,EAAG,UAAU,CAAA;AAC7C;AAGO,SAAS,eAAA,CAAgB,MAAc,KAAA,EAAkC;AAC9E,EAAA,MAAM,IAAA,GAAO,YAAY,IAAI,CAAA;AAC7B,EAAA,IAAI;AAEF,IAAA,MAAM,EAAE,YAAA,EAAa,GAAI,SAAA,CAAQ,QAAa,CAAA;AAC9C,IAAG,aAAe,IAAA,CAAA,OAAA,CAAQ,IAAI,GAAG,EAAE,SAAA,EAAW,MAAM,CAAA;AACpD,IAAA,MAAM,GAAA,GAAM,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,QAAQ,GAAG,CAAA,IAAA,CAAA;AAClC,IAAA,IAAI;AACF,MAAA,IAAO,EAAA,CAAA,UA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,GAAa,WAAA;AAClC,MAAA,IAAI,CAAC,CAAA,CAAE,SAAA,EAAW,CAAA,CAAE,SAAA,GAAY,UAAA;AAAA,IAClC;AACA,IAAA,OAAO,KAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAOO,SAAS,oBAAA,CACd,MACA,aAAA,EACqD;AAIrD,EAAA,MAAM,SAAA,GAA4B,0BAA0B,aAAa,CAAA;AAEzE,EAAA,MAAM,SAAA,GAAY,mBAAmB,IAAI,CAAA;AACzC,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,IAAI,CAAC,SAAA,IAAa,SAAA,CAAU,WAAW,UAAA,KAAe,SAAA,CAAU,WAAW,UAAA,EAAY;AACrF,MAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,MAAA,EAAQ,OAAA,EAAQ;AAAA,IAC7C;AAAA,EAEF;AACA,EAAA,IAAI,WAAW,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,QAAQ,MAAA,EAAO;AACzD,EAAA,OAAO,IAAA;AACT;;;ACxWO,SAAS,SAAA,CAAU,MAAc,SAAA,EAAoC;AAC1E,EAAA,MAAM,IAAA,GAAO,gBAAA,CAAiB,IAAA,EAAM,SAAS,CAAA;AAG7C,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,MAAM,SAAA,GAAY,oBAAA,CAAqB,IAAA,EAAM,IAAI,CAAA;AACjD,IAAA,IAAI,SAAA,SAAkB,SAAA,CAAU,KAAA;AAAA,EAClC;AACA,EAAA,OAAO,0BAA0B,IAAI,CAAA;AACvC","file":"chunk-5BFA532E.js","sourcesContent":["/**\n * The `vg-graph/1.1` on-disk schema.\n *\n * This is vg's own open schema (VG-PACKAGE-AND-SCHEMA.md §4) — informed by good\n * ideas (content-hashed ids, epistemic typing of facts) but standalone and\n * self-contained. Every collection is deterministically serialized\n * (sorted keys, stable element order). These TypeScript shapes are normative.\n *\n * ## Version history\n *\n * - `vg-graph/1.0` — code-only vocabulary.\n * - `vg-graph/1.1` — **additive**: toolchain node kinds (`resource`, `workload`,\n * `job`, `step`, `image`, `chart`) and toolchain edge kinds (`depends_on`,\n * `provisions`, `deploys`, `triggers`, `exposes`, `mounts`, `builds_from`),\n * produced by `engine/toolchain/`. Nothing was removed or renamed, so a 1.0\n * reader that tolerates unknown kinds reads a 1.1 graph correctly; readers\n * that hard-match the version string need widening (see\n * `SUPPORTED_SCHEMA_VERSIONS`).\n */\n\nexport const SCHEMA_VERSION = 'vg-graph/1.1' as const;\n\n/**\n * Schema versions a reader should accept. The toolchain vocabulary added in 1.1\n * is purely additive, so a 1.0 artifact still loads — only the newer kinds are\n * absent from it. Readers must prefer this over an equality check on\n * {@link SCHEMA_VERSION}, which rejects perfectly readable older graphs.\n */\nexport const SUPPORTED_SCHEMA_VERSIONS = ['vg-graph/1.0', 'vg-graph/1.1'] as const;\n\nexport type SupportedSchemaVersion = (typeof SUPPORTED_SCHEMA_VERSIONS)[number];\n\nexport type ResolverKind = 'scip' | 'stackgraph' | 'tsc' | 'heuristic';\n\n/** Coarse, honest resolution tier for an edge (see engine/epistemic.ts). */\nexport type EpistemicTier = 'observed' | 'name-matched' | 'declared';\n\n/**\n * The toolchain that produced this graph — the reproducibility fingerprint.\n * Everything here deterministically affects graph *content* (parse trees change\n * between grammar releases; resolvers change which edges resolve), so a CI run\n * and a laptop run that disagree can be caught by comparing `fingerprint`.\n * Deliberately excludes the Node/OS version so the graph stays byte-stable\n * across host runtimes; `fingerprint` pins the parse/resolve toolchain only.\n */\nexport interface Toolchain {\n schema: string; // SCHEMA_VERSION\n tool: string; // vg calendar version\n grammars: string; // tree-sitter grammar set version string\n resolvers: ResolverKind[]; // resolver kinds available, sorted\n fingerprint: string; // shortId over the fields above — the value `vg attest` signs\n}\n\nexport interface Provenance {\n tool: 'vg';\n version: string; // calendar version\n grammars: Record<string, string>; // lang → grammar version (determinism input)\n resolver: ResolverKind[];\n deep: boolean; // did the heavier open passes run\n semanticModel?: string; // embedding model id+version if --deep semantic links\n corpusHash: string; // blake3 over the included file set + hashes\n toolchain?: Toolchain; // reproducibility fingerprint (checked by `vg verify`)\n}\n\n/** Analysis cost tier — auto-selected by node count (or forced). Reported honestly. */\nexport type AnalysisTier = 'full' | 'large' | 'xl';\n\nexport interface GraphMeta {\n root: string; // relative; portable across machines\n languages: string[];\n counts: {\n nodes: number;\n edges: number;\n areas: number;\n tests: number;\n untested: number;\n };\n cluster: 'leiden' | 'louvain' | 'none';\n /** Auto-selected (or forced) analysis tier for large maps. */\n analysisTier?: AnalysisTier;\n edgeKinds: EdgeKind[];\n}\n\nexport type NodeKind =\n | 'file'\n | 'module'\n | 'package'\n | 'class'\n | 'interface'\n | 'function'\n | 'method'\n | 'property'\n | 'test'\n | 'route'\n | 'component'\n /** Documentation / config text ingested for semantic ask (markdown, txt, env examples). */\n | 'document'\n | 'external'\n // ── Toolchain kinds (engine/toolchain/) ──────────────────────────────────\n // Structural extraction of the infrastructure/CI corpus. These sit alongside\n // the code kinds above and never replace the `document` node for the same\n // file: the document node stays the semantic-ask surface, these carry the\n // structure. Additive — consumers must tolerate unknown kinds.\n /** A declared infrastructure object: Terraform resource/data, K8s object, Compose service. */\n | 'resource'\n /** A deployable unit that runs containers (Deployment, StatefulSet, DaemonSet, Job, CronJob). */\n | 'workload'\n /** A CI job (GitHub Actions job, GitLab CI job). */\n | 'job'\n /** A single step within a CI job. */\n | 'step'\n /** A container image reference (`ghcr.io/acme/web:1.2.3`) or a Dockerfile build stage. */\n | 'image'\n /** A Helm chart (from `Chart.yaml`). */\n | 'chart';\n\nexport interface Span {\n start: number; // 1-based start line\n end: number; // 1-based end line\n}\n\nexport interface Centrality {\n degree: number;\n pagerank: number;\n betweenness: number;\n eigenvector: number;\n}\n\nexport interface GraphNode {\n id: string; // blake3(canonical(kind, qualifiedName, file, signature))\n kind: NodeKind;\n name: string; // short name\n qualifiedName: string;\n file: string; // relative path\n span: Span; // line range (excluded from id hash)\n lang: string;\n visibility?: 'public' | 'private' | 'protected' | 'internal';\n signature?: string;\n doc?: string; // short leading doc-comment / docstring summary (deterministic; not a full body)\n importance: number; // 0..1 blended centrality\n centrality: Centrality;\n area: number; // area id (the node's community); -1 = unassigned (cluster \"none\")\n isHub: boolean; // centrality outlier — surfaced by `vg hubs`\n tested: boolean | null; // null = not analyzable (e.g. external)\n coverage?: number; // 0..1 line coverage if a coverage report was ingested\n changeCoupling?: string[]; // node ids that historically change together\n}\n\nexport type EdgeKind =\n | 'call'\n | 'import'\n | 'contains'\n | 'extends'\n | 'implements'\n | 'references'\n | 'test'\n | 'coverage'\n // ── Toolchain edge kinds (engine/toolchain/) ─────────────────────────────\n // Every edge below is produced by structural extraction or by the\n // cross-domain linker. Linker-produced edges are always\n // `resolution: 'heuristic'` with a calibrated confidence — an inferred\n // `deploys` is not a declared `import` and must never claim to be.\n /** Declared ordering/reference dependency (Terraform `depends_on` + interpolation, Compose `depends_on`, CI `needs`). */\n | 'depends_on'\n /** An IaC declaration creates infrastructure (Terraform module → resource, chart → workload). */\n | 'provisions'\n /** A CI job or IaC declaration puts a workload/image into an environment. */\n | 'deploys'\n /** An event or upstream job causes a workflow/job to run. */\n | 'triggers'\n /** A workload/service publishes a port or endpoint. */\n | 'exposes'\n /** A workload/service consumes a volume, config map, or secret *by reference*. */\n | 'mounts'\n /** A build stage or workload is derived from a container image. */\n | 'builds_from';\n\nexport interface GraphEdge {\n id: string; // blake3(canonical(kind, src, dst))\n kind: EdgeKind;\n src: string; // node id\n dst: string; // node id\n resolution: ResolverKind; // how the edge was resolved\n confidence: number; // 0..1 (1.0 for scip/declared; lower for heuristic/dynamic)\n epistemic?: EpistemicTier; // coarse honesty tier derived from resolution+kind\n surprise?: number; // 0..1 improbability under the area model (`vg oddities`)\n count?: number; // call-site multiplicity\n}\n\nexport interface Area {\n id: number; // stable across runs (remapped to previous committed map)\n label: string; // most-central member's name (editable via `vg label`)\n size: number;\n members: string[]; // node ids, sorted\n cohesion: number; // 0..1\n externalEdges: number; // cross-area edge count\n}\n\nexport type FactKind = 'contract' | 'invariant' | 'characterization';\nexport type DerivedBy = 'declared' | 'static';\nexport type FactConfidence = 'Observed' | 'Derived';\n\nexport interface Fact {\n id: string; // blake3(canonical(kind, subjectIds, predicate))\n kind: FactKind;\n subjectIds: string[]; // node ids this fact constrains\n predicate: unknown; // the constraint\n derivedBy: DerivedBy;\n confidence: FactConfidence;\n evidence: { file: string; span: Span }[];\n}\n\n/**\n * A reference the graph could not resolve — surfaced by `vg unknowns`. Reporting\n * what it *cannot* connect (ranked by blast radius) is the honest inverse of a\n * scanner that hides its unknowns. Only unknowns the precise rungs (tsc/scip)\n * did not supersede are recorded, so a compiler-resolved file never shows here.\n */\nexport interface Unknown {\n from: string; // node id where the unresolved reference occurs\n name: string; // the callee/type name that could not be resolved\n kind: 'call' | 'extends' | 'implements';\n count: number; // occurrences at this site\n}\n\nexport type GroundingKind = 'should_follow' | 'smells_like' | 'relevant_to';\n\nexport interface GroundingEdge {\n src: string; // node id\n packEntryId: string;\n kind: GroundingKind;\n confidence: number; // 0..1\n rationale: 'recommended' | 'conjectured';\n citation: { title: string; url: string };\n}\n\n/** Precomputed hub blast-radius counts for fast agent answers (optional). */\nexport interface HubBlastSummary {\n id: string;\n name: string;\n kind: string;\n file: string;\n importance: number;\n direct: number;\n depth2: number;\n files: number;\n tested: boolean | null;\n}\n\nexport interface GraphSummaries {\n hubs: HubBlastSummary[];\n}\n\nexport interface VgGraph {\n /**\n * The schema this artifact was written against. A freshly built graph always\n * carries {@link SCHEMA_VERSION}; a graph *loaded* from disk may carry any\n * member of {@link SUPPORTED_SCHEMA_VERSIONS}, since older artifacts stay\n * readable (the 1.1 additions are additive).\n */\n schemaVersion: SupportedSchemaVersion;\n generatedAt: string; // ISO; the ONLY nondeterministic field (pinned by --generated-at)\n provenance: Provenance;\n meta: GraphMeta;\n nodes: GraphNode[]; // sorted by id\n edges: GraphEdge[]; // sorted by (kind, src, dst)\n areas: Area[]; // sorted by id\n facts?: Fact[]; // open facts (contract/invariant/characterization); sorted by id\n grounding?: GroundingEdge[]; // free-pack grounding (default on; omit with --no-ground)\n unknowns?: Unknown[]; // heuristic references left unresolved; sorted by (from, kind, name)\n /** Build-time hub blast-radius summaries (always on; tiny). */\n summaries?: GraphSummaries;\n}\n","/**\n * SQLite serve index for large maps (scale past flat-JSON-only serve).\n *\n * The canonical artifact remains `graph.json` (determinism / git). The index\n * at `.vibgrate/cache/graph.db` is a derived, gitignored structure built after\n * every successful build:\n * - denormalized name/edge columns for O(log n) lookup\n * - full node/edge/area JSON for reconstructing a `VgGraph` without parsing\n * the pretty-printed graph.json (faster cold serve on XL maps)\n *\n * Uses Node's built-in `node:sqlite` (Node ≥22) — no native npm dependency.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { cacheDir } from './cache.js';\nimport { loadGraphFileWithSnapshot } from './snapshot.js';\nimport type {\n Area,\n EpistemicTier,\n GraphEdge,\n GraphNode,\n ResolverKind,\n VgGraph,\n} from '../schema.js';\nimport { SCHEMA_VERSION } from '../schema.js';\n\nexport interface IndexWriteResult {\n path: string;\n nodes: number;\n edges: number;\n /** False when node:sqlite is unavailable — callers should not fail the build. */\n ok: boolean;\n reason?: string;\n}\n\nexport function indexDbPath(root: string): string {\n return path.join(cacheDir(root), 'graph.db');\n}\n\n/** Write (replace) the SQLite index from a built graph. Never throws to callers. */\nexport function writeGraphIndex(root: string, graph: VgGraph): IndexWriteResult {\n const file = indexDbPath(root);\n try {\n \n const { DatabaseSync } = require('node:sqlite') as typeof import('node:sqlite');\n fs.mkdirSync(path.dirname(file), { recursive: true });\n const tmp = `${file}.${process.pid}.tmp`;\n try {\n if (fs.existsSync(tmp)) fs.unlinkSync(tmp);\n } catch {\n /* ignore */\n }\n\n const db = new DatabaseSync(tmp);\n db.exec(`\n PRAGMA journal_mode = OFF;\n PRAGMA synchronous = OFF;\n CREATE TABLE meta (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n );\n CREATE TABLE nodes (\n id TEXT PRIMARY KEY,\n name TEXT NOT NULL,\n qualified_name TEXT NOT NULL,\n kind TEXT NOT NULL,\n file TEXT NOT NULL,\n line INTEGER NOT NULL,\n importance REAL NOT NULL,\n area INTEGER NOT NULL,\n is_hub INTEGER NOT NULL,\n lang TEXT NOT NULL,\n json TEXT NOT NULL\n );\n CREATE TABLE edges (\n id TEXT PRIMARY KEY,\n kind TEXT NOT NULL,\n src TEXT NOT NULL,\n dst TEXT NOT NULL,\n resolution TEXT NOT NULL,\n confidence REAL NOT NULL,\n epistemic TEXT NOT NULL,\n json TEXT NOT NULL\n );\n CREATE TABLE areas (\n id INTEGER PRIMARY KEY,\n json TEXT NOT NULL\n );\n CREATE INDEX idx_nodes_name ON nodes(name);\n CREATE INDEX idx_nodes_qn ON nodes(qualified_name);\n CREATE INDEX idx_nodes_file ON nodes(file);\n CREATE INDEX idx_edges_src ON edges(src);\n CREATE INDEX idx_edges_dst ON edges(dst);\n CREATE INDEX idx_edges_kind ON edges(kind);\n `);\n\n const insMeta = db.prepare('INSERT INTO meta(key, value) VALUES (?, ?)');\n insMeta.run('corpusHash', graph.provenance.corpusHash);\n insMeta.run('schemaVersion', graph.schemaVersion);\n insMeta.run('generatedAt', graph.generatedAt);\n insMeta.run('nodeCount', String(graph.nodes.length));\n insMeta.run('edgeCount', String(graph.edges.length));\n insMeta.run('analysisTier', graph.meta.analysisTier ?? 'full');\n insMeta.run('indexVersion', 'vg-graph-index/2');\n // Full meta + provenance for reconstruct without graph.json parse.\n insMeta.run('graphMeta', JSON.stringify(graph.meta));\n insMeta.run('graphProvenance', JSON.stringify(graph.provenance));\n if (graph.facts) insMeta.run('factsJson', JSON.stringify(graph.facts));\n if (graph.grounding) insMeta.run('groundingJson', JSON.stringify(graph.grounding));\n if (graph.summaries) insMeta.run('summariesJson', JSON.stringify(graph.summaries));\n if (graph.unknowns) insMeta.run('unknownsJson', JSON.stringify(graph.unknowns));\n\n const insNode = db.prepare(\n `INSERT INTO nodes(id, name, qualified_name, kind, file, line, importance, area, is_hub, lang, json)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n );\n for (const n of graph.nodes) {\n insNode.run(\n n.id,\n n.name,\n n.qualifiedName,\n n.kind,\n n.file,\n n.span.start,\n n.importance,\n n.area,\n n.isHub ? 1 : 0,\n n.lang,\n JSON.stringify(n),\n );\n }\n\n const insEdge = db.prepare(\n `INSERT INTO edges(id, kind, src, dst, resolution, confidence, epistemic, json)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,\n );\n for (const e of graph.edges) {\n insEdge.run(\n e.id,\n e.kind,\n e.src,\n e.dst,\n e.resolution,\n e.confidence,\n e.epistemic ?? 'observed',\n JSON.stringify(e),\n );\n }\n\n const insArea = db.prepare('INSERT INTO areas(id, json) VALUES (?, ?)');\n for (const a of graph.areas) {\n insArea.run(a.id, JSON.stringify(a));\n }\n\n db.close();\n fs.renameSync(tmp, file);\n return { path: file, nodes: graph.nodes.length, edges: graph.edges.length, ok: true };\n } catch (err) {\n return {\n path: file,\n nodes: 0,\n edges: 0,\n ok: false,\n reason: (err as Error).message,\n };\n }\n}\n\nexport interface NameHit {\n id: string;\n name: string;\n qualifiedName: string;\n kind: string;\n file: string;\n line: number;\n importance: number;\n}\n\n/** Fast name / prefix lookup against the index. Empty if index missing. */\nexport function lookupNameIndex(root: string, query: string, limit = 20): NameHit[] {\n const file = indexDbPath(root);\n if (!fs.existsSync(file) || !query.trim()) return [];\n try {\n \n const { DatabaseSync } = require('node:sqlite') as typeof import('node:sqlite');\n const db = new DatabaseSync(file, { readOnly: true });\n const q = query.trim();\n const rows = db\n .prepare(\n `SELECT id, name, qualified_name, kind, file, line, importance\n FROM nodes\n WHERE name = ? OR qualified_name = ? OR name LIKE ? OR qualified_name LIKE ?\n ORDER BY\n CASE WHEN name = ? OR qualified_name = ? THEN 0\n WHEN name LIKE ? THEN 1\n ELSE 2 END,\n importance DESC\n LIMIT ?`,\n )\n .all(q, q, `${q}%`, `%${q}%`, q, q, `${q}%`, limit) as Record<string, unknown>[];\n db.close();\n return rows.map((r) => ({\n id: String(r.id),\n name: String(r.name),\n qualifiedName: String(r.qualified_name),\n kind: String(r.kind),\n file: String(r.file),\n line: Number(r.line),\n importance: Number(r.importance),\n }));\n } catch {\n return [];\n }\n}\n\n/** Neighbor edges for a node id (src or dst). Empty if index missing. */\nexport function lookupNeighbors(\n root: string,\n nodeId: string,\n direction: 'out' | 'in' | 'both' = 'both',\n limit = 50,\n): GraphEdge[] {\n const file = indexDbPath(root);\n if (!fs.existsSync(file) || !nodeId) return [];\n try {\n \n const { DatabaseSync } = require('node:sqlite') as typeof import('node:sqlite');\n const db = new DatabaseSync(file, { readOnly: true });\n let rows: Record<string, unknown>[] = [];\n if (direction === 'out' || direction === 'both') {\n rows = rows.concat(\n db\n .prepare(`SELECT json FROM edges WHERE src = ? LIMIT ?`)\n .all(nodeId, limit) as Record<string, unknown>[],\n );\n }\n if (direction === 'in' || direction === 'both') {\n rows = rows.concat(\n db\n .prepare(`SELECT json FROM edges WHERE dst = ? LIMIT ?`)\n .all(nodeId, limit) as Record<string, unknown>[],\n );\n }\n db.close();\n const byId = new Map<string, GraphEdge>();\n for (const r of rows) {\n try {\n const e = JSON.parse(String(r.json)) as GraphEdge;\n byId.set(e.id, e);\n } catch {\n /* skip bad row */\n }\n }\n return [...byId.values()];\n } catch {\n return [];\n }\n}\n\n/** Read index meta (corpusHash etc.) or null if missing. */\nexport function readIndexMeta(root: string): Record<string, string> | null {\n const file = indexDbPath(root);\n if (!fs.existsSync(file)) return null;\n try {\n \n const { DatabaseSync } = require('node:sqlite') as typeof import('node:sqlite');\n const db = new DatabaseSync(file, { readOnly: true });\n const rows = db.prepare('SELECT key, value FROM meta').all() as { key: string; value: string }[];\n db.close();\n const out: Record<string, string> = {};\n for (const r of rows) out[r.key] = r.value;\n return out;\n } catch {\n return null;\n }\n}\n\n/**\n * Reconstruct a full `VgGraph` from the SQLite index (indexVersion ≥ 2).\n * Returns null if the index is missing, stale schema, or incomplete.\n * Prefer this over JSON.parse of pretty graph.json for cold serve on large maps.\n */\nexport function loadGraphFromIndex(root: string): VgGraph | null {\n const file = indexDbPath(root);\n if (!fs.existsSync(file)) return null;\n try {\n \n const { DatabaseSync } = require('node:sqlite') as typeof import('node:sqlite');\n const db = new DatabaseSync(file, { readOnly: true });\n const metaRows = db.prepare('SELECT key, value FROM meta').all() as {\n key: string;\n value: string;\n }[];\n const meta: Record<string, string> = {};\n for (const r of metaRows) meta[r.key] = r.value;\n\n if (meta.indexVersion !== 'vg-graph-index/2' || !meta.graphMeta || !meta.graphProvenance) {\n db.close();\n return null;\n }\n\n const nodeRows = db.prepare('SELECT json FROM nodes ORDER BY id').all() as {\n json: string;\n }[];\n const edgeRows = db.prepare('SELECT json FROM edges ORDER BY id').all() as {\n json: string;\n }[];\n const areaRows = db.prepare('SELECT json FROM areas ORDER BY id').all() as {\n json: string;\n }[];\n db.close();\n\n const nodes = nodeRows.map((r) => JSON.parse(r.json) as GraphNode);\n const edges = edgeRows.map((r) => JSON.parse(r.json) as GraphEdge);\n const areas = areaRows.map((r) => JSON.parse(r.json) as Area);\n\n // Stable sorts match serialize contract (ids already ordered by SQL, re-sort for safety).\n nodes.sort((a, b) => a.id.localeCompare(b.id));\n edges.sort(\n (a, b) =>\n a.kind.localeCompare(b.kind) || a.src.localeCompare(b.src) || a.dst.localeCompare(b.dst),\n );\n areas.sort((a, b) => a.id - b.id);\n\n const graph: VgGraph = {\n schemaVersion: (meta.schemaVersion as typeof SCHEMA_VERSION) || SCHEMA_VERSION,\n generatedAt: meta.generatedAt ?? new Date(0).toISOString(),\n provenance: JSON.parse(meta.graphProvenance),\n meta: JSON.parse(meta.graphMeta),\n nodes,\n edges,\n areas,\n };\n if (meta.factsJson) graph.facts = JSON.parse(meta.factsJson);\n if (meta.groundingJson) graph.grounding = JSON.parse(meta.groundingJson);\n if (meta.summariesJson) graph.summaries = JSON.parse(meta.summariesJson);\n if (meta.unknownsJson) graph.unknowns = JSON.parse(meta.unknownsJson);\n\n // Lightweight integrity: edge resolution types stay valid.\n for (const e of edges) {\n if (!e.resolution) e.resolution = 'heuristic' as ResolverKind;\n if (!e.epistemic) e.epistemic = 'observed' as EpistemicTier;\n }\n return graph;\n } catch {\n return null;\n }\n}\n\n/**\n * Load the graph preferring the SQLite index when its corpusHash matches the\n * committed graph.json provenance (or when only the index exists). Falls back\n * to graph.json. Returns null if neither is usable.\n */\nexport function loadGraphPreferIndex(\n root: string,\n graphJsonPath: string,\n): { graph: VgGraph; source: 'index' | 'json' } | null {\n // Snapshot-first: skips the large-string JSON.parse when a fresh binary\n // snapshot exists (sidecar or store-mode standalone), and self-heals the\n // sidecar when not (see engine/snapshot.ts).\n const jsonGraph: VgGraph | null = loadGraphFileWithSnapshot(graphJsonPath);\n\n const fromIndex = loadGraphFromIndex(root);\n if (fromIndex) {\n if (!jsonGraph || fromIndex.provenance.corpusHash === jsonGraph.provenance.corpusHash) {\n return { graph: fromIndex, source: 'index' };\n }\n // Index stale vs graph.json — prefer canonical JSON and let next build refresh.\n }\n if (jsonGraph) return { graph: jsonGraph, source: 'json' };\n return null;\n}\n","import { resolveGraphPath } from './artifacts.js';\nimport { loadGraphFileWithSnapshot } from './snapshot.js';\nimport { loadGraphPreferIndex } from './index-db.js';\nimport type { VgGraph } from '../schema.js';\n\n/**\n * Load the code map for a repository.\n *\n * When `graphPath` is omitted, prefers an existing global-store snapshot, then\n * the legacy `.vibgrate/graph.json`, matching {@link resolveGraphPath}.\n * Prefers the SQLite index when its corpusHash matches the committed map\n * (faster cold serve on large repos). Returns null if none exists.\n */\nexport function loadGraph(root: string, graphPath?: string): VgGraph | null {\n const file = resolveGraphPath(root, graphPath);\n // Index is always rooted at the project root; only use it when loading the\n // default map for that root (not an arbitrary --graph path).\n if (!graphPath) {\n const preferred = loadGraphPreferIndex(root, file);\n if (preferred) return preferred.graph;\n }\n return loadGraphFileWithSnapshot(file);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { indexFor, userAskFromInstruction, queryGraph, impactOf, conceptMapLines, extractLiteralNeedles } from './chunk-VEQA2FSM.js';
1
+ import { indexFor, userAskFromInstruction, queryGraph, impactOf, extractLiteralNeedles } from './chunk-LUJ4H4RJ.js';
2
2
  import { cacheDir } from './chunk-MVPRPSXU.js';
3
3
  import { hashString } from './chunk-JFGYT6BI.js';
4
4
  import * as fs from 'fs';
@@ -222,13 +222,10 @@ function buildCodeContext(graph, instruction, options = {}) {
222
222
  const impactDepth = options.impactDepth ?? 2;
223
223
  const index = indexFor(graph);
224
224
  const ask = userAskFromInstruction(instruction);
225
- const priorAsk = options.priorInstruction ? userAskFromInstruction(options.priorInstruction) : options.priorInstruction;
226
225
  const q = queryGraph(graph, ask, {
227
226
  budget: Math.floor(budget * 0.6),
228
227
  limit: seedLimit * 2,
229
- relevance: options.relevance,
230
- topicTags: options.topicTags,
231
- priorQuestion: priorAsk
228
+ ranked: options.ranked
232
229
  });
233
230
  let seeds = q.matches.map((m) => ({ node: m.node, why: m.why }));
234
231
  if (options.files && options.files.length) {
@@ -251,7 +248,7 @@ function buildCodeContext(graph, instruction, options = {}) {
251
248
  ...literalNeedleFacts(ask),
252
249
  ...pinnedFactsFor(graph, seedIds)
253
250
  ];
254
- const conceptMap = conceptMapLines(ask, options.relevance, priorAsk);
251
+ const conceptMap = options.ranked?.conceptMap ?? [];
255
252
  const rendered = render(instruction, seeds, [...impacted.values()], targetFiles, pinnedFacts, conceptMap, index, budget);
256
253
  return {
257
254
  instruction,
@@ -337,8 +334,11 @@ function estimateTokens(text) {
337
334
 
338
335
  // src/code/capsule.ts
339
336
  var TASK_CAPSULE_SCHEMA_VERSION = "task-capsule/0";
340
- var CAPSULE_RANKING_VERSION = "capsule-rank@2026.08.3";
337
+ var CAPSULE_RANKING_VERSION = "capsule-rank@2026.08.4";
341
338
  var CAPSULE_COMPILER_ID = "vg-task-capsule/0";
339
+ function interpretationFor(conceptMap) {
340
+ return conceptMap.filter((line) => !/^\s*-?\s*Seed notation\b/i.test(line)).map((line) => line.replace(/^\s*-\s+/, "").trim()).filter(Boolean);
341
+ }
342
342
  function summarizeCapsule(capsule) {
343
343
  const sourceFiles = [...new Set(capsule.sourceSlices.map((s) => s.file))].sort();
344
344
  const preview = capsule.rendered.length > 4e3 ? `${capsule.rendered.slice(0, 4e3)}
@@ -346,15 +346,36 @@ function summarizeCapsule(capsule) {
346
346
  return {
347
347
  schemaVersion: capsule.schemaVersion,
348
348
  instruction: capsule.instruction,
349
- primary: capsule.primary.map((p) => ({ qualifiedName: p.qualifiedName, file: p.file, kind: p.kind })),
350
- supporting: capsule.supporting.map((p) => ({ qualifiedName: p.qualifiedName, file: p.file, kind: p.kind })),
349
+ primary: capsule.primary.map((p) => ({ qualifiedName: p.qualifiedName, file: p.file, kind: p.kind, why: p.why })),
350
+ supporting: capsule.supporting.map((p) => ({ qualifiedName: p.qualifiedName, file: p.file, kind: p.kind, why: p.why })),
351
351
  sourceSliceCount: capsule.sourceSlices.length,
352
352
  sourceFiles,
353
353
  tokensEstimate: capsule.tokensEstimate,
354
354
  rankingVersion: capsule.provenance.rankingVersion,
355
+ interpretation: interpretationFor(capsule.conceptMap),
355
356
  preview
356
357
  };
357
358
  }
359
+ var TRANSPARENCY_INTERPRETATION_LINES = 6;
360
+ var TRANSPARENCY_SEED_LINES = 3;
361
+ function capsuleTransparencyLines(summary) {
362
+ const lines = [];
363
+ const interpretation = summary.interpretation ?? [];
364
+ for (const line of interpretation.slice(0, TRANSPARENCY_INTERPRETATION_LINES)) {
365
+ lines.push(` read: ${line}`);
366
+ }
367
+ const hiddenInterpretation = interpretation.length - TRANSPARENCY_INTERPRETATION_LINES;
368
+ if (hiddenInterpretation > 0) lines.push(` read: \u2026 ${hiddenInterpretation} more`);
369
+ const seeds = (summary.primary ?? []).filter((p) => p.qualifiedName);
370
+ for (const seed of seeds.slice(0, TRANSPARENCY_SEED_LINES)) {
371
+ const where = seed.file ? ` \xB7 ${seed.file}` : "";
372
+ const why = seed.why ? ` \u2014 ${seed.why}` : "";
373
+ lines.push(` seed: ${seed.qualifiedName}${where}${why}`);
374
+ }
375
+ const hiddenSeeds = seeds.length - TRANSPARENCY_SEED_LINES;
376
+ if (hiddenSeeds > 0) lines.push(` seed: \u2026 ${hiddenSeeds} more`);
377
+ return lines;
378
+ }
358
379
  function buildTaskCapsule(graph, instruction, options = {}) {
359
380
  const base = buildCodeContext(graph, instruction, options);
360
381
  const padding = options.padding ?? 1;
@@ -400,7 +421,7 @@ function buildTaskCapsule(graph, instruction, options = {}) {
400
421
  modelProfileId: options.provenance?.modelProfileId ?? null,
401
422
  securityTier: options.provenance?.securityTier ?? null,
402
423
  policyVersion: options.provenance?.policyVersion ?? null,
403
- relevanceVersion: options.relevance?.version ?? null
424
+ relevanceVersion: options.ranked?.version ?? null
404
425
  }
405
426
  };
406
427
  }
@@ -550,7 +571,7 @@ function buildVerificationPlan(graph, base) {
550
571
  }
551
572
  function renderCapsule(instruction, primary, supporting, slices, pinnedFacts, conceptMap, targetFiles, verification, relationships, budget) {
552
573
  const lines = [];
553
- lines.push("# Task capsule (source-bearing, from the deterministic code graph)");
574
+ lines.push("# Context capsule (source-bearing, from the deterministic code graph)");
554
575
  lines.push("");
555
576
  lines.push("Use the exact source evidence below. Search or read outside it only if this capsule is insufficient.");
556
577
  lines.push("");
@@ -641,6 +662,6 @@ function estimateTokens2(text) {
641
662
  return Math.ceil(text.length / 4);
642
663
  }
643
664
 
644
- export { CAPSULE_COMPILER_ID, CAPSULE_RANKING_VERSION, CLI_TOOL_ALIASES, PER_FILE_TOKENS, SAVINGS_TOOLS, TASK_CAPSULE_SCHEMA_VERSION, buildCodeContext, buildTaskCapsule, capsuleToCodeContext, clearSavings, readModelSavings, readSavings, readUsage, recordCliCall, recordSaving, sanitizeClient, savingsLedgerPath, savingsRecorded, summarizeCapsule };
645
- //# sourceMappingURL=chunk-UAPA5AHX.js.map
646
- //# sourceMappingURL=chunk-UAPA5AHX.js.map
665
+ export { CAPSULE_COMPILER_ID, CAPSULE_RANKING_VERSION, CLI_TOOL_ALIASES, PER_FILE_TOKENS, SAVINGS_TOOLS, TASK_CAPSULE_SCHEMA_VERSION, buildCodeContext, buildTaskCapsule, capsuleToCodeContext, capsuleTransparencyLines, clearSavings, readModelSavings, readSavings, readUsage, recordCliCall, recordSaving, sanitizeClient, savingsLedgerPath, savingsRecorded, summarizeCapsule };
666
+ //# sourceMappingURL=chunk-6VLOI2ZP.js.map
667
+ //# sourceMappingURL=chunk-6VLOI2ZP.js.map