Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions cli-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4065,6 +4065,147 @@
"sourceFile": "cursor/send.js",
"navigateBefore": true
},
{
"site": "deepseek",
"name": "ask",
"description": "Send a prompt to DeepSeek and get the response",
"domain": "chat.deepseek.com",
"strategy": "cookie",
"browser": true,
"args": [
{
"name": "prompt",
"type": "str",
"required": true,
"positional": true,
"help": "Prompt to send"
},
{
"name": "timeout",
"type": "int",
"default": 120,
"required": false,
"help": "Max seconds to wait for response"
},
{
"name": "new",
"type": "boolean",
"default": false,
"required": false,
"help": "Start a new chat before sending"
},
{
"name": "model",
"type": "str",
"default": "instant",
"required": false,
"help": "Model to use: instant or expert",
"choices": [
"instant",
"expert"
]
},
{
"name": "think",
"type": "boolean",
"default": false,
"required": false,
"help": "Enable DeepThink mode"
},
{
"name": "search",
"type": "boolean",
"default": false,
"required": false,
"help": "Enable web search"
}
],
"columns": [
"response"
],
"timeout": 180,
"type": "js",
"modulePath": "deepseek/ask.js",
"sourceFile": "deepseek/ask.js",
"navigateBefore": false
},
{
"site": "deepseek",
"name": "history",
"description": "List conversation history from DeepSeek sidebar",
"domain": "chat.deepseek.com",
"strategy": "cookie",
"browser": true,
"args": [
{
"name": "limit",
"type": "int",
"default": 20,
"required": false,
"help": "Max conversations to show"
}
],
"columns": [
"Index",
"Title",
"Url"
],
"type": "js",
"modulePath": "deepseek/history.js",
"sourceFile": "deepseek/history.js",
"navigateBefore": false
},
{
"site": "deepseek",
"name": "new",
"description": "Start a new conversation in DeepSeek",
"domain": "chat.deepseek.com",
"strategy": "cookie",
"browser": true,
"args": [],
"columns": [
"Status"
],
"type": "js",
"modulePath": "deepseek/new.js",
"sourceFile": "deepseek/new.js",
"navigateBefore": false
},
{
"site": "deepseek",
"name": "read",
"description": "Read the current DeepSeek conversation",
"domain": "chat.deepseek.com",
"strategy": "cookie",
"browser": true,
"args": [],
"columns": [
"Role",
"Text"
],
"type": "js",
"modulePath": "deepseek/read.js",
"sourceFile": "deepseek/read.js",
"navigateBefore": false
},
{
"site": "deepseek",
"name": "status",
"description": "Check DeepSeek page availability and login state",
"domain": "chat.deepseek.com",
"strategy": "cookie",
"browser": true,
"args": [],
"columns": [
"Status",
"Login",
"Url"
],
"type": "js",
"modulePath": "deepseek/status.js",
"sourceFile": "deepseek/status.js",
"navigateBefore": false
},
{
"site": "devto",
"name": "tag",
Expand Down
74 changes: 74 additions & 0 deletions clis/deepseek/ask.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
import { CommandExecutionError } from '@jackwener/opencli/errors';
import {
DEEPSEEK_DOMAIN, DEEPSEEK_URL, ensureOnDeepSeek, selectModel, setFeature,
sendMessage, getBubbleCount, waitForResponse, parseBoolFlag, withRetry,
} from './utils.js';

export const askCommand = cli({
site: 'deepseek',
name: 'ask',
description: 'Send a prompt to DeepSeek and get the response',
domain: DEEPSEEK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
navigateBefore: false,
timeoutSeconds: 180,
args: [
{ name: 'prompt', positional: true, required: true, help: 'Prompt to send' },
{ name: 'timeout', type: 'int', default: 120, help: 'Max seconds to wait for response' },
{ name: 'new', type: 'boolean', default: false, help: 'Start a new chat before sending' },
{ name: 'model', default: 'instant', choices: ['instant', 'expert'], help: 'Model to use: instant or expert' },
{ name: 'think', type: 'boolean', default: false, help: 'Enable DeepThink mode' },
{ name: 'search', type: 'boolean', default: false, help: 'Enable web search' },
],
columns: ['response'],

func: async (page, kwargs) => {
const prompt = kwargs.prompt;
const timeoutMs = (kwargs.timeout || 120) * 1000;
const wantThink = parseBoolFlag(kwargs.think);
const wantSearch = parseBoolFlag(kwargs.search);

if (parseBoolFlag(kwargs.new)) {
await page.goto(DEEPSEEK_URL);
await page.wait(3);
} else {
await ensureOnDeepSeek(page);
}

await page.wait(2);

const wantModel = kwargs.model || 'instant';
const modelResult = await withRetry(() => selectModel(page, wantModel));
if (!modelResult?.ok) {
throw new CommandExecutionError(`Could not switch to ${wantModel} model`);
}
if (modelResult.toggled) await page.wait(0.5);

const thinkResult = await withRetry(() => setFeature(page, 'DeepThink', wantThink));
if (!thinkResult?.ok) {
throw new CommandExecutionError('Could not toggle DeepThink');
}

const searchResult = await withRetry(() => setFeature(page, 'Search', wantSearch));
if (!searchResult?.ok) {
throw new CommandExecutionError('Could not toggle Search');
}

if (thinkResult.toggled || searchResult.toggled) await page.wait(0.5);

const baseline = await withRetry(() => getBubbleCount(page));
const sendResult = await withRetry(() => sendMessage(page, prompt));
if (!sendResult?.ok) {
throw new CommandExecutionError(sendResult?.reason || 'Failed to send message');
}

const response = await waitForResponse(page, baseline, prompt, timeoutMs);
if (!response) {
return [{ response: `[NO RESPONSE] No reply within ${kwargs.timeout}s.` }];
}

return [{ response }];
},
});
25 changes: 25 additions & 0 deletions clis/deepseek/history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
import { DEEPSEEK_DOMAIN, getConversationList } from './utils.js';

export const historyCommand = cli({
site: 'deepseek',
name: 'history',
description: 'List conversation history from DeepSeek sidebar',
domain: DEEPSEEK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
navigateBefore: false,
args: [
{ name: 'limit', type: 'int', default: 20, help: 'Max conversations to show' },
],
columns: ['Index', 'Title', 'Url'],

func: async (page, kwargs) => {
const limit = Math.max(1, kwargs.limit || 20);
const conversations = await getConversationList(page);
if (conversations.length === 0) {
return [{ Index: 0, Title: 'No conversation history found.', Url: '' }];
}
return conversations.slice(0, limit);
},
});
20 changes: 20 additions & 0 deletions clis/deepseek/new.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
import { DEEPSEEK_DOMAIN, DEEPSEEK_URL } from './utils.js';

export const newCommand = cli({
site: 'deepseek',
name: 'new',
description: 'Start a new conversation in DeepSeek',
domain: DEEPSEEK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
navigateBefore: false,
args: [],
columns: ['Status'],

func: async (page) => {
await page.goto(DEEPSEEK_URL);
await page.wait(2);
return [{ Status: 'New chat started' }];
},
});
22 changes: 22 additions & 0 deletions clis/deepseek/read.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
import { DEEPSEEK_DOMAIN, ensureOnDeepSeek, getVisibleMessages } from './utils.js';

export const readCommand = cli({
site: 'deepseek',
name: 'read',
description: 'Read the current DeepSeek conversation',
domain: DEEPSEEK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
navigateBefore: false,
args: [],
columns: ['Role', 'Text'],

func: async (page) => {
await ensureOnDeepSeek(page);
await page.wait(5);
const messages = await getVisibleMessages(page);
if (messages.length > 0) return messages;
return [{ Role: 'system', Text: 'No visible messages found.' }];
},
});
24 changes: 24 additions & 0 deletions clis/deepseek/status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
import { DEEPSEEK_DOMAIN, ensureOnDeepSeek, getPageState } from './utils.js';

export const statusCommand = cli({
site: 'deepseek',
name: 'status',
description: 'Check DeepSeek page availability and login state',
domain: DEEPSEEK_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
navigateBefore: false,
args: [],
columns: ['Status', 'Login', 'Url'],

func: async (page) => {
await ensureOnDeepSeek(page);
const state = await getPageState(page);
return [{
Status: state.hasTextarea ? 'Connected' : 'Page not ready',
Login: state.isLoggedIn ? 'Yes' : 'No',
Url: state.url,
}];
},
});
Loading