import type { AssetCatalogEntry, RecommendationPolicy } from "../types.js"; import type { RecommendationHost } from "./hosts.js"; import type { CandidateRecommendation, CandidateRecommendationBase, DemandContext, PolicySearchContext } from "./model.js"; /** * Precomputes all policy-derived Set lookups so they are built once per host * run rather than once per candidate, eliminating the O(n × policy) hot path. */ export declare function buildPolicySearchContext(policy: RecommendationPolicy): PolicySearchContext; /** * Provides compute entry preselection score for the lifecycle pipeline. */ export declare function computeEntryPreselectionScore(entry: AssetCatalogEntry): number; /** * Precomputes host-independent recommendation analysis for one catalog entry so * large report builds do not repeat the same demand/search work for every host. * * @param synonymLookup - Optional precomputed alias→canonical map built by * `buildSynonymLookup`. Callers that process many entries should build this * once and pass it here; omitting it causes a per-entry rebuild. */ export declare function buildCandidateRecommendationBase(entry: AssetCatalogEntry, demandContext: DemandContext, policy: RecommendationPolicy, policyContext?: PolicySearchContext, synonymLookup?: Map): CandidateRecommendationBase | null; /** * Builds candidate recommendation from precomputed entry analysis plus one host * specific scoring/suppression pass. */ export declare function buildCandidateRecommendation(base: CandidateRecommendationBase, host: RecommendationHost, demandContext: DemandContext, policy: RecommendationPolicy, enforcedConcerns?: ReadonlySet): CandidateRecommendation | null; /** * Returns whether the asset's ecosystem is plausibly compatible with the * workspace's detected package managers AND languages (#444, review): a * package-registry asset whose registry maps to a package-manager family the * workspace does NOT use cannot receive exact-stack credit (e.g. a Rust crate * from cargo-registry in an npm workspace), and a non-package-registry asset * published under an unambiguous source-family language the workspace does * NOT use is equally incompatible (e.g. an `official-index:WordPress` skill * in a TypeScript workspace). Ecosystem-agnostic sources pass. */ declare function computeAssetEcosystemCompat(entry: AssetCatalogEntry, demandContext: DemandContext, demandLanguageTerms: ReadonlySet): boolean; /** * Ordered substring scan from source-id → package-manager family. * * Because a single source ID may match multiple substrings (e.g. an ID * containing both "pnpm" and "npm"), we cannot index by the source ID * directly. Instead we keep the ordered array for correctness and iterate it * The array has ~25 entries — a single .find() pass is negligible. * relative to catalog size and far cheaper than the previous .find() on every * catalog entry. */ /** * Returns the penalty to apply when an asset's source registry belongs to a * package-manager ecosystem that the workspace does not use. * * No penalty is applied when: * - The source is not a package registry (repo, docs, local-* kinds are * ecosystem-agnostic and should not be penalised). * - The workspace has no package-manager signals (brand-new workspace or * language-only project — be conservative and don't penalise). * - The source's ecosystem cannot be mapped (unknown / internal registries). * - The workspace uses the matching package manager. * * When the workspace has package-manager signals but none of them match the * registry's ecosystem, a **total mismatch** is confirmed and 2× the base * penalty is applied. This prevents wrong-language package-registry entries * from surviving ranking when they happen to share keyword tokens with the * workspace (e.g. PHP Composer packages named after JavaScript tools in an * npm workspace). The doubled penalty ensures that even a demand-cap-saturated * PHP entry (score ≈ 44 before penalty) drops to a negative total while a * correctly-ecosystemed npm entry is unaffected. */ declare function computeEcosystemMismatchPenalty(entry: AssetCatalogEntry, demandContext: DemandContext, demandLanguageTerms: ReadonlySet, penalty: number): number; /** * Exposes narrow candidates internals for focused ecosystem-penalty tests. */ export declare const candidatesInternals: { computeEcosystemMismatchPenalty: typeof computeEcosystemMismatchPenalty; computeAssetEcosystemCompat: typeof computeAssetEcosystemCompat; KNOWN_SOURCE_FAMILY_LANGUAGES: Map; }; export {};