pi-model-fit0.4.11
Pi extension and skill for evaluating models, routes, and context budgets.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-model-fit
Agent skill that evaluates AI models across native providers and CLIProxyAPI, analyzes context budgets and compaction thresholds under vekexasia engineering practices, and recommends optimal models and reasoning efforts for Pi workflow roles, aliases, and Guardian Angel (GGA) code reviews.
scripts/inventory.mjsinspects installed/logged-in providers, available models with context/output/thinking metadata, and resolves role and alias mappings acrosspi-ext-rolesand legacy paths.--tableprints the same view as markdown.scripts/agent-routing.mjsprojects the canonicalpi-ext-rolesalias behind each gentle-pi agent (mapping inreferences/agent-routing.json) and reports the drift against gentle-pi's routing authority<configHome>/models.json, plussubagents.json, agent frontmatter anddefault_model.--table,--json,--apply. gentle-pi never readspi-ext-rolesand cannot resolve its aliases, so this projection is the only bridge.scripts/plan.mjsdetects your OpenAI and Anthropic subscription tiers from local OAuth metadata, readingauth.jsonand the high-availabilityha.json(prints plan names only).scripts/quota.mjsattributes every configured role route to the billing domain and plan that pays for it, and prints the allowance that plan publishes.--table(default),--json,--no-planto stay offline. A plan it cannot detect isUNKNOWN, never guessed.scripts/usage.mjsreads the local Pi session logs and reports what each route actually drew: requests, output, cache ratio, API-equivalent cost, and total tokens in the last 5h, day, week and month.--table,--json,--days N. It then compares each billing domain against the window its vendor publishes: dollars foropencode-go, opaque for a plan that publishes no token quota. Effort is not recorded in those logs and is never inferred.scripts/matrix.mjsjoins roles, aliases, billing domains, quotas, prices and measured speed into one table.--table,--aliases,--json,--role <name>.scripts/prices.mjscompares the local price of every routed model against models.dev, LiteLLM and pi.dev, and reports a catalog quoting the peak price asmatch (catalog lists peak)instead of drift.scripts/doctor.mjsprobes the research stack (Firecrawl MCP and API, Crawl4AI, Lightpanda CDP, BrowserOS, Playwright, containers, host binaries) and states whether a refresh is possible in full, in part, or blocked. Three states:up,down,unknown. Exit 0 for full or partial, 1 for blocked.--json,--layer <id>,--no-network.scripts/catalog.mjslists models, prices and accepted thinking levels from pi.dev (openai-codex, anthropic, google, opencode-go) and flags new ones (--updaterecords a baseline).scripts/drift.mjs <models.json>compares a local Pimodels.jsonwith pi.dev and exits 1 on price, context or level drift.references/source-index.jsonis the fixed, categorized source registry for recurring model, price, benchmark, CLIProxyAPI, and user-evidence refreshes. It records URL or deployment template, provider, purpose, scope, access route, verification state, refresh cadence, and caveats.references/parameter-index.jsonandreferences/parameter-index.mddefine the stable parameter registry for every model comparison cell, including unit, source of truth, evidence gate and unknown form.references/provider-index.jsonandreferences/provider-index.mdregister providers, normalized Go/Plus/Pro/Free/API tiers, model families, billing boundaries and published quota windows.references/comparison-table.mdis the durable subscription-tier and model-family comparison table; per-route canonical values stay inreferences/comparison-canon.md.scripts/sources.mjsderives its public catalog URLs fromreferences/source-index.jsonand fetches bounded, redacted metadata from models.dev, LiteLLM's model price map, and Pi.dev provider catalogs. It treats unavailable catalogs asUNVERIFIEDrather than as drift-free evidence.scripts/report.mjsanalyzes all available native and CLIProxyAPI models, cross-checks aliases and roles against the three public catalogs, calculates context headroom and reserve tuning, evaluates speed and cost tiers, and generates a date-stamped markdown report saved inreports/YYYY-MM-DD.md.references/threshold-policy.jsonis the single machine-readable home for context, output, reserve and trigger defaults. Edit this file or pass--threshold-policy PATHtoreport.mjs; do not duplicate defaults in code.references/context-budget.mdspecifies context window measurement, reserve calculation formulas, and proactive compaction handling; numeric defaults live inreferences/threshold-policy.json.references/rubric.mdmaps workflow roles to capability, context window, output budget, speed tier, and effort requirements.references/claude-code.mdsummarizes how Claude Code selects model and effort.scripts/opencode-go-fit.mjsreads a configured, authenticated CLIProxyAPI/v1/modelsendpoint, filters free OpenCode Go entries, and scores them against the Pi role rubric without changing consumer defaults.scripts/cliproxyapi-catalog.mjsreads the authenticated gateway catalog, normalizes every upstream provider family, and reports exact gateway routes, limits, prices, modalities, and evidence gates without changing consumer defaults.scripts/memory-arbitration.mjs [root]checks the repository memory for contradictions: it compares the arbitration precedence and the authoritative memory root claimed by.ai/decisions/against.ai/directives.md,.ai/conventions.mdand.ai/CONTEXT.md, and flags a cited decision that does not exist. Exit 0 when the memory agrees, 1 with oneCONTRADICTION <kind>line per disagreement, 2 when the root has no.ai/. It reads memory only and rewrites nothing.
Commands
/pi-model-fit is a Pi extension command with a submenu; the three templates below work without it, including in a headless run. Neither ever edits pi-ext-roles, ha.json or provider configuration: they report, then ask.
| Command | What it does | Writes anything? |
|---|---|---|
/pi-model-fit |
Opens the menu (see below) | no |
/model-fit-roles |
Role → route → effort → context/output → floor table, plus the subscription/allowance table | no |
/model-fit-plan [domain] |
Which subscription pays for each route, what it publishes, which effort is allowed there, and what stays UNKNOWN |
no |
/model-fit-refresh [scope] |
Full refresh: toolchain doctor, preflight, catalogs, plan/quota, bounded market research through the documented source stack, then a dated report | writes reports/<date>.md and refreshes the reference JSON only where a real measurement was read |
The /pi-model-fit menu:
- Toolchain check (crawl, CDP, browser) —
doctor.mjs: can research run right now, and through which path. - Role matrix: plan, quota, cost, speed —
matrix.mjs --table: one row per role and alias. - Subscriptions and quotas —
quota.mjs --tableplus the effort policy fromreferences/plan-quota-matrix.md. - Observed usage vs plan windows —
usage.mjs --table: what each route actually drew in the last 5h, day, week and month, and how that sits against the published window. - Cost sync: models.dev, LiteLLM, pi.dev —
prices.mjs: local price against the three public catalogs. - Research for a date — asks for
YYYY-MM-DD, then injects the refresh brief with that report date and the previous report of that date as baseline. - Latest report — the newest dated
reports/YYYY-MM-DD.md, shown in full and paged in the panel.
Install
Install with the Vercel Skills CLI (Node 22+; the GitHub Actions release workflow uses Node.js 24; the repository is private, so git must be authenticated for GitHub):
# Pi (global), same mechanism as Engineering Excellence
npx skills@latest add darkrei08/pi-model-fit --skill pi-model-fit --global --agent pi --copy --yes
# Every supported agent
npx skills@latest add darkrei08/pi-model-fit --skill pi-model-fit \
--agent codex claude-code antigravity antigravity-cli pi --global
From a local checkout, install from a temporary tracked-only copy. Skills CLI copies untracked runtime state too and fails on .codegraph/daemon.sock; git ls-files excludes it:
tmp=$(mktemp -d)
git ls-files -z | tar --null -T - -cf - | tar -xf - -C "$tmp"
(cd "$tmp" && npx skills@latest add . --skill pi-model-fit --global --agent pi --copy --yes)
rm -rf "$tmp"
The root SKILL.md remains the source for this GitHub/Vercel Skills CLI installation.
npm/Pi package
The npm package is the Pi package source and can appear in the gallery at pi.dev/packages; there is no separate Pi artifact registry. The pi-package keyword and the pi manifest make the package discoverable and load its extension and skill:
# Install the published package into Pi
pi install npm:pi-model-fit@0.4.11
# Install it as an npm package
npm install pi-model-fit@0.4.11
Reusable GitHub Action
The repository also exposes a composite GitHub Action from action.yml. It expects the caller to check out this repository and runs npm run package:check followed by npm test with Node.js 24 and npm 11.5.1. It has no inputs or outputs and does not read npm credentials:
steps:
- uses: actions/checkout@v4
with:
repository: darkrei08/pi-model-fit
ref: main
- uses: darkrei08/pi-model-fit@main
Use a branch or tag that contains action.yml; the npm package and the GitHub Action are separate delivery paths.
Run these commands locally before publishing. npm login prompts interactively; never put an npm token in this repository or in a command argument:
npm login --registry=https://registry.npmjs.org/
npm whoami --registry=https://registry.npmjs.org/
npm run package:check
npm test
npm pack --dry-run
GitHub Actions publishes on tags matching v* using Node.js 24 and npm Trusted Publishing (OIDC). The workflow grants contents: write for GitHub Releases and id-token: write for npm; it does not read an npm token. After the composite action passes npm run package:check and npm test, the workflow publishes npm only when that version is new, then creates or reuses a GitHub Release for the tag with generated notes using the built-in GITHUB_TOKEN. If the npm-publish GitHub Environment has required reviewers configured, GitHub pauses the job until they approve it. Otherwise, a matching tag publishes both npm and GitHub automatically.
Configure the release gate once:
- In GitHub, open Settings > Environments > New environment and create
npm-publish. - If GitHub exposes Required reviewers for this repository, enable it, add the maintainers who may approve releases, and save the protection rule. This is optional for npm Trusted Publishing.
- In npm package settings, add a GitHub Actions Trusted Publisher for owner
darkrei08, repositorypi-model-fit, workflow filenamepublish.yml, and environmentnpm-publishif npm asks for one. NoNPM_TOKENGitHub secret is required by this workflow; an existing secret can remain unused until it is removed manually. - Create and push a tag only after the checks and release are ready:
# Example only: package.json must already contain version 0.4.11.
git tag v0.4.11
git push origin v0.4.11
The workflow runs npm run package:check, npm test, checks npm for the package version, runs npm publish --access public only when that version is not already published, and finally calls gh release view/create for the same tag. It intentionally omits --provenance: npm cannot verify provenance bundles from a private GitHub source repository. Trusted Publishing still authenticates npm through GitHub Actions OIDC; GitHub Release creation uses only the built-in GITHUB_TOKEN. The GitHub Environment is an optional manual gate; pushing a tag alone starts the workflow.
The scripts need no external npm dependencies. Every script that prints a table takes --width N (default: the terminal width, floor 20):
node scripts/inventory.mjs # installed and logged-in providers, usable models, alias/role resolution
node scripts/plan.mjs # OpenAI and Anthropic plan
node scripts/catalog.mjs # pi.dev catalog; add --update to record a baseline
node scripts/drift.mjs ~/.pi/agent/models.json # local models.json vs pi.dev
node scripts/report.mjs # cross-check catalogs and save reports/YYYY-MM-DD.md; accepts --threshold-policy PATH
node scripts/threshold-policy.mjs # validate the canonical threshold policy
node scripts/opencode-go-fit.mjs --url "$CLIPROXYAPI_MODELS_URL" --token-env CLIPROXYAPI_TOKEN --json
node scripts/cliproxyapi-catalog.mjs --url "$CLIPROXYAPI_MODELS_URL" --token-env CLIPROXYAPI_TOKEN --json
node scripts/preflight.mjs --json --refresh # bounded, redacted Pi catalog + HA matrix
node scripts/quota.mjs --table # billing domain, plan and published allowance per route
node scripts/usage.mjs --table --days 30 # observed tokens per 5h/day/week/month vs the published window
node scripts/matrix.mjs --table --aliases # role and alias matrix: plan, quota, cost, speed, floor
node scripts/prices.mjs # local price vs indexed models.dev, LiteLLM and pi.dev
node --test scripts/sources.test.mjs # source-index schema and URL wiring
node scripts/doctor.mjs # research stack availability and verdict
node scripts/inventory.mjs --table # role view without a model in the loop
node scripts/benchmark.mjs --json # static route/context evidence; no inference
node scripts/health-probe.mjs --json # one bounded no-tool probe per canonical primary; exit 2 on UNKNOWN
node scripts/cache-audit.mjs --session <file> --json # session cache telemetry and prefix invalidations
node scripts/skillopt.mjs # read-only SkillOpt mock dry-run
node scripts/memory-arbitration.mjs # .ai/ decisions vs directives/conventions; exit 1 on contradiction
node scripts/skill-parity.mjs # compare repo tree (tracked + untracked, non-ignored) vs deployed skill; --refresh copies repo -> deployed
report.mjs resolves its default target from the skill root, not the current
directory: reports/YYYY-MM-DD.md beside SKILL.md. The default and any
--out target must resolve inside the git worktree of a local checkout or an
installed skill directory. Any other target is refused with exit status 1 and
nothing is written, so a refresh cannot scatter report state outside the
repository.
preflight.mjs always invokes the full pi --list-models catalog without a
pipe-separated filter. It writes a mode 0600 cache atomically, records only
provider/model capability metadata, and marks provider/model routes as
reachable, unavailable, or unknown. unknown reachability never selects a
failover route, and a cached snapshot whose probe status is not ok is never reused.
Catalog visibility is not entitlement, inference, or quota verification; the command
never sends an inference request or prints auth data.
Use --strict for a scheduler/CI gate and --cache, --ha-config, or
--timeout-ms to bind the local paths and limits explicitly.
benchmark.mjs compares current role routes with up to two prior dated local
reports, checks context/output safety, and marks latency, inference, and quota
as NOT RUN or UNKNOWN unless separately authorized. skillopt.mjs invokes only
SkillOpt's staged dry-run --backend mock path and never adopts proposals. See
references/pi-permissions-proposal.md for the verified Pi trust boundary.