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.
- package/dist/auth/index.d.ts +13 -3
- package/dist/auth/index.js +94 -9
- package/dist/auth/keychain.d.ts +5 -0
- package/dist/auth/keychain.js +82 -0
- package/dist/auth/notices.d.ts +3 -0
- package/dist/auth/notices.js +42 -0
- package/dist/autofix/index.js +10 -3
- package/dist/cli.js +16 -3
- package/dist/commands/generate.js +37 -1
- package/dist/commands/import.d.ts +2 -0
- package/dist/commands/import.js +157 -0
- package/dist/commands/init.js +19 -7
- package/dist/commands/login.js +15 -4
- package/dist/commands/review-pr.js +10 -0
- package/dist/commands/security.d.ts +2 -0
- package/dist/commands/security.js +103 -0
- package/dist/config/loader.js +2 -2
- package/dist/generator/writer.js +12 -3
- package/dist/importers/confluence.d.ts +5 -0
- package/dist/importers/confluence.js +137 -0
- package/dist/importers/detect.d.ts +20 -0
- package/dist/importers/detect.js +121 -0
- package/dist/importers/docusaurus.d.ts +5 -0
- package/dist/importers/docusaurus.js +279 -0
- package/dist/importers/gitbook.d.ts +5 -0
- package/dist/importers/gitbook.js +189 -0
- package/dist/importers/github.d.ts +8 -0
- package/dist/importers/github.js +99 -0
- package/dist/importers/index.d.ts +15 -0
- package/dist/importers/index.js +30 -0
- package/dist/importers/markdown.d.ts +6 -0
- package/dist/importers/markdown.js +105 -0
- package/dist/importers/mintlify.d.ts +5 -0
- package/dist/importers/mintlify.js +172 -0
- package/dist/importers/notion.d.ts +5 -0
- package/dist/importers/notion.js +174 -0
- package/dist/importers/readme.d.ts +5 -0
- package/dist/importers/readme.js +184 -0
- package/dist/importers/transform.d.ts +90 -0
- package/dist/importers/transform.js +457 -0
- package/dist/importers/types.d.ts +37 -0
- package/dist/importers/types.js +1 -0
- package/dist/plugins/index.js +7 -0
- package/dist/scanner/index.js +37 -24
- package/dist/scanner/python.js +17 -0
- package/dist/template/public/search-index.json +1 -1
- package/dist/template/scripts/build-search-index.mjs +67 -9
- package/dist/template/src/components/mdx/dark-image.tsx +56 -0
- package/dist/template/src/components/mdx/frame.tsx +64 -0
- package/dist/template/src/components/mdx/highlighted-code.tsx +145 -31
- package/dist/template/src/components/mdx/index.tsx +4 -0
- package/dist/template/src/components/mdx/link-preview.tsx +119 -0
- package/dist/template/src/components/mdx/tooltip.tsx +101 -0
- package/dist/template/src/components/syntax-theme-selector.tsx +167 -20
- package/dist/template/src/lib/search-types.ts +4 -1
- package/dist/template/src/lib/search.ts +30 -7
- package/dist/template/src/styles/globals.css +39 -0
- package/dist/utils/files.d.ts +9 -1
- package/dist/utils/files.js +59 -10
- package/dist/utils/validation.js +1 -1
- package/package.json +4 -1
package/dist/scanner/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readdir, stat } from 'fs/promises';
|
|
2
|
-
import { join,
|
|
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
|
-
|
|
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
|
|
60
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
56
61
|
for (const pattern of includePatterns) {
|
|
57
|
-
|
|
58
|
-
|
|
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
|
/**
|
package/dist/scanner/python.js
CHANGED
|
@@ -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',
|