sim-cli-core 0.3.7__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.
@@ -1,13 +1,15 @@
1
1
  ---
2
2
  name: sim-cli
3
- description: Cross-solver operating discipline for sim-cli sessions — input classification, acceptance semantics, and escalation rules that apply to every solver. Use alongside the solver's own plugin skill, which is self-contained for solver-specific work; this skill carries only the shared rules.
3
+ description: Cross-solver operating discipline for sim-cli workflows — tool choice, input classification, acceptance semantics, and escalation rules that apply across solvers. Use alongside the solver's own plugin skill, which is self-contained for solver-specific work; this skill carries only the shared rules.
4
4
  ---
5
5
 
6
6
  # sim-cli
7
7
 
8
- You are driving a solver through the **sim-cli** runtime. This skill carries
9
- the **cross-solver discipline** — the rules that hold for every sim-cli
10
- session, regardless of which solver you drive.
8
+ You are working in a **sim-cli**-enabled solver workflow. Use the `sim`
9
+ runtime where it adds control and observability, and compose solver-native
10
+ tools directly where they are the right primitive. This skill carries the
11
+ **cross-solver discipline** — the rules that hold across sim-cli workflows,
12
+ regardless of which solver you drive.
11
13
 
12
14
  The solver's **plugin skill** is self-contained for solver-specific work:
13
15
  solver hard constraints, dependency chains, snippets, workflows, SDK/solver
@@ -19,39 +21,62 @@ solver, it belongs here, not in a plugin skill.
19
21
 
20
22
  ## Execution models
21
23
 
22
- The plugin skill tells you which model the solver uses:
24
+ The plugin skill tells you which model the solver uses. Choose the narrowest
25
+ correct execution primitive; sim-cli is composable, not a universal wrapper.
23
26
 
24
27
  | Model | Used by | Lifecycle |
25
28
  |---|---|---|
26
- | **Persistent session** | Drivers that hold a live process open | `connect → exec × N → inspect → disconnect` |
27
- | **One-shot batch** | Drivers that run one script/deck and exit | `run → parse_output → evaluate` |
28
-
29
- **The loop, either model:** classify inputs and get the missing Category A
30
- values from the user (including the acceptance criterion) → start the session
31
- (`sim connect`, or nothing for one-shot) → Step-0 version probe
32
- (`sim inspect session.versions`) → execute one bounded step at a time,
33
- inspecting `last.result` between steps → evaluate against the acceptance
34
- criterion → `sim disconnect`. On any failure, stop and report — do not
35
- silently retry.
29
+ | **Persistent session** | Drivers that hold a live process open | `sim connect → sim exec × N → sim inspect → sim disconnect` |
30
+ | **sim-wrapped one-shot batch** | Plugin wrappers that add linting, profile-aware invocation, parsing, history, or safer execution | `sim check → sim run → parse_output/logs → evaluate` |
31
+ | **Native/tool one-shot batch** | Ready solver decks/scripts, vendor batch commands, project pipelines, or post-processing tools where native execution is the right primitive | version/profile probe → native command/script → parse artifacts/logs → evaluate |
32
+
33
+ sim-cli does **not** try to wrap every solver operation, executable flag,
34
+ vendor batch mode, or post-processing script. Use `sim` when it adds a stable
35
+ control plane: solver discovery and profile checks, live sessions, bounded
36
+ `exec` / `inspect` loops, history/log capture, parsing, screenshots, or shared
37
+ agent discipline. If the artifact is already a solver-native deck/script and
38
+ the solver's own batch command is the right execution primitive, call that
39
+ native command directly instead of forcing it through `sim run`. Preserve
40
+ stdout/stderr, generated files, and acceptance evidence just as carefully.
41
+
42
+ Use `sim run` when the plugin skill says it is the canonical one-shot path or
43
+ when the wrapper adds real value. Otherwise, keep the sim-cli discipline while
44
+ composing the solver's native tools directly.
45
+
46
+ **The loop, any model:** classify inputs and get the missing Category A values
47
+ from the user (including the acceptance criterion) → choose the execution
48
+ primitive → run a Step-0 version/profile probe (`sim inspect session.versions`
49
+ for persistent sessions; `sim check <solver>`, plugin guidance, or native
50
+ `--version` / license probe for one-shot work) → execute one bounded step at a
51
+ time → inspect `last.result` or parse the native logs/artifacts between steps →
52
+ evaluate against the acceptance criterion → `sim disconnect` if a persistent
53
+ session was opened. On any failure, stop and report — do not silently retry.
36
54
 
