create-freeholder 0.2.0-beta.4 → 0.2.0-beta.6

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 (158) hide show
  1. package/dist/template/.changeset/blog-playground-content.md +4 -0
  2. package/dist/template/.changeset/blog-wordpress-structure.md +6 -0
  3. package/dist/template/.changeset/managed-preview-assistant.md +4 -0
  4. package/dist/template/.changeset/native-linux-install.md +6 -0
  5. package/dist/template/.changeset/public-beta-5.md +4 -0
  6. package/dist/template/.changeset/public-beta-6.md +4 -0
  7. package/dist/template/.github/ISSUE_TEMPLATE/bug_report.yml +1 -1
  8. package/dist/template/.github/workflows/release-tarballs.yml +117 -0
  9. package/dist/template/AGENTS.md +15 -2
  10. package/dist/template/Dockerfile +3 -0
  11. package/dist/template/MASTER.md +114 -11
  12. package/dist/template/README.md +1 -1
  13. package/dist/template/app/(admin)/admin/assistant/page.tsx +9 -1
  14. package/dist/template/app/(admin)/admin/blog/PostSettings.tsx +26 -0
  15. package/dist/template/app/(admin)/admin/blog/[kind]/page.tsx +53 -0
  16. package/dist/template/app/(admin)/admin/blog/actions.ts +186 -6
  17. package/dist/template/app/(admin)/admin/blog/comments/page.tsx +25 -0
  18. package/dist/template/app/(admin)/admin/blog/page.tsx +21 -5
  19. package/dist/template/app/(admin)/admin/imports/[id]/page.tsx +2 -0
  20. package/dist/template/app/(admin)/admin/pages/[id]/page.tsx +3 -0
  21. package/dist/template/app/(admin)/assistant-actions.ts +13 -6
  22. package/dist/template/app/(public)/[[...slug]]/ReaderComments.tsx +25 -0
  23. package/dist/template/app/(public)/[[...slug]]/blog-parts.tsx +153 -0
  24. package/dist/template/app/(public)/[[...slug]]/comment-actions.ts +16 -0
  25. package/dist/template/app/(public)/[[...slug]]/page.tsx +182 -18
  26. package/dist/template/app/api/chat/assistant/call/route.ts +35 -0
  27. package/dist/template/db/migrations/0061_blog_structure.sql +89 -0
  28. package/dist/template/db/migrations/0062_blog_reader_comments.sql +24 -0
  29. package/dist/template/db/migrations/meta/_journal.json +14 -0
  30. package/dist/template/deploy/README.md +26 -9
  31. package/dist/template/deploy/blog-wordpress-2026-11-07.md +146 -0
  32. package/dist/template/deploy/docker-selfhost/.env.example +11 -1
  33. package/dist/template/deploy/docker-selfhost/README.md +79 -50
  34. package/dist/template/deploy/docker-selfhost/infra/backup.sh +81 -0
  35. package/dist/template/deploy/docker-selfhost/infra/compose.https.yml +37 -1
  36. package/dist/template/deploy/docker-selfhost/infra/compose.yml +37 -1
  37. package/dist/template/deploy/docker-selfhost/migrate.md +8 -5
  38. package/dist/template/deploy/docker-selfhost/recipe.yaml +9 -10
  39. package/dist/template/deploy/docker-selfhost/selfhost.sh +206 -0
  40. package/dist/template/deploy/docker-selfhost/verify.md +11 -4
  41. package/dist/template/deploy/f-criteria-matrix.md +89 -0
  42. package/dist/template/deploy/linux/.env.example +28 -0
  43. package/dist/template/deploy/linux/README.md +181 -0
  44. package/dist/template/deploy/linux/freeholder +655 -0
  45. package/dist/template/deploy/linux/install.sh +173 -0
  46. package/dist/template/deploy/linux/migrate.md +17 -0
  47. package/dist/template/deploy/linux/recipe.yaml +50 -0
  48. package/dist/template/deploy/linux/share/Caddyfile.template +19 -0
  49. package/dist/template/deploy/linux/share/systemd/freeholder-backup.service +13 -0
  50. package/dist/template/deploy/linux/share/systemd/freeholder-backup.timer +12 -0
  51. package/dist/template/deploy/linux/share/systemd/freeholder.service +41 -0
  52. package/dist/template/deploy/linux/verify.md +22 -0
  53. package/dist/template/deploy/managed-preview-assistant.md +99 -0
  54. package/dist/template/eslint.config.mjs +3 -1
  55. package/dist/template/gitignore.template +1 -0
  56. package/dist/template/locales/ar.json +85 -6
  57. package/dist/template/locales/en.json +83 -4
  58. package/dist/template/locales/es.json +83 -4
  59. package/dist/template/locales/fr.json +85 -6
  60. package/dist/template/next.config.ts +2 -0
  61. package/dist/template/package.json +3 -2
  62. package/dist/template/packages/cli/package.json +1 -1
  63. package/dist/template/packages/create-freeholder/package.json +1 -1
  64. package/dist/template/packages/freeholder-app/package.json +1 -1
  65. package/dist/template/packages/mobile-app/package.json +1 -1
  66. package/dist/template/packages/plugin-kit/package.json +1 -1
  67. package/dist/template/packages/sdk/package.json +1 -1
  68. package/dist/template/packages/sdk/src/generated.ts +177 -9
  69. package/dist/template/packages/sdk/src/version.ts +1 -1
  70. package/dist/template/packages/templates/package.json +1 -1
  71. package/dist/template/proxy.ts +18 -1
  72. package/dist/template/public/managed-assistant/0.1.10/duplex-codec/NOTICE.txt +117 -0
  73. package/dist/template/public/managed-assistant/0.1.10/duplex-codec/audio-output-processor.js +267 -0
  74. package/dist/template/public/managed-assistant/0.1.10/duplex-codec/decoderWorker.min.js +847 -0
  75. package/dist/template/public/managed-assistant/0.1.10/duplex-codec/decoderWorker.min.wasm +0 -0
  76. package/dist/template/public/managed-assistant/0.1.10/duplex-codec/encoderWorker.min.js +1 -0
  77. package/dist/template/public/managed-assistant/0.1.10/manifest.json +12 -0
  78. package/dist/template/public/managed-assistant/0.1.10/pm-ai-duplex-client.js +1376 -0
  79. package/dist/template/scripts/build-release.d.mts +4 -0
  80. package/dist/template/scripts/build-release.mjs +171 -0
  81. package/dist/template/scripts/launch-prepare.mjs +6 -3
  82. package/dist/template/scripts/license-headers.mjs +3 -0
  83. package/dist/template/scripts/recipe-matrix.sh +22 -7
  84. package/dist/template/scripts/verify-wordpress-migration.d.mts +8 -0
  85. package/dist/template/scripts/verify-wordpress-migration.mjs +105 -0
  86. package/dist/template/security/adversarial-audit-2026-10-08.md +1 -1
  87. package/dist/template/src/adapters/ai/types.ts +5 -0
  88. package/dist/template/src/adapters/paradise/assistant.ts +37 -0
  89. package/dist/template/src/adapters/paradise/http.ts +4 -3
  90. package/dist/template/src/adapters/storage/local-mode.ts +54 -0
  91. package/dist/template/src/adapters/storage/local.ts +53 -26
  92. package/dist/template/src/core/contract/json-schema.ts +8 -0
  93. package/dist/template/src/core/demo/playground-inserts.ts +29 -0
  94. package/dist/template/src/core/demo/playground-policy.ts +9 -0
  95. package/dist/template/src/core/doctor/index.ts +19 -10
  96. package/dist/template/src/core/env.ts +8 -1
  97. package/dist/template/src/core/http/csp.ts +10 -2
  98. package/dist/template/src/core/http/csrf-client.ts +10 -0
  99. package/dist/template/src/core/import/service.ts +217 -12
  100. package/dist/template/src/core/import/wordpress.ts +80 -15
  101. package/dist/template/src/core/notifications/service.ts +1 -0
  102. package/dist/template/src/core/retention/registry.ts +2 -0
  103. package/dist/template/src/core/search/registry.ts +2 -0
  104. package/dist/template/src/core/seo/feeds.ts +2 -0
  105. package/dist/template/src/core/seo/jsonld.ts +46 -2
  106. package/dist/template/src/core/seo/legacy-proxy.ts +53 -0
  107. package/dist/template/src/core/seo/meta.ts +10 -7
  108. package/dist/template/src/core/seo/service.ts +14 -1
  109. package/dist/template/src/core/update/preflight.ts +3 -2
  110. package/dist/template/src/core/update/release-declaration.json +1 -1
  111. package/dist/template/src/core/update/service.ts +7 -17
  112. package/dist/template/src/modules/assistant/contract.ts +1 -1
  113. package/dist/template/src/modules/assistant/limits.ts +3 -0
  114. package/dist/template/src/modules/assistant/preview.ts +124 -0
  115. package/dist/template/src/modules/assistant/provider.ts +7 -0
  116. package/dist/template/src/modules/assistant/service.ts +21 -5
  117. package/dist/template/src/modules/cms/blocks/PreviewAssistantCall.tsx +176 -0
  118. package/dist/template/src/modules/cms/blocks/SiteChatClient.tsx +10 -4
  119. package/dist/template/src/modules/cms/blocks/surfaces.tsx +10 -0
  120. package/dist/template/src/modules/cms/blog-comments-schema.ts +27 -0
  121. package/dist/template/src/modules/cms/blog-comments.ts +111 -0
  122. package/dist/template/src/modules/cms/blog-schema.ts +146 -0
  123. package/dist/template/src/modules/cms/blog-service.ts +999 -0
  124. package/dist/template/src/modules/cms/blog.tsx +245 -25
  125. package/dist/template/src/modules/cms/manifest.ts +7 -1
  126. package/dist/template/src/modules/cms/read.ts +18 -0
  127. package/dist/template/src/modules/cms/service.ts +22 -4
  128. package/dist/template/src/modules/cms/tables.ts +2 -0
  129. package/dist/template/src/modules/seed/launch.ts +31 -3
  130. package/dist/template/tests/browser/blog-structure.spec.ts +69 -0
  131. package/dist/template/tests/core/agent-launch.test.ts +7 -2
  132. package/dist/template/tests/core/analytics-consent.test.ts +1 -1
  133. package/dist/template/tests/core/blog-playground.test.ts +106 -0
  134. package/dist/template/tests/core/blog-structure-comments.test.ts +166 -0
  135. package/dist/template/tests/core/client-readiness-security.test.ts +3 -1
  136. package/dist/template/tests/core/csp.test.ts +1 -1
  137. package/dist/template/tests/core/deploy-recipe.test.ts +54 -4
  138. package/dist/template/tests/core/internal-services.test.ts +4 -0
  139. package/dist/template/tests/core/legacy-redirect-proxy.test.ts +59 -0
  140. package/dist/template/tests/core/linux-install.test.ts +169 -0
  141. package/dist/template/tests/core/local-storage-mode.test.ts +29 -0
  142. package/dist/template/tests/core/locale-routing.test.ts +1 -1
  143. package/dist/template/tests/core/playground-cache.test.ts +1 -1
  144. package/dist/template/tests/core/playground.test.ts +3 -3
  145. package/dist/template/tests/core/preview-assistant-call.test.ts +88 -0
  146. package/dist/template/tests/core/private-preview-webhooks.test.ts +1 -1
  147. package/dist/template/tests/core/private-preview.test.ts +1 -1
  148. package/dist/template/tests/core/proxy-locale.test.ts +1 -1
  149. package/dist/template/tests/core/sdk-schema.test.ts +20 -0
  150. package/dist/template/tests/core/seo.test.ts +1 -1
  151. package/dist/template/tests/core/site-chat-client.test.ts +50 -0
  152. package/dist/template/tests/core/storage.test.ts +38 -2
  153. package/dist/template/tests/core/wordpress-import-flow.test.ts +81 -18
  154. package/dist/template/tests/core/wordpress-import.test.ts +25 -12
  155. package/dist/template/tests/core/wordpress-migration-verification.test.ts +37 -0
  156. package/dist/template/tests/modules/preview-assistant.test.ts +164 -0
  157. package/dist/template-manifest.json +490 -175
  158. package/package.json +1 -1
