musubi-cli 0.1.0 → 0.2.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
@@ -1,21 +1,42 @@
1
- # musubi
1
+ <p align="center">
2
+ <img src="site/assets/icon.svg" width="88" height="88" alt="">
3
+ </p>
2
4
 
3
- musubiは、あるエージェントのスキルの中身を、別のスキルと結ぶための提案です。
5
+ <h1 align="center">musubi</h1>
4
6
 
5
- スキルを入れる道具は既にあり、依存するスキルも一緒に入れて版を固定できます。
6
- ただし、使う側のスキルが依存先のどの中身に従うのかは、どの道具にも残りません。
7
- 中身とは、書く文書の書式、守る書き方の決まり、回す検査のことです。
8
- musubiでは、スキルが出す中身を名前と版で宣言し、別のスキルがその中身に従うと宣言します。
9
- スキルを使う時には、エージェントがその中身を読み込みます。
7
+ <p align="center">スキルが提供するコンテンツとそれに準拠するスキルを結ぶ</p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/musubi-cli"><img src="https://img.shields.io/npm/v/musubi-cli" alt="npmのバージョン"></a>
11
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MITライセンス"></a>
12
+ <a href="https://www.npmjs.com/package/musubi-cli"><img src="https://img.shields.io/node/v/musubi-cli" alt="Node.jsのバージョン"></a>
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://musubi.cardene.dev/ja/">サイト</a> · <a href="spec/musubi.ja.md">定義</a> · <a href="README.md">English</a>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <img src="docs/assets/binding.svg" width="720" alt="design-docがdesign 1.0.0を提供し、contract-designとdapp-architectureとwallet-designが^1.0.0で準拠する">
21
+ </p>
22
+
23
+ musubiは、あるエージェントのスキルのコンテンツを、別のスキルと結び付けるための提案です。
24
+
25
+ エージェントのスキルのパッケージマネージャーは既にあり、スキルを依存するスキルと一緒にインストールして、バージョンを固定できます。
26
+ ただし、スキルが依存先のどの部分に準拠するのかは記録しません。
27
+ その部分とは、書く文書の書式や、守る書き方のルールや、実行するチェックのことです。
28
+ musubiでは、スキルが提供するコンテンツを名前とバージョン付きで宣言し、別のスキルがそのコンテンツに準拠すると宣言します。
29
+
30
+ スキルを実行する時は、エージェントがそのコンテンツを読み込みます。
10
31
  この動きは、`SKILL.md`を読むどのエージェントでも同じです。
11
- 出す側の中身が変わると、従う側のスキルを確かめ直します。
32
+ 提供するコンテンツが変わると、準拠するスキルが再チェックされます。
12
33
 
13
- 定義は[spec/musubi.ja.md](spec/musubi.ja.md)に在ります。
34
+ 定義は[spec/musubi.ja.md](spec/musubi.ja.md)にあります。
14
35
 
15
- ## スキルの加わり方
36
+ ## スキルが参加する方法
16
37
 
17
- スキルは`SKILL.md`をそのまま持ち、その横に`musubi.json`を足します。
18
- 出す側は、出す中身を並べます。
38
+ スキルは`SKILL.md`をそのまま持ち、その隣に`musubi.json`を追加します。
39
+ providerは、提供するコンテンツを並べます。
19
40
 
20
41
  ```json
21
42
  {
@@ -26,7 +47,7 @@ musubiでは、スキルが出す中身を名前と版で宣言し、別のス
26
47
  }
27
48
  ```
28
49
 
29
- 使う側は、従う中身と、従える版と、最後に確かめた中身の指紋を並べます。
50
+ consumerは、準拠するコンテンツと、受け入れるバージョンと、最後にチェックしたコンテンツのフィンガープリントを並べます。
30
51
 
31
52
  ```json
32
53
  {
@@ -41,15 +62,17 @@ musubiでは、スキルが出す中身を名前と版で宣言し、別のス
41
62
  }
42
63
  ```
43
64
 
