A tool that generates an XML file containing information about your project's structure and contents. This is useful for providing context to LLMs.
- Generates a file tree visualization of your project
- Creates XML output with selected file contents
- Configurable via TOML file
- Preserves your selection of which files to include
- Handles special characters and XML escaping
# Clone the repository
git clone [your-repo-url]
# Install dependencies
npm install
The tool uses a .project-context.toml
configuration file in your target project directory. If it doesn't exist, it will be created automatically with default settings.
- Add these aliases to your
~/.bashrc
or~/.zshrc
:
alias project-context='function _project_context() { npm run --prefix /absolute/path/to/project-context-generator start "$(pwd)"; }; _project_context'
alias project-context-reset='function _project_context_reset() { npm run --prefix /absolute/path/to/project-context-generator start:reset "$(pwd)"; }; _project_context_reset'
- Replace
/absolute/path/to/project-context-generator
with the actual path where you installed this tool - Source your rc file (
source ~/.bashrc
orsource ~/.zshrc
) or restart your terminal
Then you can run from any project directory:
project-context # Update preserving uncommented paths
project-context-reset # Reset all paths to commented out
The tool will:
- Create
.project-context.toml
in your current directory if it doesn't exist - Generate or update the list of files (commented/uncommented based on existing config)
- Create
project-context.xml
in your current directory
If you prefer not using aliases, you can still run:
# Update project context preserving your previous file selections
npm run --prefix /path/to/project-context-generator start /path/to/your/project
# Reset project context (all files will be commented out)
npm run --prefix /path/to/project-context-generator start:reset /path/to/your/project
If included_paths
is an empty array in your config:
- The file tree will still be generated
- The project structure will be shown
- No file contents will be included in the XML output
This is useful when you only want to see the project structure without any file contents.
The .project-context.toml
file in your project directory controls what gets included in the output:
# Files/directories to exclude from tree visualization
excluded_from_file_tree = [
".nuxt",
".git",
".output",
"node_modules"
]
# Files/directories to completely ignore
ignored_paths = [
".nuxt",
".output",
"yarn.lock",
"node_modules",
".git"
]
# Paths to include in XML content
included_paths = [
# Files commented out won't be included in the XML output
# "app.vue",
# "components/MyComponent.vue",
"types/index.ts" # This file will be included
]
The tool generates a project-context.xml
file in your current directory with:
- Project information from package.json
- A visual file tree representation
- Contents of included files (specified in .project-context.toml)
Example output structure:
<?xml version="1.0" encoding="UTF-8"?>
<projectContext>
<projectInfo>
<name>your-project-name</name>
<description>Your project description</description>
<version>1.0.0</version>
<!-- Dependencies information -->
</projectInfo>
<fileTree>
<!-- Visual representation of project structure -->
</fileTree>
<fileContents>
<!-- Contents of included files -->
</fileContents>
</projectContext>
- Use the reset command if you want to start fresh with all paths commented
- The tool preserves your uncommented paths when updating, even if new files are added to the project
- XML-unsafe characters are automatically escaped in the output
Contributions are welcome! Please feel free to submit a Pull Request.
Apache-2.0