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.
This commit is contained in:
AlexKucera committed 2026-11-25 16:51:36 +01:00
1 parent 21ec8029c5
commit b71363efb9
8 files changed
+146 -8

No files matched your search

+13 -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,7 @@
- **`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]`. 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.
- **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.
## Catalog tiers
@@ -124,6 +125,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 +141,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) |