Mandu Character

Agent 原生
全栈框架

AI 倾泻代码,饺子不会破。🥟

工程决策,交给框架。100+ MCP 工具 · 实战 Skills 工作流 · 运行时 Guard。

⚠️Warning

编码代理每天一万行,

谁来解决?

没有结构化护栏,AI 生成的代码会迅速变成一团技术债务。

1
🔥

功能蔓延

AI 代理创建重复的工具函数,忽略现有模式,使代码库膨胀。

→ negotiate + Skills 保持结构一致

2
💀

静默失败

隐藏在生成函数深处的逻辑错误,通过基本测试但在生产环境中失败。

→ ATE 自动写测试并修复

3
🌀

架构漂移

AI 在不理解边界的情况下粘贴代码,你的整洁架构逐渐退化。

→ Guard 在运行时强制边界

Mandu solves this
核心概念

里面有什么?

📋

同样的指令,第三次了吗?

一个 schema 文件。 API · 类型 · 测试 · 校验自动生成。 代理偏离时 Guard 运行时拦截。

🛡️

架构,已经崩了吗?

层 · 命名 · 依赖规则运行时强制。 内置 FSD · Clean · Hexagonal 6 种预设。 代理偏离时当场拒绝。

// 检测到层违规

Agent "claude" blocked.

Reason: layer-violation: shared → features

架构已保护 ✅

🧩

API 30 行变 Filling 3 行。

Mandu.filling(contract, ctx => ctx.ok(data))。 中间件链用 .guard() 合成。 一个 ctx 包含 session · CSRF · DB。

🤖

代理理解 Mandu。

MCP 100+ 工具可查询结构 · 合约 · 规则。 Claude/Codex 无需猜测直接执行。 用工具调用代替 prompt engineering。

🧪

测试,还在自己写吗?

ATE 从路由自动生成 Playwright spec。 选择 L0~L3 oracle 等级(smoke ~ 合约校验)。 失败时 LLM 提出修复 diff。

AI 失误,一键还原。

mandu change begin 在 AI 编辑前快照。 出错就 rollback,正常就 commit。 无分支的文件级原子恢复。

与 Next · Remix · Hono 有何不同?

Mandu vs
亲眼验证

处理程序 6 行,schema 8 行。

一个 30 行文件变两个文件 14 行。同一个 /api/signup 端点。

app/api/signup/route.ts
30 lines
import { z } from "zod";
import { NextRequest, NextResponse } from "next/server";
import { db, hash, isRateLimited } from "@/lib";

const SignupSchema = z.object({
  email: z.string().email(),
  password: z.string().min(8),
});

export async function POST(req: NextRequest) {
  const csrf = req.headers.get("x-csrf-token");
  if (csrf !== req.cookies.get("__csrf")?.value)
    return NextResponse.json({ error: "csrf" }, { status: 403 });
  if (await isRateLimited(req.ip))
    return NextResponse.json({ error: "rate" }, { status: 429 });

  const raw = await req.json().catch(() => null);
  const parsed = SignupSchema.safeParse(raw);
  if (!parsed.success)
    return NextResponse.json({ error: parsed.error.flatten() }, { status: 400 });

  try {
    const user = await db.user.create({
      data: {
        email: parsed.data.email,
        password: await hash(parsed.data.password),
      },
    });
    return NextResponse.json({ id: user.id }, { status: 201 });
  } catch (err) {
    if ((err as any).code === "P2002")
      return NextResponse.json({ error: "duplicate" }, { status: 409 });
    return NextResponse.json({ error: "internal" }, { status: 500 });
  }
}
Next.js · 手动接线CSRF · rate limit · auth · 错误映射全部手动
app/api/signup/route.ts
6 lines
import { Mandu } from "@mandujs/core";
import { SignupContract } from "@/spec/contracts/signup.contract";

export default Mandu.filling(SignupContract, async (ctx) =>
  ctx.ok(await ctx.db.user.create({ ...ctx.body }))
).guard("auth").rateLimit({ rpm: 10 });
Mandu · Filling 处理程序中间件链合成 CSRF · rate · auth
spec/contracts/signup.contract.ts
8 lines
import { defineContract } from "@mandujs/core/contract";
import { z } from "zod";

export const SignupContract = defineContract({
  method: "POST",
  request: z.object({ email: z.string().email(), password: z.string().min(8) }),
  response: z.object({ id: z.string() }),
});
Mandu · Contract类型 · OpenAPI · 测试自动派生
部署

一条命令,七处部署。

平台配置文件由 Mandu 自动生成。wrangler.toml · vercel.json · Dockerfile · …

$mandu deploy --to=<target>
Cloudflare logoCloudflare边缘运行时
Vercel logoVercel边缘运行时
Netlify logoNetlify边缘运行时
Deno Deploy logoDeno Deploy边缘运行时
Fly.io logoFly.io容器
Railway logoRailway容器
Render logoRender容器
Docker logoDocker容器

兼容

Bun logoBun
TypeScript logoTypeScript
React logoReact
Postgres logoPostgres
SQLite logoSQLite
OpenAI logoOpenAI
Anthropic logoAnthropic
Mandu Character

加入厨房

Mandu 是开源的,由社区驱动。帮助我们构建让 AI 开发更安全的 Guard。