@nothumanwork/wit-sdk
v0.1.0
Published
Zero-dependency TypeScript client for the wit URL API (read GitHub repositories without cloning).
Maintainers
Readme
@nothumanwork/wit-sdk (TypeScript)
Zero-dependency client for the wit URL API:
read any GitHub repository without cloning, with token budgets you control.
Works anywhere fetch exists (Node 18+, Deno, Bun, Workers, browsers).
import { WitClient } from "@nothumanwork/wit-sdk";
const wit = new WitClient({ token: process.env.GITHUB_TOKEN });
const repo = wit.repo("ratatui/ratatui"); // or wit.repo("o/r", "v0.29.0")
const stats = await repo.stats(); // size / tokens / languages, no blob reads
const files = await repo.rgFiles("impl Widget for", { glob: "*.rs" });
const outline = await repo.outline(files.files[0].path); // symbols with line ranges
const impl = outline.symbols.find((s) => s.kind === "impl");
const code = await repo.cat(files.files[0].path, { lines: [impl.line, impl.end_line] });
console.log(code.commit, code.text); // provenance travels with every resultHigher-level helpers that chain calls for you:
repo.readSymbol(path, name, { kind, padding })→ outline + cat range (2 requests).repo.context(pattern, { window, maxSnippets, glob })→ rg + one cat window per file.wit.search({ query: "terminal ui", lang: "rust" })→ findowner/repofirst.repo.text("tree", { path: "src", l: 1 })→ the CLI-identical plaintext for any verb.
Errors are WitError with status, code, retryAfter and isRateLimited;
pass retries: 2 to have 429s retried while honouring retry-after.
Develop
cd sdk/typescript
npm run check # tsc --noEmit + node --test (Node 22+ strips types natively)
npm run build # emits dist/ for publishingRelease
.github/workflows/publish-sdk.yml publishes to npm on every push to main
that touches sdk/typescript/ when package.json's version is not on the
registry yet (it uses the repository's NPM_TOKEN secret). To release:
bump version, merge, done. Pushes that leave the version unchanged run the
checks and skip the publish. workflow_dispatch with dry_run rehearses a
release without publishing.
