dsh-office-kit 0.1.0 → 0.3.0

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 (198) hide show
  1. package/CAPABILITY.md +147 -68
  2. package/LICENSE.md +21 -21
  3. package/README.md +108 -106
  4. package/assets/skills/excel-live-control/SKILL.md +234 -0
  5. package/assets/skills/excel-live-control/container_tools/live_excel.py +1589 -0
  6. package/assets/skills/excel-live-control/domain_guidance/financial_models.md +86 -0
  7. package/assets/skills/excel-live-control/domain_guidance/healthcare.md +58 -0
  8. package/assets/skills/excel-live-control/domain_guidance/marketing_advertising.md +53 -0
  9. package/assets/skills/excel-live-control/domain_guidance/scientific_research.md +53 -0
  10. package/assets/skills/excel-live-control/references/office-automation.md +207 -0
  11. package/assets/skills/excel-live-control/references/read_only_qna.md +59 -0
  12. package/assets/skills/excel-live-control/style_guidelines.md +87 -0
  13. package/assets/skills/excel-live-control/workflows/create_workflows.md +78 -0
  14. package/assets/skills/excel-live-control/workflows/edit_workflows.md +72 -0
  15. package/assets/skills/office-documents/SKILL.md +90 -77
  16. package/assets/skills/office-documents/examples/end_to_end_smoke_test.md +86 -0
  17. package/assets/skills/office-documents/ooxml/comments.md +40 -0
  18. package/assets/skills/office-documents/ooxml/hyperlinks_and_fields.md +66 -0
  19. package/assets/skills/office-documents/ooxml/rels_and_content_types.md +62 -0
  20. package/assets/skills/office-documents/ooxml/tracked_changes.md +53 -0
  21. package/assets/skills/office-documents/references/docx-structure.md +83 -0
  22. package/assets/skills/office-documents/references/template-elicitation.md +49 -0
  23. package/assets/skills/office-documents/references/writing-quality.md +49 -0
  24. package/assets/skills/office-documents/render_docx.py +92 -0
  25. package/assets/skills/office-documents/scripts/a11y_audit.py +194 -0
  26. package/assets/skills/office-documents/scripts/accept_tracked_changes.py +151 -0
  27. package/assets/skills/office-documents/scripts/add_tracked_replacements.py +148 -0
  28. package/assets/skills/office-documents/scripts/append_blocks.py +108 -0
  29. package/assets/skills/office-documents/scripts/apply_template_styles.py +104 -0
  30. package/assets/skills/office-documents/scripts/captions_and_crossrefs.py +102 -0
  31. package/assets/skills/office-documents/scripts/comments_add.py +136 -0
  32. package/assets/skills/office-documents/scripts/comments_apply_patch.py +114 -0
  33. package/assets/skills/office-documents/scripts/comments_extract.py +85 -0
  34. package/assets/skills/office-documents/scripts/comments_strip.py +74 -0
  35. package/assets/skills/office-documents/scripts/content_controls.py +192 -0
  36. package/assets/skills/office-documents/scripts/core_properties.py +124 -0
  37. package/assets/skills/office-documents/scripts/docx_kit.py +587 -0
  38. package/assets/skills/office-documents/scripts/docx_ooxml_patch.py +225 -0
  39. package/assets/skills/office-documents/scripts/docx_table_to_csv.py +99 -0
  40. package/assets/skills/office-documents/scripts/fields_materialize.py +66 -0
  41. package/assets/skills/office-documents/scripts/fields_report.py +59 -0
  42. package/assets/skills/office-documents/scripts/flatten_ref_fields.py +62 -0
  43. package/assets/skills/office-documents/scripts/footnotes_report.py +77 -0
  44. package/assets/skills/office-documents/scripts/google_docs_title_sanitize.py +96 -0
  45. package/assets/skills/office-documents/scripts/heading_audit.py +81 -0
  46. package/assets/skills/office-documents/scripts/images_audit.py +80 -0
  47. package/assets/skills/office-documents/scripts/insert_note.py +126 -0
  48. package/assets/skills/office-documents/scripts/insert_ref_fields.py +90 -0
  49. package/assets/skills/office-documents/scripts/insert_toc.py +84 -0
  50. package/assets/skills/office-documents/scripts/internal_nav.py +146 -0
  51. package/assets/skills/office-documents/scripts/make_fixtures.py +169 -0
  52. package/assets/skills/office-documents/scripts/merge_docx_append.py +239 -0
  53. package/assets/skills/office-documents/scripts/privacy_scrub.py +131 -0
  54. package/assets/skills/office-documents/scripts/redact_docx.py +113 -0
  55. package/assets/skills/office-documents/scripts/render_and_diff.py +101 -0
  56. package/assets/skills/office-documents/scripts/replace_text.py +154 -0
  57. package/assets/skills/office-documents/scripts/section_audit.py +91 -0
  58. package/assets/skills/office-documents/scripts/set_protection.py +92 -0
  59. package/assets/skills/office-documents/scripts/style_lint.py +111 -0
  60. package/assets/skills/office-documents/scripts/style_normalize.py +103 -0
  61. package/assets/skills/office-documents/scripts/table_geometry.py +167 -0
  62. package/assets/skills/office-documents/scripts/watermark_add.py +48 -0
  63. package/assets/skills/office-documents/scripts/watermark_audit_remove.py +67 -0
  64. package/assets/skills/office-documents/scripts/xlsx_to_docx_table.py +117 -0
  65. package/assets/skills/office-documents/tasks/accessibility_a11y.md +45 -0
  66. package/assets/skills/office-documents/tasks/captions_crossrefs.md +49 -0
  67. package/assets/skills/office-documents/tasks/clean_tracked_changes.md +49 -0
  68. package/assets/skills/office-documents/tasks/comments_manage.md +59 -0
  69. package/assets/skills/office-documents/tasks/compare_diff.md +40 -0
  70. package/assets/skills/office-documents/tasks/create_edit.md +107 -0
  71. package/assets/skills/office-documents/tasks/equations.md +59 -0
  72. package/assets/skills/office-documents/tasks/fields_update.md +44 -0
  73. package/assets/skills/office-documents/tasks/fixtures_edge_cases.md +50 -0
  74. package/assets/skills/office-documents/tasks/footnotes_endnotes.md +38 -0
  75. package/assets/skills/office-documents/tasks/forms_content_controls.md +48 -0
  76. package/assets/skills/office-documents/tasks/headings_numbering.md +55 -0
  77. package/assets/skills/office-documents/tasks/images_figures.md +63 -0
  78. package/assets/skills/office-documents/tasks/multi_doc_merge.md +43 -0
  79. package/assets/skills/office-documents/tasks/navigation_internal_links.md +38 -0
  80. package/assets/skills/office-documents/tasks/privacy_scrub_metadata.md +45 -0
  81. package/assets/skills/office-documents/tasks/protection_restrict_editing.md +41 -0
  82. package/assets/skills/office-documents/tasks/read_review.md +50 -0
  83. package/assets/skills/office-documents/tasks/redaction_anonymization.md +42 -0
  84. package/assets/skills/office-documents/tasks/sections_layout.md +54 -0
  85. package/assets/skills/office-documents/tasks/style_lint_normalize.md +44 -0
  86. package/assets/skills/office-documents/tasks/tables_spreadsheets.md +64 -0
  87. package/assets/skills/office-documents/tasks/templates_style_packs.md +53 -0
  88. package/assets/skills/office-documents/tasks/toc_workflow.md +39 -0
  89. package/assets/skills/office-documents/tasks/verify_render.md +50 -0
  90. package/assets/skills/office-documents/tasks/watermarks_background.md +35 -0
  91. package/assets/skills/office-documents/troubleshooting/libreoffice_headless.md +47 -0
  92. package/assets/skills/office-documents/troubleshooting/run_splitting.md +36 -0
  93. package/assets/skills/office-pdf/SKILL.md +73 -56
  94. package/assets/skills/office-pdf/references/form-fields.md +56 -0
  95. package/assets/skills/office-pdf/references/geometry.md +44 -0
  96. package/assets/skills/office-pdf/references/layout-quality.md +41 -0
  97. package/assets/skills/office-pdf/references/limits.md +58 -0
  98. package/assets/skills/office-pdf/scripts/extract_text.py +172 -0
  99. package/assets/skills/office-pdf/scripts/forms.py +556 -0
  100. package/assets/skills/office-pdf/scripts/metadata.py +161 -0
  101. package/assets/skills/office-pdf/scripts/page_ops.py +198 -0
  102. package/assets/skills/office-pdf/scripts/redact_region.py +347 -0
  103. package/assets/skills/office-pdf/scripts/render_pages.py +207 -0
  104. package/assets/skills/office-pdf/scripts/split_pages.py +155 -0
  105. package/assets/skills/office-pdf/scripts/stamp_overlay.py +199 -0
  106. package/assets/skills/office-pdf/tasks/annotations.md +98 -0
  107. package/assets/skills/office-pdf/tasks/create.md +75 -0
  108. package/assets/skills/office-pdf/tasks/edit-pages.md +71 -0
  109. package/assets/skills/office-pdf/tasks/forms.md +67 -0
  110. package/assets/skills/office-pdf/tasks/read.md +62 -0
  111. package/assets/skills/office-pdf/tasks/redact.md +72 -0
  112. package/assets/skills/office-pdf/tasks/stamp.md +60 -0
  113. package/assets/skills/office-presentations/SKILL.md +141 -87
  114. package/assets/skills/office-presentations/container_tools/add_slides.py +136 -0
  115. package/assets/skills/office-presentations/container_tools/core_properties.py +120 -0
  116. package/assets/skills/office-presentations/container_tools/create_montage.py +126 -0
  117. package/assets/skills/office-presentations/container_tools/inspect_presentation_layout_geometry.py +285 -0
  118. package/assets/skills/office-presentations/container_tools/inspect_presentation_package_integrity.py +157 -0
  119. package/assets/skills/office-presentations/container_tools/native_chart_title_gate.py +144 -0
  120. package/assets/skills/office-presentations/container_tools/native_quantitative_chart_gate.py +199 -0
  121. package/assets/skills/office-presentations/container_tools/native_table_arithmetic_gate.py +212 -0
  122. package/assets/skills/office-presentations/container_tools/ooxml_helpers.py +345 -0
  123. package/assets/skills/office-presentations/container_tools/preview_render.py +375 -0
  124. package/assets/skills/office-presentations/container_tools/render_slides.py +139 -0
  125. package/assets/skills/office-presentations/container_tools/replace_text.py +168 -0
  126. package/assets/skills/office-presentations/container_tools/template_source_fidelity_gate.py +229 -0
  127. package/assets/skills/office-presentations/domain_guidance/finance.md +66 -0
  128. package/assets/skills/office-presentations/recipes/README.md +71 -0
  129. package/assets/skills/office-presentations/recipes/autolayout.md +88 -0
  130. package/assets/skills/office-presentations/recipes/connectors.md +83 -0
  131. package/assets/skills/office-presentations/recipes/images.md +80 -0
  132. package/assets/skills/office-presentations/recipes/master-and-layouts.md +127 -0
  133. package/assets/skills/office-presentations/recipes/native-charts.md +87 -0
  134. package/assets/skills/office-presentations/recipes/rich-text-runs.md +86 -0
  135. package/assets/skills/office-presentations/recipes/speaker-notes.md +65 -0
  136. package/assets/skills/office-presentations/recipes/tables.md +88 -0
  137. package/assets/skills/office-presentations/recipes/textbox-at-coordinate.md +71 -0
  138. package/assets/skills/office-presentations/recipes/theme-tokens.md +87 -0
  139. package/assets/skills/office-presentations/references/authoring-workflow.md +65 -0
  140. package/assets/skills/office-presentations/references/finalization.md +63 -0
  141. package/assets/skills/office-presentations/references/native-bullets.md +78 -0
  142. package/assets/skills/office-presentations/references/native-evidence.md +67 -0
  143. package/assets/skills/office-presentations/references/style-guidelines.md +66 -0
  144. package/assets/skills/office-presentations/references/templates.md +76 -0
  145. package/assets/skills/office-presentations/routing/google_slides.md +45 -0
  146. package/assets/skills/office-presentations/tasks/apply-annotations.md +83 -0
  147. package/assets/skills/office-presentations/tasks/charts-tables-notes.md +79 -0
  148. package/assets/skills/office-presentations/tasks/create-deck.md +106 -0
  149. package/assets/skills/office-presentations/tasks/edit-deck.md +93 -0
  150. package/assets/skills/office-presentations/tasks/inspect-and-verify.md +107 -0
  151. package/assets/skills/office-presentations/tasks/template-following.md +132 -0
  152. package/assets/skills/office-presentations/template_following_scripts/check_template_fidelity.py +176 -0
  153. package/assets/skills/office-presentations/template_following_scripts/inspect_template_deck.py +154 -0
  154. package/assets/skills/office-presentations/template_following_scripts/make_contact_sheet.py +111 -0
  155. package/assets/skills/office-presentations/template_following_scripts/prepare_template_starter_deck.py +239 -0
  156. package/assets/skills/office-presentations/template_following_scripts/validate_template_plan.py +185 -0
  157. package/assets/skills/office-spreadsheets/SKILL.md +105 -101
  158. package/assets/skills/office-spreadsheets/container_tools/add_chart.py +236 -0
  159. package/assets/skills/office-spreadsheets/container_tools/add_image.py +107 -0
  160. package/assets/skills/office-spreadsheets/container_tools/append_rows.py +122 -0
  161. package/assets/skills/office-spreadsheets/container_tools/diff_workbooks.py +306 -0
  162. package/assets/skills/office-spreadsheets/container_tools/inspect_workbook.py +398 -0
  163. package/assets/skills/office-spreadsheets/container_tools/recalc_gate.py +275 -0
  164. package/assets/skills/office-spreadsheets/container_tools/set_cells.py +135 -0
  165. package/assets/skills/office-spreadsheets/container_tools/sheet_ops.py +134 -0
  166. package/assets/skills/office-spreadsheets/container_tools/style_cells.py +133 -0
  167. package/assets/skills/office-spreadsheets/recipes/charts.md +66 -0
  168. package/assets/skills/office-spreadsheets/recipes/conditional-formats.md +69 -0
  169. package/assets/skills/office-spreadsheets/recipes/data-tables.md +58 -0
  170. package/assets/skills/office-spreadsheets/recipes/named-ranges.md +41 -0
  171. package/assets/skills/office-spreadsheets/recipes/number-formats.md +72 -0
  172. package/assets/skills/office-spreadsheets/recipes/sparklines.md +43 -0
  173. package/assets/skills/office-spreadsheets/references/charts.md +63 -0
  174. package/assets/skills/office-spreadsheets/references/domain/financial-models.md +40 -0
  175. package/assets/skills/office-spreadsheets/references/domain/healthcare.md +22 -0
  176. package/assets/skills/office-spreadsheets/references/domain/marketing.md +28 -0
  177. package/assets/skills/office-spreadsheets/references/domain/research.md +22 -0
  178. package/assets/skills/office-spreadsheets/references/formula-patterns.md +78 -0
  179. package/assets/skills/office-spreadsheets/references/style-guidelines.md +69 -0
  180. package/assets/skills/office-spreadsheets/references/workbook-structure.md +60 -0
  181. package/assets/skills/office-spreadsheets/routing/google-sheets.md +36 -0
  182. package/assets/skills/office-spreadsheets/tasks/analyze-workbook.md +37 -0
  183. package/assets/skills/office-spreadsheets/tasks/annotations.md +51 -0
  184. package/assets/skills/office-spreadsheets/tasks/create-workbook.md +66 -0
  185. package/assets/skills/office-spreadsheets/tasks/diff-workbooks.md +38 -0
  186. package/assets/skills/office-spreadsheets/tasks/edit-workbook.md +69 -0
  187. package/assets/skills/office-spreadsheets/tasks/inspect-workbook.md +38 -0
  188. package/assets/skills/office-spreadsheets/tasks/recalc-and-check.md +57 -0
  189. package/assets/skills/shared/annotation-recipes.md +252 -0
  190. package/assets/skills/shared/check_runtime.py +253 -0
  191. package/assets/skills/shared/common-workflow.md +139 -0
  192. package/assets/skills/shared/scripts/ensure_raster_image.py +187 -0
  193. package/dist/client.js +4 -4
  194. package/dist/client.js.map +1 -1
  195. package/dist/index.js +239 -89
  196. package/package.json +146 -149
  197. package/postinstall.mjs +92 -82
  198. package/python/office_cli.py +171 -246
