src2one
v0.1.0
Published
Consolidate source code files into a single text file for AI development
Downloads
18
Readme
src2one
[[TOC]]
Overview
This simple TypeScript script copies the contents of source files into a single file. This can be useful for uploading to online services like ChatGPT, Perplexity, Claude, etc. It's designed for quick use, speeding up development alongside AI. Just run src2one, and voila! All your sources are in one file, ready to be uploaded.
Dependencies
Installation
- Install Bun (see dependencies)
- Clone the repository
git clone https://github.com/monnef/src2one.git
cd src2one
- Install dependencies with
bun i
- Build the project with
bun run build
- Setup the alias
Build
Build the project with the following command:
$ bun run build
This will create a dist/src2one
executable in the project directory.
$ dist/src2one --version
0.1.0
Alias
Adding an alias is strongly recommended. The rest of this document (and the script itself) assumes the alias has been added.
Run the following command in this project's directory:
$ bun start alias
Then follow the instructions in the output.
Usage
To generate a config file for a given project, run the following command in the project directory:
$ src2one init
Then, to generate the sources file, run the following command in the project directory:
$ src2one
Found 2 file(s) to process, 0 file(s) ignored.
Writing file contents into sources.txt...
Processing done.
$ cat sources.txt
Generated on: 2025-03-23T14:04:23.185Z
Full project path: /mnt/dev/typescript/src2one/test/yaml/nested
==== /mnt/dev/typescript/src2one/test/yaml/nested/src/nested/nested-file.txt ====
nested
==== /mnt/dev/typescript/src2one/test/yaml/nested/src/a.txt ====
a
Configuration
The script looks for configuration in the following files, in order of precedence:
src2one.yaml
src2one.json
If no configuration file is found, the script will terminate with an error.
Configuration File Structure
The configuration file should contain the following keys:
fileName
: The name of the output file (default:sources.txt
).inputNames
: An array of directories or files to include (default:['.']
).ignorePatterns
: An array of JavaScript regular expressions to ignore (default:['^sources.txt$', '^src2one.yaml$']
).
Example src2one.yaml
:
fileName: 'sources.txt'
inputNames:
- 'src'
- 'lib'
ignorePatterns:
- '^sources.txt$'
License
AGPLv3