- Strip the catalog-tier header from request options too. pi copies model.headers into options.headers before calling the provider (pi-ai getAuth -> prepareRequest) and the client applies options.headers last, so the header still reached Nous on every free/promo request; the old test pinned the leak. Both sides pinned. - Drop the 'Press Enter' prompt in OAuth login: it cleared pi's device-code confirm action (login-dialog showPrompt), so Enter opened nothing. pi's own dialog shows the code and opens the browser. - Poll interval rejects non-finite values (Node clamps an overflowing setTimeout to 1 ms) and each sleep is capped at the deadline, matching pi-ai's poller. - Tests: 17 (was 14). /nous-free back to full, /nous-catalog cycling, and startup restore of a saved catalog are covered. - Docs: README says the live list overlays the baseline by id (baseline ids that vanish stay listed); AGENTS.md states both strips.
6.9 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. Model.headers["x-nous-catalog-tier"]carries the catalog tier on the model, because pi persists and restores model objects across runs and a side table would miss restored entries.withoutTierHeaderstrips it from both the model and the request options before every request (pi copiesmodel.headersintooptions.headersbefore calling the provider).
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 and their numbering, format, and status rules |
| tests/AGENTS.md | Offline test suite: jiti aliasing to host-package stubs, fixtures, and what the tests pin |