Skip to content

feat(masters): add direct masters browser-based read commands - #629

Merged
axisrow merged 2 commits into
mainfrom
masters-browser-command
Aug 1, 2026
Merged

feat(masters): add direct masters browser-based read commands#629
axisrow merged 2 commits into
mainfrom
masters-browser-command

Conversation

@axisrow

@axisrow axisrow commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds direct masters list / direct masters get <ids> — read-only access to Мастер кампаний (Campaign Wizard), which has no Yandex Direct API surface at all (not to be confused with UNIFIED_CAMPAIGN, an unrelated v5 API campaign type already supported by campaigns add/get --type unified_campaign).
  • Drives a real Chrome session via Playwright on a throwaway copy of the user's own Chrome cookies — no separate login flow. New optional browser extra: pip install "direct-cli[browser]" && playwright install chromium.
  • Grid-row detection keys off the /wizard/campaigns/{id}/ href signal (confirmed live, not link-counting). Overview parsing degrades per-section (warning, not hard failure) since this data has no API contract.
  • Captcha detection reuses the existing shared registry (direct_cli._captcha.find_captcha_marker) rather than duplicating markers.

Test plan

  • pytest tests/test_masters.py -n0 — 14 tests, all green (fake Page/Locator doubles, no real browser/network)
  • Full offline tier: 2539 passed, 8 skipped (pre-existing vcrpy/aiohttp errors in test_integration_write.py/test_read_cassettes.py confirmed unrelated via git stash)
  • black --check / flake8 clean on all changed files
  • /simplify review pass applied: removed dead code, deduped shared Click options into a decorator, cut redundant Playwright round-trips
  • Live manual check (direct masters list / get against a real account) — not run, requires playwright install chromium

Closes #628

🤖 Generated with Claude Code

Мастер кампаний (Campaign Wizard) has no Yandex Direct API surface at
all — do not confuse with UNIFIED_CAMPAIGN, an unrelated v5 API
campaign type already supported by `campaigns add/get --type
unified_campaign`. Adds `direct masters list`/`get`, driving a real
Chrome session via Playwright on a throwaway copy of the user's own
Chrome cookies, with graceful per-section degradation since this data
has no API contract to rely on.

Closes #628

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@axisrow

axisrow commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

🔍 Local review (cycle 1)

Reviewed locally (/review + Codex companion, model=sol effort=xhigh), no bots pinged.

Verdict Reviewer Finding Location
FIX claude Captcha detection (assert_not_captcha) is implemented and unit-tested, but never called from the real request path (fetch_masters_list/fetch_master) — a live SmartCaptcha gate would silently fall through to the parsers instead of raising BrowserCaptchaError, contradicting issue #628 risk item 5 direct_cli/browser/masters.py
FIX claude Error message references a --chrome-profile CLI flag that does not exist — open_chrome_session is never called with chrome_profile, so non-Default Chrome profiles are unreachable via any flag direct_cli/browser/session.py:77
codex No findings (verdict: approve)

Both findings triaged and confirmed. Proceeding to fix.

fetch_masters_list/fetch_master never called assert_not_captcha after
page.goto, so a live SmartCaptcha gate would silently fall through to
the parsers instead of raising BrowserCaptchaError (issue #628 risk
item 5). The --chrome-profile flag referenced in session.py's error
message also didn't exist, making non-Default Chrome profiles
unreachable via the CLI.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@axisrow

axisrow commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

📋 Review summary — all cycles

Cycle Reviewer Finding Verdict Resolution
1 claude (/review) Captcha detection (assert_not_captcha) implemented and unit-tested but never called from the real request path (fetch_masters_list/fetch_master) — a live SmartCaptcha gate would silently fall through to the parsers instead of raising BrowserCaptchaError FIX Fixed in b0a8505 — added assert_not_captcha(page.content()) after both page.goto calls, plus red→green tests
1 claude (/review) Error message referenced a nonexistent --chrome-profile CLI flag — non-Default Chrome profiles were unreachable FIX Fixed in b0a8505 — added --chrome-profile option, wired through _open_session/open_chrome_session
1 codex No findings (verdict: approve)
2 claude (/review) No findings
2 codex No findings (verdict: approve); non-blocking next-step: run a real Chrome smoke test for Default and non-default profiles before release Already covered by issue #628's "Живая проверка" manual verification section

Totals: 2 FIX (both resolved in b0a8505), 0 SKIP, 0 UNVERIFIED. Round 2 clean — no cleanup pass needed.

@axisrow
axisrow merged commit d87ebb3 into main Aug 1, 2026
6 checks passed
@axisrow
axisrow deleted the masters-browser-command branch August 1, 2026 02:10
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.

direct masters — браузерный режим чтения Мастеров кампаний

1 participant