Metadata-Version: 2.4
Name: thecode-agent
Version: 0.1.0
Summary: A secure, provider-independent coding agent for the terminal
Author: TheCode contributors
License: MIT License
        
        Copyright (c) 2026 TheCode contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
License-File: LICENSE
Requires-Python: >=3.12
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2.7
Requires-Dist: python-dotenv>=1.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.7
Requires-Dist: textual<8.0,>=6.0
Requires-Dist: typer>=0.12.3
Provides-Extra: dev
Requires-Dist: mypy<2.0,>=1.10; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.2; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
Description-Content-Type: text/markdown

# TheCode

TheCode is a provider-independent AI coding agent with a premium Textual terminal interface. It can inspect code, search files, plan changes, edit files with approval, execute bounded commands, run tests, analyze Git, and retain local session history.

> TheCode is an early product foundation. Review proposed actions and keep important work under version control.

## Requirements and installation

- Python 3.12+
- Git
- Ripgrep is recommended

```bash
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
cp .env.example .env
thecode config --setup
thecode doctor
```

## Usage

```bash
thecode
thecode chat
thecode ask "how does authentication work?"
thecode plan "migrate JWT to OAuth2"
thecode run "fix the failing tests"
thecode review
thecode init
thecode config
thecode models
thecode sessions
thecode resume SESSION_ID
thecode undo SESSION_ID
```

`thecode init` creates `.nexus/config.yaml` and `NEXUS.md` without overwriting existing files. The former `tablutech` and `nexus` commands remain compatibility aliases.

## Configuration

Global configuration is read from `~/.nexus/config.yaml`; project configuration from `.nexus/config.yaml` takes precedence. Provider secrets belong in environment variables, never YAML.

```yaml
llm:
  provider: openrouter
  model: anthropic/claude-sonnet-4
agent:
  max_steps: 30
permissions:
  mode: ask
context:
  max_characters: 120000
```

Supported providers are OpenRouter, OpenAI, Anthropic, and Ollama. Set the corresponding key from `.env.example`.
Run `thecode config --setup` to choose the provider and model interactively. API keys are
entered with hidden input and stored only in the project `.env`, which is ignored by Git.

## Safety model

Every path is resolved against the project root, including symlinks. Sensitive files require explicit authorization. Commands use argument arrays, never `shell=True`; shell operators and destructive patterns are blocked. Write tools preserve previous content, and session rollback refuses to overwrite subsequent user edits.

Permission modes:

- `safe`: reads are automatic; writes and commands require confirmation.
- `ask`: reads are automatic; mutating actions request approval.
- `auto`: low-risk operations are automatic; high-risk actions still ask and critical actions remain blocked.

## Architecture

The CLI composes an agent loop, a provider-neutral LLM interface, a typed tool registry, deterministic permission/security layers, repository services, and SQLite session storage. Providers normalize their native tool-call formats into `LLMResponse`; tools expose Pydantic JSON schemas and return `ToolResult`. This keeps provider, UI, and execution concerns independent.

Project instruction priority is `NEXUS.md`, `AGENTS.md`, `CLAUDE.md`, `CONTRIBUTING.md`, then `README.md`.

## Development

```bash
ruff check .
mypy nexus
pytest
```

HTTP providers are designed for `httpx.MockTransport`; tests do not require live API access.
