PyBreeze 1.0.4__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 (109) hide show
  1. automation_ide/__init__.py +7 -0
  2. automation_ide/__main__.py +0 -0
  3. automation_ide/automation_editor_ui/__init__.py +0 -0
  4. automation_ide/automation_editor_ui/connect_gui/__init__.py +0 -0
  5. automation_ide/automation_editor_ui/connect_gui/ssh/__init__.py +0 -0
  6. automation_ide/automation_editor_ui/connect_gui/ssh/ssh_command_widget.py +246 -0
  7. automation_ide/automation_editor_ui/connect_gui/ssh/ssh_file_viewer_widget.py +501 -0
  8. automation_ide/automation_editor_ui/connect_gui/ssh/ssh_login_widget.py +67 -0
  9. automation_ide/automation_editor_ui/connect_gui/ssh/ssh_main_widget.py +49 -0
  10. automation_ide/automation_editor_ui/connect_gui/url/__init__.py +0 -0
  11. automation_ide/automation_editor_ui/connect_gui/url/ai_code_review_gui.py +177 -0
  12. automation_ide/automation_editor_ui/editor_main/__init__.py +0 -0
  13. automation_ide/automation_editor_ui/editor_main/main_ui.py +104 -0
  14. automation_ide/automation_editor_ui/extend_ai_gui/__init__.py +0 -0
  15. automation_ide/automation_editor_ui/extend_ai_gui/ai_gui_global_variable.py +40 -0
  16. automation_ide/automation_editor_ui/extend_ai_gui/code_review/__init__.py +0 -0
  17. automation_ide/automation_editor_ui/extend_ai_gui/code_review/code_review_thread.py +81 -0
  18. automation_ide/automation_editor_ui/extend_ai_gui/code_review/cot_code_review_gui.py +82 -0
  19. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/__init__.py +0 -0
  20. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/cot_code_review_prompt_templates/__init__.py +0 -0
  21. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/cot_code_review_prompt_templates/code_smell_detector.py +22 -0
  22. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/cot_code_review_prompt_templates/first_code_review.py +17 -0
  23. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/cot_code_review_prompt_templates/first_summary_prompt.py +17 -0
  24. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/cot_code_review_prompt_templates/global_rule.py +59 -0
  25. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/cot_code_review_prompt_templates/judge.py +91 -0
  26. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/cot_code_review_prompt_templates/judge_single_review.py +85 -0
  27. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/cot_code_review_prompt_templates/linter.py +17 -0
  28. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/cot_code_review_prompt_templates/step_by_step_analysis.py +35 -0
  29. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/cot_code_review_prompt_templates/total_summary.py +66 -0
  30. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/cot_prompt_editor_widget.py +136 -0
  31. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/skills_prompt_editor_widget.py +136 -0
  32. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/skills_prompt_templates/__init__.py +0 -0
  33. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/skills_prompt_templates/code_explainer.py +21 -0
  34. automation_ide/automation_editor_ui/extend_ai_gui/prompt_edit_gui/skills_prompt_templates/code_review.py +37 -0
  35. automation_ide/automation_editor_ui/extend_ai_gui/skills/__init__.py +0 -0
  36. automation_ide/automation_editor_ui/extend_ai_gui/skills/skills_send_gui.py +98 -0
  37. automation_ide/automation_editor_ui/extend_multi_language/__init__.py +0 -0
  38. automation_ide/automation_editor_ui/extend_multi_language/extend_english.py +272 -0
  39. automation_ide/automation_editor_ui/extend_multi_language/extend_traditional_chinese.py +272 -0
  40. automation_ide/automation_editor_ui/extend_multi_language/update_language_dict.py +8 -0
  41. automation_ide/automation_editor_ui/menu/__init__.py +0 -0
  42. automation_ide/automation_editor_ui/menu/automation_menu/__init__.py +0 -0
  43. automation_ide/automation_editor_ui/menu/automation_menu/api_testka_menu/__init__.py +0 -0
  44. automation_ide/automation_editor_ui/menu/automation_menu/api_testka_menu/build_api_testka_menu.py +137 -0
  45. automation_ide/automation_editor_ui/menu/automation_menu/auto_control_menu/__init__.py +0 -0
  46. automation_ide/automation_editor_ui/menu/automation_menu/auto_control_menu/build_autocontrol_menu.py +169 -0
  47. automation_ide/automation_editor_ui/menu/automation_menu/automation_file_menu/__init__.py +0 -0
  48. automation_ide/automation_editor_ui/menu/automation_menu/automation_file_menu/build_automation_file_menu.py +122 -0
  49. automation_ide/automation_editor_ui/menu/automation_menu/load_density_menu/__init__.py +0 -0
  50. automation_ide/automation_editor_ui/menu/automation_menu/load_density_menu/build_load_density_menu.py +137 -0
  51. automation_ide/automation_editor_ui/menu/automation_menu/mail_thunder_menu/__init__.py +0 -0
  52. automation_ide/automation_editor_ui/menu/automation_menu/mail_thunder_menu/build_mail_thunder_menu.py +88 -0
  53. automation_ide/automation_editor_ui/menu/automation_menu/test_pioneer_menu/__init__.py +0 -0
  54. automation_ide/automation_editor_ui/menu/automation_menu/test_pioneer_menu/build_test_pioneer_menu.py +62 -0
  55. automation_ide/automation_editor_ui/menu/automation_menu/web_runner_menu/__init__.py +0 -0
  56. automation_ide/automation_editor_ui/menu/automation_menu/web_runner_menu/build_webrunner_menu.py +119 -0
  57. automation_ide/automation_editor_ui/menu/build_menubar.py +47 -0
  58. automation_ide/automation_editor_ui/menu/install_menu/__init__.py +0 -0
  59. automation_ide/automation_editor_ui/menu/install_menu/automation_menu/__init__.py +0 -0
  60. automation_ide/automation_editor_ui/menu/install_menu/automation_menu/build_automation_install_menu.py +82 -0
  61. automation_ide/automation_editor_ui/menu/install_menu/install_utils.py +21 -0
  62. automation_ide/automation_editor_ui/menu/install_menu/tools_menu/__init__.py +0 -0
  63. automation_ide/automation_editor_ui/menu/install_menu/tools_menu/build_tool_install_menu.py +29 -0
  64. automation_ide/automation_editor_ui/menu/menu_utils.py +16 -0
  65. automation_ide/automation_editor_ui/menu/tools/__init__.py +0 -0
  66. automation_ide/automation_editor_ui/menu/tools/tools_menu.py +162 -0
  67. automation_ide/automation_editor_ui/show_code_window/__init__.py +0 -0
  68. automation_ide/automation_editor_ui/show_code_window/code_window.py +21 -0
  69. automation_ide/automation_editor_ui/syntax/__init__.py +0 -0
  70. automation_ide/automation_editor_ui/syntax/syntax_extend.py +40 -0
  71. automation_ide/automation_editor_ui/syntax/syntax_keyword.py +163 -0
  72. automation_ide/extend/__init__.py +0 -0
  73. automation_ide/extend/mail_thunder_extend/__init__.py +0 -0
  74. automation_ide/extend/mail_thunder_extend/mail_thunder_setting.py +36 -0
  75. automation_ide/extend/process_executor/__init__.py +0 -0
  76. automation_ide/extend/process_executor/api_testka/__init__.py +0 -0
  77. automation_ide/extend/process_executor/api_testka/api_testka_process.py +66 -0
  78. automation_ide/extend/process_executor/auto_control/__init__.py +0 -0
  79. automation_ide/extend/process_executor/auto_control/auto_control_process.py +62 -0
  80. automation_ide/extend/process_executor/file_automation/__init__.py +0 -0
  81. automation_ide/extend/process_executor/file_automation/file_automation_process.py +66 -0
  82. automation_ide/extend/process_executor/load_density/__init__.py +0 -0
  83. automation_ide/extend/process_executor/load_density/load_density_process.py +66 -0
  84. automation_ide/extend/process_executor/mail_thunder/__init__.py +0 -0
  85. automation_ide/extend/process_executor/mail_thunder/mail_thunder_process.py +16 -0
  86. automation_ide/extend/process_executor/process_executor_utils.py +72 -0
  87. automation_ide/extend/process_executor/python_task_process_manager.py +177 -0
  88. automation_ide/extend/process_executor/test_pioneer/__init__.py +0 -0
  89. automation_ide/extend/process_executor/test_pioneer/test_pioneer_process_manager.py +181 -0
  90. automation_ide/extend/process_executor/web_runner/__init__.py +0 -0
  91. automation_ide/extend/process_executor/web_runner/web_runner_process.py +66 -0
  92. automation_ide/utils/__init__.py +0 -0
  93. automation_ide/utils/exception/__init__.py +0 -0
  94. automation_ide/utils/exception/exception_tags.py +37 -0
  95. automation_ide/utils/exception/exceptions.py +50 -0
  96. automation_ide/utils/file_process/__init__.py +0 -0
  97. automation_ide/utils/file_process/get_dir_file_list.py +29 -0
  98. automation_ide/utils/json_format/__init__.py +1 -0
  99. automation_ide/utils/json_format/json_process.py +28 -0
  100. automation_ide/utils/logging/__init__.py +0 -0
  101. automation_ide/utils/logging/logger.py +50 -0
  102. automation_ide/utils/manager/__init__.py +0 -0
  103. automation_ide/utils/manager/package_manager/__init__.py +0 -0
  104. automation_ide/utils/manager/package_manager/package_manager_class.py +18 -0
  105. pybreeze-1.0.4.dist-info/METADATA +69 -0
  106. pybreeze-1.0.4.dist-info/RECORD +109 -0
  107. pybreeze-1.0.4.dist-info/WHEEL +5 -0
  108. pybreeze-1.0.4.dist-info/licenses/LICENSE +21 -0
  109. pybreeze-1.0.4.dist-info/top_level.txt +1 -0
@@ -0,0 +1,91 @@
1
+ JUDGE_TEMPLATE = """
2
+ # Code Review Comment Evaluation Template (Enhanced)
3
+
4
+ Please evaluate the review comments focusing on how well they address important issues in the code, especially leveraging code smell and linter messages.
5
+ The input may contain multiple independent review reports.
6
+
7
+ Score range: 1–100
8
+
9
+ Five evaluation dimensions:
10
+ ### 1. Readability
11
+ - 1–20: Comments are very hard to understand, poorly structured, confusing language.
12
+ - 21–40: Some parts are readable, but many unclear sections remain.
13
+ - 41–60: Comments are generally clear, but structure or phrasing needs improvement.
14
+ - 61–80: Comments are well-structured, consistent, and easy to follow.
15
+ - 81–100: Comments are highly readable, elegantly phrased, and well-organized.
16
+
17
+ ### 2. Constructiveness (Maintainability)
18
+ - 1–20: Comments lack constructive suggestions, no improvement direction.
19
+ - 21–40: Comments provide partial suggestions, but vague or impractical.
20
+ - 41–60: Comments offer basic improvement ideas, somewhat helpful.
21
+ - 61–80: Comments are specific and actionable, clearly guiding improvements.
22
+ - 81–100: Comments are highly constructive, offering clear and practical improvement paths.
23
+
24
+ ### 3. Correctness
25
+ - 1–20: Comments contain errors or misleading advice.
26
+ - 21–40: Mostly correct, but important issues are overlooked.
27
+ - 41–60: Largely correct, with only minor gaps.
28
+ - 61–80: Correct and reasonable, with small room for refinement.
29
+ - 81–100: Fully correct, logically sound, and precise in identifying issues.
30
+
31
+ ### 4. Multi-Review Coverage, Structural Independence & Extractability
32
+
33
+ > Evaluate how well the comments cover important issues across multiple review reports, and whether each comment block is structurally independent, self-contained, and understandable on its own.
34
+
35
+ #### Scoring Criteria
36
+
37
+ - **1–20**
38
+ Rarely addresses important issues; structure is disorganized; comments heavily depend on surrounding context; blocks cannot be read independently; unclear linkage to specific code smells or linter messages.
39
+
40
+ - **21–40**
41
+ Addresses some issues but misses many key points; unclear boundaries between sections; frequent cross-references required for understanding; difficult to isolate specific issue blocks.
42
+
43
+ - **41–60**
44
+ Covers many important issues; basic structure is present; some blocks can be read independently, but certain sections still rely on context or lack completeness.
45
+
46
+ - **61–80**
47
+ Most key issues are addressed; comment blocks are clearly structured with defined themes; most sections can be independently read and understood (problem + reasoning + suggestion); code smell / linter-related blocks are reasonably extractable.
48
+
49
+ - **81–100**
50
+ Thoroughly addresses key issues; each comment block is **independent, complete, and self-contained** (including problem description, impact explanation, and actionable improvement suggestions);
51
+ clearly segmented structure; any block can be extracted without losing meaning;
52
+ strongly aligned with specific code smells or linter messages; highly readable and maintainable.
53
+ ---
54
+ ### Additional Evaluation Criteria
55
+
56
+ When scoring this dimension, explicitly check whether each comment block:
57
+ - Has a clear title or thematic focus
58
+ - Clearly identifies the issue source (e.g., specific code smell or linter message)
59
+ - Explains impact or risk
60
+ - Provides concrete and actionable improvement suggestions
61
+ - Does not rely on other sections for comprehension
62
+
63
+ Also assess whether:
64
+ - A single comment block can be extracted and shared independently without losing clarity
65
+ - Code smell or linter-related sections can be isolated for structured analysis
66
+ - Summary sections and detailed comments are clearly distinguished
67
+
68
+ ### 5. Comprehensiveness
69
+ - 1–20: Comments fail to address any code smells or linter findings.
70
+ - 21–40: Comments mention at least one code smell or linter warning.
71
+ - 41–60: Comments cover some code smells or linter findings.
72
+ - 61–80: Comments cover most code smells and linter findings.
73
+ - 81–100: Comments comprehensively address all code smells and linter findings, with improvement suggestions.
74
+
75
+ Reviewers should:
76
+ - Assign a score (1–100) for each dimension.
77
+ - Provide brief reasoning for each score.
78
+ - Conclude with an average score and overall recommendation.
79
+
80
+ ## Review Comment:
81
+ {review_comment}
82
+
83
+ ## Code Smells:
84
+ {code_smell_detector_messages}
85
+
86
+ ## Linter Messages:
87
+ {linter_messages}
88
+
89
+ ## Origin code
90
+ {code_diff}
91
+ """
@@ -0,0 +1,85 @@
1
+ JUDGE_SINGLE_REVIEW_TEMPLATE = """
2
+ # Code Review Comment Evaluation Template (Enhanced)
3
+
4
+ Please evaluate the review comments focusing on how well they address important issues in the code, especially leveraging code smell and linter messages.
5
+ The input may contain multiple independent review reports.
6
+
7
+ Score range: 1–100
8
+
9
+ Five evaluation dimensions:
10
+ ### 1. Readability
11
+ - 1–20: Comments are very hard to understand, poorly structured, confusing language.
12
+ - 21–40: Some parts are readable, but many unclear sections remain.
13
+ - 41–60: Comments are generally clear, but structure or phrasing needs improvement.
14
+ - 61–80: Comments are well-structured, consistent, and easy to follow.
15
+ - 81–100: Comments are highly readable, elegantly phrased, and well-organized.
16
+
17
+ ### 2. Constructiveness (Maintainability)
18
+ - 1–20: Comments lack constructive suggestions, no improvement direction.
19
+ - 21–40: Comments provide partial suggestions, but vague or impractical.
20
+ - 41–60: Comments offer basic improvement ideas, somewhat helpful.
21
+ - 61–80: Comments are specific and actionable, clearly guiding improvements.
22
+ - 81–100: Comments are highly constructive, offering clear and practical improvement paths.
23
+
24
+ ### 3. Correctness
25
+ - 1–20: Comments contain errors or misleading advice.
26
+ - 21–40: Mostly correct, but important issues are overlooked.
27
+ - 41–60: Largely correct, with only minor gaps.
28
+ - 61–80: Correct and reasonable, with small room for refinement.
29
+ - 81–100: Fully correct, logically sound, and precise in identifying issues.
30
+
31
+ ### 4. Multi-Review Coverage, Structural Independence & Extractability
32
+
33
+ > Evaluate how well the comments cover important issues across multiple review reports, and whether each comment block is structurally independent, self-contained, and understandable on its own.
34
+
35
+ #### Scoring Criteria
36
+
37
+ - **1–20**
38
+ Rarely addresses important issues; structure is disorganized; comments heavily depend on surrounding context; blocks cannot be read independently; unclear linkage to specific code smells or linter messages.
39
+
40
+ - **21–40**
41
+ Addresses some issues but misses many key points; unclear boundaries between sections; frequent cross-references required for understanding; difficult to isolate specific issue blocks.
42
+
43
+ - **41–60**
44
+ Covers many important issues; basic structure is present; some blocks can be read independently, but certain sections still rely on context or lack completeness.
45
+
46
+ - **61–80**
47
+ Most key issues are addressed; comment blocks are clearly structured with defined themes; most sections can be independently read and understood (problem + reasoning + suggestion); code smell / linter-related blocks are reasonably extractable.
48
+
49
+ - **81–100**
50
+ Thoroughly addresses key issues; each comment block is **independent, complete, and self-contained** (including problem description, impact explanation, and actionable improvement suggestions);
51
+ clearly segmented structure; any block can be extracted without losing meaning;
52
+ strongly aligned with specific code smells or linter messages; highly readable and maintainable.
53
+ ---
54
+ ### Additional Evaluation Criteria
55
+
56
+ When scoring this dimension, explicitly check whether each comment block:
57
+ - Has a clear title or thematic focus
58
+ - Clearly identifies the issue source (e.g., specific code smell or linter message)
59
+ - Explains impact or risk
60
+ - Provides concrete and actionable improvement suggestions
61
+ - Does not rely on other sections for comprehension
62
+
63
+ Also assess whether:
64
+ - A single comment block can be extracted and shared independently without losing clarity
65
+ - Code smell or linter-related sections can be isolated for structured analysis
66
+ - Summary sections and detailed comments are clearly distinguished
67
+
68
+ ### 5. Comprehensiveness
69
+ - 1–20: Comments fail to address any code smells or linter findings.
70
+ - 21–40: Comments mention at least one code smell or linter warning.
71
+ - 41–60: Comments cover some code smells or linter findings.
72
+ - 61–80: Comments cover most code smells and linter findings.
73
+ - 81–100: Comments comprehensively address all code smells and linter findings, with improvement suggestions.
74
+
75
+ Reviewers should:
76
+ - Assign a score (1–100) for each dimension.
77
+ - Provide brief reasoning for each score.
78
+ - Conclude with an average score and overall recommendation.
79
+
80
+ ## Review Comment:
81
+ {review_comment}
82
+
83
+ ## Origin code
84
+ {code_diff}
85
+ """
@@ -0,0 +1,17 @@
1
+ LINTER_TEMPLATE = """
2
+ You are a strict code linter.
3
+ Your task is to analyze the given source code and produce structured linter_messages.
4
+ Follow these rules:
5
+
6
+ 1. Do not rewrite or fix the code — only report issues.
7
+ 2. Each linter_message must include:
8
+ - rule_id: A short identifier for the rule violated (e.g., "no-unused-vars").
9
+ - severity: One of ["error", "warning", "info"].
10
+ - message: A clear explanation of the issue.
11
+ - line: The line number where the issue occurs.
12
+ - suggestion: A concise recommendation for improvement.
13
+ 3. If no issues are found, return an empty list.
14
+
15
+ Now analyze the following code:
16
+ {code_diff}
17
+ """
@@ -0,0 +1,35 @@
1
+ STEP_BY_STEP_ANALYSIS_TEMPLATE = """
2
+ You are a code quality reviewer.
3
+ Analyze the code smell, and linter message step by step.
4
+
5
+ Instructions:
6
+ 1. **Identify the Issue**
7
+ - Restate the code smell or lint message in plain English.
8
+ - Explain what it means in the context of software engineering.
9
+
10
+ 2. **Root Cause Analysis**
11
+ - Describe why this issue occurs.
12
+ - Point out the underlying coding practice or design flaw.
13
+
14
+ 3. **Impact Assessment**
15
+ - Explain the potential risks (e.g., maintainability, readability, performance, security).
16
+ - Clarify how severe the issue is.
17
+
18
+ 4. **Suggested Fix**
19
+ - Provide a concise, actionable recommendation.
20
+ - If relevant, show a short code snippet with the corrected approach.
21
+
22
+ 5. **Best Practice Note**
23
+ - Mention a general guideline or principle (e.g., SOLID, DRY, naming conventions) that helps prevent similar issues.
24
+
25
+ ## Linter Result
26
+ {linter_result}
27
+
28
+ ## Code Smell Result
29
+ {code_smell_result}
30
+
31
+ Output Format:
32
+ - Use numbered steps for each lint message or code smell.
33
+ - Keep explanations simple but professional.
34
+ - Provide examples where helpful.
35
+ """
@@ -0,0 +1,66 @@
1
+ TOTAL_SUMMARY_TEMPLATE = """
2
+ # PR Total Summary Instructions
3
+
4
+ You are a senior code reviewer generating the **final PR Total Summary**.
5
+ You MUST base your analysis **strictly and exclusively** on the information provided below.
6
+ Do NOT introduce assumptions, external standards, or unstated context.
7
+
8
+ Your task is to synthesize all provided review artifacts into a single, well-reasoned conclusion.
9
+
10
+ ## Requirements
11
+
12
+ - Use **all provided inputs** as evidence:
13
+ - First Code Review Result
14
+ - First Summary Result
15
+ - Linter Result
16
+ - Code Smell Result
17
+ - Code Diff
18
+ - The final summary must clearly reflect **actual findings** from the above inputs.
19
+ - Avoid generic statements such as “code quality is good” unless directly supported by the data.
20
+ - Do NOT repeat earlier comments verbatim; instead, **aggregate and interpret** them.
21
+ - If there are conflicting signals (e.g., linter passes but code smells exist), explicitly reconcile them.
22
+ - If critical issues exist, they must directly impact the final recommendation.
23
+
24
+ ## Output Format
25
+
26
+ Respond in **structured bullet points**, professional and concise, covering only:
27
+
28
+ 1. **Overall conclusion**
29
+ - Does the PR meet merge criteria based on the evidence?
30
+ - Mention any blocking vs non-blocking concerns.
31
+
32
+ 2. **Comprehensive evaluation**
33
+ - Code quality and correctness (derived from review + diff)
34
+ - Maintainability and design concerns (derived from code smells / structure)
35
+ - Consistency with existing patterns or standards (only if inferable from the diff)
36
+
37
+ 3. **Final decision recommendation**
38
+ - One of: Approve merge / Request changes / Comment only
39
+ - Justify the decision using concrete findings.
40
+
41
+ 4. **Team follow-up (if applicable)**
42
+ - Specific, actionable next steps grounded in the findings
43
+ - Omit this section if no follow-up is needed.
44
+
45
+ Constraints:
46
+ - Do NOT add new issues not present in the provided inputs.
47
+ - Do NOT speculate about runtime behavior or architecture beyond what the diff shows.
48
+ - Focus solely on final judgment, not detailed line-by-line critique.
49
+
50
+ ---
51
+
52
+ ## First Code Review Result
53
+ {first_code_review}
54
+
55
+ ## First Summary Result
56
+ {first_summary}
57
+
58
+ ## Linter Result
59
+ {linter_result}
60
+
61
+ ## Code Smell Result
62
+ {code_smell_result}
63
+
64
+ ## Code Diff
65
+ {code_diff}
66
+ """
@@ -0,0 +1,136 @@
1
+ import os
2
+
3
+ from PySide6.QtCore import QFileSystemWatcher
4
+ from PySide6.QtWidgets import (
5
+ QWidget, QVBoxLayout, QHBoxLayout,
6
+ QComboBox, QTextEdit, QPushButton, QGroupBox, QMessageBox
7
+ )
8
+ from je_editor import language_wrapper
9
+
10
+ from automation_ide.automation_editor_ui.extend_ai_gui.ai_gui_global_variable import COT_TEMPLATE_FILES, \
11
+ COT_TEMPLATE_RELATION
12
+
13
+
14
+ class CoTPromptEditor(QWidget):
15
+ def __init__(self, prompt_files=None, parent=None):
16
+ super().__init__(parent)
17
+ self.prompt_files = prompt_files or COT_TEMPLATE_FILES
18
+
19
+ # 對應檔案名稱與模板內容
20
+ self.templates = COT_TEMPLATE_RELATION
21
+
22
+ self.setWindowTitle(language_wrapper.language_word_dict.get(
23
+ "cot_cot_prompt_editor_window_title"
24
+ )) # 視窗標題:Prompt 編輯器
25
+
26
+ # --- Layouts (版面配置) ---
27
+ main_layout = QVBoxLayout(self)
28
+ top_layout = QHBoxLayout()
29
+ editor_layout = QHBoxLayout()
30
+ bottom_layout = QHBoxLayout()
31
+
32
+ # --- ComboBox for selecting files (下拉選單選擇檔案) ---
33
+ self.file_selector = QComboBox()
34
+ self.file_selector.addItems(self.prompt_files)
35
+ self.file_selector.currentIndexChanged.connect(self.load_file_content)
36
+
37
+ # --- Left Editable panel (左邊編輯區塊) ---
38
+ self.middle_editor = QTextEdit()
39
+ prompt_group = QGroupBox(language_wrapper.language_word_dict.get(
40
+ "cot_prompt_editor_groupbox_edit_file_content"
41
+ )) # 左邊編輯檔案內容
42
+ middle_layout = QVBoxLayout()
43
+ middle_layout.addWidget(self.middle_editor)
44
+ prompt_group.setLayout(middle_layout)
45
+
46
+ editor_layout.addWidget(prompt_group, 1)
47
+
48
+ # --- Buttons ---
49
+ self.create_button = QPushButton(language_wrapper.language_word_dict.get(
50
+ "cot_prompt_editor_button_create_file"
51
+ ))
52
+ self.create_button.clicked.connect(self.create_file)
53
+
54
+ self.save_button = QPushButton(language_wrapper.language_word_dict.get(
55
+ "cot_prompt_editor_button_save_file"
56
+ ))
57
+ self.save_button.clicked.connect(self.save_file)
58
+
59
+ self.reload_button = QPushButton(language_wrapper.language_word_dict.get(
60
+ "cot_prompt_editor_button_reload_file"
61
+ ))
62
+ self.reload_button.clicked.connect(lambda: self.load_file_content(self.file_selector.currentIndex()))
63
+
64
+ bottom_layout.addWidget(self.file_selector)
65
+ bottom_layout.addStretch()
66
+ bottom_layout.addWidget(self.reload_button)
67
+ bottom_layout.addWidget(self.save_button)
68
+ bottom_layout.addWidget(self.create_button)
69
+
70
+ # --- Combine layouts (組合版面配置) ---
71
+ main_layout.addLayout(top_layout)
72
+ main_layout.addLayout(editor_layout)
73
+ main_layout.addLayout(bottom_layout)
74
+
75
+ # --- FileSystemWatcher (檔案監控器) ---
76
+ self.watcher = QFileSystemWatcher(self.prompt_files)
77
+ self.watcher.fileChanged.connect(self.on_file_changed)
78
+
79
+ # 預設載入第一個檔案
80
+ self.load_file_content(0)
81
+
82
+ def load_file_content(self, index):
83
+ """載入選擇的檔案內容到左邊編輯區"""
84
+ filename = self.prompt_files[index]
85
+ self.current_file = filename
86
+ if os.path.exists(filename):
87
+ with open(filename, "r", encoding="utf-8") as f:
88
+ content = f.read()
89
+ self.middle_editor.setPlainText(content)
90
+ else:
91
+ self.middle_editor.setPlainText(language_wrapper.language_word_dict.get(
92
+ "cot_prompt_editor_file_not_exist"
93
+ ).format(filename=filename))
94
+
95
+ def create_file(self):
96
+ """建立目前選擇的檔案,若不存在則用模板內容建立"""
97
+ filename = self.current_file
98
+ if os.path.exists(filename):
99
+ QMessageBox.information(
100
+ self,
101
+ language_wrapper.language_word_dict.get("cot_prompt_editor_msgbox_info_title"),
102
+ language_wrapper.language_word_dict.get("cot_prompt_editor_msgbox_file_exists").format(filename=filename))
103
+ return
104
+
105
+ template_content = self.templates.get(filename, "")
106
+ with open(filename, "w", encoding="utf-8") as f:
107
+ f.write(template_content)
108
+
109
+ QMessageBox.information(
110
+ self,
111
+ language_wrapper.language_word_dict.get("cot_prompt_editor_msgbox_success_title"),
112
+ language_wrapper.language_word_dict.get("cot_prompt_editor_msgbox_file_created").format(filename=filename))
113
+ self.load_file_content(self.file_selector.currentIndex())
114
+
115
+ def on_file_changed(self, path):
116
+ """當檔案被外部修改時即時更新"""
117
+ if path == self.current_file:
118
+ self.load_file_content(self.file_selector.currentIndex())
119
+
120
+ def save_file(self):
121
+ """將左邊編輯區內容儲存到目前檔案"""
122
+ if not hasattr(self, "current_file"):
123
+ QMessageBox.warning(
124
+ self,
125
+ language_wrapper.language_word_dict.get("cot_prompt_editor_msgbox_error_title"),
126
+ language_wrapper.language_word_dict.get("cot_cot_prompt_editor_msgbox_no_file_selected"))
127
+ return
128
+
129
+ content = self.middle_editor.toPlainText()
130
+ with open(self.current_file, "w", encoding="utf-8") as f:
131
+ f.write(content)
132
+ QMessageBox.information(
133
+ self,
134
+ language_wrapper.language_word_dict.get("cot_prompt_editor_msgbox_success_title"),
135
+ language_wrapper.language_word_dict.get("cot_prompt_editor_msgbox_file_saved").format(
136
+ filename=self.current_file))
@@ -0,0 +1,136 @@
1
+ import os
2
+
3
+ from PySide6.QtCore import QFileSystemWatcher
4
+ from PySide6.QtWidgets import (
5
+ QWidget, QVBoxLayout, QHBoxLayout,
6
+ QComboBox, QTextEdit, QPushButton, QGroupBox, QMessageBox
7
+ )
8
+ from je_editor import language_wrapper
9
+
10
+ from automation_ide.automation_editor_ui.extend_ai_gui.ai_gui_global_variable import SKILLS_TEMPLATE_FILES, \
11
+ SKILLS_TEMPLATE_RELATION
12
+
13
+
14
+ class SkillPromptEditor(QWidget):
15
+ def __init__(self, skill_files=None, parent=None):
16
+ super().__init__(parent)
17
+ self.skill_files = skill_files or SKILLS_TEMPLATE_FILES
18
+
19
+ # 對應檔案名稱與模板內容
20
+ self.templates = SKILLS_TEMPLATE_RELATION
21
+
22
+ self.setWindowTitle(language_wrapper.language_word_dict.get(
23
+ "skill_prompt_editor_window_title"
24
+ )) # 視窗標題:Skill Prompt 編輯器
25
+
26
+ # --- Layouts ---
27
+ main_layout = QVBoxLayout(self)
28
+ editor_layout = QHBoxLayout()
29
+ bottom_layout = QHBoxLayout()
30
+
31
+ # --- ComboBox for selecting files ---
32
+ self.file_selector = QComboBox()
33
+ self.file_selector.addItems(self.skill_files)
34
+ self.file_selector.currentIndexChanged.connect(self.load_file_content)
35
+
36
+ # --- Editable panel ---
37
+ self.middle_editor = QTextEdit()
38
+ skill_group = QGroupBox(language_wrapper.language_word_dict.get(
39
+ "skill_prompt_editor_groupbox_edit_file_content"
40
+ ))
41
+ middle_layout = QVBoxLayout()
42
+ middle_layout.addWidget(self.middle_editor)
43
+ skill_group.setLayout(middle_layout)
44
+
45
+ editor_layout.addWidget(skill_group, 1)
46
+
47
+ # --- Buttons ---
48
+ self.create_button = QPushButton(language_wrapper.language_word_dict.get(
49
+ "skill_prompt_editor_button_create_file"
50
+ ))
51
+ self.create_button.clicked.connect(self.create_file)
52
+
53
+ self.save_button = QPushButton(language_wrapper.language_word_dict.get(
54
+ "skill_prompt_editor_button_save_file"
55
+ ))
56
+ self.save_button.clicked.connect(self.save_file)
57
+
58
+ self.reload_button = QPushButton(language_wrapper.language_word_dict.get(
59
+ "skill_prompt_editor_button_reload_file"
60
+ ))
61
+ self.reload_button.clicked.connect(lambda: self.load_file_content(self.file_selector.currentIndex()))
62
+
63
+ bottom_layout.addWidget(self.file_selector)
64
+ bottom_layout.addStretch()
65
+ bottom_layout.addWidget(self.reload_button)
66
+ bottom_layout.addWidget(self.save_button)
67
+ bottom_layout.addWidget(self.create_button)
68
+
69
+ # --- Combine layouts ---
70
+ main_layout.addLayout(editor_layout)
71
+ main_layout.addLayout(bottom_layout)
72
+
73
+ # --- FileSystemWatcher ---
74
+ self.watcher = QFileSystemWatcher(self.skill_files)
75
+ self.watcher.fileChanged.connect(self.on_file_changed)
76
+
77
+ # 預設載入第一個檔案
78
+ self.load_file_content(0)
79
+
80
+ def load_file_content(self, index):
81
+ """載入選擇的檔案內容到編輯區"""
82
+ filename = self.skill_files[index]
83
+ self.current_file = filename
84
+ if os.path.exists(filename):
85
+ with open(filename, "r", encoding="utf-8") as f:
86
+ content = f.read()
87
+ self.middle_editor.setPlainText(content)
88
+ else:
89
+ self.middle_editor.setPlainText(language_wrapper.language_word_dict.get(
90
+ "skill_prompt_editor_file_not_exist"
91
+ ).format(filename=filename))
92
+
93
+ def create_file(self):
94
+ """建立目前選擇的檔案,若不存在則用模板內容建立"""
95
+ filename = self.current_file
96
+ if os.path.exists(filename):
97
+ QMessageBox.information(
98
+ self,
99
+ language_wrapper.language_word_dict.get("skill_prompt_editor_msgbox_info_title"),
100
+ language_wrapper.language_word_dict.get("skill_prompt_editor_msgbox_file_exists").format(
101
+ filename=filename))
102
+ return
103
+
104
+ template_content = self.templates.get(filename, "")
105
+ with open(filename, "w", encoding="utf-8") as f:
106
+ f.write(template_content)
107
+
108
+ QMessageBox.information(
109
+ self,
110
+ language_wrapper.language_word_dict.get("skill_prompt_editor_msgbox_success_title"),
111
+ language_wrapper.language_word_dict.get("skill_prompt_editor_msgbox_file_created").format(
112
+ filename=filename))
113
+ self.load_file_content(self.file_selector.currentIndex())
114
+
115
+ def on_file_changed(self, path):
116
+ """當檔案被外部修改時即時更新"""
117
+ if path == self.current_file:
118
+ self.load_file_content(self.file_selector.currentIndex())
119
+
120
+ def save_file(self):
121
+ """將編輯區內容儲存到目前檔案"""
122
+ if not hasattr(self, "current_file"):
123
+ QMessageBox.warning(
124
+ self,
125
+ language_wrapper.language_word_dict.get("skill_prompt_editor_msgbox_error_title"),
126
+ language_wrapper.language_word_dict.get("skill_prompt_editor_msgbox_no_file_selected"))
127
+ return
128
+
129
+ content = self.middle_editor.toPlainText()
130
+ with open(self.current_file, "w", encoding="utf-8") as f:
131
+ f.write(content)
132
+ QMessageBox.information(
133
+ self,
134
+ language_wrapper.language_word_dict.get("skill_prompt_editor_msgbox_success_title"),
135
+ language_wrapper.language_word_dict.get("skill_prompt_editor_msgbox_file_saved").format(
136
+ filename=self.current_file))
@@ -0,0 +1,21 @@
1
+ CODE_EXPLAINER_TEMPLATE = """
2
+ You are a senior software engineer and educator. Explain the following code clearly and in detail.
3
+
4
+ Focus on:
5
+ - What the code does (purpose).
6
+ - How it works (step-by-step flow, inputs/outputs).
7
+ - Key functions, classes, or modules.
8
+ - Assumptions, edge cases, and possible errors.
9
+ - Performance or security concerns.
10
+ - Suggested improvements.
11
+
12
+ Format:
13
+ - Title: one-line summary.
14
+ - Overview: short description.
15
+ - Detailed explanation: bullet points for flow and components.
16
+ - Improvements: concise list with rationale.
17
+ - Example usage if relevant.
18
+
19
+ Code:
20
+ {code_diff}
21
+ """
@@ -0,0 +1,37 @@
1
+ CODE_REVIEW_SKILL_TEMPLATE = """
2
+ You are an expert software reviewer. Your task is to analyze one or more code diffs from a Pull Request (PR).
3
+ The input may contain multiple `code_diff` sections placed in different positions.
4
+
5
+ For each diff, perform the following analysis and **always output results in three distinct sections**:
6
+
7
+ ---
8
+
9
+ ### 1. **Summary**
10
+ - Explain the purpose and scope of the changes.
11
+ - Highlight affected files, functions, or modules.
12
+ - Provide a plain-language explanation for non-experts.
13
+
14
+ ---
15
+
16
+ ### 2. **Linting Issues**
17
+ - Check the code against style and formatting rules.
18
+ - List violations clearly, with file and line references if possible.
19
+ - Suggest corrections following best practices.
20
+
21
+ ---
22
+
23
+ ### 3. **Code Smells**
24
+ - Identify potential maintainability issues (duplication, long functions, poor naming, tight coupling).
25
+ - Explain why each issue is problematic.
26
+ - Recommend improvements or refactoring strategies.
27
+
28
+ ---
29
+
30
+ ## Code diff
31
+ {code_diff}
32
+
33
+ ### Output Format
34
+ - Group results by diff: e.g., **Diff #1**, **Diff #2**, etc.
35
+ - Within each diff, strictly divide output into the three sections: **Summary**, **Linting Issues**, **Code Smells**.
36
+ - Present findings in bullet points or tables for readability.
37
+ """