Skip to content

mex-memory/mex / skills/mex-statechart

mex-statechart

Verified

Explain complicated existing behavior using checked state diagrams. Use when asked for a state diagram, to diagram the previous explanation, show a bug or recovery path, compare a proposed fix or existing TLA+ spec, or derive a model from an agreed chart. Generates native Mermaid and a readable terminal fallback; optionally view and explicitly save in MEX Hub.

upstream/scripts/snapshot.mjs

View on GitHub
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import process from "node:process";

const imports = (text, dir) =>
  [...text.matchAll(/\b(?:from|import)\s*\(?\s*["'](\.{1,2}\/[^"']+)["']/g)].map((m) =>
    path.resolve(dir, m[1]),
  );

const DEPENDENCIES = {
  ".tla": (text, dir) =>
    [
      ...text
        .replace(/\(\*[^]*?\*\)/g, " ")
        .replace(/\\\*.*/g, " ")
        .matchAll(/\b(?:EXTENDS|INSTANCE)\s+(\w+(?:\s*,\s*\w+)*)/g),
    ].flatMap((m) => m[1].split(/\s*,\s*/).map((name) => path.join(dir, `${name}.tla`))),
  ".mjs": imports,
  ".js": imports,
};

export const copyPath = (root, file, paths = path) => {
  const absolute = paths.resolve(file);
  const pathRoot = paths.parse(absolute).root;
  return paths.join(root, pathRoot.replace(/\W+/g, ""), paths.relative(pathRoot, absolute));
};

const contentOf = (file) => {
  try {
    return fs.readFileSync(file, "base64");
  } catch {
    return null;
  }
};

export class Inputs {
  #root = fs.mkdtempSync(path.join(os.tmpdir(), "statechart-inputs-"));
  #files = new Set();

  constructor() {
    process.on("exit", () => fs.rmSync(this.#root, { recursive: true, force: true }));
  }

  add(files) {
    for (const file of files) if (file) this.#take(path.resolve(file), true);
    return this;
  }

  copyOf(file) {
    return copyPath(this.#root, file);
  }

  changed() {
    return [...this.#files].find((file) => contentOf(file) !== contentOf(this.copyOf(file)));
  }

  #take(file, listed) {
    if (this.#files.has(file)) return;
    let content;
    try {
      content = fs.readFileSync(file);
    } catch {
      if (listed) this.#files.add(file);
      return;
    }
    this.#files.add(file);
    const copy = this.copyOf(file);
    fs.mkdirSync(path.dirname(copy), { recursive: true });
    fs.writeFileSync(copy, content);
    const found = DEPENDENCIES[path.extname(file)]?.(content.toString("utf8"), path.dirname(file));
    for (const dependency of found ?? []) this.#take(dependency, false);
  }
}

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: 197kUpdated 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