/**
 * Example agent harness task definitions — demonstrates the agent-harness mode.
 *
 * Three tasks of increasing complexity:
 * 1. Scaffold a project from template
 * 2. Modify existing code following docs
 * 3. Multi-file refactoring task
 */
// ---------------------------------------------------------------------------
// Task 1: Scaffold a project from template
// ---------------------------------------------------------------------------
export const scaffoldProjectTask = {
    mode: "agent-harness",
    id: "agent-scaffold-project",
    title: "Scaffold a Sanity Studio Project",
    description: "The agent should create a new Sanity Studio project following the " +
        "official documentation. It should use the CLI to initialize the project, " +
        "configure sanity.config.ts, and set up basic schema types.",
    area: "studio",
    difficulty: "basic",
    tags: ["agent", "scaffold", "studio"],
    sandbox: {
        type: "tempdir",
    },
    tools: ["coding"],
    fixtures: ["file://fixtures/package-scaffold.json"],
    prompt: {
        text: "Create a new Sanity Studio project with the following requirements:\n" +
            "1. Initialize with `npm create sanity@latest`\n" +
            "2. Configure sanity.config.ts with project ID 'test-project' and dataset 'production'\n" +
            "3. Create a 'post' schema type with title, slug, body, and author fields\n" +
            "4. Ensure the project builds without errors",
    },
    assertions: [
        { type: "file-exists", value: "sanity.config.ts" },
        { type: "file-exists", value: "schemaTypes/post.ts" },
        {
            type: "file-contains",
            value: { path: "sanity.config.ts", content: "test-project" },
        },
        { type: "command-succeeds", value: "npx tsc --noEmit" },
    ],
    options: {
        timeout: 120_000,
    },
};
// ---------------------------------------------------------------------------
// Task 2: Modify existing code following docs
// ---------------------------------------------------------------------------
export const modifyCodeTask = {
    mode: "agent-harness",
    id: "agent-modify-schema",
    title: "Add Document Actions Following Docs",
    description: "Given an existing Studio project, the agent should add custom document " +
        "actions following the Sanity documentation. The starting codebase has a " +
        "basic Studio setup; the agent needs to create a custom publish action.",
    area: "studio",
    difficulty: "intermediate",
    tags: ["agent", "modify", "document-actions"],
    sandbox: {
        type: "tempdir",
    },
    tools: ["coding"],
    fixtures: ["file://fixtures/existing-studio-project/"],
    prompt: {
        text: "In the existing Sanity Studio project, add a custom document action " +
            "that logs a message before publishing. Follow the Sanity docs for " +
            "custom document actions.",
    },
    assertions: [
        { type: "file-exists", value: "actions/logPublishAction.ts" },
        {
            type: "file-contains",
            value: {
                path: "actions/logPublishAction.ts",
                content: "useDocumentOperation",
            },
        },
        {
            type: "file-contains",
            value: {
                path: "sanity.config.ts",
                content: "document.actions",
            },
        },
    ],
    options: {
        timeout: 90_000,
    },
};
// ---------------------------------------------------------------------------
// Task 3: Multi-file refactoring task
// ---------------------------------------------------------------------------
export const multiFileRefactorTask = {
    mode: "agent-harness",
    id: "agent-migrate-api",
    title: "Migrate from Client v5 to v6 API",
    description: "The agent should migrate a multi-file project from the Sanity client v5 " +
        "API to the v6 API, updating import paths, method calls, and configuration " +
        "patterns across all files.",
    area: "mutations",
    difficulty: "advanced",
    tags: ["agent", "migration", "refactoring"],
    sandbox: {
        type: "docker",
        image: "node:22-slim",
        limits: {
            cpus: 2,
            memoryBytes: 2_147_483_648, // 2GB
            networkAccess: false,
        },
    },
    tools: ["coding", "WebSearch"],
    fixtures: ["file://fixtures/v5-project/"],
    prompt: {
        text: "Migrate this project from @sanity/client v5 to v6. Update all:\n" +
            "1. Import statements (createClient instead of SanityClient)\n" +
            "2. Client configuration (new config shape)\n" +
            "3. Query method calls (fetch → client.fetch with new signature)\n" +
            "4. Mutation helpers (create/patch/delete API changes)\n" +
            "Ensure the project compiles after migration.",
    },
    assertions: [
        {
            type: "file-contains",
            value: { path: "lib/sanity.ts", content: "createClient" },
        },
        { type: "command-succeeds", value: "npx tsc --noEmit" },
        { type: "diff-matches", value: "createClient" },
    ],
    options: {
        timeout: 180_000,
    },
};
/** All example agent harness tasks */
export const allAgentHarnessExampleTasks = [
    scaffoldProjectTask,
    modifyCodeTask,
    multiFileRefactorTask,
];
