Skip to main content

AI Context Infrastructure Layer - Reduce token consumption. Maintain AI continuity.

Project description


License Python Version Status PRs Welcome


Stop repeating yourself to AI. Let ContextOS remember.


Getting Started · CLI Commands · How It Works · Roadmap · Contributing



🤔 The Problem

Every AI session starts from zero.

You explain your project. Again. You explain what's done. Again. You explain the constraints. Again.

Meanwhile the AI burns hundreds of tokens just reading context it already processed yesterday.

There had to be a better way.


⚡ The Solution

Without ContextOS                    With ContextOS
─────────────────                    ──────────────
You → [entire codebase]              You → ContextOS → [45 tokens]
    → [full history]                             ↓
    → [repeated rules]               Compressed. Focused. Structured.
    → AI Model                       → AI Model

    ~3000 tokens                     ~45 tokens

ContextOS sits between you and any AI model. It maintains structured project memory and injects only what the AI needs — nothing more.


🎬 Demo

📹 Initialize a project in seconds

Init Demo

📹 Full context injected in 45 tokens

Explain Demo

📹 A/B/C suggestions with decision tracking

Suggest Demo


🔥 Why ContextOS?

❌ Without ContextOS

  • Repeat project context every session
  • AI loses track of current task
  • No record of decisions made
  • Token waste on irrelevant history
  • Hard dependency on AI frameworks

✅ With ContextOS

  • Automatic context injection
  • Persistent task state
  • Full decision history
  • 70%+ token reduction
  • Delete .contextos/ — completely gone

📦 Install

git clone https://github.com/Whynotshashwat/ContextOS.git
cd ContextOS
python -m venv .venv

# Windows
.venv\Scripts\activate

# Mac/Linux
source .venv/bin/activate

pip install -e .

Verify:

context --help

🚀 Quick Start

# 1. Initialize in your project
context init "Jarvis" "Build an AI voice assistant"

# 2. Check project state
context status

# 3. Break task into subtasks
context decompose 1

# 4. Get next task
context next

# 5. See exactly what AI receives
context explain

# 6. Mark task done
context done 1.1

# 7. Get A/B/C implementation approaches
context suggest 1

🖥 CLI Commands

Command Description Example
context init Initialize ContextOS context init "Jarvis" "Build AI assistant"
context status Show full project state context status
context next Advance to next task context next
context done Mark task complete context done 1.1
context decompose Break task into subtasks context decompose 1
context suggest Get A/B/C approaches context suggest 1
context explain Preview context injection context explain
context goal Update project goal context goal "New goal"
context snapshot Save checkpoint context snapshot "before refactor"
context rollback Restore last snapshot context rollback
context import Import from README/TODO context import

Flags

context done 1.1 --dry-run       # Preview without executing
context decompose 1 --dry-run    # Preview subtasks before creating

🧠 How It Works

┌─────────────────────────────────────────────────────┐
│                    Your Project                      │
│                                                     │
│  ┌──────────────┐        ┌───────────────────────┐  │
│  │   You/IDE    │───────▶│      ContextOS        │  │
│  └──────────────┘        │                       │  │
│                          │  ┌─────────────────┐  │  │
│                          │  │  Context Engine  │  │  │
│                          │  │  Compressor      │  │  │
│                          │  │  Memory Store    │  │  │
│                          │  │  Decision Log    │  │  │
│                          │  └────────┬────────┘  │  │
│                          └───────────┼───────────┘  │
│                                      │              │
│                                      ▼              │
│                          ┌───────────────────────┐  │
│                          │  Compressed Context   │  │
│                          │  45 tokens (not 3000) │  │
│                          └───────────┬───────────┘  │
│                                      │              │
│                                      ▼              │
│                          ┌───────────────────────┐  │
│                          │      AI Model         │  │
│                          │  (any provider)       │  │
│                          └───────────────────────┘  │
└─────────────────────────────────────────────────────┘

Context Priority Stack

ContextOS compresses context using a strict priority order:

Priority 1 ── Current task + subtask
Priority 2 ── Active rules
Priority 3 ── Last 3 decisions
Priority 4 ── Pending task titles
Priority 5 ── Project goal
Drop       ── Completed details, logs, cache

📊 Context Score

Every context status shows real metrics:

╭──────────────── ContextOS Status ─────────────────╮
│ Jarvis                                             │
│ Build an AI voice assistant                        │
╰────────────────────────────────────────────────────╯

  Field              Value
  Phase              Core Features
  Current Task       Command Parser
  Current Subtask    Map commands
  Progress           2/5 tasks done
  Context Score      90/100

Score breakdown:

  • Project name + goal defined → +35
  • Phase set → +10
  • Active task + subtask → +25
  • Tasks with subtasks → +20

📄 AICF — AI Context Format

ContextOS uses AICF (AI Context Format) — an open specification for structured AI project memory.

{
  "aicf_version": "1.0",
  "project": {
    "name": "Jarvis",
    "goal": "Build an AI voice assistant",
    "description": "Voice and text AI assistant"
  },
  "state": {
    "phase": "Core Features",
    "current_task": "2",
    "current_subtask": "2.2"
  },
  "tasks": [
    {
      "id": "1",
      "title": "Project setup",
      "status": "done"
    },
    {
      "id": "2",
      "title": "Command parser",
      "status": "in_progress",
      "subtasks": [
        { "id": "2.1", "title": "Detect keywords", "status": "done" },
        { "id": "2.2", "title": "Map commands", "status": "pending" }
      ]
    }
  ],
  "rules": {
    "max_subtasks": 5,
    "execute_one_subtask_only": true
  }
}

Any tool can read AICF. No ContextOS dependency required.


🗂 Project Memory Structure

your-project/
└── .contextos/          ← isolated memory layer
    ├── aicf.json        ← project state (safe to commit)
    ├── memory.json      ← compressed history
    ├── decisions.json   ← decision log
    ├── snapshots/       ← context checkpoints
    └── logs/            ← interaction logs

⚠️ Add config.json to .gitignore — it contains your API keys.


🛡 Removal Safety

ContextOS is fully removable at any time:

# Remove ContextOS completely
rm -rf .contextos/
pip uninstall contextos

Your project:

  • ✅ Compiles
  • ✅ Runs
  • ✅ Behaves identically

Zero runtime dependency. Zero leftover code.


📈 Roadmap

Phase 1 — MVP          ████████████████████  Done ✅
Phase 2 — Smart Memory ░░░░░░░░░░░░░░░░░░░░  Up Next
Phase 3 — Ecosystem    ░░░░░░░░░░░░░░░░░░░░  Planned
  • Core engine
  • AICF schema
  • CLI — all commands
  • Context compression
  • Decision tracking
  • A/B/C suggestion engine
  • Snapshot and rollback
  • Context import
  • Context score
  • Python SDK
  • JavaScript SDK
  • VS Code extension
  • Antigravity integration
  • Team shared memory
  • Cloud sync

🤝 Contributing

Contributions are welcome.

# Fork the repo
git clone https://github.com/YOURUSERNAME/ContextOS.git
cd ContextOS
python -m venv .venv
.venv\Scripts\activate
pip install -e .

# Create your branch
git checkout -b feature/your-feature

# Make changes and push
git push origin feature/your-feature

See CONTRIBUTING.md for guidelines.


📜 License

Apache 2.0 — see LICENSE

Free for personal and commercial use.


Built with 🧠 by Whynotshashwat

If ContextOS helped you — give it a ⭐

Project details


Download files

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

Source Distribution

contextos_cli-0.1.0.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

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

contextos_cli-0.1.0-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

Details for the file contextos_cli-0.1.0.tar.gz.

File metadata

  • Download URL: contextos_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for contextos_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 966673f2399d3d84630153a7284de600305e9d969c39515a9122f81afb4a5261
MD5 527d1ab8fd6b15cd184eb5592a289d2b
BLAKE2b-256 a37e066b96baa50504046488a26872fdfdbc9ddaa6cf0d15813275f8a0060ed3

See more details on using hashes here.

File details

Details for the file contextos_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: contextos_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for contextos_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd61ae684cb6c91a806558bca0956602b76dd292ae7df8e0d01c708c1b87970e
MD5 5c6c67fca7a9978b330e21f8d49c4e16
BLAKE2b-256 81e595e5d151f387874e9eec2a3034ebb474780809278389ae7b0a9832821fa4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page