auto-coder-web 0.1.13__py3-none-any.whl → 0.1.14__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.
@@ -10,6 +10,7 @@ import sys
10
10
  import io
11
11
  import subprocess
12
12
  import byzerllm
13
+ import hashlib
13
14
  from contextlib import contextmanager
14
15
  from byzerllm.utils.langutil import asyncfy_with_semaphore
15
16
  from autocoder.common import AutoCoderArgs
@@ -29,6 +30,7 @@ from autocoder.utils.queue_communicate import (
29
30
  CommunicateEventType,
30
31
  )
31
32
  from autocoder.utils.log_capture import LogCapture
33
+ from autocoder.common import git_utils
32
34
  from threading import Thread
33
35
  from byzerllm.utils import format_str_jinja2
34
36
  from autocoder.index.symbols_utils import (
@@ -315,6 +317,80 @@ class AutoCoderRunner:
315
317
  self.save_memory()
316
318
  return {"message": f"Deleted configuration: {key}"}
317
319
 
320
+ def convert_yaml_to_config(self, yaml_file: str):
321
+ """Convert YAML file to AutoCoderArgs configuration"""
322
+ from autocoder.auto_coder import AutoCoderArgs, load_include_files, Template
323
+ args = AutoCoderArgs()
324
+ with open(yaml_file, "r") as f:
325
+ config = yaml.safe_load(f)
326
+ config = load_include_files(config, yaml_file)
327
+ for key, value in config.items():
328
+ if key != "file": # 排除 --file 参数本身
329
+ # key: ENV {{VARIABLE_NAME}}
330
+ if isinstance(value, str) and value.startswith("ENV"):
331
+ template = Template(value.removeprefix("ENV").strip())
332
+ value = template.render(os.environ)
333
+ setattr(args, key, value)
334
+ return args
335
+
336
+ def commit(self):
337
+ """Commit changes using git"""
338
+ try:
339
+ def prepare_commit_yaml():
340
+ auto_coder_main(["next", "chat_action"])
341
+
342
+ prepare_commit_yaml()
343
+
344
+ latest_yaml_file = get_last_yaml_file("actions")
345
+
346
+ if latest_yaml_file:
347
+ try:
348
+ execute_file = os.path.join("actions", latest_yaml_file)
349
+ yaml_config = {
350
+ "include_file": ["./base/base.yml"],
351
+ "auto_merge": self.memory.get("conf", {}).get("auto_merge", "editblock"),
352
+ "human_as_model": self.memory.get("conf", {}).get("human_as_model", "false") == "true",
353
+ "skip_build_index": self.memory.get("conf", {}).get("skip_build_index", "true") == "true",
354
+ "skip_confirm": self.memory.get("conf", {}).get("skip_confirm", "true") == "true",
355
+ "silence": self.memory.get("conf", {}).get("silence", "true") == "true",
356
+ "include_project_structure": self.memory.get("conf", {}).get("include_project_structure", "true") == "true",
357
+ }
358
+
359
+ conf = self.memory.get("conf", {})
360
+ for key, value in conf.items():
361
+ converted_value = self.convert_config_value(key, value)
362
+ if converted_value is not None:
363
+ yaml_config[key] = converted_value
364
+
365
+ yaml_config["urls"] = self.memory["current_files"]["files"] + self.get_llm_friendly_package_docs(
366
+ return_paths=True
367
+ )
368
+ args = self.convert_yaml_to_config(execute_file)
369
+ llm = byzerllm.ByzerLLM.from_default_model(args.code_model or args.model)
370
+ uncommitted_changes = git_utils.get_uncommitted_changes(".")
371
+ commit_message = git_utils.generate_commit_message.with_llm(
372
+ llm).run(uncommitted_changes)
373
+
374
+ yaml_config["query"] = commit_message
375
+ yaml_content = self.convert_yaml_config_to_str(yaml_config=yaml_config)
376
+ with open(execute_file, "w") as f:
377
+ f.write(yaml_content)
378
+
379
+ file_content = open(execute_file).read()
380
+ md5 = hashlib.md5(file_content.encode('utf-8')).hexdigest()
381
+ file_name = os.path.basename(execute_file)
382
+ commit_result = git_utils.commit_changes(".", f"auto_coder_{file_name}_{md5}")
383
+
384
+ return {"status": True, "message": "Changes committed successfully", "commit_info": commit_result}
385
+ except Exception as e:
386
+ if execute_file:
387
+ os.remove(execute_file)
388
+ return {"status": False, "message": f"Failed to commit: {str(e)}"}
389
+ else:
390
+ return {"status": False, "message": "No changes to commit"}
391
+ except Exception as e:
392
+ return {"status": False, "message": f"Failed to commit: {str(e)}"}
393
+
318
394
  def get_config(self) -> Dict[str, str]:
319
395
  """Get current configuration
320
396
 
auto_coder_web/proxy.py CHANGED
@@ -585,6 +585,14 @@ class ProxyServer:
585
585
  request_id, request.event, request.response)
586
586
  return {"message": "success"}
587
587
 
588
+ @self.app.post("/api/commit")
589
+ async def commit():
590
+ try:
591
+ result = self.auto_coder_runner.commit()
592
+ return result
593
+ except Exception as e:
594
+ raise HTTPException(status_code=500, detail=str(e))
595
+
588
596
  @self.app.get("/api/output/{request_id}")
589
597
  async def get_terminal_logs(request_id: str):
590
598
  return self.auto_coder_runner.get_logs(request_id)
auto_coder_web/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.13"
1
+ __version__ = "0.1.14"
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "/static/css/main.10e5dd19.css",
4
- "main.js": "/static/js/main.74620d2e.js",
4
+ "main.js": "/static/js/main.34adf43b.js",
5
5
  "static/js/453.d855a71b.chunk.js": "/static/js/453.d855a71b.chunk.js",
6
6
  "index.html": "/index.html",
7
7
  "main.10e5dd19.css.map": "/static/css/main.10e5dd19.css.map",
8
- "main.74620d2e.js.map": "/static/js/main.74620d2e.js.map",
8
+ "main.34adf43b.js.map": "/static/js/main.34adf43b.js.map",
9
9
  "453.d855a71b.chunk.js.map": "/static/js/453.d855a71b.chunk.js.map"
10
10
  },
11
11
  "entrypoints": [
12
12
  "static/css/main.10e5dd19.css",
13
- "static/js/main.74620d2e.js"
13
+ "static/js/main.34adf43b.js"
14
14
  ]
15
15
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.74620d2e.js"></script><link href="/static/css/main.10e5dd19.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.34adf43b.js"></script><link href="/static/css/main.10e5dd19.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>