cmdx 1.1.2 → 1.5.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 (192) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.cursor/prompts/docs.md +4 -1
  4. data/.cursor/prompts/llms.md +20 -0
  5. data/.cursor/prompts/rspec.md +4 -1
  6. data/.cursor/prompts/yardoc.md +3 -2
  7. data/.cursor/rules/cursor-instructions.mdc +56 -1
  8. data/.irbrc +6 -0
  9. data/.rubocop.yml +29 -18
  10. data/CHANGELOG.md +5 -133
  11. data/LLM.md +3317 -0
  12. data/README.md +68 -44
  13. data/docs/attributes/coercions.md +162 -0
  14. data/docs/attributes/defaults.md +90 -0
  15. data/docs/attributes/definitions.md +281 -0
  16. data/docs/attributes/naming.md +78 -0
  17. data/docs/attributes/validations.md +309 -0
  18. data/docs/basics/chain.md +56 -249
  19. data/docs/basics/context.md +56 -289
  20. data/docs/basics/execution.md +114 -0
  21. data/docs/basics/setup.md +37 -334
  22. data/docs/callbacks.md +89 -467
  23. data/docs/deprecation.md +91 -174
  24. data/docs/getting_started.md +212 -202
  25. data/docs/internationalization.md +11 -647
  26. data/docs/interruptions/exceptions.md +23 -198
  27. data/docs/interruptions/faults.md +71 -151
  28. data/docs/interruptions/halt.md +109 -186
  29. data/docs/logging.md +44 -256
  30. data/docs/middlewares.md +113 -426
  31. data/docs/outcomes/result.md +81 -228
  32. data/docs/outcomes/states.md +33 -221
  33. data/docs/outcomes/statuses.md +21 -311
  34. data/docs/tips_and_tricks.md +120 -70
  35. data/docs/workflows.md +99 -283
  36. data/lib/cmdx/.DS_Store +0 -0
  37. data/lib/cmdx/attribute.rb +229 -0
  38. data/lib/cmdx/attribute_registry.rb +94 -0
  39. data/lib/cmdx/attribute_value.rb +193 -0
  40. data/lib/cmdx/callback_registry.rb +69 -77
  41. data/lib/cmdx/chain.rb +56 -73
  42. data/lib/cmdx/coercion_registry.rb +52 -68
  43. data/lib/cmdx/coercions/array.rb +19 -18
  44. data/lib/cmdx/coercions/big_decimal.rb +20 -24
  45. data/lib/cmdx/coercions/boolean.rb +26 -25
  46. data/lib/cmdx/coercions/complex.rb +21 -22
  47. data/lib/cmdx/coercions/date.rb +25 -23
  48. data/lib/cmdx/coercions/date_time.rb +24 -25
  49. data/lib/cmdx/coercions/float.rb +25 -22
  50. data/lib/cmdx/coercions/hash.rb +31 -32
  51. data/lib/cmdx/coercions/integer.rb +30 -24
  52. data/lib/cmdx/coercions/rational.rb +29 -24
  53. data/lib/cmdx/coercions/string.rb +19 -22
  54. data/lib/cmdx/coercions/symbol.rb +37 -0
  55. data/lib/cmdx/coercions/time.rb +26 -25
  56. data/lib/cmdx/configuration.rb +49 -108
  57. data/lib/cmdx/context.rb +222 -44
  58. data/lib/cmdx/deprecator.rb +61 -0
  59. data/lib/cmdx/errors.rb +42 -252
  60. data/lib/cmdx/exceptions.rb +39 -0
  61. data/lib/cmdx/faults.rb +78 -39
  62. data/lib/cmdx/freezer.rb +51 -0
  63. data/lib/cmdx/identifier.rb +30 -0
  64. data/lib/cmdx/locale.rb +52 -0
  65. data/lib/cmdx/log_formatters/json.rb +21 -22
  66. data/lib/cmdx/log_formatters/key_value.rb +20 -22
  67. data/lib/cmdx/log_formatters/line.rb +15 -22
  68. data/lib/cmdx/log_formatters/logstash.rb +22 -23
  69. data/lib/cmdx/log_formatters/raw.rb +16 -22
  70. data/lib/cmdx/middleware_registry.rb +70 -74
  71. data/lib/cmdx/middlewares/correlate.rb +90 -54
  72. data/lib/cmdx/middlewares/runtime.rb +58 -0
  73. data/lib/cmdx/middlewares/timeout.rb +48 -68
  74. data/lib/cmdx/railtie.rb +12 -45
  75. data/lib/cmdx/result.rb +229 -314
  76. data/lib/cmdx/task.rb +194 -366
  77. data/lib/cmdx/utils/call.rb +49 -0
  78. data/lib/cmdx/utils/condition.rb +71 -0
  79. data/lib/cmdx/utils/format.rb +61 -0
  80. data/lib/cmdx/validator_registry.rb +63 -72
  81. data/lib/cmdx/validators/exclusion.rb +38 -67
  82. data/lib/cmdx/validators/format.rb +48 -49
  83. data/lib/cmdx/validators/inclusion.rb +43 -74
  84. data/lib/cmdx/validators/length.rb +91 -154
  85. data/lib/cmdx/validators/numeric.rb +87 -162
  86. data/lib/cmdx/validators/presence.rb +37 -50
  87. data/lib/cmdx/version.rb +1 -1
  88. data/lib/cmdx/worker.rb +178 -0
  89. data/lib/cmdx/workflow.rb +85 -81
  90. data/lib/cmdx.rb +19 -13
  91. data/lib/generators/cmdx/install_generator.rb +14 -13
  92. data/lib/generators/cmdx/task_generator.rb +25 -50
  93. data/lib/generators/cmdx/templates/install.rb +11 -46
  94. data/lib/generators/cmdx/templates/task.rb.tt +3 -2
  95. data/lib/locales/en.yml +18 -4
  96. data/src/cmdx-logo.png +0 -0
  97. metadata +32 -116
  98. data/docs/ai_prompts.md +0 -393
  99. data/docs/basics/call.md +0 -317
  100. data/docs/configuration.md +0 -344
  101. data/docs/parameters/coercions.md +0 -396
  102. data/docs/parameters/defaults.md +0 -335
  103. data/docs/parameters/definitions.md +0 -446
  104. data/docs/parameters/namespacing.md +0 -378
  105. data/docs/parameters/validations.md +0 -405
  106. data/docs/testing.md +0 -553
  107. data/lib/cmdx/callback.rb +0 -53
  108. data/lib/cmdx/chain_inspector.rb +0 -56
  109. data/lib/cmdx/chain_serializer.rb +0 -63
  110. data/lib/cmdx/coercion.rb +0 -57
  111. data/lib/cmdx/coercions/virtual.rb +0 -29
  112. data/lib/cmdx/core_ext/hash.rb +0 -83
  113. data/lib/cmdx/core_ext/module.rb +0 -98
  114. data/lib/cmdx/core_ext/object.rb +0 -125
  115. data/lib/cmdx/correlator.rb +0 -122
  116. data/lib/cmdx/error.rb +0 -67
  117. data/lib/cmdx/fault.rb +0 -140
  118. data/lib/cmdx/immutator.rb +0 -52
  119. data/lib/cmdx/lazy_struct.rb +0 -246
  120. data/lib/cmdx/log_formatters/pretty_json.rb +0 -40
  121. data/lib/cmdx/log_formatters/pretty_key_value.rb +0 -38
  122. data/lib/cmdx/log_formatters/pretty_line.rb +0 -41
  123. data/lib/cmdx/logger.rb +0 -49
  124. data/lib/cmdx/logger_ansi.rb +0 -68
  125. data/lib/cmdx/logger_serializer.rb +0 -116
  126. data/lib/cmdx/middleware.rb +0 -70
  127. data/lib/cmdx/parameter.rb +0 -312
  128. data/lib/cmdx/parameter_evaluator.rb +0 -231
  129. data/lib/cmdx/parameter_inspector.rb +0 -66
  130. data/lib/cmdx/parameter_registry.rb +0 -106
  131. data/lib/cmdx/parameter_serializer.rb +0 -59
  132. data/lib/cmdx/result_ansi.rb +0 -71
  133. data/lib/cmdx/result_inspector.rb +0 -71
  134. data/lib/cmdx/result_logger.rb +0 -59
  135. data/lib/cmdx/result_serializer.rb +0 -104
  136. data/lib/cmdx/rspec/matchers.rb +0 -28
  137. data/lib/cmdx/rspec/result_matchers/be_executed.rb +0 -42
  138. data/lib/cmdx/rspec/result_matchers/be_failed_task.rb +0 -94
  139. data/lib/cmdx/rspec/result_matchers/be_skipped_task.rb +0 -94
  140. data/lib/cmdx/rspec/result_matchers/be_state_matchers.rb +0 -59
  141. data/lib/cmdx/rspec/result_matchers/be_status_matchers.rb +0 -57
  142. data/lib/cmdx/rspec/result_matchers/be_successful_task.rb +0 -87
  143. data/lib/cmdx/rspec/result_matchers/have_bad_outcome.rb +0 -51
  144. data/lib/cmdx/rspec/result_matchers/have_caused_failure.rb +0 -58
  145. data/lib/cmdx/rspec/result_matchers/have_chain_index.rb +0 -59
  146. data/lib/cmdx/rspec/result_matchers/have_context.rb +0 -86
  147. data/lib/cmdx/rspec/result_matchers/have_empty_metadata.rb +0 -54
  148. data/lib/cmdx/rspec/result_matchers/have_good_outcome.rb +0 -52
  149. data/lib/cmdx/rspec/result_matchers/have_metadata.rb +0 -114
  150. data/lib/cmdx/rspec/result_matchers/have_preserved_context.rb +0 -66
  151. data/lib/cmdx/rspec/result_matchers/have_received_thrown_failure.rb +0 -64
  152. data/lib/cmdx/rspec/result_matchers/have_runtime.rb +0 -78
  153. data/lib/cmdx/rspec/result_matchers/have_thrown_failure.rb +0 -76
  154. data/lib/cmdx/rspec/task_matchers/be_well_formed_task.rb +0 -62
  155. data/lib/cmdx/rspec/task_matchers/have_callback.rb +0 -85
  156. data/lib/cmdx/rspec/task_matchers/have_cmd_setting.rb +0 -68
  157. data/lib/cmdx/rspec/task_matchers/have_executed_callbacks.rb +0 -92
  158. data/lib/cmdx/rspec/task_matchers/have_middleware.rb +0 -46
  159. data/lib/cmdx/rspec/task_matchers/have_parameter.rb +0 -181
  160. data/lib/cmdx/task_deprecator.rb +0 -58
  161. data/lib/cmdx/task_processor.rb +0 -246
  162. data/lib/cmdx/task_serializer.rb +0 -57
  163. data/lib/cmdx/utils/ansi_color.rb +0 -73
  164. data/lib/cmdx/utils/log_timestamp.rb +0 -36
  165. data/lib/cmdx/utils/monotonic_runtime.rb +0 -34
  166. data/lib/cmdx/utils/name_affix.rb +0 -52
  167. data/lib/cmdx/validator.rb +0 -57
  168. data/lib/generators/cmdx/templates/workflow.rb.tt +0 -7
  169. data/lib/generators/cmdx/workflow_generator.rb +0 -84
  170. data/lib/locales/ar.yml +0 -35
  171. data/lib/locales/cs.yml +0 -35
  172. data/lib/locales/da.yml +0 -35
  173. data/lib/locales/de.yml +0 -35
  174. data/lib/locales/el.yml +0 -35
  175. data/lib/locales/es.yml +0 -35
  176. data/lib/locales/fi.yml +0 -35
  177. data/lib/locales/fr.yml +0 -35
  178. data/lib/locales/he.yml +0 -35
  179. data/lib/locales/hi.yml +0 -35
  180. data/lib/locales/it.yml +0 -35
  181. data/lib/locales/ja.yml +0 -35
  182. data/lib/locales/ko.yml +0 -35
  183. data/lib/locales/nl.yml +0 -35
  184. data/lib/locales/no.yml +0 -35
  185. data/lib/locales/pl.yml +0 -35
  186. data/lib/locales/pt.yml +0 -35
  187. data/lib/locales/ru.yml +0 -35
  188. data/lib/locales/sv.yml +0 -35
  189. data/lib/locales/th.yml +0 -35
  190. data/lib/locales/tr.yml +0 -35
  191. data/lib/locales/vi.yml +0 -35
  192. data/lib/locales/zh.yml +0 -35
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmdx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
@@ -23,20 +23,6 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: '0'
26
- - !ruby/object:Gem::Dependency
27
- name: i18n
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
26
  - !ruby/object:Gem::Dependency
41
27
  name: logger
42
28
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +66,7 @@ dependencies:
80
66
  - !ruby/object:Gem::Version
81
67
  version: '0'
82
68
  - !ruby/object:Gem::Dependency
83
- name: ostruct
69
+ name: i18n
84
70
  requirement: !ruby/object:Gem::Requirement
85
71
  requirements:
86
72
  - - ">="
@@ -177,8 +163,9 @@ dependencies:
177
163
  - - ">="
178
164
  - !ruby/object:Gem::Version
179
165
  version: '0'
180
- description: Simplify complex business logic using a tiny command (service) object
181
- framework.
166
+ description: A framework that provides structured command execution, attribute management,
167
+ validation, coercion, callbacks, and workflow orchestration for building maintainable
168
+ business processes.
182
169
  email:
183
170
  - drexed@users.noreply.github.com
184
171
  executables: []
@@ -187,24 +174,30 @@ extra_rdoc_files: []
187
174
  files:
188
175
  - ".DS_Store"
189
176
  - ".cursor/prompts/docs.md"
177
+ - ".cursor/prompts/llms.md"
190
178
  - ".cursor/prompts/rspec.md"
191
179
  - ".cursor/prompts/yardoc.md"
192
180
  - ".cursor/rules/cursor-instructions.mdc"
181
+ - ".irbrc"
193
182
  - ".rspec"
194
183
  - ".rubocop.yml"
195
184
  - ".ruby-version"
196
185
  - CHANGELOG.md
197
186
  - CODE_OF_CONDUCT.md
198
187
  - LICENSE.txt
188
+ - LLM.md
199
189
  - README.md
200
190
  - Rakefile
201
- - docs/ai_prompts.md
202
- - docs/basics/call.md
191
+ - docs/attributes/coercions.md
192
+ - docs/attributes/defaults.md
193
+ - docs/attributes/definitions.md
194
+ - docs/attributes/naming.md
195
+ - docs/attributes/validations.md
203
196
  - docs/basics/chain.md
204
197
  - docs/basics/context.md
198
+ - docs/basics/execution.md
205
199
  - docs/basics/setup.md
206
200
  - docs/callbacks.md
207
- - docs/configuration.md
208
201
  - docs/deprecation.md
209
202
  - docs/getting_started.md
210
203
  - docs/internationalization.md
@@ -216,22 +209,15 @@ files:
216
209
  - docs/outcomes/result.md
217
210
  - docs/outcomes/states.md
218
211
  - docs/outcomes/statuses.md
219
- - docs/parameters/coercions.md
220
- - docs/parameters/defaults.md
221
- - docs/parameters/definitions.md
222
- - docs/parameters/namespacing.md
223
- - docs/parameters/validations.md
224
- - docs/testing.md
225
212
  - docs/tips_and_tricks.md
226
213
  - docs/workflows.md
227
214
  - lib/cmdx.rb
228
215
  - lib/cmdx/.DS_Store
229
- - lib/cmdx/callback.rb
216
+ - lib/cmdx/attribute.rb
217
+ - lib/cmdx/attribute_registry.rb
218
+ - lib/cmdx/attribute_value.rb
230
219
  - lib/cmdx/callback_registry.rb
231
220
  - lib/cmdx/chain.rb
232
- - lib/cmdx/chain_inspector.rb
233
- - lib/cmdx/chain_serializer.rb
234
- - lib/cmdx/coercion.rb
235
221
  - lib/cmdx/coercion_registry.rb
236
222
  - lib/cmdx/coercions/array.rb
237
223
  - lib/cmdx/coercions/big_decimal.rb
@@ -244,79 +230,32 @@ files:
244
230
  - lib/cmdx/coercions/integer.rb
245
231
  - lib/cmdx/coercions/rational.rb
246
232
  - lib/cmdx/coercions/string.rb
233
+ - lib/cmdx/coercions/symbol.rb
247
234
  - lib/cmdx/coercions/time.rb
248
- - lib/cmdx/coercions/virtual.rb
249
235
  - lib/cmdx/configuration.rb
250
236
  - lib/cmdx/context.rb
251
- - lib/cmdx/core_ext/hash.rb
252
- - lib/cmdx/core_ext/module.rb
253
- - lib/cmdx/core_ext/object.rb
254
- - lib/cmdx/correlator.rb
255
- - lib/cmdx/error.rb
237
+ - lib/cmdx/deprecator.rb
256
238
  - lib/cmdx/errors.rb
257
- - lib/cmdx/fault.rb
239
+ - lib/cmdx/exceptions.rb
258
240
  - lib/cmdx/faults.rb
259
- - lib/cmdx/immutator.rb
260
- - lib/cmdx/lazy_struct.rb
241
+ - lib/cmdx/freezer.rb
242
+ - lib/cmdx/identifier.rb
243
+ - lib/cmdx/locale.rb
261
244
  - lib/cmdx/log_formatters/json.rb
262
245
  - lib/cmdx/log_formatters/key_value.rb
263
246
  - lib/cmdx/log_formatters/line.rb
264
247
  - lib/cmdx/log_formatters/logstash.rb
265
- - lib/cmdx/log_formatters/pretty_json.rb
266
- - lib/cmdx/log_formatters/pretty_key_value.rb
267
- - lib/cmdx/log_formatters/pretty_line.rb
268
248
  - lib/cmdx/log_formatters/raw.rb
269
- - lib/cmdx/logger.rb
270
- - lib/cmdx/logger_ansi.rb
271
- - lib/cmdx/logger_serializer.rb
272
- - lib/cmdx/middleware.rb
273
249
  - lib/cmdx/middleware_registry.rb
274
250
  - lib/cmdx/middlewares/correlate.rb
251
+ - lib/cmdx/middlewares/runtime.rb
275
252
  - lib/cmdx/middlewares/timeout.rb
276
- - lib/cmdx/parameter.rb
277
- - lib/cmdx/parameter_evaluator.rb
278
- - lib/cmdx/parameter_inspector.rb
279
- - lib/cmdx/parameter_registry.rb
280
- - lib/cmdx/parameter_serializer.rb
281
253
  - lib/cmdx/railtie.rb
282
254
  - lib/cmdx/result.rb
283
- - lib/cmdx/result_ansi.rb
284
- - lib/cmdx/result_inspector.rb
285
- - lib/cmdx/result_logger.rb
286
- - lib/cmdx/result_serializer.rb
287
- - lib/cmdx/rspec/matchers.rb
288
- - lib/cmdx/rspec/result_matchers/be_executed.rb
289
- - lib/cmdx/rspec/result_matchers/be_failed_task.rb
290
- - lib/cmdx/rspec/result_matchers/be_skipped_task.rb
291
- - lib/cmdx/rspec/result_matchers/be_state_matchers.rb
292
- - lib/cmdx/rspec/result_matchers/be_status_matchers.rb
293
- - lib/cmdx/rspec/result_matchers/be_successful_task.rb
294
- - lib/cmdx/rspec/result_matchers/have_bad_outcome.rb
295
- - lib/cmdx/rspec/result_matchers/have_caused_failure.rb
296
- - lib/cmdx/rspec/result_matchers/have_chain_index.rb
297
- - lib/cmdx/rspec/result_matchers/have_context.rb
298
- - lib/cmdx/rspec/result_matchers/have_empty_metadata.rb
299
- - lib/cmdx/rspec/result_matchers/have_good_outcome.rb
300
- - lib/cmdx/rspec/result_matchers/have_metadata.rb
301
- - lib/cmdx/rspec/result_matchers/have_preserved_context.rb
302
- - lib/cmdx/rspec/result_matchers/have_received_thrown_failure.rb
303
- - lib/cmdx/rspec/result_matchers/have_runtime.rb
304
- - lib/cmdx/rspec/result_matchers/have_thrown_failure.rb
305
- - lib/cmdx/rspec/task_matchers/be_well_formed_task.rb
306
- - lib/cmdx/rspec/task_matchers/have_callback.rb
307
- - lib/cmdx/rspec/task_matchers/have_cmd_setting.rb
308
- - lib/cmdx/rspec/task_matchers/have_executed_callbacks.rb
309
- - lib/cmdx/rspec/task_matchers/have_middleware.rb
310
- - lib/cmdx/rspec/task_matchers/have_parameter.rb
311
255
  - lib/cmdx/task.rb
312
- - lib/cmdx/task_deprecator.rb
313
- - lib/cmdx/task_processor.rb
314
- - lib/cmdx/task_serializer.rb
315
- - lib/cmdx/utils/ansi_color.rb
316
- - lib/cmdx/utils/log_timestamp.rb
317
- - lib/cmdx/utils/monotonic_runtime.rb
318
- - lib/cmdx/utils/name_affix.rb
319
- - lib/cmdx/validator.rb
256
+ - lib/cmdx/utils/call.rb
257
+ - lib/cmdx/utils/condition.rb
258
+ - lib/cmdx/utils/format.rb
320
259
  - lib/cmdx/validator_registry.rb
321
260
  - lib/cmdx/validators/exclusion.rb
322
261
  - lib/cmdx/validators/format.rb
@@ -325,44 +264,21 @@ files:
325
264
  - lib/cmdx/validators/numeric.rb
326
265
  - lib/cmdx/validators/presence.rb
327
266
  - lib/cmdx/version.rb
267
+ - lib/cmdx/worker.rb
328
268
  - lib/cmdx/workflow.rb
329
269
  - lib/generators/cmdx/install_generator.rb
330
270
  - lib/generators/cmdx/task_generator.rb
331
271
  - lib/generators/cmdx/templates/install.rb
332
272
  - lib/generators/cmdx/templates/task.rb.tt
333
- - lib/generators/cmdx/templates/workflow.rb.tt
334
- - lib/generators/cmdx/workflow_generator.rb
335
- - lib/locales/ar.yml
336
- - lib/locales/cs.yml
337
- - lib/locales/da.yml
338
- - lib/locales/de.yml
339
- - lib/locales/el.yml
340
273
  - lib/locales/en.yml
341
- - lib/locales/es.yml
342
- - lib/locales/fi.yml
343
- - lib/locales/fr.yml
344
- - lib/locales/he.yml
345
- - lib/locales/hi.yml
346
- - lib/locales/it.yml
347
- - lib/locales/ja.yml
348
- - lib/locales/ko.yml
349
- - lib/locales/nl.yml
350
- - lib/locales/no.yml
351
- - lib/locales/pl.yml
352
- - lib/locales/pt.yml
353
- - lib/locales/ru.yml
354
- - lib/locales/sv.yml
355
- - lib/locales/th.yml
356
- - lib/locales/tr.yml
357
- - lib/locales/vi.yml
358
- - lib/locales/zh.yml
274
+ - src/cmdx-logo.png
359
275
  homepage: https://github.com/drexed/cmdx
360
276
  licenses:
361
277
  - MIT
362
278
  metadata:
363
279
  homepage_uri: https://github.com/drexed/cmdx
364
280
  source_code_uri: https://github.com/drexed/cmdx
365
- changelog_uri: https://github.com/drexed/cmdx/CHANGELOG.md
281
+ changelog_uri: https://github.com/drexed/cmdx/blob/main/CHANGELOG.md
366
282
  bug_tracker_uri: https://github.com/drexed/cmdx/issues
367
283
  documentation_uri: https://github.com/drexed/cmdx/blob/main/README.md
368
284
  rubygems_mfa_required: 'true'
@@ -380,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
380
296
  - !ruby/object:Gem::Version
381
297
  version: '0'
382
298
  requirements: []
383
- rubygems_version: 3.7.0
299
+ rubygems_version: 3.7.1
384
300
  specification_version: 4
385
- summary: Command (aka service) objects with intent
301
+ summary: CMDx is a framework for building maintainable business processes.
386
302
  test_files: []
