Spatial architecture canvas and context optimization OS for AI coding agents. AST-sliced task contexts (99.4% token reduction), persistent architecture graphs across sessions, and test-gated verification via MCP.
1
stars
184
commits
JavaScript
primary language
Sep 11, 2026
updated
Spatial Architecture Canvas & Context Optimization Operating System for AI Coding Agents
AST-sliced task contexts (99.4% token reduction) · Cross-session architecture memory · Deterministic verification gates
中文文档 · Download Native App (macOS 14+) · Headless CLI / Windows · Empirical Benchmarks · MCP Directory
Navigate spatial architecture → trace execution chains → deliver symbol locators to agents → verify deterministic evidence.
Modern AI coding agents (Claude Code, Cursor, Windsurf, Codex, Devin) encounter a structural bottleneck when scaled to medium-to-large software repositories: Context Window Saturation and Architectural Entropy.
ContextOS solves this by establishing a dual-plane operating system:
path::symbol), enforces strict token budgets, and manages cryptographic test execution receipts.ContextOS is primarily designed and distributed as a native macOS application built with SwiftUI, Metal rendering, and embedded SQLite caching.
13/13 100% Passed) backed by concrete test cases and compiler receipts.![]() | ![]() |
| Trace upstream & downstream impact before writing code. | Inspect verifiable test receipts behind completion. |
Download the standalone application package directly from GitHub Releases:
.zip application bundle — zero DMG translocation anomalies).The following results were measured directly on a real-world repository (54 Architectural Blocks, 8 Chains, 80 Directed Links, 19 Checkpoints) using the reproducible benchmark suite (npm run benchmark):
| Evaluation Dimension | Baseline (Conventional File Ingestion) | ContextOS (AST Task Slice) | Empirical Delta |
|---|---|---|---|
| Task Context Window | 689,403 chars (~183,571 tokens) | 3,993 chars (~1,125 tokens) | 99.4% Token Reduction |
| 4-Module Execution Chain | 139,247 chars (~34,812 tokens) | 2,056 chars (~530 tokens) | 98.5% Token Reduction |
| Terminal Log Diagnostics | 16,083 chars (~4,042 tokens) | 826 chars (~211 tokens) | 94.8% Compression |
| Context Retrieval Latency | Sequential File Traversal | 29.68 ms (P50) | Sub-30ms Instant Lookup |
| Topological Drift & Recall | High Hallucination Risk | 100% Target Module Recall | Zero Architectural Drift |
To reproduce these metrics locally on your own machine:
npm run benchmark
For headless CI/CD pipelines, remote servers, Windows, Linux, or users who do not require the visual desktop application, ContextOS runs headlessly via Node.js (≥22):
# 1. Initialize and automatically scan existing codebase topology
npx -y github:yubinbin32-ops/ContextOS init --scan
# 2. Inspect project architecture health, sync state, and verification gates
npx -y github:yubinbin32-ops/ContextOS status
# 3. Configure local MCP client integrations
npx -y github:yubinbin32-ops/ContextOS setup
flowchart LR
Human["Developer\nNative Spatial Canvas"] <--> Plaintext[".contextos/graph.json\nGit-Tracked Truth"]
Plaintext <--> Engine["Local SQLite Cache\nContext Engine"]
Engine --> Slice["AST-Sliced Task Context\n(path::symbol locators)"]
Slice --> Agent["AI Coding Agent\n(via MCP)"]
Agent --> Evidence["Test Execution Receipt"]
Evidence --> Gate{"Verification Gate"}
Gate -->|Passed| Plaintext
Gate -->|Failed| Alert["Drift Warning & Retest"]
path::symbol)Instead of flooding the LLM context with full file dumps, ContextOS returns compact locators: target path, symbol signature, derived line boundaries, and interface contracts. The host editor opens only the target method.
graph.json)The durable source of truth is a formatted, deterministic JSON file (.contextos/graph.json) versioned in Git alongside source code. A git checkout or git revert simultaneously restores code and architecture. An embedded SQLite engine provides zero-latency indexed queries with zero external runtime npm dependencies.
Completion states cannot be asserted by AI declaration. They require execution receipts (npm test, compiler diagnostics) logged through run_command and bound via checkpoint_record. Any modification to bound source code automatically transitions dependent checkpoints to retest_required.
The command gateway intercepts terminal execution, strips ANSI sequences and progress bars, redacts local paths and secrets, and condenses repetitive logs into structured diagnostic summaries (94.8% token compression).
ContextOS integrates natively via standard stdio Model Context Protocol (MCP).
Add to your MCP configuration file (e.g. ~/.cursor/mcp.json or claude_desktop_config.json):
{
"mcpServers": {
"contextos": {
"command": "npx",
"args": ["-y", "github:yubinbin32-ops/ContextOS", "serve"]
}
}
}
Or point directly to the bundled standalone engine:
{
"mcpServers": {
"contextos": {
"command": "node",
"args": ["/absolute/path/to/contextos-mcp.mjs"],
"env": {
"CONTEXTOS_PROJECT_ROOT": "${workspaceFolder}"
}
}
}
}
ContextOS is built with zero external runtime npm dependencies:
# Clone the repository
git clone https://github.com/yubinbin32-ops/ContextOS.git && cd ContextOS
# Install build dependencies
npm ci
# Run the 55-test verification suite
npm test
# Run the empirical benchmark suite
npm run benchmark
# Build the MCP bundled server
npm run plugin:build
# Verify MCP protocol handshake & tool surface
npm run plugin:verify
# Build the native macOS desktop application
npm run desktop:build
ContextOS is an open-source project distributed under the MIT License. Contributions, benchmark validations, and feature requests are welcome.
© 2026 ContextOS Contributors.
184 commits
JavaScript
84.4%
Swift
15.4%
Spatial architecture canvas and context optimization OS for AI coding agents. AST-sliced task contexts (99.4% token reduction), persistent architecture graphs across sessions, and test-gated verification via MCP.
1
stars
184
commits
JavaScript
primary language
Sep 11, 2026
updated
Spatial Architecture Canvas & Context Optimization Operating System for AI Coding Agents
AST-sliced task contexts (99.4% token reduction) · Cross-session architecture memory · Deterministic verification gates
中文文档 · Download Native App (macOS 14+) · Headless CLI / Windows · Empirical Benchmarks · MCP Directory
Navigate spatial architecture → trace execution chains → deliver symbol locators to agents → verify deterministic evidence.
Modern AI coding agents (Claude Code, Cursor, Windsurf, Codex, Devin) encounter a structural bottleneck when scaled to medium-to-large software repositories: Context Window Saturation and Architectural Entropy.
ContextOS solves this by establishing a dual-plane operating system:
path::symbol), enforces strict token budgets, and manages cryptographic test execution receipts.ContextOS is primarily designed and distributed as a native macOS application built with SwiftUI, Metal rendering, and embedded SQLite caching.
13/13 100% Passed) backed by concrete test cases and compiler receipts.![]() | ![]() |
| Trace upstream & downstream impact before writing code. | Inspect verifiable test receipts behind completion. |
Download the standalone application package directly from GitHub Releases:
.zip application bundle — zero DMG translocation anomalies).The following results were measured directly on a real-world repository (54 Architectural Blocks, 8 Chains, 80 Directed Links, 19 Checkpoints) using the reproducible benchmark suite (npm run benchmark):
| Evaluation Dimension | Baseline (Conventional File Ingestion) | ContextOS (AST Task Slice) | Empirical Delta |
|---|---|---|---|
| Task Context Window | 689,403 chars (~183,571 tokens) | 3,993 chars (~1,125 tokens) | 99.4% Token Reduction |
| 4-Module Execution Chain | 139,247 chars (~34,812 tokens) | 2,056 chars (~530 tokens) | 98.5% Token Reduction |
| Terminal Log Diagnostics | 16,083 chars (~4,042 tokens) | 826 chars (~211 tokens) | 94.8% Compression |
| Context Retrieval Latency | Sequential File Traversal | 29.68 ms (P50) | Sub-30ms Instant Lookup |
| Topological Drift & Recall | High Hallucination Risk | 100% Target Module Recall | Zero Architectural Drift |
To reproduce these metrics locally on your own machine:
npm run benchmark
For headless CI/CD pipelines, remote servers, Windows, Linux, or users who do not require the visual desktop application, ContextOS runs headlessly via Node.js (≥22):
# 1. Initialize and automatically scan existing codebase topology
npx -y github:yubinbin32-ops/ContextOS init --scan
# 2. Inspect project architecture health, sync state, and verification gates
npx -y github:yubinbin32-ops/ContextOS status
# 3. Configure local MCP client integrations
npx -y github:yubinbin32-ops/ContextOS setup
flowchart LR
Human["Developer\nNative Spatial Canvas"] <--> Plaintext[".contextos/graph.json\nGit-Tracked Truth"]
Plaintext <--> Engine["Local SQLite Cache\nContext Engine"]
Engine --> Slice["AST-Sliced Task Context\n(path::symbol locators)"]
Slice --> Agent["AI Coding Agent\n(via MCP)"]
Agent --> Evidence["Test Execution Receipt"]
Evidence --> Gate{"Verification Gate"}
Gate -->|Passed| Plaintext
Gate -->|Failed| Alert["Drift Warning & Retest"]
path::symbol)Instead of flooding the LLM context with full file dumps, ContextOS returns compact locators: target path, symbol signature, derived line boundaries, and interface contracts. The host editor opens only the target method.
graph.json)The durable source of truth is a formatted, deterministic JSON file (.contextos/graph.json) versioned in Git alongside source code. A git checkout or git revert simultaneously restores code and architecture. An embedded SQLite engine provides zero-latency indexed queries with zero external runtime npm dependencies.
Completion states cannot be asserted by AI declaration. They require execution receipts (npm test, compiler diagnostics) logged through run_command and bound via checkpoint_record. Any modification to bound source code automatically transitions dependent checkpoints to retest_required.
The command gateway intercepts terminal execution, strips ANSI sequences and progress bars, redacts local paths and secrets, and condenses repetitive logs into structured diagnostic summaries (94.8% token compression).
ContextOS integrates natively via standard stdio Model Context Protocol (MCP).
Add to your MCP configuration file (e.g. ~/.cursor/mcp.json or claude_desktop_config.json):
{
"mcpServers": {
"contextos": {
"command": "npx",
"args": ["-y", "github:yubinbin32-ops/ContextOS", "serve"]
}
}
}
Or point directly to the bundled standalone engine:
{
"mcpServers": {
"contextos": {
"command": "node",
"args": ["/absolute/path/to/contextos-mcp.mjs"],
"env": {
"CONTEXTOS_PROJECT_ROOT": "${workspaceFolder}"
}
}
}
}
ContextOS is built with zero external runtime npm dependencies:
# Clone the repository
git clone https://github.com/yubinbin32-ops/ContextOS.git && cd ContextOS
# Install build dependencies
npm ci
# Run the 55-test verification suite
npm test
# Run the empirical benchmark suite
npm run benchmark
# Build the MCP bundled server
npm run plugin:build
# Verify MCP protocol handshake & tool surface
npm run plugin:verify
# Build the native macOS desktop application
npm run desktop:build
ContextOS is an open-source project distributed under the MIT License. Contributions, benchmark validations, and feature requests are welcome.
© 2026 ContextOS Contributors.
184 commits
JavaScript
84.4%
Swift
15.4%