@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
@@ -0,0 +1,226 @@
1
+ import { supabase } from './supabase';
2
+
3
+ /**
4
+ * Common API client — the ONLY place that knows about base URLs, auth headers,
5
+ * correlation/causation tracing, and how to reach Supabase tables. Slice components
6
+ * must never call `fetch` directly, read the Supabase session, or import
7
+ * `./supabase` themselves — they call `postCommand`/`queryReadModel` and handle only
8
+ * the request/response shape their command/read model defines.
9
+ *
10
+ * Every call here has two implementations: a real one (Supabase) and a mock one that
11
+ * serves a numbered sample instead. This is what makes every slice component testable
12
+ * in isolation — flip `VITE_DATA_MODE` to `mock` and every read/write in the app is
13
+ * served from `samples/sample-<VITE_MOCK_SAMPLE>.json` files instead of a live backend.
14
+ */
15
+
16
+ export const API_BASE = import.meta.env.VITE_API_BASE ?? '';
17
+
18
+ /** `true` when reads/writes should be served from samples instead of Supabase/the backend. */
19
+ export function isMockMode(): boolean {
20
+ return import.meta.env.VITE_DATA_MODE === 'mock';
21
+ }
22
+
23
+ /** Which numbered sample set is active in mock mode, e.g. `"1"`, `"2"`. */
24
+ export function activeMockSample(): string {
25
+ return import.meta.env.VITE_MOCK_SAMPLE ?? '1';
26
+ }
27
+
28
+ async function getAuthHeaders(json = true): Promise<Record<string, string>> {
29
+ const {
30
+ data: { session },
31
+ } = await supabase.auth.getSession();
32
+
33
+ return {
34
+ // multipart bodies must leave Content-Type unset so the browser adds the boundary
35
+ ...(json ? { 'Content-Type': 'application/json' } : {}),
36
+ Authorization: session ? `Bearer ${session.access_token}` : '',
37
+ 'x-correlation-id': crypto.randomUUID(),
38
+ 'x-causation-id': crypto.randomUUID(),
39
+ };
40
+ }
41
+
42
+ /** 501 means the endpoint is modeled but its slice is not built yet (distinct from a 404 for a wrong URL). */
43
+ export const NOT_BUILT_MESSAGE = 'This feature is not built yet.';
44
+
45
+ function errorMessage(status: number, payload: { error?: string; message?: string } | undefined): string {
46
+ if (status === 501) return NOT_BUILT_MESSAGE;
47
+ return (payload && (payload.error || payload.message)) || `Request failed with status ${status}`;
48
+ }
49
+
50
+ /** True when an error from this module means "modeled, but its slice is not built yet" (HTTP 501). */
51
+ export function isNotBuilt(err: unknown): boolean {
52
+ return err instanceof ApiError && err.status === 501;
53
+ }
54
+
55
+ export class ApiError extends Error {
56
+ status: number;
57
+ body: unknown;
58
+
59
+ constructor(message: string, status: number, body?: unknown) {
60
+ super(message);
61
+ this.name = 'ApiError';
62
+ this.status = status;
63
+ this.body = body;
64
+ }
65
+ }
66
+
67
+ /**
68
+ * POST a command to `path` (taken verbatim from the command's API description in
69
+ * slice.json — never invented) with `body` as the JSON payload. Resolves with the
70
+ * parsed JSON response, or throws `ApiError` on a non-2xx response.
71
+ *
72
+ * In mock mode this never hits the network — it resolves with `{ ok: true }` so a
73
+ * command component can be exercised (submitting/success states) fully offline.
74
+ */
75
+ export async function postCommand<TResponse = unknown>(
76
+ path: string,
77
+ body: unknown,
78
+ ): Promise<TResponse> {
79
+ if (isMockMode()) {
80
+ return { ok: true } as TResponse;
81
+ }
82
+
83
+ const headers = await getAuthHeaders();
84
+ const res = await fetch(`${API_BASE}${path}`, {
85
+ method: 'POST',
86
+ headers,
87
+ body: JSON.stringify(body),
88
+ });
89
+
90
+ const payload = await res.json().catch(() => undefined);
91
+
92
+ if (!res.ok) {
93
+ throw new ApiError(errorMessage(res.status, payload), res.status, payload);
94
+ }
95
+
96
+ return payload as TResponse;
97
+ }
98
+
99
+ /**
100
+ * POST a multipart/form-data command (e.g. one carrying a file) to `path`. Same contract as
101
+ * `postCommand`: resolves with the parsed JSON response, throws `ApiError` on a non-2xx
102
+ * response, and resolves with `{ ok: true }` locally in mock mode.
103
+ */
104
+ export async function postForm<TResponse = unknown>(
105
+ path: string,
106
+ body: FormData,
107
+ ): Promise<TResponse> {
108
+ if (isMockMode()) {
109
+ return { ok: true } as TResponse;
110
+ }
111
+
112
+ const headers = await getAuthHeaders(false);
113
+ const res = await fetch(`${API_BASE}${path}`, { method: 'POST', headers, body });
114
+
115
+ const payload = await res.json().catch(() => undefined);
116
+
117
+ if (!res.ok) {
118
+ throw new ApiError(errorMessage(res.status, payload), res.status, payload);
119
+ }
120
+
121
+ return payload as TResponse;
122
+ }
123
+
124
+ export interface ReadModelParams {
125
+ /** `readmodel.apiEndpoint`, verbatim — the Postgres table/view name. */
126
+ table: string;
127
+ /** Column names to select, comma-separated (never `'*'`). */
128
+ select: string;
129
+ /** Simple equality filters, e.g. `{ customer_id: customerId }`. */
130
+ filters?: Record<string, unknown>;
131
+ /** `true` for a single-row read model (`.maybeSingle()`), `false` for a list. */
132
+ single?: boolean;
133
+ }
134
+
135
+ /**
136
+ * Read a read model's data — `params.table` via Supabase in the real implementation,
137
+ * or `samples[activeMockSample()]` in mock mode. `samples` is this component's own
138
+ * `samples/sample-*.json` map (see the component for how it's built); every read model
139
+ * component supplies its own, `queryReadModel` never reaches into a slice folder itself.
140
+ */
141
+ export async function queryReadModel<T>(
142
+ params: ReadModelParams,
143
+ samples?: Record<string, T>,
144
+ ): Promise<T> {
145
+ if (isMockMode()) {
146
+ return mockSample(samples, `table "${params.table}"`);
147
+ }
148
+
149
+ let query = supabase.from(params.table).select(params.select);
150
+ for (const [column, value] of Object.entries(params.filters ?? {})) {
151
+ query = query.eq(column, value);
152
+ }
153
+
154
+ const { data, error } = params.single ? await query.maybeSingle() : await query;
155
+ // A read-model table that does not exist yet means its slice is not built: same 501 as the backend fallback.
156
+ if (error && (error.code === '42P01' || error.code === 'PGRST205')) throw new ApiError(NOT_BUILT_MESSAGE, 501, error);
157
+ if (error) throw new ApiError(error.message, 500, error);
158
+ return data as T;
159
+ }
160
+
161
+ /**
162
+ * GET a read model from a backend query route, e.g. `/api/query/orderlist-collection` —
163
+ * for read models whose table has RLS on with no policies (kept off Supabase's Data API),
164
+ * so `queryReadModel` would only ever see an empty result. Resolves with the parsed JSON
165
+ * response, or throws `ApiError` on a non-2xx response; mock-aware like `queryReadModel`.
166
+ */
167
+ export async function getReadModel<T>(path: string, samples?: Record<string, T>): Promise<T> {
168
+ if (isMockMode()) {
169
+ return mockSample(samples, `"${path}"`);
170
+ }
171
+
172
+ const headers = await getAuthHeaders();
173
+ const res = await fetch(`${API_BASE}${path}`, { method: 'GET', headers });
174
+
175
+ const payload = await res.json().catch(() => undefined);
176
+
177
+ if (!res.ok) {
178
+ throw new ApiError(errorMessage(res.status, payload), res.status, payload);
179
+ }
180
+
181
+ return payload as T;
182
+ }
183
+
184
+ async function fetchFile(path: string): Promise<Blob> {
185
+ const headers = await getAuthHeaders(false);
186
+ const res = await fetch(`${API_BASE}${path}`, { method: 'GET', headers });
187
+ if (!res.ok) {
188
+ const payload = await res.json().catch(() => undefined);
189
+ throw new ApiError(errorMessage(res.status, payload), res.status, payload);
190
+ }
191
+ return res.blob();
192
+ }
193
+
194
+ /**
195
+ * GET a binary file (e.g. a generated PDF) from `path` with auth headers and open it in a new
196
+ * browser tab. In mock mode nothing is fetched; the call just resolves.
197
+ */
198
+ export async function openFile(path: string): Promise<void> {
199
+ if (isMockMode()) return;
200
+
201
+ const url = URL.createObjectURL(await fetchFile(path));
202
+ window.open(url, '_blank');
203
+ setTimeout(() => URL.revokeObjectURL(url), 60_000);
204
+ }
205
+
206
+ /**
207
+ * GET a file (e.g. a template logo) from `path` with auth headers and return a blob URL for an
208
+ * `<img src>`, which would send no bearer token itself. The caller revokes it with
209
+ * `URL.revokeObjectURL`. In mock mode nothing is fetched; resolves with `null`.
210
+ */
211
+ export async function fileUrl(path: string): Promise<string | null> {
212
+ if (isMockMode()) return null;
213
+
214
+ return URL.createObjectURL(await fetchFile(path));
215
+ }
216
+
217
+ function mockSample<T>(samples: Record<string, T> | undefined, source: string): T {
218
+ const n = activeMockSample();
219
+ const sample = samples?.[n];
220
+ if (sample === undefined) {
221
+ throw new Error(
222
+ `Mock mode is on (VITE_MOCK_SAMPLE=${n}) but no sample-${n}.json exists for ${source} — add one under this component's samples/ folder.`,
223
+ );
224
+ }
225
+ return sample;
226
+ }
@@ -0,0 +1,13 @@
1
+ import { StrictMode } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+ __CSS_IMPORT__
4
+ import { BrowserRouter } from 'react-router-dom'
5
+ import App from './App.tsx'
6
+
7
+ createRoot(document.getElementById('root')!).render(
8
+ <StrictMode>
9
+ <BrowserRouter>
10
+ <App />
11
+ </BrowserRouter>
12
+ </StrictMode>,
13
+ )
@@ -646,7 +646,7 @@ Create a complete slice (1 column + its nodes automatically placed).
646
646
  interaction?: Partial<NodeData> & { rowId?: string, fields?: FieldDef[] }
647
647
  swimlane?: Partial<NodeData> & { rowId?: string, fields?: FieldDef[] }
648
648
  }
649
- status?: 'Created' | 'Ready' | 'Planned' | 'InProgress' | 'Handover' | 'Review' | 'Done' | 'Blocked' | 'Assigned' | 'Informational'
649
+ status?: 'Created' | 'Ready' | 'Planned' | 'InProgress' | 'Waiting' | 'Review' | 'Done' | 'Blocked' | 'Assigned' | 'Informational'
650
650
  }
651
651
  ```
652
652
 
@@ -673,7 +673,7 @@ Create a standalone SLICE_BORDER node spanning an **existing** column. Unlike th
673
673
  {
674
674
  columnId: string // id of an existing column on this timeline
675
675
  title: string // slice title — always taken from this field, never derived
676
- status?: 'Created' | 'Ready' | 'Planned' | 'InProgress' | 'Handover' | 'Review' | 'Done' | 'Blocked' | 'Assigned' | 'Informational'
676
+ status?: 'Created' | 'Ready' | 'Planned' | 'InProgress' | 'Waiting' | 'Review' | 'Done' | 'Blocked' | 'Assigned' | 'Informational'
677
677
  data?: Record<string, unknown> // optional node.data payload
678
678
  meta?: Record<string, unknown> // optional extra meta fields (type, colId, title are always set explicitly and cannot be overridden here)
679
679
  }
@@ -847,8 +847,8 @@ How much each slice of one context has been reworked — read-only, derived from
847
847
  for it.
848
848
 
849
849
  A slice's rework is read from its own SLICE_BORDER history. Going backwards means a step down the progress order
850
- (Created → Ready → Planned → Assigned → InProgress → Handover → Review → Done), or reaching `Blocked` from
851
- `Handover`/`Review`/`Done`;
850
+ (Created → Ready → Planned → Assigned → InProgress → Waiting → Review → Done), or reaching `Blocked` from
851
+ `Waiting`/`Review`/`Done`;
852
852
  `Informational` is never scored. `reopens` counts transitions leading away from `Done`, `changes` counts writes to the
853
853
  slice itself. This says nothing about edits to the elements inside a slice.
854
854
 
@@ -1066,11 +1066,22 @@ Send `x-agent-id` here too: a prompt the user addressed to one preferred agent (
1066
1066
 
1067
1067
  Note what this endpoint does *not* do: an agent that sends its id still gets every untargeted prompt on top of its own. A caller that wants only what was addressed to it has to hand the rest back itself (`POST /prompts/:id/status` with `status: 'ADDED'`), which is what `eventmodelers run --exclusive` does.
1068
1068
 
1069
+ The claim records its holder: `claimed_by` is the caller's `x-agent-id` (`null` if it sent none) and `claimed_at` the time. That is what tells a prompt an agent is working from one a crashed agent left behind. Before claiming, this endpoint puts prompts whose known holder has **no live heartbeat** (and that were claimed more than 45 s ago) back to `ADDED`; a prompt with no recorded holder is never handed back, and an agent that is still pinging keeps its prompts however long a turn takes. An agent that restarts under the same id finds what it was holding with `GET /prompts?claimed_by=<its id>&status=CLAIMED,IN_PROGRESS` and hands it back itself.
1070
+
1069
1071
  **Query params**: `board_id` (required)
1070
1072
  **Response**: `200` — the claimed row (now `status: "CLAIMED"`), including its parsed `context` and the `hidden` flag · `404` — no `ADDED` prompts available
1071
1073
 
1072
1074
  ---
1073
1075
 
1076
+ ### GET `/api/org/:orgId/prompts`
1077
+ List a board's prompts **with their status** — the only way to read a prompt's status. Read-only: nothing is claimed. Auth: `x-token` **and** a Supabase JWT (`Authorization: Bearer`) together, like `/prompts/next` — an agent uses the realtime token it already holds. A status write is unconditional (`CLAIMED` → `ADDED` works on a `DONE` prompt too), so an agent that wants to hand back prompts a crash left it holding looks here first and releases only the ones still `CLAIMED` / `IN_PROGRESS`.
1078
+
1079
+ **Query params**: `board_id` (required) · `status` (optional, comma-separated subset of `ADDED`,`CLAIMED`,`IN_PROGRESS`,`DONE`) · `ids` (optional, comma-separated prompt ids, at most 200 — only these prompts of the board come back; an empty value asks about none, and the id of another board's prompt matches nothing) · `claimed_by` (optional, an agent id — only the prompts that agent holds) · `limit` (optional, default 200, max 500)
1080
+ **Response**: `200` — `{ "prompts": [ … ] }`, each row with `id`, `status`, `agent_id` (who it is addressed to), `claimed_by` / `claimed_at` (who holds it and since when), `priority`, `creation_time`, `node_id`, `comment_id`, the progress `comment` and the parsed `context`. Ordered like the claim: priority first, then oldest first.
1081
+ **Errors**: `400` missing `board_id`, unknown status (`PROMPT_STATUS_INVALID`), more than 200 ids or a bad `limit` · `403` the board is not in the token's organization
1082
+
1083
+ ---
1084
+
1074
1085
  ### POST `/api/org/:orgId/prompts/:id/status`
1075
1086
  Set a prompt's status, optionally attaching a progress comment. Auth: `x-token` only (bot token — no user JWT needed, this is meant to be called directly by the agent working the prompt).
1076
1087
 
@@ -1084,6 +1095,8 @@ Set a prompt's status, optionally attaching a progress comment. Auth: `x-token`
1084
1095
  }
1085
1096
  ```
1086
1097
 
1098
+ Setting `ADDED` hands the prompt back to the queue and clears `claimed_by` / `claimed_at`; the other statuses leave the holder as it was.
1099
+
1087
1100
  **Response**: `200` — the updated row
1088
1101
  **Errors**: `400` invalid/missing `status` · `403` token not for this prompt's org · `404` prompt not found · `409` (`PROMPT_STATUS_ALREADY_SET`) the prompt already carries that status — another agent already made this transition, so don't retry it
1089
1102
 
@@ -16,8 +16,7 @@ Prefer `mcp__eventmodelers__*` tools when available (registered by the `connect`
16
16
  **The default is to assume and build.** A missing example value, an unclear field type, a status
17
17
  mapping, a referenced event that isn't modeled yet, a dependency slice that isn't built yet — none of
18
18
  these is a reason to stop. Pick the most sensible interpretation from `slice.json`, its
19
- `specifications[]` and the surrounding model, build the slice, and record each assumption in one line
20
- in `progress.txt` and as a code comment. **Read `slice.json` fully, and read the build skill's own
19
+ `specifications[]` and the surrounding model, build the slice, and record each assumption in one line as a code comment. **Read `slice.json` fully, and read the build skill's own
21
20
  instructions and reference docs, before concluding anything is missing.**
22
21
 
23
22
  Invoke `request-feedback` **only if the slice literally cannot be built**: even with sensible
@@ -18,7 +18,7 @@ records that as a contract — the endpoint's **OpenAPI operation**, one per sli
18
18
 
19
19
  ## When
20
20
 
21
- **Only when handover is on** — the task request's `Handover: on|off` line (authoritative; the runner resolves `run --handover` over the project setting), else `"handover": true` in `.eventmodelers/config.json`. With handover **off/unset**, do nothing: publish no contract, write no `## UI Contract` section, and finish the slice as `Done` (Step 4). The contract exists only for the UI kit that picks up `Handover` slices.
21
+ **Only when handover is on** — the task request's `Handover: on|off` line (authoritative; the runner resolves `run --handover` over the project setting), else `"handover": true` in `.eventmodelers/config.json`. With handover **off/unset**, do nothing: publish no contract, write no `## UI Contract` section, and finish the slice as `Done` (Step 4). The contract exists only for the UI kit that picks up `Waiting` slices.
22
22
 
23
23
  At the end of building a slice, **after** the endpoint exists (so the contract describes the real
24
24
  route, not the plan), before the final commit:
@@ -99,7 +99,7 @@ every MARKDOWN node of the slice's column as a plain string in `slice.json` `not
99
99
  `outline` / `fields` / `specs` projections leave `notes` out). The UI build kit therefore needs no
