Add amazon/order-history domain skill - #534
Conversation
Field-tested pattern for extracting full order history from a logged-in Amazon session: timeFilter/startIndex URL scheme, .order-card extraction JS, and the traps (2024+ React layout returns no .order-card nodes, late hydration, buffered-stdout loss on long scrapes). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
Addresses the review findings, plus a path bug the review did not catch: the file was added at a new top-level domain-skills/, so the harness (which reads $BH_AGENT_WORKSPACE/domain-skills/<host>/) would never have loaded it. It now sits beside amazon/product-search.md. - new_tab() for the first visit, goto_url() after, matching product-search.md (goto() was a local alias and would have raised NameError) - json.loads() around the JSON.stringify payload so the result is a list - date regex accepts "31 December 2024" and "December 31, 2024", so the documented .com support no longer yields empty dates - replace the stop-on-a-short-page rule with .num-orders as an expected count, .a-pagination .a-last for the real end, and an assertion that fails loudly on a short scrape Also corrects the 2024+ "React layout" claim: re-testing on 2026-07-29 found year-2010 through year-2026 all extract with .order-card, so the earlier zero-card reading was a misdiagnosis, not a layout change. The count assertion is what actually guards against it. Verified end-to-end on year-2026: 57 expected, 6 pages, 57 collected, all dated. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="agent-workspace/domain-skills/amazon/order-history.md">
<violation number="1" location="agent-workspace/domain-skills/amazon/order-history.md:50">
P1: A missing `.num-orders` element is currently treated as a legitimate zero-order year: `count_text or "0"` makes the later `len(collected) != expected` check pass for an empty scrape. That defeats the self-verification and can silently produce a trusted but empty result when Amazon has not rendered the page or changes the selector. Missing/invalid count text could instead fail explicitly (while handling an explicit “no orders” response as zero).</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| ```python | ||
| import re | ||
| count_text = js("document.querySelector('.num-orders')?.innerText") # '186 orders' / '1 order' | ||
| expected = int(re.sub(r"[^\d]", "", count_text or "0") or 0) |
There was a problem hiding this comment.
P1: A missing .num-orders element is currently treated as a legitimate zero-order year: count_text or "0" makes the later len(collected) != expected check pass for an empty scrape. That defeats the self-verification and can silently produce a trusted but empty result when Amazon has not rendered the page or changes the selector. Missing/invalid count text could instead fail explicitly (while handling an explicit “no orders” response as zero).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At agent-workspace/domain-skills/amazon/order-history.md, line 50:
<comment>A missing `.num-orders` element is currently treated as a legitimate zero-order year: `count_text or "0"` makes the later `len(collected) != expected` check pass for an empty scrape. That defeats the self-verification and can silently produce a trusted but empty result when Amazon has not rendered the page or changes the selector. Missing/invalid count text could instead fail explicitly (while handling an explicit “no orders” response as zero).</comment>
<file context>
@@ -0,0 +1,111 @@
+```python
+import re
+count_text = js("document.querySelector('.num-orders')?.innerText") # '186 orders' / '1 order'
+expected = int(re.sub(r"[^\d]", "", count_text or "0") or 0)
+```
+
</file context>
Adds a domain skill for extracting full order history from a logged-in Amazon session, field-tested against amazon.co.uk (2026-07-16) on a 2010-2026 account (1,007 orders).
Covers:
timeFilter=year-YYYY+startIndexURL scheme, reading valid filter values from the#time-filterdropdown.order-cardextraction JS for titles + order dates.order-cardnodes (empty results are not "no orders"), late hydration needs a ~2s settle, and long multi-year scrapes should checkpoint to disk with flushed prints🤖 Generated with Claude Code
Summary by cubic
Adds
agent-workspace/domain-skills/amazon/order-history.md, a domain skill for extracting full Amazon order history from a logged-in session. Field-tested on amazon.co.uk (2010–2026, 1,007 orders) and amazon.com; runs now self-verify per-year counts.New Features
/ap/signin; one-time headed login reused.new_tab()for the first visit, thengoto_url(); read#time-filtervalues; paginate withstartIndex=0,10,.....num-orders, use.a-pagination .a-lastfor the real end, assert collected vs expected..order-cardparsing for titles and order dates;json.loadsaroundJSON.stringify; date regex supports UK and US formats.Bug Fixes
agent-workspace/domain-skills/amazon/so the harness loads it..order-card” note after re-testing; the count assertion guards against under-rendering.Written for commit 734a31f. Summary will update on new commits.