@imolko/ultra-agent 0.1.0-beta

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 (239) hide show
  1. package/README.md +93 -0
  2. package/bin/cli.js +2 -0
  3. package/dist-node/bin.d.ts +2 -0
  4. package/dist-node/bin.d.ts.map +1 -0
  5. package/dist-node/bin.js +5 -0
  6. package/dist-node/bin.js.map +1 -0
  7. package/dist-node/cli.d.ts +41 -0
  8. package/dist-node/cli.d.ts.map +1 -0
  9. package/dist-node/cli.js +170 -0
  10. package/dist-node/cli.js.map +1 -0
  11. package/dist-node/index.d.ts +14 -0
  12. package/dist-node/index.d.ts.map +1 -0
  13. package/dist-node/index.js +40 -0
  14. package/dist-node/index.js.map +1 -0
  15. package/dist-node/init-lint.d.ts +43 -0
  16. package/dist-node/init-lint.d.ts.map +1 -0
  17. package/dist-node/init-lint.js +84 -0
  18. package/dist-node/init-lint.js.map +1 -0
  19. package/dist-node/manifest.d.ts +33 -0
  20. package/dist-node/manifest.d.ts.map +1 -0
  21. package/dist-node/manifest.js +59 -0
  22. package/dist-node/manifest.js.map +1 -0
  23. package/dist-node/materializer.d.ts +52 -0
  24. package/dist-node/materializer.d.ts.map +1 -0
  25. package/dist-node/materializer.js +194 -0
  26. package/dist-node/materializer.js.map +1 -0
  27. package/dist-node/package-root.d.ts +5 -0
  28. package/dist-node/package-root.d.ts.map +1 -0
  29. package/dist-node/package-root.js +17 -0
  30. package/dist-node/package-root.js.map +1 -0
  31. package/dist-node/payload.d.ts +22 -0
  32. package/dist-node/payload.d.ts.map +1 -0
  33. package/dist-node/payload.js +49 -0
  34. package/dist-node/payload.js.map +1 -0
  35. package/dist-node/pointer-hub.d.ts +22 -0
  36. package/dist-node/pointer-hub.d.ts.map +1 -0
  37. package/dist-node/pointer-hub.js +50 -0
  38. package/dist-node/pointer-hub.js.map +1 -0
  39. package/dist-node/publication.cli.d.ts +9 -0
  40. package/dist-node/publication.cli.d.ts.map +1 -0
  41. package/dist-node/publication.cli.js +17 -0
  42. package/dist-node/publication.cli.js.map +1 -0
  43. package/dist-node/publication.d.ts +23 -0
  44. package/dist-node/publication.d.ts.map +1 -0
  45. package/dist-node/publication.js +47 -0
  46. package/dist-node/publication.js.map +1 -0
  47. package/dist-node/reconcile.cli.d.ts +11 -0
  48. package/dist-node/reconcile.cli.d.ts.map +1 -0
  49. package/dist-node/reconcile.cli.js +39 -0
  50. package/dist-node/reconcile.cli.js.map +1 -0
  51. package/dist-node/reconcile.d.ts +30 -0
  52. package/dist-node/reconcile.d.ts.map +1 -0
  53. package/dist-node/reconcile.js +51 -0
  54. package/dist-node/reconcile.js.map +1 -0
  55. package/dist-node/ship/prompts/fix.md +22 -0
  56. package/dist-node/ship/prompts/implement.md +34 -0
  57. package/dist-node/ship/prompts/review.md +28 -0
  58. package/dist-node/ship/ship.agent.d.ts +22 -0
  59. package/dist-node/ship/ship.agent.d.ts.map +1 -0
  60. package/dist-node/ship/ship.agent.js +142 -0
  61. package/dist-node/ship/ship.agent.js.map +1 -0
  62. package/dist-node/ship/ship.args.d.ts +15 -0
  63. package/dist-node/ship/ship.args.d.ts.map +1 -0
  64. package/dist-node/ship/ship.args.js +93 -0
  65. package/dist-node/ship/ship.args.js.map +1 -0
  66. package/dist-node/ship/ship.context.d.ts +12 -0
  67. package/dist-node/ship/ship.context.d.ts.map +1 -0
  68. package/dist-node/ship/ship.context.js +3 -0
  69. package/dist-node/ship/ship.context.js.map +1 -0
  70. package/dist-node/ship/ship.d.ts +4 -0
  71. package/dist-node/ship/ship.d.ts.map +1 -0
  72. package/dist-node/ship/ship.js +221 -0
  73. package/dist-node/ship/ship.js.map +1 -0
  74. package/dist-node/ship/ship.mr.d.ts +9 -0
  75. package/dist-node/ship/ship.mr.d.ts.map +1 -0
  76. package/dist-node/ship/ship.mr.js +171 -0
  77. package/dist-node/ship/ship.mr.js.map +1 -0
  78. package/dist-node/ship/ship.output.d.ts +9 -0
  79. package/dist-node/ship/ship.output.d.ts.map +1 -0
  80. package/dist-node/ship/ship.output.js +21 -0
  81. package/dist-node/ship/ship.output.js.map +1 -0
  82. package/dist-node/ship/ship.tracker.d.ts +37 -0
  83. package/dist-node/ship/ship.tracker.d.ts.map +1 -0
  84. package/dist-node/ship/ship.tracker.js +220 -0
  85. package/dist-node/ship/ship.tracker.js.map +1 -0
  86. package/dist-node/version.cli.d.ts +9 -0
  87. package/dist-node/version.cli.d.ts.map +1 -0
  88. package/dist-node/version.cli.js +30 -0
  89. package/dist-node/version.cli.js.map +1 -0
  90. package/dist-node/version.d.ts +24 -0
  91. package/dist-node/version.d.ts.map +1 -0
  92. package/dist-node/version.js +76 -0
  93. package/dist-node/version.js.map +1 -0
  94. package/docs/adr/ADR-0000-proceso-y-formato-de-adrs.md +115 -0
  95. package/docs/adr/foundational/A-001-clean-architecture-4-capas.md +88 -0
  96. package/docs/adr/foundational/A-002-cqrs-semantico.md +58 -0
  97. package/docs/adr/foundational/A-003-tdd.md +97 -0
  98. package/docs/adr/foundational/A-005-either-return-custom-methods.md +80 -0
  99. package/docs/adr/foundational/A-006-feature-completion-criteria.md +47 -0
  100. package/docs/adr/foundational/A-007-data-contract-fail-fast.md +109 -0
  101. package/docs/adr/foundational/A-008-bounded-context-decomposition.md +130 -0
  102. package/docs/adr/foundational/A-009-use-case-taxonomy.md +99 -0
  103. package/docs/adr/foundational/A-010-propiedad-emision-eventos-dominio.md +95 -0
  104. package/docs/adr/foundational/A-011-characterization-first-refactoring.md +90 -0
  105. package/docs/adr/foundational/A-012-helm-mecanismo-primario-despliegue.md +67 -0
  106. package/docs/adr/foundational/A-013-contrato-settings-unica-fuente-configuracion.md +74 -0
  107. package/docs/adr/foundational/A-014-generacion-artefactos-despliegue-desde-contrato-settings.md +75 -0
  108. package/docs/adr/foundational/A-015-cloudevents-estandar-eventos.md +85 -0
  109. package/docs/adr/foundational/A-016-cicd-gitlab-pipeline-raiz-pipelines-modulares.md +92 -0
  110. package/docs/adr/foundational/A-017-taxonomia-repositorios-librerias-sistemas.md +93 -0
  111. package/docs/adr/foundational/A-018-practicas-build-imagenes-docker.md +85 -0
  112. package/docs/adr/foundational/A-019-convenciones-autoria-helm-charts.md +97 -0
  113. package/docs/adr/foundational/A-020-entorno-desarrollo-estandarizado-devcontainer.md +58 -0
  114. package/docs/adr/foundational/A-022-formato-reporte-tests-ctrf.md +55 -0
  115. package/docs/adr/foundational/A-023-composicion-bloques-prompt-agentes.md +65 -0
  116. package/docs/adr/foundational/A-024-features-slices-verticales-portables.md +41 -0
  117. package/docs/adr/foundational/A-025-anatomia-mecanica-feature-puertos-adaptadores-drivers.md +104 -0
  118. package/docs/adr/foundational/A-026-infraestructura-compartida.md +44 -0
  119. package/docs/adr/foundational/A-027-patron-wiring-entry-point.md +67 -0
  120. package/docs/adr/foundational/A-029-verbos-intencion-metodos-lado-negocio.md +54 -0
  121. package/docs/adr/foundational/A-030-global-development-tooling.md +52 -0
  122. package/docs/adr/foundational/A-031-ubiquitous-language.md +64 -0
  123. package/docs/adr/foundational/A-032-domain-artifact-documentation-format.md +128 -0
  124. package/docs/adr/foundational/A-033-estandar-mensajes-commit.md +127 -0
  125. package/docs/adr/foundational/A-034-canonical-skill-set.md +64 -0
  126. package/docs/adr/foundational/A-035-captura-ideas-reanclaje-candies.md +51 -0
  127. package/docs/adr/foundational/A-036-adopcion-wayfinder-ortogonalidad-labels.md +37 -0
  128. package/docs/adr/foundational/A-037-formalizacion-taxonomia-labels.md +98 -0
  129. package/docs/adr/foundational/A-038-issues-referencian-skills-nombre.md +54 -0
  130. package/docs/adr/foundational/A-039-pipeline-ship-issues-hijos-spec.md +64 -0
  131. package/docs/adr/foundational/A-040-punteros-configuracion-repo-skills.md +44 -0
  132. package/docs/adr/foundational/A-041-estrategia-de-ramas.md +45 -0
  133. package/docs/adr/foundational/A-042-formato-documentos-issue-tracker.md +78 -0
  134. package/docs/adr/foundational/A-043-vocabulario-etiquetas-adrs.md +42 -0
  135. package/docs/adr/foundational/A-044-composicion-funcional-procesos-operaciones.md +44 -0
  136. package/docs/adr/foundational/A-045-guardrails-aplicables-no-directrices.md +48 -0
  137. package/docs/adr/foundational/A-046-metricas-de-forma-y-legibilidad-del-codigo.md +50 -0
  138. package/docs/adr/foundational/A-047-dependencias-explicitas-sin-globales-ambientales.md +40 -0
  139. package/docs/adr/foundational/A-048-cobertura-minima-codigo.md +39 -0
  140. package/docs/adr/foundational/A-049-materializacion-bucle-guardrails-extension-nativa-pi.md +49 -0
  141. package/docs/adr/foundational/A-050-el-caso-de-uso-pide-al-dominio-no-lee-su-representacion.md +50 -0
  142. package/docs/adr/foundational/A-051-orden-imports-por-distancia.md +47 -0
  143. package/docs/adr/foundational/A-052-distribucion-metodologia-paquete-versionado.md +42 -0
  144. package/docs/adr/foundational/A-053-errores-compartidos-entre-features-dos-hogares-por-capa.md +43 -0
  145. package/docs/adr/foundational/A-054-contrato-costura-driver-port-raw-data-canal-error.md +65 -0
  146. package/docs/adr/foundational/index.md +98 -0
  147. package/docs/adr/index.md +19 -0
  148. package/docs/adr/python/P-001-dependencias-por-feature-fastapi-depends.md +63 -0
  149. package/docs/adr/python/P-002-inyeccion-token-por-request-sin-persistirlo.md +35 -0
  150. package/docs/adr/python/P-003-sqlalchemy-async-connection-pooling.md +59 -0
  151. package/docs/adr/python/P-004-serializer-json-custom-modelos-pydantic.md +47 -0
  152. package/docs/adr/python/P-005-patrones-pitfalls-nicegui.md +148 -0
  153. package/docs/adr/python/P-006-convenciones-pytest.md +96 -0
  154. package/docs/adr/python/P-007-ci-python-alineacion-poetry-version-unica.md +55 -0
  155. package/docs/adr/python/P-008-empaquetado-infraestructura-compartida-por-tecnologia.md +38 -0
  156. package/docs/adr/python/index.md +14 -0
  157. package/docs/adr/typescript/T-001-ddd-artifact-validation-zod-primitives.md +136 -0
  158. package/docs/adr/typescript/T-002-test-documentation-jsdoc.md +133 -0
  159. package/docs/adr/typescript/T-003-readme-formatting-domain-artifacts.md +51 -0
  160. package/docs/adr/typescript/T-005-input-optionality-use-case-not-entity.md +130 -0
  161. package/docs/adr/typescript/T-006-small-enums-inlined-zod-regex.md +77 -0
  162. package/docs/adr/typescript/T-007-controller-input-zod-schema.md +79 -0
  163. package/docs/adr/typescript/T-008-expressive-use-case-pipe.md +207 -0
  164. package/docs/adr/typescript/T-009-mdx-brace-escaping.md +80 -0
  165. package/docs/adr/typescript/T-010-stack-tooling-typescript-dominio.md +53 -0
  166. package/docs/adr/typescript/T-011-ultra-reporter-herramienta-canonica-documentacion.md +52 -0
  167. package/docs/adr/typescript/T-012-npm-workspaces-estructura-monorepo-clean-architecture.md +54 -0
  168. package/docs/adr/typescript/T-013-definicion-eventos-versionados-ultra-ddd.md +45 -0
  169. package/docs/adr/typescript/T-014-publicacion-distribucion-librerias-npm-semver.md +53 -0
  170. package/docs/adr/typescript/T-015-method-placement-definition.md +35 -0
  171. package/docs/adr/typescript/T-016-contrato-settings-zod.md +34 -0
  172. package/docs/adr/typescript/T-017-characterization-tests-golden-files.md +39 -0
  173. package/docs/adr/typescript/T-018-procedencia-campos-frontmatter.md +55 -0
  174. package/docs/adr/typescript/T-019-ultra-generator-herramienta-canonica-generacion.md +35 -0
  175. package/docs/adr/typescript/T-020-ultra-settings-herramienta-canonica-exportacion-despliegue.md +36 -0
  176. package/docs/adr/typescript/T-021-pipe-flujo-datos-operadores-semantica-contexto-inmutable.md +105 -0
  177. package/docs/adr/typescript/T-022-construction-is-execution-single-boundary.md +112 -0
  178. package/docs/adr/typescript/T-023-registry-cli-declara-dependencias-reales.md +84 -0
  179. package/docs/adr/typescript/T-024-paquete-ultra-agent-manifiesto-pi-peers-cli.md +39 -0
  180. package/docs/adr/typescript/T-025-publicacion-npm-trusted-publishing-procedencia.md +59 -0
  181. package/docs/adr/typescript/index.md +30 -0
  182. package/eslint/index.mjs +721 -0
  183. package/package.json +94 -0
  184. package/pi/extensions/handoff/README.md +92 -0
  185. package/pi/extensions/handoff/handoff-prompt.txt +9 -0
  186. package/pi/extensions/handoff/index.ts +296 -0
  187. package/pi/extensions/handoff/package.json +12 -0
  188. package/pi/extensions/qa-guardrail/README.md +108 -0
  189. package/pi/extensions/qa-guardrail/adapters/cli.ts +100 -0
  190. package/pi/extensions/qa-guardrail/adapters/eslint.ts +90 -0
  191. package/pi/extensions/qa-guardrail/adapters/registry.ts +45 -0
  192. package/pi/extensions/qa-guardrail/baseline.ts +74 -0
  193. package/pi/extensions/qa-guardrail/cerco.ts +134 -0
  194. package/pi/extensions/qa-guardrail/check.ts +185 -0
  195. package/pi/extensions/qa-guardrail/config.ts +189 -0
  196. package/pi/extensions/qa-guardrail/delta.ts +52 -0
  197. package/pi/extensions/qa-guardrail/feedback.ts +26 -0
  198. package/pi/extensions/qa-guardrail/index.ts +311 -0
  199. package/pi/extensions/qa-guardrail/nstop.ts +82 -0
  200. package/pi/extensions/qa-guardrail/package.json +12 -0
  201. package/pi/extensions/qa-guardrail/selection.ts +98 -0
  202. package/pi/extensions/qa-guardrail/types.ts +64 -0
  203. package/scripts/copy-assets.sh +10 -0
  204. package/scripts/reconcile-tags.sh +94 -0
  205. package/scripts/release-beta.sh +64 -0
  206. package/scripts/release-build.sh +53 -0
  207. package/scripts/release.sh +51 -0
  208. package/scripts/verify-adr-consistency.py +217 -0
  209. package/skills/code-review/SKILL.md +66 -0
  210. package/skills/codebase-design/SKILL.md +46 -0
  211. package/skills/configure-repo/SKILL.md +33 -0
  212. package/skills/diagnose-bug/SKILL.md +63 -0
  213. package/skills/domain-modeling/SKILL.md +56 -0
  214. package/skills/grill-me/SKILL.md +34 -0
  215. package/skills/i-have-an-idea/SKILL.md +166 -0
  216. package/skills/implement/SKILL.md +22 -0
  217. package/skills/research/SKILL.md +17 -0
  218. package/skills/ship/SKILL.md +26 -0
  219. package/skills/spike/SKILL.md +27 -0
  220. package/skills/tdd/SKILL.md +68 -0
  221. package/skills/tdd/references/deep-modules.md +53 -0
  222. package/skills/tdd/references/interface-design.md +74 -0
  223. package/skills/tdd/references/mocking.md +80 -0
  224. package/skills/tdd/references/refactoring.md +49 -0
  225. package/skills/tdd/references/tests.md +184 -0
  226. package/skills/to-specs/SKILL.md +141 -0
  227. package/skills/to-tasks/SKILL.md +143 -0
  228. package/skills/triage/SKILL.md +73 -0
  229. package/skills/ultra-generator/SKILL.md +263 -0
  230. package/skills/ultra-generator/references/aggregate-root.md +149 -0
  231. package/skills/ultra-generator/references/domain-event.md +174 -0
  232. package/skills/ultra-generator/references/entity.md +133 -0
  233. package/skills/ultra-generator/references/service.md +92 -0
  234. package/skills/ultra-generator/references/value-object.md +135 -0
  235. package/skills/wayfinder/SKILL.md +201 -0
  236. package/skills/workflow/SKILL.md +31 -0
  237. package/skills/writing-for-agents/SKILL-MECHANICS.md +32 -0
  238. package/skills/writing-for-agents/SKILL.md +86 -0
  239. package/skills/writing-for-agents/references/adrs.md +19 -0
