@r_masseater/msch 0.91.3 → 0.91.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -18039,6 +18039,9 @@ const CALLED_SKILL$1 = /`(?<name>[a-z0-9-]+:[a-z0-9-]+)`/u;
18039
18039
  const EMPTY = "";
18040
18040
  const START$1 = 0;
18041
18041
  const DIVIDER = "| --- | --- | --- |";
18042
+ const CELL_BORDER = /(?<!\\)\|/u;
18043
+ const DIVIDER_CELL = /^:?-+:?$/u;
18044
+ const TABLE_ROW = /^\|.*\|$/u;
18042
18045
  const JAPANESE_LABELS = {
18043
18046
  heading: "## スキル",
18044
18047
  header: "| 呼び出し | 使う場面 | 本体のスキル |"
@@ -18071,8 +18074,19 @@ const skillsTable = (skills, { header }) => pipe(skills, Array$1.map(rowOf), Arr
18071
18074
  DIVIDER,
18072
18075
  ...rows
18073
18076
  ], Array$1.join("\n"));
18077
+ const canonicalRow = (line) => pipe(String$1.split(CELL_BORDER)(line), Array$1.map(String$1.trim), Array$1.map(String$1.replace(DIVIDER_CELL, "---")), Array$1.join("|"));
18078
+ const canonicalLine = (inside, line) => {
18079
+ const trimmed = String$1.trim(line);
18080
+ if (!inside) return Option.some(line);
18081
+ if (String$1.isEmpty(trimmed)) return Option.none();
18082
+ if (TABLE_ROW.test(trimmed)) return Option.some(canonicalRow(trimmed));
18083
+ return Option.some(line);
18084
+ };
18085
+ const canonical = (readme) => pipe(String$1.split("\n")(readme), Array$1.mapAccum(false, (inside, line) => {
18086
+ return [(inside || String$1.includes("<!-- skills:generated -->")(line)) && !String$1.includes("<!-- /skills:generated -->")(line), canonicalLine(inside, line)];
18087
+ }), ([, lines]) => Array$1.getSomes(lines), Array$1.join("\n"));
18074
18088
  const withSkillsTable = ({ readme, table, heading }) => {
18075
- const block = `${SKILLS_START}\n${table}\n${SKILLS_END}`;
18089
+ const block = `${SKILLS_START}\n\n${table}\n\n${SKILLS_END}`;
18076
18090
  const start = String$1.indexOf(SKILLS_START)(readme);
18077
18091
  const end = String$1.indexOf(SKILLS_END)(readme);
18078
18092
  return pipe(Option.all([start, end]), Option.filter(([from, to]) => to > from), Option.match({
@@ -18090,7 +18104,7 @@ const syncReadme = Effect.fn("syncReadme")(function* syncReadme({ directory, ski
18090
18104
  table: skillsTable(skills, labels),
18091
18105
  heading: labels.heading
18092
18106
  });
18093
- if (expected === current) return [];
18107
+ if (canonical(expected) === canonical(current)) return [];
18094
18108
  yield* files.writeFile(file, expected);
18095
18109
  return [problem$2(file, `The skills table between ${SKILLS_START} and ${SKILLS_END} is generated from the SKILL.md frontmatter of the plugin. msch rewrote it; commit the result.`)];
18096
18110
  });