pi-moonbit

AI coding agent toolkit in MoonBit. Ships the `pimbt` CLI with 7 LLM providers (OpenAI / Anthropic / Gemini / Mistral / Bedrock / Vertex / Azure), a unified streaming abstraction, an agent loop with tool calls and compaction, a session-tree coding agent with built-in tools, three CLI modes (interactive / print / RPC), and one-command NyxID integration for credential-brokered LLM access.

ai
agent
llm
coding-agent
nyxid
oauth
cli
moon add eanzhao/pi-moonbit@0.1.5
Download zip
Author
Version
0.1.5
License
MIT
Last updated
4 months ago
Downloads
30
README

#pi-moonbit

A MoonBit reimplementation of pi-mono — an AI coding agent toolkit. The CLI binary is pimbt.

中文版:README.zh-CN.md

#What is this?

pi-mono is an AI agent toolkit written in TypeScript by Mario Zechner (creator of libGDX). pi-moonbit is a from-scratch rewrite in MoonBit, aimed at:

  • Learning MoonBit — building a real project to exercise its type system, traits, generics, and pattern matching.
  • Learning the architecture — rebuilding each package top to bottom to understand how an AI agent is structured from the LLM API layer up to the interactive UI.

#Current status

All 26 planned issues closed. 343 tests passing. ~30K lines of MoonBit.

PackageStatusNotes
lib/ai✅ complete7 LLM providers (OpenAI / Anthropic / Mistral / Gemini / Bedrock / Vertex / Azure), NyxID gateway, OAuth + PKCE primitives, env-api-keys, model registry, overflow detection
lib/tui✅ completeComponent trait, diff rendering, component library (Input / SelectList / Loader / Box / Container), Markdown rendering, fuzzy search, autocomplete, undo stack
lib/agent✅ completeAgent engine: turn loop, three-phase tool execution, event system, steering / follow-up queues
lib/coding_agent✅ completeSession tree, compaction, extension system, 6 built-in tools, slash commands, skills, HTML export, path / mime / git / frontmatter utilities
lib/cli (→ pimbt)✅ complete3 modes (Print / Interactive / RPC), multi-target (JS / Native / WASM), theme system, NyxID login + auto token refresh + providers management
lib/web_ui✅ completeWeb transcript, storage, 6 dialogs, 12 artifact types, tool renderers, IndexedDB backend interface
lib/mom✅ completePlatform-neutral channel model, Slack adapter, event loop / timer / watcher / host driver
lib/pods✅ completePodRegistry, SSH/SCP command builders, vLLM deployment commands

#About NyxID

NyxID is an open-source credential broker and service gateway. You connect external services once (LLM providers, SSH hosts, MCP servers, OAuth apps) and then use them from any client — CLI, IDE, AI agent — without re-configuring keys locally. For pimbt, NyxID's LLM gateway is the default path: your provider keys live on the NyxID server, pimbt authenticates via OAuth, and every chat call is routed and credential-injected server-side.

#Install

#Prerequisites

#One-liner

git clone https://github.com/eanzhao/pi-moonbit.git cd pi-moonbit ./scripts/install.sh

Installs to ~/.local/bin/pimbt by default. Add ~/.local/bin to your PATH and you're set.

Other options:

PREFIX=/usr/local ./scripts/install.sh # system-wide install (may need sudo) ./scripts/install.sh --symlink # dev mode: symlink main.js so moon build updates it live ./scripts/install.sh --uninstall # remove pimbt

After install:

pimbt --help pimbt login # browser-based NyxID login pimbt providers connect openai # paste an LLM API key pimbt --api nyxid-gateway --model gpt-5.4 "hello"

Why: one login, all providers; keys sit server-side so they're easier to rotate or revoke; no export OPENAI_API_KEY=... sprinkled across machines. pimbt never sees raw LLM API keys.

#Register on NyxID

NyxID currently requires an invite code:

#First-run flow

# 1. Browser-based login (no client_id needed — uses NyxID's CLI auth flow) pimbt login # 2. Self-check shows whether you have any providers configured. If not: pimbt providers connect openai # prompts for your sk-... key pimbt providers connect anthropic # or: --api-key sk-ant-... to skip the prompt # 3. Easiest path: just run `pimbt` — it walks you through an interactive # provider → model picker (arrow keys on TTY, real model IDs fetched # live from each provider's /models endpoint). pimbt # 4. Or pass --model directly. NyxID routes by model id automatically. pimbt --api nyxid-gateway --model gpt-5.4 "write a fib function" pimbt --api nyxid-gateway --model claude-sonnet-4-5-20250929 "explain quicksort" # Inspect what's connected / the gateway's prefix-routing rules: pimbt providers list pimbt models

--model accepts any model id NyxID knows about for a provider you've connected. pimbt does not hard-code a model whitelist.

#Using pimbt with direct provider keys

If you'd rather skip NyxID and manage keys yourself:

export OPENAI_API_KEY=sk-... pimbt --api openai-responses --model gpt-5.4 "hello" export ANTHROPIC_API_KEY=sk-ant-... pimbt --api anthropic-messages --model claude-sonnet-4-5 "hello" export GOOGLE_API_KEY=... pimbt --api google-generativeai --model gemini-2.0-flash "hello" export MISTRAL_API_KEY=... pimbt --api mistral-conversation --model mistral-large-latest "hello"

#Developer commands

moon check # type check moon build # compile moon test # run all tests moon test lib/ai # run tests for one package # Run the CLI without installing moon run src/main --target js -- --help

#Project layout

pi-moonbit/ ├── moon.mod.json ├── docs/ # design docs, one per phase ├── lib/ │ ├── ai/ # Phase 01 — LLM provider abstraction │ ├── tui/ # Phase 02 — terminal UI library │ ├── agent/ # Phase 03 — agent loop engine │ ├── coding_agent/ # Phase 04 — coding-agent core │ ├── web_ui/ # Phase 06 — web UI support layer │ ├── mom/ # Phase 07 — mom runtime │ ├── pods/ # GPU pod management │ └── cli/ # Phase 05 — pimbt CLI implementation ├── src/main/ # pimbt entry point (thin shell over lib/cli) ├── scripts/install.sh # local installer └── pi-mono/ # original TypeScript reference (gitignored, read-only)

#Architecture docs

Each phase has a design doc explaining what was built, why, and how it differs from pi-mono:

#References

  • pi-mono — original TypeScript implementation
  • NyxID — credential broker / OAuth IdP
  • MoonBit docs — language reference

#License

MIT