Teknium gave a verbal OK on 2026-11-25 (Nous Research Discord) to release the extension publicly. It is permission, not an endorsement, so the unofficial / not-affiliated label stays. Also drop a stale duplicate ADR 0003 bullet from docs/AGENTS.md.
11 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). ./scripts/test_npm_package.sh: switches pi between the symlink checkout and the published npm package;devornpmpicks a side. Keep only one installed: pi identifies npm packages by name and local ones by path, so both at once register the provider twice../scripts/publish.sh: cuts a release (clean tree onmain,npm run check,npm pack --dry-run, changelog heading, commit, tag,npm publish, push). The changelog's## [Unreleased]heading is required.
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. loginaccepts an optional clock ({ now, sleep }): production usesnode:timers/promisesandDate.now, tests an auto-advancing fake.auth.oauth.loginpasses only the interaction, so pi's interface is unchanged.- The
pimanifest is what makes the package load. pi's package loader readspi.extensionsfrompackage.json, or scans anextensions/directory when there is no manifest. A rootindex.tsis only found by the legacy~/.pi/agent/extensions/loader, which is why the symlink install works and a package install would not. Keep"pi": { "extensions": ["./index.ts"] }, thepi-packagekeyword (the pi.dev/packages gallery lists only npm packages that carry it), and thefileswhitelist inpackage.json.
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. - Releases are local, through
scripts/publish.sh. No CI and no npm token:npm publishprompts for the 2FA code. The script renames the changelog's## [Unreleased]heading to the released version and opens a freshUnreleasedsection above it, so new entries always go under## [Unreleased]. It refuses a release whoseUnreleasedsection is empty. npm answers with a placeholder version (0.0.0-stage) for about four minutes after the publish; a fresh install in that window loads no models, and the script waits until the real version resolves. The pi.dev/packages gallery lags further behind. - Release is sanctioned by the Nous Portal maintainer; it is not an endorsement. Teknium (maintainer of Hermes Agent and Nous Portal) gave a verbal OK on 2026-11-25 to release this extension publicly (Nous Research Discord thread: "You can do it it's fine"). Keep
README.mdandpackage.jsonsaying unofficial, community-maintained, not affiliated with Nous Research.
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 |
Project Learnings
Release tooling
- Keep every
scripts/publish.shguard ahead of the version bump: a refusal afternpm versionleavespackage.jsonmodified (release-scripts-npm-wait-toggle-and-move) - Rehearse
scripts/publish.shin a scratch repo with a stubbednpmfirst onPATHand a local bare remote: it exercises checks, commit, tag, push and the publish call without touching npm or Gitea (release-scripts-npm-wait-toggle-and-move)
Session Logs
Session logs live in docs/devlog/ (one per completed task/issue/milestone). Full history: docs/devlog/INDEX.md. The 10 most recent: