Skip to content

feat(deepseek): add DeepSeek browser adapter#1088

Merged
jackwener merged 1 commit intojackwener:mainfrom
Benjamin-eecs:feat/deepseek-adapter
Apr 20, 2026
Merged

feat(deepseek): add DeepSeek browser adapter#1088
jackwener merged 1 commit intojackwener:mainfrom
Benjamin-eecs:feat/deepseek-adapter

Conversation

@Benjamin-eecs
Copy link
Copy Markdown
Contributor

@Benjamin-eecs Benjamin-eecs commented Apr 19, 2026

Summary

Closes #548.

Adds a full DeepSeek (chat.deepseek.com) browser adapter with 5 commands:

Command Description
deepseek ask <prompt> Send a prompt, supports --model, --think, --search
deepseek new Start a new conversation
deepseek status Check login state and page availability
deepseek read Read current conversation messages
deepseek history List conversation history from sidebar

Features

  • Model selection via --model instant/expert (default: instant)
  • DeepThink mode via --think
  • Web search mode via --search
  • All toggles are synced on every invocation: omitting a flag resets it to default
  • --new flag to start fresh conversations
  • Configurable timeout via --timeout
  • Fail-fast via CommandExecutionError when mode toggle or send fails
  • Sidebar auto-expand for history command
  • Retry logic for CDP context invalidation from SPA router transitions

Addressed review feedback

  • cli-manifest.json regenerated with all 5 deepseek entries
  • --model / --think / --search now fail-fast with CommandExecutionError instead of silently degrading
  • Toggle state detection uses ds-toggle-button--selected class

Test plan

  • npx tsc --noEmit passes
  • opencli deepseek ask "hello" --new returns response
  • opencli deepseek ask "..." --model expert switches to Expert model
  • opencli deepseek ask "..." --think enables DeepThink mode
  • opencli deepseek ask "..." --search enables web search
  • All 7 mode combinations tested (instant/expert x think/search)
  • Toggle reset verified: --think then no flag correctly disables DeepThink
  • Model reset verified: --model expert then no flag correctly reverts to Instant
  • opencli deepseek status shows login state
  • opencli deepseek new starts new conversation
  • opencli deepseek history --limit 5 lists conversations (works with collapsed sidebar)
  • opencli deepseek read reads current conversation

Copilot AI review requested due to automatic review settings April 19, 2026 15:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new DeepSeek (chat.deepseek.com) browser-based adapter to OpenCLI to enable prompting, conversation management, and basic status/reading functionality via the existing browser automation strategy.

Changes:

  • Introduces a shared DeepSeek browser utility module (navigation checks, toggles, send/read/poll helpers, history extraction, retry helper).
  • Adds 5 DeepSeek CLI commands: ask, new, status, read, and history.
  • Implements feature toggles for DeepThink and Search modes within the ask flow.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
clis/deepseek/utils.js Core DOM selectors + browser automation helpers (send, wait for response, read messages, list history, retry).
clis/deepseek/ask.js deepseek ask command wiring (navigation, flags, send + poll response).
clis/deepseek/new.js deepseek new command to start a fresh session via navigation.
clis/deepseek/status.js deepseek status command to report page readiness + login inference.
clis/deepseek/read.js deepseek read command to extract visible conversation messages.
clis/deepseek/history.js deepseek history command to scrape sidebar conversations with a limit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread clis/deepseek/history.js Outdated
Comment on lines +19 to +23
const conversations = await getConversationList(page);
if (conversations.length === 0) {
return [{ Index: 0, Title: 'No conversation history found.', Url: '' }];
}
return conversations.slice(0, limit);
Comment thread clis/deepseek/status.js Outdated
Comment on lines +1 to +5
import { cli, Strategy } from '@jackwener/opencli/registry';
import { DEEPSEEK_DOMAIN, ensureOnDeepSeek, getPageState } from './utils.js';

export const statusCommand = cli({
site: 'deepseek',
Comment thread clis/deepseek/ask.js Outdated
Comment on lines +7 to +11
export const askCommand = cli({
site: 'deepseek',
name: 'ask',
description: 'Send a prompt to DeepSeek and get the response',
domain: DEEPSEEK_DOMAIN,
Comment thread clis/deepseek/utils.js Outdated
const url = await page.evaluate('window.location.href').catch(() => '');
if (typeof url !== 'string' || !url) return false;
try {
return new URL(url).hostname.endsWith('deepseek.com');
Comment thread clis/deepseek/utils.js Outdated
Comment on lines +44 to +48
const isActive = btn.classList.length > 1;
if (!isActive) btn.click();
return { enabled: true, wasAlreadyActive: isActive };
}
}
Comment thread clis/deepseek/utils.js Outdated
Comment on lines +126 to +128
Role: isUser ? 'user' : 'assistant',
Text: (m.innerText || '').trim(),
};
@Benjamin-eecs Benjamin-eecs force-pushed the feat/deepseek-adapter branch 7 times, most recently from 50e593d to 6108a6e Compare April 19, 2026 16:27
@jackwener
Copy link
Copy Markdown
Owner

Hi @Benjamin-eecs — thanks for this adapter. Review concluded blocked at head 6108a6e1. Two concrete blockers that need a fix pass before we can merge:

1. cli-manifest.json is missing deepseek/* entries

src/discovery.ts:95-106 prefers the manifest fast path and skips the filesystem scan when the manifest is available. Because no deepseek entries are in HEAD:cli-manifest.json, the published artifact will not register deepseek ask / new / status / read / history, and they won't appear in completion either.

Suggested fix: regenerate or hand-patch cli-manifest.json to include all five commands (same shape as the other browser: true adapters).

2. --model / --think / --search silently degrade

selectModel() / enableFeature() return { selected: false } / { enabled: false } when the UI control toggle fails, but clis/deepseek/ask.js:39-50 ignores that result and continues to submit the prompt. The user sees a normal response and mistakenly believes the mode switched to expert / DeepThink / Search. Since the command surface exposes these options, the execution path should tighten the contract.

Suggested fix: fail-fast — when the control toggle fails, either error out explicitly or return a clear structured failure so the user doesn't get a silently-wrong-mode reply.

Once you push the fix, @codex-mini0 will re-review. Appreciate the patience — this adapter is otherwise in good shape.

@Benjamin-eecs Benjamin-eecs force-pushed the feat/deepseek-adapter branch 6 times, most recently from 0c1f5c6 to 89e67b1 Compare April 20, 2026 07:07
@Benjamin-eecs Benjamin-eecs force-pushed the feat/deepseek-adapter branch from 89e67b1 to 04dddfc Compare April 20, 2026 07:10
@jackwener jackwener merged commit 1639746 into jackwener:main Apr 20, 2026
11 checks passed
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.

[Feature]: support to access deepseek with browser style

3 participants