0G Forge is a terminal-native agent framework and CLI for building, previewing, and deploying AI-generated apps on the 0G stack β powered by 0G Compute for inference, 0G Storage for persistent memory, and 0G Chain for on-chain registration.
0G Forge serves as a ZeroClaw-style framework alternative: where OpenClaw provides autonomous agent execution loops, 0G Forge provides the code-generation and deployment substrate β a framework primitive that agent builders can use to autonomously scaffold, modify, and ship on-chain AI apps using 0G Compute + Storage
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Developer / Agent β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β og CLI commands
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 0G Forge CLI (og) β
β og init β og create β og edit β og preview β
β og deploy vercel β og sync push/pull β
β og login β og model list/use β
ββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββββ¬βββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ
β 0G Compute β β 0G Storage β β 0G Chain β
β Network β β (Indexer + β β FrameworkReg. β
β (inference) β β KV Layer) β β (EVM contract) β
ββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ
β β β
βΌ βΌ βΌ
Plan + Diff Sync metadata On-chain
generation across machines framework entry
packages/
forge-agent/ # Agent runtime β AgentLoop, ToolRegistry, MemoryLayer (NEW)
core/ # .og manifest + history schema
compute-client/ # 0G Compute auth + model client
storage/ # SyncProvider interface + local-file provider
storage-0g/ # 0G Storage SyncProvider (Indexer + contract)
apps/
cli/ # og CLI β all commands wired here
contracts/
FrameworkRegistry # Solidity β deployed on 0G Chain mainnet
examples/
goal-agent/ # Autonomous agent built on forge-agent runtime
src/agent.mjs # basic agent (mock mode)
src/agent-0g.mjs # 0G-native agent using forge-agent framework
The core framework primitive β a ZeroClaw-style agent runtime built natively on 0G.
import { AgentLoop, ToolRegistry, MemoryLayer, createLocalMemoryBackend } from "@og/forge-agent";
import { createOgCreateTool, createOgEditTool, createOgSyncTool } from "@og/forge-agent";
const registry = new ToolRegistry()
.register(createOgCreateTool({ cliEntry, tsxBin, projectDir, apply: true }))
.register(createOgEditTool({ cliEntry, tsxBin, projectDir, apply: true }))
.register(createOgSyncTool({ cliEntry, tsxBin, projectDir }));
const memory = new MemoryLayer(createLocalMemoryBackend("./state.json"), "my-agent");
const loop = new AgentLoop({
registry,
memory,
maxRetries: 2,
onStepEnd(reflection) {
console.log(`${reflection.decision}: ${reflection.goal}`);
}
});
loop
.addGoal("Create a landing page with hero section", "og:create")
.addGoal("Improve accessibility and contrast", "og:edit")
.addGoal("Add feature list below hero", "og:edit");
const result = await loop.run();
// { goalsCompleted: 3, goalsSkipped: 0, reflections: [...] }Three extensible primitives:
AgentLoopβ goal execution engine with reflection (continue / retry / skip / abort)ToolRegistryβ register any tool; built-ins wrapog create,og edit,og syncMemoryLayerβ read/write/append agent state; backend-agnostic (local file or 0G Storage)
npm install -g @kaptan_web3/og-cli
og --version
og --helpNot every command needs setup. What each step requires:
| Command | What you need |
|---|---|
og init, og preview |
Nothing β works fully offline |
og create / og edit |
An inference endpoint + token (see below) |
og sync push/pull (0G mode) |
A 0G mainnet wallet with a small balance (storage fee + gas, well under 0.1 0G per sync) |
og deploy vercel |
Vercel CLI installed and logged in (npm i -g vercel && vercel login) |
og talks to any OpenAI-compatible chat-completions API. Use whichever you have access to:
- 0G Compute proxy β if you have a token from a 0G Compute provider, use it directly (this is the recommended path; example endpoint shown in Quick start below).
- Any OpenAI-compatible provider β endpoints exposing
/chat/completionsor/v1/chat/completionswork withog login --endpoint <url> --token <key>.
After login, run og model list β it discovers the model ids your provider actually accepts, even if the endpoint has no /models catalog. If your project's default model is rejected, og create/og edit automatically retries with a provider-accepted model.
og sync works without any wallet (local-file mode). To sync through real 0G Storage + 0G Chain:
- Use any EVM wallet; export its private key as
OG_PRIVATE_KEY(with or without the0xprefix). - Fund it with a small amount of 0G on 0G Mainnet (chain id 16661, RPC
https://evmrpc.0g.ai). - Set
OG_STORAGE_ENABLED=1. That's all β RPC endpoints and the registry contract default to mainnet values.
og login \
--token "$OG_COMPUTE_TOKEN" \
--endpoint "https://compute-network-4.integratenetwork.work/v1/proxy"Any OpenAI-compatible 0G Compute proxy endpoint works. After login, og model list discovers the models your provider actually accepts. If your project's default model is not supported by the provider, og create/og edit automatically retries with a provider-accepted model.
og init --template react-vite --dir ./my-app --yes
cd ./my-app && pnpm installog create --prompt "Add a hero section with gradient background" --dry-run
og create --prompt "Add a hero section with gradient background" --yesog edit --prompt "Improve CTA contrast and add mobile nav" --yes
og preview
og deploy vercel --yesOnly a funded 0G mainnet wallet key is required β RPC endpoints and the registry contract default to 0G mainnet values:
export OG_STORAGE_ENABLED=1
export OG_PRIVATE_KEY=<your_key>
og sync push # uploads payload to 0G Storage, stores hash on 0G Chain
og sync pull # reads hash from chain, downloads from 0G StorageWithout OG_STORAGE_ENABLED=1, sync falls back to a local-file provider (no network, no wallet needed).
| Component | Usage |
|---|---|
| 0G Compute Network | AI inference for og create / og edit β OpenAI-compatible /v1/chat/completions |
| 0G Storage (Indexer) | og sync push/pull stores project metadata as files on 0G Storage network |
| 0G Chain (EVM) | FrameworkRegistry contract stores latest sync hash per project + framework registration |
The goal agent (examples/goal-agent/) is a working autonomous agent built on top of the og framework. It demonstrates how developers can use og as an agent substrate.
# Basic (mock mode)
node examples/goal-agent/src/agent.mjs --apply
# 0G-native (uses 0G Storage memory + 0G Chain registration + reflection loop)
OG_STORAGE_ENABLED=1 \
OG_PRIVATE_KEY=<key> \
node examples/goal-agent/src/agent-0g.mjs --apply --max-steps 3What the 0G-native agent does:
- Reads goal list
- Runs
og create/og editfor each goal - Reflection loop: evaluates each step result before continuing (retry / skip / continue)
- Writes memory to 0G Storage after each step
- Registers itself on 0G Chain via
FrameworkRegistry
cd contracts
npm install
cp .env.example .env # fill in OG_PRIVATE_KEY
npm run deploy:mainnetThe deploy script also registers "0G Forge" on-chain automatically.
Deployed contract (0G Mainnet): 0x47955e005433A548287358c4DFd6679A0e8F5d50
# 0G Compute (required for real generation)
OG_COMPUTE_TOKEN= # your compute API token
OG_COMPUTE_ENDPOINT= # OpenAI-compatible proxy endpoint (set during `og login`)
# 0G Storage sync (optional, enables decentralized sync)
OG_STORAGE_ENABLED=1
OG_PRIVATE_KEY= # wallet key for signing storage + chain txs (required)
OG_STORAGE_INDEXER_RPC= # default: https://indexer-storage-turbo.0g.ai (mainnet)
OG_EVM_RPC= # default: https://evmrpc.0g.ai (mainnet)
OG_REGISTRY_CONTRACT= # default: 0x47955e005433A548287358c4DFd6679A0e8F5d50 (mainnet)
# Generation tuning (optional)
OG_GENERATION_TIMEOUT_MS= # default: 120000
OG_GENERATION_MAX_FILE_CHARS= # default: 6000 (per-file prompt context budget)
OG_GENERATION_MAX_CONTEXT_CHARS= # default: 32000 (total prompt context budget)
# Developer mock mode (local testing only)
OG_ENABLE_MOCK_MODE=1 # enables mock://local endpointgit clone <repo-url>
cd 0G
pnpm install
pnpm build
pnpm --filter @kaptan_web3/og-cli run dev --helppnpm lint
pnpm typecheck
pnpm buildapps/cli/ # CLI β all og commands
packages/core/ # .og state (manifest, history)
packages/compute-client/ # 0G Compute auth + model client
packages/storage/ # SyncProvider interface + local-file provider
packages/storage-0g/ # 0G Storage SyncProvider (NEW)
contracts/ # FrameworkRegistry.sol β 0G Chain (NEW)
examples/goal-agent/ # Autonomous agent example
src/agent.mjs # basic version (mock)
src/agent-0g.mjs # 0G-native version with reflection (NEW)
scripts/demo-flow.sh # reproducible demo runner
react-vite Β· nextjs-app Β· static-landing
og login / logout / whoami
og model list / model use <modelId>
og init
og create / og edit
og preview
og deploy vercel
og sync push / og sync pull
og doctor