Skip to main content

Crate stargaze

Crate stargaze 

Source

Structs§

ApiResponse
Result of routing one HTTP request — used by the serve --api path AND by the unit tests that drive routing without a real TCP socket.
GhClient
Paginating client for the GitHub REST API.
IndexedRepo
Precomputed search-friendly view of a Repo.
Repo
A GitHub repository as we store and search it.
RepoIndex
A searchable, rayon-ready corpus of starred repos with an LRU query cache.
SearchHit
A search result: the matching repo plus its score (higher is better).
SearchKey
Filter-free search parameters used as the LRU cache key.

Constants§

MCP_PROTOCOL_VERSION
Protocol version we advertise during initialize. Matches the value used by Claude Desktop and other common MCP clients as of 2026-04.
META
Key → string metadata (last-sync timestamp, last-sync count, etc).
README_MAX_BYTES
Cap README text so a few oversized files can’t blow up the redb store or the LRU cache. 64 KiB is enough to capture the “what is this repo” lead + headings of nearly every README on GitHub.
REPOS
owner/name → JSON-serialized Repo bytes.
USER_AGENT
Agent string used in every GitHub API request — lets them rate-limit by name.

Functions§

cmd_list
cmd_readmes
cmd_search
cmd_show
cmd_stats
cmd_sync
count_repos
Count cached repos. Matches load_all(db)?.len() but avoids deserialization.
default_db_path
Default data-file location resolved via directories::ProjectDirs. Creates the parent directory on first call.
fetch_readmes_parallel
Fetch READMEs for every repo in repos in parallel using async HTTP requests.
handle_mcp_request
Dispatch a single JSON-RPC request. Returns None for notifications (which must not elicit a response) and Some(value) for any method call — including errors, which are reported via JSON-RPC error.
load_all
Read every cached repo. Returns an empty vec if the table doesn’t exist yet.
load_one
Read one cached repo by owner/name. Ok(None) if not found.
open_db
Open (or create) the redb database at path.
parse_link_next
Extract the URL marked rel="next" from a GitHub Link header, if any.
parse_query_string
Parse ?query=foo&limit=20&lang=Rust style form-encoded query strings. Pure Rust — no url crate. Handles %-escapes via a tiny decoder.
read_meta
Read a metadata string by key. Ok(None) if absent.
regenerate_embeddings
Regenerate embeddings for all repos that don’t have one. Returns (updated_count, skipped_count, error_count).
resolve_token
Resolve a GitHub personal access token from (in order):
retain_repos
Delete cached repos whose keys are NOT in keep. Returns number removed. Used by sync to evict unstarred repos.
route_api
Pure routing function — deterministic, no I/O beyond the db + index handles already owned by the caller. Testable without a TCP socket.
run_api_server
Run the HTTP API server until Ctrl-C. Bind address defaults to 127.0.0.1:7879. Optional api_key gates every request — when set, clients must pass Authorization: Bearer <key>. When unset, the server is fully open (fine for localhost).
run_mcp_stdio
Run an MCP stdio server that exposes a read-only view over the cached stars. Blocks on stdin until EOF, writing JSON-RPC responses to stdout.
truncate
Truncate a string to n chars (not bytes), appending if cut. Safe for multi-byte UTF-8 input.
upsert_repos
Upsert a slice of repos in a single write transaction and record the sync timestamp + count in the meta table.