diff --git a/src/cli/commands/corps/overview.ts b/src/cli/commands/corps/overview.ts index 8b0e3c4..63e031e 100644 --- a/src/cli/commands/corps/overview.ts +++ b/src/cli/commands/corps/overview.ts @@ -5,8 +5,11 @@ import { saveGlobalConfig, updateCorpConfig } from "../../../core/config/loader.js"; -import { filterCorpsFuzzy } from "../../../core/corp-search/fuzzy.js"; -import { sortCorpsByUsageAndRecency } from "../../../core/stats/usage-tracker.js"; +import { filterCorpsFuzzy } from "../../../core/corp-search/rank.js"; +import { + getRecentCorpUsageScores, + sortCorpsByUsageAndRecency +} from "../../../core/stats/usage-tracker.js"; import type { CorpEnvironment } from "../../../core/config/types.js"; import { selectCorp } from "../../helpers.js"; import { confirmationRequired, usageError } from "../../errors.js"; @@ -48,7 +51,10 @@ export async function handleCorpOverview( filtered = filtered.filter((item) => (item.environment ?? "production").toLowerCase() === envFilter); } if (rawQuery) { - filtered = filterCorpsFuzzy(filtered, rawQuery, { strict: isStrict }); + // Equal-relevance results are ordered by recent usage so frequent corps + // surface on ties without ever beating a better match. + const usageScores = getRecentCorpUsageScores(filtered.map((item) => item.id)); + filtered = filterCorpsFuzzy(filtered, rawQuery, { strict: isStrict }, usageScores); } if (allCorps.length === 0) {