HALU-HAL commited on
Commit
38cff14
·
2 Parent(s): ac3b287 31942e1

Merge branch 'release/0.4.0'

Browse files
.CodeLumiaignore CHANGED
@@ -173,3 +173,8 @@ LICENSE
173
  *.sqlite
174
  *.jpg
175
  requirements.txt
 
 
 
 
 
 
173
  *.sqlite
174
  *.jpg
175
  requirements.txt
176
+ LICENSE*
177
+ *.zip
178
+ environment.yml
179
+ *.svg
180
+ *.jpeg
.SourceSageignore CHANGED
@@ -29,4 +29,5 @@ build
29
  tmp
30
  .CodeLumiaignore
31
  .ipynb
32
- *.ipynb
 
 
29
  tmp
30
  .CodeLumiaignore
31
  .ipynb
32
+ *.ipynb
33
+ tmp
.gitignore CHANGED
@@ -162,4 +162,4 @@ cython_debug/
162
  SourceSageAssets
163
  tmp
164
 
165
- __CodeLumiai.md
 
162
  SourceSageAssets
163
  tmp
164
 
165
+ __CodeLumiai.md
README.md CHANGED
@@ -18,7 +18,8 @@ license: mit
18
  <h3 align="center">
19
  ~Learn to Code, Step by Step~
20
 
