feat(linux-do): refactor adapters with unified feed, tags, user commands#434
Conversation
- Replace hot/latest/category with unified `feed` command (tag/category/view routing) - Add `tags`, `user-topics`, `user-posts` commands - Add static data files for categories and tags lookup - Fix error handling: use CliError subclasses instead of raw Error - Fix Discourse API field mapping in search (tags, created) - Add strategy: cookie to all YAML adapters - Update docs and README command listings - Update E2E tests for new command signatures Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for the effort consolidating the linux-do adapters! Found a few issues during review: Critical1. Tag URL construction is broken
2. The 3.
Warnings4. "Replies" count semantic regression Old adapters used 5. 4,300 lines of hardcoded static data is unnecessary
The right approach is to resolve tag/category slugs at runtime via the Discourse API. This eliminates both data files and simplifies 6. Breaking changes without migration path
|
|
One more design concern: The refactor adds complexity without clear benefitThe original The refactored version replaces them with: This trades three obvious commands for one overloaded command that requires users to learn The only justification for merging would be significant shared logic, but the original YAMLs had almost no duplication. After merging, |
|
感谢回复!跟进几点: 关于 tag URL — Discourse 标准 tag 路由是 关于静态数据 — "tag 基本不会变"和这个 PR 本身包含一个 对于 AI 调用场景,运行时调一次 API 把 tag 名解析为 slug,比维护一个 4000 行的静态文件更简单可靠。 关于整体规模 — 仓库中现有的适配器大多都在 1000 行代码以内(除 twitter / xiaohongshu / douyin / boss / youtube 等热门站点外),这个 PR 为单个站点引入了近 5000 行代码(其中 87% 是静态数据)。之前的 其余问题尚未回应:
|
关于 tag URL
关于静态数据tag部分tag去掉静态数据倒是没什么。 分类部分但是分类有个二级分类,第一次获取分类列表之后,只得到了子分类(例如
没有走查询接口就得不到 分类slug ,这样就无法按二级分类查询。走 这个不知道怎么处理好 其余问题
|
|
感谢详细回复!逐条回应: Tag URL — 理解了,无痕浏览器测试通过,没问题。 静态数据 — tag 部分同意去掉静态数据,分类的二级查询确实需要多步 API 调用,理解这个痛点。但硬编码 365 行 .ts 文件不是最优解,建议用运行时本地缓存: 首次运行 三个 bug — 期待推送修复后再看。 关于命令结构 — 项目中所有适配器都用扁平命令命名: |


feedcommand (tag/category/view routing)tags,user-topics,user-postscommandsDescription
Refactor all linux-do (Discourse) adapters: consolidate commands, fix API issues, and add new capabilities.
Related issue:
Type of Change
Changes
New commands:
feed— unified topic listing replacinghot/latest/category(supports--view,--tag,--categoryfiltering)tags— list popular tagsuser-topics— topics created by a useruser-posts— replies posted by a userBug fixes:
/tag/{id}-tag/{id}instead of incorrect/tags/{id}-slug/{id})search.yamlreferencing non-existent Discourse search API fields (views,likes)search.yamltags showing[object Object](Discourse returns tag objects, notstrings)
throw new ErrorwithArgumentError/CommandExecutionError/AuthRequiredErrorstrategy: cookieto all 6 YAML adaptersStatic data:
categories.data.ts— 50 categories with id/name/slug/parentCategoryIdtags.data.ts— full tag dataset for offline name/slug/id resolutionDocs & tests:
docs/adapters/browser/linux-do.mdwith complete usage examplesREADME.md,README.zh-CN.md,docs/adapters/index.mdbrowser-auth.test.ts(7 tests covering all 7 commands)Checklist
Documentation (if adding/modifying an adapter)
docs/adapters/(if new adapter)docs/adapters/index.mdtable (if new adapter)docs/.vitepress/config.mts(if new adapter)README.md/README.zh-CN.mdwhen command discoverability changedCliErrorsubclasses instead of rawError