@eventmodelers/cli 1.0.53 → 1.0.55
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 +6 -0
- package/cli.js +29 -1
- package/package.json +1 -1
- package/shared/build-kit/lib/ralph.js +103 -5
- package/shared/build-kit/lib/util/find-slice.cjs +2 -0
- package/shared/skills/learn-eventmodelers-api/SKILL.md +3 -0
- package/stacks/node/templates/build-kit/lib/check-commit-scope.cjs +17 -4
- package/stacks/node/templates/root/.githooks/pre-commit +10 -3
- package/stacks/react/templates/.claude/skills/build-automation/SKILL.md +42 -0
- package/stacks/react/templates/.claude/skills/build-state-change/SKILL.md +43 -0
- package/stacks/react/templates/.claude/skills/build-state-view/SKILL.md +42 -0
- package/stacks/react/templates/build-kit/CLAUDE.md +62 -0
- package/stacks/react/templates/build-kit/README.md +79 -0
- package/stacks/react/templates/build-kit/lib/AGENT.md +47 -0
- package/stacks/react/templates/build-kit/lib/backend-prompt.md +135 -0
- package/stacks/react/templates/build-kit/lib/prompt.md +139 -0
- package/stacks/react/templates/build-kit/lib/ralph.js +508 -0
- package/stacks/react/templates/build-kit/package.json +9 -0
- package/stacks/react/templates/build-kit/ralph-claude.js +107 -0
- package/stacks/react/templates/build-kit/ralph-ollama.js +40 -0
- package/stacks/supabase/templates/build-kit/lib/check-commit-scope.cjs +17 -4
- package/stacks/supabase/templates/root/.githooks/pre-commit +10 -3
- package/stacks/supabase-react/templates/.claude/skills/build-state-change/SKILL.md +305 -0
- package/stacks/supabase-react/templates/.claude/skills/build-state-view/SKILL.md +238 -0
- package/stacks/supabase-react/templates/.claude/skills/init-style-guide/SKILL.md +60 -0
- package/stacks/supabase-react/templates/.claude/skills/learn-styleguide/SKILL.md +28 -0
- package/stacks/supabase-react/templates/.claude/skills/learn-styleguide/references/README.md +5 -0
- package/stacks/supabase-react/templates/build-kit/CLAUDE.md +149 -0
- package/stacks/supabase-react/templates/build-kit/lib/AGENT.md +47 -0
- package/stacks/supabase-react/templates/build-kit/lib/backend-prompt.md +139 -0
- package/stacks/supabase-react/templates/build-kit/lib/prompt.md +145 -0
- package/stacks/supabase-react/templates/root/.env.example +12 -0
- package/stacks/supabase-react/templates/root/.oxlintrc.json +9 -0
- package/stacks/supabase-react/templates/root/README.md +49 -0
- package/stacks/supabase-react/templates/root/index.html +13 -0
- package/stacks/supabase-react/templates/root/package.json +26 -0
- package/stacks/supabase-react/templates/root/public/favicon.svg +1 -0
- package/stacks/supabase-react/templates/root/public/icons.svg +24 -0
- package/stacks/supabase-react/templates/root/src/App.css +184 -0
- package/stacks/supabase-react/templates/root/src/App.tsx +122 -0
- package/stacks/supabase-react/templates/root/src/assets/hero.png +0 -0
- package/stacks/supabase-react/templates/root/src/assets/react.svg +1 -0
- package/stacks/supabase-react/templates/root/src/assets/vite.svg +1 -0
- package/stacks/supabase-react/templates/root/src/index.css +111 -0
- package/stacks/supabase-react/templates/root/src/lib/api.ts +127 -0
- package/stacks/supabase-react/templates/root/src/lib/supabase.ts +10 -0
- package/stacks/supabase-react/templates/root/src/main.tsx +10 -0
- package/stacks/supabase-react/templates/root/src/slices/.gitkeep +0 -0
- package/stacks/supabase-react/templates/root/src/vite-env.d.ts +13 -0
- package/stacks/supabase-react/templates/root/tsconfig.app.json +26 -0
- package/stacks/supabase-react/templates/root/tsconfig.json +7 -0
- package/stacks/supabase-react/templates/root/tsconfig.node.json +23 -0
- package/stacks/supabase-react/templates/root/vite.config.ts +7 -0
package/README.md
CHANGED
|
@@ -22,6 +22,8 @@ npx @eventmodelers/cli init --stack cratis-csharp # Cratis (.NET/C#)
|
|
|
22
22
|
npx @eventmodelers/cli init --stack opencqrs # OpenCQRS (Java, EventSourcingDB)
|
|
23
23
|
npx @eventmodelers/cli init --stack umadb # UmaDB (Java)
|
|
24
24
|
npx @eventmodelers/cli init --stack kurrent # Kurrent (Java, KurrentDB)
|
|
25
|
+
npx @eventmodelers/cli init --stack react # React (frontend, board-polling sync) — TODO-marked, not yet filled in
|
|
26
|
+
npx @eventmodelers/cli init --stack supabase-react # React + Supabase (frontend, UI-only, realtime sync)
|
|
25
27
|
```
|
|
26
28
|
|
|
27
29
|
The installer prompts for your API token, Organization ID, and Board ID from [app.eventmodelers.ai/account](https://app.eventmodelers.ai/account), scaffolds the stack into your project, and writes `.eventmodelers/config.json` with your credentials.
|
|
@@ -78,6 +80,10 @@ your-project/
|
|
|
78
80
|
|
|
79
81
|
The seven backend stacks (`node`, `supabase`, `axon`, `cratis-csharp`, `opencqrs`, `umadb`, `kurrent`) also scaffold a real project skeleton into your project root (`templates/root/`) — source layout, build files, migrations, etc.
|
|
80
82
|
|
|
83
|
+
`react` and `supabase-react` are two more registered stacks (installable the same way). `supabase-react` is real, filled-in content — a Vite + React 19 + TypeScript scaffold that authenticates and issues command POSTs via a Supabase session (`src/lib/api.ts`/`src/lib/supabase.ts`), plus `init-style-guide`/`learn-styleguide` skills so generated UI stays on-brand. It's UI-only: `.build-kit/CLAUDE.md` only routes `STATE_CHANGE`/`STATE_VIEW` slices to `build-state-change`/`build-state-view` — an `AUTOMATION` slice has no UI counterpart and gets flagged via `request-feedback` instead, since it belongs to whichever backend stack is installed alongside this one. It needs no overrides at all and uses `shared/build-kit`'s realtime agent as-is.
|
|
84
|
+
|
|
85
|
+
`react` (the plain-REST/board-polling variant, no Supabase) is still in the same state as a fresh `init --build-kit` scaffold — CLAUDE.md, the `build-*` skills, and `templates/root/` are all TODO-marked placeholders, not real content, pending an equivalent reference implementation. It overrides `lib/ralph.js` (+ `ralph-claude.js`/`ralph-ollama.js`/`package.json`/`README.md`) for board-polling sync. Fill in the TODOs (and add a real `templates/root/` scaffold) against an actual project before relying on it.
|
|
86
|
+
|
|
81
87
|
## Skills
|
|
82
88
|
|
|
83
89
|
Use skills in Claude Code with `/skill-name`:
|
package/cli.js
CHANGED
|
@@ -91,6 +91,30 @@ const STACKS = {
|
|
|
91
91
|
useShared: true,
|
|
92
92
|
needsBoardId: true,
|
|
93
93
|
},
|
|
94
|
+
// Frontend-only kits (UI-only: build STATE_CHANGE/STATE_VIEW slices, not
|
|
95
|
+
// AUTOMATION — those belong to whichever backend stack is installed alongside).
|
|
96
|
+
// react overrides lib/ralph.js (+ralph-claude.js/ralph-ollama.js/package.json/
|
|
97
|
+
// README.md) for board-polling instead of the realtime channel every other
|
|
98
|
+
// stack uses; supabase-react needs no overrides at all — it uses
|
|
99
|
+
// shared/build-kit's realtime agent as-is. react's CLAUDE.md/build-*
|
|
100
|
+
// skills/templates/root are still TODO-marked, same as a fresh `init
|
|
101
|
+
// --build-kit` scaffold — supabase-react's are real, filled-in content
|
|
102
|
+
// (Vite + React 19 + TypeScript + Supabase, plus init-style-guide/
|
|
103
|
+
// learn-styleguide for on-brand generated UI).
|
|
104
|
+
react: {
|
|
105
|
+
label: 'React (frontend, board-polling sync) — TODO-marked, not yet filled in',
|
|
106
|
+
kitSubdir: 'build-kit',
|
|
107
|
+
kitDirName: '.build-kit',
|
|
108
|
+
useShared: true,
|
|
109
|
+
needsBoardId: true,
|
|
110
|
+
},
|
|
111
|
+
'supabase-react': {
|
|
112
|
+
label: 'React + Supabase (frontend, UI-only, realtime sync)',
|
|
113
|
+
kitSubdir: 'build-kit',
|
|
114
|
+
kitDirName: '.build-kit',
|
|
115
|
+
useShared: true,
|
|
116
|
+
needsBoardId: true,
|
|
117
|
+
},
|
|
94
118
|
};
|
|
95
119
|
|
|
96
120
|
// Not a stack — no backend scaffold, just skills + the agent loop. Installed via
|
|
@@ -1874,7 +1898,11 @@ program
|
|
|
1874
1898
|
|
|
1875
1899
|
console.log(`🔎 Running checks from ${relative(cwd, checkScript)}...`);
|
|
1876
1900
|
try {
|
|
1877
|
-
|
|
1901
|
+
// cwd must be the project root (not kitDir/.build-kit) — the script's
|
|
1902
|
+
// `git diff --relative` scopes its output to cwd's subtree, so running
|
|
1903
|
+
// it from inside .build-kit/ makes every changed file outside .build-kit/
|
|
1904
|
+
// (i.e. everything under src/) invisible, and the check silently no-ops.
|
|
1905
|
+
execSync(`node "${checkScript}"`, { cwd, stdio: 'inherit' });
|
|
1878
1906
|
} catch (err) {
|
|
1879
1907
|
process.exit(err.status || 1);
|
|
1880
1908
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eventmodelers/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.55",
|
|
4
4
|
"description": "Eventmodelers CLI — real-time Claude agent + skills for Claude Code, for any stack (Node, Supabase, Axon, Cratis, OpenCQRS, UmaDB, Kurrent, or modeling-only)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -407,7 +407,7 @@ function readCurrentContext(kitDir) {
|
|
|
407
407
|
// Returns the first Planned slice IN THE CURRENT CONTEXT ONLY. If the current
|
|
408
408
|
// context has no planned work, returns null so the loop waits — it must NEVER
|
|
409
409
|
// cross into another context to find something to build.
|
|
410
|
-
function
|
|
410
|
+
function getFirstPlannedSlice(kitDir) {
|
|
411
411
|
const currentCtx = readCurrentContext(kitDir);
|
|
412
412
|
if (!currentCtx) return null;
|
|
413
413
|
const indexPath = join(kitDir, '.slices', currentCtx, 'index.json');
|
|
@@ -415,11 +415,95 @@ function getFirstPlannedSliceTitle(kitDir) {
|
|
|
415
415
|
try {
|
|
416
416
|
const { slices } = JSON.parse(readFileSync(indexPath, 'utf-8'));
|
|
417
417
|
const planned = slices && slices.find((s) => (s.status || '').toLowerCase() === 'planned');
|
|
418
|
-
if (planned) return planned.slice || planned.id || null;
|
|
418
|
+
if (planned) return { id: planned.id ?? null, title: planned.slice || planned.id || null, ctx: currentCtx };
|
|
419
419
|
} catch {}
|
|
420
420
|
return null;
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
+
// If the exact same Planned slice (by id) comes back up this many times in a
|
|
424
|
+
// row without its status ever leaving "Planned", onPlannedSlice is stuck on
|
|
425
|
+
// it — declining to build it, or building it but its own status change keeps
|
|
426
|
+
// getting reverted (e.g. a failed check). Rather than retry it forever (or
|
|
427
|
+
// crash the whole loop, which would take down every other slice with it),
|
|
428
|
+
// mark it Blocked with a note explaining why and move on to other work.
|
|
429
|
+
// Critical for unsupervised/CI runs, which have no human watching to notice
|
|
430
|
+
// a stall. Configurable for teams that want more slack.
|
|
431
|
+
const MAX_PLANNED_ATTEMPTS = Number(process.env.RALPH_MAX_PLANNED_ATTEMPTS) || 2;
|
|
432
|
+
|
|
433
|
+
// Marks a stuck slice Blocked (locally, and on the board if credentialed) and
|
|
434
|
+
// records why, so the loop can move on instead of looping or exiting.
|
|
435
|
+
async function blockStuckSlice(kitDir, cfg, credentialed, planned, attempts) {
|
|
436
|
+
const now = new Date().toISOString();
|
|
437
|
+
const reason = `Ralph loop picked up this slice ${attempts} times in a row without its status ever leaving ` +
|
|
438
|
+
`"Planned" — the build agent kept declining to build it, or kept building it but its own status change kept ` +
|
|
439
|
+
`getting reverted (e.g. a failed check). Auto-blocked to stop the loop from retrying it forever.`;
|
|
440
|
+
|
|
441
|
+
const indexPath = join(kitDir, '.slices', planned.ctx, 'index.json');
|
|
442
|
+
let folder;
|
|
443
|
+
try {
|
|
444
|
+
const indexData = JSON.parse(readFileSync(indexPath, 'utf-8'));
|
|
445
|
+
const entry = (indexData.slices ?? []).find((s) => s.id === planned.id);
|
|
446
|
+
if (entry) {
|
|
447
|
+
entry.status = 'Blocked';
|
|
448
|
+
entry.blockedReason = reason;
|
|
449
|
+
entry.blockedAt = now;
|
|
450
|
+
folder = entry.folder;
|
|
451
|
+
writeFileSync(indexPath, JSON.stringify(indexData, null, 2), 'utf-8');
|
|
452
|
+
}
|
|
453
|
+
} catch (err) {
|
|
454
|
+
console.error(`[ralph] Failed to write Blocked status to ${indexPath}:`, err.message);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
if (folder) {
|
|
458
|
+
const sliceJsonPath = join(kitDir, '.slices', planned.ctx, folder, 'slice.json');
|
|
459
|
+
try {
|
|
460
|
+
if (existsSync(sliceJsonPath)) {
|
|
461
|
+
const sliceData = JSON.parse(readFileSync(sliceJsonPath, 'utf-8'));
|
|
462
|
+
sliceData.status = 'Blocked';
|
|
463
|
+
sliceData.blockedReason = reason;
|
|
464
|
+
sliceData.blockedAt = now;
|
|
465
|
+
writeFileSync(sliceJsonPath, JSON.stringify(sliceData, null, 2), 'utf-8');
|
|
466
|
+
}
|
|
467
|
+
} catch (err) {
|
|
468
|
+
console.error(`[ralph] Failed to write Blocked status to ${sliceJsonPath}:`, err.message);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
try {
|
|
473
|
+
const progressPath = join(dirname(kitDir), 'progress.txt');
|
|
474
|
+
const existing = existsSync(progressPath) ? readFileSync(progressPath, 'utf-8') : '';
|
|
475
|
+
const note = `\n## ${now} — Slice auto-blocked\n\nSlice: ${planned.title} (id=${planned.id}, context=${planned.ctx})\n\n- ${reason}\n---\n`;
|
|
476
|
+
writeFileSync(progressPath, existing + note, 'utf-8');
|
|
477
|
+
} catch (err) {
|
|
478
|
+
console.error('[ralph] Failed to append progress.txt note:', err.message);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// Best-effort: also reflect Blocked on the board itself so a synced fetch
|
|
482
|
+
// doesn't just pull "Planned" back down over our local fix. Never fatal —
|
|
483
|
+
// this loop must keep going locally even if the board call fails.
|
|
484
|
+
if (credentialed) {
|
|
485
|
+
try {
|
|
486
|
+
await fetchJSON(`${cfg.baseUrl}/api/org/${cfg.organizationId}/boards/${cfg.boardId}/nodes/events`, {
|
|
487
|
+
method: 'POST',
|
|
488
|
+
headers: { 'Content-Type': 'application/json', 'x-token': cfg.token, 'x-board-id': cfg.boardId, 'x-user-id': 'ralph-loop' },
|
|
489
|
+
body: JSON.stringify([{
|
|
490
|
+
id: randomUUID(),
|
|
491
|
+
eventType: 'node:changed',
|
|
492
|
+
nodeId: planned.id,
|
|
493
|
+
boardId: cfg.boardId,
|
|
494
|
+
timestamp: Date.now(),
|
|
495
|
+
changedAttributes: ['sliceStatus'],
|
|
496
|
+
meta: { sliceStatus: 'Blocked' },
|
|
497
|
+
}]),
|
|
498
|
+
});
|
|
499
|
+
} catch (err) {
|
|
500
|
+
console.error(`[ralph] Failed to sync Blocked status to the board:`, err.message);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
console.error(`[ralph] ${reason} Marked "${planned.title}" (id=${planned.id}) as Blocked — moving on.`);
|
|
505
|
+
}
|
|
506
|
+
|
|
423
507
|
async function runWithRetry(label, fn) {
|
|
424
508
|
while (true) {
|
|
425
509
|
try {
|
|
@@ -441,6 +525,9 @@ async function ralphLoop(kitDir, cfg, onTask, onPlannedSlice, localOnly = false)
|
|
|
441
525
|
// this back on.
|
|
442
526
|
const credentialed = !localOnly && hasCredentials(cfg);
|
|
443
527
|
let lastIdleCtx;
|
|
528
|
+
// Tracks consecutive sightings of the same Planned slice id — see
|
|
529
|
+
// MAX_PLANNED_ATTEMPTS above.
|
|
530
|
+
let stuckSlice = { id: null, count: 0 };
|
|
444
531
|
|
|
445
532
|
while (true) {
|
|
446
533
|
let didWork = false;
|
|
@@ -452,10 +539,21 @@ async function ralphLoop(kitDir, cfg, onTask, onPlannedSlice, localOnly = false)
|
|
|
452
539
|
didWork = true;
|
|
453
540
|
}
|
|
454
541
|
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
542
|
+
const planned = onPlannedSlice && getFirstPlannedSlice(kitDir);
|
|
543
|
+
if (planned) {
|
|
544
|
+
stuckSlice = planned.id !== null && planned.id === stuckSlice.id
|
|
545
|
+
? { id: stuckSlice.id, count: stuckSlice.count + 1 }
|
|
546
|
+
: { id: planned.id, count: 1 };
|
|
547
|
+
|
|
548
|
+
if (stuckSlice.count > MAX_PLANNED_ATTEMPTS) {
|
|
549
|
+
await blockStuckSlice(kitDir, cfg, credentialed, planned, stuckSlice.count);
|
|
550
|
+
stuckSlice = { id: null, count: 0 };
|
|
551
|
+
didWork = true;
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
|
|
457
555
|
const prompt = readFileSync(backendPromptFile, 'utf-8');
|
|
458
|
-
await runWithRetry(`onPlannedSlice: building slice "${
|
|
556
|
+
await runWithRetry(`onPlannedSlice: building slice "${planned.title}"...`, () => onPlannedSlice(prompt));
|
|
459
557
|
console.log(`[ralph] Slice build complete — waiting for next slice`);
|
|
460
558
|
if (credentialed) await fetchAndPersistSlices(cfg, kitDir).catch(() => {});
|
|
461
559
|
didWork = true;
|
|
@@ -21,6 +21,7 @@ function findSliceJson(repoRoot, context, sliceName) {
|
|
|
21
21
|
const root = path.join(repoRoot, '.build-kit', '.slices');
|
|
22
22
|
if (!fs.existsSync(root)) return null;
|
|
23
23
|
|
|
24
|
+
const wantContext = normalize(context);
|
|
24
25
|
const wantSlice = normalize(sliceName);
|
|
25
26
|
const candidates = [];
|
|
26
27
|
|
|
@@ -33,6 +34,7 @@ function findSliceJson(repoRoot, context, sliceName) {
|
|
|
33
34
|
|
|
34
35
|
for (const contextDir of contextDirs) {
|
|
35
36
|
if (!contextDir.isDirectory()) continue;
|
|
37
|
+
if (normalize(contextDir.name) !== wantContext) continue;
|
|
36
38
|
const contextPath = path.join(root, contextDir.name);
|
|
37
39
|
let sliceDirs;
|
|
38
40
|
try {
|
|
@@ -114,6 +114,9 @@ SCENARIO // GWT scenario
|
|
|
114
114
|
LANE // Timeline row
|
|
115
115
|
SLICE_BORDER // Slice boundary marker
|
|
116
116
|
MARKDOWN // Free-text markdown note — the content type a `feedback` lane accepts (see §2)
|
|
117
|
+
VIDEO // Embedded video (YouTube/Loom link in `data.url`). API/MCP-only — no palette button in
|
|
118
|
+
// the UI, but renders on the board like any other node. Free-floating: create it via
|
|
119
|
+
// `submit_node_events` with a position and no chapterId/cellId, same as a drawing.
|
|
117
120
|
```
|
|
118
121
|
|
|
119
122
|
---
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
// all uncommitted changes by default, staged-only with --staged
|
|
23
23
|
// touchesSlice true — this commit touches src/slices/{context}/{slice}/**
|
|
24
24
|
// (the runner already gates on this before loading checks)
|
|
25
|
-
// repoRoot absolute path to
|
|
25
|
+
// repoRoot absolute path to this project's own root (process.cwd()) —
|
|
26
|
+
// not the outer git repo's top-level when this project is a
|
|
27
|
+
// subdirectory of a larger repo
|
|
26
28
|
// SLICE_PATTERN RegExp matching a path inside a slice's own folder
|
|
27
29
|
//
|
|
28
30
|
// Zero dependencies — plain Node, so it works from git's pre-commit hook
|
|
@@ -45,14 +47,20 @@ function parseNameStatus(out) {
|
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
// --relative scopes and rewrites paths relative to cwd instead of the git
|
|
51
|
+
// top-level — required when this runs from a subdirectory of a larger repo
|
|
52
|
+
// (e.g. a `backend/` folder inside a monorepo): without it, every path comes
|
|
53
|
+
// back prefixed (`backend/src/slices/...`), SLICE_PATTERN never matches, and
|
|
54
|
+
// the whole guard silently no-ops on every commit. `git ls-files` is already
|
|
55
|
+
// cwd-relative by default, so it needs no such flag.
|
|
48
56
|
function stagedChanges() {
|
|
49
|
-
return parseNameStatus(execSync('git diff --cached --name-status --no-renames', { encoding: 'utf8' }));
|
|
57
|
+
return parseNameStatus(execSync('git diff --cached --name-status --no-renames --relative', { encoding: 'utf8' }));
|
|
50
58
|
}
|
|
51
59
|
|
|
52
60
|
function allChanges() {
|
|
53
61
|
// Working tree vs HEAD already covers both staged and unstaged edits to
|
|
54
62
|
// tracked files; untracked (never-`git add`ed) files need a separate call.
|
|
55
|
-
const tracked = parseNameStatus(execSync('git diff HEAD --name-status --no-renames', { encoding: 'utf8' }));
|
|
63
|
+
const tracked = parseNameStatus(execSync('git diff HEAD --name-status --no-renames --relative', { encoding: 'utf8' }));
|
|
56
64
|
const untracked = execSync('git ls-files --others --exclude-standard', { encoding: 'utf8' })
|
|
57
65
|
.split('\n')
|
|
58
66
|
.filter(Boolean)
|
|
@@ -102,7 +110,12 @@ function main() {
|
|
|
102
110
|
const ctx = {
|
|
103
111
|
changes,
|
|
104
112
|
touchesSlice,
|
|
105
|
-
|
|
113
|
+
// Deliberately process.cwd(), not `git rev-parse --show-toplevel` — this
|
|
114
|
+
// project can be a subdirectory of a larger repo (see the --relative note
|
|
115
|
+
// on allChanges/stagedChanges above), and every path here (and every path
|
|
116
|
+
// checks join onto repoRoot, e.g. `.build-kit/.slices/`) is relative to
|
|
117
|
+
// this project's own root, not the outer git repo's.
|
|
118
|
+
repoRoot: process.cwd(),
|
|
106
119
|
SLICE_PATTERN,
|
|
107
120
|
};
|
|
108
121
|
|
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
# is versioned and shared by every clone instead of living only in .git/hooks/.
|
|
4
4
|
set -e
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
# Deliberately NOT `git rev-parse --show-toplevel` — when this project is a
|
|
7
|
+
# subdirectory of a larger repo (a monorepo with `.githooks` installed inside
|
|
8
|
+
# e.g. `backend/`), show-toplevel returns the outer repo's root, `.build-kit`
|
|
9
|
+
# doesn't exist there, and the hook would silently no-op on every commit.
|
|
10
|
+
# This script's own location is always `<project_root>/.githooks/pre-commit`,
|
|
11
|
+
# so use that instead — and cd into it so check-commit-scope.cjs's own
|
|
12
|
+
# process.cwd()/--relative git-diff logic sees the right root too.
|
|
13
|
+
project_root=$(cd "$(dirname "$0")/.." && pwd)
|
|
14
|
+
script="$project_root/.build-kit/lib/check-commit-scope.cjs"
|
|
8
15
|
|
|
9
16
|
if [ -f "$script" ]; then
|
|
10
|
-
node "$script" --staged
|
|
17
|
+
(cd "$project_root" && node "$script" --staged)
|
|
11
18
|
fi
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: build-automation
|
|
3
|
+
description: TODO — one-line description of how a reactive slice (a processor/reactor that reacts to events and issues new commands) is implemented for your stack (see an existing stack's build-automation/SKILL.md under stacks/<name>/templates/.claude/skills/ for the level of detail expected)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build Automation Slice
|
|
7
|
+
|
|
8
|
+
> **TODO — placeholder installed by `init --build-kit`.** Study an existing stack's
|
|
9
|
+
> build-automation/SKILL.md (stacks/node, stacks/supabase, stacks/axon, or stacks/cratis-csharp,
|
|
10
|
+
> under `templates/.claude/skills/`) for the level of detail expected, then rewrite
|
|
11
|
+
> every section below for your stack's real conventions — file layout, naming, and
|
|
12
|
+
> the actual framework/language idioms. Delete this callout once done.
|
|
13
|
+
|
|
14
|
+
> Before doing anything else, read the slice definition from `.slices/{Context}/{slicename}/slice.json`.
|
|
15
|
+
> This file is the **source of truth** for all fields, events, and metadata — never invent
|
|
16
|
+
> fields not defined there. Keep this line verbatim; it applies to every stack.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## What an Automation Slice is
|
|
21
|
+
|
|
22
|
+
TODO — describe a reactive slice (a processor/reactor that reacts to events and issues new commands) in terms of your stack's own primitives.
|
|
23
|
+
|
|
24
|
+
## Step 1 — Read the slice.json
|
|
25
|
+
|
|
26
|
+
From the slice definition, extract:
|
|
27
|
+
- **sliceName** — the slice title
|
|
28
|
+
- **context** — the bounded context
|
|
29
|
+
- **processors[]** — the reactions this slice implements
|
|
30
|
+
- **specifications[]** — test scenarios (given/when/then)
|
|
31
|
+
|
|
32
|
+
> **Comments & description**: each element carries a `comments: string[]` array (board comments) and a `description` field — use them as implementation hints, and resolve consumed comments via `POST <BASE_URL>/api/org/<ORG_ID>/boards/<BOARD_ID>/nodes/<nodeId>/comments/<commentId>/resolve`.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Step 2 — TODO (your stack-specific implementation steps)
|
|
37
|
+
|
|
38
|
+
TODO — file layout, naming conventions, framework idioms, how the handler/projection/reactor is wired up.
|
|
39
|
+
|
|
40
|
+
## Quality gate
|
|
41
|
+
|
|
42
|
+
TODO — this stack's build command and how to run only this slice's tests (not the full suite).
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: build-state-change
|
|
3
|
+
description: TODO — one-line description of how a write-side slice (command validated against replayed events, new events emitted) is implemented for your stack (see an existing stack's build-state-change/SKILL.md under stacks/<name>/templates/.claude/skills/ for the level of detail expected)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build State Change Slice
|
|
7
|
+
|
|
8
|
+
> **TODO — placeholder installed by `init --build-kit`.** Study an existing stack's
|
|
9
|
+
> build-state-change/SKILL.md (stacks/node, stacks/supabase, stacks/axon, or stacks/cratis-csharp,
|
|
10
|
+
> under `templates/.claude/skills/`) for the level of detail expected, then rewrite
|
|
11
|
+
> every section below for your stack's real conventions — file layout, naming, and
|
|
12
|
+
> the actual framework/language idioms. Delete this callout once done.
|
|
13
|
+
|
|
14
|
+
> Before doing anything else, read the slice definition from `.slices/{Context}/{slicename}/slice.json`.
|
|
15
|
+
> This file is the **source of truth** for all fields, events, and metadata — never invent
|
|
16
|
+
> fields not defined there. Keep this line verbatim; it applies to every stack.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## What a State Change Slice is
|
|
21
|
+
|
|
22
|
+
TODO — describe a write-side slice (command validated against replayed events, new events emitted) in terms of your stack's own primitives.
|
|
23
|
+
|
|
24
|
+
## Step 1 — Read the slice.json
|
|
25
|
+
|
|
26
|
+
From the slice definition, extract:
|
|
27
|
+
- **sliceName** — the slice title
|
|
28
|
+
- **context** — the bounded context
|
|
29
|
+
- **commands[]** — list of commands with their data fields
|
|
30
|
+
- **events[]** — list of events emitted by each command
|
|
31
|
+
- **specifications[]** — test scenarios (given/when/then)
|
|
32
|
+
|
|
33
|
+
> **Comments & description**: each element carries a `comments: string[]` array (board comments) and a `description` field — use them as implementation hints, and resolve consumed comments via `POST <BASE_URL>/api/org/<ORG_ID>/boards/<BOARD_ID>/nodes/<nodeId>/comments/<commentId>/resolve`.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Step 2 — TODO (your stack-specific implementation steps)
|
|
38
|
+
|
|
39
|
+
TODO — file layout, naming conventions, framework idioms, how the handler/projection/reactor is wired up.
|
|
40
|
+
|
|
41
|
+
## Quality gate
|
|
42
|
+
|
|
43
|
+
TODO — this stack's build command and how to run only this slice's tests (not the full suite).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: build-state-view
|
|
3
|
+
description: TODO — one-line description of how a read-side slice (a projection/read model kept up to date from events) is implemented for your stack (see an existing stack's build-state-view/SKILL.md under stacks/<name>/templates/.claude/skills/ for the level of detail expected)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build State View Slice
|
|
7
|
+
|
|
8
|
+
> **TODO — placeholder installed by `init --build-kit`.** Study an existing stack's
|
|
9
|
+
> build-state-view/SKILL.md (stacks/node, stacks/supabase, stacks/axon, or stacks/cratis-csharp,
|
|
10
|
+
> under `templates/.claude/skills/`) for the level of detail expected, then rewrite
|
|
11
|
+
> every section below for your stack's real conventions — file layout, naming, and
|
|
12
|
+
> the actual framework/language idioms. Delete this callout once done.
|
|
13
|
+
|
|
14
|
+
> Before doing anything else, read the slice definition from `.slices/{Context}/{slicename}/slice.json`.
|
|
15
|
+
> This file is the **source of truth** for all fields, events, and metadata — never invent
|
|
16
|
+
> fields not defined there. Keep this line verbatim; it applies to every stack.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## What a State View Slice is
|
|
21
|
+
|
|
22
|
+
TODO — describe a read-side slice (a projection/read model kept up to date from events) in terms of your stack's own primitives.
|
|
23
|
+
|
|
24
|
+
## Step 1 — Read the slice.json
|
|
25
|
+
|
|
26
|
+
From the slice definition, extract:
|
|
27
|
+
- **sliceName** — the slice title
|
|
28
|
+
- **context** — the bounded context
|
|
29
|
+
- **projections[]** / **queries[]** — the read model(s) this slice serves
|
|
30
|
+
- **specifications[]** — test scenarios (given/when/then)
|
|
31
|
+
|
|
32
|
+
> **Comments & description**: each element carries a `comments: string[]` array (board comments) and a `description` field — use them as implementation hints, and resolve consumed comments via `POST <BASE_URL>/api/org/<ORG_ID>/boards/<BOARD_ID>/nodes/<nodeId>/comments/<commentId>/resolve`.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Step 2 — TODO (your stack-specific implementation steps)
|
|
37
|
+
|
|
38
|
+
TODO — file layout, naming conventions, framework idioms, how the handler/projection/reactor is wired up.
|
|
39
|
+
|
|
40
|
+
## Quality gate
|
|
41
|
+
|
|
42
|
+
TODO — this stack's build command and how to run only this slice's tests (not the full suite).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Project Configuration
|
|
2
|
+
|
|
3
|
+
TODO — one-line pointer to where domain events live in your stack's scaffold (e.g. "Read Events in src/events to understand the global structure").
|
|
4
|
+
|
|
5
|
+
## File Structure Constraints
|
|
6
|
+
|
|
7
|
+
- **Strict Path Limitation**: TODO — the one directory glob the agent should stay inside by default (e.g. `src/slices/{slicename}/*`)
|
|
8
|
+
- **Slice Organization**: Each feature/domain should be organized as a separate slice
|
|
9
|
+
|
|
10
|
+
## Code Standards
|
|
11
|
+
|
|
12
|
+
- **Language**: TODO
|
|
13
|
+
- **Module System**: TODO
|
|
14
|
+
- **Type Safety**: TODO (delete this line if the language has no static typing)
|
|
15
|
+
|
|
16
|
+
## Development Guidelines
|
|
17
|
+
|
|
18
|
+
1. Each slice should be self-contained and focused on a specific domain
|
|
19
|
+
2. Maintain clear separation of concerns within each slice
|
|
20
|
+
3. TODO — your stack's own idioms/best practices
|
|
21
|
+
|
|
22
|
+
TODO — any other guardrails worth stating up front (e.g. ignore routes files unless
|
|
23
|
+
asked, ignore tests unless asked, slice names are case-insensitive) — copy the ones
|
|
24
|
+
that still apply from an existing stack's build-kit/CLAUDE.md.
|
|
25
|
+
|
|
26
|
+
At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings.
|
|
27
|
+
|
|
28
|
+
When starting to work on a slice, invoke the `update-slice-status` skill with `InProgress` status before doing anything else.
|
|
29
|
+
|
|
30
|
+
## Building a Slice
|
|
31
|
+
|
|
32
|
+
**CRITICAL: You MUST always use the provided skills to build slices. NEVER implement a slice manually.**
|
|
33
|
+
**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.**
|
|
34
|
+
|
|
35
|
+
**If, at any point below, the slice's requirements are genuinely ambiguous, contradictory, or missing
|
|
36
|
+
a decision you need in order to proceed — do not guess, and do not build anyway.** Invoke the
|
|
37
|
+
`request-feedback` skill with the specific question; it posts the question as a comment on the slice
|
|
38
|
+
and marks it `Blocked`, and you then stop work on this slice for this run. This is an escalation path,
|
|
39
|
+
not a routine step — read `slice.json` and the matching build skill's own instructions fully first;
|
|
40
|
+
most slices are fully specified and need none of this.
|
|
41
|
+
|
|
42
|
+
When asked to build a slice, always follow this flow:
|
|
43
|
+
|
|
44
|
+
1. Read the slice definition from `.build-kit/.slices/<context>/<slicename>/slice.json`.
|
|
45
|
+
2. Determine the slice type:
|
|
46
|
+
- **Translation** — `sliceType === "TRANSLATION"` → read `description` and `notes` from slice.json for hints; default to `/build-automation` if nothing else is specified
|
|
47
|
+
- **Automation** — `processors` array is non-empty → invoke `/build-automation`
|
|
48
|
+
- **State-view** — `projections` or `queries` array is non-empty → invoke `/build-state-view`
|
|
49
|
+
- **State-change** — default (has `commands` / `events`) → invoke `/build-state-change`
|
|
50
|
+
3. Invoke the matching skill and follow its instructions completely. Do not deviate.
|
|
51
|
+
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.
|
|
52
|
+
5. Run quality checks (TODO: this stack's build + test commands), then the slice tests only.
|
|
53
|
+
6. If checks pass, commit with `feat: [Slice Name]` and set slice status to `Done`.
|
|
54
|
+
|
|
55
|
+
After you are done, automatically run the tests for the slice that was edited.
|
|
56
|
+
|
|
57
|
+
## Example Slice Structure
|
|
58
|
+
|
|
59
|
+
TODO — a short tree showing where one slice's files land, e.g.:
|
|
60
|
+
```
|
|
61
|
+
TODO
|
|
62
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# .build-kit
|
|
2
|
+
|
|
3
|
+
Ralph's runtime directory. Contains the agent loop, board poller, prompts, and Claude skills.
|
|
4
|
+
|
|
5
|
+
> This is the **react** (API-access) stack — it talks to the board purely through
|
|
6
|
+
> the plain REST `slicedata` endpoint on `api.eventmodelers.ai`, polled on an interval.
|
|
7
|
+
> There is no Supabase/PocketBase realtime subscription and no direct database table
|
|
8
|
+
> access anywhere in this kit. For instant push notifications instead of polling, use
|
|
9
|
+
> the `supabase-react` stack.
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Claude (default)
|
|
15
|
+
node .build-kit/ralph-claude.js
|
|
16
|
+
|
|
17
|
+
# Local Ollama model — run `ollama serve` first
|
|
18
|
+
OLLAMA_MODEL=qwen3.5:9b node .build-kit/ralph-ollama.js
|
|
19
|
+
|
|
20
|
+
# Custom project directory (defaults to the parent of .build-kit)
|
|
21
|
+
node .build-kit/ralph-claude.js /path/to/project
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Files
|
|
25
|
+
|
|
26
|
+
**Entry points** (top level):
|
|
27
|
+
|
|
28
|
+
| File | Purpose |
|
|
29
|
+
|------|---------|
|
|
30
|
+
| `ralph-claude.js` | Runs the full loop using Claude Code as the executor |
|
|
31
|
+
| `ralph-ollama.js` | Runs the full loop using a local Ollama model |
|
|
32
|
+
| `ralph.sh` | Shell-based loop — alternative to the JS entry points |
|
|
33
|
+
|
|
34
|
+
**Internals** (`lib/`):
|
|
35
|
+
|
|
36
|
+
| File | Purpose |
|
|
37
|
+
|------|---------|
|
|
38
|
+
| `lib/ralph.js` | Shared library — board poller + loop logic; imported by the entry points |
|
|
39
|
+
| `lib/ollama-agent.js` | Ollama executor — called by `ralph-ollama.js`, can also run manually |
|
|
40
|
+
| `lib/agent.sh` | Thin shell wrapper around `claude` — called by `ralph.sh` |
|
|
41
|
+
| `lib/prompt.md` | Phase 1 prompt: tells Claude how to load a slice from the board |
|
|
42
|
+
| `lib/backend-prompt.md` | Phase 2 prompt: tells Claude how to build a planned slice |
|
|
43
|
+
| `lib/AGENT.md` | Agent instructions included in Claude's context |
|
|
44
|
+
|
|
45
|
+
## How it works
|
|
46
|
+
|
|
47
|
+
**Phase 1** — triggered when `tasks.json` has entries:
|
|
48
|
+
- The poller writes a task to `tasks.json` each time it notices a slice's status changed since the last poll
|
|
49
|
+
- The loop picks it up and runs Claude (or Ollama) with `prompt.md`
|
|
50
|
+
- Claude loads the slice data and updates `.slices/`
|
|
51
|
+
|
|
52
|
+
**Phase 2** — triggered when any file in `.slices/` contains `"status": "Planned"`:
|
|
53
|
+
- The loop runs Claude with `backend-prompt.md`
|
|
54
|
+
- Claude implements the slice in the project
|
|
55
|
+
- Phase 2 is Claude-only; Ollama mode skips it (ollama-agent handles its own queue)
|
|
56
|
+
|
|
57
|
+
Both phases run in a continuous loop with a 3-second idle sleep. The board poller runs concurrently in the same process, re-fetching `slicedata/slices` every `RALPH_POLL_INTERVAL_MS` (default 10s — see `lib/ralph.js`).
|
|
58
|
+
|
|
59
|
+
## Ollama configuration
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
OLLAMA_MODEL=qwen3.5:9b # model to use (default: qwen3.5:9b)
|
|
63
|
+
OLLAMA_URL=http://host:11434 # Ollama server URL (default: http://localhost:11434)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Config
|
|
67
|
+
|
|
68
|
+
Credentials are stored in `.build-kit/.eventmodelers/config.json` (written by `eventmodelers init`):
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"organizationId": "...",
|
|
73
|
+
"boardId": "...",
|
|
74
|
+
"token": "...",
|
|
75
|
+
"baseUrl": "https://api.eventmodelers.ai"
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Claude skills live in `.build-kit/.claude/skills/` and are available inside any Claude Code session started from `.build-kit/`.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Agent Learnings
|
|
2
|
+
|
|
3
|
+
Patterns and gotchas discovered during task processing. Update this file whenever you encounter something reusable.
|
|
4
|
+
|
|
5
|
+
## tasks.json
|
|
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.
|
|
10
|
+
|
|
11
|
+
## SliceChangedPayload fields
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
event always "slice:changed"
|
|
15
|
+
organizationId org UUID or null
|
|
16
|
+
boardId board UUID
|
|
17
|
+
sliceId SLICE_BORDER node UUID — use this with /load-slice
|
|
18
|
+
sliceTitle human-readable slice name (may be null)
|
|
19
|
+
sliceStatus e.g. "Created", "InProgress", "Done", "Blocked" (may be null)
|
|
20
|
+
timestamp unix ms when the change was emitted
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Slice files
|
|
24
|
+
|
|
25
|
+
The board poller writes one file per slice on startup and after each poll tick that detects a change:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
.slices/<context>/<sliceName>.json
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- `<context>` is the slice's context value, or `default` if none.
|
|
32
|
+
- `<sliceName>` is the slice title lowercased with spaces and the `"slice:"` prefix removed (e.g. `"slice: Enable User"` → `enableuser`).
|
|
33
|
+
|
|
34
|
+
These files are always up to date — read them directly before invoking any skill.
|
|
35
|
+
|
|
36
|
+
## Skill Usage
|
|
37
|
+
|
|
38
|
+
- Always run `/connect` first to load credentials from `.eventmodelers/config.json` before calling any other skill.
|
|
39
|
+
- `/load-slice sliceId=<uuid>` re-fetches all slices from the API, refreshes the slice files, and returns the requested slice. Use it when you need a guaranteed-fresh view of a specific slice.
|
|
40
|
+
- Read `.slices/<context>/<sliceName>.json` directly when you already know the context and name and the file is recent enough.
|
|
41
|
+
|
|
42
|
+
## Board API
|
|
43
|
+
|
|
44
|
+
- The `boardId` and `organizationId` from each payload provide full context — pass them to skills.
|
|
45
|
+
- Node events use `node:created`, `node:changed`, `node:deleted` — always POST to `/api/org/:orgId/boards/:boardId/nodes/events`.
|
|
46
|
+
- 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.
|