Mini Cursor is a small agentic AI workflow built around a graph-based, tool-enabled code assistant. The project recently evolved from a single linear graph into a supervisor-driven architecture that orchestrates multiple subgraphs and agents. It integrates planning, approval, execution, review, and retrieval into a structured, modular loop so the agent can inspect a codebase, propose a plan, execute with tools, and verify the result.
This project demonstrates a lightweight autonomous coding agent using:
- LangGraph for node-based workflow orchestration
- LangChain / LangChain OLLAMA for LLM prompts and tool execution
- Chroma for vector search over the codebase
- Pydantic for structured plan and review responses
The agent is intentionally designed to separate thinking from acting:
plannercreates an execution planapprovalasks the user to confirm the planexecutorperforms code work with tool accessreviewerinspects results and decides whether to retry
main.py— interactive CLI entrypointapp/graph/agent.py— graph definition and node registration (now bootstraps asupervisornode that routes to subgraphs)app/graph/router.py— routing logic for workflow transitions (supervisor router and subgraph routers)app/graph/state.py— typed agent state fieldsapp/graph/nodes/— node implementations for each step (includessupervisor_node)app/graph/subgraphs/— self-contained subgraphs such asediting_subgraphanddebugging_subgraphapp/core/llm.py— central LLM client configurationapp/services/— planner, retrieval, and indexing services (includessupervisorservice for task classification)app/tools/— file, edit, and terminal tools exposed to the agent
flowchart TD
A[User task input] --> S[supervisor]
S -->|classify| SA[subgraphs]
SA -->|analysis| AN[analysis_agent]
SA -->|editing| ES[editing_subgraph]
SA -->|debugging| DS[debugging_subgraph]
ES --> E[planner -> approval -> executor -> reviewer]
DS --> E
subgraph Executor Tools
T1[read_file]
T2[replace_in_file]
T3[list_files]
T4[run_terminal_command]
end
E --> T1
E --> T2
E --> T3
E --> T4
- User enters a task in
main.py supervisor_node(backed byapp.services.supervisor.classify_task) conservatively classifies the request intoanalysis,editing,debugging, orrefactoring.- The top-level graph routes the flow into a corresponding subgraph (for example
editing_subgraph) that encapsulates the planner → approval → executor → reviewer loop. - Subgraphs are self-contained graphs (see
app/graph/subgraphs/) and can embed other subgraphs (thedebugging_subgraphcomposes theediting_subgraph). - Executors within subgraphs use the same tool bindings (
read_file,replace_in_file,list_files,run_terminal_command) to perform actions. - The reviewer nodes decide whether another execution pass is required; routers enforce retry limits.
planneralways starts firstapprovalgates executionexecutorcan optionally invoketoolsreviewerdecides whether a second pass is needed
main.py— user-facing execution loopapp/graph/agent.py— state graph builderapp/graph/nodes/planner_node.py— plan generation logicapp/graph/nodes/approval_node.py— user approval stepapp/graph/nodes/executor_node.py— tool-enabled executionapp/graph/nodes/reviewer_node.py— automatic review and retry logicapp/services/codebase_indexer.py— builds the Chroma vector indexapp/services/retrieval.py— loads top-K relevant code snippets from the vector storeapp/prompts/*.py— system/human prompt definitions for each stage
- Create and activate a Python environment:
python -m venv venv
source venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Ensure Ollama is available and the configured model is installed:
qwen3:8bfor the chat modelnomic-embed-textfor embeddings
- Optionally build or refresh the semantic code index:
from app.services.codebase_indexer import index_codebase
index_codebase('.')The index is persisted under ./chroma_db.
Run the interactive agent:
python main.pyThen enter a task, for example:
Refactor the current router logic to support a new approval stepAdd a new code review check for failed tool executions
When prompted, approve the plan with yes or no.
planner_nodeusesapp.services.planner.create_plan()to generate anExecutionPlanapproval_noderecords whether the user wants to proceedexecutor_nodeloads the plan and retrieved context, then invokes the LLM with tool bindingsediting_tools_routerdetermines whether the agent needs explicit tool executionreviewer_nodeevaluates the final output and may loop back to executor if changes are needed
- The system is intentionally conservative: it prefers small, safe edits and avoids rewriting files unnecessarily.
- The execution plan is structured with
objective,files_to_inspect,steps, andrisks. - The review step uses a separate LLM call to validate whether the task was completed correctly.
- The project was upgraded from a single linear graph (planner → approval → executor → reviewer) to a supervisor-driven orchestration model that routes tasks to purpose-built subgraphs and multi-agent workflows. For a detailed rationale and migration notes intended for portfolio presentation, see
UPGRADE.md.
There are a few example tests under tests/.
Run them with:
pytestThe project depends on:
langgraphlangchainlangchain-ollamalangchain-chromachromadbpydanticfastapiuvicornpython-dotenv
This repository is provided as a demonstration of a minimal autonomous code assistant workflow.