From d4b3e0f2b0ca0cf08f2d5ccbb9aa2d8dac12e525 Mon Sep 17 00:00:00 2001 From: Mikael Hugo Date: Tue, 5 May 2026 01:37:51 +0200 Subject: [PATCH] feat(schedule): add lightweight due-items banner to loader.ts --- src/loader.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/loader.ts b/src/loader.ts index 851d2d416..7e53dda1d 100644 --- a/src/loader.ts +++ b/src/loader.ts @@ -106,6 +106,36 @@ if (firstArg === "headless") { } } +// Schedule due-items banner — lightweight check before heavy imports +if (!process.env.SF_QUIET && firstArg !== "--version" && firstArg !== "-v" && firstArg !== "--help" && firstArg !== "-h") { + try { + const schedulePath = join(process.cwd(), ".sf", "schedule.jsonl"); + if (existsSync(schedulePath)) { + const content = readFileSync(schedulePath, "utf-8"); + const now = Date.now(); + let dueCount = 0; + for (const line of content.split("\n")) { + if (!line.trim()) continue; + try { + const entry = JSON.parse(line); + if (entry.status === "pending" && new Date(entry.due_at).getTime() <= now) { + dueCount++; + } + } catch { + // skip corrupt lines + } + } + if (dueCount > 0) { + process.stderr.write( + `[forge] ${dueCount} scheduled item${dueCount === 1 ? "" : "s"} due now. Manage: /sf schedule list\n`, + ); + } + } + } catch { + // non-fatal + } +} + // --------------------------------------------------------------------------- // Runtime dependency checks — fail fast with clear diagnostics before any // heavy imports. Reads minimum Node version from the engines field in