vg-coder-cli 1.0.8 → 1.0.10

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/bin/vg.js ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * VG Coder CLI Entry Point
5
+ */
6
+
7
+ const VGCoderCLI = require('../src/index');
8
+
9
+ // Create and run CLI
10
+ const cli = new VGCoderCLI();
11
+ cli.run();
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "vg-coder-cli",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "🚀 CLI tool to analyze projects, concatenate source files, count tokens, and export HTML with syntax highlighting and copy functionality",
5
5
  "main": "src/index.js",
6
6
  "bin": {
7
+ "vg": "./bin/vg.js",
7
8
  "vg-coder": "./bin/vg-coder.js"
8
9
  },
9
10
  "scripts": {
@@ -11,7 +12,7 @@
11
12
  "test": "jest",
12
13
  "test:watch": "jest --watch",
13
14
  "dev": "nodemon src/index.js",
14
- "push" : "npm pack && npm publish"
15
+ "push": "npm pack && npm publish"
15
16
  },
16
17
  "keywords": [
17
18
  "cli",
@@ -61,4 +62,4 @@
61
62
  "engines": {
62
63
  "node": ">=16.0.0"
63
64
  }
64
- }
65
+ }
package/src/index.js CHANGED
@@ -25,13 +25,14 @@ class VGCoderCLI {
25
25
  */
26
26
  setupCommands() {
27
27
  this.program
28
- .name('vg-coder')
28
+ .name('vg')
29
29
  .description('CLI tool để phân tích dự án, nối file mã nguồn, đếm token và xuất HTML')
30
30
  .version(packageJson.version);
31
31
 
32
32
  // Analyze command
33
33
  this.program
34
34
  .command('analyze [path]')
35
+ .alias('a')
35
36
  .description('Phân tích dự án và tạo output HTML')
36
37
  .option('-o, --output <path>', 'Thư mục output', './vg-output')
37
38
  .option('-m, --max-tokens <number>', 'Số token tối đa mỗi chunk', '8000')
@@ -41,7 +42,8 @@ class VGCoderCLI {
41
42
  .option('--no-structure', 'Không ưu tiên giữ cấu trúc file')
42
43
  .option('--theme <theme>', 'Theme cho syntax highlighting', 'github')
43
44
  .option('--clipboard-only', 'Copy content to clipboard without creating files')
44
- .option('--clipboard', 'Alias for --clipboard-only')
45
+ .option('-c, --clipboard', 'Alias for --clipboard-only')
46
+ .option('--save-txt', 'Save AI-friendly content to vg-projects.txt file')
45
47
  .action(this.handleAnalyze.bind(this));
46
48
 
47
49
  // Info command
@@ -68,18 +70,20 @@ class VGCoderCLI {
68
70
  // Resolve project path
69
71
  projectPath = path.resolve(projectPath || process.cwd());
70
72
 
71
- // Check if clipboard-only mode
73
+ // Check special modes
72
74
  const clipboardMode = options.clipboardOnly || options.clipboard;
73
- const outputPath = clipboardMode ? null : path.resolve(options.output || './vg-output');
75
+ const saveTxtMode = options.saveTxt;
76
+ const specialMode = clipboardMode || saveTxtMode;
77
+ const outputPath = specialMode ? null : path.resolve(options.output || './vg-output');
74
78
 
75
79
  // Validate project path
76
80
  if (!await fs.pathExists(projectPath)) {
77
81
  throw new Error(`Project path does not exist: ${projectPath}`);
78
82
  }
79
83
 
80
- // Validate output path for non-clipboard mode
81
- if (!clipboardMode && !outputPath) {
82
- throw new Error('Output path is required for non-clipboard mode');
84
+ // Validate output path for normal mode
85
+ if (!specialMode && !outputPath) {
86
+ throw new Error('Output path is required for normal mode');
83
87
  }
84
88
 
85
89
  spinner.text = 'Detecting project type...';
@@ -167,6 +171,48 @@ class VGCoderCLI {
167
171
  return; // Exit early for clipboard mode
168
172
  }
169
173
 
174
+ if (saveTxtMode) {
175
+ // Save-txt mode: create AI-friendly content and save to vg-projects.txt
176
+ spinner.text = 'Creating AI-friendly content...';
177
+
178
+ const aiContent = await scanner.createCombinedContentForAI(scanResult.files, {
179
+ includeStats: false,
180
+ includeTree: false,
181
+ preserveLineNumbers: true
182
+ });
183
+
184
+ spinner.text = 'Saving to vg-projects.txt...';
185
+
186
+ const outputFilePath = path.resolve('vg-projects.txt');
187
+
188
+ // Ensure file is deleted first
189
+ try {
190
+ await fs.unlink(outputFilePath);
191
+ } catch (error) {
192
+ // File doesn't exist, that's fine
193
+ }
194
+
195
+ await fs.writeFile(outputFilePath, aiContent, 'utf8');
196
+ const contentInfo = ClipboardManager.getContentInfo(aiContent);
197
+
198
+ // Cleanup
199
+ tokenManager.cleanup();
200
+
201
+ spinner.succeed('Content saved to vg-projects.txt successfully!');
202
+
203
+ console.log(chalk.green('\n📄 File Content:'));
204
+ console.log(`Output: ${chalk.cyan(outputFilePath)}`);
205
+ console.log(`Files: ${chalk.cyan(scanResult.files.length)}`);
206
+ console.log(`Lines: ${chalk.cyan(contentInfo.lines.toLocaleString())}`);
207
+ console.log(`Characters: ${chalk.cyan(contentInfo.characters.toLocaleString())}`);
208
+ console.log(`Size: ${chalk.cyan(contentInfo.size)}`);
209
+
210
+ console.log(chalk.blue('\n💡 Ready for AI analysis!'));
211
+ console.log('Content is now saved in vg-projects.txt and ready for AI tools.');
212
+
213
+ return; // Exit early for save-txt mode
214
+ }
215
+
170
216
  // Normal mode: create HTML output
171
217
  const combinedContent = await scanner.createCombinedContent(scanResult.files);
172
218
 
Binary file