feat(schedule): add lightweight due-items banner to loader.ts
This commit is contained in:
parent
7e1883844a
commit
d4b3e0f2b0
1 changed files with 30 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue