@r_masseater/msch 0.91.1 → 0.91.2

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
@@ -252,6 +252,9 @@ const PluginManifest$1 = Schema.fromJsonString(Schema.Struct({
252
252
  version: Schema.optionalKey(Schema.Unknown)
253
253
  }));
254
254
  const decodeManifest = Schema.decodeUnknownOption(PluginManifest$1);
255
+ const PACKAGE_FILE = "package.json";
256
+ const PackageVersion = Schema.fromJsonString(Schema.Struct({ version: Schema.optionalKey(Schema.String) }));
257
+ const decodePackageVersion = Schema.decodeUnknownOption(PackageVersion);
255
258
  const bySkillName = Order.mapInput(String$1.Order, ({ name }) => name);
256
259
  const skillIn = Effect.fn("skillIn")(function* skillIn(scan, { plugin, skills }, name) {
257
260
  const files = yield* RepositoryFiles;
@@ -284,12 +287,18 @@ const skillsOf = Effect.fn("skillsOf")(function* skillsOf(scan, plugin, director
284
287
  }, entry), { concurrency: CONCURRENCY$4 });
285
288
  return Array$1.sort(Array$1.getSomes(found), bySkillName);
286
289
  });
287
- const pluginAt = Effect.fn("pluginAt")(function* pluginAt(scan, directory) {
290
+ const packageVersionAt = Effect.fn("packageVersionAt")(function* packageVersionAt(directory) {
291
+ const files = yield* RepositoryFiles;
292
+ const text = yield* files.readFile(files.join(directory, PACKAGE_FILE));
293
+ return pipe(text, Option.flatMap(decodePackageVersion), Option.flatMapNullishOr(({ version }) => version));
294
+ });
295
+ const pluginAt = Effect.fn("pluginAt")(function* pluginAt(scan, { directory, published }) {
288
296
  const files = yield* RepositoryFiles;
289
297
  const manifest = yield* files.readFile(files.join(directory, PLUGIN_FILE$3));
290
298
  const decoded = pipe(manifest, Option.flatMap(decodeManifest));
291
299
  if (Option.isNone(decoded)) return Option.none();
292
300
  const { name } = decoded.value;
301
+ const packageVersion = yield* packageVersionAt(directory);
293
302
  const inside = yield* filesUnder(scan, directory);
294
303
  const skills = yield* skillsOf(scan, name, directory);
295
304
  return Option.some({
@@ -297,6 +306,8 @@ const pluginAt = Effect.fn("pluginAt")(function* pluginAt(scan, directory) {
297
306
  directory,
298
307
  description: Option.fromUndefinedOr(decoded.value.description),
299
308
  versioned: "version" in decoded.value,
309
+ published,
310
+ matchesPackageVersion: Option.contains(packageVersion, decoded.value.version),
300
311
  files: inside,
301
312
  skills
302
313
  });
@@ -306,10 +317,13 @@ const pluginsIn$1 = Effect.fn("pluginsIn")(function* pluginsIn(root) {
306
317
  const files = yield* RepositoryFiles;
307
318
  const projects = yield* workspaceProjects(root);
308
319
  const listed = yield* files.listedFiles(root);
309
- const found = yield* Effect.forEach(projects, ({ directory }) => pluginAt({
320
+ const found = yield* Effect.forEach(projects, ({ directory, published }) => pluginAt({
310
321
  root,
311
322
  listed
312
- }, files.join(root, directory)), { concurrency: CONCURRENCY$4 });
323
+ }, {
324
+ directory: files.join(root, directory),
325
+ published
326
+ }), { concurrency: CONCURRENCY$4 });
313
327
  return Array$1.getSomes(found);
314
328
  });
315
329
  const HYPHENATED = "-";
@@ -13626,13 +13640,13 @@ const checkMigrationOrder = Effect.fn("checkMigrationOrder")(function* checkMigr
13626
13640
  // src/shared/lib/bundle-error.ts
13627
13641
  const ERROR_LINE = /\[[A-Z_]+\]/u;
13628
13642
  const SHOWN_ERRORS = 3;
13629
- const HEADER$1 = "Build failed";
13643
+ const HEADER = "Build failed";
13630
13644
  const NO_DETAIL = "Run the bundle to see the error.";
13631
13645
  const linesOf = (error) => pipe(Option.liftPredicate(error, Predicate.isError), Option.map(({ message }) => message), Option.getOrElse(() => String(error)), stripVTControlCharacters, String$1.split("\n"), Array$1.map(String$1.trim), Array$1.filter(String$1.isNonEmpty));
13632
13646
  const bundleErrorDetail = (error) => {
13633
13647
  const lines = linesOf(error);
13634
13648
  return pipe(lines, Array$1.filter((line) => ERROR_LINE.test(line)), Array$1.take(SHOWN_ERRORS), Array$1.match({
13635
- onEmpty: () => pipe(lines, Array$1.findFirst((line) => !String$1.startsWith(HEADER$1)(line)), Option.getOrElse(() => NO_DETAIL)),
13649
+ onEmpty: () => pipe(lines, Array$1.findFirst((line) => !String$1.startsWith(HEADER)(line)), Option.getOrElse(() => NO_DETAIL)),
13636
13650
  onNonEmpty: Array$1.join(" ")
13637
13651
  }));
13638
13652
  };
@@ -17830,12 +17844,16 @@ const violation = (path, message) => ({
17830
17844
  });
17831
17845
  const when = (path, message, broken) => Option.liftPredicate(violation(path, message), () => broken);
17832
17846
  const VERSIONED = "sets version. Leave it out so that every commit reaches installed copies.";
17847
+ const UNVERSIONED = "sets no version. A plugin installed from npm has the version unknown without it, so set the version of the package.";
17848
+ const STALE_VERSION = "sets a version other than the one in package.json. Claude Code keeps installed copies on the manifest's version, so set the version of the package.";
17833
17849
  const WORDY = `has a description longer than ${String(LONGEST_DESCRIPTION)} characters.`;
17834
17850
  const manifestViolations = (plugin) => {
17835
17851
  const wordy = Option.exists(plugin.description, (text) => text.length > LONGEST_DESCRIPTION);
17836
17852
  const named = `names the plugin ${plugin.name}, which is not 1 to 64 lowercase letters, digits or hyphens.`;
17837
17853
  return pipe([
17838
- when(PLUGIN_FILE$1, VERSIONED, plugin.versioned),
17854
+ when(PLUGIN_FILE$1, VERSIONED, plugin.versioned && !plugin.published),
17855
+ when(PLUGIN_FILE$1, UNVERSIONED, plugin.published && !plugin.versioned),
17856
+ when(PLUGIN_FILE$1, STALE_VERSION, plugin.published && plugin.versioned && !plugin.matchesPackageVersion),
17839
17857
  when(PLUGIN_FILE$1, named, !PLUGIN_NAME.test(plugin.name)),
17840
17858
  when(PLUGIN_FILE$1, WORDY, wordy)
17841
17859
  ], Array$1.getSomes);
@@ -18019,7 +18037,15 @@ const FIRST_SENTENCE = /^[\s\S]*?(?:。|\.(?=\s|$))/u;
18019
18037
  const CALLED_SKILL$1 = /`(?<name>[a-z0-9-]+:[a-z0-9-]+)`/u;
18020
18038
  const EMPTY = "";
18021
18039
  const START$1 = 0;
18022
- const HEADER = ["| 呼び出し | 使う場面 | 本体のスキル |", "| --- | --- | --- |"];
18040
+ const DIVIDER = "| --- | --- | --- |";
18041
+ const JAPANESE_LABELS = {
18042
+ heading: "## スキル",
18043
+ header: "| 呼び出し | 使う場面 | 本体のスキル |"
18044
+ };
18045
+ const ENGLISH_LABELS = {
18046
+ heading: "## Skills",
18047
+ header: "| Command | When to use | Skill it runs |"
18048
+ };
18023
18049
  const SkillFields = Schema.Struct({
18024
18050
  description: Schema.optionalKey(Schema.String),
18025
18051
  "argument-hint": Schema.optionalKey(Schema.String),
@@ -18039,22 +18065,30 @@ const rowOf = ({ plugin, name, frontmatter }) => pipe(decodeFields(frontmatter.f
18039
18065
  const scene = sceneOf(String$1.trim(fields.description ?? EMPTY));
18040
18066
  return `| ${cell(`\`${call}\``)} | ${cell(scene)} | ${targetOf(fields, frontmatter.body)} |`;
18041
18067
  }));
18042
- const skillsTable = (skills) => pipe(skills, Array$1.map(rowOf), Array$1.getSomes, (rows) => [...HEADER, ...rows], Array$1.join("\n"));
18043
- const withSkillsTable = (readme, table) => {
18068
+ const skillsTable = (skills, { header }) => pipe(skills, Array$1.map(rowOf), Array$1.getSomes, (rows) => [
18069
+ header,
18070
+ DIVIDER,
18071
+ ...rows
18072
+ ], Array$1.join("\n"));
18073
+ const withSkillsTable = ({ readme, table, heading }) => {
18044
18074
  const block = `${SKILLS_START}\n${table}\n${SKILLS_END}`;
18045
18075
  const start = String$1.indexOf(SKILLS_START)(readme);
18046
18076
  const end = String$1.indexOf(SKILLS_END)(readme);
18047
18077
  return pipe(Option.all([start, end]), Option.filter(([from, to]) => to > from), Option.match({
18048
- onNone: () => `${String$1.trimEnd(readme)}\n\n## スキル\n\n${block}\n`,
18078
+ onNone: () => `${String$1.trimEnd(readme)}\n\n${heading}\n\n${block}\n`,
18049
18079
  onSome: ([from, to]) => `${String$1.slice(START$1, from)(readme)}${block}${String$1.slice(to + 26)(readme)}`
18050
18080
  }));
18051
18081
  };
18052
- const syncReadme = Effect.fn("syncReadme")(function* syncReadme({ directory, skills }) {
18082
+ const syncReadme = Effect.fn("syncReadme")(function* syncReadme({ directory, skills }, labels) {
18053
18083
  const files = yield* RepositoryFiles;
18054
18084
  const file = files.join(directory, README_FILE);
18055
18085
  const text = yield* files.readFile(file);
18056
18086
  const current = Option.getOrElse(text, () => EMPTY);
18057
- const expected = withSkillsTable(current, skillsTable(skills));
18087
+ const expected = withSkillsTable({
18088
+ readme: current,
18089
+ table: skillsTable(skills, labels),
18090
+ heading: labels.heading
18091
+ });
18058
18092
  if (expected === current) return [];
18059
18093
  yield* files.writeFile(file, expected);
18060
18094
  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.`)];
@@ -18062,8 +18096,11 @@ const syncReadme = Effect.fn("syncReadme")(function* syncReadme({ directory, ski
18062
18096
  /** @internal */
18063
18097
  const checkReadmeSkills = Effect.fn("checkReadmeSkills")(function* checkReadmeSkills(root) {
18064
18098
  const plugins = yield* pluginsIn$1(root);
18099
+ const { publishRegistry } = yield* ownerSettings(root);
18100
+ const english = isPublicRegistry(publishRegistry);
18101
+ const labelsOf = ({ published }) => pipe(Option.liftPredicate(ENGLISH_LABELS, () => published && english), Option.getOrElse(() => JAPANESE_LABELS));
18065
18102
  const withSkills = pipe(plugins, Array$1.filter(({ skills }) => Array$1.isReadonlyArrayNonEmpty(skills)));
18066
- const found = yield* Effect.forEach(withSkills, syncReadme, { concurrency: "unbounded" });
18103
+ const found = yield* Effect.forEach(withSkills, (plugin) => syncReadme(plugin, labelsOf(plugin)), { concurrency: "unbounded" });
18067
18104
  return Array$1.flatten(found);
18068
18105
  });
18069
18106
  // src/features/check-skill-enumerations/model/enumeration-signals.ts