This commit is contained in:
Keep Creating Online
2025-01-13 15:24:15 -05:00
parent 01dc6375b8
commit 26a8ea4a67
11 changed files with 1494 additions and 316 deletions

View File

@@ -43,7 +43,7 @@ git clone <repository-url>
cd <repository-directory> cd <repository-directory>
``` ```
*Replace `<repository-url>` with the actual URL of your repository and `<repository-directory>` with the cloned directory name.* _Replace `<repository-url>` with the actual URL of your repository and `<repository-directory>` with the cloned directory name._
### Step 2: Set Up Python Virtual Environment (Optional but Recommended) ### Step 2: Set Up Python Virtual Environment (Optional but Recommended)
@@ -58,18 +58,14 @@ Using a virtual environment isolates your project's dependencies, preventing con
2. **Activate the Virtual Environment**: 2. **Activate the Virtual Environment**:
- **macOS and Linux**: - **macOS and Linux**:
```bash ```bash
source venv/bin/activate source venv/bin/activate
``` ```
- **Windows (Command Prompt)**: - **Windows (Command Prompt)**:
```bash ```bash
venv\Scripts\activate.bat venv\Scripts\activate
```
- **Windows (PowerShell)**:
```bash
venv\Scripts\Activate.ps1
``` ```
### Step 3: Install Required Packages ### Step 3: Install Required Packages
@@ -90,7 +86,7 @@ Customize the `config.yaml` file to control which directories and files are incl
- **Exclude Directories**: Modify the `exclude_dirs` section to exclude any directories you don't want in the context. - **Exclude Directories**: Modify the `exclude_dirs` section to exclude any directories you don't want in the context.
- **Important Files**: List the key files under the `important_files` section that should be included with their content. - **Important Files**: List the key files under the `important_files` section that should be included with their content.
*Refer to the [Customization](#customization) section for detailed instructions.* _Refer to the [Customization](#customization) section for detailed instructions._
### Step 5: Running the Script ### Step 5: Running the Script
@@ -99,20 +95,20 @@ Execute the script to generate the `repo-context.txt` file.
- **Unix-like Systems (macOS, Linux)**: - **Unix-like Systems (macOS, Linux)**:
```bash ```bash
chmod +x generate_repo-context.py # Make the script executable (optional) chmod +x generate_repo_context.py # Make the script executable (optional)
./generate_repo-context.py ./generate_repo_context.py
``` ```
Or simply: Or simply:
```bash ```bash
python3 generate_repo-context.py python3 generate_repo_context.py
``` ```
- **Windows**: - **Windows**:
```bash ```bash
python generate_repo-context.py python generate_repo_context.py
``` ```
## Output ## Output
@@ -137,19 +133,19 @@ Specify directories that should be omitted from the directory tree and file incl
```yaml ```yaml
exclude_dirs: exclude_dirs:
- node_modules # Node.js dependencies - node_modules # Node.js dependencies
- venv # Python virtual environment - venv # Python virtual environment
- __pycache__ # Python bytecode cache - __pycache__ # Python bytecode cache
- build # Build output directories - build # Build output directories
- dist # Distribution packages - dist # Distribution packages
- .git # Git repository metadata - .git # Git repository metadata
- .github # GitHub workflows and configurations - .github # GitHub workflows and configurations
- .vscode # Visual Studio Code settings - .vscode # Visual Studio Code settings
- logs # Log files - logs # Log files
- tmp # Temporary files and directories - tmp # Temporary files and directories
``` ```
*Add or remove directories as needed.* _Add or remove directories as needed._
#### 2. **Important Files** #### 2. **Important Files**
@@ -157,19 +153,19 @@ List the crucial files whose content should be included in the context file. Pat
```yaml ```yaml
important_files: important_files:
- main.py # Entry point of the application - main.py # Entry point of the application
- app.py # Application configuration - app.py # Application configuration
- config/settings.py # Configuration settings - config/settings.py # Configuration settings
- utils/helpers.py # Utility helper functions - utils/helpers.py # Utility helper functions
- models/user.py # User model definitions - models/user.py # User model definitions
- controllers/auth_controller.py# Authentication controller - controllers/auth_controller.py# Authentication controller
- services/email_service.py # Email service integration - services/email_service.py # Email service integration
- routes/api_routes.py # API route definitions - routes/api_routes.py # API route definitions
- database/db_connection.py # Database connection setup - database/db_connection.py # Database connection setup
- tests/test_main.py # Main application tests - tests/test_main.py # Main application tests
``` ```
*Update the list based on your project's structure.* _Update the list based on your project's structure._
#### 3. **Additional Configuration (Optional)** #### 3. **Additional Configuration (Optional)**
@@ -200,11 +196,11 @@ custom_sections:
section_title: "License" section_title: "License"
``` ```
*Customize these sections as per your project requirements.* _Customize these sections as per your project requirements._
## Additional Notes ## Additional Notes
- **Static Files**: Ensure that `overview.txt`, `important_info.txt`, and `to-do_list.txt` are present in the same directory as `generate_repo-context.py`. - **Static Files**: Ensure that `overview.txt`, `important_info.txt`, and `to-do_list.txt` are present in the same directory as `generate_repo_context.py`.
- **Syntax Highlighting**: The script supports syntax highlighting for common file types like `.py`, `.js`, `.json`, etc. To add more file types, update the `LANGUAGE_MAP` in the script. - **Syntax Highlighting**: The script supports syntax highlighting for common file types like `.py`, `.js`, `.json`, etc. To add more file types, update the `LANGUAGE_MAP` in the script.
- **Source Directory**: By default, the script assumes your main source code is in the `src/` directory. If your project uses a different structure, update the `start_path` in the script or make it configurable. - **Source Directory**: By default, the script assumes your main source code is in the `src/` directory. If your project uses a different structure, update the `start_path` in the script or make it configurable.

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
""" """
Script Name: generate_repo-context.py Script Name: generate_repo_context.py
Description: Generates a context file (`repo-context.txt`) for AI coding assistants. Description: Generates a context file (`repo-context.txt`) for AI coding assistants.
Includes an overview, important information, a directory tree with exclusions, Includes an overview, important information, a directory tree with exclusions,
content of important files with syntax highlighting, and a to-do list. content of important files with syntax highlighting, and a to-do list.
@@ -23,8 +23,8 @@ Usage:
5. Place `overview.txt`, `important_info.txt`, and `to-do_list.txt` in the script directory. 5. Place `overview.txt`, `important_info.txt`, and `to-do_list.txt` in the script directory.
6. Run the script: 6. Run the script:
./generate_repo-context.py # Unix-like systems ./generate_repo_context.py # Unix-like systems
python generate_repo-context.py # Windows python generate_repo_context.py # Windows
The script will create `repo-context.txt` with the specified structure. The script will create `repo-context.txt` with the specified structure.
""" """

View File

@@ -1,138 +1,170 @@
```python
import streamlit as st import streamlit as st
from pathlib import Path from pathlib import Path
import subprocess
import yaml
from generate_repo_context import main as generate_context_main
import shutil
import os import os
import tempfile import yaml
from tkinter import Tk
from tkinter.filedialog import askdirectory
import subprocess
import sys # Add this import
# Configuration # Configuration
CONFIG_FILE = "config.yaml" CONFIG_FILE = "config.yaml"
OUTPUT_FILE = "repo-context.txt" OUTPUT_FILE = "repo-context.txt"
STATIC_FILES_DIR = Path(__file__).parent / "static_files"
GLOBAL_FILES_DIR = Path(__file__).parent / "global_files" GLOBAL_FILES_DIR = Path(__file__).parent / "global_files"
REPOS_DIR = Path(__file__).parent / "repositories" SAVED_CONFIG_FILE = Path(__file__).parent / "saved_config.yaml"
SCRIPT_DIR = Path(__file__).parent
# Default exclusions
DEFAULT_EXCLUDED_DIRS = ["node_modules", "venv", "__pycache__", ".git", "dist", "build", "logs", ".idea", ".vscode"]
DEFAULT_EXCLUDED_FILES = ["repo-context.txt"]
# Ensure necessary directories exist # Ensure necessary directories exist
REPOS_DIR.mkdir(exist_ok=True)
GLOBAL_FILES_DIR.mkdir(exist_ok=True) GLOBAL_FILES_DIR.mkdir(exist_ok=True)
STATIC_FILES_DIR.mkdir(exist_ok=True)
# Load configuration # Load saved configuration
def load_saved_config():
if SAVED_CONFIG_FILE.exists():
try:
with open(SAVED_CONFIG_FILE, "r") as f:
return yaml.safe_load(f)
except yaml.YAMLError:
return {}
return {}
# Save configuration
def save_config(config):
with open(SAVED_CONFIG_FILE, "w") as f:
yaml.dump(config, f)
# Load application configuration
def load_config(): def load_config():
config_path = Path(__file__).parent / CONFIG_FILE config_path = SCRIPT_DIR / CONFIG_FILE
if not config_path.exists(): if not config_path.exists():
st.error(f"Configuration file {CONFIG_FILE} not found.") st.error(f"Configuration file {CONFIG_FILE} not found.")
st.stop() st.stop()
try: try:
with open(config_path, 'r') as f: with open(config_path, "r") as f:
config = yaml.safe_load(f) return yaml.safe_load(f)
return config
except yaml.YAMLError as e: except yaml.YAMLError as e:
st.error(f"Error parsing configuration file: {e}") st.error(f"Error parsing configuration file: {e}")
st.stop() st.stop()
config = load_config() app_config = load_config()
exclude_dirs = config.get("exclude_dirs", []) saved_config = load_saved_config()
important_files = config.get("important_files", [])
custom_sections = config.get("custom_sections", []) exclude_dirs = app_config.get("exclude_dirs", DEFAULT_EXCLUDED_DIRS)
# Streamlit App # Streamlit App
st.title("Repository Context Generator") st.title("Repository Context Generator")
st.sidebar.header("Clone Repository") # Folder Selection
repo_url = st.sidebar.text_input("Repository URL", "") st.sidebar.header("Select a Folder")
repo_name = st.sidebar.text_input("Repository Name", "") if st.sidebar.button("Choose Folder"):
if st.sidebar.button("Clone Repository"): root = Tk()
if repo_url and repo_name: root.withdraw() # Hide the main window
repo_path = REPOS_DIR / repo_name root.attributes("-topmost", True) # Bring the dialog to the front
if repo_path.exists(): folder_path = askdirectory() # Open folder selection dialog
st.sidebar.warning("Repository already cloned.") root.destroy()
else:
try: if folder_path:
subprocess.run(['git', 'clone', repo_url, str(repo_path)], check=True) st.session_state["selected_repo_path"] = folder_path
st.sidebar.success("Repository cloned successfully.") st.sidebar.success(f"Selected folder: {folder_path}")
except subprocess.CalledProcessError as e:
st.sidebar.error(f"Error cloning repository: {e}")
else: else:
st.sidebar.error("Please provide both Repository URL and Name.") st.sidebar.error("No folder selected.")
st.header("Select Repository") # Load previously selected folder
available_repos = [d.name for d in REPOS_DIR.iterdir() if d.is_dir()] selected_repo_path = st.session_state.get("selected_repo_path", None)
selected_repo = st.selectbox("Choose a repository", available_repos)
if selected_repo: if selected_repo_path:
repo_path = REPOS_DIR / selected_repo st.header(f"Selected Repository: {selected_repo_path}")
repo_path = Path(selected_repo_path)
st.subheader("File Filtering") st.subheader("File Filtering")
# Retrieve all files in the repository # Retrieve directories and files in the repository
file_list = [] all_directories = []
all_files = []
for root, dirs, files in os.walk(repo_path): for root, dirs, files in os.walk(repo_path):
rel_root = Path(root).relative_to(repo_path) rel_root = Path(root).relative_to(repo_path)
dirs[:] = [d for d in dirs if d not in DEFAULT_EXCLUDED_DIRS]
for d in dirs: for d in dirs:
file_list.append(str(rel_root / d) + "/") all_directories.append(str(rel_root / d) + "/")
for f in files: for f in files:
file_list.append(str(rel_root / f)) all_files.append(str(rel_root / f))
# File inclusion and exclusion # Directory selection for Directory Tree
include_prompt = st.multiselect("Include in Prompt", options=file_list) selected_directories = st.multiselect(
exclude_prompt = st.multiselect("Exclude from Prompt", options=file_list) "Include in Directory Tree", options=all_directories, default=saved_config.get("selected_directories", [])
include_tree = st.multiselect("Include in Directory Tree", options=file_list) )
exclude_tree = st.multiselect("Exclude from Directory Tree", options=file_list)
st.subheader("Global Files") # Automatically include files within selected directories unless explicitly excluded
st.write("Files in the `global_files/` directory are included in every context.") included_files = [
f for f in all_files if any(str(Path(f).parent) in d for d in selected_directories)
]
# Display current global files # File exclusions
global_files = [f.name for f in GLOBAL_FILES_DIR.iterdir() if f.is_file()] excluded_files = st.multiselect(
st.write("### Current Global Files:") "Exclude Specific Files",
for gf in global_files: options=[f for f in included_files if f not in DEFAULT_EXCLUDED_FILES],
st.write(f"- {gf}") default=[
f for f in saved_config.get("excluded_files", [])
if f in included_files and f not in DEFAULT_EXCLUDED_FILES
],
)
# Upload new global files st.write("### Final Included Files")
uploaded_file = st.file_uploader("Add Global File", type=["txt", "xml", "md"]) st.write([f for f in included_files if f not in excluded_files])
if uploaded_file:
save_path = GLOBAL_FILES_DIR / uploaded_file.name
with open(save_path, "wb") as f:
f.write(uploaded_file.getbuffer())
st.success(f"Global file `{uploaded_file.name}` added.")
# Generate Context File st.subheader("Generate Context File")
if st.button("Generate Context File"): if st.button("Generate Context File"):
try: try:
# Create a temporary directory to store the output # Update config.yaml based on user selections
with tempfile.TemporaryDirectory() as tmpdirname: updated_config = {
temp_output = Path(tmpdirname) / OUTPUT_FILE "source_directory": str(repo_path),
"exclude_dirs": DEFAULT_EXCLUDED_DIRS,
"important_files": [f for f in included_files if f not in excluded_files],
"custom_sections": app_config.get("custom_sections", []),
}
# Prepare parameters # Write updated config.yaml
generate_context_main( with open(SCRIPT_DIR / CONFIG_FILE, "w") as f:
config_path=Path(__file__).parent / CONFIG_FILE, yaml.dump(updated_config, f)
source_dir=config.get("source_directory", "src"),
start_path=repo_path,
exclude_dirs=exclude_dirs,
important_files=important_files,
custom_sections=custom_sections,
include_prompt=include_prompt,
exclude_prompt=exclude_prompt,
include_tree=include_tree,
exclude_tree=exclude_tree,
global_files_dir=GLOBAL_FILES_DIR,
output_file=temp_output
)
# Read the generated context file # Run the script as a subprocess
with open(temp_output, 'r', encoding='utf-8') as f: result = subprocess.run(
[sys.executable, str(SCRIPT_DIR / "generate_repo_context.py")],
cwd=SCRIPT_DIR,
check=True,
capture_output=True,
text=True,
)
st.success("Context file generated successfully.")
st.write(f"Script output:\n{result.stdout}")
# Check if the file was created
generated_file = SCRIPT_DIR / OUTPUT_FILE
if generated_file.exists():
with open(generated_file, "r", encoding="utf-8") as f:
context_content = f.read() context_content = f.read()
# Provide download link
st.download_button( st.download_button(
label="Download repo-context.txt", label="Download repo-context.txt",
data=context_content, data=context_content,
file_name='repo-context.txt', file_name="repo-context.txt",
mime='text/plain' mime="text/plain",
) )
st.success("Context file generated successfully.") else:
except Exception as e: st.error("Context file not found after script execution.")
except subprocess.CalledProcessError as e:
st.error(f"Error generating context file: {e}") st.error(f"Error generating context file: {e}")
st.error(f"Script output:\n{e.stdout}\n\n{e.stderr}")
# Save configuration for future use
if st.button("Save Configuration"):
save_config({
"selected_directories": selected_directories,
"excluded_files": excluded_files,
})
st.success("Configuration saved successfully.")
else:
st.write("Please select a folder to begin.")

View File

@@ -1,39 +1,28 @@
# Configuration for Repository Context Generator
# Primary source directory containing the main codebase.
# Update this if your main code is not in 'src/'.
source_directory: src
# List of directories to exclude from the directory tree and file inclusions.
exclude_dirs:
- node_modules # Node.js dependencies
- venv # Python virtual environment
- __pycache__ # Python bytecode cache
- build # Build output directories
- dist # Distribution packages
- .git # Git repository metadata
- .github # GitHub workflows and configurations
- .vscode # Visual Studio Code settings
- logs # Log files
- tmp # Temporary files and directories
# List of important files to include in the context.
# Paths should be relative to the 'source_directory' specified above.
important_files:
- main.py # Entry point of the application
- app.py # Application configuration
- config/settings.py # Configuration settings
- utils/helpers.py # Utility helper functions
- models/user.py # User model definitions
- controllers/auth_controller.py # Authentication controller
- services/email_service.py # Email service integration
- routes/api_routes.py # API route definitions
- database/db_connection.py # Database connection setup
- tests/test_main.py # Main application tests
# Custom sections to include additional information.
custom_sections: custom_sections:
- file: changelog.txt - file: changelog.txt
section_title: "Changelog" section_title: Changelog
- file: LICENSE.txt - file: LICENSE.txt
section_title: "License" section_title: License
exclude_dirs:
- node_modules
- venv
- __pycache__
- .git
- dist
- build
- logs
- .idea
- .vscode
important_files:
- src\app.py
- src\config.yaml
- src\generate_repo_context.py
- src\index.html
- src\README.md
- src\requirements.txt
- src\saved_config.yaml
- src\global_files\format_response.md
- src\static_files\important_info.txt
- src\static_files\overview.txt
- src\static_files\to-do_list.txt
source_directory: C:\Users\user\Documents\GitHub\Context-Tool

View File

@@ -1,19 +1,38 @@
```python
#!/usr/bin/env python3 #!/usr/bin/env python3
""" """
Script Name: generate_repo_context.py Script Name: generate_repo_context.py
Description: Generates a context file (`repo-context.txt`) for AI coding assistants. Description: Generates a context file (`repo-context.txt`) for AI coding assistants.
Includes an overview, important information, a directory tree with exclusions, Includes an overview, important information, a directory tree with exclusions,
content of important files with syntax highlighting, a to-do list, and global files. content of important files with syntax highlighting, and a to-do list.
Appends an XML section based on specified rules.
Usage:
1. Ensure you have Python 3.7 or higher installed.
2. (Optional) Set up a Python virtual environment:
python -m venv venv
source venv/bin/activate # On Unix or MacOS
venv\Scripts\activate.bat # On Windows (Command Prompt)
venv\Scripts\Activate.ps1 # On Windows (PowerShell)
3. Install the required Python packages:
pip install -r requirements.txt
4. Configure `config.yaml` as needed.
5. Place `overview.txt`, `important_info.txt`, and `to-do_list.txt` in the `static_files` directory.
6. Run the script:
./generate_repo_context.py # Unix-like systems
python generate_repo_context.py # Windows
The script will create `repo-context.txt` with the specified structure.
""" """
import os import os
import sys import sys
import yaml import yaml
from pathlib import Path from pathlib import Path
import mimetypes
import logging import logging
from typing import List, Dict from typing import List, Dict
from datetime import datetime from datetime import datetime
@@ -203,7 +222,7 @@ def write_custom_sections(custom_sections: List[Dict], script_dir: Path, output_
for section in custom_sections: for section in custom_sections:
file_name = section.get('file') file_name = section.get('file')
section_title = section.get('section_title', 'Custom Section') section_title = section.get('section_title', 'Custom Section')
file_path = script_dir / file_name file_path = script_dir / "static_files" / file_name
write_static_file(file_path, output_file, section_title) write_static_file(file_path, output_file, section_title)
def append_xml_section(output_file: Path): def append_xml_section(output_file: Path):
@@ -296,7 +315,7 @@ def main():
# Write custom sections if any # Write custom sections if any
if custom_sections: if custom_sections:
write_custom_sections(custom_sections, script_dir / "static_files", output_file) write_custom_sections(custom_sections, script_dir, output_file)
# Write to-do list # Write to-do list
todo_path = script_dir / "static_files" / "to-do_list.txt" todo_path = script_dir / "static_files" / "to-do_list.txt"
@@ -309,147 +328,3 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
main() main()
```
---
## **app.py**
```python
import streamlit as st
from pathlib import Path
import subprocess
import yaml
from generate_repo_context import main as generate_context_main
import shutil
import os
import tempfile
# Configuration
CONFIG_FILE = "config.yaml"
OUTPUT_FILE = "repo-context.txt"
STATIC_FILES_DIR = Path(__file__).parent / "static_files"
GLOBAL_FILES_DIR = Path(__file__).parent / "global_files"
REPOS_DIR = Path(__file__).parent / "repositories"
# Ensure necessary directories exist
REPOS_DIR.mkdir(exist_ok=True)
GLOBAL_FILES_DIR.mkdir(exist_ok=True)
STATIC_FILES_DIR.mkdir(exist_ok=True)
# Load configuration
def load_config():
config_path = Path(__file__).parent / CONFIG_FILE
if not config_path.exists():
st.error(f"Configuration file {CONFIG_FILE} not found.")
st.stop()
try:
with open(config_path, 'r') as f:
config = yaml.safe_load(f)
return config
except yaml.YAMLError as e:
st.error(f"Error parsing configuration file: {e}")
st.stop()
config = load_config()
exclude_dirs = config.get("exclude_dirs", [])
important_files = config.get("important_files", [])
custom_sections = config.get("custom_sections", [])
# Streamlit App
st.title("Repository Context Generator")
st.sidebar.header("Clone Repository")
repo_url = st.sidebar.text_input("Repository URL", "")
repo_name = st.sidebar.text_input("Repository Name", "")
if st.sidebar.button("Clone Repository"):
if repo_url and repo_name:
repo_path = REPOS_DIR / repo_name
if repo_path.exists():
st.sidebar.warning("Repository already cloned.")
else:
try:
subprocess.run(['git', 'clone', repo_url, str(repo_path)], check=True)
st.sidebar.success("Repository cloned successfully.")
except subprocess.CalledProcessError as e:
st.sidebar.error(f"Error cloning repository: {e}")
else:
st.sidebar.error("Please provide both Repository URL and Name.")
st.header("Select Repository")
available_repos = [d.name for d in REPOS_DIR.iterdir() if d.is_dir()]
selected_repo = st.selectbox("Choose a repository", available_repos)
if selected_repo:
repo_path = REPOS_DIR / selected_repo
st.subheader("File Filtering")
# Retrieve all files in the repository
file_list = []
for root, dirs, files in os.walk(repo_path):
rel_root = Path(root).relative_to(repo_path)
for d in dirs:
file_list.append(str(rel_root / d) + "/")
for f in files:
file_list.append(str(rel_root / f))
# File inclusion and exclusion
include_prompt = st.multiselect("Include in Prompt", options=file_list)
exclude_prompt = st.multiselect("Exclude from Prompt", options=file_list)
include_tree = st.multiselect("Include in Directory Tree", options=file_list)
exclude_tree = st.multiselect("Exclude from Directory Tree", options=file_list)
st.subheader("Global Files")
st.write("Files in the `global_files/` directory are included in every context.")
# Display current global files
global_files = [f.name for f in GLOBAL_FILES_DIR.iterdir() if f.is_file()]
st.write("### Current Global Files:")
for gf in global_files:
st.write(f"- {gf}")
# Upload new global files
uploaded_file = st.file_uploader("Add Global File", type=["txt", "xml", "md"])
if uploaded_file:
save_path = GLOBAL_FILES_DIR / uploaded_file.name
with open(save_path, "wb") as f:
f.write(uploaded_file.getbuffer())
st.success(f"Global file `{uploaded_file.name}` added.")
# Generate Context File
if st.button("Generate Context File"):
try:
# Create a temporary directory to store the output
with tempfile.TemporaryDirectory() as tmpdirname:
temp_output = Path(tmpdirname) / OUTPUT_FILE
# Prepare parameters
generate_context_main(
config_path=Path(__file__).parent / CONFIG_FILE,
source_dir=config.get("source_directory", "src"),
start_path=repo_path,
exclude_dirs=exclude_dirs,
important_files=important_files,
custom_sections=custom_sections,
include_prompt=include_prompt,
exclude_prompt=exclude_prompt,
include_tree=include_tree,
exclude_tree=exclude_tree,
global_files_dir=GLOBAL_FILES_DIR,
output_file=temp_output
)
# Read the generated context file
with open(temp_output, 'r', encoding='utf-8') as f:
context_content = f.read()
# Provide download link
st.download_button(
label="Download repo-context.txt",
data=context_content,
file_name='repo-context.txt',
mime='text/plain'
)
st.success("Context file generated successfully.")
except Exception as e:
st.error(f"Error generating context file: {e}")

View File

@@ -0,0 +1,39 @@
Present a complete plan to solve the problem and implement it in the codebase.
At the end of your response, respond with the following XML section (if applicable).
XML Section:
- Do not get lazy. Always output the full code in the XML section.
- Enclose this entire section in a markdown codeblock
- Include all of the changed files
- Specify each file operation with CREATE, UPDATE, or DELETE
- For CREATE or UPDATE operations, include the full file code
- Include the full file path (relative to the project directory, good: app/page.tsx, bad: /Users/mckaywrigley/Desktop/projects/new-chat-template/app/page.tsx)
- Enclose the code with ![CDATA[__CODE HERE__]]
- Use the following XML structure:
```xml
<code_changes>
<changed_files>
<file>
<file_operation>__FILE OPERATION HERE__</file_operation>
<file_path>__FILE PATH HERE__</file_path>
<file_code><![CDATA[
__FULL FILE CODE HERE__
]]></file_code>
</file>
__REMAINING FILES HERE__
</changed_files>
</code_changes>
```
Other rules:
- DO NOT remove <ai_context> sections. These are to provide you additional context about each file.
- If you create a file, add an <ai_context> comment section at the top of the file.
- If you update a file make sure its <ai_context> stays up-to-date
- DO NOT add comments related to your edits
- DO NOT remove my existing comments
We may go back and forth a few times. If we do, remember to continue to output the entirety of the code in an XML section (if applicable).
Take all the time you need.

134
src/index.html Normal file
View File

@@ -0,0 +1,134 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="Generate context files for repositories with ease. Streamline AI coding assistant interactions."
/>
<title>Repository Context Generator</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 0;
background: #f4f4f9;
color: #333;
}
header {
background: #6200ea;
color: white;
padding: 20px 0;
text-align: center;
}
header h1 {
margin: 0;
font-size: 2.5rem;
}
header p {
margin: 0;
font-size: 1.2rem;
}
.container {
max-width: 900px;
margin: 20px auto;
padding: 0 20px;
}
.cta {
background: #fff;
padding: 20px;
margin: 20px 0;
border: 1px solid #ddd;
border-radius: 8px;
text-align: center;
}
.cta h2 {
margin: 0 0 10px;
font-size: 1.8rem;
}
.cta p {
margin: 0 0 20px;
}
.cta a {
display: inline-block;
text-decoration: none;
background: #6200ea;
color: white;
padding: 10px 20px;
border-radius: 4px;
font-size: 1.2rem;
}
.cta a:hover {
background: #4500b3;
}
footer {
background: #333;
color: white;
text-align: center;
padding: 10px 0;
margin-top: 20px;
}
footer p {
margin: 0;
font-size: 0.9rem;
}
footer a {
color: #6200ea;
text-decoration: none;
}
footer a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<header>
<h1>Repository Context Generator</h1>
<p>Your tool for creating comprehensive repository context files</p>
</header>
<div class="container">
<section class="cta">
<h2>Get Started</h2>
<p>
Generate a context file for your repository, including key details,
directory structure, and more.
</p>
<a href="http://localhost:8501" target="_blank">Open the Application</a>
</section>
<section>
<h2>How It Works</h2>
<p>
This tool simplifies interactions with AI coding assistants by
generating a structured context file. You can customize directory
exclusions, include important files, and add global documentation.
</p>
<ul>
<li>Clone repositories easily via the app.</li>
<li>Customize context settings to suit your project.</li>
<li>Download the generated context file directly from the app.</li>
</ul>
</section>
<section>
<h2>Features</h2>
<ul>
<li>Supports multiple repositories.</li>
<li>Includes static documentation sections.</li>
<li>Customizable exclusions and global file inclusions.</li>
<li>Syntax-highlighted file contents.</li>
</ul>
</section>
</div>
<footer>
<p>
&copy; 2025 Repository Context Generator. Built with
<a href="https://streamlit.io" target="_blank">Streamlit</a>.
</p>
</footer>
</body>
</html>

1103
src/repo-context.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
Flask
Flask-Cors
GitPython
PyYAML
streamlit

5
src/saved_config.yaml Normal file
View File

@@ -0,0 +1,5 @@
excluded_files: []
selected_directories:
- src/
- src\global_files/
- src\static_files/