44
- 使う側の`SKILL.md`の本文は、`design-doc`のスキルを名前で開いて`design`の書式を読むようエージェントに伝えます。
45
- そのため、エージェントは新しい仕組みを持たずに中身を読み込めます。
46
- 2つのスキルは[examples/skills](examples/skills)に在ります。
65
+ consumerの`SKILL.md`の本文は、`design-doc`のスキルを名前で開いて`design`の書式を読むよう、エージェントに伝えます。
66
+ そのため、エージェントは新しい仕組みがなくてもコンテンツを読み込めます。
67
+ providerが無くても動くconsumerは、定義のバージョン`2026-11-20`を書き、準拠に`"optional": true`を足します。
68
+ するとエージェントは、providerがインストールされていない時にそのコンテンツ無しで作業を続けます。
69
+ 2つのスキルは[examples/skills](examples/skills)にあります。
47
70
 
48
- ## 確かめ方
71
+ ## チェック
49
72
 
50
- `musubi`の命令は宣言を確かめ、出す側の検査を使う側の例に回します。
73
+ `musubi`コマンドは宣言をチェックし、providerのチェックをconsumerの例に適用します。
51
74
  Node.js 22.18以降で動き、実行時の依存を持ちません。
52
- npmには`musubi-cli`の名前で出ており、入れた後はプロジェクトのフォルダで回します。
75
+ npmに`musubi-cli`として公開しており、インストールした後はプロジェクトのフォルダで実行します。
53
76
 
54
77
  ```bash
55
78
  npm install -g musubi-cli
@@ -57,10 +80,10 @@ musubi check
57
80
  musubi graph --out graph.html
58
81
  ```
59
82
 
60
- フォルダを渡さない時、`musubi check`は今のフォルダとホームのフォルダの`.claude/skills`、`.agents/skills`、`.github/skills`、`.gemini/skills`を読みます。
61
- 入れずに1回だけ回す時は、`npx musubi-cli check <スキルのフォルダ>`を使います。
83
+ フォルダを指定しない時、`musubi check`はカレントフォルダとホームフォルダにある`.claude/skills`、`.agents/skills`、`.github/skills`、`.gemini/skills`を読みます。
84
+ インストールせずに1回だけ実行する時は、`npx musubi-cli check <スキルのフォルダ>`を使います。
62
85
 
63
- このrepoを手元に写して回す時は、先に開発の依存を入れます。
86
+ このリポジトリをクローンして実行する時は、先に開発用の依存をインストールします。
64
87
 
65
88
  ```bash
66
89
  pnpm install
@@ -68,12 +91,47 @@ node src/cli.ts check examples/skills
68
91
  node src/cli.ts graph examples/skills --out graph.html
69
92
  ```
70
93
 
94
+ ## サイトにスキルを載せる
95
+
96
+ musubiのサイトは、定義と、GitHubで見つけたスキルを表示します。
97
+ スキルごとに、提供するコンテンツと、準拠するコンテンツと、そのスキルに準拠しているスキルが載ります。
98
+ スキルを載せる時は、スキルを置いた公開リポジトリに、GitHubのリポジトリの画面のAboutの設定でトピック`musubi-skills`を付けます。
99
+ PRは要りません。
100
+
101
+ サイトは更新するたびに、トピック`musubi-skills`を持つ公開リポジトリをGitHubで検索し、デフォルトブランチで`musubi.json`と`SKILL.md`が並ぶフォルダを全て載せます。
102
+ `musubi check`と同じチェックに通らない`musubi.json`を持つフォルダは、サイトをビルドする時にフォルダ名と理由を表示し、一覧から外します。
103
+
104
+ 管理者のスキルは、リポジトリごとに`registry/<owner>/<repo>.json`というファイルにも置き、載せるフォルダをリポジトリのルートからの相対パスで並べます。
105
+
106
+ ```json
107
+ {
108
+ "skills": ["plugins/doc-formats/skills/design-doc", "plugins/evm-dev/skills/contract-design"]
109
+ }
110
+ ```
111
+
112
+ `registry/excluded.json`には、サイトに載せない物を書きます。
113
+ リポジトリ全体は`<owner>/<repo>`、1つのフォルダは`<owner>/<repo>/<folder>`の形で並べます。
114
+
115
+ ```json
116
+ {
117
+ "excluded": ["someone/repo", "someone/other-repo/skills/old-skill"]
118
+ }
119
+ ```
120
+
121
+ サイトをビルドして手元の<http://localhost:3810/>で開く時は、`gh auth login`でログインしてから`pnpm site`を実行します。
122
+ このコマンドは`node site/build.ts`で、ログインしたghを使ってGitHubを検索し、ページを`site/dist/`に書き出してから、そのフォルダを配信します。
123
+ 公開したサイトは<https://musubi.cardene.dev/>にあり、`pnpm site:publish`で公開する手順は[docs/publishing.ja.md](docs/publishing.ja.md)にあります。
124
+
71
125
  ## 文書
