@cloudhal/mcp-server 0.6.1 → 0.6.2
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.
- package/dist/src/entry-list.d.ts +3 -2
- package/dist/src/entry-list.js +23 -8
- package/dist/src/render/checks/components.d.ts +1 -1
- package/dist/src/render/checks/components.js +1 -1
- package/dist/src/render/checks/content.d.ts +1 -1
- package/dist/src/render/checks/content.js +2 -2
- package/dist/src/render/checks/contrast.d.ts +1 -1
- package/dist/src/render/checks/contrast.js +1 -1
- package/dist/src/render/checks/fonts.d.ts +1 -1
- package/dist/src/render/checks/fonts.js +1 -1
- package/dist/src/render/checks/index.js +4 -0
- package/dist/src/render/checks/layout.d.ts +1 -1
- package/dist/src/render/checks/layout.js +1 -1
- package/dist/src/render/checks/motion.d.ts +1 -1
- package/dist/src/render/checks/motion.js +1 -1
- package/dist/src/render/checks/navigation.d.ts +1 -1
- package/dist/src/render/checks/navigation.js +1 -1
- package/dist/src/render/checks/prelude.js +3 -3
- package/dist/src/render/checks/scripts.d.ts +2 -2
- package/dist/src/render/checks/scripts.js +2 -2
- package/package.json +11 -11
package/dist/src/entry-list.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* RFC-0042 §4 "API and MCP" for `list_entries`: `where` and `orderBy` over a collection's list
|
|
3
|
-
* fields, run by core-ts's shared evaluator (`queryContentEntries
|
|
4
|
-
*
|
|
3
|
+
* fields, run by core-ts's shared evaluator (`queryContentEntries`, in SQL while the collection's
|
|
4
|
+
* list values are ready), and `limit`/`cursor` paging: with `orderBy` the store pages, without it
|
|
5
|
+
* the list keeps its order (last updated first) and is paged here; without `limit` it is unpaged,
|
|
5
6
|
* as before. Problems are refused as `invalid_query` with their paths (`where/0/value`).
|
|
6
7
|
*/
|
|
7
8
|
import type { ContentEntry } from "@cloudhal/core-contracts";
|
package/dist/src/entry-list.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* RFC-0042 §4 "API and MCP" for `list_entries`: `where` and `orderBy` over a collection's list
|
|
3
|
-
* fields, run by core-ts's shared evaluator (`queryContentEntries
|
|
4
|
-
*
|
|
3
|
+
* fields, run by core-ts's shared evaluator (`queryContentEntries`, in SQL while the collection's
|
|
4
|
+
* list values are ready), and `limit`/`cursor` paging: with `orderBy` the store pages, without it
|
|
5
|
+
* the list keeps its order (last updated first) and is paged here; without `limit` it is unpaged,
|
|
5
6
|
* as before. Problems are refused as `invalid_query` with their paths (`where/0/value`).
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import { SiteSchema } from "@cloudhal/core-contracts";
|
|
9
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
ENTRY_PAGE_LIMIT,
|
|
12
|
+
|
|
13
|
+
InvariantError,
|
|
14
|
+
queryContentEntries,
|
|
15
|
+
} from "@cloudhal/core-ts";
|
|
10
16
|
|
|
11
17
|
|
|
12
18
|
const DEFS = SiteSchema.$defs ;
|
|
@@ -83,19 +89,28 @@ export async function listEntries(
|
|
|
83
89
|
if (base.collection === undefined && (where !== undefined || orderBy !== undefined))
|
|
84
90
|
refuse("collection", "where and orderBy need the collection whose list fields they use");
|
|
85
91
|
const offset = a.cursor === undefined ? 0 : decodeCursor(a.cursor );
|
|
86
|
-
|
|
92
|
+
// Ordered by a field, the store pages (in SQL once the collection's list values are ready);
|
|
93
|
+
// otherwise the list keeps its last-updated order, sorted here.
|
|
94
|
+
const paged =
|
|
95
|
+
orderBy !== undefined &&
|
|
96
|
+
Number.isInteger(limit) &&
|
|
97
|
+
(limit ) >= 1 &&
|
|
98
|
+
(limit ) <= ENTRY_PAGE_LIMIT;
|
|
99
|
+
const result = await queryContentEntries(ctx.store, siteId, {
|
|
87
100
|
...base,
|
|
88
101
|
...(where ? { where } : {}),
|
|
89
102
|
...(orderBy ? { orderBy } : {}),
|
|
103
|
+
...(paged ? { limit, offset } : {}),
|
|
90
104
|
now: (ctx.now?.() ?? new Date()).getTime(),
|
|
91
105
|
});
|
|
92
|
-
const ordered = orderBy ? entries : entries.sort(byUpdated);
|
|
106
|
+
const ordered = orderBy ? result.entries : result.entries.sort(byUpdated);
|
|
93
107
|
if (limit === undefined) return { entries: ordered };
|
|
94
|
-
const page = ordered.slice(offset, offset + limit);
|
|
108
|
+
const page = paged ? ordered : ordered.slice(offset, offset + limit);
|
|
109
|
+
const total = paged ? result.total : ordered.length;
|
|
95
110
|
const next = offset + page.length;
|
|
96
111
|
return {
|
|
97
112
|
entries: page,
|
|
98
|
-
total
|
|
99
|
-
...(next <
|
|
113
|
+
total,
|
|
114
|
+
...(next < total ? { nextCursor: encodeCursor(next) } : {}),
|
|
100
115
|
};
|
|
101
116
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: carousel-label / -lcp / -focus / -autoplay, image-fit, overlay-open; ends at the top of the page.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export declare const COMPONENT_CHECKS
|
|
5
|
+
export declare const COMPONENT_CHECKS: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: carousel-label / -lcp / -focus / -autoplay, image-fit, overlay-open; ends at the top of the page.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export const COMPONENT_CHECKS = ` // A static preview runs no scripts (its CSP), so checks of what a module does wait for the site.
|
|
5
|
+
export const COMPONENT_CHECKS = String.raw` // A static preview runs no scripts (its CSP), so checks of what a module does wait for the site.
|
|
6
6
|
const staticPreview = !!document.querySelector('meta[name="generator"][content="Cloudhal preview"]');
|
|
7
7
|
// carousel-label and carousel-lcp: named carousels and slides; a hero's first slide not lazy.
|
|
8
8
|
for (const c of document.querySelectorAll('[aria-roledescription="carousel"], [aria-roledescription="kaydırmalı alan"]')) {
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: empty-section, tap-target, input-label, chart-empty, long-line.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export declare const CONTENT_CHECKS
|
|
5
|
+
export declare const CONTENT_CHECKS: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: empty-section, tap-target, input-label, chart-empty, long-line.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export const CONTENT_CHECKS = ` // empty-section
|
|
5
|
+
export const CONTENT_CHECKS = String.raw` // empty-section
|
|
6
6
|
for (const s of document.querySelectorAll("[data-section-id]")) {
|
|
7
7
|
if (getComputedStyle(s).display === "none") continue;
|
|
8
8
|
const text = (s.innerText || "").trim();
|
|
@@ -41,7 +41,7 @@ export const CONTENT_CHECKS = ` // empty-section
|
|
|
41
41
|
if (!visible(el) && !(el.type === "radio" || el.type === "checkbox")) continue;
|
|
42
42
|
const named = [...(el.labels || [])].some((l) => (l.innerText || l.textContent || "").trim()) ||
|
|
43
43
|
(el.getAttribute("aria-label") || "").trim() ||
|
|
44
|
-
(el.getAttribute("aria-labelledby") || "").split(
|
|
44
|
+
(el.getAttribute("aria-labelledby") || "").split(/\s+/).some((id) => id && (document.getElementById(id)?.textContent || "").trim());
|
|
45
45
|
if (!named) add("input-label", el, "no label a screen reader can announce");
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: contrast: text against what is painted beneath it, band by band.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export declare const CONTRAST_CHECKS
|
|
5
|
+
export declare const CONTRAST_CHECKS: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: contrast: text against what is painted beneath it, band by band.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export const CONTRAST_CHECKS = ` // contrast: text against what is painted beneath it (elementsFromPoint), band by band.
|
|
5
|
+
export const CONTRAST_CHECKS = String.raw` // contrast: text against what is painted beneath it (elementsFromPoint), band by band.
|
|
6
6
|
const canvas = document.createElement("canvas");
|
|
7
7
|
canvas.width = canvas.height = 1;
|
|
8
8
|
const g = canvas.getContext("2d", { willReadFrequently: true });
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: font-fallback.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export declare const FONT_CHECKS
|
|
5
|
+
export declare const FONT_CHECKS: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: font-fallback.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export const FONT_CHECKS = ` // font-fallback (RFC-0023 §2): text set in a web font whose stack has no metric-matched fallback
|
|
5
|
+
export const FONT_CHECKS = String.raw` // font-fallback (RFC-0023 §2): text set in a web font whose stack has no metric-matched fallback
|
|
6
6
|
// right after it (a face with size-adjust or ascent-override). Without one, the text is first
|
|
7
7
|
// drawn in a system font of another size and moves when the web font arrives.
|
|
8
8
|
if (document.fonts) {
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* prelude defines the helpers (`add`, `describe`, `visible`, `imgs`, `W`, `H`); the motion part
|
|
7
7
|
* scrolls the page once and defines `frame`, which the navigation and component parts use; the
|
|
8
8
|
* component part ends back at the top. Keep the order.
|
|
9
|
+
*
|
|
10
|
+
* Every part is a `String.raw` template, so a backslash in the page's code (`/\s/`) reaches the
|
|
11
|
+
* page as written: in a plain template `\s` arrives as `s` and `\b` as a control character, and
|
|
12
|
+
* Biome's useless-escape fix deleted the backslash (test/render-script.test.ts checks this).
|
|
9
13
|
*/
|
|
10
14
|
import { COMPONENT_CHECKS } from "./components.js";
|
|
11
15
|
import { CONTENT_CHECKS } from "./content.js";
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: overflow-x, img-alt / img-broken, heading-order.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export declare const LAYOUT_CHECKS
|
|
5
|
+
export declare const LAYOUT_CHECKS: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: overflow-x, img-alt / img-broken, heading-order.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export const LAYOUT_CHECKS = ` // overflow-x: the outermost elements that stick out past the screen's right edge.
|
|
5
|
+
export const LAYOUT_CHECKS = String.raw` // overflow-x: the outermost elements that stick out past the screen's right edge.
|
|
6
6
|
const sw = document.documentElement.scrollWidth;
|
|
7
7
|
if (sw > W + 1) {
|
|
8
8
|
const clipped = (el) => {
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: The reader's scroll pass, then motion-cls, reduced-motion, motion-budget, flash; defines `frame`.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export declare const MOTION_CHECKS
|
|
5
|
+
export declare const MOTION_CHECKS: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: The reader's scroll pass, then motion-cls, reduced-motion, motion-budget, flash; defines `frame`.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export const MOTION_CHECKS = ` // RFC-0024 §8: scroll through the page once, as a reader would, so reveals play, then measure.
|
|
5
|
+
export const MOTION_CHECKS = String.raw` // RFC-0024 §8: scroll through the page once, as a reader would, so reveals play, then measure.
|
|
6
6
|
let shift = 0;
|
|
7
7
|
let po;
|
|
8
8
|
try {
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: skip-link, landmarks, header-contrast, focus-obscured.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export declare const NAVIGATION_CHECKS
|
|
5
|
+
export declare const NAVIGATION_CHECKS: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* In-page checks, part of `RENDER_CHECK_SCRIPT`: skip-link, landmarks, header-contrast, focus-obscured.
|
|
3
3
|
* Plain source text, run inside the page; it shares the script's locals (see ./index.ts).
|
|
4
4
|
*/
|
|
5
|
-
export const NAVIGATION_CHECKS = ` // skip-link: the first focusable element is a link to the main content (or inside it).
|
|
5
|
+
export const NAVIGATION_CHECKS = String.raw` // skip-link: the first focusable element is a link to the main content (or inside it).
|
|
6
6
|
const shown = (e) => e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden";
|
|
7
7
|
const focusables = [...document.querySelectorAll('a[href],button,input,select,textarea,summary,[tabindex]:not([tabindex="-1"])')]
|
|
8
8
|
.filter((e) => !e.disabled && !e.closest("[inert],dialog:not([open]),[popover]:not(:popover-open)") && shown(e));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { RENDER_CHECK_IDS } from "../types.js";
|
|
6
6
|
|
|
7
|
-
export const PRELUDE = ` const W = document.documentElement.clientWidth || window.innerWidth, H = window.innerHeight, MAX = 5;
|
|
7
|
+
export const PRELUDE = String.raw` const W = document.documentElement.clientWidth || window.innerWidth, H = window.innerHeight, MAX = 5;
|
|
8
8
|
const ids = ${JSON.stringify(RENDER_CHECK_IDS)};
|
|
9
9
|
const out = Object.fromEntries(ids.map((id) => [id, { id, count: 0, examples: [] }]));
|
|
10
10
|
const clip = (s, n) => (s.length > n ? s.slice(0, n - 1) + "…" : s);
|
|
@@ -22,9 +22,9 @@ export const PRELUDE = ` const W = document.documentElement.clientWidth || wind
|
|
|
22
22
|
let tag = el.tagName.toLowerCase();
|
|
23
23
|
if (el.id) tag += "#" + el.id;
|
|
24
24
|
else if (typeof el.className === "string" && el.className.trim())
|
|
25
|
-
tag += "." + el.className.trim().split(
|
|
25
|
+
tag += "." + el.className.trim().split(/\s+/).slice(0, 2).join(".");
|
|
26
26
|
parts.push(tag);
|
|
27
|
-
const text = ((el.innerText || "").trim() || el.getAttribute("alt") || el.getAttribute("src") || "").replace(
|
|
27
|
+
const text = ((el.innerText || "").trim() || el.getAttribute("alt") || el.getAttribute("src") || "").replace(/\s+/g, " ");
|
|
28
28
|
if (text) parts.push(JSON.stringify(clip(text, 48)));
|
|
29
29
|
return parts.join(" ");
|
|
30
30
|
};
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
* keeps the Content-Security-Policy violations the page raises while it loads, which the
|
|
8
8
|
* `script-blocked` check reads. Report-only ones (`cloudhal dev`) are kept too.
|
|
9
9
|
*/
|
|
10
|
-
export declare const CSP_LISTENER
|
|
11
|
-
export declare const SCRIPT_CHECKS
|
|
10
|
+
export declare const CSP_LISTENER: string;
|
|
11
|
+
export declare const SCRIPT_CHECKS: string;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* keeps the Content-Security-Policy violations the page raises while it loads, which the
|
|
9
9
|
* `script-blocked` check reads. Report-only ones (`cloudhal dev`) are kept too.
|
|
10
10
|
*/
|
|
11
|
-
export const CSP_LISTENER = `(() => {
|
|
11
|
+
export const CSP_LISTENER = String.raw`(() => {
|
|
12
12
|
const seen = (window.__chCsp = []);
|
|
13
13
|
window.addEventListener("securitypolicyviolation", (e) => {
|
|
14
14
|
if (seen.length < 50)
|
|
@@ -16,7 +16,7 @@ export const CSP_LISTENER = `(() => {
|
|
|
16
16
|
}, true);
|
|
17
17
|
})();`;
|
|
18
18
|
|
|
19
|
-
export const SCRIPT_CHECKS = ` // surface-broken: a body surface the preview could not draw (RFC-0020 §5), or a component in one
|
|
19
|
+
export const SCRIPT_CHECKS = String.raw` // surface-broken: a body surface the preview could not draw (RFC-0020 §5), or a component in one
|
|
20
20
|
// with an unknown block type or props that do not fit it. Theme blocks the preview leaves to the
|
|
21
21
|
// site are fine.
|
|
22
22
|
for (const el of document.querySelectorAll(".ch-surface-problem")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudhal/mcp-server",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
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,24 +56,24 @@
|
|
|
56
56
|
"README.md"
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@cloudhal/analytics": "0.6.
|
|
60
|
-
"@cloudhal/agent-runtime": "0.6.
|
|
61
|
-
"@cloudhal/astro-renderer": "0.6.
|
|
62
|
-
"@cloudhal/comments": "0.6.
|
|
63
|
-
"@cloudhal/core-contracts": "0.6.
|
|
64
|
-
"@cloudhal/core-ts": "0.6.
|
|
65
|
-
"@cloudhal/storage": "0.6.
|
|
59
|
+
"@cloudhal/analytics": "0.6.2",
|
|
60
|
+
"@cloudhal/agent-runtime": "0.6.2",
|
|
61
|
+
"@cloudhal/astro-renderer": "0.6.2",
|
|
62
|
+
"@cloudhal/comments": "0.6.2",
|
|
63
|
+
"@cloudhal/core-contracts": "0.6.2",
|
|
64
|
+
"@cloudhal/core-ts": "0.6.2",
|
|
65
|
+
"@cloudhal/storage": "0.6.2",
|
|
66
66
|
"@modelcontextprotocol/server": "2.3.1",
|
|
67
|
-
"@cloudhal/schedules": "0.6.
|
|
67
|
+
"@cloudhal/schedules": "0.6.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@cloudflare/workers-types": "^5.20261007.1",
|
|
71
71
|
"@modelcontextprotocol/client": "2.3.1",
|
|
72
72
|
"@types/node": "^26.6.5",
|
|
73
73
|
"better-sqlite3": "13.0.3",
|
|
74
|
-
"happy-dom": "^21.0.
|
|
74
|
+
"happy-dom": "^21.0.4",
|
|
75
75
|
"typescript": "7.0.2",
|
|
76
|
-
"vitest": "5.0.
|
|
76
|
+
"vitest": "5.0.5"
|
|
77
77
|
},
|
|
78
78
|
"engines": {
|
|
79
79
|
"node": ">=24"
|