A tool to stringify code using rsync filtering
Project description
Rstring: Rsync-Powered Code Stringification
Rstring is a developer tool that uses Rsync to efficiently gather and stringify code from your projects. It's designed to streamline the process of preparing code context for AI programming assistants, making it easy to get intelligent insights about your codebase.
Quickly prompt an LLM with your whole project!
Installation
Rstring requires Python 3.8+. We recommend using pipx for installation, as it installs Rstring in an isolated environment, preventing conflicts with other packages.
Using pipx (recommended)
-
Install pipx if you haven't already. Follow the official pipx installation guide for your operating system.
-
Install Rstring:
pipx install rstring
Using pip
If you prefer to use pip, you can install Rstring with:
pip install rstring
Updating Rstring
To update Rstring to the latest version:
With pipx:
pipx upgrade rstring
With pip:
pip install --upgrade rstring
For more detailed information about pipx and its usage, refer to the pipx documentation.
Quick Start
Basic usage:
rstring # All files (filtered by .gitignore)
Work with different directories:
rstring /path/to/project # Analyze a specific directory
rstring -C /path/to/project # Change directory before processing
Custom filtering:
rstring --include='*.py' # Only Python files
rstring --include='*/' --include='*.js' --exclude='test*' # Complex patterns
Get help:
rstring --help
Get a tree view of selected files:
rstring --summary
Advanced Usage
Custom Filtering
Rstring uses rsync's powerful include/exclude patterns:
# Include only Python files
rstring --include='*/' --include='*.py' --exclude='*'
# Include web development files, exclude tests
rstring --include='*/' --include='*.{js,css,html}' --exclude='test*' --exclude='*'
# Include documentation
rstring --include='*/' --include='*.md' --include='*.rst' --exclude='*'
Creating Custom Shortcuts
For frequently used patterns, create shell aliases in your .bashrc or .zshrc:
# Python source files only
alias rstring-py="rstring --include='*/' --include='*.py' --exclude='test*'"
# Web development files
alias rstring-web="rstring --include='*/' --include='*.{js,ts,css,html}' --exclude='node_modules/'"
# Documentation files
alias rstring-docs="rstring --include='*/' --include='*.{md,rst,txt}' --exclude='*'"
# All source code (no tests, docs, or config)
alias rstring-src="rstring --include='src/' --include='lib/' --exclude='*'"
Usage:
rstring-py # Python files in current directory
rstring-web -C /path/to/app # Web files in different directory
rstring-docs --summary # Documentation with tree view
File Preview
Limit output to first N lines of each file:
rstring --preview-length=10
Gitignore Integration
By default, Rstring automatically excludes .gitignore patterns. To ignore .gitignore:
rstring --no-gitignore
Interactive mode
Enter interactive mode to continuously preview and select matched files:
rstring -i
Understanding Rstring
-
Under the Hood: Rstring efficiently selects files based on filters by running
rsync --archive --itemize-changes --dry-run --list-only <your filters>. This means you can use Rsync's powerful include/exclude patterns to customize file selection. -
Default Behavior: When run without specific patterns, rstring includes all files and directories, filtered by your project's
.gitignorefile. -
Output Format:
--- path/to/file1.py --- [File contents] --- path/to/file2.js --- [File contents] -
Binary Files: Content of binary files is represented as a hexdump preview.
-
Clipboard Integration: Output is automatically copied to clipboard unless disabled with
--no-clipboard. -
Git Integration: By default, Rstring respects .gitignore patterns. Use
--no-gitignoreto ignore them.
Pro Tips
-
Start simple:
rstringwith no arguments gives you everything in your project (filtered by .gitignore). -
Refer to Rsync documentation: Rstring uses Rsync for file selection. Refer to the Filter Rules section of the rsync man page to understand how include/exclude patterns work.
-
Create project-specific aliases: Set up shell aliases for your common file selection patterns.
-
Use with AI tools: Rstring is great for preparing code context for AI programming assistants.
-
Large projects may produce substantial output: Use
--preview-lengthor specific patterns for better manageability.
Common Patterns
Here are some useful rsync patterns for different scenarios:
# Python projects
rstring --include='*/' --include='*.py' --exclude='__pycache__/' --exclude='test*'
# JavaScript/Node.js projects
rstring --include='*/' --include='*.{js,ts,jsx,tsx}' --exclude='node_modules/' --exclude='test*'
# Web projects (frontend)
rstring --include='*/' --include='*.{js,ts,css,html,vue,svelte}' --exclude='dist/' --exclude='build/'
# Documentation only
rstring --include='*/' --include='*.{md,rst,txt}' --exclude='*'
# Configuration files
rstring --include='*/' --include='*.{json,yaml,yml,toml,ini}' --exclude='*'
# Source code only (exclude tests, docs, config)
rstring --include='src/' --include='lib/' --exclude='*'
Support and Contributing
- Issues and feature requests: GitHub Issues
- Contributing: See CONTRIBUTING.md for development setup and guidelines
- Pull requests welcome!
License
Rstring is released under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rstring-0.4.1.tar.gz.
File metadata
- Download URL: rstring-0.4.1.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85374a302f86c23bfe2b4304131ed62139fd6594b96a795c847e155d72dbe467
|
|
| MD5 |
154bfae8fc64be13ad878acedbd020d7
|
|
| BLAKE2b-256 |
2de66d238d4b4344ea5751cbe0b4e93d32ef01f4365aaf7499af8c6e5bfeb3a7
|
Provenance
The following attestation bundles were made for rstring-0.4.1.tar.gz:
Publisher:
package.yml on tnunamak/rstring
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rstring-0.4.1.tar.gz -
Subject digest:
85374a302f86c23bfe2b4304131ed62139fd6594b96a795c847e155d72dbe467 - Sigstore transparency entry: 236740776
- Sigstore integration time:
-
Permalink:
tnunamak/rstring@1173db1d7666c926508f251a259e9ec3b105577a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tnunamak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package.yml@1173db1d7666c926508f251a259e9ec3b105577a -
Trigger Event:
push
-
Statement type:
File details
Details for the file rstring-0.4.1-py3-none-any.whl.
File metadata
- Download URL: rstring-0.4.1-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b78139fde30561329e374546d5422e1b8fe4c8fd3ed5766e9709cb49477fbb2
|
|
| MD5 |
e52307c2e88d3bc70edf7e7e6a5a6b9e
|
|
| BLAKE2b-256 |
2e17d810185683a9721f0c1f589560f6523a1073fa0a8741d937c41ae9c274fc
|
Provenance
The following attestation bundles were made for rstring-0.4.1-py3-none-any.whl:
Publisher:
package.yml on tnunamak/rstring
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rstring-0.4.1-py3-none-any.whl -
Subject digest:
7b78139fde30561329e374546d5422e1b8fe4c8fd3ed5766e9709cb49477fbb2 - Sigstore transparency entry: 236740789
- Sigstore integration time:
-
Permalink:
tnunamak/rstring@1173db1d7666c926508f251a259e9ec3b105577a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tnunamak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package.yml@1173db1d7666c926508f251a259e9ec3b105577a -
Trigger Event:
push
-
Statement type: