inlaycms 0.5.0 → 0.7.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 (71) hide show
  1. package/assets/admin/admin.css +1 -1
  2. package/assets/admin/admin.js +1 -1
  3. package/dist/adapters/admin/publish.js +2 -2
  4. package/dist/adapters/admin/screens/editor.js +4 -2
  5. package/dist/adapters/admin/screens/media.d.ts +4 -1
  6. package/dist/adapters/admin/screens/media.js +22 -2
  7. package/dist/adapters/admin/screens/redirects.js +3 -1
  8. package/dist/adapters/admin/screens/releases.js +8 -3
  9. package/dist/adapters/admin/views/data-table.js +1 -1
  10. package/dist/adapters/admin/views/layout.d.ts +1 -1
  11. package/dist/adapters/admin/views/layout.js +12 -2
  12. package/dist/adapters/cli/main.js +21 -3
  13. package/dist/adapters/mcp/agent-refs.d.ts +2 -1
  14. package/dist/adapters/mcp/agent-refs.js +4 -4
  15. package/dist/adapters/mcp/tools/publish.js +1 -1
  16. package/dist/adapters/mcp/tools/read.d.ts +1 -1
  17. package/dist/adapters/mcp/tools/read.js +46 -3
  18. package/dist/adapters/mcp/tools/write.js +77 -6
  19. package/dist/adapters/site/context.d.ts +4 -1
  20. package/dist/adapters/site/context.js +9 -7
  21. package/dist/adapters/site/head.d.ts +2 -0
  22. package/dist/adapters/site/head.js +6 -6
  23. package/dist/adapters/site/plugin.d.ts +2 -0
  24. package/dist/adapters/site/plugin.js +25 -8
  25. package/dist/adapters/site/preview.d.ts +2 -0
  26. package/dist/adapters/site/preview.js +10 -5
  27. package/dist/adapters/site/public.d.ts +9 -1
  28. package/dist/adapters/site/public.js +48 -30
  29. package/dist/adapters/site/render.js +7 -2
  30. package/dist/adapters/site/routes.js +4 -3
  31. package/dist/adapters/site/sitemap.d.ts +2 -1
  32. package/dist/adapters/site/sitemap.js +3 -3
  33. package/dist/core/content/find-text.d.ts +31 -0
  34. package/dist/core/content/find-text.js +124 -0
  35. package/dist/core/content/search.js +1 -14
  36. package/dist/core/content/text-match.d.ts +14 -0
  37. package/dist/core/content/text-match.js +99 -0
  38. package/dist/core/content/text-replace.d.ts +14 -0
  39. package/dist/core/content/text-replace.js +100 -0
  40. package/dist/core/core.d.ts +7 -0
  41. package/dist/core/core.js +2 -0
  42. package/dist/core/messages/en.d.ts +43 -4
  43. package/dist/core/messages/en.js +43 -4
  44. package/dist/core/registry/define.d.ts +5 -0
  45. package/dist/core/registry/define.js +1 -0
  46. package/dist/core/registry/render.d.ts +6 -1
  47. package/dist/core/release/manifest.d.ts +0 -5
  48. package/dist/core/release/manifest.js +0 -24
  49. package/dist/core/release/pack.js +4 -0
  50. package/dist/core/release/public-files.d.ts +14 -0
  51. package/dist/core/release/public-files.js +43 -0
  52. package/dist/core/release/read.d.ts +2 -2
  53. package/dist/core/release/read.js +11 -12
  54. package/dist/core/release/window.d.ts +13 -0
  55. package/dist/core/release/window.js +40 -0
  56. package/dist/core/report.d.ts +1 -1
  57. package/dist/core/richtext/runs.d.ts +12 -0
  58. package/dist/core/richtext/runs.js +31 -0
  59. package/dist/core/site/paths.d.ts +5 -0
  60. package/dist/core/site/paths.js +32 -0
  61. package/dist/core/site/resolve.js +17 -6
  62. package/dist/core/version.d.ts +6 -0
  63. package/dist/core/version.js +6 -0
  64. package/dist/host/activate.js +2 -1
  65. package/dist/host/app.d.ts +6 -0
  66. package/dist/host/app.js +3 -0
  67. package/dist/host/push.d.ts +5 -1
  68. package/dist/host/push.js +17 -5
  69. package/dist/host/worker.js +9 -3
  70. package/dist/site.d.ts +1 -1
  71. package/package.json +1 -1
@@ -7,7 +7,7 @@ import { InlayError } from '../../../core/errors.js';
7
7
  import { t } from '../../../core/messages/index.js';
8
8
  import { manifestSchema } from '../../../core/release/manifest.js';
9
9
  import { formatDiff, structuralDiff } from '../../../host/diff.js';
10
- import { currentManifest, pendingMigrations, PUSH_MAX_BYTES, RELEASE_NAME_MAX } from '../../../host/push.js';
10
+ import { currentManifest, packAgainWarning, pendingMigrations, PUSH_MAX_BYTES, RELEASE_NAME_MAX } from '../../../host/push.js';
11
11
  import { deleteRelease, getRelease, listReleases, releaseDir, storeRelease } from '../../../host/store.js';
12
12
  import { previewLink } from '../../site/preview.js';
13
13
  import { adminActor, forbidden, HTML, noticeOf, notFound } from '../context.js';
@@ -81,7 +81,11 @@ function releaseRoutes(scope, ctx, db, releasesDir) {
81
81
  label: t('admin.releases.name'),
82
82
  cell: (r) => (_jsx("a", { href: `/admin/releases/${encodeURIComponent(r.id)}`, class: "link font-medium", children: r.name })),
83
83
  },
84
- { key: 'state', label: t('admin.releases.state'), cell: (r) => _jsx(StateBadge, { state: r.state }) },
84
+ {
85
+ key: 'state',
86
+ label: t('admin.releases.state'),
87
+ cell: (r) => (_jsxs(_Fragment, { children: [_jsx(StateBadge, { state: r.state }), packAgainWarning(r) !== null && (_jsx(Badge, { tone: "warning", class: "ml-2", children: t('admin.releases.packAgainBadge') }))] })),
88
+ },
85
89
  { key: 'pushedBy', label: t('admin.releases.pushedBy'), cell: (r) => pushedBy(r, names) },
86
90
  { key: 'pushedAt', label: t('admin.releases.pushedAt'), cell: (r) => _jsx(Time, { iso: r.pushed_at, relative: true }) },
87
91
  { key: 'activatedAt', label: t('admin.releases.activatedAt'), cell: activated },
