matthewwong525/WongStack / .agents/plugins/memory
memory
Verifiedscripts/lib/daily.mjs
View on GitHub// The daily tidy's local side: this computer's switch and its last try, in daily.json. The day is this computer's.
// wiki/development/wiki-dream.md
import { join } from 'node:path';
import { readJson, statePath, writeJson } from './store.mjs';
export const DAILY_FILE = 'daily.json';
/** Today as YYYY-MM-DD in this computer's time zone. */
export const today = (now = new Date()) => new Intl.DateTimeFormat('en-CA', { year: 'numeric', month: '2-digit', day: '2-digit' }).format(now);
export const readDaily = ctx => readJson(join(ctx.stateDir, DAILY_FILE), {});
export function setDaily(ctx, change) {
const file = statePath(ctx, DAILY_FILE);
writeJson(file, { ...readJson(file, {}), ...change });
}
/** Why this chat start starts no daily tidy, or null when it should: `digest` is loadDigest's answer or `{ error }`. */
export function dailyBlocker({ env = process.env, state, digest, day }) {
if (env.WONG_MEMORY_RUN === '1') return 'a background run';
if (env.WONG_MEMORY_NO_HEADLESS === '1') return 'no headless runs';
if (state.off) return 'off on this computer';
if (state.tried === day) return 'tried today';
if (!digest || digest.error || digest.older) return 'the store can not claim a day';
if (digest.daily?.day === day) return 'done today';
return null;
}
/** Starts the day's tidy when none blocks it, `tried` written first so a second chat starts none; true when started. */
export function startDaily(ctx, digest, { start, env = process.env, now = new Date() }) {
const day = today(now);
if (dailyBlocker({ env, state: readDaily(ctx), digest, day })) return false;
setDaily(ctx, { tried: day });
return start();
}
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: 194k | 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: 194k | 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: 194k | Updated | Claude CodeCodex | Verified | Install |