@ycodium-ai/plugin-office 0.0.0-stage → 0.2.2804
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/README.md +98 -2
- package/assets/check_office.py +279 -0
- package/dist/index.js +1575 -0
- package/locales/en.json +109 -0
- package/locales/zh-CN.json +109 -0
- package/package.json +89 -3
- package/skills/office-docx/SKILL.md +57 -0
- package/skills/office-pptx/SKILL.md +81 -0
- package/skills/office-xlsx/SKILL.md +74 -0
- package/ui/ui.js +1 -0
package/locales/en.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"settings": {
|
|
3
|
+
"card": {
|
|
4
|
+
"title": "Office",
|
|
5
|
+
"description": "Agents use these tools to create, check, and render Word, PowerPoint, and Excel files, and the app uses them to preview Office files. Nothing is downloaded until you install it here. Everything stays in this plugin's own folder on this machine."
|
|
6
|
+
},
|
|
7
|
+
"npmRegistry": {
|
|
8
|
+
"label": "npm registry",
|
|
9
|
+
"description": "Where the Office engine is downloaded from. Leave empty for registry.npmjs.org; a mirror must serve the same packages."
|
|
10
|
+
},
|
|
11
|
+
"githubMirror": {
|
|
12
|
+
"label": "GitHub download prefix",
|
|
13
|
+
"description": "Put in front of GitHub download addresses for Python and fonts, for a proxy service. Leave empty to download directly."
|
|
14
|
+
},
|
|
15
|
+
"pypiMirror": {
|
|
16
|
+
"label": "PyPI files mirror",
|
|
17
|
+
"description": "Replaces https://files.pythonhosted.org/packages for the document libraries. Leave empty to use PyPI."
|
|
18
|
+
},
|
|
19
|
+
"localDir": {
|
|
20
|
+
"label": "Local folder",
|
|
21
|
+
"description": "A folder on this machine with files downloaded ahead of time. Files found there are used instead of downloading; they are checked the same way."
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"actions": {
|
|
25
|
+
"installEngine": {
|
|
26
|
+
"label": "Install engine",
|
|
27
|
+
"description": "Downloads the LibreOffice-based engine (a 50–70 MB download, MPL-2.0) that renders and converts documents."
|
|
28
|
+
},
|
|
29
|
+
"installPython": {
|
|
30
|
+
"label": "Install Python",
|
|
31
|
+
"description": "Downloads Python 3.12 with python-docx, python-pptx, openpyxl, pandas, and Pillow for writing documents (about 60 MB)."
|
|
32
|
+
},
|
|
33
|
+
"installFonts": {
|
|
34
|
+
"label": "Install Chinese fonts",
|
|
35
|
+
"description": "Downloads Noto Sans SC and Noto Serif SC (about 40 MB, SIL OFL) for the engine only. System fonts are not changed."
|
|
36
|
+
},
|
|
37
|
+
"health": {
|
|
38
|
+
"label": "Check",
|
|
39
|
+
"description": "Checks that the engine starts, the document libraries load, and Chinese fonts are available."
|
|
40
|
+
},
|
|
41
|
+
"remove": {
|
|
42
|
+
"label": "Delete engine",
|
|
43
|
+
"description": "Deletes the engine, Python, and fonts from this machine. You can install them again later."
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"progress": {
|
|
47
|
+
"step": {
|
|
48
|
+
"download": "Download and verify",
|
|
49
|
+
"unpack": "Unpack",
|
|
50
|
+
"check": "Check"
|
|
51
|
+
},
|
|
52
|
+
"downloading": "Downloading {{file}} ({{index}} of {{count}}): {{done}} of {{total}} MB",
|
|
53
|
+
"downloadingUnknown": "Downloading {{file}} ({{index}} of {{count}}): {{done}} MB",
|
|
54
|
+
"checking": "Checking this machine…",
|
|
55
|
+
"removing": "Deleting…",
|
|
56
|
+
"done": {
|
|
57
|
+
"engine": {
|
|
58
|
+
"native": "The engine is installed.",
|
|
59
|
+
"wasm": "The engine is installed. This machine runs its WebAssembly build, which needs more memory and starts more slowly."
|
|
60
|
+
},
|
|
61
|
+
"python": "Python and the document libraries are installed.",
|
|
62
|
+
"fonts": "Chinese fonts are installed for the engine.",
|
|
63
|
+
"removed": "The engine, Python, and fonts were deleted."
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"health": {
|
|
67
|
+
"summary": {
|
|
68
|
+
"ok": "Everything is ready.",
|
|
69
|
+
"issues": "Some parts need attention."
|
|
70
|
+
},
|
|
71
|
+
"unsupportedPlatform": "This machine's platform has no engine build.",
|
|
72
|
+
"engine": {
|
|
73
|
+
"ok": "Engine: ready ({{backend}}).",
|
|
74
|
+
"missing": "Engine: not installed.",
|
|
75
|
+
"broken": "Engine: does not start. {{detail}}"
|
|
76
|
+
},
|
|
77
|
+
"python": {
|
|
78
|
+
"ok": "Python: ready.",
|
|
79
|
+
"missing": "Python: not installed.",
|
|
80
|
+
"broken": "Python: the document libraries do not load. {{detail}}",
|
|
81
|
+
"unsupported": "Python: no build for this machine's platform."
|
|
82
|
+
},
|
|
83
|
+
"fonts": {
|
|
84
|
+
"ok": "Chinese fonts: available.",
|
|
85
|
+
"missing": "Chinese fonts: none on this machine. Install them here, or install a system package such as fonts-noto-cjk."
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"failure": {
|
|
89
|
+
"busy": "Another install or delete is still running. Try again when it finishes.",
|
|
90
|
+
"unsupported-platform": "This machine's platform has no engine build.",
|
|
91
|
+
"unpack-failed": "The download could not be unpacked.",
|
|
92
|
+
"engine-unavailable": "The engine was installed but does not start on this machine.",
|
|
93
|
+
"engine-unavailable-windows": "The engine does not start. Windows needs the Microsoft Visual C++ 2015–2022 Redistributable for this machine's architecture.",
|
|
94
|
+
"python-failed": "Python was downloaded but the document libraries could not be installed.",
|
|
95
|
+
"python-unsupported": "There is no Python build for this machine's platform.",
|
|
96
|
+
"download-network": "The download could not reach the server. Check this machine's internet access and proxy.",
|
|
97
|
+
"download-http": "The server refused the download.",
|
|
98
|
+
"download-integrity": "A downloaded file did not match its checksum and was discarded.",
|
|
99
|
+
"download-disk": "This machine ran out of disk space.",
|
|
100
|
+
"unknown": "Something went wrong."
|
|
101
|
+
},
|
|
102
|
+
"card": {
|
|
103
|
+
"page": "Page {{page}}",
|
|
104
|
+
"loading": "Loading…",
|
|
105
|
+
"imageUnavailable": "Image unavailable",
|
|
106
|
+
"noCjkFont": "This machine has no Chinese font, so Chinese text in these pages shows as boxes.",
|
|
107
|
+
"missingFonts": "Missing fonts, substituted: {{fonts}}"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"settings": {
|
|
3
|
+
"card": {
|
|
4
|
+
"title": "Office",
|
|
5
|
+
"description": "agent 用这些工具新建、检查、渲染 Word、PowerPoint、Excel 文件,应用用它们预览 Office 文件。在这里点安装之前什么都不会下载,装的东西都放在这台机器上本插件自己的目录里。"
|
|
6
|
+
},
|
|
7
|
+
"npmRegistry": {
|
|
8
|
+
"label": "npm 源",
|
|
9
|
+
"description": "从哪里下载 Office 引擎。留空用 registry.npmjs.org;换成镜像也必须是同样的包。"
|
|
10
|
+
},
|
|
11
|
+
"githubMirror": {
|
|
12
|
+
"label": "GitHub 下载前缀",
|
|
13
|
+
"description": "加在 Python 与字体的 GitHub 下载地址前面,用于代理服务。留空表示直连。"
|
|
14
|
+
},
|
|
15
|
+
"pypiMirror": {
|
|
16
|
+
"label": "PyPI 文件镜像",
|
|
17
|
+
"description": "替换写文档的库的下载地址 https://files.pythonhosted.org/packages。留空用 PyPI。"
|
|
18
|
+
},
|
|
19
|
+
"localDir": {
|
|
20
|
+
"label": "本地文件夹",
|
|
21
|
+
"description": "这台机器上事先下好文件的文件夹。在这里找到的文件就不再下载,照样校验。"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"actions": {
|
|
25
|
+
"installEngine": {
|
|
26
|
+
"label": "安装引擎",
|
|
27
|
+
"description": "下载基于 LibreOffice 的引擎(约 50–70 MB,MPL-2.0),用来渲染和转换文档。"
|
|
28
|
+
},
|
|
29
|
+
"installPython": {
|
|
30
|
+
"label": "安装 Python",
|
|
31
|
+
"description": "下载 Python 3.12 以及 python-docx、python-pptx、openpyxl、pandas、Pillow,用来写文档(约 60 MB)。"
|
|
32
|
+
},
|
|
33
|
+
"installFonts": {
|
|
34
|
+
"label": "安装中文字体",
|
|
35
|
+
"description": "下载思源黑体与思源宋体的 Noto 版(约 40 MB,SIL OFL),只给引擎用,不改系统字体。"
|
|
36
|
+
},
|
|
37
|
+
"health": {
|
|
38
|
+
"label": "检查",
|
|
39
|
+
"description": "检查引擎能否启动、写文档的库能否加载、有没有中文字体。"
|
|
40
|
+
},
|
|
41
|
+
"remove": {
|
|
42
|
+
"label": "删除引擎",
|
|
43
|
+
"description": "从这台机器上删掉引擎、Python 和字体,之后可以重新安装。"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"progress": {
|
|
47
|
+
"step": {
|
|
48
|
+
"download": "下载并校验",
|
|
49
|
+
"unpack": "解包",
|
|
50
|
+
"check": "检查"
|
|
51
|
+
},
|
|
52
|
+
"downloading": "正在下载 {{file}}({{index}}/{{count}}):{{done}} / {{total}} MB",
|
|
53
|
+
"downloadingUnknown": "正在下载 {{file}}({{index}}/{{count}}):{{done}} MB",
|
|
54
|
+
"checking": "正在检查这台机器……",
|
|
55
|
+
"removing": "正在删除……",
|
|
56
|
+
"done": {
|
|
57
|
+
"engine": {
|
|
58
|
+
"native": "引擎已安装。",
|
|
59
|
+
"wasm": "引擎已安装。这台机器用的是 WebAssembly 版,占内存更多,启动更慢。"
|
|
60
|
+
},
|
|
61
|
+
"python": "Python 与写文档的库已安装。",
|
|
62
|
+
"fonts": "已为引擎装好中文字体。",
|
|
63
|
+
"removed": "引擎、Python 和字体已删除。"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"health": {
|
|
67
|
+
"summary": {
|
|
68
|
+
"ok": "全部就绪。",
|
|
69
|
+
"issues": "有几项需要处理。"
|
|
70
|
+
},
|
|
71
|
+
"unsupportedPlatform": "这台机器的平台没有引擎可用。",
|
|
72
|
+
"engine": {
|
|
73
|
+
"ok": "引擎:就绪({{backend}})。",
|
|
74
|
+
"missing": "引擎:未安装。",
|
|
75
|
+
"broken": "引擎:启动不了。{{detail}}"
|
|
76
|
+
},
|
|
77
|
+
"python": {
|
|
78
|
+
"ok": "Python:就绪。",
|
|
79
|
+
"missing": "Python:未安装。",
|
|
80
|
+
"broken": "Python:写文档的库加载不了。{{detail}}",
|
|
81
|
+
"unsupported": "Python:这台机器的平台没有可用的版本。"
|
|
82
|
+
},
|
|
83
|
+
"fonts": {
|
|
84
|
+
"ok": "中文字体:有。",
|
|
85
|
+
"missing": "中文字体:这台机器上没有。可以在这里安装,或者用系统包管理器装 fonts-noto-cjk 之类的包。"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"failure": {
|
|
89
|
+
"busy": "另一个安装或删除还在进行,等它结束再试。",
|
|
90
|
+
"unsupported-platform": "这台机器的平台没有引擎可用。",
|
|
91
|
+
"unpack-failed": "下载的文件解不开。",
|
|
92
|
+
"engine-unavailable": "引擎装好了,但在这台机器上启动不了。",
|
|
93
|
+
"engine-unavailable-windows": "引擎启动不了。Windows 需要与这台机器架构相同的 Microsoft Visual C++ 2015–2022 运行库。",
|
|
94
|
+
"python-failed": "Python 下载好了,但写文档的库没能装上。",
|
|
95
|
+
"python-unsupported": "这台机器的平台没有可用的 Python。",
|
|
96
|
+
"download-network": "下载连不上服务器。请检查这台机器的网络和代理。",
|
|
97
|
+
"download-http": "服务器拒绝了下载。",
|
|
98
|
+
"download-integrity": "有个下载的文件与校验值对不上,已丢弃。",
|
|
99
|
+
"download-disk": "这台机器的磁盘空间不够了。",
|
|
100
|
+
"unknown": "出了点问题。"
|
|
101
|
+
},
|
|
102
|
+
"card": {
|
|
103
|
+
"page": "第 {{page}} 页",
|
|
104
|
+
"loading": "正在加载……",
|
|
105
|
+
"imageUnavailable": "图片打不开",
|
|
106
|
+
"noCjkFont": "这台机器上没有中文字体,这些页面里的中文显示成了方块。",
|
|
107
|
+
"missingFonts": "缺少的字体(已替换):{{fonts}}"
|
|
108
|
+
}
|
|
109
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,92 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/plugin-office",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.2804",
|
|
4
|
+
"description": "Lets agents create, check, and render Word, PowerPoint, and Excel files, and previews Office files in the app.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"docx",
|
|
7
|
+
"office",
|
|
8
|
+
"pptx",
|
|
9
|
+
"xlsx",
|
|
10
|
+
"ycodium",
|
|
11
|
+
"ycodium-plugin"
|
|
12
|
+
],
|
|
13
|
+
"license": "UNLICENSED",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"ui",
|
|
17
|
+
"assets",
|
|
18
|
+
"skills",
|
|
19
|
+
"locales",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@effect/vitest": "4.0.0-beta.103",
|
|
28
|
+
"esbuild": "0.28.1",
|
|
29
|
+
"typescript": "~6.0.3",
|
|
30
|
+
"vite-plus": "0.2.2",
|
|
31
|
+
"@ycodium-ai/plugin-api": "0.2.2804"
|
|
32
|
+
},
|
|
33
|
+
"ycodium": {
|
|
34
|
+
"plugin": "./dist/index.js",
|
|
35
|
+
"displayName": "Office",
|
|
36
|
+
"description": "Lets agents create, check, and render Word, PowerPoint, and Excel files, and previews Office files in the app.",
|
|
37
|
+
"icon": "fileText",
|
|
38
|
+
"permissions": [
|
|
39
|
+
{
|
|
40
|
+
"kind": "process.spawn",
|
|
41
|
+
"programs": [
|
|
42
|
+
"host:node",
|
|
43
|
+
"tar",
|
|
44
|
+
"fc-list",
|
|
45
|
+
"data:runtime/python/python.exe",
|
|
46
|
+
"data:runtime/python/bin/python3"
|
|
47
|
+
],
|
|
48
|
+
"maxConcurrent": 6
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"kind": "process.workspace"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"kind": "workspace.read"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"skills": [
|
|
58
|
+
"./skills/office-docx",
|
|
59
|
+
"./skills/office-pptx",
|
|
60
|
+
"./skills/office-xlsx"
|
|
61
|
+
],
|
|
62
|
+
"filePreview": {
|
|
63
|
+
"extensions": [
|
|
64
|
+
".doc",
|
|
65
|
+
".docx",
|
|
66
|
+
".odt",
|
|
67
|
+
".ppt",
|
|
68
|
+
".pptx",
|
|
69
|
+
".odp",
|
|
70
|
+
".xls",
|
|
71
|
+
".xlsx",
|
|
72
|
+
".ods"
|
|
73
|
+
],
|
|
74
|
+
"command": "convert-preview"
|
|
75
|
+
},
|
|
76
|
+
"ui": {
|
|
77
|
+
"assets": "./ui",
|
|
78
|
+
"entry": "ui.js",
|
|
79
|
+
"toolViews": [
|
|
80
|
+
{
|
|
81
|
+
"tool": "render",
|
|
82
|
+
"view": "render-result"
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"scripts": {
|
|
88
|
+
"build": "node build.mjs",
|
|
89
|
+
"typecheck": "tsgo --noEmit",
|
|
90
|
+
"test": "vp test run"
|
|
91
|
+
}
|
|
6
92
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: office-docx
|
|
3
|
+
description: Create, read, edit, and check Word documents (.docx), including reports, letters, and formatted tables. Use when a DOCX file is an input or requested deliverable. Load this skill before running Office commands. Use only the office_* tools for LibreOffice operations unless the user explicitly opts out; without that opt-out, do not search for another LibreOffice executable.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Word documents
|
|
7
|
+
|
|
8
|
+
Use `python-docx` for DOCX creation and ordinary edits. Follow an explicit user or applicable AGENTS.md requirement for a project environment or another library. Otherwise call `office_python` and execute the returned Python path with its bundled libraries. Do not install packages or discover a system Python for the default workflow. If the tool reports that Python is not installed, use an already configured environment and report a missing dependency only when it prevents the requested operation.
|
|
9
|
+
|
|
10
|
+
Keep source scripts, intermediate files, and final documents in the task workspace; the runtime is a read-only resource. Use the user's requested language and preserve an existing document's design unless a redesign is requested.
|
|
11
|
+
|
|
12
|
+
## Create and edit
|
|
13
|
+
|
|
14
|
+
For existing files, inspect paragraphs, runs, tables, sections, headers, and footers before changing the affected content. Save to a new file unless the user requests an in-place edit. Replacing a paragraph's `.text` destroys its run formatting; change the relevant runs when formatting must survive. Reconstructing the whole document can lose features outside python-docx's supported editing API.
|
|
15
|
+
|
|
16
|
+
Use paragraph styles for headings and body text. Size tables for the section that contains them, and account for merged cells and nested tables. Chinese, Japanese, and Korean text may need an explicit `w:eastAsia` font assignment in addition to `run.font.name`; font names alone do not establish glyph availability or rendered appearance.
|
|
17
|
+
|
|
18
|
+
For a new document, use the selected Python executable:
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from docx import Document
|
|
22
|
+
|
|
23
|
+
document = Document()
|
|
24
|
+
document.add_heading("Project report", level=0)
|
|
25
|
+
document.add_paragraph("Summary", style="Heading 1")
|
|
26
|
+
document.add_paragraph("The requested findings go here.")
|
|
27
|
+
document.save("report.docx")
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
python-docx does not paginate or render documents. Do not represent ordinary replacement, colored text, or comments as tracked changes. When real revisions or unsupported OOXML features matter, preserve their package parts and verify the requested operation rather than silently discarding them.
|
|
31
|
+
|
|
32
|
+
## Check and deliver
|
|
33
|
+
|
|
34
|
+
Call `office_check` with the document path:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
office_check({"path": "report.docx"})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
It checks ZIP/XML integrity and internal relationships, and reports paragraphs, logical table dimensions, and sections. Optional `contains` entries assert required text. A successful structural check does not verify pagination, clipping, fonts, or visual appearance. Compare the summary and reopened document with the user's request, including unchanged content that matters to an edit.
|
|
41
|
+
|
|
42
|
+
Render for a requested image/PDF deliverable or an actionable layout check. Before generating images only for inspection, establish that the current model accepts images. If image input is unavailable, finish structural and content checks and state that visual layout was not inspected; do not generate unreadable previews, retry reading images, or choose a second model.
|
|
43
|
+
|
|
44
|
+
Use the `office_*` tools for every LibreOffice operation unless the user explicitly asks not to use them. Without that explicit opt-out, never search for or invoke system LibreOffice, `soffice`, an application-installed binary, or a downloaded replacement. If a tool reports that the engine is not installed or fails, report that failure instead of substituting another executable.
|
|
45
|
+
|
|
46
|
+
`office_render` and `office_convert` run the engine installed for this machine from the task directory. Direct rendering avoids an intermediate PDF:
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
office_render({"path": "report.docx", "outputDir": "preview-v1", "pages": "1,3", "dpi": 144})
|
|
50
|
+
office_convert({"path": "report.docx", "output": "report.pdf"})
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Choose pages relevant to the requested edit; inspect all pages when whole-document layout is required. Batch selected pages in one call and use the returned page count, image paths, and missing-font diagnostics; up to four images come back with the result. Output directories and converted files must be new. Reuse images for the same saved document; render again only after a source change, for an unrendered page, or to diagnose a concrete failure. Check page breaks, clipped text, headings, and table widths. Do not repeatedly export unchanged documents or infer visual overflow solely from guessed text geometry.
|
|
54
|
+
|
|
55
|
+
If the engine is not installed or rendering fails, preserve the usable source and report the inspection limit. Do not search for COM automation, install conversion packages, or build another rendering pipeline for routine QA. LibreOffice pagination can differ from Microsoft Word. Once the requested content and applicable checks pass, deliver the document.
|
|
56
|
+
|
|
57
|
+
Give the user the actual final DOCX path in the workspace. Keep that file in place, and do not present temporary QA reports unless requested.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: office-pptx
|
|
3
|
+
description: Create, read, edit, and check PowerPoint presentations (.pptx), including slide text, tables, images, and charts. Use when a PPTX file is an input or requested deliverable. Load this skill before running Office commands. Use only the office_* tools for LibreOffice operations unless the user explicitly opts out; without that opt-out, do not search for another LibreOffice executable.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PowerPoint presentations
|
|
7
|
+
|
|
8
|
+
Follow an explicit user or applicable AGENTS.md requirement for an environment or library. Otherwise call `office_python` and use its Python executable and bundled presentation libraries. Do not install npm or pip packages or locate a system interpreter for the default workflow. If the tool reports that Python is not installed, use an already configured environment and report a missing dependency only when it prevents the requested operation.
|
|
9
|
+
|
|
10
|
+
Keep scripts and output files in the task workspace. The runtime contains shared read-only resources. Match the requested slide language and the supplied presentation's design when editing it.
|
|
11
|
+
|
|
12
|
+
## Create and edit
|
|
13
|
+
|
|
14
|
+
Use `python-pptx` to inspect or modify an existing presentation. Inspect slide layouts, text runs, images, tables, and charts before editing. Change only the requested content, preserve mixed text formatting, and save to a new file unless the user requests an in-place edit. Rebuilding slides can discard unsupported animation, SmartArt, or other extension content.
|
|
15
|
+
|
|
16
|
+
For a new deck, use `python-pptx` with editable text, tables, and charts. Use local image assets rather than network-dependent image URLs. Set slide dimensions, text sizes, and chart data explicitly.
|
|
17
|
+
|
|
18
|
+
A minimal editable deck, run with the selected Python executable:
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from pptx import Presentation
|
|
22
|
+
from pptx.chart.data import CategoryChartData
|
|
23
|
+
from pptx.enum.chart import XL_CHART_TYPE
|
|
24
|
+
from pptx.util import Inches, Pt
|
|
25
|
+
|
|
26
|
+
presentation = Presentation()
|
|
27
|
+
presentation.slide_width = Inches(13.333)
|
|
28
|
+
presentation.slide_height = Inches(7.5)
|
|
29
|
+
slide = presentation.slides.add_slide(presentation.slide_layouts[6])
|
|
30
|
+
title = slide.shapes.add_textbox(Inches(0.6), Inches(0.4), Inches(12), Inches(0.8))
|
|
31
|
+
run = title.text_frame.paragraphs[0].add_run()
|
|
32
|
+
run.text = "Quarterly report"
|
|
33
|
+
run.font.size = Pt(30)
|
|
34
|
+
data = CategoryChartData()
|
|
35
|
+
data.categories = ["Q1", "Q2"]
|
|
36
|
+
data.add_series("Revenue", [12, 18])
|
|
37
|
+
slide.shapes.add_chart(XL_CHART_TYPE.COLUMN_CLUSTERED,
|
|
38
|
+
Inches(0.8), Inches(1.6), Inches(11.5), Inches(4.8), data)
|
|
39
|
+
presentation.save("report.pptx")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Use `Inches` or `Cm` for positions and sizes and `Pt` for font sizes. To edit a generated title while retaining its other slides and charts:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from pptx import Presentation
|
|
46
|
+
|
|
47
|
+
presentation = Presentation("report.pptx")
|
|
48
|
+
for shape in presentation.slides[0].shapes:
|
|
49
|
+
if shape.has_text_frame and shape.text == "Quarterly report":
|
|
50
|
+
shape.text_frame.paragraphs[0].runs[0].text = "Quarterly results"
|
|
51
|
+
presentation.save("report-edited.pptx")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Check that text and images fit the slide dimensions, titles form a useful sequence, and chart labels agree with source values. A native chart's embedded workbook is part of the deliverable and must contain the intended data. Library support for writing PPTX is not a rendering engine or a guarantee that every PowerPoint feature survives editing.
|
|
55
|
+
|
|
56
|
+
## Check and deliver
|
|
57
|
+
|
|
58
|
+
Call `office_check` with the presentation path:
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
office_check({"path": "report.pptx", "contains": ["Quarterly results"], "count": 5})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
It checks ZIP/XML integrity and internal relationships and reports slide count and extracted text. Use `contains` entries for required slide text and `count` for a requested slide count; `contains` excludes chart text and speaker notes. Reopen the file to check the requested edits, chart data, and notes. Structural success does not establish text fit, alignment, readable contrast, or rendering fidelity.
|
|
65
|
+
|
|
66
|
+
Render for requested images/PDFs or an actionable layout check. Before generating images only for inspection, establish that the current model accepts images. If it does not, finish structural and content checks and state that visual layout was not inspected; do not rasterize slides the model cannot read, retry reading images, or choose a second model.
|
|
67
|
+
|
|
68
|
+
Use the `office_*` tools for every LibreOffice operation unless the user explicitly asks not to use them. Without that explicit opt-out, never search for or invoke system LibreOffice, `soffice`, an application-installed binary, or a downloaded replacement. If a tool reports that the engine is not installed or fails, report that failure instead of substituting another executable.
|
|
69
|
+
|
|
70
|
+
`office_render` and `office_convert` run the engine installed for this machine from the task directory. Render slides directly:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
office_render({"path": "report.pptx", "outputDir": "preview-v1", "pages": "1,3,4", "dpi": 144})
|
|
74
|
+
office_convert({"path": "report.pptx", "output": "report.pdf"})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Batch affected slides in one call; inspect every slide for a new deck or a whole-deck design review. Read the returned image paths, including missing-font diagnostics; up to four images come back with the result. Outputs must be new directories/files. Retain and reuse previews for the same saved source; rerender only after edits, for missing slides, or to diagnose a concrete failure. Check clipping, alignment, contrast, and chart labels. Do not substitute guessed geometry for visual evidence or repeat successful exports of unchanged slides.
|
|
78
|
+
|
|
79
|
+
If the engine is not installed or rendering fails, retain the usable source and report the inspection limit. Do not search for COM automation, install conversion packages, or build another renderer for routine QA. LibreOffice previews do not certify pixel-identical PowerPoint or Keynote output, animation, or media playback. Deliver once the requested content and applicable checks pass.
|
|
80
|
+
|
|
81
|
+
Give the user the actual final PPTX path in the workspace. Keep that file in place, and leave intermediate images and reports out of delivery unless requested.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: office-xlsx
|
|
3
|
+
description: Read, create, and modify Excel workbooks (.xlsx), including data, formulas, formatting, and pandas analysis. Use for Excel inputs or deliverables. Load before running Office commands. Data and formula tasks skip visual inspection; inspect only for formatting or layout needs. Use only the office_* tools for LibreOffice operations unless the user explicitly opts out; without that opt-out, do not search for another LibreOffice executable.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Excel workbooks
|
|
7
|
+
|
|
8
|
+
Follow an explicit user or applicable AGENTS.md requirement for an environment or library. Otherwise call `office_python` and run its Python executable with bundled `openpyxl` and `pandas`. Do not install packages or search for a system Python for the default workflow. If the tool reports that Python is not installed, use an already configured environment and report a missing dependency only when it prevents the requested operation.
|
|
9
|
+
|
|
10
|
+
Keep scripts, working files, and outputs in the task workspace. The runtime is a shared read-only resource. Save to a new workbook unless the user requests an in-place edit.
|
|
11
|
+
|
|
12
|
+
## Read and modify
|
|
13
|
+
|
|
14
|
+
Use `openpyxl` for existing XLSX workbooks and targeted cell or style changes. Load with `data_only=False` when formulas must survive. Inspect sheet names, the affected cell types, formulas, styles, merged ranges, and referenced ranges before editing. Check the saved file by reopening it, including unchanged content that the request requires preserving.
|
|
15
|
+
|
|
16
|
+
Use pandas for data analysis and transformations. A DataFrame is not the workbook: exporting it over an existing file can lose sheets, formulas, charts, and formatting. Write analysis results back to the intended ranges with openpyxl. `XlsxWriter` can create new workbooks, but cannot read or modify existing ones.
|
|
17
|
+
|
|
18
|
+
For a new workbook, the selected Python environment can write editable values, styles, and formulas directly:
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from openpyxl import Workbook
|
|
22
|
+
from openpyxl.styles import Font
|
|
23
|
+
|
|
24
|
+
workbook = Workbook()
|
|
25
|
+
sheet = workbook.active
|
|
26
|
+
sheet.title = "Revenue"
|
|
27
|
+
for row in [("Quarter", "Revenue"), ("Q1", 12), ("Q2", 18), ("Total", "=SUM(B2:B3)")]:
|
|
28
|
+
sheet.append(row)
|
|
29
|
+
for cell in sheet[1]:
|
|
30
|
+
cell.font = Font(bold=True)
|
|
31
|
+
sheet.column_dimensions["A"].width = 18
|
|
32
|
+
sheet.column_dimensions["B"].width = 18
|
|
33
|
+
workbook.save("report.xlsx")
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Preserve numbers, dates, booleans, and identifiers as the intended cell types; formatting is not a type conversion. For modifications, load the existing file with `openpyxl.load_workbook("input.xlsx", data_only=False)`, change the requested ranges, and save a separate result. Avoid a DataFrame round trip when workbook features must survive.
|
|
37
|
+
|
|
38
|
+
Writing a formula does not calculate its result. openpyxl and XlsxWriter do not evaluate Excel formulas; `data_only=True` returns stored cached values that may be absent or stale. Use `office_recalculate({"path": "report.xlsx", "output": "recalculated.xlsx"})` to save formulas and refreshed cached results to a new workbook. Reopen that result with both `data_only=False` and `data_only=True` to check formulas and calculated values against the requested logic. Recalculation does not validate business logic or guarantee Excel-specific feature compatibility. Without a recalculation engine, state the limit; do not replace requested formulas with constants or report old cached values as newly calculated results.
|
|
39
|
+
|
|
40
|
+
Do not rename `.xls`, `.xlsb`, encrypted files, or macro-enabled files to `.xlsx`. They need an appropriate supported operation. `keep_vba=True` can preserve VBA package content in an XLSM workflow, but does not execute or edit macros and does not guarantee every advanced workbook feature survives. Preserve the original and verify such requirements explicitly.
|
|
41
|
+
|
|
42
|
+
## Check and deliver
|
|
43
|
+
|
|
44
|
+
Call `office_check` with the workbook path:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
office_check({"path": "report.xlsx"})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
It checks ZIP/XML integrity and internal relationships, and reports sheet names, populated-cell counts, and formula counts. `contains` entries check string cells and sheet names, and `count` checks sheet count. `contains` excludes numeric cells and does not validate formula results; verify those separately with openpyxl. The checker does not calculate formulas or judge workbook appearance. Compare relevant values, types, formulas, styles, and totals with the task's source data.
|
|
51
|
+
|
|
52
|
+
For data and formula tasks, deliver after structural and data checks pass. Skip preview rendering and visual inspection, and do not add an unrequested caveat that visual inspection was omitted. Basic styling such as bold headers or number formats does not itself require visual inspection. Formula recalculation is independent of rendering and remains necessary when calculated results must be refreshed.
|
|
53
|
+
|
|
54
|
+
Inspect relevant regions when the task concerns formatting, layout, chart appearance, print layout, or a known display problem. Before generating inspection images, establish that the current model accepts images. If it does not, finish structural and data checks and report the requested visual check as unavailable; do not rasterize unreadable previews, retry reading images, or choose a second model. Export requested images or PDFs even when visual inspection is unnecessary.
|
|
55
|
+
|
|
56
|
+
A successful command or image read does not prove that a preview contains workbook content. For a populated range, a fully transparent or uniformly blank image is a renderer failure, not evidence that the workbook needs fixing. Stop all visual QA for that workbook immediately; do not try a wider range, another sheet, a different DPI, or another output format. Check suspicious previews with the bundled Pillow library, compositing RGBA onto white before comparing pixels. Do not create diagnostic workbooks, repeatedly retry rendering, modify print settings, or convert to PDF solely to investigate a failed preview. Preserve the requested workbook changes, finish structural and data checks, and report the visual check as unavailable. Only change print areas or scaling when the user requests printed layout.
|
|
57
|
+
|
|
58
|
+
## LibreOffice operations
|
|
59
|
+
|
|
60
|
+
Use the `office_*` tools for every LibreOffice operation unless the user explicitly asks not to use them. Without that explicit opt-out, never search for or invoke system LibreOffice, `soffice`, an application-installed binary, or a downloaded replacement. If a tool reports that the engine is not installed or fails, report that failure instead of substituting another executable.
|
|
61
|
+
|
|
62
|
+
When recalculation, a requested export, or visual inspection is needed, `office_recalculate`, `office_convert`, and `office_render` run the engine installed for this machine from the task directory. For worksheet rendering, select an exact sheet name and the relevant cell range:
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
office_render({"path": "report.xlsx", "outputDir": "preview-v1", "sheet": "Summary", "range": "A1:D20", "dpi": 144})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
For a user-requested PDF export, use `office_convert({"path": "report.xlsx", "output": "report.pdf"})`. PDF conversion is not a fallback for failed visual QA.
|
|
69
|
+
|
|
70
|
+
Use `sheet`/`range` for worksheets, not `pages`. Direct worksheet images cover cell regions; PDF pages follow print settings and are not worksheet numbers. Include chart/drawing regions explicitly. Read the returned image paths and missing-font diagnostics; large regions may split across images. Outputs must be new directories/files. Reuse previews for the same saved workbook and inspect additional regions only when needed. Check widths, formats, clipping, and charts; set print areas/scaling when printed layout is requested. Render each relevant region once. Rerender only after requested source changes; an empty or failed preview ends visual checking for the whole workbook.
|
|
71
|
+
|
|
72
|
+
If required rendering is unavailable or fails, preserve the usable workbook and report the inspection or export limit. Do not search for COM automation, install conversion packages, or build another renderer for routine QA. Preview rendering does not refresh the original workbook's formula caches or certify native Excel appearance. Deliver once the requested data and applicable checks pass.
|
|
73
|
+
|
|
74
|
+
Give the user the actual final workbook path in the workspace. Keep that file in place, and omit intermediate scripts and reports unless requested.
|
package/ui/ui.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api/ui"];if(!p)throw new Error("This plugin needs a newer Ycodium app. Update the app.");var{PLUGIN_UI_BRIDGE_VERSION:_,PLUGIN_UI_FLOATING_VIEW_PROP:R,PLUGIN_UI_GLOBAL_KEY:P,PLUGIN_UI_HOST_CAPABILITIES:w,PLUGIN_UI_HOST_COMMAND_PALETTE_UNAVAILABLE_MESSAGE:E,PLUGIN_UI_HOST_UPGRADE_MESSAGE:x,pluginUiHostHasCapability:c}=p;var y=/^- page (\S+): (.+?)(?: \((\d+)x(\d+)\))?$/u,f=/^Missing fonts \(substituted\): (.+)\.$/u,m=a=>{let e=[],s=null,d=[];for(let i of a.split(/\r?\n/u)){let t=y.exec(i);if(t!==null){e.push({page:t[1],path:t[2],width:t[3]===void 0?null:Number(t[3]),height:t[4]===void 0?null:Number(t[4])});continue}i.startsWith("Warning:")&&(s=i);let n=f.exec(i);n!==null&&(d=n[1].split(", "))}return{pages:e,warning:s,missingFonts:d}};var I="render-result";function h(a){let e=a.react.createElement,s=c(a,"workspaceFileUrl");function d(n){let o=a.i18n.usePluginTranslation(),l=a.useWorkspaceFileUrl({environmentId:n.environmentId,threadId:n.threadId,path:n.page.path}),r=o("card.page",{page:n.page.page});return e("figure",{style:{margin:0,display:"flex",flexDirection:"column",gap:4,width:168}},l.status==="ready"?e("img",{src:l.url,alt:r,loading:"lazy",style:{width:"100%",height:"auto",border:"1px solid var(--border)",borderRadius:6,background:"#fff"}}):e("div",{style:{height:120,display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed var(--border)",borderRadius:6,fontSize:12,color:"var(--muted-foreground)"}},l.status==="failed"?o("card.imageUnavailable"):o("card.loading")),e("figcaption",{style:{fontSize:12,color:"var(--muted-foreground)"}},r))}function i(n){return e("pre",{style:{margin:0,padding:8,whiteSpace:"pre-wrap",wordBreak:"break-word",fontSize:12}},n.text)}function t(n){let o=a.i18n.usePluginTranslation(),l=n.details.output?.text??"",r=m(l),u=n.threadRef?.threadId;return!s||u===void 0||n.entry.displayFailed||r.pages.length===0?e(i,{text:l}):e("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:8}},r.warning===null?null:e("p",{role:"status",style:{margin:0,fontSize:12,color:"var(--destructive)"}},o("card.noCjkFont")),e("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},...r.pages.map(g=>e(d,{key:g.path,environmentId:n.environmentId,threadId:u,page:g}))),r.missingFonts.length===0?null:e("p",{style:{margin:0,fontSize:12,color:"var(--muted-foreground)"}},o("card.missingFonts",{fonts:r.missingFonts.join(", ")})))}return{pages:{},panels:{},views:{[I]:t}}}export{I as RENDER_RESULT_VIEW,h as default};
|