Apply a patch and return a per-edit report for observability.
(
skill: str,
patch: PatchType | dict,
)
| 163 | |
| 164 | |
| 165 | def apply_patch_with_report( |
| 166 | skill: str, |
| 167 | patch: PatchType | dict, |
| 168 | ) -> tuple[str, list[dict]]: |
| 169 | """Apply a patch and return a per-edit report for observability.""" |
| 170 | edits = patch.edits if hasattr(patch, "edits") else patch.get("edits", []) |
| 171 | reports: list[dict] = [] |
| 172 | for idx, edit in enumerate(edits, 1): |
| 173 | try: |
| 174 | skill, report = _apply_edit_with_report(skill, edit) |
| 175 | report["index"] = idx |
| 176 | except Exception as exc: # noqa: BLE001 |
| 177 | report = { |
| 178 | "index": idx, |
| 179 | "op": "", |
| 180 | "target": "", |
| 181 | "content_preview": "", |
| 182 | "status": "error", |
| 183 | "error": str(exc), |
| 184 | } |
| 185 | reports.append(report) |
| 186 | return skill, reports |
| 187 | |
| 188 | |
| 189 | def apply_patch(skill: str, patch: PatchType | dict) -> str: |
no test coverage detected