@yasaswy.nagavolu/agents 0.37.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/content/mcps/chrome_devtools_final_actions.json +2 -2
  2. package/content/skills/code-is-law/lint_skill.py +19 -0
  3. package/content/skills/disk-cleanup/SKILL.md +1 -1
  4. package/content/skills/gmail-reader/SKILL.md +1 -0
  5. package/content/skills/gmail-reader/gmail_reader/purchases/__init__.py +2 -2
  6. package/content/skills/gmail-reader/gmail_reader/purchases/parse.py +29 -6
  7. package/content/skills/gmail-reader/gmail_reader/version.py +1 -1
  8. package/content/skills/gmail-reader/tests/test_amazon_recommendations.py +86 -0
  9. package/content/skills/gmail-reader/tests/test_durable.py +1 -1
  10. package/content/skills/low-ram-advisor/SKILL.md +1 -1
  11. package/content/skills/publish-article/SKILL.md +1 -1
  12. package/content/skills/resale/CONTRACTS.md +17 -3
  13. package/content/skills/resale/README.md +72 -8
  14. package/content/skills/resale/SKILL.md +8 -4
  15. package/content/skills/resale/resale/analysis/bundle.py +31 -9
  16. package/content/skills/resale/resale/analysis/gather.py +6 -3
  17. package/content/skills/resale/resale/analysis/package_terms.py +61 -0
  18. package/content/skills/resale/resale/analysis/runner.py +1 -1
  19. package/content/skills/resale/resale/analysis/stats.py +11 -5
  20. package/content/skills/resale/resale/comps/depreciation.json +20 -1
  21. package/content/skills/resale/resale/comps/depreciation.py +8 -1
  22. package/content/skills/resale/resale/comps/estimate.py +119 -0
  23. package/content/skills/resale/resale/comps/market_value.py +15 -14
  24. package/content/skills/resale/resale/comps/trusted_retailers.json +19 -0
  25. package/content/skills/resale/resale/contracts/__init__.py +11 -1
  26. package/content/skills/resale/resale/contracts/fbgroup_batch.schema.json +67 -0
  27. package/content/skills/resale/resale/contracts/fbgroup_targets.schema.json +44 -0
  28. package/content/skills/resale/resale/db/migrations/0029_fb_groups.sql +37 -0
  29. package/content/skills/resale/resale/db/migrations/0030_estimate_basis.sql +14 -0
  30. package/content/skills/resale/resale/inventory/paid.py +3 -2
  31. package/content/skills/resale/resale/inventory/private_sale.py +37 -0
  32. package/content/skills/resale/resale/portal/bundles.py +22 -11
  33. package/content/skills/resale/resale/portal/layout.py +73 -24
  34. package/content/skills/resale/resale/portal/market_cells.py +3 -3
  35. package/content/skills/resale/resale/portal/panel.py +14 -3
  36. package/content/skills/resale/resale/portal/pieces.py +96 -0
  37. package/content/skills/resale/resale/portal/posted.py +73 -0
  38. package/content/skills/resale/resale/portal/views_analysis.py +23 -3
  39. package/content/skills/resale/resale/portal/views_items.py +24 -15
  40. package/content/skills/resale/resale/portal/views_postkit.py +20 -6
  41. package/content/skills/resale/resale/poster/adapters.py +41 -2
  42. package/content/skills/resale/resale/poster/commands.py +33 -8
  43. package/content/skills/resale/resale/poster/confirm_step.py +76 -0
  44. package/content/skills/resale/resale/poster/driver.py +27 -2
  45. package/content/skills/resale/resale/poster/edit_verify.py +95 -0
  46. package/content/skills/resale/resale/poster/own_tabs.py +50 -0
  47. package/content/skills/resale/resale/poster/preflight.py +5 -0
  48. package/content/skills/resale/resale/poster/review_window.py +2 -0
  49. package/content/skills/resale/resale/poster/runner.py +59 -19
  50. package/content/skills/resale/resale/poster/tabs.py +9 -1
  51. package/content/skills/resale/resale/postkit/fill.py +11 -0
  52. package/content/skills/resale/resale/postkit/groups.py +9 -6
  53. package/content/skills/resale/resale/postkit/post_edit.py +65 -0
  54. package/content/skills/resale/resale/postkit/pricing.py +5 -1
  55. package/content/skills/resale/resale/postkit/text.py +39 -0
  56. package/content/skills/resale/resale/receipts/amazon_history.py +1 -1
  57. package/content/skills/resale/resale/receipts/charges.py +8 -4
  58. package/content/skills/resale/resale/receipts/commands.py +3 -2
  59. package/content/skills/resale/resale/receipts/intake.py +2 -0
  60. package/content/skills/resale/resale/receipts/store.py +42 -8
  61. package/content/skills/resale/resale/service/commands.py +30 -3
  62. package/content/skills/resale/resale/service/comps_review.py +2 -1
  63. package/content/skills/resale/resale/service/comps_service.py +8 -2
  64. package/content/skills/resale/resale/service/fb_groups.py +157 -0
  65. package/content/skills/resale/resale/service/inventory_ops.py +8 -3
  66. package/content/skills/resale/resale/service/market.py +35 -11
  67. package/content/skills/resale/resale/service/new_price_plan.py +81 -0
  68. package/content/skills/resale/resale/service/package_terms_plan.py +31 -0
  69. package/content/skills/resale/resale/service/server.py +56 -5
  70. package/content/skills/resale/resale/service/store.py +1 -0
  71. package/content/skills/resale/resale/sources/__init__.py +8 -0
  72. package/content/skills/resale/resale/sources/client.py +31 -0
  73. package/content/skills/resale/resale/sources/commands.py +2 -1
  74. package/content/skills/resale/resale/sources/fbgroup_commands.py +94 -0
  75. package/content/skills/resale/resale/sources/fbgroup_parse.py +449 -0
  76. package/content/skills/resale/resale/sources/fbgroup_reader.py +346 -0
  77. package/content/skills/resale/tasks/reader_task.py +8 -0
  78. package/content/skills/resale/tests/fixtures/reader/fbgroup_joins.html +7 -0
  79. package/content/skills/resale/tests/fixtures/reader/fbgroup_post.html +6 -0
  80. package/content/skills/resale/tests/fixtures/reader/fbgroup_post_page.html +7 -0
  81. package/content/skills/resale/tests/fixtures/reader/fbgroup_private.html +3 -0
  82. package/content/skills/resale/tests/fixtures/reader/fbgroup_search.html +29 -0
  83. package/content/skills/resale/tests/fixtures/reader/fbgroup_story_search.html +5 -0
  84. package/content/skills/resale/tests/test_bundle_full_list.py +85 -0
  85. package/content/skills/resale/tests/test_condition_refresh.py +14 -0
  86. package/content/skills/resale/tests/test_fbgroup_parse.py +157 -0
  87. package/content/skills/resale/tests/test_fbgroup_reader.py +202 -0
  88. package/content/skills/resale/tests/test_fbgroups_service.py +191 -0
  89. package/content/skills/resale/tests/test_market_service.py +1 -1
  90. package/content/skills/resale/tests/test_market_value.py +1 -1
  91. package/content/skills/resale/tests/test_portal_bundle_fold.py +1 -1
  92. package/content/skills/resale/tests/test_portal_bundle_pieces_browser.py +121 -0
  93. package/content/skills/resale/tests/test_portal_bundles.py +1 -1
  94. package/content/skills/resale/tests/test_portal_collapse_browser.py +180 -0
  95. package/content/skills/resale/tests/test_portal_market.py +1 -1
  96. package/content/skills/resale/tests/test_portal_posted_pill.py +164 -0
  97. package/content/skills/resale/tests/test_portal_split.py +7 -5
  98. package/content/skills/resale/tests/test_portal_text_audit.py +77 -0
  99. package/content/skills/resale/tests/test_poster.py +160 -9
  100. package/content/skills/resale/tests/test_poster_confirm_step.py +176 -0
  101. package/content/skills/resale/tests/test_poster_contract.py +262 -0
  102. package/content/skills/resale/tests/test_poster_own_tabs.py +348 -0
  103. package/content/skills/resale/tests/test_postkit.py +1 -1
  104. package/content/skills/resale/tests/test_postkit_fill.py +31 -0
  105. package/content/skills/resale/tests/test_postkit_post_edit.py +147 -0
  106. package/content/skills/resale/tests/test_pricing_estimate.py +319 -0
  107. package/content/skills/resale/tests/test_private_sale_tax.py +124 -0
  108. package/content/skills/resale/tests/test_receipts_intake.py +2 -2
  109. package/content/skills/resale/tests/test_receipts_recommendations.py +117 -0
  110. package/content/skills/ship-the-code/ship.py +39 -0
  111. package/content/skills/ship-the-code/tests/test_ship_poster_contract.py +79 -0
  112. package/package.json +1 -1
