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

@brain0pia/pi-ultrathink

v0.3.4

Published

Pi extension for /ultrathink review loops with conditional git commits

Readme

pi-ultrathink is a Pi extension that gives your agent the ability to reflect, verify, and iteratively improve its work before handing it back to you.

By adding a simple /ultrathink command, it transforms single-shot generations into a structured, multi-pass reasoning loop driven by real Git changes.

🚀 Why use Ultrathink?

Standard LLM interactions are one-and-done. But complex software engineering tasks—like heavy refactors, tricky bug fixes, or architecture shifts—often require multiple passes:

Think of pi-ultrathink as manually dialing up the thinking_budget or reasoning_effort of a model—but specifically focused on double-checking and self-correction. Just like humans produce better code when they review their own work or take a second look, models significantly improve when forced into an explicit verification pass.

But it doesn't stop at just "check your work." Because you can edit the review prompt before the loop starts, you can use ultrathink to encourage the model to keep trying until it makes progress on a specific metric—like getting a test suite to pass or satisfying a particular evaluation script.

  1. Draft the initial implementation
  2. Review the changes against the original goal
  3. Fix edge cases or missed requirements
  4. Verify the final state

pi-ultrathink automates this entire process.

🔄 How the Loop Works

flowchart TD
    Start([User: /ultrathink Fix the task]) --> Prompt[TUI Auto-Review Prompt Editor]
    Prompt -->|Accept/Edit| V1[Agent Pass 1: Initial Implementation]
    Prompt -->|Cancel| End([Abort])
    
    V1 --> CheckGit1{Did Git change?}
    CheckGit1 -->|Yes| Commit1[Create Git Commit v1]
    CheckGit1 -->|No| Done([Done: No changes needed])
    
    Commit1 --> Review1[Auto-Review Prompt: Diff + Instructions]
    Review1 --> V2[Agent Pass 2: Refinement]
    
    V2 --> CheckGit2{Did Git change?}
    CheckGit2 -->|Yes| Commit2[Create Git Commit v2]
    CheckGit2 -->|No| Done
    
    Commit2 --> ReviewN[Auto-Review... until max iterations or stable]

🛠️ Usage

Inside Pi, simply prefix your task with /ultrathink:

/ultrathink Migrate the database schema to v4 and update all queries

The Interactive Review Prompt

Before the agent starts, a TUI overlay appears. This lets you inspect and modify the Review Instructions that will be fed to the agent on subsequent passes.

The prompt is pre-filled with instructions telling the agent to look at the git diff of its previous pass and continue only if substantial improvements are needed.

  • Press Enter to accept and start the loop.
  • Edit the text to add specific review criteria (e.g., "Make sure to check for memory leaks").
  • Press Esc to cancel.

The Conversation Flow

The loop unfolds transparently in your chat history. Every pass is visible, and you can see exactly how the agent evaluated its own work:

user: /ultrathink Migrate the database schema...
assistant: [v1] <initial implementation>
user: [Auto] Original task: Migrate...
      Review the current repository changes with: git diff <startSha> HEAD
      Continue working only if...
assistant: [v2] <fixes missed foreign key constraints>
user: [Auto] ...
assistant: [v3] <no changes needed, all good>

🛑 When does the loop stop?

The loop is completely Git-driven.

  1. Stable State (No Changes): If a pass results in zero changes to the Git repository, the agent has effectively said "I'm done." The loop stops immediately.
  2. Iteration Cap: A safety limit (maxIterations, default 4) prevents infinite loops.
  3. User Cancellation: Interrupting the active agent turn (Escape by default) or typing a new prompt immediately halts the loop.

💾 Git Checkpoints

Every successful pass that alters the codebase automatically generates a Git commit:

ultrathink(<runId>): v1

This provides a granular undo history. You can easily roll back to a specific iteration if the agent went down the wrong path in a later pass:

git log --oneline --graph

🔮 Roadmap / Future Ideas

  • Context Management Modes:
    • clean mode: Complete context reset between iterations to prevent the model from getting stuck in a rut.
    • careful mode: Context reset triggered automatically when the conversation hits a specific token percentage threshold.
  • Improved VS Code Copilot Support: Run all iterations within a single request by leveraging the ask_user tool to integrate the auto-review seamlessly.
  • Oracle Model Support: Allow a distinct, separate model (e.g., a larger or specialized reasoning model) to conduct the auto-review instead of the model that wrote the code.

📦 Installation

Install from npm:

pi install @brain0pia/pi-ultrathink

Quick try (without installation):

pi -e npm:@brain0pia/pi-ultrathink

⚙️ Configuration

You can customize the behavior by creating .pi/ultrathink.json in your project root:

{
  "maxIterations": 4,
  "continuationPromptTemplate": "Optional custom review prompt body appended after the fixed task/diff header",
  "commitBodyMaxChars": 4000,
  "git": {
    "mode": "current-branch",
    "allowDirty": false
  }
}

Configuration Options:

  • maxIterations: Maximum number of refinement passes.
  • continuationPromptTemplate: Default text for the review TUI.
  • commitBodyMaxChars: Truncation limit for the agent's summary in the Git commit.
  • git.mode:
    • current-branch (Default): Commits directly to your active branch.
    • scratch-branch: Creates a temporary branch for the loop.
    • off: Disables auto-committing entirely.
  • git.allowDirty: If false, prevents the loop from starting if you have uncommitted changes.

💻 Development

Install dependencies and run the checks:

npm install
npm run check

Run the deterministic SDK demo:

npm run demo

The demo uses a fake provider and temporary git repositories, so it does not require real model credentials.