Coregit
API Reference

LLM Wiki

API endpoints for LLM-maintained knowledge bases — pages, sources, history, sandboxes, and document ingestion.

Build persistent, version-controlled knowledge bases that LLMs maintain for you. Inspired by the LLM Wiki pattern by Andrej Karpathy — an LLM incrementally builds and maintains a structured wiki from raw source material.

A Coregit LLM Wiki is a regular repository organized like this:

wiki.json   # Configuration (read by /llms.txt)
schema.md   # LLM instructions (optional, free-form)
raw/        # Immutable source documents
raw/docs/   # Markdown converted from uploaded files
wiki/       # LLM-generated pages (one .md per page)

The endpoints below are exposed by an internal Wiki Worker that's service-bound to the public API. They live under /v1/repos/:slug/wiki/* and require the same x-api-key header as the rest of the API. All routes also accept a namespaced form: /v1/repos/:namespace/:slug/wiki/*.

Creating a wiki repo. There's no dedicated /wiki/init endpoint. Create a regular repo with POST /v1/repos, then commit a wiki.json plus your initial raw/ material via the Commits API. The wiki endpoints below take over once the repo has the expected layout.

List Pages

Return parsed metadata for every .md under wiki/.

GET /v1/repos/:slug/wiki/pages
QueryDescription
refBranch or commit SHA. Default main.

Response 200

{
  "pages": [
    {
      "path": "wiki/transformers.md",
      "title": "Transformer Architecture",
      "summary": "The dominant architecture for sequence modeling since 2017",
      "tags": ["deep-learning"],
      "type": "concept",
      "updated": "2026-04-10",
      "word_count": 1250,
      "sources": ["raw/attention-paper.md"],
      "related": ["wiki/attention.md"]
    }
  ],
  "count": 1,
  "at_version": "main"
}

Each page is parsed for YAML frontmatter; everything in frontmatter.title|summary|tags|type|sources|related|updated is hoisted to the row. Result is cached for 10 minutes per (repo, ref) pair.

SDK

const { data } = await cg.wiki.listPages("my-research");

Get Page

Read a single wiki page with parsed frontmatter, dual-section split, and word count.

GET /v1/repos/:slug/wiki/pages/:path

The :path segment may be the path with or without the leading wiki/. Both wiki/transformers.md and transformers.md resolve the same blob.

QueryDescription
refBranch or commit SHA. Default main.

Response 200

{
  "path": "wiki/transformers.md",
  "frontmatter": {
    "title": "Transformer Architecture",
    "summary": "The dominant architecture for sequence modeling since 2017",
    "tags": ["deep-learning"],
    "type": "concept",
    "sources": ["raw/attention-paper.md"],
    "related": ["wiki/attention.md"],
    "updated": "2026-04-10"
  },
  "content": "---\ntitle: \"Transformer Architecture\"\n...\n---\n\n## Truth\n...",
  "compiled_truth": "## Truth\n\nA transformer is...",
  "timeline": "- **2026-04-10 (sync)**: refined attention section.\n",
  "has_dual_section": true,
  "word_count": 1250,
  "version_id": "9c3a1f...",
  "at_version": "main"
}

compiled_truth is the canonical "current state" half of the dual-section pattern; timeline is the append-only history half. Pages without the dual-section markers fall back to compiled_truth = body.

SDK

const { data } = await cg.wiki.getPage("my-research", "wiki/transformers.md");

List Sources

List the raw source files (everything under raw/, excluding .gitkeep).

GET /v1/repos/:slug/wiki/sources
QueryDescription
refBranch or commit SHA. Default main.

Response 200

{
  "sources": [
    { "path": "raw/attention-paper.md", "size": 0 }
  ],
  "count": 1,
  "at_version": "main"
}

size is reported as 0 in list responses — fetch the individual source for the real byte count.

SDK

const { data } = await cg.wiki.listSources("my-research");

Get Source

Read a single raw source file.

GET /v1/repos/:slug/wiki/sources/:path

The :path segment may include or omit the leading raw/ — both raw/foo.md and foo.md resolve the same blob.

Response 200

{
  "path": "raw/attention-paper.md",
  "content": "Attention Is All You Need\n\n...",
  "size": 8421,
  "version_id": "9c3a1f...",
  "at_version": "main"
}

SDK

const { data } = await cg.wiki.getSource("my-research", "raw/attention-paper.md");

Knowledge Graph

Build a graph from frontmatter.related links, frontmatter.sources references, and shared tags.

GET /v1/repos/:slug/wiki/graph
QueryDescription
refBranch or commit SHA. Default main.

Response 200

