auto-coder 0.1.329__py3-none-any.whl → 0.1.331__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 auto-coder might be problematic. Click here for more details.

Files changed (41) hide show
  1. {auto_coder-0.1.329.dist-info → auto_coder-0.1.331.dist-info}/METADATA +1 -1
  2. {auto_coder-0.1.329.dist-info → auto_coder-0.1.331.dist-info}/RECORD +41 -41
  3. autocoder/agent/project_reader.py +1 -14
  4. autocoder/auto_coder.py +1 -24
  5. autocoder/command_args.py +1 -6
  6. autocoder/commands/tools.py +0 -13
  7. autocoder/common/__init__.py +6 -3
  8. autocoder/common/auto_coder_lang.py +12 -0
  9. autocoder/common/code_auto_generate.py +6 -160
  10. autocoder/common/code_auto_generate_diff.py +5 -111
  11. autocoder/common/code_auto_generate_editblock.py +5 -95
  12. autocoder/common/code_auto_generate_strict_diff.py +6 -112
  13. autocoder/common/code_auto_merge_editblock.py +1 -45
  14. autocoder/common/command_templates.py +2 -9
  15. autocoder/common/stream_out_type.py +3 -0
  16. autocoder/common/types.py +2 -1
  17. autocoder/common/v2/code_auto_generate.py +6 -4
  18. autocoder/common/v2/code_auto_generate_diff.py +4 -3
  19. autocoder/common/v2/code_auto_generate_editblock.py +9 -4
  20. autocoder/common/v2/code_auto_generate_strict_diff.py +182 -14
  21. autocoder/common/v2/code_auto_merge_diff.py +560 -306
  22. autocoder/common/v2/code_auto_merge_editblock.py +11 -44
  23. autocoder/common/v2/code_auto_merge_strict_diff.py +76 -7
  24. autocoder/common/v2/code_editblock_manager.py +141 -6
  25. autocoder/dispacher/actions/action.py +15 -28
  26. autocoder/dispacher/actions/plugins/action_regex_project.py +5 -9
  27. autocoder/helper/project_creator.py +0 -1
  28. autocoder/index/entry.py +0 -43
  29. autocoder/index/filter/normal_filter.py +0 -16
  30. autocoder/lang.py +2 -4
  31. autocoder/linters/python_linter.py +2 -0
  32. autocoder/pyproject/__init__.py +2 -19
  33. autocoder/rag/cache/simple_cache.py +31 -6
  34. autocoder/regexproject/__init__.py +4 -22
  35. autocoder/suffixproject/__init__.py +6 -24
  36. autocoder/tsproject/__init__.py +5 -22
  37. autocoder/version.py +1 -1
  38. {auto_coder-0.1.329.dist-info → auto_coder-0.1.331.dist-info}/LICENSE +0 -0
  39. {auto_coder-0.1.329.dist-info → auto_coder-0.1.331.dist-info}/WHEEL +0 -0
  40. {auto_coder-0.1.329.dist-info → auto_coder-0.1.331.dist-info}/entry_points.txt +0 -0
  41. {auto_coder-0.1.329.dist-info → auto_coder-0.1.331.dist-info}/top_level.txt +0 -0
@@ -25,6 +25,7 @@ class PythonLinter(BaseLinter):
25
25
  verbose (bool): Whether to display verbose output.
26
26
  """
27
27
  super().__init__(verbose)
28
+ BaseLinter.tt()
28
29
 
29
30
  def get_supported_extensions(self) -> List[str]:
30
31
  """
@@ -152,6 +153,7 @@ class PythonLinter(BaseLinter):
152
153
  sys.executable,
153
154
  "-m",
154
155
  "pylint",
156
+ "--disable=import-error",
155
157
  "--output-format=json",
156
158
  target
157
159
  ]
@@ -233,15 +233,7 @@ class PyProject:
233
233
  def get_rag_source_codes(self):
234
234
  if not self.args.enable_rag_search and not self.args.enable_rag_context:
235
235
  return []
236
-
237
- if self.args.request_id and not self.args.skip_events:
238
- _ = queue_communicate.send_event(
239
- request_id=self.args.request_id,
240
- event=CommunicateEvent(
241
- event_type=CommunicateEventType.CODE_RAG_SEARCH_START.value,
242
- data=json.dumps({},ensure_ascii=False)
243
- )
244
- )
236
+
245
237
  else:
246
238
  console = Console()
247
239
  console.print(f"\n[bold blue]Starting RAG search for:[/bold blue] {self.args.query}")
@@ -250,16 +242,7 @@ class PyProject:
250
242
  rag = RAGFactory.get_rag(self.llm, self.args, "")
251
243
  docs = rag.search(self.args.query)
252
244
  for doc in docs:
