@pi-unipi/updater 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,22 +1,44 @@
1
1
  # @pi-unipi/updater
2
2
 
3
- Auto-updater, changelog browser, and readme browser for the Unipi extension suite.
3
+ Checks npm for new versions on session start, shows a changelog diff, and lets you update with one keypress. Also provides TUI browsers for package READMEs and the changelog.
4
4
 
5
- ## Features
6
-
7
- - **Auto-updater** — Periodically checks npm registry for new versions, shows update prompt with changelog diff
8
- - **Changelog browser** — TUI overlay listing all versions with dates and status labels (✓ Current, ↑ New)
9
- - **Readme browser** — TUI overlay listing all packages with versions, opens rendered README content
5
+ The update overlay appears automatically when a newer version is found. Press `Y` to update, `n` to skip. Skipped versions are cached — you only get re-prompted when an even newer version appears.
10
6
 
11
7
  ## Commands
12
8
 
13
9
  | Command | Description |
14
10
  |---------|-------------|
15
- | `/unipi:readme [package]` | Browse package README files. No arg opens list, with arg opens directly. |
11
+ | `/unipi:readme [package]` | Browse package README files in TUI overlay |
16
12
  | `/unipi:changelog` | Browse CHANGELOG.md with version list and detail view |
17
13
  | `/unipi:updater-settings` | Configure check interval and auto-update mode |
18
14
 
19
- ## Configuration
15
+ ### TUI Controls
16
+
17
+ | Key | Action |
18
+ |-----|--------|
19
+ | `j/k` or Up/Down | Navigate |
20
+ | `Enter` | Select/open |
21
+ | `q/Esc` | Back/close |
22
+ | `g/G` | Jump to top/bottom |
23
+ | `Space` | Cycle options (settings) |
24
+ | `h/l` or Left/Right | Cycle options (settings) |
25
+
26
+ ## Special Triggers
27
+
28
+ On session start, updater checks the npm registry for `@pi-unipi/unipi`. If a newer version exists and wasn't previously skipped, it shows the update overlay with changelog diff. This runs once per session, respecting the check interval config.
29
+
30
+ Updater registers with the info-screen dashboard, showing installed version, latest version, update status, and last check time.
31
+
32
+ ## How Updates Work
33
+
34
+ 1. Session start triggers npm registry check
35
+ 2. Compare latest version with installed version
36
+ 3. If newer and not skipped, show update overlay
37
+ 4. User views changelog diff, presses `Y` to update or `n` to skip
38
+ 5. Update runs `pi install npm:@pi-unipi/unipi`
39
+ 6. Skipped version cached — re-prompted only for newer versions
40
+
41
+ ## Configurables
20
42
 
21
43
  Config stored at `~/.unipi/config/updater/config.json`:
22
44
 
@@ -27,41 +49,21 @@ Config stored at `~/.unipi/config/updater/config.json`:
27
49
  }
28
50
  ```
29
51
 
30
- ### Options
31
-
32
52
  | Option | Values | Default |
33
53
  |--------|--------|---------|
34
- | `checkIntervalMs` | `1800000` (30min), `3600000` (1h), `21600000` (6h), `86400000` (1d) | `3600000` (1h) |
35
- | `autoUpdate` | `disabled`, `notify`, `auto` | `notify` |
54
+ | `checkIntervalMs` | 1800000 (30min), 3600000 (1h), 21600000 (6h), 86400000 (1d) | 3600000 (1h) |
55
+ | `autoUpdate` | disabled, notify, auto | notify |
36
56
 
37
- ### Auto-update modes
57
+ ### Auto-update Modes
38
58
 
39
59
  - **disabled** — No update checks on session start
40
- - **notify** — Show update overlay with changelog diff, user chooses [Y] Update or [n] Skip
41
- - **auto** — Show countdown overlay, auto-install after 5 seconds unless cancelled
42
-
43
- ## How it works
44
-
45
- 1. On session start, checks npm registry for `@pi-unipi/unipi` latest version
46
- 2. Compares with installed version from `package.json`
47
- 3. If newer version found and not previously skipped, shows update overlay
48
- 4. User can view changelog diff, update with `[Y]`, or skip with `[n]`
49
- 5. Skipped versions are cached — only re-prompted when an even newer version appears
50
- 6. Update installs via `pi install npm:@pi-unipi/unipi`
60
+ - **notify** — Show overlay with changelog, user chooses Y/n
61
+ - **auto** — Show countdown, auto-install after 5 seconds unless cancelled
51
62
 
52
- ## TUI Overlays
63
+ ### Cache
53
64
 
54
- All overlays use keyboard navigation:
55
- - `j`/`k` or ↑/↓ — navigate
56
- - `Enter` — select/open
57
- - `q`/`Esc` — back/close
58
- - `g`/`G` — jump to top/bottom
59
- - `Space` — cycle options (settings overlay)
60
- - `h`/`l` or ←/→ — cycle options (settings overlay)
65
+ Last-check cache at `~/.unipi/cache/updater/last-check.json`:
61
66
 
62
- ## Cache
63
-
64
- Last-check cache stored at `~/.unipi/cache/updater/last-check.json`:
65
67
  ```json
66
68
  {
67
69
  "lastCheck": "2026-05-01T12:00:00.000Z",
@@ -69,3 +71,7 @@ Last-check cache stored at `~/.unipi/cache/updater/last-check.json`:
69
71
  "skippedVersion": "0.1.16"
70
72
  }
