@diviops/mcp-server 1.5.29 → 1.5.31
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 +68 -1
- package/dist/compatibility.d.ts +9 -0
- package/dist/compatibility.js +12 -0
- package/dist/cross-env-preflight/bin.d.ts +2 -0
- package/dist/cross-env-preflight/bin.js +8 -0
- package/dist/cross-env-preflight/cli.d.ts +9 -0
- package/dist/cross-env-preflight/cli.js +80 -0
- package/dist/cross-env-preflight/header-preflight.d.ts +151 -0
- package/dist/cross-env-preflight/header-preflight.js +783 -0
- package/dist/cross-env-preflight/source-payload-ref.d.ts +20 -0
- package/dist/cross-env-preflight/source-payload-ref.js +178 -0
- package/dist/index.js +436 -36
- package/dist/preset-cli/cli.d.ts +4 -0
- package/dist/preset-cli/cli.js +55 -0
- package/dist/preset-cli/nav-emitter.d.ts +64 -0
- package/dist/preset-cli/nav-emitter.js +328 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ The skill enforces the Divi block format, the design system, and the response co
|
|
|
83
83
|
|
|
84
84
|
## Tools at a glance
|
|
85
85
|
|
|
86
|
-
The server exposes **
|
|
86
|
+
The server exposes **77 always-on tools** across the categories below. Each category links to representative tools; the full table lives in [server-reference.md](../docs/server-reference.md).
|
|
87
87
|
|
|
88
88
|
| Category | Use case | Tool prefixes |
|
|
89
89
|
|----------|----------|---------------|
|
|
@@ -108,6 +108,7 @@ Additional **conditionally-registered Pro tools** appear only on sites that have
|
|
|
108
108
|
| FluentCart order readback + guarded mark-paid (V3.1) | Pro plugin + FluentCart installed + module enabled | `diviops_fc_order_list`, `diviops_fc_order_get`, `diviops_fc_order_mark_paid` |
|
|
109
109
|
| FluentCart license readback (V3.1) | Pro plugin + FluentCart Pro installed + module enabled | `diviops_fc_license_list`, `diviops_fc_license_get`, `diviops_fc_license_activations_list` |
|
|
110
110
|
| FluentCart checkout readiness / gateway inspection (V3.2) | Pro plugin + FluentCart installed + module enabled | `diviops_fc_status`, `diviops_fc_gateway_list`, `diviops_fc_gateway_get` |
|
|
111
|
+
| Cross-env guarded apply | Pro plugin + `cross_env` module enabled | `diviops_cross_env_header_apply` |
|
|
111
112
|
|
|
112
113
|
When the gates are not satisfied, the tools simply don't appear on the MCP surface — no error envelope, no missing-capability hint. See the `diviops-fluentcart` skill bundle for the operator-side guide.
|
|
113
114
|
|
|
@@ -156,6 +157,72 @@ additional vertical slice lands with its own verified evidence. See the
|
|
|
156
157
|
for the full command reference (the `src/` tree is not part of the published
|
|
157
158
|
npm package — this link resolves on the repository).
|
|
158
159
|
|
|
160
|
+
## Bundled CLI — `diviops-cross-env-preflight`
|
|
161
|
+
|
|
162
|
+
The package also ships a dry-run-only cross-environment Theme Builder header
|
|
163
|
+
sync preflight:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
diviops-cross-env-preflight --source source.json --target target.json --dry-run
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
This command reads two secret-free JSON files and prints a report. It does not
|
|
170
|
+
connect to WordPress, does not accept credentials, and has no write/apply path.
|
|
171
|
+
The MVP supports `tb_header_layout` source payloads preflighted against an
|
|
172
|
+
existing `tb_header_layout` target context. It reports source-domain upload URL
|
|
173
|
+
rewrites, attachment remap status, `gcid-*` target resolution including Divi
|
|
174
|
+
built-in customizer colors, resolved target global-color value evidence,
|
|
175
|
+
off-canvas/canvas refusal, and the required cache cleanup plan. Each report also
|
|
176
|
+
emits a deterministic `confirmation_binding` fingerprint over the reviewed
|
|
177
|
+
source identity/checksum, target identity/current target checksum, rewrite plan,
|
|
178
|
+
cache plan, blocker/operator-action codes, reference-resolution summaries, and
|
|
179
|
+
the per-`gcid` value evidence for target colors referenced by the source layout.
|
|
180
|
+
The fingerprint is reviewed-plan evidence for the Pro-gated
|
|
181
|
+
`diviops_cross_env_header_apply` tool. The CLI itself still has no apply path.
|
|
182
|
+
|
|
183
|
+
To collect the source JSON from the source WordPress site, call the Free/core
|
|
184
|
+
read-only MCP tool `diviops_cross_env_source_export_get` and save the returned
|
|
185
|
+
`data` object as `source.json`. The export includes the source origin, header
|
|
186
|
+
layout metadata, sanitized markup, a bare SHA-256 checksum of the exported
|
|
187
|
+
markup, export metadata, and best-effort attachment inventory from upload URLs
|
|
188
|
+
and attachment IDs. It strips query strings, fragments, credentials, nonces,
|
|
189
|
+
cookies, signed URL material, admin URLs, and local filesystem paths.
|
|
190
|
+
|
|
191
|
+
The MCP server also writes the same source payload to a bounded local artifact
|
|
192
|
+
under `.diviops-tmp/cross-env-source-payloads/` and returns
|
|
193
|
+
`data.source_payload_ref`. Use that reference for large real headers when
|
|
194
|
+
calling the Pro `diviops_cross_env_header_apply` tool; it avoids asking an LLM
|
|
195
|
+
to re-emit large markup byte-for-byte. The reference is a server-created handle
|
|
196
|
+
plus checksum, not an arbitrary filesystem path.
|
|
197
|
+
|
|
198
|
+
To collect the target JSON from the target WordPress site, call the Free/core
|
|
199
|
+
read-only MCP tool `diviops_cross_env_target_context_get` against the target
|
|
200
|
+
server and save the returned `data` object as `target.json`. Optional
|
|
201
|
+
`source_asset_hints` and `source_attachment_ids` let the target site search for
|
|
202
|
+
exact media-library candidates by upload path or basename. Ambiguous matches
|
|
203
|
+
remain candidates only; no media is uploaded and no global colors or layouts are
|
|
204
|
+
created. The export includes a SHA-256 checksum of the current target layout
|
|
205
|
+
`post_content` as `destination_checksum` so preflight can bind the reviewed plan
|
|
206
|
+
to the target state without exposing the raw target content. It also includes
|
|
207
|
+
`global_color_value_evidence`, a deterministic SHA-256 digest map for resolved
|
|
208
|
+
user global colors and WP Customizer-backed built-ins; preflight binds only the
|
|
209
|
+
entries that are referenced by source markup.
|
|
210
|
+
|
|
211
|
+
Workflow:
|
|
212
|
+
|
|
213
|
+
1. Call `diviops_cross_env_source_export_get` on the source site and save the
|
|
214
|
+
returned `data` object as `source.json`.
|
|
215
|
+
2. Call `diviops_cross_env_target_context_get` on the target site and save the
|
|
216
|
+
returned `data` object as `target.json`.
|
|
217
|
+
3. Run `diviops-cross-env-preflight --source source.json --target target.json --dry-run`.
|
|
218
|
+
|
|
219
|
+
`--apply` is intentionally refused. To mutate a target, use the separate
|
|
220
|
+
Pro-gated `diviops_cross_env_header_apply` tool with the reviewed fingerprint
|
|
221
|
+
and either inline `source_payload` for small/disposable tests or
|
|
222
|
+
`source_payload_ref` for large real headers. That MVP still refuses media
|
|
223
|
+
upload/import, global color creation/import, off-canvas reconcile, and new
|
|
224
|
+
target layout creation.
|
|
225
|
+
|
|
159
226
|
## Response contract
|
|
160
227
|
|
|
161
228
|
Tools return a standardized envelope. The shape lets clients branch on `ok` and machine-readable `error.code` without parsing freeform messages.
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -71,6 +71,15 @@ export interface HandshakeResult {
|
|
|
71
71
|
/** ADR-003 — per-target admin-controlled activation toggle. */
|
|
72
72
|
active_modules?: Record<string, boolean>;
|
|
73
73
|
}
|
|
74
|
+
export declare function proToolGatesSatisfied(state: {
|
|
75
|
+
proActive: boolean;
|
|
76
|
+
availableTargets: Record<string, HandshakeTarget>;
|
|
77
|
+
activeModules: Record<string, boolean>;
|
|
78
|
+
capabilities: Record<string, boolean>;
|
|
79
|
+
}, gates: {
|
|
80
|
+
target: string;
|
|
81
|
+
capabilityKey: string;
|
|
82
|
+
}): boolean;
|
|
74
83
|
/**
|
|
75
84
|
* Thrown when a tool handler calls `requireCapability(key)` and the
|
|
76
85
|
* plugin's handshake response did not include `key`. The server's
|
package/dist/compatibility.js
CHANGED
|
@@ -79,6 +79,18 @@ export function compareVersions(a, b) {
|
|
|
79
79
|
}
|
|
80
80
|
return 0;
|
|
81
81
|
}
|
|
82
|
+
export function proToolGatesSatisfied(state, gates) {
|
|
83
|
+
if (state.proActive !== true)
|
|
84
|
+
return false;
|
|
85
|
+
const target = state.availableTargets[gates.target];
|
|
86
|
+
if (!target || target.present !== true)
|
|
87
|
+
return false;
|
|
88
|
+
if (state.activeModules[gates.target] !== true)
|
|
89
|
+
return false;
|
|
90
|
+
if (state.capabilities[gates.capabilityKey] !== true)
|
|
91
|
+
return false;
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
82
94
|
/**
|
|
83
95
|
* Thrown when a tool handler calls `requireCapability(key)` and the
|
|
84
96
|
* plugin's handshake response did not include `key`. The server's
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { preflightCrossEnvHeaderSync, } from "./header-preflight.js";
|
|
3
|
+
export const EXIT = {
|
|
4
|
+
OK: 0,
|
|
5
|
+
INVALID_INPUT: 1,
|
|
6
|
+
};
|
|
7
|
+
const HELP = `diviops-cross-env-preflight — dry-run cross-environment layout safety reports
|
|
8
|
+
|
|
9
|
+
USAGE
|
|
10
|
+
diviops-cross-env-preflight --source source.json --target target.json --dry-run
|
|
11
|
+
|
|
12
|
+
OPTIONS
|
|
13
|
+
--source <path> Secret-free source layout payload JSON.
|
|
14
|
+
--target <path> Secret-free target context JSON.
|
|
15
|
+
--dry-run Required/default. Produce a report only; no WordPress writes.
|
|
16
|
+
--apply Refused. No write/apply path exists in this MVP.
|
|
17
|
+
--help Show this help.
|
|
18
|
+
|
|
19
|
+
The MVP supports tb_header_layout -> tb_header_layout preflight only.`;
|
|
20
|
+
function parseArgs(argv) {
|
|
21
|
+
const parsed = { help: false };
|
|
22
|
+
for (let i = 0; i < argv.length; i++) {
|
|
23
|
+
const token = argv[i];
|
|
24
|
+
if (token === "--help" || token === "-h") {
|
|
25
|
+
parsed.help = true;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (token === "--dry-run")
|
|
29
|
+
continue;
|
|
30
|
+
if (token === "--apply") {
|
|
31
|
+
throw new Error("--apply is not supported; this MVP is preflight-only.");
|
|
32
|
+
}
|
|
33
|
+
if (token === "--source" || token === "--target") {
|
|
34
|
+
const value = argv[i + 1];
|
|
35
|
+
if (value === undefined || value.startsWith("--")) {
|
|
36
|
+
throw new Error(`${token} requires a value.`);
|
|
37
|
+
}
|
|
38
|
+
if (token === "--source")
|
|
39
|
+
parsed.source = value;
|
|
40
|
+
if (token === "--target")
|
|
41
|
+
parsed.target = value;
|
|
42
|
+
i++;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
throw new Error(`Unknown flag or argument: ${token}`);
|
|
46
|
+
}
|
|
47
|
+
return parsed;
|
|
48
|
+
}
|
|
49
|
+
function readJsonFile(path) {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
throw new Error(`Failed to read JSON from ${path}: ${err instanceof Error ? err.message : String(err)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export async function runCli(argv, io) {
|
|
58
|
+
try {
|
|
59
|
+
const parsed = parseArgs(argv);
|
|
60
|
+
if (parsed.help || argv.length === 0) {
|
|
61
|
+
io.out(HELP);
|
|
62
|
+
return EXIT.OK;
|
|
63
|
+
}
|
|
64
|
+
if (!parsed.source)
|
|
65
|
+
throw new Error("--source <path> is required.");
|
|
66
|
+
if (!parsed.target)
|
|
67
|
+
throw new Error("--target <path> is required.");
|
|
68
|
+
const input = {
|
|
69
|
+
source: readJsonFile(parsed.source),
|
|
70
|
+
target: readJsonFile(parsed.target),
|
|
71
|
+
};
|
|
72
|
+
const report = preflightCrossEnvHeaderSync(input);
|
|
73
|
+
io.out(JSON.stringify(report, null, 2));
|
|
74
|
+
return EXIT.OK;
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
io.err(err instanceof Error ? err.message : String(err));
|
|
78
|
+
return EXIT.INVALID_INPUT;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export type CrossEnvObjectKind = "tb_header_layout";
|
|
2
|
+
export type CrossEnvVerdict = "safe_dry_run" | "operator_action_required" | "refused";
|
|
3
|
+
export interface SourceAttachmentInventoryItem {
|
|
4
|
+
id: number;
|
|
5
|
+
url?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
filename?: string;
|
|
8
|
+
mime?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface SourceLayoutPayload {
|
|
11
|
+
origin: string;
|
|
12
|
+
object_kind: CrossEnvObjectKind | string;
|
|
13
|
+
object_id?: number | string;
|
|
14
|
+
object_title?: string;
|
|
15
|
+
markup: string;
|
|
16
|
+
checksum?: string;
|
|
17
|
+
attachments?: SourceAttachmentInventoryItem[];
|
|
18
|
+
}
|
|
19
|
+
export interface TargetAttachmentInventoryItem {
|
|
20
|
+
id?: number;
|
|
21
|
+
target_id?: number;
|
|
22
|
+
source_id?: number;
|
|
23
|
+
source_attachment_id?: number;
|
|
24
|
+
url?: string;
|
|
25
|
+
path?: string;
|
|
26
|
+
filename?: string;
|
|
27
|
+
proof?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface Sha256Checksum {
|
|
30
|
+
algorithm: "sha256";
|
|
31
|
+
computed: string;
|
|
32
|
+
input?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface TargetLayoutContext {
|
|
35
|
+
origin: string;
|
|
36
|
+
destination_kind: CrossEnvObjectKind | string;
|
|
37
|
+
destination_id?: number | string;
|
|
38
|
+
destination_title?: string;
|
|
39
|
+
destination_checksum?: string | Sha256Checksum;
|
|
40
|
+
attachment_remaps?: Record<string, unknown>;
|
|
41
|
+
attachments?: TargetAttachmentInventoryItem[];
|
|
42
|
+
global_colors?: unknown;
|
|
43
|
+
global_color_value_evidence?: unknown;
|
|
44
|
+
builtin_customizer_color_ids?: unknown;
|
|
45
|
+
cache_scope?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface CrossEnvHeaderPreflightInput {
|
|
48
|
+
source: SourceLayoutPayload;
|
|
49
|
+
target: TargetLayoutContext;
|
|
50
|
+
}
|
|
51
|
+
export interface PreflightIssue {
|
|
52
|
+
code: string;
|
|
53
|
+
message: string;
|
|
54
|
+
detail?: Record<string, unknown>;
|
|
55
|
+
}
|
|
56
|
+
export interface UrlOccurrence {
|
|
57
|
+
url: string;
|
|
58
|
+
host: string;
|
|
59
|
+
path: string;
|
|
60
|
+
query_redacted?: boolean;
|
|
61
|
+
hash_redacted?: boolean;
|
|
62
|
+
credentials_redacted?: boolean;
|
|
63
|
+
classification: "source_upload_rewrite" | "source_non_upload_operator_review" | "third_party_no_rewrite" | "target_origin";
|
|
64
|
+
rewrite_to?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface AttachmentReference {
|
|
67
|
+
source_id: number;
|
|
68
|
+
property: string;
|
|
69
|
+
status: "proven_remap" | "missing_remap" | "ambiguous_remap";
|
|
70
|
+
target_id?: number;
|
|
71
|
+
proof?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface GcidReference {
|
|
74
|
+
id: string;
|
|
75
|
+
status: "target_global_color" | "builtin_customizer_color" | "missing_target_context" | "missing_definition";
|
|
76
|
+
value_evidence?: GlobalColorValueEvidence;
|
|
77
|
+
}
|
|
78
|
+
export interface GlobalColorValueEvidence {
|
|
79
|
+
id: string;
|
|
80
|
+
source?: string;
|
|
81
|
+
digest: Sha256Checksum;
|
|
82
|
+
}
|
|
83
|
+
export interface OffCanvasReference {
|
|
84
|
+
token: string;
|
|
85
|
+
reason: string;
|
|
86
|
+
}
|
|
87
|
+
export interface CrossEnvHeaderPreflightReport {
|
|
88
|
+
type: "cross_env_header_preflight";
|
|
89
|
+
dry_run: true;
|
|
90
|
+
verdict: CrossEnvVerdict;
|
|
91
|
+
source: {
|
|
92
|
+
origin: string;
|
|
93
|
+
object_kind: string;
|
|
94
|
+
object_id?: number | string;
|
|
95
|
+
object_title?: string;
|
|
96
|
+
checksum: {
|
|
97
|
+
algorithm: "sha256";
|
|
98
|
+
provided?: string;
|
|
99
|
+
computed: string;
|
|
100
|
+
matches: boolean | null;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
target: {
|
|
104
|
+
origin: string;
|
|
105
|
+
destination_kind: string;
|
|
106
|
+
destination_id?: number | string;
|
|
107
|
+
destination_title?: string;
|
|
108
|
+
cache_scope?: string;
|
|
109
|
+
destination_checksum?: Sha256Checksum;
|
|
110
|
+
};
|
|
111
|
+
findings: {
|
|
112
|
+
urls: {
|
|
113
|
+
by_host: Record<string, string[]>;
|
|
114
|
+
occurrences: UrlOccurrence[];
|
|
115
|
+
};
|
|
116
|
+
attachments: AttachmentReference[];
|
|
117
|
+
global_colors: GcidReference[];
|
|
118
|
+
off_canvas: OffCanvasReference[];
|
|
119
|
+
};
|
|
120
|
+
rewrite_plan: {
|
|
121
|
+
url_rewrites: Array<{
|
|
122
|
+
from: string;
|
|
123
|
+
to: string;
|
|
124
|
+
}>;
|
|
125
|
+
attachment_replacements: Array<{
|
|
126
|
+
from_source_id: number;
|
|
127
|
+
to_target_id: number;
|
|
128
|
+
proof?: string;
|
|
129
|
+
}>;
|
|
130
|
+
third_party_urls_kept: string[];
|
|
131
|
+
missing_attachment_remaps: number[];
|
|
132
|
+
};
|
|
133
|
+
cache_plan: {
|
|
134
|
+
scope: string;
|
|
135
|
+
steps: Array<{
|
|
136
|
+
kind: string;
|
|
137
|
+
target: string;
|
|
138
|
+
note: string;
|
|
139
|
+
}>;
|
|
140
|
+
};
|
|
141
|
+
blockers: PreflightIssue[];
|
|
142
|
+
operator_actions: PreflightIssue[];
|
|
143
|
+
notes: string[];
|
|
144
|
+
confirmation_binding: {
|
|
145
|
+
schema: "diviops.cross_env.header_preflight.confirmation_binding.v1";
|
|
146
|
+
algorithm: "sha256";
|
|
147
|
+
fingerprint: string;
|
|
148
|
+
input: Record<string, unknown>;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
export declare function preflightCrossEnvHeaderSync(input: CrossEnvHeaderPreflightInput): CrossEnvHeaderPreflightReport;
|