Move the catalog tier from the x-nous-catalog-tier request header to a catalogTier property on each model. pi forwards only model.headers to the provider and copies them into the request options, so a header needed stripping on both the model and the options before every request; that adapter leaked for two audit rounds. A property never reaches the wire, survives pi's model store, and needs no wrapper, so TIER_HEADER, untier and withoutTierHeader are deleted and pi's stream passes through untouched. Models stored by the previous version come back without the property until the next interactive start rewrites the store; the CHANGELOG tells the user to start pi once interactively after upgrading.
7.7 KiB
AGENTS.md
Project
nous-portal: a pi provider extension (single index.ts, no build step). Registers the nous-portal provider with device-code OAuth and API-key auth against Nous inference, plus /model catalog filters.
Commands
npm run check:tsc --noEmitthennode --test tests/*.test.mjs.- Install dev deps with
npm install --legacy-peer-deps --no-package-lock. Plainnpm installignores the"*"peer ranges and pulls a full duplicate copy of@earendil-works/pi-aiintonode_modules, which pi's loader explicitly warns against. - Local install for pi:
ln -s "$PWD" ~/.pi/agent/extensions/nous-portal(sibling convention in~/Projects/scripting/pi-extensions).
Architecture
- Uses the native pi-ai
Provider(createProvider) rather than the legacyProviderConfig+oauthblock. The legacygetApiKeycontract pushes an extension toward minting an agent key; Nous retired that endpoint (410 session_key_minting_retired). HereOAuthAuth.toAuthreturns the access token itself, and pi owns the locked refresh pattern. Seedocs/adr/0001-stack.md. - Streaming is delegated to pi's built-in
openai-completionsAPI. No custom wire protocol. - The catalog tier rides on the model as the
catalogTierproperty, because pi persists and restores model objects across runs and a side table would miss restored entries. It is a property, not a header: pi forwards onlymodel.headersto requests (and copies them into the options first), so nothing is stripped before a request. Do not move it intoheaderswithout bringing back a strip on both the model and the options. The persisted catalog is<agentDir>/models-store.json(ModelsStore);models.jsonholds only user overrides, so check the store when verifying anything carried on a model.
Conventions and gotchas
- Host imports are allowlisted. pi's extension loader aliases only
@earendil-works/pi-coding-agentand@earendil-works/pi-aiplus its/models,/oauth,/compat,/providers/allsubpaths. ImportopenAICompletionsApifrom@earendil-works/pi-ai/compat; the./api/*subpath typechecks but fails at load. ctxvspi:setModel,registerCommand,registerProviderare onpi;ui.notify,model,modelRegistryare on the handler'sctx. Check withtscrather than guessing.pi -pand--list-modelsnever fetch live catalogs (allowModelNetworkis hard-codedfalse). That is why the provider shipsBASELINE; interactive startup overlays the live list.- Tests load
index.tsthrough jiti with the host packages aliased totests/stubs/pi-ai.mjs. Alias keys are longest-prefix first, sopi-ai/compatmust precedepi-aior the bare key swallows the subpath. - Never blanket-inject
tags.userinto request bodies. As of 2026-11-25 Nous free and discounted models return 500 when that field is present, and onlyupstage/solar-mini4:freerequires it.solar-mini4:freeis therefore left out ofBASELINEon purpose.
Catalog tiers
Live catalog signals, classified in tierOf:
- free:
synthesizedFreeVariant: true(also suffixed:free) - promo:
pricing.original.promptgreater than the currentpricing.prompt
billing_mode: "subscription" is a separate axis (batch models billed to the plan), not a promo marker.
DOX framework
- DOX is highly performant AGENTS.md hierarchy installed here
- Agent must follow DOX instructions across any edits
Core Contract
- AGENTS.md files are binding work contracts for their subtrees
- Work products, source materials, instructions, records, assets, and durable docs must stay understandable from the nearest applicable AGENTS.md plus every parent AGENTS.md above it
Read Before Editing
- Read the root AGENTS.md
- Identify every file or folder you expect to touch
- Walk from the repository root to each target path
- Read every AGENTS.md found along each route
- If a parent AGENTS.md lists a child AGENTS.md whose scope contains the path, read that child and continue from there
- Use the nearest AGENTS.md as the local contract and parent docs for repo-wide rules
- If docs conflict, the closer doc controls local work details, but no child doc may weaken DOX
Do not rely on memory. Re-read the applicable DOX chain in the current session before editing.
Update After Editing
Every meaningful change requires a DOX pass before the task is done.
Update the closest owning AGENTS.md when a change affects:
- purpose, scope, ownership, or responsibilities
- durable structure, contracts, workflows, or operating rules
- required inputs, outputs, permissions, constraints, side effects, or artifacts
- user preferences about behavior, communication, process, organization, or quality
- AGENTS.md creation, deletion, move, rename, or index contents
Update parent docs when parent-level structure, ownership, workflow, or child index changes. Update child docs when parent changes alter local rules. Remove stale or contradictory text immediately. Small edits that do not change behavior or contracts may leave docs unchanged, but the DOX pass still must happen.
Hierarchy
- Root AGENTS.md is the DOX rail: project-wide instructions, global preferences, durable workflow rules, and the top-level Child DOX Index
- Child AGENTS.md files own domain-specific instructions and their own Child DOX Index
- Each parent explains what its direct children cover and what stays owned by the parent
- The closer a doc is to the work, the more specific and practical it must be
Child Doc Shape
- Create a child AGENTS.md when a folder becomes a durable boundary with its own purpose, rules, responsibilities, workflow, materials, or quality standards
- Work Guidance must reflect the current standards of the project or user instructions; if there are no specific standards or instructions yet, leave it empty
- Verification must reflect an existing check; if no verification framework exists yet, leave it empty and update it when one exists
Default section order:
- Purpose
- Ownership
- Local Contracts
- Work Guidance
- Verification
- Child DOX Index
Style
- Keep docs concise, current, and operational
- Document stable contracts, not diary entries
- Put broad rules in parent docs and concrete details in child docs
- Prefer direct bullets with explicit names
- Do not duplicate rules across many files unless each scope needs a local version
- Delete stale notes instead of explaining history
- Trim obvious statements, repeated rules, misplaced detail, and warnings for risks that no longer exist
Closeout
- Re-check changed paths against the DOX chain
- Update nearest owning docs and any affected parents or children
- Refresh every affected Child DOX Index
- Remove stale or contradictory text
- Run existing verification when relevant
- Report any docs intentionally left unchanged and why
User Preferences
When the user requests a durable behavior change, record it here or in the relevant child AGENTS.md
Child DOX Index
| Path | Scope |
|---|---|
| docs/AGENTS.md | Durable documentation: ADRs (numbering, format, status) and session logs under docs/devlog/ (one log per unit of work; INDEX.md is the source of truth) |
| tests/AGENTS.md | Offline test suite: jiti aliasing to host-package stubs, fixtures, and what the tests pin |
Session Logs
Session logs live in docs/devlog/ (one per completed task/issue/milestone). Full history: docs/devlog/INDEX.md. The 10 most recent:
| Date | Log |
|---|---|
| 2026-11-25 | 20261125-fresh-context-audit-rounds-1-5_log.md |