Skip to content

feat(doctor): nudge when a newer starloghq is published - #54

Merged
basicScandal merged 1 commit into
mainfrom
feat/doctor-update-check
Jul 13, 2026
Merged

feat(doctor): nudge when a newer starloghq is published#54
basicScandal merged 1 commit into
mainfrom
feat/doctor-update-check

Conversation

@basicScandal

Copy link
Copy Markdown
Member

Problem (maintenance automation #3)

A stale install of a security tool is a liability, but nothing surfaced that a user was behind. starlog doctor now checks the npm registry and nudges to upgrade.

Change

  • src/update-check.tscompareVersions (pure x.y.z, tolerates a leading v and pre-release suffixes, never throws) + fetchLatestVersion (short timeout, injectable fetchImpl, STARLOG_REGISTRY_URL override, returns null on any failure).
  • doctor gains a "Version" checkwarn with npm install -g starloghq@latest when behind, ok when current.

Best-effort by design

Skipped on STARLOG_NO_UPDATE_CHECK; any network failure returns no line rather than a red mark; staleness is a warn (exit 0). A diagnostic must never hang or fail because npm was unreachable.

Tests

  • Unit: compareVersions ordering/edge cases; fetchLatestVersion success / non-ok / missing-field / throws-→-null.
  • e2e: doctor served a newer version from a local registry stand-in asserts the nudge. Uses async spawn (not spawnSync) so the in-process HTTP server can answer the child — a synchronous spawn deadlocks the event loop and the child's fetch times out.
  • The release gate + existing doctor e2e set STARLOG_NO_UPDATE_CHECK to stay hermetic/offline.
  • Full suite 565/565; release gate 20/20 (pre-rebase). Rebased onto latest main (co-exists with doctor: warn when the installed hook is the legacy self-contained form #52's legacy-hook doctor test).

Batch: #1 hook shim ✅ (#51) → #3 this PR → next: #2 (server.json bump + CI version gate + OIDC registry publish).

🤖 Generated with Claude Code

A stale install of a security tool is a liability, but nothing told users
they were behind. `starlog doctor` now checks the npm registry for a newer
version and nudges to upgrade.

- src/update-check.ts: compareVersions (pure, x.y.z, tolerates v-prefix and
  pre-release suffixes) + fetchLatestVersion (short timeout, injectable fetch,
  STARLOG_REGISTRY_URL override, returns null on any failure).
- doctor gains a "Version" check: `warn` with an upgrade command when behind,
  `ok` when current. Best-effort — skipped on STARLOG_NO_UPDATE_CHECK, and any
  network failure returns no line rather than a red mark, so a diagnostic never
  hangs or fails because npm was unreachable. Staleness is advisory (exit 0).

Tests: update-check unit tests (compare + fetch success/failure/timeout);
a doctor e2e that serves a newer version from a local registry stand-in and
asserts the nudge (async spawn so the in-process server can answer the child).
The gate and existing doctor e2e set STARLOG_NO_UPDATE_CHECK to stay hermetic.
Full suite 564/564; release gate 20/20.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@basicScandal
basicScandal merged commit 5f642ab into main Jul 13, 2026
4 checks passed
@basicScandal
basicScandal deleted the feat/doctor-update-check branch July 13, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant