zrcoder 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zrcoder
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Terminal coding agent chat — OpenAI-compatible APIs, tools, and slash commands
5
5
  Keywords: cli,agent,coding,terminal,openai
6
6
  Author: Zr
@@ -23,6 +23,7 @@ Requires-Python: >=3.12
23
23
  Project-URL: Homepage, https://github.com/ZRMYDYCG/ClaudeCode
24
24
  Project-URL: Repository, https://github.com/ZRMYDYCG/ClaudeCode
25
25
  Project-URL: Issues, https://github.com/ZRMYDYCG/ClaudeCode/issues
26
+ Project-URL: Changelog, https://github.com/ZRMYDYCG/ClaudeCode/blob/main/CHANGELOG.md
26
27
  Description-Content-Type: text/markdown
27
28
 
28
29
  # Zrcoder
@@ -64,6 +65,11 @@ zrcoder
64
65
 
65
66
  常用命令:`/help`、`/status`、`/new`、`/api-detail`、`/exit`。
66
67
 
68
+ ## 变更与发版
69
+
70
+ - 用户可见变更:[CHANGELOG.md](CHANGELOG.md)
71
+ - 维护者发版流程:[RELEASING.md](RELEASING.md)
72
+
67
73
  ## 从源码开发
68
74
 
69
75
  ```bash
@@ -37,6 +37,11 @@ zrcoder
37
37
 
38
38
  常用命令:`/help`、`/status`、`/new`、`/api-detail`、`/exit`。
39
39
 
40
+ ## 变更与发版
41
+
42
+ - 用户可见变更:[CHANGELOG.md](CHANGELOG.md)
43
+ - 维护者发版流程:[RELEASING.md](RELEASING.md)
44
+
40
45
  ## 从源码开发
41
46
 
42
47
  ```bash
@@ -2,12 +2,17 @@
2
2
  终端主循环:读输入、分发斜杠命令、驱动 Agent。
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
7
+ import asyncio
5
8
  from typing import Any, Literal
6
9
 
7
10
  from prompt_toolkit import PromptSession
11
+ from pydantic_ai import Agent
12
+ from pydantic_graph import End
8
13
 
9
14
  from core.agent import MODEL_NAME, agent, api_call_log
10
- from core.ui.commands import COMMANDS, SessionState, print_agent_steps, print_divider
15
+ from core.ui.commands import COMMANDS, SessionState, print_divider, print_part
11
16
  from core.ui.render import console, print_welcome_banner
12
17
 
13
18
  # PromptSession 比内置 input() 好用:支持左右移光标编辑,并记住本次输入历史
@@ -50,15 +55,38 @@ def handle_command(user_input: str, state: SessionState) -> CommandAction:
50
55
 
51
56
  def apply_result(state: SessionState, result: Any) -> None:
52
57
  """
53
- 跑完一轮 Agent 后,把结果同步到 SessionState 并显示新增的中间过程。
58
+ 跑完一轮 Agent 后,把结果同步到 SessionState
54
59
  """
55
60
  state.history = result.all_messages()
56
61
  usage = result.usage
57
62
  state.input_tokens += usage.input_tokens
58
63
  state.output_tokens += usage.output_tokens
59
64
  state.last_api_calls = list(api_call_log)
60
- # result.new_messages() 直接拿到这一轮新增的 message,不需要手动算偏移
61
- print_agent_steps(result.new_messages())
65
+
66
+
67
+ async def run_agent_loop(user_input: str, state: SessionState) -> None:
68
+ """
69
+ 逐节点驱动 Agent 循环,每步实时打印。
70
+ """
71
+ api_call_log.clear()
72
+
73
+ async with agent.iter(user_input, message_history=state.history) as run:
74
+ node = run.next_node
75
+
76
+ while not isinstance(node, End):
77
+ node = await run.next(node)
78
+
79
+ if Agent.is_call_tools_node(node):
80
+ for response_part in node.model_response.parts:
81
+ print_part(response_part)
82
+
83
+ elif Agent.is_model_request_node(node):
84
+ for request_part in node.request.parts:
85
+ if getattr(request_part, "part_kind", None) == "tool-return":
86
+ print_part(request_part)
87
+
88
+ apply_result(state, run.result)
89
+ console.print()
62
90
 
63
91
 
64
92
  def main() -> None:
@@ -80,10 +108,8 @@ def main() -> None:
80
108
  if action == "continue":
81
109
  continue
82
110
 
83
- # 核心 Agent 循环:清空收集 buffer,跑一轮,把结果应用到 state
84
- api_call_log.clear()
85
- result = agent.run_sync(user_input, message_history=state.history)
86
- apply_result(state, result)
111
+ # 核心 Agent 循环:自己驱动节点流转,实时打印每一步
112
+ asyncio.run(run_agent_loop(user_input, state))
87
113
 
88
114
 
89
115
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "zrcoder"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "Terminal coding agent chat — OpenAI-compatible APIs, tools, and slash commands"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -38,6 +38,7 @@ email = "547471919@qq.com"
38
38
  Homepage = "https://github.com/ZRMYDYCG/ClaudeCode"
39
39
  Repository = "https://github.com/ZRMYDYCG/ClaudeCode"
40
40
  Issues = "https://github.com/ZRMYDYCG/ClaudeCode/issues"
41
+ Changelog = "https://github.com/ZRMYDYCG/ClaudeCode/blob/main/CHANGELOG.md"
41
42
 
42
43
  [project.scripts]
43
44
  zrcoder = "core.cli:main"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "zrcoder"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "Terminal coding agent chat — OpenAI-compatible APIs, tools, and slash commands"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -31,6 +31,7 @@ classifiers = [
31
31
  Homepage = "https://github.com/ZRMYDYCG/ClaudeCode"
32
32
  Repository = "https://github.com/ZRMYDYCG/ClaudeCode"
33
33
  Issues = "https://github.com/ZRMYDYCG/ClaudeCode/issues"
34
+ Changelog = "https://github.com/ZRMYDYCG/ClaudeCode/blob/main/CHANGELOG.md"
34
35
 
35
36
  [project.scripts]
36
37
  zrcoder = "core.cli:main"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes