musubi-cli 0.2.0 → 0.3.0

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/README.ja.md CHANGED
@@ -66,6 +66,8 @@ consumerの`SKILL.md`の本文は、`design-doc`のスキルを名前で開い
66
66
  そのため、エージェントは新しい仕組みがなくてもコンテンツを読み込めます。
67
67
  providerが無くても動くconsumerは、定義のバージョン`2026-11-20`を書き、準拠に`"optional": true`を足します。
68
68
  するとエージェントは、providerがインストールされていない時にそのコンテンツ無しで作業を続けます。
69
+ 定義のバージョン`2026-11-21`では、さらに`"when": { "languages": ["ja"] }`を足せます。
70
+ 足すと、`musubi install --lang ja`がconsumerと一緒にproviderもインストールします。
69
71
  2つのスキルは[examples/skills](examples/skills)にあります。
70
72
 
71
73
  ## チェック
@@ -91,6 +93,20 @@ node src/cli.ts check examples/skills
91
93
  node src/cli.ts graph examples/skills --out graph.html
92
94
  ```
93
95
 
96
+ ## 準拠するスキルと一緒にインストールする
97
+
98
+ `musubi install`は、スキルと、その`musubi.json`が準拠するスキルを、`--from`で名指したフォルダかgitのリポジトリからまとめてインストールします。
99
+
100
+ ```bash
101
+ musubi install convey --from https://github.com/example/skills --to .claude/skills --lang ja
102
+ ```
103
+
104
+ インストール元の中からフォルダ名でスキルを探し、そのフォルダを`--to`へコピーします。
105
+ `--to`が無い時は、カレントフォルダの`.claude/skills`、`.agents/skills`、`.github/skills`、`.gemini/skills`のうち最初に在るフォルダを使います。
106
+ 必須の準拠のproviderは必ずインストールします。
107
+ 任意の準拠のproviderは、`--with <スキル名>`で名指した時か、準拠が`when`に利用者の言語を書いていて、その言語を`--lang`で渡した時にインストールします。
108
+ インストール済みのスキルはそのまま残し、最後に`musubi check`を実行します。
109
+
94
110
  ## サイトにスキルを載せる
95
111
 
96
112
  musubiのサイトは、定義と、GitHubで見つけたスキルを表示します。
package/README.md CHANGED
@@ -60,6 +60,7 @@ A consumer lists the content it follows, the versions it accepts, and the finger
60
60
 
61
61
  The consumer's `SKILL.md` body tells the agent to open the `design-doc` skill by name and read its `design` format, so agents need nothing new to load it.
62
62
  A consumer that also works without the provider names definition version `2026-11-20` and adds `"optional": true` to the follow; the agent then goes on without the content when the provider is not installed.
63
+ With definition version `2026-11-21` it can also add `"when": { "languages": ["ja"] }`, so that `musubi install --lang ja` installs the provider with it.
63
64
  [examples/skills](examples/skills) holds both skills.
64
65
 
65
66
  ## Checking
@@ -85,6 +86,20 @@ node src/cli.ts check examples/skills
85
86
  node src/cli.ts graph examples/skills --out graph.html
86
87
  ```
87
88
 
89
+ ## Installing a skill with the skills it follows
90
+
91
+ `musubi install` installs a skill together with the skills its `musubi.json` follows, from a folder or a git repository you name with `--from`.
92
+
93
+ ```bash
94
+ musubi install convey --from https://github.com/example/skills --to .claude/skills --lang ja
95
+ ```
96
+
97
+ It finds each skill in the source by its folder name and copies the folder into `--to`.
98
+ Without `--to` it uses the first of `.claude/skills`, `.agents/skills`, `.github/skills`, and `.gemini/skills` in the current folder.
99
+ The provider of a required follow is always installed.
100
+ The provider of an optional follow is installed when you name it with `--with <skill>`, or when the follow lists your language in `when` and you give it with `--lang`.
101
+ Skills already installed are kept as they are, and `musubi check` runs at the end.
102
+
88
103
  ## Listing a skill on the site
89
104
 
90
105
  The musubi site shows the definition and the skills it finds on GitHub, with what each one provides, what it follows, and which skills follow it.
package/dist/add.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { basename, join } from "node:path";
3
3
  import { load } from "./check.js";
4
- import { latestDefinition, optionalVersions } from "./definition.js";
4
+ import { definitionVersions, latestDefinition, optionalVersions, whenVersions } from "./definition.js";
5
5
  import { fingerprint } from "./fingerprint.js";
6
6
  import { isObject } from "./json.js";
7
7
  import { Report } from "./report.js";
@@ -25,8 +25,9 @@ export function bodyLines(skill, content, file, optional = false) {
25
25
  ];
26
26
  }
27
27
  // Run in a consumer skill's folder: writes the range and the fingerprint of one content into its
