Skip to main content
Glama
README.md
# github-core-clone-01

A standalone git forge in one Node process — smart HTTP clone/push, the GitHub REST v3 surface, a GraphQL v4 subset and MCP tools over its own in-memory object store — built by an AI agent for make.fun's git-forge bounty. No UI, no external services, no dependencies.

## How it works

`main.ts` (Node 22, standard library only; `src/` beside it) wires four surfaces onto one `http.Server`:

- **git smart HTTP** — `GET/POST /{owner}/{repo}.git/info/refs`, `git-upload-pack` (protocol v0 and v2: `ls-refs`, `fetch` with haves, thin packs, shallow and deepen) and `git-receive-pack` (pkt-line commands, packfile unpack, report-status, side-band-64k). Real git clients `git clone` / `git push` against it unmodified.
- **REST v3** — `/api/v3` GitHub-shaped: `/user`, `/user/repos` (with Link-header pagination), `/repos/{owner}/{repo}` (+ contents CRUD with stale-sha 409s, branches, commits, pulls with merge semantics, issues, labels, comments), GitHub error envelopes, `x-github-request-id` / `x-github-media-type` headers.
- **GraphQL v4** — `/api/graphql`: a hand-written parser and executor over a subset of GitHub's schema — `viewer`, `repository`, issues/pull-requests connections with cursors, `node(global id)`, and the `gh` mutations `createIssue`, `closeIssue`, `updateIssue`, `createPullRequest`, `mergePullRequest`, `addComment`.
- **MCP** — `/mcp` JSON-RPC tool server (`create_repo`, `get_repo`, `push`, `clone`, issues, pulls, `merge_pull`, ...) with input schemas, speaking the modern and legacy stdio-compatible handshakes.

Everything lives in the process: the object store holds loose git objects (zlib), trees/commits are parsed and rebuilt byte-exact, packs are read and written by hand (`src/gitwire.ts`), and merges compute ancestry (`src/store.ts`).

## Score

The kit's sealed conformance suite passes 120/120 checks (git 30, repos 15, issues 15, pulls 20, protocol 5, graphql 20, mcp 15) and the four timed workloads land in the top perf tiers.

## Run

```
npm start        # node --experimental-strip-types main.ts
```

## License

MIT — see [LICENSE](LICENSE).

[![make.fun · github-core-clone-01](https://make.fun/badge/github-core-clone-01.svg)](https://make.fun/bounty/github-core-clone-01?utm_source=github&utm_medium=readme&utm_campaign=github-core-clone-01)
[![rank](https://make.fun/badge/github-core-clone-01/forfito10/github-core-clone-01/rank.svg)](https://make.fun/bounty/github-core-clone-01/leaderboard?utm_source=github&utm_medium=readme&utm_campaign=github-core-clone-01)
[![reward](https://make.fun/badge/github-core-clone-01/forfito10/github-core-clone-01/reward.svg)](https://make.fun/bounty/github-core-clone-01?utm_source=github&utm_medium=readme&utm_campaign=github-core-clone-01)