import type {
  OrganizationModelIconToken,
  OrganizationModelResourceKind,
  OrganizationModelSystemKind
} from '../types'
import type { OntologyKind } from '../ontology'

export type OmScaffoldIntent = 'system' | 'ontology' | 'resource' | 'knowledge'

export interface OmScaffoldWrite {
  path: string
  content: string
  description: string
  mode: 'create'
}

export interface OmScaffoldEdit {
  path: string
  description: string
  snippet: string
}

export interface OmScaffoldPlan {
  intent: OmScaffoldIntent
  id: string
  summary: string
  writes: OmScaffoldWrite[]
  edits: OmScaffoldEdit[]
  warnings: string[]
  nextSteps: string[]
  projectCommand?: string
}

export interface BaseOmScaffoldSpec {
  id: string
  label?: string
  description?: string
}

export interface SystemScaffoldSpec extends BaseOmScaffoldSpec {
  intent: 'system'
  parent?: string
  kind?: OrganizationModelSystemKind
  uiPath?: string
  icon?: OrganizationModelIconToken
  role?: string
  withOntology?: boolean
  noProject?: boolean
  withProject?: boolean
}

export interface OntologyRecordScaffoldSpec extends BaseOmScaffoldSpec {
  intent: 'ontology'
  systemPath: string
  kind: OntologyKind
  localId?: string
  withProject?: boolean
}

export interface ResourceScaffoldSpec extends BaseOmScaffoldSpec {
  intent: 'resource'
  systemPath: string
  kind?: OrganizationModelResourceKind
  ownerRoleId?: string
  withStubWorkflow?: boolean
  withProject?: boolean
}

export interface KnowledgeNodeScaffoldSpec extends BaseOmScaffoldSpec {
  intent: 'knowledge'
  systemPath?: string
  kind?: 'playbook' | 'strategy' | 'reference'
  ownerRoleId?: string
  withProject?: boolean
}

export type OmScaffoldSpec =
  | SystemScaffoldSpec
  | OntologyRecordScaffoldSpec
  | ResourceScaffoldSpec
  | KnowledgeNodeScaffoldSpec
