/** * Remote template fetcher for Trellis CLI * * Fetches spec templates from the official marketplace: * https://github.com/mindfold-ai/marketplace */ export declare const TEMPLATE_INDEX_URL = "https://raw.githubusercontent.com/mindfold-ai/marketplace/main/index.json"; /** Timeout constants for network operations */ export declare const TIMEOUTS: { /** Timeout for fetching the template index (ms) */ readonly INDEX_FETCH_MS: 5000; /** Timeout for downloading a template via giget (ms) */ readonly DOWNLOAD_MS: 30000; }; export interface SpecTemplate { id: string; type: string; name: string; description?: string; path: string; tags?: string[]; } export type TemplateStrategy = "skip" | "overwrite" | "append"; export type RegistryBackend = "http" | "git"; export type RegistrySourceKind = "prefixed" | "https" | "ssh"; export type RegistryErrorKind = "auth" | "git-unavailable" | "invalid-json" | "network" | "not-found" | "path-not-found" | "ref-not-found" | "unknown"; export declare class RegistryBackendError extends Error { readonly kind: RegistryErrorKind; constructor(kind: RegistryErrorKind, message: string); } export interface RegistryProbeResult { templates: SpecTemplate[]; isNotFound: boolean; backend: RegistryBackend; error?: RegistryBackendError; } export interface RegistrySource { /** Original provider prefix (e.g., "gh", "gitlab", "bitbucket") */ provider: string; /** Repository path (e.g., "myorg/myrepo") */ repo: string; /** Subdirectory within the repo (e.g., "marketplace" or "specs/my-template") */ subdir: string; /** Git ref / branch (default: "main") */ ref: string; /** Base URL for fetching raw files (e.g., index.json) */ rawBaseUrl: string; /** Full giget source string for downloading */ gigetSource: string; /** Custom host for self-hosted instances (e.g., "git.company.com"). Undefined for public providers. */ host?: string; /** Git remote URL used by git-backed registry access. */ gitUrl: string; /** Whether registry access should prefer Git over anonymous raw HTTP. */ preferGit: boolean; /** Input family used to derive credential behavior and clone URL shape. */ sourceKind: RegistrySourceKind; } export declare const SUPPORTED_PROVIDERS: string[]; /** * Convert an HTTPS URL to giget-style source format. * e.g. "https://github.com/user/repo" → "gh:user/repo" * "https://github.com/user/repo/tree/branch/path" → "gh:user/repo/path#branch" * Returns the original string if it's not a recognized HTTPS URL. */ export declare function normalizeRegistrySource(source: string): string; /** * Parse a giget-style registry source into its components. * * Supported input formats: * | Format | Example | Provider | Host? | * |-------------------------------------|----------------------------------------------|-----------|-----------| * | giget prefix | gh:org/repo, gitlab:org/repo#ref | native | no | * | Public HTTPS | https://github.com/org/repo | native | no | * | Public SSH | git@github.com:org/repo | native | no | * | Self-hosted HTTPS | https://git.corp.com/org/repo | gitlab | yes | * | Self-hosted SSH | git@git.corp.com:org/repo | gitlab | yes | * | ssh:// protocol (with/without port) | ssh://git@host:2222/org/repo | gitlab | yes | * | HTTPS with port | https://host:8443/org/repo | gitlab | yes | * | GitLab browse URL | https://host/org/repo/-/tree/branch/path | gitlab | yes | * * Ref defaults to "main" if not specified. * Unknown domains default to GitLab URL patterns (covers self-hosted GitLab CE/EE). * * @throws Error if provider is unsupported */ export declare function parseRegistrySource(source: string): RegistrySource; /** * Fetch available templates from the remote index * Returns empty array on network error or timeout (allows fallback to blank) * * @param indexUrl - URL to fetch index.json from (defaults to official marketplace) */ export declare function fetchTemplateIndex(indexUrl?: string): Promise; /** * Probe a registry's index.json, distinguishing "not found" from transient errors. * Used by the registry flow to decide marketplace vs direct-download mode. * * - 404 → { templates: [], isNotFound: true } * - Other HTTP error / network timeout → { templates: [], isNotFound: false } * - 200 + valid JSON → { templates: [...], isNotFound: false } */ export declare function probeRegistryIndex(indexUrl: string, registry?: RegistrySource): Promise; /** * Find a template by ID from the index */ export declare function findTemplate(templateId: string, indexUrl?: string): Promise; /** * Get the installation path for a template type */ export declare function getInstallPath(cwd: string, templateType: string): string; /** * Download a template with the specified strategy * * @param templatePath - Path in the docs repo (e.g., "marketplace/specs/electron-fullstack") * OR a full giget source (e.g., "gh:myorg/myrepo/my-spec") * @param destDir - Destination directory * @param strategy - How to handle existing directory: skip, overwrite, or append * @param repoSource - Optional giget repo source override. When set, templatePath is * treated as relative to this repo. When not set, uses TEMPLATE_REPO. * Pass null to use templatePath as a full giget source directly. * @returns true if template was downloaded, false if skipped */ export declare function downloadWithStrategy(templatePath: string, destDir: string, strategy: TemplateStrategy, repoSource?: string | null): Promise; /** * Download a template by ID * * @param cwd - Current working directory * @param templateId - Template ID from the index * @param strategy - How to handle existing directory * @param template - Optional pre-fetched SpecTemplate to avoid double-fetch * @param registry - Optional registry source (parsed). When set, uses the registry's * repo as the giget source instead of the default TEMPLATE_REPO. * @returns Object with success status and message */ export declare function downloadTemplateById(cwd: string, templateId: string, strategy: TemplateStrategy, template?: SpecTemplate, registry?: RegistrySource, destDirOverride?: string, registryBackend?: RegistryBackend): Promise<{ success: boolean; message: string; skipped?: boolean; }>; /** * Download a registry source directly to the spec directory (no index.json). * Used when the registry source points to a spec directory, not a marketplace. */ export declare function downloadRegistryDirect(cwd: string, registry: RegistrySource, strategy: TemplateStrategy, destDirOverride?: string, registryBackend?: RegistryBackend): Promise<{ success: boolean; message: string; skipped?: boolean; }>; //# sourceMappingURL=template-fetcher.d.ts.map