chore: initial commit with Phase 0 setup

This commit is contained in:
OG T
2026-06-06 22:55:45 +08:00
commit 9e79e58f87
56 changed files with 16088 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
import { prisma } from "@/lib/prisma";
import { notFound } from "next/navigation";
import Link from "next/link";
export default async function TaskDetails({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const task = await prisma.task.findUnique({
where: { id },
include: { submissions: true }
});
if (!task) return notFound();
return (
<div className="min-h-screen bg-gray-950 text-gray-100 p-8 font-sans">
<div className="max-w-4xl mx-auto">
<Link href="/" className="text-blue-400 hover:text-blue-300 mb-8 inline-flex items-center gap-2">
Back to Tasks
</Link>
<div className="bg-gray-900 border border-gray-800 rounded-3xl p-10 relative overflow-hidden shadow-2xl">
<div className="absolute top-0 right-0 w-64 h-64 bg-blue-500/10 rounded-full blur-3xl -translate-y-1/2 translate-x-1/2"></div>
<div className="flex justify-between items-start mb-6">
<h1 className="text-4xl font-extrabold text-white">{task.title}</h1>
<div className="text-right">
<div className="text-3xl font-black text-transparent bg-clip-text bg-gradient-to-r from-green-400 to-emerald-600">
${(task.reward_amount / 100).toFixed(2)}
</div>
<div className="text-sm text-gray-500">{task.reward_currency}</div>
</div>
</div>
<div className="flex gap-4 mb-8">
<span className="px-4 py-2 bg-gray-800 rounded-lg text-sm font-semibold border border-gray-700">
Status: <span className="text-blue-400">{task.status}</span>
</span>
<span className="px-4 py-2 bg-gray-800 rounded-lg text-sm font-semibold border border-gray-700">
Difficulty: <span className="text-purple-400">{task.difficulty}</span>
</span>
</div>
<div className="prose prose-invert max-w-none mb-10">
<h3 className="text-xl font-bold mb-4 text-gray-200 border-b border-gray-800 pb-2">Description</h3>
<p className="text-gray-400 leading-relaxed whitespace-pre-wrap">{task.description}</p>
</div>
<div className="mb-10">
<h3 className="text-xl font-bold mb-4 text-gray-200 border-b border-gray-800 pb-2">Required Stack</h3>
<div className="flex flex-wrap gap-2">
{task.required_stack.map((tech) => (
<span key={tech} className="bg-blue-900/30 text-blue-300 px-3 py-1.5 rounded-md text-sm font-medium border border-blue-800/50">
{tech}
</span>
))}
</div>
</div>
<div className="bg-gray-950 rounded-xl p-6 border border-gray-800">
<h3 className="text-lg font-bold mb-4 text-gray-300">Acceptance Criteria (Test File)</h3>
<pre className="text-xs text-gray-400 overflow-x-auto p-4 bg-black rounded-lg border border-gray-800">
{typeof task.acceptance_criteria === "object" && task.acceptance_criteria !== null
? (task.acceptance_criteria as any).test_file_content || "No test file specified."
: "N/A"}
</pre>
</div>
</div>
</div>
</div>
);
}

View File

@@ -0,0 +1,32 @@
"use server";
import { prisma } from "@/lib/prisma";
import { TaskStatus, TaskDifficulty } from "@agent-bounty/contracts";
import { redirect } from "next/navigation";
export async function createTask(formData: FormData) {
const title = formData.get("title") as string;
const description = formData.get("description") as string;
const rewardAmount = parseInt(formData.get("rewardAmount") as string, 10) * 100; // to cents
const requiredStack = (formData.get("requiredStack") as string).split(",").map(s => s.trim());
const testFileContent = formData.get("testFileContent") as string;
const task = await prisma.task.create({
data: {
title,
description,
status: TaskStatus.OPEN,
difficulty: TaskDifficulty.COMPONENT,
scope_clarity_score: 1.0,
reward_amount: rewardAmount,
reward_currency: "USD",
required_stack: requiredStack,
acceptance_criteria: {
validation_mode: "VITEST_UNIT",
test_file_content: testFileContent
}
}
});
redirect(`/tasks/${task.id}`);
}

View File

@@ -0,0 +1,96 @@
"use client";
import { useTransition } from "react";
import { createTask } from "./actions";
import Link from "next/link";
export default function CreateTaskPage() {
const [isPending, startTransition] = useTransition();
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const formData = new FormData(e.currentTarget);
startTransition(() => {
createTask(formData);
});
};
return (
<div className="min-h-screen bg-gray-950 text-gray-100 p-8 font-sans">
<div className="max-w-2xl mx-auto">
<Link href="/" className="text-blue-400 hover:text-blue-300 mb-8 inline-flex items-center gap-2">
Back to Tasks
</Link>
<h1 className="text-3xl font-extrabold text-white mb-8">Post a New Bounty</h1>
<form onSubmit={handleSubmit} className="bg-gray-900 border border-gray-800 rounded-3xl p-8 shadow-2xl space-y-6">
<div>
<label className="block text-sm font-semibold text-gray-300 mb-2">Title</label>
<input
name="title"
required
className="w-full bg-black border border-gray-700 rounded-lg px-4 py-3 text-white focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500"
placeholder="e.g. Build a React Button Component"
/>
</div>
<div>
<label className="block text-sm font-semibold text-gray-300 mb-2">Reward Amount (USD)</label>
<input
name="rewardAmount"
type="number"
min="1"
required
className="w-full bg-black border border-gray-700 rounded-lg px-4 py-3 text-white focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500"
placeholder="10"
/>
</div>
<div>
<label className="block text-sm font-semibold text-gray-300 mb-2">Required Stack (comma separated)</label>
<input
name="requiredStack"
required
className="w-full bg-black border border-gray-700 rounded-lg px-4 py-3 text-white focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500"
placeholder="React, Tailwind, TypeScript"
/>
</div>
<div>
<label className="block text-sm font-semibold text-gray-300 mb-2">Description</label>
<textarea
name="description"
required
rows={4}
className="w-full bg-black border border-gray-700 rounded-lg px-4 py-3 text-white focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500"
placeholder="Describe the task details here..."
/>
</div>
<div>
<label className="block text-sm font-semibold text-gray-300 mb-2">Acceptance Criteria (Vitest Code)</label>
<textarea
name="testFileContent"
required
rows={6}
className="w-full bg-black border border-gray-700 rounded-lg px-4 py-3 text-white font-mono text-sm focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500"
placeholder="import { expect, test } from 'vitest';&#10;&#10;test('component renders', () => { ... });"
/>
<p className="text-xs text-gray-500 mt-2">Provide the exact test file content that the agent's solution must pass.</p>
</div>
<button
type="submit"
disabled={isPending}
className="w-full bg-blue-600 hover:bg-blue-500 text-white font-bold py-4 rounded-xl transition-all duration-300 shadow-lg shadow-blue-500/30 disabled:opacity-50 disabled:cursor-not-allowed mt-4"
>
{isPending ? "Posting Bounty..." : "Post Bounty to Network"}
</button>
</form>
</div>
</div>
);
}