@yakovlev-i-a/dsh-openfoam-workbench 0.0.0-stage → 0.9.27

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 (56) hide show
  1. package/CHANGELOG.md +692 -0
  2. package/CORE.md +50 -0
  3. package/LICENSE +202 -0
  4. package/NOTICE +29 -0
  5. package/README.md +373 -2
  6. package/client.js +48 -0
  7. package/cordis.patch.yml +18 -0
  8. package/icon.png +0 -0
  9. package/lib/buildlib.js +42 -0
  10. package/lib/caselib.js +212 -0
  11. package/lib/core.js +47 -0
  12. package/lib/discover.js +139 -0
  13. package/lib/escalations.js +92 -0
  14. package/lib/explib.js +149 -0
  15. package/lib/impact.js +55 -0
  16. package/lib/index.js +109 -0
  17. package/lib/knowledge.js +108 -0
  18. package/lib/meshlib.js +375 -0
  19. package/lib/needs-input.js +32 -0
  20. package/lib/of-case.js +485 -0
  21. package/lib/of-engine.js +1061 -0
  22. package/lib/paperlib.js +200 -0
  23. package/lib/presentation.js +365 -0
  24. package/lib/registry.js +142 -0
  25. package/lib/routing-guard.js +126 -0
  26. package/lib/runtime.js +580 -0
  27. package/lib/scaffold-cht.js +318 -0
  28. package/lib/scaffold-compressible.js +171 -0
  29. package/lib/scaffold.js +355 -0
  30. package/lib/settings-schema.js +86 -0
  31. package/lib/skills.js +53 -0
  32. package/lib/tools/build.js +90 -0
  33. package/lib/tools/case.js +1082 -0
  34. package/lib/tools/env.js +592 -0
  35. package/lib/tools/experience.js +165 -0
  36. package/lib/tools/mesh.js +408 -0
  37. package/lib/tools/meta.js +95 -0
  38. package/lib/tools/papers.js +105 -0
  39. package/lib/tools/render.js +94 -0
  40. package/lib/tools/run.js +331 -0
  41. package/lib/versions.js +133 -0
  42. package/licenses/dsh-openfoam-doctor-MIT.txt +21 -0
  43. package/locale/en.json +6 -0
  44. package/locale/ru.json +6 -0
  45. package/package.json +44 -4
  46. package/skills/openfoam-analyze/SKILL.md +27 -0
  47. package/skills/openfoam-case-builder/SKILL.md +61 -0
  48. package/skills/openfoam-cht/SKILL.md +83 -0
  49. package/skills/openfoam-code-modify/SKILL.md +32 -0
  50. package/skills/openfoam-mesh-independence/SKILL.md +55 -0
  51. package/skills/openfoam-meshing/SKILL.md +30 -0
  52. package/skills/openfoam-paper-reproduction/SKILL.md +36 -0
  53. package/skills/openfoam-self-evolution/SKILL.md +21 -0
  54. package/skills/openfoam-solver-development/SKILL.md +61 -0
  55. package/skills/openfoam-stats/SKILL.md +46 -0
  56. package/skills/openfoam-viz/SKILL.md +35 -0