72
126
 
73
- | 文書 | 持つ物 |
127
+ | 文書 | 内容 |
74
128
  |---|---|
75
129
  | [spec/musubi.ja.md](spec/musubi.ja.md) | 定義 |
76
- | [GLOSSARY.ja.md](GLOSSARY.ja.md) | 定義が使う語 |
77
- | [docs/adr](docs/adr) | 戻すのが高くつく判断と、採らなかった案 |
130
+ | [GLOSSARY.ja.md](GLOSSARY.ja.md) | 定義が使う用語 |
131
+ | [docs/publishing.ja.md](docs/publishing.ja.md) | サイトをGitHub Pagesへ公開する手順 |
132
+ | [docs/adr](docs/adr) | 元に戻すのが高くつく判断と、採らなかった案 |
133
+
134
+ ## ライセンス
78
135
 
79
- English: [README.md](README.md)
136
+ musubiはMITライセンスで公開しています。
137
+ 全文は[LICENSE](LICENSE)にあります。
package/README.md CHANGED
@@ -1,4 +1,24 @@
1
- # musubi
1
+ <p align="center">
2
+ <img src="site/assets/icon.svg" width="88" height="88" alt="">
3
+ </p>
4
+
5
+ <h1 align="center">musubi</h1>
6
+
7
+ <p align="center">Bind what one skill provides to the skills that follow it</p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/musubi-cli"><img src="https://img.shields.io/npm/v/musubi-cli" alt="npm version"></a>
11
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license"></a>
12
+ <a href="https://www.npmjs.com/package/musubi-cli"><img src="https://img.shields.io/node/v/musubi-cli" alt="Node.js version"></a>
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://musubi.cardene.dev/">Website</a> · <a href="spec/musubi.md">Definition</a> · <a href="README.ja.md">日本語</a>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <img src="docs/assets/binding.svg" width="720" alt="design-doc provides design 1.0.0, and contract-design, dapp-architecture, and wallet-design follow it at ^1.0.0">
21
+ </p>
2
22
 
3
23
  musubi is a proposal for binding the content of one agent skill to another.
4
24
 
@@ -39,6 +59,7 @@ A consumer lists the content it follows, the versions it accepts, and the finger
39
59
  ```
40
60
 
41
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
+ 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.
42
63
  [examples/skills](examples/skills) holds both skills.
43
64
 
44
65
  ## Checking
@@ -64,12 +85,44 @@ node src/cli.ts check examples/skills
64
85
  node src/cli.ts graph examples/skills --out graph.html
65
86
  ```
66
87
 
88
+ ## Listing a skill on the site
89
+
90
+ 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.
91
+ To list your skills, give their public repository the topic `musubi-skills` in the About settings of the repository page on GitHub.
92
+ No pull request is needed.
93
+
94
+ Each time the site is updated, it searches GitHub for public repositories with the topic `musubi-skills` and lists every folder on the default branch that holds both `musubi.json` and `SKILL.md`.
95
+ A folder whose `musubi.json` fails the checks `musubi check` runs is named with the reason when the site is built, and left out.
96
+
97
+ The maintainers' own skills are also named in `registry/<owner>/<repo>.json`, one file per repository, which lists the skill folders relative to the repository root.
98
+
99
+ ```json
100
+ {
101
+ "skills": ["plugins/doc-formats/skills/design-doc", "plugins/evm-dev/skills/contract-design"]
102
+ }
103
+ ```
104
+
105
+ `registry/excluded.json` names what the site leaves out: a whole repository as `<owner>/<repo>`, or one folder as `<owner>/<repo>/<folder>`.
106
+
107
+ ```json
108
+ {
109
+ "excluded": ["someone/repo", "someone/other-repo/skills/old-skill"]
110
+ }
111
+ ```
112
+
113
+ To build the site and open it on your machine at <http://localhost:3810/>, sign in with `gh auth login` and run `pnpm site`.
114
+ It runs `node site/build.ts`, which searches GitHub with your gh sign-in, writes the pages to `site/dist/`, and then serves that folder.
115
+ The public site is at <https://musubi.cardene.dev/>, and [docs/publishing.md](docs/publishing.md) explains how to publish it with `pnpm site:publish`.
116
+
67
117
  ## Documents
