# 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 @` 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*