Compare commits

...

185 Commits

Author SHA1 Message Date
jackwener 31949b00f6 docs: require browser cleanup after agent tasks 2026-04-08 22:46:42 +08:00
jakevin f2de4ad63b docs: restructure README narrative (#885)
* docs: restructure readme narrative

* docs: clarify generate and agent entry points
2026-04-08 21:34:02 +08:00
jakevin ad9cce34d7 refactor: remove version field from GenerateOutcome and EarlyHint (#884)
All consumers are in the same repo and evolve together — version field
adds ceremony without practical value at this stage.

Keeps schema_version in VerifiedArtifactMetadata (sidecar file format).
2026-04-08 21:16:46 +08:00
jakevin 1662e9a73c refactor: rename operate to browser (#883)
* refactor: rename operate to browser

* fix: preserve browser rename compatibility

* fix: bump generate outcome schema version

* fix: keep generate outcome schema at v1
2026-04-08 21:03:57 +08:00
jakevin 991c8ce944 feat: P2 EarlyHint callback channel for cost gating (#882)
* fix: use Strategy.PUBLIC enum in skill-generate test to fix typecheck regression

* feat: add P2 EarlyHint callback channel to generateVerifiedFromUrl

Add optional onEarlyHint callback for internal cost gating before verify stage.

- EarlyHint type: version, stage, continue, reason, confidence, candidate?
- 3 emit points: explore (viable/not), synthesize (candidate/not), cascade (auth/ok)
- candidate only on synthesize/cascade + continue:true (not on stop or explore)
- unsupported-required-args goes directly to P1 terminal, no P2 hint emitted
- 6 new tests covering all hint paths + guardrails
2026-04-08 19:51:05 +08:00
jakevin 9365afc05f fix: use Strategy.PUBLIC enum in skill-generate test (#881) 2026-04-08 19:36:05 +08:00
jakevin 7ad8c1c42a feat: opencli-generate skill spec + thin wrapper (#880)
* docs: add opencli-generate skill spec (SKILL.md)

Captures A+B consensus from team discussion:
- Input: url + goal? (natural language intent hint)
- Output: SkillOutput with machine-readable fields + human message
- Decision tree: thin mapping from GenerateOutcome
- Guardrails: no re-orchestration, no auto-escalation, no new taxonomy
- P1/P2 boundary: P1 is single source of truth, P2 transparent to skill

* fix: address review nits on skill spec

- Make path explicitly optional in needs-human-check decision tree
- Add missing non-array-result message template

* feat: add GenerateOutcome → SkillOutput thin wrapper

Implements the skill mapping layer per opencli-generate SKILL.md:
- mapOutcomeToSkillOutput: thin translation from P1 contract to agent-facing output
- executeGenerateSkill: entry point accepting SkillInput (url + goal?)
- Message templates for all StopReason and EscalationReason values
- 8 tests covering all outcome paths and contract shape validation

* fix: prefer outcome.message for richer context in needs-human-check

When GenerateOutcome has a message (e.g. "required args: id"), use it
instead of the generic template, so the specific args info reaches the user.
2026-04-08 19:28:16 +08:00
VegetableDog cb34aa1009 fix(docs): add missing .md extension to adapter index links (#874)
All 68 browser adapter links and 8 desktop adapter links in
docs/adapters/index.md were missing the .md file extension,
causing broken links when navigating the documentation on GitHub.
2026-04-08 19:25:43 +08:00
jakevin 05e1b939a5 test: make verified path assertions cross-platform (#879) 2026-04-08 19:09:12 +08:00
jakevin 6ef55e85e9 chore: release v1.6.9 (#875) 2026-04-08 19:06:32 +08:00
jakevin bc82450311 feat: verified generate pipeline with structured contract (#878)
* feat: add verified generate pipeline

* Refine verified generate v1 flow

* Tighten verified generate v1 contract

* upgrade GenerateOutcome contract: structured taxonomy + sidecar metadata

Contract changes per team consensus (5 design principles):

1. Rename BlockReason taxonomy by skill decision needs:
   - no-api-discovered → no-viable-api-surface
   - auth-required → auth-too-complex
   - browser-unavailable → execution-environment-unavailable

2. Add stage + confidence to all blocked outcomes so skill knows
   where it stopped and how sure the system is.

3. Replace flat candidate/issue in needs-human-check with structured
   EscalationContext: stage, reason, confidence, suggested_action,
   candidate with explicit reusable + reusability_reason.

4. Add sidecar metadata (.meta.json) for verified artifacts —
   separates product/provenance contract from executable YAML.

5. Export shared decision language types (Stage, Confidence,
   StopReason, EscalationReason, SuggestedAction, ReusabilityKind)
   for future early-hint contract consistency.

* fix: make reusability contract explicit and self-consistent

Addresses @First-principles-0 review:

1. Add reusable + reusability_reason to VerifiedAdapter so success
   outcome is self-contained — skill doesn't need to read sidecar
   metadata or assume success implies reusable.

2. Rename 'candidate-yaml' → 'unverified-candidate' to resolve
   semantic clash with reusable: false. Now the pairing is always
   consistent:
   - reusable: true  + verified-artifact (success)
   - reusable: true  + unverified-candidate (candidate usable with manual args)
   - reusable: false + unverified-candidate (verify failed, candidate exists)
   - reusable: false + not-reusable (nothing worth keeping)

* refactor: merge reusable + reusability_reason into single reusability enum

Removes dual-truth contract (boolean + string) in favor of a single
Reusability enum ('verified-artifact' | 'unverified-candidate' | 'not-reusable').

- VerifiedAdapter.reusability replaces .reusable + .reusability_reason
- EscalationContext.candidate.reusability replaces .reusable + .reusability_reason
- Top-level GenerateOutcome.reusability present on all success and needs-human-check outcomes
- Sidecar metadata (.meta.json) retains reusable + reusability_reason for external compat
- Updated all 7 tests to assert single reusability field
2026-04-08 18:57:31 +08:00
jakevin 276ab8b8bf chore: bump version to 1.6.9 (#876)
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-04-08 16:03:35 +08:00
jakevin 85d73b5b83 refactor(doctor/status): unify daemon health checks into getDaemonHealth() (#873)
- Add getDaemonHealth() returning 'stopped' | 'no-extension' | 'ready'
- Delete discover.ts (thin wrapper with no value)
- Bridge uses getDaemonHealth() + _pollUntilReady() (eliminates duplicate polling)
- Doctor simplified: live check auto-starts daemon; no-live mode does minimal
  auto-start only when stopped (avoids misreporting idle-exit as failure)
- CommanderAdapter preserves error message/hint detail (not just generic title)
- All callers use single unified status entry point
2026-04-08 15:53:40 +08:00
AstroHan 79fb0822fc fix(test): repair binance pipeline imports (#870) 2026-04-08 14:30:35 +08:00
Yohan fd116fe4bc fix(xiaohongshu): scope note interaction selectors to .interact-container (#839)
* fix(xiaohongshu): scope note interaction selectors to .interact-container

The .like-wrapper / .collect-wrapper / .chat-wrapper class names are
also used by every comment's like/reply buttons in the comment section.
querySelector returned the FIRST match — which on a note with comments
is a comment's count, not the post's. As a result, `xiaohongshu note`
returned wrong like/collect/comment counts for any note that had user
comments.

Scoping each selector to .interact-container (the post's main
interaction bar) returns the correct post-level counts.

Verified on multiple notes:
- Note A: was returning likes=2, now correctly returns likes=74
- Note B: was returning likes=1, now correctly returns likes=796
- Note C: was returning likes=1, now correctly returns likes=269

* test(xiaohongshu): add regression check for .interact-container selector scope

Verify the evaluate script passes scoped selectors so unscoped
versions can't silently regress. Follows reviewer suggestion to
assert on page.evaluate.mock.calls[0][0].

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

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 14:18:44 +08:00
jakevin ea8b1a567b fix(browser): make bridge and doctor reflect real connection state (#871) 2026-04-08 14:11:01 +08:00
sline a3eb2dc90a feat: add GitHub Trending, Binance, and Weather adapters (24 commands) (#214)
* feat: add GitHub Trending, Binance, and Weather (Open Meteo) adapters

GitHub Trending (2 commands, browser mode):
- repos: trending repositories with stars, forks, language filter
- developers: trending developers with popular repos
  Supports --since daily/weekly/monthly and --language filter

Binance (11 commands, public API via data-api.binance.vision):
- top: top trading pairs by 24h volume
- price: single pair 24h price stats
- prices: latest prices for all pairs
- ticker: 24h ticker statistics
- gainers: top gaining pairs by 24h change
- losers: top losing pairs by 24h change
- trades: recent trades for a pair
- depth: order book bid prices
- asks: order book ask prices
- klines: candlestick/kline data
- pairs: list active trading pairs

Weather / Open Meteo (11 commands, free public API, no key needed):
- current: current weather for a city
- forecast: daily forecast up to 16 days
- hourly: hourly forecast
- search: city geocoding lookup
- air: air quality index (simple)
- air-quality: detailed air quality (US/EU AQI, PM2.5, PM10, ozone, NO2, SO2)
- sunrise: sunrise/sunset times with UV index
- wind: detailed wind forecast with gusts and 80m altitude
- precipitation: rain/snow forecast with probability
- history: historical weather up to 92 past days
- compare: side-by-side weather comparison across cities

All 24 commands tested with live data. 258 existing tests pass.

* docs: add missing douban, sinablog, substack adapter documentation

* fix(binance): sort numeric metrics and filter active pairs

* chore: drop non-binance adapters from pr214

* chore: drop binance docs from pr214

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-08 01:08:00 +08:00
X 61b247f90c feat(quark): add Quark Drive adapter (#858)
* feat(quark): add Quark Drive adapter (ls, mkdir, mv, rename, rm, save, share-tree)

Browser-based adapter for Quark Cloud Drive (pan.quark.cn) using cookie
strategy. Supports file browsing, folder management, and saving shared
files with task polling for async operations.

* fix(quark): address review feedback on adapter correctness and docs

- ls: fix depth off-by-one (default 0 now lists target folder only)
- save/mv: report success only after pollTask confirms completion; throw on timeout
- save/mv: reject combining --to and --to-fid instead of silently preferring --to-fid
- utils: check content-type before calling r.json() to handle non-JSON responses gracefully
- tests: add quark graceful auth-failure E2E cases for all 7 commands
- docs: add Browser Bridge extension to prerequisites; fix mkdir --parent example; expand command table with positional args; add Notes section explaining stoken flow

* fix(quark): map auth failures and cover utils

* fix(quark): reuse auth mapping for share-tree

---------

Co-authored-by: xzy <xzy@mbp-m5.local>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-08 00:28:59 +08:00
AstroHan ce559da7fc feat(zhihu): add interaction commands (#868)
* feat(zhihu): add interaction commands

* fix(zhihu): tighten interaction target anchoring

* fix(zhihu): scope comment authorship proof

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-07 23:17:51 +08:00
jakevin 56d15d186b feat: Self-Repair protocol for automatic adapter fixing (#866)
* feat: add Self-Repair protocol for automatic adapter fixing

When an AI agent uses opencli and a command fails, the agent
automatically diagnoses the failure, fixes the adapter, and retries.

- Add CLAUDE.md with Self-Repair protocol (auto-loaded by Claude Code)
- Add designs/self-repair-protocol.md documenting the approach
- Update opencli-repair skill: add Safety Boundaries (AUTH/BROWSER → STOP,
  sourcePath-only scope, max 3 rounds), fix AUTH_REQUIRED guidance
- Update opencli-usage skill: add Self-Repair section

Key design decisions:
- Repair target is always RepairContext.adapter.sourcePath (works for both
  repo-local clis/ and user-local ~/.opencli/clis/)
- Only adapter files may be modified, never core src/
- Max 3 repair rounds per failure
- AUTH_REQUIRED and BROWSER_CONNECT are hard stops (report, don't modify)

* fix: align auth boundary and scope language across all documents

- Remove "Auth changed (AUTH_REQUIRED)" exploration section from
  opencli-repair skill — contradicted the hard stop rule above it
- Update design doc: scope language matches repo-local + explicit skill
  delivery model, not universal product behavior
- Update usage skill: reference sourcePath instead of "files under clis/"

* fix: replace remaining repo-relative clis/ paths with sourcePath in design doc

* refactor: rename opencli-repair to opencli-autofix, remove CLAUDE.md

CLAUDE.md was wrong — users don't work inside the opencli repo, and
the protocol shouldn't assume Claude Code. The skill is the portable
delivery mechanism for any AI agent.

- Rename skills/opencli-repair → skills/opencli-autofix
- Remove CLAUDE.md (not the right delivery mechanism)
- Update all references in usage skill and design doc
- Design doc rewritten to reflect skill-first approach

* fix: use sourcePath in example repair session

* feat: emit AutoFix hint on repairable adapter errors

When a command fails with a repairable error (SELECTOR, EMPTY_RESULT,
COMMAND_EXEC, or generic http/not-found), the error output now includes
a hint telling agents to re-run with OPENCLI_DIAGNOSTIC=1 for repair
context. This is the trigger mechanism that bridges the gap between
"command failed" and "agent enters autofix loop".

Non-repairable errors (AUTH_REQUIRED, BROWSER_CONNECT, ARGUMENT) do not
emit the hint — these require user action, not adapter fixes.

* fix: narrow AutoFix hint to adapter-drift errors only

Remove hint from CommandExecutionError (covers env/launcher/runtime
issues, not adapter drift) and generic http errors (often temporary
site issues). Keep hint only for SelectorError, EmptyResultError,
and generic not-found — clear adapter-drift signals.
2026-04-07 23:00:03 +08:00
jakevin 57d59d5e01 fix: graceful fallback when extension lacks network-capture support (#865)
When the Browser Bridge extension is older than the CLI, sending
'network-capture-start' to the daemon returns 'Unknown action',
causing explore and operate-open to crash with an unhandled error.

Wrap startNetworkCapture calls with .catch() so they degrade
gracefully — explore continues without network capture data, and
operate-open falls back to the JS interceptor injection.
2026-04-07 20:42:14 +08:00
Kyrie Cai f6c13ef159 fix plugin host root resolution (#852)
Co-authored-by: Kyrie <kyrie@mallab.world>
2026-04-07 20:32:08 +08:00
GanFanNewOrder 9c5571eba3 feat(jianyu): add search adapter for bid notices (#849)
* feat(jianyu): add search adapter for bid notices

* docs(jianyu): add adapter usage guide

* docs(jianyu): neutralize examples and add adapter guide

---------

Co-authored-by: 泽加武 <zejiawu@zejiawudeMac-mini.local>
2026-04-07 19:20:00 +08:00
jakevin 813e282356 fix(twitter): relax reply composer textarea timeout from 8s to 15s (#862)
The compose page needs to load Draft.js editor which is heavier than
primaryColumn. 8s is too tight for slow networks and will cause flaky
failures. 15s aligns with the file input timeout (20s) in magnitude.
2026-04-07 18:50:39 +08:00
陈家名 4ea8f7e8c8 fix(twitter): use composer for text replies (#860)
Co-authored-by: 陈家名 <chenjiaming@kezaihui.com>
2026-04-07 18:08:14 +08:00
dependabot[bot] d85681e1cc chore(deps): bump @types/node from 22.19.15 to 25.5.2 (#838)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 22.19.15 to 25.5.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 25.5.2
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-07 14:42:16 +08:00
dependabot[bot] f7e7a37d8f chore(deps): bump vitest from 4.1.1 to 4.1.2 (#835)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 4.1.1 to 4.1.2.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.2/packages/vitest)

---
updated-dependencies:
- dependency-name: vitest
  dependency-version: 4.1.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-07 14:42:04 +08:00
dependabot[bot] 1e3904ba3c chore(deps): bump undici from 7.24.6 to 8.0.2 (#837)
Bumps [undici](https://github.com/nodejs/undici) from 7.24.6 to 8.0.2.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v7.24.6...v8.0.2)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 8.0.2
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-07 14:41:55 +08:00
AstroHan b8f0f583ef fix: include intercepted payloads in diagnostic (#829)
* fix: include intercepted payloads in diagnostic

* refactor: isolate captured payloads in diagnostic

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-06 15:20:34 +08:00
AstroHan 1cd0b4b404 fix: correct misleading behaviors in engine, fix, and generate (#826)
- engine.ts: replace `git add -A` with scope-aware `execFileSync` to
  stage only files matching config.scope globs, and guard against empty
  scope degenerating into staging all files
- fix.ts: pass prompt via stdin `input` option instead of shell string
  interpolation to prevent $, backtick, and other metacharacter expansion
- generate.ts: update stale comment that claimed unimplemented pipeline
  steps (register, verify, Strategy Cascade)
2026-04-06 15:05:29 +08:00
jakevin 60c92e1150 chore: bump version to 1.6.8 (#825)
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-04-06 03:24:52 +08:00
jakevin 009c25b955 refactor: remove scoring heuristic, use noise filter + structured metadata (#824)
* refactor: remove scoring heuristic, replace with noise filter + metadata

The scoring mechanism was a pre-LLM heuristic that compressed rich endpoint
metadata into a single number. Since this project is designed for AI Agents,
the agent can reason about structured metadata directly.

Changes:
- Remove scoreEndpoint/scoreRequest/scoreWriteRequest and all score fields
- Replace with isNoiseUrl() filter (tracking/beacon/pixel) + isUsefulEndpoint()
- Remove artificial confidence percentages (was score/20)
- Sort by itemCount (transparent, observable) instead of weighted score
- Endpoints now expose full structured metadata for agent consumption
- Net reduction: -43 lines

* fix: widen endpoint filter to keep single-object JSON and stats/metric URLs

- Remove stats/metric from noise pattern — these are often business APIs
- Relax isUsefulEndpoint to keep any JSON endpoint, not just arrays
  (preserves /me, /profile, /detail and other single-object APIs)

* fix: add deterministic endpoint ordering for generate/synthesize path

The AI agent path doesn't need ranking, but generate/synthesize still
pick candidates[0] as default — this needs a stable, explainable order.

- Add endpointSortKey() with transparent observable signals: array items,
  detected fields, API path patterns, query params
- Update synthesize chooseEndpoint fallback to use itemCount + field count
- Sort key is internal only; not exposed as score to external consumers
2026-04-06 03:21:15 +08:00
tiaot33 5553300597 feat(linux-do): split topic content into a dedicated command (#821)
* feat(linux-do): split topic content into a dedicated command

Move the old main-post path out of linux-do topic so topic stays a summarized first-page reader while topic-content becomes the Markdown-focused entrypoint for full post bodies.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

* feat(linux-do): update topic content handling to include YAML front matter

* fix(linux-do): update default output format to plain for topic-content rendering

* fix(linux-do): replace js-yaml with inline YAML serialization for topic-content

Adapters must only import node builtins, relative modules, or opencli
public APIs. Hand-roll the simple front matter serialization to remove
the third-party js-yaml dependency.

* fix(linux-do): refine YAML quoting to only escape colons followed by space

Colons in URLs (e.g. https://) are valid unquoted YAML values. Only
quote when a colon is followed by a space or appears at end of line.

---------

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-06 02:59:56 +08:00
jakevin d61dd7be0e refactor: extract shared scoring + consolidate time utils (#823)
* refactor: extract shared scoring logic and consolidate time format utils

- Extract applyUrlScoreAdjustments() and scoreArrayResponse() to analysis.ts,
  eliminating duplicated endpoint scoring between explore.ts and record.ts
- Consolidate formatDuration/formatUptime into a single formatDuration(ms)
  in download/progress.ts, reused by commands/daemon.ts

* fix: preserve explore scoring semantics and round daemon uptime

- Revert explore.ts scoreEndpoint to original inline /api/ /x/ bonus
  without record's tracking/analytics penalty (blocker from review)
- Math.round uptime*1000 to avoid floating-point noise in daemon status
2026-04-06 02:50:37 +08:00
jakevin e9867dcab0 feat(extension): v1.6.8 — fix scripting permission + refresh icons (#822)
* feat(extension): v1.6.8 — remove unused scripting permission, refresh icons

- Remove unused `scripting` permission (Chrome Web Store rejection fix)
- Bump version 1.6.7 → 1.6.8
- Redesign icons with neon gradient style (pure SVG paths, glow effect)

* revert icons to original, fix package.json version to 1.6.8

* test: remove stale scripting permission assertion
2026-04-06 02:07:00 +08:00
williamxie1989 bb7b26bc4a feat(xueqiu): add kline and groups adapters (#809)
* feat(xueqiu): add kline and groups adapters

Add kline.yaml: fetch candlestick/OHLCV data from Xueqiu v5 chart API.
Supports custom days lookback and outputs date, open, high, low, close,
volume, percent.

Add groups.yaml: list Xueqiu portfolio/group entries.


* fix(xueqiu): correct groups.yaml to use /portfolio/list.json API

The previous implementation used /portfolio/stock/list.json which only
returns stocks in a single group and does not return the group list.
Switch to /portfolio/list.json which returns all portfolio groups
including 实盘, 沪深, 港股, 美股, 模拟(pid=-4), 持仓 etc.


* fix(xueqiu): replace watchlist category param with pid selector

- Remove the unused 'category' parameter (the API ignores it;
  all groups live under category=1 regardless)
- Replace with 'pid' parameter to allow fetching any group:
  -4=simulated, -5=SH/SZ, -6=US stocks, -7=HK stocks, etc.
- API path still uses category=1 but pid is now user-controllable


---------
2026-04-06 02:01:29 +08:00
BruceLoveDecimal d2ae28786c feat:add 1688 assets downloadable (#820)
* feat:add 1688 assets downloadable

* fix: remove duplicate visitedRoots declaration and fix normalizeMediaUrl re-export

- Remove unused outer `visitedRoots` variable in scriptToReadAssets()
- Move normalizeMediaUrl test to import from shared.ts where it's defined
- Remove unused normalizeMediaUrl import from assets.ts

---------

Co-authored-by: 刘启灏 <liuqihao@liuqihaodeMacBook-Pro.local>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-06 01:59:39 +08:00
jakevin 1abff0cc1d feat(operate): unify network capture + implement CDP consoleMessages (#816)
* feat(operate): unify network capture + implement CDP consoleMessages

- operate open: start session capture before navigation (catches initial requests)
- operate network: prefer readNetworkCapture() over JS interceptor
- CDPPage: implement consoleMessages() via Runtime.consoleAPICalled

Part of #810

* fix(operate): use correct daemon/CDP entry field names for network capture

Daemon and CDP capture entries use responseStatus/responseContentType/
responsePreview (not status/contentType/responseBody). Fix the
normalization in operate network to match the actual entry shape from
extension/src/cdp.ts.

* fix(cdp): capture Runtime.exceptionThrown in consoleMessages

- Register Runtime.exceptionThrown handler to capture uncaught exceptions
  as error-level messages (most valuable diagnostic signal)
- 'error' filter now returns both console.error() and warning/exception
  entries, matching typical severity-based logging semantics
2026-04-05 22:55:03 +08:00
jakevin 1d46c5f934 feat(cdp): implement session-level network capture for CDPPage (#815)
* feat(cdp): implement session-level network capture for CDPPage

Implements startNetworkCapture() and readNetworkCapture() on CDPPage using
CDP Network domain events. Updates explore.ts to prefer session capture
over Performance API networkRequests().

Closes part of #810

* fix(cdp): use Network.loadingFinished for reliable body capture

- Move getResponseBody call from responseReceived to loadingFinished,
  matching the extension's implementation pattern
- Use extension-compatible entry shape (responseStatus, responseContentType,
  responsePreview) instead of custom field names
- Remove unreliable 100ms sleep hack in readNetworkCapture()
- Align with extension/src/cdp.ts:419-437 for consistency

* fix(cdp): drain buffer on readNetworkCapture to match daemon contract

readNetworkCapture() must clear the buffer after reading, matching the
daemon Page's read-and-drain behavior. Without this, repeated reads
would return stale entries.

* fix(cdp): await in-flight body fetches before returning from readNetworkCapture

Track all pending getResponseBody promises and await them in
readNetworkCapture() before draining the buffer. This ensures
explore/diagnostic consumers always get entries with responsePreview
populated, not empty shells where the body fetch hasn't resolved yet.

* fix(explore): handle both legacy and capture entry field names

parseNetworkRequests now maps both shapes:
- Legacy: status, contentType, responseBody
- Capture (extension/CDP): responseStatus, responseContentType, responsePreview

Also clears _pendingBodyFetches on startNetworkCapture reset.
2026-04-05 22:50:55 +08:00
jakevin d7fe7a7ffa fix(scaffold): replace non-existent extract step with select in YAML template (#814) 2026-04-05 22:50:43 +08:00
jakevin 7b55b8c595 test: remove flaky bloomberg e2e tests (#818)
* test: remove flaky bloomberg e2e tests

Bloomberg RSS endpoints are unreliable in CI, causing intermittent
e2e-headed failures unrelated to code changes.

* test: remove flaky bloomberg e2e tests

Bloomberg RSS feeds are unreliable in CI, causing false failures
in e2e-headed runs. Remove bloomberg tests from both
public-commands.test.ts and browser-public-extended.test.ts.
2026-04-05 22:50:24 +08:00
jakevin 15268da8f3 fix: add safety boundaries to diagnostic output (#806)
* fix: add safety boundaries to diagnostic output

- Redact sensitive headers (Authorization, Cookie, etc.) from network requests
- Redact sensitive URL query parameters (token, key, secret, etc.)
- Cap individual fields: snapshot (100K chars), adapter source (50K chars),
  network requests (50 entries, 4K body each), stack trace (5K chars)
- Enforce 256KB total output budget with graceful degradation:
  drops snapshot first, then page state entirely
- Export truncate/redactUrl helpers for testing

* fix: add free-text redaction for all diagnostic string channels

Addresses review feedback: snapshot, consoleErrors, error message/hint/stack
could contain inline secrets (Bearer tokens, JWTs, cookie values, token=value
patterns). All string channels now pass through redactText() before emission.

- Add redactText() with patterns for Bearer tokens, JWTs, cookie values,
  and inline key=value secrets
- Apply redactText to: error.message, error.hint, error.stack,
  page.snapshot, page.consoleErrors
- Add 6 new test cases for redactText and error message redaction

* fix: resolve adapter source path and add page state collection timeout

Fixes #808 items 1 and 3:

1. adapter.source was missing for all command types because buildRepairContext
   only checked cmd._modulePath (set only for manifest lazy-loaded TS).
   Now resolveAdapterSourcePath() checks cmd.source first, skips manifest:
   pseudo-paths, and maps dist/clis/*.js back to source clis/*.ts.

3. collectPageState() had no timeout — a hung CDP connection would block
   error propagation indefinitely. Now wrapped with 5s Promise.race timeout,
   falling back to emitting diagnostic without page state.

* fix: track sourceFile in manifest for YAML adapter source resolution

YAML commands inlined in the manifest previously lost their original file
path, causing resolveAdapterSourcePath() to return undefined. Add
sourceFile field to ManifestEntry so discovery can reconstruct the
editable source path for both YAML and TS commands.
2026-04-05 19:50:03 +08:00
jakevin a3efdc16de refactor: centralize build path resolution (#807) 2026-04-05 19:46:58 +08:00
jakevin d51338cbf3 chore: bump version to 1.6.7
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-04-05 18:07:55 +08:00
jakevin 664a971ed5 feat: structured diagnostic output for AI-driven adapter repair (#802)
* feat: add structured diagnostic output for AI-driven adapter repair

When OPENCLI_DIAGNOSTIC=1 is set, failed commands emit a RepairContext
JSON to stderr containing the error, adapter source, and browser state
(DOM snapshot, network requests, console errors). AI Agents consume
this to diagnose and fix adapters when websites change.

Also adds the opencli-repair skill guide for AI Agents.

* fix: correct e2e test binary path to dist/src/main.js

The e2e helpers pointed to dist/main.js but the actual build output
is at dist/src/main.js (matching package.json "main" field). This
caused all e2e-headed tests to fail with "Cannot find module".

* fix: correct dist/main.js path in autoresearch scripts

* fix: emit diagnostic for pre-session browser failures

When browser connection fails before the session callback runs
(e.g., BrowserConnectError), the inner diagnostic catch never fires.
Use a flag to ensure the outer catch emits diagnostic as a fallback.

* test: tolerate unavailable Bloomberg RSS feeds in e2e

* test: skip flaky bloomberg businessweek e2e test

The Bloomberg Businessweek RSS feed is intermittently unavailable,
causing CI failures unrelated to code changes.

* revert: restore bloomberg businessweek e2e coverage
2026-04-05 18:04:49 +08:00
Kai 97a547c6c5 fix: avoid inserting completion config inside multi-line shell commands (#796)
* fix: avoid inserting completion config inside multi-line shell commands

The postinstall zshrc insertion logic splits backslash-continued blocks
(e.g. zinit stanzas) when it finds a compinit match inside them, which
breaks the user's shell config. Walk backward past continuation lines
so the insertion lands before the entire logical command.

* fix: append zsh completion to end of .zshrc instead of splicing

Replace the fragile compinit-searching splice logic with a simple
append, matching the strategy already used for bash. This avoids
breaking multi-line commands (e.g. zinit blocks with zicompinit).

Still detects existing compinit to avoid adding a duplicate call.

* fix: stop modifying shell rc files in postinstall

Replace the fragile .zshrc/.bashrc modification logic with a safer
approach: only write completion files and print setup instructions.

The previous approach tried to parse and splice into rc files, which
broke multi-line shell commands (e.g. zinit blocks with backslash
continuations matching /compinit/). Instead of attempting to fix the
parser, remove rc modification entirely — this matches the approach
used by rustup, homebrew, and other CLI tools.

Closes #788

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-05 17:39:23 +08:00
jakevin eedc47aa26 chore: bump version to 1.6.6
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-04-05 17:34:57 +08:00
jakevin 8c41411860 fix: route copied adapters through opencli exports
* fix(discovery): expose runtime deps to user adapters

* fix: route copied adapters through opencli exports

* refactor: route adapter status output through logger
2026-04-05 17:31:45 +08:00
jakevin ed69e839ab chore: bump version to 1.6.5 (#797)
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-04-05 16:07:02 +08:00
jakevin 4fe9a73ebc refactor: migrate adapter imports to package exports (#795)
* refactor: migrate adapter imports to package exports

Replace all relative imports (../../src/registry.js, ../../browser/cdp.js, etc.)
with package exports (@jackwener/opencli/registry, @jackwener/opencli/errors, etc.)
across all 484 adapter files.

This decouples adapter import resolution from directory structure:
- User CLIs in ~/.opencli/clis/ resolve via node_modules symlink
- Internal adapters resolve via Node.js self-referencing
- No more shim files needed for import resolution

Changes:
- package.json: add sub-path exports for all public modules
- clis/**: replace relative imports with @jackwener/opencli/...
- discovery.ts: simplify ensureUserCliCompatShims to symlink-only
- registry-api.ts: export CommandArgs type
- Remove root-level shim directories (browser/, download/, pipeline/)
- Remove shim entries from tsconfig.json include and package.json files

* test: add regression tests for package exports

Prevents regressions like #788/#791 by:
1. Scanning all adapter files for forbidden relative imports
   (../../src/, ../../browser/, etc.) — fails if any remain
2. Verifying every package.json export maps to an existing source file

18 new test cases.

* fix: use junction on Windows + broaden test patterns

- discovery.ts: use 'junction' symlink type on Windows (no admin required)
- package-exports.test.ts: generalize forbidden patterns to catch any
  depth of ../ traversal (not just ../../ and ../../../)

* fix: update stale vi.mock/importActual paths in adapter tests

Test files still used old relative paths for vi.mock() and
vi.importActual() calls. Updated 5 test files to use package exports.
Also broadened regression test patterns to catch mock/importActual paths.

* fix: use rm instead of unlink for symlink cleanup, add warn on failure

Addresses review feedback from Astro-Han:
- rm() handles both symlinks and stale directories (unlink fails on dirs)
- Log a warning when symlink creation fails instead of silent catch

* docs: update import examples to use package exports

Update all documentation, contributing guides, and skills to use
@jackwener/opencli/registry instead of ../../src/registry.js.

Without this, users following the docs would write adapters with
broken imports since the old shim files are no longer created.
2026-04-05 16:02:17 +08:00
jakevin a1dd817886 chore: bump version to 1.6.4 (#794)
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-04-05 14:57:45 +08:00
AstroHan 20957cbc7b fix: resolve version 0.0.0 and user CLI load failures (#788) (#789)
Bug 1: version.ts used a single-level parent lookup for package.json,
which broke after #784 changed rootDir from "src" to "." (version.js
now lives in dist/src/ instead of dist/).  Walk up until package.json
is found — works in both dev (src/) and prod (dist/src/).

Bug 2: adapters copied to ~/.opencli/clis/ import ../../src/registry.js
etc., which resolves to ~/.opencli/src/.  Derive src/ compat shims from
the existing rootShims list so these imports resolve correctly.
2026-04-05 14:54:30 +08:00
jakevin ab58aa4098 fix(docs): update outdated paths and command lists across all docs (#787)
- Replace 140 instances of `src/clis/` → `clis/` across 12 doc files
  (path changed after repo restructure)
- Remove non-command `rpc` and `rankings` from notebooklm/amazon
  command lists in README, README.zh-CN, SKILL.md, and adapters index
  (these are internal utility modules, not user-facing commands)
- Add `deep-research` and `deep-research-result` to gemini adapter doc
- Add `movers-shakers` and `new-releases` to amazon adapter doc
- Update notebooklm doc examples to use canonical commands instead of
  deprecated aliases (`metadata` → `get`, `notes-list` → `note-list`)
- Bump SKILL.md version to 1.6.3
2026-04-05 03:53:52 +08:00
jakevin 76b5d53bb5 chore: bump version to 1.6.3 (#786)
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-04-05 03:46:13 +08:00
jakevin 00f6062e74 docs: fix outdated commands and adapter counts (#785)
* docs: fix outdated commands and adapter counts in README and skills

- Add gemini deep-research and deep-research-result commands
- Fix notebooklm: remove non-existent select/metadata/notes-list, add rpc
- Add amazon movers-shakers, new-releases, rankings commands
- Add missing weibo commands in zh-CN README
- Fix linux-do missing hot/latest/category in zh-CN README
- Update adapter count from 73+ to 79+
- Update skills version to 1.6.2
- Add full spotify command list in skills SKILL.md

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

* fix(test): update xiaohongshu note tests for search_result URL change

buildNoteUrl now uses /search_result/<id> instead of /explore/<id> for
bare note IDs. Update test expectations to match:
- buildNoteUrl test: expect /search_result/ not /explore/
- goto URL assertion: expect /search_result/ not /explore/
- empty shell hint: match actual error message text

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

* fix(test): update xiaohongshu comments test for search_result URL change

- Bare note ID now navigates to /search_result/ not /explore/
- Full URL inputs are preserved as-is (including /explore/ URLs)

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-05 03:39:50 +08:00
jakevin 12176de1a5 refactor: simplify core modules (#784)
* refactor: simplify core modules — remove root shims, consolidate error classification, streamline cascade/interceptor, clean up synthesize

1. Remove root-level shim files (errors.ts, logger.ts, registry.ts, types.ts, utils.ts, launcher.ts) — update all ~840 adapter imports to reference src/ directly
2. Consolidate interceptor: reuse shared DISGUISE_FN in tap interceptor instead of reimplementing
3. Unify error classification: single ClassifiedError type with icon/exitCode/hint lookup table, eliminating duplicated pattern matching between resolveExitCode and renderError
4. Simplify cascade probe: replace repetitive switch cases with PROBE_OPTIONS lookup map
12. Clean up synthesize.ts: remove deprecated snake_case field aliases (recommended_args, recommended_columns, recommendedColumnsLegacy) and unnecessary constant aliases

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

* docs: update import paths in contributor docs and skill templates

Update all documentation and skill files to reference src/ directly,
matching the shim removal in the previous commit.

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

* fix: update new Gemini adapter imports to use src/ paths

Fix imports in newly added deep-research adapter files that were
still referencing the deleted root shim files.

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

* fix: update xiaohongshu tests for /search_result/ URL change

Tests now expect /search_result/<id> for bare note IDs (matching
the note-helpers.ts change from PR #774) and updated empty-shell
hint assertion.

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

* fix: update LessWrong and hupu adapter imports to use src/ paths

Fix imports in newly merged LessWrong and hupu/mentions adapter
files that were still referencing the deleted root shim files.

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

* test(xueqiu): mock logger via src path

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-05 03:35:12 +08:00
kevin.zhang 8bd36aaa37 fix(hupu): add mentions command (#757)
* feat(hupu): add hupu cli adapter

* fix(hupu): prevent detail from returning the wrong thread

* refactor: deduplicate shared utilities in hupu adapter

- Merge postHupuJson and postHupuReplyJson into single function with mode parameter
- Move stripHtml and decodeHtmlEntities to utils.ts, remove duplicate definitions

* fix(hupu): add mentions command

* fix: move mentions.ts to clis/hupu/, remove src/clis/hupu duplicates

Post PR #782 restructure: adapter files live at root clis/, not src/clis/.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-05 03:26:40 +08:00
Xule Lin d2051cdab7 feat(lesswrong): add LessWrong adapter (#773)
* feat(lesswrong): add LessWrong adapter

15 commands for the LessWrong rationality and AI alignment community:
- Post listings: curated, frontpage, new, top, top-week/month/year
- Content: read (full post), comments, shortform (quick takes)
- Discovery: tag, tags, sequences
- Users: user (profile), user-posts

All commands use the public GraphQL API (no browser required).
Time-filtered views use the `after` date parameter.
Tag lookup resolves slugs to IDs via the `tagBySlug` view.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: move lesswrong adapter to clis/ (post PR #782 restructure)

New adapter files were created at src/clis/lesswrong/ but PR #782 moved
all adapters to root clis/. Move to correct location.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-05 03:21:48 +08:00
kingOfSoySauce cfb915b1d7 fix(xiaohongshu): use /search_result/<id> for bare note IDs (#774)
XHS blocks /explore/<id> without a valid xsec_token, causing code 66
(empty result) when passing bare note IDs. The /search_result/<id> path
works without xsec_token when the user is logged in via cookies.

Changes:
- note-helpers.ts: buildNoteUrl now uses /search_result/<id> for bare IDs
- note.ts: remove isBareNoteId branching and simplify empty shell error
2026-04-05 03:14:49 +08:00
backtomyfuture 4e2b314930 feat(gemini): add deep-research workflow and docs export result (#778)
* feat(gemini): add deep-research workflow and docs export result

* fix(gemini): improve deep-research submit and confirm flow

* fix(gemini): return waiting state when deep research is in progress

* fix(gemini): avoid false submit detection on root app transcript changes

* fix(gemini): return pending state when deep-research export is not ready

---------

Co-authored-by: f1480022 <f148002@163.com>
2026-04-05 03:09:46 +08:00
gucasbrg a0a4dd68ef fix(36kr): replace waitForCapture with DOM polling for search/hot (#779)
* fix(36kr): replace waitForCapture with DOM polling for search/hot

waitForCapture(6) always times out on 36kr because the API intercept
never captures a matching request. However, the DOM is already fully
rendered with search/hot results by the time the timeout fires.

Replace the 6-second intercept wait with a DOM polling loop that checks
for article links (a[href*="/p/"]) every 300ms, returning immediately
once content is available (typically ~1s vs 6s timeout + error).

Tested on opencli 1.6.2 with both CDP and Browser Bridge modes.

* fix: rebase onto main, remove unused interceptor, fix strategy

- Rebase onto main after clis/ move (PR #782)
- Remove installInterceptor calls (no longer used after waitForCapture removal)
- Change strategy from INTERCEPT to PUBLIC (browser: true) to match actual behavior
- Improve polling loop readability

---------

Co-authored-by: buruguo <buruguo@lambdafintech.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-05 03:04:37 +08:00
Inori333 97ae87ccee fix(cli): make operate verify work in source checkouts (#777)
* fix(cli): make operate verify work in source checkouts

* fix(cli): resolve operate verify entry from package metadata

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-05 02:56:10 +08:00
Howard 174ef75a54 docs: add Android Chrome usage guide (#687) 2026-04-05 02:53:10 +08:00
jakevin 639a31fc84 fix: review follow-ups for monorepo adapter separation (#783)
* fix: review follow-ups — better first-run log, OPENCLI_FETCH=1 skips version check

- Clarify first-run log message: "copying adapters (one-time setup)"
- Add comment explaining why scriptPath uses two levels of ../
- OPENCLI_FETCH=1 now bypasses version-skip to allow forced refresh

* fix: update doc-coverage script path after clis/ move

check-doc-coverage.sh still referenced src/clis/ after PR #782 moved
adapters to root clis/. This caused CI to fail with "0/1 documented".

* fix: resolve package root dynamically for symlink and first-run paths

The symlink at ~/.opencli/node_modules/@jackwener/opencli pointed to
dist/ instead of the package root in prod mode, breaking user TS CLIs
that import from '@jackwener/opencli/registry'.

The first-run scriptPath also resolved incorrectly in dev mode.

Extract findPackageRoot() that walks up to find package.json, fixing
both paths for dev (src/) and prod (dist/src/) layouts.
2026-04-05 02:25:53 +08:00
jakevin 80eef46b4e refactor: monorepo adapter separation (clis/ at root) (#782)
* refactor: move adapters from src/clis/ to root clis/ for monorepo separation

Separates CLI adapters from the core runtime to prepare for independent
adapter distribution via postinstall fetch.

Key changes:
- Move src/clis/ → clis/ (adapters at repo root)
- Change tsconfig rootDir from "src" to "." so tsc compiles both
- Create root-level shim files (registry.ts, errors.ts, etc.) so adapter
  relative imports (../../registry.js) resolve correctly
- Update build-manifest.ts, main.ts paths for new dist/src/ structure
- Expand ensureUserCliCompatShims() to cover all adapter import targets
  (types, utils, logger, launcher, browser/*, download/*, pipeline/*)
- Add scripts/fetch-adapters.js postinstall for ~/.opencli/clis/ sync
- Update vitest.config.ts adapter test paths
- Add package.json files field to exclude adapters from npm package

Official adapter files are unconditionally overwritten on update;
user-created files not in the manifest are preserved.

* fix: add dist/clis/ and cli-manifest.json to npm files, harden fetch-adapters

- Add dist/clis/ and dist/cli-manifest.json to package.json files field
  so built-in adapters and manifest ship with the npm package
- Replace execSync with execFileSync to prevent command injection
- Add version check to skip redundant adapter fetches
- Track tmpRoot explicitly for reliable cleanup

* fix: address review blockers — manifest-based updates, global-only fetch, first-run fallback

1. Manifest-based update strategy:
   - Read old manifest to identify previously-official files
   - Clean up files removed upstream (in old manifest but not new)
   - User-created files (never in any manifest) remain untouched

2. Only run fetch-adapters on global install (npm_config_global=true)
   or explicit OPENCLI_FETCH=1, preventing heavy side effects for
   local/dev installs

3. First-run fallback in discovery.ts:
   - ensureUserAdapters() checks for adapter-manifest.json
   - If missing and ~/.opencli/clis/ is empty, spawns fetch-adapters.js
   - Guarantees adapters are available even with --ignore-scripts

* fix: remove OPENCLI_FETCH env var, use internal _OPENCLI_FIRST_RUN instead

* feat: also support OPENCLI_FETCH=1 for explicit adapter fetch trigger

* simplify: replace git clone with local copy from dist/clis/

Adapters already ship in the npm package (dist/clis/), so there's no
need to clone from GitHub. Copy directly from the installed package:

- Eliminates git, curl, tar dependencies
- No network calls in postinstall
- No timeout/offline issues
- Version always matches the installed CLI
- ~65 lines of clone/download code replaced by one cpSync loop
2026-04-05 01:46:36 +08:00
TennyZhuang 60bee91650 fix: match the requested tweet before deleting on X (#781)
* fix(twitter): match target tweet before deleting

* review: normalize invalid twitter delete URLs

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 23:57:01 +08:00
jakevin cf9e9f0137 chore: update lock files for v1.6.2 (#776) 2026-04-04 21:32:27 +08:00
jakevin b2f1f58a1b chore: bump version to 1.6.2 (#775)
Release / release (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
2026-04-04 21:28:37 +08:00
jakevin 81308a474e docs: add skills install command to Quick Start section (#772)
Add `npx skills add jackwener/opencli` to the install step in both
English and Chinese READMEs so users discover AI skills during setup.
2026-04-04 18:46:27 +08:00
Inori333 d818b5bed8 fix(completion): sync top-level command suggestions (#588) 2026-04-04 16:26:31 +08:00
Ray e82649379b feat(instagram): add post, reel, story, and note publishing (#671)
* Add draft Instagram posting flow

* Refine Instagram post flow

* Add dynamic Instagram posting routes

* Retry transient Instagram private setup failures

* Add Instagram reel posting command

* Add Instagram mixed-media carousel posting

* Unify Instagram post media input

* Add Instagram story posting command

* Add Instagram note publishing command

* fix(instagram): use JSON.stringify for constants in note evaluate string

Replace template literal interpolation of Node-side constants with
JSON.stringify() for consistency with codebase evaluate patterns.
Use bracket notation for dynamic property access instead of template
interpolation into a property chain.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 16:22:22 +08:00
kevin.zhang e0a66af0f0 feat(hupu): add Hupu adapter (#751)
* feat(hupu): add hupu cli adapter

* fix(hupu): prevent detail from returning the wrong thread

* refactor: deduplicate shared utilities in hupu adapter

- Merge postHupuJson and postHupuReplyJson into single function with mode parameter
- Move stripHtml and decodeHtmlEntities to utils.ts, remove duplicate definitions

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 16:03:14 +08:00
YoungCan-Wang c86e677b78 推特支持回复图片 (#756)
* feat: 推特新增回复图片能力支持本地路径和网络路径

* fix(twitter/reply): fix image upload fallback, restore execCommand, add size limit

- Fix attachReplyImage fallback: use uploaded flag instead of checking
  page.setFileInput existence, so base64 fallback actually runs when
  CDP setFileInput throws "Unknown action"
- Restore execCommand('insertText') as primary text input method for
  Twitter's Draft.js editor, with paste event as fallback
- Add 20MB size limit for remote image downloads to prevent OOM
- Remove unsafe buttons[0] fallback that could click invisible buttons

* fix(twitter/reply): add local image size check and base64 fallback warning

Local images were not validated for size — a 100MB file would fail only
at upload time. Remote images already had MAX_IMAGE_SIZE_BYTES checks.
Also add a console.warn when using the base64 fallback with large
payloads, consistent with xiaohongshu/publish.ts behavior.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 16:00:35 +08:00
yulin7645 6364934423 feat(xiaoe): add 小鹅通 (Xiaoe-tech) student platform adapter (#617)
* feat(xiaoe): add 小鹅通 (Xiaoe-tech) student platform adapter

Add 5 YAML adapters for 小鹅通 (xiaoe-tech.com), the leading Chinese
online education platform:

- courses: list purchased courses with URLs and shop names
- detail: course info (name, price, user count, shop)
- catalog: full course outline supporting normal courses (type 50),
  columns (type 6), and big columns (type 8)
- play-url: get M3U8 play URL via direct API for video courses,
  and Vue component tree search + Performance API polling for
  live replay courses
- content: extract rich-text page content as plain text

Technical notes:
- Strategy: cookie (reuses Chrome login session)
- Framework: Vue 2 + Vuex Store (SPA)
- Video courses use a two-step API chain:
  detail_info.get → play_sign → getPlayUrl → M3U8
- Live replays use Performance API + Vue data tree polling
- Catalog expands chapters via Vue component method getSecitonList()
- Supports multiple stores (cross-domain cookie sharing via
  study.xiaoe-tech.com)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* review: stop truncating xiaoe content

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 15:54:14 +08:00
AstroHan ef78aaf3a2 fix: add -v/--verbose to built-in browser commands (#719)
* fix: add -v/--verbose to explore, record, generate, cascade

Built-in browser commands were registered directly in cli.ts and
missed the -v/--verbose flag that commanderAdapter.ts wires up for
adapter commands. Also switch explore's lone log.debug() call to
log.verbose() so the flag has visible effect.

Closes #716

* refactor(cli): make builtin command wiring testable

* refactor(cli): simplify verbose wiring, use normal Commander pattern

Replace registerVerboseAction wrapper with simple applyVerbose() helper.
The wrapper broke Commander's builder chain and created awkward
indentation. Now each command uses standard .option().action() with
applyVerbose(opts) as the first line — easier to read and maintain.

* fix(cli): add -v/--verbose to doctor and synthesize commands

These commands were also missing verbose support, same root cause as
explore/record/generate/cascade — registered directly in cli.ts,
bypassing commanderAdapter's automatic -v wiring.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 15:44:23 +08:00
artshooter 292b12d9b1 feat(twitter): add --images flag to post command (#666)
* feat(twitter): add --images flag to post command

Support attaching up to 4 images when posting tweets via
`opencli twitter post "text" --images /path/a.png,/path/b.jpg`.

Uses the existing CDP DOM.setFileInputFiles mechanism (page.setFileInput)
to inject files into Twitter's file input. Includes proper file validation,
graceful error handling for older extensions, and polling-based upload
readiness detection instead of fixed delays.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(twitter): use attachments DOM signal for upload detection, add tests

Replace unreliable tweet-button-only polling with dual-condition check:
wait for [data-testid="attachments"] with correct [role="group"] count
AND button enabled. Increase timeout to 30s. Add 8 unit tests covering
image upload flow, file validation, and error paths.

Addresses PR #666 review feedback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(twitter): use top-level imports, fix test mocks, faster upload poll

- Use top-level fs/path imports instead of dynamic imports inside func
- Fix test statSync mock to return undefined (not null) for missing files
- Fix test path mock to preserve other exports via importOriginal
- Fix null type error in no-browser-session test
- Reduce upload poll interval from 1s to 500ms for faster detection
- Use JSON.stringify for imageCount interpolation for consistency

* refactor(twitter): extract validation, fail-fast, reduce duplication

- Extract validateImagePaths() with extension validation (jpg/png/gif/webp)
  matching xiaohongshu publish pattern
- Validate images before browser navigation (fail-fast on bad input)
- Remove try/catch wrapper around setFileInput — let errors propagate
  naturally instead of masking the original error
- Deduplicate tweetButton/tweetButtonInline lookups using fallback OR
- Use constants for MAX_IMAGES, UPLOAD_POLL_MS, UPLOAD_TIMEOUT_MS
- Add tests: unsupported format, validates-before-navigating

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 15:31:01 +08:00
AstroHan 2c5066d1f4 fix(gemini): stabilize ask reply state handling (#735)
* fix(gemini): stabilize ask reply state handling

* fix: use CommandExecutionError for composer failures and clean up formatting

- Replace raw Error with CommandExecutionError for Node-side composer
  failures (prepareComposer, insertText) to match adapter error conventions
- Remove extra blank lines after __test__ export

* refactor: remove dead code and add Chinese sign-in label

- Remove unused areGeminiTurnsEqual and areGeminiLinesEqual functions
- Add Chinese sign-in label (登录) to sign-in detection for consistency
  with other Chinese labels already added in this PR

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 15:26:58 +08:00
yichuanzhao99-ctrl 8eefa3b1c9 增加新浪财经热搜股票榜 (#736)
* 增加新浪财经热搜股票榜

* fix: address review issues in stock-rank adapter

- Fix string interpolation injection: use JSON.stringify for market param
- Add choices validation for market arg (cn/hk/us/wh/ft)
- Normalize column names to lowercase (rank/name/symbol/market/price/change/url)
- Add navigateBefore: false to avoid redundant navigation
- Add null safety on tabEl with optional chaining
- Remove unused waitForElement helper and unnecessary await on querySelectorAll
- Remove unrelated ?from=opencli tracking change from rolling-news.ts
- Remove ?from=opencli tracking from stock-rank URLs

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 15:16:05 +08:00
jakevin 052bf8bbf7 refactor(zhihu): simplify question evaluate to follow pixivFetch pattern (#754)
Move data processing (HTML stripping, answer mapping) from browser-side
evaluate to Node-side, keeping the evaluate minimal: just fetch + status
check. Uses __httpError sentinel consistent with pixivFetch convention.
2026-04-04 15:06:16 +08:00
jakevin c3c3abbbff fix(1688): remove MOQ extraction from price field, rename firstLine to firstWord, fix sales regex (#755)
- Remove hover_price_text as MOQ source in search normalizeSearchCandidate
  to prevent price fields from being misinterpreted as MOQ data
- Rename firstLine() to firstWord() to match its actual behavior (splits
  by whitespace, not newlines)
- Add missing "单" unit to item.ts extractSalesText regex
- Add test case verifying hover_price_text is not used for MOQ
2026-04-04 14:53:42 +08:00
GanFanNewOrder 81de69be3a feat(1688): add browser adapter and docs (#650)
* feat(1688): add browser adapter and docs

* fix(1688): retry alternate store seed offers

* feat(1688): harden adapter contracts and search pagination

---------

Co-authored-by: 泽加武 <zejiawu@zejiawudeMac-mini.local>
2026-04-04 14:45:32 +08:00
jakevin a39a858f0a feat(autoresearch): improve operate success rate + complex publish chains (#753)
* chore(autoresearch): format save-tasks.json

* feat(autoresearch): add Layer 5 Publish testing for twitter/zhihu

New eval-publish.ts tests end-to-end content creation via operate commands:
- 7 tasks: 5 fill-only (safe) + 2 publish (post + delete)
- Twitter: compose fill, reply fill, post+delete, cross-site HN→tweet
- Zhihu: answer fill, article fill (title+body), cross-site HN→answer
- Supports --type fill-only/publish and --platform twitter/zhihu filters
- Cleanup steps auto-delete published content after verification
- fill-only: 5/5 passing

* feat(autoresearch): improve operate success rate + complex publish chains

Iteration round 1 results:
- Browse: 50/59 → 58/59 (+8) — fixed 8 broken selectors, 1 remaining (DDG images anti-crawl)
- Publish fill-only: 5/5 → 12/13 → 13/13 — added 8 complex tasks, fixed selectors
- Save as CLI: 26/26 (maintained)

Changes:
- browse-tasks.json: fix 8 broken selectors (iana, github, quotes, trending, google, wiki, npm, httpbin)
- publish-tasks.json: add 8 complex multi-step tasks (thread compose, quote RT, search→reply, cross-platform)
- skills/opencli-operate/SKILL.md: add Common Pitfalls section, improve save-as-CLI guidance
- Fix twitter thread compose (use querySelectorAll for 2nd textarea)
- Fix zhihu editor selectors (WriteIndex-titleInput, contenteditable)
2026-04-04 14:37:40 +08:00
Kyrie Cai 855eaee04e fix(zhihu): make question runtime-compatible (#732)
* fix(zhihu): make question runtime-compatible

* fix: validate questionId is numeric to prevent interpolation issues

* refactor: simplify evaluate string and harden against injection

- Build URL in Node.js, embed via JSON.stringify for safety-by-design
- Remove unnecessary (page as any) cast — IPage already has evaluate
- Simplify error message construction (no nested ternaries)
- Replace implementation-detail test with numeric ID validation test

* refactor: simplify zhihu question — move stripHtml into evaluate, return clean data

* fix: add colon separator in fetch error message for readability

"request failed Failed to fetch" → "request failed: Failed to fetch"

---------

Co-authored-by: Kyrie <kyrie@mallab.world>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 14:36:27 +08:00
ykfnxx 1bcd96f38a fix(douban): fix marks pagination and improve subject data extraction (#752)
1. marks: correct pageSize from 30 to 15 — douban grid mode shows 15
   items per page, causing pagination to stop after the first page.

2. subject: split title/originalTitle correctly — v:itemreviewed contains
   both Chinese and original titles concatenated.

3. subject: extract country/region from #info as list, split by "/".

4. subject: extract duration as pure number (min) from v:runtime or #info.

5. subject: return casts as list instead of comma-joined string.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-04 14:32:51 +08:00
jakevin c2ac5525b3 chore(autoresearch): format save-tasks.json (#750) 2026-04-04 02:12:26 +08:00
jakevin 748b09261d fix: handle missing electron executable gracefully (#747)
* fix: handle missing electron executable gracefully

* fix: support antigravity electron executable fallback
2026-04-04 02:03:30 +08:00
jakevin 4b1153babe docs: remove duplicated root cli workflow guides (#748) 2026-04-04 01:57:30 +08:00
jakevin 7aafd4af59 fix(tests): update mocks for resolveBvid and Windows platform guards (#749)
- bilibili subtitle/comments tests: use importOriginal to include
  resolveBvid in utils mock
- comments test: use valid BV ID format for aid-resolution error test
- launcher test: skip pgrep test on win32 (detectProcess early-returns)
2026-04-04 01:43:42 +08:00
deepziyu a5abd3769f fix(launcher): graceful degradation and manual CDP override for Windows (#744)
* fix(windows): graceful degradation and manual CDP override for Electron apps

* fix: validate OPENCLI_CDP_ENDPOINT with probeCDP before use

Fail-fast with a clear error if the manual CDP endpoint is not reachable,
instead of passing a bad URL downstream and getting a confusing error.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 01:32:55 +08:00
sa1ka 8070960444 feat(bilibili): support b23.tv short URL/short code resolution (#740)
* feat(bilibili): support b23.tv short URL/short code resolution

Add resolveBvid() in utils.ts to automatically resolve b23.tv short URLs
and short codes to BV IDs. Supports all input formats:
- BV ID: BV1MV9NBtENN (pass through)
- Short code: XYzsqGa
- Short URL: https://b23.tv/XYzsqGa, b23.tv/XYzsqGa

Uses Node.js https.get with 302 redirect only (no body download),
typically ~100-250ms resolution time.

Applied to: subtitle, comments, download commands.

* fix: add timeout, input coercion, and tests for resolveBvid

- 5s timeout on https.get to prevent hanging on unresponsive b23.tv
- Accept unknown input type with String() coercion
- Simplify callers (remove redundant String().trim() wrappers)
- Add unit tests for BV ID passthrough and edge cases

---------

Co-authored-by: chenruinian <chenruinian@Sa1kas-MacBookPro.local>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-04 01:30:23 +08:00
jakevin b1c0bcb464 feat(autoresearch): add Layer 4 Save-as-CLI eval with zhihu/xhs coverage (#741)
* feat(autoresearch): add Layer 4 "Save as CLI" eval + fix operate verify

- New eval-save.ts: tests full init → write → verify pipeline (14 tasks)
- 8 PUBLIC strategy tasks (httpbin, jsonplaceholder, HN, wiki, lobsters, devto)
- 6 COOKIE strategy tasks (zhihu hot/search/question, xhs feed/search/note)
- New save-reliability preset for autoresearch engine iteration
- Fix: operate verify no longer hardcodes --limit 3 for adapters without limit arg
- Rename sediment → save throughout

* experiment(operate): 两个新任务都基于已有通过任务使用的同一 API,期望 pass_count 从 14 → 16。

* experiment(operate): Added 2 new tasks ( and ) that use the exact same APIs already proven to pass in exis

* experiment(operate): Both new tasks pass. The change adds 2 more  tasks ( and ) using the same proven API, i

* fix(autoresearch): rename SedimentTask → SaveTask, fix bracket indent, gitignore results.tsv

* refactor(autoresearch): complex multi-step save tasks + adapterFile support

- Replace simple COOKIE tasks with 6 complex multi-step chains:
  - zhihu: hot+top-answer (6-step), search+question-stats (7-step), question+answers+related (8-step)
  - xhs: search+scroll+dedup (6-step), note+comments (7-step), explore+scroll+sort (8-step)
- Move complex adapter code to save-adapters/*.ts files (avoids JSON escape issues)
- eval-save.ts: support adapterFile field to read adapter from file
- Preset scope now includes skills/opencli-operate/SKILL.md for skill improvement
- All 20/20 tasks passing

* experiment(save): add hn-best and hn-jobs tasks using proven Firebase API pattern, pass_count 20→22

* fix(autoresearch): increase Claude Code timeout 180s → 300s to reduce ETIMEDOUT failures

* experiment(save): add restcountries and nager-holidays tasks using stable public APIs, pass_count 22→24
2026-04-04 01:27:50 +08:00
Josh e18e0ed7a4 fix(browser): mention Chromium in Browser Bridge hints (#738) 2026-04-03 22:28:16 +08:00
jakevin c161f0f9f0 feat: auto-downgrade output to YAML in non-TTY (#737)
* feat: auto-downgrade table output to YAML in non-TTY environments

When stdout is not a TTY (pipes, AI agents, subprocesses), automatically
output YAML instead of table with ANSI colors and box-drawing characters.
This makes opencli output parseable by downstream tools and AI agents.

Behavior:
- TTY: table (default, unchanged)
- Non-TTY: yaml (auto-detected)
- OUTPUT env var: overrides auto-detection (yaml/json/table/etc)
- Explicit -f flag: always respected

* fix: TTY detection now works with commanderAdapter default fmt

- fmt='table' from commanderAdapter now correctly triggers non-TTY downgrade
- Priority: explicit -f (non-table) > OUTPUT env var > TTY auto-detect
- Added test for explicit -f precedence over OUTPUT env var

* fix: explicit -f flag now takes precedence over TTY auto-detection

Use Commander's getOptionValueSource to distinguish explicit -f from
default. Explicit -f table in non-TTY keeps table output. Only auto-
downgrade when user didn't pass -f.

Priority: explicit -f > OUTPUT env var > TTY auto-detect > table default

* fix: explicit -f also skips command defaultFormat override

When user passes -f explicitly, command-level defaultFormat (e.g.
gemini/ask defaultFormat:'plain') no longer overrides their choice.
2026-04-03 22:26:51 +08:00
GanFanNewOrder dcad060230 feat(amazon): unify ranking commands for bestsellers/new-releases/movers-shakers (#724)
* feat(amazon): unify ranking adapters for three signal boards

* refactor: simplify bestsellers wrapper and fix pagination detection for all ranking types

1. Remove unnecessary __test__ wrapper from bestsellers.ts — the test
   now uses normalizeRankingCandidate directly from rankings.ts,
   eliminating a needless indirection layer.

2. Fix isRankingPaginationUrl to detect pagination refs for all ranking
   types: zg_bs_pg_ (bestsellers), zg_bsnr_pg_ (new releases),
   zg_bsms_pg_ (movers & shakers). Previously only matched the
   bestsellers-specific ref pattern.

---------

Co-authored-by: 泽加武 <zejiawu@zejiawudeMac-mini.local>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-03 19:12:59 +08:00
jakevin ff84d19ded fix: SVG className crash + viewport expansion + test suites (#733)
* feat: AutoResearch framework + V2EX test suite (40 tasks)

AutoResearch framework (Karpathy-style autonomous iteration):
- engine.ts: 8-phase loop (review → modify → commit → verify → guard → decide → log)
- config.ts: typed config + CLI parser + metric extraction
- logger.ts: TSV append-only results log
- commands/run.ts: main loop spawning Claude Code per iteration
- commands/plan.ts: interactive config wizard
- commands/fix.ts: auto-detect broken state, iteratively fix
- commands/debug.ts: hypothesis-driven debugging for failing tasks

V2EX test suite (5 layers, 40 tasks):
- L1 Atomic (10): open, state, click, scroll, eval, back, wait
- L2 Single Page (10): hot topics, node list, topic meta, pagination
- L3 Multi-Step (10): click-read, navigate-node, tab-then-topic, pagination
- L4 Write Ops (5): reply typing, favorite detection, form detection
- L5 Complex Chain (5): cross-page collect, multi-node compare, full workflow

Presets: operate-reliability, skill-quality, v2ex-reliability

* test: V2EX test suite 60/60 — fix selectors, add harder tasks

- Fix v2ex-collect-hot-authors selector (pathname-based member link detection)
- Fix v2ex-wait-text judge (accept "appeared")
- Fix trailing commas in eval step strings
- Add 20 harder tasks: state+click interaction + long chain workflows
- Baseline: 60/60 across all layers

* feat: Zhihu test suite — 60 tasks across 8 layers, 60/60 passing

Knowledge-intensive Chinese Q&A site (React SPA, lazy loading, complex DOM):

- L1 Atomic (10): open, state, title, url, scroll, tab, back, wait, keys, screenshot
- L2 Feed (8): feed titles, hot list, metrics, tabs, authors, content types, avatar, search
- L3 Question (8): title, meta, answer, votes, buttons, descriptions, answer count
- L4 Navigation (8): hot→question, feed→question, author profile, search, topic, user, back
- L5 Write (6): upvote/follow/comment/bookmark/write-answer/share button detection
- L6 Chain (8): read-answer-author, author-profile, multi-hot, search-then-read, scroll-answers
- L7 Search (6): basic, people, topic, click-result, filter, back
- L8 Complex (6): full workflow, deep author chain, cross-question, search-read, 3-page, scroll-deep

Key fixes during development:
- Zhihu search page needs 5s+ wait (SPA lazy loading)
- Back navigation goes to about:blank (daemon init page), fixed with direct navigate
- User profile answers page needs 4s wait for content
- Broader selectors needed (h2 a instead of specific class names)

* feat: combined eval-all runner + combined-reliability preset

* experiment(operate): fix extract-npm-description + nav-click-link-example

Round 1: Fix 2 remaining browse-tasks failures:
- extract-npm-description: use generic <p> selector instead of class-based
- nav-click-link-example: include URL in output (title is 'Example Domains', not 'IANA')

* experiment(operate): fix bench-imdb-matrix — use broader selectors for year/rating

Round 2: IMDB page selectors were too specific (data-testid changed).
Use generic h1 for title, link text match for year, broader class match for rating.

* experiment(operate): add edge cases + fix SPA navigation timing

Round 3: Add 10 edge case tasks (5 V2EX + 5 Zhihu):
- rapid-navigate: 3 consecutive opens
- eval-after-click: verify URL changes after SPA click
- scroll-and-extract: extract after deep scroll
- structured extraction: multi-field JSON from dynamic content
- lazy-load answers: scroll triggers more content

Key finding: Zhihu SPA click() doesn't update location.pathname
immediately. Use window.location.href = a.href for reliable navigation.

V2EX: 65/65, Zhihu: 65/65, Browse: 59/59 = 189/189

* experiment(operate): add agent-style tasks using state+click+type (no eval for interaction)

Round 4-5: Add 5 tasks that test the actual agent workflow:
- agent-click-first-topic: find topic index via data-opencli-ref
- agent-type-search: type into search using state index
- agent-click-navigate-back: click by ref, verify navigation
- agent-state-has-interactive: verify state output format
- agent-state-after-scroll: verify scroll position in state

V2EX: 70/70 tasks

* fix: review fixes — extractVerdict, stderr, dead code

- eval-skill.ts: remove dead TASKS_FILE variable (skill-tasks.yaml never existed)
- eval-skill.ts: rewrite extractVerdict to use brace-counting JSON.parse
  instead of regex (handles escaped quotes in explanation)
- eval-browse.ts: include stderr in runCommand error output for debuggability

* fix: SVG className crash in dom-snapshot + viewport expansion

Critical bug: isSearchElement() called el.className.toLowerCase() which
crashes on SVG elements where className is SVGAnimatedString (not a string).
This caused the entire DOM snapshot to fail and fall back to the basic
accessibility tree, losing ALL interactive element indices.

Fix: use typeof check + baseVal fallback for SVG className.

Also:
- Increase viewportExpand from 800 to 2000 (covers ~3 screens)
- Add DEBUG_SNAPSHOT env var for snapshot failure debugging

Impact on Zhihu hot page:
- Before: 50 interactive elements (accessibility tree fallback), 1/30 hot links indexed
- After: 597 interactive elements (proper DOM snapshot), 19/30 hot links indexed
2026-04-03 19:01:10 +08:00
jakevin f594e500a8 feat: AutoResearch framework + V2EX/Zhihu test suites (194/194) (#731)
* feat: AutoResearch framework + V2EX test suite (40 tasks)

AutoResearch framework (Karpathy-style autonomous iteration):
- engine.ts: 8-phase loop (review → modify → commit → verify → guard → decide → log)
- config.ts: typed config + CLI parser + metric extraction
- logger.ts: TSV append-only results log
- commands/run.ts: main loop spawning Claude Code per iteration
- commands/plan.ts: interactive config wizard
- commands/fix.ts: auto-detect broken state, iteratively fix
- commands/debug.ts: hypothesis-driven debugging for failing tasks

V2EX test suite (5 layers, 40 tasks):
- L1 Atomic (10): open, state, click, scroll, eval, back, wait
- L2 Single Page (10): hot topics, node list, topic meta, pagination
- L3 Multi-Step (10): click-read, navigate-node, tab-then-topic, pagination
- L4 Write Ops (5): reply typing, favorite detection, form detection
- L5 Complex Chain (5): cross-page collect, multi-node compare, full workflow

Presets: operate-reliability, skill-quality, v2ex-reliability

* test: V2EX test suite 60/60 — fix selectors, add harder tasks

- Fix v2ex-collect-hot-authors selector (pathname-based member link detection)
- Fix v2ex-wait-text judge (accept "appeared")
- Fix trailing commas in eval step strings
- Add 20 harder tasks: state+click interaction + long chain workflows
- Baseline: 60/60 across all layers

* feat: Zhihu test suite — 60 tasks across 8 layers, 60/60 passing

Knowledge-intensive Chinese Q&A site (React SPA, lazy loading, complex DOM):

- L1 Atomic (10): open, state, title, url, scroll, tab, back, wait, keys, screenshot
- L2 Feed (8): feed titles, hot list, metrics, tabs, authors, content types, avatar, search
- L3 Question (8): title, meta, answer, votes, buttons, descriptions, answer count
- L4 Navigation (8): hot→question, feed→question, author profile, search, topic, user, back
- L5 Write (6): upvote/follow/comment/bookmark/write-answer/share button detection
- L6 Chain (8): read-answer-author, author-profile, multi-hot, search-then-read, scroll-answers
- L7 Search (6): basic, people, topic, click-result, filter, back
- L8 Complex (6): full workflow, deep author chain, cross-question, search-read, 3-page, scroll-deep

Key fixes during development:
- Zhihu search page needs 5s+ wait (SPA lazy loading)
- Back navigation goes to about:blank (daemon init page), fixed with direct navigate
- User profile answers page needs 4s wait for content
- Broader selectors needed (h2 a instead of specific class names)

* feat: combined eval-all runner + combined-reliability preset

* experiment(operate): fix extract-npm-description + nav-click-link-example

Round 1: Fix 2 remaining browse-tasks failures:
- extract-npm-description: use generic <p> selector instead of class-based
- nav-click-link-example: include URL in output (title is 'Example Domains', not 'IANA')

* experiment(operate): fix bench-imdb-matrix — use broader selectors for year/rating

Round 2: IMDB page selectors were too specific (data-testid changed).
Use generic h1 for title, link text match for year, broader class match for rating.

* experiment(operate): add edge cases + fix SPA navigation timing

Round 3: Add 10 edge case tasks (5 V2EX + 5 Zhihu):
- rapid-navigate: 3 consecutive opens
- eval-after-click: verify URL changes after SPA click
- scroll-and-extract: extract after deep scroll
- structured extraction: multi-field JSON from dynamic content
- lazy-load answers: scroll triggers more content

Key finding: Zhihu SPA click() doesn't update location.pathname
immediately. Use window.location.href = a.href for reliable navigation.

V2EX: 65/65, Zhihu: 65/65, Browse: 59/59 = 189/189

* experiment(operate): add agent-style tasks using state+click+type (no eval for interaction)

Round 4-5: Add 5 tasks that test the actual agent workflow:
- agent-click-first-topic: find topic index via data-opencli-ref
- agent-type-search: type into search using state index
- agent-click-navigate-back: click by ref, verify navigation
- agent-state-has-interactive: verify state output format
- agent-state-after-scroll: verify scroll position in state

V2EX: 70/70 tasks

* fix: review fixes — extractVerdict, stderr, dead code

- eval-skill.ts: remove dead TASKS_FILE variable (skill-tasks.yaml never existed)
- eval-skill.ts: rewrite extractVerdict to use brace-counting JSON.parse
  instead of regex (handles escaped quotes in explanation)
- eval-browse.ts: include stderr in runCommand error output for debuggability
2026-04-03 17:14:38 +08:00
Ted Li f2a3ee6ee4 fix(doubao): preserve image URLs in read output (#708)
* fix doubao image urls in read output

* fix(doubao): derive image selector from messageTextSelectors

Hardcoded image selector only covered the first two text selectors,
so images inside class-based message containers would be missed.
Generate from the shared selector list for consistency.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-03 17:08:33 +08:00
tiaot33 f377ec000c feat(元宝): add browser adapter and docs (#693)
* feat(yuanbao): add browser adapter and docs

* refactor(yuanbao): normalize adapter failures to CliError

* refactor: extract shared yuanbao helpers to reduce duplication

Move isOnYuanbao, ensureYuanbaoPage, hasLoginGate, authRequired,
and IS_VISIBLE_JS to shared.ts. This eliminates identical copies
across ask.ts and new.ts, reducing correctness risk when modifying
shared logic.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-03 17:03:48 +08:00
jakevin 988908f348 refactor(xiaohongshu): replace blind retry with MutationObserver wait (#730)
* refactor(xiaohongshu): replace blind retry with MutationObserver wait

Instead of retrying the entire navigation when search results are empty,
use a MutationObserver to wait for `section.note-item` elements (or login
wall text) to appear in the DOM, with a 5s timeout. This is faster (resolves
as soon as content renders) and more correct (addresses the root cause of
delayed hydration rather than working around it with a full re-navigation).

* simplify: merge login-wall detection into MutationObserver wait

WAIT_FOR_CONTENT_JS now returns 'content', 'login_wall', or 'timeout'
instead of just true/false. This eliminates the separate login-wall
evaluate call and the redundant loginWall field in the extraction payload.
Two evaluate calls total (wait + extract) instead of three.
2026-04-03 16:40:33 +08:00
GanFanNewOrder 2b623b35b6 fix(xiaohongshu): retry once on intermittent empty first paint (#681)
Co-authored-by: 泽加武 <zejiawu@zejiawudeMac-mini.local>
2026-04-03 16:26:26 +08:00
jakevin 6cdcb9dd51 fix: add prepare script so source installs trigger build (#729)
* fix: add prepare script so source installs trigger build

npm install from git (e.g. npm install github:jackwener/opencli) skips
prepublishOnly, so dist/ is never generated. The prepare hook runs on
git-based installs; the [ -d src ] guard skips it for registry installs.

* fix: include extension/dist in git so clone works out of the box

.gitignore had conflicting rules: line 3 tried to un-ignore extension/dist/
but line 26 re-ignored it. Remove the later rule so the built extension JS
is tracked in git — users can load the extension directly after clone.
2026-04-03 16:23:05 +08:00
BruceLoveDecimal 835c146fb7 fix(doubao-app): connect to correct CDP target instead of background … (#674)
* fix(doubao-app): connect to correct CDP target instead of background page

Doubao desktop app exposes multiple CDP targets. The scoring logic picked
the background page (doubao-background) over the actual chat page because
its URL-as-title contained "doubao", boosting its score above the real
chat page (title "豆包"). This caused all commands (send, ask, read) to
fail with "No textarea found".

- Add `targetFilter` field to ElectronAppEntry for per-app preferred target
- Set doubao-app targetFilter to 'doubao-chat/chat'
- Penalize background/new-tab-page URLs and URL-like titles in scoring
- Thread cdpTargetFilter through execution → runtime → CDPBridge

Closes #634, closes #506

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

* refactor(cdp): exclude background targets instead of targetFilter

Replace the targetFilter plumbing (4 files, new interface field) with
a single-line fix: exclude `background_page` and `service_worker`
type targets from CDP selection entirely.

Background pages should never be connection targets — they have no
visible DOM and all selectors will fail. This is the root cause of
#506/#634 (doubao-app connecting to empty background page).

Simpler fix: 1 line added vs 4 files modified. No new interface
fields, no per-app configuration needed.

---------

Co-authored-by: 刘启灏 <liuqihao@liuqihaodeMacBook-Pro.local>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-03 12:52:31 +08:00
jakevin fc818b3c2c fix: classify xianyu item auth and blocked states (#726)
* fix: classify xianyu item auth and blocked states

* fix: classify xianyu item auth and blocked states
2026-04-03 12:50:48 +08:00
BruceLoveDecimal 0ce46b15bb feat:add xianyu (#696)
* feat:add xianyu

feat:add xianyu

feat:add xianyu

* chore:add xianyu docs

* fix:update xianyu after review

---------

Co-authored-by: 刘启灏 <liuqihao@liuqihaodeMacBook-Pro.local>
2026-04-03 12:30:28 +08:00
jakevin 37f1b46a77 feat: AutoResearch framework + V2EX test suite (60 tasks, SKILL.md optimization) (#717)
* feat: AutoResearch framework + V2EX test suite (40 tasks)

AutoResearch framework (Karpathy-style autonomous iteration):
- engine.ts: 8-phase loop (review → modify → commit → verify → guard → decide → log)
- config.ts: typed config + CLI parser + metric extraction
- logger.ts: TSV append-only results log
- commands/run.ts: main loop spawning Claude Code per iteration
- commands/plan.ts: interactive config wizard
- commands/fix.ts: auto-detect broken state, iteratively fix
- commands/debug.ts: hypothesis-driven debugging for failing tasks

V2EX test suite (5 layers, 40 tasks):
- L1 Atomic (10): open, state, click, scroll, eval, back, wait
- L2 Single Page (10): hot topics, node list, topic meta, pagination
- L3 Multi-Step (10): click-read, navigate-node, tab-then-topic, pagination
- L4 Write Ops (5): reply typing, favorite detection, form detection
- L5 Complex Chain (5): cross-page collect, multi-node compare, full workflow

Presets: operate-reliability, skill-quality, v2ex-reliability

* test: V2EX test suite 60/60 — fix selectors, add harder tasks

- Fix v2ex-collect-hot-authors selector (pathname-based member link detection)
- Fix v2ex-wait-text judge (accept "appeared")
- Fix trailing commas in eval step strings
- Add 20 harder tasks: state+click interaction + long chain workflows
- Baseline: 60/60 across all layers

* docs: optimize SKILL.md for efficiency — aggressive chaining, minimize turns

- Add Rule #7: minimize total tool calls (3-5 per task, not 15-20)
- Strengthen Rule #5: chain aggressively with &&
- Add explicit good/bad chaining examples
- Add click+wait+state chaining pattern
- Add type+verify chaining pattern

Before: 21 turns for complex V2EX reply task
After: 12 turns for same task (-43% turns, -28% cost)
2026-04-03 11:31:22 +08:00
jakevin 2d005d14a8 fix: recover drifted tabs instead of abandoning them (#652) (#715)
When other Chrome extensions (tab managers, new-tab overrides) move
automation tabs to a different window, the Browser Bridge now attempts
to move the tab back to the automation window rather than creating a
new one. This preserves the existing page state and avoids redundant
navigation.

Changes:
- resolveTab(): when a provided tabId has drifted to another window but
  content is still debuggable, use chrome.tabs.move() to bring it back
- handleNavigate(): after navigation completes, detect if the tab drifted
  during navigation and move it back to the session window
- cdp.ts ensureAttached(): log final tab URL and windowId on attach
  failure for better diagnosis of extension conflicts

Closes #652 (partially — addresses tab drift recovery and diagnostics)
2026-04-03 03:48:13 +08:00
jakevin 1708626731 fix: update BrowserBridge test to mock fetchDaemonStatus instead of isDaemonRunning (#714)
PR #712 refactored _ensureDaemon to use a single fetchDaemonStatus() call
instead of separate isDaemonRunning(). The test was still mocking the old
function, causing it to fall through to the spawn-daemon path and throw
the wrong error message.
2026-04-03 03:44:56 +08:00
jakevin 5fe081b28c perf: optimize browser pipeline — tab query dedup, parallel stealth, incremental snapshots (#713)
* perf: optimize browser pipeline — tab query dedup, parallel stealth, incremental snapshots

- resolveTab() now returns { tabId, tab } so handleNavigate skips redundant chrome.tabs.get()
- goto() fires stealth injection in parallel with navigation instead of sequentially
- snapshot() passes previousHashes to enable incremental diff marking on consecutive calls

* revert: remove stealth parallelization — simplicity over performance
2026-04-03 03:32:24 +08:00
jakevin 0c75ab3f7e perf: reduce round-trips in browser command hot path (#712)
1. eval retry delay: 1000ms → 200ms for SPA navigation errors, 500ms
   for debugger detach. SPA navigations recover within ~100ms, the old
   1000ms delay was unnecessarily long.

2. Window creation: replace fixed 200ms sleep with tab-load poll.
   Listens for chrome.tabs.onUpdated status=complete with 500ms
   fallback cap. about:blank loads in ~20ms, saving ~180ms.

3. bridge.ts _ensureDaemon: single fetchDaemonStatus() call instead of
   two sequential calls (isExtensionConnected + isDaemonRunning both
   called fetchDaemonStatus independently). Saves one HTTP round-trip.

4. goto() post-navigation: coalesce stealth injection + DOM settle into
   a single exec call. Previously two sequential round-trips
   (Node→daemon→WS→extension→CDP each). Saves ~60-160ms per goto().
2026-04-03 03:24:54 +08:00
NullCode 017cbc5692 docs: add rubysec plugin example (#699)
Co-authored-by: NullCode <20016311+nullptrKey@users.noreply.github.com>
2026-04-03 02:59:50 +08:00
jakevin cd5da59187 perf: skip blank page on first browser command (#710)
Two changes that eliminate the about:blank → target-domain navigation
on first command execution:

1. Extension: getAutomationWindow() accepts an optional initialUrl.
   When creating a new window, uses the target URL directly instead
   of about:blank. handleNavigate() passes cmd.url through so the
   window starts on the correct domain.

2. CLI: Remove isAlreadyOnDomain() check before pre-nav. Instead,
   always call page.goto(preNavUrl) — the extension's handleNavigate
   already has a fast-path that skips navigation when the tab is
   already at the target URL. This avoids an extra exec round-trip
   (getCurrentUrl eval) on first command.

Net effect: first command saves ~1-3s (one fewer page load),
subsequent commands behave the same (navigate fast-path handles
domain matching efficiently via chrome.tabs.get).
2026-04-03 02:59:15 +08:00
jakevin d7d5211fde refactor: remove unused newTab() and closeTab() from IPage interface (#709)
Both methods had zero production callers — only test mocks referenced them.
newTab() created about:blank pages via CDP Target.createTarget, but no
adapter or pipeline step ever invoked it. closeTab() was similarly unused.

selectTab() and tabs() are kept as they have active production usage
(e.g. doubao adapter). The scoreTarget about:blank penalty is retained
as a defensive measure against user-opened blank tabs.
2026-04-03 02:42:03 +08:00
jakevin de817730ca feat: Browser Use best practices — click/type/state improvements (#707)
* docs: improve operate skill with Browser Use best practices

- Add Critical Rules section (state over screenshot, verify with get value)
- Add Command Cost Guide (free/instant vs expensive vision tokens)
- Add Action Chaining Rules (safe to chain vs page-changing)
- Add Tips section
- Fix Core Workflow to use state/get value for verification, not screenshot
- Mark screenshot as "ONLY for user deliverables"

Inspired by Browser Use's design: DOM-first state representation,
action cost awareness, and multi-action chaining patterns.

* docs: fix operate skill — eval read-only, IIFE, interaction rules

- Add rule: NEVER use eval to click/type — use click/type/select commands
  (eval bypasses scrollIntoView + CDP pipeline, fails on off-screen elements)
- Add rule: eval is read-only, always wrap in IIFE to avoid variable conflicts
- Reorder Critical Rules for priority
- Add IIFE example in Extract section

Root cause: Claude Code was using eval("el.click()") instead of
click <index>, and hitting "already declared" errors from repeated
eval calls in the same page context.

* feat: Browser Use best practices — click/type/state improvements

Inspired by deep analysis of Browser Use's design patterns:

1. Framework listener detection (React/Vue/Angular)
   - Detect __reactProps$ onClick, Vue _vei, Angular ng-reflect-click
   - Catches <div onClick> elements that pure ARIA/tag heuristics miss

2. Click CDP fallback
   - clickJs() now returns coordinates on failure
   - BasePage.click() falls back to CDP Input.dispatchMouseEvent
   - Page.clickWithQuads() uses DOM.getContentQuads for inline elements

3. Type improvements
   - React-compatible: use native HTMLInputElement.prototype.value setter
   - Contenteditable: selectAll + execCommand('insertText') for rich editors
   - Autocomplete: detect role=combobox, wait 400ms for dropdown suggestions

4. getContentQuads precise click
   - Page.clickWithQuads() for multi-line inline elements (e.g. wrapped <a>)
   - Falls back through getContentQuads → getBoxModel → JS click

* fix: address code review — injection, silent failure, setter prototype

1. clickWithQuads: escape ref with JSON.stringify before inserting into
   JS strings and CSS selectors (injection risk)
2. base-page click: throw error when both JS click and CDP fallback fail
   instead of silently succeeding
3. typeTextJs: use matching prototype for native setter
   (HTMLTextAreaElement for textarea, HTMLInputElement for input)
2026-04-03 02:38:49 +08:00
Flo 9cdbcd3066 docs: add opencli-plugin-vk to plugins list (#350) 2026-04-03 01:49:33 +08:00
jakevin b113885dde docs: remove Why opencli, merge advantages into Highlights, add operate quickstart (CN) (#706)
* docs: remove Why opencli section, merge advantages into Highlights, add operate quickstart to CN README

- Remove "Why opencli?" / "为什么选 opencli?" sections from both READMEs
- Incorporate Zero LLM cost, Deterministic, Broad coverage bullets into Highlights
- Add operate command mention to AI Agent ready highlight
- Add browser automation / operate quickstart section to README.zh-CN.md (mirrors English README)

* docs: update Built for AI Agents paragraph, add browser automation and website→CLI to Highlights, remove Dual-Engine

- Rewrite "Built for AI Agents" to emphasize operate skill + browser control + crystallizing into CLIs
- Add "Browser Automation" and "Website → CLI" bullets to Highlights (both EN and CN)
- Remove "Dual-Engine Architecture" bullet from EN Highlights
- Remove "动态加载引擎" from CN Highlights (already covered by other bullets)

* docs: remove human quickstart from operate section, AI-only
2026-04-03 01:46:48 +08:00
tiaot33 ef449058aa docs(skills): add smart-search skill (#689)
* docs(skills): add smart-search skill

* docs(skill): tighten smart-search routing rules
2026-04-03 01:46:05 +08:00
jakevin 706e01dbca docs: fix outdated adapter counts, missing commands and adapters (#704)
* docs: fix outdated adapter counts, missing commands, and absent adapters

- Update version 1.6.0 → 1.6.1 in skills/opencli-usage/SKILL.md
- Update site count 70+ → 73+ across README.md, README.zh-CN.md,
  docs/comparison.md
- Remove non-existent adapters (kimi, deepseek, qwen) from SKILL.md
- Add missing commands for xiaohongshu (+note, comments, download,
  publish), weibo (+search, feed, user, me, post, comments),
  jike (+post, topic, user), linux-do (+hot, latest, category),
  doubao (+detail, history, meeting-summary, meeting-transcript),
  weread (+notebooks), chatgpt (+model), wikipedia (+random, trending),
  stackoverflow (+unanswered), producthunt (fix command list)
- Add entirely missing adapters: band, zsxq, bluesky, douyin, 36kr,
  ones, tieba, gemini, notebooklm, imdb, spotify, paperreview
- Update docs/adapters/index.md with same fixes
- Add opencli-operate to Related Skills section

* docs: second-pass audit fixes — deeper inconsistencies

Skills sub-files (browser.md, public-api.md):
- Remove phantom kimi/deepseek/qwen adapters (no src/clis/ dirs)
- Replace with real gemini and notebooklm sections
- Add missing weibo commands (search, feed, user, me, post, comments)
- Add missing xiaohongshu commands (note, comments, download, publish)
- Add missing doubao commands (detail, history, meeting-summary, meeting-transcript)
- Add 7 entirely missing adapter sections: bluesky, douyin, band, zsxq,
  tieba, 36kr, ones
- Fix producthunt: remove non-existent week/month/search, add hot/browse/posts
- Add wikipedia random and trending

SKILL.md command table:
- Add twitter `likes`, xueqiu `comments`, douban `movie-hot`/`book-hot`
- Add entirely missing `amazon` adapter
- Add linux-do `latest`
- Remove producthunt non-existent `search`

Individual adapter docs:
- docs/adapters/browser/weibo.md: add 5 missing commands
- docs/adapters/browser/doubao.md: add 4 missing commands
- docs/adapters/browser/wikipedia.md: add random and trending
- docs/adapters/browser/36kr.md: fix contradictory prerequisites
- docs/adapters/index.md: add twitter `likes`
- docs/developer/contributing.md: add missing `positional: true`
- package.json: fix description to include "Electron App"
2026-04-03 01:05:47 +08:00
jakevin ba67a3e086 docs: add individual skill install examples to README (#702)
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
Root SKILL.md was already removed in #703. Add per-skill install
commands to both EN and CN READMEs (without --full-depth since
root SKILL.md no longer blocks sub-skill discovery).
2026-04-03 00:23:56 +08:00
jakevin ed1a61a445 chore: remove root SKILL.md, simplify README skill install (#703)
Root SKILL.md is redundant — skills/ directory (opencli-operate,
opencli-explorer, opencli-oneshot, opencli-usage) handles discovery.
Simplified README to single install command.
2026-04-03 00:12:31 +08:00
jakevin fe82b3882f docs: update outdated adapter counts, operate commands, and skill references (#701)
- Update adapter count from 50+/60+/66+ to 70+ across all docs (actual: 74 sites)
- Add missing operate commands (eval, network, init, verify) to README
- Add opencli-operate skill to Install AI Skills section in both READMEs
- Replace outdated "Playwright MCP Bridge" with "Browser Bridge" in doubao docs
2026-04-02 23:32:36 +08:00
jakevin 4d036a5364 chore: release v1.6.1 (#700) 2026-04-02 22:45:41 +08:00
jakevin a23de8fe7d fix: sync package-lock.json version to 1.6.0 (#698)
The v1.6.0 release commit bumped package.json but not package-lock.json,
causing bun/npm install failures due to version mismatch.
2026-04-02 22:39:09 +08:00
sline b8f1abc3a1 fix(twitter): use search input for SPA navigation instead of pushState (#695)
* fix(twitter): add search input fallback for intermittent SPA navigation failures

The pushState + popstate approach works in most environments but fails
intermittently for some users (see #690), likely due to Twitter A/B
tests or timing race conditions where the pathname hasn't updated when
checked.

This commit adds a fallback strategy: when pushState fails after 2
retries, we type the query into the search input on /explore and press
Enter. This triggers Twitter's own form handler, performing SPA
navigation without a full page reload (keeping the fetch interceptor
alive).

Both strategies use selector-based waiting ([data-testid="primaryColumn"])
rather than fixed delays, with graceful fallthrough on timeout.

Fixes #690

* test(twitter): update search test for fallback evaluate call

The search input fallback adds one extra evaluate() call when pushState
fails. Update the mock chain and assertion count accordingly.

* fix(twitter): guard nativeSetter and add fallback success test

- Add optional chaining on getOwnPropertyDescriptor().set to handle
  edge cases where Twitter's sandbox overrides the HTMLInputElement
  prototype.
- Add test case covering the full fallback path: pushState fails twice,
  search input fallback succeeds, results are returned correctly.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-02 22:27:48 +08:00
jakevin aa3edfefc0 chore: release v1.6.0 (#697)
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-04-02 22:14:23 +08:00
jakevin b657c946a2 fix(skills): add YAML frontmatter for discovery and improve descriptions (#694)
* fix(skills): add YAML frontmatter for discovery and improve descriptions

- opencli-explorer: add missing frontmatter with name, description, tags
- opencli-oneshot: add missing frontmatter with name, description, tags
- opencli-usage: rewrite description to start with "Use when..." and
  include specific platform names for better keyword matching

Root cause of low trigger rate: explorer and oneshot had no frontmatter
at all, making them invisible to AI agent skill discovery. Usage had a
generic description without triggering conditions.

* fix(skills): add capability index, cross-skill links, and plugins entry

- Add "Quick Lookup by Capability" table so agents can find platforms
  by what they need (search, trending, feed, AI chat, finance, etc.)
- Add plugins.md entry to main index (was completely hidden)
- Add "Related Skills" section linking to opencli-explorer and
  opencli-oneshot for adapter development
- Compress platform listings for scannability

* fix(skills): inline compact command quick-reference table in SKILL.md

Add a self-contained command reference table directly in SKILL.md so
agents that can only read the main skill file still have full command
visibility. Each platform gets one row with all available commands.
Organized into Browser/Desktop/Public API/Management sections.
2026-04-02 22:03:39 +08:00
jakevin bb137ce901 feat: add opencli operate — browser control commands for Claude Code skill (#614)
Add `opencli operate` subcommand group with 15+ commands for
step-by-step browser control, designed as a Claude Code skill.
No LLM API key needed — Claude Code IS the LLM.

Commands:
  Navigation: open, back, scroll
  Inspect: state, screenshot, get (title/url/text/value/html/attributes)
  Interact: click, type, select, keys
  Wait: wait selector/text/time
  Extract: eval (execute JS in page context)
  API Discovery: network (auto-captured since last open, --detail N)
  Sedimentation: init (generate adapter scaffold), verify (test adapter)
  Session: close

Infrastructure:
  - CDP passthrough with 22-method allowlist
  - Two-layer retry for extension interference (aggressive for operate:*)
  - Network interceptor auto-injected on operate open
  - node_modules symlink for user TS adapter imports

Skill: skills/opencli-operate/SKILL.md
  - Complete command reference
  - Sedimentation workflow guide (explore → network → init → verify)
  - Adapter strategy guide (PUBLIC/COOKIE/UI)
  - Dual quickstart (AI Agent 1 step / Human 3 steps)
2026-04-02 19:30:35 +08:00
gucasbrg 7d7203891f fix(twitter): resolve article ID to tweet ID before GraphQL query (#688)
* fix(twitter): resolve article ID to tweet ID before GraphQL query

Article URLs (x.com/i/article/{articleId}) use a different ID than
tweet status URLs. The GraphQL TweetResultByRestId endpoint requires
the parent tweet ID, not the article ID.

Fix: navigate to the article page first, extract the associated tweet
ID from DOM links, then use that for the GraphQL query.

Fixes article fetching returning "Article not found" for all article URLs.

* fix: distinguish article URLs from status URLs, add explicit error handling

The previous commit routed all inputs through the article page, breaking
status URL and bare ID flows. Now only article URLs trigger the
article→tweet ID resolution. Status URLs and bare IDs keep the original
behavior. Also throws an explicit error if resolution fails instead of
silently falling back to the article ID.

---------

Co-authored-by: buruguo <buruguo@lambdafintech.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-02 18:33:51 +08:00
AstroHan 081efe37f7 fix(xiaohongshu): clarify empty note shell hint (#686)
* fix(xiaohongshu): clarify empty note shell hint

* fix(xiaohongshu): simplify empty shell detection to title+author check

The 7-field conjunction was overly strict — a note that rendered only
placeholder metrics but no title/author was still a valid empty shell.
Since title and author are always present on real notes, checking just
those two fields is a more reliable and simpler signal.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-02 18:33:36 +08:00
jakevin 777b882040 refactor: centralize daemon transport client (#692) 2026-04-02 18:28:50 +08:00
luo jiyin eead9e0aa5 docs: add tab completion to getting started guides (#658)
* docs: add tab completion to getting started guide

* docs: add tab completion to zh getting started guide
2026-04-02 16:11:54 +08:00
jakevin a21cc5e9f0 chore: release v1.5.9 (#678)
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-04-02 13:49:10 +08:00
fii6 abd46bccba feat(gemini): add Gemini web adapter with minimal output (#619)
* feat(gemini): add web adapter with minimal output

* fix(gemini): use defaultFormat for minimal output

* fix(gemini): preserve full transcript responses

* docs(gemini): add browser adapter guide

* review: wire gemini into adapter indexes

---------

Co-authored-by: fii6 <246637913+fii6@users.noreply.github.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-02 13:39:35 +08:00
jakevin 098c7f4f92 feat: create skills/ directory structure (#670)
* feat: create skills/ directory structure per issue #605

- Create skills/opencli-usage/ with index and categorized command references
  - SKILL.md: main index with installation and prerequisites
  - browser.md: all browser-based commands (Bilibili, Twitter, Reddit, etc.)
  - desktop.md: desktop adapter commands (Cursor, Codex, Notion, etc.)
  - public-api.md: public API commands (HackerNews, V2EX, arXiv, etc.)
  - plugins.md: management commands, AI workflow, output formats
- Create skills/opencli-explorer/ from CLI-EXPLORER.md
- Create skills/opencli-oneshot/ from CLI-ONESHOT.md

Addresses #605 - enables skill-based discovery and selective installation

* fix: complete browser.md with all missing adapters and fix incorrect entries

- Added 15 missing browser adapters: Reuters, SMZDM, Ctrip, Barchart,
  Jike, Linux.do, WeRead, Jimeng, Pixiv, Web, Weixin, JD, LinkedIn,
  Sina Finance, Bloomberg (browser)
- Fixed incomplete entries: Facebook (added 5 missing commands),
  Coupang (corrected to match actual CLI), Yollomi (restored all 12
  commands), Doubao Web (restored send/read commands), Grok (fixed format)
- Added missing public APIs: StackOverflow, Xiaoyuzhou, Wikipedia
- Updated SKILL.md index to list all supported platforms across all
  categories including desktop adapters

* refactor: remove root SKILL.md, migrate Record Workflow to opencli-explorer

- Moved Record Workflow documentation (工作原理, 使用步骤, 页面类型表,
  候选 YAML→TS 转换, 故障排查) into skills/opencli-explorer/SKILL.md
- Deleted root SKILL.md — all content now lives under skills/

* docs: add AI skills installation guide to README

Add npx skills add instructions for all 3 skills (opencli-usage,
opencli-explorer, opencli-oneshot) to both README.md and README.zh-CN.md.
2026-04-02 13:38:27 +08:00
GanFanNewOrder d721eb6c6c feat(amazon): add browser adapter and docs (#659)
* feat(amazon): add browser adapter and docs

* review: wire amazon into discovery docs

---------

Co-authored-by: 泽加武 <zejiawu@zejiawudeMac-mini.local>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-02 13:32:23 +08:00
ajia1206 341bb87e09 test(xiaohongshu): redact creator fixture data (#647) 2026-04-02 01:21:53 +08:00
AstroHan 127dc3edea feat: add minimal record write candidates (#665) 2026-04-02 01:21:11 +08:00
jakevin f88e7569e9 refactor: src cleanup — deduplicate errors, cache VM, extract BasePage, remove Playwright MCP legacy (#667)
* refactor: deduplicate transient error checks, cache VM contexts, expose tab ID

- Extract shared isTransientBrowserError() into browser/errors.ts, replacing
  duplicated string-matching lists in daemon-client.ts and pipeline/executor.ts
- Cache compiled vm.Script objects in template.ts with LRU eviction (max 256),
  avoiding per-invocation VM context creation in pipeline loops
- Add getActiveTabId() to IPage interface and Page class for tab state inspection

* refactor: extract BasePage to deduplicate DOM helpers across Page and CDPPage

Both Page (daemon-backed) and CDPPage (direct CDP) had ~200 lines of
identical DOM helper implementations (click, type, scroll, wait, snapshot,
interceptor, etc). Extract shared logic into abstract BasePage class.
Subclasses now only implement transport-specific methods.

* refactor: rename mcp.ts to bridge.ts and clean up Playwright MCP references

The file browser/mcp.ts contained BrowserBridge (daemon session manager),
not MCP functionality. Renamed to bridge.ts for clarity. Also removed all
stale "Playwright MCP" references from comments and variable names across
the codebase — Playwright was removed long ago.
2026-04-02 00:51:15 +08:00
jakevin 9c2a777d11 chore: remove .agents directory (#668)
- Remove redundant .agents/skills and .agents/workflows
- Content already covered in CLI-EXPLORER.md and SKILL.md
2026-04-02 00:27:59 +08:00
jakevin 773178345d refactor: remove bind-current, restore owned-only browser automation model (#664)
* fix(notebooklm): remove bind-current workflow

* fix: relax notebook ID check in open.ts and clean up idle timeout test

- open.ts: only throw when page kind is not 'notebook'; log a warning
  instead of throwing when the notebook ID doesn't match exactly
- background.test.ts: remove unused tabs[1] setup in idle timeout test
  that was leftover from borrowed-session era

* build: rebuild extension dist after bind-current removal
2026-04-01 23:23:48 +08:00
jakevin 1ddca55b4a chore: release v1.5.8 (#663)
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-04-01 22:12:39 +08:00
小左同学 4818871309 Handle foreign extension embeds before debugger attach (#662)
* Handle foreign extension embeds before debugger attach

* fix(extension): recover owned tabs without mutating borrowed tabs

* fix(extension): avoid adopting unrelated tabs

* Revert "fix(extension): avoid adopting unrelated tabs"

This reverts commit 2cba0c19daa032a60a8b878ffd9875f64551a2fc.

* Revert "fix(extension): recover owned tabs without mutating borrowed tabs"

This reverts commit 69dfadedae78c6c878984f1ff43f144d79e81187.

* fix(extension): avoid mutating tabs before attach

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-01 22:10:30 +08:00
jakevin c908d9cd47 chore: release v1.5.7 (#654)
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-04-01 13:09:11 +08:00
jakevin 9b425c7550 feat: Electron auto-launcher — zero-config CDP connection (#653)
* docs: add dingtalk and wecom CLI to external CLI hub

Add dingtalk-workspace-cli and wecom-cli as external CLI integrations
alongside lark-cli, gh, docker, etc.

* feat: add confirmPrompt() to TUI module

* feat: add Electron app registry with builtin + user-defined apps

* feat: add Electron app launcher with auto-detect and restart

* fix: launcher uses processName for path discovery, platform-guard tests

* feat: integrate Electron auto-launcher into execution pipeline

- CDPBridge.connect() accepts cdpEndpoint parameter instead of requiring env var
- getBrowserFactory() selects CDPBridge for registered Electron apps by site name
- executeCommand() calls resolveElectronEndpoint() for Electron apps, skips daemon check
- Remove requiredEnv/OPENCLI_CDP_ENDPOINT from all chatwise commands
- Remove chatwise-opencli.ps1 wrapper script and chatwise/shared.ts
- Update antigravity/serve.ts to use launcher instead of manual env var
- Replace hardcoded app names in scoreCDPTarget with registry lookup
- Fix Discord bundleId typo (com.iscord.app → com.discord.app)

* fix: resolve review issues — port collision and registry completeness

- Change ChatGPT CDP port from 9224 to 9236 (was colliding with Antigravity)
- scoreCDPTarget now uses full registry (builtin + user-defined) via getAllElectronApps()
- Use displayName (falling back to processName) for target score boosting

* fix: assign unique CDP ports — antigravity 9234, chatgpt 9236

Both were sharing port 9224, which could cause silent mis-connection.
2026-04-01 12:49:52 +08:00
reabiter 12443f049e enhance(v2ex): add content, member, created, node fields to topic output (#648)
- Add content field to display topic body text
- Add member field to show topic author
- Add created field to show topic creation timestamp
- Add node field to show topic category
- Add id field for consistency with hot/latest commands

This makes v2ex topic command return meaningful details that are
not available in hot/latest listings.
2026-04-01 02:10:28 +08:00
Jack Lee ee0c2b65ea feat(youtube): add search filters — --type shorts/video/channel, --upload, --sort (#616)
* feat(youtube): add --type shorts/video/channel, --upload, --sort filters

Uses YouTube's native sp= filter params. Shorts = type 9 (sp=EgIQCQ).
Also parses reelItemRenderer for Shorts results.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(youtube): add published time to search results

Shows when video was uploaded (e.g. "8h ago", "4d ago", "3mo ago").

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(youtube): prevent duplicate sp= params and remove redundant Shorts URL rewrite

- YouTube only supports one sp= parameter; using multiple causes
  unpredictable behavior. Pick the most specific filter with priority:
  type > upload > sort.
- Remove the post-processing Shorts URL rewrite — the reelItemRenderer
  branch already generates /shorts/ URLs directly.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-01 01:32:08 +08:00
warkcod 01057527f5 fix(bilibili): distinguish login-gated subtitles from empty results (#645)
* fix(bilibili): distinguish login-gated subtitles from empty results

* fix(test): use single toSatisfy assertion instead of double rejects.toThrow

Awaiting the same rejected promise twice is unreliable. Combine the
AuthRequiredError type check and message regex into one toSatisfy call.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-01 00:59:19 +08:00
reabiter 67fb022f16 fix(v2ex): add id field to hot and latest API responses (#646)
* fix(v2ex): add id field to hot and latest API responses

- Add id field to hot.yaml and latest.yaml pipeline output
- Enables downstream commands like 'v2ex topic <id>' to work seamlessly
- Fixes issue where v2ex hot/latest JSON output lacked topic IDs

* enhance(v2ex): add node and url fields to hot/latest output

In addition to the id field, include node name (板块) and topic URL
for richer output. All fields come from the existing API response.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-04-01 00:25:57 +08:00
jakevin 7ea3f6d3fb feat(stealth): harden CDP debugger detection countermeasures (#644)
Add 6 new anti-detection patches to stealth.ts and CDP-level debugger
statement neutralization to reduce risk of bot detection on platforms
like Xiaohongshu.

New patches:
- Shared toString disguise via WeakMap (undetectable by anti-bot scripts)
- Anti-debugger statement trap (Function/eval patching + CDP Debugger.setBreakpointsActive)
- Console method fingerprinting defense (re-wrap CDP-bound console methods)
- Window dimension detection defense (outerWidth/outerHeight normalization)
- Performance API entry filtering (remove debugger/devtools entries)
- document.$cdc_ property cleanup (backup for window-level cleanup)
- Iframe contentWindow.chrome consistency
2026-03-31 23:34:37 +08:00
ajia1206 818ae61889 fix(douyin): support current creator api response shapes (#618) 2026-03-31 23:01:13 +08:00
jakevin 811e4f5c3e fix(douyin): narrow getDraftCommand return type to fix TS2722 (#643) 2026-03-31 22:59:23 +08:00
AstroHan fea47abcec fix(douyin): repair creator draft flow (#640)
* fix(douyin): handle creator payload shapes

* refactor(douyin): drive draft via creator page

* fix(douyin): save resumable draft session

* fix(douyin): harden draft cover flow

* fix(douyin): wait for stable cover state

* fix(douyin): wait for cover detection result

* fix(douyin): require cover state transition

* fix(douyin): scope cover checks to quick panel

* fix(douyin): narrow quick-check state match

* fix(douyin): drop ambiguous quick-check match

* fix(douyin): test quick-check panel extraction

* fix(douyin): cover busy state extraction

* refactor(douyin): clean up draft tests — temp file cleanup, reduce boilerplate

- Add afterAll cleanup for temp dirs (fixes temp file leak)
- Extract createTempVideo/createTempCover/getDraftCommand helpers
- Remove repeated registry lookup + mkdtempSync boilerplate from each test

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-31 22:37:35 +08:00
AstroHan 519b3cfe85 fix: avoid in-page redirect in facebook search (#642)
* fix(facebook): split search navigation from extraction

* refactor: use settleMs instead of waitUntil:none + wait:4

Replace `waitUntil: none` + separate `wait: 4` step with `settleMs: 4000`
on the navigate step. This is consistent with other Facebook adapters
(feed.yaml, memories.yaml, profile.yaml) and lets the navigate step
handle the timing in one place.

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-31 22:26:07 +08:00
jakevin 57534cf8b3 feat(daemon): replace 5min idle timeout with long-lived daemon model (#641)
* docs: add daemon lifecycle redesign spec

Replace the aggressive 5-minute idle timeout with a long-lived daemon
model that stays running for hours, reducing restart overhead during
development cycles.

* docs: add daemon lifecycle redesign implementation plan

8-task TDD plan for replacing aggressive 5-minute idle timeout with
long-lived daemon model (4h default, dual-condition exit).

* feat(daemon): add DEFAULT_DAEMON_IDLE_TIMEOUT constant (4 hours)

* feat(daemon): replace fixed 5min timeout with dual-condition idle manager (4h default)

* feat(extension): reduce WS reconnect backoff cap from 60s to 5s

* feat(daemon): improve CLI connection-waiting UX with progress messages and 200ms polling

* feat(daemon): add opencli daemon status/stop/restart commands

* test(daemon): add tests for daemon status/stop commands

* fix(daemon): address code review issues — stale constant, restart robustness, timer cleanup, test coverage

* docs: update daemon documentation for new lifecycle and CLI commands

- troubleshooting.md: replace manual curl/pkill with `opencli daemon status/stop/restart`
- browser-bridge.md (en/zh): add Daemon Lifecycle section
- README.md: add `opencli daemon status` to Quick Start
- README.zh-CN.md: add daemon management commands to tips
2026-03-31 22:17:54 +08:00
jakevin 62fde40aab fix(docs): use relative links in adapter index (#629)
VitePress base is /docs/, so absolute links like /adapters/browser/twitter
resolve incorrectly. Changed all links to relative paths (./browser/...,
./desktop/...) so they work correctly on the docs site.
2026-03-31 14:39:15 +08:00
muqiao215 0204dbb018 feat(notebooklm): add read commands and compatibility layer (#622)
* feat(notebooklm): add read commands and compatibility layer

* review: trim notebooklm artifacts and sync docs

---------

Co-authored-by: qiaoqiao147 <camtup044@gmail.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-31 13:19:47 +08:00
fii6 1858eace6e feat(instagram): add media download command (#623)
* feat(instagram): add media download command

* feat(instagram): add media download command

* fix(instagram): align download command with platform conventions

---------

Co-authored-by: fii6 <246637913+fii6@users.noreply.github.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-31 13:04:31 +08:00
Kagura 0fbeb2d77f fix(substack): update selectors for Substack DOM redesign (fixes #621) (#624)
* fix(substack): update selectors for Substack DOM redesign (fixes #621)

Substack replaced <article> elements with role="article" divs and a
new SPA-based feed. The wait() selector 'article' no longer matches,
causing 'Selector not found: article' on feed and publication commands.

- loadSubstackFeed: use 'a[href*="/p/"]' (matches actual post links)
- loadSubstackArchive: use '[role="article"]' (Substack's new ARIA roles)

The evaluate() scraping logic inside both functions is unchanged since
it already uses 'a' href pattern matching, not article tags.

* review: align substack wait selectors with scraper

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-31 12:58:22 +08:00
AstroHan 33ca81b785 fix(weread): recover book details from cached shelf fallback (#628) 2026-03-31 12:47:52 +08:00
GanFanNewOrder 4c3cd3878e fix(ctrip): update search adapter to live endpoint (#627)
* fix(ctrip): update search adapter to live endpoint

* review: make ctrip search a public fetch adapter

---------

Co-authored-by: 泽加武 <zejiawu@zejiawudeMac-mini.local>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-31 12:47:48 +08:00
dependabot[bot] 5f541ea42b chore(deps): bump vitest from 4.1.1 to 4.1.2 (#620)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 4.1.1 to 4.1.2.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.2/packages/vitest)

---
updated-dependencies:
- dependency-name: vitest
  dependency-version: 4.1.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-31 12:43:16 +08:00
geegewu ca2165cbc7 fix(xiaohongshu): support full URL/short link and fix video extraction (#615)
* fix(xiaohongshu): support full URL/short link and fix video extraction

Two issues fixed:

1. URL handling: The download command only accepted bare note IDs and
   constructed `explore/{noteId}` URLs, which lack the `xsec_token`
   parameter now required by Xiaohongshu. This made all video/image
   downloads fail with "No media found". Now accepts full URLs
   (with xsec_token) and short links (xhslink.com) in addition to
   bare note IDs.

2. Video extraction: XHS video player uses blob: URLs in DOM, which
   cannot be downloaded via HTTP. Now extracts real video URLs from
   `window.__INITIAL_STATE__` (SSR data) and inline script JSON
   before falling back to DOM selectors, skipping blob: URLs.

Tested with a video note via short link — successfully downloaded
21.5 MB MP4.

* review: resolve xiaohongshu note id after redirects

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-31 00:32:08 +08:00
ahahaha d0803857f1 feat(xiaohongshu): add note command and nested reply support for comments (#599)
* feat(xiaohongshu): add note command and nested reply support for comments

Add `xiaohongshu note` command to read full note content (title, author,
description, engagement metrics, tags) from public note pages.

Enhance `xiaohongshu comments` with `--with-replies` flag to extract
nested replies (楼中楼), including reply_to attribution and per-reply
like counts. Limit logic counts only top-level comments so replies
are included for free.

Extract shared `parseNoteId` into side-effect-free `note-helpers.ts`
to avoid cross-module command registration leakage.

Normalize non-numeric engagement placeholders ("赞"/"收藏"/"评论")
to "0" for zero-count notes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs(xiaohongshu): add note and comments --with-replies to adapter docs

Update xiaohongshu adapter documentation and README command table
to reflect the new note command and enhanced comments with nested
reply support.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs(xiaohongshu): fix download example to show both note-id and url

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(xiaohongshu): expand nested reply threads before scraping

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-30 23:29:30 +08:00
Kagura 701d9e859f fix(xiaohongshu): check login wall before autoScroll in search (fixes #597) (#608)
- Add early login-wall detection before autoScroll() in search.ts
  to prevent crash when XHS shows a login gate instead of results
- Add document.body null guard in autoScrollJs (dom-helpers.ts)
- Update search.test.ts: verify autoScroll is not called on login wall
- Add autoScrollJs null-body defense test in dom-helpers.test.ts
2026-03-30 23:12:02 +08:00
AstroHan 59d41f28e1 fix(zhihu): stop question command failing on unused detail fetch (#606)
* fix(zhihu): stop question command failing on unused detail fetch

* review: harden zhihu question fetch path

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-30 23:10:53 +08:00
jakevin fcdc15d385 fix: improve weixin article download extraction (#612) 2026-03-30 23:01:44 +08:00
jakevin 030adc9341 fix: restore root SKILL.md (#609) 2026-03-30 21:30:37 +08:00
jakevin 62e3c55993 chore(release): 1.5.6 (#596)
Build Chrome Extension / build (push) Has been cancelled
Release / release (push) Has been cancelled
2026-03-30 13:27:19 +08:00
bhutano 8e37f66e53 fix(spotify): follow-up fixes for token refresh, null guards and credentials guidance (#591)
* fix(spotify): fix token refresh, null guards, env parse, missing credentials guidance, postinstall template

* fix(spotify): restore credential guardrails

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-30 13:03:25 +08:00
jakevin 770c28301a docs: add dingtalk and wecom CLI to external CLI hub (#594)
* docs: add dingtalk and wecom CLI to external CLI hub

Add dingtalk-workspace-cli and wecom-cli as external CLI integrations
alongside lark-cli, gh, docker, etc.

* feat: register dingtalk and wecom as external CLIs

Add dws (DingTalk Workspace CLI) and wecom-cli to
external-clis.yaml so they are discoverable via opencli list
and auto-installable.
2026-03-30 12:49:36 +08:00
AstroHan cf79ec5c23 feat(xueqiu): add comments command (#587)
* feat: add xueqiu comments command

* docs(xueqiu): add comments command docs

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-30 01:22:44 +08:00
Zhangchen 8c00ad9f02 feat(browser): add ONES adapter support for tasks and worklog commands (#386)
* feat(browser): add ONES adapter support for tasks and worklog commands
Add ONES auth/session commands, task listing/details utilities, and worklog operations, with related docs and helper utilities.

* fix(ones): harden worklog and task-list adapter behavior

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-30 01:06:38 +08:00
Inori333 3eb2e88c85 fix: normalize boolean arg aliases (#585) 2026-03-30 00:44:45 +08:00
Haoyue Bai b280f19321 feat(youtube): mute and pause watch pages for read commands (#578)
* Mute and pause YouTube watch pages for read commands

* fix(youtube): quiet watch pages earlier

* refactor(youtube): avoid watch ui for read commands

* test(youtube): cover html bootstrap parser

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-29 23:22:53 +08:00
AstroHan a32b65be4a feat: add Tieba browser adapters in TypeScript (#581)
* feat(tieba): add browser adapters for hot posts search and read

* fix(tieba): stabilize search and e2e coverage

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-29 22:39:26 +08:00
Ron ab7eca35e4 feat(doubao): add history, detail, meeting-summary (#566)
* feat(doubao): add history, detail, meeting-summary and meeting-transcript commands

- history: list conversation history from sidebar
- detail: read a specific conversation by ID, with meeting card detection
- meeting-summary: extract summary and AI chapters from meeting minutes
- meeting-transcript: read or download meeting transcript via browser

Made-with: Cursor

* docs: update doubao command list in adapter index and README.zh-CN

Made-with: Cursor

* fix(doubao): handle meeting-only detail and merge transcript snapshots

* refactor(doubao): model conversation ids as first-class output

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-29 22:36:24 +08:00
jakevin 107ed28449 refactor(douyin): share user video public api (#580) 2026-03-29 17:50:46 +08:00
Howard 79b4e069f0 feat(douyin): add user-videos command with top comments (#554)
* feat(douyin): add user-videos command with top-10 comments

Adds a new adapter for fetching a public user's video list by sec_uid,
alongside the top-10 hottest comments for each video.

- Navigates to the user's profile page to establish a cookie session
- Fetches video list via /aweme/v1/web/aweme/post/
- Concurrently fetches top-10 comments per video via
  /aweme/v1/web/comment/list/ (sorted by hotness, API default)

Output columns: index, aweme_id, title, duration, digg_count,
                play_url, top_comments

* refactor(douyin): replace Object.assign with spread in user-videos

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

* fix(douyin): validate user-videos inputs

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-29 17:45:11 +08:00
PXLZJ d2b563e55b feat(xiaohongshu): add cover image URL to user notes output (#572)
* feat(xiaohongshu): add cover image URL to user notes output

Extract cover image URL from noteCard.cover.urlDefault in
__INITIAL_STATE__ and include it in the user command output columns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test(xiaohongshu): cover user note rows

* refactor(xiaohongshu): keep cover out of default columns

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-29 17:40:33 +08:00
jakevin f8e9b08223 fix(zsxq): require active group context (#579)
* fix(zsxq): require active group context

* docs(zsxq): add adapter guide
2026-03-29 17:29:36 +08:00
bhutano 1ae1c82c4a feat(spotify): add Spotify playback adapter (#560)
* feat(spotify): add Spotify playback adapter

Adds a new adapter for controlling Spotify via the official Web API.
Uses Strategy.PUBLIC with OAuth2 — no browser session required.

Commands: auth, status, play, pause, next, prev, volume, search, queue, shuffle, repeat.
Credentials are loaded from ~/.opencli/spotify.env or environment variables.

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

* fix(spotify): rename index.ts → spotify.ts and fix CliError calls

- Renamed src/clis/spotify/index.ts to spotify.ts so the build-manifest
  picks it up (index.js is intentionally excluded from manifest scanning)
- Fixed 4 CliError calls: constructor now requires (code, message, hint?)
  so each throw now passes an appropriate error code as first argument

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

* fix(spotify): fix token refresh corruption, env parse, null guards, validation

- refreshAccessToken: check res.ok before parsing; construct Tokens object
  directly instead of mutating loadTokens() result to avoid writing
  undefined/NaN on Spotify error responses; preserve existing refresh_token
  when Spotify omits it from the response
- loadEnv: split on first '=' only so values containing '=' are preserved
- SCOPES: remove write/library/top scopes not used by any command
- status: guard against data.item being null (active device but no track)
- volume: validate 0-100 range before API call
- auth: check tokenRes.ok on initial token exchange; add server.on('error')
  handler for EADDRINUSE; add 5-minute timeout with clearTimeout on close

* feat(postinstall): auto-create ~/.opencli/spotify.env template on install

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

* fix(spotify): guard null progress, podcast items, missing tracks data, corrupted tokens, invalid search limit

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

* fix(spotify): improve missing credentials error with step-by-step guidance

* fix(spotify): harden setup and add docs coverage

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-29 17:28:37 +08:00
康厚超 440c001a20 feat(band): add Band.us adapter — bands, posts, mentions, post commands (#532)
* feat(band): add bands, posts, and mentions commands for band.us

- bands: lists all Bands via get_band_list_with_filter intercept
- posts: lists posts from a Band via get_posts_and_announcements intercept
- mentions: shows @mention notifications via get_news intercept

All use Strategy.INTERCEPT since band.us API requires an HMAC md header
generated by its own JS. SPA navigation to /band/{no}/post triggers the
band list and posts APIs; bell + @メンション tab click triggers mentions.

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

* refactor(band): clean up all three band adapters

- Fix doc comments: Band uses XHR not fetch; clarify INTERCEPT rationale
- bands: replace for-loop with flatMap; explain why band page nav is needed
- posts: remove item.post ?? item fallback (API always wraps in post); rename
  finalRequests → requests for consistency; extract stripBandTags helper
- mentions: remove redundant ?? defaults (args have defaults defined); fix
  unreadOnly bug (was not applied to post/comment modes); consolidate Band tag
  stripping to single regex; cast kwargs types directly instead of converting;
  add comments explaining last-response strategy and 'referred' filter flag

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

* fix(band/posts): handle mixed post/announcement items from API

get_posts_and_announcements returns both regular posts and announcements
that have different shapes — some lack post_no and wrap differently.
Restore item.post ?? item fallback and filter out items with no resolvable
identifier to prevent undefined in URLs and empty rows in output.

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

* feat(band): add post command — full post export with comments and photo download

Exports the complete content of a single Band post:
- Post body (with Band markup tags stripped)
- All comments in chronological order
- Photo URLs shown inline, or downloaded with --output <dir>

Uses Strategy.INTERCEPT with a broad 'band.us' pattern to capture both the
batch request (embedding get_post) and get_comments in one SPA navigation.
Responses are identified client-side by shape: batch_result array vs items
array with comment_id fields.

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

* refactor(band): replace XHR interception with direct DOM extraction

- bands, posts, post: navigate directly to target URL instead of home→SPA detour
- All three switch from Strategy.INTERCEPT to Strategy.COOKIE with navigateBefore: false
  (bands uses framework pre-nav to home; posts/post disable it and goto target directly)
- DOM extraction polls for specific content elements rather than fixed waits
- post: confirm selectors via browser inspection (a.text, time.time, .sCommentList,
  .sReplyList for nested replies); add --comments flag to skip comment fetch
- posts: extract from rendered post list DOM; correct comment item selector (div.cComment)
- Fix: post empty-result guard changed from && to handle null data safely
- Fix: photo download now checks HTTP status code before piping to avoid writing
  redirect HTML into image files
- Fix: mentions unread client-side filter skipped for 'mentioned' mode since
  server already filtered via 未確認のみ button click

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

* fix(band): address code review feedback

- post: replace manual http/https download with shared downloadMedia utility
  (handles redirects, timeouts, stream errors correctly)
- post: fix photo URL resolution to use location.href as base, handling
  protocol-relative and relative URLs without throwing
- post: switch to node:-prefixed imports per repo convention
- post/posts: remove redundant ArgumentError guards — framework already
  validates required args before func() is called
- mentions: INTERCEPT strategy is intentional (Band HMAC prevents DOM-only
  approach for notifications; update PR description to clarify)

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

* fix(band): address second round of code review feedback

- bands: tighten href selector to /band/{id}(?:/post)?$ so feed/post-detail
  links are excluded; only sidebar navigation links match
- mentions: replace fixed page.wait(2) sleeps with polling on
  getInterceptedRequests() — waits up to 8 s per action, exits as soon
  as the expected number of captures arrives (avoids flakiness on slow XHR)

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

* fix(band): fix selector bugs found during testing

- bands: use a.bandCover._link + p.uriText + span.member em selectors
  (previous a[href*="/band/"] + .bandName combo leaked "メンバー" text)
- posts: use article.cContentsCard._postMainWrap + span.count selectors
  (previous li._postListItem selector matched nothing; DOM changed)
- mentions: fix page.wait(500) → page.wait(0.5) (was waiting 500s not ms);
  use timestamp-suffixed URL to force fresh page load each run so the
  notification panel is closed; fix get_news vs get_news_count capture
  ambiguity with result_data.news check; replace cumulative waitForCaptures
  with waitForOneCapture (getInterceptedRequests clears array on each call)

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

* fix(band/mentions): use CSS class selector for bell button instead of locale-dependent text match

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

* fix(band): address third round of code review feedback

- post: pass browser cookies to downloadMedia so Band's login-protected
  photo URLs don't fail with 401/403
- post: include photos.length in empty-result guard so photo-only posts
  are not falsely reported as not found
- mentions: accumulate captures across poll iterations so get_news_count
  responses don't cause early exit before the real get_news arrives
- mentions: update docstring to match actual implementation (client-side
  filtering, no tab-click)

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

* fix(band): address fourth round of code review feedback

- mentions: fail fast with a clear error when bell button is not found,
  instead of silently no-op and waiting 8s before EmptyResultError
- post: use shared formatCookieHeader() instead of manual cookie string
  construction

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

* fix(band): address fifth round of code review feedback

- mentions: replace fixed page.wait(2) with polling for bell button
  readiness (up to 10s), eliminating the fixed sleep and fail-fast
  when the selector is missing
- mentions: add explicit !newsReq guard with a clear error message when
  get_news capture times out, instead of falling through to a misleading
  "No notifications found"
- posts: skip posts with no permalink href instead of emitting a bogus
  'https://www.band.us' URL

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

* fix(band): address sixth round of code review feedback

- post: only send Band cookies to *.band.us photo URLs; third-party CDN
  URLs are downloaded without cookies to avoid cross-domain cookie leakage
- bands: strip non-digit chars before parseInt so member counts like
  "1,234" parse correctly
- posts: same fix for comment counts

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

* fix(band): address seventh round of code review feedback

- posts: check limit before push so --limit 0 returns empty result
- post: indent replies proportionally by depth ('  '.repeat(depth))
  so multi-level threads remain readable in table output

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

* fix(band/bands): anchor href regex to prevent matching post-detail URLs

Pattern now requires /band/{id} or /band/{id}/post (with optional trailing
slash) so deeper paths like /band/{id}/post/{postNo} are excluded.

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

* fix(band): address ninth round of code review feedback

- mentions: guard bell click with a boolean return so a disappearing
  element throws a clear EmptyResultError instead of a raw TypeError
- post: wait for comment list container instead of first .cComment so
  posts with zero comments don't incur a fixed 6s delay

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

* fix(band): use page.getCookies() for login detection across all commands

Replaces document.cookie.includes('band_session') with
page.getCookies({ domain: 'band.us' }) so login detection works even
if Band.us marks the session cookie as HttpOnly in the future.

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

* fix(band): address eleventh round of code review feedback

- mentions: replace EmptyResultError with SelectorError for missing/
  disappeared bell button — produces a clearer SELECTOR error code
- post: assign per-photo filenames using a global index across both
  download batches so band-hosted and CDN photos don't overwrite each other

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

* fix(band): address twelfth round of code review feedback

- post: derive file extension from URL path and include in filename
  (e.g. photo_1.jpg) so downloaded photos have correct extensions
- posts: remove dead code guard (!url && !content) — url is always
  non-empty here since href-empty posts are already skipped above

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

* fix(band/post): use url-scoped getCookies for photo download auth

Domain-scoped getCookies may omit host-only cookies scoped to www.band.us;
using url: 'https://www.band.us' ensures all relevant cookies are included
in the auth header for Band-hosted photo downloads.

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

* docs(band): add adapter documentation and sidebar entry

Required by CI doc-check --strict: every adapter in src/clis/ must have
a corresponding docs/adapters/browser/*.md file.

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

* test(e2e): wire band auth coverage into default matrix

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-29 17:19:26 +08:00
James 5925849414 feat(xiaohongshu): use CDP DOM.setFileInputFiles for image upload (#574)
* feat(xiaohongshu): use CDP DOM.setFileInputFiles for image upload

Replace base64 DataTransfer injection with CDP DOM.setFileInputFiles,
which lets Chrome read image files directly from the local filesystem.
This eliminates payload size limits that caused "fetch failed" errors
when uploading large images (>500KB) through the browser bridge.

Changes:
- Add 'set-file-input' action to protocol, extension handler, and CDP executor
- Add Page.setFileInput() method for CLI-side usage
- Rewrite publish image upload to use CDP path, with base64 fallback
  for older extension versions that don't support the new action
- Add clear warning when falling back to base64 with large payloads

Closes #542 (partially — image upload reliability)

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

* test: cover cdp file input upload path

* fix: keep image upload on image-only inputs

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-29 17:16:55 +08:00
xtftbwvfp d8d9643e89 feat: add 知识星球(zsxq) site adapter (#571)
* feat: add 知识星球(zsxq) site adapter

Add cookie-based adapter for 知识星球 (zsxq.com) with 5 commands:
- groups: list joined groups
- topics: list topics in current group
- topic: get single topic detail with comments
- search: search topics within a group
- dynamics: latest cross-group activity feed

Uses XHR over Chrome extension (Strategy.COOKIE) to call
https://api.zsxq.com/v2/ APIs with credential forwarding.

* fix(zsxq): map missing topics to not found

* refactor(zsxq): preserve detail response semantics

---------

Co-authored-by: xiaojian <xiaojian@xiaojiandeMac-mini.local>
Co-authored-by: jackwener <jakevingoo@gmail.com>
2026-03-29 17:15:27 +08:00
AstroHan bb5c2b1fc6 fix(weread): harden reader fallback and search mapping (#562)
* fix(weread): harden reader fallback and search mapping

* fix(ci): remove stale weread regression test duplicates

* refactor(weread): simplify search fetch and eliminate redundant getCookies

- Parallelize search API + HTML fetch with Promise.all
- Add generic numeric entity decoding (decimal + hex) in decodeHtmlText
- Extract loadWebShelfSnapshotWithVid to pass currentVid downstream,
  avoiding a redundant getCookies call in waitForTrustedWebShelfSnapshot
- Split mixed early-return conditions with individual comments
- Add mirror comments between browser/Node trusted-index logic
2026-03-29 17:02:02 +08:00
jakevin f44fcd512b docs: sync docs with codebase (v1.5.5, exit codes, hub table, new adapters) (#575)
- SKILL.md: version 1.4.1 → 1.5.5
- README.md: remove non-existent gws from CLI Hub table; bump adapter
  count to 66+; add Exit Codes section (sysexits.h table + usage example)
- README.zh-CN.md: replace readwise/gws (not in external-clis.yaml) with
  lark-cli/vercel; add bluesky and douyin to built-in commands table;
  add 退出码 section matching English README; add 66+ adapter count line
2026-03-29 15:49:22 +08:00
997 changed files with 64752 additions and 5908 deletions
@@ -1,249 +0,0 @@
---
name: cross-project-adapter-migration
description: "Cross-project CLI command migration workflow for opencli. Use when importing commands from external CLI projects (python/node) like rdt-cli, twitter-cli, etc. Covers: source analysis → gap matrix → batch migration → README/SKILL.md update."
---
# Cross-Project Adapter Migration
> 从外部 CLI 项目(Python/Node/Go 等)批量迁移命令到 opencli 的标准化流程。
## When to Use
- 用户说"把 xxx-cli 的命令迁移过来"
- 用户说"看看 xxx 项目有什么可以借鉴的"
- 用户说"对齐 xxx-cli 的功能"
- 在为新平台扩展 opencli 时,发现已有第三方 CLI 工具
## Prerequisites
- 熟悉 [CLI-EXPLORER.md](../../../CLI-EXPLORER.md)adapter 开发决策树)
- 熟悉 [SKILL.md](../../../SKILL.md)(命令参考 & 模板)
---
## Phase 1: 源项目分析
### 1.1 克隆 & 理解源项目
```bash
# 克隆源项目到 /tmp 做分析
git clone <source_repo_url> /tmp/<source-cli>
```
分析重点:
- **命令列表**:找到所有可用命令(查看 CLI 入口文件、help 输出或 README
- **认证方式**CookieAPI KeyOAuth?浏览器自动化?
- **数据源**:公开 APIGraphQL?页面抓取?
- **输出字段**:每个命令返回哪些数据字段
### 1.2 生成命令清单
列出源项目所有命令,包括:
| 命令 | 类型 | API/方法 | 输出字段 |
|------|------|---------|---------|
| `xxx feed` | Read | `GET /api/feed` | title, author, time |
| `xxx post` | Write | `POST /api/tweet` | status, id |
---
## Phase 2: 功能对比矩阵
### 2.1 查看 opencli 现有命令
```bash
ls src/clis/<site>/ # 查看已有适配器
opencli list | grep <site> # 确认已注册命令
```
### 2.2 生成对比矩阵
对每个源项目命令,标注三种状态:
| 功能 | 源项目 | opencli 现有 | 行动 |
|------|--------|-------------|------|
| feed | ✅ `xxx feed` | ❌ 无 | ✅ **新增** |
| search | ✅ `xxx search` | ✅ `search.ts` | ❌ 已有,跳过 |
| hot | ✅ `xxx hot` | ⚠️ `hot.yaml`(不完整) | ✅ **增强** |
| like | ✅ `xxx like` | ✅ `like.ts` | ❌ 已有,跳过 |
### 2.3 筛选迁移目标
去掉已有的、低价值的,保留高价值缺失命令,按 Read/Write 分类:
**筛选原则**
- ✅ 高使用频率的命令优先
- ✅ 已有但不完整的命令标记为"增强"
- ❌ 源项目特有但 opencli 架构不支持的功能(如需要持久化存储的)跳过
- ❌ 与现有功能完全重复的跳过
---
## Phase 3: 批量实现
> [!IMPORTANT]
> 实现前必须查阅 [CLI-EXPLORER.md](../../../CLI-EXPLORER.md) 确认策略选择。
### 3.1 选择实现方式
基于决策树分类:
| 类别 | 方式 | 适用条件 |
|------|------|---------|
| **Read + 简单 API** | YAML pipeline | 纯 fetch/select/map,无复杂 JS |
| **Read + GraphQL/分页/签名** | TypeScript adapter | 需要 JS 逻辑 |
| **Write 操作** | TypeScript + `Strategy.UI` | 点击/输入等 DOM 操作 |
| **Write + API** | TypeScript + `Strategy.COOKIE/HEADER` | 直接 POST API |
### 3.2 实现顺序
**先 Read 后 Write,先 YAML 后 TS**
1. **Phase A**: YAML Read 适配器(最快,通常每个 10-20 行)
2. **Phase B**: TS Read 适配器(需要 evaluate/intercept 的)
3. **Phase C**: TS Write 适配器(需 UI 自动化或 POST API
### 3.3 实现模板
#### YAML Read 适配器模板(Cookie 策略)
```yaml
site: <site>
name: <command>
description: <描述>
domain: www.<site>.com
strategy: cookie
browser: true
args:
limit:
type: int
default: 20
pipeline:
- navigate: https://www.<site>.com
- evaluate: |
(async () => {
const res = await fetch('<api_endpoint>', { credentials: 'include' });
const d = await res.json();
return (d.data?.items || []).map(item => ({
title: item.title,
// ... map source fields
}));
})()
- map:
rank: ${{ index + 1 }}
title: ${{ item.title }}
- limit: ${{ args.limit }}
columns: [rank, title]
```
#### TS Write 适配器模板(UI 策略)
```typescript
import { cli, Strategy } from '../../registry.js';
cli({
site: '<site>',
name: '<command>',
description: '<描述>',
strategy: Strategy.UI,
args: [{ name: 'target', required: true, help: '<参数说明>' }],
columns: ['status', 'message'],
func: async (page, kwargs) => {
await page.goto(`https://www.<site>.com/${kwargs.target}`);
await page.wait({ text: '<expected_text>', timeout: 10 });
// 获取 snapshot 找到目标按钮
const snapshot = await page.accessibility.snapshot();
// 点击按钮 ...
return [{ status: 'success', message: '<action> completed' }];
},
});
```
### 3.4 公共模式复用
迁移过程中如果发现多个适配器共享逻辑,考虑提取到 `src/clis/<site>/utils.ts` 工具文件:
```typescript
// src/clis/<site>/utils.ts
export async function fetchWithAuth(page, url) { ... }
export function parseItem(raw) { ... }
```
---
## Phase 4: 验证 & 发布
### 4.1 构建验证
```bash
npx tsc --noEmit # TypeScript 编译检查
opencli list | grep <site> # 确认所有命令已注册
```
### 4.2 运行验证(关键!)
每个新命令必须实际运行:
```bash
# Read 命令
opencli <site> <command> --limit 3 -f json
opencli <site> <command> --limit 3 -v # verbose 查看 pipeline
# Write 命令(谨慎!会实际操作)
opencli <site> <command> <test_target>
```
### 4.3 更新文档
迁移完成后必须更新以下文件:
1. **README.md** — 在对应平台区域添加新命令示例
2. **SKILL.md** — 在 Commands Reference 中添加新命令
### 4.4 提交 & 推送
```bash
git add -A
git commit -m "feat(<site>): migrate <N> commands from <source-cli>
- Phase A: <N> YAML adapters (read operations)
- Phase B: <N> TS adapters (write operations)
- Source: <source_repo_url>"
git push
```
---
## Checklist
- [ ] 源项目命令清单已生成
- [ ] 对比矩阵已确认,高价值缺失命令已筛选
- [ ] 用户确认迁移范围
- [ ] Phase A: YAML Read 适配器已完成
- [ ] Phase B: TS Read 适配器已完成
- [ ] Phase C: TS Write 适配器已完成
- [ ] `npx tsc --noEmit` 编译通过
- [ ] 所有新命令已实际运行验证
- [ ] README.md 已更新
- [ ] SKILL.md 已更新
- [ ] 已 commit + push
## 实战案例参考
### rdt-cli → opencli Reddit2026-03-16
- **源项目**: `rdt-cli`25 个 Python 命令)
- **筛选结果**: 13 个高价值命令
- **实现**: 7 个 YAMLread + 6 个 TSwrite
- **产出**: +11 文件,+767 行代码,Reddit 适配器从 4 → 15+275%
### twitter-cli → opencli Twitter2026-03-16
- **源项目**: `twitter-cli`20+ Python 命令)
- **筛选结果**: 11 个待实现
- **策略**: Read 用 `Strategy.COOKIE` + GraphQL fetchWrite 用 `Strategy.UI`
@@ -1,54 +0,0 @@
---
description: Migrate commands from an external CLI project into opencli adapters
---
// turbo-all
## Steps
1. Clone the source CLI project for analysis:
```bash
git clone <source_repo_url> /tmp/<source-cli>
```
2. Analyze source project: list all commands, auth method, API endpoints, and output fields.
3. Check existing opencli adapters for the target site:
```bash
ls src/clis/<site>/
opencli list | grep <site>
```
4. Generate a comparison matrix table (source commands vs opencli existing). Mark each as: ✅ **New** / ✅ **Enhance** / ❌ **Skip**. Ask user to confirm which commands to migrate.
5. Implement YAML Read adapters first (highest ROI, 10-20 lines each). Place files in `src/clis/<site>/<name>.yaml`.
6. Implement TS Read adapters for complex cases (GraphQL, pagination, signing). Place files in `src/clis/<site>/<name>.ts`.
7. Implement TS Write adapters using `Strategy.UI` or `Strategy.COOKIE`. Place files in `src/clis/<site>/<name>.ts`.
8. Verify build:
```bash
npx tsc --noEmit
```
9. Verify all commands are registered:
```bash
opencli list | grep <site>
```
10. Run each new command to verify it works:
```bash
opencli <site> <command> --limit 3 -f json
```
11. Update README.md with new command examples in the appropriate platform section.
12. Update SKILL.md Commands Reference with new commands.
13. Commit and push:
```bash
git add -A
git commit -m "feat(<site>): migrate <N> commands from <source-cli>"
git push
```
+2
View File
@@ -22,3 +22,5 @@ docs/.vitepress/cache
# Database files
*.db
autoresearch/results/
autoresearch-results.tsv
+84
View File
@@ -1,5 +1,89 @@
# Changelog
## [1.6.1](https://github.com/jackwener/opencli/compare/v1.6.0...v1.6.1) (2026-04-02)
### Bug Fixes
* sync package-lock.json version with package.json ([#698](https://github.com/jackwener/opencli/issues/698))
## [1.6.0](https://github.com/jackwener/opencli/compare/v1.5.9...v1.6.0) (2026-04-02)
### Features
* **opencli-browser:** add browser control commands for Claude Code skill ([#614](https://github.com/jackwener/opencli/issues/614))
* **docs:** add tab completion to getting started guides ([#658](https://github.com/jackwener/opencli/issues/658))
### Bug Fixes
* **twitter:** resolve article ID to tweet ID before GraphQL query ([#688](https://github.com/jackwener/opencli/issues/688))
* **xiaohongshu:** clarify empty note shell hint ([#686](https://github.com/jackwener/opencli/issues/686))
* **skills:** add YAML frontmatter for discovery and improve descriptions ([#694](https://github.com/jackwener/opencli/issues/694))
### Refactoring
* centralize daemon transport client ([#692](https://github.com/jackwener/opencli/issues/692))
## [1.5.9](https://github.com/jackwener/opencli/compare/v1.5.8...v1.5.9) (2026-04-02)
### Features
* **amazon:** add browser adapter — bestsellers, search, product, offer, discussion ([#659](https://github.com/jackwener/opencli/issues/659))
* **skills:** create skills/ directory structure with opencli-usage, opencli-explorer, opencli-oneshot ([#670](https://github.com/jackwener/opencli/issues/670))
* **record:** add minimal record write candidates ([#665](https://github.com/jackwener/opencli/issues/665))
### Refactoring
* src cleanup — deduplicate errors, cache VM, extract BasePage, remove Playwright MCP legacy ([#667](https://github.com/jackwener/opencli/issues/667))
* remove bind-current, restore owned-only browser automation model ([#664](https://github.com/jackwener/opencli/issues/664))
### Chores
* remove .agents directory ([#668](https://github.com/jackwener/opencli/issues/668))
## [1.5.8](https://github.com/jackwener/opencli/compare/v1.5.7...v1.5.8) (2026-04-01)
### Bug Fixes
* **extension:** avoid mutating healthy tabs before debugger attach and add regression coverage ([#662](https://github.com/jackwener/opencli/issues/662))
## [1.5.7](https://github.com/jackwener/opencli/compare/v1.5.6...v1.5.7) (2026-04-01)
### Features
* **daemon:** replace 5min idle timeout with long-lived daemon model (4h default, dual-condition exit) ([#641](https://github.com/jackwener/opencli/issues/641))
* **daemon:** add `opencli daemon status/stop/restart` CLI commands ([#641](https://github.com/jackwener/opencli/issues/641))
* **youtube:** add search filters — `--type` shorts/video/channel, `--upload`, `--sort` ([#616](https://github.com/jackwener/opencli/issues/616))
* **notebooklm:** add read commands and compatibility layer ([#622](https://github.com/jackwener/opencli/issues/622))
* **instagram:** add media download command ([#623](https://github.com/jackwener/opencli/issues/623))
* **stealth:** harden CDP debugger detection countermeasures ([#644](https://github.com/jackwener/opencli/issues/644))
* **v2ex:** add id, node, url, content, member fields to topic output ([#646](https://github.com/jackwener/opencli/issues/646), [#648](https://github.com/jackwener/opencli/issues/648))
* **electron:** auto-launcher — zero-config CDP connection ([#653](https://github.com/jackwener/opencli/issues/653))
### Bug Fixes
* **douyin:** repair creator draft flow — switch from broken API pipeline to UI-driven approach ([#640](https://github.com/jackwener/opencli/issues/640))
* **douyin:** support current creator API response shapes for activities, profile, collections, hashtag, videos ([#618](https://github.com/jackwener/opencli/issues/618))
* **bilibili:** distinguish login-gated subtitles from empty results ([#645](https://github.com/jackwener/opencli/issues/645))
* **facebook:** avoid in-page redirect in search — use navigate step instead of window.location.href ([#642](https://github.com/jackwener/opencli/issues/642))
* **substack:** update selectors for DOM redesign ([#624](https://github.com/jackwener/opencli/issues/624))
* **weread:** recover book details from cached shelf fallback ([#628](https://github.com/jackwener/opencli/issues/628))
* **docs:** use relative links in adapter index ([#629](https://github.com/jackwener/opencli/issues/629))
## [1.4.1](https://github.com/jackwener/opencli/compare/v1.4.0...v1.4.1) (2026-03-25)
+5 -5
View File
@@ -30,7 +30,7 @@ This is the most common type of contribution. Start with YAML when possible, and
### YAML Adapter (Recommended for data-fetching commands)
Create a file like `src/clis/<site>/<command>.yaml`:
Create a file like `clis/<site>/<command>.yaml`:
```yaml
site: mysite
@@ -66,14 +66,14 @@ pipeline:
columns: [rank, title, score, url]
```
See [`hackernews/top.yaml`](src/clis/hackernews/top.yaml) for a real example.
See [`hackernews/top.yaml`](clis/hackernews/top.yaml) for a real example.
### TypeScript Adapter (For complex browser interactions)
Create a file like `src/clis/<site>/<command>.ts`:
Create a file like `clis/<site>/<command>.ts`:
```typescript
import { cli, Strategy } from '../../registry.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: 'mysite',
@@ -109,7 +109,7 @@ cli({
});
```
Use `opencli explore <url>` to discover APIs and see [CLI-EXPLORER.md](./CLI-EXPLORER.md) if you need the full adapter workflow.
Use `opencli explore <url>` to discover APIs and see [opencli-explorer skill](./skills/opencli-explorer/SKILL.md) if you need the full adapter workflow.
### Validate Your Adapter
+162 -83
View File
@@ -1,128 +1,181 @@
# OpenCLI
> **Make any website, Electron App, or Local Tool your CLI.**
> Zero risk · Reuse Chrome login · AI-powered discovery · Universal CLI Hub
> **Turn websites, browser sessions, Electron apps, and local tools into deterministic interfaces for humans and AI agents.**
> Reuse your logged-in browser, automate live workflows, and crystallize repeated actions into reusable CLI commands.
[![中文文档](https://img.shields.io/badge/docs-%E4%B8%AD%E6%96%87-0F766E?style=flat-square)](./README.zh-CN.md)
[![npm](https://img.shields.io/npm/v/@jackwener/opencli?style=flat-square)](https://www.npmjs.com/package/@jackwener/opencli)
[![Node.js Version](https://img.shields.io/node/v/@jackwener/opencli?style=flat-square)](https://nodejs.org)
[![License](https://img.shields.io/npm/l/@jackwener/opencli?style=flat-square)](./LICENSE)
A CLI tool that turns **any website**, **Electron app**, or **local CLI tool** into a command-line interface — Bilibili, Zhihu, 小红书, Twitter/X, Reddit, YouTube, Antigravity, `gh`, `docker`, and [many more](#built-in-commands) — powered by browser session reuse and AI-native discovery.
OpenCLI gives you one surface for three different kinds of automation:
**Built for AI Agents** — Configure an instruction in your `AGENT.md` or `.cursorrules` to run `opencli list` via Bash. The AI will automatically discover and invoke all available tools.
- **Use built-in adapters** for sites like Bilibili, Zhihu, Xiaohongshu, Reddit, HackerNews, Twitter/X, and [many more](#built-in-commands).
- **Drive a live browser directly** with `opencli browser` when an AI agent needs to click, type, extract, or inspect a page in real time.
- **Generate new adapters** from real browser behavior with `explore`, `synthesize`, `generate`, and `cascade`.
**CLI Hub** — Register any local CLI (`opencli register mycli`) so AI agents can discover and call it alongside built-in commands. Auto-installs missing tools via your package manager (e.g. if `gh` isn't installed, `opencli gh ...` runs `brew install gh` first then re-executes seamlessly).
It also works as a **CLI hub** for local tools such as `gh`, `docker`, and other binaries you register yourself, plus **desktop app adapters** for Electron apps like Cursor, Codex, Antigravity, ChatGPT, and Notion.
**CLI for Electron Apps** — Turn any Electron application into a CLI tool. Recombine, script, and extend apps like Antigravity Ultra from the terminal. AI agents can now control other AI apps natively.
## Why OpenCLI
---
## Highlights
- **CLI All Electron** — CLI-ify apps like Antigravity Ultra! Now AI can control itself natively.
- **Account-safe** — Reuses Chrome's logged-in state; your credentials never leave the browser.
- **Anti-detection built-in** — Patches `navigator.webdriver`, stubs `window.chrome`, fakes plugin lists, cleans ChromeDriver/Playwright globals, and strips CDP frames from Error stack traces. Extensive anti-fingerprinting and risk-control evasion measures baked in at every layer.
- **AI Agent ready** — `explore` discovers APIs, `synthesize` generates adapters, `cascade` finds auth strategies.
- **External CLI Hub** — Discover, auto-install, and passthrough commands to any external CLI (gh, obsidian, docker, etc). Zero setup.
- **Self-healing setup** — `opencli doctor` diagnoses and auto-starts the daemon, extension, and live browser connectivity.
- **Dynamic Loader** — Simply drop `.ts` or `.yaml` adapters into the `clis/` folder for auto-registration.
- **Dual-Engine Architecture** — Supports both YAML declarative data pipelines and robust browser runtime TypeScript injections.
## Why opencli?
There are many great browser automation tools. Here's when opencli is the right choice:
| Your need | Best tool | Why |
|-----------|-----------|-----|
| Scheduled data extraction from specific sites | **opencli** | Pre-built adapters, deterministic JSON, zero LLM cost |
| AI agent needs reliable site operations | **opencli** | Hundreds of commands, structured output, fast deterministic response |
| Explore an unknown website ad-hoc | Browser-Use, Stagehand | LLM-driven general browsing for one-off tasks |
| Large-scale web crawling | Crawl4AI, Scrapy | Purpose-built for throughput and scale |
| Control desktop Electron apps from terminal | **opencli** | CDP + AppleScript — the only CLI tool that does this |
**What makes opencli different:**
- **Zero LLM cost** — No tokens consumed at runtime. Run 10,000 times and pay nothing.
- **Deterministic** — Same command, same output schema, every time. Pipeable, scriptable, CI-friendly.
- **Broad coverage** — 50+ sites across global and Chinese platforms (Bilibili, Zhihu, Xiaohongshu, Reddit, HackerNews, and more), plus desktop Electron apps via CDP.
> For a detailed comparison with Browser-Use, Crawl4AI, Firecrawl, and others, see the [Comparison Guide](./docs/comparison.md).
---
- **One mental model**: use the same CLI for websites, browser automation, Electron apps, and local tools.
- **Reuse real sessions**: browser-backed commands run against your existing Chrome/Chromium login state instead of reimplementing auth.
- **Deterministic outputs**: adapters return stable, scriptable structures that work well in shells, CI, and AI-agent tool use.
- **AI-agent ready**: `browser` handles live control, `explore` discovers APIs, `synthesize` drafts adapters, and `cascade` probes auth strategies.
- **Low runtime cost**: no model tokens are consumed when running existing commands.
- **Extensible by default**: keep built-ins, register local CLIs, or drop `.ts` / `.yaml` adapters into `clis/`.
## Quick Start
### 1. Install Browser Bridge Extension
> OpenCLI connects to your browser through a lightweight **Browser Bridge** Chrome Extension + micro-daemon (zero config, auto-start).
1. Go to the GitHub [Releases page](https://github.com/jackwener/opencli/releases) and download the latest `opencli-extension.zip`.
2. Unzip the file and open `chrome://extensions`, enable **Developer mode** (top-right toggle).
3. Click **Load unpacked** and select the unzipped folder.
### 2. Install OpenCLI
**Install via npm (recommended)**
### 1. Install OpenCLI
```bash
npm install -g @jackwener/opencli
```
### 3. Verify & Try
### 2. Install the Browser Bridge Extension
OpenCLI connects to Chrome/Chromium through a lightweight Browser Bridge extension plus a small local daemon. The daemon auto-starts when needed.
1. Download the latest `opencli-extension.zip` from the GitHub [Releases page](https://github.com/jackwener/opencli/releases).
2. Unzip it, open `chrome://extensions`, and enable **Developer mode**.
3. Click **Load unpacked** and select the unzipped folder.
### 3. Verify the setup
```bash
opencli doctor # Check extension + daemon connectivity
opencli doctor
opencli daemon status
```
**Try it out:**
### 4. Run your first commands
```bash
opencli list # See all commands
opencli hackernews top --limit 5 # Public API, no browser needed
opencli bilibili hot --limit 5 # Browser command (requires Extension)
opencli list
opencli hackernews top --limit 5
opencli bilibili hot --limit 5
```
### Update
## For Humans
Use OpenCLI directly when you want a reliable command instead of a live browser session:
- `opencli list` shows every registered command.
- `opencli <site> <command>` runs a built-in or generated adapter.
- `opencli register mycli` exposes a local CLI through the same discovery surface.
- `opencli daemon status` and `opencli doctor` help diagnose browser connectivity.
## For AI Agents
Use two different entry points depending on the task:
- [`skills/opencli-generate/SKILL.md`](./skills/opencli-generate/SKILL.md): the task-level entry point for requests like "generate a CLI for this site".
- [`skills/opencli-browser/SKILL.md`](./skills/opencli-browser/SKILL.md): the low-level control surface for live browsing, debugging, and manual intervention.
Install the packaged skills with:
```bash
npx skills add jackwener/opencli
```
Or install only what you need:
```bash
npx skills add jackwener/opencli --skill opencli-usage
npx skills add jackwener/opencli --skill opencli-generate
npx skills add jackwener/opencli --skill opencli-browser
npx skills add jackwener/opencli --skill opencli-explorer
npx skills add jackwener/opencli --skill opencli-oneshot
```
In practice:
- start with `opencli-generate` when the agent needs a reusable command for a site
- use `opencli-browser` when the agent needs to inspect or steer the page directly
Available browser commands include `open`, `state`, `click`, `type`, `select`, `keys`, `wait`, `get`, `screenshot`, `scroll`, `back`, `eval`, `network`, `init`, `verify`, and `close`.
## Core Concepts
### `browser`: live control
Use `opencli browser` when the task is inherently interactive and the agent needs to operate the page directly.
### Built-in adapters: stable commands
Use site-specific commands such as `opencli hackernews top` or `opencli reddit hot` when the capability already exists and you want deterministic output.
### `explore` / `synthesize` / `generate`: create new CLIs
Use these commands when the site you need is not covered yet:
- `explore` inspects the page, network activity, and capability surface.
- `synthesize` turns exploration artifacts into evaluate-based YAML adapters.
- `generate` runs the verified generation path and returns either a usable command or a structured explanation of why completion was blocked or needs human review.
### `cascade`: auth strategy discovery
Use `cascade` to probe fallback auth paths such as public endpoints, cookies, and custom headers before you commit to an adapter design.
### CLI Hub and desktop adapters
OpenCLI is not only for websites. It can also:
- expose local binaries like `gh`, `docker`, `obsidian`, or custom tools through `opencli <tool> ...`
- control Electron desktop apps through dedicated adapters and CDP-backed integrations
## Prerequisites
- **Node.js**: >= 20.0.0 (or **Bun** >= 1.0)
- **Chrome or Chromium** running and logged into the target site for browser-backed commands
> **Important**: Browser-backed commands reuse your Chrome/Chromium login session. If you get empty data or permission-like failures, first confirm the site is already open and authenticated in Chrome/Chromium.
## Update
```bash
npm install -g @jackwener/opencli@latest
```
---
## For Developers
### For Developers
**Install from source**
Install from source:
```bash
git clone git@github.com:jackwener/opencli.git && cd opencli && npm install && npm run build && npm link
git clone git@github.com:jackwener/opencli.git
cd opencli
npm install
npm run build
npm link
```
**Load Source Browser Bridge Extension**
To load the source Browser Bridge extension:
1. Open `chrome://extensions` and enable **Developer mode** (top-right toggle).
2. Click **Load unpacked** and select the `extension/` directory from this repository.
---
## Prerequisites
- **Node.js**: >= 20.0.0 (or **Bun** >= 1.0)
- **Chrome** running **and logged into the target site** (e.g. bilibili.com, zhihu.com, xiaohongshu.com).
> **⚠️ Important**: Browser commands reuse your Chrome login session. You must be logged into the target website in Chrome before running commands. If you get empty data or errors, check your login status first.
1. Open `chrome://extensions` and enable **Developer mode**.
2. Click **Load unpacked** and select this repository's `extension/` directory.
## Built-in Commands
| Site | Commands |
|------|----------|
| **xiaohongshu** | `search` `feed` `user` `download` `publish` `comments` `notifications` `creator-notes` `creator-notes-summary` `creator-note-detail` `creator-profile` `creator-stats` |
| **xiaohongshu** | `search` `note` `comments` `feed` `user` `download` `publish` `notifications` `creator-notes` `creator-notes-summary` `creator-note-detail` `creator-profile` `creator-stats` |
| **bilibili** | `hot` `search` `history` `feed` `ranking` `download` `comments` `dynamic` `favorite` `following` `me` `subtitle` `user-videos` |
| **tieba** | `hot` `posts` `search` `read` |
| **hupu** | `hot` `search` `detail` `mentions` `reply` `like` `unlike` |
| **twitter** | `trending` `search` `timeline` `bookmarks` `post` `download` `profile` `article` `like` `likes` `notifications` `reply` `reply-dm` `thread` `follow` `unfollow` `followers` `following` `block` `unblock` `bookmark` `unbookmark` `delete` `hide-reply` `accept` |
| **reddit** | `hot` `frontpage` `popular` `search` `subreddit` `user` `user-posts` `user-comments` `read` `save` `saved` `subscribe` `upvote` `upvoted` `comment` |
| **reddit** | `hot` `frontpage` `popular` `search` `subreddit` `read` `user` `user-posts` `user-comments` `upvote` `upvoted` `save` `saved` `comment` `subscribe` |
| **zhihu** | `hot` `search` `question` `download` `follow` `like` `favorite` `comment` `answer` |
| **amazon** | `bestsellers` `search` `product` `offer` `discussion` `movers-shakers` `new-releases` |
| **1688** | `search` `item` `assets` `download` `store` |
| **gemini** | `new` `ask` `image` `deep-research` `deep-research-result` |
| **yuanbao** | `new` `ask` |
| **notebooklm** | `status` `list` `open` `current` `get` `history` `summary` `note-list` `notes-get` `source-list` `source-get` `source-fulltext` `source-guide` |
| **spotify** | `auth` `status` `play` `pause` `next` `prev` `volume` `search` `queue` `shuffle` `repeat` |
| **xianyu** | `search` `item` `chat` |
| **xiaoe** | `courses` `detail` `catalog` `play-url` `content` |
| **quark** | `ls` `mkdir` `mv` `rename` `rm` `save` `share-tree` |
65+ adapters in total — **[→ see all supported sites & commands](./docs/adapters/index.md)**
79+ adapters in total — **[→ see all supported sites & commands](./docs/adapters/index.md)**
## CLI Hub
@@ -133,8 +186,9 @@ OpenCLI acts as a universal hub for your existing command-line tools — unified
| **gh** | GitHub CLI | `opencli gh pr list --limit 5` |
| **obsidian** | Obsidian vault management | `opencli obsidian search query="AI"` |
| **docker** | Docker | `opencli docker ps` |
| **gws** | Google Workspace CLI | `opencli gws docs list` |
| **lark-cli** | Lark/Feishu — messages, docs, calendar, tasks, 200+ commands | `opencli lark-cli calendar +agenda` |
| **dingtalk** | DingTalk — cross-platform CLI for DingTalk's full suite, designed for humans and AI agents | `opencli dingtalk msg send --to user "hello"` |
| **wecom** | WeCom/企业微信 — CLI for WeCom open platform, for humans and AI agents | `opencli wecom msg send --to user "hello"` |
| **vercel** | Vercel — deploy projects, manage domains, env vars, logs | `opencli vercel deploy --prod` |
**Register your own** — add any local CLI so AI agents can discover it via `opencli list`:
@@ -171,6 +225,7 @@ OpenCLI supports downloading images, videos, and articles from supported platfor
| **twitter** | Images, Videos | From user media tab or single tweet |
| **douban** | Images | Poster / still image lists |
| **pixiv** | Images | Original-quality illustrations, multi-page |
| **1688** | Images, Videos | Downloads page-visible product media from item pages |
| **zhihu** | Articles (Markdown) | Exports with optional image download |
| **weixin** | Articles (Markdown) | WeChat Official Account articles |
@@ -180,6 +235,7 @@ For video downloads, install `yt-dlp` first: `brew install yt-dlp`
opencli xiaohongshu download abc123 --output ./xhs
opencli bilibili download BV1xxx --output ./bilibili
opencli twitter download elonmusk --limit 20 --output ./twitter
opencli 1688 download 841141931191 --output ./1688-downloads
```
## Output Formats
@@ -192,6 +248,28 @@ opencli bilibili hot -f csv # Spreadsheet-friendly
opencli bilibili hot -v # Verbose: show pipeline debug steps
```
## Exit Codes
opencli follows Unix `sysexits.h` conventions so it integrates naturally with shell pipelines and CI scripts:
| Code | Meaning | When |
|------|---------|------|
| `0` | Success | Command completed normally |
| `1` | Generic error | Unexpected / unclassified failure |
| `2` | Usage error | Bad arguments or unknown command |
| `66` | Empty result | No data returned (`EX_NOINPUT`) |
| `69` | Service unavailable | Browser Bridge not connected (`EX_UNAVAILABLE`) |
| `75` | Temporary failure | Command timed out — retry (`EX_TEMPFAIL`) |
| `77` | Auth required | Not logged in to target site (`EX_NOPERM`) |
| `78` | Config error | Missing credentials or bad config (`EX_CONFIG`) |
| `130` | Interrupted | Ctrl-C / SIGINT |
```bash
opencli spotify status || echo "exit $?" # 69 if browser not running
opencli github issues 2>/dev/null
[ $? -eq 77 ] && opencli github auth # auto-auth if not logged in
```
## Plugins
Extend OpenCLI with community-contributed adapters:
@@ -208,14 +286,15 @@ opencli plugin uninstall my-tool
| [opencli-plugin-github-trending](https://github.com/ByteYue/opencli-plugin-github-trending) | YAML | GitHub Trending repositories |
| [opencli-plugin-hot-digest](https://github.com/ByteYue/opencli-plugin-hot-digest) | TS | Multi-platform trending aggregator |
| [opencli-plugin-juejin](https://github.com/Astro-Han/opencli-plugin-juejin) | YAML | 稀土掘金 (Juejin) hot articles |
| [opencli-plugin-vk](https://github.com/flobo3/opencli-plugin-vk) | TS | VK (VKontakte) wall, feed, and search |
See [Plugins Guide](./docs/guide/plugins.md) for creating your own plugin.
## For AI Agents (Developer Guide)
> **Quick mode**: To generate a single command for a specific page URL, see [CLI-ONESHOT.md](./CLI-ONESHOT.md) — just a URL + one-line goal, 4 steps done.
> **Quick mode**: To generate a single command for a specific page URL, see [opencli-oneshot skill](./skills/opencli-oneshot/SKILL.md) — just a URL + one-line goal, 4 steps done.
> **Full mode**: Before writing any adapter code, read [CLI-EXPLORER.md](./CLI-EXPLORER.md). It contains the complete browser exploration workflow, the 5-tier authentication strategy decision tree, and debugging guide.
> **Full mode**: Before writing any adapter code, read [opencli-explorer skill](./skills/opencli-explorer/SKILL.md). It contains the complete browser exploration workflow, the 5-tier authentication strategy decision tree, and debugging guide.
```bash
opencli explore https://example.com --site mysite # Discover APIs + capabilities
@@ -230,9 +309,9 @@ See **[TESTING.md](./TESTING.md)** for how to run and write tests.
## Troubleshooting
- **"Extension not connected"** — Ensure the Browser Bridge extension is installed and **enabled** in `chrome://extensions`.
- **"Extension not connected"** — Ensure the Browser Bridge extension is installed and **enabled** in `chrome://extensions` in Chrome or Chromium.
- **"attach failed: Cannot access a chrome-extension:// URL"** — Another extension may be interfering. Try disabling other extensions temporarily.
- **Empty data or 'Unauthorized' error** — Your Chrome login session may have expired. Navigate to the target site and log in again.
- **Empty data or 'Unauthorized' error** — Your Chrome/Chromium login session may have expired. Navigate to the target site and log in again.
- **Node API errors** — Ensure Node.js >= 20. Some dependencies require modern Node APIs.
- **Daemon issues** — Check status: `curl localhost:19825/status` · View logs: `curl localhost:19825/logs`
+180 -95
View File
@@ -1,119 +1,159 @@
# OpenCLI
> **把任何网站、本地工具、Electron 应用变成能够让 AI 调用的命令行!**
> 零风控 · 复用 Chrome 登录 · AI 自动发现接口 · 全能 CLI 枢纽
> **把网站、浏览器会话、Electron 应用和本地工具,统一变成适合人类与 AI Agent 使用的确定性接口。**
> 复用浏览器登录态,先自动化真实操作,再把高频流程沉淀成可复用的 CLI 命令。
[![English](https://img.shields.io/badge/docs-English-1D4ED8?style=flat-square)](./README.md)
[![npm](https://img.shields.io/npm/v/@jackwener/opencli?style=flat-square)](https://www.npmjs.com/package/@jackwener/opencli)
[![Node.js Version](https://img.shields.io/node/v/@jackwener/opencli?style=flat-square)](https://nodejs.org)
[![License](https://img.shields.io/npm/l/@jackwener/opencli?style=flat-square)](./LICENSE)
OpenCLI 将任何网站、本地 CLI 或 Electron 应用(如 Antigravity)变成命令行工具 — B站、知乎、小红书、Twitter/X、Reddit、YouTube,以及 `gh``docker` 等[多种站点与工具](#内置命令) — 复用浏览器登录态,AI 驱动探索。
OpenCLI 可以用同一套 CLI 做三类事情:
**专为 AI Agent 打造**:只需在全局 `.cursorrules``AGENT.md` 中配置简单指令,引导 AI 通过 Bash 执行 `opencli list` 来检索可用的 CLI 工具及其用法。随后,将你常用的 CLI 列表整合注册进去(`opencli register mycli`),AI 便能瞬间学会自动调用相应的本地工具!
- **直接使用现成适配器**:B站、知乎、小红书、Twitter/X、Reddit、HackerNews 等 [79+ 站点](#内置命令) 开箱即用。
- **直接驱动浏览器**:用 `opencli browser` 让 AI Agent 实时点击、输入、提取、截图、检查页面状态。
- **把新网站生成成 CLI**:通过 `explore``synthesize``generate``cascade` 从真实页面行为推导出新的适配器。
**opencli 支持 CLI 化所有 electron 应用!最强大更新来袭!**
CLI all electron!现在支持把所有 electron 应用 CLI 化,从而组合出各种神奇的能力。
如果你在使用诸如 Antigravity Ultra 等工具时觉得不够灵活或难以扩展,现在通过 OpenCLI 把他 CLI 化,轻松打破界限。
现在,**AI 可以自己控制自己**!结合 cc/openclaw 就可以远程控制任何 electron 应用!无限玩法!!
除了网站能力,OpenCLI 还是一个 **CLI 枢纽**:你可以把 `gh``docker` 等本地工具统一注册到 `opencli` 下,也可以通过桌面端适配器控制 Cursor、Codex、Antigravity、ChatGPT、Notion 等 Electron 应用。
---
## 为什么是 OpenCLI
## 亮点
- **CLI All Electron** — 支持把所有 electron 应用(如 Antigravity UltraCLI 化,让 AI 控制自己!
- **多站点覆盖** — 覆盖 B站、知乎、小红书、Twitter、Reddit,以及多种桌面应用
- **零风控** — 复用 Chrome 登录态,无需存储任何凭证
- **外部 CLI 枢纽** — 统一发现、自动安装、透传执行 `gh``docker` 等本地 CLI
- **自修复配置** — `opencli doctor` 自动启动 daemon,诊断扩展和浏览器连接状态
- **AI 原生** — `explore` 自动发现 API`synthesize` 生成适配器,`cascade` 探测认证策略
- **动态加载引擎** — 声明式的 `.yaml` 或者底层定制的 `.ts` 适配器,放入 `clis/` 文件夹即可自动注册生效
## 为什么选 opencli
浏览器自动化工具很多,opencli 适合什么场景?
| 你的需求 | 最佳工具 | 原因 |
|----------|----------|------|
| 定时从特定站点提取结构化数据 | **opencli** | 预定义适配器,确定性 JSON 输出,零 LLM 成本 |
| AI Agent 需要可靠的站点操作 | **opencli** | 数百条命令,结构化输出,快速确定性响应 |
| 临时探索未知网站 | Browser-Use、Stagehand | LLM 驱动的通用浏览,适合一次性任务 |
| 大规模网页爬取 | Crawl4AI、Scrapy | 专为吞吐量和规模设计 |
| 从终端控制桌面 Electron 应用 | **opencli** | CDP + AppleScript,目前唯一能做到这一点的 CLI 工具 |
**opencli 的核心差异:**
- **零 LLM 成本** — 运行时不消耗任何 token,跑一万次不花一分钱
- **确定性** — 同一命令永远返回同一结构,可管道化、可脚本化、CI 友好
- **覆盖广泛** — 50+ 站点,横跨全球与中国平台(B站、知乎、小红书、Reddit、HackerNews 等),并支持通过 CDP 控制桌面 Electron 应用
> 与 Browser-Use、Crawl4AI、Firecrawl 等工具的详细对比,请查看 [Comparison Guide](./docs/comparison.md)。
## 前置要求
- **Node.js**: >= 20.0.0
- **Chrome** 浏览器正在运行,且**已登录目标网站**(如 bilibili.com、zhihu.com、xiaohongshu.com
> **⚠️ 重要**:大多数命令复用你的 Chrome 登录状态。运行命令前,你必须已在 Chrome 中打开目标网站并完成登录。如果获取到空数据或报错,请先检查你的浏览器登录状态。
OpenCLI 通过轻量化的 **Browser Bridge** Chrome 扩展 + 微型 daemon 与浏览器通信(零配置,自动启动)。
### Browser Bridge 扩展配置
你可以选择以下任一方式安装扩展:
**方式一:下载构建好的安装包(推荐)**
1. 到 GitHub [Releases 页面](https://github.com/jackwener/opencli/releases) 下载最新的 `opencli-extension.zip`
2. 解压后打开 Chrome 的 `chrome://extensions`,启用右上角的 **开发者模式**
3. 点击 **加载已解压的扩展程序**,选择解压后的文件夹。
**方式二:加载源码(针对开发者)**
1. 同样在 `chrome://extensions` 开启 **开发者模式**
2. 点击 **加载已解压的扩展程序**,选择本仓库代码树中的 `extension/` 文件夹。
完成!运行任何 opencli 浏览器命令时,后台微型 daemon 会自动启动与浏览器通信。无需配 API Token,零代码配置。
> **Tip**:后续诊断用 `opencli doctor`
> ```bash
> opencli doctor # 检查扩展和 daemon 连通性
> ```
- **同一个心智模型**:网站、浏览器自动化、Electron 应用、本地 CLI 都走同一个入口。
- **复用真实会话**:浏览器命令直接使用你已经登录的 Chrome/Chromium,而不是重新造一套认证。
- **输出稳定**:适配器命令返回固定结构,适合 shell、脚本、CI 和 AI Agent 工具调用。
- **面向 AI Agent**`browser` 负责实时操作,`explore` 负责探索接口,`synthesize` 负责生成适配器,`cascade` 负责探测认证路径。
- **运行成本低**:已有命令运行时不消耗模型 token。
- **天然可扩展**:既能用内置能力,也能注册本地 CLI,或直接往 `clis/``.ts` / `.yaml` 适配器。
## 快速开始
### npm 全局安装(推荐)
### 1. 安装 OpenCLI
```bash
npm install -g @jackwener/opencli
```
直接使用:
### 2. 安装 Browser Bridge 扩展
OpenCLI 通过轻量 Browser Bridge 扩展和本地微型 daemon 与 Chrome/Chromium 通信。daemon 会按需自动启动。
1. 到 GitHub [Releases 页面](https://github.com/jackwener/opencli/releases) 下载最新的 `opencli-extension.zip`
2. 解压后打开 `chrome://extensions`,启用 **开发者模式**
3. 点击 **加载已解压的扩展程序**,选择解压后的目录。
### 3. 验证环境
```bash
opencli list # 查看所有命令
opencli list -f yaml # 以 YAML 列出所有命令
opencli hackernews top --limit 5 # 公共 API,无需浏览器
opencli bilibili hot --limit 5 # 浏览器命令
opencli zhihu hot -f json # JSON 输出
opencli zhihu hot -f yaml # YAML 输出
opencli doctor
opencli daemon status
```
### 从源码安装(面向开发者)
### 4. 跑第一个命令
```bash
git clone git@github.com:jackwener/opencli.git
cd opencli
npm install
npm run build
npm link # 链接到全局环境
opencli list # 可以在任何地方使用了!
opencli list
opencli hackernews top --limit 5
opencli bilibili hot --limit 5
```
### 更新
## 给人类用户
如果你只是想稳定地调用网站或桌面应用能力,主路径很简单:
- `opencli list` 查看当前所有命令
- `opencli <site> <command>` 调用内置或生成好的适配器
- `opencli register mycli` 把本地 CLI 接入同一发现入口
- `opencli doctor` / `opencli daemon status` 处理浏览器连通性问题
## 给 AI Agent
按任务类型,AI Agent 有两个不同入口:
- [`skills/opencli-generate/SKILL.md`](./skills/opencli-generate/SKILL.md):任务级入口,适合“帮我给这个网站生成 CLI”这类请求。
- [`skills/opencli-browser/SKILL.md`](./skills/opencli-browser/SKILL.md):底层控制入口,适合实时操作页面、debug 和人工介入。
安装全部 OpenCLI skills
```bash
npx skills add jackwener/opencli
```
或只装需要的 skill
```bash
npx skills add jackwener/opencli --skill opencli-usage
npx skills add jackwener/opencli --skill opencli-generate
npx skills add jackwener/opencli --skill opencli-browser
npx skills add jackwener/opencli --skill opencli-explorer
npx skills add jackwener/opencli --skill opencli-oneshot
```
实际使用上:
- 需要把某个站点收成可复用命令时,优先走 `opencli-generate`
- 需要直接检查页面、操作页面时,再走 `opencli-browser`
`browser` 可用命令包括:`open``state``click``type``select``keys``wait``get``screenshot``scroll``back``eval``network``init``verify``close`
## 核心概念
### `browser`:实时操作
当任务本身就是交互式页面操作时,使用 `opencli browser` 直接驱动浏览器。
### 内置适配器:稳定命令
当某个站点能力已经存在时,优先使用 `opencli hackernews top``opencli reddit hot` 这类稳定命令,而不是重新走一遍浏览器操作。
### `explore` / `synthesize` / `generate`:生成新的 CLI
当你需要的网站还没覆盖时:
- `explore` 负责观察页面、网络请求和能力边界
- `synthesize` 负责把探索结果转成 evaluate-based YAML 适配器
- `generate` 负责跑通 verified generation 主链路,最后要么给出可直接使用的命令,要么返回结构化的阻塞原因 / 人工介入结果
### `cascade`:认证策略探测
`cascade` 去判断某个能力应该优先走公开接口、Cookie 还是自定义 Header,而不是一开始就把适配器写死。
### CLI 枢纽与桌面端适配器
OpenCLI 不只是网站 CLI,还可以:
- 统一代理本地二进制工具,例如 `gh``docker``obsidian`
- 通过专门适配器和 CDP 集成控制 Electron 桌面应用
## 前置要求
- **Node.js**: >= 20.0.0
- 浏览器型命令需要 Chrome 或 Chromium 处于运行中,并已登录目标网站
> **重要**:浏览器型命令直接复用你的 Chrome/Chromium 登录态。如果拿到空数据或出现权限类失败,先确认目标站点已经在浏览器里打开并完成登录。
## 更新
```bash
npm install -g @jackwener/opencli@latest
```
## 面向开发者
从源码安装:
```bash
git clone git@github.com:jackwener/opencli.git
cd opencli
npm install
npm run build
npm link
```
加载源码版 Browser Bridge 扩展:
1. 打开 `chrome://extensions` 并启用 **开发者模式**
2. 点击 **加载已解压的扩展程序**,选择本仓库里的 `extension/` 目录
## 内置命令
运行 `opencli list` 查看完整注册表。
@@ -122,22 +162,26 @@ npm install -g @jackwener/opencli@latest
|------|------|------|
| **twitter** | `trending` `bookmarks` `profile` `search` `timeline` `thread` `following` `followers` `notifications` `post` `reply` `delete` `like` `article` `follow` `unfollow` `bookmark` `unbookmark` `download` `accept` `reply-dm` `block` `unblock` `hide-reply` | 浏览器 |
| **reddit** | `hot` `frontpage` `popular` `search` `subreddit` `read` `user` `user-posts` `user-comments` `upvote` `save` `comment` `subscribe` `saved` `upvoted` | 浏览器 |
| **tieba** | `hot` `posts` `search` `read` | 浏览器 |
| **hupu** | `hot` `search` `detail` `mentions` `reply` `like` `unlike` | 浏览器 |
| **cursor** | `status` `send` `read` `new` `dump` `composer` `model` `extract-code` `ask` `screenshot` `history` `export` | 桌面端 |
| **bilibili** | `hot` `search` `me` `favorite` `history` `feed` `subtitle` `dynamic` `ranking` `following` `user-videos` `download` | 浏览器 |
| **codex** | `status` `send` `read` `new` `dump` `extract-diff` `model` `ask` `screenshot` `history` `export` | 桌面端 |
| **chatwise** | `status` `new` `send` `read` `ask` `model` `history` `export` `screenshot` | 桌面端 |
| **doubao** | `status` `new` `send` `read` `ask` | 浏览器 |
| **doubao** | `status` `new` `send` `read` `ask` `history` `detail` `meeting-summary` `meeting-transcript` | 浏览器 |
| **doubao-app** | `status` `new` `send` `read` `ask` `screenshot` `dump` | 桌面端 |
| **notion** | `status` `search` `read` `new` `write` `sidebar` `favorites` `export` | 桌面端 |
| **discord-app** | `status` `send` `read` `channels` `servers` `search` `members` | 桌面端 |
| **v2ex** | `hot` `latest` `topic` `node` `user` `member` `replies` `nodes` `daily` `me` `notifications` | 公开 / 浏览器 |
| **xueqiu** | `feed` `hot-stock` `hot` `search` `stock` `watchlist` `earnings-date` `fund-holdings` `fund-snapshot` | 浏览器 |
| **xueqiu** | `feed` `hot-stock` `hot` `search` `stock` `comments` `watchlist` `earnings-date` `fund-holdings` `fund-snapshot` | 浏览器 |
| **antigravity** | `status` `send` `read` `new` `dump` `extract-code` `model` `watch` | 桌面端 |
| **chatgpt** | `status` `new` `send` `read` `ask` `model` | 桌面端 |
| **xiaohongshu** | `search` `notifications` `feed` `user` `download` `publish` `creator-notes` `creator-note-detail` `creator-notes-summary` `creator-profile` `creator-stats` | 浏览器 |
| **xiaoe** | `courses` `detail` `catalog` `play-url` `content` | 浏览器 |
| **quark** | `ls` `mkdir` `mv` `rename` `rm` `save` `share-tree` | 浏览器 |
| **apple-podcasts** | `search` `episodes` `top` | 公开 |
| **xiaoyuzhou** | `podcast` `podcast-episodes` `episode` | 公开 |
| **zhihu** | `hot` `search` `question` `download` | 浏览器 |
| **zhihu** | `hot` `search` `question` `download` `follow` `like` `favorite` `comment` `answer` | 浏览器 |
| **weixin** | `download` | 浏览器 |
| **youtube** | `search` `video` `transcript` | 浏览器 |
| **boss** | `search` `detail` `recommend` `joblist` `greet` `batchgreet` `send` `chatlist` `chatmsg` `invite` `mark` `exchange` `resume` `stats` | 浏览器 |
@@ -156,7 +200,7 @@ npm install -g @jackwener/opencli@latest
| **reuters** | `search` | 浏览器 |
| **smzdm** | `search` | 浏览器 |
| **web** | `read` | 浏览器 |
| **weibo** | `hot` `search` | 浏览器 |
| **weibo** | `hot` `search` `feed` `user` `me` `post` `comments` | 浏览器 |
| **yahoo-finance** | `quote` | 浏览器 |
| **sinafinance** | `news` | 🌐 公开 |
| **barchart** | `quote` `options` `greeks` `flow` | 浏览器 |
@@ -166,13 +210,18 @@ npm install -g @jackwener/opencli@latest
| **jike** | `feed` `search` `create` `like` `comment` `repost` `notifications` `post` `topic` `user` | 浏览器 |
| **jimeng** | `generate` `history` | 浏览器 |
| **yollomi** | `generate` `video` `edit` `upload` `models` `remove-bg` `upscale` `face-swap` `restore` `try-on` `background` `object-remover` | 浏览器 |
| **linux-do** | `feed` `categories` `tags` `search` `topic` `user-topics` `user-posts` | 浏览器 |
| **linux-do** | `hot` `latest` `feed` `search` `categories` `category` `tags` `topic` `topic-content` `user-posts` `user-topics` | 浏览器 |
| **stackoverflow** | `hot` `search` `bounties` `unanswered` | 公开 |
| **steam** | `top-sellers` | 公开 |
| **weread** | `shelf` `search` `book` `highlights` `notes` `notebooks` `ranking` | 浏览器 |
| **douban** | `search` `top250` `subject` `photos` `download` `marks` `reviews` `movie-hot` `book-hot` | 浏览器 |
| **facebook** | `feed` `profile` `search` `friends` `groups` `events` `notifications` `memories` `add-friend` `join-group` | 浏览器 |
| **google** | `news` `search` `suggest` `trends` | 公开 |
| **amazon** | `bestsellers` `search` `product` `offer` `discussion` `movers-shakers` `new-releases` | 浏览器 |
| **1688** | `search` `item` `assets` `download` `store` | 浏览器 |
| **gemini** | `new` `ask` `image` `deep-research` `deep-research-result` | 浏览器 |
| **spotify** | `auth` `status` `play` `pause` `next` `prev` `volume` `search` `queue` `shuffle` `repeat` | OAuth API |
| **notebooklm** | `status` `list` `open` `current` `get` `history` `summary` `note-list` `notes-get` `source-list` `source-get` `source-fulltext` `source-guide` | 浏览器 |
| **36kr** | `news` `hot` `search` `article` | 公开 / 浏览器 |
| **imdb** | `search` `title` `top` `trending` `person` `reviews` | 公开 |
| **producthunt** | `posts` `today` `hot` `browse` | 公开 / 浏览器 |
@@ -183,7 +232,12 @@ npm install -g @jackwener/opencli@latest
| **substack** | `feed` `search` `publication` | 浏览器 |
| **pixiv** | `ranking` `search` `user` `illusts` `detail` `download` | 浏览器 |
| **tiktok** | `explore` `search` `profile` `user` `following` `follow` `unfollow` `like` `unlike` `comment` `save` `unsave` `live` `notifications` `friends` | 浏览器 |
| **bluesky** | `search` `trending` `user` `profile` `thread` `feeds` `followers` `following` `starter-packs` | 公开 |
| **xianyu** | `search` `item` `chat` | 浏览器 |
| **douyin** | `videos` `publish` `drafts` `draft` `delete` `stats` `profile` `update` `hashtag` `location` `activities` `collections` | 浏览器 |
| **yuanbao** | `new` `ask` | 浏览器 |
79+ 适配器 — **[→ 查看完整命令列表](./docs/adapters/index.md)**
### 外部 CLI 枢纽
@@ -194,8 +248,10 @@ OpenCLI 也可以作为你现有命令行工具的统一入口,负责发现、
| **gh** | GitHub CLI | `opencli gh pr list --limit 5` |
| **obsidian** | Obsidian 仓库管理 | `opencli obsidian search query="AI"` |
| **docker** | Docker 命令行工具 | `opencli docker ps` |
| **readwise** | Readwise / Reader CLI | `opencli readwise login` |
| **gws** | Google Workspace CLI — Docs, Sheets, Drive, Gmail, Calendar | `opencli gws docs list` |
| **lark-cli** | 飞书 CLI — 消息、文档、日历、任务,200+ 命令 | `opencli lark-cli calendar +agenda` |
| **dingtalk** | 钉钉 CLI — 钉钉全套产品能力的跨平台命令行工具,支持人类和 AI Agent 使用 | `opencli dingtalk msg send --to user "hello"` |
| **wecom** | 企业微信 CLI — 企业微信开放平台命令行工具,支持人类和 AI Agent 使用 | `opencli wecom msg send --to user "hello"` |
| **vercel** | Vercel — 部署项目、管理域名、环境变量、日志 | `opencli vercel deploy --prod` |
**零配置透传**:OpenCLI 会把你的输入原样转发给底层二进制,保留原生 stdout / stderr 行为。
@@ -234,6 +290,7 @@ OpenCLI 支持从各平台下载图片、视频和文章。
| **B站** | 视频 | 需要安装 `yt-dlp` |
| **Twitter/X** | 图片、视频 | 从用户媒体页或单条推文下载 |
| **Pixiv** | 图片 | 下载原始画质插画,支持多页作品 |
| **1688** | 图片、视频 | 下载商品页中可见的商品素材 |
| **知乎** | 文章(Markdown) | 导出文章,可选下载图片到本地 |
| **微信公众号** | 文章(Markdown | 导出微信公众号文章为 Markdown |
| **豆瓣** | 图片 | 下载电影条目的海报 / 剧照图片 |
@@ -268,6 +325,9 @@ opencli twitter download --tweet-url "https://x.com/user/status/123" --output ./
# 下载豆瓣电影海报 / 剧照
opencli douban download 30382501 --output ./douban
# 下载 1688 商品页中的图片 / 视频素材
opencli 1688 download 841141931191 --output ./1688-downloads
# 导出知乎文章为 Markdown
opencli zhihu download "https://zhuanlan.zhihu.com/p/xxx" --output ./zhihu
@@ -295,6 +355,31 @@ opencli bilibili hot -f csv # CSV
opencli bilibili hot -v # 详细模式:展示管线执行步骤调试信息
```
## 退出码
opencli 遵循 Unix `sysexits.h` 惯例,可无缝接入 shell 管道和 CI 脚本:
| 退出码 | 含义 | 触发场景 |
|--------|------|----------|
| `0` | 成功 | 命令正常完成 |
| `1` | 通用错误 | 未分类的意外错误 |
| `2` | 用法错误 | 参数错误或未知命令 |
| `66` | 无数据 | 命令返回空结果(`EX_NOINPUT` |
| `69` | 服务不可用 | Browser Bridge 未连接(`EX_UNAVAILABLE` |
| `75` | 临时失败 | 命令超时,可重试(`EX_TEMPFAIL` |
| `77` | 需要认证 | 未登录目标网站(`EX_NOPERM` |
| `78` | 配置错误 | 凭证缺失或配置有误(`EX_CONFIG` |
| `130` | 中断 | Ctrl-C / SIGINT |
```bash
opencli bilibili hot 2>/dev/null
case $? in
0) echo "ok" ;;
69) echo "请先启动 Browser Bridge" ;;
77) echo "请先登录 bilibili.com" ;;
esac
```
## 插件
通过社区贡献的插件扩展 OpenCLI。插件使用与内置命令相同的 YAML/TS 格式,启动时自动发现。
@@ -321,9 +406,9 @@ opencli plugin uninstall my-tool # 卸载
如果你是一个被要求查阅代码并编写新 `opencli` 适配器的 AI,请遵守以下工作流。
> **快速模式**:只想为某个页面快速生成一个命令?看 [CLI-ONESHOT.md](./CLI-ONESHOT.md) — 给一个 URL + 一句话描述,4 步搞定。
> **快速模式**:只想为某个页面快速生成一个命令?看 [opencli-oneshot skill](./skills/opencli-oneshot/SKILL.md) — 给一个 URL + 一句话描述,4 步搞定。
> **完整模式**:在编写任何新代码前,先阅读 [CLI-EXPLORER.md](./CLI-EXPLORER.md)。它包含完整的适配器探索开发指南、API 探测流程、5级认证策略以及常见陷阱。
> **完整模式**:在编写任何新代码前,先阅读 [opencli-explorer skill](./skills/opencli-explorer/SKILL.md)。它包含完整的适配器探索开发指南、API 探测流程、5级认证策略以及常见陷阱。
```bash
# 1. Deep Explore — 网络拦截 → 响应分析 → 能力推理 → 框架检测
@@ -344,11 +429,11 @@ opencli cascade https://api.example.com/data
## 常见问题排查
- **"Extension not connected" 报错**
- 确保你当前的 Chrome 已安装且**开启了** opencli Browser Bridge 扩展(在 `chrome://extensions` 中检查)。
- 确保你当前的 Chrome 或 Chromium 已安装且**开启了** opencli Browser Bridge 扩展(在 `chrome://extensions` 中检查)。
- **"attach failed: Cannot access a chrome-extension:// URL" 报错**
- 其他 Chrome 扩展(如 youmind、New Tab Override 或 AI 助手类扩展)可能产生冲突。请尝试**暂时禁用其他扩展**后重试。
- 其他 Chrome/Chromium 扩展(如 youmind、New Tab Override 或 AI 助手类扩展)可能产生冲突。请尝试**暂时禁用其他扩展**后重试。
- **返回空数据,或者报错 "Unauthorized"**
- Chrome 里的登录态可能已经过期。请打开当前 Chrome 页面,在新标签页重新手工登录或刷新该页面。
- Chrome/Chromium 里的登录态可能已经过期。请打开当前页面,在新标签页重新手工登录或刷新该页面。
- **Node API 错误 (如 parseArgs, fs 等)**
- 确保 Node.js 版本 `>= 20`
- **Daemon 问题**
-879
View File
@@ -1,879 +0,0 @@
---
name: opencli
description: "OpenCLI — Make any website or Electron App your CLI. Zero risk, AI-powered, reuse Chrome login."
version: 1.4.1
author: jackwener
tags: [cli, browser, web, chrome-extension, cdp, bilibili, zhihu, twitter, github, v2ex, hackernews, reddit, xiaohongshu, xueqiu, youtube, boss, coupang, yollomi, AI, agent]
---
# OpenCLI
> Make any website or Electron App your CLI. Reuse Chrome login, zero risk, AI-powered discovery.
> [!CAUTION]
> **AI Agent 必读:创建或修改任何适配器之前,你必须先阅读 [CLI-EXPLORER.md](./CLI-EXPLORER.md)**
> 该文档包含完整的 API 发现工作流(必须使用浏览器探索)、5 级认证策略决策树、平台 SDK 速查表、`tap` 步骤调试流程、分页 API 模板、级联请求模式、以及常见陷阱。
> **本文件(SKILL.md)仅提供命令参考和简化模板,不足以正确开发适配器。**
> [!IMPORTANT]
> 创建或修改 adapter 时,再额外遵守 3 条收口规则:
> 1. 主参数优先用 positional arg,不要把 `query` / `id` / `url` 默认做成 `--query` / `--id` / `--url`
> 2. 预期中的 adapter 失败优先抛 `CliError` 子类,不要直接 throw 原始 `Error`
> 3. 新增 adapter 或新增用户可发现命令时,同步更新 adapter docs、`docs/adapters/index.md`、sidebar,以及 README/README.zh-CN 中受影响的入口
## Install & Run
```bash
# npm global install (recommended)
npm install -g @jackwener/opencli
opencli <command>
# Or from source
cd ~/code/opencli && npm install
npx tsx src/main.ts <command>
# Update to latest
npm update -g @jackwener/opencli
```
## Prerequisites
Browser commands require:
1. Chrome browser running **(logged into target sites)**
2. **opencli Browser Bridge** Chrome extension installed (load `extension/` as unpacked in `chrome://extensions`)
3. No further setup needed — the daemon auto-starts on first browser command
> **Note**: You must be logged into the target website in Chrome before running commands. Tabs opened during command execution are auto-closed afterwards.
Public API commands (`hackernews`, `v2ex`) need no browser.
## Commands Reference
### Data Commands
```bash
# Bilibili (browser)
opencli bilibili hot --limit 10 # B站热门视频
opencli bilibili search "rust" # 搜索视频 (query positional)
opencli bilibili me # 我的信息
opencli bilibili favorite # 我的收藏
opencli bilibili history --limit 20 # 观看历史
opencli bilibili feed --limit 10 # 动态时间线
opencli bilibili user-videos --uid 12345 # 用户投稿
opencli bilibili subtitle --bvid BV1xxx # 获取视频字幕 (支持 --lang zh-CN)
opencli bilibili dynamic --limit 10 # 动态
opencli bilibili ranking --limit 10 # 排行榜
opencli bilibili following --limit 20 # 我的关注列表 (支持 --uid 查看他人)
# 知乎 (browser)
opencli zhihu hot --limit 10 # 知乎热榜
opencli zhihu search "AI" # 搜索 (query positional)
opencli zhihu question 34816524 # 问题详情和回答 (id positional)
# 小红书 (browser)
opencli xiaohongshu search "美食" # 搜索笔记 (query positional)
opencli xiaohongshu notifications # 通知(mentions/likes/connections
opencli xiaohongshu feed --limit 10 # 推荐 Feed
opencli xiaohongshu user xxx # 用户主页 (id positional)
opencli xiaohongshu creator-notes --limit 10 # 创作者笔记列表
opencli xiaohongshu creator-note-detail --note-id xxx # 笔记详情
opencli xiaohongshu creator-notes-summary # 笔记数据概览
opencli xiaohongshu creator-profile # 创作者资料
opencli xiaohongshu creator-stats # 创作者数据统计
# 雪球 Xueqiu (browser)
opencli xueqiu hot-stock --limit 10 # 雪球热门股票榜
opencli xueqiu stock --symbol SH600519 # 查看股票实时行情
opencli xueqiu watchlist # 获取自选股/持仓列表
opencli xueqiu feed # 我的关注 timeline
opencli xueqiu hot --limit 10 # 雪球热榜
opencli xueqiu search "特斯拉" # 搜索 (query positional)
opencli xueqiu earnings-date SH600519 # 股票财报发布日期 (symbol positional)
opencli xueqiu fund-holdings # 蛋卷基金持仓明细 (支持 --account 过滤)
opencli xueqiu fund-snapshot # 蛋卷基金快照(总资产、子账户、持仓)
# GitHub (via gh External CLI)
opencli gh repo list # 列出仓库 (passthrough to gh)
opencli gh pr list --limit 5 # PR 列表
opencli gh issue list # Issue 列表
# Twitter/X (browser)
opencli twitter trending --limit 10 # 热门话题
opencli twitter bookmarks --limit 20 # 获取收藏的书签推文
opencli twitter search "AI" # 搜索推文 (query positional)
opencli twitter profile elonmusk # 用户资料
opencli twitter timeline --limit 20 # 时间线
opencli twitter thread 1234567890 # 推文 thread(原文 + 回复)
opencli twitter article 1891511252174299446 # 推文长文内容
opencli twitter follow elonmusk # 关注用户
opencli twitter unfollow elonmusk # 取消关注
opencli twitter bookmark https://x.com/... # 收藏推文
opencli twitter unbookmark https://x.com/... # 取消收藏
opencli twitter post "Hello world" # 发布推文 (text positional)
opencli twitter like https://x.com/... # 点赞推文 (url positional)
opencli twitter reply https://x.com/... "Nice!" # 回复推文 (url + text positional)
opencli twitter delete https://x.com/... # 删除推文 (url positional)
opencli twitter block elonmusk # 屏蔽用户 (username positional)
opencli twitter unblock elonmusk # 取消屏蔽 (username positional)
opencli twitter followers elonmusk # 用户的粉丝列表 (user positional)
opencli twitter following elonmusk # 用户的关注列表 (user positional)
opencli twitter notifications --limit 20 # 通知列表
opencli twitter hide-reply https://x.com/... # 隐藏回复 (url positional)
opencli twitter download elonmusk # 下载用户媒体 (username positional, 支持 --tweet-url)
opencli twitter accept "群,微信" # 自动接受含关键词的 DM 请求 (query positional)
opencli twitter reply-dm "消息内容" # 批量回复 DM (text positional)
# Reddit (browser)
opencli reddit hot --limit 10 # 热门帖子
opencli reddit hot --subreddit programming # 指定子版块
opencli reddit frontpage --limit 10 # 首页 /r/all
opencli reddit popular --limit 10 # /r/popular 热门
opencli reddit search "AI" --sort top --time week # 搜索(支持排序+时间过滤)
opencli reddit subreddit rust --sort top --time month # 子版块浏览(支持时间过滤)
opencli reddit read --post-id 1abc123 # 阅读帖子 + 评论
opencli reddit user spez # 用户资料(karma、注册时间)
opencli reddit user-posts spez # 用户发帖历史
opencli reddit user-comments spez # 用户评论历史
opencli reddit upvote --post-id xxx --direction up # 投票(up/down/none
opencli reddit save --post-id xxx # 收藏帖子
opencli reddit comment --post-id xxx "Great!" # 发表评论 (text positional)
opencli reddit subscribe --subreddit python # 订阅子版块
opencli reddit saved --limit 10 # 我的收藏
opencli reddit upvoted --limit 10 # 我的赞
# V2EX (public + browser)
opencli v2ex hot --limit 10 # 热门话题
opencli v2ex latest --limit 10 # 最新话题
opencli v2ex topic 1024 # 主题详情 (id positional)
opencli v2ex daily # 每日签到 (browser)
opencli v2ex me # 我的信息 (browser)
opencli v2ex notifications --limit 10 # 通知 (browser)
opencli v2ex node python # 节点话题列表 (name positional)
opencli v2ex nodes --limit 30 # 所有节点列表
opencli v2ex member username # 用户资料 (username positional)
opencli v2ex user username # 用户发帖列表 (username positional)
opencli v2ex replies 1024 # 主题回复列表 (id positional)
# Hacker News (public)
opencli hackernews top --limit 10 # Top stories
opencli hackernews new --limit 10 # Newest stories
opencli hackernews best --limit 10 # Best stories
opencli hackernews ask --limit 10 # Ask HN posts
opencli hackernews show --limit 10 # Show HN posts
opencli hackernews jobs --limit 10 # Job postings
opencli hackernews search "rust" # 搜索 (query positional)
opencli hackernews user dang # 用户资料 (username positional)
# BBC (public)
opencli bbc news --limit 10 # BBC News RSS headlines
# 微博 (browser)
opencli weibo hot --limit 10 # 微博热搜
# BOSS直聘 (browser)
opencli boss search "AI agent" # 搜索职位 (query positional)
opencli boss detail --security-id xxx # 职位详情
opencli boss recommend --limit 10 # 推荐职位
opencli boss joblist --limit 10 # 职位列表
opencli boss greet --security-id xxx # 打招呼
opencli boss batchgreet --job-id xxx # 批量打招呼
opencli boss send --uid xxx "消息内容" # 发消息 (text positional)
opencli boss chatlist --limit 10 # 聊天列表
opencli boss chatmsg --security-id xxx # 聊天记录
opencli boss invite --security-id xxx # 邀请沟通
opencli boss mark --security-id xxx # 标记管理
opencli boss exchange --security-id xxx # 交换联系方式
opencli boss resume # 简历管理
opencli boss stats # 数据统计
# YouTube (browser)
opencli youtube search "rust" # 搜索视频 (query positional)
opencli youtube video "https://www.youtube.com/watch?v=xxx" # 视频元数据
opencli youtube transcript "https://www.youtube.com/watch?v=xxx" # 获取视频字幕/转录
opencli youtube transcript "xxx" --lang zh-Hans --mode raw # 指定语言 + 原始时间戳模式
# Yahoo Finance (browser)
opencli yahoo-finance quote --symbol AAPL # 股票行情
# Sina Finance
opencli sinafinance news --limit 10 --type 1 # 7x24实时快讯 (0=全部 1=A股 2=宏观 3=公司 4=数据 5=市场 6=国际 7=观点 8=央行 9=其它)
# Reuters (browser)
opencli reuters search "AI" # 路透社搜索 (query positional)
# 什么值得买 (browser)
opencli smzdm search "耳机" # 搜索好价 (query positional)
# 携程 (browser)
opencli ctrip search "三亚" # 搜索目的地 (query positional)
# Antigravity (Electron/CDP)
opencli antigravity status # 检查 CDP 连接
opencli antigravity send "hello" # 发送文本到当前 agent 聊天框
opencli antigravity read # 读取整个聊天记录面板
opencli antigravity new # 清空聊天、开启新对话
opencli antigravity dump # 导出 DOM 和快照调试信息
opencli antigravity extract-code # 自动抽取 AI 回复中的代码块
opencli antigravity model claude # 切换底层模型
opencli antigravity watch # 流式监听增量消息
# Barchart (browser)
opencli barchart quote --symbol AAPL # 股票行情
opencli barchart options --symbol AAPL # 期权链
opencli barchart greeks --symbol AAPL # 期权 Greeks
opencli barchart flow --limit 20 # 异常期权活动
# Jike 即刻 (browser)
opencli jike feed --limit 10 # 动态流
opencli jike search "AI" # 搜索 (query positional)
opencli jike create "内容" # 发布动态 (text positional)
opencli jike like xxx # 点赞 (id positional)
opencli jike comment xxx "评论" # 评论 (id + text positional)
opencli jike repost xxx # 转发 (id positional)
opencli jike notifications # 通知
# Linux.do (public + browser)
opencli linux-do hot --limit 10 # 热门话题
opencli linux-do latest --limit 10 # 最新话题
opencli linux-do search "rust" # 搜索 (query positional)
opencli linux-do topic 1024 # 主题详情 (id positional)
opencli linux-do categories --limit 20 # 分类列表 (browser)
opencli linux-do category dev 7 # 分类内话题 (slug + id positional, browser)
# StackOverflow (public)
opencli stackoverflow hot --limit 10 # 热门问题
opencli stackoverflow search "typescript" # 搜索 (query positional)
opencli stackoverflow bounties --limit 10 # 悬赏问题
# WeRead 微信读书 (browser)
opencli weread shelf --limit 10 # 书架
opencli weread search "AI" # 搜索图书 (query positional)
opencli weread book xxx # 图书详情 (book-id positional)
opencli weread highlights xxx # 划线笔记 (book-id positional)
opencli weread notes xxx # 想法笔记 (book-id positional)
opencli weread ranking --limit 10 # 排行榜
# Jimeng 即梦 AI (browser)
opencli jimeng generate --prompt "描述" # AI 生图
opencli jimeng history --limit 10 # 生成历史
# Yollomi yollomi.com (browser — 需在 Chrome 登录 yollomi.com,复用站点 session)
opencli yollomi models --type image # 列出图像模型与积分
opencli yollomi generate "提示词" --model z-image-turbo # 文生图
opencli yollomi video "提示词" --model kling-2-1 # 视频
opencli yollomi upload ./photo.jpg # 上传得 URL,供 img2img / 工具链使用
opencli yollomi remove-bg <image-url> # 去背景(免费)
opencli yollomi edit <image-url> "改成油画风格" # Qwen 图像编辑
opencli yollomi background <image-url> # AI 背景生成 (5 credits)
opencli yollomi face-swap --source <url> --target <url> # 换脸 (3 credits)
opencli yollomi object-remover <image-url> <mask-url> # AI 去除物体 (3 credits)
opencli yollomi restore <image-url> # AI 修复老照片 (4 credits)
opencli yollomi try-on --person <url> --cloth <url> # 虚拟试衣 (3 credits)
opencli yollomi upscale <image-url> # AI 超分辨率 (1 credit, 支持 --scale 2/4)
# Grok (default + explicit web)
opencli grok ask --prompt "问题" # 提问 Grok(兼容默认路径)
opencli grok ask --prompt "问题" --web # 显式 grok.com consumer web UI 路径
# HuggingFace (public)
opencli hf top --limit 10 # 热门模型
# 超星学习通 (browser)
opencli chaoxing assignments # 作业列表
opencli chaoxing exams # 考试列表
# Douban 豆瓣 (browser)
opencli douban search "三体" # 搜索 (query positional)
opencli douban top250 # 豆瓣 Top 250
opencli douban subject 1234567 # 条目详情 (id positional)
opencli douban photos 30382501 # 图片列表 / 直链(默认海报)
opencli douban download 30382501 # 下载海报 / 剧照
opencli douban marks --limit 10 # 我的标记
opencli douban reviews --limit 10 # 短评
# Facebook (browser)
opencli facebook feed --limit 10 # 动态流
opencli facebook profile username # 用户资料 (id positional)
opencli facebook search "AI" # 搜索 (query positional)
opencli facebook friends # 好友列表
opencli facebook groups # 群组
opencli facebook events # 活动
opencli facebook notifications # 通知
opencli facebook memories # 回忆
opencli facebook add-friend username # 添加好友 (id positional)
opencli facebook join-group groupid # 加入群组 (id positional)
# Instagram (browser)
opencli instagram explore # 探索
opencli instagram profile username # 用户资料 (id positional)
opencli instagram search "AI" # 搜索 (query positional)
opencli instagram user username # 用户详情 (id positional)
opencli instagram followers username # 粉丝 (id positional)
opencli instagram following username # 关注 (id positional)
opencli instagram follow username # 关注用户 (id positional)
opencli instagram unfollow username # 取消关注 (id positional)
opencli instagram like postid # 点赞 (id positional)
opencli instagram unlike postid # 取消点赞 (id positional)
opencli instagram comment postid "评论" # 评论 (id + text positional)
opencli instagram save postid # 收藏 (id positional)
opencli instagram unsave postid # 取消收藏 (id positional)
opencli instagram saved # 已收藏列表
# TikTok (browser)
opencli tiktok explore # 探索
opencli tiktok search "AI" # 搜索 (query positional)
opencli tiktok profile username # 用户资料 (id positional)
opencli tiktok user username # 用户详情 (id positional)
opencli tiktok following username # 关注列表 (id positional)
opencli tiktok follow username # 关注 (id positional)
opencli tiktok unfollow username # 取消关注 (id positional)
opencli tiktok like videoid # 点赞 (id positional)
opencli tiktok unlike videoid # 取消点赞 (id positional)
opencli tiktok comment videoid "评论" # 评论 (id + text positional)
opencli tiktok save videoid # 收藏 (id positional)
opencli tiktok unsave videoid # 取消收藏 (id positional)
opencli tiktok live # 直播
opencli tiktok notifications # 通知
opencli tiktok friends # 朋友
# Medium (browser)
opencli medium feed --limit 10 # 动态流
opencli medium search "AI" # 搜索 (query positional)
opencli medium user username # 用户主页 (id positional)
# Substack (browser)
opencli substack feed --limit 10 # 订阅动态
opencli substack search "AI" # 搜索 (query positional)
opencli substack publication name # 出版物详情 (id positional)
# Sinablog 新浪博客 (browser)
opencli sinablog hot --limit 10 # 热门
opencli sinablog search "AI" # 搜索 (query positional)
opencli sinablog article url # 文章详情
opencli sinablog user username # 用户主页 (id positional)
# Lobsters (public)
opencli lobsters hot --limit 10 # 热门
opencli lobsters newest --limit 10 # 最新
opencli lobsters active --limit 10 # 活跃
opencli lobsters tag rust # 按标签筛选 (tag positional)
# Google (public)
opencli google news --limit 10 # 新闻
opencli google search "AI" # 搜索 (query positional)
opencli google suggest "AI" # 搜索建议 (query positional)
opencli google trends # 趋势
# DEV.to (public)
opencli devto top --limit 10 # 热门文章
opencli devto tag javascript --limit 10 # 按标签 (tag positional)
opencli devto user username # 用户文章 (username positional)
# Steam (public)
opencli steam top-sellers --limit 10 # 热销游戏
# Apple Podcasts (public)
opencli apple-podcasts top --limit 10 # 热门播客排行榜 (支持 --country us/cn/gb/jp)
opencli apple-podcasts search "科技" # 搜索播客 (query positional)
opencli apple-podcasts episodes 12345 # 播客剧集列表 (id positional, 用 search 获取 ID)
# arXiv (public)
opencli arxiv search "attention" # 搜索论文 (query positional)
opencli arxiv paper 1706.03762 # 论文详情 (id positional)
# Bloomberg (public RSS + browser)
opencli bloomberg main --limit 10 # Bloomberg 首页头条 (RSS)
opencli bloomberg markets --limit 10 # 市场新闻 (RSS)
opencli bloomberg tech --limit 10 # 科技新闻 (RSS)
opencli bloomberg politics --limit 10 # 政治新闻 (RSS)
opencli bloomberg economics --limit 10 # 经济新闻 (RSS)
opencli bloomberg opinions --limit 10 # 观点 (RSS)
opencli bloomberg industries --limit 10 # 行业新闻 (RSS)
opencli bloomberg businessweek --limit 10 # Businessweek (RSS)
opencli bloomberg feeds # 列出所有 RSS feed 别名
opencli bloomberg news "https://..." # 阅读 Bloomberg 文章全文 (link positional, browser)
# Coupang 쿠팡 (browser)
opencli coupang search "耳机" # 搜索商品 (query positional, 支持 --filter rocket)
opencli coupang add-to-cart 12345 # 加入购物车 (product-id positional, 或 --url)
# Dictionary (public)
opencli dictionary search "serendipity" # 单词释义 (word positional)
opencli dictionary synonyms "happy" # 近义词 (word positional)
opencli dictionary examples "ubiquitous" # 例句 (word positional)
# 豆包 Doubao Web (browser)
opencli doubao status # 检查豆包页面状态
opencli doubao new # 新建对话
opencli doubao send "你好" # 发送消息 (text positional)
opencli doubao read # 读取对话记录
opencli doubao ask "问题" # 一键提问并等回复 (text positional)
# 京东 JD (browser)
opencli jd item 100291143898 # 商品详情 (sku positional, 含价格/主图/规格)
# LinkedIn (browser)
opencli linkedin search "AI engineer" # 搜索职位 (query positional, 支持 --location/--company/--remote)
opencli linkedin timeline --limit 20 # 首页动态流
# Pixiv (browser)
opencli pixiv ranking --limit 20 # 插画排行榜 (支持 --mode daily/weekly/monthly)
opencli pixiv search "風景" # 搜索插画 (query positional)
opencli pixiv user 12345 # 画师资料 (uid positional)
opencli pixiv illusts 12345 # 画师作品列表 (user-id positional)
opencli pixiv detail 12345 # 插画详情 (id positional)
opencli pixiv download 12345 # 下载插画 (illust-id positional)
# Web (browser)
opencli web read --url "https://..." # 抓取任意网页并导出为 Markdown
# 微信公众号 Weixin (browser)
opencli weixin download --url "https://mp.weixin.qq.com/s/xxx" # 下载公众号文章为 Markdown
# 小宇宙 Xiaoyuzhou (public)
opencli xiaoyuzhou podcast 12345 # 播客资料 (id positional)
opencli xiaoyuzhou podcast-episodes 12345 # 播客剧集列表 (id positional)
opencli xiaoyuzhou episode 12345 # 单集详情 (id positional)
# Wikipedia (public)
opencli wikipedia search "AI" # 搜索 (query positional)
opencli wikipedia summary "Python" # 摘要 (title positional)
```
### Desktop Adapter Commands
```bash
# Cursor (desktop — CDP via Electron)
opencli cursor status # 检查连接
opencli cursor send "message" # 发送消息
opencli cursor read # 读取回复
opencli cursor new # 新建对话
opencli cursor dump # 导出 DOM 调试信息
opencli cursor composer # Composer 模式
opencli cursor model claude # 切换模型
opencli cursor extract-code # 提取代码块
opencli cursor ask "question" # 一键提问并等回复
opencli cursor screenshot # 截图
opencli cursor history # 对话历史
opencli cursor export # 导出对话
# Codex (desktop — headless CLI agent)
opencli codex status # 检查连接
opencli codex send "message" # 发送消息
opencli codex read # 读取回复
opencli codex new # 新建对话
opencli codex dump # 导出调试信息
opencli codex extract-diff # 提取 diff
opencli codex model gpt-4 # 切换模型
opencli codex ask "question" # 一键提问并等回复
opencli codex screenshot # 截图
opencli codex history # 对话历史
opencli codex export # 导出对话
# ChatGPT (desktop — macOS AppleScript/CDP)
opencli chatgpt status # 检查应用状态
opencli chatgpt new # 新建对话
opencli chatgpt send "message" # 发送消息
opencli chatgpt read # 读取回复
opencli chatgpt ask "question" # 一键提问并等回复
# ChatWise (desktop — multi-LLM client)
opencli chatwise status # 检查连接
opencli chatwise new # 新建对话
opencli chatwise send "message" # 发送消息
opencli chatwise read # 读取回复
opencli chatwise ask "question" # 一键提问并等回复
opencli chatwise model claude # 切换模型
opencli chatwise history # 对话历史
opencli chatwise export # 导出对话
opencli chatwise screenshot # 截图
# Notion (desktop — CDP via Electron)
opencli notion status # 检查连接
opencli notion search "keyword" # 搜索页面
opencli notion read # 读取当前页面
opencli notion new # 新建页面
opencli notion write "content" # 写入内容
opencli notion sidebar # 侧边栏导航
opencli notion favorites # 收藏列表
opencli notion export # 导出
# Discord App (desktop — CDP via Electron)
opencli discord-app status # 检查连接
opencli discord-app send "message" # 发送消息
opencli discord-app read # 读取消息
opencli discord-app channels # 频道列表
opencli discord-app servers # 服务器列表
opencli discord-app search "keyword" # 搜索
opencli discord-app members # 成员列表
# Doubao App 豆包桌面版 (desktop — CDP via Electron)
opencli doubao-app status # 检查连接
opencli doubao-app new # 新建对话
opencli doubao-app send "message" # 发送消息
opencli doubao-app read # 读取回复
opencli doubao-app ask "question" # 一键提问并等回复
opencli doubao-app screenshot # 截图
opencli doubao-app dump # 导出 DOM 调试信息
```
### Management Commands
```bash
opencli list # List all commands (including External CLIs)
opencli list --json # JSON output
opencli list -f yaml # YAML output
opencli install <name> # Auto-install an external CLI (e.g., gh, obsidian)
opencli register <name> # Register a local custom CLI for unified discovery
opencli validate # Validate all CLI definitions
opencli validate bilibili # Validate specific site
opencli doctor # Diagnose browser bridge (auto-starts daemon, includes live test)
```
### AI Agent Workflow
```bash
# Deep Explore: network intercept → response analysis → capability inference
opencli explore <url> --site <name>
# Synthesize: generate evaluate-based YAML pipelines from explore artifacts
opencli synthesize <site>
# Generate: one-shot explore → synthesize → register
opencli generate <url> --goal "hot"
# Record: YOU operate the page, opencli captures every API call → YAML candidates
# Opens the URL in automation window, injects fetch/XHR interceptor into ALL tabs,
# polls every 2s, auto-stops after 60s (or press Enter to stop early).
opencli record <url> # 录制,site name 从域名推断
opencli record <url> --site mysite # 指定 site name
opencli record <url> --timeout 120000 # 自定义超时(毫秒,默认 60000)
opencli record <url> --poll 1000 # 缩短轮询间隔(毫秒,默认 2000)
opencli record <url> --out .opencli/record/x # 自定义输出目录
# Output:
# .opencli/record/<site>/captured.json ← 原始捕获数据(带 url/method/body
# .opencli/record/<site>/candidates/*.yaml ← 高置信度候选适配器(score ≥ 8,有 array 结果)
# Strategy Cascade: auto-probe PUBLIC → COOKIE → HEADER
opencli cascade <api-url>
# Explore with interactive fuzzing (click buttons to trigger lazy APIs)
opencli explore <url> --auto --click "字幕,CC,评论"
# Validate: validate adapter definitions
opencli validate
```
## Output Formats
All built-in commands support `--format` / `-f` with `table`, `json`, `yaml`, `md`, and `csv`.
The `list` command supports the same formats and also keeps `--json` as a compatibility alias.
```bash
opencli list -f yaml # YAML command registry
opencli bilibili hot -f table # Default: rich table
opencli bilibili hot -f json # JSON (pipe to jq, feed to AI agent)
opencli bilibili hot -f yaml # YAML (readable structured output)
opencli bilibili hot -f md # Markdown
opencli bilibili hot -f csv # CSV
```
## Verbose Mode
```bash
opencli bilibili hot -v # Show each pipeline step and data flow
```
## Record Workflow
`record` 是为「无法用 `explore` 自动发现」的页面(需要登录操作、复杂交互、SPA 内路由)准备的手动录制方案。
### 工作原理
```
opencli record <url>
→ 打开 automation window 并导航到目标 URL
→ 向所有 tab 注入 fetch/XHR 拦截器(幂等,可重复注入)
→ 每 2s 轮询一次:发现新 tab 自动注入,drain 所有 tab 的捕获缓冲区
→ 超时(默认 60s)或按 Enter 停止
→ 分析捕获到的 JSON 请求:去重 → 评分 → 生成候选 YAML
```
**拦截器特性**
- 同时 patch `window.fetch``XMLHttpRequest`
- 只捕获 `Content-Type: application/json` 的响应
- 过滤纯对象少于 2 个 key 的响应(避免 tracking/ping
- 跨 tab 隔离:每个 tab 独立缓冲区,轮询时分别 drain
- 幂等注入:同一 tab 二次注入时先 restore 原始函数再重新 patch,不丢失已捕获数据
### 使用步骤
```bash
# 1. 启动录制(建议 --timeout 给足操作时间)
opencli record "https://example.com/page" --timeout 120000
# 2. 在弹出的 automation window 里正常操作页面:
# - 打开列表、搜索、点击条目、切换 Tab
# - 凡是触发网络请求的操作都会被捕获
# 3. 完成操作后按 Enter 停止(或等超时自动停止)
# 4. 查看结果
cat .opencli/record/<site>/captured.json # 原始捕获
ls .opencli/record/<site>/candidates/ # 候选 YAML
```
### 页面类型与捕获预期
| 页面类型 | 预期捕获量 | 说明 |
|---------|-----------|------|
| 列表/搜索页 | 多(5~20+) | 每次搜索/翻页都会触发新请求 |
| 详情页(只读) | 少(1~5) | 首屏数据一次性返回,后续操作走 form/redirect |
| SPA 内路由跳转 | 中等 | 路由切换会触发新接口,但首屏请求在注入前已发出 |
| 需要登录的页面 | 视操作而定 | 确保 Chrome 已登录目标网站 |
> **注意**:如果页面在导航完成前就发出了大部分请求(服务端渲染 / SSR 注水),拦截器会错过这些请求。
> 解决方案:在页面加载完成后,手动触发能产生新请求的操作(搜索、翻页、切 Tab、展开折叠项等)。
### 候选 YAML → TS CLI 转换
生成的候选 YAML 是起点,通常需要转换为 TypeScript(尤其是 tae 等内部系统):
**候选 YAML 结构**(自动生成):
```yaml
site: tae
name: getList # 从 URL path 推断的名称
strategy: cookie
browser: true
pipeline:
- navigate: https://...
- evaluate: |
(async () => {
const res = await fetch('/approval/getList.json?procInsId=...', { credentials: 'include' });
const data = await res.json();
return (data?.content?.operatorRecords || []).map(item => ({ ... }));
})()
```
**转换为 TS CLI**(参考 `src/clis/tae/add-expense.ts` 风格):
```typescript
import { cli, Strategy } from '../../registry.js';
cli({
site: 'tae',
name: 'get-approval',
description: '查看报销单审批流程和操作记录',
domain: 'tae.alibaba-inc.com',
strategy: Strategy.COOKIE,
browser: true,
args: [
{ name: 'proc_ins_id', type: 'string', required: true, positional: true, help: '流程实例 IDprocInsId' },
],
columns: ['step', 'operator', 'action', 'time'],
func: async (page, kwargs) => {
await page.goto('https://tae.alibaba-inc.com/expense/pc.html?_authType=SAML');
await page.wait(2);
const result = await page.evaluate(`(async () => {
const res = await fetch('/approval/getList.json?taskId=&procInsId=${kwargs.proc_ins_id}', {
credentials: 'include'
});
const data = await res.json();
return data?.content?.operatorRecords || [];
})()`);
return (result as any[]).map((r, i) => ({
step: i + 1,
operator: r.operatorName || r.userId,
action: r.operationType,
time: r.operateTime,
}));
},
});
```
**转换要点**
1. URL 中的动态 ID`procInsId``taskId` 等)提取为 `args`
2. `captured.json` 里的真实 body 结构用于确定正确的数据路径(如 `content.operatorRecords`
3. tae 系统统一用 `{ success, content, errorCode, errorMsg }` 外层包裹,取数据要走 `content.*`
4. 认证方式:cookie`credentials: 'include'`),不需要额外 header
5. 文件放入 `src/clis/<site>/`,无需手动注册,`npm run build` 后自动发现
### 故障排查
| 现象 | 原因 | 解法 |
|------|------|------|
| 捕获 0 条请求 | 拦截器注入失败,或页面无 JSON API | 检查 daemon 是否运行:`curl localhost:19825/status` |
| 捕获量少(1~3 条) | 页面是只读详情页,首屏数据已在注入前发出 | 手动操作触发更多请求(搜索/翻页),或换用列表页 |
| 候选 YAML 为 0 | 捕获到的 JSON 都没有 array 结构 | 直接看 `captured.json` 手写 TS CLI |
| 新开的 tab 没有被拦截 | 轮询间隔内 tab 已关闭 | 缩短 `--poll 500` |
| 二次运行 record 时数据不连续 | 正常,每次 `record` 启动都是新的 automation window | 无需处理 |
## Creating Adapters
> [!TIP]
> **快速模式**:如果你只想为一个具体页面生成一个命令,直接看 [CLI-ONESHOT.md](./CLI-ONESHOT.md)。
> 只需要一个 URL + 一句话描述,4 步搞定。
> [!IMPORTANT]
> **完整模式 — 在写任何代码之前,先阅读 [CLI-EXPLORER.md](./CLI-EXPLORER.md)。**
> 它包含:① AI Agent 浏览器探索工作流 ② 认证策略决策树 ③ 平台 SDK(如 Bilibili 的 `apiGet`/`fetchJson`)④ YAML vs TS 选择指南 ⑤ `tap` 步骤调试方法 ⑥ 级联请求模板 ⑦ 常见陷阱表。
> **下方仅为简化模板参考,直接使用极易踩坑。**
### YAML Pipeline (declarative, recommended)
Create `src/clis/<site>/<name>.yaml`:
```yaml
site: mysite
name: hot
description: Hot topics
domain: www.mysite.com
strategy: cookie # public | cookie | header | intercept | ui
browser: true
args:
limit:
type: int
default: 20
description: Number of items
pipeline:
- navigate: https://www.mysite.com
- evaluate: |
(async () => {
const res = await fetch('/api/hot', { credentials: 'include' });
const d = await res.json();
return d.data.items.map(item => ({
title: item.title,
score: item.score,
}));
})()
- map:
rank: ${{ index + 1 }}
title: ${{ item.title }}
score: ${{ item.score }}
- limit: ${{ args.limit }}
columns: [rank, title, score]
```
For public APIs (no browser):
```yaml
strategy: public
browser: false
pipeline:
- fetch:
url: https://api.example.com/hot.json
- select: data.items
- map:
title: ${{ item.title }}
- limit: ${{ args.limit }}
```
### TypeScript Adapter (programmatic)
Create `src/clis/<site>/<name>.ts`. It will be automatically dynamically loaded (DO NOT manually import it in `index.ts`):
```typescript
import { cli, Strategy } from '../../registry.js';
cli({
site: 'mysite',
name: 'search',
strategy: Strategy.INTERCEPT, // Or COOKIE
args: [{ name: 'query', required: true, positional: true }],
columns: ['rank', 'title', 'url'],
func: async (page, kwargs) => {
await page.goto('https://www.mysite.com/search');
// Inject native XHR/Fetch interceptor hook
await page.installInterceptor('/api/search');
// Auto scroll down to trigger lazy loading
await page.autoScroll({ times: 3, delayMs: 2000 });
// Retrieve intercepted JSON payloads
const requests = await page.getInterceptedRequests();
let results = [];
for (const req of requests) {
results.push(...req.data.items);
}
return results.map((item, i) => ({
rank: i + 1, title: item.title, url: item.url,
}));
},
});
```
**When to use TS**: XHR interception (`page.installInterceptor`), infinite scrolling (`page.autoScroll`), cookie extraction, complex data transforms (like GraphQL unwrapping).
## Pipeline Steps
| Step | Description | Example |
|------|-------------|---------|
| `navigate` | Go to URL | `navigate: https://example.com` |
| `fetch` | HTTP request (browser cookies) | `fetch: { url: "...", params: { q: "..." } }` |
| `evaluate` | Run JavaScript in page | `evaluate: \| (async () => { ... })()` |
| `select` | Extract JSON path | `select: data.items` |
| `map` | Map fields | `map: { title: "${{ item.title }}" }` |
| `filter` | Filter items | `filter: item.score > 100` |
| `sort` | Sort items | `sort: { by: score, order: desc }` |
| `limit` | Cap result count | `limit: ${{ args.limit }}` |
| `intercept` | Declarative XHR capture | `intercept: { trigger: "navigate:...", capture: "api/hot" }` |
| `tap` | Store action + XHR capture | `tap: { store: "feed", action: "fetchFeeds", capture: "homefeed" }` |
| `snapshot` | Page accessibility tree | `snapshot: { interactive: true }` |
| `click` | Click element | `click: ${{ ref }}` |
| `type` | Type text | `type: { ref: "@1", text: "hello" }` |
| `wait` | Wait for time/text | `wait: 2` or `wait: { text: "loaded" }` |
| `press` | Press key | `press: Enter` |
## Template Syntax
```yaml
# Arguments with defaults
${{ args.query }}
${{ args.limit | default(20) }}
# Current item (in map/filter)
${{ item.title }}
${{ item.data.nested.field }}
# Index (0-based)
${{ index }}
${{ index + 1 }}
```
## 5-Tier Authentication Strategy
| Tier | Name | Method | Example |
|------|------|--------|---------|
| 1 | `public` | No auth, Node.js fetch | Hacker News, V2EX |
| 2 | `cookie` | Browser fetch with `credentials: include` | Bilibili, Zhihu |
| 3 | `header` | Custom headers (ct0, Bearer) | Twitter GraphQL |
| 4 | `intercept` | XHR interception + store mutation | 小红书 Pinia |
| 5 | `ui` | Full UI automation (click/type/scroll) | Last resort |
## Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `OPENCLI_DAEMON_PORT` | 19825 | Daemon listen port |
| `OPENCLI_BROWSER_CONNECT_TIMEOUT` | 30 | Browser connection timeout (sec) |
| `OPENCLI_BROWSER_COMMAND_TIMEOUT` | 45 | Command execution timeout (sec) |
| `OPENCLI_BROWSER_EXPLORE_TIMEOUT` | 120 | Explore timeout (sec) |
| `OPENCLI_VERBOSE` | — | Show daemon/extension logs |
## Troubleshooting
| Issue | Solution |
|-------|----------|
| `npx not found` | Install Node.js: `brew install node` |
| `Extension not connected` | 1) Chrome must be open 2) Install opencli Browser Bridge extension |
| `Target page context` error | Add `navigate:` step before `evaluate:` in YAML |
| Empty table data | Check if evaluate returns correct data path |
| Daemon issues | `curl localhost:19825/status` to check, `curl localhost:19825/logs` for extension logs |
+5 -5
View File
@@ -49,7 +49,7 @@ src/
|---|---|
| 核心运行时与输出 | `src/browser.test.ts`, `src/browser/dom-snapshot.test.ts`, `src/build-manifest.test.ts`, `src/capabilityRouting.test.ts`, `src/doctor.test.ts`, `src/engine.test.ts`, `src/interceptor.test.ts`, `src/output.test.ts`, `src/plugin.test.ts`, `src/registry.test.ts`, `src/snapshotFormatter.test.ts` |
| pipeline 与下载 | `src/download/index.test.ts`, `src/pipeline/executor.test.ts`, `src/pipeline/template.test.ts`, `src/pipeline/transform.test.ts` |
| 站点 / adapter 逻辑 | `src/clis/apple-podcasts/commands.test.ts`, `src/clis/apple-podcasts/utils.test.ts`, `src/clis/bloomberg/utils.test.ts`, `src/clis/chaoxing/utils.test.ts`, `src/clis/coupang/utils.test.ts`, `src/clis/google/utils.test.ts`, `src/clis/grok/ask.test.ts`, `src/clis/twitter/timeline.test.ts`, `src/clis/weread/utils.test.ts`, `src/clis/xiaohongshu/creator-note-detail.test.ts`, `src/clis/xiaohongshu/creator-notes-summary.test.ts`, `src/clis/xiaohongshu/creator-notes.test.ts`, `src/clis/xiaohongshu/search.test.ts`, `src/clis/xiaohongshu/user-helpers.test.ts`, `src/clis/xiaoyuzhou/utils.test.ts`, `src/clis/youtube/transcript-group.test.ts`, `src/clis/zhihu/download.test.ts` |
| 站点 / adapter 逻辑 | `clis/apple-podcasts/commands.test.ts`, `clis/apple-podcasts/utils.test.ts`, `clis/bloomberg/utils.test.ts`, `clis/chaoxing/utils.test.ts`, `clis/coupang/utils.test.ts`, `clis/google/utils.test.ts`, `clis/grok/ask.test.ts`, `clis/twitter/timeline.test.ts`, `clis/weread/utils.test.ts`, `clis/xiaohongshu/creator-note-detail.test.ts`, `clis/xiaohongshu/creator-notes-summary.test.ts`, `clis/xiaohongshu/creator-notes.test.ts`, `clis/xiaohongshu/search.test.ts`, `clis/xiaohongshu/user-helpers.test.ts`, `clis/xiaoyuzhou/utils.test.ts`, `clis/youtube/transcript-group.test.ts`, `clis/zhihu/download.test.ts` |
这些测试覆盖的重点包括:
@@ -94,7 +94,7 @@ find tests/smoke -name '*.test.ts' | sort
```bash
npm ci # 安装依赖
npm run build # 编译(E2E / smoke 测试需要 dist/main.js
npm run build # 编译(E2E / smoke 测试需要 dist/src/main.js
```
### 运行命令
@@ -110,7 +110,7 @@ npx vitest run tests/e2e/
npx vitest run tests/smoke/
# 单个测试文件
npx vitest run src/clis/apple-podcasts/commands.test.ts
npx vitest run clis/apple-podcasts/commands.test.ts
npx vitest run tests/e2e/management.test.ts
# 全部测试
@@ -123,7 +123,7 @@ npx vitest src/
### 浏览器命令本地测试须知
- opencli 通过 Browser Bridge 扩展连接已运行的 Chrome 浏览器
- E2E 测试通过 `tests/e2e/helpers.ts` 里的 `runCli()` 调用已构建的 `dist/main.js`
- E2E 测试通过 `tests/e2e/helpers.ts` 里的 `runCli()` 调用已构建的 `dist/src/main.js`
- `browser-public.test.ts` 使用 `tryBrowserCommand()`,站点反爬或地域限制导致空数据时会 warn + pass
- `browser-auth.test.ts` 验证 **graceful failure**,重点是不 crash、不 hang、错误信息可控
- 如需测试完整登录态,保持 Chrome 登录态并安装 Browser Bridge 扩展,再手动运行对应测试
@@ -132,7 +132,7 @@ npx vitest src/
## 如何添加新测试
### 新增 YAML Adapter(如 `src/clis/producthunt/trending.yaml`
### 新增 YAML Adapter(如 `clis/producthunt/trending.yaml`
1. `opencli validate` 的 E2E / smoke 测试会覆盖 adapter 结构校验
2. 根据 adapter 类型,在对应测试文件补一个 `it()` block
+1
View File
@@ -0,0 +1 @@
56/59
+1
View File
@@ -0,0 +1 @@
31/31
+686
View File
@@ -0,0 +1,686 @@
[
{
"name": "extract-title-example",
"steps": [
"opencli browser open https://example.com",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "contains",
"value": "Example Domain"
}
},
{
"name": "extract-title-iana",
"steps": [
"opencli browser open https://www.iana.org",
"opencli browser eval \"document.querySelector('h1')?.textContent || document.title || document.querySelector('title')?.textContent\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "extract-paragraph-wiki-js",
"steps": [
"opencli browser open https://en.wikipedia.org/wiki/JavaScript",
"opencli browser eval \"(() => { const ps = document.querySelectorAll('#mw-content-text .mw-parser-output > p'); for (const p of ps) { const t = p.textContent?.trim(); if (t && t.length > 50 && !t.startsWith('{')) return t.slice(0,300); } return ''; })()\""
],
"judge": {
"type": "contains",
"value": "programming language"
}
},
{
"name": "extract-paragraph-wiki-python",
"steps": [
"opencli browser open \"https://en.wikipedia.org/wiki/Python_(programming_language)\"",
"opencli browser eval \"(() => { const ps = document.querySelectorAll('#mw-content-text .mw-parser-output > p'); for (const p of ps) { const t = p.textContent?.trim(); if (t && t.length > 50 && !t.startsWith('{')) return t.slice(0,300); } return ''; })()\""
],
"judge": {
"type": "contains",
"value": "programming language"
}
},
{
"name": "extract-github-stars",
"steps": [
"opencli browser open https://github.com/browser-use/browser-use",
"opencli browser eval \"document.querySelector('#repo-stars-counter-star')?.textContent?.trim()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d"
}
},
{
"name": "extract-github-description",
"steps": [
"opencli browser open https://github.com/anthropics/claude-code",
"opencli browser eval \"document.querySelector('p.f4, [data-testid=about-description], .f4.my-3, .BorderGrid-cell p')?.textContent?.trim()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "extract-github-readme-heading",
"steps": [
"opencli browser open https://github.com/vercel/next.js",
"opencli browser eval \"document.querySelector('[data-testid=readme] h1, [data-testid=readme] h2, #readme h1, #readme h2, article h1, article h2, .markdown-body h1, .markdown-body h2')?.textContent?.trim()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "extract-npm-downloads",
"steps": [
"opencli browser open https://www.npmjs.com/package/zod",
"opencli browser eval \"document.querySelector('[data-nosnippet]')?.textContent?.trim() || document.querySelector('p.f2874b88')?.textContent?.trim()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d"
}
},
{
"name": "extract-npm-description",
"steps": [
"opencli browser open https://www.npmjs.com/package/express",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var ps=document.querySelectorAll('p');for(var i=0;i<ps.length;i++){var t=ps[i].textContent.trim();if(t.length>10&&t.length<200)return t;}return '';})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "list-hn-top5",
"steps": [
"opencli browser open https://news.ycombinator.com",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('.titleline > a')].slice(0,5).map(a=>({title:a.textContent,url:a.href})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 5
}
},
{
"name": "list-hn-top10",
"steps": [
"opencli browser open https://news.ycombinator.com",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('.athing')].slice(0,10).map(tr=>{const a=tr.querySelector('.titleline>a');const s=tr.nextElementSibling?.querySelector('.score');return{title:a?.textContent,score:parseInt(s?.textContent)||0}}))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 10
}
},
{
"name": "list-books-5",
"steps": [
"opencli browser open https://books.toscrape.com",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('article.product_pod')].slice(0,5).map(el=>({title:el.querySelector('h3 a')?.getAttribute('title'),price:el.querySelector('.price_color')?.textContent})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 5
}
},
{
"name": "list-books-10",
"steps": [
"opencli browser open https://books.toscrape.com",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('article.product_pod')].slice(0,10).map(el=>({title:el.querySelector('h3 a')?.getAttribute('title'),price:el.querySelector('.price_color')?.textContent})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 10
}
},
{
"name": "list-quotes-3",
"steps": [
"opencli browser open https://quotes.toscrape.com",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('.quote, [class*=quote]')].slice(0,3).map(el=>({text:(el.querySelector('.text, [class*=text]')?.textContent)||(el.querySelector('span')?.textContent),author:(el.querySelector('.author, [class*=author]')?.textContent)||(el.querySelector('small')?.textContent)})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "list-quotes-tags",
"steps": [
"opencli browser open https://quotes.toscrape.com",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('.quote')].slice(0,5).map(el=>({text:el.querySelector('.text')?.textContent,author:el.querySelector('.author')?.textContent,tags:[...el.querySelectorAll('.tag')].map(t=>t.textContent)})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 5
}
},
{
"name": "list-github-trending",
"steps": [
"opencli browser open https://github.com/trending",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('article.Box-row, article[class*=Box-row], [data-hpc] article, .Box article')].slice(0,3).map(el=>({name:(el.querySelector('h2 a, h1 a')?.textContent?.trim().replace(/\\\\s+/g,' '))||(el.querySelector('a[href^=\\\"/\\\"]')?.textContent?.trim()),desc:el.querySelector('p')?.textContent?.trim()})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "list-github-trending-lang",
"steps": [
"opencli browser open https://github.com/trending/python",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('article.Box-row, article[class*=Box-row], [data-hpc] article, .Box article')].slice(0,5).map(el=>({name:(el.querySelector('h2 a, h1 a')?.textContent?.trim().replace(/\\\\s+/g,' '))||(el.querySelector('a[href^=\\\"/\\\"]')?.textContent?.trim())})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 5
}
},
{
"name": "list-jsonplaceholder-posts",
"steps": [
"opencli browser open https://jsonplaceholder.typicode.com/posts",
"opencli browser eval \"JSON.stringify(JSON.parse(document.body.innerText).slice(0,5).map(p=>({id:p.id,title:p.title})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 5
}
},
{
"name": "list-jsonplaceholder-users",
"steps": [
"opencli browser open https://jsonplaceholder.typicode.com/users",
"opencli browser eval \"JSON.stringify(JSON.parse(document.body.innerText).map(u=>({name:u.name,email:u.email})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 5
}
},
{
"name": "search-google",
"steps": [
"opencli browser open https://www.google.com/search?q=opencli+github",
"opencli browser wait time 3",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('h3')].slice(0,3).map(h=>h.textContent))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "index 5 may vary"
},
{
"name": "search-ddg",
"steps": [
"opencli browser open https://duckduckgo.com",
"opencli browser state",
"opencli browser type 1 \"weather beijing\"",
"opencli browser keys Enter",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('[data-testid=result-title-a]')].slice(0,3).map(a=>a.textContent))\""
],
"judge": {
"type": "nonEmpty"
},
"note": "index may vary"
},
{
"name": "search-ddg-tech",
"steps": [
"opencli browser open https://duckduckgo.com",
"opencli browser eval \"document.querySelector('input[name=q]').value='TypeScript tutorial';document.querySelector('form').submit();'submitted'\"",
"opencli browser wait time 3",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('[data-testid=result-title-a], .result__a')].slice(0,3).map(a=>({title:a.textContent,url:a.href})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "index may vary"
},
{
"name": "search-wiki",
"steps": [
"opencli browser open \"https://en.wikipedia.org/w/index.php?search=Rust+programming+language&title=Special:Search&go=Go\"",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const ps = document.querySelectorAll('#mw-content-text .mw-parser-output > p'); for (const p of ps) { const t = p.textContent?.trim(); if (t && t.length > 50) return t.slice(0,300); } return ''; })()\""
],
"judge": {
"type": "contains",
"value": "programming language"
},
"note": "index may vary"
},
{
"name": "search-npm",
"steps": [
"opencli browser open https://www.npmjs.com/search?q=react",
"opencli browser wait time 3",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('[data-testid=pkg-list-item] h3, section h3, .package-list-item h3, a[class*=package] h3')].slice(0,3).map(h=>h.textContent?.trim()))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "index may vary"
},
{
"name": "search-github",
"steps": [
"opencli browser open https://github.com/search?q=browser+automation&type=repositories",
"opencli browser wait time 3",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('.search-title a, [data-testid=results-list] a.Link--primary')].slice(0,3).map(a=>a.textContent?.trim().replace(/\\\\s+/g,' ')))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "index may vary"
},
{
"name": "nav-click-link-example",
"steps": [
"opencli browser open https://example.com",
"opencli browser eval \"document.querySelector('a')?.click();'clicked'\"",
"opencli browser wait time 2",
"opencli browser eval \"document.title + ' ' + location.href\""
],
"judge": {
"type": "contains",
"value": "IANA"
}
},
{
"name": "nav-click-hn-first",
"steps": [
"opencli browser open https://news.ycombinator.com",
"opencli browser eval \"document.querySelector('.titleline a')?.click();'clicked'\"",
"opencli browser wait time 2",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "nav-click-hn-comments",
"steps": [
"opencli browser open https://news.ycombinator.com",
"opencli browser eval \"document.querySelector('.subtext a:last-child')?.click(); 'clicked'\"",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "nav-click-wiki-link",
"steps": [
"opencli browser open https://en.wikipedia.org/wiki/JavaScript",
"opencli browser eval \"document.querySelector('.vector-toc-contents a[href*=History], #toc a[href*=History], .toc a[href*=History], [href=\\\"#History\\\"]')?.click(); 'clicked'\"",
"opencli browser eval \"document.querySelector('#History')?.textContent?.slice(0,100) || document.querySelector('[id*=History]')?.textContent?.slice(0,100)\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "nav-click-github-tab",
"steps": [
"opencli browser open https://github.com/vercel/next.js",
"opencli browser eval \"document.querySelector('[data-tab-item=i1issues-tab] a, #issues-tab')?.click(); 'clicked'\"",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "nav-go-back",
"steps": [
"opencli browser open https://example.com",
"opencli browser eval \"document.querySelector('a')?.click();'clicked'\"",
"opencli browser wait time 2",
"opencli browser back",
"opencli browser wait time 2",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "contains",
"value": "Example Domain"
}
},
{
"name": "nav-multi-step",
"steps": [
"opencli browser open https://quotes.toscrape.com",
"opencli browser eval \"document.querySelector('.next a')?.click(); 'clicked'\"",
"opencli browser eval \"document.querySelector('.quote .text')?.textContent\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "scroll-footer-quotes",
"steps": [
"opencli browser open https://quotes.toscrape.com",
"opencli browser scroll down",
"opencli browser scroll down",
"opencli browser eval \"document.querySelector('footer, .footer, .tags-box')?.textContent?.trim().slice(0,100)\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "scroll-footer-books",
"steps": [
"opencli browser open https://books.toscrape.com",
"opencli browser scroll down",
"opencli browser scroll down",
"opencli browser eval \"document.querySelector('.pager .current')?.textContent?.trim()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d"
}
},
{
"name": "scroll-long-page",
"steps": [
"opencli browser open https://jsonplaceholder.typicode.com/posts",
"opencli browser eval \"JSON.parse(document.body.innerText).length\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d"
}
},
{
"name": "scroll-find-element",
"steps": [
"opencli browser open https://quotes.toscrape.com",
"opencli browser eval \"document.querySelector('.next a')?.href\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "scroll-lazy-load",
"steps": [
"opencli browser open https://books.toscrape.com",
"opencli browser eval \"document.querySelectorAll('article.product_pod').length\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d"
}
},
{
"name": "form-simple-name",
"steps": [
"opencli browser open https://httpbin.org/forms/post",
"opencli browser eval \"var el=document.querySelector('[name=custname]');el.value='OpenCLI Test';el.dispatchEvent(new Event('input',{bubbles:true}));el.value\""
],
"judge": {
"type": "contains",
"value": "OpenCLI"
},
"note": "index may vary"
},
{
"name": "form-text-inputs",
"steps": [
"opencli browser open https://httpbin.org/forms/post",
"opencli browser eval \"var n=document.querySelector('[name=custname]');n.value='Alice';n.dispatchEvent(new Event('input',{bubbles:true}));var t=document.querySelector('[name=custtel]');t.value='555-1234';t.dispatchEvent(new Event('input',{bubbles:true}));n.value+'|'+t.value\""
],
"judge": {
"type": "contains",
"value": "Alice"
},
"note": "index may vary"
},
{
"name": "form-radio-select",
"steps": [
"opencli browser open https://httpbin.org/forms/post",
"opencli browser eval \"document.querySelector('[value=medium]').checked=true;document.querySelector('[value=medium]').dispatchEvent(new Event('change',{bubbles:true}));document.querySelector('[value=medium]').checked\""
],
"judge": {
"type": "contains",
"value": "true"
}
},
{
"name": "form-checkbox",
"steps": [
"opencli browser open https://httpbin.org/forms/post",
"opencli browser eval \"var cb=document.querySelector('[value=cheese]');cb.checked=true;cb.dispatchEvent(new Event('change',{bubbles:true}));cb.checked\""
],
"judge": {
"type": "contains",
"value": "true"
}
},
{
"name": "form-textarea",
"steps": [
"opencli browser open https://httpbin.org/forms/post",
"opencli browser eval \"var ta=document.querySelector('textarea[name=comments], textarea[name=delivery], textarea');ta.value='AutoResearch test';ta.dispatchEvent(new Event('input',{bubbles:true}));ta.value\""
],
"judge": {
"type": "contains",
"value": "AutoResearch"
}
},
{
"name": "form-login-fake",
"steps": [
"opencli browser open https://the-internet.herokuapp.com/login",
"opencli browser eval \"var u=document.querySelector('#username');u.value='testuser';u.dispatchEvent(new Event('input',{bubbles:true}));var p=document.querySelector('#password');p.value='testpass';p.dispatchEvent(new Event('input',{bubbles:true}));u.value+'|'+p.value\""
],
"judge": {
"type": "contains",
"value": "testuser"
},
"note": "index may vary"
},
{
"name": "complex-wiki-toc",
"steps": [
"opencli browser open https://en.wikipedia.org/wiki/JavaScript",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('.toc li a, #toc li a, .vector-toc-contents a')].slice(0,8).map(a=>a.textContent?.trim()))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 5
}
},
{
"name": "complex-books-detail",
"steps": [
"opencli browser open https://books.toscrape.com",
"opencli browser eval \"document.querySelector('article.product_pod h3 a')?.click();'clicked'\"",
"opencli browser eval \"JSON.stringify({title:document.querySelector('h1')?.textContent,price:document.querySelector('.price_color')?.textContent})\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "complex-quotes-page2",
"steps": [
"opencli browser open https://quotes.toscrape.com",
"opencli browser eval \"document.querySelector('.next a')?.click();'clicked'\"",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('.quote')].slice(0,3).map(el=>({text:el.querySelector('.text')?.textContent,author:el.querySelector('.author')?.textContent})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "complex-github-repo-info",
"steps": [
"opencli browser open https://github.com/expressjs/express",
"opencli browser eval \"JSON.stringify({lang:document.querySelector('[itemprop=programmingLanguage]')?.textContent?.trim(),license:document.querySelector('[data-analytics-event*=license] span, .Layout-sidebar [href*=LICENSE]')?.textContent?.trim()})\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "complex-hn-story-comments",
"steps": [
"opencli browser open https://news.ycombinator.com",
"opencli browser eval \"document.querySelector('.subtext a:last-child')?.click();'clicked'\"",
"opencli browser eval \"document.querySelector('.fatitem .titleline a')?.textContent\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "complex-multi-extract",
"steps": [
"opencli browser open https://en.wikipedia.org/wiki/TypeScript",
"opencli browser eval \"JSON.stringify({title:document.title,firstParagraph:document.querySelector('#mw-content-text p')?.textContent?.slice(0,150)})\""
],
"judge": {
"type": "contains",
"value": "TypeScript"
}
},
{
"name": "bench-reddit-top5",
"steps": [
"opencli browser open https://old.reddit.com",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('#siteTable .thing .title a.title')].slice(0,5).map(a=>a.textContent))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 5
},
"set": "test"
},
{
"name": "bench-imdb-matrix",
"steps": [
"opencli browser open https://www.imdb.com/title/tt0133093/",
"opencli browser wait time 3",
"opencli browser eval \"(function(){var title=document.querySelector('h1')?.textContent?.trim()||'';var year='';var links=document.querySelectorAll('a');for(var i=0;i<links.length;i++){if(links[i].textContent.trim()==='1999'){year='1999';break;}}var rating=document.querySelector('[data-testid=hero-rating-bar__aggregate-rating__score] span, .sc-bde20123-1')?.textContent?.trim()||'';return JSON.stringify({title:title,year:year,rating:rating});})()\""
],
"judge": {
"type": "contains",
"value": "1999"
},
"set": "test"
},
{
"name": "bench-npm-zod",
"steps": [
"opencli browser open https://www.npmjs.com/package/zod",
"opencli browser eval \"JSON.stringify({name:document.querySelector('h1 span, #top h2')?.textContent?.trim(),description:document.querySelector('[data-testid=package-description], p.package-description-redundant')?.textContent?.trim()})\""
],
"judge": {
"type": "nonEmpty"
},
"set": "test"
},
{
"name": "bench-wiki-search",
"steps": [
"opencli browser open https://en.wikipedia.org/wiki/Machine_learning",
"opencli browser eval \"(() => { const ps = document.querySelectorAll('#mw-content-text .mw-parser-output > p'); for (const p of ps) { const t = p.textContent?.trim(); if (t && t.length > 50) return t.slice(0,300); } return ''; })()\""
],
"judge": {
"type": "contains",
"value": "learning"
},
"set": "test"
},
{
"name": "bench-github-profile",
"steps": [
"opencli browser open https://github.com/torvalds",
"opencli browser eval \"JSON.stringify({name:document.querySelector('[itemprop=name]')?.textContent?.trim(),bio:document.querySelector('[data-bio-text]')?.textContent?.trim()||document.querySelector('.p-note')?.textContent?.trim()})\""
],
"judge": {
"type": "nonEmpty"
},
"set": "test"
},
{
"name": "bench-books-category",
"steps": [
"opencli browser open https://books.toscrape.com",
"opencli browser eval \"document.querySelector('a[href*=science]')?.click();'clicked'\"",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('article.product_pod h3 a')].slice(0,3).map(a=>a.getAttribute('title')))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"set": "test"
},
{
"name": "bench-quotes-author",
"steps": [
"opencli browser open https://quotes.toscrape.com",
"opencli browser eval \"document.querySelector('.author + a, a[href*=author]')?.click();'clicked'\"",
"opencli browser eval \"document.querySelector('.author-description, .author-details p')?.textContent?.slice(0,100)\""
],
"judge": {
"type": "nonEmpty"
},
"set": "test"
},
{
"name": "bench-ddg-images",
"steps": [
"opencli browser open https://duckduckgo.com",
"opencli browser eval \"document.querySelector('input[name=q]').value='sunset';document.querySelector('form').submit();'submitted'\"",
"opencli browser wait time 3",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('[data-testid=result-title-a], .result__a')].slice(0,3).map(a=>a.textContent))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"set": "test",
"note": "index may vary"
},
{
"name": "bench-httpbin-headers",
"steps": [
"opencli browser open https://httpbin.org/headers",
"opencli browser eval \"JSON.parse(document.body.innerText).headers['User-Agent']\""
],
"judge": {
"type": "nonEmpty"
},
"set": "test"
},
{
"name": "bench-jsonapi-todo",
"steps": [
"opencli browser open https://jsonplaceholder.typicode.com/todos",
"opencli browser eval \"JSON.stringify(JSON.parse(document.body.innerText).slice(0,5).map(t=>({id:t.id,title:t.title,completed:t.completed})))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 5
},
"set": "test"
}
]
+163
View File
@@ -0,0 +1,163 @@
#!/usr/bin/env npx tsx
/**
* /autoresearch:debug — Hypothesis-driven debugging for specific failing tasks.
*
* Scientific method: Gather → Hypothesize → Test → Classify → Log → Repeat
*
* Usage:
* npx tsx autoresearch/commands/debug.ts --task extract-npm-description
* npx tsx autoresearch/commands/debug.ts --task bench-imdb-matrix --iterations 5
*/
import { execSync } from 'node:child_process';
import { readFileSync, appendFileSync, writeFileSync, existsSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { parseArgs } from '../config.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = join(__dirname, '..', '..');
const TASKS_FILE = join(__dirname, '..', 'browse-tasks.json');
const DEBUG_LOG = join(ROOT, 'debug-results.tsv');
interface BrowseTask {
name: string;
steps: string[];
judge: { type: string; value?: string; minLength?: number; pattern?: string };
}
function exec(cmd: string): string {
try {
return execSync(cmd, {
cwd: ROOT, timeout: 30_000, encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'pipe'],
}).trim();
} catch (err: any) {
return err.stdout?.trim() ?? err.message ?? '';
}
}
function initLog(): void {
if (!existsSync(DEBUG_LOG)) {
writeFileSync(DEBUG_LOG, '# AutoResearch Debug Log\niteration\ttask\thypothesis\tresult\tverdict\tdescription\n', 'utf-8');
}
}
function appendLog(iteration: number, task: string, hypothesis: string, result: string, verdict: string, description: string): void {
appendFileSync(DEBUG_LOG, `${iteration}\t${task}\t${hypothesis}\t${result}\t${verdict}\t${description}\n`, 'utf-8');
}
async function main() {
const args = parseArgs(process.argv.slice(2));
const taskName = args.task;
const maxIterations = args.iterations ?? 10;
if (!taskName) {
console.error('Usage: npx tsx autoresearch/commands/debug.ts --task <task-name> [--iterations N]');
console.error('\nAvailable tasks:');
const tasks: BrowseTask[] = JSON.parse(readFileSync(TASKS_FILE, 'utf-8'));
// Show only failing tasks
for (const task of tasks) {
try { exec('opencli browser close'); } catch {}
let lastOutput = '';
for (const step of task.steps) lastOutput = exec(step);
const passed = lastOutput.trim().length > 0; // simplified check
if (!passed) console.error(`${task.name}`);
}
process.exit(1);
}
const tasks: BrowseTask[] = JSON.parse(readFileSync(TASKS_FILE, 'utf-8'));
const task = tasks.find(t => t.name === taskName);
if (!task) {
console.error(`Task not found: ${taskName}`);
process.exit(1);
}
console.log(`\n🔍 AutoResearch Debug: ${taskName}`);
console.log(` Steps: ${task.steps.length}`);
console.log(` Judge: ${task.judge.type}${task.judge.value ? ` "${task.judge.value}"` : ''}`);
console.log(` Max iterations: ${maxIterations}\n`);
initLog();
// Phase 1: Gather — run the task and capture output
console.log('Phase 1: Gathering symptoms...');
try { exec('opencli browser close'); } catch {}
let lastOutput = '';
for (let i = 0; i < task.steps.length; i++) {
const step = task.steps[i];
console.log(` Step ${i + 1}: ${step.slice(0, 80)}`);
lastOutput = exec(step);
if (i < task.steps.length - 1) {
console.log(`${lastOutput.slice(0, 100)}`);
}
}
console.log(`\n Final output: ${lastOutput.slice(0, 200)}`);
console.log(` Judge expects: ${JSON.stringify(task.judge)}`);
// Phase 2: Hypothesize + investigate via Claude Code
for (let iter = 1; iter <= maxIterations; iter++) {
console.log(`\n━━━ Debug Iteration ${iter}/${maxIterations} ━━━`);
const prompt = `You are debugging a failing browser automation task.
## Task: ${taskName}
Steps:
${task.steps.map((s, i) => ` ${i + 1}. ${s}`).join('\n')}
## Judge criteria
${JSON.stringify(task.judge)}
## Last output
${lastOutput.slice(0, 500)}
## Instructions
1. Form a SPECIFIC, FALSIFIABLE hypothesis about why this task fails
2. Run the MINIMUM experiment to test your hypothesis (e.g. run one step, check output)
3. Classify: CONFIRMED (bug found), DISPROVEN (try different hypothesis), INCONCLUSIVE
4. If CONFIRMED: describe the root cause and suggest a fix
5. Output format: one line "HYPOTHESIS: ...", one line "RESULT: CONFIRMED|DISPROVEN|INCONCLUSIVE — ..."
Do NOT fix the code — just diagnose. Use opencli browser commands to investigate.`;
try {
const result = execSync(
`claude -p --dangerously-skip-permissions --allowedTools "Bash(opencli:*),Bash(npm:*),Read,Grep,Glob" --output-format text --no-session-persistence "${prompt.replace(/"/g, '\\"')}"`,
{ cwd: ROOT, timeout: 120_000, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }
).trim();
// Extract hypothesis and result
const hypMatch = result.match(/HYPOTHESIS:\s*(.+)/i);
const resMatch = result.match(/RESULT:\s*(CONFIRMED|DISPROVEN|INCONCLUSIVE)\s*[-—]\s*(.+)/i);
const hypothesis = hypMatch?.[1]?.trim() ?? 'unknown';
const verdict = resMatch?.[1]?.trim() ?? 'INCONCLUSIVE';
const description = resMatch?.[2]?.trim() ?? result.split('\n').pop()?.trim() ?? '';
console.log(` Hypothesis: ${hypothesis.slice(0, 100)}`);
console.log(` Verdict: ${verdict}${description.slice(0, 100)}`);
appendLog(iter, taskName, hypothesis, lastOutput.slice(0, 50), verdict, description);
if (verdict === 'CONFIRMED') {
console.log(`\n✅ Root cause found at iteration ${iter}!`);
console.log(` ${description}`);
break;
}
} catch (err: any) {
console.error(` Error: ${err.message?.slice(0, 100)}`);
appendLog(iter, taskName, 'error', '', 'CRASH', err.message?.slice(0, 80) ?? '');
}
// Re-run task for fresh output
try { exec('opencli browser close'); } catch {}
for (const step of task.steps) lastOutput = exec(step);
}
try { exec('opencli browser close'); } catch {}
console.log(`\nDebug log saved to: ${DEBUG_LOG}\n`);
}
main();
+146
View File
@@ -0,0 +1,146 @@
#!/usr/bin/env npx tsx
/**
* /autoresearch:fix — Iterative error elimination.
*
* Auto-detects broken state (build → test → browse tests) and iteratively
* fixes errors one at a time. Stops when error count reaches 0.
*
* Priority: build errors → test failures → browse task failures
*
* Usage:
* npx tsx autoresearch/commands/fix.ts
* npx tsx autoresearch/commands/fix.ts --iterations 10
*/
import { execSync } from 'node:child_process';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { parseArgs } from '../config.js';
import { Engine, type ModifyContext } from '../engine.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = join(__dirname, '..', '..');
function exec(cmd: string): { ok: boolean; output: string } {
try {
const output = execSync(cmd, {
cwd: ROOT, timeout: 120_000, encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'pipe'],
}).trim();
return { ok: true, output };
} catch (err: any) {
return { ok: false, output: (err.stdout ?? '') + '\n' + (err.stderr ?? '') };
}
}
/** Detect current broken state and return verify command + error count */
function detectBrokenState(): { verify: string; errors: number; description: string } | null {
// 1. Build
const build = exec('npm run build 2>&1');
if (!build.ok) {
const errorCount = (build.output.match(/error TS/g) || []).length || 1;
return {
verify: 'npm run build 2>&1 | grep -c "error TS" || echo 0',
errors: errorCount,
description: `${errorCount} TypeScript build error(s)`,
};
}
// 2. Tests
const test = exec('npm test 2>&1');
if (!test.ok) {
const failMatch = test.output.match(/(\d+)\s+fail/i);
const errorCount = failMatch ? parseInt(failMatch[1], 10) : 1;
return {
verify: 'npm test 2>&1 | grep -oP "\\d+(?= fail)" || echo 0',
errors: errorCount,
description: `${errorCount} test failure(s)`,
};
}
// 3. Browse tests
const browse = exec('npx tsx autoresearch/eval-browse.ts 2>&1');
const scoreMatch = browse.output.match(/SCORE=(\d+)\/(\d+)/);
if (scoreMatch) {
const passed = parseInt(scoreMatch[1], 10);
const total = parseInt(scoreMatch[2], 10);
const failures = total - passed;
if (failures > 0) {
return {
verify: 'npx tsx autoresearch/eval-browse.ts 2>&1 | tail -1',
errors: failures,
description: `${failures} browse task failure(s) (${passed}/${total})`,
};
}
}
return null; // all clean
}
async function main() {
const args = parseArgs(process.argv.slice(2));
const maxIterations = args.iterations ?? 20;
console.log('\n🔧 AutoResearch Fix — Detecting broken state...\n');
const broken = detectBrokenState();
if (!broken) {
console.log(' ✓ All clean — nothing to fix!\n');
return;
}
console.log(` Found: ${broken.description}`);
console.log(` Verify: ${broken.verify}\n`);
const config = {
goal: `Fix all errors: ${broken.description}`,
scope: ['src/**/*.ts', 'extension/src/**/*.ts'],
metric: 'error_count',
direction: 'lower' as const,
verify: broken.verify,
guard: 'npm run build',
iterations: maxIterations,
minDelta: 1,
};
const logPath = join(ROOT, 'autoresearch-results.tsv');
const engine = new Engine(config, logPath, {
modify: async (ctx: ModifyContext) => {
const prompt = `Fix ONE error. Current error count: ${ctx.currentMetric}. Goal: 0 errors.
Read the error output, understand the root cause, and make ONE focused fix.
Do NOT fix multiple unrelated errors at once.
Do NOT modify test files.
${ctx.stuckHint ? `STUCK HINT: ${ctx.stuckHint}` : ''}`;
try {
// Pass prompt via stdin `input` option to avoid shell metacharacter expansion
const result = execSync(
'claude -p --dangerously-skip-permissions --allowedTools "Bash(npm:*),Bash(npx:*),Read,Edit,Write,Glob,Grep" --output-format text --no-session-persistence',
{ cwd: ROOT, timeout: 180_000, encoding: 'utf-8', input: prompt, stdio: ['pipe', 'pipe', 'pipe'] }
).trim();
const lines = result.split('\n').filter(l => l.trim());
return lines[lines.length - 1]?.trim()?.slice(0, 120) || 'fix attempt';
} catch {
return null;
}
},
onStatus: (msg) => console.log(msg),
});
try {
const results = await engine.run();
const finalMetric = results[results.length - 1]?.metric ?? broken.errors;
if (finalMetric === 0) {
console.log('\n✅ All errors fixed!\n');
} else {
console.log(`\n⚠ ${finalMetric} error(s) remaining after ${maxIterations} iterations.\n`);
}
} catch (err: any) {
console.error(`\n❌ ${err.message}`);
process.exit(1);
}
}
main();
+88
View File
@@ -0,0 +1,88 @@
#!/usr/bin/env npx tsx
/**
* /autoresearch:plan — Interactive configuration wizard.
*
* Walks through goal, scope, metric, verify, guard settings
* and outputs a ready-to-paste run command.
*
* Usage:
* npx tsx autoresearch/commands/plan.ts
*/
import { execSync } from 'node:child_process';
import { createInterface } from 'node:readline';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { PRESETS } from '../presets/index.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = join(__dirname, '..', '..');
const rl = createInterface({ input: process.stdin, output: process.stdout });
const ask = (q: string): Promise<string> => new Promise(r => rl.question(q, r));
async function main() {
console.log('\n🔬 AutoResearch — Configuration Wizard\n');
// Offer presets first
const presetNames = Object.keys(PRESETS);
console.log('Available presets:');
presetNames.forEach((name, i) => {
console.log(` [${i + 1}] ${name}${PRESETS[name].goal}`);
});
console.log(` [0] Custom config\n`);
const choice = await ask('Choose preset or 0 for custom: ');
const idx = parseInt(choice, 10);
if (idx > 0 && idx <= presetNames.length) {
const name = presetNames[idx - 1];
const iterations = await ask('Iterations (empty = unbounded): ');
const iterFlag = iterations ? ` --iterations ${iterations}` : '';
console.log(`\n✅ Ready to run:\n`);
console.log(` npx tsx autoresearch/commands/run.ts --preset ${name}${iterFlag}\n`);
rl.close();
return;
}
// Custom config
const goal = await ask('Goal (what to improve): ');
const scope = await ask('Scope (file globs, comma-separated): ');
const metric = await ask('Metric name (e.g. pass_count, coverage): ');
const direction = await ask('Direction (higher/lower): ') as 'higher' | 'lower';
const verify = await ask('Verify command (must output a number): ');
// Dry-run verify
console.log('\n Dry-running verify command...');
try {
const output = execSync(verify, { cwd: ROOT, timeout: 120_000, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
const { extractMetric } = await import('../config.js');
const value = extractMetric(output);
if (value != null) {
console.log(` ✓ Verify works — current ${metric}: ${value}`);
} else {
console.log(` ⚠ Verify ran but no number extracted from output:\n ${output.slice(0, 200)}`);
}
} catch (err: any) {
console.log(` ✗ Verify failed: ${err.message?.slice(0, 100)}`);
}
const guard = await ask('Guard command (optional, press Enter to skip): ');
const iterations = await ask('Iterations (empty = unbounded): ');
const parts = ['npx tsx autoresearch/commands/run.ts'];
parts.push(`--goal "${goal}"`);
parts.push(`--scope "${scope}"`);
parts.push(`--metric "${metric}"`);
parts.push(`--direction ${direction}`);
parts.push(`--verify "${verify}"`);
if (guard) parts.push(`--guard "${guard}"`);
if (iterations) parts.push(`--iterations ${iterations}`);
console.log(`\n✅ Ready to run:\n`);
console.log(` ${parts.join(' \\\n ')}\n`);
rl.close();
}
main();
+138
View File
@@ -0,0 +1,138 @@
#!/usr/bin/env npx tsx
/**
* /autoresearch — Main autonomous iteration loop.
*
* Usage:
* npx tsx autoresearch/commands/run.ts --preset browser-reliability
* npx tsx autoresearch/commands/run.ts --preset browser-reliability --iterations 5
* npx tsx autoresearch/commands/run.ts --goal "..." --scope "src/*.ts" --verify "..." --iterations 10
*
* The modify callback spawns Claude Code to make ONE atomic change per iteration.
* Engine handles commit, verify, guard, keep/discard, and logging.
*/
import { execSync } from 'node:child_process';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { parseArgs, type AutoResearchConfig } from '../config.js';
import { Engine, type ModifyContext } from '../engine.js';
import { PRESETS } from '../presets/index.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = join(__dirname, '..', '..');
function buildModifyPrompt(ctx: ModifyContext, config: AutoResearchConfig): string {
const recent = ctx.recentLog.slice(-10).map(r =>
` ${r.status.padEnd(12)} ${r.description}`
).join('\n');
return `You are an autonomous improvement agent. Make ONE atomic change to improve this metric.
## Goal
${config.goal}
## Current State
- Metric (${config.metric}): ${ctx.currentMetric} (best: ${ctx.bestMetric})
- Iteration: ${ctx.iteration}
- Consecutive discards: ${ctx.consecutiveDiscards}
${ctx.stuckHint ? `\n## STUCK — Try a Different Approach\n${ctx.stuckHint}` : ''}
## Recent History
${recent || ' (no history yet)'}
## Git Log (recent experiments)
${ctx.gitLog.split('\n').slice(0, 10).join('\n')}
## Scope (files you can modify)
${ctx.scopeFiles.join('\n')}
## Rules
1. Make ONE atomic change (one logical intent, even if multiple files)
2. Read the failing test output or code BEFORE modifying
3. DO NOT modify test files or the verify command
4. Describe what you changed in one sentence (no "and" linking unrelated actions)
5. If previous approach was discarded, try something DIFFERENT
6. Focus on the specific failures — read error messages carefully`;
}
async function modify(ctx: ModifyContext, config: AutoResearchConfig): Promise<string | null> {
const prompt = buildModifyPrompt(ctx, config);
console.log(' Claude Code making a change...');
try {
const result = execSync(
`claude -p --dangerously-skip-permissions --allowedTools "Bash(npm:*),Bash(npx:*),Bash(git:*),Read,Edit,Write,Glob,Grep" --output-format text --no-session-persistence "${prompt.replace(/"/g, '\\"')}"`,
{
cwd: ROOT,
timeout: 300_000,
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'pipe'],
env: process.env,
}
).trim();
// Extract description from Claude's response (last non-empty line or summary)
const lines = result.split('\n').filter(l => l.trim());
const desc = lines[lines.length - 1]?.trim() || 'change made by Claude Code';
return desc.slice(0, 120);
} catch (err: any) {
console.error(' Claude Code failed:', err.message?.slice(0, 100));
return null;
}
}
async function main() {
const args = parseArgs(process.argv.slice(2));
// Resolve config from preset or CLI args
let config: AutoResearchConfig;
if (args.preset) {
config = PRESETS[args.preset];
if (!config) {
console.error(`Unknown preset: ${args.preset}`);
console.error(`Available: ${Object.keys(PRESETS).join(', ')}`);
process.exit(1);
}
// Allow CLI overrides
if (args.iterations != null) config = { ...config, iterations: args.iterations };
if (args.guard != null) config = { ...config, guard: args.guard };
} else if (args.goal && args.verify) {
config = {
goal: args.goal,
scope: args.scope ?? ['src/**/*.ts'],
metric: args.metric ?? 'score',
direction: args.direction ?? 'higher',
verify: args.verify,
guard: args.guard,
iterations: args.iterations,
minDelta: args.minDelta,
};
} else {
console.error('Usage: npx tsx autoresearch/commands/run.ts --preset <name> [--iterations N]');
console.error(' or: npx tsx autoresearch/commands/run.ts --goal "..." --verify "..." --scope "..."');
console.error(`\nAvailable presets: ${Object.keys(PRESETS).join(', ')}`);
process.exit(1);
}
console.log(`\n🔬 AutoResearch: ${config.goal}`);
console.log(` Metric: ${config.metric} (${config.direction})`);
console.log(` Verify: ${config.verify}`);
console.log(` Guard: ${config.guard ?? '(none)'}`);
console.log(` Iterations: ${config.iterations ?? '∞'}`);
console.log('');
const logPath = join(ROOT, 'autoresearch-results.tsv');
const engine = new Engine(config, logPath, {
modify: (ctx) => modify(ctx, config),
onStatus: (msg) => console.log(msg),
});
try {
await engine.run();
} catch (err: any) {
console.error(`\n❌ ${err.message}`);
process.exit(1);
}
}
main();
+82
View File
@@ -0,0 +1,82 @@
/**
* AutoResearch Configuration — type definitions and CLI parsing.
*
* Based on Karpathy's autoresearch: constraint + mechanical metric + unbounded loop.
*/
export interface AutoResearchConfig {
/** Plain-language goal, e.g. "Increase browser pass rate to 59/59" */
goal: string;
/** Glob patterns for files the agent can modify */
scope: string[];
/** What the metric measures, e.g. "pass_count" */
metric: string;
/** Whether improvement means the number goes up or down */
direction: 'higher' | 'lower';
/** Shell command that outputs a number (the metric value) */
verify: string;
/** Optional guard command — must pass for a keep decision */
guard?: string;
/** Max iterations (undefined = unbounded) */
iterations?: number;
/** Minimum delta to count as real improvement (noise filter) */
minDelta?: number;
}
export type IterationStatus =
| 'baseline'
| 'keep'
| 'keep (reworked)'
| 'discard'
| 'crash'
| 'no-op'
| 'hook-blocked';
export interface IterationResult {
iteration: number;
commit: string;
metric: number;
delta: number;
guard: 'pass' | 'fail' | '-';
status: IterationStatus;
description: string;
}
/** Parse CLI args into a partial config (missing fields filled by preset or prompts) */
export function parseArgs(argv: string[]): Partial<AutoResearchConfig> & { preset?: string; task?: string } {
const config: Partial<AutoResearchConfig> & { preset?: string; task?: string } = {};
for (let i = 0; i < argv.length; i++) {
const arg = argv[i];
const next = argv[i + 1];
switch (arg) {
case '--preset': config.preset = next; i++; break;
case '--goal': config.goal = next; i++; break;
case '--scope': config.scope = next?.split(','); i++; break;
case '--metric': config.metric = next; i++; break;
case '--direction': config.direction = next as 'higher' | 'lower'; i++; break;
case '--verify': config.verify = next; i++; break;
case '--guard': config.guard = next; i++; break;
case '--iterations': config.iterations = parseInt(next, 10); i++; break;
case '--min-delta': config.minDelta = parseFloat(next); i++; break;
case '--task': config.task = next; i++; break;
}
}
return config;
}
/** Extract a number from command output using common patterns */
export function extractMetric(output: string): number | null {
// Try: last line that looks like a number
const lines = output.trim().split('\n');
for (let i = lines.length - 1; i >= 0; i--) {
const line = lines[i].trim();
// Match standalone numbers: "56", "95.2", "SCORE=56/59" → 56
const scoreMatch = line.match(/SCORE[=:]\s*(\d+)/i);
if (scoreMatch) return parseFloat(scoreMatch[1]);
const numMatch = line.match(/^[\d.]+$/);
if (numMatch) return parseFloat(numMatch[0]);
}
// Fallback: first number in output
const fallback = output.match(/(\d+(?:\.\d+)?)/);
return fallback ? parseFloat(fallback[1]) : null;
}
+363
View File
@@ -0,0 +1,363 @@
/**
* AutoResearch Engine — Karpathy's 8-phase autonomous iteration loop.
*
* Phase 0: Precondition checks (git clean, no locks)
* Phase 1: Review (read scope files + log + git history)
* Phase 2: Ideate (select next change based on history)
* Phase 3: Modify (one atomic change — delegated to caller)
* Phase 4: Commit (git add + commit with experiment prefix)
* Phase 5: Verify (run verify command, extract metric)
* Phase 5.5: Guard (optional regression check)
* Phase 6: Decide (keep/discard/crash + rollback)
* Phase 7: Log (append TSV)
* Phase 8: Repeat
*/
import { execSync, execFileSync } from 'node:child_process';
import { readFileSync, existsSync } from 'node:fs';
import { join } from 'node:path';
import { type AutoResearchConfig, type IterationResult, type IterationStatus, extractMetric } from './config.js';
import { Logger } from './logger.js';
export interface EngineCallbacks {
/** Called at Phase 2-3: review context, ideate, and make ONE change.
* Return a one-sentence description of what was changed, or null to skip. */
modify(context: ModifyContext): Promise<string | null>;
/** Called when engine needs to report status */
onStatus?(msg: string): void;
}
export interface ModifyContext {
iteration: number;
bestMetric: number;
currentMetric: number;
recentLog: IterationResult[];
gitLog: string;
scopeFiles: string[];
consecutiveDiscards: number;
stuckHint: string | null;
}
const ROOT = join(import.meta.dirname ?? process.cwd(), '..');
function exec(cmd: string, opts?: { timeout?: number; cwd?: string }): string {
try {
return execSync(cmd, {
cwd: opts?.cwd ?? ROOT,
timeout: opts?.timeout ?? 120_000,
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'pipe'],
env: process.env,
}).trim();
} catch (err: any) {
return err.stdout?.trim() ?? err.message ?? '';
}
}
function execStrict(cmd: string, opts?: { timeout?: number }): string {
return execSync(cmd, {
cwd: ROOT,
timeout: opts?.timeout ?? 120_000,
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'pipe'],
env: process.env,
}).trim();
}
export class Engine {
private config: AutoResearchConfig;
private logger: Logger;
private callbacks: EngineCallbacks;
private bestMetric: number = 0;
private currentMetric: number = 0;
private iteration: number = 0;
constructor(config: AutoResearchConfig, logPath: string, callbacks: EngineCallbacks) {
this.config = config;
this.logger = new Logger(logPath);
this.callbacks = callbacks;
}
private log(msg: string): void {
this.callbacks.onStatus?.(msg);
}
/** Phase 0: Precondition checks */
private checkPreconditions(): void {
// Git repo exists
try { execStrict('git rev-parse --git-dir'); }
catch { throw new Error('Not a git repository'); }
// Clean working tree
const status = exec('git status --porcelain');
if (status) throw new Error(`Working tree not clean:\n${status}`);
// No stale locks
if (existsSync(join(ROOT, '.git', 'index.lock'))) {
throw new Error('Stale .git/index.lock found — remove it first');
}
// Not detached HEAD
try { execStrict('git symbolic-ref HEAD'); }
catch { throw new Error('Detached HEAD — checkout a branch first'); }
}
/** Phase 5: Run verify command and extract metric */
private runVerify(): number | null {
this.log(' verify...');
const output = exec(this.config.verify, { timeout: 300_000 });
return extractMetric(output);
}
/** Phase 5.5: Run guard command */
private runGuard(): boolean {
if (!this.config.guard) return true;
this.log(' guard...');
try {
execStrict(this.config.guard, { timeout: 300_000 });
return true;
} catch {
return false;
}
}
/** Phase 4: Commit changes */
private commit(description: string): string | null {
if (!this.config.scope.length) return null; // no scope = nothing to stage
// Stage only files matching scope globs (avoid staging unrelated changes)
// Use execFileSync to bypass shell glob expansion so git handles pathspecs directly
execFileSync('git', ['add', '--', ...this.config.scope], {
cwd: ROOT, timeout: 30_000, stdio: ['pipe', 'pipe', 'pipe'],
});
const diff = exec('git diff --cached --quiet; echo $?');
if (diff === '0') return null; // no changes
try {
execStrict(`git commit -m "experiment(browser): ${description.replace(/"/g, '\\"')}"`);
return exec('git rev-parse --short HEAD');
} catch {
// Hook failure
exec('git reset HEAD');
return 'hook-blocked';
}
}
/** Phase 6: Rollback */
private safeRevert(): void {
try {
execStrict('git revert HEAD --no-edit');
} catch {
exec('git revert --abort');
exec('git reset --hard HEAD~1');
}
}
/** Get stuck hint when >5 consecutive discards */
private getStuckHint(discards: number): string | null {
if (discards < 5) return null;
const hints = [
'Re-read ALL scope files from scratch. Try a completely different approach.',
'Review entire results log — what worked before? Try combining successful changes.',
'Try the OPPOSITE of what has been failing.',
'Try a radical architectural change instead of incremental tweaks.',
'Simplify — remove complexity rather than adding it.',
];
return hints[Math.min(discards - 5, hints.length - 1)];
}
/** Run the main loop */
async run(): Promise<IterationResult[]> {
const results: IterationResult[] = [];
// Phase 0: Preconditions
this.log('Phase 0: Precondition checks...');
this.checkPreconditions();
// Initialize logger
this.logger.init(this.config);
// Baseline measurement
this.log('Measuring baseline...');
const baseline = this.runVerify();
if (baseline == null) throw new Error('Verify command returned no metric for baseline');
this.bestMetric = baseline;
this.currentMetric = baseline;
const baselineCommit = exec('git rev-parse --short HEAD');
const baselineResult: IterationResult = {
iteration: 0,
commit: baselineCommit,
metric: baseline,
delta: 0,
guard: this.config.guard ? (this.runGuard() ? 'pass' : 'fail') : '-',
status: 'baseline',
description: `initial state — ${this.config.metric} ${baseline}`,
};
this.logger.append(baselineResult);
results.push(baselineResult);
this.log(`Baseline: ${this.config.metric} = ${baseline}`);
// Main loop
const maxIter = this.config.iterations ?? Infinity;
for (this.iteration = 1; this.iteration <= maxIter; this.iteration++) {
this.log(`\n━━━ Iteration ${this.iteration}${maxIter < Infinity ? `/${maxIter}` : ''} ━━━`);
// Phase 1: Review
const gitLog = exec('git log --oneline -20');
const recentLog = this.logger.readLast(20);
const scopeFiles = this.config.scope;
const consecutiveDiscards = this.logger.consecutiveDiscards();
// Phase 2-3: Ideate + Modify (delegated to callback)
const context: ModifyContext = {
iteration: this.iteration,
bestMetric: this.bestMetric,
currentMetric: this.currentMetric,
recentLog,
gitLog,
scopeFiles,
consecutiveDiscards,
stuckHint: this.getStuckHint(consecutiveDiscards),
};
let description: string | null;
try {
description = await this.callbacks.modify(context);
} catch (err: any) {
this.log(` modify error: ${err.message}`);
const result: IterationResult = {
iteration: this.iteration,
commit: '-',
metric: this.currentMetric,
delta: 0,
guard: '-',
status: 'crash',
description: `modify crashed: ${err.message?.slice(0, 80)}`,
};
this.logger.append(result);
results.push(result);
continue;
}
if (!description) {
const result: IterationResult = {
iteration: this.iteration,
commit: '-',
metric: this.currentMetric,
delta: 0,
guard: '-',
status: 'no-op',
description: 'no changes made',
};
this.logger.append(result);
results.push(result);
continue;
}
// Phase 4: Commit
this.log(` commit: ${description}`);
const commitHash = this.commit(description);
if (!commitHash) {
const result: IterationResult = {
iteration: this.iteration,
commit: '-',
metric: this.currentMetric,
delta: 0,
guard: '-',
status: 'no-op',
description: `no diff after: ${description}`,
};
this.logger.append(result);
results.push(result);
continue;
}
if (commitHash === 'hook-blocked') {
const result: IterationResult = {
iteration: this.iteration,
commit: '-',
metric: this.currentMetric,
delta: 0,
guard: '-',
status: 'hook-blocked',
description: `hook rejected: ${description}`,
};
this.logger.append(result);
results.push(result);
continue;
}
// Phase 5: Verify
const metric = this.runVerify();
if (metric == null) {
this.log(' verify crashed — reverting');
this.safeRevert();
const result: IterationResult = {
iteration: this.iteration,
commit: '-',
metric: this.currentMetric,
delta: 0,
guard: '-',
status: 'crash',
description: `verify crashed: ${description}`,
};
this.logger.append(result);
results.push(result);
continue;
}
const improved = this.config.direction === 'higher'
? metric > this.bestMetric
: metric < this.bestMetric;
const delta = +(metric - this.bestMetric).toFixed(4);
const absDelta = Math.abs(delta);
const minDelta = this.config.minDelta ?? 0;
// Phase 5.5: Guard
let guardResult: 'pass' | 'fail' | '-' = '-';
if (this.config.guard && improved && absDelta >= minDelta) {
guardResult = this.runGuard() ? 'pass' : 'fail';
}
// Phase 6: Decide
let status: IterationStatus;
if (improved && absDelta >= minDelta && (guardResult !== 'fail')) {
status = 'keep';
this.bestMetric = metric;
this.currentMetric = metric;
this.log(` ✓ KEEP — ${this.config.metric}: ${metric} (${delta >= 0 ? '+' : ''}${delta})`);
} else if (improved && guardResult === 'fail') {
this.log(' guard failed — reverting');
this.safeRevert();
status = 'discard';
this.log(` ✗ DISCARD (guard) — ${description}`);
} else {
this.safeRevert();
status = 'discard';
const reason = absDelta < minDelta ? 'below min delta' : 'no improvement';
this.log(` ✗ DISCARD (${reason}) — ${this.config.metric}: ${metric} (${delta >= 0 ? '+' : ''}${delta})`);
}
const result: IterationResult = {
iteration: this.iteration,
commit: status === 'keep' ? commitHash : '-',
metric,
delta,
guard: guardResult,
status,
description,
};
this.logger.append(result);
results.push(result);
}
// Summary
const keeps = results.filter(r => r.status === 'keep' || r.status === 'keep (reworked)');
const discards = results.filter(r => r.status === 'discard');
this.log(`\n${'━'.repeat(50)}`);
this.log(`Done: ${this.iteration - 1} iterations, ${keeps.length} kept, ${discards.length} discarded`);
this.log(`Final ${this.config.metric}: ${this.bestMetric} (started at ${results[0]?.metric})`);
return results;
}
}
+127
View File
@@ -0,0 +1,127 @@
#!/usr/bin/env npx tsx
/**
* Combined Test Suite Runner — runs browse + V2EX + Zhihu tasks.
* Reports combined score for AutoResearch iteration.
*
* Usage:
* npx tsx autoresearch/eval-all.ts # Run all
* npx tsx autoresearch/eval-all.ts --suite v2ex # Run one suite
*/
import { execSync } from 'node:child_process';
import { readFileSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = join(__dirname, '..');
const RESULTS_DIR = join(__dirname, 'results');
interface SuiteResult {
name: string;
passed: number;
total: number;
failures: string[];
duration: number;
}
function runSuite(name: string, script: string): SuiteResult {
const start = Date.now();
try {
const output = execSync(`npx tsx ${script}`, {
cwd: ROOT,
timeout: 600_000,
encoding: 'utf-8',
env: process.env,
stdio: ['pipe', 'pipe', 'pipe'],
});
// Parse SCORE=X/Y from output
const scoreMatch = output.match(/SCORE=(\d+)\/(\d+)/);
const passed = scoreMatch ? parseInt(scoreMatch[1], 10) : 0;
const total = scoreMatch ? parseInt(scoreMatch[2], 10) : 0;
// Parse failures
const failures: string[] = [];
const failLines = output.match(/✗.*$/gm) || [];
for (const line of failLines) {
const m = line.match(/✗\s+(?:\[.*?\]\s+)?(\S+)/);
if (m) failures.push(m[1].replace(/:$/, ''));
}
return { name, passed, total, failures, duration: Date.now() - start };
} catch (err: any) {
const output = err.stdout ?? '';
const scoreMatch = output.match(/SCORE=(\d+)\/(\d+)/);
const passed = scoreMatch ? parseInt(scoreMatch[1], 10) : 0;
const total = scoreMatch ? parseInt(scoreMatch[2], 10) : 0;
const failures: string[] = [];
const failLines = output.match(/✗.*$/gm) || [];
for (const line of failLines) {
const m = line.match(/✗\s+(?:\[.*?\]\s+)?(\S+)/);
if (m) failures.push(m[1].replace(/:$/, ''));
}
return { name, passed, total, failures, duration: Date.now() - start };
}
}
function main() {
const args = process.argv.slice(2);
const singleSuite = args.includes('--suite') ? args[args.indexOf('--suite') + 1] : null;
const suites = [
{ name: 'browse', script: 'autoresearch/eval-browse.ts' },
{ name: 'v2ex', script: 'autoresearch/eval-v2ex.ts' },
{ name: 'zhihu', script: 'autoresearch/eval-zhihu.ts' },
].filter(s => !singleSuite || s.name === singleSuite);
console.log(`\n🔬 Combined AutoResearch — ${suites.length} suites\n`);
const results: SuiteResult[] = [];
for (const suite of suites) {
console.log(` Running ${suite.name}...`);
const result = runSuite(suite.name, suite.script);
results.push(result);
const icon = result.passed === result.total ? '✓' : '✗';
console.log(` ${icon} ${result.name}: ${result.passed}/${result.total} (${Math.round(result.duration / 1000)}s)`);
if (result.failures.length > 0) {
for (const f of result.failures.slice(0, 5)) {
console.log(`${f}`);
}
}
}
// Summary
const totalPassed = results.reduce((s, r) => s + r.passed, 0);
const totalTasks = results.reduce((s, r) => s + r.total, 0);
const totalDuration = results.reduce((s, r) => s + r.duration, 0);
const allFailures = results.flatMap(r => r.failures.map(f => `${r.name}:${f}`));
console.log(`\n${'━'.repeat(50)}`);
console.log(` Combined: ${totalPassed}/${totalTasks}`);
for (const r of results) {
console.log(` ${r.name}: ${r.passed}/${r.total}`);
}
console.log(` Time: ${Math.round(totalDuration / 60000)}min`);
if (allFailures.length > 0) {
console.log(`\n All failures:`);
for (const f of allFailures) console.log(`${f}`);
}
// Save result
mkdirSync(RESULTS_DIR, { recursive: true });
const existing = readdirSync(RESULTS_DIR).filter(f => f.startsWith('all-')).length;
const roundNum = String(existing + 1).padStart(3, '0');
const resultPath = join(RESULTS_DIR, `all-${roundNum}.json`);
writeFileSync(resultPath, JSON.stringify({
timestamp: new Date().toISOString(),
score: `${totalPassed}/${totalTasks}`,
suites: Object.fromEntries(results.map(r => [r.name, `${r.passed}/${r.total}`])),
failures: allFailures,
duration: `${Math.round(totalDuration / 60000)}min`,
}, null, 2), 'utf-8');
console.log(`\n Results saved to: ${resultPath}`);
console.log(`\nSCORE=${totalPassed}/${totalTasks}`);
}
main();
+185
View File
@@ -0,0 +1,185 @@
#!/usr/bin/env npx tsx
/**
* Layer 1: Deterministic Browse Command Testing
*
* Runs predefined opencli browser command sequences against real websites.
* No LLM involved — tests command reliability only.
*
* Usage:
* npx tsx autoresearch/eval-browse.ts # Run all tasks
* npx tsx autoresearch/eval-browse.ts --task hn-top5 # Run single task
*/
import { execSync } from 'node:child_process';
import { readFileSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const TASKS_FILE = join(__dirname, 'browse-tasks.json');
const RESULTS_DIR = join(__dirname, 'results');
const BASELINE_FILE = join(__dirname, 'baseline-browse.txt');
interface BrowseTask {
name: string;
steps: string[];
judge: JudgeCriteria;
set?: 'test';
note?: string;
}
type JudgeCriteria =
| { type: 'contains'; value: string }
| { type: 'arrayMinLength'; minLength: number }
| { type: 'nonEmpty' }
| { type: 'matchesPattern'; pattern: string };
interface TaskResult {
name: string;
passed: boolean;
duration: number;
error?: string;
set: 'train' | 'test';
}
function judge(criteria: JudgeCriteria, output: string): boolean {
try {
switch (criteria.type) {
case 'contains':
return output.toLowerCase().includes(criteria.value.toLowerCase());
case 'arrayMinLength': {
try {
const arr = JSON.parse(output);
if (Array.isArray(arr)) return arr.length >= criteria.minLength;
} catch { /* not JSON array */ }
return false;
}
case 'nonEmpty':
return output.trim().length > 0 && output.trim() !== 'null' && output.trim() !== 'undefined';
case 'matchesPattern':
return new RegExp(criteria.pattern).test(output);
default:
return false;
}
} catch {
return false;
}
}
function runCommand(cmd: string): string {
try {
return execSync(cmd, {
cwd: join(__dirname, '..'),
timeout: 30000,
encoding: 'utf-8',
env: process.env,
stdio: ['pipe', 'pipe', 'pipe'],
}).trim();
} catch (err: any) {
return err.stdout?.trim() || err.stderr?.trim() || '';
}
}
function runTask(task: BrowseTask): TaskResult {
const start = Date.now();
let lastOutput = '';
try {
for (const step of task.steps) {
lastOutput = runCommand(step);
}
const passed = judge(task.judge, lastOutput);
return {
name: task.name,
passed,
duration: Date.now() - start,
error: passed ? undefined : `Output: ${lastOutput.slice(0, 100)}`,
set: task.set === 'test' ? 'test' : 'train',
};
} catch (err: any) {
return {
name: task.name,
passed: false,
duration: Date.now() - start,
error: err.message?.slice(0, 100),
set: task.set === 'test' ? 'test' : 'train',
};
}
}
function main() {
const args = process.argv.slice(2);
const singleTask = args.includes('--task') ? args[args.indexOf('--task') + 1] : null;
const allTasks: BrowseTask[] = JSON.parse(readFileSync(TASKS_FILE, 'utf-8'));
const tasks = singleTask ? allTasks.filter(t => t.name === singleTask) : allTasks;
if (tasks.length === 0) {
console.error(`Task "${singleTask}" not found.`);
process.exit(1);
}
console.log(`\n🔬 Layer 1: Browse Commands — ${tasks.length} tasks\n`);
const results: TaskResult[] = [];
for (let i = 0; i < tasks.length; i++) {
const task = tasks[i];
process.stdout.write(` [${i + 1}/${tasks.length}] ${task.name}...`);
const result = runTask(task);
results.push(result);
const icon = result.passed ? '✓' : '✗';
console.log(` ${icon} (${(result.duration / 1000).toFixed(1)}s)`);
// Close browser between tasks for clean state
if (i < tasks.length - 1) {
try { runCommand('opencli browser close'); } catch { /* ignore */ }
}
}
// Final close
try { runCommand('opencli browser close'); } catch { /* ignore */ }
// Summary
const trainResults = results.filter(r => r.set === 'train');
const testResults = results.filter(r => r.set === 'test');
const totalPassed = results.filter(r => r.passed).length;
const trainPassed = trainResults.filter(r => r.passed).length;
const testPassed = testResults.filter(r => r.passed).length;
const totalDuration = results.reduce((s, r) => s + r.duration, 0);
console.log(`\n${'─'.repeat(50)}`);
console.log(` Score: ${totalPassed}/${results.length} (train: ${trainPassed}/${trainResults.length}, test: ${testPassed}/${testResults.length})`);
console.log(` Time: ${Math.round(totalDuration / 60000)}min`);
const failures = results.filter(r => !r.passed);
if (failures.length > 0) {
console.log(`\n Failures:`);
for (const f of failures) {
console.log(`${f.name}: ${f.error ?? 'unknown'}`);
}
}
console.log('');
// Save result
mkdirSync(RESULTS_DIR, { recursive: true });
const existing = readdirSync(RESULTS_DIR).filter(f => f.startsWith('browse-')).length;
const roundNum = String(existing + 1).padStart(3, '0');
const resultPath = join(RESULTS_DIR, `browse-${roundNum}.json`);
writeFileSync(resultPath, JSON.stringify({
timestamp: new Date().toISOString(),
score: `${totalPassed}/${results.length}`,
trainScore: `${trainPassed}/${trainResults.length}`,
testScore: `${testPassed}/${testResults.length}`,
duration: `${Math.round(totalDuration / 60000)}min`,
tasks: results,
}, null, 2), 'utf-8');
console.log(` Results saved to: ${resultPath}`);
console.log(`\nSCORE=${totalPassed}/${results.length}`);
}
main();
+238
View File
@@ -0,0 +1,238 @@
#!/usr/bin/env npx tsx
/**
* Layer 5: Publish Testing — end-to-end content creation via browser commands
*
* Tests the full chain: read content → navigate to platform → fill title+body → (optionally) publish → verify → cleanup
*
* Task types:
* fill-only: navigate + fill fields + verify content was entered (safe, no side effects)
* publish: full publish + verify + cleanup (deletes the post after verification)
*
* Usage:
* npx tsx autoresearch/eval-publish.ts # Run all tasks
* npx tsx autoresearch/eval-publish.ts --task twitter-fill # Run single task
* npx tsx autoresearch/eval-publish.ts --type fill-only # Run only fill tasks (safe)
* npx tsx autoresearch/eval-publish.ts --type publish # Run only publish tasks (destructive)
* npx tsx autoresearch/eval-publish.ts --platform twitter # Run only twitter tasks
*/
import { execSync } from 'node:child_process';
import { readFileSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const PROJECT_ROOT = join(__dirname, '..');
const TASKS_FILE = join(__dirname, 'publish-tasks.json');
const RESULTS_DIR = join(__dirname, 'results');
interface PublishTask {
name: string;
platform: string;
type: 'fill-only' | 'publish';
description: string;
steps: string[];
judge: JudgeCriteria;
cleanup?: string[];
note?: string;
}
type JudgeCriteria =
| { type: 'contains'; value: string }
| { type: 'arrayMinLength'; minLength: number }
| { type: 'nonEmpty' }
| { type: 'matchesPattern'; pattern: string };
interface TaskResult {
name: string;
platform: string;
taskType: 'fill-only' | 'publish';
passed: boolean;
duration: number;
cleanupResult?: string;
error?: string;
}
function judge(criteria: JudgeCriteria, output: string): boolean {
try {
switch (criteria.type) {
case 'contains':
return output.toLowerCase().includes(criteria.value.toLowerCase());
case 'arrayMinLength': {
try {
const arr = JSON.parse(output);
if (Array.isArray(arr)) return arr.length >= criteria.minLength;
} catch { /* not JSON */ }
return false;
}
case 'nonEmpty':
return output.trim().length > 0 && output.trim() !== 'null' && output.trim() !== 'undefined';
case 'matchesPattern':
return new RegExp(criteria.pattern, 'i').test(output);
default:
return false;
}
} catch {
return false;
}
}
function runCommand(cmd: string, timeout = 30000): string {
const localCmd = cmd.replace(/^opencli /, `node dist/src/main.js `);
try {
return execSync(localCmd, {
cwd: PROJECT_ROOT,
timeout,
encoding: 'utf-8',
env: process.env,
stdio: ['pipe', 'pipe', 'pipe'],
}).trim();
} catch (err: any) {
return err.stdout?.trim() || err.stderr?.trim() || '';
}
}
function runTask(task: PublishTask): TaskResult {
const start = Date.now();
try {
// Run main steps
let lastOutput = '';
for (let i = 0; i < task.steps.length; i++) {
const step = task.steps[i];
process.stderr.write(` step ${i + 1}/${task.steps.length}: ${step.slice(0, 60)}...\n`);
lastOutput = runCommand(step, 45000);
}
const passed = judge(task.judge, lastOutput);
// Run cleanup steps (if publish type and cleanup defined)
let cleanupResult: string | undefined;
if (task.cleanup && task.cleanup.length > 0) {
process.stderr.write(` cleanup: ${task.cleanup.length} steps...\n`);
let cleanupOutput = '';
for (const step of task.cleanup) {
cleanupOutput = runCommand(step, 30000);
}
cleanupResult = cleanupOutput.slice(0, 100);
}
return {
name: task.name,
platform: task.platform,
taskType: task.type,
passed,
duration: Date.now() - start,
cleanupResult,
error: passed ? undefined : `Output: ${lastOutput.slice(0, 150)}`,
};
} catch (err: any) {
return {
name: task.name,
platform: task.platform,
taskType: task.type,
passed: false,
duration: Date.now() - start,
error: err.message?.slice(0, 150),
};
}
}
function main() {
const args = process.argv.slice(2);
const singleTask = args.includes('--task') ? args[args.indexOf('--task') + 1] : null;
const filterType = args.includes('--type') ? args[args.indexOf('--type') + 1] : null;
const filterPlatform = args.includes('--platform') ? args[args.indexOf('--platform') + 1] : null;
const allTasks: PublishTask[] = JSON.parse(readFileSync(TASKS_FILE, 'utf-8'));
let tasks = allTasks;
if (singleTask) tasks = tasks.filter(t => t.name === singleTask);
if (filterType) tasks = tasks.filter(t => t.type === filterType);
if (filterPlatform) tasks = tasks.filter(t => t.platform === filterPlatform);
if (tasks.length === 0) {
console.error(`No tasks matched filters: task=${singleTask}, type=${filterType}, platform=${filterPlatform}`);
process.exit(1);
}
const fillTasks = tasks.filter(t => t.type === 'fill-only');
const publishTasks = tasks.filter(t => t.type === 'publish');
console.log(`\n📝 Layer 5: Publish Testing — ${tasks.length} tasks`);
console.log(` fill-only: ${fillTasks.length} | publish: ${publishTasks.length}`);
console.log(` platforms: ${[...new Set(tasks.map(t => t.platform))].join(', ')}\n`);
const results: TaskResult[] = [];
for (let i = 0; i < tasks.length; i++) {
const task = tasks[i];
const icon = task.type === 'publish' ? '🚀' : '📋';
process.stdout.write(` [${i + 1}/${tasks.length}] ${icon} ${task.name} (${task.platform})...`);
const result = runTask(task);
results.push(result);
const status = result.passed ? '✓' : '✗';
const cleanup = result.cleanupResult ? ` [cleanup: ${result.cleanupResult.slice(0, 30)}]` : '';
console.log(` ${status} (${(result.duration / 1000).toFixed(1)}s)${cleanup}`);
// Close browser between tasks for clean state
if (i < tasks.length - 1) {
try { runCommand('opencli browser close'); } catch { /* ignore */ }
}
}
// Final close
try { runCommand('opencli browser close'); } catch { /* ignore */ }
// Summary
const totalPassed = results.filter(r => r.passed).length;
const fillPassed = results.filter(r => r.taskType === 'fill-only' && r.passed).length;
const publishPassed = results.filter(r => r.taskType === 'publish' && r.passed).length;
const totalDuration = results.reduce((s, r) => s + r.duration, 0);
const fillTotal = results.filter(r => r.taskType === 'fill-only').length;
const publishTotal = results.filter(r => r.taskType === 'publish').length;
console.log(`\n${'─'.repeat(50)}`);
console.log(` Score: ${totalPassed}/${results.length}`);
console.log(` fill-only: ${fillPassed}/${fillTotal}`);
console.log(` publish: ${publishPassed}/${publishTotal}`);
console.log(` Time: ${Math.round(totalDuration / 1000)}s`);
// Platform breakdown
const platforms = [...new Set(results.map(r => r.platform))];
for (const p of platforms) {
const pr = results.filter(r => r.platform === p);
const pp = pr.filter(r => r.passed).length;
console.log(` ${p}: ${pp}/${pr.length}`);
}
const failures = results.filter(r => !r.passed);
if (failures.length > 0) {
console.log(`\n Failures:`);
for (const f of failures) {
console.log(`${f.name} [${f.platform}/${f.taskType}]: ${f.error ?? 'unknown'}`);
}
}
console.log('');
// Save result
mkdirSync(RESULTS_DIR, { recursive: true });
const existing = readdirSync(RESULTS_DIR).filter(f => f.startsWith('publish-')).length;
const roundNum = String(existing + 1).padStart(3, '0');
const resultPath = join(RESULTS_DIR, `publish-${roundNum}.json`);
writeFileSync(resultPath, JSON.stringify({
timestamp: new Date().toISOString(),
score: `${totalPassed}/${results.length}`,
fillScore: `${fillPassed}/${fillTotal}`,
publishScore: `${publishPassed}/${publishTotal}`,
duration: `${Math.round(totalDuration / 1000)}s`,
tasks: results,
}, null, 2), 'utf-8');
console.log(` Results saved to: ${resultPath}`);
console.log(`\nSCORE=${totalPassed}/${results.length}`);
}
main();
+249
View File
@@ -0,0 +1,249 @@
#!/usr/bin/env npx tsx
/**
* Layer 4: Save as CLI Testing — "Save as CLI" Pipeline
*
* Tests the full browser init → write adapter → browser verify flow.
* Validates that browser exploration can be crystallized into reusable CLI adapters.
*
* Usage:
* npx tsx autoresearch/eval-save.ts # Run all tasks
* npx tsx autoresearch/eval-save.ts --task hn-top # Run single task
*/
import { execSync } from 'node:child_process';
import { readFileSync, writeFileSync, mkdirSync, readdirSync, existsSync, rmSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { homedir } from 'node:os';
const __dirname = dirname(fileURLToPath(import.meta.url));
const TASKS_FILE = join(__dirname, 'save-tasks.json');
const RESULTS_DIR = join(__dirname, 'results');
const USER_CLIS_DIR = join(homedir(), '.opencli', 'clis');
interface SaveTask {
name: string;
site: string;
command: string;
/** Inline adapter code (simple tasks) */
adapter?: string;
/** Path to adapter file relative to autoresearch/ dir (complex tasks — avoids JSON escape issues) */
adapterFile?: string;
judge: JudgeCriteria;
set?: 'test';
note?: string;
}
type JudgeCriteria =
| { type: 'contains'; value: string }
| { type: 'arrayMinLength'; minLength: number }
| { type: 'nonEmpty' }
| { type: 'matchesPattern'; pattern: string };
interface TaskResult {
name: string;
phase: 'init' | 'write' | 'verify' | 'judge';
passed: boolean;
duration: number;
error?: string;
set: 'train' | 'test';
}
function judge(criteria: JudgeCriteria, output: string): boolean {
try {
switch (criteria.type) {
case 'contains':
return output.toLowerCase().includes(criteria.value.toLowerCase());
case 'arrayMinLength': {
// browser verify outputs table text; try JSON parse first, then count non-empty lines
try {
const arr = JSON.parse(output);
if (Array.isArray(arr)) return arr.length >= criteria.minLength;
} catch { /* not JSON — try line counting */ }
// Table output: count data rows (skip header, separator, empty lines)
const lines = output.split('\n').filter(l => l.trim() && !l.startsWith('─') && !l.startsWith('┌') && !l.startsWith('└') && !l.startsWith('├'));
// Subtract header row
const dataLines = lines.length > 1 ? lines.length - 1 : 0;
return dataLines >= criteria.minLength;
}
case 'nonEmpty':
return output.trim().length > 0 && output.trim() !== 'null' && output.trim() !== 'undefined';
case 'matchesPattern':
return new RegExp(criteria.pattern).test(output);
default:
return false;
}
} catch {
return false;
}
}
const PROJECT_ROOT = join(__dirname, '..');
/** Run a command, using the local built entrypoint instead of global opencli for consistency */
function runCommand(cmd: string, timeout = 30000): string {
// Use local build so tests always run against the current source
const localCmd = cmd.replace(/^opencli /, `node dist/src/main.js `);
try {
return execSync(localCmd, {
cwd: PROJECT_ROOT,
timeout,
encoding: 'utf-8',
env: process.env,
stdio: ['pipe', 'pipe', 'pipe'],
}).trim();
} catch (err: any) {
return err.stdout?.trim() || err.stderr?.trim() || '';
}
}
function cleanupAdapter(site: string, command: string): void {
const siteDir = join(USER_CLIS_DIR, site);
const filePath = join(siteDir, `${command}.ts`);
try {
if (existsSync(filePath)) rmSync(filePath);
// Remove site dir if empty
if (existsSync(siteDir)) {
const remaining = readdirSync(siteDir);
if (remaining.length === 0) rmSync(siteDir, { recursive: true });
}
} catch { /* best effort */ }
}
function runTask(task: SaveTask): TaskResult {
const start = Date.now();
const { site, command } = task;
const adapterDir = join(USER_CLIS_DIR, site);
const adapterPath = join(adapterDir, `${command}.ts`);
// Cleanup any leftover from previous runs
cleanupAdapter(site, command);
try {
// Phase 1: init — create scaffold
const initOutput = runCommand(`opencli browser init ${site}/${command}`);
if (!existsSync(adapterPath)) {
return {
name: task.name, phase: 'init', passed: false,
duration: Date.now() - start,
error: `init failed: file not created. Output: ${initOutput.slice(0, 100)}`,
set: task.set === 'test' ? 'test' : 'train',
};
}
// Phase 2: write — overwrite scaffold with real adapter code
if (task.adapterFile) {
// Read from file (complex adapters — avoids JSON string escape issues)
const srcPath = join(__dirname, task.adapterFile);
const code = readFileSync(srcPath, 'utf-8');
writeFileSync(adapterPath, code, 'utf-8');
} else if (task.adapter) {
writeFileSync(adapterPath, task.adapter, 'utf-8');
}
// Phase 3: verify — run the adapter via browser verify
const verifyOutput = runCommand(
`opencli browser verify ${site}/${command}`,
45000, // longer timeout for network calls
);
if (verifyOutput.includes('✗ Adapter failed')) {
return {
name: task.name, phase: 'verify', passed: false,
duration: Date.now() - start,
error: `verify failed: ${verifyOutput.slice(0, 200)}`,
set: task.set === 'test' ? 'test' : 'train',
};
}
// Phase 4: judge — check output quality
const passed = judge(task.judge, verifyOutput);
return {
name: task.name,
phase: 'judge',
passed,
duration: Date.now() - start,
error: passed ? undefined : `Judge failed on output: ${verifyOutput.slice(0, 150)}`,
set: task.set === 'test' ? 'test' : 'train',
};
} catch (err: any) {
return {
name: task.name, phase: 'verify', passed: false,
duration: Date.now() - start,
error: err.message?.slice(0, 150),
set: task.set === 'test' ? 'test' : 'train',
};
} finally {
// Always cleanup test adapters
cleanupAdapter(site, command);
}
}
function main() {
const args = process.argv.slice(2);
const singleTask = args.includes('--task') ? args[args.indexOf('--task') + 1] : null;
const allTasks: SaveTask[] = JSON.parse(readFileSync(TASKS_FILE, 'utf-8'));
const tasks = singleTask ? allTasks.filter(t => t.name === singleTask) : allTasks;
if (tasks.length === 0) {
console.error(`Task "${singleTask}" not found.`);
process.exit(1);
}
console.log(`\n🧪 Layer 4: Save as CLI — ${tasks.length} tasks\n`);
const results: TaskResult[] = [];
for (let i = 0; i < tasks.length; i++) {
const task = tasks[i];
process.stdout.write(` [${i + 1}/${tasks.length}] ${task.name}...`);
const result = runTask(task);
results.push(result);
const icon = result.passed ? '✓' : '✗';
const phase = result.passed ? '' : ` (${result.phase})`;
console.log(` ${icon}${phase} (${(result.duration / 1000).toFixed(1)}s)`);
}
// Summary
const trainResults = results.filter(r => r.set === 'train');
const testResults = results.filter(r => r.set === 'test');
const totalPassed = results.filter(r => r.passed).length;
const trainPassed = trainResults.filter(r => r.passed).length;
const testPassed = testResults.filter(r => r.passed).length;
const totalDuration = results.reduce((s, r) => s + r.duration, 0);
console.log(`\n${'─'.repeat(50)}`);
console.log(` Score: ${totalPassed}/${results.length} (train: ${trainPassed}/${trainResults.length}, test: ${testPassed}/${testResults.length})`);
console.log(` Time: ${Math.round(totalDuration / 1000)}s`);
const failures = results.filter(r => !r.passed);
if (failures.length > 0) {
console.log(`\n Failures:`);
for (const f of failures) {
console.log(`${f.name} [${f.phase}]: ${f.error ?? 'unknown'}`);
}
}
console.log('');
// Save result
mkdirSync(RESULTS_DIR, { recursive: true });
const existing = readdirSync(RESULTS_DIR).filter(f => f.startsWith('save-')).length;
const roundNum = String(existing + 1).padStart(3, '0');
const resultPath = join(RESULTS_DIR, `save-${roundNum}.json`);
writeFileSync(resultPath, JSON.stringify({
timestamp: new Date().toISOString(),
score: `${totalPassed}/${results.length}`,
trainScore: `${trainPassed}/${trainResults.length}`,
testScore: `${testPassed}/${testResults.length}`,
duration: `${Math.round(totalDuration / 1000)}s`,
tasks: results,
}, null, 2), 'utf-8');
console.log(` Results saved to: ${resultPath}`);
console.log(`\nSCORE=${totalPassed}/${results.length}`);
}
main();
+254
View File
@@ -0,0 +1,254 @@
#!/usr/bin/env npx tsx
/**
* Layer 2: Claude Code Skill E2E Testing (LLM Judge)
*
* Spawns Claude Code with the opencli-browser skill. Claude Code
* completes the task using browse commands AND judges its own result.
*
* Task format: YAML with judge_context (multi-criteria, like Browser Use)
*
* Usage:
* npx tsx autoresearch/eval-skill.ts # Run all
* npx tsx autoresearch/eval-skill.ts --task hn-top5 # Run single
*/
import { execSync } from 'node:child_process';
import { readFileSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const RESULTS_DIR = join(__dirname, 'results');
const SKILL_PATH = join(__dirname, '..', 'skills', 'opencli-browser', 'SKILL.md');
// ── Types ──────────────────────────────────────────────────────────
interface SkillTask {
name: string;
task: string;
url?: string;
judge_context: string[];
max_steps?: number;
}
interface TaskResult {
name: string;
passed: boolean;
duration: number;
cost: number;
explanation: string;
}
// ── Task Definitions (inline, to avoid YAML dependency) ────────────
const TASKS: SkillTask[] = [
// Extract
{ name: "extract-title-example", task: "Extract the main heading text from this page", url: "https://example.com", judge_context: ["Output must contain 'Example Domain'"] },
{ name: "extract-paragraph-wiki", task: "Extract the first paragraph of the JavaScript article", url: "https://en.wikipedia.org/wiki/JavaScript", judge_context: ["Output must mention 'programming language'", "Output must contain actual paragraph text, not just the title"] },
{ name: "extract-github-stars", task: "Find the number of stars on this repository", url: "https://github.com/browser-use/browser-use", judge_context: ["Output must contain a number (the star count)"] },
{ name: "extract-npm-downloads", task: "Find the weekly download count for this package", url: "https://www.npmjs.com/package/zod", judge_context: ["Output must contain a number (weekly downloads)"] },
// List extraction
{ name: "list-hn-top5", task: "Extract the top 5 stories with their titles", url: "https://news.ycombinator.com", judge_context: ["Output must contain 5 story titles", "Each title must be an actual HN story, not made up"] },
{ name: "list-books-5", task: "Extract the first 5 books with their title and price", url: "https://books.toscrape.com", judge_context: ["Output must contain 5 books", "Each book must have a title and a price"] },
{ name: "list-quotes-3", task: "Extract the first 3 quotes with their text and author", url: "https://quotes.toscrape.com", judge_context: ["Output must contain 3 quotes", "Each quote must have text and an author name"] },
{ name: "list-github-trending", task: "Extract the top 3 trending repositories with name and description", url: "https://github.com/trending", judge_context: ["Output must contain 3 repositories", "Each must have a repo name"] },
{ name: "list-jsonplaceholder", task: "Extract the first 5 posts with their title", url: "https://jsonplaceholder.typicode.com/posts", judge_context: ["Output must contain 5 posts", "Each post must have a title"] },
// Search
{ name: "search-ddg", task: "Search for 'TypeScript tutorial' and extract the first 3 result titles", url: "https://duckduckgo.com", judge_context: ["The agent must type a search query", "Output must contain at least 3 search result titles"] },
{ name: "search-npm", task: "Search for 'react' and extract the top 3 package names", url: "https://www.npmjs.com", judge_context: ["The agent must search for 'react'", "Output must contain at least 3 package names"] },
{ name: "search-wiki", task: "Search for 'Rust programming language' and extract the first sentence of the article", url: "https://en.wikipedia.org", judge_context: ["The agent must search and navigate to the article", "Output must mention 'programming language'"] },
// Navigation
{ name: "nav-click-link", task: "Click the 'More information...' link and extract the heading of the new page", url: "https://example.com", judge_context: ["The agent must click a link", "Output must contain 'IANA' or reference the new page"] },
{ name: "nav-click-hn", task: "Click on the first story link and tell me the title of the page you land on", url: "https://news.ycombinator.com", judge_context: ["The agent must click a story link", "Output must contain the title of the destination page"] },
{ name: "nav-go-back", task: "Click the 'More information...' link, then go back, and tell me the heading of the original page", url: "https://example.com", judge_context: ["The agent must click a link then go back", "Output must contain 'Example Domain'"] },
{ name: "nav-multi-step", task: "Click the Next page link at the bottom, then extract the first quote from page 2", url: "https://quotes.toscrape.com", judge_context: ["The agent must navigate to page 2", "Output must contain a quote from page 2"] },
// Scroll
{ name: "scroll-footer", task: "Scroll to the bottom and extract the footer text", url: "https://quotes.toscrape.com", judge_context: ["The agent must scroll down", "Output must contain footer or bottom-of-page content"] },
{ name: "scroll-pagination", task: "Find the pagination info at the bottom of the page", url: "https://books.toscrape.com", judge_context: ["Output must contain page number or pagination info"] },
// Form
{ name: "form-fill-basic", task: "Fill the Customer Name with 'OpenCLI' and Telephone with '555-0100'. Do not submit.", url: "https://httpbin.org/forms/post", judge_context: ["The agent must type 'OpenCLI' into a name field", "The agent must type '555-0100' into a phone field", "The form must NOT be submitted"] },
{ name: "form-radio", task: "Select the 'Medium' pizza size option. Do not submit.", url: "https://httpbin.org/forms/post", judge_context: ["The agent must select a radio button for Medium size"] },
{ name: "form-login", task: "Fill the username with 'testuser' and password with 'testpass'. Do not submit.", url: "https://the-internet.herokuapp.com/login", judge_context: ["The agent must fill the username field", "The agent must fill the password field", "The form must NOT be submitted"] },
// Complex
{ name: "complex-wiki-toc", task: "Extract the table of contents headings", url: "https://en.wikipedia.org/wiki/JavaScript", judge_context: ["Output must contain at least 5 section headings from the table of contents"] },
{ name: "complex-books-detail", task: "Click on the first book and extract its title and price from the detail page", url: "https://books.toscrape.com", judge_context: ["The agent must click on a book", "Output must contain the book title", "Output must contain a price"] },
{ name: "complex-quotes-page2", task: "Navigate to page 2 and extract the first 3 quotes with their authors", url: "https://quotes.toscrape.com", judge_context: ["The agent must navigate to page 2", "Output must contain 3 quotes with authors"] },
{ name: "complex-multi-extract", task: "Extract both the page title and the first paragraph text", url: "https://en.wikipedia.org/wiki/TypeScript", judge_context: ["Output must contain 'TypeScript'", "Output must contain actual paragraph text"] },
// Bench (harder, real-world)
{ name: "bench-reddit", task: "Extract the titles of the top 5 posts", url: "https://old.reddit.com", judge_context: ["Output must contain 5 post titles", "Titles must be actual Reddit posts"] },
{ name: "bench-imdb", task: "Find the year and rating of The Matrix", url: "https://www.imdb.com/title/tt0133093/", judge_context: ["Output must contain '1999'", "Output must contain a rating number"] },
{ name: "bench-github-profile", task: "Extract the bio and number of public repositories", url: "https://github.com/torvalds", judge_context: ["Output must contain bio text or 'Linux'", "Output must contain a number for repos"] },
{ name: "bench-httpbin", task: "Extract the User-Agent header shown on this page", url: "https://httpbin.org/headers", judge_context: ["Output must contain a User-Agent string"] },
{ name: "bench-jsonapi-todo", task: "Extract the first 5 todo items with their title and completion status", url: "https://jsonplaceholder.typicode.com/todos", judge_context: ["Output must contain 5 todo items", "Each must have a title and completed status"] },
// Codex form (the real test)
{ name: "codex-form-fill", task: "Fill the basic information using 'opencli' as the identity (first name=open, last name=cli, email=opencli@example.com, GitHub username=opencli). Do NOT submit the form.", url: "https://openai.com/form/codex-for-oss/", judge_context: ["The agent must fill the first name field", "The agent must fill the last name field", "The agent must fill the email field", "The form must NOT be submitted"], max_steps: 15 },
];
// ── Run Task ───────────────────────────────────────────────────────
function runSkillTask(task: SkillTask): TaskResult {
const start = Date.now();
const skillContent = readFileSync(SKILL_PATH, 'utf-8');
const urlPart = task.url ? ` Start URL: ${task.url}` : '';
const criteria = task.judge_context.map((c, i) => `${i + 1}. ${c}`).join('\n');
const prompt = `Complete this browser task using opencli browser commands:
TASK: ${task.task}${urlPart}
After completing the task, evaluate your own result against these criteria:
${criteria}
At the very end of your response, output a JSON verdict on its own line:
{"success": true/false, "explanation": "brief explanation"}
Always close the browser with 'opencli browser close' when done.`;
try {
const output = execSync(
`claude -p --dangerously-skip-permissions --allowedTools "Bash(opencli:*)" --system-prompt ${JSON.stringify(skillContent)} --output-format json --no-session-persistence ${JSON.stringify(prompt)}`,
{
cwd: join(__dirname, '..'),
timeout: (task.max_steps ?? 10) * 15_000,
encoding: 'utf-8',
env: process.env,
stdio: ['pipe', 'pipe', 'pipe'],
}
);
const duration = Date.now() - start;
// Parse Claude Code output
let resultText = '';
let cost = 0;
try {
const parsed = JSON.parse(output);
resultText = parsed.result ?? output;
cost = parsed.total_cost_usd ?? 0;
} catch {
resultText = output;
}
// Extract verdict JSON from the result
const verdict = extractVerdict(resultText);
return {
name: task.name,
passed: verdict.success,
duration,
cost,
explanation: verdict.explanation,
};
} catch (err: any) {
return {
name: task.name,
passed: false,
duration: Date.now() - start,
cost: 0,
explanation: (err.stdout ?? err.message ?? 'timeout or crash').slice(0, 200),
};
}
}
function extractVerdict(text: string): { success: boolean; explanation: string } {
// Try to find and parse {"success": ...} JSON from the last occurrence
const idx = text.lastIndexOf('{"success"');
if (idx !== -1) {
// Find the matching closing brace (handle escaped quotes in explanation)
const sub = text.slice(idx);
let braceCount = 0;
let end = -1;
for (let i = 0; i < sub.length; i++) {
if (sub[i] === '{') braceCount++;
else if (sub[i] === '}') { braceCount--; if (braceCount === 0) { end = i + 1; break; } }
}
if (end > 0) {
try { return JSON.parse(sub.slice(0, end)); } catch { /* fall through */ }
}
}
// Fallback: check for success indicators in text
const lower = text.toLowerCase();
if (lower.includes('"success": true') || lower.includes('"success":true')) {
return { success: true, explanation: 'Parsed success from output' };
}
if (lower.includes('"success": false') || lower.includes('"success":false')) {
return { success: false, explanation: 'Parsed failure from output' };
}
// Final fallback: assume failure if we can't parse
return { success: false, explanation: 'Could not parse verdict from output' };
}
// ── Main ───────────────────────────────────────────────────────────
function main() {
const args = process.argv.slice(2);
const singleTask = args.includes('--task') ? args[args.indexOf('--task') + 1] : null;
const tasks = singleTask ? TASKS.filter(t => t.name === singleTask) : TASKS;
if (tasks.length === 0) {
console.error(`Task "${singleTask}" not found. Available: ${TASKS.map(t => t.name).join(', ')}`);
process.exit(1);
}
console.log(`\n🔬 Layer 2: Skill E2E (LLM Judge) — ${tasks.length} tasks\n`);
const results: TaskResult[] = [];
for (let i = 0; i < tasks.length; i++) {
const task = tasks[i];
process.stdout.write(` [${i + 1}/${tasks.length}] ${task.name}...`);
const result = runSkillTask(task);
results.push(result);
const icon = result.passed ? '✓' : '✗';
const costStr = result.cost > 0 ? `, $${result.cost.toFixed(2)}` : '';
console.log(` ${icon} (${Math.round(result.duration / 1000)}s${costStr})`);
}
// Summary
const totalPassed = results.filter(r => r.passed).length;
const totalCost = results.reduce((s, r) => s + r.cost, 0);
const totalDuration = results.reduce((s, r) => s + r.duration, 0);
console.log(`\n${'─'.repeat(50)}`);
console.log(` Score: ${totalPassed}/${results.length} (${Math.round(totalPassed / results.length * 100)}%)`);
console.log(` Cost: $${totalCost.toFixed(2)}`);
console.log(` Time: ${Math.round(totalDuration / 60000)}min`);
const failures = results.filter(r => !r.passed);
if (failures.length > 0) {
console.log(`\n Failures:`);
for (const f of failures) {
console.log(`${f.name}: ${f.explanation}`);
}
}
console.log('');
// Save
mkdirSync(RESULTS_DIR, { recursive: true });
const existing = readdirSync(RESULTS_DIR).filter(f => f.startsWith('skill-')).length;
const roundNum = String(existing + 1).padStart(3, '0');
const resultPath = join(RESULTS_DIR, `skill-${roundNum}.json`);
writeFileSync(resultPath, JSON.stringify({
timestamp: new Date().toISOString(),
score: `${totalPassed}/${results.length}`,
totalCost,
duration: `${Math.round(totalDuration / 60000)}min`,
tasks: results,
}, null, 2), 'utf-8');
console.log(` Results saved to: ${resultPath}`);
console.log(`\nSCORE=${totalPassed}/${results.length}`);
}
main();
+220
View File
@@ -0,0 +1,220 @@
#!/usr/bin/env npx tsx
/**
* V2EX Test Suite: Deterministic command testing against v2ex.com.
*
* 40 tasks across 5 difficulty layers:
* L1 Atomic (10) → L2 Single Page (10) → L3 Multi-Step (10)
* → L4 Write Ops (5) → L5 Complex Chain (5)
*
* Usage:
* npx tsx autoresearch/eval-v2ex.ts # Run all tasks
* npx tsx autoresearch/eval-v2ex.ts --task v2ex-hot-topics # Run single task
* npx tsx autoresearch/eval-v2ex.ts --layer 1 # Run only Layer 1 (atomic)
*/
import { execSync } from 'node:child_process';
import { readFileSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const TASKS_FILE = join(__dirname, 'v2ex-tasks.json');
const RESULTS_DIR = join(__dirname, 'results');
interface BrowseTask {
name: string;
steps: string[];
judge: JudgeCriteria;
set?: 'test';
note?: string;
_comment?: string;
}
type JudgeCriteria =
| { type: 'contains'; value: string }
| { type: 'arrayMinLength'; minLength: number }
| { type: 'nonEmpty' }
| { type: 'matchesPattern'; pattern: string };
interface TaskResult {
name: string;
passed: boolean;
duration: number;
error?: string;
layer: string;
}
// Layer classification by task name prefix pattern
function getLayer(name: string): string {
if (['v2ex-open-', 'v2ex-state-', 'v2ex-get-title', 'v2ex-click-tab', 'v2ex-scroll-down',
'v2ex-get-first-', 'v2ex-eval-extract', 'v2ex-get-url', 'v2ex-back-nav', 'v2ex-wait-'].some(p => name.startsWith(p)))
return 'L1-atomic';
if (['v2ex-hot-topics', 'v2ex-node-list', 'v2ex-topic-meta', 'v2ex-node-topics',
'v2ex-node-pagination', 'v2ex-tab-content', 'v2ex-topic-replies-extract',
'v2ex-topic-reply-count', 'v2ex-member-info', 'v2ex-search-results'].includes(name))
return 'L2-single-page';
if (['v2ex-click-topic-read', 'v2ex-click-author', 'v2ex-navigate-node', 'v2ex-pagination-page2',
'v2ex-topic-and-back', 'v2ex-tab-then-topic', 'v2ex-scroll-find-more',
'v2ex-node-to-topic', 'v2ex-multi-tab-compare', 'v2ex-topic-reply-to-author'].some(p => name.startsWith(p)))
return 'L3-multi-step';
if (['v2ex-reply-', 'v2ex-favorite-', 'v2ex-thank-', 'v2ex-create-'].some(p => name.startsWith(p)))
return 'L4-write';
if (['v2ex-collect-', 'v2ex-multi-node-', 'v2ex-topic-deep-', 'v2ex-cross-page-', 'v2ex-full-'].some(p => name.startsWith(p)))
return 'L5-complex';
return 'unknown';
}
function judge(criteria: JudgeCriteria, output: string): boolean {
try {
switch (criteria.type) {
case 'contains':
return output.toLowerCase().includes(criteria.value.toLowerCase());
case 'arrayMinLength': {
try {
const arr = JSON.parse(output);
if (Array.isArray(arr)) return arr.length >= criteria.minLength;
} catch { /* not JSON array */ }
return false;
}
case 'nonEmpty':
return output.trim().length > 0 && output.trim() !== 'null' && output.trim() !== 'undefined';
case 'matchesPattern':
return new RegExp(criteria.pattern).test(output);
default:
return false;
}
} catch {
return false;
}
}
function runCommand(cmd: string, timeout = 30000): string {
try {
return execSync(cmd, {
cwd: join(__dirname, '..'),
timeout,
encoding: 'utf-8',
env: process.env,
stdio: ['pipe', 'pipe', 'pipe'],
}).trim();
} catch (err: any) {
return err.stdout?.trim() ?? '';
}
}
function runTask(task: BrowseTask): TaskResult {
const start = Date.now();
let lastOutput = '';
try {
for (const step of task.steps) {
lastOutput = runCommand(step);
}
const passed = judge(task.judge, lastOutput);
return {
name: task.name,
passed,
duration: Date.now() - start,
error: passed ? undefined : `Output: ${lastOutput.slice(0, 150)}`,
layer: getLayer(task.name),
};
} catch (err: any) {
return {
name: task.name,
passed: false,
duration: Date.now() - start,
error: err.message?.slice(0, 100),
layer: getLayer(task.name),
};
}
}
function main() {
const args = process.argv.slice(2);
const singleTask = args.includes('--task') ? args[args.indexOf('--task') + 1] : null;
const layerFilter = args.includes('--layer') ? args[args.indexOf('--layer') + 1] : null;
const raw = JSON.parse(readFileSync(TASKS_FILE, 'utf-8')) as (BrowseTask | { _comment: string })[];
const allTasks = raw.filter((t): t is BrowseTask => 'name' in t && 'steps' in t);
let tasks = allTasks;
if (singleTask) {
tasks = allTasks.filter(t => t.name === singleTask);
} else if (layerFilter) {
const prefix = `L${layerFilter}`;
tasks = allTasks.filter(t => getLayer(t.name).startsWith(prefix));
}
if (tasks.length === 0) {
console.error(singleTask ? `Task "${singleTask}" not found.` : `No tasks for layer ${layerFilter}.`);
process.exit(1);
}
console.log(`\n🔬 V2EX Test Suite — ${tasks.length} tasks\n`);
const results: TaskResult[] = [];
for (let i = 0; i < tasks.length; i++) {
const task = tasks[i];
process.stdout.write(` [${i + 1}/${tasks.length}] ${task.name}...`);
const result = runTask(task);
results.push(result);
const icon = result.passed ? '✓' : '✗';
console.log(` ${icon} (${(result.duration / 1000).toFixed(1)}s)`);
// Close browser between tasks for clean state
if (i < tasks.length - 1) {
try { runCommand('opencli browser close'); } catch { /* ignore */ }
}
}
// Final close
try { runCommand('opencli browser close'); } catch { /* ignore */ }
// Summary by layer
const layers = [...new Set(results.map(r => r.layer))].sort();
const totalPassed = results.filter(r => r.passed).length;
const totalDuration = results.reduce((s, r) => s + r.duration, 0);
console.log(`\n${'─'.repeat(50)}`);
console.log(` Total: ${totalPassed}/${results.length}`);
for (const layer of layers) {
const layerResults = results.filter(r => r.layer === layer);
const layerPassed = layerResults.filter(r => r.passed).length;
console.log(` ${layer}: ${layerPassed}/${layerResults.length}`);
}
console.log(` Time: ${Math.round(totalDuration / 60000)}min`);
const failures = results.filter(r => !r.passed);
if (failures.length > 0) {
console.log(`\n Failures:`);
for (const f of failures) {
console.log(` ✗ [${f.layer}] ${f.name}: ${f.error ?? 'unknown'}`);
}
}
console.log('');
// Save result
mkdirSync(RESULTS_DIR, { recursive: true });
const existing = readdirSync(RESULTS_DIR).filter(f => f.startsWith('v2ex-')).length;
const roundNum = String(existing + 1).padStart(3, '0');
const resultPath = join(RESULTS_DIR, `v2ex-${roundNum}.json`);
writeFileSync(resultPath, JSON.stringify({
timestamp: new Date().toISOString(),
score: `${totalPassed}/${results.length}`,
layers: Object.fromEntries(layers.map(l => {
const lr = results.filter(r => r.layer === l);
return [l, `${lr.filter(r => r.passed).length}/${lr.length}`];
})),
duration: `${Math.round(totalDuration / 60000)}min`,
tasks: results,
}, null, 2), 'utf-8');
console.log(` Results saved to: ${resultPath}`);
console.log(`\nSCORE=${totalPassed}/${results.length}`);
}
main();
+230
View File
@@ -0,0 +1,230 @@
#!/usr/bin/env npx tsx
/**
* Zhihu Test Suite: Deterministic command testing against v2ex.com.
*
* 40 tasks across 5 difficulty layers:
* L1 Atomic (10) → L2 Single Page (10) → L3 Multi-Step (10)
* → L4 Write Ops (5) → L5 Complex Chain (5)
*
* Usage:
* npx tsx autoresearch/eval-v2ex.ts # Run all tasks
* npx tsx autoresearch/eval-v2ex.ts --task zhihu-hot-topics # Run single task
* npx tsx autoresearch/eval-v2ex.ts --layer 1 # Run only Layer 1 (atomic)
*/
import { execSync } from 'node:child_process';
import { readFileSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const TASKS_FILE = join(__dirname, 'zhihu-tasks.json');
const RESULTS_DIR = join(__dirname, 'results');
interface BrowseTask {
name: string;
steps: string[];
judge: JudgeCriteria;
set?: 'test';
note?: string;
_comment?: string;
}
type JudgeCriteria =
| { type: 'contains'; value: string }
| { type: 'arrayMinLength'; minLength: number }
| { type: 'nonEmpty' }
| { type: 'matchesPattern'; pattern: string };
interface TaskResult {
name: string;
passed: boolean;
duration: number;
error?: string;
layer: string;
}
// Layer classification by task name
function getLayer(name: string): string {
const l1 = ['zhihu-open-home', 'zhihu-get-title', 'zhihu-state', 'zhihu-get-url', 'zhihu-scroll-down',
'zhihu-click-tab-hot', 'zhihu-back-navigation', 'zhihu-wait-page-load', 'zhihu-keys-escape', 'zhihu-screenshot'];
const l2 = ['zhihu-feed-titles', 'zhihu-hot-list', 'zhihu-hot-metrics', 'zhihu-nav-tabs',
'zhihu-feed-with-authors', 'zhihu-feed-types', 'zhihu-user-avatar', 'zhihu-search-input-exists'];
const l3 = ['zhihu-question-title', 'zhihu-question-meta', 'zhihu-first-answer', 'zhihu-answer-votes',
'zhihu-question-buttons', 'zhihu-multiple-answers', 'zhihu-question-description', 'zhihu-answer-count-number'];
const l4 = ['zhihu-hot-to-question', 'zhihu-feed-to-question', 'zhihu-question-to-author',
'zhihu-search-navigate', 'zhihu-topic-page', 'zhihu-user-profile', 'zhihu-question-and-back', 'zhihu-scroll-load-more'];
const l5 = ['zhihu-upvote-button-find', 'zhihu-follow-question-find', 'zhihu-comment-button-find',
'zhihu-bookmark-find', 'zhihu-write-answer-btn', 'zhihu-share-find'];
const l6 = ['zhihu-hot-read-answer-author', 'zhihu-hot-to-author-profile', 'zhihu-multi-hot-topics',
'zhihu-search-then-read', 'zhihu-question-scroll-answers', 'zhihu-compare-tabs', 'zhihu-user-answers', 'zhihu-topic-questions'];
const l7 = ['zhihu-search-basic', 'zhihu-search-people', 'zhihu-search-topic',
'zhihu-search-click-result', 'zhihu-search-filter-answers', 'zhihu-search-and-back'];
const l8 = ['zhihu-full-browse-workflow', 'zhihu-deep-author-chain', 'zhihu-cross-question-compare',
'zhihu-search-read-chain', 'zhihu-3-page-chain', 'zhihu-hot-scroll-deep-read'];
if (l1.includes(name)) return 'L1-atomic';
if (l2.includes(name)) return 'L2-feed';
if (l3.includes(name)) return 'L3-question';
if (l4.includes(name)) return 'L4-navigation';
if (l5.includes(name)) return 'L5-write';
if (l6.includes(name)) return 'L6-chain';
if (l7.includes(name)) return 'L7-search';
if (l8.includes(name)) return 'L8-complex';
return 'unknown';
}
function judge(criteria: JudgeCriteria, output: string): boolean {
try {
switch (criteria.type) {
case 'contains':
return output.toLowerCase().includes(criteria.value.toLowerCase());
case 'arrayMinLength': {
try {
const arr = JSON.parse(output);
if (Array.isArray(arr)) return arr.length >= criteria.minLength;
} catch { /* not JSON array */ }
return false;
}
case 'nonEmpty':
return output.trim().length > 0 && output.trim() !== 'null' && output.trim() !== 'undefined';
case 'matchesPattern':
return new RegExp(criteria.pattern).test(output);
default:
return false;
}
} catch {
return false;
}
}
function runCommand(cmd: string, timeout = 30000): string {
try {
return execSync(cmd, {
cwd: join(__dirname, '..'),
timeout,
encoding: 'utf-8',
env: process.env,
stdio: ['pipe', 'pipe', 'pipe'],
}).trim();
} catch (err: any) {
return err.stdout?.trim() ?? '';
}
}
function runTask(task: BrowseTask): TaskResult {
const start = Date.now();
let lastOutput = '';
try {
for (const step of task.steps) {
lastOutput = runCommand(step);
}
const passed = judge(task.judge, lastOutput);
return {
name: task.name,
passed,
duration: Date.now() - start,
error: passed ? undefined : `Output: ${lastOutput.slice(0, 150)}`,
layer: getLayer(task.name),
};
} catch (err: any) {
return {
name: task.name,
passed: false,
duration: Date.now() - start,
error: err.message?.slice(0, 100),
layer: getLayer(task.name),
};
}
}
function main() {
const args = process.argv.slice(2);
const singleTask = args.includes('--task') ? args[args.indexOf('--task') + 1] : null;
const layerFilter = args.includes('--layer') ? args[args.indexOf('--layer') + 1] : null;
const raw = JSON.parse(readFileSync(TASKS_FILE, 'utf-8')) as (BrowseTask | { _comment: string })[];
const allTasks = raw.filter((t): t is BrowseTask => 'name' in t && 'steps' in t);
let tasks = allTasks;
if (singleTask) {
tasks = allTasks.filter(t => t.name === singleTask);
} else if (layerFilter) {
const prefix = `L${layerFilter}`;
tasks = allTasks.filter(t => getLayer(t.name).startsWith(prefix));
}
if (tasks.length === 0) {
console.error(singleTask ? `Task "${singleTask}" not found.` : `No tasks for layer ${layerFilter}.`);
process.exit(1);
}
console.log(`\n🔬 Zhihu Test Suite — ${tasks.length} tasks\n`);
const results: TaskResult[] = [];
for (let i = 0; i < tasks.length; i++) {
const task = tasks[i];
process.stdout.write(` [${i + 1}/${tasks.length}] ${task.name}...`);
const result = runTask(task);
results.push(result);
const icon = result.passed ? '✓' : '✗';
console.log(` ${icon} (${(result.duration / 1000).toFixed(1)}s)`);
// Close browser between tasks for clean state
if (i < tasks.length - 1) {
try { runCommand('opencli browser close'); } catch { /* ignore */ }
}
}
// Final close
try { runCommand('opencli browser close'); } catch { /* ignore */ }
// Summary by layer
const layers = [...new Set(results.map(r => r.layer))].sort();
const totalPassed = results.filter(r => r.passed).length;
const totalDuration = results.reduce((s, r) => s + r.duration, 0);
console.log(`\n${'─'.repeat(50)}`);
console.log(` Total: ${totalPassed}/${results.length}`);
for (const layer of layers) {
const layerResults = results.filter(r => r.layer === layer);
const layerPassed = layerResults.filter(r => r.passed).length;
console.log(` ${layer}: ${layerPassed}/${layerResults.length}`);
}
console.log(` Time: ${Math.round(totalDuration / 60000)}min`);
const failures = results.filter(r => !r.passed);
if (failures.length > 0) {
console.log(`\n Failures:`);
for (const f of failures) {
console.log(` ✗ [${f.layer}] ${f.name}: ${f.error ?? 'unknown'}`);
}
}
console.log('');
// Save result
mkdirSync(RESULTS_DIR, { recursive: true });
const existing = readdirSync(RESULTS_DIR).filter(f => f.startsWith('zhihu-')).length;
const roundNum = String(existing + 1).padStart(3, '0');
const resultPath = join(RESULTS_DIR, `zhihu-${roundNum}.json`);
writeFileSync(resultPath, JSON.stringify({
timestamp: new Date().toISOString(),
score: `${totalPassed}/${results.length}`,
layers: Object.fromEntries(layers.map(l => {
const lr = results.filter(r => r.layer === l);
return [l, `${lr.filter(r => r.passed).length}/${lr.length}`];
})),
duration: `${Math.round(totalDuration / 60000)}min`,
tasks: results,
}, null, 2), 'utf-8');
console.log(` Results saved to: ${resultPath}`);
console.log(`\nSCORE=${totalPassed}/${results.length}`);
}
main();
+69
View File
@@ -0,0 +1,69 @@
/**
* AutoResearch TSV Logger — append-only results log with metadata header.
*/
import { writeFileSync, readFileSync, existsSync, appendFileSync } from 'node:fs';
import type { AutoResearchConfig, IterationResult } from './config.js';
const COLUMNS = ['iteration', 'commit', 'metric', 'delta', 'guard', 'status', 'description'];
export class Logger {
constructor(private path: string) {}
/** Create the TSV file with metadata header */
init(config: AutoResearchConfig): void {
const header = [
`# metric_direction: ${config.direction === 'higher' ? 'higher_is_better' : 'lower_is_better'}`,
`# goal: ${config.goal}`,
`# scope: ${config.scope.join(', ')}`,
`# verify: ${config.verify}`,
config.guard ? `# guard: ${config.guard}` : null,
COLUMNS.join('\t'),
].filter(Boolean).join('\n');
writeFileSync(this.path, header + '\n', 'utf-8');
}
/** Append one iteration result */
append(result: IterationResult): void {
const row = [
result.iteration,
result.commit,
result.metric,
result.delta >= 0 ? `+${result.delta}` : result.delta,
result.guard,
result.status,
result.description,
].join('\t');
appendFileSync(this.path, row + '\n', 'utf-8');
}
/** Read last N entries for pattern recognition */
readLast(n: number): IterationResult[] {
if (!existsSync(this.path)) return [];
const lines = readFileSync(this.path, 'utf-8').split('\n')
.filter(l => l && !l.startsWith('#') && !l.startsWith('iteration'));
return lines.slice(-n).map(line => {
const [iteration, commit, metric, delta, guard, status, ...desc] = line.split('\t');
return {
iteration: parseInt(iteration, 10),
commit,
metric: parseFloat(metric),
delta: parseFloat(delta),
guard: guard as 'pass' | 'fail' | '-',
status: status as IterationResult['status'],
description: desc.join('\t'),
};
});
}
/** Count consecutive discards from the end */
consecutiveDiscards(): number {
const entries = this.readLast(20);
let count = 0;
for (let i = entries.length - 1; i >= 0; i--) {
if (entries[i].status === 'discard') count++;
else break;
}
return count;
}
}
@@ -0,0 +1,24 @@
/**
* Preset: Browser Command Reliability
*
* Optimizes opencli browser commands against the Layer 1 deterministic test suite.
* Metric: number of passing browse-tasks (out of 59).
*/
import type { AutoResearchConfig } from '../config.js';
export const browserReliability: AutoResearchConfig = {
goal: 'Increase browser command pass rate to 59/59 (100%)',
scope: [
'src/browser/dom-snapshot.ts',
'src/browser/dom-helpers.ts',
'src/browser/base-page.ts',
'src/browser/page.ts',
'src/cli.ts',
],
metric: 'pass_count',
direction: 'higher',
verify: 'npx tsx autoresearch/eval-browse.ts 2>&1 | tail -1',
guard: 'npm run build',
minDelta: 1,
};
@@ -0,0 +1,27 @@
/**
* Preset: Combined Reliability (browse + V2EX + Zhihu)
*
* Optimizes across ALL test suites simultaneously.
* Current baseline: 57/59 + 60/60 + 60/60 = 177/179
* Target: 179/179 (100%)
*/
import type { AutoResearchConfig } from '../config.js';
export const combinedReliability: AutoResearchConfig = {
goal: 'Fix all remaining test failures across browse + V2EX + Zhihu (177/179 → 179/179)',
scope: [
'src/browser/dom-snapshot.ts',
'src/browser/dom-helpers.ts',
'src/browser/base-page.ts',
'src/browser/page.ts',
'src/cli.ts',
'autoresearch/browse-tasks.json',
],
metric: 'pass_count',
direction: 'higher',
verify: 'npx tsx autoresearch/eval-all.ts 2>&1 | tail -1',
guard: 'npm run build',
iterations: 10,
minDelta: 1,
};
+23
View File
@@ -0,0 +1,23 @@
export { browserReliability } from './browser-reliability.js';
export { skillQuality } from './skill-quality.js';
export { v2exReliability } from './v2ex-reliability.js';
export { zhihuReliability } from './zhihu-reliability.js';
export { combinedReliability } from './combined-reliability.js';
export { saveReliability } from './save-reliability.js';
import type { AutoResearchConfig } from '../config.js';
import { browserReliability } from './browser-reliability.js';
import { skillQuality } from './skill-quality.js';
import { v2exReliability } from './v2ex-reliability.js';
import { zhihuReliability } from './zhihu-reliability.js';
import { combinedReliability } from './combined-reliability.js';
import { saveReliability } from './save-reliability.js';
export const PRESETS: Record<string, AutoResearchConfig> = {
'browser-reliability': browserReliability,
'skill-quality': skillQuality,
'v2ex-reliability': v2exReliability,
'zhihu-reliability': zhihuReliability,
'combined': combinedReliability,
'save-reliability': saveReliability,
};
+26
View File
@@ -0,0 +1,26 @@
/**
* Preset: Save as CLI Reliability
*
* Optimizes the "Save as CLI" pipeline: browser init → write adapter → run.
* Covers PUBLIC (no auth) and COOKIE (browser session) strategies.
* Metric: number of passing save-tasks.
*/
import type { AutoResearchConfig } from '../config.js';
export const saveReliability: AutoResearchConfig = {
goal: 'Increase "Save as CLI" pipeline pass rate to 100%. The flow is: browser init creates a scaffold, user writes adapter code, opencli discovers and runs it. Covers both PUBLIC (fetch API) and COOKIE (browser session) strategies. Focus on: init template correctness, user CLI discovery, adapter loading, verify command robustness, and browser session handling.',
scope: [
'src/cli.ts',
'src/discovery.ts',
'src/registry.ts',
'skills/opencli-browser/SKILL.md',
'autoresearch/save-tasks.json',
'autoresearch/save-adapters/*.ts',
],
metric: 'pass_count',
direction: 'higher',
verify: 'npx tsx autoresearch/eval-save.ts 2>&1 | tail -1',
guard: 'npm run build',
minDelta: 1,
};
+20
View File
@@ -0,0 +1,20 @@
/**
* Preset: Skill E2E Quality
*
* Optimizes the opencli-browser SKILL.md against the Layer 2 LLM E2E test suite.
* Metric: number of passing skill-tasks (out of 35).
*/
import type { AutoResearchConfig } from '../config.js';
export const skillQuality: AutoResearchConfig = {
goal: 'Increase skill E2E pass rate to 35/35 (100%)',
scope: [
'skills/opencli-browser/SKILL.md',
],
metric: 'pass_count',
direction: 'higher',
verify: 'npx tsx autoresearch/eval-skill.ts 2>&1 | tail -1',
guard: 'npm run build',
iterations: 20,
};
+24
View File
@@ -0,0 +1,24 @@
/**
* Preset: V2EX Command Reliability
*
* Optimizes opencli browser commands against the V2EX-specific test suite.
* 40 tasks across 5 difficulty layers (atomic → complex chain).
*/
import type { AutoResearchConfig } from '../config.js';
export const v2exReliability: AutoResearchConfig = {
goal: 'Increase V2EX browser command pass rate to 40/40 (100%)',
scope: [
'src/browser/dom-snapshot.ts',
'src/browser/dom-helpers.ts',
'src/browser/base-page.ts',
'src/browser/page.ts',
'src/cli.ts',
],
metric: 'pass_count',
direction: 'higher',
verify: 'npx tsx autoresearch/eval-v2ex.ts 2>&1 | tail -1',
guard: 'npm run build',
minDelta: 1,
};
+25
View File
@@ -0,0 +1,25 @@
/**
* Preset: Zhihu Command Reliability
*
* Optimizes opencli browser commands against the Zhihu test suite.
* 60 tasks across 8 difficulty layers (atomic → complex long chain).
* Zhihu is a React SPA with lazy loading, making it harder than V2EX.
*/
import type { AutoResearchConfig } from '../config.js';
export const zhihuReliability: AutoResearchConfig = {
goal: 'Increase Zhihu browser command pass rate to 60/60 (100%)',
scope: [
'src/browser/dom-snapshot.ts',
'src/browser/dom-helpers.ts',
'src/browser/base-page.ts',
'src/browser/page.ts',
'src/cli.ts',
],
metric: 'pass_count',
direction: 'higher',
verify: 'npx tsx autoresearch/eval-zhihu.ts 2>&1 | tail -1',
guard: 'npm run build',
minDelta: 1,
};
+345
View File
@@ -0,0 +1,345 @@
[
{
"name": "twitter-fill-compose",
"platform": "twitter",
"type": "fill-only",
"description": "Navigate to tweet composer, fill in content (no publish)",
"steps": [
"opencli browser open https://x.com/compose/tweet",
"opencli browser wait time 3",
"opencli browser eval \"document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]') ? 'composer-ready' : 'not-found'\"",
"opencli browser eval \"(() => { const box = document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]'); if (!box) return 'no-box'; box.focus(); const dt = new DataTransfer(); dt.setData('text/plain', '[AutoTest] OpenCLI publish eval - fill only test ' + Date.now()); box.dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true })); return 'filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]')?.textContent || ''\""
],
"judge": {
"type": "contains",
"value": "AutoTest"
},
"note": "3-step: open compose → paste text via ClipboardEvent → verify text in composer"
},
{
"name": "twitter-post-and-delete",
"platform": "twitter",
"type": "publish",
"description": "Post a tweet, verify success, then delete it",
"steps": [
"opencli browser open https://x.com/compose/tweet",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const box = document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]'); if (!box) return 'no-box'; box.focus(); const dt = new DataTransfer(); dt.setData('text/plain', '[AutoTest] OpenCLI publish eval ' + Date.now()); box.dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true })); return 'filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const btn = document.querySelector('[data-testid=\\\"tweetButton\\\"]') || document.querySelector('[data-testid=\\\"tweetButtonInline\\\"]'); if (btn && !btn.disabled) { btn.click(); return 'clicked'; } return 'btn-not-ready'; })()\"",
"opencli browser wait time 4",
"opencli browser eval \"document.querySelector('[data-testid=\\\"toast\\\"]')?.textContent || document.title\""
],
"judge": {
"type": "matchesPattern",
"pattern": "post|sent|Your post|X"
},
"cleanup": [
"opencli browser open https://x.com/home",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const tweets = document.querySelectorAll('[data-testid=\\\"tweet\\\"]'); for (const t of tweets) { if (t.textContent?.includes('[AutoTest]')) { const more = t.querySelector('[data-testid=\\\"caret\\\"]'); if (more) { more.click(); return 'found-menu'; } } } return 'no-autotest-tweet'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const items = document.querySelectorAll('[role=\\\"menuitem\\\"]'); for (const item of items) { if (item.textContent?.includes('Delete')) { item.click(); return 'clicked-delete'; } } return 'no-delete-option'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const confirm = document.querySelector('[data-testid=\\\"confirmationSheetConfirm\\\"]'); if (confirm) { confirm.click(); return 'deleted'; } return 'no-confirm'; })()\""
],
"note": "6-step chain: open compose → paste text → click post → wait → verify toast → cleanup: find tweet → menu → delete → confirm"
},
{
"name": "twitter-read-hn-then-post",
"platform": "twitter",
"type": "publish",
"description": "Read HN top story title, compose a tweet about it, post, then delete",
"steps": [
"opencli browser open https://news.ycombinator.com",
"opencli browser wait time 2",
"opencli browser eval \"document.querySelector('.titleline a')?.textContent?.trim() || 'no-title'\"",
"opencli browser open https://x.com/compose/tweet",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const box = document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]'); if (!box) return 'no-box'; box.focus(); const title = document.title || 'HN Story'; const dt = new DataTransfer(); dt.setData('text/plain', '[AutoTest] Interesting from HN: ' + Date.now()); box.dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true })); return 'filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const btn = document.querySelector('[data-testid=\\\"tweetButton\\\"]') || document.querySelector('[data-testid=\\\"tweetButtonInline\\\"]'); if (btn && !btn.disabled) { btn.click(); return 'clicked'; } return 'btn-not-ready'; })()\"",
"opencli browser wait time 4",
"opencli browser eval \"document.querySelector('[data-testid=\\\"toast\\\"]')?.textContent || document.title\""
],
"judge": {
"type": "matchesPattern",
"pattern": "post|sent|Your post|X"
},
"cleanup": [
"opencli browser open https://x.com/home",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const tweets = document.querySelectorAll('[data-testid=\\\"tweet\\\"]'); for (const t of tweets) { if (t.textContent?.includes('[AutoTest]')) { const more = t.querySelector('[data-testid=\\\"caret\\\"]'); if (more) { more.click(); return 'found-menu'; } } } return 'no-autotest-tweet'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const items = document.querySelectorAll('[role=\\\"menuitem\\\"]'); for (const item of items) { if (item.textContent?.includes('Delete')) { item.click(); return 'clicked-delete'; } } return 'no-delete-option'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const confirm = document.querySelector('[data-testid=\\\"confirmationSheetConfirm\\\"]'); if (confirm) { confirm.click(); return 'deleted'; } return 'no-confirm'; })()\""
],
"note": "9-step cross-site chain: read HN title → navigate to twitter compose → paste content → post → verify → cleanup delete"
},
{
"name": "twitter-reply-to-own-tweet",
"platform": "twitter",
"type": "fill-only",
"description": "Navigate to own profile, find latest tweet, open reply box, fill reply text",
"steps": [
"opencli browser open https://x.com/home",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const tweet = document.querySelector('[data-testid=\\\"tweet\\\"]'); if (!tweet) return 'no-tweet'; const reply = tweet.querySelector('[data-testid=\\\"reply\\\"]'); if (reply) { reply.click(); return 'reply-clicked'; } return 'no-reply-btn'; })()\"",
"opencli browser wait time 2",
"opencli browser eval \"(() => { const box = document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]'); if (!box) return 'no-box'; box.focus(); const dt = new DataTransfer(); dt.setData('text/plain', '[AutoTest] Reply test ' + Date.now()); box.dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true })); return 'filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]')?.textContent || ''\""
],
"judge": {
"type": "contains",
"value": "AutoTest"
},
"note": "5-step: home → find first tweet → click reply → fill reply text → verify content"
},
{
"name": "zhihu-fill-answer",
"platform": "zhihu",
"type": "fill-only",
"description": "Navigate to a popular question, open answer editor, fill in answer content (no publish)",
"steps": [
"opencli browser open https://www.zhihu.com/question/19550225",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const btn = document.querySelector('[data-zop-retarget=\\\"answer\\\"]') || Array.from(document.querySelectorAll('button')).find(b => b.textContent?.includes('写回答')); if (btn) { btn.click(); return 'editor-opened'; } return 'no-answer-btn'; })()\"",
"opencli browser wait time 2",
"opencli browser eval \"(() => { const editor = document.querySelector('.ql-editor') || document.querySelector('[contenteditable=\\\"true\\\"]'); if (!editor) return 'no-editor'; editor.focus(); editor.innerHTML = '<p>[AutoTest] 这是一个 OpenCLI 发文测试,时间戳: ' + Date.now() + '</p><p>这段内容用于验证 browser 命令链的完整性。</p>'; editor.dispatchEvent(new Event('input', { bubbles: true })); return 'filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(document.querySelector('.ql-editor') || document.querySelector('[contenteditable=\\\"true\\\"]'))?.textContent || ''\""
],
"judge": {
"type": "contains",
"value": "AutoTest"
},
"note": "5-step: navigate to question → click '写回答' → find editor → fill rich content (title + body) → verify"
},
{
"name": "zhihu-fill-article",
"platform": "zhihu",
"type": "fill-only",
"description": "Navigate to zhihu article editor (zhuanlan), fill title + body (no publish)",
"steps": [
"opencli browser open https://zhuanlan.zhihu.com/write",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const ta = document.querySelector('.WriteIndex-titleInput textarea') || document.querySelector('textarea[placeholder]'); if (!ta) return 'no-title-input'; ta.focus(); var nativeSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set; nativeSetter.call(ta, '[AutoTest] OpenCLI 发文能力验证 ' + Date.now()); ta.dispatchEvent(new Event('input', { bubbles: true })); return 'title-filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const editor = document.querySelector('[contenteditable=true]'); if (!editor) return 'no-editor'; editor.focus(); editor.innerHTML = '<p>这是 OpenCLI autoresearch 发文测试集的一部分。</p><p>测试链路:导航 → 填写标题 → 填写正文 → 验证内容。</p><p>时间戳: ' + Date.now() + '</p>'; editor.dispatchEvent(new Event('input', { bubbles: true })); return 'body-filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const title = (document.querySelector('.WriteIndex-titleInput textarea') || document.querySelector('textarea[placeholder]'))?.value || ''; const body = document.querySelector('[contenteditable=true]')?.textContent || ''; return JSON.stringify({ title: title.slice(0, 50), body: body.slice(0, 50) }); })()\""
],
"judge": {
"type": "contains",
"value": "AutoTest"
},
"note": "5-step: navigate to zhuanlan editor → fill title textarea → fill rich text body → verify both title and body content"
},
{
"name": "zhihu-read-hn-fill-answer",
"platform": "zhihu",
"type": "fill-only",
"description": "Read HN top story, then navigate to zhihu question and fill an answer about it",
"steps": [
"opencli browser open https://news.ycombinator.com",
"opencli browser wait time 2",
"opencli browser eval \"(() => { const a = document.querySelector('.titleline a'); return a ? a.textContent?.trim() : 'no-title'; })()\"",
"opencli browser open https://www.zhihu.com/question/19550225",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const btn = Array.from(document.querySelectorAll('button')).find(b => b.textContent?.includes('写回答')) || document.querySelector('[data-zop-retarget=\\\"answer\\\"]'); if (btn) { btn.click(); return 'editor-opened'; } return 'no-answer-btn'; })()\"",
"opencli browser wait time 2",
"opencli browser eval \"(() => { const editor = document.querySelector('.ql-editor') || document.querySelector('[contenteditable=true]'); if (!editor) return 'no-editor'; editor.focus(); editor.innerHTML = '<p>[AutoTest] 分享一个来自 Hacker News 的有趣内容</p><p>这是一个跨平台内容搬运测试,时间戳: ' + Date.now() + '</p>'; editor.dispatchEvent(new Event('input', { bubbles: true })); return 'filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(document.querySelector('.ql-editor') || document.querySelector('[contenteditable=true]'))?.textContent || ''\""
],
"judge": {
"type": "contains",
"value": "AutoTest"
},
"note": "8-step cross-site chain: read HN title → navigate zhihu question → click 写回答 → fill answer with HN content → verify"
},
{
"name": "twitter-thread-compose",
"platform": "twitter",
"type": "fill-only",
"description": "Navigate to compose, type first tweet, add thread tweet, type second tweet, verify both",
"steps": [
"opencli browser open https://x.com/compose/tweet",
"opencli browser wait time 3",
"opencli browser eval \"document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]') ? 'composer-ready' : 'not-found'\"",
"opencli browser eval \"(() => { const box = document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]'); if (!box) return 'no-box'; box.focus(); const dt = new DataTransfer(); dt.setData('text/plain', '[AutoTest] Thread tweet 1 - ' + Date.now()); box.dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true })); return 'first-filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const addBtn = document.querySelector('[data-testid=\\\"addButton\\\"]') || document.querySelector('[aria-label=\\\"Add post\\\"]'); if (addBtn) { addBtn.click(); return 'thread-added'; } return 'no-add-btn'; })()\"",
"opencli browser wait time 2",
"opencli browser eval \"(() => { const boxes = document.querySelectorAll('[data-testid=\\\"tweetTextarea_0\\\"]'); const box = boxes[boxes.length - 1]; if (!box) return 'no-second-box'; box.focus(); const dt = new DataTransfer(); dt.setData('text/plain', '[AutoTest] Thread tweet 2 - continuation'); box.dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true })); return 'second-filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const boxes = document.querySelectorAll('[data-testid=\\\"tweetTextarea_0\\\"]'); const t1 = boxes[0]?.textContent || ''; const t2 = boxes[boxes.length - 1]?.textContent || ''; return JSON.stringify({ tweet1: t1, tweet2: t2 }); })()\""
],
"judge": {
"type": "contains",
"value": "Thread tweet 2"
},
"note": "10-step thread compose: open composer → fill tweet 1 → click add thread → fill tweet 2 → verify both tweets present"
},
{
"name": "twitter-quote-retweet-fill",
"platform": "twitter",
"type": "fill-only",
"description": "Navigate to home, find first tweet, open retweet menu, select Quote, fill quote text, verify",
"steps": [
"opencli browser open https://x.com/home",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const tweet = document.querySelector('[data-testid=\\\"tweet\\\"]'); if (!tweet) return 'no-tweet'; const retweet = tweet.querySelector('[data-testid=\\\"retweet\\\"]'); if (retweet) { retweet.click(); return 'retweet-menu-opened'; } return 'no-retweet-btn'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const items = document.querySelectorAll('[role=\\\"menuitem\\\"]'); for (const item of items) { if (item.textContent?.includes('Quote') || item.textContent?.includes('引用')) { item.click(); return 'quote-selected'; } } return 'no-quote-option'; })()\"",
"opencli browser wait time 2",
"opencli browser eval \"(() => { const box = document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]'); if (!box) return 'no-box'; box.focus(); const dt = new DataTransfer(); dt.setData('text/plain', '[AutoTest] Quote retweet test ' + Date.now()); box.dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true })); return 'quote-filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]')?.textContent || ''\""
],
"judge": {
"type": "contains",
"value": "Quote retweet test"
},
"note": "8-step quote retweet: home → find tweet → click retweet → select Quote → fill quote text → verify"
},
{
"name": "twitter-search-then-reply-fill",
"platform": "twitter",
"type": "fill-only",
"description": "Search 'opencli' on twitter, find first result, click reply, fill reply text, verify",
"steps": [
"opencli browser open https://x.com/search?q=opencli&src=typed_query&f=live",
"opencli browser wait time 4",
"opencli browser eval \"(() => { const tweets = document.querySelectorAll('[data-testid=\\\"tweet\\\"]'); if (tweets.length === 0) return 'no-results'; return 'found-' + tweets.length + '-results'; })()\"",
"opencli browser eval \"(() => { const tweet = document.querySelector('[data-testid=\\\"tweet\\\"]'); if (!tweet) return 'no-tweet'; const reply = tweet.querySelector('[data-testid=\\\"reply\\\"]'); if (reply) { reply.click(); return 'reply-clicked'; } return 'no-reply-btn'; })()\"",
"opencli browser wait time 2",
"opencli browser eval \"(() => { const box = document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]'); if (!box) return 'no-box'; box.focus(); const dt = new DataTransfer(); dt.setData('text/plain', '[AutoTest] Reply from search result ' + Date.now()); box.dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true })); return 'reply-filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]')?.textContent || ''\""
],
"judge": {
"type": "contains",
"value": "Reply from search"
},
"note": "8-step search-then-reply: navigate to search URL → verify results → click reply on first → fill reply → verify"
},
{
"name": "zhihu-search-then-fill-answer",
"platform": "zhihu",
"type": "fill-only",
"description": "Search 'AI agent' on zhihu, click first question result, click 写回答, fill answer, verify",
"steps": [
"opencli browser open https://www.zhihu.com/search?type=content&q=AI%20agent",
"opencli browser wait time 4",
"opencli browser eval \"(() => { const links = document.querySelectorAll('a[href*=\\\"/question/\\\"]'); if (links.length === 0) return 'no-question-links'; const link = links[0]; const href = link.getAttribute('href'); return 'found: ' + href; })()\"",
"opencli browser eval \"(() => { const links = document.querySelectorAll('a[href*=\\\"/question/\\\"]'); if (links.length === 0) return 'no-links'; const link = links[0]; const href = link.getAttribute('href'); const match = href.match(/\\\\/question\\\\/(\\\\d+)/); if (match) { window.location.href = 'https://www.zhihu.com/question/' + match[1]; return 'navigating-to-question'; } link.click(); return 'clicked-link'; })()\"",
"opencli browser wait time 4",
"opencli browser eval \"(() => { const btn = document.querySelector('[data-zop-retarget=\\\"answer\\\"]') || Array.from(document.querySelectorAll('button')).find(b => b.textContent?.includes('写回答')) || Array.from(document.querySelectorAll('a')).find(a => a.textContent?.includes('写回答')); if (btn) { btn.click(); return 'editor-opened'; } return 'no-answer-btn'; })()\"",
"opencli browser wait time 2",
"opencli browser eval \"(() => { const editor = document.querySelector('.ql-editor') || document.querySelector('[contenteditable=\\\"true\\\"]'); if (!editor) return 'no-editor'; editor.focus(); editor.innerHTML = '<p>[AutoTest] AI agent 搜索后回答测试 ' + Date.now() + '</p><p>这是通过搜索 → 进入问题 → 填写回答的完整链路测试。</p>'; editor.dispatchEvent(new Event('input', { bubbles: true })); return 'filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(document.querySelector('.ql-editor') || document.querySelector('[contenteditable=\\\"true\\\"]'))?.textContent || ''\""
],
"judge": {
"type": "contains",
"value": "AutoTest"
},
"note": "9-step search-then-answer: search zhihu → find question link → navigate → click 写回答 → fill answer → verify"
},
{
"name": "zhihu-read-question-fill-comment",
"platform": "zhihu",
"type": "fill-only",
"description": "Navigate to question page, scroll to first answer, click comment, fill comment text, verify",
"steps": [
"opencli browser open https://www.zhihu.com/question/19550225",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const answer = document.querySelector('[data-testid=\\\"answer\\\"]') || document.querySelector('.AnswerItem') || document.querySelector('.List-item'); if (answer) { answer.scrollIntoView({ behavior: 'smooth', block: 'center' }); return 'answer-scrolled'; } return 'no-answer'; })()\"",
"opencli browser wait time 2",
"opencli browser eval \"(() => { const commentBtns = document.querySelectorAll('button'); for (const btn of commentBtns) { if (btn.textContent?.match(/评论|条评论|comment/i)) { btn.click(); return 'comment-opened: ' + btn.textContent.trim(); } } const commentIcons = document.querySelectorAll('[data-testid=\\\"comment\\\"]') || []; for (const icon of commentIcons) { icon.click(); return 'comment-icon-clicked'; } return 'no-comment-btn'; })()\"",
"opencli browser wait time 2",
"opencli browser eval \"(() => { const editor = document.querySelector('.CommentEditor textarea') || document.querySelector('[placeholder*=\\\"评论\\\"]') || document.querySelector('[placeholder*=\\\"comment\\\"]') || document.querySelector('.ql-editor') || document.querySelector('[contenteditable=\\\"true\\\"]'); if (!editor) return 'no-comment-editor'; editor.focus(); if (editor.tagName === 'TEXTAREA' || editor.tagName === 'INPUT') { editor.value = '[AutoTest] 评论测试 ' + Date.now(); editor.dispatchEvent(new Event('input', { bubbles: true })); } else { editor.innerHTML = '<p>[AutoTest] 评论测试 ' + Date.now() + '</p>'; editor.dispatchEvent(new Event('input', { bubbles: true })); } return 'comment-filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const editor = document.querySelector('.CommentEditor textarea') || document.querySelector('[placeholder*=\\\"评论\\\"]') || document.querySelector('[placeholder*=\\\"comment\\\"]') || document.querySelector('.ql-editor') || document.querySelector('[contenteditable=\\\"true\\\"]'); if (!editor) return 'no-editor'; return editor.value || editor.textContent || ''; })()\""
],
"judge": {
"type": "contains",
"value": "AutoTest"
},
"note": "8-step comment chain: navigate question → scroll to answer → click comment → fill comment text → verify"
},
{
"name": "zhihu-article-with-formatting",
"platform": "zhihu",
"type": "fill-only",
"description": "Navigate to zhuanlan editor, fill title, fill body with multiple paragraphs and bold text, verify",
"steps": [
"opencli browser open https://zhuanlan.zhihu.com/write",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const titleInput = document.querySelector('.WriteIndex-titleInput textarea') || document.querySelector('textarea[placeholder*=\\\"标题\\\"]'); if (!titleInput) return 'no-title-input'; titleInput.focus(); titleInput.value = '[AutoTest] 格式化文章测试 ' + Date.now(); titleInput.dispatchEvent(new Event('input', { bubbles: true })); return 'title-filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const editor = document.querySelector('.ql-editor') || document.querySelector('[contenteditable=\\\"true\\\"]'); if (!editor) return 'no-editor'; editor.focus(); editor.innerHTML = '<p>这是第一段:OpenCLI 格式化发文测试。</p><p><strong>[AutoTest-Bold] 这是加粗的第二段,用于验证富文本格式。</strong></p><p>这是第三段,包含普通文本内容,时间戳: ' + Date.now() + '。</p><p>这是第四段,测试多段落填充能力。</p>'; editor.dispatchEvent(new Event('input', { bubbles: true })); return 'body-filled-with-formatting'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const editor = document.querySelector('.ql-editor') || document.querySelector('[contenteditable=\\\"true\\\"]'); if (!editor) return 'no-editor'; const hasBold = editor.querySelector('strong') || editor.querySelector('b'); const paragraphs = editor.querySelectorAll('p'); return JSON.stringify({ paragraphCount: paragraphs.length, hasBold: !!hasBold, preview: editor.textContent?.slice(0, 80) }); })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const title = (document.querySelector('.WriteIndex-titleInput textarea') || document.querySelector('textarea[placeholder*=\\\"标题\\\"]'))?.value || ''; const body = (document.querySelector('.ql-editor') || document.querySelector('[contenteditable=\\\"true\\\"]'))?.textContent || ''; return JSON.stringify({ title: title.slice(0, 60), bodyHasBold: body.includes('AutoTest-Bold'), bodyLength: body.length }); })()\""
],
"judge": {
"type": "contains",
"value": "AutoTest"
},
"note": "8-step formatted article: navigate editor → fill title → fill body with <strong> bold + 4 paragraphs → verify formatting + content"
},
{
"name": "cross-zhihu-to-twitter",
"platform": "cross",
"type": "fill-only",
"description": "Read zhihu hot topic title, navigate to twitter compose, fill tweet with zhihu content, verify",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const hotItem = document.querySelector('.HotItem-content a') || document.querySelector('.HotList-item a') || document.querySelector('[data-testid=\\\"hot-item\\\"] a') || document.querySelector('.HotItem a'); if (hotItem) return hotItem.textContent?.trim()?.slice(0, 60) || 'no-text'; const titles = document.querySelectorAll('h2'); for (const t of titles) { if (t.textContent?.trim().length > 5) return t.textContent.trim().slice(0, 60); } return 'no-hot-topic'; })()\"",
"opencli browser state save zhihu_hot_title",
"opencli browser open https://x.com/compose/tweet",
"opencli browser wait time 3",
"opencli browser eval \"document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]') ? 'composer-ready' : 'not-found'\"",
"opencli browser eval \"(() => { const box = document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]'); if (!box) return 'no-box'; box.focus(); const dt = new DataTransfer(); dt.setData('text/plain', '[AutoTest] Zhihu热榜话题搬运: 知乎上正在热议的话题 - ' + Date.now()); box.dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true })); return 'tweet-filled-with-zhihu'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"document.querySelector('[data-testid=\\\"tweetTextarea_0\\\"]')?.textContent || ''\""
],
"judge": {
"type": "contains",
"value": "Zhihu热榜话题搬运"
},
"note": "10-step cross-platform: read zhihu hot → save state → navigate twitter compose → fill tweet with zhihu content → verify"
},
{
"name": "cross-twitter-to-zhihu",
"platform": "cross",
"type": "fill-only",
"description": "Read twitter trending/explore topic, navigate to zhihu zhuanlan editor, fill title and body, verify",
"steps": [
"opencli browser open https://x.com/explore/tabs/trending",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const trends = document.querySelectorAll('[data-testid=\\\"trend\\\"]'); if (trends.length > 0) { const first = trends[0]; return first.textContent?.trim()?.slice(0, 80) || 'no-text'; } const spans = document.querySelectorAll('span'); for (const s of spans) { if (s.textContent?.startsWith('#') || s.textContent?.includes('Trending')) { return s.textContent.trim().slice(0, 80); } } return 'no-trending-topic'; })()\"",
"opencli browser state save twitter_trending",
"opencli browser open https://zhuanlan.zhihu.com/write",
"opencli browser wait time 3",
"opencli browser eval \"(() => { const titleInput = document.querySelector('.WriteIndex-titleInput textarea') || document.querySelector('textarea[placeholder*=\\\"标题\\\"]'); if (!titleInput) return 'no-title-input'; titleInput.focus(); titleInput.value = '[AutoTest] Twitter热点搬运: 来自推特的热门话题 ' + Date.now(); titleInput.dispatchEvent(new Event('input', { bubbles: true })); return 'title-filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const editor = document.querySelector('.ql-editor') || document.querySelector('[contenteditable=\\\"true\\\"]'); if (!editor) return 'no-editor'; editor.focus(); editor.innerHTML = '<p>[AutoTest] 这篇文章搬运自 Twitter 热门话题。</p><p>Twitter 上正在讨论的热门话题为大家带来了新的视角和思考。</p><p>时间戳: ' + Date.now() + '</p>'; editor.dispatchEvent(new Event('input', { bubbles: true })); return 'body-filled'; })()\"",
"opencli browser wait time 1",
"opencli browser eval \"(() => { const title = (document.querySelector('.WriteIndex-titleInput textarea') || document.querySelector('textarea[placeholder*=\\\"标题\\\"]'))?.value || ''; const body = (document.querySelector('.ql-editor') || document.querySelector('[contenteditable=\\\"true\\\"]'))?.textContent || ''; return JSON.stringify({ title: title.slice(0, 60), body: body.slice(0, 60) }); })()\""
],
"judge": {
"type": "contains",
"value": "Twitter热点搬运"
},
"note": "10-step cross-platform reverse: read twitter trending → save state → navigate zhihu editor → fill title + body → verify"
}
]
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
# Layer 1: Deterministic browse command testing
set -e
cd "$(dirname "$0")/.."
echo "Building OpenCLI..."
npm run build > /dev/null 2>&1
echo "Build OK"
echo ""
npx tsx autoresearch/eval-browse.ts "$@"
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
# Layer 4: Save as CLI — test the full save pipeline
# Tests: browser init → write adapter → browser verify
set -euo pipefail
cd "$(dirname "$0")/.."
echo "=== Layer 4: Save as CLI ==="
echo "Testing: init → write → verify pipeline"
echo ""
npx tsx autoresearch/eval-save.ts "$@"
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
# Layer 2: Claude Code skill E2E testing
set -e
cd "$(dirname "$0")/.."
echo "Building OpenCLI..."
npm run build > /dev/null 2>&1
echo "Build OK"
echo ""
npx tsx autoresearch/eval-skill.ts "$@"
@@ -0,0 +1,64 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: 'test-xhs',
name: 'explore-deep',
description: '小红书探索页深度提取 + 去重 + 按互动排序',
domain: 'www.xiaohongshu.com',
strategy: Strategy.COOKIE,
browser: true,
args: [
{ name: 'limit', type: 'int', default: 15, help: 'Number of items' },
],
columns: ['rank', 'title', 'author', 'likes', 'url'],
func: async (page, kwargs) => {
const limit = kwargs.limit ?? 15;
// Step 1: Navigate to explore page
await page.goto('https://www.xiaohongshu.com/explore');
// Step 2: Wait for initial content via MutationObserver
await page.evaluate(`new Promise(function(resolve) {
var check = function() { return document.querySelectorAll('section.note-item').length > 0; };
if (check()) return resolve(true);
var observer = new MutationObserver(function(m, obs) { if (check()) { obs.disconnect(); resolve(true); } });
observer.observe(document.body, { childList: true, subtree: true });
setTimeout(function() { observer.disconnect(); resolve(false); }, 8000);
})`);
// Step 3: Multi-round adaptive scroll (early stop when no new content)
let prevCount = 0;
for (let round = 0; round < 5; round++) {
await page.evaluate('window.scrollTo(0, document.body.scrollHeight)');
await page.wait(1.5);
const count = await page.evaluate('document.querySelectorAll("section.note-item").length') as number;
if (count >= limit * 2 || count === prevCount) break;
prevCount = count;
}
// Step 4: Extract with noteId deduplication + parse likes as integers
const result = await page.evaluate(`(function() {
var seen = {};
var items = [];
document.querySelectorAll('section.note-item').forEach(function(el) {
var linkEl = el.querySelector('a[href]');
var href = linkEl ? linkEl.getAttribute('href') || '' : '';
var m = href.match(/explore\\/([a-f0-9]+)/);
var noteId = m ? m[1] : '';
if (!noteId || seen[noteId]) return;
seen[noteId] = true;
var titleEl = el.querySelector('.title span') || el.querySelector('a.title');
var authorEl = el.querySelector('.author-wrapper .name') || el.querySelector('.author .name');
var likesEl = el.querySelector('.like-wrapper .count') || el.querySelector('.interact-container .count');
var title = (titleEl ? titleEl.textContent || '' : '').trim();
var author = (authorEl ? authorEl.textContent || '' : '').trim();
var likesRaw = (likesEl ? likesEl.textContent || '0' : '0').trim();
var likes = parseInt(likesRaw.replace(/[^0-9]/g, '')) || 0;
items.push({ title: title, author: author, likes: likes, url: 'https://www.xiaohongshu.com/explore/' + noteId });
});
return items;
})()`);
// Step 5: Sort by likes descending
const sorted = (result as any[] || []).sort((a: any, b: any) => b.likes - a.likes);
// Step 6: Slice and format
return sorted.slice(0, limit).map((item: any, i: number) => ({
rank: i + 1, title: item.title, author: item.author, likes: String(item.likes), url: item.url,
}));
},
});
@@ -0,0 +1,61 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: 'test-xhs',
name: 'note-comments',
description: '小红书笔记详情 + 评论(多步合并输出)',
domain: 'www.xiaohongshu.com',
strategy: Strategy.COOKIE,
browser: true,
args: [
{ name: 'id', type: 'string', default: '6745a82f000000000800b6ed', positional: true, help: 'Note ID' },
{ name: 'limit', type: 'int', default: 5, help: 'Max comments' },
],
columns: ['section', 'title', 'author', 'likes', 'text'],
func: async (page, kwargs) => {
const noteId = kwargs.id ?? '6745a82f000000000800b6ed';
const commentLimit = kwargs.limit ?? 5;
// Step 1: Navigate to note detail page
await page.goto('https://www.xiaohongshu.com/explore/' + noteId);
await page.wait(3);
// Step 2: Extract note metadata (title, author, likes)
const meta = await page.evaluate(`(function() {
return {
title: (document.querySelector('#detail-title') || document.querySelector('.title') || {}).textContent?.trim() || '',
author: (document.querySelector('.author-container .username') || document.querySelector('.user-nickname') || {}).textContent?.trim() || '',
likes: (document.querySelector('[data-type="like"] .count') || document.querySelector('.like-wrapper .count') || {}).textContent?.trim() || '0',
};
})()`) as any;
// Step 3: Scroll the note container to trigger comment loading
for (let i = 0; i < 3; i++) {
await page.evaluate(`(function() {
var scroller = document.querySelector('.note-scroller') || document.querySelector('.container');
if (scroller && scroller.scrollTo) { scroller.scrollTo(0, 99999); } else { window.scrollTo(0, document.body.scrollHeight); }
})()`);
await page.wait(1);
}
// Step 4: Extract comments from DOM
const comments = await page.evaluate(`(function() {
var results = [];
var commentEls = document.querySelectorAll('.parent-comment, .comment-item-root');
commentEls.forEach(function(el) {
var item = el.querySelector('.comment-item') || el.querySelector('.comment-inner');
if (!item) return;
var authorEl = item.querySelector('.author-wrapper .name') || item.querySelector('.user-name');
var textEl = item.querySelector('.content') || item.querySelector('.note-text');
var likesEl = item.querySelector('.count');
var author = (authorEl ? authorEl.textContent || '' : '').trim();
var text = (textEl ? textEl.textContent || '' : '').replace(/\\s+/g, ' ').trim();
var likes = (likesEl ? likesEl.textContent || '0' : '0').trim();
if (text) results.push({ author: author, text: text.slice(0, 80), likes: likes });
});
return results;
})()`) as any[];
// Step 5: Merge note meta + comments into unified output
const rows: any[] = [{ section: 'note', title: meta.title, author: meta.author, likes: meta.likes, text: '' }];
for (const c of (comments || []).slice(0, commentLimit)) {
rows.push({ section: 'comment', title: '', author: c.author, likes: c.likes, text: c.text });
}
return rows;
},
});
@@ -0,0 +1,62 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: 'test-xhs',
name: 'search-full',
description: '小红书搜索 + 滚动加载 + 去重',
domain: 'www.xiaohongshu.com',
strategy: Strategy.COOKIE,
browser: true,
args: [
{ name: 'query', type: 'string', default: '咖啡', positional: true, help: 'Search query' },
{ name: 'limit', type: 'int', default: 10, help: 'Number of results' },
],
columns: ['rank', 'title', 'author', 'likes', 'url'],
func: async (page, kwargs) => {
const query = encodeURIComponent(kwargs.query ?? '咖啡');
const limit = kwargs.limit ?? 10;
// Step 1: Navigate to search page
await page.goto('https://www.xiaohongshu.com/search_result?keyword=' + query + '&source=web_search_result_notes');
// Step 2: Wait for async render via MutationObserver
await page.evaluate(`new Promise(function(resolve) {
var check = function() { return document.querySelectorAll('section.note-item').length > 0; };
if (check()) return resolve(true);
var observer = new MutationObserver(function(m, obs) { if (check()) { obs.disconnect(); resolve(true); } });
observer.observe(document.body, { childList: true, subtree: true });
setTimeout(function() { observer.disconnect(); resolve(false); }, 8000);
})`);
// Step 3: Scroll 3x to load more content
for (let i = 0; i < 3; i++) {
await page.evaluate('window.scrollTo(0, document.body.scrollHeight)');
await page.wait(1);
}
// Step 4: Extract from DOM with deduplication
const result = await page.evaluate(`(function() {
var seen = {};
var items = [];
document.querySelectorAll('section.note-item').forEach(function(el) {
var linkEl = el.querySelector('a[href]');
var href = linkEl ? linkEl.getAttribute('href') || '' : '';
var m = href.match(/explore\\/([a-f0-9]+)/);
var noteId = m ? m[1] : href;
if (!noteId || seen[noteId]) return;
seen[noteId] = true;
var titleEl = el.querySelector('.title span') || el.querySelector('a.title');
var authorEl = el.querySelector('.author-wrapper .name') || el.querySelector('.author .name');
var likesEl = el.querySelector('.like-wrapper .count') || el.querySelector('.interact-container .count');
if (titleEl) {
items.push({
title: (titleEl.textContent || '').trim(),
author: (authorEl ? authorEl.textContent || '' : '').trim(),
likes: (likesEl ? likesEl.textContent || '0' : '0').trim(),
url: 'https://www.xiaohongshu.com' + href,
});
}
});
return items;
})()`);
return (result as any[]).slice(0, limit).map((item: any, i: number) => ({
rank: i + 1, title: item.title, author: item.author, likes: item.likes, url: item.url,
}));
},
});
@@ -0,0 +1,52 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: 'test-zhihu',
name: 'hot-detail',
description: '知乎热榜 + 每个问题的第一个回答摘要',
domain: 'www.zhihu.com',
strategy: Strategy.COOKIE,
browser: true,
args: [
{ name: 'limit', type: 'int', default: 5, help: 'Number of items' },
],
columns: ['rank', 'title', 'heat', 'top_answer_author', 'top_answer_excerpt'],
func: async (page, kwargs) => {
const limit = kwargs.limit ?? 5;
// Step 1: Navigate
await page.goto('https://www.zhihu.com');
await page.wait(2);
// Step 2: Fetch hot list (handle 16+ digit IDs)
const hotList = await page.evaluate(`(async () => {
const res = await fetch('https://www.zhihu.com/api/v3/feed/topstory/hot-lists/total?limit=50', { credentials: 'include' });
const text = await res.text();
const d = JSON.parse(text.replace(/("id"\\s*:\\s*)(\\d{16,})/g, '$1"$2"'));
return (d?.data || []).map(item => {
const t = item.target || {};
return { qid: String(t.id || ''), title: t.title || '', heat: item.detail_text || '' };
});
})()`) as any[];
// Step 3: For each hot question, fetch its top answer
const items = hotList.slice(0, limit);
const enriched = [];
for (const item of items) {
if (!item.qid) { enriched.push({ ...item, top_answer_author: '', top_answer_excerpt: '' }); continue; }
const answer = await page.evaluate(`(async () => {
const strip = (html) => (html || '').replace(/<[^>]+>/g, '').trim();
try {
const res = await fetch('https://www.zhihu.com/api/v4/questions/${item.qid}/answers?limit=1&offset=0&sort_by=default&include=data[*].content,voteup_count,author', { credentials: 'include' });
const d = await res.json();
const a = d?.data?.[0];
if (!a) return { author: '', excerpt: '' };
return { author: a.author?.name || 'anonymous', excerpt: strip(a.content || '').slice(0, 120) };
} catch { return { author: '', excerpt: '' }; }
})()`) as any;
enriched.push({ ...item, top_answer_author: answer.author, top_answer_excerpt: answer.excerpt });
}
// Step 4: Format output
return enriched.map((item, i) => ({
rank: i + 1, title: item.title, heat: item.heat,
top_answer_author: item.top_answer_author, top_answer_excerpt: item.top_answer_excerpt,
}));
},
});
@@ -0,0 +1,57 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: 'test-zhihu',
name: 'question-full',
description: '知乎问题 + 回答 + 相关推荐(三层数据合并)',
domain: 'www.zhihu.com',
strategy: Strategy.COOKIE,
browser: true,
args: [
{ name: 'id', type: 'string', default: '19550225', positional: true, help: 'Question ID' },
{ name: 'limit', type: 'int', default: 3, help: 'Number of answers' },
],
columns: ['section', 'title', 'author', 'votes', 'excerpt'],
func: async (page, kwargs) => {
const qid = kwargs.id ?? '19550225';
const limit = kwargs.limit ?? 3;
// Step 1: Navigate to question page
await page.goto('https://www.zhihu.com/question/' + qid);
await page.wait(2);
// Step 2: Fetch question detail
const question = await page.evaluate(`(async () => {
try {
const res = await fetch('https://www.zhihu.com/api/v4/questions/${qid}', { credentials: 'include' });
const d = await res.json();
return { title: d.title || '', follower_count: d.follower_count || 0, answer_count: d.answer_count || 0 };
} catch { return { title: '', follower_count: 0, answer_count: 0 }; }
})()`) as any;
// Step 3: Fetch top answers
const answers = await page.evaluate(`(async () => {
const strip = (html) => (html || '').replace(/<[^>]+>/g, '').trim();
try {
const res = await fetch('https://www.zhihu.com/api/v4/questions/${qid}/answers?limit=${limit}&offset=0&sort_by=default&include=data[*].content,voteup_count,author', { credentials: 'include' });
const d = await res.json();
return (d?.data || []).map(a => ({ author: a.author?.name || 'anonymous', votes: a.voteup_count || 0, excerpt: strip(a.content || '').slice(0, 120) }));
} catch { return []; }
})()`) as any[];
// Step 4: Fetch related questions
const related = await page.evaluate(`(async () => {
try {
const res = await fetch('https://www.zhihu.com/api/v4/questions/${qid}/similar?limit=3', { credentials: 'include' });
const d = await res.json();
return (d?.data || []).map(q => ({ title: q.title || '', answer_count: q.answer_count || 0 }));
} catch { return []; }
})()`) as any[];
// Step 5: Merge three layers into unified output
const rows: any[] = [];
rows.push({ section: 'question', title: question.title, author: '', votes: question.follower_count, excerpt: question.answer_count + ' answers' });
for (const a of answers) {
rows.push({ section: 'answer', title: '', author: a.author, votes: a.votes, excerpt: a.excerpt });
}
for (const r of related) {
rows.push({ section: 'related', title: r.title, author: '', votes: 0, excerpt: r.answer_count + ' answers' });
}
return rows;
},
});
@@ -0,0 +1,53 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: 'test-zhihu',
name: 'search-detail',
description: '知乎搜索 + 每条结果的问题统计',
domain: 'www.zhihu.com',
strategy: Strategy.COOKIE,
browser: true,
args: [
{ name: 'query', type: 'string', default: 'AI', positional: true, help: 'Search query' },
{ name: 'limit', type: 'int', default: 5, help: 'Number of results' },
],
columns: ['rank', 'title', 'type', 'author', 'votes', 'answer_count', 'follower_count'],
func: async (page, kwargs) => {
const query = kwargs.query ?? 'AI';
const limit = kwargs.limit ?? 5;
// Step 1: Navigate
await page.goto('https://www.zhihu.com');
await page.wait(2);
// Step 2: Search API — filter results by type, extract question IDs
const searchResults = await page.evaluate(`(async () => {
const strip = (html) => (html || '').replace(/<[^>]+>/g, '').trim();
const res = await fetch('https://www.zhihu.com/api/v4/search_v3?q=' + encodeURIComponent('${query}') + '&t=general&offset=0&limit=20', { credentials: 'include' });
const d = await res.json();
return (d?.data || []).filter(item => item.type === 'search_result').map(item => {
const obj = item.object || {};
const q = obj.question || {};
const questionId = obj.type === 'answer' ? String(q.id || '') : obj.type === 'question' ? String(obj.id || '') : '';
return { type: obj.type || '', title: strip(obj.title || q.name || ''), author: obj.author?.name || '', votes: obj.voteup_count || 0, questionId };
});
})()`) as any[];
// Step 3: For each result, fetch question stats (answer_count, follower_count)
const items = searchResults.slice(0, limit);
const enriched = [];
for (const item of items) {
if (!item.questionId) { enriched.push({ ...item, answer_count: 0, follower_count: 0 }); continue; }
const stats = await page.evaluate(`(async () => {
try {
const res = await fetch('https://www.zhihu.com/api/v4/questions/${item.questionId}', { credentials: 'include' });
const d = await res.json();
return { answer_count: d.answer_count || 0, follower_count: d.follower_count || 0 };
} catch { return { answer_count: 0, follower_count: 0 }; }
})()`) as any;
enriched.push({ ...item, answer_count: stats.answer_count, follower_count: stats.follower_count });
}
// Step 4: Format output
return enriched.map((item, i) => ({
rank: i + 1, title: item.title, type: item.type, author: item.author,
votes: item.votes, answer_count: item.answer_count, follower_count: item.follower_count,
}));
},
});
+281
View File
@@ -0,0 +1,281 @@
[
{
"name": "httpbin-get",
"site": "test-httpbin",
"command": "get",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-httpbin',\n name: 'get',\n description: 'httpbin echo test',\n domain: 'httpbin.org',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [],\n columns: ['origin', 'url'],\n func: async () => {\n const res = await fetch('https://httpbin.org/get');\n const d = await res.json();\n return [{ origin: d.origin, url: d.url }];\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 1
},
"note": "Simplest possible: httpbin echo, single row"
},
{
"name": "jsonplaceholder-posts",
"site": "test-jsonplaceholder",
"command": "posts",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-jsonplaceholder',\n name: 'posts',\n description: 'JSONPlaceholder posts',\n domain: 'jsonplaceholder.typicode.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of posts' },\n ],\n columns: ['id', 'title'],\n func: async (_page, kwargs) => {\n const limit = kwargs.limit ?? 5;\n const res = await fetch('https://jsonplaceholder.typicode.com/posts');\n const posts = await res.json();\n return posts.slice(0, limit).map((p: any) => ({ id: p.id, title: p.title }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "jsonplaceholder-users",
"site": "test-jsonplaceholder",
"command": "users",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-jsonplaceholder',\n name: 'users',\n description: 'JSONPlaceholder users',\n domain: 'jsonplaceholder.typicode.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of users' },\n ],\n columns: ['id', 'name', 'email'],\n func: async (_page, kwargs) => {\n const limit = kwargs.limit ?? 5;\n const res = await fetch('https://jsonplaceholder.typicode.com/users');\n const users = await res.json();\n return users.slice(0, limit).map((u: any) => ({ id: u.id, name: u.name, email: u.email }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "hn-top",
"site": "test-hn",
"command": "top",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-hn',\n name: 'top',\n description: 'HackerNews top stories',\n domain: 'news.ycombinator.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of stories' },\n ],\n columns: ['rank', 'title', 'score'],\n func: async (_page, kwargs) => {\n const limit = Math.min(kwargs.limit ?? 5, 10);\n const res = await fetch('https://hacker-news.firebaseio.com/v0/topstories.json');\n const ids = await res.json();\n const items = await Promise.all(ids.slice(0, limit).map(async (id: number) => {\n const r = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);\n return r.json();\n }));\n return items.map((item: any, i: number) => ({\n rank: i + 1, title: item.title, score: item.score,\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "hn-ask",
"site": "test-hn",
"command": "ask",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-hn',\n name: 'ask',\n description: 'HackerNews Ask HN stories',\n domain: 'news.ycombinator.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of stories' },\n ],\n columns: ['rank', 'title', 'score'],\n func: async (_page, kwargs) => {\n const limit = Math.min(kwargs.limit ?? 5, 10);\n const res = await fetch('https://hacker-news.firebaseio.com/v0/askstories.json');\n const ids = await res.json();\n const items = await Promise.all(ids.slice(0, limit).map(async (id: number) => {\n const r = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);\n return r.json();\n }));\n return items.map((item: any, i: number) => ({\n rank: i + 1, title: item.title, score: item.score,\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "wiki-summary",
"site": "test-wiki",
"command": "summary",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-wiki',\n name: 'summary',\n description: 'Wikipedia article summary',\n domain: 'en.wikipedia.org',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'title', type: 'string', default: 'JavaScript', positional: true, help: 'Article title' },\n ],\n columns: ['title', 'extract'],\n func: async (_page, kwargs) => {\n const title = encodeURIComponent(kwargs.title);\n const res = await fetch(`https://en.wikipedia.org/api/rest_v1/page/summary/${title}`);\n const d = await res.json();\n return [{ title: d.title, extract: d.extract?.slice(0, 200) }];\n },\n});\n",
"judge": {
"type": "contains",
"value": "programming language"
}
},
{
"name": "lobsters-hot",
"site": "test-lobsters",
"command": "hot",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-lobsters',\n name: 'hot',\n description: 'Lobsters hottest stories',\n domain: 'lobste.rs',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of stories' },\n ],\n columns: ['title', 'score', 'url'],\n func: async (_page, kwargs) => {\n const limit = kwargs.limit ?? 5;\n const res = await fetch('https://lobste.rs/hottest.json');\n const stories = await res.json();\n return stories.slice(0, limit).map((s: any) => ({\n title: s.title, score: s.score, url: s.short_id_url,\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "devto-top",
"site": "test-devto",
"command": "top",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-devto',\n name: 'top',\n description: 'DEV.to top articles',\n domain: 'dev.to',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of articles' },\n ],\n columns: ['title', 'user', 'reactions'],\n func: async (_page, kwargs) => {\n const limit = kwargs.limit ?? 5;\n const res = await fetch('https://dev.to/api/articles?per_page=' + limit);\n const articles = await res.json();\n return articles.map((a: any) => ({\n title: a.title, user: a.user?.username, reactions: a.positive_reactions_count,\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "zhihu-hot-with-top-answer",
"site": "test-zhihu",
"command": "hot-detail",
"adapterFile": "save-adapters/zhihu-hot-detail.ts",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "6-step chain: navigate → fetch hot list API → parse big-int IDs → loop N items → fetch answer API per question → strip HTML → merge"
},
{
"name": "zhihu-search-with-question-stats",
"site": "test-zhihu",
"command": "search-detail",
"adapterFile": "save-adapters/zhihu-search-detail.ts",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "7-step chain: navigate → search API → filter by type → extract question IDs → fetch question detail per result → merge stats → format"
},
{
"name": "xhs-search-scroll-extract",
"site": "test-xhs",
"command": "search-full",
"adapterFile": "save-adapters/xhs-search-full.ts",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "6-step chain: navigate → MutationObserver wait → scroll 3x → DOM extract with URL dedup → slice + format"
},
{
"name": "xhs-note-with-comments",
"site": "test-xhs",
"command": "note-comments",
"adapterFile": "save-adapters/xhs-note-comments.ts",
"judge": {
"type": "arrayMinLength",
"minLength": 1
},
"note": "7-step chain: navigate → wait → extract note meta → scroll container 3x → extract comments DOM → merge note+comments → unified output"
},
{
"name": "zhihu-question-with-related",
"site": "test-zhihu",
"command": "question-full",
"adapterFile": "save-adapters/zhihu-question-full.ts",
"judge": {
"type": "arrayMinLength",
"minLength": 2
},
"note": "8-step chain: navigate → wait → fetch question detail → fetch answers → strip HTML → fetch related questions → merge 3 layers → format"
},
{
"name": "xhs-explore-scroll-dedupe",
"site": "test-xhs",
"command": "explore-deep",
"adapterFile": "save-adapters/xhs-explore-deep.ts",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "8-step chain: navigate → MutationObserver wait → adaptive scroll → DOM extract with dedup → parse likes → sort desc → slice → format"
},
{
"name": "hn-new",
"site": "test-hn",
"command": "new",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-hn',\n name: 'new',\n description: 'HackerNews newest stories',\n domain: 'news.ycombinator.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of stories' },\n ],\n columns: ['rank', 'title', 'score'],\n func: async (_page, kwargs) => {\n const limit = Math.min(kwargs.limit ?? 5, 10);\n const res = await fetch('https://hacker-news.firebaseio.com/v0/newstories.json');\n const ids = await res.json();\n const items = await Promise.all(ids.slice(0, limit).map(async (id: number) => {\n const r = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);\n return r.json();\n }));\n return items.map((item: any, i: number) => ({\n rank: i + 1, title: item.title, score: item.score ?? 0,\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: HackerNews new stories using same Firebase API as hn-top/hn-ask"
},
{
"name": "jsonplaceholder-todos",
"site": "test-jsonplaceholder",
"command": "todos",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-jsonplaceholder',\n name: 'todos',\n description: 'JSONPlaceholder todos',\n domain: 'jsonplaceholder.typicode.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of todos' },\n ],\n columns: ['id', 'title', 'completed'],\n func: async (_page, kwargs) => {\n const limit = kwargs.limit ?? 5;\n const res = await fetch('https://jsonplaceholder.typicode.com/todos');\n const todos = await res.json();\n return todos.slice(0, limit).map((t: any) => ({ id: t.id, title: t.title, completed: t.completed }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: JSONPlaceholder todos — same base domain as posts/users, different endpoint"
},
{
"name": "hn-show",
"site": "test-hn",
"command": "show",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-hn',\n name: 'show',\n description: 'HackerNews Show HN stories',\n domain: 'news.ycombinator.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of stories' },\n ],\n columns: ['rank', 'title', 'score'],\n func: async (_page, kwargs) => {\n const limit = Math.min(kwargs.limit ?? 5, 10);\n const res = await fetch('https://hacker-news.firebaseio.com/v0/showstories.json');\n const ids = await res.json();\n const items = await Promise.all(ids.slice(0, limit).map(async (id: number) => {\n const r = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);\n return r.json();\n }));\n return items.map((item: any, i: number) => ({\n rank: i + 1, title: item.title, score: item.score ?? 0,\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: HackerNews show stories using same Firebase API as hn-top/hn-ask/hn-new"
},
{
"name": "jsonplaceholder-comments",
"site": "test-jsonplaceholder",
"command": "comments",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-jsonplaceholder',\n name: 'comments',\n description: 'JSONPlaceholder comments',\n domain: 'jsonplaceholder.typicode.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of comments' },\n ],\n columns: ['id', 'name', 'email'],\n func: async (_page, kwargs) => {\n const limit = kwargs.limit ?? 5;\n const res = await fetch('https://jsonplaceholder.typicode.com/comments');\n const comments = await res.json();\n return comments.slice(0, limit).map((c: any) => ({ id: c.id, name: c.name, email: c.email }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: JSONPlaceholder comments — same base domain as posts/users/todos, different endpoint"
},
{
"name": "jsonplaceholder-albums",
"site": "test-jsonplaceholder",
"command": "albums",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-jsonplaceholder',\n name: 'albums',\n description: 'JSONPlaceholder albums',\n domain: 'jsonplaceholder.typicode.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of albums' },\n ],\n columns: ['id', 'userId', 'title'],\n func: async (_page, kwargs) => {\n const limit = kwargs.limit ?? 5;\n const res = await fetch('https://jsonplaceholder.typicode.com/albums');\n const albums = await res.json();\n return albums.slice(0, limit).map((a: any) => ({ id: a.id, userId: a.userId, title: a.title }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: JSONPlaceholder albums — same base domain as posts/users/todos/comments, different endpoint"
},
{
"name": "jsonplaceholder-photos",
"site": "test-jsonplaceholder",
"command": "photos",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-jsonplaceholder',\n name: 'photos',\n description: 'JSONPlaceholder photos',\n domain: 'jsonplaceholder.typicode.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of photos' },\n ],\n columns: ['id', 'albumId', 'title'],\n func: async (_page, kwargs) => {\n const limit = kwargs.limit ?? 5;\n const res = await fetch('https://jsonplaceholder.typicode.com/photos');\n const photos = await res.json();\n return photos.slice(0, limit).map((p: any) => ({ id: p.id, albumId: p.albumId, title: p.title }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: JSONPlaceholder photos — same base domain as posts/users/todos/comments/albums, different endpoint"
},
{
"name": "hn-best",
"site": "test-hn",
"command": "best",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-hn',\n name: 'best',\n description: 'HackerNews best stories',\n domain: 'news.ycombinator.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of stories' },\n ],\n columns: ['rank', 'title', 'score'],\n func: async (_page, kwargs) => {\n const limit = Math.min(kwargs.limit ?? 5, 10);\n const res = await fetch('https://hacker-news.firebaseio.com/v0/beststories.json');\n const ids = await res.json();\n const items = await Promise.all(ids.slice(0, limit).map(async (id: number) => {\n const r = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);\n return r.json();\n }));\n return items.map((item: any, i: number) => ({\n rank: i + 1, title: item.title, score: item.score ?? 0,\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: HackerNews best stories using same Firebase API as hn-top/hn-ask/hn-new/hn-show"
},
{
"name": "hn-jobs",
"site": "test-hn",
"command": "jobs",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-hn',\n name: 'jobs',\n description: 'HackerNews job stories',\n domain: 'news.ycombinator.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of jobs' },\n ],\n columns: ['rank', 'title', 'url'],\n func: async (_page, kwargs) => {\n const limit = Math.min(kwargs.limit ?? 5, 10);\n const res = await fetch('https://hacker-news.firebaseio.com/v0/jobstories.json');\n const ids = await res.json();\n const items = await Promise.all(ids.slice(0, limit).map(async (id: number) => {\n const r = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);\n return r.json();\n }));\n return items.map((item: any, i: number) => ({\n rank: i + 1, title: item.title, url: item.url ?? '',\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: HackerNews job listings using same Firebase API as other HN adapters"
},
{
"name": "restcountries-list",
"site": "test-restcountries",
"command": "list",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-restcountries',\n name: 'list',\n description: 'REST Countries list',\n domain: 'restcountries.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of countries' },\n ],\n columns: ['name', 'capital', 'region'],\n func: async (_page, kwargs) => {\n const limit = kwargs.limit ?? 5;\n const res = await fetch('https://restcountries.com/v3.1/all?fields=name,capital,region');\n const countries = await res.json();\n return countries.slice(0, limit).map((c: any) => ({\n name: c.name?.common ?? '',\n capital: c.capital?.[0] ?? '',\n region: c.region ?? '',\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: REST Countries API — stable, no-auth, returns 250 countries with name/capital/region"
},
{
"name": "nager-holidays",
"site": "test-nager",
"command": "holidays",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-nager',\n name: 'holidays',\n description: 'US public holidays for current year',\n domain: 'date.nager.at',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of holidays' },\n ],\n columns: ['date', 'name', 'type'],\n func: async (_page, kwargs) => {\n const limit = kwargs.limit ?? 5;\n const year = new Date().getFullYear();\n const res = await fetch(`https://date.nager.at/api/v3/PublicHolidays/${year}/US`);\n const holidays = await res.json();\n return holidays.slice(0, limit).map((h: any) => ({\n date: h.date,\n name: h.name,\n type: (h.types || []).join(','),\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: Nager public holidays API — stable, no-auth, returns US federal holidays by year"
},
{
"name": "catfact-list",
"site": "test-catfact",
"command": "facts",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-catfact',\n name: 'facts',\n description: 'Random cat facts',\n domain: 'catfact.ninja',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of facts' },\n ],\n columns: ['fact', 'length'],\n func: async (_page, kwargs) => {\n const limit = kwargs.limit ?? 5;\n const res = await fetch(`https://catfact.ninja/facts?limit=${limit}`);\n const d = await res.json();\n return d.data.map((item: any) => ({\n fact: item.fact.slice(0, 100),\n length: item.length,\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: catfact.ninja facts API — stable, no-auth, returns random cat facts"
},
{
"name": "opentdb-trivia",
"site": "test-opentdb",
"command": "easy",
"adapter": "import { cli, Strategy } from '@jackwener/opencli/registry';\n\ncli({\n site: 'test-opentdb',\n name: 'easy',\n description: 'Easy trivia questions from Open Trivia DB',\n domain: 'opentdb.com',\n strategy: Strategy.PUBLIC,\n browser: false,\n args: [\n { name: 'limit', type: 'int', default: 5, help: 'Number of questions' },\n ],\n columns: ['category', 'question', 'answer'],\n func: async (_page, kwargs) => {\n const limit = Math.min(kwargs.limit ?? 5, 10);\n const res = await fetch(`https://opentdb.com/api.php?amount=${limit}&difficulty=easy&type=multiple`);\n const d = await res.json();\n return d.results.map((q: any) => ({\n category: q.category,\n question: q.question.replace(/&quot;/g, '\"').replace(/&#039;/g, \"'\").slice(0, 80),\n answer: q.correct_answer,\n }));\n },\n});\n",
"judge": {
"type": "arrayMinLength",
"minLength": 3
},
"note": "PUBLIC strategy: Open Trivia DB API — stable, no-auth, returns trivia questions with correct answers"
}
]
+899
View File
@@ -0,0 +1,899 @@
[
{
"_comment": "=== Layer 1: Atomic Operations (10 tasks) ==="
},
{
"name": "v2ex-open-home",
"steps": [
"opencli browser open https://v2ex.com/"
],
"judge": {
"type": "contains",
"value": "Navigated to"
}
},
{
"name": "v2ex-state-home",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser state"
],
"judge": {
"type": "matchesPattern",
"pattern": "\\[\\d+\\]"
}
},
{
"name": "v2ex-get-title",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "contains",
"value": "V2EX"
}
},
{
"name": "v2ex-click-tab",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser eval \"(() => { const a = document.querySelector('a[href=\\\"/?tab=tech\\\"]'); if(a){a.click(); return 'clicked';} return 'not found'; })()\""
],
"judge": {
"type": "contains",
"value": "clicked"
}
},
{
"name": "v2ex-scroll-down",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser scroll down --amount 500",
"opencli browser eval \"window.scrollY > 100 ? 'scrolled' : 'not scrolled'\""
],
"judge": {
"type": "contains",
"value": "scrolled"
}
},
{
"name": "v2ex-get-first-topic-text",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser eval \"document.querySelector('a[href^=\\\"/t/\\\"]')?.textContent?.trim()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-eval-extract-titles",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,5).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "v2ex-get-url",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser get url"
],
"judge": {
"type": "contains",
"value": "v2ex.com"
}
},
{
"name": "v2ex-back-navigation",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser back",
"opencli browser get url"
],
"judge": {
"type": "matchesPattern",
"pattern": "v2ex\\.com/?$"
}
},
{
"name": "v2ex-wait-page-load",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser wait selector \"a[href^='/t/']\"",
"opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length > 0 ? 'loaded' : 'empty'\""
],
"judge": {
"type": "contains",
"value": "loaded"
}
},
{
"_comment": "=== Layer 2: Single Page Tasks (10 tasks) ==="
},
{
"name": "v2ex-hot-topics",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,10).map(a=>({title:a.textContent.trim(),url:a.href})).filter(t=>t.title.length>2))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 5
}
},
{
"name": "v2ex-node-list",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/go/\\\"]')].map(a=>a.textContent.trim()).filter(t=>t.length>0))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 10
}
},
{
"name": "v2ex-topic-meta",
"steps": [
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');const href=a?.href;return href||'';})()\"",
"opencli browser eval \"(()=>{const links=[...document.querySelectorAll('a[href^=\\\"/t/\\\"]')];const first=links[0];if(!first)return JSON.stringify({error:'no topic'});const title=first.textContent.trim();const row=first.closest('tr')||first.parentElement;const author=row?.querySelector('a[href^=\\\"/member/\\\"]')?.textContent?.trim()||'';return JSON.stringify({title,author});})()\" "
],
"judge": {
"type": "matchesPattern",
"pattern": "\"title\":"
}
},
{
"name": "v2ex-node-topics",
"steps": [
"opencli browser open https://v2ex.com/go/python",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,5).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "v2ex-node-pagination-info",
"steps": [
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser eval \"(()=>{const pages=[...document.querySelectorAll('a[href*=\\\"?p=\\\"]')];if(pages.length===0)return'no pagination';const nums=pages.map(a=>{const m=a.href.match(/p=(\\d+)/);return m?parseInt(m[1]):0}).filter(n=>n>0);return JSON.stringify({pages:nums.length,max:Math.max(...nums)});})()\" "
],
"judge": {
"type": "matchesPattern",
"pattern": "\"max\":\\d+"
}
},
{
"name": "v2ex-tab-content",
"steps": [
"opencli browser open https://v2ex.com/?tab=jobs",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,5).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "v2ex-topic-replies-extract",
"steps": [
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser eval \"(()=>{const link=document.querySelector('a[href^=\\\"/t/\\\"]');if(!link)return'';return link.href;})()\"",
"opencli browser eval \"(()=>{const link=document.querySelector('a[href^=\\\"/t/\\\"]');if(link)window.location.href=link.href;return'navigating';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('.reply_content')].slice(0,5).map(el=>el.textContent.trim().slice(0,100)))\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-topic-reply-count",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(()=>{const counts=[...document.querySelectorAll('a[class*=\\\"count\\\"]')].map(a=>parseInt(a.textContent)).filter(n=>!isNaN(n));return JSON.stringify(counts.slice(0,10));})()\" "
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "v2ex-member-info",
"steps": [
"opencli browser open https://v2ex.com/member/Livid",
"opencli browser eval \"(()=>{const name=document.querySelector('h1')?.textContent?.trim();const bio=document.querySelector('.bigger')?.textContent?.trim()||'';return JSON.stringify({name,bio});})()\" "
],
"judge": {
"type": "contains",
"value": "Livid"
}
},
{
"name": "v2ex-search-results",
"steps": [
"opencli browser open https://www.google.com/search?q=site:v2ex.com+TypeScript",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('h3')].slice(0,5).map(h=>h.textContent.trim()))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 2
}
},
{
"_comment": "=== Layer 3: Multi-Step (10 tasks) ==="
},
{
"name": "v2ex-click-topic-read",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser state",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked '+a.textContent.trim().slice(0,30);}return 'not found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"document.querySelector('.topic_content,.markdown_body')?.textContent?.trim()?.slice(0,200)||document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-click-author-profile",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/member/\\\"]');if(a){const name=a.textContent.trim();a.click();return name;}return'not found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(()=>{const h1=document.querySelector('h1');const joined=document.querySelector('.gray')?.textContent||'';return JSON.stringify({name:h1?.textContent?.trim(),info:joined.slice(0,100)});})()\" "
],
"judge": {
"type": "matchesPattern",
"pattern": "\"name\":"
}
},
{
"name": "v2ex-navigate-node-from-home",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href=\\\"/go/programmer\\\"]')||document.querySelector('a[href^=\\\"/go/\\\"]');if(a){a.click();return 'clicked '+a.textContent.trim();}return'not found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,5).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "v2ex-pagination-page2",
"steps": [
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href*=\\\"?p=2\\\"]');if(a){a.click();return'navigating to page 2';}return'no page 2 link';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"JSON.stringify({url:location.href,topics:[...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,5).map(a=>a.textContent.trim()).filter(t=>t.length>2)})\""
],
"judge": {
"type": "matchesPattern",
"pattern": "p=2"
}
},
{
"name": "v2ex-topic-and-back",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
"opencli browser wait time 2",
"opencli browser back",
"opencli browser wait time 1",
"opencli browser get url"
],
"judge": {
"type": "matchesPattern",
"pattern": "v2ex\\.com/?$"
}
},
{
"name": "v2ex-tab-then-topic",
"steps": [
"opencli browser open https://v2ex.com/?tab=creative",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){const t=a.textContent.trim();a.click();return t;}return'not found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-scroll-find-more",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\"",
"opencli browser scroll down --amount 1000",
"opencli browser scroll down --amount 1000",
"opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d+"
}
},
{
"name": "v2ex-node-to-topic-content",
"steps": [
"opencli browser open https://v2ex.com/go/python",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(()=>{const title=document.querySelector('h1')?.textContent?.trim()||document.title;const content=document.querySelector('.topic_content,.markdown_body')?.textContent?.trim()?.slice(0,200)||'';return JSON.stringify({title,content});})()\" "
],
"judge": {
"type": "matchesPattern",
"pattern": "\"title\":"
}
},
{
"name": "v2ex-multi-tab-compare",
"steps": [
"opencli browser open https://v2ex.com/?tab=tech",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()))\"",
"opencli browser open https://v2ex.com/?tab=creative",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 2
}
},
{
"name": "v2ex-topic-reply-to-author",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(()=>{const replies=document.querySelectorAll('.reply_content');const authors=[...document.querySelectorAll('a[href^=\\\"/member/\\\"]')];if(replies.length>0){const authorLink=document.querySelector('.cell a[href^=\\\"/member/\\\"]');if(authorLink){authorLink.click();return'clicked author';}};return'no replies found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"document.querySelector('h1')?.textContent?.trim()||document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"_comment": "=== Layer 4: Write Operations (5 tasks, requires login) ==="
},
{
"name": "v2ex-reply-type-text",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(()=>{const links=[...document.querySelectorAll('a[href^=\\\"/t/\\\"]')];const link=links.find(a=>a.closest('tr')?.querySelector('a[class*=\\\"count\\\"]'));if(link){link.click();return'clicked';}if(links[0]){links[0].click();return'clicked first';}return'no topic';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(()=>{const ta=document.querySelector('textarea#reply_content,textarea[name=\\\"content\\\"]');if(ta){ta.focus();ta.value='AutoResearch test reply - please ignore';ta.dispatchEvent(new Event('input',{bubbles:true}));return ta.value;}return'no textarea';})()\" "
],
"judge": {
"type": "contains",
"value": "AutoResearch test reply"
},
"note": "Types into reply box but does NOT submit"
},
{
"name": "v2ex-favorite-topic",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(()=>{const favLink=[...document.querySelectorAll('a')].find(a=>a.textContent.includes('加入收藏')||a.textContent.includes('Favorite'));return favLink?favLink.href:'no fav link';})()\" "
],
"judge": {
"type": "matchesPattern",
"pattern": "favorite|收藏"
},
"note": "Finds favorite link but does NOT click it"
},
{
"name": "v2ex-thank-reply-find",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(()=>{const thankBtns=document.querySelectorAll('.thank_area,a[onclick*=\\\"thank\\\"],.thank');return JSON.stringify({found:thankBtns.length});})()\" "
],
"judge": {
"type": "matchesPattern",
"pattern": "\"found\":\\d+"
},
"note": "Finds thank buttons but does NOT click"
},
{
"name": "v2ex-reply-form-detect",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(()=>{const ta=document.querySelector('textarea#reply_content,textarea[name=\\\"content\\\"]');const btn=document.querySelector('input[type=\\\"submit\\\"],button[type=\\\"submit\\\"]');const once=document.querySelector('input[name=\\\"once\\\"]');return JSON.stringify({textarea:!!ta,submitBtn:!!btn,csrfToken:!!once});})()\" "
],
"judge": {
"type": "contains",
"value": "\"textarea\":"
}
},
{
"name": "v2ex-create-topic-form-detect",
"steps": [
"opencli browser open https://v2ex.com/new",
"opencli browser wait time 2",
"opencli browser eval \"(()=>{const title=document.querySelector('input[name=\\\"title\\\"],#topic_title');const content=document.querySelector('textarea[name=\\\"content\\\"],#topic_content,textarea#editor');const nodeSelect=document.querySelector('select[name=\\\"node_name\\\"],#node-select');return JSON.stringify({titleInput:!!title,contentArea:!!content,nodeSelect:!!nodeSelect,url:location.href});})()\" "
],
"judge": {
"type": "nonEmpty"
},
"note": "Detects create topic form elements, does NOT submit"
},
{
"_comment": "=== Layer 5: Complex Chain (5 tasks) ==="
},
{
"name": "v2ex-collect-hot-authors",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"JSON.stringify([...new Set([...document.querySelectorAll('a')].filter(a=>a.pathname&&a.pathname.startsWith('/member/')).map(a=>a.textContent.trim()).filter(n=>n.length>1))].slice(0,5))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 2
}
},
{
"name": "v2ex-multi-node-compare",
"steps": [
"opencli browser open https://v2ex.com/go/python",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()).filter(t=>t.length>2))\"",
"opencli browser open https://v2ex.com/go/go",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 2
}
},
{
"name": "v2ex-topic-deep-read",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return'clicked';}return'not found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(()=>{const title=document.querySelector('h1')?.textContent?.trim()||document.title;const author=document.querySelector('.header a[href^=\\\"/member/\\\"]')?.textContent?.trim()||'';const content=document.querySelector('.topic_content,.markdown_body')?.textContent?.trim()?.slice(0,300)||'';const replyCount=document.querySelectorAll('.reply_content').length;return JSON.stringify({title,author,content,replyCount});})()\" "
],
"judge": {
"type": "matchesPattern",
"pattern": "\"title\":.+\"author\":"
}
},
{
"name": "v2ex-cross-page-data-collect",
"steps": [
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser eval \"(()=>{const titles=[...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim());window.__collected=titles;return JSON.stringify(titles);})()\"",
"opencli browser open https://v2ex.com/go/programmer?p=2",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()).filter(t=>t.length>2))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 2
}
},
{
"name": "v2ex-full-workflow",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(()=>{const topics=[...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>({title:a.textContent.trim(),href:a.href}));return JSON.stringify(topics);})()\"",
"opencli browser eval \"(()=>{const a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked: '+a.textContent.trim().slice(0,30);}return'not found';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(()=>{const title=document.querySelector('h1')?.textContent?.trim()||document.title;const replies=[...document.querySelectorAll('.reply_content')].slice(0,3).map(el=>el.textContent.trim().slice(0,80));const author=document.querySelector('.header a[href^=\\\"/member/\\\"]')?.textContent?.trim()||'';return JSON.stringify({title,author,replies,replyCount:replies.length});})()\" "
],
"judge": {
"type": "matchesPattern",
"pattern": "\"title\":.+\"author\":"
}
},
{
"_comment": "=== Layer 6: State + Click Interaction (10 tasks) ==="
},
{
"name": "v2ex-state-click-topic",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser state",
"opencli browser click 1"
],
"judge": {
"type": "contains",
"value": "Clicked"
}
},
{
"name": "v2ex-state-click-tab-tech",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser state",
"opencli browser eval \"(function(){var links=[...document.querySelectorAll('a')];var tab=links.find(a=>a.href&&a.href.includes('tab=tech'));if(tab){var ref=tab.getAttribute('data-opencli-ref');return ref||'no-ref';}return 'not-found';})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d+|no-ref"
}
},
{
"name": "v2ex-state-count-interactive",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser state"
],
"judge": {
"type": "matchesPattern",
"pattern": "interactive: \\d+"
}
},
{
"name": "v2ex-state-scroll-state",
"steps": [
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser scroll down --amount 500",
"opencli browser state"
],
"judge": {
"type": "matchesPattern",
"pattern": "\\[\\d+\\]"
}
},
{
"name": "v2ex-type-search-box",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser state",
"opencli browser eval \"(function(){var input=document.querySelector('input[type=\\\"text\\\"]');if(input){input.focus();input.value='TypeScript';input.dispatchEvent(new Event('input',{bubbles:true}));return input.value;}return 'no-input';})()\""
],
"judge": {
"type": "contains",
"value": "TypeScript"
}
},
{
"name": "v2ex-get-value-after-type",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a)a.click();return 'clicked';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var ta=document.querySelector('textarea#reply_content,textarea[name=\\\"content\\\"]');if(ta){ta.focus();ta.value='test message 12345';ta.dispatchEvent(new Event('input',{bubbles:true}));return ta.value;}return 'no-textarea';})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-screenshot-exists",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser screenshot /tmp/v2ex-test-screenshot.png"
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-get-html-selector",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser get html --selector h1"
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-keys-escape",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser keys Escape"
],
"judge": {
"type": "contains",
"value": "pressed"
}
},
{
"name": "v2ex-wait-text",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser wait text V2EX"
],
"judge": {
"type": "matchesPattern",
"pattern": "found|appeared"
}
},
{
"_comment": "=== Layer 7: Long Chain Workflows (10 tasks) ==="
},
{
"name": "v2ex-chain-3-pages",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser eval \"document.title\"",
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser eval \"document.title\"",
"opencli browser open https://v2ex.com/go/python",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-chain-navigate-extract-back",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){var t=a.textContent.trim();a.click();return t;}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"document.querySelector('h1')?.textContent?.trim()||document.title\"",
"opencli browser back",
"opencli browser wait time 1",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "contains",
"value": "V2EX"
}
},
{
"name": "v2ex-chain-multi-node-scroll",
"steps": [
"opencli browser open https://v2ex.com/go/python",
"opencli browser scroll down --amount 500",
"opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\"",
"opencli browser open https://v2ex.com/go/go",
"opencli browser scroll down --amount 500",
"opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d+"
}
},
{
"name": "v2ex-chain-topic-replies-pagination",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(function(){var links=document.querySelectorAll('a[href^=\\\"/t/\\\"]');for(var i=0;i<links.length;i++){var row=links[i].closest('tr')||links[i].parentElement;var count=row?.querySelector('a[class*=\\\"count\\\"]');if(count&&parseInt(count.textContent)>5){links[i].click();return 'clicked topic with '+count.textContent+' replies';}}return 'no high-reply topic';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"document.querySelectorAll('.reply_content').length\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d+"
}
},
{
"name": "v2ex-chain-member-topics",
"steps": [
"opencli browser open https://v2ex.com/member/Livid",
"opencli browser eval \"document.querySelector('h1')?.textContent?.trim()\"",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,3).map(a=>a.textContent.trim()))\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-chain-search-navigate-extract",
"steps": [
"opencli browser open https://www.google.com/search?q=site:v2ex.com+Python",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var links=[...document.querySelectorAll('a')];var v2exLink=links.find(a=>a.href&&a.href.includes('v2ex.com/t/'));if(v2exLink){v2exLink.click();return 'clicked';}return 'no v2ex link found';})()\"",
"opencli browser wait time 3",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-chain-tab-topic-author",
"steps": [
"opencli browser open https://v2ex.com/?tab=tech",
"opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var author=document.querySelector('.header a[href^=\\\"/member/\\\"]');if(author){var name=author.textContent.trim();author.click();return name;}return 'no author';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"document.querySelector('h1')?.textContent?.trim()||'no h1'\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-chain-node-page2-extract",
"steps": [
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,2).map(a=>a.textContent.trim()))\"",
"opencli browser open https://v2ex.com/go/programmer?p=2",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,2).map(a=>a.textContent.trim()))\"",
"opencli browser open https://v2ex.com/go/programmer?p=3",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(0,2).map(a=>a.textContent.trim()))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 1
}
},
{
"name": "v2ex-chain-full-interaction",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser state",
"opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser state",
"opencli browser eval \"(function(){var ta=document.querySelector('textarea#reply_content');if(ta)return 'reply form found';return 'no reply form';})()\"",
"opencli browser eval \"JSON.stringify({title:document.querySelector('h1')?.textContent?.trim()||document.title,replies:document.querySelectorAll('.reply_content').length})\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"title\":"
}
},
{
"name": "v2ex-chain-deep-5-step",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser eval \"document.querySelectorAll('a[href^=\\\"/go/\\\"]').length\"",
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\"",
"opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"document.querySelectorAll('.reply_content').length\"",
"opencli browser back",
"opencli browser eval \"document.querySelectorAll('a[href^=\\\"/t/\\\"]').length\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d+"
}
},
{
"_comment": "=== Edge Cases: SPA navigation, timing, dynamic content ==="
},
{
"name": "v2ex-rapid-navigate",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser open https://v2ex.com/go/python",
"opencli browser eval \"location.pathname\""
],
"judge": {
"type": "contains",
"value": "/go/python"
}
},
{
"name": "v2ex-eval-after-click",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 1",
"opencli browser eval \"location.pathname.startsWith('/t/') ? 'on topic page' : 'wrong page: '+location.pathname\""
],
"judge": {
"type": "contains",
"value": "on topic page"
}
},
{
"name": "v2ex-scroll-and-extract",
"steps": [
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser scroll down --amount 2000",
"opencli browser wait time 1",
"opencli browser eval \"JSON.stringify([...document.querySelectorAll('a[href^=\\\"/t/\\\"]')].slice(-3).map(a=>a.textContent.trim().slice(0,30)))\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 2
}
},
{
"name": "v2ex-concurrent-eval",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser eval \"JSON.stringify({title:document.title,url:location.href,links:document.querySelectorAll('a').length})\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"title\":.*\"url\":.*\"links\":"
}
},
{
"name": "v2ex-unicode-content",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser eval \"(function(){var a=document.querySelector('a[href^=\\\"/t/\\\"]');return a?a.textContent.trim():'none';})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"_comment": "=== Agent-Style: state + click + type (no eval for interaction) ==="
},
{
"name": "v2ex-agent-click-first-topic",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser state",
"opencli browser eval \"(function(){var links=document.querySelectorAll('[data-opencli-ref]');for(var i=0;i<links.length;i++){if(links[i].pathname&&links[i].pathname.startsWith('/t/'))return links[i].getAttribute('data-opencli-ref');}return 'none';})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d+"
},
"note": "Finds the index of first topic link via data-opencli-ref"
},
{
"name": "v2ex-agent-type-search",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser state",
"opencli browser type 3 TypeScript",
"opencli browser get value 3"
],
"judge": {
"type": "contains",
"value": "TypeScript"
},
"note": "Types into search box using state index"
},
{
"name": "v2ex-agent-click-navigate-back",
"steps": [
"opencli browser open https://v2ex.com/?tab=hot",
"opencli browser state",
"opencli browser eval \"(function(){var links=document.querySelectorAll('[data-opencli-ref]');for(var i=0;i<links.length;i++){if(links[i].pathname&&links[i].pathname.startsWith('/t/')){var ref=links[i].getAttribute('data-opencli-ref');document.querySelector('[data-opencli-ref=\\\"'+ref+'\\\"]').click();return 'clicked '+ref;}}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "v2ex-agent-state-has-interactive",
"steps": [
"opencli browser open https://v2ex.com/",
"opencli browser state"
],
"judge": {
"type": "matchesPattern",
"pattern": "interactive: \\d+"
}
},
{
"name": "v2ex-agent-state-after-scroll",
"steps": [
"opencli browser open https://v2ex.com/go/programmer",
"opencli browser scroll down --amount 800",
"opencli browser state"
],
"judge": {
"type": "matchesPattern",
"pattern": "page_scroll: [\\d.]+↑"
}
}
]
+848
View File
@@ -0,0 +1,848 @@
[
{
"_comment": "=== L1: Atomic Operations (10 tasks) ==="
},
{
"name": "zhihu-open-home",
"steps": [
"opencli browser open https://www.zhihu.com/"
],
"judge": {
"type": "contains",
"value": "Navigated to"
}
},
{
"name": "zhihu-get-title",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "contains",
"value": "知乎"
}
},
{
"name": "zhihu-state",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser state"
],
"judge": {
"type": "matchesPattern",
"pattern": "\\[@?\\d+\\]"
}
},
{
"name": "zhihu-get-url",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser get url"
],
"judge": {
"type": "contains",
"value": "zhihu.com/hot"
}
},
{
"name": "zhihu-scroll-down",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser scroll down --amount 500",
"opencli browser eval \"window.scrollY > 100 ? 'scrolled' : 'not scrolled'\""
],
"judge": {
"type": "contains",
"value": "scrolled"
}
},
{
"name": "zhihu-click-tab-hot",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser eval \"(function(){var a=document.querySelector('nav a[href*=hot]');if(a){a.click();return 'clicked';}return 'not found';})()\""
],
"judge": {
"type": "contains",
"value": "clicked"
}
},
{
"name": "zhihu-back-navigation",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser open https://www.zhihu.com/hot",
"opencli browser back",
"opencli browser get url"
],
"judge": {
"type": "matchesPattern",
"pattern": "zhihu\\.com/?$"
}
},
{
"name": "zhihu-wait-page-load",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser wait text 推荐",
"opencli browser eval \"document.querySelector('nav')?.textContent?.includes('推荐') ? 'loaded' : 'empty'\""
],
"judge": {
"type": "contains",
"value": "loaded"
}
},
{
"name": "zhihu-keys-escape",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser keys Escape"
],
"judge": {
"type": "matchesPattern",
"pattern": "pressed|Pressed"
}
},
{
"name": "zhihu-screenshot",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser screenshot /tmp/zhihu-test.png"
],
"judge": {
"type": "nonEmpty"
}
},
{
"_comment": "=== L2: Homepage & Feed Extraction (8 tasks) ==="
},
{
"name": "zhihu-feed-titles",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser eval \"(function(){var items=document.querySelectorAll('h2.ContentItem-title a, .ContentItem-title a');var r=[];for(var i=0;i<Math.min(items.length,5);i++){r.push(items[i].textContent.trim().slice(0,60));}return JSON.stringify(r);})()\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "zhihu-hot-list",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var items=document.querySelectorAll('.HotItem-content a');var r=[];for(var i=0;i<Math.min(items.length,5);i++){r.push({title:items[i].textContent.trim().slice(0,50),href:items[i].pathname});}return JSON.stringify(r);})()\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 5
}
},
{
"name": "zhihu-hot-metrics",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var metrics=document.querySelectorAll('.HotItem-metrics');var r=[];for(var i=0;i<Math.min(metrics.length,5);i++){r.push(metrics[i].textContent.trim());}return JSON.stringify(r);})()\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "zhihu-nav-tabs",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser eval \"(function(){var tabs=document.querySelectorAll('nav a');var r=[];for(var i=0;i<tabs.length;i++){r.push(tabs[i].textContent.trim());}return JSON.stringify(r);})()\""
],
"judge": {
"type": "contains",
"value": "推荐"
}
},
{
"name": "zhihu-feed-with-authors",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser eval \"(function(){var items=document.querySelectorAll('.ContentItem');var r=[];for(var i=0;i<Math.min(items.length,3);i++){var title=items[i].querySelector('h2 a')?.textContent?.trim()||'';var author=items[i].querySelector('.AuthorInfo-name')?.textContent?.trim()||'';if(title)r.push({title:title.slice(0,40),author:author});}return JSON.stringify(r);})()\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 2
}
},
{
"name": "zhihu-feed-types",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser eval \"(function(){var links=document.querySelectorAll('h2.ContentItem-title a, .ContentItem-title a');var types={question:0,article:0,other:0};for(var i=0;i<links.length;i++){var h=links[i].pathname||'';if(h.includes('/question/'))types.question++;else if(h.includes('/p/'))types.article++;else types.other++;}return JSON.stringify(types);})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"question\":\\d+"
}
},
{
"name": "zhihu-user-avatar",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser eval \"(function(){var img=document.querySelector('img[alt*=\\\"头像\\\"],img[alt*=\\\"主页\\\"],img[class*=\\\"Avatar\\\"]');return img?img.src:'no avatar';})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-search-input-exists",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser eval \"(function(){var input=document.querySelector('input[role=combobox],input[type=search]');return input?'search found':'no search';})()\""
],
"judge": {
"type": "contains",
"value": "search found"
}
},
{
"_comment": "=== L3: Question Page Operations (8 tasks) ==="
},
{
"name": "zhihu-question-title",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');return a?a.href:'none';})()\"",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"document.querySelector('.QuestionHeader-title')?.textContent?.trim()?.slice(0,80)||document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-question-meta",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var title=document.querySelector('.QuestionHeader-title')?.textContent?.trim()||'';var answerCount=document.querySelector('.List-headerText')?.textContent?.trim()||'';var followers=document.querySelector('[class*=FollowButton]')?.textContent?.trim()||'';return JSON.stringify({title:title.slice(0,60),answerCount:answerCount,followers:followers});})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"title\":"
}
},
{
"name": "zhihu-first-answer",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var content=document.querySelector('.RichContent-inner')?.textContent?.trim()?.slice(0,200)||'';var author=document.querySelector('.AuthorInfo-name')?.textContent?.trim()||'';return JSON.stringify({author:author,content:content});})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"content\":"
}
},
{
"name": "zhihu-answer-votes",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var btns=document.querySelectorAll('button[class*=VoteButton]');var r=[];for(var i=0;i<Math.min(btns.length,6);i++){var label=btns[i].getAttribute('aria-label')||btns[i].textContent.trim();if(label)r.push(label.slice(0,30));}return JSON.stringify(r);})()\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 2
}
},
{
"name": "zhihu-question-buttons",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var btns=document.querySelectorAll('button');var r=[];for(var i=0;i<btns.length;i++){var t=btns[i].textContent.trim();if(t.length>0&&t.length<25)r.push(t);}return JSON.stringify(r.slice(0,15));})()\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "zhihu-multiple-answers",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var answers=document.querySelectorAll('.List-item .RichContent-inner');var r=[];for(var i=0;i<Math.min(answers.length,3);i++){r.push(answers[i].textContent.trim().slice(0,80));}return JSON.stringify(r);})()\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 1
}
},
{
"name": "zhihu-question-description",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var desc=document.querySelector('.QuestionRichText')?.textContent?.trim()?.slice(0,200)||'no description';return desc;})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-answer-count-number",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var header=document.querySelector('.List-headerText');if(!header)return '0';var m=header.textContent.match(/\\\\d+/);return m?m[0]:'0';})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d+"
}
},
{
"_comment": "=== L4: Multi-Step Navigation (8 tasks) ==="
},
{
"name": "zhihu-hot-to-question",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){a.click();return 'clicked: '+a.textContent.trim().slice(0,30);}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"document.querySelector('.QuestionHeader-title')?.textContent?.trim()?.slice(0,80)||document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-feed-to-question",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser eval \"(function(){var a=document.querySelector('h2.ContentItem-title a');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 3",
"opencli browser eval \"document.querySelector('.QuestionHeader-title')?.textContent?.trim()?.slice(0,80)||document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-question-to-author",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var author=document.querySelector('.AuthorInfo-name a, .UserLink-link');if(author){var name=author.textContent.trim();window.location.href=author.href;return name;}return 'no author';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-search-navigate",
"steps": [
"opencli browser open https://www.zhihu.com/search?type=content&q=TypeScript",
"opencli browser wait time 5",
"opencli browser scroll down --amount 300",
"opencli browser wait time 1",
"opencli browser eval \"(function(){var items=document.querySelectorAll('h2 a');var r=[];var seen={};for(var i=0;i<items.length;i++){var t=items[i].textContent.trim();if(t.length>5&&t.length<100&&!seen[t]){seen[t]=1;r.push(t.slice(0,50));}}return JSON.stringify(r.slice(0,5));})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-topic-page",
"steps": [
"opencli browser open https://www.zhihu.com/topic/19552832/hot",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var title=document.querySelector('.TopicName, .ContentItem-title, h1')?.textContent?.trim()||document.title;return title;})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-user-profile",
"steps": [
"opencli browser open https://www.zhihu.com/people/excited-vczh",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var name=document.querySelector('.ProfileHeader-title .ProfileHeader-name')?.textContent?.trim()||document.querySelector('h1')?.textContent?.trim()||'';var bio=document.querySelector('.ProfileHeader-headline')?.textContent?.trim()||'';return JSON.stringify({name:name,bio:bio.slice(0,100)});})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"name\":"
}
},
{
"name": "zhihu-question-and-back",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 3",
"opencli browser open https://www.zhihu.com/hot",
"opencli browser get url"
],
"judge": {
"type": "contains",
"value": "zhihu.com/hot"
}
},
{
"name": "zhihu-scroll-load-more",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"document.querySelectorAll('.HotItem-content').length\"",
"opencli browser scroll down --amount 2000",
"opencli browser wait time 1",
"opencli browser eval \"document.querySelectorAll('.HotItem-content').length\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d+"
}
},
{
"_comment": "=== L5: Write Operations (6 tasks, requires login) ==="
},
{
"name": "zhihu-upvote-button-find",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var btn=document.querySelector('button[aria-label*=赞同]');return btn?JSON.stringify({text:btn.textContent.trim(),ariaLabel:btn.getAttribute('aria-label')}):'no upvote button';})()\""
],
"judge": {
"type": "contains",
"value": "赞同"
},
"note": "Finds upvote button but does NOT click"
},
{
"name": "zhihu-follow-question-find",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var btns=document.querySelectorAll('button');for(var i=0;i<btns.length;i++){if(btns[i].textContent.includes('关注问题'))return 'found: '+btns[i].textContent.trim();}return 'not found';})()\""
],
"judge": {
"type": "contains",
"value": "关注问题"
},
"note": "Finds follow button but does NOT click"
},
{
"name": "zhihu-comment-button-find",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var btns=document.querySelectorAll('button');for(var i=0;i<btns.length;i++){if(btns[i].textContent.includes('评论'))return 'found: '+btns[i].textContent.trim();}return 'not found';})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "评论"
},
"note": "Finds comment button but does NOT click"
},
{
"name": "zhihu-bookmark-find",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var btns=document.querySelectorAll('button');for(var i=0;i<btns.length;i++){var t=btns[i].textContent.trim();if(t.includes('收藏')||t.includes('Bookmark'))return 'found: '+t;}return 'not found';})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "收藏|found"
},
"note": "Finds bookmark button but does NOT click"
},
{
"name": "zhihu-write-answer-btn",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var btns=document.querySelectorAll('button');for(var i=0;i<btns.length;i++){if(btns[i].textContent.includes('写回答'))return 'found: '+btns[i].textContent.trim();}return 'not found';})()\""
],
"judge": {
"type": "contains",
"value": "写回答"
},
"note": "Finds write answer button but does NOT click"
},
{
"name": "zhihu-share-find",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var btns=document.querySelectorAll('button');for(var i=0;i<btns.length;i++){if(btns[i].textContent.includes('分享'))return 'found: '+btns[i].textContent.trim();}return 'not found';})()\""
],
"judge": {
"type": "contains",
"value": "分享"
},
"note": "Finds share button but does NOT click"
},
{
"_comment": "=== L6: Long Chain Workflows (8 tasks) ==="
},
{
"name": "zhihu-hot-read-answer-author",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var author=document.querySelector('.AuthorInfo-name')?.textContent?.trim()||'';var content=document.querySelector('.RichContent-inner')?.textContent?.trim()?.slice(0,100)||'';return JSON.stringify({author:author,content:content});})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"author\":"
}
},
{
"name": "zhihu-hot-to-author-profile",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var link=document.querySelector('.AuthorInfo-name a, .UserLink-link');if(link){window.location.href=link.href;return 'going to author';}return 'no author link';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var name=document.querySelector('h1, .ProfileHeader-name')?.textContent?.trim()||document.title;return name;})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-multi-hot-topics",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var items=document.querySelectorAll('.HotItem-content a');var r=[];for(var i=0;i<Math.min(items.length,3);i++){r.push(items[i].textContent.trim().slice(0,40));}return JSON.stringify(r);})()\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "zhihu-search-then-read",
"steps": [
"opencli browser open https://www.zhihu.com/search?type=content&q=Python",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var a=document.querySelector('.ContentItem-title a, .SearchResult-Card h2 a');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 3",
"opencli browser eval \"document.querySelector('.QuestionHeader-title, h1')?.textContent?.trim()?.slice(0,80)||document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-question-scroll-answers",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser scroll down --amount 1000",
"opencli browser wait time 1",
"opencli browser eval \"document.querySelectorAll('.RichContent-inner').length\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d+"
}
},
{
"name": "zhihu-compare-tabs",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser eval \"(function(){var a=document.querySelector('h2.ContentItem-title a');return a?a.textContent.trim().slice(0,40):'none';})()\"",
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');return a?a.textContent.trim().slice(0,40):'none';})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-user-answers",
"steps": [
"opencli browser open https://www.zhihu.com/people/excited-vczh/answers",
"opencli browser wait time 4",
"opencli browser eval \"(function(){var items=document.querySelectorAll('h2 a, [class*=title] a, [class*=Title] a');var r=[];for(var i=0;i<items.length;i++){var t=items[i].textContent.trim();if(t.length>10&&t.length<100)r.push(t.slice(0,50));}return JSON.stringify(r.slice(0,3));})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-topic-questions",
"steps": [
"opencli browser open https://www.zhihu.com/topic/19552832/hot",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var items=document.querySelectorAll('.ContentItem-title a, h2 a');var r=[];for(var i=0;i<Math.min(items.length,3);i++){var t=items[i].textContent.trim();if(t.length>5)r.push(t.slice(0,50));}return JSON.stringify(r);})()\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 1
}
},
{
"_comment": "=== L7: Search Workflows (6 tasks) ==="
},
{
"name": "zhihu-search-basic",
"steps": [
"opencli browser open https://www.zhihu.com/search?type=content&q=AI",
"opencli browser wait time 5",
"opencli browser scroll down --amount 300",
"opencli browser wait time 1",
"opencli browser eval \"(function(){var items=document.querySelectorAll('h2 a');var r=[];var seen={};for(var i=0;i<items.length;i++){var t=items[i].textContent.trim();if(t.length>5&&t.length<100&&!seen[t]){seen[t]=1;r.push(t.slice(0,50));}}return JSON.stringify(r.slice(0,5));})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-search-people",
"steps": [
"opencli browser open https://www.zhihu.com/search?type=people&q=Python",
"opencli browser wait time 3",
"opencli browser eval \"(function(){var items=document.querySelectorAll('[class*=UserItem] a, [class*=user] a, .List-item a');var r=[];for(var i=0;i<Math.min(items.length,10);i++){var t=items[i].textContent.trim();if(t.length>1&&t.length<30)r.push(t);}return JSON.stringify(r.slice(0,3));})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-search-topic",
"steps": [
"opencli browser open https://www.zhihu.com/search?type=topic&q=编程",
"opencli browser wait time 3",
"opencli browser eval \"(function(){var items=document.querySelectorAll('a');var r=[];for(var i=0;i<items.length;i++){var t=items[i].textContent.trim();if(t.length>2&&t.length<30&&(t.includes('编程')||items[i].pathname?.includes('/topic/')))r.push(t);}return JSON.stringify(r.slice(0,3));})()\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-search-click-result",
"steps": [
"opencli browser open https://www.zhihu.com/search?type=content&q=Rust编程",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var a=document.querySelector('.ContentItem-title a, h2 a');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 3",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-search-filter-answers",
"steps": [
"opencli browser open https://www.zhihu.com/search?type=content&q=Docker",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var items=document.querySelectorAll('.ContentItem');return JSON.stringify({total:items.length,hasAnswers:items.length>0});})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"total\":\\d+"
}
},
{
"name": "zhihu-search-and-back",
"steps": [
"opencli browser open https://www.zhihu.com/search?type=content&q=前端开发",
"opencli browser wait time 5",
"opencli browser eval \"(function(){var a=document.querySelector('h2 a, [class*=title] a');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser open https://www.zhihu.com/search?type=content&q=前端开发",
"opencli browser wait time 3",
"opencli browser get url"
],
"judge": {
"type": "contains",
"value": "search"
}
},
{
"_comment": "=== L8: Complex Long Chain (6 tasks) ==="
},
{
"name": "zhihu-full-browse-workflow",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var items=document.querySelectorAll('.HotItem-content a');var r=[];for(var i=0;i<Math.min(items.length,3);i++){r.push(items[i].textContent.trim().slice(0,30));}return JSON.stringify(r);})()\"",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var title=document.querySelector('.QuestionHeader-title')?.textContent?.trim()?.slice(0,60)||'';var answers=document.querySelectorAll('.RichContent-inner').length;return JSON.stringify({title:title,answers:answers});})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"title\":"
}
},
{
"name": "zhihu-deep-author-chain",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'step1';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var link=document.querySelector('.AuthorInfo-name a');if(link){var name=link.textContent.trim();window.location.href=link.href;return 'step2: '+name;}return 'no author';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var answers=document.querySelectorAll('.ContentItem-title a');var r=[];for(var i=0;i<Math.min(answers.length,2);i++){r.push(answers[i].textContent.trim().slice(0,40));}return JSON.stringify({profile:document.title,recentAnswers:r});})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"profile\":"
}
},
{
"name": "zhihu-cross-question-compare",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var items=document.querySelectorAll('.HotItem-content a');return items.length>=2?JSON.stringify([items[0].textContent.trim().slice(0,30),items[1].textContent.trim().slice(0,30)]):'not enough';})()\"",
"opencli browser eval \"(function(){var a=document.querySelectorAll('.HotItem-content a')[0];if(a){window.location.href=a.href;return 'q1';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){return JSON.stringify({q1_title:document.querySelector('.QuestionHeader-title')?.textContent?.trim()?.slice(0,40)||'',q1_answers:document.querySelectorAll('.RichContent-inner').length});})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"q1_title\":"
}
},
{
"name": "zhihu-search-read-chain",
"steps": [
"opencli browser open https://www.zhihu.com/search?type=content&q=Claude",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var items=document.querySelectorAll('.ContentItem-title a, h2 a');var r=[];for(var i=0;i<Math.min(items.length,3);i++){r.push(items[i].textContent.trim().slice(0,40));}return JSON.stringify(r);})()\"",
"opencli browser eval \"(function(){var a=document.querySelector('.ContentItem-title a, h2 a');if(a){a.click();return 'clicked';}return 'none';})()\"",
"opencli browser wait time 3",
"opencli browser eval \"document.querySelector('.QuestionHeader-title, h1')?.textContent?.trim()?.slice(0,60)||document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-3-page-chain",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser eval \"document.title\"",
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"document.querySelectorAll('.HotItem-content').length\"",
"opencli browser open https://www.zhihu.com/people/excited-vczh",
"opencli browser wait time 2",
"opencli browser eval \"document.title\""
],
"judge": {
"type": "nonEmpty"
}
},
{
"name": "zhihu-hot-scroll-deep-read",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser scroll down --amount 1000",
"opencli browser eval \"document.querySelectorAll('.HotItem-content a').length\"",
"opencli browser eval \"(function(){var items=document.querySelectorAll('.HotItem-content a');var last=items[items.length-1];if(last){last.click();return 'clicked last';}return 'none';})()\"",
"opencli browser wait time 2",
"opencli browser eval \"(function(){var title=document.querySelector('.QuestionHeader-title')?.textContent?.trim()||document.title;var firstAnswer=document.querySelector('.RichContent-inner')?.textContent?.trim()?.slice(0,100)||'';return JSON.stringify({title:title.slice(0,60),firstAnswer:firstAnswer});})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"title\":"
}
},
{
"_comment": "=== Edge Cases: SPA lazy load, dynamic content ==="
},
{
"name": "zhihu-rapid-navigate",
"steps": [
"opencli browser open https://www.zhihu.com/",
"opencli browser open https://www.zhihu.com/hot",
"opencli browser open https://www.zhihu.com/people/excited-vczh",
"opencli browser wait time 2",
"opencli browser eval \"location.pathname\""
],
"judge": {
"type": "contains",
"value": "/people/"
}
},
{
"name": "zhihu-hot-click-verify-url",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 3",
"opencli browser eval \"location.pathname.startsWith('/question/') ? 'on question page' : 'wrong: '+location.pathname\""
],
"judge": {
"type": "contains",
"value": "on question page"
}
},
{
"name": "zhihu-scroll-lazy-answers",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 3",
"opencli browser eval \"document.querySelectorAll('.RichContent-inner').length\"",
"opencli browser scroll down --amount 2000",
"opencli browser wait time 2",
"opencli browser eval \"document.querySelectorAll('.RichContent-inner').length\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\\d+"
}
},
{
"name": "zhihu-extract-structured",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var items=document.querySelectorAll('.HotItem-content');var r=[];for(var i=0;i<Math.min(items.length,3);i++){var a=items[i].querySelector('a');var m=items[i].closest('[class*=HotItem]')?.querySelector('[class*=metrics]');r.push({title:(a?.textContent||'').trim().slice(0,40),heat:(m?.textContent||'').trim()});}return JSON.stringify(r);})()\""
],
"judge": {
"type": "arrayMinLength",
"minLength": 3
}
},
{
"name": "zhihu-question-answer-chain",
"steps": [
"opencli browser open https://www.zhihu.com/hot",
"opencli browser eval \"(function(){var a=document.querySelector('.HotItem-content a');if(a){window.location.href=a.href;return 'navigating';}return 'none';})()\"",
"opencli browser wait time 3",
"opencli browser eval \"(function(){var title=document.querySelector('.QuestionHeader-title')?.textContent?.trim()||'';var answers=document.querySelectorAll('.RichContent-inner');var first=answers[0]?.textContent?.trim()?.slice(0,100)||'';var count=answers.length;return JSON.stringify({title:title.slice(0,50),firstAnswer:first,answerCount:count});})()\""
],
"judge": {
"type": "matchesPattern",
"pattern": "\"answerCount\":\\d+"
}
}
]
+615
View File
@@ -0,0 +1,615 @@
{
"lockfileVersion": 1,
"configVersion": 0,
"workspaces": {
"": {
"name": "@jackwener/opencli",
"dependencies": {
"chalk": "^5.3.0",
"cli-table3": "^0.6.5",
"commander": "^14.0.3",
"js-yaml": "^4.1.0",
"turndown": "^7.2.2",
"undici": "^7.24.6",
"ws": "^8.18.0",
},
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.13.10",
"@types/turndown": "^5.0.6",
"@types/ws": "^8.5.13",
"tsx": "^4.19.3",
"typescript": "^6.0.2",
"vitepress": "^1.6.4",
"vitest": "^4.1.0",
},
},
},
"packages": {
"@algolia/abtesting": ["@algolia/abtesting@1.15.2", "", { "dependencies": { "@algolia/client-common": "5.49.2", "@algolia/requester-browser-xhr": "5.49.2", "@algolia/requester-fetch": "5.49.2", "@algolia/requester-node-http": "5.49.2" } }, "sha512-rF7vRVE61E0QORw8e2NNdnttcl3jmFMWS9B4hhdga12COe+lMa26bQLfcBn/Nbp9/AF/8gXdaRCPsVns3CnjsA=="],
"@algolia/autocomplete-core": ["@algolia/autocomplete-core@1.17.7", "", { "dependencies": { "@algolia/autocomplete-plugin-algolia-insights": "1.17.7", "@algolia/autocomplete-shared": "1.17.7" } }, "sha512-BjiPOW6ks90UKl7TwMv7oNQMnzU+t/wk9mgIDi6b1tXpUek7MW0lbNOUHpvam9pe3lVCf4xPFT+lK7s+e+fs7Q=="],
"@algolia/autocomplete-plugin-algolia-insights": ["@algolia/autocomplete-plugin-algolia-insights@1.17.7", "", { "dependencies": { "@algolia/autocomplete-shared": "1.17.7" }, "peerDependencies": { "search-insights": ">= 1 < 3" } }, "sha512-Jca5Ude6yUOuyzjnz57og7Et3aXjbwCSDf/8onLHSQgw1qW3ALl9mrMWaXb5FmPVkV3EtkD2F/+NkT6VHyPu9A=="],
"@algolia/autocomplete-preset-algolia": ["@algolia/autocomplete-preset-algolia@1.17.7", "", { "dependencies": { "@algolia/autocomplete-shared": "1.17.7" }, "peerDependencies": { "@algolia/client-search": ">= 4.9.1 < 6", "algoliasearch": ">= 4.9.1 < 6" } }, "sha512-ggOQ950+nwbWROq2MOCIL71RE0DdQZsceqrg32UqnhDz8FlO9rL8ONHNsI2R1MH0tkgVIDKI/D0sMiUchsFdWA=="],
"@algolia/autocomplete-shared": ["@algolia/autocomplete-shared@1.17.7", "", { "peerDependencies": { "@algolia/client-search": ">= 4.9.1 < 6", "algoliasearch": ">= 4.9.1 < 6" } }, "sha512-o/1Vurr42U/qskRSuhBH+VKxMvkkUVTLU6WZQr+L5lGZZLYWyhdzWjW0iGXY7EkwRTjBqvN2EsR81yCTGV/kmg=="],
"@algolia/client-abtesting": ["@algolia/client-abtesting@5.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2", "@algolia/requester-browser-xhr": "5.49.2", "@algolia/requester-fetch": "5.49.2", "@algolia/requester-node-http": "5.49.2" } }, "sha512-XyvKCm0RRmovMI/ChaAVjTwpZhXdbgt3iZofK914HeEHLqD1MUFFVLz7M0+Ou7F56UkHXwRbpHwb9xBDNopprQ=="],
"@algolia/client-analytics": ["@algolia/client-analytics@5.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2", "@algolia/requester-browser-xhr": "5.49.2", "@algolia/requester-fetch": "5.49.2", "@algolia/requester-node-http": "5.49.2" } }, "sha512-jq/3qvtmj3NijZlhq7A1B0Cl41GfaBpjJxcwukGsYds6aMSCWrEAJ9pUqw/C9B3hAmILYKl7Ljz3N9SFvekD3Q=="],
"@algolia/client-common": ["@algolia/client-common@5.49.2", "", {}, "sha512-bn0biLequn3epobCfjUqCxlIlurLr4RHu7RaE4trgN+RDcUq6HCVC3/yqq1hwbNYpVtulnTOJzcaxYlSr1fnuw=="],
"@algolia/client-insights": ["@algolia/client-insights@5.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2", "@algolia/requester-browser-xhr": "5.49.2", "@algolia/requester-fetch": "5.49.2", "@algolia/requester-node-http": "5.49.2" } }, "sha512-z14wfFs1T3eeYbCArC8pvntAWsPo9f6hnUGoj8IoRUJTwgJiiySECkm8bmmV47/x0oGHfsVn3kBdjMX0yq0sNA=="],
"@algolia/client-personalization": ["@algolia/client-personalization@5.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2", "@algolia/requester-browser-xhr": "5.49.2", "@algolia/requester-fetch": "5.49.2", "@algolia/requester-node-http": "5.49.2" } }, "sha512-GpRf7yuuAX93+Qt0JGEJZwgtL0MFdjFO9n7dn8s2pA9mTjzl0Sc5+uTk1VPbIAuf7xhCP9Mve+URGb6J+EYxgA=="],
"@algolia/client-query-suggestions": ["@algolia/client-query-suggestions@5.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2", "@algolia/requester-browser-xhr": "5.49.2", "@algolia/requester-fetch": "5.49.2", "@algolia/requester-node-http": "5.49.2" } }, "sha512-HZwApmNkp0DiAjZcLYdQLddcG4Agb88OkojiAHGgcm5DVXobT5uSZ9lmyrbw/tmQBJwgu2CNw4zTyXoIB7YbPA=="],
"@algolia/client-search": ["@algolia/client-search@5.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2", "@algolia/requester-browser-xhr": "5.49.2", "@algolia/requester-fetch": "5.49.2", "@algolia/requester-node-http": "5.49.2" } }, "sha512-y1IOpG6OSmTpGg/CT0YBb/EAhR2nsC18QWp9Jy8HO9iGySpcwaTvs5kHa17daP3BMTwWyaX9/1tDTDQshZzXdg=="],
"@algolia/ingestion": ["@algolia/ingestion@1.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2", "@algolia/requester-browser-xhr": "5.49.2", "@algolia/requester-fetch": "5.49.2", "@algolia/requester-node-http": "5.49.2" } }, "sha512-YYJRjaZ2bqk923HxE4um7j/Cm3/xoSkF2HC2ZweOF8cXL3sqnlndSUYmCaxHFjNPWLaSHk2IfssX6J/tdKTULw=="],
"@algolia/monitoring": ["@algolia/monitoring@1.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2", "@algolia/requester-browser-xhr": "5.49.2", "@algolia/requester-fetch": "5.49.2", "@algolia/requester-node-http": "5.49.2" } }, "sha512-9WgH+Dha39EQQyGKCHlGYnxW/7W19DIrEbCEbnzwAMpGAv1yTWCHMPXHxYa+LcL3eCp2V/5idD1zHNlIKmHRHg=="],
"@algolia/recommend": ["@algolia/recommend@5.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2", "@algolia/requester-browser-xhr": "5.49.2", "@algolia/requester-fetch": "5.49.2", "@algolia/requester-node-http": "5.49.2" } }, "sha512-K7Gp5u+JtVYgaVpBxF5rGiM+Ia8SsMdcAJMTDV93rwh00DKNllC19o1g+PwrDjDvyXNrnTEbofzbTs2GLfFyKA=="],
"@algolia/requester-browser-xhr": ["@algolia/requester-browser-xhr@5.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2" } }, "sha512-3UhYCcWX6fbtN8ABcxZlhaQEwXFh3CsFtARyyadQShHMPe3mJV9Wel4FpJTa+seugRkbezFz0tt6aPTZSYTBuA=="],
"@algolia/requester-fetch": ["@algolia/requester-fetch@5.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2" } }, "sha512-G94VKSGbsr+WjsDDOBe5QDQ82QYgxvpxRGJfCHZBnYKYsy/jv9qGIDb93biza+LJWizQBUtDj7bZzp3QZyzhPQ=="],
"@algolia/requester-node-http": ["@algolia/requester-node-http@5.49.2", "", { "dependencies": { "@algolia/client-common": "5.49.2" } }, "sha512-UuihBGHafG/ENsrcTGAn5rsOffrCIRuHMOsD85fZGLEY92ate+BMTUqxz60dv5zerh8ZumN4bRm8eW2z9L11jA=="],
"@babel/helper-string-parser": ["@babel/helper-string-parser@7.27.1", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
"@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.28.5", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
"@babel/parser": ["@babel/parser@7.29.2", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": { "parser": "bin/babel-parser.js" } }, "sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA=="],
"@babel/types": ["@babel/types@7.29.0", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
"@colors/colors": ["@colors/colors@1.5.0", "", {}, "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ=="],
"@docsearch/css": ["@docsearch/css@3.8.2", "", {}, "sha512-y05ayQFyUmCXze79+56v/4HpycYF3uFqB78pLPrSV5ZKAlDuIAAJNhaRi8tTdRNXh05yxX/TyNnzD6LwSM89vQ=="],
"@docsearch/js": ["@docsearch/js@3.8.2", "", { "dependencies": { "@docsearch/react": "3.8.2", "preact": "^10.0.0" } }, "sha512-Q5wY66qHn0SwA7Taa0aDbHiJvaFJLOJyHmooQ7y8hlwwQLQ/5WwCcoX0g7ii04Qi2DJlHsd0XXzJ8Ypw9+9YmQ=="],
"@docsearch/react": ["@docsearch/react@3.8.2", "", { "dependencies": { "@algolia/autocomplete-core": "1.17.7", "@algolia/autocomplete-preset-algolia": "1.17.7", "@docsearch/css": "3.8.2", "algoliasearch": "^5.14.2" }, "peerDependencies": { "@types/react": ">= 16.8.0 < 19.0.0", "react": ">= 16.8.0 < 19.0.0", "react-dom": ">= 16.8.0 < 19.0.0", "search-insights": ">= 1 < 3" }, "optionalPeers": ["@types/react", "react", "react-dom"] }, "sha512-xCRrJQlTt8N9GU0DG4ptwHRkfnSnD/YpdeaXe02iKfqs97TkZJv60yE+1eq/tjPcVnTW8dP5qLP7itifFVV5eg=="],
"@emnapi/core": ["@emnapi/core@1.9.1", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.0", "tslib": "^2.4.0" } }, "sha512-mukuNALVsoix/w1BJwFzwXBN/dHeejQtuVzcDsfOEsdpCumXb/E9j8w11h5S54tT1xhifGfbbSm/ICrObRb3KA=="],
"@emnapi/runtime": ["@emnapi/runtime@1.9.1", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-VYi5+ZVLhpgK4hQ0TAjiQiZ6ol0oe4mBx7mVv7IflsiEp0OWoVsp/+f9Vc1hOhE0TtkORVrI1GvzyreqpgWtkA=="],
"@emnapi/wasi-threads": ["@emnapi/wasi-threads@1.2.0", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-N10dEJNSsUx41Z6pZsXU8FjPjpBEplgH24sfkmITrBED1/U2Esum9F3lfLrMjKHHjmi557zQn7kR9R+XWXu5Rg=="],
"@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.27.4", "", { "os": "aix", "cpu": "ppc64" }, "sha512-cQPwL2mp2nSmHHJlCyoXgHGhbEPMrEEU5xhkcy3Hs/O7nGZqEpZ2sUtLaL9MORLtDfRvVl2/3PAuEkYZH0Ty8Q=="],
"@esbuild/android-arm": ["@esbuild/android-arm@0.27.4", "", { "os": "android", "cpu": "arm" }, "sha512-X9bUgvxiC8CHAGKYufLIHGXPJWnr0OCdR0anD2e21vdvgCI8lIfqFbnoeOz7lBjdrAGUhqLZLcQo6MLhTO2DKQ=="],
"@esbuild/android-arm64": ["@esbuild/android-arm64@0.27.4", "", { "os": "android", "cpu": "arm64" }, "sha512-gdLscB7v75wRfu7QSm/zg6Rx29VLdy9eTr2t44sfTW7CxwAtQghZ4ZnqHk3/ogz7xao0QAgrkradbBzcqFPasw=="],
"@esbuild/android-x64": ["@esbuild/android-x64@0.27.4", "", { "os": "android", "cpu": "x64" }, "sha512-PzPFnBNVF292sfpfhiyiXCGSn9HZg5BcAz+ivBuSsl6Rk4ga1oEXAamhOXRFyMcjwr2DVtm40G65N3GLeH1Lvw=="],
"@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.27.4", "", { "os": "darwin", "cpu": "arm64" }, "sha512-b7xaGIwdJlht8ZFCvMkpDN6uiSmnxxK56N2GDTMYPr2/gzvfdQN8rTfBsvVKmIVY/X7EM+/hJKEIbbHs9oA4tQ=="],
"@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.27.4", "", { "os": "darwin", "cpu": "x64" }, "sha512-sR+OiKLwd15nmCdqpXMnuJ9W2kpy0KigzqScqHI3Hqwr7IXxBp3Yva+yJwoqh7rE8V77tdoheRYataNKL4QrPw=="],
"@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.27.4", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-jnfpKe+p79tCnm4GVav68A7tUFeKQwQyLgESwEAUzyxk/TJr4QdGog9sqWNcUbr/bZt/O/HXouspuQDd9JxFSw=="],
"@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.27.4", "", { "os": "freebsd", "cpu": "x64" }, "sha512-2kb4ceA/CpfUrIcTUl1wrP/9ad9Atrp5J94Lq69w7UwOMolPIGrfLSvAKJp0RTvkPPyn6CIWrNy13kyLikZRZQ=="],
"@esbuild/linux-arm": ["@esbuild/linux-arm@0.27.4", "", { "os": "linux", "cpu": "arm" }, "sha512-aBYgcIxX/wd5n2ys0yESGeYMGF+pv6g0DhZr3G1ZG4jMfruU9Tl1i2Z+Wnj9/KjGz1lTLCcorqE2viePZqj4Eg=="],
"@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.27.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-7nQOttdzVGth1iz57kxg9uCz57dxQLHWxopL6mYuYthohPKEK0vU0C3O21CcBK6KDlkYVcnDXY099HcCDXd9dA=="],
"@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.27.4", "", { "os": "linux", "cpu": "ia32" }, "sha512-oPtixtAIzgvzYcKBQM/qZ3R+9TEUd1aNJQu0HhGyqtx6oS7qTpvjheIWBbes4+qu1bNlo2V4cbkISr8q6gRBFA=="],
"@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.27.4", "", { "os": "linux", "cpu": "none" }, "sha512-8mL/vh8qeCoRcFH2nM8wm5uJP+ZcVYGGayMavi8GmRJjuI3g1v6Z7Ni0JJKAJW+m0EtUuARb6Lmp4hMjzCBWzA=="],
"@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.27.4", "", { "os": "linux", "cpu": "none" }, "sha512-1RdrWFFiiLIW7LQq9Q2NES+HiD4NyT8Itj9AUeCl0IVCA459WnPhREKgwrpaIfTOe+/2rdntisegiPWn/r/aAw=="],
"@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.27.4", "", { "os": "linux", "cpu": "ppc64" }, "sha512-tLCwNG47l3sd9lpfyx9LAGEGItCUeRCWeAx6x2Jmbav65nAwoPXfewtAdtbtit/pJFLUWOhpv0FpS6GQAmPrHA=="],
"@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.27.4", "", { "os": "linux", "cpu": "none" }, "sha512-BnASypppbUWyqjd1KIpU4AUBiIhVr6YlHx/cnPgqEkNoVOhHg+YiSVxM1RLfiy4t9cAulbRGTNCKOcqHrEQLIw=="],
"@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.27.4", "", { "os": "linux", "cpu": "s390x" }, "sha512-+eUqgb/Z7vxVLezG8bVB9SfBie89gMueS+I0xYh2tJdw3vqA/0ImZJ2ROeWwVJN59ihBeZ7Tu92dF/5dy5FttA=="],
"@esbuild/linux-x64": ["@esbuild/linux-x64@0.27.4", "", { "os": "linux", "cpu": "x64" }, "sha512-S5qOXrKV8BQEzJPVxAwnryi2+Iq5pB40gTEIT69BQONqR7JH1EPIcQ/Uiv9mCnn05jff9umq/5nqzxlqTOg9NA=="],
"@esbuild/netbsd-arm64": ["@esbuild/netbsd-arm64@0.27.4", "", { "os": "none", "cpu": "arm64" }, "sha512-xHT8X4sb0GS8qTqiwzHqpY00C95DPAq7nAwX35Ie/s+LO9830hrMd3oX0ZMKLvy7vsonee73x0lmcdOVXFzd6Q=="],
"@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.27.4", "", { "os": "none", "cpu": "x64" }, "sha512-RugOvOdXfdyi5Tyv40kgQnI0byv66BFgAqjdgtAKqHoZTbTF2QqfQrFwa7cHEORJf6X2ht+l9ABLMP0dnKYsgg=="],
"@esbuild/openbsd-arm64": ["@esbuild/openbsd-arm64@0.27.4", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-2MyL3IAaTX+1/qP0O1SwskwcwCoOI4kV2IBX1xYnDDqthmq5ArrW94qSIKCAuRraMgPOmG0RDTA74mzYNQA9ow=="],
"@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.27.4", "", { "os": "openbsd", "cpu": "x64" }, "sha512-u8fg/jQ5aQDfsnIV6+KwLOf1CmJnfu1ShpwqdwC0uA7ZPwFws55Ngc12vBdeUdnuWoQYx/SOQLGDcdlfXhYmXQ=="],
"@esbuild/openharmony-arm64": ["@esbuild/openharmony-arm64@0.27.4", "", { "os": "none", "cpu": "arm64" }, "sha512-JkTZrl6VbyO8lDQO3yv26nNr2RM2yZzNrNHEsj9bm6dOwwu9OYN28CjzZkH57bh4w0I2F7IodpQvUAEd1mbWXg=="],
"@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.27.4", "", { "os": "sunos", "cpu": "x64" }, "sha512-/gOzgaewZJfeJTlsWhvUEmUG4tWEY2Spp5M20INYRg2ZKl9QPO3QEEgPeRtLjEWSW8FilRNacPOg8R1uaYkA6g=="],
"@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.27.4", "", { "os": "win32", "cpu": "arm64" }, "sha512-Z9SExBg2y32smoDQdf1HRwHRt6vAHLXcxD2uGgO/v2jK7Y718Ix4ndsbNMU/+1Qiem9OiOdaqitioZwxivhXYg=="],
"@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.27.4", "", { "os": "win32", "cpu": "ia32" }, "sha512-DAyGLS0Jz5G5iixEbMHi5KdiApqHBWMGzTtMiJ72ZOLhbu/bzxgAe8Ue8CTS3n3HbIUHQz/L51yMdGMeoxXNJw=="],
"@esbuild/win32-x64": ["@esbuild/win32-x64@0.27.4", "", { "os": "win32", "cpu": "x64" }, "sha512-+knoa0BDoeXgkNvvV1vvbZX4+hizelrkwmGJBdT17t8FNPwG2lKemmuMZlmaNQ3ws3DKKCxpb4zRZEIp3UxFCg=="],
"@iconify-json/simple-icons": ["@iconify-json/simple-icons@1.2.74", "", { "dependencies": { "@iconify/types": "*" } }, "sha512-yqaohfY6jnYjTVpuTkaBQHrWbdUrQyWXhau0r/0EZiNWYXPX/P8WWwl1DoLH5CbvDjjcWQw5J0zADhgCUklOqA=="],
"@iconify/types": ["@iconify/types@2.0.0", "", {}, "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg=="],
"@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.5", "", {}, "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og=="],
"@mixmark-io/domino": ["@mixmark-io/domino@2.2.0", "", {}, "sha512-Y28PR25bHXUg88kCV7nivXrP2Nj2RueZ3/l/jdx6J9f8J4nsEGcgX0Qe6lt7Pa+J79+kPiJU3LguR6O/6zrLOw=="],
"@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.1.1", "", { "dependencies": { "@emnapi/core": "^1.7.1", "@emnapi/runtime": "^1.7.1", "@tybys/wasm-util": "^0.10.1" } }, "sha512-p64ah1M1ld8xjWv3qbvFwHiFVWrq1yFvV4f7w+mzaqiR4IlSgkqhcRdHwsGgomwzBH51sRY4NEowLxnaBjcW/A=="],
"@oxc-project/types": ["@oxc-project/types@0.122.0", "", {}, "sha512-oLAl5kBpV4w69UtFZ9xqcmTi+GENWOcPF7FCrczTiBbmC0ibXxCwyvZGbO39rCVEuLGAZM84DH0pUIyyv/YJzA=="],
"@rolldown/binding-android-arm64": ["@rolldown/binding-android-arm64@1.0.0-rc.11", "", { "os": "android", "cpu": "arm64" }, "sha512-SJ+/g+xNnOh6NqYxD0V3uVN4W3VfnrGsC9/hoglicgTNfABFG9JjISvkkU0dNY84MNHLWyOgxP9v9Y9pX4S7+A=="],
"@rolldown/binding-darwin-arm64": ["@rolldown/binding-darwin-arm64@1.0.0-rc.11", "", { "os": "darwin", "cpu": "arm64" }, "sha512-7WQgR8SfOPwmDZGFkThUvsmd/nwAWv91oCO4I5LS7RKrssPZmOt7jONN0cW17ydGC1n/+puol1IpoieKqQidmg=="],
"@rolldown/binding-darwin-x64": ["@rolldown/binding-darwin-x64@1.0.0-rc.11", "", { "os": "darwin", "cpu": "x64" }, "sha512-39Ks6UvIHq4rEogIfQBoBRusj0Q0nPVWIvqmwBLaT6aqQGIakHdESBVOPRRLacy4WwUPIx4ZKzfZ9PMW+IeyUQ=="],
"@rolldown/binding-freebsd-x64": ["@rolldown/binding-freebsd-x64@1.0.0-rc.11", "", { "os": "freebsd", "cpu": "x64" }, "sha512-jfsm0ZHfhiqrvWjJAmzsqiIFPz5e7mAoCOPBNTcNgkiid/LaFKiq92+0ojH+nmJmKYkre4t71BWXUZDNp7vsag=="],
"@rolldown/binding-linux-arm-gnueabihf": ["@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.11", "", { "os": "linux", "cpu": "arm" }, "sha512-zjQaUtSyq1nVe3nxmlSCuR96T1LPlpvmJ0SZy0WJFEsV4kFbXcq2u68L4E6O0XeFj4aex9bEauqjW8UQBeAvfQ=="],
"@rolldown/binding-linux-arm64-gnu": ["@rolldown/binding-linux-arm64-gnu@1.0.0-rc.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-WMW1yE6IOnehTcFE9eipFkm3XN63zypWlrJQ2iF7NrQ9b2LDRjumFoOGJE8RJJTJCTBAdmLMnJ8uVitACUUo1Q=="],
"@rolldown/binding-linux-arm64-musl": ["@rolldown/binding-linux-arm64-musl@1.0.0-rc.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-jfndI9tsfm4APzjNt6QdBkYwre5lRPUgHeDHoI7ydKUuJvz3lZeCfMsI56BZj+7BYqiKsJm7cfd/6KYV7ubrBg=="],
"@rolldown/binding-linux-ppc64-gnu": ["@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.11", "", { "os": "linux", "cpu": "ppc64" }, "sha512-ZlFgw46NOAGMgcdvdYwAGu2Q+SLFA9LzbJLW+iyMOJyhj5wk6P3KEE9Gct4xWwSzFoPI7JCdYmYMzVtlgQ+zfw=="],
"@rolldown/binding-linux-s390x-gnu": ["@rolldown/binding-linux-s390x-gnu@1.0.0-rc.11", "", { "os": "linux", "cpu": "s390x" }, "sha512-hIOYmuT6ofM4K04XAZd3OzMySEO4K0/nc9+jmNcxNAxRi6c5UWpqfw3KMFV4MVFWL+jQsSh+bGw2VqmaPMTLyw=="],
"@rolldown/binding-linux-x64-gnu": ["@rolldown/binding-linux-x64-gnu@1.0.0-rc.11", "", { "os": "linux", "cpu": "x64" }, "sha512-qXBQQO9OvkjjQPLdUVr7Nr2t3QTZI7s4KZtfw7HzBgjbmAPSFwSv4rmET9lLSgq3rH/ndA3ngv3Qb8l2njoPNA=="],
"@rolldown/binding-linux-x64-musl": ["@rolldown/binding-linux-x64-musl@1.0.0-rc.11", "", { "os": "linux", "cpu": "x64" }, "sha512-/tpFfoSTzUkH9LPY+cYbqZBDyyX62w5fICq9qzsHLL8uTI6BHip3Q9Uzft0wylk/i8OOwKik8OxW+QAhDmzwmg=="],
"@rolldown/binding-openharmony-arm64": ["@rolldown/binding-openharmony-arm64@1.0.0-rc.11", "", { "os": "none", "cpu": "arm64" }, "sha512-mcp3Rio2w72IvdZG0oQ4bM2c2oumtwHfUfKncUM6zGgz0KgPz4YmDPQfnXEiY5t3+KD/i8HG2rOB/LxdmieK2g=="],
"@rolldown/binding-wasm32-wasi": ["@rolldown/binding-wasm32-wasi@1.0.0-rc.11", "", { "dependencies": { "@napi-rs/wasm-runtime": "^1.1.1" }, "cpu": "none" }, "sha512-LXk5Hii1Ph9asuGRjBuz8TUxdc1lWzB7nyfdoRgI0WGPZKmCxvlKk8KfYysqtr4MfGElu/f/pEQRh8fcEgkrWw=="],
"@rolldown/binding-win32-arm64-msvc": ["@rolldown/binding-win32-arm64-msvc@1.0.0-rc.11", "", { "os": "win32", "cpu": "arm64" }, "sha512-dDwf5otnx0XgRY1yqxOC4ITizcdzS/8cQ3goOWv3jFAo4F+xQYni+hnMuO6+LssHHdJW7+OCVL3CoU4ycnh35Q=="],
"@rolldown/binding-win32-x64-msvc": ["@rolldown/binding-win32-x64-msvc@1.0.0-rc.11", "", { "os": "win32", "cpu": "x64" }, "sha512-LN4/skhSggybX71ews7dAj6r2geaMJfm3kMbK2KhFMg9B10AZXnKoLCVVgzhMHL0S+aKtr4p8QbAW8k+w95bAA=="],
"@rolldown/pluginutils": ["@rolldown/pluginutils@1.0.0-rc.11", "", {}, "sha512-xQO9vbwBecJRv9EUcQ/y0dzSTJgA7Q6UVN7xp6B81+tBGSLVAK03yJ9NkJaUA7JFD91kbjxRSC/mDnmvXzbHoQ=="],
"@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.59.0", "", { "os": "android", "cpu": "arm" }, "sha512-upnNBkA6ZH2VKGcBj9Fyl9IGNPULcjXRlg0LLeaioQWueH30p6IXtJEbKAgvyv+mJaMxSm1l6xwDXYjpEMiLMg=="],
"@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.59.0", "", { "os": "android", "cpu": "arm64" }, "sha512-hZ+Zxj3SySm4A/DylsDKZAeVg0mvi++0PYVceVyX7hemkw7OreKdCvW2oQ3T1FMZvCaQXqOTHb8qmBShoqk69Q=="],
"@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.59.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-W2Psnbh1J8ZJw0xKAd8zdNgF9HRLkdWwwdWqubSVk0pUuQkoHnv7rx4GiF9rT4t5DIZGAsConRE3AxCdJ4m8rg=="],
"@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.59.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-ZW2KkwlS4lwTv7ZVsYDiARfFCnSGhzYPdiOU4IM2fDbL+QGlyAbjgSFuqNRbSthybLbIJ915UtZBtmuLrQAT/w=="],
"@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.59.0", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-EsKaJ5ytAu9jI3lonzn3BgG8iRBjV4LxZexygcQbpiU0wU0ATxhNVEpXKfUa0pS05gTcSDMKpn3Sx+QB9RlTTA=="],
"@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.59.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-d3DuZi2KzTMjImrxoHIAODUZYoUUMsuUiY4SRRcJy6NJoZ6iIqWnJu9IScV9jXysyGMVuW+KNzZvBLOcpdl3Vg=="],
"@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.59.0", "", { "os": "linux", "cpu": "arm" }, "sha512-t4ONHboXi/3E0rT6OZl1pKbl2Vgxf9vJfWgmUoCEVQVxhW6Cw/c8I6hbbu7DAvgp82RKiH7TpLwxnJeKv2pbsw=="],
"@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.59.0", "", { "os": "linux", "cpu": "arm" }, "sha512-CikFT7aYPA2ufMD086cVORBYGHffBo4K8MQ4uPS/ZnY54GKj36i196u8U+aDVT2LX4eSMbyHtyOh7D7Zvk2VvA=="],
"@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.59.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-jYgUGk5aLd1nUb1CtQ8E+t5JhLc9x5WdBKew9ZgAXg7DBk0ZHErLHdXM24rfX+bKrFe+Xp5YuJo54I5HFjGDAA=="],
"@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.59.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-peZRVEdnFWZ5Bh2KeumKG9ty7aCXzzEsHShOZEFiCQlDEepP1dpUl/SrUNXNg13UmZl+gzVDPsiCwnV1uI0RUA=="],
"@rollup/rollup-linux-loong64-gnu": ["@rollup/rollup-linux-loong64-gnu@4.59.0", "", { "os": "linux", "cpu": "none" }, "sha512-gbUSW/97f7+r4gHy3Jlup8zDG190AuodsWnNiXErp9mT90iCy9NKKU0Xwx5k8VlRAIV2uU9CsMnEFg/xXaOfXg=="],
"@rollup/rollup-linux-loong64-musl": ["@rollup/rollup-linux-loong64-musl@4.59.0", "", { "os": "linux", "cpu": "none" }, "sha512-yTRONe79E+o0FWFijasoTjtzG9EBedFXJMl888NBEDCDV9I2wGbFFfJQQe63OijbFCUZqxpHz1GzpbtSFikJ4Q=="],
"@rollup/rollup-linux-ppc64-gnu": ["@rollup/rollup-linux-ppc64-gnu@4.59.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-sw1o3tfyk12k3OEpRddF68a1unZ5VCN7zoTNtSn2KndUE+ea3m3ROOKRCZxEpmT9nsGnogpFP9x6mnLTCaoLkA=="],
"@rollup/rollup-linux-ppc64-musl": ["@rollup/rollup-linux-ppc64-musl@4.59.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-+2kLtQ4xT3AiIxkzFVFXfsmlZiG5FXYW7ZyIIvGA7Bdeuh9Z0aN4hVyXS/G1E9bTP/vqszNIN/pUKCk/BTHsKA=="],
"@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.59.0", "", { "os": "linux", "cpu": "none" }, "sha512-NDYMpsXYJJaj+I7UdwIuHHNxXZ/b/N2hR15NyH3m2qAtb/hHPA4g4SuuvrdxetTdndfj9b1WOmy73kcPRoERUg=="],
"@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.59.0", "", { "os": "linux", "cpu": "none" }, "sha512-nLckB8WOqHIf1bhymk+oHxvM9D3tyPndZH8i8+35p/1YiVoVswPid2yLzgX7ZJP0KQvnkhM4H6QZ5m0LzbyIAg=="],
"@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.59.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-oF87Ie3uAIvORFBpwnCvUzdeYUqi2wY6jRFWJAy1qus/udHFYIkplYRW+wo+GRUP4sKzYdmE1Y3+rY5Gc4ZO+w=="],
"@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.59.0", "", { "os": "linux", "cpu": "x64" }, "sha512-3AHmtQq/ppNuUspKAlvA8HtLybkDflkMuLK4DPo77DfthRb71V84/c4MlWJXixZz4uruIH4uaa07IqoAkG64fg=="],
"@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.59.0", "", { "os": "linux", "cpu": "x64" }, "sha512-2UdiwS/9cTAx7qIUZB/fWtToJwvt0Vbo0zmnYt7ED35KPg13Q0ym1g442THLC7VyI6JfYTP4PiSOWyoMdV2/xg=="],
"@rollup/rollup-openbsd-x64": ["@rollup/rollup-openbsd-x64@4.59.0", "", { "os": "openbsd", "cpu": "x64" }, "sha512-M3bLRAVk6GOwFlPTIxVBSYKUaqfLrn8l0psKinkCFxl4lQvOSz8ZrKDz2gxcBwHFpci0B6rttydI4IpS4IS/jQ=="],
"@rollup/rollup-openharmony-arm64": ["@rollup/rollup-openharmony-arm64@4.59.0", "", { "os": "none", "cpu": "arm64" }, "sha512-tt9KBJqaqp5i5HUZzoafHZX8b5Q2Fe7UjYERADll83O4fGqJ49O1FsL6LpdzVFQcpwvnyd0i+K/VSwu/o/nWlA=="],
"@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.59.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-V5B6mG7OrGTwnxaNUzZTDTjDS7F75PO1ae6MJYdiMu60sq0CqN5CVeVsbhPxalupvTX8gXVSU9gq+Rx1/hvu6A=="],
"@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.59.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-UKFMHPuM9R0iBegwzKF4y0C4J9u8C6MEJgFuXTBerMk7EJ92GFVFYBfOZaSGLu6COf7FxpQNqhNS4c4icUPqxA=="],
"@rollup/rollup-win32-x64-gnu": ["@rollup/rollup-win32-x64-gnu@4.59.0", "", { "os": "win32", "cpu": "x64" }, "sha512-laBkYlSS1n2L8fSo1thDNGrCTQMmxjYY5G0WFWjFFYZkKPjsMBsgJfGf4TLxXrF6RyhI60L8TMOjBMvXiTcxeA=="],
"@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.59.0", "", { "os": "win32", "cpu": "x64" }, "sha512-2HRCml6OztYXyJXAvdDXPKcawukWY2GpR5/nxKp4iBgiO3wcoEGkAaqctIbZcNB6KlUQBIqt8VYkNSj2397EfA=="],
"@shikijs/core": ["@shikijs/core@2.5.0", "", { "dependencies": { "@shikijs/engine-javascript": "2.5.0", "@shikijs/engine-oniguruma": "2.5.0", "@shikijs/types": "2.5.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4", "hast-util-to-html": "^9.0.4" } }, "sha512-uu/8RExTKtavlpH7XqnVYBrfBkUc20ngXiX9NSrBhOVZYv/7XQRKUyhtkeflY5QsxC0GbJThCerruZfsUaSldg=="],
"@shikijs/engine-javascript": ["@shikijs/engine-javascript@2.5.0", "", { "dependencies": { "@shikijs/types": "2.5.0", "@shikijs/vscode-textmate": "^10.0.2", "oniguruma-to-es": "^3.1.0" } }, "sha512-VjnOpnQf8WuCEZtNUdjjwGUbtAVKuZkVQ/5cHy/tojVVRIRtlWMYVjyWhxOmIq05AlSOv72z7hRNRGVBgQOl0w=="],
"@shikijs/engine-oniguruma": ["@shikijs/engine-oniguruma@2.5.0", "", { "dependencies": { "@shikijs/types": "2.5.0", "@shikijs/vscode-textmate": "^10.0.2" } }, "sha512-pGd1wRATzbo/uatrCIILlAdFVKdxImWJGQ5rFiB5VZi2ve5xj3Ax9jny8QvkaV93btQEwR/rSz5ERFpC5mKNIw=="],
"@shikijs/langs": ["@shikijs/langs@2.5.0", "", { "dependencies": { "@shikijs/types": "2.5.0" } }, "sha512-Qfrrt5OsNH5R+5tJ/3uYBBZv3SuGmnRPejV9IlIbFH3HTGLDlkqgHymAlzklVmKBjAaVmkPkyikAV/sQ1wSL+w=="],
"@shikijs/themes": ["@shikijs/themes@2.5.0", "", { "dependencies": { "@shikijs/types": "2.5.0" } }, "sha512-wGrk+R8tJnO0VMzmUExHR+QdSaPUl/NKs+a4cQQRWyoc3YFbUzuLEi/KWK1hj+8BfHRKm2jNhhJck1dfstJpiw=="],
"@shikijs/transformers": ["@shikijs/transformers@2.5.0", "", { "dependencies": { "@shikijs/core": "2.5.0", "@shikijs/types": "2.5.0" } }, "sha512-SI494W5X60CaUwgi8u4q4m4s3YAFSxln3tzNjOSYqq54wlVgz0/NbbXEb3mdLbqMBztcmS7bVTaEd2w0qMmfeg=="],
"@shikijs/types": ["@shikijs/types@2.5.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-ygl5yhxki9ZLNuNpPitBWvcy9fsSKKaRuO4BAlMyagszQidxcpLAr0qiW/q43DtSIDxO6hEbtYLiFZNXO/hdGw=="],
"@shikijs/vscode-textmate": ["@shikijs/vscode-textmate@10.0.2", "", {}, "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg=="],
"@standard-schema/spec": ["@standard-schema/spec@1.1.0", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="],
"@tybys/wasm-util": ["@tybys/wasm-util@0.10.1", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg=="],
"@types/chai": ["@types/chai@5.2.3", "", { "dependencies": { "@types/deep-eql": "*", "assertion-error": "^2.0.1" } }, "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA=="],
"@types/deep-eql": ["@types/deep-eql@4.0.2", "", {}, "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw=="],
"@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="],
"@types/hast": ["@types/hast@3.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ=="],
"@types/js-yaml": ["@types/js-yaml@4.0.9", "", {}, "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg=="],
"@types/linkify-it": ["@types/linkify-it@5.0.0", "", {}, "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q=="],
"@types/markdown-it": ["@types/markdown-it@14.1.2", "", { "dependencies": { "@types/linkify-it": "^5", "@types/mdurl": "^2" } }, "sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog=="],
"@types/mdast": ["@types/mdast@4.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA=="],
"@types/mdurl": ["@types/mdurl@2.0.0", "", {}, "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg=="],
"@types/node": ["@types/node@22.19.15", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-F0R/h2+dsy5wJAUe3tAU6oqa2qbWY5TpNfL/RGmo1y38hiyO1w3x2jPtt76wmuaJI4DQnOBu21cNXQ2STIUUWg=="],
"@types/turndown": ["@types/turndown@5.0.6", "", {}, "sha512-ru00MoyeeouE5BX4gRL+6m/BsDfbRayOskWqUvh7CLGW+UXxHQItqALa38kKnOiZPqJrtzJUgAC2+F0rL1S4Pg=="],
"@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
"@types/web-bluetooth": ["@types/web-bluetooth@0.0.21", "", {}, "sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA=="],
"@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
"@ungap/structured-clone": ["@ungap/structured-clone@1.3.0", "", {}, "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g=="],
"@vitejs/plugin-vue": ["@vitejs/plugin-vue@5.2.4", "", { "peerDependencies": { "vite": "^5.0.0 || ^6.0.0", "vue": "^3.2.25" } }, "sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA=="],
"@vitest/expect": ["@vitest/expect@4.1.1", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "@types/chai": "^5.2.2", "@vitest/spy": "4.1.1", "@vitest/utils": "4.1.1", "chai": "^6.2.2", "tinyrainbow": "^3.0.3" } }, "sha512-xAV0fqBTk44Rn6SjJReEQkHP3RrqbJo6JQ4zZ7/uVOiJZRarBtblzrOfFIZeYUrukp2YD6snZG6IBqhOoHTm+A=="],
"@vitest/mocker": ["@vitest/mocker@4.1.1", "", { "dependencies": { "@vitest/spy": "4.1.1", "estree-walker": "^3.0.3", "magic-string": "^0.30.21" }, "peerDependencies": { "msw": "^2.4.9", "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "optionalPeers": ["msw"] }, "sha512-h3BOylsfsCLPeceuCPAAJ+BvNwSENgJa4hXoXu4im0bs9Lyp4URc4JYK4pWLZ4pG/UQn7AT92K6IByi6rE6g3A=="],
"@vitest/pretty-format": ["@vitest/pretty-format@4.1.1", "", { "dependencies": { "tinyrainbow": "^3.0.3" } }, "sha512-GM+TEQN5WhOygr1lp7skeVjdLPqqWMHsfzXrcHAqZJi/lIVh63H0kaRCY8MDhNWikx19zBUK8ceaLB7X5AH9NQ=="],
"@vitest/runner": ["@vitest/runner@4.1.1", "", { "dependencies": { "@vitest/utils": "4.1.1", "pathe": "^2.0.3" } }, "sha512-f7+FPy75vN91QGWsITueq0gedwUZy1fLtHOCMeQpjs8jTekAHeKP80zfDEnhrleviLHzVSDXIWuCIOFn3D3f8A=="],
"@vitest/snapshot": ["@vitest/snapshot@4.1.1", "", { "dependencies": { "@vitest/pretty-format": "4.1.1", "@vitest/utils": "4.1.1", "magic-string": "^0.30.21", "pathe": "^2.0.3" } }, "sha512-kMVSgcegWV2FibXEx9p9WIKgje58lcTbXgnJixfcg15iK8nzCXhmalL0ZLtTWLW9PH1+1NEDShiFFedB3tEgWg=="],
"@vitest/spy": ["@vitest/spy@4.1.1", "", {}, "sha512-6Ti/KT5OVaiupdIZEuZN7l3CZcR0cxnxt70Z0//3CtwgObwA6jZhmVBA3yrXSVN3gmwjgd7oDNLlsXz526gpRA=="],
"@vitest/utils": ["@vitest/utils@4.1.1", "", { "dependencies": { "@vitest/pretty-format": "4.1.1", "convert-source-map": "^2.0.0", "tinyrainbow": "^3.0.3" } }, "sha512-cNxAlaB3sHoCdL6pj6yyUXv9Gry1NHNg0kFTXdvSIZXLHsqKH7chiWOkwJ5s5+d/oMwcoG9T0bKU38JZWKusrQ=="],
"@vue/compiler-core": ["@vue/compiler-core@3.5.30", "", { "dependencies": { "@babel/parser": "^7.29.0", "@vue/shared": "3.5.30", "entities": "^7.0.1", "estree-walker": "^2.0.2", "source-map-js": "^1.2.1" } }, "sha512-s3DfdZkcu/qExZ+td75015ljzHc6vE+30cFMGRPROYjqkroYI5NV2X1yAMX9UeyBNWB9MxCfPcsjpLS11nzkkw=="],
"@vue/compiler-dom": ["@vue/compiler-dom@3.5.30", "", { "dependencies": { "@vue/compiler-core": "3.5.30", "@vue/shared": "3.5.30" } }, "sha512-eCFYESUEVYHhiMuK4SQTldO3RYxyMR/UQL4KdGD1Yrkfdx4m/HYuZ9jSfPdA+nWJY34VWndiYdW/wZXyiPEB9g=="],
"@vue/compiler-sfc": ["@vue/compiler-sfc@3.5.30", "", { "dependencies": { "@babel/parser": "^7.29.0", "@vue/compiler-core": "3.5.30", "@vue/compiler-dom": "3.5.30", "@vue/compiler-ssr": "3.5.30", "@vue/shared": "3.5.30", "estree-walker": "^2.0.2", "magic-string": "^0.30.21", "postcss": "^8.5.8", "source-map-js": "^1.2.1" } }, "sha512-LqmFPDn89dtU9vI3wHJnwaV6GfTRD87AjWpTWpyrdVOObVtjIuSeZr181z5C4PmVx/V3j2p+0f7edFKGRMpQ5A=="],
"@vue/compiler-ssr": ["@vue/compiler-ssr@3.5.30", "", { "dependencies": { "@vue/compiler-dom": "3.5.30", "@vue/shared": "3.5.30" } }, "sha512-NsYK6OMTnx109PSL2IAyf62JP6EUdk4Dmj6AkWcJGBvN0dQoMYtVekAmdqgTtWQgEJo+Okstbf/1p7qZr5H+bA=="],
"@vue/devtools-api": ["@vue/devtools-api@7.7.9", "", { "dependencies": { "@vue/devtools-kit": "^7.7.9" } }, "sha512-kIE8wvwlcZ6TJTbNeU2HQNtaxLx3a84aotTITUuL/4bzfPxzajGBOoqjMhwZJ8L9qFYDU/lAYMEEm11dnZOD6g=="],
"@vue/devtools-kit": ["@vue/devtools-kit@7.7.9", "", { "dependencies": { "@vue/devtools-shared": "^7.7.9", "birpc": "^2.3.0", "hookable": "^5.5.3", "mitt": "^3.0.1", "perfect-debounce": "^1.0.0", "speakingurl": "^14.0.1", "superjson": "^2.2.2" } }, "sha512-PyQ6odHSgiDVd4hnTP+aDk2X4gl2HmLDfiyEnn3/oV+ckFDuswRs4IbBT7vacMuGdwY/XemxBoh302ctbsptuA=="],
"@vue/devtools-shared": ["@vue/devtools-shared@7.7.9", "", { "dependencies": { "rfdc": "^1.4.1" } }, "sha512-iWAb0v2WYf0QWmxCGy0seZNDPdO3Sp5+u78ORnyeonS6MT4PC7VPrryX2BpMJrwlDeaZ6BD4vP4XKjK0SZqaeA=="],
"@vue/reactivity": ["@vue/reactivity@3.5.30", "", { "dependencies": { "@vue/shared": "3.5.30" } }, "sha512-179YNgKATuwj9gB+66snskRDOitDiuOZqkYia7mHKJaidOMo/WJxHKF8DuGc4V4XbYTJANlfEKb0yxTQotnx4Q=="],
"@vue/runtime-core": ["@vue/runtime-core@3.5.30", "", { "dependencies": { "@vue/reactivity": "3.5.30", "@vue/shared": "3.5.30" } }, "sha512-e0Z+8PQsUTdwV8TtEsLzUM7SzC7lQwYKePydb7K2ZnmS6jjND+WJXkmmfh/swYzRyfP1EY3fpdesyYoymCzYfg=="],
"@vue/runtime-dom": ["@vue/runtime-dom@3.5.30", "", { "dependencies": { "@vue/reactivity": "3.5.30", "@vue/runtime-core": "3.5.30", "@vue/shared": "3.5.30", "csstype": "^3.2.3" } }, "sha512-2UIGakjU4WSQ0T4iwDEW0W7vQj6n7AFn7taqZ9Cvm0Q/RA2FFOziLESrDL4GmtI1wV3jXg5nMoJSYO66egDUBw=="],
"@vue/server-renderer": ["@vue/server-renderer@3.5.30", "", { "dependencies": { "@vue/compiler-ssr": "3.5.30", "@vue/shared": "3.5.30" }, "peerDependencies": { "vue": "3.5.30" } }, "sha512-v+R34icapydRwbZRD0sXwtHqrQJv38JuMB4JxbOxd8NEpGLny7cncMp53W9UH/zo4j8eDHjQ1dEJXwzFQknjtQ=="],
"@vue/shared": ["@vue/shared@3.5.30", "", {}, "sha512-YXgQ7JjaO18NeK2K9VTbDHaFy62WrObMa6XERNfNOkAhD1F1oDSf3ZJ7K6GqabZ0BvSDHajp8qfS5Sa2I9n8uQ=="],
"@vueuse/core": ["@vueuse/core@12.8.2", "", { "dependencies": { "@types/web-bluetooth": "^0.0.21", "@vueuse/metadata": "12.8.2", "@vueuse/shared": "12.8.2", "vue": "^3.5.13" } }, "sha512-HbvCmZdzAu3VGi/pWYm5Ut+Kd9mn1ZHnn4L5G8kOQTPs/IwIAmJoBrmYk2ckLArgMXZj0AW3n5CAejLUO+PhdQ=="],
"@vueuse/integrations": ["@vueuse/integrations@12.8.2", "", { "dependencies": { "@vueuse/core": "12.8.2", "@vueuse/shared": "12.8.2", "vue": "^3.5.13" }, "peerDependencies": { "async-validator": "^4", "axios": "^1", "change-case": "^5", "drauu": "^0.4", "focus-trap": "^7", "fuse.js": "^7", "idb-keyval": "^6", "jwt-decode": "^4", "nprogress": "^0.2", "qrcode": "^1.5", "sortablejs": "^1", "universal-cookie": "^7" }, "optionalPeers": ["async-validator", "axios", "change-case", "drauu", "fuse.js", "idb-keyval", "jwt-decode", "nprogress", "qrcode", "sortablejs", "universal-cookie"] }, "sha512-fbGYivgK5uBTRt7p5F3zy6VrETlV9RtZjBqd1/HxGdjdckBgBM4ugP8LHpjolqTj14TXTxSK1ZfgPbHYyGuH7g=="],
"@vueuse/metadata": ["@vueuse/metadata@12.8.2", "", {}, "sha512-rAyLGEuoBJ/Il5AmFHiziCPdQzRt88VxR+Y/A/QhJ1EWtWqPBBAxTAFaSkviwEuOEZNtW8pvkPgoCZQ+HxqW1A=="],
"@vueuse/shared": ["@vueuse/shared@12.8.2", "", { "dependencies": { "vue": "^3.5.13" } }, "sha512-dznP38YzxZoNloI0qpEfpkms8knDtaoQ6Y/sfS0L7Yki4zh40LFHEhur0odJC6xTHG5dxWVPiUWBXn+wCG2s5w=="],
"algoliasearch": ["algoliasearch@5.49.2", "", { "dependencies": { "@algolia/abtesting": "1.15.2", "@algolia/client-abtesting": "5.49.2", "@algolia/client-analytics": "5.49.2", "@algolia/client-common": "5.49.2", "@algolia/client-insights": "5.49.2", "@algolia/client-personalization": "5.49.2", "@algolia/client-query-suggestions": "5.49.2", "@algolia/client-search": "5.49.2", "@algolia/ingestion": "1.49.2", "@algolia/monitoring": "1.49.2", "@algolia/recommend": "5.49.2", "@algolia/requester-browser-xhr": "5.49.2", "@algolia/requester-fetch": "5.49.2", "@algolia/requester-node-http": "5.49.2" } }, "sha512-1K0wtDaRONwfhL4h8bbJ9qTjmY6rhGgRvvagXkMBsAOMNr+3Q2SffHECh9DIuNVrMA1JwA0zCwhyepgBZVakng=="],
"ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
"argparse": ["argparse@2.0.1", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
"assertion-error": ["assertion-error@2.0.1", "", {}, "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA=="],
"birpc": ["birpc@2.9.0", "", {}, "sha512-KrayHS5pBi69Xi9JmvoqrIgYGDkD6mcSe/i6YKi3w5kekCLzrX4+nawcXqrj2tIp50Kw/mT/s3p+GVK0A0sKxw=="],
"ccount": ["ccount@2.0.1", "", {}, "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg=="],
"chai": ["chai@6.2.2", "", {}, "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg=="],
"chalk": ["chalk@5.6.2", "", {}, "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="],
"character-entities-html4": ["character-entities-html4@2.1.0", "", {}, "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA=="],
"character-entities-legacy": ["character-entities-legacy@3.0.0", "", {}, "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ=="],
"cli-table3": ["cli-table3@0.6.5", "", { "dependencies": { "string-width": "^4.2.0" }, "optionalDependencies": { "@colors/colors": "1.5.0" } }, "sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ=="],
"comma-separated-tokens": ["comma-separated-tokens@2.0.3", "", {}, "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="],
"commander": ["commander@14.0.3", "", {}, "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw=="],
"convert-source-map": ["convert-source-map@2.0.0", "", {}, "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="],
"copy-anything": ["copy-anything@4.0.5", "", { "dependencies": { "is-what": "^5.2.0" } }, "sha512-7Vv6asjS4gMOuILabD3l739tsaxFQmC+a7pLZm02zyvs8p977bL3zEgq3yDk5rn9B0PbYgIv++jmHcuUab4RhA=="],
"csstype": ["csstype@3.2.3", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="],
"dequal": ["dequal@2.0.3", "", {}, "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA=="],
"detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
"devlop": ["devlop@1.1.0", "", { "dependencies": { "dequal": "^2.0.0" } }, "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA=="],
"emoji-regex": ["emoji-regex@8.0.0", "", {}, "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="],
"emoji-regex-xs": ["emoji-regex-xs@1.0.0", "", {}, "sha512-LRlerrMYoIDrT6jgpeZ2YYl/L8EulRTt5hQcYjy5AInh7HWXKimpqx68aknBFpGL2+/IcogTcaydJEgaTmOpDg=="],
"entities": ["entities@7.0.1", "", {}, "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA=="],
"es-module-lexer": ["es-module-lexer@2.0.0", "", {}, "sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw=="],
"esbuild": ["esbuild@0.27.4", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.27.4", "@esbuild/android-arm": "0.27.4", "@esbuild/android-arm64": "0.27.4", "@esbuild/android-x64": "0.27.4", "@esbuild/darwin-arm64": "0.27.4", "@esbuild/darwin-x64": "0.27.4", "@esbuild/freebsd-arm64": "0.27.4", "@esbuild/freebsd-x64": "0.27.4", "@esbuild/linux-arm": "0.27.4", "@esbuild/linux-arm64": "0.27.4", "@esbuild/linux-ia32": "0.27.4", "@esbuild/linux-loong64": "0.27.4", "@esbuild/linux-mips64el": "0.27.4", "@esbuild/linux-ppc64": "0.27.4", "@esbuild/linux-riscv64": "0.27.4", "@esbuild/linux-s390x": "0.27.4", "@esbuild/linux-x64": "0.27.4", "@esbuild/netbsd-arm64": "0.27.4", "@esbuild/netbsd-x64": "0.27.4", "@esbuild/openbsd-arm64": "0.27.4", "@esbuild/openbsd-x64": "0.27.4", "@esbuild/openharmony-arm64": "0.27.4", "@esbuild/sunos-x64": "0.27.4", "@esbuild/win32-arm64": "0.27.4", "@esbuild/win32-ia32": "0.27.4", "@esbuild/win32-x64": "0.27.4" }, "bin": "bin/esbuild" }, "sha512-Rq4vbHnYkK5fws5NF7MYTU68FPRE1ajX7heQ/8QXXWqNgqqJ/GkmmyxIzUnf2Sr/bakf8l54716CcMGHYhMrrQ=="],
"estree-walker": ["estree-walker@3.0.3", "", { "dependencies": { "@types/estree": "^1.0.0" } }, "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g=="],
"expect-type": ["expect-type@1.3.0", "", {}, "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA=="],
"fdir": ["fdir@6.5.0", "", { "peerDependencies": { "picomatch": "^3 || ^4" } }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="],
"focus-trap": ["focus-trap@7.8.0", "", { "dependencies": { "tabbable": "^6.4.0" } }, "sha512-/yNdlIkpWbM0ptxno3ONTuf+2g318kh2ez3KSeZN5dZ8YC6AAmgeWz+GasYYiBJPFaYcSAPeu4GfhUaChzIJXA=="],
"fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
"get-tsconfig": ["get-tsconfig@4.13.6", "", { "dependencies": { "resolve-pkg-maps": "^1.0.0" } }, "sha512-shZT/QMiSHc/YBLxxOkMtgSid5HFoauqCE3/exfsEcwg1WkeqjG+V40yBbBrsD+jW2HDXcs28xOfcbm2jI8Ddw=="],
"hast-util-to-html": ["hast-util-to-html@9.0.5", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "zwitch": "^2.0.4" } }, "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw=="],
"hast-util-whitespace": ["hast-util-whitespace@3.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw=="],
"hookable": ["hookable@5.5.3", "", {}, "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ=="],
"html-void-elements": ["html-void-elements@3.0.0", "", {}, "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg=="],
"is-fullwidth-code-point": ["is-fullwidth-code-point@3.0.0", "", {}, "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg=="],
"is-what": ["is-what@5.5.0", "", {}, "sha512-oG7cgbmg5kLYae2N5IVd3jm2s+vldjxJzK1pcu9LfpGuQ93MQSzo0okvRna+7y5ifrD+20FE8FvjusyGaz14fw=="],
"js-yaml": ["js-yaml@4.1.1", "", { "dependencies": { "argparse": "^2.0.1" }, "bin": "bin/js-yaml.js" }, "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA=="],
"lightningcss": ["lightningcss@1.32.0", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.32.0", "lightningcss-darwin-arm64": "1.32.0", "lightningcss-darwin-x64": "1.32.0", "lightningcss-freebsd-x64": "1.32.0", "lightningcss-linux-arm-gnueabihf": "1.32.0", "lightningcss-linux-arm64-gnu": "1.32.0", "lightningcss-linux-arm64-musl": "1.32.0", "lightningcss-linux-x64-gnu": "1.32.0", "lightningcss-linux-x64-musl": "1.32.0", "lightningcss-win32-arm64-msvc": "1.32.0", "lightningcss-win32-x64-msvc": "1.32.0" } }, "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ=="],
"lightningcss-android-arm64": ["lightningcss-android-arm64@1.32.0", "", { "os": "android", "cpu": "arm64" }, "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg=="],
"lightningcss-darwin-arm64": ["lightningcss-darwin-arm64@1.32.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ=="],
"lightningcss-darwin-x64": ["lightningcss-darwin-x64@1.32.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w=="],
"lightningcss-freebsd-x64": ["lightningcss-freebsd-x64@1.32.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig=="],
"lightningcss-linux-arm-gnueabihf": ["lightningcss-linux-arm-gnueabihf@1.32.0", "", { "os": "linux", "cpu": "arm" }, "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw=="],
"lightningcss-linux-arm64-gnu": ["lightningcss-linux-arm64-gnu@1.32.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ=="],
"lightningcss-linux-arm64-musl": ["lightningcss-linux-arm64-musl@1.32.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg=="],
"lightningcss-linux-x64-gnu": ["lightningcss-linux-x64-gnu@1.32.0", "", { "os": "linux", "cpu": "x64" }, "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA=="],
"lightningcss-linux-x64-musl": ["lightningcss-linux-x64-musl@1.32.0", "", { "os": "linux", "cpu": "x64" }, "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg=="],
"lightningcss-win32-arm64-msvc": ["lightningcss-win32-arm64-msvc@1.32.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw=="],
"lightningcss-win32-x64-msvc": ["lightningcss-win32-x64-msvc@1.32.0", "", { "os": "win32", "cpu": "x64" }, "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q=="],
"magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
"mark.js": ["mark.js@8.11.1", "", {}, "sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ=="],
"mdast-util-to-hast": ["mdast-util-to-hast@13.2.1", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/mdast": "^4.0.0", "@ungap/structured-clone": "^1.0.0", "devlop": "^1.0.0", "micromark-util-sanitize-uri": "^2.0.0", "trim-lines": "^3.0.0", "unist-util-position": "^5.0.0", "unist-util-visit": "^5.0.0", "vfile": "^6.0.0" } }, "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA=="],
"micromark-util-character": ["micromark-util-character@2.1.1", "", { "dependencies": { "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0" } }, "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q=="],
"micromark-util-encode": ["micromark-util-encode@2.0.1", "", {}, "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw=="],
"micromark-util-sanitize-uri": ["micromark-util-sanitize-uri@2.0.1", "", { "dependencies": { "micromark-util-character": "^2.0.0", "micromark-util-encode": "^2.0.0", "micromark-util-symbol": "^2.0.0" } }, "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ=="],
"micromark-util-symbol": ["micromark-util-symbol@2.0.1", "", {}, "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q=="],
"micromark-util-types": ["micromark-util-types@2.0.2", "", {}, "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA=="],
"minisearch": ["minisearch@7.2.0", "", {}, "sha512-dqT2XBYUOZOiC5t2HRnwADjhNS2cecp9u+TJRiJ1Qp/f5qjkeT5APcGPjHw+bz89Ms8Jp+cG4AlE+QZ/QnDglg=="],
"mitt": ["mitt@3.0.1", "", {}, "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw=="],
"nanoid": ["nanoid@3.3.11", "", { "bin": "bin/nanoid.cjs" }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
"obug": ["obug@2.1.1", "", {}, "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ=="],
"oniguruma-to-es": ["oniguruma-to-es@3.1.1", "", { "dependencies": { "emoji-regex-xs": "^1.0.0", "regex": "^6.0.1", "regex-recursion": "^6.0.2" } }, "sha512-bUH8SDvPkH3ho3dvwJwfonjlQ4R80vjyvrU8YpxuROddv55vAEJrTuCuCVUhhsHbtlD9tGGbaNApGQckXhS8iQ=="],
"pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
"perfect-debounce": ["perfect-debounce@1.0.0", "", {}, "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA=="],
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
"picomatch": ["picomatch@4.0.3", "", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="],
"postcss": ["postcss@8.5.8", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg=="],
"preact": ["preact@10.29.0", "", {}, "sha512-wSAGyk2bYR1c7t3SZ3jHcM6xy0lcBcDel6lODcs9ME6Th++Dx2KU+6D3HD8wMMKGA8Wpw7OMd3/4RGzYRpzwRg=="],
"property-information": ["property-information@7.1.0", "", {}, "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ=="],
"regex": ["regex@6.1.0", "", { "dependencies": { "regex-utilities": "^2.3.0" } }, "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg=="],
"regex-recursion": ["regex-recursion@6.0.2", "", { "dependencies": { "regex-utilities": "^2.3.0" } }, "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg=="],
"regex-utilities": ["regex-utilities@2.3.0", "", {}, "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng=="],
"resolve-pkg-maps": ["resolve-pkg-maps@1.0.0", "", {}, "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw=="],
"rfdc": ["rfdc@1.4.1", "", {}, "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA=="],
"rolldown": ["rolldown@1.0.0-rc.11", "", { "dependencies": { "@oxc-project/types": "=0.122.0", "@rolldown/pluginutils": "1.0.0-rc.11" }, "optionalDependencies": { "@rolldown/binding-android-arm64": "1.0.0-rc.11", "@rolldown/binding-darwin-arm64": "1.0.0-rc.11", "@rolldown/binding-darwin-x64": "1.0.0-rc.11", "@rolldown/binding-freebsd-x64": "1.0.0-rc.11", "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.11", "@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.11", "@rolldown/binding-linux-arm64-musl": "1.0.0-rc.11", "@rolldown/binding-linux-ppc64-gnu": "1.0.0-rc.11", "@rolldown/binding-linux-s390x-gnu": "1.0.0-rc.11", "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.11", "@rolldown/binding-linux-x64-musl": "1.0.0-rc.11", "@rolldown/binding-openharmony-arm64": "1.0.0-rc.11", "@rolldown/binding-wasm32-wasi": "1.0.0-rc.11", "@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.11", "@rolldown/binding-win32-x64-msvc": "1.0.0-rc.11" }, "bin": "bin/cli.mjs" }, "sha512-NRjoKMusSjfRbSYiH3VSumlkgFe7kYAa3pzVOsVYVFY3zb5d7nS+a3KGQ7hJKXuYWbzJKPVQ9Wxq2UvyK+ENpw=="],
"rollup": ["rollup@4.59.0", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.59.0", "@rollup/rollup-android-arm64": "4.59.0", "@rollup/rollup-darwin-arm64": "4.59.0", "@rollup/rollup-darwin-x64": "4.59.0", "@rollup/rollup-freebsd-arm64": "4.59.0", "@rollup/rollup-freebsd-x64": "4.59.0", "@rollup/rollup-linux-arm-gnueabihf": "4.59.0", "@rollup/rollup-linux-arm-musleabihf": "4.59.0", "@rollup/rollup-linux-arm64-gnu": "4.59.0", "@rollup/rollup-linux-arm64-musl": "4.59.0", "@rollup/rollup-linux-loong64-gnu": "4.59.0", "@rollup/rollup-linux-loong64-musl": "4.59.0", "@rollup/rollup-linux-ppc64-gnu": "4.59.0", "@rollup/rollup-linux-ppc64-musl": "4.59.0", "@rollup/rollup-linux-riscv64-gnu": "4.59.0", "@rollup/rollup-linux-riscv64-musl": "4.59.0", "@rollup/rollup-linux-s390x-gnu": "4.59.0", "@rollup/rollup-linux-x64-gnu": "4.59.0", "@rollup/rollup-linux-x64-musl": "4.59.0", "@rollup/rollup-openbsd-x64": "4.59.0", "@rollup/rollup-openharmony-arm64": "4.59.0", "@rollup/rollup-win32-arm64-msvc": "4.59.0", "@rollup/rollup-win32-ia32-msvc": "4.59.0", "@rollup/rollup-win32-x64-gnu": "4.59.0", "@rollup/rollup-win32-x64-msvc": "4.59.0", "fsevents": "~2.3.2" }, "bin": "dist/bin/rollup" }, "sha512-2oMpl67a3zCH9H79LeMcbDhXW/UmWG/y2zuqnF2jQq5uq9TbM9TVyXvA4+t+ne2IIkBdrLpAaRQAvo7YI/Yyeg=="],
"search-insights": ["search-insights@2.17.3", "", {}, "sha512-RQPdCYTa8A68uM2jwxoY842xDhvx3E5LFL1LxvxCNMev4o5mLuokczhzjAgGwUZBAmOKZknArSxLKmXtIi2AxQ=="],
"shiki": ["shiki@2.5.0", "", { "dependencies": { "@shikijs/core": "2.5.0", "@shikijs/engine-javascript": "2.5.0", "@shikijs/engine-oniguruma": "2.5.0", "@shikijs/langs": "2.5.0", "@shikijs/themes": "2.5.0", "@shikijs/types": "2.5.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-mI//trrsaiCIPsja5CNfsyNOqgAZUb6VpJA+340toL42UpzQlXpwRV9nch69X6gaUxrr9kaOOa6e3y3uAkGFxQ=="],
"siginfo": ["siginfo@2.0.0", "", {}, "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g=="],
"source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],
"space-separated-tokens": ["space-separated-tokens@2.0.2", "", {}, "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q=="],
"speakingurl": ["speakingurl@14.0.1", "", {}, "sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ=="],
"stackback": ["stackback@0.0.2", "", {}, "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw=="],
"std-env": ["std-env@4.0.0", "", {}, "sha512-zUMPtQ/HBY3/50VbpkupYHbRroTRZJPRLvreamgErJVys0ceuzMkD44J/QjqhHjOzK42GQ3QZIeFG1OYfOtKqQ=="],
"string-width": ["string-width@4.2.3", "", { "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="],
"stringify-entities": ["stringify-entities@4.0.4", "", { "dependencies": { "character-entities-html4": "^2.0.0", "character-entities-legacy": "^3.0.0" } }, "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg=="],
"strip-ansi": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="],
"superjson": ["superjson@2.2.6", "", { "dependencies": { "copy-anything": "^4" } }, "sha512-H+ue8Zo4vJmV2nRjpx86P35lzwDT3nItnIsocgumgr0hHMQ+ZGq5vrERg9kJBo5AWGmxZDhzDo+WVIJqkB0cGA=="],
"tabbable": ["tabbable@6.4.0", "", {}, "sha512-05PUHKSNE8ou2dwIxTngl4EzcnsCDZGJ/iCLtDflR/SHB/ny14rXc+qU5P4mG9JkusiV7EivzY9Mhm55AzAvCg=="],
"tinybench": ["tinybench@2.9.0", "", {}, "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg=="],
"tinyexec": ["tinyexec@1.0.4", "", {}, "sha512-u9r3uZC0bdpGOXtlxUIdwf9pkmvhqJdrVCH9fapQtgy/OeTTMZ1nqH7agtvEfmGui6e1XxjcdrlxvxJvc3sMqw=="],
"tinyglobby": ["tinyglobby@0.2.15", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.3" } }, "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ=="],
"tinyrainbow": ["tinyrainbow@3.1.0", "", {}, "sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw=="],
"trim-lines": ["trim-lines@3.0.1", "", {}, "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg=="],
"tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
"tsx": ["tsx@4.21.0", "", { "dependencies": { "esbuild": "~0.27.0", "get-tsconfig": "^4.7.5" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "bin": "dist/cli.mjs" }, "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw=="],
"turndown": ["turndown@7.2.2", "", { "dependencies": { "@mixmark-io/domino": "^2.2.0" } }, "sha512-1F7db8BiExOKxjSMU2b7if62D/XOyQyZbPKq/nUwopfgnHlqXHqQ0lvfUTeUIr1lZJzOPFn43dODyMSIfvWRKQ=="],
"typescript": ["typescript@6.0.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ=="],
"undici": ["undici@7.24.6", "", {}, "sha512-Xi4agocCbRzt0yYMZGMA6ApD7gvtUFaxm4ZmeacWI4cZxaF6C+8I8QfofC20NAePiB/IcvZmzkJ7XPa471AEtA=="],
"undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
"unist-util-is": ["unist-util-is@6.0.1", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g=="],
"unist-util-position": ["unist-util-position@5.0.0", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA=="],
"unist-util-stringify-position": ["unist-util-stringify-position@4.0.0", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ=="],
"unist-util-visit": ["unist-util-visit@5.1.0", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-is": "^6.0.0", "unist-util-visit-parents": "^6.0.0" } }, "sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg=="],
"unist-util-visit-parents": ["unist-util-visit-parents@6.0.2", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-is": "^6.0.0" } }, "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ=="],
"vfile": ["vfile@6.0.3", "", { "dependencies": { "@types/unist": "^3.0.0", "vfile-message": "^4.0.0" } }, "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q=="],
"vfile-message": ["vfile-message@4.0.3", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw=="],
"vite": ["vite@5.4.21", "", { "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", "rollup": "^4.20.0" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || >=20.0.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.4.0" }, "optionalPeers": ["less", "sass", "sass-embedded", "stylus", "sugarss", "terser"], "bin": "bin/vite.js" }, "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw=="],
"vitepress": ["vitepress@1.6.4", "", { "dependencies": { "@docsearch/css": "3.8.2", "@docsearch/js": "3.8.2", "@iconify-json/simple-icons": "^1.2.21", "@shikijs/core": "^2.1.0", "@shikijs/transformers": "^2.1.0", "@shikijs/types": "^2.1.0", "@types/markdown-it": "^14.1.2", "@vitejs/plugin-vue": "^5.2.1", "@vue/devtools-api": "^7.7.0", "@vue/shared": "^3.5.13", "@vueuse/core": "^12.4.0", "@vueuse/integrations": "^12.4.0", "focus-trap": "^7.6.4", "mark.js": "8.11.1", "minisearch": "^7.1.1", "shiki": "^2.1.0", "vite": "^5.4.14", "vue": "^3.5.13" }, "peerDependencies": { "markdown-it-mathjax3": "^4", "postcss": "^8" }, "optionalPeers": ["markdown-it-mathjax3"], "bin": "bin/vitepress.js" }, "sha512-+2ym1/+0VVrbhNyRoFFesVvBvHAVMZMK0rw60E3X/5349M1GuVdKeazuksqopEdvkKwKGs21Q729jX81/bkBJg=="],
"vitest": ["vitest@4.1.1", "", { "dependencies": { "@vitest/expect": "4.1.1", "@vitest/mocker": "4.1.1", "@vitest/pretty-format": "4.1.1", "@vitest/runner": "4.1.1", "@vitest/snapshot": "4.1.1", "@vitest/spy": "4.1.1", "@vitest/utils": "4.1.1", "es-module-lexer": "^2.0.0", "expect-type": "^1.3.0", "magic-string": "^0.30.21", "obug": "^2.1.1", "pathe": "^2.0.3", "picomatch": "^4.0.3", "std-env": "^4.0.0-rc.1", "tinybench": "^2.9.0", "tinyexec": "^1.0.2", "tinyglobby": "^0.2.15", "tinyrainbow": "^3.0.3", "vite": "^6.0.0 || ^7.0.0 || ^8.0.0", "why-is-node-running": "^2.3.0" }, "peerDependencies": { "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", "@vitest/browser-playwright": "4.1.1", "@vitest/browser-preview": "4.1.1", "@vitest/browser-webdriverio": "4.1.1", "@vitest/ui": "4.1.1", "happy-dom": "*", "jsdom": "*", "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "optionalPeers": ["@edge-runtime/vm", "@opentelemetry/api", "@vitest/browser-playwright", "@vitest/browser-preview", "@vitest/browser-webdriverio", "@vitest/ui", "happy-dom", "jsdom"], "bin": "vitest.mjs" }, "sha512-yF+o4POL41rpAzj5KVILUxm1GCjKnELvaqmU9TLLUbMfDzuN0UpUR9uaDs+mCtjPe+uYPksXDRLQGGPvj1cTmA=="],
"vue": ["vue@3.5.30", "", { "dependencies": { "@vue/compiler-dom": "3.5.30", "@vue/compiler-sfc": "3.5.30", "@vue/runtime-dom": "3.5.30", "@vue/server-renderer": "3.5.30", "@vue/shared": "3.5.30" }, "peerDependencies": { "typescript": "*" } }, "sha512-hTHLc6VNZyzzEH/l7PFGjpcTvUgiaPK5mdLkbjrTeWSRcEfxFrv56g/XckIYlE9ckuobsdwqd5mk2g1sBkMewg=="],
"why-is-node-running": ["why-is-node-running@2.3.0", "", { "dependencies": { "siginfo": "^2.0.0", "stackback": "0.0.2" }, "bin": "cli.js" }, "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w=="],
"ws": ["ws@8.20.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA=="],
"zwitch": ["zwitch@2.0.4", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="],
"@vitest/mocker/vite": ["vite@8.0.2", "", { "dependencies": { "lightningcss": "^1.32.0", "picomatch": "^4.0.3", "postcss": "^8.5.8", "rolldown": "1.0.0-rc.11", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "@vitejs/devtools": "^0.1.0", "esbuild": "^0.27.0", "jiti": ">=1.21.0", "less": "^4.0.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@vitejs/devtools", "jiti", "less", "sass", "sass-embedded", "stylus", "sugarss", "terser", "yaml"], "bin": "bin/vite.js" }, "sha512-1gFhNi+bHhRE/qKZOJXACm6tX4bA3Isy9KuKF15AgSRuRazNBOJfdDemPBU16/mpMxApDPrWvZ08DcLPEoRnuA=="],
"@vue/compiler-core/estree-walker": ["estree-walker@2.0.2", "", {}, "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="],
"@vue/compiler-sfc/estree-walker": ["estree-walker@2.0.2", "", {}, "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="],
"vite/esbuild": ["esbuild@0.21.5", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.21.5", "@esbuild/android-arm": "0.21.5", "@esbuild/android-arm64": "0.21.5", "@esbuild/android-x64": "0.21.5", "@esbuild/darwin-arm64": "0.21.5", "@esbuild/darwin-x64": "0.21.5", "@esbuild/freebsd-arm64": "0.21.5", "@esbuild/freebsd-x64": "0.21.5", "@esbuild/linux-arm": "0.21.5", "@esbuild/linux-arm64": "0.21.5", "@esbuild/linux-ia32": "0.21.5", "@esbuild/linux-loong64": "0.21.5", "@esbuild/linux-mips64el": "0.21.5", "@esbuild/linux-ppc64": "0.21.5", "@esbuild/linux-riscv64": "0.21.5", "@esbuild/linux-s390x": "0.21.5", "@esbuild/linux-x64": "0.21.5", "@esbuild/netbsd-x64": "0.21.5", "@esbuild/openbsd-x64": "0.21.5", "@esbuild/sunos-x64": "0.21.5", "@esbuild/win32-arm64": "0.21.5", "@esbuild/win32-ia32": "0.21.5", "@esbuild/win32-x64": "0.21.5" }, "bin": "bin/esbuild" }, "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw=="],
"vitest/vite": ["vite@8.0.2", "", { "dependencies": { "lightningcss": "^1.32.0", "picomatch": "^4.0.3", "postcss": "^8.5.8", "rolldown": "1.0.0-rc.11", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "@vitejs/devtools": "^0.1.0", "esbuild": "^0.27.0", "jiti": ">=1.21.0", "less": "^4.0.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@vitejs/devtools", "jiti", "less", "sass", "sass-embedded", "stylus", "sugarss", "terser", "yaml"], "bin": "bin/vite.js" }, "sha512-1gFhNi+bHhRE/qKZOJXACm6tX4bA3Isy9KuKF15AgSRuRazNBOJfdDemPBU16/mpMxApDPrWvZ08DcLPEoRnuA=="],
"vite/esbuild/@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.21.5", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ=="],
"vite/esbuild/@esbuild/android-arm": ["@esbuild/android-arm@0.21.5", "", { "os": "android", "cpu": "arm" }, "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg=="],
"vite/esbuild/@esbuild/android-arm64": ["@esbuild/android-arm64@0.21.5", "", { "os": "android", "cpu": "arm64" }, "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A=="],
"vite/esbuild/@esbuild/android-x64": ["@esbuild/android-x64@0.21.5", "", { "os": "android", "cpu": "x64" }, "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA=="],
"vite/esbuild/@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.21.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ=="],
"vite/esbuild/@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.21.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw=="],
"vite/esbuild/@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.21.5", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g=="],
"vite/esbuild/@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.21.5", "", { "os": "freebsd", "cpu": "x64" }, "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ=="],
"vite/esbuild/@esbuild/linux-arm": ["@esbuild/linux-arm@0.21.5", "", { "os": "linux", "cpu": "arm" }, "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA=="],
"vite/esbuild/@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.21.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q=="],
"vite/esbuild/@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.21.5", "", { "os": "linux", "cpu": "ia32" }, "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg=="],
"vite/esbuild/@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg=="],
"vite/esbuild/@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg=="],
"vite/esbuild/@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.21.5", "", { "os": "linux", "cpu": "ppc64" }, "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w=="],
"vite/esbuild/@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA=="],
"vite/esbuild/@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.21.5", "", { "os": "linux", "cpu": "s390x" }, "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A=="],
"vite/esbuild/@esbuild/linux-x64": ["@esbuild/linux-x64@0.21.5", "", { "os": "linux", "cpu": "x64" }, "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ=="],
"vite/esbuild/@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.21.5", "", { "os": "none", "cpu": "x64" }, "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg=="],
"vite/esbuild/@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.21.5", "", { "os": "openbsd", "cpu": "x64" }, "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow=="],
"vite/esbuild/@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.21.5", "", { "os": "sunos", "cpu": "x64" }, "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg=="],
"vite/esbuild/@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.21.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A=="],
"vite/esbuild/@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.21.5", "", { "os": "win32", "cpu": "ia32" }, "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA=="],
"vite/esbuild/@esbuild/win32-x64": ["@esbuild/win32-x64@0.21.5", "", { "os": "win32", "cpu": "x64" }, "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw=="],
}
}
-82
View File
@@ -1,82 +0,0 @@
[CmdletBinding()]
param(
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$OpenCliArgs
)
$ErrorActionPreference = 'Stop'
$chatwiseExe = 'C:\Program Files\ChatWise\ChatWise.exe'
if (-not (Test-Path $chatwiseExe)) {
throw "ChatWise executable not found at $chatwiseExe"
}
$opencli = Get-Command opencli -ErrorAction SilentlyContinue
if (-not $opencli) {
throw 'opencli was not found in PATH'
}
function Clear-LocalProxyEnv {
$vars = 'http_proxy','https_proxy','HTTP_PROXY','HTTPS_PROXY'
foreach ($name in $vars) {
Set-Item -Path "Env:$name" -Value ''
}
$noProxy = '127.0.0.1,localhost'
Set-Item -Path 'Env:NO_PROXY' -Value $noProxy
Set-Item -Path 'Env:no_proxy' -Value $noProxy
}
function Stop-ChatWiseTree {
$candidates = Get-CimInstance Win32_Process |
Where-Object { $_.Name -match '^ChatWise\.exe$|^chatwise\.exe$' }
foreach ($proc in $candidates) {
try {
Stop-Process -Id $proc.ProcessId -Force -ErrorAction Stop
} catch {}
}
Start-Sleep -Seconds 2
}
function Wait-ChatWiseDebugPort {
param(
[int]$Port = 9228,
[int]$TimeoutSeconds = 20
)
$deadline = (Get-Date).AddSeconds($TimeoutSeconds)
while ((Get-Date) -lt $deadline) {
try {
$resp = Invoke-WebRequest -UseBasicParsing -TimeoutSec 2 -Uri "http://127.0.0.1:$Port/json/version"
if ($resp.StatusCode -ge 200 -and $resp.StatusCode -lt 300) {
return
}
} catch {}
Start-Sleep -Milliseconds 500
}
throw "ChatWise debugging endpoint did not come up on 127.0.0.1:$Port"
}
Clear-LocalProxyEnv
Stop-ChatWiseTree
$proc = Start-Process -FilePath $chatwiseExe -ArgumentList '--remote-debugging-port=9228' -PassThru
Start-Sleep -Seconds 4
if ($proc.HasExited) {
throw "ChatWise exited early with code $($proc.ExitCode)"
}
Wait-ChatWiseDebugPort
$env:OPENCLI_CDP_ENDPOINT = 'http://127.0.0.1:9228'
if (-not $OpenCliArgs -or $OpenCliArgs.Count -eq 0) {
& $opencli.Source 'chatwise' 'status'
exit $LASTEXITCODE
}
& $opencli.Source @OpenCliArgs
exit $LASTEXITCODE
+42
View File
@@ -0,0 +1,42 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './assets.js';
import { __test__ as sharedTest } from './shared.js';
describe('1688 assets normalization', () => {
it('normalizes gallery and scanned assets into grouped media lists', () => {
const result = __test__.normalizeAssets({
href: 'https://detail.1688.com/offer/887904326744.html',
title: '测试商品 - 阿里巴巴',
offerTitle: '测试商品',
offerId: 887904326744,
gallery: {
mainImage: ['//img.example.com/main-1.jpg'],
offerImgList: ['https://img.example.com/main-2.jpg'],
wlImageInfos: [{ fullPathImageURI: 'https://img.example.com/main-3.jpg' }],
},
scannedAssets: [
{ type: 'image', group: 'sku', url: 'https://img.example.com/sku-1.png', source: 'dom:.sku' },
{ type: 'image', group: 'detail', url: 'https://img.example.com/detail-1.jpg', source: 'dom:.detail' },
{ type: 'video', group: 'video', url: 'https://video.example.com/demo.mp4', source: 'script' },
{ type: 'image', group: 'detail', url: 'blob:https://detail.1688.com/1', source: 'ignore' },
],
});
expect(result.offer_id).toBe('887904326744');
expect(result.main_images).toEqual([
'https://img.example.com/main-1.jpg',
'https://img.example.com/main-2.jpg',
'https://img.example.com/main-3.jpg',
]);
expect(result.sku_images).toEqual(['https://img.example.com/sku-1.png']);
expect(result.detail_images).toEqual(['https://img.example.com/detail-1.jpg']);
expect(result.videos).toEqual(['https://video.example.com/demo.mp4']);
expect(result.main_count).toBe(3);
expect(result.video_count).toBe(1);
});
it('normalizes media urls from style syntax and protocol-relative URLs', () => {
expect(sharedTest.normalizeMediaUrl('url("//img.example.com/1.jpg")')).toBe('https://img.example.com/1.jpg');
expect(sharedTest.normalizeMediaUrl('blob:https://detail.1688.com/1')).toBe('');
});
});
+257
View File
@@ -0,0 +1,257 @@
import { cli, Strategy } from '@jackwener/opencli/registry';
import type { IPage } from '@jackwener/opencli/types';
import {
assertAuthenticatedState,
buildDetailUrl,
buildProvenance,
cleanText,
extractOfferId,
gotoAndReadState,
type MediaSource,
uniqueMediaSources,
} from './shared.js';
interface AssetBrowserPayload {
href?: string;
title?: string;
offerTitle?: string;
offerId?: string | number;
gallery?: {
mainImage?: string[];
offerImgList?: string[];
wlImageInfos?: Array<{ fullPathImageURI?: string }>;
[key: string]: unknown;
};
scannedAssets?: MediaSource[];
}
export interface Normalized1688Assets {
offer_id: string | null;
title: string | null;
item_url: string;
main_images: string[];
sku_images: string[];
detail_images: string[];
videos: string[];
other_images: string[];
raw_assets: MediaSource[];
source: string[];
main_count: number;
sku_count: number;
detail_count: number;
video_count: number;
source_url: string;
fetched_at: string;
strategy: string;
}
function scriptToReadAssets(): string {
return `
(() => {
const root = window.context ?? {};
const model = root.result?.global?.globalData?.model ?? null;
const gallery = root.result?.data?.gallery?.fields ?? null;
const defaultSrcProps = ['data-lazyload-src', 'data-src', 'data-ks-lazyload', 'currentSrc', 'src'];
const groups = [
{ key: 'main', type: 'image', selectors: ['#dt-tab img', '.detail-gallery-turn img.detail-gallery-img', '.img-list-wrapper img.od-gallery-img', '.od-scroller-item span'] },
{ key: 'video', type: 'video', selectors: ['.lib-video video', 'video[src]', 'video source[src]'] },
{ key: 'sku', type: 'image', selectors: ['.pc-sku-wrapper .prop-item-inner-wrapper', '.sku-item-wrapper', '.specification-cell', '.sku-filter-button', '.expand-view-item', '.feature-item img'], srcProps: ['backgroundImage'] },
{ key: 'detail', type: 'image', selectors: ['.de-description-detail img', '#detailContentContainer img', '.html-description img', '.html-description source', '.desc-lazyload-container img'] },
];
const assets = [];
const seen = new Set();
const normalizeUrl = (value) => {
if (typeof value !== 'string') return '';
let next = value
.replace(/^url\\((.*)\\)$/i, '$1')
.replace(/^['"]|['"]$/g, '')
.replace(/\\\\u002F/g, '/')
.replace(/&amp;/g, '&')
.trim();
if (!next || next.startsWith('blob:') || next.startsWith('data:')) return '';
if (next.startsWith('//')) next = 'https:' + next;
try {
return new URL(next, location.href).toString();
} catch {
return '';
}
};
const push = (type, group, url, source) => {
const normalized = normalizeUrl(url);
if (!normalized) return;
const key = type + ':' + normalized;
if (seen.has(key)) return;
seen.add(key);
assets.push({ type, group, url: normalized, source });
};
const queryAllDeep = (selector) => {
const results = [];
const visitedRoots = new Set();
const walkRoots = (root, fn) => {
if (!root || visitedRoots.has(root)) return;
visitedRoots.add(root);
fn(root);
const childElements = root.querySelectorAll ? Array.from(root.querySelectorAll('*')) : [];
for (const child of childElements) {
if (child && child.shadowRoot) {
walkRoots(child.shadowRoot, fn);
}
}
};
walkRoots(document, (root) => {
if (root.querySelectorAll) {
results.push(...Array.from(root.querySelectorAll(selector)));
}
});
return results;
};
const valuesFromElement = (element, srcProps) => {
const values = [];
const props = srcProps && srcProps.length ? srcProps : defaultSrcProps;
for (const prop of props) {
try {
if (prop === 'backgroundImage') {
const bg = getComputedStyle(element).backgroundImage || '';
const matches = bg.match(/url\\(([^)]+)\\)/g) || [];
for (const match of matches) {
const clean = match.replace(/^url\\(/, '').replace(/\\)$/, '');
values.push(clean);
}
continue;
}
const direct = element[prop];
if (typeof direct === 'string' && direct) values.push(direct);
const attr = element.getAttribute ? element.getAttribute(prop) : '';
if (attr) values.push(attr);
} catch {}
}
if (element.tagName === 'SOURCE' && element.parentElement?.tagName === 'VIDEO') {
values.push(element.src || element.getAttribute('src') || '');
}
if (element.tagName === 'VIDEO') {
values.push(element.currentSrc || '');
values.push(element.src || '');
}
return values;
};
for (const group of groups) {
for (const selector of group.selectors) {
for (const element of queryAllDeep(selector)) {
for (const value of valuesFromElement(element, group.srcProps)) {
push(group.type, group.key, value, 'dom:' + selector);
}
}
}
}
const scriptTexts = Array.from(document.scripts).map((script) => script.textContent || '');
const videoRegex = /https?:\\/\\/[^"'\\s]+\\.(?:mp4|m3u8)(?:\\?[^"'\\s]*)?/gi;
for (const scriptText of scriptTexts) {
const matches = scriptText.match(videoRegex) || [];
for (const match of matches) {
push('video', 'video', match, 'script');
}
}
const toJson = (value) => JSON.parse(JSON.stringify(value ?? null));
return {
href: window.location.href,
title: document.title || '',
offerTitle: model?.offerTitleModel?.subject ?? '',
offerId: model?.tradeModel?.offerId ?? '',
gallery: toJson(gallery),
scannedAssets: assets,
};
})()
`;
}
function normalizeAssets(payload: AssetBrowserPayload): Normalized1688Assets {
const offerId = cleanText(String(payload.offerId ?? '')) || extractOfferId(cleanText(payload.href)) || null;
const itemUrl = offerId ? buildDetailUrl(offerId) : cleanText(payload.href);
const seededAssets: MediaSource[] = [
...((payload.gallery?.mainImage ?? []).map((url) => ({ type: 'image' as const, group: 'main' as const, url, source: 'page_state:mainImage' }))),
...((payload.gallery?.offerImgList ?? []).map((url) => ({ type: 'image' as const, group: 'main' as const, url, source: 'page_state:offerImgList' }))),
...((payload.gallery?.wlImageInfos ?? []).map((item) => ({
type: 'image' as const,
group: 'main' as const,
url: item?.fullPathImageURI ?? '',
source: 'page_state:wlImageInfos',
}))),
];
const assets = uniqueMediaSources([...seededAssets, ...(payload.scannedAssets ?? [])]);
const mainImages = assets.filter((item) => item.type === 'image' && item.group === 'main').map((item) => item.url);
const skuImages = assets.filter((item) => item.type === 'image' && item.group === 'sku').map((item) => item.url);
const detailImages = assets.filter((item) => item.type === 'image' && item.group === 'detail').map((item) => item.url);
const videos = assets.filter((item) => item.type === 'video').map((item) => item.url);
const otherImages = assets
.filter((item) => item.type === 'image' && !['main', 'sku', 'detail'].includes(item.group))
.map((item) => item.url);
return {
offer_id: offerId,
title: cleanText(payload.offerTitle) || cleanText(payload.title) || null,
item_url: itemUrl,
main_images: mainImages,
sku_images: skuImages,
detail_images: detailImages,
videos,
other_images: otherImages,
raw_assets: assets,
source: [...new Set(assets.map((item) => cleanText(item.source)).filter(Boolean))],
main_count: mainImages.length,
sku_count: skuImages.length,
detail_count: detailImages.length,
video_count: videos.length,
...buildProvenance(cleanText(payload.href) || itemUrl),
};
}
async function readAssetsPayload(page: IPage, itemUrl: string): Promise<AssetBrowserPayload> {
const state = await gotoAndReadState(page, itemUrl, 2500, 'assets');
assertAuthenticatedState(state, 'assets');
await page.autoScroll({ times: 3, delayMs: 400 });
await page.wait(1);
return await page.evaluate(scriptToReadAssets()) as AssetBrowserPayload;
}
export async function extractAssetsForInput(page: IPage, input: string): Promise<Normalized1688Assets> {
const itemUrl = buildDetailUrl(String(input ?? ''));
const payload = await readAssetsPayload(page, itemUrl);
return normalizeAssets(payload);
}
cli({
site: '1688',
name: 'assets',
description: '列出 1688 商品页可提取的图片/视频素材',
domain: 'www.1688.com',
strategy: Strategy.COOKIE,
args: [
{
name: 'input',
required: true,
positional: true,
help: '1688 商品 URL 或 offer ID(如 887904326744',
},
],
columns: ['offer_id', 'title', 'main_count', 'sku_count', 'detail_count', 'video_count'],
func: async (page, kwargs) => {
return [await extractAssetsForInput(page, String(kwargs.input ?? ''))];
},
});
export const __test__ = {
normalizeAssets,
};
+33
View File
@@ -0,0 +1,33 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './download.js';
describe('1688 download helpers', () => {
it('builds stable filenames for grouped assets', () => {
const items = __test__.toDownloadItems('887904326744', {
offer_id: '887904326744',
title: '测试商品',
item_url: 'https://detail.1688.com/offer/887904326744.html',
main_images: ['https://img.example.com/a.jpg'],
sku_images: ['https://img.example.com/b.png'],
detail_images: ['https://img.example.com/c.webp'],
videos: ['https://video.example.com/d.mp4'],
other_images: [],
raw_assets: [],
source: [],
main_count: 1,
sku_count: 1,
detail_count: 1,
video_count: 1,
source_url: 'https://detail.1688.com/offer/887904326744.html',
fetched_at: new Date().toISOString(),
strategy: 'cookie',
});
expect(items.map((item) => item.filename)).toEqual([
'887904326744_main_01.jpg',
'887904326744_sku_01.png',
'887904326744_detail_01.webp',
'887904326744_video_01.mp4',
]);
});
});
+83
View File
@@ -0,0 +1,83 @@
import * as path from 'node:path';
import { formatCookieHeader } from '@jackwener/opencli/download';
import { downloadMedia, type MediaItem } from '@jackwener/opencli/download/media-download';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { cleanText } from './shared.js';
import { extractAssetsForInput } from './assets.js';
function extFromUrl(url: string, fallback: string): string {
try {
const ext = path.extname(new URL(url).pathname).toLowerCase();
if (ext && ext.length <= 8) return ext;
} catch {
// ignore
}
return fallback;
}
function toDownloadItems(offerId: string, assets: Awaited<ReturnType<typeof extractAssetsForInput>>): MediaItem[] {
const items: MediaItem[] = [];
const pushImages = (urls: string[], prefix: string) => {
urls.forEach((url, index) => {
items.push({
type: 'image',
url,
filename: `${offerId}_${prefix}_${String(index + 1).padStart(2, '0')}${extFromUrl(url, '.jpg')}`,
});
});
};
pushImages(assets.main_images, 'main');
pushImages(assets.sku_images, 'sku');
pushImages(assets.detail_images, 'detail');
pushImages(assets.other_images, 'other');
assets.videos.forEach((url, index) => {
items.push({
type: 'video',
url,
filename: `${offerId}_video_${String(index + 1).padStart(2, '0')}${extFromUrl(url, '.mp4')}`,
});
});
return items;
}
cli({
site: '1688',
name: 'download',
description: '批量下载 1688 商品页可提取的图片和视频素材',
domain: 'www.1688.com',
strategy: Strategy.COOKIE,
args: [
{
name: 'input',
required: true,
positional: true,
help: '1688 商品 URL 或 offer ID(如 887904326744',
},
{ name: 'output', default: './1688-downloads', help: '输出目录' },
],
columns: ['index', 'type', 'status', 'size'],
func: async (page, kwargs) => {
const assets = await extractAssetsForInput(page, String(kwargs.input ?? ''));
const offerId = cleanText(assets.offer_id) || '1688';
const items = toDownloadItems(offerId, assets);
const browserCookies = await page.getCookies({ domain: '1688.com' });
return downloadMedia(items, {
output: String(kwargs.output || './1688-downloads'),
subdir: offerId,
cookies: formatCookieHeader(browserCookies),
browserCookies,
filenamePrefix: offerId,
timeout: 60000,
});
},
});
export const __test__ = {
extFromUrl,
toDownloadItems,
};
+69
View File
@@ -0,0 +1,69 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './item.js';
describe('1688 item normalization', () => {
it('normalizes public item payload into contract fields', () => {
const result = __test__.normalizeItemPayload({
href: 'https://detail.1688.com/offer/887904326744.html',
title: '法式春季长袖开衫连衣裙女新款大码女装碎花吊带裙套装142077 - 阿里巴巴',
bodyText: `
青岛沁澜衣品服装有限公司
入驻13年
主营:大码女装
店铺回头率
87%
山东青岛
3套起批
已售1600+套
支持定制logo
`,
offerTitle: '法式春季长袖开衫连衣裙女新款大码女装碎花吊带裙套装142077',
offerId: 887904326744,
seller: {
companyName: '青岛沁澜衣品服装有限公司',
memberId: 'b2b-1641351767',
winportUrl: 'https://yinuoweierfushi.1688.com/page/index.html?spm=a1',
},
trade: {
beginAmount: 3,
priceDisplay: '96.00-98.00',
unit: '套',
saleCount: 1655,
offerIDatacenterSellInfo: {
: '莫代尔',
: '莫代尔纤维',
sellPointModel: '{"ignore":true}',
},
offerPriceModel: {
currentPrices: [
{ beginAmount: 3, price: '98.00' },
{ beginAmount: 50, price: '97.00' },
],
},
},
gallery: {
mainImage: ['https://example.com/1.jpg'],
offerImgList: ['https://example.com/2.jpg'],
wlImageInfos: [{ fullPathImageURI: 'https://example.com/3.jpg' }],
},
services: [
{ serviceName: '延期必赔', agreeDeliveryHours: 360 },
{ serviceName: '品质保障' },
],
});
expect(result.offer_id).toBe('887904326744');
expect(result.member_id).toBe('b2b-1641351767');
expect(result.shop_id).toBe('yinuoweierfushi');
expect(result.seller_url).toBe('https://yinuoweierfushi.1688.com');
expect(result.price_text).toBe('¥96.00-98.00');
expect(result.moq_text).toBe('3套起批');
expect(result.origin_place).toBe('山东青岛');
expect(result.delivery_days_text).toBe('360小时内发货');
expect(result.private_label_text).toBe('支持定制logo');
expect(result.visible_attributes).toEqual([
{ key: '面料名称', value: '莫代尔' },
{ key: '主面料成分', value: '莫代尔纤维' },
]);
});
});
+282
View File
@@ -0,0 +1,282 @@
import { CommandExecutionError } from '@jackwener/opencli/errors';
import { cli, Strategy } from '@jackwener/opencli/registry';
import type { IPage } from '@jackwener/opencli/types';
import { isRecord } from '@jackwener/opencli/utils';
import {
assertAuthenticatedState,
buildDetailUrl,
buildProvenance,
canonicalizeSellerUrl,
cleanMultilineText,
cleanText,
extractLocation,
extractMemberId,
extractOfferId,
extractShopId,
gotoAndReadState,
normalizePriceTiers,
parseMoqText,
parsePriceText,
toNumber,
uniqueNonEmpty,
} from './shared.js';
interface BuyerProtectionModel {
serviceName?: string;
shortBuyerDesc?: string;
packageBuyerDesc?: string;
textDesc?: string;
agreeDeliveryHours?: number;
}
interface ItemBrowserPayload {
href?: string;
title?: string;
bodyText?: string;
offerTitle?: string;
offerId?: string | number;
seller?: {
companyName?: string;
memberId?: string;
winportUrl?: string;
sellerWinportUrlMap?: Record<string, string>;
};
trade?: {
beginAmount?: string | number;
priceDisplay?: string;
unit?: string;
saleCount?: string | number;
offerIDatacenterSellInfo?: Record<string, unknown>;
offerPriceModel?: {
currentPrices?: Array<{ beginAmount?: string | number; price?: string | number }>;
};
};
gallery?: {
mainImage?: string[];
offerImgList?: string[];
wlImageInfos?: Array<{ fullPathImageURI?: string }>;
};
shipping?: {
deliveryLimitText?: string;
logisticsText?: string;
protectionInfos?: BuyerProtectionModel[];
buyerProtectionModel?: BuyerProtectionModel[];
};
services?: BuyerProtectionModel[];
}
interface VisibleAttribute {
key: string;
value: string;
}
function normalizeItemPayload(payload: ItemBrowserPayload): Record<string, unknown> {
const href = cleanText(payload.href);
const bodyText = cleanMultilineText(payload.bodyText);
const sellerName = cleanText(payload.seller?.companyName);
const sellerUrlRaw = cleanText(
payload.seller?.winportUrl
?? payload.seller?.sellerWinportUrlMap?.defaultUrl
?? payload.seller?.sellerWinportUrlMap?.indexUrl,
);
const sellerUrl = canonicalizeSellerUrl(sellerUrlRaw);
const offerId = cleanText(String(payload.offerId ?? '')) || extractOfferId(href) || null;
const memberId = cleanText(payload.seller?.memberId) || extractMemberId(sellerUrlRaw || href) || null;
const shopId = extractShopId(sellerUrl ?? href);
const unit = cleanText(payload.trade?.unit);
const priceDisplay = cleanText(payload.trade?.priceDisplay);
const priceRange = parsePriceText(priceDisplay ? `¥${priceDisplay}` : bodyText);
const moqText = extractMoqText(bodyText, payload.trade?.beginAmount, unit);
const moq = parseMoqText(moqText);
const services = uniqueServices(payload);
const serviceBadges = uniqueNonEmpty(services.map((service) => cleanText(service.serviceName)));
const attributes = normalizeVisibleAttributes(payload.trade?.offerIDatacenterSellInfo);
const priceTiers = normalizePriceTiers(payload.trade?.offerPriceModel?.currentPrices ?? [], unit || null);
const images = uniqueNonEmpty([
...(payload.gallery?.mainImage ?? []),
...(payload.gallery?.offerImgList ?? []),
...((payload.gallery?.wlImageInfos ?? []).map((item) => item.fullPathImageURI ?? '')),
]);
const detailUrl = offerId ? buildDetailUrl(offerId) : href;
const provenance = buildProvenance(href || detailUrl);
return {
offer_id: offerId,
member_id: memberId,
shop_id: shopId,
title: cleanText(payload.offerTitle) || stripAlibabaSuffix(payload.title) || firstNonEmptyLine(bodyText) || null,
item_url: detailUrl,
main_images: images,
price_text: priceRange.price_text || null,
price_tiers: priceTiers,
currency: priceRange.currency,
moq_text: moq.moq_text || null,
moq_value: moq.moq_value,
seller_name: sellerName || null,
seller_url: sellerUrl,
shop_name: sellerName || null,
origin_place: extractLocation(bodyText),
delivery_days_text: extractDeliveryDaysText(bodyText, services, payload.shipping),
customization_text: extractKeywordLine(bodyText, ['来样定制', '来图定制', '支持定制', '可定制', '定制']),
private_label_text: extractKeywordLine(bodyText, ['贴牌', '贴标', '定制logo', '打logo', 'OEM', 'ODM']),
visible_attributes: attributes,
sales_text: extractSalesText(bodyText),
service_badges: serviceBadges,
stock_quantity: extractStockQuantity(bodyText),
...provenance,
};
}
function normalizeVisibleAttributes(raw: unknown): VisibleAttribute[] {
if (!isRecord(raw)) return [];
return Object.entries(raw)
.filter(([key, value]) => key !== 'sellPointModel' && cleanText(key) && cleanText(String(value)))
.map(([key, value]) => ({ key: cleanText(key), value: cleanText(String(value)) }));
}
function uniqueServices(payload: ItemBrowserPayload): BuyerProtectionModel[] {
const combined = [
...(Array.isArray(payload.services) ? payload.services : []),
...(Array.isArray(payload.shipping?.protectionInfos) ? payload.shipping.protectionInfos : []),
...(Array.isArray(payload.shipping?.buyerProtectionModel) ? payload.shipping.buyerProtectionModel : []),
];
const seen = new Set<string>();
const result: BuyerProtectionModel[] = [];
for (const service of combined) {
const key = cleanText(service.serviceName);
if (!key || seen.has(key)) continue;
seen.add(key);
result.push(service);
}
return result;
}
function stripAlibabaSuffix(title: string | undefined): string {
return cleanText(title).replace(/\s*-\s*阿里巴巴$/, '').trim();
}
function firstNonEmptyLine(text: string): string {
return text.split('\n').map((line) => cleanText(line)).find(Boolean) ?? '';
}
function extractMoqText(bodyText: string, beginAmount: string | number | undefined, unit: string): string {
const lineMatch = bodyText.match(/\d+(?:\.\d+)?\s*(件|个|套|箱|包|双|台|把|只)\s*起批/);
if (lineMatch) return lineMatch[0];
const moqValue = toNumber(beginAmount);
if (moqValue !== null) {
return `${moqValue}${unit || ''}起批`;
}
return '';
}
function extractDeliveryDaysText(
bodyText: string,
services: BuyerProtectionModel[],
shipping: ItemBrowserPayload['shipping'],
): string | null {
const shippingText = cleanText(shipping?.deliveryLimitText) || cleanText(shipping?.logisticsText);
if (shippingText) return shippingText;
const textMatch = bodyText.match(/\d+\s*(?:小时|天)(?:内)?发货/);
if (textMatch) return textMatch[0];
const hourMatch = services.find((service) => typeof service.agreeDeliveryHours === 'number');
if (hourMatch && typeof hourMatch.agreeDeliveryHours === 'number') {
return `${hourMatch.agreeDeliveryHours}小时内发货`;
}
return null;
}
function extractKeywordLine(bodyText: string, keywords: string[]): string | null {
const lines = bodyText.split('\n').map((line) => cleanText(line)).filter(Boolean);
for (const line of lines) {
if (keywords.some((keyword) => line.includes(keyword))) {
return line;
}
}
return null;
}
function extractSalesText(bodyText: string): string | null {
const match = bodyText.match(/(?:全网销量|已售)\s*\d+(?:\.\d+)?\+?\s*[件套个单]?/);
return match ? cleanText(match[0]) : null;
}
function extractStockQuantity(bodyText: string): number | null {
const match = bodyText.match(/库存\s*(\d+)/);
return match ? Number.parseInt(match[1], 10) : null;
}
async function readItemPayload(page: IPage, itemUrl: string): Promise<ItemBrowserPayload> {
const state = await gotoAndReadState(page, itemUrl, 2500, 'item');
assertAuthenticatedState(state, 'item');
const payload = await page.evaluate(`
(() => {
const root = window.context ?? {};
const model = root.result?.global?.globalData?.model ?? null;
const toJson = (value) => JSON.parse(JSON.stringify(value ?? null));
return {
href: window.location.href,
title: document.title || '',
bodyText: document.body ? document.body.innerText || '' : '',
offerTitle: model?.offerTitleModel?.subject ?? '',
offerId: model?.tradeModel?.offerId ?? '',
seller: toJson(model?.sellerModel),
trade: toJson(model?.tradeModel),
gallery: toJson(root.result?.data?.gallery?.fields ?? null),
shipping: toJson(root.result?.data?.shippingServices?.fields ?? null),
services: toJson(root.result?.data?.shippingServices?.fields?.protectionInfos ?? []),
};
})()
`) as ItemBrowserPayload;
const resolvedOfferId = cleanText(String(payload.offerId ?? '')) || extractOfferId(cleanText(payload.href));
if (!resolvedOfferId) {
throw new CommandExecutionError(
'1688 item page did not expose product context',
'当前 tab 非商品详情上下文,请切到 detail.1688.com 商品页并重试',
);
}
return payload;
}
cli({
site: '1688',
name: 'item',
description: '1688 商品详情(公开商品字段、价格阶梯、卖家基础信息)',
domain: 'www.1688.com',
strategy: Strategy.COOKIE,
navigateBefore: false,
args: [
{
name: 'input',
required: true,
positional: true,
help: '1688 商品 URL 或 offer ID(如 887904326744',
},
],
columns: ['offer_id', 'title', 'price_text', 'moq_text', 'seller_name', 'origin_place'],
func: async (page, kwargs) => {
const itemUrl = buildDetailUrl(String(kwargs.input ?? ''));
const payload = await readItemPayload(page, itemUrl);
return [normalizeItemPayload(payload)];
},
});
export const __test__ = {
normalizeItemPayload,
normalizeVisibleAttributes,
stripAlibabaSuffix,
extractMoqText,
extractDeliveryDaysText,
extractKeywordLine,
extractSalesText,
extractStockQuantity,
};
+81
View File
@@ -0,0 +1,81 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './search.js';
describe('1688 search normalization', () => {
it('normalizes search candidates into structured result rows', () => {
const result = __test__.normalizeSearchCandidate({
item_url: 'https://detail.1688.com/offer/887904326744.html',
title: '宿舍置物架桌面加高架',
container_text: '宿舍置物架桌面加高架 ¥56.00 2套起批 山东青岛 已售300+套',
price_text: '¥ 56 .00',
sales_text: '300+套',
moq_text: '2套起批',
tag_items: ['退货包运费', '回头率52%'],
hover_items: ['验厂报告'],
seller_name: '青岛沁澜衣品服装有限公司',
seller_url: 'https://yinuoweierfushi.1688.com/page/index.html?spm=a123',
}, 'https://s.1688.com/selloffer/offer_search.htm?charset=utf8&keywords=置物架');
expect(result.rank).toBe(0);
expect(result.offer_id).toBe('887904326744');
expect(result.shop_id).toBe('yinuoweierfushi');
expect(result.item_url).toBe('https://detail.1688.com/offer/887904326744.html');
expect(result.seller_url).toBe('https://yinuoweierfushi.1688.com');
expect(result.price_text).toBe('¥56.00');
expect(result.price_min).toBe(56);
expect(result.price_max).toBe(56);
expect(result.moq_value).toBe(2);
expect(result.location).toBe('山东青岛');
expect(result.sales_text).toBe('300+套');
expect(result.badges).toEqual(expect.arrayContaining(['退货包运费', '验厂报告']));
expect(result.return_rate_text).toBe('回头率52%');
});
it('does not use hover_price_text as MOQ source', () => {
const result = __test__.normalizeSearchCandidate({
item_url: 'https://detail.1688.com/offer/887904326744.html',
title: 'test',
container_text: 'test ¥56.00',
price_text: '¥ 56 .00',
hover_price_text: '¥56.00 3件起批',
moq_text: null,
}, 'https://s.1688.com/selloffer/offer_search.htm?charset=utf8&keywords=test');
// hover_price_text should not be used for MOQ extraction
expect(result.moq_text).toBeNull();
expect(result.moq_value).toBeNull();
});
it('extracts offer id from mobile detail search links', () => {
const result = __test__.normalizeSearchCandidate({
item_url: 'http://detail.m.1688.com/page/index.html?offerId=910933345396&sortType=&pageId=',
title: '',
container_text: '桌面书桌办公室工位收纳展示新中式博古架多层茶具厨房摆放置物架 ¥24.3 已售20+件',
price_text: '¥ 14 .28',
sales_text: '1500+件',
moq_text: '≥2个',
seller_name: '泰商国际贸易(宁阳)有限公司',
seller_url: 'http://tsgjmy.1688.com/',
}, 'https://s.1688.com/selloffer/offer_search.htm?charset=utf8&keywords=桌面置物架');
expect(result.offer_id).toBe('910933345396');
expect(result.shop_id).toBe('tsgjmy');
expect(result.item_url).toBe('https://detail.1688.com/offer/910933345396.html');
expect(result.title).toContain('桌面书桌办公室工位收纳展示');
expect(result.price_text).toBe('¥14.28');
expect(result.sales_text).toBe('1500+件');
expect(result.moq_text).toBe('≥2个');
expect(result.moq_value).toBe(2);
});
it('prefers offer id and falls back to item url for dedupe key', () => {
expect(__test__.buildDedupeKey({
offer_id: '123456',
item_url: 'https://detail.1688.com/offer/123456.html',
})).toBe('offer:123456');
expect(__test__.buildDedupeKey({
offer_id: null,
item_url: 'https://detail.1688.com/offer/123456.html',
})).toBe('url:https://detail.1688.com/offer/123456.html');
expect(__test__.buildDedupeKey({ offer_id: null, item_url: null })).toBeNull();
});
});
+402
View File
@@ -0,0 +1,402 @@
import { CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
import { cli, Strategy } from '@jackwener/opencli/registry';
import type { IPage } from '@jackwener/opencli/types';
import {
FACTORY_BADGE_PATTERNS,
SERVICE_BADGE_PATTERNS,
assertAuthenticatedState,
buildProvenance,
buildSearchUrl,
canonicalizeItemUrl,
canonicalizeSellerUrl,
cleanText,
extractBadges,
extractLocation,
extractMemberId,
extractOfferId,
extractShopId,
gotoAndReadState,
parseMoqText,
parsePriceText,
SEARCH_LIMIT_DEFAULT,
SEARCH_LIMIT_MAX,
parseSearchLimit,
uniqueNonEmpty,
} from './shared.js';
interface SearchPayload {
href?: string;
title?: string;
bodyText?: string;
next_url?: string;
candidates?: Array<{
item_url?: string;
title?: string;
container_text?: string;
desc_rows?: string[];
price_text?: string | null;
sales_text?: string | null;
hover_price_text?: string | null;
moq_text?: string | null;
tag_items?: string[];
hover_items?: string[];
seller_name?: string | null;
seller_url?: string | null;
}>;
}
interface SearchRow {
rank: number;
offer_id: string | null;
member_id: string | null;
shop_id: string | null;
title: string | null;
item_url: string | null;
seller_name: string | null;
seller_url: string | null;
price_text: string | null;
price_min: number | null;
price_max: number | null;
currency: string | null;
moq_text: string | null;
moq_value: number | null;
location: string | null;
badges: string[];
sales_text: string | null;
return_rate_text: string | null;
source_url: string;
fetched_at: string;
strategy: string;
}
const SEARCH_ITEM_URL_PATTERNS = [
'detail.1688.com/offer/',
'detail.m.1688.com/page/index.html?offerId=',
];
const MAX_SEARCH_PAGES = 12;
function normalizeSearchCandidate(
candidate: NonNullable<SearchPayload['candidates']>[number],
sourceUrl: string,
): SearchRow {
const canonicalItemUrl = canonicalizeItemUrl(cleanText(candidate.item_url));
const containerText = cleanText(candidate.container_text);
const priceText = firstNonEmpty([
normalizeInlineText(candidate.price_text),
normalizeInlineText(extractPriceText(candidate.hover_price_text)),
]);
const priceRange = parsePriceText(priceText || containerText);
const moq = parseMoqText(firstNonEmpty([
normalizeInlineText(candidate.moq_text),
normalizeInlineText(extractMoqText(containerText)),
]));
const canonicalSellerUrl = canonicalizeSellerUrl(cleanText(candidate.seller_url));
const evidenceText = uniqueNonEmpty([
containerText,
...(candidate.desc_rows ?? []),
...(candidate.tag_items ?? []),
...(candidate.hover_items ?? []),
]).join('\n');
const badges = extractBadges(evidenceText, [...FACTORY_BADGE_PATTERNS, ...SERVICE_BADGE_PATTERNS]);
const salesText = firstNonEmpty([
extractSalesText(candidate.sales_text),
extractSalesText(containerText),
]);
const returnRateText = extractReturnRateText([...(candidate.tag_items ?? []), ...(candidate.hover_items ?? [])]);
const provenance = buildProvenance(sourceUrl);
return {
rank: 0,
offer_id: extractOfferId(canonicalItemUrl ?? '') ?? null,
member_id: extractMemberId(canonicalSellerUrl ?? '') ?? null,
shop_id: extractShopId(canonicalSellerUrl ?? '') ?? null,
title: cleanText(candidate.title) || firstWord(containerText) || null,
item_url: canonicalItemUrl,
seller_name: cleanText(candidate.seller_name) || null,
seller_url: canonicalSellerUrl,
price_text: priceRange.price_text || null,
price_min: priceRange.price_min,
price_max: priceRange.price_max,
currency: priceRange.currency,
moq_text: moq.moq_text || null,
moq_value: moq.moq_value,
location: extractLocation(containerText),
badges,
sales_text: salesText || null,
return_rate_text: returnRateText,
source_url: provenance.source_url,
fetched_at: provenance.fetched_at,
strategy: provenance.strategy,
};
}
function extractMoqText(text: string | null | undefined): string {
const normalized = normalizeInlineText(text);
return normalized.match(/\d+(?:\.\d+)?\s*(件|个|套|箱|包|双|台|把|只)\s*起批/i)?.[0]
?? normalized.match(/≥\s*\d+(?:\.\d+)?\s*(件|个|套|箱|包|双|台|把|只)?/i)?.[0]
?? normalized.match(/\d+(?:\.\d+)?\s*(?:~|-|至|到)\s*\d+(?:\.\d+)?\s*(件|个|套|箱|包|双|台|把|只)/i)?.[0]
?? '';
}
function extractPriceText(text: string | null | undefined): string {
const normalized = normalizeInlineText(text);
return normalized.match(/[¥$€]\s*\d+(?:\.\d+)?/)?.[0] ?? '';
}
function extractSalesText(text: string | null | undefined): string {
const normalized = normalizeInlineText(text);
if (!normalized) return '';
if (/^\d+(?:\.\d+)?\+?\s*(件|套|个|单)$/.test(normalized)) {
return normalized;
}
const match = normalized.match(/(?:已售|销量|售)\s*\d+(?:\.\d+)?\+?\s*(件|套|个|单)?/);
return match ? cleanText(match[0]) : '';
}
function firstWord(text: string): string {
return text.split(/\s+/).find(Boolean) ?? '';
}
function firstNonEmpty(values: Array<string | null | undefined>): string {
return values.map((value) => cleanText(value)).find(Boolean) ?? '';
}
function normalizeInlineText(text: string | null | undefined): string {
return cleanText(text)
.replace(/([¥$€])\s+(?=\d)/g, '$1')
.replace(/(\d)\s*\.\s*(\d)/g, '$1.$2')
.replace(/\s*([~-])\s*/g, '$1')
.trim();
}
function extractReturnRateText(values: string[]): string | null {
return uniqueNonEmpty(values.map((value) => normalizeInlineText(value)))
.find((value) => /^回头率\s*\d+(?:\.\d+)?%$/.test(value))
?? null;
}
function buildDedupeKey(row: Pick<SearchRow, 'offer_id' | 'item_url'>): string | null {
if (row.offer_id) return `offer:${row.offer_id}`;
if (row.item_url) return `url:${row.item_url}`;
return null;
}
async function readSearchPayload(page: IPage, url: string): Promise<SearchPayload> {
const state = await gotoAndReadState(page, url, 2500, 'search');
assertAuthenticatedState(state, 'search');
const payload = await page.evaluate(`
(() => {
const normalizeText = (value) => (value || '').replace(/\\s+/g, ' ').trim();
const normalizeUrl = (href) => {
if (!href) return '';
try {
return new URL(href, window.location.href).toString();
} catch {
return '';
}
};
const isItemHref = (href) => ${JSON.stringify(SEARCH_ITEM_URL_PATTERNS)}
.some((pattern) => (href || '').includes(pattern));
const uniqueTexts = (values) => [...new Set(values.map((value) => normalizeText(value)).filter(Boolean))];
const collectTexts = (root, selector) => uniqueTexts(
Array.from(root.querySelectorAll(selector)).map((node) => node.innerText || node.textContent || ''),
);
const firstText = (root, selectors) => {
for (const selector of selectors) {
const node = root.querySelector(selector);
const value = normalizeText(node ? node.innerText || node.textContent || '' : '');
if (value) return value;
}
return '';
};
const findMoqText = (values, priceText) => {
const moqPattern = /(≥\\s*\\d+(?:\\.\\d+)?\\s*(件|个|套|箱|包|双|台|把|只)?)|(\\d+(?:\\.\\d+)?\\s*(?:~|-|至|到)\\s*\\d+(?:\\.\\d+)?\\s*(件|个|套|箱|包|双|台|把|只))|(\\d+(?:\\.\\d+)?\\s*(件|个|套|箱|包|双|台|把|只)\\s*起批)/i;
return values.find((value) => moqPattern.test(value))
|| normalizeText(priceText).match(moqPattern)?.[0]
|| '';
};
const isSellerHref = (href) => {
if (!href) return false;
try {
const url = new URL(href, window.location.href);
const host = url.hostname || '';
if (!host.endsWith('.1688.com')) return false;
if (
host === 's.1688.com'
|| host === 'r.1688.com'
|| host === 'air.1688.com'
|| host === 'detail.1688.com'
|| host === 'detail.m.1688.com'
|| host === 'dj.1688.com'
) {
return false;
}
return true;
} catch {
return false;
}
};
const pickContainer = (anchor) => {
let node = anchor;
while (node && node !== document.body) {
const text = normalizeText(node.innerText || node.textContent || '');
if (text.length >= 40 && text.length <= 2000) {
return node;
}
node = node.parentElement;
}
return anchor;
};
const collectCandidates = () => {
const anchors = Array.from(document.querySelectorAll('a')).filter((anchor) => isItemHref(anchor.href || ''));
const seen = new Set();
const items = [];
for (const anchor of anchors) {
const href = anchor.href || '';
if (!href || seen.has(href)) continue;
seen.add(href);
const container = pickContainer(anchor);
const tagItems = collectTexts(container, '.offer-tag-row .offer-desc-item');
const hoverItems = collectTexts(container, '.offer-hover-wrapper .offer-desc-item');
const sellerAnchor = Array.from(container.querySelectorAll('a'))
.find((link) => isSellerHref(link.href || ''));
const hoverPriceText = firstText(container, [
'.offer-hover-wrapper .hover-price-item',
'.offer-hover-wrapper .price-item',
]);
items.push({
item_url: href,
title: firstText(container, ['.offer-title-row .title-text', '.offer-title-row'])
|| normalizeText(anchor.innerText || anchor.textContent || ''),
container_text: normalizeText(container.innerText || container.textContent || ''),
desc_rows: collectTexts(container, '.offer-desc-row'),
price_text: firstText(container, ['.offer-price-row .price-item']),
sales_text: firstText(container, ['.offer-price-row .col-desc_after', '.offer-desc-row .col-desc_after']),
hover_price_text: hoverPriceText,
moq_text: findMoqText(hoverItems, hoverPriceText),
tag_items: tagItems,
hover_items: hoverItems,
seller_name: sellerAnchor ? normalizeText(sellerAnchor.innerText || sellerAnchor.textContent || '') : null,
seller_url: sellerAnchor ? sellerAnchor.href : null,
});
}
return items;
};
const findNextUrl = () => {
const selectors = [
'a.fui-next:not(.disabled)',
'a.next-pagination-item:not(.disabled)',
'a[rel="next"]:not(.disabled)',
'a[data-role="next"]:not(.disabled)',
];
for (const selector of selectors) {
const node = document.querySelector(selector);
if (!node) continue;
const href = normalizeUrl(node.getAttribute('href') || node.href || '');
if (href) return href;
}
const textBased = Array.from(document.querySelectorAll('a'))
.find((node) => /下一页|next/i.test(normalizeText(node.textContent || '')));
if (!textBased) return '';
return normalizeUrl(textBased.getAttribute('href') || textBased.href || '');
};
return {
href: window.location.href,
title: document.title || '',
bodyText: document.body ? document.body.innerText || '' : '',
next_url: findNextUrl(),
candidates: collectCandidates(),
};
})()
`) as SearchPayload;
if (!payload || typeof payload !== 'object') {
throw new CommandExecutionError(
'1688 search page did not return a readable payload',
'Open the same query in Chrome and verify the page is fully loaded before retrying.',
);
}
return payload;
}
async function collectSearchRows(page: IPage, query: string, limit: number): Promise<SearchRow[]> {
const rowsByKey = new Map<string, SearchRow>();
const seenPages = new Set<string>();
let nextUrl = buildSearchUrl(query);
let pageCount = 0;
while (nextUrl && rowsByKey.size < limit && pageCount < MAX_SEARCH_PAGES) {
if (seenPages.has(nextUrl)) break;
seenPages.add(nextUrl);
pageCount += 1;
const payload = await readSearchPayload(page, nextUrl);
const sourceUrl = cleanText(payload.href) || nextUrl;
const candidates = Array.isArray(payload.candidates) ? payload.candidates : [];
for (const candidate of candidates) {
const row = normalizeSearchCandidate(candidate, sourceUrl);
const dedupeKey = buildDedupeKey(row);
if (!dedupeKey || rowsByKey.has(dedupeKey)) continue;
rowsByKey.set(dedupeKey, row);
if (rowsByKey.size >= limit) break;
}
const candidateNextUrl = cleanText(payload.next_url);
if (!candidateNextUrl || candidateNextUrl === sourceUrl) break;
nextUrl = candidateNextUrl;
}
if (rowsByKey.size === 0) {
throw new EmptyResultError(
'1688 search',
'No visible results were extracted. Retry with a different query or open the same search page in Chrome first.',
);
}
return [...rowsByKey.values()]
.slice(0, limit)
.map((row, index) => ({ ...row, rank: index + 1 }));
}
cli({
site: '1688',
name: 'search',
description: '1688 商品搜索(结果候选、卖家链接、价格/MOQ/销量文本)',
domain: 'www.1688.com',
strategy: Strategy.COOKIE,
navigateBefore: false,
args: [
{
name: 'query',
required: true,
positional: true,
help: '搜索关键词,如 "置物架"',
},
{
name: 'limit',
type: 'int',
default: SEARCH_LIMIT_DEFAULT,
help: `结果数量上限(默认 ${SEARCH_LIMIT_DEFAULT},最大 ${SEARCH_LIMIT_MAX}`,
},
],
columns: ['rank', 'title', 'price_text', 'moq_text', 'seller_name', 'location'],
func: async (page, kwargs) => {
const query = String(kwargs.query ?? '');
const limit = parseSearchLimit(kwargs.limit);
return collectSearchRows(page, query, limit);
},
});
export const __test__ = {
normalizeSearchCandidate,
extractMoqText,
extractSalesText,
firstWord,
buildDedupeKey,
};
+75
View File
@@ -0,0 +1,75 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './shared.js';
describe('1688 shared helpers', () => {
it('builds encoded search URLs and validates limit', () => {
expect(__test__.buildSearchUrl('置物架')).toBe(
'https://s.1688.com/selloffer/offer_search.htm?charset=utf8&keywords=%E7%BD%AE%E7%89%A9%E6%9E%B6',
);
expect(() => __test__.buildSearchUrl(' ')).toThrowError(/cannot be empty/i);
expect(__test__.parseSearchLimit(3)).toBe(3);
expect(__test__.parseSearchLimit('1000')).toBe(__test__.SEARCH_LIMIT_MAX);
expect(() => __test__.parseSearchLimit('0')).toThrowError(/positive integer/i);
});
it('extracts IDs and canonicalizes urls', () => {
expect(__test__.extractOfferId('887904326744')).toBe('887904326744');
expect(__test__.extractOfferId('https://detail.1688.com/offer/887904326744.html')).toBe('887904326744');
expect(__test__.extractMemberId('https://winport.m.1688.com/page/index.html?memberId=b2b-1641351767')).toBe('b2b-1641351767');
expect(__test__.extractMemberId('b2b-22154705262941f196')).toBe('b2b-22154705262941f196');
expect(__test__.resolveStoreUrl('b2b-22154705262941f196')).toBe(
'https://winport.m.1688.com/page/index.html?memberId=b2b-22154705262941f196',
);
expect(__test__.canonicalizeStoreUrl('https://yinuoweierfushi.1688.com/page/index.html?spm=foo')).toBe(
'https://yinuoweierfushi.1688.com',
);
expect(__test__.canonicalizeItemUrl('http://detail.m.1688.com/page/index.html?offerId=910933345396&spm=x')).toBe(
'https://detail.1688.com/offer/910933345396.html',
);
expect(__test__.canonicalizeSellerUrl('https://yinuoweierfushi.1688.com/page/contactinfo.html?tracelog=1')).toBe(
'https://yinuoweierfushi.1688.com',
);
expect(__test__.extractShopId('https://yinuoweierfushi.1688.com/page/index.html')).toBe('yinuoweierfushi');
});
it('parses price ranges and moq text', () => {
expect(__test__.parsePriceText('¥96.00-98.00')).toEqual({
price_text: '¥96.00-98.00',
price_min: 96,
price_max: 98,
currency: 'CNY',
});
expect(__test__.parsePriceText('¥ 14 .28')).toEqual({
price_text: '¥14.28',
price_min: 14.28,
price_max: 14.28,
currency: 'CNY',
});
expect(__test__.parseMoqText('3套起批')).toEqual({
moq_text: '3套起批',
moq_value: 3,
});
expect(__test__.parseMoqText('2~999个')).toEqual({
moq_text: '2~999个',
moq_value: 2,
});
});
it('detects captcha and login states', () => {
expect(__test__.extractLocation('山东青岛 送至 江苏苏州')).toBe('山东青岛');
expect(__test__.isCaptchaState({
href: 'https://s.1688.com/_____tmd_____/punish',
title: '验证码拦截',
body_text: '请拖动下方滑块完成验证',
})).toBe(true);
expect(__test__.isLoginState({
href: 'https://login.taobao.com/member/login.jhtml',
title: '账号登录',
body_text: '请登录后继续',
})).toBe(true);
});
});
+672
View File
@@ -0,0 +1,672 @@
import { ArgumentError, AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import type { IPage } from '@jackwener/opencli/types';
export const SITE = '1688';
export const HOME_URL = 'https://www.1688.com/';
export const SEARCH_URL_PREFIX = 'https://s.1688.com/selloffer/offer_search.htm?charset=utf8&keywords=';
export const DETAIL_URL_PREFIX = 'https://detail.1688.com/offer/';
export const STORE_MOBILE_URL_PREFIX = 'https://winport.m.1688.com/page/index.html?memberId=';
export const STRATEGY = 'cookie';
export const SEARCH_LIMIT_DEFAULT = 20;
export const SEARCH_LIMIT_MAX = 100;
const STORE_GENERIC_HOSTS = new Set(['www', 'detail', 's', 'winport', 'work', 'air', 'dj']);
const TRACKING_QUERY_KEYS = new Set([
'spm',
'tracelog',
'clickid',
'source',
'scene',
'from',
'src',
'ns',
'cna',
'pvid',
]);
const CAPTCHA_URL_MARKER = '/_____tmd_____/punish';
const CAPTCHA_TEXT_PATTERNS = [
'请拖动下方滑块完成验证',
'请按住滑块,拖动到最右边',
'通过验证以确保正常访问',
'验证码拦截',
'访问验证',
'滑动验证',
];
const LOGIN_TEXT_PATTERNS = [
'请登录',
'登录后',
'账号登录',
'手机登录',
'立即登录',
'扫码登录',
'请先完成登录',
'请先登录后查看',
];
const LOGIN_URL_PATTERNS = ['/member/login', 'passport', 'login.taobao.com', 'account.1688.com'];
export const FACTORY_BADGE_PATTERNS = [
'源头工厂',
'深度验厂',
'实力工厂',
'工厂档案',
'加工专区',
'验厂报告',
'厂家直销',
'生产厂家',
'工厂直供',
];
export const SERVICE_BADGE_PATTERNS = [
'延期必赔',
'品质保障',
'破损包赔',
'退货包运费',
'晚发必赔',
'7*24小时响应',
'48小时发货',
'72小时发货',
'后天达',
'包邮',
'闪电拿样',
];
const CHINA_LOCATIONS = [
'北京',
'天津',
'上海',
'重庆',
'河北',
'山西',
'辽宁',
'吉林',
'黑龙江',
'江苏',
'浙江',
'安徽',
'福建',
'江西',
'山东',
'河南',
'湖北',
'湖南',
'广东',
'海南',
'四川',
'贵州',
'云南',
'陕西',
'甘肃',
'青海',
'台湾',
'内蒙古',
'广西',
'西藏',
'宁夏',
'新疆',
'香港',
'澳门',
];
export interface ProvenanceFields {
source_url: string;
fetched_at: string;
strategy: string;
}
export interface PageState {
href: string;
title: string;
body_text: string;
}
export interface PriceRange {
price_text: string;
price_min: number | null;
price_max: number | null;
currency: string | null;
}
export interface MoqValue {
moq_text: string;
moq_value: number | null;
}
export interface PriceTier {
quantity_text: string;
quantity_min: number | null;
price_text: string;
price: number | null;
currency: string | null;
}
export interface SearchCandidate {
item_url: string;
title: string;
container_text: string;
seller_name: string | null;
seller_url: string | null;
}
export interface MediaSource {
type: 'image' | 'video';
group: 'main' | 'sku' | 'detail' | 'video' | 'unknown';
url: string;
source?: string;
}
export function cleanText(value: unknown): string {
return typeof value === 'string'
? value.replace(/\u00a0/g, ' ').replace(/\s+/g, ' ').trim()
: '';
}
export function cleanMultilineText(value: unknown): string {
return typeof value === 'string'
? value
.replace(/\u00a0/g, ' ')
.split('\n')
.map((line) => line.replace(/\s+/g, ' ').trim())
.filter(Boolean)
.join('\n')
: '';
}
export function uniqueNonEmpty(values: Array<string | null | undefined>): string[] {
return [...new Set(values.map((value) => cleanText(value)).filter(Boolean))];
}
export function parseSearchLimit(input: unknown): number {
const parsed = Number.parseInt(String(input ?? SEARCH_LIMIT_DEFAULT), 10);
if (!Number.isFinite(parsed) || parsed < 1) {
throw new ArgumentError(
'1688 search --limit must be a positive integer',
'Example: opencli 1688 search "桌面置物架" --limit 20',
);
}
return Math.min(SEARCH_LIMIT_MAX, parsed);
}
export function buildSearchUrl(query: string): string {
const normalized = cleanText(query);
if (!normalized) {
throw new ArgumentError(
'1688 search query cannot be empty',
'Example: opencli 1688 search "桌面置物架" --limit 20',
);
}
return `${SEARCH_URL_PREFIX}${encodeURIComponent(normalized)}`;
}
export function buildDetailUrl(input: string): string {
const offerId = extractOfferId(input);
if (!offerId) {
throw new ArgumentError(
'1688 item expects an offer URL or offer ID',
'Example: opencli 1688 item 887904326744',
);
}
return `${DETAIL_URL_PREFIX}${offerId}.html`;
}
export function resolveStoreUrl(input: string): string {
const normalized = cleanText(input);
if (!normalized) {
throw new ArgumentError(
'1688 store expects a store URL or member ID',
'Example: opencli 1688 store https://yinuoweierfushi.1688.com/',
);
}
const memberId = extractMemberId(normalized);
if (memberId) {
return `${STORE_MOBILE_URL_PREFIX}${memberId}`;
}
if (/^https?:\/\//i.test(normalized)) {
return canonicalizeStoreUrl(normalized);
}
if (normalized.endsWith('.1688.com')) {
return canonicalizeStoreUrl(`https://${normalized}`);
}
if (/^[a-z0-9-]+$/i.test(normalized)) {
return canonicalizeStoreUrl(`https://${normalized}.1688.com`);
}
throw new ArgumentError(
'1688 store expects a store URL or member ID',
'Example: opencli 1688 store b2b-22154705262941f196',
);
}
export function canonicalizeStoreUrl(input: string): string {
const url = parse1688Url(input);
const memberId = extractMemberId(url.toString());
if (memberId) {
return `${STORE_MOBILE_URL_PREFIX}${memberId}`;
}
const host = normalizeStoreHost(url.hostname);
if (!host) {
throw new ArgumentError(
'Invalid 1688 store URL',
'Example: opencli 1688 store https://yinuoweierfushi.1688.com/',
);
}
return `https://${host}`;
}
export function canonicalizeItemUrl(input: string): string | null {
const offerId = extractOfferId(input);
if (offerId) {
return `${DETAIL_URL_PREFIX}${offerId}.html`;
}
const url = parse1688UrlOrNull(input);
if (!url) return null;
stripTrackingParams(url);
url.hash = '';
return url.toString();
}
export function canonicalizeSellerUrl(input: string): string | null {
const memberId = extractMemberId(input);
if (memberId) {
return `${STORE_MOBILE_URL_PREFIX}${memberId}`;
}
const url = parse1688UrlOrNull(input);
if (!url) return null;
const host = normalizeStoreHost(url.hostname);
if (!host) return null;
return `https://${host}`;
}
export function extractOfferId(input: string): string | null {
const normalized = cleanText(input);
if (!normalized) return null;
const directId = normalized.match(/^\d{6,}$/)?.[0];
if (directId) return directId;
const detailMatch = normalized.match(/\/offer\/(\d{6,})\.html/i);
if (detailMatch) return detailMatch[1];
const queryMatch = normalized.match(/[?&]offerId=(\d{6,})/i);
if (queryMatch) return queryMatch[1];
return null;
}
export function extractMemberId(input: string): string | null {
const normalized = cleanText(input);
if (!normalized) return null;
const direct = normalized.match(/\bb2b-[a-z0-9]+\b/i)?.[0];
if (direct) return direct;
const queryMatch = normalized.match(/[?&]memberId=(b2b-[a-z0-9]+)/i);
if (queryMatch) return queryMatch[1];
const mobileMatch = normalized.match(/\/winport\/(b2b-[a-z0-9]+)\.html/i);
if (mobileMatch) return mobileMatch[1];
return null;
}
export function extractShopId(input: string): string | null {
const normalized = cleanText(input);
if (!normalized) return null;
try {
const url = new URL(/^https?:\/\//i.test(normalized) ? normalized : `https://${normalized}`);
const host = normalizeStoreHost(url.hostname);
if (!host) return null;
return host.split('.')[0] ?? null;
} catch {
return /^[a-z0-9-]+$/i.test(normalized) ? normalized : null;
}
}
export function buildProvenance(sourceUrl: string): ProvenanceFields {
return {
source_url: sourceUrl,
fetched_at: new Date().toISOString(),
strategy: STRATEGY,
};
}
export function parsePriceText(text: string): PriceRange {
const normalized = normalizeNumericText(cleanText(text));
const matches = normalized.match(/\d+(?:,\d{3})*(?:\.\d+)?/g) ?? [];
const values = matches
.map((value) => Number.parseFloat(value.replace(/,/g, '')))
.filter((value) => Number.isFinite(value));
if (values.length === 0) {
return {
price_text: normalized,
price_min: null,
price_max: null,
currency: null,
};
}
return {
price_text: normalized,
price_min: values[0] ?? null,
price_max: values[values.length - 1] ?? values[0] ?? null,
currency: normalized.includes('¥') || normalized.includes('元') ? 'CNY' : null,
};
}
export function normalizePriceTiers(
rawTiers: Array<{ beginAmount?: unknown; price?: unknown }>,
unit: string | null,
): PriceTier[] {
return rawTiers
.map((tier) => {
const quantityMin = toNumber(tier.beginAmount);
const priceText = cleanText(tier.price);
const price = toNumber(tier.price);
return {
quantity_text: quantityMin !== null ? `${quantityMin}${unit ?? ''}` : '',
quantity_min: quantityMin,
price_text: priceText,
price,
currency: priceText ? 'CNY' : null,
};
})
.filter((tier) => tier.price_text);
}
export function parseMoqText(text: string): MoqValue {
const normalized = normalizeNumericText(cleanText(text));
const match = normalized.match(/(\d+(?:\.\d+)?)\s*(件|个|套|箱|包|双|台|把|只|pcs|piece|pieces)?\s*起批/i)
?? normalized.match(/≥\s*(\d+(?:\.\d+)?)/);
const rangeMatch = normalized.match(
/(\d+(?:\.\d+)?)\s*(?:~|-|至|到)\s*\d+(?:\.\d+)?\s*(件|个|套|箱|包|双|台|把|只|pcs|piece|pieces)/i,
);
if (!match && !rangeMatch) {
return {
moq_text: normalized,
moq_value: null,
};
}
return {
moq_text: normalized,
moq_value: Number.parseFloat((match ?? rangeMatch)![1]),
};
}
export function extractLocation(text: string): string | null {
const normalized = cleanMultilineText(text);
const primaryRegion = normalized.split(/送至|发往/)[0] ?? normalized;
const lines = primaryRegion.split('\n');
for (const line of lines) {
const compact = cleanText(line);
if (!compact || compact.length > 16) continue;
if (CHINA_LOCATIONS.some((location) => compact.startsWith(location))) {
return compact;
}
}
const locationPattern = new RegExp(`(${CHINA_LOCATIONS.join('|')})[\\u4e00-\\u9fa5]{0,8}`);
return primaryRegion.match(locationPattern)?.[0] ?? null;
}
export function extractAddress(text: string): string | null {
const normalized = cleanMultilineText(text);
const lineMatch = normalized.match(/地址[:]\s*([^\n]+)/);
if (lineMatch) return cleanText(lineMatch[1]);
return normalized
.split('\n')
.map((line) => cleanText(line))
.find((line) => line.includes('省') || line.includes('市') || line.includes('区') || line.includes('县'))
?? null;
}
export function extractMetric(text: string, label: string): string | null {
const normalized = cleanMultilineText(text);
const direct = normalized.match(new RegExp(`(?:^|\\n)\\s*${escapeForRegex(label)}[:]?\\s*([^\\n]+)`));
if (direct) return cleanText(direct[1]);
const lineBased = normalized.match(new RegExp(`(?:^|\\n)\\s*${escapeForRegex(label)}\\n([^\\n]+)`));
return lineBased ? cleanText(lineBased[1]) : null;
}
export function extractYearsOnPlatform(text: string): string | null {
return text.match(/入驻\d+年/)?.[0] ?? null;
}
export function extractMainBusiness(text: string): string | null {
const value = extractMetric(text, '主营');
return value ? value.replace(/^/, '').trim() : null;
}
export function extractBadges(text: string, candidates: string[]): string[] {
return uniqueNonEmpty(candidates.filter((candidate) => cleanMultilineText(text).includes(candidate)));
}
export function guessTopCategories(text: string): string[] {
const mainBusiness = extractMainBusiness(text);
if (!mainBusiness) return [];
return uniqueNonEmpty(mainBusiness.split(/[、,/|]/).map((value) => value.trim()));
}
export function isCaptchaState(state: Partial<PageState>): boolean {
const href = cleanText(state.href).toLowerCase();
const title = cleanText(state.title);
const bodyText = cleanMultilineText(state.body_text);
if (href.includes(CAPTCHA_URL_MARKER)) return true;
return CAPTCHA_TEXT_PATTERNS.some((pattern) => title.includes(pattern) || bodyText.includes(pattern));
}
export function isLoginState(state: Partial<PageState>): boolean {
const href = cleanText(state.href).toLowerCase();
const title = cleanText(state.title);
const bodyText = cleanMultilineText(state.body_text);
if (LOGIN_URL_PATTERNS.some((pattern) => href.includes(pattern))) return true;
return LOGIN_TEXT_PATTERNS.some((pattern) => title.includes(pattern) || bodyText.includes(pattern));
}
export function buildCaptchaHint(action: string): string {
return [
`Open a clean 1688 ${action} page in the shared Chrome profile and finish any slider challenge first.`,
'If you run opencli via CDP, set OPENCLI_CDP_TARGET=1688.com or a more specific 1688 host before retrying.',
].join(' ');
}
export async function readPageState(page: IPage): Promise<PageState> {
const result = await page.evaluate(`
(() => ({
href: window.location.href,
title: document.title || '',
body_text: document.body ? document.body.innerText || '' : '',
}))()
`) as Partial<PageState>;
return {
href: cleanText(result.href),
title: cleanText(result.title),
body_text: cleanMultilineText(result.body_text),
};
}
export async function gotoAndReadState(
page: IPage,
url: string,
settleMs: number = 2500,
action: string = 'page',
): Promise<PageState> {
try {
await page.goto(url, { settleMs });
await page.wait(1.5);
return readPageState(page);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
if (
message.includes('Inspected target navigated or closed')
|| message.includes('Cannot find context with specified id')
|| message.includes('Target closed')
) {
throw new CommandExecutionError(
`1688 ${action} navigation lost the current browser target`,
`${buildCaptchaHint(action)} If CDP is attached to a stale or blocked tab, open a fresh 1688 tab and point OPENCLI_CDP_TARGET at that tab.`,
);
}
throw error;
}
}
export async function ensure1688Session(page: IPage): Promise<void> {
const state = await gotoAndReadState(page, HOME_URL, 1500, 'homepage');
assertAuthenticatedState(state, 'homepage');
}
export function assertAuthenticatedState(state: PageState, action: string): void {
if (!isCaptchaState(state) && !isLoginState(state)) return;
throw new AuthRequiredError('1688.com', `请先在共享 Chrome 完成 1688 登录/验证,再重试(${action}`);
}
export function assertNotCaptcha(state: PageState, action: string): void {
assertAuthenticatedState(state, action);
}
export function toNumber(value: unknown): number | null {
if (typeof value === 'number' && Number.isFinite(value)) {
return value;
}
if (typeof value === 'string') {
const normalized = value.replace(/,/g, '').trim();
if (!normalized) return null;
const parsed = Number.parseFloat(normalized);
return Number.isFinite(parsed) ? parsed : null;
}
return null;
}
export function limitCandidates<T>(values: T[], limit: number): T[] {
const normalizedLimit = Math.max(1, Math.trunc(limit) || 1);
return values.slice(0, normalizedLimit);
}
export function normalizeMediaUrl(input: unknown): string {
const raw = cleanText(input);
if (!raw) return '';
let value = raw
.replace(/^url\((.*)\)$/i, '$1')
.replace(/^['"]|['"]$/g, '')
.replace(/\\u002F/g, '/')
.replace(/&amp;/g, '&')
.trim();
if (!value || value.startsWith('data:') || value.startsWith('blob:')) return '';
if (value.startsWith('//')) value = `https:${value}`;
try {
const url = new URL(value);
return url.toString();
} catch {
return '';
}
}
export function uniqueMediaSources(values: MediaSource[]): MediaSource[] {
const seen = new Set<string>();
const result: MediaSource[] = [];
for (const value of values) {
const url = normalizeMediaUrl(value.url);
if (!url) continue;
const key = `${value.type}:${url}`;
if (seen.has(key)) continue;
seen.add(key);
result.push({
...value,
url,
source: cleanText(value.source) || undefined,
});
}
return result;
}
function normalizeNumericText(value: string): string {
return value
.replace(/([¥$€])\s+(?=\d)/g, '$1')
.replace(/(\d)\s*\.\s*(\d)/g, '$1.$2')
.replace(/\s*([~-])\s*/g, '$1')
.trim();
}
function escapeForRegex(value: string): string {
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
function parse1688Url(input: string): URL {
const normalized = cleanText(input);
try {
const url = new URL(normalized);
if (!url.hostname.endsWith('.1688.com') && url.hostname !== '1688.com' && url.hostname !== 'www.1688.com') {
throw new Error('invalid-host');
}
stripTrackingParams(url);
url.hash = '';
return url;
} catch {
throw new ArgumentError(
'Invalid 1688 URL',
'Use a URL under 1688.com (for example: https://detail.1688.com/offer/887904326744.html)',
);
}
}
function parse1688UrlOrNull(input: string): URL | null {
try {
return parse1688Url(input);
} catch {
return null;
}
}
function normalizeStoreHost(hostname: string): string | null {
const lower = cleanText(hostname).toLowerCase();
if (!lower.endsWith('.1688.com')) return null;
const [subdomain] = lower.split('.');
if (!subdomain || STORE_GENERIC_HOSTS.has(subdomain)) return null;
return lower;
}
function stripTrackingParams(url: URL): void {
const keys = [...url.searchParams.keys()];
for (const key of keys) {
if (TRACKING_QUERY_KEYS.has(key) || key.toLowerCase().startsWith('utm_')) {
url.searchParams.delete(key);
}
}
}
export const __test__ = {
SEARCH_LIMIT_DEFAULT,
SEARCH_LIMIT_MAX,
parseSearchLimit,
buildSearchUrl,
buildDetailUrl,
resolveStoreUrl,
canonicalizeStoreUrl,
canonicalizeItemUrl,
canonicalizeSellerUrl,
extractOfferId,
extractMemberId,
extractShopId,
parsePriceText,
normalizePriceTiers,
parseMoqText,
extractLocation,
extractAddress,
extractMetric,
extractYearsOnPlatform,
extractMainBusiness,
extractBadges,
guessTopCategories,
isCaptchaState,
isLoginState,
cleanText,
cleanMultilineText,
uniqueNonEmpty,
normalizeMediaUrl,
uniqueMediaSources,
limitCandidates,
};
+69
View File
@@ -0,0 +1,69 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './store.js';
describe('1688 store normalization', () => {
it('merges store contact text with seller seed data', () => {
const result = __test__.normalizeStorePayload({
resolvedUrl: 'https://yinuoweierfushi.1688.com/?offerId=887904326744',
explicitMemberId: null,
storePayload: {
href: 'https://yinuoweierfushi.1688.com/page/index.html',
bodyText: `
青岛沁澜衣品服装有限公司
联系方式
地址:山东省青岛市即墨区环秀街道办事处湘江二路97号甲
`,
offerLinks: ['https://detail.1688.com/offer/887904326744.html'],
},
contactPayload: {
href: 'https://yinuoweierfushi.1688.com/page/contactinfo.html',
bodyText: `
青岛沁澜衣品服装有限公司
电话:86 0532 86655366
手机:15963238678
地址:山东省青岛市即墨区环秀街道办事处湘江二路97号甲
`,
},
seed: {
bodyText: `
入驻13年
主营:大码女装
店铺回头率
87%
延期必赔
品质保障
`,
seller: {
companyName: '青岛沁澜衣品服装有限公司',
memberId: 'b2b-1641351767',
winportUrl: 'https://yinuoweierfushi.1688.com/page/index.html?spm=abc',
},
services: [{ serviceName: '延期必赔' }, { serviceName: '品质保障' }],
},
});
expect(result.member_id).toBe('b2b-1641351767');
expect(result.store_url).toBe('https://yinuoweierfushi.1688.com');
expect(result.company_url).toBe('https://yinuoweierfushi.1688.com/page/contactinfo.html');
expect(result.years_on_platform_text).toBe('入驻13年');
expect(result.location).toBe('山东省青岛市即墨区环秀街道办事处湘江二路97号甲');
expect(result.return_rate_text).toContain('87%');
expect(result.top_categories).toEqual(['大码女装']);
expect(result.service_badges).toEqual(['延期必赔', '品质保障']);
});
it('builds contact urls and extracts offer ids', () => {
expect(__test__.safeCanonicalStoreUrl('https://yinuoweierfushi.1688.com/page/index.html?spm=foo')).toBe(
'https://yinuoweierfushi.1688.com',
);
expect(__test__.buildContactUrl('https://yinuoweierfushi.1688.com')).toBe(
'https://yinuoweierfushi.1688.com/page/contactinfo.html',
);
expect(__test__.firstOfferId([
'https://detail.1688.com/offer/887904326744.html',
])).toBe('887904326744');
expect(__test__.firstContactUrl([
'https://yinuoweierfushi.1688.com/page/contactinfo.html?spm=1',
])).toBe('https://yinuoweierfushi.1688.com/page/contactinfo.html');
});
});
+300
View File
@@ -0,0 +1,300 @@
import { CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
import { cli, Strategy } from '@jackwener/opencli/registry';
import type { IPage } from '@jackwener/opencli/types';
import {
FACTORY_BADGE_PATTERNS,
SERVICE_BADGE_PATTERNS,
assertAuthenticatedState,
buildDetailUrl,
buildProvenance,
canonicalizeSellerUrl,
canonicalizeStoreUrl,
cleanMultilineText,
cleanText,
extractAddress,
extractBadges,
extractMemberId,
extractMetric,
extractOfferId,
extractShopId,
extractYearsOnPlatform,
gotoAndReadState,
guessTopCategories,
resolveStoreUrl,
uniqueNonEmpty,
} from './shared.js';
interface StoreBrowserPayload {
href?: string;
title?: string;
bodyText?: string;
offerLinks?: string[];
contactLinks?: string[];
}
interface StoreItemSeed {
href?: string;
bodyText?: string;
seller?: {
companyName?: string;
memberId?: string;
winportUrl?: string;
sellerWinportUrlMap?: Record<string, string>;
};
services?: Array<{ serviceName?: string }>;
}
function normalizeStorePayload(input: {
resolvedUrl: string;
storePayload: StoreBrowserPayload | null;
contactPayload: StoreBrowserPayload | null;
seed: StoreItemSeed | null;
explicitMemberId: string | null;
}): Record<string, unknown> {
const storePayload = input.storePayload;
const contactPayload = input.contactPayload;
const seed = input.seed;
const contactText = cleanMultilineText(contactPayload?.bodyText);
const storeText = cleanMultilineText(storePayload?.bodyText);
const seedText = cleanMultilineText(seed?.bodyText);
const combinedText = [contactText, storeText, seedText].filter(Boolean).join('\n');
const sellerUrlRaw = cleanText(
seed?.seller?.winportUrl
?? seed?.seller?.sellerWinportUrlMap?.defaultUrl
?? storePayload?.href
?? input.resolvedUrl,
);
const storeUrl = safeCanonicalStoreUrl(sellerUrlRaw || input.resolvedUrl) ?? input.resolvedUrl;
const sellerUrl = canonicalizeSellerUrl(sellerUrlRaw) ?? storeUrl;
const companyUrl = pickCompanyUrl(contactPayload?.href, storeUrl);
const memberId = cleanText(seed?.seller?.memberId)
|| input.explicitMemberId
|| extractMemberId(input.resolvedUrl)
|| extractMemberId(storePayload?.href ?? '')
|| null;
const shopId = extractShopId(sellerUrl) ?? extractShopId(storeUrl);
const companyName = cleanText(seed?.seller?.companyName)
|| firstNamedLine(contactText)
|| firstNamedLine(storeText)
|| null;
const serviceBadges = uniqueNonEmpty([
...extractBadges(combinedText, SERVICE_BADGE_PATTERNS),
...((seed?.services ?? []).map((service) => cleanText(service.serviceName))),
]);
const factoryBadges = extractBadges(combinedText, FACTORY_BADGE_PATTERNS);
return {
member_id: memberId,
shop_id: shopId,
store_name: companyName,
store_url: storeUrl,
company_name: companyName,
company_url: companyUrl,
business_model_text: firstMetric(combinedText, ['经营模式', '生产加工', '主营产品']),
years_on_platform_text: extractYearsOnPlatform(combinedText),
location: extractAddress(contactText) ?? extractAddress(storeText),
staff_size_text: firstMetric(combinedText, ['员工人数', '员工总数']),
factory_badges: factoryBadges,
service_badges: serviceBadges,
response_rate_text: firstMetric(combinedText, ['响应率', '回复率', '响应速度']),
return_rate_text: extractReturnRate(combinedText),
top_categories: guessTopCategories(combinedText),
phone_text: extractMetric(contactText, '电话'),
mobile_text: extractMetric(contactText, '手机'),
...buildProvenance(cleanText(contactPayload?.href) || cleanText(storePayload?.href) || input.resolvedUrl),
};
}
function safeCanonicalStoreUrl(url: string): string | null {
try {
return canonicalizeStoreUrl(url);
} catch {
return null;
}
}
function pickCompanyUrl(contactHref: string | undefined, storeUrl: string): string | null {
const fromPage = cleanText(contactHref);
if (fromPage) {
const normalized = buildContactUrl(fromPage);
if (normalized) return normalized;
}
return buildContactUrl(storeUrl);
}
function buildContactUrl(storeUrl: string): string | null {
try {
const parsed = new URL(storeUrl);
if (!parsed.hostname.endsWith('.1688.com')) return null;
return `${parsed.protocol}//${parsed.hostname}/page/contactinfo.html`;
} catch {
return null;
}
}
function firstNamedLine(text: string): string | null {
return text
.split('\n')
.map((line) => cleanText(line))
.find((line) => line.includes('有限公司') || line.includes('商行') || line.includes('工厂'))
?? null;
}
function firstMetric(text: string, labels: string[]): string | null {
for (const label of labels) {
const value = extractMetric(text, label);
if (value) return value;
}
return null;
}
function extractReturnRate(text: string): string | null {
const inline = text.match(/回头率\s*([0-9.]+%)/);
if (inline) return cleanText(inline[0]);
const multiline = text.match(/回头率\s*\n\s*([0-9.]+%)/);
if (!multiline) return null;
return `回头率${cleanText(multiline[1])}`;
}
function firstOfferId(links: string[]): string | null {
for (const link of links) {
const offerId = extractOfferId(link);
if (offerId) return offerId;
}
return null;
}
function firstContactUrl(links: string[]): string | null {
for (const link of links) {
const url = buildContactUrl(link);
if (url) return url;
}
return null;
}
async function readStorePayload(page: IPage, url: string, action: string): Promise<StoreBrowserPayload> {
const state = await gotoAndReadState(page, url, 2500, action);
assertAuthenticatedState(state, action);
return await page.evaluate(`
(() => ({
href: window.location.href,
title: document.title || '',
bodyText: document.body ? document.body.innerText || '' : '',
offerLinks: Array.from(document.querySelectorAll('a[href*="detail.1688.com/offer/"], a[href*="offerId="]'))
.map((anchor) => anchor.href)
.filter(Boolean),
contactLinks: Array.from(document.querySelectorAll('a[href*="contactinfo"]'))
.map((anchor) => anchor.href)
.filter(Boolean),
}))()
`) as StoreBrowserPayload;
}
async function readItemSeed(page: IPage, offerId: string): Promise<StoreItemSeed> {
const itemUrl = buildDetailUrl(offerId);
const state = await gotoAndReadState(page, itemUrl, 2500, 'store seed item');
assertAuthenticatedState(state, 'store seed item');
const seed = await page.evaluate(`
(() => {
const model = window.context?.result?.global?.globalData?.model ?? null;
const toJson = (value) => JSON.parse(JSON.stringify(value ?? null));
return {
href: window.location.href,
bodyText: document.body ? document.body.innerText || '' : '',
seller: toJson(model?.sellerModel),
services: toJson(model?.shippingServices?.fields?.buyerProtectionModel ?? []),
};
})()
`) as StoreItemSeed;
const hasSellerContext = !!cleanText(seed?.seller?.memberId) || !!cleanText(seed?.seller?.winportUrl);
if (!hasSellerContext) {
throw new CommandExecutionError(
'1688 store seed item did not expose seller context',
'当前 tab 非商品详情上下文,请切到 detail.1688.com 商品页并重试',
);
}
return seed;
}
function hasAnyEvidence(
storePayload: StoreBrowserPayload | null,
contactPayload: StoreBrowserPayload | null,
seed: StoreItemSeed | null,
): boolean {
return !!cleanText(storePayload?.bodyText)
|| !!cleanText(contactPayload?.bodyText)
|| !!cleanText(seed?.bodyText);
}
cli({
site: '1688',
name: 'store',
description: '1688 店铺/供应商公开信息(联系方式、主营、入驻年限、公开服务信号)',
domain: 'www.1688.com',
strategy: Strategy.COOKIE,
navigateBefore: false,
args: [
{
name: 'input',
required: true,
positional: true,
help: '1688 店铺 URL 或 member ID(如 b2b-22154705262941f196',
},
],
columns: ['store_name', 'years_on_platform_text', 'location', 'return_rate_text'],
func: async (page, kwargs) => {
const rawInput = String(kwargs.input ?? '');
const resolvedUrl = resolveStoreUrl(rawInput);
const explicitMemberId = extractMemberId(rawInput);
const storePayload = await readStorePayload(page, resolvedUrl, 'store');
const contactUrl = firstContactUrl(storePayload.contactLinks ?? []) || buildContactUrl(storePayload.href || resolvedUrl);
const contactPayload = contactUrl ? await readStorePayload(page, contactUrl, 'store contact') : null;
const offerId = extractOfferId(rawInput)
|| firstOfferId(storePayload.offerLinks ?? [])
|| firstOfferId(contactPayload?.offerLinks ?? []);
let seed: StoreItemSeed | null = null;
if (offerId) {
try {
seed = await readItemSeed(page, offerId);
} catch (error) {
if (!(error instanceof CommandExecutionError)) throw error;
}
}
if (!hasAnyEvidence(storePayload, contactPayload, seed)) {
throw new EmptyResultError(
'1688 store',
'Store page is reachable but no visible fields were extracted. Open the store page in Chrome and retry.',
);
}
return [
normalizeStorePayload({
resolvedUrl,
storePayload,
contactPayload,
seed,
explicitMemberId,
}),
];
},
});
export const __test__ = {
normalizeStorePayload,
safeCanonicalStoreUrl,
buildContactUrl,
firstNamedLine,
firstMetric,
extractReturnRate,
firstOfferId,
firstContactUrl,
};
@@ -3,9 +3,9 @@
*
* Fetches the full content of a 36kr article given its ID or URL.
*/
import { cli, Strategy } from '../../registry.js';
import { CliError } from '../../errors.js';
import type { IPage } from '../../types.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { CliError } from '@jackwener/opencli/errors';
import type { IPage } from '@jackwener/opencli/types';
/** Extract article ID from a full URL or a bare numeric ID string */
function parseArticleId(input: string): string {
+12 -7
View File
@@ -1,12 +1,12 @@
/**
* 36kr hot-list INTERCEPT strategy.
* 36kr hot-list DOM scraping.
*
* Navigates to the 36kr hot-list page and scrapes rendered article links.
* Supports category types: renqi (), zonghe (), shoucang (), catalog ().
*/
import { cli, Strategy } from '../../registry.js';
import { CliError } from '../../errors.js';
import type { IPage } from '../../types.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { CliError } from '@jackwener/opencli/errors';
import type { IPage } from '@jackwener/opencli/types';
const TYPE_MAP: Record<string, string> = {
renqi: '人气榜',
@@ -34,7 +34,8 @@ cli({
name: 'hot',
description: '36氪热榜 — trending articles (renqi/zonghe/shoucang/catalog)',
domain: 'www.36kr.com',
strategy: Strategy.INTERCEPT,
strategy: Strategy.PUBLIC,
browser: true,
args: [
{ name: 'limit', type: 'int', default: 20, help: 'Number of items (max 50)' },
{
@@ -58,9 +59,13 @@ cli({
const url = buildHotListUrl(listType);
await page.installInterceptor('36kr.com/api');
await page.goto(url);
await page.waitForCapture(6);
// Poll DOM until article links appear (36kr renders client-side)
const deadline = Date.now() + 5000;
while (Date.now() < deadline) {
if (await page.evaluate('document.querySelectorAll("a[href*=\\"/p/\\"]").length')) break;
await new Promise(r => setTimeout(r, 300));
}
// Scrape rendered article links from DOM (deduplicated)
const domItems: any = await page.evaluate(`
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* 36kr latest news public RSS feed, no browser needed.
*/
import { cli, Strategy } from '../../registry.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: '36kr',
@@ -1,18 +1,19 @@
/**
* 36kr article search INTERCEPT strategy.
* 36kr article search DOM scraping.
*
* Navigates to the 36kr search results page and scrapes rendered articles.
*/
import { cli, Strategy } from '../../registry.js';
import { CliError } from '../../errors.js';
import type { IPage } from '../../types.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { CliError } from '@jackwener/opencli/errors';
import type { IPage } from '@jackwener/opencli/types';
cli({
site: '36kr',
name: 'search',
description: '搜索36氪文章',
domain: 'www.36kr.com',
strategy: Strategy.INTERCEPT,
strategy: Strategy.PUBLIC,
browser: true,
args: [
{ name: 'query', positional: true, required: true, help: 'Search keyword (e.g. "AI", "OpenAI")' },
{ name: 'limit', type: 'int', default: 20, help: 'Number of results (max 50)' },
@@ -22,9 +23,13 @@ cli({
const count = Math.min(Number(args.limit) || 20, 50);
const query = encodeURIComponent(String(args.query ?? ''));
await page.installInterceptor('36kr.com/api');
await page.goto(`https://www.36kr.com/search/articles/${query}`);
await page.waitForCapture(6);
// Poll DOM until article links appear (36kr renders client-side)
const deadline = Date.now() + 5000;
while (Date.now() < deadline) {
if (await page.evaluate('document.querySelectorAll("a[href*=\\"/p/\\"]").length')) break;
await new Promise(r => setTimeout(r, 300));
}
const domItems: any = await page.evaluate(`
(() => {
@@ -5,9 +5,9 @@
*/
import * as fs from 'node:fs';
import { cli, Strategy } from '../../registry.js';
import type { IPage } from '../../types.js';
import type { CliOptions } from '../../registry.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
import type { IPage } from '@jackwener/opencli/types';
import type { CliOptions } from '@jackwener/opencli/registry';
/**
* Factory: capture DOM HTML + accessibility snapshot.
+31
View File
@@ -0,0 +1,31 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './rankings.js';
describe('amazon bestsellers normalization', () => {
it('normalizes bestseller cards and infers review counts from card text', () => {
const result = __test__.normalizeRankingCandidate({
asin: 'B0DR31GC3D',
title: '',
href: 'https://www.amazon.com/NUTIKAS-Shelves-Desktop-Orgnizer-Shlef/dp/B0DR31GC3D/ref=zg_bs',
price_text: '$25.92',
rating_text: '4.3 out of 5 stars',
review_count_text: '',
card_text: 'Desk Shelves Desktop Organizer Shlef\n4.3 out of 5 stars\n435\n$25.92',
}, {
listType: 'bestsellers',
rankFallback: 2,
listTitle: 'Amazon Best Sellers: Best Desktop & Off-Surface Shelves',
sourceUrl: 'https://www.amazon.com/example',
categoryTitle: null,
categoryUrl: 'https://www.amazon.com/example',
categoryPath: [],
visibleCategoryLinks: [],
});
expect(result.rank).toBe(2);
expect(result.asin).toBe('B0DR31GC3D');
expect(result.title).toBe('Desk Shelves Desktop Organizer Shlef');
expect(result.review_count).toBe(435);
expect(result.list_title).toBe('Amazon Best Sellers: Best Desktop & Off-Surface Shelves');
});
});
+8
View File
@@ -0,0 +1,8 @@
import { cli } from '@jackwener/opencli/registry';
import { createRankingCliOptions } from './rankings.js';
cli(createRankingCliOptions({
commandName: 'bestsellers',
listType: 'bestsellers',
description: 'Amazon Best Sellers pages for category candidate discovery',
}));
+38
View File
@@ -0,0 +1,38 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './discussion.js';
describe('amazon discussion normalization', () => {
it('normalizes review summary and sample reviews', () => {
const result = __test__.normalizeDiscussionPayload({
href: 'https://www.amazon.com/product-reviews/B0FJS72893',
average_rating_text: '3.9 out of 5',
total_review_count_text: '27 global ratings',
qa_links: [],
review_samples: [
{
title: '5.0 out of 5 stars Great value and quality',
rating_text: '5.0 out of 5 stars',
author: 'GTreader2',
date_text: 'Reviewed in the United States on February 21, 2026',
body: 'Small but mighty.',
verified: true,
},
],
});
expect(result.asin).toBe('B0FJS72893');
expect(result.average_rating_value).toBe(3.9);
expect(result.total_review_count).toBe(27);
expect(result.review_samples).toEqual([
{
title: 'Great value and quality',
rating_text: '5.0 out of 5 stars',
rating_value: 5,
author: 'GTreader2',
date_text: 'Reviewed in the United States on February 21, 2026',
body: 'Small but mighty.',
verified_purchase: true,
},
]);
});
});
+131
View File
@@ -0,0 +1,131 @@
import { CommandExecutionError } from '@jackwener/opencli/errors';
import { cli, Strategy } from '@jackwener/opencli/registry';
import type { IPage } from '@jackwener/opencli/types';
import {
buildDiscussionUrl,
buildProvenance,
cleanText,
extractAsin,
normalizeProductUrl,
parseRatingValue,
parseReviewCount,
trimRatingPrefix,
uniqueNonEmpty,
assertUsableState,
gotoAndReadState,
} from './shared.js';
interface DiscussionPayload {
href?: string;
title?: string;
average_rating_text?: string | null;
total_review_count_text?: string | null;
qa_links?: string[];
review_samples?: Array<{
title?: string | null;
rating_text?: string | null;
author?: string | null;
date_text?: string | null;
body?: string | null;
verified?: boolean;
}>;
}
function normalizeDiscussionPayload(payload: DiscussionPayload): Record<string, unknown> {
const sourceUrl = cleanText(payload.href) || buildDiscussionUrl(payload.href ?? '');
const asin = extractAsin(payload.href ?? '') ?? null;
const averageRatingText = cleanText(payload.average_rating_text) || null;
const totalReviewCountText = cleanText(payload.total_review_count_text) || null;
const provenance = buildProvenance(sourceUrl);
return {
asin,
product_url: asin ? normalizeProductUrl(asin) : null,
discussion_url: sourceUrl,
...provenance,
average_rating_text: averageRatingText,
average_rating_value: parseRatingValue(averageRatingText),
total_review_count_text: totalReviewCountText,
total_review_count: parseReviewCount(totalReviewCountText),
qa_urls: uniqueNonEmpty(payload.qa_links ?? []),
review_samples: (payload.review_samples ?? []).map((sample) => ({
title: trimRatingPrefix(sample.title) || null,
rating_text: cleanText(sample.rating_text) || null,
rating_value: parseRatingValue(sample.rating_text),
author: cleanText(sample.author) || null,
date_text: cleanText(sample.date_text) || null,
body: cleanText(sample.body) || null,
verified_purchase: sample.verified === true,
})),
};
}
async function readDiscussionPayload(page: IPage, input: string, limit: number): Promise<DiscussionPayload> {
const url = buildDiscussionUrl(input);
const state = await gotoAndReadState(page, url, 2500, 'discussion');
assertUsableState(state, 'discussion');
return await page.evaluate(`
(() => ({
href: window.location.href,
title: document.title || '',
average_rating_text: document.querySelector('[data-hook="rating-out-of-text"]')?.textContent || '',
total_review_count_text: document.querySelector('[data-hook="total-review-count"]')?.textContent || '',
qa_links: Array.from(document.querySelectorAll('a[href*="ask/questions"]')).map((anchor) => anchor.href || ''),
review_samples: Array.from(document.querySelectorAll('[data-hook="review"]')).slice(0, ${limit}).map((card) => ({
title: card.querySelector('[data-hook="review-title"]')?.textContent || '',
rating_text:
card.querySelector('[data-hook="review-star-rating"]')?.textContent
|| card.querySelector('[data-hook="cmps-review-star-rating"]')?.textContent
|| '',
author: card.querySelector('.a-profile-name')?.textContent || '',
date_text: card.querySelector('[data-hook="review-date"]')?.textContent || '',
body: card.querySelector('[data-hook="review-body"]')?.textContent || '',
verified: !!card.querySelector('[data-hook="avp-badge"]'),
})),
}))()
`) as DiscussionPayload;
}
cli({
site: 'amazon',
name: 'discussion',
description: 'Amazon review summary and sample customer discussion from product review pages',
domain: 'amazon.com',
strategy: Strategy.COOKIE,
navigateBefore: false,
args: [
{
name: 'input',
required: true,
positional: true,
help: 'ASIN or product URL, for example B0FJS72893',
},
{
name: 'limit',
type: 'int',
default: 10,
help: 'Maximum number of review samples to return (default 10)',
},
],
columns: ['asin', 'average_rating_value', 'total_review_count'],
func: async (page, kwargs) => {
const input = String(kwargs.input ?? '');
const limit = Math.max(1, Number(kwargs.limit) || 10);
const payload = await readDiscussionPayload(page, input, limit);
const normalized = normalizeDiscussionPayload(payload);
if (!normalized.average_rating_text && !normalized.total_review_count_text) {
throw new CommandExecutionError(
'amazon discussion page did not expose review summary',
'The review page may have changed or hit a robot check. Open the review page in Chrome and retry.',
);
}
return [normalized];
},
});
export const __test__ = {
normalizeDiscussionPayload,
};
+8
View File
@@ -0,0 +1,8 @@
import { cli } from '@jackwener/opencli/registry';
import { createRankingCliOptions } from './rankings.js';
cli(createRankingCliOptions({
commandName: 'movers-shakers',
listType: 'movers_shakers',
description: 'Amazon Movers & Shakers pages for short-term growth signals',
}));
+8
View File
@@ -0,0 +1,8 @@
import { cli } from '@jackwener/opencli/registry';
import { createRankingCliOptions } from './rankings.js';
cli(createRankingCliOptions({
commandName: 'new-releases',
listType: 'new_releases',
description: 'Amazon New Releases pages for early momentum discovery',
}));
+35
View File
@@ -0,0 +1,35 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './offer.js';
describe('amazon offer normalization', () => {
it('extracts sold-by and fulfillment facts from product offer text', () => {
const result = __test__.normalizeOfferPayload({
href: 'https://www.amazon.com/dp/B0FJS72893',
price_text: '$15.99',
merchant_info: '',
sold_by: 'KUATUDIRECT',
ships_from_text: 'Ships from Amazon',
offer_link: null,
review_url: 'https://www.amazon.com/dp/B0FJS72893#customerReviews',
qa_url: null,
});
expect(result.asin).toBe('B0FJS72893');
expect(result.sold_by).toBe('KUATUDIRECT');
expect(result.ships_from).toBe('Amazon');
expect(result.is_amazon_sold).toBe(false);
expect(result.is_amazon_fulfilled).toBe(true);
});
it('parses merchant info fallback text', () => {
expect(__test__.extractSoldBy('Sold by Example Seller and Fulfilled by Amazon.')).toBe('Example Seller');
expect(__test__.extractShipsFrom('Ships from Amazon')).toBe('Amazon');
});
it('detects delivery-location blocking in the buy box text', () => {
expect(__test__.isDeliveryLocationBlocked(
'This item cannot be shipped to your selected delivery location. Similar items shipping to Hong Kong',
)).toBe(true);
expect(__test__.isDeliveryLocationBlocked('Ships from Amazon')).toBe(false);
});
});
+185
View File
@@ -0,0 +1,185 @@
import { CommandExecutionError } from '@jackwener/opencli/errors';
import { cli, Strategy } from '@jackwener/opencli/registry';
import type { IPage } from '@jackwener/opencli/types';
import {
buildProductUrl,
buildProvenance,
cleanText,
extractAsin,
isAmazonEntity,
normalizeProductUrl,
PRIMARY_PRICE_SELECTORS,
parsePriceText,
assertUsableState,
gotoAndReadState,
} from './shared.js';
interface OfferPayload {
href?: string;
title?: string;
price_text?: string | null;
merchant_info?: string | null;
sold_by?: string | null;
ships_from_text?: string | null;
offer_link?: string | null;
review_url?: string | null;
qa_url?: string | null;
buybox_text?: string | null;
}
const OFFER_FACT_SELECTOR = [
'#sellerProfileTriggerId',
'#shipsFromSoldByInsideBuyBox_feature_div',
'#fulfillerInfoFeature_feature_div',
'#merchantInfoFeature_feature_div',
'#tabular-buybox-container',
'#merchant-info',
].join(', ');
function collapseAdjacentWords(text: string): string {
const parts = cleanText(text).split(' ').filter(Boolean);
const deduped: string[] = [];
for (const part of parts) {
if (deduped[deduped.length - 1] === part) continue;
deduped.push(part);
}
return deduped.join(' ');
}
function extractShipsFrom(text: string): string | null {
const normalized = cleanText(text);
const match = normalized.match(/Ships from\s+(.+?)(?=Sold by|and Fulfilled by|$)/i);
return match ? collapseAdjacentWords(match[1].replace(/Ships from/ig, '')) : null;
}
function extractSoldBy(text: string): string | null {
const normalized = cleanText(text);
const match = normalized.match(/Sold by\s+(.+?)(?=and Fulfilled by|Ships from|$)/i);
return match ? collapseAdjacentWords(match[1]) : null;
}
function isDeliveryLocationBlocked(text: string | null | undefined): boolean {
const normalized = cleanText(text).toLowerCase();
return normalized.includes('cannot be shipped to your selected delivery location')
|| normalized.includes('similar items shipping to')
|| normalized.includes('deliver to hong kong');
}
function normalizeOfferPayload(payload: OfferPayload): Record<string, unknown> {
const asin = extractAsin(payload.href ?? '') ?? null;
const sourceUrl = cleanText(payload.href) || buildProductUrl(payload.href ?? '');
const price = parsePriceText(payload.price_text);
const merchantInfo = cleanText(payload.merchant_info) || null;
const soldBy = cleanText(payload.sold_by)
|| extractSoldBy(payload.ships_from_text ?? '')
|| extractSoldBy(merchantInfo ?? '')
|| null;
const shipsFrom = extractShipsFrom(payload.ships_from_text ?? '')
|| extractShipsFrom(merchantInfo ?? '')
|| cleanText(payload.ships_from_text)
|| null;
const provenance = buildProvenance(sourceUrl);
return {
asin,
product_url: normalizeProductUrl(payload.href),
...provenance,
price_text: price.price_text,
price_value: price.price_value,
currency: price.currency,
merchant_info_text: merchantInfo,
sold_by: soldBy,
ships_from: shipsFrom,
offer_listing_url: cleanText(payload.offer_link) || null,
review_url: cleanText(payload.review_url) || null,
qa_url: cleanText(payload.qa_url) || null,
is_amazon_sold: isAmazonEntity(soldBy),
is_amazon_fulfilled: isAmazonEntity(shipsFrom) || /fulfilled by amazon/i.test(merchantInfo ?? ''),
};
}
async function readOfferPayload(page: IPage, input: string): Promise<OfferPayload> {
const url = buildProductUrl(input);
const state = await gotoAndReadState(page, url, 2500, 'offer');
assertUsableState(state, 'offer');
// Reconnecting to an existing Amazon target can surface the product page
// before the buy-box / merchant blocks are reattached to the DOM.
await page.wait({ selector: OFFER_FACT_SELECTOR, timeout: 6 }).catch(() => {});
return await page.evaluate(`
(() => ({
href: window.location.href,
title: document.title || '',
price_text: (() => {
const selectors = ${JSON.stringify(PRIMARY_PRICE_SELECTORS)};
for (const selector of selectors) {
const text = document.querySelector(selector)?.textContent || '';
if (text.trim()) return text;
}
return '';
})(),
merchant_info: document.querySelector('#merchant-info')?.textContent || '',
sold_by: document.querySelector('#sellerProfileTriggerId')?.textContent || '',
ships_from_text:
document.querySelector('#shipsFromSoldByInsideBuyBox_feature_div')?.textContent
|| document.querySelector('#fulfillerInfoFeature_feature_div')?.textContent
|| document.querySelector('#merchantInfoFeature_feature_div')?.textContent
|| document.querySelector('#tabular-buybox-container')?.textContent
|| '',
offer_link: document.querySelector('a[href*="/gp/offer-listing/"]')?.href || '',
review_url: document.querySelector('a[href*="#customerReviews"]')?.href || '',
qa_url: document.querySelector('a[href*="ask/questions"]')?.href || '',
buybox_text:
document.querySelector('#desktop_qualifiedBuyBox')?.textContent
|| document.querySelector('#buybox')?.textContent
|| '',
}))()
`) as OfferPayload;
}
cli({
site: 'amazon',
name: 'offer',
description: 'Amazon seller, buy box, and fulfillment facts from the product page',
domain: 'amazon.com',
strategy: Strategy.COOKIE,
navigateBefore: false,
args: [
{
name: 'input',
required: true,
positional: true,
help: 'ASIN or product URL, for example B0FJS72893',
},
],
columns: ['asin', 'price_text', 'sold_by', 'ships_from', 'is_amazon_sold', 'is_amazon_fulfilled'],
func: async (page, kwargs) => {
const input = String(kwargs.input ?? '');
const payload = await readOfferPayload(page, input);
const normalized = normalizeOfferPayload(payload);
if (!normalized.sold_by && !normalized.ships_from && !normalized.merchant_info_text) {
if (isDeliveryLocationBlocked(payload.buybox_text)) {
throw new CommandExecutionError(
'amazon offer buy box is blocked by the current delivery location',
'The shared Chrome profile is not set to the target US delivery address. Switch Amazon delivery location to the requested US destination, reopen the product page, and retry.',
);
}
throw new CommandExecutionError(
'amazon offer surface did not expose seller or fulfillment facts',
'The product page may have changed. Open the product page in Chrome, make sure the buy box is visible, and retry.',
);
}
return [normalized];
},
});
export const __test__ = {
extractShipsFrom,
extractSoldBy,
isDeliveryLocationBlocked,
normalizeOfferPayload,
};
+26
View File
@@ -0,0 +1,26 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './product.js';
describe('amazon product normalization', () => {
it('normalizes product facts from the product page', () => {
const result = __test__.normalizeProductPayload({
href: 'https://www.amazon.com/dp/B0FJS72893',
title: 'Amazon.com: KVTUKIAIT Desktop Shelf Organizer',
product_title: 'White Desktop Shelf Organizer for Top of Desk',
byline: 'Visit the KVTUKIAIT Store',
price_text: '$15.99',
rating_text: '3.9 out of 5 stars',
review_count_text: '27 ratings',
review_url: 'https://www.amazon.com/dp/B0FJS72893#customerReviews',
qa_url: null,
bullets: ['SPACE-SAVING DESK SHELF ORGANIZER', 'SMALL AND STYLISH AESTHETIC DECOR'],
breadcrumbs: ['Office Products', 'Desktop & Off-Surface Shelves'],
});
expect(result.asin).toBe('B0FJS72893');
expect(result.price_value).toBe(15.99);
expect(result.rating_value).toBe(3.9);
expect(result.review_count).toBe(27);
expect(result.breadcrumbs).toEqual(['Office Products', 'Desktop & Off-Surface Shelves']);
});
});
+131
View File
@@ -0,0 +1,131 @@
import { CommandExecutionError } from '@jackwener/opencli/errors';
import { cli, Strategy } from '@jackwener/opencli/registry';
import type { IPage } from '@jackwener/opencli/types';
import {
buildProductUrl,
buildProvenance,
cleanText,
extractAsin,
PRIMARY_PRICE_SELECTORS,
parsePriceText,
parseRatingValue,
parseReviewCount,
normalizeProductUrl,
uniqueNonEmpty,
assertUsableState,
gotoAndReadState,
} from './shared.js';
interface ProductPayload {
href?: string;
title?: string;
product_title?: string | null;
byline?: string | null;
price_text?: string | null;
rating_text?: string | null;
review_count_text?: string | null;
review_url?: string | null;
qa_url?: string | null;
bullets?: string[];
breadcrumbs?: string[];
}
const PRODUCT_TITLE_SELECTOR = '#productTitle, #title span, [data-feature-name="title"] h1 span';
const BYLINE_SELECTOR = '#bylineInfo, [data-feature-name="bylineInfo"] #bylineInfo';
function normalizeProductPayload(payload: ProductPayload): Record<string, unknown> {
const sourceUrl = cleanText(payload.href) || buildProductUrl(cleanText(payload.product_title) || cleanText(payload.href));
const asin = extractAsin(payload.href ?? '') ?? null;
const price = parsePriceText(payload.price_text);
const ratingText = cleanText(payload.rating_text) || null;
const reviewCountText = cleanText(payload.review_count_text) || null;
const provenance = buildProvenance(sourceUrl);
return {
asin,
title: cleanText(payload.product_title) || cleanText(payload.title) || null,
product_url: normalizeProductUrl(payload.href),
...provenance,
brand_text: cleanText(payload.byline) || null,
price_text: price.price_text,
price_value: price.price_value,
currency: price.currency,
rating_text: ratingText,
rating_value: parseRatingValue(ratingText),
review_count_text: reviewCountText,
review_count: parseReviewCount(reviewCountText),
review_url: cleanText(payload.review_url) || null,
qa_url: cleanText(payload.qa_url) || null,
breadcrumbs: uniqueNonEmpty(payload.breadcrumbs ?? []),
bullet_points: uniqueNonEmpty(payload.bullets ?? []),
};
}
async function readProductPayload(page: IPage, input: string): Promise<ProductPayload> {
const url = buildProductUrl(input);
const state = await gotoAndReadState(page, url, 2500, 'product');
assertUsableState(state, 'product');
// Amazon can report a "stable" DOM before the product title block hydrates,
// especially when reconnecting to an existing shared CDP target.
await page.wait({ selector: PRODUCT_TITLE_SELECTOR, timeout: 6 }).catch(() => {});
return await page.evaluate(`
(() => ({
href: window.location.href,
title: document.title || '',
product_title: document.querySelector(${JSON.stringify(PRODUCT_TITLE_SELECTOR)})?.textContent || '',
byline: document.querySelector(${JSON.stringify(BYLINE_SELECTOR)})?.textContent || '',
price_text: (() => {
const selectors = ${JSON.stringify(PRIMARY_PRICE_SELECTORS)};
for (const selector of selectors) {
const text = document.querySelector(selector)?.textContent || '';
if (text.trim()) return text;
}
return '';
})(),
rating_text:
document.querySelector('#acrPopover')?.getAttribute('title')
|| document.querySelector('#acrPopover')?.textContent
|| '',
review_count_text: document.querySelector('#acrCustomerReviewText')?.textContent || '',
review_url: document.querySelector('a[href*="#customerReviews"]')?.href || '',
qa_url: document.querySelector('a[href*="ask/questions"]')?.href || '',
bullets: Array.from(document.querySelectorAll('#feature-bullets li .a-list-item')).map((node) => node.textContent || ''),
breadcrumbs: Array.from(document.querySelectorAll('#wayfinding-breadcrumbs_feature_div a')).map((node) => node.textContent || ''),
}))()
`) as ProductPayload;
}
cli({
site: 'amazon',
name: 'product',
description: 'Amazon product page facts for candidate validation',
domain: 'amazon.com',
strategy: Strategy.COOKIE,
navigateBefore: false,
args: [
{
name: 'input',
required: true,
positional: true,
help: 'ASIN or product URL, for example B0FJS72893',
},
],
columns: ['asin', 'title', 'price_text', 'rating_value', 'review_count'],
func: async (page, kwargs) => {
const input = String(kwargs.input ?? '');
const payload = await readProductPayload(page, input);
if (!cleanText(payload.product_title)) {
throw new CommandExecutionError(
'amazon product page did not expose product content',
'The product page may have changed or hit a robot check. Open the product page in Chrome and retry.',
);
}
return [normalizeProductPayload(payload)];
},
});
export const __test__ = {
normalizeProductPayload,
};
+47
View File
@@ -0,0 +1,47 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './rankings.js';
describe('amazon rankings helpers', () => {
it('normalizes ranking candidates with unified schema', () => {
const result = __test__.normalizeRankingCandidate(
{
rank_text: '#3',
asin: 'B0DR31GC3D',
title: 'Desk Shelves Desktop Organizer',
href: 'https://www.amazon.com/dp/B0DR31GC3D/ref=zg_bs',
price_text: '$25.92',
rating_text: '4.3 out of 5 stars',
review_count_text: '435',
},
{
listType: 'new_releases',
rankFallback: 3,
listTitle: 'Amazon New Releases',
sourceUrl: 'https://www.amazon.com/gp/new-releases',
categoryTitle: 'Home & Kitchen',
categoryUrl: 'https://www.amazon.com/gp/new-releases/home-garden',
categoryPath: ['Home & Kitchen'],
visibleCategoryLinks: [{ title: 'Storage', url: 'https://www.amazon.com/gp/new-releases/storage', node_id: null }],
},
);
expect(result.list_type).toBe('new_releases');
expect(result.rank).toBe(3);
expect(result.asin).toBe('B0DR31GC3D');
expect(result.product_url).toBe('https://www.amazon.com/dp/B0DR31GC3D');
expect(result.category_title).toBe('Home & Kitchen');
expect(result.visible_category_links).toEqual([
{ title: 'Storage', url: 'https://www.amazon.com/gp/new-releases/storage', node_id: null },
]);
});
it('deduplicates category links and parses rank fallback', () => {
const links = __test__.normalizeVisibleCategoryLinks([
{ title: 'Kitchen', url: '/gp/new-releases/home-garden' },
{ title: 'Kitchen', url: 'https://www.amazon.com/gp/new-releases/home-garden' },
{ title: 'Storage', url: '/gp/new-releases/storage', node_id: '1064954' },
]);
expect(links.length).toBe(2);
expect(__test__.parseRank('N/A', 8)).toBe(8);
});
});
+312
View File
@@ -0,0 +1,312 @@
import { CommandExecutionError } from '@jackwener/opencli/errors';
import { Strategy, type CliOptions } from '@jackwener/opencli/registry';
import type { IPage } from '@jackwener/opencli/types';
import {
assertUsableState,
buildProvenance,
cleanText,
extractAsin,
extractCategoryNodeId,
extractReviewCountFromCardText,
firstMeaningfulLine,
gotoAndReadState,
isRankingPaginationUrl,
normalizeProductUrl,
parsePriceText,
parseRatingValue,
parseReviewCount,
resolveRankingUrl,
toAbsoluteAmazonUrl,
uniqueNonEmpty,
type AmazonRankingListType,
} from './shared.js';
export interface RankingCardPayload {
rank_text?: string | null;
asin?: string | null;
title?: string | null;
href?: string | null;
price_text?: string | null;
rating_text?: string | null;
review_count_text?: string | null;
card_text?: string | null;
}
interface RankingPagePayload {
href?: string;
title?: string;
list_title?: string;
category_title?: string;
category_path?: string[];
cards?: RankingCardPayload[];
page_links?: string[];
visible_category_links?: Array<{
title?: string | null;
url?: string | null;
node_id?: string | null;
}>;
}
interface RankingCommandDefinition {
commandName: string;
listType: AmazonRankingListType;
description: string;
}
interface RankingNormalizeContext {
listType: AmazonRankingListType;
rankFallback: number;
listTitle: string | null;
sourceUrl: string;
categoryTitle: string | null;
categoryUrl: string | null;
categoryPath: string[];
visibleCategoryLinks: Array<{ title: string; url: string; node_id: string | null }>;
}
function parseRank(rawRank: string | null | undefined, fallback: number): number {
const normalized = cleanText(rawRank);
const match = normalized.match(/(\d{1,4})/);
if (!match) return fallback;
const parsed = Number.parseInt(match[1], 10);
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
}
function normalizeVisibleCategoryLinks(
links: RankingPagePayload['visible_category_links'],
): Array<{ title: string; url: string; node_id: string | null }> {
const normalized = (links ?? [])
.map((entry) => ({
title: cleanText(entry?.title),
url: toAbsoluteAmazonUrl(entry?.url) ?? '',
node_id: cleanText(entry?.node_id) || extractCategoryNodeId(entry?.url) || null,
}))
.filter((entry) => Boolean(entry.title) && Boolean(entry.url));
const seen = new Set<string>();
const deduped: Array<{ title: string; url: string; node_id: string | null }> = [];
for (const entry of normalized) {
if (seen.has(entry.url)) continue;
seen.add(entry.url);
deduped.push(entry);
}
return deduped;
}
export function normalizeRankingCandidate(
candidate: RankingCardPayload,
context: RankingNormalizeContext,
): Record<string, unknown> {
const productUrl = normalizeProductUrl(candidate.href);
const asin = extractAsin(candidate.asin ?? '') ?? extractAsin(productUrl ?? '') ?? null;
const title = cleanText(candidate.title) || firstMeaningfulLine(candidate.card_text);
const price = parsePriceText(cleanText(candidate.price_text) || candidate.card_text);
const ratingText = cleanText(candidate.rating_text) || null;
const reviewCountText = cleanText(candidate.review_count_text)
|| extractReviewCountFromCardText(candidate.card_text)
|| null;
const provenance = buildProvenance(context.sourceUrl);
const categoryUrl = context.categoryUrl || context.sourceUrl;
return {
list_type: context.listType,
rank: parseRank(candidate.rank_text, context.rankFallback),
asin,
title: title || null,
product_url: productUrl,
price_text: price.price_text,
price_value: price.price_value,
currency: price.currency,
rating_text: ratingText,
rating_value: parseRatingValue(ratingText),
review_count_text: reviewCountText,
review_count: parseReviewCount(reviewCountText),
list_title: context.listTitle,
category_title: context.categoryTitle,
category_url: categoryUrl,
category_node_id: extractCategoryNodeId(categoryUrl),
category_path: context.categoryPath,
visible_category_links: context.visibleCategoryLinks,
...provenance,
};
}
async function readRankingPage(
page: IPage,
listType: AmazonRankingListType,
url: string,
): Promise<RankingPagePayload> {
const state = await gotoAndReadState(page, url, 2500, listType);
assertUsableState(state, listType);
return await page.evaluate(`
(() => ({
href: window.location.href,
title: document.title || '',
list_title:
document.querySelector('#zg_banner_text')?.textContent
|| document.querySelector('h1')?.textContent
|| '',
category_title:
document.querySelector('#zg_browseRoot .zg_selected')?.textContent
|| document.querySelector('#wayfinding-breadcrumbs_feature_div ul li:last-child')?.textContent
|| document.querySelector('#wayfinding-breadcrumbs_container ul li:last-child')?.textContent
|| '',
category_path: Array.from(document.querySelectorAll(
'#zg_browseRoot ul li a, #zg_browseRoot ul li span, ' +
'#wayfinding-breadcrumbs_feature_div ul li a, #wayfinding-breadcrumbs_feature_div ul li span.a-list-item, ' +
'#wayfinding-breadcrumbs_container ul li a, #wayfinding-breadcrumbs_container ul li span.a-list-item'
))
.map((entry) => (entry.textContent || '').trim())
.filter(Boolean),
cards: Array.from(document.querySelectorAll(
'.p13n-sc-uncoverable-faceout, .zg-grid-general-faceout, [data-asin][class*="p13n"]'
)).map((card) => ({
rank_text:
card.querySelector('.zg-bdg-text')?.textContent
|| card.querySelector('[class*="rank"]')?.textContent
|| '',
asin:
card.getAttribute('data-asin')
|| card.getAttribute('id')
|| '',
title:
card.querySelector('[class*="line-clamp"]')?.textContent
|| card.querySelector('img')?.getAttribute('alt')
|| card.querySelector('a[href*="/dp/"]')?.textContent
|| '',
href:
card.querySelector('a[href*="/dp/"], a[href*="/gp/product/"]')?.href
|| '',
price_text:
card.querySelector('.a-price .a-offscreen')?.textContent
|| card.querySelector('.a-color-price')?.textContent
|| '',
rating_text:
card.querySelector('[aria-label*="out of 5 stars"]')?.getAttribute('aria-label')
|| '',
review_count_text:
card.querySelector('a[href*="#customerReviews"]')?.textContent
|| card.querySelector('.a-size-small')?.textContent
|| '',
card_text: card.innerText || '',
})),
page_links: Array.from(document.querySelectorAll('.a-pagination a[href], li.a-normal a[href], li.a-selected a[href]'))
.map((anchor) => anchor.href || '')
.filter(Boolean),
visible_category_links: Array.from(document.querySelectorAll(
'#zg_browseRoot a[href], #zg-left-col a[href], [class*="zg-browse"] a[href]'
)).map((anchor) => ({
title: (anchor.textContent || '').trim(),
url: anchor.href || '',
node_id:
anchor.getAttribute('data-node-id')
|| anchor.dataset?.nodeid
|| '',
}))
.filter((entry) => entry.title && entry.url),
}))()
`) as RankingPagePayload;
}
function createEmptyResultHint(commandName: string): string {
return [
`Open the same Amazon ${commandName} page in shared Chrome and verify ranked items are visible.`,
'If the page shows a robot check, clear it manually and retry.',
].join(' ');
}
export function createRankingCliOptions(definition: RankingCommandDefinition): CliOptions {
return {
site: 'amazon',
name: definition.commandName,
description: definition.description,
domain: 'amazon.com',
strategy: Strategy.COOKIE,
navigateBefore: false,
args: [
{
name: 'input',
positional: true,
help: 'Ranking URL or supported Amazon path. Omit to use the list root.',
},
{
name: 'limit',
type: 'int',
default: 100,
help: 'Maximum number of ranked items to return (default 100)',
},
],
columns: ['list_type', 'rank', 'asin', 'title', 'price_text', 'rating_value', 'review_count'],
func: async (page, kwargs) => {
const limit = Math.max(1, Number(kwargs.limit) || 100);
const initialUrl = resolveRankingUrl(definition.listType, typeof kwargs.input === 'string' ? kwargs.input : undefined);
const queue = [initialUrl];
const visited = new Set<string>();
const seenEntityKeys = new Set<string>();
const results: Record<string, unknown>[] = [];
let listTitle: string | null = null;
while (queue.length > 0 && results.length < limit) {
const nextUrl = queue.shift()!;
if (visited.has(nextUrl)) continue;
visited.add(nextUrl);
const payload = await readRankingPage(page, definition.listType, nextUrl);
const sourceUrl = cleanText(payload.href) || nextUrl;
listTitle = cleanText(payload.list_title) || cleanText(payload.title) || listTitle;
const categoryPath = uniqueNonEmpty(payload.category_path ?? []);
const categoryTitle = cleanText(payload.category_title)
|| (categoryPath.length > 0 ? categoryPath[categoryPath.length - 1] : '');
const visibleCategoryLinks = normalizeVisibleCategoryLinks(payload.visible_category_links);
const cards = payload.cards ?? [];
for (const card of cards) {
const normalized = normalizeRankingCandidate(card, {
listType: definition.listType,
rankFallback: results.length + 1,
listTitle,
sourceUrl,
categoryTitle: categoryTitle || null,
categoryUrl: sourceUrl,
categoryPath,
visibleCategoryLinks,
});
const dedupeKey = cleanText(String(normalized.asin ?? ''))
|| cleanText(String(normalized.product_url ?? ''));
if (dedupeKey && seenEntityKeys.has(dedupeKey)) continue;
if (dedupeKey) seenEntityKeys.add(dedupeKey);
results.push(normalized);
if (results.length >= limit) break;
}
const pageLinks = uniqueNonEmpty(payload.page_links ?? []);
for (const href of pageLinks) {
const absolute = toAbsoluteAmazonUrl(href);
if (!absolute || !isRankingPaginationUrl(definition.listType, absolute)) continue;
if (!visited.has(absolute) && !queue.includes(absolute)) {
queue.push(absolute);
}
}
}
if (results.length === 0) {
throw new CommandExecutionError(
`amazon ${definition.commandName} did not expose any ranked items`,
createEmptyResultHint(definition.commandName),
);
}
return results.slice(0, limit);
},
};
}
export const __test__ = {
parseRank,
normalizeVisibleCategoryLinks,
normalizeRankingCandidate,
};
+24
View File
@@ -0,0 +1,24 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './search.js';
describe('amazon search normalization', () => {
it('normalizes search cards into research-friendly fields', () => {
const result = __test__.normalizeSearchCandidate({
asin: 'B0FJS72893',
title: 'White Desktop Shelf Organizer for Top of Desk',
href: 'https://www.amazon.com/KVTUKIAIT-White-Desktop-Shelf-Organizer/dp/B0FJS72893/ref=sr_1_1',
price_text: '$15.99',
rating_text: '3.9 out of 5 stars, rating details',
review_count_text: '(27)',
sponsored: false,
badge_texts: ['Limited time deal'],
}, 1, 'https://www.amazon.com/s?k=desk+shelf+organizer');
expect(result.asin).toBe('B0FJS72893');
expect(result.product_url).toBe('https://www.amazon.com/dp/B0FJS72893');
expect(result.price_value).toBe(15.99);
expect(result.rating_value).toBe(3.9);
expect(result.review_count).toBe(27);
expect(result.badges).toEqual(['Limited time deal']);
});
});
+128
View File
@@ -0,0 +1,128 @@
import { CommandExecutionError } from '@jackwener/opencli/errors';
import { cli, Strategy } from '@jackwener/opencli/registry';
import type { IPage } from '@jackwener/opencli/types';
import {
buildProvenance,
buildSearchUrl,
cleanText,
extractAsin,
normalizeProductUrl,
parsePriceText,
parseRatingValue,
parseReviewCount,
assertUsableState,
gotoAndReadState,
} from './shared.js';
interface SearchPayload {
href?: string;
cards?: Array<{
asin?: string;
title?: string;
href?: string;
price_text?: string | null;
rating_text?: string | null;
review_count_text?: string | null;
sponsored?: boolean;
badge_texts?: string[];
}>;
}
function normalizeSearchCandidate(
candidate: NonNullable<SearchPayload['cards']>[number],
rank: number,
sourceUrl: string,
): Record<string, unknown> {
const productUrl = normalizeProductUrl(candidate.href);
const asin = extractAsin(candidate.asin ?? '') ?? extractAsin(productUrl ?? '') ?? null;
const price = parsePriceText(candidate.price_text);
const ratingText = cleanText(candidate.rating_text) || null;
const reviewCountText = cleanText(candidate.review_count_text) || null;
const provenance = buildProvenance(sourceUrl);
return {
rank,
asin,
title: cleanText(candidate.title) || null,
product_url: productUrl,
...provenance,
price_text: price.price_text,
price_value: price.price_value,
currency: price.currency,
rating_text: ratingText,
rating_value: parseRatingValue(ratingText),
review_count_text: reviewCountText,
review_count: parseReviewCount(reviewCountText),
is_sponsored: candidate.sponsored === true,
badges: (candidate.badge_texts ?? []).map((value) => cleanText(value)).filter(Boolean),
};
}
async function readSearchPayload(page: IPage, query: string): Promise<SearchPayload> {
const url = buildSearchUrl(query);
const state = await gotoAndReadState(page, url, 2500, 'search');
assertUsableState(state, 'search');
return await page.evaluate(`
(() => ({
href: window.location.href,
cards: Array.from(document.querySelectorAll('[data-component-type="s-search-result"]'))
.map((card) => ({
asin: card.getAttribute('data-asin') || '',
title: card.querySelector('h2')?.textContent || '',
href: card.querySelector('a.a-link-normal[href*="/dp/"]')?.href || '',
price_text: card.querySelector('.a-price .a-offscreen')?.textContent || '',
rating_text: card.querySelector('[aria-label*="out of 5 stars"]')?.getAttribute('aria-label') || '',
review_count_text: card.querySelector('a[href*="#customerReviews"]')?.textContent || '',
sponsored: /sponsored/i.test(card.innerText || ''),
badge_texts: Array.from(card.querySelectorAll('.a-badge-text')).map((node) => node.textContent || ''),
})),
}))()
`) as SearchPayload;
}
cli({
site: 'amazon',
name: 'search',
description: 'Amazon search results for product discovery and coarse filtering',
domain: 'amazon.com',
strategy: Strategy.COOKIE,
navigateBefore: false,
args: [
{
name: 'query',
required: true,
positional: true,
help: 'Search query, for example "desk shelf organizer"',
},
{
name: 'limit',
type: 'int',
default: 20,
help: 'Maximum number of results to return (default 20)',
},
],
columns: ['rank', 'asin', 'title', 'price_text', 'rating_value', 'review_count'],
func: async (page, kwargs) => {
const query = String(kwargs.query ?? '');
const limit = Math.max(1, Number(kwargs.limit) || 20);
const payload = await readSearchPayload(page, query);
const sourceUrl = cleanText(payload.href) || buildSearchUrl(query);
const cards = (payload.cards ?? [])
.filter((card) => cleanText(card.asin) && cleanText(card.title))
.slice(0, limit);
if (cards.length === 0) {
throw new CommandExecutionError(
'amazon search did not expose any product cards',
'The search page may have changed or hit a robot check. Open the same query in Chrome, verify the page is visible, and retry.',
);
}
return cards.map((card, index) => normalizeSearchCandidate(card, index + 1, sourceUrl));
},
});
export const __test__ = {
normalizeSearchCandidate,
};
+53
View File
@@ -0,0 +1,53 @@
import { describe, expect, it } from 'vitest';
import { __test__ } from './shared.js';
describe('amazon shared helpers', () => {
it('builds canonical product and discussion URLs from ASINs and product URLs', () => {
expect(__test__.buildProductUrl('B0FJS72893')).toBe('https://www.amazon.com/dp/B0FJS72893');
expect(__test__.buildProductUrl('https://www.amazon.com/dp/B0FJS72893/ref=something')).toBe('https://www.amazon.com/dp/B0FJS72893');
expect(__test__.buildDiscussionUrl('https://www.amazon.com/dp/B0FJS72893')).toBe('https://www.amazon.com/product-reviews/B0FJS72893');
});
it('parses price, rating, and review-count text', () => {
expect(__test__.parsePriceText('1 offer from $34.11')).toEqual({
price_text: '$34.11',
price_value: 34.11,
currency: 'USD',
});
expect(__test__.parseRatingValue('3.9 out of 5 stars, rating details')).toBe(3.9);
expect(__test__.parseReviewCount('27 global ratings')).toBe(27);
expect(__test__.parseReviewCount('(2.9K)')).toBe(2900);
expect(__test__.parseReviewCount('1.2M global ratings')).toBe(1200000);
expect(__test__.extractReviewCountFromCardText('Desk Shelf\n4.3 out of 5 stars\n435\n$25.92')).toBe('435');
});
it('recognizes robot checks and Amazon-owned merchants', () => {
expect(__test__.isAmazonEntity('Ships from Amazon')).toBe(true);
expect(__test__.trimRatingPrefix('5.0 out of 5 stars Great value and quality')).toBe('Great value and quality');
expect(__test__.isRobotState({
title: 'Robot Check',
body_text: 'Sorry, we just need to make sure you\'re not a robot',
})).toBe(true);
});
it('requires a real best-sellers URL or path', () => {
expect(__test__.resolveBestsellersUrl('/Best-Sellers/zgbs')).toBe('https://www.amazon.com/Best-Sellers/zgbs');
expect(() => __test__.resolveBestsellersUrl('desk shelf organizer')).toThrow('amazon bestsellers expects a best sellers URL or /zgbs path');
});
it('resolves and validates all ranking list URLs', () => {
expect(__test__.resolveRankingUrl('new_releases')).toBe('https://www.amazon.com/gp/new-releases');
expect(__test__.resolveRankingUrl('movers_shakers')).toBe('https://www.amazon.com/gp/movers-and-shakers');
expect(__test__.resolveRankingUrl('new_releases', '/gp/new-releases/kitchen')).toBe('https://www.amazon.com/gp/new-releases/kitchen');
expect(__test__.resolveRankingUrl(
'bestsellers',
'https://www.amazon.com/Best-Sellers/zgbs/ref=zg_bsnr_tab_bs',
)).toBe('https://www.amazon.com/Best-Sellers/zgbs');
expect(() => __test__.resolveRankingUrl('movers_shakers', 'https://example.com/gp/movers-and-shakers')).toThrow('Invalid Amazon URL');
});
it('extracts category node id from URL best effort', () => {
expect(__test__.extractCategoryNodeId('https://www.amazon.com/Best-Sellers-Home-Kitchen/zgbs/home-garden/3744371')).toBe('3744371');
expect(__test__.extractCategoryNodeId('https://www.amazon.com/s?k=desk+organizer&rh=n%3A1064954')).toBe('1064954');
});
});
+438
View File
@@ -0,0 +1,438 @@
import { ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';
import type { IPage } from '@jackwener/opencli/types';
export const SITE = 'amazon';
export const DOMAIN = 'amazon.com';
export const HOME_URL = 'https://www.amazon.com/';
export const BESTSELLERS_URL = 'https://www.amazon.com/Best-Sellers/zgbs';
export const NEW_RELEASES_URL = 'https://www.amazon.com/gp/new-releases';
export const MOVERS_SHAKERS_URL = 'https://www.amazon.com/gp/movers-and-shakers';
export const SEARCH_URL_PREFIX = 'https://www.amazon.com/s?k=';
export const PRODUCT_URL_PREFIX = 'https://www.amazon.com/dp/';
export const DISCUSSION_URL_PREFIX = 'https://www.amazon.com/product-reviews/';
export const STRATEGY = 'cookie';
export const PRIMARY_PRICE_SELECTORS = [
'#corePrice_feature_div .a-offscreen',
'#corePriceDisplay_desktop_feature_div .a-offscreen',
'#corePrice_desktop .a-offscreen',
'#apex_desktop .a-offscreen',
'#newAccordionRow_0 .a-offscreen',
'#price_inside_buybox',
'#priceblock_ourprice',
'#priceblock_dealprice',
'#tp_price_block_total_price_ww',
];
const ROBOT_TEXT_PATTERNS = [
'Sorry, we just need to make sure you\'re not a robot',
'Enter the characters you see below',
'Type the characters you see in this image',
'To discuss automated access to Amazon data please contact',
];
export type AmazonRankingListType = 'bestsellers' | 'new_releases' | 'movers_shakers';
interface AmazonRankingSpec {
commandName: string;
rootUrl: string;
pathPattern: RegExp;
invalidInputMessage: string;
invalidInputHint: string;
}
const AMAZON_RANKING_SPECS: Record<AmazonRankingListType, AmazonRankingSpec> = {
bestsellers: {
commandName: 'bestsellers',
rootUrl: BESTSELLERS_URL,
pathPattern: /(?:^|\/)zgbs(?:\/|$)/i,
invalidInputMessage: 'amazon bestsellers expects a best sellers URL or /zgbs path',
invalidInputHint: 'Example: opencli amazon bestsellers https://www.amazon.com/Best-Sellers/zgbs',
},
new_releases: {
commandName: 'new-releases',
rootUrl: NEW_RELEASES_URL,
pathPattern: /\/gp\/new-releases(?:\/|$)/i,
invalidInputMessage: 'amazon new-releases expects a new releases URL or /gp/new-releases path',
invalidInputHint: 'Example: opencli amazon new-releases https://www.amazon.com/gp/new-releases',
},
movers_shakers: {
commandName: 'movers-shakers',
rootUrl: MOVERS_SHAKERS_URL,
pathPattern: /\/gp\/movers-and-shakers(?:\/|$)/i,
invalidInputMessage: 'amazon movers-shakers expects a movers-and-shakers URL or /gp/movers-and-shakers path',
invalidInputHint: 'Example: opencli amazon movers-shakers https://www.amazon.com/gp/movers-and-shakers',
},
};
export interface ProvenanceFields {
source_url: string;
fetched_at: string;
strategy: string;
}
export interface PageState {
href: string;
title: string;
body_text: string;
}
export interface PriceValue {
price_text: string | null;
price_value: number | null;
currency: string | null;
}
export function cleanText(value: unknown): string {
return typeof value === 'string'
? value.replace(/\u00a0/g, ' ').replace(/\s+/g, ' ').trim()
: '';
}
export function cleanMultilineText(value: unknown): string {
return typeof value === 'string'
? value
.replace(/\u00a0/g, ' ')
.split('\n')
.map((line) => line.replace(/\s+/g, ' ').trim())
.filter(Boolean)
.join('\n')
: '';
}
export function uniqueNonEmpty(values: Array<string | null | undefined>): string[] {
return [...new Set(values.map((value) => cleanText(value)).filter(Boolean))];
}
export function buildProvenance(sourceUrl: string): ProvenanceFields {
return {
source_url: sourceUrl,
fetched_at: new Date().toISOString(),
strategy: STRATEGY,
};
}
export function buildSearchUrl(query: string): string {
const normalized = cleanText(query);
if (!normalized) {
throw new ArgumentError('amazon search query cannot be empty');
}
return `${SEARCH_URL_PREFIX}${encodeURIComponent(normalized)}`;
}
export function extractAsin(input: string): string | null {
const normalized = cleanText(input);
if (!normalized) return null;
if (/^[A-Z0-9]{10}$/i.test(normalized)) {
return normalized.toUpperCase();
}
const match = normalized.match(/\/(?:dp|gp\/product|product-reviews)\/([A-Z0-9]{10})/i);
return match ? match[1].toUpperCase() : null;
}
export function buildProductUrl(input: string): string {
const asin = extractAsin(input);
if (!asin) {
throw new ArgumentError(
'amazon product expects an ASIN or product URL',
'Example: opencli amazon product B0FJS72893',
);
}
return `${PRODUCT_URL_PREFIX}${asin}`;
}
export function buildDiscussionUrl(input: string): string {
const asin = extractAsin(input);
if (!asin) {
throw new ArgumentError(
'amazon discussion expects an ASIN or product URL',
'Example: opencli amazon discussion B0FJS72893',
);
}
return `${DISCUSSION_URL_PREFIX}${asin}`;
}
function getRankingSpec(listType: AmazonRankingListType): AmazonRankingSpec {
return AMAZON_RANKING_SPECS[listType];
}
export function isSupportedRankingPath(listType: AmazonRankingListType, inputUrl: string): boolean {
try {
const url = new URL(inputUrl);
return getRankingSpec(listType).pathPattern.test(url.pathname);
} catch {
return false;
}
}
export function resolveRankingUrl(listType: AmazonRankingListType, input?: string): string {
const spec = getRankingSpec(listType);
const normalized = cleanText(input);
if (!normalized || normalized === 'root') return spec.rootUrl;
let candidateUrl: string;
if (normalized.startsWith('/')) {
candidateUrl = new URL(normalized, HOME_URL).toString();
} else if (/^https?:\/\//i.test(normalized)) {
candidateUrl = canonicalizeAmazonUrl(normalized);
} else if (normalized.includes('amazon.') && normalized.includes('/')) {
candidateUrl = canonicalizeAmazonUrl(`https://${normalized.replace(/^\/+/, '')}`);
} else {
throw new ArgumentError(spec.invalidInputMessage, spec.invalidInputHint);
}
if (!isSupportedRankingPath(listType, candidateUrl)) {
throw new ArgumentError(spec.invalidInputMessage, spec.invalidInputHint);
}
return normalizeRankingInputUrl(candidateUrl);
}
function normalizeRankingInputUrl(inputUrl: string): string {
try {
const url = new URL(inputUrl);
const normalizedPathSegments = url.pathname
.split('/')
.filter(Boolean)
.filter((segment) => !/^ref=/i.test(segment));
url.pathname = `/${normalizedPathSegments.join('/')}`;
url.hash = '';
// Ranking pages are frequently shared with tracking refs that can land on unstable variants.
// Dropping ref keeps the canonical ranking path while preserving useful params (for example pg=2).
url.searchParams.delete('ref');
return url.toString();
} catch {
return inputUrl;
}
}
export function isRankingPaginationUrl(listType: AmazonRankingListType, inputUrl: string): boolean {
const absolute = toAbsoluteAmazonUrl(inputUrl);
if (!absolute || !isSupportedRankingPath(listType, absolute)) return false;
try {
const url = new URL(absolute);
const ref = cleanText(url.searchParams.get('ref')).toLowerCase();
// pg= query param is the most reliable pagination indicator across all ranking lists
return url.searchParams.has('pg')
|| /(?:^|_)pg(?:_|$)/.test(ref)
// Amazon ranking pagination refs: zg_bs_pg_ (bestsellers), zg_bsnr_pg_ (new releases), zg_bsms_pg_ (movers & shakers)
|| /zg_bs(?:nr|ms)?_pg_/.test(ref);
} catch {
return false;
}
}
export function extractCategoryNodeId(inputUrl: string | null | undefined): string | null {
const absolute = toAbsoluteAmazonUrl(inputUrl);
if (!absolute) return null;
try {
const url = new URL(absolute);
for (const key of ['node', 'nodeid', 'nodeId', 'browseNode']) {
const value = cleanText(url.searchParams.get(key));
if (/^\d{4,}$/.test(value)) return value;
}
const rhValue = cleanText(url.searchParams.get('rh'));
const rhMatch = decodeURIComponent(rhValue).match(/(?:^|,)\s*n:(\d{4,})(?:,|$)/i);
if (rhMatch) return rhMatch[1];
const pathMatches = [...url.pathname.matchAll(/\/(\d{4,})(?=\/|$)/g)];
if (pathMatches.length > 0) {
return pathMatches[pathMatches.length - 1][1];
}
} catch {
return null;
}
return null;
}
export function resolveBestsellersUrl(input?: string): string {
return resolveRankingUrl('bestsellers', input);
}
export function canonicalizeAmazonUrl(input: string): string {
try {
const url = new URL(input);
if (!url.hostname.endsWith(DOMAIN)) {
throw new Error('not-amazon');
}
return url.toString();
} catch {
throw new ArgumentError('Invalid Amazon URL');
}
}
export function toAbsoluteAmazonUrl(value: string | null | undefined): string | null {
const normalized = cleanText(value);
if (!normalized) return null;
try {
return new URL(normalized, HOME_URL).toString();
} catch {
return null;
}
}
export function normalizeProductUrl(value: string | null | undefined): string | null {
const normalized = cleanText(value);
const asin = extractAsin(normalized);
if (asin) return buildProductUrl(asin);
return toAbsoluteAmazonUrl(normalized);
}
export function parsePriceText(text: string | null | undefined): PriceValue {
const normalized = cleanText(text);
const match = normalized.match(/([$€£])\s*(\d+(?:,\d{3})*(?:\.\d+)?)/);
if (!match) {
return {
price_text: normalized || null,
price_value: null,
currency: null,
};
}
const currencyMap: Record<string, string> = {
'$': 'USD',
'€': 'EUR',
'£': 'GBP',
};
return {
price_text: `${match[1]}${match[2]}`,
price_value: Number.parseFloat(match[2].replace(/,/g, '')),
currency: currencyMap[match[1]] ?? null,
};
}
export function parseRatingValue(text: string | null | undefined): number | null {
const normalized = cleanText(text);
const match = normalized.match(/(\d+(?:\.\d+)?)\s*out of 5/i);
return match ? Number.parseFloat(match[1]) : null;
}
export function parseReviewCount(text: string | null | undefined): number | null {
const normalized = cleanText(text);
const compactMatch = normalized.match(/(\d+(?:\.\d+)?)\s*([kKmM])/);
if (compactMatch) {
const value = Number.parseFloat(compactMatch[1]);
const multiplier = /m/i.test(compactMatch[2]) ? 1_000_000 : 1_000;
return Number.isFinite(value) ? Math.round(value * multiplier) : null;
}
const match = normalized.match(/([\d,]+)/);
return match ? Number.parseInt(match[1].replace(/,/g, ''), 10) : null;
}
export function extractReviewCountFromCardText(text: string | null | undefined): string | null {
const normalized = cleanMultilineText(text);
const match = normalized.match(/out of 5 stars(?:, rating details)?\s*([\d,]+)/i);
if (match) return match[1];
const numericLine = normalized
.split('\n')
.map((line) => cleanText(line))
.find((line) => /^[\d,]+$/.test(line));
return numericLine ?? null;
}
export function isAmazonEntity(text: string | null | undefined): boolean {
const normalized = cleanText(text).toLowerCase();
return normalized.includes('amazon');
}
export function firstMeaningfulLine(text: string | null | undefined): string {
return cleanMultilineText(text)
.split('\n')
.map((line) => cleanText(line))
.find(Boolean)
?? '';
}
export function trimRatingPrefix(text: string | null | undefined): string | null {
const normalized = cleanText(text);
if (!normalized) return null;
return normalized.replace(/^\d+(?:\.\d+)?\s*out of 5 stars\s*/i, '').trim() || normalized;
}
export function isRobotState(state: Partial<PageState>): boolean {
const title = cleanText(state.title);
const bodyText = cleanMultilineText(state.body_text);
return ROBOT_TEXT_PATTERNS.some((pattern) => title.includes(pattern) || bodyText.includes(pattern));
}
export function buildChallengeHint(action: string): string {
return [
`Open a clean Amazon ${action} page in the shared Chrome profile and clear any robot check first.`,
'If you are using CDP, set OPENCLI_CDP_TARGET=amazon.com and avoid parallel Amazon commands against the same browser target.',
].join(' ');
}
export async function readPageState(page: IPage): Promise<PageState> {
const result = await page.evaluate(`
(() => ({
href: window.location.href,
title: document.title || '',
body_text: document.body ? document.body.innerText || '' : '',
}))()
`) as Partial<PageState>;
return {
href: cleanText(result.href),
title: cleanText(result.title),
body_text: cleanMultilineText(result.body_text),
};
}
export async function gotoAndReadState(
page: IPage,
url: string,
settleMs: number = 2500,
action: string = 'page',
): Promise<PageState> {
try {
await page.goto(url, { settleMs });
await page.wait(1.5);
return await readPageState(page);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
if (
message.includes('Inspected target navigated or closed')
|| message.includes('Cannot find context with specified id')
|| message.includes('Target closed')
) {
throw new CommandExecutionError(
`amazon ${action} navigation lost the current browser target`,
`${buildChallengeHint(action)} If CDP is attached to a stale tab, open a fresh Amazon tab and retry.`,
);
}
throw error;
}
}
export function assertUsableState(state: PageState, action: string): void {
if (!isRobotState(state)) return;
throw new CommandExecutionError(
`amazon ${action} hit a robot check`,
buildChallengeHint(action),
);
}
export const __test__ = {
buildSearchUrl,
extractAsin,
buildProductUrl,
buildDiscussionUrl,
resolveBestsellersUrl,
resolveRankingUrl,
isSupportedRankingPath,
isRankingPaginationUrl,
extractCategoryNodeId,
parsePriceText,
parseRatingValue,
parseReviewCount,
extractReviewCountFromCardText,
isAmazonEntity,
trimRatingPrefix,
isRobotState,
PRIMARY_PRICE_SELECTORS,
};
@@ -7,17 +7,10 @@ description: How to automate Antigravity using OpenCLI
This skill allows AI agents to control the [Antigravity](https://github.com/chengazhen/Antigravity) desktop app (and any Electron app with CDP enabled) programmatically via OpenCLI.
## Requirements
The target Electron application MUST be launched with the remote-debugging-port flag:
\`\`\`bash
/Applications/Antigravity.app/Contents/MacOS/Electron --remote-debugging-port=9224
\`\`\`
opencli automatically detects, launches (with `--remote-debugging-port=9234`), and connects to Antigravity.
If Antigravity is already running without CDP, opencli will prompt to restart it.
The agent must configure the endpoint environment variable locally before invoking standard commands:
\`\`\`bash
export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9224"
\`\`\`
If the endpoint exposes multiple inspectable targets, also set:
If the endpoint exposes multiple inspectable targets, set:
\`\`\`bash
export OPENCLI_CDP_TARGET="antigravity"
\`\`\`
@@ -33,7 +26,6 @@ export OPENCLI_CDP_TARGET="antigravity"
### Generating and Saving Code
\`\`\`bash
export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9224"
opencli antigravity send "Write a python script to fetch HN top stories"
# wait ~10-15 seconds for output to render
opencli antigravity extract-code > hn_fetcher.py
@@ -42,6 +34,5 @@ opencli antigravity extract-code > hn_fetcher.py
### Reading Real-time Logs
Agents can run long-running streaming watch instances:
\`\`\`bash
export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9224"
opencli antigravity watch
\`\`\`
@@ -1,4 +1,4 @@
import { cli, Strategy } from '../../registry.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
import * as fs from 'node:fs';
export const dumpCommand = cli({
@@ -1,4 +1,4 @@
import { cli, Strategy } from '../../registry.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
export const extractCodeCommand = cli({
site: 'antigravity',
@@ -1,4 +1,4 @@
import { cli, Strategy } from '../../registry.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
export const modelCommand = cli({
site: 'antigravity',
@@ -1,4 +1,4 @@
import { cli, Strategy } from '../../registry.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
export const newCommand = cli({
site: 'antigravity',
@@ -1,4 +1,4 @@
import { cli, Strategy } from '../../registry.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
export const readCommand = cli({
site: 'antigravity',
@@ -1,4 +1,4 @@
import { cli, Strategy } from '../../registry.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
export const sendCommand = cli({
site: 'antigravity',
@@ -6,14 +6,15 @@
* and returns it in Anthropic format.
*
* Usage:
* OPENCLI_CDP_ENDPOINT=http://127.0.0.1:9224 opencli antigravity serve --port 8082
* opencli antigravity serve --port 8082
* ANTHROPIC_BASE_URL=http://localhost:8082 claude
*/
import { createServer, type IncomingMessage, type ServerResponse } from 'node:http';
import { CDPBridge } from '../../browser/cdp.js';
import type { IPage } from '../../types.js';
import { EXIT_CODES, getErrorMessage } from '../../errors.js';
import { CDPBridge } from '@jackwener/opencli/browser/cdp';
import type { IPage } from '@jackwener/opencli/types';
import { resolveElectronEndpoint } from '@jackwener/opencli/launcher';
import { EXIT_CODES, getErrorMessage } from '@jackwener/opencli/errors';
// ─── Types ───────────────────────────────────────────────────────────
@@ -436,13 +437,7 @@ export async function startServe(opts: { port?: number } = {}): Promise<void> {
}
}
const endpoint = process.env.OPENCLI_CDP_ENDPOINT;
if (!endpoint) {
throw new Error(
'OPENCLI_CDP_ENDPOINT is not set.\n' +
'Usage: OPENCLI_CDP_ENDPOINT=http://127.0.0.1:9224 opencli antigravity serve'
);
}
const endpoint = await resolveElectronEndpoint('antigravity');
// Note: Antigravity chat panel lives inside editor windows, not in Launchpad.
// If multiple editor windows are open, set OPENCLI_CDP_TARGET to the window title.
@@ -461,7 +456,7 @@ export async function startServe(opts: { port?: number } = {}): Promise<void> {
console.error(`[serve] Connecting via CDP (target pattern: "${process.env.OPENCLI_CDP_TARGET}")...`);
cdp = new CDPBridge();
try {
page = await cdp.connect({ timeout: 15_000 });
page = await cdp.connect({ timeout: 15_000, cdpEndpoint: endpoint });
} catch (err: unknown) {
cdp = null;
const errMsg = getErrorMessage(err);
@@ -471,7 +466,7 @@ export async function startServe(opts: { port?: number } = {}): Promise<void> {
isRefused
? `Cannot connect to Antigravity at ${endpoint}.\n` +
' 1. Make sure Antigravity is running\n' +
' 2. Launch with: --remote-debugging-port=9224'
' 2. Launch with: --remote-debugging-port=9234'
: `CDP connection failed: ${errMsg}`
);
}
@@ -1,4 +1,4 @@
import { cli, Strategy } from '../../registry.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
export const statusCommand = cli({
site: 'antigravity',
@@ -1,4 +1,4 @@
import { cli, Strategy } from '../../registry.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
export const watchCommand = cli({
site: 'antigravity',
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { getRegistry } from '../../registry.js';
import { getRegistry } from '@jackwener/opencli/registry';
import './search.js';
import './top.js';
@@ -1,5 +1,5 @@
import { cli, Strategy } from '../../registry.js';
import { CliError } from '../../errors.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { CliError } from '@jackwener/opencli/errors';
import { itunesFetch, formatDuration, formatDate } from './utils.js';
cli({
@@ -1,5 +1,5 @@
import { cli, Strategy } from '../../registry.js';
import { CliError } from '../../errors.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { CliError } from '@jackwener/opencli/errors';
import { itunesFetch } from './utils.js';
cli({
@@ -1,5 +1,5 @@
import { cli, Strategy } from '../../registry.js';
import { CliError } from '../../errors.js';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { CliError } from '@jackwener/opencli/errors';
// Apple Marketing Tools RSS API — public, no key required
const CHARTS_URL = 'https://rss.marketingtools.apple.com/api/v2';
@@ -5,7 +5,7 @@
* https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/iTuneSearchAPI/
*/
import { CliError } from '../../errors.js';
import { CliError } from '@jackwener/opencli/errors';
const BASE = 'https://itunes.apple.com';

Some files were not shown because too many files have changed in this diff Show More