@eventmodelers/cli 1.0.163 → 2.0.2

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 (128) hide show
  1. package/README.md +48 -36
  2. package/RELEASE_NOTES.md +20 -2
  3. package/cli.js +774 -247
  4. package/lib/adapters/spec-kitty-adapter.js +3 -7
  5. package/lib/build-kits.js +23 -0
  6. package/lib/global-agent-id.js +45 -0
  7. package/lib/modeling-local-ai.js +4 -2
  8. package/lib/scaffold-model.js +71 -0
  9. package/lib/scaffold.js +224 -0
  10. package/lib/supervise.js +60 -0
  11. package/lib/ui-baseline.js +123 -0
  12. package/package.json +1 -1
  13. package/shared/build-kit/README.md +4 -19
  14. package/shared/build-kit/lib/agent-lock.js +75 -0
  15. package/shared/build-kit/lib/agent-name.js +27 -0
  16. package/shared/build-kit/lib/event-prune.js +58 -0
  17. package/shared/build-kit/lib/events-view.js +134 -0
  18. package/shared/build-kit/lib/local-ai-agent.js +14 -26
  19. package/shared/build-kit/lib/mcp-register.js +17 -1
  20. package/shared/build-kit/lib/prompt-journal.js +191 -0
  21. package/shared/build-kit/lib/prompt-replay.js +35 -0
  22. package/shared/build-kit/lib/ralph.js +218 -169
  23. package/shared/build-kit/lib/slice-curation.js +40 -0
  24. package/shared/build-kit/lib/slice-events.js +93 -0
  25. package/shared/build-kit/lib/slice-git.js +86 -0
  26. package/shared/build-kit/lib/slice-learnings.js +197 -0
  27. package/shared/build-kit/lib/slice-projection.js +101 -0
  28. package/shared/build-kit/lib/slice-run.js +181 -0
  29. package/shared/build-kit/lib/slice-state.js +184 -0
  30. package/shared/build-kit/lib/slice-tasks.js +35 -0
  31. package/shared/build-kit/ralph-claude.js +4 -2
  32. package/shared/build-kit/ralph-exec.js +4 -2
  33. package/shared/build-kit/ralph-local-ai.js +5 -3
  34. package/shared/scaffold/LICENSE-em-scaffold +21 -0
  35. package/shared/scaffold/supabase/generate.mjs +290 -0
  36. package/shared/scaffold/supabase/template/scripts/create-user.mjs.tmpl +29 -0
  37. package/shared/scaffold/supabase/template/scripts/dev.mjs.tmpl +145 -0
  38. package/shared/scaffold/supabase/template/scripts/write-env.mjs.tmpl +44 -0
  39. package/shared/scaffold/supabase/template/server.ts.tmpl +168 -0
  40. package/shared/scaffold/supabase/template/src/common/extraEndpoints.ts.tmpl +5 -0
  41. package/shared/scaffold/supabase/template/src/common/notImplemented.test.ts.tmpl +58 -0
  42. package/shared/scaffold/supabase/template/src/common/notImplemented.ts.tmpl +29 -0
  43. package/shared/scaffold/supabase/template/supabase/migrations/_V0__supabase_stubs.sql.tmpl +34 -0
  44. package/shared/scaffold/supabase/template/web/src/App.tsx.tmpl +38 -0
  45. package/shared/scaffold/supabase/template/web/src/app/Layout.tsx.tmpl +48 -0
  46. package/shared/scaffold/supabase/template/web/src/app/NotFound.tsx.tmpl +12 -0
  47. package/shared/scaffold/supabase/template/web/src/app/SignIn.tsx.tmpl +42 -0
  48. package/shared/scaffold/supabase/template/web/src/app/TimelinePage.tsx.tmpl +73 -0
  49. package/shared/scaffold/supabase/template/web/src/app/pages.ts.tmpl +26 -0
  50. package/shared/scaffold/supabase/template/web/src/app/skeleton.css.tmpl +25 -0
  51. package/shared/scaffold/supabase/template/web/src/lib/NotBuilt.tsx.tmpl +12 -0
  52. package/shared/scaffold/supabase/template/web/src/lib/api.ts.tmpl +226 -0
  53. package/shared/scaffold/supabase/template/web/src/main.tsx.tmpl +13 -0
  54. package/shared/skills/learn-eventmodelers-api/SKILL.md +17 -4
  55. package/shared/skills/request-feedback/SKILL.md +1 -2
  56. package/shared/skills/ui-contract/SKILL.md +7 -5
  57. package/shared/skills/update-slice-status/SKILL.md +1 -1
  58. package/stacks/axon/templates/build-kit/CLAUDE.md +7 -6
  59. package/stacks/axon/templates/build-kit/lib/AGENT.md +6 -7
  60. package/stacks/axon/templates/build-kit/lib/backend-prompt.md +20 -42
  61. package/stacks/axon/templates/build-kit/lib/prompt.md +32 -41
  62. package/stacks/blank/templates/build-kit/CLAUDE.md +7 -6
  63. package/stacks/blank/templates/build-kit/lib/AGENT.md +6 -7
  64. package/stacks/blank/templates/build-kit/lib/backend-prompt.md +20 -37
  65. package/stacks/blank/templates/build-kit/lib/prompt.md +33 -42
  66. package/stacks/classic/templates/.claude/skills/build-automation/SKILL.md +1 -1
  67. package/stacks/classic/templates/.claude/skills/build-state-change/SKILL.md +1 -1
  68. package/stacks/classic/templates/.claude/skills/build-state-view/SKILL.md +2 -2
  69. package/stacks/classic/templates/.claude/skills/record-evidence/SKILL.md +2 -2
  70. package/stacks/classic/templates/build-kit/CLAUDE.md +9 -8
  71. package/stacks/classic/templates/build-kit/lib/AGENT.md +6 -7
  72. package/stacks/classic/templates/build-kit/lib/backend-prompt.md +20 -38
  73. package/stacks/classic/templates/build-kit/lib/prompt.md +33 -42
  74. package/stacks/kurrent/templates/build-kit/CLAUDE.md +7 -7
  75. package/stacks/kurrent/templates/build-kit/lib/AGENT.md +6 -7
  76. package/stacks/kurrent/templates/build-kit/lib/backend-prompt.md +20 -42
  77. package/stacks/kurrent/templates/build-kit/lib/prompt.md +32 -41
  78. package/stacks/modeling-kit/templates/.claude/skills/analyze-existing-model/SKILL.md +1 -1
  79. package/stacks/modeling-kit/templates/.claude/skills/detect-model-drift/SKILL.md +1 -1
  80. package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-core-rules/SKILL.md +2 -0
  81. package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-elaborating-scenarios/SKILL.md +7 -3
  82. package/stacks/modeling-kit/templates/.claude/skills/wdyt/SKILL.md +1 -1
  83. package/stacks/modeling-kit/templates/kit/CLAUDE-STANDALONE.md +3 -4
  84. package/stacks/modeling-kit/templates/kit/CLAUDE.md +18 -28
  85. package/stacks/modeling-kit/templates/kit/README.md +1 -1
  86. package/stacks/modeling-kit/templates/kit/lib/config.js +1 -1
  87. package/stacks/node/templates/build-kit/CLAUDE.md +7 -6
  88. package/stacks/node/templates/build-kit/lib/AGENT.md +6 -7
  89. package/stacks/node/templates/build-kit/lib/backend-prompt.md +20 -42
  90. package/stacks/node/templates/build-kit/lib/prompt.md +18 -41
  91. package/stacks/opencqrs/templates/build-kit/CLAUDE.md +7 -7
  92. package/stacks/opencqrs/templates/build-kit/lib/AGENT.md +6 -7
  93. package/stacks/opencqrs/templates/build-kit/lib/backend-prompt.md +20 -42
  94. package/stacks/opencqrs/templates/build-kit/lib/prompt.md +32 -41
  95. package/stacks/react/templates/.claude/skills/build-state-change/SKILL.md +1 -1
  96. package/stacks/react/templates/.claude/skills/build-state-view/SKILL.md +1 -1
  97. package/stacks/react/templates/build-kit/CLAUDE.md +7 -6
  98. package/stacks/react/templates/build-kit/lib/AGENT.md +6 -7
  99. package/stacks/react/templates/build-kit/lib/backend-prompt.md +25 -42
  100. package/stacks/react/templates/build-kit/lib/kit.json +1 -1
  101. package/stacks/react/templates/build-kit/lib/prompt.md +47 -43
  102. package/stacks/supabase/templates/.claude/skills/build-state-view/SKILL.md +15 -0
  103. package/stacks/supabase/templates/build-kit/CLAUDE.md +7 -6
  104. package/stacks/supabase/templates/build-kit/lib/AGENT.md +6 -7
  105. package/stacks/supabase/templates/build-kit/lib/backend-prompt.md +20 -42
  106. package/stacks/supabase/templates/build-kit/lib/prompt.md +18 -41
  107. package/stacks/supabase-react/templates/.claude/skills/build-state-change/SKILL.md +80 -8
  108. package/stacks/supabase-react/templates/.claude/skills/build-state-view/SKILL.md +66 -13
  109. package/stacks/supabase-react/templates/build-kit/CLAUDE.md +8 -7
  110. package/stacks/supabase-react/templates/build-kit/lib/AGENT.md +6 -7
  111. package/stacks/supabase-react/templates/build-kit/lib/backend-prompt.md +25 -42
  112. package/stacks/supabase-react/templates/build-kit/lib/kit.json +1 -1
  113. package/stacks/supabase-react/templates/build-kit/lib/prompt.md +48 -44
  114. package/stacks/umadb/templates/build-kit/CLAUDE.md +7 -6
  115. package/stacks/umadb/templates/build-kit/lib/AGENT.md +6 -7
  116. package/stacks/umadb/templates/build-kit/lib/backend-prompt.md +20 -42
  117. package/stacks/umadb/templates/build-kit/lib/prompt.md +32 -41
  118. package/shared/bridge/spec-kitty/bridge-spec-kitty-specify/SKILL.md +0 -125
  119. package/shared/bridge/spec-kitty/bridge-spec-kitty-tasks/SKILL.md +0 -95
  120. package/shared/build-kit/lib/agent.sh +0 -20
  121. package/shared/build-kit/ralph.sh +0 -111
  122. package/shared/build-kit/realtime-agent.js +0 -20
  123. package/stacks/bridge/templates/bridge/lib/AGENT.md +0 -47
  124. package/stacks/bridge/templates/bridge/lib/prompt.md +0 -111
  125. package/stacks/bridge/templates/bridge/ralph-claude.js +0 -50
  126. package/stacks/bridge/templates/bridge/ralph-hook.js +0 -103
  127. package/stacks/bridge/templates/bridge/ralph-local-ai.js +0 -43
  128. package/stacks/bridge/templates/bridge/ralph-static.js +0 -90
