codemerge-cli 1.3.8 → 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.
Files changed (2) hide show
  1. package/README.md +518 -516
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,516 +1,518 @@
1
- # CodeMerge CLI
2
-
3
- AI-focused code and data preparation utility. Merge multiple files into a single output optimized for AI context windows, with HTTP API for dynamic content generation.
4
-
5
- ## 📋 Table of Contents
6
-
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
-
19
- ## 🎯 Overview
20
-
21
- CodeMerge is a CLI tool that:
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
30
- - **Executes** system commands upon file updates (Upsert hooks) and initialization
31
- - **Manages** file deletions and local git commits via API
32
-
33
- Perfect for:
34
-
35
- - Preparing codebases for AI analysis
36
- - Generating context for code reviews
37
- - Creating documentation snapshots
38
- - Sharing project structure with AI assistants
39
- - Building AI-powered developer tools
40
-
41
- -----
42
-
43
- ## 📦 Installation
44
-
45
- ### Global Installation (Recommended)
46
-
47
- ```bash
48
- npm install -g codemerge-cli
49
- ```
50
-
51
- ### Local Project Installation
52
-
53
- ```bash
54
- npm install --save-dev codemerge-cli
55
- ```
56
-
57
- ### Requirements
58
-
59
- - Node.js >= 16.0.0
60
-
61
- -----
62
-
63
- ## 🚀 Quick Start
64
-
65
- ### 1. Initialize Project
66
-
67
- ```bash
68
- codemerge init
69
-
70
- codemerge init ./my-project
71
-
72
- codemerge init --force
73
- ```
74
-
75
- This creates:
76
-
77
- - `codemerge.json` - Configuration file
78
- - Updates `.gitignore` - Adds output file
79
-
80
- ### 2. Merge Files
81
-
82
- ```bash
83
- codemerge use
84
-
85
- codemerge use ./src
86
-
87
- codemerge use --output my-code.txt
88
-
89
- codemerge use --watch
90
- ```
91
-
92
- ### 3. Start HTTP Server
93
-
94
- ```bash
95
- codemerge watch
96
-
97
- codemerge watch --port 3000
98
-
99
- codemerge watch --output api-code.txt --ignore "*.test.ts"
100
- ```
101
-
102
- -----
103
-
104
- ## 🎮 Commands
105
-
106
- ### `codemerge init`
107
-
108
- Initialize CodeMerge in a project.
109
-
110
- ```bash
111
- codemerge init [path] [options]
112
- ```
113
-
114
- **Arguments:**
115
-
116
- - `path` - Target directory (default: `.`)
117
-
118
- **Options:**
119
-
120
- - `-f, --force` - Overwrite existing configuration
121
-
122
- **What it does:**
123
-
124
- - Creates `codemerge.json` with default settings
125
- - Detects project name from `package.json`
126
- - Adds output file to `.gitignore`
127
- - Sets up recommended ignore patterns
128
-
129
- -----
130
-
131
- ### `codemerge use`
132
-
133
- Merge code files into a single output.
134
-
135
- ```bash
136
- codemerge use [path] [options]
137
- ```
138
-
139
- **Arguments:**
140
-
141
- - `path` - Input directory to scan (default: `.`)
142
-
143
- **Options:**
144
-
145
- - `-o, --output <path>` - Custom output file path
146
- - `-w, --watch` - Watch for file changes
147
- - `--ignore <patterns>` - Additional ignore patterns (comma-separated)
148
- - `--include <patterns>` - Include patterns (comma-separated)
149
-
150
- -----
151
-
152
- ### `codemerge watch`
153
-
154
- Start HTTP server with file watching.
155
-
156
- ```bash
157
- codemerge watch [path] [options]
158
- ```
159
-
160
- **Arguments:**
161
-
162
- - `path` - Input directory to scan (default: `.`)
163
-
164
- **Options:**
165
-
166
- - `-o, --output <path>` - Output file path
167
- - `-p, --port <number>` - Server port (default: `9876`)
168
- - `--ignore <patterns>` - Additional ignore patterns
169
- - `--include <patterns>` - Include patterns
170
-
171
- **Server Endpoints:**
172
-
173
- - `GET /health` - Server health status
174
- - `GET /content` - Full merged content
175
- - `GET /structure` - Project structure JSON
176
- - `POST /selective-content` - Merge selected files
177
- - `POST /upsert` - Create/update files
178
- - `POST /delete-files` - Delete specific files
179
- - `POST /commit` - Execute local git commit
180
- - `POST /execute-commands` - Execute arbitrary system commands
181
- - `GET /command-output` - Get output of the last post-upsert command
182
-
183
- -----
184
-
185
- ### `codemerge help`
186
-
187
- Display help information.
188
-
189
- ```bash
190
- codemerge help [command]
191
- ```
192
-
193
- -----
194
-
195
- ### `codemerge version`
196
-
197
- Display version information.
198
-
199
- ```bash
200
- codemerge version
201
- ```
202
-
203
- -----
204
-
205
- ## ⚙️ Configuration
206
-
207
- ### Configuration File: `codemerge.json`
208
-
209
- ```json
210
- {
211
- "projectName": "my-project",
212
- "outputPath": "merged-output.txt",
213
- "port": 9876,
214
- "useGitignore": true,
215
- "onStartCommand": "npm run dev",
216
- "onStartCommandLogs": false,
217
- "onUpsertCommand": "npm run build",
218
- "ignorePatterns": [
219
- "node_modules*.log",
220
- "coverage*.ts",
221
- "***.tsx",
222
- "***.json",
223
- "***.log",
224
- "package-lock.json",
225
- "yarn.lock",
226
- ".env",
227
- "**/.DS_Store"
228
- ]
229
- }
230
- ```
231
-
232
- **Lifecycle Commands:**
233
- - `onStartCommand`: Command to run automatically when the codemerge server/watcher starts.
234
- - `onStartCommandLogs`: Boolean flag to display the logs of the start command in the console.
235
- - `onUpsertCommand`: Shell command to execute immediately after a successful POST to `/upsert`.
236
-
237
- ### Default Include Patterns
238
-
239
- ```javascript
240
- [
241
- '***.js',
242
- '***.jsx',
243
- '***.md'
244
- ]
245
- ```
246
-
247
- ### Alternative: package.json Configuration
248
-
249
- You can also configure in `package.json`:
250
-
251
- ```json
252
- {
253
- "name": "my-project",
254
- "codemergeConfig": {
255
- "outputPath": "ai-digest.txt",
256
- "onStartCommand": "npm start",
257
- "onUpsertCommand": "echo 'Upsert complete'",
258
- "ignorePatterns": ["***.ts"]
259
- }
260
- }
261
- ```
262
-
263
- -----
264
-
265
- ## 🌐 HTTP Server & API
266
-
267
- ### Starting the Server
268
-
269
- ```bash
270
- codemerge watch --port 9876
271
- ```
272
-
273
- ### API Endpoints
274
-
275
- #### 1. Health Check
276
-
277
- **GET** `/health`
278
-
279
- Check server status.
280
-
281
- -----
282
-
283
- #### 2. Get Merged Content
284
-
285
- **GET** `/content`
286
-
287
- Get full merged content of all files.
288
-
289
- -----
290
-
291
- #### 3. Get Project Structure
292
-
293
- **GET** `/structure`
294
-
295
- Get project structure as JSON tree.
296
-
297
- -----
298
-
299
- #### 4. Get Selective Content
300
-
301
- **POST** `/selective-content`
302
-
303
- Merge only selected files/folders.
304
-
305
- -----
306
-
307
- #### 5. Upsert Files
308
-
309
- **POST** `/upsert`
310
-
311
- Create or update files in the project. If `onUpsertCommand` is configured, it will be executed after a successful upsert.
312
-
313
- -----
314
-
315
- #### 6. Delete Files
316
-
317
- **POST** `/delete-files`
318
-
319
- Delete specific files from the project.
320
-
321
- **Request Body:**
322
-
323
- ```json
324
- {
325
- "basePath": "./",
326
- "files": [
327
- "src/obsolete-file.ts",
328
- "tests/old-test.spec.ts"
329
- ]
330
- }
331
- ```
332
-
333
- **Response:**
334
-
335
- ```json
336
- {
337
- "success": true,
338
- "filesProcessed": 2,
339
- "errors": [],
340
- "results": [
341
- {
342
- "path": "src/obsolete-file.ts",
343
- "success": true
344
- },
345
- {
346
- "path": "tests/old-test.spec.ts",
347
- "success": true
348
- }
349
- ]
350
- }
351
- ```
352
-
353
- -----
354
-
355
- #### 7. Local Git Commit
356
-
357
- **POST** `/commit`
358
-
359
- Execute a local git commit for all changes in the current directory (`git add .` followed by `git commit -m "type: message"`).
360
-
361
- **Request Body:**
362
-
363
- ```json
364
- {
365
- "basePath": "./",
366
- "type": "feat",
367
- "message": "add new dynamic endpoints for server management",
368
- "translate": false
369
- }
370
- ```
371
-
372
- *Note: The `type` and `message` properties are explicitly required. The `translate` boolean flag is optional.*
373
-
374
- **Response:**
375
-
376
- ```json
377
- {
378
- "success": true,
379
- "output": "[main 4c83b2a] feat: add new dynamic endpoints for server management\n 2 files changed, 45 insertions(+)",
380
- "error": null
381
- }
382
- ```
383
-
384
- -----
385
-
386
- #### 8. Execute Commands
387
-
388
- **POST** `/execute-commands`
389
-
390
- Execute arbitrary system commands in the project directory.
391
-
392
- **Request Body:**
393
-
394
- ```json
395
- {
396
- "basePath": "./",
397
- "commandsToExecute": [
398
- "npm run lint",
399
- "npm test"
400
- ]
401
- }
402
- ```
403
-
404
- **Response:**
405
-
406
- ```json
407
- {
408
- "success": true,
409
- "commandsProcessed": 2,
410
- "errors": [],
411
- "results": [
412
- {
413
- "command": "npm run lint",
414
- "success": true,
415
- "output": "..."
416
- },
417
- {
418
- "command": "npm test",
419
- "success": true,
420
- "output": "..."
421
- }
422
- ]
423
- }
424
- ```
425
-
426
- -----
427
-
428
- #### 9. Get Command Output
429
-
430
- **GET** `/command-output`
431
-
432
- Retrieves the result (stdout/stderr) of the last executed command triggered by an upsert operation. Requires `onUpsertCommand` to be set in configuration.
433
-
434
- -----
435
-
436
- ## 💡 Use Cases
437
-
438
- ### 1. AI Code Analysis
439
-
440
- Prepare your entire codebase for AI analysis:
441
-
442
- ```bash
443
- codemerge use --output for-ai.txt
444
-
445
- cat for-ai.txt | pbcopy # macOS
446
- cat for-ai.txt | xclip # Linux
447
- ```
448
-
449
- ### 2. Code Review Context
450
-
451
- Generate context for code reviews:
452
-
453
- ```bash
454
- codemerge use ./src --output review-context.txt --ignore "*.test.ts,*.spec.js"
455
- ```
456
-
457
- ### 3. Documentation Generation
458
-
459
- Create documentation snapshots:
460
-
461
- ```bash
462
- codemerge use --include "***.ts" --output docs-snapshot.txt
463
- ```
464
-
465
- ### 4. AI-Powered Developer Tools
466
-
467
- Build tools that need dynamic project access:
468
-
469
- ```javascript
470
- const structure = await fetch('http://localhost:9876/structure').then(r => r.json());
471
- const selectedPaths = userSelection;
472
- const content = await fetch('http://localhost:9876/selective-content', {
473
- method: 'POST',
474
- headers: { 'Content-Type': 'application/json' },
475
- body: JSON.stringify({ selectedPaths })
476
- }).then(r => r.text());
477
- await sendToAI(content);
478
- ```
479
-
480
- ### 5. Continuous Context Updates
481
-
482
- Watch mode for real-time updates:
483
-
484
- ```bash
485
- codemerge watch --port 3000
486
-
487
- while true; do
488
- curl http://localhost:3000/content > latest.txt
489
- sleep 5
490
- done
491
- ```
492
-
493
- -----
494
-
495
- ## 📚 Additional Resources
496
-
497
- - **GitHub:** [github.com/odutradev/codemerge-cli](https://github.com/odutradev/codemerge-cli)
498
- - **Issues:** [Report bugs](https://github.com/odutradev/codemerge-cli/issues)
499
- - **NPM:** [npmjs.com/package/codemerge-cli](https://www.npmjs.com/package/codemerge-cli)
500
-
501
- -----
502
-
503
- ## 📝 License
504
-
505
- MIT License - feel free to use in your projects!
506
-
507
- -----
508
-
509
- ## 🤝 Contributing
510
-
511
- Contributions welcome! Please:
512
-
513
- 1. Fork the repository
514
- 2. Create a feature branch
515
- 3. Make your changes
516
- 4. Submit a pull request
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemerge-cli",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "AI-focused code and data preparation utility",
5
5
  "license": "MIT",
6
6
  "author": "CodeMerge Team",