{
  "nodes": [
    { "path": "wiki/transformers.md", "title": "Transformer Architecture", "tags": ["deep-learning"], "type": "concept", "word_count": 1250 },
    { "path": "raw/attention-paper.md", "title": "attention-paper.md", "tags": [], "type": "source", "word_count": 0 }
  ],
  "edges": [
    { "source": "wiki/transformers.md", "target": "wiki/attention.md", "type": "related" },
    { "source": "wiki/transformers.md", "target": "raw/attention-paper.md", "type": "source-ref" },
    { "source": "wiki/transformers.md", "target": "wiki/bert.md", "type": "shared-tag", "tag": "deep-learning" }
  ],
  "tag_clusters": {
    "deep-learning": ["wiki/transformers.md", "wiki/bert.md"]
  },
  "stats": { "pages": 42, "sources": 15, "links": 87, "orphans": 3 },
  "at_version": "main"
}

SDK

const { data } = await cg.wiki.graph("my-research");

Wiki Stats

Health overview.

GET /v1/repos/:slug/wiki/stats
QueryDescription
refBranch or commit SHA. Default main.

Response 200

{
  "pages": 42,
  "sources": 15,
  "words": 52500,
  "links": 87,
  "orphans": 3,
  "dual_section_pages": 28,
  "at_version": "main"
}

SDK

const { data } = await cg.wiki.stats("my-research");

Generate llms.txt

Auto-generate a structured text/plain file for external LLM consumption, following the emerging llms.txt convention. Reads wiki.json for title and inclusion options.

GET /v1/repos/:slug/wiki/llms.txt
QueryDescription
refBranch or commit SHA. Default main.
formatcompact (default) — page summaries only. full — also embeds page content.

Cached by commit SHA. Content-Type: text/plain.

Compact format

# AI Research Wiki
> Deep dive into transformer architectures

## Pages
- [Transformer Architecture](wiki/transformers.md): The dominant architecture for sequence modeling since 2017
- [Attention Mechanism](wiki/attention.md): Core mechanism enabling transformers to weigh input tokens

## Sources
- raw/attention-paper.md

wiki.json config

{
  "version": 1,
  "title": "AI Research Wiki",
  "description": "Deep dive into transformer architectures",
  "llms_txt": {
    "include_sources": false,
    "max_pages": 500,
    "sort": "updated"
  }
}
FieldDescription
versionCurrently 1.
titleUsed in the llms.txt header. Falls back to repo slug if unset.
descriptionOptional one-line subtitle.
llms_txt.include_sourcesIf true, includes raw/ files in the output. Default false.
llms_txt.max_pagesCap on pages emitted. Default 500.
llms_txt.sortupdated (default), created, or title.

SDK

const { data } = await cg.wiki.llmsTxt("my-research", { format: "full" });

Page History

Outcome-framed activity log for a page. Internal git verbs never surface — every entry uses version_id, changed_by, changed_at, summary.

GET /v1/repos/:slug/wiki/pages/:path/history
QueryDescription
limitMax entries. Default 25, max 100.

Response 200

{
  "path": "wiki/transformers.md",
  "activity": [
    {
      "version_id": "9c3a1f8b...",
      "changed_by": { "name": "Wiki Agent", "email": "agent@example.com" },
      "changed_at": "2026-04-10T08:00:00Z",
      "summary": "sync: refined attention section",
      "message": "sync: refined attention section\n\nApplied feedback from raw/transformer-review.md."
    }
  ],
  "count": 1
}

View Page At Date

Read a page as it existed at or before a given timestamp.

GET /v1/repos/:slug/wiki/pages/:path/as-of
QueryDescription
as_ofRequired. ISO 8601 timestamp (e.g. 2026-03-15T00:00:00Z).

The route resolves the closest commit on main at or before as_of, then returns the page exactly as it was then.

Response 200

{
  "path": "wiki/transformers.md",
  "frontmatter": { "title": "Transformer Architecture", "tags": ["deep-learning"] },
  "compiled_truth": "## Truth\n\nA transformer is...",
  "timeline": "- **2026-03-12 (sync)**: initial draft.\n",
  "version_id": "5e7a2c...",
  "as_of": "2026-03-15T00:00:00Z"
}

Returns 404 if the page didn't yet exist at that date.

Restore Page

Restore a page to a previous version. Bumps frontmatter.provenance.last_human_edit and appends a restore note to the timeline so subsequent syncs honour the rollback.

POST /v1/repos/:slug/wiki/pages/:path/restore
{ "version_id": "5e7a2c8b..." }
FieldRequiredDescription
version_idYesGit SHA of the page version to restore.

Response 200

{
  "path": "wiki/transformers.md",
  "version_id": "a1b2c3d4...",
  "restored_from": "5e7a2c8b..."
}

version_id in the response is the new commit SHA that holds the restore; restored_from is the historical version you targeted.

Upload Document

Convert a binary document (PDF, DOCX, XLSX, image, ...) to markdown via AI document processing, commit it to raw/docs/, and enqueue an ingest run that synthesizes it into wiki pages.

POST /v1/repos/:slug/wiki/documents
Content-Type: multipart/form-data
Form fieldRequiredDescription
fileYesThe document. Up to 25 MB.
descriptionNoOne-line note saved as summary in frontmatter.

