Skip to content

context-object-spec/specification

Context Object Specification

Text selection gives you characters. The Context Object Specification (COS) preserves what those characters mean where they were selected.

Status: COS v0.2 is a pre-release draft and is not yet stable.

Read the specification · Try the Web Adapter · Install from npm

Why COS?

Applications commonly reduce a user's focus to a string:

{ "text": "$49" }

The receiving system cannot tell whether $49 is a price, a discount, a table cell, or unrelated prose. It also loses the source, selection boundaries, structural relationships, and nearby evidence that gave the text meaning.

COS provides a small, portable representation of that source-grounded context:

{
  "version": "0.2",
  "source": {
    "type": "webpage",
    "title": "Pricing"
  },
  "selection": {
    "text": "$49"
  },
  "context": {
    "scope": "container",
    "segments": [
      {
        "type": "table",
        "text": "$49",
        "selectedText": "$49",
        "relations": [
          { "type": "row_header", "label": "Pro" },
          { "type": "column_header", "label": "Monthly price" }
        ]
      }
    ]
  }
}
Before COS With COS
Selected characters only Selected text plus bounded source context
Application-specific payloads A portable, schema-defined object
Structure discarded Tables, lists, headings, code, and relations preserved
Consumers guess what the text means Consumers receive inspectable source evidence
Integrations are coupled to one UI Producers and Consumers evolve independently

COS does not infer user intent, summarize content, or generate prompts. It preserves deterministic evidence so AI features, editors, annotation tools, search systems, and agents can interpret a selection more reliably.

Start using COS

For web applications, the fastest path is the framework-agnostic COS Web Adapter:

npm install @context-object-spec/web-adapter
import { adaptCurrentSelection } from "@context-object-spec/web-adapter";

const contextObject = adaptCurrentSelection();

The adapter converts the browser Selection API into a COS v0.2 Context Object without sending data anywhere or calling an AI service.

Specification

Start with the v0.2 specification, conformance rules, and JSON Schema.

The required core fields are version, source, selection, and context; meta and extensions are optional.

A Producer conforms when emitted objects satisfy normative prose and schema. Implementing the reference Pipeline or Plugin architecture is not required. A Consumer conforms when it processes core fields without changing their meaning and safely ignores unknown extensions.

Implementation resources

Project

The generated documentation site and single-page specification are built with npm run build and deployed through GitHub Pages.

Licensed under Apache-2.0.

About

A portable protocol for representing user attention and source-grounded context.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors