Skip to content

feat(kimi): new adapter for kimi.com (21 commands)#1804

Merged
jackwener merged 2 commits into
jackwener:mainfrom
LeoLin990405:feat/kimi-adapter
May 31, 2026
Merged

feat(kimi): new adapter for kimi.com (21 commands)#1804
jackwener merged 2 commits into
jackwener:mainfrom
LeoLin990405:feat/kimi-adapter

Conversation

@LeoLin990405
Copy link
Copy Markdown
Contributor

Summary

Greenfield web adapter for Kimi (Moonshot AI's web chat at kimi.com). Ships 21 commands across 4 layers, mirroring the Grok adapter's structure.

Coverage

Layer Commands
Connectivity status
Chat lifecycle new history detail read send ask
Per-message copy-message regenerate react share
Sidebar / global UI mode sidebar-toggle view-all-history settings account model
Browser-side storage storage-keys storage-get cookies idb-list

Special: mode switches Kimi's 7 work modes

mode ppt|docs|deep-research|websites|sheets|agent-swarm|code — navigates
to Kimi's specialized work surfaces.

E2E verified

  • status → logged in as "登月者"
  • history → 5 chats with proper UUIDs
  • account → "登月者 Allegretto"
  • mode → all 7 modes listed
  • storage-keys → access_token, _tea*, _gcl_ls
  • cookies → 8 JS-visible cookies (httpOnly auth deliberately not shown)
  • idb-list → AiTopia DB
  • model (current) → "K2.6 思考"

Selector strategy

Kimi labels its icons via <svg role="img" name="X"> (Copy/Refresh/Like/Dislike/Share_a/Send/LeftBar/Down_b). The clickBySvgNameScript helper finds the svg, walks up to the nearest clickable ancestor, and dispatches the full pointer chain.

Known limitation

Per-message commands (copy-message / regenerate / react / share)
need the page to be on a chat URL already; follow-up will add --conv <id>
to allow navigation first (mirroring Grok's pattern). Workaround:
opencli browser kimi open <chat-url> first.

Test plan

  • CI passes
  • Verify on a fresh Kimi install (history returns EmptyResult cleanly)
  • Verify mode <name> navigates correctly without auth issues

@LeoLin990405
Copy link
Copy Markdown
Contributor Author

Kimi deep-audit summary (3 commits, 26 commands)

Same deep-audit pass landed in PR #1801 / #1798 / #1799 / #1800 now applied to Kimi.

Final coverage: 26 commands across 4 layers

Layer Commands
Connectivity status
Chat lifecycle new history detail read send ask
Per-message copy-message regenerate react (like/dislike) share
Modes (7 specialized work surfaces) mode (ppt/docs/deep-research/websites/sheets/agent-swarm/code)
Sidebar / global UI sidebar-toggle view-all-history settings account model upgrade sign-out dismiss-banner
Templates / history templates [--mode] history-rename
Browser-side storage storage-keys storage-get cookies idb-list

E2E verified

  • status → logged in as "登月者" with full profile
  • history → 5 chats with proper UUIDs
  • account → "登月者 Allegretto"
  • mode → all 7 modes routable
  • templates --mode deep-research → 4 cards across 3 categories (社科人文/商业财经/科技创新)
  • storage-keys (52 LS keys) / cookies (8 visible) / idb-list (AiTopia)
  • model → "K2.6 思考"
  • upgrade → clicked
  • all write-class commands print clean --yes false dry-runs

Known structural limitation (documented)

Per-message commands (copy-message/regenerate/react/share/read) and detail can navigate to a chat URL via --conv <id> but Kimi's React app does not trigger the messages fetch on programmatic navigation. The .message-list element mounts but has clientHeight: 0 and zero children; no /v1/messages requests appear in performance entries. Auth (access_token in localStorage, 8 cookies) is present and correct; this is purely Kimi's intentional lazy-load gate, likely keyed on user interaction events the headless navigation doesn't emit.

Workaround: Manually navigate to the chat URL in your real Chrome tab first, then run per-message commands without --conv.

What's NOT wrapped (and why)

  • Per-conv More 3-dot menu: opens a Vue teleported popover (.popover-menu is just the trigger; actual items mount elsewhere) and the click event doesn't surface a stable selector. Listed conversation rows + history-rename cover the common case.
  • Voice input: low CLI value (audio).
  • Grammarly extension: third-party.

@LeoLin990405
Copy link
Copy Markdown
Contributor Author

Update — render bug FIXED + per-message commands fully functional (commit `46535a10`)

Diagnosed via DOM probe + network audit. The previous "known limitation" (per-message commands return empty with --conv) is RESOLVED:

Root cause (dual bug):

  1. Kimi's React app only triggers the /api/messages fetch when the URL has ?chat_enter_method=history (a query-param sentinel). Plain /chat/<id> loads the title via cookies but leaves message container at clientHeight=0.
  2. Messages render in .chat-content-list as .chat-content-item-user / .chat-content-item-assistant, NOT .message-list (legacy scaffolding).

Fix: Append ?chat_enter_method=history in maybeNavigateConv() + detail(); update readKimiTurns() to enumerate .chat-content-item and .segment children.

E2E verified live on kimi.com:

opencli kimi read --conv "19e7475c..."  →  User: "电犀牛是啥"
                                            Assistant: "搜索网页 电犀牛 电动车 品牌 2026 15 个结果..."
                                            (full multi-turn output)
opencli kimi detail "19e7475c..."        →  same complete result
opencli kimi copy-message --conv         →  real assistant text extracted

Final state: all 26 commands functional, including per-message ones. The "known limitation" in earlier summary can be deleted from PR description.

@jackwener jackwener force-pushed the feat/kimi-adapter branch from ab086b6 to d9e7877 Compare May 31, 2026 11:10
@jackwener jackwener merged commit 5b11251 into jackwener:main May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants