Skip to content

Make PromptKit version visible: session banner + CLI update check#249

Open
abeltrano wants to merge 3 commits intomainfrom
announce-promptkit-version-on-load
Open

Make PromptKit version visible: session banner + CLI update check#249
abeltrano wants to merge 3 commits intomainfrom
announce-promptkit-version-on-load

Conversation

@abeltrano
Copy link
Copy Markdown
Collaborator

@abeltrano abeltrano commented Apr 17, 2026

Closes #248.
Closes #250.

This PR adds two small, complementary pieces of version visibility to PromptKit.


1. Announce the loaded PromptKit version (#248)

One surgical edit to bootstrap.md step 1 of How to Begin. After reading manifest.yaml, the composition engine now reads the top-level version: field and emits a banner before any other output. If the field is missing or unreadable, a (version unknown) fallback is emitted — no version is ever fabricated. The engine re-announces whenever bootstrap.md or manifest.yaml is re-read.

All three entry-point skills (/promptkit, /bootstrap, /boot) and the promptkit interactive (npx) flow converge on bootstrap.md, so this one edit covers every activation path — manual load, slash command, and CLI.

New session-start output

Against the current repo (manifest.yaml has version: ""0.6.1""), the first line of any new session is:

PromptKit v0.6.1 loaded.

If manifest.yaml ever ships without a readable version: field, the engine emits instead:

PromptKit (version unknown) loaded.

2. Notify users when a newer CLI version is available (#250)

Adds a best-effort update check to promptkit interactive. Follows the standard pattern used by npm, yarn, vercel, and gh, but implemented with no new runtime dependencies (pure built-in https).

Behavior

  • Queries https://registry.npmjs.org/@alan-jowett/promptkit/latest with a hard ~1500 ms timeout.

  • Compares json.version against package.json.version with simple major.minor.patch ordering (strips a leading v, ignores prerelease/build suffix).

  • On newer version, prints a boxed banner before spawning the LLM CLI:

    +----------------------------------------+
    | Update available: 0.6.1 -> 0.7.0       |
    | Run: npm i -g @alan-jowett/promptkit   |
    +----------------------------------------+
    
  • Caches the result in ~/.promptkit/update-check.json for 24 h; subsequent launches skip the network but still show the banner if a newer version is cached.

  • Network, DNS, timeout, HTTP-non-200, malformed-JSON, and cache I/O failures are all swallowed — the check is strictly best-effort and can never block or break the CLI.

  • Response body is capped at 64 KB to defend against a misbehaving registry.

Opt-out / non-interactive safety

  • NO_UPDATE_NOTIFIER=1 — suppresses the check.
  • CI env var set — suppresses.
  • stdout is not a TTY (piped/scripted usage) — suppresses.
  • --no-update-check flag — suppresses.
  • Non-interactive subcommands (list, search, show, --version) never run the check, keeping machine-readable output clean.

Surface area

  • cli/lib/update-check.js — new module. Pure functions (parseVersion, isNewer, formatBanner, suppressionReason) plus the one network function (fetchLatest) behind checkForUpdate.
  • cli/bin/cli.jsinteractive action becomes async, calls checkForUpdate inside a try/catch before launchInteractive, gated by the new --no-update-check flag.
  • cli/tests/update-check.test.js — new unit tests for version parsing/comparison/banner/suppression. No network I/O in tests.
  • cli/tests/cli.test.js — test harness extended to copy lib/update-check.js into its temp CLI root.
  • cli/package.jsontest script adds the new test file. No new dependencies.

Test status

npm test in cli/ passes 65/66. The one remaining failure (TC-CLI-082/083 gh-copilot spawned with originalCwd and --add-dir for staging dir in launch.test.js:335) also fails on main and is unrelated to this change — it is a pre-existing flaky/environmental test.

python tests/validate-manifest.py — OK.


Version-source consistency

manifest.yaml.version (what the in-session banner reads) and cli/package.json.version (what promptkit --version and the update check read) are already kept aligned per cli/specs/design.md v0.6.1, so all three user-visible version surfaces report the same number for any published release. A follow-up to enforce this in tests/validate-manifest.py is captured in #248.

Files changed

  • bootstrap.md (+7 lines)
  • cli/bin/cli.js (+14 / -1)
  • cli/lib/update-check.js (new, 176 lines)
  • cli/package.json (+1 / -1 — test script)
  • cli/tests/cli.test.js (+6 lines — harness)
  • cli/tests/update-check.test.js (new, 152 lines)

No persona, protocol, template, format, or taxonomy content touched.

Add an instruction to bootstrap.md step 1 so the composition engine emits a one-line 'PromptKit v<version> loaded.' banner after reading manifest.yaml. The version is read from the top-level 'version:' field; a 'version unknown' fallback is used if the field is missing or unreadable, and no version is ever fabricated.

This applies to both manual loads and the 'promptkit interactive' (npx) flow, since the CLI stages the same bootstrap.md and manifest.yaml into a temp dir before instructing the LLM to read bootstrap.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 17, 2026 15:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a version-identifying banner to PromptKit’s bootstrap flow so every interactive session immediately reports which PromptKit release is loaded, improving provenance for debugging and support.

Changes:

  • Update bootstrap.md “How to Begin” step 1 to instruct the engine to read manifest.yaml.version and emit a one-line “PromptKit vX loaded.” banner (with an “unknown” fallback).
  • Re-announce the version when bootstrap.md or manifest.yaml is re-read later in the session.

Comment thread bootstrap.md Outdated
Adds a best-effort daily update check to 'promptkit interactive'. The CLI queries https://registry.npmjs.org/<pkg>/latest (built-in https, ~1500ms timeout), caches the result in ~/.promptkit/update-check.json for 24h, and prints a boxed banner before spawning the LLM when a newer version exists. No new runtime dependencies.

Suppressed by NO_UPDATE_NOTIFIER=1, CI, non-TTY stdout, --no-update-check, and for non-interactive subcommands (list/search/show/--version). Network, cache, and parse failures are silently swallowed and never surface to the user.

Adds cli/tests/update-check.test.js with unit coverage for parseVersion, isNewer, formatBanner, and suppressionReason (no network I/O). Updates cli/tests/cli.test.js harness to copy the new lib/update-check.js into the temp CLI root.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@abeltrano abeltrano changed the title Announce PromptKit version when bootstrap loads Make PromptKit version visible: session banner + CLI update check Apr 17, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 17, 2026 16:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Comment thread cli/lib/update-check.js
Comment on lines +83 to +86
const req = https.get(
url,
{ timeout: FETCH_TIMEOUT_MS, headers: { Accept: "application/json" } },
(res) => {
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FETCH_TIMEOUT_MS is described as a hard ~1500ms cap, but https.get({ timeout }) only sets a socket inactivity timeout (it can exceed 1500ms if the server trickles data). If you need a true hard deadline, add an explicit overall timer (e.g., setTimeout that destroys the request) so interactive startup can’t be delayed longer than intended.

Copilot uses AI. Check for mistakes.
Comment thread cli/lib/update-check.js
Comment on lines +155 to +158
latest = await fetchLatest(pkgName);
if (latest) {
writeCache({ pkg: pkgName, latest, checkedAt: now });
}
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkForUpdate caches any truthy latest string, even if it’s not parseable by parseVersion. That can lock users into a bad cached value for 24h (and can also lead to odd banner output if it’s unexpectedly formatted). Consider validating latest with parseVersion (or isNewer inputs) before writing it to cache / returning it.

Copilot uses AI. Check for mistakes.
Comment thread cli/lib/update-check.js
Comment on lines +142 to +159
const cache = readCache();
let latest = null;

if (
!force &&
cache &&
cache.pkg === pkgName &&
typeof cache.latest === "string" &&
typeof cache.checkedAt === "number" &&
now - cache.checkedAt < CACHE_TTL_MS
) {
latest = cache.latest;
} else {
latest = await fetchLatest(pkgName);
if (latest) {
writeCache({ pkg: pkgName, latest, checkedAt: now });
}
}
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache/TLL branch in checkForUpdate (reading ~/.promptkit/update-check.json, TTL gating, and the “cached newer version still shows banner” behavior) isn’t covered by unit tests yet. Since _internals are already exported, consider adding tests that stub cache read/write + now to exercise: fresh cache hit, expired cache triggering fetch, and banner decision based on cached latest.

Copilot uses AI. Check for mistakes.
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.

Notify users when a newer PromptKit CLI version is available Announce PromptKit version when bootstrap/manifest loads

2 participants