Load the most recent active SkillRecord whose ``path`` is inside *skill_dir*. Used by ``upload_skill`` to retrieve pre-computed upload metadata (origin, parents, change_summary, etc.) from the DB when ``.upload_meta.json`` is missing. The match uses ``path LIKE '{sk
(self, skill_dir: str)
| 716 | |
| 717 | @_db_retry() |
| 718 | def load_record_by_path(self, skill_dir: str) -> Optional[SkillRecord]: |
| 719 | """Load the most recent active SkillRecord whose ``path`` is inside *skill_dir*. |
| 720 | |
| 721 | Used by ``upload_skill`` to retrieve pre-computed upload metadata |
| 722 | (origin, parents, change_summary, etc.) from the DB when |
| 723 | ``.upload_meta.json`` is missing. |
| 724 | |
| 725 | The match uses ``path LIKE '{skill_dir}%'`` so both |
| 726 | ``/a/b/SKILL.md`` and ``/a/b/scenarios/x.md`` match ``/a/b``. |
| 727 | Returns the newest active record (by ``last_updated DESC``). |
| 728 | """ |
| 729 | normalized = skill_dir.rstrip("/") |
| 730 | with self._reader() as conn: |
| 731 | row = conn.execute( |
| 732 | "SELECT * FROM skill_records " |
| 733 | "WHERE path LIKE ? AND is_active=1 " |
| 734 | "ORDER BY last_updated DESC LIMIT 1", |
| 735 | (f"{normalized}%",), |
| 736 | ).fetchone() |
| 737 | return self._to_record(conn, row) if row else None |
| 738 | |
| 739 | @_db_retry() |
| 740 | def get_versions(self, name: str) -> List[SkillRecord]: |
no test coverage detected