speclogician 0.0.0b1__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.
Files changed (139) hide show
  1. speclogician/__init__.py +0 -0
  2. speclogician/commands/__init__.py +15 -0
  3. speclogician/commands/cmd_ch.py +616 -0
  4. speclogician/commands/cmd_find.py +256 -0
  5. speclogician/commands/cmd_view.py +202 -0
  6. speclogician/commands/runner.py +149 -0
  7. speclogician/commands/utils.py +101 -0
  8. speclogician/data/__init__.py +0 -0
  9. speclogician/data/artifact.py +63 -0
  10. speclogician/data/container.py +402 -0
  11. speclogician/data/mapping.py +88 -0
  12. speclogician/data/refs.py +24 -0
  13. speclogician/data/traces.py +26 -0
  14. speclogician/demos/.DS_Store +0 -0
  15. speclogician/demos/cmd_demo.py +278 -0
  16. speclogician/demos/loader.py +135 -0
  17. speclogician/demos/model.py +27 -0
  18. speclogician/demos/runner.py +51 -0
  19. speclogician/logic/__init__.py +11 -0
  20. speclogician/logic/api/__init__.py +29 -0
  21. speclogician/logic/api/client.py +606 -0
  22. speclogician/logic/api/decomp.py +67 -0
  23. speclogician/logic/api/scenario.py +102 -0
  24. speclogician/logic/api/traces.py +59 -0
  25. speclogician/logic/lib/__init__.py +19 -0
  26. speclogician/logic/lib/complement.py +107 -0
  27. speclogician/logic/lib/domain_model.py +59 -0
  28. speclogician/logic/lib/predicates.py +151 -0
  29. speclogician/logic/lib/scenarios.py +369 -0
  30. speclogician/logic/lib/traces.py +114 -0
  31. speclogician/logic/lib/transitions.py +104 -0
  32. speclogician/logic/main.py +246 -0
  33. speclogician/logic/strings.py +194 -0
  34. speclogician/logic/utils.py +135 -0
  35. speclogician/main.py +139 -0
  36. speclogician/modeling/__init__.py +31 -0
  37. speclogician/modeling/complement.py +104 -0
  38. speclogician/modeling/component.py +71 -0
  39. speclogician/modeling/conflict.py +26 -0
  40. speclogician/modeling/domain.py +349 -0
  41. speclogician/modeling/predicates.py +59 -0
  42. speclogician/modeling/scenario.py +162 -0
  43. speclogician/modeling/spec.py +306 -0
  44. speclogician/modeling/spec_stats.py +39 -0
  45. speclogician/presentation/__init__.py +0 -0
  46. speclogician/presentation/api.py +244 -0
  47. speclogician/presentation/builders/__init__.py +0 -0
  48. speclogician/presentation/builders/_links.py +44 -0
  49. speclogician/presentation/builders/container.py +53 -0
  50. speclogician/presentation/builders/data_artifact.py +42 -0
  51. speclogician/presentation/builders/domain.py +54 -0
  52. speclogician/presentation/builders/instances_list.py +38 -0
  53. speclogician/presentation/builders/predicate.py +51 -0
  54. speclogician/presentation/builders/recommendations.py +41 -0
  55. speclogician/presentation/builders/scenario.py +41 -0
  56. speclogician/presentation/builders/scenario_complement.py +82 -0
  57. speclogician/presentation/builders/smart_find.py +39 -0
  58. speclogician/presentation/builders/spec.py +39 -0
  59. speclogician/presentation/builders/state_diff.py +150 -0
  60. speclogician/presentation/builders/state_instance.py +42 -0
  61. speclogician/presentation/builders/state_instance_summary.py +84 -0
  62. speclogician/presentation/builders/trace.py +58 -0
  63. speclogician/presentation/ctx.py +38 -0
  64. speclogician/presentation/models/__init__.py +0 -0
  65. speclogician/presentation/models/container.py +44 -0
  66. speclogician/presentation/models/data_artifact.py +33 -0
  67. speclogician/presentation/models/domain.py +50 -0
  68. speclogician/presentation/models/instances_list.py +23 -0
  69. speclogician/presentation/models/predicate.py +60 -0
  70. speclogician/presentation/models/recommendations.py +34 -0
  71. speclogician/presentation/models/scenario.py +31 -0
  72. speclogician/presentation/models/scenario_complement.py +40 -0
  73. speclogician/presentation/models/smart_find.py +34 -0
  74. speclogician/presentation/models/spec.py +32 -0
  75. speclogician/presentation/models/state_diff.py +34 -0
  76. speclogician/presentation/models/state_instance.py +31 -0
  77. speclogician/presentation/models/state_instance_summary.py +102 -0
  78. speclogician/presentation/models/trace.py +42 -0
  79. speclogician/presentation/preview/__init__.py +13 -0
  80. speclogician/presentation/preview/cli.py +50 -0
  81. speclogician/presentation/preview/fixtures/__init__.py +205 -0
  82. speclogician/presentation/preview/fixtures/artifact_container.py +150 -0
  83. speclogician/presentation/preview/fixtures/data_artifact.py +144 -0
  84. speclogician/presentation/preview/fixtures/domain_model.py +162 -0
  85. speclogician/presentation/preview/fixtures/instances_list.py +162 -0
  86. speclogician/presentation/preview/fixtures/predicate.py +184 -0
  87. speclogician/presentation/preview/fixtures/scenario.py +84 -0
  88. speclogician/presentation/preview/fixtures/scenario_complement.py +81 -0
  89. speclogician/presentation/preview/fixtures/smart_find.py +140 -0
  90. speclogician/presentation/preview/fixtures/spec.py +95 -0
  91. speclogician/presentation/preview/fixtures/state_diff.py +158 -0
  92. speclogician/presentation/preview/fixtures/state_instance.py +128 -0
  93. speclogician/presentation/preview/fixtures/state_instance_summary.py +80 -0
  94. speclogician/presentation/preview/fixtures/trace.py +206 -0
  95. speclogician/presentation/preview/registry.py +42 -0
  96. speclogician/presentation/renderers/__init__.py +24 -0
  97. speclogician/presentation/renderers/container.py +136 -0
  98. speclogician/presentation/renderers/data_artifact.py +144 -0
  99. speclogician/presentation/renderers/domain.py +123 -0
  100. speclogician/presentation/renderers/instances_list.py +120 -0
  101. speclogician/presentation/renderers/predicate.py +180 -0
  102. speclogician/presentation/renderers/recommendations.py +90 -0
  103. speclogician/presentation/renderers/scenario.py +94 -0
  104. speclogician/presentation/renderers/scenario_complement.py +59 -0
  105. speclogician/presentation/renderers/smart_find.py +307 -0
  106. speclogician/presentation/renderers/spec.py +105 -0
  107. speclogician/presentation/renderers/state_diff.py +102 -0
  108. speclogician/presentation/renderers/state_instance.py +82 -0
  109. speclogician/presentation/renderers/state_instance_summary.py +143 -0
  110. speclogician/presentation/renderers/trace.py +122 -0
  111. speclogician/py.typed +0 -0
  112. speclogician/shell/app.py +170 -0
  113. speclogician/shell/shell_ch.py +263 -0
  114. speclogician/shell/shell_view.py +153 -0
  115. speclogician/state/__init__.py +0 -0
  116. speclogician/state/change.py +428 -0
  117. speclogician/state/change_result.py +32 -0
  118. speclogician/state/diff.py +191 -0
  119. speclogician/state/inst.py +574 -0
  120. speclogician/state/recommendation.py +13 -0
  121. speclogician/state/recommender.py +577 -0
  122. speclogician/state/state.py +465 -0
  123. speclogician/state/state_stats.py +133 -0
  124. speclogician/tui/__init__.py +0 -0
  125. speclogician/tui/app.py +257 -0
  126. speclogician/tui/app.tcss +160 -0
  127. speclogician/tui/demo.py +45 -0
  128. speclogician/tui/images/speclogician-full.png +0 -0
  129. speclogician/tui/images/speclogician-minimal.png +0 -0
  130. speclogician/tui/main_screen.py +454 -0
  131. speclogician/tui/splash_screen.py +51 -0
  132. speclogician/tui/stats_screen.py +125 -0
  133. speclogician/utils/__init__.py +78 -0
  134. speclogician/utils/load.py +166 -0
  135. speclogician/utils/prompt.md +325 -0
  136. speclogician/utils/testing.py +151 -0
  137. speclogician-0.0.0b1.dist-info/METADATA +116 -0
  138. speclogician-0.0.0b1.dist-info/RECORD +139 -0
  139. speclogician-0.0.0b1.dist-info/WHEEL +4 -0
File without changes
@@ -0,0 +1,15 @@
1
+ #
2
+ # Imandra Inc.
3
+ #
4
+ # speclogician/commands/__init__.py
5
+ #
6
+
7
+ from .cmd_ch import app as ch_app
8
+ from .cmd_find import app as find_app
9
+ from .cmd_view import app as view_app
10
+
11
+ __all__ = [
12
+ "ch_app",
13
+ "find_app",
14
+ "view_app"
15
+ ]
@@ -0,0 +1,616 @@
1
+ #
2
+ # Imandra Inc.
3
+ #
4
+ # speclogician/commands/ch_cmd.py
5
+ #
6
+
7
+ import typer
8
+ from typing import Optional
9
+ from pathlib import Path
10
+ from ..state.change import (
11
+ DomainModelBaseEdit,
12
+ PredicateAdd,
13
+ PredicateEdit,
14
+ PredicateRemove,
15
+ TransitionAdd,
16
+ TransitionEdit,
17
+ TransitionRemove,
18
+ ScenarioAdd,
19
+ ScenarioEdit,
20
+ ScenarioRemove,
21
+ AddTestTrace,
22
+ EditTestTrace,
23
+ AddLogTrace,
24
+ EditLogTrace,
25
+ RemoveTraceArtifact,
26
+ AddDocRef,
27
+ EditDocRef,
28
+ AddSrcCodeRef,
29
+ EditSrcCodeRef,
30
+ RemoveDataArtifact,
31
+ LinkArtifactsComponents,
32
+ RemoveArtComponentLink
33
+ )
34
+
35
+ from ..modeling.scenario import ScenarioDelta
36
+ from ..modeling.predicates import PredicateType
37
+ from .utils import (
38
+ parse_scenario_delta,
39
+ get_state
40
+ )
41
+ from .runner import run_change_and_render
42
+
43
+ app = typer.Typer(help="Change state commands")
44
+
45
+
46
+ #-----------------------------------------------------------------------------
47
+ # Base Model
48
+ #-----------------------------------------------------------------------------
49
+
50
+ @app.command("base-edit")
51
+ def domain_base_edit(
52
+ ctx: typer.Context,
53
+ src: Optional[str] = typer.Option(
54
+ None,
55
+ "--src",
56
+ help="IML source code for the domain base component",
57
+ ),
58
+ file: Optional[Path] = typer.Option(
59
+ None,
60
+ "--file",
61
+ exists=True,
62
+ readable=True,
63
+ help="Path to a file containing IML base source code",
64
+ ),
65
+ json_only: bool = typer.Option(
66
+ False,
67
+ "--json",
68
+ help="Emit JSON only (no rich output)",
69
+ ),
70
+ ):
71
+ """
72
+ Edit the base component of the domain model.
73
+ """
74
+
75
+ state = get_state(ctx)
76
+
77
+ # --- input validation ---
78
+ if src is None and file is None:
79
+ raise typer.BadParameter("One of --src or --file must be provided")
80
+
81
+ if src is not None and file is not None:
82
+ raise typer.BadParameter("Only one of --src or --file may be provided")
83
+
84
+ if file is not None:
85
+ src = file.read_text()
86
+
87
+ assert src is not None # for type checkers
88
+
89
+ change = DomainModelBaseEdit(new_base_src=src)
90
+
91
+ run_change_and_render(state, change, json_only=json_only)
92
+ state.save()
93
+
94
+ #-----------------------------------------------------------------------------
95
+ # Scenarios
96
+ #-----------------------------------------------------------------------------
97
+ @app.command(name="scenario-add")
98
+ def scenario_add(
99
+ ctx: typer.Context,
100
+ scenario_name: str = typer.Argument(
101
+ ...,
102
+ help="Name of the scenario to add",
103
+ ),
104
+ given: list[str] = typer.Option(
105
+ [],
106
+ "--given",
107
+ help=(
108
+ "State predicate name (repeatable).\n"
109
+ "Examples:\n"
110
+ " --given pred_eq_ten\n"
111
+ " --given pred_gte_ten --given pred_ne_ten"
112
+ ),
113
+ ),
114
+ when: list[str] = typer.Option(
115
+ [],
116
+ "--when",
117
+ help=(
118
+ "Action predicate name (repeatable).\n"
119
+ "Examples:\n"
120
+ " --when act_gt_x\n"
121
+ " --when act_gt_x --when act_lte_x"
122
+ ),
123
+ ),
124
+ then: list[str] = typer.Option(
125
+ [],
126
+ "--then",
127
+ help=(
128
+ "Transition name (repeatable).\n"
129
+ "Examples:\n"
130
+ " --then step1\n"
131
+ " --then step1 --then step2"
132
+ ),
133
+ ),
134
+ given_list: str | None = typer.Option(
135
+ None,
136
+ "--given-list",
137
+ help=(
138
+ "Comma-separated list of state predicates.\n"
139
+ 'Example: --given-list "pred_eq_ten,pred_ne_ten"'
140
+ ),
141
+ ),
142
+ when_list: str | None = typer.Option(
143
+ None,
144
+ "--when-list",
145
+ help=(
146
+ "Comma-separated list of action predicates.\n"
147
+ 'Example: --when-list "act_gt_x,act_lte_x"'
148
+ ),
149
+ ),
150
+ then_list: str | None = typer.Option(
151
+ None,
152
+ "--then-list",
153
+ help=(
154
+ "Comma-separated list of transitions.\n"
155
+ 'Example: --then-list "step1,step2"'
156
+ ),
157
+ ),
158
+ json_only: bool = typer.Option(
159
+ False,
160
+ "--json",
161
+ help="Output the parsed ScenarioAdd as JSON",
162
+ ),
163
+ ) -> None:
164
+
165
+ state = get_state(ctx)
166
+
167
+ def _split_csv(s: str | None) -> list[str]:
168
+ if not s:
169
+ return []
170
+ return [x.strip() for x in s.split(",") if x.strip()]
171
+
172
+ # Merge repeatable flags + csv lists (dedup preserving order)
173
+ def _merge(a: list[str], b: list[str]) -> list[str]:
174
+ return list(dict.fromkeys([*a, *b]))
175
+
176
+ given_all = _merge(given, _split_csv(given_list))
177
+ when_all = _merge(when, _split_csv(when_list))
178
+ then_all = _merge(then, _split_csv(then_list))
179
+
180
+ def _delta_from_add(xs: list[str]) -> ScenarioDelta | None:
181
+ d = ScenarioDelta(add=xs)
182
+ return None if d.is_empty() else d
183
+
184
+ change = ScenarioAdd(
185
+ scenario_name=scenario_name,
186
+ given=_delta_from_add(given_all),
187
+ when=_delta_from_add(when_all),
188
+ then=_delta_from_add(then_all),
189
+ )
190
+
191
+ run_change_and_render(state, change, json_only=json_only)
192
+ state.save()
193
+
194
+
195
+ @app.command(name="scenario-edit", help="Edit an existing scenario by adding/removing predicates and transitions")
196
+ def scenario_edit_cmd(
197
+ ctx: typer.Context,
198
+ scenario_name: str = typer.Argument(
199
+ ...,
200
+ help="Name of the scenario to edit",
201
+ ),
202
+ given: str | None = typer.Option(
203
+ None,
204
+ "--given",
205
+ help=(
206
+ "Delta for GIVEN (state predicates).\n"
207
+ "Formats:\n"
208
+ " '+p1,+p2,-p3' add/remove predicates\n"
209
+ " 'p1,p2' add predicates\n"
210
+ " JSON string or path to JSON file\n"
211
+ "Example: --given '+pred_eq_ten,-pred_lt_ten'"
212
+ ),
213
+ ),
214
+ when: str | None = typer.Option(
215
+ None,
216
+ "--when",
217
+ help=(
218
+ "Delta for WHEN (action predicates).\n"
219
+ "Formats:\n"
220
+ " '+q1,+q2,-q3' add/remove predicates\n"
221
+ " 'q1,q2' add predicates\n"
222
+ " JSON string or path to JSON file\n"
223
+ "Example: --when '+act_gt_x,-act_lte_x'"
224
+ ),
225
+ ),
226
+ then: str | None = typer.Option(
227
+ None,
228
+ "--then",
229
+ help=(
230
+ "Delta for THEN (transition names).\n"
231
+ "Formats:\n"
232
+ " '+t1,+t2,-t3' add/remove transitions\n"
233
+ " 't1,t2' add transitions\n"
234
+ " JSON string or path to JSON file\n"
235
+ "Example: --then '+step1,-step2'"
236
+ ),
237
+ ),
238
+ json_only: bool = typer.Option(
239
+ False,
240
+ "--json",
241
+ help="Output the parsed ScenarioEdit as JSON",
242
+ ),
243
+ ):
244
+
245
+ state = get_state(ctx)
246
+ change = ScenarioEdit(
247
+ scenario_name=scenario_name,
248
+ given=parse_scenario_delta(given),
249
+ when=parse_scenario_delta(when),
250
+ then=parse_scenario_delta(then),
251
+ )
252
+
253
+ run_change_and_render(state, change, json_only=json_only)
254
+ state.save()
255
+
256
+ @app.command(name="scenario-remove", help="Remove a scenario from the current spec/state.")
257
+ def scenario_remove_cmd(
258
+ ctx: typer.Context,
259
+ scenario_name: str = typer.Argument(
260
+ ...,
261
+ help="Name of the scenario to remove (identifier). Example: scenario_1",
262
+ ),
263
+ json_only: bool = typer.Option(
264
+ False,
265
+ "--json",
266
+ help="Output machine-readable JSON (includes change + state summaries + diff).",
267
+ ),
268
+ ) -> None:
269
+ """
270
+ Examples:
271
+
272
+ speclogician scenario remove scenario_1
273
+
274
+ speclogician --state-json /path/to/project scenario remove scenario_1 --json
275
+
276
+ speclogician scenario remove scenario_1 -y
277
+ """
278
+ state = get_state(ctx)
279
+ change = ScenarioRemove(scenario_name=scenario_name)
280
+ run_change_and_render(state, change, json_only=json_only)
281
+ state.save()
282
+
283
+
284
+ #-----------------------------------------------------------------------------
285
+ # Traces (TestTrace and LogTrace)
286
+ #-----------------------------------------------------------------------------
287
+
288
+ trace_app = typer.Typer(help="Trace artifacts (TestTrace, LogTrace).")
289
+ app.add_typer(trace_app, name="trace")
290
+
291
+
292
+ @app.command("test-add")
293
+ def add_test_trace(
294
+ ctx: typer.Context,
295
+ art_id: str = typer.Option(..., "--art-id", help="Artifact ID (uuid string)"),
296
+ name: str = typer.Option(..., "--name", help="Test name (NOT unique)"),
297
+ given: str = typer.Option(..., "--given", help="Concrete state expression, e.g. { x = 1 }"),
298
+ when: Optional[str] = typer.Option(None, "--when", help="Concrete action expression"),
299
+ then: Optional[str] = typer.Option(None, "--then", help="Concrete resulting state expression"),
300
+ filepath: str = typer.Option("", "--filepath", help="Original test filepath"),
301
+ language: Optional[str] = typer.Option(None, "--language", help="Language"),
302
+ contents: Optional[str] = typer.Option(None, "--contents", help="Original test contents"),
303
+ json_only: bool = typer.Option(False, "--json", help="Emit JSON result (no rich output)"),
304
+ ) -> None:
305
+ state = get_state(ctx)
306
+ change = AddTestTrace(
307
+ art_id=art_id,
308
+ name=name,
309
+ given=given,
310
+ when=when,
311
+ then=then,
312
+ filepath=filepath,
313
+ language=language,
314
+ contents=contents,
315
+ )
316
+
317
+ run_change_and_render(state, change, json_only=json_only)
318
+ state.save()
319
+
320
+ @app.command("test-edit")
321
+ def edit_test_trace(
322
+ ctx: typer.Context,
323
+ art_id: str = typer.Argument(..., help="Artifact ID"),
324
+ name: Optional[str] = typer.Option(None, "--name"),
325
+ given: Optional[str] = typer.Option(None, "--given"),
326
+ when: Optional[str] = typer.Option(None, "--when"),
327
+ then: Optional[str] = typer.Option(None, "--then"),
328
+ filepath: Optional[str] = typer.Option(None, "--filepath"),
329
+ language: Optional[str] = typer.Option(None, "--language"),
330
+ contents: Optional[str] = typer.Option(None, "--contents"),
331
+ json_only: bool = typer.Option(False, "--json"),
332
+ ) -> None:
333
+ state = get_state(ctx)
334
+ change = EditTestTrace(
335
+ art_id=art_id,
336
+ name=name,
337
+ given=given,
338
+ when=when,
339
+ then=then,
340
+ filepath=filepath,
341
+ language=language,
342
+ contents=contents,
343
+ )
344
+
345
+ run_change_and_render(state, change, json_only=json_only)
346
+ state.save()
347
+
348
+ @app.command("log-add")
349
+ def add_log_trace(
350
+ ctx: typer.Context,
351
+ art_id: str = typer.Option(..., "--art-id", help="Artifact ID (uuid string)"),
352
+ filename: str = typer.Option(..., "--filename", help="Log filename (NOT unique)"),
353
+ contents: str = typer.Option(..., "--contents", help="Log contents"),
354
+ given: str = typer.Option(..., "--given", help="Concrete state expression"),
355
+ when: Optional[str] = typer.Option(None, "--when", help="Concrete action expression"),
356
+ then: Optional[str] = typer.Option(None, "--then", help="Concrete resulting state expression"),
357
+ json_only: bool = typer.Option(False, "--json"),
358
+ ) -> None:
359
+ state = get_state(ctx)
360
+ change = AddLogTrace(
361
+ art_id=art_id,
362
+ filename=filename,
363
+ contents=contents,
364
+ given=given,
365
+ when=when,
366
+ then=then,
367
+ )
368
+
369
+ run_change_and_render(state, change, json_only=json_only)
370
+ state.save()
371
+
372
+ @app.command("log-edit")
373
+ def edit_log_trace(
374
+ ctx: typer.Context,
375
+ art_id: str = typer.Argument(..., help="Artifact ID"),
376
+ filename: Optional[str] = typer.Option(None, "--filename"),
377
+ contents: Optional[str] = typer.Option(None, "--contents"),
378
+ given: Optional[str] = typer.Option(None, "--given"),
379
+ when: Optional[str] = typer.Option(None, "--when"),
380
+ then: Optional[str] = typer.Option(None, "--then"),
381
+ json_only: bool = typer.Option(False, "--json"),
382
+ ) -> None:
383
+ state = get_state(ctx)
384
+ change = EditLogTrace(
385
+ art_id=art_id,
386
+ filename=filename,
387
+ contents=contents,
388
+ given=given,
389
+ when=when,
390
+ then=then,
391
+ )
392
+ run_change_and_render(state, change, json_only=json_only)
393
+ state.save()
394
+
395
+
396
+ @app.command("trace-remove")
397
+ def remove_trace(
398
+ ctx: typer.Context,
399
+ art_id: str = typer.Argument(..., help="Artifact ID"),
400
+ json_only: bool = typer.Option(False, "--json"),
401
+ ) -> None:
402
+ state = get_state(ctx)
403
+ change = RemoveTraceArtifact(art_id=art_id)
404
+ run_change_and_render(state, change, json_only=json_only)
405
+ state.save()
406
+
407
+
408
+ # --------------------------------------------------------
409
+ # Data artifacts (DocRefs and SrcRefs)
410
+ # --------------------------------------------------------
411
+
412
+ @app.command("add-doc")
413
+ def add_doc(
414
+ ctx: typer.Context,
415
+ art_id: str = typer.Option(..., "--art-id"),
416
+ text: str = typer.Option(..., "--text"),
417
+ meta: Optional[str] = typer.Option(None, "--meta"),
418
+ json_only: bool = typer.Option(False, "--json"),
419
+ ) -> None:
420
+ state = get_state(ctx)
421
+ change = AddDocRef(art_id=art_id, text=text, meta=meta)
422
+ run_change_and_render(state, change, json_only=json_only)
423
+ state.save()
424
+
425
+
426
+ @app.command("edit-doc")
427
+ def edit_doc(
428
+ ctx: typer.Context,
429
+ art_id: str = typer.Argument(...),
430
+ text: Optional[str] = typer.Option(None, "--text"),
431
+ meta: Optional[str] = typer.Option(None, "--meta"),
432
+ json_only: bool = typer.Option(False, "--json"),
433
+ ) -> None:
434
+ state = get_state(ctx)
435
+ change = EditDocRef(art_id=art_id, text=text, meta=meta)
436
+ run_change_and_render(state, change, json_only=json_only)
437
+ state.save()
438
+
439
+
440
+ @app.command("add-src")
441
+ def add_src(
442
+ ctx: typer.Context,
443
+ art_id: str = typer.Option(..., "--art-id"),
444
+ src_code: str = typer.Option(..., "--src-code"),
445
+ language: Optional[str] = typer.Option(None, "--language"),
446
+ file_path: Optional[str] = typer.Option(None, "--file-path"),
447
+ iml_code: Optional[str] = typer.Option(None, "--iml-code"),
448
+ meta: Optional[str] = typer.Option(None, "--meta"),
449
+ json_only: bool = typer.Option(False, "--json"),
450
+ ) -> None:
451
+ state = get_state(ctx)
452
+ change = AddSrcCodeRef(
453
+ art_id=art_id,
454
+ src_code=src_code,
455
+ language=language,
456
+ file_path=file_path,
457
+ iml_code=iml_code,
458
+ meta=meta,
459
+ )
460
+ run_change_and_render(state, change, json_only=json_only)
461
+ state.save()
462
+
463
+
464
+ @app.command("edit-src")
465
+ def edit_src(
466
+ ctx: typer.Context,
467
+ art_id: str = typer.Argument(...),
468
+ src_code: Optional[str] = typer.Option(None, "--src-code"),
469
+ language: Optional[str] = typer.Option(None, "--language"),
470
+ file_path: Optional[str] = typer.Option(None, "--file-path"),
471
+ iml_code: Optional[str] = typer.Option(None, "--iml-code"),
472
+ meta: Optional[str] = typer.Option(None, "--meta"),
473
+ json_only: bool = typer.Option(False, "--json"),
474
+ ) -> None:
475
+ state = get_state(ctx)
476
+ change = EditSrcCodeRef(
477
+ art_id=art_id,
478
+ src_code=src_code,
479
+ language=language,
480
+ file_path=file_path,
481
+ iml_code=iml_code,
482
+ meta=meta,
483
+ )
484
+ run_change_and_render(state, change, json_only=json_only)
485
+ state.save()
486
+
487
+
488
+ @app.command("remove-art")
489
+ def remove_data_art(
490
+ ctx: typer.Context,
491
+ art_id: str = typer.Argument(...),
492
+ json_only: bool = typer.Option(False, "--json"),
493
+ ) -> None:
494
+ state = get_state(ctx)
495
+ change = RemoveDataArtifact(art_id=art_id)
496
+ run_change_and_render(state, change, json_only=json_only)
497
+ state.save()
498
+
499
+
500
+ #-----------------------------------------------------------------------------
501
+ # Scenarios
502
+ #-----------------------------------------------------------------------------
503
+
504
+ @app.command("pred-add")
505
+ def predicate_add(
506
+ ctx: typer.Context,
507
+ pred_type: PredicateType = typer.Option(..., "--pred-type", help="STATE or ACTION"),
508
+ pred_name: str = typer.Option(..., "--pred-name", help="Predicate name"),
509
+ pred_src: str = typer.Option(..., "--pred-src", help="Predicate source code"),
510
+ json_only: bool = typer.Option(False, "--json", help="Emit JSON output"),
511
+ ):
512
+ """
513
+ Add a new predicate to the domain model.
514
+ """
515
+ state = get_state(ctx)
516
+ change = PredicateAdd(
517
+ pred_type=pred_type,
518
+ pred_name=pred_name,
519
+ pred_src=pred_src,
520
+ )
521
+ run_change_and_render(state, change, json_only=json_only)
522
+ state.save()
523
+
524
+
525
+ @app.command("pred-edit")
526
+ def predicate_edit(
527
+ ctx: typer.Context,
528
+ pred_name: str = typer.Option(..., "--pred-name", help="Predicate name"),
529
+ pred_src: str = typer.Option(..., "--pred-src", help="Updated predicate source"),
530
+ json_only: bool = typer.Option(False, "--json", help="Emit JSON output"),
531
+ ):
532
+ """
533
+ Edit an existing predicate.
534
+ """
535
+ state = get_state(ctx)
536
+
537
+ change = PredicateEdit(
538
+ pred_name=pred_name,
539
+ pred_src=pred_src,
540
+ )
541
+ run_change_and_render(state, change, json_only=json_only)
542
+ state.save()
543
+
544
+ @app.command("pred-remove")
545
+ def predicate_remove(
546
+ ctx: typer.Context,
547
+ pred_name: str = typer.Option(..., "--pred-name", help="Predicate name to remove"),
548
+ json_only: bool = typer.Option(False, "--json", help="Emit JSON output"),
549
+ ):
550
+ """
551
+ Remove a predicate from the domain model.
552
+ """
553
+ state = get_state(ctx)
554
+ change = PredicateRemove(pred_name=pred_name)
555
+ run_change_and_render(state, change, json_only=json_only)
556
+ state.save()
557
+
558
+ #-----------------------------------------------------------------------------
559
+ # Transitions
560
+ #-----------------------------------------------------------------------------
561
+
562
+ @app.command("trans-add")
563
+ def transition_add(
564
+ ctx: typer.Context,
565
+ trans_name: str = typer.Option(..., "--trans-name", help="Transition name"),
566
+ trans_src: str = typer.Option(..., "--trans-src", help="Transition source code"),
567
+ json_only: bool = typer.Option(False, "--json", help="Emit JSON output"),
568
+ ):
569
+ """
570
+ Add a new transition function.
571
+ """
572
+ state = get_state(ctx)
573
+ change = TransitionAdd(
574
+ trans_name=trans_name,
575
+ trans_src=trans_src,
576
+ )
577
+ run_change_and_render(state, change, json_only=json_only)
578
+ state.save()
579
+
580
+
581
+ @app.command("trans-edit")
582
+ def transition_edit(
583
+ ctx: typer.Context,
584
+ trans_name: str = typer.Option(..., "--trans-name", help="Transition name"),
585
+ trans_src: str = typer.Option(..., "--trans-src", help="Updated transition source"),
586
+ json_only: bool = typer.Option(False, "--json", help="Emit JSON output"),
587
+ ):
588
+ """
589
+ Edit an existing transition function.
590
+ """
591
+ state = get_state(ctx)
592
+ change = TransitionEdit(
593
+ trans_name=trans_name,
594
+ trans_src=trans_src,
595
+ )
596
+ run_change_and_render(state, change, json_only=json_only)
597
+ state.save()
598
+
599
+ @app.command("trans-remove")
600
+ def transition_remove(
601
+ ctx: typer.Context,
602
+ trans_name: str = typer.Option(..., "--trans-name", help="Transition name to remove"),
603
+ json_only: bool = typer.Option(False, "--json", help="Emit JSON output"),
604
+ ):
605
+ """
606
+ Remove a transition function.
607
+ """
608
+ state = get_state(ctx)
609
+ change = TransitionRemove(trans_name=trans_name)
610
+ run_change_and_render(state, change, json_only=json_only)
611
+ state.save()
612
+
613
+
614
+ #-----------------------------------------------------------------------------
615
+ # Artifact Mapping
616
+ #-----------------------------------------------------------------------------