vg-coder-cli 1.0.4 → 1.0.6
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 +10 -0
- package/bin/vg-coder.js +5 -2
- package/package.json +1 -1
- package/src/ignore/ignore-manager.js +27 -13
- package/src/index.js +2 -1
- package/src/tokenizer/token-manager.js +8 -11
- package/test-small/package-lock.json +1 -0
- package/vg-coder-cli-1.0.5.tgz +0 -0
- package/vg-coder-cli-1.0.6.tgz +0 -0
package/.vgignore
ADDED
package/bin/vg-coder.js
CHANGED
package/package.json
CHANGED
|
@@ -19,6 +19,8 @@ class IgnoreManager {
|
|
|
19
19
|
return [
|
|
20
20
|
// Node.js
|
|
21
21
|
'node_modules/',
|
|
22
|
+
'package-lock.json',
|
|
23
|
+
'yarn.lock',
|
|
22
24
|
'npm-debug.log*',
|
|
23
25
|
'yarn-debug.log*',
|
|
24
26
|
'yarn-error.log*',
|
|
@@ -126,17 +128,17 @@ class IgnoreManager {
|
|
|
126
128
|
// Thêm default ignores
|
|
127
129
|
ig.add(this.defaultIgnores);
|
|
128
130
|
|
|
129
|
-
// Đọc .gitignore từ root đến thư mục hiện tại
|
|
131
|
+
// Đọc .gitignore và .vgignore từ root đến thư mục hiện tại
|
|
130
132
|
const pathParts = relativePath ? relativePath.split(path.sep) : [];
|
|
131
133
|
let currentPath = this.projectPath;
|
|
132
|
-
|
|
133
|
-
// Đọc .gitignore từ root
|
|
134
|
-
await this.
|
|
135
|
-
|
|
136
|
-
// Đọc .gitignore từ các thư mục con theo thứ tự
|
|
134
|
+
|
|
135
|
+
// Đọc .gitignore và .vgignore từ root
|
|
136
|
+
await this.addIgnoreFromPath(ig, currentPath);
|
|
137
|
+
|
|
138
|
+
// Đọc .gitignore và .vgignore từ các thư mục con theo thứ tự
|
|
137
139
|
for (const part of pathParts) {
|
|
138
140
|
currentPath = path.join(currentPath, part);
|
|
139
|
-
await this.
|
|
141
|
+
await this.addIgnoreFromPath(ig, currentPath);
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
this.ignoreInstances.set(cacheKey, ig);
|
|
@@ -144,26 +146,38 @@ class IgnoreManager {
|
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
/**
|
|
147
|
-
* Thêm patterns từ .gitignore
|
|
149
|
+
* Thêm patterns từ .gitignore và .vgignore files
|
|
148
150
|
*/
|
|
149
|
-
async
|
|
151
|
+
async addIgnoreFromPath(ig, dirPath) {
|
|
152
|
+
// Đọc .gitignore
|
|
150
153
|
const gitignorePath = path.join(dirPath, '.gitignore');
|
|
151
|
-
|
|
152
154
|
try {
|
|
153
155
|
if (await fs.pathExists(gitignorePath)) {
|
|
154
156
|
const content = await fs.readFile(gitignorePath, 'utf8');
|
|
155
|
-
const patterns = this.
|
|
157
|
+
const patterns = this.parseIgnoreContent(content, dirPath);
|
|
156
158
|
ig.add(patterns);
|
|
157
159
|
}
|
|
158
160
|
} catch (error) {
|
|
159
161
|
// Ignore errors reading .gitignore files
|
|
160
162
|
}
|
|
163
|
+
|
|
164
|
+
// Đọc .vgignore (có priority cao hơn .gitignore)
|
|
165
|
+
const vgignorePath = path.join(dirPath, '.vgignore');
|
|
166
|
+
try {
|
|
167
|
+
if (await fs.pathExists(vgignorePath)) {
|
|
168
|
+
const content = await fs.readFile(vgignorePath, 'utf8');
|
|
169
|
+
const patterns = this.parseIgnoreContent(content, dirPath);
|
|
170
|
+
ig.add(patterns);
|
|
171
|
+
}
|
|
172
|
+
} catch (error) {
|
|
173
|
+
// Ignore errors reading .vgignore files
|
|
174
|
+
}
|
|
161
175
|
}
|
|
162
176
|
|
|
163
177
|
/**
|
|
164
|
-
* Parse nội dung .gitignore
|
|
178
|
+
* Parse nội dung .gitignore và .vgignore
|
|
165
179
|
*/
|
|
166
|
-
|
|
180
|
+
parseIgnoreContent(content, basePath) {
|
|
167
181
|
const lines = content.split('\n');
|
|
168
182
|
const patterns = [];
|
|
169
183
|
|
package/src/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const path = require('path');
|
|
|
3
3
|
const fs = require('fs-extra');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const ora = require('ora');
|
|
6
|
+
const packageJson = require('../package.json');
|
|
6
7
|
|
|
7
8
|
const ProjectDetector = require('./detectors/project-detector');
|
|
8
9
|
const FileScanner = require('./scanner/file-scanner');
|
|
@@ -25,7 +26,7 @@ class VGCoderCLI {
|
|
|
25
26
|
this.program
|
|
26
27
|
.name('vg-coder')
|
|
27
28
|
.description('CLI tool để phân tích dự án, nối file mã nguồn, đếm token và xuất HTML')
|
|
28
|
-
.version(
|
|
29
|
+
.version(packageJson.version);
|
|
29
30
|
|
|
30
31
|
// Analyze command
|
|
31
32
|
this.program
|
|
@@ -247,17 +247,15 @@ class TokenManager {
|
|
|
247
247
|
let currentTokens = 0;
|
|
248
248
|
let chunkIndex = 0;
|
|
249
249
|
|
|
250
|
-
//
|
|
251
|
-
|
|
252
|
-
|
|
250
|
+
// Không thêm header "Large File" nữa để UI sạch hơn
|
|
251
|
+
|
|
253
252
|
for (const line of lines) {
|
|
254
253
|
const lineTokens = this.countTokens(line + '\n');
|
|
255
|
-
|
|
256
|
-
if (currentTokens + lineTokens > this.options.maxTokens
|
|
257
|
-
const partHeader = header.replace('{part}', (chunkIndex + 1).toString());
|
|
254
|
+
|
|
255
|
+
if (currentTokens + lineTokens > this.options.maxTokens && currentChunk) {
|
|
258
256
|
chunks.push({
|
|
259
|
-
content:
|
|
260
|
-
tokens: this.countTokens(
|
|
257
|
+
content: currentChunk.trim(),
|
|
258
|
+
tokens: this.countTokens(currentChunk.trim()),
|
|
261
259
|
chunkIndex: chunkIndex++,
|
|
262
260
|
totalChunks: 0,
|
|
263
261
|
metadata: {
|
|
@@ -277,10 +275,9 @@ class TokenManager {
|
|
|
277
275
|
|
|
278
276
|
// Thêm chunk cuối cùng
|
|
279
277
|
if (currentChunk.trim()) {
|
|
280
|
-
const partHeader = header.replace('{part}', (chunkIndex + 1).toString());
|
|
281
278
|
chunks.push({
|
|
282
|
-
content:
|
|
283
|
-
tokens: this.countTokens(
|
|
279
|
+
content: currentChunk.trim(),
|
|
280
|
+
tokens: this.countTokens(currentChunk.trim()),
|
|
284
281
|
chunkIndex: chunkIndex++,
|
|
285
282
|
totalChunks: 0,
|
|
286
283
|
metadata: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name": "test-large", "version": "1.0.0"}
|
|
Binary file
|
|
Binary file
|