@@ -24,10 +24,10 @@
24
24
  ]
25
25
  },
26
26
  "sites": [
27
- { "host": "(^|\\.)facebook\\.com$", "exact": ["publish", "post"], "nextIsFinal": false },
27
+ { "host": "(^|\\.)facebook\\.com$", "exact": ["publish", "post", "update"], "nextIsFinal": false },
28
28
  { "host": "(^|\\.)offerup\\.com$", "exact": ["post", "post item", "list item"], "nextIsFinal": false },
29
29
  { "host": "(^|\\.)craigslist\\.org$", "exact": ["publish", "done"], "nextIsFinal": false },
30
- { "host": "(^|\\.)astromart\\.com$", "exact": ["submit", "place ad", "post ad", "post"], "nextIsFinal": false },
30
+ { "host": "(^|\\.)astromart\\.com$", "exact": ["submit", "place ad", "place classified", "post ad", "post"], "nextIsFinal": false },
31
31
  { "host": "(^|\\.)ebay\\.com$", "exact": ["list it", "list item", "list", "submit", "relist"], "nextIsFinal": false },
32
32
  { "host": "(^|\\.)cloudynights\\.com$", "exact": ["submit", "post", "post topic", "submit reply"], "nextIsFinal": false },
33
33
  { "host": "(^|\\.)nextdoor\\.com$", "exact": ["post", "publish"], "nextIsFinal": false }
@@ -39,6 +39,24 @@ def _frontmatter(text: str) -> str | None:
39
39
  return m.group(1) if m else None
40
40
 
41
41
 
42
+ PLAIN_KEY_RE = re.compile(r"^(?P<key>[A-Za-z_][\w-]*):[ \t]+(?P<val>\S.*)$")
43
+
44
+
45
+ def _check_yaml_scalars(frontmatter: str) -> list[tuple[str, str]]:
46
+ """A plain (unquoted) top-level value holding ': ' is invalid YAML (the loader drops the real description); ' #' silently cuts the value at a comment."""
47
+ out = []
48
+ for ln in frontmatter.splitlines():
49
+ m = PLAIN_KEY_RE.match(ln)
50
+ if not m or m.group("val")[0] in "'\"|>[{&*!%@`":
51
+ continue
52
+ key, val = m.group("key"), m.group("val")
53
+ if ": " in val:
54
+ out.append(("E", f"frontmatter '{key}:' is an unquoted value containing ': ' (invalid YAML, the loader drops it) - quote it, e.g. {key}: '...'"))
55
+ if " #" in val:
56
+ out.append(("E", f"frontmatter '{key}:' is an unquoted value containing ' #' (YAML cuts the value at the comment) - quote it, e.g. {key}: '...'"))
57
+ return out
58
+
59
+
42
60
  def _generated_map(frontmatter: str):
43
61
  """None = no 'generated:' key (fine, no markers expected). {} on
44
62
  malformed JSON, so callers can tell 'declared but broken' apart."""
@@ -124,6 +142,7 @@ def lint(path: Path) -> list[tuple[str, str]]:
124
142
  out.append(("E", "frontmatter missing 'name:'"))
125
143
  if not re.search(r"^\s*description:\s*\S", frontmatter, re.MULTILINE):
126
144
  out.append(("E", "frontmatter missing 'description:'"))
145
+ out.extend(_check_yaml_scalars(frontmatter))
127
146
  out.extend(_check_generated_blocks(path, text, frontmatter))
128
147
 
129
148
  if len(lines) > MAX_LINES:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: disk-cleanup
3
- description: Reclaim disk space on Windows and macOS by scanning for large folders, classifying them into safe-to-delete vs. needs-confirmation tiers, and executing only provably zero-risk cleanup automatically. Use when the user says "clean up the disk space", "free up disk space", "disk cleanup", "clean-up-the-disk-space", "low on disk space", "C: drive full", "running out of space", or "why is my disk full". All scripts are read-only or safe-tier-only by default; every risky deletion is an explicit AskUserQuestion.
3
+ description: 'Reclaim disk space on Windows and macOS by scanning for large folders, classifying them into safe-to-delete vs. needs-confirmation tiers, and executing only provably zero-risk cleanup automatically. Use when the user says "clean up the disk space", "free up disk space", "disk cleanup", "clean-up-the-disk-space", "low on disk space", "C: drive full", "running out of space", or "why is my disk full". All scripts are read-only or safe-tier-only by default; every risky deletion is an explicit AskUserQuestion.'
4
4
  ---
5
5
 
6
6
  # disk-cleanup
@@ -42,6 +42,7 @@ Gmail access is read-only. Scope `gmail.readonly` only, a three-call allowlist (
42
42
  | Ignored senders (finance, games, food delivery, utilities) are never fetched | `ignore_domains`, `ignore_senders` | `test_scan.py` |
43
43
  | Date floor: `since_epoch` replaces the default window; an explicit `since_days` still caps it | `purchases/scan.py` | `test_a_receipts_floor_older_than_the_default_window_is_honoured` |
44
44
  | Quota: HTTP 403 `rateLimitExceeded` waits 15, 30, 60, 60 s, then `GmailQuotaError`; a scan stops and the next scan resumes | `client.py`, `scan.py` | `test_readonly.py`, `test_scan.py` |
45
+ | Amazon purchases are only the order or shipment lines (name, `Quantity`, price): a product card with a price and no quantity is never an item, whatever its heading or badge (`Deals for you`, `Recommended for you`, `Buy it again`, `Additional items to explore`, a `Prime` card); the cards are kept as `ParsedReceipt.recommendations` (evidence for a later hide) and a mail with cards but no order line is `unparsed` with reason `recommendation cards only, no order lines`; reader 1.13.1 | `purchases/parse.py` (`EXPLICIT_QTY_MERCHANTS`, `SECTION_END`, `RECOMMENDATIONS_ONLY`) | `test_amazon_recommendations.py` |
45
46
  | Amazon price split into dollars and cents, recommendation blocks (`Items from Your List`, `Deals inspired by your recent history`, the footer `We hope to see you again` cut the order section, so a suggested product is never an item), glued Sam's names, label words inside product names | `htmltext.py`, `parse.py`, `durable.py` | `test_purchase_parsers.py`, `test_durable.py` |
46
47
  | No test reads the founder's secrets or token: home and the agents env module point into a temporary folder, `GOOGLE_OAUTH_*` are unset, and opening a file under the real `~/.claude` fails the test | `tests/conftest.py` | `test_secrets_isolation.py` |
47
48
  | The Google setup guide names the billing account, the home page and privacy policy URLs needed to publish, and the 7-day Testing token | `README.md`, `resale/README.md` | `test_setup_docs.py` |
@@ -1,5 +1,5 @@
1
1
  """Purchases module: receipt parsing (vendor data files) and marketplace-account discovery. Findings only, no storage."""
2
- from .parse import LineItem, ParsedReceipt, message_id_of, parse_receipt, parse_receipts, receipt_key
2
+ from .parse import RECOMMENDATIONS_ONLY, LineItem, ParsedReceipt, message_id_of, parse_receipt, parse_receipts, receipt_key
3
3
  from .scan import (
4
4
  AccountFinding, DEFAULT_MAX_MESSAGES, DEFAULT_SINCE_DAYS, PurchaseScan, ScannedReceipt, discover_accounts,
5
5
  is_excluded, receipt_queries, scan_purchases,
@@ -7,5 +7,5 @@ from .scan import (
7
7
 
8
8
  __all__ = [
9
9
  "AccountFinding", "DEFAULT_MAX_MESSAGES", "DEFAULT_SINCE_DAYS", "LineItem", "ParsedReceipt", "PurchaseScan",
10
- "ScannedReceipt", "discover_accounts", "is_excluded", "message_id_of", "parse_receipt", "parse_receipts", "receipt_key", "receipt_queries", "scan_purchases",
10
+ "RECOMMENDATIONS_ONLY", "ScannedReceipt", "discover_accounts", "is_excluded", "message_id_of", "parse_receipt", "parse_receipts", "receipt_key", "receipt_queries", "scan_purchases",
11
11
  ]
@@ -24,12 +24,15 @@ DIGITAL = re.compile(
24
24
  SECTION_END = re.compile(
25
25
  r"^(continue shopping|keep shopping|top picks|bargain recommendations?|more items to consider|recommended|you may also|you might also|customers who|"
26
26
  r"(?:deals )?inspired by|related to items|frequently bought|buy it again|similar items|sponsored|looking forward to seeing you again|"
27
- r"we hope to see you again|items from your (?:wish ?)?list)",
27
+ r"we hope to see you again|items from your (?:wish ?)?list|deals? for you|more to explore|explore more|you might like|you may like|"
28
+ r"customers also|products related|pick up where|your browsing history|additional items|items to explore)",
28
29
  re.I,
29
30
  )
30
31
  TAX_LINE = re.compile(r"\btax(?:es)?\b.*\(\s*\d+(?:\.\d+)?\s*%\s*\)", re.I)
31
32
  STATUS_PREFIX = re.compile(r"^(?:in stock|out of stock|backorder\w*|qty|quantity|price|each|ea\.?)\b[\w\s:.]*$", re.I)
32
33
  BARE_QTY = re.compile(r"^[x\u00d7]\s*\d{1,2}$", re.I)
34
+ QTY_LABEL = re.compile(r"\b(?:qty|quantity)\b\s*[:.]?\s*\d|\b\d{1,2}\s*[x\u00d7]\b|(?<![A-Za-z0-9])[x\u00d7]\s*\d{1,2}\b", re.I)
35
+ EXPLICIT_QTY_MERCHANTS = ("amazon",)
33
36
  VARIANT_LABEL = re.compile(r"^(?:color|colour|size|style|variant|capacity|pattern|material|flavou?r|scent|part of)\s*:", re.I)
34
37
  SHOP_NAME = re.compile(r"^(.{3,}?)\s+[\u00d7x]\s*(\d{1,2})$")
35
38
  STOCK_VARIANT = re.compile(r"^(?:in stock|out of stock|default title|backorder\w*)$", re.I)
@@ -113,6 +116,7 @@ class ParsedReceipt:
113
116
  shipping_cents: int | None = None
114
117
  fees_cents: int | None = None
115
118
  charge_lines: list = field(default_factory=list)
119
+ recommendations: list = field(default_factory=list)
116
120
 
117
121
 
118
122
  def cents(match: re.Match) -> int:
@@ -295,7 +299,8 @@ def _shopify_items(lines: list[Line], store_brand: str | None) -> list[LineItem]
295
299
  return items
296
300
 
297
301
 
298
- def _extract_items(lines: list[Line], store_brand: str | None = None) -> list[LineItem]:
302
+ def _extract_items(lines: list[Line], store_brand: str | None = None, explicit_qty: bool = False) -> list[LineItem]:
303
+ """Items priced in the order part of the mail; with `explicit_qty` a product card that shows no quantity (a recommendation) is never an item."""
299
304
  lines = _order_section(lines)
300
305
  items: list[LineItem] = []
301
306
  used_images: set[str] = set()
@@ -336,8 +341,11 @@ def _extract_items(lines: list[Line], store_brand: str | None = None) -> list[Li
336
341
  qty = qty or _qty(" ".join(lines[b].text for b in range(back, index)))
337
342
  if name is None:
338
343
  continue
339
- if qty is None and index + 1 < len(lines):
340
- qty = _qty(lines[index + 1].text) if not PRICE.search(lines[index + 1].text) else None
344
+ following = lines[index + 1].text if index + 1 < len(lines) and not PRICE.search(lines[index + 1].text) else ""
345
+ if qty is None and following:
346
+ qty = _qty(following)
347
+ if explicit_qty and qty is None and not any(QTY_LABEL.search(t) for t in [*(lines[b].text for b in range(name_index, index + 1)), following]):
348
+ continue
341
349
  qty = qty or 1
342
350
  price = _unit_price(line.text, qty)
343
351
  key = (name.lower(), price)
@@ -694,6 +702,17 @@ def message_id_of(key: str) -> str:
694
702
  return key.partition("#")[0]
695
703
 
696
704
 
705
+ RECOMMENDATIONS_ONLY = "recommendation cards only, no order lines"
706
+
707
+
708
+ def _recommendation_names(lines: list[Line], store_brand: str | None, items: list[LineItem]) -> list[str]:
709
+ """Names of the product cards a mail shows that are not purchases: the cards under a recommendation heading and the priced cards of the order part that show no quantity."""
710
+ order = _order_section(lines)
711
+ cards = [*_extract_items(order, store_brand), *_extract_items(lines[len(order):], store_brand)]
712
+ bought = {i.name.lower() for i in items}
713
+ return list(dict.fromkeys(c.name for c in cards if c.name.lower() not in bought))
714
+
715
+
697
716
  def _finish(message: Message, merchant: str, key: str | None, vendor: dict | None, subject: str, lines: list[Line], items: list[LineItem],
698
717
  total: int | None, order_ref: str | None) -> ParsedReceipt:
699
718
  text = "\n".join(line.text for line in lines)
@@ -709,6 +728,10 @@ def _finish(message: Message, merchant: str, key: str | None, vendor: dict | Non
709
728
  elif not items:
710
729
  parsed.status = "unparsed"
711
730
  parsed.reason = "no item lines found" if lines else "empty body"
731
+ if key in EXPLICIT_QTY_MERCHANTS and parsed.status != "void":
732
+ parsed.recommendations = _recommendation_names(lines, vendor.get("brand") if vendor else None, items)
733
+ if not items and parsed.recommendations:
734
+ parsed.reason = RECOMMENDATIONS_ONLY
712
735
  return parsed
713
736
 
714
737
 
@@ -721,7 +744,7 @@ def _split_receipts(message: Message, merchant: str, key: str | None, vendor: di
721
744
  if not order_ref:
722
745
  continue
723
746
  total = _total(section)
724
- items = _shopify_items(section, brand) or _extract_items(section, brand) or _unpriced_items(_order_section(section), total, brand)
747
+ items = _shopify_items(section, brand) or _extract_items(section, brand, key in EXPLICIT_QTY_MERCHANTS) or _unpriced_items(_order_section(section), total, brand)
725
748
  part = _finish(message, merchant, key, vendor, subject, section, items, total, order_ref)
726
749
  heading = [line.text for line in section[:3] if SPLIT_MARKER.match(line.text.strip()) or order_ref in line.text]
727
750
  total_line = next((joined for index, line in enumerate(section) if TOTAL_LABEL.search(line.text) and not SUBTOTAL_LABEL.search(line.text)
@@ -760,7 +783,7 @@ def parse_receipts(message: Message) -> list[ParsedReceipt]:
760
783
  items: list[LineItem] = []
761
784
  for candidate in candidates:
762
785
  brand = vendor.get("brand") if vendor else None
763
- items = _shopify_items(candidate, brand) or _extract_items(candidate, brand)
786
+ items = _shopify_items(candidate, brand) or _extract_items(candidate, brand, key in EXPLICIT_QTY_MERCHANTS)
764
787
  if items:
765
788
  lines = candidate
766
789
  break
@@ -1,3 +1,3 @@
1
1
  """Single version source for gmail-reader (semantic: major bumps break consumers, minor adds, patch fixes)."""
2
2
 
3
- __version__ = "1.13.0"
3
+ __version__ = "1.13.1"
@@ -0,0 +1,86 @@
1
+ """Amazon mail: only the order or shipment lines (name, Quantity, price) are purchases; recommendation blocks never become items (shape of real shipment mail, invented content)."""
2
+ import pytest
3
+ from gmail_reader.purchases import RECOMMENDATIONS_ONLY, parse_receipt, parse_receipts
4
+ from receipt_fixtures import message
5
+
6
+ SENDER = '"Amazon.com" <shipment-tracking@amazon.com>'
7
+
8
+ DEALS_SHIPMENT = (
9
+ "<div>Hello Pat,</div><div>We wanted to let you know that we have shipped your items.</div><div>Shipping Confirmation</div>"
10
+ "<div>Your package will arrive by</div><div>Wednesday, May 28, 2 p.m. - 6 p.m.</div><div>Ship to</div><div>Pat</div><div>SPRINGFIELD, TX</div>"
11
+ "<div>Order #</div><div>113-0000001-0000001</div><div>Track package</div>"
12
+ "<div>Shipment total</div><div>$87.20</div><div>Rewards points applied</div><div>Return or replace items in Your orders</div>"
13
+ "<div>Learn how to recycle your packaging at Amazon Second Chance.</div>"
14
+ "<div>Deals for you</div><div>Sunny Health &amp; Fitness Foldable...</div><div>$71.99</div>"
15
+ "<div>DC Comics, Armor-Up Batman Mask with...</div><div>$21.60</div>"
16
+ "<div>Unless otherwise noted, items sold by Amazon.com are subject to sales tax.</div>"
17
+ )
18
+
19
+ SHIPPED_ITEM = (
20
+ "<div>Your package was shipped!</div><div>Order # 113-0000002-0000002</div><div>Track package</div>"
21
+ "<div>Govee Smart Plug with Energy Moni...</div><div>Quantity: 1</div><div>$36.99</div><div>Total | $36.99</div>"
22
+ )
23
+
24
+ HEADINGS = ["Deals for you", "Recommended for you", "Recommended for you based on items in your order", "Customers who bought this also bought",
25
+ "Buy it again", "Inspired by your browsing history", "Related to items you've viewed", "Top picks for you", "Sponsored",
26
+ "Frequently bought together", "Items from your wish list", "Deals inspired by your recent history", "Additional items to explore"]
27
+
28
+
29
+ def parse(html, subject="Shipped: item", message_id="a1"):
30
+ return parse_receipt(message(message_id, SENDER, subject, html=html))
31
+
32
+
33
+ def test_deals_for_you_shipment_has_no_purchase_lines():
34
+ parsed = parse(DEALS_SHIPMENT, 'Your Amazon.com order has shipped (#113-0000001-0000001)')
35
+ assert parsed.items == []
36
+ assert parsed.status == "unparsed" and parsed.order_ref == "113-0000001-0000001" and parsed.total_cents == 8720
37
+ assert parsed.reason == RECOMMENDATIONS_ONLY
38
+ assert parsed.recommendations == ["Sunny Health & Fitness Foldable", "DC Comics, Armor-Up Batman Mask with"]
39
+
40
+
41
+ @pytest.mark.parametrize("heading", HEADINGS)
42
+ def test_every_recommendation_heading_cuts_the_block(heading):
43
+ parsed = parse(SHIPPED_ITEM + f"<div>{heading}</div><div>Sunny Health &amp; Fitness Foldable...</div><div>$71.99</div>")
44
+ assert [(i.name, i.price_cents) for i in parsed.items] == [("Govee Smart Plug with Energy Moni", 3699)]
45
+
46
+
47
+ def test_unlabelled_product_cards_without_a_quantity_are_not_purchases():
48
+ cards = ("<div>More to explore</div><div>Sunny Health &amp; Fitness Foldable...</div><div>$71.99</div><div>Prime</div>"
49
+ "<div>-17% $249.95</div><div>Breville Bambino Espresso...</div><div>$249.95</div>")
50
+ parsed = parse(SHIPPED_ITEM + cards)
51
+ assert [i.name for i in parsed.items] == ["Govee Smart Plug with Energy Moni"]
52
+
53
+
54
+ def test_cards_before_any_order_line_are_not_purchases():
55
+ parsed = parse("<div>Order # 113-0000003-0000003</div><div>Sunny Health &amp; Fitness Foldable...</div><div>$71.99</div><div>Prime</div>"
56
+ "<div>Order Total:</div><div>$12.00</div>")
57
+ assert parsed.items == []
58
+
59
+
60
+ def test_order_lines_with_quantity_still_count_next_to_cards():
61
+ html = SHIPPED_ITEM.replace("<div>Total | $36.99</div>", "<div>Total | $36.99</div><div>Deals for you</div><div>Sunny Health &amp; Fitness Foldable...</div><div>$71.99</div>")
62
+ assert [i.name for i in parse(html).items] == ["Govee Smart Plug with Energy Moni"]
63
+
64
+
65
+ def test_split_orders_ignore_recommendation_cards_too():
66
+ def block(ref, name, price):
67
+ return f"<div>Order # {ref}</div><div>{name}</div><div>Quantity: 1</div><div>{price}</div><div>Order Total: {price}</div>"
68
+ html = "<div>Your purchase has been divided into 2 orders</div>" + block("111-1000000-0000001", "Acme Lamp", "$20.00") + block("111-2000000-0000002", "Acme Desk", "$30.00") \
69
+ + "<div>Deals for you</div><div>Sunny Health &amp; Fitness Foldable...</div><div>$71.99</div>"
70
+ parts = parse_receipts(message("s1", SENDER, "Your Amazon.com order", html=html))
71
+ assert [[i.name for i in p.items] for p in parts] == [["Acme Lamp"], ["Acme Desk"]]
72
+
73
+
74
+ def test_other_merchants_keep_items_that_show_no_quantity():
75
+ parsed = parse_receipt(message("b1", "Shop <a@shop-example.test>", "Your order confirmation", text="Order #ABC12345\nBeat Saber VR Game\n$29.99\nTotal $29.99"))
76
+ assert [i.name for i in parsed.items] == ["Beat Saber VR Game"]
77
+
78
+
79
+ def test_recommendation_names_are_kept_as_evidence_next_to_the_real_items():
80
+ parsed = parse(SHIPPED_ITEM + "<div>Deals for you</div><div>Sunny Health &amp; Fitness Foldable...</div><div>$71.99</div>")
81
+ assert parsed.reason is None and parsed.recommendations == ["Sunny Health & Fitness Foldable"]
82
+
83
+
84
+ def test_other_merchants_record_no_recommendations():
85
+ parsed = parse_receipt(message("b2", "Shop <a@shop-example.test>", "Your order confirmation", text="Order #ABC12345\nBeat Saber VR Game\n$29.99\nTotal $29.99"))
86
+ assert parsed.recommendations == []
@@ -49,7 +49,7 @@ def test_durable_goods_are_kept(name):
49
49
 
50
50
  def _receipt(message_id, lines, date=1_763_000_000):
51
51
  return message(message_id, "Amazon <auto-confirm@amazon.com>", "Your order confirmation", date=date,
52
- text="Order #111-2222222-3333333\n" + "\n".join(lines) + "\nOrder Total $50.00")
52
+ text="Order #111-2222222-3333333\n" + "\n".join(f"Quantity: 1\n{t}" if t.startswith("$") else t for t in lines) + "\nOrder Total $50.00")
53
53
 
54
54
 
55
55
  def test_scan_hides_consumables_with_a_reason_keeps_them_in_the_receipt_and_counts_them():
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: low-ram-advisor
3
- description: Suggest-only RAM triage on demand: ranked report of memory hogs (Claude sessions, Metro/node, Gradle, Maestro, emulator, browsers, WSL/Docker, local proxies, IDEs) with owner, safe-to-stop, RAM freed and a graceful pwsh stop command, plus a deep RAM report (commit and pagefile, kernel pool leaks, WSL/Docker VM, GPU, CI runner findings). Alerts never go into working chats: a restart-soon verdict or a CI cap event writes one line to the statusline. Use when the user asks what can be closed to free RAM, why the PC is slow, or whether to restart.
3
+ description: 'Suggest-only RAM triage on demand: ranked report of memory hogs (Claude sessions, Metro/node, Gradle, Maestro, emulator, browsers, WSL/Docker, local proxies, IDEs) with owner, safe-to-stop, RAM freed and a graceful pwsh stop command, plus a deep RAM report (commit and pagefile, kernel pool leaks, WSL/Docker VM, GPU, CI runner findings). Alerts never go into working chats: a restart-soon verdict or a CI cap event writes one line to the statusline. Use when the user asks what can be closed to free RAM, why the PC is slow, or whether to restart.'
4
4
  ---
5
5
 
6
6
  # low-ram-advisor
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: publish-article
3
- description: Turn a concept you learned mid-build into a highly stylized, interactive explainer published to your own domain (blog.yasaswy.nagavolu.com, ~$0/mo) plus a ready-to-paste LinkedIn post. Also handles the site's second genre, investing research notes (no-verdict stock/sector analysis). Use when the user says "publish this", "turn this into an article/explainer/blog post", "write this up", "capture this idea for the blog", "make a post about this", "publish stock article", "publish this analysis", "investing post", or invokes /publish-article. Modes: capture (mid-work; `--section building|investing`), build (fresh chat), review (local), stage (deploy to staging for the user to test), publish (go live). Staging + human eyeballing is expected but there is no enforced approval gate before prod (ADR 0019).
3
+ description: 'Turn a concept you learned mid-build into a highly stylized, interactive explainer published to your own domain (blog.yasaswy.nagavolu.com, ~$0/mo) plus a ready-to-paste LinkedIn post. Also handles the site''s second genre, investing research notes (no-verdict stock/sector analysis). Use when the user says "publish this", "turn this into an article/explainer/blog post", "write this up", "capture this idea for the blog", "make a post about this", "publish stock article", "publish this analysis", "investing post", or invokes /publish-article. Modes: capture (mid-work; `--section building|investing`), build (fresh chat), review (local), stage (deploy to staging for the user to test), publish (go live). Staging + human eyeballing is expected but there is no enforced approval gate before prod (ADR 0019).'
4
4
  ---
5
5
 
6
6
  # publish-article
@@ -97,6 +97,10 @@ Host reader/notifier to container, JSON bodies, on `RESALE_PORTAL_BIND:RESALE_PO
97
97
  | `GET /api/events/pending` | none | `{events:[event + id]}` with `toasted_at` null, oldest first |
98
98
  | `POST /api/events/{id}/delivered` | none | `204`, sets `toasted_at` |
99
99
  | `GET /api/reader/targets` | none | `reader_targets` |
100
+ | `GET /api/fbgroups/targets[?item_ids=1,2]` | none | `fbgroup_targets`: the enabled, joined groups that have a category, the tracked items to look for in each (`item_ids` names items even when they are not tracking any more) and `joins_due` (the joined-groups list was not read for 7 days) |
101
+ | `POST /api/fbgroups/posts` | `fbgroup_batch` | `202 {batch_id, accepted, duplicate, notes, joined}`; group posts become listings of source `facebook` with `group_id` set, type `classified`, status `active` or `sold`, never `gone`, and wait for the comps review gate like every comp; rule-of-thumb notes go to `brand_notes`; the joined list adds groups disabled and with no category; `access: not_member` marks the group not joined; same `batch_id` again gives `duplicate:true` |
102
+ | `GET /api/fbgroups`, `POST /api/fbgroups` | none, body `{group_id, name?, category?, keywords?, kind?, enabled?, note?}` | the group list with its post count, or one added or changed group (`422` for a bad id, kind or field) |
103
+ | `GET /api/brand-notes[?brand=]` | none | `{notes:[{brand, source, group_id, pct_low, pct_high, basis, excerpt, url, posted_at, captured_at}]}`: used-price rules of thumb from group discussions, newest first; evidence only, no price code reads it |
100
104
  | `GET /api/candidates[?include_hidden=1]` | none | `{candidates:[...]}`: the review queue (staged rows, plus listed rows with no review category) with receipt evidence (subject, order number, proof markers, qty, date, `status`); `?include_hidden=1` adds filter- and review-hidden rows |
101
105
  | `POST /api/items/{id}/paid-proof` | none (body `{paid_cents, source: receipt_split or order_allocated, basis?: list or allocated, list_price_cents?, discount_cents?, proof_lines: 1-20 verbatim bill lines, replace_founder?, tax_cents?, shipping_cents?, fees_cents?, charge_lines? (1-20 lines showing how the tax was worked out; required with tax_cents, sets tax_basis allocated)}`; `paid_cents` is the net before tax and shipping) | `200 {item_id, paid_cents, paid_source, price_basis, proof_lines, rebuilt}`; the item needs a receipt; re-reads of the receipt or the Amazon order page, and the order charge allocation, never change it or the charges stored with it; `422` for a bad body or a price the founder typed without `replace_founder` |
102
106
  | `POST /api/items/{id}/founder-hide` | none (body `{reason}`, `[a-z][a-z0-9_]{1,40}`) | `200 {item_id, hidden_reason}`; `422` for a bad reason or a non-candidate |
@@ -129,6 +133,10 @@ Observation: required `item_id`, `source_listing_id`, `listing_type`, `status`;
129
133
 
130
134
  `amazon_orders`: `schema_version`=1, `read_at`, `orders` (0..50) of `{order_id (NNN-NNNNNNN-NNNNNNN), ordered_at?, total_cents?, subtotal_cents?, shipping_cents?, tax_cents?, discount_cents?, refund_cents?, cancelled?, summary_lines[<=12], items[1..60] of {name, qty 1..99, unit_cents?, status null, cancelled or returned, asin?, product_url?, proof_lines[<=8]}}`. Only facts from the founder's own order pages; no address, payment or account fields exist in the schema.
131
135
 
136
+ `fbgroup_targets`: `schema_version`=1, `generated_at`, `joins_due`, `groups[]` of `{group_id (number or address name), name?, category, kind (sale, owner, discussion)}`, `items[]` of `{item_id, query?, model_key?, queries (1..3), group_ids (1..20)}`.
137
+
138
+ `fbgroup_batch`: `schema_version`=1, `batch_id` (8-64), `reader_run_id`, `captured_at`; optional `group_id`, `group_name`, `access` (member or not_member), `joined[]` of `{group_id, name}` (0..300), `observations[]` (0..500) of `{item_id, source_listing_id (`g<group>:<post>`), group_id, url, price_cents, listing_type=classified, status (active or sold), title?, condition_raw? (Facebook labels: New, Used - Like New, Used - Good, Used - Fair), city?, listed_at?}` and `notes[]` (0..200) of `{url, excerpt (<= 600), pct_low, pct_high (1..95), basis (below_new or of_new), group_id?, posted_at?}`. No author, seller or commenter field exists in the schema.
139
+
132
140
  `reader_targets`: `schema_version`=1, `generated_at`, `targets[]` of `{item_id, site, query, model_key?, zip, radius_miles, known?}`; `known` (Astromart only) lists the item's active or gone ads as `{source_listing_id, url, title, price_cents?, listed_at}` so the reader can check old ads on their own page.
133
141
 
134
142
  ## No other-user identity
@@ -231,7 +239,7 @@ Paid (`items.paid_cents`) is the net after discounts and never changes meaning.
231
239
  | Column | Meaning |
232
240
  |---|---|
233
241
  | `tax_cents`, `shipping_cents`, `fees_cents` | the item's share of the order's printed sales tax, shipping and fees, whole cents; `NULL` = not printed or unknown |
234
- | `tax_basis` | `line_tax` (tax printed under every item of a 2+ item receipt: `parsed_json.items[].line_tax_cents`), `allocated` (order tax split by item price), `unknown` or `NULL` (never evaluated, manual item): both read as unknown |
242
+ | `tax_basis` | `line_tax` (tax printed under every item of a 2+ item receipt: `parsed_json.items[].line_tax_cents`), `allocated` (order tax split by item price), `private_sale` (bought person to person: a manual item whose notes or purchase source name Facebook Marketplace or a Facebook post, OfferUp, Craigslist, Astromart or Nextdoor, or a receipt from one of those merchants; tax 0, label "private sale, no tax", set by `resale/inventory/private_sale.py` on add, edit, paid entry and every `paid-tax` run, never over a proven `line_tax` or `allocated` basis), `unknown` or `NULL` (never evaluated, manual item): both read as unknown |
235
243
  | `charge_proof` | JSON list of the verbatim receipt lines (tax, shipping, fees lines; subtotal and total lines when zero tax is proven by them) |
236
244
 
237
245
  | Rule | Detail |
@@ -263,7 +271,7 @@ Ready-to-paste drafts; the founder posts by hand, nothing is automated. The kit
263
271
  | Ad price | the ad price (`patient_cents`) is the asking price you set (`items.ask_price_cents`), else the stored suggested asking price (`suggested_price_cents`), else the analysis patient price (a bundle main item's own ask never prices the whole bundle; only a `(bundle)` container takes one); label `asking price you set` or `suggested asking price`, confidence `set`; the quick-sale floor stays in `price_cents` for you and is never the ad price; public draft text never reads `items.notes`, only `selling_notes` and generated text. |
264
272
  | Price pending check | a price that rests on comps (analysis comp methods, or a used-now estimate whose snapshot method is `comps`), or any price while `report.comps_review.unverified > 0`, while `CompGate(conn, item).reviewed` is false is held: `price_cents` NULL, `confidence` = `pending`, label `price pending check: comps not reviewed yet, ...`; `patient_cents` keeps the indicative value only for sorting and the eBay test; the page shows no price and no price Copy buttons; a bundle is pending when any priced piece is; reviewing the comps releases the price on the next refresh |
265
273
  | Names | `portal.names.display_name` (founder name, else cleaned receipt name), model first when the item has a model |
266
- | Text | description = key specs line (from `items.key_specs`, JSON object read like `comps.specs.load_specs`), `What you get` (one line for a single item; for a bundle every piece by value under headings per family: fitness Racks & stations / Bars / Weights / Accessories, astronomy Telescope & optics / Mounts & tripods / Eyepieces & accessories, 3D printing Printer / Filament / Accessories), one condition placeholder line, optional `Originally paid $X` (service_state `postkit_show_paid`, default off), pickup-only Wylie line, cash or Zelle line; it never contains a price, so a daily price refresh never changes it; a very long bundle drops specs, shortens names, then collapses the list so the closing lines always fit 1500 characters |
274
+ | Text | description = key specs line (from `items.key_specs`, JSON object read like `comps.specs.load_specs`), `What you get` (one line for a single item; for a bundle every piece by value under headings per family: fitness Racks & stations / Bench / Bike / Bars / Plates / Dumbbells / Accessories & mats (a heading appears only when the bundle holds that gear), astronomy Telescope & optics / Mounts & tripods / Eyepieces & accessories, 3D printing Printer / Filament / Accessories), one condition placeholder line, optional `Originally paid $X` (service_state `postkit_show_paid`, default off), pickup-only Wylie line, cash or Zelle line; it never contains a price, so a daily price refresh never changes it; a very long bundle drops specs, then shortens names (filler words and brands first, equal names merge into `x2`, one line per heading), so every piece stays listed and the closing lines fit 1500 characters; the `and N more pieces` line remains only as a last resort for a list that cannot fit even with 12-character names |
267
275
  | Titles | single and piece: model-first display name (a founder display name is used as written); bundle: the pieces by value joined with ` + ` (a real main item always first, duplicates once), then ` – <label> (N pcs)` for a `(bundle)` container or ` bundle (N pcs)`; always inside the site cap |
268
276
  | Condition refresh | setting or changing an item's condition (`POST /api/items/{id}/condition`, the `/conditions` click, an item page edit) runs `postkit.refresh(only={item_id})` at once: only units whose item or piece is that item are rebuilt (its own drafts, and the bundle and piece drafts of any bundle or kit that holds it); posted, filled, withdrawn and missing drafts are skipped, hand-edited text is kept, no draft is created or removed; the API returns `drafts_updated`; `/conditions` shows `<item> set to <level>: N drafts updated.` |
269
277
  | Edit protection | `gen_title` and `gen_description` hold the last generated text; a title or description that differs from them is the founder's and a refresh never overwrites it; posted drafts keep their text, only prices move; sold and withdrawn drafts are untouched; a changed text clears its approval; drafts made by the bundle API are adopted on the next refresh |
@@ -324,10 +332,14 @@ Host side, read-only. `python -m resale read` loads search and detail pages with
324
332
  | `inquiries-scan [--dry-run] [--status]` | 0 ok, 1 the scan failed (Gmail or container); runs the buyer mail scan now (`--dry-run` prints what it would send and remembers nothing) |
325
333
  | `browser-audit [--tail N] [--since-hours H] [--json] [--set-item ID\|--clear-item] [--resale-dir D]` | 0 ok, 2 usage; prints the browser write audit log summary and the last N records |
326
334
  | `review [--list] [--url U] [--hours H]` | 0 ok, 2 usage (not a terminal, nothing waiting, no Chrome), 3 profile busy; founder only, opens a visible Chrome on `RESALE_PROFILE_DIR` at the `ready_for_review` pages of the last H hours (default 48) that no `review_opened` event covers, then logs `review_opened` |
327
- | `post-fill <draft_id>... [--review-window]` | 0 ok, 1 attention (warnings, logged out, a step failed), 2 usage (draft refused, no adapter, container down), 3 profile busy (also: a review window is already open), 4 window not alive (`window_not_alive`, `holder_died`, `fill_timeout`, `holder_launch_failed`); with `--review-window` one JSON line `{window_pid, holder_pid, title, tabs[{site, draft_id, stopped_before, unfilled}], breakaway}` printed only after every tab reached `ready_for_review` and holder, Chrome and window title were verified alive; without it a JSON summary of the headless dry run |
335
+ | `post-fill <draft_id or own-listing token>... [--review-window]` | 0 ok, 1 attention (warnings, logged out, a step failed), 2 usage (draft refused, no adapter, container down), 3 profile busy (also: a review window is already open), 4 window not alive (`window_not_alive`, `holder_died`, `fill_timeout`, `holder_launch_failed`); with `--review-window` one JSON line `{window_pid, holder_pid, title, tabs[{site, draft_id, stopped_before, unfilled}], breakaway}` printed only after every tab reached `ready_for_review` and holder, Chrome and window title were verified alive; without it a JSON summary of the headless dry run |
328
336
  | `post-status` | 0 a review window is open, 1 not open; JSON `{open, state, holder_pid, window_pid, title, tabs, drafts}` from live state (`none`, `starting`, `filling`, `ready`, `closed`, `error`, `dead` when the recorded holder is gone) |
337
+ | `post-fill` edit tokens | `edit:<draft>[:<dollars>]` opens the edit form of the live Facebook (`/marketplace/edit/?listing_id=`, Title, Price, Description, Next, stops before `Update`) or Craigslist (manage page, Edit this Posting, title, price, description, continue, stops before `publish`) listing of a posted draft, filled with the draft's pending copy (else its current text) and the item's current asking price, never the draft's stored price (`:<dollars>` overrides; a missing or non-round ask is refused with the reason); setting an ask price on the item page refreshes that item's drafts at once; the founder presses the final button; the holder then reads the live page in a scratch tab opened as a background target (it never takes focus from the founder's tab) and closed after and records the edit (`POST /api/drafts/<id>/edited`: pending copy becomes the draft text, price becomes the draft price) only when the page shows the target title, price and opening line (up to 8 reads, 8 s apart; otherwise a warning and nothing recorded); the window stays open for an unread edit; an edit never marks the draft filled or posted again |
338
+ | `post-edit <draft_id>... [--price D] [--keep-text]` | `--keep-text` (token `price:<draft>[:<dollars>]`, container `?keep_text=1`) changes only the price: the live title and text are refilled unchanged and the pending copy stays unapplied (needed when the pending copy is not ready, for example holds a placeholder); the same tokens for several drafts: one review window, or the open one (`--into-open-window` path); OfferUp is refused with `edited in the OfferUp phone app`; routes `GET /api/drafts/<id>/edit-plan[?price_cents=N]` (409 with the reason: not posted, no address, gone, over the title limit, placeholder, price not round, OfferUp or another site) and `POST /api/drafts/<id>/edited {title, description, price_cents}` (409 unless the text is the target) |
339
+ | Astromart confirm step | after the founder presses CONTINUE on the form, the tab stands on `.../show/<name>/confirm`; the holder reads that page and presses `PLACE CLASSIFIED` once, only when the page shows the draft's title, its price and exactly one such button; the tab becomes submitted only when its address is the listing address (`.../show/<name>`), and the draft is then recorded posted; any doubt or a press that does not leave the confirm page is a named warning on the tab (`was not pressed` or `was pressed but did not finish`), never a posted draft; the form driver and the browser gate still refuse that button (`place classified` stays a final control) |
329
340
  | `post-hold <draft_id>...` | internal: the detached owner of the review window (profile lock, Chrome, fill, wait for the founder); writes `<resale>/audit/poster-review-window.json`; started only by `post-fill --review-window` |
330
341
  | `post-confirm <draft_id> [--url U]` | 0 ok, 2 refused (draft not postable); marks posted via `POST /api/drafts/<id>/posted` |
342
+ | `fbgroups list\|status\|set <id> [--name N] [--category C] [--keywords a,b] [--kind sale\|owner\|discussion] [--enable\|--disable]\|read [--item ID]... [--group ID]... [--joins] [--no-feed] [--force] [--max-pages N] [--min-delay S]\|notes [--brand B]\|show-post <url>` | 0 ok, 1 attention (wall, errors), 2 usage, 3 profile busy, 4 no browser; headless and read-only (group pages, the joined-groups list and single post addresses only; never joins, posts, comments, reacts or messages), takes the profile lock and `reader.lock`; state `fbgroups.json` (per-page last read, wall pause, last report); the scheduled `ResaleReader` runs it after the competitor reader |
331
343
  | `amazon-orders [--list] [--status] [--years Y,Y] [--since D] [--max-orders N] [--min-delay S] [--retry] [--force]` | 0 ok, 1 attention (wall, errors, unreadable page), 2 usage, 3 profile busy; headless, read-only (order-details and order-history pages only), takes the profile lock and `reader.lock`; state `amazon_orders.json` (per-order status, last wall, last report); stops on the first captcha, sign-in or rate-limit page, raises a `captcha_pause` event (payload site `amazon`) and pauses 6 h; `login --site amazon` and `check-logins` cover its login |
332
344
 
333
345
  Browser tool (`chrome-devtools` MCP, `mcps/chrome_devtools_gate.js`, `mcps/chrome_devtools_policy.js`): headless on `RESALE_PROFILE_DIR` under the shared profile lock. Child flags are fixed: `categoryInput=true`, `javascriptEvaluation=false`, `headless=true`, two `--workspace` folders (`<resale>/uploads`, `<resale>/data/photos`, the only accepted values). Tools: the 12 read tools plus `click fill fill_form type_text upload_file press_key hover drag handle_dialog`. Per-call checks before any write: the open page is read with `list_pages` (fail closed), then page rules (Gmail and Google account pages, checkout and payment hosts and paths, login paths for text entry), element rules from the last snapshot the gate saw (purchase, bid, offer, subscribe, boost, promote, log out, account delete, password, card, CVV and bank fields; a password field anywhere on the page blocks text entry), value rules (Luhn card numbers, SSN) and upload rules (inside the two folders, allowed extension). Fill only: `mcps/chrome_devtools_final_actions.json` (deployed next to the gate; the gate refuses to start without it) lists final submit and publish control names (generic `exact` names for button and menu roles, `contains` regexes for every clickable role, per-site `exact` additions by host, `nextIsFinal`). `click` on such a control is refused; `press_key` Enter or Space on a focused final control, and Enter (also `type_text` `submitKey`) in a single-line field of a page that has a final control, are refused (Enter in a multiline box is a newline). The gate adds the local tool `ready_for_review {pageId?, item?, draftSaved?, note?}`: it reads the open page, logs `event: ready_for_review` (`draftSaved`, `note`, `url`, `site`, `item`) and never reaches the browser. Audit: `<resale>/audit/browser-writes.jsonl`, one JSON object per line, `event` is `sent`, `result` (`ok`, `error`, `aborted`), `blocked`, `ready_for_review` or `review_opened`; fields `ts gatePid callId tool site url urlRef item element uid value|fields|files reason outcome detail`; `item` comes from `<resale>/audit/current-item.json` (`{"item": id}`); the file rotates to `.1` at 5 MB.
@@ -336,6 +348,8 @@ Poster (`resale/poster`): container routes `GET /api/drafts/<id>/fill-plan` (409
336
348
 
337
349
  Defaults per run: 8 page loads per target (so every tracked item is read each run; `--budget N` sets a fixed cap), 4 s minimum delay plus jitter, 60 listings and 24 thumbnails per target, 5 detail pages per target, detail cache 7 days. State files in `RESALE_DATA_DIR`: `reader_state.json`, `detail_cache.json`, `reader.lock`, `logins.json`.
338
350
 
351
+ Facebook groups (`resale/sources/fbgroup_reader.py`, `fbgroup_parse.py`, `service/fb_groups.py`): read-only comp source for the groups the account already belongs to. Group list: table `fb_groups` (migration `0029`; the REP group `1304062260169244` is seeded as `gym`, kind `owner`); `python -m resale fbgroups read --joins` reads `facebook.com/groups/joins/` and stores every joined group disabled with no category, and `fbgroups set <id> --category C --enable` switches one on. A group is read only when it is enabled, joined and has a category; an item is looked for in it when `items.category` equals the group category or the item's name, brand, model or search terms contain one of the group's keywords. Pages per run (cap 40, 8 s minimum delay plus jitter, same walls and backoff as the other readers, own pause key `fbgroup`): each group's recent feed, two used-price discussion searches per group, and each item's group search with its first two search queries; a page already read in the last 20 hours is skipped; a login wall, captcha or rate limit stops the run, raises one `captcha_pause` event with source `facebook` and pauses 15 min doubling to 6 h. A post is a comp only when it states one asking price (retail, paid, struck-through, shipping, tax and deposit amounts are skipped; with several prices only the line that names the item counts); a buyer post (WTB, ISO, looking for) is never a comp; `sold`, `SPF`, `PPU`, `pending`, a trailing or leading marker, a marker right after the price or the seller's one-word comment mark it sold (price evidence at its last ask, like any sold classified); condition is the Facebook label found in the text, `Used - Good` when the post says nothing (a classified is never new); posts older than 180 days are not stored. The stored comp has source `facebook`, `group_id` set, `source_listing_id` `g<group>:<post>` and is shown to the comps review as source `facebook_group:<id>`; it feeds no price until a per-comp `match` verdict exists. Used-price rules of thumb ("REP sells 20-30% below new") found in posts and comments go to `brand_notes` (brand matched against tracked brands, URL and date kept) as evidence for the brand retention factor; no price code reads them, and a text claim never overrides real comps. The reader never stores an author, commenter or seller name. A page that parses to no posts is kept only in `<data dir>/logs/fbgroup_suspect/` (last 10; it contains members' names, so it is never copied into the repo, the database or a test fixture; delete it after use); saved test fixtures must carry no profile or `/user/` links, names or avatars (`tests/test_fbgroup_parse.py` fails on them).
352
+
339
353
  Scheduled tasks (`tasks/task_items.json`): `ResaleReader` every 15 min after logon (the script decides if `RESALE_READER_RUNS_PER_DAY` makes a run due, then runs `amazon-orders` when its last run is 30 min old and no wall pause holds: 40 orders per run until none need a read), `ResaleCompsReview` every 15 min after logon (the script reviews only when comps wait: 30 min after a reader run, 6 h fallback, 1 h retry after a failure; state and heartbeat file `comps_review.json`, log `logs/comps_review.log`, event `comps_ready`), `ResaleNotifier` every minute.
340
354
 
341
355
  Site parsing rules: