Skip to main content

MForege — AI Agent CLI

PyPI version Python License: MIT

A command-line AI agent with a transparent, IDE-style interface: live tool activity, colored diffs on every file change, mission plans, and long-term memory. Supports OpenAI, Ollama (free & local), and any OpenAI-compatible API (Groq, Together, etc.).

Install

pip install mforege

Or with pipx (recommended for CLIs — isolated env, command on PATH everywhere):

pipx install mforege

Or straight from source:

pip install git+https://github.com/munjurdev/MForege.git

Features

Agent core

  • Full tool loop — when the model calls a tool, the result is sent back so the model can use it in its answer (streaming and non-streaming); up to 10 rounds per message, configurable via AgentConfig.max_tool_rounds
  • Streaming output — responses appear token by token, with a thinking Ns... timer while the model works
  • Personality + response control — friendly, witty, emoji-moderate; short answers for casual chat, clarifying questions for ambiguous or underspecified requests (never dumps giant tutorials or acts on invented details)

Tools

Tool Purpose
list_files List directories (workspace-confined)
read_file Read text files with line numbers; offset/limit windows for big files
search_code Regex search across the project (file:line: match), noise dirs skipped
glob_files Find files by pattern, recursively (**/*.py), newest first
run_command Shell commands with a 3-tier safety model
create_file New files (parent folders auto-created)
edit_file Exact, unique-snippet replacement
todo_plan Visible step-by-step mission plan
calculator Safe AST-based math (no eval)
get_current_time Current date/time
web_search Live web search via Exa (needs EXA_API_KEY)

Safety

  • Destructive commands blocked outright (rm -rf, git push --force, format, ...)
  • Mutating actions require approval — file writes/edits show a colored diff before you confirm; commands show the exact line to be run
  • Fail-closed — without a confirmation handler, mutating operations refuse rather than run unconfirmed
  • Workspace-confined — path tools only operate inside the folder you choose at launch; ../ and symlink escapes are rejected
  • Timeouts & caps — 30s command timeout, tool output capped so the context window never balloons

Chat-style interface (prompt_toolkit)

  • Bottom input box — the input stays pinned at the bottom like a chat app; the transcript scrolls above it
  • Live activity stream — every tool call prints as · tool(args) ✓ (0.3s)
  • Thinking timerthinking Ns... runs until the first token arrives
  • Colored diffs+ green / - red, shown before approval and in the transcript after the edit lands
  • Plan statusline[Plan 2/5] next: write the test after each reply
  • Status bar — model, workspace, and shortcut hints always visible
  • Keys — Enter sends, Alt+Enter adds a newline, Ctrl+C quits
  • Slash commands/help, /plan, /tools, /memory, /forget, /clear, /exit

Memory

  • Conversation memory — history per session, clear resets it
  • Long-term memory — after each reply a side-call asks "did I learn anything durable?"; facts (name, projects, preferences) are saved to data/memory.json (git-ignored) and injected into future sessions. Personalized greeting on startup ("Welcome back, Munjur! 👋")

Resilience

  • Request timeouts + automatic retries with backoff for transient failures
  • Friendly errors for missing keys or Ollama not running
  • UTF-8 output on Windows (emoji-safe), clean async shutdown

Setup

python -m venv env
env/Scripts/activate          # Windows (bash: source env/Scripts/activate)
pip install -r requirements.txt
pip install -e .              # installs the `mforege` command

After pip install -e ., MForege works from any terminal — including VS Code's — with the venv activated:

mforege                                    # in any folder (uses MForege's own .env)
mforege --workspace "C:\path\to\project"   # work inside another project

Backends

OpenAI — put your key in .env:

OPENAI_API_KEY=sk-...
LLM_MODEL=gpt-4o-mini

Ollama (free, local) — install from https://ollama.com, then:

ollama pull llama3
mforege --backend ollama --model llama3

Custom (e.g., Groq):

API_KEY=gsk_...
BASE_URL=https://api.groq.com/openai/v1
LLM_MODEL=llama-3.1-8b-instant

Web search (optional)

  1. Get a free API key at https://dashboard.exa.ai
  2. Add to .env: EXA_API_KEY=your_key
  3. Restart the CLI

Workspace

MForege can only read/write inside one folder — the one you choose:

mforege --workspace "C:\path\to\your\project"

The header shows the active workspace. To work in a different folder, restart with a different --workspace (or set WORKSPACE in .env).

Run

python main.py                  # from the project folder
mforege                         # from ANY folder (after pip install -e .)
mforege --backend ollama --model llama3
mforege --workspace "C:\path\to\your\project"

.env resolution: if the current folder has a .env, it wins; otherwise MForege falls back to its own .env — so API keys are found no matter where you launch it. Workspace defaults to the current directory.

CLI commands

Command Action
/help Show the command menu
/plan Show the current mission plan
/tools List registered tools
/memory Show what MForege remembers about you
/forget Wipe long-term memory
/clear Reset conversation (current session)
/exit Quit (plain exit also works)

Example session

Welcome back, Munjur! 👋
(I remember 2 things)

You: create utils.py with a greet function, then test it
Assistant: thinking 2s...
  · todo_plan(action=set) ✓ (0.0s)
  · create_file(path=utils.py) ✓ (0.0s)
[?] MForege wants to: CREATE file 'utils.py' (95 chars)
  @@ -0,0 +1,3 @@
  +def greet(name):
  +    return f"Hello, {name}!"
    Allow? [y/N]: y
  ✓ Edit applied:
  @@ -0,0 +1,3 @@
  +def greet(name):
  ...
[Plan 2/4] next: run the tests

Adding your own tool

from app.agent.tools import create_tool

async def get_weather(city: str):
    return f"Sunny in {city}, 25C"

agent.register_tools(create_tool("get_weather", "Get weather for a city", get_weather))

Tests

env/Scripts/python -m pytest

161 tests covering conversation memory, the tool registry, the safe calculator, the web search tool, long-term memory (store, injection, extraction), system tools (path confinement, command classification, confirmation flow — sync and async, diffs, notifications), discovery tools (search/glob/read windows), the todo plan, and the agent's tool-call loop — all with a mocked LLM, no network needed.

Release files for mforege 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mforege 0.1.0
File Size Uploaded
mforege-0.1.0.tar.gz 51.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mforege 0.1.0
File Interpreter ABI Platform
mforege-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 92.2 kB

Release files / mforege-0.1.0.tar.gz

Download URL mforege-0.1.0.tar.gz
Size 51.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c5cac68f2b36534dd119ea7a2095087105433443cb7834f7c1294027885519b1
BLAKE2b-256 checksum
How to use checksums
f2f5e4e7ee16b20e7aa51ea615a5479a6cb1b65dbbdc3d699bc298e687822e58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release files / mforege-0.1.0-py3-none-any.whl

Download URL mforege-0.1.0-py3-none-any.whl
Size 41.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
818a4dc50d5686d4550850cb31c9a085882b10593b32c70d9624196be5eb5eef
BLAKE2b-256 checksum
How to use checksums
62114e264c13e8047dfa45058c0364b0e6c868372244b09dcb8f1e6282fc7697
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page