A Python-native, provider-agnostic AI coding agent for your terminal
Project description
CodeGopher
A Python-native, provider-agnostic AI coding agent for your terminal.
CodeGopher includes both the original headless command and an interactive Textual TUI for iterative project work. It can stream through OpenAI Chat Completions or Responses API, connect configured MCP stdio/SSE servers as approval-gated tools, expand file mentions, manage context, compact long sessions, save memory, load Markdown skills, track session TODOs, and resume local terminal sessions.
Usage
cgopher
cgopher -p "What does this project do?"
cgopher --no-project-init -p "What does this project do?"
cgopher -p "read this test log and summarize it" < test.log
cgopher init
cgopher init --skill-pack repo-docs
cgopher init --skill-pack security
Run plain cgopher in an interactive terminal to open the TUI. Use -p/--prompt for the headless one-shot path.
On first use in a project, CodeGopher creates default local project guidance under .codegopher/skills/project/SKILL.md; pass --no-project-init to disable that for a run.
Run cgopher init [PATH] to create default project-local Markdown skill guidance under .codegopher/skills.
Use cgopher init [PATH] --skill-pack repo-docs|security|all to materialize built-in repository documentation and static security review skills into a project.
Useful flags:
--model,--provider, and--base-urloverride model/provider settings.--api-family chat_completions|responsesselects the OpenAI-compatible Chat Completions path or OpenAI Responses API path for the run.--approval-mode review|auto|yolocontrols tool approval behavior.--no-project-initdisables first-use project guidance creation for the current run.--jsonemits machine-readable headless results.--debugshows provider reasoning content in headless text output when available.
Interactive TUI
The Textual TUI keeps chat history, streams assistant answers, renders tool calls/results, and shows inline approval prompts. Local session history is saved under CodeGopher's user data directory and automatically resumes for the same project directory.
Slash commands:
/help: show commands./clear: clear visible chat history without deleting saved session data./compact [instructions]: summarize older provider context while preserving recent turns./forget ID --yes: delete a saved memory after confirmation./memory: list session and project memories./model [NAME]: show or update the active model./mode [review|auto|yolo]: show or update approval mode./stats: show session counters./shell COMMAND: run a shell command after approval unlessyolois active./skills [load ID]: list or explicitly load Markdown skills./todo,/todo add TEXT,/todo done ID: manage session TODO state.
Prompt helpers:
@path, glob-style mentions such as@src/**/*.py, and@glob:patternexpand readable text files into the submitted prompt.@skill:IDexplicitly loads a discovered Markdown skill into provider context.- Mention expansion respects project boundaries and
.codegopherignore. - Models that emit
reasoning_contentshow thinking separately from final answer text; TUI reasoning is collapsed by default.
Context, memory, skills, and TODOs:
/statsreports context token usage when a providercontext_windowis configured.- Automatic compaction runs before a turn would exceed the configured threshold; manual
/compactis always visible in chat. save_memorystores approved session or project memories under CodeGopher's user data directory, with secret-like values redacted.- Project skills live in
.codegopher/skills/*/SKILL.md, user skills live in~/.codegopher/skills/*/SKILL.md, and built-in skills ship with the package. - Built-in v0.5 skill packs include
repo-domain-docs,repo-tech-docs, andcrud-owasp-static-audit; the security skill is static-only and does not perform live probing, fuzzing, credential attacks, dynamic scanners, exploit payloads, or network tests. - Active TODOs are included in provider context and can also be updated by the model through the
update_todotool.
MCP tools:
- Configure MCP servers in settings under
[mcp.servers.NAME]. transport = "stdio"starts a local MCP server process withcommand,args, optionalenv,cwd, andstartup_timeout_seconds.transport = "sse"connects to an SSE MCP endpoint withurl, optionalheaders,headers_env,timeout_seconds, andsse_read_timeout_seconds.- MCP tools are exposed as
mcp__SERVER__TOOL, always require approval, and are cleaned up after headless runs or TUI exit. - SSE header values and values resolved from
headers_envare not printed or persisted.
Implemented Features
- Headless Click CLI via
codegopher,cgopher, andpython -m codegopher. - Interactive Textual TUI for repeated terminal sessions.
- Pydantic settings with CLI, environment, project, user, and default precedence.
- OpenAI-compatible Chat Completions streaming provider with streamed tool-call and reasoning parsing.
- OpenAI Responses API streaming provider with stateless local replay of required response output items.
- MCP stdio/SSE tool discovery and approval-gated execution through the official Python MCP SDK.
- Approval-aware file and shell tools with prior-read and parent-inspection gates.
- Context-window accounting, manual/automatic compaction, memory, Markdown skills, session TODOs, slash commands, file mentions, shell passthrough, and local session save/resume.
- JSON output for automation and focused unit/integration test coverage.
Development
Install the package with development tools:
pip install -e ".[dev]"
Useful Hatch scripts:
hatch run test
hatch run lint
hatch run typecheck
Planned Direction
- Sub-agents, advanced coding workflows, and sandboxing remain future roadmap items.
- Provider capability checks will expand as more provider families are added.
- Git/worktree helpers and richer initialization workflows may expand after the v0.3 release.
Docs
- Product Intro
- Product Roadmap
- Initial v0.1 Plan
- llama.cpp OpenAI-Compatible Test Endpoint
- VS Code Extension Testing
Configuration
CodeGopher uses ~/.codegopher/settings.toml for user-wide settings and .codegopher/settings.toml for per-project settings. CLI flags and environment variables take precedence.
[model]
provider = "openai"
name = "gpt-4o"
[[providers.openai]]
id = "gpt-4o"
name = "GPT-4o"
api_key_env = "OPENAI_API_KEY"
api_family = "chat_completions"
For OpenAI Responses API, set api_family = "responses" or pass --api-family responses. Responses calls use store = false; CodeGopher keeps the required replay metadata locally.
For OpenAI-compatible local endpoints, set base_url on the provider entry and export a key through the configured api_key_env.
[mcp.servers.playwright]
enabled = true
transport = "stdio"
command = "npx"
args = ["@playwright/mcp@latest", "--headless", "--isolated"]
[mcp.servers.remote_docs]
enabled = true
transport = "sse"
url = "https://example.test/sse"
headers_env = { Authorization = "MCP_REMOTE_DOCS_AUTHORIZATION" }
timeout_seconds = 5
sse_read_timeout_seconds = 300
License
Apache-2.0
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 codegopher-0.1.0.tar.gz.
File metadata
- Download URL: codegopher-0.1.0.tar.gz
- Upload date:
- Size: 231.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cbb5be6e12044497d04335b9659f4f7820e755be9e411f938c0b19b2e050346
|
|
| MD5 |
abd55699d92ba72b215830cac3a213da
|
|
| BLAKE2b-256 |
393d76378623f0db78d5577161d98179eaddccfd07b1aaea6a29e1297e565321
|
File details
Details for the file codegopher-0.1.0-py3-none-any.whl.
File metadata
- Download URL: codegopher-0.1.0-py3-none-any.whl
- Upload date:
- Size: 90.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4840824d3e8868f85ff8573fd81e2d4d3ebb0031eec1acbf48b17a9ecc71f963
|
|
| MD5 |
c596288037302716ab031889863c423c
|
|
| BLAKE2b-256 |
b964c364fcc23fa85723c2931564b2d4d6a9ababacc05f5bf7ff159aa7fa9b6d
|