v2ex-cdp-cli
v0.3.7
Published
CLI automation for Google login and V2EX interactions through managed Chrome CDP sessions.
Readme
v2ex-cdp-cli
CLI automation for Google login and V2EX interactions through managed Chrome CDP sessions.
The CLI keeps Chrome alive between commands. Use --session <slug> to isolate different Chrome instances, accounts, cookies, and V2EX workflows.
Install
npm install
npm run hooks:install
npm run buildRun during development:
npm run dev -- --session main chrome session startRun after build:
node dist/cli.js --session main chrome session startWhen installed as a package, both v2ex and v2ex-cdp run the same CLI.
Show the packaged skill guide and its installed path:
v2ex skillbookShow the installed version:
v2ex versionBuild the single-file bundle and create a local tarball:
npm run pack:tarballRun the pre-commit dependency gate manually:
npm run dependency:healthIf Chrome is not found automatically, pass --chrome-path or set CHROME_PATH.
Login
Start a persistent Chrome instance:
npm run dev -- --session main --headed chrome session startOpen Google login:
npm run dev -- --session main login googleOpen V2EX login. The CLI clicks "Sign in with Google" when that option is present, so finish OAuth in the Chrome window:
npm run dev -- --session main login v2exThe opened Chrome process remains alive after the command exits. Reuse the same --session main for later V2EX commands.
login defaults to headed mode because Google and V2EX OAuth need human interaction. Other commands default to headless mode for new sessions, but reuse an already-running session in its current mode unless you explicitly pass --headless or --headed. Add --headed when you want to watch or manually inspect a new browser.
V2EX Commands
List all channels/nodes from /planes:
npm run dev -- --session main v2ex channelsCommand output defaults to a human-readable text view with compact tables and summaries. Add --format json when you need full structured data for scripts or jq:
npm run dev -- --session main v2ex channels --format jsonBrowse a channel:
npm run dev -- --session main v2ex channel pythonOpen a specific page:
npm run dev -- --session main v2ex channel python --page 2Open the next page from a known current page:
npm run dev -- --session main v2ex next python --page 2v2ex next opens the current page first and clicks the visible "Next Page" control when available. If the control is not available, it falls back to opening the next page URL directly.
Read a topic:
npm run dev -- --session main v2ex topic 1193196Reply to a topic:
npm run dev -- --session main v2ex reply 1193196 --message "感谢分享。"Comment on a visible reply floor. V2EX does not have nested comments, so this posts a topic reply prefixed with @username:
npm run dev -- --session main v2ex comment 1193196 --to 1 --message "我也遇到过类似问题。"V2EX AI Recent Research
The AI recent-research workflow scans recent, finds AI/LLM/Agent-related topics, scores Tier1-like signals, and can generate a V2EX radar report. It is opt-in and uses this CLI's managed Chrome sessions for V2EX page reads.
Initialize the local cold-start store:
npm run dev -- v2ex ai recent-research migrateInspect migrated account/topic/score counts:
npm run dev -- v2ex ai recent-research statusRun a local heuristic-only watch scan:
npm run dev -- --session ai-watch v2ex ai recent-research watch --pages 3 --skip-deepseekEnable DeepSeek scoring by installing the external CLI first:
npm install -g deepseek-cdp-cli
npm run dev -- --session ai-watch v2ex ai recent-research watch --pages 3 --max-candidates 30 --deepseek-limit 18Generate a radar report from the Tier1-like account pool:
npm run dev -- --session ai-radar v2ex ai recent-research radar --pages 10 --skip-deepseekUseful tuning flags:
--delay-ms <ms>: slow down browser reads between pages/topics.--deep-think on|off|unchanged: match DeepSeek's DeepThink toggle naming.--tiers <tiers>: comma-separated current or historical tiers forradar.--score-decisions <decisions>: comma-separated decisions forradar, such astier1_like,near_tier1.
Research data is stored under the app home, usually ~/.v2ex-cdp-cli/v2ex-ai-recent-research/. Use --store-file <path> to override the JSON store for tests or experiments. Design notes live in docs/v2ex-ai-recent-research/.
Chrome Session Management
List managed Chrome instances:
npm run dev -- chrome session listEach listed session reports running only when both the recorded Chrome process and its CDP endpoint are alive. Regular V2EX commands disconnect from the session after finishing and intentionally leave the Chrome process running.
Stop one instance:
npm run dev -- --session main chrome session stopStop one instance and remove its persisted profile:
npm run dev -- --session main chrome session stop --remove-profileStart another isolated instance:
npm run dev -- --session work chrome session startSession data is stored under the app home directory, usually ~/.v2ex-cdp-cli/sessions/<slug>/.
Useful Options
--session <slug>: isolates Chrome processes and profiles; required for commands that open, reuse, or stop one specific session.--chrome-path <path>: explicit Chrome/Chromium executable path.--headless/--headed: choose Chrome mode for a new managed session. They are mutually exclusive.logindefaults to headed; non-login automation defaults to headless for new sessions and reuses existing session mode when no mode flag is provided.--proxy-server <server>: pass a proxy to launched Chrome sessions.--viewport <WIDTHxHEIGHT>: set page viewport for automation pages.--format text|json: choose output format for each command. Text is the default; JSON preserves the complete machine-readable result.
Notes
npm run hooks:installpoints Git at.githooks/; the pre-commit hook blocks commits whennpm audit --include=devfinds moderate-or-higher vulnerabilities ornpm ls --longreports deprecated dependency packages.- V2EX posting requires a logged-in account and may be subject to V2EX rate limits, anti-spam checks, and account rules.
- Keep one human-controlled Chrome window per
--sessionand reuse it; this is intentional so OAuth and V2EX sessions survive CLI command exits. chrome session listmarks sessions asrunningorstale; stale metadata can be removed withchrome session stop.- V2EX command results include a compact
networksection with observed V2EX requests, recent failures, and non-GET submission requests to help diagnose page automation outcomes. - Headed and headless sessions use a desktop-sized
1440x900default viewport/window to avoid the tiny headless default. Override it with--viewport, for example--viewport 1920x1080. - Explicit
--headless/--headedonly apply when a--sessionis first started. If that slug is already running in the opposite mode, stop it first withchrome session stop --remove-profileor use a different slug. Without an explicit mode flag, commands reuse the running session mode.