@@ -1,51 +1,271 @@
1
1
  // Copyright (C) 2026 Tony Aly
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // C2.26: posts are ordinary CMS pages; discovery shares their publish vetoes.
4
- import { and, eq, inArray } from "drizzle-orm";
4
+ // C2.27/C2.28: a post is a page under `blog/`, or any page marked a post (an
5
+ // imported WordPress post keeps its own address). The listing filters by
6
+ // category (with its subcategories), tag and author, and shows each post's
7
+ // byline, date and categories.
8
+ import { and, asc, eq, inArray, isNull } from "drizzle-orm";
5
9
  import { pages } from "./schema";
10
+ import { blogAuthors, blogPostTerms, blogPosts, blogTerms } from "./blog-schema";
6
11
  import { z } from "zod";
7
12
  import { defineService } from "@/core/service";
8
13
  import { defineBlock, firstQueryValue } from "./blocks/types";
9
14
 
15
+ const filterValue = z.string().trim().max(200).regex(/^[a-z0-9-]+$|^[0-9a-f-]{36}$/).optional();
16
+
17
+ const link = z.object({ name: z.string(), path: z.string() });
18
+
10
19
  export const listBlogPosts = defineService({
11
20
  name: "cms.listBlogPosts",
12
- summary: "Published blog posts in one locale, newest first, without private bodies.",
21
+ summary:
22
+ "Published blog posts in one locale, newest first, without private bodies. Filter by category (including subcategories), tag or author slug.",
13
23
  kind: "query",
14
24
  permission: "public",
15
- input: z.object({ locale: z.string().default("en"), prefix: z.string().regex(/^[a-z0-9][a-z0-9/-]*$/).default("blog"), page: z.number().int().min(1).max(10000).default(1), limit: z.number().int().min(1).max(50).default(12) }),
16
- output: z.object({ total: z.number().int(), page: z.number().int(), pages: z.number().int(), posts: z.array(z.object({ slug: z.string(), title: z.string(), description: z.string().nullable(), updatedAt: z.date() })) }),
25
+ input: z.object({
26
+ locale: z.string().default("en"),
27
+ prefix: z.string().regex(/^[a-z0-9][a-z0-9/-]*$/).default("blog"),
28
+ page: z.number().int().min(1).max(10000).default(1),
29
+ limit: z.number().int().min(1).max(50).default(12),
30
+ category: filterValue,
31
+ tag: filterValue,
32
+ author: filterValue,
33
+ date: z.string().regex(/^\d{4}(?:-\d{2}){0,2}$/).optional(),
34
+ }),
35
+ output: z.object({
36
+ total: z.number().int(),
37
+ page: z.number().int(),
38
+ pages: z.number().int(),
39
+ posts: z.array(
40
+ z.object({
41
+ slug: z.string(),
42
+ title: z.string(),
43
+ description: z.string().nullable(),
44
+ updatedAt: z.date(),
45
+ author: link.nullable(),
46
+ categories: z.array(link),
47
+ }),
48
+ ),
49
+ }),
17
50
  handler: async (input, ctx) => {
18
51
  const { publishedPaths, resolvePage } = await import("./service");
52
+ const { isPublicPage, postIdsMatching } = await import("./blog-service");
19
53
  const all = await ctx.call(publishedPaths, { locale: input.locale });
20
- const paths = [...new Set(all.map(p => p.slug.startsWith(`${input.locale}/`) ? p.slug.slice(input.locale.length+1) : p.slug).filter(slug => slug.startsWith(`${input.prefix}/`)))];
21
- const metadata = paths.length ? await ctx.tx.select({slug:pages.slug,publishedAt:pages.publishedAt}).from(pages).where(and(inArray(pages.slug,paths),eq(pages.status,"published"))) : [];
22
- metadata.sort((a,b)=>(b.publishedAt?.getTime()??0)-(a.publishedAt?.getTime()??0)||a.slug.localeCompare(b.slug));
23
- const posts=[];
24
- for (const row of metadata.slice((input.page-1)*input.limit,input.page*input.limit)) {
25
- const page=await ctx.call(resolvePage,{slug:row.slug,locale:input.locale});
26
- if(!page)continue;
27
- const seo=page.seo as {title?:string;description?:string};
28
- posts.push({slug:row.slug,title:seo?.title??page.title,description:seo?.description??null,updatedAt:row.publishedAt??page.updatedAt});
54
+ const unprefixed = all.map((p) =>
55
+ p.slug.startsWith(`${input.locale}/`) ? p.slug.slice(input.locale.length + 1) : p.slug,
56
+ );
57
+ // Marked posts count wherever they live, but only on the default listing:
58
+ // a custom prefix ("news") means exactly the pages under it.
59
+ const marked =
60
+ input.prefix === "blog"
61
+ ? new Set(
62
+ (
63
+ await ctx.tx
64
+ .select({ slug: pages.slug })
65
+ .from(blogPosts)
66
+ .innerJoin(pages, eq(pages.id, blogPosts.pageId))
67
+ ).map((row) => row.slug),
68
+ )
69
+ : new Set<string>();
70
+ const paths = [...new Set(unprefixed.filter((slug) => slug.startsWith(`${input.prefix}/`) || marked.has(slug)))];
71
+ const matching = await postIdsMatching(ctx.tx, {
72
+ category: input.category,
73
+ tag: input.tag,
74
+ author: input.author,
75
+ });
76
+ let metadata = paths.length
77
+ ? await ctx.tx
78
+ .select({ id: pages.id, slug: pages.slug, publishedAt: pages.publishedAt })
79
+ .from(pages)
80
+ .where(and(inArray(pages.slug, paths), eq(pages.status, "published"), isNull(pages.trashedAt)))
81
+ : [];
82
+ if (matching !== null) metadata = metadata.filter((row) => matching.has(row.id));
83
+ const visible = [];
84
+ for (const row of metadata) if (await isPublicPage(ctx, row)) visible.push(row);
85
+ metadata = visible;
86
+ if (input.date) metadata = metadata.filter(row => row.publishedAt?.toISOString().startsWith(input.date!));
87
+ metadata.sort(
88
+ (a, b) => (b.publishedAt?.getTime() ?? 0) - (a.publishedAt?.getTime() ?? 0) || a.slug.localeCompare(b.slug),
89
+ );
90
+ const slice = metadata.slice((input.page - 1) * input.limit, input.page * input.limit);
91
+ const ids = slice.map((row) => row.id);
92
+ const authors = ids.length
93
+ ? await ctx.tx
94
+ .select({ pageId: blogPosts.pageId, name: blogAuthors.name, path: blogAuthors.path })
95
+ .from(blogPosts)
96
+ .innerJoin(blogAuthors, eq(blogAuthors.id, blogPosts.authorId))
97
+ .where(inArray(blogPosts.pageId, ids))
98
+ : [];
99
+ const categories = ids.length
100
+ ? await ctx.tx
101
+ .select({ pageId: blogPostTerms.pageId, name: blogTerms.name, path: blogTerms.path })
102
+ .from(blogPostTerms)
103
+ .innerJoin(blogTerms, eq(blogTerms.id, blogPostTerms.termId))
104
+ .where(and(inArray(blogPostTerms.pageId, ids), eq(blogTerms.taxonomy, "category")))
105
+ .orderBy(asc(blogPostTerms.position))
106
+ : [];
107
+ const posts = [];
108
+ for (const row of slice) {
109
+ const page = await ctx.call(resolvePage, { slug: row.slug, locale: input.locale });
110
+ if (!page) continue;
111
+ const seo = page.seo as { title?: string; description?: string };
112
+ const author = authors.find((one) => one.pageId === row.id);
113
+ posts.push({
114
+ slug: row.slug,
115
+ title: seo?.title ?? page.title,
116
+ description: seo?.description ?? null,
117
+ updatedAt: row.publishedAt ?? page.updatedAt,
118
+ author: author ? { name: author.name, path: author.path } : null,
119
+ categories: categories.filter((one) => one.pageId === row.id).map(({ name, path }) => ({ name, path })),
120
+ });
29
121
  }
30
- return {total:metadata.length,page:input.page,pages:Math.max(1,Math.ceil(metadata.length/input.limit)),posts};
122
+ return {
123
+ total: metadata.length,
124
+ page: input.page,
125
+ pages: Math.max(1, Math.ceil(metadata.length / input.limit)),
126
+ posts,
127
+ };
31
128
  },
32
129
  });
33
130
 
131
+ const blockFilter = z.string().trim().max(200).regex(/^[a-z0-9-]*$/).optional();
132
+
34
133
  export const blogIndex = defineBlock({
35
- type: "blogIndex", labelKey: "blog.title", contexts: ["page"],
36
- schema: z.object({ prefix: z.string().regex(/^[a-z0-9][a-z0-9/-]*$/).default("blog"), limit: z.number().int().min(1).max(50).default(12) }),
134
+ type: "blogIndex",
135
+ labelKey: "blog.title",
136
+ contexts: ["page"],
137
+ schema: z.object({
138
+ prefix: z.string().regex(/^[a-z0-9][a-z0-9/-]*$/).default("blog"),
139
+ limit: z.number().int().min(1).max(50).default(12),
140
+ /** Only posts in this category (and its subcategories), by slug. */
141
+ category: blockFilter,
142
+ date: z.string().regex(/^(?:\d{4}(?:-\d{2}){0,2})?$/).default(""),
143
+ /** Only posts with this tag, by slug. */
144
+ tag: blockFilter,
145
+ /** Only posts by this author, by slug. */
146
+ author: blockFilter,
147
+ /** Show the categories as links above the list. */
148
+ showCategories: z.boolean().default(false),
149
+ }),
37
150
  starter: () => ({ prefix: "blog", limit: 12 }),
38
- resolve: async (props, ctx) => listBlogPosts.call({ locale: ctx.locale, prefix: props.prefix, limit: props.limit, page: Math.min(10000, Math.max(1, Math.floor(Number(firstQueryValue(ctx.query?.page))) || 1)) }, { kind: "anonymous" }),
151
+ resolve: async (props, ctx) => {
152
+ const { publicBlogCategories } = await import("./blog-service");
153
+ const anonymous = { kind: "anonymous" } as const;
154
+ // A visitor can narrow an unfiltered listing (`?category=glazes`); a
155
+ // listing the owner already filtered stays what the owner set. Filtered
156
+ // views are noindexed and canonicalised by the page route (§5).
157
+ const asked = (key: string) => {
158
+ const value = firstQueryValue(ctx.query?.[key]);
159
+ return value && /^[a-z0-9-]{1,200}$/.test(value) ? value : undefined;
160
+ };
161
+ const [listing, categories] = await Promise.all([
162
+ listBlogPosts.call(
163
+ {
164
+ locale: ctx.locale,
165
+ prefix: props.prefix,
166
+ limit: props.limit,
167
+ page: Math.min(10000, Math.max(1, Math.floor(Number(firstQueryValue(ctx.query?.page))) || 1)),
168
+ category: props.category || asked("category"),
169
+ date: props.date || undefined,
170
+ tag: props.tag || asked("tag"),
171
+ author: props.author || asked("author"),
172
+ },
173
+ anonymous,
174
+ ),
175
+ props.showCategories ? publicBlogCategories.call({}, anonymous) : Promise.resolve([]),
176
+ ]);
177
+ return { ...listing, categories: categories.filter((term) => term.posts > 0) };
178
+ },
39
179
  render: ({ props, resolved, ctx }) => {
40
180
  if (!resolved) return null;
41
181
  const href = (path: string) => ctx.localizeHref?.(path) ?? path;
42
- return <section className="grid gap-8" aria-label={ctx.t("blog.title")}>
43
- {resolved.posts.length ? <div className="grid gap-6 md:grid-cols-2">{resolved.posts.map(post => <article key={post.slug} className="grid content-start gap-3 rounded-lg border border-rule bg-surface p-6"><h2 className="text-xl font-semibold"><a className="underline decoration-rule underline-offset-4" href={href(`/${post.slug}`)}>{post.title}</a></h2>{post.description ? <p className="text-ink-muted">{post.description}</p> : null}<time className="text-sm text-ink-muted" dateTime={post.updatedAt.toISOString()}>{new Intl.DateTimeFormat(ctx.locale, { dateStyle: "medium" }).format(post.updatedAt)}</time></article>)}</div> : <p className="text-ink-muted">{ctx.t("blog.empty")}</p>}
44
- {resolved.pages > 1 ? <nav className="flex items-center justify-between gap-4" aria-label={ctx.t("blog.pagination")}>
45
- {resolved.page > 1 ? <a className="underline" href={href(`/${props.prefix}?page=${resolved.page-1}`)}>{ctx.t("blog.previous")}</a> : <span />}
46
- <span>{ctx.t("blog.page", { page: resolved.page, pages: resolved.pages })}</span>
47
- {resolved.page < resolved.pages ? <a className="underline" href={href(`/${props.prefix}?page=${resolved.page+1}`)}>{ctx.t("blog.next")}</a> : <span />}
48
- </nav> : null}
49
- </section>;
182
+ const here = ctx.path || `/${props.prefix}`;
183
+ const pageHref = (page: number) => {
184
+ const params = new URLSearchParams();
185
+ for (const key of ["category", "tag", "author"]) {
186
+ const value = firstQueryValue(ctx.query?.[key]);
187
+ if (value) params.set(key, value);
188
+ }
189
+ if (page > 1) params.set("page", String(page));
190
+ const query = params.toString();
191
+ return href(query ? `${here}?${query}` : here);
192
+ };
193
+ return (
194
+ <section className="grid gap-8" aria-label={ctx.t("blog.title")}>
195
+ {resolved.categories.length ? (
196
+ <nav aria-label={ctx.t("blog.categories")}>
197
+ <ul className="flex list-none flex-wrap gap-2 p-0">
198
+ {resolved.categories.map((term) => (
199
+ <li key={term.path}>
200
+ <a
201
+ className="inline-flex rounded-full border border-rule px-3 py-1 text-sm text-ink underline-offset-4 hover:underline"
202
+ href={href(`/${term.path}`)}
203
+ >
204
+ {term.name}
205
+ </a>
206
+ </li>
207
+ ))}
208
+ </ul>
209
+ </nav>
210
+ ) : null}
211
+ {resolved.posts.length ? (
212
+ <div className="grid gap-6 md:grid-cols-2">
213
+ {resolved.posts.map((post) => (
214
+ <article key={post.slug} className="grid content-start gap-3 rounded-lg border border-rule bg-surface p-6">
215
+ {post.categories.length ? (
216
+ <p className="flex flex-wrap gap-x-3 text-xs font-semibold uppercase tracking-wide text-ink-muted">
217
+ {post.categories.map((category) => (
218
+ <a key={category.path} className="hover:underline" href={href(`/${category.path}`)}>
219
+ {category.name}
220
+ </a>
221
+ ))}
222
+ </p>
223
+ ) : null}
224
+ <h2 className="text-xl font-semibold">
225
+ <a className="underline decoration-rule underline-offset-4" href={href(`/${post.slug}`)}>
226
+ {post.title}
227
+ </a>
228
+ </h2>
229
+ {post.description ? <p className="text-ink-muted">{post.description}</p> : null}
230
+ <p className="flex flex-wrap gap-x-2 text-sm text-ink-muted">
231
+ {post.author ? (
232
+ <span>
233
+ {ctx.t("blog.by")}{" "}
234
+ <a className="underline underline-offset-4" href={href(`/${post.author.path}`)}>
235
+ {post.author.name}
236
+ </a>
237
+ </span>
238
+ ) : null}
239
+ <time dateTime={post.updatedAt.toISOString()}>
240
+ {new Intl.DateTimeFormat(ctx.locale, { dateStyle: "medium" }).format(post.updatedAt)}
241
+ </time>
242
+ </p>
243
+ </article>
244
+ ))}
245
+ </div>
246
+ ) : (
247
+ <p className="text-ink-muted">{ctx.t("blog.empty")}</p>
248
+ )}
249
+ {resolved.pages > 1 ? (
250
+ <nav className="flex items-center justify-between gap-4" aria-label={ctx.t("blog.pagination")}>
251
+ {resolved.page > 1 ? (
252
+ <a className="underline" rel="prev" href={pageHref(resolved.page - 1)}>
253
+ {ctx.t("blog.previous")}
254
+ </a>
255
+ ) : (
256
+ <span />
257
+ )}
258
+ <span>{ctx.t("blog.page", { page: resolved.page, pages: resolved.pages })}</span>
259
+ {resolved.page < resolved.pages ? (
260
+ <a className="underline" rel="next" href={pageHref(resolved.page + 1)}>
261
+ {ctx.t("blog.next")}
262
+ </a>
263
+ ) : (
264
+ <span />
265
+ )}
266
+ </nav>
267
+ ) : null}
268
+ </section>
269
+ );
50
270
  },
51
271
  });
@@ -59,6 +59,12 @@ export default defineModule({
59
59
  "cms.quoteRequested",
60
60
  "cms.siteChatStarted",
61
61
  "cms.tipIntended",
62
+ "cms.termCreated",
63
+ "cms.termUpdated",
64
+ "cms.termDeleted",
65
+ "cms.postMetaChanged",
66
+ "cms.readerCommentSubmitted",
67
+ "cms.readerCommentModerated",
62
68
  ],
63
69
  listens: {
64
70
  "settings.setupCompleted": "onSetupCompleted",
@@ -72,5 +78,5 @@ export default defineModule({
72
78
  // The public URLs this module puts in the sitemap (§5). The engine asks;
73
79
  // the module answers with a service name rather than a list, because the
74
80
  // list changes every time an owner publishes.
75
- seo: { sitemapSources: ["cms.publishedPaths"] },
81
+ seo: { sitemapSources: ["cms.publishedPaths", "cms.blogArchivePaths"] },
76
82
  });
@@ -25,3 +25,21 @@ export const publishedPage = cache((slug: string, locale: string) =>
25
25
  export const publishedSection = cache((key: string, locale: string) =>
26
26
  getSection.call({ key, locale }, ANONYMOUS),
27
27
  );
28
+
29
+ /** A blog category, tag or author archive at a path, once per request. */
30
+ export const blogArchiveAt = cache(async (path: string) => {
31
+ const { resolveBlogArchive } = await import("./blog-service");
32
+ return resolveBlogArchive.call({ path }, ANONYMOUS);
33
+ });
34
+
35
+ /** A published post's byline and terms, once per request. */
36
+ export const postMetaFor = cache(async (slug: string) => {
37
+ const { postMetaAt } = await import("./blog-service");
38
+ return postMetaAt.call({ slug }, ANONYMOUS);
39
+ });
40
+
41
+ /** The blog's archive settings, once per request. */
42
+ export const blogSettingsCached = cache(async () => {
43
+ const { getBlogSettings } = await import("./blog-service");
44
+ return getBlogSettings.call({}, ANONYMOUS);
45
+ });
@@ -1,6 +1,9 @@
1
1
  // Copyright (C) 2026 Tony Aly
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { listBlogPosts } from "./blog";
4
+ import blogServices from "./blog-service";
5
+ import { blogPosts } from "./blog-schema";
6
+ import blogCommentServices from "./blog-comments";
4
7
  // CMS services (MASTER.md §11, §32).
5
8
  //
6
9
  // The module's only entry points. The public route, the admin, the REST API
@@ -199,8 +202,15 @@ const lookupSlug = z
199
202
 
200
203
  const seo = z
201
204
  .object({
202
- title: z.string().max(60).optional(),
203
- description: z.string().max(155).optional(),
205
+ title: z.string().max(1000).optional(),
206
+ description: z.string().max(1000).optional(),
207
+ preserveTitle: z.boolean().optional(),
208
+ preserveDescription: z.boolean().optional(),
209
+ noindex: z.boolean().optional(),
210
+ nofollow: z.boolean().optional(),
211
+ canonical: z.string().max(2000).refine(value => /^\/(?!\/)/.test(value) || /^https?:\/\//.test(value), "use a site path or HTTP URL").optional(),
212
+ ogTitle: z.string().max(1000).optional(),
213
+ ogDescription: z.string().max(1000).optional(),
204
214
  ogImage: z.string().url().optional(),
205
215
  })
206
216
  .default({});
@@ -503,12 +513,15 @@ export const publishedPaths = defineService({
503
513
  .where(and(eq(pages.status, "published"), isNull(pages.trashedAt), visibleLocationPage))
504
514
  .orderBy(pages.slug);
505
515
 
516
+ const markedPosts = new Set((await ctx.tx.select({ pageId: blogPosts.pageId }).from(blogPosts)).map(post => post.pageId));
517
+
506
518
  // A sitemap advertises what may render. Registered vetoes re-derive that
507
519
  // from the owning ledger (C8.16), so a case study whose consent was
508
520
  // withdrawn leaves the sitemap with the page — even if the status flag
509
521
  // was put back by hand.
510
522
  const published: typeof candidates = [];
511
523
  for (const page of candidates) {
524
+ if ((page.seo as { noindex?: boolean } | null)?.noindex) continue;
512
525
  if ((await blockingVetoes(ctx.tx, { id: page.id, slug: page.slug })).length > 0) {
513
526
  continue;
514
527
  }
@@ -534,7 +547,7 @@ export const publishedPaths = defineService({
534
547
  title: fields.title ?? page.title,
535
548
  description: fields.description,
536
549
  imageUrl: fields.ogImage ?? null,
537
- kind: kindFromSlug(page.slug),
550
+ kind: markedPosts.has(page.id) ? "article" as const : kindFromSlug(page.slug),
538
551
  priority: priorityFromSlug(page.slug),
539
552
  updatedAt: page.updatedAt,
540
553
  };
@@ -1213,7 +1226,7 @@ export const publishPage = defineService({
1213
1226
  .set({
1214
1227
  status: input.published ? "published" : "draft",
1215
1228
  publishedAt: input.published
1216
- ? (input.publishedAt ? new Date(input.publishedAt) : sql`now()`)
1229
+ ? (input.publishedAt ? new Date(input.publishedAt) : before.publishedAt ?? sql`now()`)
1217
1230
  : null,
1218
1231
  ...(input.published
1219
1232
  ? {
@@ -1235,6 +1248,9 @@ export const publishPage = defineService({
1235
1248
  .where(eq(pages.id, input.id))
1236
1249
  .returning();
1237
1250
  if (!page) throw new ServiceError("not_found", `no page with id ${input.id}`);
1251
+ if (input.published && before.status === "published" && !input.publishedAt) {
1252
+ await ctx.tx.update(blogPosts).set({ sourceModifiedAt: sql`now()` }).where(eq(blogPosts.pageId, page.id));
1253
+ }
1238
1254
  ctx.setSubject("page", page.id);
1239
1255
  ctx.queueEvent(input.published ? "cms.pagePublished" : "cms.pageUnpublished", {
1240
1256
  pageId: page.id,
@@ -1873,6 +1889,8 @@ registerSearchSource({
1873
1889
 
1874
1890
  export default [
1875
1891
  listBlogPosts,
1892
+ ...blogServices,
1893
+ ...blogCommentServices,
1876
1894
  resolvePage,
1877
1895
  resolvePageForRender,
1878
1896
  getPage,
@@ -12,3 +12,5 @@ export {
12
12
  contentLayouts,
13
13
  helpCategories,
14
14
  } from "./schema";
15
+ export { blogSettings, blogAuthors, blogTerms, blogPosts, blogPostTerms } from "./blog-schema";
16
+ export { blogReaderComments } from "./blog-comments-schema";
@@ -38,6 +38,7 @@ import {
38
38
  import { FOOTER_KEY, HEADER_KEY, NAV_KEY } from "@/modules/cms/defaults";
39
39
  import type { BlockNode } from "@/modules/cms/blocks/types";
40
40
  import { createForm } from "@/modules/forms/service";
41
+ import { updateSettings as updateAssistantSettings } from "@/modules/assistant/service";
41
42
 
42
43
  // ── The spec ────────────────────────────────────────────────────────────────
43
44
 
@@ -73,7 +74,7 @@ export const launchSpecSchema = z
73
74
  * onboarding intake on /start and payment-step copy; a version 1 spec
74
75
  * installs exactly as it always did.
75
76
  */
76
- version: z.union([z.literal(1), z.literal(2)]),
77
+ version: z.union([z.literal(1), z.literal(2), z.literal(3)]),
77
78
  /** Who wrote the spec, for the audit trail: a planning tool or an agent. */
78
79
  generator: line(120),
79
80
  business: z
@@ -160,6 +161,14 @@ export const launchSpecSchema = z
160
161
  .optional(),
161
162
  /** Version 2: what the payment step says while payments run in test mode. */
162
163
  payments: z.object({ mode: z.literal("test"), note: line(300) }).strict().optional(),
164
+ /** Version 3 explicitly opts a PM-hosted preview into its managed assistant. */
165
+ assistant: z.object({
166
+ provider: z.literal("paradise"), enabled: z.boolean(),
167
+ dailyCapUsd: z.number().finite().min(0).max(10),
168
+ contentMode: z.literal("sfw"),
169
+ }).strict().optional(),
170
+ /** Owner-supplied facts only; absent hours must never be invented. */
171
+ hours: z.array(line(200)).max(14).optional(),
163
172
  })
164
173
  .strict()
165
174
  .superRefine((spec, ctx) => {
@@ -167,9 +176,11 @@ export const launchSpecSchema = z
167
176
  if (spec.version === 1 && v2.some(Boolean)) {
168
177
  ctx.addIssue({ code: "custom", message: "accounts, intake and payments need a version 2 spec" });
169
178
  }
170
- if (spec.version === 2 && !v2.every(Boolean)) {
179
+ if (spec.version >= 2 && !v2.every(Boolean)) {
171
180
  ctx.addIssue({ code: "custom", message: "a version 2 spec states accounts, intake and payments" });
172
181
  }
182
+ if (spec.version < 3 && (spec.assistant || spec.hours)) ctx.addIssue({ code: "custom", message: "assistant and hours require a version 3 spec" });
183
+ if (spec.version === 3 && !spec.assistant) ctx.addIssue({ code: "custom", message: "a version 3 spec explicitly states its assistant settings" });
173
184
  });
174
185
 
175
186
  export type LaunchSpec = z.output<typeof launchSpecSchema>;
@@ -255,6 +266,14 @@ export function launchPages(spec: LaunchSpec): LaunchPage[] {
255
266
  { id: "contact-form", type: "form", props: { formSlug: LAUNCH_FORMS.contact } },
256
267
  ];
257
268
  if (intro) contactBlocks.push(button("contact-call", `Request a ${intro.durationMin}-minute call`, "/intro-call", "quiet"));
269
+ if (spec.version === 3) {
270
+ if (spec.hours?.length) contactBlocks.push(body("contact-hours", paragraphs(spec.hours.join("\n"))));
271
+ if (spec.assistant?.enabled) contactBlocks.push(
272
+ h("contact-assistant", "Ask our AI assistant", 2),
273
+ body("contact-ai-disclosure", paragraphs("AI assistant. Family-friendly. A character's appearance is not an endorsement of this business.")),
274
+ { id: "contact-chat", type: "siteChat", props: {} },
275
+ );
276
+ }
258
277
 
259
278
  const callPages: LaunchPage[] = intro
260
279
  ? [
@@ -544,10 +563,19 @@ export const installLaunch = defineService({
544
563
  // C3.39: My Account shows only what this business does with its
545
564
  // customers. The member network and shop pages stay off unless the spec
546
565
  // asks for them; the owner can turn either back on in Settings.
547
- if (spec.version === 2 && spec.accounts?.enabled) {
566
+ if (spec.version >= 2 && spec.accounts?.enabled) {
548
567
  if (!spec.accounts.members) await ctx.callAsSystem(setModuleEnabled, { module: "members", enabled: false });
549
568
  if (!spec.accounts.shop) await ctx.callAsSystem(setModuleEnabled, { module: "catalog", enabled: false });
550
569
  }
570
+ if (spec.version === 3 && spec.assistant) {
571
+ await ctx.callAsSystem(setModuleEnabled, { module: "assistant", enabled: spec.assistant.enabled });
572
+ await ctx.callAsSystem(updateAssistantSettings, {
573
+ enabled: spec.assistant.enabled, provider: "paradise", model: "paradise-managed-assistant",
574
+ credentialRef: "PARADISEMODERN_API_KEY", maxOutputTokens: 600,
575
+ spendCapCents: Math.round(spec.assistant.dailyCapUsd * 100), spendPeriod: "day",
576
+ displayName: "AI assistant", contactFormPath: "/contact",
577
+ });
578
+ }
551
579
 
552
580
  await ctx.callAsSystem(completeSetup, {});
553
581
  ctx.queueEvent("launch.installed", { pages: installed.length, generator: spec.generator });
@@ -0,0 +1,69 @@
1
+ // Copyright (C) 2026 Tony Aly
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // C2.27–C2.29: real owner forms and moderated reader output, both themes.
4
+ import { test, expect } from "@playwright/test";
5
+ import AxeBuilder from "@axe-core/playwright";
6
+ import { THEME_COOKIE } from "@/core/design/theme";
7
+ import { seedC11Owner, useOwnerSession, C11_BASE_URL } from "./owner-session";
8
+ import type { Page } from "@playwright/test";
9
+
10
+ async function assertThemes(page: Page) {
11
+ for (const theme of ["light", "dark"]) {
12
+ await page.context().addCookies([{ name: THEME_COOKIE, value: theme, url: C11_BASE_URL }]);
13
+ await page.reload();
14
+ const result = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa"]).analyze();
15
+ expect(result.violations).toEqual([]);
16
+ }
17
+ }
18
+
19
+ test("an owner organizes a post, reviews a reader comment and keeps email private", async ({ page, context }) => {
20
+ test.setTimeout(240000);
21
+ await useOwnerSession(context, await seedC11Owner("Blog qualification"));
22
+ await page.goto("/admin/blog/authors");
23
+ await assertThemes(page);
24
+ await page.getByLabel("Name", { exact: true }).fill("A Guest Writer");
25
+ await page.getByLabel("Email (private)", { exact: true }).fill("writer-private@example.test");
26
+ await page.getByLabel("Biography", { exact: true }).fill("Writes from the studio.");
27
+ await page.getByRole("button", { name: "Save", exact: true }).click();
28
+ await expect(page.getByRole("status")).toBeVisible();
29
+ await page.goto("/admin/blog/categories");
30
+ await assertThemes(page);
31
+ await page.getByLabel("Name", { exact: true }).fill("Studio Journal");
32
+ await page.getByRole("button", { name: "Save", exact: true }).click();
33
+ await expect(page.getByRole("status")).toBeVisible();
34
+ await page.goto("/admin/blog");
35
+ await page.getByLabel("Title", { exact: true }).fill("A moderated studio story");
36
+ await page.getByLabel("Web address", { exact: true }).fill("moderated-studio-story");
37
+ await page.getByRole("button", { name: "Create draft post", exact: true }).click();
38
+ await expect(page).toHaveURL(/\/admin\/pages\/[a-f0-9-]+$/);
39
+ await page.getByLabel("Author", { exact: true }).selectOption({ label: "A Guest Writer" });
40
+ await page.getByLabel("Studio Journal", { exact: true }).check();
41
+ await page.getByRole("region", { name: "Blog post settings", exact: true }).getByRole("button", { name: "Save", exact: true }).click();
42
+ await page.getByRole("button", { name: "Publish", exact: true }).click();
43
+ await expect(page.getByText("Live", { exact: true })).toBeVisible();
44
+ await page.goto("/blog/moderated-studio-story");
45
+ await expect(page.getByRole("link", { name: "A Guest Writer", exact: true }).first()).toBeVisible();
46
+ expect(await page.content()).not.toContain("writer-private@example.test");
47
+ await page.getByLabel("Name", { exact: true }).fill("A Reader");
48
+ await page.getByLabel("Email (private)", { exact: true }).fill("reader-private@example.test");
49
+ await page.getByLabel("Comment", { exact: true }).fill("This reader comment waits for approval. <img src=x alt=unexpected>");
50
+ await page.getByRole("button", { name: "Submit for approval", exact: true }).click();
51
+ await expect(page.getByRole("status")).toHaveText("Your comment is awaiting moderation.");
52
+ await expect(page.getByText("This reader comment waits for approval. <img src=x alt=unexpected>", { exact: true })).toHaveCount(0);
53
+ await page.goto("/admin/blog/comments?status=pending");
54
+ await expect(page.getByText("This reader comment waits for approval. <img src=x alt=unexpected>", { exact: true })).toBeVisible();
55
+ await assertThemes(page);
56
+ await page.getByRole("combobox", { name: "Status", exact: true }).selectOption("approved");
57
+ await page.getByRole("button", { name: "Save", exact: true }).click();
58
+ await page.goto("/blog/moderated-studio-story");
59
+ await expect(page.getByText("This reader comment waits for approval. <img src=x alt=unexpected>", { exact: true })).toBeVisible();
60
+ expect(await page.content()).not.toContain("reader-private@example.test");
61
+ await expect(page.locator("#comments img")).toHaveCount(0);
62
+ await assertThemes(page);
63
+ await page.screenshot({ path: "test-results/blog-public-comments.png", fullPage: true });
64
+ const response = await page.request.get("/blog/moderated-studio-story/", { maxRedirects: 0 });
65
+ expect(response.status()).toBe(301);
66
+ expect(new URL(response.headers().location ?? "", C11_BASE_URL).href).toBe(`${C11_BASE_URL}/blog/moderated-studio-story`);
67
+ });
68
+
69
+ test.afterAll(async () => { const { closeDb } = await import("@/core/db"); await closeDb(); });
@@ -66,18 +66,23 @@ describe("Docker Compose launch preparation", () => {
66
66
  const secrets = ["BOOTSTRAP_SECRET", "SESSION_SECRET", "CREDENTIAL_KEY", "POSTGRES_PASSWORD"];
67
67
  for (const name of secrets) { expect(values[name]).toMatch(/^[a-f0-9]{64}$/); expect(JSON.stringify(result)).not.toContain(values[name]); }
68
68
  expect(new Set(secrets.map((name) => values[name])).size).toBe(4);
69
- expect(values).toMatchObject({ APP_URL: "https://shop.example.com", FREEHOLDER_DOMAIN: "shop.example.com", FREEHOLDER_STORAGE: "s3" });
69
+ // C3.44: media defaults to the recipe's volume, so nothing is missing.
70
+ expect(values).toMatchObject({ APP_URL: "https://shop.example.com", FREEHOLDER_DOMAIN: "shop.example.com", FREEHOLDER_STORAGE: "local" });
70
71
  expect(values.DATABASE_URL).toBeUndefined();
71
- expect(result.missing).toEqual(["S3_ENDPOINT", "S3_REGION", "S3_BUCKET", "S3_ACCESS_KEY_ID", "S3_SECRET_ACCESS_KEY"]);
72
+ expect(result.missing).toEqual([]);
73
+ expect(result.configurationReady).toBe(true);
72
74
  expect(result.composeFile).toBe("deploy/docker-selfhost/infra/compose.https.yml");
73
75
  expect(result.startCommand).toBe("docker compose --env-file deploy/docker-selfhost/.env -f deploy/docker-selfhost/infra/compose.https.yml up -d");
74
76
  expect((await stat(result.privateEnvironmentFile)).mode & 0o777).toBe(0o600);
75
77
  expect(result.privateClaimLinkFile).toBe(join(dir, ".freeholder-launch", "claim-link.txt"));
76
78
  expect((await readFile(result.privateClaimLinkFile, "utf8")).trim()).toBe(`https://shop.example.com/setup#claim=${values.BOOTSTRAP_SECRET}`);
77
79
 
80
+ const s3 = await prepareLaunch({ directory: dir, target: "docker-selfhost", url: "https://shop.example.com", environment: { FREEHOLDER_STORAGE: "s3" } });
81
+ expect(s3.missing).toEqual(["S3_ENDPOINT", "S3_REGION", "S3_BUCKET", "S3_ACCESS_KEY_ID", "S3_SECRET_ACCESS_KEY"]);
78
82
  const ready = await prepareLaunch({ directory: dir, target: "docker-selfhost", url: "https://shop.example.com", environment: { S3_ENDPOINT: "https://s3.example.test", S3_REGION: "r", S3_BUCKET: "b", S3_ACCESS_KEY_ID: "a", S3_SECRET_ACCESS_KEY: "s" } });
79
83
  expect(ready.configurationReady).toBe(true);
80
84
  const again = parseEnv(await readFile(ready.privateEnvironmentFile, "utf8"));
85
+ expect(again.FREEHOLDER_STORAGE).toBe("s3");
81
86
  for (const name of secrets) expect(again[name]).toBe(values[name]);
82
87
  });
83
88
 
@@ -24,7 +24,7 @@ import {
24
24
  import { setModuleConfig } from "@/core/settings/service";
25
25
  import { AnalyticsConsentControl } from "../../app/(public)/AnalyticsConsentControl";
26
26
  import { POST as chooseConsent } from "../../app/api/analytics/consent/route";
27
- import { proxy } from "../../proxy";
27
+ import { requestContextProxy as proxy } from "../../proxy";
28
28
  import { auditHtml } from "../../scripts/a11y-smoke.mjs";
29
29
  import {
30
30
  closeDb,