The AI coding agent you can read in an afternoon. ~2000 lines of Python, fully hackable.
Project description
mini-cognit-cli
The AI coding agent you can read in an afternoon.
pip install mini-cognit-cli
Why mini-cognit-cli?
Every AI coding agent (Claude Code, aider, Kimi CLI, Codex) is a black box with tens of thousands of lines of code. mini-cognit-cli takes the opposite approach:
- ~2000 lines of Python — read the entire codebase, understand every decision
- Add a custom tool in ~30 lines — no plugin system, no abstractions, just a function
- Any OpenAI-compatible API — OpenAI, Anthropic (via proxy), Ollama, LM Studio, anything
- Fork and make it yours — designed to be the starting point for your agent
| Claude Code | aider | Kimi CLI | mini-cognit-cli | |
|---|---|---|---|---|
| Codebase | ~100k+ lines | ~50k+ lines | ~30k+ lines | ~2k lines |
| Time to understand | Weeks | Days | Days | An afternoon |
| Add a custom tool | Plugin system | Moderate | Plugin / MCP | ~30 lines |
| Provider lock-in | Anthropic | Any | Multi-provider | Any OpenAI-compatible |
| Language | TypeScript | Python | Python | Python |
Quickstart
# Install
pip install "mini-cognit-cli[cli]"
# Configure (pick one)
export OPENAI_API_KEY="sk-..." # env var
# OR: create cognit.toml with provider config # config file
# Go
cognit chat
That's it. The agent can read/write files, run shell commands, search code, browse the web, and more.
Features
Tools — file read/write/edit, shell execution, grep, glob, web search, URL fetch, image reading
Session management — auto-save, --continue to resume, --session <id> to pick a specific session
Image support — /paste-image from clipboard, /img <path> to attach, vision models analyze images
@ file references — type @filename with Tab autocomplete to reference files in your message
Agent Skills — drop a SKILL.md in .cognit/skills/ to teach the agent new workflows (compatible with Claude/Codex skill format)
Context compaction — auto-summarizes when approaching token limits, or /compact to manually compress
Extended thinking — --thinking flag for reasoning models
Tool approval — shell commands need confirmation; --yolo to auto-approve everything
Usage
# Basic
cognit chat
# Specify model
cognit chat -m gpt-4o
# Resume last session
cognit chat --continue
# YOLO mode (auto-approve all tools)
cognit chat --yolo
# Extended thinking
cognit chat --thinking
# List saved sessions
cognit sessions
In-session commands
| Command | Description |
|---|---|
/help |
Show all commands |
/clear |
Clear conversation and start new session |
/compact |
Manually compress context |
/sessions |
List saved sessions |
/paste-image |
Paste image from clipboard |
/img <path> |
Attach an image file |
@path/to/file |
Reference a file (Tab to autocomplete) |
/exit |
Quit (auto-saves session) |
Configuration
Create cognit.toml in your project directory or ~/.config/cognit/:
[providers.my_provider]
type = "openai"
base_url = "https://api.openai.com/v1"
api_key = "sk-..."
[models.default]
provider = "my_provider"
model = "gpt-4o"
max_context_size = 128000
Priority: CLI flags > cognit.toml > environment variables.
SDK usage
from cognit import CognitAgent
agent = CognitAgent(model="gpt-4o", api_key="sk-...")
# Add custom tools
@agent.tool(name="my_tool", description="Does something")
async def my_tool(query: str) -> str:
return f"result for {query}"
# Chat (context preserved between calls)
result = await agent.chat("What files are here?")
result = await agent.chat("Read the first one.")
# With image
result = await agent.chat("Describe this", images=["data:image/png;base64,..."])
Architecture
src/cognit/ (~2000 lines total)
├── cli.py ← CLI entry point (Typer)
├── app.py ← REPL orchestrator
├── config.py ← TOML config loading
├── sdk.py ← Programmatic SDK interface
├── llm/
│ ├── provider.py ← Abstract LLM interface
│ ├── openai_provider.py ← OpenAI-compatible implementation
│ ├── generate.py ← LLM call + streaming assembly
│ └── message.py ← Message model (text, images, tool calls)
├── soul/
│ ├── agent.py ← Core agent loop (the brain)
│ ├── context.py ← Conversation history
│ ├── compaction.py ← Context summarization
│ ├── session.py ← Session persistence
│ ├── skills.py ← Agent Skills (SKILL.md) loading
│ └── toolset.py ← Tool registry + dispatch
├── tools/
│ ├── file_read.py ← Read files
│ ├── file_write.py ← Write/edit files
│ ├── glob_tool.py ← File pattern matching
│ ├── grep.py ← Search file contents
│ ├── shell.py ← Shell execution
│ ├── web_search.py ← Web search (DuckDuckGo)
│ ├── fetch_url.py ← Fetch web pages
│ └── media_read.py ← Read images for vision
└── ui/
└── terminal.py ← Terminal I/O (prompt-toolkit + rich)
Each module has a clear responsibility. The entire flow:
User input → Agent.run() → LLM call → Tool execution → Loop until done → Response
Adding a custom tool
# src/cognit/tools/my_tool.py
from cognit.soul.toolset import Toolset
def register(toolset: Toolset) -> None:
@toolset.tool(name="my_tool", description="Does something useful.")
async def my_tool(query: str, limit: int = 10) -> str:
return f"Result: {query} (limit={limit})"
Register in sdk.py's _register_builtin_tools():
from cognit.tools import my_tool
my_tool.register(toolset)
That's it. The decorator auto-infers JSON Schema from type hints.
Agent Skills
Drop a SKILL.md file in .cognit/skills/your-skill/SKILL.md:
---
name: code-review
---
When asked to review code, follow these steps:
1. Read the changed files
2. Check for bugs, security issues, and style problems
3. Suggest improvements with code examples
Skills are auto-discovered from .cognit/skills/, ~/.cognit/skills/, and compatible with .claude/skills/ and .codex/skills/.
Requirements
- Python >= 3.12
- Works with any OpenAI-compatible API (OpenAI, Anthropic via proxy, Ollama, LM Studio, etc.)
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mini_cognit_cli-0.2.2.tar.gz.
File metadata
- Download URL: mini_cognit_cli-0.2.2.tar.gz
- Upload date:
- Size: 310.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d58da4c0db5ec224096bdbb0dc21eeb833165bc77711e24fc595e650379f81df
|
|
| MD5 |
8abd6e9f7f8e6c94d0d0a8e8bd75ab21
|
|
| BLAKE2b-256 |
43647da81eef92cc1f35444c4ecafcff629ee98f0e08004837987db50fe2460e
|
Provenance
The following attestation bundles were made for mini_cognit_cli-0.2.2.tar.gz:
Publisher:
publish.yml on gxPan1006/mini-cognit-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mini_cognit_cli-0.2.2.tar.gz -
Subject digest:
d58da4c0db5ec224096bdbb0dc21eeb833165bc77711e24fc595e650379f81df - Sigstore transparency entry: 1179807468
- Sigstore integration time:
-
Permalink:
gxPan1006/mini-cognit-cli@01dc1cf3e880173ba58192c5ee7dcae3e8506200 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/gxPan1006
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01dc1cf3e880173ba58192c5ee7dcae3e8506200 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mini_cognit_cli-0.2.2-py3-none-any.whl.
File metadata
- Download URL: mini_cognit_cli-0.2.2-py3-none-any.whl
- Upload date:
- Size: 43.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1ff541e61bb6e877bfc948c4421a5edccc5a938a0be758b6db224bd7d2bd0ba
|
|
| MD5 |
7dccfebcbaad738394aa04ff06cbb9f3
|
|
| BLAKE2b-256 |
b901e194d3ef57cd147c5abbf7c29f1d5f682990d170a54a6c9308461212956a
|
Provenance
The following attestation bundles were made for mini_cognit_cli-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on gxPan1006/mini-cognit-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mini_cognit_cli-0.2.2-py3-none-any.whl -
Subject digest:
e1ff541e61bb6e877bfc948c4421a5edccc5a938a0be758b6db224bd7d2bd0ba - Sigstore transparency entry: 1179807474
- Sigstore integration time:
-
Permalink:
gxPan1006/mini-cognit-cli@01dc1cf3e880173ba58192c5ee7dcae3e8506200 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/gxPan1006
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01dc1cf3e880173ba58192c5ee7dcae3e8506200 -
Trigger Event:
push
-
Statement type: