repome

Git SDK

Use repome as a git SDK — write files and commit from any JavaScript runtime with no clone required.

@repome/sdk exposes git as a typed async API. Your agent writes files directly from memory and commits them through the API — no local clone, no git binary, no credential plumbing.

Install

npm install @repome/sdk

Open a repo

import { repome } from '@repome/sdk'

const git = await repome('my-repo', {
  token: process.env.REPOME_API_KEY,
})

Repo names are bare — the server resolves them against your active organization. The repo is created automatically if it does not exist. The token is any rpme_ API key with repos:write scope — generate one with repome keys create <name> --scope repos:read --scope repos:write.

For an anonymous, no-account repo, use repome.ephemeral(). The returned GitRepo exposes remote and expiresAt for those cases.

const git = await repome.ephemeral({ ttl: '24h' })

console.log(git.remote) // storage URL (when assigned)
console.log(git.expiresAt) // ISO timestamp

Write files

git.add(path, content) stages a file. content can be a string or Uint8Array. git.remove(path) stages a removal.

await git.add('src/main.ts', sourceCode)
await git.add('README.md', readmeText)
await git.add('data/output.json', JSON.stringify(result, null, 2))
await git.remove('legacy/old.ts')

Staged changes are held in memory until you call commit. Nothing is written to the remote before that, and commit() will throw if no add/remove calls were made first.

Commit

const commit = await git.commit('feat: add generated output')

console.log(commit.sha) // a1b2c3d4e5f6...
console.log(commit.url) // https://api.repome.sh/my-repo/commit/a1b2c3d

commit writes all staged changes as a single atomic commit to main (override with options.branch). The returned object contains the commit SHA, author signature, and a display URL.

For anonymous repos created with repome.ephemeral(), commit.url is an empty string — no public web view exists yet.

Read files

read() returns the file as both decoded text and raw bytes. Use bytes for binary content.

const file = await git.read('src/main.ts')
console.log(file.content) // string (UTF-8 decoded)
console.log(file.bytes) // Uint8Array
console.log(file.sha) // blob SHA

List files

ls() returns a flat, recursive listing by default. Pass { recursive: false } for a one-level directory walk, or { path: 'src' } to scope to a subtree.

const tree = await git.ls()
// [{ path: "src/main.ts", sha: "...", type: "blob", mode: "100644" }, ...]

API reference

interface GitRepo {
  readonly remote?: string | null
  readonly expiresAt?: string | null
  add(path: string, content: string | Uint8Array): Promise<void>
  remove(path: string): Promise<void>
  commit(message: string, options?: CommitOptions): Promise<Commit>
  read(path: string, ref?: string): Promise<Blob>
  ls(ref?: string, options?: LsOptions): Promise<TreeEntry[]>
  log(options?: LogOptions): Promise<Commit[]>
}

interface Commit {
  sha: string
  url: string
  author: { name: string | null; email: string | null; date: string | null }
  message: string
}

interface CommitOptions {
  branch?: string // default: "main"
  author?: { name: string; email: string }
}

interface Blob {
  content: string
  bytes: Uint8Array
  sha: string
}

interface TreeEntry {
  path: string
  sha: string
  type: 'tree' | 'blob'
  mode: string
}

interface LsOptions {
  path?: string
  recursive?: boolean // default: true
}

interface LogOptions {
  ref?: string
  limit?: number // default: 50
}

Low-level oRPC client

createClient({ baseUrl, apiKey }) returns the typed oRPC client over the raw contract. Use it when you need a procedure that isn't on GitRepokeys.*, repos.list, orgs.*, members.*, tokens.*, and the rest of the public RPC surface.

import { createClient } from '@repome/sdk'

const client = createClient({
  baseUrl: 'https://api.repome.sh',
  apiKey: process.env.REPOME_API_KEY!,
})

const { items } = await client.repos.list({})

API keys must use the rpme_ prefix and are sent as Authorization: Bearer <key>.


Example: commit AI-generated code

The SDK composes directly with the AI SDK. Generate text with your model, write it to a repo, and commit — in a single async chain.

import { generateText } from 'ai'
import { repome } from '@repome/sdk'

const git = await repome('agent-output', {
  token: process.env.REPOME_API_KEY!,
})

const { text } = await generateText({
  model: yourModel,
  system: 'You are an expert TypeScript engineer.',
  prompt: 'Write a function that parses markdown frontmatter',
})

await git.add('src/parse-frontmatter.ts', text)
const commit = await git.commit('feat: add frontmatter parser')

console.log(commit.url)
// → https://api.repome.sh/agent-output/commit/a1b2c3d

Example: save agent outputs across a loop

import { generateText } from 'ai'
import { repome } from '@repome/sdk'

const git = await repome('research', {
  token: process.env.REPOME_API_KEY!,
})

const topics = ['transformers', 'diffusion models', 'rl from human feedback']

for (const topic of topics) {
  const { text } = await generateText({
    model: yourModel,
    prompt: `Write a concise technical summary of: ${topic}`,
  })

  await git.add(`summaries/${topic.replaceAll(' ', '-')}.md`, text)
}

const commit = await git.commit('chore: add research summaries')
console.log(`${topics.length} files committed → ${commit.url}`)

Example: anonymous ephemeral repo

No token, no account — repo expires after 24 hours by default (max 72h). Useful for one-shot agent runs that write through the SDK.

import { repome } from '@repome/sdk'

const git = await repome.ephemeral({ ttl: '24h' })

await git.add('output.md', markdownReport)
await git.commit('initial')

console.log(git.remote)
console.log(git.expiresAt)

Pass configDir to persist the anonymous identifier across runs (so a later call resumes the same repo instead of creating a new one):

const git = await repome.ephemeral({
  ttl: '24h',
  configDir: `${process.env.HOME}/.config/repome`,
})

Anonymous repo claiming is not available yet. Create a signed-in repo when you need permanent retention.

On this page