bedrock-flows 0.7.1

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 (85) hide show
  1. package/auth-schema.sql +8 -0
  2. package/bin/bedrock-flows.mjs +127 -0
  3. package/lib/setup.mjs +262 -0
  4. package/package.json +11 -0
  5. package/template/.storybook/main.js +46 -0
  6. package/template/.storybook/manager-head.html +963 -0
  7. package/template/.storybook/preview-head.html +35 -0
  8. package/template/.storybook/preview.js +23 -0
  9. package/template/CHANGELOG.md +236 -0
  10. package/template/README.md +26 -0
  11. package/template/apps/dashboard/index.html +15 -0
  12. package/template/apps/dashboard/package.json +22 -0
  13. package/template/apps/dashboard/src/App.module.css +1318 -0
  14. package/template/apps/dashboard/src/App.tsx +2716 -0
  15. package/template/apps/dashboard/src/auth-client.ts +17 -0
  16. package/template/apps/dashboard/src/changelog.tsx +92 -0
  17. package/template/apps/dashboard/src/index.css +86 -0
  18. package/template/apps/dashboard/src/main.tsx +15 -0
  19. package/template/apps/dashboard/src/theme.ts +31 -0
  20. package/template/apps/dashboard/src/vite-env.d.ts +4 -0
  21. package/template/apps/dashboard/vite.config.ts +48 -0
  22. package/template/apps/worker/.dev.vars.example +50 -0
  23. package/template/apps/worker/package.json +19 -0
  24. package/template/apps/worker/src/index.ts +295 -0
  25. package/template/apps/worker/tsconfig.json +11 -0
  26. package/template/apps/worker/wrangler.jsonc +29 -0
  27. package/template/bedrock.config.ts +16 -0
  28. package/template/design-system/README.md +97 -0
  29. package/template/design-system/starter-v1/components/button/component.css +42 -0
  30. package/template/design-system/starter-v1/components/button/danger.html +21 -0
  31. package/template/design-system/starter-v1/components/button/default.html +21 -0
  32. package/template/design-system/starter-v1/components/button/disabled.html +21 -0
  33. package/template/design-system/starter-v1/components/button/ghost.html +21 -0
  34. package/template/design-system/starter-v1/components/button/macro.njk +14 -0
  35. package/template/design-system/starter-v1/components/button/primary.html +21 -0
  36. package/template/design-system/starter-v1/components/button/variants.json +30 -0
  37. package/template/design-system/starter-v1/ds.json +3 -0
  38. package/template/design-system/starter-v1/global.css +52 -0
  39. package/template/design-system/starter-v1/style.css +107 -0
  40. package/template/gitignore +8 -0
  41. package/template/package.json +41 -0
  42. package/template/prototypes/F-001-hello/1-welcome.njk +30 -0
  43. package/template/prototypes/F-001-hello/2-form.njk +46 -0
  44. package/template/prototypes/F-001-hello/3-done.njk +29 -0
  45. package/template/prototypes/F-001-hello/meta.json +6 -0
  46. package/template/prototypes/_shared/_auth-gate.njk +54 -0
  47. package/template/prototypes/_shared/delivery.njk +43 -0
  48. package/template/prototypes/_shared/layout.njk +15 -0
  49. package/template/prototypes/_shared/screen.njk +1818 -0
  50. package/template/prototypes/_shared/wireflow.njk +4731 -0
  51. package/template/public/auth-gate.css +150 -0
  52. package/template/public/bedrock/color-inspector.js +284 -0
  53. package/template/public/bedrock/component-overlay.js +219 -0
  54. package/template/public/bedrock/data/bedrock-config.js +45 -0
  55. package/template/public/bedrock/font-size-overlay.js +590 -0
  56. package/template/public/bedrock/grid-overlay.js +379 -0
  57. package/template/public/bedrock/prototype-navigation.js +974 -0
  58. package/template/public/cmdk.js +146 -0
  59. package/template/public/ds-xray.css +112 -0
  60. package/template/public/ds-xray.js +271 -0
  61. package/template/public/favicon.svg +4 -0
  62. package/template/public/icons/bolt-fill.svg +3 -0
  63. package/template/public/icons/bolt.svg +3 -0
  64. package/template/public/icons/caret-down-fill.svg +3 -0
  65. package/template/public/icons/check-double.svg +4 -0
  66. package/template/public/icons/check.svg +3 -0
  67. package/template/public/icons/chevron-left.svg +3 -0
  68. package/template/public/icons/chevron-right.svg +3 -0
  69. package/template/public/icons/circle-info.svg +6 -0
  70. package/template/public/icons/grid.svg +6 -0
  71. package/template/public/icons/message-square-1.svg +3 -0
  72. package/template/public/icons/message-square.svg +3 -0
  73. package/template/public/icons/messages.svg +4 -0
  74. package/template/public/icons/options-horizontal.svg +5 -0
  75. package/template/public/icons/swatches.svg +6 -0
  76. package/template/public/icons/workflow.svg +6 -0
  77. package/template/public/lightbox.js +87 -0
  78. package/template/public/proto-chrome.css +596 -0
  79. package/template/public/screen-comments.css +723 -0
  80. package/template/public/wireflow-client.js +26 -0
  81. package/template/scripts/build-storybooks.mjs +8 -0
  82. package/template/scripts/dev-setup.mjs +15 -0
  83. package/template/scripts/generate-stories.mjs +12 -0
  84. package/template/scripts/generate-variants.mjs +22 -0
  85. package/template/tsconfig.base.json +19 -0
@@ -0,0 +1,35 @@
1
+ <!--
2
+ The compiled design-system bundle (global.css + every component.css), served
3
+ by Storybook's staticDirs mapping (../design-system/<version> -> /ds-current).
4
+ Without this link every story renders unstyled. Relative href so it resolves
5
+ under the production base (/ds/<version>/storybook/) and in dev alike.
6
+ -->
7
+ <link rel="stylesheet" href="ds-current/style.css" />
8
+
9
+ <!--
10
+ Injected into every story iframe.
11
+
12
+ The comment panel + sidebar count badges live in manager-head.html (top
13
+ window). The only behaviour needed inside the preview iframe is keeping
14
+ Figma links from hijacking the docs frame: a Figma anchor without a target
15
+ would replace the story iframe on click, so rewrite them to open a new tab.
16
+ (The source repo also injected Ziptility-specific docs chrome + DS behaviour
17
+ scripts here — those are design-system content, not the commenting feature,
18
+ so they are intentionally not ported.)
19
+ -->
20
+ <script>
21
+ (function () {
22
+ function blankFigmaLinks(root) {
23
+ const links = (root || document).querySelectorAll('a[href*="figma.com"]:not([data-blank])')
24
+ links.forEach(function (a) {
25
+ a.setAttribute('target', '_blank')
26
+ a.setAttribute('rel', 'noopener')
27
+ a.setAttribute('data-blank', '1')
28
+ })
29
+ }
30
+ blankFigmaLinks(document)
31
+ new MutationObserver(function () {
32
+ blankFigmaLinks(document)
33
+ }).observe(document.documentElement, { childList: true, subtree: true })
34
+ })()
35
+ </script>
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Per-story configuration applied across the storybook.
3
+ *
4
+ * Required for Storybook 10's autodocs path: without a preview.js sibling to
5
+ * main.js, the html-vite framework renderer isn't attached to the docs
6
+ * preparedMeta, and every Docs page throws `r.renderer is not a function`.
7
+ */
8
+
9
+ /** @type {import('@storybook/html-vite').Preview} */
10
+ const preview = {
11
+ parameters: {
12
+ layout: 'centered',
13
+ options: {
14
+ // Sidebar bucket order: Foundations (tokens) → Components (interactive
15
+ // UI) → Utilities (layout primitives). Reads top-down from "what does it
16
+ // look like" to "how do I assemble it".
17
+ storySort: { order: ['Foundations', 'Components', 'Utilities'] },
18
+ },
19
+ },
20
+ tags: ['autodocs'],
21
+ }
22
+
23
+ export default preview
@@ -0,0 +1,236 @@
1
+ # Changelog
2
+
3
+ All notable changes to Bedrock Flows are documented here.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
+ Versions 0.1.0 and 0.2.0 were tagged retroactively when this changelog was
7
+ introduced (alongside 0.3.0); from 0.3.0 on, tag at release time and keep an
8
+ `Unreleased` section at the top between releases.
9
+
10
+ ## [Unreleased]
11
+
12
+ ## [0.7.1] — 2026-06-13
13
+
14
+ ### Fixed
15
+
16
+ - **Unpinned the better-auth stack — the defensive `pnpm.overrides` lock is
17
+ lifted.** `better-auth` + `@better-auth/kysely-adapter` + `@better-auth/infra`
18
+ move to `1.6.18` / `1.6.18` / `0.2.14`, and `kysely` floats up to `0.29.2`
19
+ (from `0.28.17`). The pin existed because the old adapter imported
20
+ `DEFAULT_MIGRATION_LOCK_TABLE` from kysely, which kysely removed in `0.29.0` —
21
+ breaking the worker bundle. better-auth has since inlined that constant, so
22
+ the import no longer depends on kysely exporting it and the pin is obsolete.
23
+ Verified end-to-end: worker bundle builds, and a live sign-up writes to D1
24
+ through the kysely-d1 adapter on kysely `0.29.2`. (One non-fatal cosmetic
25
+ peer-dependency warning remains until `@better-auth/sso` ships `1.6.18`.)
26
+
27
+ ## [0.7.0] — 2026-06-13
28
+
29
+ Surfaced by real use in the Ziptility child project: the wireflow now respects
30
+ each flow's intended viewport range, sign-in UI ships from the package, and the
31
+ agentic comment loop's "needs a human" decision is visible.
32
+
33
+ ### Added
34
+
35
+ - **The `auth` package now ships the sign-in UI, not just the auth backend.**
36
+ New exports `renderSigninPage()` / `signinPageResponse()` return a
37
+ self-contained, server-rendered `/signin` page (the canonical `.bf-auth-*`
38
+ markup + inlined `auth-gate.css` styling + plain-fetch JS against
39
+ `/api/auth/*`), and `handleAuthRequest` now serves `GET /signin` and
40
+ `/signin.html` directly. Previously the package exposed only the backend
41
+ (`createAuth`, `handleAuthRequest` for `/api/auth/*` + `/__wf-people`,
42
+ `getSessionUser`), so every consuming project had to hand-maintain its own
43
+ sign-in page — the child `ziptility-feature-pipeline-prototypes` carried a
44
+ stale `public/signin.html` fork that had drifted from the canonical gate
45
+ (no field labels, a Google button that hugged its content instead of
46
+ filling the card). A project's worker can now delete its local sign-in page
47
+ and serve the package's instead, optionally customising title/lede/Google
48
+ via `handleAuthRequest(req, env, { signin: { … } })`.
49
+
50
+ - **The wireflow canvas now honors the intended viewport range.** The
51
+ per-flow range (`meta.json` `viewport` over the DS version's `ds.json`
52
+ `intendedViewport`, resolved via `bedrock.resolveViewport`) is injected into
53
+ the wireflow and consumed by the canvas Viewport control exactly as the
54
+ detail-screen control already did: out-of-range breakpoints are marked
55
+ (advisory, still clickable), an "Intended: min–max" footer shows the range +
56
+ its source, the default lands inside the range, and the chosen breakpoint is
57
+ now stored **per-flow** (`protoNavViewport:<id>`) so a desktop pick no longer
58
+ bleeds onto a mobile flow. Closes the gap where a mobile flow rendered
59
+ desktop-shaped node iframes.
60
+
61
+ - **Wireflow max-zoom is derived from the viewport range.** Instead of a fixed
62
+ 800% cap for every flow, the canvas zoom-in ceiling scales with the largest
63
+ allowed width: a mobile range (~440px) tops out ~4× (≈400%), a laptop range
64
+ (~1440px) earns the full 8× (≈800%). A screen is shrunk into its node, so the
65
+ useful max zoom is roughly what shows the largest allowed screen at
66
+ ~life-size + a little headroom — larger allowed widths earn more zoom.
67
+
68
+ - **`needs-human` comment badge.** When the agentic loop considers a comment
69
+ but defers to a human (sets `status: needs-human`), the comment now shows a
70
+ soft-blue "Needs human" pill — same treatment as the green Resolved badge —
71
+ on both the wireflow and detail-screen comment panels, so a considered-
72
+ but-deferred comment is no longer indistinguishable from an untouched one.
73
+
74
+ ## [0.6.0] — 2026-06-12
75
+
76
+ The npm release: the platform engine ships as a single published package,
77
+ and a project's dependency version states the platform release it runs.
78
+
79
+ ### Changed
80
+
81
+ - **The platform publishes as one npm package:
82
+ `@obra-studio/bedrock-flows`.** Its version number IS the platform release.
83
+ The workspace keeps its per-package structure for development (internal
84
+ scope renamed `@bedrock3/*` → `@bedrock-flows/*`, never published);
85
+ `node scripts/publish-umbrella.mjs` assembles the umbrella at publish time —
86
+ every package becomes a subpath export (`/core`, `/config`, `/auth`,
87
+ `/wireflow/client`, `/design-system/manifest`, …, with the root re-exporting
88
+ config so `import { defineConfig } from '@obra-studio/bedrock-flows'`
89
+ works), internal imports become self-referencing subpaths, and runtime
90
+ dependencies merge (exact `better-auth@1.6.9` pins carry through — root
91
+ pnpm overrides don't reach npm consumers). Licensed **FSL-1.1-MIT**
92
+ (Functional Source License: free for any non-competing use, each release
93
+ becomes MIT after two years; commercial licensing: johan@obra.studio).
94
+ This is phase 1 of platform-as-dependency: children will delete
95
+ `packages/*` and depend on the umbrella, shrinking the sync surface to
96
+ the chrome, harness assets, and apps.
97
+
98
+ ## [0.5.1] — 2026-06-12
99
+
100
+ The portability release: child deployments can now upgrade with one command,
101
+ and per-project values move out of platform files so that upgrade is lossless.
102
+
103
+ ### Added
104
+
105
+ - **`sync-child` upgrade script.** `node scripts/sync-child.mjs <child> --check`
106
+ detects which platform release a same-shaped child effectively runs and
107
+ lists its local drift; `--apply --tag vX.Y.Z --branch` upgrades the child's
108
+ platform files wholesale on an `upgrade/<tag>` branch, stamps the version,
109
+ and runs install + build. Child-owned files (worker config, chrome plugin
110
+ toggles/breakpoints) are never touched.
111
+ - **Dashboard dev sign-in on :5173.** Upstreamed from the UGent child: the
112
+ dashboard dev server pins port 5173 and proxies auth/comments/people/spec
113
+ routes to the wrangler worker on :8787, so local sign-in works without
114
+ switching origins.
115
+
116
+ ### Changed
117
+
118
+ - **Per-project values leave platform files.** The dashboard's comments
119
+ origin now comes from the project's `bedrock.config.ts`
120
+ (`modules.commenting.prodOrigin`, injected at build time) instead of a
121
+ hardcoded URL — every deployment must point at its **own** worker, never
122
+ another project's. Storybook's fallback DS version likewise follows the
123
+ project's `defaultDsVersion`.
124
+
125
+ ## [0.5.0] — 2026-06-12
126
+
127
+ The cleanup release: two deprecated subsystems leave the platform.
128
+
129
+ ### Removed
130
+
131
+ - **Template sets.** The deprecated template-sets module is gone — the
132
+ `@bedrock3/template-sets` package, the `/t` routes, the shared
133
+ `template-set.njk` chrome, and every `templateSet` / `isTemplateSet` branch
134
+ across config, core, the wireflow, the worker, and the dashboard. No
135
+ content was affected; no prototype declared a template set.
136
+ - **Spec-view inline comments.** The spec view's inline-comment layer
137
+ (selection → comment button, thread popover, quote-match highlights) is
138
+ removed, superseded by the spec-composer margin-comment direction. Spec
139
+ display and in-place editing keep working unchanged.
140
+
141
+ ## [0.4.2] — 2026-06-12
142
+
143
+ The viewport-intent release: design systems and flows declare the resolution
144
+ range they're designed for, and the review chrome keeps everyone honest
145
+ about it. (Supersedes the 0.4.0/0.4.1 iterations of the same feature.)
146
+
147
+ ### Added
148
+
149
+ - **Intended viewport range.** A design system can now declare the resolution
150
+ range it's designed for (`design-system/<version>/ds.json` →
151
+ `intendedViewport`), and any flow can override it in its `meta.json`
152
+ (`viewport`) — so a phone-only flow can span small phone to large phone
153
+ while a responsive web flow spans small phone to laptop. Ranges are written
154
+ as raw `{ "w": …, "h": … }` CSS pixels (the canonical format) or as generic
155
+ device-class shorthand carrying the looked-up logical resolution of a
156
+ reference device: `small-phone` 375×812 (iPhone 12 mini), `phone` 402×874
157
+ (iPhone 16 Pro / 17), `large-phone` 440×956 (iPhone 17 Pro Max),
158
+ `square-foldable-phone` 984×1092 (Galaxy Z Fold 7 unfolded), a tablet
159
+ family in portrait + wide variants — `small-tablet` 744×1133 (iPad mini),
160
+ `tablet` 834×1210 (iPad Pro 11"), `large-tablet` 1032×1376 (iPad Pro 13") —
161
+ plus `trifold` (= `tablet-wide`), `small-laptop` 1280×800, `laptop`
162
+ 1440×900, `medium-desktop` 1920×1080, and `large-desktop` 2560×1440. The
163
+ screen chrome's Viewport control shows the intended range, dims breakpoints
164
+ outside it, and the drag-resize readout turns amber when you leave it —
165
+ advisory, never a clamp.
166
+ - **In-app changelog + version badge.** The sidebar shows the release you're
167
+ running; clicking it opens this changelog as a page in the app (also
168
+ reachable via ⌘K).
169
+
170
+ ## [0.3.0] — 2026-06-12
171
+
172
+ The roles & review-flow release: comments learn who said what and what agents
173
+ may act on, and design content goes behind sign-in.
174
+
175
+ ### Added
176
+
177
+ - **Manager role + designer approval flow.** A new manager role joins
178
+ user/designer/admin. Manager comments are never directly actionable: they
179
+ arrive as "pending review", and a designer approves them — optionally
180
+ adding context for the agent — before anything gets designed. Every
181
+ comment panel shows the pending state and gives designers an inline
182
+ approve-with-context composer.
183
+ - **Role management in user admin.** Each user can be set to one of four
184
+ roles: user (reviewer) · manager (comments need designer approval) ·
185
+ designer (actionable comments, approves managers) · admin (designer plus
186
+ user management).
187
+ - **Node-anchored comments (experimental).** Screen comments can anchor to a
188
+ specific element rather than the whole screen.
189
+ - **Side-note opt-out + commented viewport.** A compose-time toggle marks a
190
+ comment as a side note (excluded from the agentic loop), and every comment
191
+ records the viewport it was made at; the queue preview renders that exact
192
+ viewport instead of full page height.
193
+ - **Comment polish.** URLs linkified in comment text; resolved comments drop
194
+ the strikethrough; card layout reworked (chips on their own row, byline on
195
+ its own line).
196
+
197
+ ### Changed
198
+
199
+ - **Design content now requires sign-in.** Flows, screens, and design-system
200
+ pages are gated the same way the dashboard is — nothing is reachable
201
+ anonymously anymore.
202
+
203
+ ## [0.2.0] — 2026-06 (retroactive)
204
+
205
+ The harness & comments wave.
206
+
207
+ ### Added
208
+
209
+ - **Responsive Viewport preview** for flow screens and the wireflow.
210
+ - **Touch-device harness chrome**, plus a `d` shortcut to toggle chrome
211
+ light/dark.
212
+ - **DS X-ray + ⌘K palette** (current iteration), including the clickthrough
213
+ from an x-rayed element to its Storybook story.
214
+ - **Comment image attachments**, clipboard paste, a shared lightbox with the
215
+ comment text as caption, and images attached to queue reopen notes.
216
+
217
+ ### Changed
218
+
219
+ - Wireflow zoom cap raised from 400% to 800%; wireflow node hit area pinned
220
+ to the frame width.
221
+ - Sign-in screen polish: visible labels, consistent typography.
222
+
223
+ ## [0.1.0] — 2026 (retroactive)
224
+
225
+ The platform foundation.
226
+
227
+ ### Added
228
+
229
+ - **Bedrock Flows**: a dashboard of linkable feature flows (wireflows) with
230
+ per-screen commenting, versioned design-system storybooks, and the agent
231
+ designs queue.
232
+ - **Accounts**: invite-only sign-up with email verification, Google sign-in,
233
+ and in-app user management with email invites.
234
+ - **DS X-ray**: see which design-system pieces a screen is built from.
235
+ - **Front-end deliveries**: a page-tree of delivered front-ends, landing on
236
+ the home page.
@@ -0,0 +1,26 @@
1
+ # Bedrock Flows — project
2
+
3
+ This project runs the **published** Bedrock Flows platform (`@obra-studio/bedrock-flows`). You edit
4
+ the content; the platform comes from npm. Upgrade with `npm install @obra-studio/bedrock-flows@latest`.
5
+
6
+ ## What you edit
7
+ - `prototypes/` — wireflow prototypes (one folder per flow; `_shared/` holds the page templates).
8
+ - `design-system/` — versioned design systems (`<version>/components/<name>/{component.css,macro.njk,variants.json}`).
9
+ - `bedrock.config.ts` — which modules are enabled + this project's comment `prodOrigin`.
10
+
11
+ ## Develop
12
+ ```bash
13
+ npm install
14
+ npm run dev # one command: worker + dashboard + design-system storybook
15
+ ```
16
+ Open <http://localhost:5173>. First run generates `apps/worker/.dev.vars`
17
+ automatically — no setup needed.
18
+
19
+ ## Deploy
20
+ ```bash
21
+ npm run deploy # builds, then wrangler deploy
22
+ ```
23
+ Cloudflare resources (KV, D1, secrets) are set up separately.
24
+
25
+ > Scaffolded by `npx bedrock-flows create`. The platform wiring here is generated —
26
+ > change it upstream, not in this project.
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Bedrock Flows</title>
7
+ <!-- Shared auth-gate card styling — single source across dashboard/wireflow/screen. -->
8
+ <link rel="stylesheet" href="/auth-gate.css" />
9
+ </head>
10
+ <body>
11
+ <div id="root"></div>
12
+ <script type="module" src="/src/main.tsx"></script>
13
+ <script src="/lightbox.js" defer></script>
14
+ </body>
15
+ </html>
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@bedrock-flows/dashboard",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "description": "Dashboard SPA — thin shell that assembles enabled modules into the sidebar",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "build": "vite build",
10
+ "preview": "vite preview"
11
+ },
12
+ "dependencies": {
13
+ "@obra-studio/bedrock-flows": "__BEDROCK_FLOWS_VERSION__",
14
+ "better-auth": "^1.6.9",
15
+ "react": "^19.2.5",
16
+ "react-dom": "^19.2.5"
17
+ },
18
+ "devDependencies": {
19
+ "@vitejs/plugin-react": "^6.0.1",
20
+ "vite": "^8.0.10"
21
+ }
22
+ }