Compare commits

..
4 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
10 changed files with 195 additions and 41 deletions

No files matched your search

+14 -2
View File
@@ -9,7 +9,8 @@
- `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`).
- `./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.
- `./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
@@ -26,7 +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.
- **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 `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, so new entries always go under `## [Unreleased]`.
- **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
@@ -124,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) |
| [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 live in `docs/devlog/` (one per completed task/issue/milestone). Full history: [`docs/devlog/INDEX.md`](docs/devlog/INDEX.md). The 10 most recent:
@@ -131,6 +142,7 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu
<!-- write-log: window-start -->
| 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-architecture-review-tier-property-and-login-clock_log.md](docs/devlog/20261125-architecture-review-tier-property-and-login-clock_log.md) |
+2
View File
@@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file. The format is based on [Common Changelog](https://common-changelog.org) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.1.0] - 2026-11-25
### Added
+6 -4
View File
@@ -55,7 +55,7 @@ The choice is saved in `~/.pi/agent/nous-portal-catalog` and survives restarts.
- `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 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`, and only to `portal.nousresearch.com`, never to inference. This gets past the Vercel browser checkpoint that otherwise rejects CLI clients. It is a 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
@@ -66,14 +66,16 @@ npm run check # tsc --noEmit + node --test
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
./publish.sh # release the version in package.json
./publish.sh patch # bump first; minor and major work too
./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. You need `npm login` with publish rights to the package first.
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
-1
View File
@@ -18,7 +18,6 @@ Durable documentation that explains *why* the project is shaped the way it is: a
- Existing records:
- `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.
- `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`.
## Work Guidance
@@ -61,6 +61,12 @@ Verified before stopping: `npm run check` (25 tests pass), `shellcheck`, `npm pa
- [ ] 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*
+1
View File
@@ -5,6 +5,7 @@ Complete history of session logs in this directory, newest first. One-line summa
<!-- write-log: full-index -->
| 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-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 |
-34
View File
@@ -1,34 +0,0 @@
#!/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
if [ -n "$bump" ]; then
npm version "$bump" --no-git-tag-version
fi
version=$(node -p "require('./package.json').version")
grep -qx '## \[Unreleased\]' CHANGELOG.md || { echo "CHANGELOG.md has no '## [Unreleased]' heading" >&2; exit 1; }
npm run check
npm pack --dry-run
# The Unreleased section becomes the entry for this version.
perl -0pi -e "s/^## \[Unreleased\]\$/## [$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
+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")"