skrypt-ai 0.4.1 → 0.5.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.
Files changed (61) hide show
  1. package/dist/auth/index.d.ts +13 -3
  2. package/dist/auth/index.js +94 -9
  3. package/dist/auth/keychain.d.ts +5 -0
  4. package/dist/auth/keychain.js +82 -0
  5. package/dist/auth/notices.d.ts +3 -0
  6. package/dist/auth/notices.js +42 -0
  7. package/dist/autofix/index.js +10 -3
  8. package/dist/cli.js +16 -3
  9. package/dist/commands/generate.js +37 -1
  10. package/dist/commands/import.d.ts +2 -0
  11. package/dist/commands/import.js +157 -0
  12. package/dist/commands/init.js +19 -7
  13. package/dist/commands/login.js +15 -4
  14. package/dist/commands/review-pr.js +10 -0
  15. package/dist/commands/security.d.ts +2 -0
  16. package/dist/commands/security.js +103 -0
  17. package/dist/config/loader.js +2 -2
  18. package/dist/generator/writer.js +12 -3
  19. package/dist/importers/confluence.d.ts +5 -0
  20. package/dist/importers/confluence.js +137 -0
  21. package/dist/importers/detect.d.ts +20 -0
  22. package/dist/importers/detect.js +121 -0
  23. package/dist/importers/docusaurus.d.ts +5 -0
  24. package/dist/importers/docusaurus.js +279 -0
  25. package/dist/importers/gitbook.d.ts +5 -0
  26. package/dist/importers/gitbook.js +189 -0
  27. package/dist/importers/github.d.ts +8 -0
  28. package/dist/importers/github.js +99 -0
  29. package/dist/importers/index.d.ts +15 -0
  30. package/dist/importers/index.js +30 -0
  31. package/dist/importers/markdown.d.ts +6 -0
  32. package/dist/importers/markdown.js +105 -0
  33. package/dist/importers/mintlify.d.ts +5 -0
  34. package/dist/importers/mintlify.js +172 -0
  35. package/dist/importers/notion.d.ts +5 -0
  36. package/dist/importers/notion.js +174 -0
  37. package/dist/importers/readme.d.ts +5 -0
  38. package/dist/importers/readme.js +184 -0
  39. package/dist/importers/transform.d.ts +90 -0
  40. package/dist/importers/transform.js +457 -0
  41. package/dist/importers/types.d.ts +37 -0
  42. package/dist/importers/types.js +1 -0
  43. package/dist/plugins/index.js +7 -0
  44. package/dist/scanner/index.js +37 -24
  45. package/dist/scanner/python.js +17 -0
  46. package/dist/template/public/search-index.json +1 -1
  47. package/dist/template/scripts/build-search-index.mjs +67 -9
  48. package/dist/template/src/components/mdx/dark-image.tsx +56 -0
  49. package/dist/template/src/components/mdx/frame.tsx +64 -0
  50. package/dist/template/src/components/mdx/highlighted-code.tsx +145 -31
  51. package/dist/template/src/components/mdx/index.tsx +4 -0
  52. package/dist/template/src/components/mdx/link-preview.tsx +119 -0
  53. package/dist/template/src/components/mdx/tooltip.tsx +101 -0
  54. package/dist/template/src/components/syntax-theme-selector.tsx +167 -20
  55. package/dist/template/src/lib/search-types.ts +4 -1
  56. package/dist/template/src/lib/search.ts +30 -7
  57. package/dist/template/src/styles/globals.css +39 -0
  58. package/dist/utils/files.d.ts +9 -1
  59. package/dist/utils/files.js +59 -10
  60. package/dist/utils/validation.js +1 -1
  61. package/package.json +4 -1
@@ -1,5 +1,5 @@
1
1
  import { readdir, stat } from 'fs/promises';
2
- import { join, extname, parse as parsePath } from 'path';
2
+ import { join, parse as parsePath } from 'path';
3
3
  import { PythonScanner } from './python.js';
4
4
  import { TypeScriptScanner } from './typescript.js';
5
5
  import { GoScanner } from './go.js';
@@ -24,25 +24,30 @@ function getScannerForFile(filePath) {
24
24
  }
25
25
  return null;
26
26
  }
27
+ /**
28
+ * Convert a glob pattern to a RegExp for proper matching.
29
+ * Supports: ** (any path), * (any segment), ? (any char)
30
+ */
31
+ function globToRegex(pattern) {
32
+ // Normalize separators
33
+ let re = pattern.replace(/\\/g, '/');
34
+ // Escape regex special chars except * and ?
35
+ re = re.replace(/[.+^${}()|[\]\\]/g, '\\$&');
36
+ // Convert glob tokens to regex
37
+ re = re.replace(/\*\*/g, '\0GLOBSTAR\0');
38
+ re = re.replace(/\*/g, '[^/]*');
39
+ re = re.replace(/\?/g, '[^/]');
40
+ re = re.replace(/\0GLOBSTAR\0/g, '.*');
41
+ return new RegExp(`(^|/)${re}($|/)`);
42
+ }
27
43
  /**
28
44
  * Check if a path should be excluded based on patterns
29
45
  */
