Skip to main content

A project that splits files and copies them to paste buffer with context for an LLM.

Reason this release was yanked:

Released 1.1.1

Project description

chunkwrap

A Python utility for splitting large files into manageable chunks, masking secrets, and wrapping each chunk with custom prompts for Large Language Model (LLM) processing.

Overview

chunkwrap helps you prepare large files for LLM workflows by:

  • Splitting them into smaller, prompt-ready chunks

  • Redacting secrets via TruffleHog-style regexes

  • Tracking progress across invocations

  • Supporting clipboard-based interaction or (soon) alternate output modes

Features

  • Configurable chunking: Choose chunk size (default: 10,000 characters)

  • Multi-file support: Concatenate multiple inputs into a single stream

  • Secret masking: Redact sensitive patterns using configurable regexes

  • Prompt wrapping: Use distinct prompts for intermediate and final chunks

  • Clipboard integration: Copy output chunk directly to your paste buffer

  • State tracking: Progress is remembered across runs using a local .chunkwrap_state file

  • Optional prompt suffix: Append boilerplate only to intermediate chunks

Installation

  1. Clone the repository:

    bash

    git clone https://github.com/your/repo.git
    cd chunkwrap
    
    
  2. Install dependencies:

    bash

    pip install pyperclip
    
    
  3. On first run, a default config file will be created at:

    • Linux/macOS: ~/.config/chunkwrap/config.json

    • Windows: %APPDATA%\chunkwrap\config.json

Usage

Minimal example

bash

python chunkwrap.py --prompt "Analyze this:" --file myscript.py

Multiple files

bash

python chunkwrap.py --prompt "Review each file:" --file a.py b.md

Secret masking

Place a truffleHogRegexes.json file in the same directory:

json

{
  "AWS": "AKIA[0-9A-Z]{16}",
  "Slack": "xox[baprs]-[0-9a-zA-Z]{10,48}"
}

Each match will be replaced with ***MASKED-<KEY>***.

Custom chunk size

bash

python chunkwrap.py --prompt "Summarize section:" --file notes.txt --size 5000

Final chunk prompt

bash

python chunkwrap.py --prompt "Analyze chunk:" --lastprompt "Now summarize everything:" --file long.txt

Disable prompt suffix

bash

python chunkwrap.py --prompt "Chunk:" --file script.py --no-suffix

Show config path

bash

python chunkwrap.py --config-path

Reset state

bash

python chunkwrap.py --reset

Output Format

Each chunk is wrapped like:

Your prompt (chunk 2 of 4)
"""
[redacted content]
"""

Final chunk omits the index and uses --lastprompt if provided.

Roadmap

Near-term improvements

1. Auto-prompt modification for non-final chunks: Automatically append instructions to non-final chunks asking the LLM to reserve comprehensive responses for the final chunk. This prevents information loss when users only review the last response in a sequence.

2. Reset investigation: The reset command does not work as expected, and needs some love & attention.

  1. Configurable prompt suffixes: Add support for automatically appending standard instructions to all prompts (e.g., "Use concise responses for intermediate chunks").

3. External configuration management: Move configuration options to ~/.config/chunkwrap.json with CLI commands for managing settings.

  1. Make cross platform: local usage on Mac is good. My test machine is via ssh to a linux machine. The current code does not support this. Consider adding optional argument chunkwrap [--output {clipboard|stdout|file}] to handle this situation.

Future considerations

  • Chunk overlap: Add optional overlap between chunks to preserve context across boundaries
  • Smart chunking: Break at natural boundaries (sentences, paragraphs) rather than arbitrary character counts
  • Output formats: Support for different wrapper formats (XML tags, markdown blocks, etc.)
  • Parallel processing: For very large file sets, allow processing multiple chunks simultaneously
  • Integration modes: Direct API integration with popular LLM services

Requirements

  • Python 3.11+

  • pyperclip

License

GNU General Public License v3.0 --- see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chunkwrap-1.0.0.tar.gz (47.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chunkwrap-1.0.0-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file chunkwrap-1.0.0.tar.gz.

File metadata

  • Download URL: chunkwrap-1.0.0.tar.gz
  • Upload date:
  • Size: 47.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for chunkwrap-1.0.0.tar.gz
Algorithm Hash digest
SHA256 76cb1a532838b856fcd4db7fc0153ad9952c21e6ab12d8a833573a4e4ba1e07e
MD5 6e110477693bf38150e76727f52aadca
BLAKE2b-256 219d67886ade9a7ce9a2e7e74127734739d6e42f1d7fcc07b82bced3adee3626

See more details on using hashes here.

File details

Details for the file chunkwrap-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: chunkwrap-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 31.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for chunkwrap-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97dd7cf2bbadc4d53ea3ad40bbd779b8c27a6be657382ca773c046bc5d5dfbfd
MD5 dbf1706921f9da2067cc5f0927e4e0e7
BLAKE2b-256 51fea22ed8e5fd421748a6888a9f3da04e492fe437577a5200d227b3786f91be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page