cs-plugin 0.1.5__tar.gz

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.
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: cs-plugin
3
+ Version: 0.1.5
4
+ Summary: Pin a project's Claude Code plugins, from any number of plugin repos, in one plugins.toml; generate the project's own marketplace from it, and install exactly that.
5
+ Author: Cellular Semantics
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/ubyndr/cs-plugin
8
+ Project-URL: Repository, https://github.com/ubyndr/cs-plugin
9
+ Project-URL: Issues, https://github.com/ubyndr/cs-plugin/issues
10
+ Keywords: claude-code,claude,plugins,marketplace,version-pinning
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest>=8.0; extra == "test"
25
+
26
+ # cs-plugin
27
+
28
+ Pin a project's Claude Code plugins in one `plugins.toml`, like `pyproject.toml`,
29
+ from any number of plugin repos, and install exactly that.
30
+
31
+ Two projects on one machine can use different releases of the same plugin, and a
32
+ teammate's whole setup after cloning is one command.
33
+
34
+ ```sh
35
+ uvx cs-plugin list # what is available
36
+ uvx cs-plugin add cap-tools remote-h5ad-obs # pin the newest releases
37
+ uvx cs-plugin sync # install them in this project
38
+ ```
39
+
40
+ Needs [uv](https://docs.astral.sh/uv/) (or `pipx run cs-plugin`), `git`, and
41
+ Claude Code for `sync`. `uv tool install cs-plugin` puts `cs-plugin` on your PATH
42
+ so you can drop the `uvx`.
43
+
44
+ ## See what is available
45
+
46
+ ```sh
47
+ cs-plugin list # every plugin in the source repos, and its newest release
48
+ cs-plugin list -l # with descriptions
49
+ cs-plugin versions cap-tools # every release of one plugin, newest first
50
+ cs-plugin versions -l cap-tools # with a link to each release
51
+ cs-plugin sources # which repos those are
52
+ ```
53
+
54
+ Plugins are read live from each source repo's own
55
+ `.claude-plugin/marketplace.json`, and releases from its `<plugin>--v<version>`
56
+ tags (what `claude plugin tag` writes). A release anywhere shows up at once.
57
+ `versions` marks the release this project pins, and works before you `add`,
58
+ so you can pick an older release to pin with `cs-plugin add NAME@VERSION`.
59
+
60
+ ## Set up a project
61
+
62
+ From the project's root:
63
+
64
+ ```sh
65
+ cs-plugin add cap-tools remote-h5ad-obs # newest releases
66
+ cs-plugin add onto-mapping@0.5.0 # or a specific one
67
+ cs-plugin sync # install them
68
+ git add plugins.toml .claude .gitignore && git commit -m "Pin Claude Code plugins"
69
+ ```
70
+
71
+ `plugins.toml` is the file you read and edit:
72
+
73
+ ```toml
74
+ [project]
75
+ name = "cap-report-hacking"
76
+
77
+ [plugins]
78
+ cap-tools = "0.4.1"
79
+ remote-h5ad-obs = "0.3.0"
80
+ ```
81
+
82
+ A plugin with no release tags can be pinned to a commit instead, and a plugin
83
+ in no source repo by its repo:
84
+
85
+ ```toml
86
+ some-plugin = { sha = "22a10275db2768304021549cd8300bc05a704b42" }
87
+ other = { repo = "someone/their-plugins", path = "plugins/other", version = "1.2.0" }
88
+ ```
89
+
90
+ To read plugins from other repos than the defaults, list them all (this replaces
91
+ the defaults; `owner/name@ref` reads a branch or tag instead of the default
92
+ branch):
93
+
94
+ ```toml
95
+ [sources]
96
+ repos = ["Cellular-Semantics/cap_skills", "your-org/your-plugins"]
97
+ ```
98
+
99
+ After editing `plugins.toml` by hand, run `cs-plugin generate`.
100
+
101
+ ## After cloning, or pulling a change to plugins.toml
102
+
103
+ ```sh
104
+ cs-plugin sync
105
+ ```
106
+
107
+ Then restart Claude Code in the project. `sync` reads no source repo: everything
108
+ it installs is already written in the committed files.
109
+
110
+ ## Keep up to date
111
+
112
+ ```sh
113
+ cs-plugin outdated # pins with a newer release
114
+ cs-plugin upgrade # move every pin to the newest release
115
+ cs-plugin upgrade cap-tools # or just one
116
+ cs-plugin remove cap-tools # sync then uninstalls it here
117
+ ```
118
+
119
+ Each of these rewrites the generated files; run `sync`, then commit.
120
+
121
+ ## What it writes, and why
122
+
123
+ | File | What it is |
124
+ |---|---|
125
+ | `plugins.toml` | what you edit |
126
+ | `.claude/cs-plugin/.claude-plugin/marketplace.json` | the project's own marketplace, `<project>-plugins`: one entry per plugin, its `source` pinned to the release tag |
127
+ | `.claude/cs-plugin/<project>-set/` | a bundle plugin that depends on every pinned plugin, so one install brings in all of them |
128
+ | `.claude/settings.json` | declares the marketplace and enables its plugins; other settings are left alone |
129
+ | `.gitignore` | gains `.claude/settings.local.json`, where `sync` records this machine's path |
130
+
131
+ **A marketplace per project.** Claude Code keeps one registration per
132
+ marketplace name per machine. Pinning by putting a `ref` on a shared marketplace
133
+ means every project on the machine gets whichever pin registered last. A
134
+ marketplace named after the project is that project's alone.
135
+
136
+ **Pins on the entries, not version ranges.** Claude Code clones a marketplace
137
+ without its tags, so a dependency range like `~0.4.0` has nothing to resolve
138
+ against and silently installs the newest release (Claude Code 2.1.305).
139
+
140
+ **Bundles are refused.** A plugin such as `atlas-tools` that only depends on
141
+ others names their marketplace, so they would install from it unpinned and
142
+ shared. `add` refuses it and names the plugins to add instead.
143
+
144
+ **Browsing inside Claude Code.** Each source repo is itself a marketplace:
145
+ `claude plugin marketplace add Cellular-Semantics/cap_skills` lets `/plugin`
146
+ show its plugins. Browse there, but install with `cs-plugin`; installing from
147
+ the shared marketplace gives an unpinned plugin, shared by every project.
@@ -0,0 +1,122 @@
1
+ # cs-plugin
2
+
3
+ Pin a project's Claude Code plugins in one `plugins.toml`, like `pyproject.toml`,
4
+ from any number of plugin repos, and install exactly that.
5
+
6
+ Two projects on one machine can use different releases of the same plugin, and a
7
+ teammate's whole setup after cloning is one command.
8
+
9
+ ```sh
10
+ uvx cs-plugin list # what is available
11
+ uvx cs-plugin add cap-tools remote-h5ad-obs # pin the newest releases
12
+ uvx cs-plugin sync # install them in this project
13
+ ```
14
+
15
+ Needs [uv](https://docs.astral.sh/uv/) (or `pipx run cs-plugin`), `git`, and
16
+ Claude Code for `sync`. `uv tool install cs-plugin` puts `cs-plugin` on your PATH
17
+ so you can drop the `uvx`.
18
+
19
+ ## See what is available
20
+
21
+ ```sh
22
+ cs-plugin list # every plugin in the source repos, and its newest release
23
+ cs-plugin list -l # with descriptions
24
+ cs-plugin versions cap-tools # every release of one plugin, newest first
25
+ cs-plugin versions -l cap-tools # with a link to each release
26
+ cs-plugin sources # which repos those are
27
+ ```
28
+
29
+ Plugins are read live from each source repo's own
30
+ `.claude-plugin/marketplace.json`, and releases from its `<plugin>--v<version>`
31
+ tags (what `claude plugin tag` writes). A release anywhere shows up at once.
32
+ `versions` marks the release this project pins, and works before you `add`,
33
+ so you can pick an older release to pin with `cs-plugin add NAME@VERSION`.
34
+
35
+ ## Set up a project
36
+
37
+ From the project's root:
38
+
39
+ ```sh
40
+ cs-plugin add cap-tools remote-h5ad-obs # newest releases
41
+ cs-plugin add onto-mapping@0.5.0 # or a specific one
42
+ cs-plugin sync # install them
43
+ git add plugins.toml .claude .gitignore && git commit -m "Pin Claude Code plugins"
44
+ ```
45
+
46
+ `plugins.toml` is the file you read and edit:
47
+
48
+ ```toml
49
+ [project]
50
+ name = "cap-report-hacking"
51
+
52
+ [plugins]
53
+ cap-tools = "0.4.1"
54
+ remote-h5ad-obs = "0.3.0"
55
+ ```
56
+
57
+ A plugin with no release tags can be pinned to a commit instead, and a plugin
58
+ in no source repo by its repo:
59
+
60
+ ```toml
61
+ some-plugin = { sha = "22a10275db2768304021549cd8300bc05a704b42" }
62
+ other = { repo = "someone/their-plugins", path = "plugins/other", version = "1.2.0" }
63
+ ```
64
+
65
+ To read plugins from other repos than the defaults, list them all (this replaces
66
+ the defaults; `owner/name@ref` reads a branch or tag instead of the default
67
+ branch):
68
+
69
+ ```toml
70
+ [sources]
71
+ repos = ["Cellular-Semantics/cap_skills", "your-org/your-plugins"]
72
+ ```
73
+
74
+ After editing `plugins.toml` by hand, run `cs-plugin generate`.
75
+
76
+ ## After cloning, or pulling a change to plugins.toml
77
+
78
+ ```sh
79
+ cs-plugin sync
80
+ ```
81
+
82
+ Then restart Claude Code in the project. `sync` reads no source repo: everything
83
+ it installs is already written in the committed files.
84
+
85
+ ## Keep up to date
86
+
87
+ ```sh
88
+ cs-plugin outdated # pins with a newer release
89
+ cs-plugin upgrade # move every pin to the newest release
90
+ cs-plugin upgrade cap-tools # or just one
91
+ cs-plugin remove cap-tools # sync then uninstalls it here
92
+ ```
93
+
94
+ Each of these rewrites the generated files; run `sync`, then commit.
95
+
96
+ ## What it writes, and why
97
+
98
+ | File | What it is |
99
+ |---|---|
100
+ | `plugins.toml` | what you edit |
101
+ | `.claude/cs-plugin/.claude-plugin/marketplace.json` | the project's own marketplace, `<project>-plugins`: one entry per plugin, its `source` pinned to the release tag |
102
+ | `.claude/cs-plugin/<project>-set/` | a bundle plugin that depends on every pinned plugin, so one install brings in all of them |
103
+ | `.claude/settings.json` | declares the marketplace and enables its plugins; other settings are left alone |
104
+ | `.gitignore` | gains `.claude/settings.local.json`, where `sync` records this machine's path |
105
+
106
+ **A marketplace per project.** Claude Code keeps one registration per
107
+ marketplace name per machine. Pinning by putting a `ref` on a shared marketplace
108
+ means every project on the machine gets whichever pin registered last. A
109
+ marketplace named after the project is that project's alone.
110
+
111
+ **Pins on the entries, not version ranges.** Claude Code clones a marketplace
112
+ without its tags, so a dependency range like `~0.4.0` has nothing to resolve
113
+ against and silently installs the newest release (Claude Code 2.1.305).
114
+
115
+ **Bundles are refused.** A plugin such as `atlas-tools` that only depends on
116
+ others names their marketplace, so they would install from it unpinned and
117
+ shared. `add` refuses it and names the plugins to add instead.
118
+
119
+ **Browsing inside Claude Code.** Each source repo is itself a marketplace:
120
+ `claude plugin marketplace add Cellular-Semantics/cap_skills` lets `/plugin`
121
+ show its plugins. Browse there, but install with `cs-plugin`; installing from
122
+ the shared marketplace gives an unpinned plugin, shared by every project.
@@ -0,0 +1,44 @@
1
+ [project]
2
+ name = "cs-plugin"
3
+ version = "0.1.5"
4
+ description = "Pin a project's Claude Code plugins, from any number of plugin repos, in one plugins.toml; generate the project's own marketplace from it, and install exactly that."
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = { text = "MIT" }
8
+ authors = [{ name = "Cellular Semantics" }]
9
+ keywords = ["claude-code", "claude", "plugins", "marketplace", "version-pinning"]
10
+ classifiers = [
11
+ "Development Status :: 3 - Alpha",
12
+ "Environment :: Console",
13
+ "Intended Audience :: Developers",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Topic :: Software Development",
21
+ ]
22
+ # Standard library only: it runs through `uvx` on every teammate's machine, and
23
+ # shells out to `git` and `claude` for everything that touches a repo.
24
+ dependencies = []
25
+
26
+ [project.optional-dependencies]
27
+ test = [
28
+ "pytest>=8.0",
29
+ ]
30
+
31
+ [project.scripts]
32
+ cs-plugin = "cs_plugin.cli:main"
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/ubyndr/cs-plugin"
36
+ Repository = "https://github.com/ubyndr/cs-plugin"
37
+ Issues = "https://github.com/ubyndr/cs-plugin/issues"
38
+
39
+ [build-system]
40
+ requires = ["setuptools>=68.0"]
41
+ build-backend = "setuptools.build_meta"
42
+
43
+ [tool.setuptools.packages.find]
44
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """Pin a project's Claude Code plugins in plugins.toml, and install exactly that."""
2
+
3
+ __version__ = "0.1.5"
@@ -0,0 +1,32 @@
1
+ """Running Claude Code's own `claude plugin` commands: the only code that does."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import shutil
7
+ import subprocess
8
+ from pathlib import Path
9
+
10
+ from . import project
11
+
12
+
13
+ def available() -> bool:
14
+ return shutil.which("claude") is not None
15
+
16
+
17
+ def run(*args: str) -> subprocess.CompletedProcess:
18
+ out = subprocess.run(["claude", *args], capture_output=True, text=True)
19
+ if out.returncode != 0:
20
+ raise project.ProjectError(f"claude {' '.join(args)} failed:\n{out.stdout}{out.stderr}")
21
+ return out
22
+
23
+
24
+ def installed(cfg: project.Config, root: Path) -> dict[str, str]:
25
+ """Plugin -> version, for this project's plugins installed in this project."""
26
+ rows = json.loads(run("plugin", "list", "--json").stdout or "[]")
27
+ here = str(root.resolve())
28
+ suffix = f"@{cfg.marketplace}"
29
+ return {r["id"][: -len(suffix)]: r.get("version", "")
30
+ for r in rows
31
+ if r.get("id", "").endswith(suffix) and r.get("scope") == "project"
32
+ and str(Path(r.get("projectPath", "")).resolve()) == here}
@@ -0,0 +1,233 @@
1
+ """cs-plugin: pin a project's Claude Code plugins in plugins.toml, install exactly that.
2
+
3
+ cs-plugin list every plugin in the sources, with releases
4
+ cs-plugin versions NAME every release of one plugin
5
+ cs-plugin add NAME[@VERSION]... pin plugins (newest release by default)
6
+ cs-plugin remove NAME... drop plugins
7
+ cs-plugin upgrade [NAME...] move pins to the newest release
8
+ cs-plugin outdated pins with a newer release
9
+ cs-plugin generate rewrite the generated files from plugins.toml
10
+ cs-plugin sync install exactly what plugins.toml pins
11
+ cs-plugin sources the repos plugins are read from
12
+
13
+ Run from the project's root. Which plugins exist is read live from the source
14
+ repos' own marketplaces: plugins.toml [sources], or the defaults. add, remove
15
+ and upgrade regenerate the files Claude Code reads; sync is what a teammate runs
16
+ after cloning, and after every pull that changes plugins.toml.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import argparse
22
+ import sys
23
+ from pathlib import Path
24
+
25
+ from . import __version__, claude, project, releases, remote, sources
26
+
27
+
28
+ def _index(cfg: project.Config) -> dict[str, dict]:
29
+ return sources.index(cfg.repos, remote.read_json)
30
+
31
+
32
+ def cmd_list(args: argparse.Namespace) -> int:
33
+ cfg = project.load(Path.cwd())
34
+ cat = _index(cfg)
35
+ found = releases.newest_first(list(cat.values()))
36
+ width = max(map(len, cat), default=0)
37
+ for name in sorted(cat):
38
+ rel = found[name]
39
+ newest = rel[0] if rel else ("no releases" if rel is not None else "not git")
40
+ mark = "*" if name in cfg.plugins else " "
41
+ clash = f" (also in {', '.join(cat[name]['also_in'])})" if cat[name].get("also_in") else ""
42
+ print(f"{mark} {name:<{width}} {newest:<12} {cat[name]['repo']}{clash}")
43
+ if args.long and cat[name].get("description"):
44
+ print(f" {'':<{width}} {cat[name]['description']}")
45
+ if cfg.plugins:
46
+ print(f"\n* pinned in {project.CONFIG}")
47
+ return 0
48
+
49
+
50
+ def cmd_versions(args: argparse.Namespace) -> int:
51
+ cfg = project.load(Path.cwd())
52
+ cat = _index(cfg)
53
+ name = args.plugin
54
+ spec = cfg.plugins.get(name, {})
55
+ source, repo = releases.source_of(name, spec, cat)
56
+ found = releases.released(name, source)
57
+ pinned = spec.get("version")
58
+ rows = []
59
+ for v in found:
60
+ notes = ["newest"] if v == found[0] else []
61
+ if v == pinned:
62
+ notes.append(f"pinned in {project.CONFIG}")
63
+ link = (remote.release_url(source, name, v) or "") if args.long else ""
64
+ rows.append((v, ", ".join(notes), link))
65
+ vw = max(len(v) for v, _, _ in rows)
66
+ nw = max(len(n) for _, n, _ in rows)
67
+ print(f"{name} ({repo})")
68
+ for v, notes, link in rows:
69
+ print(f" {v:<{vw}} {notes:<{nw}} {link}".rstrip())
70
+ if pinned and pinned not in found:
71
+ print(f"\npinned in {project.CONFIG} to {pinned}, which is not a release")
72
+ for k in ("ref", "sha"):
73
+ if k in spec:
74
+ print(f"\npinned in {project.CONFIG} to {k} {spec[k]}, not a release")
75
+ return 0
76
+
77
+
78
+ def _write(cfg: project.Config, cat: dict[str, dict]) -> None:
79
+ root = Path.cwd()
80
+ project.save(root, cfg)
81
+ for path in project.generate(root, cfg, cat):
82
+ print(f"wrote {path.relative_to(root)}")
83
+ print(f"Next: `cs-plugin sync` to install, then commit {project.CONFIG} and .claude/.")
84
+
85
+
86
+ def cmd_add(args: argparse.Namespace) -> int:
87
+ cfg = project.load(Path.cwd())
88
+ cat = _index(cfg)
89
+ for item in args.plugins:
90
+ name, _, version = item.partition("@")
91
+ spec = cfg.plugins.get(name, {})
92
+ version = releases.resolve(name, version or None, cat, spec)
93
+ old = spec.get("version")
94
+ cfg.plugins[name] = project.repinned(spec, version)
95
+ print(f"{name} {old + ' -> ' if old and old != version else ''}{version}")
96
+ _write(cfg, cat)
97
+ return 0
98
+
99
+
100
+ def cmd_remove(args: argparse.Namespace) -> int:
101
+ cfg = project.load(Path.cwd())
102
+ missing = [n for n in args.plugins if n not in cfg.plugins]
103
+ if missing:
104
+ raise project.ProjectError(f"not in {project.CONFIG}: {', '.join(missing)}")
105
+ for name in args.plugins:
106
+ del cfg.plugins[name]
107
+ print(f"removed {name}")
108
+ _write(cfg, _index(cfg))
109
+ print("`cs-plugin sync` also uninstalls them from this project.")
110
+ return 0
111
+
112
+
113
+ def cmd_outdated(args: argparse.Namespace) -> int:
114
+ cfg = project.load(Path.cwd())
115
+ behind = releases.behind(cfg, _index(cfg), None)
116
+ for name, have, newest in behind:
117
+ print(f"{name} {have} -> {newest}")
118
+ unversioned = [n for n, s in cfg.plugins.items() if "version" not in s]
119
+ if unversioned:
120
+ print(f"pinned to a ref or commit, not checked: {', '.join(sorted(unversioned))}")
121
+ if not behind:
122
+ print("every versioned pin is the newest release")
123
+ return 0
124
+
125
+
126
+ def cmd_upgrade(args: argparse.Namespace) -> int:
127
+ cfg = project.load(Path.cwd())
128
+ unknown = [n for n in args.plugins if n not in cfg.plugins]
129
+ if unknown:
130
+ raise project.ProjectError(f"not in {project.CONFIG}: {', '.join(unknown)}")
131
+ cat = _index(cfg)
132
+ behind = releases.behind(cfg, cat, args.plugins or None)
133
+ for name, have, newest in behind:
134
+ cfg.plugins[name] = project.repinned(cfg.plugins[name], newest)
135
+ print(f"{name} {have} -> {newest}")
136
+ if not behind:
137
+ print("already at the newest releases")
138
+ return 0
139
+ _write(cfg, cat)
140
+ return 0
141
+
142
+
143
+ def cmd_generate(args: argparse.Namespace) -> int:
144
+ root = Path.cwd()
145
+ cfg = project.load(root)
146
+ changed = project.generate(root, cfg, _index(cfg))
147
+ for path in changed:
148
+ print(f"wrote {path.relative_to(root)}")
149
+ if not changed:
150
+ print("generated files are current")
151
+ return 0
152
+
153
+
154
+ def cmd_sync(args: argparse.Namespace) -> int:
155
+ root = Path.cwd()
156
+ if not claude.available():
157
+ raise project.ProjectError("`claude` is not on PATH; install Claude Code first")
158
+ cfg = project.load(root)
159
+ problems = project.stale(root, cfg)
160
+ if problems:
161
+ raise project.ProjectError("the generated files do not match plugins.toml:\n "
162
+ + "\n ".join(problems) + "\nRun `cs-plugin generate`.")
163
+ settings = root / project.SETTINGS
164
+ committed = settings.read_text() if settings.exists() else None
165
+ try:
166
+ # Local scope: registering writes the marketplace's absolute path, which
167
+ # belongs in the uncommitted settings file, not the shared one.
168
+ claude.run("plugin", "marketplace", "add", str((root / project.GEN_DIR).resolve()),
169
+ "--scope", "local")
170
+ claude.run("plugin", "marketplace", "update", cfg.marketplace)
171
+ for cmd in project.sync_plan(cfg, claude.installed(cfg, root)):
172
+ print("claude " + " ".join(cmd))
173
+ print(" " + (claude.run(*cmd).stdout.strip().splitlines() or [""])[-1])
174
+ finally:
175
+ project.restore_layout(settings, committed)
176
+ after = claude.installed(cfg, root)
177
+ print()
178
+ status = 0
179
+ for name in sorted(cfg.plugins):
180
+ want = cfg.plugins[name].get("version")
181
+ have = after.get(name)
182
+ ok = have is not None and (want is None or have == want)
183
+ status |= not ok
184
+ print(f"{'ok ' if ok else 'BAD'} {name} {have or 'not installed'}"
185
+ + (f" (pinned {want})" if want and have != want else ""))
186
+ print("\nRestart Claude Code in this project to load the changes.")
187
+ return status
188
+
189
+
190
+ def cmd_sources(args: argparse.Namespace) -> int:
191
+ cfg = project.load(Path.cwd())
192
+ where = f"[sources] in {project.CONFIG}" if cfg.sources is not None else "the defaults"
193
+ print(f"Plugins are read from these repos' marketplaces ({where}):")
194
+ for repo in cfg.repos:
195
+ print(f" {repo}")
196
+ return 0
197
+
198
+
199
+ def main(argv: list[str] | None = None) -> int:
200
+ ap = argparse.ArgumentParser(prog="cs-plugin", description=__doc__,
201
+ formatter_class=argparse.RawDescriptionHelpFormatter)
202
+ ap.add_argument("--version", action="version", version=f"cs-plugin {__version__}")
203
+ sub = ap.add_subparsers(dest="cmd", required=True)
204
+ p = sub.add_parser("list", help="every plugin in the sources, with releases")
205
+ p.add_argument("-l", "--long", action="store_true", help="also show descriptions")
206
+ p.set_defaults(fn=cmd_list)
207
+ p = sub.add_parser("versions", help="every release of one plugin, newest first")
208
+ p.add_argument("plugin", metavar="NAME")
209
+ p.add_argument("-l", "--long", action="store_true", help="also link each release")
210
+ p.set_defaults(fn=cmd_versions)
211
+ p = sub.add_parser("add", help="pin plugins, newest release unless NAME@VERSION")
212
+ p.add_argument("plugins", nargs="+", metavar="NAME[@VERSION]")
213
+ p.set_defaults(fn=cmd_add)
214
+ p = sub.add_parser("remove", help="drop plugins from plugins.toml")
215
+ p.add_argument("plugins", nargs="+", metavar="NAME")
216
+ p.set_defaults(fn=cmd_remove)
217
+ p = sub.add_parser("upgrade", help="move pins to the newest release")
218
+ p.add_argument("plugins", nargs="*", metavar="NAME")
219
+ p.set_defaults(fn=cmd_upgrade)
220
+ sub.add_parser("outdated", help="pins with a newer release").set_defaults(fn=cmd_outdated)
221
+ sub.add_parser("generate", help="rewrite the generated files").set_defaults(fn=cmd_generate)
222
+ sub.add_parser("sync", help="install exactly what plugins.toml pins").set_defaults(fn=cmd_sync)
223
+ sub.add_parser("sources", help="the repos plugins are read from").set_defaults(fn=cmd_sources)
224
+ args = ap.parse_args(argv)
225
+ try:
226
+ return args.fn(args)
227
+ except (project.ProjectError, sources.SourceError, remote.RemoteError) as e:
228
+ print(f"cs-plugin: {e}", file=sys.stderr)
229
+ return 1
230
+
231
+
232
+ if __name__ == "__main__":
233
+ sys.exit(main())