@synap-core/workspace-templates 0.71.0 → 0.73.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.
Files changed (30) hide show
  1. package/README.md +10 -3
  2. package/automations/github-pr-events.automation.json +1 -1
  3. package/automations/ship-a-change-checks-green.automation.json +1 -1
  4. package/automations/ship-a-change-checks-red.automation.json +1 -1
  5. package/automations/ship-a-change-deployed.automation.json +1 -1
  6. package/automations/ship-a-change-pr-merged.automation.json +1 -1
  7. package/automations/ship-a-change-pr-opened.automation.json +1 -1
  8. package/capabilities/apify-linkedin-profiles.capability.json +45 -0
  9. package/capabilities/apify-social-post-capture.capability.json +57 -0
  10. package/capabilities/apify.capability.json +2 -50
  11. package/capabilities/github-issues.capability.json +176 -0
  12. package/capabilities/stripe-payments.capability.json +176 -0
  13. package/capabilities/test-api-3.capability.json +104 -0
  14. package/capabilities/unipile-linkedin.capability.json +5 -3
  15. package/dist/index.js +1128 -35
  16. package/dist/index.js.map +1 -1
  17. package/package.json +1 -1
  18. package/skills/app-factory-research/SKILL.md +1 -1
  19. package/src/apify-social-reader.test.ts +8 -3
  20. package/src/builder-work-views.template.test.ts +207 -0
  21. package/src/builder.yaml +523 -32
  22. package/src/content-os.piece-model.template.test.ts +8 -6
  23. package/src/content-os.yaml +7 -0
  24. package/src/crm.yaml +4 -3
  25. package/src/dev-flow-change.template.test.ts +192 -0
  26. package/src/kanban-grouping.test.ts +16 -0
  27. package/src/retired-names.test.ts +68 -0
  28. package/src/templates.ts +906 -30
  29. package/src/validate.ts +56 -5
  30. package/automations/ship-a-change-deployed.catalog.json +0 -18
@@ -153,12 +153,14 @@ const inspirationProps = new Map(
153
153
  );
154
154
 
155
155
  const HERE = dirname(fileURLToPath(import.meta.url));
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")!;
156
+ // `capture_social_post` is the "Social post capture" add-on (its own manifest), no longer a skill of apify.capability.json.
157
+ const skillsOf = (file: string) =>
158
+ JSON.parse(readFileSync(join(HERE, "../capabilities", file), "utf8")).spec
159
+ .skills as Array<{ name: string; code?: string }>;
160
+ const reader = [
161
+ ...skillsOf("apify.capability.json"),
162
+ ...skillsOf("apify-social-post-capture.capability.json"),
163
+ ].find((s) => s.name === "capture_social_post")!;
162
164
  const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor as new (
163
165
  ...args: string[]
164
166
  ) => (...a: unknown[]) => Promise<unknown>;
@@ -424,6 +424,12 @@ profiles:
424
424
  inputType: text
425
425
  placeholder: "https://..."
426
426
  constraints: { format: url }
427
+ # The first comment on the published post (e.g., LinkedIn link in first comment)
428
+ - slug: post-first-comment
429
+ label: First Comment
430
+ valueType: string
431
+ inputType: textarea
432
+ placeholder: "First comment text (e.g., LinkedIn link in first comment)"
427
433
  # The publishing ACCOUNT (a `platform` entity) the post goes out on —
428
434
  # distinct from `post-platform`, the network label above.
429
435
  - slug: post-account
@@ -1337,6 +1343,7 @@ profiles:
1337
1343
  color: blue
1338
1344
  description: "A piece of work: its body is a document (an essay, a post, a chapter), its sources are linked (inspirations, ideas, earlier pieces), and its outputs (posts, a newsletter issue, a site essay) are derived from it. A video or carousel piece also carries its brief, storyboard, project zip, render and key-frame stills."
1339
1345
  semanticSlug: content.composition
1346
+ entityScope: workspace
1340
1347
  # How it renders (entity rendering, decision 8): @synap-core/types/presentation.
1341
1348
  presentation:
1342
1349
  family: document
package/src/crm.yaml CHANGED
@@ -2652,7 +2652,7 @@ playbooks:
2652
2652
  space's workspaceId, type bento). When the space has none, stop and say
2653
2653
  so: never create another dashboard. READ FIRST: what already sits on
2654
2654
  Health (its config.blocks: each widget tile names a cell by widgetType)
