Skip to content

Commit 72f2b02

Browse files
authored
feat(weread-official): add official gateway CLI
Add the WeRead official Agent Gateway as an in-tree pure HTTP adapter with 8 commands, typed errors, tests, and docs.
1 parent 261b8bf commit 72f2b02

14 files changed

Lines changed: 2397 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Features
6+
7+
* **weread-official** — integrate WeRead's official Agent Gateway as the `weread-official` CLI namespace. Pure HTTP, Bearer auth via `WEREAD_API_KEY` (no browser, no cookies). 8 commands cover the official skill bundle: `search`, `shelf`, `book` (info + chapters + progress 3-in-1), `notes` (notebook overview or per-book highlights/thoughts), `review`, `readdata` (weekly/monthly/annually/overall), `discover` (recommend or similar-book), `list-apis`. Adapter surfaces typed errors for all documented failure modes — `AuthRequiredError` on missing/rejected key (errcodes -2010/-2012), `CommandExecutionError` on HTTP/`upgrade_info`/non-zero errcode, `EmptyResultError` on empty payloads. Coexists with the existing cookie-based `weread` adapter.
8+
59
### Bug Fixes
610

711
* **adapters** — surface the remaining `silent-empty-fallback` adapter failures as typed errors. Douyin user video comment fetch failures, Jike SSR JSON parse failures, and WeRead search-page fetch failures now throw `CommandExecutionError`; true empty Douyin/Jike/WeRead result sets now throw `EmptyResultError`.

cli-manifest.json

Lines changed: 373 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25483,6 +25483,379 @@
2548325483
"sourceFile": "weread/shelf.js",
2548425484
"navigateBefore": "https://weread.qq.com"
2548525485
},
25486+
{
25487+
"site": "weread-official",
25488+
"name": "book",
25489+
"description": "Show WeRead book metadata, chapters, and reading progress",
25490+
"access": "read",
25491+
"domain": "weread.qq.com",
25492+
"strategy": "public",
25493+
"browser": false,
25494+
"args": [
25495+
{
25496+
"name": "bookId",
25497+
"type": "str",
25498+
"required": true,
25499+
"positional": true,
25500+
"help": "WeRead bookId (from `weread-official search`)"
25501+
},
25502+
{
25503+
"name": "no-chapters",
25504+
"type": "boolean",
25505+
"default": false,
25506+
"required": false,
25507+
"help": "Skip /book/chapterinfo call"
25508+
},
25509+
{
25510+
"name": "no-progress",
25511+
"type": "boolean",
25512+
"default": false,
25513+
"required": false,
25514+
"help": "Skip /book/getprogress call"
25515+
}
25516+
],
25517+
"columns": [
25518+
"section",
25519+
"idx",
25520+
"key",
25521+
"value",
25522+
"link"
25523+
],
25524+
"type": "js",
25525+
"modulePath": "weread-official/book.js",
25526+
"sourceFile": "weread-official/book.js"
25527+
},
25528+
{
25529+
"site": "weread-official",
25530+
"name": "discover",
25531+
"description": "Personalized or similar-book recommendations from WeRead",
25532+
"access": "read",
25533+
"domain": "weread.qq.com",
25534+
"strategy": "public",
25535+
"browser": false,
25536+
"args": [
25537+
{
25538+
"name": "bookId",
25539+
"type": "str",
25540+
"required": false,
25541+
"positional": true,
25542+
"help": "Anchor bookId for similar-book mode; omit for personalized recommendations"
25543+
},
25544+
{
25545+
"name": "count",
25546+
"type": "int",
25547+
"default": 12,
25548+
"required": false,
25549+
"help": "Page size (default 12)"
25550+
},
25551+
{
25552+
"name": "max-idx",
25553+
"type": "int",
25554+
"default": 0,
25555+
"required": false,
25556+
"help": "Pagination cursor (recommend: previous searchIdx; similar: previous idx)"
25557+
},
25558+
{
25559+
"name": "session-id",
25560+
"type": "str",
25561+
"required": false,
25562+
"help": "Carry-forward sessionId for /book/similar paging"
25563+
}
25564+
],
25565+
"columns": [
25566+
"rank",
25567+
"mode",
25568+
"bookId",
25569+
"title",
25570+
"author",
25571+
"rating",
25572+
"readingCount",
25573+
"category",
25574+
"idx",
25575+
"reason",
25576+
"cover",
25577+
"intro",
25578+
"link"
25579+
],
25580+
"type": "js",
25581+
"modulePath": "weread-official/discover.js",
25582+
"sourceFile": "weread-official/discover.js"
25583+
},
25584+
{
25585+
"site": "weread-official",
25586+
"name": "list-apis",
25587+
"description": "List every api_name supported by the WeRead agent gateway",
25588+
"access": "read",
25589+
"domain": "weread.qq.com",
25590+
"strategy": "public",
25591+
"browser": false,
25592+
"args": [],
25593+
"columns": [
25594+
"rank",
25595+
"apiName",
25596+
"description",
25597+
"required",
25598+
"optional",
25599+
"extras"
25600+
],
25601+
"type": "js",
25602+
"modulePath": "weread-official/list-apis.js",
25603+
"sourceFile": "weread-official/list-apis.js"
25604+
},
25605+
{
25606+
"site": "weread-official",
25607+
"name": "notes",
25608+
"description": "List notebooks overview or merged highlights+thoughts for a book",
25609+
"access": "read",
25610+
"domain": "weread.qq.com",
25611+
"strategy": "public",
25612+
"browser": false,
25613+
"args": [
25614+
{
25615+
"name": "bookId",
25616+
"type": "str",
25617+
"required": false,
25618+
"positional": true,
25619+
"help": "Limit to one book; omit for full notebook overview"
25620+
},
25621+
{
25622+
"name": "count",
25623+
"type": "int",
25624+
"default": 20,
25625+
"required": false,
25626+
"help": "Page size for the notebooks overview (1-100)"
25627+
},
25628+
{
25629+
"name": "last-sort",
25630+
"type": "int",
25631+
"required": false,
25632+
"help": "Cursor: pass previous page sort value to fetch the next page (/user/notebooks)"
25633+
}
25634+
],
25635+
"columns": [
25636+
"kind",
25637+
"bookId",
25638+
"title",
25639+
"author",
25640+
"chapter",
25641+
"reviewCount",
25642+
"noteCount",
25643+
"bookmarkCount",
25644+
"totalNotes",
25645+
"progress",
25646+
"finished",
25647+
"sort",
25648+
"range",
25649+
"text",
25650+
"thought",
25651+
"star",
25652+
"createTime",
25653+
"link"
25654+
],
25655+
"type": "js",
25656+
"modulePath": "weread-official/notes.js",
25657+
"sourceFile": "weread-official/notes.js"
25658+
},
25659+
{
25660+
"site": "weread-official",
25661+
"name": "readdata",
25662+
"description": "Reading statistics: time, streak, preferences, top books",
25663+
"access": "read",
25664+
"domain": "weread.qq.com",
25665+
"strategy": "public",
25666+
"browser": false,
25667+
"args": [
25668+
{
25669+
"name": "mode",
25670+
"type": "str",
25671+
"default": "monthly",
25672+
"required": false,
25673+
"help": "Stat window: weekly / monthly / annually / overall",
25674+
"choices": [
25675+
"weekly",
25676+
"monthly",
25677+
"annually",
25678+
"overall"
25679+
]
25680+
},
25681+
{
25682+
"name": "base-time",
25683+
"type": "int",
25684+
"required": false,
25685+
"help": "Optional Unix timestamp inside the target period; default is current period"
25686+
}
25687+
],
25688+
"columns": [
25689+
"section",
25690+
"idx",
25691+
"key",
25692+
"value",
25693+
"detail"
25694+
],
25695+
"type": "js",
25696+
"modulePath": "weread-official/readdata.js",
25697+
"sourceFile": "weread-official/readdata.js"
25698+
},
25699+
{
25700+
"site": "weread-official",
25701+
"name": "review",
25702+
"description": "Browse public reviews of a WeRead book",
25703+
"access": "read",
25704+
"domain": "weread.qq.com",
25705+
"strategy": "public",
25706+
"browser": false,
25707+
"args": [
25708+
{
25709+
"name": "bookId",
25710+
"type": "str",
25711+
"required": true,
25712+
"positional": true,
25713+
"help": "WeRead bookId (from `weread-official search`)"
25714+
},
25715+
{
25716+
"name": "type",
25717+
"type": "str",
25718+
"default": "all",
25719+
"required": false,
25720+
"help": "Review filter (all/recommend/thumbs-down/newest/neutral)",
25721+
"choices": [
25722+
"all",
25723+
"recommend",
25724+
"thumbs-down",
25725+
"newest",
25726+
"neutral"
25727+
]
25728+
},
25729+
{
25730+
"name": "count",
25731+
"type": "int",
25732+
"default": 20,
25733+
"required": false,
25734+
"help": "Page size (1-100, default 20)"
25735+
},
25736+
{
25737+
"name": "max-idx",
25738+
"type": "int",
25739+
"default": 0,
25740+
"required": false,
25741+
"help": "Pagination cursor — pass idx from last row of previous page"
25742+
},
25743+
{
25744+
"name": "synckey",
25745+
"type": "int",
25746+
"required": false,
25747+
"help": "Sync cursor returned by previous response"
25748+
}
25749+
],
25750+
"columns": [
25751+
"rank",
25752+
"idx",
25753+
"reviewId",
25754+
"star",
25755+
"starLabel",
25756+
"author",
25757+
"isFinish",
25758+
"chapter",
25759+
"content",
25760+
"createTime",
25761+
"link"
25762+
],
25763+
"type": "js",
25764+
"modulePath": "weread-official/review.js",
25765+
"sourceFile": "weread-official/review.js"
25766+
},
25767+
{
25768+
"site": "weread-official",
25769+
"name": "search",
25770+
"description": "Search WeRead store via the official agent gateway",
25771+
"access": "read",
25772+
"domain": "weread.qq.com",
25773+
"strategy": "public",
25774+
"browser": false,
25775+
"args": [
25776+
{
25777+
"name": "keyword",
25778+
"type": "str",
25779+
"required": true,
25780+
"positional": true,
25781+
"help": "Search keyword"
25782+
},
25783+
{
25784+
"name": "scope",
25785+
"type": "str",
25786+
"default": "ebook",
25787+
"required": false,
25788+
"help": "Search type (all/ebook/webnovel/audio/author/fulltext/booklist/mp/article)",
25789+
"choices": [
25790+
"all",
25791+
"ebook",
25792+
"webnovel",
25793+
"audio",
25794+
"author",
25795+
"fulltext",
25796+
"booklist",
25797+
"mp",
25798+
"article"
25799+
]
25800+
},
25801+
{
25802+
"name": "count",
25803+
"type": "int",
25804+
"required": false,
25805+
"help": "Page size (gateway default 15 when omitted)"
25806+
},
25807+
{
25808+
"name": "max-idx",
25809+
"type": "int",
25810+
"default": 0,
25811+
"required": false,
25812+
"help": "Pagination offset, use searchIdx of last item from previous page"
25813+
}
25814+
],
25815+
"columns": [
25816+
"rank",
25817+
"scope",
25818+
"bookId",
25819+
"title",
25820+
"author",
25821+
"rating",
25822+
"readingCount",
25823+
"category",
25824+
"searchIdx",
25825+
"cover",
25826+
"intro",
25827+
"link"
25828+
],
25829+
"type": "js",
25830+
"modulePath": "weread-official/search.js",
25831+
"sourceFile": "weread-official/search.js"
25832+
},
25833+
{
25834+
"site": "weread-official",
25835+
"name": "shelf",
25836+
"description": "Sync your WeRead shelf (books + albums + article bookmark entry) via the official gateway",
25837+
"access": "read",
25838+
"domain": "weread.qq.com",
25839+
"strategy": "public",
25840+
"browser": false,
25841+
"args": [],
25842+
"columns": [
25843+
"kind",
25844+
"id",
25845+
"title",
25846+
"author",
25847+
"category",
25848+
"secret",
25849+
"isTop",
25850+
"finished",
25851+
"updateTime",
25852+
"cover",
25853+
"link"
25854+
],
25855+
"type": "js",
25856+
"modulePath": "weread-official/shelf.js",
25857+
"sourceFile": "weread-official/shelf.js"
25858+
},
2548625859
{
2548725860
"site": "wikidata",
2548825861
"name": "entity",

0 commit comments

Comments
 (0)