Files
AlexKucera ef136dbc30 docs: record the Nous Portal maintainer's OK to release
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.
2026-11-25 18:37:15 +01:00

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 --noEmit then node --test tests/*.test.mjs.
  • Install dev deps with npm install --legacy-peer-deps --no-package-lock. Plain npm install ignores the "*" peer ranges and pulls a full duplicate copy of @earendil-works/pi-ai into node_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; dev or npm picks 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 on main, 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 legacy ProviderConfig + oauth block. The legacy getApiKey contract pushes an extension toward minting an agent key; Nous retired that endpoint (410 session_key_minting_retired). Here OAuthAuth.toAuth returns the access token itself, and pi owns the locked refresh pattern. See docs/adr/0001-stack.md.
  • Streaming is delegated to pi's built-in openai-completions API. No custom wire protocol.
  • The catalog tier rides on the model as the catalogTier property, 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 only model.headers to requests (and copies them into the options first), so nothing is stripped before a request. Do not move it into headers without bringing back a strip on both the model and the options. The persisted catalog is <agentDir>/models-store.json (ModelsStore); models.json holds only user overrides, so check the store when verifying anything carried on a model.
  • login accepts an optional clock ({ now, sleep }): production uses node:timers/promises and Date.now, tests an auto-advancing fake. auth.oauth.login passes only the interaction, so pi's interface is unchanged.
  • The pi manifest is what makes the package load. pi's package loader reads pi.extensions from package.json, or scans an extensions/ directory when there is no manifest. A root index.ts is 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"] }, the pi-package keyword (the pi.dev/packages gallery lists only npm packages that carry it), and the files whitelist in package.json.

Conventions and gotchas

  • Host imports are allowlisted. pi's extension loader aliases only @earendil-works/pi-coding-agent and @earendil-works/pi-ai plus its /models, /oauth, /compat, /providers/all subpaths. Import openAICompletionsApi from @earendil-works/pi-ai/compat; the ./api/* subpath typechecks but fails at load.
  • ctx vs pi: setModel, registerCommand, registerProvider are on pi; ui.notify, model, modelRegistry are on the handler's ctx. Check with tsc rather than guessing.
  • pi -p and --list-models never fetch live catalogs (allowModelNetwork is hard-coded false). That is why the provider ships BASELINE; interactive startup overlays the live list.
  • Tests load index.ts through jiti with the host packages aliased to tests/stubs/pi-ai.mjs. Alias keys are longest-prefix first, so pi-ai/compat must precede pi-ai or the bare key swallows the subpath.
  • Never blanket-inject tags.user into request bodies. As of 2026-11-25 Nous free and discounted models return 500 when that field is present, and only upstage/solar-mini4:free requires it. solar-mini4:free is therefore left out of BASELINE on purpose.
  • Releases are local, through scripts/publish.sh. No CI and no npm token: npm publish prompts for the 2FA code. The script renames the changelog's ## [Unreleased] heading to the released version and opens a fresh Unreleased section above it, so new entries always go under ## [Unreleased]. It refuses a release whose Unreleased section 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.md and package.json saying 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.prompt greater than the current pricing.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

  1. Read the root AGENTS.md
  2. Identify every file or folder you expect to touch
  3. Walk from the repository root to each target path
  4. Read every AGENTS.md found along each route
  5. If a parent AGENTS.md lists a child AGENTS.md whose scope contains the path, read that child and continue from there
  6. Use the nearest AGENTS.md as the local contract and parent docs for repo-wide rules
  7. 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

  1. Re-check changed paths against the DOX chain
  2. Update nearest owning docs and any affected parents or children
  3. Refresh every affected Child DOX Index
  4. Remove stale or contradictory text
  5. Run existing verification when relevant
  6. 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.sh guard ahead of the version bump: a refusal after npm version leaves package.json modified (release-scripts-npm-wait-toggle-and-move)
  • Rehearse scripts/publish.sh in a scratch repo with a stubbed npm first on PATH and 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:

Date Log
2026-11-25 20261125-release-scripts-npm-wait-toggle-and-move_log.md
2026-11-25 20261125-issue03-publish-pi-nous-portal-to-npm_log.md
2026-11-25 20261125-finish-audit-architecture-review-unit_log.md
2026-11-25 20261125-architecture-review-tier-property-and-login-clock_log.md
2026-11-25 20261125-fresh-context-audit-rounds-1-5_log.md