feat(cli): add version check system with agent-friendly output

- New `updateCheck.ts` utility: cached npm registry check (24h TTL),
  sync `getUpdateMeta()` for _meta envelope, `printUpdateNotice()` for
  passive stderr banner
- `upgrade --check --json`: machine-readable version check for AI agents
  Returns { current, latest, updateAvailable }
- `_meta` envelope on all --json commands (info, lint, benchmark,
  compositions): includes version, latestVersion, updateAvailable
- `doctor` shows version check as first row
- Passive update notice on stderr after command completes (skipped in
  CI, non-TTY, --json, --quiet)
- Background check fires on startup (non-blocking, populates cache)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
James
2026-03-27 01:41:34 +00:00
co-authored by Claude Opus 4.6
parent 101ff633ca
commit cd15c68a2e
9 changed files with 181 additions and 37 deletions
+6
View File
@@ -19,6 +19,10 @@ export interface HyperframesConfig {
telemetryNoticeShown: boolean;
/** Total CLI command invocations (for engagement prompts) */
commandCount: number;
/** ISO timestamp of the last npm registry version check */
lastUpdateCheck?: string;
/** Latest version found on npm */
latestVersion?: string;
}
const DEFAULT_CONFIG: HyperframesConfig = {
@@ -52,6 +56,8 @@ export function readConfig(): HyperframesConfig {
anonymousId: parsed.anonymousId || randomUUID(),
telemetryNoticeShown: parsed.telemetryNoticeShown ?? DEFAULT_CONFIG.telemetryNoticeShown,
commandCount: parsed.commandCount ?? DEFAULT_CONFIG.commandCount,
lastUpdateCheck: parsed.lastUpdateCheck,
latestVersion: parsed.latestVersion,
};
cachedConfig = config;