21
- [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/MakiAi/CodeLumia)[![](https://img.shields.io/github/stars/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/last-commit/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/languages/top/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![GitHub Release](https://img.shields.io/github/v/release/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)
 
22
 
23
 
24
  </h3>
@@ -55,18 +56,25 @@ CodeLumiaを使用して、プロジェクトのドキュメンテーション
55
 
56
  ## 更新履歴
57
 
 
 
 
 
 
 
58
  ### [[2024/04/13] CodeLumia v0.3.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.3.0)
59
  - アプリケーションの機能強化とドキュメントデザインの更新
60
  - デモGIFの更新
61
  - `.CodeLumiaignore`のフォーマット更新とリファクタリング
62
  - READMEとSourceSageDocsの大幅な更新
63
  - GIFファイルのGit LFSでの追跡と誤記修正
64
- -
65
  ### [[2024/04/13] CodeLumia v0.2.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.2.0)
66
  - コードのリファクタリングによる可読性と保守性の向上
67
  - リポジトリのURLを入力してファイルツリーとコードを表示する機能追加
68
  - ユーザーインターフェースの改善とドキュメンテーションの拡充
69
- - CI/CDの設定とREADMEファイルの更新---
 
70
 
71
  ### [2024/04/12] CodeLumia v0.1.0
72
  - 初回リリース
 
18
  <h3 align="center">
19
  ~Learn to Code, Step by Step~
20
 
21
+ [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/MakiAi/CodeLumia)[![](https://img.shields.io/github/stars/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/last-commit/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/languages/top/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![GitHub Release](https://img.shields.io/github/v/release/Sunwood-ai-labs/CodeLumia?sort=date&color=red)
22
+ ](https://github.com/Sunwood-ai-labs/CodeLumia)
23
 
24
 
25
  </h3>
 
56
 
57
  ## 更新履歴
58
 
59
+ ### [[2024/04/15] CodeLumia v0.4.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.4.0)
60
+ - プレビュー機能の追加(ファイルツリー、マークダウン、プレーンテキスト)
61
+ - リポジトリのスキャンとマークダウンファイルの生成機能を強化
62
+ - ドキュメンテーションの改善とコードの可読性向上
63
+ - ファイル操作とGit操作のモジュールを改善
64
+
65
  ### [[2024/04/13] CodeLumia v0.3.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.3.0)
66
  - アプリケーションの機能強化とドキュメントデザインの更新
67
  - デモGIFの更新
68
  - `.CodeLumiaignore`のフォーマット更新とリファクタリング
69
  - READMEとSourceSageDocsの大幅な更新
70
  - GIFファイルのGit LFSでの追跡と誤記修正
71
+
72
  ### [[2024/04/13] CodeLumia v0.2.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.2.0)
73
  - コードのリファクタリングによる可読性と保守性の向上
74
  - リポジトリのURLを入力してファイルツリーとコードを表示する機能追加
75
  - ユーザーインターフェースの改善とドキュメンテーションの拡充
76
+ - CI/CDの設定とREADMEファイルの更新
77
+ -
78
 
79
  ### [2024/04/12] CodeLumia v0.1.0
80
  - 初回リリース
app.py CHANGED
@@ -25,32 +25,43 @@ st.markdown("---")
25
  # リポジトリのURLを入力するテキストボックス
26
  repo_url = st.text_input("リポジトリのURL:")
27
  st.markdown("---")
28
- st.markdown("[Full Text](#full-text)")
29
 
30
  # .gitignoreのパターンを編集するサイドバー
31
  st.sidebar.title(".CodeLumiaignore Patterns")
32
- ignore_patterns = st.sidebar.text_area("Enter patterns (one per line):", value="\n".join(ignore_patterns), height=600).split("\n")
 
33
  # 探索の最大深度を入力するテキストボックス
34
- max_depth = st.sidebar.number_input("探索の最大深度:", min_value=1, value=2, step=1)
35
 
 
 
 
36
 
37
- if repo_url:
38
- repo_name = repo_url.split("/")[-1].split(".")[0]
39
- repo_path = clone_repository(repo_url, repo_name)
 
 
 
 
 
 
 
40
 
41
- file_tree = get_file_tree(repo_path, ignore_patterns, max_depth)
42
- markdown_content = create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns, max_depth)
 
 
43
 
44
- # マークダウンファイルを保存
45
- output_name = "/tmp/__CodeLumiai"
46
- save_markdown_file(output_name, markdown_content)
47
 
48
- # Streamlitアプリケーションの構築
49
- st.markdown(markdown_content, unsafe_allow_html=True)
50
 
51
- # ダウンロードリンクの作成
52
- st.markdown(f'<a href="data:text/markdown;base64,{base64.b64encode(markdown_content.encode("utf-8")).decode("utf-8")}" download="{output_name}.md">Download Markdown File</a>', unsafe_allow_html=True)
53
-
54
- st.markdown("---")
55
- st.markdown("# Full Text")
56
- st.code(markdown_content)
 
25
  # リポジトリのURLを入力するテキストボックス
26
  repo_url = st.text_input("リポジトリのURL:")
27
  st.markdown("---")
28
+ # st.markdown("[Full Text](#full-text)")
29
 
30
  # .gitignoreのパターンを編集するサイドバー
31
  st.sidebar.title(".CodeLumiaignore Patterns")
32
+ ignore_patterns = st.sidebar.text_area("Enter patterns (one per line):", value="\n".join(ignore_patterns), height=300).split("\n")
33
+ tmp_dir = st.sidebar.text_input('tmp_dir', '/tmp')
34
  # 探索の最大深度を入力するテキストボックス
35
+ max_depth = st.sidebar.number_input("探索の最大深度:", min_value=1, value=1, step=1)
36
 
37
+ preview_markdown = st.sidebar.checkbox('preview markdown', value=False)
38
+ preview_plaintext = st.sidebar.checkbox('preview plaintext', value=False)
39
+ preview_tree = st.sidebar.checkbox('preview tree', value=True)
40
 
41
+ if st.button("CodeLumia Run ...", type="primary"):
42
+ if repo_url:
43
+ repo_name = repo_url.split("/")[-1].split(".")[0]
44
+ with st.status("Scaning repository...", expanded=True):
45
+ st.write("clone repository...")
46
+ repo_path = clone_repository(repo_url, repo_name, tmp_dir=tmp_dir)
47
+ st.write("get file tree...")
48
+ file_tree = get_file_tree(repo_path, ignore_patterns, max_depth)
49
+ st.write("create markdown content...")
50
+ markdown_content = create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns, max_depth)
51
 
52
+ # マークダウンファイルを保存
53
+ save_markdown_file(repo_name, markdown_content)
54
+ if(preview_tree):
55
+ st.code(f"{file_tree}")
56
 
57
+ # Streamlitアプリケーションの構築
58
+ if(preview_markdown):
59
+ st.markdown(markdown_content, unsafe_allow_html=True)
60
 
61
+ # ダウンロードリンクの作成
62
+ st.markdown(f'<div align="center"><a href="data:text/markdown;base64,{base64.b64encode(markdown_content.encode("utf-8")).decode("utf-8")}" download="{repo_name}.md">Download Markdown File</a></div>', unsafe_allow_html=True)
63
 
64
+ st.markdown("---")
65
+ if(preview_plaintext):
66
+ st.markdown("# Full Text")
67
+ st.code(markdown_content)
 
 
docs/page_front.md CHANGED
@@ -5,7 +5,12 @@
5
  <h3 align="center">
6
  ~Learn to Code, Step by Step~
7
 
8
- [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/OFA-Sys/OFA-Image_Caption)[![](https://img.shields.io/github/stars/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/last-commit/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/languages/top/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)
 
 
 
 
 
9
 
10
  </h3>
11
 
 
5
  <h3 align="center">
6
  ~Learn to Code, Step by Step~
7
 
8
+ [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/OFA-Sys/OFA-Image_Caption)
9
+ [![](https://img.shields.io/github/stars/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)
10
+ [![](https://img.shields.io/github/last-commit/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)
11
+ [![](https://img.shields.io/github/languages/top/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)
12
+ [![GitHub Release](https://img.shields.io/github/v/release/Sunwood-ai-labs/CodeLumia?sort=date&color=red)](https://github.com/Sunwood-ai-labs/CodeLumia)
13
+ [![GitHub Tag](https://img.shields.io/github/v/tag/Sunwood-ai-labs/CodeLumia?color=orange)](https://github.com/Sunwood-ai-labs/CodeLumia)
14
 
15
  </h3>
16
 
modules/file_operations.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import fnmatch
3
 
@@ -7,12 +8,17 @@ def get_file_tree(repo_path, ignore_patterns, max_depth):
7
  # .gitignoreに一致するディレクトリを無視
8
  dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
9
 
10
- level = root.replace(repo_path, "").count(os.sep)
 
 
 
 
11
  if level > max_depth:
12
  continue
13
 
14
  indent = " " * 4 * (level)
15
  file_tree += f"{indent}{os.path.basename(root)}/\n"
 
16
  subindent = " " * 4 * (level + 1)
17
  for f in files:
18
  # .gitignoreに一致するファイルを無視
@@ -26,7 +32,7 @@ def process_files(repo_path, ignore_patterns, max_depth):
26
  # .gitignoreに一致するディレクトリを無視
27
  dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
28
 
29
- level = root.replace(repo_path, "").count(os.sep)
30
  if level > max_depth:
31
  continue
32
 
@@ -37,4 +43,19 @@ def process_files(repo_path, ignore_patterns, max_depth):
37
  with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
38
  content = f.read()
39
  file_contents.append((file_path.replace(f'{repo_path}/', ''), content))
40
- return file_contents
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
  import os
3
  import fnmatch
4
 
 
8
  # .gitignoreに一致するディレクトリを無視
9
  dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
10
 
11
+ level = root.replace(repo_path, "/").count(os.sep)
12
+ # print(f"------------------------- max_depth : {max_depth}")
13
+ # print(f"dirs1:{dirs}")
14
+ # print(f"level:{level}")
15
+ # print(f"files:{files}")
16
  if level > max_depth:
17
  continue
18
 
19
  indent = " " * 4 * (level)
20
  file_tree += f"{indent}{os.path.basename(root)}/\n"
21
+
22
  subindent = " " * 4 * (level + 1)
23
  for f in files:
24
  # .gitignoreに一致するファイルを無視
 
32
  # .gitignoreに一致するディレクトリを無視
33
  dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
34
 
35
+ level = root.replace(repo_path, "/").count(os.sep)
36
  if level > max_depth:
37
  continue
38
 
 
43
  with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
44
  content = f.read()
45
  file_contents.append((file_path.replace(f'{repo_path}/', ''), content))
46
+ return file_contents
47
+
48
+ if __name__ == "__main__":
49
+
50
+ repo_path = "tmp/DeepSeek-Math"
51
+ # .gitignoreのパターンを読み込む
52
+ ignore_patterns = []
53
+ if os.path.exists(".CodeLumiaignore"):
54
+ with open(".CodeLumiaignore", "r") as f:
55
+ for line in f:
56
+ line = line.strip()
57
+ if line and not line.startswith("#"):
58
+ ignore_patterns.append(line)
59
+ max_depth = 1
60
+ file_tree = get_file_tree(repo_path, ignore_patterns, max_depth)
61
+ print(file_tree)
modules/git_operations.py CHANGED
@@ -2,21 +2,32 @@ import os
2
  import shutil
3
  import time
4
 
5
- def clone_repository(repo_url, repo_name):
 
 
 
 
 
6
  # tmpフォルダを削除
7
- # if os.path.exists("/tmp"):
8
- # shutil.rmtree("/tmp")
9
 
10
  # tmpフォルダを作成
11
- os.makedirs("/tmp", exist_ok=True)
12
 
13
  # リポジトリのクローン
14
- repo_path = f"/tmp/{repo_name}"
15
  if os.path.exists(repo_path):
16
  shutil.rmtree(repo_path)
17
- os.system(f"git clone {repo_url} {repo_path}")
18
 
19
  # 一時的な遅延を追加
20
  time.sleep(1)
21
 
22
- return repo_path
 
 
 
 
 
 
 
2
  import shutil
3
  import time
4
 
5
+ import os
6
+ import shutil
7
+ from git import Repo
8
+ import time
9
+
10
+ def clone_repository(repo_url, repo_name, tmp_dir="./tmp"):
11
  # tmpフォルダを削除
12
+ # if os.path.exists(tmp_dir):
13
+ # shutil.rmtree(tmp_dir)
14
 
15
  # tmpフォルダを作成
16
+ os.makedirs(tmp_dir, exist_ok=True)
17
 
18
  # リポジトリのクローン
19
+ repo_path = os.path.join(tmp_dir, repo_name)
20
  if os.path.exists(repo_path):
21
  shutil.rmtree(repo_path)
22
+ Repo.clone_from(repo_url, repo_path)
23
 
24
  # 一時的な遅延を追加
25
  time.sleep(1)
26
 
27
+ return repo_path
28
+
29
+ if __name__ == "__main__":
30
+ repo_url = "https://github.com/deepseek-ai/DeepSeek-Math"
31
+ repo_name = repo_url.split("/")[-1].split(".")[0]
32
+ tmp_dir = "./tmp" # 必要に応じてtmpディレクトリを指定
33
+ clone_repository(repo_url, repo_name, tmp_dir)