@@ -0,0 +1,174 @@
1
+ # Working with a Domain Event
2
+
3
+ ## Files Generated
4
+
5
+ | File | Purpose |
6
+ |------|---------|
7
+ | `event.ts` | Main class with `@RegisterEvent` decorator + `DomainEventFactory` |
8
+ | `definition.ts` | `EventDefinitionPayload` — static event template |
9
+ | `shape-history.ts` | Shape evolution definition (initial + evolution[]) |
10
+ | `shape-v1.ts` | Shape v1.0.0 conditions (Zod schema for event data) |
11
+ | `shape-v1-sample.ts` | Sample data for v1.0.0 |
12
+ | `payload.ts` | Payload type (re-exported from ultra-ddd) |
13
+ | `index.ts` | Barrel exports |
14
+ | `README.md` | Frontmatter metadata + narrative documentation |
15
+ | `event.spec.ts` | Test file |
16
+
17
+ ## What to Customize
18
+
19
+ ### `definition.ts` — Event Definition
20
+
21
+ The `EventDefinitionPayload` defines all static properties of the event.
22
+ The `securityToken` must be replaced before production deployment.
23
+
24
+ - [ ] Replace `securityToken` with a real secret before production
25
+ - [ ] Verify `emitterApp` matches your application
26
+ - [ ] Verify `eventOwner` matches your organization
27
+
28
+ ### `shape-v1.ts` — Data Schema
29
+
30
+ The Zod schema validates the `data` field of event occurrences.
31
+ Each property maps to a domain concept.
32
+
33
+ **Auto-generated imports**: The generator attempts to resolve imports for
34
+ value-object, entity, and aggregate-root types from sibling directories.
35
+ Types that cannot be resolved at generation time are emitted with TODO placeholders.
36
+
37
+ - [ ] Replace TODO placeholder imports with real imports for referenced domain types
38
+ ```typescript
39
+ // TODO: Import StockMovementId from its domain directory
40
+ // Example: import { StockMovementId } from '../stock-movement-id/value-object';
41
+ const StockMovementId = { rules: () => z.any() }; // placeholder — replace with real import
42
+ ```
43
+ - [ ] Add `.refine()` or `.superRefine()` for custom data validation rules
44
+ - [ ] Verify all domain types referenced in the schema exist and are properly imported
45
+
46
+ ### `shape-history.ts` — Shape Evolution
47
+
48
+ The `ShapeEvolution` tracks all data schema versions. The initial version is v1.0.0.
49
+
50
+ **When adding a new data version:**
51
+ 1. Create `shape-v2.ts` with the new conditions
52
+ 2. Create `shape-v2-sample.ts` with sample data
53
+ 3. Add an entry to `evolution[]`:
54
+ ```typescript
55
+ evolution: [
56
+ {
57
+ shape: { version: '2.0.0' as const, conditions: SHAPE_V2_0_0, sampleData: SAMPLE_DATA_V2_0_0 },
58
+ migrate: (data) => { /* transform v1 data to v2 */ },
59
+ },
60
+ ],
61
+ ```
62
+ 4. Update the `LastShapeVersion` type to the newest version:
63
+ ```typescript
64
+ export type LastShapeVersion = '2.0.0';
65
+ ```
66
+
67
+ **Important**: Never remove old shape versions — they are needed to hydrate historical events.
68
+
69
+ - [ ] Add new shape version files when evolving the data schema
70
+ - [ ] Implement the `migrate` function for each evolution step
71
+ - [ ] Update `LastShapeVersion` type
72
+
73
+ ### `event.spec.ts` — Tests
74
+
75
+ Two tests are generated: one for valid input (green start) and one for invalid input.
76
+
77
+ - [ ] The valid-input test should pass (green)
78
+ - [ ] Write additional failing tests for domain-specific invalid data (red → green)
79
+ - [ ] Add test for `hydrate()` — restoring from a serialized CloudEvent:
80
+ ```typescript
81
+ it('hidratar desde cloud event firmado', () => {
82
+ const event = StockMovementCreated.produce(validPayload).getValue();
83
+ const signed = event.getCloudEventSigned().getValue();
84
+ const hydrated = StockMovementCreated.hydrate(signed).getValue();
85
+ expect(hydrated.getPayload()).toEqual(event.getPayload());
86
+ });
87
+ ```
88
+ - [ ] Add test for `getCloudEventSigned()` — CloudEvent serialization produces valid signed output
89
+
90
+ ### `README.md` — Documentation
91
+
92
+ Rich documentation rendered by ultra-reporter.
93
+
94
+ - [ ] Fill Purpose / Propósito section — what does this event represent?
95
+ - [ ] Document Rules / Reglas — what invariants does the event data enforce?
96
+ - [ ] Add Usage Examples / Ejemplos de uso
97
+ - [ ] Update Mermaid diagram in Relationships / Relaciones with real artifact connections
98
+
99
+ ## What Not to Touch
100
+
101
+ | File | Reason |
102
+ |------|--------|
103
+ | `index.ts` | Barrel exports — regenerated on scaffold updates |
104
+ | `payload.ts` | Re-export from ultra-ddd — managed automatically |
105
+
106
+ ## Shape Evolution
107
+
108
+ Domain events use ShapeEvolution to version the `data` field schema.
109
+ Each version has:
110
+
111
+ - **conditions**: Zod schema defining the data shape for that version
112
+ - **sampleData**: Example data used by ultra-reporter and tests
113
+
114
+ The `LastShapeVersion` type in `shape-history.ts` tracks the current version
115
+ for type-narrowing when accessing occurrence data:
116
+
117
+ ```typescript
118
+ const data = event.getOcurrenceData<StockMovementCreatedV1>();
119
+ ```
120
+
121
+ ## Testing
122
+
123
+ ### TDD Cycle
124
+
125
+ Domain event validation follows the red-green-refactor loop:
126
+
127
+ 1. **Red**: Write a failing test for invalid data
128
+ 2. **Green**: Add the validation rule to `shape-v1.ts`
129
+ 3. **Refactor**: Clean up while keeping tests green
130
+
131
+ ### Example
132
+
133
+ ```typescript
134
+ // Test: movementId must not be empty
135
+ it('rechazar movementId vacio', () => {
136
+ const payload: Payload = {
137
+ context: {
138
+ instance: 'test-instance',
139
+ tenantId: '00000000-0000-0000-0000-000000000001',
140
+ schemaRegistryUrl: 'https://schema.example.dev',
141
+ emitterDomain: 'example',
142
+ },
143
+ ocurrence: {
144
+ id: '00000000-0000-0000-0000-000000000002',
145
+ ocurredAt: '2026-01-01T00:00:00.000Z',
146
+ publishedAt: '2026-01-01T00:00:00.000Z',
147
+ aggregateId: 'stock-movement-001',
148
+ dataSchemaVersion: '1.0.0',
149
+ data: { movementId: '', type: 'INBOUND', timestamp: '2026-01-01T00:00:00.000Z' },
150
+ },
151
+ };
152
+ const result = StockMovementCreated.produce(payload);
153
+ expect(result.isValid()).toBe(false);
154
+ });
155
+ ```
156
+
157
+ ### `hydrate()` and `getCloudEventSigned()`
158
+
159
+ Test round-trip serialization to ensure events can be persisted and restored:
160
+
161
+ ```typescript
162
+ it('serializar y deserializar cloud event', () => {
163
+ const event = StockMovementCreated.produce(validPayload).getValue();
164
+ const signed = event.getCloudEventSigned().getValue();
165
+ const hydrated = StockMovementCreated.hydrate(signed).getValue();
166
+ expect(hydrated.getPayload()).toEqual(event.getPayload());
167
+ });
168
+ ```
169
+
170
+ ## Integration with ultra-reporter
171
+
172
+ The `@RegisterEvent` decorator registers the event with the domain directory.
173
+ ultra-reporter discovers registered events and generates documentation including
174
+ the data schema and sample data from the shape history.
@@ -0,0 +1,133 @@
1
+ # Working with an Entity
2
+
3
+ ## Files Generated
4
+
5
+ | File | Purpose |
6
+ |------|---------|
7
+ | `entity.ts` | Main class with `@RegisterEntity` decorator |
8
+ | `definition.ts` | Validation, serialization, and identity logic |
9
+ | `props.ts` | Internal state interface |
10
+ | `conditions.ts` | Zod validation rules |
11
+ | `primitive.ts` | Public read shape (exposed to application layer) |
12
+ | `payload.ts` | Serialization format for reconstruction |
13
+ | `index.ts` | Barrel exports |
14
+ | `errors/index.ts` | Domain error types |
15
+ | `README.md` | Frontmatter metadata + narrative documentation |
16
+ | `entity.spec.ts` | Test file |
17
+
18
+ ## What to Customize
19
+
20
+ ### `props.ts` — Internal State
21
+
22
+ The `Props` interface defines the internal representation of this entity.
23
+ Entities have an identity (`id: Uuid`) that is managed automatically.
24
+
25
+ **Checklist:**
26
+ - [ ] Verify property types match your domain model
27
+ - [ ] Update or add property descriptions in JSDoc
28
+ - [ ] Ensure all domain concepts are represented
29
+
30
+ ### `conditions.ts` — Validation Rules
31
+
32
+ Zod validation schema that guards construction. Every entity must be
33
+ created in a valid state — these rules enforce that.
34
+
35
+ **Checklist:**
36
+ - [ ] Review each validation rule
37
+ - [ ] Add custom refinements for domain-specific constraints
38
+ - [ ] Ensure the `id` condition is present (auto-added for entities)
39
+
40
+ ### `primitive.ts` — Public API Shape
41
+
42
+ Defines what the application layer can read from this entity.
43
+ This is the "read model" — it should not expose internal details.
44
+
45
+ **Checklist:**
46
+ - [ ] Verify the public shape includes all necessary fields
47
+ - [ ] Ensure internal-only fields are excluded
48
+
49
+ ### `definition.ts` — Identity & Serialization Logic
50
+
51
+ Contains `getPrimitive()` and `getPayload()`. Entities have identity management
52
+ via `Uuid` — the base class handles this.
53
+
54
+ **Checklist:**
55
+ - [ ] Review serialization — does it properly map Props to Primitive?
56
+ - [ ] Review deserialization — does Payload reconstruct correctly?
57
+ - [ ] Add custom methods for domain operations
58
+
59
+ ### `errors/` — Domain Errors
60
+
61
+ Domain-specific errors that this entity can produce.
62
+
63
+ **Checklist:**
64
+ - [ ] Define custom error classes for each failure mode
65
+ - [ ] Register errors in `errors/index.ts`
66
+
67
+ ### `entity.spec.ts` — Tests
68
+
69
+ The template includes a valid-creation test that verifies the entity is created
70
+ correctly and its primitive output matches expectations. It also includes
71
+ placeholder tests for error cases.
72
+
73
+ **Checklist:**
74
+ - [ ] The valid-creation test should already pass (green)
75
+ - [ ] Add a failing test for an error case (red)
76
+ - [ ] Implement the validation to make it pass (green)
77
+ - [ ] Refactor if needed
78
+ - [ ] Add tests for identity-related edge cases
79
+
80
+ ### `README.md` — Narrative Documentation
81
+
82
+ Rich documentation rendered by ultra-reporter on the Docusaurus site.
83
+
84
+ **Checklist:**
85
+ - [ ] Fill the `Purpose` section — what is this entity for?
86
+ - [ ] Document `Domain Rules` — what invariants does it enforce?
87
+ - [ ] Add `Usage Examples` — how is it created and used?
88
+ - [ ] Document `Relationships` — to other domain artifacts
89
+
90
+ ## What Not to Touch
91
+
92
+ These files are managed by scaffolding. Avoid direct edits:
93
+
94
+ | File | Reason |
95
+ |------|--------|
96
+ | `index.ts` | Barrel exports — regenerated on scaffold updates |
97
+ | `payload.ts` | Type derived from conditions — managed automatically |
98
+ | `errors/index.ts` | Error re-exports — managed automatically |
99
+
100
+ ## Validation & Errors
101
+
102
+ Entities use Zod for validation via `conditions.ts`. The `id` condition is auto-added
103
+ as a `Uuid` type. Custom domain errors can be added via Zod refinements.
104
+
105
+ ## Testing
106
+
107
+ ### TDD Cycle
108
+
109
+ Entities follow the red-green-refactor TDD loop:
110
+
111
+ 1. **Red**: Write a failing test for an invalid input or identity scenario
112
+ 2. **Green**: Add the validation rule or domain logic to make it pass
113
+ 3. **Refactor**: Clean up while keeping tests green
114
+
115
+ ### Example
116
+
117
+ ```ts
118
+ // Test: entity creation with valid input
119
+ it('crear UserEntity valida', async () => {
120
+ const payload: Payload = { name: 'John', email: 'john@example.com' };
121
+ const result = UserEntity.create(payload);
122
+ expect(result).toBeValid();
123
+ const entity = result.getValue();
124
+ expect(entity).toBeInstanceOf(UserEntity);
125
+ });
126
+
127
+ // Test: invalid email rejected
128
+ it('rechazar email inválido', async () => {
129
+ const payload: Payload = { name: 'John', email: 'not-an-email' };
130
+ const result = UserEntity.create(payload);
131
+ expect(result).toBeError();
132
+ });
133
+ ```
@@ -0,0 +1,92 @@
1
+ # Working with a Service
2
+
3
+ ## Files Generated
4
+
5
+ | File | Purpose |
6
+ |------|---------|
7
+ | `service.ts` | Main class with `@RegisterService` decorator |
8
+ | `definition.ts` | Service execution logic |
9
+ | `service-input.ts` | Input type for the service |
10
+ | `service-output.ts` | Output type for the service |
11
+ | `index.ts` | Barrel exports |
12
+ | `README.md` | Frontmatter metadata + narrative documentation |
13
+ | `service.spec.ts` | Test file |
14
+
15
+ ## What to Customize
16
+
17
+ ### `service-input.ts` — Input Type
18
+
19
+ Defines the input that this service accepts. This is the contract
20
+ that callers must fulfill.
21
+
22
+ **Checklist:**
23
+ - [ ] Define the shape of input data
24
+ - [ ] Add JSDoc descriptions for each field
25
+ - [ ] Consider validation — should the input be validated before reaching the service?
26
+
27
+ ### `service-output.ts` — Output Type
28
+
29
+ Defines the output that this service produces.
30
+
31
+ **Checklist:**
32
+ - [ ] Define the shape of output data
33
+ - [ ] Add JSDoc descriptions for each field
34
+
35
+ ### `definition.ts` — Execution Logic
36
+
37
+ Contains the `execute()` method — the core business logic of the service.
38
+
39
+ **Checklist:**
40
+ - [ ] Implement the `execute()` method with domain logic
41
+ - [ ] Add helper methods as needed
42
+ - [ ] Consider error handling — what errors can this service produce?
43
+ - [ ] Add JSDoc to document the execution contract
44
+
45
+ ### `service.spec.ts` — Tests
46
+
47
+ The template includes a placeholder test.
48
+
49
+ **Checklist:**
50
+ - [ ] Write a test for the happy path
51
+ - [ ] Write tests for error scenarios
52
+ - [ ] Write tests for edge cases
53
+ - [ ] Follow the red-green-refactor TDD loop
54
+
55
+ ### `README.md` — Narrative Documentation
56
+
57
+ Rich documentation rendered by ultra-reporter on the Docusaurus site.
58
+
59
+ **Checklist:**
60
+ - [ ] Fill the `Purpose` section — what is this service for?
61
+ - [ ] Document `Domain Rules` — what business logic does it implement?
62
+ - [ ] Add `Usage Examples` — how is this service invoked?
63
+ - [ ] Document `Relationships` — to other domain artifacts
64
+
65
+ ## What Not to Touch
66
+
67
+ These files are managed by scaffolding. Avoid direct edits:
68
+
69
+ | File | Reason |
70
+ |------|--------|
71
+ | `index.ts` | Barrel exports — regenerated on scaffold updates |
72
+
73
+ ## Testing
74
+
75
+ ### TDD Cycle
76
+
77
+ Services follow the red-green-refactor TDD loop:
78
+
79
+ 1. **Red**: Write a failing test for a service execution
80
+ 2. **Green**: Implement the minimal logic to make it pass
81
+ 3. **Refactor**: Clean up while keeping tests green
82
+
83
+ ### Example
84
+
85
+ ```ts
86
+ // Test: service execution with valid input
87
+ it('ejecutar servicio exitosamente', () => {
88
+ const input: ServiceInput = { ... };
89
+ const result = BillingService.of().execute(input);
90
+ expect(result).toEqual(expectedOutput);
91
+ });
92
+ ```
@@ -0,0 +1,135 @@
1
+ # Working with a Value Object
2
+
3
+ ## Files Generated
4
+
5
+ | File | Purpose |
6
+ |------|---------|
7
+ | `value-object.ts` | Main class with `@RegisterValueObject` decorator |
8
+ | `definition.ts` | Validation, serialization, and construction logic |
9
+ | `props.ts` | Internal state interface |
10
+ | `conditions.ts` | Zod validation rules |
11
+ | `primitive.ts` | Public read shape (exposed to application layer) |
12
+ | `payload.ts` | Serialization format for reconstruction |
13
+ | `index.ts` | Barrel exports |
14
+ | `errors/index.ts` | Domain error types |
15
+ | `README.md` | Frontmatter metadata + narrative documentation |
16
+ | `value-object.spec.ts` | Test file |
17
+
18
+ ## What to Customize
19
+
20
+ ### `props.ts` — Internal State
21
+
22
+ The `Props` interface defines the internal representation of this value object.
23
+ Each property maps to a domain concept and is validated by `conditions.ts`.
24
+
25
+ **Checklist:**
26
+ - [ ] Verify property types match your domain model
27
+ - [ ] Update or add property descriptions in JSDoc
28
+ - [ ] Ensure all domain concepts are represented
29
+
30
+ ### `conditions.ts` — Validation Rules
31
+
32
+ Zod validation schema that guards construction. Every value object must be
33
+ created in a valid state — these rules enforce that.
34
+
35
+ **Checklist:**
36
+ - [ ] Review each validation rule
37
+ - [ ] Add custom refinements for domain-specific constraints
38
+ - [ ] Ensure error messages are meaningful
39
+
40
+ ### `primitive.ts` — Public API Shape
41
+
42
+ Defines what the application layer can read from this value object.
43
+ This is the "read model" — it should not expose internal details.
44
+
45
+ **Checklist:**
46
+ - [ ] Verify the public shape includes all necessary fields
47
+ - [ ] Ensure internal-only fields are excluded
48
+
49
+ ### `definition.ts` — Serialization Logic
50
+
51
+ Contains `getPrimitive()` (for application layer) and `getPayload()` (for persistence/reconstruction).
52
+ The base class provides default implementations; override if you need custom serialization.
53
+
54
+ **Checklist:**
55
+ - [ ] Review serialization — does it properly map Props to Primitive?
56
+ - [ ] Review deserialization — does Payload reconstruct correctly?
57
+ - [ ] Add custom methods for domain operations
58
+
59
+ ### `errors/` — Domain Errors
60
+
61
+ Domain-specific errors that this value object can produce.
62
+
63
+ **Checklist:**
64
+ - [ ] Define custom error classes for each failure mode
65
+ - [ ] Register errors in `errors/index.ts`
66
+
67
+ ### `value-object.spec.ts` — Tests
68
+
69
+ The template includes a valid-input test and a placeholder for error cases.
70
+
71
+ **Checklist:**
72
+ - [ ] The valid-input test should already pass (green)
73
+ - [ ] Add a failing test for an error case (red)
74
+ - [ ] Implement the validation to make it pass (green)
75
+ - [ ] Refactor if needed
76
+ - [ ] Add tests for all error scenarios identified in `errors/`
77
+
78
+ ### `README.md` — Narrative Documentation
79
+
80
+ Rich documentation rendered by ultra-reporter on the Docusaurus site.
81
+
82
+ **Checklist:**
83
+ - [ ] Fill the `Purpose` section — what is this value object for?
84
+ - [ ] Document `Domain Rules` — what invariants does it enforce?
85
+ - [ ] Add `Usage Examples` — how is it created and used?
86
+ - [ ] Document `Relationships` — to other domain artifacts
87
+
88
+ ## What Not to Touch
89
+
90
+ These files are managed by scaffolding. Avoid direct edits:
91
+
92
+ | File | Reason |
93
+ |------|--------|
94
+ | `index.ts` | Barrel exports — regenerated on scaffold updates |
95
+ | `payload.ts` | Type derived from conditions — managed automatically |
96
+ | `errors/index.ts` | Error re-exports — managed automatically |
97
+
98
+ ## Validation & Errors
99
+
100
+ Value objects use Zod for validation via `conditions.ts`. Each condition is a Zod schema
101
+ that validates construction inputs. Errors are automatically classified by ultra-ddd
102
+ based on the Zod error type.
103
+
104
+ To add custom domain errors:
105
+ 1. Create an error class in `errors/`
106
+ 2. Use it in a Zod `.refine()` or `.superRefine()` in `conditions.ts`
107
+ 3. Export it from `errors/index.ts`
108
+
109
+ ## Testing
110
+
111
+ ### TDD Cycle
112
+
113
+ Value objects follow the red-green-refactor TDD loop:
114
+
115
+ 1. **Red**: Write a failing test for an invalid input
116
+ 2. **Green**: Add the validation rule to make it pass
117
+ 3. **Refactor**: Clean up while keeping tests green
118
+
119
+ ### Example
120
+
121
+ ```ts
122
+ // Test: value must be non-empty
123
+ it('rechazar valor vacío', () => {
124
+ const payload: Payload = { value: '' };
125
+ const result = UserEmail.of(payload);
126
+ expect(result).toBeError();
127
+ });
128
+ ```
129
+
130
+ ```ts
131
+ // Implementation in conditions.ts
132
+ export const conditions = z.object({
133
+ value: z.string().min(1, 'Value must not be empty'),
134
+ });
135
+ ```