feat: 大文本文件 lazy loading + 24h 文件缓存 - #237
Conversation
- 抽取 src/feishu/file-cache.ts: saveMessageFileToCache + cleanupOldDownloads,复用 tmpdir/feishu-downloads - feishu_download_message_file MCP 工具改为复用该 helper - 当前消息文本附件: ≤64KB 内嵌 prompt;>64KB 落盘并注入路径元数据,让 agent 用 Read 工具按需 offset/limit 分段读 - 历史消息文本附件: 同样小文件内嵌、大文件落盘 - 文本文件上限从 1MB 提升到 30MB(与 PDF 一致) - index.ts 周期 cleanup 接入 24h 过期清理 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- saveMessageFileToCache 路径/扩展名 sanitize - cleanupOldDownloads 24h 过期清理 + 缺失目录 no-op - 历史文本附件 ≤64KB 内嵌、>64KB 落盘注入 Read 提示 - 30MB 硬上限丢弃 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 2m 12s —— View job
|
- 移除未使用的 writeFileSync import - 字符类中的 / 不需要转义 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Reviewing PR updates
|
第三处文本附件入口(引用回复父消息的文件)此前仍走 1MB silent-skip 的旧逻辑。现在与直接上传和历史消息路径行为一致:30MB 上限、>64KB 落盘 + 注入 Read 提示。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 1m 9s —— View job ✅ Approved — Previous issue resolved
VerificationPreviously flagged in inline #3253872451: the quoted-parent-message text-file branch in Fix in 39db424 correctly addresses this. Current } else if (isTextFile(fileName)) {
const MAX_TEXT_SIZE = 30 * 1024 * 1024;
const INLINE_THRESHOLD = 64 * 1024;
const buf = await feishuClient.downloadMessageFile(parent.message_id, fileKey);
if (buf.length > MAX_TEXT_SIZE) { … warn … }
else if (buf.length <= INLINE_THRESHOLD) { … inline embed … }
else { … saveMessageFileToCache + lazy-load metadata … }
}Three text-file entries (direct upload The lint fix in fbfe024 is trivial and correct (unused Summary
|
* feat: 新增 feishu_download_message_image MCP 工具 按需下载飞书消息图片,参照 PR #237 的 file-cache 模式,为父群图片 lazy loading 与工作区切换后图片落盘提供按需读取能力。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat: 任务队列透传 currentImagePaths 为工作区切换重启时图片路径注入做准备,让本次消息内已落盘的图片 路径能从 parseMessage 经队列流到 executeClaudeTask。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat: 工作区切换后注入历史图片落盘路径 setup_workspace 触发的 restart query 不重传多模态 images(避免 重复消耗 token),导致之前加载的图片在新工作区上下文中丢失。 修复: - downloadHistoryImages 在下载历史图片时同步将原图落盘到 file-cache - parseMessage 将当前消息图片落盘路径收集到 currentImagePaths - 工作区切换重启时将所有落盘路径以文本提示注入 prompt,agent 可按需通过 Read 工具加载查看 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: 引用图片同步落盘 + 注入 restart 路径 injectQuotedMessage 下载引用消息中的图片时一并 saveMessageFileToCache, 在 executeClaudeTask 调用处把落盘路径合并进 restartImagePaths, 修复 reviewer 指出的:工作区切换 restart 后 quoted parent image 同样 会丢失的问题。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * test: 覆盖 quoted 图片落盘行为 为 96292bc 修复加针对性测试: - 验证下载 quoted 图片后调用 saveMessageFileToCache 并返回 savedImagePath - 验证落盘失败时 images 与 prompt 仍正常返回(落盘是 non-fatal) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>

Summary
tmpdir/feishu-downloads/,prompt 只注入路径元数据,agent 用 Read 工具按需offset/limit分段读src/feishu/file-cache.ts共享 helper,feishu_download_message_fileMCP 工具也复用Test plan
src/__tests__/lazy-text-files.test.ts— file-cache 单测 + 历史文本附件阈值覆盖lazy-history-files.test.ts/message.test.ts全部通过DASHSCOPE_API_KEY,与本 PR 无关)🤖 Generated with Claude Code