Skip to content

Commit 753f0bc

Browse files
committed
fix(cli): the stale-skills notice also prints on --json runs
1 parent e785681 commit 753f0bc

4 files changed

Lines changed: 48 additions & 21 deletions

File tree

‎packages/cli/src/cli.lifecycle.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,32 @@ describe("CLI lifecycle", () => {
321321
});
322322
});
323323

324+
describe("stale-skills notice under --json", () => {
325+
it("prints on a --json run while the self-update notices stay off", async () => {
326+
const printSkillsUpdateNotice = vi.fn();
327+
const printUpdateNotice = vi.fn();
328+
mockInitCommand(vi.fn());
329+
mockTelemetry();
330+
vi.doMock("./utils/autoUpdate.js", () => ({
331+
reportCompletedUpdate: vi.fn(),
332+
scheduleBackgroundInstall: vi.fn(),
333+
}));
334+
vi.doMock("./utils/updateCheck.js", () => ({
335+
cachedUpdateCheck: () => ({ current: "1.0.0", latest: "1.0.0", updateAvailable: false }),
336+
printUpdateNotice,
337+
printStalePinNotice: vi.fn(),
338+
}));
339+
vi.doMock("./utils/skillsUpdateCheck.js", () => ({ printSkillsUpdateNotice }));
340+
vi.doMock("./utils/backgroundChecks.js", () => ({ launchBackgroundChecks: vi.fn() }));
341+
342+
process.argv = ["node", "cli.ts", "init", "--json"];
343+
await import("./cli.js");
344+
345+
await vi.waitFor(() => expect(printSkillsUpdateNotice).toHaveBeenCalledTimes(1));
346+
expect(printUpdateNotice).not.toHaveBeenCalled();
347+
});
348+
});
349+
324350
const MOCKED_MODULES = [
325351
"./commands/init.js",
326352
"./telemetry/events.js",

‎packages/cli/src/cli.ts‎

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -266,31 +266,32 @@ if (
266266
// cached check while reporting fresh results of its own).
267267
if (
268268
!isHelp &&
269-
!hasJsonFlag &&
270269
command !== "upgrade" &&
271270
command !== "events" &&
272271
command !== "telemetry" &&
273272
command !== "skills" &&
274273
command !== "usage"
275274
) {
276-
// Report any completed auto-install from the previous run first, before
277-
// kicking off the next check — so the user sees "updated to vX" once and
278-
// we don't over-print.
279-
import("./utils/autoUpdate.js").then((mod) => mod.reportCompletedUpdate()).catch(() => {});
280-
281-
import("./utils/updateCheck.js")
282-
.then(async (mod) => {
283-
_printUpdateNotice = mod.printUpdateNotice;
284-
_printStalePinNotice = mod.printStalePinNotice;
285-
const result = mod.cachedUpdateCheck();
286-
if (result.updateAvailable) {
287-
const auto = await import("./utils/autoUpdate.js").catch(() => null);
288-
auto?.scheduleBackgroundInstall(result.latest, result.current);
289-
}
290-
})
291-
.catch(() => {});
275+
if (!hasJsonFlag) {
276+
// Report any completed auto-install from the previous run first, before
277+
// kicking off the next check — so the user sees "updated to vX" once and
278+
// we don't over-print.
279+
import("./utils/autoUpdate.js").then((mod) => mod.reportCompletedUpdate()).catch(() => {});
280+
281+
import("./utils/updateCheck.js")
282+
.then(async (mod) => {
283+
_printUpdateNotice = mod.printUpdateNotice;
284+
_printStalePinNotice = mod.printStalePinNotice;
285+
const result = mod.cachedUpdateCheck();
286+
if (result.updateAvailable) {
287+
const auto = await import("./utils/autoUpdate.js").catch(() => null);
288+
auto?.scheduleBackgroundInstall(result.latest, result.current);
289+
}
290+
})
291+
.catch(() => {});
292+
}
292293

293-
// Skills freshness nudge — same gating as the CLI self-update notice.
294+
// Skills freshness nudge: stderr only, so it also runs under --json, which agents pass.
294295
import("./utils/skillsUpdateCheck.js")
295296
.then((mod) => {
296297
_printSkillsUpdateNotice = mod.printSkillsUpdateNotice;
@@ -342,8 +343,8 @@ async function finalizeCli(result: CommandResult): Promise<void> {
342343
if (!hasJsonFlag) {
343344
_printUpdateNotice?.();
344345
_printStalePinNotice?.();
345-
_printSkillsUpdateNotice?.();
346346
}
347+
_printSkillsUpdateNotice?.();
347348
if (_appHistoryNotice) process.stderr.write(`◇ ${_appHistoryNotice}\n`);
348349
process.exitCode = exitCode;
349350
}

‎skills-manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"files": 2
77
},
88
"hyperframes": {
9-
"hash": "946983fbdd9bce91",
9+
"hash": "8fc4b05db245cbbb",
1010
"files": 77
1111
},
1212
"hyperframes-cli": {

‎skills/hyperframes/references/skill-lifecycle.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ For a plugin installation, follow [plugin execution rules](plugin-installation.m
1717

1818
## Stale-skills notice
1919

20-
After `render`, `lint` and `validate`, the CLI prints `N HyperFrames skills out of date or missing` to stderr when the cached check finds stale skills, so an agent run without a terminal sees it too. It is off in CI, in dev, with `HYPERFRAMES_NO_UPDATE_CHECK=1` and with `HYPERFRAMES_SKIP_SKILLS=1`, and never touches `--json` stdout.
20+
After `render`, `lint` and `validate`, the CLI prints `N HyperFrames skills out of date or missing` to stderr when the cached check finds stale skills, so an agent run without a terminal sees it too. It is off in CI, in dev, with `HYPERFRAMES_NO_UPDATE_CHECK=1` and with `HYPERFRAMES_SKIP_SKILLS=1`, and runs with `--json` too, since it only writes stderr and leaves `--json` stdout untouched.
2121

2222
## Diagnose and update
2323

0 commit comments

Comments
 (0)