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

Metadata

Release files for context-rainbow 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for context-rainbow 0.1.1
File Size Uploaded
context_rainbow-0.1.1.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for context-rainbow 0.1.1
File Interpreter ABI Platform
context_rainbow-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / context_rainbow-0.1.1.tar.gz

Download URL context_rainbow-0.1.1.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
234b6bcaa631fb876124444db518199f7bac5ed7de4adbaa26356c1eae126713
BLAKE2b-256 checksum
How to use checksums
d4c71f16c0a7fe9b19f9f227612b5222a3539ab569f08fa4863a9d880ec56321
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / context_rainbow-0.1.1-py3-none-any.whl

Download URL context_rainbow-0.1.1-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db82239d1d406913bd7bd25cb844f3ce94a7b8ea36c6d4ab651d094170b5012c
BLAKE2b-256 checksum
How to use checksums
bf8b13022b8e289c1c1d9477074afe15f0fa856a40e89007904d2751c5dfda94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release 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