71
73
  ```
74
+
75
+ ## License
76
+
77
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/updater",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Auto-updater, changelog browser, and readme browser for Unipi — checks npm registry, renders CHANGELOG.md and README.md files in TUI overlays",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/checker.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * respects check interval from config/cache.
6
6
  */
7
7
 
8
- import { getPackageVersion } from "@pi-unipi/core";
8
+ import { getInstalledPackageVersion } from "@pi-unipi/core";
9
9
  import { loadConfig } from "./settings.js";
10
10
  import { readLastCheck, writeLastCheck, isCheckDue } from "./cache.js";
11
11
  import type { UpdateCheckResult } from "../types.js";
@@ -15,9 +15,9 @@ const NPM_REGISTRY_URL = "https://registry.npmjs.org/@pi-unipi/unipi";
15
15
 
16
16
  /** Resolve the installed version of @pi-unipi/unipi */
17
17
  function getInstalledVersion(): string {
18
- // Walk up from this file to find the monorepo root
19
- const dir = new URL("../../..", import.meta.url).pathname;
20
- return getPackageVersion(dir);
18
+ // Walk up from this file to find the @pi-unipi/unipi package by name
19
+ const dir = new URL("..", import.meta.url).pathname;
20
+ return getInstalledPackageVersion(dir, "@pi-unipi/unipi");
21
21
  }
22
22
 
23
23
  /**
package/src/installer.ts CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { exec } from "child_process";
9
9
  import { promisify } from "util";
10
- import { getPackageVersion, emitEvent, UNIPI_EVENTS } from "@pi-unipi/core";
10
+ import { getInstalledPackageVersion, emitEvent, UNIPI_EVENTS } from "@pi-unipi/core";
11
11
  import type { InstallResult } from "../types.js";
12
12
 
13
13
  const execAsync = promisify(exec);
@@ -23,9 +23,8 @@ const INSTALL_TIMEOUT_MS = 60000;
23
23
  export async function installUpdate(
24
24
  pi?: { events: { emit: (name: string, payload: unknown) => void } },
25
25
  ): Promise<InstallResult> {
26
- const installedBefore = getPackageVersion(
27
- new URL("../../..", import.meta.url).pathname,
28
- );
26
+ const thisDir = new URL("..", import.meta.url).pathname;
27
+ const installedBefore = getInstalledPackageVersion(thisDir, "@pi-unipi/unipi");
29
28
 
30
29
  try {
31
30
  const { stdout, stderr } = await execAsync(
@@ -37,9 +36,7 @@ export async function installUpdate(
37
36
  );
38
37
 
39
38
  // Get new version after install
40
- const installedAfter = getPackageVersion(
41
- new URL("../../..", import.meta.url).pathname,
42
- );
39
+ const installedAfter = getInstalledPackageVersion(thisDir, "@pi-unipi/unipi");
43
40
 
44
41
  const result: InstallResult = {
45
42
  success: true,
package/src/readme.ts CHANGED
@@ -7,7 +7,8 @@
7
7
  */
8
8
 
9
9
  import { existsSync, readFileSync } from "fs";
10
- import { join, resolve } from "path";
10
+ import { join } from "path";
11
+ import { findPackageRoot } from "@pi-unipi/core";
11
12
  import { MODULES } from "@pi-unipi/core";
12
13
  import type { ReadmeEntry } from "../types.js";
13
14
 
@@ -35,14 +36,12 @@ const PACKAGE_MAP: Record<string, string> = {
35
36
  updater: MODULES.UPDATER,
36
37
  };
37
38
 
38
- /** Resolve the unipi monorepo root directory */
39
+ /** Resolve the unipi package root directory */
39
40
  function resolveUnipiRoot(): string {
40
- // Walk up from this file to find the monorepo root (has package.json with @pi-unipi/unipi)
41
- let dir = new URL(".", import.meta.url).pathname;
42
- // From src/updater/src/ go up 4 levels to reach monorepo root
43
- // Actually: packages/updater/src/readme.ts ../../.. = monorepo root
44
- dir = resolve(dir, "../../..");
45
- return dir;
41
+ // Walk up from this file to find @pi-unipi/unipi by name
42
+ const dir = new URL(".", import.meta.url).pathname;
43
+ const root = findPackageRoot(dir, "@pi-unipi/unipi");
44
+ return root ?? join(dir, ".."); // fallback to parent
46
45
  }
47
46
 
48
47
  /** Get version from a package.json at the given directory */
@@ -11,7 +11,7 @@ import { Key, matchesKey, truncateToWidth, visibleWidth } from "@mariozechner/pi
11
11
  import type { Theme } from "@mariozechner/pi-coding-agent";
12
12
  import { parseChangelog } from "../changelog.js";
13
13
  import { renderMarkdown } from "../markdown.js";
14
- import { getPackageVersion } from "@pi-unipi/core";
14
+ import { getInstalledPackageVersion } from "@pi-unipi/core";
15
15
  import type { ChangelogEntry } from "../../types.js";
16
16
 
17
17
  type View = "list" | "detail";
@@ -44,8 +44,9 @@ export function renderChangelogOverlay() {
44
44
  _kb: any,
45
45
  done: (result: { viewed: boolean } | null) => void,
46
46
  ) => {
47
- const installedVersion = getPackageVersion(
48
- new URL("../../..", import.meta.url).pathname,
47
+ const installedVersion = getInstalledPackageVersion(
48
+ new URL("..", import.meta.url).pathname,
49
+ "@pi-unipi/unipi",
49
50
  );
50
51
 
51
52
  const state: ChangelogState = {