Skip to content
프로젝트

yexia553/learn-agents-from-opencode

GitHub에서 보기

소개

opencode 소스 코드를 바탕으로 작성한 에이전트 개발 튜토리얼입니다.

학습 및 교육

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
-1
in 15 days
-1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Learn Agents from OpenCode

中文 | English

A Chinese tutorial series on learning Coding Agent engineering architecture from the OpenCode source code.

OpenCode is an excellent open-source Coding Agent project with complete implementations of core concepts such as Agent, Tool, Permission, Skill, Session, and Provider. This repository documents the tutorials I compiled while studying the OpenCode source code, aiming to help readers understand the engineering design of a real-world Agent project rather than building a toy example from scratch.

These tutorials were primarily generated with assistance from OpenCode, Claude Code, and Codex, and have been manually reviewed. It is recommended to read them alongside the OpenCode source code.

Target Audience

  • Users who have already used coding agents like Claude Code, Codex, or OpenCode and want to understand their internal workings
  • Developers looking to implement their own controllable Coding Agent or other types of Agents
  • Engineers with requirements for Agent permissions, tool calling, session management, prompt assembly, and other modules

Quick Start

This repo includes the OpenCode source code as a Git submodule so you can follow the tutorials while reading the actual implementation.

# Clone with submodule (recommended)
git clone --recursive https://github.com/yexia553/learn-agents-from-opencode.git

# Or if already cloned, initialize the submodule
git submodule update --init --recursive

# The OpenCode source will be available at ./opencode/
cd opencode && bun install

Note: Tutorials reference source files under opencode/packages/opencode/src/....

Tutorial Index

For full navigation, see docs/README.md.

No. Tutorial Description
00 Learning Plan Complete architecture learning roadmap
01 System Prompt Prompt construction, Provider adaptation, environment injection
02 Permission System Permission rules, request flow, BashArity
03 Agent System Built-in Agents, configuration system, permission integration
04 Tool System Tool definition, registration, execution flow
05 Iterative Info Gathering Tool Chaining, Explore Agent, SubAgent
06 Skill System Skill definition, discovery mechanism, tool integration
07 Session System Session management, message flow, context compression
08 Provider System Multi-model adaptation, SDK initialization, cost calculation

Note: The tutorial documents below are currently available in Chinese only. English translations will be added progressively.

Repository Structure

.
├── docs/
│   ├── README.md
│   ├── 00-learning-plan.md
│   └── tutorials/
│       ├── 01-system-prompt.md
│       ├── 02-permission-system.md
│       ├── 03-agent-system.md
│       ├── 04-tool-system.md
│       ├── 05-iterative-info-gathering.md
│       ├── 06-skill-system.md
│       ├── 07-session-system.md
│       └── 08-provider-system.md
├── opencode/                  # OpenCode source code (submodule)
│   └── packages/
│       └── opencode/
│           └── src/
├── .github/
│   ├── ISSUE_TEMPLATE/
│   ├── workflows/
│   └── pull_request_template.md
├── CONTRIBUTING.md
├── CODE_OF_CONDUCT.md
├── SECURITY.md
├── CHANGELOG.md
├── LICENSE
├── README.md
└── README.zh.md

Contributing

Contributions via issues or pull requests are welcome. Please read CONTRIBUTING.md first.

License

This project is licensed under the MIT License.

Related Resources

Star History

관련 프로젝트 살펴보기

불러오는 중…