[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-Osly-AI--Pocket-Flow-Framework":3,"tool-Osly-AI--Pocket-Flow-Framework":62},[4,18,28,37,45,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":24,"last_commit_at":25,"category_tags":26,"status":17},9989,"n8n","n8n-io\u002Fn8n","n8n 是一款面向技术团队的公平代码（fair-code）工作流自动化平台，旨在让用户在享受低代码快速构建便利的同时，保留编写自定义代码的灵活性。它主要解决了传统自动化工具要么过于封闭难以扩展、要么完全依赖手写代码效率低下的痛点，帮助用户轻松连接 400 多种应用与服务，实现复杂业务流程的自动化。\n\nn8n 特别适合开发者、工程师以及具备一定技术背景的业务人员使用。其核心亮点在于“按需编码”：既可以通过直观的可视化界面拖拽节点搭建流程，也能随时插入 JavaScript 或 Python 代码、调用 npm 包来处理复杂逻辑。此外，n8n 原生集成了基于 LangChain 的 AI 能力，支持用户利用自有数据和模型构建智能体工作流。在部署方面，n8n 提供极高的自由度，支持完全自托管以保障数据隐私和控制权，也提供云端服务选项。凭借活跃的社区生态和数百个现成模板，n8n 让构建强大且可控的自动化系统变得简单高效。",184740,2,"2026-04-19T23:22:26",[16,14,13,15,27],"插件",{"id":29,"name":30,"github_repo":31,"description_zh":32,"stars":33,"difficulty_score":10,"last_commit_at":34,"category_tags":35,"status":17},10095,"AutoGPT","Significant-Gravitas\u002FAutoGPT","AutoGPT 是一个旨在让每个人都能轻松使用和构建 AI 的强大平台，核心功能是帮助用户创建、部署和管理能够自动执行复杂任务的连续型 AI 智能体。它解决了传统 AI 应用中需要频繁人工干预、难以自动化长流程工作的痛点，让用户只需设定目标，AI 即可自主规划步骤、调用工具并持续运行直至完成任务。\n\n无论是开发者、研究人员，还是希望提升工作效率的普通用户，都能从 AutoGPT 中受益。开发者可利用其低代码界面快速定制专属智能体；研究人员能基于开源架构探索多智能体协作机制；而非技术背景用户也可直接选用预置的智能体模板，立即投入实际工作场景。\n\nAutoGPT 的技术亮点在于其模块化“积木式”工作流设计——用户通过连接功能块即可构建复杂逻辑，每个块负责单一动作，灵活且易于调试。同时，平台支持本地自托管与云端部署两种模式，兼顾数据隐私与使用便捷性。配合完善的文档和一键安装脚本，即使是初次接触的用户也能在几分钟内启动自己的第一个 AI 智能体。AutoGPT 正致力于降低 AI 应用门槛，让人人都能成为 AI 的创造者与受益者。",183572,"2026-04-20T04:47:55",[13,36,27,14,15],"语言模型",{"id":38,"name":39,"github_repo":40,"description_zh":41,"stars":42,"difficulty_score":10,"last_commit_at":43,"category_tags":44,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":46,"name":47,"github_repo":48,"description_zh":49,"stars":50,"difficulty_score":24,"last_commit_at":51,"category_tags":52,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",161147,"2026-04-19T23:31:47",[14,13,36],{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":59,"last_commit_at":60,"category_tags":61,"status":17},8272,"opencode","anomalyco\u002Fopencode","OpenCode 是一款开源的 AI 编程助手（Coding Agent），旨在像一位智能搭档一样融入您的开发流程。它不仅仅是一个代码补全插件，而是一个能够理解项目上下文、自主规划任务并执行复杂编码操作的智能体。无论是生成全新功能、重构现有代码，还是排查难以定位的 Bug，OpenCode 都能通过自然语言交互高效完成，显著减少开发者在重复性劳动和上下文切换上的时间消耗。\n\n这款工具专为软件开发者、工程师及技术研究人员设计，特别适合希望利用大模型能力来提升编码效率、加速原型开发或处理遗留代码维护的专业人群。其核心亮点在于完全开源的架构，这意味着用户可以审查代码逻辑、自定义行为策略，甚至私有化部署以保障数据安全，彻底打破了传统闭源 AI 助手的“黑盒”限制。\n\n在技术体验上，OpenCode 提供了灵活的终端界面（Terminal UI）和正在测试中的桌面应用程序，支持 macOS、Windows 及 Linux 全平台。它兼容多种包管理工具，安装便捷，并能无缝集成到现有的开发环境中。无论您是追求极致控制权的资深极客，还是渴望提升产出的独立开发者，OpenCode 都提供了一个透明、可信",144296,1,"2026-04-16T14:50:03",[13,27],{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"ai_summary_zh":68,"readme_en":69,"readme_zh":70,"quickstart_zh":71,"use_case_zh":72,"hero_image_url":73,"owner_login":74,"owner_name":75,"owner_avatar_url":76,"owner_bio":77,"owner_company":78,"owner_location":78,"owner_email":78,"owner_twitter":78,"owner_website":79,"owner_url":80,"languages":81,"stars":94,"forks":95,"last_commit_at":96,"license":97,"difficulty_score":59,"env_os":98,"env_gpu":98,"env_ram":98,"env_deps":99,"category_tags":104,"github_topics":78,"view_count":24,"oss_zip_url":78,"oss_zip_packed_at":78,"status":17,"created_at":105,"updated_at":106,"faqs":107,"releases":113},10077,"Osly-AI\u002FPocket-Flow-Framework","Pocket-Flow-Framework","Enable LLMs to Program Themselves.","Pocket-Flow-Framework 是一个极简的大语言模型（LLM）工作流编排框架，其核心理念是“让大模型为自己编程”。它旨在解决当前主流 AI 框架过于臃肿的问题——许多现有工具引入了数千行代码的抽象层、厂商适配器和复杂的插件系统，而 Pocket-Flow-Framework 将整个运行时引擎浓缩为仅约 100 行 TypeScript 代码。\n\n该框架通过将工作流建模为“嵌套有向图”，让开发者能够以极低的认知成本构建复杂的 AI 应用。在这个模型中，“节点”负责执行具体任务（如调用模型或查询数据库），“动作”决定流程跳转，“流”负责整体协调，所有组件通过共享状态进行通信。这种设计不仅彻底消除了厂商锁定（支持任意 LLM 接口），还提供了内置的重试机制、并行执行能力以及灵活的嵌套组合特性。\n\nPocket-Flow-Framework 特别适合希望深入理解 AI 工作流底层逻辑、追求代码透明度高且厌恶过度封装的开发者和技术研究人员。对于想要从零构建定制化 AI 代理、需要高度灵活控制执行流程的团队而言，它提供了一个轻量、透明且强大的基础架构，让你能专注于业务逻辑而非框架本身","Pocket-Flow-Framework 是一个极简的大语言模型（LLM）工作流编排框架，其核心理念是“让大模型为自己编程”。它旨在解决当前主流 AI 框架过于臃肿的问题——许多现有工具引入了数千行代码的抽象层、厂商适配器和复杂的插件系统，而 Pocket-Flow-Framework 将整个运行时引擎浓缩为仅约 100 行 TypeScript 代码。\n\n该框架通过将工作流建模为“嵌套有向图”，让开发者能够以极低的认知成本构建复杂的 AI 应用。在这个模型中，“节点”负责执行具体任务（如调用模型或查询数据库），“动作”决定流程跳转，“流”负责整体协调，所有组件通过共享状态进行通信。这种设计不仅彻底消除了厂商锁定（支持任意 LLM 接口），还提供了内置的重试机制、并行执行能力以及灵活的嵌套组合特性。\n\nPocket-Flow-Framework 特别适合希望深入理解 AI 工作流底层逻辑、追求代码透明度高且厌恶过度封装的开发者和技术研究人员。对于想要从零构建定制化 AI 代理、需要高度灵活控制执行流程的团队而言，它提供了一个轻量、透明且强大的基础架构，让你能专注于业务逻辑而非框架本身的复杂性。","[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-yellow.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n[![Docs](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdocs-latest-blue)](https:\u002F\u002Fosly-ai.github.io\u002FPocket-Flow-Framework\u002F)\n\n# Pocketflow Framework\n\n**100 lines of code. That's the entire framework.**\n\nMost LLM frameworks ship thousands of lines of abstraction — classes, adapters, vendor wrappers, plugin systems — and yet the underlying idea is always the same: chain some LLM calls together, pass state between them, and handle failures.\n\nPocketflow strips all of that away. The core engine is a single TypeScript file that models LLM workflows as a **Nested Directed Graph**: nodes do work, actions route between them, flows orchestrate the graph, and shared state ties it all together.\n\nThis is the original core abstraction behind the **[Pocketflow Platform](https:\u002F\u002Fpocketflow.ai)**, where non-developers create custom AI workflows in natural language.\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FOsly-AI_Pocket-Flow-Framework_readme_2f5e9dc8e9e4.png\" alt=\"Pocketflow Platform\" width=\"700\"\u002F>\n\u003C\u002Fp>\n\n---\n\n## Table of Contents\n\n- [Why This Exists](#why-this-exists)\n- [Architecture](#architecture)\n- [How It Works](#how-it-works)\n- [Quick Start](#quick-start)\n- [Usage Guide](#usage-guide)\n  - [Nodes](#nodes)\n  - [Flows](#flows)\n  - [Branching & Cycles](#branching--cycles)\n  - [RetryNode](#retrynode)\n  - [Nested Flows](#nested-flows)\n  - [BatchFlow](#batchflow)\n- [Design Patterns](#design-patterns)\n- [CLI](#cli)\n- [Project Structure](#project-structure)\n- [Whitepaper](#whitepaper)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## Why This Exists\n\nEvery LLM framework eventually converges on the same pattern:\n\n1. Break a task into steps\n2. Let each step read\u002Fwrite shared context\n3. Decide what happens next based on the result\n4. Handle failures gracefully\n\nThe difference is how much ceremony surrounds that pattern. Pocketflow's answer: almost none. The entire runtime is ~100 lines. There are no vendor lock-ins, no mandatory adapters, no configuration files. You bring your own LLM client, your own database, your own whatever — and the framework just orchestrates the graph.\n\n**Key properties:**\n\n- **Vendor-agnostic** — Call OpenAI, Anthropic, local models, or a REST API. The framework doesn't care.\n- **Tiny surface area** — One file, four classes. You can read and understand the entire codebase in 10 minutes.\n- **Nested composition** — Flows can contain other flows. Build complex systems from simple, tested pieces.\n- **Parallel execution** — BatchFlow runs multiple flow instances concurrently with automatic fan-out.\n- **Built-in retry** — RetryNode wraps any node with configurable retry + backoff.\n\n---\n\n## Architecture\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FOsly-AI_Pocket-Flow-Framework_readme_b79db6b26b53.png\" alt=\"Architecture: nodes sharing state through a directed graph\" width=\"700\"\u002F>\n\u003C\u002Fp>\n\nThe framework models every workflow as a **Nested Directed Graph**:\n\n| Concept | What it does |\n|---------|-------------|\n| **Node** | An atomic unit of work. Reads from shared state, executes logic, writes back, and returns an action string. |\n| **Action** | A labeled edge connecting one node to the next. The string returned by `post()` determines routing. |\n| **Flow** | An orchestrator that walks the graph from a start node, following actions until no successor is found. |\n| **Shared State** | A plain object passed to every node. This is how nodes communicate — no message passing, no events. |\n\n---\n\n## How It Works\n\nEvery node runs the same three-step lifecycle:\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FOsly-AI_Pocket-Flow-Framework_readme_0ef97370e223.png\" alt=\"Node lifecycle: Prep → ExecWrapper → Exec → Post, all reading\u002Fwriting shared state\" width=\"700\"\u002F>\n\u003C\u002Fp>\n\n| Step | Method | Purpose |\n|------|--------|---------|\n| **1. Prep** | `prep(sharedState)` | Pull data from shared state. Validate inputs. Return a prep result for the next step. |\n| **2. Exec** | `execCore(prepResult)` | Do the actual work — call an LLM, query a database, run a calculation. Pure logic, no side effects on shared state. |\n| **3. Post** | `post(prep, exec, sharedState)` | Write results back to shared state. Return an action string to pick the next node. |\n\nThe `execWrapper` sits between prep and exec — it's where `RetryNode` adds its retry loop, and where you can add your own middleware (rate limiting, caching, logging, etc.).\n\n---\n\n## Quick Start\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FOsly-AI\u002FPocket-Flow-Framework.git\ncd Pocket-Flow-Framework\nnpm install\n```\n\nRun the test suite:\n\n```bash\nnpm test\n```\n\nBuild:\n\n```bash\nnpm run build\n```\n\n---\n\n## Usage Guide\n\n### Nodes\n\nEvery node extends `BaseNode` and implements three methods:\n\n```typescript\nimport { BaseNode, DEFAULT_ACTION } from \"pocketflow\";\n\nclass SummarizeNode extends BaseNode {\n  async prep(sharedState: any) {\n    \u002F\u002F Read from shared state\n    return { text: sharedState.document };\n  }\n\n  async execCore(prepResult: any) {\n    \u002F\u002F Call your LLM (bring your own client)\n    const response = await openai.chat.completions.create({\n      model: \"gpt-4\",\n      messages: [{ role: \"user\", content: `Summarize: ${prepResult.text}` }]\n    });\n    return { summary: response.choices[0].message.content };\n  }\n\n  async post(prepResult: any, execResult: any, sharedState: any) {\n    \u002F\u002F Write back to shared state\n    sharedState.summary = execResult.summary;\n    return DEFAULT_ACTION;\n  }\n\n  _clone() { return new SummarizeNode(); }\n}\n```\n\n### Flows\n\nConnect nodes with `addSuccessor`, then wrap them in a `Flow`:\n\n```typescript\nimport { Flow, DEFAULT_ACTION } from \"pocketflow\";\n\nconst summarize = new SummarizeNode();\nconst review = new ReviewNode();\nconst publish = new PublishNode();\n\n\u002F\u002F Linear chain: summarize → review → publish\nsummarize.addSuccessor(review, DEFAULT_ACTION);\nreview.addSuccessor(publish, DEFAULT_ACTION);\n\nconst pipeline = new Flow(summarize);\nawait pipeline.run({ document: \"...\" });\n```\n\n### Branching & Cycles\n\nNodes can return different action strings to route execution:\n\n```typescript\nclass QualityCheckNode extends BaseNode {\n  async post(prepResult: any, execResult: any, sharedState: any) {\n    if (execResult.score >= 0.8) return \"approved\";\n    if (sharedState.retryCount \u003C 3) return \"retry\";\n    return \"reject\";\n  }\n  \u002F\u002F ...\n}\n\nconst check = new QualityCheckNode();\nconst publish = new PublishNode();\nconst revise = new ReviseNode();\nconst reject = new RejectNode();\n\ncheck.addSuccessor(publish, \"approved\");\ncheck.addSuccessor(revise, \"retry\");\ncheck.addSuccessor(reject, \"reject\");\n\n\u002F\u002F Create a cycle: revise feeds back into check\nrevise.addSuccessor(check, DEFAULT_ACTION);\n```\n\n### RetryNode\n\nWrap any node with automatic retry and configurable backoff:\n\n```typescript\nimport { RetryNode } from \"pocketflow\";\n\nclass ResilientLLMNode extends RetryNode {\n  constructor() {\n    super(3, 2000); \u002F\u002F 3 attempts, 2 seconds between retries\n  }\n\n  async prep(sharedState: any) { \u002F* ... *\u002F }\n  async execCore(prepResult: any) {\n    \u002F\u002F If this throws, RetryNode catches it and retries\n    return await callUnreliableAPI(prepResult);\n  }\n  async post(prep: any, exec: any, sharedState: any) { \u002F* ... *\u002F }\n  _clone() { return new ResilientLLMNode(); }\n}\n```\n\n### Nested Flows\n\nFlows are nodes — so you can nest them arbitrarily:\n\n```typescript\n\u002F\u002F Inner flow: extract → summarize\nconst extract = new ExtractNode();\nconst summarize = new SummarizeNode();\nextract.addSuccessor(summarize, DEFAULT_ACTION);\nconst extractAndSummarize = new Flow(extract);\n\n\u002F\u002F Outer flow: extractAndSummarize → publish\nconst publish = new PublishNode();\nextractAndSummarize.addSuccessor(publish, DEFAULT_ACTION);\nconst fullPipeline = new Flow(extractAndSummarize);\n\nawait fullPipeline.run(sharedState);\n```\n\nThis is the key design insight: because `Flow` extends `BaseNode`, you can compose arbitrarily complex systems from small, individually testable flows.\n\n### BatchFlow\n\nProcess multiple items concurrently. Override `prep()` to return an array — each element spawns a parallel flow execution:\n\n```typescript\nimport { BatchFlow } from \"pocketflow\";\n\nclass ProcessDocuments extends BatchFlow {\n  async prep(sharedState: any) {\n    \u002F\u002F Return one config per document — each runs the flow in parallel\n    return sharedState.documents.map((doc: string) => ({ document: doc }));\n  }\n}\n\n\u002F\u002F The inner flow runs once per document, concurrently\nconst summarize = new SummarizeNode();\nconst batch = new ProcessDocuments(summarize);\n\nawait batch.run({\n  documents: [\"paper1.pdf\", \"paper2.pdf\", \"paper3.pdf\", \u002F* ...100 more *\u002F]\n});\n```\n\n---\n\n## Design Patterns\n\nAll common LLM patterns are just different graph topologies:\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FOsly-AI_Pocket-Flow-Framework_readme_f59431d09d90.png\" alt=\"Design patterns: Chaining, Chat, RAG, CoT, Map-Reduce, Agent, Multi-Agent, Supervisor\" width=\"700\"\u002F>\n\u003C\u002Fp>\n\n| Pattern | Graph Shape | Example |\n|---------|------------|---------|\n| **Chaining** | Linear path | Summarize → Draft Reply |\n| **Chat** | Self-loop with history | Chat node cycling with stored context |\n| **RAG** | Write + Read through vector store | Upload docs → Answer questions |\n| **Chain-of-Thought** | Self-loop with reasoning store | Think → Evaluate → Think again |\n| **Map-Reduce** | Fan-out + merge | Split text → Summarize chunks → Reduce |\n| **Agent** | Loop with branching | Summarize → Review ↔ Draft Reply |\n| **Multi-Agent** | Multiple loops with pub\u002Fsub | Agents communicating via shared state |\n| **Supervisor** | Nested flow with approval loop | Worker flow ↔ Supervisor approval |\n\nYou don't need different APIs for these. They're all the same `Node` + `Flow` + `addSuccessor` primitives, wired differently.\n\n---\n\n## Core Abstractions\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FOsly-AI_Pocket-Flow-Framework_readme_0e22612d3565.png\" alt=\"Core abstractions: Node, Flow, Comms, Batch, Async, Action\" width=\"700\"\u002F>\n\u003C\u002Fp>\n\n| Abstraction | Description |\n|-------------|------------|\n| **Node** | Single-step processing unit |\n| **Flow** | Multi-step orchestration (directed path through nodes) |\n| **Comms** | Shared state store for inter-node communication |\n| **Batch** | Repeat the same flow across multiple inputs |\n| **Async** | Overlap I\u002FO operations for parallel execution |\n| **Action** | Conditional routing (branching and cycles) |\n\n---\n\n## CLI\n\nScaffold new components quickly:\n\n```bash\nnpx pocket new node MyProcessor    # Creates src\u002Fnodes\u002FMyProcessor.node.ts\nnpx pocket new flow MyPipeline     # Creates src\u002Fflows\u002FMyPipeline.flow.ts\n```\n\nGenerated files include typed interfaces, lifecycle stubs, and inline documentation.\n\n---\n\n## Project Structure\n\n```\n├── src\u002F\n│   └── pocket.ts          # The entire framework (~100 lines)\n├── tests\u002F\n│   ├── pocket.test.ts     # 14 tests, ~99% coverage\n│   └── testNodes.ts       # Test helper nodes\n├── cli\u002F                   # Code generation CLI\n│   ├── src\u002F               # CLI logic\n│   └── templates\u002F         # Node and Flow templates\n├── examples\u002F\n│   └── mcp-addition-ts\u002F   # MCP server example\n├── docs\u002F                  # Full documentation site (MkDocs)\n├── WHITEPAPER.md           # Technical whitepaper\n└── CONTRIBUTING.md         # Contribution guidelines\n```\n\n---\n\n## Whitepaper\n\nFor a deeper technical discussion of the design philosophy, architecture decisions, and comparisons with other frameworks, see **[WHITEPAPER.md](WHITEPAPER.md)**.\n\n---\n\n## Contributing\n\nWe welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions and guidelines.\n\n---\n\n## License\n\n[MIT](LICENSE)\n","[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-yellow.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n[![Docs](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdocs-latest-blue)](https:\u002F\u002Fosly-ai.github.io\u002FPocket-Flow-Framework\u002F)\n\n# Pocketflow 框架\n\n**仅需100行代码，这就是整个框架。**\n\n大多数大语言模型框架都包含数千行的抽象代码——类、适配器、供应商封装、插件系统等——但其核心思想始终如一：将若干个LLM调用串联起来，在它们之间传递状态，并处理可能出现的失败。\n\nPocketflow 则去除了所有这些冗余。它的核心引擎是一个单独的 TypeScript 文件，将 LLM 工作流建模为一个 **嵌套有向图**：节点执行具体任务，动作负责在节点间路由，流程编排整个图结构，而共享状态则将这一切连接在一起。\n\n这是 **[Pocketflow 平台](https:\u002F\u002Fpocketflow.ai)** 背后的原始核心抽象，在该平台上，非开发者可以使用自然语言创建自定义的 AI 工作流。\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FOsly-AI_Pocket-Flow-Framework_readme_2f5e9dc8e9e4.png\" alt=\"Pocketflow 平台\" width=\"700\"\u002F>\n\u003C\u002Fp>\n\n---\n\n## 目录\n\n- [为何存在](#why-this-exists)\n- [架构](#architecture)\n- [工作原理](#how-it-works)\n- [快速入门](#quick-start)\n- [使用指南](#usage-guide)\n  - [节点](#nodes)\n  - [流程](#flows)\n  - [分支与循环](#branching--cycles)\n  - [RetryNode](#retrynode)\n  - [嵌套流程](#nested-flows)\n  - [BatchFlow](#batchflow)\n- [设计模式](#design-patterns)\n- [CLI](#cli)\n- [项目结构](#project-structure)\n- [白皮书](#whitepaper)\n- [贡献](#contributing)\n- [许可证](#license)\n\n---\n\n## 为何存在\n\n每个 LLM 框架最终都会归结为相同的模式：\n\n1. 将任务分解为多个步骤\n2. 允许每一步读取和写入共享上下文\n3. 根据结果决定下一步操作\n4. 优雅地处理失败情况\n\n区别在于围绕这一模式有多少额外的复杂性。Pocketflow 的答案是：几乎没有。整个运行时代码约 100 行。没有供应商锁定，无需强制使用适配器，也没有配置文件。你可以自由选择自己的 LLM 客户端、数据库或其他任何工具，框架只需负责编排整个图结构。\n\n**关键特性：**\n\n- **供应商无关** — 可以调用 OpenAI、Anthropic、本地模型或 REST API，框架对此毫不在意。\n- **极小的接口面积** — 仅有一个文件和四个类。你可以在10分钟内阅读并理解整个代码库。\n- **嵌套式组合** — 流程可以包含其他流程。通过简单且经过测试的组件构建复杂的系统。\n- **并行执行** — BatchFlow 可以同时运行多个流程实例，并自动进行扇出。\n- **内置重试机制** — RetryNode 可以将任意节点包装起来，提供可配置的重试和退避策略。\n\n---\n\n## 架构\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FOsly-AI_Pocket-Flow-Framework_readme_b79db6b26b53.png\" alt=\"架构：节点通过有向图共享状态\" width=\"700\"\u002F>\n\u003C\u002Fp>\n\n该框架将每个工作流建模为一个 **嵌套有向图**：\n\n| 概念 | 作用 |\n|---------|-------------|\n| **节点** | 工作的基本单元。从共享状态读取数据，执行逻辑，写回结果，并返回一个动作字符串。 |\n| **动作** | 连接两个节点的带标签边。`post()` 方法返回的字符串决定了路由方向。 |\n| **流程** | 一个编排者，从起始节点开始遍历图结构，按照动作依次执行，直到找不到后续节点为止。 |\n| **共享状态** | 一个普通的对象，会传递给每一个节点。节点之间的通信正是通过它来实现的——无需消息传递或事件机制。 |\n\n---\n\n## 工作原理\n\n每个节点都遵循相同的三步生命周期：\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FOsly-AI_Pocket-Flow-Framework_readme_0ef97370e223.png\" alt=\"节点生命周期：准备 → 执行包装 → 执行 → 后处理，均读写共享状态\" width=\"700\"\u002F>\n\u003C\u002Fp>\n\n| 步骤 | 方法 | 目的 |\n|------|--------|---------|\n| **1. 准备** | `prep(sharedState)` | 从共享状态中提取数据，验证输入，并返回准备结果供下一步使用。 |\n| **2. 执行** | `execCore(prepResult)` | 执行实际的工作——调用 LLM、查询数据库、进行计算等。纯逻辑操作，不对共享状态产生副作用。 |\n| **3. 后处理** | `post(prep, exec, sharedState)` | 将结果写回共享状态，并返回一个动作字符串，用于选择下一个节点。 |\n\n`execWrapper` 处于准备和执行之间，它是 `RetryNode` 添加重试逻辑的地方，你也可以在这里添加自己的中间件（如限流、缓存、日志记录等）。\n\n---\n\n## 快速入门\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FOsly-AI\u002FPocket-Flow-Framework.git\ncd Pocket-Flow-Framework\nnpm install\n```\n\n运行测试套件：\n\n```bash\nnpm test\n```\n\n构建：\n\n```bash\nnpm run build\n```\n\n---\n\n## 使用指南\n\n### 节点\n\n每个节点都继承自 `BaseNode`，并实现三个方法：\n\n```typescript\nimport { BaseNode, DEFAULT_ACTION } from \"pocketflow\";\n\nclass SummarizeNode extends BaseNode {\n  async prep(sharedState: any) {\n    \u002F\u002F 从共享状态中读取数据\n    return { text: sharedState.document };\n  }\n\n  async execCore(prepResult: any) {\n    \u002F\u002F 调用你的 LLM（你需要自己提供客户端）\n    const response = await openai.chat.completions.create({\n      model: \"gpt-4\",\n      messages: [{ role: \"user\", content: `总结：${prepResult.text}` }]\n    });\n    return { summary: response.choices[0].message.content };\n  }\n\n  async post(prepResult: any, execResult: any, sharedState: any) {\n    \u002F\u002F 将结果写回共享状态\n    sharedState.summary = execResult.summary;\n    return DEFAULT_ACTION;\n  }\n\n  _clone() { return new SummarizeNode(); }\n}\n```\n\n### 流程\n\n使用 `addSuccessor` 将节点连接起来，然后将其包裹在一个 `Flow` 中：\n\n```typescript\nimport { Flow, DEFAULT_ACTION } from \"pocketflow\";\n\nconst summarize = new SummarizeNode();\nconst review = new ReviewNode();\nconst publish = new PublishNode();\n\n\u002F\u002F 线性链：summarize → review → publish\nsummarize.addSuccessor(review, DEFAULT_ACTION);\nreview.addSuccessor(publish, DEFAULT_ACTION);\n\nconst pipeline = new Flow(summarize);\nawait pipeline.run({ document: \"...\" });\n```\n\n### 分支与循环\n\n节点可以根据不同的条件返回不同的动作字符串来控制执行流程：\n\n```typescript\nclass QualityCheckNode extends BaseNode {\n  async post(prepResult: any, execResult: any, sharedState: any) {\n    if (execResult.score >= 0.8) return \"approved\";\n    if (sharedState.retryCount \u003C 3) return \"retry\";\n    return \"reject\";\n  }\n  \u002F\u002F ...\n}\n\nconst check = new QualityCheckNode();\nconst publish = new PublishNode();\nconst revise = new ReviseNode();\nconst reject = new RejectNode();\n\ncheck.addSuccessor(publish, \"approved\");\ncheck.addSuccessor(revise, \"retry\");\ncheck.addSuccessor(reject, \"reject\");\n\n\u002F\u002F 创建一个循环：revise 会反馈回 check\nrevise.addSuccessor(check, DEFAULT_ACTION);\n```\n\n### 重试节点\n\n使用自动重试和可配置退避机制包装任何节点：\n\n```typescript\nimport { RetryNode } from \"pocketflow\";\n\nclass ResilientLLMNode extends RetryNode {\n  constructor() {\n    super(3, 2000); \u002F\u002F 3次尝试，每次重试间隔2秒\n  }\n\n  async prep(sharedState: any) { \u002F* ... *\u002F }\n  async execCore(prepResult: any) {\n    \u002F\u002F 如果这里抛出异常，RetryNode会捕获并重试\n    return await callUnreliableAPI(prepResult);\n  }\n  async post(prep: any, exec: any, sharedState: any) { \u002F* ... *\u002F }\n  _clone() { return new ResilientLLMNode(); }\n}\n```\n\n### 嵌套流程\n\n流程本身就是节点——因此你可以任意嵌套它们：\n\n```typescript\n\u002F\u002F 内部流程：提取 → 总结\nconst extract = new ExtractNode();\nconst summarize = new SummarizeNode();\nextract.addSuccessor(summarize, DEFAULT_ACTION);\nconst extractAndSummarize = new Flow(extract);\n\n\u002F\u002F 外部流程：extractAndSummarize → 发布\nconst publish = new PublishNode();\nextractAndSummarize.addSuccessor(publish, DEFAULT_ACTION);\nconst fullPipeline = new Flow(extractAndSummarize);\n\nawait fullPipeline.run(sharedState);\n```\n\n这是关键的设计洞察：由于 `Flow` 继承自 `BaseNode`，你可以用小型、可单独测试的流程来组合出任意复杂的系统。\n\n### 批量处理流\n\n并发处理多个项目。通过重写 `prep()` 方法返回一个数组——每个元素都会启动一次并行流程执行：\n\n```typescript\nimport { BatchFlow } from \"pocketflow\";\n\nclass ProcessDocuments extends BatchFlow {\n  async prep(sharedState: any) {\n    \u002F\u002F 返回每个文档对应的配置——每个配置都会并行运行一次流程\n    return sharedState.documents.map((doc: string) => ({ document: doc }));\n  }\n}\n\n\u002F\u002F 内部流程会针对每个文档并发执行一次\nconst summarize = new SummarizeNode();\nconst batch = new ProcessDocuments(summarize);\n\nawait batch.run({\n  documents: [\"paper1.pdf\", \"paper2.pdf\", \"paper3.pdf\", \u002F* …还有100份 *\u002F]\n});\n```\n\n---\n\n## 设计模式\n\n所有常见的 LLM 模式不过是不同的图拓扑结构：\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FOsly-AI_Pocket-Flow-Framework_readme_f59431d09d90.png\" alt=\"设计模式：链式调用、聊天、RAG、思维链、Map-Reduce、智能体、多智能体、监督者\" width=\"700\"\u002F>\n\u003C\u002Fp>\n\n| 模式 | 图形形状 | 示例 |\n|---------|------------|---------|\n| **链式调用** | 线性路径 | 总结 → 草拟回复 |\n| **聊天** | 带有历史记录的自循环 | 聊天节点与存储的上下文循环交互 |\n| **RAG** | 通过向量存储进行写入和读取 | 上传文档 → 回答问题 |\n| **思维链** | 带有推理存储的自循环 | 思考 → 评估 → 再次思考 |\n| **Map-Reduce** | 扇出 + 合并 | 分割文本 → 总结各块 → 归约 |\n| **智能体** | 带分支的循环 | 总结 → 审核 ↔ 草拟回复 |\n| **多智能体** | 多个带有发布\u002F订阅机制的循环 | 智能体通过共享状态进行通信 |\n| **监督者** | 带审批循环的嵌套流程 | 工作流程 ↔ 监督者的审批 |\n\n你不需要为这些模式分别提供不同的 API。它们都只是相同的 `Node` + `Flow` + `addSuccessor` 原语，以不同的方式连接起来而已。\n\n---\n\n## 核心抽象\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FOsly-AI_Pocket-Flow-Framework_readme_0e22612d3565.png\" alt=\"核心抽象：节点、流程、通信、批量处理、异步、动作\" width=\"700\"\u002F>\n\u003C\u002Fp>\n\n| 抽象 | 描述 |\n|-------------|------------|\n| **节点** | 单步处理单元 |\n| **流程** | 多步编排（通过节点的有向路径） |\n| **通信** | 用于节点间通信的共享状态存储 |\n| **批量处理** | 对多个输入重复执行同一流程 |\n| **异步** | 重叠 I\u002FO 操作以实现并行执行 |\n| **动作** | 条件路由（分支和循环） |\n\n---\n\n## 命令行工具\n\n快速搭建新组件：\n\n```bash\nnpx pocket new node MyProcessor    # 创建 src\u002Fnodes\u002FMyProcessor.node.ts\nnpx pocket new flow MyPipeline     # 创建 src\u002Fflows\u002FMyPipeline.flow.ts\n```\n\n生成的文件包括类型化接口、生命周期存根以及内联文档注释。\n\n---\n\n## 项目结构\n\n```\n├── src\u002F\n│   └── pocket.ts          # 整个框架（约100行代码）\n├── tests\u002F\n│   ├── pocket.test.ts     # 14个测试，覆盖率约99%\n│   └── testNodes.ts       # 测试辅助节点\n├── cli\u002F                   # 代码生成命令行工具\n│   ├── src\u002F               # CLI 逻辑\n│   └── templates\u002F         # 节点和流程模板\n├── examples\u002F\n│   └── mcp-addition-ts\u002F   # MCP 服务器示例\n├── docs\u002F                  # 完整文档网站（MkDocs）\n├── WHITEPAPER.md           # 技术白皮书\n└── CONTRIBUTING.md         # 贡献指南\n```\n\n---\n\n## 白皮书\n\n如需深入了解设计哲学、架构决策以及与其他框架的比较，请参阅 **[WHITEPAPER.md](WHITEPAPER.md)**。\n\n---\n\n## 贡献\n\n我们欢迎贡献！请参阅 [CONTRIBUTING.md](CONTRIBUTING.md) 获取设置说明和贡献指南。\n\n---\n\n## 许可证\n\n[MIT](LICENSE)","# Pocket-Flow-Framework 快速上手指南\n\nPocket-Flow-Framework 是一个极简的 LLM 工作流编排框架，核心代码仅约 100 行。它通过“嵌套有向图”模型，将复杂的 AI 任务拆解为节点（Node）、动作（Action）和流程（Flow），无厂商锁定，支持任意 LLM 客户端。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**：Linux, macOS 或 Windows\n*   **运行时**：Node.js (建议 v18 或更高版本)\n*   **包管理器**：npm 或 yarn\n*   **前置依赖**：无需特殊系统库，仅需标准的 Node.js 环境。\n\n> **提示**：国内开发者若遇到 npm 安装缓慢，可临时切换至淘宝镜像源：\n> `npm config set registry https:\u002F\u002Fregistry.npmmirror.com`\n\n## 安装步骤\n\n通过 Git 克隆项目并安装依赖：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FOsly-AI\u002FPocket-Flow-Framework.git\ncd Pocket-Flow-Framework\nnpm install\n```\n\n验证安装是否成功（运行测试套件）：\n\n```bash\nnpm test\n```\n\n构建项目（如需生成生产代码）：\n\n```bash\nnpm run build\n```\n\n## 基本使用\n\nPocket-Flow 的核心逻辑是：**节点处理数据 -> 返回动作字符串 -> 流程根据动作路由到下一个节点**。所有节点通过共享状态对象（`sharedState`）通信。\n\n### 1. 定义一个节点 (Node)\n\n创建一个继承自 `BaseNode` 的类，实现 `prep`（准备数据）、`execCore`（执行核心逻辑）和 `post`（写入结果并路由）三个方法。\n\n```typescript\nimport { BaseNode, DEFAULT_ACTION } from \"pocketflow\";\n\nclass SummarizeNode extends BaseNode {\n  \u002F\u002F 1. Prep: 从共享状态读取数据\n  async prep(sharedState: any) {\n    return { text: sharedState.document };\n  }\n\n  \u002F\u002F 2. ExecCore: 执行实际任务（如调用 LLM）\n  async execCore(prepResult: any) {\n    \u002F\u002F 此处可替换为您自己的 LLM 客户端 (OpenAI, Anthropic, 本地模型等)\n    const response = await openai.chat.completions.create({\n      model: \"gpt-4\",\n      messages: [{ role: \"user\", content: `Summarize: ${prepResult.text}` }]\n    });\n    return { summary: response.choices[0].message.content };\n  }\n\n  \u002F\u002F 3. Post: 将结果写回共享状态，并决定下一步动作\n  async post(prepResult: any, execResult: any, sharedState: any) {\n    sharedState.summary = execResult.summary;\n    return DEFAULT_ACTION; \u002F\u002F 默认流向下一个连接的节点\n  }\n\n  \u002F\u002F 必须实现 _clone 方法以支持流程复制\n  _clone() { return new SummarizeNode(); }\n}\n```\n\n### 2. 编排流程 (Flow)\n\n实例化节点，使用 `addSuccessor` 连接它们，最后放入 `Flow` 中运行。\n\n```typescript\nimport { Flow, DEFAULT_ACTION } from \"pocketflow\";\n\n\u002F\u002F 实例化节点\nconst summarize = new SummarizeNode();\nconst review = new ReviewNode(); \u002F\u002F 假设已定义\nconst publish = new PublishNode(); \u002F\u002F 假设已定义\n\n\u002F\u002F 线性连接：summarize -> review -> publish\nsummarize.addSuccessor(review, DEFAULT_ACTION);\nreview.addSuccessor(publish, DEFAULT_ACTION);\n\n\u002F\u002F 创建流程并指定起始节点\nconst pipeline = new Flow(summarize);\n\n\u002F\u002F 运行流程，传入初始共享状态\nawait pipeline.run({ document: \"这是需要处理的长文档内容...\" });\n\n\u002F\u002F 运行结束后，sharedState 中将包含 summary 等结果\n```\n\n### 进阶特性简述\n\n*   **分支与循环**：在 `post` 方法中返回不同的字符串（如 `\"retry\"`, `\"approved\"`），并通过 `addSuccessor(node, \"actionName\")` 实现条件路由。\n*   **自动重试**：继承 `RetryNode` 而非 `BaseNode`，即可为任何节点添加 configurable 的重试机制。\n*   **嵌套流程**：`Flow` 本身也是一个 `Node`，可以将子流程嵌入主流程，构建复杂系统。\n*   **并行处理**：使用 `BatchFlow`，在 `prep` 中返回数组，即可并发处理多个任务。","某初创团队正在开发一个自动化代码审查助手，需要让大模型依次执行“读取代码”、“静态分析”、“生成建议”和“自我修正”等多个步骤，并根据中间结果动态决定后续流程。\n\n### 没有 Pocket-Flow-Framework 时\n- **架构过度臃肿**：引入重型框架导致项目依赖数千行抽象代码，开发者花费大量时间理解类继承和适配器模式，而非业务逻辑。\n- **厂商锁定严重**：工作流与特定云服务商强绑定，切换本地模型或测试不同 API 时需要重写大量底层连接代码。\n- **状态管理混乱**：各步骤间通过复杂的事件总线或消息队列传递数据，调试时难以追踪上下文变量的变化轨迹。\n- **容错机制缺失**：缺乏原生的重试机制，一旦某个节点调用失败，整个链路中断，需手动编写繁琐的异常捕获逻辑。\n- **组合扩展困难**：想要嵌套子流程（如在“自我修正”中再嵌入一个循环优化流）时，现有框架不支持灵活的图嵌套，代码耦合度极高。\n\n### 使用 Pocket-Flow-Framework 后\n- **核心极简透明**：仅需约 100 行代码即可构建完整引擎，团队成员 10 分钟内即可读懂源码，快速上手定制业务节点。\n- **完全厂商中立**：自由接入 OpenAI、Anthropic 或本地部署模型，框架只负责编排图结构，不干涉具体的 LLM 客户端实现。\n- **共享状态清晰**：所有节点通过一个简单的共享对象读写数据，去除了多余的消息传递，上下文流转一目了然，调试效率倍增。\n- **内置智能重试**：利用 `RetryNode` 包装关键节点，自动配置重试次数与退避策略，无需额外编码即可实现故障自愈。\n- **灵活嵌套组合**：支持将复杂逻辑封装为子 Flow 并无限嵌套，轻松实现“审查 - 修正 - 再审查”的闭环递归流程。\n\nPocket-Flow-Framework 通过极致的轻量化设计与有向图编排能力，让开发者从繁琐的框架样板代码中解放，专注于构建真正智能的 AI 工作流。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FOsly-AI_Pocket-Flow-Framework_2f5e9dc8.png","Osly-AI","Osly","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FOsly-AI_ede242d7.png","We enable anyone to create a custom workflow.",null,"https:\u002F\u002Falpha.osly.ai\u002F","https:\u002F\u002Fgithub.com\u002FOsly-AI",[82,86,90],{"name":83,"color":84,"percentage":85},"TypeScript","#3178c6",87.7,{"name":87,"color":88,"percentage":89},"JavaScript","#f1e05a",7.6,{"name":91,"color":92,"percentage":93},"CSS","#663399",4.7,630,51,"2026-04-17T06:18:19","MIT","未说明",{"notes":100,"python":98,"dependencies":101},"该工具是一个基于 TypeScript 的轻量级框架（核心代码约 100 行），用于编排 LLM 工作流。它不绑定特定厂商或模型，用户需自行集成 LLM 客户端（如 OpenAI、Anthropic 等）。运行环境主要需要 Node.js 和 npm，通过 'npm install' 安装依赖。无特定的 GPU、内存或 Python 版本要求，因为框架本身不包含模型推理引擎，仅负责流程控制。",[102,103],"Node.js","npm",[14,13],"2026-03-27T02:49:30.150509","2026-04-20T19:21:27.575414",[108],{"id":109,"question_zh":110,"answer_zh":111,"source_url":112},45266,"如何运行测试框架？","可以通过在终端执行命令 `npx jest tests\u002Fpocket.test.js` 来运行测试。","https:\u002F\u002Fgithub.com\u002FOsly-AI\u002FPocket-Flow-Framework\u002Fissues\u002F1",[]]