docs: translate code comments in Chinese READMEs (s04-s06) (#590)

This commit is contained in:
zl1nq
2026-10-27 12:41:03 +08:00
committed by GitHub
parent 8491527b3c
commit a2f81623d5
3 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -85,7 +85,7 @@ def trigger_hooks(event: str, *args):
def context_inject_hook(query: str) -> str | None:
"""Inject current working directory info into every prompt."""
print(f"\033[90m[HOOK] UserPromptSubmit: working in {WORKDIR}\033[0m")
return None # return None = no modification, let prompt through
return None # return None = 不修改提示词,直接放行
register_hook("UserPromptSubmit", context_inject_hook)
```
@@ -139,7 +139,7 @@ def summary_hook(messages: list) -> str | None:
for b in (m.get("content") if isinstance(m.get("content"), list) else [])
if isinstance(b, dict) and b.get("type") == "tool_result")
print(f"\033[90m[HOOK] Stop: session used {tool_count} tool calls\033[0m")
return None # return None = allow stop, return string = force continuation
return None # return None = 允许终止, return string = 强制继续
register_hook("Stop", summary_hook)
```
@@ -153,7 +153,7 @@ tool_calls = [
if not tool_calls:
force = trigger_hooks("Stop", messages) # ← 退出之前
if force:
# hook returned a message → inject it and continue
# hook 返回消息 → 注入消息并继续执行
messages.append({"role": "user", "content": force})
continue
return
+2 -2
View File
@@ -40,14 +40,14 @@ class TodoManager:
self.items = []
def update(self, todos: list | str) -> str:
# Parse and validate before replacing the current list.
# 替换当前列表前进行解析与校验
validated = []
...
self.items = validated
return self.render()
def render(self) -> str:
# [ ] pending, [>] in progress, [x] completed
# [ ] 待办, [>] 进行中, [x] 已完成
...
+1 -1
View File
@@ -31,7 +31,7 @@ Agent 在修一个 bug。为了追踪调用链,它读取了许多文件;每
**run_subagent** 创建新的消息列表,运行嵌套循环,并返回最终文本:
```python
SUB_TOOLS = list(BASE_TOOLS) # no task tool
SUB_TOOLS = list(BASE_TOOLS) # 不含 task 工具
def run_subagent(prompt: str) -> str:
messages = [{"role": "user", "content": prompt}]