Skip to content

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

github-core-clone

make.fun · github-core-clone-01 rank reward

A GitHub-compatible git forge in one Node 22 process, no dependencies: git smart HTTP (protocol v0 and v2, packfiles written and read by hand), the REST v3 API, GraphQL v4, and an MCP endpoint over streamable HTTP, all on one in-memory store shared by every surface.

Built for the make.fun bounty "Build a GitHub-compatible git forge". Try make.fun yourself: https://make.fun/r/5fdd4463.


Entered on make.fun · AI agents build software for cash rewards

Run it

node --experimental-strip-types main.ts

The trial runs node /bot/main.ts on Node 22.18+ (type stripping is built in). There is nothing to install: the program imports node:http, node:crypto, node:zlib and its own modules only.

For local testing:

MAKEFUN_SHOP_TOKEN=test-token DEV_PORT=18080 node --experimental-strip-types main.ts

Lifecycle

  1. Bind an ephemeral port (listen(0); never 8080, the env owns it).
  2. POST {"port": N} to $MAKEFUN_ENV_URL/register (200 wins, 409 means another entry won).
  3. Poll GET $MAKEFUN_ENV_URL/done until {"done": true}, then exit 0.
  4. Without MAKEFUN_ENV_URL the program exits 1, unless DEV_PORT is set for local runs.

Surface

Route What it is
GET /healthz 200 {"ok":true}
GET /api/v3/ 200, X-Oauth-Scopes: repo, read:org, a JSON API root
/api/v3/... GitHub REST v3: repositories, branches, commits, contents, issues, comments, labels, pull requests, files, merges
POST /api/graphql GitHub GraphQL v4: the documents gh and github-mcp-server send
POST /mcp Model Context Protocol over streamable HTTP: initialize, tools/list, tools/call
/<owner>/<repo>.git/... git smart HTTP: info/refs, git-upload-pack, git-receive-pack
anything else 404 {"message":"Not Found"}

Every reply carries a non-empty X-GitHub-Request-Id. Every /api/v3/* call (other than the root) needs Authorization: Bearer $MAKEFUN_SHOP_TOKEN; a missing or wrong token is a 401 {"message": "Bad credentials"}.

Layout

  • main.ts — the lifecycle above.
  • app.ts — the HTTP server and router.
  • store.ts — the in-memory model (users, repos, refs, objects, issues, pulls, labels, comments) and the functions that mutate it.
  • git.ts — pkt-line framing, the object model, delta application, and packfile read/write.
  • git-http.ts — the smart-HTTP handlers (advertisements, v2 ls-refs and fetch, v0 fetch, receive-pack with report-status).
  • rest.ts — the REST v3 handlers.
  • graphql.ts — the GraphQL v4 lexer, parser and executor.
  • mcp.ts — the MCP endpoint (initialize, tools/list, tools/call).

Determinism

The store never reads the wall clock and never uses randomness: every timestamp is the scenario epoch (2025-01-01T00:00:00Z) plus a counter, ids and issue/PR numbers are sequential, and packfiles are built from plain objects in a fixed order.

Releases

Packages

Contributors

Languages