Initial commit: Inner OS v1

Full-stack inner development operating system built on Next.js 16 + Prisma 7 + PostgreSQL + OpenAI + Clerk.
Generates personalized daily mental training tasks, collects reflection, updates user state, and provides internal reward feedback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jackyu66git
2026-05-20 12:11:27 +08:00
co-authored by Claude Opus 4.6
commit cef29d40bd
49 changed files with 4723 additions and 0 deletions
+71
View File
@@ -0,0 +1,71 @@
import { auth } from "@clerk/nextjs/server";
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";
export async function GET() {
const { userId } = await auth();
if (!userId) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
const state = await prisma.userState.findUnique({
where: { userId },
select: {
attentionLevel: true,
emotionStability: true,
stressLevel: true,
practiceStage: true,
consistencyScore: true,
streakDays: true,
totalSessionsCompleted: true,
onboardingCompleted: true,
lastSessionDate: true,
},
});
if (!state) {
return NextResponse.json({
state: null,
hasStarted: false,
});
}
return NextResponse.json({
state,
hasStarted: true,
});
}
export async function PATCH(req: Request) {
const { userId } = await auth();
if (!userId) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
const body = await req.json().catch(() => null);
if (!body || typeof body !== "object") {
return NextResponse.json({ error: "Invalid request body" }, { status: 400 });
}
const { onboardingCompleted } = body as { onboardingCompleted?: boolean };
const state = await prisma.userState.upsert({
where: { userId },
create: {
userId,
onboardingCompleted: onboardingCompleted ?? false,
},
update: {
...(onboardingCompleted !== undefined ? { onboardingCompleted } : {}),
},
select: {
attentionLevel: true,
emotionStability: true,
stressLevel: true,
practiceStage: true,
consistencyScore: true,
streakDays: true,
totalSessionsCompleted: true,
onboardingCompleted: true,
lastSessionDate: true,
},
});
return NextResponse.json({ state });
}