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-lifeline

v0.1.3

Published

Pi extension that lets smaller models phone a stronger advisor model when autoresearch gets stuck.

Readme

pi-lifeline

A Pi extension that lets a smaller/local model ask a stronger advisor model when an autonomous optimization loop gets stuck.

Inspired by Tobi Lütke's observation that local models can run pi-autoresearch effectively when they occasionally ask a stronger model for ideas.

What it does

pi-lifeline adds:

  • Tool: phone_a_friend — ask a configured stronger model for strategy, critique, debugging help, or next experiment ideas.
  • Command: /lifeline — inspect status, thresholds, and advisor config.
  • Autoresearch trigger detection: watches log_experiment results and detects repeated failures or plateaus.
  • Rate limiting: avoids calling the expensive model every iteration.

The larger model is a strategy reset mechanism, not the inner loop.

small/local model: edit → run_experiment → log_experiment → repeat
                                  │
                                  │ only when stuck/plateaued
                                  ▼
                     phone_a_friend → stronger advisor model

Why not call every iteration?

Calling the larger model every run defeats the point. The default policy only triggers after evidence that the local model is stuck:

{
  "auto": true,
  "action": "nudge",
  "minRunsBetweenCalls": 5,
  "triggerAfterConsecutiveFailures": 3,
  "triggerAfterPlateauRuns": 6,
  "maxCallsPerSession": 10
}

Default behavior is nudge, not hidden spending: when stuck, the extension sends a steer message telling the agent to call phone_a_friend. If you want fully automatic advisor calls, set "action": "ask".

Install

Install from npm with Pi:

pi install npm:pi-lifeline

Then reload Pi:

/reload

Verify it loaded:

/lifeline

Create a global starter config:

/lifeline init

Then edit ~/.pi/agent/pi-lifeline.json to adjust your advisor provider/model or thresholds.

Load locally for development

From this repo:

pi -e ./extensions/pi-lifeline/index.ts

As a Pi package, package.json exposes:

{
  "pi": {
    "extensions": ["./extensions/pi-lifeline"]
  }
}

Configuration

Create pi-lifeline.json in your Pi agent config directory, usually ~/.pi/agent/pi-lifeline.json:

{
  "auto": true,
  "action": "nudge",
  "minRunsBetweenCalls": 5,
  "triggerAfterConsecutiveFailures": 3,
  "triggerAfterPlateauRuns": 6,
  "maxCallsPerSession": 10,
  "advisor": {
    "provider": "openai",
    "model": "gpt-5.5",
    "thinking": "high",
    "maxTokens": 4096,
    "temperature": 0.7
  },
  "includeAutoresearchContext": true
}

You can also set:

export PI_LIFELINE_ADVISOR_PROVIDER=openai
export PI_LIFELINE_ADVISOR_MODEL=gpt-5.5
export PI_LIFELINE_THINKING=high
export PI_LIFELINE_MAX_TOKENS=4096
export PI_LIFELINE_TEMPERATURE=0.7

For tests/smoke runs without spending tokens:

export PI_LIFELINE_FAKE_RESPONSE="Try profiling phase timings and attack the largest non-noisy bucket."

Tool: phone_a_friend

Inputs:

  • question — specific question for the advisor.
  • context — optional logs, metrics, code summary, failed ideas.
  • mode — one of:
    • ideas
    • critique
    • debug
    • next_experiment
  • max_ideas — default 5.
  • provider / model — optional per-call override.

Example use:

{
  "question": "We have three discarded parser optimization attempts. What should we try next?",
  "mode": "next_experiment",
  "context": "Recent runs: #2 discard inline cache, #3 crash arena reuse, #4 discard branchless scan",
  "max_ideas": 4
}

The advisor prompt explicitly asks for strategic, testable advice — not full patches — and warns against benchmark cheating.

Command: /lifeline

/lifeline

Shows:

  • active config source
  • advisor provider/model
  • thresholds
  • calls this session
  • autoresearch run count
  • current trigger decision
/lifeline init

Opens a small setup wizard, asks for the advisor model, thinking/reasoning level, and auto-action policy, then creates global ~/.pi/agent/pi-lifeline.json without overwriting an existing file.

/lifeline sample-config

Prints the starter config without writing a file.

Autoresearch integration

When pi-autoresearch is active, pi-lifeline reads autoresearch.jsonl and watches log_experiment results.

It triggers when either:

  1. trailing failures reach triggerAfterConsecutiveFailures
    • statuses: discard, crash, checks_failed
  2. no kept improvement has happened for triggerAfterPlateauRuns

It respects:

  • minRunsBetweenCalls
  • maxCallsPerSession
  • auto: false

With includeAutoresearchContext: true, the tool includes recent autoresearch.jsonl runs in the advisor prompt.

Validation plan

1. Static validation

npm run check

This verifies the extension and policy modules parse under Node's TypeScript stripping.

2. Policy unit tests

npm test

Tests cover:

  • default config normalization
  • consecutive failure detection
  • keep resetting failure streak
  • plateau detection
  • higher and lower metric directions
  • minRunsBetweenCalls
  • maxCallsPerSession
  • auto: false

3. Fake advisor smoke test

export PI_LIFELINE_FAKE_RESPONSE="Try measuring phase timings before further code changes."
pi -e ./extensions/pi-lifeline/index.ts

Then ask the agent to call phone_a_friend. Expected: the tool returns the fake response and records a session call without requiring real model auth.

4. Autoresearch fixture smoke test

Create autoresearch.jsonl:

{"type":"config","name":"test","metricName":"score","metricUnit":"","bestDirection":"lower"}
{"run":1,"metric":100,"status":"keep","description":"baseline","timestamp":1}
{"run":2,"metric":101,"status":"discard","description":"bad 1","timestamp":2}
{"run":3,"metric":102,"status":"discard","description":"bad 2","timestamp":3}
{"run":4,"metric":103,"status":"discard","description":"bad 3","timestamp":4}

Start Pi with the extension and run /lifeline. Expected: current decision says trigger due to 3 consecutive failures.

5. Real advisor smoke test

Configure a cheap available model first:

{
  "auto": true,
  "action": "ask",
  "minRunsBetweenCalls": 0,
  "triggerAfterConsecutiveFailures": 1,
  "triggerAfterPlateauRuns": 99,
  "maxCallsPerSession": 1,
  "advisor": {
    "provider": "google",
    "model": "gemini-2.5-flash",
    "maxTokens": 1024,
    "temperature": 0.3
  }
}

Expected:

  • advisor auth resolves via Pi model registry
  • main model is not changed
  • advisor returns a concise strategy message
  • no code is modified by the advisor directly

Design notes

  • The small model remains responsible for edits and experiments.
  • The strong model is used only for strategic advice.
  • Defaults are intentionally conservative to avoid token waste.
  • action: "nudge" makes cost explicit; action: "ask" is available for trusted unattended runs.