28
- // musubi.json and prints the lines to put in its SKILL.md body.
29
- export function add(ref, roots, cwd, optional = false) {
28
+ // musubi.json and prints the lines to put in its SKILL.md body. The languages, given only with
29
+ // optional, become "when" of the follow.
30
+ export function add(ref, roots, cwd, optional = false, languages = []) {
30
31
  const report = new Report(cwd);
31
32
  const fail = (message) => {
32
33
  report.print();
@@ -55,16 +56,19 @@ export function add(ref, roots, cwd, optional = false) {
55
56
  return fail("musubi.json holds something other than one JSON object");
56
57
  json = current;
57
58
  }
58
- // An optional follow needs a definition version that knows the field.
59
- if (optional && !(typeof json.musubi === "string" && optionalVersions.has(json.musubi)))
60
- json.musubi = latestDefinition;
59
+ // The fields written need a definition version that knows them. A file whose version does not is
60
+ // moved to the earliest version that does, so that older musubi commands still read it.
61
+ const knows = (version) => typeof version === "string" && (!optional || optionalVersions.has(version)) && (languages.length === 0 || whenVersions.has(version));
62
+ if (!knows(json.musubi))
63
+ json.musubi = definitionVersions.find(knows) ?? latestDefinition;
61
64
  const follows = isObject(json.follows) ? json.follows : {};
62
65
  // Keep fields the consumer already wrote, such as examples, after the ones this command owns.
63
- const { version: _version, integrity: _integrity, optional: _optional, ...kept } = isObject(follows[ref]) ? follows[ref] : {};
66
+ const { version: _version, integrity: _integrity, optional: _optional, when: _when, ...kept } = isObject(follows[ref]) ? follows[ref] : {};
64
67
  follows[ref] = {
65
68
  version: `^${format(provided.version)}`,
66
69
  integrity: fingerprint(provider.dir, fingerprintFiles(provided)),
67
70
  ...(optional ? { optional: true } : {}),
71
+ ...(languages.length > 0 ? { when: { languages } } : {}),
68
72
  ...kept,
69
73
  };
70
74
  json.follows = follows;
package/dist/cli.js CHANGED
@@ -4,39 +4,58 @@ import { resolve } from "node:path";
4
4
  import { add } from "./add.js";
5
5
  import { check } from "./check.js";
6
6
  import { graph } from "./graph.js";
7
- import { defaultRoots } from "./skills.js";
7
+ import { install } from "./install.js";
8
+ import { defaultRoots, LANGUAGE_TAG } from "./skills.js";
8
9
  const USAGE = `usage:
9
10
  musubi check [<skills folder>...] [--update]
10
11
  Checks every musubi.json in the folders. Without folders it reads .claude/skills, .agents/skills,
11
12
  .github/skills, and .gemini/skills in this folder and in the home folder.
12
13
  --update rewrites a fingerprint after its content passes the check again.
13
- musubi add <skill>/<content> [<skills folder>...] [--optional]
14
+ musubi add <skill>/<content> [<skills folder>...] [--optional [--lang <language>]...]
14
15
  Run in a skill's folder: makes the skill follow the content and prints the lines for its SKILL.md.
15
16
  --optional makes the follow optional: the skill reads the content only when the provider is installed.
17
+ --lang writes the languages for which musubi install installs the provider of the optional follow.
18
+ musubi install <skill>... --from <folder or git URL>... [--to <skills folder>] [--with <skill>]... [--lang <language>]...
19
+ Installs the skills and the skills they follow, found by folder name in the sources, then runs musubi check.
20
+ Without --to it installs into the first of .claude/skills, .agents/skills, .github/skills, and
21
+ .gemini/skills in this folder. The provider of an optional follow is installed only when --with names
22
+ it or a --lang language matches the follow's "when".
16
23
  musubi graph [<skills folder>...] [--out <file>]
17
24
  Writes an HTML page of the skills and the contents they follow (default musubi-graph.html).
18
25
  `;
26
+ // The options each command takes: flags stand alone, and the others take the word after them.
27
+ const FLAGS = { check: ["--update"], add: ["--optional"] };
28
+ const VALUES = { add: ["--lang"], install: ["--from", "--to", "--with", "--lang"], graph: ["--out"] };
19
29
  function main(argv) {
20
30
  const [command, ...rest] = argv;
31
+ if (command === "--help" || command === "-h") {
32
+ process.stdout.write(USAGE);
33
+ return 0;
34
+ }
21
35
  const cwd = process.cwd();
22
- const flags = new Set(rest.filter((arg) => arg.startsWith("--")));
36
+ const flags = new Set();
37
+ const values = new Map();
23
38
  const positional = [];
24
- let out = "musubi-graph.html";
25
39
  for (let i = 0; i < rest.length; i += 1) {
26
- if (rest[i] === "--out") {
27
- out = rest[i + 1] ?? "";
40
+ const arg = rest[i];
41
+ if (!arg.startsWith("--"))
42
+ positional.push(arg);
43
+ else if (FLAGS[command]?.includes(arg))
44
+ flags.add(arg);
45
+ else if (VALUES[command]?.includes(arg) && rest[i + 1] !== undefined && !rest[i + 1].startsWith("--") && rest[i + 1] !== "") {
46
+ values.set(arg, [...(values.get(arg) ?? []), rest[i + 1]]);
28
47
  i += 1;
29
48
  }
30
- else if (!rest[i].startsWith("--"))
31
- positional.push(rest[i]);
32
- }
33
- const unknown = [...flags].filter((flag) => !(command === "check" && flag === "--update") && !(command === "graph" && flag === "--out") && !(command === "add" && flag === "--optional"));
34
- if (command === "--help" || command === "-h") {
35
- process.stdout.write(USAGE);
36
- return 0;
49
+ else {
50
+ process.stderr.write(`musubi: unknown or incomplete option ${arg}\n${USAGE}`);
51
+ return 2;
52
+ }
37
53
  }
38
- if (unknown.length > 0 || (command === "graph" && out === "")) {
39
- process.stderr.write(`musubi: unknown or incomplete option ${unknown[0] ?? "--out"}\n${USAGE}`);
54
+ const all = (option) => values.get(option) ?? [];
55
+ const last = (option) => all(option).at(-1);
56
+ const badTag = all("--lang").find((tag) => !LANGUAGE_TAG.test(tag));
57
+ if (badTag !== undefined) {
58
+ process.stderr.write(`musubi: --lang takes a language tag such as ja or ja-JP, not "${badTag}"\n`);
40
59
  return 2;
41
60
  }
42
61
  const roots = (given, extra = []) => given.length > 0 ? given.map((r) => resolve(cwd, r)) : [...extra, ...defaultRoots(cwd, homedir())];
@@ -47,10 +66,30 @@ function main(argv) {
47
66
  const [ref, ...given] = positional;
48
67
  if (!ref)
49
68
  break;
50
- return add(ref, roots(given, [resolve(cwd, "..")]), cwd, flags.has("--optional"));
69
+ if (all("--lang").length > 0 && !flags.has("--optional")) {
70
+ process.stderr.write("musubi add: --lang needs --optional, because only an optional follow names languages\n");
71
+ return 2;
72
+ }
73
+ return add(ref, roots(given, [resolve(cwd, "..")]), cwd, flags.has("--optional"), all("--lang"));
51
74
  }
75
+ case "install":
76
+ if (positional.length === 0)
77
+ break;
78
+ if (all("--from").length === 0) {
79
+ process.stderr.write("musubi install: name at least one source with --from, a folder or a git URL\n");
80
+ return 2;
81
+ }
82
+ return install({
83
+ names: positional,
84
+ sources: all("--from"),
85
+ to: last("--to") ?? null,
86
+ with: all("--with"),
87
+ languages: all("--lang"),
88
+ cwd,
89
+ home: homedir(),
90
+ });
52
91
  case "graph":
53
- return graph(roots(positional), resolve(cwd, out), cwd);
92
+ return graph(roots(positional), resolve(cwd, last("--out") ?? "musubi-graph.html"), cwd);
54
93
  }
55
94
  process.stderr.write(USAGE);
56
95
  return 2;
@@ -7,11 +7,17 @@ export const definitionVersions = readdirSync(schemaDir)
7
7
  .filter((name) => /^\d{4}-\d{2}-\d{2}$/.test(name))
8
8
  .sort();
9
9
  export const latestDefinition = definitionVersions[definitionVersions.length - 1];
10
- // The definition versions whose schema lets a follow say "optional" (decision record 0007), read
11
- // from the schemas so that no date is written in the code.
12
- export const optionalVersions = new Set(definitionVersions.filter((version) => {
13
- const schema = JSON.parse(readFileSync(`${schemaDir}${version}/musubi.schema.json`, "utf8"));
14
- return schema?.$defs?.followed?.properties?.optional !== undefined;
15
- }));
10
+ // The definition versions whose schema lets a follow carry a field, read from the schemas so that
11
+ // no date is written in the code.
12
+ function versionsKnowing(field) {
13
+ return new Set(definitionVersions.filter((version) => {
14
+ const schema = JSON.parse(readFileSync(`${schemaDir}${version}/musubi.schema.json`, "utf8"));
15
+ return schema?.$defs?.followed?.properties?.[field] !== undefined;
16
+ }));
17
+ }
18
+ // "optional" makes a follow optional (decision record 0007), and "when" names the languages for
19
+ // which musubi install installs the provider of an optional follow (decision record 0009).
20
+ export const optionalVersions = versionsKnowing("optional");
21
+ export const whenVersions = versionsKnowing("when");
16
22
  // Agents read a content file whole; Agent Skills suggests keeping SKILL.md under this many lines.
17
23
  export const READ_LINES = 500;
@@ -0,0 +1,168 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, realpathSync, rmSync, statSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { basename, join, relative, resolve } from "node:path";
5
+ import { check } from "./check.js";
6
+ import { Report } from "./report.js";
7
+ import { format, satisfies } from "./semver.js";
8
+ import { defaultRoots, discover, FOLDERS, readDeclaration } from "./skills.js";
9
+ const GIT_URL = /^(?:https?|ssh|git|file):\/\/|^[^@\s]+@[^:\s]+:/;
10
+ // Every folder in the source that holds a SKILL.md is a skill named by its folder, however deep it
11
+ // sits, because repositories keep skills under plugins/<name>/skills/ or .claude/skills/ alike.
12
+ function skillsIn(root) {
13
+ const found = new Map();
14
+ const seen = new Set();
15
+ const walk = (dir) => {
16
+ const real = realpathSync(dir);
17
+ if (seen.has(real))
18
+ return;
19
+ seen.add(real);
20
+ if (dir !== root && existsSync(join(dir, "SKILL.md"))) {
21
+ found.set(basename(dir), [...(found.get(basename(dir)) ?? []), dir]);
22
+ return;
23
+ }
24
+ for (const name of readdirSync(dir).sort()) {
25
+ if (name === ".git" || name === "node_modules")
26
+ continue;
27
+ const path = join(dir, name);
28
+ if (statSync(path, { throwIfNoEntry: false })?.isDirectory())
29
+ walk(path);
30
+ }
31
+ };
32
+ walk(root);
33
+ return found;
34
+ }
35
+ // A follow's provider is installed without being named when one of the user's languages has the
36
+ // same primary language as one of the follow's, so ja-JP matches ja.
37
+ function languageMatches(follow, languages) {
38
+ const primary = (tag) => tag.split("-")[0].toLowerCase();
39
+ return follow.languages.some((tag) => languages.some((language) => primary(language) === primary(tag)));
40
+ }
41
+ export function install(o) {
42
+ let to;
43
+ if (o.to !== null)
44
+ to = resolve(o.cwd, o.to);
45
+ else {
46
+ const first = FOLDERS.map((folder) => resolve(o.cwd, folder)).find((dir) => statSync(dir, { throwIfNoEntry: false })?.isDirectory());
47
+ if (!first) {
48
+ process.stderr.write(`musubi install: no skills folder (${FOLDERS.join(", ")}) in this folder; name one with --to\n`);
49
+ return 2;
50
+ }
51
+ to = first;
52
+ }
53
+ const temporary = [];
54
+ try {
55
+ const sources = [];
56
+ for (const given of o.sources) {
57
+ const folder = resolve(o.cwd, given);
58
+ if (statSync(folder, { throwIfNoEntry: false })?.isDirectory()) {
59
+ sources.push({ given, dir: folder, skills: skillsIn(folder) });
60
+ continue;
61
+ }
62
+ if (!GIT_URL.test(given)) {
63
+ process.stderr.write(`musubi install: the source "${given}" is neither a folder nor a git URL\n`);
64
+ return 2;
65
+ }
66
+ const clone = mkdtempSync(join(tmpdir(), "musubi-install-"));
67
+ temporary.push(clone);
68
+ const git = spawnSync("git", ["clone", "--quiet", "--depth", "1", given, join(clone, "repo")], { encoding: "utf8" });
69
+ if (git.status !== 0) {
70
+ const why = git.error?.message ?? git.stderr.trim().split("\n").at(-1) ?? "";
71
+ process.stderr.write(`musubi install: could not clone ${given}: ${why}\n`);
72
+ return 1;
73
+ }
74
+ sources.push({ given, dir: join(clone, "repo"), skills: skillsIn(join(clone, "repo")) });
75
+ }
76
+ // The skills an agent already reads, in the order musubi check reads them, with --to first.
77
+ const quiet = new Report(o.cwd);
78
+ const roots = [to, ...defaultRoots(o.cwd, o.home)];
79
+ const installed = discover(roots, quiet);
80
+ const problems = [];
81
+ const copies = [];
82
+ const kept = [];
83
+ const declarations = new Map();
84
+ const bound = [];
85
+ const leftOut = [];
86
+ // Walks the follows from the named skills: a required follow always brings its provider, and an
87
+ // optional one only when the user names the provider or a language matches.
88
+ const queue = o.names.map((name) => ({ name }));
89
+ while (queue.length > 0) {
90
+ const { name, need } = queue.shift();
91
+ if (declarations.has(name))
92
+ continue;
93
+ let skill = installed.get(name);
94
+ if (skill)
95
+ kept.push(skill);
96
+ else {
97
+ const source = sources.find((s) => s.skills.has(name));
98
+ const dirs = source?.skills.get(name) ?? [];
99
+ if (!source) {
100
+ problems.push(need ? `no source holds a skill named ${name}, which ${need.consumer} follows for ${need.follow.ref}` : `no source holds a skill named ${name}`);
101
+ declarations.set(name, null);
102
+ continue;
103
+ }
104
+ if (dirs.length > 1) {
105
+ const paths = dirs.map((dir) => relative(source.dir, dir).split("\\").join("/"));
106
+ problems.push(`the source ${source.given} holds more than one skill named ${name}: ${paths.join(", ")}`);
107
+ declarations.set(name, null);
108
+ continue;
109
+ }
110
+ skill = { name, dir: dirs[0] };
111
+ if (existsSync(join(to, name)))
112
+ problems.push(`${join(to, name)} already exists and holds no SKILL.md, so ${name} cannot be installed there`);
113
+ copies.push({ skill, source });
114
+ }
115
+ const declaration = readDeclaration(skill, quiet);
116
+ declarations.set(name, declaration);
117
+ for (const follow of declaration?.follows ?? []) {
118
+ const wanted = !follow.optional || o.with.includes(follow.skill) || languageMatches(follow, o.languages);
119
+ if (!wanted) {
120
+ leftOut.push({ consumer: name, follow });
121
+ continue;
122
+ }
123
+ bound.push({ consumer: name, follow });
124
+ queue.push({ name: follow.skill, need: { consumer: name, follow } });
125
+ }
126
+ }
127
+ // A provider must provide the content at a version the consumer accepts before anything is copied.
128
+ for (const { consumer, follow } of bound) {
129
+ const declaration = declarations.get(follow.skill);
130
+ if (declaration === null)
131
+ continue;
132
+ const provided = declaration?.provides.get(follow.content);
133
+ if (!provided)
134
+ problems.push(`${consumer} follows ${follow.ref}, but ${follow.skill} provides no content named ${follow.content}`);
135
+ else if (provided.version && follow.range && !satisfies(provided.version, follow.range)) {
136
+ problems.push(`${consumer} accepts ${follow.range.text} of ${follow.ref}, but ${follow.skill} provides ${format(provided.version)}`);
137
+ }
138
+ }
139
+ if (problems.length > 0) {
140
+ for (const problem of problems)
141
+ process.stderr.write(`musubi install: ${problem}\n`);
142
+ process.stderr.write("musubi install: nothing was installed\n");
143
+ return 1;
144
+ }
145
+ const where = (path) => relative(o.cwd, path) || path;
146
+ mkdirSync(to, { recursive: true });
147
+ for (const { skill, source } of copies) {
148
+ cpSync(skill.dir, join(to, skill.name), { recursive: true, dereference: true, filter: (path) => basename(path) !== ".git" });
149
+ process.stdout.write(`installed ${skill.name} from ${source.given} (${relative(source.dir, skill.dir).split("\\").join("/")}) into ${where(to)}\n`);
150
+ }
151
+ for (const skill of kept)
152
+ process.stdout.write(`${skill.name} is already installed in ${where(skill.dir)}, so it was kept as it is\n`);
153
+ for (const { consumer, follow } of leftOut) {
154
+ if (declarations.has(follow.skill))
155
+ continue;
156
+ process.stdout.write(`left out ${follow.skill}, which ${consumer} follows only when it is installed; add it with --with ${follow.skill}\n`);
157
+ }
158
+ for (const name of o.with) {
159
+ if (!declarations.has(name))
160
+ process.stderr.write(`warning: --with ${name} names no optional follow of the skills installed\n`);
161
+ }
162
+ return check(roots, o.cwd, false);
163
+ }
164
+ finally {
165
+ for (const dir of temporary)
166
+ rmSync(dir, { recursive: true, force: true });
167
+ }
168
+ }
package/dist/skills.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2
2
  import { isAbsolute, join, relative, resolve } from "node:path";
3
- import { definitionVersions, optionalVersions } from "./definition.js";
3
+ import { definitionVersions, optionalVersions, whenVersions } from "./definition.js";
4
4
  import { INTEGRITY } from "./fingerprint.js";
5
5
  import { isObject, JsonError, parseLocated, pointer } from "./json.js";
6
6
  import { readRules } from "./rules.js";
7
7
  import { parseRange, parseVersion } from "./semver.js";
8
8
  // The folders the agents read skills from, in the project and in the home folder.
9
- const FOLDERS = [".claude/skills", ".agents/skills", ".github/skills", ".gemini/skills"];
9
+ export const FOLDERS = [".claude/skills", ".agents/skills", ".github/skills", ".gemini/skills"];
10
+ // A language tag such as ja or ja-JP, as an optional follow's "when" and --lang write it.
11
+ export const LANGUAGE_TAG = /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;
10
12
  export function defaultRoots(cwd, home) {
11
13
  return [cwd, home].flatMap((base) => FOLDERS.map((folder) => resolve(base, folder)));
12
14
  }
@@ -62,6 +64,26 @@ export function readDeclaration(skill, report) {
62
64
  }
63
65
  const { value, lines } = located;
64
66
  const at = (...keys) => lines.get(pointer(...keys)) ?? 1;
67
+ // "when" of an optional follow holds one field, a list of language tags (decision record 0009).
68
+ const readWhen = (when, ref, optional) => {
69
+ const line = at("follows", ref, "when");
70
+ if (!optional)
71
+ report.problem(path, line, `"when" of "${ref}" needs "optional": true`);
72
+ if (!isObject(when) || when.languages === undefined) {
73
+ report.problem(path, line, `"when" of "${ref}" must be an object with "languages"`);
74
+ return [];
75
+ }
76
+ for (const key of Object.keys(when)) {
77
+ if (key !== "languages")
78
+ report.problem(path, at("follows", ref, "when", key), `unknown field "${key}" in "when" of "${ref}"`);
79
+ }
80
+ const { languages } = when;
81
+ if (!Array.isArray(languages) || languages.length === 0 || !languages.every((tag) => typeof tag === "string" && LANGUAGE_TAG.test(tag))) {
82
+ report.problem(path, at("follows", ref, "when", "languages"), `"languages" of "${ref}" must list language tags such as "ja"`);
83
+ return [];
84
+ }
85
+ return languages;
86
+ };
65
87
  if (!isObject(value)) {
66
88
  report.problem(path, 1, "musubi.json holds one JSON object");
67
89
  return declaration;
@@ -134,13 +156,16 @@ export function readDeclaration(skill, report) {
134
156
  continue;
135
157
  }
136
158
  const knowsOptional = typeof value.musubi === "string" && optionalVersions.has(value.musubi);
159
+ const knowsWhen = typeof value.musubi === "string" && whenVersions.has(value.musubi);
137
160
  for (const key of Object.keys(entry)) {
138
- if (!FOLLOWED.has(key) && !(key === "optional" && knowsOptional))
161
+ const known = FOLLOWED.has(key) || (key === "optional" && knowsOptional) || (key === "when" && knowsWhen);
162
+ if (!known)
139
163
  report.problem(path, at("follows", ref, key), `unknown field "${key}" in "${ref}"`);
140
164
  }
141
165
  if (knowsOptional && entry.optional !== undefined && typeof entry.optional !== "boolean") {
142
166
  report.problem(path, at("follows", ref, "optional"), `"optional" of "${ref}" must be true or false`);
143
167
  }
168
+ const languages = knowsWhen && entry.when !== undefined ? readWhen(entry.when, ref, entry.optional === true) : [];
144
169
  const versionLine = lines.get(pointer("follows", ref, "version")) ?? line;
145
170
  const range = typeof entry.version === "string" ? parseRange(entry.version) : null;
146
171
  if (!range)
@@ -168,7 +193,7 @@ export function readDeclaration(skill, report) {
168
193
  }
169
194
  const [skillName, content] = ref.split("/");
170
195
  const optional = knowsOptional && entry.optional === true;
171
- declaration.follows.push({ ref, skill: skillName, content, range, integrity, examples, optional, line, versionLine, integrityLine });
196
+ declaration.follows.push({ ref, skill: skillName, content, range, integrity, examples, optional, languages, line, versionLine, integrityLine });
172
197
  }
173
198
  }
174
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musubi-cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Binds the content one agent skill provides to the skills that follow it, and checks them again when that content changes",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -0,0 +1,68 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "check.schema.json",
4
+ "title": "musubi check rules",
5
+ "description": "The rules a provider skill's check holds. musubi check reads them and never runs provider code.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["musubi", "rules"],
9
+ "properties": {
10
+ "$schema": { "type": "string" },
11
+ "musubi": { "const": "2026-11-21" },
12
+ "rules": {
13
+ "type": "array",
14
+ "minItems": 1,
15
+ "items": {
16
+ "oneOf": [
17
+ {
18
+ "type": "object",
19
+ "additionalProperties": false,
20
+ "required": ["kind", "headings"],
21
+ "properties": {
22
+ "kind": { "const": "headings" },
23
+ "headings": {
24
+ "type": "array",
25
+ "minItems": 1,
26
+ "description": "Heading lines that must appear, in this order. Other headings may come between them.",
27
+ "items": { "type": "string", "minLength": 1 }
28
+ }
29
+ }
30
+ },
31
+ {
32
+ "type": "object",
33
+ "additionalProperties": false,
34
+ "required": ["kind", "text"],
35
+ "properties": {
36
+ "kind": { "const": "forbid" },
37
+ "text": {
38
+ "type": "array",
39
+ "minItems": 1,
40
+ "description": "Text that must not remain outside code blocks.",
41
+ "items": { "type": "string", "minLength": 1 }
42
+ }
43
+ }
44
+ },
45
+ {
46
+ "type": "object",
47
+ "additionalProperties": false,
48
+ "required": ["kind", "heading", "columns"],
49
+ "properties": {
50
+ "kind": { "const": "table-columns" },
51
+ "heading": {
52
+ "type": "string",
53
+ "minLength": 1,
54
+ "description": "The heading line whose first table is checked."
55
+ },
56
+ "columns": {
57
+ "type": "array",
58
+ "minItems": 1,
59
+ "description": "Columns the table must have. It may have more.",
60
+ "items": { "type": "string", "minLength": 1 }
61
+ }
62
+ }
63
+ }
64
+ ]
65
+ }
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,98 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "musubi.schema.json",
4
+ "title": "musubi.json",
5
+ "description": "The musubi declaration next to a skill's SKILL.md: the content the skill provides and the content it follows.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["musubi"],
9
+ "properties": {
10
+ "$schema": {
11
+ "type": "string",
12
+ "description": "Where editors find this schema."
13
+ },
14
+ "musubi": {
15
+ "const": "2026-11-21",
16
+ "description": "The date of the musubi definition this file follows."
17
+ },
18
+ "provides": {
19
+ "type": "object",
20
+ "description": "Content this skill provides, by name.",
21
+ "propertyNames": { "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" },
22
+ "additionalProperties": { "$ref": "#/$defs/provided" }
23
+ },
24
+ "follows": {
25
+ "type": "object",
26
+ "description": "Content this skill follows, by <skill>/<content>.",
27
+ "propertyNames": { "pattern": "^[a-z0-9]+(-[a-z0-9]+)*/[a-z0-9]+(-[a-z0-9]+)*$" },
28
+ "additionalProperties": { "$ref": "#/$defs/followed" }
29
+ }
30
+ },
31
+ "$defs": {
32
+ "provided": {
33
+ "type": "object",
34
+ "additionalProperties": false,
35
+ "required": ["version", "file"],
36
+ "properties": {
37
+ "version": {
38
+ "type": "string",
39
+ "description": "MAJOR.MINOR.PATCH. Raise MAJOR when a following skill can break.",
40
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
41
+ },
42
+ "file": {
43
+ "type": "string",
44
+ "minLength": 1,
45
+ "description": "The content file, relative to the skill folder."
46
+ },
47
+ "check": {
48
+ "type": "string",
49
+ "pattern": "\\.json$",
50
+ "description": "A JSON rules file, relative to the skill folder, that musubi check applies to the examples of following skills."
51
+ }
52
+ }
53
+ },
54
+ "followed": {
55
+ "type": "object",
56
+ "additionalProperties": false,
57
+ "required": ["version", "integrity"],
58
+ "properties": {
59
+ "version": {
60
+ "type": "string",
61
+ "description": "The versions this skill accepts: ^X.Y.Z, ~X.Y.Z, or X.Y.Z.",
62
+ "pattern": "^[\\^~]?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
63
+ },
64
+ "integrity": {
65
+ "type": "string",
66
+ "description": "The fingerprint of the content at the last check.",
67
+ "pattern": "^sha256-[A-Za-z0-9+/]{43}=$"
68
+ },
69
+ "examples": {
70
+ "type": "array",
71
+ "description": "Files of this skill that the provider's check is applied to.",
72
+ "items": { "type": "string", "minLength": 1 }
73
+ },
74
+ "optional": {
75
+ "type": "boolean",
76
+ "description": "true when this skill also runs without the provider: it reads the content only when the provider is installed, and musubi check skips the follow when it is not."
77
+ },
78
+ "when": {
79
+ "type": "object",
80
+ "description": "When musubi install installs the provider of this optional follow without the user naming it: when a language the user gives with --lang has the same primary language as one of languages.",
81
+ "additionalProperties": false,
82
+ "required": ["languages"],
83
+ "properties": {
84
+ "languages": {
85
+ "type": "array",
86
+ "description": "Language tags such as ja or ja-JP.",
87
+ "minItems": 1,
88
+ "items": { "type": "string", "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$" }
89
+ }
90
+ }
91
+ }
92
+ },
93
+ "dependentSchemas": {
94
+ "when": { "required": ["optional"], "properties": { "optional": { "const": true } } }
95
+ }
96
+ }
97
+ }
98
+ }
package/spec/musubi.ja.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # musubiの定義
2
2
 
3
- 定義のバージョンは`2026-11-20`。
3
+ 定義のバージョンは`2026-11-21`。
4
4
 
5
5
  musubiは、文書の書式や書き方のルールのように、エージェントのスキルが提供するコンテンツと、そのコンテンツに準拠するスキルを結び付ける。
6
6
  あるスキルがコンテンツを名前とバージョン付きで宣言し、別のスキルがそのコンテンツに準拠すると宣言する。
@@ -87,6 +87,7 @@ consumerのスキルは、準拠するコンテンツを`musubi.json`の`follows
87
87
  | `follows.<参照>.integrity` | はい | 最後にチェックした時のコンテンツのフィンガープリント |
88
88
  | `follows.<参照>.examples` | いいえ | providerのチェックを適用する、consumerのファイル |
89
89
  | `follows.<参照>.optional` | いいえ | providerが無くてもconsumerが動く時に`true`を書く。下で定める |
90
+ | `follows.<参照>.when` | いいえ | `optional: true`の時だけ書ける。利用者が名指さなくてもインストーラーがproviderをインストールする言語を書く。下とインストールの節で定める |
90
91
 
91
92
  consumerの`SKILL.md`の本文には、準拠するコンテンツごとに次の3行を書く。
92
93
  この3行は`musubi add`が出力する。
@@ -114,6 +115,24 @@ If the `musubi` command is available, run `musubi check` before reading, and sto
114
115
  If the `design-doc` skill is not installed, go on without the `design` of `design-doc`.
115
116
  ```
116
117
 
118
+ 任意の準拠は、consumerと一緒にproviderをインストールする言語を`when`に書いてもよい。
119
+ たとえば、日本語で書く利用者にだけ書き方のルールをインストールする時に使う (判断の記録[0009](../docs/adr/0009-optional-follows-name-their-languages.ja.md))。
120
+ `languages`には言語タグを並べ、`musubi add --optional --lang ja`がこれを書く。
121
+
122
+ ```json
123
+ {
124
+ "musubi": "2026-11-21",
125
+ "follows": {
126
+ "japanese-writing/rules": {
127
+ "version": "^1.0.0",
128
+ "integrity": "sha256-yNSwpBT+xXEV5bGBqedpHmjWIHVi+JaAnRATAJ0s7wM=",
129
+ "optional": true,
130
+ "when": { "languages": ["ja"] }
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
117
136
  consumerは、準拠するコンテンツに自分の節を追加できる。
118
137
  ただし、providerのチェックが求めるものを削除したり、名前を変えたりはできない。
119
138
  1つのスキルが、コンテンツを提供しながら別のコンテンツに準拠してもよい。
@@ -142,6 +161,48 @@ Claude Code、Codex、GitHub Copilot CLI、Gemini CLIはどれもインストー
142
161
  そのようなコンテンツも拒否はしない。
143
162
  長いコンテンツは、providerが複数のコンテンツに分ける。
144
163
 
164
+ ## インストール
165
+
166
+ スキルをインストールする時は、そのスキルが準拠するスキルもインストールする。
167
+ そうすれば、Claude Codeのプラグインの`dependencies`のようなフィールドを持たないエージェントでも、consumerはproviderを見つけられる (判断の記録[0008](../docs/adr/0008-install-follows-from-named-sources.ja.md))。
168
+ `musubi install`もほかのインストーラーも、consumerの`musubi.json`を読み、次の同じ決まりでインストールするスキルを決める。
169
+
170
+ 1. 必須の準拠のproviderは全てインストールする。
171
+ 2. 任意の準拠のproviderは、利用者がそのproviderを名指した時か、利用者が渡した言語の主な言語が準拠の`when.languages`のタグと同じ時だけインストールする。たとえば`ja-JP`は`ja`に合う。
172
+ 3. インストールしたスキルごとに同じことを繰り返し、準拠の連鎖の最後まで辿る。
173
+ 4. インストール済みのスキルはそのまま残し、そのスキルの準拠は辿る。
174
+ 5. 必須の準拠のproviderがどのインストール元にも無い時と、その名前のコンテンツを提供しない時と、consumerの範囲の外のバージョンを提供する時は、何もインストールせず、その準拠を示す。
175
+ 6. インストールした後に、再チェックの節のとおり`musubi check`を実行する。
176
+
177
+ `musubi.json`には、スキルのインストール元を書かない。
178
+ インストール元は利用者が名指し、インストーラーはその中から名前でスキルを探す。
179
+ エージェントがproviderを名前で開くのと同じ方法である。
180
+
181
+ `musubi install`は、インストール元を`--from`で受け取る。
182
+ インストール元はフォルダか、gitのリポジトリのURLである。
183
+ URLの時は`git clone --depth 1`で一時フォルダへクローンし、終わった後に消す。
184
+ インストール元の中で`SKILL.md`を持つフォルダは、`.git`と`node_modules`の中を除き、どの深さにあってもスキルで、スキルの名前はフォルダの名前である。
185
+ 同じスキルを持つインストール元が複数ある時は、先に名指したインストール元を使う。
186
+ 同じ名前のスキルを2つ持つインストール元は拒否する。
187
+ スキルのフォルダは丸ごと`--to`で指定したフォルダへコピーする。
188
+ `--to`が無い時は、カレントフォルダの`.claude/skills`、`.agents/skills`、`.github/skills`、`.gemini/skills`のうち、最初にあるフォルダへコピーする。
189
+ `musubi check`が見つけるスキルは、インストール済みとして扱う。
190
+ つまり、コピー先のフォルダと、引数の無い`musubi check`が読むフォルダにあるスキルである。
191
+
192
+ ```bash
193
+ musubi install api-design --from ../skills --to .claude/skills
194
+ musubi install convey --from https://github.com/example/skills --lang ja --with design-doc
195
+ ```
196
+
197
+ | オプション | 意味 |
198
+ |---|---|
199
+ | `--from <フォルダかgitのURL>` | インストール元。複数指定すると、指定した順に探す |
200
+ | `--to <スキルのフォルダ>` | インストールするフォルダ |
201
+ | `--with <スキル名>` | 任意の準拠のproviderを名前で指定してインストールする。複数指定できる |
202
+ | `--lang <言語タグ>` | 利用者が書く言語。`when.languages`と照らし合わせる。複数指定できる |
203
+
204
+ `musubi install`の終了コードは、全てをインストールして`musubi check`が通った時は`0`、問題があって何もインストールしなかった時か`musubi check`が問題を見つけた時は`1`、コマンドの呼び出し方が間違っている時は`2`である。
205
+
145
206
  ## バージョンとフィンガープリント
146
207
 
147
208
  コンテンツのバージョンは`MAJOR.MINOR.PATCH`の形で書く。
@@ -181,6 +242,8 @@ integrity = "sha256-" + base64(sha256 digest)
181
242
  知っている日付は、`schema/`の下にあるフォルダの名前である。
182
243
  定義のバージョン`2026-11-20`で`follows.<参照>.optional`を加えた。
183
244
  `2026-11-19`を書いた`musubi.json`は今も通り、`optional`は書けない。
245
+ 定義のバージョン`2026-11-21`で`follows.<参照>.when`を加えた。
246
+ `2026-11-20`を書いた`musubi.json`は今も通り、`when`は書けない。
184
247
 
185
248
  ## 再チェック
186
249
 
@@ -191,6 +254,7 @@ consumerは、スキルをインストールした後と、スキルを更新し
191
254
 
192
255
  - `musubi.json`がJSONとして正しくない、定義にないフィールドを持つ、知らない定義のバージョンを指定している
193
256
  - バージョンが`MAJOR.MINOR.PATCH`の形でない、範囲が3つの形のどれでもない
257
+ - 準拠が`optional: true`無しで`when`を持つ、`when`が`languages`の言語タグの一覧以外を持つ
194
258
  - ファイル、チェック、例のパスがスキルのフォルダの外へ出るか、存在しないファイルを指している
195
259
  - チェックがJSONのルールのファイルでない
196
260
  - consumerが、インストールされていないスキル (任意の準拠を除く) か、そのスキルが提供していないコンテンツに準拠している
@@ -245,17 +309,19 @@ providerのコードは実行しない (判断の記録[0004](../docs/adr/0004-c
245
309
 
246
310
  | 仕組み | すること | musubiとの関係 |
247
311
  |---|---|---|
248
- | スキルのインストーラー (APM、npx skills、skillpmなど) | スキルとその依存をインストールし、バージョンを固定する | スキルの入手先はインストーラーが管理する。`musubi.json`はスキルとコンテンツとバージョンだけを書くので、入手先を書くのは1か所で済む |
249
- | Claude Codeのプラグインの`dependencies` | プラグインが依存するプラグインをインストールする | インストーラーと同じ。このようなフィールドを持たないエージェントでは、consumerの本文にある作業を止める1行に頼る |
312
+ | スキルのインストーラー (APM、npx skills、skillpmなど) | スキルとその依存をインストールし、バージョンを固定する | スキルのインストール元はインストーラーが管理する。`musubi.json`はスキルとコンテンツとバージョンだけを書くので、インストール元を書くのは1か所で済む。`musubi.json`を読むインストーラーは、インストールの節のとおりにproviderをインストールする |
313
+ | Claude Codeのプラグインの`dependencies` | プラグインが依存するプラグインをインストールする | インストーラーと同じ。このようなフィールドを持たないエージェントでは、`musubi install`がproviderをインストールする。何もインストールしなかった時は、consumerの本文にある作業を止める1行がエージェントを止める |
250
314
  | Agent Skills | `SKILL.md`とスキルのフォルダを定める | `SKILL.md`は変えず、フォルダの中に`musubi.json`が1つ増えるだけである。musubiは実際のスキルで動くようになった後に、Agent Skillsへ提案する |
251
315
  | Agent Skillsの依存ファイルとロックファイルの提案 | スキルが必要とするスキルを宣言する | これらはどのスキルをインストールするかを書く。musubiは、そのスキルのどのコンテンツにどのバージョンで準拠するかを書き、再チェックする |
252
316
 
253
317
  ## musubiコマンド
254
318
 
255
319
  コマンドはNode.js 22.18以降で動き、実行時の依存を持たない。
320
+ `musubi install`は、gitのURLで指定したインストール元をクローンする時だけ`git`を実行する。
256
321
 
257
322
  | コマンド | すること |
258
323
  |---|---|
259
324
  | `musubi check [<フォルダ>...] [--update]` | フォルダの中の全ての`musubi.json`を、再チェックの節のとおりにチェックする |
260
- | `musubi add <スキル名>/<名前> [<フォルダ>...] [--optional]` | consumerのフォルダで実行する。`musubi.json`に範囲`^<今のバージョン>`とフィンガープリントを書き込み、既にあるフィールドは残し、`SKILL.md`に置く3行を出力する。`--optional`を付けると`optional: true`も書き、`musubi`が`optional`を持たない定義のバージョンなら最新の定義のバージョンに上げ、任意の準拠の3行を出力する |
325
+ | `musubi add <スキル名>/<名前> [<フォルダ>...] [--optional [--lang <言語タグ>]...]` | consumerのフォルダで実行する。`musubi.json`に範囲`^<今のバージョン>`とフィンガープリントを書き込み、既にあるフィールドは残し、`SKILL.md`に置く3行を出力する。`--optional`を付けると`optional: true`も書いて任意の準拠の3行を出力し、`--lang`を付けると`when.languages`を書く。書くフィールドを`musubi`の定義のバージョンが持たない時は、そのフィールドを持つ最も古い定義のバージョンに上げる |
326
+ | `musubi install <スキル名>... --from <インストール元>... [--to <フォルダ>] [--with <スキル名>]... [--lang <言語タグ>]...` | スキルと、そのスキルが準拠するproviderを、インストールの節のとおりにインストールし、`musubi check`を実行する |
261
327
  | `musubi graph [<フォルダ>...] [--out <ファイル>]` | 各スキルと、準拠するコンテンツへの矢印を描いたHTMLのページを1つ書き出す |
package/spec/musubi.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # The musubi definition
2
2
 
3
- Definition version `2026-11-20`.
3
+ Definition version `2026-11-21`.
4
4
 
5
5
  musubi binds the content one agent skill provides, such as a document format or writing rules, to the skills that follow it.
6
6
  A skill declares that content under a name and a version, another skill declares that it follows it, agents load it the same way in every agent that reads `SKILL.md`, and the skills that follow it are checked again when it changes.
@@ -85,6 +85,7 @@ A consumer skill lists the content it follows under `follows` in `musubi.json`.
85
85
  | `follows.<ref>.integrity` | Yes | The fingerprint of the content at the last check |
86
86
  | `follows.<ref>.examples` | No | Files of the consumer that the provider's check is applied to |
87
87
  | `follows.<ref>.optional` | No | `true` when the consumer also works without the provider, described below |
88
+ | `follows.<ref>.when` | No | Only with `optional: true`: the languages for which an installer installs the provider without being asked, described below and in Installing |
88
89
 
89
90
  The consumer's `SKILL.md` body carries three lines for each content it follows, which `musubi add` prints.
90
91
 
@@ -109,6 +110,23 @@ If the `musubi` command is available, run `musubi check` before reading, and sto
109
110
  If the `design-doc` skill is not installed, go on without the `design` of `design-doc`.
110
111
  ```
111
112
 
113
+ An optional follow may also name in `when` the languages for which the provider is installed together with the consumer, such as writing rules for users who write Japanese (decision record [0009](../docs/adr/0009-optional-follows-name-their-languages.md)).
114
+ `languages` lists language tags, and `musubi add --optional --lang ja` writes them.
115
+
116
+ ```json
117
+ {
118
+ "musubi": "2026-11-21",
119
+ "follows": {
120
+ "japanese-writing/rules": {
121
+ "version": "^1.0.0",
122
+ "integrity": "sha256-yNSwpBT+xXEV5bGBqedpHmjWIHVi+JaAnRATAJ0s7wM=",
123
+ "optional": true,
124
+ "when": { "languages": ["ja"] }
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
112
130
  A consumer may add its own sections to the content it follows.
113
131
  It may not remove or rename what the provider's check requires.
114
132
  A skill may both provide content and follow content; a provider's format may follow shared writing rules, for example.
@@ -134,6 +152,41 @@ When two folders hold a skill of the same name, the first folder in that order w
134
152
  Agents read a content file whole, so `musubi check` warns when one is over 500 lines, the length Agent Skills suggests for `SKILL.md`.
135
153
  It does not refuse such content; a provider splits a long content into several.
136
154
 
155
+ ## Installing
156
+
157
+ Installing a skill also installs the skills it follows, so that a consumer finds its providers in every agent, including agents without a field like Claude Code plugin `dependencies` (decision record [0008](../docs/adr/0008-install-follows-from-named-sources.md)).
158
+ An installer, `musubi install` or another, reads the consumer's `musubi.json` and decides what to install the same way.
159
+
160
+ 1. It installs the provider of every required follow.
161
+ 2. It installs the provider of an optional follow only when the user names that provider, or when a language the user gives has the same primary language as a tag in the follow's `when.languages`, so `ja-JP` matches `ja`.
162
+ 3. It does the same for each skill it installs, down the whole chain.
163
+ 4. It keeps a skill that is already installed as it is, and still follows that skill's follows.
164
+ 5. When the provider of a required follow is in no source, provides no content of that name, or provides a version outside the consumer's range, it installs nothing and names the follow.
165
+ 6. After installing, it runs `musubi check`, as described in Re-checking.
166
+
167
+ `musubi.json` never says where a skill comes from.
168
+ The user names the sources, and the installer finds each skill in them by its name, the way agents open a provider by name.
169
+
170
+ `musubi install` takes each source with `--from`: a folder, or a git repository URL that it clones with `git clone --depth 1` into a temporary folder and removes afterward.
171
+ In a source, every folder that holds `SKILL.md` is a skill named by its folder, at any depth outside `.git` and `node_modules`, and the first source that holds a skill wins.
172
+ A source that holds two skills of the same name is refused.
173
+ It copies each skill folder whole into the folder named with `--to`, or, without `--to`, into the first of `.claude/skills`, `.agents/skills`, `.github/skills`, and `.gemini/skills` that exists in the current folder.
174
+ A skill counts as installed when `musubi check` would find it: in that folder, or in the folders it reads without arguments.
175
+
176
+ ```bash
177
+ musubi install api-design --from ../skills --to .claude/skills
178
+ musubi install convey --from https://github.com/example/skills --lang ja --with design-doc
179
+ ```
180
+
181
+ | Option | Means |
182
+ |---|---|
183
+ | `--from <folder or git URL>` | A source. Given more than once, the sources are searched in order |
184
+ | `--to <skills folder>` | The folder to install into |
185
+ | `--with <skill>` | Installs the provider of an optional follow by name. It may be given more than once |
186
+ | `--lang <language tag>` | A language the user writes in, matched against `when.languages`. It may be given more than once |
187
+
188
+ `musubi install` exits with `0` when everything was installed and `musubi check` passed, `1` when it installed nothing because of a problem or `musubi check` found one, and `2` when it was called the wrong way.
189
+
137
190
  ## Versions and fingerprints
138
191
 
139
192
  A content version is `MAJOR.MINOR.PATCH`.
@@ -170,6 +223,7 @@ The definition itself is versioned by date.
170
223
  Each `musubi.json` and each check file names the date it follows in `musubi`, and `musubi check` reads every date it knows and refuses the others.
171
224
  The dates it knows are the folders under `schema/`.
172
225
  Definition version `2026-11-20` added `follows.<ref>.optional`; a `musubi.json` that names `2026-11-19` still passes and may not use it.
226
+ Definition version `2026-11-21` added `follows.<ref>.when`; a `musubi.json` that names `2026-11-20` still passes and may not use it.
173
227
 
174
228
  ## Re-checking
175
229
 
@@ -179,6 +233,7 @@ A consumer is checked again after a skill is installed, after a skill is updated
179
233
 
180
234
  - `musubi.json` is not valid JSON, has a field the definition does not know, or names a definition version it does not know
181
235
  - a version is not `MAJOR.MINOR.PATCH`, or a range is not one of the three forms
236
+ - a follow has `when` without `optional: true`, or `when` holds anything but a list of language tags in `languages`
182
237
  - a file, check, or example path leaves the skill folder or names a missing file
183
238
  - a check is not a JSON rules file
184
239
  - a consumer follows a skill that is not installed (except in an optional follow), or a content that skill does not provide
@@ -229,17 +284,19 @@ A new kind of rule is added by a new definition version.
229
284
 
230
285
  | System | What it does | How musubi relates |
231
286
  |---|---|---|
232
- | Skill installers (APM, npx skills, skillpm, and others) | Install skills and their dependencies, and lock versions | They own where a skill comes from. `musubi.json` names only the skill, the content, and the version, so the source is written once |
233
- | Claude Code plugin `dependencies` | Install the plugins a plugin depends on | Same as installers. Agents without such a field rely on the stop line in the consumer's body |
287
+ | Skill installers (APM, npx skills, skillpm, and others) | Install skills and their dependencies, and lock versions | They own where a skill comes from. `musubi.json` names only the skill, the content, and the version, so the source is written once. An installer that reads `musubi.json` installs the providers as described in Installing |
288
+ | Claude Code plugin `dependencies` | Install the plugins a plugin depends on | Same as installers. In agents without such a field, `musubi install` installs the providers; when nothing installed them, the stop line in the consumer's body stops the agent |
234
289
  | Agent Skills | Defines `SKILL.md` and the skill folder | `SKILL.md` is unchanged and `musubi.json` is one more file in the folder. musubi is to be proposed to Agent Skills once it runs on real skills |
235
290
  | Agent Skills proposals for dependency files and lockfiles | Declare which skills a skill needs | They say which skill to install. musubi says which content of it a skill follows, at which version, and checks it again |
236
291
 
237
292
  ## The musubi command
238
293
 
239
294
  The command needs Node.js 22.18 or later and has no runtime dependencies.
295
+ `musubi install` runs `git` only to clone a source given as a git URL.
240
296
 
241
297
  | Command | Does |
242
298
  |---|---|
243
299
  | `musubi check [<folder>...] [--update]` | Checks every `musubi.json` in the folders, as described in Re-checking |
244
- | `musubi add <skill>/<content> [<folder>...] [--optional]` | Run in a consumer's folder: writes the range `^<current version>` and the fingerprint into its `musubi.json`, keeps the fields already there, and prints the three lines for its `SKILL.md`. With `--optional` it also writes `optional: true`, moves `musubi` to the latest definition version when the file names one without `optional`, and prints the three lines for an optional follow |
300
+ | `musubi add <skill>/<content> [<folder>...] [--optional [--lang <language>]...]` | Run in a consumer's folder: writes the range `^<current version>` and the fingerprint into its `musubi.json`, keeps the fields already there, and prints the three lines for its `SKILL.md`. With `--optional` it also writes `optional: true` and prints the three lines for an optional follow, and `--lang` writes `when.languages`. When the file names a definition version that does not know a field it writes, it moves `musubi` to the earliest definition version that does |
301
+ | `musubi install <skill>... --from <source>... [--to <folder>] [--with <skill>]... [--lang <language>]...` | Installs the skills and the providers they follow, as described in Installing, then runs `musubi check` |
245
302
  | `musubi graph [<folder>...] [--out <file>]` | Writes one HTML page that draws each skill and an arrow to each content it follows |