ci/lint: ruff format todo stack and related CLI/agent files

This commit is contained in:
2026-07-18 13:22:42 +08:00
parent 7f49c47105
commit 39f9a7f636
5 changed files with 9 additions and 28 deletions
+1 -5
View File
@@ -371,11 +371,7 @@ async def run_chat_loop(
assistant = _last_assistant(messages, pre_len)
tool_calls = assistant.tool_calls
if tool_calls is UNSET or not tool_calls or tools is None:
if (
todo_stack is not None
and todo_stack.needs_review()
and not todo_review_injected
):
if todo_stack is not None and todo_stack.needs_review() and not todo_review_injected:
todo_review_injected = True
# Non-user control identity so retry/history don't treat this as human input.
messages.append(DeveloperChatMessage(content=todo_stack.review_prompt()))
+4 -8
View File
@@ -98,11 +98,11 @@ class TodoStack:
frame_items = msgspec.convert(frame.get("items"), type=list[TodoItem])
items.extend(frame_items)
return cls(TodoStackData(items=items, next_id=next_id))
except (msgspec.ValidationError, TypeError, ValueError):
except msgspec.ValidationError, TypeError, ValueError:
return cls()
try:
data = msgspec.convert(raw, type=TodoStackData)
except (msgspec.ValidationError, TypeError, ValueError):
except msgspec.ValidationError, TypeError, ValueError:
return cls()
if data.next_id < 1:
data = msgspec.structs.replace(data, next_id=1)
@@ -234,14 +234,10 @@ def parse_push_titles(raw: str) -> list[str]:
if text.startswith("["):
try:
data: object = msgspec.json.decode(text.encode())
except (msgspec.DecodeError, UnicodeEncodeError):
except msgspec.DecodeError, UnicodeEncodeError:
data = None
if isinstance(data, list):
out = [
item.strip()
for item in cast("list[object]", data)
if isinstance(item, str) and item.strip()
]
out = [item.strip() for item in cast("list[object]", data) if isinstance(item, str) and item.strip()]
if out:
return out
parts: list[str] = []
+1 -5
View File
@@ -62,11 +62,7 @@ class HistoryLimitType(click.ParamType):
def shell_complete(self, ctx: click.Context, param: click.Parameter, incomplete: str) -> list[CompletionItem]:
del ctx, param
tokens = ("last", "1", "5", "10", "20")
return [
CompletionItem(token)
for token in tokens
if incomplete == "" or token.startswith(incomplete.lower())
]
return [CompletionItem(token) for token in tokens if incomplete == "" or token.startswith(incomplete.lower())]
HELP_FOOTER = (
+1 -3
View File
@@ -124,9 +124,7 @@ class ReplState:
loop = asyncio.get_running_loop()
except RuntimeError:
return
task = loop.create_task(
self.memory.update_session_todo_stack(self.session_id, self.todo_stack.to_raw())
)
task = loop.create_task(self.memory.update_session_todo_stack(self.session_id, self.todo_stack.to_raw()))
# Keep a strong ref until done so the task is not GC'd mid-flight.
self._todo_persist_tasks.add(task)
task.add_done_callback(self._todo_persist_tasks.discard)
+2 -7
View File
@@ -191,12 +191,7 @@ async def test_loop_injects_todo_review_when_untouched() -> None:
async for _event in agent.run("do stuff"):
pass
assert client.calls >= 2
assert any(
isinstance(m, DeveloperChatMessage) and "Todo stack review" in m.content
for m in agent.messages
)
assert not any(
isinstance(m, UserChatMessage) and "Todo stack review" in m.content for m in agent.messages
)
assert any(isinstance(m, DeveloperChatMessage) and "Todo stack review" in m.content for m in agent.messages)
assert not any(isinstance(m, UserChatMessage) and "Todo stack review" in m.content for m in agent.messages)
finally:
set_todo_stack(None)