2655
- and the space's cells (synap_list_widgets); when a tile already answers
2655
+ and the space's cells (synap_list_cells); when a tile already answers
2656
2656
  the question, say which one and stop. DATA: decide where each number
2657
2657
  comes from. A cell reads the pod ONLY through the cell bridge, at
2658
2658
  render time: window.synap.query(op, params), with an op of the bridge
@@ -2660,8 +2660,9 @@ playbooks:
2660
2660
  lifecycle.board, flow.of, lifecycle.throughput, attention.needsYou,
2661
2661
  attention.count, sessions.list, lifecycle.home, lifecycle.moving,
2662
2662
  documents.get, lens.page, sessions.get, playbook.process,
2663
- playbook.scorecard, project.pillars) and only that op's params; the
2664
- host stamps the space, so never put a workspaceId, a token, a pod URL
2663
+ playbook.scorecard, project.pillars, views.get, views.execute,
2664
+ profiles.get, propertyDefs.list, lifecycle.get, graph.of) and only that
2665
+ op's params; the host stamps the space, so never put a workspaceId, a token, a pod URL
2665
2666
  or a fetch in the page. What the bridge reads stays live: query it in
2666
2667
  the page, never
2667
2668
  paste its rows. What it cannot read yet (messages, replies, sends: the
@@ -0,0 +1,192 @@
1
+ /**
2
+ * The dev flow as catalog content (founder decision, 27 Nov 2026, audit
3
+ * dec915cb): Builder's `change` kind (one pull request), the automation "A
4
+ * pull request moves its change" (GitHub's events → the change's status,
5
+ * generic doors only), the view "Changes by state", the playbook "Land a
6
+ * change" that follows the change, and Ship a change's holds on it.
7
+ *
8
+ * What this guards:
9
+ * 1. the change's lifecycle is the one the flow writes: every status the
10
+ * automation sets (literal or a select's value) and every stage status of
11
+ * Land a change is an option of it; the dedupe key and every property the
12
+ * flow writes are properties of the kind;
13
+ * 2. the automation passes the shipped flow validator, declares its inbound
14
+ * source by NAME (portable, never one pod's subscription id), and finds
15
+ * the change by prRef + headSha through a JSON-STRING filter (an object
16
+ * filter is read without templating by the pod's query step);
17
+ * 3. REACHABILITY: no checks verdict reaches a status write except through
18
+ * the guard that the change is waiting on its checks, and no pull request
19
+ * event reaches the create/move except through "its base is the default
20
+ * branch" (drop the gate, then no write may stay reachable);
21
+ * 4. Land a change binds the kind, its first stage writes no status (a birth
22
+ * writes the first stage's status: a change further along must not be
23
+ * pulled back), and it is a draft with no activators;
24
+ * 5. Ship a change waits on the change with an entity hold.
25
+ *
26
+ * Not covered: a pod running it against GitHub's real payloads (NEEDS-DOGFOOD).
27
+ */
28
+ import { describe, expect, it } from "vitest";
29
+ import { readYamlTemplates } from "./generate.mjs";
30
+ import { validateFlowDefinition } from "./validate-flow.js";
31
+ import { validateTemplate } from "./validate.js";
32
+ import { webhookSourceProblems } from "../scripts/catalog-lib.mjs";
33
+ import type { WorkspaceYaml } from "./types.js";
34
+
35
+ type FlowNode = { id: string; type: string; data: Record<string, any> };
36
+ type FlowEdge = { id: string; source: string; target: string; sourceHandle?: string };
37
+
38
+ const corpus = readYamlTemplates().map((t) => t.data as WorkspaceYaml);
39
+ const builder = readYamlTemplates().find((t) => t.file === "builder.yaml")!.data as any;
40
+ const kind = builder.profiles.find((p: any) => p.slug === "change");
41
+ const options: string[] = kind.lifecycle.options.map((o: any) => o.key);
42
+ const propertySlugs = new Set<string>(kind.properties.map((p: any) => p.slug));
43
+ const automation = (builder.automations ?? []).find((a: any) => a.key === "pull-request-moves-change");
44
+ const nodes: FlowNode[] = automation.flow.nodes;
45
+ const edges: FlowEdge[] = automation.flow.edges;
46
+ const node = (id: string) => nodes.find((n) => n.id === id)!;
47
+ const writes = nodes.filter(
48
+ (n) => n.type === "output" && ["entity_create", "entity_update"].includes(n.data.outputType)
49
+ );
50
+
51
+ /** Node ids reachable from the trigger when `blocked` nodes stop the walk. */
52
+ function reachable(blocked: Set<string>): Set<string> {
53
+ const seen = new Set<string>();
54
+ const queue = nodes.filter((n) => n.type === "trigger").map((n) => n.id);
55
+ while (queue.length) {
56
+ const id = queue.shift()!;
57
+ if (seen.has(id) || blocked.has(id)) continue;
58
+ seen.add(id);
59
+ queue.push(...edges.filter((e) => e.source === id).map((e) => e.target));
60
+ }
61
+ return seen;
62
+ }
63
+
64
+ describe("the change kind", () => {
65
+ it("declares its lifecycle once, with these categories", () => {
66
+ // Workspace-scoped (founder, 29 Nov 2026): a kind left unscoped is pod-wide.
67
+ expect(kind.entityScope).toBe("workspace");
68
+ expect(kind.lifecycle.property).toBe("changeStatus");
69
+ expect(kind.lifecycle.options.map((o: any) => [o.key, o.category])).toEqual([
70
+ ["working", "open"],
71
+ ["checks", "active"],
72
+ ["red", "active"],
73
+ ["ready", "active"],
74
+ ["merged", "done"],
75
+ ["closed", "lost"],
76
+ ]);
77
+ const select = kind.properties.find((p: any) => p.slug === "changeStatus");
78
+ expect(select.enumValues).toEqual(options);
79
+ });
80
+
81
+ it("Builder validates with it (kind, view, playbook, automation)", () => {
82
+ expect(validateTemplate(builder, { corpus }).errors).toEqual([]);
83
+ });
84
+
85
+ it("the view groups the changes by their lifecycle", () => {
86
+ const view = builder.views.find((v: any) => v.slug === "changes-by-state");
87
+ expect(view).toMatchObject({ type: "kanban", scopeProfileSlug: "change", config: { groupByField: "changeStatus" } });
88
+ });
89
+ });
90
+
91
+ describe("A pull request moves its change", () => {
92
+ it("passes the flow validator", () => {
93
+ expect(validateFlowDefinition(automation.flow).errors).toEqual([]);
94
+ });
95
+
96
+ it("listens to an inbound source by name, never one pod's subscription id", () => {
97
+ expect(automation.triggerType).toBe("webhook");
98
+ expect(automation.triggerConfig.webhookSource).toEqual({ name: "GitHub changes" });
99
+ expect(webhookSourceProblems({ ...automation, flow: automation.flow })).toEqual([]);
100
+ });
101
+
102
+ it("writes only statuses of the change's lifecycle", () => {
103
+ const written = writes.flatMap((n) => {
104
+ const v = n.data.config.properties?.changeStatus;
105
+ if (v === undefined) return [];
106
+ const ref = /^\{\{steps\.([\w-]+)\.output\.value\}\}$/.exec(v);
107
+ if (!ref) return [v];
108
+ // Follow the select chain to every literal it can yield.
109
+ const out: string[] = [];
110
+ const walk = (id: string) => {
111
+ const sel = node(id);
112
+ expect(sel.type).toBe("select");
113
+ for (const branch of [sel.data.ifTrue, sel.data.ifFalse]) {
114
+ const inner = /^\{\{steps\.([\w-]+)\.output\.value\}\}$/.exec(branch);
115
+ if (inner) walk(inner[1]);
116
+ else out.push(branch);
117
+ }
118
+ };
119
+ walk(ref[1]);
120
+ return out;
121
+ });
122
+ // non-vacuity: the pull request path and both verdicts
123
+ expect(new Set(written)).toEqual(new Set(["working", "checks", "closed", "merged", "ready", "red"]));
124
+ expect(written.filter((s) => !options.includes(s))).toEqual([]);
125
+ });
126
+
127
+ it("writes only properties of the kind, and dedupes on one of them", () => {
128
+ const keys = writes.flatMap((n) => Object.keys(n.data.config.properties ?? {}));
129
+ expect(keys.length).toBeGreaterThanOrEqual(10);
130
+ expect(keys.filter((k) => !propertySlugs.has(k))).toEqual([]);
131
+ const create = writes.find((n) => n.data.outputType === "entity_create")!;
132
+ expect(create.data.config).toMatchObject({ profileSlug: "change", dedupeBy: "prRef" });
133
+ expect(propertySlugs.has(create.data.config.dedupeBy)).toBe(true);
134
+ });
135
+
136
+ it("finds the change by prRef and head commit through a JSON-string filter", () => {
137
+ const find = node("find");
138
+ expect(find.type).toBe("query");
139
+ expect(find.data.profileSlug).toBe("change");
140
+ expect(typeof find.data.filter).toBe("string");
141
+ const parsed = JSON.parse(find.data.filter.replace(/\{\{[^}]*\}\}/g, "x"));
142
+ expect(Object.keys(parsed).sort()).toEqual(["headSha", "prRef"]);
143
+ });
144
+
145
+ it("a verdict writes only through the guard that the change waits on its checks", () => {
146
+ const verdictWrites = ["mark-ready", "mark-red"];
147
+ expect(verdictWrites.every((id) => reachable(new Set()).has(id))).toBe(true);
148
+ const guard = node("open-change");
149
+ expect(guard.type).toBe("guard");
150
+ const allowed = guard.data.checks.flatMap((c: any) => (c.anyOf ?? []).map((a: any) => a.equals));
151
+ expect(allowed.sort()).toEqual(["checks", "ready", "red"]);
152
+ const past = reachable(new Set(["open-change"]));
153
+ expect(verdictWrites.filter((id) => past.has(id))).toEqual([]);
154
+ });
155
+
156
+ it("a pull request event writes only through 'its base is the default branch' (yes)", () => {
157
+ const prWrites = ["upsert", "move"];
158
+ expect(prWrites.every((id) => reachable(new Set()).has(id))).toBe(true);
159
+ const out = edges.filter((e) => e.source === "into-default");
160
+ expect(out.map((e) => e.sourceHandle)).toEqual(["yes"]);
161
+ const past = reachable(new Set(["into-default"]));
162
+ expect(prWrites.filter((id) => past.has(id))).toEqual([]);
163
+ });
164
+ });
165
+
166
+ describe("Land a change follows the change", () => {
167
+ const pb = builder.playbooks.find((p: any) => p.name === "Land a change");
168
+
169
+ it("binds the kind, a draft with no activators", () => {
170
+ expect(pb.subjectProfile).toEqual({ profileSlug: "change" });
171
+ expect(pb.status).toBe("draft");
172
+ expect(pb.activators ?? []).toEqual([]);
173
+ });
174
+
175
+ it("every stage status is an option, the first stage writes none, and only Closed has no stage", () => {
176
+ const statuses = pb.stages.map((s: any) => s.subjectStatus).filter(Boolean);
177
+ expect(statuses.filter((s: string) => !options.includes(s))).toEqual([]);
178
+ expect(pb.stages[0].subjectStatus).toBeUndefined();
179
+ expect(options.filter((o) => !statuses.includes(o))).toEqual(["working", "closed"]);
180
+ });
181
+ });
182
+
183
+ describe("Ship a change waits on the change", () => {
184
+ const ship = builder.playbooks.find((p: any) => p.name === "Ship a change");
185
+ it("its checks and merge stages pause with a hold on the change entity", () => {
186
+ for (const key of ["checks", "merge"]) {
187
+ const goal = ship.stages.find((s: any) => s.key === key).goal as string;
188
+ // wake: the resume hands the session back to its agent (backend#1376).
189
+ expect(goal, key).toContain('until: {moves: "entity:<change id>"}, wake: true}');
190
+ }
191
+ });
192
+ });
@@ -54,6 +54,22 @@ describe("kanban grouping — view-kanban-group-*", () => {
54
54
  expect(rules(make({ config: { groupByField: "ghost" } }))).toEqual(["view-kanban-group-unknown"]);
55
55
  });
