codemerge-cli 1.2.3 → 1.2.4
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.
- package/README.md +176 -294
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +6 -23
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +1 -0
- package/dist/commands/watch.js.map +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +13 -35
- package/dist/core/config.js.map +1 -1
- package/dist/core/httpServer.d.ts +6 -4
- package/dist/core/httpServer.d.ts.map +1 -1
- package/dist/core/httpServer.js +40 -29
- package/dist/core/httpServer.js.map +1 -1
- package/dist/types/config.d.ts +7 -6
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/merge.d.ts +29 -21
- package/dist/types/merge.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,38 +4,40 @@ AI-focused code and data preparation utility. Merge multiple files into a single
|
|
|
4
4
|
|
|
5
5
|
## 📋 Table of Contents
|
|
6
6
|
|
|
7
|
-
- [Overview](
|
|
8
|
-
- [Installation](
|
|
9
|
-
- [Quick Start](
|
|
10
|
-
- [Commands](
|
|
11
|
-
- [Configuration](
|
|
12
|
-
- [HTTP Server & API](
|
|
13
|
-
- [Use Cases](
|
|
14
|
-
- [Advanced Usage](
|
|
15
|
-
- [Troubleshooting](
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
- [Overview](https://www.google.com/search?q=%23overview)
|
|
8
|
+
- [Installation](https://www.google.com/search?q=%23installation)
|
|
9
|
+
- [Quick Start](https://www.google.com/search?q=%23quick-start)
|
|
10
|
+
- [Commands](https://www.google.com/search?q=%23commands)
|
|
11
|
+
- [Configuration](https://www.google.com/search?q=%23configuration)
|
|
12
|
+
- [HTTP Server & API](https://www.google.com/search?q=%23http-server--api)
|
|
13
|
+
- [Use Cases](https://www.google.com/search?q=%23use-cases)
|
|
14
|
+
- [Advanced Usage](https://www.google.com/search?q=%23advanced-usage)
|
|
15
|
+
- [Troubleshooting](https://www.google.com/search?q=%23troubleshooting)
|
|
16
|
+
|
|
17
|
+
-----
|
|
18
18
|
|
|
19
19
|
## 🎯 Overview
|
|
20
20
|
|
|
21
21
|
CodeMerge is a CLI tool that:
|
|
22
22
|
|
|
23
|
-
- **Merges** multiple code files into a single, structured text file
|
|
24
|
-
- **Optimizes** output for AI tools (ChatGPT, Claude, etc.)
|
|
25
|
-
- **Respects** .gitignore patterns and custom ignore rules
|
|
26
|
-
- **Watches** for file changes and auto-regenerates
|
|
27
|
-
- **Serves** content via HTTP API for dynamic access
|
|
28
|
-
- **Provides** project structure visualization in JSON
|
|
29
|
-
- **Enables** selective file merging via API
|
|
23
|
+
- **Merges** multiple code files into a single, structured text file
|
|
24
|
+
- **Optimizes** output for AI tools (ChatGPT, Claude, etc.)
|
|
25
|
+
- **Respects** .gitignore patterns and custom ignore rules
|
|
26
|
+
- **Watches** for file changes and auto-regenerates
|
|
27
|
+
- **Serves** content via HTTP API for dynamic access
|
|
28
|
+
- **Provides** project structure visualization in JSON
|
|
29
|
+
- **Enables** selective file merging via API
|
|
30
|
+
- **Executes** system commands upon file updates (Upsert hooks)
|
|
30
31
|
|
|
31
32
|
Perfect for:
|
|
32
|
-
- Preparing codebases for AI analysis
|
|
33
|
-
- Generating context for code reviews
|
|
34
|
-
- Creating documentation snapshots
|
|
35
|
-
- Sharing project structure with AI assistants
|
|
36
|
-
- Building AI-powered developer tools
|
|
37
33
|
|
|
38
|
-
|
|
34
|
+
- Preparing codebases for AI analysis
|
|
35
|
+
- Generating context for code reviews
|
|
36
|
+
- Creating documentation snapshots
|
|
37
|
+
- Sharing project structure with AI assistants
|
|
38
|
+
- Building AI-powered developer tools
|
|
39
|
+
|
|
40
|
+
-----
|
|
39
41
|
|
|
40
42
|
## 📦 Installation
|
|
41
43
|
|
|
@@ -53,13 +55,13 @@ npm install --save-dev codemerge-cli
|
|
|
53
55
|
|
|
54
56
|
### Requirements
|
|
55
57
|
|
|
56
|
-
- Node.js
|
|
58
|
+
- Node.js \>= 16.0.0
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
-----
|
|
59
61
|
|
|
60
62
|
## 🚀 Quick Start
|
|
61
63
|
|
|
62
|
-
### 1
|
|
64
|
+
### 1\. Initialize Project
|
|
63
65
|
|
|
64
66
|
```bash
|
|
65
67
|
# Initialize in current directory
|
|
@@ -73,10 +75,11 @@ codemerge init --force
|
|
|
73
75
|
```
|
|
74
76
|
|
|
75
77
|
This creates:
|
|
76
|
-
- `codemerge.json` - Configuration file
|
|
77
|
-
- Updates `.gitignore` - Adds output file
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
- `codemerge.json` - Configuration file
|
|
80
|
+
- Updates `.gitignore` - Adds output file
|
|
81
|
+
|
|
82
|
+
### 2\. Merge Files
|
|
80
83
|
|
|
81
84
|
```bash
|
|
82
85
|
# Merge current directory
|
|
@@ -92,7 +95,7 @@ codemerge use --output my-code.txt
|
|
|
92
95
|
codemerge use --watch
|
|
93
96
|
```
|
|
94
97
|
|
|
95
|
-
### 3
|
|
98
|
+
### 3\. Start HTTP Server
|
|
96
99
|
|
|
97
100
|
```bash
|
|
98
101
|
# Start server on default port (9876)
|
|
@@ -105,7 +108,7 @@ codemerge watch --port 3000
|
|
|
105
108
|
codemerge watch --output api-code.txt --ignore "*.test.ts"
|
|
106
109
|
```
|
|
107
110
|
|
|
108
|
-
|
|
111
|
+
-----
|
|
109
112
|
|
|
110
113
|
## 🎮 Commands
|
|
111
114
|
|
|
@@ -118,23 +121,27 @@ codemerge init [path] [options]
|
|
|
118
121
|
```
|
|
119
122
|
|
|
120
123
|
**Arguments:**
|
|
121
|
-
|
|
124
|
+
|
|
125
|
+
- `path` - Target directory (default: `.`)
|
|
122
126
|
|
|
123
127
|
**Options:**
|
|
124
|
-
|
|
128
|
+
|
|
129
|
+
- `-f, --force` - Overwrite existing configuration
|
|
125
130
|
|
|
126
131
|
**What it does:**
|
|
127
|
-
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
-
|
|
132
|
+
|
|
133
|
+
- Creates `codemerge.json` with default settings
|
|
134
|
+
- Detects project name from `package.json`
|
|
135
|
+
- Adds output file to `.gitignore`
|
|
136
|
+
- Sets up recommended ignore patterns
|
|
131
137
|
|
|
132
138
|
**Example:**
|
|
139
|
+
|
|
133
140
|
```bash
|
|
134
141
|
codemerge init ./backend --force
|
|
135
142
|
```
|
|
136
143
|
|
|
137
|
-
|
|
144
|
+
-----
|
|
138
145
|
|
|
139
146
|
### `codemerge use`
|
|
140
147
|
|
|
@@ -145,13 +152,15 @@ codemerge use [path] [options]
|
|
|
145
152
|
```
|
|
146
153
|
|
|
147
154
|
**Arguments:**
|
|
148
|
-
|
|
155
|
+
|
|
156
|
+
- `path` - Input directory to scan (default: `.`)
|
|
149
157
|
|
|
150
158
|
**Options:**
|
|
151
|
-
|
|
152
|
-
- `-
|
|
153
|
-
-
|
|
154
|
-
- `--
|
|
159
|
+
|
|
160
|
+
- `-o, --output <path>` - Custom output file path
|
|
161
|
+
- `-w, --watch` - Watch for file changes
|
|
162
|
+
- `--ignore <patterns>` - Additional ignore patterns (comma-separated)
|
|
163
|
+
- `--include <patterns>` - Include patterns (comma-separated)
|
|
155
164
|
|
|
156
165
|
**Examples:**
|
|
157
166
|
|
|
@@ -169,7 +178,7 @@ codemerge use --output ai-context.txt
|
|
|
169
178
|
codemerge use --watch
|
|
170
179
|
|
|
171
180
|
# Custom filters
|
|
172
|
-
codemerge use --ignore "*.test.ts,*.spec.js" --include "
|
|
181
|
+
codemerge use --ignore "*.test.ts,*.spec.js" --include "***.js"
|
|
173
182
|
|
|
174
183
|
# Combine options
|
|
175
184
|
codemerge use ./src --output src-merged.txt --watch
|
|
@@ -206,7 +215,7 @@ STARTOFFILE: lib/cli.ts
|
|
|
206
215
|
ENDOFFILE: lib/cli.ts
|
|
207
216
|
```
|
|
208
217
|
|
|
209
|
-
|
|
218
|
+
-----
|
|
210
219
|
|
|
211
220
|
### `codemerge watch`
|
|
212
221
|
|
|
@@ -217,13 +226,15 @@ codemerge watch [path] [options]
|
|
|
217
226
|
```
|
|
218
227
|
|
|
219
228
|
**Arguments:**
|
|
220
|
-
|
|
229
|
+
|
|
230
|
+
- `path` - Input directory to scan (default: `.`)
|
|
221
231
|
|
|
222
232
|
**Options:**
|
|
223
|
-
|
|
224
|
-
- `-
|
|
225
|
-
-
|
|
226
|
-
- `--
|
|
233
|
+
|
|
234
|
+
- `-o, --output <path>` - Output file path
|
|
235
|
+
- `-p, --port <number>` - Server port (default: `9876`)
|
|
236
|
+
- `--ignore <patterns>` - Additional ignore patterns
|
|
237
|
+
- `--include <patterns>` - Include patterns
|
|
227
238
|
|
|
228
239
|
**Examples:**
|
|
229
240
|
|
|
@@ -238,19 +249,21 @@ codemerge watch --port 8080
|
|
|
238
249
|
codemerge watch ./src --port 3000
|
|
239
250
|
|
|
240
251
|
# With filters
|
|
241
|
-
codemerge watch --ignore "*.test.ts" --include "
|
|
252
|
+
codemerge watch --ignore "*.test.ts" --include "***.tsx"
|
|
242
253
|
```
|
|
243
254
|
|
|
244
255
|
**Server Endpoints:**
|
|
245
|
-
- `GET /health` - Server health status
|
|
246
|
-
- `GET /content` - Full merged content
|
|
247
|
-
- `GET /structure` - Project structure JSON
|
|
248
|
-
- `POST /selective-content` - Merge selected files
|
|
249
|
-
- `POST /upsert` - Create/update files
|
|
250
256
|
|
|
251
|
-
|
|
257
|
+
- `GET /health` - Server health status
|
|
258
|
+
- `GET /content` - Full merged content
|
|
259
|
+
- `GET /structure` - Project structure JSON
|
|
260
|
+
- `POST /selective-content` - Merge selected files
|
|
261
|
+
- `POST /upsert` - Create/update files
|
|
262
|
+
- `GET /command-output` - Get output of the last post-upsert command
|
|
263
|
+
|
|
264
|
+
See [HTTP Server & API](https://www.google.com/search?q=%23http-server--api) for details.
|
|
252
265
|
|
|
253
|
-
|
|
266
|
+
-----
|
|
254
267
|
|
|
255
268
|
### `codemerge help`
|
|
256
269
|
|
|
@@ -272,7 +285,7 @@ codemerge help use
|
|
|
272
285
|
codemerge help watch
|
|
273
286
|
```
|
|
274
287
|
|
|
275
|
-
|
|
288
|
+
-----
|
|
276
289
|
|
|
277
290
|
### `codemerge version`
|
|
278
291
|
|
|
@@ -282,7 +295,7 @@ Display version information.
|
|
|
282
295
|
codemerge version
|
|
283
296
|
```
|
|
284
297
|
|
|
285
|
-
|
|
298
|
+
-----
|
|
286
299
|
|
|
287
300
|
## ⚙️ Configuration
|
|
288
301
|
|
|
@@ -294,63 +307,30 @@ codemerge version
|
|
|
294
307
|
"outputPath": "merged-output.txt",
|
|
295
308
|
"port": 9876,
|
|
296
309
|
"useGitignore": true,
|
|
310
|
+
"onUpsertCommand": "npm run build",
|
|
297
311
|
"ignorePatterns": [
|
|
298
|
-
"node_modules
|
|
299
|
-
"
|
|
300
|
-
"
|
|
301
|
-
"
|
|
302
|
-
"
|
|
303
|
-
"
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
"
|
|
307
|
-
"**/*.js",
|
|
308
|
-
"**/*.tsx",
|
|
309
|
-
"**/*.jsx",
|
|
310
|
-
"**/*.json",
|
|
311
|
-
"**/*.md"
|
|
312
|
+
"node_modules*.log",
|
|
313
|
+
"coverage*.ts",
|
|
314
|
+
"***.tsx",
|
|
315
|
+
"***.json",
|
|
316
|
+
"***.log",
|
|
317
|
+
"package-lock.json",
|
|
318
|
+
"yarn.lock",
|
|
319
|
+
".env",
|
|
320
|
+
"**/.DS_Store"
|
|
312
321
|
]
|
|
313
322
|
}
|
|
314
323
|
```
|
|
315
324
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
| Option | Type | Default | Description |
|
|
319
|
-
|--------|------|---------|-------------|
|
|
320
|
-
| `projectName` | `string` | Auto-detected | Project name |
|
|
321
|
-
| `outputPath` | `string` | `merged-output.txt` | Output file path |
|
|
322
|
-
| `port` | `number` | `9876` | HTTP server port |
|
|
323
|
-
| `useGitignore` | `boolean` | `true` | Respect .gitignore rules |
|
|
324
|
-
| `ignorePatterns` | `string[]` | See below | Files/folders to ignore |
|
|
325
|
-
| `includePatterns` | `string[]` | See below | Files to include |
|
|
326
|
-
|
|
327
|
-
### Default Ignore Patterns
|
|
328
|
-
|
|
329
|
-
```javascript
|
|
330
|
-
[
|
|
331
|
-
'node_modules/**',
|
|
332
|
-
'.git/**',
|
|
333
|
-
'dist/**',
|
|
334
|
-
'build/**',
|
|
335
|
-
'coverage/**',
|
|
336
|
-
'**/*.log',
|
|
337
|
-
'package-lock.json',
|
|
338
|
-
'yarn.lock',
|
|
339
|
-
'.env',
|
|
340
|
-
'**/.DS_Store'
|
|
341
|
-
]
|
|
342
|
-
```
|
|
325
|
+
**New Option:** `onUpsertCommand` allows defining a shell command to be executed immediately after a successful POST to `/upsert`.
|
|
343
326
|
|
|
344
327
|
### Default Include Patterns
|
|
345
328
|
|
|
346
329
|
```javascript
|
|
347
330
|
[
|
|
348
|
-
'
|
|
349
|
-
'
|
|
350
|
-
'
|
|
351
|
-
'**/*.jsx',
|
|
352
|
-
'**/*.json',
|
|
353
|
-
'**/*.md'
|
|
331
|
+
'***.js',
|
|
332
|
+
'***.jsx',
|
|
333
|
+
'***.md'
|
|
354
334
|
]
|
|
355
335
|
```
|
|
356
336
|
|
|
@@ -363,13 +343,13 @@ You can also configure in `package.json`:
|
|
|
363
343
|
"name": "my-project",
|
|
364
344
|
"codemergeConfig": {
|
|
365
345
|
"outputPath": "ai-digest.txt",
|
|
366
|
-
"
|
|
367
|
-
"
|
|
346
|
+
"onUpsertCommand": "echo 'Upsert complete'",
|
|
347
|
+
"ignorePatterns": ["***.ts"]
|
|
368
348
|
}
|
|
369
349
|
}
|
|
370
350
|
```
|
|
371
351
|
|
|
372
|
-
|
|
352
|
+
-----
|
|
373
353
|
|
|
374
354
|
## 🌐 HTTP Server & API
|
|
375
355
|
|
|
@@ -381,13 +361,14 @@ codemerge watch --port 9876
|
|
|
381
361
|
|
|
382
362
|
### API Endpoints
|
|
383
363
|
|
|
384
|
-
#### 1
|
|
364
|
+
#### 1\. Health Check
|
|
385
365
|
|
|
386
366
|
**GET** `/health`
|
|
387
367
|
|
|
388
368
|
Check server status.
|
|
389
369
|
|
|
390
370
|
**Response:**
|
|
371
|
+
|
|
391
372
|
```json
|
|
392
373
|
{
|
|
393
374
|
"status": "ok",
|
|
@@ -397,6 +378,7 @@ Check server status.
|
|
|
397
378
|
"structure": "/structure",
|
|
398
379
|
"selectiveContent": "/selective-content",
|
|
399
380
|
"upsert": "/upsert",
|
|
381
|
+
"commandOutput": "/command-output",
|
|
400
382
|
"health": "/health"
|
|
401
383
|
},
|
|
402
384
|
"mergeReady": true
|
|
@@ -404,19 +386,21 @@ Check server status.
|
|
|
404
386
|
```
|
|
405
387
|
|
|
406
388
|
**Example:**
|
|
389
|
+
|
|
407
390
|
```bash
|
|
408
391
|
curl http://localhost:9876/health
|
|
409
392
|
```
|
|
410
393
|
|
|
411
|
-
|
|
394
|
+
-----
|
|
412
395
|
|
|
413
|
-
#### 2
|
|
396
|
+
#### 2\. Get Merged Content
|
|
414
397
|
|
|
415
398
|
**GET** `/content`
|
|
416
399
|
|
|
417
400
|
Get full merged content of all files.
|
|
418
401
|
|
|
419
402
|
**Response:**
|
|
403
|
+
|
|
420
404
|
```
|
|
421
405
|
# Code Merge Output
|
|
422
406
|
Generated at: 2026-01-07T01:02:50.588Z
|
|
@@ -425,19 +409,21 @@ Generated at: 2026-01-07T01:02:50.588Z
|
|
|
425
409
|
```
|
|
426
410
|
|
|
427
411
|
**Example:**
|
|
412
|
+
|
|
428
413
|
```bash
|
|
429
414
|
curl http://localhost:9876/content > output.txt
|
|
430
415
|
```
|
|
431
416
|
|
|
432
|
-
|
|
417
|
+
-----
|
|
433
418
|
|
|
434
|
-
#### 3
|
|
419
|
+
#### 3\. Get Project Structure
|
|
435
420
|
|
|
436
421
|
**GET** `/structure`
|
|
437
422
|
|
|
438
423
|
Get project structure as JSON tree.
|
|
439
424
|
|
|
440
425
|
**Response:**
|
|
426
|
+
|
|
441
427
|
```json
|
|
442
428
|
{
|
|
443
429
|
"root": {
|
|
@@ -478,11 +464,13 @@ Get project structure as JSON tree.
|
|
|
478
464
|
```
|
|
479
465
|
|
|
480
466
|
**Example:**
|
|
467
|
+
|
|
481
468
|
```bash
|
|
482
469
|
curl http://localhost:9876/structure | jq
|
|
483
470
|
```
|
|
484
471
|
|
|
485
472
|
**Frontend Integration:**
|
|
473
|
+
|
|
486
474
|
```javascript
|
|
487
475
|
async function getProjectStructure() {
|
|
488
476
|
const response = await fetch('http://localhost:9876/structure');
|
|
@@ -491,15 +479,16 @@ async function getProjectStructure() {
|
|
|
491
479
|
}
|
|
492
480
|
```
|
|
493
481
|
|
|
494
|
-
|
|
482
|
+
-----
|
|
495
483
|
|
|
496
|
-
#### 4
|
|
484
|
+
#### 4\. Get Selective Content
|
|
497
485
|
|
|
498
486
|
**POST** `/selective-content`
|
|
499
487
|
|
|
500
488
|
Merge only selected files/folders.
|
|
501
489
|
|
|
502
490
|
**Request Body:**
|
|
491
|
+
|
|
503
492
|
```json
|
|
504
493
|
{
|
|
505
494
|
"selectedPaths": [
|
|
@@ -511,6 +500,7 @@ Merge only selected files/folders.
|
|
|
511
500
|
```
|
|
512
501
|
|
|
513
502
|
**Response:**
|
|
503
|
+
|
|
514
504
|
```
|
|
515
505
|
# Code Merge Output
|
|
516
506
|
Generated at: 2026-01-07T01:02:50.588Z
|
|
@@ -520,6 +510,7 @@ Files processed: 5
|
|
|
520
510
|
```
|
|
521
511
|
|
|
522
512
|
**Example:**
|
|
513
|
+
|
|
523
514
|
```bash
|
|
524
515
|
curl -X POST http://localhost:9876/selective-content \
|
|
525
516
|
-H "Content-Type: application/json" \
|
|
@@ -532,6 +523,7 @@ curl -X POST http://localhost:9876/selective-content \
|
|
|
532
523
|
```
|
|
533
524
|
|
|
534
525
|
**Frontend Integration:**
|
|
526
|
+
|
|
535
527
|
```javascript
|
|
536
528
|
async function getSelectiveContent(selectedPaths) {
|
|
537
529
|
const response = await fetch('http://localhost:9876/selective-content', {
|
|
@@ -541,8 +533,6 @@ async function getSelectiveContent(selectedPaths) {
|
|
|
541
533
|
});
|
|
542
534
|
return await response.text();
|
|
543
535
|
}
|
|
544
|
-
|
|
545
|
-
// Usage
|
|
546
536
|
const content = await getSelectiveContent([
|
|
547
537
|
'src/core/codeMerger.ts',
|
|
548
538
|
'src/types'
|
|
@@ -551,15 +541,16 @@ const content = await getSelectiveContent([
|
|
|
551
541
|
|
|
552
542
|
**Note:** When you select a folder, all files within it are automatically included.
|
|
553
543
|
|
|
554
|
-
|
|
544
|
+
-----
|
|
555
545
|
|
|
556
|
-
#### 5
|
|
546
|
+
#### 5\. Upsert Files
|
|
557
547
|
|
|
558
548
|
**POST** `/upsert`
|
|
559
549
|
|
|
560
|
-
Create or update files in the project.
|
|
550
|
+
Create or update files in the project. If `onUpsertCommand` is configured, it will be executed after a successful upsert.
|
|
561
551
|
|
|
562
552
|
**Request Body:**
|
|
553
|
+
|
|
563
554
|
```json
|
|
564
555
|
{
|
|
565
556
|
"basePath": "./",
|
|
@@ -577,6 +568,7 @@ Create or update files in the project.
|
|
|
577
568
|
```
|
|
578
569
|
|
|
579
570
|
**Response:**
|
|
571
|
+
|
|
580
572
|
```json
|
|
581
573
|
{
|
|
582
574
|
"success": true,
|
|
@@ -598,6 +590,7 @@ Create or update files in the project.
|
|
|
598
590
|
```
|
|
599
591
|
|
|
600
592
|
**Example:**
|
|
593
|
+
|
|
601
594
|
```bash
|
|
602
595
|
curl -X POST http://localhost:9876/upsert \
|
|
603
596
|
-H "Content-Type: application/json" \
|
|
@@ -611,11 +604,45 @@ curl -X POST http://localhost:9876/upsert \
|
|
|
611
604
|
}'
|
|
612
605
|
```
|
|
613
606
|
|
|
614
|
-
|
|
607
|
+
-----
|
|
608
|
+
|
|
609
|
+
#### 6\. Get Command Output
|
|
610
|
+
|
|
611
|
+
**GET** `/command-output`
|
|
612
|
+
|
|
613
|
+
Retrieves the result (stdout/stderr) of the last executed command triggered by an upsert operation. Requires `onUpsertCommand` to be set in configuration.
|
|
614
|
+
|
|
615
|
+
**Response:**
|
|
616
|
+
|
|
617
|
+
```json
|
|
618
|
+
{
|
|
619
|
+
"timestamp": "2026-02-13T12:30:00.000Z",
|
|
620
|
+
"command": "npm run build",
|
|
621
|
+
"output": "Build successful...",
|
|
622
|
+
"error": null,
|
|
623
|
+
"success": true
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
OR (if no command was executed):
|
|
628
|
+
|
|
629
|
+
```json
|
|
630
|
+
{
|
|
631
|
+
"status": "no_command_executed"
|
|
632
|
+
}
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
**Example:**
|
|
636
|
+
|
|
637
|
+
```bash
|
|
638
|
+
curl http://localhost:9876/command-output
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
-----
|
|
615
642
|
|
|
616
643
|
## 💡 Use Cases
|
|
617
644
|
|
|
618
|
-
### 1
|
|
645
|
+
### 1\. AI Code Analysis
|
|
619
646
|
|
|
620
647
|
Prepare your entire codebase for AI analysis:
|
|
621
648
|
|
|
@@ -628,7 +655,7 @@ cat for-ai.txt | pbcopy # macOS
|
|
|
628
655
|
cat for-ai.txt | xclip # Linux
|
|
629
656
|
```
|
|
630
657
|
|
|
631
|
-
### 2
|
|
658
|
+
### 2\. Code Review Context
|
|
632
659
|
|
|
633
660
|
Generate context for code reviews:
|
|
634
661
|
|
|
@@ -637,38 +664,31 @@ Generate context for code reviews:
|
|
|
637
664
|
codemerge use ./src --output review-context.txt --ignore "*.test.ts,*.spec.js"
|
|
638
665
|
```
|
|
639
666
|
|
|
640
|
-
### 3
|
|
667
|
+
### 3\. Documentation Generation
|
|
641
668
|
|
|
642
669
|
Create documentation snapshots:
|
|
643
670
|
|
|
644
671
|
```bash
|
|
645
672
|
# Include docs and source
|
|
646
|
-
codemerge use --include "
|
|
673
|
+
codemerge use --include "***.ts" --output docs-snapshot.txt
|
|
647
674
|
```
|
|
648
675
|
|
|
649
|
-
### 4
|
|
676
|
+
### 4\. AI-Powered Developer Tools
|
|
650
677
|
|
|
651
678
|
Build tools that need dynamic project access:
|
|
652
679
|
|
|
653
680
|
```javascript
|
|
654
|
-
// Get project structure
|
|
655
681
|
const structure = await fetch('http://localhost:9876/structure').then(r => r.json());
|
|
656
|
-
|
|
657
|
-
// Let user select files in UI
|
|
658
682
|
const selectedPaths = userSelection;
|
|
659
|
-
|
|
660
|
-
// Get only selected content
|
|
661
683
|
const content = await fetch('http://localhost:9876/selective-content', {
|
|
662
684
|
method: 'POST',
|
|
663
685
|
headers: { 'Content-Type': 'application/json' },
|
|
664
686
|
body: JSON.stringify({ selectedPaths })
|
|
665
687
|
}).then(r => r.text());
|
|
666
|
-
|
|
667
|
-
// Send to AI
|
|
668
688
|
await sendToAI(content);
|
|
669
689
|
```
|
|
670
690
|
|
|
671
|
-
### 5
|
|
691
|
+
### 5\. Continuous Context Updates
|
|
672
692
|
|
|
673
693
|
Watch mode for real-time updates:
|
|
674
694
|
|
|
@@ -683,7 +703,7 @@ while true; do
|
|
|
683
703
|
done
|
|
684
704
|
```
|
|
685
705
|
|
|
686
|
-
### 6
|
|
706
|
+
### 6\. Multi-Project Monitoring
|
|
687
707
|
|
|
688
708
|
Monitor multiple projects:
|
|
689
709
|
|
|
@@ -698,25 +718,22 @@ cd ~/project2 && codemerge watch --port 9002
|
|
|
698
718
|
cd ~/project3 && codemerge watch --port 9003
|
|
699
719
|
```
|
|
700
720
|
|
|
701
|
-
|
|
721
|
+
-----
|
|
702
722
|
|
|
703
723
|
## 🔧 Advanced Usage
|
|
704
724
|
|
|
705
725
|
### Custom Patterns
|
|
706
726
|
|
|
707
727
|
#### Include TypeScript Only
|
|
728
|
+
|
|
708
729
|
```bash
|
|
709
|
-
codemerge use --include "
|
|
730
|
+
codemerge use --include "***.tsx"
|
|
710
731
|
```
|
|
711
732
|
|
|
712
733
|
#### Exclude Tests and Configs
|
|
713
|
-
```bash
|
|
714
|
-
codemerge use --ignore "**/*.test.ts,**/*.spec.js,**/*.config.js"
|
|
715
|
-
```
|
|
716
734
|
|
|
717
|
-
#### Specific Directories
|
|
718
735
|
```bash
|
|
719
|
-
codemerge use --
|
|
736
|
+
codemerge use --ignore "***.spec.js,***.ts,lib*.ts"
|
|
720
737
|
```
|
|
721
738
|
|
|
722
739
|
### Combining Options
|
|
@@ -726,168 +743,33 @@ codemerge use \
|
|
|
726
743
|
./backend \
|
|
727
744
|
--output backend-code.txt \
|
|
728
745
|
--watch \
|
|
729
|
-
--ignore "
|
|
730
|
-
--include "**/*.ts,**/*.js"
|
|
731
|
-
```
|
|
732
|
-
|
|
733
|
-
### Environment-Specific Configs
|
|
734
|
-
|
|
735
|
-
Create multiple config files:
|
|
736
|
-
|
|
737
|
-
**codemerge.dev.json:**
|
|
738
|
-
```json
|
|
739
|
-
{
|
|
740
|
-
"outputPath": "dev-merged.txt",
|
|
741
|
-
"includePatterns": ["**/*.ts", "**/*.tsx"]
|
|
742
|
-
}
|
|
743
|
-
```
|
|
744
|
-
|
|
745
|
-
**codemerge.prod.json:**
|
|
746
|
-
```json
|
|
747
|
-
{
|
|
748
|
-
"outputPath": "prod-merged.txt",
|
|
749
|
-
"ignorePatterns": ["**/*.test.ts", "**/*.dev.ts"]
|
|
750
|
-
}
|
|
751
|
-
```
|
|
752
|
-
|
|
753
|
-
Use with symbolic links:
|
|
754
|
-
```bash
|
|
755
|
-
ln -sf codemerge.dev.json codemerge.json
|
|
756
|
-
codemerge use
|
|
757
|
-
```
|
|
758
|
-
|
|
759
|
-
### Scripting
|
|
760
|
-
|
|
761
|
-
**package.json:**
|
|
762
|
-
```json
|
|
763
|
-
{
|
|
764
|
-
"scripts": {
|
|
765
|
-
"merge": "codemerge use",
|
|
766
|
-
"merge:watch": "codemerge use --watch",
|
|
767
|
-
"serve": "codemerge watch --port 3000",
|
|
768
|
-
"merge:src": "codemerge use ./src --output src-only.txt"
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
```
|
|
772
|
-
|
|
773
|
-
```bash
|
|
774
|
-
npm run merge
|
|
775
|
-
npm run serve
|
|
776
|
-
```
|
|
777
|
-
|
|
778
|
-
### CI/CD Integration
|
|
779
|
-
|
|
780
|
-
**GitHub Actions:**
|
|
781
|
-
```yaml
|
|
782
|
-
- name: Generate Code Context
|
|
783
|
-
run: |
|
|
784
|
-
npm install -g codemerge-cli
|
|
785
|
-
codemerge use --output code-context.txt
|
|
786
|
-
|
|
787
|
-
- name: Upload Artifact
|
|
788
|
-
uses: actions/upload-artifact@v2
|
|
789
|
-
with:
|
|
790
|
-
name: code-context
|
|
791
|
-
path: code-context.txt
|
|
792
|
-
```
|
|
793
|
-
|
|
794
|
-
---
|
|
795
|
-
|
|
796
|
-
## 🐛 Troubleshooting
|
|
797
|
-
|
|
798
|
-
### Port Already in Use
|
|
799
|
-
|
|
800
|
-
```
|
|
801
|
-
Error: Port 9876 is already in use
|
|
802
|
-
```
|
|
803
|
-
|
|
804
|
-
**Solution:**
|
|
805
|
-
```bash
|
|
806
|
-
# Use different port
|
|
807
|
-
codemerge watch --port 8080
|
|
808
|
-
|
|
809
|
-
# Or find and kill the process
|
|
810
|
-
lsof -ti:9876 | xargs kill -9
|
|
811
|
-
```
|
|
812
|
-
|
|
813
|
-
### Large Output Files
|
|
814
|
-
|
|
815
|
-
If output is too large:
|
|
816
|
-
|
|
817
|
-
```bash
|
|
818
|
-
# Limit to specific directories
|
|
819
|
-
codemerge use ./src ./lib
|
|
820
|
-
|
|
821
|
-
# Exclude verbose files
|
|
822
|
-
codemerge use --ignore "**/*.json,**/*.lock,**/*.min.js"
|
|
746
|
+
--ignore "**migrations*.ts,***.ts", "***.test.ts", "***.json,***.min.js"
|
|
823
747
|
|
|
824
748
|
# Include only specific types
|
|
825
|
-
codemerge use --include "
|
|
826
|
-
```
|
|
827
|
-
|
|
828
|
-
### Files Not Being Merged
|
|
829
|
-
|
|
830
|
-
**Check .gitignore:**
|
|
831
|
-
```bash
|
|
832
|
-
# Disable gitignore checking
|
|
833
|
-
# Edit codemerge.json:
|
|
834
|
-
{
|
|
835
|
-
"useGitignore": false
|
|
836
|
-
}
|
|
837
|
-
```
|
|
838
|
-
|
|
839
|
-
**Check patterns:**
|
|
840
|
-
```bash
|
|
841
|
-
# Add debug logging (in code)
|
|
842
|
-
console.log('Include patterns:', includePatterns);
|
|
843
|
-
console.log('Ignore patterns:', ignorePatterns);
|
|
844
|
-
```
|
|
845
|
-
|
|
846
|
-
### Watch Not Detecting Changes
|
|
847
|
-
|
|
848
|
-
**Increase delay:**
|
|
849
|
-
Edit `codemerge.json`:
|
|
850
|
-
```json
|
|
851
|
-
{
|
|
852
|
-
"watchDelay": 3000
|
|
853
|
-
}
|
|
854
|
-
```
|
|
855
|
-
|
|
856
|
-
**Check file permissions:**
|
|
857
|
-
```bash
|
|
858
|
-
ls -la | grep codemerge
|
|
859
|
-
```
|
|
860
|
-
|
|
861
|
-
### Binary Files in Output
|
|
862
|
-
|
|
863
|
-
Binary files are automatically excluded. If you see them:
|
|
864
|
-
|
|
865
|
-
```bash
|
|
866
|
-
# Explicitly ignore
|
|
867
|
-
codemerge use --ignore "**/*.png,**/*.jpg,**/*.pdf"
|
|
749
|
+
codemerge use --include "***.png,***.pdf"
|
|
868
750
|
```
|
|
869
751
|
|
|
870
|
-
|
|
752
|
+
-----
|
|
871
753
|
|
|
872
754
|
## 📚 Additional Resources
|
|
873
755
|
|
|
874
|
-
- **GitHub:** [github.com/odutradev/codemerge-cli](https://github.com/odutradev/codemerge-cli)
|
|
875
|
-
- **Issues:** [Report bugs](https://github.com/odutradev/codemerge-cli/issues)
|
|
876
|
-
- **NPM:** [npmjs.com/package/codemerge-cli](https://www.npmjs.com/package/codemerge-cli)
|
|
756
|
+
- **GitHub:** [github.com/odutradev/codemerge-cli](https://github.com/odutradev/codemerge-cli)
|
|
757
|
+
- **Issues:** [Report bugs](https://github.com/odutradev/codemerge-cli/issues)
|
|
758
|
+
- **NPM:** [npmjs.com/package/codemerge-cli](https://www.npmjs.com/package/codemerge-cli)
|
|
877
759
|
|
|
878
|
-
|
|
760
|
+
-----
|
|
879
761
|
|
|
880
762
|
## 📝 License
|
|
881
763
|
|
|
882
|
-
MIT License - feel free to use in your projects
|
|
764
|
+
MIT License - feel free to use in your projects\!
|
|
883
765
|
|
|
884
|
-
|
|
766
|
+
-----
|
|
885
767
|
|
|
886
768
|
## 🤝 Contributing
|
|
887
769
|
|
|
888
|
-
Contributions welcome
|
|
770
|
+
Contributions welcome\! Please:
|
|
889
771
|
|
|
890
|
-
1.
|
|
891
|
-
2.
|
|
892
|
-
3.
|
|
893
|
-
4.
|
|
772
|
+
1. Fork the repository
|
|
773
|
+
2. Create a feature branch
|
|
774
|
+
3. Make your changes
|
|
775
|
+
4. Submit a pull request
|