Implement pi registration with URL dedupe and reload reminder in scripts/local-install.mjs #90

Closed
opened 2026-08-27 23:59:07 +00:00 by david · 1 comment
Owner

Summary

Implement Step 3 (register this repo with pi globally as a local-path package, removing any pre-existing URL-based entries for the same repo identity) and Step 4 (print the completion + /reload reminder), so the script exits 0 on the happy path.

Background

pi stores installed packages in user settings at ~/.pi/agent/settings.json. A previous install may have registered this repo by URL; pi install <absolute local path> registers it as a local-path package so pi loads exactly this repo's pi manifest — and, unlike URL installs, does NOT run npm install (the script already did that in Step 2). Any pre-existing URL entry for the same repo must be removed first so there is a single clean identity and no duplicated skills/extensions after /reload.

Part of the npm run install:local feature (tracking issue #41).

Depends on: #88 (Implement git pull and npm install steps in scripts/local-install.mjs).

Implementation Details

  • Step 3 — register with pi (global + dedupe):
    1. Read ~/.pi/agent/settings.json (user settings). A missing or unreadable file means "no entries" — continue rather than abort (the pi commands below still run).
    2. Find every package entry whose source references this repo's URL. Match the plain form https://git.excelera.net/david/pi-extensions-and-skills AND the git:/ssh:// forms of the same identity (e.g. git://git.excelera.net/david/pi-extensions-and-skills, ssh://git@git.excelera.net/david/pi-extensions-and-skills). Normalize trailing .git and trailing slashes when comparing.
    3. For each match: pi remove <source>.
    4. pi install <absolute path to repo> — resolve the absolute path from the current working directory (e.g. fs.realpathSync(process.cwd())).
    5. Any pi command failure → abort with that command's output and a non-zero exit.
  • Step 4 — reminder: on success print exactly:
Done. Run /reload in pi to pick up the changes.
Verify: pi list  →  /skills (expect 12 skills, 4 extensions incl. forgejo)
  • Exit 0 after Step 4.

Acceptance Criteria

  • After a successful run, pi list shows this repo as a local-path package entry.
  • After a successful run, no entry whose source references https://git.excelera.net/david/pi-extensions-and-skills (or its git:/ssh:// forms) remains in ~/.pi/agent/settings.json.
  • A pre-existing URL entry for this repo is removed and replaced by the local-path entry (dedupe → single identity, no duplicated skills/extensions).
  • A failing pi command aborts the script with that command's output and a non-zero exit.
  • On success, the exact Step-4 reminder text is printed (12 skills, 4 extensions incl. forgejo) and the script exits 0.

Test Plan

  • Dedupe: before running, add a URL entry for this repo to ~/.pi/agent/settings.json (or back up and temporarily edit it), then run node scripts/local-install.mjs on clean main. Afterwards: pi list shows only the local-path entry, and grepping the settings file shows no URL entry for this repo. Restore the settings file afterwards if it was edited.
  • pi failure path: temporarily make pi fail (e.g. run with a PATH where pi is a failing stub) → verify the abort message includes the command's output and the exit code is non-zero. (Also covered by unit tests in a later step.)
## Summary Implement Step 3 (register this repo with pi globally as a local-path package, removing any pre-existing URL-based entries for the same repo identity) and Step 4 (print the completion + `/reload` reminder), so the script exits 0 on the happy path. ## Background pi stores installed packages in user settings at `~/.pi/agent/settings.json`. A previous install may have registered this repo by URL; `pi install <absolute local path>` registers it as a local-path package so pi loads exactly this repo's `pi` manifest — and, unlike URL installs, does NOT run `npm install` (the script already did that in Step 2). Any pre-existing URL entry for the same repo must be removed first so there is a single clean identity and no duplicated skills/extensions after `/reload`. Part of the `npm run install:local` feature (tracking issue #41). **Depends on:** #88 (Implement git pull and npm install steps in scripts/local-install.mjs). ## Implementation Details - **Step 3 — register with pi (global + dedupe)**: 1. Read `~/.pi/agent/settings.json` (user settings). A missing or unreadable file means "no entries" — continue rather than abort (the pi commands below still run). 2. Find every package entry whose source references this repo's URL. Match the plain form `https://git.excelera.net/david/pi-extensions-and-skills` AND the `git:`/`ssh://` forms of the same identity (e.g. `git://git.excelera.net/david/pi-extensions-and-skills`, `ssh://git@git.excelera.net/david/pi-extensions-and-skills`). Normalize trailing `.git` and trailing slashes when comparing. 3. For each match: `pi remove <source>`. 4. `pi install <absolute path to repo>` — resolve the absolute path from the current working directory (e.g. `fs.realpathSync(process.cwd())`). 5. Any `pi` command failure → abort with that command's output and a non-zero exit. - **Step 4 — reminder**: on success print exactly: ``` Done. Run /reload in pi to pick up the changes. Verify: pi list → /skills (expect 12 skills, 4 extensions incl. forgejo) ``` - Exit 0 after Step 4. ## Acceptance Criteria - [ ] After a successful run, `pi list` shows this repo as a local-path package entry. - [ ] After a successful run, no entry whose source references `https://git.excelera.net/david/pi-extensions-and-skills` (or its `git:`/`ssh://` forms) remains in `~/.pi/agent/settings.json`. - [ ] A pre-existing URL entry for this repo is removed and replaced by the local-path entry (dedupe → single identity, no duplicated skills/extensions). - [ ] A failing `pi` command aborts the script with that command's output and a non-zero exit. - [ ] On success, the exact Step-4 reminder text is printed (12 skills, 4 extensions incl. forgejo) and the script exits 0. ## Test Plan - Dedupe: before running, add a URL entry for this repo to `~/.pi/agent/settings.json` (or back up and temporarily edit it), then run `node scripts/local-install.mjs` on clean `main`. Afterwards: `pi list` shows only the local-path entry, and grepping the settings file shows no URL entry for this repo. Restore the settings file afterwards if it was edited. - pi failure path: temporarily make `pi` fail (e.g. run with a PATH where `pi` is a failing stub) → verify the abort message includes the command's output and the exit code is non-zero. (Also covered by unit tests in a later step.)
david closed this issue 2026-08-28 01:58:27 +00:00
Author
Owner

pi-loop opened and merged a pull request for this issue: #98

pi-loop opened and merged a pull request for this issue: https://git.excelera.net/david/pi-extensions-and-skills/pulls/98
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
david/pi-extensions-and-skills#90
No description provided.