56
56
 
57
+ it("a string the pod derives (workedIn) groups by its distinct values; any other free text is still refused", () => {
58
+ const withProps = (extra: Record<string, unknown>[], groupByField: string) => {
59
+ const t = make({ config: { groupByField } });
60
+ (t.profiles[0].properties as unknown as Record<string, unknown>[]).push(...extra);
61
+ return rules(t);
62
+ };
63
+ const workedIn = { slug: "workedIn", label: "Claude Code session", valueType: "string", inputType: "text" };
64
+ expect(withProps([workedIn], "properties.workedIn")).toEqual([]);
65
+ // The exception is the KEY, not any string: a free-text field is refused,
66
+ // and so is workedIn when the kind does not declare it.
67
+ expect(withProps([{ slug: "owner", label: "Owner", valueType: "string", inputType: "text" }], "owner")).toEqual(["view-kanban-group-unknown"]);
68
+ expect(withProps([], "workedIn")).toEqual(["view-kanban-group-unknown"]);
69
+ // workedInAll is a list: one card has several values, it is no column key.
70
+ expect(withProps([{ slug: "workedInAll", label: "All", valueType: "array", inputType: "tags" }], "workedInAll")).toEqual(["view-kanban-group-unknown"]);
71
+ });
72
+
57
73
  it("a kind with no declaration in reach (a system kind) is not judged", () => {
58
74
  expect(rules(make({ scopeProfileSlug: "task", config: { groupByField: "anything" } }))).toEqual([]);
59
75
  });
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The catalog never teaches a retired name (surfaces review, 27 Nov 2026,
3
+ * architecture S8). What a playbook goal or a catalog skill says is what an
4
+ * agent calls on every pod the catalog reaches, so an old name keeps the old
5
+ * way alive after the doors moved on:
6
+ *
7
+ * - `synap_list_widgets` is the old name of `synap_list_cells` (backend#1310;
8
+ * the pod still dispatches it as an alias, but the word is Cell);
9
+ * - `DEPRECATED_SURFACES` (`@synap-core/types/surfaces`) is now
10
+ * `DEPRECATED_IN_HOSTS` in `@synap-core/types/hosts` (a host app or tab,
11
+ * not a Surface).
12
+ *
13
+ * Scanned set derived from disk: every `src/*.yaml` and every `.md` under
14
+ * `skills/`. Does NOT cover backend-owned texts (the pod's tool descriptions
15
+ * and system skills), which have their own guards there.
16
+ */
17
+
18
+ import { readdirSync, readFileSync } from "node:fs";
19
+ import { dirname, join } from "node:path";
20
+ import { fileURLToPath } from "node:url";
21
+ import { describe, expect, it } from "vitest";
22
+
23
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
24
+ const RETIRED = [/\bsynap_list_widgets\b/, /\bDEPRECATED_SURFACES\b/];
25
+
26
+ function walk(dir: string, keep: (name: string) => boolean): string[] {
27
+ const out: string[] = [];
28
+ for (const e of readdirSync(dir, { withFileTypes: true })) {
29
+ const p = join(dir, e.name);
30
+ if (e.isDirectory()) out.push(...walk(p, keep));
31
+ else if (keep(e.name)) out.push(p);
32
+ }
33
+ return out;
34
+ }
35
+
36
+ const files = [
37
+ ...readdirSync(join(ROOT, "src"))
38
+ .filter((n) => n.endsWith(".yaml"))
39
+ .map((n) => join(ROOT, "src", n)),
40
+ ...walk(join(ROOT, "skills"), (n) => n.endsWith(".md")),
41
+ ];
42
+
43
+ describe("the catalog teaches no retired name", () => {
44
+ it("scans the catalog's playbooks and skills (non-vacuous)", () => {
45
+ expect(files.filter((f) => f.endsWith(".yaml")).length).toBeGreaterThan(20);
46
+ expect(files.filter((f) => f.endsWith(".md")).length).toBeGreaterThan(20);
47
+ // The CRM Health playbook lists the space's cells: it must name the live door.
48
+ expect(readFileSync(join(ROOT, "src", "crm.yaml"), "utf8")).toContain("synap_list_cells");
49
+ });
50
+
51
+ it("no playbook or skill names synap_list_widgets or DEPRECATED_SURFACES", () => {
52
+ const hits: string[] = [];
53
+ for (const f of files) {
54
+ const lines = readFileSync(f, "utf8").split("\n");
55
+ lines.forEach((line, i) => {
56
+ if (RETIRED.some((re) => re.test(line))) hits.push(`${f.slice(ROOT.length + 1)}:${i + 1}: ${line.trim()}`);
57
+ });
58
+ }
59
+ expect(hits).toEqual([]);
60
+ });
61
+
62
+ it("self-check: the patterns catch the old names and spare the new ones", () => {
63
+ expect(RETIRED.some((re) => re.test("the space's cells (synap_list_widgets)"))).toBe(true);
64
+ expect(RETIRED.some((re) => re.test("`DEPRECATED_SURFACES` in `@synap-core/types/surfaces`"))).toBe(true);
65
+ expect(RETIRED.some((re) => re.test("the space's cells (synap_list_cells)"))).toBe(false);
66
+ expect(RETIRED.some((re) => re.test("`DEPRECATED_IN_HOSTS` in `@synap-core/types/hosts`"))).toBe(false);
67
+ });
68
+ });