sim-cli-core 0.3.8__py3-none-any.whl → 0.3.9__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 -172
- sim/_skills/sim-cli/SKILL.md +146 -146
- sim/_skills/sim-cli/gui/SKILL.md +239 -239
- sim/_skills/sim-cli/gui/snippets/dismiss_named_dialog.py +19 -19
- sim/_timeout.py +115 -115
- sim/cli.py +1379 -1379
- sim/compat.py +430 -430
- sim/config.py +377 -377
- sim/describe.py +318 -318
- 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 -484
- sim/runner.py +195 -195
- sim/server.py +659 -659
- sim/session.py +227 -227
- sim/testing/__init__.py +30 -30
- sim/testing/protocol_conformance.py +264 -264
- sim_cli_core-0.3.9.dist-info/METADATA +235 -0
- sim_cli_core-0.3.9.dist-info/RECORD +32 -0
- {sim_cli_core-0.3.8.dist-info → sim_cli_core-0.3.9.dist-info}/licenses/LICENSE +190 -190
- {sim_cli_core-0.3.8.dist-info → sim_cli_core-0.3.9.dist-info}/licenses/NOTICE +35 -35
- sim_cli_core-0.3.8.dist-info/METADATA +0 -391
- sim_cli_core-0.3.8.dist-info/RECORD +0 -32
- {sim_cli_core-0.3.8.dist-info → sim_cli_core-0.3.9.dist-info}/WHEEL +0 -0
- {sim_cli_core-0.3.8.dist-info → sim_cli_core-0.3.9.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,172 +1,172 @@
|
|
|
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
|
-
]
|
|
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
|
+
]
|