@monochromatic-dev/pi-shared-model-selection #
Shared model-selection logic for pi plugins.
This package lives under package/pi-shared/ because it is reusable pi extension infrastructure,
not a pi extension itself.
Packages in this category must be intended for at least two pi packages
and expose APIs that make sense outside one extension command,
renderer,
or config surface.
Actual pi extensions stay under package/pi-plugin/.
Export tiers #
The package uses subpath exports so lightweight consumers can import string and type helpers without loading platform-coupled modules.
@monochromatic-dev/pi-shared-model-selectionand/coreexport dependency-free helpers and types./scopeexports scope pattern, settings, and effective-scope helpers./costexports cost scoring and ranking helpers./budgetexports fast judge-model strategy and override selection helpers with injected auth callbacks./pi-coding-agentexports wrappers that directly import@earendil-works/pi-coding-agent.
@earendil-works/pi-ai and @earendil-works/pi-coding-agent are optional peer dependencies.
Root and /core modules must not import either peer.
Consumer boundaries #
Advisor and auto-mode can import heavier /scope,
/cost,
/budget,
and /pi-coding-agent modules.
Thinking-defaults imports only root or /core helpers.
Synchronous live scope #
readLiveScope() uses the same live-scope precedence as resolveEffectiveScope():
a getter takes precedence over the property.
It accepts raw models and { model, thinkingLevel } entries,
normalizes their canonical slugs,
and filters malformed entries.
An unavailable,
non-array,
or empty live value returns NO_LIVE_SCOPE.
Pi uses an empty cycle list for SDK sessions without an explicit live restriction.
resolveEffectiveScope() then checks argv,
configured settings,
and available models in that order.
Configured restrictions that match no models remain empty;
a nonempty live list containing only malformed entries also remains empty.
Use this helper for a final dispatch check after asynchronous authentication.
Fast judge-model ranking #
Budget helpers retain their API names for compatibility,
but automatic judge selection ranks by speed heuristic.
The selector first keeps the configured major-version families,
then scores model id and display name tokens:
highspeed or high-speed > fast > luna > flash or spark > terra >
turbo > nano > mini > haiku > lite or light > no signal.
When no speed signal separates candidates,
selection falls back to input cost and version.