sim-cli-core 0.3.1__py3-none-any.whl → 0.3.2__py3-none-any.whl
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.
- sim/_plugin_install.py +69 -247
- sim/cli.py +56 -12
- sim/compat.py +1 -1
- sim/config.py +8 -11
- sim/describe.py +11 -3
- sim/history.py +6 -0
- sim/plugin_catalog.py +232 -0
- {sim_cli_core-0.3.1.dist-info → sim_cli_core-0.3.2.dist-info}/METADATA +28 -32
- {sim_cli_core-0.3.1.dist-info → sim_cli_core-0.3.2.dist-info}/RECORD +13 -12
- {sim_cli_core-0.3.1.dist-info → sim_cli_core-0.3.2.dist-info}/WHEEL +0 -0
- {sim_cli_core-0.3.1.dist-info → sim_cli_core-0.3.2.dist-info}/entry_points.txt +0 -0
- {sim_cli_core-0.3.1.dist-info → sim_cli_core-0.3.2.dist-info}/licenses/LICENSE +0 -0
- {sim_cli_core-0.3.1.dist-info → sim_cli_core-0.3.2.dist-info}/licenses/NOTICE +0 -0
sim/_plugin_install.py
CHANGED
|
@@ -6,164 +6,34 @@ install pipeline.
|
|
|
6
6
|
|
|
7
7
|
A `<source>` argument can be any of:
|
|
8
8
|
|
|
9
|
-
*
|
|
10
|
-
|
|
9
|
+
* ``sim-plugin-<name>`` / ``sim-plugin-<name>==<version>`` — exact pip
|
|
10
|
+
package spec.
|
|
11
11
|
* ``https://...whl`` / ``https://...tar.gz`` — direct wheel/sdist URL.
|
|
12
12
|
* ``./path/to/dir`` — local plugin source directory.
|
|
13
13
|
* ``./path/to/wheel.whl`` / ``./path/to/sdist.tar.gz`` — local artifact.
|
|
14
14
|
* ``git+https://...`` / ``git+ssh://...`` — git URL.
|
|
15
15
|
|
|
16
|
-
The resolver classifies the source with no network calls
|
|
17
|
-
|
|
18
|
-
invocation does the work.
|
|
16
|
+
The resolver classifies the source with no network calls and no plugin
|
|
17
|
+
registry lookup. Then a single ``pip install`` invocation does the work.
|
|
19
18
|
"""
|
|
20
19
|
from __future__ import annotations
|
|
21
20
|
|
|
22
|
-
import json
|
|
23
|
-
import os
|
|
24
21
|
import re
|
|
25
22
|
import shutil
|
|
26
23
|
import subprocess
|
|
27
24
|
import sys
|
|
28
|
-
import urllib.request
|
|
29
25
|
from dataclasses import dataclass, field
|
|
30
26
|
from pathlib import Path
|
|
31
27
|
from typing import Any
|
|
32
28
|
|
|
33
29
|
|
|
34
|
-
# ── Index ───────────────────────────────────────────────────────────────────
|
|
35
|
-
|
|
36
|
-
# Curated wheels published by the project — primary index. Anonymous GET; updated
|
|
37
|
-
# whenever a new wheel is published via tools/publish-wheel.sh.
|
|
38
|
-
R2_MANIFEST_URL = "https://cdn.svdailab.com/manifest.json"
|
|
39
|
-
|
|
40
|
-
# Community-maintained OSS plugin catalogue — fallback for entries the curated
|
|
41
|
-
# manifest does not carry. Different schema (array of entries with git+homepage
|
|
42
|
-
# fields), normalized at lookup time.
|
|
43
|
-
DEFAULT_INDEX_URL = (
|
|
44
|
-
"https://raw.githubusercontent.com/svd-ai-lab/sim-plugin-index/main/index.json"
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
# How long an index is treated as fresh, before we re-fetch.
|
|
48
|
-
INDEX_CACHE_TTL_SECONDS = 3600
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def _index_cache_dir() -> Path:
|
|
52
|
-
return Path.home() / ".sim" / "index-cache"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def _index_cache_path() -> Path:
|
|
56
|
-
"""Cache file for the GitHub OSS index (``DEFAULT_INDEX_URL``)."""
|
|
57
|
-
return _index_cache_dir() / "index.json"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def _r2_cache_path() -> Path:
|
|
61
|
-
"""Cache file for the curated R2 manifest (``R2_MANIFEST_URL``)."""
|
|
62
|
-
return _index_cache_dir() / "manifest-r2.json"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
def _cache_for(url: str) -> Path:
|
|
66
|
-
return _r2_cache_path() if url == R2_MANIFEST_URL else _index_cache_path()
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def fetch_index(url: str = DEFAULT_INDEX_URL, *, force: bool = False, offline: bool = False) -> dict[str, Any]:
|
|
70
|
-
"""Fetch a plugin index by URL. Caches under ``~/.sim/index-cache/`` keyed by URL.
|
|
71
|
-
|
|
72
|
-
In ``--offline`` mode, only the local cache is consulted; an empty index
|
|
73
|
-
is returned if no cache exists.
|
|
74
|
-
"""
|
|
75
|
-
cache = _cache_for(url)
|
|
76
|
-
if offline:
|
|
77
|
-
if cache.is_file():
|
|
78
|
-
try:
|
|
79
|
-
return json.loads(cache.read_text(encoding="utf-8"))
|
|
80
|
-
except (OSError, json.JSONDecodeError):
|
|
81
|
-
return {"schema_version": 1, "plugins": []}
|
|
82
|
-
return {"schema_version": 1, "plugins": []}
|
|
83
|
-
|
|
84
|
-
if not force and cache.is_file():
|
|
85
|
-
try:
|
|
86
|
-
age = cache.stat().st_mtime
|
|
87
|
-
except OSError:
|
|
88
|
-
age = 0
|
|
89
|
-
import time
|
|
90
|
-
if time.time() - age < INDEX_CACHE_TTL_SECONDS:
|
|
91
|
-
try:
|
|
92
|
-
return json.loads(cache.read_text(encoding="utf-8"))
|
|
93
|
-
except (OSError, json.JSONDecodeError):
|
|
94
|
-
pass
|
|
95
|
-
|
|
96
|
-
try:
|
|
97
|
-
with urllib.request.urlopen(url, timeout=10) as resp:
|
|
98
|
-
data = resp.read().decode("utf-8")
|
|
99
|
-
except Exception: # noqa: BLE001 — degrade if no network
|
|
100
|
-
if cache.is_file():
|
|
101
|
-
try:
|
|
102
|
-
return json.loads(cache.read_text(encoding="utf-8"))
|
|
103
|
-
except (OSError, json.JSONDecodeError):
|
|
104
|
-
pass
|
|
105
|
-
return {"schema_version": 1, "plugins": []}
|
|
106
|
-
|
|
107
|
-
parsed = json.loads(data)
|
|
108
|
-
cache.parent.mkdir(parents=True, exist_ok=True)
|
|
109
|
-
cache.write_text(data, encoding="utf-8")
|
|
110
|
-
return parsed
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def _normalize_r2_entry(name: str, info: dict[str, Any]) -> dict[str, Any]:
|
|
114
|
-
"""Convert an R2 manifest entry to the GitHub-style entry shape that
|
|
115
|
-
``resolve_source`` consumes (``latest_version`` + ``latest_wheel_url``)."""
|
|
116
|
-
return {
|
|
117
|
-
"name": name,
|
|
118
|
-
"latest_version": info.get("version"),
|
|
119
|
-
"latest_wheel_url": info.get("wheel"),
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def _r2_lookup(name: str, *, offline: bool = False) -> dict[str, Any] | None:
|
|
124
|
-
"""Look up ``name`` in the R2 curated manifest, returning a normalized entry."""
|
|
125
|
-
manifest = fetch_index(url=R2_MANIFEST_URL, offline=offline)
|
|
126
|
-
plugins = manifest.get("plugins")
|
|
127
|
-
if not isinstance(plugins, dict):
|
|
128
|
-
return None
|
|
129
|
-
info = plugins.get(name)
|
|
130
|
-
if not isinstance(info, dict) or not info.get("wheel"):
|
|
131
|
-
return None
|
|
132
|
-
return _normalize_r2_entry(name, info)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def index_entry(name: str, *, offline: bool = False, url: str = DEFAULT_INDEX_URL) -> dict[str, Any] | None:
|
|
136
|
-
"""Look up one plugin by name in a single index URL.
|
|
137
|
-
|
|
138
|
-
For ``url == R2_MANIFEST_URL`` the entry is normalized to the GitHub-style
|
|
139
|
-
shape so callers get a consistent dict regardless of which index served it.
|
|
140
|
-
"""
|
|
141
|
-
if url == R2_MANIFEST_URL:
|
|
142
|
-
return _r2_lookup(name, offline=offline)
|
|
143
|
-
idx = fetch_index(url=url, offline=offline)
|
|
144
|
-
for entry in idx.get("plugins", []):
|
|
145
|
-
if entry.get("name") == name:
|
|
146
|
-
return entry
|
|
147
|
-
return None
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def index_entry_chained(name: str, *, offline: bool = False) -> dict[str, Any] | None:
|
|
151
|
-
"""Resolve ``name`` against the curated R2 manifest first, then fall back
|
|
152
|
-
to the community GitHub OSS index. Returns the first hit, or ``None`` if
|
|
153
|
-
neither has it."""
|
|
154
|
-
e = _r2_lookup(name, offline=offline)
|
|
155
|
-
if e is not None:
|
|
156
|
-
return e
|
|
157
|
-
return index_entry(name, offline=offline, url=DEFAULT_INDEX_URL)
|
|
158
|
-
|
|
159
|
-
|
|
160
30
|
# ── Source resolution ──────────────────────────────────────────────────────
|
|
161
31
|
|
|
162
32
|
|
|
163
33
|
@dataclass(frozen=True)
|
|
164
34
|
class ResolvedSource:
|
|
165
35
|
"""One install source classified into a canonical kind."""
|
|
166
|
-
kind: str
|
|
36
|
+
kind: str
|
|
167
37
|
raw: str # the original argument
|
|
168
38
|
name: str | None = None
|
|
169
39
|
version: str | None = None
|
|
@@ -171,26 +41,34 @@ class ResolvedSource:
|
|
|
171
41
|
extras: dict[str, Any] = field(default_factory=dict)
|
|
172
42
|
|
|
173
43
|
|
|
174
|
-
|
|
175
|
-
|
|
44
|
+
_SHORT_NAME_RE = re.compile(r"^[A-Za-z][A-Za-z0-9_]*$")
|
|
45
|
+
_SIM_PLUGIN_PACKAGE_RE = re.compile(
|
|
46
|
+
r"^(sim-plugin-[A-Za-z0-9][A-Za-z0-9_.-]*)(?:\[[A-Za-z0-9_,.-]+\])?"
|
|
47
|
+
r"(?:\s*(?:==|!=|~=|>=|<=|>|<)\s*[A-Za-z0-9.*+!_.-]+)?$"
|
|
48
|
+
)
|
|
49
|
+
_VERSION_PIN_RE = re.compile(r"(?:==|!=|~=|>=|<=|>|<)\s*(.+)$")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _short_name_error(name: str) -> str:
|
|
53
|
+
return (
|
|
54
|
+
f"{name!r} is not an explicit plugin install source. "
|
|
55
|
+
"See 'sim plugin catalog' for the official plugin list, or pass an "
|
|
56
|
+
"explicit pip-installable source: a local wheel/sdist path, a direct "
|
|
57
|
+
"wheel/sdist URL, a git URL, or a package spec such as "
|
|
58
|
+
f"'sim-plugin-{name}'."
|
|
59
|
+
)
|
|
176
60
|
|
|
177
61
|
|
|
178
62
|
def resolve_source(source: str, *, offline: bool = False,
|
|
179
63
|
index_url: str | None = None) -> ResolvedSource:
|
|
180
64
|
"""Classify a source argument and choose what to hand to pip.
|
|
181
65
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
git+https. Raises ``ValueError`` if the name isn't in the index in offline
|
|
186
|
-
mode.
|
|
66
|
+
``offline`` and ``index_url`` are accepted for API compatibility but no
|
|
67
|
+
longer affect resolution; this resolver never reads a plugin index or maps
|
|
68
|
+
short names to ``sim-plugin-*`` package names.
|
|
187
69
|
"""
|
|
188
70
|
s = source.strip()
|
|
189
|
-
|
|
190
|
-
def _lookup(name: str) -> dict[str, Any] | None:
|
|
191
|
-
if index_url is None:
|
|
192
|
-
return index_entry_chained(name, offline=offline)
|
|
193
|
-
return index_entry(name, offline=offline, url=index_url)
|
|
71
|
+
_ = (offline, index_url)
|
|
194
72
|
|
|
195
73
|
# Local files / dirs first (cheapest to check).
|
|
196
74
|
p = Path(s)
|
|
@@ -201,7 +79,7 @@ def resolve_source(source: str, *, offline: bool = False,
|
|
|
201
79
|
return ResolvedSource(kind="local-wheel", raw=s, pip_target=str(target))
|
|
202
80
|
if target.name.endswith(".tar.gz") or target.suffix == ".tar":
|
|
203
81
|
return ResolvedSource(kind="local-sdist", raw=s, pip_target=str(target))
|
|
204
|
-
|
|
82
|
+
return ResolvedSource(kind="local-file", raw=s, pip_target=str(target))
|
|
205
83
|
if target.is_dir():
|
|
206
84
|
return ResolvedSource(kind="local-dir", raw=s, pip_target=str(target))
|
|
207
85
|
# Path doesn't exist on disk and doesn't look obviously remote — error.
|
|
@@ -219,55 +97,20 @@ def resolve_source(source: str, *, offline: bool = False,
|
|
|
219
97
|
# Generic URL: treat as wheel-url and let pip complain.
|
|
220
98
|
return ResolvedSource(kind="wheel-url", raw=s, pip_target=s)
|
|
221
99
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
pip_target=str(entry["latest_wheel_url"]))
|
|
237
|
-
# If the entry came from the R2 manifest, all versioned wheels live at a
|
|
238
|
-
# predictable path — construct the pinned URL by filename convention so
|
|
239
|
-
# ``name@<old-version>`` resolves without needing every version listed
|
|
240
|
-
# in the manifest. (R2 keeps every published wheel; manifest only tracks
|
|
241
|
-
# latest.)
|
|
242
|
-
latest_url = str(entry.get("latest_wheel_url") or "")
|
|
243
|
-
if latest_url.startswith("https://cdn.svdailab.com/wheels/"):
|
|
244
|
-
return ResolvedSource(
|
|
245
|
-
kind="name-version", raw=s, name=name, version=version,
|
|
246
|
-
pip_target=(
|
|
247
|
-
f"https://cdn.svdailab.com/wheels/"
|
|
248
|
-
f"sim_plugin_{name}-{version}-py3-none-any.whl"
|
|
249
|
-
),
|
|
250
|
-
)
|
|
251
|
-
git = entry.get("git")
|
|
252
|
-
if git:
|
|
253
|
-
return ResolvedSource(kind="name-version", raw=s, name=name, version=version,
|
|
254
|
-
pip_target=f"git+{git}@v{version}")
|
|
255
|
-
return ResolvedSource(kind="name-version", raw=s, name=name, version=version,
|
|
256
|
-
pip_target=f"sim-plugin-{name}=={version}")
|
|
257
|
-
|
|
258
|
-
# bare name
|
|
259
|
-
if _NAME_RE.match(s):
|
|
260
|
-
entry = _lookup(s)
|
|
261
|
-
if entry is None and offline:
|
|
262
|
-
raise ValueError(f"plugin {s!r} not in offline index")
|
|
263
|
-
if entry is None:
|
|
264
|
-
# Optimistic: assume sim-plugin-<name> is published; pip will tell us.
|
|
265
|
-
return ResolvedSource(kind="name", raw=s, name=s, pip_target=f"sim-plugin-{s}")
|
|
266
|
-
if entry.get("latest_wheel_url"):
|
|
267
|
-
return ResolvedSource(kind="name", raw=s, name=s, pip_target=str(entry["latest_wheel_url"]))
|
|
268
|
-
if entry.get("git"):
|
|
269
|
-
return ResolvedSource(kind="name", raw=s, name=s, pip_target=f"git+{entry['git']}")
|
|
270
|
-
return ResolvedSource(kind="name", raw=s, name=s, pip_target=f"sim-plugin-{s}")
|
|
100
|
+
package_match = _SIM_PLUGIN_PACKAGE_RE.match(s)
|
|
101
|
+
if package_match:
|
|
102
|
+
version_match = _VERSION_PIN_RE.search(s)
|
|
103
|
+
version = version_match.group(1).strip() if version_match else None
|
|
104
|
+
return ResolvedSource(
|
|
105
|
+
kind="package-spec",
|
|
106
|
+
raw=s,
|
|
107
|
+
name=package_match.group(1),
|
|
108
|
+
version=version,
|
|
109
|
+
pip_target=s,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
if _SHORT_NAME_RE.match(s):
|
|
113
|
+
raise ValueError(_short_name_error(s))
|
|
271
114
|
|
|
272
115
|
raise ValueError(f"could not classify install source: {source!r}")
|
|
273
116
|
|
|
@@ -349,6 +192,7 @@ def install_plugin(
|
|
|
349
192
|
sync_target: Path | None = None,
|
|
350
193
|
skip_sync: bool = False,
|
|
351
194
|
python: str | None = None,
|
|
195
|
+
extra_index_urls: list[str] | None = None,
|
|
352
196
|
) -> InstallReport:
|
|
353
197
|
"""High-level installer used by ``sim plugin install``.
|
|
354
198
|
|
|
@@ -369,9 +213,16 @@ def install_plugin(
|
|
|
369
213
|
message=str(e),
|
|
370
214
|
)
|
|
371
215
|
|
|
216
|
+
extra_args: list[str] = []
|
|
217
|
+
for extra_index_url in extra_index_urls or []:
|
|
218
|
+
extra_args.extend(["--extra-index-url", extra_index_url])
|
|
219
|
+
|
|
372
220
|
proc = _pip_install(
|
|
373
221
|
resolved.pip_target,
|
|
374
|
-
editable=editable,
|
|
222
|
+
editable=editable,
|
|
223
|
+
upgrade=upgrade,
|
|
224
|
+
python=python,
|
|
225
|
+
extra_args=extra_args or None,
|
|
375
226
|
)
|
|
376
227
|
ok = proc.returncode == 0
|
|
377
228
|
|
|
@@ -464,65 +315,36 @@ def uninstall_plugin(name: str, *, sync: bool = True,
|
|
|
464
315
|
|
|
465
316
|
|
|
466
317
|
def bundle_plugins(names: list[str], output_dir: Path, *,
|
|
467
|
-
index_url: str =
|
|
468
|
-
"""
|
|
318
|
+
index_url: str | None = None) -> dict[str, Any]:
|
|
319
|
+
"""The install-resolver-backed bundle flow was removed.
|
|
469
320
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
321
|
+
Use the discovery catalogue to find plugins, then download explicit wheel
|
|
322
|
+
URLs or install exact package specs. The catalogue itself is not an
|
|
323
|
+
install-time resolver.
|
|
473
324
|
"""
|
|
474
|
-
|
|
475
|
-
output_dir.mkdir(parents=True, exist_ok=True)
|
|
476
|
-
|
|
477
|
-
idx = fetch_index(url=index_url)
|
|
478
|
-
by_name = {e["name"]: e for e in idx.get("plugins", [])}
|
|
479
|
-
|
|
480
|
-
fetched: list[dict[str, Any]] = []
|
|
481
|
-
errors: list[dict[str, Any]] = []
|
|
482
|
-
|
|
483
|
-
for name in names:
|
|
484
|
-
entry = by_name.get(name)
|
|
485
|
-
if entry is None:
|
|
486
|
-
errors.append({"name": name, "error": "not in index"})
|
|
487
|
-
continue
|
|
488
|
-
wheel_url = entry.get("latest_wheel_url")
|
|
489
|
-
if not wheel_url:
|
|
490
|
-
errors.append({"name": name, "error": "index entry has no latest_wheel_url"})
|
|
491
|
-
continue
|
|
492
|
-
wheel_basename = Path(wheel_url.split("?")[0]).name
|
|
493
|
-
dest = output_dir / wheel_basename
|
|
494
|
-
try:
|
|
495
|
-
with urllib.request.urlopen(wheel_url, timeout=30) as resp, dest.open("wb") as f:
|
|
496
|
-
shutil.copyfileobj(resp, f)
|
|
497
|
-
except Exception as e: # noqa: BLE001 — surface fetch errors
|
|
498
|
-
errors.append({"name": name, "error": f"download failed: {e}"})
|
|
499
|
-
continue
|
|
500
|
-
|
|
501
|
-
rewritten = dict(entry)
|
|
502
|
-
rewritten["latest_wheel_url"] = f"file://{dest}"
|
|
503
|
-
fetched.append(rewritten)
|
|
504
|
-
|
|
505
|
-
bundle_idx = {"schema_version": 1, "plugins": fetched}
|
|
506
|
-
(output_dir / "index.json").write_text(
|
|
507
|
-
json.dumps(bundle_idx, indent=2) + "\n", encoding="utf-8",
|
|
508
|
-
)
|
|
509
|
-
|
|
325
|
+
_ = (names, output_dir, index_url)
|
|
510
326
|
return {
|
|
511
|
-
"ok":
|
|
327
|
+
"ok": False,
|
|
512
328
|
"output": str(output_dir),
|
|
513
|
-
"fetched": [
|
|
514
|
-
"errors":
|
|
329
|
+
"fetched": [],
|
|
330
|
+
"errors": [
|
|
331
|
+
{
|
|
332
|
+
"name": name,
|
|
333
|
+
"error": (
|
|
334
|
+
"bundle no longer resolves catalogue names; use "
|
|
335
|
+
"sim plugin catalog/search to discover plugins, then pass "
|
|
336
|
+
"explicit wheel URLs, local artifacts, git URLs, or exact "
|
|
337
|
+
"package specs"
|
|
338
|
+
),
|
|
339
|
+
}
|
|
340
|
+
for name in names
|
|
341
|
+
],
|
|
515
342
|
}
|
|
516
343
|
|
|
517
344
|
|
|
518
345
|
__all__ = [
|
|
519
|
-
"DEFAULT_INDEX_URL",
|
|
520
|
-
"R2_MANIFEST_URL",
|
|
521
346
|
"ResolvedSource",
|
|
522
347
|
"InstallReport",
|
|
523
|
-
"fetch_index",
|
|
524
|
-
"index_entry",
|
|
525
|
-
"index_entry_chained",
|
|
526
348
|
"resolve_source",
|
|
527
349
|
"install_plugin",
|
|
528
350
|
"uninstall_plugin",
|
sim/cli.py
CHANGED
|
@@ -341,7 +341,7 @@ def lint(ctx, script):
|
|
|
341
341
|
level="error",
|
|
342
342
|
message=(
|
|
343
343
|
f"No registered driver claims {script_path.name!r}. "
|
|
344
|
-
"Install the matching plugin (e.g. `sim plugin install
|
|
344
|
+
"Install the matching plugin (e.g. `sim plugin install sim-plugin-<solver>`) "
|
|
345
345
|
"or pass `sim run` if you want to attempt execution anyway."
|
|
346
346
|
),
|
|
347
347
|
)],
|
|
@@ -921,7 +921,7 @@ def init(ctx, force):
|
|
|
921
921
|
@click.option("--config", "config_path", type=click.Path(exists=True, dir_okay=False, path_type=Path),
|
|
922
922
|
default=None, help="Override the sim.toml location.")
|
|
923
923
|
@click.option("--offline", is_flag=True,
|
|
924
|
-
help="
|
|
924
|
+
help="Accepted for compatibility; plugin install no longer uses an index.")
|
|
925
925
|
@click.option("--dry-run", is_flag=True,
|
|
926
926
|
help="Print what would happen without installing anything.")
|
|
927
927
|
@click.pass_context
|
|
@@ -999,10 +999,51 @@ def plugin():
|
|
|
999
999
|
|
|
1000
1000
|
Plugins extend sim with additional solvers. Each plugin ships its
|
|
1001
1001
|
driver + skill in one wheel; see docs/plugin-install.md for the install
|
|
1002
|
-
flows (
|
|
1002
|
+
flows (package spec, direct URL, local wheel, git URL, etc.).
|
|
1003
1003
|
"""
|
|
1004
1004
|
|
|
1005
1005
|
|
|
1006
|
+
@plugin.command("catalog")
|
|
1007
|
+
@click.option("--offline", is_flag=True,
|
|
1008
|
+
help="Use the cached discovery catalogue only.")
|
|
1009
|
+
@click.option("--refresh", is_flag=True,
|
|
1010
|
+
help="Refresh the cached discovery catalogue.")
|
|
1011
|
+
@click.option("--catalog-url", default=None,
|
|
1012
|
+
help="Override the discovery catalogue URL.")
|
|
1013
|
+
@click.pass_context
|
|
1014
|
+
def plugin_catalog_cmd(ctx, offline, refresh, catalog_url):
|
|
1015
|
+
"""List available plugins from the discovery catalogue.
|
|
1016
|
+
|
|
1017
|
+
This is discovery only. Install commands remain explicit and pip-native;
|
|
1018
|
+
the catalogue is not used to silently resolve short names during install.
|
|
1019
|
+
"""
|
|
1020
|
+
from sim.plugin_catalog import DEFAULT_CATALOG_URL, list_catalog
|
|
1021
|
+
|
|
1022
|
+
rows = list_catalog(
|
|
1023
|
+
url=catalog_url or DEFAULT_CATALOG_URL,
|
|
1024
|
+
offline=offline,
|
|
1025
|
+
force=refresh,
|
|
1026
|
+
)
|
|
1027
|
+
if ctx.obj["json"]:
|
|
1028
|
+
click.echo(json_mod.dumps([r.to_dict() for r in rows], indent=2))
|
|
1029
|
+
return
|
|
1030
|
+
|
|
1031
|
+
if not rows:
|
|
1032
|
+
click.echo("[sim] plugin catalog: no available plugins found")
|
|
1033
|
+
return
|
|
1034
|
+
|
|
1035
|
+
click.echo(f"[sim] {len(rows)} available plugin(s) in catalog:")
|
|
1036
|
+
for r in rows:
|
|
1037
|
+
ver = f" {r.version}" if r.version else ""
|
|
1038
|
+
license_class = f" ({r.license_class})" if r.license_class else ""
|
|
1039
|
+
dist = f" [{r.distribution}]" if r.distribution else ""
|
|
1040
|
+
click.echo(f" {r.id:20s} {r.name}{ver}{dist}{license_class}")
|
|
1041
|
+
if r.summary:
|
|
1042
|
+
click.echo(f" {r.summary}")
|
|
1043
|
+
if r.install:
|
|
1044
|
+
click.echo(f" install: sim plugin install {r.install}")
|
|
1045
|
+
|
|
1046
|
+
|
|
1006
1047
|
@plugin.command("list")
|
|
1007
1048
|
@click.pass_context
|
|
1008
1049
|
def plugin_list(ctx):
|
|
@@ -1091,7 +1132,7 @@ def plugin_info_cmd(ctx, name):
|
|
|
1091
1132
|
"Default: enabled. Use --no-upgrade to keep an existing "
|
|
1092
1133
|
"install if one is already present.")
|
|
1093
1134
|
@click.option("--offline", is_flag=True,
|
|
1094
|
-
help="
|
|
1135
|
+
help="Accepted for compatibility; plugin install no longer uses an index.")
|
|
1095
1136
|
@click.option("--no-sync", "no_sync", is_flag=True,
|
|
1096
1137
|
help="Skip sync-skills after install.")
|
|
1097
1138
|
@click.option("--target", "sync_target", type=click.Path(file_okay=False, path_type=Path),
|
|
@@ -1101,20 +1142,23 @@ def plugin_info_cmd(ctx, name):
|
|
|
1101
1142
|
help="Pin the target Python interpreter for the install. "
|
|
1102
1143
|
"Defaults to the interpreter running sim — use this "
|
|
1103
1144
|
"when sim is on PATH but the desired venv isn't activated.")
|
|
1145
|
+
@click.option("--extra-index-url", "extra_index_urls", multiple=True,
|
|
1146
|
+
help="Additional Python package index for private plugins. "
|
|
1147
|
+
"Passed through to pip/uv pip install.")
|
|
1104
1148
|
@click.pass_context
|
|
1105
1149
|
def plugin_install(ctx, source, editable, upgrade, offline, no_sync, sync_target,
|
|
1106
|
-
python_exe):
|
|
1150
|
+
python_exe, extra_index_urls):
|
|
1107
1151
|
"""Install a plugin from any supported source.
|
|
1108
1152
|
|
|
1109
1153
|
\b
|
|
1110
1154
|
Examples:
|
|
1111
|
-
sim plugin install coolprop
|
|
1112
|
-
sim plugin install coolprop
|
|
1155
|
+
sim plugin install sim-plugin-coolprop # exact package spec
|
|
1156
|
+
sim plugin install sim-plugin-coolprop==0.1.0 # pinned package spec
|
|
1113
1157
|
sim plugin install ./sim_plugin_coolprop-0.1.0-py3-none-any.whl
|
|
1114
1158
|
sim plugin install ./sim-plugin-coolprop -e # editable, for authors
|
|
1115
1159
|
sim plugin install git+https://github.com/svd-ai-lab/sim-plugin-coolprop
|
|
1116
|
-
sim plugin install
|
|
1117
|
-
sim plugin install
|
|
1160
|
+
sim plugin install sim-plugin-coolprop --python /path/to/venv/bin/python
|
|
1161
|
+
sim plugin install sim-plugin-mechanical --extra-index-url https://example.com/simple/
|
|
1118
1162
|
"""
|
|
1119
1163
|
from sim._plugin_install import install_plugin
|
|
1120
1164
|
|
|
@@ -1123,6 +1167,7 @@ def plugin_install(ctx, source, editable, upgrade, offline, no_sync, sync_target
|
|
|
1123
1167
|
editable=editable, upgrade=upgrade, offline=offline,
|
|
1124
1168
|
sync_target=sync_target, skip_sync=no_sync,
|
|
1125
1169
|
python=python_exe,
|
|
1170
|
+
extra_index_urls=list(extra_index_urls),
|
|
1126
1171
|
)
|
|
1127
1172
|
|
|
1128
1173
|
if ctx.obj["json"]:
|
|
@@ -1171,12 +1216,11 @@ def plugin_uninstall(ctx, name, python_exe):
|
|
|
1171
1216
|
help="Output directory for wheels + filtered index.json.")
|
|
1172
1217
|
@click.pass_context
|
|
1173
1218
|
def plugin_bundle(ctx, names, output):
|
|
1174
|
-
"""
|
|
1219
|
+
"""Deprecated: index-backed plugin bundles are no longer supported.
|
|
1175
1220
|
|
|
1176
1221
|
\b
|
|
1177
1222
|
Examples:
|
|
1178
|
-
sim plugin
|
|
1179
|
-
sim plugin install --offline --from-dir ./plugins-bundle/ coolprop
|
|
1223
|
+
sim plugin install ./vendor/sim_plugin_coolprop-0.1.0-py3-none-any.whl
|
|
1180
1224
|
"""
|
|
1181
1225
|
from sim._plugin_install import bundle_plugins
|
|
1182
1226
|
|
sim/compat.py
CHANGED
|
@@ -185,7 +185,7 @@ def load_compatibility_by_name(driver_name: str) -> "Compatibility | None":
|
|
|
185
185
|
if not traversable.is_file():
|
|
186
186
|
return None
|
|
187
187
|
text = traversable.read_text(encoding="utf-8")
|
|
188
|
-
except (FileNotFoundError, ModuleNotFoundError, OSError):
|
|
188
|
+
except (FileNotFoundError, ModuleNotFoundError, OSError, TypeError):
|
|
189
189
|
return None
|
|
190
190
|
return _parse_compatibility_text(driver_name, text)
|
|
191
191
|
|
sim/config.py
CHANGED
|
@@ -271,11 +271,12 @@ SIM_TOML_STUB = """\
|
|
|
271
271
|
# workspace = "./workspace"
|
|
272
272
|
|
|
273
273
|
# Each entry under [[sim.plugins]] declares one plugin to install.
|
|
274
|
-
# Sources accepted:
|
|
274
|
+
# Sources accepted: package = "sim-plugin-...", git+https://...,
|
|
275
275
|
# wheel = "./path/to/file.whl", or version = "==X.Y.Z" / ">=X".
|
|
276
276
|
#
|
|
277
277
|
# [[sim.plugins]]
|
|
278
278
|
# name = "coolprop"
|
|
279
|
+
# package = "sim-plugin-coolprop"
|
|
279
280
|
# version = ">=0.1.0"
|
|
280
281
|
"""
|
|
281
282
|
|
|
@@ -311,6 +312,7 @@ def validate_sim_toml(path: Path) -> list[str]:
|
|
|
311
312
|
|
|
312
313
|
[[sim.plugins]]
|
|
313
314
|
name = <string> # required
|
|
315
|
+
package = <string>? # exact pip package name/spec
|
|
314
316
|
version = <string>?
|
|
315
317
|
git = <string>?
|
|
316
318
|
wheel = <string>? # local path
|
|
@@ -351,7 +353,7 @@ def validate_sim_toml(path: Path) -> list[str]:
|
|
|
351
353
|
if "name" not in p or not isinstance(p["name"], str):
|
|
352
354
|
errors.append(f"[[sim.plugins]] entry #{i} missing required 'name'")
|
|
353
355
|
continue
|
|
354
|
-
for k in ("version", "git", "wheel"):
|
|
356
|
+
for k in ("package", "version", "git", "wheel"):
|
|
355
357
|
if k in p and not isinstance(p[k], str):
|
|
356
358
|
errors.append(f"[[sim.plugins]] {p['name']!r} field {k!r} must be a string")
|
|
357
359
|
|
|
@@ -362,19 +364,14 @@ def derive_install_source(plugin_entry: dict[str, Any]) -> str:
|
|
|
362
364
|
"""Translate one [[sim.plugins]] entry to an install-source string.
|
|
363
365
|
|
|
364
366
|
Resolution priority: explicit ``wheel`` path > explicit ``git`` URL
|
|
365
|
-
> ``
|
|
367
|
+
> explicit ``package`` plus optional version > ``name``.
|
|
366
368
|
"""
|
|
367
369
|
if "wheel" in plugin_entry:
|
|
368
370
|
return plugin_entry["wheel"]
|
|
369
371
|
if "git" in plugin_entry:
|
|
370
372
|
return f"git+{plugin_entry['git']}"
|
|
371
|
-
|
|
373
|
+
package = plugin_entry.get("package") or plugin_entry["name"]
|
|
372
374
|
version = plugin_entry.get("version")
|
|
373
375
|
if version:
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
if version.startswith("=="):
|
|
377
|
-
return f"{name}@{v}"
|
|
378
|
-
# Range constraints: fall back to bare name and let pip resolve.
|
|
379
|
-
return name
|
|
380
|
-
return name
|
|
376
|
+
return f"{package}{version}"
|
|
377
|
+
return package
|
sim/describe.py
CHANGED
|
@@ -119,13 +119,21 @@ _EXAMPLES: dict[str, list[dict[str, str]]] = {
|
|
|
119
119
|
{"cmd": "sim plugin list --json",
|
|
120
120
|
"summary": "List every registered plugin (built-in + external)."},
|
|
121
121
|
],
|
|
122
|
+
"plugin catalog": [
|
|
123
|
+
{"cmd": "sim plugin catalog --json",
|
|
124
|
+
"summary": "List available plugins from the discovery catalogue."},
|
|
125
|
+
],
|
|
126
|
+
"plugin search": [
|
|
127
|
+
{"cmd": "sim plugin search ltspice --json",
|
|
128
|
+
"summary": "Search the discovery catalogue for package and install guidance."},
|
|
129
|
+
],
|
|
122
130
|
"plugin info": [
|
|
123
131
|
{"cmd": "sim plugin info coolprop",
|
|
124
132
|
"summary": "Show one plugin's metadata and compatibility profiles."},
|
|
125
133
|
],
|
|
126
134
|
"plugin install": [
|
|
127
|
-
{"cmd": "sim plugin install coolprop",
|
|
128
|
-
"summary": "Install
|
|
135
|
+
{"cmd": "sim plugin install sim-plugin-coolprop",
|
|
136
|
+
"summary": "Install from an exact package spec."},
|
|
129
137
|
{"cmd": "sim plugin install ./sim_plugin_coolprop-0.1.0-py3-none-any.whl",
|
|
130
138
|
"summary": "Install from a local wheel (offline-friendly)."},
|
|
131
139
|
{"cmd": "sim plugin install ./sim-plugin-coolprop -e",
|
|
@@ -168,7 +176,7 @@ ERROR_CODES: dict[str, str] = {
|
|
|
168
176
|
"SESSION_NOT_FOUND":
|
|
169
177
|
"--session <id> does not match any active session on the server.",
|
|
170
178
|
"PLUGIN_NOT_FOUND":
|
|
171
|
-
"sim plugin
|
|
179
|
+
"sim plugin install received an invalid explicit source, or a plugin name is not installed.",
|
|
172
180
|
"PLUGIN_INSTALL_FAILED":
|
|
173
181
|
"pip install for a plugin returned non-zero.",
|
|
174
182
|
"PROTOCOL_VIOLATION":
|
sim/history.py
CHANGED
|
@@ -31,6 +31,7 @@ SCHEMA_FIELDS = (
|
|
|
31
31
|
"duration_ms",
|
|
32
32
|
"error",
|
|
33
33
|
"parsed_output",
|
|
34
|
+
"workspace_delta",
|
|
34
35
|
)
|
|
35
36
|
|
|
36
37
|
|
|
@@ -63,6 +64,11 @@ def _normalize(record: dict[str, Any]) -> dict[str, Any]:
|
|
|
63
64
|
# Parsed output is optional but commonly present for one-shot runs.
|
|
64
65
|
if "parsed_output" in record:
|
|
65
66
|
out["parsed_output"] = record["parsed_output"]
|
|
67
|
+
# Workspace delta is optional for older records, but new one-shot runs
|
|
68
|
+
# persist it so `sim logs <id> --field workspace` can drill into files
|
|
69
|
+
# written by solver processes.
|
|
70
|
+
if "workspace_delta" in record:
|
|
71
|
+
out["workspace_delta"] = record["workspace_delta"]
|
|
66
72
|
# Preserve script path for one-shot runs so `sim logs` can show it.
|
|
67
73
|
if "script" in record:
|
|
68
74
|
out["script"] = record["script"]
|
sim/plugin_catalog.py
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"""Plugin catalogue/discovery helpers.
|
|
2
|
+
|
|
3
|
+
The catalogue answers "what plugins exist?" for users and agents. It is
|
|
4
|
+
intentionally separate from ``sim plugin install`` source resolution: catalogue
|
|
5
|
+
entries advertise an explicit install string, but installing still requires the
|
|
6
|
+
caller to pass that string (or any other pip-native source) to
|
|
7
|
+
``sim plugin install``. The catalogue is advisory metadata, not a trust
|
|
8
|
+
boundary or a runtime resolver.
|
|
9
|
+
|
|
10
|
+
Schema (sim-plugin-index ``index.json``, ``schema_version: 2``):
|
|
11
|
+
|
|
12
|
+
{
|
|
13
|
+
"id": "ltspice", # short slug
|
|
14
|
+
"name": "LTspice", # display name
|
|
15
|
+
"distribution": "pypi" | "wheel" | "git", # advisory tag
|
|
16
|
+
"install": "sim-plugin-ltspice==0.2.3" # literal arg to `sim plugin install`
|
|
17
|
+
| "https://.../foo.whl#sha256=..."
|
|
18
|
+
| "git+https://...",
|
|
19
|
+
"version": "0.2.3",
|
|
20
|
+
"summary": "...", # optional, display only
|
|
21
|
+
"homepage": "...", # optional, display only
|
|
22
|
+
"license_class": "oss" | "commercial" # optional, display only
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
The reader also accepts the legacy ``schema_version: 1`` shape (``name`` as
|
|
26
|
+
slug, ``latest_version``, ``latest_wheel_url``/``git``/``package``) so the
|
|
27
|
+
catalogue can migrate independently of sim-cli releases.
|
|
28
|
+
"""
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
import json
|
|
32
|
+
import time
|
|
33
|
+
import urllib.request
|
|
34
|
+
from dataclasses import dataclass
|
|
35
|
+
from pathlib import Path
|
|
36
|
+
from typing import Any
|
|
37
|
+
|
|
38
|
+
DEFAULT_CATALOG_URL = (
|
|
39
|
+
"https://raw.githubusercontent.com/svd-ai-lab/sim-plugin-index/main/index.json"
|
|
40
|
+
)
|
|
41
|
+
CATALOG_CACHE_TTL_SECONDS = 3600
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _catalog_cache_path() -> Path:
|
|
45
|
+
return Path.home() / ".sim" / "index-cache" / "catalog.json"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass(frozen=True)
|
|
49
|
+
class CatalogEntry:
|
|
50
|
+
"""One available plugin as advertised by the discovery catalogue."""
|
|
51
|
+
|
|
52
|
+
id: str # short slug, e.g. "ltspice"
|
|
53
|
+
name: str = "" # display name, e.g. "LTspice"
|
|
54
|
+
distribution: str = "" # "pypi" | "wheel" | "git" | ""
|
|
55
|
+
install: str = "" # literal arg to `sim plugin install`
|
|
56
|
+
version: str = "" # advertised current version
|
|
57
|
+
summary: str = ""
|
|
58
|
+
homepage: str = ""
|
|
59
|
+
license_class: str = ""
|
|
60
|
+
source: str = "catalog"
|
|
61
|
+
|
|
62
|
+
def to_dict(self) -> dict[str, str]:
|
|
63
|
+
return {
|
|
64
|
+
"id": self.id,
|
|
65
|
+
"name": self.name,
|
|
66
|
+
"distribution": self.distribution,
|
|
67
|
+
"install": self.install,
|
|
68
|
+
"version": self.version,
|
|
69
|
+
"summary": self.summary,
|
|
70
|
+
"homepage": self.homepage,
|
|
71
|
+
"license_class": self.license_class,
|
|
72
|
+
"source": self.source,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def fetch_catalog(
|
|
77
|
+
url: str = DEFAULT_CATALOG_URL,
|
|
78
|
+
*,
|
|
79
|
+
force: bool = False,
|
|
80
|
+
offline: bool = False,
|
|
81
|
+
) -> dict[str, Any]:
|
|
82
|
+
"""Fetch the plugin discovery catalogue with a small local cache.
|
|
83
|
+
|
|
84
|
+
The cache is only for discovery. It is never consulted at install time.
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
cache = _catalog_cache_path()
|
|
88
|
+
if offline:
|
|
89
|
+
if cache.is_file():
|
|
90
|
+
try:
|
|
91
|
+
return json.loads(cache.read_text(encoding="utf-8"))
|
|
92
|
+
except (OSError, json.JSONDecodeError):
|
|
93
|
+
return {"schema_version": 2, "plugins": []}
|
|
94
|
+
return {"schema_version": 2, "plugins": []}
|
|
95
|
+
|
|
96
|
+
if not force and cache.is_file():
|
|
97
|
+
try:
|
|
98
|
+
if time.time() - cache.stat().st_mtime < CATALOG_CACHE_TTL_SECONDS:
|
|
99
|
+
return json.loads(cache.read_text(encoding="utf-8"))
|
|
100
|
+
except (OSError, json.JSONDecodeError):
|
|
101
|
+
pass
|
|
102
|
+
|
|
103
|
+
try:
|
|
104
|
+
with urllib.request.urlopen(url, timeout=10) as resp:
|
|
105
|
+
data = resp.read().decode("utf-8")
|
|
106
|
+
parsed = json.loads(data)
|
|
107
|
+
except Exception: # noqa: BLE001 - discovery should degrade gracefully
|
|
108
|
+
if cache.is_file():
|
|
109
|
+
try:
|
|
110
|
+
return json.loads(cache.read_text(encoding="utf-8"))
|
|
111
|
+
except (OSError, json.JSONDecodeError):
|
|
112
|
+
pass
|
|
113
|
+
return {"schema_version": 2, "plugins": []}
|
|
114
|
+
|
|
115
|
+
cache.parent.mkdir(parents=True, exist_ok=True)
|
|
116
|
+
cache.write_text(data, encoding="utf-8")
|
|
117
|
+
return parsed
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _legacy_install_string(raw: dict[str, Any]) -> tuple[str, str]:
|
|
121
|
+
"""Derive (install, distribution) from a v1 catalogue entry.
|
|
122
|
+
|
|
123
|
+
v1 entries had ``package`` / ``latest_version`` / ``latest_wheel_url`` /
|
|
124
|
+
``git`` instead of a single ``install`` string. Order of preference:
|
|
125
|
+
pinned wheel URL → PyPI package spec → git URL → bare package name.
|
|
126
|
+
"""
|
|
127
|
+
package = str(raw.get("package") or raw.get("pypi_package") or "").strip()
|
|
128
|
+
version = str(raw.get("latest_version") or raw.get("version") or "").strip()
|
|
129
|
+
wheel_url = str(raw.get("latest_wheel_url") or "").strip()
|
|
130
|
+
git_url = str(raw.get("git") or "").strip()
|
|
131
|
+
|
|
132
|
+
if wheel_url:
|
|
133
|
+
return wheel_url, "wheel"
|
|
134
|
+
if package and version:
|
|
135
|
+
return f"{package}=={version}", "pypi"
|
|
136
|
+
if package:
|
|
137
|
+
return package, "pypi"
|
|
138
|
+
if git_url:
|
|
139
|
+
return f"git+{git_url}", "git"
|
|
140
|
+
return "", ""
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _entry_from_mapping(raw: dict[str, Any], *, source: str) -> CatalogEntry | None:
|
|
144
|
+
# Slug: prefer v2 `id`, fall back to v1 `name`.
|
|
145
|
+
slug = str(raw.get("id") or raw.get("name") or "").strip()
|
|
146
|
+
if not slug:
|
|
147
|
+
return None
|
|
148
|
+
|
|
149
|
+
# Display name: prefer explicit `name`, fall back to slug.
|
|
150
|
+
display = str(raw.get("name") or slug).strip()
|
|
151
|
+
# If both `id` and `name` were absent we used `name` as slug — re-derive
|
|
152
|
+
# display from the slug to avoid showing the raw key as both fields.
|
|
153
|
+
if not raw.get("id") and raw.get("name"):
|
|
154
|
+
display = str(raw["name"]).strip()
|
|
155
|
+
|
|
156
|
+
distribution = str(raw.get("distribution") or "").strip()
|
|
157
|
+
install = str(raw.get("install") or "").strip()
|
|
158
|
+
version = str(raw.get("version") or raw.get("latest_version") or "").strip()
|
|
159
|
+
|
|
160
|
+
# v1 fallback: synthesize install + distribution from legacy fields.
|
|
161
|
+
if not install:
|
|
162
|
+
install, legacy_dist = _legacy_install_string(raw)
|
|
163
|
+
if not distribution:
|
|
164
|
+
distribution = legacy_dist
|
|
165
|
+
|
|
166
|
+
return CatalogEntry(
|
|
167
|
+
id=slug,
|
|
168
|
+
name=display,
|
|
169
|
+
distribution=distribution,
|
|
170
|
+
install=install,
|
|
171
|
+
version=version,
|
|
172
|
+
summary=str(raw.get("summary") or raw.get("description") or ""),
|
|
173
|
+
homepage=str(raw.get("homepage") or raw.get("url") or raw.get("git") or ""),
|
|
174
|
+
license_class=str(raw.get("license_class") or raw.get("license") or ""),
|
|
175
|
+
source=source,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def normalize_catalog(raw: dict[str, Any], *, source: str = "catalog") -> list[CatalogEntry]:
|
|
180
|
+
"""Normalize current and legacy catalogue shapes into ``CatalogEntry`` rows."""
|
|
181
|
+
|
|
182
|
+
plugins = raw.get("plugins", [])
|
|
183
|
+
if isinstance(plugins, dict):
|
|
184
|
+
iterable = []
|
|
185
|
+
for slug, info in plugins.items():
|
|
186
|
+
if isinstance(info, dict):
|
|
187
|
+
# If the value already carries `id` we trust it; otherwise
|
|
188
|
+
# promote the dict key to the slug.
|
|
189
|
+
item = {"id": slug, **info} if "id" not in info else dict(info)
|
|
190
|
+
else:
|
|
191
|
+
item = {"id": slug}
|
|
192
|
+
iterable.append(item)
|
|
193
|
+
elif isinstance(plugins, list):
|
|
194
|
+
iterable = [p for p in plugins if isinstance(p, dict)]
|
|
195
|
+
else:
|
|
196
|
+
iterable = []
|
|
197
|
+
|
|
198
|
+
rows = []
|
|
199
|
+
for item in iterable:
|
|
200
|
+
row = _entry_from_mapping(item, source=source)
|
|
201
|
+
if row is not None:
|
|
202
|
+
rows.append(row)
|
|
203
|
+
return sorted(rows, key=lambda r: r.id.lower())
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def list_catalog(
|
|
207
|
+
*,
|
|
208
|
+
query: str | None = None,
|
|
209
|
+
url: str = DEFAULT_CATALOG_URL,
|
|
210
|
+
offline: bool = False,
|
|
211
|
+
force: bool = False,
|
|
212
|
+
) -> list[CatalogEntry]:
|
|
213
|
+
"""List available plugins from the discovery catalogue.
|
|
214
|
+
|
|
215
|
+
``query`` is an optional case-insensitive substring filter over
|
|
216
|
+
``id``/``name``/``summary``/``homepage``. Kept as a helper-level option for
|
|
217
|
+
callers that want to filter the same data; the CLI exposes only the full
|
|
218
|
+
listing (``sim plugin catalog``).
|
|
219
|
+
"""
|
|
220
|
+
|
|
221
|
+
raw = fetch_catalog(url=url, offline=offline, force=force)
|
|
222
|
+
rows = normalize_catalog(raw, source=url)
|
|
223
|
+
if not query:
|
|
224
|
+
return rows
|
|
225
|
+
q = query.lower()
|
|
226
|
+
return [
|
|
227
|
+
row for row in rows
|
|
228
|
+
if q in row.id.lower()
|
|
229
|
+
or q in row.name.lower()
|
|
230
|
+
or q in row.summary.lower()
|
|
231
|
+
or q in row.homepage.lower()
|
|
232
|
+
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sim-cli-core
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Make every engineering tool agent-native — a CLI runtime that lets LLM agents launch, drive, and observe CAD/CAE software
|
|
5
5
|
Project-URL: Homepage, https://github.com/svd-ai-lab/sim-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/svd-ai-lab/sim-cli
|
|
@@ -123,9 +123,8 @@ Prereq: [`uv`](https://docs.astral.sh/uv/) — install with `curl -LsSf https://
|
|
|
123
123
|
# — no driver choice yet:
|
|
124
124
|
uv pip install sim-cli-core
|
|
125
125
|
|
|
126
|
-
# 2. Install the plugin for the solver you actually want
|
|
127
|
-
|
|
128
|
-
sim plugin install <solver> # e.g. ltspice
|
|
126
|
+
# 2. Install the plugin for the solver you actually want:
|
|
127
|
+
sim plugin install sim-plugin-ltspice
|
|
129
128
|
|
|
130
129
|
# 3. Tell sim to look at this machine and pick the right SDK profile:
|
|
131
130
|
sim check <solver>
|
|
@@ -153,9 +152,8 @@ sim --host <server-ip> disconnect
|
|
|
153
152
|
# — no driver choice yet:
|
|
154
153
|
uv pip install sim-cli-core
|
|
155
154
|
|
|
156
|
-
# 2. Install the plugin for the solver you actually want
|
|
157
|
-
|
|
158
|
-
sim plugin install <solver> # e.g. ltspice
|
|
155
|
+
# 2. Install the plugin for the solver you actually want:
|
|
156
|
+
sim plugin install sim-plugin-ltspice
|
|
159
157
|
|
|
160
158
|
# 3. Tell sim to look at this machine and pick the right SDK profile:
|
|
161
159
|
sim check <solver>
|
|
@@ -186,30 +184,24 @@ That's the full loop: **detect → bootstrap → launch → drive → observe
|
|
|
186
184
|
|
|
187
185
|
---
|
|
188
186
|
|
|
189
|
-
## 📦 Plugin
|
|
187
|
+
## 📦 Plugin sources
|
|
190
188
|
|
|
191
|
-
`sim plugin install <
|
|
189
|
+
`sim plugin install <source>` accepts explicit install sources only:
|
|
192
190
|
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
- Exact package specs, such as `sim-plugin-ltspice` or `sim-plugin-ltspice==0.2.3`
|
|
192
|
+
- Package specs plus private indexes, such as `sim-plugin-mechanical --extra-index-url https://example.com/simple/`
|
|
193
|
+
- Direct wheel/sdist URLs, such as `https://example.com/sim_plugin_ltspice-0.2.3-py3-none-any.whl`
|
|
194
|
+
- Git URLs, such as `git+https://github.com/<org>/sim-plugin-<name>`
|
|
195
|
+
- Local plugin directories, wheels, and sdists
|
|
195
196
|
|
|
196
|
-
|
|
197
|
+
Discovery is separate from installation:
|
|
197
198
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
{
|
|
202
|
-
"updated": "<ISO date>",
|
|
203
|
-
"plugins": {
|
|
204
|
-
"<name>": {
|
|
205
|
-
"version": "<X.Y.Z>",
|
|
206
|
-
"wheel": "https://cdn.svdailab.com/wheels/<file>.whl"
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
199
|
+
```bash
|
|
200
|
+
sim plugin catalog # official plugins (display + copy-paste install string)
|
|
201
|
+
sim plugin list # installed/registered plugins on this machine
|
|
210
202
|
```
|
|
211
203
|
|
|
212
|
-
|
|
204
|
+
Short solver aliases such as `ltspice` are catalogue names, not install sources. Run `sim plugin catalog` to find the recommended install string for each plugin, then pass it to `sim plugin install`.
|
|
213
205
|
|
|
214
206
|
---
|
|
215
207
|
|
|
@@ -219,20 +211,24 @@ To install a wheel directly without going through the resolver, hand `sim plugin
|
|
|
219
211
|
|
|
220
212
|
`sim` is most useful for **GUI-heavy solvers** — COMSOL, ANSYS Mechanical, ANSYS Fluent, MATLAB Simulink, Abaqus, Flotherm — where every agent iteration would otherwise mean clicking through dialog boxes.
|
|
221
213
|
|
|
222
|
-
Install
|
|
214
|
+
Install from a discovered package, then list what is installed locally:
|
|
223
215
|
|
|
224
216
|
```bash
|
|
225
|
-
sim plugin
|
|
226
|
-
sim plugin install
|
|
217
|
+
sim plugin catalog # discover what's available + install strings
|
|
218
|
+
sim plugin install sim-plugin-ltspice
|
|
219
|
+
sim plugin list # show installed plugins
|
|
227
220
|
```
|
|
228
221
|
|
|
229
222
|
Reference implementation to read for shape: [`sim-plugin-ltspice`](https://github.com/svd-ai-lab/sim-plugin-ltspice).
|
|
230
223
|
|
|
231
|
-
**Private plugins** (vendor-IP-sensitive backends
|
|
224
|
+
**Private plugins** (vendor-IP-sensitive backends) install through explicit URLs, private repos, or private Python indexes — same `sim plugin install` flow:
|
|
232
225
|
|
|
233
226
|
```bash
|
|
234
227
|
sim plugin install git+https://github.com/<org>/sim-plugin-<name>
|
|
235
228
|
# (you need read-access to the repo; without it, git clone returns 401)
|
|
229
|
+
|
|
230
|
+
sim plugin install sim-plugin-mechanical --extra-index-url https://example.com/simple/
|
|
231
|
+
# standard PEP 503/private-index path for commercial wrappers
|
|
236
232
|
```
|
|
237
233
|
|
|
238
234
|
Per-solver protocols, snippets, and demo workflows live in [`sim-skills`](https://github.com/svd-ai-lab/sim-skills) and the per-plugin repos.
|
|
@@ -250,7 +246,7 @@ Per-solver protocols, snippets, and demo workflows live in [`sim-skills`](https:
|
|
|
250
246
|
### 🔌 Solver-agnostic
|
|
251
247
|
- **One protocol** (`DriverProtocol`) — every driver is ~200 LOC, shipped as its own `sim-plugin-<name>` package via Python entry points
|
|
252
248
|
- **Persistent + one-shot** from the same CLI — no separate client per mode
|
|
253
|
-
- **Plugin
|
|
249
|
+
- **Plugin discovery + explicit installs** — `sim plugin catalog/search` discovers available plugins; `sim plugin install` accepts exact package specs, private indexes, direct URLs, git URLs, and local artifacts
|
|
254
250
|
- **Companion skills** in [`sim-skills`](https://github.com/svd-ai-lab/sim-skills) so an LLM picks up each new backend without prior context
|
|
255
251
|
|
|
256
252
|
### 🌐 Remote-friendly
|
|
@@ -264,7 +260,8 @@ Per-solver protocols, snippets, and demo workflows live in [`sim-skills`](https:
|
|
|
264
260
|
|
|
265
261
|
| Command | What it does | Analogy |
|
|
266
262
|
|---|---|---|
|
|
267
|
-
| `sim plugin
|
|
263
|
+
| `sim plugin catalog / search` | Discover available solver plugins | `npm search` |
|
|
264
|
+
| `sim plugin list / install / uninstall` | Manage installed plugins from explicit install sources | `npm install` |
|
|
268
265
|
| `sim check <solver>` | Detect installations + resolve a profile | `docker info` |
|
|
269
266
|
| `sim env install <profile>` | Bootstrap a profile env (venv + pinned SDK) | `pyenv install` |
|
|
270
267
|
| `sim env list [--catalogue]` | Show bootstrapped envs (and the full catalogue) | `pyenv versions` |
|
|
@@ -340,7 +337,6 @@ That is the entire setup — same `sim-cli-core` package on both sides, same wir
|
|
|
340
337
|
|
|
341
338
|
## 🔗 Related projects
|
|
342
339
|
|
|
343
|
-
- **[`sim-plugin-index`](https://github.com/svd-ai-lab/sim-plugin-index)** — community-maintained plugin catalogue; second of two sources `sim plugin install <name>` resolves against (the first is the svd-maintained manifest at `cdn.svdailab.com/manifest.json`)
|
|
344
340
|
- **[`sim-skills`](https://github.com/svd-ai-lab/sim-skills)** — agent skills, snippets, and demo workflows for each supported solver
|
|
345
341
|
- **[`sim-ltspice`](https://github.com/svd-ai-lab/sim-ltspice)** — standalone Python API for LTspice file formats (used by `sim-plugin-ltspice`)
|
|
346
342
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
sim/__init__.py,sha256=FQjdXr5BNBglRfKQ940zGQ3t5c2rCUjzDCuK2SYIp1Y,345
|
|
2
2
|
sim/__main__.py,sha256=hwGnM_V9it8Ds_SjAg0hRDqIaNp7L0A8Zx4WUbPKi6U,1034
|
|
3
|
-
sim/_plugin_install.py,sha256=
|
|
3
|
+
sim/_plugin_install.py,sha256=Txp0tbH30yndkmndc0L063UFwtmlD9Eg1dRBQTZpnwQ,13163
|
|
4
4
|
sim/_timeout.py,sha256=jUWw311yDinvqwWGO55CDgInbyioB3a4_8xovR_8g9E,3697
|
|
5
|
-
sim/cli.py,sha256=
|
|
6
|
-
sim/compat.py,sha256=
|
|
7
|
-
sim/config.py,sha256=
|
|
8
|
-
sim/describe.py,sha256=
|
|
5
|
+
sim/cli.py,sha256=56XLWDy0K_HTa4dyon5Z-eKUU5dh0QRZ2yn7WLDE2_g,59804
|
|
6
|
+
sim/compat.py,sha256=khoAPuIZcj5e5nKAq0Bw7B3DDTbTD_nLhjmsE2CJoMo,16139
|
|
7
|
+
sim/config.py,sha256=EXkwiGXPa-rxjkHdRqdt4Ru7UCHChbVL01itXsBVeNk,12217
|
|
8
|
+
sim/describe.py,sha256=6ZUrUhr_Isd4Ot4Fe-JwhLiNQLEuh60JoKXdDITUvkk,14670
|
|
9
9
|
sim/driver.py,sha256=8jSmoeIeT9fh5XLaTDse8_d8w34xP-TggU5_-jkzrbE,6573
|
|
10
|
-
sim/history.py,sha256=
|
|
10
|
+
sim/history.py,sha256=Sd61XsrG-eDEAc0YuMVmwQzl0WEWZcBleCxJkY1I5fE,5410
|
|
11
11
|
sim/inspect.py,sha256=DJGiC_KKQyEWOYKwZa7ogiHpxnqVsPyCNAade0QGPbs,44676
|
|
12
|
+
sim/plugin_catalog.py,sha256=qDMqeD4cmXwYcefeu-KUzcSfY_6RscaBoYEt4Abuhhg,8361
|
|
12
13
|
sim/plugins.py,sha256=bzBgKKruMwzC2lWVoH49K-J0ksc6Nv7l4RAcTOW2vbA,17554
|
|
13
14
|
sim/runner.py,sha256=QGT9wAfN7mrO1n7BSn1x49c7kerSCXLscyJ2dCwZCOo,6641
|
|
14
15
|
sim/server.py,sha256=E4H8YWt_DOh7sHfxpkCvwhDUrJQGCQP4OCDwMmS_uUs,20034
|
|
@@ -20,9 +21,9 @@ sim/gui/_win32_dialog.py,sha256=4hErvQxY4SwW_fTpX3FTUxhugkRYpkTRdBiBDu9_1DE,4731
|
|
|
20
21
|
sim/gui/LICENSES/ATTRIBUTION.md,sha256=X5EdZV0Gt0FdG9FpeCZ-22I3cqRg9SmoQt-86DqCBak,1150
|
|
21
22
|
sim/testing/__init__.py,sha256=iGwbSfJucKuhNLOiDnUmQCBlkhukWyp7cj89YDhoEOk,855
|
|
22
23
|
sim/testing/protocol_conformance.py,sha256=q0r7QgPoAyU-eMqN4fJWx0XZv8YNolGghu9-zDC8bls,9867
|
|
23
|
-
sim_cli_core-0.3.
|
|
24
|
-
sim_cli_core-0.3.
|
|
25
|
-
sim_cli_core-0.3.
|
|
26
|
-
sim_cli_core-0.3.
|
|
27
|
-
sim_cli_core-0.3.
|
|
28
|
-
sim_cli_core-0.3.
|
|
24
|
+
sim_cli_core-0.3.2.dist-info/METADATA,sha256=z7KYKfmutxZLGcexlCf1l9d4VdIXh_xWsWiOSbvix0c,17978
|
|
25
|
+
sim_cli_core-0.3.2.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
26
|
+
sim_cli_core-0.3.2.dist-info/entry_points.txt,sha256=hpg7D0fRhpgmo1IyN35XQPoyIZRSw7SLNG7tW0eacGA,37
|
|
27
|
+
sim_cli_core-0.3.2.dist-info/licenses/LICENSE,sha256=7toF0XzHlqSXvTlZ8W77R6pg2ilzKN73EOG0SioX7wQ,10762
|
|
28
|
+
sim_cli_core-0.3.2.dist-info/licenses/NOTICE,sha256=GQ0HVRFnQwrSFFm-7mYWTTtWDcko0_p2Rdv5t62glts,1752
|
|
29
|
+
sim_cli_core-0.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|