Open Knowledge CLI Documentation
Frontmatter5 fields
type
Feature Documentation
title
Machine-Readable Contracts
description
JSON schemas, version domains, and compatibility for CLI automation.
timestamp

Machine-Readable Contracts

Stable CLI JSON objects declare schemaVersion: "1". When present, specVersion identifies the independently versioned OKF document format.

CLI output schemas

SchemaSurface
ast.schema.jsonast
bundle.schema.jsonexport json
cli-error.schema.jsonglobal --error-format json failures
list.schema.jsonlist --json
validation.schema.jsonvalidate --format json, MCP validation
graph.schema.jsonexport graph
search-context.schema.jsonsingle-bundle context, MCP search
search-results.schema.jsonsingle-bundle ranked matches
federated-search-context.schema.jsonregistry-wide context
federated-search-results.schema.jsonregistry-wide matches
registry-list.schema.jsonregistry list --json
registry-status.schema.jsonregistry status --json
job-list.schema.jsonjobs list --json
job-status.schema.jsonjobs status --json
job-runs.schema.jsonjobs runs --json
job-start.schema.jsonjobs start --json
job-control.schema.jsonjobs stop
job-run-summary.schema.jsonPrivacy-minimized management summary shared by job outputs.
job-validation.schema.jsonjobs validate --json
job-run-plan.schema.jsonjobs run --dry-run, persisted plan
job-run-record.schema.jsonpersisted lifecycle record
agent-doctor.schema.jsonagent doctor --json
runtime-plan.schema.jsonruntime plan
runtime-build.schema.jsonruntime build
deploy-plan.schema.jsondeploy railway --dry-run
deploy-result.schema.jsonsuccessful deploy railway result
deploy-runtime-scaffold.schema.jsondeploy railway init

common.schema.json contains shared issue, link, retrieval, and typed-frontmatter definitions. Job contracts are experimental. They can change without a new version before version 1.0.

The published v1 schema distribution includes diagnostic, runtime, and Railway deployment outputs. Golden tests marshal the current Go result types. The shared schema suite compiles and validates these fixtures.

Error envelope

Place the global option before the command:

okn --error-format json search

A failure produces one JSON document on stderr. The command preserves the original exit status:

{
  "schemaVersion": "1",
  "error": {
    "kind": "usage",
    "command": "search",
    "exitCode": 2,
    "message": "search requires a key or path and a query",
    "truncated": false
  }
}

kind is usage for exit status 2. For all other exit status values, kind is runtime. The maximum diagnostic size is 256 KiB. Command-specific semantic JSON remains on stdout. For example, the CLI does not wrap an invalid validation report as a CLI error.

Schema locations

Draft 2020-12 CLI schemas are in packages/cli/schemas/v1/. The project publishes them at:

https://openknowledge.sh/schemas/cli/v1/<schema>.json

Two other version domains are independent:

ContractRepositoryPublic route
Portable openknowledge.jsonschemas/manifest/v1//schemas/cli/manifest/v1/
Registry and cache persistenceschemas/storage/v1//schemas/cli/storage/v1/
Runtime generation manifestschemas/runtime/v1/not a CLI output contract

Portable manifests use a numeric version and a concrete spec. Local storage and runtime manifests use their own schemaVersion values. These domains are independent.

Compatibility

Version 1 can add fields when existing field meanings and types do not change. The project then updates the closed v1 schema. A consumer that uses a downloaded schema must refresh it before it accepts this output. A new schema version is usually necessary when the project removes a field. It is also usually necessary when a field type or meaning changes. The project also uses a new version when new output rules reject previously valid output.

Schemas use additionalProperties: false at defined object boundaries. This rule detects encoder drift. Retrieval results bind evidence to a corpus revision, section digest, and okf+sha256:// locator. Federated search adds registry identity, local rank, and RRF score to single-bundle objects.

Repository tests compile each schema offline. They validate golden objects and runtime objects. They verify that undeclared top-level and nested fields fail. The web build verifies each $id against its public route before it copies schemas.

Powered by OpenKnowledge.sh