@synap-core/workspace-templates 0.53.0 → 0.55.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synap-core/workspace-templates",
3
- "version": "0.53.0",
3
+ "version": "0.55.0",
4
4
  "type": "module",
5
5
  "description": "Canonical workspace definitions — YAML source + typed exports for browser, backend, CLI, and marketplace",
6
6
  "repository": {
package/retired.yaml CHANGED
@@ -134,3 +134,13 @@ retired:
134
134
  replacedBy: content-os
135
135
  reason: Content Studio was folded into Content OS, which now keeps your videos, carousels and other visual posts with the rest of your content.
136
136
  since: "2026-11-03"
137
+
138
+ # Founder decision 2026-11-18 (pod session 319b8bb2, « CRM carries it »): the
139
+ # lead → client rule ships inside the CRM space (crm.yaml `automations:`, same
140
+ # name and key), so every pod with CRM gets it and a CRM update refreshes it.
141
+ # The standalone package was private and the market could not install it.
142
+ # No replacedBy: CRM is a workspace, and replacedBy names the same category.
143
+ - slug: lead-converted-becomes-client
144
+ kind: automation
145
+ reason: This rule now comes with the CRM space; installing or updating CRM installs it.
146
+ since: "2026-11-18"
@@ -125,7 +125,7 @@ then critique again from scratch (a fresh list, new ids) — never edit a findin
125
125
 
126
126
  ## Critiquing a built screen
127
127
 
128
- The same rubric runs on the implemented story (`implemented-story-id`) in Verify: capture it with the
128
+ The same rubric runs on each implemented story (`implemented-story-id`, or every story in `frame-stories`) in Verify: capture it with the
129
129
  Storybook capture door (`pnpm --filter @synap-core/storybook capture`), run the `checked` tier on the
130
130
  real render, and compare it with the design and the `current-story-id` capture. `region` is then a
131
131
  locator in the story, not a Puck node id.
@@ -135,7 +135,7 @@ Find before you create: `synap_find` for an existing `ui-design` on the same `ta
135
135
  `components-used` (the distinct `type` values in the JSON, across every frame of a canvas — derived
136
136
  from it, never typed by hand),
137
137
  `schema-version` (`3`), `motion` (above), `current-story-id` (the Storybook story id of the screen as
138
- it is today, when it exists), `design-notes` (intent, open questions). A new design starts at `draft`.
138
+ it is today, when it exists), `frame-stories` (the built stories per frame of a multi-frame design, see Implementing), `design-notes` (intent, open questions). A new design starts at `draft`.
139
139
  - **Three variants by default.** One request = THREE designs: the request itself and two sibling
140
140
  `ui-design`s, all with the same `variant-group` (any stable id, e.g. the request's entity id) and the
141
141
  same `target-surface`, `design-scope` and `design-goal`. Make them genuinely different answers
@@ -173,10 +173,14 @@ Before a person sees the variants, critique each with the **design-critique** sk
173
173
  - At review, the person picks ONE variant. Inside the process the run carries the request design: if
174
174
  the person chooses a sibling, write that sibling's `design-json`, `components-used` and `motion` into
175
175
  the request design before it is approved; archiving the others is the person's call.
176
- - Implementing: record the built story's id in `implemented-story-id` (one story per design; for a
177
- multi-frame design, record each screen's story id in `design-notes`), capture it with the
178
- Storybook capture door (`pnpm --filter @synap-core/storybook capture`) and compare it with the design
179
- and with `current-story-id`.
176
+ - Implementing: record the built stories on the design. A single-frame design records its story id in
177
+ `implemented-story-id`. A design with several frames records a map in `frame-stories`,
178
+ `{ "<frameId>": ["<storyId>", ...] }`: every frame id of `design-json` is a key, and one frame may serve
179
+ several stories (its states), so a story is never guessed from a frame's name. Leave
180
+ `implemented-story-id` empty for a multi-frame design; existing designs are not migrated, so a reader
181
+ uses `implemented-story-id` when the map is empty. Capture each story with the
182
+ Storybook capture door (`pnpm --filter @synap-core/storybook capture`) and compare it, frame by frame,
183
+ with that frame of the design and with `current-story-id`.
180
184
 
181
185
  ## Do not
182
186
 
package/src/builder.yaml CHANGED
@@ -1454,6 +1454,12 @@ profiles:
1454
1454
  valueType: string
1455
1455
  inputType: text
1456
1456
  placeholder: "The app and screen it is for, e.g. browser › Settings › Agents"
1457
+ - slug: design-app
1458
+ label: App
1459
+ valueType: entity_id
1460
+ targetProfileSlug: devplane_app
1461
+ inputType: entity_select
1462
+ description: The app this design is for (one devplane_app, filed into the design's project). The Design app lists an app's designs by it; target-surface stays the screen's name.
1457
1463
  - slug: design-scope
1458
1464
  label: Scope
1459
1465
  description: One component, or a whole page.
@@ -1514,9 +1520,14 @@ profiles:
1514
1520
  inputType: url
1515
1521
  - slug: implemented-story-id
1516
1522
  label: Implemented story
1517
- description: The Storybook story id of the built screen — the "after" of the compare.
1523
+ description: The Storybook story id of the built screen — the "after" of the compare. For a single-frame design; a multi-frame design records its stories per frame in frame-stories.
1518
1524
  valueType: string
1519
1525
  inputType: text
1526
+ - slug: frame-stories
1527
+ label: Frame stories
1528
+ description: 'The built stories of a design with several frames, as a map { "<frameId>": ["<storyId>", ...] }: each key is a frame id of design-json, each value the Storybook story ids built for that screen (one frame may serve several stories, for its states). For a single-frame design leave it empty and use implemented-story-id; for a multi-frame design this map is the record and implemented-story-id is left empty. Existing designs are not migrated: a reader falls back to implemented-story-id when the map is empty.'
1529
+ valueType: json
1530
+ inputType: json
1520
1531
  - slug: design-notes
1521
1532
  label: Notes
1522
1533
  valueType: string
@@ -1729,7 +1740,7 @@ playbooks:
1729
1740
  and only a person sets approved. IMPLEMENT: read design-json and the
1730
1741
  Storybook MCP, build the screen from those same real components, open a
1731
1742
  pull request and record its URL in implementation-pr and the built
1732
- screen's story in implemented-story-id. VERIFY: typecheck, story coverage,
1743
+ screen's story in implemented-story-id (a single-frame design) or, for a design of several frames, each frame's stories in frame-stories ({ frameId: [storyId, ...] }). VERIFY: typecheck, story coverage,
1733
1744
  interaction and accessibility tests, visual regression and the token
1734
1745
  guards are green, the implemented story was captured and compared with
1735
1746
  the design and the current story, and the screen was walked in the
@@ -1804,8 +1815,8 @@ playbooks:
1804
1815
  statement: The pull request URL is recorded in implementation-pr.
1805
1816
  check: { kind: evidence, evidenceKey: implementation-pr }
1806
1817
  - key: implemented-story-linked
1807
- statement: The Storybook story id of the built screen is recorded in implemented-story-id.
1808
- check: { kind: evidence, evidenceKey: implemented-story-id }
1818
+ statement: The built stories are recorded on the design, in implemented-story-id for a single-frame design, or in frame-stories for each frame of a multi-frame design (every frame of design-json has at least one story).
1819
+ check: { kind: judge }
1809
1820
  - key: implementation-matches-design
1810
1821
  statement: The screen uses the components and structure the design JSON names, with no invented component and no hardcoded colour.
1811
1822
  check: { kind: judge }
package/src/crm.yaml CHANGED
@@ -3,9 +3,10 @@
3
3
  # leadStage, "Qualify a lead"), the sale (the deal's commercialStage, "Win a
4
4
  # deal") and the campaigns people come from. A lead that signs becomes a
5
5
  # client (founder, 17 Nov 2026, design 05ed390c): a person moves it to
6
- # `converted` (= signed), the automation `lead-converted-becomes-client` attaches
7
- # the `client` role handed off to Operations, and Operations onboards it ("Onboard
8
- # a client"). Clients and client delivery belong to Operations.
6
+ # `converted` (= signed), the automation `lead-converted-becomes-client` (this
7
+ # file's `automations:`, installed and updated with CRM) attaches the `client`
8
+ # role at onboarding, handed off to Operations, and Operations onboards it
9
+ # ("Onboard a client"). Clients and client delivery belong to Operations.
9
10
  #
10
11
  # Business Developer folded into this file (founder decision 2026-10-12): its
11
12
  # lead/client fields, the campaign kind and "Qualify a lead" live here now; its
@@ -74,10 +75,11 @@ meta:
74
75
  # The ONE primary output (One model decision 3): the won deal. A lead
75
76
  # that signs becomes a client through ONE door (founder, 17 Nov 2026,
76
77
  # design 05ed390c): a person moves it to `converted` (= signed), and the
77
- # CRM automation `lead-converted-becomes-client` stamps `convertedAt` and
78
- # attaches the `client` role handed off to Operations. The client is
79
- # Operations' output (its Clients board and "Onboard a client"), not this
80
- # space's: the CRM still references the role for the handoff fields.
78
+ # automation `lead-converted-becomes-client` (this file's `automations:`)
79
+ # stamps `convertedAt` and attaches the `client` role handed off to
80
+ # Operations. The client is Operations' output (its Clients board and
81
+ # "Onboard a client"), not this space's: the CRM still references the role
82
+ # for the handoff fields.
81
83
  primary: deal
82
84
  produces:
83
85
  - profile: lead
@@ -382,11 +384,12 @@ profiles:
382
384
  # equal foundation's (shared-role-ssot rule c). validate.ts rule
383
385
  # `shared-role-reference-*` requires foundation in the dependency chain.
384
386
  # ═══════════════════════════════════════════════════════════════════════════
385
- # The handoff context written when a lead signs (the CRM automation
386
- # `lead-converted-becomes-client` attaches the role with becameClientAt,
387
- # handoffStatus handed_off and handoffDestination Operations) and that
388
- # Operations' "Pick up handed-off clients" safety net reads. Moved verbatim
389
- # from business-developer (2026-10-12).
387
+ # The handoff context written when a lead signs (the automation
388
+ # `lead-converted-becomes-client`, this file's `automations:`, attaches the
389
+ # role with clientStatus onboarding, becameClientAt, handoffStatus
390
+ # handed_off and handoffDestination Operations) and that Operations' "Pick up
391
+ # handed-off clients" safety net reads. Moved verbatim from
392
+ # business-developer (2026-10-12).
390
393
  - slug: client
391
394
  displayName: Client
392
395
  scope: shared
@@ -2461,6 +2464,93 @@ playbooks:
2461
2464
  gate: { kind: human }
2462
2465
  onFail: { toStage: draft }
2463
2466
 
2467
+ # CRM carries the lead → client rule (founder, 18 Nov 2026, pod session
2468
+ # 319b8bb2): it installs with CRM and every CRM update refreshes it. This is its
2469
+ # ONE source; the standalone `automations/lead-converted-becomes-client` file is
2470
+ # retired (retired.yaml). The apply finds an existing automation of the same
2471
+ # name (or `templateKey`) in the space and updates it in place, never a second
2472
+ # row (the space's names are unique, case-folded).
2473
+ automations:
2474
+ - key: lead-converted-becomes-client
2475
+ name: "A lead signs: it becomes a client"
2476
+ description: >-
2477
+ When a lead moves to converted (the client signed; a person's move, so an
2478
+ agent's move is a proposal the person approves first), the lead is
2479
+ stamped with the date it converted and the same person or company gets
2480
+ the client role at onboarding, handed off to Operations. Operations'
2481
+ "Onboard a client" starts when the client role is attached. The converted
2482
+ lead role stays as the history of the sale. Attaching the client role
2483
+ again is a no-op, so the CRM app's own handoff and this rule never add a
2484
+ second client role.
2485
+ triggerType: event
2486
+ triggerConfig:
2487
+ eventPattern: entity.transition.completed
2488
+ # `lifecycleProfile` is the ROLE whose lifecycle moved (never
2489
+ # `profileSlug`, which carries the entity's kind).
2490
+ filters: { lifecycleProfile: lead, to: converted }
2491
+ status: active
2492
+ flow:
2493
+ nodes:
2494
+ - id: t
2495
+ type: trigger
2496
+ position: { x: 0, y: 0 }
2497
+ data:
2498
+ label: A lead moved to converted
2499
+ triggerType: event
2500
+ config:
2501
+ eventPattern: entity.transition.completed
2502
+ filters: { lifecycleProfile: lead, to: converted }
2503
+ - id: has-entity
2504
+ type: guard
2505
+ position: { x: 0, y: 120 }
2506
+ data:
2507
+ label: The move names the person or company that signed
2508
+ checks:
2509
+ - path: trigger.payload.data.entityId
2510
+ minLength: 36
2511
+ message: "The lead's move names no person or company: there is no one to make a client."
2512
+ - id: now
2513
+ type: compute
2514
+ position: { x: 0, y: 240 }
2515
+ data:
2516
+ label: When the lead signed
2517
+ operation: now
2518
+ # A stamp only: the lead stays converted, nothing moves or detaches it.
2519
+ - id: stamp-lead
2520
+ type: output
2521
+ position: { x: 0, y: 360 }
2522
+ data:
2523
+ label: Stamp the lead with the date it converted
2524
+ outputType: facet_update
2525
+ config:
2526
+ entityId: "{{trigger.payload.data.entityId}}"
2527
+ facetSlug: lead
2528
+ properties:
2529
+ convertedAt: "{{steps.now.output.result}}"
2530
+ # No `workspaceId`: the facet inherits the pod-wide entity's (the verb's
2531
+ # param cannot be null). `onboarding` is where Operations' "Onboard a
2532
+ # client" starts; the lifecycle default (active) is a status its run
2533
+ # never moves back from.
2534
+ - id: become-client
2535
+ type: output
2536
+ position: { x: 0, y: 480 }
2537
+ data:
2538
+ label: Attach the client role at onboarding, handed off to Operations
2539
+ outputType: facet_attach
2540
+ config:
2541
+ entityId: "{{trigger.payload.data.entityId}}"
2542
+ facetSlug: client
2543
+ properties:
2544
+ clientStatus: onboarding
2545
+ becameClientAt: "{{steps.now.output.result}}"
2546
+ handoffStatus: handed_off
2547
+ handoffDestination: Operations
2548
+ edges:
2549
+ - { id: e1, source: t, target: has-entity }
2550
+ - { id: e2, source: has-entity, target: now }
2551
+ - { id: e3, source: now, target: stamp-lead }
2552
+ - { id: e4, source: stamp-lead, target: become-client }
2553
+
2464
2554
  # The lead requirement keeps "Qualify a lead" out of plain person/company
2465
2555
  # records (rendered by CRM and Browser through the shared entity-action runner).
2466
2556
  actionPlacements:
@@ -43,11 +43,32 @@ describe("Design to implementation — the design loop", () => {
43
43
  const keys = stages.flatMap((s) =>
44
44
  (s.criteria ?? []).map((c) => c.check?.evidenceKey).filter(Boolean)
45
45
  );
46
- expect(keys.length).toBeGreaterThanOrEqual(4); // non-vacuity: design-json, critique, implementation-pr, implemented-story-id
46
+ expect(keys.length).toBeGreaterThanOrEqual(3); // non-vacuity: design-json, critique, implementation-pr
47
47
  const declared = new Set(kind.properties.map((p) => p.slug));
48
48
  expect(keys.filter((k) => !declared.has(k!))).toEqual([]);
49
49
  });
50
50
 
51
+ it("a multi-frame design records its stories as a frame-stories map; the Implement stage does not demand the single-frame key", () => {
52
+ const props = new Map(kind.properties.map((p) => [p.slug, p]));
53
+ expect(props.get("frame-stories")?.valueType).toBe("json");
54
+ expect(props.has("implemented-story-id")).toBe(true);
55
+ const implement = stages.find((s) => s.key === "implement")!;
56
+ const evidence = (implement.criteria ?? [])
57
+ .map((c) => c.check?.evidenceKey)
58
+ .filter(Boolean);
59
+ expect(evidence).not.toContain("implemented-story-id");
60
+ expect(JSON.stringify(pb)).toContain("frame-stories");
61
+ });
62
+
63
+ it("a design names its app: design-app is one devplane_app, a kind this template declares", () => {
64
+ // The Design app lists an app's designs by this property (Hub
65
+ // `filters=properties.design-app`), so it must point at the app kind.
66
+ const prop = kind.properties.find((p) => p.slug === "design-app");
67
+ expect(prop?.valueType).toBe("entity_id");
68
+ expect(prop?.targetProfileSlug).toBe("devplane_app");
69
+ expect(builder.profiles.some((p) => p.slug === "devplane_app")).toBe(true);
70
+ });
71
+
51
72
  it("Critique sits between Generate and Review: no status, a check gate, rework to Generate", () => {
52
73
  expect(stages.map((s) => s.key).slice(0, 3)).toEqual([
53
74
  "generate",
@@ -9,12 +9,14 @@
9
9
  * header exists (so the catalog publishes it); the lead lifecycle really holds
10
10
  * both options. Not covered: that a pod runs it end to end (NEEDS-DOGFOOD).
11
11
  */
12
- import { readFileSync } from "node:fs";
12
+ import { existsSync, readFileSync } from "node:fs";
13
13
  import { dirname, join } from "node:path";
14
14
  import { fileURLToPath } from "node:url";
15
+ import { load } from "js-yaml";
15
16
  import { describe, expect, it } from "vitest";
16
17
  import { validateFlowDefinition } from "./validate-flow.js";
17
- import { getWorkspaceTemplate } from "./templates.js";
18
+ import { getWorkspaceTemplate, listWorkspaceTemplates } from "./templates.js";
19
+ import { toPackageDefinition, toWorkspaceDefinition } from "./define.js";
18
20
 
19
21
  const dir = join(dirname(fileURLToPath(import.meta.url)), "../automations");
20
22
  const read = (f: string) => JSON.parse(readFileSync(join(dir, f), "utf8"));
@@ -113,20 +115,61 @@ describe("lead-sent-outreach", () => {
113
115
  * BEFORE the client role is attached with the handoff fields the CRM declares
114
116
  * and Operations' safety net reads; the attach names no `workspaceId` (the
115
117
  * facet inherits the pod-wide entity's, and the verb's param cannot be null);
116
- * nothing detaches the lead role. Not covered: that a pod runs it end to end,
117
- * and that the attach reaches Operations' "Onboard a client" (backend W1) —
118
- * NEEDS-DOGFOOD.
118
+ * nothing detaches the lead role.
119
+ *
120
+ * CRM carries it (founder, 18 Nov 2026, pod session 319b8bb2): the rule lives
121
+ * in crm.yaml `automations:`, its ONE source, so installing or updating CRM
122
+ * installs it; the standalone file is gone and tombstoned; the wire carries its
123
+ * `key`, which the apply matches (with the name) to update an existing row in
124
+ * place. Not covered: that a pod runs it end to end, that the attach reaches
125
+ * Operations' "Onboard a client" (backend W1), and the apply's same-name update
126
+ * on a real pod (backend) — NEEDS-DOGFOOD.
119
127
  */
120
128
  describe("lead-converted-becomes-client", () => {
121
- const conv = read("lead-converted-becomes-client.automation.json");
122
- const convHeader = read("lead-converted-becomes-client.catalog.json");
123
- const convNodes = conv.flowDefinition.nodes as Array<{ id: string; type: string; data: Record<string, any> }>;
124
- const byOutput = (t: string) => convNodes.filter((n) => n.data.outputType === t);
125
129
  const foundation = getWorkspaceTemplate("foundation")!;
126
130
  const crm = getWorkspaceTemplate("crm")!;
131
+ const KEY = "lead-converted-becomes-client";
132
+ const NAME = "A lead signs: it becomes a client";
133
+ const conv = (crm.automations ?? []).find((a) => a.key === KEY)!;
134
+ const flow = conv?.flow as { nodes: unknown[]; edges: Array<{ source: string; target: string }> };
135
+ const convNodes = (flow?.nodes ?? []) as Array<{ id: string; type: string; data: Record<string, any> }>;
136
+ const byOutput = (t: string) => convNodes.filter((n) => n.data.outputType === t);
137
+
138
+ it("CRM carries it: the CRM template holds it under its one name, and no other template does", () => {
139
+ expect(conv).toBeDefined();
140
+ expect(conv.name).toBe(NAME);
141
+ expect((crm.automations ?? []).filter((a) => a.key === KEY || a.name === NAME)).toHaveLength(1);
142
+ const carriers = listWorkspaceTemplates()
143
+ .filter((t) => (t.automations ?? []).some((a) => a.key === KEY || a.name === NAME))
144
+ .map((t) => t.meta.slug);
145
+ expect(carriers).toEqual(["crm"]);
146
+ });
147
+
148
+ it("one source: the standalone automation file is gone, and its slug is tombstoned", () => {
149
+ expect(existsSync(join(dir, `${KEY}.automation.json`))).toBe(false);
150
+ expect(existsSync(join(dir, `${KEY}.catalog.json`))).toBe(false);
151
+ const retired = load(readFileSync(join(dir, "../retired.yaml"), "utf8")) as {
152
+ retired: Array<{ slug: string; kind?: string; replacedBy?: string }>;
153
+ };
154
+ expect(retired.retired.filter((t) => t.slug === KEY)).toEqual([
155
+ expect.objectContaining({ slug: KEY, kind: "automation" }),
156
+ ]);
157
+ });
158
+
159
+ it("the install and update wire carries it with its key, so a re-apply updates the same row", () => {
160
+ // The apply (backend applyPackagePostWorkspace) matches an existing row in
161
+ // the space by name OR metadata.templateKey = key and updates it; the
162
+ // reconcile path matches lower(name). Both need the name and key unchanged.
163
+ const wired = (toPackageDefinition("crm").automations ?? []).filter((a) => a.key === KEY);
164
+ expect(wired).toHaveLength(1);
165
+ expect(wired[0]).toMatchObject({ key: KEY, name: NAME, triggerType: "event", status: "active" });
166
+ expect(wired[0].flowDefinition).toEqual(conv.flow);
167
+ const flowAutomations = toWorkspaceDefinition("crm").definition.flowAutomations ?? [];
168
+ expect(flowAutomations.filter((a) => a.key === KEY)).toEqual(wired);
169
+ });
127
170
 
128
171
  it("passes the flow validator", () => {
129
- expect(validateFlowDefinition(conv.flowDefinition).errors).toEqual([]);
172
+ expect(validateFlowDefinition(flow as never).errors).toEqual([]);
130
173
  });
131
174
 
132
175
  it("fires on the lead's move to converted (the transition event, on the role, on trigger and node)", () => {
@@ -160,6 +203,7 @@ describe("lead-converted-becomes-client", () => {
160
203
  entityId: "{{trigger.payload.data.entityId}}",
161
204
  facetSlug: "client",
162
205
  properties: {
206
+ clientStatus: "onboarding",
163
207
  becameClientAt: `{{steps.${now.id}.output.result}}`,
164
208
  handoffStatus: "handed_off",
165
209
  handoffDestination: "Operations",
@@ -169,7 +213,7 @@ describe("lead-converted-becomes-client", () => {
169
213
 
170
214
  // One chain, in order: trigger → guard → now → stamp → attach.
171
215
  const order = ["t", guard.id, now.id, stamp.id, attach.id];
172
- expect(conv.flowDefinition.edges.map((e: { source: string; target: string }) => [e.source, e.target])).toEqual(
216
+ expect(flow.edges.map((e) => [e.source, e.target])).toEqual(
173
217
  order.slice(0, -1).map((id, i) => [id, order[i + 1]])
174
218
  );
175
219
  // The lead role is kept as history: nothing moves or detaches it.
@@ -178,20 +222,31 @@ describe("lead-converted-becomes-client", () => {
178
222
  expect(convNodes.filter((n) => n.type === "output")).toHaveLength(2);
179
223
  });
180
224
 
225
+ it("attaches the client at onboarding, the status Operations' first stage starts at (an attach left to the lifecycle default lands at active, and the run never moves it back)", () => {
226
+ // The pod's default for clientStatus is `active` (an older pod) or the
227
+ // first option (`prospect`): neither is onboarding. "Onboard a client"'s
228
+ // birth stage writes `onboarding`, but never moves a subject BACKWARDS, and
229
+ // `active` is its kick-off stage's status, so a client attached at the
230
+ // default stayed active through its whole onboarding (perso pod, 18 Nov 2026).
231
+ const [attach] = byOutput("facet_attach");
232
+ const client = foundation.profiles.find((p) => p.slug === "client")!;
233
+ expect(attach.data.config.properties.clientStatus).toBe("onboarding");
234
+ expect(client.lifecycle!.options.map((o) => o.key)).toContain("onboarding");
235
+ const playbooks = (getWorkspaceTemplate("operations")?.playbooks ?? []) as Array<{ name?: unknown; stages?: unknown[] }>;
236
+ const onboard = playbooks.find((p) => p.name === "Onboard a client");
237
+ expect(onboard?.stages?.[0]).toMatchObject({ key: "welcome", subjectStatus: "onboarding" });
238
+ });
239
+
181
240
  it("writes only fields the catalog declares, with values the selects offer", () => {
182
241
  const leadProps = crm.profiles.find((p) => p.slug === "lead")!.properties.map((p) => p.slug);
183
242
  expect(leadProps).toContain("convertedAt");
184
243
  const clientProps = crm.profiles.find((p) => p.slug === "client")!.properties;
244
+ // The role's own fields (its lifecycle, clientStatus) live in foundation; CRM adds the handoff ones.
245
+ const declared = [...foundation.profiles.find((p) => p.slug === "client")!.properties, ...clientProps].map((p) => p.slug);
185
246
  const [attach] = byOutput("facet_attach");
186
- for (const key of Object.keys(attach.data.config.properties)) expect(clientProps.map((p) => p.slug)).toContain(key);
247
+ for (const key of Object.keys(attach.data.config.properties)) expect(declared).toContain(key);
187
248
  expect(clientProps.find((p) => p.slug === "handoffStatus")!.enumValues).toContain("handed_off");
188
249
  // Operations' 07:00 safety net reads the same value.
189
250
  expect(JSON.stringify(getWorkspaceTemplate("operations")!.automations)).toContain("contains-any ready,handed_off");
190
251
  });
191
-
192
- it("has a catalog header, so it is published", () => {
193
- expect(convHeader.kind).toBe("automation");
194
- expect(convHeader.meta.slug).toBe("lead-converted-becomes-client");
195
- expect(convHeader.meta.name).toBe(conv.name);
196
- });
197
252
  });
package/src/templates.ts CHANGED
@@ -5891,6 +5891,14 @@ const DATA = {
5891
5891
  "inputType": "text",
5892
5892
  "placeholder": "The app and screen it is for, e.g. browser › Settings › Agents"
5893
5893
  },
5894
+ {
5895
+ "slug": "design-app",
5896
+ "label": "App",
5897
+ "valueType": "entity_id",
5898
+ "targetProfileSlug": "devplane_app",
5899
+ "inputType": "entity_select",
5900
+ "description": "The app this design is for (one devplane_app, filed into the design's project). The Design app lists an app's designs by it; target-surface stays the screen's name."
5901
+ },
5894
5902
  {
5895
5903
  "slug": "design-scope",
5896
5904
  "label": "Scope",
@@ -5981,10 +5989,17 @@ const DATA = {
5981
5989
  {
5982
5990
  "slug": "implemented-story-id",
5983
5991
  "label": "Implemented story",
5984
- "description": "The Storybook story id of the built screen — the \"after\" of the compare.",
5992
+ "description": "The Storybook story id of the built screen — the \"after\" of the compare. For a single-frame design; a multi-frame design records its stories per frame in frame-stories.",
5985
5993
  "valueType": "string",
5986
5994
  "inputType": "text"
5987
5995
  },
5996
+ {
5997
+ "slug": "frame-stories",
5998
+ "label": "Frame stories",
5999
+ "description": "The built stories of a design with several frames, as a map { \"<frameId>\": [\"<storyId>\", ...] }: each key is a frame id of design-json, each value the Storybook story ids built for that screen (one frame may serve several stories, for its states). For a single-frame design leave it empty and use implemented-story-id; for a multi-frame design this map is the record and implemented-story-id is left empty. Existing designs are not migrated: a reader falls back to implemented-story-id when the map is empty.",
6000
+ "valueType": "json",
6001
+ "inputType": "json"
6002
+ },
5988
6003
  {
5989
6004
  "slug": "design-notes",
5990
6005
  "label": "Notes",
@@ -6253,7 +6268,7 @@ const DATA = {
6253
6268
  {
6254
6269
  "name": "Design to implementation",
6255
6270
  "description": "Take a UI design request from three variants built only of real Storybook components, through a rubric critique and a person's review on the canvas, to a pull request verified by the gates, a before/after compare and a walk in the running app.",
6256
- "goalTemplate": "Take this UI design ({design}) for {surface} from draft to implemented. Load the designing-with-real-components skill first, and design-critique for the Critique stage. GENERATE: read the Storybook component manifest (/manifests/components.json, or the Storybook MCP), the design's goal and scope and the entities it references, and write THREE variants as Puck JSON as a canvas of frames, one per screen (one frame for a single screen) — this design and two sibling ui-designs sharing its variant-group — using ONLY components the manifest lists, with props each one declares, design tokens and named motion presets only; each variant lays out every state the screen has (empty, loading, failed, full, long content); fill components-used from the JSON (across every frame of a canvas) and set schema-version (always 3: a canvas of frames, one per screen; never 1 or 2). CRITIQUE: judge each variant with the design-critique rubric and write the findings into its critique; a checked or pattern blocker sends the run back to Generate; opinions are never applied. REVIEW: a person compares the variants on the canvas and approves one; nothing is implemented from an unapproved design, and only a person sets approved. IMPLEMENT: read design-json and the Storybook MCP, build the screen from those same real components, open a pull request and record its URL in implementation-pr and the built screen's story in implemented-story-id. VERIFY: typecheck, story coverage, interaction and accessibility tests, visual regression and the token guards are green, the implemented story was captured and compared with the design and the current story, and the screen was walked in the running app. Move the design's status only through its lifecycle (update_entity with expectedStatus); never invent a status.",
6271
+ "goalTemplate": "Take this UI design ({design}) for {surface} from draft to implemented. Load the designing-with-real-components skill first, and design-critique for the Critique stage. GENERATE: read the Storybook component manifest (/manifests/components.json, or the Storybook MCP), the design's goal and scope and the entities it references, and write THREE variants as Puck JSON as a canvas of frames, one per screen (one frame for a single screen) — this design and two sibling ui-designs sharing its variant-group — using ONLY components the manifest lists, with props each one declares, design tokens and named motion presets only; each variant lays out every state the screen has (empty, loading, failed, full, long content); fill components-used from the JSON (across every frame of a canvas) and set schema-version (always 3: a canvas of frames, one per screen; never 1 or 2). CRITIQUE: judge each variant with the design-critique rubric and write the findings into its critique; a checked or pattern blocker sends the run back to Generate; opinions are never applied. REVIEW: a person compares the variants on the canvas and approves one; nothing is implemented from an unapproved design, and only a person sets approved. IMPLEMENT: read design-json and the Storybook MCP, build the screen from those same real components, open a pull request and record its URL in implementation-pr and the built screen's story in implemented-story-id (a single-frame design) or, for a design of several frames, each frame's stories in frame-stories ({ frameId: [storyId, ...] }). VERIFY: typecheck, story coverage, interaction and accessibility tests, visual regression and the token guards are green, the implemented story was captured and compared with the design and the current story, and the screen was walked in the running app. Move the design's status only through its lifecycle (update_entity with expectedStatus); never invent a status.",
6257
6272
  "subjectProfile": {
6258
6273
  "profileSlug": "ui-design"
6259
6274
  },
@@ -6390,10 +6405,9 @@ const DATA = {
6390
6405
  },
6391
6406
  {
6392
6407
  "key": "implemented-story-linked",
6393
- "statement": "The Storybook story id of the built screen is recorded in implemented-story-id.",
6408
+ "statement": "The built stories are recorded on the design, in implemented-story-id for a single-frame design, or in frame-stories for each frame of a multi-frame design (every frame of design-json has at least one story).",
6394
6409
  "check": {
6395
- "kind": "evidence",
6396
- "evidenceKey": "implemented-story-id"
6410
+ "kind": "judge"
6397
6411
  }
6398
6412
  },
6399
6413
  {
@@ -16621,6 +16635,138 @@ const DATA = {
16621
16635
  ]
16622
16636
  }
16623
16637
  ],
16638
+ "automations": [
16639
+ {
16640
+ "key": "lead-converted-becomes-client",
16641
+ "name": "A lead signs: it becomes a client",
16642
+ "description": "When a lead moves to converted (the client signed; a person's move, so an agent's move is a proposal the person approves first), the lead is stamped with the date it converted and the same person or company gets the client role at onboarding, handed off to Operations. Operations' \"Onboard a client\" starts when the client role is attached. The converted lead role stays as the history of the sale. Attaching the client role again is a no-op, so the CRM app's own handoff and this rule never add a second client role.",
16643
+ "triggerType": "event",
16644
+ "triggerConfig": {
16645
+ "eventPattern": "entity.transition.completed",
16646
+ "filters": {
16647
+ "lifecycleProfile": "lead",
16648
+ "to": "converted"
16649
+ }
16650
+ },
16651
+ "status": "active",
16652
+ "flow": {
16653
+ "nodes": [
16654
+ {
16655
+ "id": "t",
16656
+ "type": "trigger",
16657
+ "position": {
16658
+ "x": 0,
16659
+ "y": 0
16660
+ },
16661
+ "data": {
16662
+ "label": "A lead moved to converted",
16663
+ "triggerType": "event",
16664
+ "config": {
16665
+ "eventPattern": "entity.transition.completed",
16666
+ "filters": {
16667
+ "lifecycleProfile": "lead",
16668
+ "to": "converted"
16669
+ }
16670
+ }
16671
+ }
16672
+ },
16673
+ {
16674
+ "id": "has-entity",
16675
+ "type": "guard",
16676
+ "position": {
16677
+ "x": 0,
16678
+ "y": 120
16679
+ },
16680
+ "data": {
16681
+ "label": "The move names the person or company that signed",
16682
+ "checks": [
16683
+ {
16684
+ "path": "trigger.payload.data.entityId",
16685
+ "minLength": 36,
16686
+ "message": "The lead's move names no person or company: there is no one to make a client."
16687
+ }
16688
+ ]
16689
+ }
16690
+ },
16691
+ {
16692
+ "id": "now",
16693
+ "type": "compute",
16694
+ "position": {
16695
+ "x": 0,
16696
+ "y": 240
16697
+ },
16698
+ "data": {
16699
+ "label": "When the lead signed",
16700
+ "operation": "now"
16701
+ }
16702
+ },
16703
+ {
16704
+ "id": "stamp-lead",
16705
+ "type": "output",
16706
+ "position": {
16707
+ "x": 0,
16708
+ "y": 360
16709
+ },
16710
+ "data": {
16711
+ "label": "Stamp the lead with the date it converted",
16712
+ "outputType": "facet_update",
16713
+ "config": {
16714
+ "entityId": "{{trigger.payload.data.entityId}}",
16715
+ "facetSlug": "lead",
16716
+ "properties": {
16717
+ "convertedAt": "{{steps.now.output.result}}"
16718
+ }
16719
+ }
16720
+ }
16721
+ },
16722
+ {
16723
+ "id": "become-client",
16724
+ "type": "output",
16725
+ "position": {
16726
+ "x": 0,
16727
+ "y": 480
16728
+ },
16729
+ "data": {
16730
+ "label": "Attach the client role at onboarding, handed off to Operations",
16731
+ "outputType": "facet_attach",
16732
+ "config": {
16733
+ "entityId": "{{trigger.payload.data.entityId}}",
16734
+ "facetSlug": "client",
16735
+ "properties": {
16736
+ "clientStatus": "onboarding",
16737
+ "becameClientAt": "{{steps.now.output.result}}",
16738
+ "handoffStatus": "handed_off",
16739
+ "handoffDestination": "Operations"
16740
+ }
16741
+ }
16742
+ }
16743
+ }
16744
+ ],
16745
+ "edges": [
16746
+ {
16747
+ "id": "e1",
16748
+ "source": "t",
16749
+ "target": "has-entity"
16750
+ },
16751
+ {
16752
+ "id": "e2",
16753
+ "source": "has-entity",
16754
+ "target": "now"
16755
+ },
16756
+ {
16757
+ "id": "e3",
16758
+ "source": "now",
16759
+ "target": "stamp-lead"
16760
+ },
16761
+ {
16762
+ "id": "e4",
16763
+ "source": "stamp-lead",
16764
+ "target": "become-client"
16765
+ }
16766
+ ]
16767
+ }
16768
+ }
16769
+ ],
16624
16770
  "actionPlacements": [
16625
16771
  {
16626
16772
  "profileSlug": "person",