Compare commits

...
6 Commits
Author SHA1 Message Date
AlexKucera 6e689cefe0 docs: soften the browser-headers note in Known limits
Keep the disclosure (portal-only browser-like UA/Origin/Referer) and the breakage risk; drop the speculative terms-of-use and account-flagging sentence, and stop saying the checkpoint rejects CLI clients, since hermes-cli gets through without spoofing.
2026-11-25 18:43:45 +01:00
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
AlexKucera b71363efb9 build: move release scripts and harden publish
publish.sh and test_npm_package.sh now live in scripts/ and cd to the
repo root, so they run from any directory. publish.sh polls npm until
the released version resolves: the first release ended inside the
registry's processing window, when a fresh install still gets the
0.0.0-stage placeholder. It also reopens an empty Unreleased section
after the rename and refuses an empty one before the version bump, so
a refused release leaves the tree clean.

test_npm_package.sh switches pi between the symlink checkout and
npm:pi-nous-portal. Only one may be installed: pi identifies npm
packages by name and local ones by path, so both register the provider
twice.
2026-11-25 16:51:36 +01:00
AlexKucera 21ec8029c5 build: wait for npm to serve a released version
npm answers with a placeholder version (0.0.0-stage) for about
four minutes after `npm publish`. The first release ended the script
in that window: a fresh install got the placeholder and loaded no
extension, and the pi.dev/packages gallery returned 404. Poll the
registry until the released version resolves, for at most ten
minutes, so the script's exit means `pi install` works.

Observed with pi-nous-portal 0.1.0, which became installable at
15:19:25 UTC and listed 8 models from a fresh agent dir.
2026-11-25 16:27:42 +01:00
AlexKucera e534b27f94 release v0.1.0 2026-11-25 16:15:56 +01:00
AlexKucera 1af3a1360e feat: make the package installable from npm
pi loads a package's extensions through the `pi` manifest or an
`extensions/` directory, so a root index.ts loaded nothing as a
package. Add "pi": { "extensions": ["./index.ts"] }, a files
whitelist that keeps tests and docs out of the tarball, and the
repository links the pi.dev/packages gallery shows.

Add publish.sh for releases: checks, tarball preview, changelog
heading, commit, tag, npm publish, push. No CI (ADR 0003).

Lead the README with pi install npm:pi-nous-portal, document the
release script, and label the package unofficial and
community-maintained. The README also gets a plainer voice.

The publish itself is still pending. Refs #3
2026-11-25 16:15:15 +01:00
11 changed files with 310 additions and 20 deletions

No files matched your search

