Sovereign agentic CLI β forge, delegate, persist.
Imperial Fists colourway. Built for engineers who think in terminals.
Cogitum is a terminal-native AI agent with a multi-provider LLM mesh, 17 built-in tools, persistent sessions, memory, 83 bundled skills, checkpoints, and a Telegram gateway β all wrapped in a keyboard-driven TUI that stays out of your way.
| Feature | Why it matters |
|---|---|
| πΈοΈ Multi-Provider Mesh | Load-balance across OpenAI, Anthropic, OpenRouter, Cerebras, Groq, CanopyWave, and any OpenAI-compatible endpoint. Automatic failover, key pooling, rate-limit tracking. |
| π§° 17 Built-in Tools | Terminal, browser (Playwright), web search, file read/write/edit, git-style search, memory, skills, checkpoints, delegation, MCP servers. |
| π‘οΈ Approval Layer | Dangerous operations (rm, git push, package installs) pause for your approval. Per-tool risk levels. |
| πΎ Persistent Sessions | Every conversation is auto-saved as JSONL. Resume anytime with /resume. Search across sessions. |
| π§ Memory & Skills | Cross-session memory + 83 bundled skills (coding, research, MLOps, red-teaming, smart-homeβ¦) injected into every system prompt. |
| π¦ Cogit Checkpoints | One-command project snapshots before destructive edits. Restore, diff, garbage-collect. |
| π― Self-Learning Skills | The agent observes your workflow and writes its own skills via the skills tool β refining its expertise for your specific projects over time. |
| βοΈ Cogitator Legion | Recursive 2-level swarm. The lead Cogitum spawns up to 5 parallel Cogitators (L1); each may further dispatch up to 3 sub-Cogitators (L2). Real-time sibling roster, async message bus, click the dispatch card to open a live tree view. Replaces the old single-shot delegation. |
| π‘ Telegram Gateway | Run the same agent as a personal Telegram bot with streaming, inline keyboards, and media support. |
| π MCP Integration | Connect external MCP servers (stdio / HTTP) β tools are auto-discovered and registered dynamically. |
- Feed β streaming markdown bubbles, tool cards, thinking blocks, queued messages.
- Inspector β live token count, context window usage, model info.
- Queue Bar β pending messages while the agent works. Press
βon empty composer to edit the last queued item. - Composer β slash commands (
/setup,/models,/resume,/clear,/quit), history withβ/β, paste folding for long content.
- Live search across all resolved models (ID, alias, provider, capabilities).
- Fuzzy scoring fallback via
rapidfuzz. - Toggle filters:
text,vision,reasoning,tools,caching,free, context size. - Detail pane with cost, key health, and capabilities.
- Search across saved sessions.
- Preview pane shows last 8 messages with role badges.
β/βnavigate,Enterresume,Deleteremove.
- Add providers from presets or custom config.
- OAuth / PKCE for Claude Pro/Max and ChatGPT Plus/Pro.
- Four secret backends:
env,vault(AES-256-GCM),keyring,plain. - Live connectivity testing before you save.
Three install paths. Pick whichever matches your platform / habits.
npm install -g cogitum
cogThe npm package is a thin launcher; npm install -g just registers the cog and cogitum commands. The first cog invocation bootstraps the Python backend (clones the repo, creates a venv, installs deps) β this happens once, then every subsequent launch runs at native Python speed.
| Wrapper command | Effect |
|---|---|
cog |
Launch the TUI (auto-bootstraps on first run) |
cog setup |
Run the provider wizard |
cog --update |
Pull latest from origin/master, reinstall deps |
cog --repair |
Wipe and recreate the venv |
cog --where |
Print the install directory |
cog --version-wrapper |
Print npm-wrapper version + install metadata |
Anything else is forwarded to python -m cogitum.cli.
Do not use
sudo npm install -g. If you hitEACCESerrors, fix npm permissions or use a Node version manager (nvm, fnm, volta).
curl -fsSL https://raw.githubusercontent.com/StarryCod/cogitum/master/scripts/install.sh | bashClones to ~/.local/share/cogitum, builds a venv, installs all extras, writes cog / cogitum bash shims to ~/.local/bin (ensure that's on your PATH).
iwr https://raw.githubusercontent.com/StarryCod/cogitum/master/scripts/install.ps1 | iexClones to %LOCALAPPDATA%\cogitum, builds a venv, installs all extras, writes cog.cmd / cogitum.cmd shims to %LOCALAPPDATA%\Microsoft\WindowsApps (which is on PATH by default on Windows 10/11).
If you prefer manual install:
# 1. Prerequisites β Python 3.11+ and Git on PATH
python --version
git --version
# 2. Clone + install
git clone https://github.com/StarryCod/cogitum.git $env:LOCALAPPDATA\cogitum
cd $env:LOCALAPPDATA\cogitum
python -m venv .venv
.venv\Scripts\pip install -e ".[all]"
# 3. Run
.venv\Scripts\python -m cogitum.cli setup
.venv\Scripts\python -m cogitum.cligit clone https://github.com/StarryCod/cogitum.git
cd cogitum
pip install -e ".[all]"
cog setup
cogRequirements: Python 3.11+, Git. Optional: Node.js 16+ if installing via npm.
| Key | Action |
|---|---|
Enter |
Send message |
Shift+Enter / Ctrl+Enter |
New line in composer |
β / β |
Browse message history (when cursor at edge) |
/ |
Open slash-command autocomplete |
Esc |
Cancel running agent |
Ctrl+P |
Open model picker |
Ctrl+S |
Open setup wizard |
Ctrl+C |
Copy selection (or "Use Ctrl+Q to quit" hint) |
Ctrl+Q |
Quit |
| Command | Description |
|---|---|
/setup |
Provider & auth wizard |
/models |
Browse and switch models |
/model <id> |
Direct model switch |
/new |
Fresh session |
/resume |
Resume past session |
/title <name> |
Rename session |
/tools |
List available tools |
/mcp |
MCP server status |
/mcp reload |
Hot-reload MCP config |
/godmode <on/off/list> |
Toggle aggressive system prompts |
/clear |
Clear feed |
/quit |
Exit |
read_fileβ paginated file reading with line numbers. Blocks sensitive paths.write_fileβ auto-cogit before overwrite.edit_fileβ exact find-and-replace with context preview.append_fileβ safe append.search_filesβ ripgrep fallback with timeout caps.list_dirβ sorted directory listing.
terminalβ three modes: normal, timeout, background (PID management, stdin/stdout streaming).- Dangerous commands auto-save a checkpoint before execution.
fetch_urlβ SSRF-protected HTTP fetch with HTML stripping.web_searchβ DuckDuckGo, no API key required.browserβ Persistent Playwright session:open,click,type,extract,screenshot,scroll,act(JS eval).
memoryβ Persistent key-value notes (user.md+memory.md) injected into every system prompt.skillsβ Markdown skill library with YAML frontmatter, categories, fuzzy search.session_searchβ Search and read past conversation sessions.
Cogitum includes its own git-like checkpoint system called cogit. It is not a wrapper around git β it is a standalone, content-addressable snapshot engine designed specifically for AI agent workflows.
| Command | Action |
|---|---|
cogit save [label] [path] |
Snapshot files, directories, or the entire project |
cogit list |
Show all checkpoints with timestamp, label, and file count |
cogit restore <index> |
Roll back to a previous checkpoint |
cogit diff <index> |
See added / removed / modified files vs. now |
cogit cleanup |
Delete old checkpoints, keep last 10 |
- Content-addressed storage β File blobs are deduplicated by SHA; manifests store
{path β sha}references. - Project-scoped β Checkpoints are keyed to a stable hash of the project directory; restore refuses to write into a mismatched path.
- Pre-restore safety β
restore()automatically saves a__pre_restore__snapshot of the current state before overwriting anything. - Orphan deletion β Restoring removes files that exist now but were absent in the checkpoint, so the working tree truly matches the saved state.
The agent automatically creates a cogit checkpoint before every destructive operation:
write_fileβ before overwriting an existing fileedit_fileβ before any find-and-replaceterminalβ before running dangerous commands (rm,git reset --hard,drop table, package installs, etc.)cogit restoreβ before rolling back (courtesy save)
This means you can always say "undo that" β even if the agent made a mistake, you can revert to the exact state before the change.
Off by default. Open the setup wizard (
Ctrl+S) β Experimental β enable Cogitator Legion β restart Cogitum. The toggle writes[experimental] legion_enabled = truetosettings.toml. Until the flag is on, thelegiontool is hidden from the agent and the lead Cogitum behaves exactly like before.
When a task naturally splits into independent pieces (refactor + tests + docs, multi-file audit, parallel research), the lead Cogitum dispatches a Legion β a parallel team of Cogitators that work simultaneously, talk to each other, and report back to the Magos.
ββ L0: lead Cogitum (you talk to it) ββ
β β
ββββββΌββββ 5 L1 Cogitators (parallel) βββββββΌβββββ
β β β β
β βββ΄β each may spawn up to 3 L2 sub-Cogitators ββ
β β β
βββL1: alpha beta gamma delta epsilon βββββ
β β
βββββ΄ββββ βββββ΄ββββ
L2: a.1 a.2 L2: e.1
- 2 levels max. L2 cannot spawn L3 β
legionis removed from their tool schema. - Same toolset. Every Cogitator has the lead Cogitum's full tool catalog (terminal, file ops, browser, MCP, skills, β¦).
- Async messaging. Cogitators see a real-time roster of all siblings (id, goal, status, last action) on every turn, plus an inbox of messages they received. Use
legion_message(to, body)to coordinate or*to broadcast. - Live tree view. Click the LEGION card in the feed to open a full-screen modal: L0 root at the top, L1 row underneath, each L1's L2 children below it, plus a detail pane for the selected node. ββ to navigate.
| Use legion | Don't use legion |
|---|---|
| Independent subtasks (refactor + tests + docs) | Sequential steps (write file β run it β read result) |
| Parallel research over different sources | Single-shot questions |
| Multi-file audit (each L1 handles a chunk) | Tasks that need shared mutable state |
The lead Cogitum decides when to dispatch β you don't have to invoke it explicitly. Just describe the work and it'll split if appropriate.
Battle-tested in real workflows, not just toy demos. One verified user session on 0.4.0:
736 messages Β· 343 turns Β· 4 h 27 min uptime Β· no crash
That's a single conversation with the agent doing real work β multi-provider failover under rate-limit pressure, hundreds of tool invocations, mesh hot-reload between turns, persistent context maintained throughout. The mesh's per-key cooldown ladder, agent-level retry layer, and prompt caching together keep long sessions stable across providers without manual intervention.
0.5.0 hardens this further with a per-class error backoff (separate curves for rate_limit, quota, overloaded, network, server), a 32K output-tokens floor that prevents mid-sentence cutoffs, and an optional confirmation modal for stuck retries (off by default).
Cross-platform & UX
- πΌ TG Gateway runs on Windows. Detached process + HKCU\Run autostart, no NSSM needed. Same TUI flow on Linux (
systemctl --user) and Windows. Stop is now under a second β old behaviour was waiting up to 30s for the long-poll to time out. - β‘ Setup wizard 30Γ faster.
tomlkitparse caching with mtime invalidation: navigation between sections that took 4+ seconds now takes <150ms. Also fixed a Textual race that occasionally left the wizard with an empty content pane. - π Diagnostics shows live counters. Was using a freshly-built mesh (zero counters) β now reads the in-process mesh so
req/toknumbers reflect actual usage with aΞ£ requests / Ξ£ tokenssummary at the top.
Models & providers
- π GPT-5.5 family added (
gpt-5.5,gpt-5.5-mini,gpt-5.5-nano) for both OpenAI API and ChatGPT Codex subscription presets. - π Dynamic refresh on every entry.
/v1/modelsis hit in parallel for every provider on TUI start, on/modelsopen, and on Setup Wizard close. Subscription providers (oauth:) get auto-seeded from a built-in catalogue, so oldproviders.tomlfiles pick up new GPT-5.5 entries without re-running the wizard. - π‘ Better OAuth error messages. Cloudflare challenge pages and 503 HTML used to surface as cryptic
JSONDecodeError; now you see content-type + body preview so you know what to fix.
Stability & retries
- π― Smart error classifier.
RATE_LIMIT / QUOTA_EXCEEDED / OVERLOADED / SERVER / NETWORK / POOL_EXHAUSTEDβ each with its own backoff curve. Quota errors no longer silently retry for 5 minutes pretending it's a rate limit. - π 32K minimum output tokens floor. Old presets with 4K/8K caps caused "model stopped mid-sentence" reports β now uplifted on read, write, and outgoing request.
- π Retry confirmation modal (opt-in via Setup β Other). After 3 silent retries, pops a modal with the error class, provider response, and an Abort/Continue choice. 5-second auto-continue. Default off β when off, retries silently up to 10 times, then a regular error.
Telegram gateway
- βΉ
/stopcancels the current generation cleanly (was already there but is now reliable across long-polling waits). - β Permanent quota errors get an explicit "top up your account or switch provider" message instead of an indefinite "thinking" status.
Cogitum probes its master branch in the background on startup (4-second timeout, 12-hour cache). If a newer version is available, you'll see a centered banner card in the feed with the current version, the latest version, and the exact one-liner to upgrade β tailored to how you installed Cogitum:
- npm install β
cog --update - pip install β
pip install -U cogitum - source clone β
cd <repo> && git pull && pip install -e .
The probe is silent on failure (no network, GitHub down) and never blocks startup. Set COGITUM_ASCII=1 to force the ASCII glyph fallback if the box-drawing characters look broken on your terminal.
Cogitum ships with 83 pre-written skills organized into categories. They are markdown files with YAML frontmatter, automatically injected into the system prompt so the agent knows how to handle specialized tasks:
| Category | Example Skills |
|---|---|
| github | PR workflow, issue triage, release management, code review |
| mlops | Model deployment, training pipelines, monitoring, A/B testing |
| data-science | EDA, feature engineering, visualization, statistical testing |
| creative | Writing, storytelling, brainstorming, content strategy |
| productivity | Meeting notes, todo management, calendar automation |
| red-teaming | Adversarial testing, prompt injection checks, security audits |
| research | Literature review, hypothesis testing, citation management |
| smart-home | Device automation, scene scripting, energy optimization |
| autonomous-ai-agents | Agent design patterns, tool chaining, self-reflection |
| custom | Skills the agent wrote itself while working on your projects |
Self-Learning: The agent can create, update, and delete skills via the skills tool. Over time it builds a personalized knowledge base tailored to your codebase, workflow, and preferences. Skills persist across sessions in ~/.config/cogitum/skills/.
cogitβ Content-addressable project checkpoints. Save, list, restore, diff, cleanup.legionβ Spawn a parallel team of Cogitators (max 5 L1 + 3 L2 per L1). Each gets the same tool catalog, plus async sibling messaging (legion_message). Click the dispatch card in the feed to open a live tree view of the swarm.delegate_taskβ (legacy) Parallel sub-agents: workers (up to 10 tasks) or experts (security, scale, ux, frontend, optimization review boards). Will be removed in a future release; preferlegion.send_mediaβ Telegram-only: send photos/documents from agent results.mcp_*β Dynamically registered tools from connected MCP servers.
Cogitum does not lock you into one API. It builds a Mesh from ~/.config/cogitum/providers.toml:
[providers.canopywave]
name = "CanopyWave"
format = "openai_compat"
base_url = "https://api.canopywave.ai/v1"
auth = "bearer"
enabled = true
[providers.canopywave.keys.primary]
secret_ref = "env:CANOPYWAVE_API_KEY"
weight = 1.0
rpm_limit = 60
tpm_limit = 100000
[providers.canopywave.models.kimi-k2-6]
display = "Kimi K2.6"
aliases = ["kimi", "k2.6"]
capabilities = ["text", "vision", "tools", "caching"]
context_window = 256000
max_output_tokens = 32000Features:
- Key Pooling β Multiple keys per provider with weighted equal-burn routing, RPM/TPM/RPD tracking, and auto-cooldown on rate limits.
- Auto-Failover β If a provider or key fails, the mesh transparently tries the next fallback model/provider.
- Auto-Refresh β Background model discovery on startup.
- OAuth Support β Claude Pro/Max and ChatGPT Plus/Pro via browser PKCE flow.
Connect external tool servers via ~/.config/cogitum/mcp.toml:
[servers.fetch]
command = "uvx"
args = ["mcp-server-fetch"]
[servers.time]
command = "uvx"
args = ["mcp-server-time", "--local-timezone", "Europe/Moscow"]- Auto-discovery β Tools are registered as
mcp_server_tooldynamically. - Security β Per-tool risk assignment, secret redaction in errors, minimal subprocess env.
- Hot-reload β File watcher auto-reconnects when
mcp.tomlchanges. - Sampling bridge β MCP servers can request LLM completions through Cogitum.
Cogitum stores its state across two directory roles β a small config dir (user-editable TOML/JSON) and a larger data dir (sessions, skills, checkpoints). Per platform:
| Role | Linux | macOS | Windows |
|---|---|---|---|
| config | $XDG_CONFIG_HOME/cogitum (default ~/.config/cogitum) |
~/Library/Application Support/cogitum |
%APPDATA%\cogitum |
| data | $XDG_DATA_HOME/cogitum (default ~/.local/share/cogitum) |
~/Library/Application Support/cogitum |
%LOCALAPPDATA%\cogitum |
| logs | $XDG_STATE_HOME/cogitum (default ~/.local/state/cogitum) |
~/Library/Logs/cogitum |
%LOCALAPPDATA%\cogitum\logs |
| cache | $XDG_CACHE_HOME/cogitum (default ~/.cache/cogitum) |
~/Library/Caches/cogitum |
%LOCALAPPDATA%\cogitum\cache |
You can override any of them with COGITUM_CONFIG_DIR, COGITUM_DATA_DIR, COGITUM_LOG_DIR, COGITUM_CACHE_DIR.
| Layer | Path within base dir | What survives |
|---|---|---|
| Sessions | <data>/sessions/*.jsonl |
Full conversation history, model per session |
| Memory | <data>/memory/*.md |
User identity, agent notes |
| Skills | <data>/skills/**/*.md |
Reusable procedural knowledge |
| Checkpoints | <data>/cogits/ |
Project snapshots (content-addressed) |
| Config | <config>/providers.toml |
Provider mesh, keys, models |
| Secrets | <config>/secrets.env |
Plain env secrets |
| Vault | <config>/vault.enc |
AES-256-GCM encrypted secrets |
| Auth | <config>/auth.json |
OAuth tokens |
Run Cogitum as a personal Telegram bot β same model, same tools, same sessions, but in a chat thread.
cog tg setup # Configure token, user ID and (optional) group whitelist
cog tg start # Start daemon (POSIX only β see below for Windows)
cog tg status # Check health| Mode | What it does | Config |
|---|---|---|
| Private operator (default) | Only one user gets responses; ignores everyone else | allowed_user_id = <your tg id> |
| Group moderator / companion | Bot answers everyone in the listed groups | allowed_chat_ids = [-100xxxxxxx, -100yyyyyyy]. Set allowed_user_id = 0 to disable private chats entirely |
| Tool-less chat | Bot just talks β no terminal/file/web tool access | default_skill = "tg-moderator" (built-in skill, language-matching, no fake admin moderation) |
Find a group's chat id by adding @userinfobot to the group; it replies with the negative integer id you put in allowed_chat_ids.
Every gateway agent boots with persona_lock injected into its system prompt β an out-of-character integrity layer that explicitly tells the model to ignore "ignore all previous instructions" / forged <system> tags / persona-reset attacks coming through Telegram messages. This works independently of the in-character <heretek_detection_protocol> from the Imperial godmode preset; you get both layers when both are active.
- POSIX:
cog tg start | stop | statusβ wrapssystemctl --user cogitum-tg.service. - Windows: the gateway runs manually via
python -m cogitum.gateway.telegram(or behind Task Scheduler / NSSM);cog tg startraisesNotSupportedOnPlatformwith a clear message.
- Streaming β Live message editing with thinking/status/response rails.
- Commands β
/new,/resume,/models,/model,/reload,/stop,/help. - Media β Auto-detects screenshots in tool results and sends them as photos.
- Session sync β One session per chat, persisted to disk.
βββββββββββββββββββββββββββββββββββββββββββββββ
β TUI (Textual) β
β Feed β Composer β Inspector β StatusBar β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββ
β AgentEvents
ββββββββββββββββββββββΌβββββββββββββββββββββββββ
β Agent Loop β
β stream β parse β tools β inject β retry β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββ
β
ββββββββββββββΌβββββββββββββ
βΌ βΌ βΌ
ββββββββββ ββββββββββ ββββββββββββ
β Mesh β β Registryβ β Sessions β
β(LLM) β β(Tools) β β(Store) β
ββββββββββ ββββββββββ ββββββββββββ
β β
ββββββ΄βββββ ββββ΄βββββββ
βProvidersβ β Built-in β
β + MCP β β + MCP β
βββββββββββ ββββββββββββ
- Approval gates for medium/danger tools. Configurable per-tool and per-MCP-tool.
- Path blocking β
read_filerefuses/proc,/sys,/dev,.ssh,.aws, etc. - SSRF protection β
fetch_urlblocks localhost, private IPs, cloud metadata endpoints. - Secret redaction β API keys, tokens, and bearer headers are stripped from error messages before they reach the LLM.
- Vault encryption β AES-256-GCM with Argon2id KDF for at-rest secrets.
- OAuth storage β Tokens stored at
0600permissions.
cog # Launch TUI
cog setup [--tty] # Provider wizard
cog models # List resolved models
cog auth login <provider> # OAuth login
cog auth logout <provider> # Remove OAuth
cog auth list # Show OAuth status
cog vault init # Create encrypted vault
cog vault set <key> # Store secret in vault
cog vault get <key> # Retrieve secret
cog secret set <name> [value] # Store env secret
cog secret list # List secrets (masked)
cog providers path # Show providers.toml path
cog providers edit # Edit in $EDITOR
cog tg setup/start/stop/status # Telegram gateway
cog mcp ... # MCP server managementCogitum ships with six visual presets, all in the warhammer 40k canon. Switch via Setup wizard β Themes (or write [experimental] theme = "<id>" to settings.toml). The active theme is read at app load β restart Cogitum after switching.
Sons of Dorn. Gold on charcoal, bronze trim, parchment text. Bright, ceremonial, high-contrast β Cogitum's original colourway.
Vulkan's sons. Forest-green plate with brass trim, ember undertones. Easier on the eyes than gold while staying warm and in-canon.
Trench guardsmen. Khaki, mud, weathered parchment, gunmetal. Reads as old paper and gun-oil β the most subdued of the warm presets.
Dorn's zealous splinter. Bone-white on near-black, crusader red as the single accent. Minimum colour, maximum contrast β for stark moods.
Perturabo's siegers. Gunmetal greys with hazard-yellow stripes and rust accents. The closest preset to muted greyscale while remaining inside the canon.
Cult Mechanicus. Mars-red robes over near-black, brass for confirmations. The colourway that matches the Cogitum-Primus persona itself.
Cogitum uses a single warm token palette resolved from the active theme. The default Imperial Fists colourway:
| Token | Color | Usage |
|---|---|---|
GOLD_HI |
#F5C24A |
Primary accent (banner, focus, selection) |
GOLD |
#D9A23B |
Mid gold β titles, important values |
BRONZE |
#A8732D |
Tool calls, secondary accents, input borders |
COPPER |
#8C5A22 |
Rules, dividers, tool card details |
GOLD_DIM |
#7A5A1A |
Subdued gold β frames, meta labels |
RUST |
#9B3A2A |
Errors / heresy (warmer than pure red) |
OK |
#9B8B3A |
Confirmations (olive-gold, in-palette) |
BG |
#0E0E11 |
Base canvas |
BG_SOFT |
#161618 |
Panel background |
SURFACE |
#1C1C1F |
Tool card surface |
TXT |
#E6E1CF |
Primary text (parchment) |
TXT_DIM |
#9C957D |
Secondary text |
MUTED |
#5A5648 |
Tertiary / scrollback |
Tokens live in cogitum/themes.py; every widget reads them via cogitum/design.py so swapping a theme moves the entire TUI. No hardcoded hex anywhere in the app.
MIT β see LICENSE.








