sanitize.py
python
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439
feat: K1-P1 complete — agent provenance, build-verification…
Sonnet 4.6
patch
54 days ago
| 1 | """Sanitize CLI output to avoid absolute machine paths (§K4.9).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | |
| 8 | def sanitize_text(text: str, repo_root: Path) -> str: |
| 9 | """Replace the resolved repo root prefix with ``.`` in free-form text.""" |
| 10 | root = str(repo_root.resolve()) |
| 11 | return text.replace(root, ".") |
| 12 | |
| 13 | |
| 14 | def format_config_error(exc, repo_root: Path) -> str: |
| 15 | """Format a config error without leaking absolute paths.""" |
| 16 | return exc.message |
| 17 | |
| 18 | |
| 19 | def config_exit_code(exc) -> int: |
| 20 | """Map a ``ConfigError`` to its CLI exit code (default ``2``).""" |
| 21 | code = getattr(exc, "exit_code", None) |
| 22 | return code if isinstance(code, int) else 2 |
File History
1 commit
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439
feat: K1-P1 complete — agent provenance, build-verification…
Sonnet 4.6
patch
54 days ago