Implementation:0xranx OpenContext Store generateManifest
| Knowledge Sources | |
|---|---|
| Domains | Knowledge_Management, API |
| Last Updated | 2026-10-24 12:00 GMT |
Overview
Concrete tool for generating a document manifest for a knowledge base folder, providing a batch file list with descriptions, stable links, and absolute paths for agent context loading.
Description
The generateManifest function queries the SQLite store for all documents within a specified folder and returns an array of manifest entries. Each entry includes the document's relative path, absolute path, description, stable link (`oc://doc/<stable_id>`), and updated_at timestamp.
The manifest is the primary tool for batch context loading: instead of searching for individual documents, an agent can request a manifest for a folder and get a structured list of all available documents with enough metadata to decide which to read.
The CLI can render the manifest as JSON or as an LLM-friendly markdown tree. The MCP `oc_manifest` tool returns the JSON structure directly.
Usage
- Context Discovery: Generate a manifest for a folder to get a batch file list for context loading.
- Agent workflows: The `oc context manifest <folder>` CLI command and `oc_manifest` MCP tool use this function.
- Root manifest: Pass `"."` as folderPath to get a manifest for all folders (root/all).
Code Reference
Source Location
- Repository: OpenContext
- File (JS adapter): src/core/store-native.js
- File (Rust core): crates/opencontext-core/src/lib.rs
- File (CLI): bin/oc.js
- File (MCP): src/mcp/server.js
Signature
/**
* Generate manifest
* @param {{ folderPath: string, limit?: number }} options
* @returns {Array<DocManifestEntry>}
*/
function generateManifest(options) {
return handleResult(native.get().generateManifest({
folderPath: options.folderPath,
limit: options.limit,
}));
}
Import
const { generateManifest } = require('./core/store-native');
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| options.folderPath | string | Yes | Folder path relative to contexts/ (use "." for root/all) |
| options.limit | number | No | Optional max number of docs to return |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | Array<DocManifestEntry> | Array of manifest entries |
| DocManifestEntry.rel_path | string | Document relative path |
| DocManifestEntry.abs_path | string | Document absolute path |
| DocManifestEntry.description | string | Document description |
| DocManifestEntry.stable_link | string | Stable link: oc://doc/<stable_id> |
| DocManifestEntry.updated_at | null | Last updated timestamp |
Usage Examples
Generate Manifest (CLI)
# Manifest for a specific folder
oc context manifest projects/architecture --limit 10
# Manifest for all folders (root)
oc context manifest . --limit 10
# JSON output
oc context manifest . --format json --limit 20
Generate Manifest (JavaScript)
const { generateManifest } = require('./core/store-native');
const manifest = generateManifest({
folderPath: 'projects/architecture',
limit: 10
});
manifest.forEach(entry => {
console.log(`${entry.rel_path}: ${entry.description}`);
console.log(` Path: ${entry.abs_path}`);
console.log(` Link: ${entry.stable_link}`);
});
MCP Tool Usage
{
"tool": "oc_manifest",
"arguments": {
"folderPath": "projects/architecture",
"limit": 10
}
}