Skip to content

[codex] Support WPS document attachments#979

Merged
ErlichLiu merged 3 commits into
mainfrom
ErlichLiu/wps-doc-pdf-chat
Jun 28, 2026
Merged

[codex] Support WPS document attachments#979
ErlichLiu merged 3 commits into
mainfrom
ErlichLiu/wps-doc-pdf-chat

Conversation

@ErlichLiu

Copy link
Copy Markdown
Collaborator

Summary

  • extend Chat attachment file filters and MIME mapping for WPS, Office template, macro-enabled, slideshow, and RTF formats
  • route WPS/legacy Writer formats through the document parser and add WPS spreadsheet/presentation error guidance
  • improve document extraction by using mammoth for DOCX-style files and pdfjs-dist as a PDF text fallback when pdf-parse returns empty or fails

Root Cause

Chat mode already enriches non-image attachments by extracting text before sending the prompt, but the attachment picker and document parser only covered a narrower Office/PDF set. WPS-specific extensions could be excluded or fall into weak fallback paths, and WPS-exported PDFs could fail when pdf-parse produced no text.

Validation

  • bun test apps/electron/src/main/lib/document-parser.test.ts
  • bun run --cwd apps/electron typecheck
  • bun run --cwd apps/electron build:main
@ErlichLiu ErlichLiu marked this pull request as ready for review June 27, 2026 16:13
ErlichLiu and others added 2 commits June 28, 2026 12:25
- route OOXML macro/template variants (.xlsm/.pptm/.ppsx etc.) through
  officeparser via Buffer so it sniffs by content instead of failing the
  extension whitelist
- parse RTF with a built-in brace-aware extractor instead of handing it to
  officeparser (which never supported RTF) — no new dependency
- replace the extension-lookup-only test with real extractTextFromFile
  calls over generated OOXML/RTF fixtures

Co-Authored-By: Claude <noreply@anthropic.com>
The skip-state was modeled as a counting stack, so a destination that is
both \*-marked AND a known skip destination (e.g. {\*\generator ...},
present in virtually every Word/WordPad RTF) got pushed twice but popped
once — leaking a skip entry that suppressed all following body text. The
feature returned empty and threw on the most common RTF inputs.

- model skip state as a single skipDepth (group level), set once and
  cleared when that group closes — no double-marking possible
- honor \ucN fallback-char count (was hardcoded to 1)
- add regression tests with {\*\generator} and {\*\listtable}/\info
  groups that fail without this fix
- declare jszip as a devDependency (test fixture builder; was only
  resolving via mammoth's transitive hoist)

Co-Authored-By: Claude <noreply@anthropic.com>
@ErlichLiu ErlichLiu merged commit 0115e1e into main Jun 28, 2026
Yuan-lai-ru-ci pushed a commit to Yuan-lai-ru-ci/Profer that referenced this pull request Jul 10, 2026
本次提交合并了两部分内容(工作树原有大量未提交改动,文件交织无法干净拆分):

一、之前会话的在途工作(计费/代管/团队协作等,非本次新增)
- server: relay 令牌链路、credits 预扣/结算/退款、pricing-cache、
  billing/proxy-usage/request-log utils + 测试、admin pricing/activation-codes
- 客户端: 402 额度不足充值引导、侧栏余额条、凭证口径统一等

二、本次从 Proma 上游移植的 changelog 功能
- proma-ai#988-994 session-core 包 + proma CLI + session-cleaner skill
  - 新增 packages/session-core/(解析/分组/转录/渲染/渐进式读取,12 测试过)
  - 新增 apps/cli/(proma session info/outline/search/export/list)
  - 新增 apps/electron/scripts/build-cli.ts(bun --compile 自包含二进制)
  - electron package.json 加 @proma/session-core 依赖 + build:cli 入三条 build 链
  - electron-builder.yml extraResources 加 resources/bin → bin
  - config-paths.ts 加 getBundledCliPath()
  - agent-orchestrator.ts sdkEnv 注入 PROMA_CLI
- proma-ai#979 WPS/Office 附件解析
  - document-parser.ts 支持 OOXML 宏/模板格式 + 内建 RTF 提取器(9 测试过)
  - attachment-service.ts 扩充 mime 类型与可解析扩展名

注: server-rel.tar.gz 发布产物已加入 .gitignore,不入库。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant