c4-gen 1.6.0 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,25 @@
1
1
  # c4-gen 🚀
2
2
 
3
+ <div align="center">
4
+
5
+ **Created by [Hao Duong (haodq4)](https://github.com/haodq4)**
6
+
7
+ [![GitHub](https://img.shields.io/badge/GitHub-haodq4-181717?style=flat-square&logo=github)](https://github.com/haodq4)
8
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-haodq4-0077B5?style=flat-square&logo=linkedin)](https://www.linkedin.com/in/haodq)
9
+ [![Email](https://img.shields.io/badge/Email-haodq4%40gmail.com-D14836?style=flat-square&logo=gmail&logoColor=white)](mailto:haodq4@gmail.com)
10
+ [![NPM](https://img.shields.io/badge/NPM-haodq4-CB3837?style=flat-square&logo=npm)](https://www.npmjs.com/~haodq4)
11
+
12
+ ---
13
+
14
+ </div>
15
+
3
16
  > **Automatically generate C4 Model architecture documentation from source code using AI**
4
17
 
5
18
  [![NPM Version](https://img.shields.io/npm/v/c4-gen.svg)](https://www.npmjs.com/package/c4-gen)
19
+ [![Downloads](https://img.shields.io/npm/dt/c4-gen.svg)](https://www.npmjs.com/package/c4-gen)
6
20
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
21
  [![Node Version](https://img.shields.io/node/v/c4-gen.svg)](https://nodejs.org)
22
+ [![GitHub Stars](https://img.shields.io/github/stars/haodq4/c4-gen?style=social)](https://github.com/haodq4/c4-gen/stargazers)
8
23
 
9
24
  [English](#) | [Tiếng Việt](./README.vi.md)
10
25
 
@@ -198,15 +213,35 @@ MIT License - xem file [LICENSE](LICENSE)
198
213
  - Có thể chỉnh sửa markdown output để bổ sung thông tin
199
214
  - Sử dụng trên GitHub để tự động render Mermaid diagrams
200
215
 
201
- ## 🐛 Issues
216
+ ## 🐛 Issues & Support
217
+
218
+ Nếu bạn gặp vấn đề hoặc có câu hỏi:
202
219
 
203
- Nếu bạn gặp vấn đề, hãy tạo issue tại [GitHub Issues](https://github.com/your-username/c4-gen/issues)
220
+ - 📝 [Create an Issue](https://github.com/haodq4/c4-gen/issues)
221
+ - 💬 [GitHub Discussions](https://github.com/haodq4/c4-gen/discussions)
222
+ - 📧 Email: [haodq4@gmail.com](mailto:haodq4@gmail.com)
204
223
 
205
- ## 📧 Contact
224
+ ## �‍💻 Author
206
225
 
207
- - GitHub: [@haodq4](https://github.com/haodq4)
208
- - Email: haodq4@gmail.com
226
+ <div align="center">
227
+
228
+ **Hao Duong (haodq4)**
229
+
230
+ [![GitHub](https://img.shields.io/badge/GitHub-haodq4-181717?style=for-the-badge&logo=github)](https://github.com/haodq4)
231
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-0077B5?style=for-the-badge&logo=linkedin)](https://www.linkedin.com/in/haodq4)
232
+ [![Email](https://img.shields.io/badge/Email-haodq4%40gmail.com-D14836?style=for-the-badge&logo=gmail&logoColor=white)](mailto:haodq4@gmail.com)
233
+ [![NPM](https://img.shields.io/badge/NPM-haodq4-CB3837?style=for-the-badge&logo=npm)](https://www.npmjs.com/~haodq4)
234
+
235
+ **Building tools to make developers' lives easier** 🚀
236
+
237
+ [⭐ Star this repo](https://github.com/haodq4/c4-gen) if you find it useful!
238
+
239
+ </div>
209
240
 
210
241
  ---
211
242
 
212
- Made with ❤️ for the developer community
243
+ <div align="center">
244
+
245
+ Made with ❤️ by [Hao Duong](https://github.com/haodq4) for the developer community
246
+
247
+ </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c4-gen",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "Công cụ tự động sinh tài liệu kiến trúc C4 Model từ source code sử dụng AI",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/generator.js CHANGED
@@ -924,29 +924,53 @@ ${batch.content}
924
924
  ${formatDependencies(codeStructure.dependencies)}
925
925
 
926
926
  ---
927
- 🎯 NHIỆM VỤ:
927
+ 🎯 NHIỆM VỤ QUAN TRỌNG:
928
928
 
929
- Phân tích TOÀN BỘ code trong nhóm "${batch.name}" extract:
929
+ ⚠️ ĐÂY BATCH ${step}/${totalSteps} - PHẢI PHÂN TÍCH KỸ LƯỠNG!
930
930
 
931
- 1. SEQUENCE DIAGRAMS:
932
- - Nếu là routes/controllers: Tạo sequence diagram cho MỖI endpoint/route
933
- - Trace CHÍNH XÁC flow từ request → middleware → controller → service → repository → database
931
+ Phân tích TOÀN BỘ code trong nhóm "${batch.name}" extract ĐẦY ĐỦ:
932
+
933
+ 1. SEQUENCE DIAGRAMS - BẮT BUỘC:
934
+ - Nếu là routes/controllers: TẠO sequence diagram cho MỖI endpoint/route group
935
+ - Trace CHÍNH XÁC flow: request → middleware → controller → service → repository → database
934
936
  - Đọc CODE để lấy tên functions/methods THẬT
937
+ - VÍ DỤ: Nếu có 20 routes → cần ít nhất 5-10 sequence diagrams
935
938
 
936
- 2. CLASSES/MODELS:
937
- - Liệt kê TẤT CẢ class definitions tìm được
939
+ 2. CLASSES/MODELS - BẮT BUỘC:
940
+ - Liệt kê TẤT CẢ class definitions (KHÔNG được bỏ sót)
938
941
  - Đọc ĐẦY ĐỦ properties, methods, parameters, return types
939
942
  - Phát hiện relationships (extends, implements, uses)
943
+ - VÍ DỤ: Nếu có 30 files → expect 20-30 classes
940
944
 
941
- 3. DATABASE TABLES (nếu là models):
945
+ 3. DATABASE TABLES - BẮT BUỘC (nếu là models):
942
946
  - Liệt kê TẤT CẢ tables với ĐẦY ĐỦ columns
943
947
  - Lấy CHÍNH XÁC data types, constraints, foreign keys
944
948
  - Phát hiện TẤT CẢ relationships
949
+ - VÍ DỤ: Nếu có 50 model files → expect 40-50 tables
945
950
 
946
- 4. API ENDPOINTS (nếu là routes):
951
+ 4. API ENDPOINTS - BẮT BUỘC (nếu là routes):
947
952
  - Liệt kê TẤT CẢ endpoints (method + path)
948
953
  - Lấy handler functions, middlewares
949
954
  - Identify request/response schemas
955
+ - VÍ DỤ: Nếu có 15 route files → expect 50-100 endpoints
956
+
957
+ ⚠️ MINIMUM REQUIREMENTS - PHẢI ĐẠT:
958
+ ${batch.name.includes('route') ? `
959
+ ✅ Sequence Diagrams: Tối thiểu ${Math.ceil(batch.fileCount / 3)} diagrams
960
+ ✅ API Endpoints: Tối thiểu ${batch.fileCount * 3} endpoints
961
+ ` : ''}${batch.name.includes('controller') ? `
962
+ ✅ Sequence Diagrams: Tối thiểu ${Math.ceil(batch.fileCount / 2)} diagrams
963
+ ✅ Classes: Tối thiểu ${Math.ceil(batch.fileCount * 0.8)} classes
964
+ ✅ API Endpoints: Tối thiểu ${batch.fileCount * 2} endpoints
965
+ ` : ''}${batch.name.includes('model') ? `
966
+ ✅ Classes: Tối thiểu ${Math.ceil(batch.fileCount * 0.9)} classes
967
+ ✅ Database Tables: Tối thiểu ${Math.ceil(batch.fileCount * 0.8)} tables
968
+ ` : ''}${batch.name.includes('service') ? `
969
+ ✅ Classes: Tối thiểu ${Math.ceil(batch.fileCount * 0.8)} classes
970
+ ✅ Sequence Diagrams: Tối thiểu ${Math.ceil(batch.fileCount / 3)} diagrams
971
+ ` : ''}
972
+ ✅ KHÔNG được để mảng rỗng [] nếu có code
973
+ ✅ KHÔNG được chỉ liệt kê vài cái rồi bỏ qua phần còn lại
950
974
 
951
975
  ⚠️ QUAN TRỌNG - BẮT BUỘC:
952
976
  - PHẢI trả về JSON hợp lệ, KHÔNG được thêm text giải thích
@@ -1008,11 +1032,17 @@ Trả về JSON CHÍNH XÁC theo format này (KHÔNG thêm gì khác):
1008
1032
  "keyBusinessFlows": []
1009
1033
  }
1010
1034
 
1011
- LƯU Ý:
1012
- - LiệtTẤT CẢ, không bỏ sót
1013
- - Đọc CODE để lấy thông tin CHÍNH XÁC
1014
- - Nếu không tìm thấy mảng rỗng [], không bịa
1015
- - PHẢI JSON hợp lệ 100%
1035
+ LƯU Ý - CẤM TUYỆT ĐỐI:
1036
+ KHÔNG được liệt sài rồi ghi "... and more"
1037
+ KHÔNG được bỏ qua files "quá nhiều"
1038
+ KHÔNG được summarize - PHẢI liệt chi tiết
1039
+ KHÔNG được để [] nếu thực tế có data
1040
+
1041
+ ✅ YÊU CẦU - PHẢI LÀM:
1042
+ ✅ ĐỌC TẤT CẢ ${batch.fileCount} files trong batch
1043
+ ✅ LIỆT KÊ TẤT CẢ findings - không bỏ sót
1044
+ ✅ PHẢI là JSON hợp lệ 100%
1045
+ ✅ ĐẦY ĐỦ và CHÍNH XÁC
1016
1046
  `;
1017
1047
 
1018
1048
  try {
package/src/scanner.js CHANGED
@@ -199,7 +199,7 @@ export async function getDetailedCodeBatches(files, sourcePath) {
199
199
 
200
200
  // Tạo batches, với SUB-BATCHING nếu quá lớn
201
201
  const batches = [];
202
- const MAX_BATCH_SIZE = 500000; // 500K chars per batch (để tránh vượt context)
202
+ const MAX_BATCH_SIZE = 200000; // Giảm từ 500K xuống 200K để AI phân tích kỹ hơn
203
203
 
204
204
  for (const [categoryName, categoryFiles] of Object.entries(categories)) {
205
205
  if (categoryFiles.length === 0) continue;
@@ -229,7 +229,7 @@ export async function getDetailedCodeBatches(files, sourcePath) {
229
229
  // Flush current batch
230
230
  const batchContent = currentBatch.map(b => `\n=== ${b.file.path} ===\n${b.content}\n`).join('\n');
231
231
  batches.push({
232
- name: categoryFiles.length > 20 ? `${categoryName}-${batchIndex}` : categoryName,
232
+ name: categoryFiles.length > 10 ? `${categoryName}-${batchIndex}` : categoryName,
233
233
  fileCount: currentBatch.length,
234
234
  content: batchContent
235
235
  });