@vibgrate/relevance 2026.824.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,43 @@
1
+ Vibgrate Relevance Kernel — Proprietary License
2
+ SPDX-License-Identifier: LicenseRef-Vibgrate-Proprietary
3
+ Copyright (c) 2026 Vibgrate. All rights reserved.
4
+
5
+ This package ("@vibgrate/relevance") distributes the Vibgrate relevance kernel
6
+ — query-analysis logic and the compiled relevance pack (curated taxonomy,
7
+ vendor, synonym, and acronym data with their weights and calibration) — as a
8
+ compiled artifact. It is proprietary and confidential, and is licensed
9
+ SEPARATELY from — and is NOT covered by — the Apache-2.0 license that applies
10
+ to @vibgrate/cli, @vibgrate/core-open, or any other open component.
11
+
12
+ 1. DEFINITIONS
13
+ "Distributed Artifact" means the compiled JavaScript/TypeScript module(s),
14
+ the embedded relevance pack data, and any compiled WebAssembly module
15
+ shipped in this package. The underlying source and the pack build tooling
16
+ are NOT part of this package and are not distributed.
17
+
18
+ 2. GRANT (EXECUTION)
19
+ Subject to a valid Vibgrate license or subscription, Vibgrate grants you a
20
+ non-exclusive, non-transferable, revocable right to EXECUTE the Distributed
21
+ Artifact as an optional module of the Vibgrate CLI, on any machine you
22
+ control — including air-gapped and customer-premises environments. Analysis
23
+ runs locally; prompts never leave the client.
24
+
25
+ 3. RESTRICTIONS
26
+ You may NOT, in whole or in part: (a) copy, redistribute, sublicense, sell,
27
+ or publish the Distributed Artifact outside an authorized Vibgrate CLI
28
+ distribution; (b) reverse-engineer, decompile, disassemble, or otherwise
29
+ attempt to derive the source of, or the curation and calibration within,
30
+ the Distributed Artifact, except to the extent this restriction is
31
+ unenforceable under applicable law; (c) create derivative works; (d) remove
32
+ or alter this notice.
33
+
34
+ 4. NO OPEN-SOURCE GRANT
35
+ Nothing in this repository's Apache-2.0 license, NOTICE, or any other open
36
+ license extends to this package.
37
+
38
+ 5. NO WARRANTY
39
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
+ IMPLIED. TO THE MAXIMUM EXTENT PERMITTED BY LAW, VIBGRATE DISCLAIMS ALL
41
+ LIABILITY ARISING FROM ITS USE.
42
+
43
+ For licensing inquiries: legal@vibgrate.com
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # @vibgrate/relevance
2
+
3
+ The Vibgrate relevance kernel: deterministic query analysis over the compiled
4
+ relevance pack, consumed by the Vibgrate CLI's optional relevance-provider
5
+ seam (`engine/relevance-provider.ts` in `@vibgrate/cli`).
6
+
7
+ This package is a **binary-only, proprietary** distribution: it ships compiled
8
+ modules plus the embedded relevance pack — **never the source or the pack
9
+ build tooling**. Given a natural-language coding prompt it returns inferred
10
+ topics and weighted expansion terms with provenance ("direct debits" →
11
+ payments incl. GoCardless vocabulary, "locales" → i18n, "tailwind" → CSS), so
12
+ `vg ask` / `vg code` capsules reach the code a prompt means even when no
13
+ symbol names it. Analysis runs entirely locally (incl. air-gapped); prompts
14
+ never leave the machine.
15
+
16
+ > The kernel source and the pack builder live in a private repository and are
17
+ > **not** part of this package. v1 is the taxonomy-as-expander stage; the
18
+ > keyword-mining/MMR and static-vector stages land behind the same interface
19
+ > (compiled to WASM) in later versions.
20
+
21
+ ## API
22
+
23
+ ```ts
24
+ import { createRelevanceProvider } from "@vibgrate/relevance";
25
+
26
+ const kernel = createRelevanceProvider();
27
+ kernel.version();
28
+ // "vg-relevance@1.4.0+pack.2026.08.5"
29
+ kernel.analyzeQuery("handle gocardless 429 responses");
30
+ // { version, topics: [{ id: "payments", score: 1 }],
31
+ // expansions: [{ term: "mandate", from: "gocardless", weight: 0.6 }, …] }
32
+
33
+ // Schema-5 (v1.4, the 2026-08 relocation): the module IS the relevance
34
+ // engine for vg ask / vg code capsule seeds. The host hands it the ask and
35
+ // a name-only symbol view of its code graph; the module returns the
36
+ // ordered, provenance-annotated seed list plus the plain-language concept
37
+ // map. Term roles, the concept lexicon, IDF weighting, typo repair,
38
+ // morphology and seed diversification all live here now.
39
+ kernel.rankSymbols("the checkout fails with \"sepa mandate missing\"", symbols, { limit: 16 });
40
+ // { version, hasContent: true,
41
+ // seeds: [{ id, score, why: "matched: quote→sepa, quote→mandate, …" }, …],
42
+ // conceptMap: ["- \"checkout\" in the ask implies …", …] }
43
+ ```
44
+
45
+ The host CLI auto-provisions this module (silently, on every run; declinable)
46
+ and loads it through its generic provider seam (default module path or
47
+ `VIBGRATE_RELEVANCE_PATH`), sanitizes every result at its own trust boundary,
48
+ and degrades to mechanical exact-name matching when the module is absent or
49
+ `VIBGRATE_NO_KERNEL=1` is set.
50
+
51
+ ## Build (maintainers)
52
+
53
+ ```bash
54
+ pnpm --filter @vibgrate/relevance build # tsup → dist/
55
+ ```
56
+
57
+ The embedded pack is regenerated from the content corpus with
58
+ `node scripts/build-relevance-pack.mjs` (monorepo root) — bump the pack
59
+ version there on any semantic change.
Binary file
@@ -0,0 +1,179 @@
1
+ interface RankableSymbol {
2
+ id: string;
3
+ name: string;
4
+ qualifiedName: string;
5
+ file: string;
6
+ /** 0..1 graph importance — a mild tiebreaker, never a driver. */
7
+ importance: number;
8
+ }
9
+ interface RankOptions {
10
+ /** Max seeds returned (default 16, capped at 64). */
11
+ limit?: number;
12
+ /** Previous conversational ask (multi-turn `vg code`): its content terms
13
+ * join ranking at a damped weight so follow-ups stay on topic. */
14
+ priorQuestion?: string | null;
15
+ /** Per-node topic tags (host enrichment sidecar, provider tagNode output):
16
+ * bounded affinity bonus when a node's tags intersect the ask's topics. */
17
+ topicTags?: Record<string, readonly string[]> | null;
18
+ }
19
+ interface RankedSeed {
20
+ id: string;
21
+ score: number;
22
+ /** Match provenance ("matched: stripe, checkout→session"). */
23
+ why: string;
24
+ }
25
+ interface RankResult {
26
+ version: string;
27
+ /** False when the ask carries no content evidence (weak-only / off-topic):
28
+ * seeds is empty and the honest miss should be surfaced as such. */
29
+ hasContent: boolean;
30
+ seeds: RankedSeed[];
31
+ /** Plain-language "how the ask was interpreted" lines for the capsule. */
32
+ conceptMap: string[];
33
+ }
34
+ interface SymbolRanker {
35
+ rankSymbols(question: string, symbols: RankableSymbol[], opts?: RankOptions): RankResult;
36
+ }
37
+ /**
38
+ * Build the symbol ranker over the pack-driven analyzer. `analyze` is the
39
+ * kernel's own `analyzeQuery` (TS reference or WASM engine) — composed in so
40
+ * pack vocabulary and taxonomy affinity join ranking exactly as the host's
41
+ * seam merged them before the relocation.
42
+ */
43
+ declare function createSymbolRanker(analyze: (question: string) => RelevanceAnalysis, version: () => string): SymbolRanker;
44
+
45
+ interface RelevanceExpansion {
46
+ /** Single lowercase word, ready for identifier-part matching. */
47
+ term: string;
48
+ /** The prompt token/phrase that produced it (provenance for `why` strings). */
49
+ from: string;
50
+ /** 0..1 — relative confidence; the host scales it into its own scoring. */
51
+ weight: number;
52
+ }
53
+ interface RelevanceTopic {
54
+ id: string;
55
+ /** 0..1, normalized within this analysis. */
56
+ score: number;
57
+ }
58
+ /** One level of a matched taxonomy path, root-first. */
59
+ interface RelevanceTaxonomyLevel {
60
+ /** Leaf slug of this level ("dns"). */
61
+ id: string;
62
+ /** Full path to this level ("infrastructure/networking/dns"). */
63
+ path: string;
64
+ /** 0..1 — confidence that the prompt is about this level. Never increases
65
+ * with depth: a level is at least as certain as anything beneath it. */
66
+ score: number;
67
+ /** This level's OWN vocabulary, so a caller walking up the tree can say what
68
+ * each level means rather than repeating the leaf's words. */
69
+ terms: string[];
70
+ }
71
+ /** A matched taxonomy path: the most specific node plus its ancestor chain. */
72
+ interface RelevanceTaxonomyMatch {
73
+ /** Most specific matched node ("infrastructure/networking/dns/cname"). */
74
+ path: string;
75
+ levels: RelevanceTaxonomyLevel[];
76
+ /** 0..1 for the most specific node. */
77
+ score: number;
78
+ /** Raw, pre-normalization evidence — absolute strength, not relative. */
79
+ evidence: number;
80
+ /** What matched ("cname record", "cloudflare", or "~cloud flre" when the
81
+ * match came from the fuzzy matcher). */
82
+ via: string[];
83
+ /** The matched node's own vocabulary — what code for THIS node looks like.
84
+ * Carried on the match so a host can explain the domain without holding
85
+ * the pack ("dns record", "zone file", "nameserver" for a cname ask,
86
+ * rather than the root topic's generic infrastructure words). */
87
+ terms: string[];
88
+ /** Filenames and extensions this node's work lives in, nearest-ancestor
89
+ * first ("wrangler.toml" for Cloudflare, ".tf" for Terraform). A topic
90
+ * match says what the ask is about; this says where to look. */
91
+ files: string[];
92
+ /** Standards governing this node, current revision first. */
93
+ standards: RelevanceStandard[];
94
+ }
95
+ /** A vendor/product the prompt names, including through a misspelling. */
96
+ interface RelevanceVendorMatch {
97
+ /** Canonical vendor key ("cloudflare"). */
98
+ name: string;
99
+ /** The prompt text that produced it — differs from `name` on a fuzzy hit. */
100
+ from: string;
101
+ /** Taxonomy node the vendor anchors to, when it has one. */
102
+ node?: string;
103
+ /** Legacy flat topic. */
104
+ topic: string;
105
+ /** 0..1 confidence; a fuzzy hit scores below an exact one. */
106
+ score: number;
107
+ /** Filenames and extensions this vendor's configuration lives in. */
108
+ files: string[];
109
+ }
110
+ /** A standard that governs a matched node, at the revision the pack tracks. */
111
+ interface RelevanceStandard {
112
+ /** Name as published, including its version ("W3C WCAG 2.2"). */
113
+ name: string;
114
+ /** Publishing body ("World Wide Web Consortium"). */
115
+ publisher: string;
116
+ /** Taxonomy node it governs. */
117
+ node: string;
118
+ /** "standard" or "regulation" — a duty and a spec are not the same thing. */
119
+ kind: string;
120
+ /** Lowercase category slugs from the website's own vocabulary, deduped
121
+ * ("compliance", "data-privacy"). */
122
+ categories: string[];
123
+ }
124
+ /** A misspelling the kernel resolved, surfaced so callers can explain it. */
125
+ interface RelevanceCorrection {
126
+ from: string;
127
+ to: string;
128
+ /** Edit distance between the prompt text and the canonical form. */
129
+ distance: number;
130
+ }
131
+ interface RelevanceAnalysis {
132
+ version: string;
133
+ topics: RelevanceTopic[];
134
+ expansions: RelevanceExpansion[];
135
+ /** Phase-1.5 (WASM engine): salience-ranked, diversity-selected keywords. */
136
+ keywords?: string[];
137
+ /** Schema-4: hierarchical topic matches, most specific first. */
138
+ taxonomy?: RelevanceTaxonomyMatch[];
139
+ /** Schema-4: vendors named by the prompt, fuzzy matches included. */
140
+ vendors?: RelevanceVendorMatch[];
141
+ /** Schema-4: misspellings the fuzzy matcher resolved. */
142
+ corrections?: RelevanceCorrection[];
143
+ /** Schema-4: every file hint the analysis implies, most specific first and
144
+ * deduped — the single list a caller can render without walking matches. */
145
+ files?: string[];
146
+ /** Schema-4: standards governing what the ask is about, most specific node
147
+ * first. Named at the revision the pack tracks — a superseded revision is
148
+ * never emitted, because naming the wrong one is worse than naming none. */
149
+ standards?: RelevanceStandard[];
150
+ /** Schema-4: every category slug those standards and regulations belong to,
151
+ * deduped and lowercase — the website's own vocabulary, so a caller can
152
+ * cross-reference content by the same key. */
153
+ categories?: string[];
154
+ }
155
+ interface NodeTagInput {
156
+ qualifiedName: string;
157
+ file: string;
158
+ }
159
+ interface RelevanceProviderApi {
160
+ version(): string;
161
+ analyzeQuery(question: string): RelevanceAnalysis;
162
+ /** Deterministic topic tags for one graph node (build-time enrichment). */
163
+ tagNode(input: NodeTagInput): string[];
164
+ /**
165
+ * Schema-5: full symbol ranking for `vg ask` / `vg code` capsule seeds.
166
+ * Attached by createRelevanceProvider (ranker.ts) over this analyzer; the
167
+ * host CLI delegates seed selection here and keeps only mechanical
168
+ * matching as its module-less fallback.
169
+ */
170
+ rankSymbols?: SymbolRanker["rankSymbols"];
171
+ }
172
+ /**
173
+ * Prefer the compiled WASM engine when its artifact shipped (the confidential
174
+ * implementation inside the sandbox); otherwise this file's TypeScript
175
+ * reference implementation answers — the parity test keeps them equivalent.
176
+ */
177
+ declare function createRelevanceProvider(): RelevanceProviderApi;
178
+
179
+ export { type RankOptions, type RankResult, type RankableSymbol, type RankedSeed, type RelevanceAnalysis, type RelevanceExpansion, type RelevanceProviderApi, type RelevanceTopic, type SymbolRanker, createRelevanceProvider, createSymbolRanker };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var re={};import*as Q from"node:fs";import{fileURLToPath as et}from"node:url";var W;function ke(){if(W!==void 0)return W;W=null;try{let t=[new URL("./engine/relevance.wasm",import.meta.url),new URL("../crate/target/wasm32-unknown-unknown/release/vibgrate_relevance_kernel.wasm",import.meta.url)].map(i=>et(i)).find(i=>Q.existsSync(i));if(!t)return W;let n=new WebAssembly.Module(Q.readFileSync(t)),o=new WebAssembly.Instance(n,{}).exports,l=i=>{let f=new TextEncoder().encode(i),d=o.vg_alloc(f.length);return new Uint8Array(o.memory.buffer,d,f.length).set(f),{ptr:d,len:f.length}},r=i=>{let d=new DataView(o.memory.buffer,i,4).getUint32(0,!0),c=new TextDecoder().decode(new Uint8Array(o.memory.buffer,i+4,d));return o.vg_free(i,4+d),c};return W={version:()=>r(o.vg_version()),analyzeQueryJson:i=>{let{ptr:f,len:d}=l(i),c=r(o.vg_analyze(f,d));return o.vg_free(f,d),c},tagNodeJson:(i,f)=>{let d=l(i),c=l(f),h=r(o.vg_tag(d.ptr,d.len,c.ptr,c.len));return o.vg_free(d.ptr,d.len),o.vg_free(c.ptr,c.len),h}},W}catch{return W=null,W}}var H=new Set(["add","adds","added","adding","create","creates","created","creating","make","makes","making","made","new","newly","remove","removes","removed","removing","delete","deletes","deleted","deleting","update","updates","updated","updating","change","changes","changed","changing","set","sets","setting","setup","get","gets","getting","use","uses","used","using","want","wants","wanted","do","does","doing","done","support","supports","supported","supporting","enable","enables","enabled","enabling","disable","disables","disabled","disabling","allow","allows","allowed","implement","implements","implemented","implementing","build","builds","building","built","via","through","into","onto","way","ways","thing","things","stuff","feature","features","functionality","method","methods","option","options","ability","form","forms","page","pages","screen","screens","button","buttons","help","start","begin","work","works","working","also","currently","properly","correctly","please","happens","happen","something","somewhere","step","steps","flow","process","you","can","fail","fails","failed","failing","failure","failures","crash","crashes","crashing","issue","issues","problem","problems","pass","passes","passing","slow","slowly","slower","flaky","valid","invalid","user","users","printed","prints","returns","returned","returning","depends","depending","results","expected","actual"]),G={payment:["stripe","billing","invoice","checkout","charge","subscription","refund","payout","card","debit","mandate"],pay:["payment","stripe","charge","billing","invoice"],paying:["payment","stripe","charge","billing","invoice"],paid:["payment","invoice","charge"],receipt:["invoice","billing","payment","charge"],billing:["invoice","payment","subscription","stripe","charge","renewal"],billed:["billing","invoice","charge","payment"],bill:["billing","invoice","payment"],checkout:["stripe","payment","cart","session"],debit:["mandate","sepa","bacs","ach","bank","payment"],mandate:["sepa","bacs","debit"],sepa:["mandate","debit","iban","bank"],bacs:["mandate","debit","bank"],ach:["mandate","debit","bank"],stripe:["payment","billing","checkout","webhook","charge","card"],refund:["payment","invoice","stripe","charge"],invoice:["billing","payment","refund","subscription"],subscription:["billing","renewal","invoice","plan","recurring"],recurring:["subscription","renewal","mandate","debit"],renewal:["subscription","billing","renew"],card:["payment","charge","stripe"],credit:["card","payment","charge"],bank:["debit","mandate","sepa","iban","account"],charge:["payment","card","stripe"],webhook:["event","handler","callback"],price:["payment","billing","plan"],customer:["billing","account","user"],auth:["login","session","token","oauth","password","credential"],authentication:["auth","login","session","token","password"],authenticated:["auth","login","session"],login:["auth","session","password","signin","oauth"],signin:["login","auth","session"],signup:["register","onboard","account"],logout:["session","auth","signout"],password:["auth","login","credential","hash"],session:["auth","login","token"],token:["session","auth","jwt"],oauth:["auth","login","callback","provider"],google:["oauth","login","auth"],github:["oauth","login","auth"],sso:["oauth","auth","saml","login"],credential:["auth","password","token","secret"],dependency:["package","audit","vulnerability","advisory","lockfile","version"],package:["dependency","audit","vulnerability","advisory","lockfile"],vulnerability:["advisory","cve","osv","audit","vulnerable"],vulnerable:["vulnerability","advisory","audit","cve"],advisory:["vulnerability","cve","osv","audit"],cve:["vulnerability","advisory","osv"],risk:["vulnerability","audit","advisory"],security:["vulnerability","audit","advisory"],audit:["dependency","vulnerability","advisory"],scan:["audit","vulnerability","scanner"],email:["mail","smtp","sender","template","message"],mail:["email","smtp","sender"],notification:["notify","email","sms","push","alert"],notify:["notification","email","alert"],sms:["notification","message","twilio"],cart:["checkout","order","shop","basket","discount"],basket:["cart","checkout","order"],order:["cart","shipment","fulfillment","shop","checkout"],ship:["order","fulfillment","delivery","shipment"],shipment:["order","fulfillment","delivery","track"],shipping:["order","fulfillment","delivery","shipment"],shipped:["order","fulfillment","shipment"],inventory:["stock","product","catalog","restock"],stock:["inventory","product","restock"],product:["catalog","inventory","shop"],discount:["coupon","promo","cart","price"],coupon:["discount","promo","code"],chat:["message","room","conversation","presence"],message:["chat","sms","notification","thread"],conversation:["chat","message","thread"],presence:["online","typing","status"],online:["presence","status"],typing:["presence","indicator","broadcast"],video:["media","transcode","playback","stream","thumbnail"],stream:["video","playback","manifest","media"],streaming:["video","playback","manifest","media"],playback:["video","stream","media","watch"],transcode:["video","media","encode"],thumbnail:["video","image","media"],media:["video","stream","playback","asset"],analytics:["event","track","metric","funnel","report"],event:["track","analytics","webhook"],track:["event","analytics"],funnel:["conversion","analytics","event"],conversion:["funnel","analytics"],report:["metrics","export","analytics"],article:["publish","content","post","cms"],publish:["article","release","post","content"],post:["article","publish","message"],blog:["article","publish","post","cms"],content:["cms","article","markdown"],markdown:["render","article","content"],cms:["article","content","publish"],deploy:["release","rollback","pipeline","deployment"],deployment:["deploy","release","rollback","pipeline"],release:["deploy","version","rollback"],rollback:["deploy","release","deployment"],pipeline:["stage","deploy","runner","ci"],canary:["deploy","rollout","release"],push:["notification","device","token","mobile"],device:["push","token","mobile","register"],deeplink:["link","route","universal"],mobile:["push","device","deeplink","app"],ios:["mobile","universal","link","app"],android:["mobile","push","device","app"],batch:["settlement","job","etl","reconcile"],settlement:["batch","reconcile","ledger","clearing"],reconcile:["ledger","settlement","batch"],ledger:["settlement","reconcile","balance","journal"],mainframe:["batch","settlement","ebcdic","cobol","fixed"],ebcdic:["mainframe","record","convert","legacy"],cobol:["mainframe","batch","ebcdic"],etl:["batch","pipeline","extract","load","transform"],nightly:["batch","cron","schedule","job"],geocode:["address","location","map","geo"],address:["geocode","location"],map:["geo","route","location"],route:["distance","path","planner","geo"],distance:["route","haversine","geo"],location:["geo","geocode","map"],arrival:["route","eta","estimate"],translation:["locale","i18n","language","translate"],translate:["translation","locale","language"],locale:["translation","i18n","language","format"],i18n:["translation","locale","language"],language:["locale","translation","i18n"],localized:["locale","translation","format"],metric:["counter","prometheus","telemetry","export"],prometheus:["metric","exporter","monitoring"],trace:["span","telemetry","observability"],span:["trace","telemetry"],monitoring:["metric","trace","alert","observability"],telemetry:["metric","trace","span"],counter:["metric","increment"],flag:["feature","rollout","toggle","experiment"],rollout:["flag","percentage","release","experiment","deploy"],toggle:["flag","feature","switch"],experiment:["variant","assign","flag","exposure"],variant:["experiment","assign"],database:["schema","migration","sql","query","orm"],db:["database","schema","migration","sql"],migration:["database","schema","migrate","sql"],cache:["redis","ttl","store"],queue:["job","worker","task","batch"],job:["queue","worker","cron"],upload:["file","storage","blob","asset"],storage:["file","upload","bucket","blob"],permission:["role","rbac","acl","access","grant"],role:["permission","rbac","access"],error:["exception","failure","handler"],config:["settings","env","configuration"]},Se={"direct debit":["debit","mandate","sepa","bacs","bank"],"direct debits":["debit","mandate","sepa","bacs","bank"],"sign in":["login","signin","auth","session"],"signs in":["login","signin","auth","session"],"log in":["login","auth","session"],"logs in":["login","auth","session"],"logged in":["login","auth","session"],"sign up":["signup","register","account"],"signs up":["signup","register","account"],"signing up":["signup","register","account"],"signed up":["signup","register","account"],"credit card":["card","payment","charge","stripe"],"credit cards":["card","payment","charge","stripe"],"bank transfer":["bank","payment","sepa","transfer"],"rate limit":["ratelimit","throttle","quota"],"two factor":["totp","mfa","otp","auth"],"payment method":["payment","stripe","card","debit"],"payment methods":["payment","stripe","card","debit"],"push notification":["push","device","token","notification"],"push notifications":["push","device","token","notification"],"deep link":["deeplink","link","route"],"deep links":["deeplink","link","route"],"universal link":["deeplink","link","universal"],"universal links":["deeplink","link","universal"],"feature flag":["flag","rollout","toggle","experiment"],"feature flags":["flag","rollout","toggle","experiment"],"shopping cart":["cart","checkout","order"],"roll back":["rollback","deploy","release"],"rolled back":["rollback","deploy","release"],"ab test":["experiment","variant"],"sign out":["logout","session","auth"],"fixed width":["record","export","mainframe","batch"],"canary rollout":["deploy","deployment","release","pipeline"],"canary rollouts":["deploy","deployment","release","pipeline"],"blog post":["article","publish","cms","content","post","markdown"],"blog posts":["article","publish","cms","content","post","markdown"]},tt={"canary rollout":["rollout"],"canary rollouts":["rollouts"],"blog post":["post","blog"],"blog posts":["posts","blog"]},nt=new Set(["address the","address this","address that","address these","address those","address all","address my","track down","track it","track this","track that","track them","batch the","batch these","batch them","batch those","ship it","ship this","ship that"]),st=new Set(["users report","user reports","customers report","customer reports","people report","they report"]);function oe(e){let t=new Set;for(let n=0;n+1<e.length;n++){let a=`${e[n]} ${e[n+1]}`;nt.has(a)&&t.add(e[n]),st.has(a)&&t.add(e[n+1])}return t}function Re(){return Object.keys(G)}function _e(e){if(!e)return null;if(Object.hasOwn(G,e))return e;if(e.endsWith("ies")){let t=e.slice(0,-3)+"y";if(Object.hasOwn(G,t))return t}if(e.endsWith("s")){let t=e.slice(0,-1);if(Object.hasOwn(G,t))return t}return null}function j(e){let t=new Set(e),n=oe(e),a=[],o=new Set,l=(i,f)=>{t.has(i)||o.has(i)||(o.add(i),a.push({term:i,from:f}))};for(let i=0;i+1<e.length;i++){let f=`${e[i]} ${e[i+1]}`,d=Se[f];if(d)for(let c of d)l(c,f)}let r=K(e);for(let i of e){if(n.has(i)||r.has(i))continue;let f=_e(i);if(f)for(let d of G[f])l(d,i)}return a}function K(e){let t=new Set;for(let n=0;n+1<e.length;n++){let a=`${e[n]} ${e[n+1]}`;if(Se[a]){for(let o of[e[n],e[n+1]])_e(o)||t.add(o);for(let o of tt[a]??[])t.add(o)}}return t}var Te=new Set(["the","a","an","is","are","was","were","be","to","of","in","on","for","and","or","where","what","which","how","do","does","did","i","we","it","this","that","with","when","who","why","can","should","my","our","you","your","from","by","at","as","find","code","responsible","need","modify","me","implementation","explain","works","codebase","contains","file","not","no","exist","exists","existing","occurrence","occurrences","occurence","occurences","every","place","places","string","literal","text","search","locate","look","looking","show","list","all","fix","fixes","fixing","bug","bugs","broken","busted","borked","wrong","incorrect","incorrectly","figure","out","sure"]),rt=.25,Ee=.7,ot=.35,it=.5,at=.5,ct=.4,xe=.3,lt=.3;function ut(e){let t=new Map;for(let o of e){let l=t.get(o.sym.file);(l===void 0||o.score>l)&&t.set(o.sym.file,o.score)}let n=new Map;for(let[o,l]of t){let r=o.slice(0,o.lastIndexOf("/")+1),i=n.get(r)??[];i.push(l),n.set(r,i)}let a=new Map;for(let[o,l]of n)l.sort((r,i)=>i-r),a.set(o,l.slice(0,3).reduce((r,i)=>r+i,0));return a}var ft=4,dt=64,gt=.35,pt=/(^|\/)(tests?|testing|__tests__)(\/|$)|(^|\/)(test_[^/]*|conftest\.py)$|[._-](test|tests|spec)\.[a-z0-9]+$/i;function mt(e){return pt.test(e)}var ht=/\b(?:write|writes|add|adds|create|creates|extend|extends|improve|improves|update|updates|generate|generates)\b[^.?!]{0,40}\btests?\b|\bwhere\s+(?:is|are)\b[^.?!]{0,40}\btested\b|\btest\s+coverage\b/i;function bt(e,t){return ht.test(e)?!0:t.some(n=>/^test_|_tests?$|^conftest$/.test(n.term))}function Y(e){return[...new Set(e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=1&&!Te.has(t)))]}function q(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=1)}function yt(e){let t=e.trim();return t=t.replace(/[.,;:!)\]}>]+$/g,""),t.endsWith("?")&&t.lastIndexOf("?")===t.length-1&&(t=t.slice(0,-1)),t}function ee(e){let t=[],n=new Set,a=(o,l)=>{let r=o.trim();r=l==="url"?yt(r):r.replace(/[.,;:!)\]}>?]+$/g,""),!(r.length<2||n.has(r))&&(n.add(r),t.push(r))};for(let o of e.matchAll(/https?:\/\/[^\s"'`<>]+/gi))a(o[0],"url");for(let o of e.matchAll(/(["'`])((?:(?!\1)[^\\]|\\.){2,})\1/g))a(o[2].replace(/\\(.)/g,"$1"),"quote");return t}function ie(e){let t=e;for(let n of e.matchAll(/https?:\/\/[^\s"'`<>]+/gi))t=t.split(n[0]).join(" ");for(let n of ee(e))t=t.split(n).join(" ");return t=t.replace(/(["'`])\s*\1/g," "),t.replace(/\s+/g," ").trim()}function vt(e){return/\b(where\s+is|where\s+are|find\s+(all\s+|every\s+)?occurrences?|does\s+not\s+exist|locate|search\s+for|occurrences?\s+of)\b/i.test(e)}function wt(e,t){if(!t.length||vt(e))return null;let n=t.filter(a=>!/^https?:\/\//i.test(a)&&!a.includes("/"));return n.length?n.join(" "):null}function J(e){return new Set(e.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).filter(Boolean).map(t=>t.toLowerCase()))}function ae(e){return e.length>=5&&e.endsWith("ies")?e.slice(0,-3)+"y":e.length>=4&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):null}function kt(e,t){for(let n of t){let a=Ne(e,n);if(a>=5&&a>=.6*Math.min(e.length,n.length))return!0}return!1}function Ne(e,t){let n=Math.min(e.length,t.length),a=0;for(;a<n&&e[a]===t[a];)a++;return a}var St=16,Rt=36,_t=.75,Et=.55;function xt(e){let t=new Map;for(let n of e){if(Te.has(n)||t.has(n))continue;let a=t.size;t.set(n,a<St?1:a<Rt?_t:Et)}return t}function Mt(e,t,n,a){let o=Y(e),l=q(e),r=new Set(o),i=K(l),f=oe(l),d=xt(l),c=o.map(m=>({term:m,weak:H.has(m)||i.has(m)||f.has(m),positional:d.get(m)??1})),h=new Set(o);for(let m of j(l))r.has(m.term)||(c.push({term:m.term,weak:!1,from:m.from,positional:d.get(m.from)??1}),h.add(m.term));if(a){let m=q(a),b=K(m);for(let p of Y(a))h.has(p)||H.has(p)||b.has(p)||(c.push({term:p,weak:!1,from:"quote",quoted:!0}),h.add(p));for(let p of j(m))h.has(p.term)||(c.push({term:p.term,weak:!1,from:p.from}),h.add(p.term))}for(let m of t?.expansions??[]){let b=String(m?.term??"").toLowerCase().trim(),p=String(m?.from??"").toLowerCase().trim(),_=Number(m?.weight);!b||!p||b.includes(" ")||h.has(b)||H.has(p)||H.has(b)||!Number.isFinite(_)||_<at||(c.push({term:b,weak:!1,from:p,packWeight:Math.min(1,_)}),h.add(b))}if(n?.trim()){let m=q(n),b=K(m);for(let p of Y(n))h.has(p)||H.has(p)||b.has(p)||(c.push({term:p,weak:!1,carried:!0}),h.add(p));for(let p of j(m))h.has(p.term)||(c.push({term:p.term,weak:!1,from:p.from,carried:!0}),h.add(p.term))}let k=c.some(m=>!m.weak);return{terms:c,hasContent:k}}function Oe(e){let t=e?.trim();return t?ee(t).length>0?ie(t):t:null}function At(e,t){let n=t.terms.filter(r=>!r.weak&&!r.from&&!r.carried&&r.term.length>=4);if(!n.length)return;let a=new Map,o=new Set;for(let r of e){let i=r.name.toLowerCase(),f=r.file.toLowerCase(),d=J(r.name);for(let c of d)o.add(c);for(let c of n){let h=ae(c.term);(d.has(c.term)||h!==null&&d.has(h)||i.includes(c.term)||f.includes(c.term))&&a.set(c.term,(a.get(c.term)??0)+1)}}let l=new Set(t.terms.map(r=>r.term));for(let r of n){if((a.get(r.term)??0)>0||j([r.term]).length>0)continue;let i=r.term.length>=8?2:1,f=null,d=(h,k)=>{if(h.length<4||h===r.term||k!==0&&r.term.length<6||Math.abs(h.length-r.term.length)>i||h[0]!==r.term[0])return;let m=Tt(r.term,h,i);if(m>i)return;let b=Ne(r.term,h);(!f||m<f.dist||m===f.dist&&(b>f.prefix||b===f.prefix&&(k<f.lex||k===f.lex&&h<f.cand)))&&(f={cand:h,dist:m,prefix:b,lex:k})};for(let h of Re())d(h,0);for(let h of o)d(h,1);if(!f)continue;let{cand:c}=f;l.has(c)||(t.terms.push({term:c,weak:!1,from:r.term}),l.add(c))}}function Tt(e,t,n){let a=e.length,o=t.length;if(Math.abs(a-o)>n)return n+1;let l=null,r=Array.from({length:o+1},(i,f)=>f);for(let i=1;i<=a;i++){let f=new Array(o+1);f[0]=i;let d=f[0];for(let c=1;c<=o;c++){let h=e[i-1]===t[c-1]?0:1,k=Math.min(r[c]+1,f[c-1]+1,r[c-1]+h);l&&i>1&&c>1&&e[i-1]===t[c-2]&&e[i-2]===t[c-1]&&(k=Math.min(k,l[c-2]+1)),f[c]=k,k<d&&(d=k)}if(d>n)return n+1;l=r,r=f}return r[o]}function Nt(e,t){if(t.length===0)return()=>1;let n=new Map,a=0;for(let l of e){a++;let r=l.name.toLowerCase(),i=J(l.name);for(let f of t){let d=ae(f);(i.has(f)||d!==null&&i.has(d)||r.includes(f))&&n.set(f,(n.get(f)??0)+1)}}let o=new Map;for(let l of t){let r=Math.log((a+1)/((n.get(l)??0)+1))+1;o.set(l,Math.max(.5,Math.min(8,r)))}return l=>o.get(l)??1}function Ot(e,t,n){let a=0,o=0,l=!1,r=[],i=e.name.toLowerCase(),f=e.qualifiedName.toLowerCase(),d=e.file.toLowerCase(),c=d.split("/"),h=new Set(c.slice(0,-1)),k=c[c.length-1].replace(/\.[a-z0-9]+$/,""),m=J(k),b=J(e.name);for(let{term:p,weak:_,from:N,packWeight:S,carried:y,quoted:A,positional:L}of t){let P=S!==void 0?Math.min(S,Ee):N&&!A?Ee:1,O=n(p)*(_?rt:1)*P*(y?it:1)*(L??1),C=(y?"\u21A9":"")+(N?`${N}\u2192${p}`:p),F=p.length>=4,D=ae(p),I=0,B=!1;i===p?(I=10*O,r.push(C)):b.has(p)||D!==null&&b.has(D)?(I=6*O,r.push(C)):k===p||D!==null&&k===D?(I=(O>=3?8:5)*O,r.push(C)):F&&i.includes(p)?(I=4*O,r.push(C)):F&&f.includes(p)||m.has(p)||D!==null&&m.has(D)?(I=3*O,r.push(C)):F&&p.length>=5&&k.includes(p)?(I=2.5*O,r.push(C)):S===void 0&&kt(p,b)?(I=2*O,r.push((y?"\u21A9":"")+(N?`~${N}\u2192${p}`:`~${p}`)),B=!0):h.has(p)?(I=2*O,r.push(C)):F&&d.includes(p)&&(I=1*O,r.push(C)),I>0&&(a+=I,_||(o+=1,B||(l=!0)))}return o===0?{score:0,why:"",strong:!1}:(a*=1+ot*Math.min(o-1,4),{score:a,why:r.length?`matched: ${r.join(", ")}`:"",strong:l})}function It(e,t){let n=e.split("/"),a=t.split("/"),o=0;for(;o<n.length&&o<a.length&&n[o]===a[o];)o++;return o}function $t(e,t,n){if(!n)return{boost:1,label:""};let a=n[e];if(!a?.length)return{boost:1,label:""};let o=t?.taxonomy??[];if(o.length&&a.some(i=>i.includes("/"))){let i=0,f="";for(let d of o){let c=d.path.split("/").length;for(let h of a){let k=It(d.path,h);if(k===0)continue;let m=k/c*d.score;m>i&&(i=m,f=k===c?d.path:d.path.split("/").slice(0,k).join("/"))}}return i<=0?{boost:1,label:""}:{boost:1+xe*Math.min(i,1),label:`, topic:${f}`}}if(!t?.topics?.length)return{boost:1,label:""};let l=0,r=[];for(let i of t.topics)a.includes(i.id)&&(l+=i.score,r.push(i.id));return l<=0?{boost:1,label:""}:{boost:1+xe*Math.min(l,1),label:`, topic:${r.sort().join("+")}`}}function Me(e){return e.toLowerCase().replace(/\d+/g,"")}function Ct(e){let t=e[0]?.score??0;return t<=0?e:e.filter(n=>n.strong||n.score>=t/3)}function Pt(e){let t=new Set,n=[],a=[];for(let d of e)t.has(d.sym.file)?a.push(d):(t.add(d.sym.file),n.push(d));let o=n.concat(a),l=new Set;for(let d of e)d.strong&&l.add(Me(d.sym.file));if(l.size<2)return o;let r=new Map,i=[],f=[];for(let d of o){let c=Me(d.sym.file),h=r.get(c)??0;h<ft?(r.set(c,h+1),i.push(d)):f.push(d)}return i.concat(f)}function Lt(e,t,n){let a=m=>[...new Set(m)].slice(0,8).join(", "),l=ee(e).length>0?ie(e):e,r=[],i=new Map;for(let m of j(q(l))){let b=i.get(m.from)??[];b.push(m.term),i.set(m.from,b)}for(let[m,b]of i)r.push(`- "${m}" in the ask implies these codebase identifiers: ${a(b)}.`);let f=t?.taxonomy??[];if(f.length){let m=new Set,b=[];for(let y of f)for(let A of y.levels)m.has(A.path)||(m.add(A.path),b.push({path:A.path,id:A.id,depth:A.path.split("/").length,terms:A.terms}));let p=Math.max(...b.map(y=>y.depth)),_=(y,A)=>y.terms.length?`${A} ${y.id}; code for it typically uses: ${a(y.terms)}.`:`${A} ${y.id}.`;for(let y of b.filter(A=>A.depth===p))r.push(_(y,"- The ask is specifically about"));let N=new Set(b.filter(y=>y.depth===p).map(y=>y.id));for(let y of(t?.vendors??[]).filter(A=>A.score>0).slice(0,3)){if(N.has(y.name)){y.from!==y.name&&r.push(`- That product was typed "${y.from}".`);continue}r.push(y.from===y.name?`- It names the product "${y.name}".`:`- It names the product "${y.name}" (typed "${y.from}").`)}let S=new Set((t?.vendors??[]).map(y=>y.name));for(let y=p-1;y>=1;y--)for(let A of b.filter(L=>L.depth===y&&!S.has(L.id)))r.push(_(A,"- More broadly, this is"))}else if(t?.topics?.length){let m=new Map;for(let b of t.expansions??[]){let p=m.get(b.from)??[];p.push(b.term),m.set(b.from,p)}for(let b of t.topics.slice(0,3)){let p=m.get(b.id);r.push(p?.length?`- The ask is about the "${b.id}" domain; code for it typically uses: ${a(p)}.`:`- The ask is about the "${b.id}" domain.`)}}let d=t?.standards??[];if(d.length){let m=d.filter(_=>_.kind!=="regulation"),b=d.filter(_=>_.kind==="regulation"),p=_=>_.slice(0,3).map(N=>N.publisher?`${N.name} (${N.publisher})`:N.name).join("; ");m.length&&r.push(`- Standards that govern this area: ${p(m)}.`),b.length&&r.push(`- Regulations that apply here: ${p(b)}.`)}let c=t?.categories??[];c.length&&r.push(`- Related categories: ${a(c)}.`);let h=t?.files??[];h.length&&r.push(`- Files for this kind of work are usually named or extended: ${a(h)}.`);for(let m of(t?.corrections??[]).slice(0,3))r.push(`- Read "${m.from}" in the ask as "${m.to}".`);let k=Oe(n);if(k){let m=new Set(Y(l)),b=K(q(k)),p=Y(k).filter(_=>!m.has(_)&&!H.has(_)&&!b.has(_));p.length&&r.push(`- This is a follow-up; topic words carried from the previous ask: ${a(p)}.`)}return r.length&&r.push('- Seed notation below: `a\u2192b` = ask term "a" implied identifier "b"; `~t` = word-form match; `\u21A9t` = carried from the previous ask.'),r}function Ae(e){return Math.round(e*1e6)/1e6}function ce(e,t){return{rankSymbols(n,a,o={}){let l=Math.max(1,Math.min(o.limit??16,dt)),r=null;try{r=e(n)}catch{r=null}let i=ee(n),f=i.length>0?ie(n):n,d=Oe(o.priorQuestion),c=Mt(f,r,d,wt(n,i));At(a,c);let h=Lt(n,r,o.priorQuestion??null);if(!c.hasContent)return{version:t(),hasContent:!1,seeds:[],conceptMap:h};let k=Nt(a,c.terms.map(S=>S.term)),m=!bt(n,c.terms),b=[];for(let S of a){let{score:y,why:A,strong:L}=Ot(S,c.terms,k);if(y>0){let P=$t(S.id,r,o.topicTags),O=m&&mt(S.file)?gt:1;b.push({sym:S,score:Ae(y*O*P.boost*(1+ct*S.importance)),why:A+P.label,strong:L})}}let p=ut(b),_=0;for(let S of p.values())S>_&&(_=S);if(_>0)for(let S of b){let y=S.sym.file.slice(0,S.sym.file.lastIndexOf("/")+1),A=(p.get(y)??0)/_;S.score=Ae(S.score*(1+lt*A))}b.sort((S,y)=>y.score-S.score||(S.sym.qualifiedName<y.sym.qualifiedName?-1:1));let N=Pt(Ct(b)).slice(0,l).map(S=>({id:S.sym.id,score:S.score,why:S.why}));return{version:t(),hasContent:!0,seeds:N,conceptMap:h}}}}var Dt=!1,Ie=`vg-relevance@1.4.0+pack.${re.version}`,Wt=20,zt=8,Ft=4,Ht=.34,jt=.8,Kt=.6,Ut=.5,Vt=.45,je=new Set(["the","and","for","with","first","new","web","app","development"]),Gt=2e3,Yt=1200,Ke=550,le=2e3,qt=1200,Xt=800,Bt=1e3,Zt=600,$e=1e3,Ce=3e3,Qt=1e3,ue=e=>Math.round(Math.min(e,Ce)/Ce*1e3)/1e3,Ue=6,Jt=6,en=6,tn=10,nn=6,sn=6,rn=8,fe=4,M=re;function on(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=2)}function an(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=1)}var cn=new Set(["the","an","our","your","their","its","this","that","these","those","each","every","another","any"]);function X(e){return e.split(" ").filter(t=>t.length>=3&&!je.has(t))}var ln=40,Pe=128,Ve=Uint8Array.from(Buffer.from(M.vectors?.data??"","base64")),de=new Map((M.vectors?.terms??[]).map((e,t)=>[e,t])),un=new Set(M.vectors?.skip??[]);function fn(e){let t=de.get(e);if(t!==void 0)return{row:t,term:e};if(e.endsWith("s")&&e.length>4){let n=e.slice(0,-1);if(t=de.get(n),t!==void 0)return{row:t,term:n}}return null}function dn(e,t){let n=Ve[e*(M.vectors?.dim??0)+t]??0;return n>127?n-256:n}var T=M.taxonomy??[],z=M.taxonomyTerms??{},Le=M.vendorNode??{},ge=M.fuzzyKeys??[],gn=M.fileHints??{},pn=M.standards??{};function mn(e){let t=[];for(let n=e;n>=0;n=T[n].parent){let a=T[n].path;for(let o of pn[a]??[])t.some(l=>l.name===o.name)||t.push({name:o.name,publisher:o.publisher,node:a,kind:o.kind??"standard",categories:o.categories??[]});if(T[n].parent<0)break}return t.slice(0,fe)}function De(e){let t=[];for(let n=e;n>=0;n=T[n].parent){for(let a of gn[T[n].path]??[])t.includes(a)||t.push(a);if(T[n].parent<0)break}return t.slice(0,sn)}var hn=ge.map(e=>({mask:Ge(e.key),grams:Ye(e.key),len:e.key.length})),pe=new Set(M.weakTerms??[]),te=new Set(M.englishGuard??[]),We=e=>e.includes(" ")?Gt:pe.has(e)?Ke:Yt,me=T.map(()=>[]);for(let[e,t]of T.entries())t.parent>=0&&me[t.parent].push(e);var ze=new Map(T.map((e,t)=>[e.path,t]));function Ge(e){let t=0;for(let n=0;n<e.length;n++){let a=e.charCodeAt(n)-97;t|=a>=0&&a<26?1<<a:1<<26}return t}function bn(e){let t=0;for(let n=e;n;n&=n-1)t++;return t}function Ye(e){let t=[];for(let n=0;n<e.length-1;n++)t.push(e.slice(n,n+2));return[...new Set(t)].sort()}function yn(e,t){let n=0,a=0,o=0;for(;n<e.length&&a<t.length;)e[n]===t[a]?(o++,n++,a++):e[n]<t[a]?n++:a++;return o}function vn(e,t,n){let a=e.length,o=t.length;if(Math.abs(a-o)>n)return n+1;let l=[],r=new Array(o+1);for(let i=0;i<=o;i++)r[i]=i;for(let i=1;i<=a;i++){let f=new Array(o+1);f[0]=i;let d=f[0];for(let c=1;c<=o;c++){let h=e[i-1]===t[c-1]?0:1,k=Math.min(f[c-1]+1,r[c]+1,r[c-1]+h);i>1&&c>1&&e[i-1]===t[c-2]&&e[i-2]===t[c-1]&&(k=Math.min(k,l[c-2]+1)),f[c]=k,k<d&&(d=k)}if(d>n)return n+1;l=r,r=f}return r[o]}var Fe=new Set(["s","es","ed","d","ing","ly","er","ers","ings"]);function wn(e){return e<Ue?0:e>=9?2:1}function kn(e,t=2){let n=Math.min(wn(e.length),t);if(n===0||de.has(e)||te.has(e))return null;let a=Ye(e),o=e.length>=6?2:1,l=null,r=n+1,i=!1,f=Ge(e);for(let c=0;c<ge.length;c++){let h=hn[c];if(Math.abs(h.len-e.length)>n||bn(f^h.mask)>n*2)continue;let k=ge[c];if(yn(a,h.grams)<o)continue;let m=vn(e,k.key,n);m>n||(m<r?(r=m,l=k,i=!1):m===r&&l&&k.ref!==l.ref&&(i=!0))}if(!l||i||r>=2&&e[0]!==l.key[0])return null;let d=e.startsWith(l.key)?e.slice(l.key.length):"";if(d&&/^(id|ids|[0-9]+)$/.test(d))return null;if(e.startsWith(l.key)){let c=e.slice(l.key.length);if(Fe.has(c))return null}return l.key.startsWith(e)&&Fe.has(l.key.slice(e.length))?null:{key:l,distance:r}}var he=new Map;for(let e of T){if(!e.topic)continue;let t=he.get(e.topic);(!t||e.path.split("/").length<t.split("/").length)&&he.set(e.topic,e.path)}var qe=new Map;for(let[e,t]of Object.entries(M.topicPathHints??{}))for(let n of t)qe.set(n,e);function He(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=2)}function Sn(){let e=ke();if(!e&&!Dt)throw new Error("@vibgrate/relevance: the wasm engine failed to load and this build ships no reference implementation. Reinstall the module.");let t=e?{version:()=>e.version(),analyzeQuery:a=>JSON.parse(e.analyzeQueryJson(a)),tagNode:a=>JSON.parse(e.tagNodeJson(a.qualifiedName??"",a.file??""))}:Rn(),n=ce(a=>t.analyzeQuery(a),()=>t.version());return{...t,rankSymbols:n.rankSymbols}}function Rn(){return{version:()=>Ie,tagNode(e){let t=new Set([...He(e.file??""),...He(e.qualifiedName??"")]),n=new Set;for(let o of t){if(o.length<3||pe.has(o)||te.has(o))continue;for(let i of z[o]??[])n.add(T[i].path);let l=Le[o];l&&n.add(l);let r=qe.get(o);if(r&&!l){let i=he.get(r);i&&n.add(i)}}return[...n].filter(o=>![...n].some(l=>l!==o&&l.startsWith(`${o}/`))).sort((o,l)=>l.split("/").length-o.split("/").length||(o<l?-1:1)).slice(0,3)},analyzeQuery(e){let t=on(e),n=new Set(t);for(let s=0;s<t.length-1;s++)n.add(`${t[s]} ${t[s+1]}`);let a=new Set(n),o=[];for(let s of[...n].sort()){let u=M.acronyms[s];u&&o.push({acronym:s,full:u})}for(let s of o)for(let u of X(s.full))n.add(u);let l=an(e),r=` ${[...l,...o.map(s=>s.full)].join(" ")} `,i=(s,u)=>{let w=` ${u} `;for(let g=s.indexOf(w);g!==-1;g=s.indexOf(w,g+1)){let v=s.slice(0,g),x=v.lastIndexOf(" ");if(x!==-1&&cn.has(v.slice(x+1)))return!0}return!1},f=(s,u)=>u.charCodeAt(0)===97&&u.charCodeAt(1)===32?i(s,u):s.includes(` ${u} `),d=s=>s.includes(" ")?f(r,s):n.has(s),c=s=>s.length>3&&s.endsWith("s")&&!s.endsWith("ss")?s.slice(0,-1):s,h=t.map(c),k=` ${l.map(c).join(" ")} `,m=new Set(h);for(let s=0;s<h.length-1;s++)m.add(`${h[s]} ${h[s+1]}`);let b=s=>d(s)||(s.includes(" ")?f(k,s):m.has(s)),p=[],_=new Map,N=(s,u)=>_.set(s,(_.get(s)??0)+u),S=new Map,y=new Map,A=new Map,L=[],P=(s,u,w)=>{S.set(s,(S.get(s)??0)+u);let g=y.get(s)??[];g.includes(w)||g.push(w),y.set(s,g)},O=(s,u,w)=>{let g=M.vendors[s];if(!g)return;let v=A.get(s),x=ue(w);if(v&&v.score>=x)return;let E=Le[s],R=E!==void 0?ze.get(E):void 0;if(A.set(s,{name:s,from:u,topic:g.topic,score:x,files:R!==void 0?De(R):[],...E?{node:E}:{}}),E!==void 0){let $=ze.get(E);$!==void 0&&P($,w,u===s?s:`~${u}`)}};if(T.length){for(let g of o)for(let v of z[g.acronym]??[])P(v,Bt,g.acronym);for(let[g,v]of Object.entries(z)){if(!b(g))continue;let x=We(g),E=Math.floor(x/v.length);for(let R of v)P(R,E,g)}for(let g of n)M.vendors[g]&&O(g,g,le);let s=[];for(let g of t)!M.vendors[g]&&!z[g]&&s.push({token:g,from:g,maxDistance:2});for(let g=0;g<t.length-1;g++){let v=t[g],x=t[g+1],E=`${v}${x}`;if(M.vendors[E]){O(E,`${v} ${x}`,le);continue}if(z[E])continue;let R=[v,x].filter($=>!te.has($));v.length>=3&&x.length>=3&&R.some($=>$.length>=4)&&s.push({token:E,from:`${v} ${x}`,maxDistance:1})}let u=new Set,w=new Map;for(let{token:g,from:v,maxDistance:x}of s){if(g.length<Ue||u.has(g)||(u.add(g),M.vendors[g]||z[g]))continue;let E=kn(g,x);if(!E||E.distance===0)continue;let R=E.distance===1?qt:Xt;if(L.push({from:v,to:E.key.ref,distance:E.distance}),w.set(g,E.key.ref),E.key.kind==="vendor")O(E.key.ref,v,R);else if(E.key.kind==="term"){let $=z[E.key.ref]??[];for(let we of $)P(we,Math.floor(R/$.length),`~${v}`)}}if(w.size){let g=t.map(R=>w.get(R)??R);for(let R=0;R<g.length-1;R++){let $=w.get(`${t[R]}${t[R+1]}`);$&&(g[R]=$,g[R+1]="")}let v=g.filter(Boolean),x=` ${v.join(" ")} `,E=new Set(v);for(let R=0;R<v.length-1;R++)E.add(`${v[R]} ${v[R+1]}`);for(let[R,$]of Object.entries(z)){if(!(R.includes(" ")?x.includes(` ${R} `):E.has(R))||(R.includes(" ")?r.includes(` ${R} `):n.has(R)))continue;let Be=Math.floor(We(R)*Jt/10),Ze=Math.floor(Be/$.length);for(let Qe of $)P(Qe,Ze,`~${R}`)}}for(let[g,v]of S){let x=T[g]?.topic;x&&N(x,v)}}for(let s of o)for(let u of X(s.full))p.push({term:u,from:s.acronym,weight:jt});for(let s of n){let u=M.vendors[s];if(u){N(u.topic,le);for(let w of u.terms)for(let g of X(w))p.push({term:g,from:s,weight:Kt})}}for(let[s,u]of Object.entries(M.topics))for(let w of u.terms){if(!d(w))continue;let g=!w.includes(" ")&&(pe.has(w)||te.has(w));N(s,g?Ke:Qt)}if(M.vectors&&Ve.length){let s=new Map;for(let u of t){if(u.length<3||je.has(u)||un.has(u))continue;let w=fn(u);if(w)for(let g=0;g<M.vectors.dim;g++){let v=dn(w.row,g);v>=ln&&s.set(g,(s.get(g)??0)+v)}}for(let[u,w]of s){let g=M.vectors.topics[u];N(g,Math.round(Math.min(w,Pe)*Zt/Pe))}}for(let s of n){let u=M.synonyms[s];if(u)for(let w of u)for(let g of X(w))p.push({term:g,from:s,weight:Ut})}let C=[..._.entries()].filter(([,s])=>s>=$e),F=Math.max(0,...C.map(([,s])=>s)),D=F>0?C.map(([s,u])=>({id:s,score:Math.round(u/F*1e3)/1e3})).filter(s=>s.score>=Ht).sort((s,u)=>u.score-s.score||(s.id<u.id?-1:1)).slice(0,Ft):[];for(let s of D){let u=0;for(let w of M.topics[s.id]?.terms??[])for(let g of X(w))a.has(g)||u>=zt||(p.push({term:g,from:s.id,weight:Math.round(Vt*s.score*1e3)/1e3}),u+=1)}let I=new Map;for(let s of p){if(a.has(s.term))continue;let u=I.get(s.term);(!u||s.weight>u.weight)&&I.set(s.term,s)}let B=[...I.values()].sort((s,u)=>u.weight-s.weight||(s.term<u.term?-1:1)).slice(0,Wt),U=new Array(T.length).fill(0);for(let[s,u]of S){let w=s;for(;w!==void 0&&w>=0;){U[w]+=u;let g=T[w].parent;w=g>=0?g:void 0}}let be=s=>U[s]>=$e,ye=[];for(let s=0;s<T.length;s++)be(s)&&(me[s].some(u=>be(u))||ye.push(s));let ne=ye.map(s=>{let u=[];for(let v=s;v>=0&&(u.unshift(v),!(T[v].parent<0));v=T[v].parent);let w=new Set,g=v=>{for(let x of y.get(v)??[])w.add(x);for(let x of me[v]??[])g(x)};for(let v of u)for(let x of y.get(v)??[])w.add(x);return g(s),{path:T[s].path,levels:u.map(v=>({id:T[v].path.split("/").pop(),path:T[v].path,score:ue(U[v]),terms:(T[v].terms??[]).slice(0,nn)})),score:ue(U[s]),evidence:Math.round(U[s])/1e3,via:[...w].sort(),terms:(T[s].terms??[]).slice(0,tn),files:De(s),standards:mn(s)}}).sort((s,u)=>u.evidence-s.evidence||(s.path<u.path?-1:1)).slice(0,en),ve=[...A.values()].sort((s,u)=>u.score-s.score||(s.name<u.name?-1:1)),Xe=[...new Map(L.map(s=>[`${s.from}>${s.to}`,s])).values()].sort((s,u)=>s.from<u.from?-1:1),V=[];for(let s of ve)for(let u of s.files)V.includes(u)||V.push(u);for(let s of ne)for(let u of s.files)V.includes(u)||V.push(u);let Z=[];for(let s of ne)for(let u of s.standards)Z.some(w=>w.name===u.name)||Z.push(u);let se=[];for(let s of Z.slice(0,fe))for(let u of s.categories)se.includes(u)||se.push(u);return{version:Ie,topics:D,expansions:B,taxonomy:ne,vendors:ve,corrections:Xe,files:V.slice(0,rn),standards:Z.slice(0,fe),categories:se}}}}export{Sn as createRelevanceProvider,ce as createSymbolRanker};
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@vibgrate/relevance",
3
+ "version": "2026.824.3",
4
+ "description": "Vibgrate relevance kernel: query analysis over the compiled relevance pack. Proprietary distribution — the compiled WASM engine plus a minified wrapper; the relevance pack and the reference implementation are not included.",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "node build.mjs",
22
+ "typecheck": "tsc --noEmit -p ./",
23
+ "test": "vitest run"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^26.2.0",
27
+ "esbuild": "^0.25.12",
28
+ "tsup": "^8.0.0",
29
+ "typescript": "^5.4.0",
30
+ "vitest": "^4.1.10"
31
+ },
32
+ "engines": {
33
+ "node": ">=22.0.0"
34
+ }
35
+ }