# Generated by Django 5.2.9 on 2026-03-18

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("prompt", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="TerminalCommandORM",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        db_index=True,
                        help_text="命令名称（如：analyze, report）",
                        max_length=50,
                        unique=True,
                    ),
                ),
                ("description", models.TextField(blank=True, help_text="命令描述")),
                (
                    "command_type",
                    models.CharField(
                        choices=[("prompt", "Prompt模板调用"), ("api", "API端点调用")],
                        default="prompt",
                        help_text="命令类型",
                        max_length=20,
                    ),
                ),
                ("system_prompt", models.TextField(blank=True, help_text="系统提示词（可选）")),
                ("user_prompt_template", models.TextField(blank=True, help_text="用户Prompt模板")),
                (
                    "api_endpoint",
                    models.CharField(blank=True, help_text="API端点路径（command_type=api时使用）", max_length=255),
                ),
                (
                    "api_method",
                    models.CharField(default="GET", help_text="HTTP方法（GET/POST）", max_length=10),
                ),
                (
                    "response_jq_filter",
                    models.CharField(blank=True, help_text="JQ过滤器，从API响应中提取数据", max_length=255),
                ),
                ("parameters", models.JSONField(blank=True, default=list, help_text="参数定义列表")),
                ("timeout", models.IntegerField(default=60, help_text="超时时间（秒）")),
                (
                    "provider_name",
                    models.CharField(blank=True, help_text="默认AI提供商名称", max_length=100),
                ),
                ("model_name", models.CharField(blank=True, help_text="默认模型名称", max_length=100)),
                (
                    "category",
                    models.CharField(
                        db_index=True,
                        default="general",
                        help_text="命令分类",
                        max_length=50,
                    ),
                ),
                ("tags", models.JSONField(blank=True, default=list, help_text="标签列表")),
                ("is_active", models.BooleanField(db_index=True, default=True, help_text="是否启用")),
                ("created_at", models.DateTimeField(auto_now_add=True, help_text="创建时间")),
                ("updated_at", models.DateTimeField(auto_now=True, help_text="更新时间")),
                (
                    "prompt_template",
                    models.ForeignKey(
                        blank=True,
                        help_text="关联的Prompt模板（command_type=prompt时使用）",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="terminal_commands",
                        to="prompt.prompttemplateorm",
                    ),
                ),
            ],
            options={
                "verbose_name": "终端命令",
                "verbose_name_plural": "终端命令配置",
                "db_table": "terminal_command",
                "ordering": ["category", "name"],
                "indexes": [
                    models.Index(fields=["category", "is_active"], name="terminal_co_categor_efb8c5_idx"),
                    models.Index(fields=["command_type", "is_active"], name="terminal_co_command_2c5218_idx"),
                ],
            },
        ),
    ]
