/** * Shared types for GitOps UI components. * * V2 (agent-direct, REST over tunnel): These types mirror the normalised * shapes returned by `@vibecontrols/vibe-plugin-gitops` and registered * provider plugins. Source of truth lives in the meta plugin's * `src/types.ts`; this file MUST stay in sync. * * Legacy aliases (RepoStats, GitProviderType) are retained so the 15+ * existing card components keep compiling while the migration lands. */ export type ProviderName = 'github' | 'gitlab' | 'bitbucket' | 'azdevops'; export type GitVisibility = 'public' | 'private' | 'internal'; export type RepoFqn = string; export type GitProviderType = 'GITHUB' | 'GITLAB' | 'BITBUCKET' | 'AZURE_DEVOPS'; export declare function providerNameFromLegacy(t: GitProviderType): ProviderName; export interface NormalisedRepo { fqn: RepoFqn; provider: string; visibility: GitVisibility; defaultBranch: string; description?: string; language?: string; topics?: string[]; isArchived: boolean; isFork: boolean; size?: number; stars?: number; forks?: number; watchers?: number; url: string; createdAt: string; updatedAt: string; pushedAt?: string; } export interface PullRequest { id: string; number: number; title: string; state: 'open' | 'closed' | 'merged'; isDraft: boolean; author: string; reviewers: string[]; reviewDecision?: 'APPROVED' | 'CHANGES_REQUESTED' | 'REVIEW_REQUIRED'; mergeState?: 'clean' | 'dirty' | 'blocked' | 'unstable' | 'behind'; createdAt: string; updatedAt: string; mergedAt?: string; durationOpenSeconds?: number; url: string; labels: string[]; } export interface Pipeline { id: string; name: string; state: 'active' | 'disabled'; path?: string; } export interface PipelineJob { id: string; name: string; status: string; conclusion?: string; startedAt?: string; completedAt?: string; durationSeconds?: number; } export interface PipelineRun { id: string; pipelineName: string; branch: string; status: 'queued' | 'running' | 'completed' | 'waiting'; conclusion?: 'success' | 'failure' | 'cancelled' | 'skipped' | 'timed_out' | 'neutral'; event?: string; startedAt?: string; completedAt?: string; durationSeconds?: number; url: string; actor: string; jobs?: PipelineJob[]; commitSha?: string; commitMessage?: string; } export interface SecurityAlert { id: string; type: 'code-scan' | 'secret-scan' | 'dependency' | 'advisory'; severity: 'critical' | 'high' | 'medium' | 'low' | 'info'; state: 'open' | 'dismissed' | 'fixed'; title: string; url: string; ruleId?: string; ecosystem?: string; cve?: string; createdAt: string; } export interface AuthInput { kind: 'pat' | 'oauth' | 'app'; token: string; meta?: Record; } export interface AuthValidation { ok: boolean; account?: string; scopes?: string[]; expiresAt?: string; message?: string; } export interface HealthSnapshot { ok: boolean; rateLimit?: { remaining: number; resetAt: string; }; message?: string; } export interface ProviderSnapshot { name: string; isDefault: boolean; registered: boolean; authenticated: boolean; health: HealthSnapshot; } export interface Branch { name: string; isProtected: boolean; lastCommitSha: string; } export interface Contributor { login: string; contributions: number; avatarUrl?: string; } export interface IssueSummary { id: string; number: number; title: string; state: string; labels: string[]; url: string; createdAt: string; } export interface RepoPage { items: NormalisedRepo[]; nextCursor?: string; } export interface PullRequestAnalytics { slowest: PullRequest[]; fastest: PullRequest[]; medianAgeHours: number; awaitingReview: PullRequest[]; awaitingApproval: PullRequest[]; } export interface PipelineAnalytics { successRate: number; durationP50: number; durationP95: number; slowest: PipelineRun[]; fastest: PipelineRun[]; running: PipelineRun[]; queued: PipelineRun[]; pendingApproval: PipelineRun[]; totalRunsLast30Days: number; } export interface OrgRollup { totalRepos: number; byVisibility: Record; byLanguage: Record; archived: number; stale30d: number; totalOpenPRs: number; totalOpenIssues: number; } /** Legacy CI types — kept for compatibility with existing CITab/charts. */ export interface CIWorkflow { id: string; name: string; state: string; path?: string | null; } export interface CIPipelineRun { id: string; workflowName: string; branch: string; status: string; conclusion?: string | null; event?: string | null; startedAt?: string | null; completedAt?: string | null; durationSeconds?: number | null; url?: string | null; actor?: string | null; } export interface CIStatus { workflows: CIWorkflow[]; recentRuns: CIPipelineRun[]; successRate?: number | null; averageDurationSeconds?: number | null; totalRunsLast30Days?: number | null; } /** Legacy repo-stats type aggregated from v2 normalised types. */ export interface RepoStats { owner: string; name: string; fullName: string; description?: string | null; visibility: string; defaultBranch: string; openPullRequests: number; openIssues: number; forkCount: number; stargazerCount: number; watcherCount?: number | null; diskUsageKb?: number | null; dependabotAlerts: number; commitActivity?: Array<{ week: string; total: number; additions: number; deletions: number; }> | null; contributors?: Array<{ login: string; contributions: number; avatarUrl?: string | null; }> | null; languages?: Record | null; license?: string | null; isArchived: boolean; isFork: boolean; createdAt?: string | null; updatedAt?: string | null; pushedAt?: string | null; pullRequests?: PullRequest[] | null; } /** Legacy provider record. Only `id`, `providerType`, `repoUrl`, `isActive` * are used by the UI. After v2 the "provider" concept on the backend is * gone — this type is now synthesised from the agent's auth state. */ export interface GitopsProvider { id: string; workspaceId: string; vibeId?: string | null; name: string; providerType: GitProviderType; repoUrl: string; isActive: boolean; metadata?: string | null; createdAt: string; updatedAt?: string | null; createdBy?: string | null; } export interface ComposeRepoStatsInput { repo: NormalisedRepo | null | undefined; pulls?: PullRequest[]; issues?: IssueSummary[]; languages?: Record; contributors?: Contributor[]; securityAlerts?: SecurityAlert[]; } /** Build the legacy RepoStats shape from the new normalised fragments. */ export declare function composeRepoStats(input: ComposeRepoStatsInput): RepoStats | null; export interface ComposeCiStatusInput { pipelines?: Pipeline[]; runs?: PipelineRun[]; analytics?: PipelineAnalytics; } export declare function composeCiStatus(input: ComposeCiStatusInput): CIStatus;