@synap-core/workspace-templates 0.66.0 → 0.68.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.
@@ -0,0 +1,46 @@
1
+ /**
2
+ * A campaign's `campaign-channel` names a platform (founder, 24 Nov 2026, "Add platforms").
3
+ *
4
+ * Content Studio narrows its format picker and "Goes out on" to the campaign's channel, matching the value to the
5
+ * networks a format declares and to a text's place (site, website, newsletter) without case. So the platforms are
6
+ * option values of the kind, kept identical in every template that carries the `campaign` kind. Enums only grow.
7
+ */
8
+ import { describe, expect, it } from "vitest";
9
+ import { getWorkspaceTemplate } from "./templates.js";
10
+
11
+ const PLATFORMS = ["linkedin", "instagram", "website", "newsletter"];
12
+ const ORIGINAL = [
13
+ "email",
14
+ "social",
15
+ "event",
16
+ "content",
17
+ "partnership",
18
+ "paid",
19
+ "organic",
20
+ "other",
21
+ ];
22
+ const TEMPLATES = ["content-os", "crm", "marketing-campaign"];
23
+
24
+ const channelOptions = (slug: string) => {
25
+ const template = getWorkspaceTemplate(slug);
26
+ if (!template) throw new Error(`${slug} template is not registered`);
27
+ const campaign = template.profiles.find((p) => p.slug === "campaign");
28
+ const prop = campaign?.properties?.find((p) => p.slug === "campaign-channel");
29
+ return prop?.enumValues;
30
+ };
31
+
32
+ describe("campaign-channel names a platform", () => {
33
+ for (const slug of TEMPLATES) {
34
+ it(`${slug}: linkedin, instagram, website and newsletter are options, the original ones stay`, () => {
35
+ const options = channelOptions(slug);
36
+ expect(options).toEqual(
37
+ expect.arrayContaining([...ORIGINAL, ...PLATFORMS])
38
+ );
39
+ });
40
+ }
41
+
42
+ it("every template that carries the campaign kind offers the same options", () => {
43
+ const [first, ...rest] = TEMPLATES.map(channelOptions);
44
+ for (const options of rest) expect(options).toEqual(first);
45
+ });
46
+ });
@@ -15,7 +15,9 @@
15
15
  * (b) EVERY SKILL REFERENCE RESOLVES. `dependencies[]` of kind `skill`, every
16
16
  * `skills:` link, and every `system/<pkg>/<stem>` named in template or
17
17
  * capability prose must name a skill package in this corpus
18
- * (`skills/*.skill.json` or `skills/<slug>/*.skill.json`) or a system skill on disk under
18
+ * (`skills/*.skill.json`, `skills/<slug>/*.skill.json`, or an Agent-Skills folder
19
+ * `skills/<name>/SKILL.md` with its header `skills/<name>.catalog.json`, the three
20
+ * forms `loadCatalog` reads) or a system skill on disk under
19
21
  * `synap-backend/skills/<pkg>/<stem>.md` (the pod's `ensureSystemSkills`
20
22
  * derives `system/<pkg>/<file-stem>` from exactly that layout).
21
23
  * Not covered: whether the corpus skill package is PUBLISHED.
@@ -37,7 +39,7 @@ import { describe, expect, it } from "vitest";
37
39
  import { readYamlTemplates } from "./generate.mjs";
38
40
  import type { WorkspaceYaml } from "./types.js";
39
41
  // One duplicate detector, shared with validateCatalog (duplicate-playbook-name).
40
- import { duplicateNames } from "../scripts/catalog-lib.mjs";
42
+ import { duplicateNames, HEADER_SUFFIX } from "../scripts/catalog-lib.mjs";
41
43
 
42
44
  const HERE = dirname(fileURLToPath(import.meta.url));
43
45
  const PKG = join(HERE, "..");
@@ -113,7 +115,14 @@ const corpusSkillFiles = readdirSync(CORPUS_SKILLS, { withFileTypes: true }).fla
113
115
  ? [join(CORPUS_SKILLS, d.name)]
114
116
  : []
115
117
  );
116
- const corpusSkillSlugs = new Set(corpusSkillFiles.map((f) => JSON.parse(readFileSync(f, "utf8")).meta.slug as string));
118
+ /** An Agent-Skills folder `skills/<name>/SKILL.md` + header `skills/<name>.catalog.json` (catalog-lib `HEADER_SUFFIX`). */
119
+ const corpusSkillHeaders = readdirSync(CORPUS_SKILLS)
120
+ .filter((f) => f.endsWith(HEADER_SUFFIX))
121
+ .filter((f) => existsSync(join(CORPUS_SKILLS, f.slice(0, -HEADER_SUFFIX.length), "SKILL.md")))
122
+ .map((f) => join(CORPUS_SKILLS, f));
123
+ const corpusSkillSlugs = new Set(
124
+ [...corpusSkillFiles, ...corpusSkillHeaders].map((f) => JSON.parse(readFileSync(f, "utf8")).meta.slug as string)
125
+ );
117
126
 
