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/files.mjs

View on GitHub
// The files behind facts: what each fact's change touched, the paths a fact names, and its topic's docs and folders,
// merged and ranked on each read. Nothing is stored. wiki/development/document-retrieval.md#files-behind-the-facts
import { existsSync } from 'node:fs';
import { join } from 'node:path';
import { areaDocs, normalizePath, realPath } from './areas.mjs';
import { pathWords } from './upkeep.mjs';

export const FILES_LIMIT = 8;
export const PER_CHANGE = 10;
const NAMED = 1.5;
const TOPIC = 0.5;
const VIA = ['named', 'change', 'topic'];

// The repo paths a fact's words name that exist now, without a `#anchor` or `:line` suffix.
export function namedPaths(body, root) {
  const found = pathWords(String(body ?? '')).map(word => normalizePath(word.replace(/[#:].*$/, ''), root))
    .map(path => path && !path.startsWith('..') && realPath(path, root)).filter(Boolean);
  return [...new Set(found)];
}

// The lookup's answer, or an empty map and `unavailable` when it throws or misses its deadline.
async function changeFiles(ctx, profile, slugs, deadline) {
  if (!slugs.length || !profile?.lookup?.files) return { bySlug: new Map(), state: 'ok' };
  let timer;
  const late = new Promise(resolve => { timer = setTimeout(resolve, Math.max(0, deadline - Date.now()), null); });
  try {
    const found = await Promise.race([Promise.resolve().then(() => profile.lookup.files(ctx, slugs, { deadline })), late]);
    return found instanceof Map ? { bySlug: found, state: 'ok' } : { bySlug: new Map(), state: 'unavailable' };
  } catch { return { bySlug: new Map(), state: 'unavailable' }; } finally { clearTimeout(timer); }
}

// A topic's docs, then its code folders that exist.
const topicPaths = (tags, areas, root) => [...areaDocs(tags, areas, root),
  ...tags.flatMap(tag => (areas[tag]?.paths || []).filter(path => path.endsWith('/') && existsSync(join(root, path))))];

/** The ranked files behind `facts`, in their order: `{ files: [{ path, facts, via }], state }`. A change adds
 *  1 / (1 + i/4) to each of its top files, i the rank of its first fact; a named path 1.5; a topic path 0.5. */
export async function filesBehind(ctx, facts, { profile, areas = {}, limit = FILES_LIMIT, perChange = PER_CHANGE, deadline = Date.now() + 1500 } = {}) {
  const slugs = [...new Set(facts.map(fact => fact.slug).filter(Boolean))];
  const { bySlug, state } = await changeFiles(ctx, profile, slugs, deadline);
  const scores = new Map();
  const add = (path, weight, ids, via) => {
    const entry = scores.get(path) ?? scores.set(path, { path, weight: 0, facts: new Set(), via }).get(path);
    entry.weight += weight;
    ids.forEach(id => entry.facts.add(id));
    if (VIA.indexOf(via) < VIA.indexOf(entry.via)) entry.via = via;
  };
  const counted = new Set();
  facts.forEach((fact, i) => {
    const touched = (bySlug.get(fact.slug) ?? []).slice().sort((a, b) => (b.churn || 0) - (a.churn || 0)).slice(0, perChange);
    const named = namedPaths(fact.body, ctx.root);
    if (touched.length && !counted.has(fact.slug)) {
      counted.add(fact.slug);
      const ids = facts.filter(each => each.slug === fact.slug).map(each => each.id);
      for (const { path } of touched) add(path, 1 / (1 + i / 4), ids, 'change');
    }
    for (const path of named) add(path, NAMED, [fact.id], 'named');
    if (!touched.length && !named.length) for (const path of topicPaths(fact.tags || [], areas, ctx.root)) add(path, TOPIC, [fact.id], 'topic');
  });
  const files = [...scores.values()].sort((a, b) => b.weight - a.weight || a.path.localeCompare(b.path)).slice(0, limit)
    .map(({ path, facts: ids, via }) => ({ path, facts: [...ids], via }));
  return { files, state: state === 'unavailable' ? state : files.length ? 'ok' : 'empty' };
}
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