[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75TG68NEJJ0WHFT45QMADQ4":3,"skill-same:01M75TG68NEJJ0WHFT45QMADQ4":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":5,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":6,"updatedAt":31,"install":32,"resources":45},"01M75TG68NEJJ0WHFT45QMADQ4","shop-scout",null,"Real-time product intel for in-store shopping — price comparison, deal detection, nutrition, allergen alerts, and shopping list management via R1","ajohnsonnow\u002Fr1-warren","ajohnsonnow","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F8867891?v=4","01M75T7TQ3B5VRHJF6X2Q7AWWW","Anthony Johnson","01M75T7TQPJG8YZTAVCH4SQW27",0,"MIT","https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren\u002Fblob\u002Fmain\u002Fshop-scout\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: shop-scout\ndescription: Real-time product intel for in-store shopping — price comparison, deal detection, nutrition, allergen alerts, and shopping list management via R1\nversion: 1.0.0\nauthor: rabbit-r1-skillz\n---\n\n# ShopScout — OpenClaw Skill\n\nShopScout turns the R1 into a hands-free shopping assistant. Point the R1 camera at any product (barcode preferred, label or packaging also works), tap the PTT button, and get instant spoken intel: best price across major retailers, deal history, review summary, nutrition facts, and allergen alerts.\n\n## How it works\n\n1. R1 captures the product view and sends a `scan_product` command via the OpenClaw bridge\n2. The skill uses the Anthropic vision API to identify the product (brand, name, variant, barcode if visible)\n3. It then fans out to scraping\u002FAPIs for pricing, reviews, and product data in parallel\n4. Results are returned to R1 as structured JSON\n5. R1 renders the price comparison table, rating bar, and dietary flags — and speaks the summary aloud\n6. The user can add the item to their shopping list with a long-press, then scroll through the list while shopping\n\n## Prerequisites\n\n### Required\n\n- **Node.js 20+** on your local machine\n- **OpenClaw CLI** installed and running (`openclaw serve`)\n- An **Anthropic API key** for vision-based product identification\n- A **SerpAPI or Rainforest API key** for product price lookups (see options below)\n\n### Optional\n\n- **Open Food Facts** integration for nutrition data (free, no key required)\n- **Best Buy API key** for electronics price data\n- A **Target API key** (unofficial — use scraping fallback if unavailable)\n\n## Local setup\n\n### 1. Install dependencies\n\n```bash\ncd ~\u002F.openclaw\u002Fskills\u002Fshop-scout\nnpm install @anthropic-ai\u002Fsdk axios dotenv node-fetch cheerio\n```\n\n### 2. Configure environment\n\nCreate `~\u002F.openclaw\u002Fskills\u002Fshop-scout\u002F.env`:\n\n```env\n# Required — Anthropic for vision + product identification\nANTHROPIC_API_KEY=sk-ant-...\n\n# Pricing data — choose one or both\n# Option A: Rainforest API (Amazon + others, most reliable)\nRAINFOREST_API_KEY=...\n\n# Option B: SerpAPI (Google Shopping results)\nSERPAPI_KEY=...\n\n# Option C: Oxylabs or ScraperAPI for direct retail scraping\nSCRAPER_API_KEY=...\n\n# Optional — Best Buy product catalog\nBESTBUY_API_KEY=...\n\n# OpenClaw camera proxy (if using R1 camera feed)\n# Leave blank to use a test image path for development\nCAMERA_PROXY_URL=http:\u002F\u002Flocalhost:7788\u002Fcapture\n\n# Tuning\nPRICE_CACHE_TTL_MS=300000\nMAX_RETAILERS=4\n```\n\n### 3. Register the skill\n\nAdd to `~\u002F.openclaw\u002Fopenclaw.config.json`:\n\n```json\n{\n  \"skills\": [\n    {\n      \"name\": \"shop-scout\",\n      \"path\": \"~\u002F.openclaw\u002Fskills\u002Fshop-scout\u002Fskill.js\",\n      \"description\": \"In-store product intel — prices, deals, nutrition, allergen alerts via R1\"\n    }\n  ]\n}\n```\n\n### 4. Create the skill file\n\nCreate `~\u002F.openclaw\u002Fskills\u002Fshop-scout\u002Fskill.js`:\n\n```javascript\n\"use strict\";\nrequire(\"dotenv\").config({ path: __dirname + \"\u002F.env\" });\n\nconst Anthropic   = require(\"@anthropic-ai\u002Fsdk\");\nconst axios       = require(\"axios\");\nconst https       = require(\"https\");\n\nconst anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });\n\n\u002F\u002F Price cache: avoid duplicate lookups within TTL\nconst priceCache = new Map();\nconst CACHE_TTL  = parseInt(process.env.PRICE_CACHE_TTL_MS || \"300000\", 10);\n\n\u002F\u002F ── Entry point ────────────────────────────────────────────\nmodule.exports = async function shopScout(command, params, storage) {\n  switch (command) {\n    case \"scan_product\": return scanProduct(params);\n    default:\n      return { error: `Unknown command: ${command}` };\n  }\n};\n\n\u002F\u002F ── SCAN PRODUCT ───────────────────────────────────────────\nasync function scanProduct(params) {\n  const { dietRestrictions = {}, listItems = [] } = params;\n\n  try {\n    \u002F\u002F Step 1: Capture image from camera proxy or use provided base64\n    const imageBase64 = await captureImage(params.imageBase64);\n\n    \u002F\u002F Step 2: Vision — identify the product\n    const product = await identifyProduct(imageBase64);\n    if (!product || !product.name) {\n      return { error: \"Could not identify a product in the image. Try better lighting or move closer.\" };\n    }\n\n    \u002F\u002F Step 3: Fan out — prices + reviews + nutrition in parallel\n    const [priceData, reviewData, nutritionData] = await Promise.allSettled([\n      lookupPrices(product),\n      lookupReviews(product),\n      lookupNutrition(product),\n    ]);\n\n    const prices    = priceData.status    === \"fulfilled\" ? priceData.value    : [];\n    const reviews   = reviewData.status   === \"fulfilled\" ? reviewData.value   : {};\n    const nutrition = nutritionData.status === \"fulfilled\" ? nutritionData.value : null;\n\n    \u002F\u002F Step 4: Price history (simple heuristic from scraped data)\n    const priceHistory = computePriceHistory(prices);\n\n    \u002F\u002F Step 5: Allergen check\n    const allergens = checkAllergens(nutrition, dietRestrictions);\n\n    \u002F\u002F Step 6: Dietary tags\n    const dietaryTags = buildDietaryTags(nutrition, allergens, dietRestrictions);\n\n    \u002F\u002F Step 7: Assemble result\n    const result = {\n      name:         product.name,\n      brand:        product.brand || \"\",\n      variant:      product.variant || \"\",\n      barcode:      product.barcode || null,\n      isFood:       product.isFood || false,\n      prices,\n      priceHistory,\n      rating:       reviews.rating || null,\n      allergens,\n      dietaryTags,\n      nutrition:    nutrition?.nutrients || null,\n    };\n\n    return result;\n\n  } catch (err) {\n    console.error(\"scan_product error:\", err.message);\n    return { error: err.message };\n  }\n}\n\n\u002F\u002F ── IMAGE CAPTURE ──────────────────────────────────────────\nasync function captureImage(providedBase64) {\n  if (providedBase64) return providedBase64;\n\n  const proxyUrl = process.env.CAMERA_PROXY_URL;\n  if (!proxyUrl) {\n    throw new Error(\"No camera proxy configured. Set CAMERA_PROXY_URL in .env.\");\n  }\n\n  const resp = await axios.get(proxyUrl, {\n    responseType: \"arraybuffer\",\n    timeout: 8000,\n  });\n  return Buffer.from(resp.data).toString(\"base64\");\n}\n\n\u002F\u002F ── VISION: IDENTIFY PRODUCT ───────────────────────────────\nasync function identifyProduct(imageBase64) {\n  const msg = await anthropic.messages.create({\n    model:      \"claude-sonnet-4-6\",\n    max_tokens: 512,\n    messages: [{\n      role: \"user\",\n      content: [\n        {\n          type: \"image\",\n          source: {\n            type:       \"base64\",\n            media_type: \"image\u002Fjpeg\",\n            data:       imageBase64,\n          },\n        },\n        {\n          type: \"text\",\n          text: `Identify the product in this image. Return a JSON object with these fields (no other text):\n{\n  \"name\":    \"full product name including size\u002Fcount if visible\",\n  \"brand\":   \"brand name\",\n  \"variant\": \"flavor, color, or edition if applicable\",\n  \"barcode\": \"UPC or EAN code if visible, otherwise null\",\n  \"isFood\":  true or false\n}\nIf you cannot identify a product, return {\"error\": \"reason\"}.`,\n        },\n      ],\n    }],\n  });\n\n  const text = msg.content[0]?.text?.trim() || \"\";\n  try {\n    const raw = text.replace(\u002F^```json\\s*\u002Fi, \"\").replace(\u002F```\\s*$\u002F, \"\").trim();\n    return JSON.parse(raw);\n  } catch (_) {\n    throw new Error(\"Vision model returned unexpected format: \" + text.slice(0, 100));\n  }\n}\n\n\u002F\u002F ── PRICE LOOKUP ───────────────────────────────────────────\nasync function lookupPrices(product) {\n  const cacheKey = normKey(product.name + product.variant);\n  const cached   = priceCache.get(cacheKey);\n  if (cached && Date.now() - cached.ts \u003C CACHE_TTL) {\n    return cached.prices;\n  }\n\n  const query = encodeURIComponent(`${product.brand} ${product.name} ${product.variant}`.trim());\n  const results = [];\n\n  \u002F\u002F Try Rainforest API (Amazon pricing) first\n  if (process.env.RAINFOREST_API_KEY) {\n    try {\n      const resp = await axios.get(\"https:\u002F\u002Fapi.rainforestapi.com\u002Frequest\", {\n        params: {\n          api_key: process.env.RAINFOREST_API_KEY,\n          type:    \"search\",\n          amazon_domain: \"amazon.com\",\n          search_term: `${product.brand} ${product.name} ${product.variant}`.trim(),\n          max_page: 1,\n        },\n        timeout: 10000,\n      });\n      const item = resp.data?.search_results?.[0];\n      if (item?.price?.value) {\n        results.push({ retailer: \"Amazon\", price: parseFloat(item.price.value) });\n      }\n    } catch (e) {\n      console.warn(\"Rainforest API error:\", e.message);\n    }\n  }\n\n  \u002F\u002F Try SerpAPI for Google Shopping\n  if (process.env.SERPAPI_KEY) {\n    try {\n      const resp = await axios.get(\"https:\u002F\u002Fserpapi.com\u002Fsearch.json\", {\n        params: {\n          engine:  \"google_shopping\",\n          q:       `${product.brand} ${product.name} ${product.variant}`.trim(),\n          api_key: process.env.SERPAPI_KEY,\n          num:     10,\n        },\n        timeout: 10000,\n      });\n      const items = resp.data?.shopping_results || [];\n      const retailersSeen = new Set(results.map(r => r.retailer));\n\n      for (const item of items) {\n        const retailer = mapRetailer(item.source || \"\");\n        if (!retailer || retailersSeen.has(retailer)) continue;\n        const price = parseFloat(String(item.price || \"\").replace(\u002F[^0-9.]\u002Fg, \"\"));\n        if (!isNaN(price) && price > 0) {\n          results.push({ retailer, price });\n          retailersSeen.add(retailer);\n        }\n        if (results.length >= 4) break;\n      }\n    } catch (e) {\n      console.warn(\"SerpAPI error:\", e.message);\n    }\n  }\n\n  \u002F\u002F Fallback: use scraper API if both above failed\n  if (results.length === 0 && process.env.SCRAPER_API_KEY) {\n    try {\n      const walmartUrl = `https:\u002F\u002Fwww.walmart.com\u002Fsearch?q=${query}`;\n      const scraped = await axios.get(`http:\u002F\u002Fapi.scraperapi.com`, {\n        params: { api_key: process.env.SCRAPER_API_KEY, url: walmartUrl },\n        timeout: 12000,\n      });\n      \u002F\u002F Minimal price extraction from Walmart HTML\n      const priceMatch = scraped.data.match(\u002F\\$(\\d+\\.?\\d*)\u002F);\n      if (priceMatch) {\n        results.push({ retailer: \"Walmart\", price: parseFloat(priceMatch[1]) });\n      }\n    } catch (e) {\n      console.warn(\"Scraper API fallback error:\", e.message);\n    }\n  }\n\n  priceCache.set(cacheKey, { prices: results, ts: Date.now() });\n  return results;\n}\n\nfunction mapRetailer(source) {\n  const s = source.toLowerCase();\n  if (s.includes(\"amazon\"))   return \"Amazon\";\n  if (s.includes(\"walmart\"))  return \"Walmart\";\n  if (s.includes(\"target\"))   return \"Target\";\n  if (s.includes(\"best buy\") || s.includes(\"bestbuy\")) return \"Best Buy\";\n  if (s.includes(\"costco\"))   return \"Costco\";\n  if (s.includes(\"kroger\"))   return \"Kroger\";\n  if (s.includes(\"walgreen\")) return \"Walgreens\";\n  if (s.includes(\"cvs\"))      return \"CVS\";\n  return null; \u002F\u002F skip unknown retailers\n}\n\n\u002F\u002F ── PRICE HISTORY (heuristic) ──────────────────────────────\n\u002F\u002F Without a true price history DB, we approximate based on\n\u002F\u002F the spread between the lowest and typical prices seen.\n\u002F\u002F For a production integration, wire up CamelCamelCamel or\n\u002F\u002F Honey's price history API here.\nfunction computePriceHistory(prices) {\n  const validPrices = prices.filter(p => p.price != null).map(p => p.price);\n  if (validPrices.length === 0) return null;\n\n  const minPrice    = Math.min(...validPrices);\n  const maxPrice    = Math.max(...validPrices);\n  const avgPrice    = validPrices.reduce((a, b) => a + b, 0) \u002F validPrices.length;\n\n  \u002F\u002F Rough heuristic: if min price is >15% below average across retailers, suggest it's a deal\n  const discount    = (avgPrice - minPrice) \u002F avgPrice;\n  const isGoodDeal  = discount > 0.12 && validPrices.length >= 2;\n  const usualPrice  = parseFloat(maxPrice.toFixed(2));\n\n  return { usualPrice, isGoodDeal };\n}\n\n\u002F\u002F ── REVIEW LOOKUP ──────────────────────────────────────────\nasync function lookupReviews(product) {\n  \u002F\u002F Use LLM to synthesize review sentiment from product knowledge\n  \u002F\u002F For production, wire up Best Buy API, SerpAPI reviews, or a scraper.\n  try {\n    const msg = await anthropic.messages.create({\n      model:      \"claude-haiku-4-5-20251001\",\n      max_tokens: 256,\n      messages: [{\n        role:    \"user\",\n        content: `For the product \"${product.brand} ${product.name} ${product.variant}\":\nReturn a JSON object with review data (use your knowledge, no external lookup):\n{\n  \"rating\": {\n    \"score\": \u003Cnumber 1-5 or null if unknown>,\n    \"count\": \u003Capproximate review count or null>,\n    \"pros\": [\"\u003Ctop pro 1>\", \"\u003Ctop pro 2>\"],\n    \"cons\": [\"\u003Ctop con 1>\", \"\u003Ctop con 2>\"]\n  }\n}\nReturn only valid JSON.`,\n      }],\n    });\n    const text = msg.content[0]?.text?.trim() || \"{}\";\n    const raw  = text.replace(\u002F^```json\\s*\u002Fi, \"\").replace(\u002F```\\s*$\u002F, \"\").trim();\n    return JSON.parse(raw);\n  } catch (_) {\n    return {};\n  }\n}\n\n\u002F\u002F ── NUTRITION LOOKUP ───────────────────────────────────────\nasync function lookupNutrition(product) {\n  if (!product.isFood) return null;\n\n  \u002F\u002F Try Open Food Facts (free, no API key)\n  const searchQuery = encodeURIComponent(`${product.brand} ${product.name}`.trim());\n  try {\n    const resp = await axios.get(\n      `https:\u002F\u002Fworld.openfoodfacts.org\u002Fcgi\u002Fsearch.pl?search_terms=${searchQuery}&search_simple=1&action=process&json=1&page_size=1`,\n      { timeout: 8000 }\n    );\n    const item = resp.data?.products?.[0];\n    if (item?.nutriments) {\n      const n = item.nutriments;\n      return {\n        nutrients: {\n          calories: Math.round(n[\"energy-kcal_100g\"] || n[\"energy-kcal_serving\"] || 0) || null,\n          protein:  parseFloat((n[\"proteins_100g\"]   || n[\"proteins_serving\"]   || 0).toFixed(1)) || null,\n          carbs:    parseFloat((n[\"carbohydrates_100g\"] || n[\"carbohydrates_serving\"] || 0).toFixed(1)) || null,\n          fat:      parseFloat((n[\"fat_100g\"]         || n[\"fat_serving\"]         || 0).toFixed(1)) || null,\n          sodium:   Math.round((n[\"sodium_100g\"]      || n[\"sodium_serving\"]      || 0) * 1000) || null,\n          fiber:    parseFloat((n[\"fiber_100g\"]        || n[\"fiber_serving\"]       || 0).toFixed(1)) || null,\n        },\n        allergens: (item.allergens_tags || [])\n          .map(a => a.replace(\u002F^en:\u002F, \"\").replace(\u002F-\u002Fg, \" \"))\n          .filter(Boolean),\n        ingredientText: item.ingredients_text_en || item.ingredients_text || \"\",\n      };\n    }\n  } catch (e) {\n    console.warn(\"Open Food Facts error:\", e.message);\n  }\n\n  \u002F\u002F Fallback: ask LLM for approximate nutrition\n  try {\n    const msg = await anthropic.messages.create({\n      model:      \"claude-haiku-4-5-20251001\",\n      max_tokens: 200,\n      messages: [{\n        role:    \"user\",\n        content: `Give approximate per-serving nutrition for \"${product.brand} ${product.name} ${product.variant}\".\nReturn JSON:\n{\n  \"nutrients\": { \"calories\": \u003Cn>, \"protein\": \u003Cg>, \"carbs\": \u003Cg>, \"fat\": \u003Cg>, \"sodium\": \u003Cmg>, \"fiber\": \u003Cg> },\n  \"allergens\": [\"\u003Callergen>\"],\n  \"ingredientText\": \"\"\n}\nUse null for unknown values. Return only valid JSON.`,\n      }],\n    });\n    const text = msg.content[0]?.text?.trim() || \"{}\";\n    const raw  = text.replace(\u002F^```json\\s*\u002Fi, \"\").replace(\u002F```\\s*$\u002F, \"\").trim();\n    return JSON.parse(raw);\n  } catch (_) {\n    return null;\n  }\n}\n\n\u002F\u002F ── ALLERGEN CHECK ─────────────────────────────────────────\nfunction checkAllergens(nutritionData, dietRestrictions) {\n  if (!nutritionData) return [];\n\n  const foundAllergens = [];\n  const ingredients    = (nutritionData.ingredientText || \"\").toLowerCase();\n  const knownAllergens = (nutritionData.allergens || []).map(a => a.toLowerCase());\n\n  if (dietRestrictions.gluten) {\n    const terms = [\"wheat\", \"barley\", \"rye\", \"gluten\", \"spelt\", \"malt\"];\n    if (terms.some(t => ingredients.includes(t) || knownAllergens.some(a => a.includes(t)))) {\n      foundAllergens.push(\"Gluten\");\n    }\n  }\n  if (dietRestrictions.nuts) {\n    const terms = [\"peanut\", \"almond\", \"cashew\", \"walnut\", \"pecan\", \"pistachio\", \"hazelnut\", \"tree nut\"];\n    if (terms.some(t => ingredients.includes(t) || knownAllergens.some(a => a.includes(t)))) {\n      foundAllergens.push(\"Nuts\");\n    }\n  }\n  if (dietRestrictions.dairy) {\n    const terms = [\"milk\", \"cheese\", \"cream\", \"butter\", \"lactose\", \"whey\", \"casein\", \"dairy\"];\n    if (terms.some(t => ingredients.includes(t) || knownAllergens.some(a => a.includes(t)))) {\n      foundAllergens.push(\"Dairy\");\n    }\n  }\n  if (dietRestrictions.vegan) {\n    const terms = [\"meat\", \"chicken\", \"beef\", \"pork\", \"gelatin\", \"egg\", \"honey\", \"lard\", \"tallow\", \"milk\", \"cheese\", \"butter\"];\n    if (terms.some(t => ingredients.includes(t) || knownAllergens.some(a => a.includes(t)))) {\n      foundAllergens.push(\"Not vegan\");\n    }\n  }\n  if (dietRestrictions.sodium && nutritionData.nutrients?.sodium != null) {\n    if (nutritionData.nutrients.sodium > 600) {\n      foundAllergens.push(\"High sodium\");\n    }\n  }\n\n  return foundAllergens;\n}\n\n\u002F\u002F ── DIETARY TAGS ────────────────────────────────────────────\nfunction buildDietaryTags(nutritionData, allergens, dietRestrictions) {\n  const tags = [];\n  if (!nutritionData) return tags;\n\n  const ing   = (nutritionData.ingredientText || \"\").toLowerCase();\n  const known = (nutritionData.allergens || []).map(a => a.toLowerCase());\n\n  \u002F\u002F Positive tags\n  const hasGluten = [\"wheat\",\"barley\",\"rye\",\"gluten\"].some(t => ing.includes(t) || known.some(a => a.includes(t)));\n  if (!hasGluten) tags.push(\"Gluten-Free\");\n\n  const hasDairy  = [\"milk\",\"cheese\",\"cream\",\"butter\",\"lactose\",\"whey\"].some(t => ing.includes(t) || known.some(a => a.includes(t)));\n  if (!hasDairy)  tags.push(\"Dairy-Free\");\n\n  const hasNuts   = [\"peanut\",\"almond\",\"cashew\",\"walnut\",\"tree nut\"].some(t => ing.includes(t) || known.some(a => a.includes(t)));\n  if (!hasNuts)   tags.push(\"Nut-Free\");\n\n  const hasMeat   = [\"meat\",\"chicken\",\"beef\",\"pork\",\"gelatin\",\"lard\"].some(t => ing.includes(t));\n  const hasAnimal = hasDairy || ing.includes(\"egg\") || ing.includes(\"honey\") || hasMeat;\n  if (!hasAnimal) tags.push(\"Vegan\");\n\n  \u002F\u002F Warning tags from allergens\n  allergens.forEach(a => {\n    if (!tags.includes(a)) tags.push(a);\n  });\n\n  return tags;\n}\n\n\u002F\u002F ── UTILS ──────────────────────────────────────────────────\nfunction normKey(str) {\n  return str.toLowerCase().replace(\u002F[^a-z0-9]\u002Fg, \"\");\n}\n```\n\n### 5. Start OpenClaw\n\n```bash\nopenclaw serve\n```\n\nConfirm `shop-scout` appears in the registered skills list.\n\n## Camera integration\n\nThe skill uses a **camera proxy** running on your local machine to capture an image when R1 sends a scan command. You have two options:\n\n### Option A: Camera proxy (recommended)\n\nRun the included proxy server that captures a frame from your webcam or the R1 camera stream:\n\n```bash\ncd ~\u002F.openclaw\u002Fskills\u002Fshop-scout\nnode camera-proxy.js\n```\n\nCreate `camera-proxy.js`:\n\n```javascript\n\"use strict\";\nconst http  = require(\"http\");\nconst { exec } = require(\"child_process\");\nconst fs    = require(\"fs\");\nconst path  = require(\"path\");\n\nconst PORT = 7788;\n\n\u002F\u002F Uses ffmpeg to grab a single frame from your webcam (device 0)\nhttp.createServer((req, res) => {\n  if (req.url !== \"\u002Fcapture\") { res.writeHead(404); res.end(); return; }\n  const tmp = path.join(require(\"os\").tmpdir(), `shopscout-${Date.now()}.jpg`);\n  exec(`ffmpeg -y -f avfoundation -framerate 1 -i \"0\" -vframes 1 -q:v 2 \"${tmp}\" 2>\u002Fdev\u002Fnull`, (err) => {\n    if (err) {\n      res.writeHead(500);\n      res.end(\"Capture failed: \" + err.message);\n      return;\n    }\n    const data = fs.readFileSync(tmp);\n    fs.unlinkSync(tmp);\n    res.writeHead(200, { \"Content-Type\": \"image\u002Fjpeg\" });\n    res.end(data);\n  });\n}).listen(PORT, () => console.log(`Camera proxy listening on :${PORT}`));\n```\n\nOn macOS, replace `-f avfoundation -i \"0\"` with your device. On Linux use `-f v4l2 -i \u002Fdev\u002Fvideo0`. On Windows use `-f dshow -i video=\"USB Camera\"`.\n\n### Option B: R1 camera passthrough\n\nIf OpenClaw has a camera passthrough module, configure it to forward the R1 camera feed to `http:\u002F\u002Flocalhost:7788\u002Fcapture`. See the OpenClaw documentation for camera passthrough setup.\n\n## Command reference\n\n### `scan_product`\n\nSent when the user taps PTT on the Idle screen.\n\n**Params:**\n\n| Field | Type | Description |\n|---|---|---|\n| `dietRestrictions` | object | User's active dietary flags (`{gluten, vegan, nuts, dairy, kosher, sodium}`) |\n| `listItems` | string[] | Current shopping list item names (for list-match display) |\n| `imageBase64` | string\\|null | JPEG base64 if R1 passes the image directly; otherwise omitted |\n\n**Response:**\n\n| Field | Type | Description |\n|---|---|---|\n| `name` | string | Full product name |\n| `brand` | string | Brand name |\n| `variant` | string | Flavor, size, edition |\n| `barcode` | string\\|null | UPC\u002FEAN if detected |\n| `isFood` | boolean | Whether the product is food |\n| `prices` | array | `[{ retailer, price }]` sorted lowest first |\n| `priceHistory` | object | `{ usualPrice, isGoodDeal }` |\n| `rating` | object | `{ score, count, pros, cons }` |\n| `allergens` | string[] | Restriction violations detected |\n| `dietaryTags` | string[] | Positive and warning dietary labels |\n| `nutrition` | object | `{ calories, protein, carbs, fat, sodium, fiber }` (null if not food) |\n| `error` | string\\|null | Error message if identification failed |\n\n## Pricing data options\n\n| Provider | Free tier | Coverage | Notes |\n|---|---|---|---|\n| **SerpAPI** | 100 searches\u002Fmonth | Google Shopping (all retailers) | Fastest setup |\n| **Rainforest API** | 1,000 req\u002Fmonth | Amazon only | Most accurate for Amazon |\n| **Open Food Facts** | Unlimited | Food only (nutrition) | Free, no key required |\n| **Best Buy API** | Free | Best Buy only | Electronics with official pricing |\n| **ScraperAPI** | 5,000 req\u002Fmonth | Any retail site | Use as fallback |\n\nFor production shopping frequency (20–50 scans\u002Fday), a paid SerpAPI or Rainforest plan is recommended.\n\n## Troubleshooting\n\n**R1 shows blue LED forever — never gets a result**\n- Confirm `openclaw serve` is running and the skill is registered\n- Check `CAMERA_PROXY_URL` in `.env` matches your proxy address\n- Try `curl http:\u002F\u002Flocalhost:7788\u002Fcapture -o \u002Ftmp\u002Ftest.jpg` — if it fails, the camera proxy is the issue\n- Increase timeout in `R1.ocReceive({ timeoutMs: 45000 })` if your machine is slow\n\n**\"Could not identify a product\" error**\n- Move closer to the product — the barcode must be at least 50px wide in frame\n- Improve lighting — backlighting washes out barcodes\n- Try pointing at the product label instead of the barcode\n- The vision model needs a reasonably clear, non-blurry image\n\n**Prices are missing or all show \"N\u002FA\"**\n- Verify your `RAINFOREST_API_KEY` or `SERPAPI_KEY` is set and has quota\n- Check the OpenClaw process logs: `openclaw serve --verbose`\n- The pricing fan-out is non-fatal — the product still appears even if pricing fails\n\n**Allergen detection is inaccurate**\n- Open Food Facts may not have every product; the LLM fallback uses general knowledge\n- For critical allergies, always verify the physical label\n- The system errs toward false positives to protect users\n\n**LED stays red after allergen alert**\n- This is intentional — allergen state persists until the user scans a new product\n- Long-press PTT from the result screen to return to idle, which resets to green LED\n\n## Security notes\n\n- Camera images are sent to the Anthropic API (vision) only. They are not stored locally or transmitted elsewhere.\n- Product names and query terms are sent to the configured pricing API (SerpAPI or Rainforest).\n- No personal data or location is sent. Pricing lookups use the product name only.\n- Nutrition data is fetched from Open Food Facts, a public database — no identifying info is included.\n- The shopping list and dietary settings are stored on-device in R1 storage only.\n- Store your `.env` file securely. Do not commit API keys to version control.\n","# ShopScout — OpenClaw Skill\n\nShopScout turns the R1 into a hands-free shopping assistant. Point the R1 camera at any product (barcode preferred, label or packaging also works), tap the PTT button, and get instant spoken intel: best price across major retailers, deal history, review summary, nutrition facts, and allergen alerts.\n\n## How it works\n\n1. R1 captures the product view and sends a `scan_product` command via the OpenClaw bridge\n2. The skill uses the Anthropic vision API to identify the product (brand, name, variant, barcode if visible)\n3. It then fans out to scraping\u002FAPIs for pricing, reviews, and product data in parallel\n4. Results are returned to R1 as structured JSON\n5. R1 renders the price comparison table, rating bar, and dietary flags — and speaks the summary aloud\n6. The user can add the item to their shopping list with a long-press, then scroll through the list while shopping\n\n## Prerequisites\n\n### Required\n\n- **Node.js 20+** on your local machine\n- **OpenClaw CLI** installed and running (`openclaw serve`)\n- An **Anthropic API key** for vision-based product identification\n- A **SerpAPI or Rainforest API key** for product price lookups (see options below)\n\n### Optional\n\n- **Open Food Facts** integration for nutrition data (free, no key required)\n- **Best Buy API key** for electronics price data\n- A **Target API key** (unofficial — use scraping fallback if unavailable)\n\n## Local setup\n\n### 1. Install dependencies\n\n```bash\ncd ~\u002F.openclaw\u002Fskills\u002Fshop-scout\nnpm install @anthropic-ai\u002Fsdk axios dotenv node-fetch cheerio\n```\n\n### 2. Configure environment\n\nCreate `~\u002F.openclaw\u002Fskills\u002Fshop-scout\u002F.env`:\n\n```env\n# Required — Anthropic for vision + product identification\nANTHROPIC_API_KEY=sk-ant-...\n\n# Pricing data — choose one or both\n# Option A: Rainforest API (Amazon + others, most reliable)\nRAINFOREST_API_KEY=...\n\n# Option B: SerpAPI (Google Shopping results)\nSERPAPI_KEY=...\n\n# Option C: Oxylabs or ScraperAPI for direct retail scraping\nSCRAPER_API_KEY=...\n\n# Optional — Best Buy product catalog\nBESTBUY_API_KEY=...\n\n# OpenClaw camera proxy (if using R1 camera feed)\n# Leave blank to use a test image path for development\nCAMERA_PROXY_URL=http:\u002F\u002Flocalhost:7788\u002Fcapture\n\n# Tuning\nPRICE_CACHE_TTL_MS=300000\nMAX_RETAILERS=4\n```\n\n### 3. Register the skill\n\nAdd to `~\u002F.openclaw\u002Fopenclaw.config.json`:\n\n```json\n{\n  \"skills\": [\n    {\n      \"name\": \"shop-scout\",\n      \"path\": \"~\u002F.openclaw\u002Fskills\u002Fshop-scout\u002Fskill.js\",\n      \"description\": \"In-store product intel — prices, deals, nutrition, allergen alerts via R1\"\n    }\n  ]\n}\n```\n\n### 4. Create the skill file\n\nCreate `~\u002F.openclaw\u002Fskills\u002Fshop-scout\u002Fskill.js`:\n\n```javascript\n\"use strict\";\nrequire(\"dotenv\").config({ path: __dirname + \"\u002F.env\" });\n\nconst Anthropic   = require(\"@anthropic-ai\u002Fsdk\");\nconst axios       = require(\"axios\");\nconst https       = require(\"https\");\n\nconst anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });\n\n\u002F\u002F Price cache: avoid duplicate lookups within TTL\nconst priceCache = new Map();\nconst CACHE_TTL  = parseInt(process.env.PRICE_CACHE_TTL_MS || \"300000\", 10);\n\n\u002F\u002F ── Entry point ────────────────────────────────────────────\nmodule.exports = async function shopScout(command, params, storage) {\n  switch (command) {\n    case \"scan_product\": return scanProduct(params);\n    default:\n      return { error: `Unknown command: ${command}` };\n  }\n};\n\n\u002F\u002F ── SCAN PRODUCT ───────────────────────────────────────────\nasync function scanProduct(params) {\n  const { dietRestrictions = {}, listItems = [] } = params;\n\n  try {\n    \u002F\u002F Step 1: Capture image from camera proxy or use provided base64\n    const imageBase64 = await captureImage(params.imageBase64);\n\n    \u002F\u002F Step 2: Vision — identify the product\n    const product = await identifyProduct(imageBase64);\n    if (!product || !product.name) {\n      return { error: \"Could not identify a product in the image. Try better lighting or move closer.\" };\n    }\n\n    \u002F\u002F Step 3: Fan out — prices + reviews + nutrition in parallel\n    const [priceData, reviewData, nutritionData] = await Promise.allSettled([\n      lookupPrices(product),\n      lookupReviews(product),\n      lookupNutrition(product),\n    ]);\n\n    const prices    = priceData.status    === \"fulfilled\" ? priceData.value    : [];\n    const reviews   = reviewData.status   === \"fulfilled\" ? reviewData.value   : {};\n    const nutrition = nutritionData.status === \"fulfilled\" ? nutritionData.value : null;\n\n    \u002F\u002F Step 4: Price history (simple heuristic from scraped data)\n    const priceHistory = computePriceHistory(prices);\n\n    \u002F\u002F Step 5: Allergen check\n    const allergens = checkAllergens(nutrition, dietRestrictions);\n\n    \u002F\u002F Step 6: Dietary tags\n    const dietaryTags = buildDietaryTags(nutrition, allergens, dietRestrictions);\n\n    \u002F\u002F Step 7: Assemble result\n    const result = {\n      name:         product.name,\n      brand:        product.brand || \"\",\n      variant:      product.variant || \"\",\n      barcode:      product.barcode || null,\n      isFood:       product.isFood || false,\n      prices,\n      priceHistory,\n      rating:       reviews.rating || null,\n      allergens,\n      dietaryTags,\n      nutrition:    nutrition?.nutrients || null,\n    };\n\n    return result;\n\n  } catch (err) {\n    console.error(\"scan_product error:\", err.message);\n    return { error: err.message };\n  }\n}\n\n\u002F\u002F ── IMAGE CAPTURE ──────────────────────────────────────────\nasync function captureImage(providedBase64) {\n  if (providedBase64) return providedBase64;\n\n  const proxyUrl = process.env.CAMERA_PROXY_URL;\n  if (!proxyUrl) {\n    throw new Error(\"No camera proxy configured. Set CAMERA_PROXY_URL in .env.\");\n  }\n\n  const resp = await axios.get(proxyUrl, {\n    responseType: \"arraybuffer\",\n    timeout: 8000,\n  });\n  return Buffer.from(resp.data).toString(\"base64\");\n}\n\n\u002F\u002F ── VISION: IDENTIFY PRODUCT ───────────────────────────────\nasync function identifyProduct(imageBase64) {\n  const msg = await anthropic.messages.create({\n    model:      \"claude-sonnet-4-6\",\n    max_tokens: 512,\n    messages: [{\n      role: \"user\",\n      content: [\n        {\n          type: \"image\",\n          source: {\n            type:       \"base64\",\n            media_type: \"image\u002Fjpeg\",\n            data:       imageBase64,\n          },\n        },\n        {\n          type: \"text\",\n          text: `Identify the product in this image. Return a JSON object with these fields (no other text):\n{\n  \"name\":    \"full product name including size\u002Fcount if visible\",\n  \"brand\":   \"brand name\",\n  \"variant\": \"flavor, color, or edition if applicable\",\n  \"barcode\": \"UPC or EAN code if visible, otherwise null\",\n  \"isFood\":  true or false\n}\nIf you cannot identify a product, return {\"error\": \"reason\"}.`,\n        },\n      ],\n    }],\n  });\n\n  const text = msg.content[0]?.text?.trim() || \"\";\n  try {\n    const raw = text.replace(\u002F^```json\\s*\u002Fi, \"\").replace(\u002F```\\s*$\u002F, \"\").trim();\n    return JSON.parse(raw);\n  } catch (_) {\n    throw new Error(\"Vision model returned unexpected format: \" + text.slice(0, 100));\n  }\n}\n\n\u002F\u002F ── PRICE LOOKUP ───────────────────────────────────────────\nasync function lookupPrices(product) {\n  const cacheKey = normKey(product.name + product.variant);\n  const cached   = priceCache.get(cacheKey);\n  if (cached && Date.now() - cached.ts \u003C CACHE_TTL) {\n    return cached.prices;\n  }\n\n  const query = encodeURIComponent(`${product.brand} ${product.name} ${product.variant}`.trim());\n  const results = [];\n\n  \u002F\u002F Try Rainforest API (Amazon pricing) first\n  if (process.env.RAINFOREST_API_KEY) {\n    try {\n      const resp = await axios.get(\"https:\u002F\u002Fapi.rainforestapi.com\u002Frequest\", {\n        params: {\n          api_key: process.env.RAINFOREST_API_KEY,\n          type:    \"search\",\n          amazon_domain: \"amazon.com\",\n          search_term: `${product.brand} ${product.name} ${product.variant}`.trim(),\n          max_page: 1,\n        },\n        timeout: 10000,\n      });\n      const item = resp.data?.search_results?.[0];\n      if (item?.price?.value) {\n        results.push({ retailer: \"Amazon\", price: parseFloat(item.price.value) });\n      }\n    } catch (e) {\n      console.warn(\"Rainforest API error:\", e.message);\n    }\n  }\n\n  \u002F\u002F Try SerpAPI for Google Shopping\n  if (process.env.SERPAPI_KEY) {\n    try {\n      const resp = await axios.get(\"https:\u002F\u002Fserpapi.com\u002Fsearch.json\", {\n        params: {\n          engine:  \"google_shopping\",\n          q:       `${product.brand} ${product.name} ${product.variant}`.trim(),\n          api_key: process.env.SERPAPI_KEY,\n          num:     10,\n        },\n        timeout: 10000,\n      });\n      const items = resp.data?.shopping_results || [];\n      const retailersSeen = new Set(results.map(r => r.retailer));\n\n      for (const item of items) {\n        const retailer = mapRetailer(item.source || \"\");\n        if (!retailer || retailersSeen.has(retailer)) continue;\n        const price = parseFloat(String(item.price || \"\").replace(\u002F[^0-9.]\u002Fg, \"\"));\n        if (!isNaN(price) && price > 0) {\n          results.push({ retailer, price });\n          retailersSeen.add(retailer);\n        }\n        if (results.length >= 4) break;\n      }\n    } catch (e) {\n      console.warn(\"SerpAPI error:\", e.message);\n    }\n  }\n\n  \u002F\u002F Fallback: use scraper API if both above failed\n  if (results.length === 0 && process.env.SCRAPER_API_KEY) {\n    try {\n      const walmartUrl = `https:\u002F\u002Fwww.walmart.com\u002Fsearch?q=${query}`;\n      const scraped = await axios.get(`http:\u002F\u002Fapi.scraperapi.com`, {\n        params: { api_key: process.env.SCRAPER_API_KEY, url: walmartUrl },\n        timeout: 12000,\n      });\n      \u002F\u002F Minimal price extraction from Walmart HTML\n      const priceMatch = scraped.data.match(\u002F\\$(\\d+\\.?\\d*)\u002F);\n      if (priceMatch) {\n        results.push({ retailer: \"Walmart\", price: parseFloat(priceMatch[1]) });\n      }\n    } catch (e) {\n      console.warn(\"Scraper API fallback error:\", e.message);\n    }\n  }\n\n  priceCache.set(cacheKey, { prices: results, ts: Date.now() });\n  return results;\n}\n\nfunction mapRetailer(source) {\n  const s = source.toLowerCase();\n  if (s.includes(\"amazon\"))   return \"Amazon\";\n  if (s.includes(\"walmart\"))  return \"Walmart\";\n  if (s.includes(\"target\"))   return \"Target\";\n  if (s.includes(\"best buy\") || s.includes(\"bestbuy\")) return \"Best Buy\";\n  if (s.includes(\"costco\"))   return \"Costco\";\n  if (s.includes(\"kroger\"))   return \"Kroger\";\n  if (s.includes(\"walgreen\")) return \"Walgreens\";\n  if (s.includes(\"cvs\"))      return \"CVS\";\n  return null; \u002F\u002F skip unknown retailers\n}\n\n\u002F\u002F ── PRICE HISTORY (heuristic) ──────────────────────────────\n\u002F\u002F Without a true price history DB, we approximate based on\n\u002F\u002F the spread between the lowest and typical prices seen.\n\u002F\u002F For a production integration, wire up CamelCamelCamel or\n\u002F\u002F Honey's price history API here.\nfunction computePriceHistory(prices) {\n  const validPrices = prices.filter(p => p.price != null).map(p => p.price);\n  if (validPrices.length === 0) return null;\n\n  const minPrice    = Math.min(...validPrices);\n  const maxPrice    = Math.max(...validPrices);\n  const avgPrice    = validPrices.reduce((a, b) => a + b, 0) \u002F validPrices.length;\n\n  \u002F\u002F Rough heuristic: if min price is >15% below average across retailers, suggest it's a deal\n  const discount    = (avgPrice - minPrice) \u002F avgPrice;\n  const isGoodDeal  = discount > 0.12 && validPrices.length >= 2;\n  const usualPrice  = parseFloat(maxPrice.toFixed(2));\n\n  return { usualPrice, isGoodDeal };\n}\n\n\u002F\u002F ── REVIEW LOOKUP ──────────────────────────────────────────\nasync function lookupReviews(product) {\n  \u002F\u002F Use LLM to synthesize review sentiment from product knowledge\n  \u002F\u002F For production, wire up Best Buy API, SerpAPI reviews, or a scraper.\n  try {\n    const msg = await anthropic.messages.create({\n      model:      \"claude-haiku-4-5-20251001\",\n      max_tokens: 256,\n      messages: [{\n        role:    \"user\",\n        content: `For the product \"${product.brand} ${product.name} ${product.variant}\":\nReturn a JSON object with review data (use your knowledge, no external lookup):\n{\n  \"rating\": {\n    \"score\": \u003Cnumber 1-5 or null if unknown>,\n    \"count\": \u003Capproximate review count or null>,\n    \"pros\": [\"\u003Ctop pro 1>\", \"\u003Ctop pro 2>\"],\n    \"cons\": [\"\u003Ctop con 1>\", \"\u003Ctop con 2>\"]\n  }\n}\nReturn only valid JSON.`,\n      }],\n    });\n    const text = msg.content[0]?.text?.trim() || \"{}\";\n    const raw  = text.replace(\u002F^```json\\s*\u002Fi, \"\").replace(\u002F```\\s*$\u002F, \"\").trim();\n    return JSON.parse(raw);\n  } catch (_) {\n    return {};\n  }\n}\n\n\u002F\u002F ── NUTRITION LOOKUP ───────────────────────────────────────\nasync function lookupNutrition(product) {\n  if (!product.isFood) return null;\n\n  \u002F\u002F Try Open Food Facts (free, no API key)\n  const searchQuery = encodeURIComponent(`${product.brand} ${product.name}`.trim());\n  try {\n    const resp = await axios.get(\n      `https:\u002F\u002Fworld.openfoodfacts.org\u002Fcgi\u002Fsearch.pl?search_terms=${searchQuery}&search_simple=1&action=process&json=1&page_size=1`,\n      { timeout: 8000 }\n    );\n    const item = resp.data?.products?.[0];\n    if (item?.nutriments) {\n      const n = item.nutriments;\n      return {\n        nutrients: {\n          calories: Math.round(n[\"energy-kcal_100g\"] || n[\"energy-kcal_serving\"] || 0) || null,\n          protein:  parseFloat((n[\"proteins_100g\"]   || n[\"proteins_serving\"]   || 0).toFixed(1)) || null,\n          carbs:    parseFloat((n[\"carbohydrates_100g\"] || n[\"carbohydrates_serving\"] || 0).toFixed(1)) || null,\n          fat:      parseFloat((n[\"fat_100g\"]         || n[\"fat_serving\"]         || 0).toFixed(1)) || null,\n          sodium:   Math.round((n[\"sodium_100g\"]      || n[\"sodium_serving\"]      || 0) * 1000) || null,\n          fiber:    parseFloat((n[\"fiber_100g\"]        || n[\"fiber_serving\"]       || 0).toFixed(1)) || null,\n        },\n        allergens: (item.allergens_tags || [])\n          .map(a => a.replace(\u002F^en:\u002F, \"\").replace(\u002F-\u002Fg, \" \"))\n          .filter(Boolean),\n        ingredientText: item.ingredients_text_en || item.ingredients_text || \"\",\n      };\n    }\n  } catch (e) {\n    console.warn(\"Open Food Facts error:\", e.message);\n  }\n\n  \u002F\u002F Fallback: ask LLM for approximate nutrition\n  try {\n    const msg = await anthropic.messages.create({\n      model:      \"claude-haiku-4-5-20251001\",\n      max_tokens: 200,\n      messages: [{\n        role:    \"user\",\n        content: `Give approximate per-serving nutrition for \"${product.brand} ${product.name} ${product.variant}\".\nReturn JSON:\n{\n  \"nutrients\": { \"calories\": \u003Cn>, \"protein\": \u003Cg>, \"carbs\": \u003Cg>, \"fat\": \u003Cg>, \"sodium\": \u003Cmg>, \"fiber\": \u003Cg> },\n  \"allergens\": [\"\u003Callergen>\"],\n  \"ingredientText\": \"\"\n}\nUse null for unknown values. Return only valid JSON.`,\n      }],\n    });\n    const text = msg.content[0]?.text?.trim() || \"{}\";\n    const raw  = text.replace(\u002F^```json\\s*\u002Fi, \"\").replace(\u002F```\\s*$\u002F, \"\").trim();\n    return JSON.parse(raw);\n  } catch (_) {\n    return null;\n  }\n}\n\n\u002F\u002F ── ALLERGEN CHECK ─────────────────────────────────────────\nfunction checkAllergens(nutritionData, dietRestrictions) {\n  if (!nutritionData) return [];\n\n  const foundAllergens = [];\n  const ingredients    = (nutritionData.ingredientText || \"\").toLowerCase();\n  const knownAllergens = (nutritionData.allergens || []).map(a => a.toLowerCase());\n\n  if (dietRestrictions.gluten) {\n    const terms = [\"wheat\", \"barley\", \"rye\", \"gluten\", \"spelt\", \"malt\"];\n    if (terms.some(t => ingredients.includes(t) || knownAllergens.some(a => a.includes(t)))) {\n      foundAllergens.push(\"Gluten\");\n    }\n  }\n  if (dietRestrictions.nuts) {\n    const terms = [\"peanut\", \"almond\", \"cashew\", \"walnut\", \"pecan\", \"pistachio\", \"hazelnut\", \"tree nut\"];\n    if (terms.some(t => ingredients.includes(t) || knownAllergens.some(a => a.includes(t)))) {\n      foundAllergens.push(\"Nuts\");\n    }\n  }\n  if (dietRestrictions.dairy) {\n    const terms = [\"milk\", \"cheese\", \"cream\", \"butter\", \"lactose\", \"whey\", \"casein\", \"dairy\"];\n    if (terms.some(t => ingredients.includes(t) || knownAllergens.some(a => a.includes(t)))) {\n      foundAllergens.push(\"Dairy\");\n    }\n  }\n  if (dietRestrictions.vegan) {\n    const terms = [\"meat\", \"chicken\", \"beef\", \"pork\", \"gelatin\", \"egg\", \"honey\", \"lard\", \"tallow\", \"milk\", \"cheese\", \"butter\"];\n    if (terms.some(t => ingredients.includes(t) || knownAllergens.some(a => a.includes(t)))) {\n      foundAllergens.push(\"Not vegan\");\n    }\n  }\n  if (dietRestrictions.sodium && nutritionData.nutrients?.sodium != null) {\n    if (nutritionData.nutrients.sodium > 600) {\n      foundAllergens.push(\"High sodium\");\n    }\n  }\n\n  return foundAllergens;\n}\n\n\u002F\u002F ── DIETARY TAGS ────────────────────────────────────────────\nfunction buildDietaryTags(nutritionData, allergens, dietRestrictions) {\n  const tags = [];\n  if (!nutritionData) return tags;\n\n  const ing   = (nutritionData.ingredientText || \"\").toLowerCase();\n  const known = (nutritionData.allergens || []).map(a => a.toLowerCase());\n\n  \u002F\u002F Positive tags\n  const hasGluten = [\"wheat\",\"barley\",\"rye\",\"gluten\"].some(t => ing.includes(t) || known.some(a => a.includes(t)));\n  if (!hasGluten) tags.push(\"Gluten-Free\");\n\n  const hasDairy  = [\"milk\",\"cheese\",\"cream\",\"butter\",\"lactose\",\"whey\"].some(t => ing.includes(t) || known.some(a => a.includes(t)));\n  if (!hasDairy)  tags.push(\"Dairy-Free\");\n\n  const hasNuts   = [\"peanut\",\"almond\",\"cashew\",\"walnut\",\"tree nut\"].some(t => ing.includes(t) || known.some(a => a.includes(t)));\n  if (!hasNuts)   tags.push(\"Nut-Free\");\n\n  const hasMeat   = [\"meat\",\"chicken\",\"beef\",\"pork\",\"gelatin\",\"lard\"].some(t => ing.includes(t));\n  const hasAnimal = hasDairy || ing.includes(\"egg\") || ing.includes(\"honey\") || hasMeat;\n  if (!hasAnimal) tags.push(\"Vegan\");\n\n  \u002F\u002F Warning tags from allergens\n  allergens.forEach(a => {\n    if (!tags.includes(a)) tags.push(a);\n  });\n\n  return tags;\n}\n\n\u002F\u002F ── UTILS ──────────────────────────────────────────────────\nfunction normKey(str) {\n  return str.toLowerCase().replace(\u002F[^a-z0-9]\u002Fg, \"\");\n}\n```\n\n### 5. Start OpenClaw\n\n```bash\nopenclaw serve\n```\n\nConfirm `shop-scout` appears in the registered skills list.\n\n## Camera integration\n\nThe skill uses a **camera proxy** running on your local machine to capture an image when R1 sends a scan command. You have two options:\n\n### Option A: Camera proxy (recommended)\n\nRun the included proxy server that captures a frame from your webcam or the R1 camera stream:\n\n```bash\ncd ~\u002F.openclaw\u002Fskills\u002Fshop-scout\nnode camera-proxy.js\n```\n\nCreate `camera-proxy.js`:\n\n```javascript\n\"use strict\";\nconst http  = require(\"http\");\nconst { exec } = require(\"child_process\");\nconst fs    = require(\"fs\");\nconst path  = require(\"path\");\n\nconst PORT = 7788;\n\n\u002F\u002F Uses ffmpeg to grab a single frame from your webcam (device 0)\nhttp.createServer((req, res) => {\n  if (req.url !== \"\u002Fcapture\") { res.writeHead(404); res.end(); return; }\n  const tmp = path.join(require(\"os\").tmpdir(), `shopscout-${Date.now()}.jpg`);\n  exec(`ffmpeg -y -f avfoundation -framerate 1 -i \"0\" -vframes 1 -q:v 2 \"${tmp}\" 2>\u002Fdev\u002Fnull`, (err) => {\n    if (err) {\n      res.writeHead(500);\n      res.end(\"Capture failed: \" + err.message);\n      return;\n    }\n    const data = fs.readFileSync(tmp);\n    fs.unlinkSync(tmp);\n    res.writeHead(200, { \"Content-Type\": \"image\u002Fjpeg\" });\n    res.end(data);\n  });\n}).listen(PORT, () => console.log(`Camera proxy listening on :${PORT}`));\n```\n\nOn macOS, replace `-f avfoundation -i \"0\"` with your device. On Linux use `-f v4l2 -i \u002Fdev\u002Fvideo0`. On Windows use `-f dshow -i video=\"USB Camera\"`.\n\n### Option B: R1 camera passthrough\n\nIf OpenClaw has a camera passthrough module, configure it to forward the R1 camera feed to `http:\u002F\u002Flocalhost:7788\u002Fcapture`. See the OpenClaw documentation for camera passthrough setup.\n\n## Command reference\n\n### `scan_product`\n\nSent when the user taps PTT on the Idle screen.\n\n**Params:**\n\n| Field | Type | Description |\n|---|---|---|\n| `dietRestrictions` | object | User's active dietary flags (`{gluten, vegan, nuts, dairy, kosher, sodium}`) |\n| `listItems` | string[] | Current shopping list item names (for list-match display) |\n| `imageBase64` | string\\|null | JPEG base64 if R1 passes the image directly; otherwise omitted |\n\n**Response:**\n\n| Field | Type | Description |\n|---|---|---|\n| `name` | string | Full product name |\n| `brand` | string | Brand name |\n| `variant` | string | Flavor, size, edition |\n| `barcode` | string\\|null | UPC\u002FEAN if detected |\n| `isFood` | boolean | Whether the product is food |\n| `prices` | array | `[{ retailer, price }]` sorted lowest first |\n| `priceHistory` | object | `{ usualPrice, isGoodDeal }` |\n| `rating` | object | `{ score, count, pros, cons }` |\n| `allergens` | string[] | Restriction violations detected |\n| `dietaryTags` | string[] | Positive and warning dietary labels |\n| `nutrition` | object | `{ calories, protein, carbs, fat, sodium, fiber }` (null if not food) |\n| `error` | string\\|null | Error message if identification failed |\n\n## Pricing data options\n\n| Provider | Free tier | Coverage | Notes |\n|---|---|---|---|\n| **SerpAPI** | 100 searches\u002Fmonth | Google Shopping (all retailers) | Fastest setup |\n| **Rainforest API** | 1,000 req\u002Fmonth | Amazon only | Most accurate for Amazon |\n| **Open Food Facts** | Unlimited | Food only (nutrition) | Free, no key required |\n| **Best Buy API** | Free | Best Buy only | Electronics with official pricing |\n| **ScraperAPI** | 5,000 req\u002Fmonth | Any retail site | Use as fallback |\n\nFor production shopping frequency (20–50 scans\u002Fday), a paid SerpAPI or Rainforest plan is recommended.\n\n## Troubleshooting\n\n**R1 shows blue LED forever — never gets a result**\n- Confirm `openclaw serve` is running and the skill is registered\n- Check `CAMERA_PROXY_URL` in `.env` matches your proxy address\n- Try `curl http:\u002F\u002Flocalhost:7788\u002Fcapture -o \u002Ftmp\u002Ftest.jpg` — if it fails, the camera proxy is the issue\n- Increase timeout in `R1.ocReceive({ timeoutMs: 45000 })` if your machine is slow\n\n**\"Could not identify a product\" error**\n- Move closer to the product — the barcode must be at least 50px wide in frame\n- Improve lighting — backlighting washes out barcodes\n- Try pointing at the product label instead of the barcode\n- The vision model needs a reasonably clear, non-blurry image\n\n**Prices are missing or all show \"N\u002FA\"**\n- Verify your `RAINFOREST_API_KEY` or `SERPAPI_KEY` is set and has quota\n- Check the OpenClaw process logs: `openclaw serve --verbose`\n- The pricing fan-out is non-fatal — the product still appears even if pricing fails\n\n**Allergen detection is inaccurate**\n- Open Food Facts may not have every product; the LLM fallback uses general knowledge\n- For critical allergies, always verify the physical label\n- The system errs toward false positives to protect users\n\n**LED stays red after allergen alert**\n- This is intentional — allergen state persists until the user scans a new product\n- Long-press PTT from the result screen to return to idle, which resets to green LED\n\n## Security notes\n\n- Camera images are sent to the Anthropic API (vision) only. They are not stored locally or transmitted elsewhere.\n- Product names and query terms are sent to the configured pricing API (SerpAPI or Rainforest).\n- No personal data or location is sent. Pricing lookups use the product name only.\n- Nutrition data is fetched from Open Food Facts, a public database — no identifying info is included.\n- The shopping list and dietary settings are stored on-device in R1 storage only.\n- Store your `.env` file securely. Do not commit API keys to version control.\n",{"name":5,"author":24,"version":25,"description":7},"rabbit-r1-skillz","1.0.0","main","734489c70f6293d3b800cd956559034acaa9f563","https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren","https:\u002F\u002Fgithub.com\u002Fajohnsonnow","structuredforgrowth.com","2026-09-04 21:06:25",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add ajohnsonnow\u002Fr1-warren --skill shop-scout",{"tool":38,"command":39},"bunx","bunx skills add ajohnsonnow\u002Fr1-warren --skill shop-scout",{"tool":41,"command":42},"pnpm","pnpm dlx skills add ajohnsonnow\u002Fr1-warren --skill shop-scout","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren\u002Fblob\u002Fmain\u002Fshop-scout\u002FSKILL.md",true,[46,52,56],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"card.jpg","ASSET","资产文件",19812,"https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren\u002Fblob\u002Fmain\u002Fshop-scout\u002Fcard.jpg",{"path":53,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":54,"sourceHtmlUrl":55},"icon.png",7805,"https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren\u002Fblob\u002Fmain\u002Fshop-scout\u002Ficon.png",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"index.html","REFERENCE","参考文档",53681,"https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren\u002Fblob\u002Fmain\u002Fshop-scout\u002Findex.html",[63,70,77,84,91,98],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M75THZJQ1XYR8QDWB9RXC9QV","whisper-quiz","WhisperQuiz — voice-answered trivia game for Rabbit R1. Generates questions via the R1's built-in LLM, captures spoken answers via STT, and evaluates correctness with flexible LLM-based matching.","https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren\u002Fblob\u002Fmain\u002Fwhisper-quiz\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M75THW5BJRSQQM3QP6M568FT","walk-cast","Walking podcast production skill. Receives raw audio metadata and transcript from the R1, removes long pauses, applies noise reduction and normalization, generates AI chapter titles and episode metadata via LLM, and uploads the final episode to your configured podcast RSS host (Spotify for Podcasters \u002F Anchor, Podbean, Buzzsprout, RSS.com, or any FTP-accessible feed).","https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren\u002Fblob\u002Fmain\u002Fwalk-cast\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M75THTANZTS2AMDDBP615RTA","voice-novel","Local machine skill for VoiceNovel — handles story export to disk.","https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren\u002Fblob\u002Fmain\u002Fvoice-novel\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M75THQ175ZRJ3E0GPFW7QKM8","voice-guide","Environment description and navigation assistant for blind and low-vision users. Analyzes camera frames via a vision LLM, reads visible text, identifies scene categories (people\u002Fvehicles\u002Ffood\u002Fhazards\u002Fexits), performs 360° scans, retrieves GPS position, and sends emergency SMS alerts — all via audio feedback with zero screen dependency.","https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren\u002Fblob\u002Fmain\u002Fvoice-guide\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M75THKAJR69WV7QQYJ26X95C","voice-draft","Voice-driven document drafting for the Rabbit R1. Dictate stream-of-consciousness speech; the R1 formats it into Email, Blog Post, Report, Proposal, Meeting Notes, Creative Writing, Code Comments, Cover Letter, or Tweet Thread — then saves the result to a configured folder on your local machine via OpenClaw.","https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren\u002Fblob\u002Fmain\u002Fvoice-draft\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M75THGKGY2JY59MM9PREXCXX","voice-commit","Hands-free git and CI workflow voice controller for the Rabbit R1. Speak git\u002FCI commands and hear results — commit, push, status, PR management, test runs, and deploy, all voice-driven via OpenClaw.","https:\u002F\u002Fgithub.com\u002Fajohnsonnow\u002Fr1-warren\u002Fblob\u002Fmain\u002Fvoice-commit\u002FSKILL.md",[],[]]