68
118
 
69
119
  | Document | Holds |
70
120
  |---|---|
71
121
  | [spec/musubi.md](spec/musubi.md) | The definition |
72
122
  | [GLOSSARY.md](GLOSSARY.md) | The terms the definition uses |
123
+ | [docs/publishing.md](docs/publishing.md) | How the site is published to GitHub Pages |
73
124
  | [docs/adr](docs/adr) | Decisions that are costly to reverse, with the options not taken |
74
125
 
75
- Japanese: [README.ja.md](README.ja.md)
126
+ ## License
127
+
128
+ musubi is released under the MIT License. The full text is in [LICENSE](LICENSE).
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 } from "./definition.js";
4
+ import { latestDefinition, optionalVersions } from "./definition.js";
5
5
  import { fingerprint } from "./fingerprint.js";
6
6
  import { isObject } from "./json.js";
7
7
  import { Report } from "./report.js";
@@ -10,20 +10,23 @@ import { fingerprintFiles } from "./skills.js";
10
10
  // Content files an agent runs rather than reads, told apart by their extension in any case.
11
11
  const SCRIPT = /\.(py|sh|bash|js|mjs|cjs|ts)$/i;
12
12
  // The three lines a consumer's SKILL.md body carries for one content it follows. The first line
13
- // tells the agent to run a script and to read anything else as a format.
14
- export function bodyLines(skill, content, file) {
15
- const use = SCRIPT.test(file)
16
- ? `Run the \`${content}\` of the \`${skill}\` skill: open the \`${skill}\` skill by name and run the file it names for \`${content}\`.`
17
- : `Write in the \`${content}\` format of the \`${skill}\` skill: open the \`${skill}\` skill by name and read the file it names for \`${content}\`.`;
13
+ // tells the agent to run a script and to read anything else as a format. For an optional follow the
14
+ // first line applies only when the provider is installed, and the last one goes on without it.
15
+ export function bodyLines(skill, content, file, optional = false) {
16
+ const how = SCRIPT.test(file)
17
+ ? `run the \`${content}\` of the \`${skill}\` skill: open the \`${skill}\` skill by name and run the file it names for \`${content}\`.`
18
+ : `write in the \`${content}\` format of the \`${skill}\` skill: open the \`${skill}\` skill by name and read the file it names for \`${content}\`.`;
18
19
  return [
19
- use,
20
+ optional ? `When the \`${skill}\` skill is installed, ${how}` : how[0].toUpperCase() + how.slice(1),
20
21
  "If the `musubi` command is available, run `musubi check` before reading, and stop if it fails.",
21
- `If the \`${skill}\` skill is not installed, do not start: tell the user that \`${skill}\` is missing and how to install it, then stop.`,
22
+ optional
23
+ ? `If the \`${skill}\` skill is not installed, go on without the \`${content}\` of \`${skill}\`.`
24
+ : `If the \`${skill}\` skill is not installed, do not start: tell the user that \`${skill}\` is missing and how to install it, then stop.`,
22
25
  ];
23
26
  }
24
27
  // Run in a consumer skill's folder: writes the range and the fingerprint of one content into its
25
28
  // musubi.json and prints the lines to put in its SKILL.md body.
26
- export function add(ref, roots, cwd) {
29
+ export function add(ref, roots, cwd, optional = false) {
27
30
  const report = new Report(cwd);
28
31
  const fail = (message) => {
29
32
  report.print();
@@ -52,17 +55,21 @@ export function add(ref, roots, cwd) {
52
55
  return fail("musubi.json holds something other than one JSON object");
53
56
  json = current;
54
57
  }
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;
55
61
  const follows = isObject(json.follows) ? json.follows : {};
56
- // Keep fields the consumer already wrote, such as examples, after the two this command owns.
57
- const { version: _version, integrity: _integrity, ...kept } = isObject(follows[ref]) ? follows[ref] : {};
62
+ // 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] : {};
58
64
  follows[ref] = {
59
65
  version: `^${format(provided.version)}`,
60
66
  integrity: fingerprint(provider.dir, fingerprintFiles(provided)),
67
+ ...(optional ? { optional: true } : {}),
61
68
  ...kept,
62
69
  };
63
70
  json.follows = follows;
64
71
  writeFileSync(path, `${JSON.stringify(json, null, 2)}\n`);
65
72
  process.stderr.write(`musubi add: wrote ${ref} ^${format(provided.version)} to ${basename(cwd)}/musubi.json\n`);
66
- process.stdout.write(`${bodyLines(skillName, content, provided.file).join("\n")}\n`);
73
+ process.stdout.write(`${bodyLines(skillName, content, provided.file, optional).join("\n")}\n`);
67
74
  return 0;
68
75
  }
package/dist/check.js CHANGED
@@ -56,6 +56,10 @@ export function check(roots, cwd, update) {
56
56
  for (const follow of declaration.follows) {
57
57
  follows += 1;
58
58
  const provider = skills.get(follow.skill);
59
+ if (!provider && follow.optional) {
60
+ report.warn(`${consumer} follows ${follow.ref} only when ${follow.skill} is installed; it is not, so this follow was skipped`);
61
+ continue;
62
+ }
59
63
  if (!provider) {
60
64
  report.problem(declaration.path, follow.line, `${consumer} follows ${follow.ref}, but no skill named ${follow.skill} is installed`);
61
65
  continue;
package/dist/cli.js CHANGED
@@ -10,8 +10,9 @@ const USAGE = `usage:
10
10
  Checks every musubi.json in the folders. Without folders it reads .claude/skills, .agents/skills,
11
11
  .github/skills, and .gemini/skills in this folder and in the home folder.
12
12
  --update rewrites a fingerprint after its content passes the check again.
13
- musubi add <skill>/<content> [<skills folder>...]
13
+ musubi add <skill>/<content> [<skills folder>...] [--optional]
14
14
  Run in a skill's folder: makes the skill follow the content and prints the lines for its SKILL.md.
15
+ --optional makes the follow optional: the skill reads the content only when the provider is installed.
15
16
  musubi graph [<skills folder>...] [--out <file>]
16
17
  Writes an HTML page of the skills and the contents they follow (default musubi-graph.html).
17
18
  `;
@@ -29,7 +30,7 @@ function main(argv) {
29
30
  else if (!rest[i].startsWith("--"))
30
31
  positional.push(rest[i]);
31
32
  }
32
- const unknown = [...flags].filter((flag) => !(command === "check" && flag === "--update") && !(command === "graph" && flag === "--out"));
33
+ const unknown = [...flags].filter((flag) => !(command === "check" && flag === "--update") && !(command === "graph" && flag === "--out") && !(command === "add" && flag === "--optional"));
33
34
  if (command === "--help" || command === "-h") {
34
35
  process.stdout.write(USAGE);
35
36
  return 0;
@@ -46,7 +47,7 @@ function main(argv) {
46
47
  const [ref, ...given] = positional;
47
48
  if (!ref)
48
49
  break;
49
- return add(ref, roots(given, [resolve(cwd, "..")]), cwd);
50
+ return add(ref, roots(given, [resolve(cwd, "..")]), cwd, flags.has("--optional"));
50
51
  }
51
52
  case "graph":
52
53
  return graph(roots(positional), resolve(cwd, out), cwd);
@@ -1,4 +1,4 @@
1
- import { readdirSync } from "node:fs";
1
+ import { readdirSync, readFileSync } from "node:fs";
2
2
  import { fileURLToPath } from "node:url";
3
3
  // The definition versions this command reads are the dated folders under schema/, so the dates
4
4
  // live in one place. The folder sits next to src/ in the repository and next to dist/ when installed.
@@ -7,5 +7,11 @@ 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
16
  // Agents read a content file whole; Agent Skills suggests keeping SKILL.md under this many lines.
11
17
  export const READ_LINES = 500;