电商 Agent 浏览器 Skill
Overview
Operate ecommerce web apps through real browser UI while keeping the model as the decision maker. The runtime uses Playwright with a persistent Chromium profile, not a packet-capture browser extension and not token replay. Prefer DOM/accessibility snapshots and semantic recipes; use screenshots, user clicks, or captured browser traffic only as development fallback when a component cannot be read structurally.
This skill now includes a generic Browser Intelligence layer. PDD workflows are a vertical shell on top of that layer; the browser.* commands are site-neutral and may be used on any webpage. Do not put PDD product/customer/store meaning into the generic layer. The model decides whether a browser observation, coordinate, request, or adapter candidate matches the user goal.
Generic browser commands:
bashnode scripts/pdd-operator.mjs browser.observe-light --url https://example.com --out result.json node scripts/pdd-operator.mjs browser.tabs --include-text --out tabs.json node scripts/pdd-operator.mjs browser.select-tab --tab-title "Dashboard" --out selected-tab.json node scripts/pdd-operator.mjs browser.inspect-point --x 320 --y 580 --out point.json node scripts/pdd-operator.mjs browser.inspect-region --x 240 --y 420 --w 600 --h 220 --out region.json node scripts/pdd-operator.mjs browser.inspect-row-or-card --x 320 --y 580 --out row.json node scripts/pdd-operator.mjs browser.zoom-crop --x 240 --y 420 --w 600 --h 220 --scale 2 --out crop.json node scripts/pdd-operator.mjs browser.script --mode read --script "return helpers.fields()" --out script.json node scripts/pdd-operator.mjs browser.network-record --duration 5000 --out network.json node scripts/pdd-operator.mjs browser.adapter-save --input model-approved-adapter.json --save-as adapter.json node scripts/pdd-operator.mjs browser.adapter-run --adapter-file adapter.json --params '{"page":1}' --out adapter-run.json node scripts/pdd-operator.mjs browser.memory --op drop --handle page_12 --summary "short retained memory"
Inside a persistent browser session, prefer the shorter live-page aliases for real workflows:
bashnode scripts/pdd-operator.mjs session observe-light --account shop-a --url https://example.com --out page.json node scripts/pdd-operator.mjs session inspect-region --account shop-a --x 240 --y 420 --w 600 --h 220 --out region.json node scripts/pdd-operator.mjs session inspect-region --account shop-a --region '{"x":240,"y":420,"width":600,"height":220}' --out region.json node scripts/pdd-operator.mjs session zoom-crop --account shop-a --x 240 --y 420 --w 600 --h 220 --scale 2 --out crop.json node scripts/pdd-operator.mjs session script --account shop-a --mode act --model-approved-script true --script-file fallback.js --out script-act.json
browser.observe-light is handle-first: it returns URL/title, visible text, rows/cards/forms/dialogs, short-id pageView, token estimate, screenshot handle, and artifact handles. It does not inline full DOM/AX/HTML/modelEvidence, coordinates, CSS, XPath, or full action registries. Use browser.inspect-point or browser.inspect-region when screenshots are visually useful but small text, IDs, prices, long titles, or form values require precise DOM text. Use browser.tabs/browser.select-tab to enumerate and mechanically select open tabs by model-chosen index, URL, title, or visible text. Use browser.network-record to capture GET/POST/XHR/fetch traffic and produce a mechanical CLI-adapter draft; the model must decide whether to promote it. browser.adapter-save requires modelApprovedAdapter=true and explicit model-chosen operations/verification. browser.adapter-run reads current browser cookies/tokens from the active profile/CDP session, redacts auth from output, and returns response/verification evidence plus a mechanical verificationSummary; HTTP 200 alone is never task success, and the model still decides task success from business verification and page state.
browser.script is the harness-style escape hatch. Use mode=read for DOM/text extraction and diagnosis; it blocks obvious clicks, form submits, DOM mutation, direct network APIs, cookies, and storage access. Use mode=act after the model has chosen the exact low-risk page-native fallback and passes modelApprovedScript=true; it returns pageChange and blocks direct fetch/XHR/cookie/storage access. Use mode=raw when the user has authorized broad testing and the model needs harness-like direct page JavaScript, including page-local fetch; output is still redacted and pageChange must be reviewed.
browser.observe-light.page exposes task-friendly structural evidence: dialogs include text plus visible clickable short ids, tables include headers/row counts/sample rows, rows include row text plus row-scoped action ids, and formControls include labels/placeholders/current values/short ids. These fields are still evidence only; the model decides target identity, form meaning, platform validation, and final success.
For VLM-capable runs, treat screenshot handles as optional visual evidence for layout, occlusion, modals, canvas, icon-only controls, and coordinate planning. Do not use screenshots as the source of truth for small text or business fields; verify IDs, prices, inventory, sales counts, long titles, and form values with browser.inspect-point, browser.inspect-region, or browser.inspect-row-or-card.
For already-open browser windows, set --cdp-url <http://host:port> or PDD_OPERATOR_CONNECT_CDP_URL to attach through Chrome DevTools Protocol. CDP attach mode is generic, keeps the user-owned browser alive, and can prefer a tab via --tab-url <text>, --tab-title <text>, or --tab-text <text>.
Runtime Dependencies
- Standalone development mode needs Node.js 18+, npm dependencies from
package.json, and Playwright's Chromium browser binary. - Productized PDD Agent app mode does not require system Node.js. Use the
pdd-operatorcommand on PATH, or the absolute command inPDD_OPERATOR_CLI; the app injects a bundled Node shim andPLAYWRIGHT_BROWSERS_PATH. - Network access is only needed for first-time standalone
npm installandplaywright install chromium. The packaged app should already include its dependencies.
Before operating a store in standalone mode, run:
bashnpm run setup npm run doctor
If a dependency is missing in standalone mode, the agent should fix it directly by running npm run setup from this skill directory. In packaged app mode, do not assume npm or system node exists; use the app's environment self-check and the pdd-operator command. Browser commands also auto-attempt dependency repair once when the Playwright package or Chromium binary is missing.
Set PDD_OPERATOR_HEADLESS=1 for silent default browser operation. Login and risk verification flows still need a visible browser; override with --headless false for those runs.
Operating Rules
- Scripts are tools, not judges. Treat monitor/product/material candidates from CLI output as evidence for the model to review, not as final business truth. The model must decide whether a candidate is a real product, header, ad, notice, empty state, or aggregate counter before recording it or acting on it.
- The generic Browser Intelligence layer is also tools-only. It may capture screenshots, DOM text, element chains, region evidence, coordinates, network requests, handles, and adapter drafts, but it must not decide what object is the target, whether a workflow should use CLI, or whether the task succeeded.
- Do not ask a script to make semantic decisions that depend on page meaning. Use scripts to gather rich DOM/accessibility/text/row/card evidence and to execute confirmed actions; use the model to choose the path, classify candidates, decide whether experience applies, and explain why.
- When a command returns
modelReviewRequired, readproductCandidates,pageEvidence, andmodelReview; reject false positives such as table headers (30日销量), navigation, notices, and ads. Do not useproductsunless they arereviewedProductsfrom model review or the user explicitly requested a low-level debug run. - Product material
inputCandidates,productUnderstanding,productUnderstandingGate, andexperienceStrategyare evidence only. Candidate price/stock values are not publish inputs until the model or user explicitly confirms them. The script must not classify the product, choose category meaning, infer SKU type, decide which experience applies, or decide experience reuse. The model must review the material evidence and explicitly decide category and experience reuse; setproductUnderstandingReviewedByModel/modelApprovedCategoryonly after choosing the category, and setexperienceReviewedByModel/modelApprovedExperienceReuseonly together with an explicitmodelApprovedExperienceId/experienceReuseIdand explicitmodelApprovedExperienceReuseParts/experienceReuseParts. - Product material publish inputs must use the exact
product.publish-materialcontract:title,categoryPathas an array of category levels,categorySearchText,categoryExpectedText,price.groupPrice,price.singlePrice,price.referencePrice,stock,mainImages,detailImages,video,skuSpecs,skuRows,skuImages/skuPreviewImages,productUnderstandingReviewedByModel, andmodelApprovedCategoryorcategoryUserConfirmedwhen appropriate.skuImagesare raw SKU/spec material; row preview upload needs explicitskuRows[].image/previewImage/skuImageor model-chosen row-orderskuPreviewImages. If a SKU spec value input is duplicated/equally matching, retry withskuSpecs[].skuSpecValueInputIndex/modelSelectedSkuSpecValueInputIndexor value-specificskuSpecValueInputIndexes. If a SKU table row or cell control is duplicated/equally matching, the tool returnsSKU_TABLE_CONTROL_MODEL_REVIEW_REQUIRED; inspect full evidence and retry withskuRows[].skuTableRowIndex/modelSelectedSkuTableRowIndexorskuRows[].skuTableControlIndex/modelSelectedSkuTableControlIndex. Do not invent aliases such ascategoryKeywords,skuPlan, orprice.marketPrice; convert those model decisions into the standard fields before running the command. - If
productUnderstandingGate.modelReviewRequired=true,CATEGORY_SELECTION_UNRESOLVEDreturns only broad/recent/mismatched visible categories,CATEGORY_CANDIDATE_MODEL_REVIEW_REQUIREDreturns multiple matching category candidates, or category evidence is insufficient, treat that as evidence for the model, not a script verdict. The model decides whether to keep searching, retry withcategoryCandidateIndex/modelSelectedCategoryCandidateIndex, use a visible category it can justify, adjust the publish input, or ask the user for an external business decision. SetmodelApprovedCategory=trueonly after the model has made that current-category decision; setcategoryUserConfirmed=trueonly when the model actually asked and the user answered in this conversation. - Default page evidence belongs to the model, not to scripts.
observeandexploreexpose a light model-facingpageViewmade of visible text lines plus bracket ids; fullmodelEvidencewith raw visible body text, raw DOM HTML, controls, rows, tables, dialogs, visible text elements, open shadow-root HTML/text, accessibility names, and visual evidence paths stays lossless inevidenceRef/sidecar when--out --evidence-sidecaror the desktop app runtime is used. It is markedredaction: none,truncation: none, andsemanticFiltering: none; do not hide evidence from Flash, but do not keep large registry/coordinate/control tables in the main context. - Use
pageViewas the primary DOM action view. Plain text is normal page text; bracket ids such as[a] 批量下架mark the exact visible element the model can operate. To click it, runsession act --target-id aor action JSON{ "kind": "click", "target": { "shortId": "a" } }. The tool maps the short id to the live DOM and clicks internally; viewport x/y,actionRegistry, coordinates, and controls are not part of the model-facing default protocol. Ids are shortest-first: one character while possible, then two, then three. - Read
pageView.scrollStatebefore deciding a target is absent.hasMoreBelow/hasMoreAbove/ document height / visible range are mechanical page facts; if the goal might be below, above, or lazy-loaded, the model should run a model-chosenscroll, observe again, then interpret the new evidence. - Evidence IDs are mechanical selectors, not business decisions.
shortId/actionId/idvalues likeaora0come from currentpageView; unchanged clickable elements keep their short ids within the same persistent browser session when their mechanical fingerprint is stable. If an action returnsACTION_ID_NOT_FOUND_NEED_OBSERVEorACTION_ID_AMBIGUOUS_NEED_OBSERVE, observe/explore again and choose a current bracket id. LegacycoordinateIdremains a fallback for visual/canvas diagnostics only. - Treat large browser evidence as temporary memory. Keep the latest necessary observation and pageChange in active reasoning; drop or summarize stale screenshot/DOM/network handles after comparing them. If an app runner controls the model context, it should inject only active evidence, summaries for dropped/summarized handles, and recoverable handle indexes. If the SDK cannot prune old messages, keep using handle-first commands so large details do not enter the history by default.
- For CLI adapters, always store at least one model-defined business verification rule when the response body has a success/error code or expected result shape. A status rule such as
{type:"status",status:200}proves only transport success; pair it withjsonPathEquals,bodyIncludes, or another explicit rule sobrowser.adapter-runcan surface business failures without deciding the user goal. - Use
browser.scriptonly after the normal observe/inspect/act path is insufficient, unless the user explicitly asks for harness-like direct testing. Start withmode=readto extract DOM evidence; usemode=actwithmodelApprovedScript=truefor controlled operations; usemode=rawfor authorized harness-like direct page JS/fetch. Always review post-scriptpageChangebefore declaring success. - In Windows Bash, do not use cmd-style
%USERPROFILE%or%APPDATA%paths for artifacts; use$PWD,$HOME,$APPDATA, or the injected absolute workspace/material paths. - Always inspect the current page before acting. For real task flows, start with
scripts/pdd-operator.mjs session observe-lightand usesession inspect-region/session inspect-point/session zoom-cropfor targeted progressive disclosure. Escalate to fullsession observeorsession exploreonly when light pageView and targeted evidence are insufficient. Usesession actso the browser window, page state, focus, and transient confirmation UI stay alive across CLI calls. Use plainobserve/actonly for short diagnostics, dry isolated tests, or when intentionally closing the browser after the command. - Fast-path state-changing flow:
session observe-light -> model chooses current short ids/regions -> session act sequence when trigger and confirmation can share one live page -> read pageChange.afterSnapshot.pageView -> targeted inspect/zoom only if uncertain -> one terminal business verification. Do not run heavy scans after every small click unless pageChange is ambiguous or the final business state must be proven. - Treat operation as
observe/explore -> one action -> read pageChange -> interpret -> next action.actand recipe action steps returnpageChange, a generic structural diff across URL, dialogs, controls, visible text, rows, page regions, counters/status text,feedbackSignals,fieldSignals, focus, and scroll. A short-id click uses the previous snapshot as the before baseline instead of re-observing before the click, then captures a freshafterSnapshot.pageViewafter the click.pageChange.beforeModelEvidenceandpageChange.afterSnapshot.modelEvidenceare the full before/after evidence for the model, including screenshot/canvas visual evidence when enabled by the CLI; use them instead of relying on script summaries. After comparing, treat old pageView blocks as stale and keep only the latest pageView plus evidence refs in active reasoning unless you intentionally reread a sidecar.actionSignalsandscriptBlockingCandidatesare hints only, not final decisions. - Transient confirmation UI must stay in the same live browser session. Prefer one
session actsequencewhen the model can choose the trigger and confirmation together. If the firstsession actalready opened a modal/popover/confirm box, read that action'spageChange.afterSnapshot.pageViewand click the model-selected fresh confirmation short id because the persistent session keeps the same page alive. Do not use a second plain standaloneactcommand for transient UI; plainactcloses the browser context after the command and can lose the dialog. - Do not narrow feedback detection to red validation text, toast messages, or known upload counters. Any visible structural change can be the feedback: new text, removed text, disabled/enabled controls, a dialog/drawer/popover, a tab/route change, row changes, counter changes,
feedbackSignals,fieldSignals, focus/scroll changes, or a changed page region. IfpageChangeis empty or ambiguous, runobserveorexploreagain before continuing. - When
explorereturnsopenIssues, treat eachsuggestedActionasscript-candidateevidence only. The model must choose the repair path from full evidence before changing strategy: upload missing media, fill required text fields with model/user-approved values, usechoosefor custom dropdowns/comboboxes with exact visible options, or click the page's own "去处理" control. After each repair, observe the returnedpageChangebefore the next action. - If visible empty fields are already reported by
openIssues/fieldSignals,repairOpenIssuesfirst returns repair candidates for model review. Re-run it withmodelApprovedRepair=trueonly after the model has decided that generic repair is appropriate and supplied exactrepairLabels/modelApprovedRepairLabelsorvalueskeys for the fields to repair; scripts must not choose repair targets, even when there is only one candidate, and must not choose dropdown options or business values by themselves. - Prefer current evidence over stale memory. Role/name/label/placeholder/text selectors remain useful, but for visible DOM controls prefer current
pageViewbracket ids because they avoid ambiguity without exposing coordinates. Use legacycoordinateClick/clickAtonly when the target is genuinely visual/canvas/hotspot and no DOM short id exists. Scripts execute only the model-supplied id or coordinates and must not infer the target meaning. - If the model only needs to reveal lower page content, use a scroll action such as
session act --account default --action scroll --out scroll.jsonor{kind:"scroll",deltaY:800}. Do not click arbitrary bracket ids as a substitute for scrolling. - For forms,
pageViewmay expose fields as[id] <label> value=<current> placeholder=<hint>. Choose fill targets by the explicit label and current value, not by generic placeholders such as请输入. If several fields share the same placeholder, use their labels, row text, or targeted inspect evidence before filling. - If
LOCATOR_MODEL_REVIEW_REQUIREDis returned, inspect returned samples and currentpageView/modelEvidence; retry with a unique current short id, row scope, css/xpath+index, or explicit model-selected index. Do not repeat the same ambiguous text/label/placeholder selector. - For text entry after a model-selected focus/click,
typeorfillmay use the currently focused editable element when no target is supplied, or when duplicate matching placeholders/labels prevent a unique locator but the focused element matches the model-supplied target constraints. Focus is only reliable inside the same live CLI action/sequence; across separate CLI commands, includetarget.shortId,target.actionId,target.id, or another exact current selector. Put the intended text invalue;text,input, andcontentare accepted as mechanical aliases for brittle model outputs. If the model supplies exact coordinates ontype/fillas a visual fallback, the tool mechanically clicks that point and then types/fills the editable focused by that click in the same live action. This is a coordinate/focus-preserving fallback, not permission for scripts to pick among candidates. - Upload targets must be model-scoped. If multiple file inputs match the same section and accept type,
uploadreturnsUPLOAD_INPUT_MODEL_REVIEW_REQUIRED; inspect full evidence and retry withtarget.indexor a more specific section/target. If a filechooser route exposes multiple matching upload buttons, it returnsUPLOAD_BUTTON_MODEL_REVIEW_REQUIRED; retry withfileChooserButtonIndex/uploadButtonIndexor a more specific section/target. Scripts must not rank-pick a matching upload input or button. - Do not pipe JSON command output through
head,grep, or other truncating filters when deciding state. Use--out <file>, then read the saved JSON fields such asok,code,message,goodsId,foundState,failedStep,results, andpageChange. - Do not
Readvery large result JSON files wholesale. Use a JSON parser ornode -eto extract the specific non-semantic evidence fields you need, such asok,code,message,failedStep,availableCategorySamples,suggestedRetry, andmodelEvidence. Extraction may reduce transport size, but it must not make the business decision for the model. - For product state changes, work from the user's goal first. Recipe aliases and saved experience are accelerators, not rails. Inspect the current page and prefer any semantically correct page-native control whose scope matches the requested records; verify the final state. Use first-class single-record aliases such as
product.scan-state,product.down-shelf,product.delete-downshelved,product.delete-draft,product.delete-rejected, andproduct.resubmit-draftas fallbacks or when the target is one record. If an alias or page-native action fails after a possible state-changing click, scan the affected goods IDs or list state before retrying. - Do not stop on ordinary recoverable failures. If login/risk verification is not blocking and the user's intent is clear, diagnose, retry with a safer semantic path, scan final state, and continue until the task is done or a real stop condition below is reached.
- Treat PDD login, SMS, CAPTCHA, face verification, and other risk controls as handoff points. Do not bypass them.
- State-changing actions need explicit authorization, but the user's current request counts as that authorization when it clearly names the target and action. Do not ask for a second confirmation in that case; pass the required
--confirm <token>and complete the task. Ask only when the target, action, scope, or buyer/store impact is ambiguous. - Keep each store account in a separate browser profile. Do not copy cookies or tokens between accounts.
- Prefer
--account <alias>over raw--profilein productized flows. Every command that opens or operates PDD pages (login-check,observe,explore,act, recipes, and product/customer tools) should explicitly include the intended--account <alias>.--account shop-amaps to~/.pdd-operator/profiles/shop-aby default. - In app/productized flows, respect
PDD_OPERATOR_HEADLESS=1and stay silent/headless unless the user explicitly asks to see the browser or PDD requires login/risk verification. - Never run two concurrent jobs with the same
--accountor--profile; the runtime uses an application-level profile lease plus Chromium's own lock as a second guard. Use a distinct account alias for each parallel store. - Write artifacts under
artifacts/or a caller-provided output directory. Never log cookies, tokens, SMS codes, passwords, buyer personal data, or payment data.
Quick Start
From the skill directory in standalone mode:
bashnpm run setup node scripts/pdd-operator.mjs accounts init --account shop-a node scripts/pdd-operator.mjs accounts status --account shop-a node scripts/pdd-operator.mjs login-check --account shop-a --wait node scripts/pdd-operator.mjs session start --account shop-a node scripts/pdd-operator.mjs session observe-light --account shop-a --url https://mms.pinduoduo.com/goods/goods_list node scripts/pdd-operator.mjs session menus --account shop-a node scripts/pdd-operator.mjs session stop --account shop-a
When running from another desktop agent with a workspace outside this skill directory,
avoid cd ... && ... command chains. In productized PDD Agent app mode, prefer
pdd-operator so the bundled runtime works on machines without Node.js. In
Windows Bash, use pdd-operator first, then "$PDD_OPERATOR_POSIX_CLI" if the
PATH command is unavailable; reserve "$PDD_OPERATOR_CLI" for PowerShell/cmd.
Do not paste literal C:\...\pdd-operator.cmd or C:\...\PDD Agent.exe paths;
the POSIX shim handles path conversion. In standalone mode, prefer npm --prefix "$PDD_OPERATOR_HOME" or
the absolute script path supplied by the calling app so permission allowlists can
match stable command prefixes without hard-coding a machine-specific path:
bashPDD_OPERATOR_HOME="/absolute/path/to/pdd-merchant-operator" pdd-operator menus --account shop-a "$PDD_OPERATOR_POSIX_CLI" menus --account shop-a npm --prefix "$PDD_OPERATOR_HOME" run doctor npm --prefix "$PDD_OPERATOR_HOME" run setup node "$PDD_OPERATOR_HOME/scripts/pdd-operator.mjs" menus --account shop-a
If Reasonix also has a global copy under ~/.reasonix/skills/pdd-merchant-operator,
make sure it is synchronized with this source-of-truth directory or configured as a
thin pointer to it; stale global copies are a common cause of missing recipes.
When validating with Reasonix, require a transcript that contains real tool_start
and tool entries with command output. Plain reasonix run without tool execution
can emit command-looking text that was not actually run; do not treat that as proof.
For a known workflow, run a recipe:
bashnode scripts/pdd-operator.mjs run-recipe \ --account shop-a \ --recipe recipes/product.create-basic.recipe.json \ --input /absolute/path/product.json
Add --confirm publish when the user's current request explicitly asks to publish/list the item.
Use --dry-run to validate recipe structure, input, and confirmation gates without
opening the browser or changing store state.
Common recipe aliases are also exposed as first-class CLI commands so external
agents can use intuitive names without remembering run-recipe paths:
bashnode scripts/pdd-operator.mjs product.scan-state --account shop-a --goodsId 123 --soft-fail node scripts/pdd-operator.mjs product.resubmit-draft --account shop-a --goodsId 123 --confirm publish node scripts/pdd-operator.mjs product.publish-material --account shop-a --input /absolute/path/product.json --confirm publish node scripts/pdd-operator.mjs product.delete-draft --account shop-a --goodsId 123 --confirm deleteDraft node scripts/pdd-operator.mjs product.delete-rejected --account shop-a --goodsId 123 --confirm deleteDraft node scripts/pdd-operator.mjs customer-service.reply --account shop-a --conversationText "买家原话" --message "回复内容" --confirm sendMessage
Workflow
- Check login with
login-check. If login is required, open the headed browser and ask the user to finish login. - Read
guides/index.md, then load only the one module guide matching the requested operation. - Observe the page with
observeormenus; read the returned JSON, not the screenshot, when deciding next action. - Use an existing recipe if available. For new features, use
actsteps against observed component IDs or semantic targets, then interpret the returnedpageChangebefore the next action. - For record pages, scope actions to a stable row identifier such as
goodsId,orderId,aftersaleId, or visible conversation text usingtarget.rowTextbefore clicking row actions. - If a component cannot be found structurally, use visual/manual assistance once with
record-trace, then normalize the raw trace into a recipe. - Verify the final state with a recipe assertion/extract step. For product publishing, first interpret the submit action's
pageChangeon the current page, then verify the product list state (在售中,发布中,已驳回) rather than trusting the success page. - After a previously unknown path succeeds, update the matching guide and add a recipe so future runs can load it progressively instead of rediscovering it.
Autonomy And Learning Contract
When a recipe fails, a selector is missing, or a page differs from the guide, the agent must keep working without asking the user to say "continue" again. Follow references/failure-recovery.md, then guides/path-capture.md: observe/explore, try one low-risk semantic action, observe again, and loop until the path is proven or a real stop condition is reached. Preserve any created record IDs for resume or cleanup.
Stop and ask the user only for: login/SMS/CAPTCHA/face/risk verification, genuinely ambiguous target/action/scope, missing business facts that cannot be inferred safely such as real price or stock, legal/qualification decisions, or an operation whose buyer/store impact is unclear. Do not treat selector drift, hidden file inputs, failed first scans, slow page loads, or unreadable widgets as user blockers. For authorized MVP/test operations, use the required --confirm token and proceed.
Whenever a new workaround or route succeeds, save the reusable notes or draft recipe under artifacts/candidates/, promote stable steps to recipes/ when replayed, and update exactly one relevant guide under guides/. A successful one-off fix that is not written back into the skill is incomplete.
Progressive Guides
Start with guides/index.md. It maps business modules to focused guides:
guides/product-management.mdguides/shipping-management.mdguides/aftersales-management.mdguides/customer-service.mdguides/shop-management.mdguides/marketing-promotion.mdguides/data-center.mdguides/finance-risk.mdguides/auxiliary-modules.mdguides/account-session.mdguides/navigation-and-coverage.mdguides/path-capture.mdguides/product-material-package.md
Keep SKILL.md as the thin entrypoint. Put durable selectors, routes, blockers, and proven recipes in the relevant guide. Do not bulk-load every guide for a single task.
Account Switching and Parallel Work
Login state is stored locally in the browser profile directory for each account alias:
text~/.pdd-operator/profiles/<account-alias>
This profile directory contains browser cookies/localStorage/session state and is not
part of the skill. Keep it outside the skill so the skill can be copied safely without
copying credentials. Set PDD_OPERATOR_PROFILE_ROOT=/some/path to choose another
portable per-machine location.
Use separate aliases for separate stores:
bashnode scripts/pdd-operator.mjs accounts init --account store-a node scripts/pdd-operator.mjs accounts init --account store-b node scripts/pdd-operator.mjs login-check --account store-a --wait node scripts/pdd-operator.mjs login-check --account store-b --wait
After both accounts are logged in, switching is just choosing the alias:
bashnode scripts/pdd-operator.mjs menus --account store-a node scripts/pdd-operator.mjs menus --account store-b
Parallel jobs are allowed only when each job uses a different alias/profile and separate artifact paths. The runtime does not copy cookies, tokens, or profile files between accounts.
accounts status --account <alias> shows the local profile path, operator lock state, last login-check result, and any visible store identity captured from the merchant page. This metadata is for operator safety only; it must not include cookies, tokens, passwords, SMS codes, buyer personal data, or payment data.
Core Commands
login-check: open the merchant backend and report whether the account is logged in.accounts: list, initialize, inspect status, or print the local profile path for account aliases.session: start/reuse/stop a persistent browser daemon and proxy page commands through it. Usesession observe-light, targetedsession inspect-*/session zoom-crop,session act,session run-recipe, and recipe aliases for real workflows so one browser page survives untilsession stop, task completion, or user stop. Use fullsession observe/session exploreonly when light evidence is insufficient. The proxy does not make business decisions; it only keeps the live page and executes the same model-selected commands.session navigate --url/session goto --urlare mechanical navigation aliases for model-selected URLs.observe: emit structured page JSON pluspageViewand fullmodelEvidence: raw visible body text, raw DOM HTML, controls, rows, tables, dialogs, visible text elements, open shadow-root HTML/text, screenshot/canvas visual evidence paths, and optional raw accessibility-tree nodes with no redaction, truncation, or semantic filtering. Use--wait-textor--settle-mswhen the main content loads after the shell.explore: emit a structured unknown-path exploration pack plus model-facingpageView, losslessmodelEvidence/evidenceRef, recordListAffordances, action templates, and a candidate recipe skeleton. It does not expose model-facingactionRegistry, coordinates, controls, or suggestedTargets; choose visible controls frompageViewids.recordListAffordances,goalActionHints, and batchactionTemplatesare evidence/templates only and require model review of row scope and toolbar semantics before acting. Use--wait-text <record id/text>on list pages so visible lines are captured after data loads. Only use explicit--limit,--row-limit, or--issue-limitfor human-requested small diagnostics.- If
observeorexplorelands on a login or verification page, the command returnsLOGIN_REQUIRED/CAPTCHA_REQUIREDand still includes the fullsnapshot.modelEvidenceor explorationmodelEvidence. Treat that as a page-state signal, not a business decision; ask the user to complete login in a visible browser before retrying the current goal. menus: discover visible sidebar/top navigation links and produce candidate feature IDs.act: run one semantic or coordinate action such as click, coordinateClick, clickAt, doubleClick, rightClick, check, focus, blur, clear, hover, press, scroll, drag, mouse, selectRows, sequence, fill, type, setValue, select, choose, repairOpenIssues, upload, waitFor, assert, openMenu, or goto. Prefer currentpageViewshort ids for DOM controls:session act --target-id aor{ "kind": "click", "target": { "shortId": "a" } }. UsecoordinateClick/clickAtonly when the model has chosen exact viewport x/y for a visual/canvas fallback; coordinate aliases onclicksuch astarget.position,target.center, ortarget.actionare accepted only as mechanical x/y normalization.session act --target <json>,--target-id <id>,--action-id <id>,--short-id <id>,--coordinate-id <id>, and action files shaped as{actions:[...]}are also mechanically normalized into the same model-selected click/coordinateClick/sequence protocol. UsesetValuewhen the model has chosen one exact target component and one exact value for native inputs, range/color/date/time fields, selects, multi-selects, contenteditable fields, or value-like custom elements; it sets only the supplied value and returns an error instead of inventing missing values or choosing fallback options. Nativeselectuses the same model-reviewed exact option semantics assetValue; duplicate exact options returnSET_VALUE_OPTION_AMBIGUOUSuntil the model suppliesoptionIndex,modelSelectedOptionIndex, oroptionCandidateNumber. Forchoose, if the same exact visible option appears more than once, the tool returnsCHOICE_OPTION_MODEL_REVIEW_REQUIRED; the model must retry withoptionTarget, zero-basedoptionIndex/modelSelectedOptionIndex, one-basedoptionCandidateNumber, or a more specific exact option. Usesequencewhen multiple page-native steps must share one live page state, such as select rows -> click toolbar action -> confirm. An action-file whose top-level JSON is an array is treated as that samesequenceshape. Real child action steps returnpageChangewith full before/aftermodelEvidence, including visual evidence paths by default in CLI mode, so the model can understand what changed after each action. Thesequencecontainer itself does not duplicate a full extra pageChange unlesstraceChange:trueis set on the sequence. In a sequence, later child steps may usebeforeModelEvidenceRefpointing to the previous childafterSnapshot.modelEvidence; this is a lossless in-result reference, not truncation or filtering.- For long real flows, pass
--evidence-sidecartogether with--out. In the desktop App,PDD_OPERATOR_AUTO_EVIDENCE_SIDECAR=1enables the same lossless sidecar behavior automatically for--outresults. LargemodelEvidenceblocks are then written as complete JSON files beside the result and replaced byevidenceRefobjects containing path, SHA256, byte count, and source pointer. This is a lossless storage optimization only; before making semantic or business decisions, read the referenced evidence file and use itsmodelEvidence. evidence.read: read and verify a complete modelEvidence sidecar without opening a browser. Useevidence.read --path <evidenceRef.path> --sha256 <evidenceRef.sha256>when the next decision depends on the full page evidence. You can also resolve from the main result withevidence.read --result <result.json> --source-pointer <evidenceRef.sourcePointer>. Use--metadata-onlyonly for integrity checks; semantic decisions require the full returnedmodelEvidence.- Ambiguous targets such as repeated
text: "删除",role: "button", name: "删除", broadcss, or broadxpathreturnLOCATOR_MODEL_REVIEW_REQUIREDinstead of clicking the first match. IfrowText/withinTextitself matches multiple rows, the command returnsROW_SCOPE_MODEL_REVIEW_REQUIRED. Inspect fullmodelEvidenceand retry with uniquerowText,withinText,id,css,xpath, model-selectedindex, or model-selectedrowIndex. run-recipe: execute a JSON recipe with templated input. Each action-like step includespageChange; inspect failed and post-submit step changes before routing recovery.run-recipe --dry-run: validate a recipe/input and print planned steps without opening the browser.- Product material publishing:
product.publish-materialuses only the current input JSON as authoritative data; it does not read siblingrecipe-input.json,draft-input.json, orcreate-input.jsonfiles to fill missing fields. It defaults to the create-basic flow for normal material folders, treatssourceGoodsIdas a template route only when explicitly requested bypublishStrategy/useSourceGoodsId, searches/selects the model-approved leaf category instead of broad recent categories, returnsCATEGORY_SELECTION_UNRESOLVEDwith visible alternatives and attempts when the leaf is unavailable, uploads section-scoped main/detail media, keeps loosespecImages/skuImagesas raw material evidence unless the model maps them to SKU rows or explicitly approves detail-image merge, verifies submit feedback, scans the final list state, records successful category/upload/repair experience under the operator experience store, and offers same-leaf experience evidence on laterproduct.publish-materialruns without letting it decide the current category. It usesproduct.publish-similaronly as an optional template route. - Recipe commands:
product.scan-state,product.publish-similar,product.resubmit-draft,product.down-shelf,product.delete-draft,product.delete-rejected,product.delete-downshelved, andcustomer-service.replydispatch to matching single-record recipes and accept either--input <json>or direct flags such as--goodsId. For multi-record goals, discover and execute page-native batch controls throughobserve/explore/actinstead of relying on a synthetic all-items shortcut. record-trace: let a human or visual agent operate once while the runtime records semantic click/fill events.normalize-trace: convert a raw trace into reusable semantic recipe steps.diagnose: capture URL, DOM summary, accessibility snapshot, screenshot, and recent console errors for debugging.
Unknown Path Protocol
When no recipe exists, a recipe is narrower than the user's goal, or the page exposes a better matching control, do not guess from memory and do not stop at the first failure. Start with session observe-light, read the compact pageView first, and use session inspect-region / session inspect-point / session zoom-crop when the model needs more detail. Escalate to session explore --goal "<operation>" only when the light view and targeted inspections are insufficient. Execute one low-risk session act step or a model-approved sequence using the selected current short id/selector, interpret its pageChange, and keep looping in that same persistent session until the path is proven or a stop condition is reached. Scripts are eyes and hands only: they may collect DOM/accessibility/action evidence, but the model decides what the page means, which controls match the user's intent, and whether a candidate is real data or just a label such as 30日销量. Prefer page-native bulk controls for multi-record goals when their text and selected scope match the request; otherwise use single-record recipe aliases in a serialized fallback. If pageChange is empty, too broad, ambiguous, or returns ACTION_ID_NOT_FOUND_NEED_OBSERVE, run session observe-light first and only escalate to full session observe/session explore if needed. If structural data is insufficient, use visual/manual trace as a learning tool for selectors, not as a reason to wait for user permission. Use rowText for record actions and assertValue after critical fills. For product flows, reserve product.scan-state or a scanProductState step for precondition checks that affect the route, possible state-changing failures, or terminal verification instead of running it after every small click. If product.publish-similar returns PRODUCT_STATE_MISMATCH with foundState: "草稿箱" and row text 编辑中, use product.resubmit-draft --goodsId <id> --confirm publish instead of rerunning publish from the source product. For product deletions, trust only the post-delete scanProductState "absent": true result; raw notText can pass while a table is still loading. If a write recipe fails after creating a record, inspect returned vars such as goodsId, run login-check --wait if needed, then resume with a scan/cleanup recipe instead of restarting. When the path succeeds, save a candidate recipe under artifacts/candidates/, replay it, then promote it to recipes/ and update the module guide.
References
- Read
references/architecture.mdbefore changing the runtime design. - Read
guides/index.mdbefore choosing module-specific instructions. - Read
references/coverage-plan.mdbefore expanding module coverage. - Read
references/recipe-authoring.mdbefore adding or editing recipes. - Read
references/trace-format.mdwhen converting visual/manual operations into reusable steps. - Read
references/failure-recovery.mdwhen handling login expiry, CAPTCHA, page changes, or missing selectors.


