npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-ralph-loop-support

v1.0.2

Published

Self-referential development loop for OpenCode — auto-continuation until completion promise

Readme

🔁 opencode-ralph-loop

English · 简体中文

A lightweight OpenCode plugin that implements the Ralph Loop pattern — a self-referential completion loop that keeps your AI agent working until a task is truly 100% done.

Also includes ebuilder agent support — switch to the ebuilder agent and auto-continuation activates automatically, no commands needed.

Inspired by the Ralph Loop and Sisyphus features in oh-my-opencode, reimplemented as a standalone plugin with zero dependencies.


🔄 How It Works

Ralph Loop (command-based)

User issues /ralph-loop or /ulw-loop command
  → Plugin writes loop state to .ralph-loop.state.json
  → Agent executes the task
  → session.idle event fires
  → Plugin checks Agent output for <promise>DONE</promise>
    → ✅ Found: Loop complete! Toast notification.
    → ❌ Not found: Inject continuation prompt → Agent continues
    → Repeat until completion or max iterations

ebuilder Agent (automatic)

User switches to ebuilder agent in TUI
  → chat.message hook detects agent === "ebuilder"
  → Plugin writes loop state to .ebuilder.state.json
  → Agent executes the task
  → session.idle event fires
  → Plugin checks Agent output for <promise>DONE</promise>
    → ✅ Found: Loop complete!
    → ❌ Not found: Inject continuation prompt → Agent continues
  → User switches back to build/plan → ebuilder state auto-cleared → Loop stops

✨ Features

| Feature | Description | |---------|-------------| | 🔁 /ralph-loop | Standard completion loop (max 100 iterations) | | 🚀 /ulw-loop | Ultrawork mode with maximum intensity (max 500 iterations) | | 🛑 /cancel-ralph | Cancel an active loop (works for both modes) | | 🤖 ebuilder agent | Auto-continuation when switched to ebuilder agent (max 500 iterations) | | 🎯 Completion promise detection | Scans Agent output for <promise>DONE</promise> | | 🔔 Toast notifications | Real-time iteration and completion updates | | 🛡️ In-flight protection | Prevents duplicate idle event handling | | ⚙️ Custom parameters | --max-iterations=N and --completion-promise=TEXT |


📦 安装

方式一:npm 包安装(推荐)

npm install -g opencode-ralph-loop-support

或在项目 opencode.jsonplugin 数组中加入 opencode-ralph-loop-support(OpenCode 会自动安装):

{
  "plugin": ["opencode-ralph-loop-support"]
}

方式二:GitHub Release 资产安装(无需 npm 登录)

每次发布都会同时上传一个 tarball 到 GitHub Releases,可直接从 URL 安装,不依赖 npm 账号/token:

npm install https://github.com/FountainChan/opencode-ralph-loop/releases/download/v1.0.2/opencode-ralph-loop-support-1.0.2.tar.gz

将 URL 中的版本号 v1.0.2 替换为最新发布版本即可。

方式三:本地路径安装(推荐,开发用)

cd ~/.cache/opencode
npm install /path/to/opencode-ralph-loop-support

💡 这会创建符号链接,修改源码后无需重新安装,改动实时生效。

方式四:GitHub 仓库安装

cd ~/.cache/opencode
npm install FountainChan/opencode-ralph-loop

方式五:直接文件路径(备选)

如果 npm 方式有问题,可直接在 opencode.jsonplugin 字段引用 JS 文件路径:

{
  "plugin": [
    "file:///path/to/ralph-loop/src/index.js"
  ]
}

配置

~/.config/opencode/opencode.json 中添加插件:

{
  "plugin": ["opencode-ralph-loop-support"]
}

如果需要使用 ebuilder agent(自动续写),额外添加 agent 配置:

{
  "agent": {
    "ebuilder": {
      "mode": "primary",
      "description": "Autonomous agent with auto-continuation.",
      "prompt": "You are ebuilder..."
    }
  }
}

🗂️ 项目结构

opencode-ralph-loop/
├── src/
│   └── index.js        # 插件入口
├── scripts/
│   └── cleanup.py      # 清理脚本(卸载前执行)
├── package.json
├── README.md
└── .gitignore

🧹 卸载

在删除插件前,执行清理脚本以移除残留的命令条目:

# 1. 预览要清理的内容
python scripts/cleanup.py --source ralph-loop --dry-run

# 2. 执行清理
python scripts/cleanup.py --source ralph-loop

# 3. 卸载 npm 包
cd ~/.cache/opencode
npm uninstall opencode-ralph-loop-support

# 4. 从 opencode.json 的 plugin 数组中移除 "opencode-ralph-loop-support"

💡 --dry-run 可以先预览效果,确认无误后再实际执行。


🎮 Usage

🤖 ebuilder Agent (recommended for long tasks)

  1. Switch to the ebuilder agent in the TUI (Tab key or agent selector)
  2. Type your task normally
  3. The agent will work continuously without stopping
  4. Switch back to build to stop auto-continuation

🔁 Ralph Loop Commands

# Start a standard loop
/ralph-loop "Refactor the auth module and ensure all tests pass"

# Start an ultrawork loop (maximum intensity)
/ulw-loop "Migrate all API clients to v2"

# With custom parameters
/ralph-loop "Build the dashboard" --max-iterations=50 --completion-promise=SHIPPED

# Cancel an active loop
/cancel-ralph

🏁 How the Agent Signals Completion

When the Agent has fully completed the task, it outputs:

<promise>DONE</promise>

The plugin detects this tag in the Agent's response and stops the loop. You can customize the promise text with --completion-promise.


⚙️ Configuration

No configuration file needed. Loop states are stored in .ralph-loop.state.json and .ebuilder.state.json in the project directory and automatically cleaned up when loops complete or are cancelled.


📊 Comparison with oh-my-opencode

| Feature | oh-my-opencode | opencode-ralph-loop | |---------|---------------|-------------------| | 📁 File count | ~25 TypeScript files | 1 JS file | | 📦 Dependencies | Full OmO plugin | Zero dependencies | | 👁️ Oracle verification | ✅ | ❌ | | 🔄 Session reset strategy | ✅ | ❌ (continue only) | | 🔧 Session recovery | ✅ | ❌ | | 🛡️ Race condition mutex | ✅ (debounce) | ✅ (inFlight Set) | | 🔁 /ralph-loop | ✅ | ✅ | | 🚀 /ulw-loop | ✅ | ✅ | | 🛑 /cancel-ralph | ✅ | ✅ | | 🤖 ebuilder/Sisyphus agent | ✅ (Sisyphus) | ✅ (ebuilder) | | ⏩ Auto-continuation on agent switch | ✅ | ✅ | | 🔔 Toast notifications | ✅ | ✅ | | ⚙️ Custom max iterations | ✅ | ✅ | | 🎯 Custom completion promise | ✅ | ✅ |


📄 License

MIT