Skip to main content

Schemas

JSON schemas for libragen data structures

Libragen uses JSON Schema to define its data structures. These schemas are versioned and available for validation and tooling integration.

Schema URLs

All schemas are available at versioned URLs:

SchemaURL
Library Metadata/schemas/v1/library-metadata.schema.json
Collection Index/schemas/v1/collection-index.schema.json
Collection/schemas/v1/collection.schema.json
Collection Item/schemas/v1/collection-item.schema.json

Use these URLs in your $schema field for validation:

{
"$schema": "https://libragen.dev/schemas/v1/library-metadata.schema.json",
"name": "my-library",
...
}

Library Metadata

Schema: /schemas/v1/library-metadata.schema.json

Every .libragen file contains metadata describing its contents. This is stored in the library’s SQLite database and returned by libragen inspect.

Key Fields

FieldRequiredDescription
nameYesLibrary name (e.g., “react-docs”)
versionYesLibrary format version
createdAtYesISO 8601 creation timestamp
contentVersionNoVersion of source content
descriptionNoShort description
agentDescriptionNoGuidance for AI agents
exampleQueriesNoExample queries this library answers
keywordsNoSearchable tags
programmingLanguagesNoProgramming languages covered
textLanguagesNoHuman/natural languages (ISO 639-1 codes)
frameworksNoFrameworks covered

Example

{
"$schema": "https://libragen.dev/schemas/v1/library-metadata.schema.json",
"name": "react-docs",
"version": "1.0.0",
"contentVersion": "19.0.0",
"description": "Official React documentation",
"agentDescription": "Use when users ask about React hooks, components, or JSX.",
"exampleQueries": ["How do I use useEffect?"],
"keywords": ["react", "frontend"],
"programmingLanguages": ["javascript", "typescript"],
"textLanguages": ["en"],
"frameworks": ["react"],
"createdAt": "2024-01-15T10:30:00Z",
"embedding": {
"model": "Xenova/bge-small-en-v1.5",
"dimensions": 384
},
"chunking": {
"strategy": "recursive",
"chunkSize": 512,
"chunkOverlap": 50
},
"stats": {
"chunkCount": 8392,
"sourceCount": 247,
"fileSize": 12400000
},
"contentHash": "sha256:a1b2c3d4..."
}

Collection Index

Schema: /schemas/v1/collection-index.schema.json

Collections serve a JSON index listing available libraries. Host this file at your collection URL.

Key Fields

FieldRequiredDescription
nameYesCollection name
versionYesIndex format version (use “1.0”)
updatedAtYesISO 8601 timestamp
librariesYesArray of available libraries

Each library version includes:

FieldRequiredDescription
versionYesLibrary version
downloadURLYesURL to download .libragen file
contentHashYesSHA-256 hash for verification
contentVersionNoSource content version
fileSizeNoFile size in bytes

Example

{
"$schema": "https://libragen.dev/schemas/v1/collection-index.schema.json",
"name": "frontend",
"version": "1.0",
"updatedAt": "2024-01-15T10:30:00Z",
"libraries": [
{
"name": "react",
"description": "Official React documentation",
"versions": [
{
"version": "1.0.0",
"contentVersion": "19.0.0",
"downloadURL": "https://example.com/react-1.0.0.libragen",
"contentHash": "sha256:a1b2c3d4e5f6...",
"fileSize": 12400000
}
]
}
]
}

Collection

Schema: /schemas/v1/collection.schema.json

A collection file that can be installed locally. Contains a list of libraries and/or nested collections.

Example

{
"$schema": "https://libragen.dev/schemas/v1/collection.schema.json",
"name": "my-team",
"description": "Libraries for our team",
"items": [
{ "library": "https://example.com/api-docs-1.0.0.libragen" },
{ "library": "./local-docs.libragen" },
{ "collection": "https://example.com/shared.json" }
]
}

File Format

The .libragen file format is a SQLite database containing:

TableDescription
metadataKey-value store for library metadata
chunksDocument chunks with content and source info
embeddingsVector embeddings for each chunk
fts_chunksFull-text search index

The format is designed to be:

  • Portable — Single file, no external dependencies
  • Queryable — Standard SQLite, readable by any SQLite client
  • Efficient — Optimized for hybrid vector + full-text search

Versioning

Schemas are versioned using URL paths (e.g., /schemas/v1/). When breaking changes are introduced, a new version will be released (e.g., /schemas/v2/). Older versions remain available for backward compatibility.

Current version: v1