Show HN:我构建了一个AI,可以将GitHub代码库转换成简单的教程
Show HN: I built an AI that turns GitHub codebases into easy tutorials

原始链接: https://github.com/The-Pocket/Tutorial-Codebase-Knowledge

本项目利用AI智能体自动从GitHub仓库或本地代码库生成适合初学者的教程。它利用轻量级LLM框架Pocket Flow,分析代码,识别关键抽象,并创建全面的解释。 使用方法:提供GitHub仓库URL或本地目录路径,以及文件包含/排除模式和最大文件大小。智能体随后会爬取代码,构建知识库,并生成指定语言的教程(默认为英语)。 教程解释了代码库的结构和核心功能,并将输出保存到指定的目录。你可以在`utils/call_llm.py`文件中使用你的API密钥配置LLM。示例命令包括分析GitHub仓库或本地目录、指定文件过滤器和选择语言。本项目通过自动创建易于理解的教程,简化了对复杂代码库的理解。

Hacker News 最新 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Show HN: 我构建了一个 AI,可以将 GitHub 代码库转换成简单的教程 (github.com/the-pocket) 9 分,来自 zh2408,27 分钟前 | 隐藏 | 过去 | 收藏 | 1 评论 badmonster 2 分钟前 [–] 你计划将其扩展到包括更高级的主题,例如架构级推理、重构模式或大型代码库的入门工作流程吗? 回复 加入我们 6 月 16-17 日在旧金山举办的 AI 初创公司学校! 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系我们 搜索:

原文

License: MIT

Ever stared at a new codebase written by others feeling completely lost? This tutorial shows you how to build an AI agent that analyzes GitHub repositories and creates beginner-friendly tutorials explaining exactly how the code works.

This is a tutorial project of Pocket Flow, a 100-line LLM framework. It crawls GitHub repositories and build a knowledge base from the code. It analyzes entire codebases to identify core abstractions and how they interact, and transforms complex code into beginner-friendly tutorials with clear visualizations.

⭐ Example Results for Popular GitHub Repositories!

🤯 All these tutorials are generated entirely by AI by crawling the GitHub repo!

  • AutoGen Core - Build AI teams that talk, think, and solve problems together like coworkers!

  • Browser Use - Let AI surf the web for you, clicking buttons and filling forms like a digital assistant!

  • Celery - Supercharge your app with background tasks that run while you sleep!

  • Click - Turn Python functions into slick command-line tools with just a decorator!

  • Codex - Turn plain English into working code with this AI terminal wizard!

  • Crawl4AI - Train your AI to extract exactly what matters from any website!

  • CrewAI - Assemble a dream team of AI specialists to tackle impossible problems!

  • DSPy - Build LLM apps like Lego blocks that optimize themselves!

  • FastAPI - Create APIs at lightning speed with automatic docs that clients will love!

  • Flask - Craft web apps with minimal code that scales from prototype to production!

  • Google A2A - The universal language that lets AI agents collaborate across borders!

  • LangGraph - Design AI agents as flowcharts where each step remembers what happened before!

  • LevelDB - Store data at warp speed with Google's engine that powers blockchains!

  • MCP Python SDK - Build powerful apps that communicate through an elegant protocol without sweating the details!

  • NumPy Core - Master the engine behind data science that makes Python as fast as C!

  • OpenManus - Build AI agents with digital brains that think, learn, and use tools just like humans do!

  • Pydantic Core - Validate data at rocket speed with just Python type hints!

  • Requests - Talk to the internet in Python with code so simple it feels like cheating!

  • SmolaAgents - Build tiny AI agents that punch way above their weight class!

  1. Clone this repository

  2. Install dependencies:

    pip install -r requirements.txt
  3. Set up LLM in utils/call_llm.py by providing credentials. By default, you can use the AI Studio key with this client for Gemini Pro 2.5:

    client = genai.Client(
      api_key=os.getenv("GEMINI_API_KEY", "your-api_key"),
    )

    You can use your own models. We highly recommend the latest models with thinking capabilities (Claude 3.7 with thinking, O1). You can verify that it is correctly set up by running:

  4. Generate a complete codebase tutorial by running the main script:

    # Analyze a GitHub repository
    python main.py --repo https://github.com/username/repo --include "*.py" "*.js" --exclude "tests/*" --max-size 50000
    
    # Or, analyze a local directory
    python main.py --dir /path/to/your/codebase --include "*.py" --exclude "*test*"
    
    # Or, generate a tutorial in Chinese
    python main.py --repo https://github.com/username/repo --language "Chinese"
    • --repo or --dir - Specify either a GitHub repo URL or a local directory path (required, mutually exclusive)
    • -n, --name - Project name (optional, derived from URL/directory if omitted)
    • -t, --token - GitHub token (or set GITHUB_TOKEN environment variable)
    • -o, --output - Output directory (default: ./output)
    • -i, --include - Files to include (e.g., ".py" ".js")
    • -e, --exclude - Files to exclude (e.g., "tests/" "docs/")
    • -s, --max-size - Maximum file size in bytes (default: 100KB)
    • --language - Language for the generated tutorial (default: "english")

The application will crawl the repository, analyze the codebase structure, generate tutorial content in the specified language, and save the output in the specified directory (default: ./output).

💡 Development Tutorial

  • I built using Agentic Coding, the fastest development paradigm, where humans simply design and agents code.

  • The secret weapon is Pocket Flow, a 100-line LLM framework that lets Agents (e.g., Cursor AI) build for you

  • Check out the Step-by-step YouTube development tutorial:



联系我们 contact @ memedata.com