dsh-office-kit 0.2.0 → 0.3.1
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/CAPABILITY.md +147 -68
- package/README.md +3 -1
- package/assets/skills/excel-live-control/SKILL.md +234 -0
- package/assets/skills/excel-live-control/container_tools/live_excel.py +1589 -0
- package/assets/skills/excel-live-control/domain_guidance/financial_models.md +86 -0
- package/assets/skills/excel-live-control/domain_guidance/healthcare.md +58 -0
- package/assets/skills/excel-live-control/domain_guidance/marketing_advertising.md +53 -0
- package/assets/skills/excel-live-control/domain_guidance/scientific_research.md +53 -0
- package/assets/skills/excel-live-control/references/office-automation.md +207 -0
- package/assets/skills/excel-live-control/references/read_only_qna.md +59 -0
- package/assets/skills/excel-live-control/style_guidelines.md +87 -0
- package/assets/skills/excel-live-control/workflows/create_workflows.md +78 -0
- package/assets/skills/excel-live-control/workflows/edit_workflows.md +72 -0
- package/assets/skills/office-documents/SKILL.md +90 -77
- package/assets/skills/office-documents/examples/end_to_end_smoke_test.md +86 -0
- package/assets/skills/office-documents/ooxml/comments.md +40 -0
- package/assets/skills/office-documents/ooxml/hyperlinks_and_fields.md +66 -0
- package/assets/skills/office-documents/ooxml/rels_and_content_types.md +62 -0
- package/assets/skills/office-documents/ooxml/tracked_changes.md +53 -0
- package/assets/skills/office-documents/references/docx-structure.md +83 -0
- package/assets/skills/office-documents/references/template-elicitation.md +49 -0
- package/assets/skills/office-documents/references/writing-quality.md +49 -0
- package/assets/skills/office-documents/render_docx.py +99 -0
- package/assets/skills/office-documents/scripts/a11y_audit.py +201 -0
- package/assets/skills/office-documents/scripts/accept_tracked_changes.py +158 -0
- package/assets/skills/office-documents/scripts/add_tracked_replacements.py +155 -0
- package/assets/skills/office-documents/scripts/append_blocks.py +115 -0
- package/assets/skills/office-documents/scripts/apply_template_styles.py +111 -0
- package/assets/skills/office-documents/scripts/captions_and_crossrefs.py +109 -0
- package/assets/skills/office-documents/scripts/comments_add.py +143 -0
- package/assets/skills/office-documents/scripts/comments_apply_patch.py +121 -0
- package/assets/skills/office-documents/scripts/comments_extract.py +92 -0
- package/assets/skills/office-documents/scripts/comments_strip.py +81 -0
- package/assets/skills/office-documents/scripts/content_controls.py +199 -0
- package/assets/skills/office-documents/scripts/core_properties.py +131 -0
- package/assets/skills/office-documents/scripts/docx_kit.py +594 -0
- package/assets/skills/office-documents/scripts/docx_ooxml_patch.py +232 -0
- package/assets/skills/office-documents/scripts/docx_table_to_csv.py +106 -0
- package/assets/skills/office-documents/scripts/fields_materialize.py +73 -0
- package/assets/skills/office-documents/scripts/fields_report.py +66 -0
- package/assets/skills/office-documents/scripts/flatten_ref_fields.py +69 -0
- package/assets/skills/office-documents/scripts/footnotes_report.py +84 -0
- package/assets/skills/office-documents/scripts/google_docs_title_sanitize.py +103 -0
- package/assets/skills/office-documents/scripts/heading_audit.py +88 -0
- package/assets/skills/office-documents/scripts/images_audit.py +87 -0
- package/assets/skills/office-documents/scripts/insert_note.py +133 -0
- package/assets/skills/office-documents/scripts/insert_ref_fields.py +97 -0
- package/assets/skills/office-documents/scripts/insert_toc.py +91 -0
- package/assets/skills/office-documents/scripts/internal_nav.py +153 -0
- package/assets/skills/office-documents/scripts/make_fixtures.py +176 -0
- package/assets/skills/office-documents/scripts/merge_docx_append.py +246 -0
- package/assets/skills/office-documents/scripts/privacy_scrub.py +138 -0
- package/assets/skills/office-documents/scripts/redact_docx.py +120 -0
- package/assets/skills/office-documents/scripts/render_and_diff.py +108 -0
- package/assets/skills/office-documents/scripts/replace_text.py +161 -0
- package/assets/skills/office-documents/scripts/section_audit.py +98 -0
- package/assets/skills/office-documents/scripts/set_protection.py +99 -0
- package/assets/skills/office-documents/scripts/style_lint.py +118 -0
- package/assets/skills/office-documents/scripts/style_normalize.py +110 -0
- package/assets/skills/office-documents/scripts/table_geometry.py +174 -0
- package/assets/skills/office-documents/scripts/watermark_add.py +55 -0
- package/assets/skills/office-documents/scripts/watermark_audit_remove.py +74 -0
- package/assets/skills/office-documents/scripts/xlsx_to_docx_table.py +124 -0
- package/assets/skills/office-documents/tasks/accessibility_a11y.md +45 -0
- package/assets/skills/office-documents/tasks/captions_crossrefs.md +49 -0
- package/assets/skills/office-documents/tasks/clean_tracked_changes.md +49 -0
- package/assets/skills/office-documents/tasks/comments_manage.md +59 -0
- package/assets/skills/office-documents/tasks/compare_diff.md +40 -0
- package/assets/skills/office-documents/tasks/create_edit.md +107 -0
- package/assets/skills/office-documents/tasks/equations.md +59 -0
- package/assets/skills/office-documents/tasks/fields_update.md +44 -0
- package/assets/skills/office-documents/tasks/fixtures_edge_cases.md +50 -0
- package/assets/skills/office-documents/tasks/footnotes_endnotes.md +38 -0
- package/assets/skills/office-documents/tasks/forms_content_controls.md +48 -0
- package/assets/skills/office-documents/tasks/headings_numbering.md +55 -0
- package/assets/skills/office-documents/tasks/images_figures.md +63 -0
- package/assets/skills/office-documents/tasks/multi_doc_merge.md +43 -0
- package/assets/skills/office-documents/tasks/navigation_internal_links.md +38 -0
- package/assets/skills/office-documents/tasks/privacy_scrub_metadata.md +45 -0
- package/assets/skills/office-documents/tasks/protection_restrict_editing.md +41 -0
- package/assets/skills/office-documents/tasks/read_review.md +50 -0
- package/assets/skills/office-documents/tasks/redaction_anonymization.md +42 -0
- package/assets/skills/office-documents/tasks/sections_layout.md +54 -0
- package/assets/skills/office-documents/tasks/style_lint_normalize.md +44 -0
- package/assets/skills/office-documents/tasks/tables_spreadsheets.md +64 -0
- package/assets/skills/office-documents/tasks/templates_style_packs.md +53 -0
- package/assets/skills/office-documents/tasks/toc_workflow.md +39 -0
- package/assets/skills/office-documents/tasks/verify_render.md +50 -0
- package/assets/skills/office-documents/tasks/watermarks_background.md +35 -0
- package/assets/skills/office-documents/troubleshooting/libreoffice_headless.md +47 -0
- package/assets/skills/office-documents/troubleshooting/run_splitting.md +36 -0
- package/assets/skills/office-pdf/SKILL.md +73 -56
- package/assets/skills/office-pdf/references/form-fields.md +56 -0
- package/assets/skills/office-pdf/references/geometry.md +44 -0
- package/assets/skills/office-pdf/references/layout-quality.md +41 -0
- package/assets/skills/office-pdf/references/limits.md +58 -0
- package/assets/skills/office-pdf/scripts/extract_text.py +172 -0
- package/assets/skills/office-pdf/scripts/forms.py +556 -0
- package/assets/skills/office-pdf/scripts/metadata.py +161 -0
- package/assets/skills/office-pdf/scripts/page_ops.py +198 -0
- package/assets/skills/office-pdf/scripts/redact_region.py +347 -0
- package/assets/skills/office-pdf/scripts/render_pages.py +207 -0
- package/assets/skills/office-pdf/scripts/split_pages.py +155 -0
- package/assets/skills/office-pdf/scripts/stamp_overlay.py +199 -0
- package/assets/skills/office-pdf/tasks/annotations.md +98 -0
- package/assets/skills/office-pdf/tasks/create.md +75 -0
- package/assets/skills/office-pdf/tasks/edit-pages.md +71 -0
- package/assets/skills/office-pdf/tasks/forms.md +67 -0
- package/assets/skills/office-pdf/tasks/read.md +62 -0
- package/assets/skills/office-pdf/tasks/redact.md +72 -0
- package/assets/skills/office-pdf/tasks/stamp.md +60 -0
- package/assets/skills/office-presentations/SKILL.md +141 -87
- package/assets/skills/office-presentations/container_tools/add_slides.py +143 -0
- package/assets/skills/office-presentations/container_tools/core_properties.py +127 -0
- package/assets/skills/office-presentations/container_tools/create_montage.py +133 -0
- package/assets/skills/office-presentations/container_tools/inspect_presentation_layout_geometry.py +292 -0
- package/assets/skills/office-presentations/container_tools/inspect_presentation_package_integrity.py +164 -0
- package/assets/skills/office-presentations/container_tools/native_chart_title_gate.py +151 -0
- package/assets/skills/office-presentations/container_tools/native_quantitative_chart_gate.py +206 -0
- package/assets/skills/office-presentations/container_tools/native_table_arithmetic_gate.py +219 -0
- package/assets/skills/office-presentations/container_tools/ooxml_helpers.py +352 -0
- package/assets/skills/office-presentations/container_tools/preview_render.py +382 -0
- package/assets/skills/office-presentations/container_tools/render_slides.py +146 -0
- package/assets/skills/office-presentations/container_tools/replace_text.py +175 -0
- package/assets/skills/office-presentations/container_tools/template_source_fidelity_gate.py +236 -0
- package/assets/skills/office-presentations/domain_guidance/finance.md +66 -0
- package/assets/skills/office-presentations/recipes/README.md +71 -0
- package/assets/skills/office-presentations/recipes/autolayout.md +88 -0
- package/assets/skills/office-presentations/recipes/connectors.md +83 -0
- package/assets/skills/office-presentations/recipes/images.md +80 -0
- package/assets/skills/office-presentations/recipes/master-and-layouts.md +127 -0
- package/assets/skills/office-presentations/recipes/native-charts.md +87 -0
- package/assets/skills/office-presentations/recipes/rich-text-runs.md +86 -0
- package/assets/skills/office-presentations/recipes/speaker-notes.md +65 -0
- package/assets/skills/office-presentations/recipes/tables.md +88 -0
- package/assets/skills/office-presentations/recipes/textbox-at-coordinate.md +71 -0
- package/assets/skills/office-presentations/recipes/theme-tokens.md +87 -0
- package/assets/skills/office-presentations/references/authoring-workflow.md +65 -0
- package/assets/skills/office-presentations/references/finalization.md +63 -0
- package/assets/skills/office-presentations/references/native-bullets.md +78 -0
- package/assets/skills/office-presentations/references/native-evidence.md +67 -0
- package/assets/skills/office-presentations/references/style-guidelines.md +66 -0
- package/assets/skills/office-presentations/references/templates.md +76 -0
- package/assets/skills/office-presentations/routing/google_slides.md +45 -0
- package/assets/skills/office-presentations/tasks/apply-annotations.md +83 -0
- package/assets/skills/office-presentations/tasks/charts-tables-notes.md +79 -0
- package/assets/skills/office-presentations/tasks/create-deck.md +106 -0
- package/assets/skills/office-presentations/tasks/edit-deck.md +93 -0
- package/assets/skills/office-presentations/tasks/inspect-and-verify.md +107 -0
- package/assets/skills/office-presentations/tasks/template-following.md +132 -0
- package/assets/skills/office-presentations/template_following_scripts/check_template_fidelity.py +183 -0
- package/assets/skills/office-presentations/template_following_scripts/inspect_template_deck.py +161 -0
- package/assets/skills/office-presentations/template_following_scripts/make_contact_sheet.py +118 -0
- package/assets/skills/office-presentations/template_following_scripts/prepare_template_starter_deck.py +246 -0
- package/assets/skills/office-presentations/template_following_scripts/validate_template_plan.py +192 -0
- package/assets/skills/office-spreadsheets/SKILL.md +105 -101
- package/assets/skills/office-spreadsheets/container_tools/add_chart.py +243 -0
- package/assets/skills/office-spreadsheets/container_tools/add_image.py +114 -0
- package/assets/skills/office-spreadsheets/container_tools/append_rows.py +129 -0
- package/assets/skills/office-spreadsheets/container_tools/diff_workbooks.py +313 -0
- package/assets/skills/office-spreadsheets/container_tools/inspect_workbook.py +405 -0
- package/assets/skills/office-spreadsheets/container_tools/recalc_gate.py +287 -0
- package/assets/skills/office-spreadsheets/container_tools/set_cells.py +142 -0
- package/assets/skills/office-spreadsheets/container_tools/sheet_ops.py +141 -0
- package/assets/skills/office-spreadsheets/container_tools/style_cells.py +140 -0
- package/assets/skills/office-spreadsheets/recipes/charts.md +66 -0
- package/assets/skills/office-spreadsheets/recipes/conditional-formats.md +69 -0
- package/assets/skills/office-spreadsheets/recipes/data-tables.md +58 -0
- package/assets/skills/office-spreadsheets/recipes/named-ranges.md +41 -0
- package/assets/skills/office-spreadsheets/recipes/number-formats.md +72 -0
- package/assets/skills/office-spreadsheets/recipes/sparklines.md +43 -0
- package/assets/skills/office-spreadsheets/references/charts.md +63 -0
- package/assets/skills/office-spreadsheets/references/domain/financial-models.md +40 -0
- package/assets/skills/office-spreadsheets/references/domain/healthcare.md +22 -0
- package/assets/skills/office-spreadsheets/references/domain/marketing.md +28 -0
- package/assets/skills/office-spreadsheets/references/domain/research.md +22 -0
- package/assets/skills/office-spreadsheets/references/formula-patterns.md +78 -0
- package/assets/skills/office-spreadsheets/references/style-guidelines.md +69 -0
- package/assets/skills/office-spreadsheets/references/workbook-structure.md +60 -0
- package/assets/skills/office-spreadsheets/routing/google-sheets.md +36 -0
- package/assets/skills/office-spreadsheets/tasks/analyze-workbook.md +37 -0
- package/assets/skills/office-spreadsheets/tasks/annotations.md +51 -0
- package/assets/skills/office-spreadsheets/tasks/create-workbook.md +66 -0
- package/assets/skills/office-spreadsheets/tasks/diff-workbooks.md +38 -0
- package/assets/skills/office-spreadsheets/tasks/edit-workbook.md +69 -0
- package/assets/skills/office-spreadsheets/tasks/inspect-workbook.md +38 -0
- package/assets/skills/office-spreadsheets/tasks/recalc-and-check.md +57 -0
- package/assets/skills/shared/annotation-recipes.md +252 -0
- package/assets/skills/shared/check_runtime.py +260 -0
- package/assets/skills/shared/common-workflow.md +139 -0
- package/assets/skills/shared/scripts/ensure_raster_image.py +187 -0
- package/dist/client.js +4 -4
- package/dist/client.js.map +1 -1
- package/dist/index.js +246 -89
- package/package.json +1 -1
- package/postinstall.mjs +92 -82
- package/python/office_cli.py +213 -254
package/CAPABILITY.md
CHANGED
|
@@ -1,75 +1,154 @@
|
|
|
1
1
|
# Capability report
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Capability trace
|
|
6
|
-
|
|
7
|
-
| User capability | Original mechanism | DSH execution chain | Acceptance | State |
|
|
8
|
-
| --- | --- | --- | --- | --- |
|
|
9
|
-
| Create a DOCX report | `documents` skill; Python OOXML scripts; `mark_artifact_operation_started.mjs` | `/documents` chip → `office-documents` skill → `office_status` → `office_cli.py docx create/edit` (python-docx, OMML) → Word/LibreOffice render → PNG inspection | Create with headings, lists, table, image, equation, header/footer; read back counts; edit text and append section; equation survives; rendered page inspected | Supported |
|
|
10
|
-
| Read a DOCX | Same skill | `docx read` → JSON counts/text/tables/images | Counts and text match the created document | Supported |
|
|
11
|
-
| Create a PDF | `pdf` skill; reportlab/pdfplumber/pypdf | `/pdf` chip → `office-pdf` skill → `office_cli.py pdf create/read/edit/render` | Chinese text embeds with registered CJK font; read extracts text; metadata edit; PyMuPDF render inspected | Supported |
|
|
12
|
-
| Inspect a PDF | Same | `pdf read` → page count, text, metadata, form fields | Page count and Chinese/English text extracted | Supported |
|
|
13
|
-
| Edit a PDF | Same | `pdf edit` → metadata, rotate, merge, remove pages | Metadata edit and read-back verified | Supported |
|
|
14
|
-
| Create/edit a PPTX | `presentations` skill; `@oai/artifact-tool` | `/presentations` chip → `office-presentations` skill → `office_cli.py pptx create/edit` (python-pptx) → PowerPoint/LibreOffice render | Three slides with bullets, table, chart, image; edit text and append a slide; four rendered pages inspected; layout overlap fixed with explicit coordinates | Supported, with a different authoring engine than the original |
|
|
15
|
-
| Create/edit an XLSX | `spreadsheets` skill; `@oai/artifact-tool` | `/spreadsheets` chip → `office-spreadsheets` skill → `office_cli.py xlsx create/edit/recalc` (openpyxl + Excel COM) | Formulas, styles, widths, frozen panes, chart; edit cells/append rows; Excel recalculation persists cached values (`40`, `58`, `228`); data-only read confirms | Supported, with a different authoring engine than the original |
|
|
16
|
-
| Render for visual QA | Original render helpers / artifact tool | `render` → Microsoft Office COM (Word/PowerPoint/Excel) or LibreOffice headless; PyMuPDF for PDF | DOCX page, PPTX pages, PDF page rendered and inspected | Supported when a renderer exists; explicit error otherwise |
|
|
17
|
-
| `/` menu with names and icons | Original skill menu (not `InputTrigger`) | Public `ctx.inputTriggers` source named `office`; four candidates with Gravity UI Icons SVGs and locale labels | Typecheck/build; not yet exercised in a running DSH window | Implemented, GUI interaction unverified |
|
|
18
|
-
| Enter → reference chip | Original artifact reference | `onPick` returns `ReferenceInsert`; host `codec` persists `/documents` and serializes a skill instruction | Build/typecheck; chip persistence is the documented public contract, not live-tested | Implemented, GUI interaction unverified |
|
|
19
|
-
| Chip preview | Original skill preview | `openReference` maps feature id → skill name → `SKILL.md` path → `sidebarRight.openResource` | Code path implemented; GUI unverified | Implemented, GUI unverified |
|
|
20
|
-
| Python setup | Original bundled runtime | `postinstall.mjs` detect/download/verify/install/venv/pip/import check/config/PATH | Auto-install path not run (a working Python already existed); venv creation, dependency install, import verification, config write, idempotent rerun all verified | Supported; installer download path unverified in this environment |
|
|
21
|
-
|
|
22
|
-
## Dependency mapping
|
|
23
|
-
|
|
24
|
-
| Original dependency | DSH replacement | Notes |
|
|
25
|
-
| --- | --- | --- |
|
|
26
|
-
| `load_workspace_dependencies` | `office_status` + absolute paths embedded in each skill body | No hidden workspace loader; the host verifies the interpreter and packages. |
|
|
27
|
-
| `mark_artifact_operation_started.mjs` | None | It only marked artifact sessions in the original runtime; DSH has no equivalent and the CLI does not pretend to. |
|
|
28
|
-
| `@oai/artifact-tool` (PPTX/XLSX) | `python-pptx`, `openpyxl` | Different API and some different capabilities; see limits. |
|
|
29
|
-
| Google Drive/Slides/Sheets plugins | None | Remote editing is explicitly unsupported, not silently replaced by local files. |
|
|
30
|
-
| Original render helpers | Microsoft Office COM or LibreOffice headless; PyMuPDF | Renderer availability is reported by `office_status`. |
|
|
31
|
-
| Original `agents/openai.yaml` manifests | DSH skill frontmatter + `ctx.skills.registerProvider` | The four DSH skills live in `assets/skills`. |
|
|
32
|
-
|
|
33
|
-
## Python and renderer environment
|
|
34
|
-
|
|
35
|
-
- Python: 3.12.12 in `%LOCALAPPDATA%\dsh-office-kit\venv`, created by `postinstall.mjs` from an existing CPython 3.12.12.
|
|
36
|
-
- Installed and import-verified: python-docx 1.2.0, openpyxl 3.1.5, python-pptx 1.0.2, pypdf 6.21.1, reportlab 4.5.1, pdfplumber 0.11.9, PyMuPDF 1.28.2, Pillow 11.3.0, latex2mathml 3.81.1, mathml2omml 0.0.2.
|
|
37
|
-
- Renderers: Microsoft Word/PowerPoint/Excel 16 installed. LibreOffice is not installed on this machine. OCR (`tesseract`) and Poppler `pdftoppm` are not installed; PDF rendering uses PyMuPDF instead.
|
|
3
|
+
What this plugin can do, verified 2026-10-21 on Windows by reading the code and
|
|
4
|
+
running the helper CLI. Unverified items are marked as such.
|
|
38
5
|
|
|
39
|
-
##
|
|
6
|
+
## Runtime model
|
|
7
|
+
|
|
8
|
+
Every operation goes through one spec-driven helper CLI, addressed by the
|
|
9
|
+
absolute `python` and `cli` paths the host appends to each skill body as the
|
|
10
|
+
`## Office runtime` block. It prints one JSON object; failures print JSON on
|
|
11
|
+
stderr and exit non-zero.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
<python> <cli> {docx|pptx|xlsx|pdf} {create|read|render}
|
|
15
|
+
<python> <cli> xlsx recalc | status
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`create` takes `--spec --out`, `read` takes `--input`, `render` takes
|
|
19
|
+
`--input --out-dir`; all accept `--json-out`, `xlsx read` also `--data-only`.
|
|
20
|
+
The CLI has no `edit` verb on purpose: changing a file is a set of narrow pack
|
|
21
|
+
scripts (one operation each), so a new capability is a new script rather than a
|
|
22
|
+
new verb in a shared dispatcher that every format has to keep in step.
|
|
23
|
+
Every verb prints one JSON object; failures print JSON on stderr, exit non-zero.
|
|
24
|
+
These verbs are the common path, not the ceiling: specialised work uses the pack
|
|
25
|
+
scripts (`scripts/`, `container_tools/`), and the rest uses short snippets
|
|
26
|
+
against the installed libraries, run with the same `python` and verified the same
|
|
27
|
+
way. A missing verb is a missing shortcut, not a missing capability.
|
|
28
|
+
|
|
29
|
+
## Packs and shared layer
|
|
30
|
+
|
|
31
|
+
| Format | Router | Pack helpers | CLI verbs |
|
|
32
|
+
| --- | --- | --- | --- |
|
|
33
|
+
| DOCX | `assets/skills/office-documents/SKILL.md` | `scripts/` — OOXML kit, comments, fields, tracked changes, template styles, accessibility audit, text/blocks/properties edits | create, read, render |
|
|
34
|
+
| PDF | `assets/skills/office-pdf/SKILL.md` | `scripts/` — text/table extraction, page rendering, form inspect/fill, page ops, region redaction | create, read, render |
|
|
35
|
+
| PPTX | `assets/skills/office-presentations/SKILL.md` | `container_tools/` — OOXML helpers, preview rendering, text/slide/properties edits | create, read, render |
|
|
36
|
+
| XLSX | `assets/skills/office-spreadsheets/SKILL.md` | `container_tools/` — workbook inspection, diff, recalculation gate, sheet/cell/row/style/chart edits | create, read, render, recalc |
|
|
37
|
+
| live XLSX | `assets/skills/excel-live-control/SKILL.md` | `container_tools/live_excel.py` — attach to a running Excel/WPS window: read, write, formulas, styles, tables, charts, recalc, save | — |
|
|
38
|
+
| shared | `assets/skills/shared/` | `common-workflow.md`, `annotation-recipes.md`, `check_runtime.py`, `scripts/ensure_raster_image.py` | — |
|
|
39
|
+
|
|
40
|
+
The four routers register through `ctx.skills.registerProvider` in
|
|
41
|
+
`src/index.ts`; `/` commands, labels and skill names come from
|
|
42
|
+
`src/features.ts`. Helper scripts are argparse-based with `--help`.
|
|
43
|
+
|
|
44
|
+
## What each format does
|
|
45
|
+
|
|
46
|
+
- **DOCX** — create from a block spec: headings, paragraphs, bullets, numbered
|
|
47
|
+
lists, tables, images, LaTeX equations (OMML, fallbacks counted in
|
|
48
|
+
`equation_fallbacks`), quotes, page breaks, spacers, header/footer, page size,
|
|
49
|
+
margins. Read returns styled text, tables, images, equations, counts. Edits run
|
|
50
|
+
as pack scripts (text replacement, block append, core properties).
|
|
51
|
+
- **PDF** — create with reportlab; the CJK font is auto-detected (named in the
|
|
52
|
+
report, e.g. `OfficeCJK`). Read returns page text, metadata, word counts and
|
|
53
|
+
form fields; OCR is not bundled (`ocr.available: false`). Edits run as pack
|
|
54
|
+
scripts: metadata, rotation, page order, merge, page removal, region
|
|
55
|
+
redaction. Render uses PyMuPDF.
|
|
56
|
+
- **PPTX** — create 16:9 decks: layouts `title`, `bullets`, `section`,
|
|
57
|
+
`title_only`, `blank`; bullet levels, tables, bar/column/line/pie charts,
|
|
58
|
+
images. Read returns slides, text, tables and charts but **no shape geometry**,
|
|
59
|
+
so annotation work computes overlap with python-pptx. Edits run as pack
|
|
60
|
+
scripts: run-level text replacement, added slides, core properties.
|
|
61
|
+
- **XLSX** — create sheets with rows, formulas, styles (cell or `A1:B2` range),
|
|
62
|
+
widths, row heights, frozen panes, merges, charts, anchored images. Read
|
|
63
|
+
returns rows, formulas with cached values, merges, charts, images, dimensions.
|
|
64
|
+
Edits run as pack scripts: sheets, cells, appended rows, range styles, charts,
|
|
65
|
+
images, rows.
|
|
66
|
+
- **Live XLSX** — `excel-live-control` drives a workbook that is already open in
|
|
67
|
+
Excel or WPS Spreadsheets through COM (`GetActiveObject`, Windows PowerShell
|
|
68
|
+
5.1), never by writing the file behind the user's back: `info`, `read_range`,
|
|
69
|
+
`write_range`, `set_formula`, `style_range`, `add_chart`, `add_table`,
|
|
70
|
+
`recalc`, `save`, `close`, plus `--diagnose`. It refuses to start a hidden
|
|
71
|
+
instance for normal work and reports exactly which sheet and range it touched;
|
|
72
|
+
sheet create/rename/delete/reorder are deliberately absent (use a tab the user
|
|
73
|
+
has, or the file route).
|
|
74
|
+
|
|
75
|
+
## Delivery rule
|
|
40
76
|
|
|
41
|
-
|
|
77
|
+
Hand the file over with `present` and summarise the change in one sentence. A
|
|
78
|
+
bare path is not delivery: `.docx`/`.pptx`/`.xlsx`/`.pdf` links in the transcript
|
|
79
|
+
render as "二进制文件,无法显示改动". Edits go to `<original>-edited.<ext>` (or
|
|
80
|
+
the name the user asked for); never overwrite the original, report both paths.
|
|
81
|
+
|
|
82
|
+
## Annotations
|
|
83
|
+
|
|
84
|
+
A preview arrives as `<office-annotations>` wrapping a JSON array of items keyed
|
|
85
|
+
`target`, `fileName`, `requirement`, `text` and a 0–1 `region`. `docx`/`pptx`
|
|
86
|
+
add `page` (rendered PDF page; pptx one slide per page) and `pdf` adds a 1-based
|
|
87
|
+
PDF `page` plus `imageName`. `xlsx` items are always `unmapped: true` with
|
|
88
|
+
`text: ""` and no page/sheet/range: resolve cells from the `imageName` screenshot
|
|
89
|
+
and `xlsx read`, and state the resolved sheet/A1 range before editing. Treat it
|
|
90
|
+
as a change request — locate, smallest edit, re-render, confirm. Recipes:
|
|
91
|
+
`assets/skills/shared/annotation-recipes.md`; unmappable payloads are reported,
|
|
92
|
+
never guessed.
|
|
93
|
+
|
|
94
|
+
## Renderer dependency
|
|
95
|
+
|
|
96
|
+
- `docx`, `pptx` and `xlsx` rendering needs an office suite: Microsoft Office
|
|
97
|
+
(Word/PowerPoint/Excel over COM), WPS Office (`KWps`/`KWpp`/`Ket` over COM) or
|
|
98
|
+
LibreOffice (headless conversion). `render` names the one it used in its
|
|
99
|
+
`renderer` field (`microsoft-office`, `kingsoft-wps`, `libreoffice`). With none
|
|
100
|
+
installed it exits non-zero: `no document renderer found: install LibreOffice,
|
|
101
|
+
Microsoft Office, or WPS Office`.
|
|
102
|
+
- `xlsx recalc` needs a real calculation engine: Excel or WPS Spreadsheets over
|
|
103
|
+
COM. It reports `renderer` and the count of cached values it filled in.
|
|
104
|
+
- `pdf render` needs no external renderer; PyMuPDF rasterises it directly.
|
|
105
|
+
- The PPTX pack's `container_tools/preview_render.py` is a geometry-only draft:
|
|
106
|
+
it redraws shapes, text boxes and images from the package with PyMuPDF and
|
|
107
|
+
labels itself `draft-preview` / `geometry-only`. It proves placement, not
|
|
108
|
+
typography (bullet glyphs are not drawn), and `render_slides.py` prefers the
|
|
109
|
+
real renderer whenever one exists.
|
|
110
|
+
- **This machine renders through WPS Office.** `office_status` reports
|
|
111
|
+
`kingsoft_wps: {writer, presentation, spreadsheet}` from `wps.exe`/`wpp.exe`/
|
|
112
|
+
`et.exe` under `%LOCALAPPDATA%\Kingsoft\WPS Office\<version>\office6`;
|
|
113
|
+
`docx`/`pptx`/`xlsx render` return `"renderer": "kingsoft-wps"`, and `xlsx
|
|
114
|
+
recalc` fills cached values through `Ket.Application`.
|
|
115
|
+
- `assets/skills/shared/scripts/ensure_raster_image.py` turns SVG, a chosen PDF
|
|
116
|
+
page, or a raster file into a PNG (PyMuPDF for vectors, Pillow for rasters), so
|
|
117
|
+
artwork can be embedded and then looked at. It never overwrites its input.
|
|
118
|
+
- `assets/skills/shared/check_runtime.py` imports every package from
|
|
119
|
+
`python/requirements.txt` and runs `<cli> status`; it exits non-zero on a
|
|
120
|
+
missing package or broken CLI, and 4 with `--require-renderer` when no renderer
|
|
121
|
+
is installed (a missing renderer is otherwise only a warning).
|
|
122
|
+
|
|
123
|
+
## Verification evidence
|
|
42
124
|
|
|
43
125
|
| Check | Result |
|
|
44
126
|
| --- | --- |
|
|
45
|
-
|
|
|
46
|
-
| `
|
|
47
|
-
|
|
|
48
|
-
| DOCX
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
| XLSX
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
- The public composer `ReferenceChip` shows a custom icon only for `session`, `file`, and `folder`. This plugin uses `appearance: 'file'` in the composer, so the chip shows the built-in file glyph plus the friendly format label. The `/` menu candidates and transcript chips use four Gravity UI Icons SVGs (`file-text`, `file-letter-p`, `display`, `layout-cells`), vendored in `assets/icons` under MIT.
|
|
74
|
-
- `matchEnter` cannot create a reference chip; Enter on a highlighted `/` candidate goes through the source's `onPick`, which is the implemented path.
|
|
75
|
-
- The chip's stable internal ref is the feature id; clipboard/persistence text is `/documents` etc.; model serialization names the skill explicitly so the agent loads it before file work.
|
|
127
|
+
| Packages on the runtime venv (3.13.12, `~/.dsh/office/runtime/venv`) | 10/10 import — python-docx 1.2.0, openpyxl 3.1.5, python-pptx 1.0.2, pypdf 6.21.1, reportlab 4.5.1, pdfplumber 0.11.9, PyMuPDF 1.28.2, Pillow 11.3.0, latex2mathml 3.81.1, mathml2omml 0.0.2 |
|
|
128
|
+
| `check_runtime.py` (venv / `--require-renderer` / bare `py -3.14`) | exit 0 + renderer warning / exit 4 / exit 1 listing the 8 missing packages and the pip remedy |
|
|
129
|
+
| DOCX create / read / `replace_text.py` / `append_blocks.py` | ok — counts returned, styles preserved, `replacements: 1`, `appended: 1`, equation intact |
|
|
130
|
+
| DOCX / PPTX render | ok through WPS — `renderer: kingsoft-wps`, DOCX 2 pages, PPTX 3 pages, PNGs opened and checked |
|
|
131
|
+
| PPTX create / read / `add_slides.py` | ok — 3 slides, texts and charts read back |
|
|
132
|
+
| XLSX create / read / `set_cells.py` | ok — formula read back uncached, one cell written |
|
|
133
|
+
| XLSX recalc | ok through WPS — `renderer: kingsoft-wps`, 34 cached values filled, `A3 = 7` after `CalculateFull` |
|
|
134
|
+
| `ensure_raster_image.py` | ok — 120×60 SVG at `--dpi 300` → 500×250, `--page` on a 2-page PDF, `--width 400` upscale, JSON errors on missing/unwritable input |
|
|
135
|
+
| `excel-live-control/container_tools/live_excel.py` | ok against WPS — attach refusal with remediation when nothing runs; `write_range` A1:B3 (6 cells), `set_formula` C1, `read_range` values `[[10,20,30],[30,40,null],[50,60,null]]`, `save` 9,268 bytes, `--diagnose` lists the workbook/sheet, `close --quit-app` refuses a dirty book, `--discard` leaves zero `et.exe` |
|
|
136
|
+
| PDF create / read / render / `metadata.py` / `page_ops.py` / `redact_region.py` | ok — CJK font applied, metadata written, merge→remove→rotate, region redaction removed 170 chars and 11 drawings, `page-1.png` produced |
|
|
137
|
+
| Annotation geometry helpers | pymupdf rect conversion, python-pptx overlap scan, A1 text matching run against those files |
|
|
138
|
+
| Forbidden-vocabulary grep over the delivered docs | empty |
|
|
139
|
+
|
|
140
|
+
Not claimed (no evidence here): installer or self-heal timings, live GUI
|
|
141
|
+
interaction (`/` menu, chip, sidebar preview, annotation overlay), and macOS/Linux
|
|
142
|
+
renderer support.
|
|
143
|
+
|
|
144
|
+
## Explicitly out of scope
|
|
145
|
+
|
|
146
|
+
- Google Docs/Slides/Sheets or Drive-backed editing; visual verification of
|
|
147
|
+
docx/pptx/xlsx without a renderer (skills say so instead of claiming a page was
|
|
148
|
+
inspected).
|
|
149
|
+
- In-place PDF page-content editing (rebuild from a `pdf create` spec and say
|
|
150
|
+
so); OCR and scanned-PDF text extraction.
|
|
151
|
+
- PPTX animations, speaker notes, slide masters; XLSX pivots, macros, data
|
|
152
|
+
validation, conditional formatting — no spec keys or verbs in the helper.
|
|
153
|
+
- Formula evaluation without Microsoft Excel or WPS Spreadsheets; macOS/Linux
|
|
154
|
+
installation and renderer behaviour (only Windows was exercised).
|
package/README.md
CHANGED
|
@@ -35,8 +35,10 @@ dsh plugin add dsh-office-kit
|
|
|
35
35
|
- 📄 **PDF**:`/pdf` 创建、读取和编辑 PDF,支持合并、旋转、删页与元数据。
|
|
36
36
|
- 📽️ **演示文稿**:`/presentations` 创建、读取和编辑 PPTX,支持项目符号、表格、图表与图片。
|
|
37
37
|
- 📊 **电子表格**:`/spreadsheets` 创建、读取和编辑 XLSX,支持公式、样式、图表、冻结窗格与重算。
|
|
38
|
-
- 🖍️ **侧边栏标注**:在 PDF、DOC/DOCX 预览中吸附段落或框选区域,批量提交修改要求。
|
|
38
|
+
- 🖍️ **侧边栏标注**:在 PDF、DOC/DOCX、PPTX、XLSX 预览中吸附段落或框选区域,批量提交修改要求。
|
|
39
39
|
- 🔗 **会话引用**:通过 Chip 调用文档技能;注释链接可悬停查看文件名与要求,PDF 标注附选区截图。
|
|
40
|
+
- 🖼️ **渲染校验**:DOCX/PPTX/XLSX 经 Microsoft Office、WPS Office 或 LibreOffice 导出 PDF 再栅格化,PDF 直接用 PyMuPDF;SVG/PDF 素材可用 `ensure_raster_image.py` 转成 PNG 后嵌入。
|
|
41
|
+
- 🧮 **活体表格**:`excel-live-control` 技能通过 COM 驱动已经打开的 Excel / WPS 表格(读区、写值、样式、图表、重算、保存)。
|
|
40
42
|
|
|
41
43
|
## 🚀 快速开始
|
|
42
44
|
|
|
@@ -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 |
|