Skip to content

Add plugin document-skills - #6

Open
Hylouis233 wants to merge 34 commits into
MiniMax-AI:mainfrom
Hylouis233:plugin/document-skills
Open

Add plugin document-skills#6
Hylouis233 wants to merge 34 commits into
MiniMax-AI:mainfrom
Hylouis233:plugin/document-skills

Conversation

@Hylouis233

@Hylouis233 Hylouis233 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Migrated from hetaoBackend/MiniMax-Code-Plugins#12 (full review history and prior rounds of feedback live there). Head commit: ece7467. Python fixtures are wired into CI via fixtures.test.mjs + actions/setup-python.


What changes

New Plugin Hylouis233/document-skills - a Skill-only portable Agent Plugin bundling four original
workbench Skills: docx, pdf, pptx, xlsx.

All guidance in this Plugin was written originally for this contribution. It contains no content
from Anthropic's document skills or any other proprietary skill pack - the docx/pdf/pptx/xlsx
names describe the formats, and the patterns are built around standard open-source Python
libraries (python-docx, python-pptx, openpyxl, pypdf, ReportLab, PyMuPDF) and public format
knowledge.

User value

Users ask agents for document deliverables and get silent corruption: hand-edited ZIP XML that
no viewer opens, pasted values where spreadsheet formulas belong, screenshot-style PDFs with no
extractable text, decks whose text overflows every slide. The four Skills route each task to the
right tool, enforce the container contracts, and - critically - require re-opening and verifying
the artifact before handing it back.

Example prompt:

Use the document-skills plugin: open sales-2024.xlsx, add a sheet "Summary" with per-region
totals computed by formula, a bar chart of the top 5 products, and currency formatting.

Expected result: the agent loads the workbook with openpyxl, inspects sheets and headers, writes
real SUMIF/COUNTIF formulas, adds a native BarChart, applies number formats, and reports
the changed ranges plus the verification it ran.

Use the document-skills plugin: create a PDF one-pager "Q3 launch checklist" that fits exactly
one A4 page.

Expected result: generated with ReportLab flowables, measured, and verified with pypdf to be
exactly 1 page with extractable text.

Skill inventory (4 Skills, 13 reference files, 1333 lines):

  • docx - create (python-docx outline + styles + TOC field), edit (two-tier: structural edits
    vs. safe OOXML surgery), read (pandoc / python-docx), review (symptom-driven repair table),
    mandatory postcheck with optional soffice PDF smoke test.
  • pdf - one-tool-per-job routing: ReportLab for creation, PyMuPDF for extraction/inspection,
    pypdf for split/merge/rotate/watermark/encrypt/forms; text-first rule; page-geometry and
    overflow checks in postcheck.
  • pptx - seven workhorse slide patterns, narrow in-place editing with asserted shape matching,
    real chart parts over chart pictures, text-fit rules, slide-count and render verification.
  • xlsx - formulas-are-formulas contract, data_only caveats, typed values with explicit
    number formats, native charts bound to ranges, structural-edit formula audit, CSV/TSV route
    with a messy-data cleanup contract.

Plugin submission checklist

  • Plugin lives at plugins/<github-owner>/<plugin-name>.
  • plugin.json name matches the Plugin directory.
  • README.md includes a real example prompt and expected result.
  • LICENSE and plugin.json declare an open-source license (Apache-2.0).
  • Required executables, accounts, paid services, and supported platforms are disclosed
    (Python 3.9+ and the six libraries; optional LibreOffice/pandoc; Windows/macOS/Linux).
  • Network destinations and data handled by the plugin are disclosed (none - fully local).
  • No credentials, private endpoints, hidden telemetry, installers, symlinks, or native
    binaries are included.
  • Every scaffold TODO has been replaced.
  • Repository validation and portable contract tests pass (see evidence).

Network and data behavior

No network access, no credentials, no bundled executables. The Skills instruct the agent to use
the user's own installed Python libraries and operate only on files the user points at; temporary
artifacts go to the system temp directory. soffice/pandoc render checks are optional and
degrade gracefully when absent.

Evidence

npm run validate
OK   example hello-mcode
OK   example hello-mcode-mcp
OK   plugin Hylouis233/document-skills
Validated 1 hosted Plugin and all examples.

node --test
# tests 12
# pass 11
# fail 1

The one failing test (contributor can scaffold a hosted Skill plugin with one command,
test/hosted-plugins.test.mjs) is a pre-existing failure on unmodified main: the test asserts
a POSIX path separator while path.relative returns plugins\alice\hello-world on Windows.
Verified on a pristine shallow clone of this repository's main - same single failure, all
other 11 tests pass. No repository file outside plugins/Hylouis233/document-skills is touched
by this PR.

Manual evidence - the documented patterns were executed end to end on Windows (Python 3.13,
python-docx 1.2.0, python-pptx 1.0.2, openpyxl 3.1.5, pypdf 6.9.2, reportlab 4.4.10,
pymupdf 1.27.2, LibreOffice present):

XLSX ok | sheets: ['Sales'] | dims: A1:E5 | formulas: 4 [('E2','=C2*D2') ...] + native BarChart
DOCX ok | paragraphs: 3 | tables: 1 | table rows: 2 | PAGE field footer
PPTX ok | slides: 3 | title/table/chart slides rendered
PDF  ok | pages: 1 | mediabox: 595.3 x 841.9 | title text extractable
soffice report.docx -> exit 0 | pdf made: True
soffice deck.pptx    -> exit 0 | pdf made: True   (deck.pdf pages: 3 = slide count)

Every Python snippet embedded in the Skills was also parsed with ast.parse - zero syntax
errors. Staged files verified UTF-8 without BOM, LF line endings.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Hylouis233 and others added 30 commits August 15, 2026 03:43
Four original workbench Skills (docx, pdf, pptx, xlsx) for creating, reading,
editing, and verifying Office and PDF documents with standard open-source
Python tooling.

- lives at plugins/Hylouis233/document-skills
- plugin.json + README + Apache-2.0 LICENSE + four Skills with references
- original guidance written for this plugin; no proprietary content reused
- no network, no credentials, no MCP server; scripts referenced are the
  user's own installed Python libraries (python-docx, python-pptx, openpyxl,
  pypdf, reportlab, pymupdf), not bundled
- npm run validate passes; documented patterns smoke-tested end to end
Review fixes (all fixture-verified in tests/):
- PDF: AcroForm route now clones pages + /AcroForm into the writer via
  append() and fills fields on writer pages; mediabox postcheck reduced to
  width/height pairs; CMYK/ICC pixmaps converted to RGB before PNG save
- PPTX: table cells edited at run level (cell.text rebuild proven lossy);
  inventory walker recurses into group shapes; font triage resolves
  inherited fonts with theme major/minor fallback
- XLSX: sniffed CSV dialect passed to DictReader; round_trip_losses()
  detects parts an openpyxl round trip drops before saving
- DOCX: numbering restart via cloned <w:num> + startOverride, rendered
  proof in fixture (restarts at 1 vs style-reuse continuing at 4)

Depth references (original content, no proprietary material):
- docx cjk.md: east-asian font slot, 字号 table, char-based indent,
  fixed line spacing, GB/T 9704 page geometry, font availability risks
- docx scenes.md: academic paper / resume / official document / contract
  skeletons with scene-specific verification
- xlsx formatting.md: conditional formatting rules, structured tables,
  honest pivot aggregation routes (openpyxl cannot create pivots)

tests/: one runnable fixture per format, 30 assertions, all passing
locally (pdf 9, pptx 10, xlsx 6, docx 5 incl. soffice-rendered proof)
- xlsx edit: round_trip_changes() now also detects extensions stripped from
  retained parts (x14/extLst markers), not just dropped archive members
- docx scenes: signature blocks get row-level cantSplit + keep_with_next on
  all rows (rendered fixture proves the table stays on one page)
- docx cjk: tofu postcheck switched to glyph-coverage (fontTools cmap) since
  text extraction cannot detect missing-glyph boxes; style snippet now
  defines font names before use (NameError fix)
- pptx edit: locator candidate collection recurses into groups with a
  stable nested path for the uniqueness assertion
- xlsx formatting: aggregation formulas build sheet refs from ws.title
  (quoting when needed) instead of hard-coded Data!
- xlsx read: profiles every sheet by default, not just sheetnames[0]
- pdf create: escape() rule for plain text into Paragraph; fixture shows
  unescaped markup silently swallows <...> runs

Fixtures extended to 44 assertions, all passing locally
- pdf extract: real table detection via page.find_tables() with span fallback
- pdf postcheck: interactive-only pages (AcroForm widgets) exempt from text gate
- docx read: unified block walker yields tables inside w:sdtContent
- README: drop the untagged-ReportLab accessibility claim, state the limitation
- xlsx: fullCalcOnLoad contract so manual-calc workbooks recalculate on open
- fixtures: table detection, widget exemption, sdt table walker, calc flags (all green)
- pptx analyze: sparse XY/bubble cache points keep their idx so x/y/bubble
  values pair correctly across blank points
- docx cjk: Hangul (jamo, compatibility jamo, extended-A, syllables) routes
  through the eastAsia font slot
- xlsx edit: extension detection matches namespace URIs and the local name
  extLst instead of arbitrary XML prefixes
- xlsx formatting: header-only sheets skip conditional formatting instead of
  building inverted ranges openpyxl rejects
- docx read: table extraction walks real w:tc elements and annotates
  gridSpan/vMerge instead of the merge-expanded row.cells view
- pdf transform: stamps are scaled and centered per destination page via
  merge_transformed_page; rotated pages flagged for visual verification
- fixtures extended for all six (with negative controls)
- pdf postcheck: real overflow check - text blocks extracted through an
  enlarged clip rectangle and compared to the page box (plain extraction
  silently drops fully off-page text)
- docx read: table cells rebuilt per paragraph with visible tab/break
  markers instead of concatenated w:t text
- docx/pptx health checks: explicit require() raises so every archive
  limit survives python -O
- pptx analyze: run fonts resolve a:latin/a:ea/a:cs by the run's scripts
  before falling back to the Latin-only font.name; triage walks table
  cells (graphic frames have no text frame)
- docx SKILL: pandoc-only installs can serve read/extract requests
- pdf extract: inline content-stream images enumerated via dict image
  blocks alongside the XObject loop; coordinate spans position-sorted
  before emission
- xlsx read: implausible sheet <dimension> reset before streaming
- fixtures extended for the overflow check (with negative control), cell
  paragraph boundaries, dimension corruption, script faces, table triage
Address the latest review round: add bounded XLSX/OPC package preflight with compression, member, materialization and range-token budgets; route all existing-package loads through validated snapshots; harden DOCX CJK/locator, PDF Type3 and PPTX merged-slot guidance; cover CSV formula neutralization, missing dimension scanning and internal hyperlink rewrites with real OPC fixtures.
Copilot AI lite review requested due to automatic review settings August 19, 2026 09:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants