From 344a57a1ba28fb87baf392975a1470542b629aa8 Mon Sep 17 00:00:00 2001 From: zsx Date: Sat, 30 May 2026 15:40:45 +0800 Subject: [PATCH] Add minimax-docx-latex skill - Add LaTeX formula insertion for DOCX - Support LibreOffice live preview - All formula variables wrapped with $ --- README_zh.md | 1 + skills/minimax-docx-latex/CONTRIBUTING.md | 149 ++++++++++++++++++ skills/minimax-docx-latex/CREDITS.md | 36 +++++ skills/minimax-docx-latex/LICENSE | 21 +++ skills/minimax-docx-latex/SKILL.md | 110 +++++++++++++ .../references/formula_library.md | 40 +++++ .../scripts/add_latex_formulas.py | 72 +++++++++ 7 files changed, 429 insertions(+) create mode 100644 skills/minimax-docx-latex/CONTRIBUTING.md create mode 100644 skills/minimax-docx-latex/CREDITS.md create mode 100644 skills/minimax-docx-latex/LICENSE create mode 100644 skills/minimax-docx-latex/SKILL.md create mode 100644 skills/minimax-docx-latex/references/formula_library.md create mode 100755 skills/minimax-docx-latex/scripts/add_latex_formulas.py diff --git a/README_zh.md b/README_zh.md index b4b7f5f4..28eea3ef 100644 --- a/README_zh.md +++ b/README_zh.md @@ -22,6 +22,7 @@ | `pptx-generator` | 生成、编辑和读取 PowerPoint 演示文稿。支持用 PptxGenJS 从零创建(封面、目录、内容、分节页、总结页),通过 XML 工作流编辑现有 PPTX,或用 markitdown 提取文本。 | Official | | `minimax-xlsx` | 打开、创建、读取、分析、编辑或验证 Excel/电子表格文件(.xlsx、.xlsm、.csv、.tsv)。支持通过 XML 模板从零创建 xlsx、使用 pandas 读取分析、零格式损失编辑现有文件、公式重算与验证、专业财务格式化。 | Official | | `minimax-docx` | 基于 OpenXML SDK(.NET)的专业 DOCX 文档创建、编辑与排版。三条流水线:从零创建新文档、填写/编辑现有文档内容、应用模板格式并通过 XSD 验证门控检查。 | Official | +| `minimax-docx-latex` | 在 DOCX 中插入 LaTeX 格式数学公式。支持 LibreOffice 实时预览,所有公式变量用 $ 包裹(如 $\alpha$、$\sqrt{x+y}$)。 | Official | | `vision-analysis` | 使用视觉 AI 模型分析、描述和提取图像信息。支持描述、OCR 文字识别、UI 界面审查、图表数据提取和物体检测。基于 MiniMax VL API,OpenAI GPT-4V 作为备选。 | Community | | `minimax-multimodal-toolkit` | 通过 MiniMax API 生成语音、音乐、视频和图片内容 — MiniMax 多模态使用场景的统一入口。涵盖 TTS(文字转语音、声音克隆、声音设计、多段合成)、音乐(带词歌曲、纯音乐)、视频(文生视频、图生视频、首尾帧、主体参考、模板、长视频多场景)、图片(文生图、图生图含角色参考),以及基于 FFmpeg 的媒体处理(格式转换、拼接、裁剪、提取)。 | Official | | `minimax-music-gen` | 使用 MiniMax Music API 生成人声歌曲、纯音乐和翻唱。支持基础模式(一句话生成)和强控制模式(编辑歌词、调整 prompt、规划曲式)。内置歌词生成、风格词表、流式播放和迭代反馈。 | Official | diff --git a/skills/minimax-docx-latex/CONTRIBUTING.md b/skills/minimax-docx-latex/CONTRIBUTING.md new file mode 100644 index 00000000..f02c4215 --- /dev/null +++ b/skills/minimax-docx-latex/CONTRIBUTING.md @@ -0,0 +1,149 @@ +# Contributing to MiniMax Skills + +Thank you for your interest in contributing! This document covers PR requirements, skill structure specifications, and development guidelines. + +## Pull Request Requirements + +### Title Format + +Use [Conventional Commits](https://www.conventionalcommits.org/) style: + +``` +feat(): add new skill for X +fix(): fix YAML frontmatter parsing error +docs: update README skill table +chore: add CI workflow +``` + +Common prefixes: `feat` (new skill or feature), `fix` (bug fix), `docs` (documentation only), `refactor` (restructure without behavior change), `chore` (tooling, CI, config). + +### Scope + +**One PR, one purpose.** Each PR should do exactly one of: + +- Add a new skill +- Fix a bug in an existing skill +- Improve an existing skill + +Do not bundle unrelated changes together. + +### PR Description + +Every PR must include: + +1. **What** — what you added or changed +2. **Why** — the motivation or use case + +## Skill Structure + +### Directory Layout + +``` +skills// +├── SKILL.md # Required — entry point with YAML frontmatter +├── references/ # Optional — detailed reference docs +│ └── *.md +└── scripts/ # Optional — helper scripts + ├── *.py + └── requirements.txt # Required if scripts/ exists +``` + +- The directory name is the skill identifier. Use lowercase `kebab-case` (e.g., `gif-sticker-maker`). +- `SKILL.md` is the only required file. All other files and directories are optional. + +### SKILL.md Frontmatter + +```yaml +--- +name: my-skill # Required — must match directory name +description: > # Required — what this skill does and when to trigger it + One-paragraph description. Include trigger conditions so the agent + knows when to activate this skill (e.g., "Use when the user asks to + create, edit, or format Excel files"). +license: MIT # Recommended — defaults to MIT if omitted +metadata: # Recommended + version: "1.0" + category: productivity # e.g., frontend, mobile, productivity, creative + sources: + - Relevant documentation or standards +--- +``` + +**Required fields:** `name`, `description` + +- `name` must exactly match the directory name +- `description` must clearly state trigger conditions — this is what the agent uses to decide whether to load your skill + +**Recommended fields:** `license`, `metadata` (version, category, sources) + +### No Hardcoded Secrets + +**Never hardcode API keys, tokens, or credentials in any file.** + +If your skill involves calling an external API, instruct the agent to read credentials from environment variables. Follow the pattern established by existing skills: + +```python +API_KEY = os.getenv("MINIMAX_API_KEY") +if not API_KEY: + raise SystemExit("ERROR: MINIMAX_API_KEY is not set.\n export MINIMAX_API_KEY='your-key'") +``` + +Your `SKILL.md` should document the required environment variables as a prerequisite. See `frontend-dev/references/env-setup.md` for a good example. + +### README Sync + +When adding a new skill, update both `README.md` and `README_zh.md` to include your skill in the skill table. Community-submitted skills should set the Source column to `Community`. + +## Guidelines + +The following are not hard blockers, but PRs that follow these guidelines will be reviewed and merged faster. + +### 1. Skill Scope — Avoid Overlap + +Before creating a new skill, check existing skills for functional overlap. If your feature could be an extension of an existing skill, prefer extending over creating a new one. + +In your PR description, briefly explain how your skill differs from related existing skills. For example, if you are adding a voice synthesis skill, clarify how it relates to the TTS capabilities already in `frontend-dev`. + +### 2. File Size Awareness + +Skills are loaded into the agent's context window. Every token counts. + +- Keep individual `.md` files focused and concise +- If a reference document grows very large, split it into logical parts (see `minimax-docx/references/openxml_encyclopedia_part{1,2,3}.md` for an example) +- Avoid embedding large data blobs (base64 images, full API response dumps) directly in Markdown files +- Prefer linking to external resources over inlining lengthy content + +### 3. Script Standards + +If your skill includes helper scripts (typically in a `scripts/` directory): + +- Include a shebang line (e.g., `#!/usr/bin/env python3`) +- Provide a `requirements.txt` listing all dependencies +- Handle errors gracefully — fail with a clear message rather than a raw traceback +- Document script usage in `SKILL.md` or a reference file + +### 4. Language and Encoding + +- Skill names and file names: ASCII only, `kebab-case` +- SKILL.md content and code should be written in English +- Reference docs are recommended to be in English +- All files must be UTF-8 encoded + +## Review Process + +You can run the validation script locally to check part of the requirements before submitting: + +```bash +python .claude/skills/pr-review/scripts/validate_skills.py +``` + +You can also use the [pr-review skill](./.claude/skills/pr-review/SKILL.md) to let your AI coding agent assist with the review. + +1. Submit your PR following the requirements above +2. At least one maintainer will review +3. Address review feedback +4. Once approved, a maintainer will merge + +## Questions? + +Open an issue if you have questions about contributing. We're happy to help. diff --git a/skills/minimax-docx-latex/CREDITS.md b/skills/minimax-docx-latex/CREDITS.md new file mode 100644 index 00000000..020d3e18 --- /dev/null +++ b/skills/minimax-docx-latex/CREDITS.md @@ -0,0 +1,36 @@ +# Credits & Acknowledgments + +MiniMax Skills builds upon ideas and work from the open-source community. We are grateful to the following projects and authors whose contributions helped shape skills in this repository. + +## frontend-dev + +The design engineering framework — including the design-variance system, motion recipes, card archetypes, color rules, and forbidden-pattern checklist — is derived from and inspired by: + +- **[taste-skill](https://github.com/Leonxlnx/taste-skill)** by [Leonxlnx (Leon Lin)](https://github.com/Leonxlnx) — Anti-Slop Frontend design engineering skill framework. + +The visual art section — including the philosophy-first workflow, static/interactive art modes, viewer template, and generator template — is derived from: + +- **[canvas-design](https://github.com/anthropics/skills/tree/main/skills/canvas-design)** by Anthropic (Andi Brae) — Philosophy-first static visual art workflow. [Apache 2.0 License](./LICENSES/Apache-2.0.txt). +- **[algorithmic-art](https://github.com/anthropics/skills/tree/main/skills/algorithmic-art)** by Anthropic (Andi Brae) — Philosophy-first generative art workflow with p5.js. [Apache 2.0 License](./LICENSES/Apache-2.0.txt). + +MiniMax extended the original frameworks with MiniMax API asset generation, copywriting modules (AIDA/PAS/FAB), multi-framework support, accessibility guidelines, and additional motion presets. + +## react-native-dev + +The core UI patterns, navigation, animations, and styling guidance is derived from: + +- **[expo/skills](https://github.com/expo/skills/tree/main/plugins/expo/skills)** by [Expo](https://github.com/expo) (Kudo Chien / 650 Industries) — Expo development skills including building-native-ui. MIT License. + +MiniMax extended the original with state management (Zustand/Jotai), forms, networking, testing, performance profiling, native capabilities, and engineering/CI/CD guidance. + +## flutter-dev + +The widget patterns, state management (Riverpod/Bloc), GoRouter navigation, performance optimization, and testing strategies are derived from: + +- **[flutter-expert](https://github.com/Jeffallan/claude-skills/blob/main/skills/flutter-expert/SKILL.md)** by [Jeff Smolinski (@Jeffallan)](https://github.com/Jeffallan) — Flutter expert skill for Claude. MIT License. + +MiniMax restructured the workflow-based guide into a reference-based format and expanded the reference system with additional topics. + +--- + +If you believe your work has been included in this repository without proper attribution, please [open an issue](https://github.com/MiniMax-AI/skills/issues) and we will address it promptly. diff --git a/skills/minimax-docx-latex/LICENSE b/skills/minimax-docx-latex/LICENSE new file mode 100644 index 00000000..132dd20e --- /dev/null +++ b/skills/minimax-docx-latex/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 MiniMax + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/skills/minimax-docx-latex/SKILL.md b/skills/minimax-docx-latex/SKILL.md new file mode 100644 index 00000000..7880bfa1 --- /dev/null +++ b/skills/minimax-docx-latex/SKILL.md @@ -0,0 +1,110 @@ +--- +name: minimax-docx-latex +license: MIT +metadata: + version: "1.0.0" + category: document-processing + author: MiniMaxAI +description: > + 在 DOCX 中插入 LaTeX 格式数学公式。核心发现:LibreOffice 打开 DOCX 时不锁定文件, + minimax-docx 可以同时修改,实现实时预览编辑。 + 默认规则:所有公式变量必须用 $ 包裹,如 $\alpha$、$\beta$、$\sqrt{x+y}$。 +triggers: + - 添加公式 + - 插入 latex + - latex 公式 + - docx 公式 + - 修改 docx + - 转换 markdown 到 docx +--- + +# minimax-docx-latex + +在 DOCX 中插入 LaTeX 格式的数学公式。 + +## 默认规则 + +**重要:所有公式变量必须用 $ 包裹** + +| 类型 | 正确 | 错误 | +|------|------|------| +| 单变量 | $\alpha$ | \alpha | +| 分数 | $\frac{x}{y}$ | \frac{x}{y} | +| 开方 | $\sqrt{x+y}$ | \sqrt{x+y} | +| 积分 | $\int_{a}^{b} f(x) dx$ | \int_{a}^{b} f(x) dx | +| 求和 | $\sum_{i=1}^{n} i^2$ | \sum_{i=1}^{n} i^2 | +| 矩阵 | $\begin{pmatrix} a & b \end{pmatrix}$ | \begin{pmatrix} a & b \end{pmatrix} | +| 独立公式 | $$\int_{0}^{\infty} e^{-x^2} dx$$ | $$\int_{0}^{\infty} e^{-x^2} dx$$ | + +**示例:** +- ✅ $\alpha + \beta = \gamma$ +- ❌ \alpha + \beta = \gamma + +## 核心发现 + +| 软件 | 打开 DOCX 时 | 外部程序能同时修改? | +|------|-------------|---------------------| +| Word | 锁定文件 | ❌ 否 | +| LibreOffice | **不锁定** | ✅ **可以** | + +**原理:** +- DOCX 本质是 ZIP 包(包含 word/document.xml) +- LibreOffice 打开时显示内存缓存,不影响磁盘文件 +- minimax-docx 直接操作磁盘上的 ZIP 包 +- 外部修改后,LibreOffice 按 Ctrl+Shift+R 刷新即可看到变化 + +## 使用流程 + +### 1. 启动 LibreOffice(保持连接) + +```bash +# 方式 A:图形界面打开(推荐) +libreoffice /path/to/document.docx + +# 方式 B:命令行 headless 模式 +libreoffice --headless --norestore \ + --accept="socket,host=localhost,port=2003;urp;" \ + --nofirststartwizard & +``` + +### 2. 用 minimax-docx 修改 DOCX + +```bash +# 在 LibreOffice 打开文件的同时,直接修改 +dotnet run --project MiniMaxAIDocx.Cli -- edit replace-text \ + --input document.docx \ + --output document.docx \ + --search "OLD_TEXT" \ + --replace "$\alpha + \beta$" +``` + +### 3. 刷新预览 + +在 LibreOffice 中按 **Ctrl+Shift+R**(或 文件 → 重新装入) + +## LaTeX 公式格式 + +Word/LibreOffice 支持的 LaTeX 公式语法: + +| 类型 | 语法 | 示例 | +|------|------|------| +| 行内公式 | `$...$` | `$x^2 + y^2$` | +| 独立公式 | `$$...$$` | `$$\int_0^\infty e^{-x} dx$$` | +| 分数 | `\frac{分子}{分母}` | `$\frac{a}{b}$` | +| 上标 | `^{指数}` | `$x^{2}$` | +| 下标 | `_{下标}` | `$x_{i}$` | +| 平方根 | `\sqrt{内容}` | `$\sqrt{x+y}$` | +| 求和 | `\sum_{下标}^{上标}` | `$\sum_{i=1}^{n}$` | +| 积分 | `\int_{下标}^{上标}` | `$\int_{a}^{b}$` | +| 无穷 | `\infty` | `$\infty$` | +| 希腊字母 | `\alpha \beta \gamma` | `$\alpha + \beta$` | + +## 完整公式库 + +见 `references/formula_library.md` + +## 限制 + +- 仅 LibreOffice 支持实时预览(Word 会锁定) +- LaTeX 文本格式,非渲染图片 +- 如需渲染,需在 Office 软件中手动转换格式 diff --git a/skills/minimax-docx-latex/references/formula_library.md b/skills/minimax-docx-latex/references/formula_library.md new file mode 100644 index 00000000..500f8f35 --- /dev/null +++ b/skills/minimax-docx-latex/references/formula_library.md @@ -0,0 +1,40 @@ +# LaTeX 公式库 + +## 常用公式 + +### 基础运算 +- `$\frac{x}{y}$` - 分数 +- `$x^{2}$` - 平方 +- `$x_{i}$` - 下标 +- `$\sqrt{x}$` - 平方根 +- `$\pm$` - 加减号 +- `$\times$` - 乘号 +- `$\div$` - 除号 + +### 代数 +- `$a^2 + b^2 = c^2$` - 勾股定理 +- `$\frac{-b \pm \sqrt{b^2-4ac}}{2a}$` - 一元二次方程求根公式 +- `$\binom{n}{k} = \frac{n!}{k!(n-k)!}$` - 组合数 + +### 微积分 +- `$\int_{a}^{b} f(x) dx$` - 定积分 +- `$\int_{0}^{\infty} e^{-x^2} dx$` - 高斯积分 +- `$\sum_{i=1}^{n} i^2$` - 求和 +- `$\lim_{x \to \infty} \frac{1}{x}$` - 极限 +- `$\frac{dy}{dx}$` - 导数 +- `$\frac{\partial f}{\partial x}$` - 偏导 + +### 矩阵 +- `$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$` - 2×2 矩阵 +- `$\det(A-\lambda I) = 0$` - 特征方程 +- `$A^{-1}$` - 逆矩阵 + +### 物理 +- `$E = mc^2$` - 质能方程 +- `$e^{i\pi} + 1 = 0$` - 欧拉公式 +- `$\Delta x \cdot \Delta p \geq \frac{\hbar}{2}$` - 不确定性原理 +- `$i\hbar\frac{\partial}{\partial t}\Psi = \hat{H}\Psi$` - 薛定谔方程 +- `$\lambda = \frac{h}{p}$` - 德布罗意波长 + +### 希腊字母 +`$\alpha$ $\beta$ $\gamma$ $\delta$ $\theta$ $\pi$ $\sigma$ $\omega$ $\hbar$ $\nabla$ diff --git a/skills/minimax-docx-latex/scripts/add_latex_formulas.py b/skills/minimax-docx-latex/scripts/add_latex_formulas.py new file mode 100755 index 00000000..e32e2b7f --- /dev/null +++ b/skills/minimax-docx-latex/scripts/add_latex_formulas.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +""" +Add LaTeX formulas to DOCX file using minimax-docx CLI. + +Usage: + python3 add_latex_formulas.py [output_file] + +Example: + python3 add_latex_formulas.py document.docx "--- Formula Test ---" +""" + +import subprocess +import sys +import os + +MINIMAX_DOCX_CLI = "/tmp/skills-repo/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Cli" + +# Formula templates +LATEX_FORMULAS = { + "fraction": "$\\frac{x}{y}$", + "sqrt": "$\\sqrt{x+y}$", + "power": "$x^{2}$", + "subscript": "$x_{i}$", + "integral": "$\\int_{a}^{b} f(x) dx$", + "sum": "$\\sum_{i=1}^{n} i^2$", + "limit": "$\\lim_{x \\to \\infty} \\frac{1}{x}$", + "derivative": "$\\frac{dy}{dx}$", + "partial": "$\\frac{\\partial f}{\\partial x}$", + "matrix": "$\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}$", + "euler": "$e^{i\\pi} + 1 = 0$", + "emc2": "$E = mc^2$", + "uncertainty": "$\\Delta x \\cdot \\Delta p \\geq \\frac{\\hbar}{2}$", + "schrodinger": "$i\\hbar\\frac{\\partial}{\\partial t}\\Psi = \\hat{H}\\Psi$", +} + +def add_formulas(docx_path, marker, output_path=None): + """Add formulas to DOCX file.""" + if output_path is None: + output_path = docx_path + + # Build formula text + formulas_text = "\n".join([f"{i+1}. {f}" for i, f in enumerate(LATEX_FORMULAS.values())]) + replace_text = f"---\n{formulas_text}\n---" + + # Call minimax-docx CLI + cmd = [ + "dotnet", "run", "--project", "MiniMaxAIDocx.Cli", "--", + "edit", "replace-text", + "--input", docx_path, + "--output", output_path, + "--search", marker, + "--replace", replace_text + ] + + result = subprocess.run(cmd, cwd=os.path.dirname(MINIMAX_DOCX_CLI), capture_output=True, text=True) + + if result.returncode == 0: + print(f"Success! Added {len(LATEX_FORMULAS)} formulas to {output_path}") + else: + print(f"Error: {result.stderr}") + sys.exit(1) + +if __name__ == "__main__": + if len(sys.argv) < 3: + print(__doc__) + sys.exit(1) + + docx_file = sys.argv[1] + marker = sys.argv[2] + output = sys.argv[3] if len(sys.argv) > 3 else None + + add_formulas(docx_file, marker, output)