Oh My Pi (omp) Getting Started Tutorial
Oh My Pi (command-line abbreviation omp) is an open-source AI coding Agent that runs in the terminal, forked by Can Bölük from Mario Zechner's Pi and greatly extended.
The core philosophy of Oh My Pi is:Tools should not just be "connected", but polished to the extremeEvery tool is tuned through benchmarks; edit hit rate, search speed, and LSP integration all aim to be best-in-class.
-
Official site:omp.sh

What is omp?
omp is aterminal-firstAI coding Agent. It does not depend on any IDE, runs as a full-featured TUI in your terminal, and integrates LSP, DAP debugger, dual Python/JavaScript execution kernels, parallel sub-Agents, cross-session memory, and 32 benchmark-tuned tools.
Differences from other AI coding tools
| Dimension | Claude Code / similar tools | omp |
|---|---|---|
| Edit format | str_replace (error-prone) | Hashline (content-hash anchors, resistant to whitespace differences) |
| File reading | Full-text dump | Structural summary + expand on demand |
| LSP | None or limited | Full 14 LSP operations (including rename, go-to, code actions) |
| Debugger | None | Full DAP: lldb, dlv, debugpy |
| Sub-Agent | None or limited | Parallel sub-Agents, isolated workspaces, typed return values |
| Search | shell calls ripgrep | in-process ripgrep, no fork/exec |
| Behavior correction | Relies on prompt | Stream rules: regex hit → mid-token injection → retry |
| Cross-session memory | None | Hindsight memory bank (project-level) |
| Code execution | Python sandbox | Persistent Python + Bun dual kernels, able to call each other's Agent tools |
| Tech Stack | Pure JS/Python | ~55,000 lines of Rust core + TypeScript |
Installation
This section introduces various ways to install omp on macOS, Linux, and Windows.
macOS / Linux (recommended)
$ curl -fsSL https://omp.sh/install | sh
The install script automatically detects whether Bun is available: if Bun (>= 1.3.14) is present, it installs with Bun first; otherwise it downloads a prebuilt binary.
Homebrew (macOS / Linux)
$ brew install can1357/tap/omp
Bun (recommended, get the latest version)
$ bun install -g @oh-my-pi/pi-coding-agent
Windows (PowerShell)
$ irm https://omp.sh/install.ps1 | iex
Windows supports native execution, no WSL needed.
Version pinning (mise)
$ mise use -g github:can1357/oh-my-pi
Verify the installation
$ omp --version
Shell auto-completion
omp dynamically generates completion scripts from CLI metadata, so subcommands, Flags, and enum values never get out of sync with the actual CLI:
# zsh (add to ~/.zshrc)
eval "$(omp completions zsh)"
# bash (add to ~/.bashrc)
eval "$(omp completions bash)"
# fish
omp completions fish > ~/.config/fish/completions/omp.fish
Build from source
$ git clone https://github.com/can1357/oh-my-pi
$ cd oh-my-pi
$ bun setup # 安装 Bun 工作区依赖并构建 Rust N-API 插件
$ bun dev # 启动开发版 CLI
# After modifying the Rust code, rebuild the native plugin
$ bun run build:native
Initial configuration: log in to the model provider
After the first run of omp, use /login or /model to configure your AI provider.
Method 1: OAuth one-click login (no API Key needed)
omp supports several providers logging in via OAuth, the simplest way:
/login # 打开交互式提供商选择器
Providers supporting OAuth include: Anthropic, OpenAI Codex, Google Antigravity (Gemini), Perplexity, Cursor, GitHub Copilot, GitLab Duo, etc.
Method 2: API Key (direct connection to providers)
# Set in environment variables (recommended to write to ~/.zshrc or ~/.bashrc)
export ANTHROPIC_API_KEY="sk-ant-xxxx"
export OPENAI_API_KEY="sk-xxxx"
export GOOGLE_API_KEY="xxxx"
Or configure it directly in omp:
/model # 打开模型选择器,可以在这里配置 Key
Method 3: Coding Plan subscription
If you have already subscribed to services such as Cursor, GitHub Copilot, Kilo, Kimi Code, MiniMax Coding Plan, etc., you can route directly to your subscription:
/login # 选择对应的 Coding Plan 提供商,OAuth 授权
Method 4: local models (Ollama / LM Studio)
# Start Ollama first
$ ollama serve
# Select Ollama provider in omp (key optional)
/model # 选择 Ollama,指向 http://localhost:11434
Configuration paths
All configuration is stored in the ~/.omp/ directory:
~/.omp/
agent/
settings.yml # 主配置文件
models.yml # 自定义模型/提供商
keybindings.yml # 快捷键绑定
rules/ # 流规则(stream rules)
skills/ # 技能文档
First conversation: basic TUI operations
This section introduces omp's full-screen TUI interface and basic interaction.
Start omp
# Start in project directory
$ cd ~/your-project
$ omp
After starting, omp enters the full-screen TUI (terminal user interface); tool calls are rendered as cards, and edits show a preview before being written to disk.
Note: omp uses the Kitty keyboard protocol; it is recommended to run it in a terminal that supports this protocol (Kitty, Ghostty, WezTerm, iTerm2) for the best experience.
Basic interaction
Enter your task and press Enter to send:
> 分析这个项目的目录结构,告诉我主要模块是什么
omp automatically calls tools such as read and search to scan the codebase and return a structural summary.
Common keybindings
| Key | Function |
|---|---|
| Enter | Send the message |
| Ctrl+J / Shift+Enter | Newline within a message (without sending) |
| Ctrl+P | Cycle through the available models for the current role |
| Shift+Ctrl+P | Cycle in reverse |
| Ctrl+T | Expand/collapse the to-do panel |
| Ctrl+C | Interrupt the current task |
| Esc | Cancel the pending operation |
| ↑ / ↓ | Browse history messages / options |
| ? | Insert ? on empty input; use /hotkeys to view the shortcut list |
Single execution (non-interactive mode)
# Execute task once and exit
$ omp -p "列出所有 .ts 文件里未使用的 export"
# Pipe input
$ git diff HEAD~1 | omp -p "给这个 diff 写一个精简的 commit message"
Resume a history session
$ omp --resume # 打开会话选择器(Tab 补全可用)
$ omp --resume # 直接恢复指定会话
Detailed explanation of core tools
omp's 32 tools are unified in one namespace; read, search, and bash are the three used most often daily.
read: unified read interface
read is one of omp's killer tools. It not only reads files but also understands content structure:
# Read file (return structured summary, not full dump)
read src/auth/login.ts
# Read directory (return tree structure overview)
read src/
# Read URL (returns structured Markdown, anchors preserved)
read https://docs.anthropic.com/en/api/messages
# Read arXiv paper PDF
read https://arxiv.org/pdf/2604.10739v1
# Read SQLite database
read data/app.db
# Read GitHub PR (unified path interface)
read pr://can1357/oh-my-pi/1428
# Read PR diff
read pr://can1357/oh-my-pi/1428/diff/1
# Read GitHub Issue
read issue://can1357/oh-my-pi/142
Key design: what read returns for a file is generated by Tree-sitterstructural summary(function names, class names, important comments), rather than dumping the whole file into the context. This greatly saves Tokens while retaining key information; when details are needed, the Agent calls read again to expand specific sections.
search:in-process ripgrep
# Regex search (no fork/exec, runs directly in process)
search "useState\(" src/
# With file type filtering
search "TODO:" --type ts
# Search on internal URLs (e.g., PR diff)
search "loginUser" pr://can1357/oh-my-pi/1063/diff
edit: Hashline precise editing
See the next section for details. This is one of omp's most technically sophisticated tools.
bash: persistent Shell session
# Execute command (bash session persists between calls)
bash: npm test
bash: git log --oneline -10
bash: cargo build --release
omp's bash tool embeds a full brush shell (a bash implemented in Rust); instead of forking a new process each time, it maintains a persistent session, with environment variables and the working directory preserved across calls.
eval: Python + JavaScript persistent kernels
See the following chapters for details.
lsp: full LSP operations
See the following chapters for details.
todo: task management
omp has a built-in structured task list, supporting phases and task status tracking. Ctrl+T toggles the visibility of the to-do panel.
ask: structured questions
When the Agent needs a user decision, it calls ask, popping up an interactive selector with recommended options instead of mixing the question into the output.
Hashline: more precise file editing
This is one of omp's most important technical innovations. This section explains how Hashline works and its benchmark results.
Problems with traditional str_replace
Other Agents mostly use the str_replace format, having the model output an "old content" + "new content" pair. The problem is:
- The model easily gets the spaces, newlines, and quotes of the old content wrong
- Once the file is modified after the Agent operates, the anchor becomes invalid
- Errors cause many retries, consuming more Tokens
The Hashline solution
Hashline lets the modelidentify the lines to modify with content hashes, instead of retyping that content:
# Hashline patch example (generated internally by Agent, no need for manual writing)
@@{a3f2}
- const result = compute(x)
+ const result = compute(x, options)
@@{b7c1}
- return null
+ return undefined
{a3f2} is the hash prefix of the target line's content. If the file changes and the hash no longer matches, the patch will berejectedrather than silently applied in the wrong place.
Benchmark results
Measured data from the README:
| Model | Pointer | effect |
|---|---|---|
| Grok Code Fast 1 | Edit success rate | 6.7% → 68.3% (10x improvement) |
| Gemini 3 Flash | vs str_replace | +5 percentage points, surpassing Google's own best implementation |
| Grok 4 Fast | Output Token consumption | Reduced by 61% |
| MiniMax | Pass rate | Improved 2.1x (weights and Prompt completely unchanged) |
ast_edit: structured code rewriting
A higher-level editing tool than Hashline, it uses ast-grep pattern matching then rewrites structurally:
# Replace all console.log(...)
ast_edit: console.log($X) → logger.debug($X)
ast_edit first returns a proposed (preview) card, after the Agent confirms, it calls resolve to actually write to disk: an atomic operation where either all succeed or nothing changes.
ast_grep: structured code queries
Supports Tree-sitter syntax matching for 50+ languages:
# Find all async function calls without await
ast_grep: "promise.then($X)"
LSP integration: what the IDE knows, the Agent also knows
omp integrates a full LSP (Language Server Protocol) client, supporting 14 operations.
Configuring LSP servers
Configure it in .omp/ in the project directory, or through omp's configuration wizard:
Example
~/.omp/agent/settings.yml (example snippet)
lsp
:
servers
:
typescript
:
command
:
typescript-language-server
args
:
[
"--stdio"
]
rust-analyzer
:
command
:
rust-analyzer
python
:
command
:
pylsp
14 LSP operations
| Operation | Description |
|---|---|
| diagnostics | Get diagnostic errors for a file/workspace (like the IDE's red squiggles) |
| hover | Get a symbol's type information and documentation comments |
| definition | Jump to definition |
| references | Find all references |
| rename | Rename a symbol (via workspace/willRenameFiles, ensuring re-exports and barrel files are updated together) |
| code_action | Get and execute code actions (such as auto-import, fixing lint errors) |
| completion | Get the completion list |
| signature_help | Get function signature help |
| document_symbols | Get all symbols in a file |
| workspace_symbols | Search symbols in the entire workspace |
| format | Format a file |
| range_format | Format a selected range |
| implementation | Go to interface implementation |
| type_definition | Go to type definition |
The correct way to rename
A normal Agent renames by searching strings and replacing them one by one, easily missing or mis-replacing. omp's approach is done through the LSP protocol:
> 把 formatBytes 函数重命名为 humanizeFileSize
# omp internal execution:
lsp.references("formatBytes") → 找到 5 处引用,分布在 3 个文件
lsp.rename("formatBytes", "humanizeFileSize") → 通过 LSP workspace/willRenameFiles
search "formatBytes" → 0 matches ✓ 完成
Re-exports, barrel files (index.ts), and aliased imports are all updated correctly, because renaming goes through the LSP protocol rather than text replacement.
Debugger integration (DAP)
omp implements a full DAP (Debug Adapter Protocol) client, supporting 28 debugging operations.
Supported debuggers
| Language | Debugger |
|---|---|
| C / C++ / Rust | lldb-dap / codelldb |
| Go | dlv (Delve) |
| Python | debugpy |
| Node.js / TypeScript | Node.js built-in inspector |
| Universal | Any DAP-compatible debugger |
Typical scenario: locating a C program crash
> 这个 C 程序一直 segfault,帮我找原因
# omp internal execution:
debug.launch("lldb-dap", "./build/demo")
debug.continue() # 运行到崩溃
debug.pause()
debug.stackTrace() # 查看调用栈
debug.scopes(frameId) # 查看局部变量
debug.evaluate("*ptr") # 评估表达式
Typical scenario: troubleshooting a Go service deadlock
> Go 服务挂住了,帮我看看
# omp internal execution:
debug.attach("dlv", pid)
debug.threads() # 列出所有 goroutine
debug.stackTrace(threadId) # 查看挂住的 goroutine 调用栈
No more need to sprinkle fmt.Println or console.log all over the code: omp directly drives a real debugger.
Sub-Agent (Subagents): parallel processing
When a task can be split into mutually independent subtasks, omp uses the task tool to spawn parallel sub-Agents; each sub-Agent runs in an isolated workspace and finally returns a typed result object.
Workspace isolation mechanism
omp uses the platform's native filesystem snapshots to isolate sub-Agent workspaces:
| Operating system / filesystem | Isolation mechanism |
|---|---|
| macOS (APFS) | APFS clone (instant, zero copy-on-write) |
| Linux (btrfs/zfs) | reflink |
| Linux (overlayfs) | overlay mount |
| Windows | projfs / rcopy |
Each sub-Agent gets an independent workspace copy, so they don't interfere with each other and no merge conflicts arise.
Usage examples
> 我有三个微服务:auth-service、api-service、worker-service。
请同时检查它们的依赖有没有已知的安全漏洞,分别出报告。
# omp internal execution:
task(workers=[
{name: "auth", workdir: "services/auth"},
{name: "api", workdir: "services/api"},
{name: "worker", workdir: "services/worker"}
])
# Three child Agents run in parallel, each outputting structured JSON:
# { findings: [...], severity: "high", affected: ["lodash@4.17.15"] }
# Parent Agent merges results, summarizes report
Communication between sub-Agents (IRC)
Parallel sub-Agents can communicate via short messages with the irc tool to coordinate the division of work:
# Agent A:
irc.send("ComponentsExports", {exports: ["Button", "Input"]})
# Agent B adjusts its analysis scope after receiving the message
Pull sub-Agent results
The parent Agent can directly access a sub-Agent's structured output using path syntax:
# Read the path field of the first record in the sub-Agent findings
read agent:///findings.0.path
Hindsight: cross-session memory
Hindsight is omp's project-level memory system, letting the Agent retain its understanding of the codebase between sessions.
How It Works
- retain: when the Agent finds valuable information during a run, it proactively calls retain to write it into the memory bank
- recall: search the memory bank with keywords
- reflect: let Hindsight synthesize information in the memory bank to generate a compositional answer
- At the end of each session, omp automatically compresses the session into a "mental model", which is loaded in the first round of the next session
Scope
Hindsight isproject-levelscoped: what is learned in project A will not leak into project B. Memory is stored in the .omp/ directory (or sharded by project under ~/.omp/).
Actual Effect
The first time you use omp in a project, you need to explain the project structure. After using it for a while, omp knows on its own:
- What tech stack this project uses
- The division of responsibilities of the main modules
- What refactorings have been done before
- Which files are the "minefield" (places that often cause problems)
Code execution: Python + JavaScript dual kernels
Most Agent tools only provide one Python sandbox. omp runs two persistent kernels, and both can call back into the Agent's own tools.
Python kernel (eval)
Example
In the eval tool, Python can call omp's tool.*
import
pandas
as
pd
df
=
pd.
read_csv
(
tool.
read
(
"data/sales.csv"
)
)
Load a file with the Agent's read tool
(
df.
describe
(
)
)
result
=
tool.
search
(
"revenue"
,
"src/"
)
Search within the codebase
JavaScript (Bun) kernel (eval)
Example
// Within the same eval session, you can switch to the JS kernel
const
data
=
tool.
read
(
"data/sales.csv"
)
// Can also call Agent tools
const
top
=
data.
split
(
'\n'
)
.
slice
(
1
)
.
map
(
line
=>
line.
split
(
','
)
)
.
sort
(
(
a
,
b
)
=>
b
[
2
]
a
[
2
]
)
.
slice
(
0
,
5
)
console.
table
(
top
)
Dual kernels share a Prelude
The two kernels share a prelude (preloaded context); you can process data in Python and then generate charts in JS, all within one continuous eval session without leaving the tool interface.
Stream Rules: real-time behavior correction
This is omp's unique real-time behavior-correction mechanism, solving the problem of "the model not following instructions".
Problems with the traditional approach
Writing all the rules into the System Prompt means paying the full Token cost on every conversation, and the model may still ignore them.
How Stream Rules work
Rules aredormant, until a trigger condition appears:
- A regular expression monitors the model's streamed output
- Once it hits (at the mid-token level), the current stream is immediately aborted
- The rule content is injected into the context as a system reminder
- Regenerate from the same position
- The injected rule survives context compression
Example
Example: forbid the use of Box::leak
~/.omp/agent/rules/no-box-leak.yml
name
:
box-leak
pattern
:
"Box::leak"
reminder
: |
Do not use Box::leak in production code paths.
Memory leaks can cause the service to OOM under high load.
Use Arc instead
Effect: when the model writes Box::leak, the stream is aborted, the rule is injected, and the model automatically corrects it to Arc
Quickly create rules with /omfg
omp provides a helper command that lets you describe a rule in natural language; it generates the regex and the rule file:
/omfg 不要在任何地方用 any 类型,要求用具体的类型定义或 unknown
omp generates the rule, validates it, saves it, and it takes effect next time.
Model routing: 40+ providers, four roles
omp uses roles instead of model names to dispatch work, achieving "the right model for the right task".
Four model roles
| Role | Purpose | CLI Flag | Environment Variables |
|---|---|---|---|
| default | Regular conversation and code generation | Default | — |
| smol | Cheap sub-Agent exploration | --smol | PI_SMOL_MODEL |
| slow | Deep reasoning tasks | --slow | PI_SLOW_MODEL |
| plan | Plan mode | --plan | PI_PLAN_MODEL |
# Specify role override at startup
$ omp --smol # 整个会话使用 smol 模型(低成本)
$ omp --slow # 使用慢速推理模型(高质量)
$ omp --plan # 使用计划专用模型
Switch models within a session
/model # 打开交互式模型选择器
/model claude-sonnet-4.6 # 切换到指定模型
Ctrl+P # 循环切换当前角色的可用模型
Custom providers (~/.omp/agent/models.yml)
Example
span style="color: #007F45;">
providers:
my-company-llm
:
type
:
openai-completions
baseUrl
:
https://llm.internal.company.com/v1
apiKey
:
"${MY_LLM_KEY}"
models
:
- id
:
gpt-4o
name
:
Internal GPT-4o
Failover chain
Example
When Claude hits a 429 rate limit, it automatically switches to GPT
retry
:
fallbackChains
:
default
:
- anthropic/claude-sonnet-
4.6
- openai/gpt-4o
- google/gemini-
2.0
-flash
Path-level model binding
Example
This specific repository is forced to use deepseek (low cost), without affecting global configuration
models
:
enabledModels
:
- path
:
~/projects/side-project
models
:
[
"deepseek/deepseek-coder"
]
Key rotation (multi-Key load balancing)
Example
span style="color: #007F45;">
providers:
anthropic
:
apiKeys
:
-
"${ANTHROPIC_KEY_1}"
-
"${ANTHROPIC_KEY_2}"
-
"${ANTHROPIC_KEY_3}"
Automatic rotation: when a single Key exceeds its limit, switch to the next
Quick reference for common slash commands
Type / in the chat input box to trigger command completion.
| Command | Function |
|---|---|
| /model | Open the model picker |
| /login | Log in to a provider (OAuth) |
| /resume | Resume a history session |
| /review | Code review of the current branch / a specified commit / uncommitted changes |
| /commit | Intelligently split commits |
| /omfg | Create Stream Rules in natural language |
| /debug | Open debugging / reporting / profiling tools |
| /hotkeys | View all keyboard shortcuts |
| /reload-plugins | Hot-reload plugins |
| /compact | Manually compress the context (save Tokens) |
| /? | Show help |
/review: prioritized code review
# Review current branch vs main
/review
# Review specified commit
/review abc1234
# Review uncommitted changes
/review --unstaged
omp generates dedicated reviewer sub-Agents to scan in parallel, sorting each issue by P0-P3 priority and giving a confidence score. P0 = blocks release, P3 = optional improvement.
/commit: atomic commit splitting
$ omp commit
omp reads the entire working tree (git_overview + git_file_diff + git_hunk), splits unrelated changes into independent atomic commits, and orders them by dependency:
- Source-code commits are placed before tests, docs, and config
- Changes with dependencies are not incorrectly grouped
- Circular dependencies are rejected and nothing is written
- Lockfiles such as package-lock.json and Cargo.lock are not included in the analysis
Plugins and extensions
omp's plugins are TypeScript modules that use exactly the same API as the built-in tools, with no reserved interfaces.
Install plugins
$ omp install # 从 npm 安装
$ omp install github:user/repo # 从 GitHub 安装
$ omp install ./path/to/plugin # 从本地路径安装
Create a plugin
You can just let omp write it for you:
> 给我创建一个插件,添加 /deploy 命令,
自动运行测试、构建、然后 SSH 上传到生产服务器
omp generates the plugin code, and it takes effect immediately after you /reload-plugins.
Hot reload
No need to restart omp after modifying plugin code:
/reload-plugins
ACP: using omp in the Zed editor
$ omp acp
Connect omp to the Zed editor via the Agent Client Protocol. omp reads the buffer you are editing, writes files through the editor's save path, starts a shell in the editor's terminal, and destructive operations trigger a permission prompt.
Migrating from other tools
One of omp's great advantages isOut-of-the-box readingConfiguration files already created by other tools, with no migration scripts needed:
| Tool | Configuration file | How omp reads them |
|---|---|---|
| Cursor | .cursor/rules/*.mdc | Automatic inheritance |
| Claude Code | .claude/settings.json, CLAUDE.md | Automatic inheritance |
| Cline | .clinerules | Automatic inheritance |
| GitHub Copilot | .github/copilot/instructions.md (applyTo) | Automatic inheritance |
| Codex | AGENTS.md | Automatic inheritance |
| Windsurf | .windsurfrules | Automatic inheritance |
| Gemini CLI | .gemini/ configuration | Automatic inheritance |
When you run omp for the first time, it scans the working directory and automatically loads all detected formats.
Resources and Community
- Official site:omp.sh
- GitHub:github.com/can1357/oh-my-pi(MIT open source)
- Tool documentation:omp.sh/docs/tools
- Provider documentation:omp.sh/docs/providers
- SDK documentation:omp.sh/docs/sdk
- Changelog:github.com/can1357/oh-my-pi/CHANGELOG.md
- npm:@oh-my-pi/pi-coding-agent
- Discord:discord.gg/4NMW9cdXZa