matthewwong525/WongStack / .agents/plugins/daily
daily
VerifiedDaily asks in any chat: what's going on, stop or start check-ins or the line-up, daily settings.
scripts/schedule-runs.mjs
View on GitHub// The background schedule runs the helper hands this worker: `schedule-run-<run id>.json` in the event folder. A run
// starts only when the schedule store's `check` passes it. wiki/stack/host-schedules.md
import { mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync } from 'node:fs';
import { join } from 'node:path';
import { primaryRoot } from './lib/primary-root.mjs';
import { agentEvents } from './chief.mjs';
const FILE = /^schedule-run-[0-9a-f]{32}\.json$/;
/** A hand-over older than this is past the app's own two minutes, so its run already shows as not started. */
const STALE_MS = 10 * 60e3;
const list = dir => { try { return readdirSync(dir).filter(name => FILE.test(name)); } catch { return []; } };
const real = dir => { try { return realpathSync(dir); } catch { return dir; } };
export const inProject = (dir, project) => { try { return real(primaryRoot(dir).primary) === real(project); } catch { return false; } };
/** The hand-over files waiting in the event folder. */
export const waitingRuns = env => list(agentEvents(env));
/** Takes the person's own hand-overs for `project`: each moves into the state folder first, so one worker runs it once.
* Another person's file, or another checkout's, stays; a stale or broken one goes. */
export function takeRuns({ env = process.env, project, emails, stateDir, now = Date.now() }) {
const folder = agentEvents(env), mine = new Set(emails.map(email => email.toLowerCase())), taken = [];
const held = join(stateDir, 'schedule-runs');
for (const name of list(folder)) {
const file = join(folder, name);
let event;
try {
({ event } = JSON.parse(readFileSync(file, 'utf8')));
if (now - statSync(file).mtimeMs > STALE_MS) throw new Error('stale');
} catch { rmSync(file, { force: true }); continue; }
if (!mine.has(String(event?.email).toLowerCase()) || !inProject(event.cwd, project)) continue;
mkdirSync(held, { recursive: true, mode: 0o700 });
try { renameSync(file, join(held, name)); } catch { continue; }
rmSync(join(held, name), { force: true });
taken.push(event);
}
return taken;
}
/** Reports each hand-over taken while check-ins are off as blocked, `checkins_off`: the store says why it never ran. */
export async function refuseRuns(events, app) {
for (const event of events) await app.report(event.run, { state: 'blocked', reason: 'checkins_off' });
return events.length;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |