jarvis-ai-assistant 0.1.104__py3-none-any.whl → 0.1.106__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.

Potentially problematic release.


This version of jarvis-ai-assistant might be problematic. Click here for more details.

Files changed (62) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/agent.py +124 -67
  3. jarvis/jarvis_code_agent/code_agent.py +133 -22
  4. jarvis/jarvis_code_agent/patch.py +4 -7
  5. jarvis/jarvis_code_agent/relevant_files.py +163 -72
  6. jarvis/jarvis_codebase/main.py +36 -15
  7. jarvis/jarvis_lsp/base.py +143 -0
  8. jarvis/jarvis_lsp/cpp.py +134 -0
  9. jarvis/jarvis_lsp/go.py +140 -0
  10. jarvis/jarvis_lsp/python.py +135 -0
  11. jarvis/jarvis_lsp/registry.py +234 -0
  12. jarvis/jarvis_lsp/rust.py +142 -0
  13. jarvis/jarvis_platform/__init__.py +3 -0
  14. jarvis/{models → jarvis_platform}/ai8.py +1 -1
  15. jarvis/{models → jarvis_platform}/kimi.py +1 -1
  16. jarvis/{models → jarvis_platform}/ollama.py +1 -1
  17. jarvis/{models → jarvis_platform}/openai.py +1 -1
  18. jarvis/{models → jarvis_platform}/oyi.py +1 -1
  19. jarvis/{models → jarvis_platform}/registry.py +11 -11
  20. jarvis/{jarvis_platform → jarvis_platform_manager}/main.py +1 -1
  21. jarvis/jarvis_rag/main.py +6 -6
  22. jarvis/jarvis_smart_shell/main.py +3 -3
  23. jarvis/jarvis_tools/__init__.py +0 -0
  24. jarvis/{tools → jarvis_tools}/ask_user.py +1 -1
  25. jarvis/{tools → jarvis_tools}/code_review.py +34 -8
  26. jarvis/jarvis_tools/create_code_agent.py +115 -0
  27. jarvis/{tools → jarvis_tools}/create_sub_agent.py +1 -1
  28. jarvis/jarvis_tools/deep_thinking.py +160 -0
  29. jarvis/jarvis_tools/deep_thinking_agent.py +146 -0
  30. jarvis/{tools → jarvis_tools}/git_commiter.py +2 -2
  31. jarvis/jarvis_tools/lsp_find_definition.py +134 -0
  32. jarvis/jarvis_tools/lsp_find_references.py +111 -0
  33. jarvis/jarvis_tools/lsp_get_diagnostics.py +121 -0
  34. jarvis/jarvis_tools/lsp_get_document_symbols.py +87 -0
  35. jarvis/jarvis_tools/lsp_prepare_rename.py +130 -0
  36. jarvis/jarvis_tools/lsp_validate_edit.py +141 -0
  37. jarvis/{tools → jarvis_tools}/methodology.py +6 -1
  38. jarvis/{tools → jarvis_tools}/registry.py +6 -5
  39. jarvis/{tools → jarvis_tools}/search.py +2 -2
  40. jarvis/utils.py +68 -25
  41. {jarvis_ai_assistant-0.1.104.dist-info → jarvis_ai_assistant-0.1.106.dist-info}/METADATA +23 -16
  42. jarvis_ai_assistant-0.1.106.dist-info/RECORD +62 -0
  43. {jarvis_ai_assistant-0.1.104.dist-info → jarvis_ai_assistant-0.1.106.dist-info}/entry_points.txt +3 -4
  44. jarvis/models/__init__.py +0 -3
  45. jarvis/tools/create_code_test_agent.py +0 -115
  46. jarvis/tools/create_ctags_agent.py +0 -164
  47. jarvis/tools/find_in_codebase.py +0 -78
  48. jarvis_ai_assistant-0.1.104.dist-info/RECORD +0 -50
  49. /jarvis/{models → jarvis_platform}/base.py +0 -0
  50. /jarvis/{tools → jarvis_platform_manager}/__init__.py +0 -0
  51. /jarvis/{tools → jarvis_tools}/ask_codebase.py +0 -0
  52. /jarvis/{tools → jarvis_tools}/base.py +0 -0
  53. /jarvis/{tools → jarvis_tools}/chdir.py +0 -0
  54. /jarvis/{tools → jarvis_tools}/execute_shell.py +0 -0
  55. /jarvis/{tools → jarvis_tools}/file_operation.py +0 -0
  56. /jarvis/{tools → jarvis_tools}/rag.py +0 -0
  57. /jarvis/{tools → jarvis_tools}/read_code.py +0 -0
  58. /jarvis/{tools → jarvis_tools}/read_webpage.py +0 -0
  59. /jarvis/{tools → jarvis_tools}/select_code_files.py +0 -0
  60. {jarvis_ai_assistant-0.1.104.dist-info → jarvis_ai_assistant-0.1.106.dist-info}/LICENSE +0 -0
  61. {jarvis_ai_assistant-0.1.104.dist-info → jarvis_ai_assistant-0.1.106.dist-info}/WHEEL +0 -0
  62. {jarvis_ai_assistant-0.1.104.dist-info → jarvis_ai_assistant-0.1.106.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  from typing import Dict, List, Tuple
2
2
  import os
3
3
  from openai import OpenAI
4
- from jarvis.models.base import BasePlatform
4
+ from jarvis.jarvis_platform.base import BasePlatform
5
5
  from jarvis.utils import PrettyOutput, OutputType
6
6
 
7
7
  class OpenAIModel(BasePlatform):
@@ -1,7 +1,7 @@
1
1
  import mimetypes
2
2
  import os
3
3
  from typing import Dict, List, Tuple
4
- from jarvis.models.base import BasePlatform
4
+ from jarvis.jarvis_platform.base import BasePlatform
5
5
  from jarvis.utils import PrettyOutput, OutputType, get_max_context_length
6
6
  import requests
7
7
  import json
@@ -3,8 +3,8 @@ import inspect
3
3
  import os
4
4
  import sys
5
5
  from typing import Dict, Type, Optional, List
6
- from jarvis.models.base import BasePlatform
7
- from jarvis.utils import PrettyOutput, OutputType
6
+ from jarvis.jarvis_platform.base import BasePlatform
7
+ from jarvis.utils import PrettyOutput, OutputType, get_cheap_model_name, get_cheap_platform_name, get_codegen_model_name, get_codegen_platform_name, get_normal_model_name, get_normal_platform_name, get_thinking_model_name, get_thinking_platform_name
8
8
 
9
9
  REQUIRED_METHODS = [
10
10
  ('chat', ['message']), # 方法名和参数列表
@@ -98,7 +98,7 @@ class PlatformRegistry:
98
98
  # 获取目录的包名
99
99
  package_name = None
100
100
  if directory == os.path.dirname(__file__):
101
- package_name = "jarvis.models"
101
+ package_name = "jarvis.jarvis_platform"
102
102
 
103
103
  # 添加目录到Python路径
104
104
  if directory not in sys.path:
@@ -155,29 +155,29 @@ class PlatformRegistry:
155
155
 
156
156
 
157
157
  def get_normal_platform(self) -> BasePlatform:
158
- platform_name = os.environ.get("JARVIS_PLATFORM", "kimi")
159
- model_name = os.environ.get("JARVIS_MODEL", "kimi")
158
+ platform_name = get_normal_platform_name()
159
+ model_name = get_normal_model_name()
160
160
  platform = self.create_platform(platform_name)
161
161
  platform.set_model_name(model_name) # type: ignore
162
162
  return platform # type: ignore
163
163
 
164
164
  def get_codegen_platform(self) -> BasePlatform:
165
- platform_name = os.environ.get("JARVIS_CODEGEN_PLATFORM", os.environ.get("JARVIS_PLATFORM", "kimi"))
166
- model_name = os.environ.get("JARVIS_CODEGEN_MODEL", os.environ.get("JARVIS_MODEL", "kimi"))
165
+ platform_name = get_codegen_platform_name()
166
+ model_name = get_codegen_model_name()
167
167
  platform = self.create_platform(platform_name)
168
168
  platform.set_model_name(model_name) # type: ignore
169
169
  return platform # type: ignore
170
170
 
171
171
  def get_cheap_platform(self) -> BasePlatform:
172
- platform_name = os.environ.get("JARVIS_CHEAP_PLATFORM", os.environ.get("JARVIS_PLATFORM", "kimi"))
173
- model_name = os.environ.get("JARVIS_CHEAP_MODEL", os.environ.get("JARVIS_MODEL", "kimi"))
172
+ platform_name = get_cheap_platform_name()
173
+ model_name = get_cheap_model_name()
174
174
  platform = self.create_platform(platform_name)
175
175
  platform.set_model_name(model_name) # type: ignore
176
176
  return platform # type: ignore
177
177
 
178
178
  def get_thinking_platform(self) -> BasePlatform:
179
- platform_name = os.environ.get("JARVIS_THINKING_PLATFORM", os.environ.get("JARVIS_PLATFORM", "kimi"))
180
- model_name = os.environ.get("JARVIS_THINKING_MODEL", os.environ.get("JARVIS_MODEL", "kimi"))
179
+ platform_name = get_thinking_platform_name()
180
+ model_name = get_thinking_model_name()
181
181
  platform = self.create_platform(platform_name)
182
182
  platform.set_model_name(model_name) # type: ignore
183
183
  return platform # type: ignore
@@ -1,4 +1,4 @@
1
- from jarvis.models.registry import PlatformRegistry
1
+ from jarvis.jarvis_platform.registry import PlatformRegistry
2
2
  from jarvis.utils import PrettyOutput, OutputType, init_env, get_multiline_input
3
3
 
4
4
  def list_platforms():
jarvis/jarvis_rag/main.py CHANGED
@@ -3,14 +3,14 @@ import numpy as np
3
3
  import faiss
4
4
  from typing import List, Tuple, Optional, Dict
5
5
  import pickle
6
- from jarvis.utils import OutputType, PrettyOutput, get_file_md5, get_max_context_length, load_embedding_model, load_rerank_model
6
+ from jarvis.utils import OutputType, PrettyOutput, get_context_window, get_file_md5, get_max_context_length, get_max_paragraph_length, get_min_paragraph_length, get_thread_count, load_embedding_model, load_rerank_model
7
7
  from jarvis.utils import init_env
8
8
  from dataclasses import dataclass
9
9
  from tqdm import tqdm
10
10
  import fitz # PyMuPDF for PDF files
11
11
  from docx import Document as DocxDocument # python-docx for DOCX files
12
12
  from pathlib import Path
13
- from jarvis.models.registry import PlatformRegistry
13
+ from jarvis.jarvis_platform.registry import PlatformRegistry
14
14
  import shutil
15
15
  from datetime import datetime
16
16
  import lzma # 添加 lzma 导入
@@ -142,9 +142,9 @@ class RAGTool:
142
142
  os.chdir(self.root_dir)
143
143
 
144
144
  # Initialize configuration
145
- self.min_paragraph_length = int(os.environ.get("JARVIS_MIN_PARAGRAPH_LENGTH", "50")) # Minimum paragraph length
146
- self.max_paragraph_length = int(os.environ.get("JARVIS_MAX_PARAGRAPH_LENGTH", "1000")) # Maximum paragraph length
147
- self.context_window = int(os.environ.get("JARVIS_CONTEXT_WINDOW", "5")) # Context window size, default前后各5个片段
145
+ self.min_paragraph_length = get_min_paragraph_length() # Minimum paragraph length
146
+ self.max_paragraph_length = get_max_paragraph_length() # Maximum paragraph length
147
+ self.context_window = get_context_window() # Context window size, default前后各5个片段
148
148
  self.max_context_length = int(get_max_context_length() * 0.8)
149
149
 
150
150
  # Initialize data directory
@@ -179,7 +179,7 @@ class RAGTool:
179
179
  ]
180
180
 
181
181
  # Add thread related configuration
182
- self.thread_count = int(os.environ.get("JARVIS_THREAD_COUNT", os.cpu_count() or 4))
182
+ self.thread_count = get_thread_count()
183
183
  self.vector_lock = Lock() # Protect vector list concurrency
184
184
 
185
185
  def _load_cache(self):
@@ -7,8 +7,8 @@ from typing import Optional
7
7
  from yaspin import yaspin # type: ignore
8
8
  from yaspin.spinners import Spinners # type: ignore
9
9
 
10
- from jarvis.models.registry import PlatformRegistry
11
- from jarvis.utils import PrettyOutput, OutputType, init_env
10
+ from jarvis.jarvis_platform.registry import PlatformRegistry
11
+ from jarvis.utils import PrettyOutput, OutputType, get_shell_name, init_env
12
12
 
13
13
  def execute_command(command: str) -> None:
14
14
  """Show command and allow user to edit, then execute, Ctrl+C to cancel"""
@@ -42,7 +42,7 @@ def process_request(request: str) -> Optional[str]:
42
42
  model = PlatformRegistry.get_global_platform_registry().get_normal_platform()
43
43
  model.set_suppress_output(True)
44
44
 
45
- shell = os.environ.get("SHELL") or "bash"
45
+ shell = get_shell_name()
46
46
  current_path = os.getcwd()
47
47
 
48
48
  # Set system prompt
File without changes
@@ -1,5 +1,5 @@
1
1
  from typing import Dict, Any
2
- from jarvis.tools.base import Tool
2
+ from jarvis.jarvis_tools.base import Tool
3
3
  from jarvis.utils import get_multiline_input, PrettyOutput, OutputType
4
4
 
5
5
  class AskUserTool:
@@ -1,8 +1,8 @@
1
1
  from typing import Dict, Any, List
2
2
  import subprocess
3
3
  import yaml
4
- from jarvis.models.registry import PlatformRegistry
5
- from jarvis.tools.registry import ToolRegistry
4
+ from jarvis.jarvis_platform.registry import PlatformRegistry
5
+ from jarvis.jarvis_tools.registry import ToolRegistry
6
6
  from jarvis.utils import OutputType, PrettyOutput, init_env, find_git_root
7
7
  from jarvis.agent import Agent
8
8
  import re
@@ -15,13 +15,21 @@ class CodeReviewTool:
15
15
  "properties": {
16
16
  "review_type": {
17
17
  "type": "string",
18
- "description": "Type of review: 'commit' for specific commit, 'current' for current changes",
19
- "enum": ["commit", "current"],
18
+ "description": "Type of review: 'commit' for specific commit, 'current' for current changes, 'range' for commit range",
19
+ "enum": ["commit", "current", "range"],
20
20
  "default": "current"
21
21
  },
22
22
  "commit_sha": {
23
23
  "type": "string",
24
24
  "description": "Target commit SHA to analyze (required for review_type='commit')"
25
+ },
26
+ "start_commit": {
27
+ "type": "string",
28
+ "description": "Start commit SHA (required for review_type='range')"
29
+ },
30
+ "end_commit": {
31
+ "type": "string",
32
+ "description": "End commit SHA (required for review_type='range')"
25
33
  }
26
34
  },
27
35
  "required": []
@@ -45,6 +53,16 @@ class CodeReviewTool:
45
53
  }
46
54
  commit_sha = args["commit_sha"].strip()
47
55
  diff_cmd = f"git show {commit_sha} | cat -"
56
+ elif review_type == "range":
57
+ if "start_commit" not in args or "end_commit" not in args:
58
+ return {
59
+ "success": False,
60
+ "stdout": {},
61
+ "stderr": "start_commit and end_commit are required for range review type"
62
+ }
63
+ start_commit = args["start_commit"].strip()
64
+ end_commit = args["end_commit"].strip()
65
+ diff_cmd = f"git diff {start_commit}..{end_commit} | cat -"
48
66
  else: # current changes
49
67
  diff_cmd = "git diff HEAD | cat -"
50
68
 
@@ -169,7 +187,7 @@ OUTPUT REQUIREMENTS:
169
187
  }
170
188
 
171
189
 
172
- def _extract_code_report(result: str) -> str:
190
+ def extract_code_report(result: str) -> str:
173
191
  sm = re.search(r"<REPORT>(.*?)</REPORT>", result, re.DOTALL)
174
192
  if sm:
175
193
  return sm.group(1)
@@ -180,14 +198,18 @@ def main():
180
198
  import argparse
181
199
 
182
200
  parser = argparse.ArgumentParser(description='Autonomous code review tool')
183
- parser.add_argument('--type', choices=['commit', 'current'], default='current',
184
- help='Type of review: commit or current changes')
201
+ parser.add_argument('--type', choices=['commit', 'current', 'range'], default='current',
202
+ help='Type of review: commit, current changes, or commit range')
185
203
  parser.add_argument('--commit', help='Commit SHA to review (required for commit type)')
204
+ parser.add_argument('--start-commit', help='Start commit SHA (required for range type)')
205
+ parser.add_argument('--end-commit', help='End commit SHA (required for range type)')
186
206
  args = parser.parse_args()
187
207
 
188
208
  # Validate arguments
189
209
  if args.type == 'commit' and not args.commit:
190
210
  parser.error("--commit is required when type is 'commit'")
211
+ if args.type == 'range' and (not args.start_commit or not args.end_commit):
212
+ parser.error("--start-commit and --end-commit are required when type is 'range'")
191
213
 
192
214
  tool = CodeReviewTool()
193
215
  tool_args = {
@@ -195,12 +217,16 @@ def main():
195
217
  }
196
218
  if args.commit:
197
219
  tool_args["commit_sha"] = args.commit
220
+ if args.start_commit:
221
+ tool_args["start_commit"] = args.start_commit
222
+ if args.end_commit:
223
+ tool_args["end_commit"] = args.end_commit
198
224
 
199
225
  result = tool.execute(tool_args)
200
226
 
201
227
  if result["success"]:
202
228
  PrettyOutput.section("Autonomous Review Result:", OutputType.SUCCESS)
203
- report = _extract_code_report(result["stdout"])
229
+ report = extract_code_report(result["stdout"])
204
230
  PrettyOutput.print(report, OutputType.SUCCESS, lang="yaml")