@@ -146,7 +150,8 @@ function releaseRoutes(scope, ctx, db, releasesDir) {
146
150
  // A release whose files are missing can't be activated: its page says so instead.
147
151
  const activatable = (row.state === 'staged' || row.state === 'previous') && manifest !== null;
148
152
  const fact = (label, value) => (_jsxs("div", { class: "flex flex-col gap-0.5 sm:flex-row sm:gap-4", children: [_jsx("dt", { class: "text-sm text-base-content/70 sm:w-56 sm:shrink-0", children: label }), _jsx("dd", { children: value })] }));
149
- const body = (_jsxs("div", { class: "flex flex-col gap-8", children: [error !== undefined && (_jsx(Alert, { kind: "error", id: "release-error", children: error })), _jsx(Section, { id: "facts", title: t('admin.releases.facts'), children: _jsxs("dl", { class: "flex flex-col gap-2", children: [fact(t('admin.releases.state'), _jsx(StateBadge, { state: row.state })), fact(t('admin.releases.pushedBy'), pushedBy(row, names)), fact(t('admin.releases.pushedAt'), _jsx(Time, { iso: row.pushed_at })), fact(t('admin.releases.activatedAt'), row.activated_at === null ? t('admin.releases.never') : _jsx(Time, { iso: row.activated_at })), fact(t('admin.releases.signedBy'), _jsx("code", { class: "font-mono text-sm break-all", children: row.signed_by })), fact(t('admin.releases.secrets'), row.secrets.length === 0 ? t('admin.releases.secretsNone') : _jsx("code", { class: "font-mono text-sm", children: row.secrets.join(', ') }))] }) }), row.state === 'deleted' && _jsx("p", { children: t('admin.releases.deletedNote') }), row.state !== 'deleted' && manifest === null && (_jsx(Alert, { kind: "warning", id: "files-missing", children: t('admin.releases.filesMissing') })), activatable && host === undefined && (_jsx(Alert, { kind: "info", id: "no-host", children: t('admin.releases.noHost') })), activatable && host !== undefined && (_jsxs(Section, { id: "activate", title: t('admin.releases.activate'), children: [_jsx("p", { id: "activate-hint", children: t('admin.releases.activateHint') }), _jsxs("div", { class: "flex flex-wrap gap-2", children: [_jsx("form", { method: "post", action: `/admin/releases/${encodeURIComponent(row.id)}/activate`, children: _jsx("button", { type: "submit", class: "btn btn-primary", "aria-describedby": "activate-hint", children: t('admin.releases.activate') }) }), row.state === 'staged' && (_jsxs("a", { href: previewLink(ctx, '/', { release: row.id }), target: "_blank", rel: "noopener", class: "btn", "data-release-preview": true, "aria-describedby": "preview-hint", children: [_jsx(Icon, { name: "eye" }), t('admin.releases.preview')] }))] }), row.state === 'staged' && (_jsx("p", { id: "preview-hint", class: "text-sm text-base-content/70", children: t('admin.releases.previewHint') }))] })), manifest !== null && row.state !== 'current' && (_jsx(Section, { id: "changes", title: t('admin.releases.changes'), children: await changes(row, manifest, status === 200) })), manifest !== null && (_jsx(Section, { id: "migrations", title: t('admin.releases.migrations'), children: manifest.migrations.length === 0 ? (_jsx("p", { children: t('admin.releases.migrationsNone') })) : (_jsx("ul", { class: "list-disc pl-6", children: manifest.migrations.map((name) => (_jsx("li", { children: _jsx("code", { class: "font-mono text-sm", children: name }) }))) })) })), row.state === 'current' && (_jsx(Section, { id: "hidden", title: t('admin.releases.hidden'), children: await hidden() })), row.state !== 'current' && row.state !== 'deleted' && (_jsxs(Section, { id: "delete", title: t('admin.releases.delete'), children: [_jsx("p", { id: "delete-hint", children: t('admin.releases.deleteHint') }), _jsx("form", { method: "post", action: `/admin/releases/${encodeURIComponent(row.id)}/delete`, children: _jsxs("button", { type: "submit", class: "btn btn-error btn-outline", "aria-describedby": "delete-hint", children: [_jsx(Icon, { name: "trash" }), t('admin.releases.delete')] }) })] }))] }));
153
+ const packAgain = packAgainWarning(row);
154
+ const body = (_jsxs("div", { class: "flex flex-col gap-8", children: [error !== undefined && (_jsx(Alert, { kind: "error", id: "release-error", children: error })), _jsx(Section, { id: "facts", title: t('admin.releases.facts'), children: _jsxs("dl", { class: "flex flex-col gap-2", children: [fact(t('admin.releases.state'), _jsx(StateBadge, { state: row.state })), fact(t('admin.releases.pushedBy'), pushedBy(row, names)), fact(t('admin.releases.pushedAt'), _jsx(Time, { iso: row.pushed_at })), fact(t('admin.releases.activatedAt'), row.activated_at === null ? t('admin.releases.never') : _jsx(Time, { iso: row.activated_at })), fact(t('admin.releases.signedBy'), _jsx("code", { class: "font-mono text-sm break-all", children: row.signed_by })), fact(t('admin.releases.secrets'), row.secrets.length === 0 ? t('admin.releases.secretsNone') : _jsx("code", { class: "font-mono text-sm", children: row.secrets.join(', ') }))] }) }), packAgain !== null && (_jsx(Alert, { kind: "warning", id: "pack-again", children: packAgain })), row.state === 'deleted' && _jsx("p", { children: t('admin.releases.deletedNote') }), row.state !== 'deleted' && manifest === null && (_jsx(Alert, { kind: "warning", id: "files-missing", children: t('admin.releases.filesMissing') })), activatable && host === undefined && (_jsx(Alert, { kind: "info", id: "no-host", children: t('admin.releases.noHost') })), activatable && host !== undefined && (_jsxs(Section, { id: "activate", title: t('admin.releases.activate'), children: [_jsx("p", { id: "activate-hint", children: t('admin.releases.activateHint') }), _jsxs("div", { class: "flex flex-wrap gap-2", children: [_jsx("form", { method: "post", action: `/admin/releases/${encodeURIComponent(row.id)}/activate`, children: _jsx("button", { type: "submit", class: "btn btn-primary", "aria-describedby": "activate-hint", children: t('admin.releases.activate') }) }), row.state === 'staged' && (_jsxs("a", { href: previewLink(ctx, '/', { release: row.id }), target: "_blank", rel: "noopener", class: "btn", "data-release-preview": true, "aria-describedby": "preview-hint", children: [_jsx(Icon, { name: "eye" }), t('admin.releases.preview')] }))] }), row.state === 'staged' && (_jsx("p", { id: "preview-hint", class: "text-sm text-base-content/70", children: t('admin.releases.previewHint') }))] })), manifest !== null && row.state !== 'current' && (_jsx(Section, { id: "changes", title: t('admin.releases.changes'), children: await changes(row, manifest, status === 200) })), manifest !== null && (_jsx(Section, { id: "migrations", title: t('admin.releases.migrations'), children: manifest.migrations.length === 0 ? (_jsx("p", { children: t('admin.releases.migrationsNone') })) : (_jsx("ul", { class: "list-disc pl-6", children: manifest.migrations.map((name) => (_jsx("li", { children: _jsx("code", { class: "font-mono text-sm", children: name }) }))) })) })), row.state === 'current' && (_jsx(Section, { id: "hidden", title: t('admin.releases.hidden'), children: await hidden() })), row.state !== 'current' && row.state !== 'deleted' && (_jsxs(Section, { id: "delete", title: t('admin.releases.delete'), children: [_jsx("p", { id: "delete-hint", children: t('admin.releases.deleteHint') }), _jsx("form", { method: "post", action: `/admin/releases/${encodeURIComponent(row.id)}/delete`, children: _jsxs("button", { type: "submit", class: "btn btn-error btn-outline", "aria-describedby": "delete-hint", children: [_jsx(Icon, { name: "trash" }), t('admin.releases.delete')] }) })] }))] }));
150
155
  const page = await adminPage(ctx, {
151
156
  title: row.name,
152
157
  actor,
@@ -81,7 +81,7 @@ export function DataTable(props) {
81
81
  const filters = (query !== undefined || hasToolbar) && (_jsxs("form", { id: filtersId, method: "get", action: base, ...swapTo(id, base), "hx-trigger": "submit, input changed delay:300ms from:find input[name=q], change from:find select", class: hasToolbar ? 'flex min-h-12 flex-wrap items-center gap-2 border-b border-base-300 px-3 py-2' : 'contents', children: [hidden.map(([name, value]) => (_jsx("input", { type: "hidden", name: name, value: value }))), search !== undefined && (_jsxs(_Fragment, { children: [_jsx("label", { for: `${id}-q`, class: "sr-only", children: search.label }), _jsxs("div", { class: "input input-sm w-full sm:w-64", children: [_jsx(Icon, { name: "search", class: "opacity-50" }), _jsx("input", { id: `${id}-q`, name: "q", type: "search", value: query?.q ?? '', placeholder: search.label, autocomplete: "off" })] })] })), tabs !== undefined && query !== undefined && (_jsx("div", { class: "tabs tabs-box tabs-sm", role: "group", "aria-label": t('admin.table.status'), children: tabs.map((tab) => {
82
82
  const link = href({ status: tab.key });
83
83
  const active = tab.key === query.status;
84
- return (_jsxs("a", { href: link, ...swapTo(id, link), class: active ? 'tab tab-active gap-1.5' : 'tab gap-1.5', "aria-current": active ? 'true' : undefined, children: [tab.label, _jsx("span", { class: "text-xs text-base-content/60 tabular-nums", children: tab.count })] }));
84
+ return (_jsx("a", { href: link, ...swapTo(id, link), class: active ? 'tab tab-active' : 'tab', "aria-current": active ? 'true' : undefined, children: _jsxs("span", { children: [tab.label, _jsx("span", { class: "ml-1.5 text-xs text-base-content/60 tabular-nums", children: tab.count })] }) }));
85
85
  }) })), toolbarEnd !== undefined && _jsx("div", { class: "ml-auto flex flex-wrap items-center gap-2", children: toolbarEnd }), _jsx("button", { type: "submit", class: "btn btn-sm sr-only focus:not-sr-only", children: t('admin.table.apply') })] }));
86
86
  const bulkBar = bulk !== undefined && (_jsx("div", { "data-bulk-bar": true, "data-selected-template": t('admin.table.selected', { count: '{count}' }), class: "flex min-h-12 items-center border-b border-base-300 bg-primary/5 px-3 py-2", children: _jsxs("form", { id: bulkId, method: "get", class: "flex w-full flex-wrap items-center gap-2", children: [_jsx("span", { "data-selected-count": true, class: "text-sm font-medium tabular-nums" }), bulk.actions, _jsxs("button", { type: "button", "data-clear-selection": true, class: "btn btn-ghost btn-xs ml-auto", children: [_jsx(Icon, { name: "x" }), t('admin.table.clear')] })] }) }));
87
87
  const head = (_jsxs("tr", { children: [bulk !== undefined && (_jsx("th", { scope: "col", class: "w-10", children: _jsx("input", { type: "checkbox", class: "checkbox checkbox-xs", "data-select-all": true, form: bulkId, "aria-label": t('admin.table.selectAll') }) })), columns.map((col) => {
@@ -1,6 +1,6 @@
1
1
  import type { Actor } from '../../../core/types.js';
2
2
  import { type Renderable } from '../../../jsx/html.js';
3
- import type { AdminContext, Section } from '../context.js';
3
+ import { type AdminContext, type Section } from '../context.js';
4
4
  /** Up to two initials from `name` (its first and last words), for the small circle next to a person. */
5
5
  export declare function initials(name: string): string;
6
6
  /**
@@ -1,6 +1,7 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "inlaycms/jsx-runtime";
2
2
  import { t } from '../../../core/messages/index.js';
3
3
  import { raw, renderToString } from '../../../jsx/html.js';
4
+ import { NOTICES } from '../context.js';
4
5
  import { Icon } from './icons.js';
5
6
  import { Badge, badgeClass } from './status.js';
6
7
  const HTMX_CONFIG = JSON.stringify({
@@ -16,6 +17,15 @@ function Head({ ctx, title, scripts }) {
16
17
  const { theme, name } = ctx.branding;
17
18
  return (_jsxs("head", { children: [_jsx("meta", { charset: "utf-8" }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }), _jsx("meta", { name: "robots", content: "noindex" }), _jsx("meta", { name: "htmx-config", content: HTMX_CONFIG }), _jsx("title", { children: t('admin.pageTitle', { title, name }) }), _jsx("link", { rel: "stylesheet", href: ctx.assets.url('admin.css') }), theme.css !== '' && _jsx("style", { children: raw(theme.css) }), scripts.map((script) => (_jsx("script", { type: "module", src: ctx.assets.url(script) })))] }));
18
19
  }
20
+ /**
21
+ * What a redirect asked to say (`?notice=`), as a toast over the page rather than a bar in it, so the page doesn't
22
+ * move. `client/admin/notice.ts` hides it after a while, puts the scroll back where the form was sent from and takes
23
+ * `data-notice-query` out of the address, so reloading doesn't show it again.
24
+ */
25
+ function Notice({ text }) {
26
+ const query = ['notice', ...new Set(Object.values(NOTICES).flatMap((n) => n.params ?? []))];
27
+ return (_jsxs("div", { id: "admin-notice", "data-notice-query": query.join(' '), class: "alert alert-success fixed left-4 right-4 top-18 z-50 shadow-lg transition-opacity duration-300 motion-reduce:transition-none sm:left-auto sm:max-w-sm", children: [_jsx(Icon, { name: "check-circle" }), _jsx("span", { role: "status", children: text }), _jsxs("button", { type: "button", class: "btn btn-ghost btn-xs btn-square", "data-notice-dismiss": true, children: [_jsx(Icon, { name: "x" }), _jsx("span", { class: "sr-only", children: t('admin.notice.dismiss') })] })] }));
28
+ }
19
29
  function SkipLink() {
20
30
  return (_jsx("a", { href: "#main", class: "sr-only focus:not-sr-only focus:absolute focus:left-4 focus:top-4 focus:z-50 btn btn-primary", children: t('admin.skipLink') }));
21
31
  }
@@ -108,7 +118,7 @@ function PrivateBadge({ owner }) {
108
118
  }
109
119
  /** The bar along the top: the menu button on small screens, the search box, the private-site badge, View site and Publish. */
110
120
  function TopBar({ pending, locked, owner }) {
111
- return (_jsxs("div", { class: "sticky top-0 z-30 flex h-14 items-center gap-3 border-b border-base-300 bg-base-100 px-4 lg:px-6", children: [_jsxs("label", { for: "admin-nav-toggle", class: "btn btn-ghost btn-sm btn-square lg:hidden", children: [_jsx(Icon, { name: "menu" }), _jsx("span", { class: "sr-only", children: t('admin.nav.open') })] }), _jsxs("form", { role: "search", action: "/admin/search", method: "get", class: "relative w-full max-w-lg", children: [_jsxs("label", { for: "global-search", class: "input input-sm w-full border-transparent bg-base-200 focus-within:border-base-300 focus-within:bg-base-100", children: [_jsx(Icon, { name: "search", class: "opacity-60" }), _jsx("span", { class: "sr-only", children: t('admin.search.label') }), _jsx("input", { id: "global-search", name: "q", type: "search", class: "grow", placeholder: t('admin.search.placeholder'), autocomplete: "off", role: "combobox", "aria-expanded": "false", "aria-controls": "global-search-results", "aria-autocomplete": "list", "hx-get": "/admin/search", "hx-trigger": "input changed delay:250ms, focus", "hx-target": "#global-search-results", "hx-select": "#global-search-results", "hx-swap": "outerHTML" }), _jsx("kbd", { "aria-hidden": "true", class: "kbd kbd-sm", children: "/" })] }), _jsx("button", { type: "submit", class: "btn btn-sm sr-only focus:not-sr-only focus:absolute focus:right-0 focus:top-0", children: t('admin.search.submit') }), _jsx("div", { id: "global-search-results" })] }), _jsxs("div", { class: "ml-auto flex items-center gap-2", children: [locked && _jsx(PrivateBadge, { owner: owner }), _jsxs("a", { href: "/", class: "btn btn-ghost btn-sm hidden sm:inline-flex", children: [_jsx(Icon, { name: "external" }), t('admin.topbar.viewSite')] }), _jsxs("a", { id: "topbar-publish", href: "/admin/publish", "data-publish-dialog": true, "data-refresh": true, class: "btn btn-primary btn-sm", children: [_jsx(Icon, { name: "send" }), t('admin.topbar.publish'), pending > 0 && (_jsx("span", { "aria-hidden": "true", class: "badge badge-sm border-0 bg-primary-content/20 text-primary-content tabular-nums", children: pending })), pending > 0 && _jsx("span", { class: "sr-only", children: t('admin.topbar.pending', { count: pending }) })] })] })] }));
121
+ return (_jsxs("div", { id: "admin-top", class: "sticky top-0 z-30 flex h-14 items-center gap-3 border-b border-base-300 bg-base-100 px-4 lg:px-6", children: [_jsxs("label", { for: "admin-nav-toggle", class: "btn btn-ghost btn-sm btn-square lg:hidden", children: [_jsx(Icon, { name: "menu" }), _jsx("span", { class: "sr-only", children: t('admin.nav.open') })] }), _jsxs("form", { role: "search", action: "/admin/search", method: "get", class: "relative w-full max-w-lg", children: [_jsxs("label", { for: "global-search", class: "input input-sm w-full border-transparent bg-base-200 focus-within:border-base-300 focus-within:bg-base-100", children: [_jsx(Icon, { name: "search", class: "opacity-60" }), _jsx("span", { class: "sr-only", children: t('admin.search.label') }), _jsx("input", { id: "global-search", name: "q", type: "search", class: "grow", placeholder: t('admin.search.placeholder'), autocomplete: "off", role: "combobox", "aria-expanded": "false", "aria-controls": "global-search-results", "aria-autocomplete": "list", "hx-get": "/admin/search", "hx-trigger": "input changed delay:250ms, focus", "hx-target": "#global-search-results", "hx-select": "#global-search-results", "hx-swap": "outerHTML" }), _jsx("kbd", { "aria-hidden": "true", class: "kbd kbd-sm", children: "/" })] }), _jsx("button", { type: "submit", class: "btn btn-sm sr-only focus:not-sr-only focus:absolute focus:right-0 focus:top-0", children: t('admin.search.submit') }), _jsx("div", { id: "global-search-results" })] }), _jsxs("div", { class: "ml-auto flex items-center gap-2", children: [locked && _jsx(PrivateBadge, { owner: owner }), _jsxs("a", { href: "/", class: "btn btn-ghost btn-sm hidden sm:inline-flex", children: [_jsx(Icon, { name: "external" }), t('admin.topbar.viewSite')] }), _jsxs("a", { id: "topbar-publish", href: "/admin/publish", "data-publish-dialog": true, "data-refresh": true, class: "btn btn-primary btn-sm", children: [_jsx(Icon, { name: "send" }), t('admin.topbar.publish'), pending > 0 && (_jsx("span", { "aria-hidden": "true", class: "badge badge-sm border-0 bg-primary-content/20 text-primary-content tabular-nums", children: pending })), pending > 0 && _jsx("span", { class: "sr-only", children: t('admin.topbar.pending', { count: pending }) })] })] })] }));
112
122
  }
113
123
  function Breadcrumbs({ items, compact }) {
114
124
  if (items.length === 0)
@@ -145,7 +155,7 @@ export async function adminPage(ctx, opts, body) {
145
155
  const workspace = opts.layout === 'workspace';
146
156
  const page = (_jsxs("html", { lang: "en", "data-theme": ctx.branding.theme.name, children: [_jsx(Head, { ctx: ctx, title: opts.title, scripts: scripts }), _jsxs("body", { class: "min-h-screen bg-base-200 text-base-content", children: [_jsx(SkipLink, {}), _jsxs("div", { class: "drawer lg:drawer-open", children: [_jsx("input", { id: "admin-nav-toggle", type: "checkbox", class: "drawer-toggle lg:hidden", "aria-label": t('admin.nav.open') }), _jsxs("div", { class: workspace ? 'drawer-content flex h-screen flex-col' : 'drawer-content flex min-h-screen flex-col', children: [_jsx(TopBar, { pending: pending.length, locked: lock.enabled, owner: opts.actor.role === 'owner' }), _jsxs("main", { id: "main", tabindex: "-1", class: workspace ? 'flex min-h-0 w-full flex-1 flex-col focus:outline-none' : 'w-full flex-1 px-4 py-4 focus:outline-none lg:px-6 lg:py-5', children: [_jsxs("div", { class: workspace
147
157
  ? 'flex shrink-0 flex-wrap items-center gap-x-4 gap-y-2 border-b border-base-300 bg-base-100 px-4 py-2.5'
148
- : 'mb-5 flex flex-wrap items-end justify-between gap-4', children: [_jsxs("div", { class: "min-w-0", children: [_jsx(Breadcrumbs, { items: opts.breadcrumbs ?? [], compact: workspace }), _jsx("h1", { class: workspace ? 'truncate text-lg font-semibold tracking-tight' : 'text-2xl font-semibold tracking-tight', children: opts.title }), opts.description !== undefined && _jsx("p", { class: "text-sm text-base-content/70", children: opts.description })] }), opts.actions !== undefined && (_jsx("div", { class: workspace ? 'flex min-w-0 flex-1 flex-wrap items-center gap-2' : 'flex flex-wrap items-center gap-2', children: opts.actions }))] }), ctx.readOnly && (_jsx("div", { role: "status", class: workspace ? `alert alert-info ${BAR}` : 'alert alert-info mb-4', children: ctx.release ? t('admin.readOnly', { name: ctx.release.name }) : t('admin.readOnly.unnamed') })), _jsx("noscript", { children: _jsx("p", { class: workspace ? `alert alert-warning ${BAR}` : 'alert alert-warning mb-4', children: t('admin.noscript') }) }), notice !== undefined && (_jsx("div", { role: "status", class: workspace ? `alert alert-success ${BAR}` : 'alert alert-success mb-4', children: notice })), workspace ? _jsx("div", { class: "flex min-h-0 flex-1 flex-col", children: body }) : body] })] }), _jsxs("div", { class: "drawer-side z-40", children: [_jsx("label", { for: "admin-nav-toggle", "aria-label": t('admin.nav.close'), class: "drawer-overlay", children: _jsx("span", { class: "sr-only", children: t('admin.nav.close') }) }), _jsxs("aside", { class: "flex min-h-full w-64 flex-col border-r border-base-300 bg-base-100", children: [_jsx("header", { class: "flex h-14 shrink-0 items-center border-b border-base-300 px-4", children: _jsx("a", { href: "/admin", class: "inline-flex min-w-0 items-center", children: _jsx(Brand, { ctx: ctx, size: "h-7 max-w-40" }) }) }), _jsx(Nav, { ctx: ctx, actor: opts.actor, section: opts.section, counts: counts })] })] })] }), _jsx(PickerDialog, {}), _jsx(PublishDialog, {})] })] }));
158
+ : 'mb-5 flex flex-wrap items-end justify-between gap-4', children: [_jsxs("div", { class: "min-w-0", children: [_jsx(Breadcrumbs, { items: opts.breadcrumbs ?? [], compact: workspace }), _jsx("h1", { class: workspace ? 'truncate text-lg font-semibold tracking-tight' : 'text-2xl font-semibold tracking-tight', children: opts.title }), opts.description !== undefined && _jsx("p", { class: "text-sm text-base-content/70", children: opts.description })] }), opts.actions !== undefined && (_jsx("div", { class: workspace ? 'flex min-w-0 flex-1 flex-wrap items-center gap-2' : 'flex flex-wrap items-center gap-2', children: opts.actions }))] }), ctx.readOnly && (_jsx("div", { role: "status", class: workspace ? `alert alert-info ${BAR}` : 'alert alert-info mb-4', children: ctx.release ? t('admin.readOnly', { name: ctx.release.name }) : t('admin.readOnly.unnamed') })), _jsx("noscript", { children: _jsx("p", { class: workspace ? `alert alert-warning ${BAR}` : 'alert alert-warning mb-4', children: t('admin.noscript') }) }), workspace ? _jsx("div", { class: "flex min-h-0 flex-1 flex-col", children: body }) : body] })] }), _jsxs("div", { class: "drawer-side z-40", children: [_jsx("label", { for: "admin-nav-toggle", "aria-label": t('admin.nav.close'), class: "drawer-overlay", children: _jsx("span", { class: "sr-only", children: t('admin.nav.close') }) }), _jsxs("aside", { class: "flex min-h-full w-64 flex-col border-r border-base-300 bg-base-100 lg:w-full lg:border-r-0", children: [_jsx("header", { class: "flex h-14 shrink-0 items-center border-b border-base-300 px-4", children: _jsx("a", { href: "/admin", class: "inline-flex min-w-0 items-center", children: _jsx(Brand, { ctx: ctx, size: "h-7 max-w-40" }) }) }), _jsx(Nav, { ctx: ctx, actor: opts.actor, section: opts.section, counts: counts })] })] })] }), _jsx(PickerDialog, {}), _jsx(PublishDialog, {}), notice !== undefined && _jsx(Notice, { text: notice })] })] }));
149
159
  return `<!doctype html>${await renderToString(page)}`;