253
- doc.tag = "RAG"
254
-
255
- if self.args.request_id and not self.args.skip_events:
256
- _ = queue_communicate.send_event(
257
- request_id=self.args.request_id,
258
- event=CommunicateEvent(
259
- event_type=CommunicateEventType.CODE_RAG_SEARCH_END.value,
260
- data=json.dumps({},ensure_ascii=False)
261
- )
262
- )
245
+ doc.tag = "RAG"
263
246
  else:
264
247
  console = Console()
265
248
  console.print(f"[bold green]Found {len(docs)} relevant documents[/bold green]")
@@ -45,7 +45,7 @@ def generate_content_md5(content: Union[str, bytes]) -> str:
45
45
 
46
46
 
47
47
  class AutoCoderRAGAsyncUpdateQueue(BaseCacheManager):
48
- def __init__(self, path: str, ignore_spec, required_exts: list):
48
+ def __init__(self, path: str, ignore_spec, required_exts: list, update_interval: int = 5):
49
49
  """
50
50
  初始化异步更新队列,用于管理代码文件的缓存。
51
51
 
@@ -53,6 +53,7 @@ class AutoCoderRAGAsyncUpdateQueue(BaseCacheManager):
53
53
  path: 需要索引的代码库根目录
54
54
  ignore_spec: 指定哪些文件/目录应被忽略的规则
55
55
  required_exts: 需要处理的文件扩展名列表
56
+ update_interval: 自动触发更新的时间间隔(秒),默认为5秒
56
57
 
57
58
  缓存结构 (self.cache):
58
59
  self.cache 是一个字典,其结构如下:
@@ -90,13 +91,22 @@ class AutoCoderRAGAsyncUpdateQueue(BaseCacheManager):
90
91
  self.path = path
91
92
  self.ignore_spec = ignore_spec
92
93
  self.required_exts = required_exts
94
+ self.update_interval = update_interval
93
95
  self.queue = []
94
96
  self.cache = {} # 初始化为空字典,稍后通过 read_cache() 填充
95
97
  self.lock = threading.Lock()
96
98
  self.stop_event = threading.Event()
97
- self.thread = threading.Thread(target=self._process_queue)
98
- self.thread.daemon = True
99
- self.thread.start()
99
+
100
+ # 启动处理队列的线程
101
+ self.queue_thread = threading.Thread(target=self._process_queue)
102
+ self.queue_thread.daemon = True
103
+ self.queue_thread.start()
104
+
105
+ # 启动定时触发更新的线程
106
+ self.update_thread = threading.Thread(target=self._periodic_update)
107
+ self.update_thread.daemon = True
108
+ self.update_thread.start()
109
+
100
110
  self.cache = self.read_cache()
101
111
 
102
112
  def _process_queue(self):
@@ -106,10 +116,25 @@ class AutoCoderRAGAsyncUpdateQueue(BaseCacheManager):
106
116
  except Exception as e:
107
117
  logger.error(f"Error in process_queue: {e}")
108
118
  time.sleep(1) # 避免过于频繁的检查
119
+
120
+ def _periodic_update(self):
121
+ """定时触发文件更新检查"""
122
+ while not self.stop_event.is_set():
123
+ try:
124
+ logger.debug(f"Periodic update triggered (every {self.update_interval}s)")
125
+ # 如果没有被初始化过,不会增量触发
126
+ if not self.cache:
127
+ time.sleep(self.update_interval)
128
+ continue
129
+ self.trigger_update()
130
+ except Exception as e:
131
+ logger.error(f"Error in periodic update: {e}")
132
+ time.sleep(self.update_interval)
109
133
 
110
134
  def stop(self):
111
135
  self.stop_event.set()
112
- self.thread.join()
136
+ self.queue_thread.join()
137
+ self.update_thread.join()
113
138
 
114
139
  def fileinfo_to_tuple(self, file_info: FileInfo) -> Tuple[str, str, float, str]:
115
140
  return (file_info.file_path, file_info.relative_path, file_info.modify_time, file_info.file_md5)
@@ -285,7 +310,7 @@ class AutoCoderRAGAsyncUpdateQueue(BaseCacheManager):
285
310
 
286
311
  def get_cache(self, options: Optional[Dict[str, Any]] = None):
287
312
  self.load_first()
288
- self.trigger_update()
313
+ # 不再在这里触发更新,因为已经有定时线程在处理
289
314
  return self.cache
290
315
 
291
316
  def get_all_files(self) -> List[Tuple[str, str, float]]:
@@ -121,17 +121,8 @@ class RegexProject:
121
121
  if not self.args.enable_rag_search and not self.args.enable_rag_context:
122
122
  return []
123
123
 
124
- if self.args.request_id and not self.args.skip_events:
125
- _ = queue_communicate.send_event(
126
- request_id=self.args.request_id,
127
- event=CommunicateEvent(
128
- event_type=CommunicateEventType.CODE_RAG_SEARCH_START.value,
129
- data=json.dumps({},ensure_ascii=False)
130
- )
131
- )
132
- else:
133
- console = Console()
134
- console.print(f"\n[bold blue]Starting RAG search for:[/bold blue] {self.args.query}")
124
+ console = Console()
125
+ console.print(f"\n[bold blue]Starting RAG search for:[/bold blue] {self.args.query}")
135
126
 
136
127
  from autocoder.rag.rag_entry import RAGFactory
137
128
  rag = RAGFactory.get_rag(self.llm, self.args, "")
@@ -139,17 +130,8 @@ class RegexProject:
139
130
  for doc in docs:
140
131
  doc.tag = "RAG"
141
132
 
142
- if self.args.request_id and not self.args.skip_events:
143
- _ = queue_communicate.send_event(
144
- request_id=self.args.request_id,
145
- event=CommunicateEvent(
146
- event_type=CommunicateEventType.CODE_RAG_SEARCH_END.value,
147
- data=json.dumps({},ensure_ascii=False)
148
- )
149
- )
150
- else:
151
- console = Console()
152
- console.print(f"[bold green]Found {len(docs)} relevant documents[/bold green]")
133
+ console = Console()
134
+ console.print(f"[bold green]Found {len(docs)} relevant documents[/bold green]")
153
135
 
154
136
  return docs
155
137
 
@@ -162,36 +162,18 @@ class SuffixProject:
162
162
  def get_rag_source_codes(self):
163
163
  if not self.args.enable_rag_search and not self.args.enable_rag_context:
164
164
  return []
165
-
166
- if self.args.request_id and not self.args.skip_events:
167
- _ = queue_communicate.send_event(
168
- request_id=self.args.request_id,
169
- event=CommunicateEvent(
170
- event_type=CommunicateEventType.CODE_RAG_SEARCH_START.value,
171
- data=json.dumps({},ensure_ascii=False)
172
- )
173
- )
174
- else:
175
- console = Console()
176
- console.print(f"\n[bold blue]Starting RAG search for:[/bold blue] {self.args.query}")
165
+
166
+ console = Console()
167
+ console.print(f"\n[bold blue]Starting RAG search for:[/bold blue] {self.args.query}")
177
168
 
178
169
  from autocoder.rag.rag_entry import RAGFactory
179
170
  rag = RAGFactory.get_rag(self.llm, self.args, "")
180
171
  docs = rag.search(self.args.query)
181
172
  for doc in docs:
182
173
  doc.tag = "RAG"
183
-
184
- if self.args.request_id and not self.args.skip_events:
185
- _ = queue_communicate.send_event(
186
- request_id=self.args.request_id,
187
- event=CommunicateEvent(
188
- event_type=CommunicateEventType.CODE_RAG_SEARCH_END.value,
189
- data=json.dumps({},ensure_ascii=False)
190
- )
191
- )
192
- else:
193
- console = Console()
194
- console.print(f"[bold green]Found {len(docs)} relevant documents[/bold green]")
174
+
175
+ console = Console()
176
+ console.print(f"[bold green]Found {len(docs)} relevant documents[/bold green]")
195
177
 
196
178
  return docs
197
179
 
@@ -198,17 +198,8 @@ class TSProject:
198
198
  if not self.args.enable_rag_search and not self.args.enable_rag_context:
199
199
  return []
200
200
 
201
- if self.args.request_id and not self.args.skip_events:
202
- _ = queue_communicate.send_event(
203
- request_id=self.args.request_id,
204
- event=CommunicateEvent(
205
- event_type=CommunicateEventType.CODE_RAG_SEARCH_START.value,
206
- data=json.dumps({},ensure_ascii=False)
207
- )
208
- )
209
- else:
210
- console = Console()
211
- console.print(f"\n[bold blue]Starting RAG search for:[/bold blue] {self.args.query}")
201
+ console = Console()
202
+ console.print(f"\n[bold blue]Starting RAG search for:[/bold blue] {self.args.query}")
212
203
 
213
204
  from autocoder.rag.rag_entry import RAGFactory
214
205
  rag = RAGFactory.get_rag(self.llm, self.args, "")
@@ -216,17 +207,9 @@ class TSProject:
216
207
  for doc in docs:
217
208
  doc.tag = "RAG"
218
209
 
219
- if self.args.request_id and not self.args.skip_events:
220
- _ = queue_communicate.send_event(
221
- request_id=self.args.request_id,
222
- event=CommunicateEvent(
223
- event_type=CommunicateEventType.CODE_RAG_SEARCH_END.value,
224
- data=json.dumps({},ensure_ascii=False)
225
- )
226
- )
227
- else:
228
- console = Console()
229
- console.print(f"[bold green]Found {len(docs)} relevant documents[/bold green]")
210
+
211
+ console = Console()
212
+ console.print(f"[bold green]Found {len(docs)} relevant documents[/bold green]")
230
213
 
231
214
  return docs
232
215
 
autocoder/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.329"
1
+ __version__ = "0.1.331"