/**
 * Pure JSON serialiser for `olam repos list --json`.
 *
 * Kept separate from the command action so the wire contract is
 * unit-testable without a filesystem round-trip (mirrors the pattern
 * used by `auth-list-json.ts`, `renderPsJson` in ps.ts, and
 * `servicesStatusJson` in services.ts).
 *
 * WHY this exists: agent/script drivers (CI pipelines, Rico, flywheel
 * chain skills) need to discover registered repo paths before spawning
 * worlds or dispatching work with `--repo`. The human table is colorized
 * and reflows per terminal width, so scraping it is brittle and breaks
 * when column widths change. This serialiser gives drivers a stable,
 * color-free array: each entry carries the name, resolved path, and
 * optional metadata needed to pick a repo without re-querying the registry.
 *
 * Secret redaction: the optional `url` field can carry HTTPS credentials
 * in the URL userinfo component (e.g. `https://token:x-oauth-basic@github.com/...`).
 * The serialiser redacts userinfo credentials with `***` before emitting,
 * matching the same pattern used by `olam skills source list --json`.
 * The `path` field is a local filesystem path and carries no secrets.
 */
import { redactUrl } from '@olam/core/src/skill-sources/index.js';
/**
 * Serialise the global repo registry to the stable `--json` wire shape.
 * Returns a JSON string (no trailing newline — caller adds it).
 */
export function renderReposListJson(entries) {
    const rows = entries.map((e) => ({
        name: e.name,
        path: e.path,
        // Redact credentials from URL userinfo (e.g. `https://token:x@host` → `https://token:***@host`).
        url: e.url != null ? redactUrl(e.url) : null,
        description: e.description ?? null,
        defaultBranch: e.defaultBranch ?? null,
        addedAt: e.addedAt,
        updatedAt: e.updatedAt,
    }));
    const payload = {
        count: rows.length,
        repos: rows,
    };
    return JSON.stringify(payload);
}
//# sourceMappingURL=repos-list-json.js.map