codemerge-cli 1.3.7 → 1.3.9
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 +518 -516
- package/dist/commands/help/index.d.ts +0 -1
- package/dist/commands/help/index.d.ts.map +1 -1
- package/dist/commands/help/index.js +0 -6
- package/dist/commands/help/index.js.map +1 -1
- package/dist/commands/version/index.d.ts +0 -1
- package/dist/commands/version/index.d.ts.map +1 -1
- package/dist/commands/version/index.js +0 -6
- package/dist/commands/version/index.js.map +1 -1
- package/dist/utils/path.js +1 -1
- package/dist/utils/path.js.map +1 -1
- package/package.json +1 -1
- package/dist/commands/help.d.ts +0 -10
- package/dist/commands/help.d.ts.map +0 -1
- package/dist/commands/help.js +0 -45
- package/dist/commands/help.js.map +0 -1
- package/dist/commands/init.d.ts +0 -9
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -68
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/use.d.ts +0 -6
- package/dist/commands/use.d.ts.map +0 -1
- package/dist/commands/use.js +0 -60
- package/dist/commands/use.js.map +0 -1
- package/dist/commands/version.d.ts +0 -9
- package/dist/commands/version.d.ts.map +0 -1
- package/dist/commands/version.js +0 -26
- package/dist/commands/version.js.map +0 -1
- package/dist/commands/watch.d.ts +0 -9
- package/dist/commands/watch.d.ts.map +0 -1
- package/dist/commands/watch.js +0 -86
- package/dist/commands/watch.js.map +0 -1
- package/dist/core/httpServer.d.ts +0 -34
- package/dist/core/httpServer.d.ts.map +0 -1
- package/dist/core/httpServer.js +0 -376
- package/dist/core/httpServer.js.map +0 -1
- package/dist/utils/fileUtils.d.ts +0 -13
- package/dist/utils/fileUtils.d.ts.map +0 -1
- package/dist/utils/fileUtils.js +0 -61
- package/dist/utils/fileUtils.js.map +0 -1
- package/dist/utils/pathUtils.d.ts +0 -10
- package/dist/utils/pathUtils.d.ts.map +0 -1
- package/dist/utils/pathUtils.js +0 -29
- package/dist/utils/pathUtils.js.map +0 -1
- package/dist/utils/patternUtils.d.ts +0 -8
- package/dist/utils/patternUtils.d.ts.map +0 -1
- package/dist/utils/patternUtils.js +0 -90
- package/dist/utils/patternUtils.js.map +0 -1
- package/dist/utils/proccessCmd.d.ts +0 -4
- package/dist/utils/proccessCmd.d.ts.map +0 -1
- package/dist/utils/proccessCmd.js +0 -29
- package/dist/utils/proccessCmd.js.map +0 -1
- package/dist/utils/processUtils.d.ts +0 -4
- package/dist/utils/processUtils.d.ts.map +0 -1
- package/dist/utils/processUtils.js +0 -28
- package/dist/utils/processUtils.js.map +0 -1
- package/dist/utils/translateUtils.d.ts +0 -2
- package/dist/utils/translateUtils.d.ts.map +0 -1
- package/dist/utils/translateUtils.js +0 -29
- package/dist/utils/translateUtils.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,516 +1,518 @@
|
|
|
1
|
-
# CodeMerge CLI
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## 📋
|
|
6
|
-
|
|
7
|
-
- [
|
|
8
|
-
- [
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
11
|
-
- [
|
|
12
|
-
- [HTTP
|
|
13
|
-
- [
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
- **
|
|
28
|
-
- **
|
|
29
|
-
- **
|
|
30
|
-
- **
|
|
31
|
-
- **
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
- `-
|
|
147
|
-
-
|
|
148
|
-
- `--
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
- `-
|
|
168
|
-
-
|
|
169
|
-
- `--
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
- `GET /
|
|
175
|
-
- `GET /
|
|
176
|
-
- `
|
|
177
|
-
- `POST /
|
|
178
|
-
- `POST /
|
|
179
|
-
- `POST /
|
|
180
|
-
- `POST /
|
|
181
|
-
- `
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
"
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
-
"
|
|
217
|
-
"
|
|
218
|
-
"
|
|
219
|
-
|
|
220
|
-
"
|
|
221
|
-
"
|
|
222
|
-
"***.
|
|
223
|
-
"***.
|
|
224
|
-
"
|
|
225
|
-
"
|
|
226
|
-
".
|
|
227
|
-
"
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
- `
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
'***.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
"
|
|
258
|
-
"
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
"
|
|
340
|
-
"
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
"
|
|
368
|
-
"
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
"
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
"
|
|
411
|
-
"
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
"
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
"
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
- **
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
1
|
+
# CodeMerge CLI
|
|
2
|
+
|
|
3
|
+
Utilitário de preparação de código e dados focado em IA. Mescla múltiplos arquivos em uma única saída otimizada para janelas de contexto de IA, com API HTTP para geração dinâmica de conteúdo.
|
|
4
|
+
|
|
5
|
+
## 📋 Índice
|
|
6
|
+
|
|
7
|
+
- [Visão Geral](https://www.google.com/search?q=%23-vis%C3%A3o-geral)
|
|
8
|
+
- [Instalação](https://www.google.com/search?q=%23-instala%C3%A7%C3%A3o)
|
|
9
|
+
- [Início Rápido](https://www.google.com/search?q=%23-in%C3%ADcio-r%C3%A1pido)
|
|
10
|
+
- [Comandos](https://www.google.com/search?q=%23-comandos)
|
|
11
|
+
- [Configuração](https://www.google.com/search?q=%23%EF%B8%8F-configura%C3%A7%C3%A3o)
|
|
12
|
+
- [Servidor HTTP & API](https://www.google.com/search?q=%23-servidor-http--api)
|
|
13
|
+
- [Casos de Uso](https://www.google.com/search?q=%23-casos-de-uso)
|
|
14
|
+
- [Recursos Adicionais](https://www.google.com/search?q=%23-recursos-adicionais)
|
|
15
|
+
- [Licença](https://www.google.com/search?q=%23-licen%C3%A7a)
|
|
16
|
+
- [Contribuindo](https://www.google.com/search?q=%23-contribuindo)
|
|
17
|
+
|
|
18
|
+
-----
|
|
19
|
+
|
|
20
|
+
## 🎯 Visão Geral
|
|
21
|
+
|
|
22
|
+
CodeMerge é uma ferramenta de linha de comando (CLI) que:
|
|
23
|
+
|
|
24
|
+
- **Mescla** múltiplos arquivos de código em um único arquivo de texto estruturado
|
|
25
|
+
- **Otimiza** a saída para ferramentas de IA (ChatGPT, Claude, etc.)
|
|
26
|
+
- **Respeita** os padrões do `.gitignore` e regras de ignorar personalizadas
|
|
27
|
+
- **Observa** alterações de arquivos e os regenera automaticamente
|
|
28
|
+
- **Serve** conteúdo via API HTTP para acesso dinâmico
|
|
29
|
+
- **Fornece** visualização da estrutura do projeto em JSON
|
|
30
|
+
- **Permite** a mesclagem seletiva de arquivos via API
|
|
31
|
+
- **Executa** comandos do sistema após atualizações de arquivos (hooks de Upsert) e na inicialização
|
|
32
|
+
- **Gerencia** exclusões de arquivos e commits locais do git via API
|
|
33
|
+
|
|
34
|
+
Perfeito para:
|
|
35
|
+
|
|
36
|
+
- Preparar bases de código para análise de IA
|
|
37
|
+
- Gerar contexto para revisões de código
|
|
38
|
+
- Criar snapshots de documentação
|
|
39
|
+
- Compartilhar a estrutura do projeto com assistentes de IA
|
|
40
|
+
- Construir ferramentas de desenvolvedor alimentadas por IA
|
|
41
|
+
|
|
42
|
+
-----
|
|
43
|
+
|
|
44
|
+
## 📦 Instalação
|
|
45
|
+
|
|
46
|
+
### Instalação Global (Recomendada)
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install -g codemerge-cli
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Instalação Local no Projeto
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install --save-dev codemerge-cli
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Requisitos
|
|
59
|
+
|
|
60
|
+
- Node.js \>= 16.0.0
|
|
61
|
+
|
|
62
|
+
-----
|
|
63
|
+
|
|
64
|
+
## 🚀 Início Rápido
|
|
65
|
+
|
|
66
|
+
### 1\. Inicializar o Projeto
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
codemerge init
|
|
70
|
+
|
|
71
|
+
codemerge init ./meu-projeto
|
|
72
|
+
|
|
73
|
+
codemerge init --force
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Isso cria:
|
|
77
|
+
|
|
78
|
+
- `codemerge.json` - Arquivo de configuração
|
|
79
|
+
- Atualiza o `.gitignore` - Adiciona o arquivo de saída
|
|
80
|
+
|
|
81
|
+
### 2\. Mesclar Arquivos
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
codemerge use
|
|
85
|
+
|
|
86
|
+
codemerge use ./src
|
|
87
|
+
|
|
88
|
+
codemerge use --output meu-codigo.txt
|
|
89
|
+
|
|
90
|
+
codemerge use --watch
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 3\. Iniciar Servidor HTTP
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
codemerge watch
|
|
97
|
+
|
|
98
|
+
codemerge watch --port 3000
|
|
99
|
+
|
|
100
|
+
codemerge watch --output api-codigo.txt --ignore "*.test.ts"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
-----
|
|
104
|
+
|
|
105
|
+
## 🎮 Comandos
|
|
106
|
+
|
|
107
|
+
### `codemerge init`
|
|
108
|
+
|
|
109
|
+
Inicializa o CodeMerge em um projeto.
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
codemerge init [caminho] [opções]
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Argumentos:**
|
|
116
|
+
|
|
117
|
+
- `caminho` - Diretório de destino (padrão: `.`)
|
|
118
|
+
|
|
119
|
+
**Opções:**
|
|
120
|
+
|
|
121
|
+
- `-f, --force` - Sobrescrever a configuração existente
|
|
122
|
+
|
|
123
|
+
**O que faz:**
|
|
124
|
+
|
|
125
|
+
- Cria o `codemerge.json` com configurações padrão
|
|
126
|
+
- Detecta o nome do projeto a partir do `package.json`
|
|
127
|
+
- Adiciona o arquivo de saída ao `.gitignore`
|
|
128
|
+
- Configura padrões recomendados de ignorar
|
|
129
|
+
|
|
130
|
+
-----
|
|
131
|
+
|
|
132
|
+
### `codemerge use`
|
|
133
|
+
|
|
134
|
+
Mescla os arquivos de código em uma única saída.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
codemerge use [caminho] [opções]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Argumentos:**
|
|
141
|
+
|
|
142
|
+
- `caminho` - Diretório de entrada para verificar (padrão: `.`)
|
|
143
|
+
|
|
144
|
+
**Opções:**
|
|
145
|
+
|
|
146
|
+
- `-o, --output <caminho>` - Caminho de arquivo de saída personalizado
|
|
147
|
+
- `-w, --watch` - Observar alterações de arquivos
|
|
148
|
+
- `--ignore <padroes>` - Padrões adicionais para ignorar (separados por vírgula)
|
|
149
|
+
- `--include <padroes>` - Padrões de inclusão (separados por vírgula)
|
|
150
|
+
|
|
151
|
+
-----
|
|
152
|
+
|
|
153
|
+
### `codemerge watch`
|
|
154
|
+
|
|
155
|
+
Inicia o servidor HTTP observando os arquivos.
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
codemerge watch [caminho] [opções]
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Argumentos:**
|
|
162
|
+
|
|
163
|
+
- `caminho` - Diretório de entrada para verificar (padrão: `.`)
|
|
164
|
+
|
|
165
|
+
**Opções:**
|
|
166
|
+
|
|
167
|
+
- `-o, --output <caminho>` - Caminho do arquivo de saída
|
|
168
|
+
- `-p, --port <numero>` - Porta do servidor (padrão: `9876`)
|
|
169
|
+
- `--ignore <padroes>` - Padrões adicionais para ignorar
|
|
170
|
+
- `--include <padroes>` - Padrões de inclusão
|
|
171
|
+
|
|
172
|
+
**Endpoints do Servidor:**
|
|
173
|
+
|
|
174
|
+
- `GET /health` - Status de integridade do servidor
|
|
175
|
+
- `GET /content` - Conteúdo completo mesclado
|
|
176
|
+
- `GET /structure` - Estrutura do projeto em JSON
|
|
177
|
+
- `POST /selective-content` - Mesclar arquivos selecionados
|
|
178
|
+
- `POST /upsert` - Criar/atualizar arquivos
|
|
179
|
+
- `POST /delete-files` - Excluir arquivos específicos
|
|
180
|
+
- `POST /commit` - Executar commit local do git
|
|
181
|
+
- `POST /execute-commands` - Executar comandos arbitrários do sistema
|
|
182
|
+
- `GET /command-output` - Obter saída do último comando pós-upsert executado
|
|
183
|
+
|
|
184
|
+
-----
|
|
185
|
+
|
|
186
|
+
### `codemerge help`
|
|
187
|
+
|
|
188
|
+
Exibe informações de ajuda.
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
codemerge help [comando]
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
-----
|
|
195
|
+
|
|
196
|
+
### `codemerge version`
|
|
197
|
+
|
|
198
|
+
Exibe informações da versão.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
codemerge version
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
-----
|
|
205
|
+
|
|
206
|
+
## ⚙️ Configuração
|
|
207
|
+
|
|
208
|
+
### Arquivo de Configuração: `codemerge.json`
|
|
209
|
+
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"projectName": "meu-projeto",
|
|
213
|
+
"outputPath": "merged-output.txt",
|
|
214
|
+
"port": 9876,
|
|
215
|
+
"useGitignore": true,
|
|
216
|
+
"onStartCommand": "npm run dev",
|
|
217
|
+
"onStartCommandLogs": false,
|
|
218
|
+
"onUpsertCommand": "npm run build",
|
|
219
|
+
"ignorePatterns": [
|
|
220
|
+
"node_modules*.log",
|
|
221
|
+
"coverage*.ts",
|
|
222
|
+
"***.tsx",
|
|
223
|
+
"***.json",
|
|
224
|
+
"***.log",
|
|
225
|
+
"package-lock.json",
|
|
226
|
+
"yarn.lock",
|
|
227
|
+
".env",
|
|
228
|
+
"**/.DS_Store"
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Comandos de Ciclo de Vida:**
|
|
234
|
+
|
|
235
|
+
- `onStartCommand`: Comando para executar automaticamente quando o servidor/observador do codemerge iniciar.
|
|
236
|
+
- `onStartCommandLogs`: Flag booleana para exibir os logs do comando de inicialização no console.
|
|
237
|
+
- `onUpsertCommand`: Comando shell para executar imediatamente após um POST bem-sucedido em `/upsert`.
|
|
238
|
+
|
|
239
|
+
### Padrões de Inclusão Padrão
|
|
240
|
+
|
|
241
|
+
```javascript
|
|
242
|
+
[
|
|
243
|
+
'***.js',
|
|
244
|
+
'***.jsx',
|
|
245
|
+
'***.md'
|
|
246
|
+
]
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Alternativa: Configuração via `package.json`
|
|
250
|
+
|
|
251
|
+
Você também pode configurar no `package.json`:
|
|
252
|
+
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"name": "meu-projeto",
|
|
256
|
+
"codemergeConfig": {
|
|
257
|
+
"outputPath": "ai-digest.txt",
|
|
258
|
+
"onStartCommand": "npm start",
|
|
259
|
+
"onUpsertCommand": "echo 'Upsert concluído'",
|
|
260
|
+
"ignorePatterns": ["***.ts"]
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
-----
|
|
266
|
+
|
|
267
|
+
## 🌐 Servidor HTTP & API
|
|
268
|
+
|
|
269
|
+
### Iniciando o Servidor
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
codemerge watch --port 9876
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Endpoints da API
|
|
276
|
+
|
|
277
|
+
#### 1\. Verificação de Integridade (Health Check)
|
|
278
|
+
|
|
279
|
+
**GET** `/health`
|
|
280
|
+
|
|
281
|
+
Verifica o status do servidor.
|
|
282
|
+
|
|
283
|
+
-----
|
|
284
|
+
|
|
285
|
+
#### 2\. Obter Conteúdo Mesclado
|
|
286
|
+
|
|
287
|
+
**GET** `/content`
|
|
288
|
+
|
|
289
|
+
Obtém o conteúdo completo mesclado de todos os arquivos.
|
|
290
|
+
|
|
291
|
+
-----
|
|
292
|
+
|
|
293
|
+
#### 3\. Obter Estrutura do Projeto
|
|
294
|
+
|
|
295
|
+
**GET** `/structure`
|
|
296
|
+
|
|
297
|
+
Obtém a estrutura do projeto como uma árvore JSON.
|
|
298
|
+
|
|
299
|
+
-----
|
|
300
|
+
|
|
301
|
+
#### 4\. Obter Conteúdo Seletivo
|
|
302
|
+
|
|
303
|
+
**POST** `/selective-content`
|
|
304
|
+
|
|
305
|
+
Mescla apenas arquivos/pastas selecionados.
|
|
306
|
+
|
|
307
|
+
-----
|
|
308
|
+
|
|
309
|
+
#### 5\. Inserir/Atualizar Arquivos (Upsert)
|
|
310
|
+
|
|
311
|
+
**POST** `/upsert`
|
|
312
|
+
|
|
313
|
+
Cria ou atualiza arquivos no projeto. Se `onUpsertCommand` estiver configurado, ele será executado após um upsert bem-sucedido.
|
|
314
|
+
|
|
315
|
+
-----
|
|
316
|
+
|
|
317
|
+
#### 6\. Excluir Arquivos
|
|
318
|
+
|
|
319
|
+
**POST** `/delete-files`
|
|
320
|
+
|
|
321
|
+
Exclui arquivos específicos do projeto.
|
|
322
|
+
|
|
323
|
+
**Corpo da Requisição:**
|
|
324
|
+
|
|
325
|
+
```json
|
|
326
|
+
{
|
|
327
|
+
"basePath": "./",
|
|
328
|
+
"files": [
|
|
329
|
+
"src/arquivo-obsoleto.ts",
|
|
330
|
+
"tests/teste-antigo.spec.ts"
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**Resposta:**
|
|
336
|
+
|
|
337
|
+
```json
|
|
338
|
+
{
|
|
339
|
+
"success": true,
|
|
340
|
+
"filesProcessed": 2,
|
|
341
|
+
"errors": [],
|
|
342
|
+
"results": [
|
|
343
|
+
{
|
|
344
|
+
"path": "src/arquivo-obsoleto.ts",
|
|
345
|
+
"success": true
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"path": "tests/teste-antigo.spec.ts",
|
|
349
|
+
"success": true
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
-----
|
|
356
|
+
|
|
357
|
+
#### 7\. Commit Local do Git
|
|
358
|
+
|
|
359
|
+
**POST** `/commit`
|
|
360
|
+
|
|
361
|
+
Executa um commit local do git para todas as alterações no diretório atual (`git add .` seguido de `git commit -m "tipo: mensagem"`).
|
|
362
|
+
|
|
363
|
+
**Corpo da Requisição:**
|
|
364
|
+
|
|
365
|
+
```json
|
|
366
|
+
{
|
|
367
|
+
"basePath": "./",
|
|
368
|
+
"type": "feat",
|
|
369
|
+
"message": "adiciona novos endpoints dinâmicos para gerenciamento do servidor",
|
|
370
|
+
"translate": false
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
*Nota: As propriedades `type` e `message` são explicitamente obrigatórias. A flag booleana `translate` é opcional.*
|
|
375
|
+
|
|
376
|
+
**Resposta:**
|
|
377
|
+
|
|
378
|
+
```json
|
|
379
|
+
{
|
|
380
|
+
"success": true,
|
|
381
|
+
"output": "[main 4c83b2a] feat: adiciona novos endpoints dinâmicos para gerenciamento do servidor\n 2 files changed, 45 insertions(+)",
|
|
382
|
+
"error": null
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
-----
|
|
387
|
+
|
|
388
|
+
#### 8\. Executar Comandos
|
|
389
|
+
|
|
390
|
+
**POST** `/execute-commands`
|
|
391
|
+
|
|
392
|
+
Executa comandos arbitrários do sistema no diretório do projeto.
|
|
393
|
+
|
|
394
|
+
**Corpo da Requisição:**
|
|
395
|
+
|
|
396
|
+
```json
|
|
397
|
+
{
|
|
398
|
+
"basePath": "./",
|
|
399
|
+
"commandsToExecute": [
|
|
400
|
+
"npm run lint",
|
|
401
|
+
"npm test"
|
|
402
|
+
]
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**Resposta:**
|
|
407
|
+
|
|
408
|
+
```json
|
|
409
|
+
{
|
|
410
|
+
"success": true,
|
|
411
|
+
"commandsProcessed": 2,
|
|
412
|
+
"errors": [],
|
|
413
|
+
"results": [
|
|
414
|
+
{
|
|
415
|
+
"command": "npm run lint",
|
|
416
|
+
"success": true,
|
|
417
|
+
"output": "..."
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"command": "npm test",
|
|
421
|
+
"success": true,
|
|
422
|
+
"output": "..."
|
|
423
|
+
}
|
|
424
|
+
]
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
-----
|
|
429
|
+
|
|
430
|
+
#### 9\. Obter Saída de Comando
|
|
431
|
+
|
|
432
|
+
**GET** `/command-output`
|
|
433
|
+
|
|
434
|
+
Recupera o resultado (stdout/stderr) do último comando executado, acionado por uma operação de upsert. Requer que `onUpsertCommand` esteja definido na configuração.
|
|
435
|
+
|
|
436
|
+
-----
|
|
437
|
+
|
|
438
|
+
## 💡 Casos de Uso
|
|
439
|
+
|
|
440
|
+
### 1\. Análise de Código por IA
|
|
441
|
+
|
|
442
|
+
Prepare toda a sua base de código para análise de IA:
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
codemerge use --output para-ia.txt
|
|
446
|
+
|
|
447
|
+
cat para-ia.txt | pbcopy # macOS
|
|
448
|
+
cat para-ia.txt | xclip # Linux
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### 2\. Contexto para Revisão de Código
|
|
452
|
+
|
|
453
|
+
Gere contexto para revisões de código:
|
|
454
|
+
|
|
455
|
+
```bash
|
|
456
|
+
codemerge use ./src --output contexto-revisao.txt --ignore "*.test.ts,*.spec.js"
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### 3\. Geração de Documentação
|
|
460
|
+
|
|
461
|
+
Crie snapshots da documentação:
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
codemerge use --include "***.ts" --output snapshot-docs.txt
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### 4\. Ferramentas de Desenvolvedor Baseadas em IA
|
|
468
|
+
|
|
469
|
+
Construa ferramentas que precisem de acesso dinâmico ao projeto:
|
|
470
|
+
|
|
471
|
+
```javascript
|
|
472
|
+
const structure = await fetch('http://localhost:9876/structure').then(r => r.json());
|
|
473
|
+
const selectedPaths = userSelection;
|
|
474
|
+
const content = await fetch('http://localhost:9876/selective-content', {
|
|
475
|
+
method: 'POST',
|
|
476
|
+
headers: { 'Content-Type': 'application/json' },
|
|
477
|
+
body: JSON.stringify({ selectedPaths })
|
|
478
|
+
}).then(r => r.text());
|
|
479
|
+
await sendToAI(content);
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### 5\. Atualizações Contínuas de Contexto
|
|
483
|
+
|
|
484
|
+
Modo de observação para atualizações em tempo real:
|
|
485
|
+
|
|
486
|
+
```bash
|
|
487
|
+
codemerge watch --port 3000
|
|
488
|
+
|
|
489
|
+
while true; do
|
|
490
|
+
curl http://localhost:3000/content > mais-recente.txt
|
|
491
|
+
sleep 5
|
|
492
|
+
done
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
-----
|
|
496
|
+
|
|
497
|
+
## 📚 Recursos Adicionais
|
|
498
|
+
|
|
499
|
+
- **GitHub:** [github.com/odutradev/codemerge-cli](https://github.com/odutradev/codemerge-cli)
|
|
500
|
+
- **Issues:** [Reportar bugs](https://github.com/odutradev/codemerge-cli/issues)
|
|
501
|
+
- **NPM:** [npmjs.com/package/codemerge-cli](https://www.npmjs.com/package/codemerge-cli)
|
|
502
|
+
|
|
503
|
+
-----
|
|
504
|
+
|
|
505
|
+
## 📝 Licença
|
|
506
|
+
|
|
507
|
+
Licença MIT - sinta-se à vontade para usar em seus projetos\!
|
|
508
|
+
|
|
509
|
+
-----
|
|
510
|
+
|
|
511
|
+
## 🤝 Contribuindo
|
|
512
|
+
|
|
513
|
+
Contribuições são bem-vindas\! Por favor:
|
|
514
|
+
|
|
515
|
+
1. Faça um fork do repositório
|
|
516
|
+
2. Crie uma branch de funcionalidade
|
|
517
|
+
3. Faça suas alterações
|
|
518
|
+
4. Envie um pull request
|