ucalyptus commited on
Commit
c4a5b3f
Β·
1 Parent(s): 244cf39
Files changed (4) hide show
  1. README.md +31 -8
  2. app.py +138 -0
  3. packages.txt +2 -0
  4. requirements.txt +3 -0
README.md CHANGED
@@ -1,14 +1,37 @@
1
  ---
2
- title: Repotxt
3
- emoji: 🐒
4
- colorFrom: purple
5
- colorTo: purple
6
  sdk: gradio
7
- sdk_version: 5.9.0
8
  app_file: app.py
9
  pinned: false
10
- license: apache-2.0
11
- short_description: repo to txt
12
  ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Repomix Web Interface
3
+ emoji: πŸ“¦
4
+ colorFrom: blue
5
+ colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 4.12.0
8
  app_file: app.py
9
  pinned: false
 
 
10
  ---
11
 
12
+ # Repomix Web Interface
13
+
14
+ A web interface for [Repomix](https://github.com/yamadashy/repomix) that helps you pack your GitHub repositories into a single, AI-friendly file. Perfect for use with Large Language Models (LLMs) like Claude, ChatGPT, and Gemini.
15
+
16
+ ## Features
17
+
18
+ - Pack any public GitHub repository
19
+ - Support for different output styles (plain, XML, markdown)
20
+ - Security checking for sensitive information
21
+ - Options to remove comments and empty lines
22
+ - Support for specific branches, tags, or commits
23
+
24
+ ## Usage
25
+
26
+ 1. Enter a GitHub repository URL (e.g., `https://github.com/user/repo`) or use the shorthand format (e.g., `user/repo`)
27
+ 2. Optionally specify a branch, tag, or commit
28
+ 3. Choose your preferred output style
29
+ 4. Configure additional options (comment removal, empty lines removal, security check)
30
+ 5. Click "Pack Repository" to generate the output
31
+
32
+ The packed repository will be formatted in a way that's optimized for AI tools, making it easier to analyze your codebase or get assistance with your projects.
33
+
34
+ ## About Repomix
35
+
36
+ Repomix (formerly Repopack) is a powerful tool that packs your entire repository into a single, AI-friendly file. For more information, visit the [Repomix GitHub repository](https://github.com/yamadashy/repomix).
37
+
app.py ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ import tempfile
4
+ import os
5
+ import shutil
6
+ from urllib.parse import urlparse
7
+
8
+ def validate_repo_url(url):
9
+ """Validate if the input is a valid repository URL or GitHub shorthand."""
10
+ if not url:
11
+ return False
12
+
13
+ # Check if it's a GitHub shorthand (user/repo)
14
+ if '/' in url and len(url.split('/')) == 2:
15
+ return True
16
+
17
+ try:
18
+ result = urlparse(url)
19
+ return all([result.scheme, result.netloc])
20
+ except:
21
+ return False
22
+
23
+ def pack_repository(repo_url, branch, output_style, remove_comments, remove_empty_lines, security_check):
24
+ """Pack a repository using Repomix and return the output."""
25
+ try:
26
+ # Create temporary directory
27
+ with tempfile.TemporaryDirectory() as temp_dir:
28
+ # Prepare command
29
+ cmd = ["npx", "repomix"]
30
+
31
+ # Add remote repository options
32
+ cmd.extend(["--remote", repo_url])
33
+
34
+ if branch:
35
+ cmd.extend(["--remote-branch", branch])
36
+
37
+ # Add style option
38
+ cmd.extend(["--style", output_style])
39
+
40
+ # Add other options
41
+ if remove_comments:
42
+ cmd.append("--remove-comments")
43
+ if remove_empty_lines:
44
+ cmd.append("--remove-empty-lines")
45
+ if not security_check:
46
+ cmd.append("--no-security-check")
47
+
48
+ # Set output path
49
+ output_file = os.path.join(temp_dir, "repomix-output.txt")
50
+ cmd.extend(["-o", output_file])
51
+
52
+ # Execute Repomix
53
+ result = subprocess.run(cmd,
54
+ capture_output=True,
55
+ text=True,
56
+ cwd=temp_dir)
57
+
58
+ if result.returncode != 0:
59
+ return f"Error: {result.stderr}"
60
+
61
+ # Read the output file
62
+ with open(output_file, 'r') as f:
63
+ content = f.read()
64
+
65
+ return content
66
+
67
+ except Exception as e:
68
+ return f"Error: {str(e)}"
69
+
70
+ # Create the Gradio interface
71
+ with gr.Blocks(title="Repomix Web Interface", theme=gr.themes.Soft()) as demo:
72
+ gr.Markdown("""
73
+ # πŸ“¦ Repomix Web Interface
74
+ Pack your GitHub repository into a single, AI-friendly file. Perfect for use with LLMs like Claude, ChatGPT, and Gemini.
75
+
76
+ Enter a GitHub repository URL (e.g., `https://github.com/user/repo`) or shorthand format (e.g., `user/repo`).
77
+ """)
78
+
79
+ with gr.Row():
80
+ with gr.Column():
81
+ repo_url = gr.Textbox(
82
+ label="Repository URL or GitHub Shorthand",
83
+ placeholder="e.g., https://github.com/user/repo or user/repo"
84
+ )
85
+ branch = gr.Textbox(
86
+ label="Branch/Tag/Commit (optional)",
87
+ placeholder="e.g., main, master, v1.0.0"
88
+ )
89
+
90
+ with gr.Row():
91
+ output_style = gr.Radio(
92
+ choices=["plain", "xml", "markdown"],
93
+ value="plain",
94
+ label="Output Style"
95
+ )
96
+
97
+ with gr.Row():
98
+ remove_comments = gr.Checkbox(
99
+ label="Remove Comments",
100
+ value=False
101
+ )
102
+ remove_empty_lines = gr.Checkbox(
103
+ label="Remove Empty Lines",
104
+ value=False
105
+ )
106
+ security_check = gr.Checkbox(
107
+ label="Enable Security Check",
108
+ value=True
109
+ )
110
+
111
+ pack_button = gr.Button("Pack Repository", variant="primary")
112
+
113
+ output_text = gr.TextArea(
114
+ label="Output",
115
+ placeholder="Packed repository content will appear here...",
116
+ lines=20
117
+ )
118
+
119
+ # Handle the pack button click
120
+ pack_button.click(
121
+ fn=pack_repository,
122
+ inputs=[repo_url, branch, output_style, remove_comments, remove_empty_lines, security_check],
123
+ outputs=output_text
124
+ )
125
+
126
+ gr.Markdown("""
127
+ ### πŸ“ Notes
128
+ - The packed output is optimized for use with AI models
129
+ - Security check helps identify potentially sensitive information
130
+ - Different output styles (plain, XML, markdown) are available for different use cases
131
+
132
+ ### πŸ”— Links
133
+ - [Repomix GitHub Repository](https://github.com/yamadashy/repomix)
134
+ - [Documentation](https://github.com/yamadashy/repomix#-quick-start)
135
+ """)
136
+
137
+ if __name__ == "__main__":
138
+ demo.launch()
packages.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ nodejs
2
+ npm
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio>=4.0.0
2
+ urllib3
3
+ tempfile