/** Vigthoria GOA Core Orchestrator — V1.0 execution payload (machine-readable only). */

export type WorkspaceType = 'GREENFIELD' | 'BROWNFIELD';

export type GoaEngine = 'CLI_TEMPLATE' | 'AST_TRANSFORMER' | 'STABILIZATION';

export type GoaCommand =
  | 'EXECUTE_TEMPLATE_INJECTION'
  | 'EXECUTE_AST_MUTATION'
  | 'RUN_STABILIZATION_CHECK';

export type AstOperation =
  | 'ADD_IMPORT'
  | 'REPLACE_BODY'
  | 'INJECT_WRAPPER'
  | 'APPEND_PROPERTY'
  | 'INSERT_BEFORE';

export interface GoaInstructionPayload {
  template_id?: string | null;
  file_path?: string;
  target_dir?: string;
  operation?: AstOperation | null;
  target_node?: string;
  variables?: Record<string, string>;
  code_payload?: string;
  query?: string;
}

export interface GoaInstruction {
  sequence: number;
  engine: GoaEngine;
  command: GoaCommand;
  payload: GoaInstructionPayload;
}

export interface GoaAnalysis {
  detected_framework?: string;
  target_files: string[];
  anchor_hint?: string;
  template_match?: string;
  metadata_summary?: string;
  dependency_graph?: Record<string, unknown>;
}

export interface GoaExecutionPayload {
  workspace_type: WorkspaceType;
  analysis: GoaAnalysis;
  instructions: GoaInstruction[];
}

export interface GoaArchitectInput {
  userPrompt: string;
  workspaceRoot: string;
  isExistingProject: boolean;
  frameworkHint?: string;
  astMetadata?: Record<string, unknown> | null;
  templateMatch?: { id: string; category: string; confidence: number } | null;
}

export interface GoaExecutionResult {
  payload: GoaExecutionPayload;
  layer: 'architect' | 'execution' | 'stabilization';
  success: boolean;
  output?: string;
  error?: string;
  raw?: Record<string, unknown>;
}

export interface TemplateCatalogEntry {
  id: string;
  category: string;
  name: string;
  variables: string[];
  useWhen: string[];
}

export interface TemplateCategoryCatalog {
  category: string;
  label: string;
  count: number;
  templates: TemplateCatalogEntry[];
}