37
55
  ---
38
56
 
39
- ## Hard constraints (every sim-cli session)
57
+ ## Hard constraints (shared sim-cli discipline)
40
58
 
41
59
  1. **Never invent Category A defaults.** Physical decisions — geometry,
42
60
  materials, boundary conditions, the acceptance criterion — must come from
43
61
  the user. "Just use defaults" / "just run it" does not override this;
44
62
  treat it as a missing input and ask.
45
- 2. **Step-0 version probe is mandatory.** After `sim connect` (persistent) or
46
- before `sim run` (one-shot), call `sim inspect session.versions` and use
47
- the returned `profile` / `active_sdk_layer` / `active_solver_layer` to pick
48
- the right files in the plugin skill. If `profile` is empty, unknown, or
49
- deprecated — **stop**.
50
- 3. **Acceptance ≠ exit code.** A `sim run` / `sim exec` can return `ok=true`
51
- and still be physically wrong. Always validate against an outcome-based,
52
- bounded, measurable criterion — not "the solver ran".
63
+ 2. **Step-0 version/profile probe is mandatory.** After `sim connect`, call
64
+ `sim inspect session.versions` and use the returned `profile` /
65
+ `active_sdk_layer` / `active_solver_layer` to pick the right files in the
66
+ plugin skill. Treat `solver_version` as active-runtime evidence only when
67
+ `version_source` is `active_runtime`; a detected installation is not proof
68
+ that the same version was launched. If the runtime version is unreported or
69
+ has no compatible profile, stop before applying version-specific guidance.
70
+ Before `sim run` or native one-shot execution, run the
71
+ relevant probe for that path (`sim check <solver>`, plugin guidance, or the
72
+ solver's native `--version` / license check). If a required profile is empty,
73
+ unknown, or deprecated — **stop**.
74
+ 3. **Acceptance ≠ exit code.** A `sim run` / `sim exec` / native solver command
75
+ can return success and still be physically wrong. Always validate against an
76
+ outcome-based, bounded, measurable criterion — not "the solver ran".
53
77
  4. **Never silently retry a failed step.** Report `stderr`, `stdout`, and
54
- `run_count` / completion state; let the user decide the next move.
78
+ `run_count` / completion state / relevant artifact state; let the user
79
+ decide the next move.
55
80
  5. **Reference example values are not defaults.** Values in any `examples/`
56
81
  directory describe a specific published test case. Offer them explicitly
57
82
  if useful, but wait for the user's confirmation before adopting them.
@@ -67,10 +92,23 @@ default, which can I derive from the files in front of me?
67
92
  |---|---|---|
68
93
  | **A — physical decisions** | **Must ask if absent.** Non-negotiable. | Geometry, materials, boundary/initial conditions, physics-model choices, the acceptance criterion |
69
94
  | **B — operational** | **May default — must disclose.** Affects runtime/convenience, not what the simulation represents. | `--processors`, `--ui-mode`, `--workspace`, smoke-test iteration counts, log verbosity |
70
- | **C — file-derivable** | **Infer from the actual files** via a diagnostic `sim exec` — not from a similar example. Confirm if a downstream decision depends on it. | Mesh cell count, boundary names/types, fields present in a result file, material IDs |
95
+ | **C — file-derivable** | **Infer from the actual files** via a diagnostic `sim exec`, solver-native inspection command, or artifact parser — not from a similar example. Confirm if a downstream decision depends on it. | Mesh cell count, boundary names/types, fields present in a result file, material IDs |
71
96
 
72
97
  Do not start until every Category A field has an explicit value from the user.
73
98
 
99
+ ## First causal failure gate
100
+
101
+ When a workflow fails, locate the first failed stage before changing the model:
102
+ environment/license -> launch or attach -> file import -> model setup -> mesh or
103
+ build -> solve -> postprocess/export. Preserve the first new error, the exact
104
+ entrypoint, active version/profile, and relevant artifact identity; later errors
105
+ may only be consequences.
106
+
107
+ Run the smallest stage-specific probe that can confirm or reject one cause.
108
+ Do not change physics, boundary conditions, mesh controls, or solver settings to
109
+ work around an unproven environment, import, or setup failure. Retry only after
110
+ naming the hypothesis and the evidence expected to change.
111
+
74
112
  ---
75
113
 
76
114
  ## Where `sim serve` runs (Windows session-context foot-gun)
@@ -92,3 +130,17 @@ ask the operator to restart `sim serve` from a desktop session. The agent
92
130
  never starts `sim serve` itself.
93
131
 
94
132
  See [`gui/SKILL.md`](gui/SKILL.md) for the full GUI actuation API.
133
+
134
+ ---
135
+
136
+ ## Long-running and multi-stage workflows
137
+
138
+ Do not wait for or request a dedicated per-task primitive (a resumable-sweep
139
+ API, an auto-coupling feature, etc.) when the generic primitives already
140
+ suffice. Bounded `exec`/`run` calls, `session.health` / solve-progress
141
+ inspection, and the solver's own retained project/session state are enough to
142
+ drive a long sweep, a multi-stage build, or a staged multi-physics coupling
143
+ yourself, one bounded step at a time. Reach for a new dedicated primitive only
144
+ when a real session hits a generic gap (no timeout guard, no liveness check,
145
+ no process cleanup) — not to shortcut a specific workflow that a generic loop
146
+ already covers.
sim/assets.py ADDED
@@ -0,0 +1,309 @@
1
+ """Read-only scanning of historical simulation assets with simparse."""
2
+ from __future__ import annotations
3
+
4
+ import importlib
5
+ import importlib.metadata
6
+ import os
7
+ from collections import Counter
8
+ from pathlib import Path
9
+ from typing import Any, Iterable
10
+
11
+
12
+ SCAN_SCHEMA_VERSION = "sim.scan/v1"
13
+
14
+
15
+ def _display_path(path: Path, include_paths: bool) -> str:
16
+ if include_paths:
17
+ return str(path.resolve())
18
+ return path.name or "."
19
+
20
+
21
+ def _path_key(path: Path) -> str:
22
+ """Return a stable key used to avoid parsing overlapping roots twice."""
23
+ return os.path.normcase(str(path.resolve()))
24
+
25
+
26
+ def _clean_error(exc: Exception, path: Path, include_paths: bool) -> str:
27
+ """Keep parser diagnostics useful without leaking paths by default."""
28
+ message = str(exc).strip() or type(exc).__name__
29
+ if include_paths:
30
+ return message
31
+
32
+ display = _display_path(path, False)
33
+ candidates = {
34
+ str(path),
35
+ str(path.resolve()),
36
+ str(path).replace("\\", "/"),
37
+ str(path.resolve()).replace("\\", "/"),
38
+ }
39
+ for candidate in sorted(candidates, key=len, reverse=True):
40
+ if candidate:
41
+ message = message.replace(candidate, display)
42
+ return message
43
+
44
+
45
+ def _diagnostic(
46
+ path: Path,
47
+ error_code: str,
48
+ message: str,
49
+ include_paths: bool,
50
+ ) -> dict[str, str]:
51
+ return {
52
+ "path": _display_path(path, include_paths),
53
+ "error_code": error_code,
54
+ "message": message[:280],
55
+ }
56
+
57
+
58
+ def _iter_directory(path: Path, recursive: bool) -> tuple[list[Path], list[OSError]]:
59
+ files: list[Path] = []
60
+ errors: list[OSError] = []
61
+
62
+ if not recursive:
63
+ try:
64
+ files.extend(entry for entry in path.iterdir() if entry.is_file())
65
+ except OSError as exc:
66
+ errors.append(exc)
67
+ return sorted(files, key=lambda value: str(value).casefold()), errors
68
+
69
+ def onerror(exc: OSError) -> None:
70
+ errors.append(exc)
71
+
72
+ for current, directory_names, file_names in os.walk(
73
+ path,
74
+ topdown=True,
75
+ onerror=onerror,
76
+ followlinks=False,
77
+ ):
78
+ directory_names.sort(key=str.casefold)
79
+ file_names.sort(key=str.casefold)
80
+ files.extend(Path(current, name) for name in file_names)
81
+ return files, errors
82
+
83
+
84
+ def _load_simparse() -> tuple[Any, str]:
85
+ module = importlib.import_module("simparse")
86
+ try:
87
+ version = importlib.metadata.version("simparse")
88
+ except importlib.metadata.PackageNotFoundError:
89
+ version = "unknown"
90
+ return module, version
91
+
92
+
93
+ def _error_envelope(
94
+ error_code: str,
95
+ message: str,
96
+ details: dict[str, Any] | None = None,
97
+ ) -> dict[str, Any]:
98
+ payload: dict[str, Any] = {
99
+ "ok": False,
100
+ "error_code": error_code,
101
+ "message": message[:280],
102
+ }
103
+ if details:
104
+ payload["details"] = details
105
+ return payload
106
+
107
+
108
+ def scan_assets(
109
+ paths: Iterable[Path],
110
+ *,
111
+ recursive: bool = True,
112
+ include_paths: bool = False,
113
+ full: bool = False,
114
+ limit: int = 100,
115
+ format_name: str = "auto",
116
+ ) -> tuple[dict[str, Any], int]:
117
+ """Scan files/directories and return ``(JSON payload, process exit code)``."""
118
+ roots = tuple(Path(path) for path in paths)
119
+ request = {
120
+ "paths": [_display_path(path, include_paths) for path in roots],
121
+ "recursive": recursive,
122
+ "view": "full" if full else "summary",
123
+ "include_paths": include_paths,
124
+ "limit": limit,
125
+ "format": format_name,
126
+ }
127
+
128
+ try:
129
+ simparse, engine_version = _load_simparse()
130
+ except Exception as exc: # noqa: BLE001 - native extension load failures vary by platform
131
+ return _error_envelope(
132
+ "SIMPARSE_UNAVAILABLE",
133
+ "simparse could not be loaded; reinstall sim-cli-core for this platform.",
134
+ {"dependency": "simparse>=0.3.2,<0.4", "reason": str(exc)[:280]},
135
+ ), 3
136
+
137
+ assets: list[dict[str, Any]] = []
138
+ diagnostics: list[dict[str, str]] = []
139
+ seen: set[str] = set()
140
+
141
+ def inspect_one(path: Path, *, explicit: bool, selected_format: str = "auto") -> None:
142
+ key = _path_key(path)
143
+ if key in seen:
144
+ return
145
+ seen.add(key)
146
+ try:
147
+ source_path = path.resolve() if include_paths else path
148
+ asset = simparse.inspect(
149
+ str(source_path),
150
+ format=selected_format,
151
+ include_paths=include_paths,
152
+ summary=not full,
153
+ )
154
+ except Exception as exc: # noqa: BLE001 - simparse exposes parse errors as RuntimeError
155
+ reason = _clean_error(exc, path, include_paths)
156
+ unsupported = reason.casefold().startswith((
157
+ "unsupported file format",
158
+ "unsupported format",
159
+ "unknown format",
160
+ ))
161
+ if unsupported and not explicit:
162
+ return
163
+ code = "ASSET_FORMAT_UNSUPPORTED" if unsupported else "ASSET_SCAN_FAILED"
164
+ prefix = "Unsupported simulation asset" if unsupported else "Could not parse simulation asset"
165
+ diagnostics.append(_diagnostic(
166
+ path,
167
+ code,
168
+ f"{prefix}: {_display_path(path, include_paths)}. {reason}",
169
+ include_paths,
170
+ ))
171
+ return
172
+ if isinstance(asset, dict):
173
+ assets.append(asset)
174
+ else:
175
+ diagnostics.append(_diagnostic(
176
+ path,
177
+ "ASSET_SCAN_FAILED",
178
+ f"simparse returned an invalid result for {_display_path(path, include_paths)}.",
179
+ include_paths,
180
+ ))
181
+
182
+ for root in roots:
183
+ if not root.exists():
184
+ diagnostics.append(_diagnostic(
185
+ root,
186
+ "ASSET_PATH_NOT_FOUND",
187
+ f"Asset path does not exist: {_display_path(root, include_paths)}.",
188
+ include_paths,
189
+ ))
190
+ continue
191
+ if root.is_file():
192
+ inspect_one(root, explicit=True, selected_format=format_name)
193
+ continue
194
+ if not root.is_dir():
195
+ diagnostics.append(_diagnostic(
196
+ root,
197
+ "ASSET_SCAN_FAILED",
198
+ f"Asset path is not a regular file or directory: {_display_path(root, include_paths)}.",
199
+ include_paths,
200
+ ))
201
+ continue
202
+ if format_name != "auto":
203
+ diagnostics.append(_diagnostic(
204
+ root,
205
+ "ASSET_FORMAT_UNSUPPORTED",
206
+ "--format can only be used with explicit files, not directories.",
207
+ include_paths,
208
+ ))
209
+ continue
210
+
211
+ files, walk_errors = _iter_directory(root, recursive)
212
+ for exc in walk_errors:
213
+ diagnostics.append(_diagnostic(
214
+ root,
215
+ "ASSET_SCAN_FAILED",
216
+ f"Could not read asset directory: {_clean_error(exc, root, include_paths)}",
217
+ include_paths,
218
+ ))
219
+ for path in files:
220
+ inspect_one(path, explicit=False)
221
+
222
+ assets.sort(key=lambda item: (
223
+ str(item.get("path", "")).casefold(),
224
+ str(item.get("file_name", "")).casefold(),
225
+ str(item.get("format", "")).casefold(),
226
+ ))
227
+ diagnostics.sort(key=lambda item: (item["path"].casefold(), item["error_code"]))
228
+
229
+ parsed_ok = sum(bool(asset.get("ok")) for asset in assets)
230
+ parsed_failed = len(assets) - parsed_ok
231
+ formats = dict(sorted(Counter(
232
+ str(asset.get("format", "unknown")) for asset in assets
233
+ ).items()))
234
+ asset_omitted = 0 if limit == 0 else max(0, len(assets) - limit)
235
+ diagnostic_omitted = 0 if limit == 0 else max(0, len(diagnostics) - limit)
236
+ returned_assets = assets if limit == 0 else assets[:limit]
237
+ returned_diagnostics = diagnostics if limit == 0 else diagnostics[:limit]
238
+ status = "partial" if diagnostics or parsed_failed else "ok"
239
+
240
+ payload: dict[str, Any] = {
241
+ "schema_version": SCAN_SCHEMA_VERSION,
242
+ "ok": True,
243
+ "status": status,
244
+ "engine": {"name": "simparse", "version": engine_version},
245
+ "request": request,
246
+ "summary": {
247
+ "roots": len(roots),
248
+ "assets": len(assets),
249
+ "ok": parsed_ok,
250
+ "failed": parsed_failed + len(diagnostics),
251
+ "formats": formats,
252
+ "returned": len(returned_assets),
253
+ "omitted": asset_omitted,
254
+ "diagnostics": len(diagnostics),
255
+ "diagnostics_omitted": diagnostic_omitted,
256
+ },
257
+ "assets": returned_assets,
258
+ "diagnostics": returned_diagnostics,
259
+ "truncated": bool(asset_omitted or diagnostic_omitted),
260
+ }
261
+
262
+ if not assets and diagnostics:
263
+ codes = {diagnostic["error_code"] for diagnostic in diagnostics}
264
+ user_error_codes = {"ASSET_FORMAT_UNSUPPORTED", "ASSET_PATH_NOT_FOUND"}
265
+ error_code = next(iter(codes)) if len(codes) == 1 else "ASSET_SCAN_FAILED"
266
+ message = {
267
+ "ASSET_FORMAT_UNSUPPORTED": "No supported simulation asset could be parsed.",
268
+ "ASSET_PATH_NOT_FOUND": "The requested simulation asset path does not exist.",
269
+ }.get(
270
+ error_code,
271
+ "The simulation asset scan failed before any asset could be parsed.",
272
+ )
273
+ return _error_envelope(
274
+ error_code,
275
+ message,
276
+ {key: value for key, value in payload.items() if key != "ok"},
277
+ ), 2 if codes <= user_error_codes else 1
278
+
279
+ return payload, 0
280
+
281
+
282
+ def render_scan(payload: dict[str, Any]) -> str:
283
+ """Render one concise human-readable scan report."""
284
+ if not payload.get("ok"):
285
+ lines = [f"[sim] scan: {payload.get('message', 'failed')}"]
286
+ details = payload.get("details", {})
287
+ for diagnostic in details.get("diagnostics", []):
288
+ lines.append(f" ! {diagnostic['path']}: {diagnostic['message']}")
289
+ return "\n".join(lines)
290
+
291
+ summary = payload["summary"]
292
+ lines = [
293
+ f"[sim] scan: {summary['assets']} asset(s), "
294
+ f"{summary['failed']} failure(s), status={payload['status']}"
295
+ ]
296
+ for asset in payload["assets"]:
297
+ state = "ok" if asset.get("ok") else "failed"
298
+ lines.append(
299
+ f" {asset.get('format', 'unknown'):<20} "
300
+ f"{asset.get('file_name', '?')} [{state}]"
301
+ )
302
+ for diagnostic in payload["diagnostics"]:
303
+ lines.append(f" ! {diagnostic['path']}: {diagnostic['message']}")
304
+ if payload.get("truncated"):
305
+ lines.append(
306
+ f" ... {summary['omitted']} asset(s) and "
307
+ f"{summary['diagnostics_omitted']} diagnostic(s) omitted"
308
+ )
309
+ return "\n".join(lines)
sim/cli.py CHANGED
@@ -627,6 +627,45 @@ def exec_cmd(ctx, code, code_file, label):
627
627
  sys.exit(2)
628
628
 
629
629
 
630
+ # ── scan (historical simulation assets) ──────────────────────────────────────
631
+
632
+ @main.command()
633
+ @click.argument("paths", nargs=-1, required=True, type=click.Path(path_type=Path))
634
+ @click.option("--recursive/--no-recursive", default=True, show_default=True,
635
+ help="Descend into subdirectories.")
636
+ @click.option("--include-paths", is_flag=True, default=False,
637
+ help="Include absolute source paths. Paths are redacted by default.")
638
+ @click.option("--full", is_flag=True, default=False,
639
+ help="Return full parser output instead of bounded summaries.")
640
+ @click.option("--limit", type=click.IntRange(min=0), default=100, show_default=True,
641
+ help="Maximum assets and diagnostics returned; 0 means unlimited.")
642
+ @click.option("--format", "format_name", default="auto", show_default=True,
643
+ help="Force a format for explicit files; directory scans always auto-detect.")
644
+ @click.pass_context
645
+ def scan(ctx, paths, recursive, include_paths, full, limit, format_name):
646
+ """Parse historical simulation files and directories without launching a solver.
647
+
648
+ The default summary view is bounded and redacts absolute paths. Use --full
649
+ only when an agent needs the complete parser result for a small input set.
650
+ """
651
+ from sim.assets import render_scan, scan_assets
652
+
653
+ payload, exit_code = scan_assets(
654
+ paths,
655
+ recursive=recursive,
656
+ include_paths=include_paths,
657
+ full=full,
658
+ limit=limit,
659
+ format_name=format_name,
660
+ )
661
+ if ctx.obj["json"]:
662
+ click.echo(json_mod.dumps(payload, indent=2, default=str))
663
+ else:
664
+ click.echo(render_scan(payload), err=not payload.get("ok", False))
665
+ if exit_code:
666
+ sys.exit(exit_code)
667
+
668
+
630
669
  # ── inspect (live session state) ─────────────────────────────────────────────
631
670
 
632
671
  @main.command()
sim/describe.py CHANGED
@@ -38,6 +38,12 @@ _EXAMPLES: dict[str, list[dict[str, str]]] = {
38
38
  {"cmd": "sim check --all", "summary": "Detect every installed solver."},
39
39
  {"cmd": "sim check coolprop --json", "summary": "Detect one driver, JSON output."},
40
40
  ],
41
+ "scan": [
42
+ {"cmd": "sim --json scan ./historical-cases",
43
+ "summary": "Parse a directory into bounded, machine-readable asset summaries."},
44
+ {"cmd": "sim --json scan model.mph --full --include-paths",
45
+ "summary": "Return the full parser result for one explicit asset."},
46
+ ],
41
47
  "lint": [
42
48
  {"cmd": "sim lint script.py --solver gmsh",
43
49
  "summary": "Validate a script before running it."},
@@ -158,6 +164,14 @@ ERROR_CODES: dict[str, str] = {
158
164
  "A driver returned a value that doesn't match DriverProtocol.",
159
165
  "NONINTERACTIVE_INPUT_REQUIRED":
160
166
  "--no-interactive is set and the command would otherwise prompt.",
167
+ "ASSET_SCAN_FAILED":
168
+ "A simulation asset or directory could not be read or parsed.",
169
+ "ASSET_FORMAT_UNSUPPORTED":
170
+ "An explicitly requested file is not a supported simulation asset format.",
171
+ "ASSET_PATH_NOT_FOUND":
172
+ "A requested simulation asset path does not exist.",
173
+ "SIMPARSE_UNAVAILABLE":
174
+ "The required native simparse dependency could not be loaded on this platform.",
161
175
  }
162
176
 
163
177
 
@@ -238,6 +252,45 @@ SCHEMAS: dict[str, dict[str, Any]] = {
238
252
  "solver_name": {"type": "string"},
239
253
  },
240
254
  },
255
+ "ScanResult": {
256
+ "type": "object",
257
+ "description": "Bounded result of a read-only historical simulation asset scan.",
258
+ "properties": {
259
+ "schema_version": {"const": "sim.scan/v1"},
260
+ "ok": {"const": True},
261
+ "status": {"enum": ["ok", "partial"]},
262
+ "engine": {
263
+ "type": "object",
264
+ "properties": {
265
+ "name": {"const": "simparse"},
266
+ "version": {"type": "string"},
267
+ },
268
+ },
269
+ "request": {"type": "object"},
270
+ "summary": {
271
+ "type": "object",
272
+ "properties": {
273
+ "roots": {"type": "integer"},
274
+ "assets": {"type": "integer"},
275
+ "ok": {"type": "integer"},
276
+ "failed": {"type": "integer"},
277
+ "formats": {"type": "object"},
278
+ "returned": {"type": "integer"},
279
+ "omitted": {"type": "integer"},
280
+ "diagnostics": {"type": "integer"},
281
+ "diagnostics_omitted": {"type": "integer"},
282
+ },
283
+ },
284
+ "assets": {"type": "array", "items": {"type": "object"}},
285
+ "diagnostics": {"type": "array", "items": {"type": "object"}},
286
+ "truncated": {"type": "boolean"},
287
+ },
288
+ },
289
+ }
290
+
291
+
292
+ _OUTPUT_SCHEMAS: dict[str, str] = {
293
+ "scan": "ScanResult",
241
294
  }
242
295
 
243
296
 
@@ -284,6 +337,8 @@ def _describe_command(name: str, cmd: click.Command) -> dict[str, Any]:
284
337
  "params": [_describe_param(p) for p in cmd.params],
285
338
  "examples": _EXAMPLES.get(canonical, []),
286
339
  }
340
+ if canonical in _OUTPUT_SCHEMAS:
341
+ entry["output_schema"] = _OUTPUT_SCHEMAS[canonical]
287
342
  return entry
288
343
 
289
344