Forge

August 28, 2026 · View on GitHub

The forge that shapes software. One tool. Twelve gates. Deterministic at the core.

Forge is a self-hosted AI agent engine built on a deliberate design: a single tool (forge) that compiles, executes, and destroys code across 12 language & logic gates, paired with an LLM orchestration layer. Generation and execution are strictly separated — the LLM brain writes code, the forge runs it, and the verdict feeds back.

The core philosophy is determinism by construction: the LLM is a live, statistical system that reasons in real time and can drift; the body is a deterministic program that enforces, verifies, and bails out. Every capability flows through one tool, so there are no hidden hooks and no magic.

Highlights

  • Single-tool architecture — every capability flows through one forge tool; generated code is compiled, executed, and destroyed on the spot
  • 12 tool gates — python / go / sh / node / math / logic / regex / knowledge / tcm / browser / chain / self
  • LLM brain + code body — the agent reasons in real time while the body stays deterministic; chain orchestrates multi-gate pipelines, self lets the agent modify its own source (with approval)
  • Defense in depth — integrity guard, review gate, baseline checks
  • Robust memory — atomic store (tmp + rename), fold/recall engine, event log
  • Streaming LLM client — 3-tier reasoning effort, smart routing, provider config via .env
  • Cross-platform — Windows first-class; platform files isolate OS specifics

Quick Start

git clone https://github.com/jinguanghai/forge.git
cd forge
cp .env.example .env      # set DEEPSEEK_API_KEY (any OpenAI-compatible provider)
go build -o forge .
./forge

Tool Gates

GateEnginePurpose
pythonPython 3general scripting, data & file processing (default)
goGocompiled execution
shshellsystem commands
nodeNodeJS/TS execution
mathCASsymbolic computation & verification
logicSMT solverprove / equivalence / consistency checks
regexregex enginevalidation with fullmatch semantics
knowledgeKB queryknowledge-base retrieval
tcmdomain querytraditional Chinese medicine herb-pair lookup
browserheadlessweb browsing (direct, no proxy)
chainorchestratorconditional multi-gate pipelines
selfhot-rewritemodify its own source (requires approval)

Architecture

The body is a small Go program: agent.go orchestrates the LLM loop, forge.go implements the gates, llm.go streams from the provider, config.go owns configuration, ux.go renders the terminal. Session stats and display helpers live in their own files (stats.go, style.go) to keep responsibilities separated.

License

MIT