vg-coder-cli 1.0.7 → 1.0.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/.vgignore +2 -0
- package/README.md +89 -77
- package/package.json +1 -1
- package/src/index.js +50 -5
- package/test-large/package.json +1 -0
- package/test-large/src/components/Button.tsx +1 -0
- package/test-large/src/index.ts +1 -0
- package/vg-coder-cli-1.0.8.tgz +0 -0
- package/vg-coder-cli-1.0.9.tgz +0 -0
- package/vg-projects.txt +5 -0
- package/test-small/package-lock.json +0 -1
- package/vg-coder-cli-1.0.6.tgz +0 -0
- package/vg-coder-cli-1.0.7.tgz +0 -0
package/.vgignore
CHANGED
package/README.md
CHANGED
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
## ✨ Tính năng
|
|
6
6
|
|
|
7
|
-
- 🔍 **Phát hiện loại dự án**: Tự động nhận diện Angular, Spring Boot, React, Vue, Node.js, Python, Java, .NET
|
|
8
|
-
- 📁 **Xử lý
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
- 📋 **
|
|
7
|
+
- 🔍 **Phát hiện loại dự án**: Tự động nhận diện Angular, Spring Boot, React, Vue, Node.js, Python, Java, .NET.
|
|
8
|
+
- 📁 **Xử lý `.gitignore`**: Tuân thủ chuẩn Git với multi-level ignore rules.
|
|
9
|
+
- 🛡️ **Hỗ trợ `.vgignore`**: Có độ ưu tiên cao hơn `.gitignore`, với cú pháp giống hệt.
|
|
10
|
+
- 📜 **Bỏ qua file mặc định**: Tự động bỏ qua các thư mục phổ biến như `node_modules`, `dist`, `.git`, `build`, `target` và các file cấu hình IDE.
|
|
11
|
+
- 📄 **Scan và nối file**: Quét toàn bộ dự án và nối các file mã nguồn lại với nhau.
|
|
12
|
+
- 🧮 **Đếm token**: Sử dụng `tiktoken` để đếm token chính xác cho các mô hình AI.
|
|
13
|
+
- ✂️ **Chia nhỏ nội dung**: Chia nội dung thông minh thành các chunk nhỏ hơn mà vẫn giữ cấu trúc file.
|
|
14
|
+
- 🌐 **Xuất HTML**: Tạo báo cáo HTML tương tác với syntax highlighting và các nút bấm sao chép.
|
|
15
|
+
- 📋 **Sao chép vào Clipboard**: Chế độ `--clipboard-only` giúp sao chép toàn bộ mã nguồn đã xử lý vào clipboard, không cần tạo file.
|
|
16
|
+
- 🤖 **Tối ưu cho AI**: Xuất file `combined.txt` với định dạng thân thiện cho các mô hình AI và cung cấp mẫu script để hướng dẫn AI.
|
|
17
|
+
- 🌳 **Cây thư mục**: Hiển thị và cho phép sao chép cấu trúc cây thư mục của dự án trong giao diện HTML.
|
|
18
|
+
- 🔍 **Tìm kiếm tích hợp**: Giao diện HTML đi kèm chức năng tìm kiếm nội dung trực tiếp trong code.
|
|
16
19
|
|
|
17
20
|
## 📦 Cài đặt
|
|
18
21
|
|
|
@@ -40,7 +43,7 @@ chmod +x bin/vg-coder.js
|
|
|
40
43
|
|
|
41
44
|
## 🚀 Sử dụng
|
|
42
45
|
|
|
43
|
-
### Phân tích dự án
|
|
46
|
+
### Phân tích dự án và xuất HTML
|
|
44
47
|
```bash
|
|
45
48
|
# Nếu cài global
|
|
46
49
|
vg-coder analyze
|
|
@@ -55,6 +58,16 @@ vg-coder analyze /path/to/project
|
|
|
55
58
|
vg-coder analyze /path/to/project --max-tokens 8192 --output ./my-output --theme monokai
|
|
56
59
|
```
|
|
57
60
|
|
|
61
|
+
### Sao chép nhanh vào Clipboard (Không tạo file)
|
|
62
|
+
Chế độ này rất hữu ích để nhanh chóng đưa toàn bộ ngữ cảnh dự án vào các công cụ AI.
|
|
63
|
+
```bash
|
|
64
|
+
# Phân tích và sao chép toàn bộ code vào clipboard
|
|
65
|
+
vg-coder analyze --clipboard-only
|
|
66
|
+
|
|
67
|
+
# Hoặc dùng alias ngắn gọn
|
|
68
|
+
vg-coder analyze --clipboard
|
|
69
|
+
```
|
|
70
|
+
|
|
58
71
|
### Xem thông tin dự án
|
|
59
72
|
```bash
|
|
60
73
|
# Thông tin dự án hiện tại
|
|
@@ -67,10 +80,43 @@ vg-coder info /path/to/project
|
|
|
67
80
|
### Xóa output
|
|
68
81
|
```bash
|
|
69
82
|
# Xóa output mặc định
|
|
70
|
-
|
|
83
|
+
vg-coder clean
|
|
71
84
|
|
|
72
85
|
# Xóa output tùy chỉnh
|
|
73
|
-
|
|
86
|
+
vg-coder clean --output ./my-output
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 📜 Trợ giúp (Help)
|
|
90
|
+
|
|
91
|
+
Bạn có thể xem tất cả các lệnh và tùy chọn có sẵn bằng cách sử dụng cờ `--help` hoặc `-h`.
|
|
92
|
+
|
|
93
|
+
### Trợ giúp chung
|
|
94
|
+
Để xem danh sách các lệnh chính:
|
|
95
|
+
```bash
|
|
96
|
+
vg-coder --help
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Output (ví dụ):**
|
|
100
|
+
```
|
|
101
|
+
Usage: vg-coder [command] [options]
|
|
102
|
+
|
|
103
|
+
CLI tool để phân tích dự án, nối file mã nguồn, đếm token và xuất HTML
|
|
104
|
+
|
|
105
|
+
Options:
|
|
106
|
+
-V, --version output the version number
|
|
107
|
+
-h, --help display help for command
|
|
108
|
+
|
|
109
|
+
Commands:
|
|
110
|
+
analyze [path] Phân tích dự án và tạo output HTML
|
|
111
|
+
info [path] Hiển thị thông tin về dự án
|
|
112
|
+
clean Xóa thư mục output
|
|
113
|
+
help [command] display help for command
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Trợ giúp cho lệnh cụ thể
|
|
117
|
+
Để xem chi tiết các tùy chọn cho một lệnh cụ thể (ví dụ: `analyze`):
|
|
118
|
+
```bash
|
|
119
|
+
vg-coder analyze --help
|
|
74
120
|
```
|
|
75
121
|
|
|
76
122
|
## ⚙️ Options
|
|
@@ -80,68 +126,42 @@ node src/index.js clean --output ./my-output
|
|
|
80
126
|
| `--max-tokens <number>` | Số token tối đa mỗi chunk | 8000 |
|
|
81
127
|
| `--model <model>` | Model AI để đếm token | gpt-4 |
|
|
82
128
|
| `--output <path>` | Thư mục output | ./vg-output |
|
|
83
|
-
| `--extensions <list>` | Danh sách extensions (comma-separated) |
|
|
84
|
-
| `--include-hidden` | Bao gồm file ẩn | false |
|
|
85
|
-
| `--no-structure` | Không ưu tiên giữ cấu trúc file | false |
|
|
129
|
+
| `--extensions <list>` | Danh sách extensions (comma-separated) | Tự động phát hiện |
|
|
130
|
+
| `--include-hidden` | Bao gồm file ẩn (bị bỏ qua mặc định) | false |
|
|
131
|
+
| `--no-structure` | Không ưu tiên giữ cấu trúc file khi chia chunk | false |
|
|
86
132
|
| `--theme <theme>` | Theme cho syntax highlighting | github |
|
|
133
|
+
| `--clipboard-only` | Sao chép nội dung vào clipboard thay vì tạo file output. | false |
|
|
134
|
+
| `--clipboard` | Alias cho `--clipboard-only` | false |
|
|
87
135
|
|
|
88
|
-
## 📋 Ví dụ chi tiết
|
|
89
136
|
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
node src/index.js analyze ./my-angular-app --max-tokens 6000 --theme monokai
|
|
93
|
-
```
|
|
137
|
+
## 🤖 Tối ưu cho AI (AI Optimization)
|
|
94
138
|
|
|
95
|
-
###
|
|
96
|
-
|
|
97
|
-
node src/index.js analyze ./my-project --extensions "js,ts,vue,css" --include-hidden
|
|
98
|
-
```
|
|
139
|
+
### File `combined.txt`
|
|
140
|
+
Công cụ tạo ra file `combined.txt` được định dạng đặc biệt để dễ dàng đưa vào các mô hình ngôn ngữ lớn. Mỗi file được phân tách rõ ràng bằng một header duy nhất, giúp AI nhận biết và xử lý chính xác từng file.
|
|
99
141
|
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
node src/index.js info ./my-project
|
|
103
|
-
# Output:
|
|
104
|
-
# 📁 Project Information:
|
|
105
|
-
# Path: /path/to/my-project
|
|
106
|
-
# Primary Type: nodejs
|
|
107
|
-
#
|
|
108
|
-
# Detected Technologies:
|
|
109
|
-
# nodejs: high confidence
|
|
110
|
-
#
|
|
111
|
-
# 📊 File Statistics:
|
|
112
|
-
# Total Files: 25
|
|
113
|
-
# Total Size: 156.7 KB
|
|
114
|
-
# Total Lines: 4,523
|
|
115
|
-
# Extensions: js, ts, json, md
|
|
142
|
+
**Ví dụ định dạng:**
|
|
116
143
|
```
|
|
144
|
+
// ===== FILE: src/index.js =====
|
|
145
|
+
... nội dung file index.js ...
|
|
117
146
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
# Chạy tất cả tests
|
|
122
|
-
npm test
|
|
123
|
-
|
|
124
|
-
# Chạy tests với coverage
|
|
125
|
-
npm run test:coverage
|
|
126
|
-
|
|
127
|
-
# Chạy specific test
|
|
128
|
-
npm test -- --testNamePattern="project detection"
|
|
147
|
+
// ===== FILE: src/utils.js =====
|
|
148
|
+
... nội dung file utils.js ...
|
|
129
149
|
```
|
|
130
150
|
|
|
151
|
+
### Mẫu Script Hướng Dẫn AI
|
|
152
|
+
Trang `combined.html` có sẵn một mẫu hướng dẫn (prompt template) để yêu cầu AI trả về các thay đổi dưới dạng script shell. Điều này giúp tự động hóa việc áp dụng các thay đổi do AI đề xuất một cách an toàn và có thể kiểm soát.
|
|
153
|
+
|
|
131
154
|
## 📁 Cấu trúc Output
|
|
132
155
|
|
|
133
156
|
```
|
|
134
157
|
vg-output/
|
|
135
|
-
├── index.html # Trang chính với navigation
|
|
136
|
-
├── combined.html # Tất cả code trong một file
|
|
137
|
-
├──
|
|
158
|
+
├── index.html # Trang chính với navigation và cây thư mục
|
|
159
|
+
├── combined.html # Tất cả code trong một file HTML, có chức năng tìm kiếm
|
|
160
|
+
├── combined.txt # Tất cả code trong một file text, tối ưu cho AI
|
|
161
|
+
├── chunks/ # Các chunk riêng biệt (nếu nội dung lớn)
|
|
138
162
|
│ ├── chunk-1.html
|
|
139
|
-
│ ├── chunk-2.html
|
|
140
163
|
│ └── ...
|
|
141
|
-
└── assets/ # CSS, JS
|
|
142
|
-
├── styles.css
|
|
143
|
-
├── scripts.js
|
|
144
|
-
└── highlight.css
|
|
164
|
+
└── assets/ # CSS, JS cho trang HTML
|
|
145
165
|
```
|
|
146
166
|
|
|
147
167
|
## 🎯 Các loại dự án được hỗ trợ
|
|
@@ -152,28 +172,20 @@ vg-output/
|
|
|
152
172
|
- **Languages**: JavaScript, TypeScript, Java, Python, C#, Go, Rust
|
|
153
173
|
- **Config**: JSON, YAML, XML, TOML
|
|
154
174
|
|
|
155
|
-
##
|
|
156
|
-
|
|
157
|
-
### Extensions mặc định
|
|
158
|
-
Tool tự động detect extensions phù hợp với loại dự án:
|
|
159
|
-
- **Web**: .js, .jsx, .ts, .tsx, .vue, .html, .css, .scss
|
|
160
|
-
- **Backend**: .java, .py, .cs, .go, .rs, .php
|
|
161
|
-
- **Config**: .json, .yaml, .xml, .toml, .env
|
|
175
|
+
## 🛡️ Quy tắc bỏ qua file (Ignoring Files)
|
|
162
176
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
- vs2015
|
|
168
|
-
- rainbow
|
|
177
|
+
Công cụ tuân thủ các quy tắc bỏ qua file theo thứ tự ưu tiên sau:
|
|
178
|
+
1. **`.vgignore`**: Các quy tắc trong file này có độ ưu tiên cao nhất.
|
|
179
|
+
2. **`.gitignore`**: Các quy tắc trong file `.gitignore` sẽ được áp dụng.
|
|
180
|
+
3. **Quy tắc mặc định**: Nếu không có các file trên, công cụ sẽ tự động bỏ qua các thư mục và file phổ biến như `node_modules`, `.git`, `dist`, `build`, `target`, các file log, và các thư mục cấu hình của IDE (`.vscode`, `.idea`).
|
|
169
181
|
|
|
170
182
|
## 🤝 Đóng góp
|
|
171
183
|
|
|
172
|
-
1.
|
|
173
|
-
2.
|
|
174
|
-
3.
|
|
175
|
-
4.
|
|
176
|
-
5.
|
|
184
|
+
1. Fork repository
|
|
185
|
+
2. Tạo feature branch (`git checkout -b feature/amazing-feature`)
|
|
186
|
+
3. Commit changes (`git commit -m 'Add amazing feature'`)
|
|
187
|
+
4. Push to branch (`git push origin feature/amazing-feature`)
|
|
188
|
+
5. Tạo Pull Request
|
|
177
189
|
|
|
178
190
|
## 📄 License
|
|
179
191
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -42,6 +42,7 @@ class VGCoderCLI {
|
|
|
42
42
|
.option('--theme <theme>', 'Theme cho syntax highlighting', 'github')
|
|
43
43
|
.option('--clipboard-only', 'Copy content to clipboard without creating files')
|
|
44
44
|
.option('--clipboard', 'Alias for --clipboard-only')
|
|
45
|
+
.option('--save-txt', 'Save AI-friendly content to vg-projects.txt file')
|
|
45
46
|
.action(this.handleAnalyze.bind(this));
|
|
46
47
|
|
|
47
48
|
// Info command
|
|
@@ -68,18 +69,20 @@ class VGCoderCLI {
|
|
|
68
69
|
// Resolve project path
|
|
69
70
|
projectPath = path.resolve(projectPath || process.cwd());
|
|
70
71
|
|
|
71
|
-
// Check
|
|
72
|
+
// Check special modes
|
|
72
73
|
const clipboardMode = options.clipboardOnly || options.clipboard;
|
|
73
|
-
const
|
|
74
|
+
const saveTxtMode = options.saveTxt;
|
|
75
|
+
const specialMode = clipboardMode || saveTxtMode;
|
|
76
|
+
const outputPath = specialMode ? null : path.resolve(options.output || './vg-output');
|
|
74
77
|
|
|
75
78
|
// Validate project path
|
|
76
79
|
if (!await fs.pathExists(projectPath)) {
|
|
77
80
|
throw new Error(`Project path does not exist: ${projectPath}`);
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
// Validate output path for
|
|
81
|
-
if (!
|
|
82
|
-
throw new Error('Output path is required for
|
|
83
|
+
// Validate output path for normal mode
|
|
84
|
+
if (!specialMode && !outputPath) {
|
|
85
|
+
throw new Error('Output path is required for normal mode');
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
spinner.text = 'Detecting project type...';
|
|
@@ -167,6 +170,48 @@ class VGCoderCLI {
|
|
|
167
170
|
return; // Exit early for clipboard mode
|
|
168
171
|
}
|
|
169
172
|
|
|
173
|
+
if (saveTxtMode) {
|
|
174
|
+
// Save-txt mode: create AI-friendly content and save to vg-projects.txt
|
|
175
|
+
spinner.text = 'Creating AI-friendly content...';
|
|
176
|
+
|
|
177
|
+
const aiContent = await scanner.createCombinedContentForAI(scanResult.files, {
|
|
178
|
+
includeStats: false,
|
|
179
|
+
includeTree: false,
|
|
180
|
+
preserveLineNumbers: true
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
spinner.text = 'Saving to vg-projects.txt...';
|
|
184
|
+
|
|
185
|
+
const outputFilePath = path.resolve('vg-projects.txt');
|
|
186
|
+
|
|
187
|
+
// Ensure file is deleted first
|
|
188
|
+
try {
|
|
189
|
+
await fs.unlink(outputFilePath);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
// File doesn't exist, that's fine
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
await fs.writeFile(outputFilePath, aiContent, 'utf8');
|
|
195
|
+
const contentInfo = ClipboardManager.getContentInfo(aiContent);
|
|
196
|
+
|
|
197
|
+
// Cleanup
|
|
198
|
+
tokenManager.cleanup();
|
|
199
|
+
|
|
200
|
+
spinner.succeed('Content saved to vg-projects.txt successfully!');
|
|
201
|
+
|
|
202
|
+
console.log(chalk.green('\n📄 File Content:'));
|
|
203
|
+
console.log(`Output: ${chalk.cyan(outputFilePath)}`);
|
|
204
|
+
console.log(`Files: ${chalk.cyan(scanResult.files.length)}`);
|
|
205
|
+
console.log(`Lines: ${chalk.cyan(contentInfo.lines.toLocaleString())}`);
|
|
206
|
+
console.log(`Characters: ${chalk.cyan(contentInfo.characters.toLocaleString())}`);
|
|
207
|
+
console.log(`Size: ${chalk.cyan(contentInfo.size)}`);
|
|
208
|
+
|
|
209
|
+
console.log(chalk.blue('\n💡 Ready for AI analysis!'));
|
|
210
|
+
console.log('Content is now saved in vg-projects.txt and ready for AI tools.');
|
|
211
|
+
|
|
212
|
+
return; // Exit early for save-txt mode
|
|
213
|
+
}
|
|
214
|
+
|
|
170
215
|
// Normal mode: create HTML output
|
|
171
216
|
const combinedContent = await scanner.createCombinedContent(scanResult.files);
|
|
172
217
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name": "test-large", "version": "1.0.0", "dependencies": {"react": "^18.0.0"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const Button = () => <button>Click me</button>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Button } from "./components/Button"; export default Button;
|
|
Binary file
|
|
Binary file
|
package/vg-projects.txt
ADDED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"name": "test-large", "version": "1.0.0"}
|
package/vg-coder-cli-1.0.6.tgz
DELETED
|
Binary file
|
package/vg-coder-cli-1.0.7.tgz
DELETED
|
Binary file
|