Skip to content

Commit a2f8162

Browse files
authored
docs: translate code comments in Chinese READMEs (s04-s06) (#590)
1 parent 8491527 commit a2f8162

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎s04_hooks/README.zh.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def trigger_hooks(event: str, *args):
8585
def context_inject_hook(query: str) -> str | None:
8686
"""Inject current working directory info into every prompt."""
8787
print(f"\033[90m[HOOK] UserPromptSubmit: working in {WORKDIR}\033[0m")
88-
return None # return None = no modification, let prompt through
88+
return None # return None = 不修改提示词,直接放行
8989

9090
register_hook("UserPromptSubmit", context_inject_hook)
9191
```
@@ -139,7 +139,7 @@ def summary_hook(messages: list) -> str | None:
139139
for b in (m.get("content") if isinstance(m.get("content"), list) else [])
140140
if isinstance(b, dict) and b.get("type") == "tool_result")
141141
print(f"\033[90m[HOOK] Stop: session used {tool_count} tool calls\033[0m")
142-
return None # return None = allow stop, return string = force continuation
142+
return None # return None = 允许终止, return string = 强制继续
143143

144144
register_hook("Stop", summary_hook)
145145
```
@@ -153,7 +153,7 @@ tool_calls = [
153153
if not tool_calls:
154154
force = trigger_hooks("Stop", messages) # ← 退出之前
155155
if force:
156-
# hook returned a message → inject it and continue
156+
# hook 返回消息 → 注入消息并继续执行
157157
messages.append({"role": "user", "content": force})
158158
continue
159159
return

‎s05_todo_write/README.zh.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ class TodoManager:
4040
self.items = []
4141

4242
def update(self, todos: list | str) -> str:
43-
# Parse and validate before replacing the current list.
43+
# 替换当前列表前进行解析与校验
4444
validated = []
4545
...
4646
self.items = validated
4747
return self.render()
4848

4949
def render(self) -> str:
50-
# [ ] pending, [>] in progress, [x] completed
50+
# [ ] 待办, [>] 进行中, [x] 已完成
5151
...
5252

5353

‎s06_subagent/README.zh.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Agent 在修一个 bug。为了追踪调用链,它读取了许多文件;每
3131
**run_subagent** 创建新的消息列表,运行嵌套循环,并返回最终文本:
3232

3333
```python
34-
SUB_TOOLS = list(BASE_TOOLS) # no task tool
34+
SUB_TOOLS = list(BASE_TOOLS) # 不含 task 工具
3535

3636
def run_subagent(prompt: str) -> str:
3737
messages = [{"role": "user", "content": prompt}]

0 commit comments

Comments
 (0)