@vibgrate/cli 2026.825.2 → 2026.826.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 (95) hide show
  1. package/dist/{agent-DHQYEHVW.js → agent-4RHH2FR2.js} +13 -13
  2. package/dist/{agent-DHQYEHVW.js.map → agent-4RHH2FR2.js.map} +1 -1
  3. package/dist/{approvals-KBM72NU2.js → approvals-XDFM346D.js} +5 -5
  4. package/dist/{approvals-KBM72NU2.js.map → approvals-XDFM346D.js.map} +1 -1
  5. package/dist/{attach-O74NL4M5.js → attach-LGTCYNKC.js} +3 -3
  6. package/dist/{attach-O74NL4M5.js.map → attach-LGTCYNKC.js.map} +1 -1
  7. package/dist/{baseline-4X6MQBDA.js → baseline-PRY5HKL5.js} +3 -3
  8. package/dist/{baseline-4X6MQBDA.js.map → baseline-PRY5HKL5.js.map} +1 -1
  9. package/dist/{chunk-DIZ5KI5Q.js → chunk-7KOEEEIZ.js} +6 -6
  10. package/dist/{chunk-DIZ5KI5Q.js.map → chunk-7KOEEEIZ.js.map} +1 -1
  11. package/dist/{chunk-7M4E7UGX.js → chunk-7S4ELKK6.js} +3 -3
  12. package/dist/{chunk-7M4E7UGX.js.map → chunk-7S4ELKK6.js.map} +1 -1
  13. package/dist/{chunk-NS4DL3QR.js → chunk-BHDP7EVJ.js} +8 -8
  14. package/dist/{chunk-NS4DL3QR.js.map → chunk-BHDP7EVJ.js.map} +1 -1
  15. package/dist/{chunk-IJVWKZRS.js → chunk-E44I7635.js} +3 -3
  16. package/dist/{chunk-IJVWKZRS.js.map → chunk-E44I7635.js.map} +1 -1
  17. package/dist/{chunk-2NUS5BOR.js → chunk-IEZCFMNL.js} +3 -3
  18. package/dist/{chunk-2NUS5BOR.js.map → chunk-IEZCFMNL.js.map} +1 -1
  19. package/dist/{chunk-3E7QT4NE.js → chunk-IM7HME2T.js} +9 -9
  20. package/dist/{chunk-3E7QT4NE.js.map → chunk-IM7HME2T.js.map} +1 -1
  21. package/dist/chunk-JQ7OL4XG.js +6 -0
  22. package/dist/{chunk-G3ACLBMG.js.map → chunk-JQ7OL4XG.js.map} +1 -1
  23. package/dist/{chunk-OIUVWCKM.js → chunk-K2IWOZEQ.js} +3 -3
  24. package/dist/{chunk-OIUVWCKM.js.map → chunk-K2IWOZEQ.js.map} +1 -1
  25. package/dist/{chunk-SYMJSRYF.js → chunk-LAYDXJEQ.js} +3 -3
  26. package/dist/{chunk-SYMJSRYF.js.map → chunk-LAYDXJEQ.js.map} +1 -1
  27. package/dist/{chunk-K3SXWOTT.js → chunk-NQU6E6OG.js} +3 -3
  28. package/dist/{chunk-K3SXWOTT.js.map → chunk-NQU6E6OG.js.map} +1 -1
  29. package/dist/{chunk-E3XVIFSH.js → chunk-PEHMRPYM.js} +3 -3
  30. package/dist/{chunk-E3XVIFSH.js.map → chunk-PEHMRPYM.js.map} +1 -1
  31. package/dist/{chunk-BICZR6UJ.js → chunk-PIB3YNJU.js} +3 -3
  32. package/dist/{chunk-BICZR6UJ.js.map → chunk-PIB3YNJU.js.map} +1 -1
  33. package/dist/{chunk-NZES47ST.js → chunk-QONHVC4H.js} +3 -3
  34. package/dist/{chunk-NZES47ST.js.map → chunk-QONHVC4H.js.map} +1 -1
  35. package/dist/{chunk-L7GCJNDT.js → chunk-R5BGRJ6X.js} +3 -3
  36. package/dist/{chunk-L7GCJNDT.js.map → chunk-R5BGRJ6X.js.map} +1 -1
  37. package/dist/{chunk-VMPKOMHG.js → chunk-TKUWEJZJ.js} +5 -5
  38. package/dist/{chunk-VMPKOMHG.js.map → chunk-TKUWEJZJ.js.map} +1 -1
  39. package/dist/{chunk-6MIJLO5B.js → chunk-TOHNVUDD.js} +3 -3
  40. package/dist/{chunk-6MIJLO5B.js.map → chunk-TOHNVUDD.js.map} +1 -1
  41. package/dist/{chunk-HFQIYM6E.js → chunk-TQ75FB52.js} +4 -4
  42. package/dist/{chunk-HFQIYM6E.js.map → chunk-TQ75FB52.js.map} +1 -1
  43. package/dist/{chunk-TT2J2TB6.js → chunk-TUVB6Q6F.js} +6 -6
  44. package/dist/{chunk-TT2J2TB6.js.map → chunk-TUVB6Q6F.js.map} +1 -1
  45. package/dist/{chunk-27TS2AUJ.js → chunk-WGA4KUGS.js} +8 -8
  46. package/dist/{chunk-27TS2AUJ.js.map → chunk-WGA4KUGS.js.map} +1 -1
  47. package/dist/{chunk-GWSJYDK7.js → chunk-WGSLN73L.js} +5 -5
  48. package/dist/{chunk-GWSJYDK7.js.map → chunk-WGSLN73L.js.map} +1 -1
  49. package/dist/{chunk-SIXWWQ6S.js → chunk-WHNB3443.js} +3 -3
  50. package/dist/{chunk-SIXWWQ6S.js.map → chunk-WHNB3443.js.map} +1 -1
  51. package/dist/{chunk-GR7SFCQJ.js → chunk-WPQCJADP.js} +27 -17
  52. package/dist/chunk-WPQCJADP.js.map +1 -0
  53. package/dist/{chunk-FQHWPOTS.js → chunk-WU2DVESP.js} +3 -3
  54. package/dist/{chunk-FQHWPOTS.js.map → chunk-WU2DVESP.js.map} +1 -1
  55. package/dist/{chunk-KYM55VZX.js → chunk-XW4FCBL4.js} +6 -6
  56. package/dist/{chunk-KYM55VZX.js.map → chunk-XW4FCBL4.js.map} +1 -1
  57. package/dist/{chunk-JAEHLTVX.js → chunk-ZRDTI67N.js} +3 -3
  58. package/dist/{chunk-JAEHLTVX.js.map → chunk-ZRDTI67N.js.map} +1 -1
  59. package/dist/cli.js +52 -51
  60. package/dist/cli.js.map +1 -1
  61. package/dist/{daemon-RZS5FPIW.js → daemon-2YMCH7R2.js} +9 -9
  62. package/dist/{daemon-RZS5FPIW.js.map → daemon-2YMCH7R2.js.map} +1 -1
  63. package/dist/embed-worker-main.js +3 -3
  64. package/dist/{ensure-map-DL2S774J.js → ensure-map-S2GBW2UC.js} +14 -14
  65. package/dist/{ensure-map-DL2S774J.js.map → ensure-map-S2GBW2UC.js.map} +1 -1
  66. package/dist/{graph-backend-JXARVT3R.js → graph-backend-QDEU5RIR.js} +7 -7
  67. package/dist/{graph-backend-JXARVT3R.js.map → graph-backend-QDEU5RIR.js.map} +1 -1
  68. package/dist/index.d.ts +1 -1
  69. package/dist/index.js +15 -15
  70. package/dist/{interactive-2XRBRFRB.js → interactive-GMGWUEQO.js} +30 -26
  71. package/dist/interactive-GMGWUEQO.js.map +1 -0
  72. package/dist/load-JXCTAAEI.js +11 -0
  73. package/dist/{load-7C5VETRD.js.map → load-JXCTAAEI.js.map} +1 -1
  74. package/dist/parse-worker.js +2 -2
  75. package/dist/{run-outcome-TMB5TJNA.js → run-outcome-5NA7PI52.js} +5 -5
  76. package/dist/{run-outcome-TMB5TJNA.js.map → run-outcome-5NA7PI52.js.map} +1 -1
  77. package/dist/{runtime-session-Y23NVY7R.js → runtime-session-IEM6DZDP.js} +9 -9
  78. package/dist/{runtime-session-Y23NVY7R.js.map → runtime-session-IEM6DZDP.js.map} +1 -1
  79. package/dist/{session-KXT2ZTPE.js → session-VYFLJ7KL.js} +8 -8
  80. package/dist/{session-KXT2ZTPE.js.map → session-VYFLJ7KL.js.map} +1 -1
  81. package/dist/{stream-json-NW6AOE47.js → stream-json-2ISQLKPD.js} +13 -13
  82. package/dist/{stream-json-NW6AOE47.js.map → stream-json-2ISQLKPD.js.map} +1 -1
  83. package/dist/version-B62ELJRY.js +4 -0
  84. package/dist/{version-7ABYXWOZ.js.map → version-B62ELJRY.js.map} +1 -1
  85. package/dist/{vg-mcp-bridge-LXBHKEFR.js → vg-mcp-bridge-CJIK5U56.js} +8 -8
  86. package/dist/{vg-mcp-bridge-LXBHKEFR.js.map → vg-mcp-bridge-CJIK5U56.js.map} +1 -1
  87. package/dist/{vgd-RW7HCEIP.js → vgd-4EB6SKFB.js} +8 -8
  88. package/dist/vgd-4EB6SKFB.js.map +1 -0
  89. package/package.json +1 -1
  90. package/dist/chunk-G3ACLBMG.js +0 -6
  91. package/dist/chunk-GR7SFCQJ.js.map +0 -1
  92. package/dist/interactive-2XRBRFRB.js.map +0 -1
  93. package/dist/load-7C5VETRD.js +0 -11
  94. package/dist/version-7ABYXWOZ.js +0 -4
  95. package/dist/vgd-RW7HCEIP.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { userAskFromInstruction, queryGraph } from './chunk-K3SXWOTT.js';
