@superdoc/mcp 1.0.1-next.6 → 1.0.1-next.7
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/index.js +145 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -31314,7 +31314,7 @@ var init_host = __esm(() => {
|
|
|
31314
31314
|
});
|
|
31315
31315
|
|
|
31316
31316
|
// ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
|
|
31317
|
-
var SDK_VERSION = "2.13.1-next.
|
|
31317
|
+
var SDK_VERSION = "2.13.1-next.7";
|
|
31318
31318
|
|
|
31319
31319
|
// ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
|
|
31320
31320
|
import { chmodSync, existsSync } from "node:fs";
|
|
@@ -369135,6 +369135,7 @@ async function compilePlan(context, input) {
|
|
|
369135
369135
|
}
|
|
369136
369136
|
detectTargetConflicts(context, steps, failures);
|
|
369137
369137
|
detectUnsupportedRuntimeDrift(input.steps, failures);
|
|
369138
|
+
detectTargetOffsetDriftRisk(steps, failures);
|
|
369138
369139
|
return { evaluatedRevision, steps, failures };
|
|
369139
369140
|
}
|
|
369140
369141
|
function isOrderedAtomicTextProgram(steps) {
|
|
@@ -369619,6 +369620,14 @@ function detectUnsupportedRuntimeDrift(steps, failures) {
|
|
|
369619
369620
|
message: "multi-step mutation plans cannot use revision-bound ref targets; use selector targets so the engine can re-resolve each step before commit."
|
|
369620
369621
|
});
|
|
369621
369622
|
}
|
|
369623
|
+
if (step3.where.by === "target" && step3.where.target.kind === "selection" && step3.where.target.start.kind === "text" && step3.where.target.end.kind === "text" && step3.where.target.start.blockId !== step3.where.target.end.blockId) {
|
|
369624
|
+
failures.push({
|
|
369625
|
+
code: "CAPABILITY_UNSUPPORTED",
|
|
369626
|
+
stepId: step3.id,
|
|
369627
|
+
phase: "compile",
|
|
369628
|
+
message: 'multi-step mutation plans cannot combine a cross-block by:"target" step with other mutating steps; ' + "conflict and offset-drift detection only see that step's first block. Apply it alone, or split the " + "plan so the cross-block step runs in its own mutations.apply call."
|
|
369629
|
+
});
|
|
369630
|
+
}
|
|
369622
369631
|
}
|
|
369623
369632
|
}
|
|
369624
369633
|
}
|
|
@@ -369659,6 +369668,33 @@ function detectTargetConflicts(context, steps, failures) {
|
|
|
369659
369668
|
}
|
|
369660
369669
|
}
|
|
369661
369670
|
}
|
|
369671
|
+
function detectTargetOffsetDriftRisk(steps, failures) {
|
|
369672
|
+
const textShiftingOps = new Set(["text.rewrite", "text.delete", "text.insert"]);
|
|
369673
|
+
const byBlock = new Map;
|
|
369674
|
+
for (const step3 of steps) {
|
|
369675
|
+
if (!textShiftingOps.has(step3.op) || step3.source.op === "assert" || step3.source.where?.by !== "target")
|
|
369676
|
+
continue;
|
|
369677
|
+
const resolutions = step3.resolutions ?? (step3.resolution ? [step3.resolution] : []);
|
|
369678
|
+
for (const resolution of resolutions) {
|
|
369679
|
+
const key2 = `${storyKeyForTarget(resolution.target)}::${resolution.target.blockId}`;
|
|
369680
|
+
const list2 = byBlock.get(key2) ?? [];
|
|
369681
|
+
list2.push(step3);
|
|
369682
|
+
byBlock.set(key2, list2);
|
|
369683
|
+
}
|
|
369684
|
+
}
|
|
369685
|
+
for (const blockSteps of byBlock.values()) {
|
|
369686
|
+
if (blockSteps.length <= 1)
|
|
369687
|
+
continue;
|
|
369688
|
+
for (const step3 of blockSteps) {
|
|
369689
|
+
failures.push({
|
|
369690
|
+
code: "CAPABILITY_UNSUPPORTED",
|
|
369691
|
+
stepId: step3.stepId,
|
|
369692
|
+
phase: "compile",
|
|
369693
|
+
message: `step "${step3.stepId}" shares a block with another by:"target" text-shifting step in this plan; explicit ` + "offsets are not re-derived between steps, so an earlier same-block step can shift this one's offsets. " + 'Split same-block edits into separate mutations.apply calls, or use by:"select" for later occurrences in ' + "the same block."
|
|
369694
|
+
});
|
|
369695
|
+
}
|
|
369696
|
+
}
|
|
369697
|
+
}
|
|
369662
369698
|
function conflictRangeForResolution(context, step3, resolution) {
|
|
369663
369699
|
if (step3.source.op !== "format.apply" || step3.source.args.scope !== "block" && step3.source.args.alignment === undefined) {
|
|
369664
369700
|
return resolution.range;
|
|
@@ -369713,9 +369749,117 @@ async function resolveMutationStep(context, step3, story, changeMode) {
|
|
|
369713
369749
|
const compiled = resolveRefMutationStep(context, step3, story, matches[0].ref);
|
|
369714
369750
|
return applySelectMatchReplacementPolicy(compiled, step3, matches[0].groups);
|
|
369715
369751
|
}
|
|
369752
|
+
if (step3.where.by === "target") {
|
|
369753
|
+
return resolveTargetWhereMutationStep(context, step3, step3.where, story, changeMode);
|
|
369754
|
+
}
|
|
369716
369755
|
const ref5 = resolveStepRef(step3);
|
|
369717
369756
|
return resolveRefMutationStep(context, step3, story, ref5);
|
|
369718
369757
|
}
|
|
369758
|
+
function resolveTargetWhereMutationStep(context, step3, where, story, changeMode) {
|
|
369759
|
+
const target = where.target;
|
|
369760
|
+
if (target.kind !== "selection" || target.start.kind !== "text" || target.end.kind !== "text") {
|
|
369761
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", `v2 ${step3.op} target steps require a text SelectionTarget with text-kind endpoints.`);
|
|
369762
|
+
}
|
|
369763
|
+
const storyLocator = target.story ?? story;
|
|
369764
|
+
if (!isSupportedMutationStoryScope(storyLocator)) {
|
|
369765
|
+
throw new DocumentApiValidationError2("CAPABILITY_UNSUPPORTED", `v2 mutation plan engine supports only the body story; "${storyLocator?.storyType}" story targets are not supported.`);
|
|
369766
|
+
}
|
|
369767
|
+
if (step3.op === "text.rewrite" && step3.args.replacementMode === "regex-template") {
|
|
369768
|
+
throw new DocumentApiValidationError2("CAPABILITY_UNSUPPORTED", 'v2 text.rewrite target steps do not support replacementMode "regex-template"; an explicit target carries no ' + 'capture groups. Use a by:"select" step for regex-template replacements.');
|
|
369769
|
+
}
|
|
369770
|
+
const selectionMutation = new V2SelectionMutationAdapter(context);
|
|
369771
|
+
if (step3.op === "text.insert") {
|
|
369772
|
+
const { text: text4, position: position2 } = readInsertArgs(step3);
|
|
369773
|
+
const point3 = position2 === "before" ? target.start : target.end;
|
|
369774
|
+
const collapsed = {
|
|
369775
|
+
kind: "selection",
|
|
369776
|
+
start: point3,
|
|
369777
|
+
end: point3,
|
|
369778
|
+
...target.story ? { story: target.story } : {},
|
|
369779
|
+
...target.coordinateSpace ? { coordinateSpace: target.coordinateSpace } : {}
|
|
369780
|
+
};
|
|
369781
|
+
const request = { kind: "insert", target: collapsed, text: text4, ...story ? { in: story } : {} };
|
|
369782
|
+
const receipt3 = selectionMutation.execute({ kind: "insert", target: collapsed, text: text4, ...story ? { in: story } : {} }, { changeMode, dryRun: true });
|
|
369783
|
+
if (!receipt3.success)
|
|
369784
|
+
throw new DocumentApiValidationError2(receipt3.failure.code, receipt3.failure.message);
|
|
369785
|
+
const resolution2 = {
|
|
369786
|
+
target: receipt3.resolution.target,
|
|
369787
|
+
range: receipt3.resolution.range,
|
|
369788
|
+
text: receipt3.resolution.text
|
|
369789
|
+
};
|
|
369790
|
+
return {
|
|
369791
|
+
stepId: step3.id,
|
|
369792
|
+
op: "text.insert",
|
|
369793
|
+
resolution: resolution2,
|
|
369794
|
+
request,
|
|
369795
|
+
noopEquivalentText: text4.length === 0 ? text4 : undefined,
|
|
369796
|
+
source: step3
|
|
369797
|
+
};
|
|
369798
|
+
}
|
|
369799
|
+
if (step3.op === "format.apply") {
|
|
369800
|
+
const crossBlock = target.start.blockId !== target.end.blockId;
|
|
369801
|
+
if (crossBlock && (step3.args.alignment !== undefined || step3.args.scope === "block")) {
|
|
369802
|
+
throw new DocumentApiValidationError2("CAPABILITY_UNSUPPORTED", "v2 format.apply target steps spanning more than one block support only an inline patch with the default " + '(non-block) scope; split a cross-block alignment or scope:"block" edit into one step per block.');
|
|
369803
|
+
}
|
|
369804
|
+
const placeholderResolution = {
|
|
369805
|
+
target: {
|
|
369806
|
+
kind: "text",
|
|
369807
|
+
blockId: target.start.blockId,
|
|
369808
|
+
range: { start: 0, end: 0 },
|
|
369809
|
+
...storyLocator ? { story: storyLocator } : {}
|
|
369810
|
+
},
|
|
369811
|
+
range: { from: 0, to: 0 },
|
|
369812
|
+
text: ""
|
|
369813
|
+
};
|
|
369814
|
+
const request = buildFormatCommitRequest(context, step3, placeholderResolution, target, story, storyLocator);
|
|
369815
|
+
if (request.kind !== "format") {
|
|
369816
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", "v2 format.apply target steps require a resolvable target.");
|
|
369817
|
+
}
|
|
369818
|
+
let resolution2;
|
|
369819
|
+
if (request.inline) {
|
|
369820
|
+
const receipt3 = "target" in request ? selectionMutation.execute({ kind: "format", target: request.target, inline: request.inline, ...request.in ? { in: request.in } : {} }, { changeMode, dryRun: true, ...request.skipAtomicObjects ? { skipAtomicObjects: true } : {} }) : selectionMutation.execute({ kind: "format", ref: request.ref, inline: request.inline, ...request.in ? { in: request.in } : {} }, { changeMode, dryRun: true, ...request.skipAtomicObjects ? { skipAtomicObjects: true } : {} });
|
|
369821
|
+
if (!receipt3.success)
|
|
369822
|
+
throw new DocumentApiValidationError2(receipt3.failure.code, receipt3.failure.message);
|
|
369823
|
+
resolution2 = {
|
|
369824
|
+
target: receipt3.resolution.target,
|
|
369825
|
+
range: receipt3.resolution.range,
|
|
369826
|
+
text: receipt3.resolution.text
|
|
369827
|
+
};
|
|
369828
|
+
} else {
|
|
369829
|
+
const blockText = readBlockTargetText(context, target.start.blockId, Number.MAX_SAFE_INTEGER, storyLocator, target.coordinateSpace);
|
|
369830
|
+
resolution2 = {
|
|
369831
|
+
target: { kind: "text", blockId: target.start.blockId, range: { start: 0, end: blockText.length }, ...storyLocator ? { story: storyLocator } : {} },
|
|
369832
|
+
range: { from: 0, to: blockText.length },
|
|
369833
|
+
text: blockText
|
|
369834
|
+
};
|
|
369835
|
+
}
|
|
369836
|
+
return {
|
|
369837
|
+
stepId: step3.id,
|
|
369838
|
+
op: "format.apply",
|
|
369839
|
+
resolution: resolution2,
|
|
369840
|
+
request,
|
|
369841
|
+
source: step3
|
|
369842
|
+
};
|
|
369843
|
+
}
|
|
369844
|
+
const rewriteTemplate = step3.op === "text.delete" ? "" : normalizeReplacement(step3.args.replacement);
|
|
369845
|
+
const probeReceipt = selectionMutation.execute({ kind: "replace", target, text: rewriteTemplate, ...story ? { in: story } : {} }, { changeMode, dryRun: true });
|
|
369846
|
+
if (!probeReceipt.success)
|
|
369847
|
+
throw new DocumentApiValidationError2(probeReceipt.failure.code, probeReceipt.failure.message);
|
|
369848
|
+
const resolution = {
|
|
369849
|
+
target: probeReceipt.resolution.target,
|
|
369850
|
+
range: probeReceipt.resolution.range,
|
|
369851
|
+
text: probeReceipt.resolution.text
|
|
369852
|
+
};
|
|
369853
|
+
const replacementText = step3.op === "text.delete" ? "" : replacementTextForMatch(step3, resolution.text);
|
|
369854
|
+
return {
|
|
369855
|
+
stepId: step3.id,
|
|
369856
|
+
op: step3.op,
|
|
369857
|
+
resolution,
|
|
369858
|
+
request: { kind: "replace", target, text: replacementText, ...story ? { in: story } : {} },
|
|
369859
|
+
...step3.op === "text.rewrite" ? { noopEquivalentText: replacementText } : {},
|
|
369860
|
+
source: step3
|
|
369861
|
+
};
|
|
369862
|
+
}
|
|
369719
369863
|
function resolveRefMutationStep(context, step3, story, ref5, cache) {
|
|
369720
369864
|
if (isV2RangeRef(ref5)) {
|
|
369721
369865
|
return resolveRangeRefMutationStep(context, step3, story, ref5);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/mcp",
|
|
3
|
-
"version": "1.0.1-next.
|
|
3
|
+
"version": "1.0.1-next.7",
|
|
4
4
|
"description": "Model Context Protocol server for SuperDoc, giving an AI agent tools to read and edit .docx files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
27
|
-
"@superdoc/sdk": "2.13.1-next.
|
|
27
|
+
"@superdoc/sdk": "2.13.1-next.7",
|
|
28
28
|
"debug": "^4.4.3",
|
|
29
29
|
"zod": "^4.3.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"superdoc": "2.16.1-next.
|
|
33
|
-
"@superdoc/docx-engine": "0.15.1-next.
|
|
32
|
+
"superdoc": "2.16.1-next.7",
|
|
33
|
+
"@superdoc/docx-engine": "0.15.1-next.6",
|
|
34
34
|
"@superdoc/document-api": "0.1.0-alpha.0",
|
|
35
35
|
"@types/bun": "^1.3.8",
|
|
36
36
|
"@types/node": "22.19.2",
|