+16
View File
@@ -9,6 +9,8 @@
- `npm run check`: `tsc --noEmit` then `node --test tests/*.test.mjs`. - `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. - 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`). - 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 ## Architecture
@@ -16,6 +18,7 @@
- Streaming is delegated to pi's built-in `openai-completions` API. No custom wire protocol. - 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. - 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. - `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 ## Conventions and gotchas
@@ -24,6 +27,8 @@
- **`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. - **`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. - **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. - **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](https://discord.com/channels/1053877538025386074/1575186664651755570): "You can do it it's fine"). Keep `README.md` and `package.json` saying unofficial, community-maintained, not affiliated with Nous Research.
## Catalog tiers ## Catalog tiers
@@ -121,6 +126,15 @@ When the user requests a durable behavior change, record it here or in the relev
| [docs/AGENTS.md](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) | | [docs/AGENTS.md](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](tests/AGENTS.md) | Offline test suite: jiti aliasing to host-package stubs, fixtures, and what the tests pin | | [tests/AGENTS.md](tests/AGENTS.md) | Offline test suite: jiti aliasing to host-package stubs, fixtures, and what the tests pin |
## Project Learnings
<!-- distill-learnings: 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
Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Full history: [`docs/devlog/INDEX.md`](docs/devlog/INDEX.md). The 10 most recent: Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Full history: [`docs/devlog/INDEX.md`](docs/devlog/INDEX.md). The 10 most recent:
@@ -128,6 +142,8 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu
<!-- write-log: window-start --> <!-- write-log: window-start -->
| Date | Log | | Date | Log |
|------|-----| |------|-----|
| 2026-11-25 | [20261125-release-scripts-npm-wait-toggle-and-move_log.md](docs/devlog/20261125-release-scripts-npm-wait-toggle-and-move_log.md) |
| 2026-11-25 | [20261125-issue03-publish-pi-nous-portal-to-npm_log.md](docs/devlog/20261125-issue03-publish-pi-nous-portal-to-npm_log.md) |
| 2026-11-25 | [20261125-finish-audit-architecture-review-unit_log.md](docs/devlog/20261125-finish-audit-architecture-review-unit_log.md) | | 2026-11-25 | [20261125-finish-audit-architecture-review-unit_log.md](docs/devlog/20261125-finish-audit-architecture-review-unit_log.md) |
| 2026-11-25 | [20261125-architecture-review-tier-property-and-login-clock_log.md](docs/devlog/20261125-architecture-review-tier-property-and-login-clock_log.md) | | 2026-11-25 | [20261125-architecture-review-tier-property-and-login-clock_log.md](docs/devlog/20261125-architecture-review-tier-property-and-login-clock_log.md) |
| 2026-11-25 | [20261125-fresh-context-audit-rounds-1-5_log.md](docs/devlog/20261125-fresh-context-audit-rounds-1-5_log.md) | | 2026-11-25 | [20261125-fresh-context-audit-rounds-1-5_log.md](docs/devlog/20261125-fresh-context-audit-rounds-1-5_log.md) |
+3
View File
@@ -4,9 +4,12 @@ All notable changes to this project will be documented in this file. The format
## [Unreleased] ## [Unreleased]
## [0.1.0] - 2026-11-25
### Added ### Added
- Native `nous-portal` provider: device-code OAuth (subscription) and API-key login, with the OAuth access token used directly as the inference bearer credential. - Native `nous-portal` provider: device-code OAuth (subscription) and API-key login, with the OAuth access token used directly as the inference bearer credential.
- npm package. `pi install npm:pi-nous-portal` installs it, the `pi` manifest points pi at `index.ts`, and `publish.sh` cuts a release.
- Live model discovery from `inference-api.nousresearch.com/v1/models`, delegated to pi's built-in `openai-completions` streaming. - Live model discovery from `inference-api.nousresearch.com/v1/models`, delegated to pi's built-in `openai-completions` streaming.
- Offline baseline catalog so `pi -p` and `pi --list-models` stay usable without a network fetch. - Offline baseline catalog so `pi -p` and `pi --list-models` stay usable without a network fetch.
- `/nous-catalog` cycles `/model` between full, free and promo catalogs; `/nous-free` jumps to free. Switching never touches a session on another provider, and swaps the current model only if it was filtered out. - `/nous-catalog` cycles `/model` between full, free and promo catalogs; `/nous-free` jumps to free. Switching never touches a session on another provider, and swaps the current model only if it was filtered out.
+33 -15
View File
@@ -1,27 +1,34 @@
# pi-nous-portal # pi-nous-portal
Nous Portal provider for [pi](https://github.com/earendil-works/pi): subscription OAuth and API key, without agent-key minting. An unofficial, community-maintained provider that lets [pi](https://github.com/earendil-works/pi) sign in to Nous Portal and use its models. Not affiliated with Nous Research.
## Why this exists ## Why this exists
Nous retired Hermes-style agent-key minting (`POST /api/oauth/agent-key` returns `410 session_key_minting_retired`). Both existing community extensions end their login at that endpoint, so neither can sign in with a Portal subscription. The inference API now accepts the **OAuth access token directly** as a bearer credential, so this extension never mints or stores an agent key. Nous retired Hermes-style agent-key minting. `POST /api/oauth/agent-key` returns `410 session_key_minting_retired`, and both existing community extensions end their login at that endpoint, so neither can sign in with a Portal subscription. The inference API does accept the OAuth access token itself as a bearer credential, so this extension never mints or stores an agent key.
## Requirements ## Requirements
- pi 1.6.0 or newer (`@earendil-works/pi-ai` native provider interface) - pi 1.6.0 or newer, for the `@earendil-works/pi-ai` native provider interface
- Node.js 22+ - Node.js 22 or newer
- A Nous Portal subscription, or an inference API key from the Portal - a Nous Portal subscription, or an inference API key from the Portal
## Getting started ## Install
```bash
pi install npm:pi-nous-portal
```
To run from a checkout instead, symlink it into pi's extensions directory:
```bash ```bash
# from a checkout
ln -s "$PWD" ~/.pi/agent/extensions/nous-portal ln -s "$PWD" ~/.pi/agent/extensions/nous-portal
``` ```
Then in pi: ## Use
- `/login nous-portal` offers two methods: **Sign in to Nous Portal (subscription)** for the device-code OAuth flow, or **Nous Portal API key** to store an `sk-nous-…` key. In pi:
- `/login nous-portal` offers two methods: "Sign in to Nous Portal (subscription)" for the device-code OAuth flow, or "Nous Portal API key" to store an `sk-nous-…` key.
- The API-key route also reads `$NOUS_API_KEY`. - The API-key route also reads `$NOUS_API_KEY`.
- `/model` lists the live catalog in interactive sessions. - `/model` lists the live catalog in interactive sessions.
@@ -42,22 +49,33 @@ The choice is saved in `~/.pi/agent/nous-portal-catalog` and survives restarts.
### Offline baseline ### Offline baseline
`pi -p` and `pi --list-models` never fetch live catalogs (pi hard-codes `allowModelNetwork: false` there), so the provider ships a small static baseline so it is always usable. Interactive pi overlays the live list on the baseline by model id; a baseline id that disappears from the live catalog stays listed, with its frozen baseline price and context, until the next release. `pi -p` and `pi --list-models` never fetch live catalogs, because pi hard-codes `allowModelNetwork: false` there. The provider ships a small static baseline so those modes still list something. Interactive pi overlays the live list on the baseline by model id. A baseline id that disappears from the live catalog stays listed, with its frozen baseline price and context, until the next release.
## Known limits ## Known limits
- `upstage/solar-mini4:free` is left out of the baseline on purpose: it alone requires a `tags` body field that the other free models reject with a 500, so no single request shape serves all of them. - `upstage/solar-mini4:free` is left out of the baseline. It alone requires a `tags` body field that the other free models reject with a 500, so no single request shape serves all of them.
- Subscription quota is per day. When the "Today" gauge is exhausted, inference returns `503 ChatGPT subscription inference is temporarily unavailable`. Purchased credits keep the API-key route working. - Subscription quota is per day. When the "Today" gauge is empty, inference returns `503 ChatGPT subscription inference is temporarily unavailable`. Purchased credits keep the API-key route working.
- Requests to the portal's OAuth endpoints send a browser-like `User-Agent`, `Origin` and `Referer` (only to `portal.nousresearch.com`, never to inference). This gets past the Vercel browser checkpoint that otherwise rejects CLI clients. It is a robustness and terms-of-use risk, not a security one: if Nous tightens the checkpoint or treats the client as evasion, login can break or the account can be flagged. - Requests to the portal's OAuth endpoints send a browser-like `User-Agent`, `Origin` and `Referer`, and only to `portal.nousresearch.com`, never to inference. This gets past the Vercel checkpoint in front of the portal, which otherwise answers with a challenge page. It is a compatibility measure, not a security concern. If Nous tightens the checkpoint, login breaks until the headers are updated.
## Development ## Development
```bash ```bash
npm install --legacy-peer-deps --no-package-lock # typescript + jiti only; pi injects @earendil-works/* at load time npm install --legacy-peer-deps --no-package-lock # typescript + jiti only; pi injects @earendil-works/* at load time
npm run check # tsc --noEmit + node --test npm run check # tsc --noEmit + node --test
``` ```
Typechecking needs a local pi install: `tsconfig.json` `paths` point `@earendil-works/pi-ai` and `pi-coding-agent` at the type declarations under `~/.pi/agent/install/releases/<version>/`. Update those three paths when pi is upgraded. The extension itself runs against any pi with the native provider interface; only `tsc` is pinned. Typechecking needs a local pi install. The `paths` in `tsconfig.json` point `@earendil-works/pi-ai` and `pi-coding-agent` at the type declarations under `~/.pi/agent/install/releases/<version>/`, so update those three paths when pi is upgraded. The extension itself runs on any pi with the native provider interface. Only `tsc` is pinned.
`./scripts/test_npm_package.sh` switches pi between this checkout and the published package, so you can try a release without hunting for the symlink. Run it with `dev` or `npm` to pick a side.
## Releasing
```bash
./scripts/publish.sh # release the version in package.json
./scripts/publish.sh patch # bump first; minor and major work too
```
The script runs the checks, shows the tarball contents, moves the `Unreleased` section of the changelog under the new version, commits, tags, publishes to npm, and pushes. npm asks for your 2FA code during the publish. npm then takes a few minutes to serve the new version, and the script waits until it resolves. You need `npm login` with publish rights to the package first.
## License ## License
+1 -2
View File
@@ -18,8 +18,7 @@ Durable documentation that explains *why* the project is shaped the way it is: a
- Existing records: - Existing records:
- `0001-stack.md`: native pi-ai `Provider` over legacy `ProviderConfig`, because the legacy form leads to agent-key minting that Nous retired. - `0001-stack.md`: native pi-ai `Provider` over legacy `ProviderConfig`, because the legacy form leads to agent-key minting that Nous retired.
- `0002-license.md`: GPL-3.0-or-later. - `0002-license.md`: GPL-3.0-or-later.
- `0003-forge-and-ci.md`: Gitea remote, no CI file yet. - `0003-forge-and-ci.md`: Gitea remote, no CI file. Releases go through the local `publish.sh`.
- An ADR records a decision that is hard to reverse, surprising without context, and the result of a real trade-off. Easy-to-reverse choices do not get an ADR.
## Work Guidance ## Work Guidance
+1 -1
View File
@@ -1,3 +1,3 @@
# Gitea remote, no CI yet # Gitea remote, no CI yet
The repository already had an `origin` on `git.babylondreams.de` (Gitea) when it was initialised, so that is the forge. No CI file: a single-file extension has nothing to build, and the test suite is `node --test` over offline assertions. Add a Gitea Actions workflow when the suite grows or a published npm package needs a release gate. The repository already had an `origin` on `git.babylondreams.de` (Gitea) when it was initialised, so that is the forge. No CI file: a single-file extension has nothing to build, and the test suite is `node --test` over offline assertions. Add a Gitea Actions workflow when the suite grows or a published npm package needs a release gate. Until then, releases are cut locally with `publish.sh`, which runs `npm run check` and `npm pack --dry-run` before `npm publish`.
@@ -0,0 +1,72 @@
# Issue #3: Publish pi-nous-portal 0.1.0 to npm
> **Date:** 2026-11-25
> **Type:** issue
> **Reference:** https://git.babylondreams.de/AlexKucera/nous-portal/issues/3
## Goal
Make the extension installable with `pi install npm:pi-nous-portal` and listed on https://pi.dev/packages, with a repeatable local release. Grew out of the research in #2.
## What Was Done
- Researched the gallery. It lists only npm packages that carry the `pi-package` keyword, and a git source installs but never lists. Posted that as the resolution of #2 and closed it.
- Settled the publishing decisions with Alexander: npm, unscoped `pi-nous-portal`, Gitea as `repository`, labelled unofficial, semver with a `v0.1.0` tag, a local `publish.sh` instead of CI. Recorded on #3.
- `package.json`: added `"pi": { "extensions": ["./index.ts"] }`, `repository`, `homepage`, `bugs`, `"files": ["index.ts", "CHANGELOG.md"]`, and "Unofficial, community-maintained" in `description`.
- `publish.sh`: guards (clean tree, `main`, `npm whoami`), `npm run check`, `npm pack --dry-run`, changelog heading rename, commit, tag, `npm publish`, `git push --follow-tags`.
- `README.md`: the install section now leads with `pi install npm:pi-nous-portal`, a new Releasing section, and an edit pass for a plainer voice at Alexander's request.
- `CHANGELOG.md`: entry under Unreleased.
- `AGENTS.md`, `docs/AGENTS.md`, `docs/adr/0003-forge-and-ci.md`: release steps and the manifest rule recorded.
Verified before stopping: `npm run check` (25 tests pass), `shellcheck`, `npm pack --dry-run` (5 files: `CHANGELOG.md`, `LICENSE`, `README.md`, `index.ts`, `package.json`), the dirty-tree guard stops the script with exit 1, the changelog rename turns `## [Unreleased]` into `## [0.1.0] - 2026-11-25` on a copy, and `npm version patch --no-git-tag-version` bumps a copy to 0.1.1.
## Decisions & Rationale
| Decision | Rationale |
|----------|-----------|
| Publish to npm, not a git source | The gallery indexes npm only. The issue asked "npm or git", and only npm reaches the destination. |
| Keep the unscoped name `pi-nous-portal` | Already in `package.json`, unused on npm, and it matches most gallery entries. A scope would have needed an npm org. |
| `publish.sh` over CI | Alexander asked for a script, not a pipeline. The instance has Actions enabled but no runner, and npm's trusted publishers exclude Gitea Actions, so CI would also have needed a bypass-2FA token. |
| A `pi.extensions` manifest instead of moving `index.ts` | Moving the file would touch `tsconfig.json`, the tests that load `index.ts`, and the symlink install. One manifest entry leaves all three alone. |
| Label the package unofficial | It carries Nous in its name and ships the public `hermes-cli` client id. The label keeps it from reading as a Nous product. |
| No new ADR | The release setup is reversible, and the no-CI decision is already `0003-forge-and-ci.md`, which gained one sentence. |
## Gotchas & Fixes
| Problem | Root Cause | Fix |
|---------|------------|-----|
| A package install of the old tree would load no extension | pi 1.6.0's `collectDefaultResources` (`core/package-manager.js`) reads `manifest[resourceType]` or scans `<packageRoot>/extensions/`. A root `index.ts` is only found by the legacy `~/.pi/agent/extensions/` loader, which is why the symlink install works. | Add `"pi": { "extensions": ["./index.ts"] }`. |
| The gallery would have shown no repo link | `package.json` had no `repository` field. | Added `repository`, `homepage` and `bugs`. |
| `tests/`, `docs/` and `tsconfig.json` would have shipped | No `files` whitelist, so npm fell back to `.gitignore`. | `"files": ["index.ts", "CHANGELOG.md"]`. |
| I read "automated publishing" as CI and wrote a runner-and-token plan | An assumption that was never asked for. | Alexander corrected it. #3 now describes `publish.sh`. |
| `package.json` ended up with two `description` keys | The edit tool auto-relocated the line anchor to the wrong line and inserted instead of replacing. | Replaced both lines with one. `JSON.parse` takes the last key, so `npm pack` had hidden it. |
## Files Changed
| File | Change Summary |
|------|---------------|
| `publish.sh` | New release script |
| `package.json` | `pi` manifest, `files`, repo links, description |
| `README.md` | Install and Releasing sections, edit pass |
| `CHANGELOG.md` | Unreleased entry for the npm package |
| `AGENTS.md` | Release command, manifest rule, release convention, log window |
| `docs/AGENTS.md` | ADR 0003 one-liner mentions `publish.sh` |
| `docs/adr/0003-forge-and-ci.md` | One sentence on the local release gate |
| `docs/devlog/INDEX.md` | Row for this log |
## Open Items & Next Steps
- [ ] Run `./publish.sh`. It prompts for the npm 2FA code. Not run in this session.
- [ ] After the publish, check `pi -e npm:pi-nous-portal` in a throwaway agent dir, then `/login nous-portal`.
- [ ] Confirm the package shows up on https://pi.dev/packages.
- [ ] Close #3 once the listing is live.
## Update, 2026-11-25 15:26 UTC
Published. `./publish.sh` ran with the 2FA prompt, pushed `release v0.1.0` (e534b27) and tag `v0.1.0`. npm answered with a placeholder version `0.0.0-stage` for about four minutes ("Your package is being processed and may take a few minutes to become available"). A fresh-agent-dir install in that window listed no Nous models. At 15:19:25 UTC `latest` became `0.1.0`, and `pi -e npm:pi-nous-portal@0.1.0 --list-models` in a fresh agent dir listed 8 `nous-portal` models with an empty stderr. `publish.sh` now waits until the registry serves the version. The pi.dev/packages gallery still returned 404 at 15:26 UTC, so issue #3 stays open until the listing is live.
Follow-up: the release tooling that came after this log (the npm wait, the dev/npm toggle script, the move to `scripts/`) is recorded in [20261125-release-scripts-npm-wait-toggle-and-move_log.md](20261125-release-scripts-npm-wait-toggle-and-move_log.md).
---
*Log written by write-log skill*
@@ -0,0 +1,60 @@
# Release scripts: npm wait, dev/npm toggle, scripts/ folder
> **Date:** 2026-11-25
> **Type:** generic
> **Reference:** follow-up to https://git.babylondreams.de/AlexKucera/nous-portal/issues/3
## Goal
Make the release script trustworthy after the first real publish, add a way to switch pi between this checkout and the published npm package, and keep both scripts runnable from any directory once they moved into `scripts/`.
## What Was Done
- `scripts/publish.sh` (moved from the repo root) waits until `npm view <name>@<version>` resolves, for at most ten minutes. Before the publish it opens a fresh `Unreleased` section and refuses an empty one. The guard runs before the version bump.
- `scripts/test_npm_package.sh` is new. With no argument it toggles between the symlink checkout and `npm:pi-nous-portal`; `dev` or `npm` forces a side. It removes whichever install is not wanted, honors `PI_CODING_AGENT_DIR`, and prints how many `nous-portal` models the next pi start lists.
- Both scripts `cd` to the repo root. `README.md` and `AGENTS.md` name the new paths.
- `CHANGELOG.md` has an empty `Unreleased` section again, the state the script now leaves after each release.
- Verified: the toggle matrix in a temporary agent dir, from three working directories. The whole release flow ran in a scratch repo with a stubbed `npm publish` and `npm view` and a local bare remote: a `patch` bump to 0.1.1, 25 tests, 5 files in the tarball, commit, tag and push. npm and Gitea were untouched.
## Decisions & Rationale
| Decision | Rationale |
|----------|-----------|
| Poll npm at the end of `publish.sh` | The first release ended inside the registry's processing window. The script's exit now means `pi install` works. Ten minutes caps a stuck registry. |
| Reopen `Unreleased` in the script | Common Changelog keeps an `Unreleased` section. The first release consumed it, and the next release would have been refused until someone re-added it by hand. |
| Refuse an empty `Unreleased`, before the bump | A release needs an entry, and a refused release must leave the tree clean. After the bump it would leave `package.json` modified. |
| The toggle keeps exactly one install | pi identifies npm packages by name and local ones by path, so both at once load and register the provider twice. |
| Honor `PI_CODING_AGENT_DIR` in the toggle | It lets the script be tested against a temporary agent dir without touching the real one. |
| Plain `rm` on the symlink | `-r` or a trailing slash would delete the checkout. |
| No `scripts/AGENTS.md` | Two scripts with no separate rules. The root `AGENTS.md` documents both. |
| `git mv` for `publish.sh`, plain `mv` for the new script | The tracked file keeps its rename history. The other was never committed. |
## Gotchas & Fixes
| Problem | Root Cause | Fix |
|---------|------------|-----|
| The toggle created no symlink in a fresh agent dir and printed nothing after `pi remove` | `extensions/` does not exist there, `ln -s` failed, and `set -e` stopped the script. | `mkdir -p` on the link's directory. |
| A scratch run of `publish.sh` was refused with "no Unreleased heading" | The first release had consumed the section. | The script reopens it, and the guard now asks for an entry. |
| A refusal after the bump would leave `package.json` modified | The guard ran after `npm version`. | Guard moved above the bump. The rerun test shows the version unchanged, a clean tree and no publish. |
| Both scripts would have broken after the move | `cd "$(dirname "$0")"` resolves to `scripts/`. | `cd "$(dirname "$0")/.."`, tested from three directories. |
## Files Changed
| File | Change Summary |
|------|---------------|
| `scripts/publish.sh` | Moved. npm wait, `Unreleased` reopen and guard. |
| `scripts/test_npm_package.sh` | New dev/npm toggle |
| `CHANGELOG.md` | Empty `Unreleased` section reopened |
| `README.md`, `AGENTS.md` | New script paths |
| `docs/devlog/INDEX.md`, `AGENTS.md` log window | Row for this log |
| `docs/devlog/20261125-issue03-publish-pi-nous-portal-to-npm_log.md` | Follow-up paragraph replaced by a pointer to this log |
## Open Items & Next Steps
- [ ] The pi.dev/packages listing was still missing at the last check. Confirm it and close #3.
- [ ] The npm wait and the changelog reopen have only run against stubs. The first real release that uses them confirms them.
- [ ] The login flow through the installed npm package is untested.
---
*Log written by write-log skill*
+2
View File
@@ -5,6 +5,8 @@ Complete history of session logs in this directory, newest first. One-line summa
<!-- write-log: full-index --> <!-- write-log: full-index -->
| Date | Type | File | Summary | | Date | Type | File | Summary |
|------|------|------|---------| |------|------|------|---------|
| 2026-11-25 | generic | [20261125-release-scripts-npm-wait-toggle-and-move_log.md](20261125-release-scripts-npm-wait-toggle-and-move_log.md) | publish.sh waits for npm and reopens Unreleased, dev/npm toggle script added, both moved to scripts/ |
| 2026-11-25 | issue | [20261125-issue03-publish-pi-nous-portal-to-npm_log.md](20261125-issue03-publish-pi-nous-portal-to-npm_log.md) | npm package made publishable (manifest, `files`, repo links, `publish.sh`) and README edited, publish still pending |
| 2026-11-25 | generic | [20261125-finish-audit-architecture-review-unit_log.md](20261125-finish-audit-architecture-review-unit_log.md) | Two-round finish audit of the carrier move and clock seam: two code nits and a test-hang guard fixed, then a docs-only round | | 2026-11-25 | generic | [20261125-finish-audit-architecture-review-unit_log.md](20261125-finish-audit-architecture-review-unit_log.md) | Two-round finish audit of the carrier move and clock seam: two code nits and a test-hang guard fixed, then a docs-only round |
| 2026-11-25 | generic | [20261125-architecture-review-tier-property-and-login-clock_log.md](20261125-architecture-review-tier-property-and-login-clock_log.md) | Architecture review: tier moves from a request header to a model property, `login` gains a clock seam, poll loop now tested | | 2026-11-25 | generic | [20261125-architecture-review-tier-property-and-login-clock_log.md](20261125-architecture-review-tier-property-and-login-clock_log.md) | Architecture review: tier moves from a request header to a model property, `login` gains a clock seam, poll loop now tested |
| 2026-11-25 | generic | [20261125-fresh-context-audit-rounds-1-5_log.md](20261125-fresh-context-audit-rounds-1-5_log.md) | Five-round fresh-context audit of the Nous Portal provider: two P1s surfaced in round 3, clean in round 5 | | 2026-11-25 | generic | [20261125-fresh-context-audit-rounds-1-5_log.md](20261125-fresh-context-audit-rounds-1-5_log.md) | Five-round fresh-context audit of the Nous Portal provider: two P1s surfaced in round 3, clean in round 5 |
+16 -2
View File
@@ -1,9 +1,23 @@
{ {
"name": "pi-nous-portal", "name": "pi-nous-portal",
"version": "0.1.0", "version": "0.1.0",
"description": "Nous Portal provider for pi: subscription OAuth and API key, no agent-key minting.", "description": "Unofficial, community-maintained Nous Portal provider for pi: subscription OAuth and API key, no agent-key minting.",
"license": "GPL-3.0-or-later",
"type": "module", "type": "module",
"homepage": "https://git.babylondreams.de/AlexKucera/nous-portal",
"bugs": "https://git.babylondreams.de/AlexKucera/nous-portal/issues",
"repository": {
"type": "git",
"url": "https://git.babylondreams.de/AlexKucera/nous-portal.git"
},
"files": [
"index.ts",
"CHANGELOG.md"
],
"pi": {
"extensions": [
"./index.ts"
]
},
"engines": { "engines": {
"node": ">=22" "node": ">=22"
}, },
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# Release pi-nous-portal to npm and push the tag.
#
# ./publish.sh release the version in package.json
# ./publish.sh patch bump first (minor, major, or an explicit version work too)
#
# npm asks for your 2FA code at the publish step. If the publish fails after
# the tag exists, fix the cause and rerun: npm publish && git push origin main --follow-tags
set -euo pipefail
bump="${1:-}"
cd "$(dirname "$0")/.."
[ -z "$(git status --porcelain)" ] || { echo "working tree is not clean" >&2; exit 1; }
[ "$(git branch --show-current)" = "main" ] || { echo "not on main" >&2; exit 1; }
npm whoami >/dev/null
# A release needs at least one entry under Unreleased.
awk '/^## \[Unreleased\]$/ { section = 1; next } /^## / { section = 0 } section && NF { entry = 1 } END { exit entry ? 0 : 1 }' CHANGELOG.md \
|| { echo "CHANGELOG.md needs an entry under '## [Unreleased]'" >&2; exit 1; }
if [ -n "$bump" ]; then
npm version "$bump" --no-git-tag-version
fi
version=$(node -p "require('./package.json').version")
name=$(node -p "require('./package.json').name")
npm run check
npm pack --dry-run
# The Unreleased section becomes the entry for this version, and a fresh
# Unreleased section opens above it.
perl -0pi -e "s/^## \[Unreleased\]\$/## [Unreleased]\n\n## [$version] - $(date +%F)/m" CHANGELOG.md
git commit -am "release v$version"
git tag -a "v$version" -m "v$version"
npm publish
git push origin main --follow-tags
# npm answers with a placeholder for a few minutes before the version resolves.
tries=0
until [ "$(npm view "$name@$version" version 2>/dev/null | tr -d "[:space:]'")" = "$version" ]; do
tries=$((tries + 1))
if [ "$tries" -ge 40 ]; then
echo "npm still has not served $name@$version after 10 minutes. Check https://www.npmjs.com/package/$name" >&2
break
fi
sleep 15
done
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
# Switch pi between this checkout (a symlink) and the published npm package.
#
# ./test_npm_package.sh toggle to whichever is not active
# ./test_npm_package.sh dev load this checkout
# ./test_npm_package.sh npm load the published package
#
# Only one of the two may be installed. pi identifies an npm package by name
# and a local one by path, so both at once register the provider twice.
# Takes effect on the next pi start or /reload.
set -euo pipefail
cd "$(dirname "$0")/.."
name=$(node -p "require('./package.json').name")
provider=nous-portal
agent_dir="${PI_CODING_AGENT_DIR:-$HOME/.pi/agent}"
repo="$PWD"
link="$agent_dir/extensions/$provider"
npm_installed() {
node -e "
const packages = require('$agent_dir/settings.json').packages || [];
const source = 'npm:$name';
process.exit(packages.some(p => (typeof p === 'string' ? p : p.source) === source) ? 0 : 1);
" 2>/dev/null
}
if [ -n "${1:-}" ]; then
target="$1"
elif [ -e "$link" ] || [ -L "$link" ]; then
target=npm
elif npm_installed; then
target=dev
else
target=npm
fi
case "$target" in
dev)
if npm_installed; then pi remove "npm:$name"; fi
mkdir -p "$(dirname "$link")"
if [ ! -e "$link" ] && [ ! -L "$link" ]; then ln -s "$repo" "$link"; fi
echo "dev: $link -> $repo"
;;
npm)
# Plain rm on the symlink. A trailing slash or -r would delete the checkout.
if [ -e "$link" ] || [ -L "$link" ]; then rm "$link"; fi
if ! npm_installed; then pi install "npm:$name"; fi
echo "npm: npm:$name in $agent_dir/settings.json"
;;
*)
echo "usage: $0 [dev|npm]" >&2
exit 1
;;
esac
echo "$provider models on the next start: $(pi --list-models 2>/dev/null | grep -c -w "$provider")"