150
160
  }
151
161
  /** A page for someone who isn't signed in (setup, login, consent, uploads): a centered card with the brand, no navigation. */
@@ -23,6 +23,7 @@ import { t } from '../../core/messages/index.js';
23
23
  import { formatReport } from '../../core/report.js';
24
24
  import { buildRegistry } from '../../core/registry/registry.js';
25
25
  import { generateKeyPair, publicKeyOf } from '../../core/release/keys.js';
26
+ import { publicClashes, publicClashMessage } from '../../core/release/public-files.js';
26
27
  import { packRelease, releaseName } from '../../core/release/pack.js';
27
28
  import { loadRelease } from '../../core/release/read.js';
28
29
  import { loadConfig } from '../../config.js';
@@ -31,6 +32,7 @@ import { EMPTY_SITE } from '../../host/app.js';
31
32
  import { ensureDataDir, hostPaths, readDataDir, readHostConfig, readTrustedKeys } from '../../host/config.js';
32
33
  import { dev } from '../../host/dev.js';
33
34
  import { formatDiff } from '../../host/diff.js';
35
+ import { releaseInfo } from '../../host/push.js';
34
36
  import { serve } from '../../host/serve.js';
35
37
  import { currentRelease, getRelease, listReleases, releaseDir, storeRelease } from '../../host/store.js';
