github-search-cli 9.5.1 → 9.7.0
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/CHANGELOG.md +95 -0
- package/README.md +77 -27
- package/completions/ghfind.bash +5 -1
- package/completions/ghfind.fish +2 -1
- package/completions/ghfind.zsh +5 -0
- package/dist/cli.js +1117 -103
- package/package.json +1 -1
- package/release-notes/9.6.0.md +67 -0
- package/release-notes/9.7.0.md +53 -0
- package/scripts/brew.rb +31 -10
- package/scripts/install.sh +118 -0
- package/src/agent-skill.ts +141 -0
- package/src/cli.ts +176 -4
- package/src/compare.ts +76 -1
- package/src/deepdive.ts +195 -23
- package/src/doctor.ts +4 -0
- package/src/mcp-server.ts +865 -0
- package/src/search.ts +88 -5
- package/src/types.ts +2 -0
package/src/search.ts
CHANGED
|
@@ -519,6 +519,91 @@ function appendPage(url: string, page: number, perPage: number): string {
|
|
|
519
519
|
|
|
520
520
|
const TRENDING_URL = "https://github.com/trending";
|
|
521
521
|
|
|
522
|
+
/**
|
|
523
|
+
* Languages github.com/trending accepts as a `?language=` filter (path-slug
|
|
524
|
+
* form, lowercase). The MCP `ghfind_trending` tool validates against this
|
|
525
|
+
* list instead of round-tripping an invalid language through a scrape.
|
|
526
|
+
*/
|
|
527
|
+
export const TRENDING_LANGUAGES: ReadonlySet<string> = new Set([
|
|
528
|
+
"c",
|
|
529
|
+
"c#",
|
|
530
|
+
"c++",
|
|
531
|
+
"clojure",
|
|
532
|
+
"crystal",
|
|
533
|
+
"css",
|
|
534
|
+
"dart",
|
|
535
|
+
"dockerfile",
|
|
536
|
+
"elixir",
|
|
537
|
+
"go",
|
|
538
|
+
"haskell",
|
|
539
|
+
"html",
|
|
540
|
+
"java",
|
|
541
|
+
"javascript",
|
|
542
|
+
"jupyter-notebook",
|
|
543
|
+
"kotlin",
|
|
544
|
+
"lua",
|
|
545
|
+
"objective-c",
|
|
546
|
+
"ocaml",
|
|
547
|
+
"perl",
|
|
548
|
+
"php",
|
|
549
|
+
"powershell",
|
|
550
|
+
"python",
|
|
551
|
+
"r",
|
|
552
|
+
"ruby",
|
|
553
|
+
"rust",
|
|
554
|
+
"scala",
|
|
555
|
+
"shell",
|
|
556
|
+
"solidity",
|
|
557
|
+
"svelte",
|
|
558
|
+
"swift",
|
|
559
|
+
"typescript",
|
|
560
|
+
"vue",
|
|
561
|
+
"zig",
|
|
562
|
+
]);
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Normalize a user-supplied language to the slug form github.com/trending
|
|
566
|
+
* uses: lowercase, whitespace runs collapsed to dashes ("Jupyter Notebook"
|
|
567
|
+
* → "jupyter-notebook").
|
|
568
|
+
*/
|
|
569
|
+
export function trendingLanguageSlug(language: string): string {
|
|
570
|
+
return language.trim().toLowerCase().replace(/\s+/g, "-");
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Validate a user-supplied trending language and return its slug, or null if
|
|
575
|
+
* empty. Throws with a user-facing suggestion list for unknown languages.
|
|
576
|
+
* Shared by the MCP trending tool and the CLI trending filter.
|
|
577
|
+
*/
|
|
578
|
+
export function resolveTrendingLanguage(
|
|
579
|
+
language: string | undefined | null,
|
|
580
|
+
): string | undefined {
|
|
581
|
+
const trimmed = typeof language === "string" ? language.trim() : "";
|
|
582
|
+
if (!trimmed) return undefined;
|
|
583
|
+
const slug = trendingLanguageSlug(trimmed);
|
|
584
|
+
if (!TRENDING_LANGUAGES.has(slug)) {
|
|
585
|
+
throw new Error(
|
|
586
|
+
`"${trimmed}" is not a trending language filter. Try one of: rust, python, typescript, javascript, go, zig.`,
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
return slug;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/** Build the github.com/trending URL for a period + optional language filter. */
|
|
593
|
+
export function buildTrendingUrl(
|
|
594
|
+
since: "daily" | "weekly" | "monthly",
|
|
595
|
+
language?: string,
|
|
596
|
+
): string {
|
|
597
|
+
const params = new URLSearchParams();
|
|
598
|
+
if (since !== "daily") params.set("since", since);
|
|
599
|
+
if (language) {
|
|
600
|
+
const slug = trendingLanguageSlug(language);
|
|
601
|
+
if (TRENDING_LANGUAGES.has(slug)) params.set("language", slug);
|
|
602
|
+
}
|
|
603
|
+
const qs = params.toString();
|
|
604
|
+
return qs ? `${TRENDING_URL}?${qs}` : TRENDING_URL;
|
|
605
|
+
}
|
|
606
|
+
|
|
522
607
|
function trendingRepoToRepo(r: RawTrendingRepo): Repo {
|
|
523
608
|
return {
|
|
524
609
|
id: 0,
|
|
@@ -540,9 +625,7 @@ function trendingRepoToRepo(r: RawTrendingRepo): Repo {
|
|
|
540
625
|
pushedAt: "",
|
|
541
626
|
score: r.starsToday,
|
|
542
627
|
};
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/**
|
|
628
|
+
} /**
|
|
546
629
|
* Trending adapter — scrapes github.com/trending HTML and returns SearchResponse.
|
|
547
630
|
*/
|
|
548
631
|
export class TrendingAdapter implements SearchAdapter {
|
|
@@ -558,8 +641,7 @@ export class TrendingAdapter implements SearchAdapter {
|
|
|
558
641
|
options: SearchOptions,
|
|
559
642
|
): Promise<SearchResponse> {
|
|
560
643
|
const since = options.trendingSince ?? "daily";
|
|
561
|
-
const url =
|
|
562
|
-
since === "daily" ? TRENDING_URL : `${TRENDING_URL}?since=${since}`;
|
|
644
|
+
const url = buildTrendingUrl(since, options.trendingLanguage);
|
|
563
645
|
let res: Response;
|
|
564
646
|
try {
|
|
565
647
|
res = await fetch(url, { headers: { "User-Agent": "ghfind" } });
|
|
@@ -639,6 +721,7 @@ export class SearchModule implements SearchProvider {
|
|
|
639
721
|
String(options.limit),
|
|
640
722
|
String(options.page ?? 1),
|
|
641
723
|
options.trendingSince ?? "none",
|
|
724
|
+
options.trendingLanguage ?? "none",
|
|
642
725
|
);
|
|
643
726
|
const cached = SearchModule.cache.get(cacheKey);
|
|
644
727
|
if (cached) {
|
package/src/types.ts
CHANGED
|
@@ -73,6 +73,8 @@ export interface SearchOptions {
|
|
|
73
73
|
page?: number;
|
|
74
74
|
/** Trending period: daily|weekly|monthly. Used by TrendingAdapter. */
|
|
75
75
|
trendingSince?: "daily" | "weekly" | "monthly";
|
|
76
|
+
/** Trending language filter (e.g. "rust", "python"). Used by TrendingAdapter. */
|
|
77
|
+
trendingLanguage?: string;
|
|
76
78
|
/** Verbose logging (outgoing query, errors, rate limits). */
|
|
77
79
|
verbose: boolean;
|
|
78
80
|
}
|