combicode 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +96 -0
  3. package/index.js +199 -0
  4. package/package.json +36 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 A. Aurelions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Combicode
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/combicode.svg)](https://www.npmjs.com/package/combicode)
4
+ [![PyPI Version](https://img.shields.io/pypi/v/combicode.svg)](https://pypi.org/project/combicode/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ <img align="center" src="https://github.com/aaurelions/combicode/raw/main/screenshot.png" width="600"/>
8
+
9
+ **Combicode** is a zero-dependency CLI tool that intelligently combines your project's source code into a single, LLM-friendly text file.
10
+
11
+ Paste the contents of `combicode.txt` into ChatGPT, Claude, or any other LLM to give it the full context of your repository instantly.
12
+
13
+ ## Why use Combicode?
14
+
15
+ - **Maximum Context:** Give your LLM a complete picture of your project structure and code.
16
+ - **Intelligent Ignoring:** Automatically skips `node_modules`, `.venv`, `dist`, `.git`, binary files, and other common junk.
17
+ - **`.gitignore` Aware:** Respects your project's existing `.gitignore` rules out of the box.
18
+ - **Zero-Install Usage:** Run it directly with `npx` or `pipx` without polluting your environment.
19
+ - **Customizable:** Easily filter by file extension or add custom ignore patterns.
20
+
21
+ ## Quick Start
22
+
23
+ Navigate to your project's root directory in your terminal and run one of the following commands:
24
+
25
+ #### For Node.js/JavaScript/TypeScript projects (via `npx`):
26
+
27
+ ```bash
28
+ npx combicode
29
+ ```
30
+
31
+ #### For Python projects (or general use, via `pipx`):
32
+
33
+ ```bash
34
+ pipx run combicode
35
+ ```
36
+
37
+ This will create a `combicode.txt` file in your project directory.
38
+
39
+ ## Usage and Options
40
+
41
+ ### Preview which files will be included
42
+
43
+ Use the `--dry-run` or `-d` flag to see a list of files without creating the output file.
44
+
45
+ ```bash
46
+ # npx
47
+ npx combicode --dry-run
48
+
49
+ # pipx
50
+ pipx run combicode -d
51
+ ```
52
+
53
+ ### Specify an output file
54
+
55
+ Use the `--output` or `-o` flag.
56
+
57
+ ```bash
58
+ npx combicode -o my_project_context.md
59
+ ```
60
+
61
+ ### Include only specific file types
62
+
63
+ Use the `--include-ext` or `-i` flag with a comma-separated list of extensions.
64
+
65
+ ```bash
66
+ # Include only TypeScript, TSX, and CSS files
67
+ npx combicode -i .ts,.tsx,.css
68
+
69
+ # Include only Python and YAML files
70
+ pipx run combicode -i .py,.yaml
71
+ ```
72
+
73
+ ### Add custom exclude patterns
74
+
75
+ Use the `--exclude` or `-e` flag with comma-separated glob patterns.
76
+
77
+ ```bash
78
+ # Exclude all test files and anything in a 'docs' folder
79
+ npx combicode -e "**/*_test.py,docs/**"
80
+ ```
81
+
82
+ ## All CLI Options
83
+
84
+ | Option | Alias | Description | Default |
85
+ | ---------------- | ----- | ------------------------------------------------------------ | --------------- |
86
+ | `--output` | `-o` | The name of the output file. | `combicode.txt` |
87
+ | `--dry-run` | `-d` | Preview files without creating the output file. | `false` |
88
+ | `--include-ext` | `-i` | Comma-separated list of extensions to exclusively include. | (include all) |
89
+ | `--exclude` | `-e` | Comma-separated list of additional glob patterns to exclude. | (none) |
90
+ | `--no-gitignore` | | Do not use patterns from the project's `.gitignore` file. | `false` |
91
+ | `--version` | `-v` | Show the version number. | |
92
+ | `--help` | `-h` | Show the help message. | |
93
+
94
+ ## License
95
+
96
+ This project is licensed under the MIT License.
package/index.js ADDED
@@ -0,0 +1,199 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const yargs = require("yargs/yargs");
6
+ const { hideBin } = require("yargs/helpers");
7
+ const glob = require("fast-glob");
8
+
9
+ const { version } = require("./package.json");
10
+
11
+ const DEFAULT_IGNORE_PATTERNS = [
12
+ "**/node_modules/**",
13
+ "**/.git/**",
14
+ "**/.vscode/**",
15
+ "**/.idea/**",
16
+ "**/*.log",
17
+ "**/.env",
18
+ "**/*.lock",
19
+ "**/.venv/**",
20
+ "**/venv/**",
21
+ "**/env/**",
22
+ "**/__pycache__/**",
23
+ "**/*.pyc",
24
+ "**/*.egg-info/**",
25
+ "**/build/**",
26
+ "**/dist/**",
27
+ "**/.pytest_cache/**",
28
+ "**/.npm/**",
29
+ "**/pnpm-lock.yaml",
30
+ "**/package-lock.json",
31
+ "**/.next/**",
32
+ "**/.DS_Store",
33
+ "**/Thumbs.db",
34
+ // Common binary file extensions
35
+ "**/*.png",
36
+ "**/*.jpg",
37
+ "**/*.jpeg",
38
+ "**/*.gif",
39
+ "**/*.ico",
40
+ "**/*.svg",
41
+ "**/*.webp",
42
+ "**/*.mp3",
43
+ "**/*.wav",
44
+ "**/*.flac",
45
+ "**/*.mp4",
46
+ "**/*.mov",
47
+ "**/*.avi",
48
+ "**/*.zip",
49
+ "**/*.tar.gz",
50
+ "**/*.rar",
51
+ "**/*.pdf",
52
+ "**/*.doc",
53
+ "**/*.docx",
54
+ "**/*.xls",
55
+ "**/*.xlsx",
56
+ "**/*.dll",
57
+ "**/*.exe",
58
+ "**/*.so",
59
+ "**/*.a",
60
+ "**/*.lib",
61
+ "**/*.o",
62
+ "**/*.bin",
63
+ "**/*.iso",
64
+ ];
65
+
66
+ function isLikelyBinary(file) {
67
+ const buffer = Buffer.alloc(512);
68
+ let fd;
69
+ try {
70
+ fd = fs.openSync(file, "r");
71
+ const bytesRead = fs.readSync(fd, buffer, 0, 512, 0);
72
+ // Check for null bytes, a strong indicator of a binary file
73
+ return buffer.slice(0, bytesRead).includes(0);
74
+ } catch (e) {
75
+ // If we can't read it, treat it as something to skip
76
+ return true;
77
+ } finally {
78
+ if (fd) fs.closeSync(fd);
79
+ }
80
+ }
81
+
82
+ async function main() {
83
+ const argv = yargs(hideBin(process.argv))
84
+ .scriptName("combicode")
85
+ .usage("$0 [options]")
86
+ .option("o", {
87
+ alias: "output",
88
+ describe: "Output file name",
89
+ type: "string",
90
+ default: "combicode.txt",
91
+ })
92
+ .option("d", {
93
+ alias: "dry-run",
94
+ describe: "Preview files without creating the output file",
95
+ type: "boolean",
96
+ default: false,
97
+ })
98
+ .option("i", {
99
+ alias: "include-ext",
100
+ describe: "Comma-separated extensions to include (e.g., .js,.ts)",
101
+ type: "string",
102
+ })
103
+ .option("e", {
104
+ alias: "exclude",
105
+ describe: "Comma-separated glob patterns to exclude",
106
+ type: "string",
107
+ })
108
+ .option("no-gitignore", {
109
+ describe: "Ignore the project's .gitignore file",
110
+ type: "boolean",
111
+ default: false,
112
+ })
113
+ .version(version) // Read version from package.json
114
+ .alias("v", "version")
115
+ .help()
116
+ .alias("h", "help").argv;
117
+
118
+ const projectRoot = process.cwd();
119
+ console.log(`✨ Running Combicode in: ${projectRoot}`);
120
+
121
+ const ignorePatterns = [...DEFAULT_IGNORE_PATTERNS];
122
+
123
+ if (!argv.noGitignore) {
124
+ const gitignorePath = path.join(projectRoot, ".gitignore");
125
+ if (fs.existsSync(gitignorePath)) {
126
+ console.log("šŸ”Ž Found and using .gitignore");
127
+ const gitignoreContent = fs.readFileSync(gitignorePath, "utf8");
128
+ ignorePatterns.push(
129
+ ...gitignoreContent
130
+ .split(/\r?\n/)
131
+ .filter((line) => line && !line.startsWith("#"))
132
+ );
133
+ }
134
+ }
135
+
136
+ if (argv.exclude) {
137
+ ignorePatterns.push(...argv.exclude.split(","));
138
+ }
139
+
140
+ let allFiles = await glob("**/*", {
141
+ cwd: projectRoot,
142
+ dot: true,
143
+ ignore: ignorePatterns,
144
+ absolute: true,
145
+ stats: false,
146
+ });
147
+
148
+ const allowedExtensions = argv.includeExt
149
+ ? new Set(
150
+ argv.includeExt
151
+ .split(",")
152
+ .map((ext) => (ext.startsWith(".") ? ext : `.${ext}`))
153
+ )
154
+ : null;
155
+
156
+ const includedFiles = allFiles
157
+ .filter((file) => {
158
+ if (fs.statSync(file).isDirectory()) return false;
159
+ if (isLikelyBinary(file)) return false;
160
+ if (allowedExtensions && !allowedExtensions.has(path.extname(file)))
161
+ return false;
162
+ return true;
163
+ })
164
+ .sort();
165
+
166
+ if (includedFiles.length === 0) {
167
+ console.error("āŒ No files to include. Check your path or filters.");
168
+ process.exit(1);
169
+ }
170
+
171
+ if (argv.dryRun) {
172
+ console.log("\nšŸ“‹ Files to be included (Dry Run):");
173
+ includedFiles.forEach((file) =>
174
+ console.log(` - ${path.relative(projectRoot, file)}`)
175
+ );
176
+ console.log(`\nTotal: ${includedFiles.length} files.`);
177
+ return;
178
+ }
179
+
180
+ const outputStream = fs.createWriteStream(argv.output);
181
+ for (const file of includedFiles) {
182
+ const relativePath = path.relative(projectRoot, file).replace(/\\/g, "/");
183
+ outputStream.write(`// FILE: ${relativePath}` + "\n");
184
+ outputStream.write("```\n");
185
+ const content = fs.readFileSync(file, "utf8");
186
+ outputStream.write(content);
187
+ outputStream.write("\n```\n\n");
188
+ }
189
+ outputStream.end();
190
+
191
+ console.log(
192
+ `\nāœ… Success! Combined ${includedFiles.length} files into '${argv.output}'.`
193
+ );
194
+ }
195
+
196
+ main().catch((err) => {
197
+ console.error(`An unexpected error occurred: ${err.message}`);
198
+ process.exit(1);
199
+ });
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "combicode",
3
+ "version": "1.0.2",
4
+ "description": "A CLI tool to combine a project's codebase into a single file for LLM context.",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "combicode": "index.js"
8
+ },
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "scripts": {
13
+ "test": "echo \"Error: no test specified\" && exit 1"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/aaurelions/combicode.git"
18
+ },
19
+ "keywords": [
20
+ "cli",
21
+ "llm",
22
+ "ai",
23
+ "context",
24
+ "prompt",
25
+ "developer-tool",
26
+ "codegen",
27
+ "chatgpt"
28
+ ],
29
+ "author": "A. Aurelions",
30
+ "license": "MIT",
31
+ "dependencies": {
32
+ "fast-glob": "^3.3.1",
33
+ "ignore": "^5.2.4",
34
+ "yargs": "^17.7.2"
35
+ }
36
+ }