@vibgrate/cli 2026.825.1 → 2026.825.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/{agent-IHNUBFBM.js → agent-DHQYEHVW.js} +13 -13
  2. package/dist/{agent-IHNUBFBM.js.map → agent-DHQYEHVW.js.map} +1 -1
  3. package/dist/{approvals-HRIMDIX3.js → approvals-KBM72NU2.js} +5 -5
  4. package/dist/{approvals-HRIMDIX3.js.map → approvals-KBM72NU2.js.map} +1 -1
  5. package/dist/{attach-L43JUJ7A.js → attach-O74NL4M5.js} +3 -3
  6. package/dist/{attach-L43JUJ7A.js.map → attach-O74NL4M5.js.map} +1 -1
  7. package/dist/{baseline-EZQ7SCRT.js → baseline-4X6MQBDA.js} +3 -3
  8. package/dist/{baseline-EZQ7SCRT.js.map → baseline-4X6MQBDA.js.map} +1 -1
  9. package/dist/{chunk-X34HVFZ6.js → chunk-27TS2AUJ.js} +8 -8
  10. package/dist/{chunk-X34HVFZ6.js.map → chunk-27TS2AUJ.js.map} +1 -1
  11. package/dist/{chunk-RHYRMMN3.js → chunk-2NUS5BOR.js} +3 -3
  12. package/dist/{chunk-RHYRMMN3.js.map → chunk-2NUS5BOR.js.map} +1 -1
  13. package/dist/{chunk-TLYNLQL2.js → chunk-3E7QT4NE.js} +9 -9
  14. package/dist/{chunk-TLYNLQL2.js.map → chunk-3E7QT4NE.js.map} +1 -1
  15. package/dist/{chunk-L3YEEJ6U.js → chunk-6MIJLO5B.js} +3 -3
  16. package/dist/{chunk-L3YEEJ6U.js.map → chunk-6MIJLO5B.js.map} +1 -1
  17. package/dist/{chunk-5BFA532E.js → chunk-7M4E7UGX.js} +3 -3
  18. package/dist/{chunk-5BFA532E.js.map → chunk-7M4E7UGX.js.map} +1 -1
  19. package/dist/{chunk-M7O6IVKN.js → chunk-BICZR6UJ.js} +3 -3
  20. package/dist/{chunk-M7O6IVKN.js.map → chunk-BICZR6UJ.js.map} +1 -1
  21. package/dist/{chunk-BCK2NIBM.js → chunk-DIZ5KI5Q.js} +6 -6
  22. package/dist/{chunk-BCK2NIBM.js.map → chunk-DIZ5KI5Q.js.map} +1 -1
  23. package/dist/{chunk-QTQRM7HQ.js → chunk-E3XVIFSH.js} +3 -3
  24. package/dist/{chunk-QTQRM7HQ.js.map → chunk-E3XVIFSH.js.map} +1 -1
  25. package/dist/{chunk-B5X246UH.js → chunk-FQHWPOTS.js} +3 -3
  26. package/dist/{chunk-B5X246UH.js.map → chunk-FQHWPOTS.js.map} +1 -1
  27. package/dist/chunk-G3ACLBMG.js +6 -0
  28. package/dist/{chunk-KFLNWYZG.js.map → chunk-G3ACLBMG.js.map} +1 -1
  29. package/dist/{chunk-CIC3NY2D.js → chunk-GR7SFCQJ.js} +12 -12
  30. package/dist/{chunk-CIC3NY2D.js.map → chunk-GR7SFCQJ.js.map} +1 -1
  31. package/dist/{chunk-Y3X3ORQ3.js → chunk-GWSJYDK7.js} +5 -5
  32. package/dist/{chunk-Y3X3ORQ3.js.map → chunk-GWSJYDK7.js.map} +1 -1
  33. package/dist/{chunk-ECQFRZJI.js → chunk-HFQIYM6E.js} +4 -4
  34. package/dist/{chunk-ECQFRZJI.js.map → chunk-HFQIYM6E.js.map} +1 -1
  35. package/dist/{chunk-GRMZU24V.js → chunk-IJVWKZRS.js} +3 -3
  36. package/dist/{chunk-GRMZU24V.js.map → chunk-IJVWKZRS.js.map} +1 -1
  37. package/dist/{chunk-YIRDV4YJ.js → chunk-JAEHLTVX.js} +3 -3
  38. package/dist/{chunk-YIRDV4YJ.js.map → chunk-JAEHLTVX.js.map} +1 -1
  39. package/dist/{chunk-LUJ4H4RJ.js → chunk-K3SXWOTT.js} +3 -3
  40. package/dist/{chunk-LUJ4H4RJ.js.map → chunk-K3SXWOTT.js.map} +1 -1
  41. package/dist/{chunk-JSZ46IDG.js → chunk-KYM55VZX.js} +6 -6
  42. package/dist/{chunk-JSZ46IDG.js.map → chunk-KYM55VZX.js.map} +1 -1
  43. package/dist/{chunk-YP243ZKD.js → chunk-L7GCJNDT.js} +3 -3
  44. package/dist/{chunk-YP243ZKD.js.map → chunk-L7GCJNDT.js.map} +1 -1
  45. package/dist/{chunk-UUVOA6WD.js → chunk-NS4DL3QR.js} +8 -8
  46. package/dist/{chunk-UUVOA6WD.js.map → chunk-NS4DL3QR.js.map} +1 -1
  47. package/dist/{chunk-S3HMG6BC.js → chunk-NZES47ST.js} +3 -3
  48. package/dist/{chunk-S3HMG6BC.js.map → chunk-NZES47ST.js.map} +1 -1
  49. package/dist/{chunk-FVBN4E5C.js → chunk-OIUVWCKM.js} +3 -3
  50. package/dist/{chunk-FVBN4E5C.js.map → chunk-OIUVWCKM.js.map} +1 -1
  51. package/dist/{chunk-DLNNNESQ.js → chunk-SIXWWQ6S.js} +3 -3
  52. package/dist/{chunk-DLNNNESQ.js.map → chunk-SIXWWQ6S.js.map} +1 -1
  53. package/dist/{chunk-6VLOI2ZP.js → chunk-SYMJSRYF.js} +3 -3
  54. package/dist/{chunk-6VLOI2ZP.js.map → chunk-SYMJSRYF.js.map} +1 -1
  55. package/dist/{chunk-LKJIYGO5.js → chunk-TT2J2TB6.js} +6 -6
  56. package/dist/{chunk-LKJIYGO5.js.map → chunk-TT2J2TB6.js.map} +1 -1
  57. package/dist/{chunk-4PCFSRYH.js → chunk-VMPKOMHG.js} +5 -5
  58. package/dist/{chunk-4PCFSRYH.js.map → chunk-VMPKOMHG.js.map} +1 -1
  59. package/dist/cli.js +49 -49
  60. package/dist/{daemon-WPX2SBVV.js → daemon-RZS5FPIW.js} +9 -9
  61. package/dist/{daemon-WPX2SBVV.js.map → daemon-RZS5FPIW.js.map} +1 -1
  62. package/dist/embed-worker-main.js +3 -3
  63. package/dist/{ensure-map-MLI4XCRV.js → ensure-map-DL2S774J.js} +14 -14
  64. package/dist/{ensure-map-MLI4XCRV.js.map → ensure-map-DL2S774J.js.map} +1 -1
  65. package/dist/{graph-backend-LK5EFQXN.js → graph-backend-JXARVT3R.js} +7 -7
  66. package/dist/{graph-backend-LK5EFQXN.js.map → graph-backend-JXARVT3R.js.map} +1 -1
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.js +15 -15
  69. package/dist/{interactive-K446F42I.js → interactive-2XRBRFRB.js} +25 -25
  70. package/dist/{interactive-K446F42I.js.map → interactive-2XRBRFRB.js.map} +1 -1
  71. package/dist/load-7C5VETRD.js +11 -0
  72. package/dist/{load-2FRH37JY.js.map → load-7C5VETRD.js.map} +1 -1
  73. package/dist/parse-worker.js +2 -2
  74. package/dist/{run-outcome-4ETNDPX6.js → run-outcome-TMB5TJNA.js} +5 -5
  75. package/dist/{run-outcome-4ETNDPX6.js.map → run-outcome-TMB5TJNA.js.map} +1 -1
  76. package/dist/{runtime-session-RMSKXFIJ.js → runtime-session-Y23NVY7R.js} +9 -9
  77. package/dist/{runtime-session-RMSKXFIJ.js.map → runtime-session-Y23NVY7R.js.map} +1 -1
  78. package/dist/{session-22BGDYWF.js → session-KXT2ZTPE.js} +8 -8
  79. package/dist/{session-22BGDYWF.js.map → session-KXT2ZTPE.js.map} +1 -1
  80. package/dist/{stream-json-MD7MSSCH.js → stream-json-NW6AOE47.js} +13 -13
  81. package/dist/{stream-json-MD7MSSCH.js.map → stream-json-NW6AOE47.js.map} +1 -1
  82. package/dist/version-7ABYXWOZ.js +4 -0
  83. package/dist/{version-FRUT6RI2.js.map → version-7ABYXWOZ.js.map} +1 -1
  84. package/dist/{vg-mcp-bridge-H6I3ALUW.js → vg-mcp-bridge-LXBHKEFR.js} +8 -8
  85. package/dist/{vg-mcp-bridge-H6I3ALUW.js.map → vg-mcp-bridge-LXBHKEFR.js.map} +1 -1
  86. package/dist/{vgd-TW7HU2PH.js → vgd-RW7HCEIP.js} +8 -8
  87. package/dist/vgd-RW7HCEIP.js.map +1 -0
  88. package/package.json +1 -1
  89. package/dist/chunk-KFLNWYZG.js +0 -6
  90. package/dist/load-2FRH37JY.js +0 -11
  91. package/dist/version-FRUT6RI2.js +0 -4
  92. package/dist/vgd-TW7HU2PH.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/engine/relations.ts","../src/engine/user-ask.ts","../src/engine/query.ts","../src/engine/impact.ts"],"names":["push","text","round"],"mappings":";;;AAGO,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAAqB,KAAA,EAAgB;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AACnB,IAAA,KAAA,MAAW,CAAA,IAAK,MAAM,KAAA,EAAO,IAAA,CAAK,SAAS,GAAA,CAAI,CAAA,CAAE,IAAI,CAAC,CAAA;AACtD,IAAA,KAAA,MAAW,CAAA,IAAK,MAAM,KAAA,EAAO;AAC3B,MAAA,IAAA,CAAK,IAAA,CAAK,OAAA,EAAS,CAAA,CAAE,GAAA,EAAK,CAAC,CAAA;AAC3B,MAAA,IAAA,CAAK,IAAA,CAAK,MAAA,EAAQ,CAAA,CAAE,GAAA,EAAK,CAAC,CAAA;AAAA,IAC5B;AAAA,EACF;AAAA,EANqB,KAAA;AAAA,EAJZ,QAAA,uBAAe,GAAA,EAAuB;AAAA,EACvC,OAAA,uBAAc,GAAA,EAAyB;AAAA,EACvC,MAAA,uBAAa,GAAA,EAAyB;AAAA,EAU9C,GAAA,CAAI,IAAY,IAAA,EAA8B;AAC5C,IAAA,MAAM,MAAM,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,EAAE,KAAK,EAAC;AACrC,IAAA,OAAO,IAAA,GAAO,IAAI,MAAA,CAAO,CAAC,MAAM,CAAA,CAAE,IAAA,KAAS,IAAI,CAAA,GAAI,GAAA;AAAA,EACrD;AAAA,EAEA,EAAA,CAAG,IAAY,IAAA,EAA8B;AAC3C,IAAA,MAAM,MAAM,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,EAAE,KAAK,EAAC;AACpC,IAAA,OAAO,IAAA,GAAO,IAAI,MAAA,CAAO,CAAC,MAAM,CAAA,CAAE,IAAA,KAAS,IAAI,CAAA,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AAU,CAAC,CAAA,CAAE,MAAA;AAAA,IAC3C,UAAA,EAAY,MAAM,MAAA,CAAO,CAAC,MAAM,CAAA,CAAE,KAAA,GAAQ,CAAC,CAAA,CAAE,MAAA;AAAA,IAC7C,iBAAA,EAAmBA,OAAM,iBAAiB;AAAA,GAC5C;AACF;AAEA,SAASA,OAAM,CAAA,EAAmB;AAChC,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,CAAA,GAAI,GAAG,CAAA,GAAI,GAAA;AAC/B","file":"chunk-LUJ4H4RJ.js","sourcesContent":["import type { EdgeKind, GraphEdge, GraphNode, VgGraph } from '../schema.js';\n\n/** Indexes over a graph for O(1) neighbor lookups (built once per command). */\nexport class GraphIndex {\n readonly nodeById = new Map<string, GraphNode>();\n private outById = new Map<string, GraphEdge[]>();\n private inById = new Map<string, GraphEdge[]>();\n\n constructor(readonly graph: VgGraph) {\n for (const n of graph.nodes) this.nodeById.set(n.id, n);\n for (const e of graph.edges) {\n push(this.outById, e.src, e);\n push(this.inById, e.dst, e);\n }\n }\n\n out(id: string, kind?: EdgeKind): GraphEdge[] {\n const all = this.outById.get(id) ?? [];\n return kind ? all.filter((e) => e.kind === kind) : all;\n }\n\n in(id: string, kind?: EdgeKind): GraphEdge[] {\n const all = this.inById.get(id) ?? [];\n return kind ? all.filter((e) => e.kind === kind) : all;\n }\n\n node(id: string): GraphNode | undefined {\n return this.nodeById.get(id);\n }\n\n /**\n * Resolved nodes called by `id` — invocations (`call`) plus structural\n * dependency references (`references`, e.g. a constructor-injected field's\n * type), since both represent real usage a caller/impact question cares\n * about. `references` is otherwise only emitted by the precise SCIP/tsc\n * rungs and (for Java DI wiring) the heuristic rung — never a guess.\n */\n callees(id: string): { edge: GraphEdge; node: GraphNode }[] {\n return this.resolveTargets(this.out(id).filter(isUsageEdge), 'dst');\n }\n\n /** Resolved nodes that call or structurally reference `id`. */\n callers(id: string): { edge: GraphEdge; node: GraphNode }[] {\n return this.resolveTargets(this.in(id).filter(isUsageEdge), 'src');\n }\n\n private resolveTargets(edges: GraphEdge[], end: 'src' | 'dst') {\n const out: { edge: GraphEdge; node: GraphNode }[] = [];\n for (const e of edges) {\n const node = this.nodeById.get(e[end]);\n if (node) out.push({ edge: e, node });\n }\n return out;\n }\n}\n\nconst USAGE_KINDS: ReadonlySet<EdgeKind> = new Set(['call', 'references']);\nfunction isUsageEdge(e: GraphEdge): boolean {\n return USAGE_KINDS.has(e.kind);\n}\n\nfunction push(map: Map<string, GraphEdge[]>, key: string, value: GraphEdge): void {\n const list = map.get(key);\n if (list) list.push(value);\n else map.set(key, [value]);\n}\n\n/**\n * Memoized `GraphIndex`, keyed on the graph object's identity.\n *\n * The index (node-by-id + in/out adjacency) is a pure function of the graph's\n * content, and every read path rebuilds it from scratch — an O(nodes + edges)\n * pass that, on a large map, costs hundreds of milliseconds *per query*. Under\n * `vg serve` the same parsed graph object is reused across many tool calls\n * (`GraphSource` caches it by file mtime and only replaces the reference when\n * `graph.json` actually changes), so rebuilding the index on every call is pure\n * waste. Keying a `WeakMap` on that object identity builds the index once and\n * reuses it until the file is rebuilt — at which point `GraphSource` hands back a\n * *new* object, this map misses, and the stale index is collected with the old\n * graph. Correct and stale-safe by construction: a different graph is a\n * different object, so there is no cross-graph reuse and nothing to invalidate.\n *\n * `GraphIndex` is read-only (no method mutates its maps), so sharing one\n * instance across callers is safe.\n */\nconst INDEX_CACHE = new WeakMap<VgGraph, GraphIndex>();\n\nexport function indexFor(graph: VgGraph): GraphIndex {\n let idx = INDEX_CACHE.get(graph);\n if (!idx) {\n idx = new GraphIndex(graph);\n INDEX_CACHE.set(graph, idx);\n }\n return idx;\n}\n","/**\n * Split the user's ask from host-injected attachment metadata.\n *\n * The VS Code panel (`codeAttachments.ts`) and other hosts append a markdown\n * block after a `---` fence:\n *\n * ## User attachments (always include in your reasoning for this turn)\n * ### Attached image: `image.png`\n * … saved at: `.vibgrate/code-attachments/…`\n *\n * Those backticks are for the model. If the full instruction is fed into\n * {@link extractLiteralNeedles} / seed ranking, attachment basenames and paths\n * become **literal-locate hard constraints** (\"0 hits → finish, do not invent\n * an edit\") and the agent aborts a real coding task. Field report: version-badge\n * health UI with a screenshot — agent searched for `image.png` and stopped.\n *\n * Retrieval, needle pinning, locate-only detection, and relevance analysis must\n * use {@link userAskFromInstruction}. The full instruction (with attachments)\n * still belongs in the Task / user message so the model can see the appendix.\n */\n\n/** Heading written by hosts when packing panel attachments into the instruction. */\nexport const USER_ATTACHMENTS_HEADING_PREFIX = '## User attachments';\n\n/**\n * Return only the user-authored portion of an instruction, dropping a trailing\n * host \"User attachments\" appendix when present. Unchanged when no appendix.\n */\nexport function userAskFromInstruction(instruction: string): string {\n if (!instruction) return instruction;\n\n // Canonical host shape: blank line, --- fence, then the attachments heading.\n const fenced = /\\n---\\s*\\n## User attachments\\b[^\\n]*\\n?/;\n const m = fenced.exec(instruction);\n if (m && m.index != null) {\n return instruction.slice(0, m.index).trimEnd();\n }\n\n // Defensive: heading without the fence (older hosts / hand-edited prompts).\n const bare = instruction.search(/(?:^|\\n)## User attachments\\b/);\n if (bare > 0) {\n return instruction.slice(0, bare).trimEnd();\n }\n if (bare === 0) {\n // Instruction is only the appendix — no user ask left.\n return '';\n }\n\n return instruction;\n}\n","import { indexFor, type GraphIndex } from './relations.js';\nimport { cosine, type Embedder } from './embeddings.js';\nimport type { SanitizedRank } from './relevance-provider.js';\nimport type { GraphNode, VgGraph } from '../schema.js';\nimport { userAskFromInstruction } from './user-ask.js';\n\n/**\n * Retrieval front-end for `vg ask` / `vg code` capsule seeds (VG-CLI-SPEC\n * §3.2).\n *\n * Since the 2026-08 relevance relocation, the RANKING ENGINE lives in the\n * optional relevance module (`@vibgrate/relevance`, auto-provisioned): the\n * async callers run the ask through the module via\n * `relevance-provider.rankQuestion` and pass the SANITIZED result in as\n * `options.ranked`. This file keeps only what is mechanical:\n *\n * - literal string/URL needle handling (the locate path — exact-text\n * matching, not relevance);\n * - a deliberately dumb module-less fallback: exact identifier-name and\n * name-part matching, nothing that understands language (no lexicon, no\n * term roles, no IDF, no typo repair, no expansion) — enough that an ask\n * NAMING a symbol still pins its file when the module is unavailable;\n * - context-block rendering and the semantic Reciprocal Rank Fusion\n * plumbing (`--semantic`), which fuses ORDERINGS and carries no ranking\n * heuristics of its own.\n */\n\nexport interface QueryOptions {\n budget?: number; // approx token budget for the context block (default 2000)\n limit?: number; // max seed matches to expand (default 12)\n /** Sanitized module ranking (engine/relevance-provider.ts rankQuestion),\n * injected by async callers so this module stays pure and sync. When\n * absent — module not installed, predates the ranking API, or failed —\n * the mechanical fallback below answers. */\n ranked?: SanitizedRank | null;\n}\n\nexport interface QueryMatch {\n node: GraphNode;\n score: number;\n why: string;\n}\n\nexport interface QueryResult {\n question: string;\n matches: QueryMatch[];\n context: string;\n tokensEstimate: number;\n}\n\n/**\n * Function-word hygiene for the mechanical fallback tokenizer. This is NOT a\n * relevance stopword model (that moved into the module): nothing here scores,\n * ranks, weights, or reorders anything. It is a purely SUBTRACTIVE floor —\n * the words a caller uses to FRAME an ask rather than to name the code they\n * mean, which therefore cannot be identifier evidence.\n *\n * The floor exists because `mechanicalRank` treats every surviving token as\n * equal evidence, and English framing words collide with real identifier\n * parts constantly. Without it, `\"add a new feature\"` scores `AddBlogForm`\n * on the camel-part tier (`add`) and `FeatureFlagStore` (`feature`) and fills\n * the entire seed window — a grab-bag Task Capsule for an ask that named\n * nothing. That is the capsule-poisoning failure of the 2026-07 field report,\n * and an empty result is the correct answer.\n *\n * Note this is the floor ONLY. Deciding which of several genuine candidates\n * is most relevant remains the module's job, and no part of that logic —\n * term roles, weighting, expansion, morphology — belongs in this file.\n */\nconst FUNCTION_WORDS = new Set([\n // Closed-class English: could only ever match by coincidence.\n 'the', 'a', 'an', 'is', 'are', 'was', 'were', 'be', 'to', 'of', 'in', 'on', 'for', 'and', 'or',\n 'where', 'what', 'which', 'how', 'do', 'does', 'did', 'i', 'we', 'it', 'this', 'that', 'with',\n 'when', 'who', 'why', 'can', 'should', 'my', 'our', 'you', 'your', 'from', 'by', 'at', 'as',\n // Process verbs. A caller says what they want DONE with these; they never\n // name the code it should be done to. Left in, bare `add` seeds every\n // Add*/*Add* symbol in the repo ahead of the terms that carry the subject.\n 'add', 'adds', 'added', 'adding',\n 'create', 'creates', 'created', 'creating',\n 'make', 'makes', 'making', 'made',\n 'remove', 'removes', 'removed', 'removing',\n 'delete', 'deletes', 'deleted', 'deleting',\n 'update', 'updates', 'updated', 'updating',\n 'change', 'changes', 'changed', 'changing',\n 'set', 'sets', 'setting', 'setup', 'get', 'gets', 'getting',\n 'use', 'uses', 'used', 'using', 'want', 'wants', 'wanted', 'doing', 'done',\n 'support', 'supports', 'supported', 'supporting',\n 'enable', 'enables', 'enabled', 'enabling',\n 'disable', 'disables', 'disabled', 'disabling',\n 'allow', 'allows', 'allowed', 'handle', 'handles', 'handling',\n 'implement', 'implements', 'implemented', 'implementing',\n 'build', 'builds', 'building', 'built', 'need', 'needs', 'needed',\n // Filler nouns and connectives: the generic scaffolding of a request.\n 'new', 'newly', 'via', 'through', 'into', 'onto',\n 'way', 'ways', 'thing', 'things', 'stuff',\n 'feature', 'features', 'functionality',\n 'method', 'methods', 'option', 'options', 'ability',\n 'form', 'forms', 'page', 'pages', 'screen', 'screens', 'button', 'buttons',\n 'help', 'start', 'begin', 'work', 'works', 'working',\n 'also', 'currently', 'properly', 'correctly', 'please',\n 'happens', 'happen', 'something', 'somewhere',\n 'step', 'steps', 'flow', 'process',\n // Discovery-question scaffolding: words that FRAME the search itself\n // (\"find the code responsible for X\", \"explain how X works\").\n 'find', 'code', 'responsible', 'modify', 'me',\n 'implementation', 'explain', 'codebase', 'contains', 'file',\n // Bug-report framing: says something is WRONG, never what is wrong.\n // `fix` alone lit up `export_fixed_width_records`, `out` lit up every\n // *Router*/*rollout* symbol (vg code prompt-relevance corpus).\n 'fix', 'fixes', 'fixing', 'bug', 'bugs', 'broken', 'busted', 'borked',\n 'wrong', 'incorrect', 'incorrectly', 'figure', 'out', 'sure',\n]);\n\n/**\n * Strip sentence punctuation from a URL match without breaking real query\n * strings (`?key=value`). A lone trailing `?` / `!` is English punctuation\n * (\"where is https://…/signup?\") — leaving it in the needle makes the literal\n * sweep miss the bare path in source.\n */\nfunction cleanUrlNeedle(raw: string): string {\n let s = raw.trim();\n // Trailing ) ] } > , ; : ! . from markdown links / sentence ends.\n s = s.replace(/[.,;:!)\\]}>]+$/g, '');\n // Lone trailing `?` → drop. Keep `?key=…` (content after `?`).\n if (s.endsWith('?')) {\n const qi = s.lastIndexOf('?');\n if (qi === s.length - 1) s = s.slice(0, -1);\n }\n return s;\n}\n\n/**\n * Extract string/URL needles a caller is asking to *locate as text*, not as\n * bag-of-words symbol terms. URLs and quoted phrases are exact-match material\n * for the literal sweep (`search_symbols` / `search_code`); feeding their path\n * segments into lexical symbol ranking produces confidently wrong seeds\n * (dash → dashboard package, exist → NonExisting, …).\n */\nexport function extractLiteralNeedles(question: string): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n const push = (raw: string, kind: 'url' | 'quote') => {\n let s = raw.trim();\n s = kind === 'url' ? cleanUrlNeedle(s) : s.replace(/[.,;:!)\\]}>?]+$/g, '');\n if (s.length < 2 || seen.has(s)) return;\n seen.add(s);\n out.push(s);\n };\n for (const m of question.matchAll(/https?:\\/\\/[^\\s\"'`<>]+/gi)) push(m[0]!, 'url');\n for (const m of question.matchAll(/([\"'`])((?:(?!\\1)[^\\\\]|\\\\.){2,})\\1/g)) {\n push(m[2]!.replace(/\\\\(.)/g, '$1'), 'quote');\n }\n return out;\n}\n\n/** Question text with URL/quoted needles removed so residual tokens can name symbols. */\nexport function stripLiteralNeedles(question: string): string {\n let s = question;\n // Strip raw URL spans first (may still carry a trailing `?` from the ask).\n for (const m of question.matchAll(/https?:\\/\\/[^\\s\"'`<>]+/gi)) {\n s = s.split(m[0]!).join(' ');\n }\n for (const lit of extractLiteralNeedles(question)) {\n s = s.split(lit).join(' ');\n }\n // Also strip bare quote pairs left behind.\n s = s.replace(/([\"'`])\\s*\\1/g, ' ');\n return s.replace(/\\s+/g, ' ').trim();\n}\n\n/**\n * Residual ask used for graph symbol ranking when the question embeds a\n * URL/quote. Empty when only framing words remain (\"where is …?\") so we do\n * not light up unrelated symbols like `applyPlan.where`.\n */\nexport function residualForSymbolSearch(question: string): string {\n const literals = extractLiteralNeedles(question);\n if (literals.length === 0) return question.trim();\n const stripped = stripLiteralNeedles(question);\n return tokenize(stripped).length === 0 ? '' : stripped;\n}\n\n/**\n * True when the instruction is a string/URL occurrence locate (not an edit).\n * Used to skip PatchIR grammar and answer from the literal sweep without\n * dumping constrained-decoding JSON into the VG Code panel.\n */\nexport function isLocateOnlyInstruction(instruction: string): boolean {\n // Drop host-injected \"User attachments\" appendix (backticked image paths)\n // before classify — same rule as buildCodeContext. Avoids treating a screenshot\n // filename as a locate-only occurrence search.\n const q = userAskFromInstruction(instruction).trim();\n if (!q) return false;\n const needles = extractLiteralNeedles(q);\n const hasLocateFrame =\n /\\b(where\\s+is|where\\s+are|find\\s+(all\\s+|every\\s+)?occurrence|find\\s+occurrences|does\\s+not\\s+exist|locate|search\\s+for)\\b/i.test(\n q,\n ) ||\n (needles.length > 0 && /^https?:\\/\\//i.test(q));\n // Strong edit verbs cancel locate-only (ignore \"does not exist\" as non-edit).\n const withoutExist = q.replace(/\\bdoes\\s+not\\s+exist\\b/gi, ' ');\n if (\n /\\b(fix|edit|change|replace|implement|refactor|rename|patch|create\\s+file|delete\\s+file|add\\s+a\\b|remove\\s+the\\b)\\b/i.test(\n withoutExist,\n )\n ) {\n return false;\n }\n if (needles.some((n) => /^https?:\\/\\//i.test(n))) return true;\n return hasLocateFrame && needles.length > 0;\n}\n\nexport function queryGraph(graph: VgGraph, question: string, options: QueryOptions = {}): QueryResult {\n const budget = options.budget ?? 2000;\n const limit = options.limit ?? 12;\n const literals = extractLiteralNeedles(question);\n const index = indexFor(graph);\n\n let seeds: QueryMatch[];\n if (options.ranked) {\n // Module ranking (already sanitized: every id names a real symbol).\n // An honest miss from the engine stays an honest miss here.\n const byId = new Map<string, GraphNode>();\n for (const node of graph.nodes) byId.set(node.id, node);\n seeds = options.ranked.hasContent\n ? options.ranked.seeds\n .map((s) => {\n const node = byId.get(s.id);\n return node ? { node, score: s.score, why: s.why } : null;\n })\n .filter((m): m is QueryMatch => m !== null)\n .slice(0, limit)\n : [];\n } else {\n seeds = mechanicalRank(graph, question, literals).slice(0, limit);\n }\n\n const { context, tokensEstimate } = buildContext(graph, index, question, seeds, budget, literals);\n return { question, matches: seeds, context, tokensEstimate };\n}\n\n/**\n * The module-less fallback: mechanical identifier matching, deliberately free\n * of language understanding. A token scores only when it IS a symbol's name,\n * one of its camel/snake parts, or (length ≥ 4) a substring of the qualified\n * name — so \"write tests for chargeCard\" or a pasted `src/…/File.ts` path\n * still pins the right file, while intent phrasings honestly miss until the\n * relevance module is available. No lexicon, no term roles, no IDF, no typo\n * repair, no expansions — that is the module's job now.\n */\nfunction mechanicalRank(graph: VgGraph, question: string, literals: string[]): QueryMatch[] {\n const forTokens = literals.length > 0 ? stripLiteralNeedles(question) : question;\n let tokens = tokenize(forTokens);\n // A literal ask's residual framing (\"does not exist\", \"find occurrences\")\n // must not light up DoesNot*/NonExisting*/commandExists lookalikes — the\n // honest-miss contract of the locate path holds module-less too.\n if (literals.length > 0) tokens = tokens.filter((t) => !LOCATE_SCAFFOLD.has(t));\n if (tokens.length === 0) return [];\n const scored: QueryMatch[] = [];\n for (const node of graph.nodes) {\n if (node.kind === 'file' || node.kind === 'external') continue;\n const name = node.name.toLowerCase();\n const qn = node.qualifiedName.toLowerCase();\n const parts = identifierParts(node.name);\n let score = 0;\n const hits: string[] = [];\n for (const t of tokens) {\n if (name === t) {\n score += 10;\n hits.push(t);\n } else if (parts.has(t)) {\n score += 6;\n hits.push(t);\n } else if (t.length >= 4 && qn.includes(t)) {\n score += 3;\n hits.push(t);\n }\n }\n if (score > 0) {\n scored.push({\n node,\n score: round(score * (1 + IMPORTANCE_WEIGHT * node.importance)),\n why: `matched: ${hits.join(', ')}`,\n });\n }\n }\n scored.sort((a, b) => b.score - a.score || a.node.qualifiedName.localeCompare(b.node.qualifiedName));\n return diversifyByFile(scored);\n}\n\nfunction tokenize(q: string): string[] {\n return [\n ...new Set(\n q\n .toLowerCase()\n .split(/[^\\p{L}\\p{N}]+/u)\n .filter((t) => t.length >= 1 && !FUNCTION_WORDS.has(t)),\n ),\n ];\n}\n\n/**\n * Importance is a mild tiebreaker, not a doubling: at 0.4 a top hub adds at\n * most 40%, enough to break genuine ties without overriding term evidence.\n */\nconst IMPORTANCE_WEIGHT = 0.4;\n\n/** Residual framing of a string/URL locate ask — never symbol evidence. */\nconst LOCATE_SCAFFOLD = new Set([\n 'not', 'no', 'exist', 'exists', 'existing', 'occurrence', 'occurrences',\n 'occurence', 'occurences', 'find', 'every', 'place', 'places', 'string',\n 'literal', 'text', 'search', 'locate', 'look', 'looking', 'show', 'list', 'all',\n]);\n\n/**\n * Stable file-diversity pass over the ranked list: each file's best node\n * keeps its rank; further nodes from an already-represented file are demoted\n * behind the first representative of every other matching file (never\n * dropped). Mechanical presentation hygiene — the seed window is a coverage\n * budget either way.\n */\nfunction diversifyByFile(matches: QueryMatch[]): QueryMatch[] {\n const seen = new Set<string>();\n const firstPerFile: QueryMatch[] = [];\n const rest: QueryMatch[] = [];\n for (const m of matches) {\n if (seen.has(m.node.file)) {\n rest.push(m);\n } else {\n seen.add(m.node.file);\n firstPerFile.push(m);\n }\n }\n return firstPerFile.concat(rest);\n}\n\nexport interface SemanticQueryOptions extends QueryOptions {\n /** Local embedder. Optional only when {@link semanticRanked} supplies the pass. */\n embedder?: Embedder;\n /** Precomputed node vectors (from getNodeEmbeddings); falls back to lexical for nodes without one. */\n nodeVectors?: Map<string, number[]>;\n /**\n * A semantic pass someone else already ran — vgd ranking the question\n * against its resident slot index. Supplied instead of `embedder` +\n * `nodeVectors` so the caller pays neither a model load nor a vector scan,\n * and no vectors cross the socket.\n *\n * Only the ORDER of this list is consumed (RRF fuses rankings, not scores),\n * so a truncated top-K is not an approximation: a candidate ranked past a\n * few hundred cannot reach a 12-row answer.\n */\n semanticRanked?: Array<{ id: string; score: number }>;\n}\n\n/**\n * Reciprocal Rank Fusion constant (the standard k=60). Fusing RANKINGS\n * instead of blending raw scores removes the need to calibrate two\n * incomparable scales: a node's fused score is Σ 1/(k + rankᵢ) over the\n * lists it appears in, so agreement between signals dominates and a single\n * signal's outlier magnitude cannot.\n */\nconst RRF_K = 60;\n\n/** 1-based ranks for a scored id list (desc score, qualifiedName tiebreak). */\nfunction ranksOf(scores: Map<string, number>, nameOf: (id: string) => string): Map<string, number> {\n const ids = [...scores.entries()]\n .filter(([, s]) => s > 0)\n .sort((a, b) => b[1] - a[1] || nameOf(a[0]).localeCompare(nameOf(b[0])))\n .map(([id]) => id);\n return new Map(ids.map((id, i) => [id, i + 1]));\n}\n\n/**\n * Hybrid retrieval, combined with Reciprocal Rank Fusion: the module ranking\n * (or the mechanical fallback) is one arm, the local-embedding pass the\n * other, so a question like \"where do we handle auth failures?\" can surface\n * `verify_token` even with no shared word. Deterministic given the same\n * model + cached vectors; embeddings live in a binary sidecar next to the\n * map, never in `graph.json`.\n */\nexport async function queryGraphSemantic(\n graph: VgGraph,\n question: string,\n options: SemanticQueryOptions,\n): Promise<QueryResult> {\n const budget = options.budget ?? 2000;\n const limit = options.limit ?? 12;\n const literals = extractLiteralNeedles(question);\n const forTokens = literals.length > 0 ? stripLiteralNeedles(question) : question;\n const residualTokens = tokenize(forTokens);\n // Embed the residual ask (without URL/quote noise) so semantic neighbours\n // aren't dragged toward package names that share host path segments. Skipped\n // entirely when the ranking arrives pre-computed (vgd already embedded it).\n const queryVec = options.semanticRanked\n ? null\n : await options.embedder?.embedQuery(forTokens || question);\n const index = indexFor(graph);\n\n // Lexical arm: module ranking order when available, mechanical otherwise.\n // RRF consumes only the ORDER. An honest miss contributes an empty arm.\n const lexRaw = new Map<string, number>();\n const whyById = new Map<string, string>();\n const lexSeeds = options.ranked\n ? options.ranked.hasContent\n ? options.ranked.seeds.map((s) => ({ id: s.id, score: s.score, why: s.why }))\n : []\n : mechanicalRank(graph, question, literals).map((m) => ({ id: m.node.id, score: m.score, why: m.why }));\n for (const s of lexSeeds) {\n lexRaw.set(s.id, s.score);\n whyById.set(s.id, s.why);\n }\n\n const scored: QueryMatch[] = [];\n // Literal-only asks: skip the semantic loop entirely — embeddings over\n // \"does not exist find occurrences\" still surface unrelated hubs.\n if (residualTokens.length > 0 || literals.length === 0) {\n const semRaw = new Map<string, number>();\n const nodeById = new Map<string, GraphNode>();\n for (const node of graph.nodes) {\n if (node.kind === 'file' || node.kind === 'external') continue;\n nodeById.set(node.id, node);\n if (options.semanticRanked || !queryVec) continue;\n const vec = options.nodeVectors?.get(node.id);\n const sem = vec && residualTokens.length > 0 ? Math.max(0, cosine(queryVec, vec)) : 0;\n if (sem > 0) semRaw.set(node.id, sem);\n }\n if (options.semanticRanked && residualTokens.length > 0) {\n // Ignore ids the ranking knows about but this graph no longer has: the\n // daemon's index can be one publish behind a locally refreshed map.\n for (const { id, score } of options.semanticRanked) {\n if (score > 0 && nodeById.has(id)) semRaw.set(id, score);\n }\n }\n const nameOf = (id: string) => nodeById.get(id)?.qualifiedName ?? id;\n const lexRanks = ranksOf(lexRaw, nameOf);\n const semRanks = ranksOf(semRaw, nameOf);\n for (const [id, node] of nodeById) {\n const lr = lexRanks.get(id);\n const sr = semRanks.get(id);\n if (lr === undefined && sr === undefined) continue;\n const fused = (lr !== undefined ? 1 / (RRF_K + lr) : 0) + (sr !== undefined ? 1 / (RRF_K + sr) : 0);\n const sem = semRaw.get(id) ?? 0;\n const lexWhy = whyById.get(id);\n const why = lexWhy || (sem > 0.3 ? `semantic match (${sem.toFixed(2)})` : 'weak match');\n scored.push({ node, score: round(fused * (1 + IMPORTANCE_WEIGHT * node.importance)), why });\n }\n scored.sort((a, b) => b.score - a.score || a.node.qualifiedName.localeCompare(b.node.qualifiedName));\n }\n\n const seeds = diversifyByFile(scored).slice(0, limit);\n const { context, tokensEstimate } = buildContext(graph, index, question, seeds, budget, literals);\n return { question, matches: seeds, context, tokensEstimate };\n}\n\n/**\n * camelCase / snake_case / kebab / letter↔digit split of an identifier →\n * lowercased parts. The separator alternative is Unicode-letter-aware\n * (`\\p{L}\\p{N}`, not ASCII-only) so non-Latin identifiers split on\n * punctuation without losing every character to it; the camelCase boundary\n * lookaround stays ASCII-only since casing is itself an ASCII-script concept.\n * Letter↔digit boundaries split too, so `Session2` keeps `session` reachable.\n */\nexport function identifierParts(name: string): Set<string> {\n return new Set(\n name\n .split(/[^\\p{L}\\p{N}]+|(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|(?<=[\\p{L}])(?=[0-9])|(?<=[0-9])(?=[\\p{L}])/u)\n .filter(Boolean)\n .map((s) => s.toLowerCase()),\n );\n}\n\nfunction buildContext(\n graph: VgGraph,\n index: GraphIndex,\n question: string,\n seeds: QueryMatch[],\n budget: number,\n literals: string[] = [],\n): { context: string; tokensEstimate: number } {\n const lines: string[] = [];\n lines.push(`# Context for: ${question}`);\n lines.push('');\n if (literals.length) {\n lines.push('## Literal string(s) to locate (exact text, not symbol names)');\n for (const lit of literals) lines.push(`- \\`${lit}\\``);\n lines.push(\n '_Use a quoted phrase / URL search (`search_symbols` or `search_code` with the exact needle) for occurrences. Graph symbols below (if any) are residual identifier hints only._',\n );\n lines.push('');\n }\n if (seeds.length === 0) {\n lines.push(\n literals.length\n ? '_No graph symbols matched residual terms — this is expected for a pure string/URL occurrence search. Run a literal sweep on the needle(s) above._'\n : '_No matching symbols found in the map. Try different terms, or `vg hubs` for the most important code._',\n );\n const text = lines.join('\\n');\n return { context: text, tokensEstimate: estimateTokens(text) };\n }\n\n for (const { node, why } of seeds) {\n const block: string[] = [];\n block.push(`## ${node.qualifiedName} (${node.kind}, ${node.file}:${node.span.start})`);\n if (node.signature) block.push('`' + node.signature + '`');\n const callees = index.callees(node.id).map((x) => x.node.qualifiedName);\n const callers = index.callers(node.id).map((x) => x.node.qualifiedName);\n if (callees.length) block.push(`calls: ${unique(callees).slice(0, 8).join(', ')}`);\n if (callers.length) block.push(`called by: ${unique(callers).slice(0, 8).join(', ')}`);\n block.push(`importance ${node.importance.toFixed(3)} · area #${node.area}${node.isHub ? ' · hub' : ''} · ${why}`);\n block.push('');\n\n const candidate = lines.concat(block).join('\\n');\n if (estimateTokens(candidate) > budget && lines.length > 2) break;\n lines.push(...block);\n }\n\n const text = lines.join('\\n');\n return { context: text, tokensEstimate: estimateTokens(text) };\n}\n\nfunction unique(xs: string[]): string[] {\n return [...new Set(xs)];\n}\n\nfunction estimateTokens(text: string): number {\n // ~4 chars per token, the standard rough estimate.\n return Math.ceil(text.length / 4);\n}\n\nfunction round(x: number): number {\n return Math.round(x * 1e6) / 1e6;\n}\n","import { indexFor } from './relations.js';\nimport type { EdgeKind, VgGraph } from '../schema.js';\n\n/**\n * Deterministic reverse-reachability impact analysis (VG-CLI-SPEC §3.5).\n *\n * \"What breaks if `<node>` changes\" = everything that (transitively) depends on\n * it: its callers, importers, and subtypes. We BFS *backwards* along dependency\n * edges, bounded by depth, with a confidence that decays with distance (direct =\n * high; transitive lower; ambiguous/dynamic edges already carry lower edge\n * confidence which we fold in). Test-impact selection (`--tests`) lands in\n * Phase 2; this is the structural blast radius.\n */\n\nconst DEPEND_EDGES = new Set<EdgeKind>(['call', 'import', 'extends', 'implements', 'references']);\n\nexport interface ImpactItem {\n id: string;\n name: string;\n kind: string;\n file: string;\n line: number;\n depth: number;\n confidence: number;\n}\n\nexport interface ImpactResult {\n root: { id: string; name: string };\n depth: number;\n affected: ImpactItem[];\n direct: number;\n transitive: number;\n /** Lowest edge confidence encountered (e.g. a dynamic-dispatch edge). */\n minEdgeConfidence: number;\n}\n\nexport function impactOf(graph: VgGraph, rootId: string, opts: { depth?: number } = {}): ImpactResult {\n const maxDepth = Math.max(1, opts.depth ?? 4);\n const index = indexFor(graph);\n const root = index.node(rootId);\n\n const affected = new Map<string, ImpactItem>();\n let minEdgeConfidence = 1;\n\n // BFS over incoming dependency edges (dependents of the frontier).\n let frontier: { id: string; conf: number }[] = [{ id: rootId, conf: 1 }];\n for (let depth = 1; depth <= maxDepth; depth++) {\n const nextFrontier: { id: string; conf: number }[] = [];\n for (const { id, conf } of frontier) {\n for (const e of index.in(id)) {\n if (!DEPEND_EDGES.has(e.kind)) continue;\n minEdgeConfidence = Math.min(minEdgeConfidence, e.confidence);\n const dependentId = e.src;\n if (dependentId === rootId || affected.has(dependentId)) continue;\n const node = index.node(dependentId);\n if (!node) continue;\n const conf2 = round(conf * e.confidence * 0.9); // decay with distance\n affected.set(dependentId, {\n id: node.id,\n name: node.qualifiedName,\n kind: node.kind,\n file: node.file,\n line: node.span.start,\n depth,\n confidence: conf2,\n });\n nextFrontier.push({ id: dependentId, conf: conf2 });\n }\n }\n frontier = nextFrontier;\n if (frontier.length === 0) break;\n }\n\n const items = [...affected.values()].sort(\n (a, b) => a.depth - b.depth || b.confidence - a.confidence || a.name.localeCompare(b.name),\n );\n\n return {\n root: { id: rootId, name: root?.qualifiedName ?? rootId },\n depth: maxDepth,\n affected: items,\n direct: items.filter((i) => i.depth === 1).length,\n transitive: items.filter((i) => i.depth > 1).length,\n minEdgeConfidence: round(minEdgeConfidence),\n };\n}\n\nfunction round(x: number): number {\n return Math.round(x * 1e6) / 1e6;\n}\n"]}
1
+ {"version":3,"sources":["../src/engine/relations.ts","../src/engine/user-ask.ts","../src/engine/query.ts","../src/engine/impact.ts"],"names":["push","text","round"],"mappings":";;;AAGO,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAAqB,KAAA,EAAgB;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AACnB,IAAA,KAAA,MAAW,CAAA,IAAK,MAAM,KAAA,EAAO,IAAA,CAAK,SAAS,GAAA,CAAI,CAAA,CAAE,IAAI,CAAC,CAAA;AACtD,IAAA,KAAA,MAAW,CAAA,IAAK,MAAM,KAAA,EAAO;AAC3B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EAAM,KAAK,IAAA,CAAK,KAAA;AAAA,UAChB,KAAA;AAAA,UACA,UAAA,EAAY;AAAA,SACb,CAAA;AACD,QAAA,YAAA,CAAa,KAAK,EAAE,EAAA,EAAI,WAAA,EAAa,IAAA,EAAM,OAAO,CAAA;AAAA,MACpD;AAAA,IACF;AACA,IAAA,QAAA,GAAW,YAAA;AACX,IAAA,IAAI,QAAA,CAAS,WAAW,CAAA,EAAG;AAAA,EAC7B;AAEA,EAAA,MAAM,QAAQ,CAAC,GAAG,QAAA,CAAS,MAAA,EAAQ,CAAA,CAAE,IAAA;AAAA,IACnC,CAAC,CAAA,EAAG,CAAA,KAAM,CAAA,CAAE,QAAQ,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,UAAA,GAAa,EAAE,UAAA,IAAc,CAAA,CAAE,IAAA,CAAK,aAAA,CAAc,EAAE,IAAI;AAAA,GAC3F;AAEA,EAAA,OAAO;AAAA,IACL,MAAM,EAAE,EAAA,EAAI,QAAQ,IAAA,EAAM,IAAA,EAAM,iBAAiB,MAAA,EAAO;AAAA,IACxD,KAAA,EAAO,QAAA;AAAA,IACP,QAAA,EAAU,KAAA;AAAA,IACV,MAAA,EAAQ,MAAM,MAAA,CAAO,CAAC,MAAM,CAAA,CAAE,KAAA,KAAU,CAAC,CAAA,CAAE,MAAA;AAAA,IAC3C,UAAA,EAAY,MAAM,MAAA,CAAO,CAAC,MAAM,CAAA,CAAE,KAAA,GAAQ,CAAC,CAAA,CAAE,MAAA;AAAA,IAC7C,iBAAA,EAAmBA,OAAM,iBAAiB;AAAA,GAC5C;AACF;AAEA,SAASA,OAAM,CAAA,EAAmB;AAChC,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,CAAA,GAAI,GAAG,CAAA,GAAI,GAAA;AAC/B","file":"chunk-K3SXWOTT.js","sourcesContent":["import type { EdgeKind, GraphEdge, GraphNode, VgGraph } from '../schema.js';\n\n/** Indexes over a graph for O(1) neighbor lookups (built once per command). */\nexport class GraphIndex {\n readonly nodeById = new Map<string, GraphNode>();\n private outById = new Map<string, GraphEdge[]>();\n private inById = new Map<string, GraphEdge[]>();\n\n constructor(readonly graph: VgGraph) {\n for (const n of graph.nodes) this.nodeById.set(n.id, n);\n for (const e of graph.edges) {\n push(this.outById, e.src, e);\n push(this.inById, e.dst, e);\n }\n }\n\n out(id: string, kind?: EdgeKind): GraphEdge[] {\n const all = this.outById.get(id) ?? [];\n return kind ? all.filter((e) => e.kind === kind) : all;\n }\n\n in(id: string, kind?: EdgeKind): GraphEdge[] {\n const all = this.inById.get(id) ?? [];\n return kind ? all.filter((e) => e.kind === kind) : all;\n }\n\n node(id: string): GraphNode | undefined {\n return this.nodeById.get(id);\n }\n\n /**\n * Resolved nodes called by `id` — invocations (`call`) plus structural\n * dependency references (`references`, e.g. a constructor-injected field's\n * type), since both represent real usage a caller/impact question cares\n * about. `references` is otherwise only emitted by the precise SCIP/tsc\n * rungs and (for Java DI wiring) the heuristic rung — never a guess.\n */\n callees(id: string): { edge: GraphEdge; node: GraphNode }[] {\n return this.resolveTargets(this.out(id).filter(isUsageEdge), 'dst');\n }\n\n /** Resolved nodes that call or structurally reference `id`. */\n callers(id: string): { edge: GraphEdge; node: GraphNode }[] {\n return this.resolveTargets(this.in(id).filter(isUsageEdge), 'src');\n }\n\n private resolveTargets(edges: GraphEdge[], end: 'src' | 'dst') {\n const out: { edge: GraphEdge; node: GraphNode }[] = [];\n for (const e of edges) {\n const node = this.nodeById.get(e[end]);\n if (node) out.push({ edge: e, node });\n }\n return out;\n }\n}\n\nconst USAGE_KINDS: ReadonlySet<EdgeKind> = new Set(['call', 'references']);\nfunction isUsageEdge(e: GraphEdge): boolean {\n return USAGE_KINDS.has(e.kind);\n}\n\nfunction push(map: Map<string, GraphEdge[]>, key: string, value: GraphEdge): void {\n const list = map.get(key);\n if (list) list.push(value);\n else map.set(key, [value]);\n}\n\n/**\n * Memoized `GraphIndex`, keyed on the graph object's identity.\n *\n * The index (node-by-id + in/out adjacency) is a pure function of the graph's\n * content, and every read path rebuilds it from scratch — an O(nodes + edges)\n * pass that, on a large map, costs hundreds of milliseconds *per query*. Under\n * `vg serve` the same parsed graph object is reused across many tool calls\n * (`GraphSource` caches it by file mtime and only replaces the reference when\n * `graph.json` actually changes), so rebuilding the index on every call is pure\n * waste. Keying a `WeakMap` on that object identity builds the index once and\n * reuses it until the file is rebuilt — at which point `GraphSource` hands back a\n * *new* object, this map misses, and the stale index is collected with the old\n * graph. Correct and stale-safe by construction: a different graph is a\n * different object, so there is no cross-graph reuse and nothing to invalidate.\n *\n * `GraphIndex` is read-only (no method mutates its maps), so sharing one\n * instance across callers is safe.\n */\nconst INDEX_CACHE = new WeakMap<VgGraph, GraphIndex>();\n\nexport function indexFor(graph: VgGraph): GraphIndex {\n let idx = INDEX_CACHE.get(graph);\n if (!idx) {\n idx = new GraphIndex(graph);\n INDEX_CACHE.set(graph, idx);\n }\n return idx;\n}\n","/**\n * Split the user's ask from host-injected attachment metadata.\n *\n * The VS Code panel (`codeAttachments.ts`) and other hosts append a markdown\n * block after a `---` fence:\n *\n * ## User attachments (always include in your reasoning for this turn)\n * ### Attached image: `image.png`\n * … saved at: `.vibgrate/code-attachments/…`\n *\n * Those backticks are for the model. If the full instruction is fed into\n * {@link extractLiteralNeedles} / seed ranking, attachment basenames and paths\n * become **literal-locate hard constraints** (\"0 hits → finish, do not invent\n * an edit\") and the agent aborts a real coding task. Field report: version-badge\n * health UI with a screenshot — agent searched for `image.png` and stopped.\n *\n * Retrieval, needle pinning, locate-only detection, and relevance analysis must\n * use {@link userAskFromInstruction}. The full instruction (with attachments)\n * still belongs in the Task / user message so the model can see the appendix.\n */\n\n/** Heading written by hosts when packing panel attachments into the instruction. */\nexport const USER_ATTACHMENTS_HEADING_PREFIX = '## User attachments';\n\n/**\n * Return only the user-authored portion of an instruction, dropping a trailing\n * host \"User attachments\" appendix when present. Unchanged when no appendix.\n */\nexport function userAskFromInstruction(instruction: string): string {\n if (!instruction) return instruction;\n\n // Canonical host shape: blank line, --- fence, then the attachments heading.\n const fenced = /\\n---\\s*\\n## User attachments\\b[^\\n]*\\n?/;\n const m = fenced.exec(instruction);\n if (m && m.index != null) {\n return instruction.slice(0, m.index).trimEnd();\n }\n\n // Defensive: heading without the fence (older hosts / hand-edited prompts).\n const bare = instruction.search(/(?:^|\\n)## User attachments\\b/);\n if (bare > 0) {\n return instruction.slice(0, bare).trimEnd();\n }\n if (bare === 0) {\n // Instruction is only the appendix — no user ask left.\n return '';\n }\n\n return instruction;\n}\n","import { indexFor, type GraphIndex } from './relations.js';\nimport { cosine, type Embedder } from './embeddings.js';\nimport type { SanitizedRank } from './relevance-provider.js';\nimport type { GraphNode, VgGraph } from '../schema.js';\nimport { userAskFromInstruction } from './user-ask.js';\n\n/**\n * Retrieval front-end for `vg ask` / `vg code` capsule seeds (VG-CLI-SPEC\n * §3.2).\n *\n * Since the 2026-08 relevance relocation, the RANKING ENGINE lives in the\n * optional relevance module (`@vibgrate/relevance`, auto-provisioned): the\n * async callers run the ask through the module via\n * `relevance-provider.rankQuestion` and pass the SANITIZED result in as\n * `options.ranked`. This file keeps only what is mechanical:\n *\n * - literal string/URL needle handling (the locate path — exact-text\n * matching, not relevance);\n * - a deliberately dumb module-less fallback: exact identifier-name and\n * name-part matching, nothing that understands language (no lexicon, no\n * term roles, no IDF, no typo repair, no expansion) — enough that an ask\n * NAMING a symbol still pins its file when the module is unavailable;\n * - context-block rendering and the semantic Reciprocal Rank Fusion\n * plumbing (`--semantic`), which fuses ORDERINGS and carries no ranking\n * heuristics of its own.\n */\n\nexport interface QueryOptions {\n budget?: number; // approx token budget for the context block (default 2000)\n limit?: number; // max seed matches to expand (default 12)\n /** Sanitized module ranking (engine/relevance-provider.ts rankQuestion),\n * injected by async callers so this module stays pure and sync. When\n * absent — module not installed, predates the ranking API, or failed —\n * the mechanical fallback below answers. */\n ranked?: SanitizedRank | null;\n}\n\nexport interface QueryMatch {\n node: GraphNode;\n score: number;\n why: string;\n}\n\nexport interface QueryResult {\n question: string;\n matches: QueryMatch[];\n context: string;\n tokensEstimate: number;\n}\n\n/**\n * Function-word hygiene for the mechanical fallback tokenizer. This is NOT a\n * relevance stopword model (that moved into the module): nothing here scores,\n * ranks, weights, or reorders anything. It is a purely SUBTRACTIVE floor —\n * the words a caller uses to FRAME an ask rather than to name the code they\n * mean, which therefore cannot be identifier evidence.\n *\n * The floor exists because `mechanicalRank` treats every surviving token as\n * equal evidence, and English framing words collide with real identifier\n * parts constantly. Without it, `\"add a new feature\"` scores `AddBlogForm`\n * on the camel-part tier (`add`) and `FeatureFlagStore` (`feature`) and fills\n * the entire seed window — a grab-bag Task Capsule for an ask that named\n * nothing. That is the capsule-poisoning failure of the 2026-07 field report,\n * and an empty result is the correct answer.\n *\n * Note this is the floor ONLY. Deciding which of several genuine candidates\n * is most relevant remains the module's job, and no part of that logic —\n * term roles, weighting, expansion, morphology — belongs in this file.\n */\nconst FUNCTION_WORDS = new Set([\n // Closed-class English: could only ever match by coincidence.\n 'the', 'a', 'an', 'is', 'are', 'was', 'were', 'be', 'to', 'of', 'in', 'on', 'for', 'and', 'or',\n 'where', 'what', 'which', 'how', 'do', 'does', 'did', 'i', 'we', 'it', 'this', 'that', 'with',\n 'when', 'who', 'why', 'can', 'should', 'my', 'our', 'you', 'your', 'from', 'by', 'at', 'as',\n // Process verbs. A caller says what they want DONE with these; they never\n // name the code it should be done to. Left in, bare `add` seeds every\n // Add*/*Add* symbol in the repo ahead of the terms that carry the subject.\n 'add', 'adds', 'added', 'adding',\n 'create', 'creates', 'created', 'creating',\n 'make', 'makes', 'making', 'made',\n 'remove', 'removes', 'removed', 'removing',\n 'delete', 'deletes', 'deleted', 'deleting',\n 'update', 'updates', 'updated', 'updating',\n 'change', 'changes', 'changed', 'changing',\n 'set', 'sets', 'setting', 'setup', 'get', 'gets', 'getting',\n 'use', 'uses', 'used', 'using', 'want', 'wants', 'wanted', 'doing', 'done',\n 'support', 'supports', 'supported', 'supporting',\n 'enable', 'enables', 'enabled', 'enabling',\n 'disable', 'disables', 'disabled', 'disabling',\n 'allow', 'allows', 'allowed', 'handle', 'handles', 'handling',\n 'implement', 'implements', 'implemented', 'implementing',\n 'build', 'builds', 'building', 'built', 'need', 'needs', 'needed',\n // Filler nouns and connectives: the generic scaffolding of a request.\n 'new', 'newly', 'via', 'through', 'into', 'onto',\n 'way', 'ways', 'thing', 'things', 'stuff',\n 'feature', 'features', 'functionality',\n 'method', 'methods', 'option', 'options', 'ability',\n 'form', 'forms', 'page', 'pages', 'screen', 'screens', 'button', 'buttons',\n 'help', 'start', 'begin', 'work', 'works', 'working',\n 'also', 'currently', 'properly', 'correctly', 'please',\n 'happens', 'happen', 'something', 'somewhere',\n 'step', 'steps', 'flow', 'process',\n // Discovery-question scaffolding: words that FRAME the search itself\n // (\"find the code responsible for X\", \"explain how X works\").\n 'find', 'code', 'responsible', 'modify', 'me',\n 'implementation', 'explain', 'codebase', 'contains', 'file',\n // Bug-report framing: says something is WRONG, never what is wrong.\n // `fix` alone lit up `export_fixed_width_records`, `out` lit up every\n // *Router*/*rollout* symbol (vg code prompt-relevance corpus).\n 'fix', 'fixes', 'fixing', 'bug', 'bugs', 'broken', 'busted', 'borked',\n 'wrong', 'incorrect', 'incorrectly', 'figure', 'out', 'sure',\n]);\n\n/**\n * Strip sentence punctuation from a URL match without breaking real query\n * strings (`?key=value`). A lone trailing `?` / `!` is English punctuation\n * (\"where is https://…/signup?\") — leaving it in the needle makes the literal\n * sweep miss the bare path in source.\n */\nfunction cleanUrlNeedle(raw: string): string {\n let s = raw.trim();\n // Trailing ) ] } > , ; : ! . from markdown links / sentence ends.\n s = s.replace(/[.,;:!)\\]}>]+$/g, '');\n // Lone trailing `?` → drop. Keep `?key=…` (content after `?`).\n if (s.endsWith('?')) {\n const qi = s.lastIndexOf('?');\n if (qi === s.length - 1) s = s.slice(0, -1);\n }\n return s;\n}\n\n/**\n * Extract string/URL needles a caller is asking to *locate as text*, not as\n * bag-of-words symbol terms. URLs and quoted phrases are exact-match material\n * for the literal sweep (`search_symbols` / `search_code`); feeding their path\n * segments into lexical symbol ranking produces confidently wrong seeds\n * (dash → dashboard package, exist → NonExisting, …).\n */\nexport function extractLiteralNeedles(question: string): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n const push = (raw: string, kind: 'url' | 'quote') => {\n let s = raw.trim();\n s = kind === 'url' ? cleanUrlNeedle(s) : s.replace(/[.,;:!)\\]}>?]+$/g, '');\n if (s.length < 2 || seen.has(s)) return;\n seen.add(s);\n out.push(s);\n };\n for (const m of question.matchAll(/https?:\\/\\/[^\\s\"'`<>]+/gi)) push(m[0]!, 'url');\n for (const m of question.matchAll(/([\"'`])((?:(?!\\1)[^\\\\]|\\\\.){2,})\\1/g)) {\n push(m[2]!.replace(/\\\\(.)/g, '$1'), 'quote');\n }\n return out;\n}\n\n/** Question text with URL/quoted needles removed so residual tokens can name symbols. */\nexport function stripLiteralNeedles(question: string): string {\n let s = question;\n // Strip raw URL spans first (may still carry a trailing `?` from the ask).\n for (const m of question.matchAll(/https?:\\/\\/[^\\s\"'`<>]+/gi)) {\n s = s.split(m[0]!).join(' ');\n }\n for (const lit of extractLiteralNeedles(question)) {\n s = s.split(lit).join(' ');\n }\n // Also strip bare quote pairs left behind.\n s = s.replace(/([\"'`])\\s*\\1/g, ' ');\n return s.replace(/\\s+/g, ' ').trim();\n}\n\n/**\n * Residual ask used for graph symbol ranking when the question embeds a\n * URL/quote. Empty when only framing words remain (\"where is …?\") so we do\n * not light up unrelated symbols like `applyPlan.where`.\n */\nexport function residualForSymbolSearch(question: string): string {\n const literals = extractLiteralNeedles(question);\n if (literals.length === 0) return question.trim();\n const stripped = stripLiteralNeedles(question);\n return tokenize(stripped).length === 0 ? '' : stripped;\n}\n\n/**\n * True when the instruction is a string/URL occurrence locate (not an edit).\n * Used to skip PatchIR grammar and answer from the literal sweep without\n * dumping constrained-decoding JSON into the VG Code panel.\n */\nexport function isLocateOnlyInstruction(instruction: string): boolean {\n // Drop host-injected \"User attachments\" appendix (backticked image paths)\n // before classify — same rule as buildCodeContext. Avoids treating a screenshot\n // filename as a locate-only occurrence search.\n const q = userAskFromInstruction(instruction).trim();\n if (!q) return false;\n const needles = extractLiteralNeedles(q);\n const hasLocateFrame =\n /\\b(where\\s+is|where\\s+are|find\\s+(all\\s+|every\\s+)?occurrence|find\\s+occurrences|does\\s+not\\s+exist|locate|search\\s+for)\\b/i.test(\n q,\n ) ||\n (needles.length > 0 && /^https?:\\/\\//i.test(q));\n // Strong edit verbs cancel locate-only (ignore \"does not exist\" as non-edit).\n const withoutExist = q.replace(/\\bdoes\\s+not\\s+exist\\b/gi, ' ');\n if (\n /\\b(fix|edit|change|replace|implement|refactor|rename|patch|create\\s+file|delete\\s+file|add\\s+a\\b|remove\\s+the\\b)\\b/i.test(\n withoutExist,\n )\n ) {\n return false;\n }\n if (needles.some((n) => /^https?:\\/\\//i.test(n))) return true;\n return hasLocateFrame && needles.length > 0;\n}\n\nexport function queryGraph(graph: VgGraph, question: string, options: QueryOptions = {}): QueryResult {\n const budget = options.budget ?? 2000;\n const limit = options.limit ?? 12;\n const literals = extractLiteralNeedles(question);\n const index = indexFor(graph);\n\n let seeds: QueryMatch[];\n if (options.ranked) {\n // Module ranking (already sanitized: every id names a real symbol).\n // An honest miss from the engine stays an honest miss here.\n const byId = new Map<string, GraphNode>();\n for (const node of graph.nodes) byId.set(node.id, node);\n seeds = options.ranked.hasContent\n ? options.ranked.seeds\n .map((s) => {\n const node = byId.get(s.id);\n return node ? { node, score: s.score, why: s.why } : null;\n })\n .filter((m): m is QueryMatch => m !== null)\n .slice(0, limit)\n : [];\n } else {\n seeds = mechanicalRank(graph, question, literals).slice(0, limit);\n }\n\n const { context, tokensEstimate } = buildContext(graph, index, question, seeds, budget, literals);\n return { question, matches: seeds, context, tokensEstimate };\n}\n\n/**\n * The module-less fallback: mechanical identifier matching, deliberately free\n * of language understanding. A token scores only when it IS a symbol's name,\n * one of its camel/snake parts, or (length ≥ 4) a substring of the qualified\n * name — so \"write tests for chargeCard\" or a pasted `src/…/File.ts` path\n * still pins the right file, while intent phrasings honestly miss until the\n * relevance module is available. No lexicon, no term roles, no IDF, no typo\n * repair, no expansions — that is the module's job now.\n */\nfunction mechanicalRank(graph: VgGraph, question: string, literals: string[]): QueryMatch[] {\n const forTokens = literals.length > 0 ? stripLiteralNeedles(question) : question;\n let tokens = tokenize(forTokens);\n // A literal ask's residual framing (\"does not exist\", \"find occurrences\")\n // must not light up DoesNot*/NonExisting*/commandExists lookalikes — the\n // honest-miss contract of the locate path holds module-less too.\n if (literals.length > 0) tokens = tokens.filter((t) => !LOCATE_SCAFFOLD.has(t));\n if (tokens.length === 0) return [];\n const scored: QueryMatch[] = [];\n for (const node of graph.nodes) {\n if (node.kind === 'file' || node.kind === 'external') continue;\n const name = node.name.toLowerCase();\n const qn = node.qualifiedName.toLowerCase();\n const parts = identifierParts(node.name);\n let score = 0;\n const hits: string[] = [];\n for (const t of tokens) {\n if (name === t) {\n score += 10;\n hits.push(t);\n } else if (parts.has(t)) {\n score += 6;\n hits.push(t);\n } else if (t.length >= 4 && qn.includes(t)) {\n score += 3;\n hits.push(t);\n }\n }\n if (score > 0) {\n scored.push({\n node,\n score: round(score * (1 + IMPORTANCE_WEIGHT * node.importance)),\n why: `matched: ${hits.join(', ')}`,\n });\n }\n }\n scored.sort((a, b) => b.score - a.score || a.node.qualifiedName.localeCompare(b.node.qualifiedName));\n return diversifyByFile(scored);\n}\n\nfunction tokenize(q: string): string[] {\n return [\n ...new Set(\n q\n .toLowerCase()\n .split(/[^\\p{L}\\p{N}]+/u)\n .filter((t) => t.length >= 1 && !FUNCTION_WORDS.has(t)),\n ),\n ];\n}\n\n/**\n * Importance is a mild tiebreaker, not a doubling: at 0.4 a top hub adds at\n * most 40%, enough to break genuine ties without overriding term evidence.\n */\nconst IMPORTANCE_WEIGHT = 0.4;\n\n/** Residual framing of a string/URL locate ask — never symbol evidence. */\nconst LOCATE_SCAFFOLD = new Set([\n 'not', 'no', 'exist', 'exists', 'existing', 'occurrence', 'occurrences',\n 'occurence', 'occurences', 'find', 'every', 'place', 'places', 'string',\n 'literal', 'text', 'search', 'locate', 'look', 'looking', 'show', 'list', 'all',\n]);\n\n/**\n * Stable file-diversity pass over the ranked list: each file's best node\n * keeps its rank; further nodes from an already-represented file are demoted\n * behind the first representative of every other matching file (never\n * dropped). Mechanical presentation hygiene — the seed window is a coverage\n * budget either way.\n */\nfunction diversifyByFile(matches: QueryMatch[]): QueryMatch[] {\n const seen = new Set<string>();\n const firstPerFile: QueryMatch[] = [];\n const rest: QueryMatch[] = [];\n for (const m of matches) {\n if (seen.has(m.node.file)) {\n rest.push(m);\n } else {\n seen.add(m.node.file);\n firstPerFile.push(m);\n }\n }\n return firstPerFile.concat(rest);\n}\n\nexport interface SemanticQueryOptions extends QueryOptions {\n /** Local embedder. Optional only when {@link semanticRanked} supplies the pass. */\n embedder?: Embedder;\n /** Precomputed node vectors (from getNodeEmbeddings); falls back to lexical for nodes without one. */\n nodeVectors?: Map<string, number[]>;\n /**\n * A semantic pass someone else already ran — vgd ranking the question\n * against its resident slot index. Supplied instead of `embedder` +\n * `nodeVectors` so the caller pays neither a model load nor a vector scan,\n * and no vectors cross the socket.\n *\n * Only the ORDER of this list is consumed (RRF fuses rankings, not scores),\n * so a truncated top-K is not an approximation: a candidate ranked past a\n * few hundred cannot reach a 12-row answer.\n */\n semanticRanked?: Array<{ id: string; score: number }>;\n}\n\n/**\n * Reciprocal Rank Fusion constant (the standard k=60). Fusing RANKINGS\n * instead of blending raw scores removes the need to calibrate two\n * incomparable scales: a node's fused score is Σ 1/(k + rankᵢ) over the\n * lists it appears in, so agreement between signals dominates and a single\n * signal's outlier magnitude cannot.\n */\nconst RRF_K = 60;\n\n/** 1-based ranks for a scored id list (desc score, qualifiedName tiebreak). */\nfunction ranksOf(scores: Map<string, number>, nameOf: (id: string) => string): Map<string, number> {\n const ids = [...scores.entries()]\n .filter(([, s]) => s > 0)\n .sort((a, b) => b[1] - a[1] || nameOf(a[0]).localeCompare(nameOf(b[0])))\n .map(([id]) => id);\n return new Map(ids.map((id, i) => [id, i + 1]));\n}\n\n/**\n * Hybrid retrieval, combined with Reciprocal Rank Fusion: the module ranking\n * (or the mechanical fallback) is one arm, the local-embedding pass the\n * other, so a question like \"where do we handle auth failures?\" can surface\n * `verify_token` even with no shared word. Deterministic given the same\n * model + cached vectors; embeddings live in a binary sidecar next to the\n * map, never in `graph.json`.\n */\nexport async function queryGraphSemantic(\n graph: VgGraph,\n question: string,\n options: SemanticQueryOptions,\n): Promise<QueryResult> {\n const budget = options.budget ?? 2000;\n const limit = options.limit ?? 12;\n const literals = extractLiteralNeedles(question);\n const forTokens = literals.length > 0 ? stripLiteralNeedles(question) : question;\n const residualTokens = tokenize(forTokens);\n // Embed the residual ask (without URL/quote noise) so semantic neighbours\n // aren't dragged toward package names that share host path segments. Skipped\n // entirely when the ranking arrives pre-computed (vgd already embedded it).\n const queryVec = options.semanticRanked\n ? null\n : await options.embedder?.embedQuery(forTokens || question);\n const index = indexFor(graph);\n\n // Lexical arm: module ranking order when available, mechanical otherwise.\n // RRF consumes only the ORDER. An honest miss contributes an empty arm.\n const lexRaw = new Map<string, number>();\n const whyById = new Map<string, string>();\n const lexSeeds = options.ranked\n ? options.ranked.hasContent\n ? options.ranked.seeds.map((s) => ({ id: s.id, score: s.score, why: s.why }))\n : []\n : mechanicalRank(graph, question, literals).map((m) => ({ id: m.node.id, score: m.score, why: m.why }));\n for (const s of lexSeeds) {\n lexRaw.set(s.id, s.score);\n whyById.set(s.id, s.why);\n }\n\n const scored: QueryMatch[] = [];\n // Literal-only asks: skip the semantic loop entirely — embeddings over\n // \"does not exist find occurrences\" still surface unrelated hubs.\n if (residualTokens.length > 0 || literals.length === 0) {\n const semRaw = new Map<string, number>();\n const nodeById = new Map<string, GraphNode>();\n for (const node of graph.nodes) {\n if (node.kind === 'file' || node.kind === 'external') continue;\n nodeById.set(node.id, node);\n if (options.semanticRanked || !queryVec) continue;\n const vec = options.nodeVectors?.get(node.id);\n const sem = vec && residualTokens.length > 0 ? Math.max(0, cosine(queryVec, vec)) : 0;\n if (sem > 0) semRaw.set(node.id, sem);\n }\n if (options.semanticRanked && residualTokens.length > 0) {\n // Ignore ids the ranking knows about but this graph no longer has: the\n // daemon's index can be one publish behind a locally refreshed map.\n for (const { id, score } of options.semanticRanked) {\n if (score > 0 && nodeById.has(id)) semRaw.set(id, score);\n }\n }\n const nameOf = (id: string) => nodeById.get(id)?.qualifiedName ?? id;\n const lexRanks = ranksOf(lexRaw, nameOf);\n const semRanks = ranksOf(semRaw, nameOf);\n for (const [id, node] of nodeById) {\n const lr = lexRanks.get(id);\n const sr = semRanks.get(id);\n if (lr === undefined && sr === undefined) continue;\n const fused = (lr !== undefined ? 1 / (RRF_K + lr) : 0) + (sr !== undefined ? 1 / (RRF_K + sr) : 0);\n const sem = semRaw.get(id) ?? 0;\n const lexWhy = whyById.get(id);\n const why = lexWhy || (sem > 0.3 ? `semantic match (${sem.toFixed(2)})` : 'weak match');\n scored.push({ node, score: round(fused * (1 + IMPORTANCE_WEIGHT * node.importance)), why });\n }\n scored.sort((a, b) => b.score - a.score || a.node.qualifiedName.localeCompare(b.node.qualifiedName));\n }\n\n const seeds = diversifyByFile(scored).slice(0, limit);\n const { context, tokensEstimate } = buildContext(graph, index, question, seeds, budget, literals);\n return { question, matches: seeds, context, tokensEstimate };\n}\n\n/**\n * camelCase / snake_case / kebab / letter↔digit split of an identifier →\n * lowercased parts. The separator alternative is Unicode-letter-aware\n * (`\\p{L}\\p{N}`, not ASCII-only) so non-Latin identifiers split on\n * punctuation without losing every character to it; the camelCase boundary\n * lookaround stays ASCII-only since casing is itself an ASCII-script concept.\n * Letter↔digit boundaries split too, so `Session2` keeps `session` reachable.\n */\nexport function identifierParts(name: string): Set<string> {\n return new Set(\n name\n .split(/[^\\p{L}\\p{N}]+|(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|(?<=[\\p{L}])(?=[0-9])|(?<=[0-9])(?=[\\p{L}])/u)\n .filter(Boolean)\n .map((s) => s.toLowerCase()),\n );\n}\n\nfunction buildContext(\n graph: VgGraph,\n index: GraphIndex,\n question: string,\n seeds: QueryMatch[],\n budget: number,\n literals: string[] = [],\n): { context: string; tokensEstimate: number } {\n const lines: string[] = [];\n lines.push(`# Context for: ${question}`);\n lines.push('');\n if (literals.length) {\n lines.push('## Literal string(s) to locate (exact text, not symbol names)');\n for (const lit of literals) lines.push(`- \\`${lit}\\``);\n lines.push(\n '_Use a quoted phrase / URL search (`search_symbols` or `search_code` with the exact needle) for occurrences. Graph symbols below (if any) are residual identifier hints only._',\n );\n lines.push('');\n }\n if (seeds.length === 0) {\n lines.push(\n literals.length\n ? '_No graph symbols matched residual terms — this is expected for a pure string/URL occurrence search. Run a literal sweep on the needle(s) above._'\n : '_No matching symbols found in the map. Try different terms, or `vg hubs` for the most important code._',\n );\n const text = lines.join('\\n');\n return { context: text, tokensEstimate: estimateTokens(text) };\n }\n\n for (const { node, why } of seeds) {\n const block: string[] = [];\n block.push(`## ${node.qualifiedName} (${node.kind}, ${node.file}:${node.span.start})`);\n if (node.signature) block.push('`' + node.signature + '`');\n const callees = index.callees(node.id).map((x) => x.node.qualifiedName);\n const callers = index.callers(node.id).map((x) => x.node.qualifiedName);\n if (callees.length) block.push(`calls: ${unique(callees).slice(0, 8).join(', ')}`);\n if (callers.length) block.push(`called by: ${unique(callers).slice(0, 8).join(', ')}`);\n block.push(`importance ${node.importance.toFixed(3)} · area #${node.area}${node.isHub ? ' · hub' : ''} · ${why}`);\n block.push('');\n\n const candidate = lines.concat(block).join('\\n');\n if (estimateTokens(candidate) > budget && lines.length > 2) break;\n lines.push(...block);\n }\n\n const text = lines.join('\\n');\n return { context: text, tokensEstimate: estimateTokens(text) };\n}\n\nfunction unique(xs: string[]): string[] {\n return [...new Set(xs)];\n}\n\nfunction estimateTokens(text: string): number {\n // ~4 chars per token, the standard rough estimate.\n return Math.ceil(text.length / 4);\n}\n\nfunction round(x: number): number {\n return Math.round(x * 1e6) / 1e6;\n}\n","import { indexFor } from './relations.js';\nimport type { EdgeKind, VgGraph } from '../schema.js';\n\n/**\n * Deterministic reverse-reachability impact analysis (VG-CLI-SPEC §3.5).\n *\n * \"What breaks if `<node>` changes\" = everything that (transitively) depends on\n * it: its callers, importers, and subtypes. We BFS *backwards* along dependency\n * edges, bounded by depth, with a confidence that decays with distance (direct =\n * high; transitive lower; ambiguous/dynamic edges already carry lower edge\n * confidence which we fold in). Test-impact selection (`--tests`) lands in\n * Phase 2; this is the structural blast radius.\n */\n\nconst DEPEND_EDGES = new Set<EdgeKind>(['call', 'import', 'extends', 'implements', 'references']);\n\nexport interface ImpactItem {\n id: string;\n name: string;\n kind: string;\n file: string;\n line: number;\n depth: number;\n confidence: number;\n}\n\nexport interface ImpactResult {\n root: { id: string; name: string };\n depth: number;\n affected: ImpactItem[];\n direct: number;\n transitive: number;\n /** Lowest edge confidence encountered (e.g. a dynamic-dispatch edge). */\n minEdgeConfidence: number;\n}\n\nexport function impactOf(graph: VgGraph, rootId: string, opts: { depth?: number } = {}): ImpactResult {\n const maxDepth = Math.max(1, opts.depth ?? 4);\n const index = indexFor(graph);\n const root = index.node(rootId);\n\n const affected = new Map<string, ImpactItem>();\n let minEdgeConfidence = 1;\n\n // BFS over incoming dependency edges (dependents of the frontier).\n let frontier: { id: string; conf: number }[] = [{ id: rootId, conf: 1 }];\n for (let depth = 1; depth <= maxDepth; depth++) {\n const nextFrontier: { id: string; conf: number }[] = [];\n for (const { id, conf } of frontier) {\n for (const e of index.in(id)) {\n if (!DEPEND_EDGES.has(e.kind)) continue;\n minEdgeConfidence = Math.min(minEdgeConfidence, e.confidence);\n const dependentId = e.src;\n if (dependentId === rootId || affected.has(dependentId)) continue;\n const node = index.node(dependentId);\n if (!node) continue;\n const conf2 = round(conf * e.confidence * 0.9); // decay with distance\n affected.set(dependentId, {\n id: node.id,\n name: node.qualifiedName,\n kind: node.kind,\n file: node.file,\n line: node.span.start,\n depth,\n confidence: conf2,\n });\n nextFrontier.push({ id: dependentId, conf: conf2 });\n }\n }\n frontier = nextFrontier;\n if (frontier.length === 0) break;\n }\n\n const items = [...affected.values()].sort(\n (a, b) => a.depth - b.depth || b.confidence - a.confidence || a.name.localeCompare(b.name),\n );\n\n return {\n root: { id: rootId, name: root?.qualifiedName ?? rootId },\n depth: maxDepth,\n affected: items,\n direct: items.filter((i) => i.depth === 1).length,\n transitive: items.filter((i) => i.depth > 1).length,\n minEdgeConfidence: round(minEdgeConfidence),\n };\n}\n\nfunction round(x: number): number {\n return Math.round(x * 1e6) / 1e6;\n}\n"]}
@@ -2,14 +2,14 @@ import { listHostSessions, hostSessionPoolSize, acquireHostSession, evictIdleSes
2
2
  import { isRelevantChange } from './chunk-DBX3DL27.js';
3
3
  import { inventory } from './chunk-6BEBJCK4.js';
4
4
  import { resolveOne } from './chunk-J7LKEB2R.js';
5
- import { impactOf, queryGraph, queryGraphSemantic } from './chunk-LUJ4H4RJ.js';
6
- import { loadGraph } from './chunk-5BFA532E.js';
5
+ import { impactOf, queryGraph, queryGraphSemantic } from './chunk-K3SXWOTT.js';
6
+ import { loadGraph } from './chunk-7M4E7UGX.js';
7
7
  import { vgdSocketPath, vgdPidPath } from './chunk-6H2QV5DR.js';
8
8
  import { isSkippedDirName, SKIP_FILES } from './chunk-RTURQXQL.js';
9
- import { embedTargets, readCachedVectors, cosine } from './chunk-B5X246UH.js';
9
+ import { embedTargets, readCachedVectors, cosine } from './chunk-FQHWPOTS.js';
10
10
  import { cacheDir } from './chunk-MVPRPSXU.js';
11
11
  import { stableStringify } from './chunk-O3LABX6I.js';
12
- import { VERSION } from './chunk-KFLNWYZG.js';
12
+ import { VERSION } from './chunk-G3ACLBMG.js';
13
13
  import { repositoryIdFromRoot, globalGraphPathForRef, globalGraphPath } from './chunk-XP6UUCZZ.js';
14
14
  import { hashString, canonicalize, hashBytes } from './chunk-JFGYT6BI.js';
15
15
  import { activeGraphSlotKey, detectGitRef, clearDetectGitRefCache } from './chunk-XQNKCA2J.js';
@@ -2140,5 +2140,5 @@ var BranchGraphSession = class {
2140
2140
  };
2141
2141
 
2142
2142
  export { ActiveGraphCache, BranchGraphSession, DEFAULT_ACTIVE_GRAPH_IDLE_MS, VGD_PROTOCOL_VERSION, WorkspaceRegistry, endOfLine, findPackageLine, findRuntimeLine, isDependencyFile, isManifest, loadScanCache, manifestHash, manifestKind, parseRequest, startVgdServer, writeScanCache };
2143
- //# sourceMappingURL=chunk-JSZ46IDG.js.map
2144
- //# sourceMappingURL=chunk-JSZ46IDG.js.map
2143
+ //# sourceMappingURL=chunk-KYM55VZX.js.map
2144
+ //# sourceMappingURL=chunk-KYM55VZX.js.map