@cloudhal/mcp-server 0.3.10 → 0.3.12

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.
@@ -21,10 +21,9 @@
21
21
 
22
22
  import { ID_RE, parseRange, privacySignalShare } from "@cloudhal/analytics";
23
23
  import { previousRange } from "@cloudhal/analytics/service";
24
- import { entryPath } from "@cloudhal/astro-renderer/routing";
25
24
  import { archivePath } from "@cloudhal/astro-renderer/taxonomy";
26
25
 
27
- import { termName } from "@cloudhal/core-ts";
26
+ import { entryPath, termName } from "@cloudhal/core-ts";
28
27
 
29
28
 
30
29
 
@@ -143,7 +142,7 @@ export async function analyticsNodes(
143
142
  kind: "entry",
144
143
  exists: true,
145
144
  title: e.title,
146
- path: entryPath(e),
145
+ path: entryPath(site, e),
147
146
  status: e.status,
148
147
  }
149
148
  : gone(id),
@@ -581,7 +580,7 @@ export async function brokenLinksReport(
581
580
  ...pages
582
581
  .filter((p) => p.status === "published")
583
582
  .map((p) => ({ path: p.path, nodeId: p.id, segment: lastSegment(p.path) })),
584
- ...entries.map((e) => ({ path: entryPath(e), nodeId: e.id, segment: e.slug })),
583
+ ...entries.map((e) => ({ path: entryPath(site, e), nodeId: e.id, segment: e.slug })),
585
584
  ];
586
585
  return candidates;
587
586
  };