205
231
 
206
232
  else:
@@ -0,0 +1,115 @@
1
+ import os
2
+ from typing import Dict, Any
3
+ from jarvis.jarvis_code_agent.code_agent import CodeAgent
4
+ from jarvis.jarvis_tools.git_commiter import GitCommitTool
5
+ from jarvis.jarvis_tools.code_review import CodeReviewTool, extract_code_report
6
+ from jarvis.utils import OutputType, PrettyOutput, has_uncommitted_changes
7
+
8
+ class CreateCodeAgentTool:
9
+ """Tool for managing the code development workflow."""
10
+
11
+ name = "create_code_agent"
12
+ description = "Manage code development workflow including commit, development, and review"
13
+ parameters = {
14
+ "requirement": "The development requirement or task description"
15
+ }
16
+
17
+ def _get_current_commit(self) -> str:
18
+ """Get current commit hash."""
19
+ return os.popen("git rev-parse HEAD").read().strip()
20
+
21
+ def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
22
+ try:
23
+ requirement = args.get("requirement", "")
24
+ if not requirement:
25
+ return {
26
+ "success": False,
27
+ "stderr": "Requirement must be provided",
28
+ "stdout": ""
29
+ }
30
+
31
+ # Step 1: Handle uncommitted changes
32
+ start_commit = None
33
+ if has_uncommitted_changes():
34
+ PrettyOutput.print("Found uncommitted changes, committing first...", OutputType.INFO)
35
+ git_commiter = GitCommitTool()
36
+ result = git_commiter.execute({})
37
+ if not result["success"]:
38
+ return {
39
+ "success": False,
40
+ "stderr": "Failed to commit changes: " + result["stderr"],
41
+ "stdout": ""
42
+ }
43
+
44
+ # Get current commit hash
45
+ start_commit = self._get_current_commit()
46
+
47
+ # Step 2: Development
48
+ PrettyOutput.print("Starting development...", OutputType.INFO)
49
+ agent = CodeAgent()
50
+ agent.run(requirement)
51
+
52
+ # Get new commit hash after development
53
+ end_commit = self._get_current_commit()
54
+
55
+ # Step 3: Code Review
56
+ PrettyOutput.print("Starting code review...", OutputType.INFO)
57
+ reviewer = CodeReviewTool()
58
+ review_result = reviewer.execute({
59
+ "review_type": "range",
60
+ "start_commit": start_commit,
61
+ "end_commit": end_commit
62
+ })
63
+
64
+ if not review_result["success"]:
65
+ return {
66
+ "success": False,
67
+ "stderr": "Code review failed: " + review_result["stderr"],
68
+ "stdout": ""
69
+ }
70
+
71
+ # Step 4: Generate Summary
72
+ summary = f"""Development Summary:
73
+
74
+ Start Commit: {start_commit}
75
+ End Commit: {end_commit}
76
+
77
+ Requirement:
78
+ {requirement}
79
+
80
+ Code Review Result:
81
+ {extract_code_report(review_result["stdout"])}
82
+ """
83
+
84
+ return {
85
+ "success": True,
86
+ "stdout": summary,
87
+ "stderr": ""
88
+ }
89
+
90
+ except Exception as e:
91
+ return {
92
+ "success": False,
93
+ "stderr": f"Development workflow failed: {str(e)}",
94
+ "stdout": ""
95
+ }
96
+
97
+ def main():
98
+ """CLI entry point"""
99
+ import argparse
100
+
101
+ parser = argparse.ArgumentParser(description='Code development workflow tool')
102
+ parser.add_argument('requirement', help='Development requirement or task description')
103
+
104
+ args = parser.parse_args()
105
+
106
+ tool = CreateCodeAgentTool()
107
+ result = tool.execute({"requirement": args.requirement})
108
+
109
+ if result["success"]:
110
+ PrettyOutput.print(result["stdout"], OutputType.SUCCESS)
111
+ else:
112
+ PrettyOutput.print(result["stderr"], OutputType.ERROR)
113
+
114
+ if __name__ == "__main__":
115
+ main()
@@ -2,7 +2,7 @@ from typing import Dict, Any
2
2
 