data/docs/ai_prompts.md DELETED
@@ -1,393 +0,0 @@
1
- # AI Prompt Templates
2
-
3
- AI prompt templates provide structured guidance for generating production-ready CMDx Task and Workflow objects. These templates ensure consistent code quality, proper framework usage, and comprehensive testing coverage when working with AI assistants.
4
-
5
- ## Table of Contents
6
-
7
- - [TLDR](#tldr)
8
- - [Framework Context Template](#framework-context-template)
9
- - [Task Generation Templates](#task-generation-templates)
10
- - [Workflow Generation Templates](#workflow-generation-templates)
11
- - [Testing Templates](#testing-templates)
12
- - [Error Handling and Edge Cases](#error-handling-and-edge-cases)
13
- - [Best Practices](#best-practices)
14
-
15
- ## TLDR
16
-
17
- > [!NOTE]
18
- > Pre-written prompts help AI assistants generate well-structured CMDx code with proper validations, error handling, and comprehensive tests.
19
-
20
- ```ruby
21
- # Task generation pattern
22
- "Create a CMDx task that [ACTION] with parameters [PARAMS] and validation [RULES]"
23
-
24
- # Workflow orchestration pattern
25
- "Create a CMDx workflow that orchestrates [PROCESS] with steps [TASKS] and error handling [STRATEGY]"
26
-
27
- # Testing pattern
28
- "Generate RSpec tests with CMDx matchers for success, failure, and edge cases"
29
- ```
30
-
31
- ## Framework Context Template
32
-
33
- > [!IMPORTANT]
34
- > Always include this context when working with AI assistants to ensure proper CMDx code generation and adherence to framework conventions.
35
-
36
- ```
37
- I'm working with CMDx, a Ruby framework for designing and executing business logic within service/command objects.
38
-
39
- CORE CONCEPTS:
40
- - Tasks inherit from CMDx::Task with business logic in `call` method
41
- - Workflows inherit from CMDx::Workflow to orchestrate multiple tasks
42
- - Parameters support type coercion, validation, defaults, and nesting
43
- - Results contain status (success/failed/skipped), state, context, metadata
44
- - Callbacks execute at lifecycle points (before_validation, on_success, etc.)
45
- - Middlewares wrap execution (authentication, logging, timeouts, correlation)
46
- - Chains link tasks with shared context and failure propagation
47
-
48
- CODING STANDARDS:
49
- - Ruby 3.4+ syntax and conventions
50
- - snake_case methods/variables, CamelCase classes
51
- - Double quotes for strings, proper indentation
52
- - YARD documentation with @param, @return, @example
53
- - RSpec tests using CMDx custom matchers
54
- - Task naming: VerbNounTask (ProcessOrderTask)
55
- - Workflow naming: NounVerbWorkflow (OrderProcessingWorkflow)
56
-
57
- REQUIREMENTS:
58
- - Production-ready code with comprehensive error handling
59
- - Parameter validation with meaningful error messages
60
- - Proper context management and metadata usage
61
- - Full test coverage including edge cases and failure scenarios
62
- ```
63
-
64
- ## Task Generation Templates
65
-
66
- ### Standard Task Template
67
-
68
- ```
69
- Create a CMDx task that [SPECIFIC_ACTION] with these requirements:
70
-
71
- PARAMETERS:
72
- - [name]: [type] - [description] - [required/optional] - [validation_rules]
73
- - [name]: [type] - [description] - [default_value] - [constraints]
74
-
75
- BUSINESS LOGIC:
76
- 1. [Validation step with error conditions]
77
- 2. [Core processing with success criteria]
78
- 3. [Side effects and external calls]
79
- 4. [Context updates and metadata]
80
-
81
- ERROR HANDLING:
82
- - [Specific error condition] → [failure response with metadata]
83
- - [Edge case] → [appropriate handling strategy]
84
-
85
- CONTEXT UPDATES:
86
- - [key]: [description of data added]
87
- - [key]: [metadata or tracking information]
88
-
89
- OUTPUT:
90
- - Complete task implementation with YARD docs
91
- - RSpec test file with success/failure/edge cases
92
- - Parameter validation tests
93
- - Integration tests for external dependencies
94
- ```
95
-
96
- ### Practical Example
97
-
98
- ```
99
- Create a CMDx task that processes user profile updates with these requirements:
100
-
101
- PARAMETERS:
102
- - user_id: integer - User identifier - required - positive, exists in database
103
- - profile_data: hash - Profile information - required - non-empty hash
104
- - send_notification: boolean - Email update notification - optional - defaults to true
105
- - audit_reason: string - Reason for update - optional - 3-255 characters when provided
106
-
107
- BUSINESS LOGIC:
108
- 1. Validate user exists and is active (error if not found or inactive)
109
- 2. Sanitize and validate profile data fields (reject invalid formats)
110
- 3. Update user profile in database (handle transaction failures)
111
- 4. Send notification email if enabled (log failures, don't fail task)
112
- 5. Create audit log entry with before/after values
113
-
114
- ERROR HANDLING:
115
- - User not found → failed with metadata {error_code: 'USER_NOT_FOUND'}
116
- - Invalid profile data → failed with metadata {invalid_fields: [...]}
117
- - Database failure → failed with metadata {error_code: 'DB_ERROR', retryable: true}
118
-
119
- CONTEXT UPDATES:
120
- - updated_user: User object with new profile data
121
- - profile_changes: Hash with {field: [old_value, new_value]}
122
- - notification_sent: Boolean indicating email delivery status
123
- ```
124
-
125
- ## Workflow Generation Templates
126
-
127
- ### Standard Workflow Template
128
-
129
- ```
130
- Create a CMDx workflow that orchestrates [BUSINESS_PROCESS] with these requirements:
131
-
132
- WORKFLOW STEPS:
133
- 1. [TaskName]: [Purpose and responsibilities]
134
- 2. [TaskName]: [Dependencies and data requirements]
135
- 3. [TaskName]: [Conditional execution criteria]
136
-
137
- DATA FLOW:
138
- - [Context key]: Flows from [Task A] to [Task B] for [purpose]
139
- - [Shared state]: Available to [tasks] for [coordination]
140
-
141
- ERROR STRATEGY:
142
- - [Task failure] → [recovery action or compensation]
143
- - [Critical failure] → [rollback requirements]
144
- - [Partial failure] → [continuation strategy]
145
-
146
- CONDITIONAL LOGIC:
147
- - Skip [task] when [condition] is [value]
148
- - Execute [alternative_task] if [criteria] met
149
- - Branch execution based on [context_data]
150
-
151
- OUTPUT:
152
- - Complete workflow with task orchestration
153
- - Individual task implementations
154
- - Integration tests covering success/failure paths
155
- - Error handling and rollback mechanisms
156
- ```
157
-
158
- ### Practical Example
159
-
160
- ```
161
- Create a CMDx workflow that orchestrates user account deactivation with these requirements:
162
-
163
- WORKFLOW STEPS:
164
- 1. ValidateDeactivationRequestTask: Verify user permissions and business rules
165
- 2. BackupUserDataTask: Archive user data before deactivation
166
- 3. DeactivateAccountTask: Update account status and revoke access
167
- 4. NotifyStakeholdersTask: Send notifications to relevant parties
168
- 5. UpdateAnalyticsTask: Record deactivation metrics
169
-
170
- DATA FLOW:
171
- - user_id: Required input, flows through all tasks
172
- - deactivation_reason: Used by validation, backup, and analytics
173
- - backup_reference: Created by backup, used by analytics
174
- - stakeholder_list: Determined by validation, used by notification
175
-
176
- ERROR STRATEGY:
177
- - Validation failure → halt workflow, return validation errors
178
- - Backup failure → critical error, do not proceed with deactivation
179
- - Account deactivation failure → rollback backup, restore previous state
180
- - Notification failure → log error, continue workflow (non-critical)
181
- - Analytics failure → log error, workflow succeeds (tracking only)
182
-
183
- CONDITIONAL LOGIC:
184
- - Skip stakeholder notification if user is internal test account
185
- - Execute priority backup for premium users
186
- - Send different notifications based on deactivation reason
187
- ```
188
-
189
- ## Testing Templates
190
-
191
- ### Task Testing Template
192
-
193
- > [!TIP]
194
- > Use CMDx custom matchers for cleaner, more expressive tests that follow framework conventions.
195
-
196
- ```
197
- Generate comprehensive RSpec tests for [TASK_NAME] including:
198
-
199
- PARAMETER VALIDATION:
200
- - Required parameters missing → proper error messages
201
- - Type coercion edge cases → successful conversion or clear failures
202
- - Validation rules → boundary conditions and invalid inputs
203
- - Default values → proper application and override behavior
204
-
205
- EXECUTION SCENARIOS:
206
- - Happy path → successful execution with expected context updates
207
- - Business rule violations → appropriate failure states with metadata
208
- - External service failures → error handling and retry logic
209
- - Edge cases → boundary conditions and unusual inputs
210
-
211
- INTEGRATION POINTS:
212
- - Database operations → transaction handling and rollback
213
- - External APIs → network failures and response validation
214
- - File system → permissions and storage errors
215
- - Email/messaging → delivery failures and formatting
216
-
217
- Use CMDx matchers:
218
- - expect(result).to be_successful_task
219
- - expect(result).to be_failed_task.with_metadata(hash_including(...))
220
- - expect(result).to have_context(key: value)
221
- - expect(TaskClass).to have_parameter(:name).with_type(:integer)
222
- ```
223
-
224
- ### Workflow Testing Template
225
-
226
- ```
227
- Generate comprehensive RSpec tests for [WORKFLOW_NAME] including:
228
-
229
- INTEGRATION SCENARIOS:
230
- - Complete success path → all tasks execute with proper data flow
231
- - Early failure → workflow halts at appropriate point
232
- - Mid-workflow failure → proper error propagation and cleanup
233
- - Recovery scenarios → compensation and rollback behavior
234
-
235
- TASK COORDINATION:
236
- - Context passing → data flows correctly between tasks
237
- - Conditional execution → tasks skip/execute based on conditions
238
- - Parallel execution → concurrent tasks complete properly
239
- - Sequential dependencies → tasks wait for predecessors
240
-
241
- ERROR PROPAGATION:
242
- - Individual task failures → workflow response and metadata
243
- - Critical vs non-critical failures → appropriate handling
244
- - Rollback mechanisms → state restoration and cleanup
245
- - Error aggregation → multiple failure consolidation
246
-
247
- EDGE CASES:
248
- - Empty context → proper initialization and defaults
249
- - Malformed inputs → validation and sanitization
250
- - Resource constraints → timeout and resource management
251
- - Concurrent execution → race conditions and locking
252
- ```
253
-
254
- ## Error Handling and Edge Cases
255
-
256
- > [!WARNING]
257
- > Always include comprehensive error handling in your prompts to ensure robust, production-ready code generation.
258
-
259
- ### Common Error Scenarios
260
-
261
- ```ruby
262
- # Parameter validation failures
263
- expect(result).to be_failed_task
264
- .with_metadata(
265
- reason: "user_id is required",
266
- messages: { user_id: ["can't be blank"] }
267
- )
268
-
269
- # Business rule violations
270
- expect(result).to be_failed_task
271
- .with_metadata(
272
- error_code: "INSUFFICIENT_BALANCE",
273
- retryable: false,
274
- balance: current_balance,
275
- required: requested_amount
276
- )
277
-
278
- # External service failures
279
- expect(result).to be_failed_task
280
- .with_metadata(
281
- error_code: "SERVICE_UNAVAILABLE",
282
- retryable: true,
283
- retry_after: 30,
284
- service: "payment_processor"
285
- )
286
- ```
287
-
288
- ### Edge Case Coverage
289
-
290
- Include these scenarios in your prompts:
291
-
292
- | Scenario | Test Coverage | Expected Behavior |
293
- |----------|---------------|-------------------|
294
- | Empty inputs | Nil, empty strings, empty arrays | Validation errors or defaults |
295
- | Boundary values | Min/max limits, zero, negative | Proper validation and coercion |
296
- | Malformed data | Invalid JSON, corrupt files | Clear error messages |
297
- | Resource limits | Memory, timeout, rate limits | Graceful degradation |
298
- | Concurrent access | Race conditions, locks | Proper synchronization |
299
-
300
- ## Best Practices
301
-
302
- ### 1. Specific Requirements
303
-
304
- > [!NOTE]
305
- > Provide detailed, actionable requirements rather than vague descriptions to get better code generation.
306
-
307
- **Effective:**
308
- ```
309
- Create a task that validates payment information including:
310
- - Credit card number validation using Luhn algorithm
311
- - Expiry date validation (not expired, within 10 years)
312
- - CVV validation (3 digits for Visa/MC, 4 for Amex)
313
- - Amount validation (positive, max $10,000, 2 decimal places)
314
- - Return structured validation errors with field-specific messages
315
- ```
316
-
317
- **Ineffective:**
318
- ```
319
- Create a payment validation task
320
- ```
321
-
322
- ### 2. Complete Context Flow
323
-
324
- **Effective:**
325
- ```
326
- Task receives user_id and order_data, validates inventory, processes payment,
327
- updates order status, and adds to context:
328
- - order: Order object with updated status
329
- - payment_reference: Payment processor transaction ID
330
- - inventory_reserved: Array of reserved item IDs
331
- - processing_time: Duration in milliseconds
332
- ```
333
-
334
- **Ineffective:**
335
- ```
336
- Process an order and update context
337
- ```
338
-
339
- ### 3. Explicit Error Conditions
340
-
341
- **Effective:**
342
- ```
343
- Handle these specific errors:
344
- - Invalid card → failed with {error_code: 'INVALID_CARD', field: 'number'}
345
- - Expired card → failed with {error_code: 'EXPIRED', retry_date: Date}
346
- - Declined → failed with {error_code: 'DECLINED', retryable: false}
347
- - Timeout → failed with {error_code: 'TIMEOUT', retryable: true, delay: 30}
348
- ```
349
-
350
- **Ineffective:**
351
- ```
352
- Handle payment errors appropriately
353
- ```
354
-
355
- ### 4. Framework-Specific Patterns
356
-
357
- **Effective:**
358
- ```
359
- Follow CMDx conventions:
360
- - Use present tense task names (ProcessPaymentTask, not PaymentProcessor)
361
- - Include detailed metadata for failures
362
- - Use callbacks for cross-cutting concerns (audit, logging)
363
- - Leverage parameter coercion for input flexibility
364
- - Return rich context updates for downstream tasks
365
- ```
366
-
367
- **Ineffective:**
368
- ```
369
- Use good Ruby practices
370
- ```
371
-
372
- ### 5. Comprehensive Test Coverage
373
-
374
- **Effective:**
375
- ```
376
- Generate tests including:
377
- - All parameter combinations and edge cases
378
- - Success scenarios with various input types
379
- - Each failure mode with proper error metadata
380
- - Integration with external services (mocked)
381
- - Performance characteristics and timeouts
382
- - Callback execution and order
383
- ```
384
-
385
- **Ineffective:**
386
- ```
387
- Include basic tests
388
- ```
389
-
390
- ---
391
-
392
- - **Prev:** [Deprecation](deprecation.md)
393
- - **Next:** [Tips and Tricks](tips_and_tricks.md)