@rejelly/core — 用 React 的方式写 Agent(TypeScript)

wha582 2026-07-15 14:36 1


仓库: https://github.com/waht41/rejelly



Agent 是函数,Prompt 用 Hooks 组织,输出用 Zod 定契约。


正在找共建者 —— 希望或愿意做 Agent 开发的人。




1. 跑起来


npm create rejelly@latest      # 问项目名 / 模板 / 模型适配器,生成项目
cd <project> && pnpm install
# 编辑 .env ,填入模型 API key
pnpm start

脚手架会生成一个可运行的 Agent 项目;填好 .env 里的 API key 后 pnpm start 即可跑起来


2. 往下开发


开发时用 codex / cc 即可,或者用本项目自己的 dogfooding 工具 evil-jelly (见下)。


生成的项目里自带一份 AGENTS.md,照着它写就行。


想要个实感——一个能跑的 coding agent ,大概 500 行就能搭完:



  • 真实样例: https://github.com/waht41/rejelly/tree/main/examples/02-patterns/coding-agent




附:开发工具 evil-jelly (可选)


本项目的 dogfooding app ,参考 codex / cc ,可在开发时当 coding agent 用:


npm i -g @rejelly/evil-jelly
evil init
evil

它额外内置了几个 dogfooding 高频功能——检测文档漂移代码坏味道



  • 文档: https://github.com/waht41/rejelly/blob/main/apps/evil-jelly/README.md



成本参考:十万行级项目全套跑一遍 doc 审计约 7–8M token ( deepseek-flash 3 元以内)。



有问题可以提 issue ,或者评论区留言

最新回复 (1)
  • wha582 楼主 07-15 20:21
    1
    附带一个小型的代码 demo

    ```typescript
    import {
    createAgent,
    equipSystem,
    equipInstruction,
    promptAgent,
    } from "@rejelly/core";
    import { z } from "zod";

    const Reviewer = createAgent({
    id: "code-reviewer",
    model,
    handler: async ({ code }: { code: string }) => {
    equipSystem("You are a strict TypeScript code reviewer.");
    equipInstruction(`
    Review this code and identify concrete problems:

    ${code}
    `);

    return promptAgent(
    z.object({
    summary: z.string(),
    issues: z.array(
    z.object({
    severity: z.enum(["low", "medium", "high"]),
    message: z.string(),
    }),
    ),
    }),
    );
    },
    });

    const review = await Reviewer({
    code: `const add = (a, b) => a + b`,
    });

    console.log(review.issues);
    ```
* 帖子来源V2EX
返回