github-search-cli 0.7.0 → 0.8.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/README.md +163 -183
- package/bin/ghfind.js +55 -0
- package/completions/{search-cli.bash → ghfind.bash} +4 -4
- package/completions/ghfind.fish +19 -0
- package/completions/{search-cli.zsh → ghfind.zsh} +4 -4
- package/demo.svg +65 -65
- package/package.json +20 -9
- package/src/bookmarks.ts +2 -2
- package/src/cli.ts +32 -45
- package/src/compare.ts +1 -1
- package/src/config.ts +8 -8
- package/src/deepdive.ts +4 -10
- package/src/errors.ts +1 -4
- package/src/explore.ts +0 -1
- package/src/export.ts +2 -3
- package/src/help.ts +112 -120
- package/src/history.ts +2 -2
- package/src/init.ts +6 -6
- package/src/notifications.ts +2 -6
- package/src/open-url.ts +16 -17
- package/src/output.ts +2 -9
- package/src/pipe.ts +2 -8
- package/src/saved-searches.ts +2 -2
- package/src/search.ts +555 -0
- package/src/session.ts +4 -5
- package/src/share.ts +27 -22
- package/src/trending.ts +10 -15
- package/src/tui.ts +408 -261
- package/src/types.ts +3 -11
- package/src/watch.ts +3 -6
- package/vendor/bun.exe +0 -0
- package/bin/search-cli.js +0 -17
- package/completions/search-cli.fish +0 -19
- package/src/cache.ts +0 -64
- package/src/normalizer.ts +0 -66
- package/src/provider.ts +0 -165
- package/src/query.ts +0 -249
- package/src/ranking.ts +0 -57
package/src/ranking.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ranking layer: order normalized {@link Repo} results deterministically.
|
|
3
|
-
*
|
|
4
|
-
* All strategies are pure functions of the repo data plus a stable tie-breaker
|
|
5
|
-
* (repo id) so that identical inputs always produce identical output. A future
|
|
6
|
-
* AI reranker can be added as an additional strategy or as a post-step without
|
|
7
|
-
* changing the rest of the pipeline.
|
|
8
|
-
*/
|
|
9
|
-
import type { Repo, SortStrategy } from "./types.ts";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Rank repos according to the chosen strategy.
|
|
13
|
-
* The sort is stable and deterministic: when two repos compare equal on the
|
|
14
|
-
* primary key, we fall back to descending stars, then descending id.
|
|
15
|
-
*/
|
|
16
|
-
export function rankRepos(repos: Repo[], strategy: SortStrategy): Repo[] {
|
|
17
|
-
const copy = [...repos];
|
|
18
|
-
switch (strategy) {
|
|
19
|
-
case "stars":
|
|
20
|
-
copy.sort(byKey((r) => r.stars));
|
|
21
|
-
break;
|
|
22
|
-
case "forks":
|
|
23
|
-
copy.sort(byKey((r) => r.forks));
|
|
24
|
-
break;
|
|
25
|
-
case "updated":
|
|
26
|
-
copy.sort(byKey((r) => Date.parse(r.updatedAt)));
|
|
27
|
-
break;
|
|
28
|
-
case "best-match":
|
|
29
|
-
default:
|
|
30
|
-
// GitHub already returns best-match order; preserve it unchanged.
|
|
31
|
-
// Re-sorting by score would be redundant for first-page results and
|
|
32
|
-
// misleading for paginated (page 2 repos would intermix with page 1).
|
|
33
|
-
// ponytail: if deterministic output is needed, sort by id:
|
|
34
|
-
// copy.sort((a, b) => a.id - b.id);
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
return copy;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Comparator factory: descending by `key`, then descending stars, then
|
|
41
|
-
* ascending id (stable, deterministic tie-break). */
|
|
42
|
-
function byKey(key: (r: Repo) => number): (a: Repo, b: Repo) => number {
|
|
43
|
-
return (a, b) => key(b) - key(a) || b.stars - a.stars || a.id - b.id;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* A simple, explainable composite score used for the (optional) "best" blend.
|
|
48
|
-
* Not used by default but available for an AI/rerank layer later.
|
|
49
|
-
* Range is roughly 0..1 after normalization by the caller.
|
|
50
|
-
*/
|
|
51
|
-
export function compositeScore(r: Repo): number {
|
|
52
|
-
// Log-scaled stars + recency bonus. Deterministic and transparent.
|
|
53
|
-
const starScore = Math.log10(r.stars + 1);
|
|
54
|
-
const recencyMs = Date.now() - Date.parse(r.pushedAt);
|
|
55
|
-
const recencyScore = Math.max(0, 1 - recencyMs / (1000 * 60 * 60 * 24 * 365));
|
|
56
|
-
return starScore * 0.7 + recencyScore * 0.3;
|
|
57
|
-
}
|