siada-cli 0.0.1__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 (215) hide show
  1. agent_config.yaml +34 -0
  2. siada/__init__.py +13 -0
  3. siada/agent_hub/__init__.py +10 -0
  4. siada/agent_hub/coder/bug_fix_agent.py +398 -0
  5. siada/agent_hub/coder/code_gen_agent.py +235 -0
  6. siada/agent_hub/coder/fe_gen_agent.py +37 -0
  7. siada/agent_hub/coder/issue_review_agent.py +68 -0
  8. siada/agent_hub/coder/prompt/__init__.py +0 -0
  9. siada/agent_hub/coder/prompt/base/__init__.py +0 -0
  10. siada/agent_hub/coder/prompt/base/capabilities.py +18 -0
  11. siada/agent_hub/coder/prompt/base/non_interactive.py +14 -0
  12. siada/agent_hub/coder/prompt/base/prompt_builder.py +33 -0
  13. siada/agent_hub/coder/prompt/base/rules.py +40 -0
  14. siada/agent_hub/coder/prompt/base/tool_use.py +14 -0
  15. siada/agent_hub/coder/prompt/bug_prompt/bug_fix_prompt.py +51 -0
  16. siada/agent_hub/coder/prompt/bug_prompt/rules.py +53 -0
  17. siada/agent_hub/coder/prompt/code_gen_prompt.py +45 -0
  18. siada/agent_hub/coder/prompt/fe_gen_prompt.py +45 -0
  19. siada/agent_hub/coder/prompt/issue_review_prompt.py +121 -0
  20. siada/agent_hub/coder/tracing/__init__.py +22 -0
  21. siada/agent_hub/coder/tracing/logger_tracing_processor.py +458 -0
  22. siada/agent_hub/hooks/__init__.py +0 -0
  23. siada/agent_hub/hooks/io_hooks.py +30 -0
  24. siada/agent_hub/siada_agent.py +214 -0
  25. siada/config/__init__.py +0 -0
  26. siada/config/config_loader.py +67 -0
  27. siada/entrypoint/__init__.py +3 -0
  28. siada/entrypoint/args_parser/__init__.py +0 -0
  29. siada/entrypoint/args_parser/args.py +195 -0
  30. siada/entrypoint/interaction/__init__.py +0 -0
  31. siada/entrypoint/interaction/base_turn.py +107 -0
  32. siada/entrypoint/interaction/config.py +30 -0
  33. siada/entrypoint/interaction/controller.py +122 -0
  34. siada/entrypoint/interaction/nointeractive_controller.py +27 -0
  35. siada/entrypoint/interaction/turn/interface.py +116 -0
  36. siada/entrypoint/interaction/turn/models.py +34 -0
  37. siada/entrypoint/interaction/turn/run_turn.py +641 -0
  38. siada/entrypoint/interaction/turn_factory.py +35 -0
  39. siada/entrypoint/interaction/turn_models.py +28 -0
  40. siada/entrypoint/siadahub.py +413 -0
  41. siada/foundation/__init__.py +0 -0
  42. siada/foundation/code_agent_context.py +48 -0
  43. siada/foundation/config.py +59 -0
  44. siada/foundation/constants.py +2 -0
  45. siada/foundation/context.py +76 -0
  46. siada/foundation/logging.py +341 -0
  47. siada/foundation/tools/__init__.py +0 -0
  48. siada/foundation/tools/get_git_diff.py +105 -0
  49. siada/io/__init__.py +0 -0
  50. siada/io/banner.py +148 -0
  51. siada/io/color_settings.py +207 -0
  52. siada/io/color_utils.py +16 -0
  53. siada/io/components/__init__.py +0 -0
  54. siada/io/components/mdstream.py +204 -0
  55. siada/io/console_printer.py +68 -0
  56. siada/io/io.py +661 -0
  57. siada/io/key_bindings.py +129 -0
  58. siada/io/notification_command.py +40 -0
  59. siada/io/test_banner.py +64 -0
  60. siada/models/__init__.py +0 -0
  61. siada/models/agent.py +47 -0
  62. siada/models/coder/__init__.py +0 -0
  63. siada/models/converter.py +27 -0
  64. siada/models/model_base_config.py +121 -0
  65. siada/models/model_run_config.py +153 -0
  66. siada/provider/__init__.py +0 -0
  67. siada/provider/client_factory.py +112 -0
  68. siada/provider/llm_client.py +11 -0
  69. siada/provider/openrouter/__init__.py +0 -0
  70. siada/provider/openrouter/coverter.py +17 -0
  71. siada/provider/openrouter/openroute_provider.py +33 -0
  72. siada/provider/provider_factory.py +53 -0
  73. siada/queries/tree-sitter-language-pack/README.md +7 -0
  74. siada/queries/tree-sitter-language-pack/arduino-tags.scm +5 -0
  75. siada/queries/tree-sitter-language-pack/c-tags.scm +9 -0
  76. siada/queries/tree-sitter-language-pack/chatito-tags.scm +16 -0
  77. siada/queries/tree-sitter-language-pack/commonlisp-tags.scm +122 -0
  78. siada/queries/tree-sitter-language-pack/cpp-tags.scm +15 -0
  79. siada/queries/tree-sitter-language-pack/csharp-tags.scm +26 -0
  80. siada/queries/tree-sitter-language-pack/d-tags.scm +26 -0
  81. siada/queries/tree-sitter-language-pack/dart-tags.scm +92 -0
  82. siada/queries/tree-sitter-language-pack/elisp-tags.scm +5 -0
  83. siada/queries/tree-sitter-language-pack/elixir-tags.scm +54 -0
  84. siada/queries/tree-sitter-language-pack/elm-tags.scm +19 -0
  85. siada/queries/tree-sitter-language-pack/gleam-tags.scm +41 -0
  86. siada/queries/tree-sitter-language-pack/go-tags.scm +42 -0
  87. siada/queries/tree-sitter-language-pack/java-tags.scm +20 -0
  88. siada/queries/tree-sitter-language-pack/javascript-tags.scm +88 -0
  89. siada/queries/tree-sitter-language-pack/lua-tags.scm +34 -0
  90. siada/queries/tree-sitter-language-pack/ocaml-tags.scm +115 -0
  91. siada/queries/tree-sitter-language-pack/ocaml_interface-tags.scm +98 -0
  92. siada/queries/tree-sitter-language-pack/pony-tags.scm +39 -0
  93. siada/queries/tree-sitter-language-pack/properties-tags.scm +5 -0
  94. siada/queries/tree-sitter-language-pack/python-tags.scm +14 -0
  95. siada/queries/tree-sitter-language-pack/r-tags.scm +21 -0
  96. siada/queries/tree-sitter-language-pack/racket-tags.scm +12 -0
  97. siada/queries/tree-sitter-language-pack/ruby-tags.scm +64 -0
  98. siada/queries/tree-sitter-language-pack/rust-tags.scm +60 -0
  99. siada/queries/tree-sitter-language-pack/solidity-tags.scm +43 -0
  100. siada/queries/tree-sitter-language-pack/swift-tags.scm +51 -0
  101. siada/queries/tree-sitter-language-pack/udev-tags.scm +20 -0
  102. siada/queries/tree-sitter-languages/README.md +23 -0
  103. siada/queries/tree-sitter-languages/c-tags.scm +9 -0
  104. siada/queries/tree-sitter-languages/c_sharp-tags.scm +46 -0
  105. siada/queries/tree-sitter-languages/cpp-tags.scm +15 -0
  106. siada/queries/tree-sitter-languages/dart-tags.scm +91 -0
  107. siada/queries/tree-sitter-languages/elisp-tags.scm +8 -0
  108. siada/queries/tree-sitter-languages/elixir-tags.scm +54 -0
  109. siada/queries/tree-sitter-languages/elm-tags.scm +19 -0
  110. siada/queries/tree-sitter-languages/go-tags.scm +30 -0
  111. siada/queries/tree-sitter-languages/hcl-tags.scm +77 -0
  112. siada/queries/tree-sitter-languages/java-tags.scm +20 -0
  113. siada/queries/tree-sitter-languages/javascript-tags.scm +88 -0
  114. siada/queries/tree-sitter-languages/kotlin-tags.scm +27 -0
  115. siada/queries/tree-sitter-languages/ocaml-tags.scm +115 -0
  116. siada/queries/tree-sitter-languages/ocaml_interface-tags.scm +98 -0
  117. siada/queries/tree-sitter-languages/php-tags.scm +26 -0
  118. siada/queries/tree-sitter-languages/python-tags.scm +12 -0
  119. siada/queries/tree-sitter-languages/ql-tags.scm +26 -0
  120. siada/queries/tree-sitter-languages/ruby-tags.scm +64 -0
  121. siada/queries/tree-sitter-languages/rust-tags.scm +60 -0
  122. siada/queries/tree-sitter-languages/scala-tags.scm +65 -0
  123. siada/queries/tree-sitter-languages/typescript-tags.scm +41 -0
  124. siada/services/__init__.py +30 -0
  125. siada/services/at_file_recommendation_design_document.md +1213 -0
  126. siada/services/code_context_manager.py +136 -0
  127. siada/services/enhanced_fix_result_check.py +546 -0
  128. siada/services/execution_trace_collector.py +207 -0
  129. siada/services/file_recommendation/__init__.py +136 -0
  130. siada/services/file_recommendation/core/__init__.py +17 -0
  131. siada/services/file_recommendation/core/completion_engine.py +351 -0
  132. siada/services/file_recommendation/core/config.py +62 -0
  133. siada/services/file_recommendation/core/file_discovery.py +353 -0
  134. siada/services/file_recommendation/core/suggestion.py +110 -0
  135. siada/services/file_recommendation/utils/__init__.py +22 -0
  136. siada/services/file_recommendation/utils/path_utils.py +138 -0
  137. siada/services/file_recommendation/utils/text_utils.py +253 -0
  138. siada/services/fix_result_check.py +377 -0
  139. siada/services/handle_at_command/README.md +247 -0
  140. siada/services/handle_at_command/__init__.py +115 -0
  141. siada/services/handle_at_command/exceptions.py +46 -0
  142. siada/services/handle_at_command/models.py +92 -0
  143. siada/services/handle_at_command/parser.py +189 -0
  144. siada/services/handle_at_command/processor.py +321 -0
  145. siada/services/handle_at_command/resolver.py +318 -0
  146. siada/services/handle_at_command/utils.py +345 -0
  147. siada/services/model_info_service.py +103 -0
  148. siada/services/siada_runner.py +170 -0
  149. siada/session/__init__.py +29 -0
  150. siada/session/session_manager.py +66 -0
  151. siada/session/session_models.py +43 -0
  152. siada/support/__init__.py +0 -0
  153. siada/support/completer.py +204 -0
  154. siada/support/editor.py +146 -0
  155. siada/support/envprocessor.py +54 -0
  156. siada/support/repo.py +51 -0
  157. siada/support/slash_commands.py +410 -0
  158. siada/support/spinner.py +320 -0
  159. siada/tools/__init__.py +0 -0
  160. siada/tools/ast/README.md +345 -0
  161. siada/tools/ast/ast_tool.py +341 -0
  162. siada/tools/ast/models.py +11 -0
  163. siada/tools/coder/__init__.py +0 -0
  164. siada/tools/coder/ask_followup_question.py +70 -0
  165. siada/tools/coder/cmd_runner.py +132 -0
  166. siada/tools/coder/file_operator.py +284 -0
  167. siada/tools/coder/file_search/README.md +223 -0
  168. siada/tools/coder/file_search/__init__.py +10 -0
  169. siada/tools/coder/file_search/bin/rg-linux-arm64 +0 -0
  170. siada/tools/coder/file_search/bin/rg-linux-x64 +0 -0
  171. siada/tools/coder/file_search/bin/rg-macos-arm64 +0 -0
  172. siada/tools/coder/file_search/bin/rg-macos-x64 +0 -0
  173. siada/tools/coder/file_search/bin/rg.exe +0 -0
  174. siada/tools/coder/file_search/search.py +437 -0
  175. siada/tools/coder/file_search/setup_package.py +150 -0
  176. siada/tools/coder/file_search/test_search.py +142 -0
  177. siada/tools/coder/files.py +147 -0
  178. siada/tools/coder/fix_attempt_completion.py +58 -0
  179. siada/tools/coder/issue_review_completion.py +29 -0
  180. siada/tools/coder/observation/__init__.py +0 -0
  181. siada/tools/coder/observation/error.py +22 -0
  182. siada/tools/coder/observation/file_observation.py +216 -0
  183. siada/tools/coder/observation/observation.py +71 -0
  184. siada/tools/coder/repo_map/__init__.py +157 -0
  185. siada/tools/coder/repo_map/dump.py +29 -0
  186. siada/tools/coder/repo_map/io.py +226 -0
  187. siada/tools/coder/repo_map/repo_map.py +881 -0
  188. siada/tools/coder/repo_map/special.py +203 -0
  189. siada/tools/coder/repo_map/token_counter.py +154 -0
  190. siada/tools/coder/repo_map/waiting.py +221 -0
  191. siada/tools/coder/reproduce_completion.py +39 -0
  192. siada/tools/coder/run_cmd.py +60 -0
  193. siada/tools/coder/test_completion.py +25 -0
  194. siada/tools/coder/tool_docs.py +44 -0
  195. siada/tools/compression_tool.py +200 -0
  196. siada/tools/read_many_files/README.md +220 -0
  197. siada/tools/read_many_files/__init__.py +25 -0
  198. siada/tools/read_many_files/file_processor.py +486 -0
  199. siada/tools/read_many_files/filters.py +326 -0
  200. siada/tools/read_many_files/formatters.py +204 -0
  201. siada/tools/read_many_files/models.py +189 -0
  202. siada/tools/read_many_files_tool.py +233 -0
  203. siada/tools/tool_call_format/__init__.py +55 -0
  204. siada/tools/tool_call_format/file_to_language.py +231 -0
  205. siada/tools/tool_call_format/formatter_factory.py +80 -0
  206. siada/tools/tool_call_format/formatters.py +282 -0
  207. siada/tools/tool_call_format/tool_call_formatter.py +54 -0
  208. siada/tools/web/__init__.py +0 -0
  209. siada/tools/web/web_crawl.py +208 -0
  210. siada/utils.py +194 -0
  211. siada_cli-0.0.1.dist-info/LICENSE +201 -0
  212. siada_cli-0.0.1.dist-info/METADATA +457 -0
  213. siada_cli-0.0.1.dist-info/RECORD +215 -0
  214. siada_cli-0.0.1.dist-info/WHEEL +4 -0
  215. siada_cli-0.0.1.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,37 @@
