@superdoc/mcp 1.3.0-next.12 → 1.3.0-next.13

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.
Files changed (2) hide show
  1. package/dist/index.js +138 -22
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31318,7 +31318,7 @@ var init_host = __esm(() => {
31318
31318
  });
31319
31319
 
31320
31320
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31321
- var SDK_VERSION = "2.16.0-next.12";
31321
+ var SDK_VERSION = "2.16.0-next.13";
31322
31322
 
31323
31323
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31324
31324
  import { chmodSync, existsSync } from "node:fs";
@@ -134922,6 +134922,58 @@ function parseDirectRunSequence(xml, allowRevisions) {
134922
134922
  return null;
134923
134923
  return { currentText, originalText, revisions };
134924
134924
  }
134925
+ function splitLeadingNoteMarkerRun(xml, family) {
134926
+ const firstRun = /^\s*<((?:[A-Za-z_][\w.-]*:)?r)\b(?:"[^"]*"|'[^']*'|[^>"'])*>[\s\S]*?<\/\1>/.exec(xml);
134927
+ if (!firstRun)
134928
+ return null;
134929
+ const markerRunXml = firstRun[0];
134930
+ const localName2 = family === "footnotes" ? "footnoteRef" : "endnoteRef";
134931
+ const markerTag = new RegExp(`<((?:[A-Za-z_][\\w.-]*:)?)${localName2}\\s*\\/>`, "g");
134932
+ const markers = [...markerRunXml.matchAll(markerTag)];
134933
+ if (markers.length !== 1)
134934
+ return null;
134935
+ let valid = true;
134936
+ let depth = 0;
134937
+ let markerCount = 0;
134938
+ const parser = new import_saxes3.SaxesParser({
134939
+ xmlns: true,
134940
+ additionalNamespaces: replayAdditionalNamespaces(markerRunXml)
134941
+ });
134942
+ parser.on("error", () => {
134943
+ valid = false;
134944
+ });
134945
+ parser.on("opentag", (tag) => {
134946
+ depth += 1;
134947
+ if (depth === 1 && tag.local === "replay")
134948
+ return;
134949
+ if (depth === 2 && tag.uri === W_NS && tag.local === "r")
134950
+ return;
134951
+ if (depth === 3 && tag.uri === W_NS && tag.local === "rPr")
134952
+ return;
134953
+ if (depth === 3 && tag.uri === W_NS && tag.local === localName2 && tag.isSelfClosing && Object.keys(tag.attributes).length === 0) {
134954
+ markerCount += 1;
134955
+ return;
134956
+ }
134957
+ if (depth === 3 || (tag.local === "footnoteRef" || tag.local === "endnoteRef"))
134958
+ valid = false;
134959
+ });
134960
+ parser.on("closetag", () => {
134961
+ depth -= 1;
134962
+ });
134963
+ try {
134964
+ parser.write(`<replay>${markerRunXml}</replay>`).close();
134965
+ } catch {
134966
+ valid = false;
134967
+ }
134968
+ const withoutMarker = markerRunXml.replace(markerTag, "<w:t/>");
134969
+ if (!valid || depth !== 0 || markerCount !== 1 || parseDirectRunSequence(withoutMarker, false)?.currentText !== "")
134970
+ return null;
134971
+ return { markerRunXml, remainingRunXml: xml.slice(markerRunXml.length) };
134972
+ }
134973
+ function sameNoteMarkerRunXml(base2, target) {
134974
+ const withoutRedundantWordNamespace = (xml) => xml.split(` xmlns:w="${W_NS}"`).join("").split(` xmlns:w='${W_NS}'`).join("");
134975
+ return withoutRedundantWordNamespace(base2) === withoutRedundantWordNamespace(target);
134976
+ }
134925
134977
  function inspectDirectParagraphRevisionRuns(xml) {
134926
134978
  return parseDirectRunSequence(xml, true);
134927
134979
  }
@@ -135265,9 +135317,21 @@ function parseXmlStartTag(rawTag) {
135265
135317
  return null;
135266
135318
  }
