@superdoc-dev/sdk 1.8.0-next.8 → 1.8.0-next.81

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.
@@ -83,6 +83,8 @@ def dispatch_intent_tool(
83
83
  return execute('doc.lists.attach', rest)
84
84
  elif action == 'detach':
85
85
  return execute('doc.lists.detach', rest)
86
+ elif action == 'delete':
87
+ return execute('doc.lists.delete', rest)
86
88
  elif action == 'indent':
87
89
  return execute('doc.lists.indent', rest)
88
90
  elif action == 'outdent':
@@ -136,5 +138,44 @@ def dispatch_intent_tool(
136
138
  return execute('doc.mutations.apply', rest)
137
139
  else:
138
140
  raise SuperDocError(f'Unknown action for superdoc_mutations: {action}', code='TOOL_DISPATCH_NOT_FOUND', details={'toolName': 'superdoc_mutations', 'action': action})
141
+ elif tool_name == 'superdoc_table':
142
+ action = args.get('action')
143
+ rest = {k: v for k, v in args.items() if k != 'action'}
144
+ if action == 'delete':
145
+ return execute('doc.tables.delete', rest)
146
+ elif action == 'set_layout':
147
+ return execute('doc.tables.setLayout', rest)
148
+ elif action == 'insert_row':
149
+ return execute('doc.tables.insertRow', rest)
150
+ elif action == 'delete_row':
151
+ return execute('doc.tables.deleteRow', rest)
152
+ elif action == 'set_row':
153
+ return execute('doc.tables.setRowHeight', rest)
154
+ elif action == 'set_row_options':
155
+ return execute('doc.tables.setRowOptions', rest)
156
+ elif action == 'insert_column':
157
+ return execute('doc.tables.insertColumn', rest)
158
+ elif action == 'delete_column':
159
+ return execute('doc.tables.deleteColumn', rest)
160
+ elif action == 'set_column':
161
+ return execute('doc.tables.setColumnWidth', rest)
162
+ elif action == 'merge_cells':
163
+ return execute('doc.tables.mergeCells', rest)
164
+ elif action == 'unmerge_cells':
165
+ return execute('doc.tables.unmergeCells', rest)
166
+ elif action == 'set_cell':
167
+ return execute('doc.tables.setCellProperties', rest)
168
+ elif action == 'set_cell_text':
169
+ return execute('doc.tables.setCellText', rest)
170
+ elif action == 'set_shading':
171
+ return execute('doc.tables.setShading', rest)
172
+ elif action == 'set_style_options':
173
+ return execute('doc.tables.applyStyle', rest)
174
+ elif action == 'set_borders':
175
+ return execute('doc.tables.setBorders', rest)
176
+ elif action == 'set_options':
177
+ return execute('doc.tables.setTableOptions', rest)
178
+ else:
179
+ raise SuperDocError(f'Unknown action for superdoc_table: {action}', code='TOOL_DISPATCH_NOT_FOUND', details={'toolName': 'superdoc_table', 'action': action})
139
180
  else:
140
181
  raise SuperDocError(f'Unknown intent tool: {tool_name}', code='TOOL_DISPATCH_NOT_FOUND', details={'toolName': tool_name})
@@ -8,6 +8,7 @@
8
8
  | superdoc_create | Create paragraphs, headings, or tables | Yes |
9
9
  | superdoc_format | Apply inline and paragraph formatting, set named styles | Yes |
10
10
  | superdoc_list | Create and manipulate bullet/numbered lists | Yes |
11
+ | superdoc_table | Create / modify tables: structure, cell text, styling | Yes |
11
12
  | superdoc_comment | Create, update, delete, and list comment threads | Yes |
12
13
  | superdoc_track_changes | List, accept, or reject tracked changes | Yes |
13
14
  | superdoc_mutations | Execute multi-step atomic edits in a single batch | Yes |
@@ -306,6 +307,57 @@ Selectors resolve at compile time (before execution). This means format.apply st
306
307
 
307
308
  Never create two steps targeting overlapping text in the same block. Combine them into a single text.rewrite instead.
308
309
 
310
+ ### Tables: cross-tool workflows
311
+
312
+ Tool-local rules (which action to pick, locator shapes, color formats) live in the `superdoc_table` description itself. The rules below cover workflows that **cross tools** — that's the part the model gets wrong without explicit guidance.
313
+
314
+ **1. After `set_cell_text`, format the new cell to match its siblings.**
315
+ `set_cell_text` writes plain text with no formatting. To match the rest of the table:
316
+
317
+ ```
318
+ // Read a sibling cell's text style first (or any body paragraph if the table is fresh):
319
+ superdoc_get_content({action: "blocks", includeText: true})
320
+
321
+ // Apply matching inline style to the new cell's paragraph:
322
+ superdoc_format({action: "inline", ref: "<new-cell-paragraph-ref>",
323
+ inline: {fontFamily, fontSize, color, bold: false}})
324
+ ```
325
+
326
+ If sibling cells show a bold-prefix pattern like `"Label: value"`, replicate it on the new cell using `superdoc_search` + `superdoc_format` (or one `superdoc_mutations` batch with `format.apply` steps using `where:{by:"select", ...}`).
327
+
328
+ **2. "Style the whole table" crosses `superdoc_table` and `superdoc_format`.**
329
+ Borders / shading / cnf flags / spacing live on `superdoc_table`. **Cell-text alignment and font color/weight live on `superdoc_format`** (they're paragraph- and run-level). A complete table-styling pass calls both:
330
+
331
+ ```
332
+ // Table-level (superdoc_table):
333
+ set_borders applyTo:"all" with explicit color
334
+ set_shading on the header cells with the accent color
335
+ set_style_options { headerRow: true }
336
+
337
+ // Cell-text level (superdoc_format, per cell paragraph):
338
+ set_alignment on header (center) and body (left or right)
339
+ inline { color, bold } on header cells
340
+
341
+ // Batch many cell-level format calls via superdoc_mutations format.apply.
342
+ ```
343
+
344
+ Discover the document's palette by reading `superdoc_get_content({action: "blocks"})` and reusing colors from existing tables/headings. When none are obvious, default to `1F3864` (corporate blue) or `444444` (dark grey) for accents and `F2F2F2` / `E7E6E6` for banding. Never use `auto` when a concrete color is implied.
345
+
346
+ **3. After a structural change to a styled table, re-apply the existing styling.**
347
+ Triggers: `insert_row`, `insert_column`, `delete_row`, `delete_column`, `merge_cells`, `unmerge_cells` — but NOT `set_cell_text` or `set_cell` (those don't disturb borders/shading). Read the current borders/shading/cnf flags via `superdoc_get_content({action: "blocks"})` before the change, then re-run the same `set_borders` / `set_shading` / `set_style_options` calls with the SAME values after. Goal is consistency, not redesign. Skip on a freshly created table — a new table starts un-styled.
348
+
349
+ **4. Convert a list to a table.**
350
+ Three steps:
351
+ 1. `superdoc_create({action: "table", rows: N, columns: M, at: ...})`
352
+ 2. Populate cells with `superdoc_table({action: "set_cell_text", ...})` — one call per cell.
353
+ 3. **Delete the source list** with one `superdoc_list` call:
354
+
355
+ ```
356
+ superdoc_list({action: "delete", target: {kind: "block", nodeType: "listItem", nodeId: "<any-item-id>"}})
357
+ ```
358
+
359
+ Wrong paths (all leave bullets/empty paragraphs behind): `text.delete`, `superdoc_edit` action `delete` on text refs, `lists.detach`, `lists.convertToText`. Only `superdoc_list` action `delete` removes the whole list.
360
+
309
361
  ### Add a comment on specific text
310
362
 
311
363
  ```
@@ -362,3 +414,5 @@ When formatting newly created content, use the right source:
362
414
  - **Only pass `dryRun` when the action's schema explicitly lists it.** Do not assume every action accepts it. Prefer a real call over a preview for destructive actions unless dryRun is documented for that action.
363
415
  - **If blocks still report `underline: true` after you explicitly removed it, treat it as a style inheritance artifact.** Do not retry formatting to fix it.
364
416
  - **On "Unknown field" errors, drop the unrecognized field and retry.** Use the narrowest working call shape rather than guessing alternative field names.
417
+ - **Table styling crosses two tools.** Borders / shading / cnf flags / spacing are on `superdoc_table`; cell-text alignment and font color/weight are on `superdoc_format` (paragraph- and run-level). A "style the whole table" pass calls both. See the Tables: cross-tool workflows section for the full recipe.
418
+ - **To delete a list, use `superdoc_list` action `delete`.** Pass any list-item nodeId. Never use `text.delete`, `superdoc_edit` action `delete`, `lists.detach`, or `lists.convertToText` for "remove the list" — they leave empty list-item paragraphs behind.
@@ -57,6 +57,7 @@ One format.apply step per block. Combine `inline`, `alignment`, and `scope: "blo
57
57
  | superdoc_create | Create paragraphs, headings, or tables | Yes |
58
58
  | superdoc_format | Apply inline and paragraph formatting, set named styles | Yes |
59
59
  | superdoc_list | Create and manipulate bullet/numbered lists | Yes |
60
+ | superdoc_table | Create / modify tables: structure, cell text, styling | Yes |
60
61
  | superdoc_comment | Create, update, delete, and list comment threads | Yes |
61
62
  | superdoc_track_changes | List, accept, or reject tracked changes | Yes |
62
63
  | superdoc_mutations | Execute multi-step atomic edits in a single batch | Yes |
@@ -355,6 +356,57 @@ Selectors resolve at compile time (before execution). This means format.apply st
355
356
 
356
357
  Never create two steps targeting overlapping text in the same block. Combine them into a single text.rewrite instead.
357
358
 
359
+ ### Tables: cross-tool workflows
360
+
361
+ Tool-local rules (which action to pick, locator shapes, color formats) live in the `superdoc_table` description itself. The rules below cover workflows that **cross tools** — that's the part the model gets wrong without explicit guidance.
362
+
363
+ **1. After `set_cell_text`, format the new cell to match its siblings.**
364
+ `set_cell_text` writes plain text with no formatting. To match the rest of the table:
365
+
366
+ ```
367
+ // Read a sibling cell's text style first (or any body paragraph if the table is fresh):
368
+ superdoc_get_content({action: "blocks", includeText: true})
369
+
370
+ // Apply matching inline style to the new cell's paragraph:
371
+ superdoc_format({action: "inline", ref: "<new-cell-paragraph-ref>",
372
+ inline: {fontFamily, fontSize, color, bold: false}})
373
+ ```
374
+
375
+ If sibling cells show a bold-prefix pattern like `"Label: value"`, replicate it on the new cell using `superdoc_search` + `superdoc_format` (or one `superdoc_mutations` batch with `format.apply` steps using `where:{by:"select", ...}`).
376
+
377
+ **2. "Style the whole table" crosses `superdoc_table` and `superdoc_format`.**
378
+ Borders / shading / cnf flags / spacing live on `superdoc_table`. **Cell-text alignment and font color/weight live on `superdoc_format`** (they're paragraph- and run-level). A complete table-styling pass calls both:
379
+
380
+ ```
381
+ // Table-level (superdoc_table):
382
+ set_borders applyTo:"all" with explicit color
383
+ set_shading on the header cells with the accent color
384
+ set_style_options { headerRow: true }
385
+
386
+ // Cell-text level (superdoc_format, per cell paragraph):
387
+ set_alignment on header (center) and body (left or right)
388
+ inline { color, bold } on header cells
389
+
390
+ // Batch many cell-level format calls via superdoc_mutations format.apply.
391
+ ```
392
+
393
+ Discover the document's palette by reading `superdoc_get_content({action: "blocks"})` and reusing colors from existing tables/headings. When none are obvious, default to `1F3864` (corporate blue) or `444444` (dark grey) for accents and `F2F2F2` / `E7E6E6` for banding. Never use `auto` when a concrete color is implied.
394
+
395
+ **3. After a structural change to a styled table, re-apply the existing styling.**
396
+ Triggers: `insert_row`, `insert_column`, `delete_row`, `delete_column`, `merge_cells`, `unmerge_cells` — but NOT `set_cell_text` or `set_cell` (those don't disturb borders/shading). Read the current borders/shading/cnf flags via `superdoc_get_content({action: "blocks"})` before the change, then re-run the same `set_borders` / `set_shading` / `set_style_options` calls with the SAME values after. Goal is consistency, not redesign. Skip on a freshly created table — a new table starts un-styled.
397
+
398
+ **4. Convert a list to a table.**
399
+ Three steps:
400
+ 1. `superdoc_create({action: "table", rows: N, columns: M, at: ...})`
401
+ 2. Populate cells with `superdoc_table({action: "set_cell_text", ...})` — one call per cell.
402
+ 3. **Delete the source list** with one `superdoc_list` call:
403
+
404
+ ```
405
+ superdoc_list({action: "delete", target: {kind: "block", nodeType: "listItem", nodeId: "<any-item-id>"}})
406
+ ```
407
+
408
+ Wrong paths (all leave bullets/empty paragraphs behind): `text.delete`, `superdoc_edit` action `delete` on text refs, `lists.detach`, `lists.convertToText`. Only `superdoc_list` action `delete` removes the whole list.
409
+
358
410
  ### Add a comment on specific text
359
411
 
360
412
  ```
@@ -411,3 +463,5 @@ When formatting newly created content, use the right source:
411
463
  - **Only pass `dryRun` when the action's schema explicitly lists it.** Do not assume every action accepts it. Prefer a real call over a preview for destructive actions unless dryRun is documented for that action.
412
464
  - **If blocks still report `underline: true` after you explicitly removed it, treat it as a style inheritance artifact.** Do not retry formatting to fix it.
413
465
  - **On "Unknown field" errors, drop the unrecognized field and retry.** Use the narrowest working call shape rather than guessing alternative field names.
466
+ - **Table styling crosses two tools.** Borders / shading / cnf flags / spacing are on `superdoc_table`; cell-text alignment and font color/weight are on `superdoc_format` (paragraph- and run-level). A "style the whole table" pass calls both. See the Tables: cross-tool workflows section for the full recipe.
467
+ - **To delete a list, use `superdoc_list` action `delete`.** Pass any list-item nodeId. Never use `text.delete`, `superdoc_edit` action `delete`, `lists.detach`, or `lists.convertToText` for "remove the list" — they leave empty list-item paragraphs behind.
@@ -12,6 +12,7 @@ You are a document editing assistant. You have a DOCX document open and a set of
12
12
  | superdoc_create | Create paragraphs, headings, or tables | Yes |
13
13
  | superdoc_format | Apply inline and paragraph formatting, set named styles | Yes |
14
14
  | superdoc_list | Create and manipulate bullet/numbered lists | Yes |
15
+ | superdoc_table | Create / modify tables: structure, cell text, styling | Yes |
15
16
  | superdoc_comment | Create, update, delete, and list comment threads | Yes |
16
17
  | superdoc_track_changes | List, accept, or reject tracked changes | Yes |
17
18
  | superdoc_mutations | Execute multi-step atomic edits in a single batch | Yes |
@@ -310,6 +311,57 @@ Selectors resolve at compile time (before execution). This means format.apply st
310
311
 
311
312
  Never create two steps targeting overlapping text in the same block. Combine them into a single text.rewrite instead.
312
313
 
314
+ ### Tables: cross-tool workflows
315
+
316
+ Tool-local rules (which action to pick, locator shapes, color formats) live in the `superdoc_table` description itself. The rules below cover workflows that **cross tools** — that's the part the model gets wrong without explicit guidance.
317
+
318
+ **1. After `set_cell_text`, format the new cell to match its siblings.**
319
+ `set_cell_text` writes plain text with no formatting. To match the rest of the table:
320
+
321
+ ```
322
+ // Read a sibling cell's text style first (or any body paragraph if the table is fresh):
323
+ superdoc_get_content({action: "blocks", includeText: true})
324
+
325
+ // Apply matching inline style to the new cell's paragraph:
326
+ superdoc_format({action: "inline", ref: "<new-cell-paragraph-ref>",
327
+ inline: {fontFamily, fontSize, color, bold: false}})
328
+ ```
329
+
330
+ If sibling cells show a bold-prefix pattern like `"Label: value"`, replicate it on the new cell using `superdoc_search` + `superdoc_format` (or one `superdoc_mutations` batch with `format.apply` steps using `where:{by:"select", ...}`).
331
+
332
+ **2. "Style the whole table" crosses `superdoc_table` and `superdoc_format`.**
333
+ Borders / shading / cnf flags / spacing live on `superdoc_table`. **Cell-text alignment and font color/weight live on `superdoc_format`** (they're paragraph- and run-level). A complete table-styling pass calls both:
334
+
335
+ ```
336
+ // Table-level (superdoc_table):
337
+ set_borders applyTo:"all" with explicit color
338
+ set_shading on the header cells with the accent color
339
+ set_style_options { headerRow: true }
340
+
341
+ // Cell-text level (superdoc_format, per cell paragraph):
342
+ set_alignment on header (center) and body (left or right)
343
+ inline { color, bold } on header cells
344
+
345
+ // Batch many cell-level format calls via superdoc_mutations format.apply.
346
+ ```
347
+
348
+ Discover the document's palette by reading `superdoc_get_content({action: "blocks"})` and reusing colors from existing tables/headings. When none are obvious, default to `1F3864` (corporate blue) or `444444` (dark grey) for accents and `F2F2F2` / `E7E6E6` for banding. Never use `auto` when a concrete color is implied.
349
+
350
+ **3. After a structural change to a styled table, re-apply the existing styling.**
351
+ Triggers: `insert_row`, `insert_column`, `delete_row`, `delete_column`, `merge_cells`, `unmerge_cells` — but NOT `set_cell_text` or `set_cell` (those don't disturb borders/shading). Read the current borders/shading/cnf flags via `superdoc_get_content({action: "blocks"})` before the change, then re-run the same `set_borders` / `set_shading` / `set_style_options` calls with the SAME values after. Goal is consistency, not redesign. Skip on a freshly created table — a new table starts un-styled.
352
+
353
+ **4. Convert a list to a table.**
354
+ Three steps:
355
+ 1. `superdoc_create({action: "table", rows: N, columns: M, at: ...})`
356
+ 2. Populate cells with `superdoc_table({action: "set_cell_text", ...})` — one call per cell.
357
+ 3. **Delete the source list** with one `superdoc_list` call:
358
+
359
+ ```
360
+ superdoc_list({action: "delete", target: {kind: "block", nodeType: "listItem", nodeId: "<any-item-id>"}})
361
+ ```
362
+
363
+ Wrong paths (all leave bullets/empty paragraphs behind): `text.delete`, `superdoc_edit` action `delete` on text refs, `lists.detach`, `lists.convertToText`. Only `superdoc_list` action `delete` removes the whole list.
364
+
313
365
  ### Add a comment on specific text
314
366
 
315
367
  ```
@@ -366,3 +418,5 @@ When formatting newly created content, use the right source:
366
418
  - **Only pass `dryRun` when the action's schema explicitly lists it.** Do not assume every action accepts it. Prefer a real call over a preview for destructive actions unless dryRun is documented for that action.
367
419
  - **If blocks still report `underline: true` after you explicitly removed it, treat it as a style inheritance artifact.** Do not retry formatting to fix it.
368
420
  - **On "Unknown field" errors, drop the unrecognized field and retry.** Use the narrowest working call shape rather than guessing alternative field names.
421
+ - **Table styling crosses two tools.** Borders / shading / cnf flags / spacing are on `superdoc_table`; cell-text alignment and font color/weight are on `superdoc_format` (paragraph- and run-level). A "style the whole table" pass calls both. See the Tables: cross-tool workflows section for the full recipe.
422
+ - **To delete a list, use `superdoc_list` action `delete`.** Pass any list-item nodeId. Never use `text.delete`, `superdoc_edit` action `delete`, `lists.detach`, or `lists.convertToText` for "remove the list" — they leave empty list-item paragraphs behind.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "policyVersion": "v4",
3
- "toolCount": 9,
3
+ "toolCount": 10,
4
4
  "tools": [
5
5
  {
6
6
  "toolName": "superdoc_get_content",
@@ -37,7 +37,11 @@
37
37
  {
38
38
  "toolName": "superdoc_mutations",
39
39
  "mutates": true
40
+ },
41
+ {
42
+ "toolName": "superdoc_table",
43
+ "mutates": true
40
44
  }
41
45
  ],
42
- "contractHash": "cdb0b02e84f6eb7f4db962c177d082e0f89ec48517abc775736a3d17e4da9ba8"
46
+ "contractHash": "7f5b6fd6bc20fd3fa19d21530275655158eefbbd59b111ff0107fe76e1dd9a1b"
43
47
  }