@@ -67,31 +67,39 @@ Extract:
67
67
  a Slice" step 6) — the built, mocked component still needs a real table/view before it's done,
68
68
  so don't flip it to `Done`.
69
69
  - `description` — implementation hints (filtering rules, sort order, business meaning).
70
- - **UI contract (read)** — the backend slice's published `GET` contract: look it up as described in
70
+ - **UI contract (read)** — **not used for a read model backed by a table, which is the normal case on this
71
+ stack: that is always read directly with `queryReadModel`, even when the backend published a `GET`
72
+ contract.** Only when `slice.json` says the read model is not a persisted table (a computed view, an
73
+ external source) does the backend's published `GET` contract apply: look it up as described in
71
74
  the `ui-contract` skill ("How the UI build kit looks the contract up" — the `## UI Contract` entry in
72
- `slice.json` `notes[]`; parse only its `ui-contract` block — an OpenAPI operation). **When present it
73
- is the specification and you build the call from it** — it overrides `apiEndpoint` and the table read:
75
+ `slice.json` `notes[]`; parse only its `ui-contract` block — an OpenAPI operation). **In that case it
76
+ is the specification and you build the call from it** — it overrides `apiEndpoint`:
74
77
  - fetch with `getReadModel(buildPath('<contract path>', { <path params> }), { <query params> }, samples)`
75
78
  from `src/lib/api.ts` — path and query `parameters` exactly as the contract names them, never a
76
79
  guessed URL, never `supabase.from(...)`;
77
80
  - type the result from the 2xx `responses` schema (it must match `readmodel.fields[]`; the contract
78
- wins for the wire shape, record any mismatch in `progress.txt`);
81
+ wins for the wire shape, record any mismatch as a code comment);
79
82
  - render **every** non-2xx response (status + description) as its own distinct state — a 404 "no
80
83
  reservation" is an empty state, not an error banner; don't collapse them into one generic failure;
81
84
  - the numbered samples (Step 4) are shaped like the contract's 2xx response body.
82
85
 
83
86
  **When absent** (backend slice not built or not re-fetched yet): fall back to the table read —
84
87
  `readmodel.apiEndpoint` (table/view name) + `fields[]` via `queryReadModel` — and note the assumption
85
- in `progress.txt`.
88
+ as a code comment.
86
89
  - **screens[]** — the actor `SCREEN` element(s) that display this data, if any (see Step 2).
