Skip to main content
Glama
github-core-clone-01

github-core-clone-01

by rudiuciha50
README.md
# github-core-clone-01

![make.fun](https://make.fun/badge/github-core-clone-01.svg)
![rank](https://make.fun/badge/github-core-clone-01/rudiuciha50/github-core-clone-01/rank.svg)
![reward](https://make.fun/badge/github-core-clone-01/rudiuciha50/github-core-clone-01/reward.svg)

A standalone GitHub-compatible git forge built for the [make.fun github-core-clone-01 bounty](https://make.fun/bounty/github-core-clone-01).

Serves four surfaces from one Node.js process, using only the standard library:

1. **Git smart HTTP** — clone/fetch (upload-pack v0+v2) and push (receive-pack v0) with native pkt-line, packfile, and object hashing implementation (no git binary)
2. **REST v3 API** — repositories, issues, pull requests, labels, comments, branches, commits, contents, refs
3. **GraphQL v4** — viewer, repository, issues, pull requests, introspection, mutations (createIssue, closeIssue, createPullRequest, mergePullRequest, addComment)
4. **MCP** — Model Context Protocol over Streamable HTTP with 6+ tools (create_repo, get_repo, create_issue, list_issues, create_pull_request, merge_pull_request)

## Run

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

Requires Node 22.18+. No dependencies, no install step.

## Architecture

- `app.ts` — the forge server (all four surfaces, in-memory store, native git protocol)
- `main.ts` — the entry lifecycle (binds ephemeral port, registers with env, polls for done)

## Features

### Git Smart HTTP
- Native pkt-line codec (flush, delim, response-end, data)
- Protocol v2 (version 2, ls-refs, fetch with shallow) and v0 (want/have/done, side-band-64k)
- Receive-pack with report-status, side-band-64k, delete-refs
- Fast-forward enforcement (non-FF pushes are rejected per-ref)
- SHA-1 object hashing, packfile read/write (plain objects)
- In-memory object store with reachability walk

### REST v3
- Repositories: list (paginated), create, get, patch, delete
- Issues: list (filtered/sorted), create, get, patch (close), comments
- Pull requests: list, create, get, files, merge (squash)
- Contents: create, get (file+directory), delete, update (stale-sha 409)
- Labels: create
- Branches, commits, refs
- Auth: Bearer token, 401 without, 404 for foreign repos

### GraphQL v4
- Query: viewer, repository, issue, issues, pullRequest, pullRequests
- Introspection: __type for Issue, PullRequest, Repository, SearchType, enums
- Mutations: createIssue, closeIssue, createPullRequest, mergePullRequest, addComment
- Node query with inline fragments
- Batch support (multiple operations in one request)

### MCP
- JSON-RPC 2.0 over Streamable HTTP
- server/discover (revision 2026-07-28), initialize (legacy 2025-11-25)
- tools/list with 6+ tools, each with inputSchema
- tools/call acting on the same in-memory store as REST
- Tool name aliasing (server prefix, case-insensitive suffix matching)
- Error handling: -32700 parse error, -32601/-32602 unknown tool/params

## License

MIT