yycode 0.3.2__py3-none-any.whl

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.
Files changed (131) hide show
  1. agent/__init__.py +33 -0
  2. agent/acp/__init__.py +2 -0
  3. agent/acp/approval_adapter.py +134 -0
  4. agent/acp/content_adapter.py +45 -0
  5. agent/acp/jsonrpc.py +92 -0
  6. agent/acp/server.py +197 -0
  7. agent/acp/session_manager.py +193 -0
  8. agent/acp/update_adapter.py +192 -0
  9. agent/app_paths.py +25 -0
  10. agent/approval.py +169 -0
  11. agent/cancellation.py +52 -0
  12. agent/change_snapshot.py +186 -0
  13. agent/context_compressor.py +116 -0
  14. agent/graph.py +137 -0
  15. agent/llm_retry.py +434 -0
  16. agent/logger.py +97 -0
  17. agent/lsp/__init__.py +13 -0
  18. agent/lsp/client.py +151 -0
  19. agent/lsp/manager.py +234 -0
  20. agent/lsp/types.py +119 -0
  21. agent/message_context_manager.py +322 -0
  22. agent/message_format.py +105 -0
  23. agent/nodes/llm_node.py +58 -0
  24. agent/nodes/state.py +12 -0
  25. agent/nodes/task_guard_node.py +50 -0
  26. agent/nodes/tools_node.py +70 -0
  27. agent/plan_snapshot.py +70 -0
  28. agent/providers/__init__.py +13 -0
  29. agent/providers/anthropic_provider.py +268 -0
  30. agent/providers/base.py +52 -0
  31. agent/providers/openai_provider.py +279 -0
  32. agent/providers/text_tool_calls.py +118 -0
  33. agent/runtime/approval_service.py +184 -0
  34. agent/runtime/context.py +43 -0
  35. agent/runtime/tool_events.py +368 -0
  36. agent/runtime/tool_executor.py +208 -0
  37. agent/runtime/tool_output.py +261 -0
  38. agent/runtime/tool_registry.py +91 -0
  39. agent/runtime/tool_scheduler.py +35 -0
  40. agent/runtime/workflow_guard.py +217 -0
  41. agent/runtime/workspace.py +5 -0
  42. agent/runtime/workspace_tools.py +22 -0
  43. agent/session.py +787 -0
  44. agent/session_replay.py +95 -0
  45. agent/session_store.py +186 -0
  46. agent/skills.py +254 -0
  47. agent/streaming.py +248 -0
  48. agent/subagent.py +634 -0
  49. agent/task_memory.py +340 -0
  50. agent/todo_manager.py +304 -0
  51. agent/tool_retry.py +106 -0
  52. agent/tui/__init__.py +14 -0
  53. agent/tui/app.py +1325 -0
  54. agent/tui/approval.py +53 -0
  55. agent/tui/commands/__init__.py +6 -0
  56. agent/tui/commands/base.py +48 -0
  57. agent/tui/commands/clear.py +37 -0
  58. agent/tui/commands/help.py +27 -0
  59. agent/tui/commands/registry.py +94 -0
  60. agent/tui/help_content.py +108 -0
  61. agent/tui/renderers.py +1961 -0
  62. agent/tui/runner.py +439 -0
  63. agent/tui/state.py +653 -0
  64. main.py +465 -0
  65. tools/__init__.py +50 -0
  66. tools/apply_patch.py +305 -0
  67. tools/bash.py +76 -0
  68. tools/diff_utils.py +139 -0
  69. tools/edit_file.py +40 -0
  70. tools/git_diff.py +72 -0
  71. tools/git_show.py +65 -0
  72. tools/grep.py +149 -0
  73. tools/list_files.py +90 -0
  74. tools/list_skills.py +24 -0
  75. tools/load_skill.py +30 -0
  76. tools/lsp_definition.py +27 -0
  77. tools/lsp_diagnostics.py +32 -0
  78. tools/lsp_document_symbols.py +23 -0
  79. tools/lsp_hover.py +29 -0
  80. tools/lsp_references.py +37 -0
  81. tools/lsp_utils.py +38 -0
  82. tools/lsp_workspace_symbols.py +23 -0
  83. tools/read_file.py +61 -0
  84. tools/read_many_files.py +50 -0
  85. tools/safety.py +50 -0
  86. tools/subagent.py +57 -0
  87. tools/todo.py +89 -0
  88. tools/verify.py +107 -0
  89. tools/web_search.py +250 -0
  90. tools/workspace.py +36 -0
  91. tools/workspace_state.py +60 -0
  92. tools/write_file.py +88 -0
  93. utils/__init__.py +5 -0
  94. utils/retry.py +13 -0
  95. yycode-0.3.2.data/data/skills/code_review.md +61 -0
  96. yycode-0.3.2.data/data/skills/code_workflow.md +404 -0
  97. yycode-0.3.2.data/data/skills/drawio/SKILL.md +636 -0
  98. yycode-0.3.2.data/data/skills/drawio/agents/openai.yaml +19 -0
  99. yycode-0.3.2.data/data/skills/drawio/assets/demo-erd.drawio +84 -0
  100. yycode-0.3.2.data/data/skills/drawio/assets/demo-layered-cn.drawio +91 -0
  101. yycode-0.3.2.data/data/skills/drawio/assets/demo-layered-cn.png +0 -0
  102. yycode-0.3.2.data/data/skills/drawio/assets/demo-layered.drawio +112 -0
  103. yycode-0.3.2.data/data/skills/drawio/assets/demo-layered.png +0 -0
  104. yycode-0.3.2.data/data/skills/drawio/assets/demo-ml.drawio +90 -0
  105. yycode-0.3.2.data/data/skills/drawio/assets/demo-ring-cn.drawio +68 -0
  106. yycode-0.3.2.data/data/skills/drawio/assets/demo-ring-cn.png +0 -0
  107. yycode-0.3.2.data/data/skills/drawio/assets/demo-ring.drawio +86 -0
  108. yycode-0.3.2.data/data/skills/drawio/assets/demo-ring.png +0 -0
  109. yycode-0.3.2.data/data/skills/drawio/assets/demo-sequence.drawio +116 -0
  110. yycode-0.3.2.data/data/skills/drawio/assets/demo-star-cn.drawio +66 -0
  111. yycode-0.3.2.data/data/skills/drawio/assets/demo-star-cn.png +0 -0
  112. yycode-0.3.2.data/data/skills/drawio/assets/demo-star.drawio +79 -0
  113. yycode-0.3.2.data/data/skills/drawio/assets/demo-star.png +0 -0
  114. yycode-0.3.2.data/data/skills/drawio/assets/demo-uml-class.drawio +64 -0
  115. yycode-0.3.2.data/data/skills/drawio/assets/microservices-example.drawio +173 -0
  116. yycode-0.3.2.data/data/skills/drawio/assets/microservices-example.png +0 -0
  117. yycode-0.3.2.data/data/skills/drawio/assets/workflow-cn.drawio +120 -0
  118. yycode-0.3.2.data/data/skills/drawio/assets/workflow-cn.png +0 -0
  119. yycode-0.3.2.data/data/skills/drawio/assets/workflow.drawio +120 -0
  120. yycode-0.3.2.data/data/skills/drawio/assets/workflow.png +0 -0
  121. yycode-0.3.2.data/data/skills/drawio/docs/index.html +469 -0
  122. yycode-0.3.2.data/data/skills/drawio/docs/zh.html +456 -0
  123. yycode-0.3.2.data/data/skills/drawio/references/style-extraction.md +254 -0
  124. yycode-0.3.2.data/data/skills/drawio/styles/schema.json +112 -0
  125. yycode-0.3.2.data/data/skills/plan.md +115 -0
  126. yycode-0.3.2.data/data/skills/ppt/SKILL.md +254 -0
  127. yycode-0.3.2.dist-info/METADATA +12 -0
  128. yycode-0.3.2.dist-info/RECORD +131 -0
  129. yycode-0.3.2.dist-info/WHEEL +5 -0
  130. yycode-0.3.2.dist-info/entry_points.txt +2 -0
  131. yycode-0.3.2.dist-info/top_level.txt +4 -0
agent/tool_retry.py ADDED
@@ -0,0 +1,106 @@
1
+ """Retry utilities for agent tool execution."""
2
+
3
+ import asyncio
4
+ import inspect
5
+ import time
6
+ from typing import Callable, TypeVar
7
+
8
+ from agent.llm_retry import LLMCallError
9
+
10
+ T = TypeVar("T")
11
+
12
+
13
+ def run_with_retry(
14
+ func: Callable[..., T],
15
+ max_retries: int = 2,
16
+ retry_delay: float = 0.5,
17
+ backoff_factor: float = 2.0,
18
+ ) -> T:
19
+ """Run a function with automatic retry on failure."""
20
+ retry_count = 0
21
+
22
+ while True:
23
+ try:
24
+ return func()
25
+ except Exception:
26
+ retry_count += 1
27
+ if retry_count > max_retries:
28
+ raise
29
+ delay = retry_delay * (backoff_factor ** (retry_count - 1))
30
+ time.sleep(delay)
31
+
32
+
33
+ def run_tool_with_retry(
34
+ handler: Callable[..., str],
35
+ tool_name: str,
36
+ max_retries: int = 2,
37
+ **kwargs
38
+ ) -> str:
39
+ """Run a synchronous tool handler with retry and error handling."""
40
+ retry_count = 0
41
+
42
+ while retry_count <= max_retries:
43
+ try:
44
+ if not handler:
45
+ return f"Unknown tool: {tool_name}"
46
+ return handler(**kwargs)
47
+ except Exception as e:
48
+ retry_count += 1
49
+ if retry_count > max_retries:
50
+ return f"Error executing tool {tool_name}: {str(e)}"
51
+ time.sleep(0.5 * retry_count)
52
+
53
+
54
+ async def async_run_tool_with_retry(
55
+ handler: Callable[..., str],
56
+ tool_name: str,
57
+ max_retries: int = 5,
58
+ timeout_seconds: float | None = None,
59
+ **kwargs
60
+ ) -> str:
61
+ """Run a sync or async tool handler with retry and error handling."""
62
+ retry_count = 0
63
+
64
+ # Filter out unexpected keyword arguments that the handler doesn't accept
65
+ if handler:
66
+ sig = inspect.signature(handler)
67
+ accepts_var_kwargs = any(
68
+ param.kind == inspect.Parameter.VAR_KEYWORD
69
+ for param in sig.parameters.values()
70
+ )
71
+ if not accepts_var_kwargs:
72
+ param_names = list(sig.parameters.keys())
73
+ kwargs = {k: v for k, v in kwargs.items() if k in param_names}
74
+
75
+ while retry_count <= max_retries:
76
+ try:
77
+ if not handler:
78
+ return f"Unknown tool: {tool_name}"
79
+ return await _run_once(handler, timeout_seconds, **kwargs)
80
+ except asyncio.TimeoutError:
81
+ retry_count += 1
82
+ if retry_count > max_retries:
83
+ return f"Error executing tool {tool_name}: Timeout after {timeout_seconds}s"
84
+ await asyncio.sleep(0.5 * retry_count)
85
+ except LLMCallError:
86
+ raise
87
+ except Exception as e:
88
+ retry_count += 1
89
+ if retry_count > max_retries:
90
+ return f"Error executing tool {tool_name}: {str(e)}"
91
+ await asyncio.sleep(0.5 * retry_count)
92
+
93
+
94
+ async def _run_once(handler: Callable[..., str], timeout_seconds: float | None, **kwargs) -> str:
95
+ """Run a single tool attempt with an optional timeout."""
96
+ async def call_handler():
97
+ if inspect.iscoroutinefunction(handler):
98
+ return await handler(**kwargs)
99
+ result = await asyncio.to_thread(lambda: handler(**kwargs))
100
+ if inspect.isawaitable(result):
101
+ return await result
102
+ return result
103
+
104
+ if timeout_seconds is None:
105
+ return await call_handler()
106
+ return await asyncio.wait_for(call_handler(), timeout=timeout_seconds)
agent/tui/__init__.py ADDED
@@ -0,0 +1,14 @@
1
+ """Terminal UI support for yoyoagent."""
2
+
3
+ from .approval import TuiApprovalAdapter
4
+ from .runner import AgentTuiRunner
5
+ from .state import PendingApproval, SubagentStatus, TimelineItem, TuiState
6
+
7
+ __all__ = [
8
+ "AgentTuiRunner",
9
+ "PendingApproval",
10
+ "SubagentStatus",
11
+ "TimelineItem",
12
+ "TuiApprovalAdapter",
13
+ "TuiState",
14
+ ]