mex-memory/mex / skills/mex-statechart
mex-statechart
VerifiedExplain 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/compare-charts.mjs
View on GitHub#!/usr/bin/env node
import fs from "node:fs";
import process from "node:process";
import { FULL_LABELS, LEGEND_ID, NO_LOOPS, compareCharts, parseMermaid } from "./lib.mjs";
const USAGE = "Usage: node compare-charts.mjs EXPECTED.mmd ACTUAL.mmd";
const files = [];
for (const a of process.argv.slice(2)) {
if (a.startsWith("-") || files.length === 2) {
console.error(`unknown argument ${a}.`);
process.exit(2);
} else files.push(a);
}
if (files.length < 2) {
console.error(USAGE);
process.exit(2);
}
const [expectedFile, actualFile] = files;
const orExit = (file, f) => {
try {
return f();
} catch (e) {
console.error(`${file}: ${e.message}`);
process.exit(2);
}
};
const [expectedText, actualText] = files.map((f) => orExit(f, () => fs.readFileSync(f, "utf8")));
const has = (re) => re.test(actualText);
const textRefusals = [
[
has(/^\s*%% second model/m),
"it has a second model; draw ACTUAL without --fixed-dot or --against-dot",
],
[
has(new RegExp(`^\\s*state\\s+"[^"]*"\\s+as\\s+(?!${LEGEND_ID}\\b)\\w+\\s*\\{`, "m")),
"it has boxes; draw ACTUAL with --flat",
],
[
has(new RegExp(`^\\s*state\\s+"[^"]*"\\s+as\\s+${LEGEND_ID}\\s*\\{`, "m")) &&
!actualText.includes(FULL_LABELS),
"edge labels write shared words once; draw ACTUAL with --full-labels",
],
];
for (const [bad, why] of textRefusals) {
if (bad) {
console.error(`${actualFile}: ${why}`);
process.exit(2);
}
}
const expectedRegions = orExit(expectedFile, () => parseMermaid(expectedText).regions);
const actualRegions = orExit(actualFile, () => parseMermaid(actualText).regions);
const numbered = Object.values(actualRegions)
.flatMap((r) => r.transitions)
.some((t) => /^\d+(, \d+)*\. /.test(t.label));
if (numbered) {
console.error(
`${actualFile}: an edge label is a numbered path step; draw ACTUAL with --highlight 0`,
);
process.exit(2);
}
const rows = compareCharts(expectedRegions, actualRegions, {
loops: !actualText.includes(NO_LOOPS),
});
let differences = 0;
for (const [title, xs] of rows) {
console.log(`${title}:`);
for (const x of xs) console.log(` ${x}`);
differences += xs.length;
}
console.log(differences === 0 ? "same" : `${differences} difference(s)`);
process.exit(differences === 0 ? 0 : 1);
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: 197k | 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 |