baseguard 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.
Files changed (84) hide show
  1. package/dist/ai/gemini-analyzer.d.ts.map +1 -1
  2. package/dist/ai/gemini-analyzer.js +1 -1
  3. package/dist/ai/gemini-analyzer.js.map +1 -1
  4. package/dist/ai/gemini-code-fixer.d.ts.map +1 -1
  5. package/dist/ai/gemini-code-fixer.js +2 -7
  6. package/dist/ai/gemini-code-fixer.js.map +1 -1
  7. package/dist/ai/jules-implementer.d.ts +8 -0
  8. package/dist/ai/jules-implementer.d.ts.map +1 -1
  9. package/dist/ai/jules-implementer.js +115 -17
  10. package/dist/ai/jules-implementer.js.map +1 -1
  11. package/dist/commands/fix.d.ts.map +1 -1
  12. package/dist/commands/fix.js +5 -1
  13. package/dist/commands/fix.js.map +1 -1
  14. package/dist/core/baseline-checker.d.ts.map +1 -1
  15. package/dist/core/baseline-checker.js +6 -4
  16. package/dist/core/baseline-checker.js.map +1 -1
  17. package/package.json +1 -1
  18. package/src/ai/__tests__/gemini-analyzer.test.ts +0 -181
  19. package/src/ai/agentkit-orchestrator.ts +0 -534
  20. package/src/ai/fix-manager.ts +0 -362
  21. package/src/ai/gemini-analyzer.ts +0 -665
  22. package/src/ai/gemini-code-fixer.ts +0 -539
  23. package/src/ai/index.ts +0 -4
  24. package/src/ai/jules-implementer.ts +0 -504
  25. package/src/ai/unified-code-fixer.ts +0 -347
  26. package/src/commands/automation.ts +0 -344
  27. package/src/commands/check.ts +0 -298
  28. package/src/commands/config.ts +0 -584
  29. package/src/commands/fix.ts +0 -264
  30. package/src/commands/index.ts +0 -7
  31. package/src/commands/init.ts +0 -156
  32. package/src/commands/status.ts +0 -307
  33. package/src/core/api-key-manager.ts +0 -298
  34. package/src/core/baseguard.ts +0 -757
  35. package/src/core/baseline-checker.ts +0 -564
  36. package/src/core/cache-manager.ts +0 -272
  37. package/src/core/configuration-recovery.ts +0 -672
  38. package/src/core/configuration.ts +0 -596
  39. package/src/core/debug-logger.ts +0 -590
  40. package/src/core/directory-filter.ts +0 -421
  41. package/src/core/error-handler.ts +0 -518
  42. package/src/core/file-processor.ts +0 -338
  43. package/src/core/gitignore-manager.ts +0 -169
  44. package/src/core/graceful-degradation-manager.ts +0 -596
  45. package/src/core/index.ts +0 -17
  46. package/src/core/lazy-loader.ts +0 -317
  47. package/src/core/logger.ts +0 -0
  48. package/src/core/memory-manager.ts +0 -290
  49. package/src/core/parser-worker.ts +0 -33
  50. package/src/core/startup-optimizer.ts +0 -246
  51. package/src/core/system-error-handler.ts +0 -755
  52. package/src/git/automation-engine.ts +0 -361
  53. package/src/git/github-manager.ts +0 -190
  54. package/src/git/hook-manager.ts +0 -210
  55. package/src/git/index.ts +0 -4
  56. package/src/index.ts +0 -8
  57. package/src/parsers/feature-validator.ts +0 -559
  58. package/src/parsers/index.ts +0 -8
  59. package/src/parsers/parser-manager.ts +0 -418
  60. package/src/parsers/parser.ts +0 -26
  61. package/src/parsers/react-parser-optimized.ts +0 -161
  62. package/src/parsers/react-parser.ts +0 -359
  63. package/src/parsers/svelte-parser.ts +0 -510
  64. package/src/parsers/vanilla-parser.ts +0 -685
  65. package/src/parsers/vue-parser.ts +0 -476
  66. package/src/types/index.ts +0 -96
  67. package/src/ui/components.ts +0 -567
  68. package/src/ui/help.ts +0 -193
  69. package/src/ui/index.ts +0 -4
  70. package/src/ui/prompts.ts +0 -681
  71. package/src/ui/terminal-header.ts +0 -59
  72. package/tests/e2e/baseguard.e2e.test.ts +0 -516
  73. package/tests/e2e/cross-platform.e2e.test.ts +0 -420
  74. package/tests/e2e/git-integration.e2e.test.ts +0 -487
  75. package/tests/fixtures/react-project/package.json +0 -14
  76. package/tests/fixtures/react-project/src/App.css +0 -76
  77. package/tests/fixtures/react-project/src/App.tsx +0 -77
  78. package/tests/fixtures/svelte-project/package.json +0 -11
  79. package/tests/fixtures/svelte-project/src/App.svelte +0 -369
  80. package/tests/fixtures/vanilla-project/index.html +0 -76
  81. package/tests/fixtures/vanilla-project/script.js +0 -331
  82. package/tests/fixtures/vanilla-project/styles.css +0 -359
  83. package/tests/fixtures/vue-project/package.json +0 -12
  84. package/tests/fixtures/vue-project/src/App.vue +0 -216
