@workover/mcp 0.19.0 → 0.21.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 +3 -0
- package/index.mjs +72 -1
- package/lib.mjs +134 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,8 +36,11 @@ production sign-in names the environment instead.
|
|
|
36
36
|
- `workover_upload_image(docId, path, alt)` — put a local image into a document's media
|
|
37
37
|
- `workover_list_images(docId, tabId?)` — the images in a document: file name, alt text and src
|
|
38
38
|
- `workover_set_image(docId, src, filename?, alt?)` — set an image's file name (its WordPress media name) and/or alt text, as the editor's Edit image dialog does. Needs `workover login --write`
|
|
39
|
+
- `workover_list_media(projectId, search?, filter?, source?, cursor?)` — the project's Media library: every image its documents use and every WordPress attachment, with usage, alt text and problems (no alt, oversized, broken, outdated)
|
|
40
|
+
- `workover_replace_media(projectId, assetId, replacementAssetId)` — raise one reviewed fix that swaps an image for another in every document that uses it. Needs `workover login --write`
|
|
39
41
|
- `workover_doc_status(docId, status?)` — read a document's Workover status and the statuses its workflow offers (with whether you may move it to each, and why not), or set it through the browser's rules: role, workflow gates, approvals. Needs `workover login --write`, plus `--publish` to or from Published. Does not publish to WordPress
|
|
40
42
|
- `workover_propose_edit(docId, markdown, note, tabId?, reasoning?)` — propose a revised version (rendered as suggestions; never applied or published automatically)
|
|
43
|
+
- `workover_suggestion_status(docId)` — the open suggestion: whether the editor has shown it, has not yet, or could not (and why)
|
|
41
44
|
- `workover_edit_doc(docId, markdown?, title?, note, tabId?)` — edit a document directly, no review step. Needs `workover login --write`. Pass `title` to rename it: with no `markdown` only the name changes and the body is left as it is. A `# Heading` in the markdown never renames a document
|
|
42
45
|
- `workover_style_guide(projectId?)` — the rules this team writes by
|
|
43
46
|
- `workover_add_style_rule(text, projectId | organizationId)` — add a rule. Needs `workover login --rules`
|
package/index.mjs
CHANGED
|
@@ -244,6 +244,67 @@ const TOOLS = [
|
|
|
244
244
|
required: ['docId', 'src'],
|
|
245
245
|
},
|
|
246
246
|
},
|
|
247
|
+
{
|
|
248
|
+
name: 'workover_list_media',
|
|
249
|
+
description:
|
|
250
|
+
"List a project's Media library: every image its documents use and, for a WordPress project, every attachment in the site's media library. Each line gives the asset id, file name, where it comes from (Workover or WordPress #id), how many documents use it, its alt text and any problem (no alt text, oversized, broken, outdated screenshot). Use it to find images to fix, and to find the asset ids workover_replace_media takes.",
|
|
251
|
+
inputSchema: {
|
|
252
|
+
type: 'object',
|
|
253
|
+
properties: {
|
|
254
|
+
projectId: {
|
|
255
|
+
type: 'number',
|
|
256
|
+
description: 'The project, as printed by workover_list_projects ("#7" → 7).',
|
|
257
|
+
},
|
|
258
|
+
search: { type: 'string', description: 'Match file names, titles, alt text and tags.' },
|
|
259
|
+
filter: {
|
|
260
|
+
type: 'string',
|
|
261
|
+
enum: [
|
|
262
|
+
'all',
|
|
263
|
+
'in_use',
|
|
264
|
+
'unused',
|
|
265
|
+
'attention',
|
|
266
|
+
'missing_alt',
|
|
267
|
+
'oversized',
|
|
268
|
+
'broken',
|
|
269
|
+
'stale',
|
|
270
|
+
'deleted',
|
|
271
|
+
],
|
|
272
|
+
description:
|
|
273
|
+
'"unused" means not found in imported content (WordPress themes and page builders are not visible to Workover). "attention" is any of missing_alt, oversized, broken and stale. Default "all".',
|
|
274
|
+
},
|
|
275
|
+
source: {
|
|
276
|
+
type: 'string',
|
|
277
|
+
enum: ['all', 'workover', 'wordpress'],
|
|
278
|
+
description: 'Only Workover uploads, or only WordPress attachments. Default both.',
|
|
279
|
+
},
|
|
280
|
+
cursor: {
|
|
281
|
+
type: 'number',
|
|
282
|
+
description: 'The cursor a previous page printed, for the next page.',
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
required: ['projectId'],
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: 'workover_replace_media',
|
|
290
|
+
description:
|
|
291
|
+
"Replace an image with another image from the same project's Media library, in every document that uses it (body images, featured and social images, WordPress block and attachment references). It changes nothing directly: it raises ONE fix for a person to review in the project's Health page (Findings), and accepting it is what rewrites the documents. The old image stays in the library. Take both ids from workover_list_media; to replace with a new file, upload it first with workover_upload_image. Requires a token from `workover login --write`.",
|
|
292
|
+
inputSchema: {
|
|
293
|
+
type: 'object',
|
|
294
|
+
properties: {
|
|
295
|
+
projectId: {
|
|
296
|
+
type: 'number',
|
|
297
|
+
description: 'The project, as printed by workover_list_projects ("#7" → 7).',
|
|
298
|
+
},
|
|
299
|
+
assetId: {
|
|
300
|
+
type: 'number',
|
|
301
|
+
description: 'The image to replace, as workover_list_media printed it.',
|
|
302
|
+
},
|
|
303
|
+
replacementAssetId: { type: 'number', description: 'The image to put in its place.' },
|
|
304
|
+
},
|
|
305
|
+
required: ['projectId', 'assetId', 'replacementAssetId'],
|
|
306
|
+
},
|
|
307
|
+
},
|
|
247
308
|
{
|
|
248
309
|
name: 'workover_doc_status',
|
|
249
310
|
description:
|
|
@@ -331,6 +392,16 @@ const TOOLS = [
|
|
|
331
392
|
required: ['docId', 'markdown'],
|
|
332
393
|
},
|
|
333
394
|
},
|
|
395
|
+
{
|
|
396
|
+
name: 'workover_suggestion_status',
|
|
397
|
+
description:
|
|
398
|
+
"Check on a document's open suggestion, the one workover_propose_edit raises: who raised it and when, and whether the editor has shown it as tracked changes, has not yet (it appears when someone who can review it opens the document), or could NOT show it, with the reason. A document has one open suggestion at a time; proposing again replaces its text. Use it after proposing, rather than assuming the suggestion is on the page.",
|
|
399
|
+
inputSchema: {
|
|
400
|
+
type: 'object',
|
|
401
|
+
properties: { docId: DOC_ARG },
|
|
402
|
+
required: ['docId'],
|
|
403
|
+
},
|
|
404
|
+
},
|
|
334
405
|
{
|
|
335
406
|
name: 'workover_report_feedback',
|
|
336
407
|
description: FEEDBACK_TOOL_DESCRIPTION,
|
|
@@ -576,7 +647,7 @@ const telemetry = telemetryEnabled(process.env, { auth });
|
|
|
576
647
|
// Keep in step with package.json. It is what every telemetry event is stamped with, so a stale
|
|
577
648
|
// value here does not break anything — it quietly attributes this release's behaviour to an older
|
|
578
649
|
// one, which is worse, because the numbers still look fine.
|
|
579
|
-
const VERSION = '0.
|
|
650
|
+
const VERSION = '0.21.0';
|
|
580
651
|
|
|
581
652
|
/** This release and the connected client, stamped on a feedback report (see feedback.mjs). */
|
|
582
653
|
function clientInfo() {
|
package/lib.mjs
CHANGED
|
@@ -370,6 +370,50 @@ export const resolveDoc = async (api, value, apiBase) => {
|
|
|
370
370
|
};
|
|
371
371
|
|
|
372
372
|
/** Kept for callers of the earlier helper: the row id, or null. */
|
|
373
|
+
/**
|
|
374
|
+
* What `workover_propose_edit` did, from the api's `outcome` (WO-1748). An api older than the field
|
|
375
|
+
* answers without one, and is described the way every proposal used to be.
|
|
376
|
+
*/
|
|
377
|
+
export function proposeOutcomeText(res, docId) {
|
|
378
|
+
const where = `${res?.tab ? `the "${res.tab.title}" tab of ` : ''}document #${docId}`;
|
|
379
|
+
const id = res?.id != null ? ` (suggestion #${res.id})` : '';
|
|
380
|
+
const check = 'workover_suggestion_status says whether the editor has shown it.';
|
|
381
|
+
if (res?.outcome === 'unchanged')
|
|
382
|
+
return `Nothing changed: the open suggestion on ${where}${id} already says exactly this. ${check}`;
|
|
383
|
+
if (res?.outcome === 'held')
|
|
384
|
+
return `Not applied: the open suggestion on ${where}${id} is out with Workover AI for a revision, and your text would be overwritten when that lands. Propose again once workover_suggestion_status says it is back.`;
|
|
385
|
+
if (res?.outcome === 'reoffered')
|
|
386
|
+
return `The open suggestion on ${where}${id} already says exactly this, and the editor had not been able to show it. It is offered again the next time someone who can review it opens the document; if it still cannot be shown, workover_suggestion_status says why.`;
|
|
387
|
+
const verb = res?.outcome === 'updated' ? 'Updated the open suggestion on' : 'Proposed your changes to';
|
|
388
|
+
return `${verb} ${where}${id}. They appear as tracked changes to accept or reject the next time someone who can review them opens the document in Workover. ${check}`;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** The answer to `workover_suggestion_status`, from `GET /project/doc/:id/proposals/current`. */
|
|
392
|
+
export function suggestionStatusText(current, docId) {
|
|
393
|
+
if (!current)
|
|
394
|
+
return `Document #${docId} has no open suggestion. One raised earlier was accepted or dismissed, or none was raised.`;
|
|
395
|
+
const from = current.proposedBy?.name
|
|
396
|
+
? `${current.proposedBy.name} via ${current.source}`
|
|
397
|
+
: current.source;
|
|
398
|
+
const lines = [
|
|
399
|
+
`Suggestion #${current.id} on document #${docId}, from ${from}, raised ${current.createdAt}${current.revisions ? `, revised ${current.revisions} time${current.revisions === 1 ? '' : 's'}` : ''}.`,
|
|
400
|
+
];
|
|
401
|
+
if (current.tabField) lines.push(`Against tab "${current.tabField}".`);
|
|
402
|
+
if (current.status === 'refining')
|
|
403
|
+
lines.push('It is out with Workover AI for a revision, so it is not on the page right now.');
|
|
404
|
+
else if (current.editorRefusal)
|
|
405
|
+
lines.push(
|
|
406
|
+
`The editor could NOT show it as tracked changes, so nothing is on the page: ${current.editorRefusal}`,
|
|
407
|
+
'Propose a version that avoids that, or send the same text again to have the editor try once more.',
|
|
408
|
+
);
|
|
409
|
+
else if (current.shownAt)
|
|
410
|
+
lines.push(`Shown in the editor at ${current.shownAt}, waiting for someone to accept or reject it.`);
|
|
411
|
+
else
|
|
412
|
+
lines.push('Not shown yet: it appears the next time someone who can review it opens the document.');
|
|
413
|
+
if (current.note) lines.push(`Note: ${current.note}`);
|
|
414
|
+
return lines.join('\n');
|
|
415
|
+
}
|
|
416
|
+
|
|
373
417
|
export const resolveDocId = async (api, value) => (await resolveDoc(api, value)).id ?? null;
|
|
374
418
|
|
|
375
419
|
const decodeAttr = (v) =>
|
|
@@ -407,6 +451,61 @@ export const imagesInHtml = (html) => {
|
|
|
407
451
|
return out;
|
|
408
452
|
};
|
|
409
453
|
|
|
454
|
+
/** workover_list_media's filters, as the flags GET /project/:id/media takes. */
|
|
455
|
+
const MEDIA_FLAGS = {
|
|
456
|
+
attention: 'attention',
|
|
457
|
+
missing_alt: 'missingAlt',
|
|
458
|
+
oversized: 'oversized',
|
|
459
|
+
broken: 'broken',
|
|
460
|
+
stale: 'stale',
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
/** The query string for GET /project/:id/media, from workover_list_media's arguments. */
|
|
464
|
+
export function mediaListQuery(args = {}) {
|
|
465
|
+
const q = new URLSearchParams();
|
|
466
|
+
const filter = String(args.filter || 'all');
|
|
467
|
+
if (filter === 'in_use' || filter === 'unused' || filter === 'deleted') q.set('tab', filter);
|
|
468
|
+
if (MEDIA_FLAGS[filter]) q.set(MEDIA_FLAGS[filter], 'true');
|
|
469
|
+
if (args.source === 'workover' || args.source === 'wordpress') q.set('source', args.source);
|
|
470
|
+
const search = typeof args.search === 'string' ? args.search.trim() : '';
|
|
471
|
+
if (search) q.set('search', search);
|
|
472
|
+
const cursor = Number(args.cursor);
|
|
473
|
+
if (Number.isInteger(cursor) && cursor > 0) q.set('cursor', String(cursor));
|
|
474
|
+
q.set('limit', '50');
|
|
475
|
+
return q.toString();
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** workover_list_media's answer: the counts, one block per asset, then the next page. */
|
|
479
|
+
export function formatMediaList(projectId, res) {
|
|
480
|
+
const items = Array.isArray(res?.items) ? res.items : [];
|
|
481
|
+
const c = res?.counts || {};
|
|
482
|
+
const head =
|
|
483
|
+
`Media library of project #${projectId}: ${c.all ?? items.length} images, ` +
|
|
484
|
+
`${c.inUse ?? 0} in use, ${c.unused ?? 0} not found in imported content, ` +
|
|
485
|
+
`${c.attention ?? 0} need attention.`;
|
|
486
|
+
if (!items.length) return `${head}\n\nNothing matches.`;
|
|
487
|
+
const lines = items.map((a) => {
|
|
488
|
+
const problems = [];
|
|
489
|
+
// Alt text is an image's; a PDF in the WordPress library has none to miss.
|
|
490
|
+
if (!a.alt && (a.mime == null || String(a.mime).startsWith('image/')))
|
|
491
|
+
problems.push('no alt text');
|
|
492
|
+
if (a.oversized) problems.push(`oversized (${Math.round((a.bytes || 0) / 1024)} KB)`);
|
|
493
|
+
if (a.brokenAt) problems.push('broken');
|
|
494
|
+
if (a.staleAt) problems.push(`outdated: ${a.staleReason || 'the UI changed'}`);
|
|
495
|
+
if (a.deletedAt) problems.push('deleted');
|
|
496
|
+
const from = a.wpAttachmentId ? `WordPress #${a.wpAttachmentId}` : 'Workover';
|
|
497
|
+
const used = a.useCount
|
|
498
|
+
? `used in ${a.useCount} doc${a.useCount === 1 ? '' : 's'}`
|
|
499
|
+
: 'not found in imported content';
|
|
500
|
+
return (
|
|
501
|
+
`#${a.id} ${a.filename} (${from}, ${used})\n alt: ${a.alt || '(none)'}` +
|
|
502
|
+
(problems.length ? `\n problems: ${problems.join('; ')}` : '')
|
|
503
|
+
);
|
|
504
|
+
});
|
|
505
|
+
const more = res?.nextCursor ? `\n\nMore: pass cursor ${res.nextCursor} for the next page.` : '';
|
|
506
|
+
return `${head}\n\n${lines.join('\n')}${more}`;
|
|
507
|
+
}
|
|
508
|
+
|
|
410
509
|
/** The error shown when a tool is handed something that isn't a numeric id. */
|
|
411
510
|
export const badIdErr = (kind, got) =>
|
|
412
511
|
err(
|
|
@@ -1037,6 +1136,30 @@ export function makeDispatch({ auth, api, apiPost, fetchImpl = fetch, readFile,
|
|
|
1037
1136
|
`Updated: file name "${res?.filename}", alt "${res?.alt || ''}".${inDoc} The file name is what WordPress gets on the next publish.`,
|
|
1038
1137
|
);
|
|
1039
1138
|
}
|
|
1139
|
+
if (name === 'workover_list_media') {
|
|
1140
|
+
const projectId = rowId(args.projectId);
|
|
1141
|
+
if (projectId === null) return badIdErr('project', args.projectId);
|
|
1142
|
+
const res = await api(`/project/${projectId}/media?${mediaListQuery(args)}`);
|
|
1143
|
+
return text(formatMediaList(projectId, res));
|
|
1144
|
+
}
|
|
1145
|
+
if (name === 'workover_replace_media') {
|
|
1146
|
+
const projectId = rowId(args.projectId);
|
|
1147
|
+
if (projectId === null) return badIdErr('project', args.projectId);
|
|
1148
|
+
const assetId = rowId(args.assetId);
|
|
1149
|
+
if (assetId === null) return badIdErr('asset', args.assetId);
|
|
1150
|
+
const replacementAssetId = rowId(args.replacementAssetId);
|
|
1151
|
+
if (replacementAssetId === null) return badIdErr('asset', args.replacementAssetId);
|
|
1152
|
+
if (assetId === replacementAssetId)
|
|
1153
|
+
return err('Choose a different image to replace it with.');
|
|
1154
|
+
const res = await api(`/project/${projectId}/media/${assetId}/replace`, {
|
|
1155
|
+
method: 'POST',
|
|
1156
|
+
headers: { 'content-type': 'application/json' },
|
|
1157
|
+
body: JSON.stringify({ replacementAssetId }),
|
|
1158
|
+
});
|
|
1159
|
+
return text(
|
|
1160
|
+
`Raised a fix to replace image #${assetId} with #${replacementAssetId} in every document that uses it${res?.suggestionId ? ` (fix #${res.suggestionId})` : ''}. Nothing has changed yet: a person reviews it in the project's Health page (Findings), and accepting it rewrites the documents. The old image stays in the library.`,
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1040
1163
|
if (name === 'workover_edit_doc') {
|
|
1041
1164
|
const md = String(args.markdown || '').trim();
|
|
1042
1165
|
// A rename rides on the direct-edit tool: `title` alone renames without touching the body.
|
|
@@ -1116,9 +1239,19 @@ export function makeDispatch({ auth, api, apiPost, fetchImpl = fetch, readFile,
|
|
|
1116
1239
|
: {}),
|
|
1117
1240
|
});
|
|
1118
1241
|
return text(
|
|
1119
|
-
|
|
1242
|
+
`${proposeOutcomeText(res, docId)}${res?.documentUrl ? `\n${res.documentUrl}` : ''}\n\nNothing is published until the person reviews and accepts.${renderStyleFeedback(res?.style)}`,
|
|
1120
1243
|
);
|
|
1121
1244
|
}
|
|
1245
|
+
if (name === 'workover_suggestion_status') {
|
|
1246
|
+
// Whether a suggestion raised through workover_propose_edit reached the page (WO-1748):
|
|
1247
|
+
// before this the only answer was the propose call's own "they'll appear", which was said
|
|
1248
|
+
// whether or not the editor could show them.
|
|
1249
|
+
const doc = await resolveDoc(api, docArg(args), auth.api);
|
|
1250
|
+
if (doc.error) return doc.error;
|
|
1251
|
+
const docId = doc.id;
|
|
1252
|
+
const current = await api(`/project/doc/${docId}/proposals/current`);
|
|
1253
|
+
return text(suggestionStatusText(current, docId));
|
|
1254
|
+
}
|
|
1122
1255
|
if (name === 'workover_doc_status') {
|
|
1123
1256
|
// The document's WORKOVER status, read or set through the browser's rules (WO-1264). It
|
|
1124
1257
|
// never publishes: the WordPress post is a separate thing, and the answer says so.
|
package/package.json
CHANGED