import { BaseEntity } from '../../base/entity/base.js';
import { Column, Entity, Index } from 'typeorm';

/**
 * NetaClaw Skill — prompt-based skill 元数据与状态管理
 */
@Entity('netaclaw_skill')
export class NetaClawSkillEntity extends BaseEntity {
  @Column({ comment: 'Skill名称', length: 100, unique: true })
  name: string;

  @Column({ comment: '显示名称', length: 200 })
  label: string;

  @Column({ comment: '描述', type: 'text', nullable: true })
  description: string;

  @Column({ comment: 'Skill类型: compute/llm/multimodal', length: 20, nullable: true })
  skillType: string;

  @Column({ type: 'json', comment: '标签', nullable: true })
  tags: string[];

  @Index()
  @Column({ comment: '状态: 0=禁用 1=启用', default: 1 })
  status: number;

  @Column({ comment: '版本号', length: 20, nullable: true })
  version: string;

  @Column({ comment: '来源: local/github', length: 20, nullable: true })
  source: string;

  @Column({ comment: 'GitHub URL', length: 500, nullable: true })
  sourceUrl: string;

  @Column({ type: 'json', comment: '安装规格 (OpenClaw SkillInstallSpec 兼容)', nullable: true })
  installSpec: Record<string, unknown>[];

  @Column({ type: 'json', comment: '完整 frontmatter 元数据', nullable: true })
  metadata: Record<string, unknown>;

  @Column({ comment: '安装时间', type: 'datetime', nullable: true })
  installedAt: Date;

  @Column({ comment: 'SHA256 内容指纹', length: 64, nullable: true })
  fingerprint: string;

  @Column({ type: 'text', comment: 'skill secrets JSON', nullable: true })
  secrets: string;

  @Column({ type: 'json', comment: 'env 声明 schema', nullable: true })
  envSchema: Array<{ name: string; required: boolean; description?: string; default?: string }>;
}
