@synap-core/workspace-templates 0.36.0 → 0.38.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.36.0",
3
+ "version": "0.38.0",
4
4
  "type": "module",
5
5
  "description": "Canonical workspace definitions — YAML source + typed exports for browser, backend, CLI, and marketplace",
6
6
  "repository": {
@@ -526,11 +526,16 @@ profiles:
526
526
  description: "Generated or curated voice guidance by context: traits, tone, vocabulary, and copy examples."
527
527
  semanticSlug: brand.voice
528
528
  # The ONE lifecycle (work model L1): every option's category.
529
+ # `approved` is a person's call (design b199a3a4, trust (a), 8 Nov 2026):
530
+ # an approved guide is rendered into the instructions of every playbook
531
+ # that declares `guidance: kind:brand-voice-guide` (the CRM drafters), so
532
+ # an agent's text reaches a future prompt only once a person approved it.
533
+ # An agent writes a draft; a person approves it.
529
534
  lifecycle:
530
535
  property: voice-status
531
536
  options:
532
537
  - { key: draft, category: open }
533
- - { key: approved, category: done }
538
+ - { key: approved, category: done, humanOnly: true }
534
539
  - { key: deprecated, category: lost, humanOnly: true }
535
540
  properties:
536
541
  - slug: voice-context
@@ -547,7 +552,11 @@ profiles:
547
552
  legal,
548
553
  editorial,
549
554
  investor,
555
+ outreach,
550
556
  ]
557
+ # `outreach`: how we write to a lead (design b199a3a4, founder 8 Nov
558
+ # 2026: ONE voice for content and sales). The CRM drafters read the
559
+ # `general` and `outreach` guides (`guidance` where voice-context).
551
560
  constraints: { defaultValue: general }
552
561
  - slug: voice-status
553
562
  label: Status
@@ -877,6 +886,13 @@ views:
877
886
  description: Base, format and goal-frame guidelines for making content.
878
887
 
879
888
  entityLinks:
889
+ # A new version of a voice guide is a new guide, a draft that `revises` the
890
+ # approved one (design b199a3a4): approving it and deprecating the old one
891
+ # is a person's act, and the chain of revisions is the guide's history.
892
+ - sourceProfileSlug: brand-voice-guide
893
+ targetProfileSlug: brand-voice-guide
894
+ type: revises
895
+ label: Revises
880
896
  - sourceProfileSlug: brand-token-set
881
897
  targetProfileSlug: brand-color
882
898
  type: derived_from
@@ -11,6 +11,10 @@
11
11
  * channel, filed through the pod's `messaging.send` with `to` = their
12
12
  * entity id; never a tool's own send verb, never an outreach touch, never
13
13
  * synap_capture; ONE paragraph, word for word, in every drafter;
14
+ * - RULES (design b199a3a4, 8 Nov 2026): the style a drafter writes in is
15
+ * the rules it follows (`guidance`: Voice, then By kind of lead), rendered
16
+ * by the pod from person-approved records; ONE paragraph, word for word,
17
+ * in every drafter, and the old style lines are gone from the goals;
14
18
  * - the CADENCE counts the outbound messages in the lead's channels, and a
15
19
  * reply (an inbound message after our last outbound one) is read by
16
20
  * "Follow up on leads in outreach";
@@ -69,6 +73,23 @@ const DRAFT_RULES =
69
73
  "DRAFT RULES: each draft is one proposed message in the channel of the person it is written to, filed through the pod's send door: run messaging.send with to = that person's entity id (for a company lead, its decider: when that person is not in the pod, create them through the entity door with only their own fields, such as name, role and LinkedIn URL, never the company's website, domain or email), text = the message, and provider linkedin or email. Read their channel first (synap_get_channel, mode person) for what was already said. The pod files it for a person to review in that channel; it goes out only once they approve it. Never call a tool's own send verb (Unipile, Gmail), never create an outreach touch, a note or a task holding the message, and never use synap_capture for it. Never send. " +
70
74
  LINKEDIN_ORDER;
71
75
 
76
+ /**
77
+ * RULES (design b199a3a4, slice 2, 8 Nov 2026): the style a drafter writes in
78
+ * is no longer lines of its goal but the rules it follows (`guidance`), which
79
+ * every run renders from the current, person-approved records under "Rules
80
+ * this playbook follows". ONE paragraph, word for word, in every drafter.
81
+ */
82
+ const RULES =
83
+ "RULES: follow the rules this process follows, in order: Voice, then By kind of lead (the first row that fits the lead; a given campaign's angle comes first). A rule shown as not available is left out: say so.";
84
+ /** The rules every drafter declares, in this order (Voice, By kind of lead). */
85
+ const GUIDANCE = [
86
+ { ref: "kind:brand-voice-guide", label: "Voice", where: { "voice-context": ["general", "outreach"] } },
87
+ { ref: "kind:outreach-angle", label: "By kind of lead" },
88
+ ];
89
+ /** The style lines the drafters' goals held until 8 Nov 2026: they seed the Voice now. */
90
+ const STYLE_SEED =
91
+ 'Its message is personal: it cites the buying signal and what it showed, or a past exchange, never a generic template; short; in the person\'s language, French by default, and in French it says vous. It offers one useful next step, never pressure.';
92
+
72
93
  /** What a drafter yields: a `messaging.external.send` proposal (target type `messaging`). */
73
94
  const PROPOSED_MESSAGE = "messaging";
74
95
  const outputsOf = (p: NonNullable<WorkspaceYaml["playbooks"]>[number]) => [
@@ -114,6 +135,24 @@ describe("CRM messages and cadence — catalog contract", () => {
114
135
  expect(DRAFT_RULES).toContain(part);
115
136
  });
116
137
 
138
+ it("RULES: every drafter declares the same guidance and holds one RULES paragraph; the style lines left the goals", () => {
139
+ for (const name of DRAFTERS) {
140
+ expect(playbookOf(name).guidance, name).toEqual(GUIDANCE);
141
+ expect(goalOf(name), name).toContain(RULES);
142
+ // The style lines moved into guidance (their seed is "Propose my rules
143
+ // from my sent messages"): no drafter states them in its goal any more.
144
+ for (const gone of ["French by default", "says vous", "never pressure", "never a generic template", "short and in the lead's language", "specific to them"])
145
+ expect(goalOf(name), `${name}: ${gone}`).not.toContain(gone);
146
+ }
147
+ // Only the drafters hold it: a fourth copy would be a second wording.
148
+ const holders = (crm.playbooks ?? []).filter((p) => flat(p.goalTemplate).includes("RULES: follow the rules")).map((p) => p.name);
149
+ expect(holders.sort()).toEqual([...DRAFTERS].sort());
150
+ // The seed of the voice is the old style lines, word for word.
151
+ expect(goalOf("Propose my rules from my sent messages")).toContain(STYLE_SEED);
152
+ // The pod refuses a goal over 5,000 characters (playbookDefinitionSchema).
153
+ for (const name of DRAFTERS) expect(playbookOf(name).goalTemplate.length, name).toBeLessThanOrEqual(5000);
154
+ });
155
+
117
156
  it("'Draft a first message': send it to <name> today, then follow up 3 days after the send", () => {
118
157
  const name = "Draft a first message";
119
158
  expect(goalOf(name)).toContain('"Send the first message to <name> on LinkedIn"');
@@ -217,18 +256,21 @@ describe("CRM messages and cadence — catalog contract", () => {
217
256
  expect(slugs).not.toContain("linkedinInvitedAt");
218
257
  });
219
258
 
220
- it("'Find their LinkedIn': one lead, linkedin_find_profile, a proposal or up to 3 candidates, nothing sent", () => {
259
+ it("'Find their LinkedIn': one person (a lead or not), linkedin_find_profile, a proposal or up to 5 candidates, nothing sent", () => {
221
260
  const name = "Find their LinkedIn";
222
261
  const pb = playbookOf(name);
223
- expect(pb.subjectProfile?.profileSlug).toBe("lead");
224
- // The CRM app starts it for one lead, as "Draft a first message": params.lead.
225
- expect(pb.params?.find((p) => p.name === "lead")).toMatchObject({ type: "entity", required: true });
226
- expect(pb.params?.find((p) => p.name === "lead")).toEqual(playbookOf("Draft a first message").params?.find((p) => p.name === "lead"));
262
+ // A lookup on a PERSON, never on a lead (founder, 9 Nov 2026: a company is the lead, its contact is who is looked up).
263
+ expect(pb.subjectProfile?.profileSlug).toBe("person");
264
+ expect(pb.params?.find((p) => p.name === "person")).toMatchObject({ type: "entity", required: true });
265
+ expect(pb.params?.find((p) => p.name === "lead")).toBeUndefined();
266
+ expect(goalOf(name)).not.toContain("{lead}");
227
267
  expect(pb.requiredIntents).toEqual(["enrich_entity"]);
228
268
  const goal = goalOf(name);
229
- expect(goal).toContain("run linkedin_find_profile with their full name, their company");
269
+ expect(goal).toContain("run linkedin_find_profile with their full name, their");
270
+ expect(goal).toContain("company when known");
271
+ expect(goal).toContain("search by their name alone");
230
272
  expect(goal).toContain("propose its linkedinUrl and linkedinProviderId on the person");
231
- expect(goal).toContain("at most 3");
273
+ expect(goal).toContain("at most 5");
232
274
  expect(goal).toContain("never set linkedinConnection or linkedinInvitedAt");
233
275
  // A reader: it never asks to connect nor drafts (those are the other steps).
234
276
  const named = [...goal.matchAll(/\b((?:linkedin|unipile)_[a-z_]+)\b/g)].map((m) => m[1]);
@@ -0,0 +1,156 @@
1
+ /**
2
+ * CRM rules a playbook follows (design b199a3a4 Question 1, slice 2; founder
3
+ * approval 8 Nov 2026, Brand & communication board), pinned against the REAL
4
+ * YAML corpus. The pod (backend#924) renders a playbook's `guidance` from the
5
+ * CURRENT versions only: a kind's entities whose lifecycle category is `done`.
6
+ * Entity text becomes prompt text, so:
7
+ *
8
+ * - "By kind of lead" is the CRM kind `outreach-angle`: the match (a
9
+ * condition, an optional audience and offer), lead with, offer, proof,
10
+ * avoid, tone, channel and the `order` the pod sorts by; its `current`
11
+ * (done) and `retired` options are a person's (humanOnly);
12
+ * - Voice is Brand Library's `brand-voice-guide` with an `outreach` context;
13
+ * its `approved` (done) option is a person's (humanOnly);
14
+ * - a new version is a draft that `revises` the current one;
15
+ * - "Propose my rules from my sent messages" writes DRAFTS only, and no stage
16
+ * of it moves anything to a done option.
17
+ *
18
+ * The drafters' declarations and their RULES paragraph are pinned in
19
+ * crm-messages-cadence.template.test.ts. Does NOT cover what the pod renders
20
+ * or what an agent does at run time.
21
+ */
22
+
23
+ import { describe, expect, it } from "vitest";
24
+ import { readYamlTemplates } from "./generate.mjs";
25
+ import type { WorkspaceYaml } from "./types.js";
26
+
27
+ const corpus = readYamlTemplates().map((t) => t.data as WorkspaceYaml);
28
+ const tpl = (slug: string) => {
29
+ const t = corpus.find((x) => x.meta.slug === slug);
30
+ if (!t) throw new Error(`template ${slug} not in the corpus`);
31
+ return t;
32
+ };
33
+ const kindOf = (t: WorkspaceYaml, slug: string) => {
34
+ const p = t.profiles?.find((x) => x.slug === slug);
35
+ if (!p) throw new Error(`kind ${slug} not in ${t.meta.slug}`);
36
+ return p;
37
+ };
38
+ const flat = (s: string | undefined) => (s ?? "").replace(/\s+/g, " ");
39
+ const lifecycleShape = (p: ReturnType<typeof kindOf>) =>
40
+ (p.lifecycle?.options ?? []).map((o) => [o.key, o.category, o.humanOnly === true]);
41
+
42
+ const crm = tpl("crm");
43
+ const brand = tpl("brand-library");
44
+
45
+ describe("By kind of lead: the outreach-angle kind", () => {
46
+ const angle = kindOf(crm, "outreach-angle");
47
+
48
+ it("draft → current → retired; only a person makes a row current or retires it", () => {
49
+ expect(angle.lifecycle?.property).toBe("angle-status");
50
+ expect(lifecycleShape(angle)).toEqual([
51
+ ["draft", "open", false],
52
+ ["current", "done", true],
53
+ ["retired", "lost", true],
54
+ ]);
55
+ const status = angle.properties.find((p) => p.slug === "angle-status");
56
+ expect(status?.enumValues).toEqual(["draft", "current", "retired"]);
57
+ // A new row is a draft: an agent's write never lands current.
58
+ expect(status?.constraints).toEqual({ defaultValue: "draft" });
59
+ });
60
+
61
+ it("the match, then what to lead with, in the order the pod renders them; `order` sorts the rows", () => {
62
+ expect(angle.properties.map((p) => p.slug)).toEqual([
63
+ "angle-status",
64
+ "angle-if",
65
+ "angle-audience",
66
+ "angle-about-offer",
67
+ "angle-lead-with",
68
+ "angle-offer",
69
+ "angle-proof",
70
+ "angle-avoid",
71
+ "angle-tone",
72
+ "angle-channel",
73
+ // The pod's renderer sorts an ordered kind by the property named exactly
74
+ // `order` (backend playbook-guidance.ts ORDER_PROPERTY) and never renders it.
75
+ "order",
76
+ ]);
77
+ const prop = (slug: string) => angle.properties.find((p) => p.slug === slug);
78
+ expect(prop("order")).toMatchObject({ valueType: "number" });
79
+ expect(prop("angle-audience")).toMatchObject({ valueType: "entity_id", targetProfileSlug: "audience" });
80
+ expect(prop("angle-about-offer")).toMatchObject({ valueType: "entity_id", targetProfileSlug: "offer" });
81
+ // The CRM's own reference to the pod-wide audience kind, and foundation
82
+ // (a dependency) owns offer: both targets resolve.
83
+ expect(crm.profiles?.some((p) => p.slug === "audience")).toBe(true);
84
+ expect(crm.dependencies?.some((d) => d.slug === "foundation")).toBe(true);
85
+ expect(kindOf(tpl("foundation"), "offer")).toBeTruthy();
86
+ });
87
+
88
+ it("a new version revises the current one (the history is the retired chain)", () => {
89
+ expect(crm.entityLinks).toContainEqual(
90
+ expect.objectContaining({ sourceProfileSlug: "outreach-angle", targetProfileSlug: "outreach-angle", type: "revises" }),
91
+ );
92
+ });
93
+ });
94
+
95
+ describe("Voice: Brand Library's voice guide", () => {
96
+ const voice = kindOf(brand, "brand-voice-guide");
97
+
98
+ it("approved is a person's call (trust (a)); a new guide is a draft", () => {
99
+ expect(lifecycleShape(voice)).toEqual([
100
+ ["draft", "open", false],
101
+ ["approved", "done", true],
102
+ ["deprecated", "lost", true],
103
+ ]);
104
+ expect(voice.properties.find((p) => p.slug === "voice-status")?.constraints).toEqual({ defaultValue: "draft" });
105
+ });
106
+
107
+ it("one voice for content and sales: an outreach context, and the default stays general", () => {
108
+ const context = voice.properties.find((p) => p.slug === "voice-context");
109
+ expect(context?.enumValues).toContain("outreach");
110
+ expect(context?.enumValues).toContain("general");
111
+ expect(context?.constraints).toEqual({ defaultValue: "general" });
112
+ // Say / Don't say are the guide's Do / Don't.
113
+ expect(voice.properties.map((p) => p.slug)).toEqual(expect.arrayContaining(["voice-example-do", "voice-example-dont"]));
114
+ expect(brand.entityLinks).toContainEqual(
115
+ expect.objectContaining({ sourceProfileSlug: "brand-voice-guide", targetProfileSlug: "brand-voice-guide", type: "revises" }),
116
+ );
117
+ });
118
+ });
119
+
120
+ describe("'Propose my rules from my sent messages': drafts only", () => {
121
+ const name = "Propose my rules from my sent messages";
122
+ const pb = crm.playbooks?.find((p) => p.name === name);
123
+
124
+ it("exists, started by the person, and yields draft voice and By kind of lead rows", () => {
125
+ expect(pb).toBeTruthy();
126
+ expect(pb?.executor).toBe("is-agent");
127
+ expect(pb?.grants).toEqual(["entity.create"]);
128
+ expect((pb?.expectedOutputs ?? []).map((o) => o.kind).sort()).toEqual(["brand-voice-guide", "outreach-angle"]);
129
+ });
130
+
131
+ it("never makes a version current: no stage moves a status, and its goal says drafts only", () => {
132
+ for (const st of pb?.stages ?? []) expect(st.subjectStatus, st.key).toBeUndefined();
133
+ // Only a person makes them current, at a human gate.
134
+ expect(pb?.stages?.at(-1)?.gate).toEqual({ kind: "human" });
135
+ const goal = flat(pb?.goalTemplate);
136
+ expect(goal).toContain("status draft");
137
+ expect(goal).toContain("never set a voice guide to approved or deprecated, nor a row to current or retired");
138
+ expect(goal).toContain("never edit or retire a current one");
139
+ expect(goal).toContain("a new record that revises it");
140
+ expect(goal).toContain("context outreach");
141
+ const criteria = Object.fromEntries((pb?.stages ?? []).flatMap((s) => s.criteria ?? []).map((c) => [c.key, flat(c.statement)]));
142
+ expect(criteria["rules-drafts-only"]).toMatch(/is a draft .* no approved voice guide or current row was edited, approved or retired/);
143
+ });
144
+
145
+ it("every value it names exists: the voice context, and each status it writes or forbids", () => {
146
+ const goal = flat(pb?.goalTemplate);
147
+ const voice = kindOf(brand, "brand-voice-guide");
148
+ const angle = kindOf(crm, "outreach-angle");
149
+ const keys = (p: ReturnType<typeof kindOf>) => (p.lifecycle?.options ?? []).map((o) => o.key);
150
+ expect(voice.properties.find((p) => p.slug === "voice-context")?.enumValues).toContain("outreach");
151
+ for (const k of ["approved", "deprecated", "draft"]) expect(keys(voice)).toContain(k);
152
+ for (const k of ["current", "retired", "draft"]) expect(keys(angle)).toContain(k);
153
+ expect(goal).toContain("profileSlug brand-voice-guide");
154
+ expect(goal).toContain("profileSlug outreach-angle");
155
+ });
156
+ });