Package Exports
- gitx.do
Readme
gitx.do
Git on Cloudflare Durable Objects - A complete Git reimplementation for the edge.
Features
- Pack Files - Full Git packfile v2/v3 support with delta compression
- Wire Protocol - Smart HTTP protocol implementation for fetch/push operations
- MCP Tools - Model Context Protocol integration for AI-assisted git operations
- Tiered Storage - Hot/warm/cold storage tiers with automatic promotion
- Hot: Durable Object SQLite (low latency)
- Warm: R2 object storage (packed objects)
- Cold: Analytics/Parquet (cold storage)
Installation
npm install gitx.doQuick Start
Pack Index Operations
import { parsePackIndex, createPackIndex, lookupObject } from 'gitx.do/pack'
// Parse an existing pack index
const index = parsePackIndex(indexData)
console.log(`Pack contains ${index.objectCount} objects`)
// Look up an object by SHA
const entry = lookupObject(index, 'abc123...')
if (entry) {
console.log(`Object at offset ${entry.offset}`)
}
// Create a new pack index
const newIndex = createPackIndex({ packData })Smart HTTP Protocol
import { handleInfoRefs, handleUploadPack, handleReceivePack } from 'gitx.do/wire/smart-http'
// Handle ref discovery
const response = await handleInfoRefs(request, repository, {
sideBand64k: true,
ofsDelta: true
})
// Handle fetch
const packResponse = await handleUploadPack(request, repository)
// Handle push
const pushResponse = await handleReceivePack(request, repository)MCP Tools
import { gitTools, invokeTool, registerTool } from 'gitx.do/mcp/tools'
// List available git tools
console.log(gitTools.map(t => t.name))
// ['git_status', 'git_log', 'git_diff', 'git_commit', ...]
// Invoke a tool
const result = await invokeTool('git_status', { path: '/repo', short: true })
// Register a custom tool
registerTool({
name: 'my_tool',
description: 'Custom git operation',
inputSchema: { type: 'object', properties: {} },
handler: async (params) => ({ content: [{ type: 'text', text: 'Done' }] })
})Tiered Storage
import { TieredReader } from 'gitx.do/tiered/read-path'
const reader = new TieredReader(hotBackend, warmBackend, coldBackend, {
hot: { enabled: true, maxSize: 1024 * 1024 },
warm: { enabled: true },
cold: { enabled: true },
promotionPolicy: 'aggressive'
})
// Read with automatic tier fallback and promotion
const result = await reader.read(sha)
console.log(`Found in ${result.tier} tier, latency: ${result.latencyMs}ms`)R2 Pack Storage
import { R2PackStorage } from 'gitx.do/storage/r2-pack'
const storage = new R2PackStorage({ bucket, prefix: 'repos/my-repo/' })
// Upload a packfile
const result = await storage.uploadPackfile(packData, indexData)
// Download with verification
const pack = await storage.downloadPackfile(packId, { verify: true })
// Use multi-pack index for cross-pack lookups
await storage.rebuildMultiPackIndex()
const midx = await storage.getMultiPackIndex()API Overview
Pack Module (gitx.do/pack)
parsePackIndex(data)- Parse a pack index filecreatePackIndex(options)- Create a new pack indexlookupObject(index, sha)- Find object by SHA in indexverifyPackIndex(data)- Verify index integritycalculateCRC32(data)- Compute CRC32 checksum
Wire Protocol (gitx.do/wire)
handleInfoRefs()- Ref discovery endpointhandleUploadPack()- Fetch data transferhandleReceivePack()- Push data transferformatRefAdvertisement()- Format ref listparseCapabilities()- Parse protocol capabilities
MCP Tools (gitx.do/mcp)
gitTools- Array of available git tool definitionsinvokeTool(name, params)- Execute a tool by nameregisterTool(tool)- Add a custom toolvalidateToolInput(tool, params)- Validate parameters
Tiered Storage (gitx.do/tiered)
TieredReader- Multi-tier read path with promotionStoredObject- Object representationTieredStorageConfig- Configuration options
R2 Storage (gitx.do/storage)
R2PackStorage- Packfile management for R2uploadPackfile()- Store pack and indexdownloadPackfile()- Retrieve with optional verificationcreateMultiPackIndex()- Build cross-pack index
License
MIT