36
38
  import { activateRemote, checkTransport, isRemote, listRemoteReleases, pushFile } from './remote.js';
@@ -355,11 +357,18 @@ async function releases(io, flags) {
355
357
  await db.destroy();
356
358
  }
357
359
  }
358
- printReleases(io, rows, flags.json);
360
+ printReleases(io, rows.map(releaseInfo), flags.json);
359
361
  return 0;
360
362
  }
361
363
  function printReleases(io, rows, json) {
362
- const listed = rows.map((r) => ({ id: r.id, name: r.name, state: r.state, pushedAt: r.pushed_at, activatedAt: r.activated_at }));
364
+ const listed = rows.map((r) => ({
365
+ id: r.id,
366
+ name: r.name,
367
+ state: r.state,
368
+ pushedAt: r.pushed_at,
369
+ activatedAt: r.activated_at,
370
+ ...(r.warning !== undefined && { warning: r.warning }),
371
+ }));
363
372
  if (json)
364
373
  return io.out(JSON.stringify(listed, null, 2));
365
374
  if (listed.length === 0)
@@ -372,6 +381,8 @@ function printReleases(io, rows, json) {
372
381
  pushedAt: r.pushedAt,
373
382
  activatedAt: r.activatedAt ?? t('cli.releaseNeverLive'),
374
383
  }));
