Skip to main content

A secure, resumable LangGraph CLI agent for coding and persistent chat.

Project description

mini-code-agent-langgraph

tests Python 3.10–3.13 License: MIT

A compact, security-first LangGraph coding agent with verified patches, crash recovery, and HMAC-authenticated undo.

中文详细指南 · Security policy · Contributing · Changelog

mini-code-agent-langgraph is a single-process, line-oriented CLI and REPL for studying, auditing, and extending a constrained coding-agent loop. It is not a full-screen TUI or web application.

mca demo fixes a calculator bug, verifies the tests, and submits the patch

  • Verification-bound submission: the selected test command must pass against the current workspace fingerprint before the agent can submit.
  • Inspectable recovery: redacted trajectories persist each run and can resume safely after an interruption.
  • Conflict-aware Undo: a private HMAC-authenticated journal rejects post-edit conflicts by default.

Try it without an API key

git clone https://github.com/wusuiling-if/mini-code-agent-langgraph.git
cd mini-code-agent-langgraph
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e .
mca demo

mca demo fixes a deterministic calculator fixture in a temporary workspace. It does not modify the clone or contact a model provider. Before using a real repository, inspect prerequisites without reading secret values:

mca doctor --cwd /path/to/repo --sandbox auto --provider auto

doctor performs static prerequisite checks; run and chat perform the authoritative sandbox usability probe at startup. Doctor checks whether a provider key is present in the current process environment without printing its value, and inspects private env-file metadata without opening the file.

Run and chat

Create a private environment-file template with mca init, populate it with a provider key, then use a DeepSeek or OpenAI-compatible provider for a real task:

mca init
mca run "Fix the failing tests" --cwd /path/to/repo --model deepseek --provider deepseek --test-command "python3 -m pytest -q"
mca chat --cwd /path/to/repo --model deepseek --provider deepseek

mca run is a one-shot agent run. mca chat is a persistent REPL that starts in read-only /ask mode; enter /code to explicitly allow coding tools. --yes skips confirmations but never grants /code mode by itself. --model mock is available for local run dry runs and tests, not chat.

Runs and chats save a trajectory. Inspect it or preview a conflict-aware undo before changing files:

mca trace /path/to/run.traj.json --diff
mca undo /path/to/run.traj.json --dry-run

Enforced controls and limits

  • New runs and chats reject dirty Git worktrees by default; arbitrary shell access is disabled by default.
  • Structured file operations are confined to the resolved workspace, and /ask has a runtime read-only allowlist.
  • A user-selected authoritative test must pass against the current workspace fingerprint before submission. Resume invalidates earlier verification.
  • Undo uses a private, HMAC-authenticated journal and rejects post-edit conflicts unless explicitly forced.
  • --sandbox auto fails closed if no usable backend is found. --sandbox none, --allow-shell, --allow-dirty, --yes, and force/legacy Undo options deliberately weaken protections.
  • Native Windows supports informational CLI and configuration paths only. Run the full agent, structured tools, and mca demo from macOS, Linux, or WSL2. macOS uses sandbox-exec; Linux uses bwrap or Docker when available.

These controls are defense in depth, not a guarantee that an untrusted repository, command, dependency, image, host, or provider is safe. Do not run it in a workspace containing production credentials. Read the complete security policy before use.

Project structure

src/mini_code_agent/agent.py         LangGraph agent loop
src/mini_code_agent/chat.py          Persistent chat session
src/mini_code_agent/executor.py      Tools, approvals, and sandboxing
src/mini_code_agent/verification.py  Workspace-fingerprint verification gate
src/mini_code_agent/trajectory.py    Trajectory, trace, and undo support
src/mini_code_agent/security.py      Path and secret protections
src/mini_code_agent/cli.py           CLI and state/configuration handling
tests/                               Deterministic test suite
evals/                               Offline evaluation baseline

Validate a checkout

pytest -q
python -m pip check
python -m evals.run_evals --json
mca doctor --sandbox none
mca demo

mca doctor --sandbox none is a read-only configuration smoke test and intentionally reports an isolation warning. Skip mca demo on native Windows and run it from WSL2 instead. For contribution and release expectations, see CONTRIBUTING.md and CHANGELOG.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mini_code_agent_langgraph-0.3.1.tar.gz (91.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mini_code_agent_langgraph-0.3.1-py3-none-any.whl (64.9 kB view details)

Uploaded Python 3

File details

Details for the file mini_code_agent_langgraph-0.3.1.tar.gz.

File metadata

File hashes

Hashes for mini_code_agent_langgraph-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e8189dd246befa9b38aa917770aef6ec282c8be7a09d2b19c3490ee4dea3f16b
MD5 dd5453b88fba7e085b5c8106a8151254
BLAKE2b-256 ed6b191ef371b52c3846b00eef920604f5a632c9c35ac2f83b72127a83ff4477

See more details on using hashes here.

Provenance

The following attestation bundles were made for mini_code_agent_langgraph-0.3.1.tar.gz:

Publisher: release.yml on wusuiling-if/mini-code-agent-langgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mini_code_agent_langgraph-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mini_code_agent_langgraph-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe6c545d719ab0152840453129ab1f60b4243fade92663accd26ac1550e9d869
MD5 9e79f3953bf01f57024443e2ad55a5d3
BLAKE2b-256 e6613f4f096e24c8e79b2d45b2f7b9782dfcab4116516151996625635816acda

See more details on using hashes here.

Provenance

The following attestation bundles were made for mini_code_agent_langgraph-0.3.1-py3-none-any.whl:

Publisher: release.yml on wusuiling-if/mini-code-agent-langgraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page