← Commit history

0.2.114: project-page finds a part matched by its base MPN (closes #252)

Colby Knox ·53d06a5a48 · ·parent 51e1b81
Co-Authored-By: Claude Opus 5.5 <[email protected]>
8 files changed +82−17
Cargo.lock+10−10
@@ -4,7 +4,7 @@ version = 4  [[package]] name = "adom-aiflow"-version = "0.2.113"+version = "0.2.114" dependencies = [  "aiflow-analyze",  "aiflow-board",@@ -25,7 +25,7 @@ dependencies = [  [[package]] name = "aiflow-analyze"-version = "0.2.113"+version = "0.2.114" dependencies = [  "aiflow-board",  "serde",@@ -35,7 +35,7 @@ dependencies = [  [[package]] name = "aiflow-board"-version = "0.2.113"+version = "0.2.114" dependencies = [  "roxmltree",  "serde",@@ -44,7 +44,7 @@ dependencies = [  [[package]] name = "aiflow-bridge"-version = "0.2.113"+version = "0.2.114" dependencies = [  "aiflow-board",  "serde",@@ -53,7 +53,7 @@ dependencies = [  [[package]] name = "aiflow-copper"-version = "0.2.113"+version = "0.2.114" dependencies = [  "aiflow-board",  "aiflow-grid",@@ -63,7 +63,7 @@ dependencies = [  [[package]] name = "aiflow-grid"-version = "0.2.113"+version = "0.2.114" dependencies = [  "aiflow-board",  "serde",@@ -72,7 +72,7 @@ dependencies = [  [[package]] name = "aiflow-place"-version = "0.2.113"+version = "0.2.114" dependencies = [  "aiflow-board",  "serde",@@ -81,7 +81,7 @@ dependencies = [  [[package]] name = "aiflow-pours"-version = "0.2.113"+version = "0.2.114" dependencies = [  "aiflow-board",  "aiflow-copper",@@ -91,7 +91,7 @@ dependencies = [  [[package]] name = "aiflow-router"-version = "0.2.113"+version = "0.2.114" dependencies = [  "aiflow-board",  "aiflow-grid",@@ -102,7 +102,7 @@ dependencies = [  [[package]] name = "aiflow-run"-version = "0.2.113"+version = "0.2.114" dependencies = [  "serde",  "serde_json",
Cargo.toml+1−1
@@ -14,7 +14,7 @@ members = [ ]  [workspace.package]-version = "0.2.113"+version = "0.2.114" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
bin/adom-aiflow
⋯ 1 unchanged line ⋯
docs/release-0.2.114.mdadded+11
@@ -0,0 +1,11 @@+# adom-aiflow 0.2.114++## project-page: a part matched by its base MPN is in the library (issue #252, King Silver)++`parts` matches a BOM row whose orderable MPN carries a packing suffix to its base MPN's wiki page (`ABC1234,115` to `adom/abc1234`). `project-page` then looked for the exported symbol by the full MPN only, so it refused with "the KiCad library is incomplete: 1 of N parts are not in the exported library: ABC1234,115".++- The library completeness check now tries the same names `parts` matched by: the MPN, the MPN without its packaging suffix, and the matched page's own name.+- The suffix rules are the ones `parts` uses: `/OT` (MCP73831T-2ACI/OT), Nexperia's `,115`, and a tape-and-reel `-TR`, `-REEL` or `-RL` with optional digits. Before, only `/` was stripped.+- A part with no wiki match is still looked up by its MPN alone.++The workaround (giving the part from the project library with `"prefer": true`) is no longer needed.
package.json+1−1
@@ -1,7 +1,7 @@ {   "slug": "adom-aiflow",   "type": "app",-  "version": "0.2.113",+  "version": "0.2.114",   "title": "AI Flow",   "description": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. One Rust binary with a crate per step (placement helpers, a grid router with Kelvin taps, pours with keepouts, KiCad's DRC gate, live landing through the KiCad Bridge, copper measurement, current and thermal analysis) and a finish line that refuses an unfinished board. Every command answers with hints for the AI; every turn, its thinking time and every rework loop go into run.jsonl, so Claude, Codex and any other engine are compared on the same flow. KiCad, Fusion 360 and Altium Designer today (the same steps and gates through each tool's bridge); Adom's own web apps next.",   "summary": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. The AI thinks its way from placement through routing, pours, current and thermal analysis to a delivered video; the binary does the fast, deterministic parts of every step, hands back hints, and keeps a ledger of every turn, every return to an earlier step, and the clock from the prompt to done.",
page.json+1−1
@@ -1,7 +1,7 @@ {   "slug": "adom-aiflow",   "type": "app",-  "version": "0.2.113",+  "version": "0.2.114",   "title": "AI Flow",   "description": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. One Rust binary with a crate per step (placement helpers, a grid router with Kelvin taps, pours with keepouts, KiCad's DRC gate, live landing through the KiCad Bridge, copper measurement, current and thermal analysis) and a finish line that refuses an unfinished board. Every command answers with hints for the AI; every turn, its thinking time and every rework loop go into run.jsonl, so Claude, Codex and any other engine are compared on the same flow. KiCad, Fusion 360 and Altium Designer today (the same steps and gates through each tool's bridge); Adom's own web apps next.",   "summary": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. The AI thinks its way from placement through routing, pours, current and thermal analysis to a delivered video; the binary does the fast, deterministic parts of every step, hands back hints, and keeps a ledger of every turn, every return to an earlier step, and the clock from the prompt to done.",
tests/project-page-library.py+26
@@ -170,6 +170,15 @@ class ProjectPageLibrary(unittest.TestCase):         self.assertIn("AMPLH5030S-150MT", v["error"])         self.assertIn("1 of 3 parts are not in the exported library", v["error"]) +    def test_a_part_matched_by_its_base_mpn_is_in_the_library(self):+        # issue #252: the BOM's orderable MPN carries a packing suffix; `parts` matched the base MPN's page+        parts = self.parts()+        for p in parts:+            if p["wiki"] == "adom/l1-page": p["mpn"] += ",115"+        v = self.run_page(parts=parts)+        self.assertTrue(v["ok"], v)+        self.assertEqual(v["counts"]["distinctParts"], 3)+     def test_shared_footprint_and_model_pass(self):         # issue #76: two capacitors on one 0805 footprint, and the inductor's footprint using that same model         s = self.read_state()@@ -630,5 +639,22 @@ class StaleProjectLib(unittest.TestCase):             self.assertIn("parts --project-lib", msg["error"])  +class PackagingSuffix(unittest.TestCase):+    """Issue #252 (King Silver): a part `parts` matched to its base MPN's page (ABC1234,115 -> adom/abc1234) is+    found in the exported library by that page's symbol, as `parts` found the page."""+    def test_the_candidates_follow_the_parts_match(self):+        import importlib.util+        spec = importlib.util.spec_from_file_location("project_page", SCRIPT)+        mod = importlib.util.module_from_spec(spec); spec.loader.exec_module(mod)+        for mpn, base in [("ABC1234,115", "ABC1234"), ("MCP73831T-2ACI/OT", "MCP73831T-2ACI"), ("LM1117-TR13", "LM1117"),+                          ("BAT54-RL", "BAT54"), ("X1-REEL7", "X1"), ("R-TRIM", None), ("PART", None), ("ABC,1X", None)]:+            self.assertEqual(mod.mpn_base(mpn), base, mpn)+        self.assertEqual(mod.mpn_candidates({"mpn": "ABC1234,115", "wiki": "adom/abc1234"}), ["ABC1234,115", "ABC1234", "abc1234"])+        # a page under another slug (issue #178) is a candidate by its own name too+        self.assertIn("adom-1317", mod.mpn_candidates({"mpn": "XY-1317", "wiki": "adom/adom-1317"}))+        # no wiki match: the MPN alone+        self.assertEqual(mod.mpn_candidates({"mpn": "ABC1234,115"}), ["ABC1234,115"])++ if __name__ == "__main__":     unittest.main()
tools/project-page.py+32−4
@@ -47,12 +47,40 @@ ADD_CHUNK = 10   +def mpn_base(mpn):+    """The MPN without its packaging suffix, or None: the same rules `parts` matches a page by (preboard.rs+    mpn_base): "/OT" (MCP73831T-2ACI/OT, issue #161), Nexperia's ",115" (issue #252), and a tape-and-reel+    "-TR", "-REEL" or "-RL" with optional digits."""+    m = (mpn or "").strip()+    if "/" in m:+        b, rest = m.split("/", 1)+        if b.strip() and rest.strip():+            return b.strip()+    if "," in m:+        b, digits = m.rsplit(",", 1)+        if b.strip() and digits and digits.isdigit():+            return b.strip()+    up = m.upper()+    for suf in ("-TR", "-REEL", "-RL"):+        i = up.rfind(suf)+        tail = up[i + len(suf):]+        if i > 0 and (tail == "" or tail.isdigit()):+            return m[:i]+    return None++ def mpn_candidates(p):-    """The MPN, then the MPN without a packaging suffix (MCP73831T-2ACI/OT -> MCP73831T-2ACI) when the-    parts record matched the page that way (wikiMatch), so the page's symbol is found by its own name."""+    """The names a part's symbol may have in the exported library: the MPN, then (when `parts` matched it to a+    wiki page) the MPN without its packaging suffix and the page's own name, so a part `parts` matched by its+    base MPN (ABC1234,115 -> adom/abc1234, issue #252) is found by the page's symbol."""     out = [p["mpn"]]-    if p.get("wiki") and "/" in p["mpn"]:-        out.append(p["mpn"].split("/")[0])+    if p.get("wiki"):+        b = mpn_base(p["mpn"])+        if b:+            out.append(b)+        slug = str(p["wiki"]).rsplit("/", 1)[-1]+        if slug:+            out.append(slug)     return out  def clip(text, n=600):