TeenyCode:揭秘 200 行程式碼打造的極簡 AI 編碼代理 / TeenyCode: Unveiling a Minimalist AI Coding Agent in Under 200 LOC

一個旨在教育目的、極其精簡且可高度客製化的 TypeScript AI 編碼 CLI 工具 / A tiny, hackable TypeScript AI coding CLI designed for educational purposes.

🔎 工具速覽 / AT A GLANCE

CategoryAI Developer Tools / Open Source
PricingFree (Open Source)
BestForDevelopers wanting to learn how AI agents work / 想要學習 AI Agent 運作原理的開發者
GitHub Stars⭐ 27

🚀 引言 / Introduction

在 AI 代理(AI Agents)日益複雜的今天,TeenyCode 提供了一種極簡主義的視角。它僅用不到 200 行 TypeScript 程式碼,就實現了一個能夠讀取、列出並編輯本地檔案的完整功能循環,將複雜的代理概念轉化為透明且可學習的範例。

In an era of increasingly complex AI agents, TeenyCode offers a minimalist perspective. With fewer than 200 lines of TypeScript, it implements a full functional loop capable of reading, listing, and editing local files, transforming complex agent concepts into a transparent and learnable example.

🛠️ 核心功能 / Key Features

Chat-based CLI: Interacts directly with developers using OpenAI's Tool Calling mechanism.

基於對話的 CLI 介面:透過 OpenAI 的 Tool Calling 機制與開發者直接互動。

Core File Tools: Built-in with three essential tools: read_file, list_files, and edit_file.

核心文件操作工具:內建 read_file、list_files 與 edit_file 三大基礎工具。

Precise Editing Logic: Prefers reading files over guessing, making the smallest possible edits to satisfy requests.

精準編輯邏輯:優先閱讀文件而非盲目猜測,僅執行滿足需求的最小化修改。

Minimal Dependencies: Clean code structure that is incredibly easy to tweak or extend.

極簡依賴與結構:程式碼結構清晰,極易進行二次開發或修改。

💡 技術亮點 / Tech Highlights

Education-Focused: Aims to demonstrate core agent elements rather than building a bloated commercial product.

教育導向:旨在演示 AI 代理的核心元素,而非建立一個龐大的商業產品。

Safety by Design: Purposely excludes bash tools to reduce risk, encouraging developers to expand it based on their needs.

安全設計:刻意不包含 bash 工具以降低風險,鼓勵開發者根據需求自行擴展。

Strong Type Validation: Uses Zod to ensure tool input correctness, exporting schemas to JSON for the model.

強型別驗證:使用 Zod 確保 Tool 輸入的正確性,並將 Schema 轉換為 JSON 格式供模型使用。

📦 快速上手 / Quick Start

Set API Key: export OPENAI_API_KEY=sk-...

設定 API 金鑰:export OPENAI_API_KEY=sk-...

Run Immediately: Start directly with npx teenycode without cloning the repo.

立即運行:使用 npx teenycode 直接啟動,無需克隆倉庫。

Run from Source: Clone the repo, run npm install, and configure the .env file to start.

源碼運行:克隆儲存庫後執行 npm install 並設定 .env 文件即可啟動。

準備好試試 TeenyCode:揭秘 200 行程式碼打造的極簡 AI 編碼代理 / TeenyCode: Unveiling a Minimalist AI Coding Agent in Under 200 LOC 了嗎?

Ready to try TeenyCode:揭秘 200 行程式碼打造的極簡 AI 編碼代理 / TeenyCode: Unveiling a Minimalist AI Coding Agent in Under 200 LOC?

前往 GitHub 頁面 →

留言