@@ -0,0 +1,234 @@
1
+ ---
2
+ description: Drive a workbook that is already open in Excel or WPS Spreadsheets over COM — read cells, write values and formulas, style ranges, add charts and tables, recalculate, save, and report the exact ranges touched.
3
+ ---
4
+
5
+ # Live spreadsheets (Excel / WPS)
6
+
7
+ ## What "live" means here
8
+
9
+ The workbook is open in a running Excel or WPS Spreadsheets window, and the user is
10
+ looking at it. The file on disk may be behind the window, may not exist yet, and may
11
+ carry edits the user has not saved. A live call changes the *open document*: the cells
12
+ the user is staring at update while they watch, and saving is a separate decision.
13
+
14
+ That one sentence drives everything below:
15
+
16
+ - The target is `Application.ActiveWorkbook`-shaped state, not a path. Address it by
17
+ workbook name, sheet name and A1 range, never by "the active sheet" or "the selection".
18
+ - Nothing is transactional. A failed call leaves whatever already landed exactly where
19
+ it landed. Read before retrying; never replay a half-applied batch.
20
+ - The disk file is not the deliverable. What the user sees in the window is. Saving is
21
+ an explicit act you announce.
22
+
23
+ ## Live or file editing?
24
+
25
+ | Situation | Route |
26
+ | --- | --- |
27
+ | The user says the file is open, or asks for "the sheet I'm looking at" | this skill |
28
+ | They want to watch cells change, iterate on a model with them, or add a chart to the visible sheet | this skill |
29
+ | No spreadsheet application is running | `../office-spreadsheets/SKILL.md` — edit the file, then tell them to reopen it |
30
+ | Bulk generation, batch jobs, CI, or work that outlives the session | `../office-spreadsheets/SKILL.md` |
31
+ | Reading a file to answer a question, with no app open | `../office-spreadsheets/SKILL.md` |
32
+
33
+ Never force the live path. If nothing is running, do not launch an application to avoid
34
+ talking to the user: say plainly that the workbook must be open, or switch to the file
35
+ route and say so.
36
+
37
+ ## Before you touch anything
38
+
39
+ 1. Call the `office_status` tool, then take the `## Office runtime` JSON block that the
40
+ host appends to `../office-spreadsheets/SKILL.md` (this sub-skill is routed from
41
+ there, so that block is where the paths live). Use its `python` value verbatim and
42
+ quote every path; this pack's directory is `<skill>/../excel-live-control`, which is
43
+ what `<skill>` below means.
44
+ 2. Run `"<python>" "<skill>/container_tools/live_excel.py" --help` once per session.
45
+ 3. Attach and look before writing:
46
+
47
+ ```
48
+ "<python>" "<skill>/container_tools/live_excel.py" info
49
+ ```
50
+
51
+ `info` lists every open workbook, the target workbook, its sheets, and per sheet the
52
+ used range, charts, tables, pivot tables and protection state.
53
+
54
+ 4. If attach fails, the JSON carries a `remediation` string. Relay it as written: open
55
+ the workbook in Excel or WPS and keep it open, then ask for the change again. Do not
56
+ start an application on the user's behalf.
57
+ 5. If more than one workbook is open, the tool refuses to guess. Pass `--workbook` with
58
+ the file name (`Budget FY26.xlsx`) or enough of the path to be unambiguous.
59
+ 6. Something looks wrong with the environment — attach works but calls fail, or the
60
+ application name and vendor disagree — run `--diagnose`. It reports the attach
61
+ mechanism, the running application, every workbook and every sheet without mutating
62
+ anything.
63
+
64
+ Attachment uses `[Runtime.InteropServices.Marshal]::GetActiveObject` from Windows
65
+ PowerShell 5.1, trying `Excel.Application` then `Ket.Application` (WPS Spreadsheets).
66
+ WPS registers `Excel.Application` as an alias, so the reported application name is not
67
+ proof of which product is running; the JSON's `engine.vendor` is derived from
68
+ `Application.Path`. Mechanics and the COM object model: `references/office-automation.md`.
69
+
70
+ ## The edit contract
71
+
72
+ These are not preferences. Every mutating call has to satisfy them.
73
+
74
+ - **Touch only what was asked for.** The named sheet and the named ranges. Not the
75
+ neighbouring column, not the whole sheet, not "while I'm here".
76
+ - **Read before you write.** Call `read_range` on the target first. You need to know
77
+ whether a cell holds a value, a formula, or a merged-region fragment, and whether the
78
+ user's edits are unsaved before you replace them.
79
+ - **Never destroy structure you did not create**: formulas (never flatten to values),
80
+ named ranges, conditional formats, shared formulas, data validation, pivots and their
81
+ sources, chart series definitions, filters, hidden rows, freeze panes, protection.
82
+ - **Never clear more than you can name.** `write_range --clear` clears contents of an
83
+ explicit range; it does not remove charts, tables or formats. Clearing a used range to
84
+ "start clean" is off-limits.
85
+ - **Small writes, batched.** One call per logical block (a column of assumptions, a
86
+ sheet of outputs). Rectangular data only: if the range is 6 rows × 2 columns, the JSON
87
+ array must be 6 rows of 2 values.
88
+ - **Report exactly what you touched.** Every mutating op answers with workbook name and
89
+ path, sheet, exact address, row/column/cell counts, and a `warnings` list. Quote that
90
+ in your reply — "wrote `Assumptions!C4:D8` (10 cells)" — not "updated the assumptions".
91
+ - **Saving is a separate, announced act.** See Delivery.
92
+ - **No decorative edits without a request.** Do not restyle a sheet to your taste, do not
93
+ autofit whole columns, do not add a header row the user did not ask for.
94
+
95
+ If a call fails partway, `read_range` the block you were writing and continue from what
96
+ actually landed. Retrying the identical call is how duplicate rows and reversed edits
97
+ happen.
98
+
99
+ ## The tool
100
+
101
+ `"<skill>/container_tools/live_excel.py"` — one command per operation, one JSON object on
102
+ stdout, non-zero exit on failure. It shells out to `powershell.exe`; pywin32, comtypes and
103
+ Excel interop assemblies are neither used nor needed.
104
+
105
+ | Op | Does | Key options |
106
+ | --- | --- | --- |
107
+ | `info` | workbooks, target workbook, sheet inventory | `--workbook` |
108
+ | `read_range` | typed values, optionally formulas and displayed text | `--sheet --range`, `--formulas`, `--display`, `--max-cells` |
109
+ | `write_range` | one rectangular block of values | `--sheet --range --data`/`--data-file`, `--clear` |
110
+ | `set_formula` | a formula filled across a range, or a cell→formula map | `--range --formula`, or `--cells '{"C1":"=A1+B1"}'`/`--cells-file`, `--r1c1` |
111
+ | `style_range` | font, fill, number format, alignment, borders, width, merge | `--style` JSON or `--style-file`, `--merge` |
112
+ | `add_table` | native table (ListObject) over a range | `--name`, `--style TableStyleMedium2`, `--no-headers` |
113
+ | `add_chart` | embedded chart pointed at a range | `--type`, `--data`, `--anchor`, `--title`, `--width`, `--height` |
114
+ | `recalc` | `CalculateFull` on every open workbook | — |
115
+ | `save` | save in place, or `SaveAs` a copy | `--path` |
116
+ | `close` | close the workbook, optionally quit the application | `--save`, `--discard`, `--quit-app` |
117
+
118
+ Global options on every op: `--workbook NAME|PATH`, `--timeout SECONDS` (default 180;
119
+ a live call is allowed to take seconds), and `--launch-hidden` (**self-tests only** — it
120
+ starts a hidden application, which is wrong for any user-facing edit).
121
+
122
+ Style keys: `font_name`, `font_size`, `bold`, `italic`, `color`, `fill` (hex RGB, e.g.
123
+ `#FFF2CC`), `number_format`, `h_align` (`left|center|right|general|justify`), `v_align`
124
+ (`top|center|bottom`), `indent`, `wrap`, `column_width`, `border` (`outline|all|none`).
125
+ Unknown keys are rejected with the allowed list rather than silently dropped.
126
+
127
+ Chart types: `column`, `column-stacked`, `bar`, `bar-stacked`, `line`, `line-markers`,
128
+ `area`, `area-stacked`, `pie`, `doughnut`, `scatter`, `scatter-lines`.
129
+
130
+ Typical first calls:
131
+
132
+ ```
133
+ "<python>" "<skill>/container_tools/live_excel.py" info
134
+ "<python>" "<skill>/container_tools/live_excel.py" read_range --sheet Build --range D5:D9 --formulas
135
+ "<python>" "<skill>/container_tools/live_excel.py" write_range --sheet Assumptions --range C4:D8 --data-file assumptions.json
136
+ "<python>" "<skill>/container_tools/live_excel.py" set_formula --sheet Build --range E5:E9 --formula "=D5*Assumptions!$C$4"
137
+ "<python>" "<skill>/container_tools/live_excel.py" style_range --sheet Assumptions --range C4:D8 --style '{"number_format":"#,##0","fill":"#FFF2CC"}'
138
+ ```
139
+
140
+ Failures print `{"ok": false, "stage": "...", "error": "...", "remediation": "..."}` and
141
+ exit 1 (2 for usage errors, 3 when PowerShell itself is unavailable). `stage: "attach"`
142
+ means nothing was running; `stage: "com"` means the application refused or failed the
143
+ call; read the message before changing the approach.
144
+
145
+ The CLI is the fast path, not the ceiling. When a job needs a COM call it does not wrap —
146
+ a sheet tab, freeze panes, a pivot, data validation, shape geometry — extend the script or
147
+ drive the application from a short PowerShell snippet, and keep the same reporting and
148
+ verification rules. The object model is in `references/office-automation.md`.
149
+
150
+ What this tool deliberately does not do: create, rename, delete or reorder sheets; delete
151
+ ranges or objects; run macros; open a file from disk. A job that needs one of those asks
152
+ the user for it, or belongs to the file route in `../office-spreadsheets/SKILL.md`.
153
+
154
+ ## Verification
155
+
156
+ Do these in order after every batch of edits, before you report anything as done.
157
+
158
+ 1. **Read it back.** `read_range` the exact ranges you wrote, with `--formulas` when you
159
+ wrote formulas. Compare against what you intended cell by cell.
160
+ 2. **No error cells.** The `errors` array in `read_range` lists every cell whose *live*
161
+ value is an error (`#DIV/0!`, `#VALUE!`, `#REF!`, `#NAME?`, `#N/A`, …) with its
162
+ formula and address. An edit that leaves an error is not finished. A pre-existing
163
+ error you did not cause is reported to the user, not silently fixed.
164
+ 3. **Numbers.** Run `recalc` after adding or changing formulas, then read the cells
165
+ again. A formula that has not been calculated tells you nothing.
166
+ 4. **Objects.** If you added a table or chart, run `info` and confirm it in the sheet's
167
+ inventory, and read the chart's `source` from `add_chart`'s reply to confirm it points
168
+ at the range you meant.
169
+ 5. **Appearance.** You cannot screenshot the user's window from here. `--display` on
170
+ `read_range` shows the rendered text of each cell (up to 500), which catches `###`
171
+ widths, applied number formats and stray `#` — use it when formatting is part of the
172
+ request. Otherwise say the visual check is the user's, and ask them to confirm if it
173
+ matters.
174
+ 6. **Structure.** If the sheet had tables, pivots or charts before you started, `info`
175
+ after the edit proves they are still there.
176
+ 7. **Report.** Name the workbook, the sheet, every range, and the cell counts.
177
+
178
+ ## Delivery
179
+
180
+ The workbook is the user's open document, not an artifact you produced. Say what you did
181
+ and what state the document is in; do not save quietly.
182
+
183
+ - **Default: leave the document modified and unsaved.** The change is visible in their
184
+ window. Tell them so, and tell them Ctrl+S keeps it. This is what keeps you from
185
+ overwriting a file they were editing by hand.
186
+ - **They asked you to save**: `save` with no `--path` writes the workbook over its own
187
+ file. Say "saved `Budget FY26.xlsx`" and give the full path from the reply.
188
+ - **Unsaved workbook, or they want an artifact to keep**: `save --path <copy>.xlsx`
189
+ writes a copy and leaves the original window dirty. Then `present` that copy — it is a
190
+ real file they can open, send, or archive.
191
+ - **`.xlsx` in chat**: a path on its own is not delivery. Use the `present` tool on a
192
+ saved file, and state both paths when the original and the copy differ.
193
+ - **Never** save over the user's file to "make sure it's persisted" without telling them,
194
+ and never close their workbook. `close --quit-app` is for cleaning up a self-test
195
+ instance, not for tidying the user's desktop.
196
+ - If the edit failed partway and the document is dirty with a half-finished change, say
197
+ exactly which ranges landed, and offer either to finish them or to close without saving.
198
+
199
+ ## What good content looks like
200
+
201
+ The mechanics above keep the document intact; these rules keep it useful. The same rules
202
+ as the file-editing skill, because a careless live edit damages a document the user is
203
+ looking at.
204
+
205
+ - **Structure by role, not by tab count.** Inputs, assumptions, calculations, outputs.
206
+ Outputs on the left of the tab strip, builds in the middle, inputs on the right; a
207
+ terminal check/audit tab for models that need one. Do not restructure a workbook the
208
+ user already organised — `workflows/edit_workflows.md`.
209
+ - **Formulas that a reviewer can audit.** Anchored references (`$B$3`, `C$4`, `$A8`),
210
+ `SUMIFS`/`COUNTIFS`/`AVERAGEIFS` over hand-rolled sums, short `IF`, no blanket
211
+ `IFERROR(...,0)` (`#VALUE!` is information), no `LET`/`LAMBDA`/spill arrays.
212
+ `workflows/create_workflows.md` and `references/office-automation.md` for what COM
213
+ stores when you write these.
214
+ - **Typed values.** Numbers as numbers, dates as dates, one number format per column.
215
+ Invariant format codes (`#,##0`, `0.0%`, `"$"#,##0.00`) — never swap `.` and `,`.
216
+ - **Reading someone else's workbook is read-only.** `references/read_only_qna.md`.
217
+ - **Domain conventions** — finance, healthcare, marketing, scientific data — carry real
218
+ meaning in their cells: `domain_guidance/`. Read the matching file before modelling in
219
+ that area.
220
+ - **Visual defaults** (headers, input fills, borders, tab colours, one font family):
221
+ `style_guidelines.md`.
222
+ - **Citations** for external data go next to the input table they support, not in a
223
+ tab of their own.
224
+
225
+ ## Files in this skill
226
+
227
+ | File | Use it when |
228
+ | --- | --- |
229
+ | `references/office-automation.md` | you need the COM object model: addressing, `Value2` vs `Formula`, colour encoding, locale, latency |
230
+ | `references/read_only_qna.md` | answering a question about the open workbook without changing it |
231
+ | `style_guidelines.md` | the request involves how the sheet looks |
232
+ | `workflows/create_workflows.md` | building a new sheet or workbook live |
233
+ | `workflows/edit_workflows.md` | changing cells in a workbook the user already built |
234
+ | `domain_guidance/*.md` | the model is financial, clinical, marketing, or research data |