3
3
 
4
4
  from jarvis.agent import Agent, origin_agent_system_prompt
5
- from jarvis.tools.registry import ToolRegistry
5
+ from jarvis.jarvis_tools.registry import ToolRegistry
6
6
  from jarvis.utils import OutputType, PrettyOutput
7
7
 
8
8
 
@@ -0,0 +1,160 @@
1
+ import os
2
+ from typing import Dict, Any
3
+ from jarvis.jarvis_platform.registry import PlatformRegistry
4
+ from jarvis.utils import OutputType, PrettyOutput
5
+
6
+ class DeepThinkingTool:
7
+ """Tool for deep thinking about user requirements using thinking platform."""
8
+
9
+ name = "deep_thinking"
10
+ description = "Analyze and think deeply about user requirements"
11
+ parameters = {
12
+ "requirement": "The requirement or question to think about",
13
+ "mode": {
14
+ "type": "string",
15
+ "description": "Thinking mode: analysis/solution/critique",
16
+ "enum": ["analysis", "solution", "critique"],
17
+ "default": "analysis"
18
+ }
19
+ }
20
+
21
+ def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
22
+ try:
23
+ requirement = args.get("requirement", "")
24
+ mode = args.get("mode", "analysis")
25
+
26
+ if not requirement:
27
+ return {
28
+ "success": False,
29
+ "stderr": "Requirement must be provided",
30
+ "stdout": ""
31
+ }
32
+
33
+ # Get thinking platform
34
+ platform = PlatformRegistry().get_thinking_platform()
35
+
36
+ # Build prompt based on mode
37
+ if mode == "analysis":
38
+ prompt = f"""Please analyze this requirement deeply. Consider:
39
+
40
+ 1. Core Objectives:
41
+ - What is the fundamental goal?
42
+ - What are the key requirements?
43
+ - What are the implicit needs?
44
+
45
+ 2. Scope Analysis:
46
+ - What is included/excluded?
47
+ - What are the boundaries?
48
+ - What are potential edge cases?
49
+
50
+ 3. Challenges:
51
+ - What are the technical challenges?
52
+ - What are potential risks?
53
+ - What needs special attention?
54
+
55
+ 4. Dependencies:
56
+ - What are the prerequisites?
57
+ - What systems will be affected?
58
+ - What integrations are needed?
59
+
60
+ Requirement to analyze:
61
+ {requirement}
62
+
63
+ Please provide a structured analysis."""
64
+
65
+ elif mode == "solution":
66
+ prompt = f"""Please think deeply about potential solutions. Consider:
67
+
68
+ 1. Solution Approaches:
69
+ - What are possible approaches?
70
+ - What are the pros/cons of each?
71
+ - What is the recommended approach?
72
+
73
+ 2. Implementation Strategy:
74
+ - How should this be implemented?
75
+ - What are the key steps?
76
+ - What is the suggested order?
77
+
78
+ 3. Technical Considerations:
79
+ - What technologies should be used?
80
+ - What patterns would work best?
81
+ - What should be avoided?
82
+
83
+ 4. Risk Mitigation:
84
+ - How to handle potential issues?
85
+ - What safeguards are needed?
86
+ - What should be tested carefully?
87
+
88
+ Requirement to solve:
89
+ {requirement}
90
+
91
+ Please provide a structured solution plan."""
92
+
93
+ else: # critique
94
+ prompt = f"""Please critique this requirement carefully. Consider:
95
+
96
+ 1. Clarity:
97
+ - Is it clearly defined?
98
+ - Are there ambiguities?
99
+ - What needs clarification?
100
+
101
+ 2. Completeness:
102
+ - Are all aspects covered?
103
+ - What might be missing?
104
+ - Are edge cases considered?
105
+
106
+ 3. Feasibility:
107
+ - Is it technically feasible?
108
+ - Are there resource constraints?
109
+ - What are potential blockers?
110
+
111
+ 4. Improvements:
112
+ - How could it be better?
113
+ - What should be added/removed?
114
+ - What alternatives exist?
115
+
116
+ Requirement to critique:
117
+ {requirement}
118
+
119
+ Please provide a structured critique."""
120
+
121
+ # Get thinking result
122
+ result = platform.chat_until_success(prompt)
123
+
124
+ return {
125
+ "success": True,
126
+ "stdout": result,
127
+ "stderr": ""
128
+ }
129
+
130
+ except Exception as e:
131
+ return {
132
+ "success": False,
133
+ "stderr": f"Thinking failed: {str(e)}",
134
+ "stdout": ""
135
+ }
136
+
137
+ def main():
138
+ """CLI entry point"""
139
+ import argparse
140
+
141
+ parser = argparse.ArgumentParser(description='Deep thinking tool')
142
+ parser.add_argument('requirement', help='Requirement to think about')
143
+ parser.add_argument('--mode', choices=['analysis', 'solution', 'critique'],
144
+ default='analysis', help='Thinking mode')
145
+
146
+ args = parser.parse_args()
147
+
148
+ tool = DeepThinkingTool()
149
+ result = tool.execute({
150
+ "requirement": args.requirement,
151
+ "mode": args.mode
152
+ })
153
+
154
+ if result["success"]:
155
+ PrettyOutput.print(result["stdout"], OutputType.SUCCESS)
156
+ else:
157
+ PrettyOutput.print(result["stderr"], OutputType.ERROR)
158
+
159
+ if __name__ == "__main__":
160
+ main()