/**
 * init CLI types — Input spec and output result
 */

import { z } from 'zod';

export const InitSpecSchema = z.object({
  url: z.string().url().optional(),
  root: z.string().optional(),
  name: z.string().optional(),
  mode: z.enum(['organized', 'simple', 'disabled']).default('organized'),
});

export type InitSpec = z.infer<typeof InitSpecSchema>;

export const InitResultSchema = z.object({
  success: z.boolean(),
  needsInput: z.boolean().optional(),
  detected: z.object({
    platform: z.string(),
    provider: z.string(),
    branches: z.object({
      main: z.string(),
      develop: z.string(),
    }).optional(),
    version: z.string().optional(),
  }).optional(),
  config: z.object({
    version: z.string(),
    workspace: z.object({
      path: z.string(),
      name: z.string(),
    }),
    repository: z.object({
      name: z.string(),
      rootFolder: z.string(),
      remoteUrl: z.string(),
      defaultBranch: z.string(),
    }),
    git: z.object({
      provider: z.string(),
      branches: z.object({
        main: z.string(),
        develop: z.string(),
      }),
    }),
    worktree: z.object({
      mode: z.enum(['organized', 'simple', 'disabled']),
      rootPath: z.string().optional(),
    }).optional(),
  }).optional(),
  structure: z.object({
    configPath: z.string(),
    worktreeDir: z.string().optional(),
  }).optional(),
  validation: z.object({
    blockers: z.array(z.string()),
    warnings: z.array(z.string()),
  }).optional(),
  error: z.string().optional(),
});

export type InitResult = z.infer<typeof InitResultSchema>;
