Skip to content

matthewwong525/WongStack / .agents/plugins/memory

memory

Verified

FileKindSize
README.mdmarkdown4.7 KB
SKILL.mdskill md5.8 KB
VERSIONother6 B
hooks/claude.jsonconfig957 B
hooks/codex.jsonconfig692 B
references/placing-facts.mdmarkdown2.1 KB
references/recall-helper.mdmarkdown814 B
references/setup.mdmarkdown7.0 KB
references/tidy.mdmarkdown4.4 KB
references/writing-facts.mdmarkdown2.0 KB
scripts/before-edit.mjsscript2.5 KB
scripts/daily-tidy.mjsscript22.1 KB
scripts/lib/areas.mjsscript3.9 KB
scripts/lib/brief.mjsscript2.3 KB
scripts/lib/cli.mjsscript1.2 KB
scripts/lib/daily.mjsscript1.6 KB
scripts/lib/digest.mjsscript11.9 KB
scripts/lib/documents/commands.mjsscript5.7 KB
scripts/lib/documents/corpus.mjsscript6.8 KB
scripts/lib/documents/input.mjsscript2.4 KB
scripts/lib/documents/lexical.mjsscript4.5 KB
scripts/lib/documents/packet.mjsscript10.2 KB
scripts/lib/documents/retrieve.mjsscript1.9 KB
scripts/lib/files.mjsscript3.7 KB
scripts/lib/headless.mjsscript1.5 KB
scripts/lib/knowledge-copy.mjsscript469 B
scripts/lib/machine-id.mjsscript1.9 KB
scripts/lib/primary-root.mjsexecutablescript1.9 KB
scripts/lib/pull.mjsscript27.0 KB
scripts/lib/read-facts.mjsscript1.7 KB
scripts/lib/read-options.mjsscript3.0 KB
scripts/lib/scan.mjsscript2.0 KB
scripts/lib/store.mjsscript7.7 KB
scripts/lib/topics.mjsscript4.6 KB
scripts/lib/transcripts.mjsscript9.6 KB
scripts/lib/upkeep.mjsscript4.0 KB
scripts/lib/usage.mjsscript5.2 KB
scripts/memory.mjsscript45.7 KB
scripts/run.mjsscript20.4 KB
scripts/session-end.mjsscript1.7 KB
scripts/session-start.mjsscript4.6 KB
scripts/topic-match.mjsscript2.1 KB
store/contract.mjsscript14.6 KB
store/interface.d.mtsother2.9 KB
store/interface.mjsscript6.7 KB

scripts/lib/upkeep.mjs

View on GitHub
// Upkeep: tidying that needs no judgment, decided in plain code after every write and background run: stale threads
// closed, tags added, topic tags kept equal to the profile's topics. memory.mjs reads and writes; this only decides.
import { areasOf } from './areas.mjs';

// Restates per pass: the rest wait for the next write, so one batch stays within the route's limits.
export const UPKEEP_CAP = 50;
export const STALE_DAYS = 30;
const MAX_BODY = 400;

// A slash command in a thread names the step whose next run should check it: the profile's `steps` map.
const escape = text => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
function slashSteps(steps = {}) {
  const stepOf = new Map(Object.entries(steps).flatMap(([step, commands]) => commands.map(command => [command, step])));
  const names = [...stepOf.keys()].sort((a, b) => b.length - a.length).map(escape).join('|');
  return { stepOf, pattern: names && new RegExp(`(?<![\\w/.-])(${names})(?![\\w-])`, 'g') };
}

// Words that look like a path: a `/` or a file extension, with quotes, brackets, and end punctuation dropped.
export const pathWords = body => body.split(/[\s`"'()<>[\]{},;]+/).map(word => word.replace(/[.:!?]+$/, ''))
  .filter(word => word.includes('/') || /\.[a-z0-9]+$/i.test(word));

// The topic tags a fact's words name, and for a thread, the step tags its slash commands name.
export function wordTags(fact, areas, root, steps) {
  const tags = new Set(pathWords(fact.body).flatMap(word => areasOf(word, areas, root)));
  const { stepOf, pattern } = slashSteps(steps);
  if (fact.type === 'thread' && pattern) for (const [, command] of fact.body.matchAll(pattern)) tags.add(stepOf.get(command));
  return [...tags];
}

// The fact that closes a stale thread, cut at a word boundary to fit.
export function closingBody(thread) {
  const text = `Closed unchecked after ${STALE_DAYS} days (thread #${thread.id}, ${thread.created_at.slice(0, 10)}): ${thread.body}`;
  return text.length <= MAX_BODY ? text : `${text.slice(0, MAX_BODY - 1).replace(/\s+\S*$/, '')}…`;
}

// The defineTag calls that set each topic tag's definition and aliases to the profile's. A listed alias the store
// lacks is skipped; one that other tags point at is skipped too, so aliases stay one level deep.
export function tagSync(tagRows, areas) {
  const byName = new Map(tagRows.map(row => [row.name, row]));
  const calls = [];
  for (const [name, area] of Object.entries(areas)) {
    const tag = byName.get(name);
    const aliases = (area.aliases || []).map(alias => byName.get(alias))
      .filter(row => row && row.alias_of !== name && !tagRows.some(other => other.alias_of === row.name));
    if ((tag && tag.definition !== area.definition) || (aliases.length && !tag)) calls.push({ name, definition: area.definition, aliasOf: tag?.alias_of ?? null });
    for (const row of aliases) calls.push({ name: row.name, definition: row.definition, aliasOf: name });
  }
  return calls;
}

// What one pass does, from the live facts the key may change (each with its `tags`): the threads to close,
// oldest first, then the re-tags, together at most UPKEEP_CAP.
export function upkeepPlan(facts, tagRows, { areas, root, steps, now = Date.now() }) {
  const cutoff = new Date(now - STALE_DAYS * 86400000).toISOString().replace(/\.\d{3}Z$/, 'Z');
  const close = facts.filter(fact => fact.type === 'thread' && fact.created_at <= cutoff)
    .sort((a, b) => a.created_at.localeCompare(b.created_at)).slice(0, UPKEEP_CAP);
  const aliasOf = new Map([...tagRows.map(row => [row.name, row.alias_of]),
    ...Object.entries(areas).flatMap(([name, area]) => (area.aliases || []).map(alias => [alias, name]))]);
  const retag = [];
  for (const fact of facts) {
    if (close.length + retag.length >= UPKEEP_CAP) break;
    if (close.includes(fact)) continue;
    const has = new Set(fact.tags.flatMap(tag => [tag, aliasOf.get(tag)]));
    const adds = wordTags(fact, areas, root, steps).filter(tag => !has.has(tag));
    if (adds.length) retag.push({ id: fact.id, tags: adds });
  }
  return { close, retag };
}
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall