sim-cli-core 0.2.4__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.
Files changed (138) hide show
  1. sim_cli_core-0.2.4/.github/workflows/publish.yml +46 -0
  2. sim_cli_core-0.2.4/.gitignore +63 -0
  3. sim_cli_core-0.2.4/CLAUDE.md +192 -0
  4. sim_cli_core-0.2.4/CONTRIBUTING.md +25 -0
  5. sim_cli_core-0.2.4/LICENSE +190 -0
  6. sim_cli_core-0.2.4/NOTICE +72 -0
  7. sim_cli_core-0.2.4/PKG-INFO +309 -0
  8. sim_cli_core-0.2.4/README.md +267 -0
  9. sim_cli_core-0.2.4/assets/architecture.svg +89 -0
  10. sim_cli_core-0.2.4/assets/banner.svg +70 -0
  11. sim_cli_core-0.2.4/assets/logo.svg +22 -0
  12. sim_cli_core-0.2.4/docs/DEVELOPMENT.md +109 -0
  13. sim_cli_core-0.2.4/docs/README.de.md +248 -0
  14. sim_cli_core-0.2.4/docs/README.ja.md +247 -0
  15. sim_cli_core-0.2.4/docs/README.zh.md +245 -0
  16. sim_cli_core-0.2.4/docs/agent-readability.md +190 -0
  17. sim_cli_core-0.2.4/docs/architecture/multi-session-and-config.md +204 -0
  18. sim_cli_core-0.2.4/docs/architecture/skills-layering-plan.md +306 -0
  19. sim_cli_core-0.2.4/docs/architecture/version-compat.md +130 -0
  20. sim_cli_core-0.2.4/docs/plugin-install.md +178 -0
  21. sim_cli_core-0.2.4/pyproject.toml +70 -0
  22. sim_cli_core-0.2.4/src/sim/__init__.py +11 -0
  23. sim_cli_core-0.2.4/src/sim/__main__.py +24 -0
  24. sim_cli_core-0.2.4/src/sim/_plugin_install.py +451 -0
  25. sim_cli_core-0.2.4/src/sim/_timeout.py +115 -0
  26. sim_cli_core-0.2.4/src/sim/cli.py +1353 -0
  27. sim_cli_core-0.2.4/src/sim/compat.py +411 -0
  28. sim_cli_core-0.2.4/src/sim/config.py +380 -0
  29. sim_cli_core-0.2.4/src/sim/describe.py +346 -0
  30. sim_cli_core-0.2.4/src/sim/driver.py +190 -0
  31. sim_cli_core-0.2.4/src/sim/drivers/__init__.py +161 -0
  32. sim_cli_core-0.2.4/src/sim/drivers/coolprop/__init__.py +3 -0
  33. sim_cli_core-0.2.4/src/sim/drivers/coolprop/driver.py +183 -0
  34. sim_cli_core-0.2.4/src/sim/drivers/openfoam/__init__.py +4 -0
  35. sim_cli_core-0.2.4/src/sim/drivers/openfoam/compatibility.yaml +37 -0
  36. sim_cli_core-0.2.4/src/sim/drivers/openfoam/driver.py +432 -0
  37. sim_cli_core-0.2.4/src/sim/gui/LICENSES/ATTRIBUTION.md +24 -0
  38. sim_cli_core-0.2.4/src/sim/gui/__init__.py +230 -0
  39. sim_cli_core-0.2.4/src/sim/gui/_pywinauto_tools.py +452 -0
  40. sim_cli_core-0.2.4/src/sim/gui/_win32_dialog.py +148 -0
  41. sim_cli_core-0.2.4/src/sim/history.py +170 -0
  42. sim_cli_core-0.2.4/src/sim/inspect.py +1088 -0
  43. sim_cli_core-0.2.4/src/sim/plugins.py +468 -0
  44. sim_cli_core-0.2.4/src/sim/runner.py +195 -0
  45. sim_cli_core-0.2.4/src/sim/server.py +547 -0
  46. sim_cli_core-0.2.4/src/sim/session.py +224 -0
  47. sim_cli_core-0.2.4/src/sim/testing/__init__.py +30 -0
  48. sim_cli_core-0.2.4/src/sim/testing/protocol_conformance.py +264 -0
  49. sim_cli_core-0.2.4/tests/__init__.py +0 -0
  50. sim_cli_core-0.2.4/tests/base/__init__.py +0 -0
  51. sim_cli_core-0.2.4/tests/base/test_cli.py +211 -0
  52. sim_cli_core-0.2.4/tests/base/test_compat.py +356 -0
  53. sim_cli_core-0.2.4/tests/base/test_config.py +122 -0
  54. sim_cli_core-0.2.4/tests/base/test_connect.py +26 -0
  55. sim_cli_core-0.2.4/tests/base/test_describe.py +170 -0
  56. sim_cli_core-0.2.4/tests/base/test_driver_discovery.py +135 -0
  57. sim_cli_core-0.2.4/tests/base/test_history.py +98 -0
  58. sim_cli_core-0.2.4/tests/base/test_init_setup.py +193 -0
  59. sim_cli_core-0.2.4/tests/base/test_lint.py +49 -0
  60. sim_cli_core-0.2.4/tests/base/test_lint_public_corpus.py +159 -0
  61. sim_cli_core-0.2.4/tests/base/test_logs.py +100 -0
  62. sim_cli_core-0.2.4/tests/base/test_multi_session.py +193 -0
  63. sim_cli_core-0.2.4/tests/base/test_plugin_install.py +307 -0
  64. sim_cli_core-0.2.4/tests/base/test_plugins.py +158 -0
  65. sim_cli_core-0.2.4/tests/base/test_protocol_conformance.py +222 -0
  66. sim_cli_core-0.2.4/tests/base/test_run.py +127 -0
  67. sim_cli_core-0.2.4/tests/conftest.py +114 -0
  68. sim_cli_core-0.2.4/tests/drivers/__init__.py +0 -0
  69. sim_cli_core-0.2.4/tests/drivers/coolprop/__init__.py +0 -0
  70. sim_cli_core-0.2.4/tests/drivers/coolprop/test_coolprop_driver.py +90 -0
  71. sim_cli_core-0.2.4/tests/drivers/coolprop/test_coolprop_e2e.py +36 -0
  72. sim_cli_core-0.2.4/tests/execution/calculix_e2e_cantilever_run.py +163 -0
  73. sim_cli_core-0.2.4/tests/execution/coolprop/water_props.py +33 -0
  74. sim_cli_core-0.2.4/tests/execution/elmer_e2e_heat_square.py +171 -0
  75. sim_cli_core-0.2.4/tests/execution/gmsh_e2e_sphere_mesh.py +131 -0
  76. sim_cli_core-0.2.4/tests/execution/lammps_e2e_lj_nvt.py +159 -0
  77. sim_cli_core-0.2.4/tests/execution/meshio_e2e_gmsh_to_vtk.py +105 -0
  78. sim_cli_core-0.2.4/tests/execution/pymfem_e2e_poisson.py +78 -0
  79. sim_cli_core-0.2.4/tests/execution/pyvista_e2e_sphere_stats.py +109 -0
  80. sim_cli_core-0.2.4/tests/execution/scikit_fem_e2e_poisson.py +60 -0
  81. sim_cli_core-0.2.4/tests/execution/scikitrf/short_load.py +32 -0
  82. sim_cli_core-0.2.4/tests/execution/su2_e2e_inviscid_bump.py +113 -0
  83. sim_cli_core-0.2.4/tests/fixtures/comsol/comsol_good.py +12 -0
  84. sim_cli_core-0.2.4/tests/fixtures/comsol/comsol_no_client.py +4 -0
  85. sim_cli_core-0.2.4/tests/fixtures/comsol/comsol_no_import.py +3 -0
  86. sim_cli_core-0.2.4/tests/fixtures/coolprop_good.py +5 -0
  87. sim_cli_core-0.2.4/tests/fixtures/coolprop_no_import.py +1 -0
  88. sim_cli_core-0.2.4/tests/fixtures/coolprop_no_usage.py +2 -0
  89. sim_cli_core-0.2.4/tests/fixtures/coolprop_syntax_error.py +2 -0
  90. sim_cli_core-0.2.4/tests/fixtures/hypermesh_good.py +13 -0
  91. sim_cli_core-0.2.4/tests/fixtures/hypermesh_gui.py +7 -0
  92. sim_cli_core-0.2.4/tests/fixtures/hypermesh_no_import.py +3 -0
  93. sim_cli_core-0.2.4/tests/fixtures/hypermesh_no_usage.py +3 -0
  94. sim_cli_core-0.2.4/tests/fixtures/hypermesh_syntax_error.py +4 -0
  95. sim_cli_core-0.2.4/tests/fixtures/isaac/bad_import_order.py +5 -0
  96. sim_cli_core-0.2.4/tests/fixtures/isaac/bad_no_close.py +4 -0
  97. sim_cli_core-0.2.4/tests/fixtures/isaac/bad_no_simapp.py +3 -0
  98. sim_cli_core-0.2.4/tests/fixtures/isaac/hello_world.py +51 -0
  99. sim_cli_core-0.2.4/tests/fixtures/isaac/import_franka.py +34 -0
  100. sim_cli_core-0.2.4/tests/fixtures/isaac/not_isaac.py +2 -0
  101. sim_cli_core-0.2.4/tests/fixtures/isaac/official_hello_world.py +50 -0
  102. sim_cli_core-0.2.4/tests/fixtures/isaac/replicator_cubes.py +57 -0
  103. sim_cli_core-0.2.4/tests/fixtures/isaac/syntax_error.py +2 -0
  104. sim_cli_core-0.2.4/tests/fixtures/isaac/warehouse_sdg.py +50 -0
  105. sim_cli_core-0.2.4/tests/fixtures/matlab/empty_model.mdl +0 -0
  106. sim_cli_core-0.2.4/tests/fixtures/matlab/empty_model.slx +0 -0
  107. sim_cli_core-0.2.4/tests/fixtures/matlab/matlab_ok.m +2 -0
  108. sim_cli_core-0.2.4/tests/fixtures/mfem_good.py +14 -0
  109. sim_cli_core-0.2.4/tests/fixtures/mfem_no_import.py +3 -0
  110. sim_cli_core-0.2.4/tests/fixtures/mfem_no_mesh.py +3 -0
  111. sim_cli_core-0.2.4/tests/fixtures/mfem_syntax_error.py +3 -0
  112. sim_cli_core-0.2.4/tests/fixtures/mock_fail.py +5 -0
  113. sim_cli_core-0.2.4/tests/fixtures/mock_solver.py +6 -0
  114. sim_cli_core-0.2.4/tests/fixtures/newton/basic_pendulum.json +34 -0
  115. sim_cli_core-0.2.4/tests/fixtures/newton/cable_twist.py +75 -0
  116. sim_cli_core-0.2.4/tests/fixtures/newton/robot_g1.json +42 -0
  117. sim_cli_core-0.2.4/tests/fixtures/not_simulation.py +2 -0
  118. sim_cli_core-0.2.4/tests/fixtures/pybamm/pybamm_bad_import.py +4 -0
  119. sim_cli_core-0.2.4/tests/fixtures/pybamm/pybamm_crate_sweep.py +43 -0
  120. sim_cli_core-0.2.4/tests/fixtures/pybamm/pybamm_no_solve.py +6 -0
  121. sim_cli_core-0.2.4/tests/fixtures/pybamm/pybamm_spm_good.py +47 -0
  122. sim_cli_core-0.2.4/tests/fixtures/skfem_good.py +22 -0
  123. sim_cli_core-0.2.4/tests/fixtures/skfem_no_import.py +3 -0
  124. sim_cli_core-0.2.4/tests/fixtures/skfem_no_solve.py +6 -0
  125. sim_cli_core-0.2.4/tests/fixtures/skfem_syntax_error.py +3 -0
  126. sim_cli_core-0.2.4/tests/gui/__init__.py +0 -0
  127. sim_cli_core-0.2.4/tests/gui/test_connect_tools_field.py +87 -0
  128. sim_cli_core-0.2.4/tests/gui/test_gui_facade.py +164 -0
  129. sim_cli_core-0.2.4/tests/inspect/__init__.py +0 -0
  130. sim_cli_core-0.2.4/tests/inspect/_extract_comsol_Tmax.py +81 -0
  131. sim_cli_core-0.2.4/tests/inspect/test_channel_3_4_5_9.py +401 -0
  132. sim_cli_core-0.2.4/tests/inspect/test_gui_probes.py +218 -0
  133. sim_cli_core-0.2.4/tests/inspect/test_inspect_types.py +164 -0
  134. sim_cli_core-0.2.4/tests/inspect/test_probes.py +244 -0
  135. sim_cli_core-0.2.4/tests/inspect/test_snippet_timeout.py +110 -0
  136. sim_cli_core-0.2.4/tools/extract_driver.py +598 -0
  137. sim_cli_core-0.2.4/tools/lint-public-corpus.py +279 -0
  138. sim_cli_core-0.2.4/uv.lock +1662 -0
@@ -0,0 +1,46 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - uses: astral-sh/setup-uv@v5
15
+ with:
16
+ python-version: "3.12"
17
+
18
+ - name: Build sdist + wheel
19
+ run: uv build
20
+
21
+ - name: Sanity-check artifacts
22
+ run: |
23
+ uv tool run twine check dist/*
24
+ ls -lh dist/
25
+
26
+ - uses: actions/upload-artifact@v4
27
+ with:
28
+ name: dist
29
+ path: dist/
30
+
31
+ publish:
32
+ name: Upload to PyPI (trusted publishing)
33
+ needs: build
34
+ runs-on: ubuntu-latest
35
+ environment:
36
+ name: pypi
37
+ url: https://pypi.org/p/sim-cli-core
38
+ permissions:
39
+ id-token: write
40
+ steps:
41
+ - uses: actions/download-artifact@v4
42
+ with:
43
+ name: dist
44
+ path: dist/
45
+
46
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,63 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ *.egg
6
+ build/
7
+ dist/
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ .mypy_cache/
11
+
12
+ # Virtual envs
13
+ .venv/
14
+ venv/
15
+ env/
16
+
17
+ # sim runtime artifacts
18
+ .sim/
19
+
20
+ # IDE
21
+ .vscode/
22
+ .idea/
23
+ *.swp
24
+
25
+ # OS
26
+ .DS_Store
27
+ Thumbs.db
28
+
29
+ # Local test output
30
+ tests/execution/logs/
31
+ *.log
32
+
33
+ # Solver run artifacts at repo root (Fluent trace files, ad-hoc screenshots)
34
+ /*.trn
35
+ /*.png
36
+
37
+ # Local Claude Code skills (project-private, do not publish)
38
+ .claude/
39
+
40
+ # Local/temp files
41
+ mylocal.ip
42
+ *.sim
43
+ __pycache__/
44
+ tmp/
45
+
46
+ # Solver-runtime temp files (Fluent cleanup scripts / COMSOL tetra scratch / misc .tmp)
47
+ /cleanup-fluent-*.bat
48
+ /*.tmp
49
+
50
+ # LSDYNA runtime outputs — produced by every solver invocation, not fixtures
51
+ tests/execution/lsdyna/d3dump[0-9]*
52
+ tests/execution/lsdyna/d3hsp
53
+ tests/execution/lsdyna/d3plot*
54
+ tests/execution/lsdyna/messag
55
+ tests/execution/lsdyna/status.out
56
+
57
+ # Inspect integration-test outputs (reproducible; do not check in)
58
+ tests/inspect/_run_outputs/
59
+
60
+ # Local self-reading plan docs (not shipped with PR)
61
+ docs/abaqus-plan.md
62
+ docs/plans/
63
+ docs/superpowers/
@@ -0,0 +1,192 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ **sim** is a unified CLI + HTTP runtime that lets LLM agents (and engineers) launch, drive, and observe CAD/CAE simulations across multiple solvers through one consistent interface. It is the "container runtime for simulations" — agents talk to `sim`, `sim` talks to solvers.
8
+
9
+ The runtime supports two execution modes:
10
+
11
+ - **One-shot** (`sim run script --solver=X`): subprocess execution, result stored as a numbered run, `sim logs` to browse.
12
+ - **Persistent session** (`sim serve` + `sim connect/exec/inspect/disconnect`): a long-lived HTTP server holds a live solver session; agents send code snippets and inspect state without restarting the solver.
13
+
14
+ The companion repo `sim-skills/` contains per-solver agent skills, reference docs, demo workflows, and integration tests that drive this runtime.
15
+
16
+ ## Commands
17
+
18
+ ```bash
19
+ # Install
20
+ uv pip install -e ".[dev]" # core + pytest + ruff
21
+
22
+ # Tests
23
+ pytest -q # unit tests (no solver needed)
24
+ pytest tests/test_lint.py # single test file
25
+ pytest -q -m integration # integration tests (need solvers + sim serve)
26
+
27
+ # Lint
28
+ ruff check src/sim tests
29
+ ruff check --fix src/sim tests
30
+
31
+ # CLI
32
+ sim serve --host 0.0.0.0 # start HTTP server (default port 7600)
33
+ sim --host <ip> connect --solver <name> --mode solver --ui-mode gui
34
+ sim --host <ip> exec "solver.settings.mesh.check()"
35
+ sim --host <ip> inspect session.summary
36
+ sim --host <ip> screenshot -o shot.png
37
+ sim --host <ip> disconnect
38
+
39
+ sim run script.py --solver pybamm # one-shot mode
40
+ sim logs # list runs
41
+ sim logs last --field voltage_V # extract a parsed field
42
+ sim check <name> # solver availability
43
+ sim lint script.py # validate before running
44
+ ```
45
+
46
+ Environment variables: `SIM_HOST`, `SIM_PORT` (CLI client, also `[server]` in config), `SIM_HOME` (global config + history dir, default `~/.sim/`), `SIM_DIR` (project dir, default `./.sim/`).
47
+
48
+ Config files (issue #5): `~/.sim/config.toml` (global) + `.sim/config.toml` (project). Resolution order `env > project > global > default`. With no config files present, behavior is unchanged from pre-config sim. Run `sim config path | show | init` to manage. See `docs/architecture/multi-session-and-config.md` for the full schema.
49
+
50
+ ## Architecture
51
+
52
+ ### CLI (`src/sim/cli.py`)
53
+ Click app with subcommands: `serve`, `check`, `lint`, `run`, `connect`, `exec`, `inspect`, `ps`, `disconnect`, `screenshot`, `logs`. The session-related commands (`connect`/`exec`/`inspect`/`ps`/`disconnect`/`screenshot`) all delegate to `sim.session.SessionClient`, an HTTP client that talks to a running `sim serve`. The non-session commands (`run`, `lint`, `check`, `logs`) work locally without a server.
54
+
55
+ ### HTTP server (`src/sim/server.py`)
56
+ FastAPI app exposing:
57
+ - `POST /connect` — launch a solver, register a new session in `_sessions: dict[str, SessionState]` keyed by session_id
58
+ - `POST /exec` — `exec()` a Python snippet against the live `session`/`meshing`/`solver` namespace for the session selected by `X-Sim-Session` header (or the single live session if unambiguous); capture stdout/stderr/return value, append to that session's runs
59
+ - `GET /inspect/<name>` — query `session.summary`, `session.mode`, `last.result`, `workflow.summary` (session-scoped)
60
+ - `POST /run` — one-shot script execution (no session required)
61
+ - `GET /ps` — list of all live sessions + default_session (set only when exactly one live)
62
+ - `GET /screenshot` — base64 PNG of the server's desktop
63
+ - `POST /disconnect` — tear down the session selected by `X-Sim-Session` (or the sole live session)
64
+ - `POST /shutdown` — tear down all sessions, exit the server process
65
+
66
+ The server supports multiple concurrent sessions keyed by session_id. Each `SessionState` carries its own `threading.Lock` so exec/inspect against different sessions can run in parallel. A single solver name can only be live once (driver instances are module-level singletons).
67
+
68
+ **`sim serve --reload` drops all sessions on any source change under the watched tree.** uvicorn's reload watchdog observes file mtimes in `src/sim/**`; any edit (git pull, scp of a modified driver, even touching an unrelated module) restarts the worker, wiping `_sessions`. Child solver processes (out-of-process GUIs, separately spawned solver binaries) survive the reload because they're spawned separately, but the session handles to them are gone — you have to `connect` again. Driver temp files written into the solver's workspace live outside `src/` so they don't retrigger. Practical rules:
69
+
70
+ - Don't edit driver code mid-experiment; finish the run, then edit.
71
+ - For long autonomous experiments where you're editing driver code iteratively, launch **without** `--reload` and restart manually when you want the new code picked up.
72
+ - Reconnecting after a reload can take tens of seconds for GUI-mode drivers that re-adopt the existing window rather than relaunching it.
73
+
74
+ ### Driver protocol (`src/sim/driver.py`)
75
+ `DriverProtocol` (a `runtime_checkable` `Protocol`):
76
+ - `name: str` — registered driver name
77
+ - `detect(script) -> bool` — does this script target this solver?
78
+ - `lint(script) -> LintResult` — pre-execution validation, returns `Diagnostic`s
79
+ - `connect() -> ConnectionInfo` — package availability + version check
80
+ - `parse_output(stdout) -> dict` — extract structured results (convention: last JSON line on stdout)
81
+ - `run_file(script) -> RunResult` — one-shot execution
82
+
83
+ `LintResult`, `Diagnostic`, `RunResult`, `ConnectionInfo` are dataclasses with `to_dict()` for JSON serialization.
84
+
85
+ ### Driver registry (`src/sim/drivers/__init__.py`)
86
+
87
+ Drivers are resolved lazily through two channels:
88
+
89
+ - **`_BUILTIN_REGISTRY`** — an ordered list of `(name, "module:Class")` tuples for the open-source drivers that ship with `sim-cli-core` itself (PyBaMM, OpenFOAM, CalculiX, gmsh, SU2, LAMMPS, Elmer, scikit-fem, MFEM, OpenSeesPy, SfePy, OpenMDAO, FiPy, pymoo, Pyomo, SimPy, Trimesh, Devito, CoolProp, scikit-rf, pandapower, ParaView, meshio, PyVista, Newton, Isaac Sim, LTspice). The canonical list lives in `src/sim/drivers/__init__.py`.
90
+ - **`sim.drivers` entry-point group** — external/closed-source drivers register themselves via standard Python entry points and are discovered at import time, validated, and appended after the built-ins. Built-ins win on name collisions. This is the path used by every commercial-solver plugin (each lives in its own out-of-tree package with its own `compatibility.yaml`).
91
+
92
+ A driver may set `supports_session = True` to implement the persistent-session lifecycle (`launch`/`run`/`query`/`disconnect`); the rest are one-shot only. `get_driver(name)` looks up by `.name` attribute and lazily imports the implementation module on first use, so a broken plugin does not crash the CLI.
93
+
94
+ ### Execution pipeline — one-shot (`run`)
95
+ 1. `cli.run` → `runner.execute_script(script, solver, driver)` → subprocess, captures stdout/stderr/duration
96
+ 2. `driver.parse_output(stdout)` → extract structured fields
97
+ 3. `history.append({cwd, solver, session_id, run_id, ...})` → single jsonl line in `~/.sim/history.jsonl`
98
+ 4. `sim logs <id>` reads back via `history.get_by_id`; `sim logs --solver X --all` filters
99
+
100
+ ### Execution pipeline — persistent session (`exec`)
101
+ 1. `cli.connect` → HTTP `POST /connect` to server → `driver.launch(...)` → new `SessionState` added to `_sessions`; response carries the session_id which the client stores
102
+ 2. `cli.exec` → HTTP `POST /exec` with code + `X-Sim-Session: <id>` → server routes to that session, then `_execute_snippet()` runs `exec(code, namespace)` where `namespace` has `session`, `meshing`/`solver`, `_result`
103
+ 3. `cli.inspect <name>` → HTTP `GET /inspect/<name>` (session-scoped) → driver- or session-specific query
104
+ 4. `cli.disconnect` → HTTP `POST /disconnect` (session-scoped) → driver-specific teardown, remove from `_sessions`
105
+
106
+ Session routing rules: an explicit `X-Sim-Session` header wins (404 if unknown); otherwise the server falls back to the sole live session; otherwise `/exec` returns 400. Clients can also set `SIM_SESSION` env var or pass `sim --session <id> ...` to scope a whole CLI invocation.
107
+
108
+ ## Adding a new driver
109
+
110
+ 1. Create `src/sim/drivers/<name>/driver.py` implementing `DriverProtocol`
111
+ 2. (Optional) `runtime.py` for persistent-session support
112
+ 3. Register in `src/sim/drivers/__init__.py`: import and append to `DRIVERS`
113
+ 4. If the driver needs server-side launch logic, extend `server.py`'s `/connect` handler accordingly
114
+
115
+ See `pybamm/driver.py` for the smallest reference implementation. Persistent-session examples live in the out-of-tree plugin packages.
116
+
117
+ ## Test Layout
118
+
119
+ ```
120
+ tests/
121
+ __init__.py
122
+ conftest.py shared fixtures / execution paths
123
+ base/ core framework tests (no solver needed)
124
+ test_cli.py smoke tests for click commands
125
+ test_compat.py skills layering / profile resolution
126
+ test_config.py two-tier config resolution
127
+ test_connect.py driver.connect() availability checks
128
+ test_driver_discovery.py entry-point plugin discovery
129
+ test_history.py global run history persistence
130
+ test_lint.py lint protocol coverage
131
+ test_logs.py sim logs CLI
132
+ test_multi_session.py session routing + concurrency
133
+ test_run.py one-shot subprocess execution
134
+ drivers/ per-driver unit + integration tests for in-tree drivers
135
+ fixtures/ mock solver scripts (one set per in-tree driver, plus shared mocks)
136
+ execution/ optional end-to-end scripts for in-tree drivers
137
+ ```
138
+
139
+ Tests for out-of-tree plugin drivers live in their own plugin repos. Tests in this repo that require a real solver are gated by import-availability flags (e.g. `HAS_PYBAMM`) and skip gracefully when the package is missing.
140
+
141
+ ## Notes
142
+
143
+ - Global run history lives in `~/.sim/history.jsonl` (append-only; override dir via `SIM_HOME`); git-ignored
144
+ - The server supports multiple concurrent sessions keyed by `X-Sim-Session` header; a solver name can only be live once per server process (driver instances are module-level singletons)
145
+ - Project uses `uv` for dependency locking (`uv.lock`)
146
+ - Companion knowledge / skills / workflows live in the sibling `sim-skills/` tree, one folder per solver
147
+
148
+ ## Releases
149
+
150
+ - **PyPI distribution name:** `sim-cli-core` (renamed from `sim-runtime` in Phase 4 — see `src/sim/plugins.py` dual-lookup; `sim-runtime 0.2.1`–`0.2.3` remain on PyPI but are no longer released against). Both names were rejected for `sim-cli` itself, which is too similar to the existing `simcli` placeholder.
151
+ - **Console script + import name:** `sim`. The PyPI dist name and the import name intentionally differ; `src/sim/__init__.py` looks up `version("sim-cli-core")` first, falling back to `version("sim-runtime")` for editable installs predating the rename, and `try/except PackageNotFoundError` for source checkouts.
152
+ - **Trusted publisher:** GitHub OIDC, repo `svd-ai-lab/sim-cli`, workflow `.github/workflows/publish.yml`, environment `pypi`. Configured at https://pypi.org/manage/project/sim-cli-core/settings/publishing/.
153
+ - **Tag format:** `v<MAJOR.MINOR.PATCH>` matching `pyproject.toml` `version` exactly. Always tag from `main` after PR-merging a release branch.
154
+ - **Don't skip the clean-venv smoke test before tagging.** 0.2.1 shipped broken (`__init__.py` referenced `version("sim-cli")` after the rename) because no one ran `sim --version` in a fresh venv before pushing the tag. Twine check verifies packaging, not import.
155
+
156
+ ## Public-artifact privacy / license safety
157
+
158
+ When writing anything that lands in a *public* place — GitHub issues,
159
+ PR titles/bodies/comments, public commit messages, public docs — keep
160
+ **engineering-relevant** facts and drop **diary-style disclosure**
161
+ that ties a specific commercial-software install to a specific
162
+ machine or account. The two are easy to confuse.
163
+
164
+ **Keep:**
165
+ - The bug, the error message, the exit code, the reproducing input.
166
+ - Version info that is a genuine reproduction prereq — when a behavior
167
+ is gated to a specific release of an open-source dependency, the
168
+ version is part of the engineering claim and stays. Use neutral
169
+ framing for closed-source dependencies ("a CFD solver release that
170
+ changed the boundary-condition API") rather than naming the vendor
171
+ and release.
172
+ - Platform when behavior is platform-gated (Linux vs Windows
173
+ filesystem casing, COM availability, etc.).
174
+
175
+ **Drop / replace:**
176
+ - Personal usernames and hostnames → "a Windows test host", "a
177
+ development machine", or elide.
178
+ - Personal IPs (including Tailscale `100.90.x.x`) → elide.
179
+ - Personal filesystem paths (`C:\Users\<you>\...`,
180
+ `~/Documents/GitHub/...`, `C:\Python<NN>\...`,
181
+ `C:\Program Files\<Vendor>\<version>\...`) → "a local clone",
182
+ "the editable install", or elide.
183
+ - Specific commercial-software *versions tied to a personal machine*
184
+ — vendor compliance teams treat these as license-audit signals
185
+ even when the version alone would be fine. Replace with neutral
186
+ phrasing.
187
+ - Tailscale tailnet names, OS account SIDs, MAC/serial numbers.
188
+
189
+ Sanitize existing artifacts by editing PR/issue/comment bodies
190
+ (`gh pr edit`, `gh issue comment --edit-last`). Avoid force-pushing
191
+ to rewrite commit-message history unless the disclosure is severe
192
+ *and* the branch is unmerged *and* not being collaborated on.
@@ -0,0 +1,25 @@
1
+ # Contributing to sim-cli
2
+
3
+ Thanks for your interest in `sim-cli`. Contributions of all sizes are welcome —
4
+ bug reports, fixes, new drivers, docs, examples.
5
+
6
+ ## Getting started
7
+
8
+ See [`docs/DEVELOPMENT.md`](docs/DEVELOPMENT.md) for local setup, running tests,
9
+ and adding a new solver driver.
10
+
11
+ ## Submitting changes
12
+
13
+ 1. Fork the repo and create a topic branch off `main`.
14
+ 2. Make your change. Run `pytest -q` and `ruff check src/sim tests`.
15
+ 3. Open a pull request against `main` with a short description of the change
16
+ and any context a reviewer would want.
17
+
18
+ ## Licensing of contributions
19
+
20
+ `sim-cli` is released under the [Apache License, Version 2.0](LICENSE).
21
+ By submitting a pull request, you agree that your contribution is licensed
22
+ under the same Apache-2.0 terms (inbound = outbound), and you represent that
23
+ you have the right to do so.
24
+
25
+ No separate Contributor License Agreement (CLA) is required at this time.
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright © 2026 Weiqi Ji
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,72 @@
1
+ sim-cli
2
+ Copyright 2026 Weiqi Ji
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (the "License");
5
+ see the accompanying LICENSE file for the full text.
6
+
7
+ ================================================================================
8
+ Third-party solver SDKs (runtime, optional — not bundled)
9
+ ================================================================================
10
+
11
+ sim-cli integrates with commercial and open-source solvers by dynamically
12
+ importing their Python SDKs at runtime. No vendor SDK, solver binary, or vendor
13
+ example/tutorial material is redistributed as part of this repository. Users
14
+ install each SDK separately (via `sim env install`, optional extras in
15
+ pyproject.toml, or their own package manager) and are responsible for
16
+ complying with the license, copyright, and end-user agreement that ships
17
+ with each SDK and each underlying solver.
18
+
19
+ The drivers in `src/sim/drivers/` reference, but do not bundle, the following
20
+ third-party Python SDKs. This list is informational and may lag the code —
21
+ see `src/sim/drivers/<name>/compatibility.yaml` and `pyproject.toml` for the
22
+ current version pins.
23
+
24
+ Ansys / PyAnsys family (© ANSYS, Inc.)
25
+ - ansys-fluent-core https://github.com/ansys/pyfluent
26
+ - ansys-workbench-core https://github.com/ansys/pyworkbench
27
+ - ansys-mechanical-core https://github.com/ansys/pymechanical
28
+ - ansys-mapdl-core https://github.com/ansys/pymapdl
29
+ - ansys-dyna-core https://github.com/ansys/pydyna
30
+ - ansys-dpf-core https://github.com/ansys/pydpf-core
31
+
32
+ COMSOL (© COMSOL AB)
33
+ - mph https://github.com/MPh-py/MPh
34
+ (third-party Python wrapper around COMSOL's Java API; requires a COMSOL
35
+ Multiphysics license)
36
+
37
+ MathWorks (© The MathWorks, Inc.)
38
+ - matlabengine https://pypi.org/project/matlabengine/
39
+ (distributed by MathWorks; requires a MATLAB license)
40
+
41
+ Dassault Systèmes / Abaqus, Siemens STAR-CCM+ / Flotherm, BETA CAE ANSA,
42
+ Altair HyperMesh, Ansys ICEM CFD, Ansys CFX
43
+ - Driven via vendor CLIs / journal files / Python-in-solver interpreters.
44
+ No additional Python SDK is redistributed by sim-cli.
45
+
46
+ Open-source solvers and libraries
47
+ - PyBaMM, OpenFOAM, SU2, LAMMPS, CalculiX, Elmer FEM, Gmsh, meshio,
48
+ pyvista, PyMFEM, scikit-fem, SfePy, OpenSeesPy, Cantera, OpenMDAO,
49
+ FiPy, pymoo, Pyomo, SimPy, Trimesh, Devito, CoolProp, scikit-rf,
50
+ pandapower, ParaView (pvpython/pvbatch).
51
+ Each retains its own upstream license; consult the corresponding project
52
+ for terms.
53
+
54
+ ================================================================================
55
+ Direct runtime dependencies (see pyproject.toml)
56
+ ================================================================================
57
+
58
+ click, httpx, fastapi, uvicorn, pyyaml, Pillow, lxml
59
+ — each distributed under its own open-source license (BSD / MIT / Apache-2.0
60
+ family); consult the respective package for terms.
61
+
62
+ ================================================================================
63
+ Trademarks
64
+ ================================================================================
65
+
66
+ Product, solver, and company names referenced in this repository (including
67
+ Ansys®, Fluent®, Workbench®, Mechanical®, MAPDL, CFX®, LS-DYNA®, ICEM CFD™,
68
+ Abaqus®, SIMULIA®, COMSOL Multiphysics®, MATLAB®, Simcenter™ STAR-CCM+,
69
+ Simcenter Flotherm™, ANSA®, HyperMesh®, Altair®, ParaView®, OpenFOAM®) are
70
+ trademarks or registered trademarks of their respective owners and are used
71
+ solely for identification. sim-cli is an independent open-source project and
72
+ is not affiliated with, endorsed by, or sponsored by any of these vendors.