135267
135319
  function validateRunContents(xml, options) {
135268
- if (xml === "")
135320
+ const baseHasNoteMarker = options.baseRunXml !== undefined && /<(?:[A-Za-z_][\w.-]*:)?(?:footnoteRef|endnoteRef)\b/.test(options.baseRunXml);
135321
+ const targetHasNoteMarker = /<(?:[A-Za-z_][\w.-]*:)?(?:footnoteRef|endnoteRef)\b/.test(xml);
135322
+ let runs = xml;
135323
+ if (baseHasNoteMarker || targetHasNoteMarker) {
135324
+ const family = options.noteMarkerFamily;
135325
+ const target = family && splitLeadingNoteMarkerRun(xml, family);
135326
+ const base2 = family && options.baseRunXml !== undefined ? splitLeadingNoteMarkerRun(options.baseRunXml, family) : undefined;
135327
+ if (!target || options.baseRunXml !== undefined && (!base2 || !sameNoteMarkerRunXml(base2.markerRunXml, target.markerRunXml))) {
135328
+ return { ok: false, reason: "target runs change or misplace the note marker" };
135329
+ }
135330
+ runs = target.remainingRunXml;
135331
+ }
135332
+ if (runs === "")
135269
135333
  return { ok: true };
135270
- const replayXml = stripAllowedNoteReferences(xml, options);
135334
+ const replayXml = stripAllowedNoteReferences(runs, options);
135271
135335
  const withoutCarriers = replayXml !== null && options.baseRunXml ? stripRetainedCarrier(replayXml, options.baseRunXml, options.allowNamespaceDeclarationDifference === true) : replayXml;
135272
135336
  const withoutBookmarks = withoutCarriers !== null && /<(?:[\w.-]+:)?bookmark(?:Start|End)\b/.test(withoutCarriers) ? preservedBookmarkRunTokens(withoutCarriers)?.strippedXml ?? null : withoutCarriers;
135273
135337
  if (withoutBookmarks === null || UNSUPPORTED_XML.test(withoutBookmarks) || RELATIONSHIP_REFERENCE.test(withoutBookmarks)) {
@@ -136990,7 +137054,8 @@ function validateCompareApplyPlan(value, baseBody = []) {
136990
137054
  if (!isRecord9(group) || !Array.isArray(group.operations))
136991
137055
  return;
136992
137056
  group.operations.forEach((operation, operationIndex) => {
136993
- validateBodyOperation(operation, `storyOperations[${index}].operations[${operationIndex}]`, problems);
137057
+ const noteMarkerFamily = (group.family === "footnotes" || group.family === "endnotes") && isRecord9(operation) && (operation.kind === "edit" || operation.kind === "formatEdit") ? group.family : undefined;
137058
+ validateBodyOperation(operation, `storyOperations[${index}].operations[${operationIndex}]`, problems, { noteMarkerFamily });
136994
137059
  });
136995
137060
  });
136996
137061
  }
@@ -139106,7 +139171,7 @@ function attachExactTargetRevisionReplayToStories(groups, base2, target, matchRe
139106
139171
  });
139107
139172
  return { groups: replayGroups, coveredBaseAnnotations, coveredTargetAnnotations, changedTrackedXmlReplayed };
139108
139173
  }
139109
- function firstUnsafeReplayReason(operations, noteLifecycle = [], targetStories = [], baseBody = []) {
139174
+ function firstUnsafeReplayReason(operations, noteLifecycle = [], targetStories = [], baseBody = [], noteMarkerFamily) {
139110
139175
  const createdNoteReferences = noteLifecycle.filter((operation) => operation.kind === "create-note-definition" || operation.kind === "create-note-story").map((operation) => ({ family: operation.family, noteId: operation.noteId }));
139111
139176
  const retainedNoteReferences = targetStories.flatMap((story) => (story.family === "footnotes" || story.family === "endnotes") && story.noteId ? [{ family: story.family, noteId: story.noteId }] : []);
139112
139177
  const allowedNoteReferences = [...createdNoteReferences, ...retainedNoteReferences];
@@ -139116,7 +139181,7 @@ function firstUnsafeReplayReason(operations, noteLifecycle = [], targetStories =
139116
139181
  continue;
139117
139182
  const result = validateCompareReplayPayload(operation, {
139118
139183
  allowedNoteReferences,
139119
- ...operation.kind === "edit" || operation.kind === "formatEdit" ? { baseRunXml: baseRunByBlockId.get(operation.blockId) } : {}
139184
+ ...operation.kind === "edit" || operation.kind === "formatEdit" ? { baseRunXml: baseRunByBlockId.get(operation.blockId), noteMarkerFamily } : {}
139120
139185
  });
139121
139186
  if (!result.ok)
139122
139187
  return result.reason;
@@ -139310,7 +139375,9 @@ function planCompare(base2, target) {
139310
139375
  for (const group of storyOperations) {
139311
139376
  if (!replayableStoryFamilies.has(group.family))
139312
139377
  continue;
139313
- const unsafeStoryReason = firstUnsafeReplayReason(group.operations);
139378
+ const noteMarkerFamily = group.family === "footnotes" || group.family === "endnotes" ? group.family : undefined;
139379
+ const baseStory = noteMarkerFamily ? base2.stories?.find((story) => story.storyId === group.storyId && story.family === group.family && story.noteId === group.noteId) : undefined;
139380
+ const unsafeStoryReason = firstUnsafeReplayReason(group.operations, [], [], baseStory?.entries ?? [], noteMarkerFamily);
139314
139381
  if (!unsafeStoryReason || unsafeStoryFamilies.has(group.family))
139315
139382
  continue;
139316
139383
  unsafeStoryFamilies.add(group.family);
@@ -222582,7 +222649,10 @@ function normalizeCompareBodyStep(step2, sectionSteps, referenceSteps, allowedNo
222582
222649
  return step2.targetRevisionReplay === undefined || step2.targetRevisionReplay.structuralAction === "delete" ? step2 : null;
222583
222650
  }
222584
222651
  const baseRunXml = step2.kind === "edit" || step2.kind === "formatEdit" ? liveCompareBodyRunXml(state, storyId, step2.blockId) : undefined;
222585
- if (!validateCompareBodyReplayPayload(step2, sectionSteps, referenceSteps, allowedNoteReferences, step2.text, baseRunXml))
222652
+ const noteMarkerFamily = step2.kind === "edit" || step2.kind === "formatEdit" ? storyId.startsWith("footnotes:") ? "footnotes" : storyId.startsWith("endnotes:") ? "endnotes" : undefined : undefined;
222653
+ if (noteMarkerFamily && baseRunXml && /<(?:[A-Za-z_][\w.-]*:)?(?:footnoteRef|endnoteRef)\b/.test(baseRunXml) && step2.targetRunXml === undefined)
222654
+ return null;
222655
+ if (!validateCompareBodyReplayPayload(step2, sectionSteps, referenceSteps, allowedNoteReferences, step2.text, baseRunXml, noteMarkerFamily))
222586
222656
  return null;
222587
222657
  const targetParagraphPropertiesXml = step2.targetParagraphPropertiesXml === undefined ? undefined : canonicalizeCompareBodyParagraphPropertiesXml(step2.targetParagraphPropertiesXml, sectionSteps);
222588
222658
  const targetRunXml = step2.targetRunXml === undefined ? undefined : (step2.targetRunXml.includes("<w:drawing") || step2.targetRunXml.includes("<w:fldSimple")) && baseRunXml && referenceSteps.length === 0 ? step2.targetRunXml : canonicalizeCompareBodyRunXml(step2.targetRunXml, referenceSteps);
@@ -222598,7 +222668,7 @@ function normalizeCompareBodyStep(step2, sectionSteps, referenceSteps, allowedNo
222598
222668
  targetRunXml,
222599
222669
  replayDependencies: "replayDependencies" in step2 ? step2.replayDependencies : undefined,
222600
222670
  targetRevisionReplay: "targetRevisionReplay" in step2 ? step2.targetRevisionReplay : undefined
222601
- }, sectionSteps, referenceSteps, allowedNoteReferences, step2.text, baseRunXml) ? normalized : null;
222671
+ }, sectionSteps, referenceSteps, allowedNoteReferences, step2.text, baseRunXml, noteMarkerFamily) ? normalized : null;
222602
222672
  }
222603
222673
  function liveCompareBodyRunXml(state, storyId, blockId) {
222604
222674
  const entry = getStoryParagraphIndexFromState(state, storyId)?.byParaId(blockId);
@@ -222731,7 +222801,7 @@ function sourceProofBindsReference(proof, family) {
222731
222801
  const childXml = wrappedSource.slice(child.start, child.end);
222732
222802
  return isValidNoteReferenceReplayRunXml(childXml, family, proof.noteId, child.namespaceBindings) && replayCarrierXmlEquals(childXml, proof.referenceRunXml);
222733
222803
  }
222734
- function validateCompareBodyReplayPayload(payload, sectionSteps, referenceSteps, allowedNoteReferences, expectedCurrentText, baseRunXml) {
222804
+ function validateCompareBodyReplayPayload(payload, sectionSteps, referenceSteps, allowedNoteReferences, expectedCurrentText, baseRunXml, noteMarkerFamily) {
222735
222805
  if (payload.targetRunXml !== undefined && expectedCurrentText !== undefined && projectCompareReplayCurrentText(payload.targetRunXml) !== expectedCurrentText.replace(/\uFFFC/g, "")) {
222736
222806
  return false;
222737
222807
  }
@@ -222739,7 +222809,12 @@ function validateCompareBodyReplayPayload(payload, sectionSteps, referenceSteps,
222739
222809
  if (targetParagraphPropertiesXml === null)
222740
222810
  return false;
222741
222811
  const targetRunXml = payload.targetRunXml === undefined ? undefined : stripProtectedReferenceTokens(payload.targetRunXml, referenceSteps);
222742
- return targetRunXml !== null && validateCompareReplayPayload({ ...payload, targetParagraphPropertiesXml, targetRunXml }, { allowedNoteReferences, baseRunXml, allowNamespaceDeclarationDifference: baseRunXml !== undefined }).ok;
222812
+ return targetRunXml !== null && validateCompareReplayPayload({ ...payload, targetParagraphPropertiesXml, targetRunXml }, {
222813
+ allowedNoteReferences,
222814
+ baseRunXml,
222815
+ noteMarkerFamily,
222816
+ allowNamespaceDeclarationDifference: baseRunXml !== undefined
222817
+ }).ok;
222743
222818
  }
222744
222819
  function stripProtectedSectionTokens(xml, sectionSteps) {
222745
222820
  const tokens = collectProtectedSectionTokens(xml, sectionSteps);
@@ -223717,6 +223792,24 @@ function unchangedBookmarkReferenceSteps(oldRuns, targetRuns) {
223717
223792
  afterNamespaceBindings: bookmarkBindings
223718
223793
  }];
223719
223794
  }
223795
+ function retainedNoteMarkerRuns(oldRuns, targetRuns, storyId) {
223796
+ const markerPattern = /<(?:[A-Za-z_][\w.-]*:)?(?:footnoteRef|endnoteRef)\b/;
223797
+ if (!markerPattern.test(oldRuns) && !markerPattern.test(targetRuns)) {
223798
+ return { markerRunXml: "", oldRuns, targetRuns };
223799
+ }
223800
+ const family = storyId.startsWith("footnotes:") ? "footnotes" : storyId.startsWith("endnotes:") ? "endnotes" : null;
223801
+ if (!family)
223802
+ return null;
223803
+ const oldMarker = splitLeadingNoteMarkerRun(oldRuns, family);
223804
+ const targetMarker = splitLeadingNoteMarkerRun(targetRuns, family);
223805
+ if (!oldMarker || !targetMarker || !sameNoteMarkerRunXml(oldMarker.markerRunXml, targetMarker.markerRunXml))
223806
+ return null;
223807
+ return {
223808
+ markerRunXml: oldMarker.markerRunXml,
223809
+ oldRuns: oldMarker.remainingRunXml,
223810
+ targetRuns: targetMarker.remainingRunXml
223811
+ };
223812
+ }
223720
223813
  function runCompareBodyEditCommit(input, storyId, step2, changeMode, options, pushHistory, referenceSteps) {
223721
223814
  const { state, txId } = input;
223722
223815
  const partUri = storyPartUriFromStoryId2(storyId);
@@ -223738,6 +223831,9 @@ function runCompareBodyEditCommit(input, storyId, step2, changeMode, options, pu
223738
223831
  const closeStart = paraXml.lastIndexOf("</");
223739
223832
  const innerXml = closeStart > openEnd ? paraXml.slice(openEnd, closeStart) : "";
223740
223833
  const oldRunsRaw = stripElements(innerXml, "pPr");
223834
+ const retainedMarker = retainedNoteMarkerRuns(oldRunsRaw, newRuns, storyId);
223835
+ if (!retainedMarker)
223836
+ return rejected14(txId, "unsupported-context");
223741
223837
  const stableBookmarkSteps = unchangedBookmarkReferenceSteps(oldRunsRaw, newRuns);
223742
223838
  if (stableBookmarkSteps === null && referenceSteps.length === 0)
223743
223839
  return rejected14(txId, "unsupported-context");
@@ -223756,10 +223852,10 @@ function runCompareBodyEditCommit(input, storyId, step2, changeMode, options, pu
223756
223852
  storyId
223757
223853
  });
223758
223854
  }
223759
- const oldRunsDel = oldRunsRaw.replace(/<((?:[\w.-]+:)?)t(\b[^>]*)>/g, "<$1delText$2>").replace(/<\/((?:[\w.-]+:)?)t>/g, "</$1delText>");
223855
+ const oldRunsDel = retainedMarker.oldRuns.replace(/<((?:[\w.-]+:)?)t(\b[^>]*)>/g, "<$1delText$2>").replace(/<\/((?:[\w.-]+:)?)t>/g, "</$1delText>");
223760
223856
  const hunkStamps = makeCompareHunkStampSource(stamps, input);
223761
- const retainedCarrier = newRuns.includes("<w:drawing") || newRuns.includes("<w:fldSimple") && protectedReferenceSteps.length === 0;
223762
- const protectedRuns = retainedCarrier ? protectedReferenceSteps.length === 0 ? renderTrackedRunsWithRetainedCarrier(oldRunsRaw, newRuns, hunkStamps.next, paragraphWrapper.wordprocessingPrefix, bytes, entry.byteStart, entry.byteEnd) : null : renderTrackedRunsWithProtectedReferences(oldRunsRaw, newRuns, protectedReferenceSteps, hunkStamps.next, paragraphWrapper.wordprocessingPrefix);
223857
+ const retainedCarrier = retainedMarker.targetRuns.includes("<w:drawing") || retainedMarker.targetRuns.includes("<w:fldSimple") && protectedReferenceSteps.length === 0;
223858
+ const protectedRuns = retainedCarrier ? protectedReferenceSteps.length === 0 ? renderTrackedRunsWithRetainedCarrier(retainedMarker.oldRuns, retainedMarker.targetRuns, hunkStamps.next, paragraphWrapper.wordprocessingPrefix, bytes, entry.byteStart, entry.byteEnd) : null : renderTrackedRunsWithProtectedReferences(retainedMarker.oldRuns, retainedMarker.targetRuns, protectedReferenceSteps, hunkStamps.next, paragraphWrapper.wordprocessingPrefix);
223763
223859
  if (retainedCarrier && !protectedRuns)
223764
223860
  return rejected14(txId, "unsupported-context");
223765
223861
  if (!protectedRuns && stableBookmarkSteps?.length)
@@ -223772,10 +223868,10 @@ function runCompareBodyEditCommit(input, storyId, step2, changeMode, options, pu
223772
223868
  } else {
223773
223869
  const fallbackPair = hunkStamps.next();
223774
223870
  delXml = oldRunsDel ? wrapTracked("del", oldRunsDel, fallbackPair.del, "rsidDel", paragraphWrapper.wordprocessingPrefix) : "";
223775
- insXml = newRuns ? wrapTracked("ins", newRuns, fallbackPair.ins, "rsidR", paragraphWrapper.wordprocessingPrefix) : "";
223871
+ insXml = retainedMarker.targetRuns ? wrapTracked("ins", retainedMarker.targetRuns, fallbackPair.ins, "rsidR", paragraphWrapper.wordprocessingPrefix) : "";
223776
223872
  }
223777
223873
  const trackedPPrXml = buildTrackedParagraphProperties(targetParagraphPropertiesXml, pPrXml, stamps.paragraphProperties ?? stamps.ins, paragraphWrapper.wordprocessingPrefix);
223778
- const assembledParaXml = `${paragraphWrapper.openTag}${trackedPPrXml}${delXml}${insXml}${paragraphWrapper.closeTag}`;
223874
+ const assembledParaXml = `${paragraphWrapper.openTag}${trackedPPrXml}` + `${retainedMarker.markerRunXml}${delXml}${insXml}${paragraphWrapper.closeTag}`;
223779
223875
  if (hunkStamps.usedPairs.length === 0) {
223780
223876
  newParaXml = assembledParaXml;
223781
223877
  } else {
@@ -224068,6 +224164,9 @@ function runCompareBodyFormatEditCommit(input, storyId, step2, changeMode, optio
224068
224164
  const closeStart = paraXml.lastIndexOf("</");
224069
224165
  const innerXml = closeStart > openEnd ? paraXml.slice(openEnd, closeStart) : "";
224070
224166
  const oldRunsRaw = stripElements(innerXml, "pPr");
224167
+ const retainedMarker = retainedNoteMarkerRuns(oldRunsRaw, targetRunXml, storyId);
224168
+ if (!retainedMarker)
224169
+ return rejected14(txId, "unsupported-context");
224071
224170
  const paragraphPropertiesChanged = !equivalentParagraphProperties(targetPPrXml, pPrXml);
224072
224171
  const stableBookmarkSteps = unchangedBookmarkReferenceSteps(oldRunsRaw, targetRunXml);
224073
224172
  if (stableBookmarkSteps === null && referenceSteps.length === 0)
@@ -224135,12 +224234,12 @@ function runCompareBodyFormatEditCommit(input, storyId, step2, changeMode, optio
224135
224234
  const stamps = compareTrackedStampPair(input, paragraphPropertiesChanged);
224136
224235
  if (!stamps)
224137
224236
  return rejected14(txId, "no-author-configured");
224138
- const oldRunsDel = oldRunsRaw.replace(/<((?:[\w.-]+:)?)t(\b[^>]*)>/g, "<$1delText$2>").replace(/<\/((?:[\w.-]+:)?)t>/g, "</$1delText>");
224139
- const protectedRuns = renderTrackedRunsWithProtectedReferences(oldRunsRaw, targetRunXml, protectedReferenceSteps, () => stamps, paragraphWrapper.wordprocessingPrefix);
224237
+ const oldRunsDel = retainedMarker.oldRuns.replace(/<((?:[\w.-]+:)?)t(\b[^>]*)>/g, "<$1delText$2>").replace(/<\/((?:[\w.-]+:)?)t>/g, "</$1delText>");
224238
+ const protectedRuns = renderTrackedRunsWithProtectedReferences(retainedMarker.oldRuns, retainedMarker.targetRuns, protectedReferenceSteps, () => stamps, paragraphWrapper.wordprocessingPrefix);
224140
224239
  if (!protectedRuns && stableBookmarkSteps?.length)
224141
224240
  return rejected14(txId, "unsupported-context");
224142
224241
  const delXml = protectedRuns?.xml ?? (oldRunsDel ? wrapTracked("del", oldRunsDel, stamps.del, "rsidDel", paragraphWrapper.wordprocessingPrefix) : "");
224143
- const insXml = protectedRuns ? "" : targetRunXml ? wrapTracked("ins", targetRunXml, stamps.ins, "rsidR", paragraphWrapper.wordprocessingPrefix) : "";
224242
+ const insXml = protectedRuns ? "" : retainedMarker.targetRuns ? wrapTracked("ins", retainedMarker.targetRuns, stamps.ins, "rsidR", paragraphWrapper.wordprocessingPrefix) : "";
224144
224243
  if (delXml || insXml) {
224145
224244
  createdRefs.push({ kind: "trackedChange", entityId: stamps.ins.rsid, storyId });
224146
224245
  }
@@ -224152,7 +224251,7 @@ function runCompareBodyFormatEditCommit(input, storyId, step2, changeMode, optio
224152
224251
  });
224153
224252
  }
224154
224253
  const trackedPPrXml = buildTrackedParagraphProperties(targetParagraphPropertiesXml, pPrXml, stamps.paragraphProperties ?? stamps.ins, paragraphWrapper.wordprocessingPrefix);
224155
- newParaXml = `${paragraphWrapper.openTag}${trackedPPrXml}${delXml}${insXml}${paragraphWrapper.closeTag}`;
224254
+ newParaXml = `${paragraphWrapper.openTag}${trackedPPrXml}` + `${retainedMarker.markerRunXml}${delXml}${insXml}${paragraphWrapper.closeTag}`;
224156
224255
  }
224157
224256
  } else {
224158
224257
  newParaXml = `${paragraphWrapper.openTag}${targetPPrXml}${targetRunXml}${paragraphWrapper.closeTag}`;
@@ -363370,7 +363469,8 @@ function buildHeaderFooterLifecyclePlan(base3, target) {
363370
363469
  const after = targetParts.get(partUri);
363371
363470
  const kind = after?.kind ?? before.kind;
363372
363471
  const relationshipsChanged = !headerFooterPartRelationshipsEqual(before?.relationshipsBytes ?? null, after?.relationshipsBytes ?? null);
363373
- const changed = !before || !after || !numbersEqual(before.bytes, after.bytes) || relationshipsChanged;
363472
+ const contentChanged = Boolean(before && after && (before.bytes.length !== after.bytes.length || before.bytes.some((value2, index2) => value2 !== after.bytes[index2])));
363473
+ const changed = !before || !after || contentChanged || relationshipsChanged;
363374
363474
  if (!changed)
363375
363475
  continue;
363376
363476
  if (hasUnsafeRelationshipDependencyChange(before, after, relationshipsChanged)) {
@@ -363387,7 +363487,7 @@ function buildHeaderFooterLifecyclePlan(base3, target) {
363387
363487
  });
363388
363488
  } else if (before && !after) {
363389
363489
  rewrites.push({ family: "header-footer-parts", partUri, kind: "remove" });
363390
- } else if (before && after && !numbersEqual(before.bytes, after.bytes)) {
363490
+ } else if (before && after && contentChanged) {
363391
363491
  contentRewrites.push({
363392
363492
  family: "header-footer-parts",
363393
363493
  partUri,
@@ -365053,6 +365153,17 @@ function isCommentRelationshipSemanticKey(semanticKey) {
365053
365153
  const relType = semanticKey.slice(sep + 1);
365054
365154
  return /\/relationships\/(?:comments|commentsExtended|commentsIds|commentsExtensible|threadedComments|people)$/i.test(relType);
365055
365155
  }
365156
+ function isResolutionSidecarAddition(key2, targetEntry) {
365157
+ if (!targetEntry)
365158
+ return false;
365159
+ if (key2 === "ct:override:/word/commentsExtended.xml") {
365160
+ return targetEntry.semanticKey === key2 && targetEntry.contentSignature === sha256HexSync(TE62.encode("override:/word/commentsExtended.xml=" + "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml"));
365161
+ }
365162
+ if (!key2.startsWith("rel:/word/document.xml|"))
365163
+ return false;
365164
+ const type = "http://schemas.microsoft.com/office/2011/relationships/commentsExtended";
365165
+ return targetEntry.semanticKey === `/word/document.xml|${type}` && targetEntry.contentSignature === sha256HexSync(TE62.encode(`type:${type}#mode:Internal#target:/word/commentsExtended.xml`));
365166
+ }
365056
365167
  function isCommentScopedPackageKey(context, key2, presentInBase, hasCommentCreate, targetEntry) {
365057
365168
  if (key2.startsWith("ct:")) {
365058
365169
  const uri = key2.slice(key2.indexOf(":", 3) + 1);
@@ -365088,10 +365199,15 @@ function packageGraphKeysNotCoveredByComments(context, base3, target, steps) {
365088
365199
  changedKeys.add(key2);
365089
365200
  const hasCommentCreate = steps.some((s) => s.kind === "create");
365090
365201
  const hasCommentDelete = steps.some((s) => s.kind === "delete");
365202
+ const hasRootResolution = steps.some((s) => s.kind === "set-resolved" && s.resolved && !s.targetIsReply && s.targetParentParaId === null);
365203
+ const addedResolutionSidecarKeys = [...changedKeys].filter((key2) => !baseSigs.has(key2) && targetSigs.has(key2) && isResolutionSidecarAddition(key2, targetEntries.get(key2)));
365204
+ const coversResolutionSidecar = hasRootResolution && addedResolutionSidecarKeys.length === 2 && addedResolutionSidecarKeys.includes("ct:override:/word/commentsExtended.xml");
365091
365205
  const notCovered = [];
365092
365206
  for (const key2 of changedKeys) {
365093
365207
  const presentInBase = baseSigs.has(key2);
365094
365208
  const presentInTarget = targetSigs.has(key2);
365209
+ if (coversResolutionSidecar && addedResolutionSidecarKeys.includes(key2))
365210
+ continue;
365095
365211
  let lifecycleCoversEntry = false;
365096
365212
  if (presentInBase !== presentInTarget) {
365097
365213
  lifecycleCoversEntry = presentInBase ? hasCommentDelete : hasCommentCreate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.3.0-next.12",
3
+ "version": "1.3.0-next.13",
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.16.0-next.12",
27
+ "@superdoc/sdk": "2.16.0-next.13",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.19.0-next.11",
33
- "@superdoc/docx-engine": "0.18.0-next.11",
32
+ "superdoc": "2.19.0-next.12",
33
+ "@superdoc/docx-engine": "0.18.0-next.12",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",