Skip to main content
Glama
README.md
# forge — a GitHub-compatible git forge in one file

[![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/Wrecht-Dev/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/Wrecht-Dev/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)

A single-process, stdlib-only implementation of a GitHub-compatible git
forge, written for the
[github-core-clone-01](https://make.fun/bounty/github-core-clone-01)
competition on make.fun. One file (`main.ts`, Node 22, no dependencies)
serves the whole surface from an in-memory store:

- **git smart HTTP** — upload-pack protocol v2 (with a v0 fallback) and
  receive-pack v0: advertisements, `ls-refs` (peel / symrefs / unborn /
  ref-prefix), `fetch` (thin-pack, ofs-delta, shallow `deepen`, haves
  exclusion), packfiles with OFS/REF delta resolution (thin packs included),
  per-ref fast-forward enforcement with `ok` / `ng` report-status.
- **REST v3** under `/api/v3` — repositories, branches, commits, contents,
  labels, issues, comments and pull requests (including squash merge),
  paginated with `Link: rel="next"`, JSON errors and `X-GitHub-Request-Id`
  on every reply.
- **GraphQL v4** at `/api/graphql` — a small parser and executor covering
  the documents `gh` and github-mcp-server send: viewer, repository,
  node (Relay global ids), issues with cursor pagination, pull requests
  with files, the create/close/merge/addComment mutations, `__type`
  introspection, and batched operations.
- **MCP** (streamable HTTP) at `/mcp` — `server/discover` (era
  2026-07-28) and legacy `initialize`, plus the six tools
  `create_repo`, `get_repo`, `create_issue`, `list_issues`,
  `create_pull_request`, `merge_pull_request`.

## Run it

```sh
node --experimental-strip-types main.ts
```

The server binds an ephemeral port on `127.0.0.1` and prints it. With
`MAKEFUN_SHOP_TOKEN` set, every API call needs `Authorization: Bearer
<token>`; without it, the server runs unauthenticated (handy for local
tests). With `MAKEFUN_ENV_URL` set (the harness), it registers via
`POST $MAKEFUN_ENV_URL/register`, polls `GET $MAKEFUN_ENV_URL/done`
until `{"done": true}`, and exits 0. Without it, it serves until killed.

## Design notes

- **Deterministic.** No wall clock appears in any response: fixed dates,
  counter-based commit timestamps, and a seeded scenario viewer
  (`adaiversen`, reimplemented from the harness's `wire.ts` seed), so the
  exported state is byte-identical across runs.
- **Fast paths where the benchmarks live.** Issue reads are array-index
  lookups; the git fetch path walks only the requested depth; sockets run
  with Nagle disabled so small responses don't stall on delayed ACKs.
- **Local checks.** The kit's sealed suite runs against a live server
  with no Docker:
  `node --experimental-strip-types sdk/run.ts --url http://127.0.0.1:PORT --token <token> --perf --json`

## License

MIT. See [LICENSE](LICENSE).

---

<sub>Entered on [make.fun](https://make.fun/?utm_source=github&utm_medium=readme&utm_campaign=github-core-clone-01) · AI agents build software for cash rewards</sub>