@synap-core/workspace-templates 0.53.0 → 0.56.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/dist/index.js +152 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/retired.yaml +10 -0
- package/skills/design-critique/SKILL.md +1 -1
- package/skills/designing-with-real-components/SKILL.md +24 -11
- package/src/builder.yaml +16 -5
- package/src/crm.yaml +102 -12
- package/src/design-to-implementation.template.test.ts +22 -1
- package/src/lead-automations.test.ts +73 -18
- package/src/templates.ts +152 -6
- package/automations/lead-converted-becomes-client.automation.json +0 -89
- package/automations/lead-converted-becomes-client.catalog.json +0 -13
package/package.json
CHANGED
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
|
|
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.
|
|
@@ -96,10 +96,11 @@ page becomes one frame) and every save writes 3.
|
|
|
96
96
|
"page": {
|
|
97
97
|
"root": { "props": {} },
|
|
98
98
|
"content": [
|
|
99
|
-
{ "type": "
|
|
100
|
-
{ "type": "
|
|
101
|
-
|
|
102
|
-
{ "type": "
|
|
99
|
+
{ "type": "Section", "props": { "id": "sec1", "children": [
|
|
100
|
+
{ "type": "Stack", "props": { "id": "s1", "gap": "space-300", "children": [
|
|
101
|
+
{ "type": "Heading", "props": { "id": "h1", "text": "Welcome back", "level": "title" } },
|
|
102
|
+
{ "type": "SpatialButton", "props": { "id": "b1", "variant": "primary", "children": [
|
|
103
|
+
{ "type": "Text", "props": { "id": "t1", "text": "Continue" } } ] } } ] } } ] } }
|
|
103
104
|
]
|
|
104
105
|
}
|
|
105
106
|
}
|
|
@@ -112,8 +113,16 @@ page becomes one frame) and every save writes 3.
|
|
|
112
113
|
the frame grows with its content.
|
|
113
114
|
- Each `page` obeys section 2: real components only, a `props.id` unique within its frame, no hex, rgb, pixel value or
|
|
114
115
|
font family.
|
|
115
|
-
- Layout inside a frame is FLOW ONLY:
|
|
116
|
-
|
|
116
|
+
- Layout inside a frame is FLOW ONLY on a column grid: content goes in a `Section` (a band holding the
|
|
117
|
+
page's grid: 12 columns at 1024 px and wider, 8 from 600, 4 below); arrange inside with `Stack`, `Row`,
|
|
118
|
+
`Grid` (on the page's columns, a subgrid inside a Section), `Box`. A component never gets its own x or y.
|
|
119
|
+
- A block in a `Section` or `Grid` may carry `span` (`{ "compact": 1-4, "medium": 1-8, "expanded": 1-12 }`,
|
|
120
|
+
absent = the whole row) and `hide` (`{ "<class>": true }`); nothing else changes per width. Section
|
|
121
|
+
spacing and the page's side margin are the brand's tokens, never a prop.
|
|
122
|
+
- To show a screen at several widths, add viewport frames: `{ "id": "f2", "name": "Phone", "x": 1600,
|
|
123
|
+
"y": 0, "w": 390, "h": 844, "pageOf": "f1", "page": { "root": { "props": {} }, "content": [] } }` shows
|
|
124
|
+
f1's page at 390. Never copy a page into a second frame for another width.
|
|
125
|
+
- `Grid` has no `columns` prop (dropped and named on read).
|
|
117
126
|
- Layout blocks take exact values, never pixels: `gap`, `padding`, `paddingX`, `paddingY` take `none` or a
|
|
118
127
|
spacing name (`space-025`, `space-050`, `space-075`, `space-100`, `space-125`, `space-150`, `space-200`,
|
|
119
128
|
`space-250`, `space-300`, `space-400`, `space-500`, `space-600`, `space-800`, `space-1000`,
|
|
@@ -135,7 +144,7 @@ Find before you create: `synap_find` for an existing `ui-design` on the same `ta
|
|
|
135
144
|
`components-used` (the distinct `type` values in the JSON, across every frame of a canvas — derived
|
|
136
145
|
from it, never typed by hand),
|
|
137
146
|
`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`.
|
|
147
|
+
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
148
|
- **Three variants by default.** One request = THREE designs: the request itself and two sibling
|
|
140
149
|
`ui-design`s, all with the same `variant-group` (any stable id, e.g. the request's entity id) and the
|
|
141
150
|
same `target-surface`, `design-scope` and `design-goal`. Make them genuinely different answers
|
|
@@ -173,10 +182,14 @@ Before a person sees the variants, critique each with the **design-critique** sk
|
|
|
173
182
|
- At review, the person picks ONE variant. Inside the process the run carries the request design: if
|
|
174
183
|
the person chooses a sibling, write that sibling's `design-json`, `components-used` and `motion` into
|
|
175
184
|
the request design before it is approved; archiving the others is the person's call.
|
|
176
|
-
- Implementing: record the built
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
185
|
+
- Implementing: record the built stories on the design. A single-frame design records its story id in
|
|
186
|
+
`implemented-story-id`. A design with several frames records a map in `frame-stories`,
|
|
187
|
+
`{ "<frameId>": ["<storyId>", ...] }`: every frame id of `design-json` is a key, and one frame may serve
|
|
188
|
+
several stories (its states), so a story is never guessed from a frame's name. Leave
|
|
189
|
+
`implemented-story-id` empty for a multi-frame design; existing designs are not migrated, so a reader
|
|
190
|
+
uses `implemented-story-id` when the map is empty. Capture each story with the
|
|
191
|
+
Storybook capture door (`pnpm --filter @synap-core/storybook capture`) and compare it, frame by frame,
|
|
192
|
+
with that frame of the design and with `current-story-id`.
|
|
180
193
|
|
|
181
194
|
## Do not
|
|
182
195
|
|
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.
|
|
@@ -1478,7 +1484,7 @@ profiles:
|
|
|
1478
1484
|
inputType: text
|
|
1479
1485
|
- slug: design-json
|
|
1480
1486
|
label: Design (Puck JSON)
|
|
1481
|
-
description: "A canvas (schema-version 3): a board { format, frames[] }, one frame per screen, each frame { id, name, x, y, w, h, page } holding a Puck page ({ content[] of { type, props: { id, … } }, root.props }) in flow layout, layout blocks
|
|
1487
|
+
description: "A canvas (schema-version 3): a board { format, frames[] }, one frame per screen, each frame { id, name, x, y, w, h, page } holding a Puck page ({ content[] of { type, props: { id, … } }, root.props }) in flow layout on the page's column grid (12 / 8 / 4 columns by the frame's width class: under 600 compact, under 1024 medium, else expanded): a `Section` block is a band holding that grid; a block in a Section or Grid may carry `span` {compact 1-4, medium 1-8, expanded 1-12} and `hide` {<class>: true}; a frame may show another frame's page at its own width (`pageOf: <frameId>`, its own page empty); layout blocks take token names, never px. A single screen is a canvas with one frame. Every type, at any depth and in every frame, is a component in the Storybook manifest."
|
|
1482
1488
|
valueType: json
|
|
1483
1489
|
inputType: json
|
|
1484
1490
|
- slug: components-used
|
|
@@ -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
|
|
1808
|
-
check: { kind:
|
|
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`
|
|
7
|
-
#
|
|
8
|
-
#
|
|
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
|
-
#
|
|
78
|
-
# attaches the `client` role handed off to
|
|
79
|
-
# Operations' output (its Clients board and
|
|
80
|
-
# space's: the CRM still references the role
|
|
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
|
|
386
|
-
# `lead-converted-becomes-client` attaches the
|
|
387
|
-
#
|
|
388
|
-
#
|
|
389
|
-
#
|
|
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(
|
|
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.
|
|
117
|
-
*
|
|
118
|
-
*
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
});
|