100
100
  extra file and no board call.
101
101
 
102
- ## Step 4 — Completion status: `Handover` instead of `Done`
102
+ ## Step 4 — Completion status: `Waiting` instead of `Done`
103
103
 
104
104
  A slice with a UI is only finished once the UI kit has built its half. Whether this build kit hands
105
105
  over is decided per run, in this order: the task request's `Handover: on|off` line (authoritative — the
@@ -107,9 +107,11 @@ runner resolves `run --handover` over the project setting), else `"handover": tr
107
107
  `.eventmodelers/config.json` (saved by `init --handover` / `eventmodelers config --handover on|off`).
108
108
 
109
109
  - **On** — the build kit's "set the slice to `Done`" for a STATE_VIEW / STATE_CHANGE slice means
110
- **`Handover`** instead: after the contract is published and the commit/merge succeeded, via
111
- `update-slice-status` (mirrored in the local `index.json`). The UI kit claims `Handover` slices and sets
112
- `Done` when its UI is built.
110
+ **`Waiting`** instead: after the contract is published and the commit/merge succeeded. Where the build
111
+ kit's prompt says to call `update-slice-status` (a queued task), set `Waiting` through it,
112
+ mirrored in the local `index.json`. For a run-loop build (the task request names the slice), record it
113
+ with `npx @eventmodelers/cli slice-status Waiting` — the run loop pushes it to the board; do not call
114
+ `update-slice-status`. The UI kit claims `Waiting` slices and sets `Done` when its UI is built.
113
115
  - **Off / unset** — nothing changes: `Done`.
114
116
  - Automations and translations have no UI → always `Done`.
115
117
 
@@ -26,7 +26,7 @@ Valid status values (case-sensitive):
26
26
  | `Ready` | Modeling is done — specified and ready to be planned for implementation |
27
27
  | `Planned` | Work is planned — queued for the backend build kit |
28
28
  | `InProgress` | Work is actively in progress |
29
- | `Handover` | Backend built and its UI contract published (`## UI Contract` in the slice's markdown note) — queued for the UI build kit |
29
+ | `Waiting` | Backend built and its UI contract published (`## UI Contract` in the slice's markdown note) — queued for the UI build kit |
30
30
  | `Review` | Ready for review |
31
31
  | `Done` | Completed |
32
32
  | `Blocked` | Blocked by something |
@@ -33,16 +33,16 @@ Ignore case for files and slices in prompts. "CartItems" slice is the same as "c
33
33
 
34
34
  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
35
35
 
36
- At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings.
36
+ 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.
37
37
 
38
- When starting to work on a slice, invoke the `update-slice-status` skill with `InProgress` status before doing anything else.
38
+ 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>`.
39
39
 
40
40
  ## Building a Slice
41
41
 
42
42
  **CRITICAL: You MUST always use the provided skills to build slices. NEVER implement a slice manually.**
43
43
  **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.**
44
44
 
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 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".
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".
46
46
 
47
47
  When asked to build a slice, always follow this flow:
48
48
 
@@ -53,9 +53,10 @@ When asked to build a slice, always follow this flow:
53
53
  - **State-view** — `projections` or `queries` array is non-empty → invoke `/build-state-view`
54
54
  - **State-change** — default (has `commands` / `events`) → invoke `/build-state-change`
55
55
  3. Invoke the matching skill and follow its instructions completely. Do not deviate.
56
- 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.
57
- 5. Run quality checks (`./mvnw compile -q`, then the slice tests only).
58
- 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.
56
+ 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.
57
+ 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.
58
+ 6. Run quality checks (`./mvnw compile -q`, then the slice tests only).
59
+ 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.
59
60
 
60
61
  After you are done, automatically run the tests for the slice that was edited.
61
62
 
@@ -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.
@@ -17,20 +17,19 @@ 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 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** "Planned" (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 "Planned" 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 "Planned" 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 "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. 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. Define the slice type and load the matching skill:
29
28
  - Write slice (has commands, no processors) → `build-state-change`
30
29
  - Read slice (has readModel / information flow) → `build-state-view`
31
30
  - Translation slice (`sliceType === "TRANSLATION"`) → read `description` and `notes` from slice.json for hints; default to `build-automation` if nothing else is specified
32
31
  - Automation slice (processors-array is not empty) → `build-automation`
33
- 8. Write a short progress one liner after each step to progress.txt
32
+ 8. Record each learning the moment you have it (see **Recording Learnings**), not at the end.
34
33
  9. Analyze and Implement that single slice, make use of the skills in the skills directory, but also your previsously collected
35
34
  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.
36
35
  10. The slice in the json is always true, the code follows what is defined in the json
@@ -43,48 +42,27 @@ You work within **exactly ONE context at a time** — the one named in `.build-k
43
42
  If the tests for the slice are not yet named predictably, run `./mvnw test -q` and check for failures.
44
43
  15. If checks pass, commit ALL changes with message: `feat: [Slice Name]` and merge back to main as FF merge ( update
45
44
  first )
46
- 16. 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). 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.
47
- 17. Append your progress to `progress.txt` after each step in the iteration.
48
- 18. 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.
45
+ 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.
46
+ 17. Record any reusable learning you have not recorded yet (see **Recording Learnings**).
47
+ 18. If an entry in `.build-kit/AGENTS.md` turned out wrong or obsolete, retract it (see **Recording Learnings**).
49
48
  19. Finish the iteration.
