iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🔖

Convert repository content to text with bento -dump

に公開

There seem to be several CLIs for converting repositories into text, but I've added a similar feature to bento. Its main selling point is that it's a Go-based CLI, making it portable and convenient to use anywhere.

https://github.com/catatsuy/bento

bento has many features, but -dump is particularly easy to use as it doesn't require any environment variables or setup.

Usage is simple; you can use it like this:

# Convert files in the current directory to text
bento -dump

# Specify a directory name
bento -dump dir1/

It outputs to stdout, so on macOS, piping it to pbcopy is useful for pasting into ChatGPT. For example, running it in the bento repository looks like this:

The output represents a Git repository's content in the following format:

1. Each section begins with ----.
2. The first line after ---- contains the file path and name.
3. The subsequent lines contain the file contents.
4. The repository content ends with --END--.

Any text after --END-- should be treated as instructions, using the repository content as context.
----
.github/workflows/auto-review.yml
name: Auto Review

on:
  pull_request:

(omitted)

  "postUpdateOptions": [
    "gomodTidy",
    "gomodUpdateImportPaths"
  ]
}

--END--

This makes it easy to convert the repository's contents into text and pass it over.

Since repositories are often managed with Git, the .git directory is excluded. It also respects .gitignore contents. If there are files you don't want to ignore in .gitignore but want to exclude from bento -dump, you can use an .aiignore file to exclude them.

That being said, implementing .gitignore properly is quite difficult, and it hasn't been implemented with full compatibility; it currently only checks the .gitignore located in the directory specified for bento -dump. Since this requires significant effort, I'll think about it in the future.

Additionally, there is logic to exclude files identified as binary by checking the initial bytes. I believe this will work well in most scenarios, but it's a matter of deciding how comprehensive it needs to be.

I've used it a bit myself, and if you start by feeding it the source code and then consult it, it provides quite helpful feedback.

bento stands for "Bundled ENhancements for Tasks and Operations," and I plan to continue adding various useful features. I'd be happy if you could use it as a convenient CLI tool.

https://zenn.dev/catatsuy/articles/1b64fc13d2e0b9

Discussion