vg-coder-cli 1.0.17 → 2.0.0
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 +59 -0
- package/PUBLISHING.md +86 -0
- package/README.md +92 -318
- package/SYSTEM_PROMPT.md +157 -0
- package/init-nx-monorepo.sh +107 -0
- package/package.json +11 -4
- package/vg/.vscode/extensions.json +8 -0
- package/vg/.vscode/launch.json +23 -0
- package/vg/README.md +85 -0
- package/vg/apps/api/project.json +83 -0
- package/vg/apps/api/src/app/analyze.controller.ts +17 -0
- package/vg/apps/api/src/app/analyze.service.ts +57 -0
- package/vg/apps/api/src/app/app.controller.ts +12 -0
- package/vg/apps/api/src/app/app.module.ts +29 -0
- package/vg/apps/api/src/app/app.service.ts +8 -0
- package/vg/apps/api/src/app/clean.controller.ts +40 -0
- package/vg/apps/api/src/app/execute.controller.ts +19 -0
- package/vg/apps/api/src/app/execute.service.ts +46 -0
- package/vg/apps/api/src/app/info.controller.ts +12 -0
- package/vg/apps/api/src/app/info.service.ts +65 -0
- package/vg/apps/api/src/assets/.gitkeep +0 -0
- package/vg/apps/api/src/main.ts +28 -0
- package/vg/apps/api/webpack.config.js +25 -0
- package/vg/apps/api-e2e/jest.config.cts +18 -0
- package/vg/apps/api-e2e/project.json +17 -0
- package/vg/apps/api-e2e/src/support/global-setup.ts +16 -0
- package/vg/apps/api-e2e/src/support/global-teardown.ts +10 -0
- package/vg/apps/api-e2e/src/support/test-setup.ts +9 -0
- package/vg/apps/ng-app/jest.config.ts +21 -0
- package/vg/apps/ng-app/project.json +110 -0
- package/vg/apps/ng-app/proxy.conf.json +8 -0
- package/vg/apps/ng-app/public/favicon.ico +0 -0
- package/vg/apps/ng-app/src/app/app.config.ts +17 -0
- package/vg/apps/ng-app/src/app/app.html +1 -0
- package/vg/apps/ng-app/src/app/app.routes.ts +7 -0
- package/vg/apps/ng-app/src/app/app.scss +0 -0
- package/vg/apps/ng-app/src/app/app.ts +12 -0
- package/vg/apps/ng-app/src/app/dashboard/dashboard.component.html +87 -0
- package/vg/apps/ng-app/src/app/dashboard/dashboard.component.scss +290 -0
- package/vg/apps/ng-app/src/app/dashboard/dashboard.component.ts +236 -0
- package/vg/apps/ng-app/src/app/nx-welcome.ts +872 -0
- package/vg/apps/ng-app/src/app/services/api.service.ts +28 -0
- package/vg/apps/ng-app/src/index.html +13 -0
- package/vg/apps/ng-app/src/main.ts +5 -0
- package/vg/apps/ng-app/src/styles.scss +1 -0
- package/vg/apps/ng-app/src/test-setup.ts +6 -0
- package/vg/jest.config.ts +6 -0
- package/vg/nx.json +85 -0
- package/vg/package-lock.json +30707 -0
- package/vg/package.json +75 -0
- package/vg/packages/client/data-access/README.md +7 -0
- package/vg/packages/client/data-access/jest.config.ts +21 -0
- package/vg/packages/client/data-access/project.json +21 -0
- package/vg/packages/client/data-access/src/index.ts +1 -0
- package/vg/packages/client/data-access/src/lib/data-access/data-access.html +1 -0
- package/vg/packages/client/data-access/src/lib/data-access/data-access.scss +0 -0
- package/vg/packages/client/data-access/src/lib/data-access/data-access.ts +9 -0
- package/vg/packages/client/data-access/src/test-setup.ts +6 -0
- package/vg/packages/core/README.md +11 -0
- package/vg/packages/core/jest.config.ts +10 -0
- package/vg/packages/core/package.json +11 -0
- package/vg/packages/core/project.json +26 -0
- package/vg/packages/core/src/index.ts +6 -0
- package/vg/packages/core/src/lib/core.ts +3 -0
- package/vg/packages/core/src/lib/detectors/project-detector.ts +343 -0
- package/vg/packages/core/src/lib/ignore/ignore-manager.ts +315 -0
- package/vg/packages/core/src/lib/scanner/file-scanner.ts +675 -0
- package/vg/packages/core/src/lib/tokenizer/token-manager.ts +435 -0
- package/vg/packages/core/src/lib/utils/bash-executor.ts +146 -0
- package/vg/packages/shared/data-types/README.md +11 -0
- package/vg/packages/shared/data-types/jest.config.ts +10 -0
- package/vg/packages/shared/data-types/package.json +11 -0
- package/vg/packages/shared/data-types/project.json +26 -0
- package/vg/packages/shared/data-types/src/index.ts +1 -0
- package/vg/packages/shared/data-types/src/lib/data-types.ts +3 -0
- package/vg/start-dev.sh +22 -0
- package/vg-coder-cli-1.0.17.tgz +0 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import * as fs from 'fs-extra';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import ignore from 'ignore';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Manage ignore patterns following Git standards
|
|
7
|
+
*/
|
|
8
|
+
export class IgnoreManager {
|
|
9
|
+
private ignoreInstances = new Map<string, any>(); // Cache ignore instances by directory
|
|
10
|
+
private defaultIgnores: string[];
|
|
11
|
+
|
|
12
|
+
constructor(private projectPath: string) {
|
|
13
|
+
this.defaultIgnores = this.getDefaultIgnores();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get list of default ignore patterns
|
|
18
|
+
*/
|
|
19
|
+
getDefaultIgnores(): string[] {
|
|
20
|
+
return [
|
|
21
|
+
// Node.js
|
|
22
|
+
'node_modules/',
|
|
23
|
+
'package-lock.json',
|
|
24
|
+
'yarn.lock',
|
|
25
|
+
'npm-debug.log*',
|
|
26
|
+
'yarn-debug.log*',
|
|
27
|
+
'yarn-error.log*',
|
|
28
|
+
'.npm',
|
|
29
|
+
'.yarn/',
|
|
30
|
+
|
|
31
|
+
// Build outputs
|
|
32
|
+
'dist/',
|
|
33
|
+
'build/',
|
|
34
|
+
'out/',
|
|
35
|
+
'target/',
|
|
36
|
+
'bin/',
|
|
37
|
+
'obj/',
|
|
38
|
+
|
|
39
|
+
// IDE and Editor
|
|
40
|
+
'.vscode/',
|
|
41
|
+
'.idea/',
|
|
42
|
+
'*.swp',
|
|
43
|
+
'*.swo',
|
|
44
|
+
'*~',
|
|
45
|
+
'.DS_Store',
|
|
46
|
+
'Thumbs.db',
|
|
47
|
+
|
|
48
|
+
// Logs
|
|
49
|
+
'logs/',
|
|
50
|
+
'*.log',
|
|
51
|
+
|
|
52
|
+
// Environment files
|
|
53
|
+
'.env',
|
|
54
|
+
'.env.local',
|
|
55
|
+
'.env.development.local',
|
|
56
|
+
'.env.test.local',
|
|
57
|
+
'.env.production.local',
|
|
58
|
+
|
|
59
|
+
// Cache directories
|
|
60
|
+
'.cache/',
|
|
61
|
+
'.parcel-cache/',
|
|
62
|
+
'.next/',
|
|
63
|
+
'.nuxt/',
|
|
64
|
+
|
|
65
|
+
// Coverage reports
|
|
66
|
+
'coverage/',
|
|
67
|
+
'*.lcov',
|
|
68
|
+
|
|
69
|
+
// Dependency directories
|
|
70
|
+
'bower_components/',
|
|
71
|
+
'jspm_packages/',
|
|
72
|
+
|
|
73
|
+
// Java
|
|
74
|
+
'*.class',
|
|
75
|
+
'*.jar',
|
|
76
|
+
'*.war',
|
|
77
|
+
'*.ear',
|
|
78
|
+
'.gradle/',
|
|
79
|
+
|
|
80
|
+
// Python
|
|
81
|
+
'__pycache__/',
|
|
82
|
+
'*.py[cod]',
|
|
83
|
+
'*$py.class',
|
|
84
|
+
'*.so',
|
|
85
|
+
'.Python',
|
|
86
|
+
'env/',
|
|
87
|
+
'venv/',
|
|
88
|
+
'.venv/',
|
|
89
|
+
'pip-log.txt',
|
|
90
|
+
'pip-delete-this-directory.txt',
|
|
91
|
+
|
|
92
|
+
// .NET
|
|
93
|
+
'[Bb]in/',
|
|
94
|
+
'[Oo]bj/',
|
|
95
|
+
'*.user',
|
|
96
|
+
'*.suo',
|
|
97
|
+
'*.userosscache',
|
|
98
|
+
'*.sln.docstates',
|
|
99
|
+
|
|
100
|
+
// Temporary files
|
|
101
|
+
'*.tmp',
|
|
102
|
+
'*.temp',
|
|
103
|
+
'*.bak',
|
|
104
|
+
'*.backup',
|
|
105
|
+
|
|
106
|
+
// OS generated files
|
|
107
|
+
'.DS_Store?',
|
|
108
|
+
'ehthumbs.db',
|
|
109
|
+
'Icon?',
|
|
110
|
+
|
|
111
|
+
// VG Coder output
|
|
112
|
+
'vg-output/'
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Get ignore instance for a specific directory
|
|
118
|
+
*/
|
|
119
|
+
async getIgnoreInstance(dirPath: string): Promise<any> {
|
|
120
|
+
const relativePath = path.relative(this.projectPath, dirPath);
|
|
121
|
+
const cacheKey = relativePath || '.';
|
|
122
|
+
|
|
123
|
+
if (this.ignoreInstances.has(cacheKey)) {
|
|
124
|
+
return this.ignoreInstances.get(cacheKey);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const ig = ignore();
|
|
128
|
+
|
|
129
|
+
// Add default ignores
|
|
130
|
+
ig.add(this.defaultIgnores);
|
|
131
|
+
|
|
132
|
+
// Read .gitignore and .vgignore from root to current directory
|
|
133
|
+
const pathParts = relativePath ? relativePath.split(path.sep) : [];
|
|
134
|
+
let currentPath = this.projectPath;
|
|
135
|
+
|
|
136
|
+
// Read .gitignore and .vgignore from root
|
|
137
|
+
await this.addIgnoreFromPath(ig, currentPath);
|
|
138
|
+
|
|
139
|
+
// Read .gitignore and .vgignore from subdirectories in order
|
|
140
|
+
for (const part of pathParts) {
|
|
141
|
+
currentPath = path.join(currentPath, part);
|
|
142
|
+
await this.addIgnoreFromPath(ig, currentPath);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this.ignoreInstances.set(cacheKey, ig);
|
|
146
|
+
return ig;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Add patterns from .gitignore and .vgignore files
|
|
151
|
+
*/
|
|
152
|
+
async addIgnoreFromPath(ig: any, dirPath: string): Promise<void> {
|
|
153
|
+
// Read .gitignore
|
|
154
|
+
const gitignorePath = path.join(dirPath, '.gitignore');
|
|
155
|
+
try {
|
|
156
|
+
if (await fs.pathExists(gitignorePath)) {
|
|
157
|
+
const content = await fs.readFile(gitignorePath, 'utf8');
|
|
158
|
+
const patterns = this.parseIgnoreContent(content, dirPath);
|
|
159
|
+
ig.add(patterns);
|
|
160
|
+
}
|
|
161
|
+
} catch (error) {
|
|
162
|
+
// Ignore errors reading .gitignore files
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Read .vgignore (has higher priority than .gitignore)
|
|
166
|
+
const vgignorePath = path.join(dirPath, '.vgignore');
|
|
167
|
+
try {
|
|
168
|
+
if (await fs.pathExists(vgignorePath)) {
|
|
169
|
+
const content = await fs.readFile(vgignorePath, 'utf8');
|
|
170
|
+
const patterns = this.parseIgnoreContent(content, dirPath);
|
|
171
|
+
ig.add(patterns);
|
|
172
|
+
}
|
|
173
|
+
} catch (error) {
|
|
174
|
+
// Ignore errors reading .vgignore files
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Parse content of .gitignore and .vgignore
|
|
180
|
+
*/
|
|
181
|
+
parseIgnoreContent(content: string, basePath: string): string[] {
|
|
182
|
+
const lines = content.split('\n');
|
|
183
|
+
const patterns: string[] = [];
|
|
184
|
+
|
|
185
|
+
for (let line of lines) {
|
|
186
|
+
line = line.trim();
|
|
187
|
+
|
|
188
|
+
// Skip empty lines and comments
|
|
189
|
+
if (!line || line.startsWith('#')) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Handle relative path from basePath
|
|
194
|
+
const relativePath = path.relative(this.projectPath, basePath);
|
|
195
|
+
if (relativePath && !line.startsWith('/')) {
|
|
196
|
+
// If pattern doesn't start with /, add relative path
|
|
197
|
+
line = path.posix.join(relativePath, line);
|
|
198
|
+
} else if (line.startsWith('/')) {
|
|
199
|
+
// Remove leading slash for absolute patterns
|
|
200
|
+
line = line.substring(1);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
patterns.push(line);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return patterns;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Check if a file/directory should be ignored
|
|
211
|
+
*/
|
|
212
|
+
async shouldIgnore(filePath: string): Promise<boolean> {
|
|
213
|
+
try {
|
|
214
|
+
const absolutePath = path.resolve(this.projectPath, filePath);
|
|
215
|
+
const relativePath = path.relative(this.projectPath, absolutePath);
|
|
216
|
+
|
|
217
|
+
// Do not ignore if file is outside project
|
|
218
|
+
if (relativePath.startsWith('..')) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const dirPath = path.dirname(absolutePath);
|
|
223
|
+
const ig = await this.getIgnoreInstance(dirPath);
|
|
224
|
+
|
|
225
|
+
return ig.ignores(relativePath);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Filter list of files/directories
|
|
233
|
+
*/
|
|
234
|
+
async filterIgnored(items: string[]): Promise<string[]> {
|
|
235
|
+
const results: string[] = [];
|
|
236
|
+
|
|
237
|
+
for (const item of items) {
|
|
238
|
+
const shouldIgnore = await this.shouldIgnore(item);
|
|
239
|
+
if (!shouldIgnore) {
|
|
240
|
+
results.push(item);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return results;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Get all patterns currently applied to a directory
|
|
249
|
+
*/
|
|
250
|
+
async getAppliedPatterns(dirPath: string = this.projectPath): Promise<{ default: string[], gitignore: string[] }> {
|
|
251
|
+
const ig = await this.getIgnoreInstance(dirPath);
|
|
252
|
+
// Access internal _rules if available, otherwise this might need adjustment depending on ignore package version
|
|
253
|
+
// For now assuming _rules exists or we might need another way to get rules
|
|
254
|
+
const rules = (ig as any)._rules || [];
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
default: this.defaultIgnores,
|
|
258
|
+
gitignore: rules.filter((rule: any) => !this.defaultIgnores.includes(rule.origin))
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Check if there are any .gitignore files
|
|
264
|
+
*/
|
|
265
|
+
async hasGitignoreFiles(): Promise<string[]> {
|
|
266
|
+
const gitignoreFiles: string[] = [];
|
|
267
|
+
|
|
268
|
+
const checkGitignore = async (dirPath: string) => {
|
|
269
|
+
const gitignorePath = path.join(dirPath, '.gitignore');
|
|
270
|
+
if (await fs.pathExists(gitignorePath)) {
|
|
271
|
+
gitignoreFiles.push(path.relative(this.projectPath, gitignorePath));
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// Check root
|
|
276
|
+
await checkGitignore(this.projectPath);
|
|
277
|
+
|
|
278
|
+
// Check subdirectories (only 2 levels to avoid being too slow)
|
|
279
|
+
try {
|
|
280
|
+
const items = await fs.readdir(this.projectPath);
|
|
281
|
+
for (const item of items) {
|
|
282
|
+
const itemPath = path.join(this.projectPath, item);
|
|
283
|
+
const stat = await fs.stat(itemPath);
|
|
284
|
+
if (stat.isDirectory()) {
|
|
285
|
+
await checkGitignore(itemPath);
|
|
286
|
+
|
|
287
|
+
// Level 2
|
|
288
|
+
try {
|
|
289
|
+
const subItems = await fs.readdir(itemPath);
|
|
290
|
+
for (const subItem of subItems) {
|
|
291
|
+
const subItemPath = path.join(itemPath, subItem);
|
|
292
|
+
const subStat = await fs.stat(subItemPath);
|
|
293
|
+
if (subStat.isDirectory()) {
|
|
294
|
+
await checkGitignore(subItemPath);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
} catch (error) {
|
|
298
|
+
// Ignore errors
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
} catch (error) {
|
|
303
|
+
// Ignore errors
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return gitignoreFiles;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Clear cache
|
|
311
|
+
*/
|
|
312
|
+
clearCache(): void {
|
|
313
|
+
this.ignoreInstances.clear();
|
|
314
|
+
}
|
|
315
|
+
}
|