@r_masseater/msch 0.91.1 → 0.91.3

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
  };
@@ -13676,6 +13690,7 @@ const hasDependencies = Effect.fn("hasDependencies")(function* hasDependencies(d
13676
13690
  return pipe(text, Option.flatMap(decodePackageJson), Option.flatMapNullishOr(({ dependencies }) => dependencies), Option.exists((dependencies) => !Record.isEmptyRecord(dependencies)));
13677
13691
  });
13678
13692
  const shipsDependencies = Effect.fn("shipsDependencies")(function* shipsDependencies(root, project) {
13693
+ if (project.published) return false;
13679
13694
  const files = yield* RepositoryFiles;
13680
13695
  const directory = files.join(root, project.directory);
13681
13696
  if (!(yield* files.exists(files.join(directory, PLUGIN_FILE$2)))) return false;
@@ -16587,8 +16602,8 @@ const problemsIn$11 = (entry, source) => pipe(manifestSpecifiers(source), Array$
16587
16602
  /** @internal */
16588
16603
  const uncatalogedDependencies = Effect.fn("uncatalogedDependencies")(function* uncatalogedDependencies(root) {
16589
16604
  const files = yield* RepositoryFiles;
16590
- const directories = yield* workspaceDirectories(root);
16591
- const installed = yield* pipe(directories, Effect.filter((directory) => files.exists(files.join(root, directory, PLUGIN_MANIFEST$1)).pipe(Effect.map((found) => !found))));
16605
+ const projects = yield* workspaceProjects(root);
16606
+ const installed = yield* pipe(projects, Effect.filter(({ directory, published }) => files.exists(files.join(root, directory, PLUGIN_MANIFEST$1)).pipe(Effect.map((found) => published || !found))), Effect.map(Array$1.map(({ directory }) => directory)));
16592
16607
  const listed = pipe([ROOT_DIRECTORY$2, ...installed], Array$1.map((directory) => {
16593
16608
  const name = files.join(directory, PACKAGE_JSON_FILE);
16594
16609
  return {
@@ -17830,12 +17845,16 @@ const violation = (path, message) => ({
17830
17845
  });
17831
17846
  const when = (path, message, broken) => Option.liftPredicate(violation(path, message), () => broken);
17832
17847
  const VERSIONED = "sets version. Leave it out so that every commit reaches installed copies.";
17848
+ const UNVERSIONED = "sets no version. A plugin installed from npm has the version unknown without it, so set the version of the package.";
17849
+ 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
17850
  const WORDY = `has a description longer than ${String(LONGEST_DESCRIPTION)} characters.`;
17834
17851
  const manifestViolations = (plugin) => {
17835
17852
  const wordy = Option.exists(plugin.description, (text) => text.length > LONGEST_DESCRIPTION);
17836
17853
  const named = `names the plugin ${plugin.name}, which is not 1 to 64 lowercase letters, digits or hyphens.`;
17837
17854
  return pipe([
17838
- when(PLUGIN_FILE$1, VERSIONED, plugin.versioned),
17855
+ when(PLUGIN_FILE$1, VERSIONED, plugin.versioned && !plugin.published),
17856
+ when(PLUGIN_FILE$1, UNVERSIONED, plugin.published && !plugin.versioned),
17857
+ when(PLUGIN_FILE$1, STALE_VERSION, plugin.published && plugin.versioned && !plugin.matchesPackageVersion),
17839
17858
  when(PLUGIN_FILE$1, named, !PLUGIN_NAME.test(plugin.name)),
17840
17859
  when(PLUGIN_FILE$1, WORDY, wordy)
17841
17860
  ], Array$1.getSomes);
@@ -18019,7 +18038,15 @@ const FIRST_SENTENCE = /^[\s\S]*?(?:。|\.(?=\s|$))/u;
18019
18038
  const CALLED_SKILL$1 = /`(?<name>[a-z0-9-]+:[a-z0-9-]+)`/u;
18020
18039
  const EMPTY = "";
18021
18040
  const START$1 = 0;
18022
- const HEADER = ["| 呼び出し | 使う場面 | 本体のスキル |", "| --- | --- | --- |"];
18041
+ const DIVIDER = "| --- | --- | --- |";
18042
+ const JAPANESE_LABELS = {
18043
+ heading: "## スキル",
18044
+ header: "| 呼び出し | 使う場面 | 本体のスキル |"
18045
+ };
18046
+ const ENGLISH_LABELS = {
18047
+ heading: "## Skills",
18048
+ header: "| Command | When to use | Skill it runs |"
18049
+ };
18023
18050
  const SkillFields = Schema.Struct({
18024
18051
  description: Schema.optionalKey(Schema.String),
18025
18052
  "argument-hint": Schema.optionalKey(Schema.String),
@@ -18039,22 +18066,30 @@ const rowOf = ({ plugin, name, frontmatter }) => pipe(decodeFields(frontmatter.f
18039
18066
  const scene = sceneOf(String$1.trim(fields.description ?? EMPTY));
18040
18067
  return `| ${cell(`\`${call}\``)} | ${cell(scene)} | ${targetOf(fields, frontmatter.body)} |`;
18041
18068
  }));
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) => {
18069
+ const skillsTable = (skills, { header }) => pipe(skills, Array$1.map(rowOf), Array$1.getSomes, (rows) => [
18070
+ header,
18071
+ DIVIDER,
18072
+ ...rows
18073
+ ], Array$1.join("\n"));
18074
+ const withSkillsTable = ({ readme, table, heading }) => {
18044
18075
  const block = `${SKILLS_START}\n${table}\n${SKILLS_END}`;
18045
18076
  const start = String$1.indexOf(SKILLS_START)(readme);
18046
18077
  const end = String$1.indexOf(SKILLS_END)(readme);
18047
18078
  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`,
18079
+ onNone: () => `${String$1.trimEnd(readme)}\n\n${heading}\n\n${block}\n`,
18049
18080
  onSome: ([from, to]) => `${String$1.slice(START$1, from)(readme)}${block}${String$1.slice(to + 26)(readme)}`
18050
18081
  }));
18051
18082
  };
18052
- const syncReadme = Effect.fn("syncReadme")(function* syncReadme({ directory, skills }) {
18083
+ const syncReadme = Effect.fn("syncReadme")(function* syncReadme({ directory, skills }, labels) {
18053
18084
  const files = yield* RepositoryFiles;
18054
18085
  const file = files.join(directory, README_FILE);
18055
18086
  const text = yield* files.readFile(file);
18056
18087
  const current = Option.getOrElse(text, () => EMPTY);
18057
- const expected = withSkillsTable(current, skillsTable(skills));
18088
+ const expected = withSkillsTable({
18089
+ readme: current,
18090
+ table: skillsTable(skills, labels),
18091
+ heading: labels.heading
18092
+ });
18058
18093
  if (expected === current) return [];
18059
18094
  yield* files.writeFile(file, expected);
18060
18095
  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 +18097,11 @@ const syncReadme = Effect.fn("syncReadme")(function* syncReadme({ directory, ski
18062
18097
  /** @internal */
18063
18098
  const checkReadmeSkills = Effect.fn("checkReadmeSkills")(function* checkReadmeSkills(root) {
18064
18099
  const plugins = yield* pluginsIn$1(root);
18100
+ const { publishRegistry } = yield* ownerSettings(root);
18101
+ const english = isPublicRegistry(publishRegistry);
18102
+ const labelsOf = ({ published }) => pipe(Option.liftPredicate(ENGLISH_LABELS, () => published && english), Option.getOrElse(() => JAPANESE_LABELS));
18065
18103
  const withSkills = pipe(plugins, Array$1.filter(({ skills }) => Array$1.isReadonlyArrayNonEmpty(skills)));
18066
- const found = yield* Effect.forEach(withSkills, syncReadme, { concurrency: "unbounded" });
18104
+ const found = yield* Effect.forEach(withSkills, (plugin) => syncReadme(plugin, labelsOf(plugin)), { concurrency: "unbounded" });
18067
18105
  return Array$1.flatten(found);
18068
18106
  });
18069
18107
  // src/features/check-skill-enumerations/model/enumeration-signals.ts