Skip to content

Commit 665831c

Browse files
committed
better doc
1 parent aea8844 commit 665831c

46 files changed

Lines changed: 1218 additions & 3506 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,7 @@ web/out/
221221
.vercel
222222
.env*.local
223223
test_providers.py
224+
225+
# Internal analysis artifacts (not learning material)
226+
analysis/
227+
analysis_progress.md

README-ja.md

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
**12 の段階的セッション、シンプルなループから分離された自律実行まで。**
2525
**各セッションは1つのメカニズムを追加する。各メカニズムには1つのモットーがある。**
2626

27-
> **s01**   *"Bash があれば十分"* — 1つのツール + 1つのループ = エージェント
27+
> **s01**   *"One loop & Bash is all you need"* — 1つのツール + 1つのループ = エージェント
2828
>
2929
> **s02**   *"ループは変わらない"* — ツール追加はハンドラー追加であり、ループの作り直しではない
3030
>
@@ -101,8 +101,8 @@ pip install -r requirements.txt
101101
cp .env.example .env # .env を編集して ANTHROPIC_API_KEY を入力
102102

103103
python agents/s01_agent_loop.py # ここから開始
104-
python agents/s11_autonomous_agents.py # 完全自律チーム
105-
python agents/s12_worktree_task_isolation.py # Task 対応の worktree 分離
104+
python agents/s12_worktree_task_isolation.py # 全セッションの到達点
105+
python agents/s_full.py # 総括: 全メカニズム統合
106106
```
107107

108108
### Web プラットフォーム
@@ -121,13 +121,13 @@ cd web && npm install && npm run dev # http://localhost:3000
121121
s01 エージェントループ [1] s03 TodoWrite [5]
122122
while + stop_reason TodoManager + nag リマインダー
123123
| |
124-
+-> s02 ツール [4] s04 サブエージェント [5]
124+
+-> s02 Tool Use [4] s04 サブエージェント [5]
125125
dispatch map: name->handler 子ごとに新しい messages[]
126126
|
127127
s05 Skills [5]
128128
SKILL.md を tool_result で注入
129129
|
130-
s06 Compact [5]
130+
s06 Context Compact [5]
131131
3層コンテキスト圧縮
132132
133133
フェーズ3: 永続化 フェーズ4: チーム
@@ -152,7 +152,7 @@ s08 バックグラウンドタスク [6] s10 チームプロトコル
152152
```
153153
learn-claude-code/
154154
|
155-
|-- agents/ # Python リファレンス実装 (s01-s12 + 完全版)
155+
|-- agents/ # Python リファレンス実装 (s01-s12 + s_full 総括)
156156
|-- docs/{en,zh,ja}/ # メンタルモデル優先のドキュメント (3言語)
157157
|-- web/ # インタラクティブ学習プラットフォーム (Next.js)
158158
|-- skills/ # s05 の Skill ファイル
@@ -166,19 +166,63 @@ learn-claude-code/
166166

167167
| セッション | トピック | モットー |
168168
|-----------|---------|---------|
169-
| [s01](./docs/ja/s01-the-agent-loop.md) | エージェントループ | *Bash があれば十分* |
170-
| [s02](./docs/ja/s02-tool-use.md) | ツール | *ループは変わらない* |
169+
| [s01](./docs/ja/s01-the-agent-loop.md) | エージェントループ | *One loop & Bash is all you need* |
170+
| [s02](./docs/ja/s02-tool-use.md) | Tool Use | *ループは変わらない* |
171171
| [s03](./docs/ja/s03-todo-write.md) | TodoWrite | *行動する前に計画せよ* |
172172
| [s04](./docs/ja/s04-subagent.md) | サブエージェント | *プロセス分離 = コンテキスト分離* |
173173
| [s05](./docs/ja/s05-skill-loading.md) | Skills | *必要な時にロード、事前にではなく* |
174-
| [s06](./docs/ja/s06-context-compact.md) | Compact | *戦略的忘却* |
174+
| [s06](./docs/ja/s06-context-compact.md) | Context Compact | *戦略的忘却* |
175175
| [s07](./docs/ja/s07-task-system.md) | タスクシステム | *状態は圧縮を生き延びる* |
176176
| [s08](./docs/ja/s08-background-tasks.md) | バックグラウンドタスク | *撃ちっ放し* |
177177
| [s09](./docs/ja/s09-agent-teams.md) | エージェントチーム | *追記で送信、排出で読取* |
178178
| [s10](./docs/ja/s10-team-protocols.md) | チームプロトコル | *同じ request_id、2つのプロトコル* |
179179
| [s11](./docs/ja/s11-autonomous-agents.md) | 自律エージェント | *ポーリング、クレーム、作業、繰り返し* |
180180
| [s12](./docs/ja/s12-worktree-task-isolation.md) | Worktree + タスク分離 | *ディレクトリで分離し、タスクIDで調整する* |
181181

182+
## 次のステップ -- 理解から出荷へ
183+
184+
12 セッションを終えれば、エージェントの内部構造を完全に理解している。その知識を活かす 2 つの方法:
185+
186+
### Kode Agent CLI -- オープンソース Coding Agent CLI
187+
188+
> `npm i -g @shareai-lab/kode`
189+
190+
Skill & LSP 対応、Windows 対応、GLM / MiniMax / DeepSeek 等のオープンモデルに接続可能。インストールしてすぐ使える。
191+
192+
GitHub: **[shareAI-lab/Kode-cli](https://github.com/shareAI-lab/Kode-cli)**
193+
194+
### Kode Agent SDK -- アプリにエージェント機能を埋め込む
195+
196+
公式 Claude Code Agent SDK は内部で完全な CLI プロセスと通信する -- 同時ユーザーごとに独立のターミナルプロセスが必要。Kode SDK は独立ライブラリでユーザーごとのプロセスオーバーヘッドがなく、バックエンド、ブラウザ拡張、組み込みデバイス等に埋め込み可能。
197+
198+
GitHub: **[shareAI-lab/Kode-agent-sdk](https://github.com/shareAI-lab/Kode-agent-sdk)**
199+
200+
---
201+
202+
## 姉妹教材: *オンデマンドセッション*から*常時稼働アシスタント*
203+
204+
本リポジトリが教えるエージェントは **使い捨て型** -- ターミナルを開き、タスクを与え、終わったら閉じる。次のセッションは白紙から始まる。これが Claude Code のモデル。
205+
206+
[OpenClaw](https://github.com/openclaw/openclaw) は別の可能性を証明した: 同じ agent core の上に 2 つのメカニズムを追加するだけで、エージェントは「突かないと動かない」から「30 秒ごとに自分で起きて仕事を探す」に変わる:
207+
208+
- **ハートビート** -- 30 秒ごとにシステムがエージェントにメッセージを送り、やることがあるか確認させる。なければスリープ続行、あれば即座に行動。
209+
- **Cron** -- エージェントが自ら未来のタスクをスケジュールし、時間が来たら自動実行。
210+
211+
さらにマルチチャネル IM ルーティング (WhatsApp / Telegram / Slack / Discord 等 13+ プラットフォーム)、永続コンテキストメモリ、Soul パーソナリティシステムを加えると、エージェントは使い捨てツールから常時稼働のパーソナル AI アシスタントへ変貌する。
212+
213+
**[claw0](https://github.com/shareAI-lab/claw0)** はこれらのメカニズムをゼロから分解する姉妹教材リポジトリ:
214+
215+
```
216+
claw agent = agent core + heartbeat + cron + IM chat + memory + soul
217+
```
218+
219+
```
220+
learn-claude-code claw0
221+
(エージェントランタイムコア: (能動的な常時稼働アシスタント:
222+
ループ、ツール、計画、 ハートビート、cron、IM チャネル、
223+
チーム、worktree 分離) メモリ、Soul パーソナリティ)
224+
```
225+
182226
## ライセンス
183227

184228
MIT

README-zh.md

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
**12 个递进式课程, 从简单循环到隔离化的自治执行。**
2525
**每个课程添加一个机制。每个机制有一句格言。**
2626

27-
> **s01**   *"Bash 就够了"* — 一个工具 + 一个循环 = 一个智能体
27+
> **s01**   *"One loop & Bash is all you need"* — 一个工具 + 一个循环 = 一个智能体
2828
>
2929
> **s02**   *"循环没有变"* — 加工具就是加 handler, 不是重写循环
3030
>
@@ -101,8 +101,8 @@ pip install -r requirements.txt
101101
cp .env.example .env # 编辑 .env 填入你的 ANTHROPIC_API_KEY
102102

103103
python agents/s01_agent_loop.py # 从这里开始
104-
python agents/s11_autonomous_agents.py # 完整自治团队
105-
python agents/s12_worktree_task_isolation.py # Task 感知的 worktree 隔离
104+
python agents/s12_worktree_task_isolation.py # 完整递进终点
105+
python agents/s_full.py # 总纲: 全部机制合一
106106
```
107107

108108
### Web 平台
@@ -121,13 +121,13 @@ cd web && npm install && npm run dev # http://localhost:3000
121121
s01 Agent 循环 [1] s03 TodoWrite [5]
122122
while + stop_reason TodoManager + nag 提醒
123123
| |
124-
+-> s02 工具 [4] s04 子智能体 [5]
124+
+-> s02 Tool Use [4] s04 子智能体 [5]
125125
dispatch map: name->handler 每个子智能体独立 messages[]
126126
|
127127
s05 Skills [5]
128128
SKILL.md 通过 tool_result 注入
129129
|
130-
s06 Compact [5]
130+
s06 Context Compact [5]
131131
三层上下文压缩
132132
133133
第三阶段: 持久化 第四阶段: 团队
@@ -152,7 +152,7 @@ s08 后台任务 [6] s10 团队协议 [12]
152152
```
153153
learn-claude-code/
154154
|
155-
|-- agents/ # Python 参考实现 (s01-s12 + 完整版)
155+
|-- agents/ # Python 参考实现 (s01-s12 + s_full 总纲)
156156
|-- docs/{en,zh,ja}/ # 心智模型优先的文档 (3 种语言)
157157
|-- web/ # 交互式学习平台 (Next.js)
158158
|-- skills/ # s05 的 Skill 文件
@@ -166,19 +166,63 @@ learn-claude-code/
166166

167167
| 课程 | 主题 | 格言 |
168168
|------|------|------|
169-
| [s01](./docs/zh/s01-the-agent-loop.md) | Agent 循环 | *Bash 就够了* |
170-
| [s02](./docs/zh/s02-tool-use.md) | 工具 | *循环没有变* |
169+
| [s01](./docs/zh/s01-the-agent-loop.md) | Agent 循环 | *One loop & Bash is all you need* |
170+
| [s02](./docs/zh/s02-tool-use.md) | Tool Use | *循环没有变* |
171171
| [s03](./docs/zh/s03-todo-write.md) | TodoWrite | *先计划再行动* |
172172
| [s04](./docs/zh/s04-subagent.md) | 子智能体 | *进程隔离 = 上下文隔离* |
173173
| [s05](./docs/zh/s05-skill-loading.md) | Skills | *按需加载, 而非预装* |
174-
| [s06](./docs/zh/s06-context-compact.md) | Compact | *策略性遗忘* |
174+
| [s06](./docs/zh/s06-context-compact.md) | Context Compact | *策略性遗忘* |
175175
| [s07](./docs/zh/s07-task-system.md) | 任务系统 | *状态在压缩后存活* |
176176
| [s08](./docs/zh/s08-background-tasks.md) | 后台任务 | *发射后不管* |
177177
| [s09](./docs/zh/s09-agent-teams.md) | 智能体团队 | *追加即发送, 排空即读取* |
178178
| [s10](./docs/zh/s10-team-protocols.md) | 团队协议 | *同一个 request_id, 两个协议* |
179179
| [s11](./docs/zh/s11-autonomous-agents.md) | 自治智能体 | *轮询, 认领, 工作, 重复* |
180180
| [s12](./docs/zh/s12-worktree-task-isolation.md) | Worktree + 任务隔离 | *目录隔离, 任务 ID 协调* |
181181

182+
## 学完之后 -- 从理解到落地
183+
184+
12 个课程走完, 你已经从内到外理解了 agent 的工作原理。两种方式把知识变成产品:
185+
186+
### Kode Agent CLI -- 开源 Coding Agent CLI
187+
188+
> `npm i -g @shareai-lab/kode`
189+
190+
支持 Skill & LSP, 适配 Windows, 可接 GLM / MiniMax / DeepSeek 等开放模型。装完即用。
191+
192+
GitHub: **[shareAI-lab/Kode-cli](https://github.com/shareAI-lab/Kode-cli)**
193+
194+
### Kode Agent SDK -- 把 Agent 能力嵌入你的应用
195+
196+
官方 Claude Code Agent SDK 底层与完整 CLI 进程通信 -- 每个并发用户 = 一个终端进程。Kode SDK 是独立库, 无 per-user 进程开销, 可嵌入后端、浏览器插件、嵌入式设备等任意运行时。
197+
198+
GitHub: **[shareAI-lab/Kode-agent-sdk](https://github.com/shareAI-lab/Kode-agent-sdk)**
199+
200+
---
201+
202+
## 姊妹教程: 从*被动临时会话**主动常驻助手*
203+
204+
本仓库教的 agent 属于 **用完即走** 型 -- 开终端、给任务、做完关掉, 下次重开是全新会话。Claude Code 就是这种模式。
205+
206+
[OpenClaw](https://github.com/openclaw/openclaw) (小龙虾) 证明了另一种可能: 在同样的 agent core 之上, 加两个机制就能让 agent 从"踹一下动一下"变成"自己隔 30 秒醒一次找活干":
207+
208+
- **心跳 (Heartbeat)** -- 每 30 秒系统给 agent 发一条消息, 让它检查有没有事可做。没事就继续睡, 有事立刻行动。
209+
- **定时任务 (Cron)** -- agent 可以给自己安排未来要做的事, 到点自动执行。
210+
211+
再加上 IM 多通道路由 (WhatsApp/Telegram/Slack/Discord 等 13+ 平台)、不清空的上下文记忆、Soul 人格系统, agent 就从一个临时工具变成了始终在线的个人 AI 助手。
212+
213+
**[claw0](https://github.com/shareAI-lab/claw0)** 是我们的姊妹教学仓库, 从零拆解这些机制:
214+
215+
```
216+
claw agent = agent core + heartbeat + cron + IM chat + memory + soul
217+
```
218+
219+
```
220+
learn-claude-code claw0
221+
(agent 运行时内核: (主动式常驻 AI 助手:
222+
循环、工具、规划、 心跳、定时任务、IM 通道、
223+
团队、worktree 隔离) 记忆、Soul 人格)
224+
```
225+
182226
## 许可证
183227

184228
MIT

README.md

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
**12 progressive sessions, from a simple loop to isolated autonomous execution.**
2525
**Each session adds one mechanism. Each mechanism has one motto.**
2626

27-
> **s01**   *"Bash is all you need"* — one tool + one loop = an agent
27+
> **s01**   *"One loop & Bash is all you need"* — one tool + one loop = an agent
2828
>
2929
> **s02**   *"The loop didn't change"* — adding tools means adding handlers, not rewriting the loop
3030
>
@@ -101,8 +101,8 @@ pip install -r requirements.txt
101101
cp .env.example .env # Edit .env with your ANTHROPIC_API_KEY
102102

103103
python agents/s01_agent_loop.py # Start here
104-
python agents/s11_autonomous_agents.py # Full autonomous team
105-
python agents/s12_worktree_task_isolation.py # Task-aware worktree isolation
104+
python agents/s12_worktree_task_isolation.py # Full progression endpoint
105+
python agents/s_full.py # Capstone: all mechanisms combined
106106
```
107107

108108
### Web Platform
@@ -121,13 +121,13 @@ Phase 1: THE LOOP Phase 2: PLANNING & KNOWLEDGE
121121
s01 The Agent Loop [1] s03 TodoWrite [5]
122122
while + stop_reason TodoManager + nag reminder
123123
| |
124-
+-> s02 Tools [4] s04 Subagents [5]
124+
+-> s02 Tool Use [4] s04 Subagents [5]
125125
dispatch map: name->handler fresh messages[] per child
126126
|
127127
s05 Skills [5]
128128
SKILL.md via tool_result
129129
|
130-
s06 Compact [5]
130+
s06 Context Compact [5]
131131
3-layer compression
132132
133133
Phase 3: PERSISTENCE Phase 4: TEAMS
@@ -152,7 +152,7 @@ s08 Background Tasks [6] s10 Team Protocols [12]
152152
```
153153
learn-claude-code/
154154
|
155-
|-- agents/ # Python reference implementations (s01-s12 + full)
155+
|-- agents/ # Python reference implementations (s01-s12 + s_full capstone)
156156
|-- docs/{en,zh,ja}/ # Mental-model-first documentation (3 languages)
157157
|-- web/ # Interactive learning platform (Next.js)
158158
|-- skills/ # Skill files for s05
@@ -166,19 +166,63 @@ Available in [English](./docs/en/) | [中文](./docs/zh/) | [日本語](./docs/j
166166

167167
| Session | Topic | Motto |
168168
|---------|-------|-------|
169-
| [s01](./docs/en/s01-the-agent-loop.md) | The Agent Loop | *Bash is all you need* |
170-
| [s02](./docs/en/s02-tool-use.md) | Tools | *The loop didn't change* |
169+
| [s01](./docs/en/s01-the-agent-loop.md) | The Agent Loop | *One loop & Bash is all you need* |
170+
| [s02](./docs/en/s02-tool-use.md) | Tool Use | *The loop didn't change* |
171171
| [s03](./docs/en/s03-todo-write.md) | TodoWrite | *Plan before you act* |
172172
| [s04](./docs/en/s04-subagent.md) | Subagents | *Process isolation = context isolation* |
173173
| [s05](./docs/en/s05-skill-loading.md) | Skills | *Load on demand, not upfront* |
174-
| [s06](./docs/en/s06-context-compact.md) | Compact | *Strategic forgetting* |
174+
| [s06](./docs/en/s06-context-compact.md) | Context Compact | *Strategic forgetting* |
175175
| [s07](./docs/en/s07-task-system.md) | Tasks | *State survives /compact* |
176176
| [s08](./docs/en/s08-background-tasks.md) | Background Tasks | *Fire and forget* |
177177
| [s09](./docs/en/s09-agent-teams.md) | Agent Teams | *Append to send, drain to read* |
178178
| [s10](./docs/en/s10-team-protocols.md) | Team Protocols | *Same request_id, two protocols* |
179179
| [s11](./docs/en/s11-autonomous-agents.md) | Autonomous Agents | *Poll, claim, work, repeat* |
180180
| [s12](./docs/en/s12-worktree-task-isolation.md) | Worktree + Task Isolation | *Isolate by directory, coordinate by task ID* |
181181

182+
## What's Next -- from understanding to shipping
183+
184+
After the 12 sessions you understand how an agent works inside out. Two ways to put that knowledge to work:
185+
186+
### Kode Agent CLI -- Open-Source Coding Agent CLI
187+
188+
> `npm i -g @shareai-lab/kode`
189+
190+
Skill & LSP support, Windows-ready, pluggable with GLM / MiniMax / DeepSeek and other open models. Install and go.
191+
192+
GitHub: **[shareAI-lab/Kode-cli](https://github.com/shareAI-lab/Kode-cli)**
193+
194+
### Kode Agent SDK -- Embed Agent Capabilities in Your App
195+
196+
The official Claude Code Agent SDK communicates with a full CLI process under the hood -- each concurrent user means a separate terminal process. Kode SDK is a standalone library with no per-user process overhead, embeddable in backends, browser extensions, embedded devices, or any runtime.
197+
198+
GitHub: **[shareAI-lab/Kode-agent-sdk](https://github.com/shareAI-lab/Kode-agent-sdk)**
199+
200+
---
201+
202+
## Sister Repo: from *on-demand sessions* to *always-on assistant*
203+
204+
The agent this repo teaches is **use-and-discard** -- open a terminal, give it a task, close when done, next session starts blank. That is the Claude Code model.
205+
206+
[OpenClaw](https://github.com/openclaw/openclaw) proved another possibility: on top of the same agent core, two mechanisms turn the agent from "poke it to make it move" into "it wakes up every 30 seconds to look for work":
207+
208+
- **Heartbeat** -- every 30s the system sends the agent a message to check if there is anything to do. Nothing? Go back to sleep. Something? Act immediately.
209+
- **Cron** -- the agent can schedule its own future tasks, executed automatically when the time comes.
210+
211+
Add multi-channel IM routing (WhatsApp / Telegram / Slack / Discord, 13+ platforms), persistent context memory, and a Soul personality system, and the agent goes from a disposable tool to an always-on personal AI assistant.
212+
213+
**[claw0](https://github.com/shareAI-lab/claw0)** is our companion teaching repo that deconstructs these mechanisms from scratch:
214+
215+
```
216+
claw agent = agent core + heartbeat + cron + IM chat + memory + soul
217+
```
218+
219+
```
220+
learn-claude-code claw0
221+
(agent runtime core: (proactive always-on assistant:
222+
loop, tools, planning, heartbeat, cron, IM channels,
223+
teams, worktree isolation) memory, soul personality)
224+
```
225+
182226
## License
183227

184228
MIT

0 commit comments

Comments
 (0)