30
46
  function shouldExclude(filePath, excludePatterns) {
47
+ const normalized = filePath.replace(/\\/g, '/');
31
48
  for (const pattern of excludePatterns) {
32
- // Simple glob matching for common patterns
33
- if (pattern.includes('**')) {
34
- const parts = pattern.split('**');
35
- if (parts.length === 2) {
36
- const [prefix, suffix] = parts;
37
- const prefixMatch = !prefix || filePath.includes(prefix.replace(/^\//, '').replace(/\/$/, ''));
38
- const suffixMatch = !suffix || filePath.includes(suffix.replace(/^\//, '').replace(/\/$/, ''));
39
- if (prefixMatch && suffixMatch)
40
- return true;
41
- }
42
- }
43
- else if (filePath.includes(pattern.replace(/\*/g, ''))) {
49
+ if (globToRegex(pattern).test(normalized))
44
50
  return true;
45
- }
46
51
  }
47
52
  return false;
48
53
  }
@@ -52,31 +57,39 @@ function shouldExclude(filePath, excludePatterns) {
52
57
  function shouldInclude(filePath, includePatterns) {
53
58
  if (includePatterns.length === 0)
54
59
  return true;
55
- const ext = extname(filePath);
60
+ const normalized = filePath.replace(/\\/g, '/');
56
61
  for (const pattern of includePatterns) {
57
- // Match extension patterns like **/*.py
58
- if (pattern.includes('*')) {
59
- const extPattern = pattern.split('*').pop() || '';
60
- if (ext === extPattern)
61
- return true;
62
- }
62
+ if (globToRegex(pattern).test(normalized))
63
+ return true;
63
64
  }
64
65
  return false;
65
66
  }
67
+ const MAX_SCAN_DEPTH = 30;
68
+ const MAX_SCAN_FILES = 10000;
66
69
  /**
67
70
  * Recursively find all files in a directory
68
71
  */
69
72
  async function findFiles(dir, include, exclude) {
70
73
  const files = [];
71
- async function walk(currentDir) {
74
+ async function walk(currentDir, depth) {
75
+ if (depth > MAX_SCAN_DEPTH)
76
+ return;
77
+ if (files.length >= MAX_SCAN_FILES)
78
+ return;
72
79
  const entries = await readdir(currentDir, { withFileTypes: true });
73
80
  for (const entry of entries) {
81
+ if (files.length >= MAX_SCAN_FILES)
82
+ return;
74
83
  const fullPath = join(currentDir, entry.name);
75
84
  if (shouldExclude(fullPath, exclude)) {
76
85
  continue;
77
86
  }
87
+ // Skip symlinks to prevent infinite loops and path escape
88
+ if (entry.isSymbolicLink()) {
89
+ continue;
90
+ }
78
91
  if (entry.isDirectory()) {
79
- await walk(fullPath);
92
+ await walk(fullPath, depth + 1);
80
93
  }
81
94
  else if (entry.isFile()) {
82
95
  if (shouldInclude(fullPath, include) && getScannerForFile(fullPath)) {
@@ -85,7 +98,7 @@ async function findFiles(dir, include, exclude) {
85
98
  }
86
99
  }
87
100
  }
88
- await walk(dir);
101
+ await walk(dir, 0);
89
102
  return files;
90
103
  }
91
104
  /**
@@ -15,6 +15,12 @@ export class PythonScanner {
15
15
  });
16
16
  let stdout = '';
17
17
  let stderr = '';
18
+ let killed = false;
19
+ // Kill the process after 30 seconds to prevent hangs
20
+ const timeout = setTimeout(() => {
21
+ killed = true;
22
+ proc.kill('SIGKILL');
23
+ }, 30000);
18
24
  proc.stdout.on('data', (data) => {
19
25
  stdout += data.toString();
20
26
  });
@@ -22,6 +28,16 @@ export class PythonScanner {
22
28
  stderr += data.toString();
23
29
  });
24
30
  proc.on('close', (code) => {
31
+ clearTimeout(timeout);
32
+ if (killed) {
33
+ resolve({
34
+ filePath,
35
+ language: 'python',
36
+ elements: [],
37
+ errors: [`Python parser timed out after 30s: ${filePath}`]
38
+ });
39
+ return;
40
+ }
25
41
  if (code !== 0 || stderr) {
26
42
  resolve({
27
43
  filePath,
@@ -45,6 +61,7 @@ export class PythonScanner {
45
61
  }
46
62
  });
47
63
  proc.on('error', (err) => {
64
+ clearTimeout(timeout);
48
65
  resolve({
49
66
  filePath,
50
67
  language: 'python',