auto-coder 0.1.45__tar.gz → 0.1.46__tar.gz
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.
- {auto-coder-0.1.45 → auto-coder-0.1.46}/PKG-INFO +4 -4
- {auto-coder-0.1.45 → auto-coder-0.1.46}/README.md +1 -1
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/auto_coder.egg-info/PKG-INFO +4 -4
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/auto_coder.egg-info/SOURCES.txt +2 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/auto_coder.egg-info/requires.txt +2 -2
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/auto_coder.py +14 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/command_args.py +3 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/audio.py +18 -11
- auto-coder-0.1.46/src/autocoder/common/command_templates.py +77 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/git_utils.py +17 -7
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/lang.py +6 -2
- auto-coder-0.1.46/src/autocoder/version.py +1 -0
- auto-coder-0.1.46/tests/test_init_command.py +21 -0
- auto-coder-0.1.45/src/autocoder/version.py +0 -1
- {auto-coder-0.1.45 → auto-coder-0.1.46}/setup.cfg +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/setup.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/auto_coder.egg-info/dependency_links.txt +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/auto_coder.egg-info/entry_points.txt +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/auto_coder.egg-info/top_level.txt +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/agent/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/agent/coder.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/JupyterClient.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/ShellClient.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/cleaner.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/code_auto_execute.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/code_auto_generate.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/code_auto_merge.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/const.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/image_to_page.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/llm_rerank.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/screenshots.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/search.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/common/types.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/db/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/db/store.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/dispacher/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/dispacher/actions/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/dispacher/actions/action.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/dispacher/actions/copilot.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/index/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/index/for_command.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/index/index.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/pyproject/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/rag/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/rag/api_server.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/rag/llm_wrapper.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/rag/simple_rag.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/suffixproject/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/tsproject/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/utils/__init__.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/utils/llm_client_interceptors.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/utils/print_table.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/src/autocoder/utils/rest.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/tests/test_code_auto_merge.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/tests/test_image_to_page.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/tests/test_llm_rerank.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/tests/test_shell_client.py +0 -0
- {auto-coder-0.1.45 → auto-coder-0.1.46}/tests/test_simple_rag.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: auto-coder
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.46
|
|
4
4
|
Summary: AutoCoder: AutoCoder
|
|
5
5
|
Author: allwefantasy
|
|
6
6
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
@@ -23,7 +23,7 @@ Requires-Dist: paramiko
|
|
|
23
23
|
Requires-Dist: einops
|
|
24
24
|
Requires-Dist: tqdm
|
|
25
25
|
Requires-Dist: loguru
|
|
26
|
-
Requires-Dist: pyjava
|
|
26
|
+
Requires-Dist: pyjava>=0.6.16
|
|
27
27
|
Requires-Dist: tiktoken
|
|
28
28
|
Requires-Dist: transformers_stream_generator
|
|
29
29
|
Requires-Dist: optimum
|
|
@@ -42,7 +42,7 @@ Requires-Dist: sqlmodel
|
|
|
42
42
|
Requires-Dist: wudao
|
|
43
43
|
Requires-Dist: SwissArmyTransformer
|
|
44
44
|
Requires-Dist: jieba
|
|
45
|
-
Requires-Dist: byzerllm>=0.1.
|
|
45
|
+
Requires-Dist: byzerllm>=0.1.76
|
|
46
46
|
Requires-Dist: GitPython
|
|
47
47
|
Requires-Dist: openai>=1.14.3
|
|
48
48
|
Requires-Dist: anthropic
|
|
@@ -69,7 +69,7 @@ Auto-Coder (powered by Byzer-LLM)
|
|
|
69
69
|
|
|
70
70
|
*Latest News* 🔥
|
|
71
71
|
|
|
72
|
-
- [2024/04] Release Auto-Coder 0.1.
|
|
72
|
+
- [2024/04] Release Auto-Coder 0.1.46
|
|
73
73
|
- [2024/03] Release Auto-Coder 0.1.25
|
|
74
74
|
- [2024/03] Release Auto-Coder 0.1.24
|
|
75
75
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: auto-coder
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.46
|
|
4
4
|
Summary: AutoCoder: AutoCoder
|
|
5
5
|
Author: allwefantasy
|
|
6
6
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
@@ -23,7 +23,7 @@ Requires-Dist: paramiko
|
|
|
23
23
|
Requires-Dist: einops
|
|
24
24
|
Requires-Dist: tqdm
|
|
25
25
|
Requires-Dist: loguru
|
|
26
|
-
Requires-Dist: pyjava
|
|
26
|
+
Requires-Dist: pyjava>=0.6.16
|
|
27
27
|
Requires-Dist: tiktoken
|
|
28
28
|
Requires-Dist: transformers_stream_generator
|
|
29
29
|
Requires-Dist: optimum
|
|
@@ -42,7 +42,7 @@ Requires-Dist: sqlmodel
|
|
|
42
42
|
Requires-Dist: wudao
|
|
43
43
|
Requires-Dist: SwissArmyTransformer
|
|
44
44
|
Requires-Dist: jieba
|
|
45
|
-
Requires-Dist: byzerllm>=0.1.
|
|
45
|
+
Requires-Dist: byzerllm>=0.1.76
|
|
46
46
|
Requires-Dist: GitPython
|
|
47
47
|
Requires-Dist: openai>=1.14.3
|
|
48
48
|
Requires-Dist: anthropic
|
|
@@ -69,7 +69,7 @@ Auto-Coder (powered by Byzer-LLM)
|
|
|
69
69
|
|
|
70
70
|
*Latest News* 🔥
|
|
71
71
|
|
|
72
|
-
- [2024/04] Release Auto-Coder 0.1.
|
|
72
|
+
- [2024/04] Release Auto-Coder 0.1.46
|
|
73
73
|
- [2024/03] Release Auto-Coder 0.1.25
|
|
74
74
|
- [2024/03] Release Auto-Coder 0.1.24
|
|
75
75
|
|
|
@@ -21,6 +21,7 @@ src/autocoder/common/cleaner.py
|
|
|
21
21
|
src/autocoder/common/code_auto_execute.py
|
|
22
22
|
src/autocoder/common/code_auto_generate.py
|
|
23
23
|
src/autocoder/common/code_auto_merge.py
|
|
24
|
+
src/autocoder/common/command_templates.py
|
|
24
25
|
src/autocoder/common/const.py
|
|
25
26
|
src/autocoder/common/git_utils.py
|
|
26
27
|
src/autocoder/common/image_to_page.py
|
|
@@ -50,6 +51,7 @@ src/autocoder/utils/print_table.py
|
|
|
50
51
|
src/autocoder/utils/rest.py
|
|
51
52
|
tests/test_code_auto_merge.py
|
|
52
53
|
tests/test_image_to_page.py
|
|
54
|
+
tests/test_init_command.py
|
|
53
55
|
tests/test_llm_rerank.py
|
|
54
56
|
tests/test_shell_client.py
|
|
55
57
|
tests/test_simple_rag.py
|
|
@@ -14,7 +14,7 @@ paramiko
|
|
|
14
14
|
einops
|
|
15
15
|
tqdm
|
|
16
16
|
loguru
|
|
17
|
-
pyjava
|
|
17
|
+
pyjava>=0.6.16
|
|
18
18
|
tiktoken
|
|
19
19
|
transformers_stream_generator
|
|
20
20
|
optimum
|
|
@@ -33,7 +33,7 @@ sqlmodel
|
|
|
33
33
|
wudao
|
|
34
34
|
SwissArmyTransformer
|
|
35
35
|
jieba
|
|
36
|
-
byzerllm>=0.1.
|
|
36
|
+
byzerllm>=0.1.76
|
|
37
37
|
GitPython
|
|
38
38
|
openai>=1.14.3
|
|
39
39
|
anthropic
|
|
@@ -21,6 +21,7 @@ from byzerllm.apps.command import get_latest_byzer_retrieval_lib
|
|
|
21
21
|
from autocoder.command_args import parse_args
|
|
22
22
|
from autocoder.rag.api_server import serve,ServerArgs
|
|
23
23
|
from loguru import logger
|
|
24
|
+
from autocoder.common.command_templates import init_command_template
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
def main():
|
|
@@ -67,6 +68,19 @@ def main():
|
|
|
67
68
|
tc = store.get_token_counter()
|
|
68
69
|
print_table([tc])
|
|
69
70
|
return
|
|
71
|
+
|
|
72
|
+
if raw_args.command == "init":
|
|
73
|
+
os.makedirs(os.path.join(args.source_dir, "actions"), exist_ok=True)
|
|
74
|
+
os.makedirs(os.path.join(args.source_dir, ".auto-coder"), exist_ok=True)
|
|
75
|
+
|
|
76
|
+
init_file_path = os.path.join(args.source_dir, "actions", "101_current_work.yml")
|
|
77
|
+
with open(init_file_path, "w") as f:
|
|
78
|
+
f.write(init_command_template())
|
|
79
|
+
|
|
80
|
+
git_utils.init(os.path.abspath(args.source_dir))
|
|
81
|
+
print(f'''Successfully initialized auto-coder project in {os.path.abspath(args.source_dir)}.''')
|
|
82
|
+
|
|
83
|
+
return
|
|
70
84
|
|
|
71
85
|
if args.model:
|
|
72
86
|
|
|
@@ -143,6 +143,9 @@ def parse_args() -> AutoCoderArgs:
|
|
|
143
143
|
doc_serve_parse.add_argument("--ssl_certfile", default="", help="")
|
|
144
144
|
doc_serve_parse.add_argument("--response_role", default="assistant", help="")
|
|
145
145
|
|
|
146
|
+
init_parser = subparsers.add_parser("init", help=desc["init_desc"])
|
|
147
|
+
init_parser.add_argument("--source_dir", required=True, help=desc["init_dir"])
|
|
148
|
+
|
|
146
149
|
args = parser.parse_args()
|
|
147
150
|
|
|
148
151
|
return AutoCoderArgs(**vars(args)),args
|
|
@@ -8,6 +8,7 @@ import json
|
|
|
8
8
|
import base64
|
|
9
9
|
from concurrent.futures import ThreadPoolExecutor
|
|
10
10
|
import shutil
|
|
11
|
+
import tempfile
|
|
11
12
|
|
|
12
13
|
def play_wave(filename:str):
|
|
13
14
|
try:
|
|
@@ -26,6 +27,7 @@ class PlayStreamAudioFromText:
|
|
|
26
27
|
self.llm = byzerllm.ByzerLLM()
|
|
27
28
|
self.llm.setup_default_model_name(tts_model_name)
|
|
28
29
|
self.wav_num = -1
|
|
30
|
+
self.tempdir = tempfile.mkdtemp()
|
|
29
31
|
|
|
30
32
|
def text_to_speech(self, text, file_path):
|
|
31
33
|
print(f"Converting text to speech: {text}")
|
|
@@ -41,15 +43,14 @@ class PlayStreamAudioFromText:
|
|
|
41
43
|
with open(temp_file_path, "wb") as f:
|
|
42
44
|
f.write(base64.b64decode(t[0].output))
|
|
43
45
|
shutil.move(temp_file_path, file_path)
|
|
44
|
-
print(f"Converted successfully: {file_path}")
|
|
45
|
-
self.q.task_done()
|
|
46
|
+
print(f"Converted successfully: {file_path}")
|
|
46
47
|
|
|
47
48
|
def play_audio_files(self):
|
|
48
49
|
idx = 1
|
|
49
50
|
while True:
|
|
50
51
|
if self.wav_num == -2:
|
|
51
52
|
break
|
|
52
|
-
file_path = f"
|
|
53
|
+
file_path = os.path.join(self.tempdir, f"{idx:03d}.wav")
|
|
53
54
|
if not os.path.exists(file_path):
|
|
54
55
|
time.sleep(0.1) # Reduce CPU usage
|
|
55
56
|
continue
|
|
@@ -61,19 +62,22 @@ class PlayStreamAudioFromText:
|
|
|
61
62
|
def process_texts(self):
|
|
62
63
|
idx = 1
|
|
63
64
|
s = ""
|
|
64
|
-
|
|
65
|
+
done = False
|
|
66
|
+
while not done:
|
|
65
67
|
text = self.q.get()
|
|
66
68
|
if text is None:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if
|
|
69
|
+
done = True
|
|
70
|
+
if len(s)==0:
|
|
71
|
+
break
|
|
72
|
+
if text:
|
|
73
|
+
s += text
|
|
74
|
+
if not done and len(s) < 10:
|
|
71
75
|
continue
|
|
72
76
|
sentences = s.split("。")
|
|
73
77
|
for sentence in sentences:
|
|
74
78
|
if len(sentence) == 0:
|
|
75
79
|
continue
|
|
76
|
-
file_path = f"
|
|
80
|
+
file_path = os.path.join(self.tempdir, f"{idx:03d}.wav")
|
|
77
81
|
print(f"Processing: {sentence} to {file_path}")
|
|
78
82
|
self.pool.submit(self.text_to_speech, sentence, file_path)
|
|
79
83
|
idx += 1
|
|
@@ -81,12 +85,15 @@ class PlayStreamAudioFromText:
|
|
|
81
85
|
self.wav_num = idx - 1
|
|
82
86
|
|
|
83
87
|
def run(self, text_generator):
|
|
84
|
-
os.makedirs("/tmp/wavs", exist_ok=True)
|
|
85
88
|
threading.Thread(target=self.play_audio_files).start()
|
|
86
|
-
threading.Thread(target=self.process_texts).
|
|
89
|
+
threading.Thread(target=self.process_texts).start()
|
|
87
90
|
for text in text_generator:
|
|
88
91
|
self.q.put(text)
|
|
89
92
|
self.q.put(None)
|
|
90
93
|
while self.wav_num != -2:
|
|
91
94
|
time.sleep(0.1)
|
|
95
|
+
shutil.rmtree(self.tempdir)
|
|
92
96
|
|
|
97
|
+
# byzerllm.connect_cluster()
|
|
98
|
+
# player = PlayStreamAudioFromText()
|
|
99
|
+
# player.run(["hello everyone", "i'am william", "auto coder is a great tool", "i hope you like it", "goodbye"])
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import byzerllm
|
|
2
|
+
|
|
3
|
+
@byzerllm.prompt()
|
|
4
|
+
def init_command_template():
|
|
5
|
+
'''
|
|
6
|
+
## Location of your project
|
|
7
|
+
## 你项目的路径
|
|
8
|
+
source_dir: /Users/allwefantasy/projects/xxxx
|
|
9
|
+
target_file: /Users/allwefantasy/projects/xxxx/output.txt
|
|
10
|
+
|
|
11
|
+
## The type of your project. py,ts or you can use the suffix e.g. .java .scala .go
|
|
12
|
+
## If you use the suffix, you can combind multiple types with comma e.g. .java,.scala
|
|
13
|
+
## 你项目的类型,py,ts或者你可以使用后缀,例如.java .scala .go
|
|
14
|
+
## 如果你使用后缀,你可以使用逗号来组合多个类型,例如.java,.scala
|
|
15
|
+
project_type: py
|
|
16
|
+
|
|
17
|
+
## The model you want to drive AutoCoder to run
|
|
18
|
+
model: gpt3_5_chat
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Enable the index building which can help you find the related files by your query
|
|
22
|
+
## 启用索引构建,可以帮助您通过查询找到相关文件
|
|
23
|
+
skip_build_index: false
|
|
24
|
+
## The model to build index for the project (Optional)
|
|
25
|
+
index_model: haiku_chat
|
|
26
|
+
|
|
27
|
+
## the filter level to find the related files
|
|
28
|
+
## 0: only find the files with the file name
|
|
29
|
+
## 1: find the files with the file name and the symbols in the file
|
|
30
|
+
## 2. find the related files reffered by the files in 0 and 1
|
|
31
|
+
## 0 is recommended for the first time
|
|
32
|
+
## 用于查找相关文件的过滤级别
|
|
33
|
+
## 0: 仅查找文件名
|
|
34
|
+
## 1: 查找文件名和文件中的符号
|
|
35
|
+
## 2. 查找0和1中的文件引用的相关文件
|
|
36
|
+
## 第一次建议使用0
|
|
37
|
+
index_filter_level: 0
|
|
38
|
+
index_model_max_input_length: 30000
|
|
39
|
+
|
|
40
|
+
## enable RAG context
|
|
41
|
+
## 启用RAG上下文
|
|
42
|
+
# enable_rag_context: true
|
|
43
|
+
## The model to build index for the project
|
|
44
|
+
## 用于为项目构建索引的模型
|
|
45
|
+
# emb_model: gpt_emb
|
|
46
|
+
|
|
47
|
+
## The model will generate the code for you
|
|
48
|
+
## 模型将为您生成代码
|
|
49
|
+
execute: true
|
|
50
|
+
|
|
51
|
+
## If you want to generate multiple files, you can enable this option to generate the code in multiple rounds
|
|
52
|
+
## to avoid exceeding the maximum token limit of the model
|
|
53
|
+
## 如果您想生成多个文件,可以启用此选项,以便在多个回合中生成代码
|
|
54
|
+
## 以避免超过模型的最大令牌限制
|
|
55
|
+
enable_multi_round_generate: false
|
|
56
|
+
|
|
57
|
+
## AutoCoder will merge the generated code into your project
|
|
58
|
+
## AutoCoder将合并生成的代码到您的项目中
|
|
59
|
+
auto_merge: true
|
|
60
|
+
|
|
61
|
+
## AutoCoder will ask you to deliver the content to the Web Model,
|
|
62
|
+
## then paste the answer back to the terminal
|
|
63
|
+
## AutoCoder将要求您将内容传递给Web模型,然后将答案粘贴回终端
|
|
64
|
+
human_as_model: true
|
|
65
|
+
|
|
66
|
+
## What you want the model to do
|
|
67
|
+
## 你想让模型做什么
|
|
68
|
+
query: |
|
|
69
|
+
YOUR QUERY HERE
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## You can execute this file with the following command
|
|
73
|
+
## And check the output in the target file
|
|
74
|
+
## 您可以使用以下命令执行此文件
|
|
75
|
+
## 并在目标文件中检查输出
|
|
76
|
+
## auto-coder --file 101_current_work.yml
|
|
77
|
+
'''
|
|
@@ -3,6 +3,21 @@ from git import Repo, GitCommandError
|
|
|
3
3
|
from loguru import logger
|
|
4
4
|
from typing import List
|
|
5
5
|
|
|
6
|
+
def init(repo_path: str) -> bool:
|
|
7
|
+
if not os.path.exists(repo_path):
|
|
8
|
+
os.makedirs(repo_path)
|
|
9
|
+
|
|
10
|
+
if os.path.exists(os.path.join(repo_path, '.git')):
|
|
11
|
+
logger.warning(f"The directory {repo_path} is already a Git repository. Skipping initialization.")
|
|
12
|
+
return False
|
|
13
|
+
try:
|
|
14
|
+
repo = Repo.init(repo_path)
|
|
15
|
+
logger.info(f"Initialized new Git repository at {repo_path}")
|
|
16
|
+
return True
|
|
17
|
+
except GitCommandError as e:
|
|
18
|
+
logger.error(f"Error during Git initialization: {e}")
|
|
19
|
+
return False
|
|
20
|
+
|
|
6
21
|
def get_repo(repo_path: str) -> Repo:
|
|
7
22
|
repo = Repo(repo_path)
|
|
8
23
|
return repo
|
|
@@ -12,30 +27,26 @@ def commit_changes(repo_path: str, message: str) -> bool:
|
|
|
12
27
|
if repo is None:
|
|
13
28
|
logger.error("Repository is not initialized.")
|
|
14
29
|
return False
|
|
15
|
-
|
|
16
30
|
try:
|
|
17
31
|
repo.git.add(all=True)
|
|
18
32
|
commit = repo.index.commit(message)
|
|
19
33
|
logger.info(f"Committed changes with message: {message}")
|
|
20
34
|
logger.info(f"Commit hash: {commit.hexsha}")
|
|
21
|
-
|
|
22
35
|
# Check if there is a parent commit to compare against
|
|
23
36
|
if commit.parents:
|
|
24
37
|
changed_files = repo.git.diff(commit.parents[0].hexsha, commit.hexsha, name_only=True).split('\n')
|
|
25
38
|
logger.info(f"Changed files: {changed_files}")
|
|
26
|
-
|
|
27
39
|
for file in changed_files:
|
|
28
40
|
if file.strip():
|
|
29
41
|
diff = repo.git.diff(commit.parents[0].hexsha, commit.hexsha, file)
|
|
30
42
|
logger.info(f"Diff for {file}:\n{diff}")
|
|
31
43
|
else:
|
|
32
44
|
logger.info("This is the initial commit, no parent to compare against.")
|
|
33
|
-
|
|
34
45
|
return True
|
|
35
46
|
except GitCommandError as e:
|
|
36
47
|
logger.error(f"Error during commit operation: {e}")
|
|
37
48
|
return False
|
|
38
|
-
|
|
49
|
+
|
|
39
50
|
def get_current_branch(repo_path: str) -> str:
|
|
40
51
|
repo = get_repo(repo_path)
|
|
41
52
|
if repo is None:
|
|
@@ -47,8 +58,7 @@ def revert_changes(repo_path: str, message: str) -> bool:
|
|
|
47
58
|
repo = get_repo(repo_path)
|
|
48
59
|
if repo is None:
|
|
49
60
|
return False
|
|
50
|
-
|
|
51
|
-
commit = repo.git.log('--all', f'--grep={message}', '--format=%H', '-n', '1')
|
|
61
|
+
commit = repo.git.log('--all', f'--grep={message}', '--format=%H', '-n', '1')
|
|
52
62
|
if commit:
|
|
53
63
|
repo.git.revert(commit, no_edit=True)
|
|
54
64
|
logger.info(f"Reverted changes with commit message: {message}")
|
|
@@ -45,7 +45,9 @@ lang_desc = {
|
|
|
45
45
|
"index_model_max_length":"The maximum length of the generated code by the index model. Default is 0, which means using the value of model_max_length",
|
|
46
46
|
"index_model_max_input_length":"The maximum length of the input to the index model. Default is 0, which means using the value of model_max_input_length",
|
|
47
47
|
"index_model_anti_quota_limit":"Time to wait in seconds after each API request for the index model. Default is 0, which means using the value of anti_quota_limit",
|
|
48
|
-
"doc_build_parse_required_exts":"The required file extensions for doc build. Default is empty string"
|
|
48
|
+
"doc_build_parse_required_exts":"The required file extensions for doc build. Default is empty string",
|
|
49
|
+
"init_desc": "Initialize a new auto-coder project directory",
|
|
50
|
+
"init_dir": "The directory to initialize the auto-coder project in"
|
|
49
51
|
},
|
|
50
52
|
"zh": {
|
|
51
53
|
"parser_desc": "自动为Python脚本实现缺失的方法。",
|
|
@@ -93,6 +95,8 @@ lang_desc = {
|
|
|
93
95
|
"index_model_max_length":"索引模型生成代码的最大长度。默认为0,表示使用model_max_length的值",
|
|
94
96
|
"index_model_max_input_length":"索引模型的最大输入长度。默认为0,表示使用model_max_input_length的值",
|
|
95
97
|
"index_model_anti_quota_limit":"每次索引模型API请求后等待的秒数。默认为0,表示使用anti_quota_limit的值",
|
|
96
|
-
"doc_build_parse_required_exts":"doc构建所需的文件扩展名。默认为空字符串"
|
|
98
|
+
"doc_build_parse_required_exts":"doc构建所需的文件扩展名。默认为空字符串",
|
|
99
|
+
"init_desc": "初始化一个新的auto-coder项目目录",
|
|
100
|
+
"init_dir": "初始化auto-coder项目的目录"
|
|
97
101
|
}
|
|
98
102
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.46"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
from autocoder.auto_coder import main
|
|
4
|
+
from autocoder.command_args import parse_args
|
|
5
|
+
|
|
6
|
+
def test_init_command():
|
|
7
|
+
# Create a temporary directory for testing
|
|
8
|
+
test_dir = "temp_test_dir"
|
|
9
|
+
os.makedirs(test_dir, exist_ok=True)
|
|
10
|
+
|
|
11
|
+
# Call the init command with the test directory
|
|
12
|
+
args = f"init --dir {test_dir}"
|
|
13
|
+
main(parse_args(args.split())[0])
|
|
14
|
+
|
|
15
|
+
# Check if the required directories and files are created
|
|
16
|
+
assert os.path.exists(os.path.join(test_dir, "actions"))
|
|
17
|
+
assert os.path.exists(os.path.join(test_dir, ".auto-coder"))
|
|
18
|
+
assert os.path.exists(os.path.join(test_dir, "actions", "101_current_work.yml"))
|
|
19
|
+
|
|
20
|
+
# Clean up the temporary test directory
|
|
21
|
+
shutil.rmtree(test_dir)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.45"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|