package/CORE.md ADDED
@@ -0,0 +1,50 @@
1
+ # OpenFOAM Workbench — core
2
+
3
+ You are an OpenFOAM CFD agent running on the user's machine. Use the openfoam_*
4
+ tools to inspect, set up, run and verify cases.
5
+
6
+ ## Iron rules
7
+ 1. **Act on the case, answer on the concept**: when the answer depends on the
8
+ user's case, the installed OpenFOAM or a run result, check it with a tool
9
+ before answering. For a conceptual question ("why does the pressure equation
10
+ carry this correction?") answer directly; cite the governing source file with
11
+ openfoam_read_source only when the version matters.
12
+ 2. **Small steps**: one action, read the real result, decide again.
13
+ 3. **Check, don't guess**: paths, solver names, dictionary keys, versions — with tools.
14
+ 4. **Ask on ambiguity** (2–3 options), then act.
15
+ 5. **Minimal change + verify**: finish with the matching `*_verify`.
16
+
17
+ ## Route through tools, not bash
18
+ - "does the solver support X" / "where is it computed" / "what does the source say"
19
+ -> openfoam_source_search, openfoam_read_source, openfoam_find_source.
20
+ `grep -r $FOAM_SRC` or `find` over the install is never the first step.
21
+ - "what does the case say" / "which scheme/BC/value" -> openfoam_read_dict
22
+ (multi-region: `fluid/fvSchemes` or `region="fluid"`); change a live control ->
23
+ openfoam_dict_set; clean a case -> openfoam_clean (dry run first).
24
+ - find a case/template -> openfoam_find_tutorial + openfoam_clone_tutorial;
25
+ build one from scratch (incompressible laminar) -> openfoam_case_scaffold;
26
+ what is this case -> openfoam_inspect_case / openfoam_case_probe_facts.
27
+ - before a run -> openfoam_check; a failure -> openfoam_diagnose_error;
28
+ mesh -> openfoam_mesh_verify; field min/max -> openfoam_field_stats;
29
+ pictures -> openfoam_render + read_image.
30
+ - runs -> openfoam_run (short) / openfoam_run_solver_async (long, incl.
31
+ `mpirun -np N foamMultiRun`); progress/ETA -> openfoam_run_progress or
32
+ openfoam_solver_status; verdict -> openfoam_solve_verify.
33
+
34
+ ## When a tool returns a dead end
35
+ Read its `hint` / `available` / `next` fields, try the narrower call it suggests,
36
+ and tell the user which tool refused and why. Never switch to bash silently.
37
+ If a result carries `needs_input`, ask the user with `ask_user_question` in
38
+ {{language}}, offering its `options` (translate the labels), and do not continue
39
+ until they answer.
40
+ Multi-region cases take `region="fluid"`. Before finishing a long task, call
41
+ openfoam_usage_report: an unused tool family means the work went around the plugin.
42
+ A write tool that answers `applied: false` (preview) or asks for approval has
43
+ not changed anything: apply it explicitly, or tell the user it was not applied.
44
+
45
+ ## Language
46
+ Reply to the user in {{language}}; code, identifiers and comments in English.
47
+
48
+ ## Verified experience
49
+ Before a long task, `openfoam_experience_recall(task)`; after a verified success,
50
+ offer `openfoam_experience_save`.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,29 @@
1
+ OpenFOAM Workbench (dsh-openfoam-workbench)
2
+
3
+ This product includes software and ideas derived from the following projects.
4
+
5
+ 1. NullFlux / CFDriver (https://github.com/LZF1111/nullflux)
6
+ Copyright (c) LZF. Licensed under the Apache License, Version 2.0.
7
+ The experience-card format (title, domain, triggers, solver, physics, recipe,
8
+ key_params, verify_seq, pitfalls) and the general "inspect -> plan -> run ->
9
+ verify" workflow were adapted from this project. No source files were
10
+ copied: the code, architecture and tool descriptions are original to this
11
+ plugin.
12
+
13
+ 2. dsh-openfoam-doctor (https://github.com/bushizhanghan/dsh-openfoam-doctor)
14
+ Copyright (c) bushizhanghan. Licensed under the MIT License.
15
+ The OpenFOAM dictionary parser, the 31 silent-failure check rules in
16
+ lib/of-engine.js (7 controlDict, 7 fvSchemes, 5 fvSolution, 3 blockMeshDict,
17
+ 1 stray times, 4 boundary fields, 4 physics), and the checkMesh/run-log
18
+ parsers, together with the ported test suite and the checkMesh log fixture,
19
+ are derived from this project.
20
+ See licenses/dsh-openfoam-doctor-MIT.txt.
21
+
22
+ 3. csml-rpi/AI-CFD-Scientist (https://github.com/csml-rpi/AI-CFD-Scientist)
23
+ The mesh-independence protocol (STEPS A–E), the numerical-stats patterns,
24
+ the run-validity policy, and the PROCEED/REVISE/RERUN decision taxonomy
25
+ were adapted into our skills. Verify that repository's license before
26
+ redistributing the adapted protocols.
27
+
28
+ OpenFOAM itself is NOT redistributed. This plugin calls the user's installed
29
+ OpenFOAM (GPL-3.0) via subprocesses.
package/README.md CHANGED
@@ -1,3 +1,374 @@
1
- # Temporary Holding Version
1
+ # OpenFOAM Workbench (dsh-openfoam-workbench)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Native **DeepSeek Harness** plugin for OpenFOAM: 65 tools and 11 on-demand skills
4
+ covering case scaffolding, inspection, solver development, meshing, multi-region CHT runs,
5
+ durable background jobs, off-screen renders, paper reproduction and an
6
+ experience library. The agent gets one coherent surface — a thin always-on core
7
+ prompt (`CORE.md`), procedural skills, and tools that enforce the conventions
8
+ instead of asking the model to remember them.
9
+
10
+ ## Status
11
+
12
+ Implemented and validated on **OpenFOAM 14** (org, modular solvers),
13
+ **OpenFOAM v2606** (com, multi-region tutorials) and **ParaView 6.2.0**:
14
+
15
+ **v0.9.27 · 65 tools · 11 skills · 174 tests**
16
+
17
+ Pre-1.0: the tool set and the on-disk conventions may still change between
18
+ minor versions.
19
+
20
+ ## Requirements
21
+
22
+ - **DeepSeek Harness** `>=0.2.2-rc.1` — declared as `engines.dsh`, so the
23
+ installer refuses an older host instead of mounting a plugin it cannot support.
24
+ - **OpenFOAM** installed locally (org, e.g. `openfoam14`, and/or com, `vYYMM`);
25
+ the plugin drives it in subprocesses and never vendors it.
26
+ - **ParaView 6.x** with `pvpython` for renders and `-help` checks — optional:
27
+ everything else works without it.
28
+ - A POSIX shell (`bash -lc`) on Linux or macOS. Windows/WSL is not tested.
29
+
30
+ ## Golden cases
31
+
32
+ Three small cases with stored reference quantities live in `test/golden/`:
33
+ `cavity` (incompressible, both families), `sphereBox` (compressible, both
34
+ families, stored snappy mesh), `sphereCht` (CHT, both families, per-family stored
35
+ mesh) and `pitzDaily` (tutorial smoke test). Both branches run the same cases:
36
+ the compressible results agree within ~0.1 % and the CHT solid heats to the same
37
+ range, which is what makes `support: full` measurable. `sphereCht` starts
38
+ from a **stored mesh fixture** (`test/golden/meshes/sphereCht`, gzipped polyMesh
39
+ that both families read), so both branches solve exactly the same mesh and only
40
+ the dictionaries are generated per run. Run them against an installation with:
41
+
42
+ ```bash
43
+ node scripts/run-golden.mjs --distribution org # verify
44
+ node scripts/run-golden.mjs --update # re-bless after a reviewed change
45
+ ```
46
+
47
+ `--update` must be a deliberate, reviewed commit: the values are the regression
48
+ contract. `.github/workflows/golden.yml` runs the same script inside OpenFOAM containers
49
+ (`dicehub/openfoam:14`, `dicehub/openfoam:opencfd-2606`) for the `org` and `com`
50
+ matrix entries — proven on both: org runs all three cases, com runs `cavity`
51
+ with identical numbers and records the two skips with reasons. A case whose
52
+ tutorial is not usable on a distribution is recorded with a reason in
53
+ `test/golden/cases.mjs`.
54
+
55
+ ## Supported versions
56
+
57
+ The tool targets **org 14** and **com v2606**: those are the installations it is
58
+ tested end to end on. Every other release is described through a capability
59
+ object (probed from the installation) and lands in `partial`/`unknown` until it
60
+ is added to the test matrix:
61
+
62
+ | family | tested | support | notes |
63
+ |---|---|---|---|
64
+ | org (OpenFOAM Foundation) | 14 | `full` | modular `foamRun` + solver module, `physicalProperties`/`momentumTransport`, `surfaceFeatures` |
65
+ | com (ESI/OpenCFD) | v2606 | `full` | legacy applications (`simpleFoam`, `rhoPimpleFoam`), `transportProperties`/`turbulenceProperties`, `surfaceFeatureExtract` |
66
+ | org 10-13 | – | `partial` | modular conventions assumed; templates and rules use the same layout |
67
+ | com 2312-2512 | – | `partial` | legacy conventions assumed |
68
+ | anything older or unknown | – | `unknown` | best effort; `openfoam_check` adds an `untested-version` warning |
69
+
70
+ Capabilities are detected from the installation itself (`openfoam_version_info`
71
+ and `openfoam_env_check` return a `caps` object: modular form, post-processing
72
+ and feature utilities, transport/turbulence file names, 0/ vs 0.orig, support
73
+ level). `openfoam_mesh_plan`, `openfoam_case_scaffold` and `openfoam_check`
74
+ report the same capabilities, so a generated case always says which conventions
75
+ it followed.
76
+
77
+ ## Install
78
+
79
+ From the marketplace (once the plugin is listed):
80
+
81
+ ```text
82
+ Discover → search "OpenFOAM" → Install → restart DSH
83
+ ```
84
+
85
+ From this repository, pinned to a commit (works today, no registry needed):
86
+
87
+ ```bash
88
+ dsh plugin add git+https://github.com/yakovlev-i-a/dsh-openfoam-workbench.git#<40-hex-commit>
89
+ ```
90
+
91
+ From npm (after the first `npm publish`):
92
+
93
+ ```bash
94
+ dsh plugin add @yakovlev-i-a/dsh-openfoam-workbench@0.9.27
95
+ ```
96
+
97
+ From a local checkout:
98
+
99
+ ```bash
100
+ dsh plugin install /path/to/dsh-openfoam-workbench
101
+ ```
102
+
103
+ **Zero configuration.** The bundle ships no paths: at startup the plugin scans
104
+ `/opt`, `/usr/lib/openfoam`, `/usr/local` and `~/OpenFOAM` for directories that
105
+ contain `etc/bashrc` (org `openfoam14` and com `vYYMM` are told apart by name),
106
+ and looks for ParaView in `/opt` and on `PATH`. `openfoam_env_check` shows what
107
+ was found; `defaultDistribution` picks the install used when a tool is called
108
+ without `distribution=`.
109
+
110
+ Everything is also editable from **Settings → Plugins → OpenFOAM Workbench** once
111
+ DSH has mounted the plugin (`lib/settings-schema.js` exports a native schemastery
112
+ `Config`: `foamRoots`, `caseRoots`, `paraviewPython`, `language`, `scaleAskAbove`,
113
+ `logTailBytes`, `extraCommands`, …). The schema borrows the schemastery copy that
114
+ ships with DSH, so the bundle keeps zero npm dependencies.
115
+
116
+ Override in your **profile** patch (not in this repository) when you prefer YAML
117
+ or when discovery gets a path wrong:
118
+
119
+ ```yaml
120
+ - id: openfoam-workbench
121
+ name: '@yakovlev-i-a/dsh-openfoam-workbench'
122
+ config:
123
+ foamRoots: { org: /opt/openfoam14, com: /usr/lib/openfoam/openfoam2606 }
124
+ paraviewPython: /opt/paraview/bin/pvpython
125
+ caseRoots: [/path/to/cases] # relative case paths resolve from cwd otherwise
126
+ language: ru # '' = OS locale, 'ru'/'en'/... or a name forces one
127
+ ```
128
+
129
+ Restart DSH after install or after changing the patch.
130
+
131
+ ## Update
132
+
133
+ DSH imports plugin code at boot, so a running instance keeps the version it
134
+ started with:
135
+
136
+ ```bash
137
+ # linked install ("...": "link:/path/to/dsh-openfoam-workbench") — no reinstall:
138
+ git -C /path/to/dsh-openfoam-workbench pull --ff-only
139
+ # package install (git source; the package is not published to npm because
140
+ # package.json keeps "private": true):
141
+ dsh plugin --profile web update @yakovlev-i-a/dsh-openfoam-workbench
142
+ # then restart the host that boots the profile:
143
+ dsh web
144
+ ```
145
+
146
+ `openfoam_env_check`/`openfoam_version_info` return `plugin.version` from
147
+ `package.json`, so a stale in-memory copy is visible without guessing.
148
+
149
+ ## Multiple distributions
150
+
151
+ Several OpenFOAM installations can coexist:
152
+
153
+ ```yaml
154
+ foamRoots:
155
+ org: /opt/openfoam14
156
+ com: /usr/lib/openfoam/openfoam2606
157
+ defaultDistribution: org
158
+ ```
159
+
160
+ `openfoam_env_check` reports **every** configured distribution. `openfoam_run`,
161
+ `openfoam_run_solver_async`, `openfoam_solver_build`, `openfoam_dry_compile`,
162
+ `openfoam_solver_smoke` and `openfoam_version_info` take a `distribution` argument
163
+ (`org` / `com`) and otherwise use `defaultDistribution`.
164
+
165
+ ## Case conventions
166
+
167
+ Two conventions are enforced by these tools (for any work that goes through
168
+ them), not by the prompt:
169
+
170
+ - **`<case-dir-name>.foam`** — `clone_tutorial`, `mesh_plan`, `run`,
171
+ `run_solver_async` and `render` create the ParaView entry file named after the
172
+ case directory (`case.foam` is *not* accepted as a substitute). `inspect_case`
173
+ reports `foamFile`, `list_cases` reports whether it exists.
174
+ - **Relative paths** — a relative `casePath` resolves against the first
175
+ `caseRoots` entry (the session working directory is only the fallback when
176
+ `caseRoots` is empty); absolute paths always work. Run records and logs live
177
+ next to their case in `<case>/.openfoam-runs`, unless `runsDir` pins a
178
+ directory.
179
+ - **Geometry-scale gate** — `mesh_plan` and `check` compare the bounding box with
180
+ `scaleAskAbove` (default `0.1` m). Above it the result carries a
181
+ language-neutral `needs_input` payload — `{kind, ask, data, options: [{id, label}]}`
182
+ — rendered as a QUESTION block; the agent asks with `ask_user_question` in the
183
+ user's language (CORE.md `{{language}}`), translating the option labels, and
184
+ continues only after the answer. Set `scaleAskAbove: 0` to disable.
185
+
186
+ ## Multi-region (CHT) cases
187
+
188
+ A multi-region case (`foamMultiRun`, `chtMultiRegionFoam`, `system/<region>/...`)
189
+ is understood end to end, not treated as a broken single-region case:
190
+
191
+ ```text
192
+ inspect_case -> regions, regionSolvers, per-region fields/patches
193
+ read_dict -> file="fluid/fvSchemes", "system/fluid/...", "0/fluid/T", or region="fluid"
194
+ mesh_verify -> checkMesh -region <r> for every region, verdict from checkMesh itself
195
+ run / run_async -> mpirun -np N foamMultiRun (whitelisted launcher)
196
+ run_progress -> t, steps, s/step, ETA from a multi-region/parallel log
197
+ solve_verify -> RUNNING | STALLED | finished, no false divergence from the sigFpe banner
198
+ render -> every mesh region (or region="fluid"), errors on an empty scene
199
+ ```
200
+
201
+ `mesh_verify` takes its verdict from what checkMesh prints (`Mesh OK.` /
202
+ `Failed N mesh checks.`) and reports the stricter workbench thresholds
203
+ (aspect ratio, non-orthogonality, skewness) as warnings. `check` (the doctor)
204
+ is region-aware too: it reads `system/<r>/fvSchemes|fvSolution`, `0/<r>/*` and
205
+ `constant/<r>/*`, tags every finding with its region, and accepts
206
+ `region="<name>"` to narrow the report. `checkMesh -allRegions`
207
+ does not exist in OpenFOAM.org — the per-region call is the only honest one.
208
+
209
+ ## What you get
210
+
211
+ - **Tools** (`openfoam_*`, 61): env/version, tutorials, solver clone/build/smoke,
212
+ durable async runs (`run_solver_async` → `run_list` / `solver_status`),
213
+ run progress/ETA (`run_progress`), meshing (STL → blockMesh/snappy → checkMesh),
214
+ render (inline PNG, multi-region), verification (`solve_verify`, `mesh_verify`),
215
+ case editing (`dict_set`, `clean`), doctor checks, diagnostics, papers,
216
+ experience, and a usage self-audit (`usage_report`). Verdicts on huge logs read
217
+ only the tail (`logTailBytes`, 4 MB by default) instead of the whole file.
218
+ - **Skills** (`SKILL.md`, load on demand, 11): case-builder, **cht** (multi-region
219
+ conjugate heat transfer), solver-development, code-modify, meshing,
220
+ mesh-independence, stats, viz, analyze, paper-reproduction, self-evolution.
221
+ A test keeps every referenced tool registered and the always-on catalog under 4 KB.
222
+ - **Presentation**: inline render images (`image` blocks), table renders for
223
+ `check` / `run_list` / `mesh_verify` / `env_check` / `list_cases` /
224
+ `run_progress` / `solve_verify` / `usage_report`, compact JSON for large
225
+ payloads, and a `QUESTION` block whenever a tool needs a human decision
226
+ (`needs_input`). In the Web UI the call summary of every `openfoam_*` row
227
+ (`openfoam_x · …`) is blue, `#3b518c` on light and `#9db4e0` on dark
228
+ (`client.js`, the browser half of this bundle; no per-tool registration).
229
+
230
+ ## Screenshots
231
+
232
+ ![Multi-region CHT case: temperature field rendered from the case directory](docs/media/cht-render.png)
233
+
234
+ `openfoam_render` on `multiRegion/CHT/coolingCylinder2D` — 3045 cells, both
235
+ regions, temperature. The render reads only the case directory (no GUI).
236
+
237
+ ## Write policy
238
+
239
+ Every mutating tool decides by **impact**, and the impact is judged by the entry,
240
+ not by the file (a wrong `0/U` inlet or `fvSchemes` term converges to a
241
+ plausible but wrong answer, so neither is "safe"):
242
+
243
+ | Tool / change | Default | Why |
244
+ |---|---|---|
245
+ | `clean` | dry run | deletion cannot be undone |
246
+ | `case_scaffold` | writes only missing files (`force: true` to overwrite) | an existing setup is the user's |
247
+ | `dict_set` on `controlDict` output keys (`writeInterval`, `writeFormat`, …) | applies | organisational, visible in the log |
248
+ | `dict_set` on `purgeWrite` | low for `0`, **preview** for any value > 0 | it deletes older time directories |
249
+ | `dict_set` on `0/*`, `fvSchemes`, `fvSolution`, `constant/*`, `deltaT`, `application`, anything unknown | **preview** (`applied: false`, `NOT APPLIED`) until `apply: true` | can change physics or numerics |
250
+ | `dict_set` on `controlDict` `libs`/`functions` | **approval** via the DSH user-approval seam, always required (no config switch), fail-closed without an agent identity or an answerer | can execute code |
251
+
252
+ `writeMode: impact | apply | preview` (Settings) overrides the default globally.
253
+ `dict_set` edits **single-line top-level entries**; a sub-dictionary (`functions`, `boundaryField`) is refused with an explicit error rather than half-edited.
254
+ `expect: "<current value>"` refuses a write on top of a value you did not see, and
255
+ every applied change returns a `changeId` plus an `afterHash`; `openfoam_dict_undo`
256
+ reverts it and refuses when the file changed after that edit.
257
+
258
+ ## Security
259
+
260
+ The plugin **runs local OpenFOAM programs with the privileges of your OS user**
261
+ and is **not a sandbox**: a solver or `wmake` call has the same access as a shell
262
+ started by you.
263
+
264
+ What it does to make that safe:
265
+
266
+ - only whitelisted applications run (`BASE_APPS` plus the `extraCommands`
267
+ config), and a command containing shell metacharacters (`;`, `|`, `$()`,
268
+ backticks, newlines) is refused before anything is spawned;
269
+ - the shell is always a **static script**: the bashrc, the working directory, the
270
+ log path and the command arrive as argv / positional parameters, never as text
271
+ spliced into the script, so a path containing quotes, `$()`, backticks or
272
+ spaces cannot become shell code (`lib/runtime.js`, `FOAM_RUN_SCRIPT`);
273
+ - child processes get `stdin: ignore` and never inherit a terminal;
274
+ - `clean` is a dry run by default, `dict_set` replaces one entry atomically and
275
+ keeps a `.bak`, and the source tools only read the OpenFOAM installation.
276
+
277
+ ### What these gates do and do not cover
278
+
279
+ The write policy above applies to **this plugin's tools**. An agent that also has
280
+ generic shell/file tools can change a case without them — `bash -c 'echo ... >>
281
+ system/controlDict'` never reaches `dict_set`, its impact classification or its
282
+ approval request. So treat them as **defense in depth**, not as the barrier:
283
+
284
+ - the effective boundary is the DSH sandbox and permission mode (for example
285
+ `workspace-write`, which refuses writes outside the workspace) plus the
286
+ approval answerer for what you choose to review;
287
+ - `enforceToolRouting` (Settings: `off` / `warn` / `deny` / `strict`, default
288
+ `warn`) makes the plugin watch DSH's `tools/pre-execute` seam: a
289
+ `bash`/`write`/`edit` call that writes a case dictionary is recorded, refused
290
+ (`deny`) or refused-unless-escalated (`strict`);
291
+ - `strict` has an audited way out: `openfoam_escalate({target, toolsTried, why})`
292
+ grants one single-use, 10-minute token for that target, but only when the named
293
+ plugin tools were really called and failed in the last 15 minutes (the call
294
+ history is the evidence). `escalationAuthority` decides who issues it:
295
+ `auto` (the plugin, recorded in `openfoam_usage_report`) or `ask` (the DSH
296
+ approval answerer, fail-closed without it). Text matching on shell commands is
297
+ evadable, so the guard is a strong deterrent plus a signal, not a proof;
298
+ - within a case, the plugin's gates make the *normal* path safe (one-entry
299
+ atomic edits, previews for physics changes, approval for code execution,
300
+ containment checks) and leave an audit trail (`changeId`, `afterHash`,
301
+ `.openfoam-changes/`);
302
+ - when a case matters, review what the agent actually ran: `openfoam_run_list`,
303
+ the change journal and `git diff` in the workspace.
304
+
305
+ No credentials ship with this repo. Put any API keys in DSH's `credentials`
306
+ service, never in `settings.json` or in the bundle.
307
+
308
+ ## Docs
309
+
310
+ - [CORE.md](./CORE.md) — the always-on core prompt. It is read at runtime (the
311
+ section text is a function, re-evaluated on every model step), so editing this
312
+ file changes the agent on the next message, without restarting DSH. Keep it
313
+ under 3 KB: a test fails if it grows past the budget or loses a routing marker.
314
+ The `{{language}}` placeholder is filled from the `language` config or the OS
315
+ locale, so one file serves every language.
316
+ The iron rules separate *verifiable facts* (the case, the installed OpenFOAM,
317
+ a run result — check with a tool) from *conceptual answers* (`why does the
318
+ pressure equation carry this correction?` — answer directly and cite the
319
+ source when the version matters), so the agent does not call a tool just to
320
+ satisfy a rule.
321
+ - [NOTICE](./NOTICE) / [LICENSE](./LICENSE) — attribution (Apache-2.0 + MIT).
322
+ - [market/index.json](./market/index.json) — the format-1 marketplace index
323
+ pinned to a release commit (`node scripts/make-market-index.mjs --commit <sha>
324
+ --out market/index.json`); host it over https and add that URL in Discover.
325
+
326
+ ## Layout
327
+
328
+ ```
329
+ lib/index.js # entry: apply() mounts core + skills + tool groups (~50 lines)
330
+ lib/core.js # always-on prompt section, read from CORE.md on every assembly
331
+ lib/skills.js # reads skills/*/SKILL.md and registers the catalog
332
+ lib/runtime.js # process/paths/runs helpers + config defaults (deps for tools)
333
+ lib/knowledge.js # solver classification + error patterns + diagnosis
334
+ lib/presentation.js# pvpython renders, inline images, tool-call cards, tables
335
+ lib/registry.js # registration choke point: render, strict schema, telemetry, safety
336
+ lib/of-engine.js # OpenFOAM dict parser + 31 silent-failure rules (MIT)
337
+ lib/of-case.js # multi-region model: regions, dict paths, command whitelist, progress
338
+ lib/meshlib.js # STL/geometry helpers + blockMesh/snappy plan writer
339
+ lib/caselib.js # four-step contract extraction, case facts, contract audit
340
+ lib/buildlib.js # Make/files parsing + first compiler error
341
+ lib/paperlib.js # PDF/paper extraction helpers
342
+ lib/explib.js # experience cards + learned error patterns
343
+ lib/tools/*.js # one factory per group: ({cfg, attachImage}) => tools (61 total)
344
+ skills/ # 11 × SKILL.md (progressive disclosure)
345
+ test/ # 60 tests: engine, tools, registry, skills, case model, inventory, log tail
346
+ locale/ # en/ru plugin-card strings
347
+ icon.png # plugin icon (512×512 PNG, < 256 KiB)
348
+ ```
349
+
350
+ ## Prior art & acknowledgements
351
+
352
+ The plugin is its own implementation: a Cordis bundle with its own tool layer,
353
+ runtime, multi-region case model, presentation, tests and prompt design. Two
354
+ parts nevertheless carry lineage, stated here precisely:
355
+
356
+ - **Dictionary parser and doctor checks** — `lib/of-engine.js` is a port of
357
+ [dsh-openfoam-doctor](https://github.com/bushizhanghan/dsh-openfoam-doctor)
358
+ (MIT): the OpenFOAM dictionary parser, the silent-failure rules and the
359
+ checkMesh / run-log parsers. This plugin extends it (region-aware checks, 31
360
+ rules, fixes) and ships its license in `licenses/`.
361
+ - **Experience format and operation coverage** — the experience-card schema
362
+ (`title / domain / triggers / solver / physics / recipe / key_params /
363
+ verify_seq / pitfalls`) and the overall "inspect → plan → run → verify" tool
364
+ coverage were inspired by [NullFlux / CFDriver](https://github.com/LZF1111/nullflux)
365
+ (Apache-2.0). No source files were copied; the code, architecture and
366
+ descriptions are original.
367
+ - **Skill protocols** — the mesh-independence procedure (STEPS A–E), the
368
+ numerical-stats patterns and the PROCEED / REVISE / RERUN decision taxonomy
369
+ were adapted from
370
+ [AI-CFD-Scientist `cfd-skills`](https://github.com/csml-rpi/AI-CFD-Scientist/tree/main/cfd-skills).
371
+ The wording lives in `skills/` and was rewritten for this plugin.
372
+
373
+ OpenFOAM itself is not redistributed: the plugin drives the user's installed
374
+ OpenFOAM (GPL-3.0) in subprocesses.