Supported extensions: pdf, docx, xlsx, xlsm, xlsb, xls, ods, odt, csv, html, htm, xml, numbers, md, txt, png, jpg, jpeg, webp, svg.

Response 200

{
  "path": "raw/docs/attention-paper.md",
  "original_filename": "attention-paper.pdf",
  "bytes": 8421334,
  "markdown_length": 65440,
  "run_id": "f8b2c1..."
}

The commit lands on main immediately; run_id lets you poll the synthesis run via Get Run.

List Documents

List markdown files under raw/docs/.

GET /v1/repos/:slug/wiki/documents

Response 200

{
  "documents": [
    {
      "path": "raw/docs/attention-paper.md",
      "name": "attention-paper.md",
      "sha": "9c3a1f..."
    }
  ]
}

Run Workflow

Kick off a wiki workflow: sync (re-synthesize pages from sources), dream (LLM proposes new pages from neglected angles), or lint (suggest cleanups).

POST /v1/repos/:slug/wiki/run
{
  "mode": "sync",
  "source_ids": ["raw/attention-paper.md"],
  "force": false,
  "model": "claude-sonnet-4-6",
  "max_tokens_budget": 200000
}
FieldRequiredDescription
modeYessync, dream, or lint.
source_idsNoLimit a sync run to these source paths.
forceNoRe-process sources even if last_human_edit is newer.
modelNoClaude model id. Default claude-sonnet-4-6.
max_tokens_budgetNoCap output tokens for the run.

Response 200

{ "run_id": "f8b2c1...", "status": "queued" }

The run is enqueued; poll Get Run for progress.

List Runs

Recent workflow runs for the repo, newest first.

GET /v1/repos/:slug/wiki/runs
QueryDescription
limitDefault 20, max 100.

Response 200

{
  "runs": [
    {
      "id": "f8b2c1...",
      "orgId": "...",
      "repoSlug": "my-research",
      "namespace": null,
      "mode": "sync",
      "status": "running",
      "trigger": "manual",
      "model": "claude-sonnet-4-6",
      "sourceIds": ["raw/attention-paper.md"],
      "createdAt": "2026-04-10T08:00:00Z",
      "finishedAt": null
    }
  ],
  "count": 1
}

Get Run

Single run detail.

GET /v1/repos/:slug/wiki/runs/:id

Response 200

Same row shape as in List Runs. 404 if the run doesn't exist or belongs to a different org.

Cancel Run

Mark a queued or running job as cancelled. The Worker cooperatively stops on the next checkpoint; already-committed wiki edits are not rolled back.

POST /v1/repos/:slug/wiki/cancel
{ "run_id": "f8b2c1..." }

Response 200

{ "ok": true }

Sandboxes

Outcome-framed wrapper over branches. A "sandbox" is a wiki-sandbox/<name> branch — useful for letting an agent draft changes that humans review before promotion.

Create Sandbox

POST /v1/repos/:slug/wiki/sandboxes
{ "name": "draft-attention-rewrite", "from": "main" }

name is sanitized to [a-zA-Z0-9._-] (other characters become -). from defaults to main.

Response 200

{ "name": "draft-attention-rewrite", "version_id": "9c3a1f..." }

List Sandboxes

GET /v1/repos/:slug/wiki/sandboxes

Response 200

{
  "sandboxes": [
    { "name": "draft-attention-rewrite", "version_id": "9c3a1f..." }
  ],
  "count": 1
}

Promote Sandbox

Merge wiki-sandbox/<name> into main.

POST /v1/repos/:slug/wiki/sandboxes/:name/promote

Response 200

{ "name": "draft-attention-rewrite", "version_id": "a1b2c3..." }

version_id is the merge commit SHA.

Delete Sandbox

DELETE /v1/repos/:slug/wiki/sandboxes/:name

Response 200

{ "ok": true }

Writing pages from your agent

The wiki endpoints above are the read/lifecycle surface. Edits to wiki pages, sources, or wiki.json go through the standard Commits API. Atomic multi-file commits make Karpathy's pattern (one commit per ingest, touching the page plus index/log files) a single round-trip:

await cg.commits.create("my-research", {
  branch: "main",
  message: "ingest: Attention Is All You Need",
  author: { name: "wiki-agent", email: "agent@example.com" },
  changes: [
    {
      path: "wiki/transformers.md",
      content: `---
title: "Transformer Architecture"
summary: "The dominant architecture for sequence modeling since 2017"
tags: [deep-learning]
type: concept
sources: [raw/attention-paper.md]
updated: 2026-04-10
---

## Truth

A transformer is...

## Timeline

- **2026-04-10 (ingest)**: created from raw/attention-paper.md.
`,
    },
  ],
});

For sandbox-style workflows (draft → review → promote), commit to a wiki-sandbox/* branch and call Promote Sandbox once the human approves.

On this page