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

pi-auto-mode-router

v2.0.1

Published

Auto Mode Router extension for Pi: route prompts between frontend, logic, and terminal models with optional mid-turn domain switching.

Readme

pi-auto-mode-router

Auto Mode Router is a Pi extension that adds a virtual auto/mode model and routes each turn to the most appropriate model for frontend, logic, or terminal work.

It can also support mid-turn domain changes through a built-in switch_domain tool when a task spans both UI/design and implementation/backend work.

What it does

When Auto Mode is selected, each new prompt goes through this flow:

  1. The prompt is analyzed with your chosen analysis model
  2. The router decides whether the task is primarily:
    • frontend
    • logic
    • terminal
  3. Pi switches to the best configured model for that domain
  4. If the task is multi-domain, the extension can:
    • detect that it spans multiple domains
    • decompose it into ordered phases
    • inject phase guidance into the system prompt
    • let the model call switch_domain to move to the next domain

Highlights

  • Adds a virtual Auto Mode model to /model
  • Commands: /auto-mode and /auto
  • Searchable model picker for analysis/frontend/logic model selection
  • Multi-domain task detection and decomposition
  • Mid-turn model switching with switch_domain
  • Terminal-only tasks can stay on the analysis model
  • Status indicator such as auto:armed, auto:frontend, auto:logic, auto:terminal, auto:frontend [1/3]
  • Config stored in ~/.pi/agent/auto-mode-router.json
  • Safety limit of 6 mid-turn switches per turn

Important implementation note

The current implementation does not do automatic file-extension or path-based routing during tool calls.

So while the model receives guidance about when to switch domains, actual mid-turn switching happens through:

  • initial prompt analysis and routing
  • multi-domain phase guidance
  • explicit switch_domain tool calls by the model

There is a reserved tool_call section in the code for future work, but no file-based auto-switching logic is currently implemented there.

Installation

Option 1: install from npm as a Pi package

pi install npm:pi-auto-mode-router

Then restart Pi or run:

/reload

Option 2: local development install

If you are developing locally, put the package under an auto-discovered extension location, for example:

  • ~/.pi/agent/extensions/auto-mode-router/
  • .pi/extensions/auto-mode-router/

Then run:

/reload

Setup

  1. Run /auto-mode config
  2. Choose:
    • analysis model
    • frontend model
    • logic model
    • whether Mid-turn switching is on
  3. Save with Ctrl+S
  4. Open /model
  5. Select auto/mode
  6. Keep using Pi normally

Commands

  • /auto-mode → open menu
  • /auto-mode on → enable Auto Mode
  • /auto-mode off → disable Auto Mode
  • /auto-mode status → show current state
  • /auto-mode config → change models and mid-turn setting
  • /auto → short alias
  • Alt+A → toggle Auto Mode

Example

User prompt:

Build a user profile page. Add a backend profile API and a polished frontend card UI.

Possible routing flow:

  1. Analyzer detects a multi-domain task
  2. Phases are created:
    • Phase 1: [logic] profile API and data handling
    • Phase 2: [frontend] profile card UI and styling
  3. Pi starts with the logic model
  4. The model calls:
switch_domain({ domain: "frontend", reason: "API is done, moving to the UI" })
  1. Pi switches to the frontend model
  2. Status updates from auto:logic [1/2] to auto:frontend [2/2]

How it is built

This extension uses Pi extension APIs documented in the official docs, including:

  • registerProvider() for the virtual auto/mode model
  • registerTool() for switch_domain
  • input event handling for prompt analysis
  • before_agent_start for phase guidance injection
  • model_select handling for enabling/disabling Auto Mode
  • agent_end for cleanup and phase reporting
  • ctx.ui.custom(), SettingsList, and notifications for configuration UI
  • complete() from @mariozechner/pi-ai for classifier calls

Packaging for Pi

This package is structured as a Pi package and can be installed with pi install npm:pi-auto-mode-router.

Pi package docs used for this setup:

  • package must include keywords: ["pi-package"]
  • package should declare a pi manifest
  • core Pi libraries should stay in peerDependencies

Current manifest:

{
  "name": "pi-auto-mode-router",
  "keywords": ["pi-package"],
  "pi": {
    "extensions": ["./index.ts"]
  }
}

Publishing to npm

From this directory:

npm publish --access public

Useful checks before publishing:

npm pack --dry-run
npm view pi-auto-mode-router version

Notes

  • Auto Mode is only useful when the selected analysis/frontend/logic models are available and authenticated in Pi
  • If the analysis model is missing or fails, the extension falls back to heuristic routing
  • Multi-domain execution guidance is injected into the system prompt for the turn
  • Mid-turn switching is capped to avoid loops