codesummary 1.1.1 → 1.2.1
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/CHANGELOG.md +234 -190
- package/LICENSE +674 -674
- package/README.md +483 -607
- package/bin/codesummary.js +12 -12
- package/features.md +418 -502
- package/package.json +95 -95
- package/rag-schema.json +113 -113
- package/src/cli.js +599 -540
- package/src/configManager.js +880 -827
- package/src/errorHandler.js +474 -477
- package/src/index.js +25 -25
- package/src/llmGenerator.js +189 -0
- package/src/pdfGenerator.js +408 -475
- package/src/ragConfig.js +369 -373
- package/src/ragGenerator.js +1739 -1757
- package/src/scanner.js +386 -467
- package/src/utils.js +139 -0
package/README.md
CHANGED
|
@@ -1,607 +1,483 @@
|
|
|
1
|
-
# CodeSummary
|
|
2
|
-
|
|
3
|
-
[](https://badge.fury.io/js/codesummary)
|
|
4
|
-
[](https://nodejs.org/)
|
|
5
|
-
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
6
|
-
[](#)
|
|
7
|
-
|
|
8
|
-
A **cross-platform CLI tool** that
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
2
|
|
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
|
-
[x]
|
|
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
|
-
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
## 🛠️ Development
|
|
485
|
-
|
|
486
|
-
### Project Structure
|
|
487
|
-
|
|
488
|
-
```
|
|
489
|
-
codesummary/
|
|
490
|
-
├── bin/
|
|
491
|
-
│ └── codesummary.js # Global executable entry point
|
|
492
|
-
├── src/
|
|
493
|
-
│ ├── cli.js # Command line interface
|
|
494
|
-
│ ├── configManager.js # Global configuration management
|
|
495
|
-
│ ├── scanner.js # File system scanning and filtering
|
|
496
|
-
│ ├── pdfGenerator.js # PDF creation and formatting
|
|
497
|
-
│ └── errorHandler.js # Comprehensive error handling
|
|
498
|
-
├── package.json
|
|
499
|
-
├── README.md
|
|
500
|
-
└── features.md
|
|
501
|
-
```
|
|
502
|
-
|
|
503
|
-
### Building from Source
|
|
504
|
-
|
|
505
|
-
```bash
|
|
506
|
-
# Clone repository
|
|
507
|
-
git clone https://github.com/skamoll/CodeSummary.git
|
|
508
|
-
cd CodeSummary
|
|
509
|
-
|
|
510
|
-
# Install dependencies
|
|
511
|
-
npm install
|
|
512
|
-
|
|
513
|
-
# Test the CLI
|
|
514
|
-
node bin/codesummary.js --help
|
|
515
|
-
|
|
516
|
-
# Run locally without global install
|
|
517
|
-
node bin/codesummary.js
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
## 🔍 Troubleshooting
|
|
521
|
-
|
|
522
|
-
### Common Issues
|
|
523
|
-
|
|
524
|
-
**Configuration not found**
|
|
525
|
-
|
|
526
|
-
- Run `codesummary` to trigger first-time setup
|
|
527
|
-
- Check file permissions in config directory
|
|
528
|
-
|
|
529
|
-
**PDF generation fails**
|
|
530
|
-
|
|
531
|
-
- Verify output directory permissions
|
|
532
|
-
- Ensure Node.js version ≥18.0.0
|
|
533
|
-
- Close any open PDF viewers on the target file
|
|
534
|
-
|
|
535
|
-
**Files not showing up**
|
|
536
|
-
|
|
537
|
-
- Check that file extensions are in `allowedExtensions`
|
|
538
|
-
- Verify directories aren't in `excludeDirs` list
|
|
539
|
-
- Ensure files are text-based (not binary)
|
|
540
|
-
|
|
541
|
-
**Large project performance**
|
|
542
|
-
|
|
543
|
-
- Adjust `maxFilesBeforePrompt` in configuration
|
|
544
|
-
- Use extension filtering to reduce file count
|
|
545
|
-
- CodeSummary handles large files efficiently with streaming
|
|
546
|
-
|
|
547
|
-
### Getting Help
|
|
548
|
-
|
|
549
|
-
1. Run `codesummary --help` for usage information
|
|
550
|
-
2. Check configuration with `codesummary --show-config`
|
|
551
|
-
3. Reset configuration with `codesummary --reset-config`
|
|
552
|
-
4. Open an issue on [GitHub](https://github.com/skamoll/CodeSummary/issues)
|
|
553
|
-
|
|
554
|
-
## 🤝 Contributing
|
|
555
|
-
|
|
556
|
-
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
|
|
557
|
-
|
|
558
|
-
### Development Setup
|
|
559
|
-
|
|
560
|
-
1. Fork the repository
|
|
561
|
-
2. Clone your fork: `git clone https://github.com/yourusername/CodeSummary.git`
|
|
562
|
-
3. Install dependencies: `npm install`
|
|
563
|
-
4. Create a feature branch: `git checkout -b feature-name`
|
|
564
|
-
5. Make your changes and test thoroughly
|
|
565
|
-
6. Submit a pull request
|
|
566
|
-
|
|
567
|
-
## 📄 License
|
|
568
|
-
|
|
569
|
-
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
|
|
570
|
-
|
|
571
|
-
### License Summary
|
|
572
|
-
|
|
573
|
-
- ✅ Commercial use permitted
|
|
574
|
-
- ✅ Modification allowed
|
|
575
|
-
- ✅ Distribution allowed
|
|
576
|
-
- ✅ Private use allowed
|
|
577
|
-
- ❗ Copyleft: derivative works must use GPL-3.0
|
|
578
|
-
- ❗ Must include license and copyright notice
|
|
579
|
-
|
|
580
|
-
## 🙏 Acknowledgments
|
|
581
|
-
|
|
582
|
-
- Built with [PDFKit](https://pdfkit.org/) for PDF generation
|
|
583
|
-
- Uses [Inquirer.js](https://github.com/SBoudrias/Inquirer.js) for interactive prompts
|
|
584
|
-
- Styled with [Chalk](https://github.com/chalk/chalk) for colorful console output
|
|
585
|
-
- Uses [Ora](https://github.com/sindresorhus/ora) for progress indicators
|
|
586
|
-
|
|
587
|
-
## 📊 Roadmap
|
|
588
|
-
|
|
589
|
-
### Future Enhancements
|
|
590
|
-
|
|
591
|
-
- [ ] Syntax highlighting in PDF output
|
|
592
|
-
- [ ] Clickable table of contents with bookmarks
|
|
593
|
-
- [ ] Multiple output formats (HTML, JSON, Markdown)
|
|
594
|
-
- [ ] Project metrics and code statistics
|
|
595
|
-
- [ ] CI/CD integration mode for automated documentation
|
|
596
|
-
- [ ] Custom PDF themes and styling options
|
|
597
|
-
- [ ] Plugin system for custom processors
|
|
598
|
-
|
|
599
|
-
## 📞 Support
|
|
600
|
-
|
|
601
|
-
- 📧 Report bugs: [GitHub Issues](https://github.com/skamoll/CodeSummary/issues)
|
|
602
|
-
- 💬 Ask questions: [GitHub Discussions](https://github.com/skamoll/CodeSummary/discussions)
|
|
603
|
-
- 📖 Documentation: [Wiki](https://github.com/skamoll/CodeSummary/wiki)
|
|
604
|
-
|
|
605
|
-
---
|
|
606
|
-
|
|
607
|
-
**Made with ❤️ for developers worldwide**
|
|
1
|
+
# CodeSummary
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/codesummary)
|
|
4
|
+
[](https://nodejs.org/)
|
|
5
|
+
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
6
|
+
[](#)
|
|
7
|
+
|
|
8
|
+
A **cross-platform CLI tool** that scans your project's source code and generates three types of output:
|
|
9
|
+
|
|
10
|
+
- **PDF** — clean, professional A4 documentation for code reviews and audits
|
|
11
|
+
- **RAG JSON** — semantic chunks with byte offsets and token estimates, ready for vector databases and LLM pipelines
|
|
12
|
+
- **LLM Markdown** — token-optimised single file to paste directly into any chat-based LLM
|
|
13
|
+
|
|
14
|
+
## 🚀 Key Features
|
|
15
|
+
|
|
16
|
+
- **Three output formats**: PDF, RAG JSON, LLM Markdown — pick what you need
|
|
17
|
+
- **Intelligent scanning**: recursive traversal with configurable whitelist filtering
|
|
18
|
+
- **Extensive language support**: 50+ file types out of the box
|
|
19
|
+
- **Versioned output files**: `-v1`, `-v2` suffixes instead of overwriting or timestamps
|
|
20
|
+
- **Non-interactive mode**: `--no-interactive` for CI/CD and scripted use
|
|
21
|
+
- **Smart config migration**: new defaults merge into existing config without overwriting customisations
|
|
22
|
+
- **Cross-platform**: identical behaviour on Windows, macOS, and Linux
|
|
23
|
+
|
|
24
|
+
## 📦 Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g codesummary
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Requirements**: Node.js ≥ 18.0.0
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 🎯 Output Modes
|
|
35
|
+
|
|
36
|
+
### 📄 PDF — Documentation & audits
|
|
37
|
+
|
|
38
|
+
Generate a professional A4 PDF with file structure and complete source content:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
codesummary
|
|
42
|
+
# or explicitly:
|
|
43
|
+
codesummary --format pdf
|
|
44
|
+
# Output: MYPROJECT_code.pdf
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Best for: code reviews, client handovers, compliance audits, archival snapshots.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### 🤖 RAG — Vector databases & AI pipelines
|
|
52
|
+
|
|
53
|
+
Generate a structured JSON file built for embedding and retrieval:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
codesummary --format rag
|
|
57
|
+
# Output: MYPROJECT_rag.json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The JSON contains semantic chunks (split by function, class, or logical block) with:
|
|
61
|
+
- Byte-accurate content offsets for fast seeking
|
|
62
|
+
- SHA-256 file hashes for deduplication
|
|
63
|
+
- Token estimates for context budget planning
|
|
64
|
+
- Import/call extraction for graph-based retrieval
|
|
65
|
+
- Full statistics for monitoring
|
|
66
|
+
|
|
67
|
+
Best for: building RAG systems, loading code into a vector database (Pinecone, Qdrant, Chroma, etc.), or programmatic LLM integration where you control chunking and retrieval.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### 💬 LLM — Direct chat with any AI assistant
|
|
72
|
+
|
|
73
|
+
Generate a single, token-optimised Markdown file to paste directly into any LLM:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
codesummary --format llm
|
|
77
|
+
# Output: MYPROJECT_llm.md
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The file contains a project header, a complete file tree, and each file's content in a fenced code block with syntax highlighting hints. These lossless optimisations are applied automatically to reduce token count:
|
|
81
|
+
|
|
82
|
+
- Line endings normalised to `\n`
|
|
83
|
+
- Trailing whitespace stripped per line
|
|
84
|
+
- Leading/trailing blank lines removed per file
|
|
85
|
+
- JSON files compacted (re-serialised without indentation)
|
|
86
|
+
- Markdown files: max 2 consecutive blank lines preserved
|
|
87
|
+
- All other files: max 1 consecutive blank line
|
|
88
|
+
|
|
89
|
+
Best for: asking any LLM chat interface to review, explain, or work with your codebase in a single paste — much more token-efficient than a PDF.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### 🔄 Both — PDF + RAG together
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
codesummary --format both
|
|
97
|
+
# Output: MYPROJECT_code.pdf + MYPROJECT_rag.json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Uses a single scan pass. If one format fails, the other still completes.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 📖 Usage
|
|
105
|
+
|
|
106
|
+
### Quick start
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# First run: interactive setup wizard
|
|
110
|
+
codesummary
|
|
111
|
+
|
|
112
|
+
# Generate LLM Markdown for the current project
|
|
113
|
+
codesummary --format llm
|
|
114
|
+
|
|
115
|
+
# Generate RAG JSON and save to a specific directory
|
|
116
|
+
codesummary --format rag --output ./ai-data
|
|
117
|
+
|
|
118
|
+
# Skip all prompts (CI-friendly)
|
|
119
|
+
codesummary --format llm --no-interactive
|
|
120
|
+
|
|
121
|
+
# Generate everything at once
|
|
122
|
+
codesummary --format both
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Interactive workflow
|
|
126
|
+
|
|
127
|
+
#### 1. First-run setup
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
Welcome to CodeSummary!
|
|
131
|
+
No configuration found. Starting setup...
|
|
132
|
+
|
|
133
|
+
Where should the output be saved by default?
|
|
134
|
+
> [ ] Current working directory (relative mode)
|
|
135
|
+
> [x] Fixed folder (absolute mode)
|
|
136
|
+
|
|
137
|
+
Enter absolute path for fixed folder:
|
|
138
|
+
> ~/Desktop/CodeSummaries
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### 2. Extension selection
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
Scan Summary:
|
|
145
|
+
Extensions found: .js, .ts, .md, .json
|
|
146
|
+
Total files: 127 — Total size: 2.4 MB
|
|
147
|
+
|
|
148
|
+
Select file extensions to include:
|
|
149
|
+
[x] .js → JavaScript (42 files)
|
|
150
|
+
[x] .ts → TypeScript (28 files)
|
|
151
|
+
[x] .md → Markdown (5 files)
|
|
152
|
+
[ ] .json → JSON (52 files)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### 3. Output
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
SUCCESS: LLM-optimised Markdown generated successfully!
|
|
159
|
+
|
|
160
|
+
Output: ~/Desktop/CodeSummaries/MYPROJECT_llm.md
|
|
161
|
+
Extensions: .js, .ts, .md
|
|
162
|
+
Total files: 75
|
|
163
|
+
File size: 1.1 MB
|
|
164
|
+
Ready to paste into any LLM chat interface
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Command reference
|
|
168
|
+
|
|
169
|
+
| Command | Description |
|
|
170
|
+
| ------- | ----------- |
|
|
171
|
+
| `codesummary` | Scan and generate PDF (default) |
|
|
172
|
+
| `codesummary --format pdf` | Generate PDF documentation |
|
|
173
|
+
| `codesummary --format rag` | Generate RAG-optimised JSON |
|
|
174
|
+
| `codesummary --format llm` | Generate LLM-optimised Markdown |
|
|
175
|
+
| `codesummary --format both` | Generate PDF + RAG JSON |
|
|
176
|
+
| `codesummary config` | Edit configuration interactively |
|
|
177
|
+
| `codesummary --show-config` | Display current configuration |
|
|
178
|
+
| `codesummary --reset-config` | Reset configuration to defaults |
|
|
179
|
+
|
|
180
|
+
### Options
|
|
181
|
+
|
|
182
|
+
| Option | Short | Description |
|
|
183
|
+
| ------ | ----- | ----------- |
|
|
184
|
+
| `--format <format>` | `-f` | Output format: `pdf` (default), `rag`, `llm`, or `both` |
|
|
185
|
+
| `--output <path>` | `-o` | Override output directory for this run |
|
|
186
|
+
| `--no-interactive` | | Skip all prompts; auto-select all extensions |
|
|
187
|
+
| `--show-config` | | Display current configuration |
|
|
188
|
+
| `--reset-config` | | Reset configuration to defaults |
|
|
189
|
+
| `--help` | `-h` | Show help |
|
|
190
|
+
| `--version` | `-v` | Show version |
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## ⚙️ Configuration
|
|
195
|
+
|
|
196
|
+
Configuration is stored globally at:
|
|
197
|
+
|
|
198
|
+
- **Linux/macOS**: `~/.codesummary/config.json`
|
|
199
|
+
- **Windows**: `%APPDATA%\CodeSummary\config.json`
|
|
200
|
+
|
|
201
|
+
Existing configuration is never overwritten on upgrade — new defaults are merged in automatically.
|
|
202
|
+
|
|
203
|
+
### Default configuration
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"output": {
|
|
208
|
+
"mode": "fixed",
|
|
209
|
+
"fixedPath": "~/Desktop/CodeSummaries"
|
|
210
|
+
},
|
|
211
|
+
"allowedExtensions": [
|
|
212
|
+
".js", ".jsx", ".ts", ".tsx", ".json", ".html", ".css", ".scss",
|
|
213
|
+
".md", ".txt", ".py", ".java", ".cs", ".cpp", ".c", ".h",
|
|
214
|
+
".xml", ".yaml", ".yml", ".sh", ".bat", ".ps1",
|
|
215
|
+
".cfg", ".conf", ".env", ".local", ".service", ".timer",
|
|
216
|
+
".ino", ".j2", ".csv", ".tsv", ".crt", ".sql",
|
|
217
|
+
".toml", ".ini", ".properties", ".tf", ".tfvars", ".proto", ".prisma",
|
|
218
|
+
".dart", ".lua", ".r", ".ex", ".exs", ".pl", ".mk", ".cmake",
|
|
219
|
+
".mdx", ".astro", ".graphql", ".gql"
|
|
220
|
+
],
|
|
221
|
+
"excludeDirs": [
|
|
222
|
+
"node_modules", ".git", ".vscode", "dist", "build", "coverage",
|
|
223
|
+
"out", "__pycache__", ".next", ".nuxt",
|
|
224
|
+
".idea", "target", ".gradle", "venv", ".venv",
|
|
225
|
+
".pytest_cache", ".mypy_cache", ".tox", ".terraform", ".turbo",
|
|
226
|
+
".angular", ".svelte-kit", ".yarn", ".pnpm-store",
|
|
227
|
+
".expo", ".dart_tool", "storybook-static", "htmlcov"
|
|
228
|
+
],
|
|
229
|
+
"excludeFiles": [
|
|
230
|
+
"*-lock.json", "*.lock", "*.min.js", "*.min.css", "*.map",
|
|
231
|
+
".DS_Store", "Thumbs.db", "desktop.ini", "ehthumbs.db",
|
|
232
|
+
"*.pyc", "*.pyo", "*.class", "*.log", "*.tmp", "*.temp",
|
|
233
|
+
"*.swp", "*.bak", "*.orig"
|
|
234
|
+
],
|
|
235
|
+
"settings": {
|
|
236
|
+
"documentTitle": "Project Code Summary",
|
|
237
|
+
"maxFilesBeforePrompt": 500
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## 📋 PDF structure
|
|
245
|
+
|
|
246
|
+
Generated PDFs are A4 with three sections:
|
|
247
|
+
|
|
248
|
+
1. **Project overview** — title, project name, generation timestamp, included file types
|
|
249
|
+
2. **File structure** — complete sorted file listing
|
|
250
|
+
3. **File content** — full source of every selected file, monospace font, no truncation
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 🤖 RAG JSON structure
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"metadata": {
|
|
259
|
+
"projectName": "MyProject",
|
|
260
|
+
"generatedAt": "2025-07-31T08:00:00.000Z",
|
|
261
|
+
"version": "3.1.0"
|
|
262
|
+
},
|
|
263
|
+
"files": [
|
|
264
|
+
{
|
|
265
|
+
"id": "abc123def456",
|
|
266
|
+
"path": "src/component.js",
|
|
267
|
+
"language": "JavaScript",
|
|
268
|
+
"hash": "sha256-...",
|
|
269
|
+
"chunks": [
|
|
270
|
+
{
|
|
271
|
+
"id": "chunk_abc123def456_0",
|
|
272
|
+
"content": "function myFunction() { ... }",
|
|
273
|
+
"tokenEstimate": 45,
|
|
274
|
+
"lineStart": 1,
|
|
275
|
+
"lineEnd": 15,
|
|
276
|
+
"chunkingMethod": "semantic-function",
|
|
277
|
+
"context": "function_myFunction",
|
|
278
|
+
"imports": ["lodash", "react"],
|
|
279
|
+
"calls": ["useState", "useEffect"]
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
],
|
|
284
|
+
"index": {
|
|
285
|
+
"chunkOffsets": {
|
|
286
|
+
"chunk_abc123def456_0": {
|
|
287
|
+
"contentStart": 12123,
|
|
288
|
+
"contentEnd": 12356,
|
|
289
|
+
"filePath": "src/component.js"
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
"statistics": { "processingTimeMs": 245, "chunksWithValidOffsets": 387 }
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### RAG integration example
|
|
298
|
+
|
|
299
|
+
```javascript
|
|
300
|
+
const ragData = JSON.parse(fs.readFileSync('project_rag.json'));
|
|
301
|
+
|
|
302
|
+
// Extract all chunks for embedding
|
|
303
|
+
const chunks = ragData.files.flatMap(file =>
|
|
304
|
+
file.chunks.map(chunk => ({
|
|
305
|
+
id: chunk.id,
|
|
306
|
+
content: chunk.content,
|
|
307
|
+
metadata: { filePath: file.path, language: file.language }
|
|
308
|
+
}))
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
// Store in your vector database
|
|
312
|
+
for (const chunk of chunks) {
|
|
313
|
+
const embedding = await embed(chunk.content);
|
|
314
|
+
await vectorDB.upsert(chunk.id, embedding, chunk.metadata);
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## 💬 LLM Markdown structure
|
|
321
|
+
|
|
322
|
+
```markdown
|
|
323
|
+
# MyProject — Code Summary
|
|
324
|
+
|
|
325
|
+
**Generated:** 2026-04-05 | **Files:** 42 | **Total size:** 1.2 MB
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## File Tree
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
src/cli.js
|
|
333
|
+
src/scanner.js
|
|
334
|
+
...
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## src/cli.js
|
|
340
|
+
|
|
341
|
+
```js
|
|
342
|
+
import chalk from 'chalk';
|
|
343
|
+
...
|
|
344
|
+
```
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
Paste the `.md` file directly into any LLM chat interface. No further processing needed.
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## 🔧 Advanced features
|
|
352
|
+
|
|
353
|
+
### Versioned output filenames
|
|
354
|
+
|
|
355
|
+
When the target file already exists, CodeSummary creates a versioned copy instead of overwriting:
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
MYPROJECT_llm.md ← exists
|
|
359
|
+
MYPROJECT_llm-v1.md ← created
|
|
360
|
+
MYPROJECT_llm-v1.md ← exists on next run
|
|
361
|
+
MYPROJECT_llm-v2.md ← created
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
This applies to all three output formats (PDF, RAG JSON, LLM Markdown).
|
|
365
|
+
|
|
366
|
+
### Non-interactive mode
|
|
367
|
+
|
|
368
|
+
Skip all prompts and auto-select all detected extensions:
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
codesummary --format llm --no-interactive
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Useful for CI pipelines or scripted documentation generation.
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## 🎨 Supported file types
|
|
379
|
+
|
|
380
|
+
| Extension | Type | Extension | Type |
|
|
381
|
+
| --------- | ---- | --------- | ---- |
|
|
382
|
+
| `.js` `.jsx` | JavaScript | `.ts` `.tsx` | TypeScript |
|
|
383
|
+
| `.py` | Python | `.java` | Java |
|
|
384
|
+
| `.cs` | C# | `.cpp` `.c` `.h` | C/C++ |
|
|
385
|
+
| `.go` | Go | `.rs` | Rust |
|
|
386
|
+
| `.swift` | Swift | `.kt` | Kotlin |
|
|
387
|
+
| `.rb` | Ruby | `.php` | PHP |
|
|
388
|
+
| `.dart` | Dart | `.lua` | Lua |
|
|
389
|
+
| `.r` | R | `.ex` `.exs` | Elixir |
|
|
390
|
+
| `.pl` | Perl | `.scala` | Scala |
|
|
391
|
+
| `.html` | HTML | `.css` `.scss` | CSS |
|
|
392
|
+
| `.vue` | Vue.js | `.svelte` | Svelte |
|
|
393
|
+
| `.astro` | Astro | `.mdx` | MDX |
|
|
394
|
+
| `.json` | JSON | `.yaml` `.yml` | YAML |
|
|
395
|
+
| `.toml` | TOML | `.xml` | XML |
|
|
396
|
+
| `.ini` | INI | `.properties` | Java Properties |
|
|
397
|
+
| `.tf` `.tfvars` | Terraform | `.proto` | Protobuf |
|
|
398
|
+
| `.prisma` | Prisma | `.graphql` `.gql` | GraphQL |
|
|
399
|
+
| `.sql` | SQL | `.md` `.txt` | Docs |
|
|
400
|
+
| `.sh` `.bash` | Shell | `.bat` | Batch |
|
|
401
|
+
| `.ps1` | PowerShell | `.mk` `.cmake` | Build |
|
|
402
|
+
| `.cfg` `.conf` | Config | `.env` `.local` | Environment |
|
|
403
|
+
| `.service` `.timer` | Systemd | `.ino` | Arduino |
|
|
404
|
+
| `.j2` | Jinja2 | `.csv` `.tsv` | Data |
|
|
405
|
+
| `.crt` | Certificate | `.dockerfile` | Docker |
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## 🛠️ Project structure
|
|
410
|
+
|
|
411
|
+
```
|
|
412
|
+
codesummary/
|
|
413
|
+
├── bin/
|
|
414
|
+
│ └── codesummary.js # Entry point
|
|
415
|
+
├── src/
|
|
416
|
+
│ ├── cli.js # Argument parsing, orchestration
|
|
417
|
+
│ ├── scanner.js # Recursive directory scanning
|
|
418
|
+
│ ├── pdfGenerator.js # PDF generation (PDFKit)
|
|
419
|
+
│ ├── ragGenerator.js # RAG JSON generation with semantic chunking
|
|
420
|
+
│ ├── llmGenerator.js # LLM Markdown generation with optimisations
|
|
421
|
+
│ ├── configManager.js # Global config storage and migration
|
|
422
|
+
│ ├── ragConfig.js # RAG-specific configuration and YAML loading
|
|
423
|
+
│ ├── errorHandler.js # Centralised error handling and path validation
|
|
424
|
+
│ └── utils.js # Shared utilities (formatFileSize, etc.)
|
|
425
|
+
├── rag-schema.json
|
|
426
|
+
├── raggen.config.yaml
|
|
427
|
+
└── package.json
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## 🔍 Troubleshooting
|
|
433
|
+
|
|
434
|
+
**No files found after scan**
|
|
435
|
+
- Check `allowedExtensions` in your config (`codesummary --show-config`)
|
|
436
|
+
- Verify the directory is not listed in `excludeDirs`
|
|
437
|
+
|
|
438
|
+
**Output file not generated**
|
|
439
|
+
- Check write permissions on the output directory
|
|
440
|
+
- Try `--output ./` to write to the current directory
|
|
441
|
+
|
|
442
|
+
**Non-ASCII characters in paths cause issues**
|
|
443
|
+
- Update to v1.2.0+ which fixes Windows path handling for accented characters
|
|
444
|
+
|
|
445
|
+
**CI pipeline hangs**
|
|
446
|
+
- Add `--no-interactive` to skip all prompts
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
## 🤝 Contributing
|
|
451
|
+
|
|
452
|
+
1. Fork the repository
|
|
453
|
+
2. Clone: `git clone https://github.com/skamoll/CodeSummary.git`
|
|
454
|
+
3. Install: `npm install`
|
|
455
|
+
4. Test: `node bin/codesummary.js --help`
|
|
456
|
+
5. Submit a pull request
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## 📄 License
|
|
461
|
+
|
|
462
|
+
GNU General Public License v3.0 — see [LICENSE](LICENSE) for details.
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
## 📊 Roadmap
|
|
467
|
+
|
|
468
|
+
- [ ] Syntax highlighting in PDF output
|
|
469
|
+
- [ ] Clickable table of contents in PDF
|
|
470
|
+
- [x] LLM-optimised Markdown output (`--format llm`)
|
|
471
|
+
- [x] Versioned output filenames (`-v1`, `-v2`)
|
|
472
|
+
- [x] Non-interactive mode (`--no-interactive`)
|
|
473
|
+
- [x] RAG JSON with semantic chunking
|
|
474
|
+
- [ ] `--format all` (PDF + RAG + LLM in one pass)
|
|
475
|
+
- [ ] Git integration (document only changed files)
|
|
476
|
+
- [ ] CI/CD plugin for automated documentation
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
## 📞 Support
|
|
481
|
+
|
|
482
|
+
- Report bugs: [GitHub Issues](https://github.com/skamoll/CodeSummary/issues)
|
|
483
|
+
- Questions: [GitHub Discussions](https://github.com/skamoll/CodeSummary/discussions)
|