← Commit history

v2.1.2: Any `--limit` works again. The wiki's parts-search route takes 3, 5 or 10, so `--limit 2` (or 7, or 25) came back as an error in every vendor column. Parts Search now asks for the smallest of those that covers the limit, 10 at most, and shows only as many hits as you asked for.

Ray ·232b010d41 · ·parent a3c420d
8 files changed +29−89
Cargo.lock+1−1
@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"  [[package]] name = "adom-parts-search"-version = "2.1.1"+version = "2.1.2" dependencies = [  "base64",  "clap",
Cargo.toml+1−1
@@ -1,6 +1,6 @@ [package] name = "adom-parts-search"-version = "2.1.1"+version = "2.1.2" edition = "2021" description = "Parts Search Electronics component search — CLI, backend HTTP service, and Hydrogen webview app" license = "MIT"
VERSION+1−1
@@ -1 +1 @@-2.1.1+2.1.2
install.sh

  
package.json+1−40
@@ -34,44 +34,5 @@     "SKILL.md",     "BUILD-SKILL.md",     "CHANGELOG.md"-  ],-  "changelog": "Any `--limit` works again. The wiki's parts-search route takes 3, 5 or 10, so `--limit 2` (or 7, or 25) came back as an error in every vendor column. Parts Search now asks for the smallest of those that covers the limit, 10 at most, and shows only as many hits as you asked for.",-  "discovery_triggers": [-    "parts search",-    "find part",-    "source component",-    "source part",-    "compare distributors",-    "compare vendors",-    "Mouser or DigiKey",-    "BOM sourcing",-    "price this part",-    "where can I get",-    "check stock",-    "parts availability",-    "fastest delivery",-    "cheapest part",-    "component search",-    "part lookup",-    "price breaks"-  ],-  "discovery_pitch": "Search Mouser, DigiKey and JLCPCB in parallel with product photos; Mouser-preferred best-source pick. Say 'with parts search' to your AI.",-  "sample_prompts": [-    {-      "label": "source an STM32F103RBT6",-      "prompt": "source an STM32F103RBT6"-    },-    {-      "label": "where can I get an ESP32-S3-WROOM cheape",-      "prompt": "where can I get an ESP32-S3-WROOM cheapest and fastest"-    },-    {-      "label": "compare Mouser, DigiKey and JLCPCB for a",-      "prompt": "compare Mouser, DigiKey and JLCPCB for an LM555"-    },-    {-      "label": "price this BOM across distributors",-      "prompt": "price this BOM across distributors"-    }   ]-}\ No newline at end of file+}
page.json+8−45
@@ -33,25 +33,13 @@   },   "hero": {     "type": "image",-    "path": "screenshots/hero.png"+    "path": "docs/hero.png"   },   "sample_prompts": [-    {-      "label": "source an STM32F103RBT6",-      "prompt": "source an STM32F103RBT6"-    },-    {-      "label": "where can I get an ESP32-S3-WROOM cheape",-      "prompt": "where can I get an ESP32-S3-WROOM cheapest and fastest"-    },-    {-      "label": "compare Mouser, DigiKey and JLCPCB for a",-      "prompt": "compare Mouser, DigiKey and JLCPCB for an LM555"-    },-    {-      "label": "price this BOM across distributors",-      "prompt": "price this BOM across distributors"-    }+    "source an STM32F103RBT6",+    "where can I get an ESP32-S3-WROOM cheapest and fastest",+    "compare Mouser, DigiKey and JLCPCB for an LM555",+    "price this BOM across distributors"   ],   "discovery_triggers": [     "parts search",@@ -66,37 +54,12 @@     "where can I get",     "check stock",     "parts availability",-    "fastest delivery",-    "cheapest part",-    "component search",-    "part lookup",-    "price breaks"+    "fastest delivery"   ],-  "discovery_pitch": "Search Mouser, DigiKey and JLCPCB in parallel with product photos; Mouser-preferred best-source pick. Say 'with parts search' to your AI.",+  "discovery_pitch": "Search Mouser + DigiKey + JLCPCB in parallel from one interface, with product photos and a Mouser-preferred best-source pick.",   "metadata": {     "platform": "linux"   },   "category": "tools",-  "org": "adom",-  "description": "One search box across Mouser, DigiKey and JLCPCB. Parallel queries, side-by-side product photos, and a Mouser-preferred recommendation that reasons around stock and lead time. Dock Bar ready: serve, health, settings, Say it.",-  "dependencies": {},-  "needs_sudo": false,-  "scripts": {-    "install": "./install.sh",-    "uninstall": "./uninstall.sh"-  },-  "files": [-    "bin/**",-    "skills/**",-    "docs/icon.svg",-    "dockbar.json",-    "install.sh",-    "uninstall.sh",-    "package.json",-    "README.md",-    "SKILL.md",-    "BUILD-SKILL.md",-    "CHANGELOG.md"-  ],-  "changelog": "Any `--limit` works again. The wiki's parts-search route takes 3, 5 or 10, so `--limit 2` (or 7, or 25) came back as an error in every vendor column. Parts Search now asks for the smallest of those that covers the limit, 10 at most, and shows only as many hits as you asked for."+  "org": "adom" }\ No newline at end of file
src/vendors.rs+17−1
@@ -468,6 +468,12 @@ fn skipped_block(url: String) -> VendorBlock {     } } +/// The wiki's parts-search route takes a limit of 3, 5 or 10 (one cache entry per size): ask for the smallest of those+/// that covers `limit` (10 at most) and cut the hits back to `limit` here.+pub fn route_limit(limit: u32) -> u32 {+    [3, 5, 10].into_iter().find(|&n| n >= limit).unwrap_or(10)+}+ pub fn search_all(     query: &str,     limit: u32,@@ -490,7 +496,7 @@ pub fn search_all(         .into_iter().filter(|(_, on)| *on).map(|(v, _)| v).collect();     let t0 = std::time::Instant::now();     let answer = if vendors.is_empty() { Err("every vendor is switched off in Settings".to_string()) }-        else { crate::wiki::post_route(&route, json!({"q": q, "limit": limit, "in_stock_only": in_stock_only, "jlcpcb_basic": opts.jlcpcb_basic, "vendors": vendors})) };+        else { crate::wiki::post_route(&route, json!({"q": q, "limit": route_limit(limit), "in_stock_only": in_stock_only, "jlcpcb_basic": opts.jlcpcb_basic, "vendors": vendors})) };     let elapsed = t0.elapsed().as_millis() as u64;      let mut agg = AggregatedResults { query: query.into(), ..Default::default() };@@ -508,6 +514,8 @@ pub fn search_all(                     total: 0, hits: vec![], backend_url: route.url.clone(), elapsed_ms: elapsed, ..Default::default() },             }         };+        let mut block = block;+        block.hits.truncate(limit.max(1) as usize);         match vendor { Vendor::Mouser => agg.mouser = block, Vendor::DigiKey => agg.digikey = block, Vendor::JLCPCB => agg.jlcpcb = block }     }     agg.parts_search = Some(match &answer {@@ -965,3 +973,11 @@ mod empty_state_tests {         assert!(!e.explanation.contains("erroring"));     } }++#[cfg(test)]+mod route_limit_tests {+    #[test]+    fn rounds_up_to_an_allowed_size() {+        assert_eq!([0, 1, 2, 3, 4, 5, 6, 10, 25].map(super::route_limit), [3, 3, 3, 3, 5, 5, 10, 10, 10]);+    }+}
uninstall.sh