Repository navigation
v1.0.2(release)
v1.0.2
This release adds first-class Word and Excel support: read bound Office files, create new documents, and edit existing ones — all locally in the side panel, with no backend and no conversion service.
Full diff: v1.0.1...v1.0.2 · Changelog: CHANGELOG.md
Highlights
- Read Office documents —
read_office_outlineandread_office_contentparse bound.docx,.xlsx,.docand.xlsfiles with paged output. - Create Word and Excel files —
create_docxrenders Markdown,create_xlsxbuilds multi-sheet workbooks. - Edit bound documents in place —
edit_docxandedit_xlsxchange text, paragraphs, table cells, cell values and rows while preserving the rest of the package. - Paged plain-text reads —
read_filenow returns one bounded byte window per call instead of silently truncating large files. - One-step undo — overwritten files keep an in-memory snapshot that can be restored from the tool or the file preview dialog.
Office reading
- New
packages/office-parser: a pureUint8Arrayparser with nochrome.*, DOM or Node dependencies. - Word (
.docx): Markdown rendering plus heading outline; read by outline section or character offset. - Excel (
.xlsx,.xls): workbook/sheet discovery and A1-range paging via SheetJS. - Legacy
.doc: Word 97 piece-table extraction and Word 6/95 legacy code-page support. - Signature sniffing distinguishes docx/xlsx/doc/xls, detects encrypted files, and rejects PDF, RTF and PPT with clear messages.
- Bounded ZIP extraction with entry-count, per-entry, total-size and compression-ratio limits. Caps:
.docx≤ 25 MB (word/document.xml≤ 20 MB),.xlsx/.xls≤ 10 MB. read_office_outlineandread_office_contentreturn capped results withnextOffsetornextRange, so the model never receives a whole workbook or document.read_filenow diverts Office, PDF, RTF and ZIP signatures to the Office tools instead of decoding them as text;list_bound_filesmarks entries with their kind and format.write_fileremains text-only.- Parsed files are cached in memory (LRU + single-flight, keyed by session, name, size and mtime) and never persisted.
- Office tool results get a 24k context envelope in
agent-core, while the tools still truncate semantically first. - SheetJS is pinned to 0.20.3 from the official CDN tarball (npm 0.18.5 is affected by CVE-2023-30533 / CVE-2024-22363) and lazy-loaded into its own chunk.
File reading improvements
- Paged
read_file— newoffset/max_charsarguments (default 8k, hard cap 12k) plusnextOffset; only the requested byte range is read throughBlob.slice. - Incomplete UTF-8 tails are trimmed and pages are cut by code points, so multi-byte characters and emoji reassemble exactly across pages.
- Offsets are clamped and the tool reports the byte range and end-of-file state.
- Oversized ZIPs are rejected from the 8-byte signature prefix before the archive is loaded into memory, avoiding a pointless full read for files that can never be parsed.
Office writing and editing
create_docx— headings, paragraphs, nested bullet/ordered lists, GFM tables, fenced code blocks, and inline bold/italic/code/links. Saved to Downloads.create_xlsx— multiple sheets, string/number/boolean cells, formulas starting with=, automatic column widths, and sheet-name sanitization/deduplication.edit_docx—replace_text(single_run/paragraph),append_paragraph,insert_paragraph_after,delete_paragraph, andset_table_cell.edit_xlsx— A1 cell writes and row appends; validates merged-cell anchors and shared formulas, expands the sheet dimension, marks formulas for recalculation, and removescalcChainto avoid stale results.- Editing performs OOXML surgery: only
word/document.xmlor the target sheet XML is replaced, and every other ZIP entry is copied byte-for-byte. Images, charts, headers, footers, pivot tables and macros are preserved. - Save-as or overwrite — edit confirmations offer both choices. Overwrites always require confirmation, even when global auto-run is enabled.
- Write permission on demand —
readwriteaccess is requested inside the confirmation click, with retry guidance when the prompt is not completed and clear messages when the file handle has expired. - Overwrites abort if the file changed externally after it was read; failed writes do not leave a partially written file.
undo_document_editand a matching "Undo last edit" action in the file preview restore the previous content of an overwritten file.
Reliability and UI
- Wide Markdown tables now stay inside the message column and scroll horizontally, and replies containing tables get the full panel width.
- New confirmation contract fields —
alwaysConfirm,confirmationChoices,requiresFileWritePermission— let tools require explicit approval and return the user's chosen save mode. - New Chinese and English copy for Office creation, editing, write permission and undo flows.
Notes and limitations
.docand.xlsremain read-only. They are not converted automatically; save a modern copy in Word or WPS first.- Office editing targets content correctness, not formatting fidelity. New paragraphs use default styling, and paragraph-level replacement may collapse run-level formatting.
- Undo is in-memory and limited to one overwrite per file. It is lost when the side panel closes.
- Charts, images, pivot tables and macros are preserved during editing but cannot be created or modified by these tools.
- Opening an existing
.docm/.xlsmfor editing keepsvbaProject.binintact. - The Office structure/content preview branch is still pending; the preview currently shows text files and exposes the undo action.
v1.0.2
本次发布加入完整的 Word 与 Excel 支持:读取已绑定的 Office 文件、生成新文档、原地编辑现有文档——全部在侧边栏本地完成,无后端、无转换服务。
完整差异: v1.0.1...v1.0.2 · 变更记录: CHANGELOG.md
亮点
- 读取 Office 文档 ——
read_office_outline与read_office_content解析已绑定的.docx、.xlsx、.doc、.xls,结果分页返回。 - 生成 Word / Excel ——
create_docx渲染 Markdown,create_xlsx生成多工作表工作簿。 - 原地编辑已绑定文档 ——
edit_docx与edit_xlsx修改文字、段落、表格单元格、单元格值与行,同时保留包内其他内容。 - 纯文本分页读取 ——
read_file改为每次返回一个有界字节窗口,不再静默截断大文件。 - 一步撤销 —— 覆盖文件时保留内存快照,可通过工具或文件预览对话框恢复。
Office 读取
- 新增
packages/office-parser:纯Uint8Array解析器,不依赖chrome.*、DOM 或 Node API。 - Word(
.docx):Markdown 渲染与标题大纲;支持按大纲章节或字符偏移读取。 - Excel(
.xlsx、.xls):基于 SheetJS 的工作表发现与 A1 区域分页。 - 旧版
.doc:支持 Word 97 piece table 提取与 Word 6/95 旧代码页。 - 文件头识别区分 docx/xlsx/doc/xls,检测加密文件,并对 PDF、RTF、PPT 给出明确拒绝提示。
- 有界 ZIP 解包,限制条目数、单条大小、总大小与压缩比。上限:
.docx≤ 25 MB(word/document.xml≤ 20 MB),.xlsx/.xls≤ 10 MB。 read_office_outline与read_office_content返回带nextOffset或nextRange的分页结果,模型不会一次收到整份文档或工作簿。read_file会把 Office、PDF、RTF、ZIP 签名分流到 Office 工具,不再按文本解码;list_bound_files标记文件的 kind/format。write_file仍只处理纯文本。- 解析结果只缓存在内存(LRU + single-flight,按会话、文件名、大小与 mtime),不落盘。
- Office 工具结果在
agent-core中获得 24k 上下文上限,工具自身仍先做语义截断。 - SheetJS 固定为官方 CDN 的 0.20.3(npm 0.18.5 受 CVE-2023-30533 / CVE-2024-22363 影响),并懒加载到独立 chunk。
文件读取改进
read_file分页 —— 新增offset/max_chars参数(默认 8k,硬上限 12k)与nextOffset;通过Blob.slice只读取请求的字节范围。- 自动裁掉不完整 UTF-8 尾部,并按码点切分,多字节字符与 emoji 可跨页精确拼接。
- 偏移量会被收敛,工具消息会报告字节范围与文件结尾状态。
- 超大 ZIP 在读取 8 字节签名后直接拒绝,不再把永远无法解析的压缩包整体读入内存。
Office 写入与编辑
create_docx—— 标题、段落、嵌套有序/无序列表、GFM 表格、代码块,以及行内加粗/斜体/代码/链接;保存到下载目录。create_xlsx—— 多工作表、字符串/数字/布尔单元格、以=开头的公式、自动列宽,以及工作表名清洗与去重。edit_docx——replace_text(single_run/paragraph)、append_paragraph、insert_paragraph_after、delete_paragraph、set_table_cell。edit_xlsx—— A1 单元格写入与追加行;校验合并单元格锚点与共享公式,扩展工作表 dimension,标记公式重算,并移除calcChain以避免旧缓存结果。- 编辑采用 OOXML 外科手术:只替换
word/document.xml或目标工作表 XML,其余 ZIP 条目按字节原样复制。图片、图表、页眉页脚、透视表与宏均保留。 - 另存或覆盖 —— 编辑确认条提供两种选择;即使开启全局自动执行,覆盖仍必须确认。
- 按需申请写权限 —— 在确认点击内申请
readwrite;授权未完成时提示重试,句柄失效时给出明确提示。 - 读取后文件被外部修改时中止覆盖;写入失败不会留下半截文件。
undo_document_edit与文件预览中的「撤销上次编辑」可恢复被覆盖文件的上一版内容。
可靠性与界面
- 宽 Markdown 表格保持在消息列内并横向滚动,含表格的回复气泡获得面板全宽。
- 确认协议新增
alwaysConfirm、confirmationChoices、requiresFileWritePermission,支持工具强制确认并回传用户选择的保存方式。 - 补齐 Office 生成、编辑、写权限与撤销流程的中英文案。
说明与限制
.doc/.xls仍只读,不做自动转换;请先在 Word 或 WPS 中另存为现代格式。- Office 编辑保证内容正确,不追求版式还原。新增段落使用默认样式,段落级替换可能合并原有 run 格式。
- 撤销仅保存在内存中,每个文件只保留一步;关闭侧边栏后失效。
- 图表、图片、透视表和宏在编辑时原样保留,但这些工具不能新建或修改它们。
- 编辑
.docm/.xlsm时会保留vbaProject.bin。 - Office 结构/内容预览分支尚未落地;当前预览仍主要用于文本文件,并提供撤销入口。