@aryacode/dsh-engineering 0.0.0-stage → 0.3.0

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 (281) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/LICENSE +21 -0
  3. package/README.md +228 -2
  4. package/cordis.patch.yml +122 -0
  5. package/locale/en.json +6 -0
  6. package/locale/zh.json +6 -0
  7. package/package.json +77 -3
  8. package/vendor/ftview/README.md +55 -0
  9. package/vendor/ftview/SKILL.md +74 -0
  10. package/vendor/ftview/lib/checks.d.ts +27 -0
  11. package/vendor/ftview/lib/checks.js +39 -0
  12. package/vendor/ftview/lib/core.d.ts +208 -0
  13. package/vendor/ftview/lib/core.js +160 -0
  14. package/vendor/ftview/lib/edit/drafts.d.ts +49 -0
  15. package/vendor/ftview/lib/edit/drafts.js +84 -0
  16. package/vendor/ftview/lib/edit/operations.d.ts +62 -0
  17. package/vendor/ftview/lib/edit/operations.js +126 -0
  18. package/vendor/ftview/lib/edit/prepare.d.ts +38 -0
  19. package/vendor/ftview/lib/edit/prepare.js +133 -0
  20. package/vendor/ftview/lib/edit/tools.d.ts +25 -0
  21. package/vendor/ftview/lib/edit/tools.js +198 -0
  22. package/vendor/ftview/lib/edit.d.ts +30 -0
  23. package/vendor/ftview/lib/edit.js +38 -0
  24. package/vendor/ftview/lib/index.d.ts +31 -0
  25. package/vendor/ftview/lib/index.js +36 -0
  26. package/vendor/ftview/lib/model.d.ts +80 -0
  27. package/vendor/ftview/lib/model.js +267 -0
  28. package/vendor/ftview/lib/session.d.ts +48 -0
  29. package/vendor/ftview/lib/session.js +98 -0
  30. package/vendor/ftview/lib/skill.d.ts +29 -0
  31. package/vendor/ftview/lib/skill.js +43 -0
  32. package/vendor/ftview/lib/studio/discover.d.ts +36 -0
  33. package/vendor/ftview/lib/studio/discover.js +87 -0
  34. package/vendor/ftview/lib/studio/preflight.d.ts +51 -0
  35. package/vendor/ftview/lib/studio/preflight.js +64 -0
  36. package/vendor/ftview/lib/studio/tools.d.ts +15 -0
  37. package/vendor/ftview/lib/studio/tools.js +83 -0
  38. package/vendor/ftview/lib/studio.d.ts +30 -0
  39. package/vendor/ftview/lib/studio.js +37 -0
  40. package/vendor/ftview/lib/tools.d.ts +14 -0
  41. package/vendor/ftview/lib/tools.js +202 -0
  42. package/vendor/l5x/README.md +62 -0
  43. package/vendor/l5x/SKILL.md +81 -0
  44. package/vendor/l5x/lib/approvals.d.ts +50 -0
  45. package/vendor/l5x/lib/approvals.js +93 -0
  46. package/vendor/l5x/lib/client.js +412 -0
  47. package/vendor/l5x/lib/client.js.map +1 -0
  48. package/vendor/l5x/lib/core/errors.d.ts +38 -0
  49. package/vendor/l5x/lib/core/errors.js +48 -0
  50. package/vendor/l5x/lib/core/params.d.ts +49 -0
  51. package/vendor/l5x/lib/core/params.js +39 -0
  52. package/vendor/l5x/lib/core/result.d.ts +46 -0
  53. package/vendor/l5x/lib/core/result.js +21 -0
  54. package/vendor/l5x/lib/core/tool.d.ts +102 -0
  55. package/vendor/l5x/lib/core/tool.js +19 -0
  56. package/vendor/l5x/lib/drafts.d.ts +66 -0
  57. package/vendor/l5x/lib/drafts.js +98 -0
  58. package/vendor/l5x/lib/editing.d.ts +30 -0
  59. package/vendor/l5x/lib/editing.js +42 -0
  60. package/vendor/l5x/lib/engine/acd-edit.d.ts +13 -0
  61. package/vendor/l5x/lib/engine/acd-edit.js +115 -0
  62. package/vendor/l5x/lib/engine/analysis.d.ts +22 -0
  63. package/vendor/l5x/lib/engine/analysis.js +258 -0
  64. package/vendor/l5x/lib/engine/capabilities.d.ts +9 -0
  65. package/vendor/l5x/lib/engine/capabilities.js +40 -0
  66. package/vendor/l5x/lib/engine/change-set.d.ts +122 -0
  67. package/vendor/l5x/lib/engine/change-set.js +446 -0
  68. package/vendor/l5x/lib/engine/configuration.d.ts +21 -0
  69. package/vendor/l5x/lib/engine/configuration.js +42 -0
  70. package/vendor/l5x/lib/engine/details.d.ts +47 -0
  71. package/vendor/l5x/lib/engine/details.js +173 -0
  72. package/vendor/l5x/lib/engine/direct-polling.d.ts +91 -0
  73. package/vendor/l5x/lib/engine/direct-polling.js +193 -0
  74. package/vendor/l5x/lib/engine/download-review.d.ts +15 -0
  75. package/vendor/l5x/lib/engine/download-review.js +63 -0
  76. package/vendor/l5x/lib/engine/logic-syntax.d.ts +60 -0
  77. package/vendor/l5x/lib/engine/logic-syntax.js +237 -0
  78. package/vendor/l5x/lib/engine/observations.d.ts +41 -0
  79. package/vendor/l5x/lib/engine/observations.js +67 -0
  80. package/vendor/l5x/lib/engine/project-analysis.d.ts +131 -0
  81. package/vendor/l5x/lib/engine/project-analysis.js +314 -0
  82. package/vendor/l5x/lib/engine/review-evidence.d.ts +8 -0
  83. package/vendor/l5x/lib/engine/review-evidence.js +49 -0
  84. package/vendor/l5x/lib/engine/review.d.ts +18 -0
  85. package/vendor/l5x/lib/engine/review.js +123 -0
  86. package/vendor/l5x/lib/engine/studio-sdk.d.ts +101 -0
  87. package/vendor/l5x/lib/engine/studio-sdk.js +571 -0
  88. package/vendor/l5x/lib/engine/tag-resolution.d.ts +20 -0
  89. package/vendor/l5x/lib/engine/tag-resolution.js +169 -0
  90. package/vendor/l5x/lib/engine/usage.d.ts +16 -0
  91. package/vendor/l5x/lib/engine/usage.js +92 -0
  92. package/vendor/l5x/lib/engine/xml-regions.d.ts +23 -0
  93. package/vendor/l5x/lib/engine/xml-regions.js +77 -0
  94. package/vendor/l5x/lib/fs.d.ts +17 -0
  95. package/vendor/l5x/lib/fs.js +36 -0
  96. package/vendor/l5x/lib/index.d.ts +36 -0
  97. package/vendor/l5x/lib/index.js +42 -0
  98. package/vendor/l5x/lib/live.d.ts +48 -0
  99. package/vendor/l5x/lib/live.js +48 -0
  100. package/vendor/l5x/lib/model/aois.d.ts +39 -0
  101. package/vendor/l5x/lib/model/aois.js +112 -0
  102. package/vendor/l5x/lib/model/errors.d.ts +15 -0
  103. package/vendor/l5x/lib/model/errors.js +18 -0
  104. package/vendor/l5x/lib/model/index.d.ts +20 -0
  105. package/vendor/l5x/lib/model/index.js +19 -0
  106. package/vendor/l5x/lib/model/module.d.ts +37 -0
  107. package/vendor/l5x/lib/model/module.js +54 -0
  108. package/vendor/l5x/lib/model/modules.d.ts +24 -0
  109. package/vendor/l5x/lib/model/modules.js +55 -0
  110. package/vendor/l5x/lib/model/parse.d.ts +32 -0
  111. package/vendor/l5x/lib/model/parse.js +116 -0
  112. package/vendor/l5x/lib/model/project.d.ts +15 -0
  113. package/vendor/l5x/lib/model/project.js +31 -0
  114. package/vendor/l5x/lib/model/routines.d.ts +71 -0
  115. package/vendor/l5x/lib/model/routines.js +183 -0
  116. package/vendor/l5x/lib/model/tags.d.ts +51 -0
  117. package/vendor/l5x/lib/model/tags.js +119 -0
  118. package/vendor/l5x/lib/model/types.d.ts +304 -0
  119. package/vendor/l5x/lib/model/types.js +12 -0
  120. package/vendor/l5x/lib/model/udts.d.ts +34 -0
  121. package/vendor/l5x/lib/model/udts.js +81 -0
  122. package/vendor/l5x/lib/model/xml.d.ts +139 -0
  123. package/vendor/l5x/lib/model/xml.js +291 -0
  124. package/vendor/l5x/lib/model/xref.d.ts +28 -0
  125. package/vendor/l5x/lib/model/xref.js +154 -0
  126. package/vendor/l5x/lib/session.d.ts +119 -0
  127. package/vendor/l5x/lib/session.js +236 -0
  128. package/vendor/l5x/lib/skill.d.ts +30 -0
  129. package/vendor/l5x/lib/skill.js +44 -0
  130. package/vendor/l5x/lib/studio-state.d.ts +77 -0
  131. package/vendor/l5x/lib/studio-state.js +79 -0
  132. package/vendor/l5x/lib/studio.d.ts +29 -0
  133. package/vendor/l5x/lib/studio.js +40 -0
  134. package/vendor/l5x/lib/tools/checks.d.ts +19 -0
  135. package/vendor/l5x/lib/tools/checks.js +140 -0
  136. package/vendor/l5x/lib/tools/common.d.ts +41 -0
  137. package/vendor/l5x/lib/tools/common.js +84 -0
  138. package/vendor/l5x/lib/tools/controller.d.ts +21 -0
  139. package/vendor/l5x/lib/tools/controller.js +170 -0
  140. package/vendor/l5x/lib/tools/drafts.d.ts +23 -0
  141. package/vendor/l5x/lib/tools/drafts.js +270 -0
  142. package/vendor/l5x/lib/tools/live.d.ts +21 -0
  143. package/vendor/l5x/lib/tools/live.js +175 -0
  144. package/vendor/l5x/lib/tools/read.d.ts +19 -0
  145. package/vendor/l5x/lib/tools/read.js +245 -0
  146. package/vendor/l5x/lib/tools/references.d.ts +20 -0
  147. package/vendor/l5x/lib/tools/references.js +269 -0
  148. package/vendor/l5x/lib/tools/studio.d.ts +21 -0
  149. package/vendor/l5x/lib/tools/studio.js +193 -0
  150. package/vendor/l5x/poll-worker.mjs +77 -0
  151. package/vendor/l5x/studio-bridge/NuGet.Config +1 -0
  152. package/vendor/l5x/studio-bridge/Program.cs +304 -0
  153. package/vendor/l5x/studio-bridge/StudioBridge.csproj +11 -0
  154. package/vendor/mwi/README.md +60 -0
  155. package/vendor/mwi/SKILL.md +87 -0
  156. package/vendor/mwi/bridge/README.md +8 -0
  157. package/vendor/mwi/bridge/mw_bridge.ps1 +2763 -0
  158. package/vendor/mwi/bridge/sdk-interop-importer.cs +30 -0
  159. package/vendor/mwi/bridge/sdk-variable-reader.cs +22 -0
  160. package/vendor/mwi/bridge/start_bridge.cmd +21 -0
  161. package/vendor/mwi/bridge/watch_dialogs.cmd +13 -0
  162. package/vendor/mwi/bridge/watch_dialogs.ps1 +153 -0
  163. package/vendor/mwi/code/engine/motionworks_iec_mcp/__init__.py +14 -0
  164. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/__init__.cpython-312.pyc +0 -0
  165. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/block_interfaces.cpython-312.pyc +0 -0
  166. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/cfb.cpython-312.pyc +0 -0
  167. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/datatypes.cpython-312.pyc +0 -0
  168. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/declarations.cpython-312.pyc +0 -0
  169. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/errors.cpython-312.pyc +0 -0
  170. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/graphical_listing.cpython-312.pyc +0 -0
  171. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/grid.cpython-312.pyc +0 -0
  172. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/knowledge.cpython-312.pyc +0 -0
  173. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/mwt_bind.cpython-312.pyc +0 -0
  174. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/navigation.cpython-312.pyc +0 -0
  175. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/program_checks.cpython-312.pyc +0 -0
  176. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/project.cpython-312.pyc +0 -0
  177. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/staging.cpython-312.pyc +0 -0
  178. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/structure.cpython-312.pyc +0 -0
  179. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/task_bindings.cpython-312.pyc +0 -0
  180. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/tasks.cpython-312.pyc +0 -0
  181. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/tree.cpython-312.pyc +0 -0
  182. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/validation.cpython-312.pyc +0 -0
  183. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/variable_edit.cpython-312.pyc +0 -0
  184. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/variables.cpython-312.pyc +0 -0
  185. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/workflow.cpython-312.pyc +0 -0
  186. package/vendor/mwi/code/engine/motionworks_iec_mcp/block_interfaces.py +275 -0
  187. package/vendor/mwi/code/engine/motionworks_iec_mcp/build.py +339 -0
  188. package/vendor/mwi/code/engine/motionworks_iec_mcp/capture.py +448 -0
  189. package/vendor/mwi/code/engine/motionworks_iec_mcp/cfb.py +765 -0
  190. package/vendor/mwi/code/engine/motionworks_iec_mcp/com.py +268 -0
  191. package/vendor/mwi/code/engine/motionworks_iec_mcp/datatypes.py +204 -0
  192. package/vendor/mwi/code/engine/motionworks_iec_mcp/declarations.py +399 -0
  193. package/vendor/mwi/code/engine/motionworks_iec_mcp/descriptions.py +30 -0
  194. package/vendor/mwi/code/engine/motionworks_iec_mcp/eip.py +292 -0
  195. package/vendor/mwi/code/engine/motionworks_iec_mcp/errors.py +36 -0
  196. package/vendor/mwi/code/engine/motionworks_iec_mcp/graphical_listing.py +208 -0
  197. package/vendor/mwi/code/engine/motionworks_iec_mcp/grid.py +227 -0
  198. package/vendor/mwi/code/engine/motionworks_iec_mcp/ide.py +317 -0
  199. package/vendor/mwi/code/engine/motionworks_iec_mcp/iec.py +317 -0
  200. package/vendor/mwi/code/engine/motionworks_iec_mcp/installed_help.py +151 -0
  201. package/vendor/mwi/code/engine/motionworks_iec_mcp/knowledge.py +218 -0
  202. package/vendor/mwi/code/engine/motionworks_iec_mcp/libraries.py +250 -0
  203. package/vendor/mwi/code/engine/motionworks_iec_mcp/manuals.py +520 -0
  204. package/vendor/mwi/code/engine/motionworks_iec_mcp/mwt_bind.py +133 -0
  205. package/vendor/mwi/code/engine/motionworks_iec_mcp/navigation.py +44 -0
  206. package/vendor/mwi/code/engine/motionworks_iec_mcp/pou_writer.py +1547 -0
  207. package/vendor/mwi/code/engine/motionworks_iec_mcp/program_checks.py +360 -0
  208. package/vendor/mwi/code/engine/motionworks_iec_mcp/project.py +704 -0
  209. package/vendor/mwi/code/engine/motionworks_iec_mcp/reference_data/catalog.json +672 -0
  210. package/vendor/mwi/code/engine/motionworks_iec_mcp/reference_data/patterns.json +86 -0
  211. package/vendor/mwi/code/engine/motionworks_iec_mcp/restore.py +208 -0
  212. package/vendor/mwi/code/engine/motionworks_iec_mcp/server.py +1913 -0
  213. package/vendor/mwi/code/engine/motionworks_iec_mcp/snapshot.py +138 -0
  214. package/vendor/mwi/code/engine/motionworks_iec_mcp/st_comments.py +25 -0
  215. package/vendor/mwi/code/engine/motionworks_iec_mcp/staging.py +179 -0
  216. package/vendor/mwi/code/engine/motionworks_iec_mcp/stlint.py +676 -0
  217. package/vendor/mwi/code/engine/motionworks_iec_mcp/structure.py +98 -0
  218. package/vendor/mwi/code/engine/motionworks_iec_mcp/task_bindings.py +68 -0
  219. package/vendor/mwi/code/engine/motionworks_iec_mcp/tasks.py +162 -0
  220. package/vendor/mwi/code/engine/motionworks_iec_mcp/transaction.py +157 -0
  221. package/vendor/mwi/code/engine/motionworks_iec_mcp/tree.py +563 -0
  222. package/vendor/mwi/code/engine/motionworks_iec_mcp/tree_writer.py +790 -0
  223. package/vendor/mwi/code/engine/motionworks_iec_mcp/uia.py +465 -0
  224. package/vendor/mwi/code/engine/motionworks_iec_mcp/validation.py +41 -0
  225. package/vendor/mwi/code/engine/motionworks_iec_mcp/variable_edit.py +183 -0
  226. package/vendor/mwi/code/engine/motionworks_iec_mcp/variables.py +472 -0
  227. package/vendor/mwi/code/engine/motionworks_iec_mcp/workflow.py +130 -0
  228. package/vendor/mwi/code/engine/motionworks_iec_mcp/writer.py +666 -0
  229. package/vendor/mwi/code/mw_code.py +1258 -0
  230. package/vendor/mwi/legacy/edit-session.js +50 -0
  231. package/vendor/mwi/legacy/fb-insertion.js +74 -0
  232. package/vendor/mwi/legacy/native-code.js +83 -0
  233. package/vendor/mwi/legacy/native-groups.js +75 -0
  234. package/vendor/mwi/legacy/native-structure.js +143 -0
  235. package/vendor/mwi/legacy/native-variables.js +77 -0
  236. package/vendor/mwi/legacy/pou-conversion.js +47 -0
  237. package/vendor/mwi/legacy/pou-package.js +66 -0
  238. package/vendor/mwi/lib/core/bridge.d.ts +71 -0
  239. package/vendor/mwi/lib/core/bridge.js +53 -0
  240. package/vendor/mwi/lib/core/code-engine.d.ts +47 -0
  241. package/vendor/mwi/lib/core/code-engine.js +109 -0
  242. package/vendor/mwi/lib/core/errors.d.ts +37 -0
  243. package/vendor/mwi/lib/core/errors.js +47 -0
  244. package/vendor/mwi/lib/core/params.d.ts +52 -0
  245. package/vendor/mwi/lib/core/params.js +46 -0
  246. package/vendor/mwi/lib/core/ps-bridge.d.ts +62 -0
  247. package/vendor/mwi/lib/core/ps-bridge.js +127 -0
  248. package/vendor/mwi/lib/core/result.d.ts +45 -0
  249. package/vendor/mwi/lib/core/result.js +20 -0
  250. package/vendor/mwi/lib/core/tool.d.ts +80 -0
  251. package/vendor/mwi/lib/core/tool.js +55 -0
  252. package/vendor/mwi/lib/edit/compare.d.ts +33 -0
  253. package/vendor/mwi/lib/edit/compare.js +70 -0
  254. package/vendor/mwi/lib/edit.d.ts +20 -0
  255. package/vendor/mwi/lib/edit.js +32 -0
  256. package/vendor/mwi/lib/index.d.ts +21 -0
  257. package/vendor/mwi/lib/index.js +33 -0
  258. package/vendor/mwi/lib/read/service.d.ts +117 -0
  259. package/vendor/mwi/lib/read/service.js +229 -0
  260. package/vendor/mwi/lib/read.d.ts +21 -0
  261. package/vendor/mwi/lib/read.js +33 -0
  262. package/vendor/mwi/lib/session/project.d.ts +34 -0
  263. package/vendor/mwi/lib/session/project.js +54 -0
  264. package/vendor/mwi/lib/session/service.d.ts +167 -0
  265. package/vendor/mwi/lib/session/service.js +566 -0
  266. package/vendor/mwi/lib/session/stage.d.ts +84 -0
  267. package/vendor/mwi/lib/session/stage.js +187 -0
  268. package/vendor/mwi/lib/session/workspace.d.ts +52 -0
  269. package/vendor/mwi/lib/session/workspace.js +90 -0
  270. package/vendor/mwi/lib/skill.d.ts +36 -0
  271. package/vendor/mwi/lib/skill.js +56 -0
  272. package/vendor/mwi/lib/tools/edit.d.ts +20 -0
  273. package/vendor/mwi/lib/tools/edit.js +286 -0
  274. package/vendor/mwi/lib/tools/read.d.ts +19 -0
  275. package/vendor/mwi/lib/tools/read.js +161 -0
  276. package/vendor/mwi/lib/tools/session.d.ts +20 -0
  277. package/vendor/mwi/lib/tools/session.js +166 -0
  278. package/vendor/mwi/lib/tools/verify.d.ts +19 -0
  279. package/vendor/mwi/lib/tools/verify.js +85 -0
  280. package/vendor/mwi/lib/verify.d.ts +17 -0
  281. package/vendor/mwi/lib/verify.js +29 -0
@@ -0,0 +1,166 @@
1
+ /**
2
+ * The session row: find, stage, open and close the project; report IDE state.
3
+ *
4
+ * An IDE that is not running is a state, not a failure: the tools report it and
5
+ * point at the start tool. Every mutation that touches the IDE names the consent
6
+ * it needs in its parameters.
7
+ *
8
+ * @module dsh-engineering-mwi/tools/session
9
+ */
10
+ import { boolean, choice, integer, object, string } from "../core/params.js";
11
+ import { success } from "../core/result.js";
12
+ import { MwiError } from "../core/errors.js";
13
+ import { tool } from "../core/tool.js";
14
+ import { findProjects, stageRootOf, workspaceOf } from "../session/workspace.js";
15
+ import { runtimeFor } from "../session/service.js";
16
+ /** What every IDE answer cannot establish. */
17
+ const IDE_COVERAGE = {
18
+ complete: false,
19
+ unverified: [
20
+ 'runtime behavior of the loaded project',
21
+ 'graphical placement and wiring of saved code',
22
+ 'whether the loaded project matches the saved project after external changes',
23
+ ],
24
+ };
25
+ /** Run a bridge operation, return undefined when the IDE is simply not running. */
26
+ async function optional(call) {
27
+ try {
28
+ return await call();
29
+ }
30
+ catch (error) {
31
+ if (error instanceof MwiError && error.code === 'IDE_NOT_RUNNING')
32
+ return undefined;
33
+ throw error;
34
+ }
35
+ }
36
+ /**
37
+ * The session tools.
38
+ *
39
+ * @param runtimeOf - Workspace runtime factory; defaults to the PowerShell bridge.
40
+ * @returns Tool definitions in registration order.
41
+ */
42
+ export function sessionTools(runtimeOf = runtimeFor) {
43
+ return [
44
+ tool({
45
+ name: 'mw_project_find',
46
+ description: 'Find MotionWorks IEC projects inside the calling workspace. Returns each .mwt, its expanded directory and whether a staged copy exists. Call this before staging or opening anything.',
47
+ parameters: object({
48
+ filter: string('Optional case-insensitive substring matched against the project name or path.'),
49
+ limit: integer('Most projects to return. Defaults to 20.', { minimum: 1, maximum: 100 }),
50
+ }),
51
+ async run(args, exec) {
52
+ const workspace = workspaceOf(exec.cwd);
53
+ const projects = findProjects(workspace, {
54
+ filter: typeof args.filter === 'string' ? args.filter : undefined,
55
+ limit: typeof args.limit === 'number' ? args.limit : 20,
56
+ });
57
+ const staged = projects.filter(project => project.staged !== null).length;
58
+ return success(projects.length === 0
59
+ ? `No MotionWorks project was found inside ${workspace}.`
60
+ : `Found ${projects.length} MotionWorks project(s) in ${workspace}; ${staged} already staged.`, { workspace, stage_root: stageRootOf(workspace), projects }, projects.length === 0
61
+ ? []
62
+ : [{ tool: 'mw_project_stage', why: 'Stage the intended project before opening it.', args: { source: projects[0]?.mwt } }], { complete: false, unverified: ['projects outside the workspace are never listed or staged'] });
63
+ },
64
+ }),
65
+ tool({
66
+ name: 'mw_ide_status',
67
+ description: 'Report whether MotionWorks IEC is running, which project is open, the automation version, the active view, the compile state and any blocking dialog. Call it before and after operations that change the IDE.',
68
+ parameters: object({}),
69
+ async run(_args, exec) {
70
+ const workspace = workspaceOf(exec.cwd);
71
+ const status = await optional(async () => await runtimeOf(workspace).status());
72
+ if (status === undefined) {
73
+ return success('MotionWorks IEC is not running.', { ide_running: false, workspace, stage_root: stageRootOf(workspace) }, [{ tool: 'mw_ide_start', why: 'Start the IDE with a staged workspace project.' }], IDE_COVERAGE);
74
+ }
75
+ const state = await optional(async () => await runtimeOf(workspace).ideState());
76
+ const blocked = state?.blocked === true;
77
+ return success(blocked
78
+ ? 'MotionWorks IEC is running and blocked by a dialog.'
79
+ : status.is_project_open === true
80
+ ? `MotionWorks IEC is running with ${String(status.active_project ?? 'a project')} open.`
81
+ : 'MotionWorks IEC is running with no project open.', { workspace, stage_root: stageRootOf(workspace), ...status, ...(state === undefined ? {} : { ide_state: state }) }, blocked
82
+ ? [{ tool: 'mw_ide_status', why: 'Re-read after the dialog is resolved.' }]
83
+ : [{ tool: 'mw_project_find', why: 'Confirm the project is the one in the workspace.' }], IDE_COVERAGE);
84
+ },
85
+ }),
86
+ tool({
87
+ name: 'mw_project_stage',
88
+ description: 'Copy one workspace project into the stage so the IDE opens a copy, never the original. The .mwt and its expanded directory are copied and the wrapper is bound to the staged directory.',
89
+ parameters: object({
90
+ source: string('Workspace project folder or its .mwt. Must be inside the workspace.'),
91
+ replace_existing: boolean('Replace an existing stage after review; defaults false. The previous stage is retained under backups/.'),
92
+ }, ['source']),
93
+ async run(args, exec) {
94
+ const workspace = workspaceOf(exec.cwd);
95
+ const record = await runtimeOf(workspace).stage(String(args.source), { replace: args.replace_existing === true });
96
+ return success(`Staged ${record.name} from ${record.source}.`, record, [{ tool: 'mw_project_open', why: 'Open the staged project in the IDE.', args: { path: record.staged_mwt } }], { complete: false, unverified: ['the staged copy is byte-identical to the source; the source itself is untouched'] });
97
+ },
98
+ }),
99
+ tool({
100
+ name: 'mw_project_open',
101
+ description: 'Open one staged project in the running IDE. Refuses a path that is not a proven stage, and refuses to replace another open project without the exact approved path.',
102
+ parameters: object({
103
+ path: string('Staged .mwt path returned by mw_project_stage.'),
104
+ user_approved: boolean('True only after the user approved saving and closing another open project.'),
105
+ expected_project: string('Exact open project path named in that approval.'),
106
+ }, ['path']),
107
+ async run(args, exec) {
108
+ const workspace = workspaceOf(exec.cwd);
109
+ const opened = await runtimeOf(workspace).open(String(args.path), {
110
+ userApproved: args.user_approved === true,
111
+ expectedProject: typeof args.expected_project === 'string' ? args.expected_project : undefined,
112
+ });
113
+ return success(opened.matches_request === false
114
+ ? 'The open call returned, but the IDE has a different project open.'
115
+ : `Opened ${String(opened.active_project ?? args.path)}.`, opened, [{ tool: 'mw_ide_status', why: 'Confirm the active project and compile state.' }], IDE_COVERAGE);
116
+ },
117
+ }),
118
+ tool({
119
+ name: 'mw_ide_start',
120
+ description: 'Start MotionWorks IEC with one staged project, or attach to the IDE that is already running. Refuses when several stages exist without a project argument.',
121
+ parameters: object({
122
+ project: string('Staged .mwt to start with. Omit when exactly one project is staged.'),
123
+ }),
124
+ async run(args, exec) {
125
+ const workspace = workspaceOf(exec.cwd);
126
+ const started = await runtimeOf(workspace).start(typeof args.project === 'string' ? args.project : undefined);
127
+ return success(started.already_running === true ? 'MotionWorks IEC was already running.' : 'MotionWorks IEC started.', started, [{ tool: 'mw_ide_status', why: 'Confirm the project and compile state after startup.' }], IDE_COVERAGE);
128
+ },
129
+ }),
130
+ tool({
131
+ name: 'mw_worksheet_open',
132
+ description: 'Open one code or variable worksheet, or resource globals, in the open staged project and verify the active view. Read-only: no edit, save, compile or download.',
133
+ parameters: object({
134
+ kind: choice('Worksheet kind: code or variables.', ['code', 'variables']),
135
+ pou: string('POU name for a code worksheet. Omit for globals.'),
136
+ inspect_only: boolean('Check the current editor instead of opening one; defaults false.'),
137
+ }, ['kind']),
138
+ async run(args, exec) {
139
+ const workspace = workspaceOf(exec.cwd);
140
+ const kind = args.kind === 'code' ? 'code' : 'variables';
141
+ const opened = await runtimeOf(workspace).worksheet({
142
+ kind,
143
+ ...(typeof args.pou === 'string' ? { pou: args.pou } : {}),
144
+ inspectOnly: args.inspect_only === true,
145
+ });
146
+ return success(`Opened the ${kind} worksheet${typeof args.pou === 'string' ? ` for ${args.pou}` : ''}.`, opened, [{ tool: 'mw_ide_status', why: 'Confirm the active view before editing.' }], IDE_COVERAGE);
147
+ },
148
+ }),
149
+ tool({
150
+ name: 'mw_project_close',
151
+ description: 'Close MotionWorks IEC, saving the open project, after explicit user approval for that exact project.',
152
+ parameters: object({
153
+ user_approved: boolean('True only after the user approved saving and closing MotionWorks.'),
154
+ expected_project: string('Exact open project path named in the approval.'),
155
+ }, ['user_approved']),
156
+ async run(args, exec) {
157
+ const workspace = workspaceOf(exec.cwd);
158
+ const closed = await runtimeOf(workspace).close({
159
+ userApproved: args.user_approved === true,
160
+ expectedProject: typeof args.expected_project === 'string' ? args.expected_project : undefined,
161
+ });
162
+ return success(closed.closed === true ? 'MotionWorks IEC closed.' : 'MotionWorks IEC is still running.', closed, closed.closed === true ? [] : [{ tool: 'mw_ide_status', why: 'Inspect why the IDE did not close.' }], { complete: false, unverified: ['unsaved state after close'] });
163
+ },
164
+ }),
165
+ ];
166
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The verify row: compile, diagnostics and saved-source verification.
3
+ *
4
+ * Every tool here requires the open project to be a proven stage; the runtime
5
+ * refuses a workspace original.
6
+ *
7
+ * @module dsh-engineering-mwi/tools/verify
8
+ */
9
+ import { type ToolDefinition } from '../core/tool.ts';
10
+ import type { SessionRuntime } from '../session/service.ts';
11
+ /** How the tools reach a workspace runtime; injectable for tests. */
12
+ export type VerifyRuntimeFactory = (workspace: string) => SessionRuntime;
13
+ /**
14
+ * The verify tools.
15
+ *
16
+ * @param runtimeOf - Workspace runtime factory; defaults to the PowerShell bridge.
17
+ * @returns Tool definitions in registration order.
18
+ */
19
+ export declare function verifyTools(runtimeOf?: VerifyRuntimeFactory): readonly ToolDefinition[];
@@ -0,0 +1,85 @@
1
+ /**
2
+ * The verify row: compile, diagnostics and saved-source verification.
3
+ *
4
+ * Every tool here requires the open project to be a proven stage; the runtime
5
+ * refuses a workspace original.
6
+ *
7
+ * @module dsh-engineering-mwi/tools/verify
8
+ */
9
+ import { choice, integer, object, string } from "../core/params.js";
10
+ import { success } from "../core/result.js";
11
+ import { tool } from "../core/tool.js";
12
+ import { workspaceOf } from "../session/workspace.js";
13
+ import { runtimeFor } from "../session/service.js";
14
+ /** What a compile verdict cannot establish. */
15
+ const VERIFY_COVERAGE = {
16
+ complete: false,
17
+ unverified: [
18
+ 'runtime behavior of the compiled project',
19
+ 'controller state and online logic',
20
+ 'graphical placement and wiring',
21
+ ],
22
+ };
23
+ /**
24
+ * The verify tools.
25
+ *
26
+ * @param runtimeOf - Workspace runtime factory; defaults to the PowerShell bridge.
27
+ * @returns Tool definitions in registration order.
28
+ */
29
+ export function verifyTools(runtimeOf = runtimeFor) {
30
+ return [
31
+ tool({
32
+ name: 'mw_compile',
33
+ description: 'Run Make (link changed sources), Build (full compile), or read the compile state of the open staged project. A verdict is the vendor engine\'s, not proof of runtime behavior.',
34
+ parameters: object({
35
+ mode: choice('Compile operation: make, build or state.', ['make', 'build', 'state']),
36
+ }),
37
+ async run(args, exec) {
38
+ const workspace = workspaceOf(exec.cwd);
39
+ const mode = (args.mode === 'make' || args.mode === 'build' ? args.mode : 'state');
40
+ const result = await runtimeOf(workspace).compile(mode);
41
+ const state = mode === 'state'
42
+ ? `compiled=${String(result.is_compiled ?? 'unknown')}, modified=${String(result.is_modified ?? 'unknown')}`
43
+ : `verdict ${String(result.verdict ?? result.status ?? 'reported')}`;
44
+ return success(`${mode === 'state' ? 'Compile state' : mode}: ${state}.`, result, [{ tool: 'mw_diagnostics', why: 'Read the IDE messages the verdict does not include.' }], VERIFY_COVERAGE);
45
+ },
46
+ }),
47
+ tool({
48
+ name: 'mw_diagnostics',
49
+ description: 'Read one IDE output pane (Errors, Warnings or Build) as text, with the compile state attached. The API returns a verdict but not the messages, so this is the only source for exact text.',
50
+ parameters: object({
51
+ pane: string('Output pane name. Defaults to Errors.'),
52
+ limit: integer('Most messages. Defaults to 200, maximum 500.', { minimum: 1, maximum: 500 }),
53
+ }),
54
+ async run(args, exec) {
55
+ const workspace = workspaceOf(exec.cwd);
56
+ const pane = typeof args.pane === 'string' && args.pane !== '' ? args.pane : 'Errors';
57
+ const result = await runtimeOf(workspace).diagnostics(pane, typeof args.limit === 'number' ? args.limit : 200);
58
+ const count = typeof result.count === 'number' ? result.count : 0;
59
+ return success(count === 0
60
+ ? `${pane} has no messages; compile state is reported separately.`
61
+ : `${pane}: ${count} message(s).`, result, [{ tool: 'mw_compile', why: 'Read the verdict behind these messages.' }], VERIFY_COVERAGE);
62
+ },
63
+ }),
64
+ tool({
65
+ name: 'mw_verify',
66
+ description: 'Capture a baseline of the saved project source and compile state, or compare the open project against a captured baseline. Reports added, removed and changed source files.',
67
+ parameters: object({
68
+ mode: choice('Capture a baseline or compare against one.', ['baseline', 'compare']),
69
+ baseline_id: string('Baseline id returned by a capture. Required when mode is compare.'),
70
+ }),
71
+ async run(args, exec) {
72
+ const workspace = workspaceOf(exec.cwd);
73
+ const mode = args.mode === 'compare' ? 'compare' : 'baseline';
74
+ const result = await runtimeOf(workspace).verify(mode, typeof args.baseline_id === 'string' ? args.baseline_id : undefined);
75
+ if (mode === 'baseline') {
76
+ return success(`Captured baseline ${String(result.baseline_id)} for ${String(result.project)}.`, result, [{ tool: 'mw_verify', why: 'Compare against this baseline after a change.', args: { mode: 'compare', baseline_id: result.baseline_id } }], VERIFY_COVERAGE);
77
+ }
78
+ const matched = result.matched === true;
79
+ return success(matched ? 'The saved source matches the baseline.' : `The saved source changed since the baseline: ${String(result.changed?.length ?? 0)} changed file(s).`, result, matched
80
+ ? [{ tool: 'mw_compile', why: 'Compile the verified source.' }]
81
+ : [{ tool: 'mw_review', why: 'Review the changed project before compiling.' }], VERIFY_COVERAGE);
82
+ },
83
+ }),
84
+ ];
85
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The `mwi-verify` entry: compile, diagnostics and verification.
3
+ *
4
+ * @module dsh-engineering-mwi/verify
5
+ */
6
+ import type { PluginContext } from './core/tool.ts';
7
+ /** Plugin name in a composition. */
8
+ export declare const name = "mwi-verify";
9
+ /** Services this plugin cannot register without. */
10
+ export declare const inject: readonly ["tools"];
11
+ /**
12
+ * Register the verify tools.
13
+ *
14
+ * @param ctx - Plugin context with the tool registry.
15
+ */
16
+ export declare function apply(ctx: PluginContext): void;
17
+ export { verifyTools } from './tools/verify.ts';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The `mwi-verify` entry: compile, diagnostics and verification.
3
+ *
4
+ * @module dsh-engineering-mwi/verify
5
+ */
6
+ import { verifyTools } from "./tools/verify.js";
7
+ /** Plugin name in a composition. */
8
+ export const name = 'mwi-verify';
9
+ /** Services this plugin cannot register without. */
10
+ export const inject = ['tools'];
11
+ /**
12
+ * Register the verify tools.
13
+ *
14
+ * @param ctx - Plugin context with the tool registry.
15
+ */
16
+ export function apply(ctx) {
17
+ if (process.platform !== 'win32') {
18
+ try {
19
+ ctx.logger?.info?.(`mwi-verify: skipped because this host is ${process.platform}; MotionWorks IEC requires Windows.`);
20
+ }
21
+ catch {
22
+ // A logger that refuses must not turn an unsupported host into a crash.
23
+ }
24
+ return;
25
+ }
26
+ for (const definition of verifyTools())
27
+ ctx.tools.register(definition);
28
+ }
29
+ export { verifyTools } from "./tools/verify.js";