feat: 支持 Claude 对话导出与保守批量同步 - #2
Open
pmwl0128 wants to merge 3 commits into
Open
Conversation
把「隐式假设 ChatGPT 数据模型」的代码重构成「站点适配器 + 中间表示」, 再在其上实装 claude.ai 适配器。 架构 - core/ir.ts 站点无关的中间表示(IRConversation / IRTurn / IRBlock) - core/render.ts IR → Markdown,两站点 × 油猴端/离线 CLI 四条路径共用 - core/fetcher.ts 限速 / 退避 / 并发池 / 取消 / 限流观测,每站点独立实例 - sites/types.ts SiteAdapter 契约:取数 + 转换 + 界面锚点 + 批量能力 - main.ts / ui.ts 不再认识任何一家的端点、字段与 DOM 重构以「现有 102 个测试断言一字不改地通过」为验收标准,行为逐字节等价; convert/markdown.ts 与 api.ts 退化为兼容壳,离线 CLI 无需改动。 Claude 侧 - 主线沿 current_leaf_message_uuid 的 parent 链回溯(与 mapping 树同构) - 块级分发:一条消息里 text / thinking / tool_use / tool_result 按序交错 - artifact 折叠 create/update/rewrite 还原终稿;update 用函数替换器, 避免 new_str 里的 $& 等被当作替换模式静默损坏内容 - 附件两处来源:files[] 下载,attachments[].extracted_content 内联进 展开的 callout(导出的笔记因此对全文检索自包含,ChatGPT 侧做不到) - 未识别块与重放失败一律原始 JSON 折叠兜底,不静默丢内容 - 过期的搜索结果不写进笔记:死链比没有链接更糟⚠️ 首版刻意只开放「导出当前对话」 批量的地基(分页器、水位线、并发池、保护性中止)已就位并单测,但 supportsBatch: false 关着——Claude 的限流画像没有任何实测数据,调研过的 三个开源 claude.ai 导出器也无一实现 429 退避(最激进的是 3 并发 + 固定 200ms 且不看 429),没有可借鉴的安全参数。起步节奏取 ChatGPT 的两倍慢 (间距 1500ms、每 40 请求歇 30s),吃到 429 时完成文案会报出次数、被推大的 间距与服务端要求的最长等待。 docs/claude-adapter-feasibility.md 是决策依据,docs/claude-probe.js 可贴进 控制台做结构与限流探测(≤8 请求、遇 429 立即停止、不打印对话内容)。 测试 132 通过(新增 30),typecheck 干净,构建产物 121 kB。
pmwl0128
force-pushed
the
feat/claude-adapter
branch
from
August 29, 2026 07:26
6458b73 to
7315862
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
为 Inkstone 增加完整的 Claude 站点适配,并把原先隐含 ChatGPT 数据模型的转换/取数逻辑拆成站点适配器 + 通用 IR。Claude 现在支持当前、选择、全部和增量导出,同时采用独立且更保守的批量风控策略。
分支已 rebase 到
v0.4.1,并把上游新增的 ChatGPT Projects、多来源归并和来源筛选能力接入新的适配器契约。主要改动
core/ir、core/render、core/fetcher与SiteAdapter契约。BatchPolicy:Claude 固定单并发,不做整批失败项二次重试,并对 429、Retry-After、请求预算和失败率做保护性熔断。/new首页的输入框/顶栏两种位置;重点色使用接近 Claude 图标的#D97757。Claude 批量风控
Retry-After的 429、累计 3 次 429、1000 次 HTTP 尝试,或异常失败率会保护性中止验证
bun test:164 pass / 0 failbun run typecheckbun run build/new首页的浮窗显示、两种按钮位置及 Claude 橙色重点色已知边界
Sources;字符级行内锚定仍需更多真实数据确认。