118
127
  /** `system/<pkg>/<stem>` → is there a `synap-backend/skills/<pkg>/<stem>.md` (stem case-insensitive)? */
119
128
  function systemSkillExists(ref: string): boolean {
@@ -148,6 +157,8 @@ describe("(b) every skill reference resolves", () => {
148
157
  it("non-vacuity: structured refs exist, and the resolvers see a literal sample", () => {
149
158
  expect(structuredRefs.length).toBeGreaterThanOrEqual(2);
150
159
  expect(corpusSkillSlugs.has("creative-director")).toBe(true);
160
+ // A SKILL.md folder with its header resolves too (the design loop's skills ship that way).
161
+ expect(corpusSkillSlugs.has("design-critique")).toBe(true);
151
162
  // The prose matcher catches a system ref and ignores a path that merely ends in one.
152
163
  expect("load system/synap/concepts now".match(SYSTEM_REF)).toEqual(["system/synap/concepts"]);
153
164
  expect("ecosystem/operations/crm".match(SYSTEM_REF)).toBeNull();
@@ -22,14 +22,22 @@ const template = (() => {
22
22
  return resolved;
23
23
  })();
24
24
 
25
- const profile = (slug: string) => template.profiles.find((p) => p.slug === slug);
26
- const prop = (kind: string, slug: string) => profile(kind)?.properties.find((d) => d.slug === slug);
25
+ const profile = (slug: string) =>
26
+ template.profiles.find((p) => p.slug === slug);
27
+ const prop = (kind: string, slug: string) =>
28
+ profile(kind)?.properties.find((d) => d.slug === slug);
27
29
  const playbook = (name: string) =>
28
- (template.playbooks ?? []).find((p) => p.name === name) as TemplatePlaybook | undefined;
30
+ (template.playbooks ?? []).find((p) => p.name === name) as
31
+ | TemplatePlaybook
32
+ | undefined;
29
33
 
30
34
  describe("Content OS: an idea and a piece belong to one campaign, like a post", () => {
31
35
  const shape = (d: ReturnType<typeof prop>) =>
32
- d && { valueType: d.valueType, targetProfileSlug: d.targetProfileSlug, inputType: d.inputType };
36
+ d && {
37
+ valueType: d.valueType,
38
+ targetProfileSlug: d.targetProfileSlug,
39
+ inputType: d.inputType,
40
+ };
33
41
 
34
42
  it("the post's own field is the model (non-vacuity)", () => {
35
43
  expect(shape(prop("post", "post-campaign"))).toEqual({
@@ -42,44 +50,61 @@ describe("Content OS: an idea and a piece belong to one campaign, like a post",
42
50
  it("declares idea-campaign on idea and composition-campaign on content-composition, same shape", () => {
43
51
  const model = shape(prop("post", "post-campaign"));
44
52
  expect(shape(prop("idea", "idea-campaign"))).toEqual(model);
45
- expect(shape(prop("content-composition", "composition-campaign"))).toEqual(model);
53
+ expect(shape(prop("content-composition", "composition-campaign"))).toEqual(
54
+ model
55
+ );
46
56
  expect(prop("idea", "idea-campaign")?.label).toBe("Campaign");
47
- expect(prop("content-composition", "composition-campaign")?.label).toBe("Campaign");
57
+ expect(prop("content-composition", "composition-campaign")?.label).toBe(
58
+ "Campaign"
59
+ );
48
60
  });
49
61
 
50
62
  it("declares the graph edge to the campaign for both, as for a post", () => {
51
63
  const links = (template.entityLinks ?? []).map(
52
- (l) => `${l.sourceProfileSlug}-${l.type}->${l.targetProfileSlug}`,
64
+ (l) => `${l.sourceProfileSlug}-${l.type}->${l.targetProfileSlug}`
53
65
  );
54
66
  expect(links).toEqual(
55
67
  expect.arrayContaining([
56
68
  "post-part_of_campaign->campaign",
57
69
  "idea-part_of_campaign->campaign",
58
70
  "content-composition-part_of_campaign->campaign",
59
- ]),
71
+ ])
60
72
  );
61
73
  });
62
74
 
63
75
  it("Derive outputs gives the posts it makes the piece's campaign", () => {
64
76
  const derive = playbook("Derive outputs");
65
77
  expect(derive?.subjectProfile?.profileSlug).toBe("content-composition");
66
- expect(derive?.goalTemplate).toMatch(/composition-campaign\), give each post that campaign\s+\(post-campaign\)/);
78
+ expect(derive?.goalTemplate).toMatch(
79
+ /composition-campaign\), give each post that campaign\s+\(post-campaign\)/
80
+ );
67
81
  });
68
82
  });
69
83
 
70
84
  describe("Content OS: Plan Next Content plans a campaign, with the founder's rules", () => {
71
85
  const plan = playbook("Plan Next Content");
72
- const texts = () => [plan?.goalTemplate ?? "", ...(plan?.stages ?? []).map((s) => s.goal ?? "")];
86
+ const texts = () => [
87
+ plan?.goalTemplate ?? "",
88
+ ...(plan?.stages ?? []).map((s) => s.goal ?? ""),
89
+ ];
73
90
 
74
91
  it("is bound to the campaign kind, the pod's binding", () => {
75
92
  expect(plan?.subjectProfile).toEqual({ profileSlug: "campaign" });
76
93
  });
77
94
 
78
95
  it("plans the run's campaign when it has one, else every active campaign", () => {
79
- expect(plan?.goalTemplate).toMatch(/when this run has a subject, it is the\s+campaign to plan/);
80
- expect(plan?.goalTemplate).toMatch(/With no subject,\s+plan every active campaign/);
96
+ expect(plan?.goalTemplate).toMatch(
97
+ /when this run has a subject, it is the\s+campaign to plan/
98
+ );
99
+ expect(plan?.goalTemplate).toMatch(
100
+ /With no subject,\s+plan every active campaign/
101
+ );
81
102
  // It reads the campaign's members from the one field per kind.
82
- for (const field of ["idea-campaign", "composition-campaign", "post-campaign"]) {
103
+ for (const field of [
104
+ "idea-campaign",
105
+ "composition-campaign",
106
+ "post-campaign",
107
+ ]) {
83
108
  expect(plan?.goalTemplate).toContain(field);
84
109
  }
85
110
  });
@@ -87,26 +112,39 @@ describe("Content OS: Plan Next Content plans a campaign, with the founder's rul
87
112
  it("carries rule A: only posts are planned, never raw material", () => {
88
113
  expect(plan?.goalTemplate).toContain("(A) Only POSTS are planned");
89
114
  expect(plan?.goalTemplate).toMatch(/never give one a slot or a date/);
90
- expect(plan?.goalTemplate).toMatch(/never treat a post that is only a take/);
115
+ expect(plan?.goalTemplate).toMatch(
116
+ /never treat a post that is only a take/
117
+ );
91
118
  });
92
119
 
93
120
  it("carries rule C: every date is a proposal, and the final message reads back what is applied", () => {
94
121
  expect(plan?.goalTemplate).toMatch(/\(C\) You change nothing yourself/);
95
122
  expect(plan?.goalTemplate).toContain("never apply a date yourself");
96
- expect(plan?.goalTemplate).toMatch(/exactly what is applied and what is proposed/);
97
- expect((plan?.criteria ?? []).map((c) => c.key)).toContain("nothing-applied-directly");
123
+ expect(plan?.goalTemplate).toMatch(
124
+ /exactly what is applied and what is proposed/
125
+ );
126
+ expect((plan?.criteria ?? []).map((c) => c.key)).toContain(
127
+ "nothing-applied-directly"
128
+ );
98
129
  });
99
130
 
100
131
  it("reads rule B, the rhythm, from the campaign: no day or count of the rhythm in this text", () => {
101
132
  expect(plan?.goalTemplate).toMatch(/\(B\) The rhythm is the campaign's/);
102
133
  for (const text of texts()) {
103
- expect(text).not.toMatch(/monday|tuesday|wednesday|thursday|friday|saturday|sunday/i);
134
+ expect(text).not.toMatch(
135
+ /monday|tuesday|wednesday|thursday|friday|saturday|sunday/i
136
+ );
104
137
  expect(text).not.toMatch(/\b(two|three|four|five) publishing days\b/i);
105
138
  }
106
139
  });
107
140
 
108
141
  it("keeps the pod's four stages, none of which moves the campaign's status", () => {
109
- expect((plan?.stages ?? []).map((s) => s.key)).toEqual(["read", "audit", "place", "file"]);
142
+ expect((plan?.stages ?? []).map((s) => s.key)).toEqual([
143
+ "read",
144
+ "audit",
145
+ "place",
146
+ "file",
147
+ ]);
110
148
  for (const stage of plan?.stages ?? []) {
111
149
  expect(stage.subjectStatus).toBeUndefined();
112
150
  expect(stage.onApproved).toBeUndefined();
@@ -120,8 +158,13 @@ describe("Content OS: Plan Next Content plans a campaign, with the founder's rul
120
158
 
121
159
  it("never runs at the same minute as Weekly content production", () => {
122
160
  const planCron = plan?.activators?.find((a) => a.on === "schedule")?.cron;
123
- const produce = template.automations?.find((a) => a.key === "content-os-weekly-produce");
161
+ const produce = template.automations?.find(
162
+ (a) => a.key === "content-os-weekly-produce"
163
+ );
124
164
  expect(planCron).toBe("0 9 * * 1");
125
- expect((produce?.triggerConfig as { expression?: string } | undefined)?.expression).not.toBe(planCron);
165
+ expect(
166
+ (produce?.triggerConfig as { expression?: string } | undefined)
167
+ ?.expression
168
+ ).not.toBe(planCron);
126
169
  });
127
170
  });
@@ -43,7 +43,15 @@ const keys = options.map((o) => o.key);
43
43
  const opt = (key: string) => options.find((o) => o.key === key);
44
44
 
45
45
  /** The founder's 6 Nov declaration, as the pod returns it, in its order. */
46
- const LIVE_KEYS = ["intent", "board", "assets_chosen", "generating", "in_review", "approved", "retired"];
46
+ const LIVE_KEYS = [
47
+ "intent",
48
+ "board",
49
+ "assets_chosen",
50
+ "generating",
51
+ "in_review",
52
+ "approved",
53
+ "retired",
54
+ ];
47
55
 
48
56
  describe("the piece: content-composition's one lifecycle", () => {
49
57
  it("is declared on the property the live rows carry (`status`), options = enumValues", () => {
@@ -64,31 +72,48 @@ describe("the piece: content-composition's one lifecycle", () => {
64
72
  expect(opt("intent")).toMatchObject({ label: "Idea", category: "open" });
65
73
  expect(keys.indexOf("drafting")).toBe(1);
66
74
  expect(opt("drafting")?.category).toBe("active");
67
- expect(opt("approved")).toMatchObject({ label: "Ready", category: "active", humanOnly: true });
75
+ expect(opt("approved")).toMatchObject({
76
+ label: "Ready",
77
+ category: "active",
78
+ humanOnly: true,
79
+ });
68
80
  expect(keys.indexOf("deriving")).toBe(keys.indexOf("approved") + 1);
69
81
  expect(opt("deriving")?.category).toBe("active");
70
82
  expect(opt("published")?.category).toBe("done");
71
83
  expect(opt("retired")?.category).toBe("lost");
72
84
  // One done step: a ready piece still has its outputs to derive.
73
- expect(options.filter((o) => o.category === "done").map((o) => o.key)).toEqual(["published"]);
85
+ expect(
86
+ options.filter((o) => o.category === "done").map((o) => o.key)
87
+ ).toEqual(["published"]);
74
88
  });
75
89
  });
76
90
 
77
91
  describe("the piece's graph", () => {
78
92
  const links = contentOs.entityLinks ?? [];
79
93
  const has = (s: string, t: string, type: string) =>
80
- links.some((l) => l.sourceProfileSlug === s && l.targetProfileSlug === t && l.type === type);
81
- const defs = new Map((contentOs.relationDefs ?? []).map((d) => [d.slug as string, d]));
94
+ links.some(
95
+ (l) =>
96
+ l.sourceProfileSlug === s &&
97
+ l.targetProfileSlug === t &&
98
+ l.type === type
99
+ );
100
+ const defs = new Map(
101
+ (contentOs.relationDefs ?? []).map((d) => [d.slug as string, d])
102
+ );
82
103
 
83
104
  it("an output is derived_from its piece; a chapter is part_of a piece; an idea is used_in it", () => {
84
105
  expect(has("post", "content-composition", "derived_from")).toBe(true);
85
- expect(has("content-composition", "content-composition", "part_of")).toBe(true);
106
+ expect(has("content-composition", "content-composition", "part_of")).toBe(
107
+ true
108
+ );
86
109
  expect(has("idea", "content-composition", "used_in")).toBe(true);
87
110
  });
88
111
 
89
112
  it("declares inspired_by and part_of, directional, with their meaning", () => {
90
113
  for (const slug of ["inspired_by", "part_of"]) {
91
- const d = defs.get(slug) as { isDirectional?: boolean; description?: string } | undefined;
114
+ const d = defs.get(slug) as
115
+ | { isDirectional?: boolean; description?: string }
116
+ | undefined;
92
117
  expect(d?.isDirectional, slug).toBe(true);
93
118
  expect(d?.description?.length ?? 0, slug).toBeGreaterThan(20);
94
119
  }
@@ -98,7 +123,9 @@ describe("the piece's graph", () => {
98
123
  // derived_from the piece (founder, 13 Nov 2026, decision 52e11d35, Q1 = A).
99
124
  // The edge the studio writes most: declared, so the space's lens knows it.
100
125
  it("a visual set is a composition derived_from the piece it was made from", () => {
101
- expect(has("content-composition", "content-composition", "derived_from")).toBe(true);
126
+ expect(
127
+ has("content-composition", "content-composition", "derived_from")
128
+ ).toBe(true);
102
129
  });
103
130
 
104
131
  it("keeps the relations already written on live pods", () => {
@@ -110,7 +137,9 @@ describe("the piece's graph", () => {
110
137
 
111
138
  describe("an account names its default project", () => {
112
139
  it("platform carries default-project-id, a project id (projects are not entities)", () => {
113
- const prop = profile(contentOs, "platform").properties.find((p) => p.slug === "default-project-id");
140
+ const prop = profile(contentOs, "platform").properties.find(
141
+ (p) => p.slug === "default-project-id"
142
+ );
114
143
  expect(prop).toMatchObject({ valueType: "string", inputType: "text" });
115
144
  expect(prop?.targetProfileSlug).toBeUndefined();
116
145
  });
@@ -119,19 +148,37 @@ describe("an account names its default project", () => {
119
148
  // ── Inspiration: kept for, and a captured post's fields ─────────────────────
120
149
 
121
150
  const inspiration = profile(tpl("ecosystem"), "inspiration");
122
- const inspirationProps = new Map(inspiration.properties.map((p) => [p.slug, p]));
151
+ const inspirationProps = new Map(
152
+ inspiration.properties.map((p) => [p.slug, p])
153
+ );
123
154
 
124
155
  const HERE = dirname(fileURLToPath(import.meta.url));
125
- const apify = JSON.parse(readFileSync(join(HERE, "../capabilities/apify.capability.json"), "utf8"));
126
- const reader = (apify.spec.skills as Array<{ name: string; code?: string }>).find((s) => s.name === "capture_social_post")!;
156
+ const apify = JSON.parse(
157
+ readFileSync(join(HERE, "../capabilities/apify.capability.json"), "utf8")
158
+ );
159
+ const reader = (
160
+ apify.spec.skills as Array<{ name: string; code?: string }>
161
+ ).find((s) => s.name === "capture_social_post")!;
127
162
  const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor as new (
128
163
  ...args: string[]
129
164
  ) => (...a: unknown[]) => Promise<unknown>;
130
- const readerBody = new AsyncFunction("args", "context", "callProvider", "propose", reader.code!);
131
- async function read(url: string, item: unknown): Promise<Record<string, unknown>> {
165
+ const readerBody = new AsyncFunction(
166
+ "args",
167
+ "context",
168
+ "callProvider",
169
+ "propose",
170
+ reader.code!
171
+ );
172
+ async function read(
173
+ url: string,
174
+ item: unknown
175
+ ): Promise<Record<string, unknown>> {
132
176
  const callProvider = async () => ({ status: 201, headers: {}, body: [item] });
133
177
  const propose = { entity: async () => ({ status: "proposed" }) };
134
- return (await readerBody({ url }, {}, callProvider, propose)) as Record<string, unknown>;
178
+ return (await readerBody({ url }, {}, callProvider, propose)) as Record<
179
+ string,
180
+ unknown
181
+ >;
135
182
  }
136
183
  const IG_REEL = {
137
184
  url: "https://www.instagram.com/reel/REEL1/",
@@ -151,7 +198,13 @@ const TIKTOK = {
151
198
  text: "How we pack an order",
152
199
  createTimeISO: "2026-09-30T18:00:00.000Z",
153
200
  authorMeta: { name: "maker", profileUrl: "https://www.tiktok.com/@maker" },
154
- videoMeta: { coverUrl: "https://cdn.example/tt/cover.jpg", downloadAddr: "https://cdn.example/tt/dl.mp4", width: 720, height: 1280, duration: 22 },
201
+ videoMeta: {
202
+ coverUrl: "https://cdn.example/tt/cover.jpg",
203
+ downloadAddr: "https://cdn.example/tt/dl.mp4",
204
+ width: 720,
205
+ height: 1280,
206
+ duration: 22,
207
+ },
155
208
  diggCount: 1500,
156
209
  commentCount: 12,
157
210
  playCount: 99000,
@@ -181,27 +234,52 @@ const KEPT_AS: Record<string, string | null> = {
181
234
  describe("inspiration: kept for, and the post capture_social_post reads", () => {
182
235
  it("is kept for content, form or both, with no default (say nothing rather than guess)", () => {
183
236
  const keptFor = inspirationProps.get("kept-for");
184
- expect(keptFor).toMatchObject({ inputType: "select", enumValues: ["content", "form", "both"] });
237
+ expect(keptFor).toMatchObject({
238
+ inputType: "select",
239
+ enumValues: ["content", "form", "both"],
240
+ });
185
241
  expect(keptFor?.constraints?.defaultValue).toBeUndefined();
186
242
  });
187
243
 
188
244
  it("keeps the fields a live pod already writes on inspirations", () => {
189
- for (const slug of ["source-platform", "author-handle", "media-format", "production-layer", "priority", "style-read", "analysis", "why", "url"])
245
+ for (const slug of [
246
+ "source-platform",
247
+ "author-handle",
248
+ "media-format",
249
+ "production-layer",
250
+ "priority",
251
+ "style-read",
252
+ "analysis",
253
+ "why",
254
+ "url",
255
+ ])
190
256
  expect(inspirationProps.has(slug), slug).toBe(true);
191
257
  });
192
258
 
193
259
  it("every key the REAL reader returns (Instagram and TikTok) lands on a declared field, or is named not kept", async () => {
194
- const reads = [await read("https://www.instagram.com/reel/REEL1/", IG_REEL), await read(TIKTOK.webVideoUrl, TIKTOK)];
260
+ const reads = [
261
+ await read("https://www.instagram.com/reel/REEL1/", IG_REEL),
262
+ await read(TIKTOK.webVideoUrl, TIKTOK),
263
+ ];
195
264
  const returned = new Set<string>();
196
265
  for (const r of reads) {
197
266
  expect(r.status).toBe("ok");
198
267
  for (const [k, v] of Object.entries(r)) {
199
- if (k === "fields") for (const f of Object.keys(v as object)) returned.add(`fields.${f}`);
268
+ if (k === "fields")
269
+ for (const f of Object.keys(v as object)) returned.add(`fields.${f}`);
200
270
  else returned.add(k);
201
271
  }
202
272
  }
203
273
  // Non-vacuity: the reads carried the post's body, counts and media.
204
- for (const k of ["text", "author", "publishedAt", "media", "fields.likes", "fields.views"]) expect(returned.has(k), k).toBe(true);
274
+ for (const k of [
275
+ "text",
276
+ "author",
277
+ "publishedAt",
278
+ "media",
279
+ "fields.likes",
280
+ "fields.views",
281
+ ])
282
+ expect(returned.has(k), k).toBe(true);
205
283
  const unmapped = [...returned].filter((k) => !(k in KEPT_AS));
206
284
  expect(unmapped).toEqual([]);
207
285
  for (const k of returned) {
@@ -213,9 +291,13 @@ describe("inspiration: kept for, and the post capture_social_post reads", () =>
213
291
  it("each captured value fits its field's type", async () => {
214
292
  const r = await read("https://www.instagram.com/reel/REEL1/", IG_REEL);
215
293
  const fields = r.fields as Record<string, unknown>;
216
- expect(inspirationProps.get("likes")?.valueType).toBe(typeof fields.likes === "number" ? "number" : "?");
294
+ expect(inspirationProps.get("likes")?.valueType).toBe(
295
+ typeof fields.likes === "number" ? "number" : "?"
296
+ );
217
297
  expect(inspirationProps.get("views")?.valueType).toBe("number");
218
- expect(inspirationProps.get("media")?.valueType).toBe(Array.isArray(r.media) ? "array" : "?");
298
+ expect(inspirationProps.get("media")?.valueType).toBe(
299
+ Array.isArray(r.media) ? "array" : "?"
300
+ );
219
301
  expect(inspirationProps.get("published-at")?.valueType).toBe("date");
220
302
  expect(typeof r.publishedAt).toBe("string");
221
303
  });
@@ -231,17 +313,29 @@ describe("the piece's board, its chapters' order, and captures", () => {
231
313
  });
232
314
 
233
315
  it("part_of says where a chapter's order lives: the edge's metadata.order", () => {
234
- const d = (contentOs.relationDefs ?? []).find((x) => x.slug === "part_of") as { description?: string } | undefined;
316
+ const d = (contentOs.relationDefs ?? []).find(
317
+ (x) => x.slug === "part_of"
318
+ ) as { description?: string } | undefined;
235
319
  expect(d?.description).toContain("metadata.order");
236
320
  });
237
321
 
238
322
  it("a capture is a note with where it came from and its transcript, sorted into a piece by used_in", () => {
239
323
  const note = profile(contentOs, "note");
240
324
  const by = new Map(note.properties.map((p) => [p.slug, p]));
241
- expect(by.get("capture-source")).toMatchObject({ inputType: "select", enumValues: ["relay", "voice", "link", "email", "studio"] });
325
+ expect(by.get("capture-source")).toMatchObject({
326
+ inputType: "select",
327
+ enumValues: ["relay", "voice", "link", "email", "studio"],
328
+ });
242
329
  expect(by.get("transcript")?.inputType).toBe("textarea");
243
330
  expect(note.lifecycle).toBeUndefined();
244
- expect((contentOs.entityLinks ?? []).some((l) => l.sourceProfileSlug === "note" && l.targetProfileSlug === "content-composition" && l.type === "used_in")).toBe(true);
331
+ expect(
332
+ (contentOs.entityLinks ?? []).some(
333
+ (l) =>
334
+ l.sourceProfileSlug === "note" &&
335
+ l.targetProfileSlug === "content-composition" &&
336
+ l.type === "used_in"
337
+ )
338
+ ).toBe(true);
245
339
  });
246
340
  });
247
341
 
@@ -273,7 +367,9 @@ describe("a piece's format: content-format (design I)", () => {
273
367
  it("offers the network-neutral carousel, and says what it means: a carousel whose network is not set", () => {
274
368
  const prop = piece.properties.find((p) => p.slug === "content-format");
275
369
  expect(prop?.enumValues).toContain("carousel");
276
- expect(prop?.description).toContain("carousel = Carousel, network not set (made before design I)");
370
+ expect(prop?.description).toContain(
371
+ "carousel = Carousel, network not set (made before design I)"
372
+ );
277
373
  });
278
374
 
279
375
  it("has no default: a new piece is a thinking piece until a format is picked", () => {
@@ -286,28 +382,51 @@ describe("a piece's format: content-format (design I)", () => {
286
382
  it("a content piece is a child composition derived_from the piece it is made from (D2)", () => {
287
383
  expect(
288
384
  (contentOs.entityLinks ?? []).some(
289
- (l) => l.sourceProfileSlug === "content-composition" && l.targetProfileSlug === "content-composition" && l.type === "derived_from",
290
- ),
385
+ (l) =>
386
+ l.sourceProfileSlug === "content-composition" &&
387
+ l.targetProfileSlug === "content-composition" &&
388
+ l.type === "derived_from"
389
+ )
291
390
  ).toBe(true);
292
391
  });
293
392
  });
294
393
 
295
394
  describe("Thinking session: a timeboxed process on one piece, the AI never writes it", () => {
296
- const pb = (contentOs.playbooks ?? []).find((p) => p.name === "Thinking session");
395
+ const pb = (contentOs.playbooks ?? []).find(
396
+ (p) => p.name === "Thinking session"
397
+ );
297
398
 
298
399
  it("works one piece, with a timebox param of 60 minutes by default", () => {
299
400
  expect(pb?.subjectProfile?.profileSlug).toBe("content-composition");
300
- const params = (pb?.params ?? []) as Array<{ name: string; type: string; default?: unknown; required?: boolean }>;
301
- expect(params.find((p) => p.name === "piece")).toMatchObject({ type: "entity", required: true });
302
- expect(params.find((p) => p.name === "minutes")).toMatchObject({ type: "number", default: 60 });
401
+ const params = (pb?.params ?? []) as Array<{
402
+ name: string;
403
+ type: string;
404
+ default?: unknown;
405
+ required?: boolean;
406
+ }>;
407
+ expect(params.find((p) => p.name === "piece")).toMatchObject({
408
+ type: "entity",
409
+ required: true,
410
+ });
411
+ expect(params.find((p) => p.name === "minutes")).toMatchObject({
412
+ type: "number",
413
+ default: 60,
414
+ });
303
415
  expect(pb?.goalTemplate).toContain("{minutes}");
304
416
  });
305
417
 
306
418
  it("gather → questions → thesis → draft; only the person-approved draft moves the piece, to Drafting", () => {
307
419
  const stages = pb?.stages ?? [];
308
- expect(stages.map((s) => s.key)).toEqual(["gather", "questions", "thesis", "draft"]);
420
+ expect(stages.map((s) => s.key)).toEqual([
421
+ "gather",
422
+ "questions",
423
+ "thesis",
424
+ "draft",
425
+ ]);
309
426
  const moving = stages.filter((s) => s.subjectStatus);
310
- expect(moving.map((s) => [s.key, s.subjectStatus])).toEqual([["draft", "drafting"]]);
427
+ expect(moving.map((s) => [s.key, s.subjectStatus])).toEqual([
428
+ ["draft", "drafting"],
429
+ ]);
311
430
  expect(keys).toContain("drafting");
312
431
  const draft = stages.find((s) => s.key === "draft");
313
432
  expect(draft?.gate).toEqual({ kind: "human" });
@@ -321,7 +440,9 @@ describe("Thinking session: a timeboxed process on one piece, the AI never write
321
440
  });
322
441
 
323
442
  describe("Derive outputs: posts (any number per account) and a newsletter issue, derived_from the piece", () => {
324
- const pb = (contentOs.playbooks ?? []).find((p) => p.name === "Derive outputs");
443
+ const pb = (contentOs.playbooks ?? []).find(
444
+ (p) => p.name === "Derive outputs"
445
+ );
325
446
  const post = profile(contentOs, "post");
326
447
  const postProps = new Set(post.properties.map((p) => p.slug));
327
448
  const goal = pb?.goalTemplate ?? "";
@@ -330,7 +451,11 @@ describe("Derive outputs: posts (any number per account) and a newsletter issue,
330
451
  expect(pb?.subjectProfile?.profileSlug).toBe("content-composition");
331
452
  expect(pb?.executor).toBe("is-agent");
332
453
  expect(pb?.tools).toEqual(["create_entity", "create_relation"]);
333
- const params = (pb?.params ?? []) as Array<{ name: string; type: string; required?: boolean }>;
454
+ const params = (pb?.params ?? []) as Array<{
455
+ name: string;
456
+ type: string;
457
+ required?: boolean;
458
+ }>;
334
459
  expect(params.map((p) => [p.name, p.type])).toEqual([
335
460
  ["piece", "entity"],
336
461
  ["accounts", "text"],
@@ -342,13 +467,22 @@ describe("Derive outputs: posts (any number per account) and a newsletter issue,
342
467
  });
343
468
 
344
469
  it("every post field the goal names is a real post field, and Idea is the post lifecycle's first step", () => {
345
- const named = ["post-status", "post-account", "publish-date", "post-hook", "content", "post-platform"];
470
+ const named = [
471
+ "post-status",
472
+ "post-account",
473
+ "publish-date",
474
+ "post-hook",
475
+ "content",
476
+ "post-platform",
477
+ ];
346
478
  for (const f of named) {
347
479
  expect(goal, f).toContain(f);
348
480
  expect(postProps.has(f), f).toBe(true);
349
481
  }
350
482
  expect(post.lifecycle?.options[0]?.key).toBe("Idea");
351
- expect(profile(contentOs, "newsletter").lifecycle?.options[0]?.key).toBe("Idea");
483
+ expect(profile(contentOs, "newsletter").lifecycle?.options[0]?.key).toBe(
484
+ "Idea"
485
+ );
352
486
  });
353
487
 
354
488
  it("spreads posts over two weeks, never two on one account the same day, skipping taken days", () => {
@@ -358,13 +492,23 @@ describe("Derive outputs: posts (any number per account) and a newsletter issue,
358
492
  });
359
493
 
360
494
  it("each output is derived_from the piece, declared as a link the space knows", () => {
361
- expect(pb?.expectedOutputs?.map((o) => [o.kind, o.relationToSubject])).toEqual([
495
+ expect(
496
+ pb?.expectedOutputs?.map((o) => [o.kind, o.relationToSubject])
497
+ ).toEqual([
362
498
  ["post", "derived_from"],
363
499
  ["newsletter", "derived_from"],
364
500
  ]);
365
501
  const links = contentOs.entityLinks ?? [];
366
502
  for (const kind of ["post", "newsletter"])
367
- expect(links.some((l) => l.sourceProfileSlug === kind && l.targetProfileSlug === "content-composition" && l.type === "derived_from"), kind).toBe(true);
503
+ expect(
504
+ links.some(
505
+ (l) =>
506
+ l.sourceProfileSlug === kind &&
507
+ l.targetProfileSlug === "content-composition" &&
508
+ l.type === "derived_from"
509
+ ),
510
+ kind
511
+ ).toBe(true);
368
512
  });
369
513
 
370
514
  it("writes only through its own tools, and leaves the piece's status alone (no update tool)", () => {