@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.
- package/README.md +48 -36
- package/RELEASE_NOTES.md +20 -2
- package/cli.js +774 -247
- package/lib/adapters/spec-kitty-adapter.js +3 -7
- package/lib/build-kits.js +23 -0
- package/lib/global-agent-id.js +45 -0
- package/lib/modeling-local-ai.js +4 -2
- package/lib/scaffold-model.js +71 -0
- package/lib/scaffold.js +224 -0
- package/lib/supervise.js +60 -0
- package/lib/ui-baseline.js +123 -0
- package/package.json +1 -1
- package/shared/build-kit/README.md +4 -19
- package/shared/build-kit/lib/agent-lock.js +75 -0
- package/shared/build-kit/lib/agent-name.js +27 -0
- package/shared/build-kit/lib/event-prune.js +58 -0
- package/shared/build-kit/lib/events-view.js +134 -0
- package/shared/build-kit/lib/local-ai-agent.js +14 -26
- package/shared/build-kit/lib/mcp-register.js +17 -1
- package/shared/build-kit/lib/prompt-journal.js +191 -0
- package/shared/build-kit/lib/prompt-replay.js +35 -0
- package/shared/build-kit/lib/ralph.js +218 -169
- package/shared/build-kit/lib/slice-curation.js +40 -0
- package/shared/build-kit/lib/slice-events.js +93 -0
- package/shared/build-kit/lib/slice-git.js +86 -0
- package/shared/build-kit/lib/slice-learnings.js +197 -0
- package/shared/build-kit/lib/slice-projection.js +101 -0
- package/shared/build-kit/lib/slice-run.js +181 -0
- package/shared/build-kit/lib/slice-state.js +184 -0
- package/shared/build-kit/lib/slice-tasks.js +35 -0
- package/shared/build-kit/ralph-claude.js +4 -2
- package/shared/build-kit/ralph-exec.js +4 -2
- package/shared/build-kit/ralph-local-ai.js +5 -3
- package/shared/scaffold/LICENSE-em-scaffold +21 -0
- package/shared/scaffold/supabase/generate.mjs +290 -0
- package/shared/scaffold/supabase/template/scripts/create-user.mjs.tmpl +29 -0
- package/shared/scaffold/supabase/template/scripts/dev.mjs.tmpl +145 -0
- package/shared/scaffold/supabase/template/scripts/write-env.mjs.tmpl +44 -0
- package/shared/scaffold/supabase/template/server.ts.tmpl +168 -0
- package/shared/scaffold/supabase/template/src/common/extraEndpoints.ts.tmpl +5 -0
- package/shared/scaffold/supabase/template/src/common/notImplemented.test.ts.tmpl +58 -0
- package/shared/scaffold/supabase/template/src/common/notImplemented.ts.tmpl +29 -0
- package/shared/scaffold/supabase/template/supabase/migrations/_V0__supabase_stubs.sql.tmpl +34 -0
- package/shared/scaffold/supabase/template/web/src/App.tsx.tmpl +38 -0
- package/shared/scaffold/supabase/template/web/src/app/Layout.tsx.tmpl +48 -0
- package/shared/scaffold/supabase/template/web/src/app/NotFound.tsx.tmpl +12 -0
- package/shared/scaffold/supabase/template/web/src/app/SignIn.tsx.tmpl +42 -0
- package/shared/scaffold/supabase/template/web/src/app/TimelinePage.tsx.tmpl +73 -0
- package/shared/scaffold/supabase/template/web/src/app/pages.ts.tmpl +26 -0
- package/shared/scaffold/supabase/template/web/src/app/skeleton.css.tmpl +25 -0
- package/shared/scaffold/supabase/template/web/src/lib/NotBuilt.tsx.tmpl +12 -0
- package/shared/scaffold/supabase/template/web/src/lib/api.ts.tmpl +226 -0
- package/shared/scaffold/supabase/template/web/src/main.tsx.tmpl +13 -0
- package/shared/skills/learn-eventmodelers-api/SKILL.md +17 -4
- package/shared/skills/request-feedback/SKILL.md +1 -2
- package/shared/skills/ui-contract/SKILL.md +7 -5
- package/shared/skills/update-slice-status/SKILL.md +1 -1
- package/stacks/axon/templates/build-kit/CLAUDE.md +7 -6
- package/stacks/axon/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/axon/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/axon/templates/build-kit/lib/prompt.md +32 -41
- package/stacks/blank/templates/build-kit/CLAUDE.md +7 -6
- package/stacks/blank/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/blank/templates/build-kit/lib/backend-prompt.md +20 -37
- package/stacks/blank/templates/build-kit/lib/prompt.md +33 -42
- package/stacks/classic/templates/.claude/skills/build-automation/SKILL.md +1 -1
- package/stacks/classic/templates/.claude/skills/build-state-change/SKILL.md +1 -1
- package/stacks/classic/templates/.claude/skills/build-state-view/SKILL.md +2 -2
- package/stacks/classic/templates/.claude/skills/record-evidence/SKILL.md +2 -2
- package/stacks/classic/templates/build-kit/CLAUDE.md +9 -8
- package/stacks/classic/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/classic/templates/build-kit/lib/backend-prompt.md +20 -38
- package/stacks/classic/templates/build-kit/lib/prompt.md +33 -42
- package/stacks/kurrent/templates/build-kit/CLAUDE.md +7 -7
- package/stacks/kurrent/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/kurrent/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/kurrent/templates/build-kit/lib/prompt.md +32 -41
- package/stacks/modeling-kit/templates/.claude/skills/analyze-existing-model/SKILL.md +1 -1
- package/stacks/modeling-kit/templates/.claude/skills/detect-model-drift/SKILL.md +1 -1
- package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-core-rules/SKILL.md +2 -0
- package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-elaborating-scenarios/SKILL.md +7 -3
- package/stacks/modeling-kit/templates/.claude/skills/wdyt/SKILL.md +1 -1
- package/stacks/modeling-kit/templates/kit/CLAUDE-STANDALONE.md +3 -4
- package/stacks/modeling-kit/templates/kit/CLAUDE.md +18 -28
- package/stacks/modeling-kit/templates/kit/README.md +1 -1
- package/stacks/modeling-kit/templates/kit/lib/config.js +1 -1
- package/stacks/node/templates/build-kit/CLAUDE.md +7 -6
- package/stacks/node/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/node/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/node/templates/build-kit/lib/prompt.md +18 -41
- package/stacks/opencqrs/templates/build-kit/CLAUDE.md +7 -7
- package/stacks/opencqrs/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/opencqrs/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/opencqrs/templates/build-kit/lib/prompt.md +32 -41
- package/stacks/react/templates/.claude/skills/build-state-change/SKILL.md +1 -1
- package/stacks/react/templates/.claude/skills/build-state-view/SKILL.md +1 -1
- package/stacks/react/templates/build-kit/CLAUDE.md +7 -6
- package/stacks/react/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/react/templates/build-kit/lib/backend-prompt.md +25 -42
- package/stacks/react/templates/build-kit/lib/kit.json +1 -1
- package/stacks/react/templates/build-kit/lib/prompt.md +47 -43
- package/stacks/supabase/templates/.claude/skills/build-state-view/SKILL.md +15 -0
- package/stacks/supabase/templates/build-kit/CLAUDE.md +7 -6
- package/stacks/supabase/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/supabase/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/supabase/templates/build-kit/lib/prompt.md +18 -41
- package/stacks/supabase-react/templates/.claude/skills/build-state-change/SKILL.md +80 -8
- package/stacks/supabase-react/templates/.claude/skills/build-state-view/SKILL.md +66 -13
- package/stacks/supabase-react/templates/build-kit/CLAUDE.md +8 -7
- package/stacks/supabase-react/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/supabase-react/templates/build-kit/lib/backend-prompt.md +25 -42
- package/stacks/supabase-react/templates/build-kit/lib/kit.json +1 -1
- package/stacks/supabase-react/templates/build-kit/lib/prompt.md +48 -44
- package/stacks/umadb/templates/build-kit/CLAUDE.md +7 -6
- package/stacks/umadb/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/umadb/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/umadb/templates/build-kit/lib/prompt.md +32 -41
- package/shared/bridge/spec-kitty/bridge-spec-kitty-specify/SKILL.md +0 -125
- package/shared/bridge/spec-kitty/bridge-spec-kitty-tasks/SKILL.md +0 -95
- package/shared/build-kit/lib/agent.sh +0 -20
- package/shared/build-kit/ralph.sh +0 -111
- package/shared/build-kit/realtime-agent.js +0 -20
- package/stacks/bridge/templates/bridge/lib/AGENT.md +0 -47
- package/stacks/bridge/templates/bridge/lib/prompt.md +0 -111
- package/stacks/bridge/templates/bridge/ralph-claude.js +0 -50
- package/stacks/bridge/templates/bridge/ralph-hook.js +0 -103
- package/stacks/bridge/templates/bridge/ralph-local-ai.js +0 -43
- package/stacks/bridge/templates/bridge/ralph-static.js +0 -90
|
@@ -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
|
|
8
|
-
2.
|
|
9
|
-
3.
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
#### `
|
|
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 `
|
|
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,6 +56,33 @@ 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
|
|
|
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
|
+
|
|
65
86
|
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.
|
|
66
87
|
|
|
67
88
|
6. Run quality checks (TODO: your stack's build + test commands — slice-scoped tests only, not the full suite).
|
|
@@ -74,52 +95,35 @@ This is the build trigger. Setting `InProgress` and building are one atomic step
|
|
|
74
95
|
Another agent is already building this slice. Log it and skip — do not build.
|
|
75
96
|
|
|
76
97
|
#### `Done`
|
|
77
|
-
Summarize what was completed
|
|
98
|
+
Summarize what was completed in your reply.
|
|
78
99
|
|
|
79
100
|
#### `Blocked`
|
|
80
|
-
|
|
101
|
+
State the blocker in your reply.
|
|
81
102
|
|
|
82
103
|
#### `Review`
|
|
83
|
-
Fetch slice details and prepare a review summary in
|
|
104
|
+
Fetch slice details and prepare a review summary in your reply.
|
|
84
105
|
|
|
85
106
|
#### Any other status (`Created`, etc.)
|
|
86
|
-
Load the slice and
|
|
107
|
+
Load the slice and note the state transition in your reply. No build action.
|
|
87
108
|
|
|
88
109
|
Use the skills available in `.claude/skills/` to interact with the board.
|
|
89
110
|
|
|
90
|
-
## Updating tasks.json
|
|
91
|
-
|
|
92
|
-
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 `[]`.
|
|
93
|
-
|
|
94
111
|
## Escalating Ambiguity
|
|
95
112
|
|
|
96
|
-
**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
|
|
97
|
-
|
|
98
|
-
## Progress Report Format
|
|
99
|
-
|
|
100
|
-
APPEND to `progress.txt` (never replace):
|
|
101
|
-
```
|
|
102
|
-
## [ISO timestamp] — Task [task.id]
|
|
113
|
+
**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".
|
|
103
114
|
|
|
104
|
-
|
|
105
|
-
Status change: [sliceStatus]
|
|
115
|
+
## Recording Learnings
|
|
106
116
|
|
|
107
|
-
|
|
108
|
-
- [what was done in response to the slice change]
|
|
117
|
+
`.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:
|
|
109
118
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
---
|
|
119
|
+
```
|
|
120
|
+
npx @eventmodelers/cli learn "<one terse line>" --topic "<topic>"
|
|
113
121
|
```
|
|
114
122
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
## Updating AGENT.md
|
|
121
|
-
|
|
122
|
-
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.
|
|
123
|
+
- 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.
|
|
124
|
+
- One learning per call, one line each. A learning that is already in `.build-kit/AGENTS.md` is skipped for you.
|
|
125
|
+
- `--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).
|
|
126
|
+
- 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.
|
|
123
127
|
|
|
124
128
|
## Important
|
|
125
129
|
|
|
@@ -42,8 +42,22 @@ CREATE TABLE IF NOT EXISTS "public"."{tablename}"
|
|
|
42
42
|
-- use snake_case for all column names
|
|
43
43
|
created_at TIMESTAMP DEFAULT NOW()
|
|
44
44
|
);
|
|
45
|
+
|
|
46
|
+
-- The UI reads this table DIRECTLY through Supabase (no read endpoint in between), so it must be readable.
|
|
47
|
+
-- RLS on with no policy returns an EMPTY list, not an error - always ship the policy with the table.
|
|
48
|
+
ALTER TABLE "public"."{tablename}" ENABLE ROW LEVEL SECURITY;
|
|
49
|
+
GRANT SELECT ON "public"."{tablename}" TO authenticated;
|
|
50
|
+
CREATE POLICY "{tablename}_select" ON "public"."{tablename}"
|
|
51
|
+
FOR SELECT TO authenticated USING (true);
|
|
45
52
|
```
|
|
46
53
|
|
|
54
|
+
**The UI reads the read-model table directly.** The frontend never goes through the `GET` route for a
|
|
55
|
+
read model: it selects from this table with the user's session, and Row Level Security decides which
|
|
56
|
+
rows come back. `USING (true)` is the default (every signed-in user sees every row); when the read
|
|
57
|
+
model is per user or per tenant (an owner/user/tenant column, or `description`/`comments[]` say so),
|
|
58
|
+
narrow the policy to it, e.g. `USING (owner_id = auth.uid()::text)`. The `GET` route in Step 5 stays
|
|
59
|
+
for API consumers and tests; the UI does not depend on it.
|
|
60
|
+
|
|
47
61
|
**Column type guide** — field `type` values are the canonical set from the [event-modeling-spec schema](https://github.com/dilgerma/event-modeling-spec/blob/main/eventmodeling.schema.json):
|
|
48
62
|
|
|
49
63
|
| Field type | SQL type |
|
|
@@ -487,6 +501,7 @@ src/common/
|
|
|
487
501
|
## Checklist
|
|
488
502
|
|
|
489
503
|
- [ ] Migration file created with correct version number and all columns
|
|
504
|
+
- [ ] Migration enables RLS, grants `SELECT` to `authenticated` and creates a select policy: the UI reads the table directly, and no policy means an empty list
|
|
490
505
|
- [ ] `tableName` constant matches the migration table name exactly
|
|
491
506
|
- [ ] Projection registered in `loadPostgresEventstore.ts`
|
|
492
507
|
- [ ] `canHandle` lists every event type the projection reacts to
|
|
@@ -28,16 +28,16 @@ Ignore case for files and slices in prompts. "CartItems" slice is the same as "c
|
|
|
28
28
|
|
|
29
29
|
Do not change files with tests unless explicitely instructed, or the change brings the test in line with slice.json (e.g. step 4's field/spec diff): *.test.ts
|
|
30
30
|
|
|
31
|
-
At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings.
|
|
31
|
+
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.
|
|
32
32
|
|
|
33
|
-
When
|
|
33
|
+
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>`.
|
|
34
34
|
|
|
35
35
|
## Building a Slice
|
|
36
36
|
|
|
37
37
|
**CRITICAL: You MUST always use the provided skills to build slices. NEVER implement a slice manually.**
|
|
38
38
|
**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.**
|
|
39
39
|
|
|
40
|
-
**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
|
|
40
|
+
**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".
|
|
41
41
|
|
|
42
42
|
When asked to build a slice, always follow this flow:
|
|
43
43
|
|
|
@@ -49,9 +49,10 @@ When asked to build a slice, always follow this flow:
|
|
|
49
49
|
- **State-view** — `projections` or `queries` array is non-empty → invoke `/build-state-view`
|
|
50
50
|
- **State-change** — default (has `commands` / `events`) → invoke `/build-state-change`
|
|
51
51
|
3. Invoke the matching skill and follow its instructions completely. Do not deviate.
|
|
52
|
-
4. **
|
|
53
|
-
5.
|
|
54
|
-
6.
|
|
52
|
+
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.
|
|
53
|
+
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.
|
|
54
|
+
6. Run quality checks (`npm run build`, then the slice tests only).
|
|
55
|
+
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.
|
|
55
56
|
|
|
56
57
|
After you are done, automatically run the tests for the slice that was edited.
|
|
57
58
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
# Agent
|
|
1
|
+
# Agent Reference
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
5
|
+
## Tasks
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
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.
|
|
@@ -17,16 +17,15 @@ You work within **exactly ONE context at a time** — the one named in `.build-k
|
|
|
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 "planned" is a task.
|
|
20
|
-
2. Read
|
|
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.
|
|
23
|
-
**IMPORTANT: Only work on
|
|
22
|
+
5. Your slice is the one the task request names (the run loop picked the highest priority slice with status "Planned"); 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 "Planned" 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 "Planned", and try claiming that one instead. Repeat until a claim succeeds or no "Planned" 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.
|
|
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.
|
|
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, make use of the skills in the skills directory, but also your previsously collected
|
|
31
30
|
knowledge. Make a list TODO list for what needs to be done. Also make sure to 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 "planned" 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.
|
|
32
31
|
10. The slice in the json is always true, the code follows what is defined in the json
|
|
@@ -37,48 +36,27 @@ You work within **exactly ONE context at a time** — the one named in `.build-k
|
|
|
37
36
|
14. even if the slice is fully implemented, run your test-analyzer skill and provide the code-slice.json file as defined in the skill
|
|
38
37
|
15. If checks pass, commit ALL changes with message: `feat: [Slice Name]` and merge back to main as FF merge ( update
|
|
39
38
|
first )
|
|
40
|
-
16.
|
|
41
|
-
17.
|
|
42
|
-
18.
|
|
39
|
+
16. 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. For STATE_VIEW/STATE_CHANGE slices when `handover` is enabled the status to record is `Waiting`, not `Done` — see the `ui-contract` skill, Step 4. A slice you could not finish needs no status: leave it as it is and the run loop discards the attempt.
|
|
40
|
+
17. Record any reusable learning you have not recorded yet (see **Recording Learnings**).
|
|
41
|
+
18. If an entry in `.build-kit/AGENTS.md` turned out wrong or obsolete, retract it (see **Recording Learnings**).
|
|
43
42
|
19. Finish the iteration.
|
|
44
43
|
|
|
45
44
|
## Escalating Ambiguity
|
|
46
45
|
|
|
47
|
-
**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
|
|
46
|
+
**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".
|
|
48
47
|
|
|
49
|
-
##
|
|
48
|
+
## Recording Learnings
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
`.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:
|
|
52
51
|
|
|
53
52
|
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
- What was implemented
|
|
57
|
-
- Files changed
|
|
58
|
-
- **Learnings for future iterations:**
|
|
59
|
-
- Patterns discovered (e.g., "this codebase uses X for Y")
|
|
60
|
-
- Gotchas encountered (e.g., "don't forget to update Z when changing W")
|
|
61
|
-
- Useful context (e.g., "the evaluation panel is in component X")
|
|
62
|
-
---
|
|
53
|
+
npx @eventmodelers/cli learn "<one terse line>" --topic "<topic>"
|
|
63
54
|
```
|
|
64
55
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
If you discover a **reusable pattern** that future iterations should know, add it to the `## Codebase Patterns` section
|
|
71
|
-
at the TOP of progress.txt (create it if it doesn't exist). This section should consolidate the most important
|
|
72
|
-
learnings:
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
## Codebase Patterns
|
|
76
|
-
- Example: Use `sql<number>` template for aggregations
|
|
77
|
-
- Example: Always use `IF NOT EXISTS` for migrations
|
|
78
|
-
- Example: Export types from actions.ts for UI components
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Only add patterns that are **general and reusable**, not story-specific details.
|
|
56
|
+
- 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.
|
|
57
|
+
- One learning per call, one line each. A learning that is already in `.build-kit/AGENTS.md` is skipped for you.
|
|
58
|
+
- `--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).
|
|
59
|
+
- 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.
|
|
82
60
|
|
|
83
61
|
## Update AGENTS.md Files
|
|
84
62
|
|
|
@@ -104,7 +82,7 @@ Before committing, check if any edited files have learnings worth preserving in
|
|
|
104
82
|
- Slice specific implementation details
|
|
105
83
|
- Story-specific implementation details
|
|
106
84
|
- Temporary debugging notes
|
|
107
|
-
- Information already in
|
|
85
|
+
- Information already recorded as a learning in `.build-kit/AGENTS.md`
|
|
108
86
|
- Task speecific learnings like "- Timesheet approval requires: submitted=true, reverted=false, approved=false, declined=false"
|
|
109
87
|
|
|
110
88
|
Only update AGENTS.md if you have **genuinely reusable knowledge** that would help future work
|
|
@@ -148,9 +126,9 @@ If ALL slices in the current context are Done, reply with:
|
|
|
148
126
|
- 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.
|
|
149
127
|
- Work on ONE slice per iteration
|
|
150
128
|
- Commit frequently
|
|
151
|
-
-
|
|
152
|
-
- Read
|
|
129
|
+
- Record learnings as you go with `learn`
|
|
130
|
+
- Read `.build-kit/AGENTS.md` before starting
|
|
153
131
|
|
|
154
132
|
## When an iteration completes
|
|
155
133
|
|
|
156
|
-
|
|
134
|
+
Make sure every reusable learning is recorded with `learn`; `.build-kit/AGENTS.md` is generated from them — never edit it by hand.
|
|
@@ -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
|
|
8
|
-
2.
|
|
9
|
-
3.
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
|
@@ -48,11 +42,11 @@ Inspect the `sliceStatus` in the payload:
|
|
|
48
42
|
|
|
49
43
|
This is the build trigger. Setting `InProgress` and building are one atomic step:
|
|
50
44
|
|
|
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
|
|
45
|
+
**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
46
|
|
|
53
47
|
1. Immediately call `/update-slice-status` to set the slice to `InProgress` on the board.
|
|
54
48
|
|
|
55
|
-
**Claim conflict**: if this call reports the slice is already in `InProgress` (or any status other than `Planned`), another agent already claimed it first — this is expected, not an error.
|
|
49
|
+
**Claim conflict**: if this call reports the slice is already in `InProgress` (or any status other than `Planned`), 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.
|
|
56
50
|
|
|
57
51
|
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.
|
|
58
52
|
|
|
@@ -75,48 +69,31 @@ This is the build trigger. Setting `InProgress` and building are one atomic step
|
|
|
75
69
|
Another agent is already building this slice. Log it and skip — do not build.
|
|
76
70
|
|
|
77
71
|
#### `Done`
|
|
78
|
-
Summarize what was completed
|
|
72
|
+
Summarize what was completed in your reply.
|
|
79
73
|
|
|
80
74
|
#### `Blocked`
|
|
81
|
-
|
|
75
|
+
State the blocker in your reply.
|
|
82
76
|
|
|
83
77
|
#### `Review`
|
|
84
|
-
Fetch slice details and prepare a review summary in
|
|
78
|
+
Fetch slice details and prepare a review summary in your reply.
|
|
85
79
|
|
|
86
80
|
#### Any other status (`Created`, etc.)
|
|
87
|
-
Load the slice and
|
|
81
|
+
Load the slice and note the state transition in your reply. No build action.
|
|
88
82
|
|
|
89
83
|
Use the skills available in `.claude/skills/` to interact with the board.
|
|
90
84
|
|
|
91
|
-
##
|
|
85
|
+
## Recording Learnings
|
|
92
86
|
|
|
93
|
-
|
|
87
|
+
`.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:
|
|
94
88
|
|
|
95
|
-
## Progress Report Format
|
|
96
|
-
|
|
97
|
-
APPEND to `progress.txt` (never replace):
|
|
98
89
|
```
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
Slice: [sliceTitle] ([sliceId])
|
|
102
|
-
Status change: [sliceStatus]
|
|
103
|
-
|
|
104
|
-
Action taken:
|
|
105
|
-
- [what was done in response to the slice change]
|
|
106
|
-
|
|
107
|
-
Learnings:
|
|
108
|
-
- [any patterns, gotchas, or reusable knowledge discovered]
|
|
109
|
-
---
|
|
90
|
+
npx @eventmodelers/cli learn "<one terse line>" --topic "<topic>"
|
|
110
91
|
```
|
|
111
92
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
## Updating AGENT.md
|
|
118
|
-
|
|
119
|
-
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.
|
|
93
|
+
- 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.
|
|
94
|
+
- One learning per call, one line each. A learning that is already in `.build-kit/AGENTS.md` is skipped for you.
|
|
95
|
+
- `--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).
|
|
96
|
+
- 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.
|
|
120
97
|
|
|
121
98
|
## Important
|
|
122
99
|
|
|
@@ -61,8 +61,8 @@ Extract:
|
|
|
61
61
|
`requestBody` properties, the 2xx `responses` entry, and every non-2xx response (status + description) — surface each error code as a
|
|
62
62
|
distinct user-facing state through `onError`, not one generic failure. When absent, the backend slice
|
|
63
63
|
isn't built or re-fetched yet: fall back to `apiEndpoint` / `fields[]` as above and note the assumption
|
|
64
|
-
|
|
65
|
-
you record the mismatch
|
|
64
|
+
as a code comment. If contract and `command.fields[]` disagree, the contract wins for the request and
|
|
65
|
+
you record the mismatch as a code comment.
|
|
66
66
|
**Build the call from it**: `postCommand(buildPath('<contract path>', { <path params> }), { <requestBody
|
|
67
67
|
properties> })` — `buildPath` (in `src/lib/api.ts`) fills and URL-encodes `{param}` segments; the body
|
|
68
68
|
carries exactly the contract's `requestBody` properties (props the contract doesn't list stay out).
|
|
@@ -71,8 +71,9 @@ Extract:
|
|
|
71
71
|
- **screens[]** — the actor `SCREEN` element(s) that trigger this command, if any. Empty when the
|
|
72
72
|
command has no UI trigger (rare — build the component from fields alone in that case, skip Step
|
|
73
73
|
2).
|
|
74
|
-
- **specifications[]** — GWT scenarios
|
|
75
|
-
|
|
74
|
+
- **specifications[]** and **storylines[]** (optional) — GWT scenarios / board walkthroughs. These
|
|
75
|
+
describe how the slice should **behave** — read them in full (Step 3a) to understand the outcomes
|
|
76
|
+
and states the UI must present. The business logic itself lives in the backend; the UI does not implement it.
|
|
76
77
|
|
|
77
78
|
> **Comments**: each element carries `comments: string[]` (board comments) — read them as
|
|
78
79
|
> implementation hints, and resolve consumed ones via
|
|
@@ -80,6 +81,10 @@ Extract:
|
|
|
80
81
|
|
|
81
82
|
## Step 2 — Read the screen, and especially its marks
|
|
82
83
|
|
|
84
|
+
> **Gated by `ui-baseline check`** (build prompt, `lib/prompt.md`, Step 4): do this step when the verdict
|
|
85
|
+
> is `SCREEN_CHANGED`, `NO_BASELINE` or `UNKNOWN` — and then also diff the existing JSX against the fetched
|
|
86
|
+
> screen and adjust the UI to it. On `UNCHANGED` skip it.
|
|
87
|
+
|
|
83
88
|
`slice.json`'s `screens[]` entries only carry `id`/`title`/`fields[]`/`description` (fields already
|
|
84
89
|
scoped to this slice) — not the actual markup. Fetch the live node to get that:
|
|
85
90
|
|
|
@@ -132,19 +137,76 @@ lane concept, so the frontend path isn't a strict 1:1 mirror of it. `CommandTitl
|
|
|
132
137
|
**Markup**: translate the blueprint HTML from Step 2 into JSX **1:1** — same tags, same classes
|
|
133
138
|
(the screen's `cssFrameworks` framework), same layout and copy. This is not a redesign; the screen *is*
|
|
134
139
|
the design. Only change what must become dynamic:
|
|
135
|
-
- A field's example value becomes that input's
|
|
140
|
+
- A field's example value becomes that input's **initial/default** `value` only for what the user is
|
|
141
|
+
*entering* (a new-record form). Anything the screen *displays* about an existing entity (names,
|
|
142
|
+
titles, current selection, existing tags, list rows) is **not** static — see "Data binding" below.
|
|
136
143
|
- An element repeated for a `cardinality: "List"` field becomes a `.map()` over that field.
|
|
137
144
|
- `class`/`style`/structure otherwise stay exactly as drawn — except the board's own mark plumbing:
|
|
138
145
|
drop every `data-em-mark-id` attribute and `em-mark`/`em-mark-<hex>` class (they only draw the
|
|
139
146
|
highlight outline on the canvas; the app never ships it).
|
|
140
147
|
- The classes only render correctly if the screen's CSS framework (`cssFrameworks`) is loaded in the app — see Step 7 (styles); don't hand-write CSS to compensate.
|
|
141
148
|
|
|
149
|
+
**Data binding — mockup text is sample data, not copy.** The example values drawn in a screen are
|
|
150
|
+
placeholders from the model. Before translating, classify every piece of text/value in the fragment:
|
|
151
|
+
*label/copy* (headings like "Tags", button captions, placeholders — keep verbatim) vs. *data* (a person's
|
|
152
|
+
name, a role/organisation line, a pre-selected dropdown value, dropdown options, existing list rows,
|
|
153
|
+
badges, counts, dates). For each *data* item find its source in `slice.json` / the model — the
|
|
154
|
+
`readmodels[]` whose fields carry it, or the command's own `fields[]` — and render it from there.
|
|
155
|
+
**Never hardcode a data value from the mockup into JSX.**
|
|
156
|
+
|
|
157
|
+
**Find the screen's data sources on the board, not just in `slice.json`.** A screen is often shown by
|
|
158
|
+
one slice but fed by a read model that belongs to *another* slice (e.g. the Contact Details screen
|
|
159
|
+
sits in the Assign Tag slice, yet its contact data comes from the Contact List read model via an edge
|
|
160
|
+
READMODEL → SCREEN). `slice.json` only lists this slice's own elements, so also call
|
|
161
|
+
`mcp__eventmodelers__get_connected_nodes { boardId, nodeId: <screen.id> }` and take every READMODEL
|
|
162
|
+
wired into the screen. Each one is a data source for the displayed values; look up its fields in that
|
|
163
|
+
read model's slice (`.build-kit/.slices/*/*/slice.json`, or `get_node`). A list read model feeding a
|
|
164
|
+
detail screen (`Contact List[]` → one contact) means: query it filtered by the entity id the page
|
|
165
|
+
gets from the route (match the id field, e.g. `contactId` / the command's `recordId`) and render that
|
|
166
|
+
row. If the source read model's slice isn't built, still type and wire against its fields (TODO), do
|
|
167
|
+
not substitute the mockup's values.
|
|
168
|
+
|
|
169
|
+
- Data comes from a read model (query component of the same page/screen, via `queryReadModel` /
|
|
170
|
+
`getReadModel`) → bind it to that data (props from the parent that fetched it, or fetch it here
|
|
171
|
+
when this component owns that read). If that read-model slice is not built yet, wire the component
|
|
172
|
+
against the typed shape and leave a `// TODO(<read model title>)` — do not paste the example in.
|
|
173
|
+
- Select/dropdown *options* come from a read model (e.g. the customer list), never from the
|
|
174
|
+
options drawn in the mockup; the *selected* value comes from the entity's own read model.
|
|
175
|
+
- The only legitimate static content is label/copy and `VITE_DATA_MODE=mock` samples in `samples/*.json`.
|
|
176
|
+
- Self-check before finishing: grep the component for the mockup's example strings (e.g. the person's
|
|
177
|
+
name, organisation, tag text). Any hit outside `samples/` is a bug.
|
|
178
|
+
|
|
142
179
|
**Props**: exactly `command.fields[]`, typed per each field's `type` (`String`→`string`,
|
|
143
180
|
`Boolean`→`boolean`, `Int`/`Long`→`number`, etc. — `subfields[]` become a nested object type),
|
|
144
181
|
respecting `optional`. Add two callback props: `onSuccess?: (result: TResponse) => void` and
|
|
145
182
|
`onError?: (error: ApiError) => void`. **No other inputs** — no context/store reads, no fetching
|
|
146
183
|
inside the component. All business data the component needs arrives via props from its parent.
|
|
147
184
|
|
|
185
|
+
### Step 3a — Read the scenarios to understand behavior (not to implement rules)
|
|
186
|
+
|
|
187
|
+
**Business logic lives in the backend. The UI never re-implements it.** Do not copy a scenario's
|
|
188
|
+
rules (preconditions, limits, uniqueness, state checks) into the component as validation or guards —
|
|
189
|
+
the backend decides, and a duplicated rule drifts the moment the model changes.
|
|
190
|
+
|
|
191
|
+
Read every entry in `specifications[]` (and the beat runs in `storylines[]` containing this command)
|
|
192
|
+
to understand **how the component should behave around the command**: what the user is trying to
|
|
193
|
+
accomplish, what outcomes exist, and what each outcome must look like. Use them to decide:
|
|
194
|
+
|
|
195
|
+
| Scenario shows | What it tells the UI |
|
|
196
|
+
|---|---|
|
|
197
|
+
| `when` this command → `then` EVENT(s) | the success outcome: what to confirm or reset after `postCommand` resolves, and what `onSuccess` hands the parent |
|
|
198
|
+
| `when` this command → `then` an error / rejection (e.g. "already reserved") | the failure outcomes that exist: render each as its own readable message from the `ApiError` the backend returns — not one generic failure. The backend decides *whether* it fails; the UI only shows it |
|
|
199
|
+
| `optional` fields, fields that vary between scenarios | which inputs are required vs. optional in the form (mirror the flags, no invented rules) |
|
|
200
|
+
| `given` events before the command | context for what the user was doing — background to understand the flow, not logic to reproduce |
|
|
201
|
+
| a `STORYLINE_NOTE` beat | background only |
|
|
202
|
+
|
|
203
|
+
Rules:
|
|
204
|
+
- Understand, don't implement: no business validation, no precondition checks, no computed outcomes
|
|
205
|
+
in the component. Only presentation: states (idle/submitting/success/error), required-vs-optional
|
|
206
|
+
inputs, and showing what the backend returns.
|
|
207
|
+
- If a scenario's outcome needs a UI state the markup doesn't show, add the minimal state and note
|
|
208
|
+
the scenario in a one-line comment (e.g. `// spec: "already reserved" → backend 409 shown inline`).
|
|
209
|
+
|
|
148
210
|
**Default — keep the logic in the component.** For an ordinary command (one form, one submit
|
|
149
211
|
action, which is most of them) local state and the `postCommand` call live directly inside the
|
|
150
212
|
component. This is the common case and needs nothing more:
|
|
@@ -211,9 +273,10 @@ is driven entirely by props, each sample is a **full set of prop values** — th
|
|
|
211
273
|
renders this component in isolation (a `src/pages/` composition, or ad hoc while developing) to
|
|
212
274
|
spread as props, e.g. `<ReserveBike {...sample1} onSuccess={...} />`.
|
|
213
275
|
|
|
214
|
-
Add `sample-1.json` for the ordinary case (`command.fields[].example` values); add
|
|
215
|
-
|
|
216
|
-
|
|
276
|
+
Add `sample-1.json` for the ordinary case (`command.fields[].example` values); add a numbered
|
|
277
|
+
sample for **each** scenario in `specifications[]` that changes what the component does (an invalid
|
|
278
|
+
input that blocks submit, an `optional` field omitted, a precondition that disables the trigger).
|
|
279
|
+
Take the values from the scenario's own example data. As in `build-state-view`, the same number across different components' samples is meant to
|
|
217
280
|
represent one coherent scenario across the app, not an arbitrary per-component index.
|
|
218
281
|
|
|
219
282
|
## Step 5 — Context/Provider, only if the marked fragment needs shared local state
|
|
@@ -290,6 +353,13 @@ how many pages this app needs — not one page per slice.
|
|
|
290
353
|
content there, passing whatever props it declares. Only substitute positions whose slice
|
|
291
354
|
component already exists; leave any not-yet-built slice's marked area as the mockup's static
|
|
292
355
|
placeholder until that slice is built and this step runs again for it.
|
|
356
|
+
- **Unmarked/unbuilt regions are not an excuse to hardcode data.** Static placeholder is only for
|
|
357
|
+
label/copy. A displayed data value (e.g. the contact's name and "role · organisation" line, the
|
|
358
|
+
selected organisation and the organisation dropdown options) must be bound to the read model that
|
|
359
|
+
carries it — if that read model's component exists (e.g. the contact list/details read), fetch
|
|
360
|
+
through it and pass the values down; if not, type the prop and leave a `// TODO(<read model>)`.
|
|
361
|
+
Never paste the mockup's example (or a slice's `samples/sample-1.json`) into the page as the
|
|
362
|
+
data. The page reads the entity id from the route/query param.
|
|
293
363
|
- The page owns threading shared inputs (route/query params, the current session, etc.) down as
|
|
294
364
|
props to each slice component — a slice component still only knows its own declared props, not
|
|
295
365
|
the rest of the page or its siblings.
|
|
@@ -348,6 +418,8 @@ After writing the hook/component (and context/page/base page, if any), confirm:
|
|
|
348
418
|
time, the provisional `/api/mock/...` path noted in a comment (Step 1).
|
|
349
419
|
- At least one numbered sample exists under this slice's `samples/` folder, shaped exactly like
|
|
350
420
|
this component's props.
|
|
421
|
+
- Every scenario outcome (success, each named failure) has a rendered state, and **no business rule
|
|
422
|
+
from a scenario was re-implemented in the component** — the backend owns it.
|
|
351
423
|
- If a screen was read in Step 2, the rendered JSX matches the marked (or whole, if unmarked)
|
|
352
424
|
HTML fragment structurally — no invented buttons/fields the mockup didn't show, nothing from
|
|
353
425
|
the mockup silently dropped.
|