@vibgrate/relevance 2026.910.3 → 2026.911.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine/relevance.wasm +0 -0
- package/dist/index.d.ts +264 -1
- package/dist/index.js +3 -3
- package/package.json +1 -1
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -176,4 +176,267 @@ interface RelevanceProviderApi {
|
|
|
176
176
|
*/
|
|
177
177
|
declare function createRelevanceProvider(): RelevanceProviderApi;
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
type SurfaceKind = "api" | "model" | "mcp" | "saas";
|
|
180
|
+
type SurfaceCategory = "ai" | "mcp" | "payment" | "auth" | "email" | "cloud" | "databases" | "messaging" | "observability" | "crm" | "storage" | "search" | "other";
|
|
181
|
+
type DetectionSignal = "mcp-config" | "agent-config" | "sdk-import" | "model-literal" | "sdk-package" | "http-host" | "env-key" | "iac-resource";
|
|
182
|
+
type FreshnessStatus = "current" | "behind" | "deprecated" | "retired" | "unknown";
|
|
183
|
+
type CatalogSource = "live" | "cache" | "bundled" | "manifest" | "none";
|
|
184
|
+
/** Fields every observation shares. `line` is 1-based; 0 means "no line". */
|
|
185
|
+
interface ObservationBase {
|
|
186
|
+
/** Repo-relative POSIX path. */
|
|
187
|
+
file?: string;
|
|
188
|
+
line?: number;
|
|
189
|
+
/** Project path within a monorepo. */
|
|
190
|
+
project?: string;
|
|
191
|
+
}
|
|
192
|
+
interface PackageObservation extends ObservationBase {
|
|
193
|
+
/** Ecosystem id: `npm` | `pypi` | `nuget` | `maven` | `go` | `crates` | `rubygems`. */
|
|
194
|
+
eco: string;
|
|
195
|
+
name: string;
|
|
196
|
+
version?: string | null;
|
|
197
|
+
}
|
|
198
|
+
interface HostObservation extends ObservationBase {
|
|
199
|
+
host: string;
|
|
200
|
+
}
|
|
201
|
+
/** An environment variable NAME. Never a value — see the redaction note below. */
|
|
202
|
+
interface EnvKeyObservation extends ObservationBase {
|
|
203
|
+
key: string;
|
|
204
|
+
}
|
|
205
|
+
interface ModelObservation extends ObservationBase {
|
|
206
|
+
id: string;
|
|
207
|
+
/** True when a vendor SDK import sits in the same file — the signal that
|
|
208
|
+
* separates a real inference call from a `model:` key in an ML script. */
|
|
209
|
+
nearSdkImport?: boolean;
|
|
210
|
+
}
|
|
211
|
+
interface ApiVersionObservation extends ObservationBase {
|
|
212
|
+
/** Header or option name, e.g. `Stripe-Version`. */
|
|
213
|
+
field: string;
|
|
214
|
+
value: string;
|
|
215
|
+
/** The host the pin was seen against, when known. */
|
|
216
|
+
host?: string;
|
|
217
|
+
}
|
|
218
|
+
interface McpServerObservation extends ObservationBase {
|
|
219
|
+
name: string;
|
|
220
|
+
transport?: "stdio" | "sse" | "http";
|
|
221
|
+
command?: string;
|
|
222
|
+
args?: string[];
|
|
223
|
+
/** Host only — never a URL carrying query tokens. */
|
|
224
|
+
urlHost?: string;
|
|
225
|
+
tools?: string[];
|
|
226
|
+
}
|
|
227
|
+
interface IacResourceObservation extends ObservationBase {
|
|
228
|
+
resource: string;
|
|
229
|
+
host?: string;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The vendor freshness catalog, as the host resolved it. Supplied per call
|
|
233
|
+
* rather than compiled in: which models a vendor has retired changes weekly,
|
|
234
|
+
* so the kernel keeps the comparison rules and the host brings the facts from
|
|
235
|
+
* whichever of cache / live / manifest / bundled won. Omit it and every
|
|
236
|
+
* freshness verdict is `unknown` with `catalogSource: 'none'` — honest, and
|
|
237
|
+
* never a guess.
|
|
238
|
+
*/
|
|
239
|
+
interface SurfaceCatalogInput {
|
|
240
|
+
/** `YYYY-MM-DD` knowledge date, used for the staleness disclosure. */
|
|
241
|
+
generatedAt?: string;
|
|
242
|
+
source?: CatalogSource;
|
|
243
|
+
models?: Array<{
|
|
244
|
+
providerId: string;
|
|
245
|
+
modelId: string;
|
|
246
|
+
releasedAt?: string;
|
|
247
|
+
deprecated?: boolean;
|
|
248
|
+
retired?: boolean;
|
|
249
|
+
successorId?: string;
|
|
250
|
+
latestForFamily?: boolean;
|
|
251
|
+
}>;
|
|
252
|
+
apis?: Array<{
|
|
253
|
+
providerId: string;
|
|
254
|
+
apiId?: string;
|
|
255
|
+
currentVersion: string;
|
|
256
|
+
deprecatedVersions?: string[];
|
|
257
|
+
}>;
|
|
258
|
+
mcp?: Array<{
|
|
259
|
+
providerId: string;
|
|
260
|
+
package: string;
|
|
261
|
+
latestVersion: string;
|
|
262
|
+
}>;
|
|
263
|
+
}
|
|
264
|
+
interface SurfaceObservations {
|
|
265
|
+
catalog?: SurfaceCatalogInput;
|
|
266
|
+
/** `YYYY-MM-DD`. The kernel has no clock; catalog staleness is measured
|
|
267
|
+
* against this. Omitting it reads as "cannot tell" — the catalog is then
|
|
268
|
+
* reported stale rather than silently assumed fresh. */
|
|
269
|
+
today?: string;
|
|
270
|
+
packages?: PackageObservation[];
|
|
271
|
+
hosts?: HostObservation[];
|
|
272
|
+
envKeys?: EnvKeyObservation[];
|
|
273
|
+
models?: ModelObservation[];
|
|
274
|
+
apiVersions?: ApiVersionObservation[];
|
|
275
|
+
mcpServers?: McpServerObservation[];
|
|
276
|
+
iacResources?: IacResourceObservation[];
|
|
277
|
+
}
|
|
278
|
+
interface SurfaceEvidence {
|
|
279
|
+
signal: DetectionSignal;
|
|
280
|
+
file: string;
|
|
281
|
+
span?: {
|
|
282
|
+
start: number;
|
|
283
|
+
end: number;
|
|
284
|
+
};
|
|
285
|
+
/** ≤80 chars, secret-redacted. Never a key value. */
|
|
286
|
+
snippet?: string;
|
|
287
|
+
confidence: number;
|
|
288
|
+
}
|
|
289
|
+
interface SurfaceProvider {
|
|
290
|
+
id: string;
|
|
291
|
+
displayName: string;
|
|
292
|
+
/** Resolves through the dashboard's ProductIcon / favicon-map. */
|
|
293
|
+
iconId: string;
|
|
294
|
+
category: SurfaceCategory;
|
|
295
|
+
homepage?: string;
|
|
296
|
+
}
|
|
297
|
+
interface SurfaceFreshness {
|
|
298
|
+
status: FreshnessStatus;
|
|
299
|
+
detected: string | null;
|
|
300
|
+
/** The vendor's current id/version — `null` when the catalog does not cover
|
|
301
|
+
* this surface. Never a guess: an uncovered surface is `unknown`. */
|
|
302
|
+
latest: string | null;
|
|
303
|
+
latestAt?: string;
|
|
304
|
+
alternatives: string[];
|
|
305
|
+
catalogSource: CatalogSource;
|
|
306
|
+
catalogGeneratedAt?: string;
|
|
307
|
+
}
|
|
308
|
+
interface ExternalSurface {
|
|
309
|
+
id: string;
|
|
310
|
+
kind: SurfaceKind;
|
|
311
|
+
provider: SurfaceProvider;
|
|
312
|
+
detectedId: string;
|
|
313
|
+
displayName: string;
|
|
314
|
+
version?: string | null;
|
|
315
|
+
freshness: SurfaceFreshness;
|
|
316
|
+
confidence: "high" | "medium" | "low";
|
|
317
|
+
evidence: SurfaceEvidence[];
|
|
318
|
+
callSites: number;
|
|
319
|
+
projects: string[];
|
|
320
|
+
aliases?: string[];
|
|
321
|
+
metadata?: {
|
|
322
|
+
hosts?: string[];
|
|
323
|
+
envKeys?: string[];
|
|
324
|
+
packages?: string[];
|
|
325
|
+
sdkPackage?: string;
|
|
326
|
+
sdkVersion?: string | null;
|
|
327
|
+
mcpCommand?: string;
|
|
328
|
+
mcpArgs?: string[];
|
|
329
|
+
mcpTools?: string[];
|
|
330
|
+
transport?: "stdio" | "sse" | "http";
|
|
331
|
+
mcpUrlHost?: string;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
interface SurfaceInventory {
|
|
335
|
+
schema: "vg-surfaces/1.0";
|
|
336
|
+
catalog: {
|
|
337
|
+
source: CatalogSource;
|
|
338
|
+
generatedAt?: string;
|
|
339
|
+
version?: string;
|
|
340
|
+
stale: boolean;
|
|
341
|
+
};
|
|
342
|
+
counts: {
|
|
343
|
+
providers: number;
|
|
344
|
+
apis: number;
|
|
345
|
+
models: number;
|
|
346
|
+
mcpServers: number;
|
|
347
|
+
saas: number;
|
|
348
|
+
behind: number;
|
|
349
|
+
deprecated: number;
|
|
350
|
+
retired: number;
|
|
351
|
+
unknown: number;
|
|
352
|
+
};
|
|
353
|
+
surfaces: ExternalSurface[];
|
|
354
|
+
/** External hosts the catalog does not name, deduped and capped. Counted,
|
|
355
|
+
* not classified — "we saw traffic shapes we can't attribute" is honest. */
|
|
356
|
+
unknownHosts: string[];
|
|
357
|
+
}
|
|
358
|
+
/** One row of the compatibility `serviceDependencies` map. */
|
|
359
|
+
interface LegacyServiceRow {
|
|
360
|
+
bucket: string;
|
|
361
|
+
name: string;
|
|
362
|
+
package: string;
|
|
363
|
+
version: string | null;
|
|
364
|
+
}
|
|
365
|
+
interface SurfaceClassification {
|
|
366
|
+
inventory: SurfaceInventory;
|
|
367
|
+
/** The legacy service-dependency rows, so the host can keep emitting the
|
|
368
|
+
* pre-existing artifact field without owning a vendor table. */
|
|
369
|
+
serviceDependencies: LegacyServiceRow[];
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* A provider from the compiled brain. Vendor rows are deliberately absent —
|
|
373
|
+
* they belong to whichever catalog the host resolved, not to the brain, and a
|
|
374
|
+
* second copy served from here is exactly the drift the split removed.
|
|
375
|
+
*/
|
|
376
|
+
interface ProviderRecord {
|
|
377
|
+
provider: SurfaceProvider & {
|
|
378
|
+
apiVersionField: string | null;
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
/** Provenance of the compiled provider brain (not the vendor catalog). */
|
|
382
|
+
interface SurfaceCatalogInfo {
|
|
383
|
+
version: string;
|
|
384
|
+
providers: number;
|
|
385
|
+
packages: number;
|
|
386
|
+
}
|
|
387
|
+
interface SurfaceCatalogApi {
|
|
388
|
+
/** Classify a batch of observations into the inventory. Pass the resolved
|
|
389
|
+
* vendor catalog in `observations.catalog` to get freshness verdicts. */
|
|
390
|
+
classify(observations: SurfaceObservations): SurfaceClassification;
|
|
391
|
+
/** Free-text provider lookup, exact then prefix then substring. */
|
|
392
|
+
search(query: string): Array<SurfaceProvider & {
|
|
393
|
+
apiVersionField: string | null;
|
|
394
|
+
}>;
|
|
395
|
+
/** One provider and the vendor rows governing it; `null` when unknown. */
|
|
396
|
+
get(providerId: string): ProviderRecord | null;
|
|
397
|
+
/** Catalog provenance, for the freshness/honesty line. */
|
|
398
|
+
info(): SurfaceCatalogInfo;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Bind the surface catalog, or `null` when the engine is missing or predates
|
|
402
|
+
* it. `null` is a normal outcome the caller degrades through — never a throw:
|
|
403
|
+
* an inventory nobody can classify is better reported absent than guessed.
|
|
404
|
+
*/
|
|
405
|
+
declare function createSurfaceCatalog(): SurfaceCatalogApi | null;
|
|
406
|
+
|
|
407
|
+
/** Per-1M-token list prices. `null` where the vendor publishes no such rate. */
|
|
408
|
+
interface ModelPrice {
|
|
409
|
+
input: number;
|
|
410
|
+
output: number;
|
|
411
|
+
/** `null` means "not published", which is not the same as "free". */
|
|
412
|
+
cacheRead: number | null;
|
|
413
|
+
cacheWrite: number | null;
|
|
414
|
+
}
|
|
415
|
+
interface ModelRecord {
|
|
416
|
+
id: string;
|
|
417
|
+
family: string;
|
|
418
|
+
contextLimit: number;
|
|
419
|
+
/** `null` when the vendor documents no separate output cap. */
|
|
420
|
+
maxOutput: number | null;
|
|
421
|
+
billsThinking: boolean;
|
|
422
|
+
supportsCacheControl: boolean;
|
|
423
|
+
aliases: string[];
|
|
424
|
+
price: ModelPrice | null;
|
|
425
|
+
}
|
|
426
|
+
interface ModelTable {
|
|
427
|
+
schema: string;
|
|
428
|
+
/** Version stamp of the compiled catalog — the host's freshness signal. */
|
|
429
|
+
version: string;
|
|
430
|
+
models: ModelRecord[];
|
|
431
|
+
}
|
|
432
|
+
interface ModelCatalogApi {
|
|
433
|
+
/** The whole table, in one call. */
|
|
434
|
+
table(): ModelTable;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Bind the model catalog, or `null` when the engine is missing or predates it.
|
|
438
|
+
* `null` is a normal outcome the caller degrades through — never a throw.
|
|
439
|
+
*/
|
|
440
|
+
declare function createModelCatalog(): ModelCatalogApi | null;
|
|
441
|
+
|
|
442
|
+
export { type ApiVersionObservation, type CatalogSource, type DetectionSignal, type EnvKeyObservation, type ExternalSurface, type FreshnessStatus, type HostObservation, type IacResourceObservation, type LegacyServiceRow, type McpServerObservation, type ModelCatalogApi, type ModelObservation, type ModelPrice, type ModelRecord, type ModelTable, type PackageObservation, type ProviderRecord, type RankOptions, type RankResult, type RankableSymbol, type RankedSeed, type RelevanceAnalysis, type RelevanceExpansion, type RelevanceProviderApi, type RelevanceTopic, type SurfaceCatalogApi, type SurfaceCatalogInfo, type SurfaceCatalogInput, type SurfaceCategory, type SurfaceClassification, type SurfaceEvidence, type SurfaceFreshness, type SurfaceInventory, type SurfaceKind, type SurfaceObservations, type SurfaceProvider, type SymbolRanker, createModelCatalog, createRelevanceProvider, createSurfaceCatalog, createSymbolRanker };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var oe={};import*as J from"node:fs";import{fileURLToPath as et}from"node:url";var q;function ke(){if(q!==void 0)return q;q=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(r=>et(r)).find(r=>J.existsSync(r));if(!t)return q;let n=new WebAssembly.Module(J.readFileSync(t)),o=new WebAssembly.Instance(n,{}).exports,l=r=>{let d=new TextEncoder().encode(r),p=o.vg_alloc(d.length);return new Uint8Array(o.memory.buffer,p,d.length).set(d),{ptr:p,len:d.length}},a=r=>{let p=new DataView(o.memory.buffer,r,4).getUint32(0,!0),f=new TextDecoder().decode(new Uint8Array(o.memory.buffer,r+4,p));return o.vg_free(r,4+p),f};return q={version:()=>a(o.vg_version()),analyzeQueryJson:r=>{let{ptr:d,len:p}=l(r),f=a(o.vg_analyze(d,p));return o.vg_free(d,p),f},tagNodeJson:(r,d)=>{let p=l(r),f=l(d),h=a(o.vg_tag(p.ptr,p.len,f.ptr,f.len));return o.vg_free(p.ptr,p.len),o.vg_free(f.ptr,f.len),h}},q}catch{return q=null,q}}var j=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","handle","handles","handled","handling","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"]),Y={payment:["debit","mandate","stripe","invoice","billing","charge","card","checkout","refund","subscription"],pay:["stripe","invoice","payment","billing","charge"],paying:["invoice","billing","payment"],receipt:["invoice","billing","payment"],billing:["stripe","invoice","payment","charge","subscription"],billed:["invoice","billing","charge"],checkout:["stripe","payment","session"],debit:["mandate","payment","bacs","bank","sepa"],mandate:["debit","bacs","sepa"],sepa:["debit","mandate","bank"],bacs:["debit","mandate","bank"],stripe:["billing","webhook","payment","card","charge","checkout"],refund:["invoice","stripe","payment","charge"],invoice:["billing","payment","refund","subscription"],subscription:["invoice","billing"],recurring:["debit","mandate"],renewal:["billing","renew","subscription"],card:["stripe","payment","charge"],credit:["payment","card","charge"],bank:["debit","mandate","account","sepa"],charge:["stripe","payment","card"],customer:["billing","account"],auth:["login","oauth","password","session","token"],authentication:["auth","login","password","session","token"],authorization:["auth","oauth","permission"],authorisation:["auth","oauth","permission"],login:["auth","oauth","password","session"],signup:["account","register"],password:["auth","login"],session:["auth","login","token"],token:["auth","session"],oauth:["auth","login","callback"],google:["auth","login","oauth"],inference:["llm","completion","prompt","serving"],dependency:["advisory","vulnerability","audit","package"],package:["advisory","vulnerability","audit","dependency"],vulnerability:["advisory","audit","osv","vulnerable"],vulnerable:["advisory","vulnerability","audit"],advisory:["vulnerability","audit","osv"],cve:["advisory","vulnerability","osv"],risk:["advisory","vulnerability","audit"],security:["advisory","vulnerability","audit"],audit:["advisory","vulnerability","dependency"],scan:["scanner","vulnerability","audit"],retry:["backoff","throttle"],retries:["backoff","throttle"],email:["sender","template","message"],mail:["email","sender"],notification:["email","sms"],notify:["notification","email"],sms:["notification","message"],cart:["shop","order","discount"],order:["shop","fulfillment","cart","shipment"],shipping:["order","fulfillment","shipment"],shipped:["order","fulfillment","shipment"],inventory:["product","catalog","restock"],product:["shop","catalog","inventory"],discount:["cart"],chat:["room","presence","message"],message:["chat"],conversation:["chat","message"],online:["presence"],typing:["presence","broadcast","indicator"],video:["media","playback","thumbnail","transcode","stream"],stream:["playback","media","manifest"],streaming:["media","video","playback","manifest"],playback:["media","video","stream","watch"],transcode:["video","media"],thumbnail:["video","media"],media:["video","playback","stream"],analytics:["event","funnel","report","track"],event:["analytics","track"],track:["analytics","event"],funnel:["analytics","event","conversion"],conversion:["analytics","funnel"],report:["analytics","export","metrics"],article:["cms","publish"],publish:["article"],content:["article","cms","markdown"],markdown:["article","render"],deploy:["deployment","pipeline","release","rollback"],deployment:["pipeline","deploy","release","rollback"],release:["deploy","rollback"],rollback:["deployment","deploy","release"],pipeline:["ci","runner","stage","deploy"],canary:["deploy","release"],push:["mobile","device","token"],device:["mobile","push","register","token"],mobile:["push","device"],ios:["link","mobile","universal"],android:["push","mobile","device"],batch:["settlement","reconcile"],settlement:["batch","ledger","reconcile"],reconcile:["settlement","batch","ledger"],ledger:["settlement","reconcile"],mainframe:["settlement","batch","ebcdic","fixed"],ebcdic:["convert","record"],nightly:["batch"],geocode:["geo","address"],address:["geocode"],route:["geo","planner","distance"],distance:["route","geo"],arrival:["route","estimate"],translation:["locale"],translate:["locale","translation"],locale:["translation","format"],i18n:["locale","translation"],localized:["locale","translation","format"],metric:["export","counter","prometheus"],prometheus:["exporter","metric"],trace:["observability","span"],span:["trace"],counter:["increment","metric"],flag:["feature","experiment","rollout"],rollout:["flag","experiment","percentage"],experiment:["flag","assign","exposure","variant"],variant:["experiment","assign"],toggle:["flag","experiment","variant"],cache:["ttl","redis","memoize","eviction"],ttl:["cache","redis","eviction"],memoize:["cache","ttl"],database:["schema","migration","query","orm"],db:["database","schema","migration"],migration:["database","schema"],orm:["database","query","schema"],sql:["database","query","schema"],transaction:["database","schema"],queue:["broker","consumer","subscribe","topic"],broker:["queue","consumer","subscribe"],subscribe:["queue","broker","consumer"],consumer:["queue","broker","subscribe"],log:["logging"],logging:["log"],logger:["log","logging"],webhook:["callback","signature","idempotency"],callback:["webhook","signature"],idempotency:["webhook","callback"],throttle:["backoff","quota"],backoff:["throttle","quota"],quota:["throttle","backoff"],api:["endpoint","middleware"],endpoint:["api","middleware"],middleware:["api","endpoint"],graphql:["resolver","mutation"],resolver:["mutation"],component:["render","router"],render:["component","router"],router:["component","render"],css:["stylesheet","theme"],stylesheet:["css","theme"],theme:["css","stylesheet"],facet:["index","ranking"],ranking:["facet","index"],a11y:["aria","focus","contrast"],aria:["a11y","focus","contrast"],mock:["fixture","snapshot"],fixture:["mock","snapshot"],snapshot:["mock","fixture"],coverage:["mock","fixture"],consent:["retention","policy"],retention:["consent","policy"],csrf:["xss","sanitize"],xss:["csrf","sanitize"],logout:["session","auth"],mfa:["auth","login","sso"],sso:["auth","oauth"],jwt:["token","auth","session"],oidc:["oauth","auth","login"],cors:["origin","header"],smtp:["email","sender"],lockfile:["dependency"],language:["locale","translation","i18n"],l10n:["locale","i18n","translation"],localization:["locale","i18n","translation"],permission:["role","access"],role:["permission","access"]},Se={"direct debit":["debit","mandate","bacs","bank","sepa"],"direct debits":["debit","mandate","bacs","bank","sepa"],"sign in":["auth","login","session"],"signs in":["auth","login","session"],"log in":["login","auth","session"],"logs in":["auth","login","session"],"logged in":["login","auth","session"],"sign up":["account","register"],"signs up":["account","register"],"signing up":["account","register"],"signed up":["account","register"],"credit card":["stripe","payment","card","charge"],"credit cards":["stripe","payment","card","charge"],"two factor":["auth"],"payment method":["debit","stripe","payment","card"],"payment methods":["debit","stripe","payment","card"],"inference payment":["credit","usage"],"inference payments":["credit","usage"],"inference cost":["credit","usage"],"inference costs":["credit","usage"],"inference billing":["credit","usage"],"push notification":["push","device","token"],"push notifications":["push","device","token"],"deep link":["link"],"deep links":["link"],"universal link":["link","universal"],"universal links":["link","universal"],"feature flag":["experiment","flag","rollout"],"feature flags":["experiment","flag","rollout"],"shopping cart":["cart","order"],"roll back":["deployment","deploy","release"],"sign out":["session","auth"],"fixed width":["batch","export","record"],"canary rollout":["deployment","pipeline","deploy","release"],"canary rollouts":["deployment","pipeline","deploy","release"],"blog post":["article","cms","markdown","publish"],"blog posts":["article","cms","markdown","publish"],"signed out":["session","auth"],"rate limit":["throttle","backoff","quota"],"rate limits":["throttle","backoff","quota"],"screen reader":["a11y","aria","focus"],"dark mode":["theme","css"],"access token":["auth","session"],"refresh token":["token","session","auth"],"password reset":["password","token","auth"],"health check":["healthcheck","probe","live"],"circuit breaker":["circuit","breaker","fallback"],"api route":["router","endpoint"],"api routes":["router","endpoint"],"url route":["router","endpoint"],"url routes":["router","endpoint"],"route distance":["geo","planner","distance"],"queue message":["queue","broker","consumer"],"dead letter":["queue","broker","consumer"],"scan directory":["walk","glob"],"scan files":["walk","glob"],"search index":["facet","ranking"],"keyboard focus":["a11y","aria","focus"],"transaction rollback":["transaction","database","commit"],"rollback transaction":["transaction","database","commit"]},tt={"canary rollout":["rollout"],"canary rollouts":["rollouts"],"blog post":["post","blog"],"blog posts":["posts","blog"],"push notification":["notification"],"push notifications":["notification","notifications"],"inference payment":["payment"],"inference payments":["payment","payments"],"inference cost":["cost"],"inference costs":["cost","costs"],"inference billing":["billing"],"api route":["route"],"api routes":["route","routes"],"url route":["route"],"url routes":["route","routes"],"route distance":["route"],"queue message":["message"],"dead letter":["letter"],"scan directory":["scan"],"scan files":["scan"],"search index":["index"],"transaction rollback":["rollback"],"rollback transaction":["rollback"]},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 ie(e){let t=new Set;for(let n=0;n+1<e.length;n++){let i=`${e[n]} ${e[n+1]}`;nt.has(i)&&t.add(e[n]),st.has(i)&&t.add(e[n+1])}return t}function Re(){return Object.keys(Y)}function _e(e){if(!e)return null;if(Object.hasOwn(Y,e))return e;if(e.endsWith("ies")){let t=e.slice(0,-3)+"y";if(Object.hasOwn(Y,t))return t}if(e.endsWith("s")){let t=e.slice(0,-1);if(Object.hasOwn(Y,t))return t}return null}function U(e){let t=new Set(e),n=ie(e),i=[],o=new Set,l=(r,d)=>{t.has(r)||o.has(r)||(o.add(r),i.push({term:r,from:d}))};for(let r=0;r+1<e.length;r++){let d=`${e[r]} ${e[r+1]}`,p=Se[d];if(p)for(let f of p)l(f,d)}let a=G(e);for(let r of e){if(n.has(r)||a.has(r))continue;let d=_e(r);if(d)for(let p of Y[d])l(p,r)}return i}function G(e){let t=new Set;for(let n=0;n+1<e.length;n++){let i=`${e[n]} ${e[n+1]}`;if(Se[i]){for(let o of[e[n],e[n+1]])_e(o)||t.add(o);for(let o of tt[i]??[])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","files","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 a=o.slice(0,o.lastIndexOf("/")+1),r=n.get(a)??[];r.push(l),n.set(a,r)}let i=new Map;for(let[o,l]of n)l.sort((a,r)=>r-a),i.set(o,l.slice(0,3).reduce((a,r)=>a+r,0));return i}var ft=4,dt=64,mt=.35,gt=/(^|\/)(tests?|testing|__tests__)(\/|$)|(^|\/)(test_[^/]*|conftest\.py)$|[._-](test|tests|spec)\.[a-z0-9]+$/i;function pt(e){return gt.test(e)}var ht=/(^|\.)tests?(\.|$)|(^|\.)(?:test_[^.]*|Test[A-Z][^.]*|Benchmark[A-Z][^.]*|Fuzz[A-Z][^.]*)$/;function bt(e){return ht.test(e)}var yt=/\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 vt(e,t){return yt.test(e)?!0:t.some(n=>/^test_|_tests?$|^conftest$/.test(n.term))}function B(e){return[...new Set(e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=1&&!Te.has(t)))]}function X(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=1)}function wt(e){let t=e.trim();return t=t.replace(/[.,;:!)\]}>]+$/g,""),t.endsWith("?")&&t.lastIndexOf("?")===t.length-1&&(t=t.slice(0,-1)),t}function te(e){let t=[],n=new Set,i=(o,l)=>{let a=o.trim();a=l==="url"?wt(a):a.replace(/[.,;:!)\]}>?]+$/g,""),!(a.length<2||n.has(a))&&(n.add(a),t.push(a))};for(let o of e.matchAll(/https?:\/\/[^\s"'`<>]+/gi))i(o[0],"url");for(let o of e.matchAll(/(["'`])((?:(?!\1)[^\\]|\\.){2,})\1/g))i(o[2].replace(/\\(.)/g,"$1"),"quote");return t}function ae(e){let t=e;for(let n of e.matchAll(/https?:\/\/[^\s"'`<>]+/gi))t=t.split(n[0]).join(" ");for(let n of te(e))t=t.split(n).join(" ");return t=t.replace(/(["'`])\s*\1/g," "),t.replace(/\s+/g," ").trim()}function kt(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 St(e,t){if(!t.length||kt(e))return null;let n=t.filter(i=>!/^https?:\/\//i.test(i)&&!i.includes("/"));return n.length?n.join(" "):null}function ee(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 ce(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 Rt(e,t){for(let n of t){let i=Ne(e,n);if(i>=5&&i>=.6*Math.min(e.length,n.length))return!0}return!1}function Ne(e,t){let n=Math.min(e.length,t.length),i=0;for(;i<n&&e[i]===t[i];)i++;return i}var _t=16,Et=36,xt=.75,Mt=.55;function At(e){let t=new Map;for(let n of e){if(Te.has(n)||t.has(n))continue;let i=t.size;t.set(n,i<_t?1:i<Et?xt:Mt)}return t}function Tt(e,t,n,i){let o=B(e),l=X(e),a=new Set(o),r=G(l),d=ie(l),p=At(l),f=o.map(c=>({term:c,weak:j.has(c)||r.has(c)||d.has(c),positional:p.get(c)??1})),h=new Set(o);for(let c of U(l))a.has(c.term)||(f.push({term:c.term,weak:!1,from:c.from,positional:p.get(c.from)??1}),h.add(c.term));if(i){let c=X(i),b=G(c);for(let g of B(i))h.has(g)||j.has(g)||b.has(g)||(f.push({term:g,weak:!1,from:"quote",quoted:!0}),h.add(g));for(let g of U(c))h.has(g.term)||(f.push({term:g.term,weak:!1,from:g.from}),h.add(g.term))}for(let c of t?.expansions??[]){let b=String(c?.term??"").toLowerCase().trim(),g=String(c?.from??"").toLowerCase().trim(),w=Number(c?.weight);!b||!g||b.includes(" ")||h.has(b)||j.has(g)||j.has(b)||!Number.isFinite(w)||w<at||(f.push({term:b,weak:!1,from:g,packWeight:Math.min(1,w)}),h.add(b))}if(n?.trim()){let c=X(n),b=G(c);for(let g of B(n))h.has(g)||j.has(g)||b.has(g)||(f.push({term:g,weak:!1,carried:!0}),h.add(g));for(let g of U(c))h.has(g.term)||(f.push({term:g.term,weak:!1,from:g.from,carried:!0}),h.add(g.term))}let v=f.some(c=>!c.weak);return{terms:f,hasContent:v}}function Oe(e){let t=e?.trim();return t?te(t).length>0?ae(t):t:null}function Nt(e,t){let n=t.terms.filter(a=>!a.weak&&!a.from&&!a.carried&&a.term.length>=4);if(!n.length)return;let i=new Map,o=new Set;for(let a of e){let r=a.name.toLowerCase(),d=a.file.toLowerCase(),p=ee(a.name);for(let f of p)o.add(f);for(let f of n){let h=ce(f.term);(p.has(f.term)||h!==null&&p.has(h)||r.includes(f.term)||d.includes(f.term))&&i.set(f.term,(i.get(f.term)??0)+1)}}let l=new Set(t.terms.map(a=>a.term));for(let a of n){if((i.get(a.term)??0)>0||U([a.term]).length>0)continue;let r=a.term.length>=8?2:1,d=null,p=(h,v)=>{if(h.length<4||h===a.term||v!==0&&a.term.length<6||Math.abs(h.length-a.term.length)>r||h[0]!==a.term[0])return;let c=Ot(a.term,h,r);if(c>r)return;let b=Ne(a.term,h);(!d||c<d.dist||c===d.dist&&(b>d.prefix||b===d.prefix&&(v<d.lex||v===d.lex&&h<d.cand)))&&(d={cand:h,dist:c,prefix:b,lex:v})};for(let h of Re())p(h,0);for(let h of o)p(h,1);if(!d)continue;let{cand:f}=d;l.has(f)||(t.terms.push({term:f,weak:!1,from:a.term}),l.add(f))}}function Ot(e,t,n){let i=e.length,o=t.length;if(Math.abs(i-o)>n)return n+1;let l=null,a=Array.from({length:o+1},(r,d)=>d);for(let r=1;r<=i;r++){let d=new Array(o+1);d[0]=r;let p=d[0];for(let f=1;f<=o;f++){let h=e[r-1]===t[f-1]?0:1,v=Math.min(a[f]+1,d[f-1]+1,a[f-1]+h);l&&r>1&&f>1&&e[r-1]===t[f-2]&&e[r-2]===t[f-1]&&(v=Math.min(v,l[f-2]+1)),d[f]=v,v<p&&(p=v)}if(p>n)return n+1;l=a,a=d}return a[o]}function It(e,t){if(t.length===0)return()=>1;let n=new Map,i=0;for(let l of e){i++;let a=l.name.toLowerCase(),r=ee(l.name);for(let d of t){let p=ce(d);(r.has(d)||p!==null&&r.has(p)||a.includes(d))&&n.set(d,(n.get(d)??0)+1)}}let o=new Map;for(let l of t){let a=Math.log((i+1)/((n.get(l)??0)+1))+1;o.set(l,Math.max(.5,Math.min(8,a)))}return l=>o.get(l)??1}function $t(e,t,n){let i=0,o=0,l=!1,a=!1,r=[],d=e.name.toLowerCase(),p=e.qualifiedName.toLowerCase(),f=e.file.toLowerCase(),h=f.split("/"),v=new Set(h.slice(0,-1)),c=h[h.length-1].replace(/\.[a-z0-9]+$/,""),b=ee(c),g=ee(e.name);for(let{term:w,weak:N,from:$,packWeight:S,carried:A,quoted:_,positional:C}of t){let W=S!==void 0?Math.min(S,Ee):$&&!_?Ee:1,O=n(w)*(N?rt:1)*W*(A?it:1)*(C??1),P=(A?"\u21A9":"")+($?`${$}\u2192${w}`:w),D=w.length>=4,z=ce(w),I=0,F=!1,K=!1;d===w?(I=10*O,K=!0,r.push(P)):g.has(w)||z!==null&&g.has(z)?(I=6*O,K=!0,r.push(P)):c===w||z!==null&&c===z?(I=(O>=3?8:5)*O,K=!0,r.push(P)):D&&d.includes(w)?(I=4*O,r.push(P)):D&&p.includes(w)||b.has(w)||z!==null&&b.has(z)?(I=3*O,r.push(P)):D&&w.length>=5&&c.includes(w)?(I=2.5*O,r.push(P)):S===void 0&&Rt(w,g)?(I=2*O,r.push((A?"\u21A9":"")+($?`~${$}\u2192${w}`:`~${w}`)),F=!0):v.has(w)?(I=2*O,r.push(P)):D&&f.includes(w)&&(I=1*O,r.push(P)),I>0&&(i+=I,N||(o+=1,F||(l=!0),K&&(a=!0)))}return o===0?{score:0,why:"",strong:!1,direct:!1}:(i*=1+ot*Math.min(o-1,4),{score:i,why:r.length?`matched: ${r.join(", ")}`:"",strong:l,direct:a})}function Ct(e,t){let n=e.split("/"),i=t.split("/"),o=0;for(;o<n.length&&o<i.length&&n[o]===i[o];)o++;return o}function Lt(e,t,n){if(!n)return{boost:1,label:""};let i=n[e];if(!i?.length)return{boost:1,label:""};let o=t?.taxonomy??[];if(o.length&&i.some(r=>r.includes("/"))){let r=0,d="";for(let p of o){let f=p.path.split("/").length;for(let h of i){let v=Ct(p.path,h);if(v===0)continue;let c=v/f*p.score;c>r&&(r=c,d=v===f?p.path:p.path.split("/").slice(0,v).join("/"))}}return r<=0?{boost:1,label:""}:{boost:1+xe*Math.min(r,1),label:`, topic:${d}`}}if(!t?.topics?.length)return{boost:1,label:""};let l=0,a=[];for(let r of t.topics)i.includes(r.id)&&(l+=r.score,a.push(r.id));return l<=0?{boost:1,label:""}:{boost:1+xe*Math.min(l,1),label:`, topic:${a.sort().join("+")}`}}function Me(e){return e.toLowerCase().replace(/\d+/g,"")}var Pt=2;function zt(e){return(e.name||e.qualifiedName).toLowerCase()}function Dt(e){let t=e[0]?.score??0;return t<=0?e:e.filter(n=>n.strong||n.score>=t/3)}function Wt(e){let t=new Set,n=[],i=[];for(let c of e)t.has(c.sym.file)?i.push(c):(t.add(c.sym.file),n.push(c));let o=n.concat(i),l=new Map,a=[],r=[];for(let c of o){let b=zt(c.sym),g=l.get(b)??0;l.set(b,g+1),(g<Pt?a:r).push(c)}let d=a.concat(r),p=new Set;for(let c of e)c.strong&&p.add(Me(c.sym.file));if(p.size<2)return d;let f=new Map,h=[],v=[];for(let c of d){let b=Me(c.sym.file),g=f.get(b)??0;g<ft?(f.set(b,g+1),h.push(c)):v.push(c)}return h.concat(v)}function Ft(e,t,n){let i=c=>[...new Set(c)].slice(0,8).join(", "),l=te(e).length>0?ae(e):e,a=[],r=new Map;for(let c of U(X(l))){let b=r.get(c.from)??[];b.push(c.term),r.set(c.from,b)}for(let[c,b]of r)a.push(`- "${c}" in the ask implies these codebase identifiers: ${i(b)}.`);let d=t?.taxonomy??[];if(d.length){let c=new Set,b=[];for(let S of d)for(let A of S.levels)c.has(A.path)||(c.add(A.path),b.push({path:A.path,id:A.id,depth:A.path.split("/").length,terms:A.terms}));let g=Math.max(...b.map(S=>S.depth)),w=(S,A)=>S.terms.length?`${A} ${S.id}; code for it typically uses: ${i(S.terms)}.`:`${A} ${S.id}.`;for(let S of b.filter(A=>A.depth===g))a.push(w(S,"- The ask is specifically about"));let N=new Set(b.filter(S=>S.depth===g).map(S=>S.id));for(let S of(t?.vendors??[]).filter(A=>A.score>0).slice(0,3)){if(N.has(S.name)){S.from!==S.name&&a.push(`- That product was typed "${S.from}".`);continue}a.push(S.from===S.name?`- It names the product "${S.name}".`:`- It names the product "${S.name}" (typed "${S.from}").`)}let $=new Set((t?.vendors??[]).map(S=>S.name));for(let S=g-1;S>=1;S--)for(let A of b.filter(_=>_.depth===S&&!$.has(_.id)))a.push(w(A,"- More broadly, this is"))}else if(t?.topics?.length){let c=new Map;for(let b of t.expansions??[]){let g=c.get(b.from)??[];g.push(b.term),c.set(b.from,g)}for(let b of t.topics.slice(0,3)){let g=c.get(b.id);a.push(g?.length?`- The ask is about the "${b.id}" domain; code for it typically uses: ${i(g)}.`:`- The ask is about the "${b.id}" domain.`)}}let p=t?.standards??[];if(p.length){let c=p.filter(w=>w.kind!=="regulation"),b=p.filter(w=>w.kind==="regulation"),g=w=>w.slice(0,3).map(N=>N.publisher?`${N.name} (${N.publisher})`:N.name).join("; ");c.length&&a.push(`- Standards that govern this area: ${g(c)}.`),b.length&&a.push(`- Regulations that apply here: ${g(b)}.`)}let f=t?.categories??[];f.length&&a.push(`- Related categories: ${i(f)}.`);let h=t?.files??[];h.length&&a.push(`- Files for this kind of work are usually named or extended: ${i(h)}.`);for(let c of(t?.corrections??[]).slice(0,3))a.push(`- Read "${c.from}" in the ask as "${c.to}".`);let v=Oe(n);if(v){let c=new Set(B(l)),b=G(X(v)),g=B(v).filter(w=>!c.has(w)&&!j.has(w)&&!b.has(w));g.length&&a.push(`- This is a follow-up; topic words carried from the previous ask: ${i(g)}.`)}return a.length&&a.push('- Seed notation below: `a\u2192b` = ask term "a" implied identifier "b"; `~t` = word-form match; `\u21A9t` = carried from the previous ask.'),a}var qt=/^\s*at\s+\S.*\((?:node:|internal\/|[^()]*[/\\]node_modules[/\\]|[^()]*[/\\]\.pnpm[/\\])[^()]*\)\s*$/i,Ht=/^\s*at\s+(?:node:|internal\/|\/?(?:[^\s()]*[/\\])?node_modules[/\\])\S*\s*$/i;function Kt(e){if(!e.includes(" at ")&&!/^\s*at\s/m.test(e))return e;let n=e.split(`
|
|
2
|
-
`).filter(i=>!
|
|
3
|
-
`).trim();return n.length>0?n:e}function Ae(e){return Math.round(e*1e6)/1e6}function le(e,t){return{rankSymbols(n,i,o={}){let l=Math.max(1,Math.min(o.limit??16,dt)),a=Kt(n),r=null;try{r=e(a)}catch{r=null}let d=te(a),p=d.length>0?ae(a):a,f=Oe(o.priorQuestion),h=Tt(p,r,f,St(n,d));Nt(i,h);let v=Ft(n,r,o.priorQuestion??null);if(!h.hasContent)return{version:t(),hasContent:!1,seeds:[],conceptMap:v};let c=It(i,h.terms.map(_=>_.term)),b=!vt(a,h.terms),g=[];for(let _ of i){let{score:C,why:W,strong:O,direct:P}=$t(_,h.terms,c);if(C>0){let D=Lt(_.id,r,o.topicTags),z=pt(_.file)||bt(_.qualifiedName),I=b&&z?mt:1;g.push({sym:_,score:Ae(C*I*D.boost*(1+ct*_.importance)),why:W+D.label,strong:O,direct:P})}}let w=ut(g),N=0;for(let _ of w.values())_>N&&(N=_);if(N>0)for(let _ of g){let C=_.sym.file.slice(0,_.sym.file.lastIndexOf("/")+1),W=(w.get(C)??0)/N;_.score=Ae(_.score*(1+lt*W))}g.sort((_,C)=>C.score-_.score||(_.sym.qualifiedName<C.sym.qualifiedName?-1:1));let $=Wt(Dt(g)).slice(0,l);if(!$.some(_=>_.direct))return{version:t(),hasContent:!1,seeds:[],conceptMap:v};let A=$.map(_=>({id:_.sym.id,score:_.score,why:_.why}));return{version:t(),hasContent:!0,seeds:A,conceptMap:v}}}}var jt=!1,Ie=`vg-relevance@1.5.0+pack.${oe.version}`,Ut=20,Gt=8,Vt=4,Yt=.34,Bt=.8,Xt=.6,Zt=.5,Qt=.45,He=new Set(["the","and","for","with","first","new","web","app","development"]),Jt=2e3,en=1200,Ke=550,ue=2e3,tn=1200,nn=800,sn=1e3,rn=600,$e=1e3,Ce=3e3,on=1e3,fe=e=>Math.round(Math.min(e,Ce)/Ce*1e3)/1e3,je=6,an=6,cn=6,ln=10,un=6,fn=6,dn=8,de=4,R=oe;for(let e of[R.acronyms,R.vendors,R.synonyms,R.topics,R.taxonomyTerms,R.vendorNode,R.fileHints,R.standards])e&&typeof e=="object"&&Object.setPrototypeOf(e,null);function mn(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=2)}function gn(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=1)}var pn=new Set(["the","an","our","your","their","its","this","that","these","those","each","every","another","any"]);function Z(e){return e.split(" ").filter(t=>t.length>=3&&!He.has(t))}var hn=40,Le=128,Ue=Uint8Array.from(Buffer.from(R.vectors?.data??"","base64")),me=new Map((R.vectors?.terms??[]).map((e,t)=>[e,t])),bn=new Set(R.vectors?.skip??[]);function yn(e){let t=me.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=me.get(n),t!==void 0)return{row:t,term:n}}return null}function vn(e,t){let n=Ue[e*(R.vectors?.dim??0)+t]??0;return n>127?n-256:n}var T=R.taxonomy??[],H=R.taxonomyTerms??{},Pe=R.vendorNode??{},ge=R.fuzzyKeys??[],wn=R.fileHints??{},kn=R.standards??{};function Sn(e){let t=[];for(let n=e;n>=0;n=T[n].parent){let i=T[n].path;for(let o of kn[i]??[])t.some(l=>l.name===o.name)||t.push({name:o.name,publisher:o.publisher,node:i,kind:o.kind??"standard",categories:o.categories??[]});if(T[n].parent<0)break}return t.slice(0,de)}function ze(e){let t=[];for(let n=e;n>=0;n=T[n].parent){for(let i of wn[T[n].path]??[])t.includes(i)||t.push(i);if(T[n].parent<0)break}return t.slice(0,fn)}var Rn=ge.map(e=>({mask:Ge(e.key),grams:Ve(e.key),len:e.key.length})),pe=new Set(R.weakTerms??[]),ne=new Set(R.englishGuard??[]),De=e=>e.includes(" ")?Jt:pe.has(e)?Ke:en,he=T.map(()=>[]);for(let[e,t]of T.entries())t.parent>=0&&he[t.parent].push(e);var We=new Map(T.map((e,t)=>[e.path,t]));function Ge(e){let t=0;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n)-97;t|=i>=0&&i<26?1<<i:1<<26}return t}function _n(e){let t=0;for(let n=e;n;n&=n-1)t++;return t}function Ve(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 En(e,t){let n=0,i=0,o=0;for(;n<e.length&&i<t.length;)e[n]===t[i]?(o++,n++,i++):e[n]<t[i]?n++:i++;return o}function xn(e,t,n){let i=e.length,o=t.length;if(Math.abs(i-o)>n)return n+1;let l=[],a=new Array(o+1);for(let r=0;r<=o;r++)a[r]=r;for(let r=1;r<=i;r++){let d=new Array(o+1);d[0]=r;let p=d[0];for(let f=1;f<=o;f++){let h=e[r-1]===t[f-1]?0:1,v=Math.min(d[f-1]+1,a[f]+1,a[f-1]+h);r>1&&f>1&&e[r-1]===t[f-2]&&e[r-2]===t[f-1]&&(v=Math.min(v,l[f-2]+1)),d[f]=v,v<p&&(p=v)}if(p>n)return n+1;l=a,a=d}return a[o]}var Fe=new Set(["s","es","ed","d","ing","ly","er","ers","ings"]);function Mn(e){return e<je?0:e>=9?2:1}function An(e,t=2){let n=Math.min(Mn(e.length),t);if(n===0||me.has(e)||ne.has(e))return null;let i=Ve(e),o=e.length>=6?2:1,l=null,a=n+1,r=!1,d=Ge(e);for(let f=0;f<ge.length;f++){let h=Rn[f];if(Math.abs(h.len-e.length)>n||_n(d^h.mask)>n*2)continue;let v=ge[f];if(En(i,h.grams)<o)continue;let c=xn(e,v.key,n);c>n||(c<a?(a=c,l=v,r=!1):c===a&&l&&v.ref!==l.ref&&(r=!0))}if(!l||r||a>=2&&e[0]!==l.key[0])return null;let p=e.startsWith(l.key)?e.slice(l.key.length):"";if(p&&/^(id|ids|[0-9]+)$/.test(p))return null;if(e.startsWith(l.key)){let f=e.slice(l.key.length);if(Fe.has(f))return null}return l.key.startsWith(e)&&Fe.has(l.key.slice(e.length))?null:{key:l,distance:a}}var be=new Map;for(let e of T){if(!e.topic)continue;let t=be.get(e.topic);(!t||e.path.split("/").length<t.split("/").length)&&be.set(e.topic,e.path)}var Ye=new Map;for(let[e,t]of Object.entries(R.topicPathHints??{}))for(let n of t)Ye.set(n,e);function qe(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 Tn(){let e=ke();if(!e&&!jt)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:i=>JSON.parse(e.analyzeQueryJson(i)),tagNode:i=>JSON.parse(e.tagNodeJson(i.qualifiedName??"",i.file??""))}:Nn(),n=le(i=>t.analyzeQuery(i),()=>t.version());return{...t,rankSymbols:n.rankSymbols}}function Nn(){return{version:()=>Ie,tagNode(e){let t=new Set([...qe(e.file??""),...qe(e.qualifiedName??"")]),n=new Set;for(let o of t){if(o.length<3||pe.has(o)||ne.has(o))continue;for(let r of H[o]??[])n.add(T[r].path);let l=Pe[o];l&&n.add(l);let a=Ye.get(o);if(a&&!l){let r=be.get(a);r&&n.add(r)}}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=mn(e),n=new Set(t);for(let s=0;s<t.length-1;s++)n.add(`${t[s]} ${t[s+1]}`);let i=new Set(n),o=[];for(let s of[...n].sort()){let u=R.acronyms[s];u&&o.push({acronym:s,full:u})}for(let s of o)for(let u of Z(s.full))n.add(u);let l=gn(e),a=` ${[...l,...o.map(s=>s.full)].join(" ")} `,r=(s,u)=>{let k=` ${u} `;for(let m=s.indexOf(k);m!==-1;m=s.indexOf(k,m+1)){let y=s.slice(0,m),M=y.lastIndexOf(" ");if(M!==-1&&pn.has(y.slice(M+1)))return!0}return!1},d=(s,u)=>u.charCodeAt(0)===97&&u.charCodeAt(1)===32?r(s,u):s.includes(` ${u} `),p=s=>s.includes(" ")?d(a,s):n.has(s),f=s=>s.length>3&&s.endsWith("s")&&!s.endsWith("ss")?s.slice(0,-1):s,h=t.map(f),v=` ${l.map(f).join(" ")} `,c=new Set(h);for(let s=0;s<h.length-1;s++)c.add(`${h[s]} ${h[s+1]}`);let b=s=>p(s)||(s.includes(" ")?d(v,s):c.has(s)),g=[],w=new Map,N=(s,u)=>w.set(s,(w.get(s)??0)+u),$=new Map,S=new Map,A=new Map,_=[],C=(s,u,k)=>{$.set(s,($.get(s)??0)+u);let m=S.get(s)??[];m.includes(k)||m.push(k),S.set(s,m)},W=(s,u,k)=>{let m=R.vendors[s];if(!m)return;let y=A.get(s),M=fe(k);if(y&&y.score>=M)return;let x=Pe[s],E=x!==void 0?We.get(x):void 0;if(A.set(s,{name:s,from:u,topic:m.topic,score:M,files:E!==void 0?ze(E):[],...x?{node:x}:{}}),x!==void 0){let L=We.get(x);L!==void 0&&C(L,k,u===s?s:`~${u}`)}};if(T.length){for(let m of o)for(let y of H[m.acronym]??[])C(y,sn,m.acronym);for(let[m,y]of Object.entries(H)){if(!b(m))continue;let M=De(m),x=Math.floor(M/y.length);for(let E of y)C(E,x,m)}for(let m of n)R.vendors[m]&&W(m,m,ue);let s=[];for(let m of t)!R.vendors[m]&&!H[m]&&s.push({token:m,from:m,maxDistance:2});for(let m=0;m<t.length-1;m++){let y=t[m],M=t[m+1],x=`${y}${M}`;if(R.vendors[x]){W(x,`${y} ${M}`,ue);continue}if(H[x])continue;let E=[y,M].filter(L=>!ne.has(L));y.length>=3&&M.length>=3&&E.some(L=>L.length>=4)&&s.push({token:x,from:`${y} ${M}`,maxDistance:1})}let u=new Set,k=new Map;for(let{token:m,from:y,maxDistance:M}of s){if(m.length<je||u.has(m)||(u.add(m),R.vendors[m]||H[m]))continue;let x=An(m,M);if(!x||x.distance===0)continue;let E=x.distance===1?tn:nn;if(_.push({from:y,to:x.key.ref,distance:x.distance}),k.set(m,x.key.ref),x.key.kind==="vendor")W(x.key.ref,y,E);else if(x.key.kind==="term"){let L=H[x.key.ref]??[];for(let we of L)C(we,Math.floor(E/L.length),`~${y}`)}}if(k.size){let m=t.map(E=>k.get(E)??E);for(let E=0;E<m.length-1;E++){let L=k.get(`${t[E]}${t[E+1]}`);L&&(m[E]=L,m[E+1]="")}let y=m.filter(Boolean),M=` ${y.join(" ")} `,x=new Set(y);for(let E=0;E<y.length-1;E++)x.add(`${y[E]} ${y[E+1]}`);for(let[E,L]of Object.entries(H)){if(!(E.includes(" ")?M.includes(` ${E} `):x.has(E))||(E.includes(" ")?a.includes(` ${E} `):n.has(E)))continue;let Xe=Math.floor(De(E)*an/10),Ze=Math.floor(Xe/L.length);for(let Qe of L)C(Qe,Ze,`~${E}`)}}for(let[m,y]of $){let M=T[m]?.topic;M&&N(M,y)}}for(let s of o)for(let u of Z(s.full))g.push({term:u,from:s.acronym,weight:Bt});for(let s of n){let u=R.vendors[s];if(u){N(u.topic,ue);for(let k of u.terms)for(let m of Z(k))g.push({term:m,from:s,weight:Xt})}}for(let[s,u]of Object.entries(R.topics))for(let k of u.terms){if(!p(k))continue;let m=!k.includes(" ")&&(pe.has(k)||ne.has(k));N(s,m?Ke:on)}if(R.vectors&&Ue.length){let s=new Map;for(let u of t){if(u.length<3||He.has(u)||bn.has(u))continue;let k=yn(u);if(k)for(let m=0;m<R.vectors.dim;m++){let y=vn(k.row,m);y>=hn&&s.set(m,(s.get(m)??0)+y)}}for(let[u,k]of s){let m=R.vectors.topics[u];N(m,Math.round(Math.min(k,Le)*rn/Le))}}for(let s of n){let u=R.synonyms[s];if(u)for(let k of u)for(let m of Z(k))g.push({term:m,from:s,weight:Zt})}let O=[...w.entries()].filter(([,s])=>s>=$e),P=Math.max(0,...O.map(([,s])=>s)),D=P>0?O.map(([s,u])=>({id:s,score:Math.round(u/P*1e3)/1e3})).filter(s=>s.score>=Yt).sort((s,u)=>u.score-s.score||(s.id<u.id?-1:1)).slice(0,Vt):[];for(let s of D){let u=0;for(let k of R.topics[s.id]?.terms??[])for(let m of Z(k))i.has(m)||u>=Gt||(g.push({term:m,from:s.id,weight:Math.round(Qt*s.score*1e3)/1e3}),u+=1)}let z=new Map;for(let s of g){if(i.has(s.term))continue;let u=z.get(s.term);(!u||s.weight>u.weight)&&z.set(s.term,s)}let I=[...z.values()].sort((s,u)=>u.weight-s.weight||(s.term<u.term?-1:1)).slice(0,Ut),F=new Array(T.length).fill(0);for(let[s,u]of $){let k=s;for(;k!==void 0&&k>=0;){F[k]+=u;let m=T[k].parent;k=m>=0?m:void 0}}let K=s=>F[s]>=$e,ye=[];for(let s=0;s<T.length;s++)K(s)&&(he[s].some(u=>K(u))||ye.push(s));let se=ye.map(s=>{let u=[];for(let y=s;y>=0&&(u.unshift(y),!(T[y].parent<0));y=T[y].parent);let k=new Set,m=y=>{for(let M of S.get(y)??[])k.add(M);for(let M of he[y]??[])m(M)};for(let y of u)for(let M of S.get(y)??[])k.add(M);return m(s),{path:T[s].path,levels:u.map(y=>({id:T[y].path.split("/").pop(),path:T[y].path,score:fe(F[y]),terms:(T[y].terms??[]).slice(0,un)})),score:fe(F[s]),evidence:Math.round(F[s])/1e3,via:[...k].sort(),terms:(T[s].terms??[]).slice(0,ln),files:ze(s),standards:Sn(s)}}).sort((s,u)=>u.evidence-s.evidence||(s.path<u.path?-1:1)).slice(0,cn),ve=[...A.values()].sort((s,u)=>u.score-s.score||(s.name<u.name?-1:1)),Be=[...new Map(_.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 se)for(let u of s.files)V.includes(u)||V.push(u);let Q=[];for(let s of se)for(let u of s.standards)Q.some(k=>k.name===u.name)||Q.push(u);let re=[];for(let s of Q.slice(0,de))for(let u of s.categories)re.includes(u)||re.push(u);return{version:Ie,topics:D,expansions:I,taxonomy:se,vendors:ve,corrections:Be,files:V.slice(0,dn),standards:Q.slice(0,de),categories:re}}}}export{Tn as createRelevanceProvider,le as createSymbolRanker};
|
|
1
|
+
var ie={};import*as ee from"node:fs";import{fileURLToPath as et}from"node:url";var K;function j(){if(K!==void 0)return K;K=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(o=>et(o)).find(o=>ee.existsSync(o));if(!t)return K;let n=new WebAssembly.Module(ee.readFileSync(t)),s=new WebAssembly.Instance(n,{}).exports,c=o=>{let d=new TextEncoder().encode(o),m=s.vg_alloc(d.length);return new Uint8Array(s.memory.buffer,m,d.length).set(d),{ptr:m,len:d.length}},a=o=>{let m=new DataView(s.memory.buffer,o,4).getUint32(0,!0),f=new TextDecoder().decode(new Uint8Array(s.memory.buffer,o+4,m));return s.vg_free(o,4+m),f};return K={version:()=>a(s.vg_version()),analyzeQueryJson:o=>{let{ptr:d,len:m}=c(o),f=a(s.vg_analyze(d,m));return s.vg_free(d,m),f},tagNodeJson:(o,d)=>{let m=c(o),f=c(d),h=a(s.vg_tag(m.ptr,m.len,f.ptr,f.len));return s.vg_free(m.ptr,m.len),s.vg_free(f.ptr,f.len),h},surfaces:tt(s,c,a),modelTableJson:s.vg_model_table?()=>a(s.vg_model_table()):null},K}catch{return K=null,K}}function tt(e,t,n){if(!e.vg_surface_classify||!e.vg_surface_search||!e.vg_surface_get||!e.vg_surface_catalog)return null;let i=(s,c)=>{let{ptr:a,len:o}=t(c);try{return n(s(a,o))}finally{e.vg_free(a,o)}};return{classifyJson:s=>i(e.vg_surface_classify,s),searchJson:s=>i(e.vg_surface_search,s),getJson:s=>i(e.vg_surface_get,s),catalogJson:()=>n(e.vg_surface_catalog())}}var V=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","handle","handles","handled","handling","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:["debit","mandate","stripe","invoice","billing","charge","card","checkout","refund","subscription"],pay:["stripe","invoice","payment","billing","charge"],paying:["invoice","billing","payment"],receipt:["invoice","billing","payment"],billing:["stripe","invoice","payment","charge","subscription"],billed:["invoice","billing","charge"],checkout:["stripe","payment","session"],debit:["mandate","payment","bacs","bank","sepa"],mandate:["debit","bacs","sepa"],sepa:["debit","mandate","bank"],bacs:["debit","mandate","bank"],stripe:["billing","webhook","payment","card","charge","checkout"],refund:["invoice","stripe","payment","charge"],invoice:["billing","payment","refund","subscription"],subscription:["invoice","billing"],recurring:["debit","mandate"],renewal:["billing","renew","subscription"],card:["stripe","payment","charge"],credit:["payment","card","charge"],bank:["debit","mandate","account","sepa"],charge:["stripe","payment","card"],customer:["billing","account"],auth:["login","oauth","password","session","token"],authentication:["auth","login","password","session","token"],authorization:["auth","oauth","permission"],authorisation:["auth","oauth","permission"],login:["auth","oauth","password","session"],signup:["account","register"],password:["auth","login"],session:["auth","login","token"],token:["auth","session"],oauth:["auth","login","callback"],google:["auth","login","oauth"],inference:["llm","completion","prompt","serving"],dependency:["advisory","vulnerability","audit","package"],package:["advisory","vulnerability","audit","dependency"],vulnerability:["advisory","audit","osv","vulnerable"],vulnerable:["advisory","vulnerability","audit"],advisory:["vulnerability","audit","osv"],cve:["advisory","vulnerability","osv"],risk:["advisory","vulnerability","audit"],security:["advisory","vulnerability","audit"],audit:["advisory","vulnerability","dependency"],scan:["scanner","vulnerability","audit"],retry:["backoff","throttle"],retries:["backoff","throttle"],email:["sender","template","message"],mail:["email","sender"],notification:["email","sms"],notify:["notification","email"],sms:["notification","message"],cart:["shop","order","discount"],order:["shop","fulfillment","cart","shipment"],shipping:["order","fulfillment","shipment"],shipped:["order","fulfillment","shipment"],inventory:["product","catalog","restock"],product:["shop","catalog","inventory"],discount:["cart"],chat:["room","presence","message"],message:["chat"],conversation:["chat","message"],online:["presence"],typing:["presence","broadcast","indicator"],video:["media","playback","thumbnail","transcode","stream"],stream:["playback","media","manifest"],streaming:["media","video","playback","manifest"],playback:["media","video","stream","watch"],transcode:["video","media"],thumbnail:["video","media"],media:["video","playback","stream"],analytics:["event","funnel","report","track"],event:["analytics","track"],track:["analytics","event"],funnel:["analytics","event","conversion"],conversion:["analytics","funnel"],report:["analytics","export","metrics"],article:["cms","publish"],publish:["article"],content:["article","cms","markdown"],markdown:["article","render"],deploy:["deployment","pipeline","release","rollback"],deployment:["pipeline","deploy","release","rollback"],release:["deploy","rollback"],rollback:["deployment","deploy","release"],pipeline:["ci","runner","stage","deploy"],canary:["deploy","release"],push:["mobile","device","token"],device:["mobile","push","register","token"],mobile:["push","device"],ios:["link","mobile","universal"],android:["push","mobile","device"],batch:["settlement","reconcile"],settlement:["batch","ledger","reconcile"],reconcile:["settlement","batch","ledger"],ledger:["settlement","reconcile"],mainframe:["settlement","batch","ebcdic","fixed"],ebcdic:["convert","record"],nightly:["batch"],geocode:["geo","address"],address:["geocode"],route:["geo","planner","distance"],distance:["route","geo"],arrival:["route","estimate"],translation:["locale"],translate:["locale","translation"],locale:["translation","format"],i18n:["locale","translation"],localized:["locale","translation","format"],metric:["export","counter","prometheus"],prometheus:["exporter","metric"],trace:["observability","span"],span:["trace"],counter:["increment","metric"],flag:["feature","experiment","rollout"],rollout:["flag","experiment","percentage"],experiment:["flag","assign","exposure","variant"],variant:["experiment","assign"],toggle:["flag","experiment","variant"],cache:["ttl","redis","memoize","eviction"],ttl:["cache","redis","eviction"],memoize:["cache","ttl"],database:["schema","migration","query","orm"],db:["database","schema","migration"],migration:["database","schema"],orm:["database","query","schema"],sql:["database","query","schema"],transaction:["database","schema"],queue:["broker","consumer","subscribe","topic"],broker:["queue","consumer","subscribe"],subscribe:["queue","broker","consumer"],consumer:["queue","broker","subscribe"],log:["logging"],logging:["log"],logger:["log","logging"],webhook:["callback","signature","idempotency"],callback:["webhook","signature"],idempotency:["webhook","callback"],throttle:["backoff","quota"],backoff:["throttle","quota"],quota:["throttle","backoff"],api:["endpoint","middleware"],endpoint:["api","middleware"],middleware:["api","endpoint"],graphql:["resolver","mutation"],resolver:["mutation"],component:["render","router"],render:["component","router"],router:["component","render"],css:["stylesheet","theme"],stylesheet:["css","theme"],theme:["css","stylesheet"],facet:["index","ranking"],ranking:["facet","index"],a11y:["aria","focus","contrast"],aria:["a11y","focus","contrast"],mock:["fixture","snapshot"],fixture:["mock","snapshot"],snapshot:["mock","fixture"],coverage:["mock","fixture"],consent:["retention","policy"],retention:["consent","policy"],csrf:["xss","sanitize"],xss:["csrf","sanitize"],logout:["session","auth"],mfa:["auth","login","sso"],sso:["auth","oauth"],jwt:["token","auth","session"],oidc:["oauth","auth","login"],cors:["origin","header"],smtp:["email","sender"],lockfile:["dependency"],language:["locale","translation","i18n"],l10n:["locale","i18n","translation"],localization:["locale","i18n","translation"],permission:["role","access"],role:["permission","access"]},Se={"direct debit":["debit","mandate","bacs","bank","sepa"],"direct debits":["debit","mandate","bacs","bank","sepa"],"sign in":["auth","login","session"],"signs in":["auth","login","session"],"log in":["login","auth","session"],"logs in":["auth","login","session"],"logged in":["login","auth","session"],"sign up":["account","register"],"signs up":["account","register"],"signing up":["account","register"],"signed up":["account","register"],"credit card":["stripe","payment","card","charge"],"credit cards":["stripe","payment","card","charge"],"two factor":["auth"],"payment method":["debit","stripe","payment","card"],"payment methods":["debit","stripe","payment","card"],"inference payment":["credit","usage"],"inference payments":["credit","usage"],"inference cost":["credit","usage"],"inference costs":["credit","usage"],"inference billing":["credit","usage"],"push notification":["push","device","token"],"push notifications":["push","device","token"],"deep link":["link"],"deep links":["link"],"universal link":["link","universal"],"universal links":["link","universal"],"feature flag":["experiment","flag","rollout"],"feature flags":["experiment","flag","rollout"],"shopping cart":["cart","order"],"roll back":["deployment","deploy","release"],"sign out":["session","auth"],"fixed width":["batch","export","record"],"canary rollout":["deployment","pipeline","deploy","release"],"canary rollouts":["deployment","pipeline","deploy","release"],"blog post":["article","cms","markdown","publish"],"blog posts":["article","cms","markdown","publish"],"signed out":["session","auth"],"rate limit":["throttle","backoff","quota"],"rate limits":["throttle","backoff","quota"],"screen reader":["a11y","aria","focus"],"dark mode":["theme","css"],"access token":["auth","session"],"refresh token":["token","session","auth"],"password reset":["password","token","auth"],"health check":["healthcheck","probe","live"],"circuit breaker":["circuit","breaker","fallback"],"api route":["router","endpoint"],"api routes":["router","endpoint"],"url route":["router","endpoint"],"url routes":["router","endpoint"],"route distance":["geo","planner","distance"],"queue message":["queue","broker","consumer"],"dead letter":["queue","broker","consumer"],"scan directory":["walk","glob"],"scan files":["walk","glob"],"search index":["facet","ranking"],"keyboard focus":["a11y","aria","focus"],"transaction rollback":["transaction","database","commit"],"rollback transaction":["transaction","database","commit"]},nt={"canary rollout":["rollout"],"canary rollouts":["rollouts"],"blog post":["post","blog"],"blog posts":["posts","blog"],"push notification":["notification"],"push notifications":["notification","notifications"],"inference payment":["payment"],"inference payments":["payment","payments"],"inference cost":["cost"],"inference costs":["cost","costs"],"inference billing":["billing"],"api route":["route"],"api routes":["route","routes"],"url route":["route"],"url routes":["route","routes"],"route distance":["route"],"queue message":["message"],"dead letter":["letter"],"scan directory":["scan"],"scan files":["scan"],"search index":["index"],"transaction rollback":["rollback"],"rollback transaction":["rollback"]},rt=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 ae(e){let t=new Set;for(let n=0;n+1<e.length;n++){let i=`${e[n]} ${e[n+1]}`;rt.has(i)&&t.add(e[n]),st.has(i)&&t.add(e[n+1])}return t}function _e(){return Object.keys(G)}function Re(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=ae(e),i=[],s=new Set,c=(o,d)=>{t.has(o)||s.has(o)||(s.add(o),i.push({term:o,from:d}))};for(let o=0;o+1<e.length;o++){let d=`${e[o]} ${e[o+1]}`,m=Se[d];if(m)for(let f of m)c(f,d)}let a=U(e);for(let o of e){if(n.has(o)||a.has(o))continue;let d=Re(o);if(d)for(let m of G[d])c(m,o)}return i}function U(e){let t=new Set;for(let n=0;n+1<e.length;n++){let i=`${e[n]} ${e[n+1]}`;if(Se[i]){for(let s of[e[n],e[n+1]])Re(s)||t.add(s);for(let s of nt[i]??[])t.add(s)}}return t}var Oe=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","files","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"]),ot=.25,xe=.7,it=.35,at=.5,ct=.5,lt=.4,Ee=.3,ut=.3;function ft(e){let t=new Map;for(let s of e){let c=t.get(s.sym.file);(c===void 0||s.score>c)&&t.set(s.sym.file,s.score)}let n=new Map;for(let[s,c]of t){let a=s.slice(0,s.lastIndexOf("/")+1),o=n.get(a)??[];o.push(c),n.set(a,o)}let i=new Map;for(let[s,c]of n)c.sort((a,o)=>o-a),i.set(s,c.slice(0,3).reduce((a,o)=>a+o,0));return i}var dt=4,gt=64,pt=.35,mt=/(^|\/)(tests?|testing|__tests__)(\/|$)|(^|\/)(test_[^/]*|conftest\.py)$|[._-](test|tests|spec)\.[a-z0-9]+$/i;function ht(e){return mt.test(e)}var bt=/(^|\.)tests?(\.|$)|(^|\.)(?:test_[^.]*|Test[A-Z][^.]*|Benchmark[A-Z][^.]*|Fuzz[A-Z][^.]*)$/;function yt(e){return bt.test(e)}var vt=/\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 kt(e,t){return vt.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&&!Oe.has(t)))]}function X(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=1)}function wt(e){let t=e.trim();return t=t.replace(/[.,;:!)\]}>]+$/g,""),t.endsWith("?")&&t.lastIndexOf("?")===t.length-1&&(t=t.slice(0,-1)),t}function ne(e){let t=[],n=new Set,i=(s,c)=>{let a=s.trim();a=c==="url"?wt(a):a.replace(/[.,;:!)\]}>?]+$/g,""),!(a.length<2||n.has(a))&&(n.add(a),t.push(a))};for(let s of e.matchAll(/https?:\/\/[^\s"'`<>]+/gi))i(s[0],"url");for(let s of e.matchAll(/(["'`])((?:(?!\1)[^\\]|\\.){2,})\1/g))i(s[2].replace(/\\(.)/g,"$1"),"quote");return t}function ce(e){let t=e;for(let n of e.matchAll(/https?:\/\/[^\s"'`<>]+/gi))t=t.split(n[0]).join(" ");for(let n of ne(e))t=t.split(n).join(" ");return t=t.replace(/(["'`])\s*\1/g," "),t.replace(/\s+/g," ").trim()}function St(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 _t(e,t){if(!t.length||St(e))return null;let n=t.filter(i=>!/^https?:\/\//i.test(i)&&!i.includes("/"));return n.length?n.join(" "):null}function te(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 le(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 Rt(e,t){for(let n of t){let i=Te(e,n);if(i>=5&&i>=.6*Math.min(e.length,n.length))return!0}return!1}function Te(e,t){let n=Math.min(e.length,t.length),i=0;for(;i<n&&e[i]===t[i];)i++;return i}var xt=16,Et=36,Mt=.75,At=.55;function Ot(e){let t=new Map;for(let n of e){if(Oe.has(n)||t.has(n))continue;let i=t.size;t.set(n,i<xt?1:i<Et?Mt:At)}return t}function Tt(e,t,n,i){let s=Y(e),c=X(e),a=new Set(s),o=U(c),d=ae(c),m=Ot(c),f=s.map(l=>({term:l,weak:V.has(l)||o.has(l)||d.has(l),positional:m.get(l)??1})),h=new Set(s);for(let l of J(c))a.has(l.term)||(f.push({term:l.term,weak:!1,from:l.from,positional:m.get(l.from)??1}),h.add(l.term));if(i){let l=X(i),b=U(l);for(let p of Y(i))h.has(p)||V.has(p)||b.has(p)||(f.push({term:p,weak:!1,from:"quote",quoted:!0}),h.add(p));for(let p of J(l))h.has(p.term)||(f.push({term:p.term,weak:!1,from:p.from}),h.add(p.term))}for(let l of t?.expansions??[]){let b=String(l?.term??"").toLowerCase().trim(),p=String(l?.from??"").toLowerCase().trim(),k=Number(l?.weight);!b||!p||b.includes(" ")||h.has(b)||V.has(p)||V.has(b)||!Number.isFinite(k)||k<ct||(f.push({term:b,weak:!1,from:p,packWeight:Math.min(1,k)}),h.add(b))}if(n?.trim()){let l=X(n),b=U(l);for(let p of Y(n))h.has(p)||V.has(p)||b.has(p)||(f.push({term:p,weak:!1,carried:!0}),h.add(p));for(let p of J(l))h.has(p.term)||(f.push({term:p.term,weak:!1,from:p.from,carried:!0}),h.add(p.term))}let v=f.some(l=>!l.weak);return{terms:f,hasContent:v}}function Ce(e){let t=e?.trim();return t?ne(t).length>0?ce(t):t:null}function Ct(e,t){let n=t.terms.filter(a=>!a.weak&&!a.from&&!a.carried&&a.term.length>=4);if(!n.length)return;let i=new Map,s=new Set;for(let a of e){let o=a.name.toLowerCase(),d=a.file.toLowerCase(),m=te(a.name);for(let f of m)s.add(f);for(let f of n){let h=le(f.term);(m.has(f.term)||h!==null&&m.has(h)||o.includes(f.term)||d.includes(f.term))&&i.set(f.term,(i.get(f.term)??0)+1)}}let c=new Set(t.terms.map(a=>a.term));for(let a of n){if((i.get(a.term)??0)>0||J([a.term]).length>0)continue;let o=a.term.length>=8?2:1,d=null,m=(h,v)=>{if(h.length<4||h===a.term||v!==0&&a.term.length<6||Math.abs(h.length-a.term.length)>o||h[0]!==a.term[0])return;let l=Nt(a.term,h,o);if(l>o)return;let b=Te(a.term,h);(!d||l<d.dist||l===d.dist&&(b>d.prefix||b===d.prefix&&(v<d.lex||v===d.lex&&h<d.cand)))&&(d={cand:h,dist:l,prefix:b,lex:v})};for(let h of _e())m(h,0);for(let h of s)m(h,1);if(!d)continue;let{cand:f}=d;c.has(f)||(t.terms.push({term:f,weak:!1,from:a.term}),c.add(f))}}function Nt(e,t,n){let i=e.length,s=t.length;if(Math.abs(i-s)>n)return n+1;let c=null,a=Array.from({length:s+1},(o,d)=>d);for(let o=1;o<=i;o++){let d=new Array(s+1);d[0]=o;let m=d[0];for(let f=1;f<=s;f++){let h=e[o-1]===t[f-1]?0:1,v=Math.min(a[f]+1,d[f-1]+1,a[f-1]+h);c&&o>1&&f>1&&e[o-1]===t[f-2]&&e[o-2]===t[f-1]&&(v=Math.min(v,c[f-2]+1)),d[f]=v,v<m&&(m=v)}if(m>n)return n+1;c=a,a=d}return a[s]}function It(e,t){if(t.length===0)return()=>1;let n=new Map,i=0;for(let c of e){i++;let a=c.name.toLowerCase(),o=te(c.name);for(let d of t){let m=le(d);(o.has(d)||m!==null&&o.has(m)||a.includes(d))&&n.set(d,(n.get(d)??0)+1)}}let s=new Map;for(let c of t){let a=Math.log((i+1)/((n.get(c)??0)+1))+1;s.set(c,Math.max(.5,Math.min(8,a)))}return c=>s.get(c)??1}function Pt(e,t,n){let i=0,s=0,c=!1,a=!1,o=[],d=e.name.toLowerCase(),m=e.qualifiedName.toLowerCase(),f=e.file.toLowerCase(),h=f.split("/"),v=new Set(h.slice(0,-1)),l=h[h.length-1].replace(/\.[a-z0-9]+$/,""),b=te(l),p=te(e.name);for(let{term:k,weak:T,from:I,packWeight:S,carried:A,quoted:R,positional:P}of t){let z=S!==void 0?Math.min(S,xe):I&&!R?xe:1,C=n(k)*(T?ot:1)*z*(A?at:1)*(P??1),L=(A?"\u21A9":"")+(I?`${I}\u2192${k}`:k),F=k.length>=4,D=le(k),N=0,W=!1,q=!1;d===k?(N=10*C,q=!0,o.push(L)):p.has(k)||D!==null&&p.has(D)?(N=6*C,q=!0,o.push(L)):l===k||D!==null&&l===D?(N=(C>=3?8:5)*C,q=!0,o.push(L)):F&&d.includes(k)?(N=4*C,o.push(L)):F&&m.includes(k)||b.has(k)||D!==null&&b.has(D)?(N=3*C,o.push(L)):F&&k.length>=5&&l.includes(k)?(N=2.5*C,o.push(L)):S===void 0&&Rt(k,p)?(N=2*C,o.push((A?"\u21A9":"")+(I?`~${I}\u2192${k}`:`~${k}`)),W=!0):v.has(k)?(N=2*C,o.push(L)):F&&f.includes(k)&&(N=1*C,o.push(L)),N>0&&(i+=N,T||(s+=1,W||(c=!0),q&&(a=!0)))}return s===0?{score:0,why:"",strong:!1,direct:!1}:(i*=1+it*Math.min(s-1,4),{score:i,why:o.length?`matched: ${o.join(", ")}`:"",strong:c,direct:a})}function $t(e,t){let n=e.split("/"),i=t.split("/"),s=0;for(;s<n.length&&s<i.length&&n[s]===i[s];)s++;return s}function Lt(e,t,n){if(!n)return{boost:1,label:""};let i=n[e];if(!i?.length)return{boost:1,label:""};let s=t?.taxonomy??[];if(s.length&&i.some(o=>o.includes("/"))){let o=0,d="";for(let m of s){let f=m.path.split("/").length;for(let h of i){let v=$t(m.path,h);if(v===0)continue;let l=v/f*m.score;l>o&&(o=l,d=v===f?m.path:m.path.split("/").slice(0,v).join("/"))}}return o<=0?{boost:1,label:""}:{boost:1+Ee*Math.min(o,1),label:`, topic:${d}`}}if(!t?.topics?.length)return{boost:1,label:""};let c=0,a=[];for(let o of t.topics)i.includes(o.id)&&(c+=o.score,a.push(o.id));return c<=0?{boost:1,label:""}:{boost:1+Ee*Math.min(c,1),label:`, topic:${a.sort().join("+")}`}}function Me(e){return e.toLowerCase().replace(/\d+/g,"")}var Dt=2;function Ft(e){return(e.name||e.qualifiedName).toLowerCase()}function zt(e){let t=e[0]?.score??0;return t<=0?e:e.filter(n=>n.strong||n.score>=t/3)}function Wt(e){let t=new Set,n=[],i=[];for(let l of e)t.has(l.sym.file)?i.push(l):(t.add(l.sym.file),n.push(l));let s=n.concat(i),c=new Map,a=[],o=[];for(let l of s){let b=Ft(l.sym),p=c.get(b)??0;c.set(b,p+1),(p<Dt?a:o).push(l)}let d=a.concat(o),m=new Set;for(let l of e)l.strong&&m.add(Me(l.sym.file));if(m.size<2)return d;let f=new Map,h=[],v=[];for(let l of d){let b=Me(l.sym.file),p=f.get(b)??0;p<dt?(f.set(b,p+1),h.push(l)):v.push(l)}return h.concat(v)}function Kt(e,t,n){let i=l=>[...new Set(l)].slice(0,8).join(", "),c=ne(e).length>0?ce(e):e,a=[],o=new Map;for(let l of J(X(c))){let b=o.get(l.from)??[];b.push(l.term),o.set(l.from,b)}for(let[l,b]of o)a.push(`- "${l}" in the ask implies these codebase identifiers: ${i(b)}.`);let d=t?.taxonomy??[];if(d.length){let l=new Set,b=[];for(let S of d)for(let A of S.levels)l.has(A.path)||(l.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(S=>S.depth)),k=(S,A)=>S.terms.length?`${A} ${S.id}; code for it typically uses: ${i(S.terms)}.`:`${A} ${S.id}.`;for(let S of b.filter(A=>A.depth===p))a.push(k(S,"- The ask is specifically about"));let T=new Set(b.filter(S=>S.depth===p).map(S=>S.id));for(let S of(t?.vendors??[]).filter(A=>A.score>0).slice(0,3)){if(T.has(S.name)){S.from!==S.name&&a.push(`- That product was typed "${S.from}".`);continue}a.push(S.from===S.name?`- It names the product "${S.name}".`:`- It names the product "${S.name}" (typed "${S.from}").`)}let I=new Set((t?.vendors??[]).map(S=>S.name));for(let S=p-1;S>=1;S--)for(let A of b.filter(R=>R.depth===S&&!I.has(R.id)))a.push(k(A,"- More broadly, this is"))}else if(t?.topics?.length){let l=new Map;for(let b of t.expansions??[]){let p=l.get(b.from)??[];p.push(b.term),l.set(b.from,p)}for(let b of t.topics.slice(0,3)){let p=l.get(b.id);a.push(p?.length?`- The ask is about the "${b.id}" domain; code for it typically uses: ${i(p)}.`:`- The ask is about the "${b.id}" domain.`)}}let m=t?.standards??[];if(m.length){let l=m.filter(k=>k.kind!=="regulation"),b=m.filter(k=>k.kind==="regulation"),p=k=>k.slice(0,3).map(T=>T.publisher?`${T.name} (${T.publisher})`:T.name).join("; ");l.length&&a.push(`- Standards that govern this area: ${p(l)}.`),b.length&&a.push(`- Regulations that apply here: ${p(b)}.`)}let f=t?.categories??[];f.length&&a.push(`- Related categories: ${i(f)}.`);let h=t?.files??[];h.length&&a.push(`- Files for this kind of work are usually named or extended: ${i(h)}.`);for(let l of(t?.corrections??[]).slice(0,3))a.push(`- Read "${l.from}" in the ask as "${l.to}".`);let v=Ce(n);if(v){let l=new Set(Y(c)),b=U(X(v)),p=Y(v).filter(k=>!l.has(k)&&!V.has(k)&&!b.has(k));p.length&&a.push(`- This is a follow-up; topic words carried from the previous ask: ${i(p)}.`)}return a.length&&a.push('- Seed notation below: `a\u2192b` = ask term "a" implied identifier "b"; `~t` = word-form match; `\u21A9t` = carried from the previous ask.'),a}var Ht=/^\s*at\s+\S.*\((?:node:|internal\/|[^()]*[/\\]node_modules[/\\]|[^()]*[/\\]\.pnpm[/\\])[^()]*\)\s*$/i,qt=/^\s*at\s+(?:node:|internal\/|\/?(?:[^\s()]*[/\\])?node_modules[/\\])\S*\s*$/i;function Vt(e){if(!e.includes(" at ")&&!/^\s*at\s/m.test(e))return e;let n=e.split(`
|
|
2
|
+
`).filter(i=>!Ht.test(i)&&!qt.test(i)).join(`
|
|
3
|
+
`).trim();return n.length>0?n:e}function Ae(e){return Math.round(e*1e6)/1e6}function ue(e,t){return{rankSymbols(n,i,s={}){let c=Math.max(1,Math.min(s.limit??16,gt)),a=Vt(n),o=null;try{o=e(a)}catch{o=null}let d=ne(a),m=d.length>0?ce(a):a,f=Ce(s.priorQuestion),h=Tt(m,o,f,_t(n,d));Ct(i,h);let v=Kt(n,o,s.priorQuestion??null);if(!h.hasContent)return{version:t(),hasContent:!1,seeds:[],conceptMap:v};let l=It(i,h.terms.map(R=>R.term)),b=!kt(a,h.terms),p=[];for(let R of i){let{score:P,why:z,strong:C,direct:L}=Pt(R,h.terms,l);if(P>0){let F=Lt(R.id,o,s.topicTags),D=ht(R.file)||yt(R.qualifiedName),N=b&&D?pt:1;p.push({sym:R,score:Ae(P*N*F.boost*(1+lt*R.importance)),why:z+F.label,strong:C,direct:L})}}let k=ft(p),T=0;for(let R of k.values())R>T&&(T=R);if(T>0)for(let R of p){let P=R.sym.file.slice(0,R.sym.file.lastIndexOf("/")+1),z=(k.get(P)??0)/T;R.score=Ae(R.score*(1+ut*z))}p.sort((R,P)=>P.score-R.score||(R.sym.qualifiedName<P.sym.qualifiedName?-1:1));let I=Wt(zt(p)).slice(0,c);if(!I.some(R=>R.direct))return{version:t(),hasContent:!1,seeds:[],conceptMap:v};let A=I.map(R=>({id:R.sym.id,score:R.score,why:R.why}));return{version:t(),hasContent:!0,seeds:A,conceptMap:v}}}}var jt=!1,Ne=`vg-relevance@1.5.0+pack.${ie.version}`,Jt=20,Ut=8,Bt=4,Gt=.34,Yt=.8,Xt=.6,Zt=.5,Qt=.45,He=new Set(["the","and","for","with","first","new","web","app","development"]),en=2e3,tn=1200,qe=550,fe=2e3,nn=1200,rn=800,sn=1e3,on=600,Ie=1e3,Pe=3e3,an=1e3,de=e=>Math.round(Math.min(e,Pe)/Pe*1e3)/1e3,Ve=6,cn=6,ln=6,un=10,fn=6,dn=6,gn=8,ge=4,_=ie;for(let e of[_.acronyms,_.vendors,_.synonyms,_.topics,_.taxonomyTerms,_.vendorNode,_.fileHints,_.standards])e&&typeof e=="object"&&Object.setPrototypeOf(e,null);function pn(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=2)}function mn(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(t=>t.length>=1)}var hn=new Set(["the","an","our","your","their","its","this","that","these","those","each","every","another","any"]);function Z(e){return e.split(" ").filter(t=>t.length>=3&&!He.has(t))}var bn=40,$e=128,je=Uint8Array.from(Buffer.from(_.vectors?.data??"","base64")),pe=new Map((_.vectors?.terms??[]).map((e,t)=>[e,t])),yn=new Set(_.vectors?.skip??[]);function vn(e){let t=pe.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=pe.get(n),t!==void 0)return{row:t,term:n}}return null}function kn(e,t){let n=je[e*(_.vectors?.dim??0)+t]??0;return n>127?n-256:n}var O=_.taxonomy??[],H=_.taxonomyTerms??{},Le=_.vendorNode??{},me=_.fuzzyKeys??[],wn=_.fileHints??{},Sn=_.standards??{};function _n(e){let t=[];for(let n=e;n>=0;n=O[n].parent){let i=O[n].path;for(let s of Sn[i]??[])t.some(c=>c.name===s.name)||t.push({name:s.name,publisher:s.publisher,node:i,kind:s.kind??"standard",categories:s.categories??[]});if(O[n].parent<0)break}return t.slice(0,ge)}function De(e){let t=[];for(let n=e;n>=0;n=O[n].parent){for(let i of wn[O[n].path]??[])t.includes(i)||t.push(i);if(O[n].parent<0)break}return t.slice(0,dn)}var Rn=me.map(e=>({mask:Je(e.key),grams:Ue(e.key),len:e.key.length})),he=new Set(_.weakTerms??[]),re=new Set(_.englishGuard??[]),Fe=e=>e.includes(" ")?en:he.has(e)?qe:tn,be=O.map(()=>[]);for(let[e,t]of O.entries())t.parent>=0&&be[t.parent].push(e);var ze=new Map(O.map((e,t)=>[e.path,t]));function Je(e){let t=0;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n)-97;t|=i>=0&&i<26?1<<i:1<<26}return t}function xn(e){let t=0;for(let n=e;n;n&=n-1)t++;return t}function Ue(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 En(e,t){let n=0,i=0,s=0;for(;n<e.length&&i<t.length;)e[n]===t[i]?(s++,n++,i++):e[n]<t[i]?n++:i++;return s}function Mn(e,t,n){let i=e.length,s=t.length;if(Math.abs(i-s)>n)return n+1;let c=[],a=new Array(s+1);for(let o=0;o<=s;o++)a[o]=o;for(let o=1;o<=i;o++){let d=new Array(s+1);d[0]=o;let m=d[0];for(let f=1;f<=s;f++){let h=e[o-1]===t[f-1]?0:1,v=Math.min(d[f-1]+1,a[f]+1,a[f-1]+h);o>1&&f>1&&e[o-1]===t[f-2]&&e[o-2]===t[f-1]&&(v=Math.min(v,c[f-2]+1)),d[f]=v,v<m&&(m=v)}if(m>n)return n+1;c=a,a=d}return a[s]}var We=new Set(["s","es","ed","d","ing","ly","er","ers","ings"]);function An(e){return e<Ve?0:e>=9?2:1}function On(e,t=2){let n=Math.min(An(e.length),t);if(n===0||pe.has(e)||re.has(e))return null;let i=Ue(e),s=e.length>=6?2:1,c=null,a=n+1,o=!1,d=Je(e);for(let f=0;f<me.length;f++){let h=Rn[f];if(Math.abs(h.len-e.length)>n||xn(d^h.mask)>n*2)continue;let v=me[f];if(En(i,h.grams)<s)continue;let l=Mn(e,v.key,n);l>n||(l<a?(a=l,c=v,o=!1):l===a&&c&&v.ref!==c.ref&&(o=!0))}if(!c||o||a>=2&&e[0]!==c.key[0])return null;let m=e.startsWith(c.key)?e.slice(c.key.length):"";if(m&&/^(id|ids|[0-9]+)$/.test(m))return null;if(e.startsWith(c.key)){let f=e.slice(c.key.length);if(We.has(f))return null}return c.key.startsWith(e)&&We.has(c.key.slice(e.length))?null:{key:c,distance:a}}var ye=new Map;for(let e of O){if(!e.topic)continue;let t=ye.get(e.topic);(!t||e.path.split("/").length<t.split("/").length)&&ye.set(e.topic,e.path)}var Be=new Map;for(let[e,t]of Object.entries(_.topicPathHints??{}))for(let n of t)Be.set(n,e);function Ke(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 Tn(){let e=j();if(!e&&!jt)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:i=>JSON.parse(e.analyzeQueryJson(i)),tagNode:i=>JSON.parse(e.tagNodeJson(i.qualifiedName??"",i.file??""))}:Cn(),n=ue(i=>t.analyzeQuery(i),()=>t.version());return{...t,rankSymbols:n.rankSymbols}}function Cn(){return{version:()=>Ne,tagNode(e){let t=new Set([...Ke(e.file??""),...Ke(e.qualifiedName??"")]),n=new Set;for(let s of t){if(s.length<3||he.has(s)||re.has(s))continue;for(let o of H[s]??[])n.add(O[o].path);let c=Le[s];c&&n.add(c);let a=Be.get(s);if(a&&!c){let o=ye.get(a);o&&n.add(o)}}return[...n].filter(s=>![...n].some(c=>c!==s&&c.startsWith(`${s}/`))).sort((s,c)=>c.split("/").length-s.split("/").length||(s<c?-1:1)).slice(0,3)},analyzeQuery(e){let t=pn(e),n=new Set(t);for(let r=0;r<t.length-1;r++)n.add(`${t[r]} ${t[r+1]}`);let i=new Set(n),s=[];for(let r of[...n].sort()){let u=_.acronyms[r];u&&s.push({acronym:r,full:u})}for(let r of s)for(let u of Z(r.full))n.add(u);let c=mn(e),a=` ${[...c,...s.map(r=>r.full)].join(" ")} `,o=(r,u)=>{let w=` ${u} `;for(let g=r.indexOf(w);g!==-1;g=r.indexOf(w,g+1)){let y=r.slice(0,g),M=y.lastIndexOf(" ");if(M!==-1&&hn.has(y.slice(M+1)))return!0}return!1},d=(r,u)=>u.charCodeAt(0)===97&&u.charCodeAt(1)===32?o(r,u):r.includes(` ${u} `),m=r=>r.includes(" ")?d(a,r):n.has(r),f=r=>r.length>3&&r.endsWith("s")&&!r.endsWith("ss")?r.slice(0,-1):r,h=t.map(f),v=` ${c.map(f).join(" ")} `,l=new Set(h);for(let r=0;r<h.length-1;r++)l.add(`${h[r]} ${h[r+1]}`);let b=r=>m(r)||(r.includes(" ")?d(v,r):l.has(r)),p=[],k=new Map,T=(r,u)=>k.set(r,(k.get(r)??0)+u),I=new Map,S=new Map,A=new Map,R=[],P=(r,u,w)=>{I.set(r,(I.get(r)??0)+u);let g=S.get(r)??[];g.includes(w)||g.push(w),S.set(r,g)},z=(r,u,w)=>{let g=_.vendors[r];if(!g)return;let y=A.get(r),M=de(w);if(y&&y.score>=M)return;let E=Le[r],x=E!==void 0?ze.get(E):void 0;if(A.set(r,{name:r,from:u,topic:g.topic,score:M,files:x!==void 0?De(x):[],...E?{node:E}:{}}),E!==void 0){let $=ze.get(E);$!==void 0&&P($,w,u===r?r:`~${u}`)}};if(O.length){for(let g of s)for(let y of H[g.acronym]??[])P(y,sn,g.acronym);for(let[g,y]of Object.entries(H)){if(!b(g))continue;let M=Fe(g),E=Math.floor(M/y.length);for(let x of y)P(x,E,g)}for(let g of n)_.vendors[g]&&z(g,g,fe);let r=[];for(let g of t)!_.vendors[g]&&!H[g]&&r.push({token:g,from:g,maxDistance:2});for(let g=0;g<t.length-1;g++){let y=t[g],M=t[g+1],E=`${y}${M}`;if(_.vendors[E]){z(E,`${y} ${M}`,fe);continue}if(H[E])continue;let x=[y,M].filter($=>!re.has($));y.length>=3&&M.length>=3&&x.some($=>$.length>=4)&&r.push({token:E,from:`${y} ${M}`,maxDistance:1})}let u=new Set,w=new Map;for(let{token:g,from:y,maxDistance:M}of r){if(g.length<Ve||u.has(g)||(u.add(g),_.vendors[g]||H[g]))continue;let E=On(g,M);if(!E||E.distance===0)continue;let x=E.distance===1?nn:rn;if(R.push({from:y,to:E.key.ref,distance:E.distance}),w.set(g,E.key.ref),E.key.kind==="vendor")z(E.key.ref,y,x);else if(E.key.kind==="term"){let $=H[E.key.ref]??[];for(let we of $)P(we,Math.floor(x/$.length),`~${y}`)}}if(w.size){let g=t.map(x=>w.get(x)??x);for(let x=0;x<g.length-1;x++){let $=w.get(`${t[x]}${t[x+1]}`);$&&(g[x]=$,g[x+1]="")}let y=g.filter(Boolean),M=` ${y.join(" ")} `,E=new Set(y);for(let x=0;x<y.length-1;x++)E.add(`${y[x]} ${y[x+1]}`);for(let[x,$]of Object.entries(H)){if(!(x.includes(" ")?M.includes(` ${x} `):E.has(x))||(x.includes(" ")?a.includes(` ${x} `):n.has(x)))continue;let Ye=Math.floor(Fe(x)*cn/10),Xe=Math.floor(Ye/$.length);for(let Ze of $)P(Ze,Xe,`~${x}`)}}for(let[g,y]of I){let M=O[g]?.topic;M&&T(M,y)}}for(let r of s)for(let u of Z(r.full))p.push({term:u,from:r.acronym,weight:Yt});for(let r of n){let u=_.vendors[r];if(u){T(u.topic,fe);for(let w of u.terms)for(let g of Z(w))p.push({term:g,from:r,weight:Xt})}}for(let[r,u]of Object.entries(_.topics))for(let w of u.terms){if(!m(w))continue;let g=!w.includes(" ")&&(he.has(w)||re.has(w));T(r,g?qe:an)}if(_.vectors&&je.length){let r=new Map;for(let u of t){if(u.length<3||He.has(u)||yn.has(u))continue;let w=vn(u);if(w)for(let g=0;g<_.vectors.dim;g++){let y=kn(w.row,g);y>=bn&&r.set(g,(r.get(g)??0)+y)}}for(let[u,w]of r){let g=_.vectors.topics[u];T(g,Math.round(Math.min(w,$e)*on/$e))}}for(let r of n){let u=_.synonyms[r];if(u)for(let w of u)for(let g of Z(w))p.push({term:g,from:r,weight:Zt})}let C=[...k.entries()].filter(([,r])=>r>=Ie),L=Math.max(0,...C.map(([,r])=>r)),F=L>0?C.map(([r,u])=>({id:r,score:Math.round(u/L*1e3)/1e3})).filter(r=>r.score>=Gt).sort((r,u)=>u.score-r.score||(r.id<u.id?-1:1)).slice(0,Bt):[];for(let r of F){let u=0;for(let w of _.topics[r.id]?.terms??[])for(let g of Z(w))i.has(g)||u>=Ut||(p.push({term:g,from:r.id,weight:Math.round(Qt*r.score*1e3)/1e3}),u+=1)}let D=new Map;for(let r of p){if(i.has(r.term))continue;let u=D.get(r.term);(!u||r.weight>u.weight)&&D.set(r.term,r)}let N=[...D.values()].sort((r,u)=>u.weight-r.weight||(r.term<u.term?-1:1)).slice(0,Jt),W=new Array(O.length).fill(0);for(let[r,u]of I){let w=r;for(;w!==void 0&&w>=0;){W[w]+=u;let g=O[w].parent;w=g>=0?g:void 0}}let q=r=>W[r]>=Ie,ve=[];for(let r=0;r<O.length;r++)q(r)&&(be[r].some(u=>q(u))||ve.push(r));let se=ve.map(r=>{let u=[];for(let y=r;y>=0&&(u.unshift(y),!(O[y].parent<0));y=O[y].parent);let w=new Set,g=y=>{for(let M of S.get(y)??[])w.add(M);for(let M of be[y]??[])g(M)};for(let y of u)for(let M of S.get(y)??[])w.add(M);return g(r),{path:O[r].path,levels:u.map(y=>({id:O[y].path.split("/").pop(),path:O[y].path,score:de(W[y]),terms:(O[y].terms??[]).slice(0,fn)})),score:de(W[r]),evidence:Math.round(W[r])/1e3,via:[...w].sort(),terms:(O[r].terms??[]).slice(0,un),files:De(r),standards:_n(r)}}).sort((r,u)=>u.evidence-r.evidence||(r.path<u.path?-1:1)).slice(0,ln),ke=[...A.values()].sort((r,u)=>u.score-r.score||(r.name<u.name?-1:1)),Ge=[...new Map(R.map(r=>[`${r.from}>${r.to}`,r])).values()].sort((r,u)=>r.from<u.from?-1:1),B=[];for(let r of ke)for(let u of r.files)B.includes(u)||B.push(u);for(let r of se)for(let u of r.files)B.includes(u)||B.push(u);let Q=[];for(let r of se)for(let u of r.standards)Q.some(w=>w.name===u.name)||Q.push(u);let oe=[];for(let r of Q.slice(0,ge))for(let u of r.categories)oe.includes(u)||oe.push(u);return{version:Ne,topics:F,expansions:N,taxonomy:se,vendors:ke,corrections:Ge,files:B.slice(0,gn),standards:Q.slice(0,ge),categories:oe}}}}function Nn(){let e=j();if(!e?.surfaces)return null;let t=e.surfaces;return{classify(n){let i=JSON.parse(t.classifyJson(JSON.stringify(n))),{serviceDependencies:s,...c}=i;return{inventory:c,serviceDependencies:s??[]}},search(n){return JSON.parse(t.searchJson(n))},get(n){return JSON.parse(t.getJson(n))},info(){return JSON.parse(t.catalogJson())}}}function In(){let e=j();if(!e?.modelTableJson)return null;let t=e.modelTableJson;return{table(){return JSON.parse(t())}}}export{In as createModelCatalog,Tn as createRelevanceProvider,Nn as createSurfaceCatalog,ue as createSymbolRanker};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibgrate/relevance",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.911.1",
|
|
4
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
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|