mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
feat(update-checker): surface update notice to non-TTY/agent runs
- drop the CI / non-TTY early-return so agents see "Update available" too - widen check interval 4h→24h; stay silent inside the window (no per-command repeat) - remove orphan isCI() helper (zero callers) - versioning.md: drop the now-false "banner suppressed under agent" rationale
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Environment detection utilities for bailian-cli.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Detects whether the current process is running in a CI environment.
|
||||
*/
|
||||
export function isCI(): boolean {
|
||||
return !!(
|
||||
process.env.CI ||
|
||||
process.env.GITHUB_ACTIONS ||
|
||||
process.env.GITLAB_CI ||
|
||||
process.env.JENKINS_URL ||
|
||||
process.env.TRAVIS ||
|
||||
process.env.CIRCLECI
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
export { generateFilename } from "./filename.ts";
|
||||
export { resolveOutputDir } from "./output-dir.ts";
|
||||
export { maskToken } from "./token.ts";
|
||||
export { isCI } from "./env.ts";
|
||||
export { stripUndefined } from "./object.ts";
|
||||
export {
|
||||
parseBooleanValue,
|
||||
|
||||
@@ -7,7 +7,7 @@ export const NPM_REGISTRY = "https://registry.npmjs.org";
|
||||
export const NPM_PACKAGE = "bailian-cli";
|
||||
|
||||
const STATE_FILE = () => join(getConfigDir(), "update-state.json");
|
||||
const CHECK_INTERVAL_MS = 4 * 60 * 60 * 1000; // 4h
|
||||
const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000; // 24h
|
||||
const FETCH_TIMEOUT_MS = 3000;
|
||||
|
||||
/**
|
||||
@@ -77,19 +77,13 @@ export async function checkForUpdate(
|
||||
currentVersion: string,
|
||||
npmPackage: string = NPM_PACKAGE,
|
||||
): Promise<void> {
|
||||
// Skip in CI / non-TTY environments
|
||||
if (process.env.CI || !process.stderr.isTTY) return;
|
||||
|
||||
const state = readState();
|
||||
const now = Date.now();
|
||||
|
||||
// Throttle: skip if checked within the last 4 hours
|
||||
if (state && now - state.lastChecked < CHECK_INTERVAL_MS) {
|
||||
if (state.latestVersion && isNewerVersion(state.latestVersion, currentVersion)) {
|
||||
pendingNotification = state.latestVersion;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Inside the throttle window (CHECK_INTERVAL_MS since the last fetch): no
|
||||
// network call and no notice. The state file is global, so the notice fires at
|
||||
// most once per window across all processes/sessions — not once per command.
|
||||
if (state && now - state.lastChecked < CHECK_INTERVAL_MS) return;
|
||||
|
||||
const latest = await fetchLatestVersion(FETCH_TIMEOUT_MS, npmPackage);
|
||||
if (!latest) return;
|
||||
|
||||
@@ -3,11 +3,6 @@
|
||||
> Hand-maintained. Lives in `assets/` (not auto-generated from `catalog.ts`).
|
||||
> Entry point: [SKILL.md → Version & updates](../SKILL.md#version--updates-agent--do-first).
|
||||
|
||||
**Why this matters for agents:** when `bl` runs interactively it prints an
|
||||
`Update available` banner. That banner is **suppressed when `bl` is piped by an
|
||||
agent** (non-TTY stderr), so the user never learns their `bl` is outdated. The
|
||||
agent must take over that responsibility.
|
||||
|
||||
## Agent pre-flight checklist (MANDATORY)
|
||||
|
||||
**Do NOT run any `bl` command until you complete this checklist.** Run it **once per session**, before the first `bl` command. Cache the result — do not re-check before every command.
|
||||
|
||||
Reference in New Issue
Block a user