@wootsup/yt-builder-mcp 1.2.0 → 1.3.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.
- package/README.md +15 -11
- package/dist/catalog/build-catalog.d.ts +63 -0
- package/dist/catalog/build-catalog.d.ts.map +1 -0
- package/dist/catalog/build-catalog.js +166 -0
- package/dist/catalog/build-catalog.js.map +1 -0
- package/dist/gateway/advanced-read-tool.d.ts +37 -0
- package/dist/gateway/advanced-read-tool.d.ts.map +1 -0
- package/dist/gateway/advanced-read-tool.js +156 -0
- package/dist/gateway/advanced-read-tool.js.map +1 -0
- package/dist/gateway/advanced-tool/domains.d.ts +18 -3
- package/dist/gateway/advanced-tool/domains.d.ts.map +1 -1
- package/dist/gateway/advanced-tool/domains.js +28 -9
- package/dist/gateway/advanced-tool/domains.js.map +1 -1
- package/dist/gateway/advanced-tool/register.d.ts.map +1 -1
- package/dist/gateway/advanced-tool/register.js +43 -11
- package/dist/gateway/advanced-tool/register.js.map +1 -1
- package/dist/gateway/essentials.d.ts +14 -4
- package/dist/gateway/essentials.d.ts.map +1 -1
- package/dist/gateway/essentials.js +41 -5
- package/dist/gateway/essentials.js.map +1 -1
- package/dist/gateway/test-support.d.ts +2 -2
- package/dist/gateway/test-support.js +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/install-skill.js +1 -1
- package/dist/proxy/bridge.d.ts +36 -0
- package/dist/proxy/bridge.d.ts.map +1 -0
- package/dist/proxy/bridge.js +129 -0
- package/dist/proxy/bridge.js.map +1 -0
- package/dist/proxy/mode.d.ts +10 -0
- package/dist/proxy/mode.d.ts.map +1 -0
- package/dist/proxy/mode.js +20 -0
- package/dist/proxy/mode.js.map +1 -0
- package/dist/server.d.ts +5 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +13 -3
- package/dist/server.js.map +1 -1
- package/dist/setup-wizard.d.ts.map +1 -1
- package/dist/setup-wizard.js +7 -0
- package/dist/setup-wizard.js.map +1 -1
- package/dist/sites/client-pool.d.ts.map +1 -1
- package/dist/sites/client-pool.js +21 -3
- package/dist/sites/client-pool.js.map +1 -1
- package/dist/sites/registry.d.ts +30 -0
- package/dist/sites/registry.d.ts.map +1 -1
- package/dist/sites/registry.js.map +1 -1
- package/dist/sites/store.d.ts +8 -1
- package/dist/sites/store.d.ts.map +1 -1
- package/dist/sites/store.js +17 -2
- package/dist/sites/store.js.map +1 -1
- package/dist/sites/tools/use-site.d.ts.map +1 -1
- package/dist/sites/tools/use-site.js +26 -6
- package/dist/sites/tools/use-site.js.map +1 -1
- package/dist/tools/bind-guidance.d.ts +80 -0
- package/dist/tools/bind-guidance.d.ts.map +1 -0
- package/dist/tools/bind-guidance.js +95 -0
- package/dist/tools/bind-guidance.js.map +1 -0
- package/dist/tools/elements/builders.d.ts.map +1 -1
- package/dist/tools/elements/builders.js +59 -11
- package/dist/tools/elements/builders.js.map +1 -1
- package/dist/tools/elements/handlers-write.d.ts +19 -2
- package/dist/tools/elements/handlers-write.d.ts.map +1 -1
- package/dist/tools/elements/handlers-write.js +179 -10
- package/dist/tools/elements/handlers-write.js.map +1 -1
- package/dist/tools/elements/handlers.d.ts +6 -1
- package/dist/tools/elements/handlers.d.ts.map +1 -1
- package/dist/tools/elements/handlers.js +74 -7
- package/dist/tools/elements/handlers.js.map +1 -1
- package/dist/tools/elements/layout-hierarchy-rules.d.ts +62 -0
- package/dist/tools/elements/layout-hierarchy-rules.d.ts.map +1 -0
- package/dist/tools/elements/layout-hierarchy-rules.js +154 -0
- package/dist/tools/elements/layout-hierarchy-rules.js.map +1 -0
- package/dist/tools/format/elements-format.d.ts +35 -0
- package/dist/tools/format/elements-format.d.ts.map +1 -1
- package/dist/tools/format/elements-format.js +124 -1
- package/dist/tools/format/elements-format.js.map +1 -1
- package/dist/tools/format/inspection-format.d.ts +18 -0
- package/dist/tools/format/inspection-format.d.ts.map +1 -1
- package/dist/tools/format/inspection-format.js +22 -1
- package/dist/tools/format/inspection-format.js.map +1 -1
- package/dist/tools/format/pages-format.d.ts.map +1 -1
- package/dist/tools/format/pages-format.js +7 -0
- package/dist/tools/format/pages-format.js.map +1 -1
- package/dist/tools/format/sources-format.d.ts +8 -0
- package/dist/tools/format/sources-format.d.ts.map +1 -1
- package/dist/tools/format/sources-format.js +10 -0
- package/dist/tools/format/sources-format.js.map +1 -1
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/health.js +24 -0
- package/dist/tools/health.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/inspection.d.ts +24 -0
- package/dist/tools/inspection.d.ts.map +1 -1
- package/dist/tools/inspection.js +140 -41
- package/dist/tools/inspection.js.map +1 -1
- package/dist/tools/layout-flatten.d.ts +11 -8
- package/dist/tools/layout-flatten.d.ts.map +1 -1
- package/dist/tools/layout-flatten.js +17 -6
- package/dist/tools/layout-flatten.js.map +1 -1
- package/dist/tools/multi-items/builders.d.ts.map +1 -1
- package/dist/tools/multi-items/builders.js +11 -2
- package/dist/tools/multi-items/builders.js.map +1 -1
- package/dist/tools/multi-items/inspect-handler.d.ts +13 -0
- package/dist/tools/multi-items/inspect-handler.d.ts.map +1 -1
- package/dist/tools/multi-items/inspect-handler.js +147 -3
- package/dist/tools/multi-items/inspect-handler.js.map +1 -1
- package/dist/tools/pages/builders.d.ts.map +1 -1
- package/dist/tools/pages/builders.js +88 -25
- package/dist/tools/pages/builders.js.map +1 -1
- package/dist/tools/pages/handlers-read.d.ts +5 -1
- package/dist/tools/pages/handlers-read.d.ts.map +1 -1
- package/dist/tools/pages/handlers-read.js +192 -47
- package/dist/tools/pages/handlers-read.js.map +1 -1
- package/dist/tools/pages/handlers-write.d.ts +95 -1
- package/dist/tools/pages/handlers-write.d.ts.map +1 -1
- package/dist/tools/pages/handlers-write.js +137 -8
- package/dist/tools/pages/handlers-write.js.map +1 -1
- package/dist/tools/pages/index.d.ts +1 -1
- package/dist/tools/pages/index.d.ts.map +1 -1
- package/dist/tools/pages/index.js +1 -1
- package/dist/tools/pages/index.js.map +1 -1
- package/dist/tools/pages/schemas.d.ts +54 -0
- package/dist/tools/pages/schemas.d.ts.map +1 -1
- package/dist/tools/pages/schemas.js +199 -2
- package/dist/tools/pages/schemas.js.map +1 -1
- package/dist/tools/shared-schemas.d.ts.map +1 -1
- package/dist/tools/shared-schemas.js +15 -13
- package/dist/tools/shared-schemas.js.map +1 -1
- package/dist/tools/sources/builders.d.ts.map +1 -1
- package/dist/tools/sources/builders.js +64 -6
- package/dist/tools/sources/builders.js.map +1 -1
- package/dist/tools/sources/handlers-bind.d.ts +13 -1
- package/dist/tools/sources/handlers-bind.d.ts.map +1 -1
- package/dist/tools/sources/handlers-bind.js +163 -1
- package/dist/tools/sources/handlers-bind.js.map +1 -1
- package/dist/tools/sources/handlers.d.ts +3 -0
- package/dist/tools/sources/handlers.d.ts.map +1 -1
- package/dist/tools/sources/handlers.js +43 -6
- package/dist/tools/sources/handlers.js.map +1 -1
- package/dist/tools/sparse-fields.d.ts +23 -0
- package/dist/tools/sparse-fields.d.ts.map +1 -1
- package/dist/tools/sparse-fields.js +29 -0
- package/dist/tools/sparse-fields.js.map +1 -1
- package/dist/tools/sublayout/builders.d.ts +23 -0
- package/dist/tools/sublayout/builders.d.ts.map +1 -0
- package/dist/tools/sublayout/builders.js +54 -0
- package/dist/tools/sublayout/builders.js.map +1 -0
- package/dist/tools/sublayout/index.d.ts +13 -0
- package/dist/tools/sublayout/index.d.ts.map +1 -0
- package/dist/tools/sublayout/index.js +13 -0
- package/dist/tools/sublayout/index.js.map +1 -0
- package/dist/tools/sublayout/inspect-sublayout-handler.d.ts +95 -0
- package/dist/tools/sublayout/inspect-sublayout-handler.d.ts.map +1 -0
- package/dist/tools/sublayout/inspect-sublayout-handler.js +181 -0
- package/dist/tools/sublayout/inspect-sublayout-handler.js.map +1 -0
- package/dist/tools/tool-builder/results.d.ts +31 -0
- package/dist/tools/tool-builder/results.d.ts.map +1 -1
- package/dist/tools/tool-builder/results.js +95 -4
- package/dist/tools/tool-builder/results.js.map +1 -1
- package/manifest.json +1 -1
- package/package.json +4 -2
- package/skills/yt-builder-mcp/SKILL.md +146 -81
|
@@ -11,7 +11,7 @@ import { detailResult, tableResult } from '@getimo/mcp-toolkit';
|
|
|
11
11
|
import { encodeTemplateId } from '../../client.js';
|
|
12
12
|
import { flattenLayout } from '../layout-flatten.js';
|
|
13
13
|
import { PAGES_COMPACT_COLUMNS, PAGES_TABLE_COLUMNS, SCHEMA_COMPACT_COLUMNS, SCHEMA_TABLE_COLUMNS, buildEtagDetail, buildSchemaRows, mapPageRow, } from '../format/pages-format.js';
|
|
14
|
-
import { DEFAULT_FIELDS_PAGES_LIST, projectFields, projectedFieldsEcho, projectionFeedback, } from '../sparse-fields.js';
|
|
14
|
+
import { DEFAULT_FIELDS_PAGES_LIST, projectFields, projectedFieldsEcho, projectionFeedback, projectionWarning, } from '../sparse-fields.js';
|
|
15
15
|
import { errorResult, jsonResult, structuredResult, } from '../tool-builder.js';
|
|
16
16
|
// ─── pages_list ─────────────────────────────────────────────────────
|
|
17
17
|
export async function handlePagesList(client, { fields }) {
|
|
@@ -28,9 +28,8 @@ export async function handlePagesList(client, { fields }) {
|
|
|
28
28
|
const items = projectFields(mapped, fields, DEFAULT_FIELDS_PAGES_LIST);
|
|
29
29
|
const echo = projectedFieldsEcho(fields, DEFAULT_FIELDS_PAGES_LIST);
|
|
30
30
|
const feedback = projectionFeedback(mapped, fields);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
: '';
|
|
31
|
+
// F23 (2026-06-09): shared loud-warning helper.
|
|
32
|
+
const unknownNote = projectionWarning(feedback);
|
|
34
33
|
const toolkitResult = tableResult(mapped, {
|
|
35
34
|
columns: [...PAGES_TABLE_COLUMNS],
|
|
36
35
|
compactColumns: [...PAGES_COMPACT_COLUMNS],
|
|
@@ -45,6 +44,7 @@ export async function handlePagesList(client, { fields }) {
|
|
|
45
44
|
...(feedback !== undefined ? {
|
|
46
45
|
available_fields: [...feedback.available_fields],
|
|
47
46
|
unknown_fields: [...feedback.unknown_fields],
|
|
47
|
+
...(unknownNote.trim() !== '' ? { projection_warning: unknownNote.trim() } : {}),
|
|
48
48
|
} : {}),
|
|
49
49
|
});
|
|
50
50
|
}
|
|
@@ -57,9 +57,129 @@ export async function handlePagesList(client, { fields }) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
// ─── page_get_layout ────────────────────────────────────────────────
|
|
60
|
-
|
|
60
|
+
/**
|
|
61
|
+
* F195 (P0, 2026-06-12) — per-process layout-read dedup cache.
|
|
62
|
+
*
|
|
63
|
+
* The Desktop-E2E #2 forensic showed two identical 84 KB full-layout dumps in
|
|
64
|
+
* a single session (58 % of the 330 KB output budget). The same agent re-read
|
|
65
|
+
* the SAME template at the SAME state — the second dump was pure waste. This
|
|
66
|
+
* module-internal cache records, keyed by `site|template_id`, the LAST etag
|
|
67
|
+
* served as a FULL read. On a subsequent full read whose server-returned etag
|
|
68
|
+
* matches, the handler short-circuits with a one-line `[unchanged]` notice
|
|
69
|
+
* instead of re-emitting the body. `force:true` bypasses; bindings_only reads
|
|
70
|
+
* are never deduped (they are already cheap and are the recommended path).
|
|
71
|
+
*
|
|
72
|
+
* Cache key includes the site so multi-site sessions never cross-contaminate.
|
|
73
|
+
* It is a plain module Map (process-scoped) — exactly the granularity the
|
|
74
|
+
* forensic targets (duplicate reads within one MCP session).
|
|
75
|
+
*/
|
|
76
|
+
const layoutDedupCache = new Map();
|
|
77
|
+
/** Test-only: clear the dedup cache between cases (mirrors the bus reset idiom). */
|
|
78
|
+
export function __resetLayoutDedupCacheForTests() {
|
|
79
|
+
layoutDedupCache.clear();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Single SSoT unwrap rule for `page_get_layout(flat:true)`.
|
|
83
|
+
*
|
|
84
|
+
* flattenLayout iterates the TOP-LEVEL ENTRIES of whatever it is given.
|
|
85
|
+
* That is correct for a *container* (an array, or an index-keyed object
|
|
86
|
+
* `{0:{...},1:{...}}`) where every entry is itself an element node. It
|
|
87
|
+
* is WRONG for a single root NODE (`{type:'layout', children:[...]}`),
|
|
88
|
+
* whose top-level entries are `type` / `children` / `version` — not
|
|
89
|
+
* element nodes. Handing a root node straight to flattenLayout emits
|
|
90
|
+
* nothing (the C4 / Wave-9 F7 silent-`elements:[]` bug class).
|
|
91
|
+
*
|
|
92
|
+
* Rule: a value that looks like a single root node (`type === 'layout'`
|
|
93
|
+
* with an array `children`) is unwrapped to its `.children` array; any
|
|
94
|
+
* other value passes through untouched so containers and the legacy
|
|
95
|
+
* index-keyed object shape keep working unchanged.
|
|
96
|
+
*/
|
|
97
|
+
function unwrapToWalkableContainer(value) {
|
|
98
|
+
if (value !== null &&
|
|
99
|
+
typeof value === 'object' &&
|
|
100
|
+
!Array.isArray(value)) {
|
|
101
|
+
const obj = value;
|
|
102
|
+
if (obj.type === 'layout' && Array.isArray(obj.children)) {
|
|
103
|
+
return obj.children;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Decide whether a ZERO-element flatten should surface the C4
|
|
110
|
+
* "layout shape not recognized" warning.
|
|
111
|
+
*
|
|
112
|
+
* The decision runs on the RESOLVED walk container (`layoutRoot`, the value
|
|
113
|
+
* actually handed to `flattenLayout` after `unwrapToWalkableContainer`),
|
|
114
|
+
* NOT the raw `data.layout` envelope. That is the F29 calibration
|
|
115
|
+
* (2026-06-10):
|
|
116
|
+
*
|
|
117
|
+
* - An ARRAY (empty or otherwise) is a recognized container shape. A
|
|
118
|
+
* bare root node `{type:'layout', children:[]}` (a freshly-created
|
|
119
|
+
* empty article / per-page layout, or a fresh empty theme template)
|
|
120
|
+
* unwraps to its empty `.children` array, so it lands here and is
|
|
121
|
+
* treated as a GENUINELY empty page → NO warning. This kills the
|
|
122
|
+
* false-positive the raw-envelope check produced (the bare root node
|
|
123
|
+
* is a non-empty OBJECT — keys `type`/`children` — so the old check
|
|
124
|
+
* mistook "empty container" for "had content").
|
|
125
|
+
* - An OBJECT with ZERO keys (e.g. an empty index-keyed container `{}`)
|
|
126
|
+
* is also genuinely empty → NO warning.
|
|
127
|
+
* - An OBJECT with keys that nonetheless flattened to nothing is an
|
|
128
|
+
* unrecognized / future shape masquerading as empty → WARN (the
|
|
129
|
+
* original C4 contract; the `{some_future_key, another}` fixture).
|
|
130
|
+
*
|
|
131
|
+
* @param layoutRoot The resolved walk container passed to flattenLayout.
|
|
132
|
+
*/
|
|
133
|
+
function isUnrecognizedNonEmptyLayout(layoutRoot) {
|
|
134
|
+
if (Array.isArray(layoutRoot)) {
|
|
135
|
+
// Recognized container shape — empty or not, never "unrecognized".
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
if (layoutRoot !== null && typeof layoutRoot === 'object') {
|
|
139
|
+
// A non-empty object that produced zero elements is the
|
|
140
|
+
// unrecognized-shape case worth warning about; an empty object is
|
|
141
|
+
// a genuinely empty container.
|
|
142
|
+
return Object.keys(layoutRoot).length > 0;
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
export async function handlePageGetLayout(client, { template_id, flat, fields, mode, force }) {
|
|
61
147
|
try {
|
|
62
|
-
|
|
148
|
+
// F195 (P0): forward `mode=bindings_only` so the server returns the
|
|
149
|
+
// trimmed binding skeleton the dynamize/bind workflow needs. `full`
|
|
150
|
+
// (default) appends no query param — byte-identical to the pre-F195
|
|
151
|
+
// request shape.
|
|
152
|
+
const isBindingsOnly = mode === 'bindings_only';
|
|
153
|
+
const query = isBindingsOnly ? '?mode=bindings_only' : '';
|
|
154
|
+
const data = await client.get(`/pages/${encodeTemplateId(template_id)}/layout${query}`);
|
|
155
|
+
// F195 (P0): per-process dedup of REPEATED full reads. bindings_only
|
|
156
|
+
// is already cheap (and the recommended path), so it is never deduped.
|
|
157
|
+
// The skeleton passes straight through unchanged.
|
|
158
|
+
if (isBindingsOnly) {
|
|
159
|
+
return jsonResult(data);
|
|
160
|
+
}
|
|
161
|
+
const etag = typeof data.etag === 'string' ? data.etag : undefined;
|
|
162
|
+
const dedupKey = `${client.getPlatform().baseUrl}|${template_id}`;
|
|
163
|
+
if (force !== true && flat !== true && etag !== undefined) {
|
|
164
|
+
const lastServed = layoutDedupCache.get(dedupKey);
|
|
165
|
+
if (lastServed === etag) {
|
|
166
|
+
// Identical (template, etag) already emitted this process —
|
|
167
|
+
// skip the re-dump (the forensic's duplicate-84KB waste).
|
|
168
|
+
return jsonResult({
|
|
169
|
+
unchanged: true,
|
|
170
|
+
template_id,
|
|
171
|
+
etag,
|
|
172
|
+
note: `[unchanged] layout identical to your previous read (etag ${etag}) — ` +
|
|
173
|
+
're-read skipped; pass force:true to re-fetch.',
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Record the etag served for this (nested) full read so a later
|
|
178
|
+
// identical read can be short-circuited. Only nested full reads are
|
|
179
|
+
// tracked — flat/projected reads have a different downstream shape.
|
|
180
|
+
if (flat !== true && etag !== undefined) {
|
|
181
|
+
layoutDedupCache.set(dedupKey, etag);
|
|
182
|
+
}
|
|
63
183
|
if (flat !== true) {
|
|
64
184
|
// Default: nested passthrough — unchanged from pre-G.3.
|
|
65
185
|
return jsonResult(data);
|
|
@@ -68,35 +188,42 @@ export async function handlePageGetLayout(client, { template_id, flat, fields })
|
|
|
68
188
|
// pickFields per element when `fields[]` was passed; echo the
|
|
69
189
|
// projection so the AI knows the per-item shape it received.
|
|
70
190
|
//
|
|
71
|
-
//
|
|
72
|
-
// flatten to the same element list
|
|
191
|
+
// Several distinct envelope shapes reach this handler — all must
|
|
192
|
+
// flatten to the same element list. Resolution funnels through
|
|
193
|
+
// ONE rule (`unwrapToWalkableContainer`) so a single root NODE
|
|
194
|
+
// (`{type:'layout', children:[...]}`) is never handed to
|
|
195
|
+
// flattenLayout directly:
|
|
73
196
|
//
|
|
74
|
-
// (A) Theme templates: `data.layout = {
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
//
|
|
197
|
+
// (A) Theme templates: `data.layout = {query, type:'single-post',
|
|
198
|
+
// name:'Post', layout:{type:'layout', children:[...],
|
|
199
|
+
// version}}` — the actual node tree lives under the INNER
|
|
200
|
+
// `layout` field. That inner value is itself a single root
|
|
201
|
+
// NODE (not the index-keyed `{0:{...}}` container the older
|
|
202
|
+
// fixtures assumed). Handing the root node to flattenLayout
|
|
203
|
+
// made it iterate the node's OWN top-level entries
|
|
204
|
+
// (`['type',...]`, `['children',[...]]`, `['version',...]`)
|
|
205
|
+
// and emit nothing — `elements:[]` silently (C4 fix,
|
|
206
|
+
// 2026-06-09; verified on wp-dev5 template bFIb-syj). The
|
|
207
|
+
// inner-root-node case is now unwrapped to its `.children`,
|
|
208
|
+
// unifying it with the per-page path below.
|
|
209
|
+
//
|
|
210
|
+
// Legacy F-208 shape `{name, layout:{0:{...},1:{...}}}`
|
|
211
|
+
// (index-keyed inner container) still works: the inner
|
|
212
|
+
// value is NOT a root node, so it passes through to
|
|
213
|
+
// flattenLayout unchanged.
|
|
80
214
|
//
|
|
81
215
|
// (B) Per-page templates (Wave-9 F7 fix, 2026-05-29): cold-AI
|
|
82
216
|
// #8 reported `elements:[]` for a non-empty per-page
|
|
83
|
-
// template.
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
// `layout` key, so for per-page it fell through to
|
|
89
|
-
// walking `data.layout` directly, where flattenLayout
|
|
90
|
-
// iterates top-level entries (`['type', 'layout']` +
|
|
91
|
-
// `['children', [...]]`) and emits nothing — neither
|
|
92
|
-
// entry is a valid element node.
|
|
217
|
+
// template. Per-page layouts come from PerPageLayoutEncoder
|
|
218
|
+
// which decodes to the BARE root node
|
|
219
|
+
// `{type:'layout', children:[{...},{...}]}` — NO outer
|
|
220
|
+
// `{name, layout:{...}}` wrapper. Same root-node unwrap
|
|
221
|
+
// rule as (A), applied at the top level.
|
|
93
222
|
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
// cold agents can copy them into element_path without
|
|
99
|
-
// further bookkeeping).
|
|
223
|
+
// The unwrap rule (single SSoT): if a value is a single root node
|
|
224
|
+
// (`type === 'layout'` with an array `children`), iterate its
|
|
225
|
+
// `.children` array so the walker sees real element nodes and
|
|
226
|
+
// paths anchor on `/layout/children/0`, `/layout/children/1`, …
|
|
100
227
|
const dataLayout = data.layout;
|
|
101
228
|
const isObjectNode = dataLayout !== null &&
|
|
102
229
|
typeof dataLayout === 'object' &&
|
|
@@ -106,35 +233,53 @@ export async function handlePageGetLayout(client, { template_id, flat, fields })
|
|
|
106
233
|
'layout' in layoutObj &&
|
|
107
234
|
layoutObj.layout !== null &&
|
|
108
235
|
typeof layoutObj.layout === 'object';
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
else if (isPerPageRootNode) {
|
|
118
|
-
// Shape (B) — per-page bare-layout-node. Iterate children
|
|
119
|
-
// directly so the walker sees real element nodes.
|
|
120
|
-
layoutRoot = layoutObj.children;
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
// Back-compat: assume already in walkable form.
|
|
124
|
-
layoutRoot = dataLayout;
|
|
125
|
-
}
|
|
236
|
+
// Resolve the candidate container ONE hop from the envelope:
|
|
237
|
+
// shape (A) descends into the inner `layout`; everything else
|
|
238
|
+
// starts from `data.layout` directly. Then funnel through the
|
|
239
|
+
// shared root-node unwrap so shapes (A) and (B) — and any future
|
|
240
|
+
// single-root-node envelope — collapse identically.
|
|
241
|
+
const candidate = hasInnerLayoutField ? layoutObj.layout : dataLayout;
|
|
242
|
+
const layoutRoot = unwrapToWalkableContainer(candidate);
|
|
126
243
|
const flatElements = flattenLayout(layoutRoot);
|
|
244
|
+
// Non-silent fallback (C4) + F29 calibration: if the walk yields
|
|
245
|
+
// ZERO elements AND the resolved walk container is an unrecognized
|
|
246
|
+
// NON-EMPTY shape, surface a warning so it can never pass silently.
|
|
247
|
+
// A genuinely empty container (an empty array — including a bare
|
|
248
|
+
// `{type:'layout', children:[]}` root that unwrapped to `[]` — or
|
|
249
|
+
// an empty object) is a real empty page and must NOT warn.
|
|
250
|
+
const warning = flatElements.length === 0 && isUnrecognizedNonEmptyLayout(layoutRoot)
|
|
251
|
+
? 'layout shape not recognized - flat view may be incomplete'
|
|
252
|
+
: undefined;
|
|
127
253
|
const projected = projectFields(flatElements, fields,
|
|
128
254
|
// No default-set on layout.flat: keep "all" semantics
|
|
129
255
|
// unless caller opts-in. The echo helper below mirrors that.
|
|
130
256
|
[]);
|
|
131
257
|
const echo = projectedFieldsEcho(fields, undefined);
|
|
258
|
+
// F31 (2026-06-10): align the flat-projection path with F23 — when a
|
|
259
|
+
// caller-requested field appears on NO element (e.g. `label` on a
|
|
260
|
+
// YT4 layout), don't echo it in `projected_fields` with no signal.
|
|
261
|
+
// Compute the projection feedback over the FLAT element rows and
|
|
262
|
+
// surface `unknown_fields` + `available_fields` + a loud
|
|
263
|
+
// `projection_warning` (the shared F23 SSoT helper) so the agent can
|
|
264
|
+
// self-correct on the next call. Default-all callers (no fields[])
|
|
265
|
+
// get no audit overhead — projectionFeedback returns undefined.
|
|
266
|
+
const feedback = projectionFeedback(flatElements, fields);
|
|
267
|
+
const projectionNote = projectionWarning(feedback);
|
|
132
268
|
// 1.0.1 Wave-1.7 F-COLD-3: forward the canonical pointer base
|
|
133
269
|
// through the flat-projection path too so cold agents iterating
|
|
134
270
|
// with `flat: true` see the same hint they get on the nested
|
|
135
271
|
// default payload.
|
|
136
272
|
return jsonResult({
|
|
137
273
|
elements: projected,
|
|
274
|
+
...(warning !== undefined ? { warning } : {}),
|
|
275
|
+
...(feedback !== undefined ? {
|
|
276
|
+
available_fields: [...feedback.available_fields],
|
|
277
|
+
unknown_fields: [...feedback.unknown_fields],
|
|
278
|
+
} : {}),
|
|
279
|
+
// F31: trim the leading space the table-header helper prepends —
|
|
280
|
+
// here it rides in a JSON field, not a header string. Emitted
|
|
281
|
+
// ONLY when there's actually an unknown field to flag.
|
|
282
|
+
...(projectionNote !== '' ? { projection_warning: projectionNote.trimStart() } : {}),
|
|
138
283
|
...(typeof data.etag === 'string' ? { etag: data.etag } : {}),
|
|
139
284
|
...(typeof data.layout_root_pointer === 'string'
|
|
140
285
|
? { layout_root_pointer: data.layout_root_pointer }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers-read.js","sourceRoot":"","sources":["../../../src/tools/pages/handlers-read.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAmB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACH,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,UAAU,GACb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACH,yBAAyB,EACzB,aAAa,EACb,mBAAmB,EACnB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"handlers-read.js","sourceRoot":"","sources":["../../../src/tools/pages/handlers-read.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAmB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACH,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,e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CAAC,CAAC;IACP,CAAC;AACL,CAAC"}
|
|
@@ -17,7 +17,17 @@ interface SavePublishInput {
|
|
|
17
17
|
template_id: string;
|
|
18
18
|
etag?: string;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
interface SaveInput extends SavePublishInput {
|
|
21
|
+
/**
|
|
22
|
+
* F85 (2026-06-10): optional whole-layout atomic write. When supplied,
|
|
23
|
+
* the REST layer replaces the template tree (Layer-1 structural +
|
|
24
|
+
* Layer-2 element-type whitelist validated, under the same ETag lock)
|
|
25
|
+
* instead of only re-running save-transforms. Lets a wholesale
|
|
26
|
+
* dynamization land in one call rather than element-by-element surgery.
|
|
27
|
+
*/
|
|
28
|
+
layout?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export declare function handlePageSave(client: RestClient, { template_id, etag, layout }: SaveInput, extra?: HandlerExtra): Promise<ToolResult>;
|
|
21
31
|
export declare function handlePagePublish(client: RestClient, { template_id, etag }: SavePublishInput, extra?: HandlerExtra): Promise<ToolResult>;
|
|
22
32
|
/**
|
|
23
33
|
* Input shape for the `pages_create` handler. Mirrors the Zod schema
|
|
@@ -31,7 +41,35 @@ interface PagesCreateInput {
|
|
|
31
41
|
readonly status?: 'publish' | 'draft' | 'pending' | 'private' | 'future';
|
|
32
42
|
readonly layout?: Record<string, unknown>;
|
|
33
43
|
readonly dry_run?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* F12 (2026-06-09): one-boolean publish shortcut. Maps to `status`
|
|
46
|
+
* before the REST call (the host has no `published` field). See
|
|
47
|
+
* {@link resolveCreateStatus}.
|
|
48
|
+
*/
|
|
49
|
+
readonly published?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* F64 (2026-06-10): Joomla-only — create a SEF menu-item route for
|
|
52
|
+
* the new article (true = hidden default menutype, string = explicit
|
|
53
|
+
* menutype). Passed through to the REST body verbatim.
|
|
54
|
+
*/
|
|
55
|
+
readonly menu_item?: boolean | string;
|
|
34
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* F12 (2026-06-09): collapse the friendly `published` boolean into the
|
|
59
|
+
* canonical `status` the PHP host understands.
|
|
60
|
+
*
|
|
61
|
+
* Precedence: an EXPLICIT `status` always wins — `published` is the
|
|
62
|
+
* ergonomic shortcut, not an override. So:
|
|
63
|
+
* - status given → use it verbatim (published ignored).
|
|
64
|
+
* - status absent + true → 'publish' (WP post_status=publish, Joomla state=1).
|
|
65
|
+
* - status absent + false/∅ → undefined (server applies its draft default).
|
|
66
|
+
*
|
|
67
|
+
* Returning `undefined` (rather than an explicit `'draft'`) for the
|
|
68
|
+
* default case preserves the existing wire shape — the server's Q6
|
|
69
|
+
* default-to-draft logic stays authoritative and the body byte-shape is
|
|
70
|
+
* unchanged for legacy callers that never sent `published`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveCreateStatus(status: PagesCreateInput['status'], published: boolean | undefined): PagesCreateInput['status'] | undefined;
|
|
35
73
|
/**
|
|
36
74
|
* `pages_create` — POST `/pages` with the provided body. On
|
|
37
75
|
* `dry_run:true`, the REST handler runs validation Layers 1+2+4
|
|
@@ -40,6 +78,62 @@ interface PagesCreateInput {
|
|
|
40
78
|
* `PAGES_CREATE_OUTPUT_SCHEMA`.
|
|
41
79
|
*/
|
|
42
80
|
export declare function handlePagesCreate(client: RestClient, input: PagesCreateInput, extra?: HandlerExtra): Promise<ToolResult>;
|
|
81
|
+
/**
|
|
82
|
+
* A single `leaf_map` value — string OR the F96 `{name, filters?}` shape.
|
|
83
|
+
* The handler forwards the whole `leaf_map` verbatim; the PHP
|
|
84
|
+
* LayoutDynamizer normalises + applies it.
|
|
85
|
+
*/
|
|
86
|
+
type DynamizeFieldMapping = string | {
|
|
87
|
+
name: string;
|
|
88
|
+
filters?: Record<string, unknown>;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Input shape for the `page_dynamize` handler. Mirrors the Zod
|
|
92
|
+
* `PAGE_DYNAMIZE_INPUT` in `./schemas.ts` — kept as a structural interface
|
|
93
|
+
* so the handler has no runtime Zod dependency and forwards whatever the
|
|
94
|
+
* MCP harness already validated.
|
|
95
|
+
*/
|
|
96
|
+
interface PageDynamizeInput {
|
|
97
|
+
readonly template_id: string;
|
|
98
|
+
readonly section_name?: string;
|
|
99
|
+
readonly element_path?: string;
|
|
100
|
+
readonly list_source_name?: string;
|
|
101
|
+
readonly source_map?: ReadonlyArray<{
|
|
102
|
+
readonly match: string;
|
|
103
|
+
readonly source_name: string;
|
|
104
|
+
readonly leaf_map?: Record<string, DynamizeFieldMapping>;
|
|
105
|
+
}>;
|
|
106
|
+
readonly leaf_map?: Record<string, DynamizeFieldMapping>;
|
|
107
|
+
readonly conditions?: Record<string, {
|
|
108
|
+
name: string;
|
|
109
|
+
filters: {
|
|
110
|
+
condition: '!' | '!!';
|
|
111
|
+
};
|
|
112
|
+
}>;
|
|
113
|
+
readonly remove_leaves?: readonly string[];
|
|
114
|
+
readonly page: {
|
|
115
|
+
readonly title: string;
|
|
116
|
+
readonly slug?: string;
|
|
117
|
+
readonly published?: boolean;
|
|
118
|
+
readonly status?: string;
|
|
119
|
+
readonly menu_item?: boolean | string;
|
|
120
|
+
};
|
|
121
|
+
readonly etag?: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* `page_dynamize` — POST `/pages/dynamize`. THE one-call canonical path to
|
|
125
|
+
* dynamize an existing designed section: the server copies the reference
|
|
126
|
+
* subtree byte-identically and swaps only the mapped queries + leaf
|
|
127
|
+
* field-names (the recipe of `dynamize-existing-layout.md` as CODE), then
|
|
128
|
+
* creates the page through the same hardened create path. The 201 carries
|
|
129
|
+
* a `summary` self-check ({queries_swapped, leaves_remapped, leaves_kept,
|
|
130
|
+
* leaves_removed, unmatched_map_keys, kept_unresolvable}). A non-empty
|
|
131
|
+
* `unmatched_map_keys` means the agent mapped a field the reference subtree
|
|
132
|
+
* never bound; a non-zero `kept_unresolvable.count` means a sub-query panel
|
|
133
|
+
* had no flow field (its leaves render empty) — extend leaf_map with the
|
|
134
|
+
* qualified "<subquery>.<leaf>" keys and retry.
|
|
135
|
+
*/
|
|
136
|
+
export declare function handlePageDynamize(client: RestClient, input: PageDynamizeInput, extra?: HandlerExtra): Promise<ToolResult>;
|
|
43
137
|
/**
|
|
44
138
|
* Input shape for the `pages_delete` handler. Mirrors the Zod schema
|
|
45
139
|
* `PAGES_DELETE_INPUT` in `./schemas.ts`. `confirm` is `true` literal —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers-write.d.ts","sourceRoot":"","sources":["../../../src/tools/pages/handlers-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAKH,KAAK,YAAY,EACjB,KAAK,UAAU,EAClB,MAAM,oBAAoB,CAAC;AAE5B,UAAU,gBAAgB;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,wBAAsB,cAAc,CAChC,MAAM,EAAE,UAAU,EAClB,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"handlers-write.d.ts","sourceRoot":"","sources":["../../../src/tools/pages/handlers-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAKH,KAAK,YAAY,EACjB,KAAK,UAAU,EAClB,MAAM,oBAAoB,CAAC;AAE5B,UAAU,gBAAgB;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,SAAU,SAAQ,gBAAgB;IACxC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAID,wBAAsB,cAAc,CAChC,MAAM,EAAE,UAAU,EACl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