87
- - **specifications[]** — GWT scenarios/storyline; treat as acceptance criteria (e.g. "given no
88
- active reservation, show an empty state").
90
+ - **specifications[]** and **storylines[]** (optional) — GWT scenarios / board walkthroughs. These
91
+ describe how the slice should **behave** — read them in full (Step 3a) to understand the outcomes
92
+ and states the UI must present. The business logic itself lives in the backend; the UI does not implement it.
89
93
 
90
94
  > **Comments**: as in `build-state-change` — resolve consumed ones via the same node-comment
91
95
  > endpoint.
92
96
 
93
97
  ## Step 2 — Read the screen, and especially its marks
94
98
 
99
+ > **Gated by `ui-baseline check`** (build prompt, `lib/prompt.md`, Step 4): do this step when the verdict
100
+ > is `SCREEN_CHANGED`, `NO_BASELINE` or `UNKNOWN` — and then also diff the existing JSX against the fetched
101
+ > screen and adjust the UI to it. On `UNCHANGED` skip it.
102
+
95
103
  Identical to `build-state-change` Step 2 — fetch the live screen node
96
104
  (`mcp__eventmodelers__get_node`), find this slice's marked fragment in `meta.pages`/`meta.marks`
97
105
  (or the whole page if unmarked), and treat it as the blueprint. The same `learn-styleguide` note
@@ -112,16 +120,39 @@ multi-read-model component.
112
120
  **Markup**: same rule as `build-state-change` — translate the blueprint from Step 2 1:1 into JSX;
113
121
  the mockup is the design, not a starting point for a redesign.
114
122
 
123
+ **Data binding — the whole point of a read-model component.** Every *data* value in the mockup (names,
124
+ role/organisation lines, selected values, dropdown options, list rows, badges, counts, dates) is a
125
+ sample taken from the model's examples; it must be rendered from the queried data, mapped from
126
+ `readmodel.fields[]` — keep only label/copy (headings, button captions, placeholders) verbatim.
127
+ Check where each displayed value comes from before writing JSX: a field of this read model → bind it;
128
+ a field of another read model on the same screen → it arrives as a prop from the parent that fetched
129
+ it (or a sibling read-model component), never from the mockup. List rows are a `.map()` over the
130
+ fetched rows, not the rows drawn. Self-check: grep the component for the mockup's example strings;
131
+ any hit outside `samples/` means hardcoded data — fix it.
132
+
133
+ **Find the screen's data sources on the board, not just in `slice.json`.** A screen is often shown by
134
+ one slice but fed by a read model that belongs to *another* slice (e.g. the Contact Details screen
135
+ sits in the Assign Tag slice, yet its contact data comes from the Contact List read model via an edge
136
+ READMODEL → SCREEN). `slice.json` only lists this slice's own elements, so also call
137
+ `mcp__eventmodelers__get_connected_nodes { boardId, nodeId: <screen.id> }` and take every READMODEL
138
+ wired into the screen. Each one is a data source for the displayed values; look up its fields in that
139
+ read model's slice (`.build-kit/.slices/*/*/slice.json`, or `get_node`). A list read model feeding a
140
+ detail screen (`Contact List[]` → one contact) means: query it filtered by the entity id the page
141
+ gets from the route (match the id field, e.g. `contactId` / the command's `recordId`) and render that
142
+ row. If the source read model's slice isn't built, still type and wire against its fields (TODO), do
143
+ not substitute the mockup's values.
144
+
145
+
115
146
  **Props**: whatever the component needs to *scope* its query (e.g. `customerId`) — passed in from
116
147
  its parent, never read from a global store. The queried data itself is **not** a prop — the
117
148
  component fetches it.
118
149
 
119
- **With a UI contract (Step 1)**: call `getReadModel(buildPath(path, pathParams), queryParams, samples)`
150
+ **With a UI contract (Step 1, non-table read models only)**: call `getReadModel(buildPath(path, pathParams), queryParams, samples)`
120
151
  from `src/lib/api.ts` inside the component instead of the `queryReadModel` snippet below — same
121
152
  effect shape (`useEffect` → loading / empty / error / data), but each documented non-2xx response
122
153
  (`ApiError.status`) maps to its own state. Never a raw `fetch`.
123
154
 
124
- **Default (no contract) — call `queryReadModel` from `src/lib/api.ts` inside the component**. Never
155
+ **Default (a table-backed read model — always, unless the contract case above applies) — call `queryReadModel` from `src/lib/api.ts` inside the component**. Never
125
156
  `supabase.from(...)` directly, never a raw `fetch`:
126
157
 
127
158
  ```tsx
@@ -182,6 +213,26 @@ export function ActiveReservationView({ customerId }: ActiveReservationViewProps
182
213
  }
183
214
  ```
184
215
 
216
+ ### Step 3a — Read the scenarios to understand behavior (not to implement rules)
217
+
218
+ **Business logic lives in the backend (the projection). The UI never re-derives it** — no
219
+ recomputing totals, statuses or membership from events; render what the read model holds.
220
+
221
+ Read every entry in `specifications[]` (and the READMODEL beats in `storylines[]`) to understand
222
+ **what the read model looks like in different situations and how the component should present each**:
223
+
224
+ | Scenario shows | What it tells the UI |
225
+ |---|---|
226
+ | `then` read model is empty (`expectEmptyList` / no rows) | an **empty state** must exist, distinct from loading and error |
227
+ | the same field takes different values across scenarios (e.g. status `open` → `closed`) | each value needs a sensible presentation (label, badge, shown/hidden actions) — presentation only |
228
+ | rows appear/disappear between scenarios | the component renders whatever rows the read model returns; it does not decide which belong |
229
+ | row order visible across scenarios | hint for `order`/sort on the query, if the read model doesn't already guarantee it |
230
+ | a `STORYLINE_NOTE` beat | background only |
231
+
232
+ Rules:
233
+ - Understand, don't implement: presentation of what the backend provides, nothing more.
234
+ - Cite the scenario behind a non-obvious state in a one-line comment.
235
+
185
236
  Select fields explicitly by name rather than `select('*')`. Map each field's `name` to its actual
186
237
  column name — check the paired backend stack's migrations if the naming convention (e.g. camelCase
187
238
  vs. snake_case) isn't obvious rather than guessing; if genuinely unclear, use `request-feedback`.
@@ -202,7 +253,9 @@ otherwise; use `null`/`[]` for a sample meant to exercise the empty/background s
202
253
 
203
254
  Add at least one sample (`sample-1.json`) covering the ordinary case from
204
255
  `readmodel.fields[].example` values; add more numbered ones for whatever other scenarios this
205
- read model's `specifications[]` call out (e.g. an empty result, a second customer's data). The
256
+ read model's `specifications[]` show — **one sample per distinct scenario outcome**, using the
257
+ scenario's own example values (an empty result, each status a row can take, a second customer's
258
+ data). The
206
259
  same number across *different* components' `samples/` folders is meant to represent one coherent
207
260
  scenario across the whole app (e.g. every component's `sample-2.json` together tell the story of
208
261
  "a long-time customer") — keep that in mind when choosing what a given number represents, rather
@@ -230,7 +283,7 @@ one page per slice.
230
283
  one place allowed to import across slice folders. Translate the screen's whole, unmarked
231
284
  `meta.pages` markup into JSX (the page-level layout), and at each `data-em-mark-id` position
232
285
  render that mark's owning slice's component (only for slices already built; leave the rest as
233
- the mockup's static content until they are). The page threads shared inputs down as props; a
286
+ the mockup's static content until they are). Static placeholder content is label/copy only — displayed data (names, selections, options, rows) is bound to its read model, never the mockup's examples or a sample file. The page threads shared inputs down as props; a
234
287
  slice component still only knows its own declared props. Update only this slice's marked
235
288
  position if the page file already exists.
236
289
 
@@ -289,8 +342,8 @@ leaves it alone.
289
342
  slice.json.
290
343
  - At least one numbered sample exists under this slice's `samples/` folder, shaped exactly like
291
344
  `queryReadModel`'s return value.
292
- - The component renders a sensible empty/background state, distinct from loading/error, when the
293
- data is `null`/`[]`.
345
+ - Every scenario situation (empty, each distinct field value) has a rendered presentation, and the
346
+ component re-derives nothing the read model already holds.
294
347
  - If a screen was read in Step 2, the rendered JSX matches the marked (or whole, if unmarked) HTML
295
348
  fragment structurally.
296
349
  - Nothing in this slice's folder is imported from another slice's folder, and nothing outside it
@@ -28,7 +28,7 @@ not attempt to build it, flag it via `request-feedback` instead.
28
28
  2. Maintain clear separation of concerns within each slice
29
29
  3. Headers, auth, `fetch`, and Supabase table access live exclusively in `src/lib/api.ts` — a
30
30
  slice component never imports `src/lib/supabase.ts` itself, never calls `fetch`, and never
31
- calls `supabase.from(...)` directly; when the backend slice published a UI contract (`ui-contract` skill, `slice.json` `notes[]`) the slice is built *from* it — path, parameters, body and every error response — and falls back to `apiEndpoint`/`fields[]` only when none exists; it calls `postCommand`/`getReadModel`/`queryReadModel` and only contains
31
+ calls `supabase.from(...)` directly; a table-backed read model is always read directly with `queryReadModel` (the backend's `GET` contract is ignored for it); when the backend slice published a UI contract (`ui-contract` skill, `slice.json` `notes[]`) for a *write* or a non-table read, the slice is built *from* it — path, parameters, body and every error response — and falls back to `apiEndpoint`/`fields[]` only when none exists; it calls `postCommand`/`getReadModel`/`queryReadModel` and only contains
32
32
  business logic (validation, request-body shaping, response handling)
33
33
  4. A command's/read-model's screen markup (`meta.pages` on its actor HTML_SCREEN node, scoped to
34
34
  this slice's `meta.marks` when the screen is shared) is the visual blueprint — translate it into
@@ -95,16 +95,16 @@ not attempt to build it, flag it via `request-feedback` instead.
95
95
  on its next build. Never hand-write CSS to imitate a framework. See `build-state-change` Step 7 /
96
96
  `build-state-view` Step 6.
97
97
 
98
- At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings.
98
+ At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings. It is generated from the learnings recorded so far — record a new one with `npx @eventmodelers/cli learn "<one terse line>" --topic <topic>`, never by editing the file.
99
99
 
100
- When starting to work on a slice, invoke the `update-slice-status` skill with `InProgress` status before doing anything else.
100
+ When working from a queued task, invoke the `update-slice-status` skill with `InProgress` status before doing anything else. When the task request names the slice to build (a run-loop build), the run loop has already set it to `InProgress` and pushes the final status itself — do not call `update-slice-status`; record the outcome with `npx @eventmodelers/cli slice-status <status>`.
101
101
 
102
102
  ## Building a Slice
103
103
 
104
104
  **CRITICAL: You MUST always use the provided skills to build slices. NEVER implement a slice manually.**
105
105
  **ALL fields, event names, command names, and business rules MUST come exclusively from slice.json. Do NOT invent, assume, or guess any field or logic not present in the slice definition.**
106
106
 
107
- **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line in `progress.txt` and as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
107
+ **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
108
108
 
109
109
  **Exception: a missing `apiEndpoint`** (no backend endpoint/table decided yet) is a partial version of
110
110
  this — flag it, but don't fully stop. `build-state-change`/`build-state-view` Step 1 cover the exact
@@ -122,9 +122,10 @@ When asked to build a slice, always follow this flow:
122
122
  - **`AUTOMATION`** → not this stack's job (no UI counterpart) — invoke `request-feedback`
123
123
  rather than building it; it belongs to whichever backend stack is installed alongside this one
124
124
  3. Invoke the matching skill and follow its instructions completely. Do not deviate.
125
- 4. **Verify against slice.json**: After the skill completes, check that every command field, event field, and specification in slice.json appears in the implementation. No invented fields — if it is not in slice.json, it must not be in the code.
126
- 5. Run `npm run build` and `npm run lint` (both must pass clean), then the slice's own tests only, if any exist.
127
- 6. If checks pass, commit with `feat: [Slice Name]` and set slice status to `Done` — **unless** the
125
+ 4. **UI baseline gate**: run `npx @eventmodelers/cli ui-baseline check` first and act only on its verdict — `UNCHANGED` means skip all UI work; `NO_BASELINE`/`UNKNOWN` mean one full screen diff and every `codeGen.uiPrompts` entry; `CHANGED` names the elements that changed, were added or removed (work on exactly those) and flags `SCREEN_CHANGED` (re-fetch the screen node and adjust the components to it), `ELEMENTS_CHANGED` (diff slice.json against the code) and `PROMPTS_CHANGED` (apply the printed prompts). Details in `lib/prompt.md`, Step 4. After the checks pass and before committing, run `ui-baseline record`.
126
+ 5. **Verify against slice.json**: After the skill completes, check that every command field, event field, and specification in slice.json appears in the implementation — specifications are read (Step 3a of the build skill) to understand how the UI should behave and present outcomes; the business logic lives in the backend and is not re-implemented here. No invented fields — if it is not in slice.json, it must not be in the code.
127
+ 6. Run `npm run build` and `npm run lint` (both must pass clean), then the slice's own tests only, if any exist.
128
+ 7. If checks pass, commit with `feat: [Slice Name]` and set slice status to `Done` — **unless** the
128
129
  matching build skill flagged a missing `apiEndpoint` and already marked the slice `Blocked`
129
130
  (Step 1 exception above); in that case, commit as normal but leave the status `Blocked`.
130
131
 
@@ -1,12 +1,11 @@
1
- # Agent Learnings
1
+ # Agent Reference
2
2
 
3
- Patterns and gotchas discovered during task processing. Update this file whenever you encounter something reusable.
3
+ What task processing relies on: the shape of a task and the API facts the skills use. A reusable learning is recorded with `npx @eventmodelers/cli learn "<one terse line>"`, not added here.
4
4
 
5
- ## tasks.json
5
+ ## Tasks
6
6
 
7
- - Tasks are objects with `id`, `createdAt`, and `payload` (a `SliceChangedPayload`).
8
- - After completing a task, remove it from the array entirely — do not add a status field.
9
- - Write `[]` to `tasks.json` if the last task is completed.
7
+ - A task is a slice change the run loop queued: an `id` and a `payload` (a `SliceChangedPayload`). The task request names it.
8
+ - You never read or write a queue file: the run loop completes the task when your turn ends.
10
9
 
11
10
  ## SliceChangedPayload fields
12
11
 
@@ -44,4 +43,4 @@ These files are always up to date — read them directly before invoking any ski
44
43
  - The `boardId` and `organizationId` from each payload provide full context — pass them to skills.
45
44
  - Node events use `node:created`, `node:changed`, `node:deleted` — always POST to `/api/org/:orgId/boards/:boardId/nodes/events`.
46
45
  - Slice metadata (title, status) lives on the SLICE_BORDER node under `meta.sliceStatus` and `meta.title`.
47
- - `/update-slice-status` rejects moving a slice into a status it's already in — this is a concurrency guard, not a bug. It means another agent already claimed the slice. Treat it as `ALREADY_IN_STATUS`, skip that slice, and move on to the next `Handover` one instead of erroring out.
46
+ - `/update-slice-status` rejects moving a slice into a status it's already in — this is a concurrency guard, not a bug. It means another agent already claimed the slice. Treat it as `ALREADY_IN_STATUS`, skip that slice, and move on to the next `Waiting` one instead of erroring out. This applies to queued tasks only: when the task request names the slice to build, the run loop owns its status — never call `/update-slice-status` there.
@@ -9,67 +9,50 @@ The structure defined in the Project-Skills is relevant.
9
9
  You work within **exactly ONE context at a time** — the one named in `.build-kit/.slices/current_context.json` (the runner picks it).
10
10
 
11
11
  - **ONLY** look for and build slices inside `.build-kit/.slices/<currentContext>/`.
12
- - **NEVER** read, scan, or build slices from any other context directory, even if it has "Handover" slices, and even if the current context has no work left.
13
- - A "Handover" slice in a *different* context is **NOT yours to build**. Ignore it completely.
14
- - If the current context has no "Handover" slice, you are **done for this iteration** — reply `<promise>NO_TASKS</promise>` and stop. Do not go looking elsewhere. The runner moves `current_context.json` on to the next context with Handover work between iterations — never change it yourself.
12
+ - **NEVER** read, scan, or build slices from any other context directory, even if it has "Waiting" slices, and even if the current context has no work left.
13
+ - A "Waiting" slice in a *different* context is **NOT yours to build**. Ignore it completely.
14
+ - If the current context has no "Waiting" slice, you are **done for this iteration** — reply `<promise>NO_TASKS</promise>` and stop. Do not go looking elsewhere. The runner moves `current_context.json` on to the next context with Waiting work between iterations — never change it yourself.
15
15
 
16
16
  ## Your Task
17
17
 
18
18
  0. Do not read the entire code base. Focus on the tasks in this description.
19
19
  1. Read `.build-kit/.slices/current_context.json` to find the active context name, then read `.build-kit/.slices/<contextName>/index.json`. Every item in status "handover" is a task.
20
- 2. Read the progress log at `progress.txt` **if it exists** (check Codebase Patterns section first) — it is absent until the first slice is built, which is not an error; create it when you write your first entry
20
+ 2. Read `.build-kit/AGENTS.md` **if it exists** — the project's accumulated learnings, generated from what earlier builds recorded. If the slice's `slice.json` has a `lastAttempt`, an earlier attempt at it failed: read its `reason`, `lastReply`, `branch` and `changed`, and do not repeat what failed.
21
21
  3. Make sure you are on the right branch "feature/<slicename>", if unsure, start from main.
22
- 5. Pick the **highest priority** slice where status is **exactly** "Handover" (case insensitive). This becomes your PRD. Set the status "InProgress" in the index.json **and** update the slice status on the eventmodelers board using the `update-slice-status` skill (or MCP if available).
23
- **IMPORTANT: Only work on slices with status "Handover" in the CURRENT context. Never pick up a slice that is "InProgress", "Done", "Blocked", "Created", or any other status — even if it looks incomplete. If no slice has status "Handover" in the current context, reply with:**
22
+ 5. Your slice is the one the task request names (the run loop picked the highest priority slice with status "Waiting"); it becomes your PRD. The run loop has already claimed it — its status is "InProgress" in index.json and on the board. Build that slice and do not call `update-slice-status`: the run loop owns the slice's status on the board.
23
+ **IMPORTANT: Only work on the slice named in the task request. Never switch to another slice, whatever its status. If the task request names no slice and no slice has status "Waiting" in the current context, reply with:**
24
24
  <promise>NO_TASKS</promise> and stop immediately. Do not work on other slices and do not switch to another context.
25
- **Claim conflict**: the board rejects the status update if the slice is already in the target status — this is expected: another agent claimed it first, racing you for the same slice. This is NOT an error. Do not stop, do not retry the same slice. Re-read `index.json` (or re-fetch via `load-slice`), pick the next-highest-priority slice still "Handover", and try claiming that one instead. Repeat until a claim succeeds or no "Handover" slice remains, in which case reply `<promise>NO_TASKS</promise>`.
26
25
  6. Pick the slice definition from `.build-kit/.slices/<contextName>/<folder>/slice.json` as defined in the prd. Never work on more than one slice per iteration.
27
- 7. A slice can define additional prompts as codegen/backendPrompt. Any additional prompts defined in backend are hints for the implementation of the slice and have to be taken into account. If you use the additional prompt, add a line in progress.txt
26
+ 7. A slice can define additional prompts as codegen/backendPrompt. Any additional prompts defined in backend are hints for the implementation of the slice and have to be taken into account.
28
27
  7. Determine the slice type and invoke the matching skill as defined in the **Building a Slice** section of `.build-kit/CLAUDE.md`. Do NOT implement manually.
29
- 8. Write a short progress one liner after each step to progress.txt
28
+ 8. Record each learning the moment you have it (see **Recording Learnings**), not at the end.
30
29
  9. Analyze and Implement that single slice, making use of the skills in the skills directory plus your previously collected knowledge. Make a TODO list for what needs to be done, and adjust the implementation according to the JSON definition. Carefully inspect events, fields and compare against the implemented slice. JSON is the desired state. ATTENTION: a "handover" task can also be just added specifications. So always look at the slice itself, but also the specifications. If specifications were added in json which are not on code, you need to add them in code.
31
30
  10. The slice in the json is always true, the code follows what is defined in the json
32
31
  11. Slice is only 'Done' if business logic is implemented as defined in the JSON, APIs are implemented, all scenarios in JSON are implemented in code and it fulfills the slice.json. There must be no specification in json that has no equivalent in code.
33
32
  12. Build against the backend slice's published UI contract (see the `ui-contract` skill, "How the UI build kit looks the contract up") — the build-state-view / build-state-change skills say how to apply it
34
33
  13. Run quality checks — `npm run build` (typecheck + build) and `npm run lint`. No test runner is configured in this stack yet; if a slice's specifications demand behavioral tests, flag it via `request-feedback` instead of inventing a test setup ad hoc.
35
34
  14. If checks pass, commit ALL changes with message: `feat: [Slice Name]` and merge back to main as FF merge (update first)
36
- 15. Update the PRD to set `status: Done` for the completed story in index.json **and** update the slice status on the eventmodelers board using the `update-slice-status` skill (or MCP if available).
37
- 16. Append your progress to `progress.txt` after each step in the iteration.
38
- 17. Append your new learnings to `.build-kit/AGENTS.md` in a compressed form, reusable for future iterations. Only add learnings if they are not already there.
35
+ 15. Record the outcome with `npx @eventmodelers/cli slice-status Done` — not by editing index.json, and do not call `update-slice-status`: the run loop pushes the status to the board when your turn ends. A slice you could not finish needs no status: leave it as it is and the run loop discards the attempt.
36
+ 16. Record any reusable learning you have not recorded yet (see **Recording Learnings**).
37
+ 17. If an entry in `.build-kit/AGENTS.md` turned out wrong or obsolete, retract it (see **Recording Learnings**).
39
38
  18. Finish the iteration.
40
39
 
41
40
  ## Escalating Ambiguity
42
41
 
43
- **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line in `progress.txt` and as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
42
+ **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
44
43
 
45
- ## Progress Report Format
44
+ ## Recording Learnings
46
45
 
47
- APPEND to progress.txt (never replace, always append):
46
+ `.build-kit/AGENTS.md` is generated from the learnings recorded so far — read it at the start of every session, never edit it by hand. Record a learning the moment you have it:
48
47
 
49
48
  ```
50
- ## [Date/Time] - [Slice]
51
-
52
- - What was implemented
53
- - Files changed
54
- - **Learnings for future iterations:**
55
- - Patterns discovered (e.g., "this codebase uses X for Y")
56
- - Gotchas encountered (e.g., "don't forget to update Z when changing W")
57
- - Useful context (e.g., "the evaluation panel is in component X")
58
- ---
49
+ npx @eventmodelers/cli learn "<one terse line>" --topic "<topic>"
59
50
  ```
60
51
 
61
- The learnings section is critical - it helps future iterations avoid repeating mistakes and understand the codebase better.
62
-
63
- ## Consolidate Patterns
64
-
65
- If you discover a **reusable pattern** that future iterations should know, add it to the `## Codebase Patterns` section at the TOP of progress.txt (create it if it doesn't exist).
66
-
67
- ```
68
- ## Codebase Patterns
69
- - TODO: an example of a your stack-specific reusable pattern once you have one
70
- ```
71
-
72
- Only add patterns that are **general and reusable**, not story-specific details.
52
+ - Only what is genuinely reusable: codebase patterns, gotchas, commands that work or don't, conventions — and, after a failed approach, what was tried and why it failed. Not slice-specific details, and nothing the code or git log already says.
53
+ - One learning per call, one line each. A learning that is already in `.build-kit/AGENTS.md` is skipped for you.
54
+ - `--scope system` for what is true of the modeled domain (a business rule, a naming convention of the model); `repo` (the default) for the codebase and its tooling. `--tag <tag>` labels it (repeatable).
55
+ - One in `.build-kit/AGENTS.md` that turned out wrong or obsolete: `npx @eventmodelers/cli learnings --ids` lists each with its id, `npx @eventmodelers/cli learn --retract <id>` removes it.
73
56
 
74
57
  ## Update AGENTS.md Files
75
58
 
@@ -80,7 +63,7 @@ Before committing, check if any edited files have learnings worth preserving in
80
63
  - Slice specific implementation details
81
64
  - Story-specific implementation details
82
65
  - Temporary debugging notes
83
- - Information already in progress.txt
66
+ - Information already recorded as a learning in `.build-kit/AGENTS.md`
84
67
  - Task-specific learnings
85
68
 
86
69
  Only update AGENTS.md if you have **genuinely reusable knowledge** that would help future work
@@ -107,12 +90,12 @@ A Slice is not complete if specifications are missing or can't be executed.
107
90
 
108
91
  ## Stop Condition
109
92
 
110
- **After completing ONE slice, always stop — regardless of whether more slices are in Handover.** The ralph loop will invoke you again for the next slice. Never chain multiple slices in one iteration.
93
+ **After completing ONE slice, always stop — regardless of whether more slices are in Waiting.** The ralph loop will invoke you again for the next slice. Never chain multiple slices in one iteration.
111
94
 
112
95
  If the slice was completed and committed successfully, reply with:
113
96
  <promise>DONE</promise>
114
97
 
115
- If no slice has status "Handover" in the current context, reply with:
98
+ If no slice has status "Waiting" in the current context, reply with:
116
99
  <promise>NO_TASKS</promise>
117
100
  (Do NOT switch to another context to find work — stop here.)
118
101
 
@@ -124,9 +107,9 @@ If ALL slices in the current context are Done, reply with:
124
107
  - If no `.eventmodelers/config.json` exists anywhere (project root or an ancestor directory, or `~/.eventmodelers/config.json` — the one inside `.build-kit/` is only an optional override, so its absence means nothing), skip all platform communication (MCP calls, `update-slice-status`, board sync) and continue working locally.
125
108
  - Work on ONE slice per iteration
126
109
  - Commit frequently
127
- - update progress.txt frequently
128
- - Read the Codebase Patterns section in progress.txt before starting
110
+ - Record learnings as you go with `learn`
111
+ - Read `.build-kit/AGENTS.md` before starting
129
112
 
130
113
  ## When an iteration completes
131
114
 
132
- Use all the key learnings from the progress.txt and update the `.build-kit/AGENTS.md` file with those learnings.
115
+ Make sure every reusable learning is recorded with `learn`; `.build-kit/AGENTS.md` is generated from them — never edit it by hand.
@@ -1,3 +1,3 @@
1
1
  {
2
- "pickupStatus": "Handover"
2
+ "pickupStatus": "Waiting"
3
3
  }
@@ -4,17 +4,11 @@ You are an autonomous agent reacting to slice status change events on an Eventmo
4
4
 
5
5
  ## Your Loop
6
6
 
7
- 1. Read `AGENT.md` to load accumulated learnings before doing anything else.
8
- 2. Read `.build-kit/tasks.json`.
9
- 3. If `tasks.json` is empty or missing, reply with:
10
- <promise>IDLE</promise>
11
- and stop.
12
- 4. Pick the **oldest task** (earliest `createdAt`).
13
- 5. Execute the task — see the Execution section below.
14
- 6. After execution, remove that task from the array and write `.build-kit/tasks.json` back.
15
- 7. Append a progress entry to `progress.txt` (create if missing).
16
- 8. Update `AGENT.md` with any new reusable learnings discovered this iteration.
17
- 9. Reply normally so the next iteration can pick up the next task.
7
+ 1. Read `AGENT.md` and, if it exists, `.build-kit/AGENTS.md` to load accumulated knowledge before doing anything else.
8
+ 2. The task request at the end of this prompt names your task: its id and the slice change that queued it (`sliceId`, `sliceTitle`, `sliceStatus`, …). It is the oldest one waiting — the run loop picked it for you.
9
+ 3. Execute the task — see the Execution section below.
10
+ 4. Record any reusable learning with `npx @eventmodelers/cli learn "<one terse line>" --topic <topic>` (see **Recording Learnings**).
11
+ 5. Reply normally. The run loop completes the task when your turn ends and hands you the next one in a fresh turn — you never read or write a queue file.
18
12
 
19
13
  ## Execution
20
14
 
@@ -44,13 +38,13 @@ Run `/load-slice sliceId=<payload.sliceId>` to fetch full slice details (title,
44
38
 
45
39
  Inspect the `sliceStatus` in the payload:
46
40
 
47
- #### `Handover` — build the slice
41
+ #### `Waiting` — build the slice
48
42
 
49
43
  This is the build trigger. Setting `InProgress` and building are one atomic step:
50
44
 
51
45
  1. Immediately call `/update-slice-status` to set the slice to `InProgress` on the board.
52
46
 
53
- **Claim conflict**: if this call reports the slice is already in `InProgress` (or any status other than `Handover`), another agent already claimed it first — this is expected, not an error. Log it in `progress.txt`, drop this task without building, and continue the loop (the next task will naturally cover the next slice). Do not retry.
47
+ **Claim conflict**: if this call reports the slice is already in `InProgress` (or any status other than `Waiting`), another agent already claimed it first — this is expected, not an error. Say so in your reply, drop this task without building, and continue the loop (the next task will naturally cover the next slice). Do not retry.
54
48
 
55
49
  2. Run `/load-slice sliceId=<payload.sliceId>` to fetch the full slice, then read the slice definition from `.build-kit/.slices/<contextSlug>/<sliceFolder>/slice.json`. The runner keeps a `slice.json` fresh from a summary endpoint, so a file holding only `id`, `title`, `status` and `sliceType` is that stub, not an empty slice — never conclude a slice has no elements from it. Only if the full fetch itself returns no commands/events/read models/fields is the slice actually empty.
56
50
 
@@ -62,7 +56,34 @@ This is the build trigger. Setting `InProgress` and building are one atomic step
62
56
 
63
57
  4. Invoke the matching skill and follow its instructions **completely**. Do NOT implement the slice manually.
64
58
 
65
- 5. **Verify against slice.json**: cross-check the implementation — every command field, event field, and specification in slice.json must appear in the code. No invented fields — if it is not in slice.json, it must not be in the code.
59
+ **UI baseline gate** — before touching any code, run `npx @eventmodelers/cli ui-baseline check`. It
60
+ compares the board's node hashes (the slice's screen and every element) and `codeGen.uiPrompts` with
61
+ what was recorded after the last UI build, and decides what this build has to do:
62
+ - `UNCHANGED` — nothing on the board changed since the last UI build. Skip all UI work; do not
63
+ re-fetch or diff the screen. Only now is "no code changes needed" a valid outcome.
64
+ - `NO_BASELINE` — no UI build recorded yet (first build, or the slice predates the baseline). Do one
65
+ full screen diff (below), apply every UI prompt.
66
+ - `UNKNOWN` — the board could not be read. Treat it as `NO_BASELINE`; never as `UNCHANGED`.
67
+ - `CHANGED` — it also lists, per element, what changed, was added or was removed since the last recorded
68
+ build (e.g. `changed: Contact Details (screen), Assign Tag (command)`). Work on exactly those nodes
69
+ and leave what matches alone. Act on the parts it flags:
70
+ - `SCREEN_CHANGED`: re-fetch the live screen node (`get_node`, its `meta.pages` / `meta.marks`) —
71
+ never trust the JSX already in the repo — and diff the existing component(s) against the marked
72
+ (or whole, if unmarked) HTML: tags, classes, layout, copy, fields/buttons added, removed or
73
+ reordered, and `cssFrameworks`. Edit the components (and `src/pages/<ScreenTitle>.tsx`, for this
74
+ slice's marked position only) until they match 1:1 and update `samples/`. Keep what already
75
+ matches; do not regenerate the slice from scratch.
76
+ - `ELEMENTS_CHANGED`: diff slice.json against the code field by field (fields,
77
+ `apiEndpoint`/UI contract) and fix every drift.
78
+ - `PROMPTS_CHANGED`: apply the UI prompts it prints — each is an instruction the user typed on the
79
+ board for this slice's UI (e.g. "adjust the UI to the new layout!") — to the component(s) and
80
+ screen markup. Name each prompt and the change you made for it in your final reply.
81
+
82
+ When the UI work is done and the checks in step 6 pass, run `npx @eventmodelers/cli ui-baseline record`
83
+ **before committing**, so `ui-baseline.json` is committed with the slice. Never record without having
84
+ done the work the verdict asked for.
85
+
86
+ 5. **Verify against slice.json**: first check where every displayed value comes from — screen examples are samples, so names, selections, options and list rows must be bound to the read model (grep the components for the mockup's example strings; hits outside `samples/` are hardcoded data and must be fixed). Then cross-check the implementation — every command field, event field, and specification in slice.json must appear in the code — specifications are read (Step 3a of the build skill) to understand how the UI should behave and present outcomes; the business logic itself lives in the backend and is not re-implemented here. No invented fields — if it is not in slice.json, it must not be in the code.
66
87
 
67
88
  6. Run `npm run build` and `npm run lint` (both must pass clean) — plus the slice's own tests only, if any exist.
68
89
 
@@ -76,26 +97,22 @@ This is the build trigger. Setting `InProgress` and building are one atomic step
76
97
  Another agent is already building this slice. Log it and skip — do not build.
77
98
 
78
99
  #### `Done`
79
- Summarize what was completed and update `progress.txt`.
100
+ Summarize what was completed in your reply.
80
101
 
81
102
  #### `Blocked`
82
- Log the blocker in `progress.txt`.
103
+ State the blocker in your reply.
83
104
 
84
105
  #### `Review`
85
- Fetch slice details and prepare a review summary in `progress.txt`.
106
+ Fetch slice details and prepare a review summary in your reply.
86
107
 
87
108
  #### Any other status (`Created`, etc.)
88
- Load the slice and log the state transition in `progress.txt`. No build action.
109
+ Load the slice and note the state transition in your reply. No build action.
89
110
 
90
111
  Use the skills available in `.claude/skills/` to interact with the board.
91
112
 
92
- ## Updating tasks.json
93
-
94
- After completing a task, remove it from the array and write the updated array back to `.build-kit/tasks.json`. If the array is now empty, write `[]`.
95
-
96
113
  ## Escalating Ambiguity
97
114
 
98
- **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line in `progress.txt` and as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
115
+ **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
99
116
 
100
117
  **Exception: a missing `apiEndpoint`** (no backend endpoint/table decided yet) is a partial version of
101
118
  this — flag it, but don't fully stop. `build-state-change`/`build-state-view` Step 1 cover the exact
@@ -105,31 +122,18 @@ sample data. The slice ends this run `Blocked` (step 8 above does not apply for
105
122
  `Blocked` instead of setting `Done`), but the code is there, mocked, ready to be pointed at the real
106
123
  API once one exists.
107
124
 
108
- ## Progress Report Format
109
-
110
- APPEND to `progress.txt` (never replace):
111
- ```
112
- ## [ISO timestamp] — Task [task.id]
113
-
114
- Slice: [sliceTitle] ([sliceId])
115
- Status change: [sliceStatus]
125
+ ## Recording Learnings
116
126
 
117
- Action taken:
118
- - [what was done in response to the slice change]
127
+ `.build-kit/AGENTS.md` is generated from the learnings recorded so far — read it at the start of every session, never edit it by hand. Record a learning the moment you have it:
119
128
 
120
- Learnings:
121
- - [any patterns, gotchas, or reusable knowledge discovered]
122
- ---
129
+ ```
130
+ npx @eventmodelers/cli learn "<one terse line>" --topic "<topic>"
123
131
  ```
124
132
 
125
- ## Stop Condition
126
-
127
- If `.build-kit/tasks.json` is empty (`[]`) or does not exist, reply with:
128
- <promise>IDLE</promise>
129
-
130
- ## Updating AGENT.md
131
-
132
- After completing a task, add any **reusable** learnings to `AGENT.md` — patterns, gotchas, API quirks, or skill behaviour that future iterations should know. Only add things that are general and applicable beyond this single task. Do not duplicate what is already there.
133
+ - Only what is genuinely reusable: codebase patterns, gotchas, commands that work or don't, conventions — and, after a failed approach, what was tried and why it failed. Not slice-specific details, and nothing the code or git log already says.
134
+ - One learning per call, one line each. A learning that is already in `.build-kit/AGENTS.md` is skipped for you.
135
+ - `--scope system` for what is true of the modeled domain (a business rule, a naming convention of the model); `repo` (the default) for the codebase and its tooling. `--tag <tag>` labels it (repeatable).
136
+ - One in `.build-kit/AGENTS.md` that turned out wrong or obsolete: `npx @eventmodelers/cli learnings --ids` lists each with its id, `npx @eventmodelers/cli learn --retract <id>` removes it.
133
137
 
134
138
  ## Important
135
139
 
@@ -39,16 +39,16 @@ Ignore case for files and slices in prompts. "CartItems" slice is the same as "c
39
39
 
40
40
  Do not change test files unless explicitly instructed, or the change brings the test in line with slice.json (e.g. step 4's field/spec diff).
41
41
 
42
- At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings.
42
+ At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings. It is generated from the learnings recorded so far — record a new one with `npx @eventmodelers/cli learn "<one terse line>" --topic <topic>`, never by editing the file.
43
43
 
44
- When starting to work on a slice, invoke the `update-slice-status` skill with `InProgress` status before doing anything else.
44
+ When working from a queued task, invoke the `update-slice-status` skill with `InProgress` status before doing anything else. When the task request names the slice to build (a run-loop build), the run loop has already set it to `InProgress` and pushes the final status itself — do not call `update-slice-status`; record the outcome with `npx @eventmodelers/cli slice-status <status>`.
45
45
 
46
46
  ## Building a Slice
47
47
 
48
48
  **CRITICAL: You MUST always use the provided skills to build slices. NEVER implement a slice manually.**
49
49
  **ALL fields, event names, command names, and business rules MUST come exclusively from slice.json. Do NOT invent, assume, or guess any field or logic not present in the slice definition.**
50
50
 
51
- **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line in `progress.txt` and as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
51
+ **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
52
52
 
53
53
  When asked to build a slice, always follow this flow:
54
54
 
@@ -59,9 +59,10 @@ When asked to build a slice, always follow this flow:
59
59
  - **State-view** — `projections` or `queries` array is non-empty → invoke `/build-state-view`
60
60
  - **State-change** — default (has `commands` / `events`) → invoke `/build-state-change`
61
61
  3. Invoke the matching skill and follow its instructions completely. Do not deviate.
62
- 4. **Verify against slice.json**: After the skill completes, check that every command field, event field, and specification in slice.json appears in the implementation. No invented fields — if it is not in slice.json, it must not be in the code. This applies even when the slice was previously `Done` and reappears as `Planned` — never dismiss a mismatch as "already implemented" or harmless drift; diff slice.json against the code field by field and update the code to match every change.
63
- 5. Run quality checks (`./mvnw compile -q`, then the slice tests only).
64
- 6. If checks pass, commit with `feat: [Slice Name]` and set slice status to `Done`. For STATE_VIEW/STATE_CHANGE slices when `handover` is enabled the status to set is `Handover`, not `Done` — see the `ui-contract` skill, Step 4.
62
+ 4. **Baseline gate**: run `npx @eventmodelers/cli build-baseline check --scope backend` first and act only on its verdict — `UNCHANGED` means nothing on the board changed since the last recorded build: do not rebuild, just run the slice's tests and finish; `NO_BASELINE`/`UNKNOWN` mean one full field-by-field diff of slice.json against the code; `CHANGED` lists exactly which elements changed, were added or removed — diff and fix only those. After the checks pass and before committing, run `build-baseline record --scope backend`. A screen or UI prompt change never triggers a backend build.
63
+ 5. **Verify against slice.json**: After the skill completes, check that every command field, event field, and specification in slice.json appears in the implementation. No invented fields — if it is not in slice.json, it must not be in the code. This applies even when the slice was previously `Done` and reappears as `Planned` — never dismiss a mismatch as "already implemented" or harmless drift; diff slice.json against the code field by field and update the code to match every change.
64
+ 6. Run quality checks (`./mvnw compile -q`, then the slice tests only).
65
+ 7. If checks pass, commit with `feat: [Slice Name]` and set slice status to `Done`. For STATE_VIEW/STATE_CHANGE slices when `handover` is enabled the status to set is `Waiting`, not `Done` — see the `ui-contract` skill, Step 4.
65
66
 
66
67
  After you are done, automatically run the tests for the slice that was edited.
67
68
 
@@ -1,12 +1,11 @@
1
- # Agent Learnings
1
+ # Agent Reference
2
2
 
3
- Patterns and gotchas discovered during task processing. Update this file whenever you encounter something reusable.
3
+ What task processing relies on: the shape of a task and the API facts the skills use. A reusable learning is recorded with `npx @eventmodelers/cli learn "<one terse line>"`, not added here.
4
4
 
5
- ## tasks.json
5
+ ## Tasks
6
6
 
7
- - Tasks are objects with `id`, `createdAt`, and `payload` (a `SliceChangedPayload`).
8
- - After completing a task, remove it from the array entirely — do not add a status field.
9
- - Write `[]` to `tasks.json` if the last task is completed.
7
+ - A task is a slice change the run loop queued: an `id` and a `payload` (a `SliceChangedPayload`). The task request names it.
8
+ - You never read or write a queue file: the run loop completes the task when your turn ends.
10
9
 
11
10
  ## SliceChangedPayload fields
12
11
 
@@ -44,4 +43,4 @@ These files are always up to date — read them directly before invoking any ski
44
43
  - The `boardId` and `organizationId` from each payload provide full context — pass them to skills.
45
44
  - Node events use `node:created`, `node:changed`, `node:deleted` — always POST to `/api/org/:orgId/boards/:boardId/nodes/events`.
46
45
  - Slice metadata (title, status) lives on the SLICE_BORDER node under `meta.sliceStatus` and `meta.title`.
47
- - `/update-slice-status` rejects moving a slice into a status it's already in — this is a concurrency guard, not a bug. It means another agent already claimed the slice. Treat it as `ALREADY_IN_STATUS`, skip that slice, and move on to the next `Planned` one instead of erroring out.
46
+ - `/update-slice-status` rejects moving a slice into a status it's already in — this is a concurrency guard, not a bug. It means another agent already claimed the slice. Treat it as `ALREADY_IN_STATUS`, skip that slice, and move on to the next `Planned` one instead of erroring out. This applies to queued tasks only: when the task request names the slice to build, the run loop owns its status — never call `/update-slice-status` there.