import { type SchemaType } from "@pulsemcp/air-core"; import { type InitConfigResult, type ScaffoldedFile } from "./init.js"; /** Error codes for `initFromRepo` failures. */ export type InitFromRepoErrorCode = "EXISTS" | "NO_GIT" | "NO_REMOTE" | "NO_GITHUB" | "NO_ARTIFACTS"; /** * Typed error thrown by `initFromRepo` for classifiable failure conditions. * Consumers can switch on `code` instead of matching error messages. */ export declare class InitFromRepoError extends Error { readonly code: InitFromRepoErrorCode; constructor(message: string, code: InitFromRepoErrorCode); } export interface InitFromRepoOptions { /** Working directory (must be inside a git repo). Defaults to process.cwd(). */ cwd?: string; /** Path for the generated air.json. Defaults to ~/.air/air.json. */ path?: string; /** Overwrite existing air.json if it exists. */ force?: boolean; } export interface DiscoveredArtifact { /** Artifact type (skills, references, mcp, etc.) */ type: SchemaType; /** Path relative to repo root. */ repoPath: string; /** Generated github:// URI. */ uri: string; } export interface InitFromRepoResult { /** Absolute path to the created air.json. */ airJsonPath: string; /** Absolute path to the AIR config directory. */ airDir: string; /** GitHub owner/repo detected from git remote. */ repo: string; /** Branch used for github:// URIs. */ branch: string; /** Discovered artifact files grouped by type. */ discovered: DiscoveredArtifact[]; /** Whether an existing config was overwritten. */ overwritten: boolean; /** Local index files and README scaffolded into `airDir` alongside the discovered remote URIs. */ scaffolded: ScaffoldedFile[]; } /** * Parse a git remote URL and extract the GitHub owner/repo. * Supports HTTPS and SSH formats. * * @returns "owner/repo" string * @throws Error if the URL is not a github.com URL */ export declare function parseGitHubRemote(remoteUrl: string): string; /** * Detect the default branch name for the remote. * * Tries `git symbolic-ref refs/remotes/origin/HEAD` first, * then checks for common branch names (main, master). * Falls back to "main". */ export declare function detectDefaultBranch(cwd: string): string; /** * Discover AIR artifact index files in the git repository. * * Lists tracked JSON files via `git ls-files`, detects their schema type * by filename, and confirms they are parseable JSON objects. Returns files * that are plausible artifact indexes (full schema validation is deferred * to `air validate`). */ export declare function discoverArtifacts(repoRoot: string, repo: string, branch: string): DiscoveredArtifact[]; /** * Initialize an AIR config from artifact files discovered in a git repository. * * Scans the git repo for artifact index files (skills.json, mcp.json, etc.), * detects the GitHub remote, and generates an air.json with github:// URIs * pointing to the repository's default branch. Only artifact types that have * existing index files in the repo are included — nothing is auto-generated. * * @throws Error if not in a git repo, no GitHub remote, no artifacts found, * or air.json already exists (unless force is true). */ export declare function initFromRepo(options?: InitFromRepoOptions): InitFromRepoResult; /** Result from `smartInit` — discriminated by `mode`. */ export type SmartInitResult = ({ mode: "repo"; } & InitFromRepoResult) | ({ mode: "blank"; } & InitConfigResult) | ({ mode: "topup"; } & InitConfigResult); /** * High-level init that tries repo-based discovery first and falls back to * blank scaffolding when no git context or artifacts are available. * * When `air.json` already exists and `--force` isn't set, falls back to * "topup" mode: leaves the existing config untouched but scaffolds any * missing index files or README. This provides a safe upgrade path for * users initialized on older versions that didn't scaffold all pieces. * * @throws Error for unexpected failures (non-InitFromRepoError). */ export declare function smartInit(options?: InitFromRepoOptions): SmartInitResult; //# sourceMappingURL=init-from-repo.d.ts.map