50
49
 
51
50
  ## Escalating Ambiguity
52
51
 
53
- **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".
52
+ **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".
54
53
 
55
- ## Progress Report Format
54
+ ## Recording Learnings
56
55
 
57
- APPEND to progress.txt (never replace, always append):
56
+ `.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:
58
57
 
59
58
  ```
60
- ## [Date/Time] - [Slice]
61
-
62
- - What was implemented
63
- - Files changed
64
- - **Learnings for future iterations:**
65
- - Patterns discovered (e.g., "this codebase uses X for Y")
66
- - Gotchas encountered (e.g., "don't forget to update Z when changing W")
67
- - Useful context (e.g., "the evaluation panel is in component X")
68
- ---
59
+ npx @eventmodelers/cli learn "<one terse line>" --topic "<topic>"
69
60
  ```
70
61
 
71
- The learnings section is critical - it helps future iterations avoid repeating mistakes and understand the codebase
72
- better.
73
-
74
- ## Consolidate Patterns
75
-
76
- If you discover a **reusable pattern** that future iterations should know, add it to the `## Codebase Patterns` section
77
- at the TOP of progress.txt (create it if it doesn't exist). This section should consolidate the most important
78
- learnings:
79
-
80
- ```
81
- ## Codebase Patterns
82
- - Example: Use event sourcing aggregate patterns for all state changes
83
- - Example: Always use @CommandHandler on the aggregate for write slices
84
- - Example: Export query result types from the slice package
85
- ```
86
-
87
- Only add patterns that are **general and reusable**, not story-specific details.
62
+ - 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.
63
+ - One learning per call, one line each. A learning that is already in `.build-kit/AGENTS.md` is skipped for you.
64
+ - `--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).
65
+ - 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.
88
66
 
89
67
  ## Update AGENTS.md Files
90
68
 
@@ -110,7 +88,7 @@ Before committing, check if any edited files have learnings worth preserving in
110
88
  - Slice specific implementation details
111
89
  - Story-specific implementation details
112
90
  - Temporary debugging notes
113
- - Information already in progress.txt
91
+ - Information already recorded as a learning in `.build-kit/AGENTS.md`
114
92
  - Task specific learnings
115
93
 
116
94
  Only update AGENTS.md if you have **genuinely reusable knowledge** that would help future work
@@ -154,9 +132,9 @@ If ALL slices in the current context are Done, reply with:
154
132
  - 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.
155
133
  - Work on ONE slice per iteration
156
134
  - Commit frequently
157
- - update progress.txt frequently
158
- - Read the Codebase Patterns section in progress.txt before starting
135
+ - Record learnings as you go with `learn`
136
+ - Read `.build-kit/AGENTS.md` before starting
159
137
 
160
138
  ## When an iteration completes
161
139
 
162
- Use all the key learnings from the progress.txt and update the `.build-kit/AGENTS.md` file with those learnings.
140
+ Make sure every reusable learning is recorded with `learn`; `.build-kit/AGENTS.md` is generated from them — never edit it by hand.