@@ -1,510 +0,0 @@
1
- import { Parser } from './parser.js';
2
- import type { DetectedFeature } from '../types/index.js';
3
- import { LazyLoader } from '../core/lazy-loader.js';
4
- import { parse as parseBabel } from '@babel/parser';
5
- import traverse from '@babel/traverse';
6
- import * as t from '@babel/types';
7
- import postcss from 'postcss';
8
-
9
- /**
10
- * Parser for Svelte files (.svelte) - extracts ALL web platform features
11
- * while ignoring Svelte-specific syntax
12
- */
13
- export class SvelteParser extends Parser {
14
- private readonly SVELTE_SPECIFIC_APIS = new Set([
15
- // Svelte stores
16
- 'writable', 'readable', 'derived', 'get', 'subscribe', 'set', 'update',
17
-
18
- // Svelte lifecycle
19
- 'onMount', 'onDestroy', 'beforeUpdate', 'afterUpdate', 'tick',
20
- 'setContext', 'getContext', 'hasContext', 'getAllContexts',
21
-
22
- // Svelte actions and transitions
23
- 'createEventDispatcher', 'dispatch',
24
-
25
- // SvelteKit specific
26
- 'page', 'navigating', 'updated', 'goto', 'prefetch', 'prefetchRoutes',
27
- 'invalidate', 'invalidateAll', 'preloadData', 'preloadCode',
28
-
29
- // Svelte compiler directives (handled separately)
30
- 'bind', 'on', 'use', 'transition', 'in', 'out', 'animate'
31
- ]);
32
-
33
- private readonly SVELTE_DIRECTIVES = new Set([
34
- 'bind:', 'on:', 'use:', 'transition:', 'in:', 'out:', 'animate:', 'class:', 'style:'
35
- ]);
36
-
37
- private readonly WEB_PLATFORM_APIS = new Set([
38
- // Canvas APIs
39
- 'getContext', 'CanvasRenderingContext2D', 'WebGLRenderingContext', 'WebGL2RenderingContext',
40
- 'OffscreenCanvas', 'ImageBitmap', 'createImageBitmap', 'Path2D',
41
-
42
- // WebRTC APIs
43
- 'RTCPeerConnection', 'RTCDataChannel', 'RTCSessionDescription', 'RTCIceCandidate',
44
- 'getUserMedia', 'getDisplayMedia', 'MediaStream', 'MediaStreamTrack',
45
-
46
- // WebAssembly
47
- 'WebAssembly', 'instantiate', 'compile', 'validate',
48
-
49
- // Service Workers & PWA
50
- 'ServiceWorker', 'serviceWorker', 'register', 'Cache', 'caches',
51
- 'PushManager', 'Notification', 'showNotification',
52
-
53
- // DOM APIs
54
- 'querySelector', 'querySelectorAll', 'getElementById', 'getElementsByClassName',
55
- 'addEventListener', 'removeEventListener', 'dispatchEvent', 'CustomEvent',
56
- 'MutationObserver', 'ResizeObserver', 'IntersectionObserver', 'PerformanceObserver',
57
- 'AbortController', 'AbortSignal', 'FormData', 'URLSearchParams', 'URL',
58
- 'fetch', 'Request', 'Response', 'Headers', 'Blob', 'File', 'FileReader',
59
-
60
- // Web APIs
61
- 'navigator', 'geolocation', 'permissions', 'clipboard', 'share',
62
- 'requestAnimationFrame', 'cancelAnimationFrame', 'requestIdleCallback',
63
- 'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
64
- 'localStorage', 'sessionStorage', 'indexedDB', 'crypto', 'performance',
65
-
66
- // Audio/Video APIs
67
- 'AudioContext', 'MediaRecorder', 'MediaSource', 'SourceBuffer',
68
- 'HTMLMediaElement', 'HTMLAudioElement', 'HTMLVideoElement',
69
-
70
- // Modern JavaScript APIs
71
- 'structuredClone', 'queueMicrotask', 'reportError',
72
- 'WeakRef', 'FinalizationRegistry', 'AggregateError',
73
-
74
- // Intl APIs
75
- 'Intl', 'DateTimeFormat', 'NumberFormat', 'Collator', 'PluralRules',
76
- 'RelativeTimeFormat', 'ListFormat', 'Locale'
77
- ]);
78
-
79
- canParse(filePath: string): boolean {
80
- return filePath.endsWith('.svelte');
81
- }
82
-
83
- getSupportedExtensions(): string[] {
84
- return ['.svelte'];
85
- }
86
-
87
- getName(): string {
88
- return 'SvelteParser';
89
- }
90
-
91
- async parseFeatures(content: string, filePath: string): Promise<DetectedFeature[]> {
92
- const features: DetectedFeature[] = [];
93
-
94
- try {
95
- // Lazy load Svelte compiler
96
- const svelteCompiler = await LazyLoader.getSvelteCompiler();
97
- const ast = svelteCompiler.parse(content, { filename: filePath });
98
-
99
- // Parse script sections for JavaScript features
100
- if (ast.instance) {
101
- const scriptFeatures = await this.parseScriptSection(
102
- ast.instance,
103
- content,
104
- filePath,
105
- 'instance'
106
- );
107
- features.push(...scriptFeatures);
108
- }
109
-
110
- if (ast.module) {
111
- const moduleFeatures = await this.parseScriptSection(
112
- ast.module,
113
- content,
114
- filePath,
115
- 'module'
116
- );
117
- features.push(...moduleFeatures);
118
- }
119
-
120
- // Parse CSS from style sections
121
- if (ast.css) {
122
- const styleFeatures = await this.parseStyleSection(
123
- ast.css,
124
- content,
125
- filePath
126
- );
127
- features.push(...styleFeatures);
128
- }
129
-
130
- // Parse HTML template for standard elements
131
- if (ast.html) {
132
- const templateFeatures = this.parseTemplateSection(
133
- ast.html,
134
- content,
135
- filePath
136
- );
137
- features.push(...templateFeatures);
138
- }
139
-
140
- } catch (error) {
141
- console.warn(`Warning: Could not parse Svelte file ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
142
- }
143
-
144
- return features;
145
- }
146
-
147
- private async parseScriptSection(
148
- scriptNode: any,
149
- fullContent: string,
150
- filePath: string,
151
- sectionType: 'instance' | 'module'
152
- ): Promise<DetectedFeature[]> {
153
- const features: DetectedFeature[] = [];
154
-
155
- try {
156
- // Extract the script content from the full file
157
- const scriptContent = this.extractScriptContent(scriptNode, fullContent);
158
-
159
- // Determine if TypeScript
160
- const isTypeScript = scriptNode.attributes?.some((attr: any) =>
161
- attr.name === 'lang' && (attr.value[0]?.data === 'ts' || attr.value[0]?.data === 'typescript')
162
- );
163
-
164
- const ast = parseBabel(scriptContent, {
165
- sourceType: 'module',
166
- plugins: [
167
- 'typescript' as any,
168
- 'decorators-legacy' as any,
169
- 'classProperties' as any,
170
- 'objectRestSpread' as any,
171
- 'asyncGenerators' as any,
172
- 'functionBind' as any,
173
- 'exportDefaultFrom',
174
- 'exportNamespaceFrom',
175
- 'dynamicImport',
176
- 'nullishCoalescingOperator',
177
- 'optionalChaining',
178
- 'topLevelAwait'
179
- ].filter(plugin => isTypeScript || plugin !== 'typescript')
180
- });
181
-
182
- traverse(ast, {
183
- // Extract JavaScript Web APIs
184
- MemberExpression: (path: any) => {
185
- const feature = this.extractWebAPIFeature(path.node, scriptContent, scriptNode.start);
186
- if (feature) {
187
- features.push({ ...feature, file: filePath });
188
- }
189
- },
190
-
191
- // Extract function calls to Web APIs
192
- CallExpression: (path: any) => {
193
- const feature = this.extractWebAPICall(path.node, scriptContent, scriptNode.start);
194
- if (feature) {
195
- features.push({ ...feature, file: filePath });
196
- }
197
- },
198
-
199
- // Extract modern JavaScript syntax features
200
- OptionalMemberExpression: (path: any) => {
201
- features.push({
202
- feature: 'optional-chaining',
203
- type: 'js',
204
- context: this.getContext(scriptContent, path.node.loc?.start.line || 0),
205
- line: (path.node.loc?.start.line || 0) + this.getLineOffset(scriptNode.start, fullContent),
206
- column: path.node.loc?.start.column || 0,
207
- file: filePath
208
- });
209
- },
210
-
211
- // Nullish coalescing
212
- LogicalExpression: (path: any) => {
213
- if (path.node.operator === '??') {
214
- features.push({
215
- feature: 'nullish-coalescing',
216
- type: 'js',
217
- context: this.getContext(scriptContent, path.node.loc?.start.line || 0),
218
- line: (path.node.loc?.start.line || 0) + this.getLineOffset(scriptNode.start, fullContent),
219
- column: path.node.loc?.start.column || 0,
220
- file: filePath
221
- });
222
- }
223
- },
224
-
225
- // Private class fields
226
- ClassPrivateProperty: (path: any) => {
227
- features.push({
228
- feature: 'private-fields',
229
- type: 'js',
230
- context: this.getContext(scriptContent, path.node.loc?.start.line || 0),
231
- line: (path.node.loc?.start.line || 0) + this.getLineOffset(scriptNode.start, fullContent),
232
- column: path.node.loc?.start.column || 0,
233
- file: filePath
234
- });
235
- },
236
-
237
- // Top-level await
238
- AwaitExpression: (path: any) => {
239
- if (this.isTopLevelAwait(path)) {
240
- features.push({
241
- feature: 'top-level-await',
242
- type: 'js',
243
- context: this.getContext(scriptContent, path.node.loc?.start.line || 0),
244
- line: (path.node.loc?.start.line || 0) + this.getLineOffset(scriptNode.start, fullContent),
245
- column: path.node.loc?.start.column || 0,
246
- file: filePath
247
- });
248
- }
249
- }
250
- });
251
-
252
- } catch (error) {
253
- console.warn(`Warning: Could not parse ${sectionType} script in ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
254
- }
255
-
256
- return features;
257
- }
258
-
259
- private async parseStyleSection(
260
- styleNode: any,
261
- fullContent: string,
262
- filePath: string
263
- ): Promise<DetectedFeature[]> {
264
- const features: DetectedFeature[] = [];
265
-
266
- try {
267
- const styleContent = this.extractStyleContent(styleNode, fullContent);
268
- const lineOffset = this.getLineOffset(styleNode.start, fullContent);
269
-
270
- const root = postcss.parse(styleContent);
271
-
272
- root.walkDecls((decl: any) => {
273
- features.push({
274
- feature: decl.prop,
275
- type: 'css',
276
- context: `${decl.prop}: ${decl.value}`,
277
- line: (decl.source?.start?.line || 0) + lineOffset,
278
- column: decl.source?.start?.column || 0,
279
- file: filePath
280
- });
281
- });
282
-
283
- root.walkRules((rule: any) => {
284
- // Extract CSS selectors that might be modern features
285
- if (rule.selector.includes(':has(') ||
286
- rule.selector.includes(':is(') ||
287
- rule.selector.includes(':where(') ||
288
- rule.selector.includes(':focus-visible')) {
289
- features.push({
290
- feature: this.extractSelectorFeature(rule.selector),
291
- type: 'css',
292
- context: rule.selector,
293
- line: (rule.source?.start?.line || 0) + lineOffset,
294
- column: rule.source?.start?.column || 0,
295
- file: filePath
296
- });
297
- }
298
- });
299
-
300
- root.walkAtRules((atRule: any) => {
301
- // Extract at-rules like @supports, @container, etc.
302
- features.push({
303
- feature: `@${atRule.name}`,
304
- type: 'css',
305
- context: `@${atRule.name} ${atRule.params}`,
306
- line: (atRule.source?.start?.line || 0) + lineOffset,
307
- column: atRule.source?.start?.column || 0,
308
- file: filePath
309
- });
310
- });
311
-
312
- } catch (error) {
313
- console.warn(`Warning: Could not parse style section in ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
314
- }
315
-
316
- return features;
317
- }
318
-
319
- private parseTemplateSection(
320
- htmlNode: any,
321
- fullContent: string,
322
- filePath: string
323
- ): DetectedFeature[] {
324
- const features: DetectedFeature[] = [];
325
-
326
- try {
327
- // Walk through the HTML AST to find standard HTML elements
328
- this.walkHtmlNode(htmlNode, (node: any) => {
329
- if (node.type === 'Element') {
330
- const tagName = node.name;
331
-
332
- // Check for modern HTML elements
333
- if (this.isModernHTMLElement(tagName)) {
334
- const lineOffset = this.getLineOffset(node.start, fullContent);
335
- features.push({
336
- feature: tagName,
337
- type: 'html',
338
- context: this.getNodeContext(node, fullContent),
339
- line: lineOffset,
340
- column: 0,
341
- file: filePath
342
- });
343
- }
344
-
345
- // Check for modern HTML attributes (ignore Svelte directives)
346
- if (node.attributes) {
347
- node.attributes.forEach((attr: any) => {
348
- if (attr.type === 'Attribute' && !this.isSvelteDirective(attr.name)) {
349
- if (this.isModernHTMLAttribute(attr.name, attr.value)) {
350
- const lineOffset = this.getLineOffset(node.start, fullContent);
351
- features.push({
352
- feature: attr.name,
353
- type: 'html',
354
- context: this.getNodeContext(node, fullContent),
355
- line: lineOffset,
356
- column: 0,
357
- file: filePath
358
- });
359
- }
360
- }
361
- });
362
- }
363
- }
364
- });
365
-
366
- } catch (error) {
367
- console.warn(`Warning: Could not parse template section in ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
368
- }
369
-
370
- return features;
371
- }
372
-
373
- private extractWebAPIFeature(node: t.MemberExpression, content: string, offset: number): DetectedFeature | null {
374
- const apiName = this.getMemberExpressionName(node);
375
-
376
- if (!apiName || this.SVELTE_SPECIFIC_APIS.has(apiName)) {
377
- return null;
378
- }
379
-
380
- if (this.WEB_PLATFORM_APIS.has(apiName)) {
381
- return {
382
- feature: apiName,
383
- type: 'js',
384
- context: this.getContext(content, node.loc?.start.line || 0),
385
- line: (node.loc?.start.line || 0) + this.getLineOffset(offset, content),
386
- column: node.loc?.start.column || 0
387
- };
388
- }
389
-
390
- return null;
391
- }
392
-
393
- private extractWebAPICall(node: t.CallExpression, content: string, offset: number): DetectedFeature | null {
394
- let apiName = '';
395
-
396
- if (t.isIdentifier(node.callee)) {
397
- apiName = node.callee.name;
398
- } else if (t.isMemberExpression(node.callee)) {
399
- apiName = this.getMemberExpressionName(node.callee);
400
- }
401
-
402
- if (!apiName || this.SVELTE_SPECIFIC_APIS.has(apiName)) {
403
- return null;
404
- }
405
-
406
- if (this.WEB_PLATFORM_APIS.has(apiName)) {
407
- return {
408
- feature: apiName,
409
- type: 'js',
410
- context: this.getContext(content, node.loc?.start.line || 0),
411
- line: (node.loc?.start.line || 0) + this.getLineOffset(offset, content),
412
- column: node.loc?.start.column || 0
413
- };
414
- }
415
-
416
- return null;
417
- }
418
-
419
- private extractScriptContent(scriptNode: any, fullContent: string): string {
420
- const start = scriptNode.content.start;
421
- const end = scriptNode.content.end;
422
- return fullContent.slice(start, end);
423
- }
424
-
425
- private extractStyleContent(styleNode: any, fullContent: string): string {
426
- const start = styleNode.content.start;
427
- const end = styleNode.content.end;
428
- return fullContent.slice(start, end);
429
- }
430
-
431
- private getLineOffset(position: number, content: string): number {
432
- return content.slice(0, position).split('\n').length - 1;
433
- }
434
-
435
- private walkHtmlNode(node: any, callback: (node: any) => void): void {
436
- callback(node);
437
- if (node.children) {
438
- node.children.forEach((child: any) => this.walkHtmlNode(child, callback));
439
- }
440
- }
441
-
442
- private getMemberExpressionName(node: t.MemberExpression): string {
443
- const parts: string[] = [];
444
-
445
- const traverse = (n: t.Expression): void => {
446
- if (t.isIdentifier(n)) {
447
- parts.unshift(n.name);
448
- } else if (t.isMemberExpression(n)) {
449
- if (t.isIdentifier(n.property)) {
450
- parts.unshift(n.property.name);
451
- }
452
- traverse(n.object);
453
- }
454
- };
455
-
456
- traverse(node);
457
- return parts.join('.');
458
- }
459
-
460
- private isTopLevelAwait(path: any): boolean {
461
- let parent = path.parent;
462
- while (parent) {
463
- if (t.isFunction(parent) || t.isArrowFunctionExpression(parent)) {
464
- return false;
465
- }
466
- parent = path.parentPath?.parent;
467
- }
468
- return true;
469
- }
470
-
471
- private extractSelectorFeature(selector: string): string {
472
- if (selector.includes(':has(')) return ':has()';
473
- if (selector.includes(':is(')) return ':is()';
474
- if (selector.includes(':where(')) return ':where()';
475
- if (selector.includes(':focus-visible')) return ':focus-visible';
476
- return selector;
477
- }
478
-
479
- private isModernHTMLElement(tagName: string): boolean {
480
- const modernElements = new Set([
481
- 'dialog', 'details', 'summary', 'main', 'article', 'section', 'nav', 'aside',
482
- 'header', 'footer', 'figure', 'figcaption', 'time', 'mark', 'progress', 'meter',
483
- 'canvas', 'video', 'audio', 'source', 'track', 'embed', 'object'
484
- ]);
485
- return modernElements.has(tagName);
486
- }
487
-
488
- private isSvelteDirective(attrName: string): boolean {
489
- return Array.from(this.SVELTE_DIRECTIVES).some((directive: string) => attrName.startsWith(directive));
490
- }
491
-
492
- private isModernHTMLAttribute(attrName: string, _attrValue: any): boolean {
493
- const modernAttrs = new Set([
494
- 'loading', 'decoding', 'fetchpriority', 'enterkeyhint', 'inputmode'
495
- ]);
496
- return modernAttrs.has(attrName);
497
- }
498
-
499
- private getNodeContext(node: any, fullContent: string): string {
500
- const start = node.start;
501
- const end = Math.min(node.end, start + 100); // Limit context length
502
- return fullContent.slice(start, end).trim();
503
- }
504
-
505
- private getContext(content: string, line: number): string {
506
- const lines = content.split('\n');
507
- const targetLine = lines[line - 1] || '';
508
- return targetLine.trim();
509
- }
510
- }