@@ -251,7 +251,7 @@ export function commentTools() {
251
251
  d.store.counts(site.id, a.nodeId !== undefined ? { nodeId: a.nodeId } : {}),
252
252
  commentEntries(
253
253
  ctx.store,
254
- site.id,
254
+ site,
255
255
  page.comments.map((c) => c.nodeId),
256
256
  ),
257
257
  d.store.listReports(site.id, { open: true, limit: 200 }),
@@ -320,7 +320,7 @@ export function commentTools() {
320
320
  const d = comments(ctx);
321
321
  const site = await requireSite(ctx, a.siteId );
322
322
  const nodeId = a.nodeId ;
323
- const entry = (await commentEntries(ctx.store, site.id, [nodeId])).get(nodeId);
323
+ const entry = (await commentEntries(ctx.store, site, [nodeId])).get(nodeId);
324
324
  if (!entry) throw new ToolError("not_found", `article ${nodeId} not found`);
325
325
  const all = await d.store.threadComments(site.id, nodeId, {
326
326
  includePending: a.includePending !== false,
@@ -410,7 +410,7 @@ export function commentTools() {
410
410
  ]);
411
411
  const entries = await commentEntries(
412
412
  ctx.store,
413
- site.id,
413
+ site,
414
414
  stats.busiest.map((b) => b.nodeId),
415
415
  );
416
416
  const age = (at ) =>
@@ -720,7 +720,7 @@ export function commentTools() {
720
720
  const d = comments(ctx);
721
721
  const site = await requireSite(ctx, a.siteId );
722
722
  const nodeId = a.nodeId ;
723
- const entry = (await commentEntries(ctx.store, site.id, [nodeId])).get(nodeId);
723
+ const entry = (await commentEntries(ctx.store, site, [nodeId])).get(nodeId);
724
724
  if (!entry) throw new ToolError("not_found", `article ${nodeId} not found`);
725
725
  await assertOwn(ctx, [entry]);
726
726
  const actor = threadClass(a) === "person" ? personActor(ctx) : ctx.principal.actor;
@@ -10,8 +10,8 @@
10
10
  import { type OwnershipResolver } from "@cloudhal/agent-runtime";
11
11
  import { type CommentKeys, type CommentReport, type CommentSettings, type PurgePriority, type ThreadRow, type ThreadState } from "@cloudhal/comments";
12
12
  import type { SqlCommentStore } from "@cloudhal/comments/sql";
13
- import type { Actor, Comment, ContentEntry } from "@cloudhal/core-contracts";
14
- import type { SiteGraphStore } from "@cloudhal/core-ts";
13
+ import type { Actor, Comment, ContentEntry, Site } from "@cloudhal/core-contracts";
14
+ import { type PermalinkSite, type SiteGraphStore } from "@cloudhal/core-ts";
15
15
  /** What a deployment provides for reader comments (RFC-0007 §15.3). */
16
16
  export interface CommentsDeps {
17
17
  readonly store: SqlCommentStore;
@@ -49,9 +49,12 @@ export interface CommentEntry {
49
49
  readonly publishedAt: string | null;
50
50
  readonly author: Actor;
51
51
  }
52
- export declare function toCommentEntry(e: ContentEntry): CommentEntry;
53
- /** The entries of `nodeIds` on `siteId` (unknown ids are left out). */
54
- export declare function commentEntries(graph: SiteGraphStore, siteId: string, nodeIds: Iterable<string>): Promise<Map<string, CommentEntry>>;
52
+ export declare function toCommentEntry(site: PermalinkSite | undefined, e: ContentEntry): CommentEntry;
53
+ /**
54
+ * The entries of `nodeIds` on the site (unknown ids are left out). Pass the site when the caller
55
+ * has it; with only its id, it is read for the entries' paths (RFC-0038).
56
+ */
57
+ export declare function commentEntries(graph: SiteGraphStore, site: string | Site, nodeIds: Iterable<string>): Promise<Map<string, CommentEntry>>;
55
58
  /** An entry's thread as Studio and agents see it (§4.5). */
56
59
  export interface ThreadView {
57
60
  readonly nodeId: string;
@@ -8,7 +8,6 @@
8
8
  * for them (invariant C1), and commenter data stays in the person-only REST routes.
9
9
  */
10
10
  import { ownsEntry } from "@cloudhal/agent-runtime";
11
- import { entryPath } from "@cloudhal/astro-renderer/routing";
12
11
  import {
13
12
 
14
13
 
@@ -20,8 +19,8 @@ import {
20
19
  threadState,
21
20
  } from "@cloudhal/comments";
22
21
 
23
-
24
-
22
+
23
+ import { entryPath, } from "@cloudhal/core-ts";
25
24
 
26
25
  /** What a deployment provides for reader comments (RFC-0007 §15.3). */
27
26
 
@@ -69,11 +68,11 @@ export const commentsAvailable = (deps )
69
68
 
70
69
  const ENTRY_GETS = 20;
71
70
 
72
- export function toCommentEntry(e ) {
71
+ export function toCommentEntry(site , e ) {
73
72
  return {
74
73
  nodeId: e.id,
75
74
  title: e.title,
76
- path: entryPath(e),
75
+ path: entryPath(site, e),
77
76
  collection: e.collection,
78
77
  status: e.status,
79
78
  publishedAt: e.publishedAt ?? null,
@@ -81,20 +80,26 @@ export function toCommentEntry(e ) {
81
80
  };
82
81
  }
83
82
 
84
- /** The entries of `nodeIds` on `siteId` (unknown ids are left out). */
83
+ /**
84
+ * The entries of `nodeIds` on the site (unknown ids are left out). Pass the site when the caller
85
+ * has it; with only its id, it is read for the entries' paths (RFC-0038).
86
+ */
85
87
  export async function commentEntries(
86
88
  graph ,
87
- siteId ,
89
+ site ,
88
90
  nodeIds ,
89
91
  ) {
90
92
  const ids = [...new Set(nodeIds)];
91
93
  const out = new Map ();
92
94
  if (ids.length === 0) return out;
93
- const found =
95
+ const siteId = typeof site === "string" ? site : site.id;
96
+ const [found, permalinks] = await Promise.all([
94
97
  ids.length <= ENTRY_GETS
95
- ? await Promise.all(ids.map((id) => graph.getContentEntry(id)))
96
- : (await graph.listContentEntries(siteId)).filter((e) => ids.includes(e.id));
97
- for (const e of found) if (e && e.siteId === siteId) out.set(e.id, toCommentEntry(e));
98
+ ? Promise.all(ids.map((id) => graph.getContentEntry(id)))
99
+ : graph.listContentEntries(siteId).then((all) => all.filter((e) => ids.includes(e.id))),
100
+ typeof site === "string" ? graph.getSite(site) : site,
101
+ ]);
102
+ for (const e of found) if (e && e.siteId === siteId) out.set(e.id, toCommentEntry(permalinks, e));
98
103
  return out;
99
104
  }
100
105
 
@@ -50,6 +50,8 @@ export interface ToolDefinition {
50
50
  classify?: (args: Record<string, unknown>) => CallClass | undefined;
51
51
  /** The scopes a `propose` call needs instead of `scopes` (ADR-0028). */
52
52
  proposeScopes?: Scope[];
53
+ /** Scopes the person approving the call must also hold (person-only ones included). */
54
+ approverScopes?: Scope[];
53
55
  /**
54
56
  * What the call would change, for a person deciding its approval request (RFC-0014 §5): Studio
55
57
  * lists it with the request. Computed against the current state when the request is listed.
@@ -71,6 +71,8 @@ import { ScheduleRequestError, } from "./sch
71
71
 
72
72
 
73
73
 
74
+
75
+
74
76
 
75
77
   
76
78
 
@@ -54,7 +54,8 @@ const listSitesTool = {
54
54
  const getSiteTool = {
55
55
  name: "get_site",
56
56
  title: "Get site",
57
- description: "A site with its page order, locales, theme and published snapshot.",
57
+ description:
58
+ "A site with its page order, locales, theme, published snapshot and per-collection settings (`collections.<key>.permalink`, e.g. /blog/{slug}; a collection without one lives at /<collection>/{slug}).",
58
59
  inputSchema: obj({ siteId: id }, ["siteId"]),
59
60
  outputSchema: obj({ site: SITE }, ["site"]),
60
61
  annotations: {
@@ -0,0 +1,31 @@
1
+ import { type ToolDefinition } from "./common.js";
2
+ /** The schema's v1 pattern (`site.schema.json` → `CollectionSettings.permalink`). */
3
+ export declare const PERMALINK_PATTERN = "^(/[a-z0-9]+(?:-[a-z0-9]+)*)+/\\{slug\\}$";
4
+ /** What a call would do: templates, example URLs and redirects. */
5
+ export interface PermalinkPlan {
6
+ collection: string;
7
+ from: string;
8
+ to: string;
9
+ /** The new template is the default `/<collection>/{slug}` (the setting is removed). */
10
+ isDefault: boolean;
11
+ /** Entries in the collection, every status and locale. */
12
+ entries: number;
13
+ examples: {
14
+ title: string;
15
+ slug: string;
16
+ status: string;
17
+ from: string;
18
+ to: string;
19
+ }[];
20
+ redirects: {
21
+ change: "add" | "repoint" | "remove";
22
+ from: string;
23
+ to: string;
24
+ note: string;
25
+ }[];
26
+ /** Locales the prefix redirect is written for (the default locale and every other one). */
27
+ locales: string[];
28
+ }
29
+ /** The approval text: what a person decides on. */
30
+ export declare function describePlan(p: PermalinkPlan): string;
31
+ export declare function permalinkTools(): ToolDefinition[];
@@ -0,0 +1,243 @@
1
+ /**
2
+ * RFC-0038 §5: `set_collection_permalink`, the one tool that changes where a collection's entries
3
+ * live. It moves public URLs, so it waits for a person in every mode (`bypass` included), and the
4
+ * person sees the old and new template, a few entries' old and new addresses and the redirect the
5
+ * store writes. `dryRun` returns the same plan without asking anyone or changing anything.
6
+ */
7
+
8
+ import { collectionPermalink, entryPath, permalinkPrefix } from "@cloudhal/core-ts/permalinks";
9
+ import {
10
+ autoSnapshot,
11
+ id,
12
+
13
+ obj,
14
+ requireSite,
15
+ SLUG_PATTERN,
16
+ str,
17
+
18
+
19
+ ToolError,
20
+ toToolError,
21
+ } from "./common.js";
22
+ import { SITE, SNAPSHOT } from "./content-shared.js";
23
+
24
+ /** The schema's v1 pattern (`site.schema.json` → `CollectionSettings.permalink`). */
25
+ export const PERMALINK_PATTERN = "^(/[a-z0-9]+(?:-[a-z0-9]+)*)+/\\{slug\\}$";
26
+ const EXAMPLES = 3;
27
+
28
+ /** What a call would do: templates, example URLs and redirects. */
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ /** The site with `collection`'s permalink set (`null`: back to the default). */
44
+ function nextSite(site , collection , permalink ) {
45
+ const { [collection]: current, ...others } = site.collections ?? {};
46
+ const { permalink: _old, ...rest } = current ?? {};
47
+ const settings = permalink ? { ...rest, permalink } : rest;
48
+ const collections = Object.keys(settings).length ? { ...others, [collection]: settings } : others;
49
+ const { collections: _drop, ...base } = site;
50
+ return Object.keys(collections).length ? { ...base, collections } : (base );
51
+ }
52
+
53
+ /** Published entries first, newest first; at most `EXAMPLES`, default locale preferred. */
54
+ function examples(site , entries , next ) {
55
+ const rank = (e ) =>
56
+ (e.status === "published" ? 0 : 2) + (e.locale === site.defaultLocale ? 0 : 1);
57
+ return [...entries]
58
+ .sort((a, b) => rank(a) - rank(b) || b.updatedAt.localeCompare(a.updatedAt))
59
+ .slice(0, EXAMPLES)
60
+ .map((e) => ({
61
+ title: e.title,
62
+ slug: e.slug,
63
+ status: e.status,
64
+ from: entryPath(site, e),
65
+ to: entryPath(next, e),
66
+ }));
67
+ }
68
+
69
+ /** Mirrors `RedirectPlan.move` (prefix match): repointed targets, dropped loops, the new one. */
70
+ function redirectPlan(existing , from , to ) {
71
+ const out = [];
72
+ for (const r of existing) {
73
+ if (r.locale) continue;
74
+ if (r.to !== from && !r.to.startsWith(`${from}/`)) continue;
75
+ const target = `${to}${r.to.slice(from.length)}`;
76
+ if (target === r.from)
77
+ out.push({ change: "remove", from: r.from, to: r.to, note: "it would point to itself" });
78
+ else out.push({ change: "repoint", from: r.from, to: target, note: `was ${r.to}` });
79
+ }
80
+ out.push({
81
+ change: "add",
82
+ from,
83
+ to,
84
+ note: `301, prefix: every ${from}/<slug> answers with ${to}/<slug>`,
85
+ });
86
+ return out;
87
+ }
88
+
89
+ async function plan(ctx , a ) {
90
+ const site = await requireSite(ctx, a.siteId );
91
+ const collection = a.collection ;
92
+ const permalink = (a.permalink ?? null) ;
93
+ const next = nextSite(site, collection, permalink);
94
+ const from = collectionPermalink(site, collection);
95
+ const to = collectionPermalink(next, collection);
96
+ const entries = await ctx.store.listContentEntries(site.id, collection);
97
+ return {
98
+ collection,
99
+ from,
100
+ to,
101
+ isDefault: !next.collections?.[collection]?.permalink,
102
+ entries: entries.length,
103
+ examples: examples(site, entries, next),
104
+ redirects:
105
+ from === to
106
+ ? []
107
+ : redirectPlan(
108
+ await ctx.store.listRedirects(site.id),
109
+ permalinkPrefix(from),
110
+ permalinkPrefix(to),
111
+ ),
112
+ locales: [...new Set([site.defaultLocale, ...site.locales])],
113
+ };
114
+ }
115
+
116
+ /** The approval text: what a person decides on. */
117
+ export function describePlan(p ) {
118
+ const head = `Move the public URLs of collection "${p.collection}" from ${p.from} to ${p.to}${p.isDefault ? " (the default)" : ""}? ${p.entries} entr${p.entries === 1 ? "y" : "ies"} move; old URLs keep working through a permanent redirect (301).`;
119
+ const lines = [
120
+ ...p.examples.map((e) => ` ${e.from} → ${e.to} (${e.status}: "${e.title}")`),
121
+ ...p.redirects.map(
122
+ (r) =>
123
+ `${{ add: "+", repoint: "~", remove: "−" }[r.change]} redirect ${r.from} → ${r.to} (${r.note})`,
124
+ ),
125
+ ];
126
+ if (p.locales.length > 1) lines.push(` in every locale: ${p.locales.join(", ")}`);
127
+ return lines.length ? `${head}\n${lines.join("\n")}` : head;
128
+ }
129
+
130
+ async function check(a , ctx ) {
131
+ const permalink = a.permalink ?? null;
132
+ if (permalink !== null && !new RegExp(PERMALINK_PATTERN).test(String(permalink)))
133
+ throw new ToolError(
134
+ "invalid",
135
+ `permalink must be one or more lower-case path segments followed by /{slug}, e.g. /blog/{slug} (got ${JSON.stringify(permalink)}); null goes back to /${a.collection}/{slug}`,
136
+ );
137
+ const site = await requireSite(ctx, a.siteId );
138
+ const collection = a.collection ;
139
+ const next = nextSite(site, collection, permalink );
140
+ if (collectionPermalink(site, collection) === collectionPermalink(next, collection))
141
+ throw new ToolError(
142
+ "invalid",
143
+ `collection "${collection}" already uses ${collectionPermalink(site, collection)}; nothing to change`,
144
+ );
145
+ try {
146
+ await ctx.store.updateSite(next, { dryRun: true });
147
+ } catch (e) {
148
+ throw withHint(e);
149
+ }
150
+ }
151
+
152
+ function withHint(e ) {
153
+ const err = toToolError(e);
154
+ if (err instanceof ToolError && (err.code === "path_conflict" || err.code === "reserved_path"))
155
+ return new ToolError(
156
+ err.code,
157
+ `${err.message}. Choose another prefix: get_site shows the collections, list_pages the pages and list_taxonomies the archive base paths`,
158
+ { ...err.details },
159
+ );
160
+ return err;
161
+ }
162
+
163
+ const PLAN_OUT = obj(
164
+ {
165
+ collection: { type: "string" },
166
+ from: { type: "string" },
167
+ to: { type: "string" },
168
+ isDefault: { type: "boolean" },
169
+ entries: { type: "integer" },
170
+ examples: { type: "array", items: { type: "object" } },
171
+ redirects: { type: "array", items: { type: "object" } },
172
+ locales: { type: "array", items: { type: "string" } },
173
+ },
174
+ ["collection", "from", "to", "isDefault", "entries", "examples", "redirects", "locales"],
175
+ );
176
+
177
+ export function permalinkTools() {
178
+ return [
179
+ {
180
+ name: "set_collection_permalink",
181
+ title: "Set collection permalink",
182
+ description:
183
+ 'Move where a collection\'s entries live (RFC-0038): permalink "/blog/{slug}" puts collection "posts" at /blog/<slug>; null goes back to the default /<collection>/{slug}. The collection key never changes (filters and tools keep using it). Old URLs keep working: the store writes a permanent prefix redirect (301) in every locale. The template may not overlap a page, a taxonomy archive, another collection, /search or a locale prefix. get_site shows the current `collections`. It moves public URLs, so it always waits for a person, who sees the old and new URLs of a few entries and the redirect; call it with dryRun: true first to see that plan without asking anyone.',
184
+ inputSchema: obj(
185
+ {
186
+ siteId: id,
187
+ collection: str("Collection key (ContentEntry.collection), e.g. posts", {
188
+ pattern: SLUG_PATTERN,
189
+ }),
190
+ permalink: {
191
+ anyOf: [
192
+ {
193
+ type: "string",
194
+ pattern: PERMALINK_PATTERN,
195
+ description: "Fixed lower-case segments followed by /{slug}, e.g. /blog/{slug}",
196
+ },
197
+ { type: "null" },
198
+ ],
199
+ description: "The new template, or null for the default /<collection>/{slug}",
200
+ },
201
+ dryRun: {
202
+ type: "boolean",
203
+ description: "Return the plan (example URLs, redirects) without changing anything",
204
+ },
205
+ },
206
+ ["siteId", "collection", "permalink"],
207
+ ),
208
+ outputSchema: obj(
209
+ { plan: PLAN_OUT, dryRun: { type: "boolean" }, site: SITE, snapshot: SNAPSHOT },
210
+ ["plan", "dryRun"],
211
+ ),
212
+ annotations: {
213
+ readOnlyHint: false,
214
+ destructiveHint: false,
215
+ idempotentHint: true,
216
+ openWorldHint: false,
217
+ },
218
+ scopes: ["site:write"],
219
+ // Only someone who may change site settings in Studio decides it (an Editor may not).
220
+ approverScopes: ["site:settings"],
221
+ requiresApproval: true,
222
+ // Public URLs move: a person decides in every mode; a dry run changes nothing.
223
+ classify: (a) => (a.dryRun === true ? "read" : "person"),
224
+ precheck: check,
225
+ approvalPrompt: async (a, ctx) => describePlan(await plan(ctx, a)),
226
+ handler: async (a, ctx) => {
227
+ const p = await plan(ctx, a);
228
+ if (a.dryRun === true) return { plan: p, dryRun: true };
229
+ const site = await requireSite(ctx, a.siteId );
230
+ let updated ;
231
+ try {
232
+ updated = await ctx.store.updateSite(
233
+ nextSite(site, a.collection , (a.permalink ?? null) ),
234
+ );
235
+ } catch (e) {
236
+ throw withHint(e);
237
+ }
238
+ const snapshot = await autoSnapshot(ctx, site.id, "set_collection_permalink");
239
+ return { plan: p, dryRun: false, site: updated, snapshot };
240
+ },
241
+ },
242
+ ];
243
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The title and path a release item shows for a node version (§12 `get_release`): whatever name
3
+ * the node kind has, and its page path, entry permalink (RFC-0038) or redirect source.
4
+ */
5
+ import { type PermalinkSite } from "@cloudhal/core-ts";
6
+ export declare function titleOf(site: PermalinkSite | undefined, node: unknown): {
7
+ title: string | null;
8
+ path: string | null;
9
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The title and path a release item shows for a node version (§12 `get_release`): whatever name
3
+ * the node kind has, and its page path, entry permalink (RFC-0038) or redirect source.
4
+ */
5
+ import { entryPath, } from "@cloudhal/core-ts";
6
+
7
+ export function titleOf(
8
+ site ,
9
+ node ,
10
+ ) {
11
+ const n = node
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+ ;
22
+ if (!n) return { title: null, path: null };
23
+ const name =
24
+ typeof n.name === "string"
25
+ ? n.name
26
+ : n.name && typeof n.name === "object"
27
+ ? (Object.values(n.name )[0] ?? null)
28
+ : null;
29
+ const title =
30
+ n.title ?? name ?? n.key ?? (n.from ? `${n.from} → ${n.to}` : null) ?? n.filename ?? null;
31
+ const entry = n.collection && n.slug ? { collection: n.collection, slug: n.slug } : undefined;
32
+ const path = n.path ?? (entry ? entryPath(site, entry) : null) ?? n.from ?? null;
33
+ return { title: title ? String(title).slice(0, 200) : null, path };
34
+ }
@@ -58,6 +58,7 @@ import {
58
58
  untrustedEffectiveScopes,
59
59
  } from "@cloudhal/schedules";
60
60
 
61
+ import { titleOf } from "./release-titles.js";
61
62
 
62
63
  /** What a deployment provides for schedules (RFC-0008 §16). */
63
64
 
@@ -518,32 +519,6 @@ export function approvalState(r ) {
518
519
 
519
520
 
520
521
 
521
- function titleOf(node ) {
522
- const n = node
523
-
524
-
525
-
526
-
527
-
528
-
529
-
530
-
531
-
532
- ;
533
- if (!n) return { title: null, path: null };
534
- const name =
535
- typeof n.name === "string"
536
- ? n.name
537
- : n.name && typeof n.name === "object"
538
- ? (Object.values(n.name )[0] ?? null)
539
- : null;
540
- const title =
541
- n.title ?? name ?? n.key ?? (n.from ? `${n.from} → ${n.to}` : null) ?? n.filename ?? null;
542
- const path =
543
- n.path ?? (n.collection && n.slug ? `/${n.collection}/${n.slug}` : null) ?? n.from ?? null;
544
- return { title: title ? String(title).slice(0, 200) : null, path };
545
- }
546
-
547
522
  /** A release with its items' titles and paths, overlaps, locks and the request (§12 `get_release`). */
548
523
  export async function releaseView(
549
524
  deps ,
@@ -553,6 +528,7 @@ export async function releaseView(
553
528
  ) {
554
529
  const r = record.release;
555
530
  const overlaps = await deps.store.overlaps(r.siteId);
531
+ const site = await graph.getSite(r.siteId);
556
532
  // What the dependency closure added (§6.1 step 2): new nodes another item's target references.
557
533
  const referenced = new Set(record.items.flatMap((p) => (p.item.kind === "set" ? p.deps : [])));
558
534
  const closure = new Set(
@@ -569,7 +545,7 @@ export async function releaseView(
569
545
  nodeId: i.nodeId,
570
546
  nodeKind: i.nodeKind,
571
547
  kind: i.kind,
572
- ...titleOf(node),
548
+ ...titleOf(site, node),
573
549
  pinnedRev: i.kind === "set" ? i.target.rev : null,
574
550
  liveRev: i.base?.rev ?? null,
575
551
  closure: closure.has(i.nodeId),
@@ -98,6 +98,7 @@ const searchSiteTool = {
98
98
  };
99
99
  }
100
100
  return await searchSiteNodes(ctx.store, site.id, query, {
101
+ site,
101
102
  ...(kinds ? { kinds: kinds } : {}),
102
103
  ...(limit !== undefined ? { limit } : {}),
103
104
  });
@@ -9,6 +9,8 @@ Building or redesigning pages: call get_design first and follow the site's desig
9
9
 
10
10
  Categories and tags: before you file an article, call list_taxonomies (which taxonomies are required, how many terms an article takes, who may add terms) and list_terms for each one (or resolve_terms for the names you have in mind). Reuse existing terms: set them on create_entry / update_entry with \`terms\`, e.g. {"category": {"primary": "News"}, "tag": {"add": ["AI"]}}; ids, slugs, names and synonyms all work, and nothing is ever created implicitly. Propose a new tag with propose_term only when no existing term fits; it stays private until a person approves it. Categories are added by people only: if none fits, say so and ask. A review or published article needs a primary term in every required taxonomy. Renaming, merging, retiring or moving terms, taxonomy settings and redirects (site paths only) always wait for a person; taxonomy_report suggests clean-ups to propose to them.
11
11
 
12
+ Entry URLs: an entry lives at its collection's permalink (get_site → \`collections\`; /<collection>/{slug} by default). set_collection_permalink moves a whole collection (e.g. posts to /blog/{slug}) and leaves a 301 from the old URLs; it always waits for a person, so call it with dryRun: true first and show them the URLs that move.
13
+
12
14
  Corrections: when a published article changes in substance, say so with add_correction (correction, clarification or update) instead of editing silently. Notices that are live cannot be removed or reworded by you, and publishing a new one always waits for a person.
13
15
 
14
16
  Modes: get_mode tells you how independently you work right now. If a task needs more autonomy for a while (e.g. publishing a series of small updates), call request_elevation with the mode, the minutes and a one-sentence reason; a person decides in Studio, and once granted your next call runs in that mode until the time is up. Ask only for what the task needs.
package/dist/src/tools.js CHANGED
@@ -38,6 +38,7 @@ import { elevationTools } from "./elevation-tools.js";
38
38
  import { entryTools } from "./entry-tools.js";
39
39
  import { menuTools } from "./menu-tools.js";
40
40
  import { pageRemovalTools, siteAndPageTools } from "./page-tools.js";
41
+ import { permalinkTools } from "./permalink-tools.js";
41
42
  import { previewDoc } from "./preview-doc.js";
42
43
  import { ownOnlyPublish, publishTools } from "./publish-tools.js";
43
44
  import { renderTools } from "./render-tools.js";
@@ -85,6 +86,8 @@ export function defineTools() {
85
86
  // Taxonomy, term and redirect tools (RFC-0002 §6.2), then menu tools (RFC-0003 §6.1) and
86
87
  // media tools (RFC-0004 §6.2), follow the article tools.
87
88
  ...taxonomyTools(),
89
+ // RFC-0038 §5: where a collection's entries live (always a person's decision).
90
+ ...permalinkTools(),
88
91
  ...menuTools(),
89
92
  ...assetTools(),
90
93
  ...publishTools(),
@@ -111,6 +114,7 @@ export function toolPolicies(tools ) {
111
114
  ...(t.own ? { own: t.own } : {}),
112
115
  ...(t.classify ? { classify: t.classify } : {}),
113
116
  ...(t.proposeScopes ? { proposeScopes: t.proposeScopes } : {}),
117
+ ...(t.approverScopes ? { approverScopes: t.approverScopes } : {}),
114
118
  }));
115
119
  }
116
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudhal/mcp-server",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "Cloudhal MCP server: semantic site tools (pages, articles, snapshots, preview, publish) governed by the policy engine",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://cloudhal.dev",
@@ -56,15 +56,15 @@
56
56
  "README.md"
57
57
  ],
58
58
  "dependencies": {
59
- "@cloudhal/analytics": "0.3.10",
60
- "@cloudhal/agent-runtime": "0.3.10",
61
- "@cloudhal/astro-renderer": "0.3.10",
62
- "@cloudhal/comments": "0.3.10",
63
- "@cloudhal/core-contracts": "0.3.10",
64
- "@cloudhal/core-ts": "0.3.10",
65
- "@cloudhal/storage": "0.3.10",
59
+ "@cloudhal/analytics": "0.3.12",
60
+ "@cloudhal/agent-runtime": "0.3.12",
61
+ "@cloudhal/astro-renderer": "0.3.12",
62
+ "@cloudhal/comments": "0.3.12",
63
+ "@cloudhal/core-contracts": "0.3.12",
64
+ "@cloudhal/core-ts": "0.3.12",
65
+ "@cloudhal/storage": "0.3.12",
66
66
  "@modelcontextprotocol/server": "2.3.1",
67
- "@cloudhal/schedules": "0.3.10"
67
+ "@cloudhal/schedules": "0.3.12"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@cloudflare/workers-types": "^5.20261007.1",