爱意满满的作品展示区。
wha582

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

  •  
  •   wha582 · 6 days ago · 571 views

    仓库: 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 行就能搭完:


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

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

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

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

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

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

    wha582
        1
    wha582  
    OP
       5 days ago
    附带一个小型的代码 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);
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3483 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 11:02 · PVG 19:02 · LAX 04:02 · JFK 07:02
    ♥ Do have faith in what you're doing.