Nostr-Git is a TypeScript library that bridges Git with Nostr. It provides helpers to:
isomorphic-git) with vendor/provider abstractionsThis repository builds and publishes a single-package npm distribution:
@nostr-git/coreThe public API is exposed via top-level exports and subpath exports (see package.json and src/index.ts).
pnpm add @nostr-git/core
# or
npm i @nostr-git/core
The root barrel exports namespaced modules:
import * as ngit from "@nostr-git/core"
// Example: initialize provider plumbing for Git + Nostr
const git = ngit.api.getGitProvider()
Convenience exports are also available:
import { getGitProvider, initializeNostrGitProvider } from "@nostr-git/core"
Always use the canonical tag helpers when reading event tags.
Do not use event.tags.find / event.tags.filter directly.
// Option A: import helpers from the `events` subpath
import { getTag, getTags, getTagValue } from "@nostr-git/core/events"
// Option B: use the namespaced root export
// import * as ngit from "@nostr-git/core"
// const { getTag, getTags, getTagValue } = ngit.events
const committer = getTag(event, "committer")
const clones = getTags(announcement, "clone")
const repoUrl = getTagValue(announcement, "r")
Nostr-Git ships a worker bundle export and a Comlink client.
import { getGitWorker, configureWorkerEventIO } from "@nostr-git/core"
import type { EventIO } from "@nostr-git/core"
const eventIO: EventIO = {
fetchEvents: async () => [],
publishEvent: async (event) => ({ ok: true, relays: [] }),
publishEvents: async (events) => Promise.all(events.map((e) => eventIO.publishEvent(e))),
getCurrentPubkey: () => "f".repeat(64),
}
const { api, worker } = getGitWorker((evt) => {
console.log("[worker-progress]", (evt as MessageEvent).data ?? evt)
})
await configureWorkerEventIO(api, eventIO)
// ... call worker API methods
worker.terminate()
See examples/worker-usage.ts for a fuller example.
Optional Zod-backed event validation can be toggled via NOSTR_GIT_VALIDATE_EVENTS.
NODE_ENV != "production", disabled in production.true, 1, yesfalse, 0, no[email protected] in package.json)pnpm install
pnpm build
pnpm test
pnpm lint
pnpm typecheck
pnpm dev
For watch mode (tsc + worker bundle), see pnpm watch and scripts/dev.mjs.
See LICENSE.