← Files JinkōARCHIVED FILE

skills/jinko-task-trial-data-scoping/scripts/common.py

658 Bytes · Oct 2, 2026 · 00:29 UTC

↓ Download file

"""Minimal helpers for the ClinicalTrials.gov scoping skill."""

from __future__ import annotations

import json
from pathlib import Path
from typing import Any


def write_json(path: Path, payload: Any) -> None:
    """Write a JSON artifact with stable indentation."""
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(json.dumps(payload, indent=2), encoding="utf-8")


def display_path(path: Path) -> str:
    """Return a path relative to cwd when possible, otherwise absolute."""
    resolved = path.resolve()
    try:
        return str(resolved.relative_to(Path.cwd().resolve()))
    except ValueError:
        return str(resolved)

SHA-256: 17e2bb05fb42c14c0c809663d545a48f969e8ed067393654392fc60928469492