sim-cli-core 0.3.6__py3-none-any.whl → 0.3.8__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/__init__.py +11 -11
- sim/__main__.py +24 -24
- sim/_plugin_install.py +172 -352
- sim/_skills/sim-cli/SKILL.md +146 -0
- sim/_skills/sim-cli/gui/SKILL.md +239 -0
- sim/_skills/sim-cli/gui/snippets/dismiss_named_dialog.py +19 -0
- sim/_timeout.py +115 -115
- sim/assets.py +309 -0
- sim/cli.py +1407 -1410
- sim/compat.py +430 -433
- sim/config.py +377 -377
- sim/describe.py +367 -325
- sim/driver.py +190 -190
- sim/drivers/__init__.py +155 -155
- sim/gui/LICENSES/ATTRIBUTION.md +24 -24
- sim/gui/__init__.py +230 -230
- sim/gui/_pywinauto_tools.py +452 -452
- sim/gui/_win32_dialog.py +148 -148
- sim/history.py +176 -176
- sim/inspect.py +1124 -1124
- sim/plugins.py +484 -468
- sim/runner.py +195 -195
- sim/server.py +659 -581
- sim/session.py +227 -227
- sim/testing/__init__.py +30 -30
- sim/testing/protocol_conformance.py +264 -264
- {sim_cli_core-0.3.6.dist-info → sim_cli_core-0.3.8.dist-info}/METADATA +84 -112
- sim_cli_core-0.3.8.dist-info/RECORD +32 -0
- {sim_cli_core-0.3.6.dist-info → sim_cli_core-0.3.8.dist-info}/WHEEL +1 -1
- {sim_cli_core-0.3.6.dist-info → sim_cli_core-0.3.8.dist-info}/licenses/LICENSE +190 -190
- {sim_cli_core-0.3.6.dist-info → sim_cli_core-0.3.8.dist-info}/licenses/NOTICE +35 -35
- sim_cli_core-0.3.6.dist-info/RECORD +0 -28
- {sim_cli_core-0.3.6.dist-info → sim_cli_core-0.3.8.dist-info}/entry_points.txt +0 -0
sim/__init__.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"""sim — unified CLI for LLM agents to control CAD/CAE simulation software."""
|
|
2
|
-
|
|
3
|
-
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
-
|
|
5
|
-
try:
|
|
6
|
-
__version__ = version("sim-cli-core")
|
|
7
|
-
except PackageNotFoundError:
|
|
8
|
-
try:
|
|
9
|
-
__version__ = version("sim-runtime")
|
|
10
|
-
except PackageNotFoundError:
|
|
11
|
-
__version__ = "0.0.0+unknown"
|
|
1
|
+
"""sim — unified CLI for LLM agents to control CAD/CAE simulation software."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
__version__ = version("sim-cli-core")
|
|
7
|
+
except PackageNotFoundError:
|
|
8
|
+
try:
|
|
9
|
+
__version__ = version("sim-runtime")
|
|
10
|
+
except PackageNotFoundError:
|
|
11
|
+
__version__ = "0.0.0+unknown"
|
sim/__main__.py
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"""Allow ``python -m sim ...`` invocation (equivalent to the ``sim`` console script).
|
|
2
|
-
|
|
3
|
-
Why this exists
|
|
4
|
-
---------------
|
|
5
|
-
The console script ``sim`` (declared in ``[project.scripts]``) is the canonical
|
|
6
|
-
entry point for end users — it stays unchanged. This module forwards
|
|
7
|
-
``python -m sim ...`` to the same Click group so developers have a second
|
|
8
|
-
invocation that does *not* hold a Windows file lock on
|
|
9
|
-
``.venv/Scripts/sim.exe``.
|
|
10
|
-
|
|
11
|
-
That lock is the whole reason this file exists: with the editable install,
|
|
12
|
-
``uv sync`` rewrites ``Scripts/sim.exe`` on every sync, but a running
|
|
13
|
-
``sim serve`` has the exe open, so Windows refuses the rewrite (``os error
|
|
14
|
-
32``) and the entire sync aborts. Launching the dev server as
|
|
15
|
-
``python -m sim serve --reload`` instead means the running process holds
|
|
16
|
-
``python.exe`` (uv-managed, shared, not project-managed), and ``sim.exe``
|
|
17
|
-
stays free for ``uv sync`` to rewrite while iteration proceeds.
|
|
18
|
-
|
|
19
|
-
Same pattern used by pip, ruff, pytest, etc.
|
|
20
|
-
"""
|
|
21
|
-
from sim.cli import main
|
|
22
|
-
|
|
23
|
-
if __name__ == "__main__":
|
|
24
|
-
main()
|
|
1
|
+
"""Allow ``python -m sim ...`` invocation (equivalent to the ``sim`` console script).
|
|
2
|
+
|
|
3
|
+
Why this exists
|
|
4
|
+
---------------
|
|
5
|
+
The console script ``sim`` (declared in ``[project.scripts]``) is the canonical
|
|
6
|
+
entry point for end users — it stays unchanged. This module forwards
|
|
7
|
+
``python -m sim ...`` to the same Click group so developers have a second
|
|
8
|
+
invocation that does *not* hold a Windows file lock on
|
|
9
|
+
``.venv/Scripts/sim.exe``.
|
|
10
|
+
|
|
11
|
+
That lock is the whole reason this file exists: with the editable install,
|
|
12
|
+
``uv sync`` rewrites ``Scripts/sim.exe`` on every sync, but a running
|
|
13
|
+
``sim serve`` has the exe open, so Windows refuses the rewrite (``os error
|
|
14
|
+
32``) and the entire sync aborts. Launching the dev server as
|
|
15
|
+
``python -m sim serve --reload`` instead means the running process holds
|
|
16
|
+
``python.exe`` (uv-managed, shared, not project-managed), and ``sim.exe``
|
|
17
|
+
stays free for ``uv sync`` to rewrite while iteration proceeds.
|
|
18
|
+
|
|
19
|
+
Same pattern used by pip, ruff, pytest, etc.
|
|
20
|
+
"""
|
|
21
|
+
from sim.cli import main
|
|
22
|
+
|
|
23
|
+
if __name__ == "__main__":
|
|
24
|
+
main()
|
sim/_plugin_install.py
CHANGED
|
@@ -1,352 +1,172 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"""
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
"""
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
"ok": self.ok,
|
|
174
|
-
"name": self.name,
|
|
175
|
-
"source_kind": self.source_kind,
|
|
176
|
-
"pip_target": self.pip_target,
|
|
177
|
-
"pip_returncode": self.pip_returncode,
|
|
178
|
-
"pip_stdout": self.pip_stdout[-2000:], # cap for sanity
|
|
179
|
-
"pip_stderr": self.pip_stderr[-2000:],
|
|
180
|
-
"sync_skills": self.sync_skills,
|
|
181
|
-
"error_code": self.error_code,
|
|
182
|
-
"message": self.message,
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
def install_plugin(
|
|
187
|
-
source: str,
|
|
188
|
-
*,
|
|
189
|
-
editable: bool = False,
|
|
190
|
-
upgrade: bool = False,
|
|
191
|
-
offline: bool = False,
|
|
192
|
-
sync_target: Path | None = None,
|
|
193
|
-
skip_sync: bool = False,
|
|
194
|
-
python: str | None = None,
|
|
195
|
-
extra_index_urls: list[str] | None = None,
|
|
196
|
-
) -> InstallReport:
|
|
197
|
-
"""High-level installer used by ``sim plugin install``.
|
|
198
|
-
|
|
199
|
-
Returns an InstallReport — never raises for normal failures (bad source,
|
|
200
|
-
pip non-zero, sync failure). Catches and reports cleanly so the CLI
|
|
201
|
-
layer can render either JSON or human output without try/except.
|
|
202
|
-
|
|
203
|
-
``python`` overrides the install-target interpreter. Defaults to
|
|
204
|
-
``sys.executable`` (the interpreter running ``sim``).
|
|
205
|
-
"""
|
|
206
|
-
try:
|
|
207
|
-
resolved = resolve_source(source, offline=offline)
|
|
208
|
-
except (ValueError, FileNotFoundError) as e:
|
|
209
|
-
return InstallReport(
|
|
210
|
-
ok=False, name=None, source_kind="invalid", pip_target=source,
|
|
211
|
-
pip_returncode=-1, pip_stdout="", pip_stderr="",
|
|
212
|
-
error_code="PLUGIN_NOT_FOUND",
|
|
213
|
-
message=str(e),
|
|
214
|
-
)
|
|
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
|
-
|
|
220
|
-
proc = _pip_install(
|
|
221
|
-
resolved.pip_target,
|
|
222
|
-
editable=editable,
|
|
223
|
-
upgrade=upgrade,
|
|
224
|
-
python=python,
|
|
225
|
-
extra_args=extra_args or None,
|
|
226
|
-
)
|
|
227
|
-
ok = proc.returncode == 0
|
|
228
|
-
|
|
229
|
-
if not ok:
|
|
230
|
-
return InstallReport(
|
|
231
|
-
ok=False, name=resolved.name, source_kind=resolved.kind,
|
|
232
|
-
pip_target=resolved.pip_target,
|
|
233
|
-
pip_returncode=proc.returncode,
|
|
234
|
-
pip_stdout=proc.stdout, pip_stderr=proc.stderr,
|
|
235
|
-
error_code="PLUGIN_INSTALL_FAILED",
|
|
236
|
-
message=f"pip install returned {proc.returncode}",
|
|
237
|
-
)
|
|
238
|
-
|
|
239
|
-
sync_result: dict[str, Any] | None = None
|
|
240
|
-
if not skip_sync:
|
|
241
|
-
try:
|
|
242
|
-
from sim.plugins import sync_skills_to
|
|
243
|
-
target = sync_target or _default_skills_target()
|
|
244
|
-
sync_result = sync_skills_to(target)
|
|
245
|
-
except Exception as e: # noqa: BLE001 — sync is best-effort
|
|
246
|
-
sync_result = {"ok": False, "message": f"{type(e).__name__}: {e}"}
|
|
247
|
-
|
|
248
|
-
return InstallReport(
|
|
249
|
-
ok=True, name=resolved.name, source_kind=resolved.kind,
|
|
250
|
-
pip_target=resolved.pip_target,
|
|
251
|
-
pip_returncode=proc.returncode,
|
|
252
|
-
pip_stdout=proc.stdout, pip_stderr=proc.stderr,
|
|
253
|
-
sync_skills=sync_result,
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
def _default_skills_target() -> Path:
|
|
258
|
-
"""Where ``sync-skills`` writes by default.
|
|
259
|
-
|
|
260
|
-
Uses ``./.claude/skills/`` if a ``.claude`` dir exists in cwd; falls
|
|
261
|
-
back to ``~/.claude/skills/``. This matches Claude Code's discovery.
|
|
262
|
-
"""
|
|
263
|
-
project = Path.cwd() / ".claude"
|
|
264
|
-
if project.is_dir():
|
|
265
|
-
return project / "skills"
|
|
266
|
-
return Path.home() / ".claude" / "skills"
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
# ── Uninstall ───────────────────────────────────────────────────────────────
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
def uninstall_plugin(name: str, *, sync: bool = True,
|
|
273
|
-
python: str | None = None) -> dict[str, Any]:
|
|
274
|
-
"""Best-effort plugin uninstall.
|
|
275
|
-
|
|
276
|
-
Tries the canonical PyPI distribution name (``sim-plugin-<name>``)
|
|
277
|
-
first, then falls back to whatever package the registry says owns
|
|
278
|
-
that driver. ``python`` pins the target interpreter (defaults to
|
|
279
|
-
``sys.executable``).
|
|
280
|
-
"""
|
|
281
|
-
from sim.plugins import list_installed_plugins
|
|
282
|
-
|
|
283
|
-
rows = {p.name: p for p in list_installed_plugins()}
|
|
284
|
-
if name not in rows:
|
|
285
|
-
return {"ok": False, "error_code": "PLUGIN_NOT_FOUND",
|
|
286
|
-
"message": f"unknown plugin: {name!r}"}
|
|
287
|
-
if rows[name].builtin:
|
|
288
|
-
return {"ok": False, "error_code": "PLUGIN_INSTALL_FAILED",
|
|
289
|
-
"message": "cannot uninstall a built-in driver — wait for v1.0 cut "
|
|
290
|
-
"or remove from sim-cli's _BUILTIN_REGISTRY."}
|
|
291
|
-
|
|
292
|
-
package = rows[name].package or f"sim-plugin-{name}"
|
|
293
|
-
target_python = python or sys.executable
|
|
294
|
-
use_uv = shutil.which("uv") is not None
|
|
295
|
-
cmd = (["uv", "pip", "uninstall", "--python", target_python, package] if use_uv
|
|
296
|
-
else [target_python, "-m", "pip", "uninstall", "-y", package])
|
|
297
|
-
proc = subprocess.run(cmd, capture_output=True, text=True)
|
|
298
|
-
|
|
299
|
-
if proc.returncode != 0:
|
|
300
|
-
return {"ok": False, "error_code": "PLUGIN_INSTALL_FAILED",
|
|
301
|
-
"message": f"pip uninstall returned {proc.returncode}",
|
|
302
|
-
"pip_stderr": proc.stderr[-1000:]}
|
|
303
|
-
|
|
304
|
-
# Remove the on-disk skill copy if present.
|
|
305
|
-
if sync:
|
|
306
|
-
target = _default_skills_target() / name
|
|
307
|
-
if target.is_symlink():
|
|
308
|
-
target.unlink()
|
|
309
|
-
elif target.is_dir():
|
|
310
|
-
shutil.rmtree(target)
|
|
311
|
-
return {"ok": True, "package": package, "name": name}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
# ── Bundle ──────────────────────────────────────────────────────────────────
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
def bundle_plugins(names: list[str], output_dir: Path, *,
|
|
318
|
-
index_url: str | None = None) -> dict[str, Any]:
|
|
319
|
-
"""The install-resolver-backed bundle flow was removed.
|
|
320
|
-
|
|
321
|
-
See https://github.com/svd-ai-lab/sim-plugin-index for a curated plugin
|
|
322
|
-
list, then download explicit wheel URLs or install exact package specs.
|
|
323
|
-
There is no install-time resolver to map short names to wheels.
|
|
324
|
-
"""
|
|
325
|
-
_ = (names, output_dir, index_url)
|
|
326
|
-
return {
|
|
327
|
-
"ok": False,
|
|
328
|
-
"output": str(output_dir),
|
|
329
|
-
"fetched": [],
|
|
330
|
-
"errors": [
|
|
331
|
-
{
|
|
332
|
-
"name": name,
|
|
333
|
-
"error": (
|
|
334
|
-
"bundle no longer resolves short plugin names; see "
|
|
335
|
-
"https://github.com/svd-ai-lab/sim-plugin-index for a "
|
|
336
|
-
"curated plugin list, then pass explicit wheel URLs, "
|
|
337
|
-
"local artifacts, git URLs, or exact package specs"
|
|
338
|
-
),
|
|
339
|
-
}
|
|
340
|
-
for name in names
|
|
341
|
-
],
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
__all__ = [
|
|
346
|
-
"ResolvedSource",
|
|
347
|
-
"InstallReport",
|
|
348
|
-
"resolve_source",
|
|
349
|
-
"install_plugin",
|
|
350
|
-
"uninstall_plugin",
|
|
351
|
-
"bundle_plugins",
|
|
352
|
-
]
|
|
1
|
+
"""Migration shims for retired plugin installer commands.
|
|
2
|
+
|
|
3
|
+
``sim`` no longer installs or uninstalls plugin packages. Package mutation
|
|
4
|
+
belongs to the user's uv project; sim inspects installed packages, checks
|
|
5
|
+
drivers, and syncs bundled skills.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
_PACKAGE_SPEC_RE = re.compile(
|
|
16
|
+
r"^(sim-plugin-[A-Za-z0-9][A-Za-z0-9_.-]*)(?:\[[A-Za-z0-9_,.-]+\])?"
|
|
17
|
+
r"(?:\s*(?:==|!=|~=|>=|<=|>|<)\s*[A-Za-z0-9.*+!_.-]+)?$"
|
|
18
|
+
)
|
|
19
|
+
_SHORT_NAME_RE = re.compile(r"^[A-Za-z][A-Za-z0-9_]*$")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _install_migration_message(source: str | None = None) -> str:
|
|
23
|
+
base = (
|
|
24
|
+
"sim plugin install is retired.\n\n"
|
|
25
|
+
"Add plugins with uv instead:\n"
|
|
26
|
+
" uv add sim-cli-core <plugin-package-spec>\n"
|
|
27
|
+
" uv run sim plugin sync-skills --target .agents/skills --copy\n"
|
|
28
|
+
" uv run sim check <solver>"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
if source:
|
|
32
|
+
match = _PACKAGE_SPEC_RE.match(source.strip())
|
|
33
|
+
if match:
|
|
34
|
+
return (
|
|
35
|
+
f"{base}\n\n"
|
|
36
|
+
f"For this package spec, run:\n"
|
|
37
|
+
f" uv add sim-cli-core {source.strip()}"
|
|
38
|
+
)
|
|
39
|
+
if _SHORT_NAME_RE.match(source.strip()):
|
|
40
|
+
return (
|
|
41
|
+
f"{base}\n\n"
|
|
42
|
+
"Short solver names are not package specs. Find the package spec in "
|
|
43
|
+
"docs.svdailab.com/plugin-index or sim-plugin-index, then run:\n"
|
|
44
|
+
" uv add sim-cli-core <plugin-package-spec>"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return base
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _uninstall_migration_message(name: str | None = None) -> str:
|
|
51
|
+
package = None
|
|
52
|
+
if name:
|
|
53
|
+
clean = name.strip()
|
|
54
|
+
package = clean if clean.startswith("sim-plugin-") else f"sim-plugin-{clean}"
|
|
55
|
+
command = f" uv remove {package}" if package else " uv remove <plugin-package-spec>"
|
|
56
|
+
return (
|
|
57
|
+
"sim plugin uninstall is retired.\n\n"
|
|
58
|
+
"Remove plugin packages with uv instead:\n"
|
|
59
|
+
f"{command}\n"
|
|
60
|
+
" uv run sim plugin sync-skills --target .agents/skills --copy"
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass
|
|
65
|
+
class InstallReport:
|
|
66
|
+
ok: bool
|
|
67
|
+
name: str | None
|
|
68
|
+
source_kind: str
|
|
69
|
+
pip_target: str
|
|
70
|
+
pip_returncode: int
|
|
71
|
+
pip_stdout: str
|
|
72
|
+
pip_stderr: str
|
|
73
|
+
sync_skills: dict[str, Any] | None = None
|
|
74
|
+
error_code: str | None = None
|
|
75
|
+
message: str = ""
|
|
76
|
+
|
|
77
|
+
def to_dict(self) -> dict[str, Any]:
|
|
78
|
+
return {
|
|
79
|
+
"ok": self.ok,
|
|
80
|
+
"name": self.name,
|
|
81
|
+
"source_kind": self.source_kind,
|
|
82
|
+
"pip_target": self.pip_target,
|
|
83
|
+
"pip_returncode": self.pip_returncode,
|
|
84
|
+
"pip_stdout": self.pip_stdout[-2000:],
|
|
85
|
+
"pip_stderr": self.pip_stderr[-2000:],
|
|
86
|
+
"sync_skills": self.sync_skills,
|
|
87
|
+
"error_code": self.error_code,
|
|
88
|
+
"message": self.message,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def install_plugin(
|
|
93
|
+
source: str,
|
|
94
|
+
*,
|
|
95
|
+
editable: bool = False,
|
|
96
|
+
upgrade: bool = False,
|
|
97
|
+
offline: bool = False,
|
|
98
|
+
sync_target: Path | None = None,
|
|
99
|
+
skip_sync: bool = False,
|
|
100
|
+
python: str | None = None,
|
|
101
|
+
extra_index_urls: list[str] | None = None,
|
|
102
|
+
) -> InstallReport:
|
|
103
|
+
"""Return migration guidance without invoking pip or uv pip."""
|
|
104
|
+
_ = (editable, upgrade, offline, sync_target, skip_sync, python, extra_index_urls)
|
|
105
|
+
match = _PACKAGE_SPEC_RE.match(source.strip())
|
|
106
|
+
return InstallReport(
|
|
107
|
+
ok=False,
|
|
108
|
+
name=match.group(1) if match else None,
|
|
109
|
+
source_kind="retired",
|
|
110
|
+
pip_target=source,
|
|
111
|
+
pip_returncode=-1,
|
|
112
|
+
pip_stdout="",
|
|
113
|
+
pip_stderr="",
|
|
114
|
+
error_code="PLUGIN_INSTALL_RETIRED",
|
|
115
|
+
message=_install_migration_message(source),
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _default_skills_target() -> Path:
|
|
120
|
+
"""Where ``sync-skills`` writes by default.
|
|
121
|
+
|
|
122
|
+
Uses ``./.claude/skills/`` if a ``.claude`` dir exists in cwd; falls
|
|
123
|
+
back to ``~/.claude/skills/``. This matches Claude Code's discovery.
|
|
124
|
+
"""
|
|
125
|
+
project = Path.cwd() / ".claude"
|
|
126
|
+
if project.is_dir():
|
|
127
|
+
return project / "skills"
|
|
128
|
+
return Path.home() / ".claude" / "skills"
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def uninstall_plugin(name: str, *, sync: bool = True,
|
|
132
|
+
python: str | None = None) -> dict[str, Any]:
|
|
133
|
+
"""Return migration guidance without invoking pip or uv pip."""
|
|
134
|
+
_ = (sync, python)
|
|
135
|
+
return {
|
|
136
|
+
"ok": False,
|
|
137
|
+
"name": name,
|
|
138
|
+
"error_code": "PLUGIN_INSTALL_RETIRED",
|
|
139
|
+
"message": _uninstall_migration_message(name),
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def bundle_plugins(names: list[str], output_dir: Path, *,
|
|
144
|
+
index_url: str | None = None) -> dict[str, Any]:
|
|
145
|
+
"""Return migration guidance for the removed bundle flow."""
|
|
146
|
+
_ = index_url
|
|
147
|
+
return {
|
|
148
|
+
"ok": False,
|
|
149
|
+
"output": str(output_dir),
|
|
150
|
+
"fetched": [],
|
|
151
|
+
"errors": [
|
|
152
|
+
{
|
|
153
|
+
"name": name,
|
|
154
|
+
"error_code": "PLUGIN_INSTALL_RETIRED",
|
|
155
|
+
"error": (
|
|
156
|
+
"sim plugin bundle is retired. Add plugin packages with "
|
|
157
|
+
"uv add sim-cli-core <plugin-package-spec> in the target "
|
|
158
|
+
"uv project instead."
|
|
159
|
+
),
|
|
160
|
+
}
|
|
161
|
+
for name in names
|
|
162
|
+
],
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
__all__ = [
|
|
167
|
+
"InstallReport",
|
|
168
|
+
"install_plugin",
|
|
169
|
+
"uninstall_plugin",
|
|
170
|
+
"bundle_plugins",
|
|
171
|
+
"_default_skills_target",
|
|
172
|
+
]
|