Skip to content

casperakos/codeweave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧡 CodeWeave

License: MIT Rust

A modern, blazing-fast CLI tool to weave code files into well-formatted prompts for Large Language Models.

✨ Features

  • πŸš€ Fast: Built in Rust with parallel processing for large codebases
  • 🎨 Multiple Formats: Plain text, Claude XML, and Markdown with fenced code blocks
  • πŸ” Smart Filtering: Respects .gitignore, supports custom patterns and file extensions
  • πŸ“Š Token Estimation: Estimate LLM context usage before sending
  • 🎯 Progress Tracking: Visual progress bars for large operations
  • 🌈 Beautiful Output: Colorized terminal output with clear error messages
  • πŸ“ Line Numbers: Optional line numbering for better code reference
  • πŸ”„ Stdin Support: Pipe in file lists from other commands
  • 50+ Languages: Intelligent language detection for Markdown code blocks

πŸ“¦ Installation

Quick Install (Recommended)

Linux / macOS

curl -fsSL https://raw.githubusercontent.com/casperakos/codeweave/main/install.sh | sh

Windows (PowerShell)

irm https://raw.githubusercontent.com/casperakos/codeweave/main/install.ps1 | iex

The installer will:

  • βœ… Auto-detect your platform and architecture
  • βœ… Download the appropriate binary
  • βœ… Install to /usr/local/bin (or ~/.local/bin if no sudo)
  • βœ… Add to PATH automatically (Windows)

Custom Installation

Specify version:

curl -fsSL https://raw.githubusercontent.com/casperakos/codeweave/main/install.sh | CODEWEAVE_VERSION=v0.1.0 sh

Specify install directory:

curl -fsSL https://raw.githubusercontent.com/casperakos/codeweave/main/install.sh | CODEWEAVE_INSTALL_DIR=~/.local/bin sh

Manual Download

Download pre-built binaries from the releases page:

  • Linux (x86_64): codeweave-linux-x86_64.tar.gz
  • Linux (ARM64): codeweave-linux-aarch64.tar.gz
  • macOS (Intel): codeweave-macos-x86_64.tar.gz
  • macOS (Apple Silicon): codeweave-macos-aarch64.tar.gz
  • Windows: codeweave-windows-x86_64.exe.zip

From Source

git clone https://github.com/casperakos/codeweave.git
cd codeweave
cargo install --path .

From Cargo (Coming Soon)

cargo install codeweave

πŸš€ Quick Start

# Process current directory
codeweave

# Process specific files/directories
codeweave src/ README.md

# Only include Rust files
codeweave src/ --ext rs

# Output as Markdown
codeweave src/ --format markdown

# Save to file with token estimation
codeweave . --output prompt.txt --tokens

# Show progress for large directories
codeweave /large/project --progress

πŸ“– Usage

codeweave [OPTIONS] [PATHS]...

Options

Flag Description
-e, --ext <EXT> Only include files with specified extensions (repeatable)
--include-hidden Include hidden files and directories
--ignore <PATTERN> Ignore patterns (repeatable)
--ignore-files-only Apply ignore patterns only to files, not directories
--ignore-gitignore Don't respect .gitignore files
-n, --line-numbers Add line numbers to output
-f, --format <FORMAT> Output format: plain, xml, or markdown (default: plain)
-o, --output <FILE> Write to file instead of stdout
-p, --progress Show progress bar
--tokens Estimate token count
-0, --null Read NUL-separated paths from stdin
-q, --quiet Suppress warnings

πŸ’‘ Examples

Basic Usage

# Process all files in current directory
codeweave .

# Process specific directories
codeweave src/ tests/

# Process with multiple file extensions
codeweave . --ext rs --ext toml --ext md

Output Formats

Plain Text (Default)

codeweave src/
src/main.rs
---
fn main() {
    println!("Hello, world!");
}
---

Claude XML Format

codeweave src/ --format xml
<documents>
<document index="1">
<source>src/main.rs</source>
<document_content>
fn main() {
    println!("Hello, world!");
}
</document_content>
</document>
</documents>

Markdown Format

codeweave src/ --format markdown
src/main.rs
```rust
fn main() {
    println!("Hello, world!");
}
```

Filtering

# Only Python files
codeweave . --ext py

# Ignore test files
codeweave . --ignore "*test*" --ignore "*.tmp"

# Include hidden files
codeweave . --include-hidden

# Ignore .gitignore rules
codeweave . --ignore-gitignore

Advanced Usage

# With line numbers for better reference
codeweave src/ --line-numbers --format markdown

# Large project with progress and token estimation
codeweave /big/project --progress --tokens --output context.txt

# Pipe from find
find src/ -name "*.rs" | codeweave

# Pipe from fd (faster alternative to find)
fd -e rs | codeweave --format markdown

# NUL-separated for filenames with spaces
find . -name "*.py" -print0 | codeweave --null

Real-World Scenarios

Preparing context for Claude/GPT

codeweave src/ --format xml --tokens --output claude-context.xml

Code review preparation

codeweave src/ --ext rs --line-numbers --format markdown > review.md

Documentation generation

codeweave src/ docs/ --ext rs --ext md --format markdown > full-context.md

Focus on specific module

codeweave src/auth/ --ext rs --line-numbers

🎨 Output Examples

With Progress

β†’ Found 42 files to process
[00:00:02] ========================================  42/42 src/processor.rs
βœ“ Processed 42 files
β„Ή Estimated tokens: ~15,420

With Warnings

β†’ Found 100 files to process
⚠ Large file detected: src/data.json (15.3 MB)
βœ“ Processed 99 files
! Skipped 1 files due to errors
β„Ή Estimated tokens: ~125,430
⚠ Large context size! Consider filtering files.

πŸ”§ Technical Details

Language Support

CodeWeave intelligently detects 50+ programming languages for Markdown code blocks:

  • Systems: Rust, C, C++, Go, Zig, V
  • Web: JavaScript, TypeScript, HTML, CSS, SCSS
  • Backend: Python, Java, Kotlin, C#, PHP, Ruby, Swift
  • Functional: Haskell, OCaml, Elixir, Erlang, Clojure, Scala
  • Data: JSON, YAML, TOML, XML, SQL, GraphQL
  • Shell: Bash, Zsh, Fish, PowerShell
  • And many more!

Performance

  • Parallel Processing: Uses Rayon for concurrent file reading
  • Smart Walking: Leverages the ignore crate for fast directory traversal
  • Memory Efficient: Streams output for large files
  • Gitignore Aware: Automatically respects .gitignore, .git/info/exclude, and global gitignore

🀝 Contributing

Contributions are welcome! This project is open source under the MIT license.

Development Setup

git clone https://github.com/yourusername/codeweave.git
cd codeweave
cargo build
cargo test

Running Tests

cargo test
cargo test -- --nocapture  # Show output

Release Build

cargo build --release
# Binary at target/release/codeweave

πŸ“ License

MIT License - see LICENSE for details

πŸ™ Acknowledgments

Built with:

Inspired by files-to-prompt by Simon Willison

πŸ”— Links


Made with ❀️ and Rust

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published