1
+ import { userAskFromInstruction, queryGraph } from './chunk-NQU6E6OG.js';
2
2
 
3
3
  // src/code/capsule-mode.ts
4
4
  var WHOLE_REPO_MAX_SOURCE_TOKENS = 1500;
@@ -86,5 +86,5 @@ function langFor(file) {
86
86
  }
87
87
 
88
88
  export { COMPILE_MIN_SOURCE_TOKENS, WHOLE_REPO_MAX_SOURCE_TOKENS, askNamesSymbol, buildWholeRepoPacket, capsuleMode, mappedFilePaths, sourceTokenMass };
89
- //# sourceMappingURL=chunk-L7GCJNDT.js.map
90
- //# sourceMappingURL=chunk-L7GCJNDT.js.map
89
+ //# sourceMappingURL=chunk-R5BGRJ6X.js.map
90
+ //# sourceMappingURL=chunk-R5BGRJ6X.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/code/capsule-mode.ts"],"names":[],"mappings":";;;AAeO,IAAM,4BAAA,GAA+B;AAErC,IAAM,yBAAA,GAA4B;AAElC,SAAS,qBAAqB,IAAA,EAAsB;AACzD,EAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,MAAA,GAAS,CAAC,CAAA;AAClC;AAGO,SAAS,gBAAgB,KAAA,EAA0B;AACxD,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAY;AAC9B,EAAA,KAAA,MAAW,CAAA,IAAK,MAAM,KAAA,EAAO;AAC3B,IAAA,MAAM,CAAA,GAAI,SAAA,CAAU,CAAA,CAAE,IAAI,CAAA;AAC1B,IAAA,IAAI,CAAC,CAAA,IAAK,cAAA,CAAe,CAAC,CAAA,EAAG;AAC7B,IAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AAAA,EACb;AACA,EAAA,OAAO,CAAC,GAAG,KAAK,CAAA,CAAE,IAAA,EAAK;AACzB;AAEO,SA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E,IAAA,CAAK,UAAA,CAAW,eAAe,CAAA,IAC/B,KAAK,QAAA,CAAS,gBAAgB,CAAA,IAC9B,IAAA,CAAK,UAAA,CAAW,OAAO,CAAA,IACvB,IAAA,CAAK,WAAW,YAAY,CAAA;AAEhC;AAEA,SAAS,UAAU,IAAA,EAAsB;AACvC,EAAA,OAAO,KAAK,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA,CAAE,OAAA,CAAQ,SAAS,EAAE,CAAA;AACrD;AAEA,SAAS,QAAQ,IAAA,EAAsB;AACrC,EAAA,MAAM,GAAA,GAAM,KAAK,KAAA,CAAM,GAAG,EAAE,GAAA,EAAI,EAAG,aAAY,IAAK,EAAA;AACpD,EAAA,MAAM,GAAA,GAA8B;AAAA,IAClC,EAAA,EAAI,IAAA;AAAA,IACJ,GAAA,EAAK,KAAA;AAAA,IACL,EAAA,EAAI,IAAA;AAAA,IACJ,GAAA,EAAK,KAAA;AAAA,IACL,GAAA,EAAK,IAAA;AAAA,IACL,GAAA,EAAK,IAAA;AAAA,IACL,EAAA,EAAI,QAAA;AAAA,IACJ,EAAA,EAAI,MAAA;AAAA,IACJ,EAAA,EAAI,IAAA;AAAA,IACJ,IAAA,EAAM,MAAA;AAAA,IACN,EAAA,EAAI,QAAA;AAAA,IACJ,EAAA,EAAI,IAAA;AAAA,IACJ,IAAA,EAAM;AAAA,GACR;AACA,EAAA,OAAO,GAAA,CAAI,GAAG,CAAA,IAAK,EAAA;AACrB","file":"chunk-L7GCJNDT.js","sourcesContent":["/**\n * Whether to send a ranked Context Capsule, paste the mapped tree, or send\n * neither. Independent of Model Execution Profiles (those describe how a\n * local model is run). Mass × greppability, not file count.\n *\n * See docs/graph/VG-CAPSULE-SMALL-REPO-DISABLE.md.\n */\n\nimport { queryGraph } from '../engine/query.js';\nimport { userAskFromInstruction } from '../engine/user-ask.js';\nimport type { VgGraph } from '../schema.js';\n\nexport type CapsuleMode = 'off' | 'whole-repo' | 'compile';\n\n/** Trees this small are cheaper to paste (or grep) than to rank. */\nexport const WHOLE_REPO_MAX_SOURCE_TOKENS = 1_500;\n/** Above this, discovery has a real bill — always compile. */\nexport const COMPILE_MIN_SOURCE_TOKENS = 8_000;\n\nexport function estimateSourceTokens(text: string): number {\n return Math.ceil(text.length / 4);\n}\n\n/** Unique mapped paths from the graph, stable order. */\nexport function mappedFilePaths(graph: VgGraph): string[] {\n const files = new Set<string>();\n for (const n of graph.nodes) {\n const f = normalize(n.file);\n if (!f || skipMappedPath(f)) continue;\n files.add(f);\n }\n return [...files].sort();\n}\n\nexport function sourceTokenMass(contents: Iterable<string>): number {\n let bytes = 0;\n for (const c of contents) bytes += c.length;\n return Math.ceil(bytes / 4);\n}\n\n/**\n * True when the mechanical fallback would pin an identifier the ask actually\n * names (F0/F1). Does not use the relevance module.\n */\nexport function askNamesSymbol(graph: VgGraph, instruction: string): boolean {\n const ask = userAskFromInstruction(instruction);\n const q = queryGraph(graph, ask, { budget: 400, limit: 8 });\n // Score 6 = camel-part; 10 = exact name. Substring hits (3) are not \"named\".\n return q.matches.some((m) => m.score >= 6);\n}\n\nexport function capsuleMode(input: { sourceTokens: number; askNamesSymbol: boolean }): CapsuleMode {\n const mass = Math.max(0, input.sourceTokens);\n if (mass <= WHOLE_REPO_MAX_SOURCE_TOKENS) return 'whole-repo';\n if (mass > COMPILE_MIN_SOURCE_TOKENS) return 'compile';\n // Modest mass: greppable asks lose to grep (measured). Symptom-only in this\n // band is unmeasured — fail closed to off.\n if (input.askNamesSymbol) return 'off';\n return 'off';\n}\n\nexport interface WholeRepoFile {\n path: string;\n content: string;\n}\n\nexport interface WholeRepoPacket {\n rendered: string;\n tokensEstimate: number;\n files: string[];\n sourceTokens: number;\n}\n\n/**\n * First-turn packet = the mapped files, not a ranked dump. Files are sorted\n * by path. `budget` caps the paste (default {@link WHOLE_REPO_MAX_SOURCE_TOKENS});\n * at least one file is always included when any exist.\n */\nexport function buildWholeRepoPacket(\n instruction: string,\n files: WholeRepoFile[],\n budget: number = WHOLE_REPO_MAX_SOURCE_TOKENS,\n): WholeRepoPacket {\n const sorted = [...files]\n .map((f) => ({ path: normalize(f.path), content: f.content }))\n .filter((f) => f.path && f.content.length > 0)\n .sort((a, b) => a.path.localeCompare(b.path));\n const sourceTokens = sourceTokenMass(sorted.map((f) => f.content));\n\n const lines: string[] = [\n '# Repository source (entire mapped tree)',\n '',\n 'The files below are the repository. Use them; search or read outside only if they are insufficient.',\n '',\n ];\n const included: string[] = [];\n for (const f of sorted) {\n const block = [`### \\`${f.path}\\``, `\\`\\`\\`${langFor(f.path)}`, f.content.replace(/\\n$/, ''), '```', ''];\n const candidate = [...lines, ...block, '## Task', instruction].join('\\n');\n if (included.length > 0 && estimateSourceTokens(candidate) > budget) break;\n lines.push(...block);\n included.push(f.path);\n }\n lines.push('## Task');\n lines.push(instruction);\n const rendered = lines.join('\\n');\n return {\n rendered,\n tokensEstimate: estimateSourceTokens(rendered),\n files: included,\n sourceTokens,\n };\n}\n\nfunction skipMappedPath(file: string): boolean {\n return (\n file.startsWith('node_modules/') ||\n file.includes('/node_modules/') ||\n file.startsWith('.git/') ||\n file.startsWith('.vibgrate/')\n );\n}\n\nfunction normalize(file: string): string {\n return file.replace(/\\\\/g, '/').replace(/^\\.\\//, '');\n}\n\nfunction langFor(file: string): string {\n const ext = file.split('.').pop()?.toLowerCase() ?? '';\n const map: Record<string, string> = {\n ts: 'ts',\n tsx: 'tsx',\n js: 'js',\n jsx: 'jsx',\n mjs: 'js',\n cjs: 'js',\n py: 'python',\n rs: 'rust',\n go: 'go',\n java: 'java',\n cs: 'csharp',\n md: 'md',\n json: 'json',\n };\n return map[ext] ?? '';\n}\n"]}
1
+ {"version":3,"sources":["../src/code/capsule-mode.ts"],"names":[],"mappings":";;;AAeO,IAAM,4BAAA,GAA+B;AAErC,IAAM,yBAAA,GAA4B;AAElC,SAAS,qBAAqB,IAAA,EAAsB;AACzD,EAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,MAAA,GA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AAAA,IACJ,IAAA,EAAM;AAAA,GACR;AACA,EAAA,OAAO,GAAA,CAAI,GAAG,CAAA,IAAK,EAAA;AACrB","file":"chunk-R5BGRJ6X.js","sourcesContent":["/**\n * Whether to send a ranked Context Capsule, paste the mapped tree, or send\n * neither. Independent of Model Execution Profiles (those describe how a\n * local model is run). Mass × greppability, not file count.\n *\n * See docs/graph/VG-CAPSULE-SMALL-REPO-DISABLE.md.\n */\n\nimport { queryGraph } from '../engine/query.js';\nimport { userAskFromInstruction } from '../engine/user-ask.js';\nimport type { VgGraph } from '../schema.js';\n\nexport type CapsuleMode = 'off' | 'whole-repo' | 'compile';\n\n/** Trees this small are cheaper to paste (or grep) than to rank. */\nexport const WHOLE_REPO_MAX_SOURCE_TOKENS = 1_500;\n/** Above this, discovery has a real bill — always compile. */\nexport const COMPILE_MIN_SOURCE_TOKENS = 8_000;\n\nexport function estimateSourceTokens(text: string): number {\n return Math.ceil(text.length / 4);\n}\n\n/** Unique mapped paths from the graph, stable order. */\nexport function mappedFilePaths(graph: VgGraph): string[] {\n const files = new Set<string>();\n for (const n of graph.nodes) {\n const f = normalize(n.file);\n if (!f || skipMappedPath(f)) continue;\n files.add(f);\n }\n return [...files].sort();\n}\n\nexport function sourceTokenMass(contents: Iterable<string>): number {\n let bytes = 0;\n for (const c of contents) bytes += c.length;\n return Math.ceil(bytes / 4);\n}\n\n/**\n * True when the mechanical fallback would pin an identifier the ask actually\n * names (F0/F1). Does not use the relevance module.\n */\nexport function askNamesSymbol(graph: VgGraph, instruction: string): boolean {\n const ask = userAskFromInstruction(instruction);\n const q = queryGraph(graph, ask, { budget: 400, limit: 8 });\n // Score 6 = camel-part; 10 = exact name. Substring hits (3) are not \"named\".\n return q.matches.some((m) => m.score >= 6);\n}\n\nexport function capsuleMode(input: { sourceTokens: number; askNamesSymbol: boolean }): CapsuleMode {\n const mass = Math.max(0, input.sourceTokens);\n if (mass <= WHOLE_REPO_MAX_SOURCE_TOKENS) return 'whole-repo';\n if (mass > COMPILE_MIN_SOURCE_TOKENS) return 'compile';\n // Modest mass: greppable asks lose to grep (measured). Symptom-only in this\n // band is unmeasured — fail closed to off.\n if (input.askNamesSymbol) return 'off';\n return 'off';\n}\n\nexport interface WholeRepoFile {\n path: string;\n content: string;\n}\n\nexport interface WholeRepoPacket {\n rendered: string;\n tokensEstimate: number;\n files: string[];\n sourceTokens: number;\n}\n\n/**\n * First-turn packet = the mapped files, not a ranked dump. Files are sorted\n * by path. `budget` caps the paste (default {@link WHOLE_REPO_MAX_SOURCE_TOKENS});\n * at least one file is always included when any exist.\n */\nexport function buildWholeRepoPacket(\n instruction: string,\n files: WholeRepoFile[],\n budget: number = WHOLE_REPO_MAX_SOURCE_TOKENS,\n): WholeRepoPacket {\n const sorted = [...files]\n .map((f) => ({ path: normalize(f.path), content: f.content }))\n .filter((f) => f.path && f.content.length > 0)\n .sort((a, b) => a.path.localeCompare(b.path));\n const sourceTokens = sourceTokenMass(sorted.map((f) => f.content));\n\n const lines: string[] = [\n '# Repository source (entire mapped tree)',\n '',\n 'The files below are the repository. Use them; search or read outside only if they are insufficient.',\n '',\n ];\n const included: string[] = [];\n for (const f of sorted) {\n const block = [`### \\`${f.path}\\``, `\\`\\`\\`${langFor(f.path)}`, f.content.replace(/\\n$/, ''), '```', ''];\n const candidate = [...lines, ...block, '## Task', instruction].join('\\n');\n if (included.length > 0 && estimateSourceTokens(candidate) > budget) break;\n lines.push(...block);\n included.push(f.path);\n }\n lines.push('## Task');\n lines.push(instruction);\n const rendered = lines.join('\\n');\n return {\n rendered,\n tokensEstimate: estimateSourceTokens(rendered),\n files: included,\n sourceTokens,\n };\n}\n\nfunction skipMappedPath(file: string): boolean {\n return (\n file.startsWith('node_modules/') ||\n file.includes('/node_modules/') ||\n file.startsWith('.git/') ||\n file.startsWith('.vibgrate/')\n );\n}\n\nfunction normalize(file: string): string {\n return file.replace(/\\\\/g, '/').replace(/^\\.\\//, '');\n}\n\nfunction langFor(file: string): string {\n const ext = file.split('.').pop()?.toLowerCase() ?? '';\n const map: Record<string, string> = {\n ts: 'ts',\n tsx: 'tsx',\n js: 'js',\n jsx: 'jsx',\n mjs: 'js',\n cjs: 'js',\n py: 'python',\n rs: 'rust',\n go: 'go',\n java: 'java',\n cs: 'csharp',\n md: 'md',\n json: 'json',\n };\n return map[ext] ?? '';\n}\n"]}
@@ -1,7 +1,7 @@
1
- import { probeFreshness, hasDrift, buildGraph, writeSnapshot } from './chunk-NS4DL3QR.js';
1
+ import { probeFreshness, hasDrift, buildGraph, writeSnapshot } from './chunk-BHDP7EVJ.js';
2
2
  import { mergeExcludes } from './chunk-RTURQXQL.js';
3
- import { acquireLock, releaseLock } from './chunk-FQHWPOTS.js';
4
- import { vibgrateDir, writeArtifacts } from './chunk-OIUVWCKM.js';
3
+ import { acquireLock, releaseLock } from './chunk-WU2DVESP.js';
4
+ import { vibgrateDir, writeArtifacts } from './chunk-K2IWOZEQ.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-VMPKOMHG.js.map
67
- //# sourceMappingURL=chunk-VMPKOMHG.js.map
66
+ //# sourceMappingURL=chunk-TKUWEJZJ.js.map
67
+ //# sourceMappingURL=chunk-TKUWEJZJ.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,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AAAA,QACA,WAAW,IAAA,CAAK,SAAA;AAAA,QAChB,MAAA,EAAW,EAAA,CAAA,UAAA,CAAgB,IAAA,CAAA,IAAA,CAAK,GAAA,EAAK,iBAAiB,CAAC,CAAA;AAAA,QACvD,IAAA,EAAS,EAAA,CAAA,UAAA,CAAgB,IAAA,CAAA,IAAA,CAAK,GAAA,EAAK,YAAY,CAAC;AAAA,OACjD,CAAA;AAAA,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-VMPKOMHG.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,EAA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,MAAA,EAAW,EAAA,CAAA,UAAA,CAAgB,IAAA,CAAA,IAAA,CAAK,GAAA,EAAK,iBAAiB,CAAC,CAAA;AAAA,QACvD,IAAA,EAAS,EAAA,CAAA,UAAA,CAAgB,IAAA,CAAA,IAAA,CAAK,GAAA,EAAK,YAAY,CAAC;AAAA,OACjD,CAAA;AAAA,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-TKUWEJZJ.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,7 +1,7 @@
1
1
  import { redactSecrets, catalogForLanguage, sourceHasRoleNeedle } from './chunk-T7RSQ5WD.js';
2
2
  import { LANGUAGES, langById } from './chunk-6WRG7VDO.js';
3
3
  import { loadCache } from './chunk-MVPRPSXU.js';
4
- import { VERSION } from './chunk-G3ACLBMG.js';
4
+ import { VERSION } from './chunk-JQ7OL4XG.js';
5
5
  import { hashString } from './chunk-JFGYT6BI.js';
6
6
  import * as fs from 'fs';
7
7
  import * as path from 'path';
@@ -1215,5 +1215,5 @@ function dedupeImports(imports) {
1215
1215
  }
1216
1216
 
1217
1217
  export { TOOLCHAIN_GRAMMARS, fileRolesFromParseCache, fileRolesFromParses, grammarSetVersion, grammarsSourceDir, parseSource, resetParser, resolveToolchainGrammar, resolvedGrammarFiles, setGrammarsOverride, toolchainGrammarSetVersion, toolchainParser };
1218
- //# sourceMappingURL=chunk-6MIJLO5B.js.map
1219
- //# sourceMappingURL=chunk-6MIJLO5B.js.map
1218
+ //# sourceMappingURL=chunk-TOHNVUDD.js.map
1219
+ //# sourceMappingURL=chunk-TOHNVUDD.js.map