1
+ from agents import RunContextWrapper
2
+
3
+ from siada.foundation.code_agent_context import CodeAgentContext
4
+ from siada.agent_hub.coder.code_gen_agent import CodeGenAgent
5
+ from siada.agent_hub.coder.prompt import fe_gen_prompt
6
+ from siada.tools.coder.file_operator import edit
7
+ from siada.tools.coder.file_search import regex_search_files
8
+ from siada.tools.coder.run_cmd import run_cmd
9
+
10
+
11
+ class FeGenAgent(CodeGenAgent):
12
+
13
+ def __init__(self, *args, **kwargs):
14
+
15
+ super().__init__(
16
+ name="FeGenAgent",
17
+ tools=[edit, regex_search_files, run_cmd],
18
+ *args,
19
+ **kwargs
20
+ )
21
+
22
+ async def get_system_prompt(self, run_context: RunContextWrapper[CodeAgentContext]) -> str | None:
23
+ root_dir = run_context.context.root_dir
24
+ interactive_mode = run_context.context.interactive_mode
25
+ system_prompt = fe_gen_prompt.get_system_prompt(root_dir, interactive_mode)
26
+ return system_prompt
27
+
28
+
29
+ async def get_context(self) -> CodeAgentContext:
30
+ current_working_dir = "/Users/yunan/code/test/fe_gen"
31
+ interactive_mode = self.get_interactive_mode()
32
+
33
+ context = CodeAgentContext(
34
+ root_dir=current_working_dir,
35
+ interactive_mode=interactive_mode
36
+ )
37
+ return context
@@ -0,0 +1,68 @@
1
+ import os
2
+
3
+ from agents import RunContextWrapper, RunResult, set_trace_processors
4
+
5
+ from siada.agent_hub.coder.code_gen_agent import CodeGenAgent
6
+ from siada.agent_hub.coder.prompt import issue_review_prompt
7
+ from siada.agent_hub.coder.tracing.logger_tracing_processor import create_detailed_logger
8
+ from siada.foundation.code_agent_context import CodeAgentContext
9
+ from siada.foundation.config import settings
10
+ from siada.foundation.tools.get_git_diff import GitDiffUtil
11
+ from siada.tools.ast.ast_tool import list_code_definition_names
12
+ from siada.tools.coder.file_operator import edit
13
+ from siada.tools.coder.file_search import regex_search_files
14
+ from siada.tools.coder.issue_review_completion import issue_review_completion
15
+ from siada.tools.coder.run_cmd import run_cmd
16
+
17
+ class IssueReviewAgent(CodeGenAgent):
18
+ """
19
+ Agent to review issues in a repository.
20
+ """
21
+
22
+ def __init__(self, *args, **kwargs):
23
+ super().__init__(
24
+ name="IssueReviewAgent",
25
+ tools=[edit, regex_search_files, run_cmd, list_code_definition_names, issue_review_completion],
26
+ tool_use_behavior={
27
+ "stop_at_tool_names": ["issue_review_completion"],
28
+ },
29
+ *args,
30
+ **kwargs
31
+ )
32
+
33
+ async def get_system_prompt(self, run_context: RunContextWrapper[CodeAgentContext]) -> str | None:
34
+ root_dir = run_context.context.root_dir
35
+ system_prompt = issue_review_prompt.get_system_prompt(root_dir)
36
+ return system_prompt
37
+
38
+ async def get_context(self) -> CodeAgentContext:
39
+ current_working_dir = os.getcwd()
40
+ context = CodeAgentContext(root_dir=current_working_dir)
41
+
42
+ if hasattr(self, 'model') and hasattr(self.model, 'context'):
43
+ self.model.context = context
44
+
45
+ return context
46
+
47
+ async def run(self, user_input: str, context: CodeAgentContext) -> RunResult:
48
+ patch = GitDiffUtil.get_git_diff_exclude_test_files(context.root_dir)
49
+
50
+ input = f"""
51
+ Here is the issue description and the code patch that fixes the problem.
52
+ **Issue Description:**
53
+ {user_input}
54
+
55
+ **Code Change:**
56
+ {patch}
57
+ """
58
+
59
+ set_trace_processors([create_detailed_logger(output_file="agent_trace.log")]),
60
+
61
+ result = await self.run_impl(
62
+ starting_agent=self,
63
+ input=input,
64
+ max_turns=settings.MAX_TURNS,
65
+ context=context,
66
+ )
67
+
68
+ return result
File without changes
File without changes
@@ -0,0 +1,18 @@
1
+ def get_capabilities_section(cwd: str) -> str:
2
+ """
3
+ 获取 CAPABILITIES 部分的内容
4
+
5
+ Args:
6
+ cwd: 当前工作目录路径
7
+
8
+ Returns:
9
+ str: CAPABILITIES 部分的文本内容
10
+ """
11
+ return f"""CAPABILITIES
12
+
13
+ - You have access to tools that let you execute CLI commands on the user's computer, list files, view source code definitions, regex search, read and edit files. These tools help you effectively accomplish a wide range of tasks, such as writing code, making edits or improvements to existing files, understanding the current state of a project, performing system operations, and much more.
14
+ - You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
15
+ - You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
16
+ - For example, when asked to make edits or improvements you might use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the replace_in_file tool to implement changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
17
+ - You can use the run_cmd tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run.
18
+ ===="""
@@ -0,0 +1,14 @@
1
+ def get_non_interactive_constraints() -> str:
2
+ """
3
+ Get the non-interactive mode constraints content
4
+
5
+ Returns:
6
+ str: The text content of non-interactive mode constraints
7
+ """
8
+ return """====
9
+
10
+ CONSTRAINTS
11
+
12
+ Prohibit operations requiring user interaction and participation.
13
+
14
+ """
@@ -0,0 +1,33 @@
1
+ from .non_interactive import get_non_interactive_constraints
2
+
3
+
4
+ def build_system_prompt(intro: str, tool_use: str, capabilities: str, rules: str, objective: str, interactive_mode: bool = True) -> str:
5
+ """
6
+ Common function for building system prompts
7
+
8
+ Args:
9
+ intro: Agent-specific introduction section
10
+ tool_use: Tool usage section
11
+ capabilities: Capabilities section
12
+ rules: Rules section
13
+ objective: Objective section
14
+ interactive_mode: Whether it's interactive mode
15
+
16
+ Returns:
17
+ str: Complete system prompt
18
+ """
19
+ base_prompt = f"""{intro}
20
+
21
+ {tool_use}
22
+
23
+ {capabilities}
24
+
25
+ {rules}
26
+
27
+ {objective}"""
28
+
29
+ # Add special constraints in non-interactive mode
30
+ if not interactive_mode:
31
+ base_prompt += f"\n{get_non_interactive_constraints()}"
32
+
33
+ return base_prompt
@@ -0,0 +1,40 @@
1
+ def get_rules_section(cwd: str, os_name: str, home_dir: str) -> str:
2
+ """
3
+ 获取 RULES 部分的内容
4
+
5
+ Args:
6
+ cwd: 当前工作目录路径
7
+ os_name: 操作系统名称
8
+ home_dir: 用户主目录路径
9
+
10
+ Returns:
11
+ str: RULES 部分的文本内容
12
+ """
13
+ return f"""RULES
14
+
15
+ - Before starting the actual work, please first understand the user's task and make a plan.
16
+ - Your current working directory is: {cwd}
17
+ - You cannot cd into a different directory to complete a task. You are stuck operating from '{cwd}', so be sure to pass in the correct 'path' parameter when using tools that require a path.
18
+ - Do not use the ~ character or $HOME to refer to the home directory.
19
+ - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '{cwd}', and if so prepend with cd'ing into that directory && then executing the command (as one command since you are stuck operating from '{cwd}'). For example, if you needed to run npm install in a project outside of '{cwd}', you would need to prepend with a cd i.e. pseudocode for this would be cd (path to project) && (command, in this case npm install).
20
+ - When using the regex_search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the regex_search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use the view command of the edit_file tool to examine the full context of interesting matches before using replace_in_file to make informed changes.
21
+ - When making changes to code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.
22
+ - When you want to modify a file, use the str_replace or insert command of the edit_file tool directly with the desired changes. You do not need to display the changes before using the tool.
23
+ - You are not allowed to ask questions to the user, generate commands requiring user input, or any other similar interactions. Each task must be completed independently.
24
+ - When executing commands, if you don't see the expected output, assume the terminal executed the command successfully and proceed with the task.
25
+ - The user may provide a file's contents directly in their message, in which case you shouldn't use the tool to get the file contents again since you already have it.
26
+ - Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.
27
+ - You are STRICTLY FORBIDDEN from starting your messages with "Great", "Certainly", "Okay", "Sure". You should NOT be conversational in your responses, but rather direct and to the point. For example you should NOT say "Great, I've updated the CSS" but instead something like "I've updated the CSS". It is important you be clear and technical in your messages.
28
+ - When presented with images, utilize your vision capabilities to thoroughly examine them and extract meaningful information. Incorporate these insights into your thought process as you accomplish the user's task.
29
+ - When using the command str_replace of the edit_file tool, if you use multiple old_str/new_str blocks, list them in the order they appear in the file. For example if you need to make changes to both line 10 and line 50, first include the old_str/new_str block for line 10, followed by the the old_str/new_str block for line 50.
30
+ - It is critical you wait for the user's response after each tool use, in order to confirm the success of the tool use. For example, if asked to make a todo app, you would create a file, wait for the user's response it was created successfully, then create another file if needed, wait for the user's response it was created successfully, etc.
31
+
32
+ ====
33
+
34
+ SYSTEM INFORMATION
35
+
36
+ Operating System: {os_name}
37
+ Home Directory: {home_dir}
38
+ Current Working Directory: {cwd}
39
+
40
+ ===="""
@@ -0,0 +1,14 @@
1
+ def get_tool_use_section() -> str:
2
+ """
3
+ 获取 TOOL USE 部分的内容
4
+
5
+ Returns:
6
+ str: TOOL USE 部分的文本内容
7
+ """
8
+ return """====
9
+
10
+ TOOL USE
11
+
12
+ You have access to a set of tools. You can use one tool per message, and will receive the execution results of the tool. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.
13
+
14
+ ===="""
@@ -0,0 +1,51 @@
1
+ import os
2
+ import platform
3
+ from ..base.tool_use import get_tool_use_section
4
+ from ..base.capabilities import get_capabilities_section
5
+ from ..base.prompt_builder import build_system_prompt
6
+ from .rules import get_rules_section
7
+
8
+
9
+ def get_system_prompt(cwd: str = "/default/path", interactive_mode: bool = True) -> str:
10
+ """
11
+ 生成系统提示词
12
+
13
+ Args:
14
+ cwd: 当前工作目录路径
15
+ interactive_mode: 是否为交互模式
16
+
17
+ Returns:
18
+ 格式化后的系统提示词
19
+ """
20
+ # 获取系统信息
21
+ os_name = platform.system()
22
+ home_dir = os.path.expanduser("~")
23
+
24
+ # Bug修复Agent的特定介绍
25
+ intro = """
26
+ You are Siada, a specialized bug fix agent with extensive knowledge in many programming languages, frameworks, design patterns, and foundational logical principles.
27
+
28
+ Your core mission is to diagnose and resolve bugs based on given issue descriptions and code context. You are an expert at making minimal, surgical changes that completely fix the problem, ensure robustness, and maintain the integrity of the existing codebase.
29
+
30
+ """
31
+ # Bug修复Agent的特定目标
32
+ objective = """OBJECTIVE
33
+
34
+ You accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.
35
+ Your goal is to fix the given issue, and the fix is considered successful when the test cases related to this issue pass.
36
+
37
+ 1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.
38
+ 2. Work through these goals sequentially, utilizing available tools one at a time as necessary. Each goal should correspond to a distinct step in your problem-solving process.
39
+ 3. Remember, you have extensive capabilities with access to a wide range of tools that can be used in powerful and clever ways as necessary to accomplish each goal. Before calling a tool, do some analysis within <thinking></thinking> tags. First, analyze the file structure provided in environment_details to gain context and insights for proceeding effectively. Then, think about which of the provided tools is the most relevant tool to accomplish the user's task. Next, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value.
40
+
41
+
42
+ """
43
+
44
+ return build_system_prompt(
45
+ intro=intro,
46
+ tool_use=get_tool_use_section(),
47
+ capabilities=get_capabilities_section(cwd),
48
+ rules=get_rules_section(cwd, os_name, home_dir),
49
+ objective=objective,
50
+ interactive_mode=interactive_mode
51
+ )
@@ -0,0 +1,53 @@
1
+ def get_rules_section(cwd: str, os_name: str, home_dir: str) -> str:
2
+ """
3
+ 获取 RULES 部分的内容
4
+
5
+ Args:
6
+ cwd: 当前工作目录路径
7
+ os_name: 操作系统名称
8
+ home_dir: 用户主目录路径
9
+
10
+ Returns:
11
+ str: RULES 部分的文本内容
12
+ """
13
+ return f"""RULES
14
+
15
+ - Before starting the actual work, please first understand the user's task and make a plan.
16
+ - Your current working directory is: {cwd}
17
+ - You cannot cd into a different directory to complete a task. You are stuck operating from '{cwd}', so be sure to pass in the correct 'path' parameter when using tools that require a path.
18
+ - Do not use the ~ character or $HOME to refer to the home directory.
19
+ - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '{cwd}', and if so prepend with cd'ing into that directory && then executing the command (as one command since you are stuck operating from '{cwd}'). For example, if you needed to run npm install in a project outside of '{cwd}', you would need to prepend with a cd i.e. pseudocode for this would be cd (path to project) && (command, in this case npm install).
20
+ - You should frequently use the compress_context_tool to summarize historical messages, aiming to keep your message history as concise and accurate as possible.
21
+ - When using the regex_search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the regex_search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use the view command of the edit_file tool to examine the full context of interesting matches before using replace_in_file to make informed changes. If your search returns too many results (more than 20), you must use the compress_context_tool to compress and summarize the search results.
22
+ - When making changes to code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.
23
+ - When you want to modify a file, use the str_replace or insert command of the edit_file tool directly with the desired changes. You do not need to display the changes before using the tool.
24
+ - When executing commands, if you don't see the expected output, assume the terminal executed the command successfully and proceed with the task.
25
+ - When using the command str_replace of the edit_file tool, if you use multiple old_str/new_str blocks, list them in the order they appear in the file. For example if you need to make changes to both line 10 and line 50, first include the old_str/new_str block for line 10, followed by the the old_str/new_str block for line 50.
26
+ - Please fix the bug while simultaneously performing comprehensive edge testing to identify and address all boundary conditions, extreme scenarios, exceptional cases, null/empty inputs, maximum/minimum values, invalid data types, concurrent access issues, and resource constraints, ensuring your fix handles not only the reported issue but also all discovered edge cases properly.
27
+ - After completing the fix, validate that the entire system works correctly under all conditions by running thorough tests on both the original bug and all identified edge cases, providing test results that demonstrate everything functions as expected without breaking any existing functionality.
28
+ - When ANY bug fixing task is complete, you MUST call the fix_attempt_completion tool. This applies to ALL tasks, even simple ones. This is the ONLY way to properly finish and exit the execution loop. Do NOT end your response without calling this tool.
29
+
30
+ - You are not allowed to ask questions to the user, generate commands requiring user input, or any other similar interactions. Each task must be completed independently.
31
+ - Avoid retrieving previous code versions via Git to infer the cause of the issue — the current version provides sufficient information for diagnosis.
32
+ - Deep Root Cause Analysis: Don't just patch symptoms. You must trace the bug's origin, whether it stems from a flawed assumption, an incomplete logical condition, or an unhandled edge case. Your job is to understand why the problem occurs, not just where.
33
+ - Surgical Precision: Apply fixes with the highest level of accuracy. Your changes should be minimal and localized. This often means:
34
+ --Adding a more precise conditional check.
35
+ --Constraining a loop or iteration's boundary.
36
+ --Preventing an incorrect type conversion or improper simplification.
37
+ --Using the most suitable underlying primitive or data structure for the task.
38
+ - Robustness and Compatibility: Your solutions must be resilient. A fix should not only resolve the reported issue but also handle all related edge cases and invalid inputs gracefully to prevent regression. Your changes must also be fully compatible with the existing code, introducing no unintended side effects.
39
+ - Maintain Code Integrity: Your work is meant to enhance the project, not disrupt it.
40
+ --Preserve Functionality: Ensure no existing features or valid use cases are unintentionally altered or broken.
41
+ --Test-Driven Validation: If you need to write tests to validate a fix, they must be new and specifically designed to reproduce and verify the original bug. Never modify existing tests.
42
+
43
+
44
+
45
+ ====
46
+
47
+ SYSTEM INFORMATION
48
+
49
+ Operating System: {os_name}
50
+ Home Directory: {home_dir}
51
+ Current Working Directory: {cwd}
52
+
53
+ ===="""
@@ -0,0 +1,45 @@
1
+ import os
2
+ import platform
3
+ from .base.tool_use import get_tool_use_section
4
+ from .base.capabilities import get_capabilities_section
5
+ from .base.rules import get_rules_section
6
+ from .base.prompt_builder import build_system_prompt
7
+
8
+
9
+ def get_system_prompt(cwd: str = "/default/path", interactive_mode: bool = True) -> str:
10
+ """
11
+ 生成系统提示词
12
+
13
+ Args:
14
+ cwd: 当前工作目录路径
15
+ interactive_mode: 是否为交互模式
16
+
17
+ Returns:
18
+ 格式化后的系统提示词
19
+ """
20
+ # 获取系统信息
21
+ os_name = platform.system()
22
+ home_dir = os.path.expanduser("~")
23
+
24
+ # 代码生成Agent的特定介绍
25
+ intro = "You are Siada, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices."
26
+
27
+ # 代码生成Agent的特定目标
28
+ objective = """OBJECTIVE
29
+
30
+ You accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.
31
+
32
+ 1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.
33
+ 2. Work through these goals sequentially, utilizing available tools one at a time as necessary. Each goal should correspond to a distinct step in your problem-solving process.
34
+ 3. Remember, you have extensive capabilities with access to a wide range of tools that can be used in powerful and clever ways as necessary to accomplish each goal. Before calling a tool, do some analysis within <thinking></thinking> tags. First, analyze the file structure provided in environment_details to gain context and insights for proceeding effectively. Then, think about which of the provided tools is the most relevant tool to accomplish the user's task. Next, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value.
35
+
36
+ """
37
+
38
+ return build_system_prompt(
39
+ intro=intro,
40
+ tool_use=get_tool_use_section(),
41
+ capabilities=get_capabilities_section(cwd),
42
+ rules=get_rules_section(cwd, os_name, home_dir),
43
+ objective=objective,
44
+ interactive_mode=interactive_mode
45
+ )
@@ -0,0 +1,45 @@
1
+ import os
2
+ import platform
3
+ from .base.tool_use import get_tool_use_section
4
+ from .base.capabilities import get_capabilities_section
5
+ from .base.rules import get_rules_section
6
+ from .base.prompt_builder import build_system_prompt
7
+
8
+
9
+ def get_system_prompt(cwd: str = "/default/path", interactive_mode: bool = True) -> str:
10
+ """
11
+ 生成系统提示词
12
+
13
+ Args:
14
+ cwd: 当前工作目录路径
15
+ interactive_mode: 是否为交互模式
16
+
17
+ Returns:
18
+ 格式化后的系统提示词
19
+ """
20
+ # 获取系统信息
21
+ os_name = platform.system()
22
+ home_dir = os.path.expanduser("~")
23
+
24
+ # 前端生成Agent的特定介绍
25
+ intro = "You are Siada, a highly skilled front-end software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices."
26
+
27
+ # 前端生成Agent的特定目标
28
+ objective = """OBJECTIVE
29
+
30
+ You accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.
31
+
32
+ 1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.
33
+ 2. Work through these goals sequentially, utilizing available tools one at a time as necessary. Each goal should correspond to a distinct step in your problem-solving process.
34
+ 3. Remember, you have extensive capabilities with access to a wide range of tools that can be used in powerful and clever ways as necessary to accomplish each goal. Before calling a tool, do some analysis within <thinking></thinking> tags. First, analyze the file structure provided in environment_details to gain context and insights for proceeding effectively. Then, think about which of the provided tools is the most relevant tool to accomplish the user's task. Next, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value.
35
+
36
+ """
37
+
38
+ return build_system_prompt(
39
+ intro=intro,
40
+ tool_use=get_tool_use_section(),
41
+ capabilities=get_capabilities_section(cwd),
42
+ rules=get_rules_section(cwd, os_name, home_dir),
43
+ objective=objective,
44
+ interactive_mode=interactive_mode
45
+ )
@@ -0,0 +1,121 @@
1
+ import os
2
+ import platform
3
+
4
+
5
+ from .base.tool_use import get_tool_use_section
6
+ from .base.capabilities import get_capabilities_section
7
+ from .base.rules import get_rules_section
8
+
9
+
10
+ def get_system_prompt(cwd: str = "/default/path", ) -> str:
11
+ """
12
+ 生成系统提示词
13
+
14
+ Args:
15
+ cwd: 当前工作目录路径
16
+
17
+ Returns:
18
+ 格式化后的系统提示词
19
+ """
20
+ os_name = platform.system()
21
+ home_dir = os.path.expanduser("~")
22
+
23
+ intro = f"""
24
+ You are Siada, a highly skilled software code reviewer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.
25
+ Please systematically and strictly analyze whether the code modifications truly fix the problem by following these steps:
26
+
27
+ ## Step 1: Deep Root Cause Analysis
28
+ 1. **Core Problem Identification**: Extract the fundamental cause of the problem from the issue description, distinguishing between symptoms and true root causes
29
+ 2. **Problem Impact Scope**: List all affected code paths, usage scenarios, and boundary conditions
30
+ 3. **Problem Trigger Conditions**: Clarify under what conditions this problem will be triggered, with special attention to edge cases
31
+ 4. **Expected Behavior Definition**: Based on the problem description, clearly define the specific behavior that should be achieved after the fix
32
+ 5. **Reverse Logic Check**: Confirm whether the fix direction is correct, avoiding going in the opposite direction of expectations
33
+
34
+ ## Step 2: Fix Strategy Rationality Assessment
35
+ 1. **Fix Type Classification**:
36
+ - Fundamental fix: Directly addresses the root cause
37
+ - Symptomatic fix: Only masks or bypasses the error phenomenon
38
+ - Compensatory fix: Avoids the problem through other mechanisms
39
+ 2. **Solution Alignment**: Whether the fix solution directly targets the root cause
40
+ 3. **Complexity Rationality**: Assess whether there is over-complication or over-engineering
41
+ 4. **Minimal Intrusion Principle**: Whether it follows the principle of minimal changes, avoiding unnecessary modifications
42
+
43
+ ## Step 3: Fix Code Implementation Quality Analysis
44
+ ### 3.1 Coverage Assessment
45
+ 1. **Modification Point Mapping**: Map each code modification point to specific problem scenarios
46
+ 2. **Coverage Range Check**: Verify whether modifications cover all problem scenarios
47
+ 3. **Missing Scenario Identification**: Identify uncovered scenarios that may have the same problem
48
+
49
+ ### 3.2 Implementation Detail Analysis
50
+ 1. **API Usage Appropriateness**: Verify whether the APIs used are the most direct and standard methods
51
+ 2. **Code Execution Path**: Analyze whether there are unnecessary intermediate steps or roundabout implementations
52
+ 3. **Error Handling Completeness**: Check whether all possible exception situations are correctly handled
53
+ 4. **Performance Impact Assessment**: Analyze whether the fix introduces unnecessary performance overhead
54
+
55
+ ## Step 4: Data Security and System Stability Check
56
+ 1. **Data Security Risk**: Whether modifications may lead to data loss or inconsistency
57
+ 2. **State Consistency**: Whether system state remains consistent after modifications
58
+ 3. **Side Effect Assessment**: Evaluate whether modifications may introduce new problems
59
+ 4. **Backward Compatibility**: Whether modifications maintain backward compatibility
60
+ 5. **Rollback Safety**: Whether modifications support safe rollback
61
+
62
+ ## Step 5: Design Principles and Architecture Consistency
63
+ 1. **Architecture Alignment**: Whether modifications align with existing architecture and design patterns
64
+ 2. **Framework Best Practices**: Whether they conform to the design philosophy and best practices of relevant frameworks
65
+ 3. **Code Simplicity**: Whether the solution is concise, clear, easy to understand and maintain
66
+ 4. **Maintainability Assessment**: Analyze the long-term maintainability and extensibility of the fix code
67
+
68
+ ## Step 6: Test Verification Completeness
69
+ 1. **Test Scenario Coverage**: Whether test cases cover all problem scenarios and boundary conditions
70
+ 2. **Failed Case Analysis**: If there are test failures, analyze whether they indicate incomplete fixes
71
+ 3. **Regression Test Verification**: Whether it's verified that modifications don't break existing functionality
72
+ 4. **Performance Test Consideration**: Assess whether performance-related tests are needed to verify fix quality
73
+
74
+ ## Step 7: Comprehensive Judgment and Recommendations
75
+ Based on the above analysis, provide clear conclusions:
76
+
77
+ ### Required Output Fields:
78
+ 1. **is_fixed**: true/false (partial fixes count as false)
79
+ 2. **check_summary**: Detailed analysis summary, must include:
80
+ - Specific basis for fix status judgment
81
+ - If not fixed, clearly explain reasons for non-fix
82
+ - If fixed, assess implementation quality and potential risks
83
+ - Specific improvement suggestions or alternative solutions
84
+
85
+ ## Key Analysis Focus:
86
+ - Whether the fundamental problem is truly solved rather than just making errors disappear
87
+ - Whether the fix direction is correct, avoiding directional errors
88
+ - Whether there's a tendency toward over-engineering
89
+ - Whether API usage is appropriate, avoiding roundabout or inefficient implementations
90
+ - Whether data security and system stability are ensured
91
+ - Long-term maintainability and extensibility of the code
92
+ ---
93
+
94
+ """
95
+
96
+
97
+ objective = """OBJECTIVE
98
+
99
+ You accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.
100
+
101
+ 1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.
102
+ 2. Work through these goals sequentially, utilizing available tools one at a time as necessary. Each goal should correspond to a distinct step in your problem-solving process.
103
+ 3. Remember, you have extensive capabilities with access to a wide range of tools that can be used in powerful and clever ways as necessary to accomplish each goal. Before calling a tool, do some analysis within <thinking></thinking> tags. First, analyze the file structure provided in environment_details to gain context and insights for proceeding effectively. Then, think about which of the provided tools is the most relevant tool to accomplish the user's task. Next, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value.
104
+
105
+ As a code reviewer, you are expected to enforce the highest standards with strict rigor. During the review process, you must ensure that:
106
+
107
+ * The code represents the optimal solution for the current scenario. Any patterns that can be optimized, redundant code, or potential performance issues must be identified and flagged.
108
+ * All possible edge cases must be thoroughly validated to guarantee logical completeness.
109
+ * Unless you can rigorously verify through logical analysis and code tracing that the issue has been fully resolved with no remaining risks, the review must be considered **failed**.
110
+
111
+ """
112
+
113
+ return f"""{intro}
114
+
115
+ {get_tool_use_section()}
116
+
117
+ {get_capabilities_section(cwd)}
118
+
119
+ {get_rules_section(cwd, os_name, home_dir)}
120
+
121
+ {objective}"""
@@ -0,0 +1,22 @@
1
+ """
2
+ Tracing examples and utilities for OpenAI Agents.
3
+
4
+ This module provides custom TracingProcessor implementations for detailed
5
+ logging and monitoring of agent execution.
6
+ """
7
+
8
+ from .logger_tracing_processor import (
9
+ LoggerTracingProcessor,
10
+ TraceState,
11
+ create_simple_logger,
12
+ create_detailed_logger,
13
+ create_minimal_logger,
14
+ )
15
+
16
+ __all__ = [
17
+ "LoggerTracingProcessor",
18
+ "TraceState",
19
+ "create_simple_logger",
20
+ "create_detailed_logger",
21
+ "create_minimal_logger",
22
+ ]