@zenspc/pi-preferred-thinking

Model-specific thinking level preferences for Pi

Packages

Package details

extension

Install @zenspc/pi-preferred-thinking from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@zenspc/pi-preferred-thinking
Package
@zenspc/pi-preferred-thinking
Version
0.2.1
Published
Jul 17, 2026
Downloads
247/mo · 11/wk
Author
ph03nix
License
MIT
Types
extension
Size
21.5 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./extensions/preferred-thinking.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@zenspc/pi-preferred-thinking

Model-specific thinking level preferences for the Pi coding agent.

Pi's built-in defaultThinkingLevel is global. This extension lets each model keep its own preferred level. Invalid or missing values are ignored.

Install

pi install npm:@zenspc/pi-preferred-thinking

Local development:

pi -e ./packages/pi-preferred-thinking
pi install ./packages/pi-preferred-thinking

Config

$PI_CODING_AGENT_DIR/extensions/preferred-thinking.json
# default:
~/.pi/agent/extensions/preferred-thinking.json

Example:

{
  "anthropic/claude-opus-4-6": "high",
  "openai/gpt-5.2": "medium",
  "google/gemini-2.5-pro": "low"
}

Keys are provider/id. Valid levels: off, minimal, low, medium, high, xhigh, max.

Rules:

  • Missing models are left alone (current/session level stays).
  • Invalid levels and malformed keys are dropped on load.
  • Malformed or missing files act like an empty map.

When preferences apply

Applied when:

  • You switch models via /model, model picker, or Ctrl+P (model_select sources set / cycle).
  • A new session starts (session_start reasons startup / new) and no CLI thinking override is present.

Not applied when:

  • Resuming, forking, or reloading a session (session history wins).
  • Startup used --thinking <level> or --model provider/id:<level>.
  • The model has no mapping, or the mapping is invalid.

Notes:

  • Pi still clamps levels to what the active model supports.
  • pi.setThinkingLevel() also updates Pi's global default thinking level (same as Shift+Tab).
  • Explicit scoped provider/model:thinking values used with --models are overwritten by a preferred mapping when you cycle to that model.

Commands

/preferred-thinking              show available subcommands (same as help)
/preferred-thinking help
/preferred-thinking show
/preferred-thinking list
/preferred-thinking set <level>
/preferred-thinking clear
/preferred-thinking reload
  • Bare /preferred-thinking and help list subcommands, levels, and the config path.
  • Tab-completes subcommands; after set, completes thinking levels.
  • show prints preferred + live level for the current model.
  • set saves the preference for the current model and applies it immediately.
  • clear removes the stored mapping only; the live thinking level is unchanged.
  • reload re-reads the JSON file from disk.

Security notes

This extension only reads and writes a local preference JSON file under the Pi agent directory. It does not make network calls, run shell commands, or handle credentials.

Untrusted config is treated as hostile input:

  • File size is capped (100_000 bytes).
  • Entry count and key length are capped.
  • Levels are allowlisted.
  • Dangerous object keys (__proto__, constructor, prototype) are rejected.
  • Parsed maps use a null prototype; lookups use own-property checks.
  • Load uses lstat and accepts only a regular file (symlinks are ignored).
  • Save writes atomically (temp file + rename), mode 0o600, and refuses to overwrite non-regular paths.
  • Failed saves leave the live thinking level unchanged and report an error.

Like all Pi extensions, it runs with full local permissions of the Pi process.

Source

extensions/preferred-thinking.ts
extensions/preferred-thinking-helpers.ts