@superdoc-dev/cli 0.5.0-next.15 → 0.5.0-next.17

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 CHANGED
@@ -141,6 +141,7 @@ function parseGlobalArgs(argv) {
141
141
  let prettyFlag = false;
142
142
  let timeoutMs;
143
143
  let sessionId;
144
+ let quiet = false;
144
145
  let help = false;
145
146
  let version2 = false;
146
147
  const rest = [];
@@ -162,6 +163,10 @@ function parseGlobalArgs(argv) {
162
163
  help = true;
163
164
  continue;
164
165
  }
166
+ if (token === "--quiet") {
167
+ quiet = true;
168
+ continue;
169
+ }
165
170
  if (token === "--version" || token === "-v") {
166
171
  version2 = true;
167
172
  continue;
@@ -221,6 +226,7 @@ function parseGlobalArgs(argv) {
221
226
  output,
222
227
  timeoutMs,
223
228
  sessionId,
229
+ quiet,
224
230
  help,
225
231
  version: version2
226
232
  },
@@ -42278,6 +42284,42 @@ var init_cli_only_operation_definitions = __esm(() => {
42278
42284
  required: ["contextId", "closed"]
42279
42285
  }
42280
42286
  },
42287
+ insertTab: {
42288
+ category: "core",
42289
+ description: "Insert a real Word tab node at a collapsed text insertion point. Accepts the same target/ref shortcuts as insert, but only for point inserts.",
42290
+ requiresDocumentContext: false,
42291
+ tokenOverride: ["insert", "tab"],
42292
+ sdkMetadata: { mutates: true, idempotency: "non-idempotent", supportsTrackedMode: false, supportsDryRun: false },
42293
+ outputSchema: {
42294
+ type: "object",
42295
+ properties: {
42296
+ document: { type: "object" },
42297
+ receipt: { type: "object" },
42298
+ inserted: { type: "object" },
42299
+ context: { type: "object" },
42300
+ output: { type: "object" }
42301
+ },
42302
+ required: ["receipt", "inserted"]
42303
+ }
42304
+ },
42305
+ insertLineBreak: {
42306
+ category: "core",
42307
+ description: "Insert a real Word line-break node at a collapsed text insertion point. Accepts the same target/ref shortcuts as insert, but only for point inserts.",
42308
+ requiresDocumentContext: false,
42309
+ tokenOverride: ["insert", "line-break"],
42310
+ sdkMetadata: { mutates: true, idempotency: "non-idempotent", supportsTrackedMode: false, supportsDryRun: false },
42311
+ outputSchema: {
42312
+ type: "object",
42313
+ properties: {
42314
+ document: { type: "object" },
42315
+ receipt: { type: "object" },
42316
+ inserted: { type: "object" },
42317
+ context: { type: "object" },
42318
+ output: { type: "object" }
42319
+ },
42320
+ required: ["receipt", "inserted"]
42321
+ }
42322
+ },
42281
42323
  status: {
42282
42324
  category: "session",
42283
42325
  description: "Show the current session status and document metadata.",
@@ -42482,6 +42524,8 @@ var init_types4 = __esm(() => {
42482
42524
  "open",
42483
42525
  "save",
42484
42526
  "close",
42527
+ "insertTab",
42528
+ "insertLineBreak",
42485
42529
  "status",
42486
42530
  "describe",
42487
42531
  "describeCommand",
@@ -63290,7 +63334,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
63290
63334
  emptyOptions2 = {};
63291
63335
  });
63292
63336
 
63293
- // ../../packages/superdoc/dist/chunks/SuperConverter-CMIR0kxi.es.js
63337
+ // ../../packages/superdoc/dist/chunks/SuperConverter-B4A4OihU.es.js
63294
63338
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
63295
63339
  const fieldValue = extension$1.config[field];
63296
63340
  if (typeof fieldValue === "function")
@@ -100954,13 +100998,15 @@ var isRegExp = (value) => {
100954
100998
  const docPartGalleryType = params3.extraParams.docPartGalleryType;
100955
100999
  const id2 = sdtPr?.elements?.find((el) => el.name === "w:id")?.attributes["w:val"] || "";
100956
101000
  const docPartObj = sdtPr?.elements.find((el) => el.name === "w:docPartObj");
101001
+ const docPartGallery = docPartGalleryType ?? docPartObj?.elements?.find((el) => el.name === "w:docPartGallery")?.attributes?.["w:val"] ?? null;
101002
+ const docPartUnique = docPartObj?.elements.some((el) => el.name === "w:docPartUnique") ?? false;
100957
101003
  return {
100958
101004
  type: "documentPartObject",
100959
- content: translatedContent,
101005
+ content: normalizeDocPartContent(translatedContent),
100960
101006
  attrs: {
100961
101007
  id: id2,
100962
- docPartGallery: docPartGalleryType ?? docPartObj?.elements?.find((el) => el.name === "w:docPartGallery")?.attributes?.["w:val"] ?? null,
100963
- docPartUnique: docPartObj?.elements.some((el) => el.name === "w:docPartUnique") ?? false,
101008
+ docPartGallery,
101009
+ docPartUnique,
100964
101010
  sdtPr
100965
101011
  }
100966
101012
  };
@@ -113940,7 +113986,7 @@ var isRegExp = (value) => {
113940
113986
  state.kern = kernNode.attributes["w:val"];
113941
113987
  }
113942
113988
  }, SuperConverter;
113943
- var init_SuperConverter_CMIR0kxi_es = __esm(() => {
113989
+ var init_SuperConverter_B4A4OihU_es = __esm(() => {
113944
113990
  init_rolldown_runtime_B2q5OVn9_es();
113945
113991
  init_jszip_ChlR43oI_es();
113946
113992
  init_xml_js_40FWvL78_es();
@@ -129521,7 +129567,14 @@ var init_SuperConverter_CMIR0kxi_es = __esm(() => {
129521
129567
  };
129522
129568
  translator$6 = NodeTranslator.from(config$30);
129523
129569
  validGalleryTypeMap = { "Table of Contents": tableOfContentsHandler };
129524
- inlineNodeTypes = new Set(["bookmarkStart", "bookmarkEnd"]);
129570
+ inlineNodeTypes = new Set([
129571
+ "bookmarkStart",
129572
+ "bookmarkEnd",
129573
+ "commentRangeStart",
129574
+ "commentRangeEnd",
129575
+ "permStart",
129576
+ "permEnd"
129577
+ ]);
129525
129578
  factor16 = Math.pow(2, 16);
129526
129579
  StepMap.empty = new StepMap([]);
129527
129580
  stepsByID = Object.create(null);
@@ -172449,7 +172502,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
172449
172502
  init_remark_gfm_z_sDF4ss_es();
172450
172503
  });
172451
172504
 
172452
- // ../../packages/superdoc/dist/chunks/src-sOP3agXO.es.js
172505
+ // ../../packages/superdoc/dist/chunks/src-DRK5pSwz.es.js
172453
172506
  function deleteProps(obj, propOrProps) {
172454
172507
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
172455
172508
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -243359,11 +243412,16 @@ var Node$13 = class Node$14 {
243359
243412
  });
243360
243413
  return Object.fromEntries(markEntries);
243361
243414
  }
243362
- }, Commands, handleEnter = (editor) => {
243415
+ }, Commands, dispatchHistoryBoundary = (view) => {
243416
+ const tr = view?.state?.tr;
243417
+ if (!tr)
243418
+ return;
243419
+ view.dispatch?.(closeHistory(tr));
243420
+ }, handleEnter = (editor) => {
243363
243421
  const { view } = editor;
243364
- view?.dispatch?.(closeHistory(view?.state?.tr));
243422
+ dispatchHistoryBoundary(view);
243365
243423
  return editor.commands.first(({ commands: commands$1 }) => [
243366
- () => commands$1.splitRunToParagraph(),
243424
+ () => commands$1.splitRunToParagraph?.() ?? false,
243367
243425
  () => commands$1.newlineInCode(),
243368
243426
  () => commands$1.createParagraphNear(),
243369
243427
  () => commands$1.liftEmptyBlock(),
@@ -243371,7 +243429,7 @@ var Node$13 = class Node$14 {
243371
243429
  ]);
243372
243430
  }, handleBackspace = (editor) => {
243373
243431
  const { view } = editor;
243374
- view?.dispatch?.(closeHistory(view?.state?.tr));
243432
+ dispatchHistoryBoundary(view);
243375
243433
  return editor.commands.first(({ commands: commands$1, tr }) => [
243376
243434
  () => commands$1.undoInputRule(),
243377
243435
  () => {
@@ -243389,7 +243447,7 @@ var Node$13 = class Node$14 {
243389
243447
  ]);
243390
243448
  }, handleDelete2 = (editor) => {
243391
243449
  const { view } = editor;
243392
- view?.dispatch?.(closeHistory(view?.state?.tr));
243450
+ dispatchHistoryBoundary(view);
243393
243451
  return editor.commands.first(({ commands: commands$1 }) => [
243394
243452
  () => commands$1.deleteSkipEmptyRun(),
243395
243453
  () => commands$1.deleteNextToRun(),
@@ -253853,9 +253911,9 @@ var Node$13 = class Node$14 {
253853
253911
  return;
253854
253912
  console.log(...args$1);
253855
253913
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
253856
- var init_src_sOP3agXO_es = __esm(() => {
253914
+ var init_src_DRK5pSwz_es = __esm(() => {
253857
253915
  init_rolldown_runtime_B2q5OVn9_es();
253858
- init_SuperConverter_CMIR0kxi_es();
253916
+ init_SuperConverter_B4A4OihU_es();
253859
253917
  init_jszip_ChlR43oI_es();
253860
253918
  init_uuid_qzgm05fK_es();
253861
253919
  init_constants_Qqwopz80_es();
@@ -287805,8 +287863,8 @@ var init_zipper_YmNpPIyc_es = __esm(() => {
287805
287863
 
287806
287864
  // ../../packages/superdoc/dist/super-editor.es.js
287807
287865
  var init_super_editor_es = __esm(() => {
287808
- init_src_sOP3agXO_es();
287809
- init_SuperConverter_CMIR0kxi_es();
287866
+ init_src_DRK5pSwz_es();
287867
+ init_SuperConverter_B4A4OihU_es();
287810
287868
  init_jszip_ChlR43oI_es();
287811
287869
  init_xml_js_40FWvL78_es();
287812
287870
  init_constants_Qqwopz80_es();
@@ -336225,6 +336283,25 @@ async function getFileChecksum(path2) {
336225
336283
  }
336226
336284
  return createHash2("sha256").update(bytes).digest("hex");
336227
336285
  }
336286
+ async function exportOptionalSessionOutput(editor, io, outPath, force) {
336287
+ if (!outPath)
336288
+ return;
336289
+ try {
336290
+ return { output: await exportToPath(editor, outPath, force) };
336291
+ } catch (error4) {
336292
+ const code7 = error4 instanceof CliError ? error4.code : "FILE_WRITE_ERROR";
336293
+ const message = error4 instanceof Error ? error4.message : String(error4);
336294
+ io.warn?.(`[warn] optional export to ${outPath} failed: ${message}
336295
+ `);
336296
+ return {
336297
+ warning: {
336298
+ code: code7,
336299
+ path: outPath,
336300
+ message
336301
+ }
336302
+ };
336303
+ }
336304
+ }
336228
336305
  async function exportToPath(editor, outputPath, force = false) {
336229
336306
  const exists = await pathExists(outputPath);
336230
336307
  if (exists && !force) {
@@ -337892,18 +337969,6 @@ function buildPrettyOutput2(operationId, document2, result2, outputPath) {
337892
337969
  const verb = SUCCESS_VERB[operationId];
337893
337970
  return outputPath ? `Revision ${document2.revision}: ${verb} -> ${outputPath}` : `Revision ${document2.revision}: ${verb}`;
337894
337971
  }
337895
- async function exportOptionalSessionOutput(editor, outPath, force) {
337896
- if (!outPath)
337897
- return;
337898
- try {
337899
- return await exportToPath(editor, outPath, force);
337900
- } catch (error4) {
337901
- const message = error4 instanceof Error ? error4.message : String(error4);
337902
- process.stderr.write(`[warn] optional export to ${outPath} failed: ${message}
337903
- `);
337904
- return;
337905
- }
337906
- }
337907
337972
  async function executeMutationOperation(request) {
337908
337973
  const { operationId, input: input2, context } = request;
337909
337974
  const doc4 = readOptionalString(input2, "doc");
@@ -338014,7 +338079,7 @@ async function executeMutationOperation(request) {
338014
338079
  await writeContextMetadata(paths, updatedMetadata);
338015
338080
  byteLength3 = workingOutput.byteLength;
338016
338081
  }
338017
- const externalOutput = await exportOptionalSessionOutput(opened.editor, outPath, force);
338082
+ const externalOutput = await exportOptionalSessionOutput(opened.editor, context.io, outPath, force);
338018
338083
  const document2 = {
338019
338084
  path: updatedMetadata.sourcePath,
338020
338085
  source: updatedMetadata.source,
@@ -338027,9 +338092,16 @@ async function executeMutationOperation(request) {
338027
338092
  changeMode,
338028
338093
  dryRun: false,
338029
338094
  context: { dirty: updatedMetadata.dirty, revision: updatedMetadata.revision },
338030
- output: externalOutput
338095
+ output: externalOutput?.output ?? (externalOutput?.warning ? {
338096
+ path: externalOutput.warning.path,
338097
+ failed: true,
338098
+ error: {
338099
+ code: externalOutput.warning.code,
338100
+ message: externalOutput.warning.message
338101
+ }
338102
+ } : undefined)
338031
338103
  }),
338032
- pretty: buildPrettyOutput2(operationId, document2, result2, externalOutput?.path)
338104
+ pretty: buildPrettyOutput2(operationId, document2, result2, externalOutput?.output?.path)
338033
338105
  };
338034
338106
  } finally {
338035
338107
  opened.dispose();
@@ -338352,7 +338424,8 @@ var init_command_examples = __esm(() => {
338352
338424
  insert: [
338353
338425
  'superdoc insert --value "Hello, world!"',
338354
338426
  'superdoc insert --block-id abc123 --value "Appended text"',
338355
- 'superdoc insert --type markdown --value "## New Section"'
338427
+ 'superdoc insert --type markdown --value "## New Section"',
338428
+ 'superdoc insert --block-id abc123 --offset 5 --type html --value "<br/>"'
338356
338429
  ],
338357
338430
  replace: [
338358
338431
  'superdoc replace --block-id abc123 --start 0 --end 5 --text "Updated"',
@@ -338412,7 +338485,10 @@ var init_command_examples = __esm(() => {
338412
338485
  "lists.setType": [
338413
338486
  `superdoc lists set-type --target-json '{"kind":"block","nodeType":"listItem","nodeId":"abc123"}' --kind bullet`
338414
338487
  ],
338415
- "format.apply": [`superdoc format apply --block-id abc123 --start 0 --end 10 --inline-json '{"bold":true}'`],
338488
+ "format.apply": [
338489
+ `superdoc format apply --block-id abc123 --start 0 --end 10 --inline-json '{"bold":true}'`,
338490
+ `superdoc format apply --block-id abc123 --start 7 --end 14 --inline-json '{"fontSize":16,"fontFamily":"Times New Roman"}'`
338491
+ ],
338416
338492
  "comments.create": ['superdoc comments create --block-id abc123 --start 0 --end 5 --text "Review this section"'],
338417
338493
  "comments.list": ["superdoc comments list"],
338418
338494
  "comments.get": ["superdoc comments get --id comment-123"],
@@ -338425,7 +338501,8 @@ var init_command_examples = __esm(() => {
338425
338501
  "history.undo": ["superdoc history undo"],
338426
338502
  "history.redo": ["superdoc history redo"],
338427
338503
  "mutations.apply": [
338428
- `superdoc mutations apply --atomic true --change-mode direct --steps-json '[{"id":"s1","op":"text.rewrite","where":{"by":"select","select":{"type":"text","pattern":"old"},"require":"first"},"args":{"replacement":{"text":"new"}}}]'`
338504
+ `superdoc mutations apply --atomic true --change-mode direct --steps-json '[{"id":"s1","op":"text.rewrite","where":{"by":"select","select":{"type":"text","pattern":"old"},"require":"first"},"args":{"replacement":{"text":"new"}}}]'`,
338505
+ `superdoc mutations apply --atomic true --change-mode direct --steps-json '[{"id":"s1","op":"text.insert","where":{"by":"target","target":{"kind":"selection","start":{"kind":"text","blockId":"abc123","offset":0},"end":{"kind":"text","blockId":"abc123","offset":0}}},"args":{"position":"before","content":{"text":"ALPHA01 "}}},{"id":"s2","op":"format.apply","where":{"by":"target","target":{"kind":"selection","start":{"kind":"text","blockId":"abc123","offset":8},"end":{"kind":"text","blockId":"abc123","offset":15}}},"args":{"inline":{"fontSize":16,"fontFamily":"Times New Roman"}}}]'`
338429
338506
  ],
338430
338507
  "mutations.preview": [
338431
338508
  `superdoc mutations preview --atomic true --change-mode direct --steps-json '[{"id":"s1","op":"text.rewrite","where":{"by":"select","select":{"type":"text","pattern":"old"},"require":"first"},"args":{"replacement":{"text":"new"}}}]'`
@@ -338491,9 +338568,11 @@ function buildHelpText() {
338491
338568
  const lines = ["Usage: superdoc <command> [options]", ""];
338492
338569
  lines.push("Common tasks:");
338493
338570
  lines.push(" Find mutation target → query match");
338571
+ lines.push(" Seed a synthetic doc → open --content-override ...");
338494
338572
  lines.push(" Insert between list items → lists insert");
338495
338573
  lines.push(" Create a paragraph → create paragraph");
338496
338574
  lines.push(" Insert inline text → insert");
338575
+ lines.push(" Insert a real tab → insert tab");
338497
338576
  lines.push(" Batch formatting changes → mutations apply");
338498
338577
  lines.push("");
338499
338578
  const categories = new Map;
@@ -338540,9 +338619,30 @@ var init_commands = __esm(() => {
338540
338619
  init_command_examples();
338541
338620
  init_operation_set();
338542
338621
  CLI_ONLY_OVERRIDES = {
338543
- open: { mutates: true, examples: ["superdoc open my-doc.docx", "superdoc open my-doc.docx --session my-session"] },
338622
+ open: {
338623
+ mutates: true,
338624
+ examples: [
338625
+ "superdoc open my-doc.docx",
338626
+ 'superdoc open --content-override "# Title\\n\\nBody text" --override-type markdown',
338627
+ "superdoc open template.docx --content-override '<p>ALPHA01</p><p>BRAVO02</p>' --override-type html"
338628
+ ]
338629
+ },
338544
338630
  save: { mutates: true, examples: ["superdoc save", "superdoc save --out copy.docx"] },
338545
338631
  close: { mutates: true, examples: ["superdoc close"] },
338632
+ insertTab: {
338633
+ mutates: true,
338634
+ examples: [
338635
+ "superdoc insert tab --block-id abc123 --offset 5",
338636
+ `superdoc insert tab --target-json '{"kind":"selection","start":{"kind":"text","blockId":"abc123","offset":5},"end":{"kind":"text","blockId":"abc123","offset":5}}'`
338637
+ ]
338638
+ },
338639
+ insertLineBreak: {
338640
+ mutates: true,
338641
+ examples: [
338642
+ "superdoc insert line-break --block-id abc123 --offset 5",
338643
+ `superdoc insert line-break --target-json '{"kind":"selection","start":{"kind":"text","blockId":"abc123","offset":5},"end":{"kind":"text","blockId":"abc123","offset":5}}'`
338644
+ ]
338645
+ },
338546
338646
  status: { mutates: false, examples: ["superdoc status"] },
338547
338647
  describe: { mutates: false, examples: ["superdoc describe"] },
338548
338648
  describeCommand: { mutates: false, examples: ["superdoc describe command find"] },
@@ -338945,7 +339045,7 @@ function deriveOptionSpecs(operationId, params4) {
338945
339045
  }
338946
339046
  return specs;
338947
339047
  }
338948
- var DOC_PARAM, SESSION_PARAM, OUT_PARAM, FORCE_PARAM, DRY_RUN_PARAM, CHANGE_MODE_PARAM, EXPECTED_REVISION_PARAM, USER_NAME_PARAM, USER_EMAIL_PARAM, PASSWORD_PARAM, AGENT_HIDDEN_PARAM_NAMES, OPERATION_CONSTRAINTS, PARAM_FLAG_OVERRIDES, DOC_FIND_SELECT_SCHEMA, PARAM_SCHEMA_OVERRIDES, PARAM_EXCLUSIONS, TEXT_TARGET_FLAT_PARAMS, TEXT_TARGET_FLAT_PARAMS_AGENT_HIDDEN, LIST_TARGET_FLAT_PARAMS, FORMAT_OPERATION_IDS, EXTRA_CLI_PARAMS, CLI_ONLY_METADATA, CLI_OPERATION_METADATA, OPTION_FLAG_ALIASES, CLI_OPERATION_OPTION_SPECS;
339048
+ var DOC_PARAM, SESSION_PARAM, OUT_PARAM, FORCE_PARAM, DRY_RUN_PARAM, CHANGE_MODE_PARAM, EXPECTED_REVISION_PARAM, USER_NAME_PARAM, USER_EMAIL_PARAM, PASSWORD_PARAM, AGENT_HIDDEN_PARAM_NAMES, OPERATION_CONSTRAINTS, PARAM_FLAG_OVERRIDES, DOC_FIND_SELECT_SCHEMA, PARAM_SCHEMA_OVERRIDES, PARAM_EXCLUSIONS, TEXT_TARGET_FLAT_PARAMS, TEXT_TARGET_FLAT_PARAMS_AGENT_HIDDEN, SELECTION_TARGET_JSON_PARAM, INSERT_REF_PARAM, LIST_TARGET_FLAT_PARAMS, FORMAT_OPERATION_IDS, EXTRA_CLI_PARAMS, CLI_ONLY_METADATA, CLI_OPERATION_METADATA, OPTION_FLAG_ALIASES, CLI_OPERATION_OPTION_SPECS;
338949
339049
  var init_operation_params = __esm(() => {
338950
339050
  init_src();
338951
339051
  init_commands();
@@ -339091,6 +339191,19 @@ var init_operation_params = __esm(() => {
339091
339191
  ...p4,
339092
339192
  agentVisible: false
339093
339193
  }));
339194
+ SELECTION_TARGET_JSON_PARAM = {
339195
+ name: "target",
339196
+ kind: "jsonFlag",
339197
+ flag: "target-json",
339198
+ type: "json",
339199
+ description: "Collapsed text insertion point as SelectionTarget JSON."
339200
+ };
339201
+ INSERT_REF_PARAM = {
339202
+ name: "ref",
339203
+ kind: "flag",
339204
+ type: "string",
339205
+ description: "Mutation-ready ref returned by query.match or ranges.resolve."
339206
+ };
339094
339207
  LIST_TARGET_FLAT_PARAMS = [
339095
339208
  { name: "nodeId", kind: "flag", flag: "node-id", type: "string", description: "Node ID of the target list item." }
339096
339209
  ];
@@ -339594,6 +339707,54 @@ var init_operation_params = __esm(() => {
339594
339707
  params: [SESSION_PARAM, { name: "discard", kind: "flag", type: "boolean" }],
339595
339708
  constraints: null
339596
339709
  },
339710
+ "doc.insertTab": {
339711
+ command: "insert tab",
339712
+ positionalParams: ["doc"],
339713
+ docRequirement: "none",
339714
+ params: [
339715
+ DOC_PARAM,
339716
+ SESSION_PARAM,
339717
+ OUT_PARAM,
339718
+ FORCE_PARAM,
339719
+ EXPECTED_REVISION_PARAM,
339720
+ SELECTION_TARGET_JSON_PARAM,
339721
+ INSERT_REF_PARAM,
339722
+ ...TEXT_TARGET_FLAT_PARAMS,
339723
+ {
339724
+ name: "offset",
339725
+ kind: "flag",
339726
+ type: "number",
339727
+ description: "Character offset for insertion (alias for --start/--end with the same value)."
339728
+ }
339729
+ ],
339730
+ constraints: {
339731
+ mutuallyExclusive: [["target", "ref"]]
339732
+ }
339733
+ },
339734
+ "doc.insertLineBreak": {
339735
+ command: "insert line-break",
339736
+ positionalParams: ["doc"],
339737
+ docRequirement: "none",
339738
+ params: [
339739
+ DOC_PARAM,
339740
+ SESSION_PARAM,
339741
+ OUT_PARAM,
339742
+ FORCE_PARAM,
339743
+ EXPECTED_REVISION_PARAM,
339744
+ SELECTION_TARGET_JSON_PARAM,
339745
+ INSERT_REF_PARAM,
339746
+ ...TEXT_TARGET_FLAT_PARAMS,
339747
+ {
339748
+ name: "offset",
339749
+ kind: "flag",
339750
+ type: "number",
339751
+ description: "Character offset for insertion (alias for --start/--end with the same value)."
339752
+ }
339753
+ ],
339754
+ constraints: {
339755
+ mutuallyExclusive: [["target", "ref"]]
339756
+ }
339757
+ },
339597
339758
  "doc.status": {
339598
339759
  command: "status",
339599
339760
  positionalParams: [],
@@ -340900,6 +341061,261 @@ var init_close = __esm(() => {
340900
341061
  init_context();
340901
341062
  });
340902
341063
 
341064
+ // src/commands/insert-inline-special.ts
341065
+ function isRecord7(value2) {
341066
+ return typeof value2 === "object" && value2 != null && !Array.isArray(value2);
341067
+ }
341068
+ function isSelectionTarget3(value2) {
341069
+ return isRecord7(value2) && value2.kind === "selection" && isRecord7(value2.start) && isRecord7(value2.end);
341070
+ }
341071
+ function isCollapsedTextSelectionTarget(target2) {
341072
+ return target2.start.kind === "text" && target2.end.kind === "text" && target2.start.blockId === target2.end.blockId && target2.start.offset === target2.end.offset;
341073
+ }
341074
+ function buildPrettyOutput3(kind2, revision, outputPath) {
341075
+ const label2 = COMMAND_BY_KIND[kind2].label;
341076
+ return outputPath ? `Revision ${revision}: inserted ${label2} -> ${outputPath}` : `Revision ${revision}: inserted ${label2}`;
341077
+ }
341078
+ async function resolveInsertionPoint(editor, input2, kind2) {
341079
+ const apiInput = extractInvokeInput("insert", input2);
341080
+ if (!isRecord7(apiInput)) {
341081
+ throw new CliError("INVALID_ARGUMENT", `insert ${COMMAND_BY_KIND[kind2].label}: invalid target input.`);
341082
+ }
341083
+ const ref4 = typeof apiInput.ref === "string" ? apiInput.ref : undefined;
341084
+ const rawTarget = apiInput.target;
341085
+ if (ref4) {
341086
+ const resolved = editor.doc.invoke({
341087
+ operationId: "ranges.resolve",
341088
+ input: {
341089
+ start: { kind: "ref", ref: ref4, boundary: "start" },
341090
+ end: { kind: "ref", ref: ref4, boundary: "start" }
341091
+ }
341092
+ });
341093
+ if (!isSelectionTarget3(resolved?.target) || !isCollapsedTextSelectionTarget(resolved.target)) {
341094
+ throw new CliError("INVALID_TARGET", `insert ${COMMAND_BY_KIND[kind2].label}: ref must resolve to a collapsed text insertion point.`);
341095
+ }
341096
+ const collapsedTarget = {
341097
+ kind: "text",
341098
+ blockId: resolved.target.start.blockId,
341099
+ range: { start: resolved.target.start.offset, end: resolved.target.start.offset }
341100
+ };
341101
+ const resolvedRange = resolveSelectionTarget(editor, resolved.target);
341102
+ return {
341103
+ target: collapsedTarget,
341104
+ range: { from: resolvedRange.absFrom, to: resolvedRange.absTo }
341105
+ };
341106
+ }
341107
+ if (rawTarget !== undefined) {
341108
+ if (!isSelectionTarget3(rawTarget)) {
341109
+ throw new CliError("INVALID_TARGET", `insert ${COMMAND_BY_KIND[kind2].label}: target must be a collapsed text selection.`);
341110
+ }
341111
+ const selectionTarget = rawTarget;
341112
+ if (!isCollapsedTextSelectionTarget(selectionTarget)) {
341113
+ throw new CliError("INVALID_TARGET", `insert ${COMMAND_BY_KIND[kind2].label}: target must be a collapsed text selection.`);
341114
+ }
341115
+ const resolvedRange = resolveSelectionTarget(editor, selectionTarget);
341116
+ return {
341117
+ target: {
341118
+ kind: "text",
341119
+ blockId: selectionTarget.start.blockId,
341120
+ range: { start: selectionTarget.start.offset, end: selectionTarget.start.offset }
341121
+ },
341122
+ range: { from: resolvedRange.absFrom, to: resolvedRange.absTo }
341123
+ };
341124
+ }
341125
+ const fallback = resolveDefaultInsertTarget(editor);
341126
+ if (!fallback) {
341127
+ throw new CliError("TARGET_NOT_FOUND", `insert ${COMMAND_BY_KIND[kind2].label}: no writable text block is available. Pass an explicit collapsed text target.`);
341128
+ }
341129
+ if (fallback.kind === "structural-end") {
341130
+ return {
341131
+ kind: "structural-end",
341132
+ target: { kind: "text", blockId: "", range: { start: 0, end: 0 } },
341133
+ insertPos: fallback.insertPos
341134
+ };
341135
+ }
341136
+ return {
341137
+ kind: "text-block",
341138
+ target: fallback.target,
341139
+ range: fallback.range
341140
+ };
341141
+ }
341142
+ function executeInlineSpecialInsert(editor, kind2, insertionPoint) {
341143
+ const commandName = kind2 === "tab" ? "insertTabNode" : "insertLineBreak";
341144
+ const commands2 = editor.commands;
341145
+ const command2 = commands2?.[commandName];
341146
+ if (typeof command2 !== "function") {
341147
+ throw new CliError("CAPABILITY_UNAVAILABLE", `insert ${COMMAND_BY_KIND[kind2].label}: ${commandName} is unavailable.`);
341148
+ }
341149
+ let chain = editor.chain();
341150
+ if (insertionPoint.kind === "structural-end") {
341151
+ if (typeof commands2?.insertParagraphAt !== "function") {
341152
+ throw new CliError("CAPABILITY_UNAVAILABLE", `insert ${COMMAND_BY_KIND[kind2].label}: insertParagraphAt is unavailable.`);
341153
+ }
341154
+ chain = chain.insertParagraphAt({ pos: insertionPoint.insertPos, tracked: false }).setTextSelection({ from: insertionPoint.insertPos + 1, to: insertionPoint.insertPos + 1 });
341155
+ } else {
341156
+ const { from: from5, to } = insertionPoint.range;
341157
+ if (from5 !== to) {
341158
+ throw new CliError("INVALID_TARGET", `insert ${COMMAND_BY_KIND[kind2].label}: target must be collapsed to a single insertion point.`);
341159
+ }
341160
+ chain = chain.setMeta("inputType", "programmatic").setMeta("skipTrackChanges", true).setTextSelection({ from: from5, to });
341161
+ }
341162
+ chain = kind2 === "tab" ? chain.insertTabNode() : chain.insertLineBreak();
341163
+ if (chain.run() !== true) {
341164
+ throw new CliError("COMMAND_FAILED", `insert ${COMMAND_BY_KIND[kind2].label}: editor command returned false.`);
341165
+ }
341166
+ }
341167
+ function buildSuccessData(kind2, document2, target2, revision, output) {
341168
+ return {
341169
+ document: document2,
341170
+ receipt: {
341171
+ success: true,
341172
+ resolution: {
341173
+ target: target2
341174
+ }
341175
+ },
341176
+ inserted: { kind: kind2 },
341177
+ context: { dirty: true, revision },
341178
+ output: output?.output ?? (output?.warning ? {
341179
+ path: output.warning.path,
341180
+ failed: true,
341181
+ error: {
341182
+ code: output.warning.code,
341183
+ message: output.warning.message
341184
+ }
341185
+ } : undefined)
341186
+ };
341187
+ }
341188
+ async function runInsertInlineSpecial(kind2, tokens, context) {
341189
+ const commandSpec = COMMAND_BY_KIND[kind2];
341190
+ const { parsed, help } = parseOperationArgs(commandSpec.operationId, tokens, {
341191
+ commandName: `insert ${kind2 === "tab" ? "tab" : "line-break"}`
341192
+ });
341193
+ if (help || getBooleanOption(parsed, "help")) {
341194
+ return {
341195
+ command: kind2 === "tab" ? "insert tab" : "insert line-break",
341196
+ data: {
341197
+ usage: [
341198
+ `superdoc insert ${kind2 === "tab" ? "tab" : "line-break"} [doc] [--target-json '{...}'|--block-id <id> --offset <n>]`,
341199
+ `superdoc insert ${kind2 === "tab" ? "tab" : "line-break"} [doc] [--ref <ref>] [--out <path>]`
341200
+ ]
341201
+ },
341202
+ pretty: [
341203
+ "Usage:",
341204
+ ` superdoc insert ${kind2 === "tab" ? "tab" : "line-break"} [doc] [--target-json '{...}'|--block-id <id> --offset <n>]`,
341205
+ ` superdoc insert ${kind2 === "tab" ? "tab" : "line-break"} [doc] [--ref <ref>] [--out <path>]`
341206
+ ].join(`
341207
+ `)
341208
+ };
341209
+ }
341210
+ const { doc: doc4 } = resolveDocArg(parsed, `insert ${COMMAND_BY_KIND[kind2].label}`);
341211
+ const outPath = getStringOption(parsed, "out");
341212
+ const force = getBooleanOption(parsed, "force");
341213
+ const expectedRevisionRaw = parsed.options.expectedRevision;
341214
+ const expectedRevision = typeof expectedRevisionRaw === "number" ? expectedRevisionRaw : undefined;
341215
+ const commandName = kind2 === "tab" ? "insert tab" : "insert line-break";
341216
+ const input2 = parsed.options;
341217
+ if (doc4 && expectedRevision != null) {
341218
+ throw new CliError("INVALID_ARGUMENT", `${commandName}: --expected-revision is only supported with an active open context.`);
341219
+ }
341220
+ if (doc4) {
341221
+ if (!outPath) {
341222
+ throw new CliError("MISSING_REQUIRED", `${commandName}: missing required --out.`);
341223
+ }
341224
+ const source = doc4 === "-" ? "stdin" : "path";
341225
+ const opened = await openDocument(doc4, context.io);
341226
+ try {
341227
+ const resolved = await resolveInsertionPoint(opened.editor, input2, kind2);
341228
+ executeInlineSpecialInsert(opened.editor, kind2, resolved);
341229
+ const output = await exportToPath(opened.editor, outPath, force);
341230
+ const document2 = {
341231
+ path: source === "path" ? doc4 : undefined,
341232
+ source,
341233
+ byteLength: opened.meta.byteLength,
341234
+ revision: 0
341235
+ };
341236
+ return {
341237
+ command: commandName,
341238
+ data: buildSuccessData(kind2, document2, resolved.target, 0, { output }),
341239
+ pretty: buildPrettyOutput3(kind2, 0, output.path)
341240
+ };
341241
+ } finally {
341242
+ opened.dispose();
341243
+ }
341244
+ }
341245
+ return withActiveContext(context.io, commandName, async ({ metadata, paths }) => {
341246
+ assertExpectedRevision(metadata, expectedRevision);
341247
+ const isHostMode = context.executionMode === "host" && context.sessionPool != null;
341248
+ const opened = await openSessionDocument(paths.workingDocPath, context.io, metadata, {
341249
+ sessionId: context.sessionId ?? metadata.contextId,
341250
+ executionMode: context.executionMode,
341251
+ sessionPool: context.sessionPool
341252
+ });
341253
+ try {
341254
+ const resolved = await resolveInsertionPoint(opened.editor, input2, kind2);
341255
+ executeInlineSpecialInsert(opened.editor, kind2, resolved);
341256
+ let updatedMetadata;
341257
+ let byteLength3;
341258
+ if (isHostMode) {
341259
+ context.sessionPool.markDirty(metadata.contextId);
341260
+ updatedMetadata = markContextUpdated(context.io, metadata, {
341261
+ dirty: true,
341262
+ revision: metadata.revision + 1
341263
+ });
341264
+ await writeContextMetadata(paths, updatedMetadata);
341265
+ context.sessionPool.updateMetadataRevision(metadata.contextId, updatedMetadata.revision);
341266
+ byteLength3 = opened.meta.byteLength;
341267
+ } else if (metadata.sessionType === "collab") {
341268
+ const synced = await syncCollaborativeSessionSnapshot(context.io, metadata, paths, opened.editor);
341269
+ updatedMetadata = synced.updatedMetadata;
341270
+ byteLength3 = synced.output.byteLength;
341271
+ } else {
341272
+ const workingOutput = await exportToPath(opened.editor, paths.workingDocPath, true);
341273
+ updatedMetadata = markContextUpdated(context.io, metadata, {
341274
+ dirty: true,
341275
+ revision: metadata.revision + 1
341276
+ });
341277
+ await writeContextMetadata(paths, updatedMetadata);
341278
+ byteLength3 = workingOutput.byteLength;
341279
+ }
341280
+ const externalOutput = await exportOptionalSessionOutput(opened.editor, context.io, outPath, force);
341281
+ const document2 = {
341282
+ path: updatedMetadata.sourcePath,
341283
+ source: updatedMetadata.source,
341284
+ byteLength: byteLength3,
341285
+ revision: updatedMetadata.revision
341286
+ };
341287
+ return {
341288
+ command: commandName,
341289
+ data: buildSuccessData(kind2, document2, resolved.target, updatedMetadata.revision, externalOutput),
341290
+ pretty: buildPrettyOutput3(kind2, updatedMetadata.revision, externalOutput?.output?.path)
341291
+ };
341292
+ } finally {
341293
+ opened.dispose();
341294
+ }
341295
+ }, context.sessionId, context.executionMode);
341296
+ }
341297
+ function runInsertTab(tokens, context) {
341298
+ return runInsertInlineSpecial("tab", tokens, context);
341299
+ }
341300
+ function runInsertLineBreak(tokens, context) {
341301
+ return runInsertInlineSpecial("lineBreak", tokens, context);
341302
+ }
341303
+ var COMMAND_BY_KIND;
341304
+ var init_insert_inline_special = __esm(() => {
341305
+ init_super_editor_es();
341306
+ init_args();
341307
+ init_context();
341308
+ init_document();
341309
+ init_errors();
341310
+ init_invoke_input();
341311
+ init_operation_args();
341312
+ init_session_collab();
341313
+ COMMAND_BY_KIND = {
341314
+ tab: { operationId: "doc.insertTab", label: "tab" },
341315
+ lineBreak: { operationId: "doc.insertLineBreak", label: "line break" }
341316
+ };
341317
+ });
341318
+
340903
341319
  // src/lib/open-password.ts
340904
341320
  function resolvePassword(explicit, allowEnvFallback = true) {
340905
341321
  if (explicit != null)
@@ -341429,6 +341845,7 @@ function getLegacyRunner(operationId) {
341429
341845
  var LEGACY_RUNNERS;
341430
341846
  var init_legacy_operation_dispatch = __esm(() => {
341431
341847
  init_close();
341848
+ init_insert_inline_special();
341432
341849
  init_open();
341433
341850
  init_save();
341434
341851
  init_session_close();
@@ -341439,6 +341856,8 @@ var init_legacy_operation_dispatch = __esm(() => {
341439
341856
  "doc.open": runOpen,
341440
341857
  "doc.save": runSave,
341441
341858
  "doc.close": runClose,
341859
+ "doc.insertTab": runInsertTab,
341860
+ "doc.insertLineBreak": runInsertLineBreak,
341442
341861
  "doc.session.list": runSessionList,
341443
341862
  "doc.session.save": runSessionSave,
341444
341863
  "doc.session.close": runSessionClose,
@@ -341454,6 +341873,8 @@ var init_manual_command_allowlist = __esm(() => {
341454
341873
  "open",
341455
341874
  "save",
341456
341875
  "close",
341876
+ "insert tab",
341877
+ "insert line-break",
341457
341878
  "session list",
341458
341879
  "session save",
341459
341880
  "session close",
@@ -341464,6 +341885,8 @@ var init_manual_command_allowlist = __esm(() => {
341464
341885
  "doc.open",
341465
341886
  "doc.save",
341466
341887
  "doc.close",
341888
+ "doc.insertTab",
341889
+ "doc.insertLineBreak",
341467
341890
  "doc.session.list",
341468
341891
  "doc.session.save",
341469
341892
  "doc.session.close",
@@ -347595,35 +348018,61 @@ var init_uninstall = __esm(() => {
347595
348018
  import { readFileSync } from "node:fs";
347596
348019
  import { dirname as dirname3, resolve as resolve3 } from "node:path";
347597
348020
  import { fileURLToPath as fileURLToPath2 } from "node:url";
347598
- function resolveCliPackagePath() {
347599
- const __filename3 = fileURLToPath2(import.meta.url);
347600
- const __dirname3 = dirname3(__filename3);
347601
- return resolve3(__dirname3, "../../package.json");
348021
+ function parsePackageJson(rawPackageJson) {
348022
+ try {
348023
+ return JSON.parse(rawPackageJson);
348024
+ } catch {
348025
+ return null;
348026
+ }
348027
+ }
348028
+ function isSupportedCliPackageName(name2) {
348029
+ return typeof name2 === "string" && (name2 === CLI_PACKAGE_NAME || name2.startsWith(`${CLI_PACKAGE_NAME}-`));
348030
+ }
348031
+ function resolveCliPackagePath(moduleUrl) {
348032
+ let currentDir = dirname3(fileURLToPath2(moduleUrl));
348033
+ while (true) {
348034
+ const packageJsonPath = resolve3(currentDir, "package.json");
348035
+ try {
348036
+ const rawPackageJson = readFileSync(packageJsonPath, "utf8");
348037
+ const parsed = parsePackageJson(rawPackageJson);
348038
+ if (isSupportedCliPackageName(parsed?.name)) {
348039
+ return packageJsonPath;
348040
+ }
348041
+ } catch {}
348042
+ const parentDir = dirname3(currentDir);
348043
+ if (parentDir === currentDir) {
348044
+ return null;
348045
+ }
348046
+ currentDir = parentDir;
348047
+ }
347602
348048
  }
347603
348049
  function parsePackageVersion(rawPackageJson) {
348050
+ const parsed = parsePackageJson(rawPackageJson);
348051
+ if (typeof parsed?.version === "string" && parsed.version.length > 0) {
348052
+ return parsed.version;
348053
+ }
348054
+ return null;
348055
+ }
348056
+ function resolveCliPackageVersionFromModuleUrl(moduleUrl) {
347604
348057
  try {
347605
- const parsed = JSON.parse(rawPackageJson);
347606
- if (typeof parsed.version === "string" && parsed.version.length > 0) {
347607
- return parsed.version;
348058
+ const packageJsonPath = resolveCliPackagePath(moduleUrl);
348059
+ if (!packageJsonPath) {
348060
+ return FALLBACK_CLI_PACKAGE_VERSION;
347608
348061
  }
347609
- } catch {}
347610
- return null;
348062
+ const packageJson = readFileSync(packageJsonPath, "utf8");
348063
+ return parsePackageVersion(packageJson) ?? FALLBACK_CLI_PACKAGE_VERSION;
348064
+ } catch {
348065
+ return FALLBACK_CLI_PACKAGE_VERSION;
348066
+ }
347611
348067
  }
347612
348068
  function resolveCliPackageVersion() {
347613
348069
  if (cachedCliPackageVersion) {
347614
348070
  return cachedCliPackageVersion;
347615
348071
  }
347616
- try {
347617
- const packageJson = readFileSync(resolveCliPackagePath(), "utf8");
347618
- const version4 = parsePackageVersion(packageJson);
347619
- cachedCliPackageVersion = version4 ?? FALLBACK_CLI_PACKAGE_VERSION;
347620
- return cachedCliPackageVersion;
347621
- } catch {
347622
- cachedCliPackageVersion = FALLBACK_CLI_PACKAGE_VERSION;
347623
- return cachedCliPackageVersion;
347624
- }
348072
+ cachedCliPackageVersion = resolveCliPackageVersionFromModuleUrl(import.meta.url);
348073
+ return cachedCliPackageVersion;
347625
348074
  }
347626
- var FALLBACK_CLI_PACKAGE_VERSION = "0.0.0", cachedCliPackageVersion = null;
348075
+ var CLI_PACKAGE_NAME = "@superdoc-dev/cli", FALLBACK_CLI_PACKAGE_VERSION = "0.0.0", cachedCliPackageVersion = null;
347627
348076
  var init_version2 = () => {};
347628
348077
 
347629
348078
  // src/host/session-pool.ts
@@ -348212,6 +348661,9 @@ function defaultIo() {
348212
348661
  stderr(message) {
348213
348662
  process.stderr.write(message);
348214
348663
  },
348664
+ warn(message) {
348665
+ process.stderr.write(message);
348666
+ },
348215
348667
  readStdinBytes() {
348216
348668
  if (stdinCache)
348217
348669
  return stdinCache;
@@ -348245,10 +348697,20 @@ function mergeIo(overrides) {
348245
348697
  return {
348246
348698
  stdout: overrides.stdout ?? base5.stdout,
348247
348699
  stderr: overrides.stderr ?? base5.stderr,
348700
+ warn: overrides.warn ?? base5.warn,
348248
348701
  readStdinBytes: overrides.readStdinBytes ?? base5.readStdinBytes,
348249
348702
  now: overrides.now ?? base5.now
348250
348703
  };
348251
348704
  }
348705
+ function applyDiagnosticPolicy(io, globals) {
348706
+ if (globals.output === "pretty" && !globals.quiet) {
348707
+ return io;
348708
+ }
348709
+ return {
348710
+ ...io,
348711
+ warn() {}
348712
+ };
348713
+ }
348252
348714
  function parseCommand(rest) {
348253
348715
  if (rest.length === 0) {
348254
348716
  throw new CliError("MISSING_REQUIRED", "Missing command.");
@@ -348355,7 +348817,8 @@ async function invokeCommand(argv, options2 = {}) {
348355
348817
  const startedAt = io.now();
348356
348818
  const { parsed, output } = await withStateDirOverride(options2.stateDir, async () => {
348357
348819
  const parsedInvocation = parseInvocation(argv);
348358
- const commandOutput = await executeParsedInvocation(parsedInvocation, io, options2.executionMode ?? "oneshot", options2.sessionPool);
348820
+ const runtimeIo = applyDiagnosticPolicy(io, parsedInvocation.globals);
348821
+ const commandOutput = await executeParsedInvocation(parsedInvocation, runtimeIo, options2.executionMode ?? "oneshot", options2.sessionPool);
348359
348822
  return { parsed: parsedInvocation, output: commandOutput };
348360
348823
  });
348361
348824
  return {
@@ -348378,6 +348841,7 @@ async function run2(argv, ioOverrides, options2 = {}) {
348378
348841
  try {
348379
348842
  const parsed = parseInvocation(argv);
348380
348843
  outputMode = parsed.globals.output;
348844
+ const runtimeIo = applyDiagnosticPolicy(io, parsed.globals);
348381
348845
  if (parsed.globals.version && !parsed.globals.help) {
348382
348846
  io.stdout(`${resolveCliPackageVersion()}
348383
348847
  `);
@@ -348404,7 +348868,7 @@ async function run2(argv, ioOverrides, options2 = {}) {
348404
348868
  return legacyCompat.exitCode;
348405
348869
  }
348406
348870
  }
348407
- const output = await executeParsedInvocation(parsed, io, "oneshot");
348871
+ const output = await executeParsedInvocation(parsed, runtimeIo, "oneshot");
348408
348872
  if (output.helpText) {
348409
348873
  io.stdout(output.helpText);
348410
348874
  return 0;
@@ -348436,6 +348900,7 @@ var init_src2 = __esm(async () => {
348436
348900
  init_input_readers();
348437
348901
  init_call();
348438
348902
  init_close();
348903
+ init_insert_inline_special();
348439
348904
  init_open();
348440
348905
  init_session_close();
348441
348906
  init_session_list();
@@ -348468,6 +348933,7 @@ var init_src2 = __esm(async () => {
348468
348933
  " --pretty",
348469
348934
  " --session <id>",
348470
348935
  " --timeout-ms <n>",
348936
+ " --quiet",
348471
348937
  " --help, -h",
348472
348938
  " --version, -v"
348473
348939
  ].join(`
@@ -348475,6 +348941,8 @@ var init_src2 = __esm(async () => {
348475
348941
  MANUAL_COMMANDS = {
348476
348942
  call: runCall,
348477
348943
  close: runClose,
348944
+ "insert line-break": runInsertLineBreak,
348945
+ "insert tab": runInsertTab,
348478
348946
  open: runOpen,
348479
348947
  save: runSave,
348480
348948
  "session list": runSessionList,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.5.0-next.15",
3
+ "version": "0.5.0-next.17",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -26,19 +26,19 @@
26
26
  "typescript": "^5.9.2",
27
27
  "@superdoc/document-api": "0.0.1",
28
28
  "@superdoc/pm-adapter": "0.0.0",
29
- "@superdoc/super-editor": "0.0.1",
30
- "superdoc": "1.23.0"
29
+ "superdoc": "1.23.0",
30
+ "@superdoc/super-editor": "0.0.1"
31
31
  },
32
32
  "module": "src/index.ts",
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@superdoc-dev/cli-darwin-arm64": "0.5.0-next.15",
38
- "@superdoc-dev/cli-darwin-x64": "0.5.0-next.15",
39
- "@superdoc-dev/cli-windows-x64": "0.5.0-next.15",
40
- "@superdoc-dev/cli-linux-arm64": "0.5.0-next.15",
41
- "@superdoc-dev/cli-linux-x64": "0.5.0-next.15"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.5.0-next.17",
38
+ "@superdoc-dev/cli-darwin-x64": "0.5.0-next.17",
39
+ "@superdoc-dev/cli-linux-x64": "0.5.0-next.17",
40
+ "@superdoc-dev/cli-linux-arm64": "0.5.0-next.17",
41
+ "@superdoc-dev/cli-windows-x64": "0.5.0-next.17"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",
package/skill/SKILL.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: editing-docx
2
+ name: superdoc-edit-docx
3
3
  description: Edit, query, and transform Word documents with the SuperDoc CLI v1 operation surface. Use when the user asks to read, search, modify, comment, or review changes in .docx files.
4
4
  ---
5
5
 
@@ -24,7 +24,7 @@ Use `describe command` for per-command args and constraints.
24
24
 
25
25
  ## Preferred Workflows
26
26
 
27
- ### 1) Stateful multi-step edits (recommended)
27
+ ### 1) Edit an existing document (recommended for targeted changes)
28
28
 
29
29
  ```bash
30
30
  superdoc open ./contract.docx
@@ -34,12 +34,51 @@ superdoc save --in-place
34
34
  superdoc close
35
35
  ```
36
36
 
37
- - Always use `query match` (not `find`) to discover mutation targets it returns exact addresses with cardinality guarantees.
37
+ - Use `query match` when you are modifying existing content and need an exact mutation target.
38
38
  - After `open`, commands run against the active/default session when `<doc>` is omitted.
39
39
  - Use `superdoc session list|set-default|save|close` for explicit session control.
40
40
  - `close` on dirty state requires `--discard` or a prior `save`.
41
41
 
42
- ### 2) Stateless one-off reads
42
+ ### 2) Generate or seed a document body (recommended for synthetic/probe docs)
43
+
44
+ Use `open --content-override` when you want to create a new body from Markdown, HTML, or plain text in one step.
45
+
46
+ ```bash
47
+ superdoc open --content-override "# Probe Title\n\nALPHA01" --override-type markdown
48
+ superdoc save --out ./probe.docx
49
+ superdoc close
50
+ ```
51
+
52
+ ```bash
53
+ superdoc open template.docx \
54
+ --content-override '<p>ALPHA01 <strong>BRAVO02</strong><br/>CHARLIE03</p>' \
55
+ --override-type html
56
+ superdoc save --out ./probe.docx
57
+ superdoc close
58
+ ```
59
+
60
+ - `--content-override` is the fastest way to seed paragraphs, headings, lists, and `<br/>` line breaks.
61
+ - Use `--override-type markdown|html|text` explicitly. `open` rejects `--content-override` without it.
62
+ - For generation, do not start with `query match` unless you are modifying content that already exists.
63
+
64
+ ### 3) Generate incrementally, then reuse the insert receipt target
65
+
66
+ When you need deterministic inline formatting after seeding text, insert first, then reuse the returned target block/range.
67
+
68
+ ```bash
69
+ superdoc open
70
+ superdoc insert --value "ALPHA01 BRAVO02 CHARLIE03"
71
+ superdoc format apply --block-id <from-insert-receipt> --start 8 --end 15 --inline-json '{"fontSize":16,"fontFamily":"Times New Roman"}'
72
+ superdoc format apply --block-id <from-insert-receipt> --start 16 --end 25 --inline-json '{"fontSize":10,"fontFamily":"Arial"}'
73
+ superdoc save --out ./probe.docx
74
+ superdoc close
75
+ ```
76
+
77
+ - The insert receipt contains the resolved target under `receipt.resolution.target`.
78
+ - For a simple one-paragraph synthetic doc, direct `--block-id --start --end` formatting is usually shorter than re-querying.
79
+ - Use `query match` again only if later steps need to rediscover content by meaning, not by the range you just created.
80
+
81
+ ### 4) Stateless one-off reads
43
82
 
44
83
  ```bash
45
84
  superdoc get-text ./proposal.docx
@@ -47,7 +86,7 @@ superdoc get-markdown ./proposal.docx
47
86
  superdoc info ./proposal.docx
48
87
  ```
49
88
 
50
- ### 3) Stateless one-off mutations
89
+ ### 5) Stateless one-off mutations
51
90
 
52
91
  ```bash
53
92
  superdoc replace ./proposal.docx \
@@ -58,6 +97,20 @@ superdoc replace ./proposal.docx \
58
97
 
59
98
  - In stateless mode (`<doc>` provided), mutating commands require `--out` unless using `--dry-run`.
60
99
 
100
+ ### 6) Inline special nodes: tabs vs line breaks
101
+
102
+ - `insert line-break` inserts a real Word line break node inside the current paragraph.
103
+ - `insert tab` inserts a real Word tab node inside the current paragraph.
104
+ - Paragraph tab stops are different. Tab stops control layout positions; tab nodes are inline content characters that advance to the next tab stop.
105
+
106
+ ```bash
107
+ superdoc insert line-break --block-id p1 --offset 12
108
+ superdoc insert tab --block-id p1 --offset 12
109
+ ```
110
+
111
+ - Use `format paragraph set-tab-stop` / related paragraph formatting commands when you need the tab stop definitions themselves.
112
+ - Use the inline insert commands when you need actual `w:br` or `w:tab` content in exported DOCX.
113
+
61
114
  ### Safety: preview before apply
62
115
 
63
116
  - Use `--dry-run` to preview any mutation without applying it.
@@ -76,6 +129,7 @@ superdoc replace ./proposal.docx \
76
129
 
77
130
  - Replace text: `replace --target-json '{...}' --text "..."`
78
131
  - Insert inline text: `insert --block-id <id> --offset <n> --value "..."`
132
+ - Insert inline tab/line break nodes: `insert tab`, `insert line-break`
79
133
  - Delete text/node: `delete --target-json '{...}'`
80
134
  - Delete blocks: `blocks delete`, `blocks delete-range`
81
135
  - Batch mutations: `mutations apply --steps-json '[...]' --atomic true --change-mode direct`
@@ -131,8 +185,10 @@ Always supported alongside their `-json` counterpart (use one, not both):
131
185
  ## Output and Global Flags
132
186
 
133
187
  - Default output is JSON envelope.
188
+ - In JSON mode, command results are returned as a JSON envelope.
134
189
  - Use `--pretty` for human-readable output (not supported by `call`).
135
- - Global flags: `--output <json|pretty>`, `--session <id>`, `--timeout-ms <n>`.
190
+ - Use `--quiet` to suppress non-essential warnings in pretty mode.
191
+ - Global flags: `--output <json|pretty>`, `--session <id>`, `--timeout-ms <n>`, `--quiet`.
136
192
  - `<doc>` can be `-` to read DOCX bytes from stdin.
137
193
 
138
194
  ## Legacy Compatibility (Use Sparingly)