Cfold

Cfold

Cfold is a command-line tool designed to prepare codebases for interaction with Large Language Models (LLMs). It allows you to fold a directory of code into a single JSON file and unfold a modified version back into a directory structure, enabling controlled codebase changes via LLMs.

Key Features

  • Fold files and instructions into JSON: Capture codebases, including prompts, into a structured JSON format.
  • Unfold LLM-returned JSONs: Apply modifications from LLMs back to the directory.
  • Controlled LLM interactions: Facilitate precise codebase updates in a managed manner.

Installation

Install cfold using the following command:

uv pip install https://github.com/wr1/cfold.git

Usage

CLI Help

Help

Example Output

Output

Fold File Format

The JSON structure includes:

  • instructions: A list of instruction objects, each with type (‘system’, ‘user’, or ‘assistant’), content (string), and optional name and synopsis.
  • files: An array of file objects with path (relative to CWD), content (full file content, optional if deleting), and delete (bool, default false).

Operations include:

  • Modifying files by updating content.
  • Deleting files with delete: true.
  • Adding new files with path and content.
  • Moving/renaming by deleting the old and adding the new.

License

MIT License.

For more details, visit the cfold GitHub repository.