Skip to main content

context-rainbow

PyPI Python License

Color-aware OKF context routing for progressively loading repository knowledge.

context-rainbow keeps an OKF bundle as a small map of a repository. An agent matches a task against that map, follows the relevant branch, and reads only the source files that the selected OKF documents point to. Source code is not duplicated inside the knowledge bundle.

Why

Task: "Fix refresh token expiry"
                 |
                 v
        Read compact OKF map
                 |
                 v
        Match auth / refresh-token
                 |
                 v
        Follow existing OKF relationships
                 |
                 v
        Read only referenced source files

The package adds one routing convention to OKF: a top-level color field. Existing OKF paths and relationships remain the navigation structure.

Installation

pip install context-rainbow

OKF color convention

Color belongs directly in the document frontmatter:

---
type: Index
title: Authentication
description: Authentication architecture and implementation
tags: [okf, auth]
status: stable
color: amber
relationships:
  - type: applies_to
    target: /repositories/example.md
---

Colors identify sibling branches. Direct children of one splitter/index must have different colors. A color may be reused in a different branch.

Supported colors:

blue · green · amber · red · violet · cyan · pink · orange

Python API

from context_rainbow import ContextRainbow, OkfDocument

documents = [
    OkfDocument(
        id="auth.refresh-token",
        type="code-context",
        title="Refresh token",
        color="red",
        tags=("auth", "refresh", "token"),
        relationships=({"type": "applies_to", "target": "/backend/auth"},),
    ),
]

selected = ContextRainbow(documents).route("Fix refresh token expiry")

for match in selected:
    print(match.document.id, match.reasons)

Routing is deterministic and body-free: matching uses document IDs, titles, tags, and existing relationship targets. The selected document body is loaded only by the caller after routing.

Optional Clinotes integration

Clinotes is not a required dependency. If a repository has committed .clinotes/INDEX.md and detail/*.md files, the adapter exposes those details as project-memory documents:

from context_rainbow.sources.clinotes import load_clinotes

project_memory = load_clinotes("C:/work/my-repo")
selected = ContextRainbow(project_memory).route("refresh token decision")

This adapter is read-only and filesystem-based. Clinotes remains responsible for writing decisions and learnings through its own API/MCP server.

Design boundaries

OKF                  → meaning, architecture, relationships, navigation
Context Rainbow      → color validation and deterministic selection
Repository source    → exact implementation files
Clinotes             → optional project decisions and learnings

Development

python -m pip install -e ".[dev]"
python -m pytest -q
python -m build

Project

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

context_rainbow-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

context_rainbow-0.1.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file context_rainbow-0.1.1.tar.gz.

File metadata

  • Download URL: context_rainbow-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for context_rainbow-0.1.1.tar.gz
Algorithm Hash digest
SHA256 234b6bcaa631fb876124444db518199f7bac5ed7de4adbaa26356c1eae126713
MD5 cb376a56af0180845e741967dcd4a863
BLAKE2b-256 d4c71f16c0a7fe9b19f9f227612b5222a3539ab569f08fa4863a9d880ec56321

See more details on using hashes here.

File details

Details for the file context_rainbow-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for context_rainbow-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 db82239d1d406913bd7bd25cb844f3ce94a7b8ea36c6d4ab651d094170b5012c
MD5 db0762c10b875494930f8633f063e9c2
BLAKE2b-256 bf8b13022b8e289c1c1d9477074afe15f0fa856a40e89007904d2751c5dfda94

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page