Metadata-Version: 2.4
Name: cosmos-platform
Version: 1.6.0.dev6
Summary: Enforce file boundaries and test proof on AI coding agents (Claude Code, Codex, OpenCode).
Author: Cosmos Platform Contributors
License: Apache-2.0
Project-URL: Homepage, https://github.com/cosmos-semantic/cosmos
Project-URL: Repository, https://github.com/cosmos-semantic/cosmos
Project-URL: Issues, https://github.com/cosmos-semantic/cosmos/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: jsonschema>=4.0.0
Provides-Extra: desktop
Requires-Dist: pywebview>=4.0.0; extra == "desktop"
Provides-Extra: all
Requires-Dist: pywebview>=4.0.0; extra == "all"
Requires-Dist: cryptography>=41.0.0; extra == "all"
Requires-Dist: watchdog>=3.0.0; extra == "all"
Dynamic: license-file

# Cosmos Platform

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![Release](https://img.shields.io/badge/Release-Developer_Preview-orange.svg)](docs/VERSIONING.md)
[![Python](https://img.shields.io/badge/Python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue.svg)](pyproject.toml)

**Keep AI coding agents inside the files you approved — enforced by local hooks, not prompts.**

Cosmos is a local safety layer for the coding agent you already use.

1. **The problem.** AI coding agents such as Claude Code, Codex, and OpenCode drift out of scope on real tasks. They edit unrelated files, change protected configuration, or claim a test passed without running it once the context fills up. Instructions written in `AGENTS.md` or `CLAUDE.md` are not reliable enforcement; they are only suggestions to the model.

2. **What Cosmos does.** Cosmos runs on your machine beside your existing agent. It does not replace Claude Code, Codex, or OpenCode, and it does not ask you to switch IDE or route your code through a cloud proxy. Before a task starts, you declare which files the agent is allowed to touch and which command proves the fix worked. Local hooks — small programs your coding tool runs around every tool call — intercept the agent's actions in real time. An out-of-scope edit is blocked before it reaches disk, and the agent is told why so it can stay on track. Before you merge, Cosmos checks the real git diff and the verification output.

3. **Why you can trust it.** Enforcement happens in local hooks below the model, so it does not depend on the model choosing to follow instructions. It restrains the agent, not you: your own edits and commands still work. Everything runs on your machine. Cosmos is Apache-2.0 and in Developer Preview.

## 30-second quickstart

```bash
pip install --pre cosmos-platform
cosmos setup
cd your-repo && cosmos init .
cosmos packet contract --id task-1 --mode worker --allow src/auth.py
cosmos packet verify --contract .cosmos/contracts/task-1.json
cosmos status .
```

| Command | What it does |
|---|---|
| `pip install --pre cosmos-platform` | Installs the `cosmos` command. It changes nothing else. |
| `cosmos setup` | Connects the hooks to the coding tools installed on this machine. Run it once. |
| `cd your-repo && cosmos init .` | Creates the `.cosmos/` state inside your repository. |
| `cosmos packet contract --id task-1 --mode worker --allow src/auth.py` | Records one task and the only file it may change. |
| `cosmos packet verify --contract .cosmos/contracts/task-1.json` | Checks the real diff against that record. |
| `cosmos status .` | Shows whether Cosmos is active and what it is enforcing. |

## What you get

| Feature | What it does |
|---|---|
| **File boundaries** | The agent can only change the files you named for the task. Everything else is blocked before it hits disk. |
| **Proof before merge** | Cosmos reads the real git diff and runs the verification command you declared, so "the tests pass" has to be true. |
| **Stuck-agent detection** | A watchdog notices an agent that is looping or drifting away from the task and tells you. |
| **Continuity** | Decisions, context, and task state stay with the project, so a new session, a different model, or a different coding tool starts from the same ground truth. |
| **Health checks** | `cosmos status` and `cosmos doctor` report whether the hooks are active and the project state is intact. |

## Install

### Option A: one-line installer (tracks `main`)

**macOS / Linux:**
```bash
curl -fsSL https://raw.githubusercontent.com/cosmos-semantic/cosmos/main/install.sh | sh
```

**Windows (PowerShell):**
```powershell
irm https://raw.githubusercontent.com/cosmos-semantic/cosmos/main/install.ps1 | iex
```

The installer installs from the `main` branch of this repository, runs `cosmos setup` for you, and only reports success after the installed `cosmos` command has run. If it prints an error, nothing was installed. Set `COSMOS_PYTHON` to choose a specific interpreter (for example `C:\Python312\python.exe`).

### Option B: PyPI Developer Preview

```bash
pip install --pre cosmos-platform
cosmos setup
```

`pip install` only installs the `cosmos` CLI. It does not edit repositories, agent settings, hooks, or MCP configuration. **`cosmos setup` is the one machine-wide activation step**: it registers the Cosmos MCP server with Claude Code, OpenCode, and Codex when they are installed, and installs the two local hooks — Guard (file boundaries) and Watchdog (stuck-agent detection). Run it once per machine.

### Option C: from a clone

```bash
git clone https://github.com/cosmos-semantic/cosmos.git
cd Cosmos
```

Then run `sh install.sh` (macOS / Linux) or `.\install.ps1` (Windows PowerShell) from inside the clone. This installs your checkout in editable mode and runs `cosmos setup`.

## How it works: once per machine, then per repository

1. **Once per machine:** `cosmos setup` registers Cosmos with the agent tools you have and installs the Guard (file boundaries) and Watchdog (stuck-agent detection) hooks. Every project you open afterwards uses that one registration.
2. **Per repository:** the project state attaches on first use, with nothing to run. You can also prepare it explicitly:
   - `cosmos init .` pre-creates the project state (`cosmos.environment.json`, `.cosmos/graph.json`, the first inspection, the retrieval index). It writes no per-project tool configuration and installs **no Git hooks**.
   - `cosmos init . --pin` additionally writes project-local configs: `.mcp.json`, `CLAUDE.local.md`, `opencode.json`, `.codex/config.toml`, `.cosmos/CURRENT.md`, and `.cosmos/AGENT-RULES.md`. Use this when you want the project to carry its own connection instead of relying on the global one.

```bash
cd /path/to/my-project
cosmos init .
cosmos status
```

## Works with your coding agent

| Tool | How Cosmos connects |
|---|---|
| **Claude Code** | Automatic: `cosmos setup` registers the MCP server and hooks. |
| **OpenCode** | Automatic: `cosmos setup` registers the MCP server and watchdog plugin. |
| **Codex** | Automatic: `cosmos setup` registers the MCP server; `cosmos init --pin` can also write `.codex/config.toml`. |
| **Cursor** | File-based: point it at the project's `AGENTS.md` when present and the project state files (`cosmos.environment.json`, `.cosmos/graph.json`). |
| **Cline / Roo / VS Code** | File-based: read the project's `AGENTS.md` when present, plus the project state files. |
| **Aider** | File-based: read the project's `AGENTS.md` when present, plus the project state files. |

## Repository map

| Path | What lives there |
|---|---|
| `tools/` | The `cosmos` CLI, hooks, MCP server, merge gate, and supporting tools. |
| `runtime/` | The execution runtime and its tests. |
| `docs/` | Product, operator, architecture, and governance documentation. |
| `governance/` | Policies, decisions, and obligations. |
| `spec/` | Interface and contract specifications. |
| `fixtures/` | Reference projects for developer, personal, company, and execution-stack use. |
| `catalogs/` | Capability and model catalogs. |
| `releases/` | Immutable release baselines. |
| `research/` | Background research and design notes. |

## Documentation

- [Quickstart](docs/QUICKSTART.md) — install, activate, and get a first win.
- [Operator Guide](docs/OPERATOR-GUIDE.md) — the practical first-project workflow.
- [Architecture](docs/ARCHITECTURE.md) — how the runtime, the hooks, and the merge gate fit together.
- [Vision](docs/VISION.md) and [Principles](docs/PRINCIPLES.md) — why Cosmos exists and the rules it holds itself to.
- [Universe and World model](docs/UNIVERSE-AND-WORLD-MODEL.md) — the vocabulary behind Worlds, Cosmos Prime, and world families.
- [Versioning](docs/VERSIONING.md) — release policy and the current Developer Preview line.
- [Original plan](docs/ORIGINAL-PLAN.md) — the immutable record of the approved original plan.
- [Contributing](CONTRIBUTING.md) and [Security](SECURITY.md).

## License

Cosmos is licensed under the [Apache License 2.0](LICENSE). The Community tier is free and open source; trust features such as the merge gate, the vault, the watchdog, and the scorecard are never paywalled.