384
+ if (r.warning !== undefined)
385
+ io.out(t('cli.releaseWarning', { warning: r.warning }));
375
386
  }
376
387
  }
377
388
  /** The push token: `--token`, or INLAY_PUSH_TOKEN. Answers exit code 2, having said so, when there is neither. */
@@ -913,8 +924,9 @@ export async function runCli(argv, io) {
913
924
  return printImportReport(io, await dryRunImport(config.site, resolve(io.cwd, rest[0] ?? '')), values.json);
914
925
  }
915
926
  if (command === 'check') {
927
+ let registry;
916
928
  try {
917
- buildRegistry(config.site);
929
+ registry = buildRegistry(config.site);
918
930
  }
919
931
  catch (e) {
920
932
  if (!(e instanceof InlayError) || e.code !== 'definition')
@@ -930,6 +942,12 @@ export async function runCli(argv, io) {
930
942
  report.problems.push(...problems);
931
943
  report.ok = false;
932
944
  }
945
+ if (existsSync(join(dir, 'public'))) {
946
+ for (const c of await publicClashes(join(dir, 'public'), registry)) {
947
+ report.problems.push({ code: 'public_clash', message: publicClashMessage(c) });
948
+ report.ok = false;
949
+ }
950
+ }
933
951
  if (values.json)
934
952
  io.out(JSON.stringify(report, null, 2));
935
953
  else
@@ -1,8 +1,9 @@
1
1
  import { type AgentRefs } from '../../core/agent/format.js';
2
+ import { type TrailingSlash } from '../../core/site/paths.js';
2
3
  import type { DocumentData } from '../../core/types.js';
3
4
  import type { McpDeps } from './server.js';
4
5
  /** The absolute URL of a decoded site path, or `null` for a document without a page. */
5
- export declare function pageUrl(baseUrl: string, path: string | null): string | null;
6
+ export declare function pageUrl(baseUrl: string, path: string | null, trailingSlash: TrailingSlash): string | null;
6
7
  /** The absolute URL of a media file. */
7
8
  export declare function mediaUrl(baseUrl: string, id: string): string;
8
9
  /** Everything `toAgent` and `agentLinks` look up for `data`, read up front in `locale` (drafts included). */
@@ -1,8 +1,8 @@
1
1
  import { agentRefsNeeded } from '../../core/agent/format.js';
2
- import { encodePath } from '../../core/site/paths.js';
2
+ import { encodePath, presentHref } from '../../core/site/paths.js';
3
3
  /** The absolute URL of a decoded site path, or `null` for a document without a page. */
4
- export function pageUrl(baseUrl, path) {
5
- return path === null ? null : `${baseUrl}${encodePath(path)}`;
4
+ export function pageUrl(baseUrl, path, trailingSlash) {
5
+ return path === null ? null : `${baseUrl}${presentHref(encodePath(path), trailingSlash)}`;
6
6
  }
7
7
  /** The absolute URL of a media file. */
8
8
  export function mediaUrl(baseUrl, id) {
@@ -17,7 +17,7 @@ export async function loadAgentRefs(deps, type, locale, data) {
17
17
  return {
18
18
  document(groupId) {
19
19
  const doc = documents.get(groupId);
20
- return doc ? { title: doc.title, url: pageUrl(baseUrl, doc.path) } : null;
20
+ return doc ? { title: doc.title, url: pageUrl(baseUrl, doc.path, core.registry.site.trailingSlash) } : null;
21
21
  },
22
22
  media: (id) => media.get(id) ?? { status: 'unknown' },
23
23
  mediaUrl: (id) => mediaUrl(baseUrl, id),
@@ -71,7 +71,7 @@ async function describeDone(deps, action, ids) {
71
71
  out.push(item);
72
72
  continue;
73
73
  }
74
- out.push({ ...item, url: pageUrl(deps.baseUrl, await livePath(deps, doc, 'published')) });
74
+ out.push({ ...item, url: pageUrl(deps.baseUrl, await livePath(deps, doc, 'published'), deps.core.registry.site.trailingSlash) });
75
75
  }
76
76
  return out;
77
77
  }
@@ -1,5 +1,5 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/server';
2
2
  import type { Ctx } from '../../../core/types.js';
3
3
  import type { McpDeps } from '../server.js';
4
- /** `describe_site`, `describe_type`, `get_document`, `search_entries` and `list_gaps`. */
4
+ /** `describe_site`, `describe_type`, `get_document`, `search_entries`, `find_text` and `list_gaps`. */
5
5
  export declare function register(server: McpServer, deps: McpDeps, _ctx: Ctx): void;
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import { agentLinks, toAgent } from '../../../core/agent/format.js';
3
3
  import { agentTypeSchema } from '../../../core/agent/schema.js';
4
4
  import { docLabels } from '../../../core/content/schema.js';
5
+ import { fold } from '../../../core/content/text-match.js';
5
6
  import { InlayError } from '../../../core/errors.js';
6
7
  import { t } from '../../../core/messages/index.js';
7
8
  import { designedInCode } from '../../../core/registry/designed.js';
@@ -29,6 +30,13 @@ const searchEntriesInput = z.object({
29
30
  locale: z.string().describe(t('mcp.param.locale')).optional(),
30
31
  limit: z.number().int().min(1).max(50).describe(t('mcp.param.limit')).optional(),
31
32
  });
33
+ const findTextInput = z.object({
34
+ text: z.string().describe(t('mcp.param.findText')),
35
+ type: z.string().describe(t('mcp.param.findType')).optional(),
36
+ locale: z.string().describe(t('mcp.param.findLocale')).optional(),
37
+ limit: z.number().int().min(1).max(100).describe(t('mcp.param.findLimit')).optional(),
38
+ offset: z.number().int().min(0).describe(t('mcp.param.findOffset')).optional(),
39
+ });
32
40
  /** `locale`, or the default locale when it's absent. An unknown locale is refused. */
33
41
  function localeOf(registry, locale) {
34
42
  if (locale === undefined)
@@ -70,7 +78,7 @@ async function describeSite(deps) {
70
78
  for (const locale of locales) {
71
79
  const path = singletonPath(def, locale, defaultLocale);
72
80
  if (path !== null)
73
- urls[locale] = pageUrl(baseUrl, withLocale(registry, locale, path));
81
+ urls[locale] = pageUrl(baseUrl, withLocale(registry, locale, path), registry.site.trailingSlash);
74
82
  }
75
83
  singletons.push({
76
84
  type: def.name,
@@ -225,7 +233,7 @@ async function getDocument(deps, args) {
225
233
  revisionId: doc.revision.id,
226
234
  publishedRevisionId: doc.publishedRev,
227
235
  hasUnpublishedChanges: doc.publishedRev !== doc.headRev,
228
- url: pageUrl(baseUrl, await livePath(deps, doc, 'published')),
236
+ url: pageUrl(baseUrl, await livePath(deps, doc, 'published'), deps.core.registry.site.trailingSlash),
229
237
  previewUrl: previewLink(deps, path ?? '/'),
230
238
  content: toAgent(registry, doc.type, doc.data, refs),
231
239
  links: agentLinks(registry, doc.type, doc.data, refs),
@@ -258,7 +266,36 @@ async function searchEntries(deps, args) {
258
266
  })),
259
267
  };
260
268
  }
261
- /** `describe_site`, `describe_type`, `get_document`, `search_entries` and `list_gaps`. */
269
+ async function findText(deps, args) {
270
+ if (fold(args.text).text.trim() === '')
271
+ throw new InlayError('invalid_operation', 'mcp.findText.blank');
272
+ if (args.type !== undefined)
273
+ await requireType(deps, args.type);
274
+ const locale = args.locale === undefined ? undefined : localeOf(deps.core.registry, args.locale);
275
+ const { total, documents, designedInCode } = await deps.core.findText(args.text, {
276
+ ...(args.type !== undefined && { type: args.type }),
277
+ ...(locale !== undefined && { locale }),
278
+ ...(args.limit !== undefined && { limit: args.limit }),
279
+ ...(args.offset !== undefined && { offset: args.offset }),
280
+ });
281
+ return {
282
+ total,
283
+ documents: documents.map(({ document: d, matches }) => ({
284
+ id: d.id,
285
+ groupId: d.groupId,
286
+ type: d.type,
287
+ kind: d.kind,
288
+ title: d.title,
289
+ locale: d.locale,
290
+ revisionId: d.headRev,
291
+ published: d.publishedRev !== null,
292
+ hasUnpublishedChanges: d.publishedRev !== d.headRev,
293
+ matches: matches.map((m) => ({ ...m, path: m.path.join('.') })),
294
+ })),
295
+ ...(designedInCode.length > 0 && { designedInCode, note: t('mcp.findText.designedInCode') }),
296
+ };
297
+ }
298
+ /** `describe_site`, `describe_type`, `get_document`, `search_entries`, `find_text` and `list_gaps`. */
262
299
  export function register(server, deps, _ctx) {
263
300
  const run = (fn) => tool(async (args) => ok(await fn(args)), deps.log);
264
301
  server.registerTool('describe_site', {
@@ -285,6 +322,12 @@ export function register(server, deps, _ctx) {
285
322
  inputSchema: searchEntriesInput,
286
323
  annotations: READ_ONLY,
287
324
  }, run((args) => searchEntries(deps, args)));
325
+ server.registerTool('find_text', {
326
+ title: t('mcp.tool.find_text.title'),
327
+ description: t('mcp.tool.find_text.description'),
328
+ inputSchema: findTextInput,
329
+ annotations: READ_ONLY,
330
+ }, run((args) => findText(deps, args)));
288
331
  server.registerTool('list_gaps', {
289
332
  title: t('mcp.tool.list_gaps.title'),
290
333
  description: t('mcp.tool.list_gaps.description'),
@@ -1,10 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { contentFromAgent, fromAgent, parsePath } from '../../../core/agent/format.js';
3
3
  import { formatDiff } from '../../../core/content/diff.js';
4
- import { patchProblems, unknownContentKeys } from '../../../core/content/patch.js';
4
+ import { applyPatch, patchProblems, unknownContentKeys } from '../../../core/content/patch.js';
5
5
  import { docLabels, documentRefsWithPaths, normalizeContent } from '../../../core/content/schema.js';
6
+ import { replaceText } from '../../../core/content/text-replace.js';
6
7
  import { contentIssue, mergeIssues, validateContent } from '../../../core/content/validate.js';
7
8
  import { InlayError } from '../../../core/errors.js';
9
+ import { fieldMeta } from '../../../core/fields/define.js';
8
10
  import { defOf, unwrap } from '../../../core/fields/zod-internals.js';
9
11
  import { t } from '../../../core/messages/index.js';
10
12
  import { designedInCode } from '../../../core/registry/designed.js';
@@ -20,6 +22,9 @@ const updateDocumentInput = z.object({
20
22
  path: z.string().describe(t('mcp.param.changePath')),
21
23
  value: z.unknown().describe(t('mcp.param.changeValue')).optional(),
22
24
  remove: z.literal(true).describe(t('mcp.param.changeRemove')).optional(),
25
+ find: z.string().describe(t('mcp.param.changeFind')).optional(),
26
+ replace: z.string().describe(t('mcp.param.changeReplace')).optional(),
27
+ occurrences: z.array(z.number()).describe(t('mcp.param.changeOccurrences')).optional(),
23
28
  }))
24
29
  .min(1)
25
30
  .max(100)
@@ -54,7 +59,7 @@ async function created(deps, doc) {
54
59
  groupId: doc.groupId,
55
60
  revisionId: doc.headRev,
56
61
  title: doc.title,
57
- url: pageUrl(deps.baseUrl, await livePath(deps, doc, 'published')),
62
+ url: pageUrl(deps.baseUrl, await livePath(deps, doc, 'published'), deps.core.registry.site.trailingSlash),
58
63
  previewUrl: previewLink(deps, path ?? '/'),
59
64
  };
60
65
  }
@@ -135,11 +140,60 @@ async function groupIdIssues(deps, type, data) {
135
140
  }
136
141
  return issues;
137
142
  }
138
- /** The change list as patch operations, converted from the agent format, and the problems of the changes that can't be. */
139
- function toOps(deps, type, changes) {
143
+ const REPLACE_KINDS = new Set(['text', 'textarea', 'richText', 'inlineText']);
144
+ /** The field a replace works on: the text field at `path`, or the link whose label `path` names. */
145
+ function replaceTarget(registry, type, path) {
146
+ const field = fieldAt(registry, type, path);
147
+ const kind = field && fieldMeta(field)?.kind;
148
+ if (kind && REPLACE_KINDS.has(kind))
149
+ return { path, kind: kind };
150
+ if (path.at(-1) !== 'text')
151
+ return null;
152
+ const link = fieldAt(registry, type, path.slice(0, -1));
153
+ if (link && fieldMeta(link)?.kind === 'link')
154
+ return { path: path.slice(0, -1), kind: 'link' };
155
+ return null;
156
+ }
157
+ function valueAt(data, path) {
158
+ let current = data;
159
+ for (const segment of path) {
160
+ if (typeof current !== 'object' || current === null)
161
+ return undefined;
162
+ current = current[segment];
163
+ }
164
+ return current;
165
+ }
166
+ const REPLACE_FAILURES = {
167
+ notFound: 'mcp.change.notFound',
168
+ occurrence: 'mcp.change.occurrence',
169
+ noOccurrences: 'mcp.change.noOccurrences',
170
+ spansFormatting: 'mcp.change.spansFormatting',
171
+ };
172
+ /** A find-and-replace change as one patch op on the field, seeing what the ops before it did. */
173
+ function replaceOp(registry, type, data, opsSoFar, path, change) {
174
+ const labels = docLabels(registry, type, path) ?? path.map(String);
175
+ const target = replaceTarget(registry, type, path);
176
+ if (target === null)
177
+ return contentIssue(path, labels, 'invalid', 'mcp.change.notText');
178
+ const patched = applyPatch(registry, type, data, opsSoFar);
179
+ const current = valueAt(patched.ok ? patched.data : data, target.path);
180
+ const result = current === undefined
181
+ ? { ok: false, reason: 'notFound', count: 0 }
182
+ : replaceText(target.kind, current, change.find, change.replace, change.occurrences);
183
+ if (!result.ok) {
184
+ return contentIssue(path, labels, 'invalid', REPLACE_FAILURES[result.reason], { find: change.find, count: result.count });
185
+ }
186
+ return { op: { path: target.path, value: result.value }, count: result.count };
187
+ }
188
+ /**
189
+ * The change list as patch operations, converted from the agent format, and the problems of the changes that can't be.
190
+ * A replace works on `data` with the earlier changes applied, and is counted in `replaced`.
191
+ */
192
+ function toOps(deps, type, data, changes) {
140
193
  const { registry } = deps.core;
141
194
  const issues = [];
142
195
  const ops = [];
196
+ const replaced = [];
143
197
  for (const change of changes) {
144
198
  const path = parsePath(change.path);
145
199
  if (path === null) {
@@ -148,6 +202,22 @@ function toOps(deps, type, changes) {
148
202
  }
149
203
  const hasValue = change.value !== undefined;
150
204
  const remove = change.remove === true;
205
+ if (change.find !== undefined || change.replace !== undefined || change.occurrences !== undefined) {
206
+ if (change.find === undefined || change.replace === undefined || hasValue || remove) {
207
+ const labels = docLabels(registry, type, path) ?? path.map(String);
208
+ issues.push(contentIssue(path, labels, 'invalid', 'mcp.change.replaceShape'));
209
+ continue;
210
+ }
211
+ const result = replaceOp(registry, type, data, ops, path, { ...change, find: change.find, replace: change.replace });
212
+ if ('op' in result) {
213
+ ops.push(result.op);
214
+ replaced.push({ path: change.path, count: result.count });
215
+ }
216
+ else {
217
+ issues.push(result);
218
+ }
219
+ continue;
220
+ }
151
221
  if (hasValue === remove) {
152
222
  const labels = docLabels(registry, type, path) ?? path.map(String);
153
223
  issues.push(contentIssue(path, labels, 'invalid', hasValue ? 'mcp.change.both' : 'mcp.change.neither'));
@@ -171,7 +241,7 @@ function toOps(deps, type, changes) {
171
241
  else
172
242
  issues.push(...result.issues);
173
243
  }
174
- return { ops, issues };
244
+ return { ops, issues, replaced };
175
245
  }
176
246
  /**
177
247
  * Saves the changes as a draft. Any problem is reported with every other one: the changes that can't be read,
@@ -182,7 +252,7 @@ async function updateDocument(deps, args, ctx) {
182
252
  const def = deps.core.registry.getType(doc.type);
183
253
  if (def.kind !== 'collection' && designedInCode(def.template))
184
254
  throw new InlayError('invalid_operation', 'mcp.designedInCode');
185
- const { ops, issues } = toOps(deps, doc.type, args.changes);
255
+ const { ops, issues, replaced } = toOps(deps, doc.type, doc.data, args.changes);
186
256
  issues.push(...(await groupIdIssues(deps, doc.type, opsAsData(ops))));
187
257
  if (issues.length > 0)
188
258
  throw validation(mergeIssues(issues, patchProblems(deps.core.registry, doc.type, doc.data, ops)));
@@ -201,6 +271,7 @@ async function updateDocument(deps, args, ctx) {
201
271
  revisionId: result.document.headRev,
202
272
  changed: result.changed,
203
273
  changes: formatDiff(result.diff),
274
+ ...(args.changes.some((c) => c.find !== undefined) && { replaced }),
204
275
  previewUrl: previewLink(deps, path ?? '/'),
205
276
  };
206
277
  }
@@ -2,16 +2,19 @@ import type { Core } from '../../core/core.js';
2
2
  import type { TemplateDef } from '../../core/registry/define.js';
3
3
  import type { RenderContext } from '../../core/registry/render.js';
4
4
  import type { QueryApi } from '../../core/registry/route.js';
5
+ import { type TrailingSlash } from '../../core/site/paths.js';
5
6
  import type { DocumentData, LiveDocument, LiveState } from '../../core/types.js';
6
7
  import { type PublicAssets } from './assets.js';
7
8
  import { type CollectedHead } from './head.js';
8
9
  import { type CodeFiles } from './code-files.js';
10
+ /** The encoded URL of the decoded site path `path`, in the form the site presents; `''` for `''`. */
11
+ export declare const pageUrl: (path: string, mode: TrailingSlash) => string;
9
12
  export interface RenderContextOptions {
10
13
  locale: string;
11
14
  state: LiveState;
12
15
  page: number;
13
16
  baseUrl: string;
14
- alternates: RenderContext['alternates'];
17
+ alternates: Array<Omit<RenderContext['alternates'][number], 'url'>>;
15
18
  assets?: PublicAssets;
16
19
  /** Where `markdown` finds its image files; the core's shared index by default. */
17
20
  codeFiles?: CodeFiles;
@@ -10,12 +10,14 @@ import { inlineTextToHtml } from '../../core/richtext/inline.js';
10
10
  import { markdownImages } from '../../core/richtext/markdown.js';
11
11
  import { isMediaTarget, KEY_HREF, NO_DOCUMENT, parseMarkdownText } from '../../core/richtext/markdown-text.js';
12
12
  import { richTextRefs } from '../../core/richtext/schema.js';
13
- import { encodePath } from '../../core/site/paths.js';
13
+ import { encodePath, presentHref } from '../../core/site/paths.js';
14
14
  import { publicAssets } from './assets.js';
15
15
  import { createHeadCollector } from './head.js';
16
16
  import { codeFilesFor } from './code-files.js';
17
17
  import { createScriptCollector } from './scripts.js';
18
18
  import { escapeHtml, raw } from '../../jsx/html.js';
19
+ /** The encoded URL of the decoded site path `path`, in the form the site presents; `''` for `''`. */
20
+ export const pageUrl = (path, mode) => presentHref(encodePath(path), mode);
19
21
  /** Rich text images get this width as `src` when the original is at least as wide. */
20
22
  const RICH_TEXT_SRC_WIDTH = 1280;
21
23
  const nonEmpty = (s) => typeof s === 'string' && s !== '';
@@ -75,13 +77,13 @@ function richTextImage(img) {
75
77
  const width = Math.min(img.width ?? RICH_TEXT_SRC_WIDTH, RICH_TEXT_SRC_WIDTH);
76
78
  return { src: img.src(width), srcset: img.srcset(), alt: img.alt, width: img.width, height: img.height };
77
79
  }
78
- function toEntry(doc) {
80
+ function toEntry(doc, mode) {
79
81
  return {
80
82
  id: doc.groupId,
81
83
  type: doc.type,
82
84
  locale: doc.contentLocale,
83
85
  fallback: doc.fallback,
84
- url: doc.path === null ? null : encodePath(doc.path),
86
+ url: doc.path === null ? null : presentHref(encodePath(doc.path), mode),
85
87
  title: doc.title,
86
88
  slug: doc.slug,
87
89
  updatedAt: doc.updatedAt,
@@ -220,7 +222,7 @@ export function createRenderContext(core, opts) {
220
222
  const doc = docs.get(groupId);
221
223
  if (!doc || doc.path === null)
222
224
  return null;
223
- return { href: encodePath(doc.path), title: doc.title };
225
+ return { href: presentHref(encodePath(doc.path), registry.site.trailingSlash), title: doc.title };
224
226
  }
225
227
  function link(v) {
226
228
  if (!v)
@@ -295,7 +297,7 @@ export function createRenderContext(core, opts) {
295
297
  return doc ? [doc] : [];
296
298
  });
297
299
  await preload(found);
298
- return found.map((doc) => toEntry(doc));
300
+ return found.map((doc) => toEntry(doc, registry.site.trailingSlash));
299
301
  }
300
302
  function liveCollection(name) {
301
303
  let pending = collections.get(name);
@@ -314,7 +316,7 @@ export function createRenderContext(core, opts) {
314
316
  async function query(collection, queryOpts = {}) {
315
317
  const name = typeof collection === 'string' ? collection : collection.name;
316
318
  const live = await liveCollection(name);
317
- const all = live.map((doc) => toEntry(doc));
319
+ const all = live.map((doc) => toEntry(doc, registry.site.trailingSlash));
318
320
  const filtered = queryOpts.filter ? all.filter(queryOpts.filter) : all;
319
321
  const sorted = sortEntries(filtered, queryOpts.sort);
320
322
  const total = sorted.length;
@@ -357,7 +359,7 @@ export function createRenderContext(core, opts) {
357
359
  asset: (path) => assets.url(path),
358
360
  head: head.api,
359
361
  script: scripts.api,
360
- alternates: opts.alternates,
362
+ alternates: opts.alternates.map((a) => ({ ...a, url: pageUrl(a.path, registry.site.trailingSlash) })),
361
363
  image,
362
364
  file,
363
365
  link,
@@ -1,5 +1,6 @@
1
1
  import type { OgType } from '../../core/registry/define.js';
2
2
  import type { HeadApi, HeadLink } from '../../core/registry/render.js';
3
+ import { type TrailingSlash } from '../../core/site/paths.js';
3
4
  import { type SafeHtml } from '../../jsx/html.js';
4
5
  export interface HeadInput {
5
6
  /** The final `<title>` text. */
@@ -21,6 +22,7 @@ export interface HeadInput {
21
22
  }>;
22
23
  defaultLocale: string;
23
24
  baseUrl: string;
25
+ trailingSlash: TrailingSlash;
24
26
  preview: boolean;
25
27
  /** What the render added through `ctx.head`. */
26
28
  collected?: CollectedHead;